diff --git a/asset-manifest.json b/asset-manifest.json index 197b21c..11ddf26 100644 --- a/asset-manifest.json +++ b/asset-manifest.json @@ -1,7 +1,7 @@ { "files": { "main.css": "./static/css/main.352fe986.css", - "main.js": "./static/js/main.f7cc68be.js", + "main.js": "./static/js/main.abd1e4ad.js", "static/js/787.cf5efa72.chunk.js": "./static/js/787.cf5efa72.chunk.js", "demo/libs/gemini-viewer.esm.min.js": "./demo/libs/gemini-viewer.esm.min.js", "static/media/dwg_background.png": "./static/media/dwg_background.f630e7cda68e19172eec.png", @@ -9,8 +9,8 @@ "demo/libs/types/core/camera-controls/CameraControls.d.ts": "./demo/libs/types/core/camera-controls/CameraControls.d.ts", "demo/libs/types/core/dxf/DxfLoader.d.ts": "./demo/libs/types/core/dxf/DxfLoader.d.ts", "demo/libs/types/core/viewers/BimViewer.d.ts": "./demo/libs/types/core/viewers/BimViewer.d.ts", - "demo/libs/types/core/utils/ObjectUtils.d.ts": "./demo/libs/types/core/utils/ObjectUtils.d.ts", "demo/libs/types/core/Configs.d.ts": "./demo/libs/types/core/Configs.d.ts", + "demo/libs/types/core/utils/ObjectUtils.d.ts": "./demo/libs/types/core/utils/ObjectUtils.d.ts", "demo/libs/types/plugins/pdf/PdfLoader.d.ts": "./demo/libs/types/plugins/pdf/PdfLoader.d.ts", "demo/libs/types/core/dxf-parser/DxfParser.d.ts": "./demo/libs/types/core/dxf-parser/DxfParser.d.ts", "demo/libs/types/core/viewers/VRViewer.d.ts": "./demo/libs/types/core/viewers/VRViewer.d.ts", @@ -22,8 +22,8 @@ "demo/libs/types/core/utils/Locale.d.ts": "./demo/libs/types/core/utils/Locale.d.ts", "demo/libs/types/plugins/sections/BaseBoxSection.d.ts": "./demo/libs/types/plugins/sections/BaseBoxSection.d.ts", "demo/libs/types/core/dxf/DxfCompare.d.ts": "./demo/libs/types/core/dxf/DxfCompare.d.ts", - "demo/libs/types/core/utils/CommonUtils.d.ts": "./demo/libs/types/core/utils/CommonUtils.d.ts", "demo/libs/types/core/viewers/SimplifiedBimViewer.d.ts": "./demo/libs/types/core/viewers/SimplifiedBimViewer.d.ts", + "demo/libs/types/core/utils/CommonUtils.d.ts": "./demo/libs/types/core/utils/CommonUtils.d.ts", "demo/libs/types/core/utils/MergeUtils.d.ts": "./demo/libs/types/core/utils/MergeUtils.d.ts", "demo/libs/types/plugins/measure/BaseMeasurement.d.ts": "./demo/libs/types/plugins/measure/BaseMeasurement.d.ts", "demo/libs/types/plugins/measure/MeasurementPlugin.d.ts": "./demo/libs/types/plugins/measure/MeasurementPlugin.d.ts", @@ -39,8 +39,8 @@ "demo/libs/types/core/dxf-parser/entities/mleader.d.ts": "./demo/libs/types/core/dxf-parser/entities/mleader.d.ts", "demo/libs/types/core/dxf/DxfUtils.d.ts": "./demo/libs/types/core/dxf/DxfUtils.d.ts", "demo/libs/types/core/compare/DxfCompareHelper.d.ts": "./demo/libs/types/core/compare/DxfCompareHelper.d.ts", - "demo/libs/types/core/dxf-parser/entities/hatch.d.ts": "./demo/libs/types/core/dxf-parser/entities/hatch.d.ts", "demo/libs/types/plugins/toolbars/Toolbar.constants.d.ts": "./demo/libs/types/plugins/toolbars/Toolbar.constants.d.ts", + "demo/libs/types/core/dxf-parser/entities/hatch.d.ts": "./demo/libs/types/core/dxf-parser/entities/hatch.d.ts", "demo/libs/types/core/canvas/Drawable.d.ts": "./demo/libs/types/core/canvas/Drawable.d.ts", "demo/libs/types/core/font/FontManager.d.ts": "./demo/libs/types/core/font/FontManager.d.ts", "demo/libs/types/plugins/screenshot/ScreenshotPlugin.d.ts": "./demo/libs/types/plugins/screenshot/ScreenshotPlugin.d.ts", @@ -70,6 +70,7 @@ "demo/libs/types/plugins/measure/BaseMeasureDrawable.d.ts": "./demo/libs/types/plugins/measure/BaseMeasureDrawable.d.ts", "demo/libs/types/plugins/bottom-bar/BottomBarPlugin.d.ts": "./demo/libs/types/plugins/bottom-bar/BottomBarPlugin.d.ts", "demo/libs/types/core/utils/MaterialUtils.d.ts": "./demo/libs/types/core/utils/MaterialUtils.d.ts", + "demo/libs/types/plugins/overview-map/TextDrawable.d.ts": "./demo/libs/types/plugins/overview-map/TextDrawable.d.ts", "demo/libs/types/core/vr/BaseVRMesh.d.ts": "./demo/libs/types/core/vr/BaseVRMesh.d.ts", "demo/libs/types/plugins/explode/ExplodePlugin.d.ts": "./demo/libs/types/plugins/explode/ExplodePlugin.d.ts", "demo/libs/types/core/dxf-parser/entities/viewport.d.ts": "./demo/libs/types/core/dxf-parser/entities/viewport.d.ts", @@ -78,19 +79,18 @@ "demo/libs/types/core/dxf-parser/entities/geomtry.d.ts": "./demo/libs/types/core/dxf-parser/entities/geomtry.d.ts", "demo/libs/types/plugins/axis-gizmo/AxisGizmoPlugin.d.ts": "./demo/libs/types/plugins/axis-gizmo/AxisGizmoPlugin.d.ts", "demo/libs/types/core/geometry-offset/Offset.d.ts": "./demo/libs/types/core/geometry-offset/Offset.d.ts", + "demo/libs/types/export.doc.d.ts": "./demo/libs/types/export.doc.d.ts", "demo/libs/types/plugins/sections/AxisPlaneSection.d.ts": "./demo/libs/types/plugins/sections/AxisPlaneSection.d.ts", "demo/libs/types/core/vr/VRCube24Faces.d.ts": "./demo/libs/types/core/vr/VRCube24Faces.d.ts", "demo/libs/types/plugins/sections/SectionGizmo.d.ts": "./demo/libs/types/plugins/sections/SectionGizmo.d.ts", - "demo/libs/types/export.doc.d.ts": "./demo/libs/types/export.doc.d.ts", + "demo/libs/types/plugins/overview-map/ImageDrawable.d.ts": "./demo/libs/types/plugins/overview-map/ImageDrawable.d.ts", "demo/libs/types/plugins/sections/ObjectsBoxSection.d.ts": "./demo/libs/types/plugins/sections/ObjectsBoxSection.d.ts", "demo/libs/types/plugins/nav-cube/NavCubePlugin.d.ts": "./demo/libs/types/plugins/nav-cube/NavCubePlugin.d.ts", "demo/libs/types/plugins/ground-grass/GroundGrassPlugin.d.ts": "./demo/libs/types/plugins/ground-grass/GroundGrassPlugin.d.ts", "demo/libs/types/core/font/BaseFont.d.ts": "./demo/libs/types/core/font/BaseFont.d.ts", "demo/libs/types/plugins/ground-grid/GroundGridPlugin.d.ts": "./demo/libs/types/plugins/ground-grid/GroundGridPlugin.d.ts", - "demo/libs/types/plugins/overview-map/ImageDrawable.d.ts": "./demo/libs/types/plugins/overview-map/ImageDrawable.d.ts", "demo/libs/types/core/helpers/ControlsHelper.d.ts": "./demo/libs/types/core/helpers/ControlsHelper.d.ts", "demo/libs/types/core/camera-controls/EventDispatcher.d.ts": "./demo/libs/types/core/camera-controls/EventDispatcher.d.ts", - "demo/libs/types/plugins/overview-map/TextDrawable.d.ts": "./demo/libs/types/plugins/overview-map/TextDrawable.d.ts", "demo/libs/types/plugins/measure/AreaMeasurement.d.ts": "./demo/libs/types/plugins/measure/AreaMeasurement.d.ts", "demo/libs/types/core/font/shx/util/BitConverter.d.ts": "./demo/libs/types/core/font/shx/util/BitConverter.d.ts", "demo/libs/types/core/markup/BaseMarkup.d.ts": "./demo/libs/types/core/markup/BaseMarkup.d.ts", @@ -126,8 +126,8 @@ "demo/libs/types/core/dxf-parser/objects/layout.d.ts": "./demo/libs/types/core/dxf-parser/objects/layout.d.ts", "demo/libs/types/plugins/measure/AngleMeasurement.d.ts": "./demo/libs/types/plugins/measure/AngleMeasurement.d.ts", "demo/libs/types/plugins/sections/GlobalPlaneSection.d.ts": "./demo/libs/types/plugins/sections/GlobalPlaneSection.d.ts", - "demo/libs/types/plugins/measure/CoordinateMeasurement.d.ts": "./demo/libs/types/plugins/measure/CoordinateMeasurement.d.ts", "demo/libs/types/plugins/toolbars/BimViewerToolbarPlugin.d.ts": "./demo/libs/types/plugins/toolbars/BimViewerToolbarPlugin.d.ts", + "demo/libs/types/plugins/measure/CoordinateMeasurement.d.ts": "./demo/libs/types/plugins/measure/CoordinateMeasurement.d.ts", "demo/libs/types/core/canvas/Constants.d.ts": "./demo/libs/types/core/canvas/Constants.d.ts", "demo/libs/types/core/utils/Viewer3DUtils.d.ts": "./demo/libs/types/core/utils/Viewer3DUtils.d.ts", "demo/libs/types/core/font/shx/TextShape.d.ts": "./demo/libs/types/core/font/shx/TextShape.d.ts", @@ -151,6 +151,7 @@ "demo/libs/types/plugins/measure/DistanceMeasureDrawable.d.ts": "./demo/libs/types/plugins/measure/DistanceMeasureDrawable.d.ts", "demo/libs/types/plugins/overview-map/LineDrawable.d.ts": "./demo/libs/types/plugins/overview-map/LineDrawable.d.ts", "demo/libs/types/core/utils/ColorUtils.d.ts": "./demo/libs/types/core/utils/ColorUtils.d.ts", + "demo/libs/types/plugins/local-model-uploader/LocalDxfUploader.d.ts": "./demo/libs/types/plugins/local-model-uploader/LocalDxfUploader.d.ts", "demo/libs/types/plugins/pdf/PdfLoaderPlugin.d.ts": "./demo/libs/types/plugins/pdf/PdfLoaderPlugin.d.ts", "demo/libs/types/core/dxf-parser/entities/vertex.d.ts": "./demo/libs/types/core/dxf-parser/entities/vertex.d.ts", "demo/libs/types/core/font/shx/ShxParser.d.ts": "./demo/libs/types/core/font/shx/ShxParser.d.ts", @@ -169,7 +170,6 @@ "demo/libs/types/core/index.d.ts": "./demo/libs/types/core/index.d.ts", "demo/libs/types/core/utils/UnitConversionUtils.d.ts": "./demo/libs/types/core/utils/UnitConversionUtils.d.ts", "demo/libs/types/core/helpers/RafHelper.d.ts": "./demo/libs/types/core/helpers/RafHelper.d.ts", - "demo/libs/types/plugins/local-model-uploader/LocalDxfUploader.d.ts": "./demo/libs/types/plugins/local-model-uploader/LocalDxfUploader.d.ts", "demo/libs/types/core/font/MeshFont.d.ts": "./demo/libs/types/core/font/MeshFont.d.ts", "demo/libs/types/core/compare/CompareDrawable.d.ts": "./demo/libs/types/core/compare/CompareDrawable.d.ts", "demo/libs/types/core/utils/CSS2DObjectUtils.d.ts": "./demo/libs/types/core/utils/CSS2DObjectUtils.d.ts", @@ -219,6 +219,7 @@ "demo/libs/types/core/dxf-parser/AutoCadColorIndex.d.ts": "./demo/libs/types/core/dxf-parser/AutoCadColorIndex.d.ts", "demo/libs/types/plugins/sections/Section.constants.d.ts": "./demo/libs/types/plugins/sections/Section.constants.d.ts", "demo/libs/types/core/dxf-parser/entities/point.d.ts": "./demo/libs/types/core/dxf-parser/entities/point.d.ts", + "demo/libs/types/core/patches/shaders/shaderChunk/outine_bc_vertex.glsl.d.ts": "./demo/libs/types/core/patches/shaders/shaderChunk/outine_bc_vertex.glsl.d.ts", "demo/libs/types/core/dxf-parser/entities/region.d.ts": "./demo/libs/types/core/dxf-parser/entities/region.d.ts", "demo/libs/types/core/dxf-parser/entities/solid.d.ts": "./demo/libs/types/core/dxf-parser/entities/solid.d.ts", "demo/libs/types/core/dxf-parser/entities/xline.d.ts": "./demo/libs/types/core/dxf-parser/entities/xline.d.ts", @@ -263,7 +264,6 @@ "demo/libs/types/core/undo-redo/Command.d.ts": "./demo/libs/types/core/undo-redo/Command.d.ts", "demo/libs/types/core/compare/index.d.ts": "./demo/libs/types/core/compare/index.d.ts", "demo/libs/types/core/patches/index.d.ts": "./demo/libs/types/core/patches/index.d.ts", - "demo/libs/types/core/patches/shaders/shaderChunk/outine_bc_vertex.glsl.d.ts": "./demo/libs/types/core/patches/shaders/shaderChunk/outine_bc_vertex.glsl.d.ts", "demo/libs/types/core/canvas/index.d.ts": "./demo/libs/types/core/canvas/index.d.ts", "demo/libs/types/core/vr/index.d.ts": "./demo/libs/types/core/vr/index.d.ts", "demo/libs/types/core/utils/DecimalPrecisionUtils.d.ts": "./demo/libs/types/core/utils/DecimalPrecisionUtils.d.ts", @@ -313,11 +313,11 @@ "demo/libs/types/core/webcam/index.d.ts": "./demo/libs/types/core/webcam/index.d.ts", "demo/libs/types/core/workers/CreateMeshBvh.worker.d.ts": "./demo/libs/types/core/workers/CreateMeshBvh.worker.d.ts", "main.352fe986.css.map": "./static/css/main.352fe986.css.map", - "main.f7cc68be.js.map": "./static/js/main.f7cc68be.js.map", + "main.abd1e4ad.js.map": "./static/js/main.abd1e4ad.js.map", "787.cf5efa72.chunk.js.map": "./static/js/787.cf5efa72.chunk.js.map" }, "entrypoints": [ "static/css/main.352fe986.css", - "static/js/main.f7cc68be.js" + "static/js/main.abd1e4ad.js" ] } \ No newline at end of file diff --git a/demo/bim_2_overlay_with_dxf.html b/demo/bim_2_overlay_with_dxf.html index 15b6c14..2904cbe 100644 --- a/demo/bim_2_overlay_with_dxf.html +++ b/demo/bim_2_overlay_with_dxf.html @@ -24,6 +24,8 @@ NavCubePlugin, SectionPlugin, } from "./demo/libs/gemini-viewer.esm.min.js"; + import * as dat from "./demo/libs/dat.gui.module.js"; + const gui = new dat.GUI(); const project = { "id": "building1", @@ -82,6 +84,22 @@ // viewer.setToOrthographicCamera(false); }); }); + + // dat.gui controls + const controls = { + dxfElevation: 0, + } + // update dxf elevation between -2 to 30, default value is 17. + gui.add(controls, "dxfElevation", -2.0, 30.0, 0.1) + .name("Dxf elevation") + .setValue(17) // the origin value is 17 + .onChange((val) => { + const dxf = viewer.loadedModels.find((model) => model.modelId.endsWith(".dxf")); + const object = dxf.object; + object.position.setY(val); + object.updateMatrix(); + viewer.enableRender(); + }); diff --git a/demo/bim_3_explode.html b/demo/bim_3_explode.html index 1963bcf..cdd79ae 100644 --- a/demo/bim_3_explode.html +++ b/demo/bim_3_explode.html @@ -31,7 +31,6 @@ const viewerCfg = { containerId: "myCanvas", language: "en", - enableToolbar: false, } const viewer = new BimViewer(viewerCfg); diff --git a/demo/libs/dat.gui.module.js b/demo/libs/dat.gui.module.js new file mode 100644 index 0000000..3ed1379 --- /dev/null +++ b/demo/libs/dat.gui.module.js @@ -0,0 +1,2524 @@ +/** + * dat-gui JavaScript Controller Library + * https://github.com/dataarts/dat.gui + * + * Copyright 2011 Data Arts Team, Google Creative Lab + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + */ + +function ___$insertStyle(css) { + if (!css) { + return; + } + if (typeof window === 'undefined') { + return; + } + + var style = document.createElement('style'); + + style.setAttribute('type', 'text/css'); + style.innerHTML = css; + document.head.appendChild(style); + + return css; +} + +function colorToString (color, forceCSSHex) { + var colorFormat = color.__state.conversionName.toString(); + var r = Math.round(color.r); + var g = Math.round(color.g); + var b = Math.round(color.b); + var a = color.a; + var h = Math.round(color.h); + var s = color.s.toFixed(1); + var v = color.v.toFixed(1); + if (forceCSSHex || colorFormat === 'THREE_CHAR_HEX' || colorFormat === 'SIX_CHAR_HEX') { + var str = color.hex.toString(16); + while (str.length < 6) { + str = '0' + str; + } + return '#' + str; + } else if (colorFormat === 'CSS_RGB') { + return 'rgb(' + r + ',' + g + ',' + b + ')'; + } else if (colorFormat === 'CSS_RGBA') { + return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')'; + } else if (colorFormat === 'HEX') { + return '0x' + color.hex.toString(16); + } else if (colorFormat === 'RGB_ARRAY') { + return '[' + r + ',' + g + ',' + b + ']'; + } else if (colorFormat === 'RGBA_ARRAY') { + return '[' + r + ',' + g + ',' + b + ',' + a + ']'; + } else if (colorFormat === 'RGB_OBJ') { + return '{r:' + r + ',g:' + g + ',b:' + b + '}'; + } else if (colorFormat === 'RGBA_OBJ') { + return '{r:' + r + ',g:' + g + ',b:' + b + ',a:' + a + '}'; + } else if (colorFormat === 'HSV_OBJ') { + return '{h:' + h + ',s:' + s + ',v:' + v + '}'; + } else if (colorFormat === 'HSVA_OBJ') { + return '{h:' + h + ',s:' + s + ',v:' + v + ',a:' + a + '}'; + } + return 'unknown format'; +} + +var ARR_EACH = Array.prototype.forEach; +var ARR_SLICE = Array.prototype.slice; +var Common = { + BREAK: {}, + extend: function extend(target) { + this.each(ARR_SLICE.call(arguments, 1), function (obj) { + var keys = this.isObject(obj) ? Object.keys(obj) : []; + keys.forEach(function (key) { + if (!this.isUndefined(obj[key])) { + target[key] = obj[key]; + } + }.bind(this)); + }, this); + return target; + }, + defaults: function defaults(target) { + this.each(ARR_SLICE.call(arguments, 1), function (obj) { + var keys = this.isObject(obj) ? Object.keys(obj) : []; + keys.forEach(function (key) { + if (this.isUndefined(target[key])) { + target[key] = obj[key]; + } + }.bind(this)); + }, this); + return target; + }, + compose: function compose() { + var toCall = ARR_SLICE.call(arguments); + return function () { + var args = ARR_SLICE.call(arguments); + for (var i = toCall.length - 1; i >= 0; i--) { + args = [toCall[i].apply(this, args)]; + } + return args[0]; + }; + }, + each: function each(obj, itr, scope) { + if (!obj) { + return; + } + if (ARR_EACH && obj.forEach && obj.forEach === ARR_EACH) { + obj.forEach(itr, scope); + } else if (obj.length === obj.length + 0) { + var key = void 0; + var l = void 0; + for (key = 0, l = obj.length; key < l; key++) { + if (key in obj && itr.call(scope, obj[key], key) === this.BREAK) { + return; + } + } + } else { + for (var _key in obj) { + if (itr.call(scope, obj[_key], _key) === this.BREAK) { + return; + } + } + } + }, + defer: function defer(fnc) { + setTimeout(fnc, 0); + }, + debounce: function debounce(func, threshold, callImmediately) { + var timeout = void 0; + return function () { + var obj = this; + var args = arguments; + function delayed() { + timeout = null; + if (!callImmediately) func.apply(obj, args); + } + var callNow = callImmediately || !timeout; + clearTimeout(timeout); + timeout = setTimeout(delayed, threshold); + if (callNow) { + func.apply(obj, args); + } + }; + }, + toArray: function toArray(obj) { + if (obj.toArray) return obj.toArray(); + return ARR_SLICE.call(obj); + }, + isUndefined: function isUndefined(obj) { + return obj === undefined; + }, + isNull: function isNull(obj) { + return obj === null; + }, + isNaN: function (_isNaN) { + function isNaN(_x) { + return _isNaN.apply(this, arguments); + } + isNaN.toString = function () { + return _isNaN.toString(); + }; + return isNaN; + }(function (obj) { + return isNaN(obj); + }), + isArray: Array.isArray || function (obj) { + return obj.constructor === Array; + }, + isObject: function isObject(obj) { + return obj === Object(obj); + }, + isNumber: function isNumber(obj) { + return obj === obj + 0; + }, + isString: function isString(obj) { + return obj === obj + ''; + }, + isBoolean: function isBoolean(obj) { + return obj === false || obj === true; + }, + isFunction: function isFunction(obj) { + return obj instanceof Function; + } +}; + +var INTERPRETATIONS = [ +{ + litmus: Common.isString, + conversions: { + THREE_CHAR_HEX: { + read: function read(original) { + var test = original.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i); + if (test === null) { + return false; + } + return { + space: 'HEX', + hex: parseInt('0x' + test[1].toString() + test[1].toString() + test[2].toString() + test[2].toString() + test[3].toString() + test[3].toString(), 0) + }; + }, + write: colorToString + }, + SIX_CHAR_HEX: { + read: function read(original) { + var test = original.match(/^#([A-F0-9]{6})$/i); + if (test === null) { + return false; + } + return { + space: 'HEX', + hex: parseInt('0x' + test[1].toString(), 0) + }; + }, + write: colorToString + }, + CSS_RGB: { + read: function read(original) { + var test = original.match(/^rgb\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/); + if (test === null) { + return false; + } + return { + space: 'RGB', + r: parseFloat(test[1]), + g: parseFloat(test[2]), + b: parseFloat(test[3]) + }; + }, + write: colorToString + }, + CSS_RGBA: { + read: function read(original) { + var test = original.match(/^rgba\(\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*,\s*(\S+)\s*\)/); + if (test === null) { + return false; + } + return { + space: 'RGB', + r: parseFloat(test[1]), + g: parseFloat(test[2]), + b: parseFloat(test[3]), + a: parseFloat(test[4]) + }; + }, + write: colorToString + } + } +}, +{ + litmus: Common.isNumber, + conversions: { + HEX: { + read: function read(original) { + return { + space: 'HEX', + hex: original, + conversionName: 'HEX' + }; + }, + write: function write(color) { + return color.hex; + } + } + } +}, +{ + litmus: Common.isArray, + conversions: { + RGB_ARRAY: { + read: function read(original) { + if (original.length !== 3) { + return false; + } + return { + space: 'RGB', + r: original[0], + g: original[1], + b: original[2] + }; + }, + write: function write(color) { + return [color.r, color.g, color.b]; + } + }, + RGBA_ARRAY: { + read: function read(original) { + if (original.length !== 4) return false; + return { + space: 'RGB', + r: original[0], + g: original[1], + b: original[2], + a: original[3] + }; + }, + write: function write(color) { + return [color.r, color.g, color.b, color.a]; + } + } + } +}, +{ + litmus: Common.isObject, + conversions: { + RGBA_OBJ: { + read: function read(original) { + if (Common.isNumber(original.r) && Common.isNumber(original.g) && Common.isNumber(original.b) && Common.isNumber(original.a)) { + return { + space: 'RGB', + r: original.r, + g: original.g, + b: original.b, + a: original.a + }; + } + return false; + }, + write: function write(color) { + return { + r: color.r, + g: color.g, + b: color.b, + a: color.a + }; + } + }, + RGB_OBJ: { + read: function read(original) { + if (Common.isNumber(original.r) && Common.isNumber(original.g) && Common.isNumber(original.b)) { + return { + space: 'RGB', + r: original.r, + g: original.g, + b: original.b + }; + } + return false; + }, + write: function write(color) { + return { + r: color.r, + g: color.g, + b: color.b + }; + } + }, + HSVA_OBJ: { + read: function read(original) { + if (Common.isNumber(original.h) && Common.isNumber(original.s) && Common.isNumber(original.v) && Common.isNumber(original.a)) { + return { + space: 'HSV', + h: original.h, + s: original.s, + v: original.v, + a: original.a + }; + } + return false; + }, + write: function write(color) { + return { + h: color.h, + s: color.s, + v: color.v, + a: color.a + }; + } + }, + HSV_OBJ: { + read: function read(original) { + if (Common.isNumber(original.h) && Common.isNumber(original.s) && Common.isNumber(original.v)) { + return { + space: 'HSV', + h: original.h, + s: original.s, + v: original.v + }; + } + return false; + }, + write: function write(color) { + return { + h: color.h, + s: color.s, + v: color.v + }; + } + } + } +}]; +var result = void 0; +var toReturn = void 0; +var interpret = function interpret() { + toReturn = false; + var original = arguments.length > 1 ? Common.toArray(arguments) : arguments[0]; + Common.each(INTERPRETATIONS, function (family) { + if (family.litmus(original)) { + Common.each(family.conversions, function (conversion, conversionName) { + result = conversion.read(original); + if (toReturn === false && result !== false) { + toReturn = result; + result.conversionName = conversionName; + result.conversion = conversion; + return Common.BREAK; + } + }); + return Common.BREAK; + } + }); + return toReturn; +}; + +var tmpComponent = void 0; +var ColorMath = { + hsv_to_rgb: function hsv_to_rgb(h, s, v) { + var hi = Math.floor(h / 60) % 6; + var f = h / 60 - Math.floor(h / 60); + var p = v * (1.0 - s); + var q = v * (1.0 - f * s); + var t = v * (1.0 - (1.0 - f) * s); + var c = [[v, t, p], [q, v, p], [p, v, t], [p, q, v], [t, p, v], [v, p, q]][hi]; + return { + r: c[0] * 255, + g: c[1] * 255, + b: c[2] * 255 + }; + }, + rgb_to_hsv: function rgb_to_hsv(r, g, b) { + var min = Math.min(r, g, b); + var max = Math.max(r, g, b); + var delta = max - min; + var h = void 0; + var s = void 0; + if (max !== 0) { + s = delta / max; + } else { + return { + h: NaN, + s: 0, + v: 0 + }; + } + if (r === max) { + h = (g - b) / delta; + } else if (g === max) { + h = 2 + (b - r) / delta; + } else { + h = 4 + (r - g) / delta; + } + h /= 6; + if (h < 0) { + h += 1; + } + return { + h: h * 360, + s: s, + v: max / 255 + }; + }, + rgb_to_hex: function rgb_to_hex(r, g, b) { + var hex = this.hex_with_component(0, 2, r); + hex = this.hex_with_component(hex, 1, g); + hex = this.hex_with_component(hex, 0, b); + return hex; + }, + component_from_hex: function component_from_hex(hex, componentIndex) { + return hex >> componentIndex * 8 & 0xFF; + }, + hex_with_component: function hex_with_component(hex, componentIndex, value) { + return value << (tmpComponent = componentIndex * 8) | hex & ~(0xFF << tmpComponent); + } +}; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { + return typeof obj; +} : function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; +}; + + + + + + + + + + + +var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +}; + +var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; +}(); + + + + + + + +var get = function get(object, property, receiver) { + if (object === null) object = Function.prototype; + var desc = Object.getOwnPropertyDescriptor(object, property); + + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + + if (getter === undefined) { + return undefined; + } + + return getter.call(receiver); + } +}; + +var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; +}; + + + + + + + + + + + +var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; +}; + +var Color = function () { + function Color() { + classCallCheck(this, Color); + this.__state = interpret.apply(this, arguments); + if (this.__state === false) { + throw new Error('Failed to interpret color arguments'); + } + this.__state.a = this.__state.a || 1; + } + createClass(Color, [{ + key: 'toString', + value: function toString() { + return colorToString(this); + } + }, { + key: 'toHexString', + value: function toHexString() { + return colorToString(this, true); + } + }, { + key: 'toOriginal', + value: function toOriginal() { + return this.__state.conversion.write(this); + } + }]); + return Color; +}(); +function defineRGBComponent(target, component, componentHexIndex) { + Object.defineProperty(target, component, { + get: function get$$1() { + if (this.__state.space === 'RGB') { + return this.__state[component]; + } + Color.recalculateRGB(this, component, componentHexIndex); + return this.__state[component]; + }, + set: function set$$1(v) { + if (this.__state.space !== 'RGB') { + Color.recalculateRGB(this, component, componentHexIndex); + this.__state.space = 'RGB'; + } + this.__state[component] = v; + } + }); +} +function defineHSVComponent(target, component) { + Object.defineProperty(target, component, { + get: function get$$1() { + if (this.__state.space === 'HSV') { + return this.__state[component]; + } + Color.recalculateHSV(this); + return this.__state[component]; + }, + set: function set$$1(v) { + if (this.__state.space !== 'HSV') { + Color.recalculateHSV(this); + this.__state.space = 'HSV'; + } + this.__state[component] = v; + } + }); +} +Color.recalculateRGB = function (color, component, componentHexIndex) { + if (color.__state.space === 'HEX') { + color.__state[component] = ColorMath.component_from_hex(color.__state.hex, componentHexIndex); + } else if (color.__state.space === 'HSV') { + Common.extend(color.__state, ColorMath.hsv_to_rgb(color.__state.h, color.__state.s, color.__state.v)); + } else { + throw new Error('Corrupted color state'); + } +}; +Color.recalculateHSV = function (color) { + var result = ColorMath.rgb_to_hsv(color.r, color.g, color.b); + Common.extend(color.__state, { + s: result.s, + v: result.v + }); + if (!Common.isNaN(result.h)) { + color.__state.h = result.h; + } else if (Common.isUndefined(color.__state.h)) { + color.__state.h = 0; + } +}; +Color.COMPONENTS = ['r', 'g', 'b', 'h', 's', 'v', 'hex', 'a']; +defineRGBComponent(Color.prototype, 'r', 2); +defineRGBComponent(Color.prototype, 'g', 1); +defineRGBComponent(Color.prototype, 'b', 0); +defineHSVComponent(Color.prototype, 'h'); +defineHSVComponent(Color.prototype, 's'); +defineHSVComponent(Color.prototype, 'v'); +Object.defineProperty(Color.prototype, 'a', { + get: function get$$1() { + return this.__state.a; + }, + set: function set$$1(v) { + this.__state.a = v; + } +}); +Object.defineProperty(Color.prototype, 'hex', { + get: function get$$1() { + if (this.__state.space !== 'HEX') { + this.__state.hex = ColorMath.rgb_to_hex(this.r, this.g, this.b); + this.__state.space = 'HEX'; + } + return this.__state.hex; + }, + set: function set$$1(v) { + this.__state.space = 'HEX'; + this.__state.hex = v; + } +}); + +var Controller = function () { + function Controller(object, property) { + classCallCheck(this, Controller); + this.initialValue = object[property]; + this.domElement = document.createElement('div'); + this.object = object; + this.property = property; + this.__onChange = undefined; + this.__onFinishChange = undefined; + } + createClass(Controller, [{ + key: 'onChange', + value: function onChange(fnc) { + this.__onChange = fnc; + return this; + } + }, { + key: 'onFinishChange', + value: function onFinishChange(fnc) { + this.__onFinishChange = fnc; + return this; + } + }, { + key: 'setValue', + value: function setValue(newValue) { + this.object[this.property] = newValue; + if (this.__onChange) { + this.__onChange.call(this, newValue); + } + this.updateDisplay(); + return this; + } + }, { + key: 'getValue', + value: function getValue() { + return this.object[this.property]; + } + }, { + key: 'updateDisplay', + value: function updateDisplay() { + return this; + } + }, { + key: 'isModified', + value: function isModified() { + return this.initialValue !== this.getValue(); + } + }]); + return Controller; +}(); + +var EVENT_MAP = { + HTMLEvents: ['change'], + MouseEvents: ['click', 'mousemove', 'mousedown', 'mouseup', 'mouseover'], + KeyboardEvents: ['keydown'] +}; +var EVENT_MAP_INV = {}; +Common.each(EVENT_MAP, function (v, k) { + Common.each(v, function (e) { + EVENT_MAP_INV[e] = k; + }); +}); +var CSS_VALUE_PIXELS = /(\d+(\.\d+)?)px/; +function cssValueToPixels(val) { + if (val === '0' || Common.isUndefined(val)) { + return 0; + } + var match = val.match(CSS_VALUE_PIXELS); + if (!Common.isNull(match)) { + return parseFloat(match[1]); + } + return 0; +} +var dom = { + makeSelectable: function makeSelectable(elem, selectable) { + if (elem === undefined || elem.style === undefined) return; + elem.onselectstart = selectable ? function () { + return false; + } : function () {}; + elem.style.MozUserSelect = selectable ? 'auto' : 'none'; + elem.style.KhtmlUserSelect = selectable ? 'auto' : 'none'; + elem.unselectable = selectable ? 'on' : 'off'; + }, + makeFullscreen: function makeFullscreen(elem, hor, vert) { + var vertical = vert; + var horizontal = hor; + if (Common.isUndefined(horizontal)) { + horizontal = true; + } + if (Common.isUndefined(vertical)) { + vertical = true; + } + elem.style.position = 'absolute'; + if (horizontal) { + elem.style.left = 0; + elem.style.right = 0; + } + if (vertical) { + elem.style.top = 0; + elem.style.bottom = 0; + } + }, + fakeEvent: function fakeEvent(elem, eventType, pars, aux) { + var params = pars || {}; + var className = EVENT_MAP_INV[eventType]; + if (!className) { + throw new Error('Event type ' + eventType + ' not supported.'); + } + var evt = document.createEvent(className); + switch (className) { + case 'MouseEvents': + { + var clientX = params.x || params.clientX || 0; + var clientY = params.y || params.clientY || 0; + evt.initMouseEvent(eventType, params.bubbles || false, params.cancelable || true, window, params.clickCount || 1, 0, + 0, + clientX, + clientY, + false, false, false, false, 0, null); + break; + } + case 'KeyboardEvents': + { + var init = evt.initKeyboardEvent || evt.initKeyEvent; + Common.defaults(params, { + cancelable: true, + ctrlKey: false, + altKey: false, + shiftKey: false, + metaKey: false, + keyCode: undefined, + charCode: undefined + }); + init(eventType, params.bubbles || false, params.cancelable, window, params.ctrlKey, params.altKey, params.shiftKey, params.metaKey, params.keyCode, params.charCode); + break; + } + default: + { + evt.initEvent(eventType, params.bubbles || false, params.cancelable || true); + break; + } + } + Common.defaults(evt, aux); + elem.dispatchEvent(evt); + }, + bind: function bind(elem, event, func, newBool) { + var bool = newBool || false; + if (elem.addEventListener) { + elem.addEventListener(event, func, bool); + } else if (elem.attachEvent) { + elem.attachEvent('on' + event, func); + } + return dom; + }, + unbind: function unbind(elem, event, func, newBool) { + var bool = newBool || false; + if (elem.removeEventListener) { + elem.removeEventListener(event, func, bool); + } else if (elem.detachEvent) { + elem.detachEvent('on' + event, func); + } + return dom; + }, + addClass: function addClass(elem, className) { + if (elem.className === undefined) { + elem.className = className; + } else if (elem.className !== className) { + var classes = elem.className.split(/ +/); + if (classes.indexOf(className) === -1) { + classes.push(className); + elem.className = classes.join(' ').replace(/^\s+/, '').replace(/\s+$/, ''); + } + } + return dom; + }, + removeClass: function removeClass(elem, className) { + if (className) { + if (elem.className === className) { + elem.removeAttribute('class'); + } else { + var classes = elem.className.split(/ +/); + var index = classes.indexOf(className); + if (index !== -1) { + classes.splice(index, 1); + elem.className = classes.join(' '); + } + } + } else { + elem.className = undefined; + } + return dom; + }, + hasClass: function hasClass(elem, className) { + return new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)').test(elem.className) || false; + }, + getWidth: function getWidth(elem) { + var style = getComputedStyle(elem); + return cssValueToPixels(style['border-left-width']) + cssValueToPixels(style['border-right-width']) + cssValueToPixels(style['padding-left']) + cssValueToPixels(style['padding-right']) + cssValueToPixels(style.width); + }, + getHeight: function getHeight(elem) { + var style = getComputedStyle(elem); + return cssValueToPixels(style['border-top-width']) + cssValueToPixels(style['border-bottom-width']) + cssValueToPixels(style['padding-top']) + cssValueToPixels(style['padding-bottom']) + cssValueToPixels(style.height); + }, + getOffset: function getOffset(el) { + var elem = el; + var offset = { left: 0, top: 0 }; + if (elem.offsetParent) { + do { + offset.left += elem.offsetLeft; + offset.top += elem.offsetTop; + elem = elem.offsetParent; + } while (elem); + } + return offset; + }, + isActive: function isActive(elem) { + return elem === document.activeElement && (elem.type || elem.href); + } +}; + +var BooleanController = function (_Controller) { + inherits(BooleanController, _Controller); + function BooleanController(object, property) { + classCallCheck(this, BooleanController); + var _this2 = possibleConstructorReturn(this, (BooleanController.__proto__ || Object.getPrototypeOf(BooleanController)).call(this, object, property)); + var _this = _this2; + _this2.__prev = _this2.getValue(); + _this2.__checkbox = document.createElement('input'); + _this2.__checkbox.setAttribute('type', 'checkbox'); + function onChange() { + _this.setValue(!_this.__prev); + } + dom.bind(_this2.__checkbox, 'change', onChange, false); + _this2.domElement.appendChild(_this2.__checkbox); + _this2.updateDisplay(); + return _this2; + } + createClass(BooleanController, [{ + key: 'setValue', + value: function setValue(v) { + var toReturn = get(BooleanController.prototype.__proto__ || Object.getPrototypeOf(BooleanController.prototype), 'setValue', this).call(this, v); + if (this.__onFinishChange) { + this.__onFinishChange.call(this, this.getValue()); + } + this.__prev = this.getValue(); + return toReturn; + } + }, { + key: 'updateDisplay', + value: function updateDisplay() { + if (this.getValue() === true) { + this.__checkbox.setAttribute('checked', 'checked'); + this.__checkbox.checked = true; + this.__prev = true; + } else { + this.__checkbox.checked = false; + this.__prev = false; + } + return get(BooleanController.prototype.__proto__ || Object.getPrototypeOf(BooleanController.prototype), 'updateDisplay', this).call(this); + } + }]); + return BooleanController; +}(Controller); + +var OptionController = function (_Controller) { + inherits(OptionController, _Controller); + function OptionController(object, property, opts) { + classCallCheck(this, OptionController); + var _this2 = possibleConstructorReturn(this, (OptionController.__proto__ || Object.getPrototypeOf(OptionController)).call(this, object, property)); + var options = opts; + var _this = _this2; + _this2.__select = document.createElement('select'); + if (Common.isArray(options)) { + var map = {}; + Common.each(options, function (element) { + map[element] = element; + }); + options = map; + } + Common.each(options, function (value, key) { + var opt = document.createElement('option'); + opt.innerHTML = key; + opt.setAttribute('value', value); + _this.__select.appendChild(opt); + }); + _this2.updateDisplay(); + dom.bind(_this2.__select, 'change', function () { + var desiredValue = this.options[this.selectedIndex].value; + _this.setValue(desiredValue); + }); + _this2.domElement.appendChild(_this2.__select); + return _this2; + } + createClass(OptionController, [{ + key: 'setValue', + value: function setValue(v) { + var toReturn = get(OptionController.prototype.__proto__ || Object.getPrototypeOf(OptionController.prototype), 'setValue', this).call(this, v); + if (this.__onFinishChange) { + this.__onFinishChange.call(this, this.getValue()); + } + return toReturn; + } + }, { + key: 'updateDisplay', + value: function updateDisplay() { + if (dom.isActive(this.__select)) return this; + this.__select.value = this.getValue(); + return get(OptionController.prototype.__proto__ || Object.getPrototypeOf(OptionController.prototype), 'updateDisplay', this).call(this); + } + }]); + return OptionController; +}(Controller); + +var StringController = function (_Controller) { + inherits(StringController, _Controller); + function StringController(object, property) { + classCallCheck(this, StringController); + var _this2 = possibleConstructorReturn(this, (StringController.__proto__ || Object.getPrototypeOf(StringController)).call(this, object, property)); + var _this = _this2; + function onChange() { + _this.setValue(_this.__input.value); + } + function onBlur() { + if (_this.__onFinishChange) { + _this.__onFinishChange.call(_this, _this.getValue()); + } + } + _this2.__input = document.createElement('input'); + _this2.__input.setAttribute('type', 'text'); + dom.bind(_this2.__input, 'keyup', onChange); + dom.bind(_this2.__input, 'change', onChange); + dom.bind(_this2.__input, 'blur', onBlur); + dom.bind(_this2.__input, 'keydown', function (e) { + if (e.keyCode === 13) { + this.blur(); + } + }); + _this2.updateDisplay(); + _this2.domElement.appendChild(_this2.__input); + return _this2; + } + createClass(StringController, [{ + key: 'updateDisplay', + value: function updateDisplay() { + if (!dom.isActive(this.__input)) { + this.__input.value = this.getValue(); + } + return get(StringController.prototype.__proto__ || Object.getPrototypeOf(StringController.prototype), 'updateDisplay', this).call(this); + } + }]); + return StringController; +}(Controller); + +function numDecimals(x) { + var _x = x.toString(); + if (_x.indexOf('.') > -1) { + return _x.length - _x.indexOf('.') - 1; + } + return 0; +} +var NumberController = function (_Controller) { + inherits(NumberController, _Controller); + function NumberController(object, property, params) { + classCallCheck(this, NumberController); + var _this = possibleConstructorReturn(this, (NumberController.__proto__ || Object.getPrototypeOf(NumberController)).call(this, object, property)); + var _params = params || {}; + _this.__min = _params.min; + _this.__max = _params.max; + _this.__step = _params.step; + if (Common.isUndefined(_this.__step)) { + if (_this.initialValue === 0) { + _this.__impliedStep = 1; + } else { + _this.__impliedStep = Math.pow(10, Math.floor(Math.log(Math.abs(_this.initialValue)) / Math.LN10)) / 10; + } + } else { + _this.__impliedStep = _this.__step; + } + _this.__precision = numDecimals(_this.__impliedStep); + return _this; + } + createClass(NumberController, [{ + key: 'setValue', + value: function setValue(v) { + var _v = v; + if (this.__min !== undefined && _v < this.__min) { + _v = this.__min; + } else if (this.__max !== undefined && _v > this.__max) { + _v = this.__max; + } + if (this.__step !== undefined && _v % this.__step !== 0) { + _v = Math.round(_v / this.__step) * this.__step; + } + return get(NumberController.prototype.__proto__ || Object.getPrototypeOf(NumberController.prototype), 'setValue', this).call(this, _v); + } + }, { + key: 'min', + value: function min(minValue) { + this.__min = minValue; + return this; + } + }, { + key: 'max', + value: function max(maxValue) { + this.__max = maxValue; + return this; + } + }, { + key: 'step', + value: function step(stepValue) { + this.__step = stepValue; + this.__impliedStep = stepValue; + this.__precision = numDecimals(stepValue); + return this; + } + }]); + return NumberController; +}(Controller); + +function roundToDecimal(value, decimals) { + var tenTo = Math.pow(10, decimals); + return Math.round(value * tenTo) / tenTo; +} +var NumberControllerBox = function (_NumberController) { + inherits(NumberControllerBox, _NumberController); + function NumberControllerBox(object, property, params) { + classCallCheck(this, NumberControllerBox); + var _this2 = possibleConstructorReturn(this, (NumberControllerBox.__proto__ || Object.getPrototypeOf(NumberControllerBox)).call(this, object, property, params)); + _this2.__truncationSuspended = false; + var _this = _this2; + var prevY = void 0; + function onChange() { + var attempted = parseFloat(_this.__input.value); + if (!Common.isNaN(attempted)) { + _this.setValue(attempted); + } + } + function onFinish() { + if (_this.__onFinishChange) { + _this.__onFinishChange.call(_this, _this.getValue()); + } + } + function onBlur() { + onFinish(); + } + function onMouseDrag(e) { + var diff = prevY - e.clientY; + _this.setValue(_this.getValue() + diff * _this.__impliedStep); + prevY = e.clientY; + } + function onMouseUp() { + dom.unbind(window, 'mousemove', onMouseDrag); + dom.unbind(window, 'mouseup', onMouseUp); + onFinish(); + } + function onMouseDown(e) { + dom.bind(window, 'mousemove', onMouseDrag); + dom.bind(window, 'mouseup', onMouseUp); + prevY = e.clientY; + } + _this2.__input = document.createElement('input'); + _this2.__input.setAttribute('type', 'text'); + dom.bind(_this2.__input, 'change', onChange); + dom.bind(_this2.__input, 'blur', onBlur); + dom.bind(_this2.__input, 'mousedown', onMouseDown); + dom.bind(_this2.__input, 'keydown', function (e) { + if (e.keyCode === 13) { + _this.__truncationSuspended = true; + this.blur(); + _this.__truncationSuspended = false; + onFinish(); + } + }); + _this2.updateDisplay(); + _this2.domElement.appendChild(_this2.__input); + return _this2; + } + createClass(NumberControllerBox, [{ + key: 'updateDisplay', + value: function updateDisplay() { + this.__input.value = this.__truncationSuspended ? this.getValue() : roundToDecimal(this.getValue(), this.__precision); + return get(NumberControllerBox.prototype.__proto__ || Object.getPrototypeOf(NumberControllerBox.prototype), 'updateDisplay', this).call(this); + } + }]); + return NumberControllerBox; +}(NumberController); + +function map(v, i1, i2, o1, o2) { + return o1 + (o2 - o1) * ((v - i1) / (i2 - i1)); +} +var NumberControllerSlider = function (_NumberController) { + inherits(NumberControllerSlider, _NumberController); + function NumberControllerSlider(object, property, min, max, step) { + classCallCheck(this, NumberControllerSlider); + var _this2 = possibleConstructorReturn(this, (NumberControllerSlider.__proto__ || Object.getPrototypeOf(NumberControllerSlider)).call(this, object, property, { min: min, max: max, step: step })); + var _this = _this2; + _this2.__background = document.createElement('div'); + _this2.__foreground = document.createElement('div'); + dom.bind(_this2.__background, 'mousedown', onMouseDown); + dom.bind(_this2.__background, 'touchstart', onTouchStart); + dom.addClass(_this2.__background, 'slider'); + dom.addClass(_this2.__foreground, 'slider-fg'); + function onMouseDown(e) { + document.activeElement.blur(); + dom.bind(window, 'mousemove', onMouseDrag); + dom.bind(window, 'mouseup', onMouseUp); + onMouseDrag(e); + } + function onMouseDrag(e) { + e.preventDefault(); + var bgRect = _this.__background.getBoundingClientRect(); + _this.setValue(map(e.clientX, bgRect.left, bgRect.right, _this.__min, _this.__max)); + return false; + } + function onMouseUp() { + dom.unbind(window, 'mousemove', onMouseDrag); + dom.unbind(window, 'mouseup', onMouseUp); + if (_this.__onFinishChange) { + _this.__onFinishChange.call(_this, _this.getValue()); + } + } + function onTouchStart(e) { + if (e.touches.length !== 1) { + return; + } + dom.bind(window, 'touchmove', onTouchMove); + dom.bind(window, 'touchend', onTouchEnd); + onTouchMove(e); + } + function onTouchMove(e) { + var clientX = e.touches[0].clientX; + var bgRect = _this.__background.getBoundingClientRect(); + _this.setValue(map(clientX, bgRect.left, bgRect.right, _this.__min, _this.__max)); + } + function onTouchEnd() { + dom.unbind(window, 'touchmove', onTouchMove); + dom.unbind(window, 'touchend', onTouchEnd); + if (_this.__onFinishChange) { + _this.__onFinishChange.call(_this, _this.getValue()); + } + } + _this2.updateDisplay(); + _this2.__background.appendChild(_this2.__foreground); + _this2.domElement.appendChild(_this2.__background); + return _this2; + } + createClass(NumberControllerSlider, [{ + key: 'updateDisplay', + value: function updateDisplay() { + var pct = (this.getValue() - this.__min) / (this.__max - this.__min); + this.__foreground.style.width = pct * 100 + '%'; + return get(NumberControllerSlider.prototype.__proto__ || Object.getPrototypeOf(NumberControllerSlider.prototype), 'updateDisplay', this).call(this); + } + }]); + return NumberControllerSlider; +}(NumberController); + +var FunctionController = function (_Controller) { + inherits(FunctionController, _Controller); + function FunctionController(object, property, text) { + classCallCheck(this, FunctionController); + var _this2 = possibleConstructorReturn(this, (FunctionController.__proto__ || Object.getPrototypeOf(FunctionController)).call(this, object, property)); + var _this = _this2; + _this2.__button = document.createElement('div'); + _this2.__button.innerHTML = text === undefined ? 'Fire' : text; + dom.bind(_this2.__button, 'click', function (e) { + e.preventDefault(); + _this.fire(); + return false; + }); + dom.addClass(_this2.__button, 'button'); + _this2.domElement.appendChild(_this2.__button); + return _this2; + } + createClass(FunctionController, [{ + key: 'fire', + value: function fire() { + if (this.__onChange) { + this.__onChange.call(this); + } + this.getValue().call(this.object); + if (this.__onFinishChange) { + this.__onFinishChange.call(this, this.getValue()); + } + } + }]); + return FunctionController; +}(Controller); + +var ColorController = function (_Controller) { + inherits(ColorController, _Controller); + function ColorController(object, property) { + classCallCheck(this, ColorController); + var _this2 = possibleConstructorReturn(this, (ColorController.__proto__ || Object.getPrototypeOf(ColorController)).call(this, object, property)); + _this2.__color = new Color(_this2.getValue()); + _this2.__temp = new Color(0); + var _this = _this2; + _this2.domElement = document.createElement('div'); + dom.makeSelectable(_this2.domElement, false); + _this2.__selector = document.createElement('div'); + _this2.__selector.className = 'selector'; + _this2.__saturation_field = document.createElement('div'); + _this2.__saturation_field.className = 'saturation-field'; + _this2.__field_knob = document.createElement('div'); + _this2.__field_knob.className = 'field-knob'; + _this2.__field_knob_border = '2px solid '; + _this2.__hue_knob = document.createElement('div'); + _this2.__hue_knob.className = 'hue-knob'; + _this2.__hue_field = document.createElement('div'); + _this2.__hue_field.className = 'hue-field'; + _this2.__input = document.createElement('input'); + _this2.__input.type = 'text'; + _this2.__input_textShadow = '0 1px 1px '; + dom.bind(_this2.__input, 'keydown', function (e) { + if (e.keyCode === 13) { + onBlur.call(this); + } + }); + dom.bind(_this2.__input, 'blur', onBlur); + dom.bind(_this2.__selector, 'mousedown', function () { + dom.addClass(this, 'drag').bind(window, 'mouseup', function () { + dom.removeClass(_this.__selector, 'drag'); + }); + }); + dom.bind(_this2.__selector, 'touchstart', function () { + dom.addClass(this, 'drag').bind(window, 'touchend', function () { + dom.removeClass(_this.__selector, 'drag'); + }); + }); + var valueField = document.createElement('div'); + Common.extend(_this2.__selector.style, { + width: '122px', + height: '102px', + padding: '3px', + backgroundColor: '#222', + boxShadow: '0px 1px 3px rgba(0,0,0,0.3)' + }); + Common.extend(_this2.__field_knob.style, { + position: 'absolute', + width: '12px', + height: '12px', + border: _this2.__field_knob_border + (_this2.__color.v < 0.5 ? '#fff' : '#000'), + boxShadow: '0px 1px 3px rgba(0,0,0,0.5)', + borderRadius: '12px', + zIndex: 1 + }); + Common.extend(_this2.__hue_knob.style, { + position: 'absolute', + width: '15px', + height: '2px', + borderRight: '4px solid #fff', + zIndex: 1 + }); + Common.extend(_this2.__saturation_field.style, { + width: '100px', + height: '100px', + border: '1px solid #555', + marginRight: '3px', + display: 'inline-block', + cursor: 'pointer' + }); + Common.extend(valueField.style, { + width: '100%', + height: '100%', + background: 'none' + }); + linearGradient(valueField, 'top', 'rgba(0,0,0,0)', '#000'); + Common.extend(_this2.__hue_field.style, { + width: '15px', + height: '100px', + border: '1px solid #555', + cursor: 'ns-resize', + position: 'absolute', + top: '3px', + right: '3px' + }); + hueGradient(_this2.__hue_field); + Common.extend(_this2.__input.style, { + outline: 'none', + textAlign: 'center', + color: '#fff', + border: 0, + fontWeight: 'bold', + textShadow: _this2.__input_textShadow + 'rgba(0,0,0,0.7)' + }); + dom.bind(_this2.__saturation_field, 'mousedown', fieldDown); + dom.bind(_this2.__saturation_field, 'touchstart', fieldDown); + dom.bind(_this2.__field_knob, 'mousedown', fieldDown); + dom.bind(_this2.__field_knob, 'touchstart', fieldDown); + dom.bind(_this2.__hue_field, 'mousedown', fieldDownH); + dom.bind(_this2.__hue_field, 'touchstart', fieldDownH); + function fieldDown(e) { + setSV(e); + dom.bind(window, 'mousemove', setSV); + dom.bind(window, 'touchmove', setSV); + dom.bind(window, 'mouseup', fieldUpSV); + dom.bind(window, 'touchend', fieldUpSV); + } + function fieldDownH(e) { + setH(e); + dom.bind(window, 'mousemove', setH); + dom.bind(window, 'touchmove', setH); + dom.bind(window, 'mouseup', fieldUpH); + dom.bind(window, 'touchend', fieldUpH); + } + function fieldUpSV() { + dom.unbind(window, 'mousemove', setSV); + dom.unbind(window, 'touchmove', setSV); + dom.unbind(window, 'mouseup', fieldUpSV); + dom.unbind(window, 'touchend', fieldUpSV); + onFinish(); + } + function fieldUpH() { + dom.unbind(window, 'mousemove', setH); + dom.unbind(window, 'touchmove', setH); + dom.unbind(window, 'mouseup', fieldUpH); + dom.unbind(window, 'touchend', fieldUpH); + onFinish(); + } + function onBlur() { + var i = interpret(this.value); + if (i !== false) { + _this.__color.__state = i; + _this.setValue(_this.__color.toOriginal()); + } else { + this.value = _this.__color.toString(); + } + } + function onFinish() { + if (_this.__onFinishChange) { + _this.__onFinishChange.call(_this, _this.__color.toOriginal()); + } + } + _this2.__saturation_field.appendChild(valueField); + _this2.__selector.appendChild(_this2.__field_knob); + _this2.__selector.appendChild(_this2.__saturation_field); + _this2.__selector.appendChild(_this2.__hue_field); + _this2.__hue_field.appendChild(_this2.__hue_knob); + _this2.domElement.appendChild(_this2.__input); + _this2.domElement.appendChild(_this2.__selector); + _this2.updateDisplay(); + function setSV(e) { + if (e.type.indexOf('touch') === -1) { + e.preventDefault(); + } + var fieldRect = _this.__saturation_field.getBoundingClientRect(); + var _ref = e.touches && e.touches[0] || e, + clientX = _ref.clientX, + clientY = _ref.clientY; + var s = (clientX - fieldRect.left) / (fieldRect.right - fieldRect.left); + var v = 1 - (clientY - fieldRect.top) / (fieldRect.bottom - fieldRect.top); + if (v > 1) { + v = 1; + } else if (v < 0) { + v = 0; + } + if (s > 1) { + s = 1; + } else if (s < 0) { + s = 0; + } + _this.__color.v = v; + _this.__color.s = s; + _this.setValue(_this.__color.toOriginal()); + return false; + } + function setH(e) { + if (e.type.indexOf('touch') === -1) { + e.preventDefault(); + } + var fieldRect = _this.__hue_field.getBoundingClientRect(); + var _ref2 = e.touches && e.touches[0] || e, + clientY = _ref2.clientY; + var h = 1 - (clientY - fieldRect.top) / (fieldRect.bottom - fieldRect.top); + if (h > 1) { + h = 1; + } else if (h < 0) { + h = 0; + } + _this.__color.h = h * 360; + _this.setValue(_this.__color.toOriginal()); + return false; + } + return _this2; + } + createClass(ColorController, [{ + key: 'updateDisplay', + value: function updateDisplay() { + var i = interpret(this.getValue()); + if (i !== false) { + var mismatch = false; + Common.each(Color.COMPONENTS, function (component) { + if (!Common.isUndefined(i[component]) && !Common.isUndefined(this.__color.__state[component]) && i[component] !== this.__color.__state[component]) { + mismatch = true; + return {}; + } + }, this); + if (mismatch) { + Common.extend(this.__color.__state, i); + } + } + Common.extend(this.__temp.__state, this.__color.__state); + this.__temp.a = 1; + var flip = this.__color.v < 0.5 || this.__color.s > 0.5 ? 255 : 0; + var _flip = 255 - flip; + Common.extend(this.__field_knob.style, { + marginLeft: 100 * this.__color.s - 7 + 'px', + marginTop: 100 * (1 - this.__color.v) - 7 + 'px', + backgroundColor: this.__temp.toHexString(), + border: this.__field_knob_border + 'rgb(' + flip + ',' + flip + ',' + flip + ')' + }); + this.__hue_knob.style.marginTop = (1 - this.__color.h / 360) * 100 + 'px'; + this.__temp.s = 1; + this.__temp.v = 1; + linearGradient(this.__saturation_field, 'left', '#fff', this.__temp.toHexString()); + this.__input.value = this.__color.toString(); + Common.extend(this.__input.style, { + backgroundColor: this.__color.toHexString(), + color: 'rgb(' + flip + ',' + flip + ',' + flip + ')', + textShadow: this.__input_textShadow + 'rgba(' + _flip + ',' + _flip + ',' + _flip + ',.7)' + }); + } + }]); + return ColorController; +}(Controller); +var vendors = ['-moz-', '-o-', '-webkit-', '-ms-', '']; +function linearGradient(elem, x, a, b) { + elem.style.background = ''; + Common.each(vendors, function (vendor) { + elem.style.cssText += 'background: ' + vendor + 'linear-gradient(' + x + ', ' + a + ' 0%, ' + b + ' 100%); '; + }); +} +function hueGradient(elem) { + elem.style.background = ''; + elem.style.cssText += 'background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);'; + elem.style.cssText += 'background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);'; + elem.style.cssText += 'background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);'; + elem.style.cssText += 'background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);'; + elem.style.cssText += 'background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);'; +} + +var css = { + load: function load(url, indoc) { + var doc = indoc || document; + var link = doc.createElement('link'); + link.type = 'text/css'; + link.rel = 'stylesheet'; + link.href = url; + doc.getElementsByTagName('head')[0].appendChild(link); + }, + inject: function inject(cssContent, indoc) { + var doc = indoc || document; + var injected = document.createElement('style'); + injected.type = 'text/css'; + injected.innerHTML = cssContent; + var head = doc.getElementsByTagName('head')[0]; + try { + head.appendChild(injected); + } catch (e) { + } + } +}; + +var saveDialogContents = "
\n\n Here's the new load parameter for your GUI's constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI's constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n\n
\n\n
\n\n
"; + +var ControllerFactory = function ControllerFactory(object, property) { + var initialValue = object[property]; + if (Common.isArray(arguments[2]) || Common.isObject(arguments[2])) { + return new OptionController(object, property, arguments[2]); + } + if (Common.isNumber(initialValue)) { + if (Common.isNumber(arguments[2]) && Common.isNumber(arguments[3])) { + if (Common.isNumber(arguments[4])) { + return new NumberControllerSlider(object, property, arguments[2], arguments[3], arguments[4]); + } + return new NumberControllerSlider(object, property, arguments[2], arguments[3]); + } + if (Common.isNumber(arguments[4])) { + return new NumberControllerBox(object, property, { min: arguments[2], max: arguments[3], step: arguments[4] }); + } + return new NumberControllerBox(object, property, { min: arguments[2], max: arguments[3] }); + } + if (Common.isString(initialValue)) { + return new StringController(object, property); + } + if (Common.isFunction(initialValue)) { + return new FunctionController(object, property, ''); + } + if (Common.isBoolean(initialValue)) { + return new BooleanController(object, property); + } + return null; +}; + +function requestAnimationFrame(callback) { + setTimeout(callback, 1000 / 60); +} +var requestAnimationFrame$1 = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || requestAnimationFrame; + +var CenteredDiv = function () { + function CenteredDiv() { + classCallCheck(this, CenteredDiv); + this.backgroundElement = document.createElement('div'); + Common.extend(this.backgroundElement.style, { + backgroundColor: 'rgba(0,0,0,0.8)', + top: 0, + left: 0, + display: 'none', + zIndex: '1000', + opacity: 0, + WebkitTransition: 'opacity 0.2s linear', + transition: 'opacity 0.2s linear' + }); + dom.makeFullscreen(this.backgroundElement); + this.backgroundElement.style.position = 'fixed'; + this.domElement = document.createElement('div'); + Common.extend(this.domElement.style, { + position: 'fixed', + display: 'none', + zIndex: '1001', + opacity: 0, + WebkitTransition: '-webkit-transform 0.2s ease-out, opacity 0.2s linear', + transition: 'transform 0.2s ease-out, opacity 0.2s linear' + }); + document.body.appendChild(this.backgroundElement); + document.body.appendChild(this.domElement); + var _this = this; + dom.bind(this.backgroundElement, 'click', function () { + _this.hide(); + }); + } + createClass(CenteredDiv, [{ + key: 'show', + value: function show() { + var _this = this; + this.backgroundElement.style.display = 'block'; + this.domElement.style.display = 'block'; + this.domElement.style.opacity = 0; + this.domElement.style.webkitTransform = 'scale(1.1)'; + this.layout(); + Common.defer(function () { + _this.backgroundElement.style.opacity = 1; + _this.domElement.style.opacity = 1; + _this.domElement.style.webkitTransform = 'scale(1)'; + }); + } + }, { + key: 'hide', + value: function hide() { + var _this = this; + var hide = function hide() { + _this.domElement.style.display = 'none'; + _this.backgroundElement.style.display = 'none'; + dom.unbind(_this.domElement, 'webkitTransitionEnd', hide); + dom.unbind(_this.domElement, 'transitionend', hide); + dom.unbind(_this.domElement, 'oTransitionEnd', hide); + }; + dom.bind(this.domElement, 'webkitTransitionEnd', hide); + dom.bind(this.domElement, 'transitionend', hide); + dom.bind(this.domElement, 'oTransitionEnd', hide); + this.backgroundElement.style.opacity = 0; + this.domElement.style.opacity = 0; + this.domElement.style.webkitTransform = 'scale(1.1)'; + } + }, { + key: 'layout', + value: function layout() { + this.domElement.style.left = window.innerWidth / 2 - dom.getWidth(this.domElement) / 2 + 'px'; + this.domElement.style.top = window.innerHeight / 2 - dom.getHeight(this.domElement) / 2 + 'px'; + } + }]); + return CenteredDiv; +}(); + +var styleSheet = ___$insertStyle(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n"); + +css.inject(styleSheet); +var CSS_NAMESPACE = 'dg'; +var HIDE_KEY_CODE = 72; +var CLOSE_BUTTON_HEIGHT = 20; +var DEFAULT_DEFAULT_PRESET_NAME = 'Default'; +var SUPPORTS_LOCAL_STORAGE = function () { + try { + return !!window.localStorage; + } catch (e) { + return false; + } +}(); +var SAVE_DIALOGUE = void 0; +var autoPlaceVirgin = true; +var autoPlaceContainer = void 0; +var hide = false; +var hideableGuis = []; +var GUI = function GUI(pars) { + var _this = this; + var params = pars || {}; + this.domElement = document.createElement('div'); + this.__ul = document.createElement('ul'); + this.domElement.appendChild(this.__ul); + dom.addClass(this.domElement, CSS_NAMESPACE); + this.__folders = {}; + this.__controllers = []; + this.__rememberedObjects = []; + this.__rememberedObjectIndecesToControllers = []; + this.__listening = []; + params = Common.defaults(params, { + closeOnTop: false, + autoPlace: true, + width: GUI.DEFAULT_WIDTH + }); + params = Common.defaults(params, { + resizable: params.autoPlace, + hideable: params.autoPlace + }); + if (!Common.isUndefined(params.load)) { + if (params.preset) { + params.load.preset = params.preset; + } + } else { + params.load = { preset: DEFAULT_DEFAULT_PRESET_NAME }; + } + if (Common.isUndefined(params.parent) && params.hideable) { + hideableGuis.push(this); + } + params.resizable = Common.isUndefined(params.parent) && params.resizable; + if (params.autoPlace && Common.isUndefined(params.scrollable)) { + params.scrollable = true; + } + var useLocalStorage = SUPPORTS_LOCAL_STORAGE && localStorage.getItem(getLocalStorageHash(this, 'isLocal')) === 'true'; + var saveToLocalStorage = void 0; + var titleRow = void 0; + Object.defineProperties(this, + { + parent: { + get: function get$$1() { + return params.parent; + } + }, + scrollable: { + get: function get$$1() { + return params.scrollable; + } + }, + autoPlace: { + get: function get$$1() { + return params.autoPlace; + } + }, + closeOnTop: { + get: function get$$1() { + return params.closeOnTop; + } + }, + preset: { + get: function get$$1() { + if (_this.parent) { + return _this.getRoot().preset; + } + return params.load.preset; + }, + set: function set$$1(v) { + if (_this.parent) { + _this.getRoot().preset = v; + } else { + params.load.preset = v; + } + setPresetSelectIndex(this); + _this.revert(); + } + }, + width: { + get: function get$$1() { + return params.width; + }, + set: function set$$1(v) { + params.width = v; + setWidth(_this, v); + } + }, + name: { + get: function get$$1() { + return params.name; + }, + set: function set$$1(v) { + params.name = v; + if (titleRow) { + titleRow.innerHTML = params.name; + } + } + }, + closed: { + get: function get$$1() { + return params.closed; + }, + set: function set$$1(v) { + params.closed = v; + if (params.closed) { + dom.addClass(_this.__ul, GUI.CLASS_CLOSED); + } else { + dom.removeClass(_this.__ul, GUI.CLASS_CLOSED); + } + this.onResize(); + if (_this.__closeButton) { + _this.__closeButton.innerHTML = v ? GUI.TEXT_OPEN : GUI.TEXT_CLOSED; + } + } + }, + load: { + get: function get$$1() { + return params.load; + } + }, + useLocalStorage: { + get: function get$$1() { + return useLocalStorage; + }, + set: function set$$1(bool) { + if (SUPPORTS_LOCAL_STORAGE) { + useLocalStorage = bool; + if (bool) { + dom.bind(window, 'unload', saveToLocalStorage); + } else { + dom.unbind(window, 'unload', saveToLocalStorage); + } + localStorage.setItem(getLocalStorageHash(_this, 'isLocal'), bool); + } + } + } + }); + if (Common.isUndefined(params.parent)) { + this.closed = params.closed || false; + dom.addClass(this.domElement, GUI.CLASS_MAIN); + dom.makeSelectable(this.domElement, false); + if (SUPPORTS_LOCAL_STORAGE) { + if (useLocalStorage) { + _this.useLocalStorage = true; + var savedGui = localStorage.getItem(getLocalStorageHash(this, 'gui')); + if (savedGui) { + params.load = JSON.parse(savedGui); + } + } + } + this.__closeButton = document.createElement('div'); + this.__closeButton.innerHTML = GUI.TEXT_CLOSED; + dom.addClass(this.__closeButton, GUI.CLASS_CLOSE_BUTTON); + if (params.closeOnTop) { + dom.addClass(this.__closeButton, GUI.CLASS_CLOSE_TOP); + this.domElement.insertBefore(this.__closeButton, this.domElement.childNodes[0]); + } else { + dom.addClass(this.__closeButton, GUI.CLASS_CLOSE_BOTTOM); + this.domElement.appendChild(this.__closeButton); + } + dom.bind(this.__closeButton, 'click', function () { + _this.closed = !_this.closed; + }); + } else { + if (params.closed === undefined) { + params.closed = true; + } + var titleRowName = document.createTextNode(params.name); + dom.addClass(titleRowName, 'controller-name'); + titleRow = addRow(_this, titleRowName); + var onClickTitle = function onClickTitle(e) { + e.preventDefault(); + _this.closed = !_this.closed; + return false; + }; + dom.addClass(this.__ul, GUI.CLASS_CLOSED); + dom.addClass(titleRow, 'title'); + dom.bind(titleRow, 'click', onClickTitle); + if (!params.closed) { + this.closed = false; + } + } + if (params.autoPlace) { + if (Common.isUndefined(params.parent)) { + if (autoPlaceVirgin) { + autoPlaceContainer = document.createElement('div'); + dom.addClass(autoPlaceContainer, CSS_NAMESPACE); + dom.addClass(autoPlaceContainer, GUI.CLASS_AUTO_PLACE_CONTAINER); + document.body.appendChild(autoPlaceContainer); + autoPlaceVirgin = false; + } + autoPlaceContainer.appendChild(this.domElement); + dom.addClass(this.domElement, GUI.CLASS_AUTO_PLACE); + } + if (!this.parent) { + setWidth(_this, params.width); + } + } + this.__resizeHandler = function () { + _this.onResizeDebounced(); + }; + dom.bind(window, 'resize', this.__resizeHandler); + dom.bind(this.__ul, 'webkitTransitionEnd', this.__resizeHandler); + dom.bind(this.__ul, 'transitionend', this.__resizeHandler); + dom.bind(this.__ul, 'oTransitionEnd', this.__resizeHandler); + this.onResize(); + if (params.resizable) { + addResizeHandle(this); + } + saveToLocalStorage = function saveToLocalStorage() { + if (SUPPORTS_LOCAL_STORAGE && localStorage.getItem(getLocalStorageHash(_this, 'isLocal')) === 'true') { + localStorage.setItem(getLocalStorageHash(_this, 'gui'), JSON.stringify(_this.getSaveObject())); + } + }; + this.saveToLocalStorageIfPossible = saveToLocalStorage; + function resetWidth() { + var root = _this.getRoot(); + root.width += 1; + Common.defer(function () { + root.width -= 1; + }); + } + if (!params.parent) { + resetWidth(); + } +}; +GUI.toggleHide = function () { + hide = !hide; + Common.each(hideableGuis, function (gui) { + gui.domElement.style.display = hide ? 'none' : ''; + }); +}; +GUI.CLASS_AUTO_PLACE = 'a'; +GUI.CLASS_AUTO_PLACE_CONTAINER = 'ac'; +GUI.CLASS_MAIN = 'main'; +GUI.CLASS_CONTROLLER_ROW = 'cr'; +GUI.CLASS_TOO_TALL = 'taller-than-window'; +GUI.CLASS_CLOSED = 'closed'; +GUI.CLASS_CLOSE_BUTTON = 'close-button'; +GUI.CLASS_CLOSE_TOP = 'close-top'; +GUI.CLASS_CLOSE_BOTTOM = 'close-bottom'; +GUI.CLASS_DRAG = 'drag'; +GUI.DEFAULT_WIDTH = 245; +GUI.TEXT_CLOSED = 'Close Controls'; +GUI.TEXT_OPEN = 'Open Controls'; +GUI._keydownHandler = function (e) { + if (document.activeElement.type !== 'text' && (e.which === HIDE_KEY_CODE || e.keyCode === HIDE_KEY_CODE)) { + GUI.toggleHide(); + } +}; +dom.bind(window, 'keydown', GUI._keydownHandler, false); +Common.extend(GUI.prototype, +{ + add: function add(object, property) { + return _add(this, object, property, { + factoryArgs: Array.prototype.slice.call(arguments, 2) + }); + }, + addColor: function addColor(object, property) { + return _add(this, object, property, { + color: true + }); + }, + remove: function remove(controller) { + this.__ul.removeChild(controller.__li); + this.__controllers.splice(this.__controllers.indexOf(controller), 1); + var _this = this; + Common.defer(function () { + _this.onResize(); + }); + }, + destroy: function destroy() { + if (this.parent) { + throw new Error('Only the root GUI should be removed with .destroy(). ' + 'For subfolders, use gui.removeFolder(folder) instead.'); + } + if (this.autoPlace) { + autoPlaceContainer.removeChild(this.domElement); + } + var _this = this; + Common.each(this.__folders, function (subfolder) { + _this.removeFolder(subfolder); + }); + dom.unbind(window, 'keydown', GUI._keydownHandler, false); + removeListeners(this); + }, + addFolder: function addFolder(name) { + if (this.__folders[name] !== undefined) { + throw new Error('You already have a folder in this GUI by the' + ' name "' + name + '"'); + } + var newGuiParams = { name: name, parent: this }; + newGuiParams.autoPlace = this.autoPlace; + if (this.load && + this.load.folders && + this.load.folders[name]) { + newGuiParams.closed = this.load.folders[name].closed; + newGuiParams.load = this.load.folders[name]; + } + var gui = new GUI(newGuiParams); + this.__folders[name] = gui; + var li = addRow(this, gui.domElement); + dom.addClass(li, 'folder'); + return gui; + }, + removeFolder: function removeFolder(folder) { + this.__ul.removeChild(folder.domElement.parentElement); + delete this.__folders[folder.name]; + if (this.load && + this.load.folders && + this.load.folders[folder.name]) { + delete this.load.folders[folder.name]; + } + removeListeners(folder); + var _this = this; + Common.each(folder.__folders, function (subfolder) { + folder.removeFolder(subfolder); + }); + Common.defer(function () { + _this.onResize(); + }); + }, + open: function open() { + this.closed = false; + }, + close: function close() { + this.closed = true; + }, + hide: function hide() { + this.domElement.style.display = 'none'; + }, + show: function show() { + this.domElement.style.display = ''; + }, + onResize: function onResize() { + var root = this.getRoot(); + if (root.scrollable) { + var top = dom.getOffset(root.__ul).top; + var h = 0; + Common.each(root.__ul.childNodes, function (node) { + if (!(root.autoPlace && node === root.__save_row)) { + h += dom.getHeight(node); + } + }); + if (window.innerHeight - top - CLOSE_BUTTON_HEIGHT < h) { + dom.addClass(root.domElement, GUI.CLASS_TOO_TALL); + root.__ul.style.height = window.innerHeight - top - CLOSE_BUTTON_HEIGHT + 'px'; + } else { + dom.removeClass(root.domElement, GUI.CLASS_TOO_TALL); + root.__ul.style.height = 'auto'; + } + } + if (root.__resize_handle) { + Common.defer(function () { + root.__resize_handle.style.height = root.__ul.offsetHeight + 'px'; + }); + } + if (root.__closeButton) { + root.__closeButton.style.width = root.width + 'px'; + } + }, + onResizeDebounced: Common.debounce(function () { + this.onResize(); + }, 50), + remember: function remember() { + if (Common.isUndefined(SAVE_DIALOGUE)) { + SAVE_DIALOGUE = new CenteredDiv(); + SAVE_DIALOGUE.domElement.innerHTML = saveDialogContents; + } + if (this.parent) { + throw new Error('You can only call remember on a top level GUI.'); + } + var _this = this; + Common.each(Array.prototype.slice.call(arguments), function (object) { + if (_this.__rememberedObjects.length === 0) { + addSaveMenu(_this); + } + if (_this.__rememberedObjects.indexOf(object) === -1) { + _this.__rememberedObjects.push(object); + } + }); + if (this.autoPlace) { + setWidth(this, this.width); + } + }, + getRoot: function getRoot() { + var gui = this; + while (gui.parent) { + gui = gui.parent; + } + return gui; + }, + getSaveObject: function getSaveObject() { + var toReturn = this.load; + toReturn.closed = this.closed; + if (this.__rememberedObjects.length > 0) { + toReturn.preset = this.preset; + if (!toReturn.remembered) { + toReturn.remembered = {}; + } + toReturn.remembered[this.preset] = getCurrentPreset(this); + } + toReturn.folders = {}; + Common.each(this.__folders, function (element, key) { + toReturn.folders[key] = element.getSaveObject(); + }); + return toReturn; + }, + save: function save() { + if (!this.load.remembered) { + this.load.remembered = {}; + } + this.load.remembered[this.preset] = getCurrentPreset(this); + markPresetModified(this, false); + this.saveToLocalStorageIfPossible(); + }, + saveAs: function saveAs(presetName) { + if (!this.load.remembered) { + this.load.remembered = {}; + this.load.remembered[DEFAULT_DEFAULT_PRESET_NAME] = getCurrentPreset(this, true); + } + this.load.remembered[presetName] = getCurrentPreset(this); + this.preset = presetName; + addPresetOption(this, presetName, true); + this.saveToLocalStorageIfPossible(); + }, + revert: function revert(gui) { + Common.each(this.__controllers, function (controller) { + if (!this.getRoot().load.remembered) { + controller.setValue(controller.initialValue); + } else { + recallSavedValue(gui || this.getRoot(), controller); + } + if (controller.__onFinishChange) { + controller.__onFinishChange.call(controller, controller.getValue()); + } + }, this); + Common.each(this.__folders, function (folder) { + folder.revert(folder); + }); + if (!gui) { + markPresetModified(this.getRoot(), false); + } + }, + listen: function listen(controller) { + var init = this.__listening.length === 0; + this.__listening.push(controller); + if (init) { + updateDisplays(this.__listening); + } + }, + updateDisplay: function updateDisplay() { + Common.each(this.__controllers, function (controller) { + controller.updateDisplay(); + }); + Common.each(this.__folders, function (folder) { + folder.updateDisplay(); + }); + } +}); +function addRow(gui, newDom, liBefore) { + var li = document.createElement('li'); + if (newDom) { + li.appendChild(newDom); + } + if (liBefore) { + gui.__ul.insertBefore(li, liBefore); + } else { + gui.__ul.appendChild(li); + } + gui.onResize(); + return li; +} +function removeListeners(gui) { + dom.unbind(window, 'resize', gui.__resizeHandler); + if (gui.saveToLocalStorageIfPossible) { + dom.unbind(window, 'unload', gui.saveToLocalStorageIfPossible); + } +} +function markPresetModified(gui, modified) { + var opt = gui.__preset_select[gui.__preset_select.selectedIndex]; + if (modified) { + opt.innerHTML = opt.value + '*'; + } else { + opt.innerHTML = opt.value; + } +} +function augmentController(gui, li, controller) { + controller.__li = li; + controller.__gui = gui; + Common.extend(controller, { + options: function options(_options) { + if (arguments.length > 1) { + var nextSibling = controller.__li.nextElementSibling; + controller.remove(); + return _add(gui, controller.object, controller.property, { + before: nextSibling, + factoryArgs: [Common.toArray(arguments)] + }); + } + if (Common.isArray(_options) || Common.isObject(_options)) { + var _nextSibling = controller.__li.nextElementSibling; + controller.remove(); + return _add(gui, controller.object, controller.property, { + before: _nextSibling, + factoryArgs: [_options] + }); + } + }, + name: function name(_name) { + controller.__li.firstElementChild.firstElementChild.innerHTML = _name; + return controller; + }, + listen: function listen() { + controller.__gui.listen(controller); + return controller; + }, + remove: function remove() { + controller.__gui.remove(controller); + return controller; + } + }); + if (controller instanceof NumberControllerSlider) { + var box = new NumberControllerBox(controller.object, controller.property, { min: controller.__min, max: controller.__max, step: controller.__step }); + Common.each(['updateDisplay', 'onChange', 'onFinishChange', 'step', 'min', 'max'], function (method) { + var pc = controller[method]; + var pb = box[method]; + controller[method] = box[method] = function () { + var args = Array.prototype.slice.call(arguments); + pb.apply(box, args); + return pc.apply(controller, args); + }; + }); + dom.addClass(li, 'has-slider'); + controller.domElement.insertBefore(box.domElement, controller.domElement.firstElementChild); + } else if (controller instanceof NumberControllerBox) { + var r = function r(returned) { + if (Common.isNumber(controller.__min) && Common.isNumber(controller.__max)) { + var oldName = controller.__li.firstElementChild.firstElementChild.innerHTML; + var wasListening = controller.__gui.__listening.indexOf(controller) > -1; + controller.remove(); + var newController = _add(gui, controller.object, controller.property, { + before: controller.__li.nextElementSibling, + factoryArgs: [controller.__min, controller.__max, controller.__step] + }); + newController.name(oldName); + if (wasListening) newController.listen(); + return newController; + } + return returned; + }; + controller.min = Common.compose(r, controller.min); + controller.max = Common.compose(r, controller.max); + } else if (controller instanceof BooleanController) { + dom.bind(li, 'click', function () { + dom.fakeEvent(controller.__checkbox, 'click'); + }); + dom.bind(controller.__checkbox, 'click', function (e) { + e.stopPropagation(); + }); + } else if (controller instanceof FunctionController) { + dom.bind(li, 'click', function () { + dom.fakeEvent(controller.__button, 'click'); + }); + dom.bind(li, 'mouseover', function () { + dom.addClass(controller.__button, 'hover'); + }); + dom.bind(li, 'mouseout', function () { + dom.removeClass(controller.__button, 'hover'); + }); + } else if (controller instanceof ColorController) { + dom.addClass(li, 'color'); + controller.updateDisplay = Common.compose(function (val) { + li.style.borderLeftColor = controller.__color.toString(); + return val; + }, controller.updateDisplay); + controller.updateDisplay(); + } + controller.setValue = Common.compose(function (val) { + if (gui.getRoot().__preset_select && controller.isModified()) { + markPresetModified(gui.getRoot(), true); + } + return val; + }, controller.setValue); +} +function recallSavedValue(gui, controller) { + var root = gui.getRoot(); + var matchedIndex = root.__rememberedObjects.indexOf(controller.object); + if (matchedIndex !== -1) { + var controllerMap = root.__rememberedObjectIndecesToControllers[matchedIndex]; + if (controllerMap === undefined) { + controllerMap = {}; + root.__rememberedObjectIndecesToControllers[matchedIndex] = controllerMap; + } + controllerMap[controller.property] = controller; + if (root.load && root.load.remembered) { + var presetMap = root.load.remembered; + var preset = void 0; + if (presetMap[gui.preset]) { + preset = presetMap[gui.preset]; + } else if (presetMap[DEFAULT_DEFAULT_PRESET_NAME]) { + preset = presetMap[DEFAULT_DEFAULT_PRESET_NAME]; + } else { + return; + } + if (preset[matchedIndex] && preset[matchedIndex][controller.property] !== undefined) { + var value = preset[matchedIndex][controller.property]; + controller.initialValue = value; + controller.setValue(value); + } + } + } +} +function _add(gui, object, property, params) { + if (object[property] === undefined) { + throw new Error('Object "' + object + '" has no property "' + property + '"'); + } + var controller = void 0; + if (params.color) { + controller = new ColorController(object, property); + } else { + var factoryArgs = [object, property].concat(params.factoryArgs); + controller = ControllerFactory.apply(gui, factoryArgs); + } + if (params.before instanceof Controller) { + params.before = params.before.__li; + } + recallSavedValue(gui, controller); + dom.addClass(controller.domElement, 'c'); + var name = document.createElement('span'); + dom.addClass(name, 'property-name'); + name.innerHTML = controller.property; + var container = document.createElement('div'); + container.appendChild(name); + container.appendChild(controller.domElement); + var li = addRow(gui, container, params.before); + dom.addClass(li, GUI.CLASS_CONTROLLER_ROW); + if (controller instanceof ColorController) { + dom.addClass(li, 'color'); + } else { + dom.addClass(li, _typeof(controller.getValue())); + } + augmentController(gui, li, controller); + gui.__controllers.push(controller); + return controller; +} +function getLocalStorageHash(gui, key) { + return document.location.href + '.' + key; +} +function addPresetOption(gui, name, setSelected) { + var opt = document.createElement('option'); + opt.innerHTML = name; + opt.value = name; + gui.__preset_select.appendChild(opt); + if (setSelected) { + gui.__preset_select.selectedIndex = gui.__preset_select.length - 1; + } +} +function showHideExplain(gui, explain) { + explain.style.display = gui.useLocalStorage ? 'block' : 'none'; +} +function addSaveMenu(gui) { + var div = gui.__save_row = document.createElement('li'); + dom.addClass(gui.domElement, 'has-save'); + gui.__ul.insertBefore(div, gui.__ul.firstChild); + dom.addClass(div, 'save-row'); + var gears = document.createElement('span'); + gears.innerHTML = ' '; + dom.addClass(gears, 'button gears'); + var button = document.createElement('span'); + button.innerHTML = 'Save'; + dom.addClass(button, 'button'); + dom.addClass(button, 'save'); + var button2 = document.createElement('span'); + button2.innerHTML = 'New'; + dom.addClass(button2, 'button'); + dom.addClass(button2, 'save-as'); + var button3 = document.createElement('span'); + button3.innerHTML = 'Revert'; + dom.addClass(button3, 'button'); + dom.addClass(button3, 'revert'); + var select = gui.__preset_select = document.createElement('select'); + if (gui.load && gui.load.remembered) { + Common.each(gui.load.remembered, function (value, key) { + addPresetOption(gui, key, key === gui.preset); + }); + } else { + addPresetOption(gui, DEFAULT_DEFAULT_PRESET_NAME, false); + } + dom.bind(select, 'change', function () { + for (var index = 0; index < gui.__preset_select.length; index++) { + gui.__preset_select[index].innerHTML = gui.__preset_select[index].value; + } + gui.preset = this.value; + }); + div.appendChild(select); + div.appendChild(gears); + div.appendChild(button); + div.appendChild(button2); + div.appendChild(button3); + if (SUPPORTS_LOCAL_STORAGE) { + var explain = document.getElementById('dg-local-explain'); + var localStorageCheckBox = document.getElementById('dg-local-storage'); + var saveLocally = document.getElementById('dg-save-locally'); + saveLocally.style.display = 'block'; + if (localStorage.getItem(getLocalStorageHash(gui, 'isLocal')) === 'true') { + localStorageCheckBox.setAttribute('checked', 'checked'); + } + showHideExplain(gui, explain); + dom.bind(localStorageCheckBox, 'change', function () { + gui.useLocalStorage = !gui.useLocalStorage; + showHideExplain(gui, explain); + }); + } + var newConstructorTextArea = document.getElementById('dg-new-constructor'); + dom.bind(newConstructorTextArea, 'keydown', function (e) { + if (e.metaKey && (e.which === 67 || e.keyCode === 67)) { + SAVE_DIALOGUE.hide(); + } + }); + dom.bind(gears, 'click', function () { + newConstructorTextArea.innerHTML = JSON.stringify(gui.getSaveObject(), undefined, 2); + SAVE_DIALOGUE.show(); + newConstructorTextArea.focus(); + newConstructorTextArea.select(); + }); + dom.bind(button, 'click', function () { + gui.save(); + }); + dom.bind(button2, 'click', function () { + var presetName = prompt('Enter a new preset name.'); + if (presetName) { + gui.saveAs(presetName); + } + }); + dom.bind(button3, 'click', function () { + gui.revert(); + }); +} +function addResizeHandle(gui) { + var pmouseX = void 0; + gui.__resize_handle = document.createElement('div'); + Common.extend(gui.__resize_handle.style, { + width: '6px', + marginLeft: '-3px', + height: '200px', + cursor: 'ew-resize', + position: 'absolute' + }); + function drag(e) { + e.preventDefault(); + gui.width += pmouseX - e.clientX; + gui.onResize(); + pmouseX = e.clientX; + return false; + } + function dragStop() { + dom.removeClass(gui.__closeButton, GUI.CLASS_DRAG); + dom.unbind(window, 'mousemove', drag); + dom.unbind(window, 'mouseup', dragStop); + } + function dragStart(e) { + e.preventDefault(); + pmouseX = e.clientX; + dom.addClass(gui.__closeButton, GUI.CLASS_DRAG); + dom.bind(window, 'mousemove', drag); + dom.bind(window, 'mouseup', dragStop); + return false; + } + dom.bind(gui.__resize_handle, 'mousedown', dragStart); + dom.bind(gui.__closeButton, 'mousedown', dragStart); + gui.domElement.insertBefore(gui.__resize_handle, gui.domElement.firstElementChild); +} +function setWidth(gui, w) { + gui.domElement.style.width = w + 'px'; + if (gui.__save_row && gui.autoPlace) { + gui.__save_row.style.width = w + 'px'; + } + if (gui.__closeButton) { + gui.__closeButton.style.width = w + 'px'; + } +} +function getCurrentPreset(gui, useInitialValues) { + var toReturn = {}; + Common.each(gui.__rememberedObjects, function (val, index) { + var savedValues = {}; + var controllerMap = gui.__rememberedObjectIndecesToControllers[index]; + Common.each(controllerMap, function (controller, property) { + savedValues[property] = useInitialValues ? controller.initialValue : controller.getValue(); + }); + toReturn[index] = savedValues; + }); + return toReturn; +} +function setPresetSelectIndex(gui) { + for (var index = 0; index < gui.__preset_select.length; index++) { + if (gui.__preset_select[index].value === gui.preset) { + gui.__preset_select.selectedIndex = index; + } + } +} +function updateDisplays(controllerArray) { + if (controllerArray.length !== 0) { + requestAnimationFrame$1.call(window, function () { + updateDisplays(controllerArray); + }); + } + Common.each(controllerArray, function (c) { + c.updateDisplay(); + }); +} + +var color = { + Color: Color, + math: ColorMath, + interpret: interpret +}; +var controllers = { + Controller: Controller, + BooleanController: BooleanController, + OptionController: OptionController, + StringController: StringController, + NumberController: NumberController, + NumberControllerBox: NumberControllerBox, + NumberControllerSlider: NumberControllerSlider, + FunctionController: FunctionController, + ColorController: ColorController +}; +var dom$1 = { dom: dom }; +var gui = { GUI: GUI }; +var GUI$1 = GUI; +var index = { + color: color, + controllers: controllers, + dom: dom$1, + gui: gui, + GUI: GUI$1 +}; + +export { color, controllers, dom$1 as dom, gui, GUI$1 as GUI }; +export default index; +//# sourceMappingURL=dat.gui.module.js.map diff --git a/demo/libs/gemini-viewer.esm.min.js b/demo/libs/gemini-viewer.esm.min.js index 238edca..f48e85d 100644 --- a/demo/libs/gemini-viewer.esm.min.js +++ b/demo/libs/gemini-viewer.esm.min.js @@ -1 +1 @@ -var vSe=Object.create,m1=Object.defineProperty,ySe=Object.defineProperties,xSe=Object.getOwnPropertyDescriptor,bSe=Object.getOwnPropertyDescriptors,ESe=Object.getOwnPropertyNames,aG=Object.getOwnPropertySymbols,oG=Object.getPrototypeOf,lG=Object.prototype.hasOwnProperty,_Se=Object.prototype.propertyIsEnumerable,TSe=Reflect.get,Do=Math.pow,s3=(e,t,n)=>t in e?m1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wr=(e,t)=>{for(var n in t||(t={}))lG.call(t,n)&&s3(e,n,t[n]);if(aG)for(var n of aG(t))_Se.call(t,n)&&s3(e,n,t[n]);return e},Ri=(e,t)=>ySe(e,bSe(t)),a3=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)((function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')})),wSe=(e,t)=>()=>(e&&(t=e(e=0)),t),J=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),FT=(e,t)=>{for(var n in t)m1(e,n,{get:t[n],enumerable:!0})},cG=(e,t,n,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of ESe(t))!lG.call(e,r)&&r!==n&&m1(e,r,{get:()=>t[r],enumerable:!(i=xSe(t,r))||i.enumerable});return e},ji=(e,t,n)=>(n=null!=e?vSe(oG(e)):{},cG(!t&&e&&e.__esModule?n:m1(n,"default",{value:e,enumerable:!0}),e)),SSe=e=>cG(m1({},"__esModule",{value:!0}),e),Xi=(e,t,n)=>(s3(e,"symbol"!=typeof t?t+"":t,n),n),o3=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},ce=(e,t,n)=>(o3(e,t,"read from private field"),n?n.call(e):t.get(e)),Je=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},St=(e,t,n,i)=>(o3(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),NT=(e,t,n,i)=>({set _(i){St(e,t,i,n)},get _(){return ce(e,t,i)}}),dt=(e,t,n)=>(o3(e,t,"access private method"),n),uG=(e,t,n)=>TSe(oG(e),n,t),ft=(e,t,n)=>new Promise(((i,r)=>{var a=e=>{try{o(n.next(e))}catch(e){r(e)}},s=e=>{try{o(n.throw(e))}catch(e){r(e)}},o=e=>e.done?i(e.value):Promise.resolve(e.value).then(a,s);o((n=n.apply(e,t)).next())})),fG={};function BT(e){return(BT="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function RSe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function hG(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};RSe(this,r),this._locale=function(e){for(var t=dG(e),n=0;nLSe});var CSe,dG,PSe,ISe,pG=wSe((()=>{CSe=function(e){return e.split("-").every((function(e){return/[a-z0-9]+/i.test(e)}))},dG=function(e){if(!e)return[];Array.isArray(e)||(e=[e]);for(var t={},n=0;n{"use strict";function n(e,t){for(var n=0;n="0"&&r<="9"&&++n}return nthis._maxSD?e.toPrecision(this._maxSD):t}return this._minFD>0?e.toFixed(this._minFD):0===this._maxFD?e.toFixed(0):String(e)}}]),e}();t.exports=i})),SG=J(((e,t)=>{"use strict";var n=(pG(),SSe(fG)),i=vG();function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=r(n),s=r(i);function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var h,c,u,d,p,f,m,g,v={exports:{}};h=v,u=function(e,t){return t?"other":1==e?"one":"other"},d=function(e,t){return t?"other":0==e||1==e?"one":"other"},p=function(e,t){return t?"other":e>=0&&e<=1?"one":"other"},f=function(e,t){var n=!String(e).split(".")[1];return t?"other":1==e&&n?"one":"other"},g=function(e,t){return t?"other":1==e?"one":2==e?"two":"other"},c={_in:m=function(e,t){return"other"},af:u,ak:d,am:p,an:u,ar:function(e,t){var n=String(e).split("."),i=Number(n[0])==e&&n[0].slice(-2);return t?"other":0==e?"zero":1==e?"one":2==e?"two":i>=3&&i<=10?"few":i>=11&&i<=99?"many":"other"},ars:function(e,t){var n=String(e).split("."),i=Number(n[0])==e&&n[0].slice(-2);return t?"other":0==e?"zero":1==e?"one":2==e?"two":i>=3&&i<=10?"few":i>=11&&i<=99?"many":"other"},as:function(e,t){return t?1==e||5==e||7==e||8==e||9==e||10==e?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":e>=0&&e<=1?"one":"other"},asa:u,ast:f,az:function(e,t){var n=String(e).split(".")[0],i=n.slice(-1),r=n.slice(-2),a=n.slice(-3);return t?1==i||2==i||5==i||7==i||8==i||20==r||50==r||70==r||80==r?"one":3==i||4==i||100==a||200==a||300==a||400==a||500==a||600==a||700==a||800==a||900==a?"few":0==n||6==i||40==r||60==r||90==r?"many":"other":1==e?"one":"other"},be:function(e,t){var n=String(e).split("."),i=Number(n[0])==e,r=i&&n[0].slice(-1),a=i&&n[0].slice(-2);return t?2!=r&&3!=r||12==a||13==a?"other":"few":1==r&&11!=a?"one":r>=2&&r<=4&&(a<12||a>14)?"few":i&&0==r||r>=5&&r<=9||a>=11&&a<=14?"many":"other"},bem:u,bez:u,bg:u,bho:d,bm:m,bn:function(e,t){return t?1==e||5==e||7==e||8==e||9==e||10==e?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":e>=0&&e<=1?"one":"other"},bo:m,br:function(e,t){var n=String(e).split("."),i=Number(n[0])==e,r=i&&n[0].slice(-1),a=i&&n[0].slice(-2),s=i&&n[0].slice(-6);return t?"other":1==r&&11!=a&&71!=a&&91!=a?"one":2==r&&12!=a&&72!=a&&92!=a?"two":(3==r||4==r||9==r)&&(a<10||a>19)&&(a<70||a>79)&&(a<90||a>99)?"few":0!=e&&i&&0==s?"many":"other"},brx:u,bs:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=i.slice(-2),l=r.slice(-1),h=r.slice(-2);return t?"other":a&&1==s&&11!=o||1==l&&11!=h?"one":a&&s>=2&&s<=4&&(o<12||o>14)||l>=2&&l<=4&&(h<12||h>14)?"few":"other"},ca:function(e,t){var n=!String(e).split(".")[1];return t?1==e||3==e?"one":2==e?"two":4==e?"few":"other":1==e&&n?"one":"other"},ce:u,ceb:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=r.slice(-1);return t?"other":a&&(1==i||2==i||3==i)||a&&4!=s&&6!=s&&9!=s||!a&&4!=o&&6!=o&&9!=o?"one":"other"},cgg:u,chr:u,ckb:u,cs:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1];return t?"other":1==e&&r?"one":i>=2&&i<=4&&r?"few":r?"other":"many"},cy:function(e,t){return t?0==e||7==e||8==e||9==e?"zero":1==e?"one":2==e?"two":3==e||4==e?"few":5==e||6==e?"many":"other":0==e?"zero":1==e?"one":2==e?"two":3==e?"few":6==e?"many":"other"},da:function(e,t){var n=String(e).split("."),i=n[0],r=Number(n[0])==e;return t||1!=e&&(r||0!=i&&1!=i)?"other":"one"},de:f,doi:p,dsb:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-2),o=r.slice(-2);return t?"other":a&&1==s||1==o?"one":a&&2==s||2==o?"two":a&&(3==s||4==s)||3==o||4==o?"few":"other"},dv:u,dz:m,ee:u,el:u,en:function(e,t){var n=String(e).split("."),i=!n[1],r=Number(n[0])==e,a=r&&n[0].slice(-1),s=r&&n[0].slice(-2);return t?1==a&&11!=s?"one":2==a&&12!=s?"two":3==a&&13!=s?"few":"other":1==e&&i?"one":"other"},eo:u,es:u,et:f,eu:u,fa:p,ff:function(e,t){return t?"other":e>=0&&e<2?"one":"other"},fi:f,fil:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=r.slice(-1);return t?1==e?"one":"other":a&&(1==i||2==i||3==i)||a&&4!=s&&6!=s&&9!=s||!a&&4!=o&&6!=o&&9!=o?"one":"other"},fo:u,fr:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=i.slice(-6);return t?1==e?"one":"other":e>=0&&e<2?"one":0!=i&&0==a&&r?"many":"other"},fur:u,fy:f,ga:function(e,t){var n=String(e).split("."),i=Number(n[0])==e;return t?1==e?"one":"other":1==e?"one":2==e?"two":i&&e>=3&&e<=6?"few":i&&e>=7&&e<=10?"many":"other"},gd:function(e,t){var n=String(e).split("."),i=Number(n[0])==e;return t?1==e||11==e?"one":2==e||12==e?"two":3==e||13==e?"few":"other":1==e||11==e?"one":2==e||12==e?"two":i&&e>=3&&e<=10||i&&e>=13&&e<=19?"few":"other"},gl:f,gsw:u,gu:function(e,t){return t?1==e?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":e>=0&&e<=1?"one":"other"},guw:d,gv:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=i.slice(-1),s=i.slice(-2);return t?"other":r&&1==a?"one":r&&2==a?"two":!r||0!=s&&20!=s&&40!=s&&60!=s&&80!=s?r?"other":"many":"few"},ha:u,haw:u,he:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=Number(n[0])==e,s=a&&n[0].slice(-1);return t?"other":1==e&&r?"one":2==i&&r?"two":r&&(e<0||e>10)&&a&&0==s?"many":"other"},hi:function(e,t){return t?1==e?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":e>=0&&e<=1?"one":"other"},hr:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=i.slice(-2),l=r.slice(-1),h=r.slice(-2);return t?"other":a&&1==s&&11!=o||1==l&&11!=h?"one":a&&s>=2&&s<=4&&(o<12||o>14)||l>=2&&l<=4&&(h<12||h>14)?"few":"other"},hsb:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-2),o=r.slice(-2);return t?"other":a&&1==s||1==o?"one":a&&2==s||2==o?"two":a&&(3==s||4==s)||3==o||4==o?"few":"other"},hu:function(e,t){return t?1==e||5==e?"one":"other":1==e?"one":"other"},hy:function(e,t){return t?1==e?"one":"other":e>=0&&e<2?"one":"other"},ia:f,id:m,ig:m,ii:m,io:f,is:function(e,t){var n=String(e).split("."),i=n[0],r=Number(n[0])==e,a=i.slice(-1),s=i.slice(-2);return t?"other":r&&1==a&&11!=s||!r?"one":"other"},it:function(e,t){var n=!String(e).split(".")[1];return t?11==e||8==e||80==e||800==e?"many":"other":1==e&&n?"one":"other"},iu:g,iw:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=Number(n[0])==e,s=a&&n[0].slice(-1);return t?"other":1==e&&r?"one":2==i&&r?"two":r&&(e<0||e>10)&&a&&0==s?"many":"other"},ja:m,jbo:m,jgo:u,ji:f,jmc:u,jv:m,jw:m,ka:function(e,t){var n=String(e).split(".")[0],i=n.slice(-2);return t?1==n?"one":0==n||i>=2&&i<=20||40==i||60==i||80==i?"many":"other":1==e?"one":"other"},kab:function(e,t){return t?"other":e>=0&&e<2?"one":"other"},kaj:u,kcg:u,kde:m,kea:m,kk:function(e,t){var n=String(e).split("."),i=Number(n[0])==e,r=i&&n[0].slice(-1);return t?6==r||9==r||i&&0==r&&0!=e?"many":"other":1==e?"one":"other"},kkj:u,kl:u,km:m,kn:p,ko:m,ks:u,ksb:u,ksh:function(e,t){return t?"other":0==e?"zero":1==e?"one":"other"},ku:u,kw:function(e,t){var n=String(e).split("."),i=Number(n[0])==e,r=i&&n[0].slice(-2),a=i&&n[0].slice(-3),s=i&&n[0].slice(-5),o=i&&n[0].slice(-6);return t?i&&e>=1&&e<=4||r>=1&&r<=4||r>=21&&r<=24||r>=41&&r<=44||r>=61&&r<=64||r>=81&&r<=84?"one":5==e||5==r?"many":"other":0==e?"zero":1==e?"one":2==r||22==r||42==r||62==r||82==r||i&&0==a&&(s>=1e3&&s<=2e4||4e4==s||6e4==s||8e4==s)||0!=e&&1e5==o?"two":3==r||23==r||43==r||63==r||83==r?"few":1==e||1!=r&&21!=r&&41!=r&&61!=r&&81!=r?"other":"many"},ky:u,lag:function(e,t){var n=String(e).split(".")[0];return t?"other":0==e?"zero":0!=n&&1!=n||0==e?"other":"one"},lb:u,lg:u,lij:function(e,t){var n=String(e).split("."),i=!n[1],r=Number(n[0])==e;return t?11==e||8==e||r&&e>=80&&e<=89||r&&e>=800&&e<=899?"many":"other":1==e&&i?"one":"other"},lkt:m,ln:d,lo:function(e,t){return t&&1==e?"one":"other"},lt:function(e,t){var n=String(e).split("."),i=n[1]||"",r=Number(n[0])==e,a=r&&n[0].slice(-1),s=r&&n[0].slice(-2);return t?"other":1==a&&(s<11||s>19)?"one":a>=2&&a<=9&&(s<11||s>19)?"few":0!=i?"many":"other"},lv:function(e,t){var n=String(e).split("."),i=n[1]||"",r=i.length,a=Number(n[0])==e,s=a&&n[0].slice(-1),o=a&&n[0].slice(-2),l=i.slice(-2),h=i.slice(-1);return t?"other":a&&0==s||o>=11&&o<=19||2==r&&l>=11&&l<=19?"zero":1==s&&11!=o||2==r&&1==h&&11!=l||2!=r&&1==h?"one":"other"},mas:u,mg:d,mgo:u,mk:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=i.slice(-2),l=r.slice(-1),h=r.slice(-2);return t?1==s&&11!=o?"one":2==s&&12!=o?"two":7!=s&&8!=s||17==o||18==o?"other":"many":a&&1==s&&11!=o||1==l&&11!=h?"one":"other"},ml:u,mn:u,mo:function(e,t){var n=String(e).split("."),i=!n[1],r=Number(n[0])==e&&n[0].slice(-2);return t?1==e?"one":"other":1==e&&i?"one":!i||0==e||r>=2&&r<=19?"few":"other"},mr:function(e,t){return t?1==e?"one":2==e||3==e?"two":4==e?"few":"other":1==e?"one":"other"},ms:function(e,t){return t&&1==e?"one":"other"},mt:function(e,t){var n=String(e).split("."),i=Number(n[0])==e&&n[0].slice(-2);return t?"other":1==e?"one":0==e||i>=2&&i<=10?"few":i>=11&&i<=19?"many":"other"},my:m,nah:u,naq:g,nb:u,nd:u,ne:function(e,t){var n=String(e).split("."),i=Number(n[0])==e;return t?i&&e>=1&&e<=4?"one":"other":1==e?"one":"other"},nl:f,nn:u,nnh:u,no:u,nqo:m,nr:u,nso:d,ny:u,nyn:u,om:u,or:function(e,t){var n=String(e).split("."),i=Number(n[0])==e;return t?1==e||5==e||i&&e>=7&&e<=9?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":1==e?"one":"other"},os:u,osa:m,pa:d,pap:u,pcm:p,pl:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=i.slice(-1),s=i.slice(-2);return t?"other":1==e&&r?"one":r&&a>=2&&a<=4&&(s<12||s>14)?"few":r&&1!=i&&(0==a||1==a)||r&&a>=5&&a<=9||r&&s>=12&&s<=14?"many":"other"},prg:function(e,t){var n=String(e).split("."),i=n[1]||"",r=i.length,a=Number(n[0])==e,s=a&&n[0].slice(-1),o=a&&n[0].slice(-2),l=i.slice(-2),h=i.slice(-1);return t?"other":a&&0==s||o>=11&&o<=19||2==r&&l>=11&&l<=19?"zero":1==s&&11!=o||2==r&&1==h&&11!=l||2!=r&&1==h?"one":"other"},ps:u,pt:function(e,t){var n=String(e).split(".")[0];return t?"other":0==n||1==n?"one":"other"},pt_PT:f,rm:u,ro:function(e,t){var n=String(e).split("."),i=!n[1],r=Number(n[0])==e&&n[0].slice(-2);return t?1==e?"one":"other":1==e&&i?"one":!i||0==e||r>=2&&r<=19?"few":"other"},rof:u,root:m,ru:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=i.slice(-1),s=i.slice(-2);return t?"other":r&&1==a&&11!=s?"one":r&&a>=2&&a<=4&&(s<12||s>14)?"few":r&&0==a||r&&a>=5&&a<=9||r&&s>=11&&s<=14?"many":"other"},rwk:u,sah:m,saq:u,sat:g,sc:function(e,t){var n=!String(e).split(".")[1];return t?11==e||8==e||80==e||800==e?"many":"other":1==e&&n?"one":"other"},scn:function(e,t){var n=!String(e).split(".")[1];return t?11==e||8==e||80==e||800==e?"many":"other":1==e&&n?"one":"other"},sd:u,sdh:u,se:g,seh:u,ses:m,sg:m,sh:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=i.slice(-2),l=r.slice(-1),h=r.slice(-2);return t?"other":a&&1==s&&11!=o||1==l&&11!=h?"one":a&&s>=2&&s<=4&&(o<12||o>14)||l>=2&&l<=4&&(h<12||h>14)?"few":"other"},shi:function(e,t){var n=String(e).split("."),i=Number(n[0])==e;return t?"other":e>=0&&e<=1?"one":i&&e>=2&&e<=10?"few":"other"},si:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"";return t?"other":0==e||1==e||0==i&&1==r?"one":"other"},sk:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1];return t?"other":1==e&&r?"one":i>=2&&i<=4&&r?"few":r?"other":"many"},sl:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=i.slice(-2);return t?"other":r&&1==a?"one":r&&2==a?"two":r&&(3==a||4==a)||!r?"few":"other"},sma:g,smi:g,smj:g,smn:g,sms:g,sn:u,so:u,sq:function(e,t){var n=String(e).split("."),i=Number(n[0])==e,r=i&&n[0].slice(-1),a=i&&n[0].slice(-2);return t?1==e?"one":4==r&&14!=a?"many":"other":1==e?"one":"other"},sr:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=i.slice(-2),l=r.slice(-1),h=r.slice(-2);return t?"other":a&&1==s&&11!=o||1==l&&11!=h?"one":a&&s>=2&&s<=4&&(o<12||o>14)||l>=2&&l<=4&&(h<12||h>14)?"few":"other"},ss:u,ssy:u,st:u,su:m,sv:function(e,t){var n=String(e).split("."),i=!n[1],r=Number(n[0])==e,a=r&&n[0].slice(-1),s=r&&n[0].slice(-2);return t?1!=a&&2!=a||11==s||12==s?"other":"one":1==e&&i?"one":"other"},sw:f,syr:u,ta:u,te:u,teo:u,th:m,ti:d,tig:u,tk:function(e,t){var n=String(e).split("."),i=Number(n[0])==e&&n[0].slice(-1);return t?6==i||9==i||10==e?"few":"other":1==e?"one":"other"},tl:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=r.slice(-1);return t?1==e?"one":"other":a&&(1==i||2==i||3==i)||a&&4!=s&&6!=s&&9!=s||!a&&4!=o&&6!=o&&9!=o?"one":"other"},tn:u,to:m,tr:u,ts:u,tzm:function(e,t){var n=String(e).split("."),i=Number(n[0])==e;return t?"other":0==e||1==e||i&&e>=11&&e<=99?"one":"other"},ug:u,uk:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=Number(n[0])==e,s=a&&n[0].slice(-1),o=a&&n[0].slice(-2),l=i.slice(-1),h=i.slice(-2);return t?3==s&&13!=o?"few":"other":r&&1==l&&11!=h?"one":r&&l>=2&&l<=4&&(h<12||h>14)?"few":r&&0==l||r&&l>=5&&l<=9||r&&h>=11&&h<=14?"many":"other"},ur:f,uz:u,ve:u,vi:function(e,t){return t&&1==e?"one":"other"},vo:u,vun:u,wa:d,wae:u,wo:m,xh:u,xog:u,yi:f,yo:m,yue:m,zh:m,zu:p},Object.defineProperty(c,"__esModule",{value:!0}),h.exports=c;var y=l(v.exports),x=Object.freeze(Object.assign(Object.create(null),v.exports,{default:y})),b={exports:{}};!function(e,t){var n,i="zero",r="one",a="two",s="few",o="many",l="other",h={cardinal:[r,l],ordinal:[l]},c={cardinal:[l],ordinal:[l]},u={cardinal:[r,s,o,l],ordinal:[l]},d={cardinal:[r,l],ordinal:[r,l]},p={cardinal:[r,a,l],ordinal:[l]};n={_in:c,af:h,ak:h,am:h,an:h,ar:{cardinal:[i,r,a,s,o,l],ordinal:[l]},ars:{cardinal:[i,r,a,s,o,l],ordinal:[l]},as:{cardinal:[r,l],ordinal:[r,a,s,o,l]},asa:h,ast:h,az:{cardinal:[r,l],ordinal:[r,s,o,l]},be:{cardinal:[r,s,o,l],ordinal:[s,l]},bem:h,bez:h,bg:h,bho:h,bm:c,bn:{cardinal:[r,l],ordinal:[r,a,s,o,l]},bo:c,br:{cardinal:[r,a,s,o,l],ordinal:[l]},brx:h,bs:{cardinal:[r,s,l],ordinal:[l]},ca:{cardinal:[r,l],ordinal:[r,a,s,l]},ce:h,ceb:h,cgg:h,chr:h,ckb:h,cs:u,cy:{cardinal:[i,r,a,s,o,l],ordinal:[i,r,a,s,o,l]},da:h,de:h,doi:h,dsb:{cardinal:[r,a,s,l],ordinal:[l]},dv:h,dz:c,ee:h,el:h,en:{cardinal:[r,l],ordinal:[r,a,s,l]},eo:h,es:h,et:h,eu:h,fa:h,ff:h,fi:h,fil:d,fo:h,fr:{cardinal:[r,o,l],ordinal:[r,l]},fur:h,fy:h,ga:{cardinal:[r,a,s,o,l],ordinal:[r,l]},gd:{cardinal:[r,a,s,l],ordinal:[r,a,s,l]},gl:h,gsw:h,gu:{cardinal:[r,l],ordinal:[r,a,s,o,l]},guw:h,gv:{cardinal:[r,a,s,o,l],ordinal:[l]},ha:h,haw:h,he:{cardinal:[r,a,o,l],ordinal:[l]},hi:{cardinal:[r,l],ordinal:[r,a,s,o,l]},hr:{cardinal:[r,s,l],ordinal:[l]},hsb:{cardinal:[r,a,s,l],ordinal:[l]},hu:d,hy:d,ia:h,id:c,ig:c,ii:c,io:h,is:h,it:{cardinal:[r,l],ordinal:[o,l]},iu:p,iw:{cardinal:[r,a,o,l],ordinal:[l]},ja:c,jbo:c,jgo:h,ji:h,jmc:h,jv:c,jw:c,ka:{cardinal:[r,l],ordinal:[r,o,l]},kab:h,kaj:h,kcg:h,kde:c,kea:c,kk:{cardinal:[r,l],ordinal:[o,l]},kkj:h,kl:h,km:c,kn:h,ko:c,ks:h,ksb:h,ksh:{cardinal:[i,r,l],ordinal:[l]},ku:h,kw:{cardinal:[i,r,a,s,o,l],ordinal:[r,o,l]},ky:h,lag:{cardinal:[i,r,l],ordinal:[l]},lb:h,lg:h,lij:{cardinal:[r,l],ordinal:[o,l]},lkt:c,ln:h,lo:{cardinal:[l],ordinal:[r,l]},lt:u,lv:{cardinal:[i,r,l],ordinal:[l]},mas:h,mg:h,mgo:h,mk:{cardinal:[r,l],ordinal:[r,a,o,l]},ml:h,mn:h,mo:{cardinal:[r,s,l],ordinal:[r,l]},mr:{cardinal:[r,l],ordinal:[r,a,s,l]},ms:{cardinal:[l],ordinal:[r,l]},mt:u,my:c,nah:h,naq:p,nb:h,nd:h,ne:d,nl:h,nn:h,nnh:h,no:h,nqo:c,nr:h,nso:h,ny:h,nyn:h,om:h,or:{cardinal:[r,l],ordinal:[r,a,s,o,l]},os:h,osa:c,pa:h,pap:h,pcm:h,pl:u,prg:{cardinal:[i,r,l],ordinal:[l]},ps:h,pt:h,pt_PT:h,rm:h,ro:{cardinal:[r,s,l],ordinal:[r,l]},rof:h,root:c,ru:u,rwk:h,sah:c,saq:h,sat:p,sc:{cardinal:[r,l],ordinal:[o,l]},scn:{cardinal:[r,l],ordinal:[o,l]},sd:h,sdh:h,se:p,seh:h,ses:c,sg:c,sh:{cardinal:[r,s,l],ordinal:[l]},shi:{cardinal:[r,s,l],ordinal:[l]},si:h,sk:u,sl:{cardinal:[r,a,s,l],ordinal:[l]},sma:p,smi:p,smj:p,smn:p,sms:p,sn:h,so:h,sq:{cardinal:[r,l],ordinal:[r,o,l]},sr:{cardinal:[r,s,l],ordinal:[l]},ss:h,ssy:h,st:h,su:c,sv:d,sw:h,syr:h,ta:h,te:h,teo:h,th:c,ti:h,tig:h,tk:{cardinal:[r,l],ordinal:[s,l]},tl:d,tn:h,to:c,tr:h,ts:h,tzm:h,ug:h,uk:{cardinal:[r,s,o,l],ordinal:[s,l]},ur:h,uz:h,ve:h,vi:{cardinal:[l],ordinal:[r,l]},vo:h,vun:h,wa:h,wae:h,wo:c,xh:h,xog:h,yi:h,yo:c,yue:c,zh:c,zu:h},Object.defineProperty(n,"__esModule",{value:!0}),e.exports=n}(b);var _=l(b.exports),w=Object.freeze(Object.assign(Object.create(null),b.exports,{default:_})),S=y||x,M=_||w,E="object"===("undefined"==typeof Intl?"undefined":o(Intl))&&Intl.NumberFormat||s.default,T=function(e){return"in"===e?"_in":"pt-PT"===e?"pt_PT":e},A=a.default(E,(function(e){return S[T(e)]}),(function(e,t){return M[T(e)][t?"ordinal":"cardinal"]}));t.exports=A})),AG=J((e=>{"use strict";var t,n,i=(t=SG())&&"object"==typeof t&&"default"in t?t:{default:t};"undefined"==typeof Intl?("undefined"!=typeof global?global.Intl={PluralRules:i.default}:"undefined"!=typeof window?window.Intl={PluralRules:i.default}:e.Intl={PluralRules:i.default},i.default.polyfill=!0):Intl.PluralRules?(n=["en","es","ru","zh"],Intl.PluralRules.supportedLocalesOf(n).length{var n=function(e){return e&&e.Math==Math&&e};t.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof global&&global)||function(){return this}()||e||Function("return this")()})),Yt=J(((e,t)=>{t.exports=function(e){try{return!!e()}catch(e){return!0}}})),Kn=J(((e,t)=>{var n=Yt();t.exports=!n((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))})),Mg=J(((e,t)=>{var n=Yt();t.exports=!n((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))})),Sr=J(((e,t)=>{var n=Mg(),i=Function.prototype.call;t.exports=n?i.bind(i):function(){return i.apply(i,arguments)}})),g1=J((e=>{"use strict";var t={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor,i=n&&!t.call({1:2},1);e.f=i?function(e){var t=n(this,e);return!!t&&t.enumerable}:t})),Oo=J(((e,t)=>{t.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}})),en=J(((e,t)=>{var n=Mg(),i=Function.prototype,r=i.call,a=n&&i.bind.bind(r,r);t.exports=n?a:function(e){return function(){return r.apply(e,arguments)}}})),ha=J(((e,t)=>{var n=en(),i=n({}.toString),r=n("".slice);t.exports=function(e){return r(i(e),8,-1)}})),bp=J(((e,t)=>{var n=en(),i=Yt(),r=ha(),a=Object,s=n("".split);t.exports=i((function(){return!a("z").propertyIsEnumerable(0)}))?function(e){return"String"==r(e)?s(e,""):a(e)}:a})),La=J(((e,t)=>{t.exports=function(e){return null==e}})),_s=J(((e,t)=>{var n=La(),i=TypeError;t.exports=function(e){if(n(e))throw i("Can't call method on "+e);return e}})),Ls=J(((e,t)=>{var n=bp(),i=_s();t.exports=function(e){return n(i(e))}})),p3=J(((e,t)=>{var n="object"==typeof document&&document.all,i=void 0===n&&void 0!==n;t.exports={all:n,IS_HTMLDDA:i}})),Fr=J(((e,t)=>{var n=p3(),i=n.all;t.exports=n.IS_HTMLDDA?function(e){return"function"==typeof e||e===i}:function(e){return"function"==typeof e}})),Nr=J(((e,t)=>{var n=Fr(),i=p3(),r=i.all;t.exports=i.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:n(e)||e===r}:function(e){return"object"==typeof e?null!==e:n(e)}})),ki=J(((e,t)=>{var n=Mn(),i=Fr();t.exports=function(e,t){return arguments.length<2?function(e){return i(e)?e:void 0}(n[e]):n[e]&&n[e][t]}})),ko=J(((e,t)=>{var n=en();t.exports=n({}.isPrototypeOf)})),iu=J(((e,t)=>{t.exports="undefined"!=typeof navigator&&String(navigator.userAgent)||""})),su=J(((e,t)=>{var n,i,r=Mn(),a=iu(),s=r.process,o=r.Deno,l=s&&s.versions||o&&o.version,h=l&&l.v8;h&&(i=(n=h.split("."))[0]>0&&n[0]<4?1:+(n[0]+n[1])),!i&&a&&(!(n=a.match(/Edge\/(\d+)/))||n[1]>=74)&&(n=a.match(/Chrome\/(\d+)/))&&(i=+n[1]),t.exports=i})),Ep=J(((e,t)=>{var n=su(),i=Yt(),r=Mn().String;t.exports=!!Object.getOwnPropertySymbols&&!i((function(){var e=Symbol();return!r(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&n&&n<41}))})),v3=J(((e,t)=>{var n=Ep();t.exports=n&&!Symbol.sham&&"symbol"==typeof Symbol.iterator})),Dd=J(((e,t)=>{var n=ki(),i=Fr(),r=ko(),a=v3(),s=Object;t.exports=a?function(e){return"symbol"==typeof e}:function(e){var t=n("Symbol");return i(t)&&r(t.prototype,s(e))}})),Od=J(((e,t)=>{var n=String;t.exports=function(e){try{return n(e)}catch(e){return"Object"}}})),is=J(((e,t)=>{var n=Fr(),i=Od(),r=TypeError;t.exports=function(e){if(n(e))return e;throw r(i(e)+" is not a function")}})),au=J(((e,t)=>{var n=is(),i=La();t.exports=function(e,t){var r=e[t];return i(r)?void 0:n(r)}})),E3=J(((e,t)=>{var n=Sr(),i=Fr(),r=Nr(),a=TypeError;t.exports=function(e,t){var s,o;if("string"===t&&i(s=e.toString)&&!r(o=n(s,e))||i(s=e.valueOf)&&!r(o=n(s,e))||"string"!==t&&i(s=e.toString)&&!r(o=n(s,e)))return o;throw a("Can't convert object to primitive value")}})),ss=J(((e,t)=>{t.exports=!1})),GT=J(((e,t)=>{var n=Mn(),i=Object.defineProperty;t.exports=function(e,t){try{i(n,e,{value:t,configurable:!0,writable:!0})}catch(i){n[e]=t}return t}})),qT=J(((e,t)=>{var n=Mn(),i=GT(),r="__core-js_shared__",a=n[r]||i(r,{});t.exports=a})),_p=J(((e,t)=>{var n=ss(),i=qT();(t.exports=function(e,t){return i[e]||(i[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.30.2",mode:n?"pure":"global",copyright:"\xa9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.30.2/LICENSE",source:"https://github.com/zloirock/core-js"})})),li=J(((e,t)=>{var n=_s(),i=Object;t.exports=function(e){return i(n(e))}})),$r=J(((e,t)=>{var n=en(),i=li(),r=n({}.hasOwnProperty);t.exports=Object.hasOwn||function(e,t){return r(i(e),t)}})),Tp=J(((e,t)=>{var n=en(),i=0,r=Math.random(),a=n(1..toString);t.exports=function(e){return"Symbol("+(void 0===e?"":e)+")_"+a(++i+r,36)}})),Br=J(((e,t)=>{var n=Mn(),i=_p(),r=$r(),a=Tp(),s=Ep(),o=v3(),l=n.Symbol,h=i("wks"),c=o?l.for||l:l&&l.withoutSetter||a;t.exports=function(e){return r(h,e)||(h[e]=s&&r(l,e)?l[e]:c("Symbol."+e)),h[e]}})),v1=J(((e,t)=>{var n=Sr(),i=Nr(),r=Dd(),a=au(),s=E3(),o=Br(),l=TypeError,h=o("toPrimitive");t.exports=function(e,t){if(!i(e)||r(e))return e;var o,c=a(e,h);if(c){if(void 0===t&&(t="default"),o=n(c,e,t),!i(o)||r(o))return o;throw l("Can't convert object to primitive value")}return void 0===t&&(t="number"),s(e,t)}})),vh=J(((e,t)=>{var n=v1(),i=Dd();t.exports=function(e){var t=n(e,"string");return i(t)?t:t+""}})),y1=J(((e,t)=>{var n=Mn(),i=Nr(),r=n.document,a=i(r)&&i(r.createElement);t.exports=function(e){return a?r.createElement(e):{}}})),w3=J(((e,t)=>{var n=Kn(),i=Yt(),r=y1();t.exports=!n&&!i((function(){return 7!=Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a}))})),Qs=J((e=>{var t=Kn(),n=Sr(),i=g1(),r=Oo(),a=Ls(),s=vh(),o=$r(),l=w3(),h=Object.getOwnPropertyDescriptor;e.f=t?h:function(e,t){if(e=a(e),t=s(t),l)try{return h(e,t)}catch(e){}if(o(e,t))return r(!n(i.f,e,t),e[t])}})),S3=J(((e,t)=>{var n=Kn(),i=Yt();t.exports=n&&i((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))})),xr=J(((e,t)=>{var n=Nr(),i=String,r=TypeError;t.exports=function(e){if(n(e))return e;throw r(i(e)+" is not an object")}})),Gi=J((e=>{var t=Kn(),n=w3(),i=S3(),r=xr(),a=vh(),s=TypeError,o=Object.defineProperty,l=Object.getOwnPropertyDescriptor,h="enumerable",c="configurable",u="writable";e.f=t?i?function(e,t,n){if(r(e),t=a(t),r(n),"function"==typeof e&&"prototype"===t&&"value"in n&&u in n&&!n[u]){var i=l(e,t);i&&i[u]&&(e[t]=n.value,n={configurable:c in n?n[c]:i[c],enumerable:h in n?n[h]:i[h],writable:!1})}return o(e,t,n)}:o:function(e,t,i){if(r(e),t=a(t),r(i),n)try{return o(e,t,i)}catch(e){}if("get"in i||"set"in i)throw s("Accessors not supported");return"value"in i&&(e[t]=i.value),e}})),da=J(((e,t)=>{var n=Kn(),i=Gi(),r=Oo();t.exports=n?function(e,t,n){return i.f(e,t,r(1,n))}:function(e,t,n){return e[t]=n,e}})),wp=J(((e,t)=>{var n=Kn(),i=$r(),r=Function.prototype,a=n&&Object.getOwnPropertyDescriptor,s=i(r,"name"),o=s&&"something"===function(){}.name,l=s&&(!n||n&&a(r,"name").configurable);t.exports={EXISTS:s,PROPER:o,CONFIGURABLE:l}})),jT=J(((e,t)=>{var n=en(),i=Fr(),r=qT(),a=n(Function.toString);i(r.inspectSource)||(r.inspectSource=function(e){return a(e)}),t.exports=r.inspectSource})),D3=J(((e,t)=>{var n=Mn(),i=Fr(),r=n.WeakMap;t.exports=i(r)&&/native code/.test(String(r))})),x1=J(((e,t)=>{var n=_p(),i=Tp(),r=n("keys");t.exports=function(e){return r[e]||(r[e]=i(e))}})),Ag=J(((e,t)=>{t.exports={}})),Ts=J(((e,t)=>{var n,i,r,a,s,o=D3(),l=Mn(),h=Nr(),c=da(),u=$r(),d=qT(),p=x1(),f=Ag(),m="Object already initialized",g=l.TypeError,v=l.WeakMap;o||d.state?((a=d.state||(d.state=new v)).get=a.get,a.has=a.has,a.set=a.set,n=function(e,t){if(a.has(e))throw g(m);return t.facade=e,a.set(e,t),t},i=function(e){return a.get(e)||{}},r=function(e){return a.has(e)}):(f[s=p("state")]=!0,n=function(e,t){if(u(e,s))throw g(m);return t.facade=e,c(e,s,t),t},i=function(e){return u(e,s)?e[s]:{}},r=function(e){return u(e,s)}),t.exports={set:n,get:i,has:r,enforce:function(e){return r(e)?i(e):n(e,{})},getterFor:function(e){return function(t){var n;if(!h(t)||(n=i(t)).type!==e)throw g("Incompatible receiver, "+e+" required");return n}}}})),KT=J(((e,t)=>{var n=en(),i=Yt(),r=Fr(),a=$r(),s=Kn(),o=wp().CONFIGURABLE,l=jT(),h=Ts(),c=h.enforce,u=h.get,d=String,p=Object.defineProperty,f=n("".slice),m=n("".replace),g=n([].join),v=s&&!i((function(){return 8!==p((function(){}),"length",{value:8}).length})),y=String(String).split("String"),x=t.exports=function(e,t,n){"Symbol("===f(d(t),0,7)&&(t="["+m(d(t),/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!a(e,"name")||o&&e.name!==t)&&(s?p(e,"name",{value:t,configurable:!0}):e.name=t),v&&n&&a(n,"arity")&&e.length!==n.arity&&p(e,"length",{value:n.arity});try{n&&a(n,"constructor")&&n.constructor?s&&p(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var i=c(e);return a(i,"source")||(i.source=g(y,"string"==typeof t?t:"")),e};Function.prototype.toString=x((function(){return r(this)&&u(this).source||l(this)}),"toString")})),Yi=J(((e,t)=>{var n=Fr(),i=Gi(),r=KT(),a=GT();t.exports=function(e,t,s,o){o||(o={});var l=o.enumerable,h=void 0!==o.name?o.name:t;if(n(s)&&r(s,h,o),o.global)l?e[t]=s:a(t,s);else{try{o.unsafe?e[t]&&(l=!0):delete e[t]}catch(e){}l?e[t]=s:i.f(e,t,{value:s,enumerable:!1,configurable:!o.nonConfigurable,writable:!o.nonWritable})}return e}})),U3=J(((e,t)=>{var n=Math.ceil,i=Math.floor;t.exports=Math.trunc||function(e){var t=+e;return(t>0?i:n)(t)}})),as=J(((e,t)=>{var n=U3();t.exports=function(e){var t=+e;return t!=t||0===t?0:n(t)}})),lc=J(((e,t)=>{var n=as(),i=Math.max,r=Math.min;t.exports=function(e,t){var a=n(e);return a<0?i(a+t,0):r(a,t)}})),eo=J(((e,t)=>{var n=as(),i=Math.min;t.exports=function(e){return e>0?i(n(e),9007199254740991):0}})),pi=J(((e,t)=>{var n=eo();t.exports=function(e){return n(e.length)}})),Cg=J(((e,t)=>{var n=Ls(),i=lc(),r=pi(),a=function(e){return function(t,a,s){var o,l=n(t),h=r(l),c=i(s,h);if(e&&a!=a){for(;h>c;)if((o=l[c++])!=o)return!0}else for(;h>c;c++)if((e||c in l)&&l[c]===a)return e||c||0;return!e&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}})),V3=J(((e,t)=>{var n=en(),i=$r(),r=Ls(),a=Cg().indexOf,s=Ag(),o=n([].push);t.exports=function(e,t){var n,l=r(e),h=0,c=[];for(n in l)!i(s,n)&&i(l,n)&&o(c,n);for(;t.length>h;)i(l,n=t[h++])&&(~a(c,n)||o(c,n));return c}})),JT=J(((e,t)=>{t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]})),yh=J((e=>{var t=V3(),n=JT().concat("length","prototype");e.f=Object.getOwnPropertyNames||function(e){return t(e,n)}})),E1=J((e=>{e.f=Object.getOwnPropertySymbols})),QT=J(((e,t)=>{var n=ki(),i=en(),r=yh(),a=E1(),s=xr(),o=i([].concat);t.exports=n("Reflect","ownKeys")||function(e){var t=r.f(s(e)),n=a.f;return n?o(t,n(e)):t}})),_1=J(((e,t)=>{var n=$r(),i=QT(),r=Qs(),a=Gi();t.exports=function(e,t,s){for(var o=i(t),l=a.f,h=r.f,c=0;c{var n=Yt(),i=Fr(),r=/#|\.prototype\./,a=function(e,t){var r=o[s(e)];return r==h||r!=l&&(i(t)?n(t):!!t)},s=a.normalize=function(e){return String(e).replace(r,".").toLowerCase()},o=a.data={},l=a.NATIVE="N",h=a.POLYFILL="P";t.exports=a})),tt=J(((e,t)=>{var n=Mn(),i=Qs().f,r=da(),a=Yi(),s=GT(),o=_1(),l=Pg();t.exports=function(e,t){var h,c,u,d,p,f=e.target,m=e.global,g=e.stat;if(h=m?n:g?n[f]||s(f,{}):(n[f]||{}).prototype)for(c in t){if(d=t[c],u=e.dontCallGetSet?(p=i(h,c))&&p.value:h[c],!l(m?c:f+(g?".":"#")+c,e.forced)&&void 0!==u){if(typeof d==typeof u)continue;o(d,u)}(e.sham||u&&u.sham)&&r(d,"sham",!0),a(h,c,d,e)}}})),ew=J(((e,t)=>{var n={};n[Br()("toStringTag")]="z",t.exports="[object z]"===String(n)})),cc=J(((e,t)=>{var n=ew(),i=Fr(),r=ha(),a=Br()("toStringTag"),s=Object,o="Arguments"==r(function(){return arguments}());t.exports=n?r:function(e){var t,n,l;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=s(e),a))?n:o?r(t):"Object"==(l=r(t))&&i(t.callee)?"Arguments":l}})),Mr=J(((e,t)=>{var n=cc(),i=String;t.exports=function(e){if("Symbol"===n(e))throw TypeError("Cannot convert a Symbol value to a string");return i(e)}})),Ig=J(((e,t)=>{var n=V3(),i=JT();t.exports=Object.keys||function(e){return n(e,i)}})),nw=J((e=>{var t=Kn(),n=S3(),i=Gi(),r=xr(),a=Ls(),s=Ig();e.f=t&&!n?Object.defineProperties:function(e,t){r(e);for(var n,o=a(t),l=s(t),h=l.length,c=0;h>c;)i.f(e,n=l[c++],o[n]);return e}})),G3=J(((e,t)=>{var n=ki();t.exports=n("document","documentElement")})),to=J(((e,t)=>{var n,i=xr(),r=nw(),a=JT(),s=Ag(),o=G3(),l=y1(),h=x1(),c="prototype",u="script",d=h("IE_PROTO"),p=function(){},f=function(e){return"<"+u+">"+e+""},m=function(e){e.write(f("")),e.close();var t=e.parentWindow.Object;return e=null,t},g=function(){try{n=new ActiveXObject("htmlfile")}catch(e){}g="undefined"!=typeof document?document.domain&&n?m(n):function(){var e,t=l("iframe"),n="java"+u+":";return t.style.display="none",o.appendChild(t),t.src=String(n),(e=t.contentWindow.document).open(),e.write(f("document.F=Object")),e.close(),e.F}():m(n);for(var e=a.length;e--;)delete g[c][a[e]];return g()};s[d]=!0,t.exports=Object.create||function(e,t){var n;return null!==e?(p[c]=i(e),n=new p,p[c]=null,n[d]=e):n=g(),void 0===t?n:r.f(n,t)}})),ou=J(((e,t)=>{"use strict";var n=vh(),i=Gi(),r=Oo();t.exports=function(e,t,a){var s=n(t);s in e?i.f(e,s,r(0,a)):e[s]=a}})),Lg=J(((e,t)=>{var n=lc(),i=pi(),r=ou(),a=Array,s=Math.max;t.exports=function(e,t,o){for(var l=i(e),h=n(t,l),c=n(void 0===o?l:o,l),u=a(s(c-h,0)),d=0;h{var n=ha(),i=Ls(),r=yh().f,a=Lg(),s="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];t.exports.f=function(e){return s&&"Window"==n(e)?function(e){try{return r(e)}catch(e){return a(s)}}(e):r(i(e))}})),Hs=J(((e,t)=>{var n=KT(),i=Gi();t.exports=function(e,t,r){return r.get&&n(r.get,t,{getter:!0}),r.set&&n(r.set,t,{setter:!0}),i.f(e,t,r)}})),X3=J((e=>{var t=Br();e.f=t})),aw=J(((e,t)=>{var n=Mn();t.exports=n})),Da=J(((e,t)=>{var n=aw(),i=$r(),r=X3(),a=Gi().f;t.exports=function(e){var t=n.Symbol||(n.Symbol={});i(t,e)||a(t,e,{value:r.f(e)})}})),Y3=J(((e,t)=>{var n=Sr(),i=ki(),r=Br(),a=Yi();t.exports=function(){var e=i("Symbol"),t=e&&e.prototype,s=t&&t.valueOf,o=r("toPrimitive");t&&!t[o]&&a(t,o,(function(e){return n(s,this)}),{arity:1})}})),no=J(((e,t)=>{var n=Gi().f,i=$r(),r=Br()("toStringTag");t.exports=function(e,t,a){e&&!a&&(e=e.prototype),e&&!i(e,r)&&n(e,r,{configurable:!0,value:t})}})),xh=J(((e,t)=>{var n=ha(),i=en();t.exports=function(e){if("Function"===n(e))return i(e)}})),fl=J(((e,t)=>{var n=xh(),i=is(),r=Mg(),a=n(n.bind);t.exports=function(e,t){return i(e),void 0===t?e:r?a(e,t):function(){return e.apply(t,arguments)}}})),bh=J(((e,t)=>{var n=ha();t.exports=Array.isArray||function(e){return"Array"==n(e)}})),Mp=J(((e,t)=>{var n=en(),i=Yt(),r=Fr(),a=cc(),s=ki(),o=jT(),l=function(){},h=[],c=s("Reflect","construct"),u=/^\s*(?:class|function)\b/,d=n(u.exec),p=!u.exec(l),f=function(e){if(!r(e))return!1;try{return c(l,h,e),!0}catch(e){return!1}},m=function(e){if(!r(e))return!1;switch(a(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return p||!!d(u,o(e))}catch(e){return!0}};m.sham=!0,t.exports=!c||i((function(){var e;return f(f.call)||!f(Object)||!f((function(){e=!0}))||e}))?m:f})),l9=J(((e,t)=>{var n=bh(),i=Mp(),r=Nr(),a=Br()("species"),s=Array;t.exports=function(e){var t;return n(e)&&(t=e.constructor,(i(t)&&(t===s||n(t.prototype))||r(t)&&null===(t=t[a]))&&(t=void 0)),void 0===t?s:t}})),Dg=J(((e,t)=>{var n=l9();t.exports=function(e,t){return new(n(e))(0===t?0:t)}})),Vs=J(((e,t)=>{var n=fl(),i=en(),r=bp(),a=li(),s=pi(),o=Dg(),l=i([].push),h=function(e){var t=1==e,i=2==e,h=3==e,c=4==e,u=6==e,d=7==e,p=5==e||u;return function(f,m,g,v){for(var y,x,b=a(f),_=r(b),w=n(m,g),S=s(_),M=0,E=v||o,T=t?E(f,S):i||d?E(f,0):void 0;S>M;M++)if((p||M in _)&&(x=w(y=_[M],M,b),e))if(t)T[M]=x;else if(x)switch(e){case 3:return!0;case 5:return y;case 6:return M;case 2:l(T,y)}else switch(e){case 4:return!1;case 7:l(T,y)}return u?-1:h||c?c:T}};t.exports={forEach:h(0),map:h(1),filter:h(2),some:h(3),every:h(4),find:h(5),findIndex:h(6),filterReject:h(7)}})),R9=J((()=>{"use strict";var e=tt(),t=Mn(),n=Sr(),i=en(),r=ss(),a=Kn(),s=Ep(),o=Yt(),l=$r(),h=ko(),c=xr(),u=Ls(),d=vh(),p=Mr(),f=Oo(),m=to(),g=Ig(),v=yh(),y=sw(),x=E1(),b=Qs(),_=Gi(),w=nw(),S=g1(),M=Yi(),E=Hs(),T=_p(),A=x1(),C=Ag(),P=Tp(),R=Br(),O=X3(),L=Da(),I=Y3(),D=no(),k=Ts(),N=Vs().forEach,F=A("hidden"),U="Symbol",B="prototype",z=k.set,H=k.getterFor(U),V=Object[B],j=t.Symbol,G=j&&j[B],W=t.TypeError,X=t.QObject,Y=b.f,q=_.f,J=y.f,Z=S.f,K=i([].push),$=T("symbols"),Q=T("op-symbols"),ee=T("wks"),te=!X||!X[B]||!X[B].findChild,ne=a&&o((function(){return 7!=m(q({},"a",{get:function(){return q(this,"a",{value:7}).a}})).a}))?function(e,t,n){var i=Y(V,t);i&&delete V[t],q(e,t,n),i&&e!==V&&q(V,t,i)}:q,ie=function(e,t){var n=$[e]=m(G);return z(n,{type:U,tag:e,description:t}),a||(n.description=t),n},re=function(e,t,n){e===V&&re(Q,t,n),c(e);var i=d(t);return c(n),l($,i)?(n.enumerable?(l(e,F)&&e[F][i]&&(e[F][i]=!1),n=m(n,{enumerable:f(0,!1)})):(l(e,F)||q(e,F,f(1,{})),e[F][i]=!0),ne(e,i,n)):q(e,i,n)},ae=function(e,t){c(e);var i=u(t),r=g(i).concat(he(i));return N(r,(function(t){(!a||n(se,i,t))&&re(e,t,i[t])})),e},se=function(e){var t=d(e),i=n(Z,this,t);return!(this===V&&l($,t)&&!l(Q,t))&&(!(i||!l(this,t)||!l($,t)||l(this,F)&&this[F][t])||i)},oe=function(e,t){var n=u(e),i=d(t);if(n!==V||!l($,i)||l(Q,i)){var r=Y(n,i);return r&&l($,i)&&!(l(n,F)&&n[F][i])&&(r.enumerable=!0),r}},le=function(e){var t=J(u(e)),n=[];return N(t,(function(e){!l($,e)&&!l(C,e)&&K(n,e)})),n},he=function(e){var t=e===V,n=J(t?Q:u(e)),i=[];return N(n,(function(e){l($,e)&&(!t||l(V,e))&&K(i,$[e])})),i};s||(M(G=(j=function(){if(h(G,this))throw W("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?p(arguments[0]):void 0,t=P(e),i=function(e){this===V&&n(i,Q,e),l(this,F)&&l(this[F],t)&&(this[F][t]=!1),ne(this,t,f(1,e))};return a&&te&&ne(V,t,{configurable:!0,set:i}),ie(t,e)})[B],"toString",(function(){return H(this).tag})),M(j,"withoutSetter",(function(e){return ie(P(e),e)})),S.f=se,_.f=re,w.f=ae,b.f=oe,v.f=y.f=le,x.f=he,O.f=function(e){return ie(R(e),e)},a&&(E(G,"description",{configurable:!0,get:function(){return H(this).description}}),r||M(V,"propertyIsEnumerable",se,{unsafe:!0}))),e({global:!0,constructor:!0,wrap:!0,forced:!s,sham:!s},{Symbol:j}),N(g(ee),(function(e){L(e)})),e({target:U,stat:!0,forced:!s},{useSetter:function(){te=!0},useSimple:function(){te=!1}}),e({target:"Object",stat:!0,forced:!s,sham:!a},{create:function(e,t){return void 0===t?m(e):ae(m(e),t)},defineProperty:re,defineProperties:ae,getOwnPropertyDescriptor:oe}),e({target:"Object",stat:!0,forced:!s},{getOwnPropertyNames:le}),I(),D(j,U),C[F]=!0})),cL=J(((e,t)=>{var n=Ep();t.exports=n&&!!Symbol.for&&!!Symbol.keyFor})),P9=J((()=>{var e=tt(),t=ki(),n=$r(),i=Mr(),r=_p(),a=cL(),s=r("string-to-symbol-registry"),o=r("symbol-to-string-registry");e({target:"Symbol",stat:!0,forced:!a},{for:function(e){var r=i(e);if(n(s,r))return s[r];var a=t("Symbol")(r);return s[r]=a,o[a]=r,a}})})),L9=J((()=>{var e=tt(),t=$r(),n=Dd(),i=Od(),r=_p(),a=cL(),s=r("symbol-to-string-registry");e({target:"Symbol",stat:!0,forced:!a},{keyFor:function(e){if(!n(e))throw TypeError(i(e)+" is not a symbol");if(t(s,e))return s[e]}})})),Fo=J(((e,t)=>{var n=Mg(),i=Function.prototype,r=i.apply,a=i.call;t.exports="object"==typeof Reflect&&Reflect.apply||(n?a.bind(r):function(){return a.apply(r,arguments)})})),Fd=J(((e,t)=>{var n=en();t.exports=n([].slice)})),z9=J(((e,t)=>{var n=en(),i=bh(),r=Fr(),a=ha(),s=Mr(),o=n([].push);t.exports=function(e){if(r(e))return e;if(i(e)){for(var t=e.length,n=[],l=0;l{var e=tt(),t=ki(),n=Fo(),i=Sr(),r=en(),a=Yt(),s=Fr(),o=Dd(),l=Fd(),h=z9(),c=Ep(),u=String,d=t("JSON","stringify"),p=r(/./.exec),f=r("".charAt),m=r("".charCodeAt),g=r("".replace),v=r(1..toString),y=/[\uD800-\uDFFF]/g,x=/^[\uD800-\uDBFF]$/,b=/^[\uDC00-\uDFFF]$/,_=!c||a((function(){var e=t("Symbol")();return"[null]"!=d([e])||"{}"!=d({a:e})||"{}"!=d(Object(e))})),w=a((function(){return'"\\udf06\\ud834"'!==d("\udf06\ud834")||'"\\udead"'!==d("\udead")})),S=function(e,t){var r=l(arguments),a=h(t);if(s(a)||void 0!==e&&!o(e))return r[1]=function(e,t){if(s(a)&&(t=i(a,this,u(e),t)),!o(t))return t},n(d,null,r)},M=function(e,t,n){var i=f(n,t-1),r=f(n,t+1);return p(x,e)&&!p(b,r)||p(b,e)&&!p(x,i)?"\\u"+v(m(e,0),16):e};d&&e({target:"JSON",stat:!0,arity:3,forced:_||w},{stringify:function(e,t,i){var r=l(arguments),a=n(_?S:d,null,r);return w&&"string"==typeof a?g(a,y,M):a}})})),tW=J((()=>{var e=tt(),t=Ep(),n=Yt(),i=E1(),r=li();e({target:"Object",stat:!0,forced:!t||n((function(){i.f(1)}))},{getOwnPropertySymbols:function(e){var t=i.f;return t?t(r(e)):[]}})})),nW=J((()=>{R9(),P9(),L9(),hL(),tW()})),cW=J((()=>{"use strict";var e,t,n,i,r,a,s,o,l=tt(),h=Kn(),c=Mn(),u=en(),d=$r(),p=Fr(),f=ko(),m=Mr(),g=Hs(),v=_1(),y=c.Symbol,x=y&&y.prototype;h&&p(y)&&(!("description"in x)||void 0!==y().description)&&(e={},v(t=function(){var t=arguments.length<1||void 0===arguments[0]?void 0:m(arguments[0]),n=f(x,this)?new y(t):void 0===t?y():y(t);return""===t&&(e[n]=!0),n},y),t.prototype=x,x.constructor=t,n="Symbol(test)"==String(y("test")),i=u(x.valueOf),r=u(x.toString),a=/^Symbol\((.*)\)[^)]+$/,s=u("".replace),o=u("".slice),g(x,"description",{configurable:!0,get:function(){var t=i(this);if(d(e,t))return"";var l=r(t),h=n?o(l,7,-1):s(l,a,"$1");return""===h?void 0:h}}),l({global:!0,constructor:!0,forced:!0},{Symbol:t}))})),uW=J((()=>{Da()("asyncIterator")})),hW=J((()=>{Da()("hasInstance")})),dW=J((()=>{Da()("isConcatSpreadable")})),fW=J((()=>{Da()("iterator")})),pW=J((()=>{Da()("match")})),mW=J((()=>{Da()("matchAll")})),gW=J((()=>{Da()("replace")})),vW=J((()=>{Da()("search")})),yW=J((()=>{Da()("species")})),xW=J((()=>{Da()("split")})),bW=J((()=>{var e=Da(),t=Y3();e("toPrimitive"),t()})),EW=J((()=>{var e=ki(),t=Da(),n=no();t("toStringTag"),n(e("Symbol"),"Symbol")})),_W=J((()=>{Da()("unscopables")})),wW=J(((e,t)=>{var n=en(),i=is();t.exports=function(e,t,r){try{return n(i(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(e){}}})),fL=J(((e,t)=>{var n=Fr(),i=String,r=TypeError;t.exports=function(e){if("object"==typeof e||n(e))return e;throw r("Can't set "+i(e)+" as a prototype")}})),uc=J(((e,t)=>{var n=wW(),i=xr(),r=fL();t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,a={};try{(e=n(Object.prototype,"__proto__","set"))(a,[]),t=a instanceof Array}catch(e){}return function(n,a){return i(n),r(a),t?e(n,a):n.__proto__=a,n}}():void 0)})),pL=J(((e,t)=>{var n=Gi().f;t.exports=function(e,t,i){i in e||n(e,i,{configurable:!0,get:function(){return t[i]},set:function(e){t[i]=e}})}})),Pp=J(((e,t)=>{var n=Fr(),i=Nr(),r=uc();t.exports=function(e,t,a){var s,o;return r&&n(s=t.constructor)&&s!==a&&i(o=s.prototype)&&o!==a.prototype&&r(e,o),e}})),Fg=J(((e,t)=>{var n=Mr();t.exports=function(e,t){return void 0===e?arguments.length<2?"":t:n(e)}})),mL=J(((e,t)=>{var n=Nr(),i=da();t.exports=function(e,t){n(t)&&"cause"in t&&i(e,"cause",t.cause)}})),pw=J(((e,t)=>{var n=en(),i=Error,r=n("".replace),a=String(i("zxcasd").stack),s=/\n\s*at [^:]*:[^\n]*/,o=s.test(a);t.exports=function(e,t){if(o&&"string"==typeof e&&!i.prepareStackTrace)for(;t--;)e=r(e,s,"");return e}})),gL=J(((e,t)=>{var n=Yt(),i=Oo();t.exports=!n((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",i(1,7)),7!==e.stack)}))})),vL=J(((e,t)=>{var n=da(),i=pw(),r=gL(),a=Error.captureStackTrace;t.exports=function(e,t,s,o){r&&(a?a(e,t):n(e,"stack",i(s,o)))}})),yL=J(((e,t)=>{"use strict";var n=ki(),i=$r(),r=da(),a=ko(),s=uc(),o=_1(),l=pL(),h=Pp(),c=Fg(),u=mL(),d=vL(),p=Kn(),f=ss();t.exports=function(e,t,m,g){var v="stackTraceLimit",y=g?2:1,x=e.split("."),b=x[x.length-1],_=n.apply(null,x);if(_){var w=_.prototype;if(!f&&i(w,"cause")&&delete w.cause,!m)return _;var S=n("Error"),M=t((function(e,t){var n=c(g?t:e,void 0),i=g?new _(e):new _;return void 0!==n&&r(i,"message",n),d(i,M,i.stack,2),this&&a(w,this)&&h(i,this,M),arguments.length>y&&u(i,arguments[y]),i}));if(M.prototype=w,"Error"!==b?s?s(M,S):o(M,S,{name:!0}):p&&v in _&&(l(M,_,v),l(M,_,"prepareStackTrace")),o(M,_),!f)try{w.name!==b&&r(w,"name",b),w.constructor=M}catch(e){}return M}}})),YW=J((()=>{var e=tt(),t=Mn(),n=Fo(),i=yL(),r="WebAssembly",a=t[r],s=7!==Error("e",{cause:7}).cause,o=function(t,n){var r={};r[t]=i(t,n,s),e({global:!0,constructor:!0,arity:1,forced:s},r)},l=function(t,n){if(a&&a[t]){var o={};o[t]=i(r+"."+t,n,s),e({target:r,stat:!0,constructor:!0,arity:1,forced:s},o)}};o("Error",(function(e){return function(t){return n(e,this,arguments)}})),o("EvalError",(function(e){return function(t){return n(e,this,arguments)}})),o("RangeError",(function(e){return function(t){return n(e,this,arguments)}})),o("ReferenceError",(function(e){return function(t){return n(e,this,arguments)}})),o("SyntaxError",(function(e){return function(t){return n(e,this,arguments)}})),o("TypeError",(function(e){return function(t){return n(e,this,arguments)}})),o("URIError",(function(e){return function(t){return n(e,this,arguments)}})),l("CompileError",(function(e){return function(t){return n(e,this,arguments)}})),l("LinkError",(function(e){return function(t){return n(e,this,arguments)}})),l("RuntimeError",(function(e){return function(t){return n(e,this,arguments)}}))})),EL=J(((e,t)=>{"use strict";var n=Kn(),i=Yt(),r=xr(),a=to(),s=Fg(),o=Error.prototype.toString,l=i((function(){if(n){var e=a(Object.defineProperty({},"name",{get:function(){return this===e}}));if("true"!==o.call(e))return!0}return"2: 1"!==o.call({message:1,name:2})||"Error"!==o.call({})}));t.exports=l?function(){var e=r(this),t=s(e.name,"Error"),n=s(e.message);return t?n?t+": "+n:t:n}:o})),QW=J((()=>{var e=Yi(),t=EL(),n=Error.prototype;n.toString!==t&&e(n,"toString",t)})),vw=J(((e,t)=>{var n=Yt();t.exports=!n((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}))})),No=J(((e,t)=>{var n=$r(),i=Fr(),r=li(),a=x1(),s=vw(),o=a("IE_PROTO"),l=Object,h=l.prototype;t.exports=s?l.getPrototypeOf:function(e){var t=r(e);if(n(t,o))return t[o];var a=t.constructor;return i(a)&&t instanceof a?a.prototype:t instanceof l?h:null}})),Ng=J(((e,t)=>{t.exports={}})),yw=J(((e,t)=>{var n=Br(),i=Ng(),r=n("iterator"),a=Array.prototype;t.exports=function(e){return void 0!==e&&(i.Array===e||a[r]===e)}})),Bg=J(((e,t)=>{var n=cc(),i=au(),r=La(),a=Ng(),s=Br()("iterator");t.exports=function(e){if(!r(e))return i(e,s)||i(e,"@@iterator")||a[n(e)]}})),I1=J(((e,t)=>{var n=Sr(),i=is(),r=xr(),a=Od(),s=Bg(),o=TypeError;t.exports=function(e,t){var l=arguments.length<2?s(e):t;if(i(l))return r(n(l,e));throw o(a(e)+" is not iterable")}})),TL=J(((e,t)=>{var n=Sr(),i=xr(),r=au();t.exports=function(e,t,a){var s,o;i(e);try{if(!(s=r(e,"return"))){if("throw"===t)throw a;return a}s=n(s,e)}catch(e){o=!0,s=e}if("throw"===t)throw a;if(o)throw s;return i(s),a}})),hc=J(((e,t)=>{var n=fl(),i=Sr(),r=xr(),a=Od(),s=yw(),o=pi(),l=ko(),h=I1(),c=Bg(),u=TL(),d=TypeError,p=function(e,t){this.stopped=e,this.result=t},f=p.prototype;t.exports=function(e,t,m){var g,v,y,x,b,_,w,S=m&&m.that,M=!(!m||!m.AS_ENTRIES),E=!(!m||!m.IS_RECORD),T=!(!m||!m.IS_ITERATOR),A=!(!m||!m.INTERRUPTED),C=n(t,S),P=function(e){return g&&u(g,"normal",e),new p(!0,e)},R=function(e){return M?(r(e),A?C(e[0],e[1],P):C(e[0],e[1])):A?C(e,P):C(e)};if(E)g=e.iterator;else if(T)g=e;else{if(!(v=c(e)))throw d(a(e)+" is not iterable");if(s(v)){for(y=0,x=o(e);x>y;y++)if((b=R(e[y]))&&l(f,b))return b;return new p(!1)}g=h(e,v)}for(_=E?e.next:g.next;!(w=i(_,g)).done;){try{b=R(w.value)}catch(e){u(g,"throw",e)}if("object"==typeof b&&b&&l(f,b))return b}return new p(!1)}})),mj=J((()=>{"use strict";var e=tt(),t=ko(),n=No(),i=uc(),r=_1(),a=to(),s=da(),o=Oo(),l=mL(),h=vL(),c=hc(),u=Fg(),d=Br()("toStringTag"),p=Error,f=[].push,m=function(e,r){var o,v=t(g,this);i?o=i(p(),v?n(this):g):(o=v?this:a(g),s(o,d,"Error")),void 0!==r&&s(o,"message",u(r)),h(o,m,o.stack,1),arguments.length>2&&l(o,arguments[2]);var y=[];return c(e,f,{that:y}),s(o,"errors",y),o};i?i(m,p):r(m,p,{name:!0});var g=m.prototype=a(p.prototype,{constructor:o(1,m),message:o(1,""),name:o(1,"AggregateError")});e({global:!0,constructor:!0,arity:2},{AggregateError:m})})),gj=J((()=>{mj()})),bj=J((()=>{var e=tt(),t=ki(),n=Fo(),i=Yt(),r=yL(),a="AggregateError",s=t(a),o=!i((function(){return 1!==s([1]).errors[0]}))&&i((function(){return 7!==s([1],a,{cause:7}).cause}));e({global:!0,constructor:!0,arity:2,forced:o},{AggregateError:r(a,(function(e){return function(t,i){return n(e,this,arguments)}}),o,!0)})})),Oa=J(((e,t)=>{var n=Br(),i=to(),r=Gi().f,a=n("unscopables"),s=Array.prototype;null==s[a]&&r(s,a,{configurable:!0,value:i(null)}),t.exports=function(e){s[a][e]=!0}})),_j=J((()=>{"use strict";var e=tt(),t=li(),n=pi(),i=as(),r=Oa();e({target:"Array",proto:!0},{at:function(e){var r=t(this),a=n(r),s=i(e),o=s>=0?s:a+s;return o<0||o>=a?void 0:r[o]}}),r("at")})),Lp=J(((e,t)=>{var n=TypeError;t.exports=function(e){if(e>9007199254740991)throw n("Maximum allowed index exceeded");return e}})),Hg=J(((e,t)=>{var n=Yt(),i=Br(),r=su(),a=i("species");t.exports=function(e){return r>=51||!n((function(){var t=[];return(t.constructor={})[a]=function(){return{foo:1}},1!==t[e](Boolean).foo}))}})),Aj=J((()=>{"use strict";var e=tt(),t=Yt(),n=bh(),i=Nr(),r=li(),a=pi(),s=Lp(),o=ou(),l=Dg(),h=Hg(),c=Br(),u=su(),d=c("isConcatSpreadable"),p=u>=51||!t((function(){var e=[];return e[d]=!1,e.concat()[0]!==e})),f=function(e){if(!i(e))return!1;var t=e[d];return void 0!==t?!!t:n(e)};e({target:"Array",proto:!0,arity:1,forced:!p||!h("concat")},{concat:function(e){var t,n,i,h,c,u=r(this),d=l(u,0),p=0;for(t=-1,i=arguments.length;t{"use strict";var n=Od(),i=TypeError;t.exports=function(e,t){if(!delete e[t])throw i("Cannot delete property "+n(t)+" of "+n(e))}})),IL=J(((e,t)=>{"use strict";var n=li(),i=lc(),r=pi(),a=L1(),s=Math.min;t.exports=[].copyWithin||function(e,t){var o=n(this),l=r(o),h=i(e,l),c=i(t,l),u=arguments.length>2?arguments[2]:void 0,d=s((void 0===u?l:i(u,l))-c,l-h),p=1;for(c0;)c in o?o[h]=o[c]:a(o,h),h+=p,c+=p;return o}})),Lj=J((()=>{var e=tt(),t=IL(),n=Oa();e({target:"Array",proto:!0},{copyWithin:t}),n("copyWithin")})),cu=J(((e,t)=>{"use strict";var n=Yt();t.exports=function(e,t){var i=[][e];return!!i&&n((function(){i.call(null,t||function(){return 1},1)}))}})),Oj=J((()=>{"use strict";var e=tt(),t=Vs().every;e({target:"Array",proto:!0,forced:!cu()("every")},{every:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),_w=J(((e,t)=>{"use strict";var n=li(),i=lc(),r=pi();t.exports=function(e){for(var t=n(this),a=r(t),s=arguments.length,o=i(s>1?arguments[1]:void 0,a),l=s>2?arguments[2]:void 0,h=void 0===l?a:i(l,a);h>o;)t[o++]=e;return t}})),Nj=J((()=>{var e=tt(),t=_w(),n=Oa();e({target:"Array",proto:!0},{fill:t}),n("fill")})),Bj=J((()=>{"use strict";var e=tt(),t=Vs().filter;e({target:"Array",proto:!0,forced:!Hg()("filter")},{filter:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),Hj=J((()=>{"use strict";var e=tt(),t=Vs().find,n=Oa(),i="find",r=!0;i in[]&&Array(1)[i]((function(){r=!1})),e({target:"Array",proto:!0,forced:r},{find:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),n(i)})),zj=J((()=>{"use strict";var e=tt(),t=Vs().findIndex,n=Oa(),i="findIndex",r=!0;i in[]&&Array(1)[i]((function(){r=!1})),e({target:"Array",proto:!0,forced:r},{findIndex:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),n(i)})),D1=J(((e,t)=>{var n=fl(),i=bp(),r=li(),a=pi(),s=function(e){var t=1==e;return function(s,o,l){for(var h,c=r(s),u=i(c),d=n(o,l),p=a(u);p-- >0;)if(d(h=u[p],p,c))switch(e){case 0:return h;case 1:return p}return t?-1:void 0}};t.exports={findLast:s(0),findLastIndex:s(1)}})),Wj=J((()=>{"use strict";var e=tt(),t=D1().findLast,n=Oa();e({target:"Array",proto:!0},{findLast:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),n("findLast")})),jj=J((()=>{"use strict";var e=tt(),t=D1().findLastIndex,n=Oa();e({target:"Array",proto:!0},{findLastIndex:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),n("findLastIndex")})),OL=J(((e,t)=>{"use strict";var n=bh(),i=pi(),r=Lp(),a=fl(),s=function(e,t,o,l,h,c,u,d){for(var p,f,m=h,g=0,v=!!u&&a(u,d);g0&&n(p)?(f=i(p),m=s(e,t,p,f,m,c-1)-1):(r(m+1),e[m]=p),m++),g++;return m};t.exports=s})),$j=J((()=>{"use strict";var e=tt(),t=OL(),n=li(),i=pi(),r=as(),a=Dg();e({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,s=n(this),o=i(s),l=a(s,0);return l.length=t(l,s,s,o,0,void 0===e?1:r(e)),l}})})),Zj=J((()=>{"use strict";var e=tt(),t=OL(),n=is(),i=li(),r=pi(),a=Dg();e({target:"Array",proto:!0},{flatMap:function(e){var s,o=i(this),l=r(o);return n(e),(s=a(o,0)).length=t(s,o,o,l,0,1,e,arguments.length>1?arguments[1]:void 0),s}})})),kL=J(((e,t)=>{"use strict";var n=Vs().forEach,i=cu()("forEach");t.exports=i?[].forEach:function(e){return n(this,e,arguments.length>1?arguments[1]:void 0)}})),Qj=J((()=>{"use strict";var e=tt(),t=kL();e({target:"Array",proto:!0,forced:[].forEach!=t},{forEach:t})})),tX=J(((e,t)=>{var n=xr(),i=TL();t.exports=function(e,t,r,a){try{return a?t(n(r)[0],r[1]):t(r)}catch(t){i(e,"throw",t)}}})),FL=J(((e,t)=>{"use strict";var n=fl(),i=Sr(),r=li(),a=tX(),s=yw(),o=Mp(),l=pi(),h=ou(),c=I1(),u=Bg(),d=Array;t.exports=function(e){var t=r(e),p=o(this),f=arguments.length,m=f>1?arguments[1]:void 0,g=void 0!==m;g&&(m=n(m,f>2?arguments[2]:void 0));var v,y,x,b,_,w,S=u(t),M=0;if(!S||this===d&&s(S))for(v=l(t),y=p?new this(v):d(v);v>M;M++)w=g?m(t[M],M):t[M],h(y,M,w);else for(_=(b=c(t,S)).next,y=p?new this:[];!(x=i(_,b)).done;M++)w=g?a(b,m,[x.value,M],!0):x.value,h(y,M,w);return y.length=M,y}})),O1=J(((e,t)=>{var n,i,r=Br()("iterator"),a=!1;try{n=0,(i={next:function(){return{done:!!n++}},return:function(){a=!0}})[r]=function(){return this},Array.from(i,(function(){throw 2}))}catch(e){}t.exports=function(e,t){if(!t&&!a)return!1;var n=!1;try{var i={};i[r]=function(){return{next:function(){return{done:n=!0}}}},e(i)}catch(e){}return n}})),cX=J((()=>{var e=tt(),t=FL();e({target:"Array",stat:!0,forced:!O1()((function(e){Array.from(e)}))},{from:t})})),uX=J((()=>{"use strict";var e=tt(),t=Cg().includes,n=Yt(),i=Oa();e({target:"Array",proto:!0,forced:n((function(){return!Array(1).includes()}))},{includes:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),i("includes")})),dX=J((()=>{"use strict";var e=tt(),t=xh(),n=Cg().indexOf,i=cu(),r=t([].indexOf),a=!!r&&1/r([1],1,-0)<0;e({target:"Array",proto:!0,forced:a||!i("indexOf")},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return a?r(this,e,t)||0:n(this,e,t)}})})),fX=J((()=>{tt()({target:"Array",stat:!0},{isArray:bh()})})),zL=J(((e,t)=>{"use strict";var n,i,r,a=Yt(),s=Fr(),o=Nr(),l=to(),h=No(),c=Yi(),u=Br(),d=ss(),p=u("iterator"),f=!1;[].keys&&("next"in(r=[].keys())?(i=h(h(r)))!==Object.prototype&&(n=i):f=!0),!o(n)||a((function(){var e={};return n[p].call(e)!==e}))?n={}:d&&(n=l(n)),s(n[p])||c(n,p,(function(){return this})),t.exports={IteratorPrototype:n,BUGGY_SAFARI_ITERATORS:f}})),Tw=J(((e,t)=>{"use strict";var n=zL().IteratorPrototype,i=to(),r=Oo(),a=no(),s=Ng(),o=function(){return this};t.exports=function(e,t,l,h){var c=t+" Iterator";return e.prototype=i(n,{next:r(+!h,l)}),a(e,c,!1,!0),s[c]=o,e}})),Mw=J(((e,t)=>{"use strict";var n=tt(),i=Sr(),r=ss(),a=wp(),s=Fr(),o=Tw(),l=No(),h=uc(),c=no(),u=da(),d=Yi(),p=Br(),f=Ng(),m=zL(),g=a.PROPER,v=a.CONFIGURABLE,y=m.IteratorPrototype,x=m.BUGGY_SAFARI_ITERATORS,b=p("iterator"),_="keys",w="values",S="entries",M=function(){return this};t.exports=function(e,t,a,p,m,E,T){o(a,t,p);var A,C,P,R=function(e){if(e===m&&k)return k;if(!x&&e in I)return I[e];switch(e){case _:case w:case S:return function(){return new a(this,e)}}return function(){return new a(this)}},O=t+" Iterator",L=!1,I=e.prototype,D=I[b]||I["@@iterator"]||m&&I[m],k=!x&&D||R(m),N="Array"==t&&I.entries||D;if(N&&(A=l(N.call(new e)))!==Object.prototype&&A.next&&(!r&&l(A)!==y&&(h?h(A,y):s(A[b])||d(A,b,M)),c(A,O,!0,!0),r&&(f[O]=M)),g&&m==w&&D&&D.name!==w&&(!r&&v?u(I,"name",w):(L=!0,k=function(){return i(D,this)})),m)if(C={values:R(w),keys:E?k:R(_),entries:R(S)},T)for(P in C)(x||L||!(P in I))&&d(I,P,C[P]);else n({target:t,proto:!0,forced:x||L},C);return(!r||T)&&I[b]!==k&&d(I,b,k,{name:m}),f[t]=k,C}})),N1=J(((e,t)=>{t.exports=function(e,t){return{value:e,done:t}}})),B1=J(((e,t)=>{"use strict";var n=Ls(),i=Oa(),r=Ng(),a=Ts(),s=Gi().f,o=Mw(),l=N1(),h=ss(),c=Kn(),u="Array Iterator",d=a.set,p=a.getterFor(u);t.exports=o(Array,"Array",(function(e,t){d(this,{type:u,target:n(e),index:0,kind:t})}),(function(){var e=p(this),t=e.target,n=e.kind,i=e.index++;return!t||i>=t.length?(e.target=void 0,l(void 0,!0)):l("keys"==n?i:"values"==n?t[i]:[i,t[i]],!1)}),"values");var f=r.Arguments=r.Array;if(i("keys"),i("values"),i("entries"),!h&&c&&"values"!==f.name)try{s(f,"name",{value:"values"})}catch(e){}})),OX=J((()=>{"use strict";var e=tt(),t=en(),n=bp(),i=Ls(),r=cu(),a=t([].join);e({target:"Array",proto:!0,forced:n!=Object||!r("join",",")},{join:function(e){return a(i(this),void 0===e?",":e)}})})),jL=J(((e,t)=>{"use strict";var n=Fo(),i=Ls(),r=as(),a=pi(),s=cu(),o=Math.min,l=[].lastIndexOf,h=!!l&&1/[1].lastIndexOf(1,-0)<0,c=s("lastIndexOf"),u=h||!c;t.exports=u?function(e){if(h)return n(l,this,arguments)||0;var t=i(this),s=a(t),c=s-1;for(arguments.length>1&&(c=o(c,r(arguments[1]))),c<0&&(c=s+c);c>=0;c--)if(c in t&&t[c]===e)return c||0;return-1}:l})),BX=J((()=>{var e=tt(),t=jL();e({target:"Array",proto:!0,forced:t!==[].lastIndexOf},{lastIndexOf:t})})),UX=J((()=>{"use strict";var e=tt(),t=Vs().map;e({target:"Array",proto:!0,forced:!Hg()("map")},{map:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),VX=J((()=>{"use strict";var e=tt(),t=Yt(),n=Mp(),i=ou(),r=Array;e({target:"Array",stat:!0,forced:t((function(){function e(){}return!(r.of.call(e)instanceof e)}))},{of:function(){for(var e=0,t=arguments.length,a=new(n(this)?this:r)(t);t>e;)i(a,e,arguments[e++]);return a.length=t,a}})})),Aw=J(((e,t)=>{"use strict";var n=Kn(),i=bh(),r=TypeError,a=Object.getOwnPropertyDescriptor,s=n&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}();t.exports=s?function(e,t){if(i(e)&&!a(e,"length").writable)throw r("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t}})),GX=J((()=>{"use strict";var e=tt(),t=li(),n=pi(),i=Aw(),r=Lp();e({target:"Array",proto:!0,arity:1,forced:Yt()((function(){return 4294967297!==[].push.call({length:4294967296},1)}))||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(e){return e instanceof TypeError}}()},{push:function(e){var a=t(this),s=n(a),o=arguments.length;r(s+o);for(var l=0;l{var n=is(),i=li(),r=bp(),a=pi(),s=TypeError,o=function(e){return function(t,o,l,h){n(o);var c=i(t),u=r(c),d=a(c),p=e?d-1:0,f=e?-1:1;if(l<2)for(;;){if(p in u){h=u[p],p+=f;break}if(p+=f,e?p<0:d<=p)throw s("Reduce of empty array with no initial value")}for(;e?p>=0:d>p;p+=f)p in u&&(h=o(h,u[p],p,c));return h}};t.exports={left:o(!1),right:o(!0)}})),uu=J(((e,t)=>{var n=ha();t.exports="undefined"!=typeof process&&"process"==n(process)})),YX=J((()=>{"use strict";var e=tt(),t=U1().left,n=cu(),i=su();e({target:"Array",proto:!0,forced:!uu()&&i>79&&i<83||!n("reduce")},{reduce:function(e){var n=arguments.length;return t(this,e,n,n>1?arguments[1]:void 0)}})})),ZX=J((()=>{"use strict";var e=tt(),t=U1().right,n=cu(),i=su();e({target:"Array",proto:!0,forced:!uu()&&i>79&&i<83||!n("reduceRight")},{reduceRight:function(e){return t(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}})})),JX=J((()=>{"use strict";var e=tt(),t=en(),n=bh(),i=t([].reverse),r=[1,2];e({target:"Array",proto:!0,forced:String(r)===String(r.reverse())},{reverse:function(){return n(this)&&(this.length=this.length),i(this)}})})),tY=J((()=>{"use strict";var e=tt(),t=bh(),n=Mp(),i=Nr(),r=lc(),a=pi(),s=Ls(),o=ou(),l=Br(),h=Hg(),c=Fd(),u=h("slice"),d=l("species"),p=Array,f=Math.max;e({target:"Array",proto:!0,forced:!u},{slice:function(e,l){var h,u,m,g=s(this),v=a(g),y=r(e,v),x=r(void 0===l?v:l,v);if(t(g)&&(h=g.constructor,(n(h)&&(h===p||t(h.prototype))||i(h)&&null===(h=h[d]))&&(h=void 0),h===p||void 0===h))return c(g,y,x);for(u=new(void 0===h?p:h)(f(x-y,0)),m=0;y{"use strict";var e=tt(),t=Vs().some;e({target:"Array",proto:!0,forced:!cu()("some")},{some:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),Cw=J(((e,t)=>{var n=Lg(),i=Math.floor,r=function(e,t){var o=e.length,l=i(o/2);return o<8?a(e,t):s(e,r(n(e,0,l),t),r(n(e,l),t),t)},a=function(e,t){for(var n,i,r=e.length,a=1;a0;)e[i]=e[--i];i!==a++&&(e[i]=n)}return e},s=function(e,t,n,i){for(var r=t.length,a=n.length,s=0,o=0;s{var n=iu().match(/firefox\/(\d+)/i);t.exports=!!n&&+n[1]})),ZL=J(((e,t)=>{var n=iu();t.exports=/MSIE|Trident/.test(n)})),Pw=J(((e,t)=>{var n=iu().match(/AppleWebKit\/(\d+)\./);t.exports=!!n&&+n[1]})),yY=J((()=>{"use strict";var e=tt(),t=en(),n=is(),i=li(),r=pi(),a=L1(),s=Mr(),o=Yt(),l=Cw(),h=cu(),c=$L(),u=ZL(),d=su(),p=Pw(),f=[],m=t(f.sort),g=t(f.push),v=o((function(){f.sort(void 0)})),y=o((function(){f.sort(null)})),x=h("sort"),b=!o((function(){if(d)return d<70;if(!(c&&c>3)){if(u)return!0;if(p)return p<603;var e,t,n,i,r="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(i=0;i<47;i++)f.push({k:t+i,v:n})}for(f.sort((function(e,t){return t.v-e.v})),i=0;is(n)?1:-1}}(e)),o=r(c),h=0;h{"use strict";var n=ki(),i=Hs(),r=Br(),a=Kn(),s=r("species");t.exports=function(e){var t=n(e);a&&t&&!t[s]&&i(t,s,{configurable:!0,get:function(){return this}})}})),EY=J((()=>{Dp()("Array")})),_Y=J((()=>{"use strict";var e=tt(),t=li(),n=lc(),i=as(),r=pi(),a=Aw(),s=Lp(),o=Dg(),l=ou(),h=L1(),c=Hg()("splice"),u=Math.max,d=Math.min;e({target:"Array",proto:!0,forced:!c},{splice:function(e,c){var p,f,m,g,v,y,x=t(this),b=r(x),_=n(e,b),w=arguments.length;for(0===w?p=f=0:1===w?(p=0,f=b-_):(p=w-2,f=d(u(i(c),0),b-_)),s(b+p-f),m=o(x,f),g=0;gb-f+p;g--)h(x,g-1)}else if(p>f)for(g=b-f;g>_;g--)y=g+p-1,(v=g+f-1)in x?x[y]=x[v]:h(x,y);for(g=0;g{var n=pi();t.exports=function(e,t){for(var i=n(e),r=new t(i),a=0;a{"use strict";var e=tt(),t=QL(),n=Ls(),i=Oa(),r=Array;e({target:"Array",proto:!0},{toReversed:function(){return t(n(this),r)}}),i("toReversed")})),Iw=J(((e,t)=>{var n=pi();t.exports=function(e,t){for(var i=0,r=n(t),a=new e(r);r>i;)a[i]=t[i++];return a}})),RY=J(((e,t)=>{var n=Mn();t.exports=function(e){return n[e].prototype}})),AY=J((()=>{"use strict";var e=tt(),t=en(),n=is(),i=Ls(),r=Iw(),a=RY(),s=Oa(),o=Array,l=t(a("Array").sort);e({target:"Array",proto:!0},{toSorted:function(e){void 0!==e&&n(e);var t=i(this),a=r(o,t);return l(a,e)}}),s("toSorted")})),CY=J((()=>{"use strict";var e=tt(),t=Oa(),n=Lp(),i=pi(),r=lc(),a=Ls(),s=as(),o=Array,l=Math.max,h=Math.min;e({target:"Array",proto:!0},{toSpliced:function(e,t){var c,u,d,p,f=a(this),m=i(f),g=r(e,m),v=arguments.length,y=0;for(0===v?c=u=0:1===v?(c=0,u=m-g):(c=v-2,u=h(l(s(t),0),m-g)),d=n(m+c-u),p=o(d);y{Oa()("flat")})),IY=J((()=>{Oa()("flatMap")})),LY=J((()=>{"use strict";var e=tt(),t=li(),n=pi(),i=Aw(),r=L1(),a=Lp();e({target:"Array",proto:!0,arity:1,forced:1!==[].unshift(0)||!function(){try{Object.defineProperty([],"length",{writable:!1}).unshift()}catch(e){return e instanceof TypeError}}()},{unshift:function(e){var s=t(this),o=n(s),l=arguments.length;if(l){a(o+l);for(var h=o;h--;){var c=h+l;h in s?s[c]=s[h]:r(s,c)}for(var u=0;u{var n=pi(),i=as(),r=RangeError;t.exports=function(e,t,a,s){var o=n(e),l=i(a),h=l<0?o+l:l;if(h>=o||h<0)throw r("Incorrect index");for(var c=new t(o),u=0;u{"use strict";var e=tt(),t=eD(),n=Ls(),i=Array;e({target:"Array",proto:!0},{with:function(e,r){return t(n(this),i,e,r)}})})),Lw=J(((e,t)=>{t.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView})),Vg=J(((e,t)=>{var n=Yi();t.exports=function(e,t,i){for(var r in t)n(e,r,t[r],i);return e}})),dc=J(((e,t)=>{var n=ko(),i=TypeError;t.exports=function(e,t){if(n(t,e))return e;throw i("Incorrect invocation")}})),tD=J(((e,t)=>{var n=as(),i=eo(),r=RangeError;t.exports=function(e){if(void 0===e)return 0;var t=n(e),a=i(t);if(t!==a)throw r("Wrong length or index");return a}})),HY=J(((e,t)=>{var n=Array,i=Math.abs,r=Math.pow,a=Math.floor,s=Math.log,o=Math.LN2;t.exports={pack:function(e,t,l){var h,c,u,d=n(l),p=8*l-t-1,f=(1<>1,g=23===t?r(2,-24)-r(2,-77):0,v=e<0||0===e&&1/e<0?1:0,y=0;for((e=i(e))!=e||e===1/0?(c=e!=e?1:0,h=f):(h=a(s(e)/o),e*(u=r(2,-h))<1&&(h--,u*=2),(e+=h+m>=1?g/u:g*r(2,1-m))*u>=2&&(h++,u/=2),h+m>=f?(c=0,h=f):h+m>=1?(c=(e*u-1)*r(2,t),h+=m):(c=e*r(2,m-1)*r(2,t),h=0));t>=8;)d[y++]=255&c,c/=256,t-=8;for(h=h<0;)d[y++]=255&h,h/=256,p-=8;return d[--y]|=128*v,d},unpack:function(e,t){var n,i=e.length,a=8*i-t-1,s=(1<>1,l=a-7,h=i-1,c=e[h--],u=127&c;for(c>>=7;l>0;)u=256*u+e[h--],l-=8;for(n=u&(1<<-l)-1,u>>=-l,l+=t;l>0;)n=256*n+e[h--],l-=8;if(0===u)u=1-o;else{if(u===s)return n?NaN:c?-1/0:1/0;n+=r(2,t),u-=o}return(c?-1:1)*n*r(2,u-t)}}})),z1=J(((e,t)=>{"use strict";var n,i,r,a,s,o,l=Mn(),h=en(),c=Kn(),u=Lw(),d=wp(),p=da(),f=Hs(),m=Vg(),g=Yt(),v=dc(),y=as(),x=eo(),b=tD(),_=HY(),w=No(),S=uc(),M=yh().f,E=_w(),T=Lg(),A=no(),C=Ts(),P=d.PROPER,R=d.CONFIGURABLE,O="ArrayBuffer",L="DataView",I="prototype",D="Wrong index",k=C.getterFor(O),N=C.getterFor(L),F=C.set,U=l[O],B=U,z=B&&B[I],H=l[L],V=H&&H[I],j=Object.prototype,G=l.Array,W=l.RangeError,X=h(E),Y=h([].reverse),q=_.pack,J=_.unpack,Z=function(e){return[255&e]},K=function(e){return[255&e,e>>8&255]},$=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},Q=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},ee=function(e){return q(e,23,4)},te=function(e){return q(e,52,8)},ne=function(e,t,n){f(e[I],t,{configurable:!0,get:function(){return n(this)[t]}})},ie=function(e,t,n,i){var r=b(n),a=N(e);if(r+t>a.byteLength)throw W(D);var s=a.bytes,o=r+a.byteOffset,l=T(s,o,o+t);return i?l:Y(l)},re=function(e,t,n,i,r,a){var s=b(n),o=N(e);if(s+t>o.byteLength)throw W(D);for(var l=o.bytes,h=s+o.byteOffset,c=i(+r),u=0;ur;)(a=i[r++])in B||p(B,a,U[a]);z.constructor=B}S&&w(V)!==j&&S(V,j),s=new H(new B(2)),o=h(V.setInt8),s.setInt8(0,2147483648),s.setInt8(1,2147483649),(s.getInt8(0)||!s.getInt8(1))&&m(V,{setInt8:function(e,t){o(this,e,t<<24>>24)},setUint8:function(e,t){o(this,e,t<<24>>24)}},{unsafe:!0})}else z=(B=function(e){v(this,z);var t=b(e);F(this,{type:O,bytes:X(G(t),0),byteLength:t}),c||(this.byteLength=t,this.detached=!1)})[I],V=(H=function(e,t,n){v(this,V),v(e,z);var i=k(e),r=i.byteLength,a=y(t);if(a<0||a>r)throw W("Wrong offset");if(a+(n=void 0===n?r-a:x(n))>r)throw W("Wrong length");F(this,{type:L,buffer:e,byteLength:n,byteOffset:a,bytes:i.bytes}),c||(this.buffer=e,this.byteLength=n,this.byteOffset=a)})[I],c&&(ne(B,"byteLength",k),ne(H,"buffer",N),ne(H,"byteLength",N),ne(H,"byteOffset",N)),m(V,{getInt8:function(e){return ie(this,1,e)[0]<<24>>24},getUint8:function(e){return ie(this,1,e)[0]},getInt16:function(e){var t=ie(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=ie(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return Q(ie(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return Q(ie(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return J(ie(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return J(ie(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){re(this,1,e,Z,t)},setUint8:function(e,t){re(this,1,e,Z,t)},setInt16:function(e,t){re(this,2,e,K,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){re(this,2,e,K,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){re(this,4,e,$,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){re(this,4,e,$,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){re(this,4,e,ee,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){re(this,8,e,te,t,arguments.length>2?arguments[2]:void 0)}});A(B,O),A(H,L),t.exports={ArrayBuffer:B,DataView:H}})),a$=J((()=>{"use strict";var e=tt(),t=Mn(),n=z1(),i=Dp(),r="ArrayBuffer",a=n[r];e({global:!0,constructor:!0,forced:t[r]!==a},{ArrayBuffer:a}),i(r)})),Pr=J(((e,t)=>{"use strict";var n,i,r,a=Lw(),s=Kn(),o=Mn(),l=Fr(),h=Nr(),c=$r(),u=cc(),d=Od(),p=da(),f=Yi(),m=Hs(),g=ko(),v=No(),y=uc(),x=Br(),b=Tp(),_=Ts(),w=_.enforce,S=_.get,M=o.Int8Array,E=M&&M.prototype,T=o.Uint8ClampedArray,A=T&&T.prototype,C=M&&v(M),P=E&&v(E),R=Object.prototype,O=o.TypeError,L=x("toStringTag"),I=b("TYPED_ARRAY_TAG"),D="TypedArrayConstructor",k=a&&!!y&&"Opera"!==u(o.opera),N=!1,F={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},U={BigInt64Array:8,BigUint64Array:8},B=function(e){var t=v(e);if(h(t)){var n=S(t);return n&&c(n,D)?n[D]:B(t)}},z=function(e){if(!h(e))return!1;var t=u(e);return c(F,t)||c(U,t)};for(n in F)(r=(i=o[n])&&i.prototype)?w(r)[D]=i:k=!1;for(n in U)(r=(i=o[n])&&i.prototype)&&(w(r)[D]=i);if((!k||!l(C)||C===Function.prototype)&&(C=function(){throw O("Incorrect invocation")},k))for(n in F)o[n]&&y(o[n],C);if((!k||!P||P===R)&&(P=C.prototype,k))for(n in F)o[n]&&y(o[n].prototype,P);if(k&&v(A)!==P&&y(A,P),s&&!c(P,L))for(n in N=!0,m(P,L,{configurable:!0,get:function(){return h(this)?this[I]:void 0}}),F)o[n]&&p(o[n],I,n);t.exports={NATIVE_ARRAY_BUFFER_VIEWS:k,TYPED_ARRAY_TAG:N&&I,aTypedArray:function(e){if(z(e))return e;throw O("Target is not a typed array")},aTypedArrayConstructor:function(e){if(l(e)&&(!y||g(C,e)))return e;throw O(d(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,i){if(s){if(n)for(var r in F){var a=o[r];if(a&&c(a.prototype,e))try{delete a.prototype[e]}catch(n){try{a.prototype[e]=t}catch(e){}}}(!P[e]||n)&&f(P,e,n?t:k&&E[e]||t,i)}},exportTypedArrayStaticMethod:function(e,t,n){var i,r;if(s){if(y){if(n)for(i in F)if((r=o[i])&&c(r,e))try{delete r[e]}catch(e){}if(C[e]&&!n)return;try{return f(C,e,n?t:k&&C[e]||t)}catch(e){}}for(i in F)(r=o[i])&&(!r[e]||n)&&f(r,e,t)}},getTypedArrayConstructor:B,isView:function(e){if(!h(e))return!1;var t=u(e);return"DataView"===t||c(F,t)||c(U,t)},isTypedArray:z,TypedArray:C,TypedArrayPrototype:P}})),y$=J((()=>{var e=tt(),t=Pr();e({target:"ArrayBuffer",stat:!0,forced:!t.NATIVE_ARRAY_BUFFER_VIEWS},{isView:t.isView})})),qw=J(((e,t)=>{var n=Mp(),i=Od(),r=TypeError;t.exports=function(e){if(n(e))return e;throw r(i(e)+" is not a constructor")}})),kp=J(((e,t)=>{var n=xr(),i=qw(),r=La(),a=Br()("species");t.exports=function(e,t){var s,o=n(e).constructor;return void 0===o||r(s=n(o)[a])?t:i(s)}})),R$=J((()=>{"use strict";var e=tt(),t=xh(),n=Yt(),i=z1(),r=xr(),a=lc(),s=eo(),o=kp(),l=i.ArrayBuffer,h=i.DataView,c=h.prototype,u=t(l.prototype.slice),d=t(c.getUint8),p=t(c.setUint8);e({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:n((function(){return!new l(2).slice(1,void 0).byteLength}))},{slice:function(e,t){if(u&&void 0===t)return u(r(this),e);for(var n=r(this).byteLength,i=a(e,n),c=a(void 0===t?n:t,n),f=new(o(this,l))(s(c-i)),m=new h(this),g=new h(f),v=0;i{var e=tt(),t=z1();e({global:!0,constructor:!0,forced:!Lw()},{DataView:t.DataView})})),C$=J((()=>{A$()})),P$=J((()=>{"use strict";var e=tt(),t=en(),n=Yt()((function(){return 120!==new Date(16e11).getYear()})),i=t(Date.prototype.getFullYear);e({target:"Date",proto:!0,forced:n},{getYear:function(){return i(this)-1900}})})),L$=J((()=>{var e=tt(),t=en(),n=Date,i=t(n.prototype.getTime);e({target:"Date",stat:!0},{now:function(){return i(new n)}})})),k$=J((()=>{"use strict";var e=tt(),t=en(),n=as(),i=Date.prototype,r=t(i.getTime),a=t(i.setFullYear);e({target:"Date",proto:!0},{setYear:function(e){r(this);var t=n(e);return a(this,0<=t&&t<=99?t+1900:t)}})})),F$=J((()=>{tt()({target:"Date",proto:!0},{toGMTString:Date.prototype.toUTCString})})),G1=J(((e,t)=>{"use strict";var n=as(),i=Mr(),r=_s(),a=RangeError;t.exports=function(e){var t=i(r(this)),s="",o=n(e);if(o<0||o==1/0)throw a("Wrong number of repetitions");for(;o>0;(o>>>=1)&&(t+=t))1&o&&(s+=t);return s}})),Ww=J(((e,t)=>{var n=en(),i=eo(),r=Mr(),a=G1(),s=_s(),o=n(a),l=n("".slice),h=Math.ceil,c=function(e){return function(t,n,a){var c,u,d=r(s(t)),p=i(n),f=d.length,m=void 0===a?" ":r(a);return p<=f||""==m?d:((u=o(m,h((c=p-f)/m.length))).length>c&&(u=l(u,0,c)),e?d+u:u+d)}};t.exports={start:c(!1),end:c(!0)}})),q$=J(((e,t)=>{"use strict";var n=en(),i=Yt(),r=Ww().start,a=RangeError,s=isFinite,o=Math.abs,l=Date.prototype,h=l.toISOString,c=n(l.getTime),u=n(l.getUTCDate),d=n(l.getUTCFullYear),p=n(l.getUTCHours),f=n(l.getUTCMilliseconds),m=n(l.getUTCMinutes),g=n(l.getUTCMonth),v=n(l.getUTCSeconds);t.exports=i((function(){return"0385-07-25T07:06:39.999Z"!=h.call(new Date(-50000000000001))}))||!i((function(){h.call(new Date(NaN))}))?function(){if(!s(c(this)))throw a("Invalid time value");var e=this,t=d(e),n=f(e),i=t<0?"-":t>9999?"+":"";return i+r(o(t),i?6:4,0)+"-"+r(g(e)+1,2,0)+"-"+r(u(e),2,0)+"T"+r(p(e),2,0)+":"+r(m(e),2,0)+":"+r(v(e),2,0)+"."+r(n,3,0)+"Z"}:h})),j$=J((()=>{var e=tt(),t=q$();e({target:"Date",proto:!0,forced:Date.prototype.toISOString!==t},{toISOString:t})})),X$=J((()=>{"use strict";var e=tt(),t=Yt(),n=li(),i=v1();e({target:"Date",proto:!0,arity:1,forced:t((function(){return null!==new Date(NaN).toJSON()||1!==Date.prototype.toJSON.call({toISOString:function(){return 1}})}))},{toJSON:function(e){var t=n(this),r=i(t,"number");return"number"!=typeof r||isFinite(r)?t.toISOString():null}})})),$$=J(((e,t)=>{"use strict";var n=xr(),i=E3(),r=TypeError;t.exports=function(e){if(n(this),"string"===e||"default"===e)e="string";else if("number"!==e)throw r("Incorrect hint");return i(this,e)}})),J$=J((()=>{var e=$r(),t=Yi(),n=$$(),i=Br()("toPrimitive"),r=Date.prototype;e(r,i)||t(r,i,n)})),nZ=J((()=>{var e=en(),t=Yi(),n=Date.prototype,i="Invalid Date",r="toString",a=e(n[r]),s=e(n.getTime);String(new Date(NaN))!=i&&t(n,r,(function(){var e=s(this);return e==e?a(this):i}))})),iZ=J((()=>{"use strict";var e=tt(),t=en(),n=Mr(),i=t("".charAt),r=t("".charCodeAt),a=t(/./.exec),s=t(1..toString),o=t("".toUpperCase),l=/[\w*+\-./@]/,h=function(e,t){for(var n=s(e,16);n.length{"use strict";var n=en(),i=is(),r=Nr(),a=$r(),s=Fd(),o=Mg(),l=Function,h=n([].concat),c=n([].join),u={};t.exports=o?l.bind:function(e){var t=i(this),n=t.prototype,o=s(arguments,1),d=function(){var n=h(o,s(arguments));return this instanceof d?function(e,t,n){if(!a(u,t)){for(var i=[],r=0;r{var e=tt(),t=wD();e({target:"Function",proto:!0,forced:Function.bind!==t},{bind:t})})),fZ=J((()=>{"use strict";var e=Fr(),t=Nr(),n=Gi(),i=No(),r=Br(),a=KT(),s=r("hasInstance"),o=Function.prototype;s in o||n.f(o,s,{value:a((function(n){if(!e(this)||!t(n))return!1;var r=this.prototype;if(!t(r))return n instanceof this;for(;n=i(n);)if(r===n)return!0;return!1}),s)})})),vZ=J((()=>{var e=Kn(),t=wp().EXISTS,n=en(),i=Hs(),r=Function.prototype,a=n(r.toString),s=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,o=n(s.exec);e&&!t&&i(r,"name",{configurable:!0,get:function(){try{return o(s,a(this))[1]}catch(e){return""}}})})),yZ=J((()=>{var e=tt(),t=Mn();e({global:!0,forced:t.globalThis!==t},{globalThis:t})})),xZ=J((()=>{var e=Mn();no()(e.JSON,"JSON",!0)})),jw=J(((e,t)=>{var n=Yt();t.exports=n((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}))})),Yw=J(((e,t)=>{var n=Yt(),i=Nr(),r=ha(),a=jw(),s=Object.isExtensible,o=n((function(){s(1)}));t.exports=o||a?function(e){return!(!i(e)||a&&"ArrayBuffer"==r(e))&&(!s||s(e))}:s})),Np=J(((e,t)=>{var n=Yt();t.exports=!n((function(){return Object.isExtensible(Object.preventExtensions({}))}))})),qd=J(((e,t)=>{var n=tt(),i=en(),r=Ag(),a=Nr(),s=$r(),o=Gi().f,l=yh(),h=sw(),c=Yw(),u=Tp(),d=Np(),p=!1,f=u("meta"),m=0,g=function(e){o(e,f,{value:{objectID:"O"+m++,weakData:{}}})},v=t.exports={enable:function(){v.enable=function(){},p=!0;var e=l.f,t=i([].splice),r={};r[f]=1,e(r).length&&(l.f=function(n){for(var i=e(n),r=0,a=i.length;r{"use strict";var n=tt(),i=Mn(),r=en(),a=Pg(),s=Yi(),o=qd(),l=hc(),h=dc(),c=Fr(),u=La(),d=Nr(),p=Yt(),f=O1(),m=no(),g=Pp();t.exports=function(e,t,v){var y=-1!==e.indexOf("Map"),x=-1!==e.indexOf("Weak"),b=y?"set":"add",_=i[e],w=_&&_.prototype,S=_,M={},E=function(e){var t=r(w[e]);s(w,e,"add"==e?function(e){return t(this,0===e?0:e),this}:"delete"==e?function(e){return!(x&&!d(e))&&t(this,0===e?0:e)}:"get"==e?function(e){return x&&!d(e)?void 0:t(this,0===e?0:e)}:"has"==e?function(e){return!(x&&!d(e))&&t(this,0===e?0:e)}:function(e,n){return t(this,0===e?0:e,n),this})};if(a(e,!c(_)||!(x||w.forEach&&!p((function(){(new _).entries().next()})))))S=v.getConstructor(t,e,y,b),o.enable();else if(a(e,!0)){var T=new S,A=T[b](x?{}:-0,1)!=T,C=p((function(){T.has(1)})),P=f((function(e){new _(e)})),R=!x&&p((function(){for(var e=new _,t=5;t--;)e[b](t,t);return!e.has(-0)}));P||((S=t((function(e,t){h(e,w);var n=g(new _,e,S);return u(t)||l(t,n[b],{that:n,AS_ENTRIES:y}),n}))).prototype=w,w.constructor=S),(C||R)&&(E("delete"),E("has"),y&&E("get")),(R||A)&&E(b),x&&w.clear&&delete w.clear}return M[e]=S,n({global:!0,constructor:!0,forced:S!=_},M),m(S,e),x||v.setStrong(S,e,y),S}})),DD=J(((e,t)=>{"use strict";var n=to(),i=Hs(),r=Vg(),a=fl(),s=dc(),o=La(),l=hc(),h=Mw(),c=N1(),u=Dp(),d=Kn(),p=qd().fastKey,f=Ts(),m=f.set,g=f.getterFor;t.exports={getConstructor:function(e,t,h,c){var u=e((function(e,i){s(e,f),m(e,{type:t,index:n(null),first:void 0,last:void 0,size:0}),d||(e.size=0),o(i)||l(i,e[c],{that:e,AS_ENTRIES:h})})),f=u.prototype,v=g(t),y=function(e,t,n){var i,r,a=v(e),s=x(e,t);return s?s.value=n:(a.last=s={index:r=p(t,!0),key:t,value:n,previous:i=a.last,next:void 0,removed:!1},a.first||(a.first=s),i&&(i.next=s),d?a.size++:e.size++,"F"!==r&&(a.index[r]=s)),e},x=function(e,t){var n,i=v(e),r=p(t);if("F"!==r)return i.index[r];for(n=i.first;n;n=n.next)if(n.key==t)return n};return r(f,{clear:function(){for(var e=v(this),t=e.index,n=e.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete t[n.index],n=n.next;e.first=e.last=void 0,d?e.size=0:this.size=0},delete:function(e){var t=this,n=v(t),i=x(t,e);if(i){var r=i.next,a=i.previous;delete n.index[i.index],i.removed=!0,a&&(a.next=r),r&&(r.previous=a),n.first==i&&(n.first=r),n.last==i&&(n.last=a),d?n.size--:t.size--}return!!i},forEach:function(e){for(var t,n=v(this),i=a(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:n.first;)for(i(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!x(this,e)}}),r(f,h?{get:function(e){var t=x(this,e);return t&&t.value},set:function(e,t){return y(this,0===e?0:e,t)}}:{add:function(e){return y(this,e=0===e?0:e,e)}}),d&&i(f,"size",{configurable:!0,get:function(){return v(this).size}}),u},setStrong:function(e,t,n){var i=t+" Iterator",r=g(t),a=g(i);h(e,t,(function(e,t){m(this,{type:i,target:e,state:r(e),kind:t,last:void 0})}),(function(){for(var e=a(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?c("keys"==t?n.key:"values"==t?n.value:[n.key,n.value],!1):(e.target=void 0,c(void 0,!0))}),n?"entries":"values",!n,!0),u(t)}}})),OZ=J((()=>{"use strict";W1()("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),DD())})),kZ=J((()=>{OZ()})),OD=J(((e,t)=>{var n=Math.log;t.exports=Math.log1p||function(e){var t=+e;return t>-1e-8&&t<1e-8?t-t*t/2:n(1+t)}})),BZ=J((()=>{var e=tt(),t=OD(),n=Math.acosh,i=Math.log,r=Math.sqrt,a=Math.LN2;e({target:"Math",stat:!0,forced:!n||710!=Math.floor(n(Number.MAX_VALUE))||n(1/0)!=1/0},{acosh:function(e){var n=+e;return n<1?NaN:n>94906265.62425156?i(n)+a:t(n-1+r(n-1)*r(n+1))}})})),VZ=J((()=>{var e=tt(),t=Math.asinh,n=Math.log,i=Math.sqrt;e({target:"Math",stat:!0,forced:!(t&&1/t(0)>0)},{asinh:function e(t){var r=+t;return isFinite(r)&&0!=r?r<0?-e(-r):n(r+i(r*r+1)):r}})})),GZ=J((()=>{var e=tt(),t=Math.atanh,n=Math.log;e({target:"Math",stat:!0,forced:!(t&&1/t(-0)<0)},{atanh:function(e){var t=+e;return 0==t?t:n((1+t)/(1-t))/2}})})),Zw=J(((e,t)=>{t.exports=Math.sign||function(e){var t=+e;return 0==t||t!=t?t:t<0?-1:1}})),WZ=J((()=>{var e=tt(),t=Zw(),n=Math.abs,i=Math.pow;e({target:"Math",stat:!0},{cbrt:function(e){var r=+e;return t(r)*i(n(r),1/3)}})})),jZ=J((()=>{var e=tt(),t=Math.floor,n=Math.log,i=Math.LOG2E;e({target:"Math",stat:!0},{clz32:function(e){var r=e>>>0;return r?31-t(n(r+.5)*i):32}})})),Y1=J(((e,t)=>{var n=Math.expm1,i=Math.exp;t.exports=!n||n(10)>22025.465794806718||n(10)<22025.465794806718||-2e-17!=n(-2e-17)?function(e){var t=+e;return 0==t?t:t>-1e-6&&t<1e-6?t+t*t/2:i(t)-1}:n})),$Z=J((()=>{var e=tt(),t=Y1(),n=Math.cosh,i=Math.abs,r=Math.E;e({target:"Math",stat:!0,forced:!n||n(710)===1/0},{cosh:function(e){var n=t(i(e)-1)+1;return(n+1/(n*r*r))*(r/2)}})})),KZ=J((()=>{var e=tt(),t=Y1();e({target:"Math",stat:!0,forced:t!=Math.expm1},{expm1:t})})),QZ=J(((e,t)=>{var n=Zw(),i=Math.abs,r=Math.pow,a=r(2,-52),s=r(2,-23),o=r(2,127)*(2-s),l=r(2,-126);t.exports=Math.fround||function(e){var t,r,h=+e,c=i(h),u=n(h);return co||r!=r?u*(1/0):u*r}})),eK=J((()=>{tt()({target:"Math",stat:!0},{fround:QZ()})})),nK=J((()=>{var e=tt(),t=Math.hypot,n=Math.abs,i=Math.sqrt;e({target:"Math",stat:!0,arity:2,forced:!!t&&t(1/0,NaN)!==1/0},{hypot:function(e,t){for(var r,a,s=0,o=0,l=arguments.length,h=0;o0?(a=r/h)*a:r;return h===1/0?1/0:h*i(s)}})})),iK=J((()=>{var e=tt(),t=Yt(),n=Math.imul;e({target:"Math",stat:!0,forced:t((function(){return-5!=n(4294967295,5)||2!=n.length}))},{imul:function(e,t){var n=65535,i=+e,r=+t,a=n&i,s=n&r;return 0|a*s+((n&i>>>16)*s+a*(n&r>>>16)<<16>>>0)}})})),UD=J(((e,t)=>{var n=Math.log,i=Math.LOG10E;t.exports=Math.log10||function(e){return n(e)*i}})),aK=J((()=>{tt()({target:"Math",stat:!0},{log10:UD()})})),oK=J((()=>{tt()({target:"Math",stat:!0},{log1p:OD()})})),lK=J((()=>{var e=tt(),t=Math.log,n=Math.LN2;e({target:"Math",stat:!0},{log2:function(e){return t(e)/n}})})),cK=J((()=>{tt()({target:"Math",stat:!0},{sign:Zw()})})),dK=J((()=>{var e=tt(),t=Yt(),n=Y1(),i=Math.abs,r=Math.exp,a=Math.E;e({target:"Math",stat:!0,forced:t((function(){return-2e-17!=Math.sinh(-2e-17)}))},{sinh:function(e){var t=+e;return i(t)<1?(n(t)-n(-t))/2:(r(t-1)-r(-t-1))*(a/2)}})})),mK=J((()=>{var e=tt(),t=Y1(),n=Math.exp;e({target:"Math",stat:!0},{tanh:function(e){var i=+e,r=t(i),a=t(-i);return r==1/0?1:a==1/0?-1:(r-a)/(n(i)+n(-i))}})})),gK=J((()=>{no()(Math,"Math",!0)})),vK=J((()=>{tt()({target:"Math",stat:!0},{trunc:U3()})})),$1=J(((e,t)=>{var n=en();t.exports=n(1..valueOf)})),Z1=J(((e,t)=>{t.exports="\t\n\v\f\r \xa0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\ufeff"})),Bp=J(((e,t)=>{var n=en(),i=_s(),r=Mr(),a=Z1(),s=n("".replace),o=RegExp("^["+a+"]+"),l=RegExp("(^|[^"+a+"])["+a+"]+$"),h=function(e){return function(t){var n=r(i(t));return 1&e&&(n=s(n,o,"")),2&e&&(n=s(n,l,"$1")),n}};t.exports={start:h(1),end:h(2),trim:h(3)}})),AK=J((()=>{"use strict";var e=tt(),t=ss(),n=Kn(),i=Mn(),r=aw(),a=en(),s=Pg(),o=$r(),l=Pp(),h=ko(),c=Dd(),u=v1(),d=Yt(),p=yh().f,f=Qs().f,m=Gi().f,g=$1(),v=Bp().trim,y="Number",x=i[y],b=r[y],_=x.prototype,w=i.TypeError,S=a("".slice),M=a("".charCodeAt),E=s(y,!x(" 0o1")||!x("0b1")||x("+0x1")),T=function(e){var t,n=arguments.length<1?0:x(function(e){var t=u(e,"number");return"bigint"==typeof t?t:function(e){var t,n,i,r,a,s,o,l,h=u(e,"number");if(c(h))throw w("Cannot convert a Symbol value to a number");if("string"==typeof h&&h.length>2)if(h=v(h),43===(t=M(h,0))||45===t){if(88===(n=M(h,2))||120===n)return NaN}else if(48===t){switch(M(h,1)){case 66:case 98:i=2,r=49;break;case 79:case 111:i=8,r=55;break;default:return+h}for(s=(a=S(h,2)).length,o=0;or)return NaN;return parseInt(a,i)}return+h}(t)}(e));return h(_,t=this)&&d((function(){g(t)}))?l(Object(n),this,T):n};T.prototype=_,E&&!t&&(_.constructor=T),e({global:!0,constructor:!0,wrap:!0,forced:E},{Number:T});var A=function(e,t){for(var i,r=n?p(t):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),a=0;r.length>a;a++)o(t,i=r[a])&&!o(e,i)&&m(e,i,f(t,i))};t&&b&&A(r[y],b),(E||t)&&A(r[y],x)})),CK=J((()=>{tt()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{EPSILON:Math.pow(2,-52)})})),IK=J(((e,t)=>{var n=Mn().isFinite;t.exports=Number.isFinite||function(e){return"number"==typeof e&&n(e)}})),LK=J((()=>{tt()({target:"Number",stat:!0},{isFinite:IK()})})),tS=J(((e,t)=>{var n=Nr(),i=Math.floor;t.exports=Number.isInteger||function(e){return!n(e)&&isFinite(e)&&i(e)===e}})),OK=J((()=>{tt()({target:"Number",stat:!0},{isInteger:tS()})})),kK=J((()=>{tt()({target:"Number",stat:!0},{isNaN:function(e){return e!=e}})})),FK=J((()=>{var e=tt(),t=tS(),n=Math.abs;e({target:"Number",stat:!0},{isSafeInteger:function(e){return t(e)&&n(e)<=9007199254740991}})})),NK=J((()=>{tt()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991})})),BK=J((()=>{tt()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MIN_SAFE_INTEGER:-9007199254740991})})),jD=J(((e,t)=>{var n=Mn(),i=Yt(),r=en(),a=Mr(),s=Bp().trim,o=Z1(),l=r("".charAt),h=n.parseFloat,c=n.Symbol,u=c&&c.iterator,d=1/h(o+"-0")!=-1/0||u&&!i((function(){h(Object(u))}));t.exports=d?function(e){var t=s(a(e)),n=h(t);return 0===n&&"-"==l(t,0)?-0:n}:h})),qK=J((()=>{var e=tt(),t=jD();e({target:"Number",stat:!0,forced:Number.parseFloat!=t},{parseFloat:t})})),XD=J(((e,t)=>{var n=Mn(),i=Yt(),r=en(),a=Mr(),s=Bp().trim,o=Z1(),l=n.parseInt,h=n.Symbol,c=h&&h.iterator,u=/^[+-]?0x/i,d=r(u.exec),p=8!==l(o+"08")||22!==l(o+"0x16")||c&&!i((function(){l(Object(c))}));t.exports=p?function(e,t){var n=s(a(e));return l(n,t>>>0||(d(u,n)?16:10))}:l})),JK=J((()=>{var e=tt(),t=XD();e({target:"Number",stat:!0,forced:Number.parseInt!=t},{parseInt:t})})),rJ=J((()=>{"use strict";var e=tt(),t=en(),n=as(),i=$1(),r=G1(),a=UD(),s=Yt(),o=RangeError,l=String,h=isFinite,c=Math.abs,u=Math.floor,d=Math.pow,p=Math.round,f=t(1..toExponential),m=t(r),g=t("".slice),v="-6.9000e-11"===f(-69e-12,4)&&"1.25e+0"===f(1.255,2)&&"1.235e+4"===f(12345,3)&&"3e+1"===f(25,0);e({target:"Number",proto:!0,forced:!v||!(s((function(){f(1,1/0)}))&&s((function(){f(1,-1/0)})))||!!s((function(){f(1/0,1/0),f(NaN,1/0)}))},{toExponential:function(e){var t=i(this);if(void 0===e)return f(t);var r=n(e);if(!h(t))return String(t);if(r<0||r>20)throw o("Incorrect fraction digits");if(v)return f(t,r);var s="",y="",x=0,b="",_="";if(t<0&&(s="-",t=-t),0===t)x=0,y=m("0",r+1);else{var w=a(t);x=u(w);var S=0,M=d(10,x-r);2*t>=(2*(S=p(t/M))+1)*M&&(S+=1),S>=d(10,r+1)&&(S/=10,x+=1),y=l(S)}return 0!==r&&(y=g(y,0,1)+"."+g(y,1)),0===x?(b="+",_="0"):(b=x>0?"+":"-",_=l(c(x))),s+(y+"e")+b+_}})})),cJ=J((()=>{"use strict";var e=tt(),t=en(),n=as(),i=$1(),r=G1(),a=Yt(),s=RangeError,o=String,l=Math.floor,h=t(r),c=t("".slice),u=t(1..toFixed),d=function(e,t,n){return 0===t?n:t%2==1?d(e,t-1,n*e):d(e*e,t/2,n)},p=function(e,t,n){for(var i=-1,r=n;++i<6;)r+=t*e[i],e[i]=r%1e7,r=l(r/1e7)},f=function(e,t){for(var n=6,i=0;--n>=0;)i+=e[n],e[n]=l(i/t),i=i%t*1e7},m=function(e){for(var t=6,n="";--t>=0;)if(""!==n||0===t||0!==e[t]){var i=o(e[t]);n=""===n?i:n+h("0",7-i.length)+i}return n};e({target:"Number",proto:!0,forced:a((function(){return"0.000"!==u(8e-5,3)||"1"!==u(.9,0)||"1.25"!==u(1.255,2)||"1000000000000000128"!==u(0xde0b6b3a7640080,0)}))||!a((function(){u({})}))},{toFixed:function(e){var t,r,a,l,u=i(this),g=n(e),v=[0,0,0,0,0,0],y="",x="0";if(g<0||g>20)throw s("Incorrect fraction digits");if(u!=u)return"NaN";if(u<=-1e21||u>=1e21)return o(u);if(u<0&&(y="-",u=-u),u>1e-21)if(t=function(e){for(var t=0,n=e;n>=4096;)t+=12,n/=4096;for(;n>=2;)t+=1,n/=2;return t}(u*d(2,69,1))-69,r=t<0?u*d(2,-t,1):u/d(2,t,1),r*=4503599627370496,(t=52-t)>0){for(p(v,0,r),a=g;a>=7;)p(v,1e7,0),a-=7;for(p(v,d(10,a,1),0),a=t-1;a>=23;)f(v,1<<23),a-=23;f(v,1<0?y+((l=x.length)<=g?"0."+h("0",g-l)+x:c(x,0,l-g)+"."+c(x,l-g)):y+x}})})),dJ=J((()=>{"use strict";var e=tt(),t=en(),n=Yt(),i=$1(),r=t(1..toPrecision);e({target:"Number",proto:!0,forced:n((function(){return"1"!==r(1,void 0)}))||!n((function(){r({})}))},{toPrecision:function(e){return void 0===e?r(i(this)):r(i(this),e)}})})),eO=J(((e,t)=>{"use strict";var n=Kn(),i=en(),r=Sr(),a=Yt(),s=Ig(),o=E1(),l=g1(),h=li(),c=bp(),u=Object.assign,d=Object.defineProperty,p=i([].concat);t.exports=!u||a((function(){if(n&&1!==u({b:1},u(d({},"a",{enumerable:!0,get:function(){d(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},i=Symbol(),r="abcdefghijklmnopqrst";return e[i]=7,r.split("").forEach((function(e){t[e]=e})),7!=u({},e)[i]||s(u({},t)).join("")!=r}))?function(e,t){for(var i=h(e),a=arguments.length,u=1,d=o.f,f=l.f;a>u;)for(var m,g=c(arguments[u++]),v=d?p(s(g),d(g)):s(g),y=v.length,x=0;y>x;)m=v[x++],(!n||r(f,g,m))&&(i[m]=g[m]);return i}:u})),vJ=J((()=>{var e=tt(),t=eO();e({target:"Object",stat:!0,arity:2,forced:Object.assign!==t},{assign:t})})),yJ=J((()=>{tt()({target:"Object",stat:!0,sham:!Kn()},{create:to()})})),ex=J(((e,t)=>{"use strict";var n=ss(),i=Mn(),r=Yt(),a=Pw();t.exports=n||!r((function(){if(!(a&&a<535)){var e=Math.random();__defineSetter__.call(null,e,(function(){})),delete i[e]}}))})),EJ=J((()=>{"use strict";var e=tt(),t=Kn(),n=ex(),i=is(),r=li(),a=Gi();t&&e({target:"Object",proto:!0,forced:n},{__defineGetter__:function(e,t){a.f(r(this),e,{get:i(t),enumerable:!0,configurable:!0})}})})),TJ=J((()=>{var e=tt(),t=Kn(),n=nw().f;e({target:"Object",stat:!0,forced:Object.defineProperties!==n,sham:!t},{defineProperties:n})})),SJ=J((()=>{var e=tt(),t=Kn(),n=Gi().f;e({target:"Object",stat:!0,forced:Object.defineProperty!==n,sham:!t},{defineProperty:n})})),MJ=J((()=>{"use strict";var e=tt(),t=Kn(),n=ex(),i=is(),r=li(),a=Gi();t&&e({target:"Object",proto:!0,forced:n},{__defineSetter__:function(e,t){a.f(r(this),e,{set:i(t),enumerable:!0,configurable:!0})}})})),tO=J(((e,t)=>{var n=Kn(),i=en(),r=Ig(),a=Ls(),s=i(g1().f),o=i([].push),l=function(e){return function(t){for(var i,l=a(t),h=r(l),c=h.length,u=0,d=[];c>u;)i=h[u++],(!n||s(l,i))&&o(d,e?[i,l[i]]:l[i]);return d}};t.exports={entries:l(!0),values:l(!1)}})),PJ=J((()=>{var e=tt(),t=tO().entries;e({target:"Object",stat:!0},{entries:function(e){return t(e)}})})),IJ=J((()=>{var e=tt(),t=Np(),n=Yt(),i=Nr(),r=qd().onFreeze,a=Object.freeze;e({target:"Object",stat:!0,forced:n((function(){a(1)})),sham:!t},{freeze:function(e){return a&&i(e)?a(r(e)):e}})})),LJ=J((()=>{var e=tt(),t=hc(),n=ou();e({target:"Object",stat:!0},{fromEntries:function(e){var i={};return t(e,(function(e,t){n(i,e,t)}),{AS_ENTRIES:!0}),i}})})),kJ=J((()=>{var e=tt(),t=Yt(),n=Ls(),i=Qs().f,r=Kn();e({target:"Object",stat:!0,forced:!r||t((function(){i(1)})),sham:!r},{getOwnPropertyDescriptor:function(e,t){return i(n(e),t)}})})),FJ=J((()=>{var e=tt(),t=Kn(),n=QT(),i=Ls(),r=Qs(),a=ou();e({target:"Object",stat:!0,sham:!t},{getOwnPropertyDescriptors:function(e){for(var t,s,o=i(e),l=r.f,h=n(o),c={},u=0;h.length>u;)void 0!==(s=l(o,t=h[u++]))&&a(c,t,s);return c}})})),NJ=J((()=>{var e=tt(),t=Yt(),n=sw().f;e({target:"Object",stat:!0,forced:t((function(){return!Object.getOwnPropertyNames(1)}))},{getOwnPropertyNames:n})})),UJ=J((()=>{var e=tt(),t=Yt(),n=li(),i=No(),r=vw();e({target:"Object",stat:!0,forced:t((function(){i(1)})),sham:!r},{getPrototypeOf:function(e){return i(n(e))}})})),HJ=J((()=>{tt()({target:"Object",stat:!0},{hasOwn:$r()})})),rO=J(((e,t)=>{t.exports=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}})),zJ=J((()=>{tt()({target:"Object",stat:!0},{is:rO()})})),qJ=J((()=>{var e=tt(),t=Yw();e({target:"Object",stat:!0,forced:Object.isExtensible!==t},{isExtensible:t})})),jJ=J((()=>{var e=tt(),t=Yt(),n=Nr(),i=ha(),r=jw(),a=Object.isFrozen;e({target:"Object",stat:!0,forced:r||t((function(){a(1)}))},{isFrozen:function(e){return!(n(e)&&(!r||"ArrayBuffer"!=i(e)))||!!a&&a(e)}})})),YJ=J((()=>{var e=tt(),t=Yt(),n=Nr(),i=ha(),r=jw(),a=Object.isSealed;e({target:"Object",stat:!0,forced:r||t((function(){a(1)}))},{isSealed:function(e){return!(n(e)&&(!r||"ArrayBuffer"!=i(e)))||!!a&&a(e)}})})),ZJ=J((()=>{var e=tt(),t=li(),n=Ig();e({target:"Object",stat:!0,forced:Yt()((function(){n(1)}))},{keys:function(e){return n(t(e))}})})),KJ=J((()=>{"use strict";var e=tt(),t=Kn(),n=ex(),i=li(),r=vh(),a=No(),s=Qs().f;t&&e({target:"Object",proto:!0,forced:n},{__lookupGetter__:function(e){var t,n=i(this),o=r(e);do{if(t=s(n,o))return t.get}while(n=a(n))}})})),JJ=J((()=>{"use strict";var e=tt(),t=Kn(),n=ex(),i=li(),r=vh(),a=No(),s=Qs().f;t&&e({target:"Object",proto:!0,forced:n},{__lookupSetter__:function(e){var t,n=i(this),o=r(e);do{if(t=s(n,o))return t.set}while(n=a(n))}})})),QJ=J((()=>{var e=tt(),t=Nr(),n=qd().onFreeze,i=Np(),r=Yt(),a=Object.preventExtensions;e({target:"Object",stat:!0,forced:r((function(){a(1)})),sham:!i},{preventExtensions:function(e){return a&&t(e)?a(n(e)):e}})})),sQ=J((()=>{"use strict";var e=Kn(),t=Hs(),n=Nr(),i=li(),r=_s(),a=Object.getPrototypeOf,s=Object.setPrototypeOf,o=Object.prototype,l="__proto__";if(e&&a&&s&&!(l in o))try{t(o,l,{configurable:!0,get:function(){return a(i(this))},set:function(e){var t=r(this);!n(e)&&null!==e||!n(t)||s(t,e)}})}catch(e){}})),aQ=J((()=>{var e=tt(),t=Nr(),n=qd().onFreeze,i=Np(),r=Yt(),a=Object.seal;e({target:"Object",stat:!0,forced:r((function(){a(1)})),sham:!i},{seal:function(e){return a&&t(e)?a(n(e)):e}})})),oQ=J((()=>{tt()({target:"Object",stat:!0},{setPrototypeOf:uc()})})),cQ=J(((e,t)=>{"use strict";var n=ew(),i=cc();t.exports=n?{}.toString:function(){return"[object "+i(this)+"]"}})),uQ=J((()=>{var e=ew(),t=Yi(),n=cQ();e||t(Object.prototype,"toString",n,{unsafe:!0})})),hQ=J((()=>{var e=tt(),t=tO().values;e({target:"Object",stat:!0},{values:function(e){return t(e)}})})),fQ=J((()=>{var e=tt(),t=jD();e({global:!0,forced:parseFloat!=t},{parseFloat:t})})),mQ=J((()=>{var e=tt(),t=XD();e({global:!0,forced:parseInt!=t},{parseInt:t})})),pu=J(((e,t)=>{var n=TypeError;t.exports=function(e,t){if(e{var n=iu();t.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(n)})),rx=J(((e,t)=>{var n,i,r,a,s=Mn(),o=Fo(),l=fl(),h=Fr(),c=$r(),u=Yt(),d=G3(),p=Fd(),f=y1(),m=pu(),g=lO(),v=uu(),y=s.setImmediate,x=s.clearImmediate,b=s.process,_=s.Dispatch,w=s.Function,S=s.MessageChannel,M=s.String,E=0,T={},A="onreadystatechange";u((function(){n=s.location}));var C=function(e){if(c(T,e)){var t=T[e];delete T[e],t()}},P=function(e){return function(){C(e)}},R=function(e){C(e.data)},O=function(e){s.postMessage(M(e),n.protocol+"//"+n.host)};(!y||!x)&&(y=function(e){m(arguments.length,1);var t=h(e)?e:w(e),n=p(arguments,1);return T[++E]=function(){o(t,void 0,n)},i(E),E},x=function(e){delete T[e]},v?i=function(e){b.nextTick(P(e))}:_&&_.now?i=function(e){_.now(P(e))}:S&&!g?(a=(r=new S).port2,r.port1.onmessage=R,i=l(a.postMessage,a)):s.addEventListener&&h(s.postMessage)&&!s.importScripts&&n&&"file:"!==n.protocol&&!u(O)?(i=O,s.addEventListener("message",R,!1)):i=A in f("script")?function(e){d.appendChild(f("script"))[A]=function(){d.removeChild(this),C(e)}}:function(e){setTimeout(P(e),0)}),t.exports={set:y,clear:x}})),vO=J(((e,t)=>{var n=function(){this.head=null,this.tail=null};n.prototype={add:function(e){var t={item:e,next:null},n=this.tail;n?n.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}},t.exports=n})),PQ=J(((e,t)=>{var n=iu();t.exports=/ipad|iphone|ipod/i.test(n)&&"undefined"!=typeof Pebble})),LQ=J(((e,t)=>{var n=iu();t.exports=/web0s(?!.*chrome)/i.test(n)})),TO=J(((e,t)=>{var n,i,r,a,s,o,l,h=Mn(),c=fl(),u=Qs().f,d=rx().set,p=vO(),f=lO(),m=PQ(),g=LQ(),v=uu(),y=h.MutationObserver||h.WebKitMutationObserver,x=h.document,b=h.process,_=h.Promise,w=u(h,"queueMicrotask"),S=w&&w.value;S||(o=new p,l=function(){var e,t;for(v&&(e=b.domain)&&e.exit();t=o.get();)try{t()}catch(e){throw o.head&&n(),e}e&&e.enter()},f||v||g||!y||!x?!m&&_&&_.resolve?((a=_.resolve(void 0)).constructor=_,s=c(a.then,a),n=function(){s(l)}):v?n=function(){b.nextTick(l)}:(d=c(d,h),n=function(){d(l)}):(i=!0,r=x.createTextNode(""),new y(l).observe(r,{characterData:!0}),n=function(){r.data=i=!i}),S=function(e){o.head||n(),o.add(e)}),t.exports=S})),VQ=J(((e,t)=>{t.exports=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(e){}}})),Jg=J(((e,t)=>{t.exports=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}}})),Vp=J(((e,t)=>{var n=Mn();t.exports=n.Promise})),aS=J(((e,t)=>{t.exports="object"==typeof Deno&&Deno&&"object"==typeof Deno.version})),wO=J(((e,t)=>{var n=aS(),i=uu();t.exports=!n&&!i&&"object"==typeof window&&"object"==typeof document})),Qg=J(((e,t)=>{var n=Mn(),i=Vp(),r=Fr(),a=Pg(),s=jT(),o=Br(),l=wO(),h=aS(),c=ss(),u=su(),d=i&&i.prototype,p=o("species"),f=!1,m=r(n.PromiseRejectionEvent),g=a("Promise",(function(){var e=s(i),t=e!==String(i);if(!t&&66===u||c&&(!d.catch||!d.finally))return!0;if(!u||u<51||!/native code/.test(e)){var n=new i((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((n.constructor={})[p]=r,!(f=n.then((function(){}))instanceof r))return!0}return!t&&(l||h)&&!m}));t.exports={CONSTRUCTOR:g,REJECTION_EVENT:m,SUBCLASSING:f}})),Wd=J(((e,t)=>{"use strict";var n=is(),i=TypeError,r=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw i("Bad Promise constructor");t=e,r=n})),this.resolve=n(t),this.reject=n(r)};t.exports.f=function(e){return new r(e)}})),mee=J((()=>{"use strict";var e,t,n,i=tt(),r=ss(),a=uu(),s=Mn(),o=Sr(),l=Yi(),h=uc(),c=no(),u=Dp(),d=is(),p=Fr(),f=Nr(),m=dc(),g=kp(),v=rx().set,y=TO(),x=VQ(),b=Jg(),_=vO(),w=Ts(),S=Vp(),M=Qg(),E=Wd(),T="Promise",A=M.CONSTRUCTOR,C=M.REJECTION_EVENT,P=M.SUBCLASSING,R=w.getterFor(T),O=w.set,L=S&&S.prototype,I=S,D=L,k=s.TypeError,N=s.document,F=s.process,U=E.f,B=U,z=!!(N&&N.createEvent&&s.dispatchEvent),H="unhandledrejection",V=function(e){var t;return!(!f(e)||!p(t=e.then))&&t},j=function(e,t){var n,i,r,a=t.value,s=1==t.state,l=s?e.ok:e.fail,h=e.resolve,c=e.reject,u=e.domain;try{l?(s||(2===t.rejection&&q(t),t.rejection=1),!0===l?n=a:(u&&u.enter(),n=l(a),u&&(u.exit(),r=!0)),n===e.promise?c(k("Promise-chain cycle")):(i=V(n))?o(i,n,h,c):h(n)):c(a)}catch(e){u&&!r&&u.exit(),c(e)}},G=function(e,t){e.notified||(e.notified=!0,y((function(){for(var n,i=e.reactions;n=i.get();)j(n,e);e.notified=!1,t&&!e.rejection&&X(e)})))},W=function(e,t,n){var i,r;z?((i=N.createEvent("Event")).promise=t,i.reason=n,i.initEvent(e,!1,!0),s.dispatchEvent(i)):i={promise:t,reason:n},!C&&(r=s["on"+e])?r(i):e===H&&x("Unhandled promise rejection",n)},X=function(e){o(v,s,(function(){var t,n=e.facade,i=e.value;if(Y(e)&&(t=b((function(){a?F.emit("unhandledRejection",i,n):W(H,n,i)})),e.rejection=a||Y(e)?2:1,t.error))throw t.value}))},Y=function(e){return 1!==e.rejection&&!e.parent},q=function(e){o(v,s,(function(){var t=e.facade;a?F.emit("rejectionHandled",t):W("rejectionhandled",t,e.value)}))},J=function(e,t,n){return function(i){e(t,i,n)}},Z=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,G(e,!0))},K=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw k("Promise can't be resolved itself");var i=V(t);i?y((function(){var n={done:!1};try{o(i,t,J(K,n,e),J(Z,n,e))}catch(t){Z(n,t,e)}})):(e.value=t,e.state=1,G(e,!1))}catch(t){Z({done:!1},t,e)}}};if(A&&(D=(I=function(t){m(this,D),d(t),o(e,this);var n=R(this);try{t(J(K,n),J(Z,n))}catch(e){Z(n,e)}}).prototype,(e=function(e){O(this,{type:T,done:!1,notified:!1,parent:!1,reactions:new _,rejection:!1,state:0,value:void 0})}).prototype=l(D,"then",(function(e,t){var n=R(this),i=U(g(this,I));return n.parent=!0,i.ok=!p(e)||e,i.fail=p(t)&&t,i.domain=a?F.domain:void 0,0==n.state?n.reactions.add(i):y((function(){j(i,n)})),i.promise})),t=function(){var t=new e,n=R(t);this.promise=t,this.resolve=J(K,n),this.reject=J(Z,n)},E.f=U=function(e){return e===I||void 0===e?new t(e):B(e)},!r&&p(S)&&L!==Object.prototype)){n=L.then,P||l(L,"then",(function(e,t){var i=this;return new I((function(e,t){o(n,i,e,t)})).then(e,t)}),{unsafe:!0});try{delete L.constructor}catch(e){}h&&h(L,D)}i({global:!0,constructor:!0,wrap:!0,forced:A},{Promise:I}),c(I,T,!1,!0),u(T)})),ox=J(((e,t)=>{var n=Vp(),i=O1(),r=Qg().CONSTRUCTOR;t.exports=r||!i((function(e){n.all(e).then(void 0,(function(){}))}))})),vee=J((()=>{"use strict";var e=tt(),t=Sr(),n=is(),i=Wd(),r=Jg(),a=hc();e({target:"Promise",stat:!0,forced:ox()},{all:function(e){var s=this,o=i.f(s),l=o.resolve,h=o.reject,c=r((function(){var i=n(s.resolve),r=[],o=0,c=1;a(e,(function(e){var n=o++,a=!1;c++,t(i,s,e).then((function(e){a||(a=!0,r[n]=e,--c||l(r))}),h)})),--c||l(r)}));return c.error&&h(c.value),o.promise}})})),xee=J((()=>{"use strict";var e,t=tt(),n=ss(),i=Qg().CONSTRUCTOR,r=Vp(),a=ki(),s=Fr(),o=Yi(),l=r&&r.prototype;t({target:"Promise",proto:!0,forced:i,real:!0},{catch:function(e){return this.then(void 0,e)}}),!n&&s(r)&&(e=a("Promise").prototype.catch,l.catch!==e&&o(l,"catch",e,{unsafe:!0}))})),bee=J((()=>{"use strict";var e=tt(),t=Sr(),n=is(),i=Wd(),r=Jg(),a=hc();e({target:"Promise",stat:!0,forced:ox()},{race:function(e){var s=this,o=i.f(s),l=o.reject,h=r((function(){var i=n(s.resolve);a(e,(function(e){t(i,s,e).then(o.resolve,l)}))}));return h.error&&l(h.value),o.promise}})})),Eee=J((()=>{"use strict";var e=tt(),t=Sr(),n=Wd();e({target:"Promise",stat:!0,forced:Qg().CONSTRUCTOR},{reject:function(e){var i=n.f(this);return t(i.reject,void 0,e),i.promise}})})),NO=J(((e,t)=>{var n=xr(),i=Nr(),r=Wd();t.exports=function(e,t){if(n(e),i(t)&&t.constructor===e)return t;var a=r.f(e);return(0,a.resolve)(t),a.promise}})),See=J((()=>{"use strict";var e=tt(),t=ki(),n=ss(),i=Vp(),r=Qg().CONSTRUCTOR,a=NO(),s=t("Promise"),o=n&&!r;e({target:"Promise",stat:!0,forced:n||r},{resolve:function(e){return a(o&&this===s?i:this,e)}})})),Mee=J((()=>{mee(),vee(),xee(),bee(),Eee(),See()})),Ree=J((()=>{"use strict";var e=tt(),t=Sr(),n=is(),i=Wd(),r=Jg(),a=hc();e({target:"Promise",stat:!0,forced:ox()},{allSettled:function(e){var s=this,o=i.f(s),l=o.resolve,h=o.reject,c=r((function(){var i=n(s.resolve),r=[],o=0,h=1;a(e,(function(e){var n=o++,a=!1;h++,t(i,s,e).then((function(e){a||(a=!0,r[n]={status:"fulfilled",value:e},--h||l(r))}),(function(e){a||(a=!0,r[n]={status:"rejected",reason:e},--h||l(r))}))})),--h||l(r)}));return c.error&&h(c.value),o.promise}})})),Cee=J((()=>{"use strict";var e=tt(),t=Sr(),n=is(),i=ki(),r=Wd(),a=Jg(),s=hc(),o=ox(),l="No one promise resolved";e({target:"Promise",stat:!0,forced:o},{any:function(e){var o=this,h=i("AggregateError"),c=r.f(o),u=c.resolve,d=c.reject,p=a((function(){var i=n(o.resolve),r=[],a=0,c=1,p=!1;s(e,(function(e){var n=a++,s=!1;c++,t(i,o,e).then((function(e){s||p||(p=!0,u(e))}),(function(e){s||p||(s=!0,r[n]=e,--c||d(new h(r,l)))}))})),--c||d(new h(r,l))}));return p.error&&d(p.value),c.promise}})})),Dee=J((()=>{"use strict";var e,t=tt(),n=ss(),i=Vp(),r=Yt(),a=ki(),s=Fr(),o=kp(),l=NO(),h=Yi(),c=i&&i.prototype;t({target:"Promise",proto:!0,real:!0,forced:!!i&&r((function(){c.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=o(this,a("Promise")),n=s(e);return this.then(n?function(n){return l(t,e()).then((function(){return n}))}:e,n?function(n){return l(t,e()).then((function(){throw n}))}:e)}}),!n&&s(i)&&(e=a("Promise").prototype.finally,c.finally!==e&&h(c,"finally",e,{unsafe:!0}))})),Oee=J((()=>{var e=tt(),t=Fo(),n=is(),i=xr();e({target:"Reflect",stat:!0,forced:!Yt()((function(){Reflect.apply((function(){}))}))},{apply:function(e,r,a){return t(n(e),r,i(a))}})})),Vee=J((()=>{var e=tt(),t=ki(),n=Fo(),i=wD(),r=qw(),a=xr(),s=Nr(),o=to(),l=Yt(),h=t("Reflect","construct"),c=Object.prototype,u=[].push,d=l((function(){function e(){}return!(h((function(){}),[],e)instanceof e)})),p=!l((function(){h((function(){}))})),f=d||p;e({target:"Reflect",stat:!0,forced:f,sham:f},{construct:function(e,t){r(e),a(t);var l=arguments.length<3?e:r(arguments[2]);if(p&&!d)return h(e,t,l);if(e==l){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var f=[null];return n(u,f,t),new(n(i,e,f))}var m=l.prototype,g=o(s(m)?m:c),v=n(e,g,t);return s(v)?v:g}})})),qee=J((()=>{var e=tt(),t=Kn(),n=xr(),i=vh(),r=Gi();e({target:"Reflect",stat:!0,forced:Yt()((function(){Reflect.defineProperty(r.f({},1,{value:1}),1,{value:2})})),sham:!t},{defineProperty:function(e,t,a){n(e);var s=i(t);n(a);try{return r.f(e,s,a),!0}catch(e){return!1}}})})),Wee=J((()=>{var e=tt(),t=xr(),n=Qs().f;e({target:"Reflect",stat:!0},{deleteProperty:function(e,i){var r=n(t(e),i);return!(r&&!r.configurable)&&delete e[i]}})})),zO=J(((e,t)=>{var n=$r();t.exports=function(e){return void 0!==e&&(n(e,"value")||n(e,"writable"))}})),$ee=J((()=>{var e=tt(),t=Sr(),n=Nr(),i=xr(),r=zO(),a=Qs(),s=No();e({target:"Reflect",stat:!0},{get:function e(o,l){var h,c,u=arguments.length<3?o:arguments[2];return i(o)===u?o[l]:(h=a.f(o,l))?r(h)?h.value:void 0===h.get?void 0:t(h.get,u):n(c=s(o))?e(c,l,u):void 0}})})),Zee=J((()=>{var e=tt(),t=Kn(),n=xr(),i=Qs();e({target:"Reflect",stat:!0,sham:!t},{getOwnPropertyDescriptor:function(e,t){return i.f(n(e),t)}})})),Kee=J((()=>{var e=tt(),t=xr(),n=No();e({target:"Reflect",stat:!0,sham:!vw()},{getPrototypeOf:function(e){return n(t(e))}})})),Jee=J((()=>{tt()({target:"Reflect",stat:!0},{has:function(e,t){return t in e}})})),Qee=J((()=>{var e=tt(),t=xr(),n=Yw();e({target:"Reflect",stat:!0},{isExtensible:function(e){return t(e),n(e)}})})),ete=J((()=>{tt()({target:"Reflect",stat:!0},{ownKeys:QT()})})),tte=J((()=>{var e=tt(),t=ki(),n=xr();e({target:"Reflect",stat:!0,sham:!Np()},{preventExtensions:function(e){n(e);try{var i=t("Object","preventExtensions");return i&&i(e),!0}catch(e){return!1}}})})),ate=J((()=>{var e=tt(),t=Sr(),n=xr(),i=Nr(),r=zO(),a=Yt(),s=Gi(),o=Qs(),l=No(),h=Oo();e({target:"Reflect",stat:!0,forced:a((function(){var e=function(){},t=s.f(new e,"a",{configurable:!0});return!1!==Reflect.set(e.prototype,"a",1,t)}))},{set:function e(a,c,u){var d,p,f,m=arguments.length<4?a:arguments[3],g=o.f(n(a),c);if(!g){if(i(p=l(a)))return e(p,c,u,m);g=h(0)}if(r(g)){if(!1===g.writable||!i(m))return!1;if(d=o.f(m,c)){if(d.get||d.set||!1===d.writable)return!1;d.value=u,s.f(m,c,d)}else s.f(m,c,h(0,u))}else{if(void 0===(f=g.set))return!1;t(f,m,u)}return!0}})})),lte=J((()=>{var e=tt(),t=xr(),n=fL(),i=uc();i&&e({target:"Reflect",stat:!0},{setPrototypeOf:function(e,r){t(e),n(r);try{return i(e,r),!0}catch(e){return!1}}})})),cte=J((()=>{var e=tt(),t=Mn(),n=no();e({global:!0},{Reflect:{}}),n(t.Reflect,"Reflect",!0)})),i0=J(((e,t)=>{var n=Nr(),i=ha(),r=Br()("match");t.exports=function(e){var t;return n(e)&&(void 0!==(t=e[r])?!!t:"RegExp"==i(e))}})),pS=J(((e,t)=>{"use strict";var n=xr();t.exports=function(){var e=n(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t}})),s0=J(((e,t)=>{var n=Sr(),i=$r(),r=ko(),a=pS(),s=RegExp.prototype;t.exports=function(e){var t=e.flags;return void 0!==t||"flags"in s||i(e,"flags")||!r(s,e)?t:n(a,e)}})),lx=J(((e,t)=>{var n=Yt(),i=Mn().RegExp,r=n((function(){var e=i("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),a=r||n((function(){return!i("a","y").sticky})),s=r||n((function(){var e=i("^r","gy");return e.lastIndex=2,null!=e.exec("str")}));t.exports={BROKEN_CARET:s,MISSED_STICKY:a,UNSUPPORTED_Y:r}})),mS=J(((e,t)=>{var n=Yt(),i=Mn().RegExp;t.exports=n((function(){var e=i(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)}))})),XO=J(((e,t)=>{var n=Yt(),i=Mn().RegExp;t.exports=n((function(){var e=i("(?b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$c")}))})),Ste=J((()=>{var e,t,n,i=Kn(),r=Mn(),a=en(),s=Pg(),o=Pp(),l=da(),h=yh().f,c=ko(),u=i0(),d=Mr(),p=s0(),f=lx(),m=pL(),g=Yi(),v=Yt(),y=$r(),x=Ts().enforce,b=Dp(),_=Br(),w=mS(),S=XO(),M=_("match"),E=r.RegExp,T=E.prototype,A=r.SyntaxError,C=a(T.exec),P=a("".charAt),R=a("".replace),O=a("".indexOf),L=a("".slice),I=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,D=/a/g,k=/a/g,N=new E(D)!==D,F=f.MISSED_STICKY,U=f.UNSUPPORTED_Y;if(s("RegExp",i&&(!N||F||w||S||v((function(){return k[M]=!1,E(D)!=D||E(k)==k||"/a/i"!=E(D,"i")}))))){for(e=function(t,n){var i,r,a,s,h,f,m=c(T,this),g=u(t),v=void 0===n,b=[],_=t;if(!m&&g&&v&&t.constructor===e)return t;if((g||c(T,t))&&(t=t.source,v&&(n=p(_))),t=void 0===t?"":d(t),n=void 0===n?"":d(n),_=t,w&&"dotAll"in D&&(r=!!n&&O(n,"s")>-1)&&(n=R(n,/s/g,"")),i=n,F&&"sticky"in D&&(a=!!n&&O(n,"y")>-1)&&U&&(n=R(n,/y/g,"")),S&&(s=function(e){for(var t,n=e.length,i=0,r="",a=[],s={},o=!1,l=!1,h=0,c="";i<=n;i++){if("\\"===(t=P(e,i)))t+=P(e,++i);else if("]"===t)o=!1;else if(!o)switch(!0){case"["===t:o=!0;break;case"("===t:C(I,L(e,i+1))&&(i+=2,l=!0),r+=t,h++;continue;case">"===t&&l:if(""===c||y(s,c))throw new A("Invalid capture group name");s[c]=!0,a[a.length]=[c,h],l=!1,c="";continue}l?c+=t:r+=t}return[r,a]}(t),t=s[0],b=s[1]),h=o(E(t,n),m?this:T,e),(r||a||b.length)&&(f=x(h),r&&(f.dotAll=!0,f.raw=e(function(e){for(var t,n=e.length,i=0,r="",a=!1;i<=n;i++)"\\"!==(t=P(e,i))?a||"."!==t?("["===t?a=!0:"]"===t&&(a=!1),r+=t):r+="[\\s\\S]":r+=t+P(e,++i);return r}(t),i)),a&&(f.sticky=!0),b.length&&(f.groups=b)),t!==_)try{l(h,"source",""===_?"(?:)":_)}catch(e){}return h},t=h(E),n=0;t.length>n;)m(e,E,t[n++]);T.constructor=e,e.prototype=T,g(r,"RegExp",e,{constructor:!0})}b("RegExp")})),Rte=J((()=>{var e=Kn(),t=mS(),n=ha(),i=Hs(),r=Ts().get,a=RegExp.prototype,s=TypeError;e&&t&&i(a,"dotAll",{configurable:!0,get:function(){if(this!==a){if("RegExp"===n(this))return!!r(this).dotAll;throw s("Incompatible receiver, RegExp required")}}})})),ux=J(((e,t)=>{"use strict";var n,i,r=Sr(),a=en(),s=Mr(),o=pS(),l=lx(),h=_p(),c=to(),u=Ts().get,d=mS(),p=XO(),f=h("native-string-replace",String.prototype.replace),m=RegExp.prototype.exec,g=m,v=a("".charAt),y=a("".indexOf),x=a("".replace),b=a("".slice),_=(i=/b*/g,r(m,n=/a/,"a"),r(m,i,"a"),0!==n.lastIndex||0!==i.lastIndex),w=l.BROKEN_CARET,S=void 0!==/()??/.exec("")[1];(_||S||w||d||p)&&(g=function(e){var t,n,i,a,l,h,d,p=this,M=u(p),E=s(e),T=M.raw;if(T)return T.lastIndex=p.lastIndex,t=r(g,T,E),p.lastIndex=T.lastIndex,t;var A=M.groups,C=w&&p.sticky,P=r(o,p),R=p.source,O=0,L=E;if(C&&(P=x(P,"y",""),-1===y(P,"g")&&(P+="g"),L=b(E,p.lastIndex),p.lastIndex>0&&(!p.multiline||p.multiline&&"\n"!==v(E,p.lastIndex-1))&&(R="(?: "+R+")",L=" "+L,O++),n=new RegExp("^(?:"+R+")",P)),S&&(n=new RegExp("^"+R+"$(?!\\s)",P)),_&&(i=p.lastIndex),a=r(m,C?n:p,L),C?a?(a.input=b(a.input,O),a[0]=b(a[0],O),a.index=p.lastIndex,p.lastIndex+=a[0].length):p.lastIndex=0:_&&a&&(p.lastIndex=p.global?a.index+a[0].length:i),S&&a&&a.length>1&&r(f,a[0],n,(function(){for(l=1;l{"use strict";var e=tt(),t=ux();e({target:"RegExp",proto:!0,forced:/./.exec!==t},{exec:t})})),Dte=J((()=>{var e=Mn(),t=Kn(),n=Hs(),i=pS(),r=Yt(),a=e.RegExp,s=a.prototype;t&&r((function(){var e=!0;try{a(".","d")}catch(t){e=!1}var t={},n="",i=e?"dgimsy":"gimsy",r=function(e,i){Object.defineProperty(t,e,{get:function(){return n+=i,!0}})},o={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var l in e&&(o.hasIndices="d"),o)r(l,o[l]);return Object.getOwnPropertyDescriptor(s,"flags").get.call(t)!==i||n!==i}))&&n(s,"flags",{configurable:!0,get:i})})),kte=J((()=>{var e=Kn(),t=lx().MISSED_STICKY,n=ha(),i=Hs(),r=Ts().get,a=RegExp.prototype,s=TypeError;e&&t&&i(a,"sticky",{configurable:!0,get:function(){if(this!==a){if("RegExp"===n(this))return!!r(this).sticky;throw s("Incompatible receiver, RegExp required")}}})})),Bte=J((()=>{"use strict";xS();var e,t,n=tt(),i=Sr(),r=Fr(),a=xr(),s=Mr(),o=(e=!1,(t=/[ac]/).exec=function(){return e=!0,/./.exec.apply(this,arguments)},!0===t.test("abc")&&e),l=/./.test;n({target:"RegExp",proto:!0,forced:!o},{test:function(e){var t=a(this),n=s(e),o=t.exec;if(!r(o))return i(l,t,n);var h=i(o,t,n);return null!==h&&(a(h),!0)}})})),Vte=J((()=>{"use strict";var e=wp().PROPER,t=Yi(),n=xr(),i=Mr(),r=Yt(),a=s0(),s="toString",o=RegExp.prototype[s],l=r((function(){return"/a/b"!=o.call({source:"a",flags:"b"})})),h=e&&o.name!=s;(l||h)&&t(RegExp.prototype,s,(function(){var e=n(this);return"/"+i(e.source)+"/"+i(a(e))}),{unsafe:!0})})),zte=J((()=>{"use strict";W1()("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),DD())})),Gte=J((()=>{zte()})),qte=J((()=>{"use strict";var e=tt(),t=en(),n=_s(),i=as(),r=Mr(),a=Yt(),s=t("".charAt);e({target:"String",proto:!0,forced:a((function(){return"\ud842"!=="\ud842\udfb7".at(-2)}))},{at:function(e){var t=r(n(this)),a=t.length,o=i(e),l=o>=0?o:a+o;return l<0||l>=a?void 0:s(t,l)}})})),hx=J(((e,t)=>{var n=en(),i=as(),r=Mr(),a=_s(),s=n("".charAt),o=n("".charCodeAt),l=n("".slice),h=function(e){return function(t,n){var h,c,u=r(a(t)),d=i(n),p=u.length;return d<0||d>=p?e?"":void 0:(h=o(u,d))<55296||h>56319||d+1===p||(c=o(u,d+1))<56320||c>57343?e?s(u,d):h:e?l(u,d,d+2):c-56320+(h-55296<<10)+65536}};t.exports={codeAt:h(!1),charAt:h(!0)}})),Yte=J((()=>{"use strict";var e=tt(),t=hx().codeAt;e({target:"String",proto:!0},{codePointAt:function(e){return t(this,e)}})})),bS=J(((e,t)=>{var n=i0(),i=TypeError;t.exports=function(e){if(n(e))throw i("The method doesn't accept regular expressions");return e}})),ES=J(((e,t)=>{var n=Br()("match");t.exports=function(e){var t=/./;try{"/./"[e](t)}catch(i){try{return t[n]=!1,"/./"[e](t)}catch(e){}}return!1}})),tne=J((()=>{"use strict";var e,t=tt(),n=xh(),i=Qs().f,r=eo(),a=Mr(),s=bS(),o=_s(),l=ES(),h=ss(),c=n("".endsWith),u=n("".slice),d=Math.min,p=l("endsWith");t({target:"String",proto:!0,forced:!(!h&&!p&&(e=i(String.prototype,"endsWith"),e&&!e.writable))&&!p},{endsWith:function(e){var t=a(o(this));s(e);var n=arguments.length>1?arguments[1]:void 0,i=t.length,l=void 0===n?i:d(r(n),i),h=a(e);return c?c(t,h,l):u(t,l-h.length,l)===h}})})),ine=J((()=>{var e=tt(),t=en(),n=lc(),i=RangeError,r=String.fromCharCode,a=String.fromCodePoint,s=t([].join);e({target:"String",stat:!0,arity:1,forced:!!a&&1!=a.length},{fromCodePoint:function(e){for(var t,a=[],o=arguments.length,l=0;o>l;){if(t=+arguments[l++],n(t,1114111)!==t)throw i(t+" is not a valid code point");a[l]=t<65536?r(t):r(55296+((t-=65536)>>10),t%1024+56320)}return s(a,"")}})})),ane=J((()=>{"use strict";var e=tt(),t=en(),n=bS(),i=_s(),r=Mr(),a=ES(),s=t("".indexOf);e({target:"String",proto:!0,forced:!a("includes")},{includes:function(e){return!!~s(r(i(this)),r(n(e)),arguments.length>1?arguments[1]:void 0)}})})),ik=J((()=>{"use strict";var e=hx().charAt,t=Mr(),n=Ts(),i=Mw(),r=N1(),a="String Iterator",s=n.set,o=n.getterFor(a);i(String,"String",(function(e){s(this,{type:a,string:t(e),index:0})}),(function(){var t,n=o(this),i=n.string,a=n.index;return a>=i.length?r(void 0,!0):(t=e(i,a),n.index+=t.length,r(t,!1))}))})),dx=J(((e,t)=>{"use strict";xS();var n=xh(),i=Yi(),r=ux(),a=Yt(),s=Br(),o=da(),l=s("species"),h=RegExp.prototype;t.exports=function(e,t,c,u){var d=s(e),p=!a((function(){var t={};return t[d]=function(){return 7},7!=""[e](t)})),f=p&&!a((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[l]=function(){return n},n.flags="",n[d]=/./[d]),n.exec=function(){return t=!0,null},n[d](""),!t}));if(!p||!f||c){var m=n(/./[d]),g=t(d,""[e],(function(e,t,i,a,s){var o=n(e),l=t.exec;return l===r||l===h.exec?p&&!s?{done:!0,value:m(t,i,a)}:{done:!0,value:o(i,t,a)}:{done:!1}}));i(String.prototype,e,g[0]),i(h,d,g[1])}u&&o(h[d],"sham",!0)}})),fx=J(((e,t)=>{"use strict";var n=hx().charAt;t.exports=function(e,t,i){return t+(i?n(e,t).length:1)}})),l0=J(((e,t)=>{var n=Sr(),i=xr(),r=Fr(),a=ha(),s=ux(),o=TypeError;t.exports=function(e,t){var l=e.exec;if(r(l)){var h=n(l,e,t);return null!==h&&i(h),h}if("RegExp"===a(e))return n(s,e,t);throw o("RegExp#exec called on incompatible receiver")}})),xne=J((()=>{"use strict";var e=Sr(),t=dx(),n=xr(),i=La(),r=eo(),a=Mr(),s=_s(),o=au(),l=fx(),h=l0();t("match",(function(t,c,u){return[function(n){var r=s(this),l=i(n)?void 0:o(n,t);return l?e(l,n,r):new RegExp(n)[t](a(r))},function(e){var t=n(this),i=a(e),s=u(c,t,i);if(s.done)return s.value;if(!t.global)return h(t,i);var o=t.unicode;t.lastIndex=0;for(var d,p=[],f=0;null!==(d=h(t,i));){var m=a(d[0]);p[f]=m,""===m&&(t.lastIndex=l(i,r(t.lastIndex),o)),f++}return 0===f?null:p}]}))})),Cne=J((()=>{"use strict";var e=tt(),t=Sr(),n=xh(),i=Tw(),r=N1(),a=_s(),s=eo(),o=Mr(),l=xr(),h=La(),c=ha(),u=i0(),d=s0(),p=au(),f=Yi(),m=Yt(),g=Br(),v=kp(),y=fx(),x=l0(),b=Ts(),_=ss(),w=g("matchAll"),S="RegExp String",M=S+" Iterator",E=b.set,T=b.getterFor(M),A=RegExp.prototype,C=TypeError,P=n("".indexOf),R=n("".matchAll),O=!!R&&!m((function(){R("a",/./)})),L=i((function(e,t,n,i){E(this,{type:M,regexp:e,string:t,global:n,unicode:i,done:!1})}),S,(function(){var e=T(this);if(e.done)return r(void 0,!0);var t=e.regexp,n=e.string,i=x(t,n);return null===i?(e.done=!0,r(void 0,!0)):e.global?(""===o(i[0])&&(t.lastIndex=y(n,s(t.lastIndex),e.unicode)),r(i,!1)):(e.done=!0,r(i,!1))})),I=function(e){var t,n,i,r=l(this),a=o(e),h=v(r,RegExp),c=o(d(r));return t=new h(h===RegExp?r.source:r,c),n=!!~P(c,"g"),i=!!~P(c,"u"),t.lastIndex=s(r.lastIndex),new L(t,a,n,i)};e({target:"String",proto:!0,forced:O},{matchAll:function(e){var n,i,r,s,l=a(this);if(h(e)){if(O)return R(l,e)}else{if(u(e)&&(n=o(a(d(e))),!~P(n,"g")))throw C("`.matchAll` does not allow non-global regexes");if(O)return R(l,e);if(void 0===(r=p(e,w))&&_&&"RegExp"==c(e)&&(r=I),r)return t(r,e,l)}return i=o(l),s=new RegExp(e,"g"),_?t(I,s,i):s[w](i)}}),_||w in A||f(A,w,I)})),hk=J(((e,t)=>{var n=iu();t.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(n)})),Ine=J((()=>{"use strict";var e=tt(),t=Ww().end;e({target:"String",proto:!0,forced:hk()},{padEnd:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),Lne=J((()=>{"use strict";var e=tt(),t=Ww().start;e({target:"String",proto:!0,forced:hk()},{padStart:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),Fne=J((()=>{var e=tt(),t=en(),n=Ls(),i=li(),r=Mr(),a=pi(),s=t([].push),o=t([].join);e({target:"String",stat:!0},{raw:function(e){var t=n(i(e).raw),l=a(t);if(!l)return"";for(var h=arguments.length,c=[],u=0;;){if(s(c,r(t[u++])),u===l)return o(c,"");u{tt()({target:"String",proto:!0},{repeat:G1()})})),mk=J(((e,t)=>{var n=en(),i=li(),r=Math.floor,a=n("".charAt),s=n("".replace),o=n("".slice),l=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,h=/\$([$&'`]|\d{1,2})/g;t.exports=function(e,t,n,c,u,d){var p=n+e.length,f=c.length,m=h;return void 0!==u&&(u=i(u),m=l),s(d,m,(function(i,s){var l;switch(a(s,0)){case"$":return"$";case"&":return e;case"`":return o(t,0,n);case"'":return o(t,p);case"<":l=u[o(s,1,-1)];break;default:var h=+s;if(0===h)return i;if(h>f){var d=r(h/10);return 0===d?i:d<=f?void 0===c[d-1]?a(s,1):c[d-1]+a(s,1):i}l=c[h-1]}return void 0===l?"":l}))}})),Gne=J((()=>{"use strict";var e=Fo(),t=Sr(),n=en(),i=dx(),r=Yt(),a=xr(),s=Fr(),o=La(),l=as(),h=eo(),c=Mr(),u=_s(),d=fx(),p=au(),f=mk(),m=l0(),g=Br()("replace"),v=Math.max,y=Math.min,x=n([].concat),b=n([].push),_=n("".indexOf),w=n("".slice),S=function(e){return void 0===e?e:String(e)},M="$0"==="a".replace(/./,"$0"),E=!!/./[g]&&""===/./[g]("a","$0");i("replace",(function(n,i,r){var M=E?"$":"$0";return[function(e,n){var r=u(this),a=o(e)?void 0:p(e,g);return a?t(a,e,r,n):t(i,c(r),e,n)},function(t,n){var o=a(this),u=c(t);if("string"==typeof n&&-1===_(n,M)&&-1===_(n,"$<")){var p=r(i,o,u,n);if(p.done)return p.value}var g=s(n);g||(n=c(n));var E=o.global;if(E){var T=o.unicode;o.lastIndex=0}for(var A=[];;){var C=m(o,u);if(null===C||(b(A,C),!E))break;""===c(C[0])&&(o.lastIndex=d(u,h(o.lastIndex),T))}for(var P="",R=0,O=0;O=R&&(P+=w(u,R,I)+U,R=I+L.length)}return P+w(u,R)}]}),!!r((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$")}))||!M||E)})),Yne=J((()=>{"use strict";var e=tt(),t=Sr(),n=en(),i=_s(),r=Fr(),a=La(),s=i0(),o=Mr(),l=au(),h=s0(),c=mk(),u=Br(),d=ss(),p=u("replace"),f=TypeError,m=n("".indexOf),g=n("".replace),v=n("".slice),y=Math.max,x=function(e,t,n){return n>e.length?-1:""===t?n:m(e,t,n)};e({target:"String",proto:!0},{replaceAll:function(e,n){var u,b,_,w,S,M,E,T,A,C=i(this),P=0,R=0,O="";if(!a(e)){if((u=s(e))&&(b=o(i(h(e))),!~m(b,"g")))throw f("`.replaceAll` does not allow non-global regexes");if(_=l(e,p))return t(_,e,C,n);if(d&&u)return g(o(C),e,n)}for(w=o(C),S=o(e),(M=r(n))||(n=o(n)),E=S.length,T=y(1,E),P=x(w,S,0);-1!==P;)A=M?o(n(S,P,w)):c(S,w,P,[],void 0,n),O+=v(w,R,P)+A,R=P+E,P=x(w,S,P+T);return R{"use strict";var e=Sr(),t=dx(),n=xr(),i=La(),r=_s(),a=rO(),s=Mr(),o=au(),l=l0();t("search",(function(t,h,c){return[function(n){var a=r(this),l=i(n)?void 0:o(n,t);return l?e(l,n,a):new RegExp(n)[t](s(a))},function(e){var t=n(this),i=s(e),r=c(h,t,i);if(r.done)return r.value;var o=t.lastIndex;a(o,0)||(t.lastIndex=0);var u=l(t,i);return a(t.lastIndex,o)||(t.lastIndex=o),null===u?-1:u.index}]}))})),rre=J((()=>{"use strict";var e=Fo(),t=Sr(),n=en(),i=dx(),r=xr(),a=La(),s=i0(),o=_s(),l=kp(),h=fx(),c=eo(),u=Mr(),d=au(),p=Lg(),f=l0(),m=ux(),g=lx(),v=Yt(),y=g.UNSUPPORTED_Y,x=4294967295,b=Math.min,_=[].push,w=n(/./.exec),S=n(_),M=n("".slice);i("split",(function(n,i,g){var v;return v="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(n,r){var a=u(o(this)),l=void 0===r?x:r>>>0;if(0===l)return[];if(void 0===n)return[a];if(!s(n))return t(i,a,n,l);for(var h,c,d,f=[],g=(n.ignoreCase?"i":"")+(n.multiline?"m":"")+(n.unicode?"u":"")+(n.sticky?"y":""),v=0,y=new RegExp(n.source,g+"g");(h=t(m,y,a))&&!((c=y.lastIndex)>v&&(S(f,M(a,v,h.index)),h.length>1&&h.index=l));)y.lastIndex===h.index&&y.lastIndex++;return v===a.length?(d||!w(y,""))&&S(f,""):S(f,M(a,v)),f.length>l?p(f,0,l):f}:"0".split(void 0,0).length?function(e,n){return void 0===e&&0===n?[]:t(i,this,e,n)}:i,[function(e,i){var r=o(this),s=a(e)?void 0:d(e,n);return s?t(s,e,r,i):t(v,u(r),e,i)},function(e,t){var n=r(this),a=u(e),s=g(v,n,a,t,v!==i);if(s.done)return s.value;var o=l(n,RegExp),d=n.unicode,p=(n.ignoreCase?"i":"")+(n.multiline?"m":"")+(n.unicode?"u":"")+(y?"g":"y"),m=new o(y?"^(?:"+n.source+")":n,p),_=void 0===t?x:t>>>0;if(0===_)return[];if(0===a.length)return null===f(m,a)?[a]:[];for(var w=0,E=0,T=[];E{"use strict";var e,t=tt(),n=xh(),i=Qs().f,r=eo(),a=Mr(),s=bS(),o=_s(),l=ES(),h=ss(),c=n("".startsWith),u=n("".slice),d=Math.min,p=l("startsWith");t({target:"String",proto:!0,forced:!(!h&&!p&&(e=i(String.prototype,"startsWith"),e&&!e.writable))&&!p},{startsWith:function(e){var t=a(o(this));s(e);var n=r(d(arguments.length>1?arguments[1]:void 0,t.length)),i=a(e);return c?c(t,i,n):u(t,n,n+i.length)===i}})})),ure=J((()=>{"use strict";var e=tt(),t=en(),n=_s(),i=as(),r=Mr(),a=t("".slice),s=Math.max,o=Math.min;e({target:"String",proto:!0,forced:!"".substr||"b"!=="ab".substr(-1)},{substr:function(e,t){var l,h,c=r(n(this)),u=c.length,d=i(e);return d===1/0&&(d=0),d<0&&(d=s(u+d,0)),(l=void 0===t?u:i(t))<=0||l===1/0||d>=(h=o(d+l,u))?"":a(c,d,h)}})})),MS=J(((e,t)=>{var n=wp().PROPER,i=Yt(),r=Z1();t.exports=function(e){return i((function(){return!!r[e]()||"\u200b\x85\u180e"!=="\u200b\x85\u180e"[e]()||n&&r[e].name!==e}))}})),pre=J((()=>{"use strict";var e=tt(),t=Bp().trim;e({target:"String",proto:!0,forced:MS()("trim")},{trim:function(){return t(this)}})})),Ek=J(((e,t)=>{"use strict";var n=Bp().end,i=MS();t.exports=i("trimEnd")?function(){return n(this)}:"".trimEnd})),vre=J((()=>{var e=tt(),t=Ek();e({target:"String",proto:!0,name:"trimEnd",forced:"".trimRight!==t},{trimRight:t})})),xre=J((()=>{vre();var e=tt(),t=Ek();e({target:"String",proto:!0,name:"trimEnd",forced:"".trimEnd!==t},{trimEnd:t})})),_k=J(((e,t)=>{"use strict";var n=Bp().start,i=MS();t.exports=i("trimStart")?function(){return n(this)}:"".trimStart})),_re=J((()=>{var e=tt(),t=_k();e({target:"String",proto:!0,name:"trimStart",forced:"".trimLeft!==t},{trimLeft:t})})),wre=J((()=>{_re();var e=tt(),t=_k();e({target:"String",proto:!0,name:"trimStart",forced:"".trimStart!==t},{trimStart:t})})),so=J(((e,t)=>{var n=en(),i=_s(),r=Mr(),a=/"/g,s=n("".replace);t.exports=function(e,t,n,o){var l=r(i(e)),h="<"+t;return""!==n&&(h+=" "+n+'="'+s(r(o),a,""")+'"'),h+">"+l+""}})),ao=J(((e,t)=>{var n=Yt();t.exports=function(e){return n((function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3}))}})),Are=J((()=>{"use strict";var e=tt(),t=so();e({target:"String",proto:!0,forced:ao()("anchor")},{anchor:function(e){return t(this,"a","name",e)}})})),Cre=J((()=>{"use strict";var e=tt(),t=so();e({target:"String",proto:!0,forced:ao()("big")},{big:function(){return t(this,"big","","")}})})),Pre=J((()=>{"use strict";var e=tt(),t=so();e({target:"String",proto:!0,forced:ao()("blink")},{blink:function(){return t(this,"blink","","")}})})),Ire=J((()=>{"use strict";var e=tt(),t=so();e({target:"String",proto:!0,forced:ao()("bold")},{bold:function(){return t(this,"b","","")}})})),Lre=J((()=>{"use strict";var e=tt(),t=so();e({target:"String",proto:!0,forced:ao()("fixed")},{fixed:function(){return t(this,"tt","","")}})})),Dre=J((()=>{"use strict";var e=tt(),t=so();e({target:"String",proto:!0,forced:ao()("fontcolor")},{fontcolor:function(e){return t(this,"font","color",e)}})})),Ore=J((()=>{"use strict";var e=tt(),t=so();e({target:"String",proto:!0,forced:ao()("fontsize")},{fontsize:function(e){return t(this,"font","size",e)}})})),kre=J((()=>{"use strict";var e=tt(),t=so();e({target:"String",proto:!0,forced:ao()("italics")},{italics:function(){return t(this,"i","","")}})})),Fre=J((()=>{"use strict";var e=tt(),t=so();e({target:"String",proto:!0,forced:ao()("link")},{link:function(e){return t(this,"a","href",e)}})})),Nre=J((()=>{"use strict";var e=tt(),t=so();e({target:"String",proto:!0,forced:ao()("small")},{small:function(){return t(this,"small","","")}})})),Bre=J((()=>{"use strict";var e=tt(),t=so();e({target:"String",proto:!0,forced:ao()("strike")},{strike:function(){return t(this,"strike","","")}})})),Ure=J((()=>{"use strict";var e=tt(),t=so();e({target:"String",proto:!0,forced:ao()("sub")},{sub:function(){return t(this,"sub","","")}})})),Hre=J((()=>{"use strict";var e=tt(),t=so();e({target:"String",proto:!0,forced:ao()("sup")},{sup:function(){return t(this,"sup","","")}})})),RS=J(((e,t)=>{var n=Mn(),i=Yt(),r=O1(),a=Pr().NATIVE_ARRAY_BUFFER_VIEWS,s=n.ArrayBuffer,o=n.Int8Array;t.exports=!a||!i((function(){o(1)}))||!i((function(){new o(-1)}))||!r((function(e){new o,new o(null),new o(1.5),new o(e)}),!0)||i((function(){return 1!==new o(new s(2),1,void 0).length}))})),qre=J(((e,t)=>{var n=as(),i=RangeError;t.exports=function(e){var t=n(e);if(t<0)throw i("The argument can't be less than 0");return t}})),wk=J(((e,t)=>{var n=qre(),i=RangeError;t.exports=function(e,t){var r=n(e);if(r%t)throw i("Wrong offset");return r}})),Sk=J(((e,t)=>{var n=cc();t.exports=function(e){var t=n(e);return"BigInt64Array"==t||"BigUint64Array"==t}})),AS=J(((e,t)=>{var n=v1(),i=TypeError;t.exports=function(e){var t=n(e,"number");if("number"==typeof t)throw i("Can't convert number to bigint");return BigInt(t)}})),Mk=J(((e,t)=>{var n=fl(),i=Sr(),r=qw(),a=li(),s=pi(),o=I1(),l=Bg(),h=yw(),c=Sk(),u=Pr().aTypedArrayConstructor,d=AS();t.exports=function(e){var t,p,f,m,g,v,y,x,b=r(this),_=a(e),w=arguments.length,S=w>1?arguments[1]:void 0,M=void 0!==S,E=l(_);if(E&&!h(E))for(x=(y=o(_,E)).next,_=[];!(v=i(x,y)).done;)_.push(v.value);for(M&&w>2&&(S=n(S,arguments[2])),p=s(_),f=new(u(b))(p),m=c(f),t=0;p>t;t++)g=M?S(_[t],t):_[t],f[t]=m?d(g):+g;return f}})),mu=J(((e,t)=>{"use strict";var n=tt(),i=Mn(),r=Sr(),a=Kn(),s=RS(),o=Pr(),l=z1(),h=dc(),c=Oo(),u=da(),d=tS(),p=eo(),f=tD(),m=wk(),g=vh(),v=$r(),y=cc(),x=Nr(),b=Dd(),_=to(),w=ko(),S=uc(),M=yh().f,E=Mk(),T=Vs().forEach,A=Dp(),C=Hs(),P=Gi(),R=Qs(),O=Ts(),L=Pp(),I=O.get,D=O.set,k=O.enforce,N=P.f,F=R.f,U=Math.round,B=i.RangeError,z=l.ArrayBuffer,H=z.prototype,V=l.DataView,j=o.NATIVE_ARRAY_BUFFER_VIEWS,G=o.TYPED_ARRAY_TAG,W=o.TypedArray,X=o.TypedArrayPrototype,Y=o.aTypedArrayConstructor,q=o.isTypedArray,J="BYTES_PER_ELEMENT",Z="Wrong length",K=function(e,t){Y(e);for(var n=0,i=t.length,r=new e(i);i>n;)r[n]=t[n++];return r},$=function(e,t){C(e,t,{configurable:!0,get:function(){return I(this)[t]}})},Q=function(e){var t;return w(H,e)||"ArrayBuffer"==(t=y(e))||"SharedArrayBuffer"==t},ee=function(e,t){return q(e)&&!b(t)&&t in e&&d(+t)&&t>=0},te=function(e,t){return t=g(t),ee(e,t)?c(2,e[t]):F(e,t)},ne=function(e,t,n){return t=g(t),!(ee(e,t)&&x(n)&&v(n,"value"))||v(n,"get")||v(n,"set")||n.configurable||v(n,"writable")&&!n.writable||v(n,"enumerable")&&!n.enumerable?N(e,t,n):(e[t]=n.value,e)};a?(j||(R.f=te,P.f=ne,$(X,"buffer"),$(X,"byteOffset"),$(X,"byteLength"),$(X,"length")),n({target:"Object",stat:!0,forced:!j},{getOwnPropertyDescriptor:te,defineProperty:ne}),t.exports=function(e,t,a){var o=e.match(/\d+/)[0]/8,l=e+(a?"Clamped":"")+"Array",c="get"+e,d="set"+e,g=i[l],v=g,y=v&&v.prototype,b={},w=function(e,t){N(e,t,{get:function(){return function(e,t){var n=I(e);return n.view[c](t*o+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,n){var i=I(e);a&&(n=(n=U(n))<0?0:n>255?255:255&n),i.view[d](t*o+i.byteOffset,n,!0)}(this,t,e)},enumerable:!0})};j?s&&(v=t((function(e,t,n,i){return h(e,y),L(x(t)?Q(t)?void 0!==i?new g(t,m(n,o),i):void 0!==n?new g(t,m(n,o)):new g(t):q(t)?K(v,t):r(E,v,t):new g(f(t)),e,v)})),S&&S(v,W),T(M(g),(function(e){e in v||u(v,e,g[e])})),v.prototype=y):(v=t((function(e,t,n,i){h(e,y);var a,s,l,c=0,u=0;if(x(t)){if(!Q(t))return q(t)?K(v,t):r(E,v,t);a=t,u=m(n,o);var d=t.byteLength;if(void 0===i){if(d%o||(s=d-u)<0)throw B(Z)}else if((s=p(i)*o)+u>d)throw B(Z);l=s/o}else l=f(t),a=new z(s=l*o);for(D(e,{buffer:a,byteOffset:u,byteLength:s,length:l,view:new V(a)});c{mu()("Float32",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),mie=J((()=>{mu()("Float64",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),gie=J((()=>{mu()("Int8",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),vie=J((()=>{mu()("Int16",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),yie=J((()=>{mu()("Int32",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),xie=J((()=>{mu()("Uint8",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),bie=J((()=>{mu()("Uint8",(function(e){return function(t,n,i){return e(this,t,n,i)}}),!0)})),Eie=J((()=>{mu()("Uint16",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),_ie=J((()=>{mu()("Uint32",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),wie=J((()=>{"use strict";var e=Pr(),t=pi(),n=as(),i=e.aTypedArray;(0,e.exportTypedArrayMethod)("at",(function(e){var r=i(this),a=t(r),s=n(e),o=s>=0?s:a+s;return o<0||o>=a?void 0:r[o]}))})),Mie=J((()=>{"use strict";var e=en(),t=Pr(),n=e(IL()),i=t.aTypedArray;(0,t.exportTypedArrayMethod)("copyWithin",(function(e,t){return n(i(this),e,t,arguments.length>2?arguments[2]:void 0)}))})),Aie=J((()=>{"use strict";var e=Pr(),t=Vs().every,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("every",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),Pie=J((()=>{"use strict";var e=Pr(),t=_w(),n=AS(),i=cc(),r=Sr(),a=en(),s=Yt(),o=e.aTypedArray,l=e.exportTypedArrayMethod,h=a("".slice);l("fill",(function(e){var a=arguments.length;o(this);var s="Big"===h(i(this),0,3)?n(e):+e;return r(t,this,s,a>1?arguments[1]:void 0,a>2?arguments[2]:void 0)}),s((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e})))})),bx=J(((e,t)=>{var n=Pr(),i=kp(),r=n.aTypedArrayConstructor,a=n.getTypedArrayConstructor;t.exports=function(e){return r(i(e,a(e)))}})),Oie=J(((e,t)=>{var n=Iw(),i=bx();t.exports=function(e,t){return n(i(e),t)}})),Fie=J((()=>{"use strict";var e=Pr(),t=Vs().filter,n=Oie(),i=e.aTypedArray;(0,e.exportTypedArrayMethod)("filter",(function(e){var r=t(i(this),e,arguments.length>1?arguments[1]:void 0);return n(this,r)}))})),Bie=J((()=>{"use strict";var e=Pr(),t=Vs().find,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("find",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),Hie=J((()=>{"use strict";var e=Pr(),t=Vs().findIndex,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("findIndex",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),zie=J((()=>{"use strict";var e=Pr(),t=D1().findLast,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLast",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),qie=J((()=>{"use strict";var e=Pr(),t=D1().findLastIndex,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLastIndex",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),jie=J((()=>{"use strict";var e=Pr(),t=Vs().forEach,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("forEach",(function(e){t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),Xie=J((()=>{"use strict";var e=RS();(0,Pr().exportTypedArrayStaticMethod)("from",Mk(),e)})),$ie=J((()=>{"use strict";var e=Pr(),t=Cg().includes,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("includes",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),Kie=J((()=>{"use strict";var e=Pr(),t=Cg().indexOf,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("indexOf",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),nse=J((()=>{"use strict";var e=Mn(),t=Yt(),n=en(),i=Pr(),r=B1(),a=Br()("iterator"),s=e.Uint8Array,o=n(r.values),l=n(r.keys),h=n(r.entries),c=i.aTypedArray,u=i.exportTypedArrayMethod,d=s&&s.prototype,p=!t((function(){d[a].call([1])})),f=!!d&&d.values&&d[a]===d.values&&"values"===d.values.name,m=function(){return o(c(this))};u("entries",(function(){return h(c(this))}),p),u("keys",(function(){return l(c(this))}),p),u("values",m,p||!f,{name:"values"}),u(a,m,p||!f,{name:"values"})})),ise=J((()=>{"use strict";var e=Pr(),t=en(),n=e.aTypedArray,i=e.exportTypedArrayMethod,r=t([].join);i("join",(function(e){return r(n(this),e)}))})),ase=J((()=>{"use strict";var e=Pr(),t=Fo(),n=jL(),i=e.aTypedArray;(0,e.exportTypedArrayMethod)("lastIndexOf",(function(e){var r=arguments.length;return t(n,i(this),r>1?[e,arguments[1]]:[e])}))})),lse=J((()=>{"use strict";var e=Pr(),t=Vs().map,n=bx(),i=e.aTypedArray;(0,e.exportTypedArrayMethod)("map",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(n(e))(t)}))}))})),use=J((()=>{"use strict";var e=Pr(),t=RS(),n=e.aTypedArrayConstructor;(0,e.exportTypedArrayStaticMethod)("of",(function(){for(var e=0,t=arguments.length,i=new(n(this))(t);t>e;)i[e]=arguments[e++];return i}),t)})),dse=J((()=>{"use strict";var e=Pr(),t=U1().left,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("reduce",(function(e){var i=arguments.length;return t(n(this),e,i,i>1?arguments[1]:void 0)}))})),pse=J((()=>{"use strict";var e=Pr(),t=U1().right,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("reduceRight",(function(e){var i=arguments.length;return t(n(this),e,i,i>1?arguments[1]:void 0)}))})),gse=J((()=>{"use strict";var e=Pr(),t=e.aTypedArray,n=e.exportTypedArrayMethod,i=Math.floor;n("reverse",(function(){for(var e,n=this,r=t(n).length,a=i(r/2),s=0;s{"use strict";var e=Mn(),t=Sr(),n=Pr(),i=pi(),r=wk(),a=li(),s=Yt(),o=e.RangeError,l=e.Int8Array,h=l&&l.prototype,c=h&&h.set,u=n.aTypedArray,d=n.exportTypedArrayMethod,p=!s((function(){var e=new Uint8ClampedArray(2);return t(c,e,{length:1,0:3},1),3!==e[1]})),f=p&&n.NATIVE_ARRAY_BUFFER_VIEWS&&s((function(){var e=new l(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));d("set",(function(e){u(this);var n=r(arguments.length>1?arguments[1]:void 0,1),s=a(e);if(p)return t(c,this,s,n);var l=this.length,h=i(s),d=0;if(h+n>l)throw o("Wrong length");for(;d{"use strict";var e=Pr(),t=bx(),n=Yt(),i=Fd(),r=e.aTypedArray;(0,e.exportTypedArrayMethod)("slice",(function(e,n){for(var a=i(r(this),e,n),s=t(this),o=0,l=a.length,h=new s(l);l>o;)h[o]=a[o++];return h}),n((function(){new Int8Array(1).slice()})))})),Mse=J((()=>{"use strict";var e=Pr(),t=Vs().some,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("some",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),Lse=J((()=>{"use strict";var e=Mn(),t=xh(),n=Yt(),i=is(),r=Cw(),a=Pr(),s=$L(),o=ZL(),l=su(),h=Pw(),c=a.aTypedArray,u=a.exportTypedArrayMethod,d=e.Uint16Array,p=d&&t(d.prototype.sort),f=!(!p||n((function(){p(new d(2),null)}))&&n((function(){p(new d(2),{})}))),m=!!p&&!n((function(){if(l)return l<74;if(s)return s<67;if(o)return!0;if(h)return h<602;var e,t,n=new d(516),i=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,i[e]=e-2*t+3;for(p(n,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(n[e]!==i[e])return!0}));u("sort",(function(e){return void 0!==e&&i(e),m?p(this,e):r(c(this),(t=e,function(e,n){return void 0!==t?+t(e,n)||0:n!=n?-1:e!=e?1:0===e&&0===n?1/e>0&&1/n<0?1:-1:e>n}));var t}),!m||f)})),kse=J((()=>{"use strict";var e=Pr(),t=eo(),n=lc(),i=bx(),r=e.aTypedArray;(0,e.exportTypedArrayMethod)("subarray",(function(e,a){var s=r(this),o=s.length,l=n(e,o);return new(i(s))(s.buffer,s.byteOffset+l*s.BYTES_PER_ELEMENT,t((void 0===a?o:n(a,o))-l))}))})),Hse=J((()=>{"use strict";var e=Mn(),t=Fo(),n=Pr(),i=Yt(),r=Fd(),a=e.Int8Array,s=n.aTypedArray,o=n.exportTypedArrayMethod,l=[].toLocaleString,h=!!a&&i((function(){l.call(new a(1))}));o("toLocaleString",(function(){return t(l,h?r(s(this)):s(this),r(arguments))}),i((function(){return[1,2].toLocaleString()!=new a([1,2]).toLocaleString()}))||!i((function(){a.prototype.toLocaleString.call([1,2])})))})),Vse=J((()=>{"use strict";var e=QL(),t=Pr(),n=t.aTypedArray,i=t.exportTypedArrayMethod,r=t.getTypedArrayConstructor;i("toReversed",(function(){return e(n(this),r(this))}))})),zse=J((()=>{"use strict";var e=Pr(),t=en(),n=is(),i=Iw(),r=e.aTypedArray,a=e.getTypedArrayConstructor,s=e.exportTypedArrayMethod,o=t(e.TypedArrayPrototype.sort);s("toSorted",(function(e){void 0!==e&&n(e);var t=r(this),s=i(a(t),t);return o(s,e)}))})),qse=J((()=>{"use strict";var e=Pr().exportTypedArrayMethod,t=Yt(),n=Mn(),i=en(),r=n.Uint8Array,a=r&&r.prototype||{},s=[].toString,o=i([].join);t((function(){s.call({})}))&&(s=function(){return o(this)});var l=a.toString!=s;e("toString",s,l)})),Wse=J((()=>{"use strict";var e=eD(),t=Pr(),n=Sk(),i=as(),r=AS(),a=t.aTypedArray,s=t.getTypedArrayConstructor;(0,t.exportTypedArrayMethod)("with",(function(t,o){var l=a(this),h=i(t),c=n(l)?r(o):+o;return e(l,s(l),h,c)}),!function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(e){return 8===e}}())})),Zse=J((()=>{"use strict";var e=tt(),t=en(),n=Mr(),i=String.fromCharCode,r=t("".charAt),a=t(/./.exec),s=t("".slice),o=/^[\da-f]{2}$/i,l=/^[\da-f]{4}$/i;e({global:!0},{unescape:function(e){for(var t,h,c=n(e),u="",d=c.length,p=0;p{"use strict";var n=en(),i=Vg(),r=qd().getWeakData,a=dc(),s=xr(),o=La(),l=Nr(),h=hc(),c=Vs(),u=$r(),d=Ts(),p=d.set,f=d.getterFor,m=c.find,g=c.findIndex,v=n([].splice),y=0,x=function(e){return e.frozen||(e.frozen=new b)},b=function(){this.entries=[]},_=function(e,t){return m(e.entries,(function(e){return e[0]===t}))};b.prototype={get:function(e){var t=_(this,e);if(t)return t[1]},has:function(e){return!!_(this,e)},set:function(e,t){var n=_(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=g(this.entries,(function(t){return t[0]===e}));return~t&&v(this.entries,t,1),!!~t}},t.exports={getConstructor:function(e,t,n,c){var d=e((function(e,i){a(e,m),p(e,{type:t,id:y++,frozen:void 0}),o(i)||h(i,e[c],{that:e,AS_ENTRIES:n})})),m=d.prototype,g=f(t),v=function(e,t,n){var i=g(e),a=r(s(t),!0);return!0===a?x(i).set(t,n):a[i.id]=n,e};return i(m,{delete:function(e){var t=g(this);if(!l(e))return!1;var n=r(e);return!0===n?x(t).delete(e):n&&u(n,t.id)&&delete n[t.id]},has:function(e){var t=g(this);if(!l(e))return!1;var n=r(e);return!0===n?x(t).has(e):n&&u(n,t.id)}}),i(m,n?{get:function(e){var t=g(this);if(l(e)){var n=r(e);return!0===n?x(t).get(e):n?n[t.id]:void 0}},set:function(e,t){return v(this,e,t)}}:{add:function(e){return v(this,e,!0)}}),d}}})),dae=J((()=>{"use strict";var e,t,n,i,r=Np(),a=Mn(),s=en(),o=Vg(),l=qd(),h=W1(),c=$k(),u=Nr(),d=Ts().enforce,p=Yt(),f=D3(),m=Object,g=Array.isArray,v=m.isExtensible,y=m.isFrozen,x=m.isSealed,b=m.freeze,_=m.seal,w={},S={},M=!a.ActiveXObject&&"ActiveXObject"in a,E=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},T=h("WeakMap",E,c),A=T.prototype,C=s(A.set);f&&(M?(e=c.getConstructor(E,"WeakMap",!0),l.enable(),t=s(A.delete),n=s(A.has),i=s(A.get),o(A,{delete:function(n){if(u(n)&&!v(n)){var i=d(this);return i.frozen||(i.frozen=new e),t(this,n)||i.frozen.delete(n)}return t(this,n)},has:function(t){if(u(t)&&!v(t)){var i=d(this);return i.frozen||(i.frozen=new e),n(this,t)||i.frozen.has(t)}return n(this,t)},get:function(t){if(u(t)&&!v(t)){var r=d(this);return r.frozen||(r.frozen=new e),n(this,t)?i(this,t):r.frozen.get(t)}return i(this,t)},set:function(t,i){if(u(t)&&!v(t)){var r=d(this);r.frozen||(r.frozen=new e),n(this,t)?C(this,t,i):r.frozen.set(t,i)}else C(this,t,i);return this}})):r&&p((function(){var e=b([]);return C(new T,e,1),!y(e)}))&&o(A,{set:function(e,t){var n;return g(e)&&(y(e)?n=w:x(e)&&(n=S)),C(this,e,t),n==w&&b(e),n==S&&_(e),this}}))})),fae=J((()=>{dae()})),pae=J((()=>{"use strict";W1()("WeakSet",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),$k())})),mae=J((()=>{pae()})),Jk=J(((e,t)=>{var n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r={};for(n=0;n<66;n++)r[i.charAt(n)]=n;t.exports={itoc:i,ctoi:r}})),wae=J((()=>{var e=tt(),t=Mn(),n=ki(),i=en(),r=Sr(),a=Yt(),s=Mr(),o=$r(),l=pu(),h=Jk().ctoi,c=/[^\d+/a-z]/i,u=/[\t\n\f\r ]+/g,d=/[=]{1,2}$/,p=n("atob"),f=String.fromCharCode,m=i("".charAt),g=i("".replace),v=i(c.exec),y=a((function(){return""!==p(" ")})),x=!a((function(){p("a")})),b=!y&&!x&&!a((function(){p()})),_=!y&&!x&&1!==p.length;e({global:!0,bind:!0,enumerable:!0,forced:y||x||b||_},{atob:function(e){if(l(arguments.length,1),b||_)return r(p,t,e);var i,a,y=g(s(e),u,""),x="",w=0,S=0;if(y.length%4==0&&(y=g(y,d,"")),y.length%4==1||v(c,y))throw new(n("DOMException"))("The string is not correctly encoded","InvalidCharacterError");for(;i=m(y,w++);)o(h,i)&&(a=S%4?64*a+h[i]:h[i],S++%4&&(x+=f(255&a>>(-2*S&6))));return x}})})),Dae=J((()=>{var e=tt(),t=Mn(),n=ki(),i=en(),r=Sr(),a=Yt(),s=Mr(),o=pu(),l=Jk().itoc,h=n("btoa"),c=i("".charAt),u=i("".charCodeAt),d=!!h&&!a((function(){h()})),p=!!h&&a((function(){return"bnVsbA=="!==h(null)})),f=!!h&&1!==h.length;e({global:!0,bind:!0,enumerable:!0,forced:d||p||f},{btoa:function(e){if(o(arguments.length,1),d||p||f)return r(h,t,s(e));for(var i,a,m=s(e),g="",v=0,y=l;c(m,v)||(y="=",v%1);){if((a=u(m,v+=3/4))>255)throw new(n("DOMException"))("The string contains characters outside of the Latin1 range","InvalidCharacterError");g+=c(y,63&(i=i<<8|a)>>8-v%1*8)}return g}})})),iF=J(((e,t)=>{t.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}})),aF=J(((e,t)=>{var n=y1()("span").classList,i=n&&n.constructor&&n.constructor.prototype;t.exports=i===Object.prototype?void 0:i})),Hae=J((()=>{var e,t=Mn(),n=iF(),i=aF(),r=kL(),a=da(),s=function(e){if(e&&e.forEach!==r)try{a(e,"forEach",r)}catch(t){e.forEach=r}};for(e in n)n[e]&&s(t[e]&&t[e].prototype);s(i)})),jae=J((()=>{var e,t=Mn(),n=iF(),i=aF(),r=B1(),a=da(),s=Br(),o=s("iterator"),l=s("toStringTag"),h=r.values,c=function(e,t){if(e){if(e[o]!==h)try{a(e,o,h)}catch(t){e[o]=h}if(e[l]||a(e,l,t),n[t])for(var i in r)if(e[i]!==r[i])try{a(e,i,r[i])}catch(t){e[i]=r[i]}}};for(e in n)c(t[e]&&t[e].prototype,e);c(i,"DOMTokenList")})),Yae=J(((e,t)=>{var n=uu();t.exports=function(e){try{if(n)return Function('return require("'+e+'")')()}catch(e){}}})),hF=J(((e,t)=>{t.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}})),aoe=J((()=>{"use strict";var e=tt(),t=Yae(),n=ki(),i=Yt(),r=to(),a=Oo(),s=Gi().f,o=Yi(),l=Hs(),h=$r(),c=dc(),u=xr(),d=EL(),p=Fg(),f=hF(),m=pw(),g=Ts(),v=Kn(),y=ss(),x="DOMException",b="DATA_CLONE_ERR",_=n("Error"),w=n(x)||function(){try{(new(n("MessageChannel")||t("worker_threads").MessageChannel)).port1.postMessage(new WeakMap)}catch(e){if(e.name==b&&25==e.code)return e.constructor}}(),S=w&&w.prototype,M=_.prototype,E=g.set,T=g.getterFor(x),A="stack"in _(x),C=function(e){return h(f,e)&&f[e].m?f[e].c:0},P=function(){c(this,R);var e=arguments.length,t=p(e<1?void 0:arguments[0]),n=p(e<2?void 0:arguments[1],"Error"),i=C(n);if(E(this,{type:x,name:n,message:t,code:i}),v||(this.name=n,this.message=t,this.code=i),A){var r=_(t);r.name=x,s(this,"stack",a(1,m(r.stack,1)))}},R=P.prototype=r(M),O=function(e){return{enumerable:!0,configurable:!0,get:e}},L=function(e){return O((function(){return T(this)[e]}))};v&&(l(R,"code",L("code")),l(R,"message",L("message")),l(R,"name",L("name"))),s(R,"constructor",a(1,P));var I=i((function(){return!(new w instanceof _)})),D=I||i((function(){return M.toString!==d||"2: 1"!==String(new w(1,2))})),k=I||i((function(){return 25!==new w(1,"DataCloneError").code})),N=I||25!==w[b]||25!==S[b],F=y?D||k||N:I;e({global:!0,constructor:!0,forced:F},{DOMException:F?P:w});var U,B,z,H,V=n(x),j=V.prototype;for(H in D&&(y||w===V)&&o(j,"toString",d),k&&v&&w===V&&l(j,"code",O((function(){return C(u(this).name)}))),f)h(f,H)&&(B=(U=f[H]).s,z=a(6,U.c),h(V,B)||s(V,B,z),h(j,B)||s(j,B,z))})),foe=J((()=>{"use strict";var e=tt(),t=Mn(),n=ki(),i=Oo(),r=Gi().f,a=$r(),s=dc(),o=Pp(),l=Fg(),h=hF(),c=pw(),u=Kn(),d=ss(),p="DOMException",f=n("Error"),m=n(p),g=function(){s(this,v);var e=arguments.length,t=l(e<1?void 0:arguments[0]),n=l(e<2?void 0:arguments[1],"Error"),a=new m(t,n),h=f(t);return h.name=p,r(a,"stack",i(1,c(h.stack,1))),o(a,this,g),a},v=g.prototype=m.prototype,y="stack"in f(p),x="stack"in new m(1,2),b=m&&u&&Object.getOwnPropertyDescriptor(t,p),_=!(!b||b.writable&&b.configurable),w=y&&!_&&!x;e({global:!0,constructor:!0,forced:d||w},{DOMException:w?g:m});var S,M,E,T=n(p),A=T.prototype;if(A.constructor!==T)for(E in d||r(A,"constructor",i(1,T)),h)a(h,E)&&(a(T,M=(S=h[E]).s)||r(T,M,i(6,S.c)))})),moe=J((()=>{var e=ki(),t="DOMException";no()(e(t),t)})),voe=J((()=>{var e=tt(),t=Mn(),n=rx().clear;e({global:!0,bind:!0,enumerable:!0,forced:t.clearImmediate!==n},{clearImmediate:n})})),xoe=J(((e,t)=>{t.exports="function"==typeof Bun&&Bun&&"string"==typeof Bun.version})),eM=J(((e,t)=>{"use strict";var n,i=Mn(),r=Fo(),a=Fr(),s=xoe(),o=iu(),l=Fd(),h=pu(),c=i.Function,u=/MSIE .\./.test(o)||s&&((n=i.Bun.version.split(".")).length<3||0==n[0]&&(n[1]<3||3==n[1]&&0==n[2]));t.exports=function(e,t){var n=t?2:1;return u?function(i,s){var o=h(arguments.length,1)>n,u=a(i)?i:c(i),d=o?l(arguments,n):[],p=o?function(){r(u,this,d)}:u;return t?e(p,s):e(p)}:e}})),Soe=J((()=>{var e=tt(),t=Mn(),n=rx().set,i=eM(),r=t.setImmediate?i(n,!1):n;e({global:!0,bind:!0,enumerable:!0,forced:t.setImmediate!==r},{setImmediate:r})})),Moe=J((()=>{voe(),Soe()})),Roe=J((()=>{var e=tt(),t=Mn(),n=TO(),i=is(),r=pu(),a=uu(),s=t.process;e({global:!0,enumerable:!0,dontCallGetSet:!0},{queueMicrotask:function(e){r(arguments.length,1),i(e);var t=a&&s.domain;n(t?t.bind(e):e)}})})),Coe=J((()=>{"use strict";var e,t=tt(),n=Mn(),i=Hs(),r=Kn(),a=TypeError,s=Object.defineProperty,o=n.self!==n;try{r?(e=Object.getOwnPropertyDescriptor(n,"self"),(o||!e||!e.get||!e.enumerable)&&i(n,"self",{get:function(){return n},set:function(e){if(this!==n)throw a("Illegal invocation");s(n,"self",{value:e,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})):t({global:!0,simple:!0,forced:o},{self:n})}catch(e){}})),Ioe=J(((e,t)=>{var n=en(),i=Map.prototype;t.exports={Map:Map,set:n(i.set),get:n(i.get),has:n(i.has),remove:n(i.delete),proto:i}})),Doe=J(((e,t)=>{var n=en(),i=Set.prototype;t.exports={Set:Set,add:n(i.add),has:n(i.has),remove:n(i.delete),proto:i}})),Foe=J(((e,t)=>{var n=Mn(),i=Yt(),r=su(),a=wO(),s=aS(),o=uu(),l=n.structuredClone;t.exports=!!l&&!i((function(){if(s&&r>92||o&&r>94||a&&r>97)return!1;var e=new ArrayBuffer(8),t=l(e,{transfer:[e]});return 0!=e.byteLength||8!=t.byteLength}))})),Woe=J((()=>{var e,t=ss(),n=tt(),i=Mn(),r=ki(),a=en(),s=Yt(),o=Tp(),l=Fr(),h=Mp(),c=La(),u=Nr(),d=Dd(),p=hc(),f=xr(),m=cc(),g=$r(),v=ou(),y=da(),x=pi(),b=pu(),_=s0(),w=Ioe(),S=Doe(),M=gL(),E=Foe(),T=i.Object,A=i.Array,C=i.Date,P=i.Error,R=i.EvalError,O=i.RangeError,L=i.ReferenceError,I=i.SyntaxError,D=i.TypeError,k=i.URIError,N=i.PerformanceMark,F=i.WebAssembly,U=F&&F.CompileError||P,B=F&&F.LinkError||P,z=F&&F.RuntimeError||P,H=r("DOMException"),V=w.Map,j=w.has,G=w.get,W=w.set,X=S.Set,Y=S.add,q=r("Object","keys"),J=a([].push),Z=a((!0).valueOf),K=a(1..valueOf),$=a("".valueOf),Q=a(C.prototype.getTime),ee=o("structuredClone"),te="DataCloneError",ne="Transferring",ie=function(e){return!s((function(){var t=new i.Set([7]),n=e(t),r=e(T(7));return n==t||!n.has(7)||"object"!=typeof r||7!=r}))&&e},re=function(e,t){return!s((function(){var n=new t,i=e({a:n,b:n});return!(i&&i.a===i.b&&i.a instanceof t&&i.a.stack===n.stack)}))},ae=i.structuredClone,se=t||!re(ae,P)||!re(ae,H)||(e=ae,!!s((function(){var t=e(new i.AggregateError([1],ee,{cause:3}));return"AggregateError"!=t.name||1!=t.errors[0]||t.message!=ee||3!=t.cause}))),oe=!ae&&ie((function(e){return new N(ee,{detail:e}).detail})),le=ie(ae)||oe,he=function(e){throw new H("Uncloneable type: "+e,te)},ce=function(e,t){throw new H((t||"Cloning")+" of "+e+" cannot be properly polyfilled in this engine",te)},ue=function(e,t){return le||ce(t),le(e)},de=function(e,t){if(d(e)&&he("Symbol"),!u(e))return e;if(t){if(j(t,e))return G(t,e)}else t=new V;var n,a,s,o,h,c,p,f,b,w,S,E=m(e),N=!1;switch(E){case"Array":s=A(x(e)),N=!0;break;case"Object":s={},N=!0;break;case"Map":s=new V,N=!0;break;case"Set":s=new X,N=!0;break;case"RegExp":s=new RegExp(e.source,_(e));break;case"Error":switch(a=e.name){case"AggregateError":s=r("AggregateError")([]);break;case"EvalError":s=R();break;case"RangeError":s=O();break;case"ReferenceError":s=L();break;case"SyntaxError":s=I();break;case"TypeError":s=D();break;case"URIError":s=k();break;case"CompileError":s=U();break;case"LinkError":s=B();break;case"RuntimeError":s=z();break;default:s=P()}N=!0;break;case"DOMException":s=new H(e.message,e.name),N=!0;break;case"DataView":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":n=i[E],u(n)||ce(E),s=new n(de(e.buffer,t),e.byteOffset,"DataView"===E?e.byteLength:e.length);break;case"DOMQuad":try{s=new DOMQuad(de(e.p1,t),de(e.p2,t),de(e.p3,t),de(e.p4,t))}catch(t){s=ue(e,E)}break;case"File":if(le)try{s=le(e),m(s)!==E&&(s=void 0)}catch(e){}if(!s)try{s=new File([e],e.name,e)}catch(e){}s||ce(E);break;case"FileList":if(o=function(){var e;try{e=new i.DataTransfer}catch(t){try{e=new i.ClipboardEvent("").clipboardData}catch(e){}}return e&&e.items&&e.files?e:null}(),o){for(h=0,c=x(e);h1&&!c(arguments[1])?f(arguments[1]):void 0,r=n?n.transfer:void 0;return void 0!==r&&function(e,t){if(!u(e))throw D("Transfer option cannot be converted to a sequence");var n=[];p(e,(function(e){J(n,f(e))}));var r,a,s,o,c,d,g=0,v=x(n);if(E)for(o=ae(n,{transfer:n});g{var e=tt(),t=Mn(),n=eM()(t.setInterval,!0);e({global:!0,bind:!0,forced:t.setInterval!==n},{setInterval:n})})),Koe=J((()=>{var e=tt(),t=Mn(),n=eM()(t.setTimeout,!0);e({global:!0,bind:!0,forced:t.setTimeout!==n},{setTimeout:n})})),Joe=J((()=>{Yoe(),Koe()})),cM=J(((e,t)=>{var n=Yt(),i=Br(),r=Kn(),a=ss(),s=i("iterator");t.exports=!n((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,n="";return e.pathname="c%20d",t.forEach((function(e,i){t.delete("b"),n+=i+e})),a&&!e.toJSON||!t.size&&(a||!r)||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[s]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://\u0442\u0435\u0441\u0442").host||"#%D0%B1"!==new URL("http://a#\u0431").hash||"a1c3"!==n||"x"!==new URL("http://x",void 0).host}))})),cle=J(((e,t)=>{var n=en(),i=2147483647,r=/[^\0-\u007E]/,a=/[.\u3002\uFF0E\uFF61]/g,s="Overflow: input needs wider integers to process",o=RangeError,l=n(a.exec),h=Math.floor,c=String.fromCharCode,u=n("".charCodeAt),d=n([].join),p=n([].push),f=n("".replace),m=n("".split),g=n("".toLowerCase),v=function(e){return e+22+75*(e<26)},y=function(e,t,n){var i=0;for(e=n?h(e/700):e>>1,e+=h(e/t);e>455;)e=h(e/35),i+=36;return h(i+36*e/(e+38))},x=function(e){var t=[];e=function(e){for(var t=[],n=0,i=e.length;n=55296&&r<=56319&&n=l&&rh((i-f)/_))throw o(s);for(f+=(b-l)*_,l=b,n=0;ni)throw o(s);if(r==l){for(var w=f,S=36;;){var M=S<=m?1:S>=m+26?26:S-m;if(w{"use strict";B1();var n=tt(),i=Mn(),r=Sr(),a=en(),s=Kn(),o=cM(),l=Yi(),h=Hs(),c=Vg(),u=no(),d=Tw(),p=Ts(),f=dc(),m=Fr(),g=$r(),v=fl(),y=cc(),x=xr(),b=Nr(),_=Mr(),w=to(),S=Oo(),M=I1(),E=Bg(),T=pu(),A=Br(),C=Cw(),P=A("iterator"),R="URLSearchParams",O=R+"Iterator",L=p.set,I=p.getterFor(R),D=p.getterFor(O),k=Object.getOwnPropertyDescriptor,N=function(e){if(!s)return i[e];var t=k(i,e);return t&&t.value},F=N("fetch"),U=N("Request"),B=N("Headers"),z=U&&U.prototype,H=B&&B.prototype,V=i.RegExp,j=i.TypeError,G=i.decodeURIComponent,W=i.encodeURIComponent,X=a("".charAt),Y=a([].join),q=a([].push),J=a("".replace),Z=a([].shift),K=a([].splice),$=a("".split),Q=a("".slice),ee=/\+/g,te=Array(4),ne=function(e){return te[e-1]||(te[e-1]=V("((?:%[\\da-f]{2}){"+e+"})","gi"))},ie=function(e){try{return G(e)}catch(t){return e}},re=function(e){var t=J(e,ee," "),n=4;try{return G(t)}catch(e){for(;n;)t=J(t,ne(n--),ie);return t}},ae=/[!'()~]|%20/g,se={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},oe=function(e){return se[e]},le=function(e){return J(W(e),ae,oe)},he=d((function(e,t){L(this,{type:O,iterator:M(I(e).entries),kind:t})}),"Iterator",(function(){var e=D(this),t=e.kind,n=e.iterator.next(),i=n.value;return n.done||(n.value="keys"===t?i.key:"values"===t?i.value:[i.key,i.value]),n}),!0),ce=function(e){this.entries=[],this.url=null,void 0!==e&&(b(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===X(e,0)?Q(e,1):e:_(e)))};ce.prototype={type:R,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,i,a,s,o,l,h=E(e);if(h)for(n=(t=M(e,h)).next;!(i=r(n,t)).done;){if(s=(a=M(x(i.value))).next,(o=r(s,a)).done||(l=r(s,a)).done||!r(s,a).done)throw j("Expected sequence with length 2");q(this.entries,{key:_(o.value),value:_(l.value)})}else for(var c in e)g(e,c)&&q(this.entries,{key:c,value:_(e[c])})},parseQuery:function(e){if(e)for(var t,n,i=$(e,"&"),r=0;r0?arguments[0]:void 0));s||(this.length=e.entries.length)},ge=me.prototype;c(ge,{append:function(e,t){T(arguments.length,2);var n=I(this);q(n.entries,{key:_(e),value:_(t)}),s||this.length++,n.updateURL()},delete:function(e){T(arguments.length,1);for(var t=I(this),n=t.entries,i=_(e),r=0;rt.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,n=I(this).entries,i=v(e,arguments.length>1?arguments[1]:void 0),r=0;r1?pe(arguments[1]):{})}}),m(U)&&(fe=function(e){return f(this,z),new U(e,arguments.length>1?pe(arguments[1]):{})},z.constructor=fe,fe.prototype=z,n({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:fe}))),t.exports={URLSearchParams:me,getState:I}})),Xle=J((()=>{"use strict";ik();var e,t=tt(),n=Kn(),i=cM(),r=Mn(),a=fl(),s=en(),o=Yi(),l=Hs(),h=dc(),c=$r(),u=eO(),d=FL(),p=Lg(),f=hx().codeAt,m=cle(),g=Mr(),v=no(),y=pu(),x=eN(),b=Ts(),_=b.set,w=b.getterFor("URL"),S=x.URLSearchParams,M=x.getState,E=r.URL,T=r.TypeError,A=r.parseInt,C=Math.floor,P=Math.pow,R=s("".charAt),O=s(/./.exec),L=s([].join),I=s(1..toString),D=s([].pop),k=s([].push),N=s("".replace),F=s([].shift),U=s("".split),B=s("".slice),z=s("".toLowerCase),H=s([].unshift),V="Invalid scheme",j="Invalid host",G="Invalid port",W=/[a-z]/i,X=/[\d+-.a-z]/i,Y=/\d/,q=/^0x/i,J=/^[0-7]+$/,Z=/^\d+$/,K=/^[\da-f]+$/i,$=/[\0\t\n\r #%/:<>?@[\\\]^|]/,Q=/[\0\t\n\r #/:<>?@[\\\]^|]/,ee=/^[\u0000-\u0020]+/,te=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,ne=/[\t\n\r]/g,ie=function(e){var t,n,i,r;if("number"==typeof e){for(t=[],n=0;n<4;n++)H(t,e%256),e=C(e/256);return L(t,".")}if("object"==typeof e){for(t="",i=function(e){for(var t=null,n=1,i=null,r=0,a=0;a<8;a++)0!==e[a]?(r>n&&(t=i,n=r),i=null,r=0):(null===i&&(i=a),++r);return r>n&&(t=i,n=r),t}(e),n=0;n<8;n++)r&&0===e[n]||(r&&(r=!1),i===n?(t+=n?":":"::",r=!0):(t+=I(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},re={},ae=u({},re,{" ":1,'"':1,"<":1,">":1,"`":1}),se=u({},ae,{"#":1,"?":1,"{":1,"}":1}),oe=u({},se,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),le=function(e,t){var n=f(e,0);return n>32&&n<127&&!c(t,e)?e:encodeURIComponent(e)},he={ftp:21,file:null,http:80,https:443,ws:80,wss:443},ce=function(e,t){var n;return 2==e.length&&O(W,R(e,0))&&(":"==(n=R(e,1))||!t&&"|"==n)},ue=function(e){var t;return e.length>1&&ce(B(e,0,2))&&(2==e.length||"/"===(t=R(e,2))||"\\"===t||"?"===t||"#"===t)},de=function(e){return"."===e||"%2e"===z(e)},pe=function(e){return".."===(e=z(e))||"%2e."===e||".%2e"===e||"%2e%2e"===e},fe={},me={},ge={},ve={},ye={},xe={},be={},_e={},we={},Se={},Me={},Ee={},Te={},Ae={},Ce={},Pe={},Re={},Oe={},Le={},Ie={},De={},ke=function(e,t,n){var i,r,a,s=g(e);if(t){if(r=this.parse(s))throw T(r);this.searchParams=null}else{if(void 0!==n&&(i=new ke(n,!0)),r=this.parse(s,null,i))throw T(r);(a=M(new S)).bindURL(this),this.searchParams=a}};ke.prototype={type:"URL",parse:function(t,n,i){var r,a,s,o,l=this,h=n||fe,u=0,f="",m=!1,v=!1,y=!1;for(t=g(t),n||(l.scheme="",l.username="",l.password="",l.host=null,l.port=null,l.path=[],l.query=null,l.fragment=null,l.cannotBeABaseURL=!1,t=N(t,ee,""),t=N(t,te,"$1")),t=N(t,ne,""),r=d(t);u<=r.length;){switch(a=r[u],h){case fe:if(!a||!O(W,a)){if(n)return V;h=ge;continue}f+=z(a),h=me;break;case me:if(a&&(O(X,a)||"+"==a||"-"==a||"."==a))f+=z(a);else{if(":"!=a){if(n)return V;f="",h=ge,u=0;continue}if(n&&(l.isSpecial()!=c(he,f)||"file"==f&&(l.includesCredentials()||null!==l.port)||"file"==l.scheme&&!l.host))return;if(l.scheme=f,n)return void(l.isSpecial()&&he[l.scheme]==l.port&&(l.port=null));f="","file"==l.scheme?h=Ae:l.isSpecial()&&i&&i.scheme==l.scheme?h=ve:l.isSpecial()?h=_e:"/"==r[u+1]?(h=ye,u++):(l.cannotBeABaseURL=!0,k(l.path,""),h=Le)}break;case ge:if(!i||i.cannotBeABaseURL&&"#"!=a)return V;if(i.cannotBeABaseURL&&"#"==a){l.scheme=i.scheme,l.path=p(i.path),l.query=i.query,l.fragment="",l.cannotBeABaseURL=!0,h=De;break}h="file"==i.scheme?Ae:xe;continue;case ve:if("/"!=a||"/"!=r[u+1]){h=xe;continue}h=we,u++;break;case ye:if("/"==a){h=Se;break}h=Oe;continue;case xe:if(l.scheme=i.scheme,a==e)l.username=i.username,l.password=i.password,l.host=i.host,l.port=i.port,l.path=p(i.path),l.query=i.query;else if("/"==a||"\\"==a&&l.isSpecial())h=be;else if("?"==a)l.username=i.username,l.password=i.password,l.host=i.host,l.port=i.port,l.path=p(i.path),l.query="",h=Ie;else{if("#"!=a){l.username=i.username,l.password=i.password,l.host=i.host,l.port=i.port,l.path=p(i.path),l.path.length--,h=Oe;continue}l.username=i.username,l.password=i.password,l.host=i.host,l.port=i.port,l.path=p(i.path),l.query=i.query,l.fragment="",h=De}break;case be:if(!l.isSpecial()||"/"!=a&&"\\"!=a){if("/"!=a){l.username=i.username,l.password=i.password,l.host=i.host,l.port=i.port,h=Oe;continue}h=Se}else h=we;break;case _e:if(h=we,"/"!=a||"/"!=R(f,u+1))continue;u++;break;case we:if("/"!=a&&"\\"!=a){h=Se;continue}break;case Se:if("@"==a){m&&(f="%40"+f),m=!0,s=d(f);for(var x=0;x65535)return G;l.port=l.isSpecial()&&w===he[l.scheme]?null:w,f=""}if(n)return;h=Re;continue}return G}f+=a;break;case Ae:if(l.scheme="file","/"==a||"\\"==a)h=Ce;else{if(!i||"file"!=i.scheme){h=Oe;continue}if(a==e)l.host=i.host,l.path=p(i.path),l.query=i.query;else if("?"==a)l.host=i.host,l.path=p(i.path),l.query="",h=Ie;else{if("#"!=a){ue(L(p(r,u),""))||(l.host=i.host,l.path=p(i.path),l.shortenPath()),h=Oe;continue}l.host=i.host,l.path=p(i.path),l.query=i.query,l.fragment="",h=De}}break;case Ce:if("/"==a||"\\"==a){h=Pe;break}i&&"file"==i.scheme&&!ue(L(p(r,u),""))&&(ce(i.path[0],!0)?k(l.path,i.path[0]):l.host=i.host),h=Oe;continue;case Pe:if(a==e||"/"==a||"\\"==a||"?"==a||"#"==a){if(!n&&ce(f))h=Oe;else if(""==f){if(l.host="",n)return;h=Re}else{if(o=l.parseHost(f))return o;if("localhost"==l.host&&(l.host=""),n)return;f="",h=Re}continue}f+=a;break;case Re:if(l.isSpecial()){if(h=Oe,"/"!=a&&"\\"!=a)continue}else if(n||"?"!=a)if(n||"#"!=a){if(a!=e&&(h=Oe,"/"!=a))continue}else l.fragment="",h=De;else l.query="",h=Ie;break;case Oe:if(a==e||"/"==a||"\\"==a&&l.isSpecial()||!n&&("?"==a||"#"==a)){if(pe(f)?(l.shortenPath(),"/"!=a&&!("\\"==a&&l.isSpecial())&&k(l.path,"")):de(f)?"/"!=a&&!("\\"==a&&l.isSpecial())&&k(l.path,""):("file"==l.scheme&&!l.path.length&&ce(f)&&(l.host&&(l.host=""),f=R(f,0)+":"),k(l.path,f)),f="","file"==l.scheme&&(a==e||"?"==a||"#"==a))for(;l.path.length>1&&""===l.path[0];)F(l.path);"?"==a?(l.query="",h=Ie):"#"==a&&(l.fragment="",h=De)}else f+=le(a,se);break;case Le:"?"==a?(l.query="",h=Ie):"#"==a?(l.fragment="",h=De):a!=e&&(l.path[0]+=le(a,re));break;case Ie:n||"#"!=a?a!=e&&("'"==a&&l.isSpecial()?l.query+="%27":l.query+="#"==a?"%23":le(a,re)):(l.fragment="",h=De);break;case De:a!=e&&(l.fragment+=le(a,ae))}u++}},parseHost:function(e){var t,n,i;if("["==R(e,0)){if("]"!=R(e,e.length-1)||(t=function(e){var t,n,i,r,a,s,o,l=[0,0,0,0,0,0,0,0],h=0,c=null,u=0,d=function(){return R(e,u)};if(":"==d()){if(":"!=R(e,1))return;u+=2,c=++h}for(;d();){if(8==h)return;if(":"!=d()){for(t=n=0;n<4&&O(K,d());)t=16*t+A(d(),16),u++,n++;if("."==d()){if(0==n||(u-=n,h>6))return;for(i=0;d();){if(r=null,i>0){if(!("."==d()&&i<4))return;u++}if(!O(Y,d()))return;for(;O(Y,d());){if(a=A(d(),10),null===r)r=a;else{if(0==r)return;r=10*r+a}if(r>255)return;u++}l[h]=256*l[h]+r,(2==++i||4==i)&&h++}if(4!=i)return;break}if(":"==d()){if(u++,!d())return}else if(d())return;l[h++]=t}else{if(null!==c)return;u++,c=++h}}if(null!==c)for(s=h-c,h=7;0!=h&&s>0;)o=l[h],l[h--]=l[c+s-1],l[c+--s]=o;else if(8!=h)return;return l}(B(e,1,-1)),!t))return j;this.host=t}else if(this.isSpecial()){if(e=m(e),O($,e)||(t=function(e){var t,n,i,r,a,s,o,l=U(e,".");if(l.length&&""==l[l.length-1]&&l.length--,(t=l.length)>4)return e;for(n=[],i=0;i1&&"0"==R(r,0)&&(a=O(q,r)?16:8,r=B(r,8==a?1:2)),""===r)s=0;else{if(!O(10==a?Z:8==a?J:K,r))return e;s=A(r,a)}k(n,s)}for(i=0;i=P(256,5-t))return null}else if(s>255)return null;for(o=D(n),i=0;i1?arguments[1]:void 0,r=_(t,new ke(e,!1,i));n||(t.href=r.serialize(),t.origin=r.getOrigin(),t.protocol=r.getProtocol(),t.username=r.getUsername(),t.password=r.getPassword(),t.host=r.getHost(),t.hostname=r.getHostname(),t.port=r.getPort(),t.pathname=r.getPathname(),t.search=r.getSearch(),t.searchParams=r.getSearchParams(),t.hash=r.getHash())},Be=Ue.prototype,ze=function(e,t){return{get:function(){return w(this)[e]()},set:t&&function(e){return w(this)[t](e)},configurable:!0,enumerable:!0}};n&&(l(Be,"href",ze("serialize","setHref")),l(Be,"origin",ze("getOrigin")),l(Be,"protocol",ze("getProtocol","setProtocol")),l(Be,"username",ze("getUsername","setUsername")),l(Be,"password",ze("getPassword","setPassword")),l(Be,"host",ze("getHost","setHost")),l(Be,"hostname",ze("getHostname","setHostname")),l(Be,"port",ze("getPort","setPort")),l(Be,"pathname",ze("getPathname","setPathname")),l(Be,"search",ze("getSearch","setSearch")),l(Be,"searchParams",ze("getSearchParams")),l(Be,"hash",ze("getHash","setHash"))),o(Be,"toJSON",(function(){return w(this).serialize()}),{enumerable:!0}),o(Be,"toString",(function(){return w(this).serialize()}),{enumerable:!0}),E&&(Ne=E.createObjectURL,Fe=E.revokeObjectURL,Ne&&o(Ue,"createObjectURL",a(Ne,E)),Fe&&o(Ue,"revokeObjectURL",a(Fe,E))),v(Ue,"URL"),t({global:!0,constructor:!0,forced:!i,sham:!n},{URL:Ue})})),Yle=J((()=>{Xle()})),Kle=J((()=>{var e=tt(),t=ki(),n=Yt(),i=pu(),r=Mr(),a=cM(),s=t("URL");e({target:"URL",stat:!0,forced:!(a&&n((function(){s.canParse()})))},{canParse:function(e){var t=i(arguments.length,1),n=r(e),a=t<2||void 0===arguments[1]?void 0:r(arguments[1]);try{return!!new s(n,a)}catch(e){return!1}}})})),Jle=J((()=>{"use strict";var e=tt(),t=Sr();e({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return t(URL.prototype.toString,this)}})})),Qle=J((()=>{eN()})),ece=J((()=>{"use strict";var e=Kn(),t=en(),n=Hs(),i=URLSearchParams.prototype,r=t(i.forEach);e&&!("size"in i)&&n(i,"size",{get:function(){var e=0;return r(this,(function(){e++})),e},configurable:!0,enumerable:!0})})),nce=J(((e,t)=>{nW(),cW(),uW(),hW(),dW(),fW(),pW(),mW(),gW(),vW(),yW(),xW(),bW(),EW(),_W(),YW(),QW(),gj(),bj(),_j(),Aj(),Lj(),Oj(),Nj(),Bj(),Hj(),zj(),Wj(),jj(),$j(),Zj(),Qj(),cX(),uX(),dX(),fX(),B1(),OX(),BX(),UX(),VX(),GX(),YX(),ZX(),JX(),tY(),nY(),yY(),EY(),_Y(),wY(),AY(),CY(),PY(),IY(),LY(),OY(),a$(),y$(),R$(),C$(),P$(),L$(),k$(),F$(),j$(),X$(),J$(),nZ(),iZ(),uZ(),fZ(),vZ(),yZ(),hL(),xZ(),kZ(),BZ(),VZ(),GZ(),WZ(),jZ(),$Z(),KZ(),eK(),nK(),iK(),aK(),oK(),lK(),cK(),dK(),mK(),gK(),vK(),AK(),CK(),LK(),OK(),kK(),FK(),NK(),BK(),qK(),JK(),rJ(),cJ(),dJ(),vJ(),yJ(),EJ(),TJ(),SJ(),MJ(),PJ(),IJ(),LJ(),kJ(),FJ(),NJ(),UJ(),HJ(),zJ(),qJ(),jJ(),YJ(),ZJ(),KJ(),JJ(),QJ(),sQ(),aQ(),oQ(),uQ(),hQ(),fQ(),mQ(),Mee(),Ree(),Cee(),Dee(),Oee(),Vee(),qee(),Wee(),$ee(),Zee(),Kee(),Jee(),Qee(),ete(),tte(),ate(),lte(),cte(),Ste(),Rte(),xS(),Dte(),kte(),Bte(),Vte(),Gte(),qte(),Yte(),tne(),ine(),ane(),ik(),xne(),Cne(),Ine(),Lne(),Fne(),Nne(),Gne(),Yne(),Kne(),rre(),lre(),ure(),pre(),xre(),wre(),Are(),Cre(),Pre(),Ire(),Lre(),Dre(),Ore(),kre(),Fre(),Nre(),Bre(),Ure(),Hre(),pie(),mie(),gie(),vie(),yie(),xie(),bie(),Eie(),_ie(),wie(),Mie(),Aie(),Pie(),Fie(),Bie(),Hie(),zie(),qie(),jie(),Xie(),$ie(),Kie(),nse(),ise(),ase(),lse(),use(),dse(),pse(),gse(),_se(),wse(),Mse(),Lse(),kse(),Hse(),Vse(),zse(),qse(),Wse(),Zse(),fae(),mae(),wae(),Dae(),Hae(),jae(),aoe(),foe(),moe(),Moe(),Roe(),Coe(),Woe(),Joe(),Yle(),Kle(),Jle(),Qle(),ece(),t.exports=aw()})),rce=J(((e,t)=>{var n=function(e){"use strict";var t,n=Object.prototype,i=n.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function h(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(e){h=function(e,t,n){return e[t]=n}}function c(e,t,n,i){var a=t&&t.prototype instanceof v?t:v,s=Object.create(a.prototype),o=new R(i||[]);return r(s,"_invoke",{value:T(e,n,o)}),s}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var d="suspendedStart",p="suspendedYield",f="executing",m="completed",g={};function v(){}function y(){}function x(){}var b={};h(b,s,(function(){return this}));var _=Object.getPrototypeOf,w=_&&_(_(O([])));w&&w!==n&&i.call(w,s)&&(b=w);var S=x.prototype=v.prototype=Object.create(b);function M(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function E(e,t){function n(r,a,s,o){var l=u(e[r],e,a);if("throw"!==l.type){var h=l.arg,c=h.value;return c&&"object"==typeof c&&i.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(c).then((function(e){h.value=e,s(h)}),(function(e){return n("throw",e,s,o)}))}o(l.arg)}var a;r(this,"_invoke",{value:function(e,i){function r(){return new t((function(t,r){n(e,i,t,r)}))}return a=a?a.then(r,r):r()}})}function T(e,t,n){var i=d;return function(r,a){if(i===f)throw new Error("Generator is already running");if(i===m){if("throw"===r)throw a;return L()}for(n.method=r,n.arg=a;;){var s=n.delegate;if(s){var o=A(s,n);if(o){if(o===g)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===d)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=f;var l=u(e,t,n);if("normal"===l.type){if(i=n.done?m:p,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(i=m,n.method="throw",n.arg=l.arg)}}}function A(e,n){var i=n.method,r=e.iterator[i];if(r===t)return n.delegate=null,"throw"===i&&e.iterator.return&&(n.method="return",n.arg=t,A(e,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),g;var a=u(r,e.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,g;var s=a.arg;return s?s.done?(n[e.resultName]=s.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,g):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function C(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function O(e){if(e){var n=e[s];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function n(){for(;++r=0;--a){var s=this.tryEntries[a],o=s.completion;if("root"===s.tryLoc)return r("end");if(s.tryLoc<=this.prev){var l=i.call(s,"catchLoc"),h=i.call(s,"finallyLoc");if(l&&h){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),P(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var i=n.completion;if("throw"===i.type){var r=i.arg;P(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,i){return this.delegate={iterator:O(e),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=t),g}},e}("object"==typeof t?t.exports:{});try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}})),fde=J(((e,t)=>{!function(e,n){"use strict";"function"==typeof define&&define.amd?define(n):"object"==typeof t&&t.exports?t.exports=n():e.log=n()}(e,(function(){"use strict";var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"];function r(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(t){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function a(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function s(t,n){for(var r=0;r=0&&n<=o.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(a=n,!1!==r&&function(e){var n=(i[e]||"silent").toUpperCase();if(typeof window!==t&&h){try{return void(window.localStorage[h]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(h)+"="+n+";"}catch(e){}}}(n),s.call(o,n,e),typeof console===t&&n{"use strict";t.exports=function(e,t,i){var r=e*t,a=n*e,s=a-(a-e),o=e-s,l=n*t,h=l-(l-t),c=t-h,u=o*c-(r-s*h-o*h-s*c);return i?(i[0]=u,i[1]=r,i):[u,r]};var n=+(Math.pow(2,27)+1)})),e5=J(((e,t)=>{"use strict";t.exports=function(e,t){var n=0|e.length,i=0|t.length;if(1===n&&1===i)return function(e,t){var n=e+t,i=n-e,r=e-(n-i)+(t-i);return r?[r,n]:[n]}(e[0],t[0]);var r,a,s=new Array(n+i),o=0,l=0,h=0,c=Math.abs,u=e[l],d=c(u),p=t[h],f=c(p);d=i?(r=u,(l+=1){"use strict";t.exports=function(e,t,n){var i=e+t,r=i-e,a=t-r,s=e-(i-r);return n?(n[0]=s+a,n[1]=i,n):[s+a,i]}})),n5=J(((e,t)=>{"use strict";var n=BA(),i=rfe();t.exports=function(e,t){var r=e.length;if(1===r){var a=n(e[0],t);return a[0]?a:[a[1]]}var s=new Array(2*r),o=[.1,.1],l=[.1,.1],h=0;n(e[0],t,o),o[0]&&(s[h++]=o[0]);for(var c=1;c{"use strict";t.exports=function(e){for(var t=e.length,n=e[e.length-1],i=t,r=t-2;r>=0;--r){var a=n;(l=(o=e[r])-((n=a+o)-a))&&(e[--i]=n,n=l)}var s=0;for(r=i;r{"use strict";t.exports=function(e,t){var n=0|e.length,i=0|t.length;if(1===n&&1===i)return function(e,t){var n=e+t,i=n-e,r=e-(n-i)+(t-i);return r?[r,n]:[n]}(e[0],-t[0]);var r,a,s=new Array(n+i),o=0,l=0,h=0,c=Math.abs,u=e[l],d=c(u),p=-t[h],f=c(p);d=i?(r=u,(l+=1){"use strict";var n=BA(),i=e5(),r=n5(),a=lfe();function s(e,t,n,i){return function(n,r,a){var s=e(e(t(r[1],a[0]),t(-a[1],r[0])),e(t(n[1],r[0]),t(-r[1],n[0]))),o=e(t(n[1],a[0]),t(-a[1],n[0])),l=i(s,o);return l[l.length-1]}}function o(e,t,n,i){return function(r,a,s,o){var l=e(e(n(e(t(s[1],o[0]),t(-o[1],s[0])),a[2]),e(n(e(t(a[1],o[0]),t(-o[1],a[0])),-s[2]),n(e(t(a[1],s[0]),t(-s[1],a[0])),o[2]))),e(n(e(t(a[1],o[0]),t(-o[1],a[0])),r[2]),e(n(e(t(r[1],o[0]),t(-o[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),o[2])))),h=e(e(n(e(t(s[1],o[0]),t(-o[1],s[0])),r[2]),e(n(e(t(r[1],o[0]),t(-o[1],r[0])),-s[2]),n(e(t(r[1],s[0]),t(-s[1],r[0])),o[2]))),e(n(e(t(a[1],s[0]),t(-s[1],a[0])),r[2]),e(n(e(t(r[1],s[0]),t(-s[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),s[2])))),c=i(l,h);return c[c.length-1]}}function l(e,t,n,i){return function(r,a,s,o,l){var h=e(e(e(n(e(n(e(t(o[1],l[0]),t(-l[1],o[0])),s[2]),e(n(e(t(s[1],l[0]),t(-l[1],s[0])),-o[2]),n(e(t(s[1],o[0]),t(-o[1],s[0])),l[2]))),a[3]),e(n(e(n(e(t(o[1],l[0]),t(-l[1],o[0])),a[2]),e(n(e(t(a[1],l[0]),t(-l[1],a[0])),-o[2]),n(e(t(a[1],o[0]),t(-o[1],a[0])),l[2]))),-s[3]),n(e(n(e(t(s[1],l[0]),t(-l[1],s[0])),a[2]),e(n(e(t(a[1],l[0]),t(-l[1],a[0])),-s[2]),n(e(t(a[1],s[0]),t(-s[1],a[0])),l[2]))),o[3]))),e(n(e(n(e(t(s[1],o[0]),t(-o[1],s[0])),a[2]),e(n(e(t(a[1],o[0]),t(-o[1],a[0])),-s[2]),n(e(t(a[1],s[0]),t(-s[1],a[0])),o[2]))),-l[3]),e(n(e(n(e(t(o[1],l[0]),t(-l[1],o[0])),a[2]),e(n(e(t(a[1],l[0]),t(-l[1],a[0])),-o[2]),n(e(t(a[1],o[0]),t(-o[1],a[0])),l[2]))),r[3]),n(e(n(e(t(o[1],l[0]),t(-l[1],o[0])),r[2]),e(n(e(t(r[1],l[0]),t(-l[1],r[0])),-o[2]),n(e(t(r[1],o[0]),t(-o[1],r[0])),l[2]))),-a[3])))),e(e(n(e(n(e(t(a[1],l[0]),t(-l[1],a[0])),r[2]),e(n(e(t(r[1],l[0]),t(-l[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),l[2]))),o[3]),e(n(e(n(e(t(a[1],o[0]),t(-o[1],a[0])),r[2]),e(n(e(t(r[1],o[0]),t(-o[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),o[2]))),-l[3]),n(e(n(e(t(s[1],o[0]),t(-o[1],s[0])),a[2]),e(n(e(t(a[1],o[0]),t(-o[1],a[0])),-s[2]),n(e(t(a[1],s[0]),t(-s[1],a[0])),o[2]))),r[3]))),e(n(e(n(e(t(s[1],o[0]),t(-o[1],s[0])),r[2]),e(n(e(t(r[1],o[0]),t(-o[1],r[0])),-s[2]),n(e(t(r[1],s[0]),t(-s[1],r[0])),o[2]))),-a[3]),e(n(e(n(e(t(a[1],o[0]),t(-o[1],a[0])),r[2]),e(n(e(t(r[1],o[0]),t(-o[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),o[2]))),s[3]),n(e(n(e(t(a[1],s[0]),t(-s[1],a[0])),r[2]),e(n(e(t(r[1],s[0]),t(-s[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),s[2]))),-o[3]))))),c=e(e(e(n(e(n(e(t(o[1],l[0]),t(-l[1],o[0])),s[2]),e(n(e(t(s[1],l[0]),t(-l[1],s[0])),-o[2]),n(e(t(s[1],o[0]),t(-o[1],s[0])),l[2]))),r[3]),n(e(n(e(t(o[1],l[0]),t(-l[1],o[0])),r[2]),e(n(e(t(r[1],l[0]),t(-l[1],r[0])),-o[2]),n(e(t(r[1],o[0]),t(-o[1],r[0])),l[2]))),-s[3])),e(n(e(n(e(t(s[1],l[0]),t(-l[1],s[0])),r[2]),e(n(e(t(r[1],l[0]),t(-l[1],r[0])),-s[2]),n(e(t(r[1],s[0]),t(-s[1],r[0])),l[2]))),o[3]),n(e(n(e(t(s[1],o[0]),t(-o[1],s[0])),r[2]),e(n(e(t(r[1],o[0]),t(-o[1],r[0])),-s[2]),n(e(t(r[1],s[0]),t(-s[1],r[0])),o[2]))),-l[3]))),e(e(n(e(n(e(t(s[1],l[0]),t(-l[1],s[0])),a[2]),e(n(e(t(a[1],l[0]),t(-l[1],a[0])),-s[2]),n(e(t(a[1],s[0]),t(-s[1],a[0])),l[2]))),r[3]),n(e(n(e(t(s[1],l[0]),t(-l[1],s[0])),r[2]),e(n(e(t(r[1],l[0]),t(-l[1],r[0])),-s[2]),n(e(t(r[1],s[0]),t(-s[1],r[0])),l[2]))),-a[3])),e(n(e(n(e(t(a[1],l[0]),t(-l[1],a[0])),r[2]),e(n(e(t(r[1],l[0]),t(-l[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),l[2]))),s[3]),n(e(n(e(t(a[1],s[0]),t(-s[1],a[0])),r[2]),e(n(e(t(r[1],s[0]),t(-s[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),s[2]))),-l[3])))),u=i(h,c);return u[u.length-1]}}function h(e){return(3===e?s:4===e?o:l)(i,n,r,a)}var c=h(3),u=h(4),d=[function(){return 0},function(){return 0},function(e,t){return t[0]-e[0]},function(e,t,n){var i,r=(e[1]-n[1])*(t[0]-n[0]),a=(e[0]-n[0])*(t[1]-n[1]),s=r-a;if(r>0){if(a<=0)return s;i=r+a}else{if(!(r<0))return s;if(a>=0)return s;i=-(r+a)}var o=33306690738754716e-32*i;return s>=o||s<=-o?s:c(e,t,n)},function(e,t,n,i){var r=e[0]-i[0],a=t[0]-i[0],s=n[0]-i[0],o=e[1]-i[1],l=t[1]-i[1],h=n[1]-i[1],c=e[2]-i[2],d=t[2]-i[2],p=n[2]-i[2],f=a*h,m=s*l,g=s*o,v=r*h,y=r*l,x=a*o,b=c*(f-m)+d*(g-v)+p*(y-x),_=7771561172376103e-31*((Math.abs(f)+Math.abs(m))*Math.abs(c)+(Math.abs(g)+Math.abs(v))*Math.abs(d)+(Math.abs(y)+Math.abs(x))*Math.abs(p));return b>_||-b>_?b:u(e,t,n,i)}];function p(e){var t=d[e.length];return t||(t=d[e.length]=h(e.length)),t.apply(void 0,e)}function f(e,t,n,i,r,a,s){return function(t,n,o,l,h){switch(arguments.length){case 0:case 1:return 0;case 2:return i(t,n);case 3:return r(t,n,o);case 4:return a(t,n,o,l);case 5:return s(t,n,o,l,h)}for(var c=new Array(arguments.length),u=0;u{"use strict";t.exports=function(e,t,i,r){var a=n(e,i,r),s=n(t,i,r);if(a>0&&s>0||a<0&&s<0)return!1;var o=n(i,e,t),l=n(r,e,t);return!(o>0&&l>0||o<0&&l<0)&&(0!==a||0!==s||0!==o||0!==l||function(e,t,n,i){for(var r=0;r<2;++r){var a=e[r],s=t[r],o=Math.min(a,s),l=Math.max(a,s),h=n[r],c=i[r],u=Math.min(h,c);if(Math.max(h,c){"use strict";t.exports=function(e,t,o,l){if(!s(e,t,o,l))return[[0],[0],[0]];var h=i([o[1]],[-l[1]]),c=i([-o[0]],[l[0]]),u=i(i(r(c,e[1]),r(c,-t[1])),i(r(h,e[0]),r(h,-t[0]))),d=i(n(-e[0],t[1]),n(e[1],t[0])),p=i(n(-o[0],l[1]),n(o[1],l[0])),f=i(i(r(p,e[0]),r(p,-t[0])),i(r(d,-o[0]),r(d,l[0]))),m=i(i(r(p,e[1]),r(p,-t[1])),i(r(d,-o[1]),r(d,l[1])));return[a(f),a(m),a(u)]};var n=BA(),i=e5(),r=n5(),a=afe(),s=dfe()})),gfe=J(((e,t)=>{t.exports=function(e){var t=0,n=e.length;switch(n){case 1:t=e[0];break;case 2:t=e[0]+e[1];break;case 3:t=e[0]+e[1]+e[2];break;case 4:t=e[0]+e[1]+e[2]+e[3];break;default:for(var i=0;i{var n=pfe(),i=gfe();function r(e,t){return e[0]===t[0]&&e[1]===t[1]}t.exports=function(e,t){for(var c={},u=e.length,d=[],p=0;p{function n(e){if(e)return function(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}(e)}t.exports=n,n.prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[e]=this._callbacks[e]||[]).push(t),this},n.prototype.once=function(e,t){var n=this;function i(){n.off(e,i),t.apply(this,arguments)}return this._callbacks=this._callbacks||{},i.fn=t,this.on(e,i),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks[e];if(!n)return this;if(1==arguments.length)return delete this._callbacks[e],this;for(var i,r=0;r{var n=Zfe();function i(){n.call(this)}i.prototype=new n,t.exports=i,i.Stream=i,i.prototype.pipe=function(e,t){var n=this;function i(t){e.writable&&!1===e.write(t)&&n.pause&&n.pause()}function r(){n.readable&&n.resume&&n.resume()}n.on("data",i),e.on("drain",r),!e._isStdio&&(!t||!1!==t.end)&&(n.on("end",s),n.on("close",o));var a=!1;function s(){a||(a=!0,e.end())}function o(){a||(a=!0,"function"==typeof e.destroy&&e.destroy())}function l(e){if(h(),!this.hasListeners("error"))throw e}function h(){n.off("data",i),e.off("drain",r),n.off("end",s),n.off("close",o),n.off("error",l),e.off("error",l),n.off("end",h),n.off("close",h),e.off("end",h),e.off("close",h)}return n.on("error",l),e.on("error",l),n.on("end",h),n.on("close",h),e.on("end",h),e.on("close",h),e.emit("pipe",n),e}})),epe=J(((e,t)=>{var n,i;n=e,i=function(){"use strict";var e=Math.imul,t=Math.clz32;function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var n,i=0;ie.length)&&(t=e.length);for(var n=0,i=Array(t);no.__kMaxLength)throw new RangeError("Maximum BigInt size exceeded");return n}!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&a(e,t)}(o,e);var l=c(o);return function(e,t,n){t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1})}(o,[{key:"toDebugString",value:function(){var e,t=["BigInt["],n=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=d(e))){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}(this);try{for(n.s();!(e=n.n()).done;){var i=e.value;t.push((i&&(i>>>0).toString(16))+", ")}}catch(e){n.e(e)}finally{n.f()}return t.push("]"),t.join("")}},{key:"toString",value:function(){var e=0e||36this.length&&(n=this.length);for(var i=32767&e,r=e>>>15,a=0,s=t,l=0;l>>15,d=o.__imul(c,i),p=o.__imul(c,r),f=o.__imul(u,i),m=s+d+a;a=m>>>30,m&=1073741823,a+=(m+=((32767&p)<<15)+((32767&f)<<15))>>>30,s=o.__imul(u,r)+(p>>>15)+(f>>>15),this.__setDigit(l,1073741823&m)}if(0!==a||0!==s)throw new Error("implementation bug")}},{key:"__inplaceAdd",value:function(e,t,n){for(var i,r=0,a=0;a>>15,this.__setHalfDigit(t+a,32767&i);return r}},{key:"__inplaceSub",value:function(e,t,n){var i=0;if(1&t){t>>=1;for(var r=this.__digit(t),a=32767&r,s=0;s>>1;s++){var o=e.__digit(s),l=(r>>>15)-(32767&o)-i;i=1&l>>>15,this.__setDigit(t+s,(32767&l)<<15|32767&a),i=1&(a=(32767&(r=this.__digit(t+s+1)))-(o>>>15)-i)>>>15}var h=e.__digit(s),c=(r>>>15)-(32767&h)-i;if(i=1&c>>>15,this.__setDigit(t+s,(32767&c)<<15|32767&a),t+s+1>=this.length)throw new RangeError("out of bounds");!(1&n)&&(i=1&(a=(32767&(r=this.__digit(t+s+1)))-(h>>>15)-i)>>>15,this.__setDigit(t+e.length,1073709056&r|32767&a))}else{t>>=1;for(var u=0;u>>15)-(p>>>15)-(i=1&f>>>15);i=1&m>>>15,this.__setDigit(t+u,(32767&m)<<15|32767&f)}var g=this.__digit(t+u),v=e.__digit(u),y=(32767&g)-(32767&v)-i;i=1&y>>>15;var x=0;!(1&n)&&(i=1&(x=(g>>>15)-(v>>>15)-i)>>>15),this.__setDigit(t+u,(32767&x)<<15|32767&y)}return i}},{key:"__inplaceRightShift",value:function(e){if(0!==e){for(var t,n=this.__digit(0)>>>e,i=this.length-1,r=0;r>>e;this.__setDigit(i,n)}}},{key:"__digit",value:function(e){return this[e]}},{key:"__unsignedDigit",value:function(e){return this[e]>>>0}},{key:"__setDigit",value:function(e,t){this[e]=0|t}},{key:"__setDigitGrow",value:function(e,t){this[e]=0|t}},{key:"__halfDigitLength",value:function(){var e=this.length;return 32767>=this.__unsignedDigit(e-1)?2*e-1:2*e}},{key:"__halfDigit",value:function(e){return 32767&this[e>>>1]>>>15*(1&e)}},{key:"__setHalfDigit",value:function(e,t){var n=e>>>1,i=this.__digit(n),r=1&e?32767&i|t<<15:1073709056&i|32767&t;this.__setDigit(n,r)}}],[{key:"BigInt",value:function(e){var t=Number.isFinite;if("number"==typeof e){if(0===e)return o.__zero();if(o.__isOneDigitInt(e))return 0>e?o.__oneDigit(-e,!0):o.__oneDigit(e,!1);if(!t(e)||s(e)!==e)throw new RangeError("The number "+e+" cannot be converted to BigInt because it is not an integer");return o.__fromDouble(e)}if("string"==typeof e){var i=o.__fromString(e);if(null===i)throw new SyntaxError("Cannot convert "+e+" to a BigInt");return i}if("boolean"==typeof e)return!0===e?o.__oneDigit(1,!1):o.__zero();if("object"===n(e)){if(e.constructor===o)return e;var r=o.__toPrimitive(e);return o.BigInt(r)}throw new TypeError("Cannot convert "+e+" to a BigInt")}},{key:"toNumber",value:function(e){var t=e.length;if(0===t)return 0;if(1===t){var n=e.__unsignedDigit(0);return e.sign?-n:n}var i=e.__digit(t-1),r=o.__clz30(i),a=30*t-r;if(1024>>=12;var d=c-12,p=12<=c?0:l<<20+c,f=20+c;for(0>>30-d,p=l<>>30-f,f-=30;var m=o.__decideRounding(e,f,h,l);if((1===m||0===m&&1==(1&p))&&0==(p=p+1>>>0)&&++u>>>20!=0&&(u=0,1023<++s))return e.sign?-1/0:1/0;var g=e.sign?-2147483648:0;return s=s+1023<<20,o.__kBitConversionInts[1]=g|s|u,o.__kBitConversionInts[0]=p,o.__kBitConversionDouble[0]}},{key:"unaryMinus",value:function(e){if(0===e.length)return e;var t=e.__copy();return t.sign=!e.sign,t}},{key:"bitwiseNot",value:function(e){return e.sign?o.__absoluteSubOne(e).__trim():o.__absoluteAddOne(e,!0)}},{key:"exponentiate",value:function(e,t){if(t.sign)throw new RangeError("Exponent must be positive");if(0===t.length)return o.__oneDigit(1,!1);if(0===e.length)return e;if(1===e.length&&1===e.__digit(0))return!e.sign||1&t.__digit(0)?e:o.unaryMinus(e);if(1=o.__kMaxLengthBits)throw new RangeError("BigInt too big");if(1===e.length&&2===e.__digit(0)){var i=1+(0|n/30),r=new o(i,e.sign&&0!=(1&n));r.__initializeDigits();var a=1<>=1;0!==n;n>>=1)l=o.multiply(l,l),1&n&&(s=null===s?l:o.multiply(s,l));return s}},{key:"multiply",value:function(e,t){if(0===e.length)return e;if(0===t.length)return t;var n=e.length+t.length;30<=e.__clzmsd()+t.__clzmsd()&&n--;var i=new o(n,e.sign!==t.sign);i.__initializeDigits();for(var r=0;ro.__absoluteCompare(e,t))return o.__zero();var n,i=e.sign!==t.sign,r=t.__unsignedDigit(0);if(1===t.length&&32767>=r){if(1===r)return i===e.sign?e:o.unaryMinus(e);n=o.__absoluteDivSmall(e,r,null)}else n=o.__absoluteDivLarge(e,t,!0,!1);return n.sign=i,n.__trim()}},{key:"remainder",value:function(e,t){if(0===t.length)throw new RangeError("Division by zero");if(0>o.__absoluteCompare(e,t))return e;var n=t.__unsignedDigit(0);if(1===t.length&&32767>=n){if(1===n)return o.__zero();var i=o.__absoluteModSmall(e,n);return 0===i?o.__zero():o.__oneDigit(i,e.sign)}var r=o.__absoluteDivLarge(e,t,!1,!0);return r.sign=e.sign,r.__trim()}},{key:"add",value:function(e,t){var n=e.sign;return n===t.sign?o.__absoluteAdd(e,t,n):0<=o.__absoluteCompare(e,t)?o.__absoluteSub(e,t,n):o.__absoluteSub(t,e,!n)}},{key:"subtract",value:function(e,t){var n=e.sign;return n===t.sign?0<=o.__absoluteCompare(e,t)?o.__absoluteSub(e,t,n):o.__absoluteSub(t,e,!n):o.__absoluteAdd(e,t,n)}},{key:"leftShift",value:function(e,t){return 0===t.length||0===e.length?e:t.sign?o.__rightShiftByAbsolute(e,t):o.__leftShiftByAbsolute(e,t)}},{key:"signedRightShift",value:function(e,t){return 0===t.length||0===e.length?e:t.sign?o.__leftShiftByAbsolute(e,t):o.__rightShiftByAbsolute(e,t)}},{key:"unsignedRightShift",value:function(){throw new TypeError("BigInts have no unsigned right shift; use >> instead")}},{key:"lessThan",value:function(e,t){return 0>o.__compareToBigInt(e,t)}},{key:"lessThanOrEqual",value:function(e,t){return 0>=o.__compareToBigInt(e,t)}},{key:"greaterThan",value:function(e,t){return 0(e=s(e)))throw new RangeError("Invalid value: not (convertible to) a safe integer");if(0===e)return o.__zero();if(e>=o.__kMaxLengthBits)return t;var n=0|(e+29)/30;if(t.length(e=s(e)))throw new RangeError("Invalid value: not (convertible to) a safe integer");if(0===e)return o.__zero();if(t.sign){if(e>o.__kMaxLengthBits)throw new RangeError("BigInt too big");return o.__truncateAndSubFromPowerOfTwo(e,t,!1)}if(e>=o.__kMaxLengthBits)return t;var n=0|(e+29)/30;if(t.length>>i))return t}return o.__truncateToNBits(e,t)}},{key:"ADD",value:function(e,t){if(e=o.__toPrimitive(e),t=o.__toPrimitive(t),"string"==typeof e)return"string"!=typeof t&&(t=t.toString()),e+t;if("string"==typeof t)return e.toString()+t;if(e=o.__toNumeric(e),t=o.__toNumeric(t),o.__isBigInt(e)&&o.__isBigInt(t))return o.add(e,t);if("number"==typeof e&&"number"==typeof t)return e+t;throw new TypeError("Cannot mix BigInt and other types, use explicit conversions")}},{key:"LT",value:function(e,t){return o.__compare(e,t,0)}},{key:"LE",value:function(e,t){return o.__compare(e,t,1)}},{key:"GT",value:function(e,t){return o.__compare(e,t,2)}},{key:"GE",value:function(e,t){return o.__compare(e,t,3)}},{key:"EQ",value:function(e,t){for(;;){if(o.__isBigInt(e))return o.__isBigInt(t)?o.equal(e,t):o.EQ(t,e);if("number"==typeof e){if(o.__isBigInt(t))return o.__equalToNumber(t,e);if("object"!==n(t))return e==t;t=o.__toPrimitive(t)}else if("string"==typeof e){if(o.__isBigInt(t))return null!==(e=o.__fromString(e))&&o.equal(e,t);if("object"!==n(t))return e==t;t=o.__toPrimitive(t)}else if("boolean"==typeof e){if(o.__isBigInt(t))return o.__equalToNumber(t,+e);if("object"!==n(t))return e==t;t=o.__toPrimitive(t)}else if("symbol"===n(e)){if(o.__isBigInt(t))return!1;if("object"!==n(t))return e==t;t=o.__toPrimitive(t)}else{if("object"!==n(e))return e==t;if("object"===n(t)&&t.constructor!==o)return e==t;e=o.__toPrimitive(e)}}}},{key:"NE",value:function(e,t){return!o.EQ(e,t)}},{key:"DataViewGetBigInt64",value:function(e,t){var n=2>>30),h.__setDigit(2,s>>>28),h.__trim()}},{key:"DataViewSetBigInt64",value:function(e,t,n){var i=3>>2,2t)r=-t-1;else{if(0===n)return-1;n--,i=e.__digit(n),r=29}var a=1<>>20)-1023,i=1+(0|n/30),r=new o(i,0>e),a=1048575&o.__kBitConversionInts[1]|1048576,s=o.__kBitConversionInts[0],l=n%30,h=0;if(l<20){var c=20-l;h=c+32,t=a>>>c,a=a<<32-c|s>>>c,s<<=32-c}else if(20===l)h=32,t=a,a=s,s=0;else{var u=l-20;h=32-u,t=a<>>32-u,a=s<>>2,a=a<<30|s>>>2,s<<=30):t=0,r.__setDigit(d,t);return r.__trim()}},{key:"__isWhitespace",value:function(e){return 13>=e&&9<=e||(159>=e?32==e:131071>=e?160==e||5760==e:196607>=e?10>=(e&=131071)||40==e||41==e||47==e||95==e||4096==e:65279==e)}},{key:"__fromString",value:function(e){var t=11073741824/l)return null;var c=new o(0|(29+(l*s+h>>>o.__kBitsPerCharTableShift))/30,!1),u=10>t?t:10,d=10>>0>>0>>o.__kBitsPerCharTableShift)/30;c.__inplaceMultiplyAdd(v,g,x)}while(!p)}else{l>>=o.__kBitsPerCharTableShift;var b=[],_=[],w=!1;do{for(var S,M=0,E=0;;){if(S=void 0,a-48>>>0>>0>>l-(a-=30))}if(0!==r){if(i>=e.length)throw new Error("implementation bug");e.__setDigit(i++,r)}for(;i>>1)+(85&i))>>>2)+(51&i))>>>4)+(15&i),a=t-1,s=e.__digit(n-1),l=0|(30*n-o.__clz30(s)+r-1)/r;if(e.sign&&l++,268435456>>g,d=30-g;d>=r;)h[c--]=o.__kConversionChars[u&a],u>>>=r,d-=r}var v=(u|s<>>r-d;0!==u;)h[c--]=o.__kConversionChars[u&a],u>>>=r;if(e.sign&&(h[c--]="-"),-1!==c)throw new Error("implementation bug");return h.join("")}},{key:"__toStringGeneric",value:function(e,t,n){var i=e.length;if(0===i)return"";if(1===i){var r=e.__unsignedDigit(0).toString(t);return!1===n&&e.sign&&(r="-"+r),r}var a,s,l=30*i-o.__clz30(e.__digit(i-1)),h=o.__kMaxBitsPerChar[t]-1,c=l*o.__kBitsPerCharTableMultiplier,u=1+(c=0|(c+=h-1)/h)>>1,d=o.exponentiate(o.__oneDigit(t,!1),o.__oneDigit(u,!1)),p=d.__unsignedDigit(0);if(1===d.length&&32767>=p){(a=new o(e.length,!1)).__initializeDigits();for(var f,m=0,g=2*e.length-1;0<=g;g--)f=m<<15|e.__halfDigit(g),a.__setHalfDigit(g,0|f/p),m=0|f%p;s=m.toString(t)}else{var v=o.__absoluteDivLarge(e,d,!0,!0);a=v.quotient;var y=v.remainder.__trim();s=o.__toStringGeneric(y,t,!0)}a.__trim();for(var x=o.__toStringGeneric(a,t,!0);s.lengthi?o.__absoluteLess(n):0}},{key:"__compareToNumber",value:function(e,n){if(o.__isOneDigitInt(n)){var i=e.sign,r=0>n;if(i!==r)return o.__unequalSign(i);if(0===e.length){if(r)throw new Error("implementation bug");return 0===n?0:-1}if(1a?o.__absoluteGreater(i):st)return o.__unequalSign(n);if(0===t)throw new Error("implementation bug: should be handled elsewhere");if(0===e.length)return-1;o.__kBitConversionDouble[0]=t;var i=2047&o.__kBitConversionInts[1]>>>20;if(2047==i)throw new Error("implementation bug: handled elsewhere");var r=i-1023;if(0>r)return o.__absoluteGreater(n);var a=e.length,s=e.__digit(a-1),l=o.__clz30(s),h=30*a-l,c=r+1;if(hc)return o.__absoluteGreater(n);var u=1048576|1048575&o.__kBitConversionInts[1],d=o.__kBitConversionInts[0],p=29-l;if(p!==(0|(h-1)%30))throw new Error("implementation bug");var f,m=0;if(p<20){var g=20-p;m=g+32,f=u>>>g,u=u<<32-g|d>>>g,d<<=32-g}else if(20===p)m=32,f=u,u=d,d=0;else{var v=p-20;m=32-v,f=u<>>32-v,u=d<>>=0)>(f>>>=0))return o.__absoluteGreater(n);if(s>>2,u=u<<30|d>>>2,d<<=30):f=0;var x=e.__unsignedDigit(y);if(x>f)return o.__absoluteGreater(n);if(xn&&e.__unsignedDigit(0)===t(n):0===o.__compareToDouble(e,n)}},{key:"__comparisonResultToBool",value:function(e,t){return 0===t?0>e:1===t?0>=e:2===t?0t;case 3:return e>=t}if(o.__isBigInt(e)&&"string"==typeof t)return null!==(t=o.__fromString(t))&&o.__comparisonResultToBool(o.__compareToBigInt(e,t),n);if("string"==typeof e&&o.__isBigInt(t))return null!==(e=o.__fromString(e))&&o.__comparisonResultToBool(o.__compareToBigInt(e,t),n);if(e=o.__toNumeric(e),t=o.__toNumeric(t),o.__isBigInt(e)){if(o.__isBigInt(t))return o.__comparisonResultToBool(o.__compareToBigInt(e,t),n);if("number"!=typeof t)throw new Error("implementation bug");return o.__comparisonResultToBool(o.__compareToNumber(e,t),n)}if("number"!=typeof e)throw new Error("implementation bug");if(o.__isBigInt(t))return o.__comparisonResultToBool(o.__compareToNumber(t,e),2^n);if("number"!=typeof t)throw new Error("implementation bug");return 0===n?et:3===n?e>=t:void 0}},{key:"__absoluteAdd",value:function(e,t,n){if(e.length>>30,a.__setDigit(l,1073741823&r);for(;l>>30,a.__setDigit(l,1073741823&h)}return l>>30,r.__setDigit(s,1073741823&i);for(;s>>30,r.__setDigit(s,1073741823&l)}return r.__trim()}},{key:"__absoluteAddOne",value:function(e,t){var n=2>>30,n.__setDigit(s,1073741823&r);return 0!==a&&n.__setDigitGrow(i,1),n}},{key:"__absoluteSubOne",value:function(e,t){for(var n,i=e.length,r=new o(t=t||i,!1),a=1,s=0;s>>30,r.__setDigit(s,1073741823&n);if(0!==a)throw new Error("implementation bug");for(var l=i;li?0:e.__unsignedDigit(i)>t.__unsignedDigit(i)?1:-1}},{key:"__multiplyAccumulate",value:function(e,t,n,i){if(0!==t){for(var r=32767&t,a=t>>>15,s=0,l=0,h=0;h>>15,f=o.__imul(d,r),m=o.__imul(d,a),g=o.__imul(p,r);s=(c+=l+f+s)>>>30,c&=1073741823,s+=(c+=((32767&m)<<15)+((32767&g)<<15))>>>30,l=o.__imul(p,a)+(m>>>15)+(g>>>15),n.__setDigit(i,1073741823&c)}for(;0!==s||0!==l;i++){var v=n.__digit(i);v+=s+l,l=0,s=v>>>30,n.__setDigit(i,1073741823&v)}}}},{key:"__internalMultiplyAdd",value:function(e,t,n,i,r){for(var a=n,s=0,l=0;l>>15,t),d=c+((32767&u)<<15)+s+a;a=d>>>30,s=u>>>15,r.__setDigit(l,1073741823&d)}if(r.length>i)for(r.__setDigit(i++,a+s);i>>0,s=0|a/t,l=0|(a=((i=0|a%t)<<15|e.__halfDigit(r-1))>>>0)/t;i=0|a%t,n.__setDigit(r>>>1,s<<15|l)}return n}},{key:"__absoluteModSmall",value:function(e,t){for(var n=0,i=2*e.length-1;0<=i;i--)n=0|((n<<15|e.__halfDigit(i))>>>0)%t;return n}},{key:"__absoluteDivLarge",value:function(e,t,n,i){var r=t.__halfDigitLength(),a=t.length,s=e.__halfDigitLength()-r,l=null;n&&(l=new o(s+2>>>1,!1)).__initializeDigits();var h=new o(r+2>>>1,!1);h.__initializeDigits();var c=o.__clz15(t.__halfDigit(r-1));0>>0;m=0|v/d;for(var y=0|v%d,x=t.__halfDigit(r-2),b=u.__halfDigit(f+r-2);o.__imul(m,x)>>>0>(y<<16|b)>>>0&&(m--,!(32767<(y+=d))););}o.__internalMultiplyAdd(t,m,0,a,h);var _=u.__inplaceSub(h,f,r+1);0!==_&&(_=u.__inplaceAdd(t,f,r),u.__setHalfDigit(f+r,32767&u.__halfDigit(f+r)+_),m--),n&&(1&f?p=m<<15:l.__setDigit(f>>>1,p|m))}if(i)return u.__inplaceRightShift(c),n?{quotient:l,remainder:u}:u;if(n)return l;throw new Error("unreachable")}},{key:"__clz15",value:function(e){return o.__clz30(e)-15}},{key:"__specialLeftShift",value:function(e,t,n){var i=e.length,r=new o(i+n,!1);if(0===t){for(var a=0;a>>30-t;return 0n)throw new RangeError("BigInt too big");var i=0|n/30,r=n%30,a=e.length,s=0!==r&&e.__digit(a-1)>>>30-r!=0,l=a+i+(s?1:0),h=new o(l,e.sign);if(0===r){for(var c=0;c>>30-r;if(s)h.__setDigit(a+i,u);else if(0!==u)throw new Error("implementation bug")}return h.__trim()}},{key:"__rightShiftByAbsolute",value:function(e,t){var n=e.length,i=e.sign,r=o.__toShiftAmount(t);if(0>r)return o.__rightShiftByMaximum(i);var a=0|r/30,s=r%30,l=n-a;if(0>=l)return o.__rightShiftByMaximum(i);var h=!1;if(i)if(e.__digit(a)&(1<>>s,m=n-a-1,g=0;g>>s;u.__setDigit(m,f)}return h&&(u=o.__absoluteAddOne(u,!0,u)),u.__trim()}},{key:"__rightShiftByMaximum",value:function(e){return e?o.__oneDigit(1,!0):o.__zero()}},{key:"__toShiftAmount",value:function(e){if(1o.__kMaxLengthBits?-1:t}},{key:"__toPrimitive",value:function(e){var t=1>>l}return i.__setDigit(r,s),i.__trim()}},{key:"__truncateAndSubFromPowerOfTwo",value:function(e,t,n){for(var i,r=Math.min,a=0|(e+29)/30,s=new o(a,n),l=0,h=a-1,c=0,u=r(h,t.length);l>>30,s.__setDigit(l,1073741823&i);for(;l>>m)-c,d&=g-1}return s.__setDigit(h,d),s.__trim()}},{key:"__digitPow",value:function(e,t){for(var n=1;0>>=1,e*=e;return n}},{key:"__isOneDigitInt",value:function(e){return(1073741823&e)===e}}]),o}(l(Array));return f.__kMaxLength=33554432,f.__kMaxLengthBits=f.__kMaxLength<<5,f.__kMaxBitsPerChar=[0,0,32,51,64,75,83,90,96,102,107,111,115,119,122,126,128,131,134,136,139,141,143,145,147,149,151,153,154,156,158,159,160,162,163,165,166],f.__kBitsPerCharTableShift=5,f.__kBitsPerCharTableMultiplier=1<>>0)/t)},f.__imul=e||function(e,t){return 0|e*t},f},"object"==typeof e&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define(i):(n=n||self).JSBI=i()})),Fl=J(((e,t)=>{(function(){var n,i="Expected a function",r="__lodash_hash_undefined__",a="__lodash_placeholder__",s=32,o=128,l=1/0,h=9007199254740991,c=NaN,u=4294967295,d=[["ary",o],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",s],["partialRight",64],["rearg",256]],p="[object Arguments]",f="[object Array]",m="[object Boolean]",g="[object Date]",v="[object Error]",y="[object Function]",x="[object GeneratorFunction]",b="[object Map]",_="[object Number]",w="[object Object]",S="[object Promise]",M="[object RegExp]",E="[object Set]",T="[object String]",A="[object Symbol]",C="[object WeakMap]",P="[object ArrayBuffer]",R="[object DataView]",O="[object Float32Array]",L="[object Float64Array]",I="[object Int8Array]",D="[object Int16Array]",k="[object Int32Array]",N="[object Uint8Array]",F="[object Uint8ClampedArray]",U="[object Uint16Array]",B="[object Uint32Array]",z=/\b__p \+= '';/g,H=/\b(__p \+=) '' \+/g,V=/(__e\(.*?\)|\b__t\)) \+\n'';/g,j=/&(?:amp|lt|gt|quot|#39);/g,G=/[&<>"']/g,W=RegExp(j.source),X=RegExp(G.source),Y=/<%-([\s\S]+?)%>/g,q=/<%([\s\S]+?)%>/g,J=/<%=([\s\S]+?)%>/g,Z=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,K=/^\w*$/,$=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Q=/[\\^$.*+?()[\]{}|]/g,ee=RegExp(Q.source),te=/^\s+/,ne=/\s/,ie=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,re=/\{\n\/\* \[wrapped with (.+)\] \*/,ae=/,? & /,se=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,oe=/[()=,{}\[\]\/\s]/,le=/\\(\\)?/g,he=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ce=/\w*$/,ue=/^[-+]0x[0-9a-f]+$/i,de=/^0b[01]+$/i,pe=/^\[object .+?Constructor\]$/,fe=/^0o[0-7]+$/i,me=/^(?:0|[1-9]\d*)$/,ge=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ve=/($^)/,ye=/['\n\r\u2028\u2029\\]/g,xe="\\ud800-\\udfff",be="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",_e="\\u2700-\\u27bf",we="a-z\\xdf-\\xf6\\xf8-\\xff",Se="A-Z\\xc0-\\xd6\\xd8-\\xde",Me="\\ufe0e\\ufe0f",Ee="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Te="["+xe+"]",Ae="["+Ee+"]",Ce="["+be+"]",Pe="\\d+",Re="["+_e+"]",Oe="["+we+"]",Le="[^"+xe+Ee+Pe+_e+we+Se+"]",Ie="\\ud83c[\\udffb-\\udfff]",De="[^"+xe+"]",ke="(?:\\ud83c[\\udde6-\\uddff]){2}",Ne="[\\ud800-\\udbff][\\udc00-\\udfff]",Fe="["+Se+"]",Ue="\\u200d",Be="(?:"+Oe+"|"+Le+")",ze="(?:"+Fe+"|"+Le+")",He="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",Ve="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",je="(?:"+Ce+"|"+Ie+")?",Ge="["+Me+"]?",We=Ge+je+"(?:"+Ue+"(?:"+[De,ke,Ne].join("|")+")"+Ge+je+")*",Xe="(?:"+[Re,ke,Ne].join("|")+")"+We,Ye="(?:"+[De+Ce+"?",Ce,ke,Ne,Te].join("|")+")",qe=RegExp("['\u2019]","g"),Je=RegExp(Ce,"g"),Ze=RegExp(Ie+"(?="+Ie+")|"+Ye+We,"g"),Ke=RegExp([Fe+"?"+Oe+"+"+He+"(?="+[Ae,Fe,"$"].join("|")+")",ze+"+"+Ve+"(?="+[Ae,Fe+Be,"$"].join("|")+")",Fe+"?"+Be+"+"+He,Fe+"+"+Ve,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Pe,Xe].join("|"),"g"),$e=RegExp("["+Ue+xe+be+Me+"]"),Qe=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,et=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],tt=-1,nt={};nt[O]=nt[L]=nt[I]=nt[D]=nt[k]=nt[N]=nt[F]=nt[U]=nt[B]=!0,nt[p]=nt[f]=nt[P]=nt[m]=nt[R]=nt[g]=nt[v]=nt[y]=nt[b]=nt[_]=nt[w]=nt[M]=nt[E]=nt[T]=nt[C]=!1;var it={};it[p]=it[f]=it[P]=it[R]=it[m]=it[g]=it[O]=it[L]=it[I]=it[D]=it[k]=it[b]=it[_]=it[w]=it[M]=it[E]=it[T]=it[A]=it[N]=it[F]=it[U]=it[B]=!0,it[v]=it[y]=it[C]=!1;var rt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},at=parseFloat,st=parseInt,ot="object"==typeof global&&global&&global.Object===Object&&global,lt="object"==typeof self&&self&&self.Object===Object&&self,ht=ot||lt||Function("return this")(),ct="object"==typeof e&&e&&!e.nodeType&&e,ut=ct&&"object"==typeof t&&t&&!t.nodeType&&t,dt=ut&&ut.exports===ct,pt=dt&&ot.process,ft=function(){try{return ut&&ut.require&&ut.require("util").types||pt&&pt.binding&&pt.binding("util")}catch(e){}}(),mt=ft&&ft.isArrayBuffer,gt=ft&&ft.isDate,vt=ft&&ft.isMap,yt=ft&&ft.isRegExp,xt=ft&&ft.isSet,bt=ft&&ft.isTypedArray;function _t(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function wt(e,t,n,i){for(var r=-1,a=null==e?0:e.length;++r-1}function Ct(e,t,n){for(var i=-1,r=null==e?0:e.length;++i-1;);return n}function Kt(e,t){for(var n=e.length;n--&&Ft(t,e[n],0)>-1;);return n}var $t=Vt({"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss","\u0100":"A","\u0102":"A","\u0104":"A","\u0101":"a","\u0103":"a","\u0105":"a","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u010e":"D","\u0110":"D","\u010f":"d","\u0111":"d","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g","\u0124":"H","\u0126":"H","\u0125":"h","\u0127":"h","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u0131":"i","\u0134":"J","\u0135":"j","\u0136":"K","\u0137":"k","\u0138":"k","\u0139":"L","\u013b":"L","\u013d":"L","\u013f":"L","\u0141":"L","\u013a":"l","\u013c":"l","\u013e":"l","\u0140":"l","\u0142":"l","\u0143":"N","\u0145":"N","\u0147":"N","\u014a":"N","\u0144":"n","\u0146":"n","\u0148":"n","\u014b":"n","\u014c":"O","\u014e":"O","\u0150":"O","\u014d":"o","\u014f":"o","\u0151":"o","\u0154":"R","\u0156":"R","\u0158":"R","\u0155":"r","\u0157":"r","\u0159":"r","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0162":"T","\u0164":"T","\u0166":"T","\u0163":"t","\u0165":"t","\u0167":"t","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u017a":"z","\u017c":"z","\u017e":"z","\u0132":"IJ","\u0133":"ij","\u0152":"Oe","\u0153":"oe","\u0149":"'n","\u017f":"s"}),Qt=Vt({"&":"&","<":"<",">":">",'"':""","'":"'"});function en(e){return"\\"+rt[e]}function tn(e){return $e.test(e)}function nn(e){var t=-1,n=Array(e.size);return e.forEach((function(e,i){n[++t]=[i,e]})),n}function rn(e,t){return function(n){return e(t(n))}}function an(e,t){for(var n=-1,i=e.length,r=0,s=[];++n",""":'"',"'":"'"}),un=function e(t){var ne,xe=(t=null==t?ht:un.defaults(ht.Object(),t,un.pick(ht,et))).Array,be=t.Date,_e=t.Error,we=t.Function,Se=t.Math,Me=t.Object,Ee=t.RegExp,Te=t.String,Ae=t.TypeError,Ce=xe.prototype,Pe=we.prototype,Re=Me.prototype,Oe=t["__core-js_shared__"],Le=Pe.toString,Ie=Re.hasOwnProperty,De=0,ke=(ne=/[^.]+$/.exec(Oe&&Oe.keys&&Oe.keys.IE_PROTO||""))?"Symbol(src)_1."+ne:"",Ne=Re.toString,Fe=Le.call(Me),Ue=ht._,Be=Ee("^"+Le.call(Ie).replace(Q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ze=dt?t.Buffer:n,He=t.Symbol,Ve=t.Uint8Array,je=ze?ze.allocUnsafe:n,Ge=rn(Me.getPrototypeOf,Me),We=Me.create,Xe=Re.propertyIsEnumerable,Ye=Ce.splice,Ze=He?He.isConcatSpreadable:n,$e=He?He.iterator:n,rt=He?He.toStringTag:n,ot=function(){try{var e=oa(Me,"defineProperty");return e({},"",{}),e}catch(e){}}(),lt=t.clearTimeout!==ht.clearTimeout&&t.clearTimeout,ct=be&&be.now!==ht.Date.now&&be.now,ut=t.setTimeout!==ht.setTimeout&&t.setTimeout,pt=Se.ceil,ft=Se.floor,Dt=Me.getOwnPropertySymbols,Vt=ze?ze.isBuffer:n,dn=t.isFinite,pn=Ce.join,fn=rn(Me.keys,Me),mn=Se.max,gn=Se.min,vn=be.now,yn=t.parseInt,xn=Se.random,bn=Ce.reverse,_n=oa(t,"DataView"),wn=oa(t,"Map"),Sn=oa(t,"Promise"),Mn=oa(t,"Set"),En=oa(t,"WeakMap"),Tn=oa(Me,"create"),An=En&&new En,Cn={},Pn=Ia(_n),Rn=Ia(wn),On=Ia(Sn),Ln=Ia(Mn),In=Ia(En),Dn=He?He.prototype:n,kn=Dn?Dn.valueOf:n,Nn=Dn?Dn.toString:n;function Fn(e){if(Zs(e)&&!Bs(e)&&!(e instanceof Hn)){if(e instanceof zn)return e;if(Ie.call(e,"__wrapped__"))return Da(e)}return new zn(e)}var Un=function(){function e(){}return function(t){if(!Js(t))return{};if(We)return We(t);e.prototype=t;var i=new e;return e.prototype=n,i}}();function Bn(){}function zn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=n}function Hn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=u,this.__views__=[]}function Vn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function ai(e,t,i,r,a,s){var o,l=1&t,h=2&t,c=4&t;if(i&&(o=a?i(e,r,a,s):i(e)),o!==n)return o;if(!Js(e))return e;var u=Bs(e);if(u){if(o=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&Ie.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!l)return Er(e,o)}else{var d=ca(e),f=d==y||d==x;if(js(e))return xr(e,l);if(d==w||d==p||f&&!a){if(o=h||f?{}:da(e),!l)return h?function(e,t){return Tr(e,ha(e),t)}(e,function(e,t){return e&&Tr(t,Co(t),e)}(o,e)):function(e,t){return Tr(e,la(e),t)}(e,ti(o,e))}else{if(!it[d])return a?e:{};o=function(e,t,n){var i=e.constructor;switch(t){case P:return br(e);case m:case g:return new i(+e);case R:return function(e,t){var n=t?br(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case O:case L:case I:case D:case k:case N:case F:case U:case B:return _r(e,n);case b:return new i;case _:case T:return new i(e);case M:return function(e){var t=new e.constructor(e.source,ce.exec(e));return t.lastIndex=e.lastIndex,t}(e);case E:return new i;case A:return function(e){return kn?Me(kn.call(e)):{}}(e)}}(e,d,l)}}s||(s=new Xn);var v=s.get(e);if(v)return v;s.set(e,o),to(e)?e.forEach((function(n){o.add(ai(n,t,i,n,e,s))})):Ks(e)&&e.forEach((function(n,r){o.set(r,ai(n,t,i,r,e,s))}));var S=u?n:(c?h?ea:Qr:h?Co:Ao)(e);return St(S||e,(function(n,r){S&&(n=e[r=n]),$n(o,r,ai(n,t,i,r,e,s))})),o}function si(e,t,i){var r=i.length;if(null==e)return!r;for(e=Me(e);r--;){var a=i[r],s=t[a],o=e[a];if(o===n&&!(a in e)||!s(o))return!1}return!0}function oi(e,t,r){if("function"!=typeof e)throw new Ae(i);return Ta((function(){e.apply(n,r)}),t)}function li(e,t,n,i){var r=-1,a=At,s=!0,o=e.length,l=[],h=t.length;if(!o)return l;n&&(t=Pt(t,Yt(n))),i?(a=Ct,s=!1):t.length>=200&&(a=Jt,s=!1,t=new Wn(t));e:for(;++r-1},jn.prototype.set=function(e,t){var n=this.__data__,i=Qn(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this},Gn.prototype.clear=function(){this.size=0,this.__data__={hash:new Vn,map:new(wn||jn),string:new Vn}},Gn.prototype.delete=function(e){var t=aa(this,e).delete(e);return this.size-=t?1:0,t},Gn.prototype.get=function(e){return aa(this,e).get(e)},Gn.prototype.has=function(e){return aa(this,e).has(e)},Gn.prototype.set=function(e,t){var n=aa(this,e),i=n.size;return n.set(e,t),this.size+=n.size==i?0:1,this},Wn.prototype.add=Wn.prototype.push=function(e){return this.__data__.set(e,r),this},Wn.prototype.has=function(e){return this.__data__.has(e)},Xn.prototype.clear=function(){this.__data__=new jn,this.size=0},Xn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Xn.prototype.get=function(e){return this.__data__.get(e)},Xn.prototype.has=function(e){return this.__data__.has(e)},Xn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof jn){var i=n.__data__;if(!wn||i.length<199)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new Gn(i)}return n.set(e,t),this.size=n.size,this};var hi=Pr(vi),ci=Pr(yi,!0);function ui(e,t){var n=!0;return hi(e,(function(e,i,r){return n=!!t(e,i,r)})),n}function di(e,t,i){for(var r=-1,a=e.length;++r0&&n(o)?t>1?fi(o,t-1,n,i,r):Rt(r,o):i||(r[r.length]=o)}return r}var mi=Rr(),gi=Rr(!0);function vi(e,t){return e&&mi(e,t,Ao)}function yi(e,t){return e&&gi(e,t,Ao)}function xi(e,t){return Tt(t,(function(t){return Xs(e[t])}))}function bi(e,t){for(var i=0,r=(t=mr(t,e)).length;null!=e&&it}function Mi(e,t){return null!=e&&Ie.call(e,t)}function Ei(e,t){return null!=e&&t in Me(e)}function Ti(e,t,i){for(var r=i?Ct:At,a=e[0].length,s=e.length,o=s,l=xe(s),h=1/0,c=[];o--;){var u=e[o];o&&t&&(u=Pt(u,Yt(t))),h=gn(u.length,h),l[o]=!i&&(t||a>=120&&u.length>=120)?new Wn(o&&u):n}u=e[0];var d=-1,p=l[0];e:for(;++d=o?l:l*("desc"==n[i]?-1:1)}return e.index-t.index}(e,t,n)}))}function Hi(e,t,n){for(var i=-1,r=t.length,a={};++i-1;)o!==e&&Ye.call(o,l,1),Ye.call(e,l,1);return e}function ji(e,t){for(var n=e?t.length:0,i=n-1;n--;){var r=t[n];if(n==i||r!==a){var a=r;fa(r)?Ye.call(e,r,1):or(e,r)}}return e}function Gi(e,t){return e+ft(xn()*(t-e+1))}function Wi(e,t){var n="";if(!e||t<1||t>h)return n;do{t%2&&(n+=e),(t=ft(t/2))&&(e+=e)}while(t);return n}function Xi(e,t){return Aa(wa(e,t,Qo),e+"")}function Yi(e){return qn(No(e))}function qi(e,t){var n=No(e);return Ra(n,ri(t,0,n.length))}function Ji(e,t,i,r){if(!Js(e))return e;for(var a=-1,s=(t=mr(t,e)).length,o=s-1,l=e;null!=l&&++ar?0:r+t),(n=n>r?r:n)<0&&(n+=r),r=t>n?0:n-t>>>0,t>>>=0;for(var a=xe(r);++i>>1,s=e[a];null!==s&&!io(s)&&(n?s<=t:s=200){var h=t?null:Wr(e);if(h)return sn(h);s=!1,r=Jt,l=new Wn}else l=t?[]:o;e:for(;++i=r?e:Qi(e,t,i)}var yr=lt||function(e){return ht.clearTimeout(e)};function xr(e,t){if(t)return e.slice();var n=e.length,i=je?je(n):new e.constructor(n);return e.copy(i),i}function br(e){var t=new e.constructor(e.byteLength);return new Ve(t).set(new Ve(e)),t}function _r(e,t){var n=t?br(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function wr(e,t){if(e!==t){var i=e!==n,r=null===e,a=e==e,s=io(e),o=t!==n,l=null===t,h=t==t,c=io(t);if(!l&&!c&&!s&&e>t||s&&o&&h&&!l&&!c||r&&o&&h||!i&&h||!a)return 1;if(!r&&!s&&!c&&e1?i[a-1]:n,o=a>2?i[2]:n;for(s=e.length>3&&"function"==typeof s?(a--,s):n,o&&ma(i[0],i[1],o)&&(s=a<3?n:s,a=1),t=Me(t);++r-1?a[s?t[o]:o]:n}}function kr(e){return $r((function(t){var r=t.length,a=r,s=zn.prototype.thru;for(e&&t.reverse();a--;){var o=t[a];if("function"!=typeof o)throw new Ae(i);if(s&&!l&&"wrapper"==na(o))var l=new zn([],!0)}for(a=l?a:r;++a1&&x.reverse(),d&&cl))return!1;var c=s.get(e),u=s.get(t);if(c&&u)return c==t&&u==e;var d=-1,p=!0,f=2&i?new Wn:n;for(s.set(e,t),s.set(t,e);++d-1&&e%1==0&&e1?"& ":"")+t[i],t=t.join(n>2?", ":" "),e.replace(ie,"{\n/* [wrapped with "+t+"] */\n")}(i,function(e,t){return St(d,(function(n){var i="_."+n[0];t&n[1]&&!At(e,i)&&e.push(i)})),e.sort()}(function(e){var t=e.match(re);return t?t[1].split(ae):[]}(i),n)))}function Pa(e){var t=0,i=0;return function(){var r=vn(),a=16-(r-i);if(i=r,a>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(n,arguments)}}function Ra(e,t){var i=-1,r=e.length,a=r-1;for(t=t===n?r:t;++i1?e[t-1]:n;return i="function"==typeof i?(e.pop(),i):n,es(e,i)}));function os(e){var t=Fn(e);return t.__chain__=!0,t}function ls(e,t){return t(e)}var hs=$r((function(e){var t=e.length,i=t?e[0]:0,r=this.__wrapped__,a=function(t){return ii(t,e)};return!(t>1||this.__actions__.length)&&r instanceof Hn&&fa(i)?((r=r.slice(i,+i+(t?1:0))).__actions__.push({func:ls,args:[a],thisArg:n}),new zn(r,this.__chain__).thru((function(e){return t&&!e.length&&e.push(n),e}))):this.thru(a)})),cs=Ar((function(e,t,n){Ie.call(e,n)?++e[n]:ni(e,n,1)})),us=Dr(Ua),ds=Dr(Ba);function ps(e,t){return(Bs(e)?St:hi)(e,ra(t,3))}function fs(e,t){return(Bs(e)?Mt:ci)(e,ra(t,3))}var ms=Ar((function(e,t,n){Ie.call(e,n)?e[n].push(t):ni(e,n,[t])})),gs=Xi((function(e,t,n){var i=-1,r="function"==typeof t,a=Hs(e)?xe(e.length):[];return hi(e,(function(e){a[++i]=r?_t(t,e,n):Ai(e,t,n)})),a})),vs=Ar((function(e,t,n){ni(e,n,t)}));function ys(e,t){return(Bs(e)?Pt:ki)(e,ra(t,3))}var xs=Ar((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]})),bs=Xi((function(e,t){if(null==e)return[];var n=t.length;return n>1&&ma(e,t[0],t[1])?t=[]:n>2&&ma(t[0],t[1],t[2])&&(t=[t[0]]),zi(e,fi(t,1),[])})),_s=ct||function(){return ht.Date.now()};function ws(e,t,i){return t=i?n:t,t=e&&null==t?e.length:t,Yr(e,o,n,n,n,n,t)}function Ss(e,t){var r;if("function"!=typeof t)throw new Ae(i);return e=ho(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=n),r}}var Ms=Xi((function(e,t,n){var i=1;if(n.length){var r=an(n,ia(Ms));i|=s}return Yr(e,i,t,n,r)})),Es=Xi((function(e,t,n){var i=3;if(n.length){var r=an(n,ia(Es));i|=s}return Yr(t,i,e,n,r)}));function Ts(e,t,r){var a,s,o,l,h,c,u=0,d=!1,p=!1,f=!0;if("function"!=typeof e)throw new Ae(i);function m(t){var i=a,r=s;return a=s=n,u=t,l=e.apply(r,i)}function g(e){var i=e-c;return c===n||i>=t||i<0||p&&e-u>=o}function v(){var e=_s();if(g(e))return y(e);h=Ta(v,function(e){var n=t-(e-c);return p?gn(n,o-(e-u)):n}(e))}function y(e){return h=n,f&&a?m(e):(a=s=n,l)}function x(){var e=_s(),i=g(e);if(a=arguments,s=this,c=e,i){if(h===n)return function(e){return u=e,h=Ta(v,t),d?m(e):l}(c);if(p)return yr(h),h=Ta(v,t),m(c)}return h===n&&(h=Ta(v,t)),l}return t=uo(t)||0,Js(r)&&(d=!!r.leading,o=(p="maxWait"in r)?mn(uo(r.maxWait)||0,t):o,f="trailing"in r?!!r.trailing:f),x.cancel=function(){h!==n&&yr(h),u=0,a=c=s=h=n},x.flush=function(){return h===n?l:y(_s())},x}var As=Xi((function(e,t){return oi(e,1,t)})),Cs=Xi((function(e,t,n){return oi(e,uo(t)||0,n)}));function Ps(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ae(i);var n=function(){var i=arguments,r=t?t.apply(this,i):i[0],a=n.cache;if(a.has(r))return a.get(r);var s=e.apply(this,i);return n.cache=a.set(r,s)||a,s};return n.cache=new(Ps.Cache||Gn),n}function Rs(e){if("function"!=typeof e)throw new Ae(i);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Ps.Cache=Gn;var Os=gr((function(e,t){var n=(t=1==t.length&&Bs(t[0])?Pt(t[0],Yt(ra())):Pt(fi(t,1),Yt(ra()))).length;return Xi((function(i){for(var r=-1,a=gn(i.length,n);++r=t})),Us=Ci(function(){return arguments}())?Ci:function(e){return Zs(e)&&Ie.call(e,"callee")&&!Xe.call(e,"callee")},Bs=xe.isArray,zs=mt?Yt(mt):function(e){return Zs(e)&&wi(e)==P};function Hs(e){return null!=e&&qs(e.length)&&!Xs(e)}function Vs(e){return Zs(e)&&Hs(e)}var js=Vt||dl,Gs=gt?Yt(gt):function(e){return Zs(e)&&wi(e)==g};function Ws(e){if(!Zs(e))return!1;var t=wi(e);return t==v||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!Qs(e)}function Xs(e){if(!Js(e))return!1;var t=wi(e);return t==y||t==x||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Ys(e){return"number"==typeof e&&e==ho(e)}function qs(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=h}function Js(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Zs(e){return null!=e&&"object"==typeof e}var Ks=vt?Yt(vt):function(e){return Zs(e)&&ca(e)==b};function $s(e){return"number"==typeof e||Zs(e)&&wi(e)==_}function Qs(e){if(!Zs(e)||wi(e)!=w)return!1;var t=Ge(e);if(null===t)return!0;var n=Ie.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Le.call(n)==Fe}var eo=yt?Yt(yt):function(e){return Zs(e)&&wi(e)==M},to=xt?Yt(xt):function(e){return Zs(e)&&ca(e)==E};function no(e){return"string"==typeof e||!Bs(e)&&Zs(e)&&wi(e)==T}function io(e){return"symbol"==typeof e||Zs(e)&&wi(e)==A}var ro=bt?Yt(bt):function(e){return Zs(e)&&qs(e.length)&&!!nt[wi(e)]},ao=Vr(Di),so=Vr((function(e,t){return e<=t}));function oo(e){if(!e)return[];if(Hs(e))return no(e)?ln(e):Er(e);if($e&&e[$e])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[$e]());var t=ca(e);return(t==b?nn:t==E?sn:No)(e)}function lo(e){return e?(e=uo(e))===l||e===-l?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function ho(e){var t=lo(e),n=t%1;return t==t?n?t-n:t:0}function co(e){return e?ri(ho(e),0,u):0}function uo(e){if("number"==typeof e)return e;if(io(e))return c;if(Js(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Js(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Xt(e);var n=de.test(e);return n||fe.test(e)?st(e.slice(2),n?2:8):ue.test(e)?c:+e}function po(e){return Tr(e,Co(e))}function fo(e){return null==e?"":ar(e)}var mo=Cr((function(e,t){if(xa(t)||Hs(t))Tr(t,Ao(t),e);else for(var n in t)Ie.call(t,n)&&$n(e,n,t[n])})),go=Cr((function(e,t){Tr(t,Co(t),e)})),vo=Cr((function(e,t,n,i){Tr(t,Co(t),e,i)})),yo=Cr((function(e,t,n,i){Tr(t,Ao(t),e,i)})),xo=$r(ii),bo=Xi((function(e,t){e=Me(e);var i=-1,r=t.length,a=r>2?t[2]:n;for(a&&ma(t[0],t[1],a)&&(r=1);++i1),t})),Tr(e,ea(e),n),i&&(n=ai(n,7,Zr));for(var r=t.length;r--;)or(n,t[r]);return n})),Lo=$r((function(e,t){return null==e?{}:function(e,t){return Hi(e,t,(function(t,n){return So(e,n)}))}(e,t)}));function Io(e,t){if(null==e)return{};var n=Pt(ea(e),(function(e){return[e]}));return t=ra(t),Hi(e,n,(function(e,n){return t(e,n[0])}))}var Do=Xr(Ao),ko=Xr(Co);function No(e){return null==e?[]:qt(e,Ao(e))}var Fo=Lr((function(e,t,n){return t=t.toLowerCase(),e+(n?Uo(t):t)}));function Uo(e){return Xo(fo(e).toLowerCase())}function Bo(e){return(e=fo(e))&&e.replace(ge,$t).replace(Je,"")}var zo=Lr((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),Ho=Lr((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),Vo=Or("toLowerCase"),jo=Lr((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()})),Go=Lr((function(e,t,n){return e+(n?" ":"")+Xo(t)})),Wo=Lr((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Xo=Or("toUpperCase");function Yo(e,t,i){return e=fo(e),(t=i?n:t)===n?function(e){return Qe.test(e)}(e)?function(e){return e.match(Ke)||[]}(e):function(e){return e.match(se)||[]}(e):e.match(t)||[]}var qo=Xi((function(e,t){try{return _t(e,n,t)}catch(e){return Ws(e)?e:new _e(e)}})),Jo=$r((function(e,t){return St(t,(function(t){t=La(t),ni(e,t,Ms(e[t],e))})),e}));function Zo(e){return function(){return e}}var Ko=kr(),$o=kr(!0);function Qo(e){return e}function el(e){return Li("function"==typeof e?e:ai(e,1))}var tl=Xi((function(e,t){return function(n){return Ai(n,e,t)}})),nl=Xi((function(e,t){return function(n){return Ai(e,n,t)}}));function il(e,t,n){var i=Ao(t),r=xi(t,i);null==n&&(!Js(t)||!r.length&&i.length)&&(n=t,t=e,e=this,r=xi(t,Ao(t)));var a=!(Js(n)&&"chain"in n&&!n.chain),s=Xs(e);return St(r,(function(n){var i=t[n];e[n]=i,s&&(e.prototype[n]=function(){var t=this.__chain__;if(a||t){var n=e(this.__wrapped__);return(n.__actions__=Er(this.__actions__)).push({func:i,args:arguments,thisArg:e}),n.__chain__=t,n}return i.apply(e,Rt([this.value()],arguments))})})),e}function rl(){}var al=Br(Pt),sl=Br(Et),ol=Br(It);function ll(e){return ga(e)?Ht(La(e)):function(e){return function(t){return bi(t,e)}}(e)}var hl=Hr(),cl=Hr(!0);function ul(){return[]}function dl(){return!1}var pl=Ur((function(e,t){return e+t}),0),fl=Gr("ceil"),ml=Ur((function(e,t){return e/t}),1),gl=Gr("floor"),vl=Ur((function(e,t){return e*t}),1),yl=Gr("round"),xl=Ur((function(e,t){return e-t}),0);return Fn.after=function(e,t){if("function"!=typeof t)throw new Ae(i);return e=ho(e),function(){if(--e<1)return t.apply(this,arguments)}},Fn.ary=ws,Fn.assign=mo,Fn.assignIn=go,Fn.assignInWith=vo,Fn.assignWith=yo,Fn.at=xo,Fn.before=Ss,Fn.bind=Ms,Fn.bindAll=Jo,Fn.bindKey=Es,Fn.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Bs(e)?e:[e]},Fn.chain=os,Fn.chunk=function(e,t,i){t=(i?ma(e,t,i):t===n)?1:mn(ho(t),0);var r=null==e?0:e.length;if(!r||t<1)return[];for(var a=0,s=0,o=xe(pt(r/t));aa?0:a+i),(r=r===n||r>a?a:ho(r))<0&&(r+=a),r=i>r?0:co(r);i>>0)?(e=fo(e))&&("string"==typeof t||null!=t&&!eo(t))&&!(t=ar(t))&&tn(e)?vr(ln(e),0,i):e.split(t,i):[]},Fn.spread=function(e,t){if("function"!=typeof e)throw new Ae(i);return t=null==t?0:mn(ho(t),0),Xi((function(n){var i=n[t],r=vr(n,0,t);return i&&Rt(r,i),_t(e,this,r)}))},Fn.tail=function(e){var t=null==e?0:e.length;return t?Qi(e,1,t):[]},Fn.take=function(e,t,i){return e&&e.length?Qi(e,0,(t=i||t===n?1:ho(t))<0?0:t):[]},Fn.takeRight=function(e,t,i){var r=null==e?0:e.length;return r?Qi(e,(t=r-(t=i||t===n?1:ho(t)))<0?0:t,r):[]},Fn.takeRightWhile=function(e,t){return e&&e.length?hr(e,ra(t,3),!1,!0):[]},Fn.takeWhile=function(e,t){return e&&e.length?hr(e,ra(t,3)):[]},Fn.tap=function(e,t){return t(e),e},Fn.throttle=function(e,t,n){var r=!0,a=!0;if("function"!=typeof e)throw new Ae(i);return Js(n)&&(r="leading"in n?!!n.leading:r,a="trailing"in n?!!n.trailing:a),Ts(e,t,{leading:r,maxWait:t,trailing:a})},Fn.thru=ls,Fn.toArray=oo,Fn.toPairs=Do,Fn.toPairsIn=ko,Fn.toPath=function(e){return Bs(e)?Pt(e,La):io(e)?[e]:Er(Oa(fo(e)))},Fn.toPlainObject=po,Fn.transform=function(e,t,n){var i=Bs(e),r=i||js(e)||ro(e);if(t=ra(t,4),null==n){var a=e&&e.constructor;n=r?i?new a:[]:Js(e)&&Xs(a)?Un(Ge(e)):{}}return(r?St:vi)(e,(function(e,i,r){return t(n,e,i,r)})),n},Fn.unary=function(e){return ws(e,1)},Fn.union=Za,Fn.unionBy=Ka,Fn.unionWith=$a,Fn.uniq=function(e){return e&&e.length?sr(e):[]},Fn.uniqBy=function(e,t){return e&&e.length?sr(e,ra(t,2)):[]},Fn.uniqWith=function(e,t){return t="function"==typeof t?t:n,e&&e.length?sr(e,n,t):[]},Fn.unset=function(e,t){return null==e||or(e,t)},Fn.unzip=Qa,Fn.unzipWith=es,Fn.update=function(e,t,n){return null==e?e:lr(e,t,fr(n))},Fn.updateWith=function(e,t,i,r){return r="function"==typeof r?r:n,null==e?e:lr(e,t,fr(i),r)},Fn.values=No,Fn.valuesIn=function(e){return null==e?[]:qt(e,Co(e))},Fn.without=ts,Fn.words=Yo,Fn.wrap=function(e,t){return Ls(fr(t),e)},Fn.xor=ns,Fn.xorBy=is,Fn.xorWith=rs,Fn.zip=as,Fn.zipObject=function(e,t){return dr(e||[],t||[],$n)},Fn.zipObjectDeep=function(e,t){return dr(e||[],t||[],Ji)},Fn.zipWith=ss,Fn.entries=Do,Fn.entriesIn=ko,Fn.extend=go,Fn.extendWith=vo,il(Fn,Fn),Fn.add=pl,Fn.attempt=qo,Fn.camelCase=Fo,Fn.capitalize=Uo,Fn.ceil=fl,Fn.clamp=function(e,t,i){return i===n&&(i=t,t=n),i!==n&&(i=(i=uo(i))==i?i:0),t!==n&&(t=(t=uo(t))==t?t:0),ri(uo(e),t,i)},Fn.clone=function(e){return ai(e,4)},Fn.cloneDeep=function(e){return ai(e,5)},Fn.cloneDeepWith=function(e,t){return ai(e,5,t="function"==typeof t?t:n)},Fn.cloneWith=function(e,t){return ai(e,4,t="function"==typeof t?t:n)},Fn.conformsTo=function(e,t){return null==t||si(e,t,Ao(t))},Fn.deburr=Bo,Fn.defaultTo=function(e,t){return null==e||e!=e?t:e},Fn.divide=ml,Fn.endsWith=function(e,t,i){e=fo(e),t=ar(t);var r=e.length,a=i=i===n?r:ri(ho(i),0,r);return(i-=t.length)>=0&&e.slice(i,a)==t},Fn.eq=ks,Fn.escape=function(e){return(e=fo(e))&&X.test(e)?e.replace(G,Qt):e},Fn.escapeRegExp=function(e){return(e=fo(e))&&ee.test(e)?e.replace(Q,"\\$&"):e},Fn.every=function(e,t,i){var r=Bs(e)?Et:ui;return i&&ma(e,t,i)&&(t=n),r(e,ra(t,3))},Fn.find=us,Fn.findIndex=Ua,Fn.findKey=function(e,t){return kt(e,ra(t,3),vi)},Fn.findLast=ds,Fn.findLastIndex=Ba,Fn.findLastKey=function(e,t){return kt(e,ra(t,3),yi)},Fn.floor=gl,Fn.forEach=ps,Fn.forEachRight=fs,Fn.forIn=function(e,t){return null==e?e:mi(e,ra(t,3),Co)},Fn.forInRight=function(e,t){return null==e?e:gi(e,ra(t,3),Co)},Fn.forOwn=function(e,t){return e&&vi(e,ra(t,3))},Fn.forOwnRight=function(e,t){return e&&yi(e,ra(t,3))},Fn.get=wo,Fn.gt=Ns,Fn.gte=Fs,Fn.has=function(e,t){return null!=e&&ua(e,t,Mi)},Fn.hasIn=So,Fn.head=Ha,Fn.identity=Qo,Fn.includes=function(e,t,n,i){e=Hs(e)?e:No(e),n=n&&!i?ho(n):0;var r=e.length;return n<0&&(n=mn(r+n,0)),no(e)?n<=r&&e.indexOf(t,n)>-1:!!r&&Ft(e,t,n)>-1},Fn.indexOf=function(e,t,n){var i=null==e?0:e.length;if(!i)return-1;var r=null==n?0:ho(n);return r<0&&(r=mn(i+r,0)),Ft(e,t,r)},Fn.inRange=function(e,t,i){return t=lo(t),i===n?(i=t,t=0):i=lo(i),function(e,t,n){return e>=gn(t,n)&&e=-h&&e<=h},Fn.isSet=to,Fn.isString=no,Fn.isSymbol=io,Fn.isTypedArray=ro,Fn.isUndefined=function(e){return e===n},Fn.isWeakMap=function(e){return Zs(e)&&ca(e)==C},Fn.isWeakSet=function(e){return Zs(e)&&"[object WeakSet]"==wi(e)},Fn.join=function(e,t){return null==e?"":pn.call(e,t)},Fn.kebabCase=zo,Fn.last=Wa,Fn.lastIndexOf=function(e,t,i){var r=null==e?0:e.length;if(!r)return-1;var a=r;return i!==n&&(a=(a=ho(i))<0?mn(r+a,0):gn(a,r-1)),t==t?function(e,t,n){for(var i=n+1;i--;)if(e[i]===t)return i;return i}(e,t,a):Nt(e,Bt,a,!0)},Fn.lowerCase=Ho,Fn.lowerFirst=Vo,Fn.lt=ao,Fn.lte=so,Fn.max=function(e){return e&&e.length?di(e,Qo,Si):n},Fn.maxBy=function(e,t){return e&&e.length?di(e,ra(t,2),Si):n},Fn.mean=function(e){return zt(e,Qo)},Fn.meanBy=function(e,t){return zt(e,ra(t,2))},Fn.min=function(e){return e&&e.length?di(e,Qo,Di):n},Fn.minBy=function(e,t){return e&&e.length?di(e,ra(t,2),Di):n},Fn.stubArray=ul,Fn.stubFalse=dl,Fn.stubObject=function(){return{}},Fn.stubString=function(){return""},Fn.stubTrue=function(){return!0},Fn.multiply=vl,Fn.nth=function(e,t){return e&&e.length?Bi(e,ho(t)):n},Fn.noConflict=function(){return ht._===this&&(ht._=Ue),this},Fn.noop=rl,Fn.now=_s,Fn.pad=function(e,t,n){e=fo(e);var i=(t=ho(t))?on(e):0;if(!t||i>=t)return e;var r=(t-i)/2;return zr(ft(r),n)+e+zr(pt(r),n)},Fn.padEnd=function(e,t,n){e=fo(e);var i=(t=ho(t))?on(e):0;return t&&it){var r=e;e=t,t=r}if(i||e%1||t%1){var a=xn();return gn(e+a*(t-e+at("1e-"+((a+"").length-1))),t)}return Gi(e,t)},Fn.reduce=function(e,t,n){var i=Bs(e)?Ot:jt,r=arguments.length<3;return i(e,ra(t,4),n,r,hi)},Fn.reduceRight=function(e,t,n){var i=Bs(e)?Lt:jt,r=arguments.length<3;return i(e,ra(t,4),n,r,ci)},Fn.repeat=function(e,t,i){return t=(i?ma(e,t,i):t===n)?1:ho(t),Wi(fo(e),t)},Fn.replace=function(){var e=arguments,t=fo(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Fn.result=function(e,t,i){var r=-1,a=(t=mr(t,e)).length;for(a||(a=1,e=n);++rh)return[];var n=u,i=gn(e,u);t=ra(t),e-=u;for(var r=Wt(i,t);++n=s)return e;var l=i-on(r);if(l<1)return r;var h=o?vr(o,0,l).join(""):e.slice(0,l);if(a===n)return h+r;if(o&&(l+=h.length-l),eo(a)){if(e.slice(l).search(a)){var c,u=h;for(a.global||(a=Ee(a.source,fo(ce.exec(a))+"g")),a.lastIndex=0;c=a.exec(u);)var d=c.index;h=h.slice(0,d===n?l:d)}}else if(e.indexOf(ar(a),l)!=l){var p=h.lastIndexOf(a);p>-1&&(h=h.slice(0,p))}return h+r},Fn.unescape=function(e){return(e=fo(e))&&W.test(e)?e.replace(j,cn):e},Fn.uniqueId=function(e){var t=++De;return fo(e)+t},Fn.upperCase=Wo,Fn.upperFirst=Xo,Fn.each=ps,Fn.eachRight=fs,Fn.first=Ha,il(Fn,function(){var e={};return vi(Fn,(function(t,n){Ie.call(Fn.prototype,n)||(e[n]=t)})),e}(),{chain:!1}),Fn.VERSION="4.17.21",St(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Fn[e].placeholder=Fn})),St(["drop","take"],(function(e,t){Hn.prototype[e]=function(i){i=i===n?1:mn(ho(i),0);var r=this.__filtered__&&!t?new Hn(this):this.clone();return r.__filtered__?r.__takeCount__=gn(i,r.__takeCount__):r.__views__.push({size:gn(i,u),type:e+(r.__dir__<0?"Right":"")}),r},Hn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),St(["filter","map","takeWhile"],(function(e,t){var n=t+1,i=1==n||3==n;Hn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:ra(e,3),type:n}),t.__filtered__=t.__filtered__||i,t}})),St(["head","last"],(function(e,t){var n="take"+(t?"Right":"");Hn.prototype[e]=function(){return this[n](1).value()[0]}})),St(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");Hn.prototype[e]=function(){return this.__filtered__?new Hn(this):this[n](1)}})),Hn.prototype.compact=function(){return this.filter(Qo)},Hn.prototype.find=function(e){return this.filter(e).head()},Hn.prototype.findLast=function(e){return this.reverse().find(e)},Hn.prototype.invokeMap=Xi((function(e,t){return"function"==typeof e?new Hn(this):this.map((function(n){return Ai(n,e,t)}))})),Hn.prototype.reject=function(e){return this.filter(Rs(ra(e)))},Hn.prototype.slice=function(e,t){e=ho(e);var i=this;return i.__filtered__&&(e>0||t<0)?new Hn(i):(e<0?i=i.takeRight(-e):e&&(i=i.drop(e)),t!==n&&(i=(t=ho(t))<0?i.dropRight(-t):i.take(t-e)),i)},Hn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Hn.prototype.toArray=function(){return this.take(u)},vi(Hn.prototype,(function(e,t){var i=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),a=Fn[r?"take"+("last"==t?"Right":""):t],s=r||/^find/.test(t);a&&(Fn.prototype[t]=function(){var t=this.__wrapped__,o=r?[1]:arguments,l=t instanceof Hn,h=o[0],c=l||Bs(t),u=function(e){var t=a.apply(Fn,Rt([e],o));return r&&d?t[0]:t};c&&i&&"function"==typeof h&&1!=h.length&&(l=c=!1);var d=this.__chain__,p=!!this.__actions__.length,f=s&&!d,m=l&&!p;if(!s&&c){t=m?t:new Hn(this);var g=e.apply(t,o);return g.__actions__.push({func:ls,args:[u],thisArg:n}),new zn(g,d)}return f&&m?e.apply(this,o):(g=this.thru(u),f?r?g.value()[0]:g.value():g)})})),St(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Ce[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);Fn.prototype[e]=function(){var e=arguments;if(i&&!this.__chain__){var r=this.value();return t.apply(Bs(r)?r:[],e)}return this[n]((function(n){return t.apply(Bs(n)?n:[],e)}))}})),vi(Hn.prototype,(function(e,t){var n=Fn[t];if(n){var i=n.name+"";Ie.call(Cn,i)||(Cn[i]=[]),Cn[i].push({name:t,func:n})}})),Cn[Nr(n,2).name]=[{name:"wrapper",func:n}],Hn.prototype.clone=function(){var e=new Hn(this.__wrapped__);return e.__actions__=Er(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Er(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Er(this.__views__),e},Hn.prototype.reverse=function(){if(this.__filtered__){var e=new Hn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Hn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Bs(e),i=t<0,r=n?e.length:0,a=function(e,t,n){for(var i=-1,r=n.length;++i=this.__values__.length;return{done:e,value:e?n:this.__values__[this.__index__++]}},Fn.prototype.plant=function(e){for(var t,i=this;i instanceof Bn;){var r=Da(i);r.__index__=0,r.__values__=n,t?a.__wrapped__=r:t=r;var a=r;i=i.__wrapped__}return a.__wrapped__=e,t},Fn.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Hn){var t=e;return this.__actions__.length&&(t=new Hn(this)),(t=t.reverse()).__actions__.push({func:ls,args:[Ja],thisArg:n}),new zn(t,this.__chain__)}return this.thru(Ja)},Fn.prototype.toJSON=Fn.prototype.valueOf=Fn.prototype.value=function(){return cr(this.__wrapped__,this.__actions__)},Fn.prototype.first=Fn.prototype.head,$e&&(Fn.prototype[$e]=function(){return this}),Fn}();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(ht._=un,define((function(){return un}))):ut?((ut.exports=un)._=un,ct._=un):ht._=un}).call(e)})),lpe=J(((e,t)=>{var n,i;n=e,i=function(){"use strict";function e(e,i,r,a,s){!function e(n,i,r,a,s){for(;a>r;){if(a-r>600){var o=a-r+1,l=i-r+1,h=Math.log(o),c=.5*Math.exp(2*h/3),u=.5*Math.sqrt(h*c*(o-c)/o)*(l-o/2<0?-1:1);e(n,i,Math.max(r,Math.floor(i-l*c/o+u)),Math.min(a,Math.floor(i+(o-l)*c/o+u)),s)}var d=n[i],p=r,f=a;for(t(n,r,i),s(n[a],d)>0&&t(n,r,a);p0;)f--}0===s(n[r],d)?t(n,r,f):t(n,++f,a),f<=i&&(r=f+1),i<=f&&(a=f-1)}}(e,i,r||0,a||e.length-1,s||n)}function t(e,t,n){var i=e[t];e[t]=e[n],e[n]=i}function n(e,t){return et?1:0}var i=function(e){void 0===e&&(e=9),this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function r(e,t,n){if(!n)return t.indexOf(e);for(var i=0;i=e.minX&&t.maxY>=e.minY}function f(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function m(t,n,i,r,a){for(var s=[n,i];s.length;)if(!((i=s.pop())-(n=s.pop())<=r)){var o=n+Math.ceil((i-n)/r/2)*r;e(t,o,n,i,a),s.push(n,o,o,i)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(e){var t=this.data,n=[];if(!p(e,t))return n;for(var i=this.toBBox,r=[];t;){for(var a=0;a=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(i,r,t)},i.prototype._split=function(e,t){var n=e[t],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);var s=this._chooseSplitIndex(n,r,i),o=f(n.children.splice(s,n.children.length-s));o.height=n.height,o.leaf=n.leaf,a(n,this.toBBox),a(o,this.toBBox),t?e[t-1].children.push(o):this._splitRoot(n,o)},i.prototype._splitRoot=function(e,t){this.data=f([e,t]),this.data.height=e.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(e,t,n){for(var i,r,a,o,l,h,u,d=1/0,p=1/0,f=t;f<=n-t;f++){var m=s(e,0,f,this.toBBox),g=s(e,f,n,this.toBBox),v=(r=m,a=g,o=Math.max(r.minX,a.minX),l=Math.max(r.minY,a.minY),h=Math.min(r.maxX,a.maxX),u=Math.min(r.maxY,a.maxY),Math.max(0,h-o)*Math.max(0,u-l)),y=c(m)+c(g);v=t;p--){var f=e.children[p];o(l,e.leaf?r(f):f),h+=u(l)}return h},i.prototype._adjustParentBBoxes=function(e,t,n){for(var i=n;i>=0;i--)o(t[i],e)},i.prototype._condense=function(e){for(var t=e.length-1,n=void 0;t>=0;t--)0===e[t].children.length?t>0?(n=e[t-1].children).splice(n.indexOf(e[t]),1):this.clear():a(e[t],this.toBBox)},i},"object"==typeof e&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define(i):(n=n||self).RBush=i()})),cpe=J(((e,t)=>{var n,i;n=e,i=function(){"use strict";var e=function(e,n){if(void 0===e&&(e=[]),void 0===n&&(n=t),this.data=e,this.length=this.data.length,this.compare=n,this.length>0)for(var i=(this.length>>1)-1;i>=0;i--)this._down(i)};function t(e,t){return et?1:0}return e.prototype.push=function(e){this.data.push(e),this.length++,this._up(this.length-1)},e.prototype.pop=function(){if(0!==this.length){var e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}},e.prototype.peek=function(){return this.data[0]},e.prototype._up=function(e){for(var t=this.data,n=this.compare,i=t[e];e>0;){var r=e-1>>1,a=t[r];if(n(i,a)>=0)break;t[e]=a,e=r}t[e]=i},e.prototype._down=function(e){for(var t=this.data,n=this.compare,i=this.length>>1,r=t[e];e=0)break;t[e]=s,e=a}t[e]=r},e},"object"==typeof e&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define(i):(n=n||self).TinyQueue=i()})),hpe=J(((e,t)=>{t.exports=function(e,t,n,i){var r=e[0],a=e[1],s=!1;void 0===n&&(n=0),void 0===i&&(i=t.length);for(var o=(i-n)/2,l=0,h=o-1;la!=p>a&&r<(d-c)*(a-u)/(p-u)+c&&(s=!s)}return s}})),fpe=J(((e,t)=>{t.exports=function(e,t,n,i){var r=e[0],a=e[1],s=!1;void 0===n&&(n=0),void 0===i&&(i=t.length);for(var o=i-n,l=0,h=o-1;la!=p>a&&r<(d-c)*(a-u)/(p-u)+c&&(s=!s)}return s}})),gpe=J(((e,t)=>{var n=hpe(),i=fpe();t.exports=function(e,t,r,a){return t.length>0&&Array.isArray(t[0])?i(e,t,r,a):n(e,t,r,a)},t.exports.nested=i,t.exports.flat=n})),ype=J(((e,t)=>{var n,i;n=e,i=function(e){"use strict";function t(e,t,n,i,r){let a,s,o,l,h=t[0],c=i[0],u=0,d=0;c>h==c>-h?(a=h,h=t[++u]):(a=c,c=i[++d]);let p=0;if(uh==c>-h?(o=a-((s=h+a)-h),h=t[++u]):(o=a-((s=c+a)-c),c=i[++d]),a=s,0!==o&&(r[p++]=o);uh==c>-h?(o=a-((s=a+h)-(l=s-a))+(h-l),h=t[++u]):(o=a-((s=a+c)-(l=s-a))+(c-l),c=i[++d]),a=s,0!==o&&(r[p++]=o);for(;u0!=p>0)return f;let m=Math.abs(d+p);return Math.abs(f)>=33306690738754716e-32*m?f:-function(e,n,l,h,c,u,d){let p,f,m,g,v,y,x,b,_,w,S,M,E,T,A,C,P,R,O=e-c,L=l-c,I=n-u,D=h-u;v=(A=(b=O-(x=(y=134217729*O)-(y-O)))*(w=D-(_=(y=134217729*D)-(y-D)))-((T=O*D)-x*_-b*_-x*w))-(S=A-(P=(b=I-(x=(y=134217729*I)-(y-I)))*(w=L-(_=(y=134217729*L)-(y-L)))-((C=I*L)-x*_-b*_-x*w))),i[0]=A-(S+v)+(v-P),v=(E=T-((M=T+S)-(v=M-T))+(S-v))-(S=E-C),i[1]=E-(S+v)+(v-C),v=(R=M+S)-M,i[2]=M-(R-v)+(S-v),i[3]=R;let k=function(e,t){let n=t[0];for(let i=1;i<4;i++)n+=t[i];return n}(0,i),N=22204460492503146e-32*d;if(k>=N||-k>=N||(p=e-(O+(v=e-O))+(v-c),m=l-(L+(v=l-L))+(v-c),f=n-(I+(v=n-I))+(v-u),g=h-(D+(v=h-D))+(v-u),0===p&&0===f&&0===m&&0===g)||(N=11093356479670487e-47*d+33306690738754706e-32*Math.abs(k),(k+=O*g+D*p-(I*m+L*f))>=N||-k>=N))return k;v=(A=(b=p-(x=(y=134217729*p)-(y-p)))*(w=D-(_=(y=134217729*D)-(y-D)))-((T=p*D)-x*_-b*_-x*w))-(S=A-(P=(b=f-(x=(y=134217729*f)-(y-f)))*(w=L-(_=(y=134217729*L)-(y-L)))-((C=f*L)-x*_-b*_-x*w))),o[0]=A-(S+v)+(v-P),v=(E=T-((M=T+S)-(v=M-T))+(S-v))-(S=E-C),o[1]=E-(S+v)+(v-C),v=(R=M+S)-M,o[2]=M-(R-v)+(S-v),o[3]=R;let F=t(4,i,4,o,r);v=(A=(b=O-(x=(y=134217729*O)-(y-O)))*(w=g-(_=(y=134217729*g)-(y-g)))-((T=O*g)-x*_-b*_-x*w))-(S=A-(P=(b=I-(x=(y=134217729*I)-(y-I)))*(w=m-(_=(y=134217729*m)-(y-m)))-((C=I*m)-x*_-b*_-x*w))),o[0]=A-(S+v)+(v-P),v=(E=T-((M=T+S)-(v=M-T))+(S-v))-(S=E-C),o[1]=E-(S+v)+(v-C),v=(R=M+S)-M,o[2]=M-(R-v)+(S-v),o[3]=R;let U=t(F,r,4,o,a);v=(A=(b=p-(x=(y=134217729*p)-(y-p)))*(w=g-(_=(y=134217729*g)-(y-g)))-((T=p*g)-x*_-b*_-x*w))-(S=A-(P=(b=f-(x=(y=134217729*f)-(y-f)))*(w=m-(_=(y=134217729*m)-(y-m)))-((C=f*m)-x*_-b*_-x*w))),o[0]=A-(S+v)+(v-P),v=(E=T-((M=T+S)-(v=M-T))+(S-v))-(S=E-C),o[1]=E-(S+v)+(v-C),v=(R=M+S)-M,o[2]=M-(R-v)+(S-v),o[3]=R;let B=t(U,a,4,o,s);return s[B-1]}(e,n,l,h,c,u,m)},e.orient2dfast=function(e,t,n,i,r,a){return(t-a)*(n-r)-(e-r)*(i-a)},Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof e&&void 0!==t?i(e):"function"==typeof define&&define.amd?define(["exports"],i):i((n=n||self).predicates={})})),wpe=J(((e,t)=>{"use strict";var n=lpe(),i=cpe(),r=gpe(),a=ype().orient2d;function s(e,t,i){t=Math.max(0,void 0===t?2:t),i=i||0;var a=function(e){for(var t=e[0],n=e[0],i=e[0],a=e[0],s=0;si[0]&&(i=o),o[1]a[1]&&(a=o)}var l=[t,n,i,a],h=l.slice();for(s=0;s=2&&d(t[t.length-2],t[t.length-1],e[n])<=0;)t.pop();t.push(e[n])}for(var i=[],r=e.length-1;r>=0;r--){for(;i.length>=2&&d(i[i.length-2],i[i.length-1],e[r])<=0;)i.pop();i.push(e[r])}return i.pop(),t.pop(),t.concat(i)}(h)}(e),s=new n(16);s.toBBox=function(e){return{minX:e[0],minY:e[1],maxX:e[0],maxY:e[1]}},s.compareMinX=function(e,t){return e[0]-t[0]},s.compareMinY=function(e,t){return e[1]-t[1]},s.load(e);for(var l,h=[],c=0;cs||c.push({node:f,dist:m})}for(;c.length&&!c.peek().node.children;){var g=c.pop(),y=g.node,x=v(y,t,n),b=v(y,r,a);if(g.dist=t.minX&&e[0]<=t.maxX&&e[1]>=t.minY&&e[1]<=t.maxY}function u(e,t,n){for(var i=Math.min(e[0],t[0]),r=Math.min(e[1],t[1]),a=Math.max(e[0],t[0]),s=Math.max(e[1],t[1]),o=n.search({minX:i,minY:r,maxX:a,maxY:s}),l=0;l0!=d(e,t,i)>0&&d(n,i,e)>0!=d(n,i,t)>0}function f(e){var t=e.p,n=e.next.p;return e.minX=Math.min(t[0],n[0]),e.minY=Math.min(t[1],n[1]),e.maxX=Math.max(t[0],n[0]),e.maxY=Math.max(t[1],n[1]),e}function m(e,t){var n={p:e,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return t?(n.next=t.next,n.prev=t,t.next.prev=n,t.next=n):(n.prev=n,n.next=n),n}function g(e,t){var n=e[0]-t[0],i=e[1]-t[1];return n*n+i*i}function v(e,t,n){var i=t[0],r=t[1],a=n[0]-i,s=n[1]-r;if(0!==a||0!==s){var o=((e[0]-i)*a+(e[1]-r)*s)/(a*a+s*s);o>1?(i=n[0],r=n[1]):o>0&&(i+=a*o,r+=s*o)}return(a=e[0]-i)*a+(s=e[1]-r)*s}function y(e,t,n,i,r,a,s,o){var l,h,c,u,d=n-e,p=i-t,f=s-r,m=o-a,g=e-r,v=t-a,y=d*d+p*p,x=d*f+p*m,b=f*f+m*m,_=d*g+p*v,w=f*g+m*v,S=y*b-x*x,M=S,E=S;0===S?(h=0,M=1,u=w,E=b):(u=y*w-x*_,(h=x*w-b*_)<0?(h=0,u=w,E=b):h>M&&(h=M,u=w+x,E=b)),u<0?(u=0,-_<0?h=0:-_>y?h=M:(h=-_,M=y)):u>E&&(u=E,-_+x<0?h=0:-_+x>y?h=M:(h=-_+x,M=y));var T=(1-(c=0===u?0:u/E))*r+c*s-((1-(l=0===h?0:h/M))*e+l*n),A=(1-c)*a+c*o-((1-l)*t+l*i);return T*T+A*A}function x(e,t){return e[0]===t[0]?e[1]-t[1]:e[0]-t[0]}i.default&&(i=i.default),t.exports=s,t.exports.default=s})),Wpe=J(((e,t)=>{t.exports=function(){var e,t=0,n=!1;function i(t,n){return e.list.push({type:t,data:n?JSON.parse(JSON.stringify(n)):void 0}),e}return e={list:[],segmentId:function(){return t++},checkIntersection:function(e,t){return i("check",{seg1:e,seg2:t})},segmentChop:function(e,t){return i("div_seg",{seg:e,pt:t}),i("chop",{seg:e,pt:t})},statusRemove:function(e){return i("pop_seg",{seg:e})},segmentUpdate:function(e){return i("seg_update",{seg:e})},segmentNew:function(e,t){return i("new_seg",{seg:e,primary:t})},segmentRemove:function(e){return i("rem_seg",{seg:e})},tempStatus:function(e,t,n){return i("temp_status",{seg:e,above:t,below:n})},rewind:function(e){return i("rewind",{seg:e})},status:function(e,t,n){return i("status",{seg:e,above:t,below:n})},vert:function(t){return t===n?e:(n=t,i("vert",{x:t}))},log:function(e){return"string"!=typeof e&&(e=JSON.stringify(e,!1," ")),i("log",{txt:e})},reset:function(){return i("reset")},selected:function(e){return i("selected",{segs:e})},chainStart:function(e){return i("chain_start",{seg:e})},chainRemoveHead:function(e,t){return i("chain_rem_head",{index:e,pt:t})},chainRemoveTail:function(e,t){return i("chain_rem_tail",{index:e,pt:t})},chainNew:function(e,t){return i("chain_new",{pt1:e,pt2:t})},chainMatch:function(e){return i("chain_match",{index:e})},chainClose:function(e){return i("chain_close",{index:e})},chainAddHead:function(e,t){return i("chain_add_head",{index:e,pt:t})},chainAddTail:function(e,t){return i("chain_add_tail",{index:e,pt:t})},chainConnect:function(e,t){return i("chain_con",{index1:e,index2:t})},chainReverse:function(e){return i("chain_rev",{index:e})},chainJoin:function(e,t){return i("chain_join",{index1:e,index2:t})},done:function(){return i("done")}}}})),Xpe=J(((e,t)=>{t.exports=function(e){"number"!=typeof e&&(e=1e-10);var t={epsilon:function(t){return"number"==typeof t&&(e=t),e},pointAboveOrOnLine:function(t,n,i){var r=n[0],a=n[1],s=i[0],o=i[1],l=t[0];return(s-r)*(t[1]-a)-(o-a)*(l-r)>=-e},pointBetween:function(t,n,i){var r=t[1]-n[1],a=i[0]-n[0],s=t[0]-n[0],o=i[1]-n[1],l=s*a+r*o;return!(l-e)},pointsSameX:function(t,n){return Math.abs(t[0]-n[0])e!=s-r>e&&(a-h)*(r-c)/(s-c)+h-i>e&&(o=!o),a=h,s=c}return o}};return t}})),$pe=J(((e,t)=>{t.exports={create:function(){var e={root:{root:!0,next:null},exists:function(t){return!(null===t||t===e.root)},isEmpty:function(){return null===e.root.next},getHead:function(){return e.root.next},insertBefore:function(t,n){for(var i=e.root,r=e.root.next;null!==r;){if(n(r))return t.prev=r.prev,t.next=r,r.prev.next=t,void(r.prev=t);i=r,r=r.next}i.next=t,t.prev=i,t.next=null},findTransition:function(t){for(var n=e.root,i=e.root.next;null!==i&&!t(i);)n=i,i=i.next;return{before:n===e.root?null:n,after:i,insert:function(e){return e.prev=n,e.next=i,n.next=e,null!==i&&(i.prev=e),e}}}};return e},node:function(e){return e.prev=null,e.next=null,e.remove=function(){e.prev.next=e.next,e.next&&(e.next.prev=e.prev),e.prev=null,e.next=null},e}}})),Kpe=J(((e,t)=>{var n=$pe();t.exports=function(e,t,i){function r(e,t){return{id:i?i.segmentId():-1,start:e,end:t,myFill:{above:null,below:null},otherFill:null}}function a(e,t,n){return{id:i?i.segmentId():-1,start:e,end:t,myFill:{above:n.myFill.above,below:n.myFill.below},otherFill:null}}var s=n.create();function o(e,n){s.insertBefore(e,(function(i){var r=function(e,n,i,r,a,s){var o=t.pointsCompare(n,a);return 0!==o?o:t.pointsSame(i,s)?0:e!==r?e?1:-1:t.pointAboveOrOnLine(i,r?a:s,r?s:a)?1:-1}(e.isStart,e.pt,n,i.isStart,i.pt,i.other.pt);return r<0}))}function l(e,t){var i=function(e,t){var i=n.node({isStart:!0,pt:e.start,seg:e,primary:t,other:null,status:null});return o(i,e.end),i}(e,t);return function(e,t,i){var r=n.node({isStart:!1,pt:t.end,seg:t,primary:i,other:e,status:null});e.other=r,o(r,e.pt)}(i,e,t),i}function h(e,t){var n=a(t,e.seg.end,e.seg);return function(e,t){i&&i.segmentChop(e.seg,t),e.other.remove(),e.seg.end=t,e.other.pt=t,o(e.other,e.pt)}(e,t),l(n,e.primary)}function c(r,a){var o=n.create();function l(e){return o.findTransition((function(n){var i=function(e,n){var i=e.seg.start,r=e.seg.end,a=n.seg.start,s=n.seg.end;return t.pointsCollinear(i,a,s)?t.pointsCollinear(r,a,s)||t.pointAboveOrOnLine(r,a,s)?1:-1:t.pointAboveOrOnLine(i,a,s)?1:-1}(e,n.ev);return i>0}))}function c(e,n){var r=e.seg,a=n.seg,s=r.start,o=r.end,l=a.start,c=a.end;i&&i.checkIntersection(r,a);var u=t.linesIntersect(s,o,l,c);if(!1===u){if(!t.pointsCollinear(s,o,l)||t.pointsSame(s,c)||t.pointsSame(o,l))return!1;var d=t.pointsSame(s,l),p=t.pointsSame(o,c);if(d&&p)return n;var f=!d&&t.pointBetween(s,l,c),m=!p&&t.pointBetween(o,l,c);if(d)return m?h(n,o):h(e,c),n;f&&(p||(m?h(n,o):h(e,c)),h(n,s))}else 0===u.alongA&&(-1===u.alongB?h(e,l):0===u.alongB?h(e,u.pt):1===u.alongB&&h(e,c)),0===u.alongB&&(-1===u.alongA?h(n,s):0===u.alongA?h(n,u.pt):1===u.alongA&&h(n,o));return!1}for(var u=[];!s.isEmpty();){var d=s.getHead();if(i&&i.vert(d.pt[0]),d.isStart){let t=function(){if(f){var e=c(d,f);if(e)return e}return!!m&&c(d,m)};i&&i.segmentNew(d.seg,d.primary);var p=l(d),f=p.before?p.before.ev:null,m=p.after?p.after.ev:null;i&&i.tempStatus(d.seg,!!f&&f.seg,!!m&&m.seg);var g,v=t();if(v)e?(g=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below)&&(v.seg.myFill.above=!v.seg.myFill.above):v.seg.otherFill=d.seg.myFill,i&&i.segmentUpdate(v.seg),d.other.remove(),d.remove();if(s.getHead()!==d){i&&i.rewind(d.seg);continue}if(e)g=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below,d.seg.myFill.below=m?m.seg.myFill.above:r,d.seg.myFill.above=g?!d.seg.myFill.below:d.seg.myFill.below;else if(null===d.seg.otherFill){var y;y=m?d.primary===m.primary?m.seg.otherFill.above:m.seg.myFill.above:d.primary?a:r,d.seg.otherFill={above:y,below:y}}i&&i.status(d.seg,!!f&&f.seg,!!m&&m.seg),d.other.status=p.insert(n.node({ev:d}))}else{var x=d.status;if(null===x)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(o.exists(x.prev)&&o.exists(x.next)&&c(x.prev.ev,x.next.ev),i&&i.statusRemove(x.ev.seg),x.remove(),!d.primary){var b=d.seg.myFill;d.seg.myFill=d.seg.otherFill,d.seg.otherFill=b}u.push(d.seg)}s.getHead().remove()}return i&&i.done(),u}return e?{addRegion:function(e){for(var n,i=e[e.length-1],a=0;a{t.exports=function(e,t,n){var i=[],r=[];return e.forEach((function(e){var a=e.start,s=e.end;if(t.pointsSame(a,s))console.warn("PolyBool: Warning: Zero-length segment detected; your epsilon is probably too small or too large");else{n&&n.chainStart(e);for(var o={index:0,matches_head:!1,matches_pt1:!1},l={index:0,matches_head:!1,matches_pt1:!1},h=o,c=0;c{function n(e,t,n){var i=[];return e.forEach((function(e){var r=(e.myFill.above?8:0)+(e.myFill.below?4:0)+(e.otherFill&&e.otherFill.above?2:0)+(e.otherFill&&e.otherFill.below?1:0);0!==t[r]&&i.push({id:n?n.segmentId():-1,start:e.start,end:e.end,myFill:{above:1===t[r],below:2===t[r]},otherFill:null})})),n&&n.selected(i),i}var i={union:function(e,t){return n(e,[0,2,1,0,2,2,0,0,1,0,1,0,0,0,0,0],t)},intersect:function(e,t){return n(e,[0,0,0,0,0,2,0,2,0,0,1,1,0,2,1,0],t)},difference:function(e,t){return n(e,[0,0,0,0,2,0,2,0,1,1,0,0,0,1,2,0],t)},differenceRev:function(e,t){return n(e,[0,2,1,0,0,0,1,1,0,2,0,2,0,0,0,0],t)},xor:function(e,t){return n(e,[0,2,1,0,2,0,0,1,1,0,0,2,0,1,2,0],t)}};t.exports=i})),rme=J(((e,t)=>{var n={toPolygon:function(e,t){function n(t){if(t.length<=0)return e.segments({inverted:!1,regions:[]});function n(t){var n=t.slice(0,t.length-1);return e.segments({inverted:!1,regions:[n]})}for(var i=n(t[0]),r=1;r{var n,i=Wpe(),r=Xpe(),a=Kpe(),s=Qpe(),o=tme(),l=rme(),h=!1,c=r();function u(e,t,i){var r=n.segments(e),a=n.segments(t),s=i(n.combine(r,a));return n.polygon(s)}n={buildLog:function(e){return!0===e?h=i():!1===e&&(h=!1),!1!==h&&h.list},epsilon:function(e){return c.epsilon(e)},segments:function(e){var t=a(!0,c,h);return e.regions.forEach(t.addRegion),{segments:t.calculate(e.inverted),inverted:e.inverted}},combine:function(e,t){return{combined:a(!1,c,h).calculate(e.segments,e.inverted,t.segments,t.inverted),inverted1:e.inverted,inverted2:t.inverted}},selectUnion:function(e){return{segments:o.union(e.combined,h),inverted:e.inverted1||e.inverted2}},selectIntersect:function(e){return{segments:o.intersect(e.combined,h),inverted:e.inverted1&&e.inverted2}},selectDifference:function(e){return{segments:o.difference(e.combined,h),inverted:e.inverted1&&!e.inverted2}},selectDifferenceRev:function(e){return{segments:o.differenceRev(e.combined,h),inverted:!e.inverted1&&e.inverted2}},selectXor:function(e){return{segments:o.xor(e.combined,h),inverted:e.inverted1!==e.inverted2}},polygon:function(e){return{regions:s(e.segments,c,h),inverted:e.inverted}},polygonFromGeoJSON:function(e){return l.toPolygon(n,e)},polygonToGeoJSON:function(e){return l.fromPolygon(n,c,e)},union:function(e,t){return u(e,t,n.selectUnion)},intersect:function(e,t){return u(e,t,n.selectIntersect)},difference:function(e,t){return u(e,t,n.selectDifference)},differenceRev:function(e,t){return u(e,t,n.selectDifferenceRev)},xor:function(e,t){return u(e,t,n.selectXor)}},"object"==typeof window&&(window.PolyBool=n),t.exports=n})),RC=J((()=>{})),dve=J(((e,t)=>{var n,i;n=e,i=function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;nt?1:e0))break;if(null===t.right)break;if(n(e,t.right.key)>0&&(l=t.right,t.right=l.left,l.left=t,null===(t=l).right))break;a.right=t,a=t,t=t.right}}return a.right=t.left,s.left=t.right,t.left=r.right,t.right=r.left,t}function s(e,t,n,r){var s=new i(e,t);if(null===n)return s.left=s.right=null,s;var o=r(e,(n=a(e,n,r)).key);return o<0?(s.left=n.left,s.right=n,n.left=null):o>=0&&(s.right=n.right,s.left=n,n.right=null),s}function o(e,t,n){var i=null,r=null;if(t){var s=n((t=a(e,t,n)).key,e);0===s?(i=t.left,r=t.right):s<0?(r=t.right,t.right=null,i=t):(i=t.left,t.left=null,r=t)}return{left:i,right:r}}function l(e,t,n,i,r){if(e){i(t+(n?"\u2514\u2500\u2500 ":"\u251c\u2500\u2500 ")+r(e)+"\n");var a=t+(n?" ":"\u2502 ");e.left&&l(e.left,a,!1,i,r),e.right&&l(e.right,a,!0,i,r)}}var h=function(){function e(e){void 0===e&&(e=r),this._root=null,this._size=0,this._comparator=e}return e.prototype.insert=function(e,t){return this._size++,this._root=s(e,t,this._root,this._comparator)},e.prototype.add=function(e,t){var n=new i(e,t);null===this._root&&(n.left=n.right=null,this._size++,this._root=n);var r=this._comparator,s=a(e,this._root,r),o=r(e,s.key);return 0===o?this._root=s:(o<0?(n.left=s.left,n.right=s,s.left=null):o>0&&(n.right=s.right,n.left=s,s.right=null),this._size++,this._root=n),this._root},e.prototype.remove=function(e){this._root=this._remove(e,this._root,this._comparator)},e.prototype._remove=function(e,t,n){var i;return null===t?null:0===n(e,(t=a(e,t,n)).key)?(null===t.left?i=t.right:(i=a(e,t.left,n)).right=t.right,this._size--,i):t},e.prototype.pop=function(){var e=this._root;if(e){for(;e.left;)e=e.left;return this._root=a(e.key,this._root,this._comparator),this._root=this._remove(e.key,this._root,this._comparator),{key:e.key,data:e.data}}return null},e.prototype.findStatic=function(e){for(var t=this._root,n=this._comparator;t;){var i=n(e,t.key);if(0===i)return t;t=i<0?t.left:t.right}return null},e.prototype.find=function(e){return this._root&&(this._root=a(e,this._root,this._comparator),0!==this._comparator(e,this._root.key))?null:this._root},e.prototype.contains=function(e){for(var t=this._root,n=this._comparator;t;){var i=n(e,t.key);if(0===i)return!0;t=i<0?t.left:t.right}return!1},e.prototype.forEach=function(e,t){for(var n=this._root,i=[],r=!1;!r;)null!==n?(i.push(n),n=n.left):0!==i.length?(n=i.pop(),e.call(t,n),n=n.right):r=!0;return this},e.prototype.range=function(e,t,n,i){for(var r=[],a=this._comparator,s=this._root;0!==r.length||s;)if(s)r.push(s),s=s.left;else{if(a((s=r.pop()).key,t)>0)break;if(a(s.key,e)>=0&&n.call(i,s))return this;s=s.right}return this},e.prototype.keys=function(){var e=[];return this.forEach((function(t){var n=t.key;return e.push(n)})),e},e.prototype.values=function(){var e=[];return this.forEach((function(t){var n=t.data;return e.push(n)})),e},e.prototype.min=function(){return this._root?this.minNode(this._root).key:null},e.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},e.prototype.minNode=function(e){if(void 0===e&&(e=this._root),e)for(;e.left;)e=e.left;return e},e.prototype.maxNode=function(e){if(void 0===e&&(e=this._root),e)for(;e.right;)e=e.right;return e},e.prototype.at=function(e){for(var t=this._root,n=!1,i=0,r=[];!n;)if(t)r.push(t),t=t.left;else if(r.length>0){if(t=r.pop(),i===e)return t;i++,t=t.right}else n=!0;return null},e.prototype.next=function(e){var t=this._root,n=null;if(e.right){for(n=e.right;n.left;)n=n.left;return n}for(var i=this._comparator;t;){var r=i(e.key,t.key);if(0===r)break;r<0?(n=t,t=t.left):t=t.right}return n},e.prototype.prev=function(e){var t=this._root,n=null;if(null!==e.left){for(n=e.left;n.right;)n=n.right;return n}for(var i=this._comparator;t;){var r=i(e.key,t.key);if(0===r)break;r<0?t=t.left:(n=t,t=t.right)}return n},e.prototype.clear=function(){return this._root=null,this._size=0,this},e.prototype.toList=function(){return function(e){for(var t=e,n=[],r=!1,a=new i(null,null),s=a;!r;)t?(n.push(t),t=t.left):n.length>0?t=(t=s=s.next=n.pop()).right:r=!0;return s.next=null,a.next}(this._root)},e.prototype.load=function(e,t,n){void 0===t&&(t=[]),void 0===n&&(n=!1);var r=e.length,a=this._comparator;if(n&&d(e,t,0,r-1,a),null===this._root)this._root=c(e,t,0,r),this._size=r;else{var s=function(e,t,n){for(var r=new i(null,null),a=r,s=e,o=t;null!==s&&null!==o;)n(s.key,o.key)<0?(a.next=s,s=s.next):(a.next=o,o=o.next),a=a.next;return null!==s?a.next=s:null!==o&&(a.next=o),r.next}(this.toList(),function(e,t){for(var n=new i(null,null),r=n,a=0;a0){var s=n+Math.floor(a/2),o=e[s],l=t[s],h=new i(o,l);return h.left=c(e,t,n,s),h.right=c(e,t,s+1,r),h}return null}function u(e,t,n){var i=n-t;if(i>0){var r=t+Math.floor(i/2),a=u(e,t,r),s=e.head;return s.left=a,e.head=e.head.next,s.right=u(e,r+1,n),s}return null}function d(e,t,n,i,r){if(!(n>=i)){for(var a=e[n+i>>1],s=n-1,o=i+1;;){do{s++}while(r(e[s],a)<0);do{o--}while(r(e[o],a)>0);if(s>=o)break;var l=e[s];e[s]=e[o],e[o]=l,l=t[s],t[s]=t[o],t[o]=l}d(e,t,n,o,r),d(e,t,o+1,i,r)}}var p=function(e,t){return e.ll.x<=t.x&&t.x<=e.ur.x&&e.ll.y<=t.y&&t.y<=e.ur.y},f=function(e,t){if(t.ur.xt.x?1:e.yt.y?1:0}}]),n(t,[{key:"link",value:function(e){if(e.point===this.point)throw new Error("Tried to link already linked events");for(var t=e.point.events,n=0,i=t.length;n=0&&l>=0?sh?-1:0:a<0&&l<0?sh?1:0:la?1:0}}}]),t}(),R=0,O=function(){function t(n,i,r,a){e(this,t),this.id=++R,this.leftSE=n,n.segment=this,n.otherSE=i,this.rightSE=i,i.segment=this,i.otherSE=n,this.rings=r,this.windings=a}return n(t,null,[{key:"compare",value:function(e,t){var n=e.leftSE.point.x,i=t.leftSE.point.x,r=e.rightSE.point.x,a=t.rightSE.point.x;if(as&&o>l)return-1;var c=e.comparePoint(t.leftSE.point);if(c<0)return 1;if(c>0)return-1;var u=t.comparePoint(e.rightSE.point);return 0!==u?u:-1}if(n>i){if(so&&s>h)return 1;var d=t.comparePoint(e.leftSE.point);if(0!==d)return d;var p=e.comparePoint(t.rightSE.point);return p<0?1:p>0?-1:1}if(so)return 1;if(ra){var m=e.comparePoint(t.rightSE.point);if(m<0)return 1;if(m>0)return-1}if(r!==a){var g=l-s,v=r-n,y=h-o,x=a-i;if(g>v&&yx)return-1}return r>a?1:rh?1:e.idt.id?1:0}}]),n(t,[{key:"replaceRightSE",value:function(e){this.rightSE=e,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}},{key:"bbox",value:function(){var e=this.leftSE.point.y,t=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:et?e:t}}}},{key:"vector",value:function(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}},{key:"isAnEndpoint",value:function(e){return e.x===this.leftSE.point.x&&e.y===this.leftSE.point.y||e.x===this.rightSE.point.x&&e.y===this.rightSE.point.y}},{key:"comparePoint",value:function(e){if(this.isAnEndpoint(e))return 0;var t=this.leftSE.point,n=this.rightSE.point,i=this.vector();if(t.x===n.x)return e.x===t.x?0:e.x0&&o.swapEvents(),P.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),i&&(r.checkForConsuming(),a.checkForConsuming()),n}},{key:"swapEvents",value:function(){var e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(var t=0,n=this.windings.length;t0){var a=n;n=i,i=a}if(n.prev===i){var s=n;n=i,i=s}for(var o=0,l=i.rings.length;o0))throw new Error("Tried to create degenerate segment at [".concat(e.x,", ").concat(e.y,"]"));r=n,a=e,s=-1}return new t(new P(r,!0),new P(a,!1),[i],[s])}}]),t}(),L=function(){function t(n,i,r){if(e(this,t),!Array.isArray(n)||0===n.length)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=i,this.isExterior=r,this.segments=[],"number"!=typeof n[0][0]||"number"!=typeof n[0][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var a=b.round(n[0][0],n[0][1]);this.bbox={ll:{x:a.x,y:a.y},ur:{x:a.x,y:a.y}};for(var s=a,o=1,l=n.length;othis.bbox.ur.x&&(this.bbox.ur.x=h.x),h.y>this.bbox.ur.y&&(this.bbox.ur.y=h.y),s=h)}(a.x!==s.x||a.y!==s.y)&&this.segments.push(O.fromRing(s,a,this))}return n(t,[{key:"getSweepEvents",value:function(){for(var e=[],t=0,n=this.segments.length;tthis.bbox.ur.x&&(this.bbox.ur.x=s.bbox.ur.x),s.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=s.bbox.ur.y),this.interiorRings.push(s)}this.multiPoly=i}return n(t,[{key:"getSweepEvents",value:function(){for(var e=this.exteriorRing.getSweepEvents(),t=0,n=this.interiorRings.length;tthis.bbox.ur.x&&(this.bbox.ur.x=s.bbox.ur.x),s.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=s.bbox.ur.y),this.polys.push(s)}this.isSubject=i}return n(t,[{key:"getSweepEvents",value:function(){for(var e=[],t=0,n=this.polys.length;t0&&(e=i)}for(var r=e.segment.prevInResult(),a=r?r.prevInResult():null;;){if(!r)return null;if(!a)return r.ringOut;if(a.ringOut!==r.ringOut)return a.ringOut.enclosingRing()!==r.ringOut?r.ringOut:r.ringOut.enclosingRing();r=a.prevInResult(),a=r?r.prevInResult():null}}}]),t}(),N=function(){function t(n){e(this,t),this.exteriorRing=n,n.poly=this,this.interiorRings=[]}return n(t,[{key:"addInterior",value:function(e){this.interiorRings.push(e),e.poly=this}},{key:"getGeom",value:function(){var e=[this.exteriorRing.getGeom()];if(null===e[0])return null;for(var t=0,n=this.interiorRings.length;t1&&void 0!==arguments[1]?arguments[1]:O.compare;e(this,t),this.queue=n,this.tree=new h(i),this.segments=[]}return n(t,[{key:"process",value:function(e){var t=e.segment,n=[];if(e.consumedBy)return e.isLeft?this.queue.remove(e.otherSE):this.tree.remove(t),n;var i=e.isLeft?this.tree.insert(t):this.tree.find(t);if(!i)throw new Error("Unable to find segment #".concat(t.id," ")+"[".concat(t.leftSE.point.x,", ").concat(t.leftSE.point.y,"] -> ")+"[".concat(t.rightSE.point.x,", ").concat(t.rightSE.point.y,"] ")+"in SweepLine tree. Please submit a bug report.");for(var r=i,a=i,s=void 0,o=void 0;void 0===s;)null===(r=this.tree.prev(r))?s=null:void 0===r.key.consumedBy&&(s=r.key);for(;void 0===o;)null===(a=this.tree.next(a))?o=null:void 0===a.key.consumedBy&&(o=a.key);if(e.isLeft){var l=null;if(s){var h=s.getIntersection(t);if(null!==h&&(t.isAnEndpoint(h)||(l=h),!s.isAnEndpoint(h)))for(var c=this._splitSafely(s,h),u=0,d=c.length;u0?(this.tree.remove(t),n.push(e)):(this.segments.push(t),t.prev=s)}else{if(s&&o){var w=s.getIntersection(o);if(null!==w){if(!s.isAnEndpoint(w))for(var S=this._splitSafely(s,w),M=0,E=S.length;MB)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big). Please file a bug report.");for(var w=new U(m),S=m.size,M=m.pop();M;){var E=M.key;if(m.size===S){var T=E.segment;throw new Error("Unable to pop() ".concat(E.isLeft?"left":"right"," SweepEvent ")+"[".concat(E.point.x,", ").concat(E.point.y,"] from segment #").concat(T.id," ")+"[".concat(T.leftSE.point.x,", ").concat(T.leftSE.point.y,"] -> ")+"[".concat(T.rightSE.point.x,", ").concat(T.rightSE.point.y,"] from queue. ")+"Please file a bug report.")}if(m.size>B)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big). Please file a bug report.");if(w.segments.length>z)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments). Please file a bug report.");for(var A=w.process(E),C=0,R=A.length;C1?t-1:0),i=1;i1?t-1:0),i=1;i1?t-1:0),i=1;i1?t-1:0),i=1;i{!function(){"use strict";var e,n={version:"6.4.2.2",use_lines:!0,use_xyz:!1},i=!1;if(void 0!==t&&t.exports?(t.exports=n,i=!0):("function"==typeof define&&define.amd&&define(n),"undefined"!=typeof document?window.ClipperLib=n:self.ClipperLib=n),i){var r="chrome";e="Netscape"}else r=navigator.userAgent.toString().toLowerCase(),e=navigator.appName;var a,s={};function o(e,t,i){n.biginteger_used=1,null!=e&&("number"==typeof e&&void 0===t?this.fromInt(e):"number"==typeof e?this.fromNumber(e,t,i):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function l(){return new o(null,void 0,void 0)}-1!=r.indexOf("chrome")&&-1==r.indexOf("chromium")?s.chrome=1:s.chrome=0,-1!=r.indexOf("chromium")?s.chromium=1:s.chromium=0,-1!=r.indexOf("safari")&&-1==r.indexOf("chrome")&&-1==r.indexOf("chromium")?s.safari=1:s.safari=0,-1!=r.indexOf("firefox")?s.firefox=1:s.firefox=0,-1!=r.indexOf("firefox/17")?s.firefox17=1:s.firefox17=0,-1!=r.indexOf("firefox/15")?s.firefox15=1:s.firefox15=0,-1!=r.indexOf("firefox/3")?s.firefox3=1:s.firefox3=0,-1!=r.indexOf("opera")?s.opera=1:s.opera=0,-1!=r.indexOf("msie 10")?s.msie10=1:s.msie10=0,-1!=r.indexOf("msie 9")?s.msie9=1:s.msie9=0,-1!=r.indexOf("msie 8")?s.msie8=1:s.msie8=0,-1!=r.indexOf("msie 7")?s.msie7=1:s.msie7=0,-1!=r.indexOf("msie ")?s.msie=1:s.msie=0,n.biginteger_used=null,"Microsoft Internet Explorer"==e?(o.prototype.am=function(e,t,n,i,r,a){for(var s=32767&t,o=t>>15;--a>=0;){var l=32767&this[e],h=this[e++]>>15,c=o*l+h*s;r=((l=s*l+((32767&c)<<15)+n[i]+(1073741823&r))>>>30)+(c>>>15)+o*h+(r>>>30),n[i++]=1073741823&l}return r},a=30):"Netscape"!=e?(o.prototype.am=function(e,t,n,i,r,a){for(;--a>=0;){var s=t*this[e++]+n[i]+r;r=Math.floor(s/67108864),n[i++]=67108863&s}return r},a=26):(o.prototype.am=function(e,t,n,i,r,a){for(var s=16383&t,o=t>>14;--a>=0;){var l=16383&this[e],h=this[e++]>>14,c=o*l+h*s;r=((l=s*l+((16383&c)<<14)+n[i]+r)>>28)+(c>>14)+o*h,n[i++]=268435455&l}return r},a=28),o.prototype.DB=a,o.prototype.DM=(1<>>16)&&(e=t,n+=16),0!=(t=e>>8)&&(e=t,n+=8),0!=(t=e>>4)&&(e=t,n+=4),0!=(t=e>>2)&&(e=t,n+=2),0!=(t=e>>1)&&(e=t,n+=1),n}function g(e){this.m=e}function v(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function S(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function M(){}function E(e){return e}function T(e){this.r2=l(),this.q3=l(),o.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}g.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},g.prototype.revert=function(e){return e},g.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},g.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n),this.reduce(n)},g.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},v.prototype.convert=function(e){var t=l();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(o.ZERO)>0&&this.m.subTo(t,t),t},v.prototype.revert=function(e){var t=l();return e.copyTo(t),this.reduce(t),t},v.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(e[n=t+this.m.t]+=this.m.am(0,i,e,t,0,this.m.t);e[n]>=e.DV;)e[n]-=e.DV,e[++n]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},v.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n),this.reduce(n)},v.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},o.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},o.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0},o.prototype.fromString=function(e,t){var n;if(16==t)n=4;else if(8==t)n=3;else if(256==t)n=8;else if(2==t)n=1;else if(32==t)n=5;else{if(4!=t)return void this.fromRadix(e,t);n=2}this.t=0,this.s=0;for(var i=e.length,r=!1,a=0;--i>=0;){var s=8==n?255&e[i]:p(e,i);s<0?"-"==e.charAt(i)&&(r=!0):(r=!1,0==a?this[this.t++]=s:a+n>this.DB?(this[this.t-1]|=(s&(1<>this.DB-a):this[this.t-1]|=s<=this.DB&&(a-=this.DB))}8==n&&128&e[0]&&(this.s=-1,a>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t},o.prototype.dlShiftTo=function(e,t){var n;for(n=this.t-1;n>=0;--n)t[n+e]=this[n];for(n=e-1;n>=0;--n)t[n]=0;t.t=this.t+e,t.s=this.s},o.prototype.drShiftTo=function(e,t){for(var n=e;n=0;--n)t[n+s+1]=this[n]>>r|o,o=(this[n]&a)<=0;--n)t[n]=0;t[s]=o,t.t=this.t+s+1,t.s=this.s,t.clamp()},o.prototype.rShiftTo=function(e,t){t.s=this.s;var n=Math.floor(e/this.DB);if(n>=this.t)t.t=0;else{var i=e%this.DB,r=this.DB-i,a=(1<>i;for(var s=n+1;s>i;i>0&&(t[this.t-n-1]|=(this.s&a)<>=this.DB;if(e.t>=this.DB;i+=this.s}else{for(i+=this.s;n>=this.DB;i-=e.s}t.s=i<0?-1:0,i<-1?t[n++]=this.DV+i:i>0&&(t[n++]=i),t.t=n,t.clamp()},o.prototype.multiplyTo=function(e,t){var n=this.abs(),i=e.abs(),r=n.t;for(t.t=r+i.t;--r>=0;)t[r]=0;for(r=0;r=0;)e[n]=0;for(n=0;n=t.DV&&(e[n+t.t]-=t.DV,e[n+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(n,t[n],e,2*n,0,1)),e.s=0,e.clamp()},o.prototype.divRemTo=function(e,t,n){var i=e.abs();if(!(i.t<=0)){var r=this.abs();if(r.t0?(i.lShiftTo(c,a),r.lShiftTo(c,n)):(i.copyTo(a),r.copyTo(n));var u=a.t,d=a[u-1];if(0!=d){var p=d*(1<1?a[u-2]>>this.F2:0),f=this.FV/p,g=(1<=0&&(n[n.t++]=1,n.subTo(b,n)),o.ONE.dlShiftTo(u,b),b.subTo(a,a);a.t=0;){var _=n[--y]==d?this.DM:Math.floor(n[y]*f+(n[y-1]+v)*g);if((n[y]+=a.am(0,_,n,x,0,u))<_)for(a.dlShiftTo(x,b),n.subTo(b,n);n[y]<--_;)n.subTo(b,n)}null!=t&&(n.drShiftTo(u,t),s!=h&&o.ZERO.subTo(t,t)),n.t=u,n.clamp(),c>0&&n.rShiftTo(c,n),s<0&&o.ZERO.subTo(n,n)}}},o.prototype.invDigit=function(){if(this.t<1)return 0;var e=this[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},o.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},o.prototype.exp=function(e,t){if(e>4294967295||e<1)return o.ONE;var n=l(),i=l(),r=t.convert(this),a=m(e)-1;for(r.copyTo(n);--a>=0;)if(t.sqrTo(n,i),(e&1<0)t.mulTo(i,r,n);else{var s=n;n=i,i=s}return t.revert(n)},o.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var n,i=(1<0)for(o>o)>0&&(r=!0,a=d(n));s>=0;)o>(o+=this.DB-t)):(n=this[s]>>(o-=t)&i,o<=0&&(o+=this.DB,--s)),n>0&&(r=!0),r&&(a+=d(n));return r?a:"0"},o.prototype.negate=function(){var e=l();return o.ZERO.subTo(this,e),e},o.prototype.abs=function(){return this.s<0?this.negate():this},o.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var n=this.t;if(0!=(t=n-e.t))return this.s<0?-t:t;for(;--n>=0;)if(0!=(t=this[n]-e[n]))return t;return 0},o.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+m(this[this.t-1]^this.s&this.DM)},o.prototype.mod=function(e){var t=l();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(o.ZERO)>0&&e.subTo(t,t),t},o.prototype.modPowInt=function(e,t){var n;return n=e<256||t.isEven()?new g(t):new v(t),this.exp(e,n)},o.ZERO=f(0),o.ONE=f(1),M.prototype.convert=E,M.prototype.revert=E,M.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n)},M.prototype.sqrTo=function(e,t){e.squareTo(t)},T.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=l();return e.copyTo(t),this.reduce(t),t},T.prototype.revert=function(e){return e},T.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},T.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n),this.reduce(n)},T.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var A=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],C=(1<<26)/A[A.length-1];o.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},o.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),n=Math.pow(e,t),i=f(n),r=l(),a=l(),s="";for(this.divRemTo(i,r,a);r.signum()>0;)s=(n+a.intValue()).toString(e).substr(1)+s,r.divRemTo(i,r,a);return a.intValue().toString(e)+s},o.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var n=this.chunkSize(t),i=Math.pow(t,n),r=!1,a=0,s=0,l=0;l=n&&(this.dMultiply(i),this.dAddOffset(s,0),a=0,s=0))}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(s,0)),r&&o.ZERO.subTo(this,this)},o.prototype.fromNumber=function(e,t,n){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo(o.ONE.shiftLeft(e-1),x,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(o.ONE.shiftLeft(e-1),this);else{var i=new Array,r=7&e;i.length=1+(e>>3),t.nextBytes(i),r>0?i[0]&=(1<>=this.DB;if(e.t>=this.DB;i+=this.s}else{for(i+=this.s;n>=this.DB;i+=e.s}t.s=i<0?-1:0,i>0?t[n++]=i:i<-1&&(t[n++]=this.DV+i),t.t=n,t.clamp()},o.prototype.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},o.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},o.prototype.multiplyLowerTo=function(e,t,n){var i,r=Math.min(this.t+e.t,t);for(n.s=0,n.t=r;r>0;)n[--r]=0;for(i=n.t-this.t;r=0;)n[i]=0;for(i=Math.max(t-this.t,0);i0)if(0==t)n=this[0]%e;else for(var i=this.t-1;i>=0;--i)n=(t*n+this[i])%e;return n},o.prototype.millerRabin=function(e){var t=this.subtract(o.ONE),n=t.getLowestSetBit();if(n<=0)return!1;var i=t.shiftRight(n);(e=e+1>>1)>A.length&&(e=A.length);for(var r=l(),a=0;a>24},o.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},o.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},o.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var n,i=this.DB-e*this.DB%8,r=0;if(e-- >0)for(i>i)!=(this.s&this.DM)>>i&&(t[r++]=n|this.s<=0;)i<8?(n=(this[e]&(1<>(i+=this.DB-8)):(n=this[e]>>(i-=8)&255,i<=0&&(i+=this.DB,--e)),128&n&&(n|=-256),0==r&&(128&this.s)!=(128&n)&&++r,(r>0||n!=this.s)&&(t[r++]=n);return t},o.prototype.equals=function(e){return 0==this.compareTo(e)},o.prototype.min=function(e){return this.compareTo(e)<0?this:e},o.prototype.max=function(e){return this.compareTo(e)>0?this:e},o.prototype.and=function(e){var t=l();return this.bitwiseTo(e,y,t),t},o.prototype.or=function(e){var t=l();return this.bitwiseTo(e,x,t),t},o.prototype.xor=function(e){var t=l();return this.bitwiseTo(e,b,t),t},o.prototype.andNot=function(e){var t=l();return this.bitwiseTo(e,_,t),t},o.prototype.not=function(){for(var e=l(),t=0;t=this.t?0!=this.s:0!=(this[t]&1<1){var u=l();for(i.sqrTo(s[1],u);o<=c;)s[o]=l(),i.mulTo(u,s[o-2],s[o]),o+=2}var d,p,y=e.t-1,x=!0,b=l();for(r=m(e[y])-1;y>=0;){for(r>=h?d=e[y]>>r-h&c:(d=(e[y]&(1<0&&(d|=e[y-1]>>this.DB+r-h)),o=n;!(1&d);)d>>=1,--o;if((r-=o)<0&&(r+=this.DB,--y),x)s[d].copyTo(a),x=!1;else{for(;o>1;)i.sqrTo(a,b),i.sqrTo(b,a),o-=2;o>0?i.sqrTo(a,b):(p=a,a=b,b=p),i.mulTo(b,s[d],a)}for(;y>=0&&!(e[y]&1<=0?(n.subTo(i,n),t&&r.subTo(s,r),a.subTo(l,a)):(i.subTo(n,i),t&&s.subTo(r,s),l.subTo(a,l))}return 0!=i.compareTo(o.ONE)?o.ZERO:l.compareTo(e)>=0?l.subtract(e):l.signum()<0?(l.addTo(e,l),l.signum()<0?l.add(e):l):l},o.prototype.pow=function(e){return this.exp(e,new M)},o.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),n=e.s<0?e.negate():e.clone();if(t.compareTo(n)<0){var i=t;t=n,n=i}var r=t.getLowestSetBit(),a=n.getLowestSetBit();if(a<0)return t;for(r0&&(t.rShiftTo(a,t),n.rShiftTo(a,n));t.signum()>0;)(r=t.getLowestSetBit())>0&&t.rShiftTo(r,t),(r=n.getLowestSetBit())>0&&n.rShiftTo(r,n),t.compareTo(n)>=0?(t.subTo(n,t),t.rShiftTo(1,t)):(n.subTo(t,n),n.rShiftTo(1,n));return a>0&&n.lShiftTo(a,n),n},o.prototype.isProbablePrime=function(e){var t,n=this.abs();if(1==n.t&&n[0]<=A[A.length-1]){for(t=0;t0},P.op_LessThan=function(e,t){return e.compareTo(t)<0},P.op_Addition=function(e,t){return new P(e,void 0,void 0).add(new P(t,void 0,void 0))},P.op_Subtraction=function(e,t){return new P(e,void 0,void 0).subtract(new P(t,void 0,void 0))},P.Int128Mul=function(e,t){return new P(e,void 0,void 0).multiply(new P(t,void 0,void 0))},P.op_Division=function(e,t){return e.divide(t)},P.prototype.ToDouble=function(){return parseFloat(this.toString())};var R=function(e,t){var n;if(void 0===Object.getOwnPropertyNames){for(n in t.prototype)(void 0===e.prototype[n]||e.prototype[n]===Object.prototype[n])&&(e.prototype[n]=t.prototype[n]);for(n in t)void 0===e[n]&&(e[n]=t[n]);e.$baseCtor=t}else{for(var i=Object.getOwnPropertyNames(t.prototype),r=0;r0?this.m_Childs[0]:this.GetNextSiblingUp()},n.PolyNode.prototype.GetNextSiblingUp=function(){return null===this.m_Parent?null:this.m_Index===this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+1]},n.PolyNode.prototype.Childs=function(){return this.m_Childs},n.PolyNode.prototype.Parent=function(){return this.m_Parent},n.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()},n.PolyTree=function(){this.m_AllPolys=[],n.PolyNode.call(this)},n.PolyTree.prototype.Clear=function(){for(var e=0,t=this.m_AllPolys.length;e0?this.m_Childs[0]:null},n.PolyTree.prototype.Total=function(){var e=this.m_AllPolys.length;return e>0&&this.m_Childs[0]!==this.m_AllPolys[0]&&e--,e},R(n.PolyTree,n.PolyNode),n.Math_Abs_Int64=n.Math_Abs_Int32=n.Math_Abs_Double=function(e){return Math.abs(e)},n.Math_Max_Int32_Int32=function(e,t){return Math.max(e,t)},s.msie||s.opera||s.safari?n.Cast_Int32=function(e){return 0|e}:n.Cast_Int32=function(e){return~~e},void 0===Number.toInteger&&(Number.toInteger=null),s.chrome?n.Cast_Int64=function(e){return e<-2147483648||e>2147483647?e<0?Math.ceil(e):Math.floor(e):~~e}:s.firefox&&"function"==typeof Number.toInteger?n.Cast_Int64=function(e){return Number.toInteger(e)}:s.msie7||s.msie8?n.Cast_Int64=function(e){return parseInt(e,10)}:s.msie?n.Cast_Int64=function(e){return e<-2147483648||e>2147483647?e<0?Math.ceil(e):Math.floor(e):0|e}:n.Cast_Int64=function(e){return e<0?Math.ceil(e):Math.floor(e)},n.Clear=function(e){e.length=0},n.PI=3.141592653589793,n.PI2=6.283185307179586,n.IntPoint=function(){var e=arguments,t=e.length;if(this.X=0,this.Y=0,n.use_xyz)if(this.Z=0,3===t)this.X=e[0],this.Y=e[1],this.Z=e[2];else if(2===t)this.X=e[0],this.Y=e[1],this.Z=0;else if(1===t)if(e[0]instanceof n.DoublePoint){var i=e[0];this.X=n.Clipper.Round(i.X),this.Y=n.Clipper.Round(i.Y),this.Z=0}else void 0===(r=e[0]).Z&&(r.Z=0),this.X=r.X,this.Y=r.Y,this.Z=r.Z;else this.X=0,this.Y=0,this.Z=0;else if(2===t)this.X=e[0],this.Y=e[1];else if(1===t)if(e[0]instanceof n.DoublePoint)i=e[0],this.X=n.Clipper.Round(i.X),this.Y=n.Clipper.Round(i.Y);else{var r=e[0];this.X=r.X,this.Y=r.Y}else this.X=0,this.Y=0},n.IntPoint.op_Equality=function(e,t){return e.X===t.X&&e.Y===t.Y},n.IntPoint.op_Inequality=function(e,t){return e.X!==t.X||e.Y!==t.Y},n.IntPoint0=function(){this.X=0,this.Y=0,n.use_xyz&&(this.Z=0)},n.IntPoint0.prototype=n.IntPoint.prototype,n.IntPoint1=function(e){this.X=e.X,this.Y=e.Y,n.use_xyz&&(void 0===e.Z?this.Z=0:this.Z=e.Z)},n.IntPoint1.prototype=n.IntPoint.prototype,n.IntPoint1dp=function(e){this.X=n.Clipper.Round(e.X),this.Y=n.Clipper.Round(e.Y),n.use_xyz&&(this.Z=0)},n.IntPoint1dp.prototype=n.IntPoint.prototype,n.IntPoint2=function(e,t,i){this.X=e,this.Y=t,n.use_xyz&&(this.Z=void 0===i?0:i)},n.IntPoint2.prototype=n.IntPoint.prototype,n.IntRect=function(){var e=arguments,t=e.length;if(4===t)this.left=e[0],this.top=e[1],this.right=e[2],this.bottom=e[3];else if(1===t){var n=e[0];this.left=n.left,this.top=n.top,this.right=n.right,this.bottom=n.bottom}else this.left=0,this.top=0,this.right=0,this.bottom=0},n.IntRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0},n.IntRect0.prototype=n.IntRect.prototype,n.IntRect1=function(e){this.left=e.left,this.top=e.top,this.right=e.right,this.bottom=e.bottom},n.IntRect1.prototype=n.IntRect.prototype,n.IntRect4=function(e,t,n,i){this.left=e,this.top=t,this.right=n,this.bottom=i},n.IntRect4.prototype=n.IntRect.prototype,n.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},n.PolyType={ptSubject:0,ptClip:1},n.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},n.JoinType={jtSquare:0,jtRound:1,jtMiter:2},n.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},n.EdgeSide={esLeft:0,esRight:1},n.Direction={dRightToLeft:0,dLeftToRight:1},n.TEdge=function(){this.Bot=new n.IntPoint0,this.Curr=new n.IntPoint0,this.Top=new n.IntPoint0,this.Delta=new n.IntPoint0,this.Dx=0,this.PolyTyp=n.PolyType.ptSubject,this.Side=n.EdgeSide.esLeft,this.WindDelta=0,this.WindCnt=0,this.WindCnt2=0,this.OutIdx=0,this.Next=null,this.Prev=null,this.NextInLML=null,this.NextInAEL=null,this.PrevInAEL=null,this.NextInSEL=null,this.PrevInSEL=null},n.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new n.IntPoint0},n.MyIntersectNodeSort=function(){},n.MyIntersectNodeSort.Compare=function(e,t){var n=t.Pt.Y-e.Pt.Y;return n>0?1:n<0?-1:0},n.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null},n.Scanbeam=function(){this.Y=0,this.Next=null},n.Maxima=function(){this.X=0,this.Next=null,this.Prev=null},n.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null},n.OutPt=function(){this.Idx=0,this.Pt=new n.IntPoint0,this.Next=null,this.Prev=null},n.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new n.IntPoint0},n.ClipperBase=function(){this.m_MinimaList=null,this.m_CurrentLM=null,this.m_edges=new Array,this.m_UseFullRange=!1,this.m_HasOpenPaths=!1,this.PreserveCollinear=!1,this.m_Scanbeam=null,this.m_PolyOuts=null,this.m_ActiveEdges=null},n.ClipperBase.horizontal=-9007199254740992,n.ClipperBase.Skip=-2,n.ClipperBase.Unassigned=-1,n.ClipperBase.tolerance=1e-20,n.ClipperBase.loRange=47453132,n.ClipperBase.hiRange=0xfffffffffffff,n.ClipperBase.near_zero=function(e){return e>-n.ClipperBase.tolerance&&et.X==e.Xt.Y==e.Yt.X==e.Xt.Y==e.Yn.ClipperBase.hiRange||e.Y>n.ClipperBase.hiRange||-e.X>n.ClipperBase.hiRange||-e.Y>n.ClipperBase.hiRange)&&n.Error("Coordinate outside allowed range in RangeTest()."):(e.X>n.ClipperBase.loRange||e.Y>n.ClipperBase.loRange||-e.X>n.ClipperBase.loRange||-e.Y>n.ClipperBase.loRange)&&(t.Value=!0,this.RangeTest(e,t))},n.ClipperBase.prototype.InitEdge=function(e,t,i,r){e.Next=t,e.Prev=i,e.Curr.X=r.X,e.Curr.Y=r.Y,n.use_xyz&&(e.Curr.Z=r.Z),e.OutIdx=-1},n.ClipperBase.prototype.InitEdge2=function(e,t){e.Curr.Y>=e.Next.Curr.Y?(e.Bot.X=e.Curr.X,e.Bot.Y=e.Curr.Y,n.use_xyz&&(e.Bot.Z=e.Curr.Z),e.Top.X=e.Next.Curr.X,e.Top.Y=e.Next.Curr.Y,n.use_xyz&&(e.Top.Z=e.Next.Curr.Z)):(e.Top.X=e.Curr.X,e.Top.Y=e.Curr.Y,n.use_xyz&&(e.Top.Z=e.Curr.Z),e.Bot.X=e.Next.Curr.X,e.Bot.Y=e.Next.Curr.Y,n.use_xyz&&(e.Bot.Z=e.Next.Curr.Z)),this.SetDx(e),e.PolyTyp=t},n.ClipperBase.prototype.FindNextLocMin=function(e){for(var t;;){for(;n.IntPoint.op_Inequality(e.Bot,e.Prev.Bot)||n.IntPoint.op_Equality(e.Curr,e.Top);)e=e.Next;if(e.Dx!==n.ClipperBase.horizontal&&e.Prev.Dx!==n.ClipperBase.horizontal)break;for(;e.Prev.Dx===n.ClipperBase.horizontal;)e=e.Prev;for(t=e;e.Dx===n.ClipperBase.horizontal;)e=e.Next;if(e.Top.Y!==e.Prev.Bot.Y){t.Prev.Bot.Xa.Next.Top.X&&(a=r.Prev)}for(;e!==a;)e.NextInLML=e.Next,e.Dx===n.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),e=e.Next;e.Dx===n.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),a=a.Next}else{for(;a.Top.Y===a.Prev.Bot.Y&&a.Prev.OutIdx!==n.ClipperBase.Skip;)a=a.Prev;if(a.Dx===n.ClipperBase.horizontal&&a.Prev.OutIdx!==n.ClipperBase.Skip){for(r=a;r.Next.Dx===n.ClipperBase.horizontal;)r=r.Next;(r.Next.Top.X===a.Prev.Top.X||r.Next.Top.X>a.Prev.Top.X)&&(a=r.Next)}for(;e!==a;)e.NextInLML=e.Prev,e.Dx===n.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),e=e.Prev;e.Dx===n.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),a=a.Prev}return a},n.ClipperBase.prototype.AddPath=function(e,t,i){n.use_lines?!i&&t===n.PolyType.ptClip&&n.Error("AddPath: Open paths must be subject."):i||n.Error("AddPath: Open paths have been disabled.");var r=e.length-1;if(i)for(;r>0&&n.IntPoint.op_Equality(e[r],e[0]);)--r;for(;r>0&&n.IntPoint.op_Equality(e[r],e[r-1]);)--r;if(i&&r<2||!i&&r<1)return!1;for(var a=new Array,s=0;s<=r;s++)a.push(new n.TEdge);var o=!0;a[1].Curr.X=e[1].X,a[1].Curr.Y=e[1].Y,n.use_xyz&&(a[1].Curr.Z=e[1].Z);var l={Value:this.m_UseFullRange};for(this.RangeTest(e[0],l),this.m_UseFullRange=l.Value,l.Value=this.m_UseFullRange,this.RangeTest(e[r],l),this.m_UseFullRange=l.Value,this.InitEdge(a[0],a[1],a[r],e[0]),this.InitEdge(a[r],a[0],a[r-1],e[r]),s=r-1;s>=1;--s)l.Value=this.m_UseFullRange,this.RangeTest(e[s],l),this.m_UseFullRange=l.Value,this.InitEdge(a[s],a[s+1],a[s-1],e[s]);for(var h=a[0],c=h,u=h;;)if(c.Curr!==c.Next.Curr||!i&&c.Next===h){if(c.Prev===c.Next)break;if(!i||!n.ClipperBase.SlopesEqual4(c.Prev.Curr,c.Curr,c.Next.Curr,this.m_UseFullRange)||this.PreserveCollinear&&this.Pt2IsBetweenPt1AndPt3(c.Prev.Curr,c.Curr,c.Next.Curr)){if((c=c.Next)===u||!i&&c.Next===h)break}else c===h&&(h=c.Next),u=c=(c=this.RemoveEdge(c)).Prev}else{if(c===c.Next)break;c===h&&(h=c.Next),u=c=this.RemoveEdge(c)}if(!i&&c===c.Next||i&&c.Prev===c.Next)return!1;i||(this.m_HasOpenPaths=!0,h.Prev.OutIdx=n.ClipperBase.Skip),c=h;do{this.InitEdge2(c,t),c=c.Next,o&&c.Curr.Y!==h.Curr.Y&&(o=!1)}while(c!==h);if(o){if(i)return!1;for(c.Prev.OutIdx=n.ClipperBase.Skip,(f=new n.LocalMinima).Next=null,f.Y=c.Bot.Y,f.LeftBound=null,f.RightBound=c,f.RightBound.Side=n.EdgeSide.esRight,f.RightBound.WindDelta=0;c.Bot.X!==c.Prev.Top.X&&this.ReverseHorizontal(c),c.Next.OutIdx!==n.ClipperBase.Skip;)c.NextInLML=c.Next,c=c.Next;return this.InsertLocalMinima(f),this.m_edges.push(a),!0}this.m_edges.push(a);var d,p=null;for(n.IntPoint.op_Equality(c.Prev.Bot,c.Prev.Top)&&(c=c.Next);(c=this.FindNextLocMin(c))!==p;){var f;null===p&&(p=c),(f=new n.LocalMinima).Next=null,f.Y=c.Bot.Y,c.Dxe.X==t.Xe.Y==t.Y=this.m_MinimaList.Y)e.Next=this.m_MinimaList,this.m_MinimaList=e;else{for(var t=this.m_MinimaList;null!==t.Next&&e.Ythis.m_Scanbeam.Y){var t=new n.Scanbeam;t.Y=e,t.Next=this.m_Scanbeam,this.m_Scanbeam=t}else{for(var i=this.m_Scanbeam;null!==i.Next&&e<=i.Next.Y;)i=i.Next;if(e===i.Y)return;var r=new n.Scanbeam;r.Y=e,r.Next=i.Next,i.Next=r}},n.ClipperBase.prototype.PopScanbeam=function(e){return null===this.m_Scanbeam?(e.v=0,!1):(e.v=this.m_Scanbeam.Y,this.m_Scanbeam=this.m_Scanbeam.Next,!0)},n.ClipperBase.prototype.LocalMinimaPending=function(){return null!==this.m_CurrentLM},n.ClipperBase.prototype.CreateOutRec=function(){var e=new n.OutRec;return e.Idx=n.ClipperBase.Unassigned,e.IsHole=!1,e.IsOpen=!1,e.FirstLeft=null,e.Pts=null,e.BottomPt=null,e.PolyNode=null,this.m_PolyOuts.push(e),e.Idx=this.m_PolyOuts.length-1,e},n.ClipperBase.prototype.DisposeOutRec=function(e){var t=this.m_PolyOuts[e];t.Pts=null,t=null,this.m_PolyOuts[e]=null},n.ClipperBase.prototype.UpdateEdgeIntoAEL=function(e){null===e.NextInLML&&n.Error("UpdateEdgeIntoAEL: invalid call");var t=e.PrevInAEL,i=e.NextInAEL;return e.NextInLML.OutIdx=e.OutIdx,null!==t?t.NextInAEL=e.NextInLML:this.m_ActiveEdges=e.NextInLML,null!==i&&(i.PrevInAEL=e.NextInLML),e.NextInLML.Side=e.Side,e.NextInLML.WindDelta=e.WindDelta,e.NextInLML.WindCnt=e.WindCnt,e.NextInLML.WindCnt2=e.WindCnt2,(e=e.NextInLML).Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,e.PrevInAEL=t,e.NextInAEL=i,n.ClipperBase.IsHorizontal(e)||this.InsertScanbeam(e.Top.Y),e},n.ClipperBase.prototype.SwapPositionsInAEL=function(e,t){if(e.NextInAEL!==e.PrevInAEL&&t.NextInAEL!==t.PrevInAEL){if(e.NextInAEL===t){var n=t.NextInAEL;null!==n&&(n.PrevInAEL=e);var i=e.PrevInAEL;null!==i&&(i.NextInAEL=t),t.PrevInAEL=i,t.NextInAEL=e,e.PrevInAEL=t,e.NextInAEL=n}else if(t.NextInAEL===e){var r=e.NextInAEL;null!==r&&(r.PrevInAEL=t);var a=t.PrevInAEL;null!==a&&(a.NextInAEL=e),e.PrevInAEL=a,e.NextInAEL=t,t.PrevInAEL=e,t.NextInAEL=r}else{var s=e.NextInAEL,o=e.PrevInAEL;e.NextInAEL=t.NextInAEL,null!==e.NextInAEL&&(e.NextInAEL.PrevInAEL=e),e.PrevInAEL=t.PrevInAEL,null!==e.PrevInAEL&&(e.PrevInAEL.NextInAEL=e),t.NextInAEL=s,null!==t.NextInAEL&&(t.NextInAEL.PrevInAEL=t),t.PrevInAEL=o,null!==t.PrevInAEL&&(t.PrevInAEL.NextInAEL=t)}null===e.PrevInAEL?this.m_ActiveEdges=e:null===t.PrevInAEL&&(this.m_ActiveEdges=t)}},n.ClipperBase.prototype.DeleteFromAEL=function(e){var t=e.PrevInAEL,n=e.NextInAEL;null===t&&null===n&&e!==this.m_ActiveEdges||(null!==t?t.NextInAEL=n:this.m_ActiveEdges=n,null!==n&&(n.PrevInAEL=t),e.NextInAEL=null,e.PrevInAEL=null)},n.Clipper=function(e){void 0===e&&(e=0),this.m_PolyOuts=null,this.m_ClipType=n.ClipType.ctIntersection,this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=null,this.m_IntersectNodeComparer=null,this.m_ExecuteLocked=!1,this.m_ClipFillType=n.PolyFillType.pftEvenOdd,this.m_SubjFillType=n.PolyFillType.pftEvenOdd,this.m_Joins=null,this.m_GhostJoins=null,this.m_UsingPolyTree=!1,this.ReverseSolution=!1,this.StrictlySimple=!1,n.ClipperBase.call(this),this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=new Array,this.m_IntersectNodeComparer=n.MyIntersectNodeSort.Compare,this.m_ExecuteLocked=!1,this.m_UsingPolyTree=!1,this.m_PolyOuts=new Array,this.m_Joins=new Array,this.m_GhostJoins=new Array,this.ReverseSolution=0!=(1&e),this.StrictlySimple=0!=(2&e),this.PreserveCollinear=0!=(4&e),n.use_xyz&&(this.ZFillFunction=null)},n.Clipper.ioReverseSolution=1,n.Clipper.ioStrictlySimple=2,n.Clipper.ioPreserveCollinear=4,n.Clipper.prototype.Clear=function(){0!==this.m_edges.length&&(this.DisposeAllPolyPts(),n.ClipperBase.prototype.Clear.call(this))},n.Clipper.prototype.InsertMaxima=function(e){var t=new n.Maxima;if(t.X=e,null===this.m_Maxima)this.m_Maxima=t,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(e=i.Next.X;)i=i.Next;if(e===i.X)return;t.Next=i.Next,t.Prev=i,null!==i.Next&&(i.Next.Prev=t),i.Next=t}},n.Clipper.prototype.Execute=function(){var e=arguments,t=e.length,i=e[1]instanceof n.PolyTree;if(4===t&&!i){var r=e[0],a=e[1],s=e[2],o=e[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&n.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,n.Clear(a),this.m_SubjFillType=s,this.m_ClipFillType=o,this.m_ClipType=r,this.m_UsingPolyTree=!1;try{(h=this.ExecuteInternal())&&this.BuildResult(a)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return h}if(4===t&&i){r=e[0];var l=e[1];if(s=e[2],o=e[3],this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=s,this.m_ClipFillType=o,this.m_ClipType=r,this.m_UsingPolyTree=!0;try{var h;(h=this.ExecuteInternal())&&this.BuildResult2(l)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return h}return 2!==t||i?2===t&&i?(r=e[0],l=e[1],this.Execute(r,l,n.PolyFillType.pftEvenOdd,n.PolyFillType.pftEvenOdd)):void 0:(r=e[0],a=e[1],this.Execute(r,a,n.PolyFillType.pftEvenOdd,n.PolyFillType.pftEvenOdd))},n.Clipper.prototype.FixHoleLinkage=function(e){if(null!==e.FirstLeft&&(e.IsHole===e.FirstLeft.IsHole||null===e.FirstLeft.Pts)){for(var t=e.FirstLeft;null!==t&&(t.IsHole===e.IsHole||null===t.Pts);)t=t.FirstLeft;e.FirstLeft=t}},n.Clipper.prototype.ExecuteInternal=function(){try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var e,t,n,i={},r={};if(!this.PopScanbeam(i))return!1;for(this.InsertLocalMinimaIntoAEL(i.v);this.PopScanbeam(r)||this.LocalMinimaPending();){if(this.ProcessHorizontals(),this.m_GhostJoins.length=0,!this.ProcessIntersections(r.v))return!1;this.ProcessEdgesAtTopOfScanbeam(r.v),i.v=r.v,this.InsertLocalMinimaIntoAEL(i.v)}for(t=0,n=this.m_PolyOuts.length;t0&&this.ReversePolyPtLinks(e.Pts);for(this.JoinCommonEdges(),t=0,n=this.m_PolyOuts.length;t0&&0!==i.WindDelta)for(var s=0,o=this.m_GhostJoins.length;s=0&&null!==t.PrevInAEL&&t.PrevInAEL.Curr.X===t.Bot.X&&t.PrevInAEL.OutIdx>=0&&n.ClipperBase.SlopesEqual5(t.PrevInAEL.Curr,t.PrevInAEL.Top,t.Curr,t.Top,this.m_UseFullRange)&&0!==t.WindDelta&&0!==t.PrevInAEL.WindDelta){var h=this.AddOutPt(t.PrevInAEL,t.Bot);this.AddJoin(a,h,t.Top)}if(t.NextInAEL!==i){i.OutIdx>=0&&i.PrevInAEL.OutIdx>=0&&n.ClipperBase.SlopesEqual5(i.PrevInAEL.Curr,i.PrevInAEL.Top,i.Curr,i.Top,this.m_UseFullRange)&&0!==i.WindDelta&&0!==i.PrevInAEL.WindDelta&&(h=this.AddOutPt(i.PrevInAEL,i.Bot),this.AddJoin(a,h,i.Top));var c=t.NextInAEL;if(null!==c)for(;c!==i;)this.IntersectEdges(i,c,t.Curr),c=c.NextInAEL}}}},n.Clipper.prototype.InsertEdgeIntoAEL=function(e,t){if(null===this.m_ActiveEdges)e.PrevInAEL=null,e.NextInAEL=null,this.m_ActiveEdges=e;else if(null===t&&this.E2InsertsBeforeE1(this.m_ActiveEdges,e))e.PrevInAEL=null,e.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=e,this.m_ActiveEdges=e;else{for(null===t&&(t=this.m_ActiveEdges);null!==t.NextInAEL&&!this.E2InsertsBeforeE1(t.NextInAEL,e);)t=t.NextInAEL;e.NextInAEL=t.NextInAEL,null!==t.NextInAEL&&(t.NextInAEL.PrevInAEL=e),e.PrevInAEL=t,t.NextInAEL=e}},n.Clipper.prototype.E2InsertsBeforeE1=function(e,t){return t.Curr.X===e.Curr.X?t.Top.Y>e.Top.Y?t.Top.Xn.Clipper.TopX(t,e.Top.Y):t.Curr.X0;default:return e.WindCnt2<0}case n.ClipType.ctUnion:switch(i){case n.PolyFillType.pftEvenOdd:case n.PolyFillType.pftNonZero:return 0===e.WindCnt2;case n.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}case n.ClipType.ctDifference:if(e.PolyTyp===n.PolyType.ptSubject)switch(i){case n.PolyFillType.pftEvenOdd:case n.PolyFillType.pftNonZero:return 0===e.WindCnt2;case n.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}else switch(i){case n.PolyFillType.pftEvenOdd:case n.PolyFillType.pftNonZero:return 0!==e.WindCnt2;case n.PolyFillType.pftPositive:return e.WindCnt2>0;default:return e.WindCnt2<0}case n.ClipType.ctXor:if(0!==e.WindDelta)return!0;switch(i){case n.PolyFillType.pftEvenOdd:case n.PolyFillType.pftNonZero:return 0===e.WindCnt2;case n.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}}return!0},n.Clipper.prototype.SetWindingCount=function(e){for(var t=e.PrevInAEL;null!==t&&(t.PolyTyp!==e.PolyTyp||0===t.WindDelta);)t=t.PrevInAEL;if(null===t){var i=e.PolyTyp===n.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;0===e.WindDelta?e.WindCnt=i===n.PolyFillType.pftNegative?-1:1:e.WindCnt=e.WindDelta,e.WindCnt2=0,t=this.m_ActiveEdges}else if(0===e.WindDelta&&this.m_ClipType!==n.ClipType.ctUnion)e.WindCnt=1,e.WindCnt2=t.WindCnt2,t=t.NextInAEL;else if(this.IsEvenOddFillType(e)){if(0===e.WindDelta){for(var r=!0,a=t.PrevInAEL;null!==a;)a.PolyTyp===t.PolyTyp&&0!==a.WindDelta&&(r=!r),a=a.PrevInAEL;e.WindCnt=r?0:1}else e.WindCnt=e.WindDelta;e.WindCnt2=t.WindCnt2,t=t.NextInAEL}else t.WindCnt*t.WindDelta<0?Math.abs(t.WindCnt)>1?t.WindDelta*e.WindDelta<0?e.WindCnt=t.WindCnt:e.WindCnt=t.WindCnt+e.WindDelta:e.WindCnt=0===e.WindDelta?1:e.WindDelta:0===e.WindDelta?e.WindCnt=t.WindCnt<0?t.WindCnt-1:t.WindCnt+1:t.WindDelta*e.WindDelta<0?e.WindCnt=t.WindCnt:e.WindCnt=t.WindCnt+e.WindDelta,e.WindCnt2=t.WindCnt2,t=t.NextInAEL;if(this.IsEvenOddAltFillType(e))for(;t!==e;)0!==t.WindDelta&&(e.WindCnt2=0===e.WindCnt2?1:0),t=t.NextInAEL;else for(;t!==e;)e.WindCnt2+=t.WindDelta,t=t.NextInAEL},n.Clipper.prototype.AddEdgeToSEL=function(e){null===this.m_SortedEdges?(this.m_SortedEdges=e,e.PrevInSEL=null,e.NextInSEL=null):(e.NextInSEL=this.m_SortedEdges,e.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=e,this.m_SortedEdges=e)},n.Clipper.prototype.PopEdgeFromSEL=function(e){if(e.v=this.m_SortedEdges,null===e.v)return!1;var t=e.v;return this.m_SortedEdges=e.v.NextInSEL,null!==this.m_SortedEdges&&(this.m_SortedEdges.PrevInSEL=null),t.NextInSEL=null,t.PrevInSEL=null,!0},n.Clipper.prototype.CopyAELToSEL=function(){var e=this.m_ActiveEdges;for(this.m_SortedEdges=e;null!==e;)e.PrevInSEL=e.PrevInAEL,e.NextInSEL=e.NextInAEL,e=e.NextInAEL},n.Clipper.prototype.SwapPositionsInSEL=function(e,t){if(!(null===e.NextInSEL&&null===e.PrevInSEL||null===t.NextInSEL&&null===t.PrevInSEL)){if(e.NextInSEL===t)null!==(n=t.NextInSEL)&&(n.PrevInSEL=e),null!==(i=e.PrevInSEL)&&(i.NextInSEL=t),t.PrevInSEL=i,t.NextInSEL=e,e.PrevInSEL=t,e.NextInSEL=n;else if(t.NextInSEL===e)null!==(n=e.NextInSEL)&&(n.PrevInSEL=t),null!==(i=t.PrevInSEL)&&(i.NextInSEL=e),e.PrevInSEL=i,e.NextInSEL=t,t.PrevInSEL=e,t.NextInSEL=n;else{var n=e.NextInSEL,i=e.PrevInSEL;e.NextInSEL=t.NextInSEL,null!==e.NextInSEL&&(e.NextInSEL.PrevInSEL=e),e.PrevInSEL=t.PrevInSEL,null!==e.PrevInSEL&&(e.PrevInSEL.NextInSEL=e),t.NextInSEL=n,null!==t.NextInSEL&&(t.NextInSEL.PrevInSEL=t),t.PrevInSEL=i,null!==t.PrevInSEL&&(t.PrevInSEL.NextInSEL=t)}null===e.PrevInSEL?this.m_SortedEdges=e:null===t.PrevInSEL&&(this.m_SortedEdges=t)}},n.Clipper.prototype.AddLocalMaxPoly=function(e,t,n){this.AddOutPt(e,n),0===t.WindDelta&&this.AddOutPt(t,n),e.OutIdx===t.OutIdx?(e.OutIdx=-1,t.OutIdx=-1):e.OutIdxt.Dx?(r=this.AddOutPt(e,i),t.OutIdx=e.OutIdx,e.Side=n.EdgeSide.esLeft,t.Side=n.EdgeSide.esRight,s=(a=e).PrevInAEL===t?t.PrevInAEL:a.PrevInAEL):(r=this.AddOutPt(t,i),e.OutIdx=t.OutIdx,e.Side=n.EdgeSide.esRight,t.Side=n.EdgeSide.esLeft,s=(a=t).PrevInAEL===e?e.PrevInAEL:a.PrevInAEL),null!==s&&s.OutIdx>=0&&s.Top.Yt&&(r=e,e=t,t=r),n>i&&(r=n,n=i,i=r),e=0&&0!==n.WindDelta&&(null===i?i=n:i.OutIdx===n.OutIdx&&(i=null)),n=n.PrevInAEL;null===i?(t.FirstLeft=null,t.IsHole=!1):(t.FirstLeft=this.m_PolyOuts[i.OutIdx],t.IsHole=!t.FirstLeft.IsHole)},n.Clipper.prototype.GetDx=function(e,t){return e.Y===t.Y?n.ClipperBase.horizontal:(t.X-e.X)/(t.Y-e.Y)},n.Clipper.prototype.FirstIsBottomPt=function(e,t){for(var i=e.Prev;n.IntPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Prev;var r=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=e.Next;n.IntPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Next;var a=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=t.Prev;n.IntPoint.op_Equality(i.Pt,t.Pt)&&i!==t;)i=i.Prev;var s=Math.abs(this.GetDx(t.Pt,i.Pt));for(i=t.Next;n.IntPoint.op_Equality(i.Pt,t.Pt)&&i!==t;)i=i.Next;var o=Math.abs(this.GetDx(t.Pt,i.Pt));return Math.max(r,a)===Math.max(s,o)&&Math.min(r,a)===Math.min(s,o)?this.Area(e)>0:r>=s&&r>=o||a>=s&&a>=o},n.Clipper.prototype.GetBottomPt=function(e){for(var t=null,i=e.Next;i!==e;)i.Pt.Y>e.Pt.Y?(e=i,t=null):i.Pt.Y===e.Pt.Y&&i.Pt.X<=e.Pt.X&&(i.Pt.Xi.Pt.Y?e:n.Pt.Yi.Pt.X||n.Next===n?t:i.Next===i||this.FirstIsBottomPt(n,i)?e:t},n.Clipper.prototype.OutRec1RightOfOutRec2=function(e,t){do{if((e=e.FirstLeft)===t)return!0}while(null!==e);return!1},n.Clipper.prototype.GetOutRec=function(e){for(var t=this.m_PolyOuts[e];t!==this.m_PolyOuts[t.Idx];)t=this.m_PolyOuts[t.Idx];return t},n.Clipper.prototype.AppendPolygon=function(e,t){var i,r=this.m_PolyOuts[e.OutIdx],a=this.m_PolyOuts[t.OutIdx];i=this.OutRec1RightOfOutRec2(r,a)?a:this.OutRec1RightOfOutRec2(a,r)?r:this.GetLowermostRec(r,a);var s=r.Pts,o=s.Prev,l=a.Pts,h=l.Prev;e.Side===n.EdgeSide.esLeft?t.Side===n.EdgeSide.esLeft?(this.ReversePolyPtLinks(l),l.Next=s,s.Prev=l,o.Next=h,h.Prev=o,r.Pts=h):(h.Next=s,s.Prev=h,l.Prev=o,o.Next=l,r.Pts=l):t.Side===n.EdgeSide.esRight?(this.ReversePolyPtLinks(l),o.Next=h,h.Prev=o,l.Next=s,s.Prev=l):(o.Next=l,l.Prev=o,s.Prev=h,h.Next=s),r.BottomPt=null,i===a&&(a.FirstLeft!==r&&(r.FirstLeft=a.FirstLeft),r.IsHole=a.IsHole),a.Pts=null,a.BottomPt=null,a.FirstLeft=r;var c=e.OutIdx,u=t.OutIdx;e.OutIdx=-1,t.OutIdx=-1;for(var d=this.m_ActiveEdges;null!==d;){if(d.OutIdx===u){d.OutIdx=c,d.Side=e.Side;break}d=d.NextInAEL}a.Idx=r.Idx},n.Clipper.prototype.ReversePolyPtLinks=function(e){if(null!==e){var t,n;t=e;do{n=t.Next,t.Next=t.Prev,t.Prev=n,t=n}while(t!==e)}},n.Clipper.SwapSides=function(e,t){var n=e.Side;e.Side=t.Side,t.Side=n},n.Clipper.SwapPolyIndexes=function(e,t){var n=e.OutIdx;e.OutIdx=t.OutIdx,t.OutIdx=n},n.Clipper.prototype.IntersectEdges=function(e,t,i){var r=e.OutIdx>=0,a=t.OutIdx>=0;if(n.use_xyz&&this.SetZ(i,e,t),!n.use_lines||0!==e.WindDelta&&0!==t.WindDelta){if(e.PolyTyp===t.PolyTyp)if(this.IsEvenOddFillType(e)){var s=e.WindCnt;e.WindCnt=t.WindCnt,t.WindCnt=s}else e.WindCnt+t.WindDelta===0?e.WindCnt=-e.WindCnt:e.WindCnt+=t.WindDelta,t.WindCnt-e.WindDelta==0?t.WindCnt=-t.WindCnt:t.WindCnt-=e.WindDelta;else this.IsEvenOddFillType(t)?e.WindCnt2=0===e.WindCnt2?1:0:e.WindCnt2+=t.WindDelta,this.IsEvenOddFillType(e)?t.WindCnt2=0===t.WindCnt2?1:0:t.WindCnt2-=e.WindDelta;var o,l,h,c,u,d;switch(e.PolyTyp===n.PolyType.ptSubject?(o=this.m_SubjFillType,h=this.m_ClipFillType):(o=this.m_ClipFillType,h=this.m_SubjFillType),t.PolyTyp===n.PolyType.ptSubject?(l=this.m_SubjFillType,c=this.m_ClipFillType):(l=this.m_ClipFillType,c=this.m_SubjFillType),o){case n.PolyFillType.pftPositive:u=e.WindCnt;break;case n.PolyFillType.pftNegative:u=-e.WindCnt;break;default:u=Math.abs(e.WindCnt)}switch(l){case n.PolyFillType.pftPositive:d=t.WindCnt;break;case n.PolyFillType.pftNegative:d=-t.WindCnt;break;default:d=Math.abs(t.WindCnt)}if(r&&a)0!==u&&1!==u||0!==d&&1!==d||e.PolyTyp!==t.PolyTyp&&this.m_ClipType!==n.ClipType.ctXor?this.AddLocalMaxPoly(e,t,i):(this.AddOutPt(e,i),this.AddOutPt(t,i),n.Clipper.SwapSides(e,t),n.Clipper.SwapPolyIndexes(e,t));else if(r)(0===d||1===d)&&(this.AddOutPt(e,i),n.Clipper.SwapSides(e,t),n.Clipper.SwapPolyIndexes(e,t));else if(a)(0===u||1===u)&&(this.AddOutPt(t,i),n.Clipper.SwapSides(e,t),n.Clipper.SwapPolyIndexes(e,t));else if(!(0!==u&&1!==u||0!==d&&1!==d)){var p,f;switch(h){case n.PolyFillType.pftPositive:p=e.WindCnt2;break;case n.PolyFillType.pftNegative:p=-e.WindCnt2;break;default:p=Math.abs(e.WindCnt2)}switch(c){case n.PolyFillType.pftPositive:f=t.WindCnt2;break;case n.PolyFillType.pftNegative:f=-t.WindCnt2;break;default:f=Math.abs(t.WindCnt2)}if(e.PolyTyp!==t.PolyTyp)this.AddLocalMinPoly(e,t,i);else if(1===u&&1===d)switch(this.m_ClipType){case n.ClipType.ctIntersection:p>0&&f>0&&this.AddLocalMinPoly(e,t,i);break;case n.ClipType.ctUnion:p<=0&&f<=0&&this.AddLocalMinPoly(e,t,i);break;case n.ClipType.ctDifference:(e.PolyTyp===n.PolyType.ptClip&&p>0&&f>0||e.PolyTyp===n.PolyType.ptSubject&&p<=0&&f<=0)&&this.AddLocalMinPoly(e,t,i);break;case n.ClipType.ctXor:this.AddLocalMinPoly(e,t,i)}else n.Clipper.SwapSides(e,t)}}else{if(0===e.WindDelta&&0===t.WindDelta)return;e.PolyTyp===t.PolyTyp&&e.WindDelta!==t.WindDelta&&this.m_ClipType===n.ClipType.ctUnion?0===e.WindDelta?a&&(this.AddOutPt(e,i),r&&(e.OutIdx=-1)):r&&(this.AddOutPt(t,i),a&&(t.OutIdx=-1)):e.PolyTyp!==t.PolyTyp&&(0!==e.WindDelta||1!==Math.abs(t.WindCnt)||this.m_ClipType===n.ClipType.ctUnion&&0!==t.WindCnt2?0===t.WindDelta&&1===Math.abs(e.WindCnt)&&(this.m_ClipType!==n.ClipType.ctUnion||0===e.WindCnt2)&&(this.AddOutPt(t,i),a&&(t.OutIdx=-1)):(this.AddOutPt(e,i),r&&(e.OutIdx=-1)))}},n.Clipper.prototype.DeleteFromSEL=function(e){var t=e.PrevInSEL,n=e.NextInSEL;null===t&&null===n&&e!==this.m_SortedEdges||(null!==t?t.NextInSEL=n:this.m_SortedEdges=n,null!==n&&(n.PrevInSEL=t),e.NextInSEL=null,e.PrevInSEL=null)},n.Clipper.prototype.ProcessHorizontals=function(){for(var e={};this.PopEdgeFromSEL(e);)this.ProcessHorizontal(e.v)},n.Clipper.prototype.GetHorzDirection=function(e,t){e.Bot.X=o.Top.X&&(h=null)}else{for(;null!==h.Next&&h.Next.X=0&&!s&&this.AddOutPt(e,new n.IntPoint2(h.X,e.Bot.Y)),h=h.Next;else for(;null!==h&&h.X>d.Curr.X;)e.OutIdx>=0&&!s&&this.AddOutPt(e,new n.IntPoint2(h.X,e.Bot.Y)),h=h.Prev;if(i===n.Direction.dLeftToRight&&d.Curr.X>a||i===n.Direction.dRightToLeft&&d.Curr.X=0&&!s){n.use_xyz&&(i===n.Direction.dLeftToRight?this.SetZ(d.Curr,e,d):this.SetZ(d.Curr,d,e)),c=this.AddOutPt(e,d.Curr);for(var p=this.m_SortedEdges;null!==p;){if(p.OutIdx>=0&&this.HorzSegmentsOverlap(e.Bot.X,e.Top.X,p.Bot.X,p.Top.X)){var f=this.GetLastOutPt(p);this.AddJoin(f,c,p.Top)}p=p.NextInSEL}this.AddGhostJoin(c,e.Bot)}if(d===l&&u)return e.OutIdx>=0&&this.AddLocalMaxPoly(e,l,e.Top),this.DeleteFromAEL(e),void this.DeleteFromAEL(l);if(i===n.Direction.dLeftToRight){var m=new n.IntPoint2(d.Curr.X,e.Curr.Y);this.IntersectEdges(e,d,m)}else m=new n.IntPoint2(d.Curr.X,e.Curr.Y),this.IntersectEdges(d,e,m);var g=this.GetNextInAEL(d,i);this.SwapPositionsInAEL(e,d),d=g}if(null===e.NextInLML||!n.ClipperBase.IsHorizontal(e.NextInLML))break;(e=this.UpdateEdgeIntoAEL(e)).OutIdx>=0&&this.AddOutPt(e,e.Bot),t={Dir:i,Left:r,Right:a},this.GetHorzDirection(e,t),i=t.Dir,r=t.Left,a=t.Right}if(e.OutIdx>=0&&null===c){for(c=this.GetLastOutPt(e),p=this.m_SortedEdges;null!==p;)p.OutIdx>=0&&this.HorzSegmentsOverlap(e.Bot.X,e.Top.X,p.Bot.X,p.Top.X)&&(f=this.GetLastOutPt(p),this.AddJoin(f,c,p.Top)),p=p.NextInSEL;this.AddGhostJoin(c,e.Top)}if(null!==e.NextInLML)if(e.OutIdx>=0){if(c=this.AddOutPt(e,e.Top),0===(e=this.UpdateEdgeIntoAEL(e)).WindDelta)return;var v=e.PrevInAEL;g=e.NextInAEL,null!==v&&v.Curr.X===e.Bot.X&&v.Curr.Y===e.Bot.Y&&0===v.WindDelta&&v.OutIdx>=0&&v.Curr.Y>v.Top.Y&&n.ClipperBase.SlopesEqual3(e,v,this.m_UseFullRange)?(f=this.AddOutPt(v,e.Bot),this.AddJoin(c,f,e.Top)):null!==g&&g.Curr.X===e.Bot.X&&g.Curr.Y===e.Bot.Y&&0!==g.WindDelta&&g.OutIdx>=0&&g.Curr.Y>g.Top.Y&&n.ClipperBase.SlopesEqual3(e,g,this.m_UseFullRange)&&(f=this.AddOutPt(g,e.Bot),this.AddJoin(c,f,e.Top))}else e=this.UpdateEdgeIntoAEL(e);else e.OutIdx>=0&&this.AddOutPt(e,e.Top),this.DeleteFromAEL(e)},n.Clipper.prototype.GetNextInAEL=function(e,t){return t===n.Direction.dLeftToRight?e.NextInAEL:e.PrevInAEL},n.Clipper.prototype.IsMinima=function(e){return null!==e&&e.Prev.NextInLML!==e&&e.Next.NextInLML!==e},n.Clipper.prototype.IsMaxima=function(e,t){return null!==e&&e.Top.Y===t&&null===e.NextInLML},n.Clipper.prototype.IsIntermediate=function(e,t){return e.Top.Y===t&&null!==e.NextInLML},n.Clipper.prototype.GetMaximaPair=function(e){return n.IntPoint.op_Equality(e.Next.Top,e.Top)&&null===e.Next.NextInLML?e.Next:n.IntPoint.op_Equality(e.Prev.Top,e.Top)&&null===e.Prev.NextInLML?e.Prev:null},n.Clipper.prototype.GetMaximaPairEx=function(e){var t=this.GetMaximaPair(e);return null===t||t.OutIdx===n.ClipperBase.Skip||t.NextInAEL===t.PrevInAEL&&!n.ClipperBase.IsHorizontal(t)?null:t},n.Clipper.prototype.ProcessIntersections=function(e){if(null===this.m_ActiveEdges)return!0;try{if(this.BuildIntersectList(e),0===this.m_IntersectList.length)return!0;if(1!==this.m_IntersectList.length&&!this.FixupIntersectionOrder())return!1;this.ProcessIntersectList()}catch(e){this.m_SortedEdges=null,this.m_IntersectList.length=0,n.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0},n.Clipper.prototype.BuildIntersectList=function(e){if(null!==this.m_ActiveEdges){var t=this.m_ActiveEdges;for(this.m_SortedEdges=t;null!==t;)t.PrevInSEL=t.PrevInAEL,t.NextInSEL=t.NextInAEL,t.Curr.X=n.Clipper.TopX(t,e),t=t.NextInAEL;for(var i=!0;i&&null!==this.m_SortedEdges;){for(i=!1,t=this.m_SortedEdges;null!==t.NextInSEL;){var r=t.NextInSEL,a=new n.IntPoint0;if(t.Curr.X>r.Curr.X){this.IntersectPoint(t,r,a),a.Y2147483647?Math.floor(e):0|e}:n.Clipper.Round=function(e){return e<0?Math.ceil(e-.5):Math.floor(e+.5)},n.Clipper.TopX=function(e,t){return t===e.Top.Y?e.Top.X:e.Bot.X+n.Clipper.Round(e.Dx*(t-e.Bot.Y))},n.Clipper.prototype.IntersectPoint=function(e,t,i){var r,a;if(i.X=0,i.Y=0,e.Dx===t.Dx)return i.Y=e.Curr.Y,void(i.X=n.Clipper.TopX(e,i.Y));if(0===e.Delta.X)i.X=e.Bot.X,n.ClipperBase.IsHorizontal(t)?i.Y=t.Bot.Y:(a=t.Bot.Y-t.Bot.X/t.Dx,i.Y=n.Clipper.Round(i.X/t.Dx+a));else if(0===t.Delta.X)i.X=t.Bot.X,n.ClipperBase.IsHorizontal(e)?i.Y=e.Bot.Y:(r=e.Bot.Y-e.Bot.X/e.Dx,i.Y=n.Clipper.Round(i.X/e.Dx+r));else{r=e.Bot.X-e.Bot.Y*e.Dx;var s=((a=t.Bot.X-t.Bot.Y*t.Dx)-r)/(e.Dx-t.Dx);i.Y=n.Clipper.Round(s),Math.abs(e.Dx)t.Top.Y)return i.Y=e.Top.Y,i.X=n.Clipper.TopX(t,e.Top.Y),i.Xe.Curr.Y&&(i.Y=e.Curr.Y,Math.abs(e.Dx)>Math.abs(t.Dx)?i.X=n.Clipper.TopX(t,i.Y):i.X=n.Clipper.TopX(e,i.Y))},n.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(e){for(var t=this.m_ActiveEdges;null!==t;){var i=this.IsMaxima(t,e);if(i){var r=this.GetMaximaPairEx(t);i=null===r||!n.ClipperBase.IsHorizontal(r)}if(i){this.StrictlySimple&&this.InsertMaxima(t.Top.X);var a=t.PrevInAEL;this.DoMaxima(t),t=null===a?this.m_ActiveEdges:a.NextInAEL}else{if(this.IsIntermediate(t,e)&&n.ClipperBase.IsHorizontal(t.NextInLML)?((t=this.UpdateEdgeIntoAEL(t)).OutIdx>=0&&this.AddOutPt(t,t.Bot),this.AddEdgeToSEL(t)):(t.Curr.X=n.Clipper.TopX(t,e),t.Curr.Y=e),n.use_xyz&&(t.Top.Y===e?t.Curr.Z=t.Top.Z:t.Bot.Y===e?t.Curr.Z=t.Bot.Z:t.Curr.Z=0),this.StrictlySimple&&(a=t.PrevInAEL,t.OutIdx>=0&&0!==t.WindDelta&&null!==a&&a.OutIdx>=0&&a.Curr.X===t.Curr.X&&0!==a.WindDelta)){var s=new n.IntPoint1(t.Curr);n.use_xyz&&this.SetZ(s,a,t);var o=this.AddOutPt(a,s),l=this.AddOutPt(t,s);this.AddJoin(o,l,s)}t=t.NextInAEL}}for(this.ProcessHorizontals(),this.m_Maxima=null,t=this.m_ActiveEdges;null!==t;){if(this.IsIntermediate(t,e)){o=null,t.OutIdx>=0&&(o=this.AddOutPt(t,t.Top)),a=(t=this.UpdateEdgeIntoAEL(t)).PrevInAEL;var h=t.NextInAEL;null!==a&&a.Curr.X===t.Bot.X&&a.Curr.Y===t.Bot.Y&&null!==o&&a.OutIdx>=0&&a.Curr.Y===a.Top.Y&&n.ClipperBase.SlopesEqual5(t.Curr,t.Top,a.Curr,a.Top,this.m_UseFullRange)&&0!==t.WindDelta&&0!==a.WindDelta?(l=this.AddOutPt(ePrev2,t.Bot),this.AddJoin(o,l,t.Top)):null!==h&&h.Curr.X===t.Bot.X&&h.Curr.Y===t.Bot.Y&&null!==o&&h.OutIdx>=0&&h.Curr.Y===h.Top.Y&&n.ClipperBase.SlopesEqual5(t.Curr,t.Top,h.Curr,h.Top,this.m_UseFullRange)&&0!==t.WindDelta&&0!==h.WindDelta&&(l=this.AddOutPt(h,t.Bot),this.AddJoin(o,l,t.Top))}t=t.NextInAEL}},n.Clipper.prototype.DoMaxima=function(e){var t=this.GetMaximaPairEx(e);if(null===t)return e.OutIdx>=0&&this.AddOutPt(e,e.Top),void this.DeleteFromAEL(e);for(var i=e.NextInAEL;null!==i&&i!==t;)this.IntersectEdges(e,i,e.Top),this.SwapPositionsInAEL(e,i),i=e.NextInAEL;-1===e.OutIdx&&-1===t.OutIdx?(this.DeleteFromAEL(e),this.DeleteFromAEL(t)):e.OutIdx>=0&&t.OutIdx>=0?(e.OutIdx>=0&&this.AddLocalMaxPoly(e,t,e.Top),this.DeleteFromAEL(e),this.DeleteFromAEL(t)):n.use_lines&&0===e.WindDelta?(e.OutIdx>=0&&(this.AddOutPt(e,e.Top),e.OutIdx=n.ClipperBase.Unassigned),this.DeleteFromAEL(e),t.OutIdx>=0&&(this.AddOutPt(t,e.Top),t.OutIdx=n.ClipperBase.Unassigned),this.DeleteFromAEL(t)):n.Error("DoMaxima error")},n.Clipper.ReversePaths=function(e){for(var t=0,n=e.length;t=0},n.Clipper.prototype.PointCount=function(e){if(null===e)return 0;var t=0,n=e;do{t++,n=n.Next}while(n!==e);return t},n.Clipper.prototype.BuildResult=function(e){n.Clear(e);for(var t=0,i=this.m_PolyOuts.length;tt.Pt.X?n.Direction.dRightToLeft:n.Direction.dLeftToRight,l=i.Pt.X>r.Pt.X?n.Direction.dRightToLeft:n.Direction.dLeftToRight;if(o===l)return!1;if(o===n.Direction.dLeftToRight){for(;e.Next.Pt.X<=a.X&&e.Next.Pt.X>=e.Pt.X&&e.Next.Pt.Y===a.Y;)e=e.Next;s&&e.Pt.X!==a.X&&(e=e.Next),t=this.DupOutPt(e,!s),n.IntPoint.op_Inequality(t.Pt,a)&&((e=t).Pt.X=a.X,e.Pt.Y=a.Y,n.use_xyz&&(e.Pt.Z=a.Z),t=this.DupOutPt(e,!s))}else{for(;e.Next.Pt.X>=a.X&&e.Next.Pt.X<=e.Pt.X&&e.Next.Pt.Y===a.Y;)e=e.Next;!s&&e.Pt.X!==a.X&&(e=e.Next),t=this.DupOutPt(e,s),n.IntPoint.op_Inequality(t.Pt,a)&&((e=t).Pt.X=a.X,e.Pt.Y=a.Y,n.use_xyz&&(e.Pt.Z=a.Z),t=this.DupOutPt(e,s))}if(l===n.Direction.dLeftToRight){for(;i.Next.Pt.X<=a.X&&i.Next.Pt.X>=i.Pt.X&&i.Next.Pt.Y===a.Y;)i=i.Next;s&&i.Pt.X!==a.X&&(i=i.Next),r=this.DupOutPt(i,!s),n.IntPoint.op_Inequality(r.Pt,a)&&((i=r).Pt.X=a.X,i.Pt.Y=a.Y,n.use_xyz&&(i.Pt.Z=a.Z),r=this.DupOutPt(i,!s))}else{for(;i.Next.Pt.X>=a.X&&i.Next.Pt.X<=i.Pt.X&&i.Next.Pt.Y===a.Y;)i=i.Next;!s&&i.Pt.X!==a.X&&(i=i.Next),r=this.DupOutPt(i,s),n.IntPoint.op_Inequality(r.Pt,a)&&((i=r).Pt.X=a.X,i.Pt.Y=a.Y,n.use_xyz&&(i.Pt.Z=a.Z),r=this.DupOutPt(i,s))}return o===n.Direction.dLeftToRight===s?(e.Prev=i,i.Next=e,t.Next=r,r.Prev=t):(e.Next=i,i.Prev=e,t.Prev=r,r.Next=t),!0},n.Clipper.prototype.JoinPoints=function(e,t,i){var r=e.OutPt1,a=new n.OutPt,s=e.OutPt2,o=new n.OutPt,l=e.OutPt1.Pt.Y===e.OffPt.Y;if(l&&n.IntPoint.op_Equality(e.OffPt,e.OutPt1.Pt)&&n.IntPoint.op_Equality(e.OffPt,e.OutPt2.Pt)){if(t!==i)return!1;for(a=e.OutPt1.Next;a!==r&&n.IntPoint.op_Equality(a.Pt,e.OffPt);)a=a.Next;var h=a.Pt.Y>e.OffPt.Y;for(o=e.OutPt2.Next;o!==s&&n.IntPoint.op_Equality(o.Pt,e.OffPt);)o=o.Next;return h!==o.Pt.Y>e.OffPt.Y&&(h?(a=this.DupOutPt(r,!1),o=this.DupOutPt(s,!0),r.Prev=s,s.Next=r,a.Next=o,o.Prev=a,e.OutPt1=r,e.OutPt2=a,!0):(a=this.DupOutPt(r,!0),o=this.DupOutPt(s,!1),r.Next=s,s.Prev=r,a.Prev=o,o.Next=a,e.OutPt1=r,e.OutPt2=a,!0))}if(l){for(a=r;r.Prev.Pt.Y===r.Pt.Y&&r.Prev!==a&&r.Prev!==s;)r=r.Prev;for(;a.Next.Pt.Y===a.Pt.Y&&a.Next!==r&&a.Next!==s;)a=a.Next;if(a.Next===r||a.Next===s)return!1;for(o=s;s.Prev.Pt.Y===s.Pt.Y&&s.Prev!==o&&s.Prev!==a;)s=s.Prev;for(;o.Next.Pt.Y===o.Pt.Y&&o.Next!==s&&o.Next!==r;)o=o.Next;if(o.Next===s||o.Next===r)return!1;var c={Left:null,Right:null};if(!this.GetOverlap(r.Pt.X,a.Pt.X,s.Pt.X,o.Pt.X,c))return!1;var u,d=c.Left,p=c.Right,f=new n.IntPoint0;return r.Pt.X>=d&&r.Pt.X<=p?(f.X=r.Pt.X,f.Y=r.Pt.Y,n.use_xyz&&(f.Z=r.Pt.Z),u=r.Pt.X>a.Pt.X):s.Pt.X>=d&&s.Pt.X<=p?(f.X=s.Pt.X,f.Y=s.Pt.Y,n.use_xyz&&(f.Z=s.Pt.Z),u=s.Pt.X>o.Pt.X):a.Pt.X>=d&&a.Pt.X<=p?(f.X=a.Pt.X,f.Y=a.Pt.Y,n.use_xyz&&(f.Z=a.Pt.Z),u=a.Pt.X>r.Pt.X):(f.X=o.Pt.X,f.Y=o.Pt.Y,n.use_xyz&&(f.Z=o.Pt.Z),u=o.Pt.X>s.Pt.X),e.OutPt1=r,e.OutPt2=s,this.JoinHorz(r,a,s,o,f,u)}for(a=r.Next;n.IntPoint.op_Equality(a.Pt,r.Pt)&&a!==r;)a=a.Next;var m=a.Pt.Y>r.Pt.Y||!n.ClipperBase.SlopesEqual4(r.Pt,a.Pt,e.OffPt,this.m_UseFullRange);if(m){for(a=r.Prev;n.IntPoint.op_Equality(a.Pt,r.Pt)&&a!==r;)a=a.Prev;if(a.Pt.Y>r.Pt.Y||!n.ClipperBase.SlopesEqual4(r.Pt,a.Pt,e.OffPt,this.m_UseFullRange))return!1}for(o=s.Next;n.IntPoint.op_Equality(o.Pt,s.Pt)&&o!==s;)o=o.Next;var g=o.Pt.Y>s.Pt.Y||!n.ClipperBase.SlopesEqual4(s.Pt,o.Pt,e.OffPt,this.m_UseFullRange);if(g){for(o=s.Prev;n.IntPoint.op_Equality(o.Pt,s.Pt)&&o!==s;)o=o.Prev;if(o.Pt.Y>s.Pt.Y||!n.ClipperBase.SlopesEqual4(s.Pt,o.Pt,e.OffPt,this.m_UseFullRange))return!1}return a!==r&&o!==s&&a!==o&&(t!==i||m!==g)&&(m?(a=this.DupOutPt(r,!1),o=this.DupOutPt(s,!0),r.Prev=s,s.Next=r,a.Next=o,o.Prev=a,e.OutPt1=r,e.OutPt2=a,!0):(a=this.DupOutPt(r,!0),o=this.DupOutPt(s,!1),r.Next=s,s.Prev=r,a.Prev=o,o.Next=a,e.OutPt1=r,e.OutPt2=a,!0))},n.Clipper.GetBounds=function(e){for(var t=0,i=e.length;tr.right&&(r.right=e[t][a].X),e[t][a].Yr.bottom&&(r.bottom=e[t][a].Y);return r},n.Clipper.prototype.GetBounds2=function(e){var t=e,i=new n.IntRect;for(i.left=e.Pt.X,i.right=e.Pt.X,i.top=e.Pt.Y,i.bottom=e.Pt.Y,e=e.Next;e!==t;)e.Pt.Xi.right&&(i.right=e.Pt.X),e.Pt.Yi.bottom&&(i.bottom=e.Pt.Y),e=e.Next;return i},n.Clipper.PointInPolygon=function(e,t){var n=0,i=t.length;if(i<3)return 0;for(var r=t[0],a=1;a<=i;++a){var s=a===i?t[0]:t[a];if(s.Y===e.Y&&(s.X===e.X||r.Y===e.Y&&s.X>e.X==r.X=e.X)if(s.X>e.X)n=1-n;else{if(0===(o=(r.X-e.X)*(s.Y-e.Y)-(s.X-e.X)*(r.Y-e.Y)))return-1;o>0==s.Y>r.Y&&(n=1-n)}else if(s.X>e.X){var o;if(0===(o=(r.X-e.X)*(s.Y-e.Y)-(s.X-e.X)*(r.Y-e.Y)))return-1;o>0==s.Y>r.Y&&(n=1-n)}r=s}return n},n.Clipper.prototype.PointInPolygon=function(e,t){var n=0,i=t,r=e.X,a=e.Y,s=t.Pt.X,o=t.Pt.Y;do{var l=(t=t.Next).Pt.X,h=t.Pt.Y;if(h===a&&(l===r||o===a&&l>r==s=r)if(l>r)n=1-n;else{if(0===(c=(s-r)*(h-a)-(l-r)*(o-a)))return-1;c>0==h>o&&(n=1-n)}else if(l>r){var c;if(0===(c=(s-r)*(h-a)-(l-r)*(o-a)))return-1;c>0==h>o&&(n=1-n)}s=l,o=h}while(i!==t);return n},n.Clipper.prototype.Poly2ContainsPoly1=function(e,t){var n=e;do{var i=this.PointInPolygon(n.Pt,t);if(i>=0)return i>0;n=n.Next}while(n!==e);return!0},n.Clipper.prototype.FixupFirstLefts1=function(e,t){for(var i,r,a=0,s=this.m_PolyOuts.length;a0&&this.ReversePolyPtLinks(a.Pts)):this.Poly2ContainsPoly1(r.Pts,a.Pts)?(a.IsHole=r.IsHole,r.IsHole=!a.IsHole,a.FirstLeft=r.FirstLeft,r.FirstLeft=a,this.m_UsingPolyTree&&this.FixupFirstLefts2(r,a),(r.IsHole^this.ReverseSolution)==this.Area$1(r)>0&&this.ReversePolyPtLinks(r.Pts)):(a.IsHole=r.IsHole,a.FirstLeft=r.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(r,a))):(a.Pts=null,a.BottomPt=null,a.Idx=r.Idx,r.IsHole=n.IsHole,n===a&&(r.FirstLeft=a.FirstLeft),a.FirstLeft=r,this.m_UsingPolyTree&&this.FixupFirstLefts3(a,r))))}},n.Clipper.prototype.UpdateOutPtIdxs=function(e){var t=e.Pts;do{t.Idx=e.Idx,t=t.Prev}while(t!==e.Pts)},n.Clipper.prototype.DoSimplePolygons=function(){for(var e=0;eMath.abs(e.Y-t.Y)?e.X>t.X==e.Xe.X==t.Xt.Y==e.Ye.Y==t.Y0&&r&&i.push(e.m_polygon);for(var a=0,s=e.Childs(),o=s.length,l=s[a];a0&&n.IntPoint.op_Equality(e[0],e[r]);)r--;a.m_polygon.push(e[0]);for(var s=0,o=0,l=1;l<=r;l++)n.IntPoint.op_Inequality(a.m_polygon[s],e[l])&&(s++,a.m_polygon.push(e[l]),(e[l].Y>a.m_polygon[o].Y||e[l].Y===a.m_polygon[o].Y&&e[l].Xh.Y||a.m_polygon[o].Y===h.Y&&a.m_polygon[o].X=0&&!n.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var e=0;e2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5,i=this.ArcTolerance<=0?n.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(e)*n.ClipperOffset.def_arc_tolerance?Math.abs(e)*n.ClipperOffset.def_arc_tolerance:this.ArcTolerance;var r=3.14159265358979/Math.acos(1-i/Math.abs(e));for(this.m_sin=Math.sin(n.ClipperOffset.two_pi/r),this.m_cos=Math.cos(n.ClipperOffset.two_pi/r),this.m_StepsPerRad=r/n.ClipperOffset.two_pi,e<0&&(this.m_sin=-this.m_sin),t=0;t0;h--)this.m_normals[h]=new n.DoublePoint2(-this.m_normals[h-1].X,-this.m_normals[h-1].Y);for(this.m_normals[0]=new n.DoublePoint2(-d.X,-d.Y),u=0,h=s-1;h>=0;h--)u=this.OffsetPoint(h,u,a.m_jointype);this.m_destPolys.push(this.m_destPoly)}else{for(u=0,h=1;h0;h--)this.m_normals[h]=new n.DoublePoint2(-this.m_normals[h-1].X,-this.m_normals[h-1].Y);for(this.m_normals[0]=new n.DoublePoint2(-this.m_normals[1].X,-this.m_normals[1].Y),h=(u=s-1)-1;h>0;--h)u=this.OffsetPoint(h,u,a.m_jointype);a.m_endtype===n.EndType.etOpenButt?(p=new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[0].X-this.m_normals[0].X*e),n.ClipperOffset.Round(this.m_srcPoly[0].Y-this.m_normals[0].Y*e)),this.m_destPoly.push(p),p=new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[0].X+this.m_normals[0].X*e),n.ClipperOffset.Round(this.m_srcPoly[0].Y+this.m_normals[0].Y*e)),this.m_destPoly.push(p)):(u=1,this.m_sinA=0,a.m_endtype===n.EndType.etOpenSquare?this.DoSquare(0,1):this.DoRound(0,1)),this.m_destPolys.push(this.m_destPoly)}}}}},n.ClipperOffset.prototype.Execute=function(){var e=arguments;if(e[0]instanceof n.PolyTree){var t=e[1];if((l=e[0]).Clear(),this.FixOrientations(),this.DoOffset(t),(s=new n.Clipper(0)).AddPaths(this.m_destPolys,n.PolyType.ptSubject,!0),t>0)s.Execute(n.ClipType.ctUnion,l,n.PolyFillType.pftPositive,n.PolyFillType.pftPositive);else{var i=n.Clipper.GetBounds(this.m_destPolys);if((o=new n.Path).push(new n.IntPoint2(i.left-10,i.bottom+10)),o.push(new n.IntPoint2(i.right+10,i.bottom+10)),o.push(new n.IntPoint2(i.right+10,i.top-10)),o.push(new n.IntPoint2(i.left-10,i.top-10)),s.AddPath(o,n.PolyType.ptSubject,!0),s.ReverseSolution=!0,s.Execute(n.ClipType.ctUnion,l,n.PolyFillType.pftNegative,n.PolyFillType.pftNegative),1===l.ChildCount()&&l.Childs()[0].ChildCount()>0){var r=l.Childs()[0];l.Childs()[0]=r.Childs()[0],l.Childs()[0].m_Parent=l;for(var a=1;a0)s.Execute(n.ClipType.ctUnion,l,n.PolyFillType.pftPositive,n.PolyFillType.pftPositive);else i=n.Clipper.GetBounds(this.m_destPolys),(o=new n.Path).push(new n.IntPoint2(i.left-10,i.bottom+10)),o.push(new n.IntPoint2(i.right+10,i.bottom+10)),o.push(new n.IntPoint2(i.right+10,i.top-10)),o.push(new n.IntPoint2(i.left-10,i.top-10)),s.AddPath(o,n.PolyType.ptSubject,!0),s.ReverseSolution=!0,s.Execute(n.ClipType.ctUnion,l,n.PolyFillType.pftNegative,n.PolyFillType.pftNegative),l.length>0&&l.splice(0,1)}},n.ClipperOffset.prototype.OffsetPoint=function(e,t,i){if(this.m_sinA=this.m_normals[t].X*this.m_normals[e].Y-this.m_normals[e].X*this.m_normals[t].Y,Math.abs(this.m_sinA*this.m_delta)<1){if(this.m_normals[t].X*this.m_normals[e].X+this.m_normals[e].Y*this.m_normals[t].Y>0)return this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[t].X*this.m_delta),n.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[t].Y*this.m_delta))),t}else this.m_sinA>1?this.m_sinA=1:this.m_sinA<-1&&(this.m_sinA=-1);if(this.m_sinA*this.m_delta<0)this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[t].X*this.m_delta),n.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[t].Y*this.m_delta))),this.m_destPoly.push(new n.IntPoint1(this.m_srcPoly[e])),this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[e].X*this.m_delta),n.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[e].Y*this.m_delta)));else switch(i){case n.JoinType.jtMiter:var r=this.m_normals[e].X*this.m_normals[t].X+this.m_normals[e].Y*this.m_normals[t].Y+1;r>=this.m_miterLim?this.DoMiter(e,t,r):this.DoSquare(e,t);break;case n.JoinType.jtSquare:this.DoSquare(e,t);break;case n.JoinType.jtRound:this.DoRound(e,t)}return e},n.ClipperOffset.prototype.DoSquare=function(e,t){var i=Math.tan(Math.atan2(this.m_sinA,this.m_normals[t].X*this.m_normals[e].X+this.m_normals[t].Y*this.m_normals[e].Y)/4);this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[t].X-this.m_normals[t].Y*i)),n.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[t].Y+this.m_normals[t].X*i)))),this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[e].X+this.m_normals[e].Y*i)),n.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[e].Y-this.m_normals[e].X*i))))},n.ClipperOffset.prototype.DoMiter=function(e,t,i){var r=this.m_delta/i;this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+(this.m_normals[t].X+this.m_normals[e].X)*r),n.ClipperOffset.Round(this.m_srcPoly[e].Y+(this.m_normals[t].Y+this.m_normals[e].Y)*r)))},n.ClipperOffset.prototype.DoRound=function(e,t){for(var i,r=Math.atan2(this.m_sinA,this.m_normals[t].X*this.m_normals[e].X+this.m_normals[t].Y*this.m_normals[e].Y),a=Math.max(n.Cast_Int32(n.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(r))),1),s=this.m_normals[t].X,o=this.m_normals[t].Y,l=0;l1?(y=u.X,x=u.Y):v>0&&(y+=m*v,x+=g*v)),(m=d.X-y)*m+(g=d.Y-x)*g<=_&&(p[a+1]=1,a++);for(l.push({X:s[0].X,Y:s[0].Y}),a=1;a2&&w.push(l)}return i||(w=w[0]),void 0===w&&(w=[]),w},n.JS.PerimeterOfPath=function(e,t,n){if(void 0===e)return 0;var i,r,a=Math.sqrt,s=0,o=0,l=0,h=0,c=0,u=e.length;if(u<2)return 0;for(t&&(e[u]=e[0],u++);--u;)o=(i=e[u]).X,l=i.Y,s+=a((o-(h=(r=e[u-1]).X))*(o-h)+(l-(c=r.Y))*(l-c));return t&&e.pop(),s/n},n.JS.PerimeterOfPaths=function(e,t,i){i||(i=1);for(var r=0,a=0;a{})),Bye=J((()=>{})),Uye=J((()=>{})),Hye=J((()=>{})),Vye=J((()=>{})),g1e=J(((exports,module)=>{var t,e;t=globalThis,e=()=>(()=>{"use strict";var __webpack_modules__=[,(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.VerbosityLevel=t.Util=t.UnknownErrorException=t.UnexpectedResponseException=t.TextRenderingMode=t.RenderingIntentFlag=t.PromiseCapability=t.PermissionFlag=t.PasswordResponses=t.PasswordException=t.PageActionEventType=t.OPS=t.MissingPDFException=t.MAX_IMAGE_SIZE_TO_CACHE=t.LINE_FACTOR=t.LINE_DESCENT_FACTOR=t.InvalidPDFException=t.ImageKind=t.IDENTITY_MATRIX=t.FormatError=t.FeatureTest=t.FONT_IDENTITY_MATRIX=t.DocumentActionEventType=t.CMapCompressionType=t.BaseException=t.BASELINE_FACTOR=t.AnnotationType=t.AnnotationReplyType=t.AnnotationMode=t.AnnotationFlag=t.AnnotationFieldFlag=t.AnnotationEditorType=t.AnnotationEditorPrefix=t.AnnotationEditorParamsType=t.AnnotationBorderStyleType=t.AnnotationActionEventType=t.AbortException=void 0,t.assert=function(e,t){e||s(t)},t.bytesToString=function(e){("object"!=typeof e||void 0===(null==e?void 0:e.length))&&s("Invalid argument for bytesToString");let t=e.length,n=8192;if(t=2&&(e=`http://${e}`)}if(n.tryConvertEncoding)try{e=d(e)}catch(e){}}let i=t?new URL(e,t):new URL(e);if(function(e){switch(null==e?void 0:e.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(i))return i}catch(e){}return null},t.getModificationDate=function(e=new Date){return[e.getUTCFullYear().toString(),(e.getUTCMonth()+1).toString().padStart(2,"0"),e.getUTCDate().toString().padStart(2,"0"),e.getUTCHours().toString().padStart(2,"0"),e.getUTCMinutes().toString().padStart(2,"0"),e.getUTCSeconds().toString().padStart(2,"0")].join("")},t.getVerbosityLevel=function(){return r},t.info=function(e){r>=i.INFOS&&console.log(`Info: ${e}`)},t.isArrayBuffer=function(e){return"object"==typeof e&&void 0!==(null==e?void 0:e.byteLength)},t.isArrayEqual=function(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;nt?t.normalize("NFKC"):f.get(n)))},t.objectFromMap=function(e){let t=Object.create(null);for(let[n,i]of e)t[n]=i;return t},t.objectSize=function(e){return Object.keys(e).length},t.setVerbosityLevel=function(e){Number.isInteger(e)&&(r=e)},t.shadow=o,t.string32=function(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)},t.stringToBytes=h,t.stringToPDFString=function(e){if(e[0]>="\xef"){let t;if("\xfe"===e[0]&&"\xff"===e[1]?t="utf-16be":"\xff"===e[0]&&"\xfe"===e[1]?t="utf-16le":"\xef"===e[0]&&"\xbb"===e[1]&&"\xbf"===e[2]&&(t="utf-8"),t)try{let n=new TextDecoder(t,{fatal:!0}),i=h(e);return n.decode(i)}catch(e){a(`stringToPDFString: "${e}".`)}}let t=[];for(let n=0,i=e.length;n=i.WARNINGS&&console.log(`Warning: ${e}`)}function s(e){throw new Error(e)}function o(e,t,n,i=!1){return Object.defineProperty(e,t,{value:n,enumerable:!i,configurable:!0,writable:!1}),n}let l=function(){function e(t,n){this.constructor===e&&s("Cannot initialize BaseException."),this.message=t,this.name=n}return e.prototype=new Error,e.constructor=e,e}();function h(e){"string"!=typeof e&&s("Invalid argument for stringToBytes");let t=e.length,n=new Uint8Array(t);for(let i=0;ie.toString(16).padStart(2,"0")));t.Util=class{static makeHexColor(e,t,n){return`#${c[e]}${c[t]}${c[n]}`}static scaleMinMax(e,t){let n;e[0]?(e[0]<0&&(n=t[0],t[0]=t[1],t[1]=n),t[0]*=e[0],t[1]*=e[0],e[3]<0&&(n=t[2],t[2]=t[3],t[3]=n),t[2]*=e[3],t[3]*=e[3]):(n=t[0],t[0]=t[2],t[2]=n,n=t[1],t[1]=t[3],t[3]=n,e[1]<0&&(n=t[2],t[2]=t[3],t[3]=n),t[2]*=e[1],t[3]*=e[1],e[2]<0&&(n=t[0],t[0]=t[1],t[1]=n),t[0]*=e[2],t[1]*=e[2]),t[0]+=e[4],t[1]+=e[4],t[2]+=e[5],t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){return[e[0]*t[0]+e[1]*t[2]+t[4],e[0]*t[1]+e[1]*t[3]+t[5]]}static applyInverseTransform(e,t){let n=t[0]*t[3]-t[1]*t[2];return[(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/n,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/n]}static getAxialAlignedBoundingBox(e,t){let n=this.applyTransform(e,t),i=this.applyTransform(e.slice(2,4),t),r=this.applyTransform([e[0],e[3]],t),a=this.applyTransform([e[2],e[1]],t);return[Math.min(n[0],i[0],r[0],a[0]),Math.min(n[1],i[1],r[1],a[1]),Math.max(n[0],i[0],r[0],a[0]),Math.max(n[1],i[1],r[1],a[1])]}static inverseTransform(e){let t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e){let t=[e[0],e[2],e[1],e[3]],n=e[0]*t[0]+e[1]*t[2],i=e[0]*t[1]+e[1]*t[3],r=e[2]*t[0]+e[3]*t[2],a=e[2]*t[1]+e[3]*t[3],s=(n+a)/2,o=Math.sqrt(Do(n+a,2)-4*(n*a-r*i))/2,l=s+o||1,h=s-o||1;return[Math.sqrt(l),Math.sqrt(h)]}static normalizeRect(e){let t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){let n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),i=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>i)return null;let r=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),a=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return r>a?null:[n,r,i,a]}static bezierBoundingBox(e,t,n,i,r,a,s,o){let l,h,c,u,d,p,f,m,g=[],v=[[],[]];for(let _=0;_<2;++_)if(0===_?(h=6*e-12*n+6*r,l=-3*e+9*n-9*r+3*s,c=3*n-3*e):(h=6*t-12*i+6*a,l=-3*t+9*i-9*a+3*o,c=3*i-3*t),Math.abs(l)<1e-12){if(Math.abs(h)<1e-12)continue;u=-c/h,0{this.resolve=t=>{St(this,n,!0),e(t)},this.reject=e=>{St(this,n,!0),t(e)}}))}get settled(){return ce(this,n)}};let p=null,f=null},(__unused_webpack_module,exports,__w_pdfjs_require__)=>{var i,e,n,r,$y,a,U2,l,c,u,h,d,f,p,g,_V,v,E,TV,_,R;Object.defineProperty(exports,"__esModule",{value:!0}),exports.build=exports.RenderTask=exports.PDFWorkerUtil=exports.PDFWorker=exports.PDFPageProxy=exports.PDFDocumentProxy=exports.PDFDocumentLoadingTask=exports.PDFDataRangeTransport=exports.LoopbackPort=exports.DefaultStandardFontDataFactory=exports.DefaultFilterFactory=exports.DefaultCanvasFactory=exports.DefaultCMapReaderFactory=void 0,exports.getDocument=getDocument,exports.version=void 0;var _util=__w_pdfjs_require__(1),_annotation_storage=__w_pdfjs_require__(3),_display_utils=__w_pdfjs_require__(6),_font_loader=__w_pdfjs_require__(9),_canvas=__w_pdfjs_require__(11),_worker_options=__w_pdfjs_require__(14),_is_node=__w_pdfjs_require__(10),_message_handler=__w_pdfjs_require__(15),_metadata=__w_pdfjs_require__(16),_optional_content_config=__w_pdfjs_require__(17),_transport_stream=__w_pdfjs_require__(18),_xfa_text=__w_pdfjs_require__(19);let DEFAULT_RANGE_CHUNK_SIZE=65536,RENDERING_CANCELLED_TIMEOUT=100,DELAYED_CLEANUP_TIMEOUT=5e3,DefaultCanvasFactory=_is_node.isNodeJS?__w_pdfjs_require__(20).NodeCanvasFactory:_display_utils.DOMCanvasFactory;exports.DefaultCanvasFactory=DefaultCanvasFactory;let DefaultCMapReaderFactory=_is_node.isNodeJS?__w_pdfjs_require__(20).NodeCMapReaderFactory:_display_utils.DOMCMapReaderFactory;exports.DefaultCMapReaderFactory=DefaultCMapReaderFactory;let DefaultFilterFactory=_is_node.isNodeJS?__w_pdfjs_require__(20).NodeFilterFactory:_display_utils.DOMFilterFactory;exports.DefaultFilterFactory=DefaultFilterFactory;let DefaultStandardFontDataFactory=_is_node.isNodeJS?__w_pdfjs_require__(20).NodeStandardFontDataFactory:_display_utils.DOMStandardFontDataFactory,createPDFNetworkStream;if(exports.DefaultStandardFontDataFactory=DefaultStandardFontDataFactory,_is_node.isNodeJS){let{PDFNodeStream:e}=__w_pdfjs_require__(21);createPDFNetworkStream=t=>new e(t)}else{let{PDFNetworkStream:e}=__w_pdfjs_require__(24),{PDFFetchStream:t}=__w_pdfjs_require__(25);createPDFNetworkStream=n=>(0,_display_utils.isValidFetchUrl)(n.url)?new t(n):new e(n)}function getDocument(e){var t,n;if("string"==typeof e||e instanceof URL?e={url:e}:(0,_util.isArrayBuffer)(e)&&(e={data:e}),"object"!=typeof e)throw new Error("Invalid parameter in getDocument, need parameter object.");if(!e.url&&!e.data&&!e.range)throw new Error("Invalid parameter object: need either .data, .range or .url");let i=new PDFDocumentLoadingTask,{docId:r}=i,a=e.url?getUrlProp(e.url):null,s=e.data?getDataProp(e.data):null,o=e.httpHeaders||null,l=!0===e.withCredentials,h=null!=(t=e.password)?t:null,c=e.range instanceof PDFDataRangeTransport?e.range:null,u=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:DEFAULT_RANGE_CHUNK_SIZE,d=e.worker instanceof PDFWorker?e.worker:null,p=e.verbosity,f="string"!=typeof e.docBaseUrl||(0,_display_utils.isDataScheme)(e.docBaseUrl)?null:e.docBaseUrl,m="string"==typeof e.cMapUrl?e.cMapUrl:null,g=!1!==e.cMapPacked,v=e.CMapReaderFactory||DefaultCMapReaderFactory,y="string"==typeof e.standardFontDataUrl?e.standardFontDataUrl:null,x=e.StandardFontDataFactory||DefaultStandardFontDataFactory,b=!0!==e.stopAtErrors,_=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,w=!1!==e.isEvalSupported,S="boolean"==typeof e.isOffscreenCanvasSupported?e.isOffscreenCanvasSupported:!_is_node.isNodeJS,M=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,E="boolean"==typeof e.disableFontFace?e.disableFontFace:_is_node.isNodeJS,T=!0===e.fontExtraProperties,A=!0===e.enableXfa,C=e.ownerDocument||globalThis.document,P=!0===e.disableRange,R=!0===e.disableStream,O=!0===e.disableAutoFetch,L=!0===e.pdfBug,I=c?c.length:null!=(n=e.length)?n:NaN,D="boolean"==typeof e.useSystemFonts?e.useSystemFonts:!_is_node.isNodeJS&&!E,k="boolean"==typeof e.useWorkerFetch?e.useWorkerFetch:v===_display_utils.DOMCMapReaderFactory&&x===_display_utils.DOMStandardFontDataFactory&&(0,_display_utils.isValidFetchUrl)(m,document.baseURI)&&(0,_display_utils.isValidFetchUrl)(y,document.baseURI),N=e.canvasFactory||new DefaultCanvasFactory({ownerDocument:C}),F=e.filterFactory||new DefaultFilterFactory({docId:r,ownerDocument:C});(0,_util.setVerbosityLevel)(p);let U={canvasFactory:N,filterFactory:F};if(k||(U.cMapReaderFactory=new v({baseUrl:m,isCompressed:g}),U.standardFontDataFactory=new x({baseUrl:y})),!d){let e={verbosity:p,port:_worker_options.GlobalWorkerOptions.workerPort};d=e.port?PDFWorker.fromPort(e):new PDFWorker(e),i._worker=d}let B={docId:r,apiVersion:"3.8.162",data:s,password:h,disableAutoFetch:O,rangeChunkSize:u,length:I,docBaseUrl:f,enableXfa:A,evaluatorOptions:{maxImageSize:_,disableFontFace:E,ignoreErrors:b,isEvalSupported:w,isOffscreenCanvasSupported:S,canvasMaxAreaInBytes:M,fontExtraProperties:T,useSystemFonts:D,cMapUrl:k?m:null,standardFontDataUrl:k?y:null}},z={ignoreErrors:b,isEvalSupported:w,disableFontFace:E,fontExtraProperties:T,enableXfa:A,ownerDocument:C,disableAutoFetch:O,pdfBug:L,styleElement:null};return d.promise.then((function(){if(i.destroyed)throw new Error("Loading aborted");let e=_fetchDocument(d,B),t=new Promise((function(e){let t;c?t=new _transport_stream.PDFDataTransportStream({length:I,initialData:c.initialData,progressiveDone:c.progressiveDone,contentDispositionFilename:c.contentDispositionFilename,disableRange:P,disableStream:R},c):s||(t=createPDFNetworkStream({url:a,length:I,httpHeaders:o,withCredentials:l,rangeChunkSize:u,disableRange:P,disableStream:R})),e(t)}));return Promise.all([e,t]).then((function([e,t]){if(i.destroyed)throw new Error("Loading aborted");let n=new _message_handler.MessageHandler(r,e,d.port),a=new WorkerTransport(n,i,t,z,U);i._transport=a,n.send("Ready",null)}))})).catch(i._capability.reject),i}function _fetchDocument(e,t){return ft(this,null,(function*(){if(e.destroyed)throw new Error("Worker was destroyed");let n=yield e.messageHandler.sendWithPromise("GetDocRequest",t,t.data?[t.data.buffer]:null);if(e.destroyed)throw new Error("Worker was destroyed");return n}))}function getUrlProp(e){if(e instanceof URL)return e.href;try{return new URL(e,window.location).href}catch(t){if(_is_node.isNodeJS&&"string"==typeof e)return e}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function getDataProp(e){if(_is_node.isNodeJS&&"undefined"!=typeof Buffer&&e instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if("string"==typeof e)return(0,_util.stringToBytes)(e);if("object"==typeof e&&!isNaN(null==e?void 0:e.length)||(0,_util.isArrayBuffer)(e))return new Uint8Array(e);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}let t=class{constructor(){this._capability=new _util.PromiseCapability,this._transport=null,this._worker=null,this.docId="d"+NT(t,i)._++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}destroy(){return ft(this,null,(function*(){var e;this.destroyed=!0,yield null==(e=this._transport)?void 0:e.destroy(),this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}))}},PDFDocumentLoadingTask=t;i=new WeakMap,Je(PDFDocumentLoadingTask,i,0),exports.PDFDocumentLoadingTask=PDFDocumentLoadingTask;class PDFDataRangeTransport{constructor(e,t,n=!1,i=null){this.length=e,this.initialData=t,this.progressiveDone=n,this.contentDispositionFilename=i,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=new _util.PromiseCapability}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(let n of this._rangeListeners)n(e,t)}onDataProgress(e,t){this._readyCapability.promise.then((()=>{for(let n of this._progressListeners)n(e,t)}))}onDataProgressiveRead(e){this._readyCapability.promise.then((()=>{for(let t of this._progressiveReadListeners)t(e)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(let e of this._progressiveDoneListeners)e()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){(0,_util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}exports.PDFDataRangeTransport=PDFDataRangeTransport;class PDFDocumentProxy{constructor(e,t){this._pdfInfo=e,this._transport=t}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return(0,_util.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJavaScript(){return this._transport.getJavaScript()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig(){return this._transport.getOptionalContentConfig()}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}exports.PDFDocumentProxy=PDFDocumentProxy;class PDFPageProxy{constructor(t,i,s,o=!1){Je(this,r),Je(this,a),Je(this,e,null),Je(this,n,!1),this._pageIndex=t,this._pageInfo=i,this._transport=s,this._stats=o?new _display_utils.StatTimer:null,this._pdfBug=o,this.commonObjs=s.commonObjs,this.objs=new PDFObjects,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:n=0,offsetY:i=0,dontFlip:r=!1}={}){return new _display_utils.PageViewport({viewBox:this.view,scale:e,rotation:t,offsetX:n,offsetY:i,dontFlip:r})}getAnnotations({intent:e="display"}={}){let t=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t.renderingIntent)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return(0,_util.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}getXfa(){return ft(this,null,(function*(){var e;return(null==(e=this._transport._htmlForXfa)?void 0:e.children[this._pageIndex])||null}))}render({canvasContext:e,viewport:t,intent:i="display",annotationMode:s=_util.AnnotationMode.ENABLE,transform:o=null,background:l=null,optionalContentConfigPromise:h=null,annotationCanvasMap:c=null,pageColors:u=null,printAnnotationStorage:d=null}){var p,f;null==(p=this._stats)||p.time("Overall");let m=this._transport.getRenderingIntent(i,s,d);St(this,n,!1),dt(this,a,U2).call(this),h||(h=this._transport.getOptionalContentConfig());let g=this._intentStates.get(m.cacheKey);g||(g=Object.create(null),this._intentStates.set(m.cacheKey,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);let v=!!(m.renderingIntent&_util.RenderingIntentFlag.PRINT);g.displayReadyCapability||(g.displayReadyCapability=new _util.PromiseCapability,g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(f=this._stats)||f.time("Page Request"),this._pumpOperatorList(m));let y=e=>{var t,i;g.renderTasks.delete(x),(this._maybeCleanupAfterRender||v)&&St(this,n,!0),dt(this,r,$y).call(this,!v),e?(x.capability.reject(e),this._abortOperatorList({intentState:g,reason:e instanceof Error?e:new Error(e)})):x.capability.resolve(),null==(t=this._stats)||t.timeEnd("Rendering"),null==(i=this._stats)||i.timeEnd("Overall")},x=new InternalRenderTask({callback:y,params:{canvasContext:e,viewport:t,transform:o,background:l},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:u});(g.renderTasks||(g.renderTasks=new Set)).add(x);let b=x.task;return Promise.all([g.displayReadyCapability.promise,h]).then((([e,t])=>{var n;this.destroyed?y():(null==(n=this._stats)||n.time("Rendering"),x.initializeGraphics({transparency:e,optionalContentConfig:t}),x.operatorListChanged())})).catch(y),b}getOperatorList({intent:e="display",annotationMode:t=_util.AnnotationMode.ENABLE,printAnnotationStorage:n=null}={}){var i;let r,a=this._transport.getRenderingIntent(e,t,n,!0),s=this._intentStates.get(a.cacheKey);return s||(s=Object.create(null),this._intentStates.set(a.cacheKey,s)),s.opListReadCapability||(r=Object.create(null),r.operatorListChanged=function(){s.operatorList.lastChunk&&(s.opListReadCapability.resolve(s.operatorList),s.renderTasks.delete(r))},s.opListReadCapability=new _util.PromiseCapability,(s.renderTasks||(s.renderTasks=new Set)).add(r),s.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(i=this._stats)||i.time("Page Request"),this._pumpOperatorList(a)),s.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===e,disableNormalization:!0===t},{highWaterMark:100,size:e=>e.items.length})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then((e=>_xfa_text.XfaText.textContent(e)));let t=this.streamTextContent(e);return new Promise((function(e,n){let i=t.getReader(),r={items:[],styles:Object.create(null)};!function t(){i.read().then((function({value:n,done:i}){i?e(r):(Object.assign(r.styles,n.styles),r.items.push(...n.items),t())}),n)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let e=[];for(let t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0}),!t.opListReadCapability)for(let n of t.renderTasks)e.push(n.completed),n.cancel();return this.objs.clear(),St(this,n,!1),dt(this,a,U2).call(this),Promise.all(e)}cleanup(e=!1){St(this,n,!0);let t=dt(this,r,$y).call(this,!1);return e&&t&&this._stats&&(this._stats=new _display_utils.StatTimer),t}_startRenderPage(e,t){var n,i;let r=this._intentStates.get(t);r&&(null==(n=this._stats)||n.timeEnd("Page Request"),null==(i=r.displayReadyCapability)||i.resolve(e))}_renderPageChunk(e,t){for(let n=0,i=e.length;n{s.read().then((({value:e,done:t})=>{t?o.streamReader=null:this._transport.destroyed||(this._renderPageChunk(e,o),l())}),(e=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(let e of o.renderTasks)e.operatorListChanged();dt(this,r,$y).call(this,!0)}if(o.displayReadyCapability)o.displayReadyCapability.reject(e);else{if(!o.opListReadCapability)throw e;o.opListReadCapability.reject(e)}}}))};l()}_abortOperatorList({intentState:e,reason:t,force:n=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!n){if(e.renderTasks.size>0)return;if(t instanceof _display_utils.RenderingCancelledException){let n=RENDERING_CANCELLED_TIMEOUT;return t.extraDelay>0&&t.extraDelay<1e3&&(n+=t.extraDelay),void(e.streamReaderCancelTimeout=setTimeout((()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})}),n))}}if(e.streamReader.cancel(new _util.AbortException(t.message)).catch((()=>{})),e.streamReader=null,!this._transport.destroyed){for(let[t,n]of this._intentStates)if(n===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}}e=new WeakMap,n=new WeakMap,r=new WeakSet,$y=function(t=!1){if(dt(this,a,U2).call(this),!ce(this,n)||this.destroyed)return!1;if(t)return St(this,e,setTimeout((()=>{St(this,e,null),dt(this,r,$y).call(this,!1)}),DELAYED_CLEANUP_TIMEOUT)),!1;for(let{renderTasks:e,operatorList:n}of this._intentStates.values())if(e.size>0||!n.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),St(this,n,!1),!0},a=new WeakSet,U2=function(){ce(this,e)&&(clearTimeout(ce(this,e)),St(this,e,null))},exports.PDFPageProxy=PDFPageProxy;class LoopbackPort{constructor(){Je(this,l,new Set),Je(this,c,Promise.resolve())}postMessage(e,t){let n={data:structuredClone(e,t?{transfer:t}:null)};ce(this,c).then((()=>{for(let e of ce(this,l))e.call(this,n)}))}addEventListener(e,t){ce(this,l).add(t)}removeEventListener(e,t){ce(this,l).delete(t)}terminate(){ce(this,l).clear()}}l=new WeakMap,c=new WeakMap,exports.LoopbackPort=LoopbackPort;let PDFWorkerUtil={isWorkerDisabled:!1,fallbackWorkerSrc:null,fakeWorkerId:0};if(exports.PDFWorkerUtil=PDFWorkerUtil,_is_node.isNodeJS&&"function"==typeof a3)PDFWorkerUtil.isWorkerDisabled=!0,PDFWorkerUtil.fallbackWorkerSrc="./pdf.worker.js";else if("object"==typeof document){let e=null==(u=null==document?void 0:document.currentScript)?void 0:u.src;e&&(PDFWorkerUtil.fallbackWorkerSrc=e.replace(/(\.(?:min\.)?js)(\?.*)?$/i,".worker$1$2"))}PDFWorkerUtil.isSameOrigin=function(e,t){let n;try{if(n=new URL(e),!n.origin||"null"===n.origin)return!1}catch(e){return!1}let i=new URL(t,n);return n.origin===i.origin},PDFWorkerUtil.createCDNWrapper=function(e){let t=`importScripts("${e}");`;return URL.createObjectURL(new Blob([t]))};let _PDFWorker=class{constructor({name:e=null,port:t=null,verbosity:n=(0,_util.getVerbosityLevel)()}={}){if(t&&ce(_PDFWorker,h).has(t))throw new Error("Cannot use more than one PDFWorker per port.");if(this.name=e,this.destroyed=!1,this.verbosity=n,this._readyCapability=new _util.PromiseCapability,this._port=null,this._webWorker=null,this._messageHandler=null,t)return ce(_PDFWorker,h).set(t,this),void this._initializeFromPort(t);this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e,this._messageHandler=new _message_handler.MessageHandler("main","worker",e),this._messageHandler.on("ready",(function(){})),this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}_initialize(){if(!PDFWorkerUtil.isWorkerDisabled&&!_PDFWorker._mainThreadWorkerMessageHandler){let{workerSrc:t}=_PDFWorker;try{PDFWorkerUtil.isSameOrigin(window.location.href,t)||(t=PDFWorkerUtil.createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t),n=new _message_handler.MessageHandler("main","worker",e),i=()=>{e.removeEventListener("error",r),n.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},r=()=>{this._webWorker||i()};e.addEventListener("error",r),n.on("test",(t=>{e.removeEventListener("error",r),this.destroyed?i():t?(this._messageHandler=n,this._port=e,this._webWorker=e,this._readyCapability.resolve(),n.send("configure",{verbosity:this.verbosity})):(this._setupFakeWorker(),n.destroy(),e.terminate())})),n.on("ready",(t=>{if(e.removeEventListener("error",r),this.destroyed)i();else try{a()}catch(t){this._setupFakeWorker()}}));let a=()=>{let e=new Uint8Array;n.send("test",e,[e.buffer])};return void a()}catch(e){(0,_util.info)("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){PDFWorkerUtil.isWorkerDisabled||((0,_util.warn)("Setting up fake worker."),PDFWorkerUtil.isWorkerDisabled=!0),_PDFWorker._setupFakeWorkerGlobal.then((e=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));let t=new LoopbackPort;this._port=t;let n="fake"+PDFWorkerUtil.fakeWorkerId++,i=new _message_handler.MessageHandler(n+"_worker",n,t);e.setup(i,t);let r=new _message_handler.MessageHandler(n,n+"_worker",t);this._messageHandler=r,this._readyCapability.resolve(),r.send("configure",{verbosity:this.verbosity})})).catch((e=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${e.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),ce(_PDFWorker,h).delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(e){if(null==e||!e.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return ce(this,h).has(e.port)?ce(this,h).get(e.port):new _PDFWorker(e)}static get workerSrc(){if(_worker_options.GlobalWorkerOptions.workerSrc)return _worker_options.GlobalWorkerOptions.workerSrc;if(null!==PDFWorkerUtil.fallbackWorkerSrc)return _is_node.isNodeJS||(0,_display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.'),PDFWorkerUtil.fallbackWorkerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _mainThreadWorkerMessageHandler(){var e;try{return(null==(e=globalThis.pdfjsWorker)?void 0:e.WorkerMessageHandler)||null}catch(e){return null}}static get _setupFakeWorkerGlobal(){let loader=()=>ft(this,null,(function*(){let mainWorkerMessageHandler=this._mainThreadWorkerMessageHandler;if(mainWorkerMessageHandler)return mainWorkerMessageHandler;if(_is_node.isNodeJS&&"function"==typeof a3){let worker=eval("require")(this.workerSrc);return worker.WorkerMessageHandler}return yield(0,_display_utils.loadScript)(this.workerSrc),window.pdfjsWorker.WorkerMessageHandler}));return(0,_util.shadow)(this,"_setupFakeWorkerGlobal",loader())}},PDFWorker=_PDFWorker;h=new WeakMap,Je(PDFWorker,h,new WeakMap),exports.PDFWorker=PDFWorker;class WorkerTransport{constructor(e,t,n,i,r){Je(this,g),Je(this,d,new Map),Je(this,f,new Map),Je(this,p,new Map),this.messageHandler=e,this.loadingTask=t,this.commonObjs=new PDFObjects,this.fontLoader=new _font_loader.FontLoader({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._passwordCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=new _util.PromiseCapability,this.setupMessageHandler()}get annotationStorage(){return(0,_util.shadow)(this,"annotationStorage",new _annotation_storage.AnnotationStorage)}getRenderingIntent(e,t=_util.AnnotationMode.ENABLE,n=null,i=!1){let r=_util.RenderingIntentFlag.DISPLAY,a=_annotation_storage.SerializableEmpty;switch(e){case"any":r=_util.RenderingIntentFlag.ANY;break;case"display":break;case"print":r=_util.RenderingIntentFlag.PRINT;break;default:(0,_util.warn)(`getRenderingIntent - invalid intent: ${e}`)}switch(t){case _util.AnnotationMode.DISABLE:r+=_util.RenderingIntentFlag.ANNOTATIONS_DISABLE;break;case _util.AnnotationMode.ENABLE:break;case _util.AnnotationMode.ENABLE_FORMS:r+=_util.RenderingIntentFlag.ANNOTATIONS_FORMS;break;case _util.AnnotationMode.ENABLE_STORAGE:r+=_util.RenderingIntentFlag.ANNOTATIONS_STORAGE,a=(r&_util.RenderingIntentFlag.PRINT&&n instanceof _annotation_storage.PrintAnnotationStorage?n:this.annotationStorage).serializable;break;default:(0,_util.warn)(`getRenderingIntent - invalid annotationMode: ${t}`)}return i&&(r+=_util.RenderingIntentFlag.OPLIST),{renderingIntent:r,cacheKey:`${r}_${a.hash}`,annotationStorageSerializable:a}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=new _util.PromiseCapability,this._passwordCapability&&this._passwordCapability.reject(new Error("Worker was destroyed during onPassword callback"));let e=[];for(let n of ce(this,f).values())e.push(n._destroy());ce(this,f).clear(),ce(this,p).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let t=this.messageHandler.sendWithPromise("Terminate",null);return e.push(t),Promise.all(e).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),ce(this,d).clear(),this.filterFactory.destroy(),this._networkStream&&this._networkStream.cancelAllRequests(new _util.AbortException("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:e,loadingTask:t}=this;e.on("GetReader",((e,t)=>{(0,_util.assert)(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=e=>{this._lastProgress={loaded:e.loaded,total:e.total}},t.onPull=()=>{this._fullReader.read().then((function({value:e,done:n}){n?t.close():((0,_util.assert)(e instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),t.enqueue(new Uint8Array(e),1,[e]))})).catch((e=>{t.error(e)}))},t.onCancel=e=>{this._fullReader.cancel(e),t.ready.catch((e=>{if(!this.destroyed)throw e}))}})),e.on("ReaderHeadersReady",(e=>{let n=new _util.PromiseCapability,i=this._fullReader;return i.headersReady.then((()=>{var e;(!i.isStreamingSupported||!i.isRangeSupported)&&(this._lastProgress&&(null==(e=t.onProgress)||e.call(t,this._lastProgress)),i.onProgress=e=>{var n;null==(n=t.onProgress)||n.call(t,{loaded:e.loaded,total:e.total})}),n.resolve({isStreamingSupported:i.isStreamingSupported,isRangeSupported:i.isRangeSupported,contentLength:i.contentLength})}),n.reject),n.promise})),e.on("GetRangeReader",((e,t)=>{(0,_util.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let n=this._networkStream.getRangeReader(e.begin,e.end);n?(t.onPull=()=>{n.read().then((function({value:e,done:n}){n?t.close():((0,_util.assert)(e instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),t.enqueue(new Uint8Array(e),1,[e]))})).catch((e=>{t.error(e)}))},t.onCancel=e=>{n.cancel(e),t.ready.catch((e=>{if(!this.destroyed)throw e}))}):t.close()})),e.on("GetDoc",(({pdfInfo:e})=>{this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,t._capability.resolve(new PDFDocumentProxy(e,this))})),e.on("DocException",(function(e){let n;switch(e.name){case"PasswordException":n=new _util.PasswordException(e.message,e.code);break;case"InvalidPDFException":n=new _util.InvalidPDFException(e.message);break;case"MissingPDFException":n=new _util.MissingPDFException(e.message);break;case"UnexpectedResponseException":n=new _util.UnexpectedResponseException(e.message,e.status);break;case"UnknownErrorException":n=new _util.UnknownErrorException(e.message,e.details);break;default:(0,_util.unreachable)("DocException - expected a valid Error.")}t._capability.reject(n)})),e.on("PasswordRequest",(e=>{if(this._passwordCapability=new _util.PromiseCapability,t.onPassword){let n=e=>{e instanceof Error?this._passwordCapability.reject(e):this._passwordCapability.resolve({password:e})};try{t.onPassword(n,e.code)}catch(e){this._passwordCapability.reject(e)}}else this._passwordCapability.reject(new _util.PasswordException(e.message,e.code));return this._passwordCapability.promise})),e.on("DataLoaded",(e=>{var n;null==(n=t.onProgress)||n.call(t,{loaded:e.length,total:e.length}),this.downloadInfoCapability.resolve(e)})),e.on("StartRenderPage",(e=>{this.destroyed||ce(this,f).get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)})),e.on("commonobj",(([t,n,i])=>{var r;if(!this.destroyed&&!this.commonObjs.has(t))switch(n){case"Font":let a=this._params;if("error"in i){let e=i.error;(0,_util.warn)(`Error during font loading: ${e}`),this.commonObjs.resolve(t,e);break}let s=a.pdfBug&&null!=(r=globalThis.FontInspector)&&r.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null,o=new _font_loader.FontFaceObject(i,{isEvalSupported:a.isEvalSupported,disableFontFace:a.disableFontFace,ignoreErrors:a.ignoreErrors,inspectFont:s});this.fontLoader.bind(o).catch((n=>e.sendWithPromise("FontFallback",{id:t}))).finally((()=>{!a.fontExtraProperties&&o.data&&(o.data=null),this.commonObjs.resolve(t,o)}));break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(t,i);break;default:throw new Error(`Got unknown common object type ${n}`)}})),e.on("obj",(([e,t,n,i])=>{var r;if(this.destroyed)return;let a=ce(this,f).get(t);if(!a.objs.has(e))switch(n){case"Image":if(a.objs.resolve(e,i),i){let e;if(i.bitmap){let{width:t,height:n}=i;e=t*n*4}else e=(null==(r=i.data)?void 0:r.length)||0;e>_util.MAX_IMAGE_SIZE_TO_CACHE&&(a._maybeCleanupAfterRender=!0)}break;case"Pattern":a.objs.resolve(e,i);break;default:throw new Error(`Got unknown object type ${n}`)}})),e.on("DocProgress",(e=>{var n;this.destroyed||null==(n=t.onProgress)||n.call(t,{loaded:e.loaded,total:e.total})})),e.on("FetchBuiltInCMap",(e=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(e):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.")))),e.on("FetchStandardFontData",(e=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(e):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."))))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var e,t;this.annotationStorage.size<=0&&(0,_util.warn)("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:n,transfers:i}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:n,filename:null!=(t=null==(e=this._fullReader)?void 0:e.filename)?t:null},i).finally((()=>{this.annotationStorage.resetModified()}))}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request."));let t=e-1,n=ce(this,p).get(t);if(n)return n;let i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then((e=>{if(this.destroyed)throw new Error("Transport destroyed");let n=new PDFPageProxy(t,e,this,this._params.pdfBug);return ce(this,f).set(t,n),n}));return ce(this,p).set(t,i),i}getPageIndex(e){return"object"!=typeof e||null===e||!Number.isInteger(e.num)||e.num<0||!Number.isInteger(e.gen)||e.gen<0?Promise.reject(new Error("Invalid pageIndex request.")):this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen})}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:t})}getFieldObjects(){return dt(this,g,_V).call(this,"GetFieldObjects")}hasJSActions(){return dt(this,g,_V).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return"string"!=typeof e?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getJavaScript(){return this.messageHandler.sendWithPromise("GetJavaScript",null)}getDocJSActions(){return this.messageHandler.sendWithPromise("GetDocJSActions",null)}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(){return this.messageHandler.sendWithPromise("GetOptionalContentConfig",null).then((e=>new _optional_content_config.OptionalContentConfig(e)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let e="GetMetadata",t=ce(this,d).get(e);if(t)return t;let n=this.messageHandler.sendWithPromise(e,null).then((e=>{var t,n,i,r;return{info:e[0],metadata:e[1]?new _metadata.Metadata(e[1]):null,contentDispositionFilename:null!=(n=null==(t=this._fullReader)?void 0:t.filename)?n:null,contentLength:null!=(r=null==(i=this._fullReader)?void 0:i.contentLength)?r:null}}));return ce(this,d).set(e,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}startCleanup(e=!1){return ft(this,null,(function*(){if(!this.destroyed){yield this.messageHandler.sendWithPromise("Cleanup",null);for(let e of ce(this,f).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),ce(this,d).clear(),this.filterFactory.destroy(!0)}}))}get loadingParams(){let{disableAutoFetch:e,enableXfa:t}=this._params;return(0,_util.shadow)(this,"loadingParams",{disableAutoFetch:e,enableXfa:t})}}d=new WeakMap,f=new WeakMap,p=new WeakMap,g=new WeakSet,_V=function(e,t=null){let n=ce(this,d).get(e);if(n)return n;let i=this.messageHandler.sendWithPromise(e,t);return ce(this,d).set(e,i),i};class PDFObjects{constructor(){Je(this,E),Je(this,v,Object.create(null))}get(e,t=null){if(t){let n=dt(this,E,TV).call(this,e);return n.capability.promise.then((()=>t(n.data))),null}let n=ce(this,v)[e];if(null==n||!n.capability.settled)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return n.data}has(e){let t=ce(this,v)[e];return(null==t?void 0:t.capability.settled)||!1}resolve(e,t=null){let n=dt(this,E,TV).call(this,e);n.data=t,n.capability.resolve()}clear(){var e;for(let t in ce(this,v)){let{data:n}=ce(this,v)[t];null==(e=null==n?void 0:n.bitmap)||e.close()}St(this,v,Object.create(null))}}v=new WeakMap,E=new WeakSet,TV=function(e){return ce(this,v)[e]||(ce(this,v)[e]={capability:new _util.PromiseCapability,data:null})};class RenderTask{constructor(e){Je(this,_,null),St(this,_,e),this.onContinue=null}get promise(){return ce(this,_).capability.promise}cancel(e=0){ce(this,_).cancel(null,e)}get separateAnnots(){let{separateAnnots:e}=ce(this,_).operatorList;if(!e)return!1;let{annotationCanvasMap:t}=ce(this,_);return e.form||e.canvas&&(null==t?void 0:t.size)>0}}_=new WeakMap,exports.RenderTask=RenderTask;let M=class{constructor({callback:e,params:t,objs:n,commonObjs:i,annotationCanvasMap:r,operatorList:a,pageIndex:s,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:c=!1,pageColors:u=null}){this.callback=e,this.params=t,this.objs=n,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=s,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=c,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"undefined"!=typeof window,this.cancelled=!1,this.capability=new _util.PromiseCapability,this.task=new RenderTask(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=t.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){var n,i;if(this.cancelled)return;if(this._canvas){if(ce(M,R).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");ce(M,R).add(this._canvas)}this._pdfBug&&null!=(n=globalThis.StepperManager)&&n.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{canvasContext:r,viewport:a,transform:s,background:o}=this.params;this.gfx=new _canvas.CanvasGraphics(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:s,viewport:a,transparency:e,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,null==(i=this.graphicsReadyCallback)||i.call(this)}cancel(e=null,t=0){var n;this.running=!1,this.cancelled=!0,null==(n=this.gfx)||n.endDrawing(),this._canvas&&ce(M,R).delete(this._canvas),this.callback(e||new _display_utils.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,t))}operatorListChanged(){var e;this.graphicsReady?(null==(e=this.stepper)||e.updateOperatorList(this.operatorList),!this.running&&this._continue()):this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound)}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?window.requestAnimationFrame((()=>{this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}_next(){return ft(this,null,(function*(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(this.pageColors),this._canvas&&ce(M,R).delete(this._canvas),this.callback())))}))}},InternalRenderTask=M;R=new WeakMap,Je(InternalRenderTask,R,new WeakSet);let version="3.8.162";exports.version=version;let build="2c74323e3";exports.build=build},(e,t,n)=>{var i,r,a,s,o;Object.defineProperty(t,"__esModule",{value:!0}),t.SerializableEmpty=t.PrintAnnotationStorage=t.AnnotationStorage=void 0;var l=n(1),h=n(4),c=n(8);let u=Object.freeze({map:null,hash:"",transfers:void 0});t.SerializableEmpty=u;class d{constructor(){Je(this,a),Je(this,i,!1),Je(this,r,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){let n=ce(this,r).get(e);return void 0===n?t:Object.assign(t,n)}getRawValue(e){return ce(this,r).get(e)}remove(e){if(ce(this,r).delete(e),0===ce(this,r).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(let e of ce(this,r).values())if(e instanceof h.AnnotationEditor)return;this.onAnnotationEditor(null)}}setValue(e,t){let n=ce(this,r).get(e),i=!1;if(void 0!==n)for(let[r,a]of Object.entries(t))n[r]!==a&&(i=!0,n[r]=a);else i=!0,ce(this,r).set(e,t);i&&dt(this,a,s).call(this),t instanceof h.AnnotationEditor&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(t.constructor._type)}has(e){return ce(this,r).has(e)}getAll(){return ce(this,r).size>0?(0,l.objectFromMap)(ce(this,r)):null}setAll(e){for(let[t,n]of Object.entries(e))this.setValue(t,n)}get size(){return ce(this,r).size}resetModified(){ce(this,i)&&(St(this,i,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new p(this)}get serializable(){if(0===ce(this,r).size)return u;let e=new Map,t=new c.MurmurHash3_64,n=[];for(let[i,a]of ce(this,r)){let r=a instanceof h.AnnotationEditor?a.serialize():a;r&&(e.set(i,r),t.update(`${i}:${JSON.stringify(r)}`),r.bitmap&&n.push(r.bitmap))}return e.size>0?{map:e,hash:t.hexdigest(),transfers:n}:u}}i=new WeakMap,r=new WeakMap,a=new WeakSet,s=function(){ce(this,i)||(St(this,i,!0),"function"==typeof this.onSetModified&&this.onSetModified())},t.AnnotationStorage=d;class p extends d{constructor(e){super(),Je(this,o,void 0);let{map:t,hash:n,transfers:i}=e.serializable,r=structuredClone(t,i?{transfer:i}:null);St(this,o,{map:r,hash:n,transfers:i})}get print(){(0,l.unreachable)("Should not call PrintAnnotationStorage.print")}get serializable(){return ce(this,o)}}o=new WeakMap,t.PrintAnnotationStorage=p},(e,t,n)=>{var i,r,a,s,o,l;Object.defineProperty(t,"__esModule",{value:!0}),t.AnnotationEditor=void 0;var h=n(5),c=n(1);let u=class{constructor(e){Je(this,i,this.focusin.bind(this)),Je(this,r,this.focusout.bind(this)),Je(this,a,!1),Je(this,s,!1),Je(this,o,!1),Xi(this,"_uiManager",null),Je(this,l,u._zIndex++),this.constructor===u&&(0,c.unreachable)("Cannot initialize AnnotationEditor."),this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null;let{rotation:t,rawDims:{pageWidth:n,pageHeight:h,pageX:d,pageY:p}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,h],this.pageTranslation=[d,p];let[f,m]=this.parentDimensions;this.x=e.x/f,this.y=e.y/m,this.isAttachedToDOM=!1,this.deleted=!1}static get _defaultLineColor(){return(0,c.shadow)(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){let t=new p({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=ce(this,l)}setParent(e){null!==e&&(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions),this.parent=e}focusin(e){ce(this,a)?St(this,a,!1):this.parent.setSelected(this)}focusout(e){var t;if(!this.isAttachedToDOM)return;let n=e.relatedTarget;null!=n&&n.closest(`#${this.id}`)||(e.preventDefault(),null!=(t=this.parent)&&t.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}dragstart(e){let t=this.parent.div.getBoundingClientRect();this.startX=e.clientX-t.x,this.startY=e.clientY-t.y,e.dataTransfer.setData("text/plain",this.id),e.dataTransfer.effectAllowed="move"}setAt(e,t,n,i){let[r,a]=this.parentDimensions;[n,i]=this.screenToPageTranslation(n,i),this.x=(e+n)/r,this.y=(t+i)/a,this.div.style.left=100*this.x+"%",this.div.style.top=100*this.y+"%"}translate(e,t){let[n,i]=this.parentDimensions;[e,t]=this.screenToPageTranslation(e,t),this.x+=e/n,this.y+=t/i,this.div.style.left=100*this.x+"%",this.div.style.top=100*this.y+"%"}screenToPageTranslation(e,t){switch(this.parentRotation){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{realScale:e}=this._uiManager.viewParameters,[t,n]=this.pageDimensions;return[t*e,n*e]}setDims(e,t){let[n,i]=this.parentDimensions;this.div.style.width=100*e/n+"%",this.div.style.height=100*t/i+"%"}fixDims(){let{style:e}=this.div,{height:t,width:n}=e,i=n.endsWith("%"),r=t.endsWith("%");if(i&&r)return;let[a,s]=this.parentDimensions;i||(e.width=100*parseFloat(n)/a+"%"),r||(e.height=100*parseFloat(t)/s+"%")}getInitialTranslation(){return[0,0]}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.setAttribute("tabIndex",0),this.setInForeground(),this.div.addEventListener("focusin",ce(this,i)),this.div.addEventListener("focusout",ce(this,r));let[e,t]=this.getInitialTranslation();return this.translate(e,t),(0,h.bindEvents)(this,this.div,["dragstart","pointerdown"]),this.div}pointerdown(e){let{isMac:t}=c.FeatureTest.platform;0!==e.button||e.ctrlKey&&t?e.preventDefault():(e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this),St(this,a,!0))}getRect(e,t){let n=this.parentScale,[i,r]=this.pageDimensions,[a,s]=this.pageTranslation,o=e/n,l=t/n,h=this.x*i,c=this.y*r,u=this.width*i,d=this.height*r;switch(this.rotation){case 0:return[h+o+a,r-c-l-d+s,h+o+u+a,r-c-l+s];case 90:return[h+l+a,r-c+o+s,h+l+d+a,r-c+o+u+s];case 180:return[h-o-u+a,r-c+l+s,h-o+a,r-c+l+d+s];case 270:return[h-l-d+a,r-c-o-u+s,h-l+a,r-c-o+s];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,t){let[n,i,r,a]=e,s=r-n,o=a-i;switch(this.rotation){case 0:return[n,t-a,s,o];case 90:return[n,t-i,o,s];case 180:return[r,t-i,s,o];case 270:return[r,t-a,o,s];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){St(this,o,!0)}disableEditMode(){St(this,o,!1)}isInEditMode(){return ce(this,o)}shouldGetKeyboardEvents(){return!1}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var e,t;null==(e=this.div)||e.addEventListener("focusin",ce(this,i)),null==(t=this.div)||t.addEventListener("focusout",ce(this,r))}serialize(e=!1){(0,c.unreachable)("An editor must be serializable")}static deserialize(e,t,n){let i=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:n});i.rotation=e.rotation;let[r,a]=i.pageDimensions,[s,o,l,h]=i.getRectInCurrentCoords(e.rect,a);return i.x=s/r,i.y=o/a,i.width=l/r,i.height=h/a,i}remove(){this.div.removeEventListener("focusin",ce(this,i)),this.div.removeEventListener("focusout",ce(this,r)),this.isEmpty()||this.commit(),this.parent.remove(this)}select(){var e;null==(e=this.div)||e.classList.add("selectedEditor")}unselect(){var e;null==(e=this.div)||e.classList.remove("selectedEditor")}updateParams(e,t){}disableEditing(){}enableEditing(){}get propertiesToUpdate(){return{}}get contentDiv(){return this.div}get isEditing(){return ce(this,s)}set isEditing(e){St(this,s,e),e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null)}},d=u;i=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap,Xi(d,"_colorManager",new h.ColorManager),Xi(d,"_zIndex",1),t.AnnotationEditor=d;class p extends d{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}},(e,t,n)=>{var i,r,a,s,o,l,h,c,u,d,p,f,m,g,v,y,x,b,_,w,S,M,E,T,A,C,P,R,O,L,I,D,k,N,F,U,B,z,H,V,j,G,W,X,Y,q,J,Z,K,$,Q,ee,te;Object.defineProperty(t,"__esModule",{value:!0}),t.KeyboardManager=t.CommandManager=t.ColorManager=t.AnnotationEditorUIManager=void 0,t.bindEvents=function(e,t,n){for(let i of n)t.addEventListener(i,e[i].bind(e))},t.opacityToHex=function(e){return Math.round(Math.min(255,Math.max(1,255*e))).toString(16).padStart(2,"0")};var ne=n(1),ie=n(6);class re{constructor(){Je(this,i,0)}getId(){return`${ne.AnnotationEditorPrefix}${NT(this,i)._++}`}}i=new WeakMap;class ae{constructor(e=128){Je(this,r,[]),Je(this,a,!1),Je(this,s,void 0),Je(this,o,-1),St(this,s,e)}add({cmd:e,undo:t,mustExec:n,type:i=NaN,overwriteIfSameType:l=!1,keepUndo:h=!1}){if(n&&e(),ce(this,a))return;let c={cmd:e,undo:t,type:i};if(-1===ce(this,o))return ce(this,r).length>0&&(ce(this,r).length=0),St(this,o,0),void ce(this,r).push(c);if(l&&ce(this,r)[ce(this,o)].type===i)return h&&(c.undo=ce(this,r)[ce(this,o)].undo),void(ce(this,r)[ce(this,o)]=c);let u=ce(this,o)+1;u===ce(this,s)?ce(this,r).splice(0,1):(St(this,o,u),ue===t[n])))return oe._colorsMapping.get(n);return t}getHexCode(e){let t=this._colors.get(e);return t?ne.Util.makeHexColor(...t):e}},le=oe;Xi(le,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]])),t.ColorManager=le;let he=class{constructor(e,t,n){Je(this,D),Je(this,N),Je(this,U),Je(this,z),Je(this,V),Je(this,G),Je(this,X),Je(this,q),Je(this,Z),Je(this,$),Je(this,ee),Je(this,c,null),Je(this,u,new Map),Je(this,d,new Map),Je(this,p,null),Je(this,f,new ae),Je(this,m,0),Je(this,g,new Set),Je(this,v,null),Je(this,y,new Set),Je(this,x,null),Je(this,b,new re),Je(this,_,!1),Je(this,w,ne.AnnotationEditorType.NONE),Je(this,S,new Set),Je(this,M,this.copy.bind(this)),Je(this,E,this.cut.bind(this)),Je(this,T,this.paste.bind(this)),Je(this,A,this.keydown.bind(this)),Je(this,C,this.onEditingAction.bind(this)),Je(this,P,this.onPageChanging.bind(this)),Je(this,R,this.onScaleChanging.bind(this)),Je(this,O,this.onRotationChanging.bind(this)),Je(this,L,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1}),Je(this,I,null),St(this,I,e),St(this,x,t),ce(this,x)._on("editingaction",ce(this,C)),ce(this,x)._on("pagechanging",ce(this,P)),ce(this,x)._on("scalechanging",ce(this,R)),ce(this,x)._on("rotationchanging",ce(this,O)),St(this,p,n),this.viewParameters={realScale:ie.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:0}}static get _keyboardManager(){return(0,ne.shadow)(this,"_keyboardManager",new se([[["ctrl+a","mac+meta+a"],he.prototype.selectAll],[["ctrl+z","mac+meta+z"],he.prototype.undo],[["ctrl+y","ctrl+shift+Z","mac+meta+shift+Z"],he.prototype.redo],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete"],he.prototype.delete],[["Escape","mac+Escape"],he.prototype.unselectAll]]))}destroy(){dt(this,N,F).call(this),ce(this,x)._off("editingaction",ce(this,C)),ce(this,x)._off("pagechanging",ce(this,P)),ce(this,x)._off("scalechanging",ce(this,R)),ce(this,x)._off("rotationchanging",ce(this,O));for(let e of ce(this,d).values())e.destroy();ce(this,d).clear(),ce(this,u).clear(),ce(this,y).clear(),St(this,c,null),ce(this,S).clear(),ce(this,f).destroy()}onPageChanging({pageNumber:e}){St(this,m,e-1)}focusMainContainer(){ce(this,I).focus()}addShouldRescale(e){ce(this,y).add(e)}removeShouldRescale(e){ce(this,y).delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*ie.PixelsPerInch.PDF_TO_CSS_UNITS;for(let t of ce(this,y))t.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}addToAnnotationStorage(e){!e.isEmpty()&&ce(this,p)&&!ce(this,p).has(e.id)&&ce(this,p).setValue(e.id,e)}copy(e){if(e.preventDefault(),ce(this,c)&&ce(this,c).commitOrRemove(),!this.hasSelection)return;let t=[];for(let n of ce(this,S)){let e=n.serialize(!0);e&&t.push(e)}0!==t.length&&e.clipboardData.setData("application/pdfjs",JSON.stringify(t))}cut(e){this.copy(e),this.delete()}paste(e){e.preventDefault();let t=e.clipboardData.getData("application/pdfjs");if(!t)return;try{t=JSON.parse(t)}catch(e){return void(0,ne.warn)(`paste: "${e.message}".`)}if(!Array.isArray(t))return;this.unselectAll();let n=ce(this,d).get(ce(this,m));try{let e=[];for(let a of t){let t=n.deserialize(a);if(!t)return;e.push(t)}let i=()=>{for(let t of e)dt(this,Z,K).call(this,t);dt(this,ee,te).call(this,e)},r=()=>{for(let t of e)t.remove()};this.addCommands({cmd:i,undo:r,mustExec:!0})}catch(e){(0,ne.warn)(`paste: "${e.message}".`)}}keydown(e){var t;null!=(t=this.getActive())&&t.shouldGetKeyboardEvents()||he._keyboardManager.exec(this,e)}onEditingAction(e){["undo","redo","delete","selectAll"].includes(e.name)&&this[e.name]()}setEditingState(e){e?(dt(this,D,k).call(this),dt(this,U,B).call(this),dt(this,V,j).call(this,{isEditing:ce(this,w)!==ne.AnnotationEditorType.NONE,isEmpty:dt(this,$,Q).call(this),hasSomethingToUndo:ce(this,f).hasSomethingToUndo(),hasSomethingToRedo:ce(this,f).hasSomethingToRedo(),hasSelectedEditor:!1})):(dt(this,N,F).call(this),dt(this,z,H).call(this),dt(this,V,j).call(this,{isEditing:!1}))}registerEditorTypes(e){if(!ce(this,v)){St(this,v,e);for(let e of ce(this,v))dt(this,G,W).call(this,e.defaultPropertiesToUpdate)}}getId(){return ce(this,b).getId()}get currentLayer(){return ce(this,d).get(ce(this,m))}get currentPageIndex(){return ce(this,m)}addLayer(e){ce(this,d).set(e.pageIndex,e),ce(this,_)?e.enable():e.disable()}removeLayer(e){ce(this,d).delete(e.pageIndex)}updateMode(e){if(St(this,w,e),e===ne.AnnotationEditorType.NONE)this.setEditingState(!1),dt(this,q,J).call(this);else{this.setEditingState(!0),dt(this,X,Y).call(this);for(let t of ce(this,d).values())t.updateMode(e)}}updateToolbar(e){e!==ce(this,w)&&ce(this,x).dispatch("switchannotationeditormode",{source:this,mode:e})}updateParams(e,t){if(ce(this,v)){for(let n of ce(this,S))n.updateParams(e,t);for(let n of ce(this,v))n.updateDefaultParams(e,t)}}getEditors(e){let t=[];for(let n of ce(this,u).values())n.pageIndex===e&&t.push(n);return t}getEditor(e){return ce(this,u).get(e)}addEditor(e){ce(this,u).set(e.id,e)}removeEditor(e){var t;ce(this,u).delete(e.id),this.unselect(e),(!e.annotationElementId||!ce(this,g).has(e.annotationElementId))&&(null==(t=ce(this,p))||t.remove(e.id))}addDeletedAnnotationElement(e){ce(this,g).add(e.annotationElementId),e.deleted=!0}isDeletedAnnotationElement(e){return ce(this,g).has(e)}removeDeletedAnnotationElement(e){ce(this,g).delete(e.annotationElementId),e.deleted=!1}setActiveEditor(e){ce(this,c)!==e&&(St(this,c,e),e&&dt(this,G,W).call(this,e.propertiesToUpdate))}toggleSelected(e){if(ce(this,S).has(e))return ce(this,S).delete(e),e.unselect(),void dt(this,V,j).call(this,{hasSelectedEditor:this.hasSelection});ce(this,S).add(e),e.select(),dt(this,G,W).call(this,e.propertiesToUpdate),dt(this,V,j).call(this,{hasSelectedEditor:!0})}setSelected(e){for(let t of ce(this,S))t!==e&&t.unselect();ce(this,S).clear(),ce(this,S).add(e),e.select(),dt(this,G,W).call(this,e.propertiesToUpdate),dt(this,V,j).call(this,{hasSelectedEditor:!0})}isSelected(e){return ce(this,S).has(e)}unselect(e){e.unselect(),ce(this,S).delete(e),dt(this,V,j).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==ce(this,S).size}undo(){ce(this,f).undo(),dt(this,V,j).call(this,{hasSomethingToUndo:ce(this,f).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:dt(this,$,Q).call(this)})}redo(){ce(this,f).redo(),dt(this,V,j).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:ce(this,f).hasSomethingToRedo(),isEmpty:dt(this,$,Q).call(this)})}addCommands(e){ce(this,f).add(e),dt(this,V,j).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:dt(this,$,Q).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;let e=[...ce(this,S)];this.addCommands({cmd:()=>{for(let t of e)t.remove()},undo:()=>{for(let t of e)dt(this,Z,K).call(this,t)},mustExec:!0})}commitOrRemove(){var e;null==(e=ce(this,c))||e.commitOrRemove()}selectAll(){for(let e of ce(this,S))e.commit();dt(this,ee,te).call(this,ce(this,u).values())}unselectAll(){if(ce(this,c))ce(this,c).commitOrRemove();else if(0!==ce(this,S).size){for(let e of ce(this,S))e.unselect();ce(this,S).clear(),dt(this,V,j).call(this,{hasSelectedEditor:!1})}}isActive(e){return ce(this,c)===e}getActive(){return ce(this,c)}getMode(){return ce(this,w)}},ue=he;c=new WeakMap,u=new WeakMap,d=new WeakMap,p=new WeakMap,f=new WeakMap,m=new WeakMap,g=new WeakMap,v=new WeakMap,y=new WeakMap,x=new WeakMap,b=new WeakMap,_=new WeakMap,w=new WeakMap,S=new WeakMap,M=new WeakMap,E=new WeakMap,T=new WeakMap,A=new WeakMap,C=new WeakMap,P=new WeakMap,R=new WeakMap,O=new WeakMap,L=new WeakMap,I=new WeakMap,D=new WeakSet,k=function(){ce(this,I).addEventListener("keydown",ce(this,A))},N=new WeakSet,F=function(){ce(this,I).removeEventListener("keydown",ce(this,A))},U=new WeakSet,B=function(){document.addEventListener("copy",ce(this,M)),document.addEventListener("cut",ce(this,E)),document.addEventListener("paste",ce(this,T))},z=new WeakSet,H=function(){document.removeEventListener("copy",ce(this,M)),document.removeEventListener("cut",ce(this,E)),document.removeEventListener("paste",ce(this,T))},V=new WeakSet,j=function(e){Object.entries(e).some((([e,t])=>ce(this,L)[e]!==t))&&ce(this,x).dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(ce(this,L),e)})},G=new WeakSet,W=function(e){ce(this,x).dispatch("annotationeditorparamschanged",{source:this,details:e})},X=new WeakSet,Y=function(){if(!ce(this,_)){St(this,_,!0);for(let e of ce(this,d).values())e.enable()}},q=new WeakSet,J=function(){if(this.unselectAll(),ce(this,_)){St(this,_,!1);for(let e of ce(this,d).values())e.disable()}},Z=new WeakSet,K=function(e){let t=ce(this,d).get(e.pageIndex);t?t.addOrRebuild(e):this.addEditor(e)},$=new WeakSet,Q=function(){if(0===ce(this,u).size)return!0;if(1===ce(this,u).size)for(let e of ce(this,u).values())return e.isEmpty();return!1},ee=new WeakSet,te=function(e){ce(this,S).clear();for(let t of e)t.isEmpty()||(ce(this,S).add(t),t.select());dt(this,V,j).call(this,{hasSelectedEditor:!0})},t.AnnotationEditorUIManager=ue},(e,t,n)=>{var i,r,a,s,o,l,h,c,u,d,p,f,m,g,v,y,x,b,_,w,S,M,E,T,A;Object.defineProperty(t,"__esModule",{value:!0}),t.StatTimer=t.RenderingCancelledException=t.PixelsPerInch=t.PageViewport=t.PDFDateString=t.DOMStandardFontDataFactory=t.DOMSVGFactory=t.DOMFilterFactory=t.DOMCanvasFactory=t.DOMCMapReaderFactory=t.AnnotationPrefix=void 0,t.deprecated=function(e){console.log("Deprecated API usage: "+e)},t.getColorValues=function(e){let t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(let n of e.keys()){t.style.color=n;let i=window.getComputedStyle(t).color;e.set(n,G(i))}t.remove()},t.getCurrentTransform=function(e){let{a:t,b:n,c:i,d:r,e:a,f:s}=e.getTransform();return[t,n,i,r,a,s]},t.getCurrentTransformInverse=function(e){let{a:t,b:n,c:i,d:r,e:a,f:s}=e.getTransform().invertSelf();return[t,n,i,r,a,s]},t.getFilenameFromUrl=function(e,t=!1){return t||([e]=e.split(/[#?]/,1)),e.substring(e.lastIndexOf("/")+1)},t.getPdfFilenameFromUrl=function(e,t="document.pdf"){if("string"!=typeof e)return t;if(V(e))return(0,P.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;let n=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(e),r=n.exec(i[1])||n.exec(i[2])||n.exec(i[3]);if(r&&(r=r[0],r.includes("%")))try{r=n.exec(decodeURIComponent(r))[0]}catch(e){}return r||t},t.getRGB=G,t.getXfaPageViewport=function(e,{scale:t=1,rotation:n=0}){let{width:i,height:r}=e.attributes.style,a=[0,0,parseInt(i),parseInt(r)];return new z({viewBox:a,scale:t,rotation:n})},t.isDataScheme=V,t.isPdfFile=function(e){return"string"==typeof e&&/\.pdf$/i.test(e)},t.isValidFetchUrl=j,t.loadScript=function(e,t=!1){return new Promise(((n,i)=>{let r=document.createElement("script");r.src=e,r.onload=function(e){t&&r.remove(),n(e)},r.onerror=function(){i(new Error(`Cannot load script at: ${r.src}`))},(document.head||document.documentElement).append(r)}))},t.setLayerDimensions=function(e,t,n=!1,i=!0){if(t instanceof z){let{pageWidth:i,pageHeight:r}=t.rawDims,{style:a}=e,s=`calc(var(--scale-factor) * ${i}px)`,o=`calc(var(--scale-factor) * ${r}px)`;n&&t.rotation%180!=0?(a.width=o,a.height=s):(a.width=s,a.height=o)}i&&e.setAttribute("data-main-rotation",t.rotation)};var C=n(7),P=n(1);let R="http://www.w3.org/2000/svg";t.AnnotationPrefix="pdfjs_internal_id_";let O,L=class{},I=L;Xi(I,"CSS",96),Xi(I,"PDF",72),Xi(I,"PDF_TO_CSS_UNITS",L.CSS/L.PDF),t.PixelsPerInch=I;class D extends C.BaseFilterFactory{constructor({docId:e,ownerDocument:t=globalThis.document}={}){super(),Je(this,f),Je(this,g),Je(this,y),Je(this,b),Je(this,w),Je(this,M),Je(this,T),Je(this,i,void 0),Je(this,r,void 0),Je(this,a,void 0),Je(this,s,void 0),Je(this,o,void 0),Je(this,l,void 0),Je(this,h,void 0),Je(this,c,void 0),Je(this,u,void 0),Je(this,d,void 0),Je(this,p,0),St(this,a,e),St(this,s,t)}addFilter(e){if(!e)return"none";let t,n,i,r,s=ce(this,f,m).get(e);if(s)return s;if(1===e.length){let a=e[0],s=new Array(256);for(let e=0;e<256;e++)s[e]=a[e]/255;r=t=n=i=s.join(",")}else{let[a,s,o]=e,l=new Array(256),h=new Array(256),c=new Array(256);for(let e=0;e<256;e++)l[e]=a[e]/255,h[e]=s[e]/255,c[e]=o[e]/255;t=l.join(","),n=h.join(","),i=c.join(","),r=`${t}${n}${i}`}if(s=ce(this,f,m).get(r),s)return ce(this,f,m).set(e,s),s;let o=`g_${ce(this,a)}_transfer_map_${NT(this,p)._++}`,l=`url(#${o})`;ce(this,f,m).set(e,l),ce(this,f,m).set(r,l);let h=dt(this,b,_).call(this,o);return dt(this,M,E).call(this,t,n,i,h),l}addHCMFilter(e,t){var n;let i=`${e}-${t}`;if(ce(this,l)===i)return ce(this,h);if(St(this,l,i),St(this,h,"none"),null==(n=ce(this,o))||n.remove(),!e||!t)return ce(this,h);let r=dt(this,T,A).call(this,e);e=P.Util.makeHexColor(...r);let s=dt(this,T,A).call(this,t);if(t=P.Util.makeHexColor(...s),ce(this,g,v).style.color="","#000000"===e&&"#ffffff"===t||e===t)return ce(this,h);let u=new Array(256);for(let a=0;a<=255;a++){let e=a/255;u[a]=e<=.03928?e/12.92:Do((e+.055)/1.055,2.4)}let d=u.join(","),p=`g_${ce(this,a)}_hcm_filter`,f=St(this,c,dt(this,b,_).call(this,p));dt(this,M,E).call(this,d,d,d,f),dt(this,y,x).call(this,f);let m=(e,t)=>{let n=r[e]/255,i=s[e]/255,a=new Array(t+1);for(let r=0;r<=t;r++)a[r]=n+r/t*(i-n);return a.join(",")};return dt(this,M,E).call(this,m(0,5),m(1,5),m(2,5),f),St(this,h,`url(#${p})`),ce(this,h)}addHighlightHCMFilter(e,t,n,i){var r;let s=`${e}-${t}-${n}-${i}`;if(ce(this,u)===s)return ce(this,d);if(St(this,u,s),St(this,d,"none"),null==(r=ce(this,c))||r.remove(),!e||!t)return ce(this,d);let[o,l]=[e,t].map(dt(this,T,A).bind(this)),h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),p=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[f,m]=[n,i].map(dt(this,T,A).bind(this));p{let i=new Array(256),r=(p-h)/n,a=e/255,s=(t-e)/(255*n),o=0;for(let l=0;l<=n;l++){let e=Math.round(h+l*r),t=a+l*s;for(let n=o;n<=e;n++)i[n]=t;o=e+1}for(let l=o;l<256;l++)i[l]=i[o-1];return i.join(",")},S=`g_${ce(this,a)}_hcm_highlight_filter`,C=St(this,c,dt(this,b,_).call(this,S));return dt(this,y,x).call(this,C),dt(this,M,E).call(this,w(f[0],m[0],5),w(f[1],m[1],5),w(f[2],m[2],5),C),St(this,d,`url(#${S})`),ce(this,d)}destroy(e=!1){e&&(ce(this,h)||ce(this,d))||(ce(this,r)&&(ce(this,r).parentNode.parentNode.remove(),St(this,r,null)),ce(this,i)&&(ce(this,i).clear(),St(this,i,null)),St(this,p,0))}}i=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,u=new WeakMap,d=new WeakMap,p=new WeakMap,f=new WeakSet,m=function(){return ce(this,i)||St(this,i,new Map)},g=new WeakSet,v=function(){if(!ce(this,r)){let e=ce(this,s).createElement("div"),{style:t}=e;t.visibility="hidden",t.contain="strict",t.width=t.height=0,t.position="absolute",t.top=t.left=0,t.zIndex=-1;let n=ce(this,s).createElementNS(R,"svg");n.setAttribute("width",0),n.setAttribute("height",0),St(this,r,ce(this,s).createElementNS(R,"defs")),e.append(n),n.append(ce(this,r)),ce(this,s).body.append(e)}return ce(this,r)},y=new WeakSet,x=function(e){let t=ce(this,s).createElementNS(R,"feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(t)},b=new WeakSet,_=function(e){let t=ce(this,s).createElementNS(R,"filter");return t.setAttribute("color-interpolation-filters","sRGB"),t.setAttribute("id",e),ce(this,g,v).append(t),t},w=new WeakSet,S=function(e,t,n){let i=ce(this,s).createElementNS(R,t);i.setAttribute("type","discrete"),i.setAttribute("tableValues",n),e.append(i)},M=new WeakSet,E=function(e,t,n,i){let r=ce(this,s).createElementNS(R,"feComponentTransfer");i.append(r),dt(this,w,S).call(this,r,"feFuncR",e),dt(this,w,S).call(this,r,"feFuncG",t),dt(this,w,S).call(this,r,"feFuncB",n)},T=new WeakSet,A=function(e){return ce(this,g,v).style.color=e,G(getComputedStyle(ce(this,g,v)).getPropertyValue("color"))},t.DOMFilterFactory=D;class k extends C.BaseCanvasFactory{constructor({ownerDocument:e=globalThis.document}={}){super(),this._document=e}_createCanvas(e,t){let n=this._document.createElement("canvas");return n.width=e,n.height=t,n}}function N(e,t=!1){return ft(this,null,(function*(){if(j(e,document.baseURI)){let n=yield fetch(e);if(!n.ok)throw new Error(n.statusText);return t?new Uint8Array(yield n.arrayBuffer()):(0,P.stringToBytes)(yield n.text())}return new Promise(((n,i)=>{let r=new XMLHttpRequest;r.open("GET",e,!0),t&&(r.responseType="arraybuffer"),r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){if(200===r.status||0===r.status){let e;if(t&&r.response?e=new Uint8Array(r.response):!t&&r.responseText&&(e=(0,P.stringToBytes)(r.responseText)),e)return void n(e)}i(new Error(r.statusText))}},r.send(null)}))}))}t.DOMCanvasFactory=k;class F extends C.BaseCMapReaderFactory{_fetchData(e,t){return N(e,this.isCompressed).then((e=>({cMapData:e,compressionType:t})))}}t.DOMCMapReaderFactory=F;class U extends C.BaseStandardFontDataFactory{_fetchData(e){return N(e,!0)}}t.DOMStandardFontDataFactory=U;class B extends C.BaseSVGFactory{_createSVG(e){return document.createElementNS(R,e)}}t.DOMSVGFactory=B;class z{constructor({viewBox:e,scale:t,rotation:n,offsetX:i=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=e,this.scale=t,this.rotation=n,this.offsetX=i,this.offsetY=r;let s,o,l,h,c,u,d,p,f=(e[2]+e[0])/2,m=(e[3]+e[1])/2;switch((n%=360)<0&&(n+=360),n){case 180:s=-1,o=0,l=0,h=1;break;case 90:s=0,o=1,l=1,h=0;break;case 270:s=0,o=-1,l=-1,h=0;break;case 0:s=1,o=0,l=0,h=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(l=-l,h=-h),0===s?(c=Math.abs(m-e[1])*t+i,u=Math.abs(f-e[0])*t+r,d=(e[3]-e[1])*t,p=(e[2]-e[0])*t):(c=Math.abs(f-e[0])*t+i,u=Math.abs(m-e[1])*t+r,d=(e[2]-e[0])*t,p=(e[3]-e[1])*t),this.transform=[s*t,o*t,l*t,h*t,c-s*t*f-l*t*m,u-o*t*f-h*t*m],this.width=d,this.height=p}get rawDims(){let{viewBox:e}=this;return(0,P.shadow)(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:n=this.offsetX,offsetY:i=this.offsetY,dontFlip:r=!1}={}){return new z({viewBox:this.viewBox.slice(),scale:e,rotation:t,offsetX:n,offsetY:i,dontFlip:r})}convertToViewportPoint(e,t){return P.Util.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){let t=P.Util.applyTransform([e[0],e[1]],this.transform),n=P.Util.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],n[0],n[1]]}convertToPdfPoint(e,t){return P.Util.applyInverseTransform([e,t],this.transform)}}t.PageViewport=z;class H extends P.BaseException{constructor(e,t=0){super(e,"RenderingCancelledException"),this.extraDelay=t}}function V(e){let t=e.length,n=0;for(;n>16,(65280&t)>>8,255&t]}return e.startsWith("rgb(")?e.slice(4,-1).split(",").map((e=>parseInt(e))):e.startsWith("rgba(")?e.slice(5,-1).split(",").map((e=>parseInt(e))).slice(0,3):((0,P.warn)(`Not a valid color format: "${e}"`),[0,0,0])}t.RenderingCancelledException=H,t.StatTimer=class{constructor(){Xi(this,"started",Object.create(null)),Xi(this,"times",[])}time(e){e in this.started&&(0,P.warn)(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||(0,P.warn)(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){let e=[],t=0;for(let{name:n}of this.times)t=Math.max(n.length,t);for(let{name:n,start:i,end:r}of this.times)e.push(`${n.padEnd(t)} ${r-i}ms\n`);return e.join("")}},t.PDFDateString=class{static toDateObject(e){if(!e||"string"!=typeof e)return null;O||(O=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));let t=O.exec(e);if(!t)return null;let n=parseInt(t[1],10),i=parseInt(t[2],10);i=i>=1&&i<=12?i-1:0;let r=parseInt(t[3],10);r=r>=1&&r<=31?r:1;let a=parseInt(t[4],10);a=a>=0&&a<=23?a:0;let s=parseInt(t[5],10);s=s>=0&&s<=59?s:0;let o=parseInt(t[6],10);o=o>=0&&o<=59?o:0;let l=t[7]||"Z",h=parseInt(t[8],10);h=h>=0&&h<=23?h:0;let c=parseInt(t[9],10)||0;return c=c>=0&&c<=59?c:0,"-"===l?(a+=h,s+=c):"+"===l&&(a-=h,s-=c),new Date(Date.UTC(n,i,r,a,s,o))}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BaseStandardFontDataFactory=t.BaseSVGFactory=t.BaseFilterFactory=t.BaseCanvasFactory=t.BaseCMapReaderFactory=void 0;var i=n(1);class r{constructor(){this.constructor===r&&(0,i.unreachable)("Cannot initialize BaseFilterFactory.")}addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addHighlightHCMFilter(e,t,n,i){return"none"}destroy(e=!1){}}t.BaseFilterFactory=r;class a{constructor(){this.constructor===a&&(0,i.unreachable)("Cannot initialize BaseCanvasFactory.")}create(e,t){if(e<=0||t<=0)throw new Error("Invalid canvas size");let n=this._createCanvas(e,t);return{canvas:n,context:n.getContext("2d")}}reset(e,t,n){if(!e.canvas)throw new Error("Canvas is not specified");if(t<=0||n<=0)throw new Error("Invalid canvas size");e.canvas.width=t,e.canvas.height=n}destroy(e){if(!e.canvas)throw new Error("Canvas is not specified");e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){(0,i.unreachable)("Abstract method `_createCanvas` called.")}}t.BaseCanvasFactory=a;class s{constructor({baseUrl:e=null,isCompressed:t=!0}){this.constructor===s&&(0,i.unreachable)("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=e,this.isCompressed=t}fetch(e){return ft(this,arguments,(function*({name:e}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!e)throw new Error("CMap name must be specified.");let t=this.baseUrl+e+(this.isCompressed?".bcmap":""),n=this.isCompressed?i.CMapCompressionType.BINARY:i.CMapCompressionType.NONE;return this._fetchData(t,n).catch((e=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${t}`)}))}))}_fetchData(e,t){(0,i.unreachable)("Abstract method `_fetchData` called.")}}t.BaseCMapReaderFactory=s;class o{constructor({baseUrl:e=null}){this.constructor===o&&(0,i.unreachable)("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=e}fetch(e){return ft(this,arguments,(function*({filename:e}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!e)throw new Error("Font filename must be specified.");let t=`${this.baseUrl}${e}`;return this._fetchData(t).catch((e=>{throw new Error(`Unable to load font data at: ${t}`)}))}))}_fetchData(e){(0,i.unreachable)("Abstract method `_fetchData` called.")}}t.BaseStandardFontDataFactory=o;class l{constructor(){this.constructor===l&&(0,i.unreachable)("Cannot initialize BaseSVGFactory.")}create(e,t,n=!1){if(e<=0||t<=0)throw new Error("Invalid SVG dimensions");let i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),n||(i.setAttribute("width",`${e}px`),i.setAttribute("height",`${t}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${e} ${t}`),i}createElement(e){if("string"!=typeof e)throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){(0,i.unreachable)("Abstract method `_createSVG` called.")}}t.BaseSVGFactory=l},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MurmurHash3_64=void 0;var i=n(1);let r=3285377520,a=4294901760,s=65535;t.MurmurHash3_64=class{constructor(e){this.h1=e?4294967295&e:r,this.h2=e?4294967295&e:r}update(e){let t,n;if("string"==typeof e){t=new Uint8Array(2*e.length),n=0;for(let i=0,r=e.length;i>>8,t[n++]=255&r)}}else{if(!(0,i.isArrayBuffer)(e))throw new Error("Wrong data format in MurmurHash3_64_update. Input must be a string or array.");t=e.slice(),n=t.byteLength}let r=n>>2,o=n-4*r,l=new Uint32Array(t.buffer,0,r),h=0,c=0,u=this.h1,d=this.h2,p=3432918353,f=461845907,m=p&s,g=f&s;for(let i=0;i>>17,h=h*f&a|h*g&s,u^=h,u=u<<13|u>>>19,u=5*u+3864292196):(c=l[i],c=c*p&a|c*m&s,c=c<<15|c>>>17,c=c*f&a|c*g&s,d^=c,d=d<<13|d>>>19,d=5*d+3864292196);switch(h=0,o){case 3:h^=t[4*r+2]<<16;case 2:h^=t[4*r+1]<<8;case 1:h^=t[4*r],h=h*p&a|h*m&s,h=h<<15|h>>>17,h=h*f&a|h*g&s,1&r?u^=h:d^=h}this.h1=u,this.h2=d}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=3981806797*e&a|36045*e&s,t=4283543511*t&a|(2950163797*(t<<16|e>>>16)&a)>>>16,e^=t>>>1,e=444984403*e&a|60499*e&s,t=3301882366*t&a|(3120437893*(t<<16|e>>>16)&a)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}},(e,t,n)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.FontLoader=t.FontFaceObject=void 0;var r=n(1),a=n(10);i=new WeakMap,t.FontLoader=class{constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){Je(this,i,new Set),this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));let t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(let e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),ce(this,i).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}loadSystemFont(e){return ft(this,null,(function*(){if(e&&!ce(this,i).has(e.loadedName)){if((0,r.assert)(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:n,src:a,style:s}=e,o=new FontFace(n,a,s);this.addNativeFontFace(o);try{yield o.load(),ce(this,i).add(n)}catch(t){(0,r.warn)(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}(0,r.unreachable)("Not implemented: loadSystemFont without the Font Loading API.")}}))}bind(e){return ft(this,null,(function*(){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo)return void(yield this.loadSystemFont(e.systemFontInfo));if(this.isFontLoadingAPISupported){let t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{yield t.loaded}catch(n){throw(0,r.warn)(`Failed to load font '${t.family}': '${n}'.`),e.disableFontFace=!0,n}}return}let t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;yield new Promise((t=>{let n=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,n)}))}}))}get isFontLoadingAPISupported(){var e;let t=!(null==(e=this._document)||!e.fonts);return(0,r.shadow)(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let e=!1;return(a.isNodeJS||"undefined"!=typeof navigator&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),(0,r.shadow)(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){let{loadingRequests:t}=this,n={done:!1,complete:function(){for((0,r.assert)(!n.done,"completeRequest() cannot be called twice."),n.done=!0;t.length>0&&t[0].done;){let e=t.shift();setTimeout(e.callback,0)}},callback:e};return t.push(n),n}get _loadTestFont(){let e=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return(0,r.shadow)(this,"_loadTestFont",e)}_prepareFontLoadEvent(e,t){function n(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|255&e.charCodeAt(t+3)}function i(e,t,n,i){return e.substring(0,t)+i+e.substring(t+n)}let a,s,o=this._document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d"),h=0,c=`lt${Date.now()}${this.loadTestFontId++}`,u=this._loadTestFont;u=i(u,976,c.length,c);let d=1482184792,p=n(u,16);for(a=0,s=c.length-3;a30)return(0,r.warn)("Load test font never loaded."),void n();l.font="30px "+t,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0?n():setTimeout(e.bind(null,t,n))}(c,(()=>{m.remove(),t.complete()}))}},t.FontFaceObject=class{constructor(e,{isEvalSupported:t=!0,disableFontFace:n=!1,ignoreErrors:i=!1,inspectFont:r=null}){this.compiledGlyphs=Object.create(null);for(let a in e)this[a]=e[a];this.isEvalSupported=!1!==t,this.disableFontFace=!0===n,this.ignoreErrors=!0===i,this._inspectFont=r}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){let e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return null==(e=this._inspectFont)||e.call(this,this),t}createFontFaceRule(){var e;if(!this.data||this.disableFontFace)return null;let t,n=(0,r.bytesToString)(this.data),i=`url(data:${this.mimetype};base64,${btoa(n)});`;if(this.cssFontInfo){let e=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(e+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${e}src:${i}}`}else t=`@font-face {font-family:"${this.loadedName}";src:${i}}`;return null==(e=this._inspectFont)||e.call(this,this,i),t}getPathGenerator(e,t){if(void 0!==this.compiledGlyphs[t])return this.compiledGlyphs[t];let n;try{n=e.get(this.loadedName+"_path_"+t)}catch(e){if(!this.ignoreErrors)throw e;return(0,r.warn)(`getPathGenerator - ignoring character: "${e}".`),this.compiledGlyphs[t]=function(e,t){}}if(this.isEvalSupported&&r.FeatureTest.isEvalSupported){let e=[];for(let t of n){let n=void 0!==t.args?t.args.join(","):"";e.push("c.",t.cmd,"(",n,");\n")}return this.compiledGlyphs[t]=new Function("c","size",e.join(""))}return this.compiledGlyphs[t]=function(e,t){for(let i of n)"scale"===i.cmd&&(i.args=[t,-t]),e[i.cmd].apply(e,i.args)}}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNodeJS=void 0;let n=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type);t.isNodeJS=n},(e,t,n)=>{var i,r,a,s;Object.defineProperty(t,"__esModule",{value:!0}),t.CanvasGraphics=void 0;var o=n(1),l=n(6),h=n(12),c=n(13),u=n(10);let d=4096,p=16;class f{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,n){let i;return void 0!==this.cache[e]?(i=this.cache[e],this.canvasFactory.reset(i,t,n)):(i=this.canvasFactory.create(t,n),this.cache[e]=i),i}delete(e){delete this.cache[e]}clear(){for(let e in this.cache){let t=this.cache[e];this.canvasFactory.destroy(t),delete this.cache[e]}}}function m(e,t,n,i,r,a,s,o,h,c){let[u,d,p,f,m,g]=(0,l.getCurrentTransform)(e);if(0===d&&0===p){let l=s*u+m,v=Math.round(l),y=o*f+g,x=Math.round(y),b=(s+h)*u+m,_=Math.abs(Math.round(b)-v)||1,w=(o+c)*f+g,S=Math.abs(Math.round(w)-x)||1;return e.setTransform(Math.sign(u),0,0,Math.sign(f),v,x),e.drawImage(t,n,i,r,a,0,0,_,S),e.setTransform(u,d,p,f,m,g),[_,S]}if(0===u&&0===f){let l=o*p+m,v=Math.round(l),y=s*d+g,x=Math.round(y),b=(o+c)*p+m,_=Math.abs(Math.round(b)-v)||1,w=(s+h)*d+g,S=Math.abs(Math.round(w)-x)||1;return e.setTransform(0,Math.sign(d),Math.sign(p),0,v,x),e.drawImage(t,n,i,r,a,0,0,S,_),e.setTransform(u,d,p,f,m,g),[S,_]}return e.drawImage(t,n,i,r,a,s,o,h,c),[Math.hypot(u,d)*h,Math.hypot(p,f)*c]}class g{constructor(e,t){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=o.IDENTITY_MATRIX,this.textMatrixScale=1,this.fontMatrix=o.FONT_IDENTITY_MATRIX,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=o.TextRenderingMode.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,e,t])}clone(){let e=Object.create(this);return e.clipBox=this.clipBox.slice(),e}setCurrentPoint(e,t){this.x=e,this.y=t}updatePathMinMax(e,t,n){[t,n]=o.Util.applyTransform([t,n],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,n)}updateRectMinMax(e,t){let n=o.Util.applyTransform(t,e),i=o.Util.applyTransform(t.slice(2),e);this.minX=Math.min(this.minX,n[0],i[0]),this.minY=Math.min(this.minY,n[1],i[1]),this.maxX=Math.max(this.maxX,n[0],i[0]),this.maxY=Math.max(this.maxY,n[1],i[1])}updateScalingPathMinMax(e,t){o.Util.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.maxX=Math.max(this.maxX,t[1]),this.minY=Math.min(this.minY,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,n,i,r,a,s,l,h,c){let u=o.Util.bezierBoundingBox(t,n,i,r,a,s,l,h);if(c)return c[0]=Math.min(c[0],u[0],u[2]),c[1]=Math.max(c[1],u[0],u[2]),c[2]=Math.min(c[2],u[1],u[3]),void(c[3]=Math.max(c[3],u[1],u[3]));this.updateRectMinMax(e,u)}getPathBoundingBox(e=h.PathType.FILL,t=null){let n=[this.minX,this.minY,this.maxX,this.maxY];if(e===h.PathType.STROKE){t||(0,o.unreachable)("Stroke bounding box must include transform.");let e=o.Util.singularValueDecompose2dScale(t),i=e[0]*this.lineWidth/2,r=e[1]*this.lineWidth/2;n[0]-=i,n[1]-=r,n[2]+=i,n[3]+=r}return n}updateClipFromPath(){let e=o.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(e=h.PathType.FILL,t=null){return o.Util.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function v(e,t){if("undefined"!=typeof ImageData&&t instanceof ImageData)return void e.putImageData(t,0,0);let n,i,r,a,s,l=t.height,h=t.width,c=l%p,u=(l-c)/p,d=0===c?u:u+1,f=e.createImageData(h,p),m=0,g=t.data,v=f.data;if(t.kind===o.ImageKind.GRAYSCALE_1BPP){let t=g.byteLength,s=new Uint32Array(v.buffer,0,v.byteLength>>2),l=s.length,y=h+7>>3,x=4294967295,b=o.FeatureTest.isLittleEndian?4278190080:255;for(i=0;iy?h:8*e-7,a=-8&r,o=0,l=0;for(;i>=1}for(;n=u&&(a=c,s=h*a),n=0,r=s;r--;)v[n++]=g[m++],v[n++]=g[m++],v[n++]=g[m++],v[n++]=255;e.putImageData(f,0,i*p)}}}function y(e,t){if(t.bitmap)return void e.drawImage(t.bitmap,0,0);let n=t.height,i=t.width,r=n%p,a=(n-r)/p,s=0===r?a:a+1,o=e.createImageData(i,p),l=0,h=t.data,u=o.data;for(let d=0;d>8,e[a-2]=e[a-2]*r+n*s>>8,e[a-1]=e[a-1]*r+i*s>>8}}}function w(e,t,n){let i=e.length;for(let r=3;r>8]>>8:t[r]*i>>16}}function M(e,t){let n=o.Util.singularValueDecompose2dScale(e);n[0]=Math.fround(n[0]),n[1]=Math.fround(n[1]);let i=Math.fround((globalThis.devicePixelRatio||1)*l.PixelsPerInch.PDF_TO_CSS_UNITS);return void 0!==t?t:n[0]<=i||n[1]<=i}let E=["butt","round","square"],T=["miter","round","bevel"],A={},C={},P=class{constructor(e,t,n,r,s,{optionalContentConfig:o,markedContentStack:l=null},h,c){Je(this,i),Je(this,a),this.ctx=e,this.current=new g(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=t,this.objs=n,this.canvasFactory=r,this.filterFactory=s,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=l||[],this.optionalContentConfig=o,this.cachedCanvases=new f(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=h,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(e,t=null){return"string"==typeof e?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):t}beginDrawing({transform:e,viewport:t,transparency:n=!1,background:i=null}){let r=this.ctx.canvas.width,a=this.ctx.canvas.height,s=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,r,a),this.ctx.fillStyle=s,n){let e=this.cachedCanvases.getCanvas("transparent",r,a);this.compositeCtx=this.ctx,this.transparentCanvas=e.canvas,this.ctx=e.context,this.ctx.save(),this.ctx.transform(...(0,l.getCurrentTransform)(this.compositeCtx))}this.ctx.save(),b(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...t.transform),this.viewportScale=t.scale,this.baseTransform=(0,l.getCurrentTransform)(this.ctx)}executeOperatorList(e,t,n,i){let r=e.argsArray,a=e.fnArray,s=t||0,l=r.length;if(l===s)return s;let h,c=l-s>10&&"function"==typeof n,u=c?Date.now()+15:0,d=0,p=this.commonObjs,f=this.objs;for(;;){if(void 0!==i&&s===i.nextBreakPoint)return i.breakIt(s,n),s;if(h=a[s],h!==o.OPS.dependency)this[h].apply(this,r[s]);else for(let e of r[s]){let t=e.startsWith("g_")?p:f;if(!t.has(e))return t.get(e,n),s}if(s++,s===l)return s;if(c&&++d>10){if(Date.now()>u)return n(),s;d=0}}}endDrawing(){dt(this,i,r).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(let e of this._cachedBitmapsMap.values()){for(let t of e.values())"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),dt(this,a,s).call(this)}_scaleImage(e,t){let n,i,r=e.width,a=e.height,s=Math.max(Math.hypot(t[0],t[1]),1),o=Math.max(Math.hypot(t[2],t[3]),1),l=r,h=a,c="prescale1";for(;s>2&&l>1||o>2&&h>1;){let t=l,r=h;s>2&&l>1&&(t=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),s/=l/t),o>2&&h>1&&(r=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/r),n=this.cachedCanvases.getCanvas(c,t,r),i=n.context,i.clearRect(0,0,t,r),i.drawImage(e,0,0,l,h,0,0,t,r),e=n.canvas,l=t,h=r,c="prescale1"===c?"prescale2":"prescale1"}return{img:e,paintWidth:l,paintHeight:h}}_createMaskCanvas(e){let t,n,i,r,a=this.ctx,{width:s,height:c}=e,u=this.current.fillColor,d=this.current.patternFill,p=(0,l.getCurrentTransform)(a);if((e.bitmap||e.data)&&e.count>1){let r=e.bitmap||e.data.buffer;n=JSON.stringify(d?p:[p.slice(0,4),u]),t=this._cachedBitmapsMap.get(r),t||(t=new Map,this._cachedBitmapsMap.set(r,t));let a=t.get(n);if(a&&!d)return{canvas:a,offsetX:Math.round(Math.min(p[0],p[2])+p[4]),offsetY:Math.round(Math.min(p[1],p[3])+p[5])};i=a}i||(r=this.cachedCanvases.getCanvas("maskCanvas",s,c),y(r.context,e));let f=o.Util.transform(p,[1/s,0,0,-1/c,0,0]);f=o.Util.transform(f,[1,0,0,1,0,-c]);let g=o.Util.applyTransform([0,0],f),v=o.Util.applyTransform([s,c],f),x=o.Util.normalizeRect([g[0],g[1],v[0],v[1]]),b=Math.round(x[2]-x[0])||1,_=Math.round(x[3]-x[1])||1,w=this.cachedCanvases.getCanvas("fillCanvas",b,_),S=w.context,E=Math.min(g[0],v[0]),T=Math.min(g[1],v[1]);S.translate(-E,-T),S.transform(...f),i||(i=this._scaleImage(r.canvas,(0,l.getCurrentTransformInverse)(S)),i=i.img,t&&d&&t.set(n,i)),S.imageSmoothingEnabled=M((0,l.getCurrentTransform)(S),e.interpolate),m(S,i,0,0,i.width,i.height,0,0,s,c),S.globalCompositeOperation="source-in";let A=o.Util.transform((0,l.getCurrentTransformInverse)(S),[1,0,0,1,-E,-T]);return S.fillStyle=d?u.getPattern(a,this,A,h.PathType.FILL):u,S.fillRect(0,0,s,c),t&&!d&&(this.cachedCanvases.delete("fillCanvas"),t.set(n,w.canvas)),{canvas:w.canvas,offsetX:Math.round(E),offsetY:Math.round(T)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=E[e]}setLineJoin(e){this.ctx.lineJoin=T[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){let n=this.ctx;void 0!==n.setLineDash&&(n.setLineDash(e),n.lineDashOffset=t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(let[t,n]of e)switch(t){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n[0],n[1]);break;case"CA":this.current.strokeAlpha=n;break;case"ca":this.current.fillAlpha=n,this.ctx.globalAlpha=n;break;case"BM":this.ctx.globalCompositeOperation=n;break;case"SMask":this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");let e=this.ctx.canvas.width,t=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(n,e,t);this.suspendedCtx=this.ctx,this.ctx=i.context;let r=this.ctx;r.setTransform(...(0,l.getCurrentTransform)(this.suspendedCtx)),x(this.suspendedCtx,r),function(e,t){if(e._removeMirroring)throw new Error("Context is already forwarding operations.");e.__originalSave=e.save,e.__originalRestore=e.restore,e.__originalRotate=e.rotate,e.__originalScale=e.scale,e.__originalTranslate=e.translate,e.__originalTransform=e.transform,e.__originalSetTransform=e.setTransform,e.__originalResetTransform=e.resetTransform,e.__originalClip=e.clip,e.__originalMoveTo=e.moveTo,e.__originalLineTo=e.lineTo,e.__originalBezierCurveTo=e.bezierCurveTo,e.__originalRect=e.rect,e.__originalClosePath=e.closePath,e.__originalBeginPath=e.beginPath,e._removeMirroring=()=>{e.save=e.__originalSave,e.restore=e.__originalRestore,e.rotate=e.__originalRotate,e.scale=e.__originalScale,e.translate=e.__originalTranslate,e.transform=e.__originalTransform,e.setTransform=e.__originalSetTransform,e.resetTransform=e.__originalResetTransform,e.clip=e.__originalClip,e.moveTo=e.__originalMoveTo,e.lineTo=e.__originalLineTo,e.bezierCurveTo=e.__originalBezierCurveTo,e.rect=e.__originalRect,e.closePath=e.__originalClosePath,e.beginPath=e.__originalBeginPath,delete e._removeMirroring},e.save=function(){t.save(),this.__originalSave()},e.restore=function(){t.restore(),this.__originalRestore()},e.translate=function(e,n){t.translate(e,n),this.__originalTranslate(e,n)},e.scale=function(e,n){t.scale(e,n),this.__originalScale(e,n)},e.transform=function(e,n,i,r,a,s){t.transform(e,n,i,r,a,s),this.__originalTransform(e,n,i,r,a,s)},e.setTransform=function(e,n,i,r,a,s){t.setTransform(e,n,i,r,a,s),this.__originalSetTransform(e,n,i,r,a,s)},e.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},e.rotate=function(e){t.rotate(e),this.__originalRotate(e)},e.clip=function(e){t.clip(e),this.__originalClip(e)},e.moveTo=function(e,n){t.moveTo(e,n),this.__originalMoveTo(e,n)},e.lineTo=function(e,n){t.lineTo(e,n),this.__originalLineTo(e,n)},e.bezierCurveTo=function(e,n,i,r,a,s){t.bezierCurveTo(e,n,i,r,a,s),this.__originalBezierCurveTo(e,n,i,r,a,s)},e.rect=function(e,n,i,r){t.rect(e,n,i,r),this.__originalRect(e,n,i,r)},e.closePath=function(){t.closePath(),this.__originalClosePath()},e.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}(r,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),x(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let t=this.current.activeSMask;(function(e,t,n,i){let r=i[0],a=i[1],s=i[2]-r,o=i[3]-a;0===s||0===o||(function(e,t,n,i,r,a,s,o,l,h,c){let u,d=!!a,p=d?a[0]:0,f=d?a[1]:0,m=d?a[2]:0;u="Luminosity"===r?S:w;let g=Math.min(i,Math.ceil(1048576/n));for(let v=0;v100&&(c=100),this.current.fontSizeScale=t/c,this.ctx.font=`${h} ${l} ${c}px ${s}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(e,t){this.setLeading(-t),this.moveText(e,t)}setTextMatrix(e,t,n,i,r,a){this.current.textMatrix=[e,t,n,i,r,a],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(e,t,n,i){let r,a=this.ctx,s=this.current,h=s.font,c=s.textRenderingMode,u=s.fontSize/s.fontSizeScale,d=c&o.TextRenderingMode.FILL_STROKE_MASK,p=!!(c&o.TextRenderingMode.ADD_TO_PATH_FLAG),f=s.patternFill&&!h.missingFile;(h.disableFontFace||p||f)&&(r=h.getPathGenerator(this.commonObjs,e)),h.disableFontFace||f?(a.save(),a.translate(t,n),a.beginPath(),r(a,u),i&&a.setTransform(...i),(d===o.TextRenderingMode.FILL||d===o.TextRenderingMode.FILL_STROKE)&&a.fill(),(d===o.TextRenderingMode.STROKE||d===o.TextRenderingMode.FILL_STROKE)&&a.stroke(),a.restore()):((d===o.TextRenderingMode.FILL||d===o.TextRenderingMode.FILL_STROKE)&&a.fillText(e,t,n),(d===o.TextRenderingMode.STROKE||d===o.TextRenderingMode.FILL_STROKE)&&a.strokeText(e,t,n)),p&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:(0,l.getCurrentTransform)(a),x:t,y:n,fontSize:u,addToPath:r})}get isFontSubpixelAAEnabled(){let{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);let t=e.getImageData(0,0,10,10).data,n=!1;for(let i=3;i0&&t[i]<255){n=!0;break}return(0,o.shadow)(this,"isFontSubpixelAAEnabled",n)}showText(e){let t=this.current,n=t.font;if(n.isType3Font)return this.showType3Text(e);let i=t.fontSize;if(0===i)return;let r,a=this.ctx,s=t.fontSizeScale,c=t.charSpacing,u=t.wordSpacing,d=t.fontDirection,p=t.textHScale*d,f=e.length,m=n.vertical,g=m?1:-1,v=n.defaultVMetrics,y=i*t.fontMatrix[0],x=t.textRenderingMode===o.TextRenderingMode.FILL&&!n.disableFontFace&&!t.patternFill;if(a.save(),a.transform(...t.textMatrix),a.translate(t.x,t.y+t.textRise),d>0?a.scale(p,-1):a.scale(p,1),t.patternFill){a.save();let e=t.fillColor.getPattern(a,this,(0,l.getCurrentTransformInverse)(a),h.PathType.FILL);r=(0,l.getCurrentTransform)(a),a.restore(),a.fillStyle=e}let b=t.lineWidth,_=t.textMatrixScale;if(0===_||0===b){let e=t.textRenderingMode&o.TextRenderingMode.FILL_STROKE_MASK;(e===o.TextRenderingMode.STROKE||e===o.TextRenderingMode.FILL_STROKE)&&(b=this.getSinglePixelWidth())}else b/=_;if(1!==s&&(a.scale(s,s),b/=s),a.lineWidth=b,n.isInvalidPDFjsFont){let n=[],i=0;for(let t of e)n.push(t.unicode),i+=t.width;return a.fillText(n.join(""),0,0),t.x+=i*y*p,a.restore(),void this.compose()}let w,S=0;for(w=0;w0){let e=1e3*a.measureText(b).width/i*s;if(Mnew P(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};t=new h.TilingPattern(e,n,this.ctx,r,i)}else t=this._getPattern(e[1],e[2]);return t}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e,t,n){let i=o.Util.makeHexColor(e,t,n);this.ctx.strokeStyle=i,this.current.strokeColor=i}setFillRGBColor(e,t,n){let i=o.Util.makeHexColor(e,t,n);this.ctx.fillStyle=i,this.current.fillColor=i,this.current.patternFill=!1}_getPattern(e,t=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=(0,h.getShadingPattern)(this.getObject(e)),this.cachedPatterns.set(e,n)),t&&(n.matrix=t),n}shadingFill(e){if(!this.contentVisible)return;let t=this.ctx;this.save();let n=this._getPattern(e);t.fillStyle=n.getPattern(t,this,(0,l.getCurrentTransformInverse)(t),h.PathType.SHADING);let i=(0,l.getCurrentTransformInverse)(t);if(i){let{width:e,height:n}=t.canvas,[r,a,s,l]=o.Util.getAxialAlignedBoundingBox([0,0,e,n],i);this.ctx.fillRect(r,a,s-r,l-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){(0,o.unreachable)("Should not call beginInlineImage")}beginImageData(){(0,o.unreachable)("Should not call beginImageData")}paintFormXObjectBegin(e,t){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),Array.isArray(e)&&6===e.length&&this.transform(...e),this.baseTransform=(0,l.getCurrentTransform)(this.ctx),t)){let e=t[2]-t[0],n=t[3]-t[1];this.ctx.rect(t[0],t[1],e,n),this.current.updateRectMinMax((0,l.getCurrentTransform)(this.ctx),t),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let t=this.ctx;e.isolated||(0,o.info)("TODO: Support non-isolated groups."),e.knockout&&(0,o.warn)("Knockout groups not supported.");let n=(0,l.getCurrentTransform)(t);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let i=o.Util.getAxialAlignedBoundingBox(e.bbox,(0,l.getCurrentTransform)(t)),r=[0,0,t.canvas.width,t.canvas.height];i=o.Util.intersect(i,r)||[0,0,0,0];let a=Math.floor(i[0]),s=Math.floor(i[1]),h=Math.max(Math.ceil(i[2])-a,1),c=Math.max(Math.ceil(i[3])-s,1),u=1,p=1;h>d&&(u=h/d,h=d),c>d&&(p=c/d,c=d),this.current.startNewPathAndClipBox([0,0,h,c]);let f="groupAt"+this.groupLevel;e.smask&&(f+="_smask_"+this.smaskCounter++%2);let m=this.cachedCanvases.getCanvas(f,h,c),g=m.context;g.scale(1/u,1/p),g.translate(-a,-s),g.transform(...n),e.smask?this.smaskStack.push({canvas:m.canvas,context:g,offsetX:a,offsetY:s,scaleX:u,scaleY:p,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(t.setTransform(1,0,0,1,0,0),t.translate(a,s),t.scale(u,p),t.save()),x(t,g),this.ctx=g,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(t),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;let t=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,e.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let e=(0,l.getCurrentTransform)(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...e);let n=o.Util.getAxialAlignedBoundingBox([0,0,t.canvas.width,t.canvas.height],e);this.ctx.drawImage(t.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(e,t,n,a,s){if(dt(this,i,r).call(this),b(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),Array.isArray(t)&&4===t.length){let i=t[2]-t[0],r=t[3]-t[1];if(s&&this.annotationCanvasMap){(n=n.slice())[4]-=t[0],n[5]-=t[1],(t=t.slice())[0]=t[1]=0,t[2]=i,t[3]=r;let[a,s]=o.Util.singularValueDecompose2dScale((0,l.getCurrentTransform)(this.ctx)),{viewportScale:h}=this,c=Math.ceil(i*this.outputScaleX*h),u=Math.ceil(r*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(c,u);let{canvas:d,context:p}=this.annotationCanvas;this.annotationCanvasMap.set(e,d),this.annotationCanvas.savedCtx=this.ctx,this.ctx=p,this.ctx.save(),this.ctx.setTransform(a,0,0,-s,0,r*s),b(this.ctx)}else b(this.ctx),this.ctx.rect(t[0],t[1],i,r),this.ctx.clip(),this.endPath()}this.current=new g(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...a)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),dt(this,a,s).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;let t=e.count;(e=this.getObject(e.data,e)).count=t;let n=this.ctx,i=this.processingType3;if(i&&(void 0===i.compiled&&(i.compiled=function(e){let{width:t,height:n}=e;if(t>1e3||n>1e3)return null;let i,r,a,s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),o=t+1,l=new Uint8Array(o*(n+1)),h=t+7&-8,c=new Uint8Array(h*n),u=0;for(let m of e.data){let e=128;for(;e>0;)c[u++]=m&e?0:255,e>>=1}let d=0;for(u=0,0!==c[u]&&(l[0]=1,++d),r=1;r>2)+(c[u+1]?4:0)+(c[u-h+1]?8:0),s[e]&&(l[a+r]=s[e],++d),u++;if(c[u-h]!==c[u]&&(l[a+r]=c[u]?2:4,++d),d>1e3)return null}for(u=h*(n-1),a=i*o,0!==c[u]&&(l[a]=8,++d),r=1;r1e3)return null;let p=new Int32Array([0,o,-1,0,-o,0,0,0,1]),f=new Path2D;for(i=0;d&&i<=n;i++){let e=i*o,n=e+t;for(;e>4,l[e]&=a>>2|a<<2),f.lineTo(e%o,e/o|0),l[e]||--d}while(r!==e);--i}return c=null,l=null,function(e){e.save(),e.scale(1/t,-1/n),e.translate(0,-n),e.fill(f),e.beginPath(),e.restore()}}(e)),i.compiled))return void i.compiled(n);let r=this._createMaskCanvas(e),a=r.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(a,r.offsetX,r.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(e,t,n=0,i=0,r,a){if(!this.contentVisible)return;e=this.getObject(e.data,e);let s=this.ctx;s.save();let h=(0,l.getCurrentTransform)(s);s.transform(t,n,i,r,0,0);let c=this._createMaskCanvas(e);s.setTransform(1,0,0,1,c.offsetX-h[4],c.offsetY-h[5]);for(let l=0,u=a.length;li?h/i:1,t=l>i?l/i:1}}this._cachedScaleForStroking[0]=e,this._cachedScaleForStroking[1]=t}return this._cachedScaleForStroking}rescaleAndStroke(e){let{ctx:t}=this,{lineWidth:n}=this.current,[i,r]=this.getScaleForStroking();if(t.lineWidth=n||1,1===i&&1===r)return void t.stroke();let a=t.getLineDash();if(e&&t.save(),t.scale(i,r),a.length>0){let e=Math.max(i,r);t.setLineDash(a.map((t=>t/e))),t.lineDashOffset/=e}t.stroke(),e&&t.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}},R=P;i=new WeakSet,r=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},a=new WeakSet,s=function(){if(this.pageColors){let e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==e){let t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}},t.CanvasGraphics=R;for(let O in o.OPS)void 0!==R.prototype[O]&&(R.prototype[o.OPS[O]]=R.prototype[O])},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TilingPattern=t.PathType=void 0,t.getShadingPattern=function(e){switch(e[0]){case"RadialAxial":return new l(e);case"Mesh":return new u(e);case"Dummy":return new d}throw new Error(`Unknown IR type: ${e[0]}`)};var i=n(1),r=n(6);let a={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function s(e,t){if(!t)return;let n=t[2]-t[0],i=t[3]-t[1],r=new Path2D;r.rect(t[0],t[1],n,i),e.clip(r)}t.PathType=a;class o{constructor(){this.constructor===o&&(0,i.unreachable)("Cannot initialize BaseShadingPattern.")}getPattern(){(0,i.unreachable)("Abstract method `getPattern` called.")}}class l extends o{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let t;"axial"===this._type?t=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(t=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(let n of this._colorStops)t.addColorStop(n[0],n[1]);return t}getPattern(e,t,n,o){let l;if(o===a.STROKE||o===a.FILL){let a=t.current.getClippedPathBoundingBox(o,(0,r.getCurrentTransform)(e))||[0,0,0,0],h=Math.ceil(a[2]-a[0])||1,c=Math.ceil(a[3]-a[1])||1,u=t.cachedCanvases.getCanvas("pattern",h,c,!0),d=u.context;d.clearRect(0,0,d.canvas.width,d.canvas.height),d.beginPath(),d.rect(0,0,d.canvas.width,d.canvas.height),d.translate(-a[0],-a[1]),n=i.Util.transform(n,[1,0,0,1,a[0],a[1]]),d.transform(...t.baseTransform),this.matrix&&d.transform(...this.matrix),s(d,this._bbox),d.fillStyle=this._createGradient(d),d.fill(),l=e.createPattern(u.canvas,"no-repeat");let p=new DOMMatrix(n);l.setTransform(p)}else s(e,this._bbox),l=this._createGradient(e);return l}}function h(e,t,n,i,r,a,s,o){let l,h=t.coords,c=t.colors,u=e.data,d=4*e.width;h[n+1]>h[i+1]&&(l=n,n=i,i=l,l=a,a=s,s=l),h[i+1]>h[r+1]&&(l=i,i=r,r=l,l=s,s=o,o=l),h[n+1]>h[i+1]&&(l=n,n=i,i=l,l=a,a=s,s=l);let p=(h[n]+t.offsetX)*t.scaleX,f=(h[n+1]+t.offsetY)*t.scaleY,m=(h[i]+t.offsetX)*t.scaleX,g=(h[i+1]+t.offsetY)*t.scaleY,v=(h[r]+t.offsetX)*t.scaleX,y=(h[r+1]+t.offsetY)*t.scaleY;if(f>=y)return;let x,b,_,w,S,M,E,T,A=c[a],C=c[a+1],P=c[a+2],R=c[s],O=c[s+1],L=c[s+2],I=c[o],D=c[o+1],k=c[o+2],N=Math.round(f),F=Math.round(y);for(let U=N;U<=F;U++){if(Uy?1:g===y?0:(g-U)/(g-y),x=m-(m-v)*e,b=R-(R-I)*e,_=O-(O-D)*e,w=L-(L-k)*e}let e;e=Uy?1:(f-U)/(f-y),S=p-(p-v)*e,M=A-(A-I)*e,E=C-(C-D)*e,T=P-(P-k)*e;let t=Math.round(Math.min(x,S)),n=Math.round(Math.max(x,S)),i=d*U+4*t;for(let r=t;r<=n;r++)e=(x-r)/(x-S),e<0?e=0:e>1&&(e=1),u[i++]=b-(b-M)*e|0,u[i++]=_-(_-E)*e|0,u[i++]=w-(w-T)*e|0,u[i++]=255}}function c(e,t,n){let i,r,a=t.coords,s=t.colors;switch(t.type){case"lattice":let o=t.verticesPerRow,l=Math.floor(a.length/o)-1,c=o-1;for(i=0;i=i?r=i:n=r/e,{scale:n,size:r}}clipBbox(e,t,n,i,a){let s=i-t,o=a-n;e.ctx.rect(t,n,s,o),e.current.updateRectMinMax((0,r.getCurrentTransform)(e.ctx),[t,n,i,a]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,t,n){let r=e.ctx,a=e.current;switch(t){case 1:let e=this.ctx;r.fillStyle=e.fillStyle,r.strokeStyle=e.strokeStyle,a.fillColor=e.fillStyle,a.strokeColor=e.strokeStyle;break;case 2:let s=i.Util.makeHexColor(n[0],n[1],n[2]);r.fillStyle=s,r.strokeStyle=s,a.fillColor=s,a.strokeColor=s;break;default:throw new i.FormatError(`Unsupported paint type: ${t}`)}}getPattern(e,t,n,r){let s=n;r!==a.SHADING&&(s=i.Util.transform(s,t.baseTransform),this.matrix&&(s=i.Util.transform(s,this.matrix)));let o=this.createPatternCanvas(t),l=new DOMMatrix(s);l=l.translate(o.offsetX,o.offsetY),l=l.scale(1/o.scaleX,1/o.scaleY);let h=e.createPattern(o.canvas,"repeat");return h.setTransform(l),h}},f=p;Xi(f,"MAX_PATTERN_SIZE",3e3),t.TilingPattern=f},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.convertBlackAndWhiteToRGBA=r,t.convertToRGBA=function(e){switch(e.kind){case i.ImageKind.GRAYSCALE_1BPP:return r(e);case i.ImageKind.RGB_24BPP:return function({src:e,srcPos:t=0,dest:n,destPos:r=0,width:a,height:s}){let o=0,l=e.length>>2,h=new Uint32Array(e.buffer,t,l);if(i.FeatureTest.isLittleEndian){for(;o>>24|t<<8|4278190080,n[r+2]=t>>>16|i<<16|4278190080,n[r+3]=i>>>8|4278190080}for(let t=4*o,i=e.length;t>>8|255,n[r+2]=t<<16|i>>>16|255,n[r+3]=i<<8|255}for(let t=4*o,i=e.length;t>3,d=7&r,p=e.length;n=new Uint32Array(n.buffer);let f=0;for(let i=0;i{Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalWorkerOptions=void 0;let n=Object.create(null);t.GlobalWorkerOptions=n,n.workerPort=null,n.workerSrc=""},(e,t,n)=>{var i,r,a,s,o,l;Object.defineProperty(t,"__esModule",{value:!0}),t.MessageHandler=void 0;var h=n(1);function c(e){switch(e instanceof Error||"object"==typeof e&&null!==e||(0,h.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),e.name){case"AbortException":return new h.AbortException(e.message);case"MissingPDFException":return new h.MissingPDFException(e.message);case"PasswordException":return new h.PasswordException(e.message,e.code);case"UnexpectedResponseException":return new h.UnexpectedResponseException(e.message,e.status);case"UnknownErrorException":return new h.UnknownErrorException(e.message,e.details);default:return new h.UnknownErrorException(e.message,e.toString())}}i=new WeakSet,r=function(e){let t=e.streamId,n=this.sourceName,i=e.sourceName,r=this.comObj,a=this,s=this.actionHandler[e.action],o={enqueue(e,a=1,s){if(this.isCancelled)return;let o=this.desiredSize;this.desiredSize-=a,o>0&&this.desiredSize<=0&&(this.sinkCapability=new h.PromiseCapability,this.ready=this.sinkCapability.promise),r.postMessage({sourceName:n,targetName:i,stream:4,streamId:t,chunk:e},s)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:n,targetName:i,stream:3,streamId:t}),delete a.streamSinks[t])},error(e){(0,h.assert)(e instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:n,targetName:i,stream:5,streamId:t,reason:c(e)}))},sinkCapability:new h.PromiseCapability,onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[t]=o,new Promise((function(t){t(s(e.data,o))})).then((function(){r.postMessage({sourceName:n,targetName:i,stream:8,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:n,targetName:i,stream:8,streamId:t,reason:c(e)})}))},a=new WeakSet,s=function(e){let t=e.streamId,n=this.sourceName,i=e.sourceName,r=this.comObj,a=this.streamControllers[t],s=this.streamSinks[t];switch(e.stream){case 8:e.success?a.startCall.resolve():a.startCall.reject(c(e.reason));break;case 7:e.success?a.pullCall.resolve():a.pullCall.reject(c(e.reason));break;case 6:if(!s){r.postMessage({sourceName:n,targetName:i,stream:7,streamId:t,success:!0});break}s.desiredSize<=0&&e.desiredSize>0&&s.sinkCapability.resolve(),s.desiredSize=e.desiredSize,new Promise((function(e){var t;e(null==(t=s.onPull)?void 0:t.call(s))})).then((function(){r.postMessage({sourceName:n,targetName:i,stream:7,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:n,targetName:i,stream:7,streamId:t,reason:c(e)})}));break;case 4:if((0,h.assert)(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(e.chunk);break;case 3:if((0,h.assert)(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),dt(this,o,l).call(this,a,t);break;case 5:(0,h.assert)(a,"error should have stream controller"),a.controller.error(c(e.reason)),dt(this,o,l).call(this,a,t);break;case 2:e.success?a.cancelCall.resolve():a.cancelCall.reject(c(e.reason)),dt(this,o,l).call(this,a,t);break;case 1:if(!s)break;new Promise((function(t){var n;t(null==(n=s.onCancel)?void 0:n.call(s,c(e.reason)))})).then((function(){r.postMessage({sourceName:n,targetName:i,stream:2,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:n,targetName:i,stream:2,streamId:t,reason:c(e)})})),s.sinkCapability.reject(c(e.reason)),s.isCancelled=!0,delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}},o=new WeakSet,l=function(e,t){return ft(this,null,(function*(){var n,i,r;yield Promise.allSettled([null==(n=e.startCall)?void 0:n.promise,null==(i=e.pullCall)?void 0:i.promise,null==(r=e.cancelCall)?void 0:r.promise]),delete this.streamControllers[t]}))},t.MessageHandler=class{constructor(e,t,n){Je(this,i),Je(this,a),Je(this,o),this.sourceName=e,this.targetName=t,this.comObj=n,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),this._onComObjOnMessage=e=>{let t=e.data;if(t.targetName!==this.sourceName)return;if(t.stream)return void dt(this,a,s).call(this,t);if(t.callback){let e=t.callbackId,n=this.callbackCapabilities[e];if(!n)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],1===t.callback)n.resolve(t.data);else{if(2!==t.callback)throw new Error("Unexpected callback case");n.reject(c(t.reason))}return}let o=this.actionHandler[t.action];if(!o)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let e=this.sourceName,i=t.sourceName;new Promise((function(e){e(o(t.data))})).then((function(r){n.postMessage({sourceName:e,targetName:i,callback:1,callbackId:t.callbackId,data:r})}),(function(r){n.postMessage({sourceName:e,targetName:i,callback:2,callbackId:t.callbackId,reason:c(r)})}))}else t.streamId?dt(this,i,r).call(this,t):o(t.data)},n.addEventListener("message",this._onComObjOnMessage)}on(e,t){let n=this.actionHandler;if(n[e])throw new Error(`There is already an actionName called "${e}"`);n[e]=t}send(e,t,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},n)}sendWithPromise(e,t,n){let i=this.callbackId++,r=new h.PromiseCapability;this.callbackCapabilities[i]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:i,data:t},n)}catch(e){r.reject(e)}return r.promise}sendWithStream(e,t,n,i){let r=this.streamId++,a=this.sourceName,s=this.targetName,o=this.comObj;return new ReadableStream({start:n=>{let l=new h.PromiseCapability;return this.streamControllers[r]={controller:n,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:a,targetName:s,action:e,streamId:r,data:t,desiredSize:n.desiredSize},i),l.promise},pull:e=>{let t=new h.PromiseCapability;return this.streamControllers[r].pullCall=t,o.postMessage({sourceName:a,targetName:s,stream:6,streamId:r,desiredSize:e.desiredSize}),t.promise},cancel:e=>{(0,h.assert)(e instanceof Error,"cancel must have a valid reason");let t=new h.PromiseCapability;return this.streamControllers[r].cancelCall=t,this.streamControllers[r].isClosed=!0,o.postMessage({sourceName:a,targetName:s,stream:1,streamId:r,reason:c(e)}),t.promise}},n)}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}},(e,t,n)=>{var i,r;Object.defineProperty(t,"__esModule",{value:!0}),t.Metadata=void 0;var a=n(1);i=new WeakMap,r=new WeakMap,t.Metadata=class{constructor({parsedData:e,rawData:t}){Je(this,i,void 0),Je(this,r,void 0),St(this,i,e),St(this,r,t)}getRaw(){return ce(this,r)}get(e){var t;return null!=(t=ce(this,i).get(e))?t:null}getAll(){return(0,a.objectFromMap)(ce(this,i))}has(e){return ce(this,i).has(e)}}},(e,t,n)=>{var i,r,a,s,o,l,h;Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalContentConfig=void 0;var c=n(1),u=n(8);let d=Symbol("INTERNAL");class p{constructor(e,t){Je(this,i,!0),this.name=e,this.intent=t}get visible(){return ce(this,i)}_setVisible(e,t){e!==d&&(0,c.unreachable)("Internal method `_setVisible` called."),St(this,i,t)}}i=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakSet,h=function(e){let t=e.length;if(t<2)return!0;let n=e[0];for(let i=1;i0?(0,c.objectFromMap)(ce(this,a)):null}getGroup(e){return ce(this,a).get(e)||null}getHash(){if(null!==ce(this,r))return ce(this,r);let e=new u.MurmurHash3_64;for(let[t,n]of ce(this,a))e.update(`${t}:${n.visible}`);return St(this,r,e.hexdigest())}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFDataTransportStream=void 0;var i=n(1),r=n(6);t.PDFDataTransportStream=class{constructor({length:e,initialData:t,progressiveDone:n=!1,contentDispositionFilename:r=null,disableRange:a=!1,disableStream:s=!1},o){if((0,i.assert)(o,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.'),this._queuedChunks=[],this._progressiveDone=n,this._contentDispositionFilename=r,(null==t?void 0:t.length)>0){let e=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;this._queuedChunks.push(e)}this._pdfDataRangeTransport=o,this._isStreamingSupported=!s,this._isRangeSupported=!a,this._contentLength=e,this._fullRequestReader=null,this._rangeReaders=[],this._pdfDataRangeTransport.addRangeListener(((e,t)=>{this._onReceiveData({begin:e,chunk:t})})),this._pdfDataRangeTransport.addProgressListener(((e,t)=>{this._onProgress({loaded:e,total:t})})),this._pdfDataRangeTransport.addProgressiveReadListener((e=>{this._onReceiveData({chunk:e})})),this._pdfDataRangeTransport.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),this._pdfDataRangeTransport.transportReady()}_onReceiveData({begin:e,chunk:t}){let n=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;if(void 0===e)this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n);else{let t=this._rangeReaders.some((function(t){return t._begin===e&&(t._enqueue(n),!0)}));(0,i.assert)(t,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var e,t;return null!=(t=null==(e=this._fullRequestReader)?void 0:e._loaded)?t:0}_onProgress(e){var t,n,i,r;void 0===e.total?null==(n=null==(t=this._rangeReaders[0])?void 0:t.onProgress)||n.call(t,{loaded:e.loaded}):null==(r=null==(i=this._fullRequestReader)?void 0:i.onProgress)||r.call(i,{loaded:e.loaded,total:e.total})}_onProgressiveDone(){var e;null==(e=this._fullRequestReader)||e.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){let t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){(0,i.assert)(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let e=this._queuedChunks;return this._queuedChunks=null,new a(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new s(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(n),n}cancelAllRequests(e){var t;null==(t=this._fullRequestReader)||t.cancel(e);for(let n of this._rangeReaders.slice(0))n.cancel(e);this._pdfDataRangeTransport.abort()}};class a{constructor(e,t,n=!1,i=null){this._stream=e,this._done=n||!1,this._filename=(0,r.isPdfFile)(i)?i:null,this._queuedChunks=t||[],this._loaded=0;for(let r of this._queuedChunks)this._loaded+=r.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}read(){return ft(this,null,(function*(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=new i.PromiseCapability;return this._requests.push(e),e.promise}))}cancel(e){this._done=!0;for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class s{constructor(e,t,n){this._stream=e,this._begin=t,this._end=n,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(0===this._requests.length)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}read(){return ft(this,null,(function*(){if(this._queuedChunk){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let e=new i.PromiseCapability;return this._requests.push(e),e.promise}))}cancel(e){this._done=!0;for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XfaText=void 0;class n{static textContent(e){let t=[],i={items:t,styles:Object.create(null)};return function e(i){var r;if(!i)return;let a=null,s=i.name;if("#text"===s)a=i.value;else{if(!n.shouldBuildText(s))return;null!=(r=null==i?void 0:i.attributes)&&r.textContent?a=i.attributes.textContent:i.value&&(a=i.value)}if(null!==a&&t.push({str:a}),i.children)for(let t of i.children)e(t)}(e),i}static shouldBuildText(e){return!("textarea"===e||"input"===e||"option"===e||"select"===e)}}t.XfaText=n},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NodeStandardFontDataFactory=t.NodeFilterFactory=t.NodeCanvasFactory=t.NodeCMapReaderFactory=void 0;var i=n(7);let r=function(e){return new Promise(((t,n)=>{RC().readFile(e,((e,i)=>{!e&&i?t(new Uint8Array(i)):n(new Error(e))}))}))};class a extends i.BaseFilterFactory{}t.NodeFilterFactory=a;class s extends i.BaseCanvasFactory{_createCanvas(e,t){return Nye().createCanvas(e,t)}}t.NodeCanvasFactory=s;class o extends i.BaseCMapReaderFactory{_fetchData(e,t){return r(e).then((e=>({cMapData:e,compressionType:t})))}}t.NodeCMapReaderFactory=o;class l extends i.BaseStandardFontDataFactory{_fetchData(e){return r(e)}}t.NodeStandardFontDataFactory=l},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFNodeStream=void 0;var i=n(1),r=n(22);let a=RC(),s=Bye(),o=Uye(),l=Hye(),h=/^file:\/\/\/[a-zA-Z]:\//;t.PDFNodeStream=class{constructor(e){this.source=e,this.url=function(e){let t=l.parse(e);return"file:"===t.protocol||t.host?t:/^[a-z]:[/\\]/i.test(e)?l.parse(`file:///${e}`):(t.host||(t.protocol="file:"),t)}(e.url),this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol,this.isFsUrl="file:"===this.url.protocol,this.httpHeaders=this.isHttp&&e.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var e,t;return null!=(t=null==(e=this._fullRequestReader)?void 0:e._loaded)?t:0}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new m(this):new p(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=this.isFsUrl?new g(this,e,t):new f(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){var t;null==(t=this._fullRequestReader)||t.cancel(e);for(let n of this._rangeRequestReaders.slice(0))n.cancel(e)}};class c{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;let t=e.source;this._contentLength=t.length,this._loaded=0,this._filename=null,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._readableStream=null,this._readCapability=new i.PromiseCapability,this._headersCapability=new i.PromiseCapability}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){return ft(this,null,(function*(){var e;if(yield this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return null===t?(this._readCapability=new i.PromiseCapability,this.read()):(this._loaded+=t.length,null==(e=this.onProgress)||e.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}))}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",(()=>{this._readCapability.resolve()})),e.on("end",(()=>{e.destroy(),this._done=!0,this._readCapability.resolve()})),e.on("error",(e=>{this._error(e)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new i.AbortException("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class u{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=new i.PromiseCapability;let t=e.source;this._isStreamingSupported=!t.disableStream}get isStreamingSupported(){return this._isStreamingSupported}read(){return ft(this,null,(function*(){var e;if(yield this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return null===t?(this._readCapability=new i.PromiseCapability,this.read()):(this._loaded+=t.length,null==(e=this.onProgress)||e.call(this,{loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}))}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",(()=>{this._readCapability.resolve()})),e.on("end",(()=>{e.destroy(),this._done=!0,this._readCapability.resolve()})),e.on("error",(e=>{this._error(e)})),this._storedError&&this._readableStream.destroy(this._storedError)}}function d(e,t){return{protocol:e.protocol,auth:e.auth,host:e.hostname,port:e.port,path:e.path,method:"GET",headers:t}}class p extends c{constructor(e){super(e);let t=t=>{if(404===t.statusCode){let e=new i.MissingPDFException(`Missing PDF "${this._url}".`);return this._storedError=e,void this._headersCapability.reject(e)}this._headersCapability.resolve(),this._setReadableStream(t);let n=e=>this._readableStream.headers[e.toLowerCase()],{allowRangeRequests:a,suggestedLength:s}=(0,r.validateRangeRequestCapabilities)({getResponseHeader:n,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=s||this._contentLength,this._filename=(0,r.extractFilenameFromHeader)(n)};this._request=null,"http:"===this._url.protocol?this._request=s.request(d(this._url,e.httpHeaders),t):this._request=o.request(d(this._url,e.httpHeaders),t),this._request.on("error",(e=>{this._storedError=e,this._headersCapability.reject(e)})),this._request.end()}}class f extends u{constructor(e,t,n){super(e),this._httpHeaders={};for(let i in e.httpHeaders){let t=e.httpHeaders[i];void 0!==t&&(this._httpHeaders[i]=t)}this._httpHeaders.Range=`bytes=${t}-${n-1}`;let r=e=>{if(404!==e.statusCode)this._setReadableStream(e);else{let e=new i.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=e}};this._request=null,"http:"===this._url.protocol?this._request=s.request(d(this._url,this._httpHeaders),r):this._request=o.request(d(this._url,this._httpHeaders),r),this._request.on("error",(e=>{this._storedError=e})),this._request.end()}}class m extends c{constructor(e){super(e);let t=decodeURIComponent(this._url.path);h.test(this._url.href)&&(t=t.replace(/^\//,"")),a.lstat(t,((e,n)=>{if(e)return"ENOENT"===e.code&&(e=new i.MissingPDFException(`Missing PDF "${t}".`)),this._storedError=e,void this._headersCapability.reject(e);this._contentLength=n.size,this._setReadableStream(a.createReadStream(t)),this._headersCapability.resolve()}))}}class g extends u{constructor(e,t,n){super(e);let i=decodeURIComponent(this._url.path);h.test(this._url.href)&&(i=i.replace(/^\//,"")),this._setReadableStream(a.createReadStream(i,{start:t,end:n-1}))}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createResponseStatusError=function(e,t){return 404===e||0===e&&t.startsWith("file:")?new i.MissingPDFException('Missing PDF "'+t+'".'):new i.UnexpectedResponseException(`Unexpected server response (${e}) while retrieving PDF "${t}".`,e)},t.extractFilenameFromHeader=function(e){let t=e("Content-Disposition");if(t){let n=(0,r.getFilenameFromContentDispositionHeader)(t);if(n.includes("%"))try{n=decodeURIComponent(n)}catch(e){}if((0,a.isPdfFile)(n))return n}return null},t.validateRangeRequestCapabilities=function({getResponseHeader:e,isHttp:t,rangeChunkSize:n,disableRange:i}){let r={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(e("Content-Length"),10);return!Number.isInteger(a)||(r.suggestedLength=a,a<=2*n)||i||!t||"bytes"!==e("Accept-Ranges")||"identity"!==(e("Content-Encoding")||"identity")||(r.allowRangeRequests=!0),r},t.validateResponseStatus=function(e){return 200===e||206===e};var i=n(1),r=n(23),a=n(6)},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getFilenameFromContentDispositionHeader=function(e){let t=!0,n=r("filename\\*","i").exec(e);if(n){n=n[1];let e=o(n);return e=unescape(e),e=l(e),e=h(e),s(e)}if(n=function(e){let t,n=[],i=r("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(t=i.exec(e));){let[,e,i,r]=t;if(e=parseInt(e,10),e in n){if(0===e)break}else n[e]=[i,r]}let a=[];for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFNetworkStream=void 0;var i=n(1),r=n(22);class a{constructor(e,t={}){this.url=e,this.isHttp=/^https?:/i.test(e),this.httpHeaders=this.isHttp&&t.httpHeaders||Object.create(null),this.withCredentials=t.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(e,t,n){let i={begin:e,end:t};for(let r in n)i[r]=n[r];return this.request(i)}requestFull(e){return this.request(e)}request(e){let t=new XMLHttpRequest,n=this.currXhrId++,i=this.pendingRequests[n]={xhr:t};t.open("GET",this.url),t.withCredentials=this.withCredentials;for(let r in this.httpHeaders){let e=this.httpHeaders[r];void 0!==e&&t.setRequestHeader(r,e)}return this.isHttp&&"begin"in e&&"end"in e?(t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),i.expectedStatus=206):i.expectedStatus=200,t.responseType="arraybuffer",e.onError&&(t.onerror=function(n){e.onError(t.status)}),t.onreadystatechange=this.onStateChange.bind(this,n),t.onprogress=this.onProgress.bind(this,n),i.onHeadersReceived=e.onHeadersReceived,i.onDone=e.onDone,i.onError=e.onError,i.onProgress=e.onProgress,t.send(null),n}onProgress(e,t){var n;let i=this.pendingRequests[e];i&&(null==(n=i.onProgress)||n.call(i,t))}onStateChange(e,t){var n,r,a;let s=this.pendingRequests[e];if(!s)return;let o=s.xhr;if(o.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),4!==o.readyState||!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],0===o.status&&this.isHttp)return void(null==(n=s.onError)||n.call(s,o.status));let l=o.status||200;if((200!==l||206!==s.expectedStatus)&&l!==s.expectedStatus)return void(null==(r=s.onError)||r.call(s,o.status));let h=function(e){let t=e.response;return"string"!=typeof t?t:(0,i.stringToBytes)(t).buffer}(o);if(206===l){let e=o.getResponseHeader("Content-Range"),t=/bytes (\d+)-(\d+)\/(\d+)/.exec(e);s.onDone({begin:parseInt(t[1],10),chunk:h})}else h?s.onDone({begin:0,chunk:h}):null==(a=s.onError)||a.call(s,o.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){let t=this.pendingRequests[e].xhr;delete this.pendingRequests[e],t.abort()}}t.PDFNetworkStream=class{constructor(e){this._source=e,this._manager=new a(e.url,{httpHeaders:e.httpHeaders,withCredentials:e.withCredentials}),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){let t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new s(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){let n=new o(this._manager,e,t);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(e){var t;null==(t=this._fullRequestReader)||t.cancel(e);for(let n of this._rangeRequestReaders.slice(0))n.cancel(e)}};class s{constructor(e,t){this._manager=e;let n={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._fullRequestId=e.requestFull(n),this._headersReceivedCapability=new i.PromiseCapability,this._disableRange=t.disableRange||!1,this._contentLength=t.length,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let e=this._fullRequestId,t=this._manager.getRequestXhr(e),n=e=>t.getResponseHeader(e),{allowRangeRequests:i,suggestedLength:a}=(0,r.validateRangeRequestCapabilities)({getResponseHeader:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=(0,r.extractFilenameFromHeader)(n),this._isRangeSupported&&this._manager.abortRequest(e),this._headersReceivedCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=(0,r.createResponseStatusError)(e,this._url),this._headersReceivedCapability.reject(this._storedError);for(let t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){var t;null==(t=this.onProgress)||t.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}read(){return ft(this,null,(function*(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=new i.PromiseCapability;return this._requests.push(e),e.promise}))}cancel(e){this._done=!0,this._headersReceivedCapability.reject(e);for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class o{constructor(e,t,n){this._manager=e;let i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._requestId=e.requestRange(t,n,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){var e;null==(e=this.onClosed)||e.call(this,this)}_onDone(e){let t=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0;for(let n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError=(0,r.createResponseStatusError)(e,this._url);for(let t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){var t;this.isStreamingSupported||null==(t=this.onProgress)||t.call(this,{loaded:e.loaded})}get isStreamingSupported(){return!1}read(){return ft(this,null,(function*(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let e=new i.PromiseCapability;return this._requests.push(e),e.promise}))}cancel(e){this._done=!0;for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFFetchStream=void 0;var i=n(1),r=n(22);function a(e,t,n){return{method:"GET",headers:e,signal:n.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function s(e){let t=new Headers;for(let n in e){let i=e[n];void 0!==i&&t.append(n,i)}return t}function o(e){return e instanceof Uint8Array?e.buffer:e instanceof ArrayBuffer?e:((0,i.warn)(`getArrayBuffer - unexpected data format: ${e}`),new Uint8Array(e).buffer)}t.PDFFetchStream=class{constructor(e){this.source=e,this.isHttp=/^https?:/i.test(e.url),this.httpHeaders=this.isHttp&&e.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var e,t;return null!=(t=null==(e=this._fullRequestReader)?void 0:e._loaded)?t:0}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new l(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new h(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){var t;null==(t=this._fullRequestReader)||t.cancel(e);for(let n of this._rangeRequestReaders.slice(0))n.cancel(e)}};class l{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;let t=e.source;this._withCredentials=t.withCredentials||!1,this._contentLength=t.length,this._headersCapability=new i.PromiseCapability,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._headers=s(this._stream.httpHeaders);let n=t.url;fetch(n,a(this._headers,this._withCredentials,this._abortController)).then((e=>{if(!(0,r.validateResponseStatus)(e.status))throw(0,r.createResponseStatusError)(e.status,n);this._reader=e.body.getReader(),this._headersCapability.resolve();let t=t=>e.headers.get(t),{allowRangeRequests:a,suggestedLength:s}=(0,r.validateRangeRequestCapabilities)({getResponseHeader:t,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=s||this._contentLength,this._filename=(0,r.extractFilenameFromHeader)(t),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new i.AbortException("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){return ft(this,null,(function*(){var e;yield this._headersCapability.promise;let{value:t,done:n}=yield this._reader.read();return n?{value:t,done:n}:(this._loaded+=t.byteLength,null==(e=this.onProgress)||e.call(this,{loaded:this._loaded,total:this._contentLength}),{value:o(t),done:!1})}))}cancel(e){var t;null==(t=this._reader)||t.cancel(e),this._abortController.abort()}}class h{constructor(e,t,n){this._stream=e,this._reader=null,this._loaded=0;let o=e.source;this._withCredentials=o.withCredentials||!1,this._readCapability=new i.PromiseCapability,this._isStreamingSupported=!o.disableStream,this._abortController=new AbortController,this._headers=s(this._stream.httpHeaders),this._headers.append("Range",`bytes=${t}-${n-1}`);let l=o.url;fetch(l,a(this._headers,this._withCredentials,this._abortController)).then((e=>{if(!(0,r.validateResponseStatus)(e.status))throw(0,r.createResponseStatusError)(e.status,l);this._readCapability.resolve(),this._reader=e.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}read(){return ft(this,null,(function*(){var e;yield this._readCapability.promise;let{value:t,done:n}=yield this._reader.read();return n?{value:t,done:n}:(this._loaded+=t.byteLength,null==(e=this.onProgress)||e.call(this,{loaded:this._loaded}),{value:o(t),done:!1})}))}cancel(e){var t;null==(t=this._reader)||t.cancel(e),this._abortController.abort()}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TextLayerRenderTask=void 0,t.renderTextLayer=function(e){!e.textContentSource&&(e.textContent||e.textContentStream)&&((0,r.deprecated)("The TextLayerRender `textContent`/`textContentStream` parameters will be removed in the future, please use `textContentSource` instead."),e.textContentSource=e.textContent||e.textContentStream);let{container:t,viewport:n}=e,i=getComputedStyle(t),a=i.getPropertyValue("visibility"),s=parseFloat(i.getPropertyValue("--scale-factor"));"visible"===a&&(!s||Math.abs(s-n.scale)>1e-5)&&console.error("The `--scale-factor` CSS-variable must be set, to the same value as `viewport.scale`, either on the `container`-element itself or higher up in the DOM.");let o=new c(e);return o._render(),o},t.updateTextLayer=function({container:e,viewport:t,textDivs:n,textDivProperties:i,isOffscreenCanvasSupported:a,mustRotate:s=!0,mustRescale:l=!0}){if(s&&(0,r.setLayerDimensions)(e,{rotation:t.rotation}),l){let e=o(0,a),r={prevFontSize:null,prevFontFamily:null,div:null,scale:t.scale*(globalThis.devicePixelRatio||1),properties:null,ctx:e};for(let t of n)r.properties=i.get(t),r.div=t,h(r)}};var i=n(1),r=n(6);let a=30,s=new Map;function o(e,t){let n;if(t&&i.FeatureTest.isOffscreenCanvasSupported)n=new OffscreenCanvas(e,e).getContext("2d",{alpha:!1});else{let t=document.createElement("canvas");t.width=t.height=e,n=t.getContext("2d",{alpha:!1})}return n}function l(e,t,n){let r=document.createElement("span"),l={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};e._textDivs.push(r);let h=i.Util.transform(e._transform,t.transform),c=Math.atan2(h[1],h[0]),u=n[t.fontName];u.vertical&&(c+=Math.PI/2);let d,p,f=Math.hypot(h[2],h[3]),m=f*function(e,t){let n=s.get(e);if(n)return n;let i=o(a,t);i.font=`30px ${e}`;let r=i.measureText(""),l=r.fontBoundingBoxAscent,h=Math.abs(r.fontBoundingBoxDescent);if(l){let t=l/(l+h);return s.set(e,t),i.canvas.width=i.canvas.height=0,t}i.strokeStyle="red",i.clearRect(0,0,a,a),i.strokeText("g",0,0);let c=i.getImageData(0,0,a,a).data;h=0;for(let s=c.length-1-3;s>=0;s-=4)if(c[s]>0){h=Math.ceil(s/4/a);break}i.clearRect(0,0,a,a),i.strokeText("A",0,a),c=i.getImageData(0,0,a,a).data,l=0;for(let s=0,o=c.length;s0){l=a-Math.floor(s/4/a);break}if(i.canvas.width=i.canvas.height=0,l){let t=l/(l+h);return s.set(e,t),t}return s.set(e,.8),.8}(u.fontFamily,e._isOffscreenCanvasSupported);0===c?(d=h[4],p=h[5]-m):(d=h[4]+m*Math.sin(c),p=h[5]-m*Math.cos(c));let g="calc(var(--scale-factor)*",v=r.style;e._container===e._rootContainer?(v.left=`${(100*d/e._pageWidth).toFixed(2)}%`,v.top=`${(100*p/e._pageHeight).toFixed(2)}%`):(v.left=`${g}${d.toFixed(2)}px)`,v.top=`${g}${p.toFixed(2)}px)`),v.fontSize=`${g}${f.toFixed(2)}px)`,v.fontFamily=u.fontFamily,l.fontSize=f,r.setAttribute("role","presentation"),r.textContent=t.str,r.dir=t.dir,e._fontInspectorEnabled&&(r.dataset.fontName=t.fontName),0!==c&&(l.angle=c*(180/Math.PI));let y=!1;if(t.str.length>1)y=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){let e=Math.abs(t.transform[0]),n=Math.abs(t.transform[3]);e!==n&&Math.max(e,n)/Math.min(e,n)>1.5&&(y=!0)}y&&(l.canvasWidth=u.vertical?t.height:t.width),e._textDivProperties.set(r,l),e._isReadableStream&&e._layoutText(r)}function h(e){let{div:t,scale:n,properties:i,ctx:r,prevFontSize:a,prevFontFamily:s}=e,{style:o}=t,l="";if(0!==i.canvasWidth&&i.hasText){let{fontFamily:h}=o,{canvasWidth:c,fontSize:u}=i;(a!==u||s!==h)&&(r.font=`${u*n}px ${h}`,e.prevFontSize=u,e.prevFontFamily=h);let{width:d}=r.measureText(t.textContent);d>0&&(l=`scaleX(${c*n/d})`)}0!==i.angle&&(l=`rotate(${i.angle}deg) ${l}`),l.length>0&&(o.transform=l)}class c{constructor({textContentSource:e,container:t,viewport:n,textDivs:a,textDivProperties:s,textContentItemsStr:l,isOffscreenCanvasSupported:h}){var c;this._textContentSource=e,this._isReadableStream=e instanceof ReadableStream,this._container=this._rootContainer=t,this._textDivs=a||[],this._textContentItemsStr=l||[],this._isOffscreenCanvasSupported=h,this._fontInspectorEnabled=!(null==(c=globalThis.FontInspector)||!c.enabled),this._reader=null,this._textDivProperties=s||new WeakMap,this._canceled=!1,this._capability=new i.PromiseCapability,this._layoutTextParams={prevFontSize:null,prevFontFamily:null,div:null,scale:n.scale*(globalThis.devicePixelRatio||1),properties:null,ctx:o(0,h)};let{pageWidth:u,pageHeight:d,pageX:p,pageY:f}=n.rawDims;this._transform=[1,0,0,-1,-p,f+d],this._pageWidth=u,this._pageHeight=d,(0,r.setLayerDimensions)(t,n),this._capability.promise.finally((()=>{this._layoutTextParams=null})).catch((()=>{}))}get promise(){return this._capability.promise}cancel(){this._canceled=!0,this._reader&&(this._reader.cancel(new i.AbortException("TextLayer task cancelled.")).catch((()=>{})),this._reader=null),this._capability.reject(new i.AbortException("TextLayer task cancelled."))}_processItems(e,t){for(let n of e)if(void 0!==n.str)this._textContentItemsStr.push(n.str),l(this,n,t);else if("beginMarkedContentProps"===n.type||"beginMarkedContent"===n.type){let e=this._container;this._container=document.createElement("span"),this._container.classList.add("markedContent"),null!==n.id&&this._container.setAttribute("id",`${n.id}`),e.append(this._container)}else"endMarkedContent"===n.type&&(this._container=this._container.parentNode)}_layoutText(e){let t=this._layoutTextParams.properties=this._textDivProperties.get(e);if(this._layoutTextParams.div=e,h(this._layoutTextParams),t.hasText&&this._container.append(e),t.hasEOL){let e=document.createElement("br");e.setAttribute("role","presentation"),this._container.append(e)}}_render(){let e=new i.PromiseCapability,t=Object.create(null);if(this._isReadableStream){let n=()=>{this._reader.read().then((({value:i,done:r})=>{r?e.resolve():(Object.assign(t,i.styles),this._processItems(i.items,t),n())}),e.reject)};this._reader=this._textContentSource.getReader(),n()}else{if(!this._textContentSource)throw new Error('No "textContentSource" parameter specified.');{let{items:t,styles:n}=this._textContentSource;this._processItems(t,n),e.resolve()}}e.promise.then((()=>{t=null,function(e){if(e._canceled)return;let t=e._textDivs,n=e._capability;if(t.length>1e5)n.resolve();else{if(!e._isReadableStream)for(let n of t)e._layoutText(n);n.resolve()}}(this)}),this._capability.reject)}}t.TextLayerRenderTask=c},(e,t,n)=>{var i,r,a,s,o,l,h,c,u,d,p,f,m,g,v,y,x,b;Object.defineProperty(t,"__esModule",{value:!0}),t.AnnotationEditorLayer=void 0;var _=n(1),w=n(4),S=n(5),M=n(28),E=n(33),T=n(6);let A=class{constructor(e){Je(this,p),Je(this,m),Je(this,v),Je(this,x),Je(this,i,void 0),Je(this,r,!1),Je(this,a,null),Je(this,s,this.pointerup.bind(this)),Je(this,o,this.pointerdown.bind(this)),Je(this,l,new Map),Je(this,h,!1),Je(this,c,!1),Je(this,u,!1),Je(this,d,void 0),A._initialized||(A._initialized=!0,M.FreeTextEditor.initialize(e.l10n),E.InkEditor.initialize(e.l10n)),e.uiManager.registerEditorTypes([M.FreeTextEditor,E.InkEditor]),St(this,d,e.uiManager),this.pageIndex=e.pageIndex,this.div=e.div,St(this,i,e.accessibilityManager),St(this,a,e.annotationLayer),this.viewport=e.viewport,ce(this,d).addLayer(this)}get isEmpty(){return 0===ce(this,l).size}updateToolbar(e){ce(this,d).updateToolbar(e)}updateMode(e=ce(this,d).getMode()){dt(this,x,b).call(this),e===_.AnnotationEditorType.INK?(this.addInkEditorIfNeeded(!1),this.disableClick()):this.enableClick(),ce(this,d).unselectAll(),e!==_.AnnotationEditorType.NONE&&(this.div.classList.toggle("freeTextEditing",e===_.AnnotationEditorType.FREETEXT),this.div.classList.toggle("inkEditing",e===_.AnnotationEditorType.INK),this.div.hidden=!1)}addInkEditorIfNeeded(e){if(e||ce(this,d).getMode()===_.AnnotationEditorType.INK){if(!e)for(let e of ce(this,l).values())if(e.isEmpty())return void e.setInBackground();dt(this,v,y).call(this,{offsetX:0,offsetY:0}).setInBackground()}}setEditingState(e){ce(this,d).setEditingState(e)}addCommands(e){ce(this,d).addCommands(e)}enable(){this.div.style.pointerEvents="auto";let e=new Set;for(let n of ce(this,l).values())n.enableEditing(),n.annotationElementId&&e.add(n.annotationElementId);if(!ce(this,a))return;let t=ce(this,a).getEditableAnnotations();for(let n of t){if(n.hide(),ce(this,d).isDeletedAnnotationElement(n.data.id)||e.has(n.data.id))continue;let t=this.deserialize(n);t&&(this.addOrRebuild(t),t.enableEditing())}}disable(){var e;St(this,u,!0),this.div.style.pointerEvents="none";let t=new Set;for(let n of ce(this,l).values())n.disableEditing(),n.annotationElementId&&null===n.serialize()?(null==(e=this.getEditableAnnotation(n.annotationElementId))||e.show(),n.remove()):t.add(n.annotationElementId);if(ce(this,a)){let e=ce(this,a).getEditableAnnotations();for(let n of e){let{id:e}=n.data;t.has(e)||ce(this,d).isDeletedAnnotationElement(e)||n.show()}}dt(this,x,b).call(this),this.isEmpty&&(this.div.hidden=!0),St(this,u,!1)}getEditableAnnotation(e){var t;return(null==(t=ce(this,a))?void 0:t.getEditableAnnotation(e))||null}setActiveEditor(e){ce(this,d).getActive()!==e&&ce(this,d).setActiveEditor(e)}enableClick(){this.div.addEventListener("pointerdown",ce(this,o)),this.div.addEventListener("pointerup",ce(this,s))}disableClick(){this.div.removeEventListener("pointerdown",ce(this,o)),this.div.removeEventListener("pointerup",ce(this,s))}attach(e){ce(this,l).set(e.id,e);let{annotationElementId:t}=e;t&&ce(this,d).isDeletedAnnotationElement(t)&&ce(this,d).removeDeletedAnnotationElement(e)}detach(e){var t;ce(this,l).delete(e.id),null==(t=ce(this,i))||t.removePointerInTextLayer(e.contentDiv),!ce(this,u)&&e.annotationElementId&&ce(this,d).addDeletedAnnotationElement(e)}remove(e){this.detach(e),ce(this,d).removeEditor(e),e.div.style.display="none",setTimeout((()=>{e.div.style.display="",e.div.remove(),e.isAttachedToDOM=!1,document.activeElement===document.body&&ce(this,d).focusMainContainer()}),0),ce(this,c)||this.addInkEditorIfNeeded(!1)}add(e){if(dt(this,p,f).call(this,e),ce(this,d).addEditor(e),this.attach(e),!e.isAttachedToDOM){let t=e.render();this.div.append(t),e.isAttachedToDOM=!0}this.moveEditorInDOM(e),e.onceAdded(),ce(this,d).addToAnnotationStorage(e)}moveEditorInDOM(e){var t;null==(t=ce(this,i))||t.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?e.rebuild():this.add(e)}getNextId(){return ce(this,d).getId()}deserialize(e){var t;switch(null!=(t=e.annotationType)?t:e.annotationEditorType){case _.AnnotationEditorType.FREETEXT:return M.FreeTextEditor.deserialize(e,this,ce(this,d));case _.AnnotationEditorType.INK:return E.InkEditor.deserialize(e,this,ce(this,d))}return null}setSelected(e){ce(this,d).setSelected(e)}toggleSelected(e){ce(this,d).toggleSelected(e)}isSelected(e){return ce(this,d).isSelected(e)}unselect(e){ce(this,d).unselect(e)}pointerup(e){let{isMac:t}=_.FeatureTest.platform;if(!(0!==e.button||e.ctrlKey&&t)&&e.target===this.div&&ce(this,h)){if(St(this,h,!1),!ce(this,r))return void St(this,r,!0);dt(this,v,y).call(this,e)}}pointerdown(e){let{isMac:t}=_.FeatureTest.platform;if(0!==e.button||e.ctrlKey&&t||e.target!==this.div)return;St(this,h,!0);let n=ce(this,d).getActive();St(this,r,!n||n.isEmpty())}drop(e){let t=e.dataTransfer.getData("text/plain"),n=ce(this,d).getEditor(t);if(!n)return;e.preventDefault(),e.dataTransfer.dropEffect="move",dt(this,p,f).call(this,n);let i=this.div.getBoundingClientRect(),r=e.clientX-i.x,a=e.clientY-i.y;n.translate(r-n.startX,a-n.startY),this.moveEditorInDOM(n),n.div.focus()}dragover(e){e.preventDefault()}destroy(){var e,t;(null==(e=ce(this,d).getActive())?void 0:e.parent)===this&&ce(this,d).setActiveEditor(null);for(let n of ce(this,l).values())null==(t=ce(this,i))||t.removePointerInTextLayer(n.contentDiv),n.setParent(null),n.isAttachedToDOM=!1,n.div.remove();this.div=null,ce(this,l).clear(),ce(this,d).removeLayer(this)}render({viewport:e}){this.viewport=e,(0,T.setLayerDimensions)(this.div,e),(0,S.bindEvents)(this,this.div,["dragover","drop"]);for(let t of ce(this,d).getEditors(this.pageIndex))this.add(t);this.updateMode()}update({viewport:e}){ce(this,d).commitOrRemove(),this.viewport=e,(0,T.setLayerDimensions)(this.div,{rotation:e.rotation}),this.updateMode()}get pageDimensions(){let{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}},C=A;i=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,u=new WeakMap,d=new WeakMap,p=new WeakSet,f=function(e){var t;e.parent!==this&&(e.annotationElementId&&(ce(this,d).addDeletedAnnotationElement(e.annotationElementId),w.AnnotationEditor.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),null==(t=e.parent)||t.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))},m=new WeakSet,g=function(e){switch(ce(this,d).getMode()){case _.AnnotationEditorType.FREETEXT:return new M.FreeTextEditor(e);case _.AnnotationEditorType.INK:return new E.InkEditor(e)}return null},v=new WeakSet,y=function(e){let t=this.getNextId(),n=dt(this,m,g).call(this,{parent:this,id:t,x:e.offsetX,y:e.offsetY,uiManager:ce(this,d)});return n&&this.add(n),n},x=new WeakSet,b=function(){St(this,c,!0);for(let e of ce(this,l).values())e.isEmpty()&&e.remove();St(this,c,!1)},Xi(C,"_initialized",!1),t.AnnotationEditorLayer=C},(e,t,n)=>{var i,r,a,s,o,l,h,c,u,d,p,f,m,g,v,y,x,b,_,w,S,M,E;Object.defineProperty(t,"__esModule",{value:!0}),t.FreeTextEditor=void 0;var T=n(1),A=n(5),C=n(4),P=n(29);let R=class extends C.AnnotationEditor{constructor(e){super(Ri(wr({},e),{name:"freeTextEditor"})),Je(this,d),Je(this,f),Je(this,g),Je(this,y),Je(this,b),Je(this,w),Je(this,M),Je(this,i,this.editorDivBlur.bind(this)),Je(this,r,this.editorDivFocus.bind(this)),Je(this,a,this.editorDivInput.bind(this)),Je(this,s,this.editorDivKeydown.bind(this)),Je(this,o,void 0),Je(this,l,""),Je(this,h,`${this.id}-editor`),Je(this,c,void 0),Je(this,u,null),St(this,o,e.color||R._defaultColor||C.AnnotationEditor._defaultLineColor),St(this,c,e.fontSize||R._defaultFontSize)}static get _keyboardManager(){return(0,T.shadow)(this,"_keyboardManager",new A.KeyboardManager([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],R.prototype.commitOrRemove,!0],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],R.prototype.commitOrRemove]]))}static initialize(e){this._l10nPromise=new Map(["free_text2_default_content","editor_free_text2_aria_label"].map((t=>[t,e.get(t)])));let t=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(t.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,t){switch(e){case T.AnnotationEditorParamsType.FREETEXT_SIZE:R._defaultFontSize=t;break;case T.AnnotationEditorParamsType.FREETEXT_COLOR:R._defaultColor=t}}updateParams(e,t){switch(e){case T.AnnotationEditorParamsType.FREETEXT_SIZE:dt(this,d,p).call(this,t);break;case T.AnnotationEditorParamsType.FREETEXT_COLOR:dt(this,f,m).call(this,t)}}static get defaultPropertiesToUpdate(){return[[T.AnnotationEditorParamsType.FREETEXT_SIZE,R._defaultFontSize],[T.AnnotationEditorParamsType.FREETEXT_COLOR,R._defaultColor||C.AnnotationEditor._defaultLineColor]]}get propertiesToUpdate(){return[[T.AnnotationEditorParamsType.FREETEXT_SIZE,ce(this,c)],[T.AnnotationEditorParamsType.FREETEXT_COLOR,ce(this,o)]]}getInitialTranslation(){let e=this.parentScale;return[-R._internalPadding*e,-(R._internalPadding+ce(this,c))*e]}rebuild(){super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this))}enableEditMode(){this.isInEditMode()||(this.parent.setEditingState(!1),this.parent.updateToolbar(T.AnnotationEditorType.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this.div.draggable=!1,this.div.removeAttribute("aria-activedescendant"),this.editorDiv.addEventListener("keydown",ce(this,s)),this.editorDiv.addEventListener("focus",ce(this,r)),this.editorDiv.addEventListener("blur",ce(this,i)),this.editorDiv.addEventListener("input",ce(this,a)))}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",ce(this,h)),this.div.draggable=!0,this.editorDiv.removeEventListener("keydown",ce(this,s)),this.editorDiv.removeEventListener("focus",ce(this,r)),this.editorDiv.removeEventListener("blur",ce(this,i)),this.editorDiv.removeEventListener("input",ce(this,a)),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freeTextEditing"))}focusin(e){super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus()}onceAdded(){this.width?dt(this,M,E).call(this):(this.enableEditMode(),this.editorDiv.focus())}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent.setEditingState(!0),this.parent.div.classList.add("freeTextEditing"),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let e=ce(this,l),t=St(this,l,dt(this,g,v).call(this).trimEnd());if(e===t)return;let n=e=>{St(this,l,e),e?(dt(this,b,_).call(this),this.rebuild(),dt(this,y,x).call(this)):this.remove()};this.addCommands({cmd:()=>{n(t)},undo:()=>{n(e)},mustExec:!1}),dt(this,y,x).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}dblclick(e){this.enableEditMode(),this.editorDiv.focus()}keydown(e){e.target===this.div&&"Enter"===e.key&&(this.enableEditMode(),this.editorDiv.focus())}editorDivKeydown(e){R._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freeTextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let e,t;this.width&&(e=this.x,t=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",ce(this,h)),this.enableEditing(),R._l10nPromise.get("editor_free_text2_aria_label").then((e=>{var t;return null==(t=this.editorDiv)?void 0:t.setAttribute("aria-label",e)})),R._l10nPromise.get("free_text2_default_content").then((e=>{var t;return null==(t=this.editorDiv)?void 0:t.setAttribute("default-content",e)})),this.editorDiv.contentEditable=!0;let{style:n}=this.editorDiv;if(n.fontSize=`calc(${ce(this,c)}px * var(--scale-factor))`,n.color=ce(this,o),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),(0,A.bindEvents)(this,this.div,["dblclick","keydown"]),this.width){let[n,i]=this.parentDimensions;if(this.annotationElementId){let[r]=this.getInitialTranslation();this.setAt(e*n,t*i,r,r)}else this.setAt(e*n,t*i,this.width*n,this.height*i);dt(this,b,_).call(this),this.div.draggable=!0,this.editorDiv.contentEditable=!1}else this.div.draggable=!1,this.editorDiv.contentEditable=!0;return this.div}get contentDiv(){return this.editorDiv}static deserialize(e,t,n){let i=null;if(e instanceof P.FreeTextAnnotationElement){let{data:{defaultAppearanceData:{fontSize:t,fontColor:n},rect:r,rotation:a,id:s},textContent:o,parent:{page:{pageNumber:l}}}=e;if(!o||0===o.length)return null;i=e={annotationType:T.AnnotationEditorType.FREETEXT,color:Array.from(n),fontSize:t,value:o.join("\n"),pageIndex:l-1,rect:r,rotation:a,id:s,deleted:!1}}let r=super.deserialize(e,t,n);return St(r,c,e.fontSize),St(r,o,T.Util.makeHexColor(...e.color)),St(r,l,e.value),r.annotationElementId=e.id||null,St(r,u,i),r}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};let t=R._internalPadding*this.parentScale,n=this.getRect(t,t),i=C.AnnotationEditor._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:ce(this,o)),r={annotationType:T.AnnotationEditorType.FREETEXT,color:i,fontSize:ce(this,c),value:ce(this,l),pageIndex:this.pageIndex,rect:n,rotation:this.rotation};return e?r:this.annotationElementId&&!dt(this,w,S).call(this,r)?null:(r.id=this.annotationElementId,r)}},O=R;i=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,u=new WeakMap,d=new WeakSet,p=function(e){let t=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--scale-factor))`,this.translate(0,-(e-ce(this,c))*this.parentScale),St(this,c,e),dt(this,y,x).call(this)},n=ce(this,c);this.addCommands({cmd:()=>{t(e)},undo:()=>{t(n)},mustExec:!0,type:T.AnnotationEditorParamsType.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},f=new WeakSet,m=function(e){let t=ce(this,o);this.addCommands({cmd:()=>{St(this,o,this.editorDiv.style.color=e)},undo:()=>{St(this,o,this.editorDiv.style.color=t)},mustExec:!0,type:T.AnnotationEditorParamsType.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},g=new WeakSet,v=function(){let e=this.editorDiv.getElementsByTagName("div");if(0===e.length)return this.editorDiv.innerText;let t=[];for(let n of e)t.push(n.innerText.replace(/\r\n?|\n/,""));return t.join("\n")},y=new WeakSet,x=function(){let e,[t,n]=this.parentDimensions;if(this.isAttachedToDOM)e=this.div.getBoundingClientRect();else{let{currentLayer:t,div:n}=this,i=n.style.display;n.style.display="hidden",t.div.append(this.div),e=n.getBoundingClientRect(),n.remove(),n.style.display=i}this.width=e.width/t,this.height=e.height/n},b=new WeakSet,_=function(){if(this.editorDiv.replaceChildren(),ce(this,l))for(let e of ce(this,l).split("\n")){let t=document.createElement("div");t.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(t)}},w=new WeakSet,S=function(e){let{value:t,fontSize:n,color:i,rect:r,pageIndex:a}=ce(this,u);return e.value!==t||e.fontSize!==n||e.rect.some(((e,t)=>Math.abs(e-r[t])>=1))||e.color.some(((e,t)=>e!==i[t]))||e.pageIndex!==a},M=new WeakSet,E=function(e=!1){if(!this.annotationElementId)return;if(dt(this,y,x).call(this),!e&&(0===this.width||0===this.height))return void setTimeout((()=>dt(this,M,E).call(this,!0)),0);let t=R._internalPadding*this.parentScale;ce(this,u).rect=this.getRect(t,t)},Xi(O,"_freeTextDefaultContent",""),Xi(O,"_l10nPromise"),Xi(O,"_internalPadding",0),Xi(O,"_defaultColor",null),Xi(O,"_defaultFontSize",10),Xi(O,"_type","freetext"),t.FreeTextEditor=O},(e,t,n)=>{var i,r,a,s,o,l,h,c,u,d,p,f,m,g,v,y,x,b,_,w,S,M,E,T,A,C,P,R,O,L,I,D,k,N,F,U,B,z,H;Object.defineProperty(t,"__esModule",{value:!0}),t.InkAnnotationElement=t.FreeTextAnnotationElement=t.AnnotationLayer=void 0;var V=n(1),j=n(6),G=n(3),W=n(30),X=n(31);let Y=1e3,q=new WeakSet;function J(e){return{width:e[2]-e[0],height:e[3]-e[1]}}class Z{static create(e){switch(e.data.annotationType){case V.AnnotationType.LINK:return new $(e);case V.AnnotationType.TEXT:return new Q(e);case V.AnnotationType.WIDGET:switch(e.data.fieldType){case"Tx":return new te(e);case"Btn":return e.data.radioButton?new re(e):e.data.checkBox?new ie(e):new ae(e);case"Ch":return new se(e);case"Sig":return new ne(e)}return new ee(e);case V.AnnotationType.POPUP:return new oe(e);case V.AnnotationType.FREETEXT:return new he(e);case V.AnnotationType.LINE:return new ue(e);case V.AnnotationType.SQUARE:return new de(e);case V.AnnotationType.CIRCLE:return new pe(e);case V.AnnotationType.POLYLINE:return new fe(e);case V.AnnotationType.CARET:return new ge(e);case V.AnnotationType.INK:return new ve(e);case V.AnnotationType.POLYGON:return new me(e);case V.AnnotationType.HIGHLIGHT:return new ye(e);case V.AnnotationType.UNDERLINE:return new xe(e);case V.AnnotationType.SQUIGGLY:return new be(e);case V.AnnotationType.STRIKEOUT:return new _e(e);case V.AnnotationType.STAMP:return new we(e);case V.AnnotationType.FILEATTACHMENT:return new Se(e);default:return new K(e)}}}class K{constructor(e,{isRenderable:t=!1,ignoreBorder:n=!1,createQuadrilaterals:i=!1}={}){this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,t&&(this.container=this._createContainer(n)),i&&(this.quadrilaterals=this._createQuadrilaterals(n))}_createContainer(e){let{data:t,parent:{page:n,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",t.id),r.style.zIndex=this.parent.zIndex++,this.data.popupRef&&r.setAttribute("aria-haspopup","dialog"),t.noRotate&&r.classList.add("norotate");let{pageWidth:a,pageHeight:s,pageX:o,pageY:l}=i.rawDims;if(!t.rect||this instanceof oe){let{rotation:e}=t;return!t.hasOwnCanvas&&0!==e&&this.setRotation(e,r),r}let{width:h,height:c}=J(t.rect),u=V.Util.normalizeRect([t.rect[0],n.view[3]-t.rect[1]+n.view[1],t.rect[2],n.view[3]-t.rect[3]+n.view[1]]);if(!e&&t.borderStyle.width>0){r.style.borderWidth=`${t.borderStyle.width}px`;let e=t.borderStyle.horizontalCornerRadius,n=t.borderStyle.verticalCornerRadius;if(e>0||n>0){let t=`calc(${e}px * var(--scale-factor)) / calc(${n}px * var(--scale-factor))`;r.style.borderRadius=t}else if(this instanceof re){let e=`calc(${h}px * var(--scale-factor)) / calc(${c}px * var(--scale-factor))`;r.style.borderRadius=e}switch(t.borderStyle.style){case V.AnnotationBorderStyleType.SOLID:r.style.borderStyle="solid";break;case V.AnnotationBorderStyleType.DASHED:r.style.borderStyle="dashed";break;case V.AnnotationBorderStyleType.BEVELED:(0,V.warn)("Unimplemented border style: beveled");break;case V.AnnotationBorderStyleType.INSET:(0,V.warn)("Unimplemented border style: inset");break;case V.AnnotationBorderStyleType.UNDERLINE:r.style.borderBottomStyle="solid"}let i=t.borderColor||null;i?r.style.borderColor=V.Util.makeHexColor(0|i[0],0|i[1],0|i[2]):r.style.borderWidth=0}r.style.left=100*(u[0]-o)/a+"%",r.style.top=100*(u[1]-l)/s+"%";let{rotation:d}=t;return t.hasOwnCanvas||0===d?(r.style.width=100*h/a+"%",r.style.height=100*c/s+"%"):this.setRotation(d,r),r}setRotation(e,t=this.container){let n,i,{pageWidth:r,pageHeight:a}=this.parent.viewport.rawDims,{width:s,height:o}=J(this.data.rect);e%180==0?(n=100*s/r,i=100*o/a):(n=100*o/r,i=100*s/a),t.style.width=`${n}%`,t.style.height=`${i}%`,t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){let e=(e,t,n)=>{let i=n.detail[e];n.target.style[t]=W.ColorConverters[`${i[0]}_HTML`](i.slice(1))};return(0,V.shadow)(this,"_commonActions",{display:e=>{let t=e.detail.display%2==1;this.container.style.visibility=t?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{hidden:t,print:0===e.detail.display||3===e.detail.display})},print:e=>{this.annotationStorage.setValue(this.data.id,{print:e.detail.print})},hidden:e=>{this.container.style.visibility=e.detail.hidden?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{hidden:e.detail.hidden})},focus:e=>{setTimeout((()=>e.target.focus({preventScroll:!1})),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.detail.readonly?e.target.setAttribute("readonly",""):e.target.removeAttribute("readonly")},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:t=>{e("bgColor","backgroundColor",t)},fillColor:t=>{e("fillColor","backgroundColor",t)},fgColor:t=>{e("fgColor","color",t)},textColor:t=>{e("textColor","color",t)},borderColor:t=>{e("borderColor","borderColor",t)},strokeColor:t=>{e("strokeColor","borderColor",t)},rotation:e=>{let t=e.detail.rotation;this.setRotation(t),this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){let n=this._commonActions;for(let i of Object.keys(t.detail)){let r=e[i]||n[i];null==r||r(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;let t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;let n=this._commonActions;for(let[i,r]of Object.entries(t)){let a=n[i];a&&(a({detail:{[i]:r},target:e}),delete t[i])}}_createQuadrilaterals(e=!1){if(!this.data.quadPoints)return null;let t=[],n=this.data.rect,i=null;for(let r of this.data.quadPoints)this.data.rect=[r[2].x,r[2].y,r[1].x,r[1].y],t.push(this._createContainer(e)),i||(i=this.data.rect);return this.data.rect=n,this.firstQuadRect=i,t}_createPopup(){let{container:e,data:t}=this;e.setAttribute("aria-haspopup","dialog");let n=new oe({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:this.firstQuadRect||t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(n.render())}_renderQuadrilaterals(e){for(let t of this.quadrilaterals)t.classList.add(e);return this.quadrilaterals}render(){(0,V.unreachable)("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){let n=[];if(this._fieldObjects){let i=this._fieldObjects[e];if(i)for(let{page:e,id:r,exportValues:a}of i){if(-1===e||r===t)continue;let i="string"==typeof a?a:null,s=document.querySelector(`[data-element-id="${r}"]`);!s||q.has(s)?n.push({id:r,exportValue:i,domElement:s}):(0,V.warn)(`_getElementsByName - element not allowed: ${r}`)}return n}for(let i of document.getElementsByName(e)){let{exportValue:e}=i,r=i.getAttribute("data-element-id");r!==t&&q.has(i)&&n.push({id:r,exportValue:e,domElement:i})}return n}show(){var e;this.container&&(this.container.hidden=!1),null==(e=this.popup)||e.maybeShow()}hide(){var e;this.container&&(this.container.hidden=!0),null==(e=this.popup)||e.forceHide()}getElementsToTriggerPopup(){return this.quadrilaterals||this.container}addHighlightArea(){let e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(let t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}}class $ extends K{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!(null==t||!t.ignoreBorder),createQuadrilaterals:!0}),Je(this,i),Je(this,a),this.isTooltipOnly=e.data.isTooltipOnly}render(){let{data:e,linkService:t}=this,n=document.createElement("a");n.setAttribute("data-element-id",e.id);let i=!1;return e.url?(t.addLinkAttributes(n,e.url,e.newWindow),i=!0):e.action?(this._bindNamedAction(n,e.action),i=!0):e.attachment?(this._bindAttachment(n,e.attachment),i=!0):e.setOCGState?(dt(this,a,s).call(this,n,e.setOCGState),i=!0):e.dest?(this._bindLink(n,e.dest),i=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),i=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(n,""),i=!0)),this.quadrilaterals?this._renderQuadrilaterals("linkAnnotation").map(((e,t)=>{let i=0===t?n:n.cloneNode();return e.append(i),e})):(this.container.classList.add("linkAnnotation"),i&&this.container.append(n),this.container)}_bindLink(e,t){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.goToDestination(t),!1),(t||""===t)&&dt(this,i,r).call(this)}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),dt(this,i,r).call(this)}_bindAttachment(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>{var e;return null==(e=this.downloadManager)||e.openOrDownloadData(this.container,t.content,t.filename),!1},dt(this,i,r).call(this)}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl("");let n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let i of Object.keys(t.actions)){let r=n.get(i);r&&(e[r]=()=>{var e;return null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t.id,name:i}}),!1})}e.onclick||(e.onclick=()=>!1),dt(this,i,r).call(this)}_bindResetFormAction(e,t){let n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl("")),dt(this,i,r).call(this),!this._fieldObjects)return(0,V.warn)('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(n||(e.onclick=()=>!1));e.onclick=()=>{var e;null==n||n();let{fields:i,refs:r,include:a}=t,s=[];if(0!==i.length||0!==r.length){let e=new Set(r);for(let t of i){let n=this._fieldObjects[t]||[];for(let{id:t}of n)e.add(t)}for(let t of Object.values(this._fieldObjects))for(let n of t)e.has(n.id)===a&&s.push(n)}else for(let t of Object.values(this._fieldObjects))s.push(...t);let o=this.annotationStorage,l=[];for(let t of s){let{id:e}=t;switch(l.push(e),t.type){case"text":{let n=t.defaultValue||"";o.setValue(e,{value:n});break}case"checkbox":case"radiobutton":{let n=t.defaultValue===t.exportValues;o.setValue(e,{value:n});break}case"combobox":case"listbox":{let n=t.defaultValue||"";o.setValue(e,{value:n});break}default:continue}let n=document.querySelector(`[data-element-id="${e}"]`);n&&(q.has(n)?n.dispatchEvent(new Event("resetform")):(0,V.warn)(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&(null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:l,name:"ResetForm"}})),!1}}}i=new WeakSet,r=function(){this.container.setAttribute("data-internal-link","")},a=new WeakSet,s=function(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(t),!1),dt(this,i,r).call(this)};class Q extends K{constructor(e){var t,n,i;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(n=e.data.contentsObj)&&n.str||null!=(i=e.data.richText)&&i.str)})}render(){this.container.classList.add("textAnnotation");let e=document.createElement("img");return e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.alt="[{{type}} Annotation]",e.dataset.l10nId="text_annotation_type",e.dataset.l10nArgs=JSON.stringify({type:this.data.name}),this.data.popupRef||this._createPopup(),this.container.append(e),this.container}}class ee extends K{render(){return this.data.alternativeText&&(this.container.title=this.data.alternativeText),this.container}showElementAndHideCanvas(e){var t;this.data.hasOwnCanvas&&("CANVAS"===(null==(t=e.previousSibling)?void 0:t.nodeName)&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){let{isWin:t,isMac:n}=V.FeatureTest.platform;return t&&e.ctrlKey||n&&e.metaKey}_setEventListener(e,t,n,i){t.includes("mouse")?e.addEventListener(t,(e=>{var t;null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:i(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})})):e.addEventListener(t,(e=>{var t;null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:i(e)}})}))}_setEventListeners(e,t,n){var i;for(let[r,a]of t)("Action"===a||null!=(i=this.data.actions)&&i[a])&&this._setEventListener(e,r,a,n)}_setBackgroundColor(e){let t=this.data.backgroundColor||null;e.style.backgroundColor=null===t?"transparent":V.Util.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){let t,{fontColor:n}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||9,r=e.style,a=e=>Math.round(10*e)/10;if(this.data.multiLine){let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),n=e/(Math.round(e/(V.LINE_FACTOR*i))||1);t=Math.min(i,a(n/V.LINE_FACTOR))}else{let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);t=Math.min(i,a(e/V.LINE_FACTOR))}r.fontSize=`calc(${t}px * var(--scale-factor))`,r.color=V.Util.makeHexColor(n[0],n[1],n[2]),null!==this.data.textAlignment&&(r.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",t)}}class te extends ee{constructor(e){super(e,{isRenderable:e.renderForms||!e.data.hasAppearance&&!!e.data.fieldValue})}setPropertyOnSiblings(e,t,n,i){let r=this.annotationStorage;for(let a of this._getElementsByName(e.name,e.id))a.domElement&&(a.domElement[t]=n),r.setValue(a.id,{[i]:n})}render(){var e,t;let n=this.annotationStorage,i=this.data.id;this.container.classList.add("textWidgetAnnotation");let r=null;if(this.renderForms){let a=n.getValue(i,{value:this.data.fieldValue}),s=a.value||"",o=n.getValue(i,{charLimit:this.data.maxLen}).charLimit;o&&s.length>o&&(s=s.slice(0,o));let l=a.formattedValue||(null==(e=this.data.textContent)?void 0:e.join("\n"))||null;l&&this.data.comb&&(l=l.replaceAll(/\s+/g,""));let h={userValue:s,formattedValue:l,lastCommittedValue:null,commitKey:1};this.data.multiLine?(r=document.createElement("textarea"),r.textContent=null!=l?l:s,this.data.doNotScroll&&(r.style.overflowY="hidden")):(r=document.createElement("input"),r.type="text",r.setAttribute("value",null!=l?l:s),this.data.doNotScroll&&(r.style.overflowX="hidden")),this.data.hasOwnCanvas&&(r.hidden=!0),q.add(r),r.setAttribute("data-element-id",i),r.disabled=this.data.readOnly,r.name=this.data.baseFieldName||this.data.fieldName,r.tabIndex=Y,this._setRequired(r,this.data.required),o&&(r.maxLength=o),r.addEventListener("input",(e=>{n.setValue(i,{value:e.target.value}),this.setPropertyOnSiblings(r,"value",e.target.value,"value"),h.formattedValue=null})),r.addEventListener("resetform",(e=>{var t;let n=null!=(t=this.data.defaultFieldValue)?t:"";r.value=h.userValue=n,h.formattedValue=null}));let c=e=>{let{formattedValue:t}=h;null!=t&&(e.target.value=t),e.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){r.addEventListener("focus",(e=>{let{target:t}=e;h.userValue&&(t.value=h.userValue),h.lastCommittedValue=t.value,h.commitKey=1})),r.addEventListener("updatefromsandbox",(e=>{this.showElementAndHideCanvas(e.target);let t={value(e){var t;h.userValue=null!=(t=e.detail.value)?t:"",n.setValue(i,{value:h.userValue.toString()}),e.target.value=h.userValue},formattedValue(e){let{formattedValue:t}=e.detail;h.formattedValue=t,null!=t&&e.target!==document.activeElement&&(e.target.value=t),n.setValue(i,{formattedValue:t})},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:e=>{var t;let{charLimit:r}=e.detail,{target:a}=e;if(0===r)return void a.removeAttribute("maxLength");a.setAttribute("maxLength",r);let s=h.userValue;!s||s.length<=r||(s=s.slice(0,r),a.value=h.userValue=s,n.setValue(i,{value:s}),null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:s,willCommit:!0,commitKey:1,selStart:a.selectionStart,selEnd:a.selectionEnd}}))}};this._dispatchEventFromSandbox(t,e)})),r.addEventListener("keydown",(e=>{var t;h.commitKey=1;let n=-1;if("Escape"===e.key?n=0:"Enter"!==e.key||this.data.multiLine?"Tab"===e.key&&(h.commitKey=3):n=2,-1===n)return;let{value:r}=e.target;h.lastCommittedValue!==r&&(h.lastCommittedValue=r,h.userValue=r,null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:r,willCommit:!0,commitKey:n,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}))}));let e=c;c=null,r.addEventListener("blur",(t=>{var n;if(!t.relatedTarget)return;let{value:r}=t.target;h.userValue=r,h.lastCommittedValue!==r&&(null==(n=this.linkService.eventBus)||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:r,willCommit:!0,commitKey:h.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}})),e(t)})),null!=(t=this.data.actions)&&t.Keystroke&&r.addEventListener("beforeinput",(e=>{var t;h.lastCommittedValue=null;let{data:n,target:r}=e,{value:a,selectionStart:s,selectionEnd:o}=r,l=s,c=o;switch(e.inputType){case"deleteWordBackward":{let e=a.substring(0,s).match(/\w*[^\w]*$/);e&&(l-=e[0].length);break}case"deleteWordForward":{let e=a.substring(s).match(/^[^\w]*\w*/);e&&(c+=e[0].length);break}case"deleteContentBackward":s===o&&(l-=1);break;case"deleteContentForward":s===o&&(c+=1)}e.preventDefault(),null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:a,change:n||"",willCommit:!1,selStart:l,selEnd:c}})})),this._setEventListeners(r,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.value))}if(c&&r.addEventListener("blur",c),this.data.comb){let e=(this.data.rect[2]-this.data.rect[0])/o;r.classList.add("comb"),r.style.letterSpacing=`calc(${e}px * var(--scale-factor) - 1ch)`}}else r=document.createElement("div"),r.textContent=this.data.fieldValue,r.style.verticalAlign="middle",r.style.display="table-cell";return this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class ne extends ee{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class ie extends ee{constructor(e){super(e,{isRenderable:e.renderForms})}render(){let e=this.annotationStorage,t=this.data,n=t.id,i=e.getValue(n,{value:t.exportValue===t.fieldValue}).value;"string"==typeof i&&(i="Off"!==i,e.setValue(n,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let r=document.createElement("input");return q.add(r),r.setAttribute("data-element-id",n),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=t.baseFieldName||t.fieldName,i&&r.setAttribute("checked",!0),r.setAttribute("exportValue",t.exportValue),r.tabIndex=Y,r.addEventListener("change",(i=>{let{name:r,checked:a}=i.target;for(let s of this._getElementsByName(r,n)){let n=a&&s.exportValue===t.exportValue;s.domElement&&(s.domElement.checked=n),e.setValue(s.id,{value:n})}e.setValue(n,{value:a})})),r.addEventListener("resetform",(e=>{let n=t.defaultFieldValue||"Off";e.target.checked=n===t.exportValue})),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",(t=>{let i={value(t){t.target.checked="Off"!==t.detail.value,e.setValue(n,{value:t.target.checked})}};this._dispatchEventFromSandbox(i,t)})),this._setEventListeners(r,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.checked))),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class re extends ee{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let e=this.annotationStorage,t=this.data,n=t.id,i=e.getValue(n,{value:t.fieldValue===t.buttonValue}).value;"string"==typeof i&&(i=i!==t.buttonValue,e.setValue(n,{value:i}));let r=document.createElement("input");if(q.add(r),r.setAttribute("data-element-id",n),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=t.baseFieldName||t.fieldName,i&&r.setAttribute("checked",!0),r.tabIndex=Y,r.addEventListener("change",(t=>{let{name:i,checked:r}=t.target;for(let a of this._getElementsByName(i,n))e.setValue(a.id,{value:!1});e.setValue(n,{value:r})})),r.addEventListener("resetform",(e=>{let n=t.defaultFieldValue;e.target.checked=null!=n&&n===t.buttonValue})),this.enableScripting&&this.hasJSActions){let i=t.buttonValue;r.addEventListener("updatefromsandbox",(t=>{let r={value:t=>{let r=i===t.detail.value;for(let i of this._getElementsByName(t.target.name)){let t=r&&i.id===n;i.domElement&&(i.domElement.checked=t),e.setValue(i.id,{value:t})}}};this._dispatchEventFromSandbox(r,t)})),this._setEventListeners(r,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.checked))}return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class ae extends ${constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){let e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton"),this.data.alternativeText&&(e.title=this.data.alternativeText);let t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({},e)}))),e}}class se extends ee{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let e=this.annotationStorage,t=this.data.id,n=e.getValue(t,{value:this.data.fieldValue}),i=document.createElement("select");q.add(i),i.setAttribute("data-element-id",t),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.baseFieldName||this.data.fieldName,i.tabIndex=Y;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",(e=>{let t=this.data.defaultFieldValue;for(let n of i.options)n.selected=n.value===t}));for(let h of this.data.options){let e=document.createElement("option");e.textContent=h.displayValue,e.value=h.exportValue,n.value.includes(h.exportValue)&&(e.setAttribute("selected",!0),r=!1),i.append(e)}let a=null;if(r){let e=document.createElement("option");e.value=" ",e.setAttribute("hidden",!0),e.setAttribute("selected",!0),i.prepend(e),a=()=>{e.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}let s=e=>{let t=e?"value":"textContent",{options:n,multiple:r}=i;return r?Array.prototype.filter.call(n,(e=>e.selected)).map((e=>e[t])):-1===n.selectedIndex?null:n[n.selectedIndex][t]},o=s(!1),l=e=>{let t=e.target.options;return Array.prototype.map.call(t,(e=>({displayValue:e.textContent,exportValue:e.value})))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",(n=>{let r={value(n){null==a||a();let r=n.detail.value,l=new Set(Array.isArray(r)?r:[r]);for(let e of i.options)e.selected=l.has(e.value);e.setValue(t,{value:s(!0)}),o=s(!1)},multipleSelection(e){i.multiple=!0},remove(n){let r=i.options,a=n.detail.remove;r[a].selected=!1,i.remove(a),r.length>0&&-1===Array.prototype.findIndex.call(r,(e=>e.selected))&&(r[0].selected=!0),e.setValue(t,{value:s(!0),items:l(n)}),o=s(!1)},clear(n){for(;0!==i.length;)i.remove(0);e.setValue(t,{value:null,items:[]}),o=s(!1)},insert(n){let{index:r,displayValue:a,exportValue:h}=n.detail.insert,c=i.children[r],u=document.createElement("option");u.textContent=a,u.value=h,c?c.before(u):i.append(u),e.setValue(t,{value:s(!0),items:l(n)}),o=s(!1)},items(n){let{items:r}=n.detail;for(;0!==i.length;)i.remove(0);for(let e of r){let{displayValue:t,exportValue:n}=e,r=document.createElement("option");r.textContent=t,r.value=n,i.append(r)}i.options.length>0&&(i.options[0].selected=!0),e.setValue(t,{value:s(!0),items:l(n)}),o=s(!1)},indices(n){let i=new Set(n.detail.indices);for(let e of n.target.options)e.selected=i.has(e.index);e.setValue(t,{value:s(!0)}),o=s(!1)},editable(e){e.target.disabled=!e.detail.editable}};this._dispatchEventFromSandbox(r,n)})),i.addEventListener("input",(n=>{var i;let r=s(!0);e.setValue(t,{value:r}),n.preventDefault(),null==(i=this.linkService.eventBus)||i.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:o,changeEx:r,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(i,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(e=>e.target.value))):i.addEventListener("input",(function(n){e.setValue(t,{value:s(!0)})})),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class oe extends K{constructor(e){var t,n,i;let{data:r,elements:a}=e;super(e,{isRenderable:!!(null!=(t=r.titleObj)&&t.str||null!=(n=r.contentsObj)&&n.str||null!=(i=r.richText)&&i.str)}),this.elements=a}render(){this.container.classList.add("popupAnnotation");let e=new le({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),t=[];for(let n of this.elements)n.popup=e,t.push(n.data.id),n.addHighlightArea();return this.container.setAttribute("aria-controls",t.join(",")),this.container}}class le{constructor({container:e,color:t,elements:n,titleObj:i,modificationDate:r,contentsObj:a,richText:s,parent:P,rect:R,parentRect:O,open:L}){Je(this,S),Je(this,E),Je(this,A),Je(this,o,null),Je(this,l,dt(this,A,C).bind(this)),Je(this,h,dt(this,E,T).bind(this)),Je(this,c,dt(this,S,M).bind(this)),Je(this,u,null),Je(this,d,null),Je(this,p,null),Je(this,f,null),Je(this,m,null),Je(this,g,null),Je(this,v,!1),Je(this,y,null),Je(this,x,null),Je(this,b,null),Je(this,_,null),Je(this,w,!1),St(this,d,e),St(this,_,i),St(this,p,a),St(this,b,s),St(this,m,P),St(this,u,t),St(this,x,R),St(this,g,O),St(this,f,n);let I=j.PDFDateString.toDateObject(r);I&&St(this,o,P.l10n.get("annotation_date_string",{date:I.toLocaleDateString(),time:I.toLocaleTimeString()})),this.trigger=n.flatMap((e=>e.getElementsToTriggerPopup()));for(let o of this.trigger)o.addEventListener("click",ce(this,c)),o.addEventListener("mouseenter",ce(this,h)),o.addEventListener("mouseleave",ce(this,l));ce(this,d).hidden=!0,L&&dt(this,S,M).call(this)}render(){if(ce(this,y))return;let{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:n,pageX:i,pageY:r}}}=ce(this,m),a=St(this,y,document.createElement("div"));if(a.className="popup",ce(this,u)){let e=a.style.outlineColor=V.Util.makeHexColor(...ce(this,u));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?a.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`:a.style.backgroundColor=V.Util.makeHexColor(...ce(this,u).map((e=>Math.floor(.7*(255-e)+e))))}let s=document.createElement("span");s.className="header";let l=document.createElement("h1");if(s.append(l),({dir:l.dir,str:l.textContent}=ce(this,_)),a.append(s),ce(this,o)){let e=document.createElement("span");e.classList.add("popupDate"),ce(this,o).then((t=>{e.textContent=t})),s.append(e)}let h=ce(this,p),c=ce(this,b);if(null==c||!c.str||null!=h&&h.str&&h.str!==c.str){let e=this._formatContents(h);a.append(e)}else X.XfaLayer.render({xfaHtml:c.html,intent:"richText",div:a}),a.lastChild.classList.add("richText","popupContent");let v=!!ce(this,g),w=ce(this,v?g:x);for(let o of ce(this,f))if(!w||null!==V.Util.intersect(o.data.rect,w)){w=o.data.rect,v=!0;break}let S=V.Util.normalizeRect([w[0],e[3]-w[1]+e[1],w[2],e[3]-w[3]+e[1]]),M=v?w[2]-w[0]+5:0,E=S[0]+M,T=S[1],{style:A}=ce(this,d);A.left=100*(E-i)/t+"%",A.top=100*(T-r)/n+"%",ce(this,d).append(a)}_formatContents({str:e,dir:t}){let n=document.createElement("p");n.classList.add("popupContent"),n.dir=t;let i=e.split(/(?:\r\n?|\n)/);for(let r=0,a=i.length;r0&&ce(this,F).set(n.data.id,n);let a=n.render();if(e.hidden&&(a.style.visibility="hidden"),Array.isArray(a))for(let i of a)dt(this,U,B).call(this,i,e.id);else dt(this,U,B).call(this,a,e.id)}dt(this,z,H).call(this),yield this.l10n.translate(n)}))}update({viewport:e}){let t=this.div;this.viewport=e,(0,j.setLayerDimensions)(t,{rotation:e.rotation}),dt(this,z,H).call(this),t.hidden=!1}getEditableAnnotations(){return Array.from(ce(this,F).values())}getEditableAnnotation(e){return ce(this,F).get(e)}}},(e,t)=>{function n(e){return Math.floor(255*Math.max(0,Math.min(1,e))).toString(16).padStart(2,"0")}Object.defineProperty(t,"__esModule",{value:!0}),t.ColorConverters=void 0,t.ColorConverters=class{static CMYK_G([e,t,n,i]){return["G",1-Math.min(1,.3*e+.59*n+.11*t+i)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_HTML([e]){let t=n(e);return`#${t}${t}${t}`}static RGB_G([e,t,n]){return["G",.3*e+.59*t+.11*n]}static RGB_HTML([e,t,i]){return`#${n(e)}${n(t)}${n(i)}`}static T_HTML(){return"#00000000"}static CMYK_RGB([e,t,n,i]){return["RGB",1-Math.min(1,e+i),1-Math.min(1,n+i),1-Math.min(1,t+i)]}static CMYK_HTML(e){let t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,n]){let i=1-e,r=1-t,a=1-n;return["CMYK",i,r,a,Math.min(i,r,a)]}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XfaLayer=void 0;var i=n(19);t.XfaLayer=class{static setupStorage(e,t,n,i,r){let a=i.getValue(t,{value:null});switch(n.name){case"textarea":if(null!==a.value&&(e.textContent=a.value),"print"===r)break;e.addEventListener("input",(e=>{i.setValue(t,{value:e.target.value})}));break;case"input":if("radio"===n.attributes.type||"checkbox"===n.attributes.type){if(a.value===n.attributes.xfaOn?e.setAttribute("checked",!0):a.value===n.attributes.xfaOff&&e.removeAttribute("checked"),"print"===r)break;e.addEventListener("change",(e=>{i.setValue(t,{value:e.target.checked?e.target.getAttribute("xfaOn"):e.target.getAttribute("xfaOff")})}))}else{if(null!==a.value&&e.setAttribute("value",a.value),"print"===r)break;e.addEventListener("input",(e=>{i.setValue(t,{value:e.target.value})}))}break;case"select":if(null!==a.value)for(let e of n.children)e.attributes.value===a.value&&(e.attributes.selected=!0);e.addEventListener("input",(e=>{let n=e.target.options,r=-1===n.selectedIndex?"":n[n.selectedIndex].value;i.setValue(t,{value:r})}))}}static setAttributes({html:e,element:t,storage:n=null,intent:i,linkService:r}){let{attributes:a}=t,s=e instanceof HTMLAnchorElement;"radio"===a.type&&(a.name=`${a.name}-${i}`);for(let[o,l]of Object.entries(a))if(null!=l)switch(o){case"class":l.length&&e.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",l);break;case"style":Object.assign(e.style,l);break;case"textContent":e.textContent=l;break;default:(!s||"href"!==o&&"newWindow"!==o)&&e.setAttribute(o,l)}s&&r.addLinkAttributes(e,a.href,a.newWindow),n&&a.dataId&&this.setupStorage(e,a.dataId,t,n)}static render(e){var t;let n=e.annotationStorage,r=e.linkService,a=e.xfaHtml,s=e.intent||"display",o=document.createElement(a.name);a.attributes&&this.setAttributes({html:o,element:a,intent:s,linkService:r});let l=[[a,-1,o]],h=e.div;if(h.append(o),e.viewport){let t=`matrix(${e.viewport.transform.join(",")})`;h.style.transform=t}"richText"!==s&&h.setAttribute("class","xfaLayer xfaFont");let c=[];for(;l.length>0;){let[e,a,o]=l.at(-1);if(a+1===e.children.length){l.pop();continue}let h=e.children[++l.at(-1)[1]];if(null===h)continue;let u,{name:d}=h;if("#text"!==d){if(u=null!=(t=null==h?void 0:h.attributes)&&t.xmlns?document.createElementNS(h.attributes.xmlns,d):document.createElement(d),o.append(u),h.attributes&&this.setAttributes({html:u,element:h,storage:n,intent:s,linkService:r}),h.children&&h.children.length>0)l.push([h,-1,u]);else if(h.value){let e=document.createTextNode(h.value);i.XfaText.shouldBuildText(d)&&c.push(e),u.append(e)}}else{let e=document.createTextNode(h.value);c.push(e),o.append(e)}}for(let i of h.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))i.setAttribute("readOnly",!0);return{textDivs:c}}static update(e){let t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t,e.div.hidden=!1}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NullL10n=void 0,t.getL10nFallback=i;let n={of_pages:"of {{pagesCount}}",page_of_pages:"({{pageNumber}} of {{pagesCount}})",document_properties_kb:"{{size_kb}} KB ({{size_b}} bytes)",document_properties_mb:"{{size_mb}} MB ({{size_b}} bytes)",document_properties_date_string:"{{date}}, {{time}}",document_properties_page_size_unit_inches:"in",document_properties_page_size_unit_millimeters:"mm",document_properties_page_size_orientation_portrait:"portrait",document_properties_page_size_orientation_landscape:"landscape",document_properties_page_size_name_a3:"A3",document_properties_page_size_name_a4:"A4",document_properties_page_size_name_letter:"Letter",document_properties_page_size_name_legal:"Legal",document_properties_page_size_dimension_string:"{{width}} \xd7 {{height}} {{unit}} ({{orientation}})",document_properties_page_size_dimension_name_string:"{{width}} \xd7 {{height}} {{unit}} ({{name}}, {{orientation}})",document_properties_linearized_yes:"Yes",document_properties_linearized_no:"No",additional_layers:"Additional Layers",page_landmark:"Page {{page}}",thumb_page_title:"Page {{page}}",thumb_page_canvas:"Thumbnail of Page {{page}}",find_reached_top:"Reached top of document, continued from bottom",find_reached_bottom:"Reached end of document, continued from top","find_match_count[one]":"{{current}} of {{total}} match","find_match_count[other]":"{{current}} of {{total}} matches","find_match_count_limit[one]":"More than {{limit}} match","find_match_count_limit[other]":"More than {{limit}} matches",find_not_found:"Phrase not found",page_scale_width:"Page Width",page_scale_fit:"Page Fit",page_scale_auto:"Automatic Zoom",page_scale_actual:"Actual Size",page_scale_percent:"{{scale}}%",loading_error:"An error occurred while loading the PDF.",invalid_file_error:"Invalid or corrupted PDF file.",missing_file_error:"Missing PDF file.",unexpected_response_error:"Unexpected server response.",rendering_error:"An error occurred while rendering the page.",annotation_date_string:"{{date}}, {{time}}",printing_not_supported:"Warning: Printing is not fully supported by this browser.",printing_not_ready:"Warning: The PDF is not fully loaded for printing.",web_fonts_disabled:"Web fonts are disabled: unable to use embedded PDF fonts.",free_text2_default_content:"Start typing\u2026",editor_free_text2_aria_label:"Text Editor",editor_ink2_aria_label:"Draw Editor",editor_ink_canvas_aria_label:"User-created image"};function i(e,t){switch(e){case"find_match_count":e=`find_match_count[${1===t.total?"one":"other"}]`;break;case"find_match_count_limit":e=`find_match_count_limit[${1===t.limit?"one":"other"}]`}return n[e]||""}n.print_progress_percent="{{progress}}%";let r={getLanguage(){return ft(this,null,(function*(){return"en-us"}))},getDirection(){return ft(this,null,(function*(){return"ltr"}))},get(e){return ft(this,arguments,(function*(e,t=null,n=i(e,t)){return function(e,t){return t?e.replaceAll(/\{\{\s*(\w+)\s*\}\}/g,((e,n)=>n in t?t[n]:"{{"+n+"}}")):e}(n,t)}))},translate(e){return ft(this,null,(function*(){}))}};t.NullL10n=r},(e,t,n)=>{var i,r,a,s,o,l,h,c,u,d,p,f,m,g,v,y,x,b,_,w,S,M,E,T,A,C,P,R,O,L,I,D,k,N,F,U,B,z,H,V,j,G,W,X,Y,q,J,Z,K,$,Q,ee,te,ne,ie,re,ae,se,oe,le,he,ue,de,pe,fe,me,ge,ve,ye,xe;Object.defineProperty(t,"__esModule",{value:!0}),t.InkEditor=void 0;var be=n(1),_e=n(4),we=n(29),Se=n(5);let Me=16,Ee=class extends _e.AnnotationEditor{constructor(e){super(Ri(wr({},e),{name:"inkEditor"})),Je(this,x),Je(this,_),Je(this,S),Je(this,E),Je(this,A),Je(this,P),Je(this,O),Je(this,I),Je(this,k),Je(this,F),Je(this,B),Je(this,H),Je(this,j),Je(this,W),Je(this,Y),Je(this,J),Je(this,K),Je(this,Q),Je(this,te),Je(this,he),Je(this,de),Je(this,fe),Je(this,ge),Je(this,ye),Je(this,i,0),Je(this,r,0),Je(this,a,0),Je(this,s,this.canvasContextMenu.bind(this)),Je(this,o,this.canvasPointermove.bind(this)),Je(this,l,this.canvasPointerleave.bind(this)),Je(this,h,this.canvasPointerup.bind(this)),Je(this,c,this.canvasPointerdown.bind(this)),Je(this,u,new Path2D),Je(this,d,!1),Je(this,p,!1),Je(this,f,!1),Je(this,m,null),Je(this,g,0),Je(this,v,0),Je(this,y,null),this.color=e.color||null,this.thickness=e.thickness||null,this.opacity=e.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0}static initialize(e){this._l10nPromise=new Map(["editor_ink_canvas_aria_label","editor_ink2_aria_label"].map((t=>[t,e.get(t)])))}static updateDefaultParams(e,t){switch(e){case be.AnnotationEditorParamsType.INK_THICKNESS:Ee._defaultThickness=t;break;case be.AnnotationEditorParamsType.INK_COLOR:Ee._defaultColor=t;break;case be.AnnotationEditorParamsType.INK_OPACITY:Ee._defaultOpacity=t/100}}updateParams(e,t){switch(e){case be.AnnotationEditorParamsType.INK_THICKNESS:dt(this,x,b).call(this,t);break;case be.AnnotationEditorParamsType.INK_COLOR:dt(this,_,w).call(this,t);break;case be.AnnotationEditorParamsType.INK_OPACITY:dt(this,S,M).call(this,t)}}static get defaultPropertiesToUpdate(){return[[be.AnnotationEditorParamsType.INK_THICKNESS,Ee._defaultThickness],[be.AnnotationEditorParamsType.INK_COLOR,Ee._defaultColor||_e.AnnotationEditor._defaultLineColor],[be.AnnotationEditorParamsType.INK_OPACITY,Math.round(100*Ee._defaultOpacity)]]}get propertiesToUpdate(){var e;return[[be.AnnotationEditorParamsType.INK_THICKNESS,this.thickness||Ee._defaultThickness],[be.AnnotationEditorParamsType.INK_COLOR,this.color||Ee._defaultColor||_e.AnnotationEditor._defaultLineColor],[be.AnnotationEditorParamsType.INK_OPACITY,Math.round(100*(null!=(e=this.opacity)?e:Ee._defaultOpacity))]]}rebuild(){super.rebuild(),null!==this.div&&(this.canvas||(dt(this,Y,q).call(this),dt(this,J,Z).call(this)),this.isAttachedToDOM||(this.parent.add(this),dt(this,K,$).call(this)),dt(this,ge,ve).call(this))}remove(){null!==this.canvas&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,ce(this,m).disconnect(),St(this,m,null),super.remove())}setParent(e){!this.parent&&e?this._uiManager.removeShouldRescale(this):this.parent&&null===e&&this._uiManager.addShouldRescale(this),super.setParent(e)}onScaleChanging(){let[e,t]=this.parentDimensions,n=this.width*e,i=this.height*t;this.setDimensions(n,i)}enableEditMode(){ce(this,d)||null===this.canvas||(super.enableEditMode(),this.div.draggable=!1,this.canvas.addEventListener("pointerdown",ce(this,c)))}disableEditMode(){!this.isInEditMode()||null===this.canvas||(super.disableEditMode(),this.div.draggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",ce(this,c)))}onceAdded(){this.div.draggable=!this.isEmpty()}isEmpty(){return 0===this.paths.length||1===this.paths.length&&0===this.paths[0].length}commit(){ce(this,d)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),St(this,d,!0),this.div.classList.add("disabled"),dt(this,ge,ve).call(this,!0),this.parent.addInkEditorIfNeeded(!0),this.parent.moveEditorInDOM(this),this.div.focus({preventScroll:!0}))}focusin(e){super.focusin(e),this.enableEditMode()}canvasPointerdown(e){0!==e.button||!this.isInEditMode()||ce(this,d)||(this.setInForeground(),e.preventDefault(),"mouse"!==e.type&&this.div.focus(),dt(this,P,R).call(this,e.offsetX,e.offsetY))}canvasContextMenu(e){e.preventDefault()}canvasPointermove(e){e.preventDefault(),dt(this,O,L).call(this,e.offsetX,e.offsetY)}canvasPointerup(e){e.preventDefault(),dt(this,W,X).call(this,e)}canvasPointerleave(e){dt(this,W,X).call(this,e)}render(){if(this.div)return this.div;let e,t;this.width&&(e=this.x,t=this.y),super.render(),Ee._l10nPromise.get("editor_ink2_aria_label").then((e=>{var t;return null==(t=this.div)?void 0:t.setAttribute("aria-label",e)}));let[n,i,r,a]=dt(this,E,T).call(this);if(this.setAt(n,i,0,0),this.setDims(r,a),dt(this,Y,q).call(this),this.width){let[n,i]=this.parentDimensions;this.setAt(e*n,t*i,this.width*n,this.height*i),St(this,f,!0),dt(this,K,$).call(this),this.setDims(this.width*n,this.height*i),dt(this,j,G).call(this),dt(this,ye,xe).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return dt(this,J,Z).call(this),this.div}setDimensions(e,t){let n=Math.round(e),r=Math.round(t);if(ce(this,g)===n&&ce(this,v)===r)return;St(this,g,n),St(this,v,r),this.canvas.style.visibility="hidden",ce(this,i)&&Math.abs(ce(this,i)-e/t)>.01&&(t=Math.ceil(e/ce(this,i)),this.setDims(e,t));let[a,s]=this.parentDimensions;this.width=e/a,this.height=t/s,ce(this,d)&&dt(this,Q,ee).call(this,e,t),dt(this,K,$).call(this),dt(this,j,G).call(this),this.canvas.style.visibility="visible",this.fixDims()}static deserialize(e,t,n){var s,o,l;if(e instanceof we.InkAnnotationElement)return null;let h=super.deserialize(e,t,n);h.thickness=e.thickness,h.color=be.Util.makeHexColor(...e.color),h.opacity=e.opacity;let[c,u]=h.pageDimensions,p=h.width*c,f=h.height*u,m=h.parentScale,y=e.thickness/2;St(h,i,p/f),St(h,d,!0),St(h,g,Math.round(p)),St(h,v,Math.round(f));let{paths:x,rect:b,rotation:_}=e;for(let{bezier:i}of x){i=dt(s=Ee,oe,le).call(s,i,b,_);let e=[];h.paths.push(e);let t=m*(i[0]-y),n=m*(i[1]-y);for(let a=2,s=i.length;a{this.thickness=e,dt(this,ge,ve).call(this)},undo:()=>{this.thickness=t,dt(this,ge,ve).call(this)},mustExec:!0,type:be.AnnotationEditorParamsType.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},_=new WeakSet,w=function(e){let t=this.color;this.addCommands({cmd:()=>{this.color=e,dt(this,j,G).call(this)},undo:()=>{this.color=t,dt(this,j,G).call(this)},mustExec:!0,type:be.AnnotationEditorParamsType.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},S=new WeakSet,M=function(e){e/=100;let t=this.opacity;this.addCommands({cmd:()=>{this.opacity=e,dt(this,j,G).call(this)},undo:()=>{this.opacity=t,dt(this,j,G).call(this)},mustExec:!0,type:be.AnnotationEditorParamsType.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},E=new WeakSet,T=function(){let{parentRotation:e,parentDimensions:[t,n]}=this;switch(e){case 90:return[0,n,n,t];case 180:return[t,n,t,n];case 270:return[t,0,n,t];default:return[0,0,t,n]}},A=new WeakSet,C=function(){let{ctx:e,color:t,opacity:n,thickness:i,parentScale:r,scaleFactor:a}=this;e.lineWidth=i*r/a,e.lineCap="round",e.lineJoin="round",e.miterLimit=10,e.strokeStyle=`${t}${(0,Se.opacityToHex)(n)}`},P=new WeakSet,R=function(e,t){this.canvas.addEventListener("contextmenu",ce(this,s)),this.canvas.addEventListener("pointerleave",ce(this,l)),this.canvas.addEventListener("pointermove",ce(this,o)),this.canvas.addEventListener("pointerup",ce(this,h)),this.canvas.removeEventListener("pointerdown",ce(this,c)),this.isEditing=!0,ce(this,f)||(St(this,f,!0),dt(this,K,$).call(this),this.thickness||(this.thickness=Ee._defaultThickness),this.color||(this.color=Ee._defaultColor||_e.AnnotationEditor._defaultLineColor),null!=this.opacity||(this.opacity=Ee._defaultOpacity)),this.currentPath.push([e,t]),St(this,p,!1),dt(this,A,C).call(this),St(this,y,(()=>{dt(this,F,U).call(this),ce(this,y)&&window.requestAnimationFrame(ce(this,y))})),window.requestAnimationFrame(ce(this,y))},O=new WeakSet,L=function(e,t){let[n,i]=this.currentPath.at(-1);if(this.currentPath.length>1&&e===n&&t===i)return;let r=this.currentPath,a=ce(this,u);if(r.push([e,t]),St(this,p,!0),r.length<=2)return a.moveTo(...r[0]),void a.lineTo(e,t);3===r.length&&(St(this,u,a=new Path2D),a.moveTo(...r[0])),dt(this,B,z).call(this,a,...r.at(-3),...r.at(-2),e,t)},I=new WeakSet,D=function(){if(0===this.currentPath.length)return;let e=this.currentPath.at(-1);ce(this,u).lineTo(...e)},k=new WeakSet,N=function(e,t){let n;if(St(this,y,null),e=Math.min(Math.max(e,0),this.canvas.width),t=Math.min(Math.max(t,0),this.canvas.height),dt(this,O,L).call(this,e,t),dt(this,I,D).call(this),1!==this.currentPath.length)n=dt(this,H,V).call(this);else{let i=[e,t];n=[[i,i.slice(),i.slice(),i]]}let i=ce(this,u),r=this.currentPath;this.currentPath=[],St(this,u,new Path2D),this.addCommands({cmd:()=>{this.allRawPaths.push(r),this.paths.push(n),this.bezierPath2D.push(i),this.rebuild()},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),0===this.paths.length?this.remove():(this.canvas||(dt(this,Y,q).call(this),dt(this,J,Z).call(this)),dt(this,ge,ve).call(this))},mustExec:!0})},F=new WeakSet,U=function(){if(!ce(this,p))return;St(this,p,!1),Math.ceil(this.thickness*this.parentScale);let e=this.currentPath.slice(-3),t=e.map((e=>e[0])),n=e.map((e=>e[1])),{ctx:i}=(Math.min(...t),Math.max(...t),Math.min(...n),Math.max(...n),this);i.save(),i.clearRect(0,0,this.canvas.width,this.canvas.height);for(let r of this.bezierPath2D)i.stroke(r);i.stroke(ce(this,u)),i.restore()},B=new WeakSet,z=function(e,t,n,i,r,a,s){let o=(t+i)/2,l=(n+r)/2,h=(i+a)/2,c=(r+s)/2;e.bezierCurveTo(o+2*(i-o)/3,l+2*(r-l)/3,h+2*(i-h)/3,c+2*(r-c)/3,h,c)},H=new WeakSet,V=function(){let e=this.currentPath;if(e.length<=2)return[[e[0],e[0],e.at(-1),e.at(-1)]];let t,n=[],[i,r]=e[0];for(t=1;t{this.canvas.removeEventListener("contextmenu",ce(this,s))}),10),dt(this,k,N).call(this,e.offsetX,e.offsetY),this.addToAnnotationStorage(),this.setInBackground()},Y=new WeakSet,q=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",Ee._l10nPromise.get("editor_ink_canvas_aria_label").then((e=>{var t;return null==(t=this.canvas)?void 0:t.setAttribute("aria-label",e)})),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},J=new WeakSet,Z=function(){St(this,m,new ResizeObserver((e=>{let t=e[0].contentRect;t.width&&t.height&&this.setDimensions(t.width,t.height)}))),ce(this,m).observe(this.div)},K=new WeakSet,$=function(){if(!ce(this,f))return;let[e,t]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*e),this.canvas.height=Math.ceil(this.height*t),dt(this,te,ne).call(this)},Q=new WeakSet,ee=function(e,t){let n=dt(this,fe,me).call(this),i=(e-n)/ce(this,a),s=(t-n)/ce(this,r);this.scaleFactor=Math.min(i,s)},te=new WeakSet,ne=function(){let e=dt(this,fe,me).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+e,this.translationY*this.scaleFactor+e)},ie=new WeakSet,re=function(e){let t=new Path2D;for(let n=0,i=e.length;n=1?(e.minHeight="16px",e.minWidth=`${Math.round(ce(this,i)*Me)}px`):(e.minWidth="16px",e.minHeight=`${Math.round(Me/ce(this,i))}px`)},Je(Te,ie),Je(Te,ae),Je(Te,oe),Xi(Te,"_defaultColor",null),Xi(Te,"_defaultOpacity",1),Xi(Te,"_defaultThickness",1),Xi(Te,"_l10nPromise"),Xi(Te,"_type","ink"),t.InkEditor=Te},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SVGGraphics=void 0;var i=n(6),r=n(1),a=n(10);let s="normal",o="#000000",l=["butt","round","square"],h=["miter","round","bevel"],c=function(e,t="",n=!1){if(URL.createObjectURL&&"undefined"!=typeof Blob&&!n)return URL.createObjectURL(new Blob([e],{type:t}));let i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r=`data:${t};base64,`;for(let a=0,s=e.length;a>2]+i[(3&t)<<4|n>>4]+i[a+1>6:64]+i[a+2>1&2147483647:e>>1&2147483647;t[r]=e}function n(e,n,i,r){let a=r,s=n.length;i[a]=s>>24&255,i[a+1]=s>>16&255,i[a+2]=s>>8&255,i[a+3]=255&s,a+=4,i[a]=255&e.charCodeAt(0),i[a+1]=255&e.charCodeAt(1),i[a+2]=255&e.charCodeAt(2),i[a+3]=255&e.charCodeAt(3),a+=4,i.set(n,a),a+=n.length;let o=function(e,n,i){let r=-1;for(let a=n;a>>8^t[n]}return-1^r}(i,r+4,a);i[a]=o>>24&255,i[a+1]=o>>16&255,i[a+2]=o>>8&255,i[a+3]=255&o}function i(e){let t=e.length,n=65535,i=Math.ceil(t/n),r=new Uint8Array(2+t+5*i+4),a=0;r[a++]=120,r[a++]=156;let s=0;for(;t>n;)r[a++]=0,r[a++]=255,r[a++]=255,r[a++]=0,r[a++]=0,r.set(e.subarray(s,s+n),a),a+=n,s+=n,t-=n;r[a++]=1,r[a++]=255&t,r[a++]=t>>8&255,r[a++]=255&~t,r[a++]=(65535&~t)>>8&255,r.set(e.subarray(s),a),a+=e.length-s;let o=function(e,t,n){let i=1,r=0;for(let a=0;a>24&255,r[a++]=o>>16&255,r[a++]=o>>8&255,r[a++]=255&o,r}function s(t,s,o,l){let h,u,d,p=t.width,f=t.height,m=t.data;switch(s){case r.ImageKind.GRAYSCALE_1BPP:u=0,h=1,d=p+7>>3;break;case r.ImageKind.RGB_24BPP:u=2,h=8,d=3*p;break;case r.ImageKind.RGBA_32BPP:u=6,h=8,d=4*p;break;default:throw new Error("invalid format")}let g=new Uint8Array((1+d)*f),v=0,y=0;for(let e=0;e>24&255,p>>16&255,p>>8&255,255&p,f>>24&255,f>>16&255,f>>8&255,255&f,h,u,0,0,0]),b=function(e){if(!a.isNodeJS)return i(e);try{let t;t=parseInt(process.versions.node)>=8?e:Buffer.from(e);let n=Vye().deflateSync(t,{level:9});return n instanceof Uint8Array?n:new Uint8Array(n)}catch(e){(0,r.warn)("Not compressing PNG because zlib.deflateSync is unavailable: "+e)}return i(e)}(g),_=e.length+36+x.length+b.length,w=new Uint8Array(_),S=0;return w.set(e,S),S+=e.length,n("IHDR",x,w,S),S+=12+x.length,n("IDATA",b,w,S),S+=12+b.length,n("IEND",new Uint8Array(0),w,S),c(w,"image/png",o)}return function(e,t,n){return s(e,void 0===e.kind?r.ImageKind.GRAYSCALE_1BPP:e.kind,t,n)}}();class d{constructor(){this.fontSizeScale=1,this.fontWeight=s,this.fontSize=0,this.textMatrix=r.IDENTITY_MATRIX,this.fontMatrix=r.FONT_IDENTITY_MATRIX,this.leading=0,this.textRenderingMode=r.TextRenderingMode.FILL,this.textMatrixScale=1,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRise=0,this.fillColor=o,this.strokeColor="#000000",this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.lineJoin="",this.lineCap="",this.miterLimit=0,this.dashArray=[],this.dashPhase=0,this.dependencies=[],this.activeClipUrl=null,this.clipGroup=null,this.maskId=""}clone(){return Object.create(this)}setCurrentPoint(e,t){this.x=e,this.y=t}}function p(e){if(Number.isInteger(e))return e.toString();let t=e.toFixed(10),n=t.length-1;if("0"!==t[n])return t;do{n--}while("0"===t[n]);return t.substring(0,"."===t[n]?n:n+1)}function f(e){if(0===e[4]&&0===e[5]){if(0===e[1]&&0===e[2])return 1===e[0]&&1===e[3]?"":`scale(${p(e[0])} ${p(e[3])})`;if(e[0]===e[3]&&e[1]===-e[2])return`rotate(${p(180*Math.acos(e[0])/Math.PI)})`}else if(1===e[0]&&0===e[1]&&0===e[2]&&1===e[3])return`translate(${p(e[4])} ${p(e[5])})`;return`matrix(${p(e[0])} ${p(e[1])} ${p(e[2])} ${p(e[3])} ${p(e[4])} ${p(e[5])})`}let m=0,g=0,v=0;t.SVGGraphics=class{constructor(e,t,n=!1){(0,i.deprecated)("The SVG back-end is no longer maintained and *may* be removed in the future."),this.svgFactory=new i.DOMSVGFactory,this.current=new d,this.transformMatrix=r.IDENTITY_MATRIX,this.transformStack=[],this.extraStack=[],this.commonObjs=e,this.objs=t,this.pendingClip=null,this.pendingEOFill=!1,this.embedFonts=!1,this.embeddedFonts=Object.create(null),this.cssStyle=null,this.forceDataSchema=!!n,this._operatorIdMapping=[];for(let i in r.OPS)this._operatorIdMapping[r.OPS[i]]=i}getObject(e,t=null){return"string"==typeof e?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):t}save(){this.transformStack.push(this.transformMatrix);let e=this.current;this.extraStack.push(e),this.current=e.clone()}restore(){this.transformMatrix=this.transformStack.pop(),this.current=this.extraStack.pop(),this.pendingClip=null,this.tgrp=null}group(e){this.save(),this.executeOpTree(e),this.restore()}loadDependencies(e){let t=e.fnArray,n=e.argsArray;for(let i=0,a=t.length;i{t.get(e,n)}));this.current.dependencies.push(n)}return Promise.all(this.current.dependencies)}transform(e,t,n,i,a,s){let o=[e,t,n,i,a,s];this.transformMatrix=r.Util.transform(this.transformMatrix,o),this.tgrp=null}getSVG(e,t){this.viewport=t;let n=this._initialize(t);return this.loadDependencies(e).then((()=>(this.transformMatrix=r.IDENTITY_MATRIX,this.executeOpTree(this.convertOpList(e)),n)))}convertOpList(e){let t=this._operatorIdMapping,n=e.argsArray,i=e.fnArray,r=[];for(let a=0,s=i.length;a0&&(this.current.lineWidth=e)}setLineCap(e){this.current.lineCap=l[e]}setLineJoin(e){this.current.lineJoin=h[e]}setMiterLimit(e){this.current.miterLimit=e}setStrokeAlpha(e){this.current.strokeAlpha=e}setStrokeRGBColor(e,t,n){this.current.strokeColor=r.Util.makeHexColor(e,t,n)}setFillAlpha(e){this.current.fillAlpha=e}setFillRGBColor(e,t,n){this.current.fillColor=r.Util.makeHexColor(e,t,n),this.current.tspan=this.svgFactory.createElement("svg:tspan"),this.current.xcoords=[],this.current.ycoords=[]}setStrokeColorN(e){this.current.strokeColor=this._makeColorN_Pattern(e)}setFillColorN(e){this.current.fillColor=this._makeColorN_Pattern(e)}shadingFill(e){let{width:t,height:n}=this.viewport,i=r.Util.inverseTransform(this.transformMatrix),[a,s,o,l]=r.Util.getAxialAlignedBoundingBox([0,0,t,n],i),h=this.svgFactory.createElement("svg:rect");h.setAttributeNS(null,"x",a),h.setAttributeNS(null,"y",s),h.setAttributeNS(null,"width",o-a),h.setAttributeNS(null,"height",l-s),h.setAttributeNS(null,"fill",this._makeShadingPattern(e)),this.current.fillAlpha<1&&h.setAttributeNS(null,"fill-opacity",this.current.fillAlpha),this._ensureTransformGroup().append(h)}_makeColorN_Pattern(e){return"TilingPattern"===e[0]?this._makeTilingPattern(e):this._makeShadingPattern(e)}_makeTilingPattern(e){let t=e[1],n=e[2],i=e[3]||r.IDENTITY_MATRIX,[a,s,o,l]=e[4],h=e[5],c=e[6],u=e[7],d="shading"+v++,[p,f,m,g]=r.Util.normalizeRect([...r.Util.applyTransform([a,s],i),...r.Util.applyTransform([o,l],i)]),[y,x]=r.Util.singularValueDecompose2dScale(i),b=h*y,_=c*x,w=this.svgFactory.createElement("svg:pattern");w.setAttributeNS(null,"id",d),w.setAttributeNS(null,"patternUnits","userSpaceOnUse"),w.setAttributeNS(null,"width",b),w.setAttributeNS(null,"height",_),w.setAttributeNS(null,"x",`${p}`),w.setAttributeNS(null,"y",`${f}`);let S=this.svg,M=this.transformMatrix,E=this.current.fillColor,T=this.current.strokeColor,A=this.svgFactory.create(m-p,g-f);if(this.svg=A,this.transformMatrix=i,2===u){let e=r.Util.makeHexColor(...t);this.current.fillColor=e,this.current.strokeColor=e}return this.executeOpTree(this.convertOpList(n)),this.svg=S,this.transformMatrix=M,this.current.fillColor=E,this.current.strokeColor=T,w.append(A.childNodes[0]),this.defs.append(w),`url(#${d})`}_makeShadingPattern(e){switch("string"==typeof e&&(e=this.objs.get(e)),e[0]){case"RadialAxial":let t,n="shading"+v++,i=e[3];switch(e[1]){case"axial":let i=e[4],r=e[5];t=this.svgFactory.createElement("svg:linearGradient"),t.setAttributeNS(null,"id",n),t.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),t.setAttributeNS(null,"x1",i[0]),t.setAttributeNS(null,"y1",i[1]),t.setAttributeNS(null,"x2",r[0]),t.setAttributeNS(null,"y2",r[1]);break;case"radial":let a=e[4],s=e[5],o=e[6],l=e[7];t=this.svgFactory.createElement("svg:radialGradient"),t.setAttributeNS(null,"id",n),t.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),t.setAttributeNS(null,"cx",s[0]),t.setAttributeNS(null,"cy",s[1]),t.setAttributeNS(null,"r",l),t.setAttributeNS(null,"fx",a[0]),t.setAttributeNS(null,"fy",a[1]),t.setAttributeNS(null,"fr",o);break;default:throw new Error(`Unknown RadialAxial type: ${e[1]}`)}for(let e of i){let n=this.svgFactory.createElement("svg:stop");n.setAttributeNS(null,"offset",e[0]),n.setAttributeNS(null,"stop-color",e[1]),t.append(n)}return this.defs.append(t),`url(#${n})`;case"Mesh":return(0,r.warn)("Unimplemented pattern Mesh"),null;case"Dummy":return"hotpink";default:throw new Error(`Unknown IR type: ${e[0]}`)}}setDash(e,t){this.current.dashArray=e,this.current.dashPhase=t}constructPath(e,t){let n=this.current,i=n.x,a=n.y,s=[],o=0;for(let l of e)switch(0|l){case r.OPS.rectangle:i=t[o++],a=t[o++];let e=i+t[o++],n=a+t[o++];s.push("M",p(i),p(a),"L",p(e),p(a),"L",p(e),p(n),"L",p(i),p(n),"Z");break;case r.OPS.moveTo:i=t[o++],a=t[o++],s.push("M",p(i),p(a));break;case r.OPS.lineTo:i=t[o++],a=t[o++],s.push("L",p(i),p(a));break;case r.OPS.curveTo:i=t[o+4],a=t[o+5],s.push("C",p(t[o]),p(t[o+1]),p(t[o+2]),p(t[o+3]),p(i),p(a)),o+=6;break;case r.OPS.curveTo2:s.push("C",p(i),p(a),p(t[o]),p(t[o+1]),p(t[o+2]),p(t[o+3])),i=t[o+2],a=t[o+3],o+=4;break;case r.OPS.curveTo3:i=t[o+2],a=t[o+3],s.push("C",p(t[o]),p(t[o+1]),p(i),p(a),p(i),p(a)),o+=4;break;case r.OPS.closePath:s.push("Z")}s=s.join(" "),n.path&&e.length>0&&e[0]!==r.OPS.rectangle&&e[0]!==r.OPS.moveTo?s=n.path.getAttributeNS(null,"d")+s:(n.path=this.svgFactory.createElement("svg:path"),this._ensureTransformGroup().append(n.path)),n.path.setAttributeNS(null,"d",s),n.path.setAttributeNS(null,"fill","none"),n.element=n.path,n.setCurrentPoint(i,a)}endPath(){let e=this.current;if(e.path=null,!this.pendingClip)return;if(!e.element)return void(this.pendingClip=null);let t="clippath"+m++,n=this.svgFactory.createElement("svg:clipPath");n.setAttributeNS(null,"id",t),n.setAttributeNS(null,"transform",f(this.transformMatrix));let i=e.element.cloneNode(!0);if("evenodd"===this.pendingClip?i.setAttributeNS(null,"clip-rule","evenodd"):i.setAttributeNS(null,"clip-rule","nonzero"),this.pendingClip=null,n.append(i),this.defs.append(n),e.activeClipUrl){e.clipGroup=null;for(let e of this.extraStack)e.clipGroup=null;n.setAttributeNS(null,"clip-path",e.activeClipUrl)}e.activeClipUrl=`url(#${t})`,this.tgrp=null}clip(e){this.pendingClip=e}closePath(){let e=this.current;if(e.path){let t=`${e.path.getAttributeNS(null,"d")}Z`;e.path.setAttributeNS(null,"d",t)}}setLeading(e){this.current.leading=-e}setTextRise(e){this.current.textRise=e}setTextRenderingMode(e){this.current.textRenderingMode=e}setHScale(e){this.current.textHScale=e/100}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(let[t,n]of e)switch(t){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n);break;case"CA":this.setStrokeAlpha(n);break;case"ca":this.setFillAlpha(n);break;default:(0,r.warn)(`Unimplemented graphic state operator ${t}`)}}fill(){let e=this.current;e.element&&(e.element.setAttributeNS(null,"fill",e.fillColor),e.element.setAttributeNS(null,"fill-opacity",e.fillAlpha),this.endPath())}stroke(){let e=this.current;e.element&&(this._setStrokeAttributes(e.element),e.element.setAttributeNS(null,"fill","none"),this.endPath())}_setStrokeAttributes(e,t=1){let n=this.current,i=n.dashArray;1!==t&&i.length>0&&(i=i.map((function(e){return t*e}))),e.setAttributeNS(null,"stroke",n.strokeColor),e.setAttributeNS(null,"stroke-opacity",n.strokeAlpha),e.setAttributeNS(null,"stroke-miterlimit",p(n.miterLimit)),e.setAttributeNS(null,"stroke-linecap",n.lineCap),e.setAttributeNS(null,"stroke-linejoin",n.lineJoin),e.setAttributeNS(null,"stroke-width",p(t*n.lineWidth)+"px"),e.setAttributeNS(null,"stroke-dasharray",i.map(p).join(" ")),e.setAttributeNS(null,"stroke-dashoffset",p(t*n.dashPhase)+"px")}eoFill(){var e;null==(e=this.current.element)||e.setAttributeNS(null,"fill-rule","evenodd"),this.fill()}fillStroke(){this.stroke(),this.fill()}eoFillStroke(){var e;null==(e=this.current.element)||e.setAttributeNS(null,"fill-rule","evenodd"),this.fillStroke()}closeStroke(){this.closePath(),this.stroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.closePath(),this.eoFillStroke()}paintSolidColorImageMask(){let e=this.svgFactory.createElement("svg:rect");e.setAttributeNS(null,"x","0"),e.setAttributeNS(null,"y","0"),e.setAttributeNS(null,"width","1px"),e.setAttributeNS(null,"height","1px"),e.setAttributeNS(null,"fill",this.current.fillColor),this._ensureTransformGroup().append(e)}paintImageXObject(e){let t=this.getObject(e);t?this.paintInlineImageXObject(t):(0,r.warn)(`Dependent image with object ID ${e} is not ready yet`)}paintInlineImageXObject(e,t){let n=e.width,i=e.height,r=u(e,this.forceDataSchema,!!t),a=this.svgFactory.createElement("svg:rect");a.setAttributeNS(null,"x","0"),a.setAttributeNS(null,"y","0"),a.setAttributeNS(null,"width",p(n)),a.setAttributeNS(null,"height",p(i)),this.current.element=a,this.clip("nonzero");let s=this.svgFactory.createElement("svg:image");s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r),s.setAttributeNS(null,"x","0"),s.setAttributeNS(null,"y",p(-i)),s.setAttributeNS(null,"width",p(n)+"px"),s.setAttributeNS(null,"height",p(i)+"px"),s.setAttributeNS(null,"transform",`scale(${p(1/n)} ${p(-1/i)})`),t?t.append(s):this._ensureTransformGroup().append(s)}paintImageMaskXObject(e){let t=this.getObject(e.data,e);if(t.bitmap)return void(0,r.warn)("paintImageMaskXObject: ImageBitmap support is not implemented, ensure that the `isOffscreenCanvasSupported` API parameter is disabled.");let n=this.current,i=t.width,a=t.height,s=n.fillColor;n.maskId="mask"+g++;let o=this.svgFactory.createElement("svg:mask");o.setAttributeNS(null,"id",n.maskId);let l=this.svgFactory.createElement("svg:rect");l.setAttributeNS(null,"x","0"),l.setAttributeNS(null,"y","0"),l.setAttributeNS(null,"width",p(i)),l.setAttributeNS(null,"height",p(a)),l.setAttributeNS(null,"fill",s),l.setAttributeNS(null,"mask",`url(#${n.maskId})`),this.defs.append(o),this._ensureTransformGroup().append(l),this.paintInlineImageXObject(t,o)}paintFormXObjectBegin(e,t){if(Array.isArray(e)&&6===e.length&&this.transform(e[0],e[1],e[2],e[3],e[4],e[5]),t){let e=t[2]-t[0],n=t[3]-t[1],i=this.svgFactory.createElement("svg:rect");i.setAttributeNS(null,"x",t[0]),i.setAttributeNS(null,"y",t[1]),i.setAttributeNS(null,"width",p(e)),i.setAttributeNS(null,"height",p(n)),this.current.element=i,this.clip("nonzero"),this.endPath()}}paintFormXObjectEnd(){}_initialize(e){let t=this.svgFactory.create(e.width,e.height),n=this.svgFactory.createElement("svg:defs");t.append(n),this.defs=n;let i=this.svgFactory.createElement("svg:g");return i.setAttributeNS(null,"transform",f(e.transform)),t.append(i),this.svg=i,t}_ensureClipGroup(){if(!this.current.clipGroup){let e=this.svgFactory.createElement("svg:g");e.setAttributeNS(null,"clip-path",this.current.activeClipUrl),this.svg.append(e),this.current.clipGroup=e}return this.current.clipGroup}_ensureTransformGroup(){return this.tgrp||(this.tgrp=this.svgFactory.createElement("svg:g"),this.tgrp.setAttributeNS(null,"transform",f(this.transformMatrix)),this.current.activeClipUrl?this._ensureClipGroup().append(this.tgrp):this.svg.append(this.tgrp)),this.tgrp}}}],__webpack_module_cache__={};function __w_pdfjs_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](n,n.exports,__w_pdfjs_require__),n.exports}var __webpack_exports__={};return(()=>{var e=__webpack_exports__;Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"AbortException",{enumerable:!0,get:function(){return t.AbortException}}),Object.defineProperty(e,"AnnotationEditorLayer",{enumerable:!0,get:function(){return a.AnnotationEditorLayer}}),Object.defineProperty(e,"AnnotationEditorParamsType",{enumerable:!0,get:function(){return t.AnnotationEditorParamsType}}),Object.defineProperty(e,"AnnotationEditorType",{enumerable:!0,get:function(){return t.AnnotationEditorType}}),Object.defineProperty(e,"AnnotationEditorUIManager",{enumerable:!0,get:function(){return s.AnnotationEditorUIManager}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return o.AnnotationLayer}}),Object.defineProperty(e,"AnnotationMode",{enumerable:!0,get:function(){return t.AnnotationMode}}),Object.defineProperty(e,"CMapCompressionType",{enumerable:!0,get:function(){return t.CMapCompressionType}}),Object.defineProperty(e,"FeatureTest",{enumerable:!0,get:function(){return t.FeatureTest}}),Object.defineProperty(e,"GlobalWorkerOptions",{enumerable:!0,get:function(){return l.GlobalWorkerOptions}}),Object.defineProperty(e,"ImageKind",{enumerable:!0,get:function(){return t.ImageKind}}),Object.defineProperty(e,"InvalidPDFException",{enumerable:!0,get:function(){return t.InvalidPDFException}}),Object.defineProperty(e,"MissingPDFException",{enumerable:!0,get:function(){return t.MissingPDFException}}),Object.defineProperty(e,"OPS",{enumerable:!0,get:function(){return t.OPS}}),Object.defineProperty(e,"PDFDataRangeTransport",{enumerable:!0,get:function(){return n.PDFDataRangeTransport}}),Object.defineProperty(e,"PDFDateString",{enumerable:!0,get:function(){return i.PDFDateString}}),Object.defineProperty(e,"PDFWorker",{enumerable:!0,get:function(){return n.PDFWorker}}),Object.defineProperty(e,"PasswordResponses",{enumerable:!0,get:function(){return t.PasswordResponses}}),Object.defineProperty(e,"PermissionFlag",{enumerable:!0,get:function(){return t.PermissionFlag}}),Object.defineProperty(e,"PixelsPerInch",{enumerable:!0,get:function(){return i.PixelsPerInch}}),Object.defineProperty(e,"PromiseCapability",{enumerable:!0,get:function(){return t.PromiseCapability}}),Object.defineProperty(e,"RenderingCancelledException",{enumerable:!0,get:function(){return i.RenderingCancelledException}}),e.SVGGraphics=void 0,Object.defineProperty(e,"UnexpectedResponseException",{enumerable:!0,get:function(){return t.UnexpectedResponseException}}),Object.defineProperty(e,"Util",{enumerable:!0,get:function(){return t.Util}}),Object.defineProperty(e,"VerbosityLevel",{enumerable:!0,get:function(){return t.VerbosityLevel}}),Object.defineProperty(e,"XfaLayer",{enumerable:!0,get:function(){return h.XfaLayer}}),Object.defineProperty(e,"build",{enumerable:!0,get:function(){return n.build}}),Object.defineProperty(e,"createValidAbsoluteUrl",{enumerable:!0,get:function(){return t.createValidAbsoluteUrl}}),Object.defineProperty(e,"getDocument",{enumerable:!0,get:function(){return n.getDocument}}),Object.defineProperty(e,"getFilenameFromUrl",{enumerable:!0,get:function(){return i.getFilenameFromUrl}}),Object.defineProperty(e,"getPdfFilenameFromUrl",{enumerable:!0,get:function(){return i.getPdfFilenameFromUrl}}),Object.defineProperty(e,"getXfaPageViewport",{enumerable:!0,get:function(){return i.getXfaPageViewport}}),Object.defineProperty(e,"isDataScheme",{enumerable:!0,get:function(){return i.isDataScheme}}),Object.defineProperty(e,"isPdfFile",{enumerable:!0,get:function(){return i.isPdfFile}}),Object.defineProperty(e,"loadScript",{enumerable:!0,get:function(){return i.loadScript}}),Object.defineProperty(e,"normalizeUnicode",{enumerable:!0,get:function(){return t.normalizeUnicode}}),Object.defineProperty(e,"renderTextLayer",{enumerable:!0,get:function(){return r.renderTextLayer}}),Object.defineProperty(e,"setLayerDimensions",{enumerable:!0,get:function(){return i.setLayerDimensions}}),Object.defineProperty(e,"shadow",{enumerable:!0,get:function(){return t.shadow}}),Object.defineProperty(e,"updateTextLayer",{enumerable:!0,get:function(){return r.updateTextLayer}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return n.version}});var t=__w_pdfjs_require__(1),n=__w_pdfjs_require__(2),i=__w_pdfjs_require__(6),r=__w_pdfjs_require__(26),a=__w_pdfjs_require__(27),s=__w_pdfjs_require__(5),o=__w_pdfjs_require__(29),l=__w_pdfjs_require__(14),h=__w_pdfjs_require__(31);let c=__w_pdfjs_require__(34).SVGGraphics;e.SVGGraphics=c})(),__webpack_exports__})(),"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("pdfjs-dist/build/pdf",[],e):"object"==typeof exports?exports["pdfjs-dist/build/pdf"]=e():t["pdfjs-dist/build/pdf"]=t.pdfjsLib=e()}));!function(){if("undefined"!=typeof document&&!document.getElementById("49ac4a8dcd17f208ca341c9f18f42303e25b2da73020aebf25932de4cfe90dd5")){var e=document.createElement("style");e.id="49ac4a8dcd17f208ca341c9f18f42303e25b2da73020aebf25932de4cfe90dd5",e.textContent='@import"https://at.alicdn.com/t/c/font_2809422_kipm6ycaet.css";@import"https://at.alicdn.com/t/c/font_2802048_dc945363jlf.css";.model-layout-switch-bar{position:absolute;bottom:0;width:100%;height:24px;background:#ffffff;opacity:.7;display:flex;font-size:14px;line-height:1;overflow-x:scroll;overflow-y:hidden;z-index:1}.model-layout-switch-bar .model-layout-switch-bar-content{white-space:nowrap}.model-layout-switch-bar .model-layout-switch-bar-content .model-layout-switch-item{position:relative;display:inline-block;padding:3px 10px 0;color:#000;height:22px;cursor:pointer;transform:translate(0)}.model-layout-switch-bar .model-layout-switch-bar-content .model-layout-switch-item:before{content:"";position:absolute;inset:0;z-index:-1;background:#fff;border:1px solid #000;border-top:0px}.model-layout-switch-bar .model-layout-switch-bar-content .model-layout-switch-item:hover{color:#8080f0}.model-layout-switch-bar .model-layout-switch-bar-content .model-layout-switch-item:nth-child(n+2){margin-left:-1px}.model-layout-switch-bar .model-layout-switch-bar-content .model-layout-switch-item.activate{color:#fff!important}.model-layout-switch-bar .model-layout-switch-bar-content .model-layout-switch-item.activate:before{background:#212830!important}.model-layout-switch-bar.hidden{display:none}.model-layout-switch-bar::-webkit-scrollbar{display:none}.pop-panel{z-index:99999999;top:calc(70% - 100px);left:calc(90% - 160px);position:absolute;background:#ffffff;color:#333;border-radius:4px;width:160px;box-shadow:0 12px 48px 16px #00000008,0 9px 28px #0000000d,0 6px 16px -8px #00000014}.pop-panel .pop-panel-header{font-size:16px;font-weight:bolder;padding:16px 24px 8px;color:#333;border-bottom:1px solid #EFEFEF;cursor:move;user-select:none}.pop-panel .pop-panel-body{display:flex;flex-direction:row;justify-content:space-between;align-items:center;padding:16px 24px}.pop-panel .pop-panel-body .pop-panel-item{display:inline-block;cursor:pointer;margin-right:16px;font-size:16px}.pop-panel .pop-panel-body .pop-panel-item .gemini-viewer-icon{font-size:24px}.pop-panel .pop-panel-body .pop-panel-item:last-child{margin-right:0}.pop-panel .pop-panel-body .pop-panel-item:hover,.pop-panel .pop-panel-body .pop-panel-item.active{color:#2c7be5}.pop-panel .pop-panel-body .pop-panel-item.disable{color:#999;cursor:not-allowed}.progress-bar{z-index:3;bottom:20%;left:25%;position:absolute;color:#ffffffa0;width:50%;user-select:none;font-size:14px}.progress-bar.hidden{display:none}.progress-bar .progress-bar-item{width:100%;text-align:center;padding:2px}.follow-tooltip{z-index:99999999;position:absolute;left:-500px;padding:6px;background:rgba(25,25,25,.3);color:#fffc;font-size:12px;border-radius:2px}.layer-manager{position:absolute;top:30px;left:20px;width:330px;height:600px;max-height:90%;border-radius:4px;box-shadow:1px 3px 10px #0006;background-color:#ffffffe6;color:#000;z-index:2;overflow:hidden;user-select:none}.layer-manager:hover{background-color:#fffffff2}.layer-manager input[type=checkbox]{width:16px;height:16px;cursor:pointer}.layer-manager input[type=color]{width:30px;height:16px;border:0;padding:0;background-color:#0000;overflow:hidden}.layer-manager ::-webkit-color-swatch{position:relative;margin-top:-5px;width:40px;height:16px}.layer-manager .header{display:flex;align-items:center;padding-left:6px;width:100%;height:40px;border-bottom:1px solid #ccc;cursor:move;font-size:16px}.layer-manager .header .close{position:absolute;right:8px;cursor:pointer;padding:10px}.layer-manager .header .close:hover{font-weight:700}.layer-manager .layer-list{width:100%;height:calc(100% - 40px);padding:0;margin:0;border-bottom:1px solid #ccc;overflow-y:scroll}.layer-manager .layer-list-item{display:flex;align-items:center;padding:6px;border-bottom:1px solid #ccc;white-space:nowrap}.layer-manager .layer-list-item:hover{background-color:#f0f8ff}.layer-manager .popup-layer-color{display:inline-block;margin-left:5px;width:20px;font-size:12px}.layer-manager .item-color{margin-left:8px;font-size:12px;border:1px solid black;width:18px;height:16px;min-width:18px}.layer-manager .item-layer-name{display:inline-block;margin-left:10px;padding:1px 0;width:280px;font-size:12px;text-overflow:ellipsis;overflow:hidden}.layer-manager .popup-freeze{margin-right:5px;color:#ccc;font-size:12px;width:50px}#axisGizmo{width:100px;height:100px;position:absolute;display:block;bottom:1px;left:10px;background:#ffffff00}.bottom-bar{position:absolute;bottom:0;right:0;display:flex;color:#666;z-index:3;overflow:hidden;user-select:none}.bottom-bar i{font-size:18px;padding:3px;align-self:center;opacity:.4;cursor:pointer;line-height:1}.bottom-bar i:hover,.bottom-bar i.active{color:#2c7be5;opacity:1}.bottom-bar .fps{width:4rem}.bottom-bar span{align-self:center;padding:4px;font-size:14px}#gemini-viewer-threejs-statistics-tooltip,#gemini-viewer-threejs-tips-tooltip,#gemini-viewer-threejs-cameraInfo-tooltip{position:absolute;right:5px;bottom:30px;background:#666666;color:#fff;padding:8px 8px 5px;font-size:.8rem;border-radius:4px;z-index:3;opacity:.9;user-select:none}#gemini-viewer-threejs-statistics-tooltip p,#gemini-viewer-threejs-tips-tooltip p,#gemini-viewer-threejs-cameraInfo-tooltip p{padding-bottom:3px;margin:3px}#gemini-viewer-threejs-statistics-tooltip p span,#gemini-viewer-threejs-tips-tooltip p span,#gemini-viewer-threejs-cameraInfo-tooltip p span{float:left;margin-right:10px}.context-menu{position:absolute;box-sizing:border-box;background-color:#fff;width:200px;padding:2px;border-radius:2px;box-shadow:0 4px 8px #0003,0 6px 20px #00000030;cursor:pointer;z-index:2}.context-menu ul{list-style:none;padding:0}.context-menu ul:last-child li{border-bottom:0px}.context-menu li{height:2rem;padding:.5rem;box-sizing:border-box}.context-menu li:hover{background-color:#d3d3d3}.context-menu li.disabled{color:#ccc;cursor:not-allowed}.context-menu li:last-child{border-bottom:1px solid #000}#navCube{width:135px;height:135px;position:absolute;bottom:10px;right:10px;z-index:1;pointer-events:none;cursor:pointer}#navCube:hover{opacity:1}.css3d-navcube .navcube-plane{backface-visibility:hidden;z-index:1;transition:all .2s}.css3d-navcube .navcube-plane.outer{opacity:.7;background:linear-gradient(-45deg,transparent 15px,#efefef 0) bottom right,linear-gradient(-135deg,transparent 15px,#efefef 0) top right,linear-gradient(135deg,transparent 15px,#efefef 0) top left,linear-gradient(45deg,transparent 15px,#efefef 0) bottom left;background-size:70% 70%;background-repeat:no-repeat}.css3d-navcube .navcube-plane.inner{margin:2px;font-size:30px;text-align:center;line-height:100px;background:linear-gradient(-45deg,transparent 14px,#2c7be5 0) bottom right,linear-gradient(-135deg,transparent 14px,#2c7be5 0) top right,linear-gradient(135deg,transparent 14px,#2c7be5 0) top left,linear-gradient(45deg,transparent 14px,#2c7be5 0) bottom left;background-size:70% 70%;background-repeat:no-repeat}.css3d-navcube .navcube-plane:hover{opacity:1!important}.css3d-navcube .navcube-edge{opacity:0;z-index:2;transition:all .2s}.css3d-navcube .navcube-edge:hover{opacity:1!important}.css3d-navcube .navcube-corner{opacity:.7;backface-visibility:hidden;box-sizing:content-box;transform-origin:50% 33%;top:4px;z-index:3;transition:all .2s}.css3d-navcube .navcube-corner-plane{opacity:0;backface-visibility:hidden;transform-origin:bottom;top:-6.5px;z-index:3;transition:all .2s}.css3d-navcube .highlight{opacity:1}#overview-map{width:200px;height:200px;top:10px;left:10px;position:absolute;z-index:1;border:1px #50505090 solid;background-color:#80808030}.gemini-spinner{display:flex;flex-flow:row nowrap;align-items:center;justify-content:space-between;width:2em;position:absolute;pointer-events:none;top:50%;left:50%;transform:translate(-50%,-50%);font-size:14px}.gemini-spinner.hidden{display:none}.gemini-spinner span{width:.3em;height:1em;background-color:#3cefff}.gemini-spinner span:nth-of-type(1){animation:grow 1s -.45s ease-in-out infinite}.gemini-spinner span:nth-of-type(2){animation:grow 1s -.3s ease-in-out infinite}.gemini-spinner span:nth-of-type(3){animation:grow 1s -.15s ease-in-out infinite}.gemini-spinner span:nth-of-type(4){animation:grow 1s ease-in-out infinite}@keyframes grow{0%,to{transform:scaleY(1)}50%{transform:scaleY(2)}}.statsOutput{position:absolute;opacity:.6;top:1px;left:1px}.toolbar{position:absolute;display:flex;box-sizing:border-box;height:68px;left:50%;bottom:40px;padding:8px 20px;box-shadow:1px 3px 10px #0006;border-radius:4px;background:rgba(255,255,255,.8);transform:translate(-50%);align-items:center;z-index:10;user-select:none}.toolbar .toolbar-group{display:flex;padding:0 2px;box-sizing:border-box}.toolbar .toolbar-group-division{width:1px;background-color:#999c;height:60%}.toolbar .toolbar-menu{display:flex;box-sizing:border-box;flex-direction:column;word-break:break-word;width:50px;height:50px;padding:3px 1px;margin:0 2px;transition:all .3s;cursor:pointer;color:#666;border-radius:4px}.toolbar .toolbar-menu.active{color:#2c7be5}.toolbar .toolbar-menu .icon{width:24px;height:24px;margin:auto;font-size:24px;line-height:normal}.toolbar .toolbar-menu span{display:block;width:100%;margin:auto;font-size:12px;text-align:center;user-select:none}.toolbar .toolbar-menu-active{color:#2c7be5;background-color:#fffc}.toolbar .toolbar-parent-menu{position:relative}.toolbar .toolbar-parent-menu-active .toolbar-sub-menu{display:block}.toolbar .toolbar-parent-menu-active .toolbar-sub-menu-list{background:rgba(255,255,255,.8)}.toolbar .toolbar-parent-menu:after{content:"";position:absolute;box-sizing:border-box;width:0;height:0;right:2px;top:2px;border-width:4px;border-style:solid;border-top-color:#666;border-right-color:#666;border-bottom-color:transparent;border-left-color:transparent;border-radius:1px}.toolbar .toolbar-sub-menu{display:none;position:absolute;min-width:50px;bottom:100%;box-shadow:1px 3px 10px #0006}.toolbar .toolbar-sub-menu .toolbar-sub-menu-list{margin-bottom:2px;border-radius:4px}.toolbar .toolbar-sub-menu .toolbar-sub-menu-list .toolbar-menu{margin:0}@media screen and (max-width:768px){.toolbar .toolbar-menu{width:30px;height:30px;margin:0}.toolbar .toolbar-menu .icon+span{display:none}.toolbar .toolbar-parent-menu:after{top:1px;right:0}.toolbar .toolbar-sub-menu{min-width:30px}}#viewCube{width:150px;height:150px;position:absolute;bottom:10px;right:10px;z-index:1}.anchor{position:absolute;top:0;left:0;opacity:0;width:20px;height:20px;transform:translate(-50%,-50%);pointer-events:none;user-select:none;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAADjRJREFUeF7tXQnQttUYvq4Zxr5MqBgaihRlKakUU7SYSBQljUhaxijtso2MTCrRn8YoldKIUlIIJRplSyKyqzGyJDSDLGHmMtfvvOb19n7fe7Zn+/7nnnnn+/7/O8t9zrne+5xzn3sh1hCS9GUA20UO9xqS20eWHXQxDpr7BOZHAMyfrBEA8+dllAAJX65BFB0lwCgBxjPAHAyMW8C4BQxCghczOW4B4xYwbgHjFjDqAWYxMJ4BxjNA8fY6iAbGM8B4BhjPAGvKGUDSYwA8FcAmAJ4EYOPw8/6R4upvAH4I4Efh580AbiJ5W2T9wRRbEWcASTuFBX/a1KLfq/Iq/HsKDN8NgLiych+tNzdYAEh6JoAXAdgtLHrrkwfAkuEyAJeTvL4LBkr7HBQAJK0fFtwLH/u0WzpHsfWvMRAMCJK3xlbqutwgACDplVMLf++uJ21B//+aAsL5PecVvQaApB0BHA3AP4dIVwE4maR/9pJ6CYBwij8GwOt7OWvpTJ0O4KQ+3iJ6BwBJXnQvvq9yK4l8hTQIDIbeUG8AsALEfeyi9mpb6AUAJL0bwBtjZ3CFlDuR5LFdj6VzAEi6EMCeXU9ER/1fRHKvjvpe3W1nAJC0NoDPAnhGwxNwF4DbZz6/m/q3u183fNaZ+n3yfw9smL8bALyA5B0N9zO3+U4AIMmL/gUAazU0aKtor/CH5M9K+pD0BAC7hI9Vzk3QnQB2JmkwtEqtA0DS7gAuqTxKn7C96F8EcBXJP1Zuf3Vzkh4WdBI7ADAYat9U9iD5ySZ4X6rNVgEg6TAA76s4wKsBnBa+6X6saY0k+bHJkuFQAM+r2PHhJE+t2N6yTbUGAEkHADiz0sBu8sKTPKdSe0XNSHpNAIKfoGvQgSQ/VKOhRW20AoDwcvfNRcxE/P034Rvvxf97RPnWiki6XwCBJcKjKnS8ZRsvjI0DILzg3VI4IX5gsahf1Ud16vTYghr7DQEMpQ9XGzT9stgoACQ9BMD3Cw9LlhyvI3ljIYharS5pMwAfALBlQcc+3G5K8k8FbXR3BpDkE+1LCpj3+/o+JH2XHxxJsg7ho8FwJZf/S0n65tQINSYBJH0QwEEFXJ9F0gfHwZMkH+heWzCQM0geXFB/yaqNAEDS8QDeUsDwsSRPLKjfu6qS/NbhN49cehfJt+ZWXqpedQCEV70SY8ltSX619kD70J6kbQBcV8DLTrWNS5oAgBc/y4KHZHV+Cia7saqSlNm4tZxV1dFVJzwYc7w/c3BPJPnTzLqDqiZpQwA/yWT6kJpGJdUAEO6/Ft05+vFdSX4mc0IGWU3SCwF8OoN5Xw23qaUPqQkAf/NzbPiOJPnejIkYfBVJRwA4JWMgp5M8JKPePapUAUDBwa+x602NyWmjjYLrcpUDYS0A5Bz87Ky5C8l/tDHRs31IesTUdnUbyd93xMd9g+1CalzCKgfCYgAEp42PJE6edftbtaXeDWrZ59ryJiz6owHcZ4bnuwH8CoD3WFsqfall/r4BIPXtYF+SRc4nNQBwMYA9EgFwCsmjEuskFZe0c7A1tAuZXcpyyC5edvmy7Z4tmBojSe8BcGRiB5eQfGlinf8rXgSA8NL340Tk+knX3/5GXK0l+U3ehievLpmYOXXPBXAqSdsiVKdwi7IUSHlKtiTdqOTFsBQAhwNIPcE3ouaVZN9/q0q9+H6bb4Jsg2BrneNJOoZAVcpUFx9BMtvKqhQAKVE3PFn+9mxd25hD0tMB+PHJLuNtkF3BDyb5nZqdBaOSr4dYB7FNF4W1zQZAppXP/rXNuCS9HMDHYmercrm9SX68ZpvBvOzsxDazrYdKAJD64nc1SVvTViNJbwdwXLUG8xo6juQ78qrOryXJ1s0phqbZL4UlALClj2PwxNJuJG3gUYXCKf/zVRorb+RZJC26q5AkB8Bw5JFYupnkprGFp8tlASBD8/dbAOuRrGK6XeFZNWeuFtV5HMlfLCoU8/dgcv5LAI+MKR/KZGkGcwHg+6rvrbF0Acl9YgsvVy5c8+z1k3JdqtH1ojasDfWj1j8XFYz5uySbkr0ipmwocxTJ5HeFXAD4TvyqBOaq2blL8jaya0LfbRY9geSba3SY4UdxHslk3UcuAL4NwFavsbRODefHgifUWD5Ly1lP4GtusbIoOM/aiTWWbiS5eWzhSblkAEiy6PVeF6u3vpbkc1IZm1e+59/+Ccvnktyv0ni/AuDZkW1ZK/hYkta0RlMOAGySlKIXr6L5G8C3f3rSn1/j7SBDM2gP4yR7zBwApKp/Nybp94IiknQBgL2LGmmvctZ+PMuepI1CuNpYzpPVwjkAsJbKzpAxdBfJB8UUXK6MJLfxawDFbZXyElnf9gXrRZZdtpikvwCIDVJxDsn9U/rNAYBdtWJ17j8n6QALRSRpXwDnFTXSfuUqyiFJDnDx+Ej2ryeZ5IrGEEc/sv3VxbYA8IDICteRjD3ELNlkBRezSHarFnsbSavLi0jStQC2jWzkrwC+FVl2dTEDINdGPaafi0m+LKbggi2gSR5L2VuqftEr3aRRSZ8AUGT0sdwAmwZAsfWqpAcDaMw7tqnVB3ALyVjRvZz0y7W2jhpa0wAoFoOSbL/XiPVQ1AzlF7qbpA0+i0iSjVzeWdTIMpWbBsABJM8qYV6SM378oKSNDuuuXWptLMlexY2Fi2kaAMUeP5K2BvC1DhexpOvNSy2Lm1aAjQAoWd7Fddd4AIxbQKHDydC3gPEQuFhKLFti6IfA8RpYDoBBXwNHRVA5ABpXBNm2P4X8DhCbgLGWKjjVPCplPE2VPZpkitncXD4SVcF2VklKX5fzGGRdc2yI91qPQQ4112oQ5QqoKL4BmIfEx6AbSPqtJppyAGBPYKdxi6Faz8F+DrXnrgNPDoFuJblBDUYTn4PPJ+mX02jKAYDTnJwQ3QOwYWnM/vBNSAFeAnuNFE1+l5/HRchVkBI36U0kk0LR5QAgNbbNYSRXlU5z0xqxUv5m6tcyCXPM4ZTQ8cma1xwAOAiU/eZjkzNfSdK++sW0BhqF2vYyNiycnW7WT3W7TwZAEMc2e35Kwoo+vEYWjwFIgZpm4c5O8oeEOf4eyeR8BbkASL2WVfOi7bkUqOkYkur1nOV9lQsA5/M9KQGdZ5MsCZb8v64kbQXgcwAemtB/G0V9/96+VuAISX5GTzHwPIbkyakDzQVAqm+ADTq8P9VyDrXPnKVQn2izWgEjgnOoz1kpQTeTfQI8eVkACOeArt3DHSjRWUT6QNW2uDC3/XYPD0yOASL+C701NkCE3wRSE0E1ESLGV8yuAkVUue9Pi7DBhIgJUqAvQaIch/+iFmMG2AFzz9p5DQYVJCoAINVP0NWqOIvObvwhcIStZ5uOHeAI3zZ0KXYBnzOGnKwiyf6A0/1mHwIDAByBs2+BIq2qPrABIHjhz2wqrP0gA0UGEPQ1VKyB4Ouif+Y6ldox03kMrGRpNJ/BIEPFBgD4abi3waKDZ7HtCV6ckMLuUgCfAuCUbQZBoxSCWQ8zWHQAQU64eN8gdmg7J2BwNbO7mT8T+wK7nv3ZH5L+2RqF3IKOC5jk1RuypMc+FC05nqIzwKTVjLBxk6qXk9yttdnuYUeSHA/Qip9UygoLN9tJFQAEKZBrvbpiEkSmrmBBQslia+sJrzUBYL11btKoRq6GqQvSZvmM+D8T9vqZNCpIASeNyk0bt2ITRs6575ckkOxn2rip80DOgXB19TFx5EIZVCVP0HQv1baACgfCSRMrNoFkYcJIz0+Vg1+jAAhbgS1TrdbMpWTjxtyO2qpXwZztRJK2yK5K1SXAlCS4MCRtymV4xSSULEgQOZk7J63aK3cil6vXGACCJEjxIprH5xnOAdRVbsHSCZfkEDE26z6ooK1kb5+UvpoGwNoh0uVaKUzNlPWTs0Oh31jQRutVg3rXvoGpCSGneb0TgCOt3tHUABoFQJAC9iNMil03Z7AOhGzzr1Wpdu9NTdxS7YZXPTt0HJoQUHup5rYgeUOTY2gcAAEEuwO4pMJAbIhhIJxWO/NYKW/BmMOL7k+NZBZ7kGzcIbYVAAQQOJ9fdn67mQWyMYZBcE7pwtWoH8y4vPDJjhlL9H84yRSXsOxhtAaAAIIDbFSRze09K14dJMIVtUzOY3kLptu7hG98SoavRV1Uy66yqCP/vVUABBDkGJMuGouTUvmw6Dy/lzV1aApZPPx66XzEPtylJHVaNAb/PTv/X0zj88q0DoAAApuSebFSHB9SxugAy84AbjAU5SoIMfu96M48Xhz4eolB+IFnu5IcwCmTM122EwAEENgY48MJVjq5Y7wLwO0zH+fimfyf2103fNaZ+n3yf7Gx+nP5s/XRfiQ7iYfcGQAmsyXJOX9LFCW5E9+HemeQPLhLRjoHQJAGqV5GXc5Zrb6z073WYqCTQ+BSzAezMnsd71hzgD1s6yoAJ5P0z86pFxJgehYk2ajkmAYPiF1Nug96J5E8vSsGenMLWDQBQZ1qEBgMK4G86F783uU96J0EmJEG3g6GvC30StwPRgLMMirJzie+i9t8OjZjaVeSww9Xzm9sHcT5XTER22+vJcAcIFiBNAGCtXF9Iiu2Jgvv6B6DoEEBYGZ7sErZEsGA2KSj2b7Z33QvPMmkGL0d8XuPbgcLgDlnBYet23TqU3ursGh3WJzJx2HZenGVKwHTigDAnK3C7/GWCk8OPye/xya8dAJGJ6ryN9yf1b+nZuYuWZi26q5IAMybvJAhNfbcUCXpY1uLWNLPCID5szcCoARVfaw7SoD5qzJKgFEC9PH7Wp+nUQKMEiAlpN14Bqj/Hey2xVECjBJglABzMDAeAsdDYLeiua3exy1g3ALGLWDcAlY7dMTQGnML+A8qtnUcTFYqYAAAAABJRU5ErkJggg==) no-repeat center center;background-size:100% 100%;background-blend-mode:lighten;filter:invert(61%) sepia(87%) saturate(845%) hue-rotate(120deg) brightness(94%) contrast(101%);transition:opacity .5s ease-in-out}.anchor.active{opacity:1}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(360deg)}}\n',document.head.appendChild(e)}}();var MSe=fetch;window.fetch=(...e)=>Promise.resolve(MSe(...e));var Dcn=ji(AG(),1),Ocn=ji(nce(),1),kcn=ji(rce(),1),Wt={};FT(Wt,{ACESFilmicToneMapping:()=>Jue,AddEquation:()=>Go,AddOperation:()=>Yue,AdditiveAnimationBlendMode:()=>VU,AdditiveBlending:()=>_c,AlphaFormat:()=>nhe,AlwaysCompare:()=>bhe,AlwaysDepth:()=>Vue,AlwaysStencilFunc:()=>dhe,AmbientLight:()=>Pl,AmbientLightProbe:()=>uU,AnimationAction:()=>GR,AnimationClip:()=>fo,AnimationLoader:()=>nU,AnimationMixer:()=>vU,AnimationObjectGroup:()=>gU,AnimationUtils:()=>Nlt,ArcCurve:()=>gm,ArrayCamera:()=>ER,ArrowHelper:()=>Mc,Audio:()=>VR,AudioAnalyser:()=>pU,AudioContext:()=>Db,AudioListener:()=>dU,AudioLoader:()=>lU,AxesHelper:()=>IU,BackSide:()=>Ki,BasicDepthPacking:()=>uhe,BasicShadowMap:()=>Snt,Bone:()=>Ml,BooleanKeyframeTrack:()=>Jh,Box2:()=>Ji,Box3:()=>Ot,Box3Helper:()=>CU,BoxGeometry:()=>va,BoxHelper:()=>AU,BufferAttribute:()=>gn,BufferGeometry:()=>Dt,BufferGeometryLoader:()=>HR,ByteType:()=>ehe,Cache:()=>Em,Camera:()=>Wh,CameraHelper:()=>Fb,CanvasTexture:()=>Eb,CapsuleGeometry:()=>uv,CatmullRomCurve3:()=>SR,CineonToneMapping:()=>Kue,CircleGeometry:()=>hv,ClampToEdgeWrapping:()=>Ai,Clock:()=>po,Color:()=>ct,ColorKeyframeTrack:()=>Cb,ColorManagement:()=>Tl,CompressedArrayTexture:()=>KB,CompressedTexture:()=>$h,CompressedTextureLoader:()=>rU,ConeGeometry:()=>dv,CubeCamera:()=>xR,CubeReflectionMapping:()=>sf,CubeRefractionMapping:()=>af,CubeTexture:()=>mm,CubeTextureLoader:()=>Pb,CubeUVReflectionMapping:()=>wv,CubicBezierCurve:()=>_b,CubicBezierCurve3:()=>MR,CubicInterpolant:()=>OR,CullFaceBack:()=>nB,CullFaceFront:()=>Iue,CullFaceFrontBack:()=>wnt,CullFaceNone:()=>Pue,Curve:()=>Va,CurvePath:()=>AR,CustomBlending:()=>Mm,CustomToneMapping:()=>Que,CylinderGeometry:()=>wc,Cylindrical:()=>_U,Data3DTexture:()=>gb,DataArrayTexture:()=>sv,DataTexture:()=>Sl,DataTextureLoader:()=>Tm,DataUtils:()=>Av,DecrementStencilOp:()=>Ont,DecrementWrapStencilOp:()=>Fnt,DefaultLoadingManager:()=>mo,DepthFormat:()=>rf,DepthStencilFormat:()=>Gh,DepthTexture:()=>cf,DirectionalLight:()=>js,DirectionalLightHelper:()=>kb,DiscreteInterpolant:()=>kR,DisplayP3ColorSpace:()=>qU,DodecahedronGeometry:()=>fv,DoubleSide:()=>Er,DstAlphaFactor:()=>_v,DstColorFactor:()=>Tv,DynamicCopyUsage:()=>Knt,DynamicDrawUsage:()=>Wnt,DynamicReadUsage:()=>Ynt,EdgesGeometry:()=>Cu,EllipseCurve:()=>Zh,EqualCompare:()=>mhe,EqualDepth:()=>Gue,EqualStencilFunc:()=>Hnt,EquirectangularReflectionMapping:()=>fm,EquirectangularRefractionMapping:()=>ub,Euler:()=>Xn,EventDispatcher:()=>jo,ExtrudeGeometry:()=>ta,FileLoader:()=>Kr,Float16BufferAttribute:()=>UB,Float32BufferAttribute:()=>Bt,Float64BufferAttribute:()=>HB,FloatType:()=>ga,Fog:()=>Su,FogExp2:()=>ov,FramebufferTexture:()=>ZB,FrontSide:()=>ci,Frustum:()=>ya,GLBufferAttribute:()=>bU,GLSL1:()=>Qnt,GLSL3:()=>PB,GreaterCompare:()=>vhe,GreaterDepth:()=>Wue,GreaterEqualCompare:()=>xhe,GreaterEqualDepth:()=>que,GreaterEqualStencilFunc:()=>qnt,GreaterStencilFunc:()=>znt,GridHelper:()=>Ob,Group:()=>er,HalfFloatType:()=>Rr,HemisphereLight:()=>Du,HemisphereLightHelper:()=>MU,HemisphereLightProbe:()=>cU,IcosahedronGeometry:()=>pv,ImageBitmapLoader:()=>Lb,ImageLoader:()=>_m,ImageUtils:()=>mb,IncrementStencilOp:()=>Dnt,IncrementWrapStencilOp:()=>knt,InstancedBufferAttribute:()=>Yh,InstancedBufferGeometry:()=>UR,InstancedInterleavedBuffer:()=>xU,InstancedMesh:()=>Pi,Int16BufferAttribute:()=>NB,Int32BufferAttribute:()=>BB,Int8BufferAttribute:()=>kB,IntType:()=>kU,InterleavedBuffer:()=>Xh,InterleavedBufferAttribute:()=>uo,Interpolant:()=>Kh,InterpolateDiscrete:()=>qh,InterpolateLinear:()=>wu,InterpolateSmooth:()=>pR,InvertStencilOp:()=>Nnt,KeepStencilOp:()=>mR,KeyframeTrack:()=>Yo,LOD:()=>wR,LatheGeometry:()=>ym,Layers:()=>lf,LessCompare:()=>phe,LessDepth:()=>zue,LessEqualCompare:()=>ghe,LessEqualDepth:()=>gR,LessEqualStencilFunc:()=>Vnt,LessStencilFunc:()=>Unt,Light:()=>Ws,LightProbe:()=>xv,Line:()=>ur,Line3:()=>sa,LineBasicMaterial:()=>Gn,LineCurve:()=>cv,LineCurve3:()=>RR,LineDashedMaterial:()=>Iu,LineLoop:()=>lv,LineSegments:()=>Wr,LinearEncoding:()=>GU,LinearFilter:()=>Ir,LinearInterpolant:()=>Ab,LinearMipMapLinearFilter:()=>Pnt,LinearMipMapNearestFilter:()=>Cnt,LinearMipmapLinearFilter:()=>Ua,LinearMipmapNearestFilter:()=>Rm,LinearSRGBColorSpace:()=>Ha,LinearToneMapping:()=>$ue,Loader:()=>_r,LoaderUtils:()=>ra,LoadingManager:()=>Lu,LoopOnce:()=>ohe,LoopPingPong:()=>che,LoopRepeat:()=>lhe,LuminanceAlphaFormat:()=>rhe,LuminanceFormat:()=>XR,MOUSE:()=>WR,Material:()=>vr,MaterialLoader:()=>bv,MathUtils:()=>An,Matrix3:()=>Ln,Matrix4:()=>Qe,MaxEquation:()=>aB,Mesh:()=>xt,MeshBasicMaterial:()=>ln,MeshDepthMaterial:()=>Tc,MeshDistanceMaterial:()=>xb,MeshLambertMaterial:()=>Pu,MeshMatcapMaterial:()=>DR,MeshNormalMaterial:()=>df,MeshPhongMaterial:()=>na,MeshPhysicalMaterial:()=>Xo,MeshStandardMaterial:()=>hf,MeshToonMaterial:()=>LR,MinEquation:()=>sB,MirroredRepeatWrapping:()=>zh,MixOperation:()=>Xue,MultiplyBlending:()=>iB,MultiplyOperation:()=>Nb,NearestFilter:()=>Qr,NearestMipMapLinearFilter:()=>Ant,NearestMipMapNearestFilter:()=>Rnt,NearestMipmapLinearFilter:()=>Vh,NearestMipmapNearestFilter:()=>of,NeverCompare:()=>fhe,NeverDepth:()=>Hue,NeverStencilFunc:()=>Bnt,NoBlending:()=>ei,NoColorSpace:()=>Tu,NoToneMapping:()=>bu,NormalAnimationBlendMode:()=>$R,NormalBlending:()=>hm,NotEqualCompare:()=>yhe,NotEqualDepth:()=>jue,NotEqualStencilFunc:()=>Gnt,NumberKeyframeTrack:()=>Cl,Object3D:()=>on,ObjectLoader:()=>oU,ObjectSpaceNormalMap:()=>hhe,OctahedronGeometry:()=>bm,OneFactor:()=>Oue,OneMinusDstAlphaFactor:()=>Nue,OneMinusDstColorFactor:()=>Bue,OneMinusSrcAlphaFactor:()=>OU,OneMinusSrcColorFactor:()=>Fue,OrthographicCamera:()=>Ur,PCFShadowMap:()=>LU,PCFSoftShadowMap:()=>Ev,PMREMGenerator:()=>jh,Path:()=>Ru,PerspectiveCamera:()=>cr,Plane:()=>Gr,PlaneGeometry:()=>ui,PlaneHelper:()=>PU,PointLight:()=>Sc,PointLightHelper:()=>SU,Points:()=>ii,PointsMaterial:()=>xi,PolarGridHelper:()=>RU,PolyhedronGeometry:()=>Au,PositionalAudio:()=>fU,PropertyBinding:()=>Jn,PropertyMixer:()=>zR,QuadraticBezierCurve:()=>Tb,QuadraticBezierCurve3:()=>wb,Quaternion:()=>hr,QuaternionKeyframeTrack:()=>Ga,QuaternionLinearInterpolant:()=>FR,RED_GREEN_RGTC2_Format:()=>AB,RED_RGTC1_Format:()=>ahe,REVISION:()=>qR,RGBADepthPacking:()=>Rv,RGBAFormat:()=>ea,RGBAIntegerFormat:()=>HU,RGBA_ASTC_10x10_Format:()=>wB,RGBA_ASTC_10x5_Format:()=>EB,RGBA_ASTC_10x6_Format:()=>_B,RGBA_ASTC_10x8_Format:()=>TB,RGBA_ASTC_12x10_Format:()=>SB,RGBA_ASTC_12x12_Format:()=>MB,RGBA_ASTC_4x4_Format:()=>fB,RGBA_ASTC_5x4_Format:()=>pB,RGBA_ASTC_5x5_Format:()=>mB,RGBA_ASTC_6x5_Format:()=>gB,RGBA_ASTC_6x6_Format:()=>vB,RGBA_ASTC_8x5_Format:()=>yB,RGBA_ASTC_8x6_Format:()=>xB,RGBA_ASTC_8x8_Format:()=>bB,RGBA_BPTC_Format:()=>fR,RGBA_ETC2_EAC_Format:()=>dB,RGBA_PVRTC_2BPPV1_Format:()=>uB,RGBA_PVRTC_4BPPV1_Format:()=>cB,RGBA_S3TC_DXT1_Format:()=>uR,RGBA_S3TC_DXT3_Format:()=>hR,RGBA_S3TC_DXT5_Format:()=>dR,RGB_ETC1_Format:()=>she,RGB_ETC2_Format:()=>hB,RGB_PVRTC_2BPPV1_Format:()=>lB,RGB_PVRTC_4BPPV1_Format:()=>oB,RGB_S3TC_DXT1_Format:()=>cR,RGFormat:()=>ihe,RGIntegerFormat:()=>UU,RawShaderMaterial:()=>IR,Ray:()=>co,Raycaster:()=>ia,RectAreaLight:()=>NR,RedFormat:()=>YR,RedIntegerFormat:()=>BU,ReinhardToneMapping:()=>Zue,RepeatWrapping:()=>Ci,ReplaceStencilOp:()=>Lnt,ReverseSubtractEquation:()=>Due,RingGeometry:()=>mv,SIGNED_RED_GREEN_RGTC2_Format:()=>CB,SIGNED_RED_RGTC1_Format:()=>RB,SRGBColorSpace:()=>tn,Scene:()=>_i,ShaderChunk:()=>$n,ShaderLib:()=>xc,ShaderMaterial:()=>cn,ShadowMaterial:()=>PR,Shape:()=>Ss,ShapeGeometry:()=>Al,ShapePath:()=>Sm,ShapeUtils:()=>qs,ShortType:()=>the,Skeleton:()=>Rl,SkeletonHelper:()=>wU,SkinnedMesh:()=>Mu,Source:()=>bc,Sphere:()=>gr,SphereGeometry:()=>za,Spherical:()=>ff,SphericalHarmonics3:()=>BR,SplineCurve:()=>vm,SpotLight:()=>Ou,SpotLightHelper:()=>TU,Sprite:()=>TR,SpriteMaterial:()=>bb,SrcAlphaFactor:()=>DU,SrcAlphaSaturateFactor:()=>Uue,SrcColorFactor:()=>kue,StaticCopyUsage:()=>Znt,StaticDrawUsage:()=>db,StaticReadUsage:()=>Xnt,StereoCamera:()=>hU,StreamCopyUsage:()=>Jnt,StreamDrawUsage:()=>jnt,StreamReadUsage:()=>$nt,StringKeyframeTrack:()=>Qh,SubtractEquation:()=>Lue,SubtractiveBlending:()=>rB,TOUCH:()=>Tnt,TangentSpaceNormalMap:()=>mf,TetrahedronGeometry:()=>gv,Texture:()=>qr,TextureLoader:()=>Rs,TorusGeometry:()=>uf,TorusKnotGeometry:()=>vv,Triangle:()=>Zr,TriangleFanDrawMode:()=>Mv,TriangleStripDrawMode:()=>Bb,TrianglesDrawMode:()=>zU,TubeGeometry:()=>yv,TwoPassDoubleSide:()=>Mnt,UVMapping:()=>jR,Uint16BufferAttribute:()=>pm,Uint32BufferAttribute:()=>yb,Uint8BufferAttribute:()=>vb,Uint8ClampedBufferAttribute:()=>FB,Uniform:()=>wm,UniformsGroup:()=>yU,UniformsLib:()=>Jt,UniformsUtils:()=>Ti,UnsignedByteType:()=>Ec,UnsignedInt248Type:()=>Eu,UnsignedIntType:()=>Hh,UnsignedShort4444Type:()=>FU,UnsignedShort5551Type:()=>NU,UnsignedShortType:()=>Sv,VSMShadowMap:()=>yu,Vector2:()=>be,Vector3:()=>O,Vector4:()=>mr,VectorKeyframeTrack:()=>ho,VideoTexture:()=>$B,WebGL1Renderer:()=>_R,WebGL3DRenderTarget:()=>DB,WebGLArrayRenderTarget:()=>LB,WebGLCoordinateSystem:()=>xu,WebGLCubeRenderTarget:()=>bR,WebGLMultipleRenderTargets:()=>OB,WebGLRenderTarget:()=>sr,WebGLRenderer:()=>Ms,WebGLUtils:()=>Phe,WebGPUCoordinateSystem:()=>fb,WireframeGeometry:()=>CR,WrapAroundEnding:()=>hb,ZeroCurvatureEnding:()=>lm,ZeroFactor:()=>pf,ZeroSlopeEnding:()=>cm,ZeroStencilOp:()=>Int,_SRGBAFormat:()=>vR,sRGBEncoding:()=>_u});var qR="154",WR={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Tnt={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Pue=0,nB=1,Iue=2,wnt=3,Snt=0,LU=1,Ev=2,yu=3,ci=0,Ki=1,Er=2,Mnt=2,ei=0,hm=1,_c=2,rB=3,iB=4,Mm=5,Go=100,Lue=101,Due=102,sB=103,aB=104,pf=200,Oue=201,kue=202,Fue=203,DU=204,OU=205,_v=206,Nue=207,Tv=208,Bue=209,Uue=210,Hue=0,Vue=1,zue=2,gR=3,Gue=4,que=5,Wue=6,jue=7,Nb=0,Xue=1,Yue=2,bu=0,$ue=1,Zue=2,Kue=3,Jue=4,Que=5,jR=300,sf=301,af=302,fm=303,ub=304,wv=306,Ci=1e3,Ai=1001,zh=1002,Qr=1003,of=1004,Rnt=1004,Vh=1005,Ant=1005,Ir=1006,Rm=1007,Cnt=1007,Ua=1008,Pnt=1008,Ec=1009,ehe=1010,the=1011,Sv=1012,kU=1013,Hh=1014,ga=1015,Rr=1016,FU=1017,NU=1018,Eu=1020,nhe=1021,ea=1023,XR=1024,rhe=1025,rf=1026,Gh=1027,YR=1028,BU=1029,ihe=1030,UU=1031,HU=1033,cR=33776,uR=33777,hR=33778,dR=33779,oB=35840,lB=35841,cB=35842,uB=35843,she=36196,hB=37492,dB=37496,fB=37808,pB=37809,mB=37810,gB=37811,vB=37812,yB=37813,xB=37814,bB=37815,EB=37816,_B=37817,TB=37818,wB=37819,SB=37820,MB=37821,fR=36492,ahe=36283,RB=36284,AB=36285,CB=36286,ohe=2200,lhe=2201,che=2202,qh=2300,wu=2301,pR=2302,lm=2400,cm=2401,hb=2402,$R=2500,VU=2501,zU=0,Bb=1,Mv=2,GU=3e3,_u=3001,uhe=3200,Rv=3201,mf=0,hhe=1,Tu="",tn="srgb",Ha="srgb-linear",qU="display-p3",Int=0,mR=7680,Lnt=7681,Dnt=7682,Ont=7683,knt=34055,Fnt=34056,Nnt=5386,Bnt=512,Unt=513,Hnt=514,Vnt=515,znt=516,Gnt=517,qnt=518,dhe=519,fhe=512,phe=513,mhe=514,ghe=515,vhe=516,yhe=517,xhe=518,bhe=519,db=35044,Wnt=35048,jnt=35040,Xnt=35045,Ynt=35049,$nt=35041,Znt=35046,Knt=35050,Jnt=35042,Qnt="100",PB="300 es",vR=1035,xu=2e3,fb=2001,jo=class{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});let n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;let n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;let n=this._listeners[e];if(void 0!==n){let e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;let t=this._listeners[e.type];if(void 0!==t){e.target=this;let n=t.slice(0);for(let t=0,i=n.length;t>8&255]+pa[e>>16&255]+pa[e>>24&255]+"-"+pa[255&t]+pa[t>>8&255]+"-"+pa[t>>16&15|64]+pa[t>>24&255]+"-"+pa[63&n|128]+pa[n>>8&255]+"-"+pa[n>>16&255]+pa[n>>24&255]+pa[255&i]+pa[i>>8&255]+pa[i>>16&255]+pa[i>>24&255]).toLowerCase()}function ls(e,t,n){return Math.max(t,Math.min(n,e))}function WU(e,t){return(e%t+t)%t}function ert(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function trt(e,t,n){return e!==t?(n-e)/(t-e):0}function sb(e,t,n){return(1-n)*e+n*t}function nrt(e,t,n,i){return sb(e,t,1-Math.exp(-n*i))}function rrt(e,t=1){return t-Math.abs(WU(e,2*t)-t)}function irt(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)}function srt(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)}function art(e,t){return e+Math.floor(Math.random()*(t-e+1))}function ort(e,t){return e+Math.random()*(t-e)}function lrt(e){return e*(.5-Math.random())}function crt(e){void 0!==e&&(ice=e);let t=ice+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}function urt(e){return e*dm}function hrt(e){return e*iv}function IB(e){return 0==(e&e-1)&&0!==e}function Ehe(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function yR(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function drt(e,t,n,i,r){let a=Math.cos,s=Math.sin,o=a(n/2),l=s(n/2),h=a((t+i)/2),c=s((t+i)/2),u=a((t-i)/2),d=s((t-i)/2),p=a((i-t)/2),f=s((i-t)/2);switch(r){case"XYX":e.set(o*c,l*u,l*d,o*h);break;case"YZY":e.set(l*d,o*c,l*u,o*h);break;case"ZXZ":e.set(l*u,l*d,o*c,o*h);break;case"XZX":e.set(o*c,l*f,l*p,o*h);break;case"YXY":e.set(l*p,o*c,l*f,o*h);break;case"ZYZ":e.set(l*f,l*p,o*c,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function qo(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function br(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}var An={DEG2RAD:dm,RAD2DEG:iv,generateUUID:Wo,clamp:ls,euclideanModulo:WU,mapLinear:ert,inverseLerp:trt,lerp:sb,damp:nrt,pingpong:rrt,smoothstep:irt,smootherstep:srt,randInt:art,randFloat:ort,randFloatSpread:lrt,seededRandom:crt,degToRad:urt,radToDeg:hrt,isPowerOfTwo:IB,ceilPowerOfTwo:Ehe,floorPowerOfTwo:yR,setQuaternionFromProperEuler:drt,normalize:br,denormalize:qo},be=class{constructor(e=0,t=0){be.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(ls(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ln=class{constructor(e,t,n,i,r,a,s,o,l){Ln.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l)}set(e,t,n,i,r,a,s,o,l){let h=this.elements;return h[0]=e,h[1]=i,h[2]=s,h[3]=t,h[4]=r,h[5]=o,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[3],o=n[6],l=n[1],h=n[4],c=n[7],u=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],v=i[1],y=i[4],x=i[7],b=i[2],_=i[5],w=i[8];return r[0]=a*f+s*v+o*b,r[3]=a*m+s*y+o*_,r[6]=a*g+s*x+o*w,r[1]=l*f+h*v+c*b,r[4]=l*m+h*y+c*_,r[7]=l*g+h*x+c*w,r[2]=u*f+d*v+p*b,r[5]=u*m+d*y+p*_,r[8]=u*g+d*x+p*w,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],h=e[8];return t*a*h-t*s*l-n*r*h+n*s*o+i*r*l-i*a*o}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],h=e[8],c=h*a-s*l,u=s*o-h*r,d=l*r-a*o,p=t*c+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);let f=1/p;return e[0]=c*f,e[1]=(i*l-h*n)*f,e[2]=(s*n-i*a)*f,e[3]=u*f,e[4]=(h*t-i*o)*f,e[5]=(i*r-s*t)*f,e[6]=d*f,e[7]=(n*o-l*t)*f,e[8]=(a*t-n*r)*f,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,a,s){let o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*a+l*s)+a+e,-i*l,i*o,-i*(-l*a+o*s)+s+t,0,0,1),this}scale(e,t){return this.premultiply(wN.makeScale(e,t)),this}rotate(e){return this.premultiply(wN.makeRotation(-e)),this}translate(e,t){return this.premultiply(wN.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}},wN=new Ln;function _he(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}var frt={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function Q0(e,t){return new frt[e](t)}function pb(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}var sce={};function ab(e){e in sce||(sce[e]=!0,console.warn(e))}function nv(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function SN(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}var prt=(new Ln).fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),mrt=(new Ln).fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function grt(e){return e.convertSRGBToLinear().applyMatrix3(mrt)}function vrt(e){return e.applyMatrix3(prt).convertLinearToSRGB()}var yrt={[Ha]:e=>e,[tn]:e=>e.convertSRGBToLinear(),[qU]:grt},xrt={[Ha]:e=>e,[tn]:e=>e.convertLinearToSRGB(),[qU]:vrt},Tl={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(e){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!e},get workingColorSpace(){return Ha},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,n){if(!1===this.enabled||t===n||!t||!n)return e;let i=yrt[t],r=xrt[n];if(void 0===i||void 0===r)throw new Error(`Unsupported color space conversion, "${t}" to "${n}".`);return r(i(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}},I0,mb=class{static getDataURL(e){if(/^data:/i.test(e.src)||"undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===I0&&(I0=pb("canvas")),I0.width=e.width,I0.height=e.height;let n=I0.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=I0}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){let t=pb("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==jR)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ci:e.x=e.x-Math.floor(e.x);break;case Ai:e.x=e.x<0?0:1;break;case zh:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case Ci:e.y=e.y-Math.floor(e.y);break;case Ai:e.y=e.y<0?0:1;break;case zh:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return ab("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===tn?_u:GU}set encoding(e){ab("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===_u?tn:Tu}};qr.DEFAULT_IMAGE=null,qr.DEFAULT_MAPPING=jR,qr.DEFAULT_ANISOTROPY=1;var mr=class{constructor(e=0,t=0,n=0,i=1){mr.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,a=e.elements,s=a[0],o=a[4],l=a[8],h=a[1],c=a[5],u=a[9],d=a[2],p=a[6],f=a[10];if(Math.abs(o-h)<.01&&Math.abs(l-d)<.01&&Math.abs(u-p)<.01){if(Math.abs(o+h)<.1&&Math.abs(l+d)<.1&&Math.abs(u+p)<.1&&Math.abs(s+c+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let e=(s+1)/2,a=(c+1)/2,m=(f+1)/2,g=(o+h)/4,v=(l+d)/4,y=(u+p)/4;return e>a&&e>m?e<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(e),i=g/n,r=v/n):a>m?a<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(a),n=g/i,r=y/i):m<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(m),n=v/r,i=y/r),this.set(n,i,r,t),this}let m=Math.sqrt((p-u)*(p-u)+(l-d)*(l-d)+(h-o)*(h-o));return Math.abs(m)<.001&&(m=1),this.x=(p-u)/m,this.y=(l-d)/m,this.z=(h-o)/m,this.w=Math.acos((s+c+f-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},sr=class extends jo{constructor(e=1,t=1,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new mr(0,0,e,t),this.scissorTest=!1,this.viewport=new mr(0,0,e,t);let i={width:e,height:t,depth:1};void 0!==n.encoding&&(ab("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===_u?tn:Tu),this.texture=new qr(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.internalFormat=void 0!==n.internalFormat?n.internalFormat:null,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:Ir,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0!==n.stencilBuffer&&n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null,this.samples=void 0!==n.samples?n.samples:0}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new bc(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},sv=class extends qr{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Qr,this.minFilter=Qr,this.wrapR=Ai,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},LB=class extends sr{constructor(e=1,t=1,n=1){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new sv(null,e,t,n),this.texture.isRenderTargetTexture=!0}},gb=class extends qr{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Qr,this.minFilter=Qr,this.wrapR=Ai,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},DB=class extends sr{constructor(e=1,t=1,n=1){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new gb(null,e,t,n),this.texture.isRenderTargetTexture=!0}},OB=class extends sr{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLMultipleRenderTargets=!0;let r=this.texture;this.texture=[];for(let a=0;a=0?1:-1,i=1-t*t;if(i>Number.EPSILON){let r=Math.sqrt(i),a=Math.atan2(r,t*n);e=Math.sin(e*a)/r,s=Math.sin(s*a)/r}let r=s*n;if(o=o*e+u*r,l=l*e+d*r,h=h*e+p*r,c=c*e+f*r,e===1-s){let e=1/Math.sqrt(o*o+l*l+h*h+c*c);o*=e,l*=e,h*=e,c*=e}}e[t]=o,e[t+1]=l,e[t+2]=h,e[t+3]=c}static multiplyQuaternionsFlat(e,t,n,i,r,a){let s=n[i],o=n[i+1],l=n[i+2],h=n[i+3],c=r[a],u=r[a+1],d=r[a+2],p=r[a+3];return e[t]=s*p+h*c+o*d-l*u,e[t+1]=o*p+h*u+l*c-s*d,e[t+2]=l*p+h*d+s*u-o*c,e[t+3]=h*p-s*c-o*u-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){let n=e._x,i=e._y,r=e._z,a=e._order,s=Math.cos,o=Math.sin,l=s(n/2),h=s(i/2),c=s(r/2),u=o(n/2),d=o(i/2),p=o(r/2);switch(a){case"XYZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"YXZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"ZXY":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"ZYX":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"YZX":this._x=u*h*c+l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c-u*d*p;break;case"XZY":this._x=u*h*c-l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],s=t[5],o=t[9],l=t[2],h=t[6],c=t[10],u=n+s+c;if(u>0){let e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(h-o)*e,this._y=(r-l)*e,this._z=(a-i)*e}else if(n>s&&n>c){let e=2*Math.sqrt(1+n-s-c);this._w=(h-o)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(r+l)/e}else if(s>c){let e=2*Math.sqrt(1+s-n-c);this._w=(r-l)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(o+h)/e}else{let e=2*Math.sqrt(1+c-n-s);this._w=(a-i)/e,this._x=(r+l)/e,this._y=(o+h)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ls(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(0===n)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,i=e._y,r=e._z,a=e._w,s=t._x,o=t._y,l=t._z,h=t._w;return this._x=n*h+a*s+i*l-r*o,this._y=i*h+a*o+r*s-n*l,this._z=r*h+a*l+n*o-i*s,this._w=a*h-n*s-i*o-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);let n=this._x,i=this._y,r=this._z,a=this._w,s=a*e._w+n*e._x+i*e._y+r*e._z;if(s<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,s=-s):this.copy(e),s>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;let o=1-s*s;if(o<=Number.EPSILON){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}let l=Math.sqrt(o),h=Math.atan2(l,s),c=Math.sin((1-t)*h)/l,u=Math.sin(t*h)/l;return this._w=a*c+this._w*u,this._x=n*c+this._x*u,this._y=i*c+this._y*u,this._z=r*c+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(r),n*Math.cos(r),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},O=class{constructor(e=0,t=0,n=0){O.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(ace.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ace.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,s=e.z,o=e.w,l=o*t+a*i-s*n,h=o*n+s*t-r*i,c=o*i+r*n-a*t,u=-r*t-a*n-s*i;return this.x=l*o+u*-r+h*-s-c*-a,this.y=h*o+u*-a+c*-r-l*-s,this.z=c*o+u*-s+l*-a-h*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,i=e.y,r=e.z,a=t.x,s=t.y,o=t.z;return this.x=i*o-r*s,this.y=r*a-n*o,this.z=n*s-i*a,this}projectOnVector(e){let t=e.lengthSq();if(0===t)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return RN.copy(this).projectOnVector(e),this.sub(RN)}reflect(e){return this.sub(RN.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(ls(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,n=Math.sqrt(1-Do(e,2));return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},RN=new O,ace=new hr,Ot=class{constructor(e=new O(1/0,1/0,1/0),t=new O(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Dh),Dh.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Xx),_M.subVectors(this.max,Xx),D0.subVectors(e.a,Xx),O0.subVectors(e.b,Xx),k0.subVectors(e.c,Xx),Jd.subVectors(O0,D0),Qd.subVectors(k0,O0),Kp.subVectors(D0,k0);let t=[0,-Jd.z,Jd.y,0,-Qd.z,Qd.y,0,-Kp.z,Kp.y,Jd.z,0,-Jd.x,Qd.z,0,-Qd.x,Kp.z,0,-Kp.x,-Jd.y,Jd.x,0,-Qd.y,Qd.x,0,-Kp.y,Kp.x,0];return!(!AN(t,D0,O0,k0,_M)||(t=[1,0,0,0,1,0,0,0,1],!AN(t,D0,O0,k0,_M)))&&(TM.crossVectors(Jd,Qd),t=[TM.x,TM.y,TM.z],AN(t,D0,O0,k0,_M))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Dh).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(Dh).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Lh[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Lh[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Lh[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Lh[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Lh[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Lh[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Lh[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Lh[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Lh)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Lh=[new O,new O,new O,new O,new O,new O,new O,new O],Dh=new O,L0=new Ot,D0=new O,O0=new O,k0=new O,Jd=new O,Qd=new O,Kp=new O,Xx=new O,_M=new O,TM=new O,Jp=new O;function AN(e,t,n,i,r){for(let a=0,s=e.length-3;a<=s;a+=3){Jp.fromArray(e,a);let s=r.x*Math.abs(Jp.x)+r.y*Math.abs(Jp.y)+r.z*Math.abs(Jp.z),o=t.dot(Jp),l=n.dot(Jp),h=i.dot(Jp);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>s)return!1}return!0}var _rt=new Ot,Yx=new O,CN=new O,gr=class{constructor(e=new O,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;void 0!==t?n.copy(t):_rt.setFromPoints(e).getCenter(n);let i=0;for(let r=0,a=e.length;rthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Yx.subVectors(e,this.center);let t=Yx.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(Yx,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(CN.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Yx.copy(e.center).add(CN)),this.expandByPoint(Yx.copy(e.center).sub(CN))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}},Oh=new O,PN=new O,wM=new O,ef=new O,IN=new O,SM=new O,LN=new O,co=class{constructor(e=new O,t=new O(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Oh)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Oh.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Oh.copy(this.origin).addScaledVector(this.direction,t),Oh.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){PN.copy(e).add(t).multiplyScalar(.5),wM.copy(t).sub(e).normalize(),ef.copy(this.origin).sub(PN);let r,a,s,o,l=.5*e.distanceTo(t),h=-this.direction.dot(wM),c=ef.dot(this.direction),u=-ef.dot(wM),d=ef.lengthSq(),p=Math.abs(1-h*h);if(p>0)if(r=h*u-c,a=h*c-u,o=l*p,r>=0)if(a>=-o)if(a<=o){let e=1/p;r*=e,a*=e,s=r*(r+h*a+2*c)+a*(h*r+a+2*u)+d}else a=l,r=Math.max(0,-(h*a+c)),s=-r*r+a*(a+2*u)+d;else a=-l,r=Math.max(0,-(h*a+c)),s=-r*r+a*(a+2*u)+d;else a<=-o?(r=Math.max(0,-(-h*l+c)),a=r>0?-l:Math.min(Math.max(-l,-u),l),s=-r*r+a*(a+2*u)+d):a<=o?(r=0,a=Math.min(Math.max(-l,-u),l),s=a*(a+2*u)+d):(r=Math.max(0,-(h*l+c)),a=r>0?l:Math.min(Math.max(-l,-u),l),s=-r*r+a*(a+2*u)+d);else a=h>0?-l:l,r=Math.max(0,-(h*a+c)),s=-r*r+a*(a+2*u)+d;return n&&n.copy(this.origin).addScaledVector(this.direction,r),i&&i.copy(PN).addScaledVector(wM,a),s}intersectSphere(e,t){Oh.subVectors(e.center,this.origin);let n=Oh.dot(this.direction),i=Oh.dot(Oh)-n*n,r=e.radius*e.radius;if(i>r)return null;let a=Math.sqrt(r-i),s=n-a,o=n+a;return o<0?null:s<0?this.at(o,t):this.at(s,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,s,o,l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,u=this.origin;return l>=0?(n=(e.min.x-u.x)*l,i=(e.max.x-u.x)*l):(n=(e.max.x-u.x)*l,i=(e.min.x-u.x)*l),h>=0?(r=(e.min.y-u.y)*h,a=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,a=(e.min.y-u.y)*h),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a=0?(s=(e.min.z-u.z)*c,o=(e.max.z-u.z)*c):(s=(e.max.z-u.z)*c,o=(e.min.z-u.z)*c),n>o||s>i)||((s>n||n!=n)&&(n=s),(o=0?n:i,t)}intersectsBox(e){return null!==this.intersectBox(e,Oh)}intersectTriangle(e,t,n,i,r){IN.subVectors(t,e),SM.subVectors(n,e),LN.crossVectors(IN,SM);let a,s=this.direction.dot(LN);if(s>0){if(i)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}ef.subVectors(this.origin,e);let o=a*this.direction.dot(SM.crossVectors(ef,SM));if(o<0)return null;let l=a*this.direction.dot(IN.cross(ef));if(l<0||o+l>s)return null;let h=-a*ef.dot(LN);return h<0?null:this.at(h/s,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}},Qe=class{constructor(e,t,n,i,r,a,s,o,l,h,c,u,d,p,f,m){Qe.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l,h,c,u,d,p,f,m)}set(e,t,n,i,r,a,s,o,l,h,c,u,d,p,f,m){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=s,g[13]=o,g[2]=l,g[6]=h,g[10]=c,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Qe).fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,i=1/F0.setFromMatrixColumn(e,0).length(),r=1/F0.setFromMatrixColumn(e,1).length(),a=1/F0.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),s=Math.sin(n),o=Math.cos(i),l=Math.sin(i),h=Math.cos(r),c=Math.sin(r);if("XYZ"===e.order){let e=a*h,n=a*c,i=s*h,r=s*c;t[0]=o*h,t[4]=-o*c,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-s*o,t[2]=r-e*l,t[6]=i+n*l,t[10]=a*o}else if("YXZ"===e.order){let e=o*h,n=o*c,i=l*h,r=l*c;t[0]=e+r*s,t[4]=i*s-n,t[8]=a*l,t[1]=a*c,t[5]=a*h,t[9]=-s,t[2]=n*s-i,t[6]=r+e*s,t[10]=a*o}else if("ZXY"===e.order){let e=o*h,n=o*c,i=l*h,r=l*c;t[0]=e-r*s,t[4]=-a*c,t[8]=i+n*s,t[1]=n+i*s,t[5]=a*h,t[9]=r-e*s,t[2]=-a*l,t[6]=s,t[10]=a*o}else if("ZYX"===e.order){let e=a*h,n=a*c,i=s*h,r=s*c;t[0]=o*h,t[4]=i*l-n,t[8]=e*l+r,t[1]=o*c,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=s*o,t[10]=a*o}else if("YZX"===e.order){let e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*h,t[4]=r-e*c,t[8]=i*c+n,t[1]=c,t[5]=a*h,t[9]=-s*h,t[2]=-l*h,t[6]=n*c+i,t[10]=e-r*c}else if("XZY"===e.order){let e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*h,t[4]=-c,t[8]=l*h,t[1]=e*c+r,t[5]=a*h,t[9]=n*c-i,t[2]=i*c-n,t[6]=s*h,t[10]=r*c+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Trt,e,wrt)}lookAt(e,t,n){let i=this.elements;return Vo.subVectors(e,t),0===Vo.lengthSq()&&(Vo.z=1),Vo.normalize(),tf.crossVectors(n,Vo),0===tf.lengthSq()&&(1===Math.abs(n.z)?Vo.x+=1e-4:Vo.z+=1e-4,Vo.normalize(),tf.crossVectors(n,Vo)),tf.normalize(),MM.crossVectors(Vo,tf),i[0]=tf.x,i[4]=MM.x,i[8]=Vo.x,i[1]=tf.y,i[5]=MM.y,i[9]=Vo.y,i[2]=tf.z,i[6]=MM.z,i[10]=Vo.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[4],o=n[8],l=n[12],h=n[1],c=n[5],u=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],y=n[7],x=n[11],b=n[15],_=i[0],w=i[4],S=i[8],M=i[12],E=i[1],T=i[5],A=i[9],C=i[13],P=i[2],R=i[6],O=i[10],L=i[14],I=i[3],D=i[7],k=i[11],N=i[15];return r[0]=a*_+s*E+o*P+l*I,r[4]=a*w+s*T+o*R+l*D,r[8]=a*S+s*A+o*O+l*k,r[12]=a*M+s*C+o*L+l*N,r[1]=h*_+c*E+u*P+d*I,r[5]=h*w+c*T+u*R+d*D,r[9]=h*S+c*A+u*O+d*k,r[13]=h*M+c*C+u*L+d*N,r[2]=p*_+f*E+m*P+g*I,r[6]=p*w+f*T+m*R+g*D,r[10]=p*S+f*A+m*O+g*k,r[14]=p*M+f*C+m*L+g*N,r[3]=v*_+y*E+x*P+b*I,r[7]=v*w+y*T+x*R+b*D,r[11]=v*S+y*A+x*O+b*k,r[15]=v*M+y*C+x*L+b*N,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],s=e[5],o=e[9],l=e[13],h=e[2],c=e[6],u=e[10],d=e[14];return e[3]*(+r*o*c-i*l*c-r*s*u+n*l*u+i*s*d-n*o*d)+e[7]*(+t*o*d-t*l*u+r*a*u-i*a*d+i*l*h-r*o*h)+e[11]*(+t*l*c-t*s*d-r*a*c+n*a*d+r*s*h-n*l*h)+e[15]*(-i*s*h-t*o*c+t*s*u+i*a*c-n*a*u+n*o*h)}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(e,t,n){let i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],h=e[8],c=e[9],u=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=c*m*l-f*u*l+f*o*d-s*m*d-c*o*g+s*u*g,y=p*u*l-h*m*l-p*o*d+a*m*d+h*o*g-a*u*g,x=h*f*l-p*c*l+p*s*d-a*f*d-h*s*g+a*c*g,b=p*c*o-h*f*o-p*s*u+a*f*u+h*s*m-a*c*m,_=t*v+n*y+i*x+r*b;if(0===_)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let w=1/_;return e[0]=v*w,e[1]=(f*u*r-c*m*r-f*i*d+n*m*d+c*i*g-n*u*g)*w,e[2]=(s*m*r-f*o*r+f*i*l-n*m*l-s*i*g+n*o*g)*w,e[3]=(c*o*r-s*u*r-c*i*l+n*u*l+s*i*d-n*o*d)*w,e[4]=y*w,e[5]=(h*m*r-p*u*r+p*i*d-t*m*d-h*i*g+t*u*g)*w,e[6]=(p*o*r-a*m*r-p*i*l+t*m*l+a*i*g-t*o*g)*w,e[7]=(a*u*r-h*o*r+h*i*l-t*u*l-a*i*d+t*o*d)*w,e[8]=x*w,e[9]=(p*c*r-h*f*r-p*n*d+t*f*d+h*n*g-t*c*g)*w,e[10]=(a*f*r-p*s*r+p*n*l-t*f*l-a*n*g+t*s*g)*w,e[11]=(h*s*r-a*c*r-h*n*l+t*c*l+a*n*d-t*s*d)*w,e[12]=b*w,e[13]=(h*f*i-p*c*i+p*n*u-t*f*u-h*n*m+t*c*m)*w,e[14]=(p*s*i-a*f*i-p*n*o+t*f*o+a*n*m-t*s*m)*w,e[15]=(a*c*i-h*s*i+h*n*o-t*c*o-a*n*u+t*s*u)*w,this}scale(e){let t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,s=e.y,o=e.z,l=r*a,h=r*s;return this.set(l*a+n,l*s-i*o,l*o+i*s,0,l*s+i*o,h*s+n,h*o-i*a,0,l*o-i*s,h*o+i*a,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,r=t._x,a=t._y,s=t._z,o=t._w,l=r+r,h=a+a,c=s+s,u=r*l,d=r*h,p=r*c,f=a*h,m=a*c,g=s*c,v=o*l,y=o*h,x=o*c,b=n.x,_=n.y,w=n.z;return i[0]=(1-(f+g))*b,i[1]=(d+x)*b,i[2]=(p-y)*b,i[3]=0,i[4]=(d-x)*_,i[5]=(1-(u+g))*_,i[6]=(m+v)*_,i[7]=0,i[8]=(p+y)*w,i[9]=(m-v)*w,i[10]=(1-(u+f))*w,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements,r=F0.set(i[0],i[1],i[2]).length(),a=F0.set(i[4],i[5],i[6]).length(),s=F0.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],gc.copy(this);let o=1/r,l=1/a,h=1/s;return gc.elements[0]*=o,gc.elements[1]*=o,gc.elements[2]*=o,gc.elements[4]*=l,gc.elements[5]*=l,gc.elements[6]*=l,gc.elements[8]*=h,gc.elements[9]*=h,gc.elements[10]*=h,t.setFromRotationMatrix(gc),n.x=r,n.y=a,n.z=s,this}makePerspective(e,t,n,i,r,a,s=xu){let o,l,h=this.elements,c=2*r/(t-e),u=2*r/(n-i),d=(t+e)/(t-e),p=(n+i)/(n-i);if(s===xu)o=-(a+r)/(a-r),l=-2*a*r/(a-r);else{if(s!==fb)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);o=-a/(a-r),l=-a*r/(a-r)}return h[0]=c,h[4]=0,h[8]=d,h[12]=0,h[1]=0,h[5]=u,h[9]=p,h[13]=0,h[2]=0,h[6]=0,h[10]=o,h[14]=l,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,t,n,i,r,a,s=xu){let o,l,h=this.elements,c=1/(t-e),u=1/(n-i),d=1/(a-r),p=(t+e)*c,f=(n+i)*u;if(s===xu)o=(a+r)*d,l=-2*d;else{if(s!==fb)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);o=r*d,l=-1*d}return h[0]=2*c,h[4]=0,h[8]=0,h[12]=-p,h[1]=0,h[5]=2*u,h[9]=0,h[13]=-f,h[2]=0,h[6]=0,h[10]=l,h[14]=-o,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},F0=new O,gc=new Qe,Trt=new O(0,0,0),wrt=new O(1,1,1),tf=new O,MM=new O,Vo=new O,oce=new Qe,lce=new hr,Xn=class{constructor(e=0,t=0,n=0,i=Xn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],a=i[4],s=i[8],o=i[1],l=i[5],h=i[9],c=i[2],u=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(ls(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ls(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(s,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(ls(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-ls(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(ls(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(s,d));break;case"XZY":this._z=Math.asin(-ls(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-h,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return oce.makeRotationFromQuaternion(e),this.setFromRotationMatrix(oce,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return lce.setFromEuler(this),this.setFromQuaternion(lce,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Xn.DEFAULT_ORDER="XYZ";var lf=class{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(n=n.concat(r))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose($x,e,Mrt),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose($x,Rrt,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){let n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),s.length>0&&(n.images=s),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),h.length>0&&(n.animations=h),c.length>0&&(n.nodes=c)}return n.object=i,n;function a(e){let t=[];for(let n in e){let i=e[n];delete i.metadata,t.push(i)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let n=0;n0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){vc.subVectors(i,t),Fh.subVectors(n,t),DN.subVectors(e,t);let a=vc.dot(vc),s=vc.dot(Fh),o=vc.dot(DN),l=Fh.dot(Fh),h=Fh.dot(DN),c=a*l-s*s;if(0===c)return r.set(-2,-1,-1);let u=1/c,d=(l*o-s*h)*u,p=(a*h-s*o)*u;return r.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Nh),Nh.x>=0&&Nh.y>=0&&Nh.x+Nh.y<=1}static getUV(e,t,n,i,r,a,s,o){return!1===AM&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),AM=!0),this.getInterpolation(e,t,n,i,r,a,s,o)}static getInterpolation(e,t,n,i,r,a,s,o){return this.getBarycoord(e,t,n,i,Nh),o.setScalar(0),o.addScaledVector(r,Nh.x),o.addScaledVector(a,Nh.y),o.addScaledVector(s,Nh.z),o}static isFrontFacing(e,t,n,i){return vc.subVectors(n,t),Fh.subVectors(e,t),vc.cross(Fh).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return vc.subVectors(this.c,this.b),Fh.subVectors(this.a,this.b),.5*vc.cross(Fh).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Zr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Zr.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return!1===AM&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),AM=!0),Zr.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}getInterpolation(e,t,n,i,r){return Zr.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Zr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Zr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n,i,r=this.a,a=this.b,s=this.c;B0.subVectors(a,r),U0.subVectors(s,r),ON.subVectors(e,r);let o=B0.dot(ON),l=U0.dot(ON);if(o<=0&&l<=0)return t.copy(r);kN.subVectors(e,a);let h=B0.dot(kN),c=U0.dot(kN);if(h>=0&&c<=h)return t.copy(a);let u=o*c-h*l;if(u<=0&&o>=0&&h<=0)return n=o/(o-h),t.copy(r).addScaledVector(B0,n);FN.subVectors(e,s);let d=B0.dot(FN),p=U0.dot(FN);if(p>=0&&d<=p)return t.copy(s);let f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return i=l/(l-p),t.copy(r).addScaledVector(U0,i);let m=h*p-d*c;if(m<=0&&c-h>=0&&d-p>=0)return pce.subVectors(s,a),i=(c-h)/(c-h+(d-p)),t.copy(a).addScaledVector(pce,i);let g=1/(m+f+u);return n=f*g,i=u*g,t.copy(r).addScaledVector(B0,n).addScaledVector(U0,i)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Crt=0,vr=class extends jo{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Crt++}),this.uuid=Wo(),this.name="",this.type="Material",this.blending=hm,this.side=ci,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=DU,this.blendDst=OU,this.blendEquation=Go,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=gR,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=dhe,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=mR,this.stencilZFail=mR,this.stencilZPass=mR,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(let t in e){let n=e[t];if(void 0===n){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){let t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});let n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(e){let t=[];for(let n in e){let i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==hm&&(n.blending=this.blending),this.side!==ci&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=this.alphaHash),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.forceSinglePass&&(n.forceSinglePass=this.forceSinglePass),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){let t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(null!==t){let e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}},The={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},yc={h:0,s:0,l:0},CM={h:0,s:0,l:0};function NN(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}var ct=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(void 0===t&&void 0===n){let t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=tn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Tl.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=Tl.workingColorSpace){return this.r=e,this.g=t,this.b=n,Tl.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=Tl.workingColorSpace){if(e=WU(e,1),t=ls(t,0,1),n=ls(n,0,1),0===t)this.r=this.g=this.b=n;else{let i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=NN(r,i,e+1/3),this.g=NN(r,i,e),this.b=NN(r,i,e-1/3)}return Tl.toWorkingColorSpace(this,i),this}setStyle(e,t=tn){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,a=i[1],s=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(n,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=tn){let n=The[e.toLowerCase()];return void 0!==n?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=nv(e.r),this.g=nv(e.g),this.b=nv(e.b),this}copyLinearToSRGB(e){return this.r=SN(e.r),this.g=SN(e.g),this.b=SN(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=tn){return Tl.fromWorkingColorSpace(ma.copy(this),e),65536*Math.round(ls(255*ma.r,0,255))+256*Math.round(ls(255*ma.g,0,255))+Math.round(ls(255*ma.b,0,255))}getHexString(e=tn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Tl.workingColorSpace){Tl.fromWorkingColorSpace(ma.copy(this),t);let n,i,r=ma.r,a=ma.g,s=ma.b,o=Math.max(r,a,s),l=Math.min(r,a,s),h=(l+o)/2;if(l===o)n=0,i=0;else{let e=o-l;switch(i=h<=.5?e/(o+l):e/(2-o-l),o){case r:n=(a-s)/e+(a>-e-14,i[256|l]=1024>>-e-14|32768,r[l]=-e-1,r[256|l]=-e-1):e<=15?(i[l]=e+15<<10,i[256|l]=e+15<<10|32768,r[l]=13,r[256|l]=13):e<128?(i[l]=31744,i[256|l]=64512,r[l]=24,r[256|l]=24):(i[l]=31744,i[256|l]=64512,r[l]=13,r[256|l]=13)}let a=new Uint32Array(2048),s=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let e=l<<13,t=0;for(;!(8388608&e);)e<<=1,t-=8388608;e&=-8388609,t+=947912704,a[l]=e|t}for(let l=1024;l<2048;++l)a[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)s[l]=l<<23;s[31]=1199570944,s[32]=2147483648;for(let l=33;l<63;++l)s[l]=2147483648+(l-32<<23);s[63]=3347054592;for(let l=1;l<64;++l)32!==l&&(o[l]=1024);return{floatView:t,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:a,exponentTable:s,offsetTable:o}}function lo(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=ls(e,-65504,65504),Uh.floatView[0]=e;let t=Uh.uint32View[0],n=t>>23&511;return Uh.baseTable[n]+((8388607&t)>>Uh.shiftTable[n])}function rb(e){let t=e>>10;return Uh.uint32View[0]=Uh.mantissaTable[Uh.offsetTable[t]+(1023&e)]+Uh.exponentTable[t],Uh.floatView[0]}var Av={toHalfFloat:lo,fromHalfFloat:rb},ws=new O,PM=new be,gn=class{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=db,this.updateRange={offset:0,count:-1},this.gpuType=ga,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i0&&(e.userData=this.userData),void 0!==this.parameters){let t=this.parameters;for(let n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let o in n){let t=n[o];e.data.attributes[o]=t.toJSON(e.data)}let i={},r=!1;for(let o in this.morphAttributes){let t=this.morphAttributes[o],n=[];for(let i=0,r=t.length;i0&&(i[o]=n,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let s=this.boundingSphere;return null!==s&&(e.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;null!==n&&this.setIndex(n.clone(t));let i=e.attributes;for(let l in i){let e=i[l];this.setAttribute(l,e.clone(t))}let r=e.morphAttributes;for(let l in r){let e=[],n=r[l];for(let i=0,r=n.length;i0){let n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;eDo(e.far-e.near,2)))&&(mce.copy(r).invert(),Qp.copy(e.ray).applyMatrix4(mce),(null===n.boundingBox||!1!==Qp.intersectsBox(n.boundingBox))&&this._computeIntersections(e,t,Qp)))}_computeIntersections(e,t,n){let i,r=this.geometry,a=this.material,s=r.index,o=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,c=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==s)if(Array.isArray(a))for(let p=0,f=u.length;pn.far?null:{distance:h,point:NM.clone(),object:e}}function BM(e,t,n,i,r,a,s,o,l,h){e.getVertexPosition(o,V0),e.getVertexPosition(l,z0),e.getVertexPosition(h,G0);let c=Lrt(e,t,n,i,V0,z0,G0,FM);if(c){r&&(DM.fromBufferAttribute(r,o),OM.fromBufferAttribute(r,l),kM.fromBufferAttribute(r,h),c.uv=Zr.getInterpolation(FM,V0,z0,G0,DM,OM,kM,new be)),a&&(DM.fromBufferAttribute(a,o),OM.fromBufferAttribute(a,l),kM.fromBufferAttribute(a,h),c.uv1=Zr.getInterpolation(FM,V0,z0,G0,DM,OM,kM,new be),c.uv2=c.uv1),s&&(vce.fromBufferAttribute(s,o),yce.fromBufferAttribute(s,l),xce.fromBufferAttribute(s,h),c.normal=Zr.getInterpolation(FM,V0,z0,G0,vce,yce,xce,new O),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));let e={a:o,b:l,c:h,normal:new O,materialIndex:0};Zr.getNormal(V0,z0,G0,e.normal),c.face=e}return c}var va=class extends Dt{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};let s=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);let o=[],l=[],h=[],c=[],u=0,d=0;function p(e,t,n,i,r,a,p,f,m,g,v){let y=a/m,x=p/g,b=a/2,_=p/2,w=f/2,S=m+1,M=g+1,E=0,T=0,A=new O;for(let s=0;s0?1:-1,h.push(A.x,A.y,A.z),c.push(o/m),c.push(1-s/g),E+=1}}for(let s=0;s0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)!0===this.extensions[i]&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},Wh=class extends on{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Qe,this.projectionMatrix=new Qe,this.projectionMatrixInverse=new Qe,this.coordinateSystem=xu}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}},cr=class extends Wh{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=2*iv*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(.5*dm*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*iv*Math.atan(Math.tan(.5*dm*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,r,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(.5*dm*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i,a=this.view;if(null!==this.view&&this.view.enabled){let e=a.fullWidth,s=a.fullHeight;r+=a.offsetX*i/e,t-=a.offsetY*n/s,i*=a.width/e,n*=a.height/s}let s=this.filmOffset;0!==s&&(r+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},q0=-90,W0=1,xR=class extends on{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null;let i=new cr(q0,W0,e,t);i.layers=this.layers,this.add(i);let r=new cr(q0,W0,e,t);r.layers=this.layers,this.add(r);let a=new cr(q0,W0,e,t);a.layers=this.layers,this.add(a);let s=new cr(q0,W0,e,t);s.layers=this.layers,this.add(s);let o=new cr(q0,W0,e,t);o.layers=this.layers,this.add(o);let l=new cr(q0,W0,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,s,o]=t;for(let l of t)this.remove(l);if(e===xu)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),s.up.set(0,1,0),s.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(e!==fb)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),s.up.set(0,-1,0),s.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();let n=this.renderTarget;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[i,r,a,s,o,l]=this.children,h=e.getRenderTarget(),c=e.toneMapping,u=e.xr.enabled;e.toneMapping=bu,e.xr.enabled=!1;let d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,r),e.setRenderTarget(n,2),e.render(t,a),e.setRenderTarget(n,3),e.render(t,s),e.setRenderTarget(n,4),e.render(t,o),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(h),e.toneMapping=c,e.xr.enabled=u,n.texture.needsPMREMUpdate=!0}},mm=class extends qr{constructor(e,t,n,i,r,a,s,o,l,h){super(e=void 0!==e?e:[],t=void 0!==t?t:sf,n,i,r,a,s,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},bR=class extends sr{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];void 0!==t.encoding&&(ab("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===_u?tn:Tu),this.texture=new mm(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:Ir}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={tEquirect:{value:null}},i="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",r="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",a=new va(5,5,5),s=new cn({name:"CubemapFromEquirect",uniforms:av(n),vertexShader:i,fragmentShader:r,side:Ki,blending:ei});s.uniforms.tEquirect.value=t;let o=new xt(a,s),l=t.minFilter;return t.minFilter===Ua&&(t.minFilter=Ir),new xR(1,10,this).update(e,o),t.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){let r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(r)}},HN=new O,Frt=new O,Nrt=new Ln,Gr=class{constructor(e=new O(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=HN.subVectors(n,t).cross(Frt.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(HN),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;let r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||Nrt.getNormalMatrix(e),i=this.coplanarPoint(HN).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}},em=new gr,UM=new O,ya=class{constructor(e=new Gr,t=new Gr,n=new Gr,i=new Gr,r=new Gr,a=new Gr){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){let s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(n),s[3].copy(i),s[4].copy(r),s[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=xu){let n=this.planes,i=e.elements,r=i[0],a=i[1],s=i[2],o=i[3],l=i[4],h=i[5],c=i[6],u=i[7],d=i[8],p=i[9],f=i[10],m=i[11],g=i[12],v=i[13],y=i[14],x=i[15];if(n[0].setComponents(o-r,u-l,m-d,x-g).normalize(),n[1].setComponents(o+r,u+l,m+d,x+g).normalize(),n[2].setComponents(o+a,u+h,m+p,x+v).normalize(),n[3].setComponents(o-a,u-h,m-p,x-v).normalize(),n[4].setComponents(o-s,u-c,m-f,x-y).normalize(),t===xu)n[5].setComponents(o+s,u+c,m+f,x+y).normalize();else{if(t!==fb)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(s,c,f,y).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),em.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),em.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(em)}intersectsSprite(e){return em.center.set(0,0,0),em.radius=.7071067811865476,em.applyMatrix4(e.matrixWorld),this.intersectsSphere(em)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)0?e.max.x:e.min.x,UM.y=i.normal.y>0?e.max.y:e.min.y,UM.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(UM)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}};function She(){let e=null,t=!1,n=null,i=null;function r(t,a){n(t,a),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Brt(e,t){let n=t.isWebGL2,i=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);let n=i.get(t);n&&(e.deleteBuffer(n.buffer),i.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){let e=i.get(t);return void((!e||e.version0?n:t).get(v)),null===v?f(h,c):v&&v.isColor&&(f(v,1),g=!0),e.xr.getEnvironmentBlendMode()){case"opaque":g=!0;break;case"additive":i.buffers.color.setClear(0,0,0,1,s),g=!0;break;case"alpha-blend":i.buffers.color.setClear(0,0,0,0,s),g=!0}(e.autoClear||g)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),v&&(v.isCubeTexture||v.mapping===wv)?(void 0===l&&(l=new xt(new va(1,1,1),new cn({name:"BackgroundCubeMaterial",uniforms:av(xc.backgroundCube.uniforms),vertexShader:xc.backgroundCube.vertexShader,fragmentShader:xc.backgroundCube.fragmentShader,side:Ki,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),l.material.uniforms.envMap.value=v,l.material.uniforms.flipEnvMap.value=v.isCubeTexture&&!1===v.isRenderTargetTexture?-1:1,l.material.uniforms.backgroundBlurriness.value=m.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,l.material.toneMapped=v.colorSpace!==tn,(u!==v||d!==v.version||p!==e.toneMapping)&&(l.material.needsUpdate=!0,u=v,d=v.version,p=e.toneMapping),l.layers.enableAll(),a.unshift(l,l.geometry,l.material,0,0,null)):v&&v.isTexture&&(void 0===o&&(o=new xt(new ui(2,2),new cn({name:"BackgroundMaterial",uniforms:av(xc.background.uniforms),vertexShader:xc.background.vertexShader,fragmentShader:xc.background.fragmentShader,side:ci,depthTest:!1,depthWrite:!1,fog:!1})),o.geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(o)),o.material.uniforms.t2D.value=v,o.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,o.material.toneMapped=v.colorSpace!==tn,!0===v.matrixAutoUpdate&&v.updateMatrix(),o.material.uniforms.uvTransform.value.copy(v.matrix),(u!==v||d!==v.version||p!==e.toneMapping)&&(o.material.needsUpdate=!0,u=v,d=v.version,p=e.toneMapping),o.layers.enableAll(),a.unshift(o,o.geometry,o.material,0,0,null))}}}function vat(e,t,n,i){let r=e.getParameter(e.MAX_VERTEX_ATTRIBS),a=i.isWebGL2?null:t.get("OES_vertex_array_object"),s=i.isWebGL2||null!==a,o={},l=p(null),h=l,c=!1;function u(t){return i.isWebGL2?e.bindVertexArray(t):a.bindVertexArrayOES(t)}function d(t){return i.isWebGL2?e.deleteVertexArray(t):a.deleteVertexArrayOES(t)}function p(e){let t=[],n=[],i=[];for(let a=0;a=0){let t=r[l],n=a[l];if(void 0===n&&("instanceMatrix"===l&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===l&&e.instanceColor&&(n=e.instanceColor)),void 0===t||t.attribute!==n||n&&t.data!==n.data)return!0;s++}return h.attributesNum!==s||h.index!==i}(r,x,d,b),_&&function(e,t,n,i){let r={},a=t.attributes,s=0,o=n.getAttributes();for(let l in o)if(o[l].location>=0){let t=a[l];void 0===t&&("instanceMatrix"===l&&e.instanceMatrix&&(t=e.instanceMatrix),"instanceColor"===l&&e.instanceColor&&(t=e.instanceColor));let n={};n.attribute=t,t&&t.data&&(n.data=t.data),r[l]=n,s++}h.attributes=r,h.attributesNum=s,h.index=i}(r,x,d,b)}else{let e=!0===l.wireframe;(h.geometry!==x.id||h.program!==d.id||h.wireframe!==e)&&(h.geometry=x.id,h.program=d.id,h.wireframe=e,_=!0)}null!==b&&n.update(b,e.ELEMENT_ARRAY_BUFFER),(_||c)&&(c=!1,function(r,a,s,o){if(!1===i.isWebGL2&&(r.isInstancedMesh||o.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;f();let l=o.attributes,h=s.getAttributes(),c=a.defaultAttributeValues;for(let t in h){let a=h[t];if(a.location>=0){let s=l[t];if(void 0===s&&("instanceMatrix"===t&&r.instanceMatrix&&(s=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(s=r.instanceColor)),void 0!==s){let t=s.normalized,l=s.itemSize,h=n.get(s);if(void 0===h)continue;let c=h.buffer,u=h.type,d=h.bytesPerElement,p=!0===i.isWebGL2&&(u===e.INT||u===e.UNSIGNED_INT||s.gpuType===kU);if(s.isInterleavedBufferAttribute){let n=s.data,i=n.stride,h=s.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name,s=void 0!==n.precision?n.precision:"highp",o=r(s);o!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",o,"instead."),s=o);let l=a||t.has("WEBGL_draw_buffers"),h=!0===n.logarithmicDepthBuffer,c=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),u=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),f=e.getParameter(e.MAX_VERTEX_ATTRIBS),m=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),g=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),y=u>0,x=a||t.has("OES_texture_float");return{isWebGL2:a,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){let n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,precision:s,logarithmicDepthBuffer:h,maxTextures:c,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:p,maxAttributes:f,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:y,floatFragmentTextures:x,floatVertexTextures:y&&x,maxSamples:a?e.getParameter(e.MAX_SAMPLES):0}}function bat(e){let t=this,n=null,i=0,r=!1,a=!1,s=new Gr,o=new Ln,l={value:null,needsUpdate:!1};function h(e,n,i,r){let a=null!==e?e.length:0,h=null;if(0!==a){if(h=l.value,!0!==r||null===h){let t=i+4*a,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===h||h.length0),t.numPlanes=i,t.numIntersection=0);else{let e=a?0:i,t=4*e,r=f.clippingState||null;l.value=r,r=h(u,o,t,c);for(let i=0;i!==t;++i)r[i]=n[i];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}}}function Eat(e){let t=new WeakMap;function n(e,t){return t===fm?e.mapping=sf:t===ub&&(e.mapping=af),e}function i(e){let n=e.target;n.removeEventListener("dispose",i);let r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture&&!1===r.isRenderTargetTexture){let a=r.mapping;if(a===fm||a===ub){if(t.has(r))return n(t.get(r).texture,r.mapping);{let a=r.image;if(a&&a.height>0){let s=new bR(a.height/2);return s.fromEquirectangularTexture(e,r),t.set(r,s),r.addEventListener("dispose",i),n(s.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}var Ur=class extends Wh{constructor(e=-1,t=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-e,a=n+e,s=i+t,o=i-t;if(null!==this.view&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,a=r+e*this.view.width,s-=t*this.view.offsetY,o=s-t*this.view.height}this.projectionMatrix.makeOrthographic(r,a,s,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}},ev=4,bce=[.125,.215,.35,.446,.526,.582],om=20,VN=new Ur,Ece=new ct,zN=null,am=(1+Math.sqrt(5))/2,j0=1/am,_ce=[new O(1,1,1),new O(-1,1,1),new O(1,1,-1),new O(-1,1,-1),new O(0,am,j0),new O(0,am,-j0),new O(j0,0,am),new O(-j0,0,am),new O(am,j0,0),new O(-am,j0,0)],jh=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){zN=this._renderer.getRenderTarget(),this._setSize(256);let r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Sce(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=wce(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e2?n:0,n,n),o.setRenderTarget(i),d&&o.render(u,r),o.render(e,r)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=h,o.autoClear=l,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===sf||e.mapping===af;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Sce()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=wce());let r=i?this._cubemapMaterial:this._equirectMaterial,a=new xt(this._lodPlanes[0],r);r.uniforms.envMap.value=e;let s=this._cubeSize;VM(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,VN)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;iom&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${om}`);let m=[],g=0;for(let x=0;xv-ev?i-v+ev:0),4*(this._cubeSize-y),3*y,2*y),o.setRenderTarget(t),o.render(h,VN)}};function _at(e){let t=[],n=[],i=[],r=e,a=e-ev+1+bce.length;for(let s=0;se-ev?o=bce[s-e+ev-1]:0===s&&(o=0),i.push(o);let l=1/(a-2),h=-l,c=1+l,u=[h,h,c,h,c,c,h,h,c,c,h,c],d=6,p=6,f=3,m=2,g=1,v=new Float32Array(f*p*d),y=new Float32Array(m*p*d),x=new Float32Array(g*p*d);for(let e=0;e2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];v.set(i,f*p*e),y.set(u,m*p*e);let r=[e,e,e,e,e,e];x.set(r,g*p*e)}let b=new Dt;b.setAttribute("position",new gn(v,f)),b.setAttribute("uv",new gn(y,m)),b.setAttribute("faceIndex",new gn(x,g)),t.push(b),r>ev&&r--}return{lodPlanes:t,sizeLods:n,sigmas:i}}function Tce(e,t,n){let i=new sr(e,t,n);return i.texture.mapping=wv,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function VM(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function Tat(e,t,n){let i=new Float32Array(om),r=new O(0,1,0);return new cn({name:"SphericalGaussianBlur",defines:{n:om,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:jU(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:ei,depthTest:!1,depthWrite:!1})}function wce(){return new cn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:jU(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:ei,depthTest:!1,depthWrite:!1})}function Sce(){return new cn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:jU(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:ei,depthTest:!1,depthWrite:!1})}function jU(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function wat(e){let t=new WeakMap,n=null;function i(e){let n=e.target;n.removeEventListener("dispose",i);let r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){let a=r.mapping,s=a===fm||a===ub,o=a===sf||a===af;if(s||o){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let i=t.get(r);return null===n&&(n=new jh(e)),i=s?n.fromEquirectangular(r,i):n.fromCubemap(r,i),t.set(r,i),i.texture}if(t.has(r))return t.get(r).texture;{let a=r.image;if(s&&a&&a.height>0||o&&a&&function(e){let t=0;for(let n=0;n<6;n++)void 0!==e[n]&&t++;return 6===t}(a)){null===n&&(n=new jh(e));let a=s?n.fromEquirectangular(r):n.fromCubemap(r);return t.set(r,a),r.addEventListener("dispose",i),a.texture}return null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Sat(e){let t={};function n(n){if(void 0!==t[n])return t[n];let i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(e){let t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function Mat(e,t,n,i){let r={},a=new WeakMap;function s(e){let o=e.target;null!==o.index&&t.remove(o.index);for(let n in o.attributes)t.remove(o.attributes[n]);for(let n in o.morphAttributes){let e=o.morphAttributes[n];for(let n=0,i=e.length;nt.maxTextureSize&&(m=Math.ceil(f/t.maxTextureSize),f=t.maxTextureSize);let g=new Float32Array(f*m*4*r),v=new sv(g,f,m,r);v.type=ga,v.needsUpdate=!0;let y=4*p;for(let t=0;t0)return e;let r=t*n,a=Mce[r];if(void 0===a&&(a=new Float32Array(r),Mce[r]=a),0!==t){i.toArray(a,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(a,r)}return a}function Ds(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n":" "} ${e}: ${n[s]}`)}return i.join("\n")}function _ot(e){switch(e){case Ha:return["Linear","( value )"];case tn:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),["Linear","( value )"]}}function Dce(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),r=e.getShaderInfoLog(t).trim();if(i&&""===r)return"";let a=/ERROR: 0:(\d+)/.exec(r);if(a){let i=parseInt(a[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+Eot(e.getShaderSource(t),i)}return r}function Tot(e,t){let n=_ot(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function wot(e,t){let n;switch(t){case $ue:n="Linear";break;case Zue:n="Reinhard";break;case Kue:n="OptimizedCineon";break;case Jue:n="ACESFilmic";break;case Que:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function Sot(e){return[e.extensionDerivatives||e.envMapCubeUVHeight||e.bumpMap||e.normalMapTangentSpace||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(ib).join("\n")}function Mot(e){let t=[];for(let n in e){let i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}function Rot(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function qB(e){return e.replace(Aot,Pot)}var Cot=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function Pot(e,t){let n=$n[t];if(void 0===n){let e=Cot.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");n=$n[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return qB(n)}var Iot=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Fce(e){return e.replace(Iot,Lot)}function Lot(e,t,n,i){let r="";for(let a=parseInt(t);a0&&(r+="\n"),a=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(ib).join("\n"),a.length>0&&(a+="\n")):(r=[Nce(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ib).join("\n"),a=[m,Nce(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+p:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==bu?"#define TONE_MAPPING":"",n.toneMapping!==bu?$n.tonemapping_pars_fragment:"",n.toneMapping!==bu?wot("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",$n.colorspace_pars_fragment,Tot("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(ib).join("\n")),l=qB(l),l=Oce(l,n),l=kce(l,n),h=qB(h),h=Oce(h,n),h=kce(h,n),l=Fce(l),h=Fce(h),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",r=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+r,a=["#define varying in",n.glslVersion===PB?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===PB?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+a);let x,b,_=y+r+l,w=y+a+h,S=Lce(s,s.VERTEX_SHADER,_),M=Lce(s,s.FRAGMENT_SHADER,w);if(s.attachShader(v,S),s.attachShader(v,M),void 0!==n.index0AttributeName?s.bindAttribLocation(v,0,n.index0AttributeName):!0===n.morphTargets&&s.bindAttribLocation(v,0,"position"),s.linkProgram(v),e.debug.checkShaderErrors){let t=s.getProgramInfoLog(v).trim(),n=s.getShaderInfoLog(S).trim(),i=s.getShaderInfoLog(M).trim(),o=!0,l=!0;if(!1===s.getProgramParameter(v,s.LINK_STATUS))if(o=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(s,v,S,M);else{let e=Dce(s,S,"vertex"),n=Dce(s,M,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(v,s.VALIDATE_STATUS)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+n)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):(""===n||""===i)&&(l=!1);l&&(this.diagnostics={runnable:o,programLog:t,vertexShader:{log:n,prefix:r},fragmentShader:{log:i,prefix:a}})}return s.deleteShader(S),s.deleteShader(M),this.getUniforms=function(){return void 0===x&&(x=new rv(s,v)),x},this.getAttributes=function(){return void 0===b&&(b=Rot(s,v)),b},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=bot++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=S,this.fragmentShader=M,this}var Uot=0,WB=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return!1===a.has(i)&&(a.add(i),i.usedTimes++),!1===a.has(r)&&(a.add(r),r.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,0===n.usedTimes&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return void 0===n&&(n=new jB(e),t.set(e,n)),n}},jB=class{constructor(e){this.id=Uot++,this.code=e,this.usedTimes=0}};function Hot(e,t,n,i,r,a,s){let o=new lf,l=new WB,h=[],c=r.isWebGL2,u=r.logarithmicDepthBuffer,d=r.vertexTextures,p=r.precision,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(e){return 0===e?"uv":`uv${e}`}return{getParameters:function(a,o,h,g,v){let y=g.fog,x=v.geometry,b=a.isMeshStandardMaterial?g.environment:null,_=(a.isMeshStandardMaterial?n:t).get(a.envMap||b),w=_&&_.mapping===wv?_.image.height:null,S=f[a.type];null!==a.precision&&(p=r.getMaxPrecision(a.precision),p!==a.precision&&console.warn("THREE.WebGLProgram.getParameters:",a.precision,"not supported, using",p,"instead."));let M,E,T,A,C=x.morphAttributes.position||x.morphAttributes.normal||x.morphAttributes.color,P=void 0!==C?C.length:0,R=0;if(void 0!==x.morphAttributes.position&&(R=1),void 0!==x.morphAttributes.normal&&(R=2),void 0!==x.morphAttributes.color&&(R=3),S){let e=xc[S];M=e.vertexShader,E=e.fragmentShader}else M=a.vertexShader,E=a.fragmentShader,l.update(a),T=l.getVertexShaderID(a),A=l.getFragmentShaderID(a);let O=e.getRenderTarget(),L=!0===v.isInstancedMesh,I=!!a.map,D=!!a.matcap,k=!!_,N=!!a.aoMap,F=!!a.lightMap,U=!!a.bumpMap,B=!!a.normalMap,z=!!a.displacementMap,H=!!a.emissiveMap,V=!!a.metalnessMap,j=!!a.roughnessMap,G=a.anisotropy>0,W=a.clearcoat>0,X=a.iridescence>0,Y=a.sheen>0,q=a.transmission>0,J=G&&!!a.anisotropyMap,Z=W&&!!a.clearcoatMap,K=W&&!!a.clearcoatNormalMap,$=W&&!!a.clearcoatRoughnessMap,Q=X&&!!a.iridescenceMap,ee=X&&!!a.iridescenceThicknessMap,te=Y&&!!a.sheenColorMap,ne=Y&&!!a.sheenRoughnessMap,ie=!!a.specularMap,re=!!a.specularColorMap,ae=!!a.specularIntensityMap,se=q&&!!a.transmissionMap,oe=q&&!!a.thicknessMap,le=!!a.gradientMap,he=!!a.alphaMap,ce=a.alphaTest>0,ue=!!a.alphaHash,de=!!a.extensions,pe=!!x.attributes.uv1,fe=!!x.attributes.uv2,me=!!x.attributes.uv3;return{isWebGL2:c,shaderID:S,shaderType:a.type,shaderName:a.name,vertexShader:M,fragmentShader:E,defines:a.defines,customVertexShaderID:T,customFragmentShaderID:A,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:p,instancing:L,instancingColor:L&&null!==v.instanceColor,supportsVertexTextures:d,outputColorSpace:null===O?e.outputColorSpace:!0===O.isXRRenderTarget?O.texture.colorSpace:Ha,map:I,matcap:D,envMap:k,envMapMode:k&&_.mapping,envMapCubeUVHeight:w,aoMap:N,lightMap:F,bumpMap:U,normalMap:B,displacementMap:d&&z,emissiveMap:H,normalMapObjectSpace:B&&a.normalMapType===hhe,normalMapTangentSpace:B&&a.normalMapType===mf,metalnessMap:V,roughnessMap:j,anisotropy:G,anisotropyMap:J,clearcoat:W,clearcoatMap:Z,clearcoatNormalMap:K,clearcoatRoughnessMap:$,iridescence:X,iridescenceMap:Q,iridescenceThicknessMap:ee,sheen:Y,sheenColorMap:te,sheenRoughnessMap:ne,specularMap:ie,specularColorMap:re,specularIntensityMap:ae,transmission:q,transmissionMap:se,thicknessMap:oe,gradientMap:le,opaque:!1===a.transparent&&a.blending===hm,alphaMap:he,alphaTest:ce,alphaHash:ue,combine:a.combine,mapUv:I&&m(a.map.channel),aoMapUv:N&&m(a.aoMap.channel),lightMapUv:F&&m(a.lightMap.channel),bumpMapUv:U&&m(a.bumpMap.channel),normalMapUv:B&&m(a.normalMap.channel),displacementMapUv:z&&m(a.displacementMap.channel),emissiveMapUv:H&&m(a.emissiveMap.channel),metalnessMapUv:V&&m(a.metalnessMap.channel),roughnessMapUv:j&&m(a.roughnessMap.channel),anisotropyMapUv:J&&m(a.anisotropyMap.channel),clearcoatMapUv:Z&&m(a.clearcoatMap.channel),clearcoatNormalMapUv:K&&m(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:$&&m(a.clearcoatRoughnessMap.channel),iridescenceMapUv:Q&&m(a.iridescenceMap.channel),iridescenceThicknessMapUv:ee&&m(a.iridescenceThicknessMap.channel),sheenColorMapUv:te&&m(a.sheenColorMap.channel),sheenRoughnessMapUv:ne&&m(a.sheenRoughnessMap.channel),specularMapUv:ie&&m(a.specularMap.channel),specularColorMapUv:re&&m(a.specularColorMap.channel),specularIntensityMapUv:ae&&m(a.specularIntensityMap.channel),transmissionMapUv:se&&m(a.transmissionMap.channel),thicknessMapUv:oe&&m(a.thicknessMap.channel),alphaMapUv:he&&m(a.alphaMap.channel),vertexTangents:!!x.attributes.tangent&&(B||G),vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!x.attributes.color&&4===x.attributes.color.itemSize,vertexUv1s:pe,vertexUv2s:fe,vertexUv3s:me,pointsUvs:!0===v.isPoints&&!!x.attributes.uv&&(I||he),fog:!!y,useFog:!0===a.fog,fogExp2:y&&y.isFogExp2,flatShading:!0===a.flatShading,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==x.morphAttributes.position,morphNormals:void 0!==x.morphAttributes.normal,morphColors:void 0!==x.morphAttributes.color,morphTargetsCount:P,morphTextureStride:R,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&h.length>0,shadowMapType:e.shadowMap.type,toneMapping:a.toneMapped?e.toneMapping:bu,useLegacyLights:e.useLegacyLights,premultipliedAlpha:a.premultipliedAlpha,doubleSided:a.side===Er,flipSided:a.side===Ki,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionDerivatives:de&&!0===a.extensions.derivatives,extensionFragDepth:de&&!0===a.extensions.fragDepth,extensionDrawBuffers:de&&!0===a.extensions.drawBuffers,extensionShaderTextureLOD:de&&!0===a.extensions.shaderTextureLOD,rendererExtensionFragDepth:c||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||i.has("EXT_shader_texture_lod"),customProgramCacheKey:a.customProgramCacheKey()}},getProgramCacheKey:function(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.isWebGL2&&o.enable(0),t.supportsVertexTextures&&o.enable(1),t.instancing&&o.enable(2),t.instancingColor&&o.enable(3),t.matcap&&o.enable(4),t.envMap&&o.enable(5),t.normalMapObjectSpace&&o.enable(6),t.normalMapTangentSpace&&o.enable(7),t.clearcoat&&o.enable(8),t.iridescence&&o.enable(9),t.alphaTest&&o.enable(10),t.vertexColors&&o.enable(11),t.vertexAlphas&&o.enable(12),t.vertexUv1s&&o.enable(13),t.vertexUv2s&&o.enable(14),t.vertexUv3s&&o.enable(15),t.vertexTangents&&o.enable(16),t.anisotropy&&o.enable(17),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.skinning&&o.enable(4),t.morphTargets&&o.enable(5),t.morphNormals&&o.enable(6),t.morphColors&&o.enable(7),t.premultipliedAlpha&&o.enable(8),t.shadowMapEnabled&&o.enable(9),t.useLegacyLights&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){let t,n=f[e.type];if(n){let e=xc[n];t=Ti.clone(e.uniforms)}else t=e.uniforms;return t},acquireProgram:function(t,n){let i;for(let e=0,r=h.length;e0?i.push(c):!0===s.transparent?r.push(c):n.push(c)},unshift:function(e,t,s,o,l,h){let c=a(e,t,s,o,l,h);s.transmission>0?i.unshift(c):!0===s.transparent?r.unshift(c):n.unshift(c)},finish:function(){for(let n=t,i=e.length;n1&&n.sort(e||zot),i.length>1&&i.sort(t||Bce),r.length>1&&r.sort(t||Bce)}}}function Got(){let e=new WeakMap;return{get:function(t,n){let i,r=e.get(t);return void 0===r?(i=new Uce,e.set(t,[i])):n>=r.length?(i=new Uce,r.push(i)):i=r[n],i},dispose:function(){e=new WeakMap}}}function qot(){let e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new O,color:new ct};break;case"SpotLight":n={position:new O,direction:new O,color:new ct,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new O,color:new ct,distance:0,decay:0};break;case"HemisphereLight":n={direction:new O,skyColor:new ct,groundColor:new ct};break;case"RectAreaLight":n={color:new ct,position:new O,halfWidth:new O,halfHeight:new O}}return e[t.id]=n,n}}}function Wot(){let e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new be};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new be,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}var jot=0;function Xot(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Yot(e,t){let n=new qot,i=Wot(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let l=0;l<9;l++)r.probe.push(new O);let a=new O,s=new Qe,o=new Qe;return{setup:function(a,s){let o=0,l=0,h=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,u=0,d=0,p=0,f=0,m=0,g=0,v=0,y=0,x=0;a.sort(Xot);let b=!0===s?Math.PI:1;for(let e=0,t=a.length;e0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=Jt.LTC_FLOAT_1,r.rectAreaLTC2=Jt.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=Jt.LTC_HALF_1,r.rectAreaLTC2=Jt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=l,r.ambient[2]=h;let _=r.hash;(_.directionalLength!==c||_.pointLength!==u||_.spotLength!==d||_.rectAreaLength!==p||_.hemiLength!==f||_.numDirectionalShadows!==m||_.numPointShadows!==g||_.numSpotShadows!==v||_.numSpotMaps!==y)&&(r.directional.length=c,r.spot.length=d,r.rectArea.length=p,r.point.length=u,r.hemi.length=f,r.directionalShadow.length=m,r.directionalShadowMap.length=m,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=v,r.spotShadowMap.length=v,r.directionalShadowMatrix.length=m,r.pointShadowMatrix.length=g,r.spotLightMatrix.length=v+y-x,r.spotLightMap.length=y,r.numSpotLightShadowsWithMaps=x,_.directionalLength=c,_.pointLength=u,_.spotLength=d,_.rectAreaLength=p,_.hemiLength=f,_.numDirectionalShadows=m,_.numPointShadows=g,_.numSpotShadows=v,_.numSpotMaps=y,r.version=jot++)},setupView:function(e,t){let n=0,i=0,l=0,h=0,c=0,u=t.matrixWorldInverse;for(let d=0,p=e.length;d=s.length?(a=new Hce(e,t),s.push(a)):a=s[r],a},dispose:function(){n=new WeakMap}}}var Tc=class extends vr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=uhe,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},xb=class extends vr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},Zot="void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",Kot="uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}";function Jot(e,t,n){let i=new ya,r=new be,a=new be,s=new mr,o=new Tc({depthPacking:Rv}),l=new xb,h={},c=n.maxTextureSize,u={[ci]:Ki,[Ki]:ci,[Er]:Er},d=new cn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new be},radius:{value:4}},vertexShader:Zot,fragmentShader:Kot}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new Dt;f.setAttribute("position",new gn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new xt(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=LU;let v=this.type;function y(n,i){let a=t.update(m);d.defines.VSM_SAMPLES!==n.blurSamples&&(d.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new sr(r.x,r.y)),d.uniforms.shadow_pass.value=n.map.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,a,d,m,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,a,p,m,null)}function x(t,n,i,r){let a=null,s=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==s)a=s;else if(a=!0===i.isPointLight?l:o,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){let e=a.uuid,t=n.uuid,i=h[e];void 0===i&&(i={},h[e]=i);let r=i[t];void 0===r&&(r=a.clone(),i[t]=r),a=r}return a.visible=n.visible,a.wireframe=n.wireframe,a.side=r===yu?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],a.alphaMap=n.alphaMap,a.alphaTest=n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===i.isPointLight&&!0===a.isMeshDistanceMaterial&&(e.properties.get(a).light=i),a}function b(n,r,a,s,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&o===yu)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let i=t.update(n),r=n.material;if(Array.isArray(r)){let t=i.groups;for(let l=0,h=t.length;lc||r.y>c)&&(r.x>c&&(a.x=Math.floor(c/u.x),r.x=a.x*u.x,h.mapSize.x=a.x),r.y>c&&(a.y=Math.floor(c/u.y),r.y=a.y*u.y,h.mapSize.y=a.y)),null===h.map||!0===p||!0===f){let e=this.type!==yu?{minFilter:Qr,magFilter:Qr}:{};null!==h.map&&h.map.dispose(),h.map=new sr(r.x,r.y,e),h.map.texture.name=l.name+".shadowMap",h.camera.updateProjectionMatrix()}e.setRenderTarget(h.map),e.clear();let g=h.getViewportCount();for(let e=0;e=1):-1!==O.indexOf("OpenGL ES")&&(R=parseFloat(/^OpenGL ES (\d)/.exec(O)[1]),P=R>=2);let L=null,I={},D=e.getParameter(e.SCISSOR_BOX),k=e.getParameter(e.VIEWPORT),N=(new mr).fromArray(D),F=(new mr).fromArray(k);function U(t,n,r,a){let s=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let l=0;li||e.height>i)&&(r=i/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){let i=t?yR:Math.floor,a=i(r*e.width),s=i(r*e.height);void 0===o&&(o=y(a,s));let l=n?y(a,s):o;return l.width=a,l.height=s,l.getContext("2d").drawImage(e,0,0,a,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+a+"x"+s+")."),l}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function b(e){return IB(e.width)&&IB(e.height)}function _(e,t){return e.generateMipmaps&&t&&e.minFilter!==Qr&&e.minFilter!==Ir}function w(t){e.generateMipmap(t)}function S(n,i,r,a,s=!1){if(!1===l)return i;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;return i===e.RED&&(r===e.FLOAT&&(o=e.R32F),r===e.HALF_FLOAT&&(o=e.R16F),r===e.UNSIGNED_BYTE&&(o=e.R8)),i===e.RG&&(r===e.FLOAT&&(o=e.RG32F),r===e.HALF_FLOAT&&(o=e.RG16F),r===e.UNSIGNED_BYTE&&(o=e.RG8)),i===e.RGBA&&(r===e.FLOAT&&(o=e.RGBA32F),r===e.HALF_FLOAT&&(o=e.RGBA16F),r===e.UNSIGNED_BYTE&&(o=a===tn&&!1===s?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(o=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(o=e.RGB5_A1)),(o===e.R16F||o===e.R32F||o===e.RG16F||o===e.RG32F||o===e.RGBA16F||o===e.RGBA32F)&&t.get("EXT_color_buffer_float"),o}function M(e,t,n){return!0===_(e,n)||e.isFramebufferTexture&&e.minFilter!==Qr&&e.minFilter!==Ir?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function E(t){return t===Qr||t===of||t===Vh?e.NEAREST:e.LINEAR}function T(e){let t=e.target;t.removeEventListener("dispose",T),function(e){let t=i.get(e);if(void 0===t.__webglInit)return;let n=e.source,r=g.get(n);if(r){let i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&C(e),0===Object.keys(r).length&&g.delete(n)}i.remove(e)}(t),t.isVideoTexture&&m.delete(t)}function A(t){let n=t.target;n.removeEventListener("dispose",A),function(t){let n=t.texture,r=i.get(t),a=i.get(n);if(void 0!==a.__webglTexture&&(e.deleteTexture(a.__webglTexture),s.memory.textures--),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let i=0;i<6;i++)e.deleteFramebuffer(r.__webglFramebuffer[i]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[i]);else{if(e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer)for(let t=0;t0&&a.__version!==t.version){let e=t.image;if(null===e)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void N(a,t,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+r)}let O={[Ci]:e.REPEAT,[Ai]:e.CLAMP_TO_EDGE,[zh]:e.MIRRORED_REPEAT},L={[Qr]:e.NEAREST,[of]:e.NEAREST_MIPMAP_NEAREST,[Vh]:e.NEAREST_MIPMAP_LINEAR,[Ir]:e.LINEAR,[Rm]:e.LINEAR_MIPMAP_NEAREST,[Ua]:e.LINEAR_MIPMAP_LINEAR},I={[fhe]:e.NEVER,[bhe]:e.ALWAYS,[phe]:e.LESS,[ghe]:e.LEQUAL,[mhe]:e.EQUAL,[xhe]:e.GEQUAL,[vhe]:e.GREATER,[yhe]:e.NOTEQUAL};function D(n,a,s){if(s?(e.texParameteri(n,e.TEXTURE_WRAP_S,O[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,O[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,O[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,L[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,L[a.minFilter])):(e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),(a.wrapS!==Ai||a.wrapT!==Ai)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,e.TEXTURE_MAG_FILTER,E(a.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,E(a.minFilter)),a.minFilter!==Qr&&a.minFilter!==Ir&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,I[a.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){let s=t.get("EXT_texture_filter_anisotropic");if(a.magFilter===Qr||a.minFilter!==Vh&&a.minFilter!==Ua||a.type===ga&&!1===t.has("OES_texture_float_linear")||!1===l&&a.type===Rr&&!1===t.has("OES_texture_half_float_linear"))return;(a.anisotropy>1||i.get(a).__currentAnisotropy)&&(e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy)}}function k(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",T));let r=n.source,a=g.get(r);void 0===a&&(a={},g.set(r,a));let o=function(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(o!==t.__cacheKey){void 0===a[o]&&(a[o]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,i=!0),a[o].usedTimes++;let r=a[t.__cacheKey];void 0!==r&&(a[t.__cacheKey].usedTimes--,0===r.usedTimes&&C(n)),t.__cacheKey=o,t.__webglTexture=a[o].texture}return i}function N(t,r,s){let o=e.TEXTURE_2D;(r.isDataArrayTexture||r.isCompressedArrayTexture)&&(o=e.TEXTURE_2D_ARRAY),r.isData3DTexture&&(o=e.TEXTURE_3D);let h=k(t,r),c=r.source;n.bindTexture(o,t.__webglTexture,e.TEXTURE0+s);let d=i.get(c);if(c.version!==d.__version||!0===h){n.activeTexture(e.TEXTURE0+s),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);let t=function(e){return!l&&(e.wrapS!==Ai||e.wrapT!==Ai||e.minFilter!==Qr&&e.minFilter!==Ir)}(r)&&!1===b(r.image),i=x(r.image,t,!1,u);i=V(r,i);let p=b(i)||l,f=a.convert(r.format,r.colorSpace),m=a.convert(r.type),g=S(r.internalFormat,f,m,r.colorSpace);D(o,r,p);let v,y=r.mipmaps,E=l&&!0!==r.isVideoTexture,T=void 0===d.__version||!0===h,A=M(r,i,p);if(r.isDepthTexture)g=e.DEPTH_COMPONENT,l?g=r.type===ga?e.DEPTH_COMPONENT32F:r.type===Hh?e.DEPTH_COMPONENT24:r.type===Eu?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:r.type===ga&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===rf&&g===e.DEPTH_COMPONENT&&r.type!==Sv&&r.type!==Hh&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Hh,m=a.convert(r.type)),r.format===Gh&&g===e.DEPTH_COMPONENT&&(g=e.DEPTH_STENCIL,r.type!==Eu&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=Eu,m=a.convert(r.type))),T&&(E?n.texStorage2D(e.TEXTURE_2D,1,g,i.width,i.height):n.texImage2D(e.TEXTURE_2D,0,g,i.width,i.height,0,f,m,null));else if(r.isDataTexture)if(y.length>0&&p){E&&T&&n.texStorage2D(e.TEXTURE_2D,A,g,y[0].width,y[0].height);for(let t=0,i=y.length;t>=1,r>>=1}}else if(y.length>0&&p){E&&T&&n.texStorage2D(e.TEXTURE_2D,A,g,y[0].width,y[0].height);for(let t=0,i=y.length;t=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,o,l,i.get(s).__webglTexture,0),n.bindFramebuffer(e.FRAMEBUFFER,null)}function U(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer&&!n.stencilBuffer){let r=e.DEPTH_COMPONENT16;if(i||H(n)){let t=n.depthTexture;t&&t.isDepthTexture&&(t.type===ga?r=e.DEPTH_COMPONENT32F:t.type===Hh&&(r=e.DEPTH_COMPONENT24));let i=z(n);H(n)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,i,r,n.width,n.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,i,r,n.width,n.height)}else e.renderbufferStorage(e.RENDERBUFFER,r,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(n.depthBuffer&&n.stencilBuffer){let r=z(n);i&&!1===H(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):H(n)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{let t=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let r=0;r0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function V(e,n){let i=e.colorSpace,r=e.format,a=e.type;return!0===e.isCompressedTexture||e.format===vR||i!==Ha&&i!==Tu&&(i===tn?!1===l?!0===t.has("EXT_sRGB")&&r===ea?(e.format=vR,e.minFilter=Ir,e.generateMipmaps=!1):n=mb.sRGBToLinear(n):(r!==ea||a!==Ec)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",i)),n}this.allocateTextureUnit=function(){let e=P;return e>=h&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+h),P+=1,e},this.resetTextureUnits=function(){P=0},this.setTexture2D=R,this.setTexture2DArray=function(t,r){let a=i.get(t);t.version>0&&a.__version!==t.version?N(a,t,r):n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+r)},this.setTexture3D=function(t,r){let a=i.get(t);t.version>0&&a.__version!==t.version?N(a,t,r):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,r){let s=i.get(t);t.version>0&&s.__version!==t.version?function(t,r,s){if(6!==r.image.length)return;let o=k(t,r),h=r.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+s);let u=i.get(h);if(h.version!==u.__version||!0===o){n.activeTexture(e.TEXTURE0+s),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);let t=r.isCompressedTexture||r.image[0].isCompressedTexture,i=r.image[0]&&r.image[0].isDataTexture,d=[];for(let e=0;e<6;e++)d[e]=t||i?i?r.image[e].image:r.image[e]:x(r.image[e],!1,!0,c),d[e]=V(r,d[e]);let p,f=d[0],m=b(f)||l,g=a.convert(r.format,r.colorSpace),v=a.convert(r.type),y=S(r.internalFormat,g,v,r.colorSpace),E=l&&!0!==r.isVideoTexture,T=void 0===u.__version||!0===o,A=M(r,f,m);if(D(e.TEXTURE_CUBE_MAP,r,m),t){E&&T&&n.texStorage2D(e.TEXTURE_CUBE_MAP,A,y,f.width,f.height);for(let t=0;t<6;t++){p=d[t].mipmaps;for(let i=0;i0&&A++,n.texStorage2D(e.TEXTURE_CUBE_MAP,A,y,d[0].width,d[0].height));for(let t=0;t<6;t++)if(i){E?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,d[t].width,d[t].height,g,v,d[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,y,d[t].width,d[t].height,0,g,v,d[t].data);for(let i=0;i0&&!1===H(t)){let i=d?o:[o];h.__webglMultisampledFramebuffer=e.createFramebuffer(),h.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,h.__webglMultisampledFramebuffer);for(let n=0;n0&&!1===H(t)){let r=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],a=t.width,s=t.height,o=e.COLOR_BUFFER_BIT,l=[],h=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=i.get(t),u=!0===t.isWebGLMultipleRenderTargets;if(u)for(let t=0;to+h?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&s<=o-h&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==s&&(i=t.getPose(e.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(tlt)))}return null!==s&&(s.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==a),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){let n=new er;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},cf=class extends qr{constructor(e,t,n,i,r,a,s,o,l,h){if((h=void 0!==h?h:rf)!==rf&&h!==Gh)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&h===rf&&(n=Hh),void 0===n&&h===Gh&&(n=Eu),super(null,i,r,a,s,o,h,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==s?s:Qr,this.minFilter=void 0!==o?o:Qr,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}},XB=class extends jo{constructor(e,t){super();let n=this,i=null,r=1,a=null,s="local-floor",o=1,l=null,h=null,c=null,u=null,d=null,p=null,f=t.getContextAttributes(),m=null,g=null,v=[],y=[],x=new cr;x.layers.enable(1),x.viewport=new mr;let b=new cr;b.layers.enable(2),b.viewport=new mr;let _=[x,b],w=new ER;w.layers.enable(1),w.layers.enable(2);let S=null,M=null;function E(e){let t=y.indexOf(e.inputSource);if(-1===t)return;let n=v[t];void 0!==n&&(n.update(e.inputSource,e.frame,l||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function T(){i.removeEventListener("select",E),i.removeEventListener("selectstart",E),i.removeEventListener("selectend",E),i.removeEventListener("squeeze",E),i.removeEventListener("squeezestart",E),i.removeEventListener("squeezeend",E),i.removeEventListener("end",T),i.removeEventListener("inputsourceschange",A);for(let e=0;e=0&&(y[i]=null,v[i].disconnect(n))}for(let t=0;t=y.length){y.push(n),i=e;break}if(null===y[e]){y[e]=n,i=e;break}}if(-1===i)break}let r=v[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=v[e];return void 0===t&&(t=new ob,v[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=v[e];return void 0===t&&(t=new ob,v[e]=t),t.getGripSpace()},this.getHand=function(e){let t=v[e];return void 0===t&&(t=new ob,v[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){s=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=function(h){return ft(this,null,(function*(){if(i=h,null!==i){if(m=e.getRenderTarget(),i.addEventListener("select",E),i.addEventListener("selectstart",E),i.addEventListener("selectend",E),i.addEventListener("squeeze",E),i.addEventListener("squeezestart",E),i.addEventListener("squeezeend",E),i.addEventListener("end",T),i.addEventListener("inputsourceschange",A),!0!==f.xrCompatible&&(yield t.makeXRCompatible()),void 0===i.renderState.layers||!1===e.capabilities.isWebGL2){let n={antialias:void 0!==i.renderState.layers||f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,n),i.updateRenderState({baseLayer:d}),g=new sr(d.framebufferWidth,d.framebufferHeight,{format:ea,type:Ec,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil})}else{let n=null,a=null,s=null;f.depth&&(s=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=f.stencil?Gh:rf,a=f.stencil?Eu:Hh);let o={colorFormat:t.RGBA8,depthFormat:s,scaleFactor:r};c=new XRWebGLBinding(i,t),u=c.createProjectionLayer(o),i.updateRenderState({layers:[u]}),g=new sr(u.textureWidth,u.textureHeight,{format:ea,type:Ec,depthTexture:new cf(u.textureWidth,u.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0}),e.properties.get(g).__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=yield i.requestReferenceSpace(s),I.setContext(i),I.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}}))},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode};let C=new O,P=new O;function R(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===i)return;w.near=b.near=x.near=e.near,w.far=b.far=x.far=e.far,(S!==w.near||M!==w.far)&&(i.updateRenderState({depthNear:w.near,depthFar:w.far}),S=w.near,M=w.far);let t=e.parent,n=w.cameras;R(w,t);for(let i=0;i0&&(i.alphaTest.value=r.alphaTest);let a=t.get(r).envMap;if(a&&(i.envMap.value=a,i.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,i.reflectivity.value=r.reflectivity,i.ior.value=r.ior,i.refractionRatio.value=r.refractionRatio),r.lightMap){i.lightMap.value=r.lightMap;let t=!0===e.useLegacyLights?Math.PI:1;i.lightMapIntensity.value=r.lightMapIntensity*t,n(r.lightMap,i.lightMapTransform)}r.aoMap&&(i.aoMap.value=r.aoMap,i.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,i.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,whe(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,a,s,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(i(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(i(e,r),function(e,i){e.metalness.value=i.metalness,i.metalnessMap&&(e.metalnessMap.value=i.metalnessMap,n(i.metalnessMap,e.metalnessMapTransform)),e.roughness.value=i.roughness,i.roughnessMap&&(e.roughnessMap.value=i.roughnessMap,n(i.roughnessMap,e.roughnessMapTransform)),t.get(i).envMap&&(e.envMapIntensity.value=i.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===Ki&&e.clearcoatNormalScale.value.negate())),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,o)):r.isMeshMatcapMaterial?(i(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),function(e,n){let i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,a,s):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function rlt(e,t,n,i){let r={},a={},s=[],o=n.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(e,t,n){let i=e.value;if(void 0===n[t]){if("number"==typeof i)n[t]=i;else{let e=Array.isArray(i)?i:[i],r=[];for(let t=0;t0&&(i=n%16,0!==i&&16-i-a.boundary<0&&(n+=16-i,e.__offset=n)),n+=a.storage}i=n%16,i>0&&(n+=16-i),e.__size=n,e.__cache={}}(n),d=function(t){let n=function(){for(let e=0;e0),u=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,p=!!n.morphAttributes.color,f=i.toneMapped?y.toneMapping:bu,g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,v=void 0!==g?g.length:0,x=$.get(i),b=m.state.lights;if(!0===z&&(!0===H||e!==M)){let t=e===M&&i.id===S;he.setState(i,e,t)}let _=!1;i.version===x.__version?(x.needsLights&&x.lightsStateVersion!==b.state.version||x.outputColorSpace!==o||r.isInstancedMesh&&!1===x.instancing||!r.isInstancedMesh&&!0===x.instancing||r.isSkinnedMesh&&!1===x.skinning||!r.isSkinnedMesh&&!0===x.skinning||x.envMap!==l||!0===i.fog&&x.fog!==a||void 0!==x.numClippingPlanes&&(x.numClippingPlanes!==he.numPlanes||x.numIntersection!==he.numIntersection)||x.vertexAlphas!==h||x.vertexTangents!==c||x.morphTargets!==u||x.morphNormals!==d||x.morphColors!==p||x.toneMapping!==f||!0===J.isWebGL2&&x.morphTargetsCount!==v)&&(_=!0):(_=!0,x.__version=i.version);let E=x.currentProgram;!0===_&&(E=ke(i,t,r));let T=!1,A=!1,C=!1,P=E.getUniforms(),R=x.uniforms;if(Z.useProgram(E.program)&&(T=!0,A=!0,C=!0),i.id!==S&&(S=i.id,A=!0),T||M!==e){if(P.setValue(ye,"projectionMatrix",e.projectionMatrix),J.logarithmicDepthBuffer&&P.setValue(ye,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),M!==e&&(M=e,A=!0,C=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshStandardMaterial||i.envMap){let t=P.map.cameraPosition;void 0!==t&&t.setValue(ye,W.setFromMatrixPosition(e.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&P.setValue(ye,"isOrthographic",!0===e.isOrthographicCamera),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.isShadowMaterial||r.isSkinnedMesh)&&P.setValue(ye,"viewMatrix",e.matrixWorldInverse)}if(r.isSkinnedMesh){P.setOptional(ye,r,"bindMatrix"),P.setOptional(ye,r,"bindMatrixInverse");let e=r.skeleton;e&&(J.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),P.setValue(ye,"boneTexture",e.boneTexture,Q),P.setValue(ye,"boneTextureSize",e.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let O=n.morphAttributes;if((void 0!==O.position||void 0!==O.normal||void 0!==O.color&&!0===J.isWebGL2)&&de.update(r,n,E),(A||x.receiveShadow!==r.receiveShadow)&&(x.receiveShadow=r.receiveShadow,P.setValue(ye,"receiveShadow",r.receiveShadow)),i.isMeshGouraudMaterial&&null!==i.envMap&&(R.envMap.value=l,R.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1),A&&(P.setValue(ye,"toneMappingExposure",y.toneMappingExposure),x.needsLights&&function(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}(R,C),a&&!0===i.fog&&se.refreshFogUniforms(R,a),se.refreshMaterialUniforms(R,i,I,L,V),rv.upload(ye,x.uniformsList,R,Q)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(rv.upload(ye,x.uniformsList,R,Q),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&P.setValue(ye,"center",r.center),P.setValue(ye,"modelViewMatrix",r.modelViewMatrix),P.setValue(ye,"normalMatrix",r.normalMatrix),P.setValue(ye,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){let e=i.uniformsGroups;for(let t=0,n=e.length;t0&&function(e,t,n,i){let r=J.isWebGL2;null===V&&(V=new sr(1,1,{generateMipmaps:!0,type:q.has("EXT_color_buffer_half_float")?Rr:Ec,minFilter:Ua,samples:r?4:0})),y.getDrawingBufferSize(G),r?V.setSize(G.x,G.y):V.setSize(yR(G.x),yR(G.y));let a=y.getRenderTarget();y.setRenderTarget(V),y.getClearColor(C),P=y.getClearAlpha(),P<1&&y.setClearColor(16777215,.5),y.clear();let s=y.toneMapping;y.toneMapping=bu,Ie(e,n,i),Q.updateMultisampleRenderTarget(V),Q.updateRenderTargetMipmap(V);let o=!1;for(let l=0,h=t.length;l0&&Ie(r,t,n),a.length>0&&Ie(a,t,n),s.length>0&&Ie(s,t,n),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function Ie(e,t,n){let i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,a=e.length;r0?v[v.length-1]:null,g.pop(),f=g.length>0?g[g.length-1]:null},this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return _},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(e,t,n){$.get(e.texture).__webglTexture=t,$.get(e.depthTexture).__webglTexture=n;let i=$.get(e);i.__hasExternalTextures=!0,i.__hasExternalTextures&&(i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===q.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){let n=$.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){w=e,b=t,_=n;let i=!0,r=null,a=!1,s=!1;if(e){let n=$.get(e);void 0!==n.__useDefaultFramebuffer?(Z.bindFramebuffer(ye.FRAMEBUFFER,null),i=!1):void 0===n.__webglFramebuffer?Q.setupRenderTarget(e):n.__hasExternalTextures&&Q.rebindTextures(e,$.get(e.texture).__webglTexture,$.get(e.depthTexture).__webglTexture);let o=e.texture;(o.isData3DTexture||o.isDataArrayTexture||o.isCompressedArrayTexture)&&(s=!0);let l=$.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=l[t],a=!0):r=J.isWebGL2&&e.samples>0&&!1===Q.useMultisampledRTT(e)?$.get(e).__webglMultisampledFramebuffer:l,E.copy(e.viewport),T.copy(e.scissor),A=e.scissorTest}else E.copy(N).multiplyScalar(I).floor(),T.copy(F).multiplyScalar(I).floor(),A=U;if(Z.bindFramebuffer(ye.FRAMEBUFFER,r)&&J.drawBuffers&&i&&Z.drawBuffers(e,r),Z.viewport(E),Z.scissor(T),Z.setScissorTest(A),a){let i=$.get(e.texture);ye.framebufferTexture2D(ye.FRAMEBUFFER,ye.COLOR_ATTACHMENT0,ye.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(s){let i=$.get(e.texture),r=t||0;ye.framebufferTextureLayer(ye.FRAMEBUFFER,ye.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}S=-1},this.readRenderTargetPixels=function(e,t,n,i,r,a,s){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=$.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(o=o[s]),o){Z.bindFramebuffer(ye.FRAMEBUFFER,o);try{let s=e.texture,o=s.format,l=s.type;if(o!==ea&&me.convert(o)!==ye.getParameter(ye.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");let h=l===Rr&&(q.has("EXT_color_buffer_half_float")||J.isWebGL2&&q.has("EXT_color_buffer_float"));if(!(l===Ec||me.convert(l)===ye.getParameter(ye.IMPLEMENTATION_COLOR_READ_TYPE)||l===ga&&(J.isWebGL2||q.has("OES_texture_float")||q.has("WEBGL_color_buffer_float"))||h))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&ye.readPixels(t,n,i,r,me.convert(o),me.convert(l),a)}finally{let e=null!==w?$.get(w).__webglFramebuffer:null;Z.bindFramebuffer(ye.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){let i=Math.pow(2,-n),r=Math.floor(t.image.width*i),a=Math.floor(t.image.height*i);Q.setTexture2D(t,0),ye.copyTexSubImage2D(ye.TEXTURE_2D,n,0,0,e.x,e.y,r,a),Z.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){let r=t.image.width,a=t.image.height,s=me.convert(n.format),o=me.convert(n.type);Q.setTexture2D(n,0),ye.pixelStorei(ye.UNPACK_FLIP_Y_WEBGL,n.flipY),ye.pixelStorei(ye.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),ye.pixelStorei(ye.UNPACK_ALIGNMENT,n.unpackAlignment),t.isDataTexture?ye.texSubImage2D(ye.TEXTURE_2D,i,e.x,e.y,r,a,s,o,t.image.data):t.isCompressedTexture?ye.compressedTexSubImage2D(ye.TEXTURE_2D,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,s,t.mipmaps[0].data):ye.texSubImage2D(ye.TEXTURE_2D,i,e.x,e.y,s,o,t.image),0===i&&n.generateMipmaps&&ye.generateMipmap(ye.TEXTURE_2D),Z.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i,r=0){if(y.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");let a,s=e.max.x-e.min.x+1,o=e.max.y-e.min.y+1,l=e.max.z-e.min.z+1,h=me.convert(i.format),c=me.convert(i.type);if(i.isData3DTexture)Q.setTexture3D(i,0),a=ye.TEXTURE_3D;else{if(!i.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");Q.setTexture2DArray(i,0),a=ye.TEXTURE_2D_ARRAY}ye.pixelStorei(ye.UNPACK_FLIP_Y_WEBGL,i.flipY),ye.pixelStorei(ye.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),ye.pixelStorei(ye.UNPACK_ALIGNMENT,i.unpackAlignment);let u=ye.getParameter(ye.UNPACK_ROW_LENGTH),d=ye.getParameter(ye.UNPACK_IMAGE_HEIGHT),p=ye.getParameter(ye.UNPACK_SKIP_PIXELS),f=ye.getParameter(ye.UNPACK_SKIP_ROWS),m=ye.getParameter(ye.UNPACK_SKIP_IMAGES),g=n.isCompressedTexture?n.mipmaps[0]:n.image;ye.pixelStorei(ye.UNPACK_ROW_LENGTH,g.width),ye.pixelStorei(ye.UNPACK_IMAGE_HEIGHT,g.height),ye.pixelStorei(ye.UNPACK_SKIP_PIXELS,e.min.x),ye.pixelStorei(ye.UNPACK_SKIP_ROWS,e.min.y),ye.pixelStorei(ye.UNPACK_SKIP_IMAGES,e.min.z),n.isDataTexture||n.isData3DTexture?ye.texSubImage3D(a,r,t.x,t.y,t.z,s,o,l,h,c,g.data):n.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ye.compressedTexSubImage3D(a,r,t.x,t.y,t.z,s,o,l,h,g.data)):ye.texSubImage3D(a,r,t.x,t.y,t.z,s,o,l,h,c,g),ye.pixelStorei(ye.UNPACK_ROW_LENGTH,u),ye.pixelStorei(ye.UNPACK_IMAGE_HEIGHT,d),ye.pixelStorei(ye.UNPACK_SKIP_PIXELS,p),ye.pixelStorei(ye.UNPACK_SKIP_ROWS,f),ye.pixelStorei(ye.UNPACK_SKIP_IMAGES,m),0===r&&i.generateMipmaps&&ye.generateMipmap(a),Z.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?Q.setTextureCube(e,0):e.isData3DTexture?Q.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?Q.setTexture2DArray(e,0):Q.setTexture2D(e,0),Z.unbindTexture()},this.resetState=function(){b=0,_=0,w=null,Z.reset(),ge.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return xu}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===tn?_u:GU}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===_u?tn:Ha}},_R=class extends Ms{};_R.prototype.isWebGL1Renderer=!0;var ov=class{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new ct(e),this.density=t}clone(){return new ov(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}},Su=class{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new ct(e),this.near=t,this.far=n}clone(){return new Su(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},_i=class extends on{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t}},Xh=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=db,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Wo()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;ie.far||t.push({distance:o,point:Kx.clone(),uv:Zr.getInterpolation(Kx,zM,Qx,GM,Vce,qN,zce,new be),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}};function qM(e,t,n,i,r,a){Z0.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?(Jx.x=a*Z0.x-r*Z0.y,Jx.y=r*Z0.x+a*Z0.y):Jx.copy(Z0),e.copy(t),e.x+=Jx.x,e.y+=Jx.y,e.applyMatrix4(Ihe)}var WM=new O,Gce=new O,wR=class extends on{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let n=0,i=t.length;n0){let n,i;for(n=1,i=t.length;n0){WM.setFromMatrixPosition(this.matrixWorld);let n=e.ray.origin.distanceTo(WM);this.getObjectForDistance(n).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){WM.setFromMatrixPosition(e.matrixWorld),Gce.setFromMatrixPosition(this.matrixWorld);let n,i,r=WM.distanceTo(Gce)/e.zoom;for(t[0].object.visible=!0,n=1,i=t.length;n=e))break;t[n-1].object.visible=!1,t[n].object.visible=!0}for(this._currentLevel=n-1;no)continue;u.applyMatrix4(this.matrixWorld);let r=e.ray.origin.distanceTo(u);re.far||t.push({distance:r,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}else for(let m=Math.max(0,a.start),g=Math.min(f.count,a.start+a.count)-1;mo)continue;u.applyMatrix4(this.matrixWorld);let n=e.ray.origin.distanceTo(u);ne.far||t.push({distance:n,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e0){let n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er.far)return;a.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:t,face:null,object:s})}}var $B=class extends qr{constructor(e,t,n,i,r,a,s,o,l){super(e,t,n,i,r,a,s,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==a?a:Ir,this.magFilter=void 0!==r?r:Ir,this.generateMipmaps=!1;let h=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){h.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e==0&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},ZB=class extends qr{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Qr,this.minFilter=Qr,this.generateMipmaps=!1,this.needsUpdate=!0}},$h=class extends qr{constructor(e,t,n,i,r,a,s,o,l,h,c,u){super(null,a,s,o,l,h,i,r,c,u),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},KB=class extends $h{constructor(e,t,n,i,r,a){super(e,t,n,r,a),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Ai}},Eb=class extends qr{constructor(e,t,n,i,r,a,s,o,l){super(e,t,n,i,r,a,s,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Va=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t,n=[],i=this.getPoint(0),r=0;n.push(0);for(let a=1;a<=e;a++)t=this.getPoint(a/e),r+=t.distanceTo(i),n.push(r),i=t;return this.cacheArcLengths=n,n}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let n,i=this.getLengths(),r=0,a=i.length;n=t||e*i[a-1];let s,o=0,l=a-1;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),s=i[r]-n,s<0)o=r+1;else{if(!(s>0)){l=r;break}l=r-1}if(r=l,i[r]===n)return r/(a-1);let h=i[r];return(r+(n-h)/(i[r+1]-h))/(a-1)}getTangent(e,t){let n=e-1e-4,i=e+1e-4;n<0&&(n=0),i>1&&(i=1);let r=this.getPoint(n),a=this.getPoint(i),s=t||(r.isVector2?new be:new O);return s.copy(a).sub(r).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){let n=new O,i=[],r=[],a=[],s=new O,o=new Qe;for(let d=0;d<=e;d++){let t=d/e;i[d]=this.getTangentAt(t,new O)}r[0]=new O,a[0]=new O;let l=Number.MAX_VALUE,h=Math.abs(i[0].x),c=Math.abs(i[0].y),u=Math.abs(i[0].z);h<=l&&(l=h,n.set(1,0,0)),c<=l&&(l=c,n.set(0,1,0)),u<=l&&n.set(0,0,1),s.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],s),a[0].crossVectors(i[0],r[0]);for(let d=1;d<=e;d++){if(r[d]=r[d-1].clone(),a[d]=a[d-1].clone(),s.crossVectors(i[d-1],i[d]),s.length()>Number.EPSILON){s.normalize();let e=Math.acos(ls(i[d-1].dot(i[d]),-1,1));r[d].applyMatrix4(o.makeRotationAxis(s,e))}a[d].crossVectors(i[d],r[d])}if(!0===t){let t=Math.acos(ls(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(s.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],t*n)),a[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:a}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Zh=class extends Va{constructor(e=0,t=0,n=1,i=1,r=0,a=2*Math.PI,s=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=s,this.aRotation=o}getPoint(e,t){let n=t||new be,i=2*Math.PI,r=this.aEndAngle-this.aStartAngle,a=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(l)/s)+1)*s:0===h&&l===s-1&&(l=s-2,h=1),this.closed||l>0?n=a[(l-1)%s]:(ZM.subVectors(a[0],a[1]).add(a[0]),n=ZM);let c=a[l%s],u=a[(l+1)%s];if(this.closed||l+2i.length-2?i.length-1:a+1],c=i[a>i.length-3?i.length-1:a+2];return n.set(sue(s,o.x,l.x,h.x,c.x),sue(s,o.y,l.y,h.y,c.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){let e=i[r]-n,a=this.curves[r],s=a.getLength(),o=0===s?0:1-e/s;return a.getPointAt(o,t)}r++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,i=this.curves.length;n1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){let e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},ym=class extends Dt{constructor(e=[new be(0,-.5),new be(.5,0),new be(0,.5)],t=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=ls(i,0,2*Math.PI);let r=[],a=[],s=[],o=[],l=[],h=1/t,c=new O,u=new be,d=new O,p=new O,f=new O,m=0,g=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,d.x=1*g,d.y=-m,d.z=0*g,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,d.x=1*g,d.y=-m,d.z=0*g,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let v=0;v<=t;v++){let r=n+v*h*i,d=Math.sin(r),p=Math.cos(r);for(let n=0;n<=e.length-1;n++){c.x=e[n].x*d,c.y=e[n].y,c.z=e[n].x*p,a.push(c.x,c.y,c.z),u.x=v/t,u.y=n/(e.length-1),s.push(u.x,u.y);let i=o[3*n+0]*d,r=o[3*n+1],h=o[3*n+0]*p;l.push(i,r,h)}}for(let v=0;v0&&v(!0),t>0&&v(!1)),this.setIndex(h),this.setAttribute("position",new Bt(c,3)),this.setAttribute("normal",new Bt(u,3)),this.setAttribute("uv",new Bt(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new wc(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},dv=class extends wc{constructor(e=1,t=1,n=32,i=1,r=!1,a=0,s=2*Math.PI){super(0,e,t,n,i,r,a,s),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:s}}static fromJSON(e){return new dv(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Au=class extends Dt{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};let r=[],a=[];function s(e,t,n,i){let r=i+1,a=[];for(let s=0;s<=r;s++){a[s]=[];let i=e.clone().lerp(n,s/r),o=t.clone().lerp(n,s/r),l=r-s;for(let e=0;e<=l;e++)a[s][e]=0===e&&s===r?i:i.clone().lerp(o,e/l)}for(let s=0;s.9&&s<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),i<.2&&(a[e+4]+=1))}}()}(),this.setAttribute("position",new Bt(r,3)),this.setAttribute("normal",new Bt(r.slice(),3)),this.setAttribute("uv",new Bt(a,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Au(e.vertices,e.indices,e.radius,e.details)}},fv=class extends Au{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new fv(e.radius,e.detail)}},KM=new O,JM=new O,KN=new O,QM=new Zr,Cu=class extends Dt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){let n=Math.pow(10,4),i=Math.cos(dm*t),r=e.getIndex(),a=e.getAttribute("position"),s=r?r.count:a.count,o=[0,0,0],l=["a","b","c"],h=new Array(3),c={},u=[];for(let e=0;e80*n){i=a=e[0],r=s=e[1];for(let t=n;ta&&(a=o),l>s&&(s=l);h=Math.max(a-i,s-r),h=0!==h?32767/h:0}return Sb(d,p,n,i,r,h,0),p}};function Lhe(e,t,n,i,r){let a,s;if(r===Ilt(e,t,n,i)>0)for(a=t;a=t;a-=i)s=aue(a,e[a],e[a+1],s);return s&&KR(s,s.next)&&(Rb(s),s=s.next),s}function xm(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!KR(i,i.next)&&0!==Zi(i.prev,i,i.next))i=i.next;else{if(Rb(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function Sb(e,t,n,i,r,a,s){if(!e)return;!s&&a&&Slt(e,i,r,a);let o,l,h=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,a?vlt(e,i,r,a):glt(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),Rb(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?Sb(e=ylt(xm(e),t,n),t,n,i,r,a,2):2===s&&xlt(e,t,n,i,r,a):Sb(xm(e),t,n,i,r,a,1);break}}function glt(e){let t=e.prev,n=e,i=e.next;if(Zi(t,n,i)>=0)return!1;let r=t.x,a=n.x,s=i.x,o=t.y,l=n.y,h=i.y,c=ra?r>s?r:s:a>s?a:s,p=o>l?o>h?o:h:l>h?l:h,f=i.next;for(;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&tv(r,o,a,l,s,h,f.x,f.y)&&Zi(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function vlt(e,t,n,i){let r=e.prev,a=e,s=e.next;if(Zi(r,a,s)>=0)return!1;let o=r.x,l=a.x,h=s.x,c=r.y,u=a.y,d=s.y,p=ol?o>h?o:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,v=JB(p,f,t,n,i),y=JB(m,g,t,n,i),x=e.prevZ,b=e.nextZ;for(;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&tv(o,c,l,u,h,d,x.x,x.y)&&Zi(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==s&&tv(o,c,l,u,h,d,b.x,b.y)&&Zi(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&tv(o,c,l,u,h,d,x.x,x.y)&&Zi(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==s&&tv(o,c,l,u,h,d,b.x,b.y)&&Zi(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function ylt(e,t,n){let i=e;do{let r=i.prev,a=i.next.next;!KR(r,a)&&Dhe(r,i,i.next,a)&&Mb(r,a)&&Mb(a,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(a.i/n|0),Rb(i),Rb(i.next),i=e=a),i=i.next}while(i!==e);return xm(i)}function xlt(e,t,n,i,r,a){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&Alt(s,e)){let o=Ohe(s,e);return s=xm(s,s.next),o=xm(o,o.next),Sb(s,t,n,i,r,a,0),void Sb(o,t,n,i,r,a,0)}e=e.next}s=s.next}while(s!==e)}function blt(e,t,n,i){let r,a,s,o,l,h=[];for(r=0,a=t.length;r=i.next.y&&i.next.y!==i.y){let e=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=a&&e>r&&(r=e,n=i.x=i.x&&i.x>=h&&a!==i.x&&tv(sn.x||i.x===n.x&&wlt(n,i)))&&(n=i,u=o)),i=i.next}while(i!==l);return n}function wlt(e,t){return Zi(e.prev,e,t.prev)<0&&Zi(t.next,e,e.next)<0}function Slt(e,t,n,i){let r=e;do{0===r.z&&(r.z=JB(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,Mlt(r)}function Mlt(e){let t,n,i,r,a,s,o,l,h=1;do{for(n=e,e=null,a=null,s=0;n;){for(s++,i=n,o=0,t=0;t0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,l--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,h*=2}while(s>1);return e}function JB(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Rlt(e){let t=e,n=e;do{(t.x=(e-s)*(a-o)&&(e-s)*(i-o)>=(n-s)*(t-o)&&(n-s)*(a-o)>=(r-s)*(i-o)}function Alt(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Clt(e,t)&&(Mb(e,t)&&Mb(t,e)&&Plt(e,t)&&(Zi(e.prev,e,t.prev)||Zi(e,t.prev,t))||KR(e,t)&&Zi(e.prev,e,e.next)>0&&Zi(t.prev,t,t.next)>0)}function Zi(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function KR(e,t){return e.x===t.x&&e.y===t.y}function Dhe(e,t,n,i){let r=tR(Zi(e,t,n)),a=tR(Zi(e,t,i)),s=tR(Zi(n,i,e)),o=tR(Zi(n,i,t));return!!(r!==a&&s!==o||0===r&&eR(e,n,t)||0===a&&eR(e,i,t)||0===s&&eR(n,e,i)||0===o&&eR(n,t,i))}function eR(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function tR(e){return e>0?1:e<0?-1:0}function Clt(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Dhe(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Mb(e,t){return Zi(e.prev,e,e.next)<0?Zi(e,t,e.next)>=0&&Zi(e,e.prev,t)>=0:Zi(e,t,e.prev)<0||Zi(e,e.next,t)<0}function Plt(e,t){let n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}function Ohe(e,t){let n=new QB(e.i,e.x,e.y),i=new QB(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function aue(e,t,n,i){let r=new QB(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Rb(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function QB(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Ilt(e,t,n,i){let r=0;for(let a=t,s=n-i;a2&&e[t-1].equals(e[0])&&e.pop()}function lue(e,t){for(let n=0;nNumber.EPSILON){let u=Math.sqrt(c),d=Math.sqrt(l*l+h*h),p=t.x-o/u,f=t.y+s/u,m=((n.x-h/d-p)*h-(n.y+l/d-f)*l)/(s*h-o*l);i=p+s*m-e.x,r=f+o*m-e.y;let g=i*i+r*r;if(g<=2)return new be(i,r);a=Math.sqrt(g/2)}else{let e=!1;s>Number.EPSILON?l>Number.EPSILON&&(e=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(h)&&(e=!0),e?(i=-o,r=s,a=Math.sqrt(c)):(i=s,r=o,a=Math.sqrt(c/2))}return new be(i/a,r/a)}let L=[];for(let t=0,n=T.length,i=n-1,r=t+1;t=0;t--){let e=t/y,n=m*Math.cos(e*Math.PI/2),i=g*Math.sin(e*Math.PI/2)+v;for(let t=0,r=T.length;t=0;){let i=n,r=n-1;r<0&&(r=e.length-1);for(let e=0,n=d+2*y;e0)&&d.push(t,i,s),(g!==n-1||o0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},na=class extends vr{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ct(16777215),this.specular=new ct(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ct(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mf,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Nb,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},LR=class extends vr{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ct(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ct(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mf,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},df=class extends vr{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mf,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},Pu=class extends vr{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ct(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ct(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mf,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Nb,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},DR=class extends vr{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ct(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mf,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}},Iu=class extends Gn{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};function wl(e,t,n){return $U(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)}function um(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function $U(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function khe(e){let t=e.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort((function(t,n){return e[t]-e[n]})),n}function eU(e,t,n){let i=e.length,r=new e.constructor(i);for(let a=0,s=0;s!==i;++a){let i=n[a]*t;for(let n=0;n!==t;++n)r[s++]=e[i+n]}return r}function ZU(e,t,n,i){let r=1,a=e[0];for(;void 0!==a&&void 0===a[i];)a=e[r++];if(void 0===a)return;let s=a[i];if(void 0!==s)if(Array.isArray(s))do{s=a[i],void 0!==s&&(t.push(a.time),n.push.apply(n,s)),a=e[r++]}while(void 0!==a);else if(void 0!==s.toArray)do{s=a[i],void 0!==s&&(t.push(a.time),s.toArray(n,n.length)),a=e[r++]}while(void 0!==a);else do{s=a[i],void 0!==s&&(t.push(a.time),n.push(s)),a=e[r++]}while(void 0!==a)}function klt(e,t,n,i,r=30){let a=e.clone();a.name=t;let s=[];for(let l=0;l=i)){o.push(e.times[a]);for(let n=0;na.tracks[l].times[0]&&(o=a.tracks[l].times[0]);for(let l=0;l=t.times[d]){let e=d*l+o,n=e+l-o;u=wl(t.values,e,n)}else{let e=t.createInterpolant(),n=o,i=l-o;e.evaluate(a),u=wl(e.resultBuffer,n,i)}"quaternion"===i&&(new hr).fromArray(u).normalize().conjugate().toArray(u);let p=r.times.length;for(let e=0;e=r)break e;{let s=t[1];e=r)break t}a=n,n=0}}for(;n>>1;et;)--a;if(++a,0!==r||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);let e=this.getValueSize();this.times=wl(n,r,a),this.values=wl(this.values,r*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let s=0;s!==r;s++){let t=n[s];if("number"==typeof t&&isNaN(t)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,s,t),e=!1;break}if(null!==a&&a>t){console.error("THREE.KeyframeTrack: Out of order keys.",this,s,t,a),e=!1;break}a=t}if(void 0!==i&&$U(i))for(let s=0,o=i.length;s!==o;++s){let t=i[s];if(isNaN(t)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,s,t),e=!1;break}}return e}optimize(){let e=wl(this.times),t=wl(this.values),n=this.getValueSize(),i=this.getInterpolation()===pR,r=e.length-1,a=1;for(let s=1;s0){e[a]=e[r];for(let e=r*n,i=a*n,s=0;s!==n;++s)t[i+s]=t[e+s];++a}return a!==e.length?(this.times=wl(e,0,a),this.values=wl(t,0,a*n)):(this.times=e,this.values=t),this}clone(){let e=wl(this.times,0),t=wl(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}};Yo.prototype.TimeBufferType=Float32Array,Yo.prototype.ValueBufferType=Float32Array,Yo.prototype.DefaultInterpolation=wu;var Jh=class extends Yo{};Jh.prototype.ValueTypeName="bool",Jh.prototype.ValueBufferType=Array,Jh.prototype.DefaultInterpolation=qh,Jh.prototype.InterpolantFactoryMethodLinear=void 0,Jh.prototype.InterpolantFactoryMethodSmooth=void 0;var Cb=class extends Yo{};Cb.prototype.ValueTypeName="color";var Cl=class extends Yo{};Cl.prototype.ValueTypeName="number";var FR=class extends Kh{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=(n-t)/(i-t),l=e*s;for(let h=l+s;l!==h;l+=4)hr.slerpFlat(r,0,a,l-s,a,l,o);return r}},Ga=class extends Yo{InterpolantFactoryMethodLinear(e){return new FR(this.times,this.values,this.getValueSize(),e)}};Ga.prototype.ValueTypeName="quaternion",Ga.prototype.DefaultInterpolation=wu,Ga.prototype.InterpolantFactoryMethodSmooth=void 0;var Qh=class extends Yo{};Qh.prototype.ValueTypeName="string",Qh.prototype.ValueBufferType=Array,Qh.prototype.DefaultInterpolation=qh,Qh.prototype.InterpolantFactoryMethodLinear=void 0,Qh.prototype.InterpolantFactoryMethodSmooth=void 0;var ho=class extends Yo{};ho.prototype.ValueTypeName="vector";var fo=class{constructor(e,t=-1,n,i=$R){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Wo(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,s=n.length;a!==s;++a)t.push(Ult(n[a]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,a=n.length;r!==a;++r)t.push(Yo.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,a=[];for(let s=0;s1){let e=n[1],r=i[e];r||(i[e]=r=[]),r.push(t)}}let a=[];for(let s in i)a.push(this.CreateFromMorphTargetSequence(s,i[s],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(e,t,n,i,r){if(0!==n.length){let a=[],s=[];ZU(n,a,s,i),0!==a.length&&r.push(new e(t,a,s))}},i=[],r=e.name||"default",a=e.fps||30,s=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==Bh[e])return void Bh[e].push({onLoad:t,onProgress:n,onError:i});Bh[e]=[],Bh[e].push({onLoad:t,onProgress:n,onError:i});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),s=this.mimeType,o=this.responseType;fetch(a).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;let n=Bh[e],i=t.body.getReader(),r=t.headers.get("Content-Length")||t.headers.get("X-File-Size"),a=r?parseInt(r):0,s=0!==a,o=0,l=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{o+=r.byteLength;let i=new ProgressEvent("progress",{lengthComputable:s,loaded:o,total:a});for(let e=0,t=n.length;e{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,s)));case"json":return e.json();default:if(void 0===s)return e.text();{let t=/charset="?([^;"\s]*)"?/i.exec(s),n=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(n);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{Em.add(e,t);let n=Bh[e];delete Bh[e];for(let e=0,i=n.length;e{let n=Bh[e];if(void 0===n)throw this.manager.itemError(e),t;delete Bh[e];for(let e=0,i=n.length;e{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},nU=class extends _r{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new Kr(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e){let t=[];for(let n=0;n0:i.vertexColors=e.vertexColors),void 0!==e.uniforms)for(let r in e.uniforms){let t=e.uniforms[r];switch(i.uniforms[r]={},t.type){case"t":i.uniforms[r].value=n(t.value);break;case"c":i.uniforms[r].value=(new ct).setHex(t.value);break;case"v2":i.uniforms[r].value=(new be).fromArray(t.value);break;case"v3":i.uniforms[r].value=(new O).fromArray(t.value);break;case"v4":i.uniforms[r].value=(new mr).fromArray(t.value);break;case"m3":i.uniforms[r].value=(new Ln).fromArray(t.value);break;case"m4":i.uniforms[r].value=(new Qe).fromArray(t.value);break;default:i.uniforms[r].value=t.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(i.glslVersion=e.glslVersion),void 0!==e.extensions)for(let r in e.extensions)i.extensions[r]=e.extensions[r];if(void 0!==e.lights&&(i.lights=e.lights),void 0!==e.clipping&&(i.clipping=e.clipping),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=n(e.map)),void 0!==e.matcap&&(i.matcap=n(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),i.normalScale=(new be).fromArray(t)}return void 0!==e.displacementMap&&(i.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=n(e.specularMap)),void 0!==e.specularIntensityMap&&(i.specularIntensityMap=n(e.specularIntensityMap)),void 0!==e.specularColorMap&&(i.specularColorMap=n(e.specularColorMap)),void 0!==e.envMap&&(i.envMap=n(e.envMap)),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=(new be).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(i.iridescenceMap=n(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(i.transmissionMap=n(e.transmissionMap)),void 0!==e.thicknessMap&&(i.thicknessMap=n(e.thicknessMap)),void 0!==e.anisotropyMap&&(i.anisotropyMap=n(e.anisotropyMap)),void 0!==e.sheenColorMap&&(i.sheenColorMap=n(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){return new{ShadowMaterial:PR,SpriteMaterial:bb,RawShaderMaterial:IR,ShaderMaterial:cn,PointsMaterial:xi,MeshPhysicalMaterial:Xo,MeshStandardMaterial:hf,MeshPhongMaterial:na,MeshToonMaterial:LR,MeshNormalMaterial:df,MeshLambertMaterial:Pu,MeshDepthMaterial:Tc,MeshDistanceMaterial:xb,MeshBasicMaterial:ln,MeshMatcapMaterial:DR,LineDashedMaterial:Iu,LineBasicMaterial:Gn,Material:vr}[e]}},ra=class{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;n0){let i=new Lu(t);n=new _m(i),n.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t0){t=new _m(this.manager),t.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(n[o]!==n[o+t]){s.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,a=i;r!==a;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let a=0;a!==r;++a)e[t+a]=e[n+a]}_slerp(e,t,n,i){hr.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let a=this._workIndex*r;hr.multiplyQuaternionsFlat(e,a,e,t,e,n),hr.slerpFlat(e,t,e,t,e,a,i)}_lerp(e,t,n,i,r){let a=1-i;for(let s=0;s!==r;++s){let r=t+s;e[r]=e[r]*a+e[n+s]*i}}_lerpAdditive(e,t,n,i,r){for(let a=0;a!==r;++a){let r=t+a;e[r]=e[r]+e[n+a]*i}}},KU="\\[\\]\\.:\\/",Glt=new RegExp("["+KU+"]","g"),JU="[^"+KU+"]",qlt="[^"+KU.replace("\\.","")+"]",Wlt=/((?:WC+[\/:])*)/.source.replace("WC",JU),jlt=/(WCOD+)?/.source.replace("WCOD",qlt),Xlt=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",JU),Ylt=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",JU),$lt=new RegExp("^"+Wlt+jlt+Xlt+Ylt+"$"),Zlt=["material","materials","bones","map"],mU=class{constructor(e,t,n){let i=n||Jn.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},Jn=class{constructor(e,t,n){this.path=t,this.parsedPath=n||Jn.parseTrackName(t),this.node=Jn.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Jn.Composite(e,t,n):new Jn(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(Glt,"")}static parseTrackName(e){let t=$lt.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){let e=n.nodeName.substring(i+1);-1!==Zlt.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){let n=function(e){for(let i=0;i=r){let a=r++,h=e[a];t[h.uuid]=l,e[l]=h,t[o]=a,e[a]=s;for(let e=0,t=i;e!==t;++e){let t=n[e],i=t[a],r=t[l];t[l]=i,t[a]=r}}}this.nCachedObjects_=r}uncache(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length,r=this.nCachedObjects_,a=e.length;for(let s=0,o=arguments.length;s!==o;++s){let o=arguments[s].uuid,l=t[o];if(void 0!==l)if(delete t[o],l0&&(t[s.uuid]=l),e[l]=s,e.pop();for(let e=0,t=i;e!==t;++e){let t=n[e];t[l]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){let n=this._bindingsIndicesByPath,i=n[e],r=this._bindings;if(void 0!==i)return r[i];let a=this._paths,s=this._parsedPaths,o=this._objects,l=o.length,h=this.nCachedObjects_,c=new Array(l);i=r.length,n[e]=i,a.push(e),s.push(t),r.push(c);for(let u=h,d=o.length;u!==d;++u){let n=o[u];c[u]=new Jn(n,e,t)}return c}unsubscribe_(e){let t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){let i=this._paths,r=this._parsedPaths,a=this._bindings,s=a.length-1,o=a[s];t[e[s]]=n,a[n]=o,a.pop(),r[n]=r[s],r.pop(),i[n]=i[s],i.pop()}}},GR=class{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,a=r.length,s=new Array(a),o={endingStart:lm,endingEnd:lm};for(let l=0;l!==a;++l){let e=r[l].createInterpolant(null);s[l]=e,e.settings=o}this._interpolantSettings=o,this._interpolants=s,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=lhe,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){let n=this._clip.duration,i=e._clip.duration,r=i/n,a=n/i;e.warp(1,r,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,a=this.timeScale,s=this._timeScaleInterpolant;null===s&&(s=i._lendControlInterpolant(),this._timeScaleInterpolant=s);let o=s.parameterPositions,l=s.sampleValues;return o[0]=r,o[1]=r+n,l[0]=e/a,l[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled)return void this._updateWeight(e);let r=this._startTime;if(null!==r){let i=(e-r)*n;i<0||0===n?t=0:(this._startTime=null,t=n*i)}t*=this._updateTimeScale(e);let a=this._updateTime(t),s=this._updateWeight(e);if(s>0){let e=this._interpolants,t=this._propertyBindings;if(this.blendMode===VU)for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(a),t[n].accumulateAdditive(s);else for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(a),t[n].accumulate(i,s)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(null!==n){let i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;null!==n&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,a=n===che;if(0===e)return-1===r?i:a&&1==(1&r)?t-i:i;if(n===ohe){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),i>=t||i<0){let n=Math.floor(i/t);i-=t*n,r+=Math.abs(n);let s=this.repetitions-r;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===s){let t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(a&&1==(1&r))return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;n?(i.endingStart=cm,i.endingEnd=cm):(i.endingStart=e?this.zeroSlopeAtStart?cm:lm:hb,i.endingEnd=t?this.zeroSlopeAtEnd?cm:lm:hb)}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);let s=a.parameterPositions,o=a.sampleValues;return s[0]=r,o[0]=t,s[1]=r+e,o[1]=n,this}},Klt=new Float32Array(1),vU=class extends jo{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,a=e._propertyBindings,s=e._interpolants,o=n.uuid,l=this._bindingsByRootAndName,h=l[o];void 0===h&&(h={},l[o]=h);for(let c=0;c!==r;++c){let e=i[c],r=e.name,l=h[r];if(void 0!==l)++l.referenceCount,a[c]=l;else{if(l=a[c],void 0!==l){null===l._cacheIndex&&(++l.referenceCount,this._addInactiveBinding(l,o,r));continue}let i=t&&t._propertyBindings[c].binding.parsedPath;l=new zR(Jn.create(n,r,i),e.ValueTypeName,e.getValueSize()),++l.referenceCount,this._addInactiveBinding(l,o,r),a[c]=l}s[c].resultBuffer=l.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){let t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return null!==t&&t=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(i,e,r,a);let s=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)s[l].apply(a);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,_ue).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Tue=new O,rR=new O,sa=class{constructor(e=new O,t=new O){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Tue.subVectors(e,this.start),rR.subVectors(this.end,this.start);let n=rR.dot(rR),i=rR.dot(Tue)/n;return t&&(i=ls(i,0,1)),i}closestPointToPoint(e,t,n){let i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}},wue=new O,TU=class extends on{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let n=new Dt,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,s=1,o=32;a1)for(let h=0;h.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Cue.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Cue,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},IU=class extends Wr{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=new Dt;n.setAttribute("position",new Bt(t,3)),n.setAttribute("color",new Bt([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(n,new Gn({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){let i=new ct,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},Sm=class{constructor(){this.type="ShapePath",this.color=new ct,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Ru,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,r,a){return this.currentPath.bezierCurveTo(e,t,n,i,r,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e,t){let n=t.length,i=!1;for(let r=n-1,a=0;aNumber.EPSILON){if(l<0&&(n=t[a],o=-o,s=t[r],l=-l),e.ys.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{let t=l*(e.x-n.x)-o*(e.y-n.y);if(0===t)return!0;if(t<0)continue;i=!i}}else{if(e.y!==n.y)continue;if(s.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=s.x)return!0}}return i}let n=qs.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,a,s,o=[];if(1===i.length)return a=i[0],s=new Ss,s.curves=a.curves,o.push(s),o;let l=!n(i[0].getPoints());l=e?!l:l;let h,c,u=[],d=[],p=[],f=0;d[f]=void 0,p[f]=[];for(let m=0,g=i.length;m1){let e=!1,n=0;for(let t=0,i=d.length;t0&&!1===e&&(p=u)}for(let m=0,g=d.length;ma)return!1;let o=n.ray.origin.distanceTo(Hhe);return!(on.far)&&(s.push({distance:o,point:Uhe.clone(),index:i,object:e}),!0)}ur.prototype.raycast=function(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),ku.copy(n.boundingSphere),ku.applyMatrix4(i),ku.radius+=r,!1===e.ray.intersectsSphere(ku))return;let s=r*r,o=this.isLineSegments?2:1,l=n.index,h=n.attributes.position,c=t.length;if(null!==l){let n=this.userData.batches;if(n&&n.length>0&&n[0].boundingSphere)for(let r=0;r=1))return}else for(let i=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count)-1;i=1))return}else{let n=this.userData.batches;if(n&&n.length>0&&n[0].boundingSphere)for(let r=0;r=1)return}else for(let i=Math.max(0,a.start),r=Math.min(h.count,a.start+a.count)-1;i=1)return}};var Vhe=Math.pow(2,-24),Cm=class{constructor(){}};function Il(e,t,n){return n.min.x=t[e],n.min.y=t[e+1],n.min.z=t[e+2],n.max.x=t[e+3],n.max.y=t[e+4],n.max.z=t[e+5],n}function QU(e){let t=-1,n=-1/0;for(let i=0;i<3;i++){let r=e[i+3]-e[i];r>n&&(n=r,t=i)}return t}function eH(e,t){t.set(e)}function tH(e,t,n){let i,r;for(let a=0;a<3;a++){let s=a+3;i=e[a],r=t[a],n[a]=ir?i:r}}function Ub(e,t,n){for(let i=0;i<3;i++){let r=t[e+2*i],a=t[e+2*i+1],s=r-a,o=r+a;sn[i+3]&&(n[i+3]=o)}}function Pv(e){let t=e[3]-e[0],n=e[4]-e[1],i=e[5]-e[2];return 2*(t*n+n*i+i*t)}function nct(e,t){if(!e.index){let n,i=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;n=i>65535?new Uint32Array(new r(4*i)):new Uint16Array(new r(2*i)),e.setIndex(new gn(n,1));for(let e=0;ee-t));for(let r=0;rl&&(l=r),v&&tf&&(f=t);let x=e[y+2],b=e[y+3],_=x-b,w=x+b;_h&&(h=w),v&&xm&&(m=x);let S=e[y+4],M=e[y+5],E=S-M,T=S+M;Ec&&(c=T),v&&Sg&&(g=S)}i[0]=a,i[1]=s,i[2]=o,i[3]=l,i[4]=h,i[5]=c,v&&(r[0]=u,r[1]=d,r[2]=p,r[3]=f,r[4]=m,r[5]=g)}function ict(e,t,n,i){let r=1/0,a=1/0,s=1/0,o=-1/0,l=-1/0,h=-1/0;for(let c=6*t,u=6*(t+n);co&&(o=t);let n=e[c+2];nl&&(l=n);let i=e[c+4];ih&&(h=i)}i[0]=r,i[1]=a,i[2]=s,i[3]=o,i[4]=l,i[5]=h}function sct(e,t,n,i,r){let a=n,s=n+i-1,o=r.pos,l=2*r.axis;for(;;){for(;a<=s&&t[6*a+l]=o;)s--;if(!(ae.candidate-t.candidate,gf=new Array(ed).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),QR=new Float32Array(6);function oct(e,t,n,i,r,a){let s=-1,o=0;if(0===a)s=QU(t),-1!==s&&(o=(t[s]+t[s+3])/2);else if(1===a)s=QU(e),-1!==s&&(o=lct(n,i,r,s));else if(2===a){let a=Pv(e),l=1.25*r,h=6*i,c=6*(i+r);for(let e=0;e<3;e++){let i=t[e],u=(t[e+3]-i)/ed;if(r=a.candidate?Ub(r,n,a.rightCacheBounds):(Ub(r,n,a.leftCacheBounds),a.count++)}}for(let n=0;n=ed&&(t=ed-1);let a=gf[t];a.count++,Ub(r,n,a.bounds)}let t=gf[ed-1];eH(t.bounds,t.rightCacheBounds);for(let e=ed-2;e>=0;e--){let t=gf[e],n=gf[e+1];tH(t.bounds,n.rightCacheBounds,t.rightCacheBounds)}let d=0;for(let n=0;nm&&(m=h),u>m&&(m=u);let g=(m-p)/2,v=2*i;a[f+v+0]=p+g,a[f+v+1]=g+(Math.abs(p)+g)*Vhe,pt[i+3]&&(t[i+3]=m)}}return a}function uct(e,t){function n(e){d&&d(e/p)}function i(t,r,d,p=null,m=0){if(!f&&m>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),d<=c||m>=l)return n(r+d),t.offset=r,t.count=d,t;let g=oct(t.boundingData,p,s,r,d,u);if(-1===g.axis)return n(r+d),t.offset=r,t.count=d,t;let v=sct(o,s,r,d,g);if(v===r||v===r+d)n(r+d),t.offset=r,t.count=d;else{t.splitAxis=g.axis;let e=new Cm,n=r,o=v-r;t.left=e,e.boundingData=new Float32Array(6),rH(s,n,o,e.boundingData,a),i(e,n,o,a,m+1);let l=new Cm,h=v,c=d-o;t.right=l,l.boundingData=new Float32Array(6),rH(s,h,c,l.boundingData,a),i(l,h,c,a,m+1)}return t}nct(e,t);let r=new Float32Array(6),a=new Float32Array(6),s=cct(e,r),o=e.index.array,l=t.maxDepth,h=t.verbose,c=t.maxLeafTris,u=t.strategy,d=t.onProgress,p=e.index.count/3,f=!1,m=[],g=rct(e);if(1===g.length){let e=g[0],t=new Cm;t.boundingData=r,ict(s,e.offset,e.count,a),i(t,e.offset,e.count,a),m.push(t)}else for(let v of g){let e=new Cm;e.boundingData=new Float32Array(6),rH(s,v.offset,v.count,e.boundingData,a),i(e,v.offset,v.count,a),m.push(e)}return m}function qhe(e,t){let n,i,r,a=uct(e,t),s=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;cMath.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[a+6]=n/4,n=h(n,s),i[a+7]=o,n}}}var go=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let r=0,a=e.length;ri?a:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let r=0,a=t.length;ri?s:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}};go.prototype.setFromBox=function(){let e=new O;return function(t,n){let i=n.min,r=n.max,a=1/0,s=-1/0;for(let o=0;o<=1;o++)for(let n=0;n<=1;n++)for(let l=0;l<=1;l++){e.x=i.x*o+r.x*(1-o),e.y=i.y*n+r.y*(1-n),e.z=i.z*l+r.z*(1-l);let h=t.dot(e);a=Math.min(h,a),s=Math.max(h,s)}this.min=a,this.max=s}}();var KIt=function(){let e=new go;return function(t,n){let i=t.points,r=t.satAxes,a=t.satBounds,s=n.points,o=n.satAxes,l=n.satBounds;for(let h=0;h<3;h++){let t=a[h],n=r[h];if(e.setFromPoints(n,s),t.isSeparated(e))return!1}for(let h=0;h<3;h++){let t=l[h],n=o[h];if(e.setFromPoints(n,i),t.isSeparated(e))return!1}}}(),hct=function(){let e=new O,t=new O,n=new O;return function(i,r,a){let s=i.start,o=e,l=r.start,h=t;n.subVectors(s,l),e.subVectors(i.end,i.start),t.subVectors(r.end,r.start);let c,u,d=n.dot(h),p=h.dot(o),f=h.dot(h),m=n.dot(o),g=o.dot(o)*f-p*p;c=0!==g?(d*p-m*f)/g:0,u=(d+c*p)/f,a.x=c,a.y=u}}(),Hb=function(){let e=new be,t=new O,n=new O;return function(i,r,a,s){hct(i,r,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1)return i.at(o,a),void r.at(l,s);if(o>=0&&o<=1)return l<0?r.at(0,s):r.at(1,s),void i.closestPointToPoint(s,!0,a);if(l>=0&&l<=1)return o<0?i.at(0,a):i.at(1,a),void r.closestPointToPoint(a,!0,s);{let e,h;e=o<0?i.start:i.end,h=l<0?r.start:r.end;let c=t,u=n;return i.closestPointToPoint(h,!0,t),r.closestPointToPoint(e,!0,n),c.distanceToSquared(h)<=u.distanceToSquared(e)?(a.copy(c),void s.copy(h)):(a.copy(e),void s.copy(u))}}}(),Whe=function(){let e=new O,t=new O,n=new Gr,i=new sa;return function(r,a){let{radius:s,center:o}=r,{a:l,b:h,c:c}=a;if(i.start=l,i.end=h,i.closestPointToPoint(o,!0,e).distanceTo(o)<=s||(i.start=l,i.end=c,i.closestPointToPoint(o,!0,e).distanceTo(o)<=s)||(i.start=h,i.end=c,i.closestPointToPoint(o,!0,e).distanceTo(o)<=s))return!0;let u=a.getPlane(n);if(Math.abs(u.distanceToPoint(o))<=s){let e=u.projectPoint(o,t);if(a.containsPoint(e))return!0}return!1}}(),dct=1e-15;function Iv(e){return Math.abs(e)new O)),this.satBounds=new Array(4).fill().map((()=>new go)),this.points=[this.a,this.b,this.c],this.sphere=new gr,this.plane=new Gr,this.needsUpdate=!0}intersectsSphere(e){return Whe(e,this)}update(){let e=this.a,t=this.b,n=this.c,i=this.points,r=this.satAxes,a=this.satBounds,s=r[0],o=a[0];this.getNormal(s),o.setFromPoints(s,i);let l=r[1],h=a[1];l.subVectors(e,t),h.setFromPoints(l,i);let c=r[2],u=a[2];c.subVectors(t,n),u.setFromPoints(c,i);let d=r[3],p=a[3];d.subVectors(n,e),p.setFromPoints(d,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(s,e),this.needsUpdate=!1}};vo.prototype.closestPointToSegment=function(){let e=new O,t=new O,n=new sa;return function(i,r=null,a=null){let s,{start:o,end:l}=i,h=this.points,c=1/0;for(let u=0;u<3;u++){let o=(u+1)%3;n.start.copy(h[u]),n.end.copy(h[o]),Hb(n,i,e,t),s=e.distanceToSquared(t),s1-1e-10){let e=this.satBounds,s=this.satAxes;n[0]=d.a,n[1]=d.b,n[2]=d.c;for(let t=0;t<4;t++){let r=e[t],a=s[t];if(i.setFromPoints(a,n),r.isSeparated(i))return!1}let o=d.satBounds,l=d.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let n=0;n<4;n++){let e=o[n],r=l[n];if(i.setFromPoints(r,t),e.isSeparated(i))return!1}for(let h=0;h<4;h++){let e=s[h];for(let s=0;s<4;s++){let o=l[s];if(a.crossVectors(e,o),i.setFromPoints(a,t),r.setFromPoints(a,n),i.isSeparated(r))return!1}}return p&&(f||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}{let e=this.points,t=!1,n=0;for(let o=0;o<3;o++){let i=e[o],r=e[(o+1)%3];h.start.copy(i),h.end.copy(r),h.delta(s);let a=t?c.start:c.end,l=Iv(g.distanceToPoint(i));if(Iv(g.normal.dot(s))&&l){c.copy(h),n=2;break}if((g.intersectLine(h,a)||l)&&!Iv(a.distanceTo(r))){if(n++,t)break;t=!0}}if(1===n&&d.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(2!==n)return!1;let i=d.points,r=!1,a=0;for(let s=0;s<3;s++){let e=i[s],t=i[(s+1)%3];h.start.copy(e),h.end.copy(t),h.delta(o);let n=r?u.start:u.end,l=Iv(m.distanceToPoint(e));if(Iv(m.normal.dot(o))&&l){u.copy(h),a=2;break}if((m.intersectLine(h,n)||l)&&!Iv(n.distanceTo(t))){if(a++,r)break;r=!0}}if(1===a&&this.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(2!==a)return!1;if(c.delta(s),u.delta(o),s.dot(o)<0){let e=u.start;u.start=u.end,u.end=e}let f=c.start.dot(s),v=c.end.dot(s),y=u.start.dot(s),x=u.end.dot(s);return(f===x||y===v||v0?p.start.copy(c.start):p.start.copy(u.start),l.subVectors(c.end,u.end),l.dot(s)<0?p.end.copy(c.end):p.end.copy(u.end)),!0)}}}(),vo.prototype.distanceToPoint=function(){let e=new O;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),vo.prototype.distanceToTriangle=function(){let e=new O,t=new O,n=["a","b","c"],i=new sa,r=new sa;return function(a,s=null,o=null){let l=s||o?i:null;if(this.intersectsTriangle(a,l))return(s||o)&&(s&&l.getCenter(s),o&&l.getCenter(o)),0;let h=1/0;for(let t=0;t<3;t++){let i,r=n[t],l=a[r];this.closestPointToPoint(l,e),i=l.distanceToSquared(e),inew O)),this.satAxes=new Array(3).fill().map((()=>new O)),this.satBounds=new Array(3).fill().map((()=>new go)),this.alignedSatBounds=new Array(3).fill().map((()=>new go)),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};yo.prototype.update=function(){let e=this.matrix,t=this.min,n=this.max,i=this.points;for(let l=0;l<=1;l++)for(let r=0;r<=1;r++)for(let a=0;a<=1;a++){let s=i[1*l|2*r|4*a];s.x=l?n.x:t.x,s.y=r?n.y:t.y,s.z=a?n.z:t.z,s.applyMatrix4(e)}let r=this.satBounds,a=this.satAxes,s=i[0];for(let l=0;l<3;l++){let e=a[l],t=r[l],n=i[1<new sa)),n=new Array(12).fill().map((()=>new sa)),i=new O,r=new O;return function(a,s=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(o||l)&&(a.getCenter(r),this.closestPointToPoint(r,i),a.closestPointToPoint(i,r),o&&o.copy(i),l&&l.copy(r)),0;let h=s*s,c=a.min,u=a.max,d=this.points,p=1/0;for(let e=0;e<8;e++){let t=d[e];r.copy(t).clamp(c,u);let n=t.distanceToSquared(r);if(nn.far)?null:e}function Ll(e,t,n,i){let r=e.a,a=e.b,s=e.c,o=t,l=t+1,h=t+2;n&&(o=n.getX(t),l=n.getX(t+1),h=n.getX(t+2)),r.x=i.getX(o),r.y=i.getY(o),r.z=i.getZ(o),a.x=i.getX(l),a.y=i.getY(l),a.z=i.getZ(l),s.x=i.getX(h),s.y=i.getY(h),s.z=i.getZ(h)}function oH(e,t,n,i,r,a,s){let o=n.index,l=n.attributes.position;for(let h=e,c=t+e;h=0;c?(r=Ov(e),s=kv(e,o)):(r=kv(e,o),s=Ov(e));let u=lA(r,a,i,sA)?oA(r,t,n,i):null;if(u){let e=u.point[h];if(c?e<=a[s+l]:e>=a[s+l+3])return u}let d=lA(s,a,i,sA)?oA(s,t,n,i):null;return u&&d?u.distance<=d.distance?u:d:u||d||null}}var Qhe=function(){let e,t,n=[],i=new Lv((()=>new Ot));return function(...a){e=i.getPrimitive(),t=i.getPrimitive(),n.push(e,t);let s=r(...a);i.releasePrimitive(e),i.releasePrimitive(t),n.pop(),n.pop();let o=n.length;return o>0&&(t=n[o-1],e=n[o-2]),s};function r(n,i,a,s,o=null,l=0,h=0){function c(e){let t=2*e,n=vf,i=yf;for(;!td(t,n);)t=2*(e=Ov(e));return Pm(e,i)}function u(e){let t=2*e,n=vf,i=yf;for(;!td(t,n);)t=2*(e=kv(e,i));return Pm(e,i)+Dv(t,n)}let d=2*n,p=Nv,f=vf,m=yf;if(td(d,f)){let t=Pm(n,m),i=Dv(d,f);return Il(n,p,e),s(t,i,!1,h,l+n,e)}{let d,g,v,y,x=Ov(n),b=kv(n,m),_=x,w=b;if(o&&(v=e,y=t,Il(_,p,v),Il(w,p,y),d=o(v),g=o(y),gr.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(h),e.b.applyMatrix4(h),e.c.applyMatrix4(h),e.needsUpdate=!0;for(let n=3*v,i=3*(y+v);nnew vo)),Rc=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Rc.serialize(arguments[0],{cloneBuffers:void 0===arguments[2]||arguments[2]});t=wr({cloneBuffers:!0},t);let n,i=e.geometry,r=e._roots,a=i.getIndex();return n=t.cloneBuffers?{roots:r.map((e=>e.slice())),index:a.array.slice()}:{roots:r,index:a.array},n}static deserialize(e,t,n={}){if("boolean"==typeof n)return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Rc.deserialize(arguments[0],arguments[1],{setIndex:void 0===arguments[2]||arguments[2]});n=wr({setIndex:!0},n);let{index:i,roots:r}=e,a=new Rc(t,Ri(wr({},n),{[cH]:!0}));if(a._roots=r,n.setIndex){let n=t.getIndex();if(null===n){let n=new gn(e.index,1,!1);t.setIndex(n)}else n.array!==i&&(n.array.set(i),n.needsUpdate=!0)}return a}constructor(e,t={}){if(!e.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if((t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[cH]:!1},t)).useSharedArrayBuffer&&"undefined"==typeof SharedArrayBuffer)throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[cH]||(this._roots=qhe(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Ot))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t,n,i,r,a=this.geometry,s=a.index.array,o=a.attributes.position,l=0,h=this._roots;for(let u=0,d=h.length;uu&&(u=n),id&&(d=i),rp&&(p=r)}return(r[t+0]!==a||r[t+1]!==l||r[t+2]!==c||r[t+3]!==u||r[t+4]!==d||r[t+5]!==p)&&(r[t+0]=a,r[t+1]=l,r[t+2]=c,r[t+3]=u,r[t+4]=d,r[t+5]=p,!0)}{let i=t+8,s=n[t+6],o=i+a,h=s+a,u=l,d=!1,p=!1;e?u||(d=e.has(o),p=e.has(h),u=!d&&!p):(d=!0,p=!0);let f=u||p,m=!1;(u||d)&&(m=c(i,a,u));let g=!1;f&&(g=c(s,a,u));let v=m||g;if(v)for(let e=0;e<3;e++){let n=i+e,a=s+e,o=r[n],l=r[n+3],h=r[a],c=r[a+3];r[t+e]=oc?l:c}return v}}}traverse(e,t=0){let n=this._roots[t],i=new Uint32Array(n),r=new Uint16Array(n);!function t(a,s=0){let o=2*a,l=65535===r[o+15];if(l){let t=i[a+6],h=r[o+14];e(s,l,new Float32Array(n,4*a,6),t,h)}else{let r=a+8,o=i[a+6],h=i[a+7];e(s,l,new Float32Array(n,4*a,6),h)||(t(r,s+1),t(o,s+1))}}(0)}raycast(e,t=ci){let n=this._roots,i=this.geometry,r=[],a=t.isMaterial,s=Array.isArray(t),o=i.groups,l=a?t.side:t;for(let h=0,c=n.length;h{let a=3*n;return e(t,a,a+1,a+2,i,r)}}e={boundsTraverseOrder:n,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let r=Fu.getPrimitive(),{boundsTraverseOrder:a,intersectsBounds:s,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let e=o;o=(t,n,a,s,o)=>!!e(t,n,a,s,o)||oH(t,n,i,l,a,s,r)}else o||(o=l?(e,t,n,a)=>oH(e,t,i,l,n,a,r):(e,t,n)=>n);let h=!1,c=0;for(let u of this._roots){if(Bv(u),h=Qhe(0,i,s,o,a,c),Vb(),h)break;c+=u.byteLength}return Fu.releasePrimitive(r),h}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:r}=n,a=this.geometry.index,s=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;Uv.copy(t).invert();let h=Fu.getPrimitive(),c=Fu.getPrimitive();if(r){let e=function(e,n,i,u,d,p,f,m){for(let g=i,v=i+u;ghH.intersectsBox(e),intersectsRange:(t,n,r,a,s,o)=>(uH.copy(o),uH.applyMatrix4(Uv),e.shapecast({intersectsBounds:e=>uH.intersectsBox(e),intersectsRange:(e,r,o,l,h)=>i(t,n,e,r,a,s,l,h)}))});return Fu.releasePrimitive(h),Fu.releasePrimitive(c),u}intersectsBox(e,t){return Im.set(e.min,e.max,t),Im.needsUpdate=!0,this.shapecast({intersectsBounds:e=>Im.intersectsBox(e),intersectsTriangle:e=>Im.intersectsTriangle(e)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},r=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Im.set(e.boundingBox.min,e.boundingBox.max,t),Im.needsUpdate=!0;let s=this.geometry,o=s.attributes.position,l=s.index,h=e.attributes.position,c=e.index,u=Fu.getPrimitive(),d=Fu.getPrimitive(),p=cA,f=vct,m=null,g=null;i&&(m=yct,g=xct);let v=1/0,y=null,x=null;return Uv.copy(t).invert(),zb.matrix.copy(Uv),this.shapecast({boundsTraverseOrder:e=>Im.distanceToBox(e),intersectsBounds:(e,t,n)=>n{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:e=>zb.distanceToBox(e),intersectsBounds:(e,t,n)=>n{for(let s=3*e,b=3*(e+a);s(Gb.copy(e).clamp(t.min,t.max),Gb.distanceToSquared(e)),intersectsBounds:(e,t,n)=>n{t.closestPointToPoint(e,Gb);let i=e.distanceToSquared(Gb);return i{Il(0,new Float32Array(t),tde),e.union(tde)})),e}},dH=new co,nde=new Qe,bct=xt.prototype.raycast;function fH(e,t){if(this.geometry.boundsTree){if(void 0===this.material)return;nde.copy(this.matrixWorld).invert(),dH.copy(e.ray).applyMatrix4(nde);let n=this.geometry.boundsTree;if(!0===e.firstHitOnly){let i=aH(n.raycastFirst(dH,this.material),this,e);i&&t.push(i)}else{let i=n.raycast(dH,this.material);for(let n=0,r=i.length;nn.far?null:{distance:h,point:gA.clone(),object:e}}function vA(e,t,n,i,r,a,s,o,l,h,c,u){xf.fromBufferAttribute(r,h),bf.fromBufferAttribute(r,c),Ef.fromBufferAttribute(r,u);let d=e.morphTargetInfluences;if(a&&d){uA.set(0,0,0),hA.set(0,0,0),dA.set(0,0,0);for(let e=0,t=a.length;ei.far)return;r.push({distance:o,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,object:a})}}ii.prototype.raycast=function(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),yA.copy(n.boundingSphere),yA.applyMatrix4(i),yA.radius+=r,!1===e.ray.intersectsSphere(yA))return;let s=r*r,o=n.index,l=n.attributes.position,h=t.length;if(null!==o)for(let c=Math.max(0,a.start),u=Math.min(o.count,a.start+a.count);c=1)return}else for(let c=Math.max(0,a.start),u=Math.min(l.count,a.start+a.count);c=1)return};var xH=class{constructor(){this.id=0,this.object=null,this.z=0,this.renderOrder=0}},qb=class{constructor(){this.id=0,this.v1=new _f,this.v2=new _f,this.v3=new _f,this.normalModel=new O,this.vertexNormalsModel=[new O,new O,new O],this.vertexNormalsLength=0,this.color=new ct,this.material=null,this.uvs=[new be,new be,new be],this.z=0,this.renderOrder=0}},_f=class{constructor(){this.position=new O,this.positionWorld=new O,this.positionScreen=new mr,this.visible=!0}copy(e){this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)}},Wb=class{constructor(){this.id=0,this.v1=new _f,this.v2=new _f,this.vertexColors=[new ct,new ct],this.material=null,this.z=0,this.renderOrder=0}},jb=class{constructor(){this.id=0,this.object=null,this.x=0,this.y=0,this.z=0,this.rotation=0,this.scale=new be,this.material=null,this.renderOrder=0}},bA=class{constructor(){let e,t,n,i,r,a,s,o,l,h,c,u=0,d=0,p=0,f=0,m=0,g={objects:[],lights:[],elements:[]},v=new O,y=new mr,x=new Ot(new O(-1,-1,-1),new O(1,1,1)),b=new Ot,_=new Array(3),w=new Qe,S=new Qe,M=new Qe,E=new ya,T=[],A=[],C=[],P=[],R=[],L=new function(){let e=[],t=[],l=[],h=null,u=new Ln;function m(e){let t=e.position,n=e.positionWorld,i=e.positionScreen;n.copy(t).applyMatrix4(c),i.copy(n).applyMatrix4(S);let r=1/i.w;i.x*=r,i.y*=r,i.z*=r,e.visible=i.x>=-1&&i.x<=1&&i.y>=-1&&i.y<=1&&i.z>=-1&&i.z<=1}function w(e,t,n){return!0===e.visible||!0===t.visible||!0===n.visible||(_[0]=e.positionScreen,_[1]=t.positionScreen,_[2]=n.positionScreen,x.intersectsBox(b.setFromPoints(_)))}function E(e,t,n){return(n.positionScreen.x-e.positionScreen.x)*(t.positionScreen.y-e.positionScreen.y)-(n.positionScreen.y-e.positionScreen.y)*(t.positionScreen.x-e.positionScreen.x)<0}return{setObject:function(n){h=n,u.getNormalMatrix(h.matrixWorld),e.length=0,t.length=0,l.length=0},projectVertex:m,checkTriangleVisibility:w,checkBackfaceCulling:E,pushVertex:function(e,t,r){n=function(){if(i===d){let e=new _f;return A.push(e),d++,i++,e}return A[i++]}(),n.position.set(e,t,r),m(n)},pushNormal:function(t,n,i){e.push(t,n,i)},pushColor:function(e,n,i){t.push(e,n,i)},pushUv:function(e,t){l.push(e,t)},pushLine:function(e,n){let i=A[e],r=A[n];i.positionScreen.copy(i.position).applyMatrix4(M),r.positionScreen.copy(r.position).applyMatrix4(M),!0===function(e,t){let n=0,i=1,r=e.z+e.w,a=t.z+t.w,s=-e.z+e.w,o=-t.z+t.w;return r>=0&&a>=0&&s>=0&&o>=0||!(r<0&&a<0||s<0&&o<0)&&(r<0?n=Math.max(n,r/(r-a)):a<0&&(i=Math.min(i,r/(r-a))),s<0?n=Math.max(n,s/(s-o)):o<0&&(i=Math.min(i,s/(s-o))),!(i=-1&&e.z<=1&&(l=function(){if(h===m){let e=new jb;return R.push(e),m++,h++,e}return R[h++]}(),l.id=t.id,l.x=e.x*i,l.y=e.y*i,l.z=e.z,l.renderOrder=t.renderOrder,l.object=t,l.rotation=t.rotation,l.scale.x=t.scale.x*Math.abs(l.x-(e.x+n.projectionMatrix.elements[0])/(e.w+n.projectionMatrix.elements[12])),l.scale.y=t.scale.y*Math.abs(l.y-(e.y+n.projectionMatrix.elements[5])/(e.w+n.projectionMatrix.elements[13])),l.material=t.material,g.elements.push(l))}function N(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id!==t.id?e.id-t.id:0}this.projectScene=function(e,n,r,s){a=0,o=0,h=0,g.elements.length=0,!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===n.parent&&!0===n.matrixWorldAutoUpdate&&n.updateMatrixWorld(),w.copy(n.matrixWorldInverse),S.multiplyMatrices(n.projectionMatrix,w),E.setFromProjectionMatrix(S),t=0,g.objects.length=0,g.lights.length=0,I(e),!0===r&&g.objects.sort(N);let l=g.objects;for(let t=0,a=l.length;t0)for(let r=0;r0)for(let r=0;r0;)k.removeChild(k.childNodes[0])}function F(e){return null!==g?e.toFixed(g):e}function U(e,t,n){let i=t.scale.x*a,r=t.scale.y*s;n.isPointsMaterial&&(i*=n.size,r*=n.size);let o="M"+F(e.x-.5*i)+","+F(e.y-.5*r)+"h"+F(i)+"v"+F(r)+"h"+F(-i)+"z",l="";(n.isSpriteMaterial||n.isPointsMaterial)&&(l="fill:"+n.color.getStyle()+";fill-opacity:"+n.opacity),V(l,o)}function B(e,t,n){let i="M"+F(e.positionScreen.x)+","+F(e.positionScreen.y)+"L"+F(t.positionScreen.x)+","+F(t.positionScreen.y);if(n.isLineBasicMaterial){let e="fill:none;stroke:"+n.color.getStyle()+";stroke-opacity:"+n.opacity+";stroke-width:"+n.linewidth+";stroke-linecap:"+n.linecap;n.isLineDashedMaterial&&(e=e+";stroke-dasharray:"+n.dashSize+","+n.gapSize),V(e,i)}}function z(e,t,i,r,a){y.info.render.vertices+=3,y.info.render.faces++;let s="M"+F(e.positionScreen.x)+","+F(e.positionScreen.y)+"L"+F(t.positionScreen.x)+","+F(t.positionScreen.y)+"L"+F(i.positionScreen.x)+","+F(i.positionScreen.y)+"z",o="";a.isMeshBasicMaterial?(_.copy(a.color),a.vertexColors&&_.multiply(r.color)):a.isMeshLambertMaterial||a.isMeshPhongMaterial||a.isMeshStandardMaterial?(w.copy(a.color),a.vertexColors&&w.multiply(r.color),_.copy(S),A.copy(e.positionWorld).add(t.positionWorld).add(i.positionWorld).divideScalar(3),function(e,t,n,i){for(let r=0,a=e.length;r1||l.positionScreen.z<-1||l.positionScreen.z>1||h.positionScreen.z<-1||h.positionScreen.z>1)continue;o.positionScreen.x*=a,o.positionScreen.y*=-s,l.positionScreen.x*=a,l.positionScreen.y*=-s,h.positionScreen.x*=a,h.positionScreen.y*=-s,this.overdraw>0&&(H(o.positionScreen,l.positionScreen,this.overdraw),H(l.positionScreen,h.positionScreen,this.overdraw),H(h.positionScreen,o.positionScreen,this.overdraw)),b.setFromPoints([o.positionScreen,l.positionScreen,h.positionScreen]),!0===x.intersectsBox(b)&&z(o,l,h,n,i)}}j(),i.traverseVisible((function(e){if(e.isSVGObject){if(T.setFromMatrixPosition(e.matrixWorld),T.applyMatrix4(L),T.z<-1||T.z>1)return;let t=T.x*a,n=-T.y*s,i=e.node;i.setAttribute("transform",`translate(${t}, ${n}) rotate(${e.rotation.z})`),k.appendChild(i)}}))}}};function _ct(e){let t={};return t.r=(e>>16&255)/255,t.g=(e>>8&255)/255,t.b=(255&e)/255,t}var ode="\n #if defined(USE_BC_OUTLINE)\n vBarycentric = barycentric;\n #endif\n",lde="\n #if defined(USE_BC_OUTLINE)\n vec3 finWireFrameColor = outLineColor;\n vec3 _tempColor = gl_FragColor.rgb;\n\n gl_FragColor.rgb = mix(finWireFrameColor, _tempColor, edgeFactor3());\n #endif\n",cde="\n #if defined(USE_BC_OUTLINE)\n varying vec3 vBarycentric;\n uniform vec3 outLineColor;\n\n float edgeFactor3(){\n vec3 d = fwidth(vBarycentric);\n float minValue = 0.0000001;\n // make sure d is not 0\n d = clamp(d, vec3(minValue), vec3(10.0));\n vec3 a3 = smoothstep(vec3(0.0), d*0.8, vBarycentric);\n return min(min(a3.x, a3.y), a3.z);\n }\n #endif\n",ude="\n #ifdef USE_BC_OUTLINE \n attribute vec3 barycentric;\n varying vec3 vBarycentric;\n #endif\n",bH="\n#define STANDARD\n\nvarying vec3 vViewPosition;\n\n#ifdef USE_TRANSMISSION\n\n\tvarying vec3 vWorldPosition;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n #include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\t#include \n\n#ifdef USE_TRANSMISSION\n\n\tvWorldPosition = worldPosition.xyz;\n\n#endif\n}\n",EH="\n#define STANDARD\n\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n\n#ifdef IOR\n\tuniform float ior;\n#endif\n\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\n\nvarying vec3 vViewPosition;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// modulation\n\t#include \n\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\n\t#include \n\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\n\t#ifdef USE_SHEEN\n\n\t\t// Sheen energy compensation approximation calculation can be found at the end of\n\t\t// https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\n\t#endif\n\n\t#ifdef USE_CLEARCOAT\n\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n #include \n}\n";$n.outline_bc_vertex=ode,$n.outline_bc_fragment=lde,$n.outline_bc_pars_fragment=cde,$n.outline_bc_pars_vertex=ude,$n.gemini_standard_vertex=bH,$n.gemini_standard_fragment=EH;var EA=class{constructor(e){this.isCanceled=!1;let t=new Promise(((e,t)=>{this.cancelReject=t}));this.promise=Promise.race([t,e])}cancel(){this.cancelReject&&this.cancelReject({type:"cancel"})}},Tct=ji(fde(),1),se=Tct;se.setLevel("warn");var pde=e=>{try{se.setLevel(e)}catch(e){se.setLevel("error"),se.error(e)}},_H=class{static isTouchScreenDevice(){return"ontouchstart"in window}static printDeviceInfo(){let e=navigator.userAgent,t=/(?:Android)/.test(e),n=/(?:Firefox)/.test(e),i=/(?:Chrome|CriOS)/.test(e),r=/(?:iPad|PlayBook)/.test(e)||t&&!/(?:Mobile)/.test(e)||n&&/(?:Tablet)/.test(e),a=/(?:iPhone)/.test(e)&&!r,s=!a&&!t,o=_H.isTouchScreenDevice();t&&se.debug("[DI] is android"),n&&se.debug("[DI] is fireFox"),i&&se.debug("[DI] is chrome"),r&&se.debug("[DI] is tablet"),a&&se.debug("[DI] is iPhone"),s&&se.debug("[DI] is PC"),o&&se.debug("[DI] is touch device")}static creatReactNativeCanvas(e){let t=e.drawingBufferWidth||e.width||0,n=e.drawingBufferHeight||e.height||0;return{style:{},width:t,height:n,clientWidth:Math.ceil(t/(window.devicePixelRatio||1)),clientHeight:Math.ceil(n/(window.devicePixelRatio||1)),addEventListener:()=>{},removeEventListener:()=>{}}}},Dn=_H;Dn.isMobile=/mobile/i.test(navigator.userAgent),Dn.isBrowser="undefined"!=typeof document,Dn.isNode="undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process);var TA=class{static isFullScreen(){return!(!document.fullscreenElement&&!document.mozFullScreenElement)}static fullScreen(e=document.documentElement){(e.requestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen||e.msRequestFullscreen).call(e)}static exitFullscreen(){(document.exitFullscreen||document.mozCancelFullscreen||document.webkitExitFullscreen||document.msExitFullscreen).call(document)}static joinStrings(...e){return e.join("")}static numberToString(e){let t=2;return Math.abs(e)<1e-6?t=2:Math.abs(e)<1e-5?t=7:Math.abs(e)<1e-4?t=6:Math.abs(e)<.001?t=5:Math.abs(e)<.01?t=4:Math.abs(e)<.1&&(t=3),e.toFixed(t)}static hexToBase64(e){return btoa((e.match(/\w{2}/g)||[]).map((function(e){return String.fromCharCode(parseInt(e,16))})).join(""))}static vectorToString(e){return e instanceof O?`(${this.numberToString(e.x)}, ${this.numberToString(e.y)}, ${this.numberToString(e.z)})`:`(${this.numberToString(e.x)}, ${this.numberToString(e.y)})`}static arrayToVector2(e){return e?e instanceof be?e:Array.isArray(e)&&e.length>=2?new be(e[0],e[1]):void 0:e}static arrayToVector3(e){return e?e instanceof O?e:Array.isArray(e)&&e.length>=2?new O(e[0],e[1],e.length>2?e[2]:0):void 0:e}static arrayToEuler(e){return e?e instanceof Xn?e:Array.isArray(e)&&e.length>=3?new Xn(e[0],e[1],e[2]):void 0:e}static arrayOrObjectToVector3(e){if(!e)return e;if(e instanceof O)return e;if(e instanceof be)return new O(e.x,e.y,0);if(Array.isArray(e)&&e.length>=2)return new O(e[0],e[1],e[2]||0);let t=e;return null!=t.x&&null!=t.y?new O(t.x,t.y,t.z||0):void 0}static isVectorValid(e){let t=e&&!isNaN(e.x)&&!isNaN(e.y)&&isFinite(e.x)&&isFinite(e.y);return t&&e instanceof O&&(t=!isNaN(e.z)&&isFinite(e.z)),t}static isBoxValid(e){return e&&!e.isEmpty()&&this.isVectorValid(e.min)&&this.isVectorValid(e.max)}static isMatrixValid(e){let t=e&&e.elements;if(!t||t.length<16)return!1;for(let n=0;n<16;++n){let e=t[n];if(Number.isNaN(e))return!1}return!0}static guid(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{let t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}static expandBoxByScale(e,t){let n=new O;e.getCenter(n);let i=(e.max.x-e.min.x)*t,r=(e.max.y-e.min.y)*t,a=(e.max.z-e.min.z)*t,s=new O(n.x-i/2,n.y-r/2,n.z-a/2),o=new O(n.x+i/2,n.y+r/2,n.z+a/2);e.set(s,o)}static expandBoxByMinSize(e,t){let n=new O;e.getCenter(n);let i=e.max.x-e.min.x,r=e.max.y-e.min.y,a=e.max.z-e.min.z;i{n.onload=function(){e(n)}}))}static renderingContextToImage(e,t,n="image/png",i=.8){if(t){let r=Math.max(t.min.x,0),a=Math.max(t.min.y,0),s=Math.max(t.max.x-r,0),o=Math.max(t.max.y-a,0),l=e.getImageData(r,a,s,o),h=document.createElement("canvas");return h.width=s,h.height=o,h.getContext("2d").putImageData(l,0,0),h.toDataURL(n,i)}return e.canvas.toDataURL(n,i)}static printMemory(e){if(Dn.isBrowser){let t=performance.memory;if(!t)return void se.warn("[CommonUtils] performance.memory is not available in this browser");let n=(t.jsHeapSizeLimit/1048576).toFixed(2),i=(t.totalJSHeapSize/1048576).toFixed(2),r=(t.usedJSHeapSize/1048576).toFixed(2);se.info(`[CommonUtils] ${e}. jsHeapSizeLimit: ${n}M , totalJSHeapSize: ${i}M , usedJSHeapSize: ${r}M `)}}static printGpuInfo(e){if(Dn.isBrowser){let t=e.getExtension("webgl_debug_renderer_info"),n=e.getParameter(t.UNMASKED_RENDERER_WEBGL);se.info("[CommonUtils] gpu:",n)}}static sleep(e){return ft(this,null,(function*(){let t;return new Promise((n=>{t=setTimeout((()=>{n("")}),e)})).then((()=>{clearTimeout(t)}))}))}static twinkle(e,t=500){return ft(this,null,(function*(){let n=this.twinklingObjectIds;n[e.id]||(n[e.id]=!0,e.visible=!e.visible,yield this.sleep(t),e.visible=!e.visible,yield this.sleep(t),e.visible=!e.visible,yield this.sleep(t),e.visible=!e.visible,yield this.sleep(t),e.visible=!e.visible,yield this.sleep(t),e.visible=!e.visible,delete n[e.id])}))}static getUpdateProgressFunc(e){return t=>{e&&e(new ProgressEvent("",{loaded:t,total:100}))}}static getUpdateProgressFuncAsync(e){let t=Date.now();return n=>ft(this,null,(function*(){if(e){e(new ProgressEvent("",{loaded:n,total:100}));let i=500,r=Date.now();r-t>i&&(yield TA.sleep(0),t=r)}}))}static getUpdateProgressFuncForLoop(e,t){let n=Math.round(Math.pow(e,.5)),i=Date.now();return r=>ft(this,null,(function*(){if(t&&(r%n==0||r===e-1)){t(new ProgressEvent("",{loaded:r+1,total:e}));let n=500,a=Date.now();(a-i>n||r===e-1)&&(yield TA.sleep(0),i=a)}}))}static getUpdateSubProgressFunc(e,t,n){let i=!1;return r=>{let a=100*r.loaded/r.total;a=a*(t-e)/100+e,a>t&&(i||(se.warn("[Progress] Invalid ProgressEvent:",r),i=!0),a=t),n&&n(new ProgressEvent(r.type,{loaded:a,total:100}))}}},Mt=TA;Mt.twinklingObjectIds={};var wA=(e,t,n)=>{let{default:i,active:r}=t;n?(e.remove(i),e.add(r||i)):(r&&e.remove(r),e.add(i))},Cn=class{static color2rgba(e){let t,n=[0,0,0,1];if(t=/^(\w+)\(([^)]*)\)/.exec(e)){let i,r=t[1],a=t[2];switch(r){case"rgb":case"rgba":(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))&&(n=[Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,Number(i[4]||1)]),(i=/^\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))&&(n=[Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,Number(i[4]||1)]);break;case"hsl":case"hsla":(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))&&(n=[parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,Number(i[4]||1)]);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(t=/^#([A-Fa-f\d]+)$/.exec(e)){let i=t[1],r=i.length;if(3===r)n=[parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,1];else if(6===r){let e=parseInt(i,16);n=[(e>>16&255)/255,(e>>8&255)/255,(255&e)/255,1]}else console.warn("THREE.Color: Invalid hex color "+e)}return n}static rgba2Color(e){return`rgba(${this.to255(e[0])},${this.to255(e[1])},${this.to255(e[2])},${null!=e[3]?e[3]:1})`}static colorStr2Rgba(e){let t=e.replace("rgba(","");t=t.replace(")","");let n=t.split(","),i=[];return i.push(this.to1(parseInt(n[0]))),i.push(this.to1(parseInt(n[1]))),i.push(this.to1(parseInt(n[2]))),null!=n[3]&&i.push(parseFloat(n[3])),i}static rgb2Hex(e){return(this.to255(e[0])<<16)+(this.to255(e[1])<<8)+this.to255(e[2])}static to255(e){let t=Math.max(e,0);return t=Math.min(e,1),255*t}static to1(e){let t=Math.max(e,0);return t=Math.min(e,255),t/255}},un=class{static getScreenPointByEvent(e,t){let n=new be,{left:i,top:r}=t.getBoundingClientRect();return n.x=e.clientX-i,n.y=e.clientY-r,n}static getScreenPointByTouchEvent(e,t){let n=new be,{left:i,top:r}=t.getBoundingClientRect();return n.x=e.touches[0].clientX-i,n.y=e.touches[0].clientY-r,n}static worldPosition2ScreenPoint(e,t,n){let{clientWidth:i,clientHeight:r}=n,a=e.clone(),s=new be;return a.project(t),s.x=Math.round((.5+a.x/2)*i),s.y=Math.round((.5-a.y/2)*r),s}static screenPoint2worldPosition(e,t,n){let i=un.screenPoint2NdcPoint(e,t,n);return new O(i.x,i.y,1).unproject(t)}static screenPoint2NdcPoint(e,t,n){let{clientWidth:i,clientHeight:r}=n,a=new be;return a.x=e.x/i*2-1,a.y=-e.y/r*2+1,a}static worldCoordinate2NormalizedScreenCoordinate(e,t,n){let i=new O;e instanceof be?i.set(e.x,e.y,0):i.set(e.x,e.y,e.z);let r=un.worldPosition2ScreenPoint(i,t,n);return r.x/=n.clientWidth,r.y/=n.clientHeight,r}},zv=class extends on{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new be(.5,.5),this.addEventListener("removed",(function(){this.traverse((function(e){e.element instanceof Element&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}},Vv=new O,mde=new Qe,gde=new Qe,vde=new O,yde=new O,Nu=class{constructor(e={}){let t,n,i,r,a=this,s={objects:new WeakMap},o=void 0!==e.element?e.element:document.createElement("div");function l(e,t,n){if(e.isCSS2DObject){Vv.setFromMatrixPosition(e.matrixWorld),Vv.applyMatrix4(gde);let l=!0===e.visible&&Vv.z>=-1&&Vv.z<=1&&!0===e.layers.test(n.layers);if(e.element.style.display=!0===l?"":"none",!0===l){e.onBeforeRender(a,t,n);let s=e.element;s.style.transform="translate("+-100*e.center.x+"%,"+-100*e.center.y+"%)translate("+(Vv.x*i+i)+"px,"+(-Vv.y*r+r)+"px)",s.parentNode!==o&&o.appendChild(s),e.onAfterRender(a,t,n)}let c={distanceToCameraSquared:h(n,e)};s.objects.set(e,c)}for(let i=0,r=e.children.length;ie.toFixed(t===xde["Precision from file"]?2:t),si=!1,GLt=!1,Uu=10,vs=11,ti=12,qv="gemini-viewer-iconfont",qLt="keydown",WLt="keyup",wf="mousemove",TH="mouseup",wH="mousedown",jLt="Escape",XLt="Enter",YLt="axis-section-plane",$Lt="axis-section-plane-control",ZLt="section-plane",KLt="section-plane-control",JLt="section-box",SH="plane-section-boxface",bde=-1e3,SA=10,Wv=(e=>(e.ObjectsBoxSection="ObjectsBoxSection",e.PickPlaneSection="PickPlaneSection",e.AxisPlaneSection="AxisPlaneSection",e))(Wv||{}),MH=(e=>(e.Default="Default",e.BoxSelection="BoxSelection",e.PickMarkup="PickMarkup",e))(MH||{}),Ede=new O,_de=new O,Tde=new O,Xb=new O,nd=new O,wde=new Zr;function wct(e,t,n,i,r){let a,s,o,l,h,c,u=[],d={},p=Math.pow(10,4),f=0;for(h=0,c=e.length;hy))&&(m=r[d.index1],g=r[d.index2],(!b&&m>65535||g>65535)&&(b=!0),v.push(m),v.push(g));return b?new Uint32Array(v):new Uint16Array(v)}static buildBarycentrics(e){let t=e.getAttribute("position");if(!t||0===t.count)return console.warn(" no positions in geometry !"),!1;let n=Math.pow(10,4),i=Math.cos(20*An.DEG2RAD),r=e.getIndex(),a=r?r.count:t.count,s=[0,0,0],o=new Array(3),l=RH.length,h=[];for(let S=0;S0))break;g=new Set;for(let e of m[v])g.add(e.a),g.add(e.b),g.add(e.c);m.splice(v,1),v=0}}let y=new Set;for(let S=0;S{y.has(e)?se.warn(`${e} is already in positionIndexSet !`):y.add(e)}));let x=(e,t)=>{let n=!1,i=d[e];if(!i)return console.warn(`${e} is not in positionIndexHash !`),n;let r=d[t];if(!r)return console.warn(`${t} is not in positionIndexHash !`),n;let a=`${i}_${r}`;if(p[a])n=p[a].outer;else{let e=`${r}_${i}`;p[e]&&(n=p[e].outer)}return n},b=(e,t,n)=>{let i=[];return i.push(x(e,t)),i.push(x(t,n)),i.push(x(n,e)),i.filter((e=>!0===e)).length>=2},_=(e,t)=>{if(!c[e])return se.warn(`${e} position isn't used !`),!0;let n=c[e];for(let r of n){let n=x(e,r),i=h[r];if(!i.inited)continue;let a=Mct(t,i.point);if(n&&!a||!n&&a)return!1}let i=u[e];for(let r of i){let n=t,i=h[r.b],a=h[r.c];if(r.b===e?i=h[r.a]:r.c===e&&(a=h[r.a]),b(r.a,r.b,r.c)&&(i.inited&&n.equals(i.point)||a.inited&&n.equals(a.point)))return!1;if(i.inited&&a.inited&&(nd.addVectors(n,i.point),nd.add(a.point),nd.x+nd.y+nd.z<2))return!1}return!0},w=!1;for(let S=0;S=0;){t=e[n];let i=h[t].inited?h[t].barycentricIndex+1:0;for(;ie(t)))}hasEventListener(e){return!!this.map.get(e)}removeEventListener(e,t){if(!e)return void this.map.clear();if(!t)return void this.map.delete(e);let n=this.map.get(e);n&&n.delete(t)}},xa=class{parse(e,t={}){if(t=Object.assign({decodeSpeed:5,encodeSpeed:5,encoderMethod:xa.MESH_EDGEBREAKER_ENCODING,quantization:[16,8,8,8,8],exportUvs:!0,exportNormals:!0,exportColor:!1},t),void 0===DracoEncoderModule)throw new Error("THREE.DRACOExporter: required the draco_encoder to work.");let n,i,r=e.geometry,a=DracoEncoderModule(),s=new a.Encoder;if(!0===e.isMesh){n=new a.MeshBuilder,i=new a.Mesh;let e=r.getAttribute("position");n.AddFloatAttributeToMesh(i,a.POSITION,e.count,e.itemSize,e.array);let s=r.getIndex();if(null!==s)n.AddFacesToMesh(i,s.count/3,s.array);else{let t=new(e.count>65535?Uint32Array:Uint16Array)(e.count);for(let e=0;e4?n=e.array[r*e.itemSize+t]:(0===t?n=e.getX(r):1===t?n=e.getY(r):2===t?n=e.getZ(r):3===t&&(n=e.getW(r)),!0===e.normalized&&(n=An.normalize(n,e.array))),i.min[t]=Math.min(i.min[t],n),i.max[t]=Math.max(i.max[t],n)}return i}function Lde(e){return 4*Math.ceil(e/4)}function PH(e,t=0){let n=Lde(e.byteLength);if(n!==e.byteLength){let i=new Uint8Array(n);if(i.set(new Uint8Array(e)),0!==t)for(let r=e.byteLength;re.toBlob(n,t)));let n;return"image/jpeg"===t?n=.92:"image/webp"===t&&(n=.8),e.convertToBlob({type:t,quality:n})}var IH=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}write(e,t){return ft(this,arguments,(function*(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),yield Promise.all(this.pending);let i=this,r=i.buffers,a=i.json;n=i.options;let s=i.extensionsUsed,o=i.extensionsRequired,l=new Blob(r,{type:"application/octet-stream"}),h=Object.keys(s),c=Object.keys(o);if(h.length>0&&(a.extensionsUsed=h),c.length>0&&(a.extensionsRequired=c),a.buffers&&a.buffers.length>0&&(a.buffers[0].byteLength=l.size),!0===n.binary){let e=new FileReader;e.readAsArrayBuffer(l),e.onloadend=function(){let n=PH(e.result),i=new DataView(new ArrayBuffer(Cde));i.setUint32(0,n.byteLength,!0),i.setUint32(4,Ict,!0);let r=PH(Lct(JSON.stringify(a)),32),s=new DataView(new ArrayBuffer(Cde));s.setUint32(0,r.byteLength,!0),s.setUint32(4,Pct,!0);let o=new ArrayBuffer(Ade),l=new DataView(o);l.setUint32(0,Act,!0),l.setUint32(4,Cct,!0);let h=Ade+s.byteLength+r.byteLength+i.byteLength+n.byteLength;l.setUint32(8,h,!0);let c=new Blob([o,s,r,i,n],{type:"application/octet-stream"}),u=new FileReader;u.readAsArrayBuffer(c),u.onloadend=function(){t(u.result)}}}else if(a.buffers&&a.buffers.length>0){let e=new FileReader;e.readAsDataURL(l),e.onloadend=function(){let n=e.result;a.buffers[0].uri=n,t(a)}}else t(a)}))}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;let n=this.options,i=this.extensionsUsed;try{let r=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&r.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(let e in r.gltfExtensions)t.extensions[e]=r.gltfExtensions[e],i[e]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(t.extras=r)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let t=new O;for(let n=0,i=e.count;n5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),i=new O;for(let r=0,a=n.count;r4?i=e.array[u*e.itemSize+n]:(0===n?i=e.getX(u):1===n?i=e.getY(u):2===n?i=e.getZ(u):3===n&&(i=e.getW(u)),!0===e.normalized&&(i=An.normalize(i,e.array))),t===Hr.FLOAT?l.setFloat32(h,i,!0):t===Hr.INT?l.setInt32(h,i,!0):t===Hr.UNSIGNED_INT?l.setUint32(h,i,!0):t===Hr.SHORT?l.setInt16(h,i,!0):t===Hr.UNSIGNED_SHORT?l.setUint16(h,i,!0):t===Hr.BYTE?l.setInt8(h,i):t===Hr.UNSIGNED_BYTE&&l.setUint8(h,i),h+=a}let c={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:o};return void 0!==r&&(c.target=r),r===Hr.ARRAY_BUFFER&&(c.byteStride=e.itemSize*a),this.byteOffset+=o,s.bufferViews.push(c),{id:s.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise((function(i){let r=new FileReader;r.readAsArrayBuffer(e),r.onloadend=function(){let e=PH(r.result),a={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,i(n.bufferViews.push(a)-1)}}))}processAccessor(e,t,n,i){let r,a=this.json;if(e.array.constructor===Float32Array)r=Hr.FLOAT;else if(e.array.constructor===Int32Array)r=Hr.INT;else if(e.array.constructor===Uint32Array)r=Hr.UNSIGNED_INT;else if(e.array.constructor===Int16Array)r=Hr.SHORT;else if(e.array.constructor===Uint16Array)r=Hr.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)r=Hr.BYTE;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);r=Hr.UNSIGNED_BYTE}if(void 0===n&&(n=0),void 0===i&&(i=e.count),0===i)return null;let s,o=Oct(e,n,i);void 0!==t&&(s=e===t.index?Hr.ELEMENT_ARRAY_BUFFER:Hr.ARRAY_BUFFER);let l=this.processBufferView(e,r,n,i,s),h={bufferView:l.id,byteOffset:l.byteOffset,componentType:r,count:i,max:o.max,min:o.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(h.normalized=!0),a.accessors||(a.accessors=[]),a.accessors.push(h)-1}processImage(e,t,n,i="image/png"){if(null!==e){let r=this,a=r.cache,s=r.json,o=r.options,l=r.pending;a.images.has(e)||a.images.set(e,{});let h=a.images.get(e),c=i+":flipY/"+n.toString();if(void 0!==h[c])return h[c];s.images||(s.images=[]);let u={mimeType:i},d=Pde();d.width=Math.min(e.width,o.maxTextureSize),d.height=Math.min(e.height,o.maxTextureSize);let p=d.getContext("2d");if(!0===n&&(p.translate(0,d.height),p.scale(1,-1)),void 0!==e.data){t!==ea&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>o.maxTextureSize||e.height>o.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;tr.processBufferViewImage(e))).then((e=>{u.bufferView=e}))):void 0!==d.toDataURL?u.uri=d.toDataURL(i):l.push(Ide(d,i).then((e=>(new FileReader).readAsDataURL(e))).then((e=>{u.uri=e})));let f=s.images.push(u)-1;return h[c]=f,f}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let n={magFilter:$o[e.magFilter],minFilter:$o[e.minFilter],wrapS:$o[e.wrapS],wrapT:$o[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){let t=this.options,n=this.cache,i=this.json;if(n.textures.has(e))return n.textures.get(e);i.textures||(i.textures=[]),e instanceof $h&&(e=CA(e,t.maxTextureSize));let r=e.userData.mimeType;"image/webp"===r&&(r="image/png");let a={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,r)};e.name&&(a.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,a)}));let s=i.textures.push(a)-1;return n.textures.set(e,s),s}processMaterial(e){let t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);let i={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let r=e.color.toArray().concat([e.opacity]);if(Yb(r,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=r),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){let t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),n={index:this.processTexture(t),channel:t.channel};this.applyTextureTransform(n,t),i.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){let t={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),i.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(i.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),i.emissiveTexture=t}}if(e.normalMap){let t={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),i.normalTexture=t}if(e.aoMap){let t={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),i.occlusionTexture=t}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===Er&&(i.doubleSided=!0),""!==e.name&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,i)}));let a=n.materials.push(i)-1;return t.materials.set(e,a),a}processMesh(e){let t=this.cache,n=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let y=0,x=e.material.length;y0){let n=[],i=[],r={};if(void 0!==e.morphTargetDictionary)for(let t in e.morphTargetDictionary)r[e.morphTargetDictionary[t]]=t;for(let a=0;a0&&(o.extras={},o.extras.targetNames=i)}let f=Array.isArray(e.material);if(f&&0===s.groups.length)return null;let m=f?e.material:[e.material],g=f?s.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let y=0,x=g.length;y0&&(e.targets=c),null!==s.index){let n=this.getUID(s.index);(void 0!==g[y].start||void 0!==g[y].count)&&(n+=":"+g[y].start+":"+g[y].count),t.attributes.has(n)?e.indices=t.attributes.get(n):(e.indices=this.processAccessor(s.index,s,g[y].start,g[y].count),t.attributes.set(n,e.indices)),null===e.indices&&delete e.indices}let n=this.processMaterial(m[g[y].materialIndex]);null!==n&&(e.material=n),h.push(e)}o.primitives=h,n.meshes||(n.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,o)}));let v=n.meshes.push(o)-1;return t.meshes.set(r,v),v}detectMeshQuantization(e,t){if(this.extensionsUsed[CH])return;let n;switch(t.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}t.normalized&&(n+=" normalized");let i=e.split("_",1)[0];Mde[i]&&Mde[i].includes(n)&&(this.extensionsUsed[CH]=!0,this.extensionsRequired[CH]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let n=e.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:An.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){let n=this.json,i=this.nodeMap;n.animations||(n.animations=[]);let r=(e=Xv.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,a=[],s=[];for(let o=0;o0){let t=[];for(let i=0,r=e.children.length;i0&&(r.children=t)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,r)}));let a=t.nodes.push(r)-1;return i.set(e,a),a}processScene(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let i={};""!==e.name&&(i.name=e.name),t.scenes.push(i);let r=[];for(let a=0,s=e.children.length;a0&&(i.nodes=r),this.serializeUserData(e,i)}processObjects(e){let t=new _i;t.name="AuxScene";for(let n=0;n0&&this.processObjects(n);for(let i=0;i0&&(a.range=e.distance)):e.isSpotLight&&(a.type="spot",e.distance>0&&(a.range=e.distance),a.spot={},a.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,a.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||0!==e.target.position.x||0!==e.target.position.y||-1!==e.target.position.z)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),r[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},r[this.name]=!0);let s=i.extensions[this.name].lights;s.push(a),t.extensions=t.extensions||{},t.extensions[this.name]={light:s.length-1}}},DH=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},OH=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(t,e.clearcoatMap),r.clearcoatTexture=t}if(r.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(t,e.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};n.applyTextureTransform(t,e.clearcoatNormalMap),r.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},kH=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(t,e.iridescenceMap),r.iridescenceTexture=t}if(r.iridescenceIor=e.iridescenceIOR,r.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(t,e.iridescenceThicknessMap),r.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},FH=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.transmissionFactor=e.transmission,e.transmissionMap){let t={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(t,e.transmissionMap),r.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},NH=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.thicknessFactor=e.thickness,e.thicknessMap){let t={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(t,e.thicknessMap),r.thicknessTexture=t}r.attenuationDistance=e.attenuationDistance,r.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},BH=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;let n=this.writer.extensionsUsed,i={};i.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0}},UH=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(Rct)&&!e.specularIntensityMap&&!e.specularColorTexture)return;let n=this.writer,i=n.extensionsUsed,r={};if(e.specularIntensityMap){let t={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(t,e.specularIntensityMap),r.specularTexture=t}if(e.specularColorMap){let t={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(t,e.specularColorMap),r.specularColorTexture=t}r.specularFactor=e.specularIntensity,r.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},HH=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;let n=this.writer,i=n.extensionsUsed,r={};if(e.sheenRoughnessMap){let t={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(t,e.sheenRoughnessMap),r.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(t,e.sheenColorMap),r.sheenColorTexture=t}r.sheenRoughnessFactor=e.sheenRoughness,r.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},VH=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;let n=this.writer,i=n.extensionsUsed,r={};if(e.anisotropyMap){let t={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(t,e.anisotropyMap),r.anisotropyTexture=t}r.anisotropyStrength=e.anisotropy,r.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},zH=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;let n=this.writer.extensionsUsed,i={};i.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0}};Xv.Utils={insertKeyframe:function(e,t){let n,i=e.getValueSize(),r=new e.TimeBufferType(e.times.length+1),a=new e.ValueBufferType(e.values.length+i),s=e.createInterpolant(new e.ValueBufferType(i));if(0===e.times.length){r[0]=t;for(let e=0;ee.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<.001)return e.times.length-1;r[r.length-1]=t,r.set(e.times,0),a.set(e.values,0),a.set(s.evaluate(t),e.values.length),n=r.length-1}else for(let o=0;ot){r.set(e.times.slice(0,o+1),0),r[o+1]=t,r.set(e.times.slice(o+1),o+2),a.set(e.values.slice(0,(o+1)*i),0),a.set(s.evaluate(t),(o+1)*i),a.set(e.values.slice((o+1)*i),(o+2)*i),n=o+1;break}}return e.times=r,e.values=a,n},mergeMorphTargetTracks:function(e,t){let n=[],i={},r=e.tracks;for(let a=0;a{if(n.binary){t=Fi.addExtention(t,Fi.EXTENSION_GLB);let n=e;Fi.saveArrayBuffer(n,t)}else t=Fi.addExtention(t,Fi.EXTENSION_GLTF),Fi.saveJson(e,t)}),(e=>console.log(e)),n)}static exportToObj(e,t){if(!e||!t)throw new Error("Invalid input or filename!");t=Fi.addExtention(t,Fi.EXTENSION_OBJ);let n=(new PA).parse(e);Fi.saveString(n,t)}static exportToDraco(e,t,n={}){if(!e||!t)throw new Error("Invalid input or filename!");t=Fi.addExtention(t,Fi.EXTENSION_DRACO);let i=new xa;n=Object.assign({},{encodeSpeed:5},n);let r=i.parse(e,n);Fi.saveArrayBuffer(r,t)}static exportToThreeJsJson(e,t){let n=e.toJSON();t.toLowerCase().endsWith(Fi.EXTENSION_JSON)||(t+=Fi.EXTENSION_JSON),Fi.saveJson(n,t)}static save(e,t){let n=Fi.downloadLink;n||(n=document.createElement("a"),n.style.display="none",document.body.appendChild(n),Fi.downloadLink=n),n.href=URL.createObjectURL(e),n.download=t,n.click()}static saveArrayBuffer(e,t){Fi.save(new Blob([e],{type:"application/octet-stream"}),t)}static saveJson(e,t){Fi.saveJsonString(JSON.stringify(e),t)}static saveJsonString(e,t){Fi.save(new Blob([e],{type:"application/json"}),t)}static saveString(e,t){Fi.save(new Blob([e],{type:"text/csv"}),t)}static addExtention(e,t){return e.toLowerCase().endsWith(t.toLowerCase())||(e+=t),e}},Lm=Fi;Lm.EXTENSION_GLTF=".gltf",Lm.EXTENSION_GLB=".glb",Lm.EXTENSION_OBJ=".obj",Lm.EXTENSION_DRACO=".drc",Lm.EXTENSION_JSON=".json";var IA=class{constructor(){this.prevTime=(performance||Date).now(),this.beginTime=(performance||Date).now(),this.frames=0,this.fps=Number.NaN}begin(){this.beginTime=(performance||Date).now()}end(){this.frames++;let e=(performance||Date).now();return e>=this.prevTime+1e3&&(this.fps=Math.round(1e3*this.frames/(e-this.prevTime)),this.frames=0,this.prevTime=e),e}update(){this.beginTime=this.end()}},YH={exports:{}};function OA(e,t,n){n=n||2;var i,r,a,s,o,l,h,c=t&&t.length,u=c?t[0]*n:e.length,d=Bde(e,0,u,n,!0),p=[];if(!d||d.next===d.prev)return p;if(c&&(d=Uct(e,t,d,n)),e.length>80*n){i=a=e[0],r=s=e[1];for(var f=n;fa&&(a=o),l>s&&(s=l);h=0!==(h=Math.max(a-i,s-r))?32767/h:0}return $b(d,p,n,i,r,h,0),p}function Bde(e,t,n,i,r){var a,s;if(r===XH(e,t,n,i)>0)for(a=t;a=t;a-=i)s=Dde(a,e[a],e[a+1],s);return s&&kA(s,s.next)&&(Kb(s),s=s.next),s}function Dm(e,t){if(!e)return e;t||(t=e);var n,i=e;do{if(n=!1,i.steiner||!kA(i,i.next)&&0!==Qi(i.prev,i,i.next))i=i.next;else{if(Kb(i),(i=t=i.prev)===i.next)break;n=!0}}while(n||i!==t);return t}function $b(e,t,n,i,r,a,s){if(e){!s&&a&&qct(e,i,r,a);for(var o,l,h=e;e.prev!==e.next;)if(o=e.prev,l=e.next,a?Fct(e,i,r,a):kct(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),Kb(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?$b(e=Nct(Dm(e),t,n),t,n,i,r,a,2):2===s&&Bct(e,t,n,i,r,a):$b(Dm(e),t,n,i,r,a,1);break}}}function kct(e){var t=e.prev,n=e,i=e.next;if(Qi(t,n,i)>=0)return!1;for(var r=t.x,a=n.x,s=i.x,o=t.y,l=n.y,h=i.y,c=ra?r>s?r:s:a>s?a:s,p=o>l?o>h?o:h:l>h?l:h,f=i.next;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&Yv(r,o,a,l,s,h,f.x,f.y)&&Qi(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Fct(e,t,n,i){var r=e.prev,a=e,s=e.next;if(Qi(r,a,s)>=0)return!1;for(var o=r.x,l=a.x,h=s.x,c=r.y,u=a.y,d=s.y,p=ol?o>h?o:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,v=WH(p,f,t,n,i),y=WH(m,g,t,n,i),x=e.prevZ,b=e.nextZ;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&Yv(o,c,l,u,h,d,x.x,x.y)&&Qi(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==s&&Yv(o,c,l,u,h,d,b.x,b.y)&&Qi(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&Yv(o,c,l,u,h,d,x.x,x.y)&&Qi(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==s&&Yv(o,c,l,u,h,d,b.x,b.y)&&Qi(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Nct(e,t,n){var i=e;do{var r=i.prev,a=i.next.next;!kA(r,a)&&Ude(r,i,i.next,a)&&Zb(r,a)&&Zb(a,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(a.i/n|0),Kb(i),Kb(i.next),i=e=a),i=i.next}while(i!==e);return Dm(i)}function Bct(e,t,n,i,r,a){var s=e;do{for(var o=s.next.next;o!==s.prev;){if(s.i!==o.i&&Xct(s,o)){var l=Hde(s,o);return s=Dm(s,s.next),l=Dm(l,l.next),$b(s,t,n,i,r,a,0),void $b(l,t,n,i,r,a,0)}o=o.next}s=s.next}while(s!==e)}function Uct(e,t,n,i){var r,a,s,o=[];for(r=0,a=t.length;r=i.next.y&&i.next.y!==i.y){var o=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(o<=r&&o>s&&(s=o,n=i.x=i.x&&i.x>=c&&r!==i.x&&Yv(an.x||i.x===n.x&&Gct(n,i)))&&(n=i,d=l)),i=i.next}while(i!==h);return n}function Gct(e,t){return Qi(e.prev,e,t.prev)<0&&Qi(t.next,e,e.next)<0}function qct(e,t,n,i){var r=e;do{0===r.z&&(r.z=WH(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,Wct(r)}function Wct(e){var t,n,i,r,a,s,o,l,h=1;do{for(n=e,e=null,a=null,s=0;n;){for(s++,i=n,o=0,t=0;t0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,l--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,h*=2}while(s>1);return e}function WH(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function jct(e){var t=e,n=e;do{(t.x=(e-s)*(a-o)&&(e-s)*(i-o)>=(n-s)*(t-o)&&(n-s)*(a-o)>=(r-s)*(i-o)}function Xct(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Yct(e,t)&&(Zb(e,t)&&Zb(t,e)&&$ct(e,t)&&(Qi(e.prev,e,t.prev)||Qi(e,t.prev,t))||kA(e,t)&&Qi(e.prev,e,e.next)>0&&Qi(t.prev,t,t.next)>0)}function Qi(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function kA(e,t){return e.x===t.x&&e.y===t.y}function Ude(e,t,n,i){var r=DA(Qi(e,t,n)),a=DA(Qi(e,t,i)),s=DA(Qi(n,i,e)),o=DA(Qi(n,i,t));return!!(r!==a&&s!==o||0===r&&LA(e,n,t)||0===a&&LA(e,i,t)||0===s&&LA(n,e,i)||0===o&&LA(n,t,i))}function LA(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function DA(e){return e>0?1:e<0?-1:0}function Yct(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Ude(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Zb(e,t){return Qi(e.prev,e,e.next)<0?Qi(e,t,e.next)>=0&&Qi(e,e.prev,t)>=0:Qi(e,t,e.prev)<0||Qi(e,e.next,t)<0}function $ct(e,t){var n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}function Hde(e,t){var n=new jH(e.i,e.x,e.y),i=new jH(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function Dde(e,t,n,i){var r=new jH(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Kb(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function jH(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function XH(e,t,n,i){for(var r=0,a=t,s=n-i;a0&&(i+=e[r-1].length,n.holes.push(i))}return n};var xDt=YH.exports;function Ode(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function Zct(e,t){var n=t[0],i=t[1],r=t[2],a=Math.sqrt(n*n+i*i+r*r)||1;return e[0]=n/a,e[1]=i/a,e[2]=r/a,e}function Kct(e,t,n){var i=t[0],r=t[1],a=t[2],s=n[0],o=n[1],l=n[2];return e[0]=r*l-a*o,e[1]=a*s-i*l,e[2]=i*o-r*s,e}function Jct(e,t){function n(e,t,n,i){e[0]=t,e[1]=n,e[2]=i}for(var i=[],r=[],a=[],s=[],o=[],l=[],h=e.length,c=new Float32Array(t.length),u=0;u0&&(d=(d=d.map((function(e){return e}))).reverse());for(var p=0,f=d.length-1;p0}var $H=1e-15,zde=(new Qe).set(0,0,-1,0,1,0,0,0,0,1,0,0,0,0,0,1),Gde=(new Qe).set(0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1),Zt=class{static roundNumber(e,t){return Math.round(e*Math.pow(10,t))/Math.pow(10,t)}static floorNumber(e,t){return Math.floor(e*Math.pow(10,t))/Math.pow(10,t)}static areNumbersEqual(e,t,n=1e-7){return Math.abs(e-t){let n=e.attributes[t];if(n instanceof uo){let i=n.clone();e.attributes[t]=i}}))}static isPointInPolygon(e,t,n=!1){let i=e.x,r=e.y,a=!1,s=t.length;for(let o=0,l=s-1;or!=c>r;n&&(u=s>=r!=c>=r),u&&i<(h-e)*(r-s)/(c-s)+e&&(a=!a)}return a}static caculateGeometryCenter(e){if(!e.hasAttribute("position"))return null;let t=e.getAttribute("position");if(0===t.count)return null;let n=new O,i=t.itemSize,r=t.array,a=[0,0,0];for(let s=0;s0&&n<0||i<0&&n>0)return!1;n=i}}return!0}static areLineSegmentsIntersecting(e,t){let{start:n,end:i}=e,{start:r,end:a}=t,s=r.clone().sub(n),o=i.clone().sub(n),l=a.clone().sub(n),h=s.cross(o).dot(l.cross(o)),c=n.clone().sub(r),u=a.clone().sub(r),d=i.clone().sub(r),p=c.cross(u).dot(d.cross(u));return h<0&&p<0}static getLineSegmentsIntersectingPoint(e,t){let{start:n,end:i}=e,{start:r,end:a}=t,s=jde.subVectors(i,n).normalize(),o=Xde.subVectors(a,r).normalize();if(1===s.dot(o))return null;let l=Yde.subVectors(r,n),h=s.clone().cross(o),c=l.clone().cross(o),u=l.clone().dot(h);if(u>=1e-5||u<=-1e-5)return null;let d=h.lengthSq();if(Zt.areNumbersEqual(0,d))return;let p=c.clone().dot(h)/d,f=n.clone().add(s.multiplyScalar(p));return f.equals(n)||f.equals(i)?null:f}static isPointOnLineSegment(e,t,n=.001){let{start:i,end:r}=t,a=jde.subVectors(i,r).length(),s=Xde.subVectors(e,i).length(),o=Yde.subVectors(e,r).length();return Math.abs(a-(s+o))<=n}static isPointOnLineSegments(e,t,n=.001){let i=!1;for(let r=0;r{n?t.add(e):(t.x+=e.x,t.y+=e.y)})),t.divideScalar(e.length);let i=!1;if(Qt.shouldRebasePositionOnRTC(t)){i=!0;for(let i=0;iZH||Math.abs(e.y)>ZH||e instanceof O&&Math.abs(e.z)>ZH}static calculateSurfaceArea(e){let t=0,n=e.getAttribute("position"),i=e.index;if(i)for(let r=0;r2&&(a=t?2*r:2*r-2);let s=new i(a),o=0;for(let l=0;l0&&l{let n=e.geometry.attributes.position.array;return e.localToWorld(new O(n[3*t],n[3*t+1],n[3*t+2]))};e.updateWorldMatrix(!0,!1);let s=(null==(n=e.geometry.getIndex())?void 0:n.array)||[],o=null!=(i=s[t])?i:t,l=null!=(r=s[t+1])?r:t+1;return[a(o),a(l)]}static arePolygonsIntersect(e,t){if(0===e.length||0===t.length||(qde.setFromPoints(e),Wde.setFromPoints(t),!qde.intersectsBox(Wde)))return!1;for(let n=0;n1-r)return;let o=t.y-e.y,l=e.x-t.x,h=o*e.x+l*e.y,c=i.y-n.y,u=n.x-i.x,d=c*n.x+u*n.y,p=o*u-c*l;return Math.abs(p){n.push([e.x,e.y])}));try{let{indices:e,position:i}=Vde([n],{lineWidth:t,depth:1}),r=new Dt;return r.setAttribute("position",new Bt(i,3)),r.setIndex(Array.from(e)),r}catch(e){return}}static releaseGeometryManually(e){e.index=null,e.attributes={}}static getAdjacentNonRepeatPoints(e,t=1e-7){let n=[],i=e.length;for(let r=0;r0){let e=[];return n.forEach((n=>{e.push(this.clonedHighlightMaterial(n,t))})),e}if(n instanceof vr)return this.clonedHighlightMaterial(n,t);console.warn(`[MaterialUtils] Invalid material: ${n}`)}static clonedHighlightMaterial(e,t={}){let{depthTest:n,highlightColor:i=new ct(583902),opacity:r=.7}=t,a=e.clone();return this.setMaterialColor(a,i),a.opacity=r,a.transparent=!0,void 0!==n&&(a.depthTest=n,a.side=Er),a}static cloneMaterial(e){if(!e)return e;if(Array.isArray(e)){let t=[];return e.forEach((e=>{t.push(e.clone())})),t}return e.clone()}static getMaterialColor(e){let t=new ct(16777215);return e instanceof xi||e instanceof Gn||e instanceof ln?t=e.color:e instanceof cn&&e.uniforms.u_color&&(t=e.uniforms.u_color.value),t}static setMaterialColor(e,t){var n,i,r;let a=e;null==(n=a.color)||n.set(t),null==(i=a.emissive)||i.set(t),null!=(r=a.uniforms)&&r.u_color&&a.uniforms.u_color.value.set(t)}static cloneMaterials(e){let t=new Map;e.traverse((e=>{e.material&&(e.material=(e=>{let n;return Array.isArray(e)?(n=[],e.forEach((e=>{if(t.has(e))n.push(t.get(e));else{let i=e.clone();t.set(e,i),n.push(i)}}))):e&&(t.has(e)?n=t.get(e):(n=e.clone(),t.set(e,n))),n})(e.material))}))}};function Ni(e,t=!1){let n=null!==e[0].index,i=new Set(Object.keys(e[0].attributes)),r=new Set(Object.keys(e[0].morphAttributes)),a={},s={},o=e[0].morphTargetsRelative,l=new Dt,h=0;for(let c=0;c0){e.matrixWorld||(e.matrixWorld=new Qe),e.matrixWorld.copy(e.matrix),n&&e.matrixWorld.premultiply(n);let i=e.children;for(let n=0,r=i.length;n{r.find((t=>t.id===e.id))||(r.push({id:e.id,opacity:e.opacity,transparent:e.transparent,side:e.side}),e.opacity*=t,e.transparent=!0,e.side=Er)},s=e=>{let n=r.find((t=>t.id===e.id));if(!n){let n=e.clone();return r.push({id:e.id,opacity:e.opacity,transparent:e.transparent,side:e.side,material:e,clonedMaterial:n}),n.opacity*=t,n.transparent=!0,n}return n.clonedMaterial};return e.traverse((e=>{if((!i||-1===i.indexOf(e.id))&&(!n||-1!==n.indexOf(e.id))&&e instanceof xt){let t=e;if(n||i){if(Array.isArray(t.material)){let e=[];t.material.forEach((t=>{let n=s(t);n&&e.push(n)})),t.material=e}else if(t.material){let e=s(t.material);e&&(t.material=e)}}else if(Array.isArray(t.material))t.material.forEach((e=>{a(e)}));else if(t.material){let e=t.material;a(e)}}})),r}static revertObjectOpacity(e,t,n,i){let r=new Set,a=e=>{if(!e||null==e.id||r.has(e.id))return;r.add(e.id);let n=t.find((t=>t.id===e.id));n&&(e.opacity=n.opacity,e.transparent=n.transparent,e.side=n.side,0===e.opacity&&se.warn(`[ObjectUtils] Material '${e.name}'s opacity is 0, you may not be able to see your objects!`))},s=e=>{let n=t.find((t=>t.clonedMaterial&&t.clonedMaterial.id===e.id));if(n)return n.material};e.traverse((e=>{if((!i||-1===i.indexOf(e.id))&&(!n||-1!==n.indexOf(e.id))&&e instanceof xt)if(Array.isArray(e.material)){let t=[];e.material.forEach((e=>{let n=s(e);n?t.push(n):a(e)})),e.material=t}else if(e.material){let t=s(e.material);t?e.material=t:a(e.material)}}))}static setObjectOpacityById(e,t,n=.3,i,r){let a=e.getObjectById(t);if(!a)throw new Error(`Failed to find object by id: ${t}`);return Ac.setObjectOpacity(a,n,i,r)}static revertObjectOpacityById(e,t,n,i,r){let a=e.getObjectById(t);if(!a)throw new Error(`Failed to find object by id: ${t}`);Ac.revertObjectOpacity(a,n,i,r)}static applyMaterialToObject(e,t,n,i){e.traverse((e=>{i&&-1!==i.indexOf(e.id)||n&&-1===n.indexOf(e.id)||e instanceof xt&&(e.userData.originalMaterial||(e.userData.originalMaterial=e.material),e.material=t)}))}static revertAppliedMaterialToObject(e,t,n){e.traverse((e=>{n&&-1!==n.indexOf(e.id)||t&&-1===t.indexOf(e.id)||e.userData.originalMaterial&&(e.material=e.userData.originalMaterial,e.userData.originalMaterial=void 0)}))}static applyMaterialToObjectById(e,t,n,i,r){let a=e.getObjectById(t);if(!a)throw new Error(`Failed to find object by id: ${t}`);this.applyMaterialToObject(a,n,i,r)}static revertAppliedMaterialToObjectById(e,t,n,i){let r=e.getObjectById(t);if(!r)throw new Error(`Failed to find object by id: ${t}`);this.revertAppliedMaterialToObject(r,n,i)}static applyOpacityMaterialToObject(e,t,n){let i=new ln({color:0,transparent:!0,opacity:.05});this.applyMaterialToObject(e,i,t,n)}static setWireframeMode(e){let t=new ln({color:16732160,wireframe:!0,transparent:!0,opacity:.8});e.traverseVisible((e=>{if(e instanceof xt){let n=e;n.userData.materialForWireframe=n.material,n.material=t}}))}static setWireframeModeById(e,t){let n=e.getObjectById(t);if(!n)throw new Error(`Failed to find object by id: ${t}`);Ac.setWireframeMode(n)}static revertWireframeMode(e){e.traverseVisible((e=>{e instanceof xt&&e.userData.materialForWireframe&&(e.material=e.userData.materialForWireframe,e.userData.materialForWireframe=void 0)}))}static revertWireframeModeById(e,t){let n=e.getObjectById(t);if(!n)throw new Error(`Failed to find object by id: ${t}`);Ac.revertWireframeMode(n)}static findInner(e,t,n=[],i=!1){let r=t.toLowerCase(),a=[],s=e=>-1!==e.toLowerCase().indexOf(r),o=e=>-1!==e.toString().indexOf(r),l=e=>{if(e.name&&-1!==e.name.toLowerCase().indexOf(r))return!0;if(e.gltfExtensions){let t=e.gltfExtensions,n=t.objectId&&t.objectId.Value||t.elementId&&t.elementId.Value;if(n&&-1!==n.toLowerCase().indexOf(r))return!0}return!1};if(n.length>0)for(let h=0;h{(s(e.name)||o(e.id)||l(e.userData))&&a.push(e)})),i&&a.length>0)return[a[0]]}else if(e.traverse((e=>{(s(e.name)||o(e.id)||l(e.userData))&&a.push(e)})),i&&a.length>0)return[a[0]];return a}static find(e,t,n=[],i=!1){return this.findInner(e,t,n,i)}static findFirst(e,t,n=[],i=!1){let r=this.findInner(e,t,n,i);if(r.length>0)return r[0]}static getFloorsFromString(e){let t=[],n=new RegExp(/(?:-?(?:\d+(?:\.5)?)F)(?=\W|$)/,"g").exec(e);return n&&n.length>0&&n.forEach((e=>{if(e){let n=e.replace("F",""),i=Number(n);i?t.push(i):console.log(`[OU] invalid floor: ${e}`)}})),t}static matchFloor(e,t){return-1!==this.getFloorsFromString(e).findIndex((e=>e===t))}static matchFloors(e,t){return-1!==this.getFloorsFromString(e).findIndex((e=>-1!==t.findIndex((t=>t===e))))}static distinctFloors(e,t){let n=[],i=e=>{this.getFloorsFromString(e).forEach((e=>{n[e]=!0}))};return t.forEach((t=>{let n=e.getObjectById(t);n&&n.traverse((e=>{if(i(e.name),e.userData.gltfExtensions){let t=e.userData.gltfExtensions;t.level&&t.level.Value&&i(t.level.Value)}}))})),Object.keys(n).sort()}static traverseObjectByFloors(e,t,n,i,r){let a=e.getObjectById(t);if(!a)return[];a.traverse((e=>{let t=this.matchFloors(e.name,n);if(!t&&e.userData&&e.userData.gltfExtensions){let i=e.userData.gltfExtensions;i.level&&i.level.Value&&(t=this.matchFloors(i.level.Value,n))}t&&i&&i(e),!t&&r&&r(e)}))}static setVisibleForFloors(e,t,n,i=!0){this.traverseObjectByFloors(e,t,n,(e=>{let t=e;for(;t;)t.visible=!0,t=t.parent||void 0}),(e=>{i&&(e.visible=!1)}))}static revertVisibleForFloors(e){e.traverse((e=>{e.visible=!0}))}static revertVisibleForFloorsById(e,t){let n=this.getObjectById(e,t);this.revertVisibleForFloors(n)}static getObjectById(e,t){let n=e.getObjectById(t);if(!n)throw new Error(`Failed to find object by id: ${t}`);return n}static createOutlines(e){return ft(this,arguments,(function*(e,t={onlyVisible:!0,meshOnly:!0},n){if(!e)return[];if(0===e.children.length&&(t.onlyVisible&&!e.visible||t.meshOnly&&!(e instanceof xt)))return[];let i=[],r=e,a=r.children.length,s=Math.round(Math.pow(a,.5)),o=Mt.getUpdateProgressFuncAsync(n);for(let l=a-1;l>=0;--l){let e,o=a-l-1;if(n&&(o%s==0||0===o||o===a-1)){let t=90*o/a,i=90*(o+1)/a;e=Mt.getUpdateSubProgressFunc(t,i,n)}let h=r.children[l],c=yield this.createOutlines(h,t,e);i.push(...c)}if(!r.geometry)return yield o(100),i;if(r instanceof xt&&!this.hasOutline(r,!1)){yield o(50);let e=this.createOutline(r.geometry);r.add(e),e.updateWorldMatrix(!0,!1),i.push(e)}return yield o(100),i}))}static removeOutlines(e){if(e&&Array.isArray(e.children))for(let t=e.children.length-1;t>=0;--t){let n=e.children[t];n.children.length>0&&this.removeOutlines(n),n.userData.isOutline&&e.remove(n)}}static hasOutline(e,t=!0){let n=!1;for(let i=0;i0&&(n=this.hasOutline(r),n))break}return n}static setOutlinesVisibility(e,t){e.traverse((e=>{e.userData.isOutline&&(e.visible=t)}))}static createOutline(e,t=this.OUTLINE_MATERIAL,n){let i=new Cu(e,10),r=new Wr(i,t);return r.layers.enableAll(),Ac.disableLayerChannels(r,[12,11]),r.userData.isOutline=!0,r.matrixAutoUpdate=!1,n&&r.applyMatrix4(n),r}static cloneObject(e,t=!0){let n=e.clone();return t&&n.traverse((e=>{(e instanceof xt||e instanceof ur)&&(e.material=es.cloneMaterial(e.material))})),n}static createBox(e,t,n,i=Ac.BOX_FACE_MATERIAL,r=!0){let a=[],s=(e,t,n)=>{a.push(new O(e,t,n))};s(0,0,0),s(e,0,0),s(e,t,0),s(0,t,0),s(0,0,n),s(e,0,n),s(e,t,n),s(0,t,n);let o=new Dt;o.setFromPoints(a);let l=[0,3,2,0,2,1,4,6,7,4,5,6,0,7,3,0,4,7,3,6,2,3,7,6,1,6,5,1,2,6];return r&&l.push(0,5,4,0,1,5),o.setIndex(l),o.computeVertexNormals(),new xt(o,i)}static rebaseObjectOnRTC(e){let t=e;if(!((t.isMesh||t.isLine||t.isPoints)&&t.geometry&&t.geometry instanceof Dt))return e;let n=t.geometry;if(!n.hasAttribute("position"))return e;let i=n.getAttribute("position");if(0===i.count)return e;let r=i.itemSize,a=i.array,s=[];for(let h=0;h2?s[2]:0);let l=e.matrixAutoUpdate;return e.matrixAutoUpdate=!1,e.applyMatrix4(o),e.matrixAutoUpdate=l,e}static isEmptyObject(e){if(0===e.children.length){let t=e.geometry;if(!t||!t.hasAttribute("position")||0===t.getAttribute("position").count)return!0}return!1}static removeEmptyObjects(e){for(let t=0;t{e.removeFromParent()})),this.removeEmptyObjects(t))}static setSharedVariablesOfObject(e){e.uuid="",e.up=out;let t=e;t.material&&(Array.isArray(t.material)?t.material.forEach((e=>{e.uuid&&(e.uuid="")})):t.material.uuid&&(t.material.uuid=""))}static isLeafObject(e){return(e instanceof xt||e instanceof ur||e instanceof ii)&&!!e.geometry}static enableLayerChannels(e,t,n=!0){for(let i=0,r=t.length;i0){this.mergeInner(n,t);continue}if(n.isInstancedMesh||!n.geometry||!(n.geometry instanceof Dt))continue;let a=!1,s=Object.values(i);for(let t=s.length-1;t>=0;--t){let n=s[t].indexes[0];if(a=this.tryHandleMergeableObjects(e,h,n,i,r),a)break}for(let t=r.length-1;!a&&t>=0;--t){let n=r[t];if(a=this.tryHandleMergeableObjects(e,h,n,i,r),a)break}a||r.push(h)}if(Object.keys(i).length<=0)return;let a=[],s=[],o=[],l=[];Object.values(i).forEach((n=>{let i,r=n.indexes,h=e.children[r[0]],c=[],u=0,d=0,p=0,f=[];if(r.forEach((n=>{var i,r,a;let s=e.children[n],o=s.geometry.clone();if(o.applyMatrix4(s.matrix),Qt.tryConvertInterleavedBufferAttributes(o),o.userData.isLineSegments=!0===s.isLineSegments,c.push(o),t){let e=s.name,t=null==(r=null==(i=o.attributes)?void 0:i.position)?void 0:r.count,n=(null==(a=o.index)?void 0:a.count)||0,l={batchId:u,name:e,positionStart:d,positionCount:t,indexStart:p,indexCount:n};0!==Object.keys(s.userData).length&&(l.userData=s.userData),f.push(l),d+=t,p+=n,u++}})),0!==c.length){if(h.isMesh){let e=Ni(c);if(!e)return;e.userData={},i=new xt(e,h.material),a.push(i)}else if(h.isLine){let e=this.mergeLineGeometries(c,t,h.material instanceof Iu||h.material instanceof cn,f);if(!e)return;i=new Wr(e,h.material),s.push(i)}else if(h.isPoints){let e=Ni(c);if(!e)return;e.userData={},i=new ii(e,h.material),o.push(i)}i&&(t?i.userData.batches=f:(i.userData=h.userData,i.userData.batches=void 0),i.userData.layerName=h.userData.layerName,i.name=`[Merged] ${h.name}`,i.matrixAutoUpdate=!1,i.renderOrder=h.renderOrder,i.layers.mask=h.layers.mask,i.visible=h.visible,l.push(...r)),c.forEach((e=>{e.dispose(),Qt.releaseGeometryManually(e)})),c=[]}})),l.sort(((e,t)=>t-e)),l.forEach((t=>{let n=e.children[t];e.remove(n)})),[...a,...s,...o].forEach((t=>{e.add(t)})),e.updateMatrix(),this.mergeInfo.removedObjects+=l.length,this.mergeInfo.mergedMeshes+=a.length,this.mergeInfo.mergedLines+=s.length,this.mergeInfo.mergedPoints+=o.length}static tryHandleMergeableObjects(e,t,n,i,r){let a=!1,s=Array.isArray(e),o=s?e.length:e.children.length;if(t===n||t>=o||n>=o)return a;let l=s?e[t]:e.children[t],h=s?e[n]:e.children[n];return this.areObjectsMergeable(l,h)&&this.areGeometriesMergeable(l.geometry,h.geometry)&&es.materialsEquals(l.material,h.material)&&(i[n]||(i[n]={indexes:[n]},this.removeFromArray(r,n)),i[n].indexes.push(t),a=!0),a}static deepMerge(e,t=void 0,n=!0,i=!0,r=!0){let a={added:[],removed:[]};if(e.length<=1)return a;let s=Date.now(),o={},l=[];for(let m=0;m=0;--r){let t=i[r].indexes[0];if(n=this.tryHandleMergeableObjects(e,m,t,o,l),n)break}for(let r=l.length-1;!n&&r>=0;--r){let t=l[r];if(n=this.tryHandleMergeableObjects(e,m,t,o,l),n)break}n||l.push(m)}if(Object.keys(o).length<=0)return a;se.debug(`[Merge] Built merged indexes for ${e.length} objects in ${(Date.now()-s)/1e3}s`),s=Date.now();let h=[],c=[],u=[],d=[];Object.values(o).forEach((n=>{let i=n.indexes;if(i.length<2)return;let a,s=e[i[0]],o=[],l=0,p=0,f=0,m=[];if(i.forEach((n=>{var i,a,h;let c=e[n],u=c.geometry.clone();if(s.material instanceof Gn&&u.deleteAttribute("lineDistance"),this.applyMatrix(u,c,t),u.userData.isLineSegments=!0===c.isLineSegments,o.push(u),r){let e,t=c.name,n=null==(a=null==(i=u.attributes)?void 0:i.position)?void 0:a.count,r=(null==(h=u.index)?void 0:h.count)||0;s.isLine&&(u.boundingSphere||u.computeBoundingSphere(),e=u.boundingSphere.clone());let o={batchId:l,name:t,positionStart:p,positionCount:n,indexStart:f,indexCount:r,boundingSphere:e};0!==Object.keys(c.userData).length&&(o.userData=c.userData),m.push(o),p+=n,f+=r,l++}})),0!==o.length){if(s.isMesh){let e=Ni(o);if(!e)return;e.userData={},a=new xt(e,s.material),h.push(a)}else if(s.isLine){let e=this.mergeLineGeometries(o,r,s.material instanceof Iu||s.material instanceof cn,m);if(!e)return;a=new Wr(e,s.material),c.push(a)}else if(s.isPoints){let e=Ni(o);if(!e)return;e.userData={},a=new ii(e,s.material),u.push(a)}a&&(r?a.userData.batches=m:(a.userData=s.userData,a.userData.batches=void 0),a.userData.layerName=s.userData.layerName,a.name=`[Merged] ${s.name}`,a.matrixAutoUpdate=!1,a.renderOrder=s.renderOrder,a.layers.mask=s.layers.mask,a.visible=s.visible,i.forEach((e=>d.push(e)))),o.forEach((e=>{e.dispose(),Qt.releaseGeometryManually(e)})),o=[]}})),se.debug(`[Merge] Ran deepMerge() in ${(Date.now()-s)/1e3}s`);let p=a.removed;d.forEach((t=>{let i=e[t];p.push(i),n&&i.removeFromParent()}));let f=a.added;return[...h,...c,...u].forEach((e=>{f.push(e),n&&t&&(t.add(e),e.updateWorldMatrix(!1,!1))})),this.mergeInfo.removedObjects+=d.length,this.mergeInfo.mergedMeshes+=h.length,this.mergeInfo.mergedLines+=c.length,this.mergeInfo.mergedPoints+=u.length,i&&t&&zn.removeEmptyObjects(t),a}static applyMatrix(e,t,n){let i=t;for(FA.identity();i&&i!==n&&(FA.premultiply(i.matrix),i.parent);)i=i.parent;return FA.equals(lut)?e:e.applyMatrix4(FA)}static mergeLineGeometries(e,t,n,i){let r;if(n)r=NA.mergeBufferGeometriesWithLinesToLineSegments(e,t,i);else{if(r=Ni(e),!r)return;r.userData={};let n=[],a=0;e.forEach(((e,r)=>{let s=e.attributes.position;if(!s)return;let o=e.index,l=!0===e.userData.isLineSegments,h=n.length;if(o)for(let t=0;t0&&n.push(a+o.array[t-1],a+e)}else for(let t=0;t0&&(l?t%2==1&&n.push(a+t-1,a+t):n.push(a+t-1,a+t));a+=s.count,t&&i&&(i[r].indexStart=h,i[r].indexCount=n.length-h)})),r.setIndex(n)}return r}static mergeBufferGeometriesWithLinesToLineSegments(e,t,n){let i=new Set(Object.keys(e[0].attributes)),r={},a=new Dt,s=[],o=0;for(let l=0;l=0;--n)if(e[n]===t)return void e.splice(n,1)}static removeObjectFromArray(e,t){for(let n=e.length-1;n>=0;--n)if(e[n]===t)return void e.splice(n,1)}static areGeometriesMergeable(e,t){if(!e||!t||"InstancedBufferGeometry"===e.type||"InstancedBufferGeometry"===t.type||!!e.index!=!!t.index)return!1;let n=Object.keys(e.attributes);if(n.length!==Object.keys(t.attributes).length)return!1;for(let i of n)if(!t.attributes[i])return!1;return!0}static areObjectsMergeable(e,t){if(e.layers.mask!==t.layers.mask||e.renderOrder!==t.renderOrder||e.visible!==t.visible||e.userData.layerName!==t.userData.layerName)return!1;if(e.type===t.type)return!0;let n=e,i=t;return n.isMesh&&i.isMesh||n.isLine&&i.isLine||n.isPoints&&i.isPoints}static isMergedMesh(e){return!(!e||!e.userData.batches)}static isFaceIndexInBatch(e,t,n){if(e.boundsTree){let i=e.index.getX(3*n);if(i>=t.positionStart&&i=e&&n<=i)return!0}else{let e=3*n;if(e>=t.positionStart&&e=e.indexStart&&t=e.positionStart&&t80*n){i=a=e[0],r=s=e[1];for(let t=n;ta&&(a=o),l>s&&(s=l);h=Math.max(a-i,s-r),h=0!==h?32767/h:0}return nE(d,p,n,i,r,h,0),p}};function Efe(e,t,n,i,r){let a,s;if(r===eht(e,t,n,i)>0)for(a=t;a=t;a-=i)s=xfe(a,e[a],e[a+1],s);return s&&jA(s,s.next)&&(iE(s),s=s.next),s}function km(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!jA(i,i.next)&&0!==ts(i.prev,i,i.next))i=i.next;else{if(iE(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function nE(e,t,n,i,r,a,s){if(!e)return;!s&&a&&Yut(e,i,r,a);let o,l,h=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,a?Hut(e,i,r,a):Uut(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),iE(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?nE(e=Vut(km(e),t,n),t,n,i,r,a,2):2===s&&zut(e,t,n,i,r,a):nE(km(e),t,n,i,r,a,1);break}}function Uut(e){let t=e.prev,n=e,i=e.next;if(ts(t,n,i)>=0)return!1;let r=t.x,a=n.x,s=i.x,o=t.y,l=n.y,h=i.y,c=ra?r>s?r:s:a>s?a:s,p=o>l?o>h?o:h:l>h?l:h,f=i.next;for(;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&$v(r,o,a,l,s,h,f.x,f.y)&&ts(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Hut(e,t,n,i){let r=e.prev,a=e,s=e.next;if(ts(r,a,s)>=0)return!1;let o=r.x,l=a.x,h=s.x,c=r.y,u=a.y,d=s.y,p=ol?o>h?o:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,v=a5(p,f,t,n,i),y=a5(m,g,t,n,i),x=e.prevZ,b=e.nextZ;for(;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&$v(o,c,l,u,h,d,x.x,x.y)&&ts(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==s&&$v(o,c,l,u,h,d,b.x,b.y)&&ts(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&$v(o,c,l,u,h,d,x.x,x.y)&&ts(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==s&&$v(o,c,l,u,h,d,b.x,b.y)&&ts(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Vut(e,t,n){let i=e;do{let r=i.prev,a=i.next.next;!jA(r,a)&&_fe(r,i,i.next,a)&&rE(r,a)&&rE(a,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(a.i/n|0),iE(i),iE(i.next),i=e=a),i=i.next}while(i!==e);return km(i)}function zut(e,t,n,i,r,a){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&Kut(s,e)){let o=Tfe(s,e);return s=km(s,s.next),o=km(o,o.next),nE(s,t,n,i,r,a,0),void nE(o,t,n,i,r,a,0)}e=e.next}s=s.next}while(s!==e)}function Gut(e,t,n,i){let r,a,s,o,l,h=[];for(r=0,a=t.length;r=i.next.y&&i.next.y!==i.y){let e=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=a&&e>r&&(r=e,n=i.x=i.x&&i.x>=h&&a!==i.x&&$v(sn.x||i.x===n.x&&Xut(n,i)))&&(n=i,u=o)),i=i.next}while(i!==l);return n}function Xut(e,t){return ts(e.prev,e,t.prev)<0&&ts(t.next,e,e.next)<0}function Yut(e,t,n,i){let r=e;do{0===r.z&&(r.z=a5(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,$ut(r)}function $ut(e){let t,n,i,r,a,s,o,l,h=1;do{for(n=e,e=null,a=null,s=0;n;){for(s++,i=n,o=0,t=0;t0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,l--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,h*=2}while(s>1);return e}function a5(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Zut(e){let t=e,n=e;do{(t.x=(e-s)*(a-o)&&(e-s)*(i-o)>=(n-s)*(t-o)&&(n-s)*(a-o)>=(r-s)*(i-o)}function Kut(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Jut(e,t)&&(rE(e,t)&&rE(t,e)&&Qut(e,t)&&(ts(e.prev,e,t.prev)||ts(e,t.prev,t))||jA(e,t)&&ts(e.prev,e,e.next)>0&&ts(t.prev,t,t.next)>0)}function ts(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function jA(e,t){return e.x===t.x&&e.y===t.y}function _fe(e,t,n,i){let r=WA(ts(e,t,n)),a=WA(ts(e,t,i)),s=WA(ts(n,i,e)),o=WA(ts(n,i,t));return!!(r!==a&&s!==o||0===r&&qA(e,n,t)||0===a&&qA(e,i,t)||0===s&&qA(n,e,i)||0===o&&qA(n,t,i))}function qA(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function WA(e){return e>0?1:e<0?-1:0}function Jut(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&_fe(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function rE(e,t){return ts(e.prev,e,e.next)<0?ts(e,t,e.next)>=0&&ts(e,e.prev,t)>=0:ts(e,t,e.prev)<0||ts(e,e.next,t)<0}function Qut(e,t){let n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}function Tfe(e,t){let n=new o5(e.i,e.x,e.y),i=new o5(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function xfe(e,t,n,i){let r=new o5(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function iE(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function o5(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function eht(e,t,n,i){let r=0;for(let a=t,s=n-i;ae.toArray())).reduce(((e,t)=>(e.push(...t),e)),[]),n=[];return bfe.triangulate(t,[],3).forEach((e=>n.push(e))),n}static arePointsCoplanar(e){if(e.length<4)return!0;let t=e[1].clone().sub(e[0]),n=e[2].clone().sub(e[0]).cross(t).normalize();for(let i=3;itht)return!1;return!0}static isSelfIntersecting(e){let t=e.map((e=>e.toArray().slice(0,-1)));return(0,wfe.default)(t).length>0}},ks=class{static getVisibleObjectBoundingBox(e){let t=new Ot;return e.traverse((e=>{e.visible&&(e instanceof xt||e instanceof ur)&&zn.isObjectSelectable(e)&&t.expandByObject(e)})),t}static getObjectsBoundingBox(e,t,n){let i=new Ot;return t.forEach((t=>{let r=e.getObjectById(t);if(r){let e=ks.getBoundingBox(r,n);e.isEmpty()||i.union(e)}})),i}static getBoundingBox(e,t=!0){let n=new Ot;if(e instanceof Pi)return ks.getInstancedMeshBoundingBox(e);if(0===e.children.length)return n.expandByObject(e),n;let i=e.children.length,r=1;i>20&&(r=3),i>100&&(r=5),i>200&&(r=10),i>1e3&&(r=100),e.updateMatrixWorld(!1);for(let a=0;a{let t=e.material;Array.isArray(t)?t.forEach((e=>{e.clippingPlanes=void 0})):t&&(t.clippingPlanes=void 0)}))}static addSection(e,t,n=!1,i=!1){e&&e.traverse((e=>{let r=e.material;Array.isArray(r)?r.forEach((e=>{Hu.setMaterialSection(e,t,n,i)})):r&&Hu.setMaterialSection(r,t,n,i)}))}static generateSectionPlanesByBox(e){let t=e.min,n=e.max;return[new Gr(new O(0,-1,0),n.y),new Gr(new O(0,1,0),-t.y),new Gr(new O(1,0,0),-t.x),new Gr(new O(-1,0,0),n.x)]}static generateSectionPlanesByPoints(e,t=!0){let n=e.length;if(n<2)return;let i=[];for(let r=0;r-1&&e.splice(n,1)}function rht(e,t){let n=t.position.distanceTo(e.position),i=0,r=[];for(let a=0,s=e.faces.length;a=0;a--)n.faces[a]&&n.faces[a].hasVertex(i)&&iht(n.faces[a],t);for(let a=n.faces.length-1;a>=0;a--)n.faces[a].replaceVertex(n,i);Mfe(n,e);for(let a=0;a0?(new XA).modify(e,n):e}static getNumberOfVerticesToRemove(e,t){let n=0;e instanceof Dt&&e.index&&(n=e.attributes.position.count);let i=Math.floor(n*t);return n<20?0:i}},$A=class extends on{constructor(e){super(),this.isSVGObject=!0,this.node=e}},TOt=10,Pfe=(e=>(e.TripleCross="TripleCross",e.Square="Square",e.Triangle="Triangle",e.CircleWithCross="CircleWithCross",e.Cross="Cross",e.Perpendicular="Perpendicular",e))(Pfe||{}),Cfe=class{static createSVGObject(e){return new $A(e)}},ZA=class extends Tm{constructor(e){super(e),this.type=Rr}parse(e){let t=function(e,t){switch(e){case 1:console.error("THREE.RGBELoader Read Error: "+(t||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(t||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(t||""));break;default:console.error("THREE.RGBELoader: Error: "+(t||""))}return-1},n=function(e,t,n){t=t||1024;let i=e.pos,r=-1,a=0,s="",o=String.fromCharCode.apply(null,new Uint16Array(e.subarray(i,i+128)));for(;0>(r=o.indexOf("\n"))&&a=e.byteLength||!(i=n(e)))return t(1,"no header found");if(!(r=i.match(/^#\?(\S+)/)))return t(3,"bad initial token");for(h.valid|=1,h.programtype=r[1],h.string+=i+"\n";i=n(e),!1!==i;)if(h.string+=i+"\n","#"!==i.charAt(0)){if((r=i.match(a))&&(h.gamma=parseFloat(r[1])),(r=i.match(s))&&(h.exposure=parseFloat(r[1])),(r=i.match(o))&&(h.valid|=2,h.format=r[1]),(r=i.match(l))&&(h.valid|=4,h.height=parseInt(r[1],10),h.width=parseInt(r[2],10)),2&h.valid&&4&h.valid)break}else h.comments+=i+"\n";return 2&h.valid?4&h.valid?h:t(3,"missing image size specifier"):t(3,"missing format specifier")}(a);if(-1!==s){let e=s.width,n=s.height,o=function(e,n,i){let r=n;if(r<8||r>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(r!==(e[2]<<8|e[3]))return t(3,"wrong scanline width");let a=new Uint8Array(4*n*i);if(!a.length)return t(4,"unable to allocate buffer space");let s=0,o=0,l=4*r,h=new Uint8Array(4),c=new Uint8Array(l),u=i;for(;u>0&&oe.byteLength)return t(1);if(h[0]=e[o++],h[1]=e[o++],h[2]=e[o++],h[3]=e[o++],2!=h[0]||2!=h[1]||(h[2]<<8|h[3])!=r)return t(3,"bad rgbe scanline format");let n,i=0;for(;i128;if(r&&(n-=128),0===n||i+n>l)return t(3,"bad scanline data");if(r){let t=e[o++];for(let e=0;e{n.load(t,(t=>{if(e){let n=e.fromEquirectangular(t).texture;e.dispose(),i(n)}}))}))}))}static createEnvTextureFromDataArray(e){return ft(this,arguments,(function*(e,t=this.HDR_CITY_STREET_64x32,n=64,i=32){if(e){let r=new Sl(t,n,i);r.flipY=!0,r.magFilter=Ir,r.minFilter=Ir,r.type=Rr,r.version=1;let a=e.fromEquirectangular(r).texture;return e.dispose(),Promise.resolve(a)}return Promise.reject("Invalid pmremGenerator!")}))}};function oht(){if(Dn.isBrowser){let e=document.createElement("div");return e.setAttribute("style","height: 1in; visibility: hidden; position: absolute; margin: 0; padding: 0;"),document.body.appendChild(e),.0254/e.clientHeight}return.0254/96}Cc.HDR_CITY_STREET_64x32=Uint16Array.from([11910,12340,12797,15360,11926,12348,12806,15360,11958,12364,12814,15360,11974,12380,12830,15360,11958,12364,12822,15360,11926,12348,12797,15360,11878,12324,12773,15360,11830,12308,12749,15360,11798,12292,12733,15360,11782,12279,12725,15360,11765,12263,12709,15360,11749,12247,12701,15360,11733,12231,12701,15360,11701,12215,12693,15360,11685,12199,12685,15360,11685,12199,12685,15360,11701,12215,12693,15360,11717,12231,12701,15360,11733,12247,12709,15360,11749,12263,12717,15360,11749,12279,12717,15360,11765,12279,12725,15360,11765,12279,12725,15360,11765,12292,12725,15360,11798,12300,12733,15360,11830,12316,12749,15360,11846,12324,12757,15360,11894,12340,12781,15360,11926,12356,12797,15360,11942,12356,12797,15360,11926,12348,12789,15360,11926,12348,12789,15360,11942,12356,12797,15360,11942,12356,12797,15360,11942,12348,12806,15360,11942,12356,12806,15360,11942,12356,12814,15360,11958,12372,12830,15360,11974,12372,12830,15360,11974,12372,12838,15360,11990,12388,12854,15360,12055,12420,12886,15360,12119,12452,12918,15360,12167,12476,12950,15360,12231,12500,12982,15360,12263,12516,12998,15360,12231,12500,12974,15360,12199,12484,12958,15360,12199,12484,12958,15360,12199,12492,12966,15360,12247,12508,12982,15360,12247,12508,12990,15360,12231,12500,12982,15360,12199,12484,12966,15360,12167,12468,12942,15360,12119,12444,12918,15360,12087,12436,12902,15360,12055,12420,12886,15360,12055,12412,12878,15360,12039,12412,12878,15360,12022,12396,12862,15360,12006,12388,12846,15360,11958,12364,12830,15360,11910,12340,12806,15360,12119,12508,13103,15360,12087,12484,13071,15360,12055,12468,13046,15360,12006,12436,13006,15360,11926,12396,12958,15360,11878,12364,12926,15360,11846,12348,12894,15360,11782,12308,12854,15360,11749,12292,12830,15360,11717,12263,12814,15360,11685,12247,12806,15360,11669,12215,12789,15360,11685,12231,12789,15360,11701,12247,12797,15360,11701,12247,12806,15360,11717,12263,12814,15360,11749,12292,12822,15360,11782,12308,12838,15360,11798,12316,12846,15360,11814,12332,12862,15360,11846,12340,12870,15360,11862,12348,12878,15360,11846,12340,12870,15360,11846,12340,12862,15360,11878,12356,12886,15360,11910,12372,12910,15360,11942,12396,12934,15360,11958,12412,12958,15360,12039,12452,12998,15360,12071,12468,13022,15360,12039,12452,12998,15360,12039,12452,12998,15360,12006,12444,13006,15360,11974,12436,12998,15360,11942,12412,12982,15360,11926,12396,12974,15360,11926,12404,12974,15360,11958,12420,12998,15360,12006,12452,13038,15360,12055,12476,13071,15360,12039,12476,13079,15360,12087,12508,13127,15360,12247,12597,13231,15360,12388,12693,13332,15360,12420,12741,13364,15360,12436,12757,13372,15360,12468,12773,13380,15360,12500,12806,13388,15360,12516,12822,13404,15360,12629,12934,13452,15360,12741,13046,13508,15360,12806,13095,13532,15360,12757,13046,13516,15360,12645,12950,13460,15360,12565,12870,13428,15360,12532,12838,13412,15360,12549,12854,13412,15360,12516,12838,13396,15360,12452,12757,13356,15360,12420,12725,13340,15360,12404,12709,13332,15360,12372,12677,13316,15360,12279,12589,13207,15360,12135,12516,13119,15360,12388,12709,13348,15360,12247,12581,13223,15360,12055,12476,13087,15360,11910,12388,12982,15360,11733,12308,12886,15360,11669,12247,12846,15360,11621,12199,12814,15360,11541,12103,12765,15360,11492,12055,12733,15360,11508,12055,12733,15360,11476,12022,12717,15360,11525,12055,12725,15360,11589,12135,12757,15360,11669,12199,12765,15360,11765,12292,12814,15360,11862,12348,12886,15360,11910,12372,12910,15360,12006,12420,12966,15360,12071,12452,12998,15360,12119,12476,13022,15360,12167,12492,13046,15360,12183,12500,13063,15360,12199,12524,13079,15360,12308,12589,13151,15360,12300,12581,13151,15360,12167,12516,13087,15360,12087,12468,13030,15360,12022,12444,13014,15360,11990,12420,12990,15360,11974,12420,12990,15360,11974,12420,12990,15360,11990,12436,13014,15360,11990,12444,13030,15360,12103,12500,13103,15360,12087,12508,13111,15360,12039,12484,13103,15360,12039,12476,13103,15360,11942,12436,13054,15360,11974,12452,13087,15360,12039,12492,13135,15360,12103,12532,13199,15360,12183,12581,13263,15360,12308,12661,13340,15360,12484,12822,13436,15360,12613,12918,13484,15360,12725,13046,13540,15360,13046,13332,13677,15360,13143,13380,13717,15360,13223,13420,13741,15360,13396,13540,13862,15360,13436,13589,13902,15360,13484,13629,13942,15360,13468,13621,13934,15360,13412,13564,13878,15360,13372,13524,13846,15360,13287,13452,13781,15360,13223,13428,13749,15360,13340,13492,13805,15360,13239,13428,13749,15360,13095,13364,13685,15360,12918,13223,13597,15360,12822,13111,13556,15360,12613,12934,13468,15360,12532,12854,13428,15360,12565,12870,13444,15360,12468,12789,13396,15360,12372,12693,13340,15360,12087,12492,13111,15360,11846,12364,12958,15360,11717,12300,12878,15360,11557,12135,12781,15360,11476,12055,12741,15360,11460,12022,12725,15360,11476,12022,12725,15360,11476,12022,12709,15360,11476,11958,12605,15360,11364,11733,12332,15360,11111,11412,11661,15360,11223,11476,11773,15360,11388,11669,12095,15360,11765,12119,12492,15360,12388,12613,13079,15360,12661,12902,13356,15360,12998,13255,13564,15360,13372,13508,13797,15360,13412,13548,13846,15360,13287,13436,13725,15360,13271,13428,13709,15360,13287,13428,13717,15360,13014,13287,13597,15360,12709,12998,13460,15360,12452,12741,13332,15360,12364,12653,13271,15360,12404,12693,13316,15360,12420,12709,13316,15360,12420,12709,13332,15360,12263,12589,13231,15360,12332,12661,13312,15360,12300,12629,13295,15360,12263,12605,13287,15360,12231,12597,13279,15360,12247,12613,13303,15360,12231,12597,13295,15360,12231,12605,13312,15360,12199,12597,13324,15360,12231,12613,13340,15360,12516,12870,13468,15360,12725,13063,13564,15360,12741,13079,13573,15360,12854,13175,13613,15360,12902,13223,13629,15360,13046,13348,13693,15360,13356,13516,13846,15360,13605,13765,14078,15360,13717,13870,14191,15360,13765,13918,14255,15360,13765,13910,14247,15360,13701,13854,14191,15360,13573,13733,14070,15360,13508,13677,14006,15360,13380,13548,13886,15360,13111,13380,13741,15360,13063,13348,13709,15360,12886,13207,13629,15360,12725,13046,13548,15360,12645,12966,13508,15360,12677,12982,13508,15360,12629,12950,13492,15360,12452,12789,13412,15360,12324,12661,13332,15360,12356,12677,13340,15360,12388,12693,13348,15360,12279,12597,13247,15360,11894,12396,12998,15360,11637,12231,12846,15360,11573,12135,12789,15360,11589,12151,12797,15360,11621,12167,12797,15360,11637,12119,12677,15360,11079,11404,11693,15360,10517,10701,10653,15360,10252,10348,10007,15360,9902,9999,9428,15360,9846,9886,9047,15360,10135,10260,9685,15360,10412,10533,10412,15360,11268,11436,11549,15360,12364,12605,13087,15360,12444,12709,13255,15360,12549,12822,13348,15360,12613,12886,13396,15360,12597,12886,13412,15360,12581,12870,13404,15360,12661,12950,13460,15360,12725,13014,13492,15360,13079,13332,13645,15360,12757,13046,13500,15360,12677,12982,13476,15360,12854,13143,13556,15360,12693,12982,13492,15360,12581,12886,13452,15360,12709,13030,13508,15360,12372,12709,13364,15360,12324,12661,13348,15360,12292,12645,13340,15360,12292,12645,13348,15360,12468,12806,13436,15360,12532,12854,13460,15360,12500,12854,13468,15360,12500,12854,13484,15360,12725,13063,13589,15360,12982,13324,13701,15360,13111,13388,13741,15360,13014,13340,13709,15360,13014,13332,13717,15360,13287,13476,13862,15360,13436,13621,13974,15360,13532,13717,14095,15360,13725,13902,14295,15360,13942,14103,14420,15360,13974,14135,14436,15360,13862,14022,14388,15360,13725,13894,14295,15360,13789,13958,14336,15360,13830,13990,14348,15360,13372,13548,13942,15360,13014,13332,13733,15360,12886,13239,13661,15360,12854,13207,13637,15360,12757,13095,13589,15360,12757,13079,13573,15360,12645,12982,13516,15360,12629,12966,13532,15360,12549,12870,13468,15360,12356,12693,13372,15360,12151,12549,13231,15360,12215,12573,13247,15360,12199,12565,13231,15360,12071,12492,13135,15360,12055,12468,13087,15360,11878,12372,12958,15360,11685,12199,12781,15360,10774,11159,11412,15360,9533,9621,8870,15360,9308,9340,8071,15360,9276,9300,7878,15360,9324,9332,8420,15360,9191,9216,7991,15360,8950,8983,7766,15360,9493,9525,8677,15360,10252,10332,10007,15360,10661,10846,10894,15360,10701,10926,10998,15360,10950,11276,11428,15360,11364,11637,12063,15360,11958,12388,12926,15360,12183,12540,13175,15360,12340,12645,13295,15360,12420,12693,13316,15360,12757,13030,13460,15360,13046,13324,13645,15360,13095,13348,13677,15360,13303,13460,13781,15360,13207,13404,13741,15360,13127,13372,13717,15360,13372,13524,13862,15360,12693,13030,13540,15360,12725,13046,13548,15360,12468,12822,13436,15360,12263,12629,13348,15360,12436,12773,13428,15360,12693,12998,13524,15360,12725,13046,13564,15360,12645,12982,13556,15360,12613,12966,13556,15360,12886,13255,13685,15360,13436,13629,14022,15360,13637,13813,14231,15360,13621,13789,14215,15360,13878,14038,14412,15360,14022,14183,14468,15360,13926,14119,14452,15360,14054,14231,14508,15360,14135,14311,14540,15360,14348,14436,14669,15360,14460,14540,14749,15360,14404,14484,14709,15360,14420,14500,14709,15360,14653,14717,14894,15360,14119,14279,14508,15360,13484,13669,14078,15360,13063,13380,13773,15360,12677,13079,13613,15360,12484,12886,13516,15360,12436,12822,13476,15360,12468,12838,13476,15360,12039,12532,13316,15360,12231,12613,13340,15360,12468,12789,13436,15360,12388,12725,13396,15360,12135,12557,13287,15360,12151,12557,13271,15360,12039,12484,13175,15360,11878,12396,13038,15360,11814,12348,12950,15360,11492,11894,12460,15360,9950,10103,9621,15360,8830,8838,7220,15360,8565,8533,7015,15360,8541,8501,6919,15360,8332,8300,6822,15360,8412,8372,7220,15360,8710,8701,7686,15360,9372,9404,8549,15360,9533,9621,9079,15360,9268,9292,8196,15360,9452,9460,8167,15360,9533,9581,8533,15360,9742,9870,9316,15360,11460,11814,12348,15360,11942,12388,12902,15360,11749,12167,12573,15360,11300,11492,11621,15360,11974,12332,12669,15360,12436,12741,13364,15360,12597,12886,13460,15360,12966,13271,13653,15360,12998,13303,13669,15360,13476,13629,13974,15360,13733,13886,14239,15360,13364,13524,13894,15360,13063,13356,13725,15360,12982,13287,13669,15360,12484,12806,13444,15360,12565,12902,13500,15360,12950,13287,13693,15360,12934,13271,13677,15360,12693,13046,13589,15360,12661,13030,13605,15360,12870,13271,13717,15360,13348,13548,13966,15360,13621,13813,14271,15360,13797,13974,14412,15360,13942,14119,14484,15360,14263,14388,14629,15360,14420,14508,14733,15360,14460,14548,14773,15360,14982,15046,15231,15360,15564,15580,15669,15360,15974,15982,16078,15360,15805,15821,15926,15360,15460,15476,15572,15360,15436,15460,15556,15360,14781,14862,15127,15360,13621,13813,14348,15360,12789,13207,13757,15360,12452,12886,13581,15360,12263,12709,13476,15360,12039,12597,13396,15360,11942,12516,13340,15360,11846,12468,13271,15360,11733,12380,13127,15360,11926,12460,13191,15360,12055,12524,13263,15360,11878,12428,13159,15360,11605,12231,12886,15360,11412,11990,12709,15360,11508,12103,12789,15360,11637,12231,12854,15360,10661,11079,11380,15360,9541,9685,9252,15360,8573,8605,7493,15360,8404,8388,7348,15360,8830,8822,8212,15360,9308,9324,9095,15360,9324,9364,9220,15360,9047,9119,8653,15360,9023,9055,8404,15360,9055,9063,8167,15360,8870,8846,7541,15360,8862,8806,7380,15360,8950,8910,7252,15360,9268,9284,7557,15360,10316,10468,10380,15360,11239,11476,11677,15360,10653,10942,11047,15360,9661,9814,9324,15360,10693,10958,11047,15360,11396,11653,11990,15360,11878,12292,12597,15360,12468,12789,13396,15360,12773,13095,13589,15360,13364,13516,13894,15360,13894,14054,14380,15360,13717,13870,14247,15360,13420,13589,13958,15360,13255,13452,13830,15360,12806,13143,13637,15360,13159,13412,13830,15360,13629,13813,14215,15360,13303,13500,13910,15360,13079,13396,13805,15360,13191,13452,13878,15360,13412,13621,14062,15360,14103,14279,14540,15360,14773,14854,15086,15360,14717,14805,15046,15360,14295,14420,14685,15360,14380,14476,14733,15360,14572,14661,14902,15360,15596,15612,15701,15360,16351,16335,16384,15360,16484,16476,16492,15360,16516,16500,16516,15360,16388,16375,16404,15360,16054,16054,16118,15360,15918,15926,16006,15360,15556,15572,15669,15360,14653,14725,14982,15360,13637,13838,14319,15360,13412,13613,14054,15360,12870,13287,13789,15360,12404,12838,13524,15360,12199,12677,13428,15360,12324,12741,13452,15360,11942,12516,13324,15360,11765,12380,13111,15360,11428,11942,12589,15360,10886,11388,11902,15360,10372,10717,11006,15360,9846,10240,10191,15360,10252,10549,10766,15360,10613,11079,11484,15360,10581,10998,11388,15360,9613,9846,9629,15360,8525,8557,7541,15360,8605,8613,7814,15360,9292,9324,9079,15360,9388,9396,9220,15360,10709,10846,11031,15360,9894,9966,9854,15360,9252,9236,8774,15360,8822,8790,8183,15360,8292,8260,6533,15360,8111,8007,6324,15360,8228,8183,6405,15360,8501,8501,6565,15360,8814,8878,7172,15360,9260,9364,8244,15360,8902,9095,8252,15360,9444,9581,9047,15360,9509,9637,8790,15360,9477,9613,8806,15360,10725,11063,11079,15360,11508,11910,12356,15360,12484,12789,13380,15360,12838,13159,13629,15360,13428,13589,13974,15360,14135,14279,14484,15360,13942,14087,14396,15360,13677,13846,14247,15360,13436,13613,14006,15360,13597,13781,14183,15360,14183,14340,14540,15360,14022,14215,14484,15360,13637,13838,14271,15360,14038,14231,14508,15360,14380,14476,14701,15360,14757,14854,15078,15360,15030,15111,15343,15360,15420,15452,15556,15360,15476,15500,15588,15360,15351,15388,15492,15360,15572,15596,15677,15360,15653,15669,15717,15360,15821,15821,15853,15360,15845,15845,15869,15360,15998,15990,16022,15360,15926,15926,15974,15360,15653,15669,15733,15360,15661,15677,15749,15360,15612,15629,15717,15360,15271,15335,15452,15360,14484,14572,14821,15360,14215,14372,14588,15360,13468,13677,14167,15360,12773,13175,13653,15360,12725,13143,13637,15360,12452,12886,13532,15360,12263,12709,13444,15360,11894,12436,13103,15360,10252,10533,10661,15360,8613,8693,7445,15360,8742,8782,7047,15360,8420,8412,6565,15360,7926,7910,6405,15360,8806,8854,7300,15360,9127,9228,8007,15360,8685,8750,7300,15360,8348,8356,6758,15360,8380,8340,7300,15360,8991,8918,8388,15360,9838,9790,9549,15360,10055,10127,10047,15360,9501,9493,9268,15360,9332,9292,8902,15360,9079,9007,8509,15360,8300,8260,7252,15360,8693,8701,8196,15360,8228,8212,7111,15360,8469,8501,7380,15360,8420,8501,6919,15360,8549,8645,6983,15360,8581,8661,6951,15360,9268,9332,7718,15360,9063,9207,7445,15360,9284,9380,7718,15360,9412,9557,8693,15360,10276,10517,10103,15360,11830,12279,12589,15360,12725,13079,13589,15360,13127,13396,13773,15360,14087,14231,14460,15360,13974,14119,14412,15360,13677,13854,14247,15360,14119,14279,14500,15360,13990,14167,14460,15360,14364,14452,14653,15360,14564,14653,14837,15360,14404,14492,14701,15360,14870,14942,15135,15360,15388,15420,15500,15360,15207,15287,15420,15360,14797,14894,15127,15360,15271,15335,15452,15360,15926,15942,15990,15360,16207,16207,16231,15360,16118,16110,16126,15360,15741,15733,15741,15360,16239,16207,16175,15360,16444,16460,16484,15360,16046,16022,16006,15360,15942,15950,15966,15360,15773,15789,15829,15360,15789,15797,15845,15360,15693,15709,15757,15360,15540,15564,15653,15360,15303,15364,15468,15360,14733,14813,15014,15360,13862,14054,14420,15360,12838,13255,13725,15360,12789,13207,13693,15360,12468,12918,13564,15360,12404,12838,13500,15360,11428,11862,12412,15360,9143,9276,8388,15360,8541,8533,6726,15360,8444,8428,6629,15360,8212,8183,6597,15360,8388,8380,7015,15360,8726,8710,6758,15360,8332,8316,6437,15360,8453,8428,6565,15360,8597,8605,7814,15360,8701,8661,8151,15360,9452,9396,9015,15360,10581,10557,10380,15360,10950,10974,10846,15360,10380,10356,10252,15360,10749,10741,10685,15360,9870,9854,9693,15360,9023,9039,8669,15360,8790,8854,8509,15360,8196,8167,7332,15360,7975,8015,7079,15360,8589,8750,7445,15360,9095,9260,7111,15360,8983,9135,7188,15360,8902,8991,7252,15360,8862,9007,7015,15360,8967,9111,7300,15360,8742,8878,7493,15360,9557,9999,9549,15360,11292,11613,11862,15360,12135,12468,12982,15360,12215,12460,12878,15360,13356,13468,13685,15360,13821,13934,14199,15360,13548,13701,14022,15360,14103,14263,14468,15360,14279,14388,14572,15360,14364,14452,14645,15360,14709,14789,14950,15360,15143,15199,15327,15360,15388,15412,15468,15360,15476,15500,15548,15360,15420,15444,15492,15360,15436,15460,15516,15360,15612,15637,15685,15360,16086,16086,16110,15360,16396,16388,16396,15360,16094,16094,16110,15360,15869,15861,15861,15360,16135,16110,16070,15360,16428,16420,16404,15360,15588,15556,15524,15360,15484,15500,15508,15360,15335,15364,15396,15360,15677,15685,15717,15360,15604,15621,15661,15360,15420,15444,15500,15360,15303,15372,15452,15360,14717,14805,14998,15360,14412,14508,14701,15360,13548,13765,14199,15360,13271,13508,13942,15360,12661,13159,13709,15360,12468,12854,13436,15360,10260,10484,10509,15360,8613,8669,6951,15360,8151,8143,6469,15360,8653,8629,7814,15360,8469,8444,7541,15360,8718,8693,7814,15360,8372,8332,6597,15360,8356,8308,7111,15360,9047,8983,8396,15360,8822,8798,8308,15360,9372,9348,8967,15360,10364,10364,10183,15360,10268,10260,9894,15360,10541,10533,10468,15360,10380,10364,10276,15360,10621,10613,10549,15360,9910,9942,9758,15360,8364,8380,7621,15360,8581,8637,8135,15360,8252,8300,7573,15360,8119,8175,7300,15360,8372,8453,7493,15360,8420,8501,6983,15360,8742,8822,7573,15360,8782,8854,8151,15360,8581,8661,7079,15360,9220,9268,8340,15360,9549,9645,8854,15360,11717,11950,12127,15360,12468,12741,13207,15360,12709,12966,13388,15360,12300,12508,12886,15360,12492,12709,13063,15360,13239,13372,13548,15360,12476,12597,12814,15360,13581,13685,13878,15360,14476,14548,14685,15360,14556,14629,14773,15360,14765,14829,14966,15360,15159,15207,15303,15360,15372,15396,15444,15360,15516,15532,15572,15360,15653,15661,15693,15360,15829,15837,15853,15360,16022,16014,16022,15360,16311,16295,16279,15360,16343,16319,16303,15360,16412,16388,16359,15360,15813,15797,15773,15360,13063,13151,13183,15360,11484,11701,11798,15360,12300,12412,12468,15360,14613,14637,14653,15360,11974,12215,12316,15360,14135,14215,14303,15360,15604,15629,15677,15360,15524,15548,15596,15360,15351,15380,15428,15360,14797,14894,15054,15360,13990,14231,14500,15360,13492,13709,14070,15360,12886,13316,13701,15360,12613,13207,13749,15360,11525,11974,12428,15360,9284,9412,8629,15360,8597,8653,6951,15360,7806,7790,6292,15360,7589,7541,6437,15360,7485,7437,6597,15360,7453,7404,6180,15360,7774,7686,6565,15360,8300,8260,7332,15360,9918,9942,9862,15360,10348,10372,10231,15360,9725,9709,9228,15360,10613,10621,10509,15360,10199,10175,9838,15360,10380,10388,10340,15360,11207,11255,11284,15360,10661,10717,10725,15360,10103,10135,9950,15360,8444,8436,7669,15360,8469,8501,7445,15360,8950,9111,8854,15360,9485,9798,10071,15360,8364,8501,8039,15360,7959,7951,6806,15360,8597,8605,8039,15360,8501,8533,7557,15360,8758,8830,7509,15360,10758,10830,10693,15360,11508,11605,11621,15360,13524,13669,13886,15360,13830,14022,14327,15360,13926,14103,14364,15360,13460,13621,13886,15360,12854,13191,13420,15360,13597,13733,13926,15360,13846,13990,14223,15360,13773,13942,14199,15360,13910,14087,14356,15360,13813,14022,14319,15360,14247,14396,14540,15360,14693,14765,14878,15360,15223,15279,15343,15360,15508,15524,15540,15360,15540,15548,15564,15360,15327,15335,15319,15360,15303,15311,15303,15360,15918,15910,15886,15360,16247,16207,16151,15360,16175,16143,16086,15360,14436,14452,14436,15360,12263,12380,12404,15360,11476,11701,11773,15360,12380,12492,12532,15360,14797,14797,14757,15360,11372,11589,11677,15360,12597,12934,13356,15360,13990,14364,14725,15360,14183,14444,14773,15360,14231,14444,14717,15360,14412,14532,14709,15360,14054,14199,14380,15360,12372,12500,12605,15360,12199,12565,13006,15360,12581,13175,13653,15360,10055,10380,10324,15360,8557,8573,6726,15360,8167,8196,6533,15360,7517,7485,6119,15360,7244,7172,5798,15360,7071,6959,5718,15360,7669,7581,6260,15360,8661,8605,7975,15360,10942,11079,11151,15360,12573,12741,13014,15360,11902,12030,12191,15360,10308,10332,10135,15360,11255,11300,11284,15360,11276,11348,11396,15360,10055,10215,10292,15360,12183,12332,12468,15360,9918,9966,9798,15360,8734,8742,8196,15360,8967,8950,8469,15360,10260,10276,10039,15360,9734,9758,9605,15360,9388,9404,9308,15360,7943,7878,7095,15360,7726,7637,6645,15360,8047,7983,7204,15360,9284,9236,8693,15360,9621,9565,9143,15360,11255,11268,11047,15360,13175,13332,13420,15360,13773,13934,14175,15360,13854,14022,14271,15360,13870,14038,14279,15360,13388,13516,13677,15360,12279,12629,12966,15360,13348,13452,13564,15360,13821,13918,14054,15360,13701,13846,14022,15360,13460,13605,13781,15360,13492,13637,13821,15360,13709,13821,13950,15360,14372,14428,14476,15360,14516,14572,14613,15360,14741,14789,14813,15360,14725,14749,14749,15360,13452,13484,13468,15360,13476,13500,13492,15360,14990,15022,15022,15360,14556,14572,14564,15360,15094,15111,15094,15360,13231,13287,13215,15360,11255,11380,11175,15360,10677,10886,10492,15360,11846,12006,11934,15360,14327,14340,14279,15360,10766,11039,10862,15360,12918,13255,13452,15360,14231,14548,14886,15360,13878,14380,14765,15360,13444,13862,14412,15360,12151,12404,12621,15360,12637,12902,13215,15360,11549,11749,11870,15360,12279,12653,13119,15360,13223,13404,13516,15360,9228,9260,8276,15360,8087,7991,6308,15360,7918,7814,6919,15360,7469,7364,6148,15360,7485,7380,6212,15360,8228,7991,7204,15360,9276,8967,8212,15360,9806,9573,8742,15360,10135,10087,9621,15360,11452,11452,11452,15360,10629,10637,10509,15360,10693,10733,10637,15360,11095,11111,10982,15360,11292,11348,11372,15360,10199,10244,10167,15360,10814,10926,10846,15360,8669,8774,7493,15360,7870,7910,6244,15360,8204,8183,6919,15360,9806,9758,9159,15360,9460,9436,8629,15360,9159,9087,8260,15360,7637,7509,6790,15360,7758,7629,6838,15360,7967,7918,6774,15360,10854,10749,10501,15360,11508,11412,11316,15360,12372,12300,12151,15360,12030,12119,12063,15360,12781,12910,12982,15360,13476,13581,13661,15360,13484,13589,13677,15360,12404,12428,12380,15360,11605,11765,11798,15360,11492,11533,11452,15360,11838,11886,11798,15360,12263,12372,12380,15360,12151,12231,12175,15360,11492,11508,11412,15360,11119,11111,10838,15360,12508,12581,12573,15360,12621,12693,12677,15360,12573,12629,12589,15360,12292,12324,12231,15360,12476,12565,12573,15360,11998,12159,12215,15360,12950,13071,13159,15360,12263,12372,12428,15360,12380,12428,12444,15360,11300,11308,11143,15360,10199,10244,9734,15360,9709,9701,9252,15360,10492,10581,10404,15360,11476,11516,11388,15360,9477,9517,8790,15360,11717,11854,11838,15360,14247,14420,14524,15360,14054,14311,14436,15360,13597,13805,13982,15360,11364,11533,11597,15360,12263,12428,12549,15360,11436,11605,11653,15360,13079,13324,13444,15360,12516,12613,12605,15360,10039,10015,9605,15360,8693,8621,7878,15360,7951,7862,6902,15360,8196,8204,7015,15360,8677,8589,7637,15360,9284,9031,8340,15360,9814,9605,8902,15360,10685,10428,9910,15360,10492,10260,9685,15360,9404,9252,7943,15360,8830,8766,7220,15360,9220,9047,7943,15360,9693,9669,9015,15360,11412,11468,11372,15360,11135,11159,11023,15360,10087,10055,9428,15360,9910,10007,9621,15360,9236,9300,8934,15360,9597,9557,8902,15360,10669,10549,9782,15360,9926,9870,9127,15360,9894,9918,9047,15360,8685,8742,7910,15360,9958,10167,10284,15360,10215,10332,10396,15360,11396,11428,11452,15360,11223,11255,11300,15360,11814,11862,11958,15360,10685,10846,10870,15360,10340,10380,10007,15360,11175,11207,10894,15360,12103,12207,12215,15360,11143,11103,10902,15360,9910,9966,9613,15360,10015,10079,9493,15360,10806,10846,10517,15360,10862,10934,10637,15360,10838,10942,10661,15360,10958,11087,10878,15360,10709,10838,10701,15360,10669,10741,10589,15360,10581,10669,10525,15360,10252,10348,9974,15360,11396,11500,11525,15360,11207,11255,11264,15360,10878,10910,10934,15360,11031,11063,11159,15360,11292,11324,11396,15360,11223,11255,11300,15360,10693,10685,10645,15360,10428,10420,10324,15360,10300,10252,9991,15360,10838,10846,10798,15360,10428,10428,10364,15360,9669,9605,9380,15360,10167,10244,10087,15360,11709,11854,11910,15360,11223,11284,11268,15360,10231,10244,9878,15360,10199,10244,9862,15360,10183,10260,9942,15360,10525,10653,10541,15360,12500,12597,12621,15360,11814,11741,11597,15360,11533,11460,11175,15360,11103,11006,10557,15360,10444,10396,9846,15360,10007,10023,9228,15360,9653,9790,8469,15360,9316,9372,8039,15360,9557,9830,8071,15360,9621,9918,8071,15360,9677,10015,8167,15360,9991,10284,8420,15360,10215,10436,8581,15360,10260,10484,8645,15360,10292,10476,8902,15360,10324,10468,9252,15360,9910,9894,8886,15360,10525,10573,9701,15360,9782,10039,8581,15360,9565,9814,8167,15360,9950,10039,8934,15360,10749,10758,10199,15360,10669,10685,10244,15360,10838,10838,10460,15360,11215,10910,10087,15360,11492,11364,10806,15360,11095,11159,11055,15360,11364,11388,11356,15360,11023,11039,10990,15360,11653,11653,11613,15360,11798,11725,11557,15360,11974,11862,11637,15360,12039,11942,11765,15360,12119,12047,11934,15360,12151,12071,11950,15360,12087,12006,11886,15360,12047,11966,11838,15360,11990,11926,11790,15360,11974,11910,11798,15360,11998,11934,11814,15360,12111,12039,11886,15360,12231,12143,11998,15360,12292,12199,12039,15360,12039,11974,11846,15360,11822,11782,11653,15360,11862,11838,11765,15360,11798,11765,11701,15360,11782,11733,11669,15360,11798,11749,11685,15360,11838,11790,11725,15360,11870,11822,11749,15360,11741,11701,11621,15360,11565,11541,11452,15360,11533,11500,11412,15360,11621,11581,11484,15360,11605,11557,11460,15360,11516,11468,11372,15360,11565,11533,11444,15360,11677,11637,11541,15360,11725,11661,11557,15360,11725,11661,11557,15360,11733,11669,11573,15360,11838,11773,11677,15360,11998,11926,11814,15360,12014,11926,11798,15360,11460,11404,11332,15360,11637,11557,11428,15360,12014,11894,11693,15360,12167,12022,11765,15360,12119,11982,11709,15360,11926,11806,11516,15360,11685,11589,11300,15360,11476,11404,10886,15360,11239,11151,10468,15360,10766,10733,9894,15360,10565,10565,9589,15360,10436,10444,9332,15360,10308,10308,9031,15360,10308,10316,8999,15360,10199,10244,8774,15360,9725,9645,8549,15360,10244,10276,8967,15360,10878,10838,10183,15360,11055,10966,10348,15360,11119,11006,10404,15360,11264,11135,10565,15360,11404,11316,10822,15360,11492,11388,10982,15360,11798,11613,11223,15360,12047,11830,11412,15360,12039,11894,11597,15360,12127,11990,11693,15360,12127,11990,11725,15360,12191,12055,11806,15360,12191,12055,11830,15360,11870,11773,11613,15360,11573,11516,11428,15360,11533,11484,11412,15360,11541,11492,11420,15360,11565,11516,11452,15360,11589,11541,11476,15360,11605,11557,11500,15360,11637,11589,11533,15360,11669,11621,11557,15360,11701,11645,11573,15360,11733,11669,11589,15360,11798,11717,11605,15360,11838,11749,11621,15360,11878,11782,11661,15360,11894,11798,11661,15360,11926,11806,11653,15360,11958,11822,11661,15360,11982,11846,11677,15360,12006,11870,11685,15360,12095,11950,11765,15360,12047,11910,11741,15360,11886,11765,11605,15360,11838,11733,11589,15360,11814,11717,11589,15360,11814,11709,11573,15360,11790,11693,11565,15360,11741,11677,11589,15360,11733,11677,11613,15360,11733,11685,11629,15360,11717,11669,11621,15360,11685,11645,11589,15360,11629,11589,11533,15360,11573,11525,11468,15360,11492,11444,11380,15360,11316,11255,11111,15360,11348,11292,11143,15360,11516,11436,11316,15360,11854,11749,11589,15360,12127,11990,11765,15360,12199,12055,11782,15360,12340,12231,11910,15360,12372,12292,11958,15360,12380,12300,11974,15360,12348,12247,11910,15360,12324,12215,11878,15360,12247,12103,11773,15360,12095,11958,11637,15360,12055,11926,11613,15360,11974,11854,11541,15360,11870,11765,11468,15360,11966,11854,11541,15360,12300,12151,11846,15360,12396,12316,12006,15360,12388,12308,11990,15360,12388,12308,12006,15360,12396,12316,12022,15360,12396,12308,12022,15360,12396,12308,12022,15360,12364,12279,11974,15360,12340,12247,11942,15360,12340,12231,11926,15360,12215,12071,11806,15360,12095,11966,11749,15360,11741,11645,11500,15360,11420,11356,11255,15360,11364,11308,11207,15360,11356,11300,11175,15360,11348,11292,11191,15360,11372,11324,11255,15360,11412,11364,11308,15360,11420,11372,11316,15360,11428,11380,11324,15360,11444,11388,11332,15360,11484,11428,11364,15360,11508,11460,11396,15360,11557,11500,11436,15360,11589,11533,11460,15360,11613,11557,11484,15360,11621,11557,11492,15360,11613,11557,11500,15360,11621,11557,11500,15360,11629,11573,11508,15360,11629,11573,11508,15360,11605,11557,11484,15360,11589,11533,11468,15360,11557,11508,11436,15360,11549,11500,11428,15360,11557,11500,11436,15360,11549,11492,11436,15360,11533,11484,11428,15360,11525,11476,11428,15360,11516,11476,11428,15360,11525,11484,11444,15360,11516,11476,11428,15360,11468,11428,11380,15360,11428,11388,11332,15360,11356,11308,11239,15360,11308,11255,11127,15360,11167,11071,10926,15360,11223,11119,10966,15360,11276,11175,10998,15360,11404,11332,11191,15360,11773,11693,11557,15360,11926,11798,11613,15360,12207,12039,11773,15360,12348,12231,11894,15360,12308,12151,11846,15360,12332,12215,11894,15360,12364,12279,11958,15360,12380,12292,11974,15360,12396,12316,12022,15360,12404,12316,12039,15360,12412,12332,12087,15360,12412,12332,12103,15360,12436,12356,12135,15360,12372,12292,12039,15360,12420,12332,12087,15360,12396,12316,12055,15360,12356,12263,11990,15360,12340,12231,11942,15360,12271,12127,11854,15360,12215,12071,11814,15360,12292,12135,11878,15360,12288,12135,11870,15360,12111,11982,11765,15360,11990,11886,11717,15360,11637,11557,11428,15360,11364,11300,11143,15360,11316,11239,11079,15360,11300,11207,11047,15360,11268,11159,11015,15360,11268,11159,11015,15360,11268,11159,11031,15360,11300,11223,11095,15360,11340,11292,11191,15360,11348,11300,11223,15360,11372,11324,11255,15360,11380,11332,11255,15360,11372,11316,11239,15360,11396,11340,11268,15360,11468,11404,11300,15360,11460,11404,11324,15360,11484,11428,11356,15360,11492,11436,11372,15360,11500,11444,11388,15360,11508,11460,11404,15360,11500,11452,11396,15360,11492,11436,11380,15360,11468,11412,11356,15360,11444,11388,11324,15360,11444,11388,11324,15360,11428,11380,11316,15360,11412,11356,11300,15360,11404,11348,11300,15360,11404,11356,11308,15360,11396,11356,11308,15360,11388,11348,11308,15360,11372,11340,11292,15360,11348,11308,11255,15360,11284,11223,11111,15360,11231,11143,11023,15360,11199,11111,10974,15360,11047,10958,10814,15360,11127,11023,10870,15360,11119,11006,10846,15360,11175,11055,10886,15360,11292,11191,10998,15360,11525,11404,11284,15360,11822,11637,11476,15360,11878,11733,11549,15360,11918,11790,11573,15360,12063,11918,11653,15360,12223,12063,11765,15360,12300,12151,11846,15360,12255,12103,11814,15360,12271,12127,11846,15360,12271,12127,11862,15360,12271,12127,11886,15360,12308,12183,11942,15360,12175,12039,11814,15360,12063,11934,11709,15360,12159,12014,11765,15360,12215,12063,11798,15360,12143,11998,11757,15360,12071,11934,11693,15360,11998,11870,11661,15360,11974,11870,11685,15360,11998,11910,11757,15360,11846,11765,11629,15360,11468,11396,11284,15360,11308,11223,11031,15360,11215,11103,10934,15360,11207,11095,10942,15360,11215,11103,10950,15360,11191,11087,10942,15360,11175,11079,10942,15360,11167,11063,10934,15360,11143,11031,10902,15360,11247,11143,11015,15360,11284,11191,11079,15360,11300,11223,11095,15360,11316,11268,11127,15360,11340,11284,11143,15360,11340,11284,11159,15360,11356,11300,11191,15360,11372,11316,11239,15360,11380,11324,11255,15360,11372,11316,11255,15360,11380,11324,11276,15360,11380,11324,11268,15360,11372,11316,11255,15360,11364,11316,11255,15360,11364,11308,11239,15360,11348,11292,11207,15360,11340,11284,11191,15360,11348,11292,11191,15360,11348,11292,11207,15360,11340,11292,11207,15360,11340,11292,11207,15360,11324,11276,11207,15360,11308,11255,11175,15360,11264,11175,11079,15360,11119,11039,10934,15360,11103,11015,10902,15360,11095,11006,10878,15360,11031,10942,10806,15360,10990,10902,10766,15360,11047,10942,10814,15360,11031,10926,10790,15360,11055,10942,10806,15360,11119,10998,10846,15360,11151,11015,10830,15360,11268,11095,10886,15360,11484,11396,11268,15360,11790,11701,11549,15360,11886,11790,11637,15360,11838,11741,11581,15360,11838,11725,11541,15360,11902,11782,11581,15360,11966,11838,11629,15360,11974,11846,11629,15360,11958,11838,11629,15360,11950,11838,11637,15360,11814,11701,11525,15360,11581,11492,11332,15360,11645,11541,11380,15360,11806,11701,11533,15360,11902,11806,11637,15360,11950,11862,11717,15360,12014,11934,11790,15360,11942,11862,11725,15360,11565,11492,11388,15360,11292,11191,11015,15360,11231,11111,10950,15360,11159,11047,10894,15360,11119,11006,10854,15360,11127,11023,10878,15360,11159,11055,10902,15360,11135,11031,10894,15360,11111,11006,10878,15360,11095,10990,10870,15360,11095,10998,10886,15360,11071,10966,10846,15360,11111,11006,10902,15360,11191,11095,10974,15360,11268,11159,11031,15360,11284,11191,11063,15360,11292,11207,11063,15360,11300,11223,11079,15360,11332,11268,11143,15360,11316,11255,11127,15360,11316,11255,11143,15360,11308,11239,11127,15360,11316,11255,11159,15360,11300,11223,11127,15360,11292,11207,11095,15360,11300,11223,11111,15360,11300,11223,11095,15360,11300,11223,11095,15360,11308,11239,11111,15360,11300,11223,11111,15360,11292,11207,11111,15360,11264,11167,11071,15360,11215,11127,11047,15360,11135,11055,10966,15360,11015,10934,10846,15360,10918,10838,10733,15360,10982,10894,10782,15360,10974,10886,10766,15360,10982,10894,10766,15360,10958,10862,10749,15360,10982,10886,10774,15360,10958,10862,10758,15360,10958,10862,10749,15360,11015,10910,10790,15360,11023,10910,10774,15360,11079,10958,10806,15360,11103,10974,10798,15360,11191,11047,10846,15360,11468,11388,11276,15360,11846,11765,11637,15360,12006,11918,11782,15360,11998,11910,11782,15360,11902,11822,11693,15360,11838,11749,11637,15360,11782,11709,11605,15360,11806,11741,11645,15360,11782,11717,11629,15360,11773,11717,11621,15360,11870,11806,11701,15360,11942,11862,11757,15360,12183,12103,11974,15360,11974,11894,11765,15360,11476,11404,11308,15360,11268,11143,10966,15360,11183,11063,10902,15360,11111,10998,10854,15360,11055,10942,10806,15360,11023,10910,10766,15360,11047,10934,10782,15360,11039,10926,10782,15360,11079,10966,10830,15360,11031,10918,10782,15360,11031,10926,10806,15360,10990,10894,10782,15360,10974,10886,10790,15360,10966,10870,10774,15360,11006,10902,10806,15360,11039,10942,10838,15360,11127,11023,10910,15360,11175,11079,10958,15360,11191,11087,10958,15360,11207,11095,10958,15360,11268,11143,11015,15360,11276,11175,11047,15360,11284,11191,11079,15360,11292,11191,11079,15360,11276,11175,11079,15360,11239,11135,11031,15360,11268,11159,11047,15360,11215,11111,11006,15360,11239,11127,11015,15360,11255,11143,11031,15360,11223,11119,11015,15360,11199,11103,10998,15360,11175,11087,10982,15360,11143,11047,10958,15360,11031,10942,10854,15360,10958,10878,10790,15360,10910,10830,10741,15360,10942,10862,10758,15360,10926,10838,10733,15360,10854,10758,10637,15360,10918,10830,10709,15360,10910,10822,10717,15360,10942,10846,10749,15360,10942,10854,10741,15360,10942,10854,10749,15360,10966,10870,10758,15360,10966,10870,10758,15360,10958,10854,10733,15360,10998,10886,10741,15360,10942,10830,10677,15360,11039,10918,10749,15360,11095,10974,10806,15360,11308,11223,11031,15360,11468,11396,11292,15360,11605,11533,11428,15360,11701,11621,11525,15360,11693,11629,11541,15360,11685,11621,11549,15360,11685,11629,11549,15360,11629,11565,11484,15360,11589,11533,11444,15360,11364,11308,11191,15360,11191,11087,10958,15360,11135,11031,10902,15360,11135,11031,10894,15360,11055,10950,10830,15360,11015,10910,10782,15360,10958,10854,10733,15360,10942,10838,10717,15360,10974,10870,10733,15360,10982,10878,10749,15360,10990,10886,10758,15360,11015,10910,10798,15360,10966,10862,10758,15360,10950,10854,10758,15360,10910,10822,10733,15360,10894,10798,10709,15360,10902,10814,10725,15360,10934,10846,10758,15360,10910,10822,10733,15360,10950,10854,10749,15360,10974,10878,10766,15360,11047,10942,10830,15360,11095,10990,10878,15360,11167,11055,10942,15360,11199,11103,10990,15360,11191,11087,10982,15360,11151,11047,10950,15360,11135,11031,10934,15360,11095,10998,10902,15360,11143,11047,10950,15360,11079,10990,10894,15360,11079,10990,10902,15360,11103,11006,10910,15360,11079,10982,10886,15360,11023,10926,10822,15360,10982,10894,10798,15360,10958,10870,10782,15360,10910,10814,10725,15360,10926,10838,10741,15360,10934,10838,10733,15360,10950,10854,10749,15360,10886,10798,10709,15360,10910,10814,10709,15360,10926,10830,10725,15360,10910,10814,10701,15360,10862,10774,10677,15360,10950,10854,10733,15360,10926,10830,10717,15360,10926,10838,10725,15360,10926,10830,10725,15360,10894,10798,10685,15360,10926,10830,10701,15360,10958,10854,10717,15360,10934,10830,10685,15360,10950,10846,10709,15360,10974,10862,10717,15360,10942,10830,10685,15360,10958,10846,10701,15360,11006,10894,10749,15360,10950,10846,10725,15360,10958,10862,10741,15360,10894,10806,10701,15360,10854,10774,10669,15360,10886,10806,10701,15360,10862,10790,10693,15360,10878,10806,10717,15360,10982,10902,10798,15360,10990,10902,10798,15360,10950,10862,10758,15360,10942,10846,10733,15360,10870,10774,10669,15360,10894,10798,10693,15360,10918,10830,10725,15360,10894,10806,10701,15360,10926,10830,10733,15360,10902,10830,10725,15360,10870,10790,10693,15360,10886,10814,10725,15360,10814,10741,10661,15360,10838,10766,10677,15360,10822,10741,10661,15360,10822,10741,10669,15360,10862,10790,10709,15360,10846,10758,10669,15360,10894,10798,10693,15360,10974,10878,10766,15360,10966,10870,10766,15360,11023,10926,10814,15360,11079,10974,10862,15360,11006,10910,10814,15360,10950,10862,10766,15360,10982,10894,10798,15360,10958,10862,10774,15360,10958,10870,10782,15360,10910,10830,10741,15360,10950,10862,10766,15360,10982,10886,10790,15360,10918,10822,10725,15360,10886,10798,10701,15360,10854,10766,10669,15360,10894,10806,10709,15360,10926,10830,10725,15360,10926,10830,10725,15360,10958,10862,10749,15360,10958,10862,10749,15360,10894,10806,10717,15360,10902,10814,10717,15360,10878,10790,10677,15360,10942,10838,10717,15360,10918,10814,10701,15360,10886,10790,10661,15360,10942,10838,10717,15360,10950,10854,10725,15360,10950,10854,10725,15360,10910,10814,10693,15360,10910,10814,10685,15360,10942,10838,10709,15360,10894,10790,10661,15360,10910,10806,10669,15360,10822,10725,10597,15360,10749,10661,10541,15360,10830,10733,10613,15360,10838,10741,10629,15360,10806,10709,10597,15360,10854,10766,10653,15360,10862,10774,10669,15360,10798,10725,10629,15360,10822,10749,10653,15360,10854,10782,10693,15360,10806,10741,10661,15360,10862,10790,10701,15360,10870,10790,10685,15360,10870,10790,10693,15360,10878,10790,10677,15360,10862,10782,10677,15360,10870,10790,10693,15360,10870,10782,10685,15360,10894,10814,10709,15360,10886,10814,10709,15360,10846,10782,10685,15360,10741,10669,10573,15360,10766,10693,10589,15360,10709,10637,10541,15360,10741,10669,10589,15360,10741,10677,10589,15360,10709,10637,10557,15360,10774,10701,10613,15360,10862,10774,10677,15360,11006,10918,10806,15360,11006,10902,10782,15360,10974,10870,10749,15360,10958,10854,10733,15360,10934,10838,10725,15360,10934,10838,10733,15360,10934,10838,10725,15360,10886,10790,10685,15360,10854,10766,10661,15360,10886,10798,10701,15360,10838,10749,10645,15360,10878,10782,10661,15360,10822,10725,10613,15360,10822,10717,10605,15360,10846,10749,10629,15360,10854,10749,10637,15360,10950,10854,10733,15360,10958,10854,10741,15360,10910,10806,10693,15360,10926,10822,10693,15360,10934,10838,10725,15360,10910,10822,10709,15360,10910,10822,10709,15360,10886,10782,10661,15360,10910,10814,10677,15360,10910,10806,10677,15360,10926,10822,10685,15360,10958,10854,10717,15360,10974,10870,10725,15360,10926,10830,10693,15360,10926,10830,10693,15360,10918,10822,10693,15360,10934,10838,10701,15360,10918,10814,10685,15360,10878,10782,10653,15360,10870,10774,10645,15360,10838,10749,10629,15360,10806,10717,10605,15360,10822,10733,10621,15360,10822,10733,10621,15360,10846,10758,10653,15360,10846,10766,10653,15360,10822,10741,10629,15360,10806,10733,10629,15360,10806,10725,10621,15360,10790,10709,10605,15360,10766,10693,10589,15360,10814,10741,10629,15360,10846,10766,10653,15360,10838,10758,10653,15360,10878,10790,10677,15360,10894,10798,10685,15360,10830,10741,10629,15360,10830,10758,10653,15360,10798,10725,10629,15360,10806,10733,10629,15360,10717,10637,10525,15360,10661,10581,10476,15360,10701,10621,10517,15360,10733,10661,10565,15360,10782,10685,10557,15360,10862,10758,10613,15360,10974,10862,10725,15360,10958,10846,10709,15360,11006,10902,10766,15360,11006,10902,10774,15360,11039,10934,10814,15360,11006,10902,10790,15360,11006,10910,10790,15360,10950,10854,10741,15360,10934,10830,10709,15360,10918,10814,10701,15360,10854,10758,10653,15360,10918,10814,10701,15360,10870,10766,10645,15360,10830,10733,10621,15360,10934,10830,10709,15360,10990,10886,10758,15360,10950,10838,10717,15360,10910,10814,10701,15360,10926,10822,10693,15360,10934,10830,10709,15360,10878,10774,10653,15360,10934,10830,10701,15360,10926,10822,10693,15360,10878,10782,10661,15360,10878,10782,10661,15360,10862,10766,10621,15360,10886,10782,10645,15360,10886,10782,10653,15360,10926,10822,10701,15360,10902,10806,10685,15360,10926,10822,10701,15360,10918,10814,10685,15360,10878,10782,10645,15360,10910,10806,10669,15360,10854,10758,10621,15360,10886,10790,10645,15360,10854,10758,10629,15360,10830,10741,10613,15360,10918,10814,10685,15360,10862,10766,10645,15360,10830,10741,10613,15360,10806,10717,10597,15360,10741,10661,10557,15360,10774,10693,10581,15360,10749,10669,10557,15360,10774,10693,10581,15360,10766,10685,10573,15360,10790,10709,10597,15360,10782,10701,10589,15360,10790,10709,10597,15360,10838,10749,10621,15360,10870,10774,10645,15360,10894,10790,10661,15360,10878,10782,10653,15360,10846,10741,10613,15360,10790,10693,10557,15360,10814,10717,10597,15360,10790,10701,10581,15360,10741,10645,10525,15360,10717,10629,10509,15360,10774,10685,10573,15360,10725,10637,10525,15360,10854,10749,10621,15360,10950,10846,10701,15360,10966,10854,10709,15360,10934,10814,10677,15360,10926,10822,10701,15360,10982,10878,10766,15360,10998,10894,10782,15360,10990,10878,10766,15360,10998,10894,10782,15360,10998,10886,10774,15360,10998,10886,10758,15360,11006,10894,10774,15360,10942,10838,10733,15360,10958,10854,10741,15360,10958,10854,10749,15360,11006,10902,10790,15360,11015,10902,10798,15360,10982,10870,10758,15360,10998,10894,10782,15360,10974,10870,10758,15360,11006,10902,10790,15360,10998,10894,10774,15360,10974,10870,10758,15360,10950,10854,10741,15360,10878,10790,10693,15360,10902,10814,10701,15360,10918,10822,10709,15360,10838,10733,10613,15360,10878,10782,10661,15360,10934,10838,10717,15360,10902,10806,10693,15360,10918,10822,10709,15360,10926,10830,10709,15360,10838,10733,10605,15360,10910,10806,10661,15360,10942,10838,10693,15360,10886,10782,10645,15360,10886,10782,10637,15360,10854,10749,10621,15360,10926,10830,10709,15360,10966,10862,10741,15360,10846,10749,10629,15360,10830,10733,10605,15360,10854,10758,10637,15360,10822,10725,10605,15360,10886,10790,10661,15360,10902,10806,10669,15360,10918,10814,10677,15360,10830,10733,10605,15360,10806,10717,10589,15360,10870,10774,10645,15360,10934,10838,10709,15360,10958,10862,10733,15360,10886,10790,10661,15360,10894,10798,10661,15360,10958,10854,10709,15360,10934,10830,10709,15360,10814,10717,10581,15360,10862,10758,10613,15360,10854,10741,10589,15360,10814,10717,10573,15360,10886,10782,10645,15360,10814,10725,10597,15360,10862,10766,10637,15360,10910,10806,10669,15360,10942,10838,10709,15360,10966,10862,10733,15360,10974,10870,10741,15360,10974,10870,10749,15360,10958,10862,10749,15360,11031,10934,10822,15360,10998,10894,10782,15360,10974,10870,10766,15360,11023,10918,10814,15360,11039,10926,10822,15360,10958,10846,10741,15360,10918,10814,10693,15360,10966,10870,10741,15360,10982,10886,10766,15360,10982,10878,10766,15360,10942,10846,10733,15360,10958,10862,10758,15360,10950,10854,10758,15360,10934,10830,10717,15360,10966,10862,10733,15360,10942,10846,10725,15360,10934,10846,10733,15360,10934,10846,10733,15360,10878,10798,10693,15360,10886,10798,10693,15360,10910,10814,10709,15360,10942,10846,10733,15360,10838,10733,10597,15360,10878,10774,10645,15360,10918,10822,10701,15360,10878,10782,10653,15360,10894,10790,10661,15360,10934,10838,10725,15360,10958,10854,10725,15360,10966,10862,10733,15360,10910,10806,10685,15360,10982,10878,10758,15360,10942,10854,10749,15360,10934,10838,10733,15360,10918,10814,10701,15360,10894,10798,10669,15360,10894,10798,10669,15360,10814,10725,10605,15360,10902,10798,10669,15360,10814,10725,10605,15360,10894,10798,10685,15360,10958,10862,10749,15360,10910,10814,10701,15360,10910,10806,10685,15360,10918,10814,10693,15360,10926,10822,10709,15360,10894,10790,10661,15360,10902,10806,10677,15360,10902,10806,10685,15360,10934,10838,10717,15360,10934,10838,10701,15360,10934,10838,10717,15360,10950,10854,10725,15360,10894,10798,10661,15360,10862,10749,10597,15360,10894,10798,10677,15360,10878,10782,10661,15360,10926,10838,10717,15360,10926,10838,10717,15360,10918,10822,10709,15360,10934,10838,10733,15360,10926,10838,10733,15360,10958,10870,10766,15360,10942,10854,10749,15360,10958,10870,10774,15360,10974,10878,10774,15360,10958,10854,10741,15360,10950,10846,10741,15360,10950,10854,10758,15360,10934,10838,10733,15360,10942,10846,10725,15360,10966,10862,10741,15360,10926,10838,10733,15360,10958,10862,10749,15360,10910,10822,10709,15360,10942,10854,10758,15360,10926,10838,10733,15360,10910,10822,10717,15360,10934,10838,10733,15360,10934,10846,10733,15360,10902,10814,10709,15360,10926,10830,10717,15360,10918,10822,10709,15360,10838,10749,10637,15360,10878,10790,10677,15360,10942,10846,10733,15360,10926,10822,10701,15360,10958,10862,10749,15360,10886,10790,10685,15360,10918,10814,10693,15360,10910,10814,10693,15360,10902,10806,10701,15360,10878,10774,10637,15360,10798,10693,10565,15360,10822,10725,10597,15360,10934,10838,10709,15360,10958,10854,10725,15360,10886,10790,10669,15360,10910,10806,10677,15360,10886,10782,10645,15360,10830,10725,10597,15360,10822,10717,10581,15360,10862,10758,10637,15360,10878,10782,10669,15360,10926,10822,10709,15360,10974,10878,10774,15360,10966,10870,10758,15360,10918,10822,10709,15360,10846,10749,10645,15360,10894,10798,10693,15360,10918,10822,10709,15360,10974,10878,10774,15360,10918,10822,10717,15360,10982,10886,10774,15360,10974,10878,10758,15360,10950,10854,10741,15360,10958,10854,10725,15360,10982,10886,10766,15360,10918,10822,10701,15360,10878,10782,10669,15360,10886,10790,10669,15360,10934,10838,10717,15360,10950,10854,10741,15360,10934,10838,10733,15360,10982,10886,10782,15360,10886,10798,10701,15360,10870,10782,10685,15360,10894,10814,10717,15360,10910,10822,10725,15360,10934,10838,10733,15360,10950,10846,10741,15360,10934,10838,10725,15360,10934,10846,10749,15360,10902,10814,10717,15360,10878,10790,10677,15360,10878,10782,10669,15360,10854,10766,10645,15360,10838,10749,10629,15360,10902,10814,10701,15360,10910,10814,10693,15360,10902,10798,10669,15360,10910,10806,10677,15360,10886,10782,10653,15360,10854,10749,10629,15360,10870,10774,10653,15360,10974,10870,10758,15360,10990,10878,10758,15360,10918,10822,10709,15360,10926,10838,10725,15360,10958,10854,10733,15360,10894,10790,10653,15360,10822,10725,10605,15360,10878,10782,10661,15360,10974,10870,10749,15360,10902,10806,10677,15360,10934,10838,10725,15360,10870,10774,10653,15360,10798,10701,10581,15360,10854,10749,10621,15360,10894,10798,10669,15360,10934,10822,10685,15360,10942,10830,10701,15360,10910,10806,10669,15360,10870,10758,10629,15360,10886,10774,10645,15360,10950,10838,10701,15360,10966,10870,10749,15360,10886,10790,10685,15360,10870,10782,10677,15360,10934,10838,10733,15360,10934,10838,10725,15360,10822,10725,10621,15360,10878,10790,10677,15360,10894,10798,10693,15360,10822,10733,10629,15360,10894,10798,10685,15360,10998,10902,10790,15360,11015,10918,10806,15360,10950,10854,10741,15360,10950,10846,10741,15360,10934,10838,10733,15360,10942,10846,10749,15360,10910,10822,10725,15360,10846,10758,10653,15360,10878,10790,10685,15360,10894,10798,10701,15360,10862,10774,10669,15360,10814,10725,10621,15360,10846,10758,10645,15360,10870,10774,10661,15360,10870,10774,10677,15360,10878,10790,10693,15360,10878,10782,10677,15360,10830,10741,10637,15360,10870,10782,10677,15360,10966,10870,10766,15360,11015,10918,10814,15360,10910,10814,10701,15360,10942,10846,10725,15360,10950,10846,10725,15360,10942,10838,10725,15360,10934,10830,10701,15360,10910,10798,10677,15360,10886,10782,10653,15360,10838,10733,10597,15360,10902,10806,10669,15360,10830,10733,10613,15360,10838,10741,10621,15360,10838,10741,10621,15360,10894,10798,10669,15360,10934,10830,10685,15360,10886,10790,10669,15360,10902,10806,10685,15360,10854,10749,10637,15360]);var Ife={file:1,m:1,mm:.001,cm:.01,ft:.3048,in:.0254,pt:oht()},lht={file:"m",m:"m",mm:"mm",cm:"cm",ft:"ft",in:"in",pt:"pt"},Lfe=e=>2===e?"\xb2":3===e?"\xb3":"",sE=(e,t=1)=>lht[e]+Lfe(t),IOt=(e,t,n,i=1)=>(null==n&&(n=t),n===t?{value:e,unit:sE(n)}:{value:e*Math.pow(Ife[t]/Ife[n],i),unit:sE(n)+Lfe(i)}),u5=(e=>(e.Top="Top",e.Bottom="Bottom",e.Front="Front",e.Back="Back",e.Left="Left",e.Right="Right",e))(u5||{}),aE=class{static getCameraPositionByBboxAndDirection(e,t,n,i,r){if(e.isEmpty()||!i)return;let a=new O,s=new O,o=new O(0,1,0);e.getSize(s),e.getCenter(a);let l,h,c=(s.x+s.y+s.z)/3*1.5;if(!r||null!=r&&r.equals(new O))l=new O(a.x+c,a.y+c/1.5,a.z+c),h=l.clone().sub(a);else{let e=new O(c,c/1.5,c).length();h=new O(-r.x,-r.y,-r.z).normalize().multiplyScalar(e),l=h.clone().add(a)}c=h.length(),h=h.normalize();let u=new Qe;u.lookAt(l,a,o);let d=new Qe;d.makeTranslation(-l.x,-l.y,-l.z);let p=e.clone().applyMatrix4(d).applyMatrix4(u.invert()).applyMatrix4(i),f=Math.max(Math.abs(p.max.x),Math.abs(p.min.x)),m=Math.max(Math.abs(p.max.y),Math.abs(p.min.y));c*=1.1*Math.sqrt(Math.pow(f,2)+Math.pow(m,2)),l=h.multiplyScalar(c).add(a),n.set(a.x,a.y,a.z),t.set(l.x,l.y,l.z)}static getCameraDirectionByView(e){let t=new O(1,0,0);return"Top"===e?t.set(0,-1,0):"Bottom"===e?t.set(0,1,0):"Front"===e?t.set(0,0,-1):"Back"===e?t.set(0,0,1):"Left"===e?t.set(1,0,0):"Right"===e&&t.set(-1,0,0),t}},cht=!1,Bi=class extends cs{constructor(e){super(),this.DEFAULT_LINE_WIDTH=1,this.DEFAULT_STROKE_STYLE=[0,0,0,1],this.DEFAULT_FILL_STYLE=[0,0,0,1],this.lineWidth=this.DEFAULT_LINE_WIDTH,this.lineColor=this.DEFAULT_STROKE_STYLE,this.fillColor=this.DEFAULT_FILL_STYLE,this.x=0,this.y=0,this.width=0,this.height=0,this.points=[],this.userData={},this.tolerance=1,this.visible=!0,this.selected=!1,this.renderOrder=1,this.needsFrustumCulled=!0,this.editPointSize=3,this.editPointFillColor="#ffffff",this.editPointStrokeColor="#939ea4",this.matrix=new Qe,this.id=e||Mt.guid()}setTolerance(e){this.tolerance=e}render(e,t){this.ctx=e,this.draw(e,t),this.selected&&this.drawSelect(e,t),cht&&(this.drawBounds(e,t),this.drawCenter(e,t))}getData(){return{id:this.id,points:this.points.map((e=>[e.x,e.y])),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,type:this.getClassType()}}setData(e){this.id=e.id,this.setLineWidth(e.lineWidth),this.setLineColor(e.lineColor),this.setFillColor(e.fillColor)}getVertexes(){return[new O(this.x,this.y,0),new O(this.x+this.width,this.y,0),new O(this.x+this.width,this.y-this.height,0),new O(this.x,this.y-this.height,0)]}setLineWidth(e){this.lineWidth=e||this.DEFAULT_LINE_WIDTH}setLineColor(e){this.lineColor=e||this.DEFAULT_STROKE_STYLE}setFillColor(e){this.fillColor=e||this.DEFAULT_FILL_STYLE}isSelected(){return this.selected}getCenter(){return this.getBounds().getCenter(new O)}transToScreenCoord(e,t){return this.ctx?un.worldPosition2ScreenPoint(e,t,this.ctx.canvas):new be}drawBounds(e,t){let{min:n,max:i}=this.getBounds(),r=[],a=(e,t,n)=>r.push(new O(e,t,n));a(i.x,i.y,i.z),a(n.x,i.y,i.z),a(n.x,n.y,i.z),a(i.x,n.y,i.z),a(i.x,i.y,n.z),a(n.x,i.y,n.z),a(n.x,n.y,n.z),a(i.x,n.y,n.z),a(n.x,i.y,i.z),a(n.x,n.y,i.z),a(i.x,i.y,i.z),a(i.x,n.y,i.z),a(i.x,i.y,n.z),a(i.x,n.y,n.z),a(n.x,i.y,n.z),a(n.x,n.y,n.z),a(n.x,i.y,i.z),a(n.x,i.y,n.z),a(i.x,i.y,i.z),a(i.x,i.y,n.z),a(n.x,n.y,i.z),a(n.x,n.y,n.z),a(i.x,n.y,i.z),a(i.x,n.y,n.z),e.save(),e.strokeStyle="yellow",e.beginPath(),r.forEach(((n,i)=>{let r=this.transToScreenCoord(n,t);i%2==0?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.closePath(),e.stroke(),e.restore()}drawCenter(e,t){let n=this.transToScreenCoord(this.getCenter(),t);e.save(),e.fillStyle="yellow",e.beginPath(),e.arc(n.x,n.y,5,0,2*Math.PI),e.closePath(),e.fill(),e.restore()}getBounds(){let e=this.getVertexes();return(new Ot).setFromPoints(e)}},Ii=(e=>(e.MouseClicked="MouseClicked",e.LayoutChanged="LayoutChanged",e.ModelLoaded="ModelLoaded",e.BeforeRender="BeforeRender",e.AfterRender="AfterRender",e.OnAnimate="OnAnimate",e.CameraChanged="CameraChanged",e.BoxSelectActivated="BoxSelectActivated",e.BoxSelectDeactivated="BoxSelectDeactivated",e.PickMarkupActivated="PickMarkupActivated",e.PickMarkupDeactivated="PickMarkupDeactivated",e.MarkupActivated="MarkupActivated",e.MarkupDeactivated="MarkupDeactivated",e.MarkupAdded="MarkupAdded",e.MarkupUpdated="MarkupUpdated",e.MarkupRemoved="MarkupRemoved",e.BeforeRemoveMarkup="BeforeRemoveMarkup",e.MeasurementActivated="MeasurementActivated",e.MeasurementDeactivated="MeasurementDeactivated",e.MeasurementAdded="MeasurementAdded",e.MeasurementRemoved="MeasurementRemoved",e))(Ii||{}),Dfe={},Hn=class extends cs{constructor(e){super(),this.drawableLists=[],this.frustum=new ya,this.projScreenMatrix=new Qe,this.viewer=e,this.init()}static _registerDrawableClass(e){Dfe[e.prototype.getClassType()]=e}static createDrawable(e){let t=Dfe[e.type];if(!t)throw new Error(`Invalid drawable type: ${t}`);let n=e.points.map((e=>new O(e[0],e[1],e[2]||0))),i=new t(e.id,n);return i.setData(e),i}get container(){return this.viewer.viewerContainer}get camera(){return this.viewer.camera}get raycaster(){return this.viewer.getRaycaster()}init(){this.initCanvas(),this.viewer.addEventListener("AfterRender",(()=>{this.projScreenMatrix.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),this.frustum.setFromProjectionMatrix(this.projScreenMatrix),this.render()}))}initCanvas(){let e=this.viewer.getViewConfig();if(Dn.isBrowser&&!e.context2d){let e=this.canvas=document.createElement("canvas"),t=this.viewer.viewerContainer;t.appendChild(e),e.classList.add("overlay-renderer"),e.style.pointerEvents="none",e.style.position="absolute",e.style.left="0px",e.style.top="0px",e.style.userSelect="none",this.context=e.getContext("2d",{willReadFrequently:!0});let{clientWidth:n,clientHeight:i}=t;this.setSize(n,i)}else e.context2d&&(this.context=e.context2d,this.canvas=Dn.creatReactNativeCanvas(this.context),this.context.canvas||(this.context.canvas=this.canvas))}toHighDpr(e,t,n){let i=Math.max(window.devicePixelRatio||1,1),r=this.canvas;return r.width=t*i,r.height=n*i,e.scale(i,i),r.style.width=`${t}px`,r.style.height=`${n}px`,e}clearCanvas(){var e,t,n;null==(n=this.context)||n.clearRect(0,0,null==(e=this.canvas)?void 0:e.width,null==(t=this.canvas)?void 0:t.height)}addDrawableList(e){this.drawableLists.push(e)}render(){if(!this.canvas||!this.context||this.drawableLists.length<1)return;this.clearCanvas();let e=this.getSortedDrawables(!1);if(0===e.length)return;let t=new gr,n=this.viewer.getPixelSizeInWorldCoord();for(let i=0;i{let i=Array.from(n.getDrawables().values());e&&(i=i.filter((e=>e.visible))),i.length>0&&t.push(...i)})),t.sort(((e,t)=>e.renderOrder===t.renderOrder?t.getCenter().distanceTo(this.camera.position)-e.getCenter().distanceTo(this.camera.position):e.renderOrder-t.renderOrder)),t}getDrawablesByPosition(e,t){let n=this.getSortedDrawables(),i=[];for(let r=0;rt.id===e))}measureTextLength(e,t){let n=this.context,i=e.split("\n"),r=0;for(let a=0;ae.clear())),this.drawableLists=[],this.canvas&&(null==(e=this.viewer.viewerContainer)||e.removeChild(this.canvas),this.canvas=void 0)}},Ko=class extends cs{constructor(e){super(),this.drawableMap=new Map,this.category=e}addDrawable(e){this.drawableMap.set(e.id,e),this.dispatchEvent("addDrawable",e.getData())}updateDrawable(e,t){e.setData(t),this.dispatchEvent("updateDrawable",e.getData())}removeDrawable(e){this.drawableMap.delete(e.id),this.dispatchEvent("removeDrawable",e.getData())}getDrawableById(e){return this.drawableMap.get(e)}clear(){this.drawableMap.forEach((e=>this.removeDrawable(e)))}getDrawables(){return this.drawableMap}getDrawableDatas(){return Array.from(this.drawableMap).map((([e,t])=>t.getData()))}setDrawableDatas(e){for(let t=0;t{let i=this.transToScreenCoord(n,t);e.moveTo(i.x,i.y),e.arc(i.x,i.y,this.editPointSize,0,2*Math.PI)})),e.closePath(),e.stroke(),e.fill(),e.restore()}setEditPointSize(e){this.editPointSize=e}setEditPointFillColor(e){this.editPointFillColor=e}setEditPointStrokeColor(e){this.editPointStrokeColor=e}getCenter(){return this.getBounds().getCenter(new O)}isPointInPath(e){let t=this.getVertexes().map((e=>new be(e.x,e.y)));return Qt.isPointInPolygon(new be(e.x,e.y),t,!0)}setData(e){super.setData(e),this.update(e.points.map((e=>new O(e[0],e[1],0))))}setParent(e){this.parent=e}setLeaderText(e){this.leaderText=e,e.setParent(this)}update(e){let{min:t,max:n}=uht.setFromPoints(e);return this.x=t.x,this.y=n.y,this.width=Math.abs(n.x-t.x),this.height=Math.abs(n.y-t.y),this.points=e,this}translate(e,t){let n=new O(e,t,0);return this.points.forEach((e=>e.add(n))),this.update(this.points),this}rotate(){return this}scale(){return this}},qa=(e=>(e.Arrow="ArrowMarkup",e.Circle="CircleMarkup",e.CloudLine="CloudLineMarkup",e.CloudLineRectangle="CloudRectMarkup",e.CloudRectWithText="CloudRectWithTextMarkup",e.Dot="DotMarkup",e.Ellipse="EllipseMarkup",e.LeaderLine="LeaderLineMarkup",e.PolyLine="PolylineMarkup",e.Rectangle="RectMarkup",e.Text="TextMarkup",e.X="XMarkup",e))(qa||{}),h5=class extends wi{constructor(e,t){super(e),this.type="ArrowMarkup",this.update(t)}draw(e,t){let n=this.points.map((e=>this.transToScreenCoord(e,t))),[i,r]=this.points,a=(new O).subVectors(i,r).length()/10/this.tolerance;this.drawArrowLine(e,n,a),this.drawArrowHead(e,n[0],n[1],10,a)}drawArrowLine(e,t,n){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor);let[i,r]=t,a=(new be).subVectors(r,i).normalize();e.beginPath(),e.moveTo(i.x,i.y);let s=r.clone().sub(a.multiplyScalar(n));e.lineTo(s.x,s.y),e.closePath(),e.stroke(),e.restore()}drawArrowHead(e,t,n,i,r){let a=180*Math.atan2(t.y-n.y,t.x-n.x)/Math.PI,s=(a+i)*Math.PI/180,o=(a-i)*Math.PI/180,l=r*Math.cos(s),h=r*Math.sin(s),c=r*Math.cos(o),u=r*Math.sin(o),d=new be(n.x+l,n.y+h),p=new be(n.x+c,n.y+u);e.save(),e.fillStyle=Cn.rgba2Color(this.lineColor),e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(d.x,d.y),e.lineTo(p.x,p.y),e.closePath(),e.fill(),e.restore()}getVertexes(){return this.points}update(e){let[t,n]=e;return this.points=e,this.x=Math.min(t.x,n.x),this.y=Math.max(t.y,n.y),this.width=Math.abs(n.x-t.x),this.height=Math.abs(n.y-t.y),this}isPointInPath(e){return Qt.isPointOnLineSegments(e,this.points,this.tolerance)}getClassType(){return"ArrowMarkup"}};Hn._registerDrawableClass(h5);var hht=new be,Ofe=new O,d5=class extends wi{constructor(e,t){super(e),this.radius=1,this.type="CircleMarkup",this.update(t)}draw(e,t){let[n,i]=this.points.map((e=>this.transToScreenCoord(e,t)));this.radius=hht.subVectors(i,n).length(),e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor),e.fillStyle=Cn.rgba2Color(this.fillColor),e.beginPath(),e.arc(n.x,n.y,this.radius,0,2*Math.PI),e.closePath(),e.stroke(),e.restore()}update(e){let[t,n]=e,i=Ofe.subVectors(n,t).length();return this.width=2*i,this.height=2*i,this.x=t.x-this.width/2,this.y=t.y+this.height/2,this.points=e,this}isPointInPath(e){let[t,n]=this.points,i=Ofe.subVectors(t,n).length();return Math.abs(e.distanceTo(t)-i)<=2*this.tolerance}getClassType(){return"CircleMarkup"}};Hn._registerDrawableClass(d5);var kfe=new Ot,Pc=class extends wi{constructor(e,t){super(e),this.type="CloudLineMarkup",this.update(t)}draw(e,t){let n=this.points,i=[];e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor),e.fillStyle=Cn.rgba2Color(this.fillColor),e.beginPath();for(let s=0;sthis.transToScreenCoord(e,t))),r=(new be).lerpVectors(n,i,.5);this.radiusX=Math.abs(i.x-n.x)/2,this.radiusY=Math.abs(i.y-n.y)/2,e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor),e.fillStyle=Cn.rgba2Color(this.fillColor),e.beginPath(),e.ellipse(r.x,r.y,this.radiusX,this.radiusY,0,0,2*Math.PI),e.closePath(),e.stroke(),e.restore()}isPointInPath(e){let[t,n]=this.points,i=(new O).lerpVectors(t,n,.5),r=Math.pow(e.x-i.x,2),a=Math.pow(e.y-i.y,2),s=2*this.tolerance,o=Math.abs(n.x-t.x)/2-s,l=Math.abs(n.y-t.y)/2-s,h=r/(o*o),c=a/(l*l),u=Math.abs(n.x-t.x)/2+s,d=Math.abs(n.y-t.y)/2+s;return h+c>=1&&r/(u*u)+a/(d*d)<=1}getClassType(){return"EllipseMarkup"}};Hn._registerDrawableClass(m5);var oE=class extends wi{constructor(e,t,n){super(e),this.text="",this.fontSize=12,this.type="TextMarkup",this.padding=300,this.inputStatus="CHAR_TYPING",this.isEditing=!1,this.handleClick=()=>{},this.handleKeydown=e=>{if(this.textInput)if("Enter"===e.key){let e=parseInt(this.textInput.style.height);this.textInput.style.height=`${Math.round(e+this.fontSize/this.tolerance)}px`}else"Escape"===e.code&&this.exitEditing()},this.handleInput=()=>{var e;if(!this.textInput||!this.manager||"CHINESE_TYPING"===this.inputStatus)return;let t=this.textInput.value,n=(null==(e=this.manager.overlayRender)?void 0:e.measureTextLength(t,this.fontSize/this.tolerance+"px Arial"))||0;n>oE.DEFAULT_INPUT_WIDTH&&(this.textInput.style.width=`${Math.round(n+this.padding/this.tolerance*2)}px`),this.inputStatus="CHAR_TYPING",this.text=t},this.handleCompositionStart=()=>{this.inputStatus="CHINESE_TYPING"},this.handleCompositionEnd=()=>{var e;if(!this.textInput||!this.manager||"CHINESE_TYPING"!==this.inputStatus)return;let t=this.textInput.value,n=(null==(e=this.manager.overlayRender)?void 0:e.measureTextLength(t,this.fontSize/this.tolerance+"px Arial"))||0;n>oE.DEFAULT_INPUT_WIDTH&&(this.textInput.style.width=`${Math.round(n+this.padding/this.tolerance*2)}px`),this.text=t,this.inputStatus="CHAR_TYPING"},this.handleBlur=()=>{this.exitEditing()},this.handleFoucs=()=>{},this.update(t),this.text=n}draw(e,t){this.isEditing||this.drawText(e,t,this.text)}drawText(e,t,n){let i=this.transToScreenCoord(new O(this.x,this.y,0),t),r=n.split("\n"),a=this.fontSize/this.tolerance,s=0;e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor),e.fillStyle=Cn.rgba2Color(this.lineColor),e.textAlign="left",e.textBaseline="top",e.font=`${a}px Arial`;for(let h=0;hs&&(s=n)}let o=this.padding/this.tolerance,l=new be(i.x,i.y);for(let h=0;h[e.x,e.y])),text:this.text,lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,fontSize:this.fontSize,type:this.getClassType()}}getClassType(){return"TextMarkup"}addInput(e,t,n){var i;this.textInput||(this.textInput=document.createElement("textarea"),this.textInput.style.cssText=`\n position: absolute;\n border: ${this.lineWidth}px solid ${Cn.rgba2Color(this.lineColor)};\n background: transparent;\n outline: none;\n resize: none;\n overflow: hidden;\n z-index: 1000;\n box-sizing: content-box;\n display: inline-block;\n padding: ${this.padding/this.tolerance}px;\n whiteSpace: 'nowrap';\n color: ${this.lineColor}`,this.textInput.style.display="inline-block",null==(i=e.viewerCanvas.parentElement)||i.appendChild(this.textInput),this.addInputEvents()),this.manager=e,this.enterEditing(),this.textInput.style.left=`${t}px`,this.textInput.style.top=`${n}px`,this.textInput.style.width=`${oE.DEFAULT_INPUT_WIDTH}px`,this.textInput.style.height=this.fontSize/this.tolerance+"px",this.textInput.style.lineHeight=this.fontSize/this.tolerance+"px",this.textInput.style.fontSize=this.fontSize/this.tolerance+"px",this.textInput.style.color=Cn.rgba2Color(this.lineColor)}addInputEvents(){var e,t,n,i,r,a,s;null==(e=this.textInput)||e.addEventListener("click",this.handleClick),null==(t=this.textInput)||t.addEventListener("blur",this.handleBlur),null==(n=this.textInput)||n.addEventListener("foucs",this.handleFoucs),null==(i=this.textInput)||i.addEventListener("keydown",this.handleKeydown),null==(r=this.textInput)||r.addEventListener("input",this.handleInput),null==(a=this.textInput)||a.addEventListener("compositionstart",this.handleCompositionStart),null==(s=this.textInput)||s.addEventListener("compositionend",this.handleCompositionEnd)}enterEditing(){this.textInput&&(this.textInput.value=this.text,this.textInput.focus(),this.isEditing=!0,this.dispatchEvent("EnterEditing"))}exitEditing(){var e,t,n,i,r,a,s,o;null==(e=this.textInput)||e.removeEventListener("click",this.handleClick),null==(t=this.textInput)||t.removeEventListener("blur",this.handleBlur),null==(n=this.textInput)||n.removeEventListener("foucs",this.handleFoucs),null==(i=this.textInput)||i.removeEventListener("keydown",this.handleKeydown),null==(r=this.textInput)||r.removeEventListener("input",this.handleInput),null==(a=this.textInput)||a.removeEventListener("compositionstart",this.handleCompositionStart),null==(s=this.textInput)||s.removeEventListener("compositionend",this.handleCompositionEnd),null==(o=this.textInput)||o.remove(),this.textInput=void 0,this.isEditing=!1,this.dispatchEvent("ExitEditing")}},Ol=oE;Ol.DEFAULT_INPUT_WIDTH=50,Hn._registerDrawableClass(Ol);var Ffe=new be,Nfe=new be(1,0),Bfe=new be(0,-1),g5=class extends Ol{constructor(e,t,n){super(e,t,n),this.type="LeaderLineMarkup",this.text="LeaderLine",this.fontSize=12,this.textBounds=new Ot,this.handleInput=()=>{!this.textInput||!this.manager||"CHINESE_TYPING"===this.inputStatus||(this.text=this.textInput.value,this.calcuTextInputPositionByText(this.text),this.inputStatus="CHAR_TYPING")},this.handleCompositionEnd=()=>{!this.textInput||!this.manager||"CHINESE_TYPING"!==this.inputStatus||(this.text=this.textInput.value,this.calcuTextInputPositionByText(this.text),this.inputStatus="CHAR_TYPING")}}draw(e,t){if(this.points.length<2)return;let n=this.points.map((e=>this.transToScreenCoord(e,t))),[i,r]=this.points,a=(new O).subVectors(i,r).length()/10/this.tolerance;this.drawArrowLine(e,n,a),this.drawArrowHead(e,n[1],n[0],10,a),!this.isEditing&&this.text.length>0&&this.drawText(e,t,this.text)}drawArrowHead(e,t,n,i,r){let a=180*Math.atan2(t.y-n.y,t.x-n.x)/Math.PI,s=(a+i)*Math.PI/180,o=(a-i)*Math.PI/180,l=r*Math.cos(s),h=r*Math.sin(s),c=r*Math.cos(o),u=r*Math.sin(o),d=new be(n.x+l,n.y+h),p=new be(n.x+c,n.y+u);e.save(),e.fillStyle=Cn.rgba2Color(this.lineColor),e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(d.x,d.y),e.lineTo(p.x,p.y),e.closePath(),e.fill(),e.restore()}drawArrowLine(e,t,n){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor);let[i,r]=t,a=(new be).subVectors(i,r).normalize();e.beginPath(),e.moveTo(r.x,r.y);let s=i.clone().sub(a.multiplyScalar(n));e.lineTo(s.x,s.y),e.closePath(),e.stroke(),e.restore()}drawText(e,t,n){let[i,r]=this.points.map((e=>this.transToScreenCoord(e,t))),a=(new be).subVectors(r,i).normalize(),s=a.cross(Bfe)<0,o=a.cross(Nfe)<0,l=n.split("\n"),h=this.fontSize/this.tolerance,c=0;e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor),e.fillStyle=Cn.rgba2Color(this.lineColor),e.textAlign="left",e.textBaseline="top",e.font=`${h}px Arial`;for(let v=0;vc&&(c=n)}let u=this.padding/this.tolerance,d=u+h/2,p=l.length*h+2*u,f=new be(s?r.x:r.x-c-2*u,o?r.y-d:r.y-p+(p-d));for(let v=0;v[e.x,e.y])),text:this.text,lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,fontSize:this.fontSize,type:this.getClassType()}}isPointInPath(e){return Qt.isPointOnLineSegments(e,this.points,this.tolerance)||this.textBounds.containsPoint(e)}updateText(e){this.text=e}getClassType(){return"LeaderLineMarkup"}addInput(e,t,n){let[i,r]=this.points.map((t=>un.worldPosition2ScreenPoint(t,e.camera,e.viewerCanvas))),a=(new be).subVectors(r,i).normalize(),s=a.cross(Bfe)<0,o=a.cross(Nfe)<0,l=this.fontSize/this.tolerance,h=this.padding/this.tolerance,c=h+l/2,u=Ol.DEFAULT_INPUT_WIDTH,d=l;super.addInput(e,s?t:t-u-2*h,o?n-c:n-d+(d-c))}calcuTextInputPositionByText(e){var t;if(!this.textInput||!this.manager)return;let n=(null==(t=this.manager.overlayRender)?void 0:t.measureTextLength(e,this.fontSize/this.tolerance+"px Arial"))||0;if(n>Ol.DEFAULT_INPUT_WIDTH){let e=this.points[1],t=un.worldPosition2ScreenPoint(this.points[0],this.manager.camera,this.manager.viewerCanvas),i=un.worldPosition2ScreenPoint(e,this.manager.camera,this.manager.viewerCanvas).clone().sub(t).normalize().cross(new be(0,-1))<0,r=un.worldPosition2ScreenPoint(e,this.manager.camera,this.manager.viewerCanvas);i||(this.textInput.style.left=r.x-n-this.padding/this.tolerance*2+"px"),this.textInput.style.width=`${Math.round(n)}px`}}};Hn._registerDrawableClass(g5);var v5=class extends wi{constructor(e,t){super(e),this.type="PolylineMarkup",this.update(t)}draw(e,t){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor),e.fillStyle=Cn.rgba2Color(this.fillColor);let n=this.points;e.beginPath(),n.forEach(((n,i)=>{let r=this.transToScreenCoord(n,t);0===i?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.stroke(),e.restore()}isPointInPath(e){let t=this.points,n=[];for(let i=0;i{let r=this.transToScreenCoord(n,t);0===i?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.closePath(),e.stroke(),e.restore()}isPointInPath(e){let t=this.getVertexes(),n=[];for(let i=0;ithis.transToScreenCoord(e,t)));e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.moveTo(i.x,i.y),e.lineTo(a.x,a.y),e.closePath(),e.stroke(),e.restore()}isPointInPath(e){let[t,n,i,r]=this.getVertexes();return Qt.isPointOnLineSegments(e,[t,i,n,r],.1)}getClassType(){return"XMarkup"}};Hn._registerDrawableClass(x5);var Ufe=new Ot,b5=new O,E5=new be,dht=new be(1,0),fht=new be(0,-1),_5=class extends Ol{constructor(e,t,n=""){super(e,t,n),this.type="CloudRectWithTextMarkup",this.textPosition=new O,this.textBounds=new Ot,this.text="CloudRectWithText",this.fontSize=12,this.handleClick=()=>{var e;null==(e=this.textInput)||e.blur()},this.handleInput=()=>{!this.textInput||!this.manager||"CHINESE_TYPING"===this.inputStatus||(this.text=this.textInput.value,this.calcInputPositionByText(this.text),this.inputStatus="CHAR_TYPING")},this.handleCompositionEnd=()=>{!this.textInput||!this.manager||"CHINESE_TYPING"!==this.inputStatus||(this.text=this.textInput.value,this.calcInputPositionByText(this.text),this.inputStatus="CHAR_TYPING")}}draw(e,t){this.drawCloudRect(e,t),(this.isEditing||this.text.length>0)&&this.drawLeaderLine(e,t),!this.isEditing&&this.text.length>0&&this.drawText(e,t,this.text)}drawCloudRect(e,t){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor),e.fillStyle=Cn.rgba2Color(this.fillColor),e.beginPath();let n=this.getCloudPoints();n.push(n[0]);let i,r=[];for(let a=0;an.distanceTo(e)-n.distanceTo(t)));let i=this.controlPoints[0];e.save(),e.lineWidth=_5.LEADER_LINE_WIDTH,e.strokeStyle=Cn.rgba2Color(this.lineColor),e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(n.x,n.y),e.closePath(),e.stroke(),e.restore()}drawText(e,t,n){let i=this.transToScreenCoord(this.points[0],t),r=this.transToScreenCoord(this.textPosition,t),a=E5.subVectors(r,i).normalize(),s=a.cross(dht)<0,o=a.cross(fht)<0,l=n.split("\n"),h=this.fontSize/this.tolerance,c=0;e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor),e.fillStyle=Cn.rgba2Color(this.lineColor),e.textAlign="left",e.textBaseline="top",e.font=`${h}px Arial`;for(let v=0;vc&&(c=n)}let u=this.padding/this.tolerance,d=u+h/2,p=l.length*h+2*u,f=new be(o?r.x:r.x-c-2*u,s?r.y-d:r.y-p+(p-d));for(let v=0;ve.add(n))),this.textPosition.add(n);let[i,r]=this.points;return this.x=Math.min(i.x,r.x),this.y=Math.max(i.y,r.y),this.width=Math.abs(r.x-i.x),this.height=Math.abs(r.y-i.y),this}update(e){let[t,n]=e;return this.points=e,this.x=Math.min(t.x,n.x),this.y=Math.max(t.y,n.y),this.width=Math.abs(n.x-t.x),this.height=Math.abs(n.y-t.y),this.textPosition||(this.textPosition=new O),this.textPosition.set(Math.max(t.x,n.x),Math.max(t.y,n.y),0),this}getCloudPoints(){return[new O(this.x,this.y,0),new O(this.x+this.width,this.y,0),new O(this.x+this.width,this.y-this.height,0),new O(this.x,this.y-this.height,0)]}getBounds(){return Ufe.setFromPoints([...this.points,...this.vertexes||[]]),Ufe.union(this.textBounds)}getVertexes(){let e=this.getBounds(),t=e.min,n=e.getSize(b5);return[new O(t.x,t.y,0),new O(t.x+n.x,t.y,0),new O(t.x+n.x,t.y+n.y,0),new O(t.x,t.y+n.y,0)]}isLeaderTextSelected(e){return this.textBounds.containsPoint(e)}translateLeaderText(e,t){let n=new O(e,t,0);return this.textPosition.add(n),this}isPointInPath(e){let t=this.getCloudPoints(),n=[];for(let i=0;i[e.x,e.y])),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,fontSize:this.fontSize,text:this.text,textPosition:[this.textPosition.x,this.textPosition.y],type:this.getClassType()}}getClassType(){return"CloudRectWithTextMarkup"}addInput(e,t,n){let i=this.padding/this.tolerance+this.fontSize/this.tolerance/2;super.addInput(e,t,n-i)}updateInputPosition(e,t){var n;if(!this.manager||!this.textInput)return;let i=t.clone().sub(e).normalize().cross(new be(0,-1))<0,r=this.textInput.value,a=(null==(n=this.manager.overlayRender)?void 0:n.measureTextLength(r,this.fontSize/this.tolerance+"px Arial"))||Ol.DEFAULT_INPUT_WIDTH,s=this.padding/this.tolerance+this.fontSize/this.tolerance/2;this.textInput.style.left=`${i?t.x:t.x-this.padding/this.tolerance*2-a}px`,this.textInput.style.top=t.y-s+"px",this.textPosition.copy(un.screenPoint2worldPosition(t,this.manager.camera,this.manager.viewerCanvas))}calcInputPositionByText(e){var t;if(!this.textInput||!this.manager)return;let n=(null==(t=this.manager.overlayRender)?void 0:t.measureTextLength(e,this.fontSize/this.tolerance+"px Arial"))||0;if(n>Ol.DEFAULT_INPUT_WIDTH){let e=un.worldPosition2ScreenPoint(this.points[0],this.manager.camera,this.manager.viewerCanvas),t=un.worldPosition2ScreenPoint(this.textPosition,this.manager.camera,this.manager.viewerCanvas).clone().sub(e).normalize().cross(new be(0,-1))<0,i=un.worldPosition2ScreenPoint(this.textPosition,this.manager.camera,this.manager.viewerCanvas);t||(this.textInput.style.left=i.x-n-this.padding/this.tolerance*2+"px"),this.textInput.style.width=`${Math.round(n)}px`}}},Bm=_5;Bm.LEADER_LINE_WIDTH=1,Hn._registerDrawableClass(Bm);var tr={LEFT:1,RIGHT:2,MIDDLE:4},yt=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768});function Rf(e){return e.isPerspectiveCamera}function Vu(e){return e.isOrthographicCamera}var pht=(e=>(e[e.NONE=-1]="NONE",e[e.ROTATE=0]="ROTATE",e[e.DOLLY=1]="DOLLY",e[e.PAN=2]="PAN",e[e.TOUCH_ROTATE=3]="TOUCH_ROTATE",e[e.TOUCH_DOLLY=4]="TOUCH_DOLLY",e))(pht||{}),mht=(e=>(e.LEFT="ArrowLeft",e.UP="ArrowUp",e.RIGHT="ArrowRight",e.BOTTOM="ArrowDown",e))(mht||{});function Zv(e){return{type:e}}var zu={movable:!1,startDistBetweenFingers:0,scale:1},Kv=2*Math.PI,Hfe=1e-6,KA=class extends jo{constructor(e,t,n=!1){super(),this.enabled=!0,this.target=new O,this.enableZoom=!1,this.enablePan=!1,this.enableRotate=!0,this.state=-1,this.rotateSpeed=1,this.zoomSpeed=1,this.panSpeed=1,this.scale=1,this.minZoom=0,this.maxZoom=1/0,this.screenSpacePanning=!0,this.autoRotate=!0,this.autoRotateSpeed=2,this.enableDamping=!1,this.dampingFactor=.05,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minDistance=0,this.maxDistance=1/0,this.keyPanSpeed=7,this.minFov=50,this.maxFov=95,this.zoomChanged=!1,this.panOffset=new O,this.pointerPositions={},this.rotateStart=new be,this.rotateEnd=new be,this.rotateDelta=new be,this.dollyStart=new be,this.dollyEnd=new be,this.dollyDelta=new be,this.panStart=new be,this.panEnd=new be,this.panDelta=new be,this.pointers=[],this.spherical=new ff,this.sphericalDelta=new ff,this.update=function(e){let t=new O,n=new O,i=new hr;return function(){let r=e.quat,a=r.clone().invert(),s=e.object.position;t.copy(s).sub(e.target),t.applyQuaternion(r),e.spherical.setFromVector3(t),e.autoRotate&&-1===e.state&&(e.isVRMode?e.sphericalDelta.theta+=Kv/60/60*e.autoRotateSpeed:e.sphericalDelta.theta-=Kv/60/60*e.autoRotateSpeed),e.enableDamping?(e.spherical.theta+=e.sphericalDelta.theta*e.dampingFactor,e.spherical.phi+=e.sphericalDelta.phi*e.dampingFactor):(e.spherical.theta+=e.sphericalDelta.theta,e.spherical.phi+=e.sphericalDelta.phi);let o=e.minAzimuthAngle,l=e.maxAzimuthAngle;return isFinite(o)&&isFinite(l)&&(o<-Math.PI?o+=Kv:o>Math.PI&&(o-=Kv),l<-Math.PI?l+=Kv:l>Math.PI&&(l-=Kv),e.spherical.theta=o<=l?Math.max(o,Math.min(l,e.spherical.theta)):e.spherical.theta>(o+l)/2?Math.max(o,e.spherical.theta):Math.min(l,e.spherical.theta)),e.spherical.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,e.spherical.phi)),e.spherical.makeSafe(),e.spherical.radius*=e.scale,e.spherical.radius=Math.max(e.minDistance,Math.min(e.maxDistance,e.spherical.radius)),!0===e.enableDamping?e.target.addScaledVector(e.panOffset,e.dampingFactor):e.target.add(e.panOffset),t.setFromSpherical(e.spherical),t.applyQuaternion(a),s.copy(e.target).add(t),e.object.lookAt(e.target),!0===e.enableDamping?(e.sphericalDelta.theta*=1-e.dampingFactor,e.sphericalDelta.phi*=1-e.dampingFactor,e.panOffset.multiplyScalar(1-e.dampingFactor)):(e.sphericalDelta.set(0,0,0),e.panOffset.set(0,0,0)),e.scale=1,!!(e.zoomChanged||n.distanceToSquared(e.object.position)>Hfe||8*(1-i.dot(e.object.quaternion))>Hfe)&&(e.dispatchEvent(Zv("change")),n.copy(e.object.position),i.copy(e.object.quaternion),e.zoomChanged=!1,!0)}}(this),this.onContextMenu=function(e){return t=>{!1!==e.enabled&&t.preventDefault()}}(this),this.onPointerDown=function(e){return t=>{!1!==e.enabled&&(0===e.pointers.length&&(e.domElement.setPointerCapture(t.pointerId),e.domElement.addEventListener("pointermove",e.onPointerMove),e.domElement.addEventListener("pointerup",e.onPointerUp)),e.addPointer(t),"touch"===t.pointerType?e.onTouchStart(t):e.onMouseDown(t))}}(this),this.onPointerMove=function(e){return t=>{!1!==e.enabled&&("touch"===t.pointerType?e.onTouchMove(t):e.onMouseMove(t))}}(this),this.onPointerUp=function(e){return t=>{e.removePointer(t),0===e.pointers.length&&(e.domElement.releasePointerCapture(t.pointerId),e.domElement.removeEventListener("pointermove",e.onPointerMove),e.domElement.removeEventListener("pointerup",e.onPointerUp)),"touch"===t.pointerType&&e.handlerTouchEnd(t),e.dispatchEvent(Zv("end")),e.state=-1}}(this),this.onPointerCancel=function(e){return t=>{e.removePointer(t),e.handlerTouchEnd(t)}}(this),this.onMouseWheel=function(e){return t=>{!1===e.enabled||!1===e.enableZoom||-1!==e.state||(t.preventDefault(),t.stopPropagation(),e.dispatchEvent(Zv("start")),e.handleMouseWheel(t),e.dispatchEvent(Zv("end")))}}(this),this.pan=function(e){let t=new O;return function(n,i){let r=e.domElement;if(e.object instanceof cr){let a=e.object.position;t.copy(a).sub(e.target);let s=t.length();s*=Math.tan(e.object.fov/2*Math.PI/180),e.panLeft(2*n*s/r.clientHeight,e.object.matrix),e.panUp(2*i*s/r.clientHeight,e.object.matrix)}else console.warn("WARNING: VRControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1}}(this),this.panLeft=function(e){let t=new O;return function(n,i){t.setFromMatrixColumn(i,0),t.multiplyScalar(-n),e.panOffset.add(t)}}(this),this.panUp=function(e){let t=new O;return function(n,i){!0===e.screenSpacePanning?t.setFromMatrixColumn(i,1):(t.setFromMatrixColumn(i,0),t.crossVectors(e.object.up,t)),t.multiplyScalar(n),e.panOffset.add(t)}}(this),this.onKeyDown=e=>{!1===this.enabled||!1===this.enablePan||this.handleKeyDown(e)},this.object=e,this.domElement=t,this.isVRMode=n,this.quat=(new hr).setFromUnitVectors(this.object.up,new O(0,1,0)),this.domElement&&this.domElement.style&&(this.domElement.style.touchAction="none"),this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointercancel",this.onPointerCancel),this.domElement.addEventListener("wheel",this.onMouseWheel,{passive:!1}),this.update()}dispose(){this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onMouseWheel),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp),this.domElementKeyEvents&&this.domElementKeyEvents.removeEventListener("keydown",this.onKeyDown)}addPointer(e){this.pointers.push(e)}removePointer(e){delete this.pointerPositions[e.pointerId];for(let t=0;t0&&this.dollyOut(t),this.update()}handleMouseDownRotate(e){this.rotateStart.set(e.clientX,e.clientY)}handleMouseDownDolly(e){this.dollyStart.set(e.clientX,e.clientY)}handleMouseDownPan(e){this.panStart.set(e.clientX,e.clientY)}handleTouchStartRotate(){if(1===this.pointers.length)this.rotateStart.set(this.pointers[0].pageX,this.pointers[0].pageY);else{let e=.5*(this.pointers[0].pageX+this.pointers[1].pageX),t=.5*(this.pointers[0].pageY+this.pointers[1].pageY);this.rotateStart.set(e,t)}}handleTouchStartDolly(e){if(e.length<2)return;let t=e[0],n=e[1];zu.startDistBetweenFingers=this.getDist([t.pageX,t.pageY],[n.pageX,n.pageY]),zu.movable=!0,zu.scale=1}updateRotate(){let e=this.isVRMode,t=this.sphericalDelta;this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);let n=this.domElement;e?(t.theta+=2*Math.PI*this.rotateDelta.x/n.clientHeight,t.phi+=2*Math.PI*this.rotateDelta.y/n.clientHeight):(t.theta-=2*Math.PI*this.rotateDelta.x/n.clientHeight,t.phi-=2*Math.PI*this.rotateDelta.y/n.clientHeight),this.rotateStart.copy(this.rotateEnd)}handleMouseMoveRotate(e){this.rotateEnd.set(e.clientX,e.clientY),this.updateRotate()}dollyOut(e){this.object instanceof cr?this.scale/=e:(console.warn("WARNING: VRControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}dollyIn(e){this.object instanceof cr?this.scale*=e:(console.warn("WARNING: VRControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}handleMouseMoveDolly(e){this.dollyEnd.set(e.clientX,e.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart);let t=Math.pow(.95,this.zoomSpeed);this.dollyDelta.y>0?this.dollyOut(t):this.dollyIn(t),this.dollyStart.copy(this.dollyEnd)}handleMouseMovePan(e){this.panEnd.set(e.clientX,e.clientY),this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}getSecondPointerPosition(e){let t=e.pointerId===this.pointers[0].pointerId?this.pointers[1]:this.pointers[0];return this.pointerPositions[t.pointerId]}handleTouchMoveRotate(e){if(1==this.pointers.length)this.rotateEnd.set(e.pageX,e.pageY);else{let t=this.getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this.rotateEnd.set(n,i)}this.updateRotate()}updateFov(e){var t;let n=this.object;if(!(n&&n instanceof cr))return void console.warn("WARNING: VRControls.js encountered an unknown camera type - updateFov disabled.");let i=this.minFov,r=this.maxFov,a=e=>{let t=n.fov+e;t=Math.min(t,r),t=Math.max(t,i),n.fov!==t&&(n.fov=t,n.updateProjectionMatrix(),this.dispatchEvent({type:"change"}))},s=e/20;for(let o=0;o<20;++o)setTimeout((()=>a(s)),5*o);this.autoRotate&&(null==(t=this.controlsHelper)||t.delayAutoRotate())}handleTouchMoveDolly(e){if(!zu.movable||this.pointers.length<2)return;let t=this.getSecondPointerPosition(e),n=[e.pageX,e.pageY],i=[t.x,t.y],r=zu.startDistBetweenFingers,a=this.getDist(n,i);if(!r||!a||Math.abs(r-a)<10)return;let s=a/r;console.log(s),s=Math.min(s,3),s=Math.max(s,1/3);let o=s-zu.scale;if(Math.abs(o)<.05)return;let l=0;l=o>0?10*-o:10*(zu.scale/s-1),this.updateFov(l),zu.scale=s}handleKeyDown(e){let t=!1;switch(e.code){case"ArrowUp":this.pan(0,this.keyPanSpeed),t=!0;break;case"ArrowDown":this.pan(0,-this.keyPanSpeed),t=!0;break;case"ArrowLeft":this.pan(this.keyPanSpeed,0),t=!0;break;case"ArrowRight":this.pan(-this.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),this.update())}listenToKeyEvents(e){e.addEventListener("keydown",this.onKeyDown),this.domElementKeyEvents=e}},Jo=class extends cs{constructor(e){super(),this.enabled=!0,this.keyboardEnabled=!0,this.mouseDownPositionX=0,this.mouseDownPositionY=0,this.lastLeftPointerUpTime=0,this.pointers=[],this.handleClick=e=>{if(!this.enabled)return;let t=this.getBaseEvent(e);this.dispatchEvent("click",t)},this.handlePointerDown=e=>{if(!this.enabled)return;this.stop(e);let t=this.getBaseEvent(e);this.isDoubleClick(t)?(this.lastLeftPointerUpTime=0,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.dispatchEvent("dblclick",t)):(this.mouseDownPositionX=t.x,this.mouseDownPositionY=t.y),this.dispatchEvent("pointerdown",t),"touch"===e.pointerType?(this.pointers.push(t),t.pointers=this.pointers,this.dispatchEvent("touchstart",t)):this.dispatchEvent("mousedown",t)},this.handlePointerMove=e=>{if(!this.enabled)return;this.stop(e);let t=this.getBaseEvent(e);this.isCloseToLastPosition(t)||(this.dispatchEvent("pointermove",t),"touch"===e.pointerType?(this.updatePointers(t),t.pointers=this.pointers,this.dispatchEvent("touchmove",t)):this.dispatchEvent("mousemove",t))},this.handlePointerUp=e=>{if(!this.enabled)return;this.stop(e);let t=this.getBaseEvent(e);0===t.button&&(this.lastLeftPointerUpTime=t.timestamp),this.dispatchEvent("pointerup",t),"touch"===e.pointerType?(this.removePointers(t),t.pointers=this.pointers,this.dispatchEvent("touchend",t)):this.dispatchEvent("mouseup",t)},this.handlePointerCancel=e=>{this.enabled&&(this.stop(e),this.dispatchEvent("pointercancel",this.getBaseEvent(e)))},this.handleMouseWheel=e=>{this.enabled&&(this.stop(e),this.dispatchEvent("wheel",this.getBaseEvent(e)))},this.handleContextMenu=e=>{if(this.enabled)return this.stop(e),this.dispatchEvent("contextmenu",this.getBaseEvent(e)),!1},this.handlePointerEnter=e=>{this.enabled&&(this.stop(e),this.dispatchEvent("pointerenter",this.getBaseEvent(e)))},this.handlePointerLeave=e=>{this.enabled&&(this.stop(e),this.dispatchEvent("pointerleave",this.getBaseEvent(e)))},this.handleResize=e=>{this.enabled&&(this.stop(e),this.dispatchEvent("resize",this.getBaseEvent(e)))},this.handleKeydown=e=>{!this.enabled||!this.keyboardEnabled||this.dispatchEvent("keydown",this.getBaseEvent(e))},this.handleKeyup=e=>{!this.enabled||!this.keyboardEnabled||this.dispatchEvent("keyup",this.getBaseEvent(e))},this.style={},this.element=e,this.bindEvents()}getEnabled(){return this.enabled}setEnabled(e){this.enabled=e}getkKeyboardEnabled(){return this.keyboardEnabled}setkKeyboardEnabled(e){this.keyboardEnabled=e}setCursor(e){this.element.style&&(this.element.style.cursor=e||"default")}bindEvents(){this.element.style.touchAction="none",this.element.style.userSelect="none",this.element.style.webkitUserSelect="none",this.element.addEventListener("click",this.handleClick),this.element.addEventListener("pointerdown",this.handlePointerDown),this.element.addEventListener("pointermove",this.handlePointerMove),this.element.addEventListener("pointerup",this.handlePointerUp),this.element.addEventListener("pointercancel",this.handlePointerCancel),this.element.addEventListener("pointerenter",this.handlePointerEnter),this.element.addEventListener("pointerleave",this.handlePointerLeave),this.element.addEventListener("contextmenu",this.handleContextMenu),this.element.addEventListener("wheel",this.handleMouseWheel),window.addEventListener("resize",this.handleResize),window.addEventListener("keydown",this.handleKeydown),window.addEventListener("keyup",this.handleKeyup)}unBindEvents(){this.element.removeEventListener("pointerdown",this.handlePointerDown),this.element.removeEventListener("pointermove",this.handlePointerMove),this.element.removeEventListener("pointerup",this.handlePointerUp),this.element.removeEventListener("pointerenter",this.handlePointerEnter),this.element.removeEventListener("pointerleave",this.handlePointerLeave),this.element.removeEventListener("contextmenu",this.handleContextMenu),this.element.removeEventListener("wheel",this.handleMouseWheel),window.removeEventListener("resize",this.handleResize),window.removeEventListener("keydown",this.handleKeydown),window.removeEventListener("keyup",this.handleKeyup),this.element.style.touchAction="",this.element.style.userSelect="",this.element.style.webkitUserSelect=""}getBaseEvent(e){let t={x:0,y:0,pageX:0,pageY:0,clientX:0,clientY:0,deltaX:0,deltaY:0,movementX:0,movementY:0,deltaMode:0,pointerId:0,timestamp:0,buttons:0,pointerType:"mouse",altKey:!1,ctrlKey:!1,shiftKey:!1,metaKey:!1,originalEvent:e};if(t.timestamp=e.timeStamp,JA(e,"clientX"))if(t.altKey=e.altKey,t.ctrlKey=e.ctrlKey,t.shiftKey=e.shiftKey,t.clientX=e.clientX,t.clientY=e.clientY,t.button=e.button,JA(e,"pointerId")){t.pointerType=e.pointerType,t.buttons=e.buttons,t.pageX=e.pageX,t.pageY=e.pageY,t.pointerId=e.pointerId;let n=un.getScreenPointByEvent(e,this.element);t.x=n.x,t.y=n.y,t.movementX=e.movementX,t.movementY=e.movementY}else JA(e,"deltaX")&&(t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaY=e.deltaY);else JA(e,"code")&&(t.altKey=e.altKey,t.ctrlKey=e.ctrlKey,t.shiftKey=e.shiftKey,t.metaKey=e.metaKey,t.code=e.code);return t}stop(e){e.preventDefault()}updatePointers(e){for(let t=0;t0==p>c&&(p=c,n.value=(p-c)/a),p}function S5(e,t,n,i,r=1/0,a,s){let o=2/(i=Math.max(1e-4,i)),l=o*a,h=1/(1+l+.48*l*l+.235*l*l*l),c=t.x,u=t.y,d=t.z,p=e.x-c,f=e.y-u,m=e.z-d,g=c,v=u,y=d,x=r*i,b=p*p+f*f+m*m;if(b>x*x){let e=Math.sqrt(b);p=p/e*x,f=f/e*x,m=m/e*x}c=e.x-p,u=e.y-f,d=e.z-m;let _=(n.x+o*p)*a,w=(n.y+o*f)*a,S=(n.z+o*m)*a;n.x=(n.x-o*_)*h,n.y=(n.y-o*w)*h,n.z=(n.z-o*S)*h,s.x=c+(p+_)*h,s.y=u+(f+w)*h,s.z=d+(m+S)*h;let M=g-e.x,E=v-e.y,T=y-e.z;return M*(s.x-g)+E*(s.y-v)+T*(s.z-y)>0&&(s.x=g,s.y=v,s.z=y,n.x=(s.x-g)/a,n.y=(s.y-v)/a,n.z=(s.z-y)/a),s}function QA(e,t){t.set(0,0),e.forEach((e=>{t.x+=e.clientX,t.y+=e.clientY})),t.x/=e.length,t.y/=e.length}function eC(e,t){return!!Vu(e)&&(console.warn(`${t} is not supported in OrthographicCamera`),!0)}var tC=class{constructor(){this._listeners={}}addEventListener(e,t){let n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){let n=this._listeners[e];if(void 0!==n){let e=n.indexOf(t);-1!==e&&n.splice(e,1)}}removeAllEventListeners(e){e?Array.isArray(this._listeners[e])&&(this._listeners[e].length=0):this._listeners={}}dispatchEvent(e){let t=this._listeners[e.type];if(void 0!==t){e.target=this;let n=t.slice(0);for(let t=0,i=n.length;t{},this._enabled=!0,this._state=yt.NONE,this._viewport=null,this._dollyControlAmount=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=Dn.isBrowser?new DOMRect:{x:0,y:0,width:0,height:0,left:0,right:0,top:0,bottom:0},this._activePointers=[],this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new nr.Vector3,this._focalOffsetVelocity=new nr.Vector3,this._zoomVelocity={value:0},this._truckInternal=(e,t,n)=>{if(Rf(this._camera)){let i=ar.copy(this._camera.position).sub(this._target),r=this._camera.getEffectiveFOV()*Jv,a=i.length()*Math.tan(.5*r),s=this.truckSpeed*e*a/this._elementRect.height,o=this.truckSpeed*t*a/this._elementRect.height;this.verticalDragToForward?(n?this.setFocalOffset(this._focalOffsetEnd.x+s,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(s,0,!0),this.forward(-o,!0)):n?this.setFocalOffset(this._focalOffsetEnd.x+s,this._focalOffsetEnd.y+o,this._focalOffsetEnd.z,!0):this.truck(s,o,!0)}else if(Vu(this._camera)){let i=this._camera,r=e*(i.right-i.left)/i.zoom/this._elementRect.width,a=t*(i.top-i.bottom)/i.zoom/this._elementRect.height;n?this.setFocalOffset(this._focalOffsetEnd.x+r,this._focalOffsetEnd.y+a,this._focalOffsetEnd.z,!0):this.truck(r,a,!0)}},this._rotateInternal=(e,t)=>{let n=Um*this.azimuthRotateSpeed*e/this._elementRect.height,i=Um*this.polarRotateSpeed*t/this._elementRect.height;this.rotate(n,i,!0)},this._dollyInternal=(e,t,n)=>{let i=Math.pow(.95,-e*this.dollySpeed),r=this._sphericalEnd.radius*i,a=this._sphericalEnd.radius,s=a*(e>=0?-1:1);this.dollyTo(r),this.infinityDolly&&(r{let i=Math.pow(.95,e*this.dollySpeed),r=this._zoomEnd;this.zoomTo(this._zoom*i),this.dollyToCursor&&(this._dollyControlAmount+=this._zoomEnd-r,this._dollyControlCoord.set(t,n))},void 0===nr&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=(new nr.Quaternion).setFromUnitVectors(this._camera.up,rC),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=yt.NONE,this._target=new nr.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new nr.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=(new nr.Spherical).setFromVector3(ar.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._nearPlaneCorners=[new nr.Vector3,new nr.Vector3,new nr.Vector3,new nr.Vector3],this._updateNearPlaneCorners(),this._boundary=new nr.Box3(new nr.Vector3(-1/0,-1/0,-1/0),new nr.Vector3(1/0,1/0,1/0)),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlAmount=0,this._dollyControlCoord=new nr.Vector2,this.mouseButtons={left:yt.ROTATE,middle:yt.DOLLY,right:yt.TRUCK,wheel:Rf(this._camera)?yt.DOLLY:Vu(this._camera)?yt.ZOOM:yt.NONE},this.touches={one:yt.TOUCH_ROTATE,two:Rf(this._camera)?yt.TOUCH_DOLLY_TRUCK:Vu(this._camera)?yt.TOUCH_ZOOM_TRUCK:yt.NONE,three:yt.TOUCH_TRUCK};let n=new nr.Vector2,i=new nr.Vector2,r=new nr.Vector2,a=e=>{if(!this._enabled||!this._domElement)return;let t="mouse"!==e.pointerType?null:(e.buttons&tr.LEFT)===tr.LEFT?tr.LEFT:(e.buttons&tr.MIDDLE)===tr.MIDDLE?tr.MIDDLE:(e.buttons&tr.RIGHT)===tr.RIGHT?tr.RIGHT:null;if(null!==t){let e=this._findPointerByMouseButton(t);e&&this._activePointers.splice(this._activePointers.indexOf(e),1)}let n={pointerId:e.pointerId,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:0,mouseButton:t};this._activePointers.push(n),this._domElement.removeEventListener("pointermove",o),this._domElement.removeEventListener("pointerup",h),this._domElement.addEventListener("pointermove",o),this._domElement.addEventListener("pointerup",h),f(e)},s=e=>{if(!this._enabled||!this._domElement)return;let t=(e.buttons&tr.LEFT)===tr.LEFT?tr.LEFT:(e.buttons&tr.MIDDLE)===tr.MIDDLE?tr.MIDDLE:(e.buttons&tr.RIGHT)===tr.RIGHT?tr.RIGHT:null;if(null!==t){let e=this._findPointerByMouseButton(t);e&&this._activePointers.splice(this._activePointers.indexOf(e),1)}let n={pointerId:0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:0,mouseButton:(e.buttons&tr.LEFT)===tr.LEFT?tr.LEFT:(e.buttons&tr.MIDDLE)===tr.LEFT?tr.MIDDLE:(e.buttons&tr.RIGHT)===tr.LEFT?tr.RIGHT:null};this._activePointers.push(n),this._domElement.removeEventListener("mousemove",l),this._domElement.removeEventListener("mouseup",c),this._domElement.addEventListener("mousemove",l),this._domElement.addEventListener("mouseup",c),f(e)},o=e=>{let t=e.pointerId,n=this._findPointerById(t);if(n){if(n.clientX=e.clientX,n.clientY=e.clientY,n.deltaX=e.movementX,n.deltaY=e.movementY,"touch"===e.pointerType)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else this._state=0,(e.buttons&tr.LEFT)===tr.LEFT&&(this._state=this._state|this.mouseButtons.left),(e.buttons&tr.MIDDLE)===tr.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&tr.RIGHT)===tr.RIGHT&&(this._state=this._state|this.mouseButtons.right);m()}},l=e=>{let t=this._findPointerById(0);t&&(t.clientX=e.clientX,t.clientY=e.clientY,t.deltaX=e.movementX,t.deltaY=e.movementY,this._state=0,(e.buttons&tr.LEFT)===tr.LEFT&&(this._state=this._state|this.mouseButtons.left),(e.buttons&tr.MIDDLE)===tr.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&tr.RIGHT)===tr.RIGHT&&(this._state=this._state|this.mouseButtons.right),m())},h=e=>{let t=e.pointerId,n=this._findPointerById(t);if(n&&this._activePointers.splice(this._activePointers.indexOf(n),1),"touch"===e.pointerType)switch(this._activePointers.length){case 0:this._state=yt.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else this._state=yt.NONE;g()},c=()=>{let e=this._findPointerById(0);e&&this._activePointers.splice(this._activePointers.indexOf(e),1),this._state=yt.NONE,g()},u=-1,d=e=>{if(!this._enabled||this.mouseButtons.wheel===yt.NONE)return;if(this.dollyToCursor||this.mouseButtons.wheel===yt.ROTATE||this.mouseButtons.wheel===yt.TRUCK){let e=performance.now();u-e<1e3&&this._getClientRect(this._elementRect),u=e}let t=ght?-1:-3,n=1===e.deltaMode?e.deltaY/t:e.deltaY/(10*t),i=this.dollyToCursor?(e.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,r=this.dollyToCursor?(e.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case yt.ROTATE:this._rotateInternal(e.deltaX,e.deltaY),this._isUserControllingRotate=!0;break;case yt.TRUCK:this._truckInternal(e.deltaX,e.deltaY,!1),this._isUserControllingTruck=!0;break;case yt.OFFSET:this._truckInternal(e.deltaX,e.deltaY,!0),this._isUserControllingOffset=!0;break;case yt.DOLLY:this._dollyInternal(-n,i,r),this._isUserControllingDolly=!0;break;case yt.ZOOM:this._zoomInternal(-n,i,r),this._isUserControllingZoom=!0}this.dispatchEvent({type:"control"})},p=e=>{if(this._domElement&&this._enabled&&this.mouseButtons.right===Af.ACTION.NONE){let t=e instanceof PointerEvent?e.pointerId:(MouseEvent,0),n=this._findPointerById(t);return n&&this._activePointers.splice(this._activePointers.indexOf(n),1),this._domElement.removeEventListener("pointermove",o),this._domElement.removeEventListener("pointerup",h),this._domElement.removeEventListener("mousemove",l),void this._domElement.removeEventListener("mouseup",c)}},f=e=>{if(this._enabled){if(QA(this._activePointers,xo),this._getClientRect(this._elementRect),n.copy(xo),i.copy(xo),this._activePointers.length>=2){let e=xo.x-this._activePointers[1].clientX,t=xo.y-this._activePointers[1].clientY,n=Math.sqrt(e*e+t*t);r.set(0,n);let a=.5*(this._activePointers[0].clientX+this._activePointers[1].clientX),s=.5*(this._activePointers[0].clientY+this._activePointers[1].clientY);i.set(a,s)}if("pointerType"in e&&"touch"===e.pointerType)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else this._state=0,(e.buttons&tr.LEFT)===tr.LEFT&&(this._state=this._state|this.mouseButtons.left),(e.buttons&tr.MIDDLE)===tr.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&tr.RIGHT)===tr.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&yt.ROTATE)===yt.ROTATE||(this._state&yt.TOUCH_ROTATE)===yt.TOUCH_ROTATE||(this._state&yt.TOUCH_DOLLY_ROTATE)===yt.TOUCH_DOLLY_ROTATE||(this._state&yt.TOUCH_ZOOM_ROTATE)===yt.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&yt.TRUCK)===yt.TRUCK||(this._state&yt.TOUCH_TRUCK)===yt.TOUCH_TRUCK||(this._state&yt.TOUCH_DOLLY_TRUCK)===yt.TOUCH_DOLLY_TRUCK||(this._state&yt.TOUCH_ZOOM_TRUCK)===yt.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&yt.DOLLY)===yt.DOLLY||(this._state&yt.TOUCH_DOLLY)===yt.TOUCH_DOLLY||(this._state&yt.TOUCH_DOLLY_TRUCK)===yt.TOUCH_DOLLY_TRUCK||(this._state&yt.TOUCH_DOLLY_OFFSET)===yt.TOUCH_DOLLY_OFFSET||(this._state&yt.TOUCH_DOLLY_ROTATE)===yt.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&yt.ZOOM)===yt.ZOOM||(this._state&yt.TOUCH_ZOOM)===yt.TOUCH_ZOOM||(this._state&yt.TOUCH_ZOOM_TRUCK)===yt.TOUCH_ZOOM_TRUCK||(this._state&yt.TOUCH_ZOOM_OFFSET)===yt.TOUCH_ZOOM_OFFSET||(this._state&yt.TOUCH_ZOOM_ROTATE)===yt.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&yt.OFFSET)===yt.OFFSET||(this._state&yt.TOUCH_OFFSET)===yt.TOUCH_OFFSET||(this._state&yt.TOUCH_DOLLY_OFFSET)===yt.TOUCH_DOLLY_OFFSET||(this._state&yt.TOUCH_ZOOM_OFFSET)===yt.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})}},m=()=>{if(!this._enabled)return;QA(this._activePointers,xo);let e=!!Dn.isBrowser&&this._domElement&&document.pointerLockElement===this._domElement,t=e?-this._activePointers[0].deltaX:i.x-xo.x,a=e?-this._activePointers[0].deltaY:i.y-xo.y;if(i.copy(xo),((this._state&yt.ROTATE)===yt.ROTATE||(this._state&yt.TOUCH_ROTATE)===yt.TOUCH_ROTATE||(this._state&yt.TOUCH_DOLLY_ROTATE)===yt.TOUCH_DOLLY_ROTATE||(this._state&yt.TOUCH_ZOOM_ROTATE)===yt.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(t,a),this._isUserControllingRotate=!0),(this._state&yt.DOLLY)===yt.DOLLY||(this._state&yt.ZOOM)===yt.ZOOM){let e=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,t=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&yt.DOLLY)===yt.DOLLY?(this._dollyInternal(a*nC,e,t),this._isUserControllingDolly=!0):(this._zoomInternal(a*nC,e,t),this._isUserControllingZoom=!0)}if((this._state&yt.TOUCH_DOLLY)===yt.TOUCH_DOLLY||(this._state&yt.TOUCH_ZOOM)===yt.TOUCH_ZOOM||(this._state&yt.TOUCH_DOLLY_TRUCK)===yt.TOUCH_DOLLY_TRUCK||(this._state&yt.TOUCH_ZOOM_TRUCK)===yt.TOUCH_ZOOM_TRUCK||(this._state&yt.TOUCH_DOLLY_OFFSET)===yt.TOUCH_DOLLY_OFFSET||(this._state&yt.TOUCH_ZOOM_OFFSET)===yt.TOUCH_ZOOM_OFFSET||(this._state&yt.TOUCH_DOLLY_ROTATE)===yt.TOUCH_DOLLY_ROTATE||(this._state&yt.TOUCH_ZOOM_ROTATE)===yt.TOUCH_ZOOM_ROTATE){let e=xo.x-this._activePointers[1].clientX,t=xo.y-this._activePointers[1].clientY,n=Math.sqrt(e*e+t*t),a=r.y-n;r.set(0,n);let s=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,o=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&yt.TOUCH_DOLLY)===yt.TOUCH_DOLLY||(this._state&yt.TOUCH_DOLLY_ROTATE)===yt.TOUCH_DOLLY_ROTATE||(this._state&yt.TOUCH_DOLLY_TRUCK)===yt.TOUCH_DOLLY_TRUCK||(this._state&yt.TOUCH_DOLLY_OFFSET)===yt.TOUCH_DOLLY_OFFSET?(this._dollyInternal(a*nC,s,o),this._isUserControllingDolly=!0):(this._zoomInternal(a*nC,s,o),this._isUserControllingZoom=!0)}((this._state&yt.TRUCK)===yt.TRUCK||(this._state&yt.TOUCH_TRUCK)===yt.TOUCH_TRUCK||(this._state&yt.TOUCH_DOLLY_TRUCK)===yt.TOUCH_DOLLY_TRUCK||(this._state&yt.TOUCH_ZOOM_TRUCK)===yt.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(t,a,!1),this._isUserControllingTruck=!0),((this._state&yt.OFFSET)===yt.OFFSET||(this._state&yt.TOUCH_OFFSET)===yt.TOUCH_OFFSET||(this._state&yt.TOUCH_DOLLY_OFFSET)===yt.TOUCH_DOLLY_OFFSET||(this._state&yt.TOUCH_ZOOM_OFFSET)===yt.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(t,a,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},g=()=>{QA(this._activePointers,xo),i.copy(xo),0===this._activePointers.length&&this._domElement&&(this._domElement.removeEventListener("pointermove",o),this._domElement.removeEventListener("mousemove",l),this._domElement.removeEventListener("pointerup",h),this._domElement.removeEventListener("mouseup",c),this.dispatchEvent({type:"controlend"}))};this._addAllEventListeners=e=>{this._domElement=e,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",a),vht&&this._domElement.addEventListener("mousedown",s),this._domElement.addEventListener("pointercancel",h),this._domElement.addEventListener("wheel",d),this._domElement.addEventListener("contextmenu",p)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",a),this._domElement.removeEventListener("mousedown",s),this._domElement.removeEventListener("pointercancel",h),this._domElement.removeEventListener("wheel",d),this._domElement.removeEventListener("contextmenu",p),this._domElement.removeEventListener("pointermove",o),this._domElement.removeEventListener("mousemove",l),this._domElement.removeEventListener("pointerup",h),this._domElement.removeEventListener("mouseup",c))},this.cancel=()=>{this._state!==yt.NONE&&(this._state=yt.NONE,this._activePointers.length=0,g())},t&&this.connect(t),this.update(0)}static install(e){nr=e.THREE,Vfe=Object.freeze(new nr.Vector3(0,0,0)),rC=Object.freeze(new nr.Vector3(0,1,0)),M5=Object.freeze(new nr.Vector3(0,0,1)),xo=new nr.Vector2,ar=new nr.Vector3,bi=new nr.Vector3,ty=new nr.Vector3,Gu=new nr.Vector3,qu=new nr.Vector3,Vm=new nr.Vector3,zfe=new nr.Vector3,Gfe=new nr.Vector3,Ic=new nr.Spherical,cE=new nr.Spherical,ny=new nr.Box3,qfe=new nr.Box3,R5=new nr.Sphere,Wfe=new nr.Quaternion,A5=new nr.Quaternion,C5=new nr.Matrix4,iC=new nr.Raycaster}static get ACTION(){return yt}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,n=!1){this._isUserControllingRotate=!1;let i=Hm(e,this.minAzimuthAngle,this.maxAzimuthAngle),r=Hm(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=i,this._sphericalEnd.phi=r,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);let a=!n||Hi(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Hi(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(a)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){this._isUserControllingDolly=!1;let n=this._sphericalEnd.radius,i=Hm(e,this.minDistance,this.maxDistance);if(this.colliderMeshes.length>=1){let e=this._collisionTest(),t=Hi(e,this._spherical.radius);if(!(n>i)&&t)return Promise.resolve();this._sphericalEnd.radius=Math.min(i,e)}else this._sphericalEnd.radius=i;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);let r=!t||Hi(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=Hm(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);let n=!t||Hi(this._zoom,this._zoomEnd,this.restThreshold);return this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),Gu.setFromMatrixColumn(this._camera.matrix,0),qu.setFromMatrixColumn(this._camera.matrix,1),Gu.multiplyScalar(e),qu.multiplyScalar(-t);let i=ar.copy(Gu).add(qu),r=bi.copy(this._targetEnd).add(i);return this.moveTo(r.x,r.y,r.z,n)}forward(e,t=!1){ar.setFromMatrixColumn(this._camera.matrix,0),ar.crossVectors(this._camera.up,ar),ar.multiplyScalar(e);let n=bi.copy(this._targetEnd).add(ar);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return ar.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+ar.x,this._targetEnd.y+ar.y,this._targetEnd.z+ar.z,t)}moveTo(e,t,n,i=!1){this._isUserControllingTruck=!1;let r=ar.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,r,this.boundaryFriction),this._needsUpdate=!0,i||this._target.copy(this._targetEnd);let a=!i||Hi(this._target.x,this._targetEnd.x,this.restThreshold)&&Hi(this._target.y,this._targetEnd.y,this.restThreshold)&&Hi(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}lookInDirectionOf(e,t,n,i=!1){let r=ar.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius);return this.setPosition(r.x,r.y,r.z,i)}fitToBox(e,t,{cover:n=!1,paddingLeft:i=0,paddingRight:r=0,paddingBottom:a=0,paddingTop:s=0}={}){let o=[],l=e.isBox3?ny.copy(e):ny.setFromObject(e);l.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());let h=w5(this._sphericalEnd.theta,T5),c=w5(this._sphericalEnd.phi,T5);o.push(this.rotateTo(h,c,t));let u=ar.setFromSpherical(this._sphericalEnd).normalize(),d=Wfe.setFromUnitVectors(u,M5),p=Hi(Math.abs(u.y),1);p&&d.multiply(A5.setFromAxisAngle(rC,h)),d.multiply(this._yAxisUpSpaceInverse);let f=qfe.makeEmpty();bi.copy(l.min).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.min).setX(l.max.x).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.min).setY(l.max.y).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.max).setZ(l.min.z).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.min).setZ(l.max.z).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.max).setY(l.min.y).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.max).setX(l.min.x).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.max).applyQuaternion(d),f.expandByPoint(bi),f.min.x-=i,f.min.y-=a,f.max.x+=r,f.max.y+=s,d.setFromUnitVectors(M5,u),p&&d.premultiply(A5.invert()),d.premultiply(this._yAxisUpSpace);let m=f.getSize(ar),g=f.getCenter(bi).applyQuaternion(d);if(Rf(this._camera)){let e=this.getDistanceToFitBox(m.x,m.y,m.z,n);o.push(this.moveTo(g.x,g.y,g.z,t)),o.push(this.dollyTo(e,t)),o.push(this.setFocalOffset(0,0,0,t))}else if(Vu(this._camera)){let e=this._camera,i=e.right-e.left,r=e.top-e.bottom,a=n?Math.max(i/m.x,r/m.y):Math.min(i/m.x,r/m.y);o.push(this.moveTo(g.x,g.y,g.z,t)),o.push(this.zoomTo(a,t)),o.push(this.setFocalOffset(0,0,0,t))}return Promise.all(o)}fitToSphere(e,t){let n=[],i=e instanceof nr.Sphere?R5.copy(e):Af.createBoundingSphere(e,R5);if(n.push(this.moveTo(i.center.x,i.center.y,i.center.z,t)),Rf(this._camera)){let e=this.getDistanceToFitSphere(i.radius);n.push(this.dollyTo(e,t))}else if(Vu(this._camera)){let e=this._camera.right-this._camera.left,r=this._camera.top-this._camera.bottom,a=2*i.radius,s=Math.min(e/a,r/a);n.push(this.zoomTo(s,t))}return n.push(this.setFocalOffset(0,0,0,t)),Promise.all(n)}setLookAt(e,t,n,i,r,a,s=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1;let o=bi.set(i,r,a),l=ar.set(e,t,n);this._targetEnd.copy(o),this._sphericalEnd.setFromVector3(l.sub(o).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,s||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));let h=!s||Hi(this._target.x,this._targetEnd.x,this.restThreshold)&&Hi(this._target.y,this._targetEnd.y,this.restThreshold)&&Hi(this._target.z,this._targetEnd.z,this.restThreshold)&&Hi(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Hi(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Hi(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(h)}lerpLookAt(e,t,n,i,r,a,s,o,l,h,c,u,d,p=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1;let f=ar.set(i,r,a),m=bi.set(e,t,n);Ic.setFromVector3(m.sub(f).applyQuaternion(this._yAxisUpSpace));let g=ty.set(h,c,u),v=bi.set(s,o,l);cE.setFromVector3(v.sub(g).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(f.lerp(g,d));let y=cE.theta-Ic.theta,x=cE.phi-Ic.phi,b=cE.radius-Ic.radius;this._sphericalEnd.set(Ic.radius+b*d,Ic.phi+x*d,Ic.theta+y*d),this.normalizeRotations(),this._needsUpdate=!0,p||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));let _=!p||Hi(this._target.x,this._targetEnd.x,this.restThreshold)&&Hi(this._target.y,this._targetEnd.y,this.restThreshold)&&Hi(this._target.z,this._targetEnd.z,this.restThreshold)&&Hi(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Hi(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Hi(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(_)}setPosition(e,t,n,i=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,i)}setTarget(e,t,n,i=!1){let r=this.getPosition(ar),a=this.setLookAt(r.x,r.y,r.z,e,t,n,i);return this._sphericalEnd.phi=Hm(this.polarAngle,this.minPolarAngle,this.maxPolarAngle),a}setFocalOffset(e,t,n,i=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,i||this._focalOffset.copy(this._focalOffsetEnd);let r=!i||Hi(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Hi(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Hi(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),Gu.setFromMatrixColumn(this._camera.matrixWorldInverse,0),qu.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Vm.setFromMatrixColumn(this._camera.matrixWorldInverse,2);let i=ar.set(e,t,n),r=i.distanceTo(this._camera.position),a=i.sub(this._camera.position);Gu.multiplyScalar(a.x),qu.multiplyScalar(a.y),Vm.multiplyScalar(a.z),ar.copy(Gu).add(qu).add(Vm),ar.z=ar.z+r,this.dollyTo(r,!1),this.setFocalOffset(-ar.x,ar.y,-ar.z,!1),this.moveTo(e,t,n,!1)}setBoundary(e){if(!e)return this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),void(this._needsUpdate=!0);this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,n,i){null!==e?(this._viewport=this._viewport||new nr.Vector4,"number"==typeof e?this._viewport.set(e,t,n,i):this._viewport.copy(e)):this._viewport=null}getDistanceToFitBox(e,t,n,i=!1){if(eC(this._camera,"getDistanceToFitBox"))return this._spherical.radius;let r=e/t,a=this._camera.getEffectiveFOV()*Jv,s=this._camera.aspect;return.5*((i?r>s:rt.pointerId===e))}_findPointerByMouseButton(e){return this._activePointers.find((t=>t.mouseButton===e))}_encloseToBoundary(e,t,n){let i=t.lengthSq();if(0===i)return e;let r=bi.copy(t).add(e),a=this._boundary.clampPoint(r,ty).sub(r),s=a.lengthSq();if(0===s)return e.add(t);if(s===i)return e;if(0===n)return e.add(t).add(a);{let i=1+n*s/t.dot(a);return e.add(bi.copy(t).multiplyScalar(i)).add(a.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(Rf(this._camera)){let e=this._camera,t=e.near,n=e.getEffectiveFOV()*Jv,i=Math.tan(.5*n)*t,r=i*e.aspect;this._nearPlaneCorners[0].set(-r,-i,0),this._nearPlaneCorners[1].set(r,-i,0),this._nearPlaneCorners[2].set(r,i,0),this._nearPlaneCorners[3].set(-r,i,0)}else if(Vu(this._camera)){let e=this._camera,t=1/e.zoom,n=e.left*t,i=e.right*t,r=e.top*t,a=e.bottom*t;this._nearPlaneCorners[0].set(n,r,0),this._nearPlaneCorners[1].set(i,r,0),this._nearPlaneCorners[2].set(i,a,0),this._nearPlaneCorners[3].set(n,a,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||eC(this._camera,"_collisionTest"))return e;let t=ar.setFromSpherical(this._spherical).divideScalar(this._spherical.radius);C5.lookAt(Vfe,t,this._camera.up);for(let n=0;n<4;n++){let i=bi.copy(this._nearPlaneCorners[n]);i.applyMatrix4(C5);let r=ty.addVectors(this._target,i);iC.set(r,t),iC.far=this._spherical.radius+1;let a=iC.intersectObjects(this.colliderMeshes);0!==a.length&&a[0].distance{let t=()=>{this.removeEventListener("rest",t),e()};this.addEventListener("rest",t)})))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new nr.Sphere){let n=t,i=n.center;ny.makeEmpty(),e.traverseVisible((e=>{e.isMesh&&ny.expandByObject(e)})),ny.getCenter(i);let r=0;return e.traverseVisible((e=>{if(!e.isMesh)return;let t=e,n=t.geometry.clone();if(n.applyMatrix4(t.matrixWorld),n.isBufferGeometry){let e=n.attributes.position;for(let t=0,n=e.count;t{if(this.enabled){switch(e.code){case this.keys.up:e.ctrlKey||e.metaKey||e.shiftKey?(this._rotateInternal(0,1),this._isUserControllingRotate=!0):(this._truckInternal(0,this.keyTruckSpeed,!1),this._isUserControllingTruck=!0);break;case this.keys.bottom:e.ctrlKey||e.metaKey||e.shiftKey?(this._rotateInternal(0,-1),this._isUserControllingRotate=!0):(this._truckInternal(0,-this.keyTruckSpeed,!1),this._isUserControllingTruck=!0);break;case this.keys.left:e.ctrlKey||e.metaKey||e.shiftKey?(this._rotateInternal(1,0),this._isUserControllingRotate=!0):(this._truckInternal(this.keyTruckSpeed,0,!1),this._isUserControllingTruck=!0);break;case this.keys.right:e.ctrlKey||e.metaKey||e.shiftKey?(this._rotateInternal(-1,0),this._isUserControllingRotate=!0):(this._truckInternal(-this.keyTruckSpeed,0,!1),this._isUserControllingTruck=!0)}this.dispatchEvent({type:"control"})}},this.onKeyUp=e=>{this.dispatchEvent({type:"controlend"})},this._getClientRect(this._elementRect),this.dollySpeedBackup=this.dollySpeed,this.azimuthRotateSpeedBackup=this.azimuthRotateSpeed,this.polarRotateSpeedBackup=this.polarRotateSpeed,this.truckSpeedBackup=this.truckSpeed}get enableZoom(){return!!this.dollySpeed}set enableZoom(e){e?this.dollySpeed=this.dollySpeedBackup:(this.dollySpeedBackup=this.dollySpeed,this.dollySpeed=0)}get enableRotate(){return!!this.azimuthRotateSpeed||!!this.polarRotateSpeed}set enableRotate(e){e?(this.azimuthRotateSpeed=this.azimuthRotateSpeedBackup,this.polarRotateSpeed=this.polarRotateSpeedBackup):(this.azimuthRotateSpeedBackup=this.azimuthRotateSpeed,this.polarRotateSpeedBackup=this.polarRotateSpeed,this.azimuthRotateSpeed=0,this.polarRotateSpeed=0)}get enableTruck(){return!!this.truckSpeed}set enableTruck(e){e?this.truckSpeed=this.truckSpeedBackup:(this.truckSpeedBackup=this.truckSpeed,this.truckSpeed=0)}listenToKeyEvents(){var e,t;null==(e=this._domElement)||e.addEventListener("keydown",this.onKeyDown),null==(t=this._domElement)||t.addEventListener("keyup",this.onKeyUp)}stopListenToKeyEvents(){var e,t;null==(e=this._domElement)||e.removeEventListener("keydown",this.onKeyDown),null==(t=this._domElement)||t.removeEventListener("keyup",this.onKeyUp)}dispose(){super.dispose(),this.stopListenToKeyEvents()}},kl=class{constructor(e){this.name=e}},sC=class{constructor(e){this.history=[],this.step=0,this.maxCount=50,this.isBatchCommand=!1,this.batchCommands=[],this.maxCount=e||this.maxCount}addCommand(e){this.isBatchCommand?this.batchCommands.push(e):(this.history.length===this.maxCount&&this.history.shift(),this.step!==this.history.length&&this.history.splice(this.step),this.history.push(e),this.step++)}startTransaction(){this.isBatchCommand=!0}endTransaction(){this.history.length===this.maxCount&&this.history.shift(),this.step!==this.history.length&&this.history.splice(this.step),this.batchCommands.length>0&&(this.history.push(this.batchCommands.slice()),this.step++),this.isBatchCommand=!1,this.batchCommands=[]}undo(){if(this.canUndo())return!1;this.step--;let e=this.history[this.step];return e&&(Array.isArray(e)?e.forEach((e=>e.undo())):e.undo()),!0}redo(){if(this.canRedo())return!1;this.step++;let e=this.history[this.step-1];return e&&(Array.isArray(e)?e.forEach((e=>e.redo())):e.redo()),!0}getCommands(){return this.history}canUndo(){return this.step<=0}canRedo(){return this.step>=this.history.length}clear(){this.history=[],this.step=0}destroy(){this.clear(),this.maxCount=0}},uE=class extends kl{constructor(e,t){super("AddMarkup"),this.manager=e,this.data=t}undo(){let e=this.manager.getMarkupById(this.data.id);return!!e&&(this.manager.removeMarkup(e),!0)}redo(){let e=this.manager.createMarkup(this.data);return!!e&&(this.manager.addMarkup(e),!0)}},aC=class extends kl{constructor(e,t,n){super("UpdateMarkup"),this.manager=e,this.oldData=t,this.newData=n}undo(){let e=this.manager.getMarkupById(this.oldData.id);return!!e&&(this.manager.updateMarkup(e,this.oldData),!0)}redo(){let e=this.manager.getMarkupById(this.newData.id);return!!e&&(this.manager.updateMarkup(e,this.newData),!0)}},zm=class extends kl{constructor(e,t){super("RemoveMarkup"),this.manager=e,this.data=t}undo(){let e=this.manager.createMarkup(this.data);return!!e&&(this.manager.addMarkup(e),!0)}redo(){let e=this.manager.getMarkupById(this.data.id);return!!e&&(this.manager.removeMarkup(e),!0)}},hE=class extends kl{constructor(e,t){super("AddMeasurement"),this.manager=e,this.data=t}undo(){let e=this.manager.getById(this.data.id);return!!e&&(this.manager.remove(e),!0)}redo(){let e=this.manager.create(this.data);return!!e&&(this.manager.add(e),!0)}},ry=class extends kl{constructor(e,t){super("RemoveMeasurement"),this.manager=e,this.data=t}undo(){let e=this.manager.create(this.data);return!!e&&(this.manager.add(e),!0)}redo(){let e=this.manager.getById(this.data.id);return!!e&&(this.manager.remove(e),!0)}},jfe=new O,dE=class extends cs{constructor(e,t){var n;super(),this.drawableList=new Ko("markup"),this.lineWidth=2,this.lineColor=[1,0,0,1],this.fillColor=[1,0,0,.3],this.fontSize=20,this.mouseDown=!1,this.mouseDownPositionX=void 0,this.mouseDownPositionY=void 0,this.isSelectLeaderText=!1,this.isDrawing=!1,this.tempPoints=[],this.activated=!1,this.handleDbClick=()=>{},this.handleInputMousemove=e=>{if(!this.mouseDown&&"CloudRectWithTextMarkup"===this.type&&this.isDrawing&&this.creatingShape){let t=un.getScreenPointByEvent(e,this.viewerCanvas);this.creatingShape.updateInputPosition(this.mousedownPoint,t),this.render()}},this.mousedown=e=>{var t;if(e.pointers&&e.pointers.length>1)return;let n=this.pickThreejsPositionByMouse(e);if(n){if(this.mouseDownPositionX=n.x,this.mouseDownPositionY=n.y,this.mousedownPoint=new be(e.x,e.y),0===e.button&&(this.mouseDown=!0),2===e.button)return void(this.isDrawing&&this.endDraw(this.creatingShape));if(this.selectedShape&&(this.selectedShape.selected=!1,this.selectedShape=void 0,this.render()),!this.isDrawing){let e=this.drawableList.getDrawableByPosition(n);e&&(this.selectedShape=e,e.selected=!0,e instanceof Bm&&(this.isSelectLeaderText=e.isLeaderTextSelected(n)),this.render())}if(this.isCreateTextMode()&&this.mouseDown&&!this.selectedShape){this.creatingShape||(this.creatingShape=this.drawText(n,""));let t=this.creatingShape;0===t.text.length?(t.setTolerance(this.viewer.getPixelSizeInWorldCoord()),t.update([n]),t.addInput(this,e.x,e.y)):(t.exitEditing(),this.addMarkup(t,!1),this.endDraw(t)),this.render()}if(this.isCreateLineMode()&&this.mouseDown&&!this.selectedShape){if(this.tempPoints.length>0){let e=this.tempPoints[0];if(jfe.subVectors(e,n).length()<5*this.viewer.getPixelSizeInWorldCoord())return n=this.tempPoints[0].clone(),this.tempPoints.push(n),void this.endDraw(this.creatingShape)}if(this.isDrawing=!0,this.tempPoints.push(n),!this.creatingShape){let e=this.creatingShape=this.drawLine([...this.tempPoints,n]);e&&this.addMarkup(e,!1)}this.creatingShape&&(this.creatingShape.update([...this.tempPoints,n]),this.render()),this.dispatchEvent("StartDraw",this.creatingShape)}if(this.isCreateDotMode()&&this.mouseDown&&!this.selectedShape){if(!this.creatingShape){let e=this.creatingShape=this.drawShape(n);e&&this.addMarkup(e,!1)}this.isDrawing=!0,this.render()}null==(t=this.creatingShape)||t.setTolerance(this.viewer.getPixelSizeInWorldCoord())}},this.mousemove=e=>{if(e.pointers&&e.pointers.length>1)return;let t=this.pickThreejsPositionByMouse(e);if(t)if(this.selectedShape){if(this.mouseDown&&void 0!==this.mouseDownPositionX&&void 0!==this.mouseDownPositionY){this.isEditing()||(this.initialDataForEditing=this.selectedShape.getData());let e=t.x-this.mouseDownPositionX,n=t.y-this.mouseDownPositionY;this.selectedShape instanceof Bm&&this.isSelectLeaderText?this.selectedShape.translateLeaderText(e,n):this.selectedShape.translate(e,n),this.render(),this.mouseDownPositionX=t.x,this.mouseDownPositionY=t.y}}else{if(this.isCreateDotMode())return;if(this.mouseDown&&this.isCreateShapeMode()&&void 0!==this.mouseDownPositionX&&void 0!==this.mouseDownPositionY){let e=new O(this.mouseDownPositionX,this.mouseDownPositionY,0);if(!this.creatingShape){let n=this.creatingShape=this.drawShape(e,t);n&&this.addMarkup(n,!1)}this.creatingShape.update([e,t]),this.isDrawing=!0,this.render()}if(this.isCreateLineMode()&&this.tempPoints.length>0&&this.isDrawing){let e=this.tempPoints[0];jfe.subVectors(e,t).length()<5*this.viewer.getPixelSizeInWorldCoord()&&(t=this.tempPoints[0].clone()),this.creatingShape.update([...this.tempPoints,t]),this.render()}}},this.mouseup=e=>{if(this.mouseDown=!1,this.selectedShape&&this.isEditing()&&this.endEdit(this.selectedShape),this.isCreateShapeMode()&&this.isDrawing&&this.creatingShape)if("LeaderLineMarkup"===this.type){let t=this.creatingShape;t.isEditing?t.exitEditing():(t.setFontSize(this.fontSize*this.viewer.getPixelSizeInWorldCoord()),t.addInput(this,e.x,e.y)),t.addEventListener("ExitEditing",(()=>{this.isDrawing=!1,this.endDraw(this.creatingShape)}))}else if("CloudRectWithTextMarkup"===this.type){let t=this.creatingShape;t.setFontSize(this.fontSize*this.viewer.getPixelSizeInWorldCoord()),t.addInput(this,e.x,e.y),t.addEventListener("ExitEditing",(()=>{this.isDrawing=!1,this.endDraw(this.creatingShape)}))}else this.endDraw(this.creatingShape)},this.keydown=e=>{var t;"Delete"===e.code?this.selectedShape&&(this.viewer.hasEventListener("BeforeRemoveMarkup")?this.viewer.dispatchEvent("BeforeRemoveMarkup",this.confirmToRemove.bind(this)):(this.removeMarkup(this.selectedShape),null==(t=this.viewer.undoRedoManager)||t.addCommand(new zm(this,this.selectedShape.getData())),this.selectedShape=void 0)):"Escape"===e.code&&this.cancelDraw(this.creatingShape)},this.viewer=e,this.inputManager=t,this.overlayRender=this.viewer.overlayRender,null==(n=this.overlayRender)||n.addDrawableList(this.drawableList)}get viewerCanvas(){var e;return null==(e=this.viewer.renderer)?void 0:e.domElement}get camera(){return this.viewer.camera}get raycaster(){return this.viewer.getRaycaster()}setMarkupVisibility(e,t){let n=this.drawableList.getDrawables().get(e);return!!n&&(n.visible!==t&&(n.visible=t,this.render()),!0)}setMarkupsVisibility(e){let t=!1;this.drawableList.getDrawables().forEach((n=>{n.visible!==e&&(n.visible=e,t=!0)})),t&&this.render()}clearAll(){this.drawableList.clear(),this.isDrawing&&this.reset(),this.render()}isMarkupActive(){return this.activated}createMobileExitButton(){let e=this.viewer.widgetContainer,t=document.createElement("button");return t.innerText="X",t.style.cssText="position: absolute;right: 5%; top: 5%;background-color: #000000;color: #ffffff;padding: 3px 10px;font-weight: bolder;",null==e||e.appendChild(t),this.exitButton=t,this.exitButton.style.display="none",t.addEventListener("touchstart",(()=>{this.isDrawing&&this.endDraw(this.creatingShape),this.exitButton&&(this.exitButton.style.display="none")})),this.addEventListener("StartDraw",(()=>{this.exitButton&&(this.exitButton.style.display="inline")})),this.addEventListener("EndDraw",(()=>{this.exitButton&&(this.exitButton.style.display="none")})),this.exitButton}activate(){this.activated=!0,Dn.isMobile?(this.inputManager.addEventListener("touchstart",this.mousedown),this.inputManager.addEventListener("touchmove",this.mousemove),this.inputManager.addEventListener("touchend",this.mouseup)):(this.inputManager.addEventListener("mousedown",this.mousedown),this.inputManager.addEventListener("mousemove",this.mousemove),this.inputManager.addEventListener("mouseup",this.mouseup),this.inputManager.addEventListener("dblclick",this.handleDbClick)),this.inputManager.addEventListener("keydown",this.keydown),window.addEventListener("mousemove",this.handleInputMousemove);let e=this.viewer.controls;this.tempKey=e.mouseButtons.left,e.mouseButtons.left=yt.NONE,this.tempTouch=e.touches.one,e.touches.one=yt.NONE,this.tempArrowKeys=e.keys,e.keys={},this.render()}deactivate(){this.activated=!1,Dn.isMobile?(this.inputManager.removeEventListener("touchstart",this.mousedown),this.inputManager.removeEventListener("touchmove",this.mousemove),this.inputManager.removeEventListener("touchend",this.mouseup)):(this.inputManager.removeEventListener("mousedown",this.mousedown),this.inputManager.removeEventListener("mousemove",this.mousemove),this.inputManager.removeEventListener("mouseup",this.mouseup),this.inputManager.removeEventListener("dblclick",this.handleDbClick)),this.inputManager.removeEventListener("keydown",this.keydown),window.removeEventListener("mousemove",this.handleInputMousemove),this.viewer.controls.mouseButtons.left=this.tempKey,this.viewer.controls.keys=this.tempArrowKeys,this.viewer.controls.touches.one=this.tempTouch,this.mouseDown=!1,this.tempPoints=[],this.isDrawing=!1,this.creatingShape=void 0,this.selectedShape&&(this.selectedShape.selected=!1,this.selectedShape=void 0),this.render()}getActiveMarkupType(){return this.type}setDrawType(e){this.type=e,this.reset()}setLineWidth(e){this.lineWidth=e}getLineWidth(){return this.lineWidth}setLineColor(e){this.lineColor=e}getLineColor(){return this.lineColor}setFillColor(e){this.fillColor=e}getFillColor(){return this.fillColor}setFontSize(e){this.fontSize=e}getFontSize(){return this.fontSize}pickPositionByScreenPoint(e){let t,n=un.screenPoint2NdcPoint(e,this.camera,this.viewerCanvas);this.raycaster.layers.set(10),this.raycaster.setFromCamera(n,this.camera);let i=this.viewer.scene,r=this.raycaster.intersectObject(this.viewer.groundPlane||i)||[];return r.length>0&&(t=r[0].point),t}pickThreejsPositionByMouse(e){return this.pickPositionByScreenPoint(new be(e.x,e.y))}confirmToRemove(e){var t;this.selectedShape&&e&&(this.removeMarkup(this.selectedShape),null==(t=this.viewer.undoRedoManager)||t.addCommand(new zm(this,this.selectedShape.getData())),this.selectedShape=void 0)}isEditing(){return!!this.initialDataForEditing}endEdit(e){var t;if(!this.initialDataForEditing)return;let n=e.getData();this.viewer.dispatchEvent("MarkupUpdated",{oldData:this.initialDataForEditing,newData:n}),this.dispatchEvent("EndEdit",e),null==(t=this.viewer.undoRedoManager)||t.addCommand(new aC(this,this.initialDataForEditing,n)),this.initialDataForEditing=void 0,this.isSelectLeaderText=!1}endDraw(e){var t;if("PolylineMarkup"===this.type&&this.creatingShape&&(this.tempPoints.length<2?(this.removeMarkup(this.creatingShape,!1),this.creatingShape=void 0):this.creatingShape.update(this.tempPoints)),e){let n=e.getData();this.viewer.dispatchEvent("MarkupAdded",n),null==(t=this.viewer.undoRedoManager)||t.addCommand(new uE(this,n))}this.dispatchEvent("EndDraw",e),this.reset()}cancelDraw(e){e&&this.removeMarkup(e,!1),this.reset()}reset(){this.tempPoints=[],this.isDrawing=!1,this.creatingShape=void 0,this.mouseDownPositionX=void 0,this.mouseDownPositionY=void 0,this.mousedownPoint=void 0,this.isSelectLeaderText=!1,this.selectedShape&&(this.selectedShape.selected=!1,this.selectedShape=void 0),this.render()}render(){var e;null==(e=this.overlayRender)||e.render()}addMarkup(e,t=!0){this.drawableList.addDrawable(e),this.render(),t&&this.viewer.dispatchEvent("MarkupAdded",e.getData())}updateMarkup(e,t,n=!0){this.drawableList.updateDrawable(e,t),this.render(),n&&this.viewer.dispatchEvent("MarkupUpdated",{oldData:e.getData(),newData:t})}removeMarkup(e,t=!0){this.drawableList.removeDrawable(e),this.render(),t&&this.viewer.dispatchEvent("MarkupRemoved",e.getData())}removeMarkupById(e){let t=this.getMarkupById(e);return!!t&&(this.removeMarkup(t,!1),!0)}createMarkup(e){return Hn.createDrawable(e)}getMarkupById(e){return this.drawableList.getDrawableById(e)}getMarkupData(){return this.drawableList.getDrawableDatas()}setMarkupData(e){var t,n;null==(t=this.viewer.undoRedoManager)||t.startTransaction(),e.forEach((e=>{var t;this.addMarkup(this.createMarkup(e)),null==(t=this.viewer.undoRedoManager)||t.addCommand(new uE(this,e))})),null==(n=this.viewer.undoRedoManager)||n.endTransaction(),this.render()}isCreateLineMode(){return["PolylineMarkup","CloudLineMarkup"].includes(this.type)}isCreateDotMode(){return["DotMarkup"].includes(this.type)}isCreateTextMode(){return["TextMarkup"].includes(this.type)}isCreateShapeMode(){return["XMarkup","RectMarkup","CloudRectMarkup","CircleMarkup","EllipseMarkup","ArrowMarkup","LeaderLineMarkup","CloudRectWithTextMarkup","DotMarkup"].includes(this.type)}drawShape(e,t){let n=[[e.x,e.y]];return t&&n.push([t.x,t.y]),Hn.createDrawable({id:Mt.guid(),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,type:this.type,points:n})}drawLine(e){return Hn.createDrawable({id:Mt.guid(),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,type:this.type,points:e.map((e=>[e.x,e.y]))})}drawText(e,t){return Hn.createDrawable({id:Mt.guid(),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,fontSize:this.fontSize*this.viewer.getPixelSizeInWorldCoord(),type:this.type,text:t,points:[[e.x,e.y]]})}destroy(){this.deactivate(),this.clearAll()}},Xfe=new O,Gm=class extends Bi{constructor(e,t){super(e),this.lineSegments=[],this.boxes=t,this.lineColor=[1,0,0,1],this.lineWidth=2,this.calculateCloudLineSegments(t)}calculateCloudLineSegments(e){var t;for(let n=0;n(e[e.Mesh=-1]="Mesh",e[e.MeshWithPattern=0]="MeshWithPattern",e[e.LineWithWidth=1]="LineWithWidth",e[e.Line=2]="Line",e[e.LineWithPattern=3]="LineWithPattern",e[e.Point=4]="Point",e[e.Text=5]="Text",e))(Yfe||{}),qm=["INSERT","DIMENSION"],tVt=ji(Qfe(),1),oC=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215],ay=class{constructor(){this.pointer=0,this.eof=!1}},L5=ji(epe(),1),Cf=class{constructor(e,t){this.endian=t&&"big"===t?"big":"little",this.position=0,this.data=new DataView(e)}readAsciiString(e){if(this.data.byteLength=0&&e<=9)return this.readNullTerminatedString();if(e>=10&&e<=59)return this.reader.readFloat64();if(e>=60&&e<=79)return this.reader.readInt16();if(e>=90&&e<=99)return this.reader.readInt32();if(e>=100&&e<=109)return this.readNullTerminatedString();if(e>=110&&e<=149)return this.reader.readFloat64();if(e>=160&&e<=169)return this.reader.readInt64();if(e>=170&&e<=179)return this.reader.readInt16();if(e>=210&&e<=239)return this.reader.readFloat64();if(e>=270&&e<=289)return this.reader.readInt16();if(e>=290&&e<=299)return this.reader.readInt8()>0;if(e>=300&&e<=309)return this.readNullTerminatedString();if(e>=310&&e<=319)return npe(this.ReadBinaryData());if(e>=320&&e<=369)return this.readNullTerminatedString();if(e>=370&&e<=389)return this.reader.readInt16();if(e>=390&&e<=399)return this.readNullTerminatedString();if(e>=400&&e<=409)return this.reader.readInt16();if(e>=410&&e<=419)return this.readNullTerminatedString();if(e>=420&&e<=429)return this.reader.readInt32();if(e>=430&&e<=439)return this.readNullTerminatedString();if(e>=440&&e<=459)return this.reader.readInt32();if(e>=460&&e<=469)return this.reader.readFloat64();if(e>=470&&e<=481)return this.readNullTerminatedString();if(999===e)throw new Error("The comment group 999, is not used in binary DXF files at byte address!");return 1004===e?npe(this.ReadBinaryData()):e>=1e3&&e<=1009?this.readNullTerminatedString():e>=1010&&e<=1059?this.reader.readFloat64():e>=1060&&e<=1070?this.reader.readInt16():1071===e?this.reader.readInt32():void se.warn(`[DxfBinReader] Invalid code '${e}' at byte address ${this.reader.getPosition()}`)}readNullTerminatedString(){var e;this.decoder||(this.decoder=new TextDecoder("utf-8"));let t=0,n=this.reader.readInt8();for(;0!==n;)this.int8Array[t++]=n,n=this.reader.readInt8();if(0===t)return"";if(t>tpe)return se.warn(`[DxfBinReader] Failed to read string! The number of bytes is ${t} !`),"";let i=this.int8Array.subarray(0,t),r=i.toString();if(this.caches.get(r))return this.caches.get(r);let a=null==(e=this.decoder)?void 0:e.decode(i);return this.caches.set(r,a),a}ReadBinaryData(){let e=this.reader.readUint8();return this.reader.readBytes(e)}};function npe(e){return Array.prototype.map.call(e,(e=>("00"+e.toString(16)).slice(-2))).join("")}var oy=class extends ay{constructor(e){super(),this.data=e}next(){if(!this.hasNext())throw this.eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this.data[this.pointer]);let e={code:parseInt(this.data[this.pointer])};return this.pointer++,e.value=xht(e.code,this.data[this.pointer].trim()),this.pointer++,0===e.code&&"EOF"===e.value&&(this.eof=!0),this.lastReadGroup=e,e}hasNext(){return!(this.eof||this.pointer>this.data.length-2)}isEOF(){return this.eof}};function xht(e,t){return e>=0&&e<=9?t:e>=10&&e<=59?parseFloat(t):e>=60&&e<=99?parseInt(t):e>=100&&e<=109?t:e>=110&&e<=149?parseFloat(t):e>=160&&e<=179?parseInt(t):e>=210&&e<=239?parseFloat(t):e>=270&&e<=289?parseInt(t):e>=290&&e<=299?bht(t):e>=300&&e<=369?t:e>=370&&e<=389?parseInt(t):e>=390&&e<=399?t:e>=400&&e<=409?parseInt(t):e>=410&&e<=419?t:e>=420&&e<=429?parseInt(t):e>=430&&e<=439?t:e>=440&&e<=459?parseInt(t):e>=460&&e<=469?parseFloat(t):e>=470&&e<=481||999===e||e>=1e3&&e<=1009?t:e>=1010&&e<=1059?parseFloat(t):e>=1060&&e<=1071?parseInt(t):(se.info("WARNING: Group code does not have a defined type: %j",{code:e,value:t}),t)}function bht(e){if("0"===e)return!1;if("1"===e)return!0;throw TypeError("String '"+e+"' cannot be cast to Boolean type")}var spe=ji(Fl(),1),Eht="OriginalHandle",_ht="OriginalType",Tht="Outlines",rpe=["PROXY","REGION","INSERT","HATCH"];function Wm(e){return oC[e]}function Ft(e){let t={},n=e.lastReadGroup,i=n.code;if(t.x=n.value,i+=10,n=e.next(),n.code!=i)throw new Error(`Expected code for point value to be ${i} but got ${n.code}`);return t.y=n.value,i+=10,n=e.next(),n.code!=i||(t.z=n.value,e.next()),t}function ipe(e,t){let n=e.lastReadGroup,i=[];for(let r=0;r<16;r++){if(n.code!==t)throw new Error(`Expected code for matrix value to be ${t} but got ${n.code}`);i.push(n.value),n=e.next()}return i}function Bn(e,t){switch(t.code){case 0:e.type=t.value;break;case 5:e.handle=t.value;break;case 6:e.lineType=t.value.toUpperCase();break;case 8:e.layer=t.value;break;case 48:e.lineTypeScale=t.value,e.lineTypeScale<=0&&(e.lineTypeScale=1);break;case 60:e.visible=0===t.value;break;case 62:e.isTrueColor||(e.colorIndex=t.value,e.colorIndex<0&&se.warn("[DxfParser] a negative value of colorIndex indicates that the layer is turned off"),e.color=Wm(Math.abs(t.value)));break;case 67:e.inPaperSpace=0!==t.value;break;case 100:case 1001:break;case 330:e.ownerHandle=t.value;break;case 347:e.materialObjectHandle=t.value;break;case 370:e.lineweight=t.value;break;case 410:e.layoutName=t.value;break;case 420:e.isTrueColor=!0,e.color=t.value;break;case 1e3:if(t.value&&t.value.includes(Eht)){let n=t.value.split(":").map((e=>e.trim()));e.extendedData||(e.extendedData={}),e.extendedData.originalHandle=n[1]}if(e.extendedData&&e.extendedData.outlines)try{e.extendedData.outlines=JSON.parse(t.value||"[]")}catch(t){e.extendedData.outlines=void 0}if(t.value&&t.value.includes(Tht)&&(e.extendedData||(e.extendedData={}),e.extendedData.outlines=[]),t.value&&t.value.includes(_ht)){let n=t.value.split(":").map((e=>e.trim()));e.extendedData||(e.extendedData={}),e.extendedData.originalType=n[1]}break;default:return!1}return!0}function Nl(e,t){switch(t.code){case 0:e.type=t.value;break;case 5:e.handle=t.value;break;case 330:e.ownerHandle=t.value;break;case 1e3:case 1001:break;default:return!1}return!0}var gE=class{constructor(){this.ForEntityName="3DFACE"}parseEntity(e,t){let n={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 70:if(0!==t.value){let e=Math.log2(t.value)-1;n.vertices.splice(e,1)}t=e.next();break;case 10:n.vertices=wht(e,t),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}return n}};function wht(e,t){let n=[],i=!1,r=!1;for(let a=0;a<=4;a++){let a={};for(;!e.isEOF()&&0!==t.code&&!r;){switch(t.code){case 10:case 11:case 12:case 13:if(i){r=!0;continue}a.x=t.value,i=!0;break;case 20:case 21:case 22:case 23:a.y=t.value;break;case 30:case 31:case 32:case 33:a.z=t.value;break;default:return n}t=e.next()}(0,spe.isEmpty)(a)||n.push(a),i=!1,r=!1}return n}var vE=class{constructor(){this.ForEntityName="ARC"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.center=Ft(e),t=e.lastReadGroup;break;case 40:n.radius=t.value,t=e.next();break;case 50:n.startAngle=Math.PI/180*t.value,t=e.next();break;case 51:n.endAngle=Math.PI/180*t.value,n.angleLength=n.endAngle-n.startAngle,t=e.next();break;case 210:n.extrusionDirectionX=t.value,t=e.next();break;case 220:n.extrusionDirectionY=t.value,t=e.next();break;case 230:n.extrusionDirectionZ=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}return n}},yE=class{constructor(){this.ForEntityName="ATTDEF"}parseEntity(e,t){let n={type:t.value,xScale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 1:n.text=t.value,t=e.next();break;case 2:n.tag=t.value,t=e.next();break;case 3:n.prompt=t.value,t=e.next();break;case 7:n.textStyle=t.value,t=e.next();break;case 10:n.startPoint=Ft(e),t=e.lastReadGroup;break;case 11:n.endPoint=Ft(e),t=e.lastReadGroup;break;case 39:n.thickness=t.value,t=e.next();break;case 40:n.textHeight=t.value,t=e.next();break;case 41:n.xScale=t.value,t=e.next();break;case 50:n.rotation=t.value,t=e.next();break;case 51:n.obliqueAngle=t.value,t=e.next();break;case 70:n.invisible=!!(1&t.value),n.constant=!!(2&t.value),n.verificationRequired=!!(4&t.value),n.preset=!!(8&t.value),t=e.next();break;case 71:n.backwards=!!(2&t.value),n.mirrored=!!(4&t.value),t=e.next();break;case 72:n.horizontalJustification=t.value,t=e.next();break;case 73:n.fieldLength=t.value,t=e.next();break;case 74:n.verticalJustification=t.value,t=e.next();break;case 100:t=e.next();break;case 210:n.extrusionDirectionX=t.value,t=e.next();break;case 220:n.extrusionDirectionY=t.value,t=e.next();break;case 230:n.extrusionDirectionZ=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}return n}},xE=class{constructor(){this.ForEntityName="ATTRIB"}parseEntity(e,t){let n={type:t.value,xScale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 1:n.text=t.value,t=e.next();break;case 2:n.tag=t.value,t=e.next();break;case 3:n.prompt=t.value,t=e.next();break;case 7:n.textStyle=t.value,t=e.next();break;case 10:n.startPoint=Ft(e),t=e.lastReadGroup;break;case 11:n.endPoint=Ft(e),t=e.lastReadGroup;break;case 39:n.thickness=t.value,t=e.next();break;case 40:n.textHeight=t.value,t=e.next();break;case 41:n.xScale=t.value,t=e.next();break;case 50:n.rotation=t.value,t=e.next();break;case 51:n.obliqueAngle=t.value,t=e.next();break;case 70:n.invisible=!!(1&t.value),n.constant=!!(2&t.value),n.verificationRequired=!!(4&t.value),n.preset=!!(8&t.value),t=e.next();break;case 71:n.backwards=!!(2&t.value),n.mirrored=!!(4&t.value),t=e.next();break;case 72:n.horizontalJustification=t.value,t=e.next();break;case 73:n.fieldLength=t.value,t=e.next();break;case 74:n.verticalJustification=t.value,t=e.next();break;case 100:t=e.next();break;case 210:n.extrusionDirectionX=t.value,t=e.next();break;case 220:n.extrusionDirectionY=t.value,t=e.next();break;case 230:n.extrusionDirectionZ=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}return n}},bE=class{constructor(){this.ForEntityName="CIRCLE"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.center=Ft(e),t=e.lastReadGroup;break;case 40:n.radius=t.value,t=e.next();break;case 50:n.startAngle=Math.PI/180*t.value,t=e.next();break;case 51:let i=Math.PI/180*t.value;i=0&&n.push({angle:e,origin:r,delta:a,dashPattern:o})}return n}function Cht(e,t){let n=[],i=t.next();for(;n.length0&&(n.colorIndex=t.value,n.color=Wm(Math.abs(t.value))))}t=e.next();break;default:Bn(n,t),t=e.next()}return n}};function Pht(e){switch(e){case 40:return"DIMSCALE";case 41:return"DIMASZ";case 42:return"DIMEXO";case 44:return"DIMEXE";case 75:return"DIMSE1";case 76:return"DIMSE2";case 77:return"DIMTAD";case 140:return"DIMTXT";case 144:return"DIMLFAC";case 147:return"DIMGAP";case 176:return"DIMCLRD";case 178:return"DIMCLRT";case 271:return"DIMDEC";case 341:return"DIMLDRBLK";default:return null}}var RE=class{constructor(){this.ForEntityName="LINE"}parseEntity(e,t){let n={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.vertices.unshift(Ft(e)),t=e.lastReadGroup;break;case 11:n.vertices.push(Ft(e)),t=e.lastReadGroup;break;case 210:n.extrusionDirection=Ft(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}return n}},AE=class{constructor(){this.ForEntityName="LWPOLYLINE"}parseEntity(e,t){let n={type:t.value,vertices:[]},i=0;for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 38:n.elevation=t.value,t=e.next();break;case 39:n.thickness=t.value,t=e.next();break;case 70:n.shape=1==(1&t.value),n.hasContinuousLinetypePattern=128==(128&t.value),t=e.next();break;case 90:i=t.value,t=e.next();break;case 10:n.vertices.push(...Iht(i,e)),t=e.lastReadGroup;break;case 43:0!==t.value&&(n.constantWidth=t.value),t=e.next();break;case 210:n.extrusionDirectionX=t.value,t=e.next();break;case 220:n.extrusionDirectionY=t.value,t=e.next();break;case 230:n.extrusionDirectionZ=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}return n}};function Iht(e,t){if(!e||e<=0)throw Error("n must be greater than 0 verticies");let n=[],i=!1,r=!1,a=t.lastReadGroup,s={};for(;!t.isEOF()&&0!==a.code&&!r;)switch(a.code){case 10:if(i){r=!0;continue}s.x=a.value,i=!0,a=t.next();break;case 20:s.y=a.value,a=t.next();break;case 30:s.z=a.value,a=t.next();break;case 40:s.startWidth=a.value,a=t.next();break;case 41:s.endWidth=a.value,a=t.next();break;case 42:0!=a.value&&(s.bulge=a.value),a=t.next();break;default:return i&&n.push(s),n}return n.push(s),i=!1,r=!1,n}var CE=class{constructor(){this.ForEntityName="MULTILEADER"}parseEntity(e,t){let n={type:t.value};function i(){for(;!e.isEOF();)switch(t.code){case 40:n.contextData.contentScale=t.value,t=e.next();break;case 10:n.contextData.contentBasePosition=Ft(e),t=e.lastReadGroup;break;case 145:n.contextData.landingGap=t.value,t=e.next();break;case 290:n.contextData.hasMText=t.value,t=e.next();break;case 304:n.contextData.defaultTextContents=t.value,t=e.next();break;case 11:n.contextData.textNormalDirection=Ft(e),t=e.lastReadGroup;break;case 12:n.contextData.textLocation=Ft(e),t=e.lastReadGroup;break;case 13:n.contextData.textDirection=Ft(e),t=e.lastReadGroup;break;case 140:n.contextData.arrowHeadSize=t.value,t=e.next();break;case 41:n.contextData.textHeight=t.value,t=e.next();break;case 42:n.contextData.textRotation=t.value,t=e.next();break;case 43:n.contextData.textWidth=t.value,t=e.next();break;case 44:default:t=e.next();break;case 45:n.contextData.textLineSpacingFactor=t.value,t=e.next();break;case 90:n.contextData.textColor=t.value,t=e.next();break;case 170:n.contextData.textLineSpacingStyle=t.value,t=e.next();break;case 171:n.contextData.textAttachment=t.value,t=e.next();break;case 172:n.contextData.textFlowDirection=t.value,t=e.next();break;case 141:n.contextData.textBackgroundScaleFactor=t.value,t=e.next();break;case 92:n.contextData.textBackgroundTransparency=t.value,t=e.next();break;case 291:n.contextData.textBackgroundColorOn=t.value,t=e.next();break;case 292:n.contextData.textBackgroundFillOn=t.value,t=e.next();break;case 293:n.contextData.textUseAutoHeight=t.value,t=e.next();break;case 173:n.contextData.textColumnType=t.value,t=e.next();break;case 142:n.contextData.textColumnWidth=t.value,t=e.next();break;case 143:n.contextData.textColumnGutterWidth=t.value,t=e.next();break;case 144:n.contextData.textColumnHeight=t.value,t=e.next();break;case 295:n.contextData.textUseWordBreak=t.value,t=e.next();break;case 296:n.contextData.hasBlock=t.value,t=e.next();break;case 341:n.contextData.blockContentId=t.value,t=e.next();break;case 14:n.contextData.blockContentNormalDirection=Ft(e),t=e.lastReadGroup;break;case 15:n.contextData.blockContentPosition=Ft(e),t=e.lastReadGroup;break;case 16:n.contextData.blockContentScale=t.value,t=e.next();break;case 46:n.contextData.blockContentRotation=t.value,t=e.next();break;case 93:n.contextData.blockContentColor=t.value,t=e.next();break;case 47:n.contextData.blockTransformationMatrix=ipe(e,47),t=e.lastReadGroup;break;case 110:n.contextData.planeOriginPoint=Ft(e),t=e.lastReadGroup;break;case 111:n.contextData.planeXAxisDirection=Ft(e),t=e.lastReadGroup;break;case 112:n.contextData.planeYAxisDirection=Ft(e),t=e.lastReadGroup;break;case 297:n.contextData.planeNormalReversed=t.value,t=e.next();break;case 301:return;case 302:r(),t=e.lastReadGroup}}function r(){let i={leaderLines:[]};for(n.contextData.leaders.push(i);!e.isEOF();)switch(t.code){case 290:i.hasSetLastLeaderLinePoint=t.value,t=e.next();break;case 291:i.hasSetDoglegVector=t.value,t=e.next();break;case 10:i.lastLeaderLinePoint=Ft(e),t=e.lastReadGroup;break;case 11:i.doglegVector=Ft(e),t=e.lastReadGroup;break;case 90:i.leaderBranchIndex=t.value,t=e.next();break;case 40:i.doglegLength=t.value,t=e.next();break;case 303:return;case 304:a(),t=e.lastReadGroup;break;default:t=e.next()}}function a(){let i={vertices:[[]]};for(n.contextData.leaders[n.contextData.leaders.length-1].leaderLines.push(i);!e.isEOF();)switch(t.code){case 10:i.vertices[0].push(Ft(e)),t=e.lastReadGroup;break;case 305:return;default:t=e.next()}}return n.contextData={leaders:[]},t=e.next(),function(){for(;!e.isEOF();)switch(t.code){case 0:return;case 340:n.leaderStyleId=t.value,t=e.next();break;case 170:n.leaderLineType=t.value,t=e.next();break;case 91:n.leaderLineColor=t.value,t=e.next();break;case 341:n.leaderLineTypeId=t.value,t=e.next();break;case 171:n.leaderLineWeight=t.value,t=e.next();break;case 41:n.doglegLength=t.value,t=e.next();break;case 290:n.enableLanding=t.value,t=e.next();break;case 291:n.enableDogLeg=t.value,t=e.next();break;case 342:n.arrowHeadId=t.value,t=e.next();break;case 42:n.arrowHeadSize=t.value,t=e.next();break;case 172:n.contentType=t.value,t=e.next();break;case 173:case 95:n.textLeftAttachmentType=t.value,t=e.next();break;case 174:n.textAngleType=t.value,t=e.next();break;case 175:n.textAlignmentType=t.value,t=e.next();break;case 343:n.textStyleId=t.value,t=e.next();break;case 92:n.textColor=t.value,t=e.next();break;case 292:n.enableFrameText=t.value,t=e.next();break;case 344:n.blockContentId=t.value,t=e.next();break;case 93:n.blockContentColor=t.value,t=e.next();break;case 10:n.blockContentScale=Ft(e),t=e.lastReadGroup;break;case 43:n.blockContentRotation=t.value,t=e.next();break;case 176:n.blockContentConnectionType=t.value,t=e.next();break;case 293:n.enableAnotationScale=t.value,t=e.next();break;case 94:n.arrowHeadIndex=t.value,t=e.next();break;case 177:n.blockAttributeIndex=t.value,t=e.next();break;case 44:n.blockAttributeWidth=t.value,t=e.next();break;case 302:n.blockAttributeTextString=t.value,t=e.next();break;case 294:n.textDirectionNegative=t.value,t=e.next();break;case 178:n.textAlignInIPE=t.value,t=e.next();break;case 179:n.textAttachmentPoint=t.value,t=e.next();break;case 271:n.textAttachmentDirectionMText=t.value,t=e.next();break;case 272:n.textAttachmentDirectionBottom=t.value,t=e.next();break;case 273:n.textAttachmentDirectionTop=t.value,t=e.next();break;case 300:i(),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}}(),n}},PE=class{constructor(){this.ForEntityName="MTEXT"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 3:case 1:n.text?n.text+=t.value:n.text=t.value,t=e.next();break;case 10:n.position=Ft(e),t=e.lastReadGroup;break;case 7:n.textStyle=t.value,t=e.next();break;case 44:n.lineSpaceFactor=t.value,t=e.next();break;case 11:n.directionVector=Ft(e),n.rotation=void 0,t=e.lastReadGroup;break;case 40:n.height=t.value,t=e.next();break;case 41:n.width=t.value,t=e.next();break;case 50:n.rotation=t.value,n.directionVector=void 0,t=e.next();break;case 71:n.attachmentPoint=t.value,t=e.next();break;case 72:n.drawingDirection=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}return n}},IE=class{constructor(){this.ForEntityName="OLE2FRAME"}parseEntity(e,t){let n={type:t.value,binaryData:""};for(t=e.next();"OLE"!==t.value&&0!==t.code;)switch(t.code){case 3:n.documentType=t.value,t=e.next();break;case 70:n.version=t.value,t=e.next();break;case 10:n.leftUpX=t.value,t=e.next();break;case 20:n.leftUpY=t.value,t=e.next();break;case 30:n.leftUpZ=t.value,t=e.next();break;case 11:n.rightDownX=t.value,t=e.next();break;case 21:n.rightDownY=t.value,t=e.next();break;case 31:n.rightDownZ=t.value,t=e.next();break;case 90:n.lengthOfBinaryData=t.value,t=e.next();break;case 310:n.binaryData+=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}return n}},LE=class{constructor(){this.ForEntityName="POINT"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.position=Ft(e),t=e.lastReadGroup;break;case 39:n.thickness=t.value,t=e.next();break;case 210:n.extrusionDirection=Ft(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}return n}},DE=class{constructor(){this.ForEntityName="VERTEX"}parseEntity(e,t){var n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.x=t.value,t=e.next();break;case 20:n.y=t.value,t=e.next();break;case 30:n.z=t.value,t=e.next();break;case 40:case 41:case 50:t=e.next();break;case 42:0!=t.value&&(n.bulge=t.value),t=e.next();break;case 70:n.curveFittingVertex=0!=(1&t.value),n.curveFitTangent=0!=(2&t.value),n.splineVertex=0!=(8&t.value),n.splineControlPoint=0!=(16&t.value),n.threeDPolylineVertex=0!=(32&t.value),n.threeDPolylineMesh=0!=(64&t.value),n.polyfaceMeshVertex=0!=(128&t.value),t=e.next();break;case 71:n.faceA=t.value,t=e.next();break;case 72:n.faceB=t.value,t=e.next();break;case 73:n.faceC=t.value,t=e.next();break;case 74:n.faceD=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}return n}},OE=class{constructor(){this.ForEntityName="POLYLINE"}parseEntity(e,t){var n={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:case 20:case 30:case 40:case 41:case 71:case 72:case 73:case 74:case 75:t=e.next();break;case 39:t=e.next(),n.thickness=t.value;break;case 70:n.shape=0!=(1&t.value),n.includesCurveFitVertices=0!=(2&t.value),n.includesSplineFitVertices=0!=(4&t.value),n.is3dPolyline=0!=(8&t.value),n.is3dPolygonMesh=0!=(16&t.value),n.is3dPolygonMeshClosed=0!=(32&t.value),n.isPolyfaceMesh=0!=(64&t.value),n.hasContinuousLinetypePattern=0!=(128&t.value),t=e.next();break;case 210:n.extrusionDirection=Ft(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}return n.vertices=Lht(e,t),n}};function Lht(e,t){let n=new DE,i=[];for(;!e.isEOF();)if(0===t.code)if("VERTEX"===t.value)i.push(n.parseEntity(e,t)),t=e.lastReadGroup;else if("SEQEND"===t.value){Dht(e,t);break}return i}function Dht(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)if(101===t.code)for(;0!=t.code;)t=e.next();else Bn(n,t),t=e.next();return n}var kE=class{constructor(){this.ForEntityName="RAY"}parseEntity(e,t){let n={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.vertices.unshift(Ft(e)),t=e.lastReadGroup;break;case 11:n.directionVector=Ft(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}return n}},FE=class{constructor(){this.ForEntityName="REGION"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 70:n.modelerVersion=t.value,t=e.next();break;case 1:n.proprietaryData=t.value,t=e.next();break;case 3:n.proprietaryData+=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}return n}},NE=class{constructor(){this.ForEntityName="SEQEND"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)-2===t.code||(Bn(n,t),t=e.next());return n}},BE=class{constructor(){this.ForEntityName="SOLID"}parseEntity(e,t){let n={type:t.value,points:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.points[0]=Ft(e),t=e.lastReadGroup;break;case 11:n.points[1]=Ft(e),t=e.lastReadGroup;break;case 12:n.points[2]=Ft(e),t=e.lastReadGroup;break;case 13:n.points[3]=Ft(e),t=e.lastReadGroup;break;case 210:n.extrusionDirection=Ft(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}return n}},UE=class{constructor(){this.ForEntityName="SPLINE"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.controlPoints||(n.controlPoints=[]),n.controlPoints.push(Ft(e)),t=e.lastReadGroup;break;case 11:n.fitPoints||(n.fitPoints=[]),n.fitPoints.push(Ft(e)),t=e.lastReadGroup;break;case 12:n.startTangent=Ft(e),t=e.lastReadGroup;break;case 13:n.endTangent=Ft(e),t=e.lastReadGroup;break;case 40:n.knotValues||(n.knotValues=[]),n.knotValues.push(t.value),t=e.next();break;case 70:1&t.value&&(n.closed=!0),2&t.value&&(n.periodic=!0),4&t.value&&(n.rational=!0),8&t.value&&(n.planar=!0),16&t.value&&(n.planar=!0,n.linear=!0),t=e.next();break;case 71:n.degreeOfSplineCurve=t.value,t=e.next();break;case 72:n.numberOfKnots=t.value,t=e.next();break;case 73:n.numberOfControlPoints=t.value,t=e.next();break;case 74:n.numberOfFitPoints=t.value,t=e.next();break;case 210:n.normalVector=Ft(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}return n}},HE=class{constructor(){this.ForEntityName="TEXT"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.startPoint=Ft(e),t=e.lastReadGroup;break;case 11:n.endPoint=Ft(e),t=e.lastReadGroup;break;case 40:n.textHeight=t.value,t=e.next();break;case 41:n.xScale=t.value,t=e.next();break;case 50:n.rotation=t.value,t=e.next();break;case 1:n.text=t.value,t=e.next();break;case 72:n.halign=t.value,t=e.next();break;case 73:n.valign=t.value,t=e.next();break;case 7:n.textStyle=t.value,t=e.next();break;case 71:n.mirrored=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}return n}},VE=class{constructor(){this.ForEntityName="VIEWPORT"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 68:n.viewportStatus=t.value,t=e.next();break;case 40:n.width_paperSpace=t.value,t=e.next();break;case 41:n.height_paperSpace=t.value,t=e.next();break;case 69:n.viewportId=t.value,t=e.next();break;case 10:n.centerPoint=Ft(e),t=e.lastReadGroup;break;case 12:n.centerPoint_dcs=Ft(e),t=e.lastReadGroup;break;case 13:n.snapBasePoint_dcs=Ft(e),t=e.lastReadGroup;break;case 14:n.snapSpacing_dcs=Ft(e),t=e.lastReadGroup;break;case 15:n.gridSpacing_dcs=Ft(e),t=e.lastReadGroup;break;case 16:n.viewDirection=Ft(e),t=e.lastReadGroup;break;case 17:n.viewTarget=Ft(e),t=e.lastReadGroup;break;case 42:n.perspectiveLens=t.value,t=e.next();break;case 43:n.frontClippingPlaneZ=t.value,t=e.next();break;case 44:n.backClippingPlaneZ=t.value,t=e.next();break;case 45:n.viewHeight=t.value,t=e.next();break;case 50:n.snapAngle=t.value,t=e.next();break;case 51:n.viewTwistAngle=t.value,t=e.next();break;case 72:n.circleZoomPercent=t.value,t=e.next();break;case 331:n.frozenLayerHandles=n.frozenLayerHandles||[],n.frozenLayerHandles.push(t.value),t=e.next();break;case 90:n.viewportStatusFlags=t.value,t=e.next();break;case 340:n.viewportClippingBoundaryhandleId=t.value,t=e.next();break;case 1:n.plotStyleSheetName=t.value,t=e.next();break;case 281:n.renderMode=t.value,t=e.next();break;case 71:n.viewportFlag_ucs=t.value,t=e.next();break;case 74:n.ucsIcon=t.value,t=e.next();break;case 110:n.ucsOrigin=Ft(e),t=e.lastReadGroup;break;case 111:n.ucsXAxis=Ft(e),t=e.lastReadGroup;break;case 112:n.ucsYAxis=Ft(e),t=e.lastReadGroup;break;case 345:n.ucsTableRecordHandle=t.value,t=e.next();break;case 346:n.baseUcsTableRecordHandle=t.value,t=e.next();break;case 79:n.orthographicType=t.value,t=e.next();break;case 146:n.elevation=t.value,t=e.next();break;case 170:n.shadePlotMode=t.value,t=e.next();break;case 61:n.frequency=t.value,t=e.next();break;case 292:n.lightingFlag=t.value,t=e.next();break;case 282:n.lightingType=t.value,t=e.next();break;case 141:n.viewBrightness=t.value,t=e.next();break;case 142:n.viewContrast=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}return n}},zE=class{constructor(){this.ForEntityName="XLINE"}parseEntity(e,t){let n={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.vertices.unshift(Ft(e)),t=e.lastReadGroup;break;case 11:n.directionVector=Ft(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Bn(n,t),t=e.next()}return n}},lC=class{constructor(){this.ForObjectName="DICTIONARY"}parseObject(e,t){let n={type:t.value},i=[],r=[];for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 280:n.isHardOwner=1===t.value,t=e.next();break;case 281:n.cloningFlag=t.value,t=e.next();break;case 3:i.push(t.value),t=e.next();break;case 350:case 360:r.push(t.value),t=e.next();break;case 100:case 102:t=e.next();break;default:Nl(n,t),t=e.next()}if(i.length!==r.length)throw new Error("The number of Dictionary entries does not match !");return n.entries={},i.forEach(((e,t)=>{n.entries[r[t]]=e})),n}},cC=class{constructor(){this.ForObjectName="IMAGEDEF"}parseObject(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 90:n.classVersion=t.value,t=e.next();break;case 1:n.filename=t.value,t=e.next();break;case 10:n.imageSize=Ft(e),t=e.next();break;case 11:n.pixelSize=Ft(e),t=e.next();break;case 280:n.loaded=t.value,t=e.next();break;case 281:n.resolutionUnits=t.value,t=e.next();break;default:Nl(n,t),t=e.next()}return n}},uC=class{constructor(){this.ForObjectName="LAYOUT"}parseObject(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 100:t=e.next();break;case 1:n.layoutName=t.value,t=e.next();break;case 70:n.flag=t.value,t=e.next();break;case 71:n.tabOrder=t.value,t=e.next();break;case 76:n.orthographicType=t.value,t=e.next();break;case 10:n.minLimit=Ft(e),t=e.lastReadGroup;break;case 11:n.maxLimit=Ft(e),t=e.lastReadGroup;break;case 12:n.basePoint=Ft(e),t=e.lastReadGroup;break;case 13:n.origin=Ft(e),t=e.lastReadGroup;break;case 14:n.minExtent=Ft(e),t=e.lastReadGroup;break;case 15:n.maxExtent=Ft(e),t=e.lastReadGroup;break;case 16:n.XAxis=Ft(e),t=e.lastReadGroup;break;case 17:n.YAxis=Ft(e),t=e.lastReadGroup;break;case 146:n.elevation=t.value,t=e.next();break;case 331:n.viewportHandle=t.value,t=e.next();break;default:Nl(n,t),t=e.next()}return n.blockTableHandle=n.ownerHandle,n}},hC=class{constructor(){this.ForObjectName="SORTENTSTABLE"}parseObject(e,t){let n={type:t.value},i=!1;n.sortEntsObject={},n.sortEntsObject.entityHandles=[];let r=[];for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 5:i?(r.push(t.value),n.sortEntsObject.entityHandles.push(r),r=[]):n.handle=t.value,t=e.next();break;case 100:t=e.next(),i=!0;break;case 102:t=e.next();break;case 330:i?n.sortEntsObject.ownerHandle=t.value:n.ownerHandle=t.value,t=e.next();break;case 331:r.push(t.value),t=e.next();break;default:Nl(n,t),t=e.next()}return n}},dC=class{constructor(){this.ForObjectName="SPATIAL_FILTER"}parseObject(e,t){let n,i,r={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 11:r.origin=Ft(e),t=e.lastReadGroup;break;case 70:r.numberOfPointsOnClipBoundary=t.value,2===r.numberOfPointsOnClipBoundary?(t=e.next(),n=Ft(e),t=e.lastReadGroup,i=Ft(e),t=e.lastReadGroup,r.vertices.push(n,{x:i.x,y:n.y},i,{x:n.x,y:i.y},n)):r.numberOfPointsOnClipBoundary>2?(r.vertices=Oht(r.numberOfPointsOnClipBoundary,e),t=e.lastReadGroup):t=e.next();break;case 71:r.clipBoundaryVisible=1===t.value,t=e.next();break;case 72:r.frontClippingPlaneFlag=1===t.value,t=e.next(),r.frontClippingPlaneFlag&&40===t.code&&(r.frontClippingPlaneDistance=t.value,t=e.next());break;case 73:r.backClippingPlaneFlag=1===t.value,t=e.next(),r.backClippingPlaneFlag&&41===t.code&&(r.backClippingPlaneDistance=t.value,t=e.next());break;case 100:case 102:t=e.next();break;case 210:r.extrusionDirectionX=t.value,t=e.next();break;case 220:r.extrusionDirectionY=t.value,t=e.next();break;case 230:r.extrusionDirectionZ=t.value,t=e.next();break;case 40:r.invertBlockMatrix=ape(e,40),r.matrix=ape(e,40),t=e.lastReadGroup;break;default:Nl(r,t),t=e.next()}return r}};function Oht(e,t){t.next();let n=[];for(;n.length{e.on("data",(e=>{t+=e})),e.on("end",(()=>{try{i(n.parse(t))}catch(e){r(e)}})),e.on("error",(e=>{r(e)}))}))}_parse(e){let t={},n=0;if(!e.hasNext())throw Error("Empty file");let i,r=this;function a(){let t=null,n=null,r={};for(i=e.next();;){if(el(i,0,"ENDSEC")){t&&(r[t]=n);break}9===i.code?(t&&(r[t]=n),t=i.value):10===i.code?n={x:i.value}:20===i.code?n.y=i.value:30===i.code?n.z=i.value:n=i.value,i=e.next()}return i=e.next(),r}function s(){let t={};for(i=e.next();"EOF"!==i.value&&!el(i,0,"ENDSEC");)if(el(i,0,"BLOCK")){se.trace("block {");let e=o();se.trace("}"),m(e),e.name?t[e.name]=e:se.error(`[DxfParser] Block with handle '${e.handle}' is missing a name, ignored!`)}else rd(i),i=e.next();return t}function o(){let t={};for(i=e.next();"EOF"!==i.value;){switch(i.code){case 1:t.xrefPath=i.value,i=e.next();break;case 2:t.name=i.value,i=e.next();break;case 3:t.name2=i.value,i=e.next();break;case 4:t.description=i.value,i=e.next();break;case 5:t.handle=i.value,i=e.next();break;case 8:t.layer=i.value,i=e.next();break;case 10:t.position=f(i),i=e.lastReadGroup;break;case 67:t.paperSpace=!(!i.value||1!==i.value),i=e.next();break;case 70:t.blockType=i.value,i=e.next();break;case 100:i=e.next();break;case 330:t.ownerHandle=i.value,i=e.next();break;case 0:if("ENDBLK"==i.value)break;t.entities=d(!0);break;default:rd(i),i=e.next()}if(el(i,0,"ENDBLK")){i=e.next();break}}return t}function l(){let t={};for(i=e.next();"EOF"!==i.value&&!el(i,0,"ENDSEC");)el(i,0,"TABLE")?(i=e.next(),u[i.value]?(se.trace(i.value+" Table {"),t[u[i.value].tableName]=c(i),se.trace("}")):se.trace("Unhandled Table "+i.value)):i=e.next();return i=e.next(),t}let h="ENDTAB";function c(t){let n=u[t.value],r={},a=0;for(i=e.next();!el(i,0,h);)switch(i.code){case 5:r.handle=i.value,i=e.next();break;case 330:r.ownerHandle=i.value,i=e.next();break;case 100:"AcDbSymbolTable"===i.value||rd(i),i=e.next();break;case 70:a=i.value,i=e.next();break;case 0:i.value===n.dxfSymbolName?r[n.tableRecordsProperty]=n.parseTableRecords():(rd(i),i=e.next());break;default:rd(i),i=e.next()}let s=r[n.tableRecordsProperty];if(s){let e=s.constructor===Array?s.length:"object"==typeof s?Object.keys(s).length:void 0;a!==e&&se.warn(`[DxfParser] Parsed ${e} ${n.dxfSymbolName}s but expected ${a}`)}return i=e.next(),r}let u={VPORT:{tableRecordsProperty:"viewports",tableName:"viewport",dxfSymbolName:"VPORT",parseTableRecords:function(){let t=[],n={};for(se.trace("Viewport {"),i=e.next();!el(i,0,h);)switch(i.code){case 2:n.name=i.value,i=e.next();break;case 10:n.lowerLeftCorner=f(i),i=e.lastReadGroup;break;case 11:n.upperRightCorner=f(i),i=e.lastReadGroup;break;case 12:n.center=f(i),i=e.lastReadGroup;break;case 13:n.snapBasePoint=f(i),i=e.lastReadGroup;break;case 14:n.snapSpacing=f(i),i=e.lastReadGroup;break;case 15:n.gridSpacing=f(i),i=e.lastReadGroup;break;case 16:n.viewDirectionFromTarget=f(i),i=e.lastReadGroup;break;case 17:n.viewTarget=f(i),i=e.lastReadGroup;break;case 40:case 45:n.viewHeight=i.value,i=e.next();break;case 41:n.aspectRatio=i.value,i=e.next();break;case 42:n.lensLength=i.value,i=e.next();break;case 43:n.frontClippingPlane=i.value,i=e.next();break;case 44:n.backClippingPlane=i.value,i=e.next();break;case 50:n.snapRotationAngle=i.value,i=e.next();break;case 51:n.viewTwistAngle=i.value,i=e.next();break;case 79:n.orthographicType=i.value,i=e.next();break;case 110:n.ucsOrigin=f(i),i=e.lastReadGroup;break;case 111:n.ucsXAxis=f(i),i=e.lastReadGroup;break;case 112:n.ucsYAxis=f(i),i=e.lastReadGroup;break;case 281:n.renderMode=i.value,i=e.next();break;case 282:n.defaultLightingType=i.value,i=e.next();break;case 292:n.defaultLightingOn=i.value,i=e.next();break;case 330:n.ownerHandle=i.value,i=e.next();break;case 63:case 421:case 431:n.ambientColor=i.value,i=e.next();break;case 0:"VPORT"===i.value&&(se.trace("}"),t.push(n),se.trace("Viewport {"),n={},i=e.next());break;default:rd(i),i=e.next()}return se.trace("}"),t.push(n),t}},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:function(){let t={},n={},a=0,s="",o=!1;for(se.trace("LType {"),i=e.next();!el(i,0,"ENDTAB");)switch(i.code){case 2:n.name=i.value.toUpperCase(),s=n.name,i=e.next();break;case 3:n.description=i.value,i=e.next();break;case 9:case 44:case 45:case 46:case 70:case 75:default:i=e.next();break;case 40:n.patternLength=i.value,i=e.next();break;case 49:let l=i.value;o&&(l=Math.abs(l),o=!1),n.pattern.push(l),i=e.next();break;case 73:a=i.value,a>0&&(n.pattern=[]),i=e.next();break;case 74:0!==i.value&&(o=!0,r.unsupportedLineTypes[n.name]?r.unsupportedLineTypes[n.name]++:r.unsupportedLineTypes[n.name]=1),i=e.next();break;case 0:se.trace("}"),a>0&&a!==n.pattern.length&&se.warn("[DxfParser] lengths do not match on LTYPE pattern"),t[s]=n,n={},se.trace("LType {"),i=e.next()}return se.trace("}"),t[s]=n,t}},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:function(){let t,n={},r={};for(se.trace("Layer {"),i=e.next();!el(i,0,"ENDTAB");)switch(i.code){case 2:r.name=i.value,t=i.value,i=e.next();break;case 5:r.handle=i.value,i=e.next();break;case 62:r.visible=i.value>=0,r.colorIndex=Math.abs(i.value),r.color=Bht(r.colorIndex),i=e.next();break;case 70:r.flag=i.value,r.frozen=(1&r.flag)>0,i=e.next();break;case 420:r.color=Math.abs(i.value),i=e.next();break;case 6:r.lineType=i.value.toUpperCase(),i=e.next();break;case 370:r.lineweight=i.value,i=e.next();break;case 0:"LAYER"===i.value&&(se.trace("}"),t&&(n[t]=r),se.trace("Layer {"),r={},t=void 0,i=e.next());break;default:rd(i),i=e.next()}return se.trace("}"),t&&(n[t]=r),n}},BLOCK_RECORD:{tableRecordsProperty:"blockRecords",tableName:"blockRecord",dxfSymbolName:"BLOCK_RECORD",parseTableRecords:function(){let t,n={},a={};for(se.trace("BlockRecord {"),i=e.next();!el(i,0,"ENDTAB");)switch(i.code){case 5:a.handle=i.value,i=e.next();break;case 330:a.ownerHandle=i.value,i=e.next();break;case 2:a.blockName=i.value,t=a.blockName,i=e.next();break;case 340:a.layoutHandle=i.value,i=e.next();break;case 70:a.blockInsertUnits=i.value,i=e.next();break;case 280:a.blockExplodability=i.value,i=e.next();break;case 281:a.blockScalability=i.value,i=e.next();break;case 310:a.bitmap=i.value,i=e.next();break;case 0:if("BLOCK_RECORD"===i.value){se.trace("}"),t&&(n[t]=a);let s=a.layoutHandle;t&&s&&s.length>0&&"0"!==s&&(r._layoutBlocks[s]=a),se.trace("BlockRecord {"),a={},t=void 0,i=e.next()}else rd(i),i=e.next();break;default:rd(i),i=e.next()}se.trace("}"),t&&(n[t]=a);let s=a.layoutHandle;return t&&s&&s.length>0&&"0"!==s&&(r._layoutBlocks[s]=a),n}},STYLE:{tableRecordsProperty:"styles",tableName:"style",dxfSymbolName:"STYLE",parseTableRecords:function(){let t,n={},r={};for(se.trace("Style {"),i=e.next();!el(i,0,"ENDTAB");)switch(i.code){case 2:r.styleName=i.value,t=i.value,i=e.next();break;case 3:r.fontFile=i.value,i=e.next();break;case 4:r.bigFontFile=i.value,i=e.next();break;case 5:r.handle=i.value,i=e.next();break;case 40:r.textHeight=i.value,i=e.next();break;case 41:r.xScale=i.value,i=e.next();break;case 42:r.priorTextHeight=i.value,i=e.next();break;case 50:r.rotation=i.value,i=e.next();break;case 70:default:i=e.next();break;case 71:r.mirrorType=i.value,i=e.next();break;case 330:r.ownerHandle=i.value,i=e.next();break;case 0:"STYLE"===i.value&&(se.trace("}"),t&&(n[t]=r),se.trace("Style {"),r={},t=void 0,i=e.next())}return se.trace("}"),t&&(n[t]=r),n}},DIMSTYLE:{tableRecordsProperty:"dimStyles",tableName:"dimStyle",dxfSymbolName:"DIMSTYLE",parseTableRecords:function(){let t,n={},r={};for(se.trace("DimStyle {"),i=e.next();!el(i,0,"ENDTAB");)switch(i.code){case 2:r.styleName=i.value,t=i.value,i=e.next();break;case 40:r.DIMSCALE=i.value,i=e.next();break;case 41:r.DIMASZ=i.value,i=e.next();break;case 42:r.DIMEXO=i.value,i=e.next();break;case 44:r.DIMEXE=i.value,i=e.next();break;case 75:r.DIMSE1=i.value,i=e.next();break;case 76:r.DIMSE2=i.value,i=e.next();break;case 77:r.DIMTAD=i.value,i=e.next();break;case 140:r.DIMTXT=i.value,i=e.next();break;case 144:r.DIMLFAC=i.value,i=e.next();break;case 147:r.DIMGAP=i.value,i=e.next();break;case 176:r.DIMCLRD=i.value,i=e.next();break;case 178:r.DIMCLRT=i.value,i=e.next();break;case 271:r.DIMDEC=i.value,i=e.next();break;case 341:r.DIMLDRBLK=i.value,i=e.next();break;case 70:default:i=e.next();break;case 0:"DIMSTYLE"===i.value&&(se.trace("}"),t&&(n[t]=r),se.trace("DimStyle {"),r={},t=void 0,i=e.next())}return se.trace("}"),t&&(n[t]=r),n}}};function d(t){let n=[],a=t?"ENDBLK":"ENDSEC";for(t||(i=e.next());;)if(0===i.code){if(i.value===a)break;let t=r._entityHandlers[i.value];if(null==t){let t=i.value;r.unhandledEntities[t]||(r.unhandledEntities[t]=0),r.unhandledEntities[t]++,i=e.next();continue}{se.trace(i.value+" {");let r=t.parseEntity(e,i);r&&(r.layer||(r.layer="0"),void 0===r.colorIndex&&(r.colorIndex=256),r.lineType||(r.lineType=iy)),i=e.lastReadGroup,se.trace("}"),m(r),n.push(r)}}else i=e.next();return"ENDSEC"==a&&(i=e.next()),n}function p(){let t={};for(i=e.next();"EOF"!==i.value;)if(0===i.code){if("ENDSEC"===i.value)break;let n=r._objectHandlers[i.value];if(null==n){let t=i.value;r.unhandledObjects[t]||(r.unhandledObjects[t]=0),r.unhandledObjects[t]++,i=e.next();continue}{se.trace(i.value+" {");let r=n.parseObject(e,i),a=i.value;i=e.lastReadGroup,se.trace("}"),m(r),t[a]||(t[a]=[]),t[a].push(r)}}else i=e.next();return i=e.next(),t.LAYOUT&&(Object.keys(r._layoutBlocks).length!==t.LAYOUT.length&&se.warn("[DxfParser] The number of layout and block associations does not match!"),t.LAYOUT.forEach((e=>{r._layoutBlocks[e.handle]&&(e.associatedBlockName=r._layoutBlocks[e.handle].blockName)})),t.LAYOUT.sort(((e,t)=>e.tabOrder-t.tabOrder))),t}function f(t){let n={},i=t.code;if(n.x=t.value,i+=10,(t=e.next()).code!=i)throw new Error(`Expected code for point value to be ${i} but got ${t.code}.`);return n.y=t.value,i+=10,(t=e.next()).code!=i||(n.z=t.value,t=e.next()),n}function m(e){if(!e)throw new TypeError("entity cannot be undefined or null");e.handle||(e.handle=(n++).toString())}return function(){for(i=e.next();999===i.code;)i=e.next();for(;!e.isEOF();)if(0===i.code&&"SECTION"===i.value){if(i=e.next(),2!==i.code){se.error("Unexpected code %s after 0:SECTION",ope(i)),i=e.next();continue}if("HEADER"===i.value)se.trace("> HEADER"),t.header=a(),se.trace("<");else if("TABLES"===i.value)se.trace("> TABLES"),t.tables=l(),se.trace("<");else if("BLOCKS"===i.value)se.trace("> BLOCKS"),t.blocks=s(),se.trace("<");else if("ENTITIES"===i.value)se.trace("> ENTITIES"),t.entities=d(!1),se.trace("<");else if("OBJECTS"===i.value)se.trace("> OBJECTS"),t.objects=p(),se.trace("<");else if("EOF"===i.value)se.trace("EOF");else{let e=i.value;r.unhandledSections[e]?r.unhandledSections[e]++:r.unhandledSections[e]=1}}else i=e.next();r.unhandledSections={},r.unhandledEntities={},r.unhandledObjects={},r.unsupportedLineTypes={}}(),t}splitByLineSeparator(e){let t=[],n=0;for(let i=0,r=e.length;i(e.Added="Added",e.Removed="Removed",e.Modified="Modified",e.NoChange="NoChange",e))(B5||{}),Wa=1,pC=class{constructor(e,t,n){if(this.changes={},this.comparedBlocks=new Map,this.isComparingBlock=!1,this.isComparingDimension=!1,this.enableDetailComparision=!0,this.dxf1=e,this.dxf2=t,this.enableDetailComparision=!n||(null==n?void 0:n.enableDetailComparision),!e||!t)throw new Error("Invalid dxf data to compare!")}getLayerFrozen(e,t){var n,i,r;let a=null==(i=null==(n=e.tables)?void 0:n.layer)?void 0:i.layers;return a&&(null==(r=a[t.layer])?void 0:r.frozen)}compare(e){return ft(this,null,(function*(){this.changes={};let t=[],n=new Map;return this.dxf1.entities.forEach((e=>{if(!0!==e.inPaperSpace){let n=!0===this.getLayerFrozen(this.dxf1,e);!pC.ignoreEntityTypes.includes(e.type)&&!n&&t.push(e)}})),this.dxf2.entities.forEach((e=>{if(!0!==e.inPaperSpace){let t=!0===this.getLayerFrozen(this.dxf2,e);!pC.ignoreEntityTypes.includes(e.type)&&!t&&n.set(e.handle,e)}})),yield this.compareEntities(t,n,e),Promise.resolve(this.changes)}))}isDimensionBlock(e){return e.includes("*D")}compareInsertOrDemensionEntities(e,t,n,i){if(!e.block||!t.block)return;let r,a=e.block;if(this.isComparingBlock=!0,this.isDimensionBlock(a)){let n=this.dxf1.blocks[e.block],i=this.dxf2.blocks[t.block],s=Date.now();this.isComparingDimension=!0,r=this.compareBlock(e,t,n,i),this.isComparingDimension=!1,se.debug(`[DxfCompare] compare block: ${a} cost ${(Date.now()-s)/1e3}s`)}else{if(!this.comparedBlocks.has(a)){let n=this.dxf1.blocks[a],i=this.dxf2.blocks[a],r=Date.now(),s=this.compareBlock(e,t,n,i);this.comparedBlocks.set(a,s),se.debug(`[DxfCompare] compare block: ${a} cost ${(Date.now()-r)/1e3}s`)}r=this.comparedBlocks.get(a)}return null==r||r.forEach((t=>{if(t.parentHandles||(t.parentHandles=[]),n&&i)"Added"===t.type?t.parentHandles.push(i):"Removed"===t.type&&t.parentHandles.push(n);else{let n=[...t.parentHandles,e.handle];("Added"===t.type||"Removed"===t.type)&&(this.changes[Wa]=Ri(wr({id:Wa},t),{parentHandles:n})),Wa++}})),!n&&!i&&(this.isComparingBlock=!1),r}compareBlock(e,t,n,i){var r,a;let s=[],o=[];null==(r=null==n?void 0:n.entities)||r.forEach((e=>{"ATTDEF"!==e.type&&!this.bIgnoreChildEntitiesOriginalType(e)&&s.push(e)})),null==(a=null==i?void 0:i.entities)||a.forEach((e=>{"ATTDEF"!==e.type&&!this.bIgnoreChildEntitiesOriginalType(e)&&o.push(e)}));let l=[],h=[];for(let c=0;c0&&l.push(...e),i=!1,o.splice(r--,1);break}i=!1,o.splice(r--,1);break}i=!0}i&&(l.push({type:"Removed",handle:n.handle}),h.push(n.handle))}return o.forEach((e=>{h.includes(e.handle)||l.push({type:"Added",handle:e.handle})})),l}compareEntities(e,t,n){return ft(this,null,(function*(){var i,r;let a=Mt.getUpdateProgressFuncForLoop(e.length,n);for(let n=0;n0&&(this.changes[Wa].detailChanges=l),Wa++}t.delete(s)}else this.changes[Wa]={id:Wa,type:"Removed",handle:s},Wa++;yield a(n)}for(let e of t){let t=e[0];this.changes[Wa]={id:Wa,type:"Added",handle:t},Wa++}}))}bIgnoreChildEntitiesOriginalType(e){var t;return rpe.includes(null==(t=e.extendedData)?void 0:t.originalType)}entitiesEqual(e,t,n,i,r){if(!this.baseEntitiesEqual(e,t,n,i,r))return!1;let a=e.type,s=!0;return"CIRCLE"===a||"ARC"===a?s=this.arcsEqual(e,t):"LWPOLYLINE"===a||"LINE"===a?s=this.linesEqual(e,t,r):"POLYLINE"===a?s=this.polylinesEqual(e,t):"TEXT"===a?s=this.textsEqual(e,t):"SOLID"===a?s=this.solidsEqual(e,t):"POINT"===a?s=this.pointEntitiesEqual(e,t):"INSERT"===a?s=this.insertsEqual(e,t):"SPLINE"===a?s=this.splinesEqual(e,t):"MTEXT"===a?s=this.mtextsEqual(e,t):"ELLIPSE"===a?s=this.ellipsesEqual(e,t):"DIMENSION"===a?s=this.dimensionsEqual(e,t):"REGION"===a?s=this.regionsEqual(e,t):"ATTDEF"===a?s=this.attDefsEqual(e,t):"ATTRIB"===a?s=this.attribsEqual(e,t):"HATCH"===a?s=this.hatchesEqual(e,t):"VIEWPORT"===a?s=this.viewportsEqual(e,t):"LEADER"===a?s=this.leadersEqual(e,t):"MULTILEADER"===a?s=this.mleadersEqual(e,t):"OLE2FRAME"===a&&(s=this.ole2framesEqual(e,t)),s}getColor(e,t,n){var i,r,a,s,o,l;if(e.isTrueColor||e.colorIndex>0&&e.colorIndex<256)return e.color;if(0===e.colorIndex)return n?this.getColor(n,t):null==(r=null==(i=t.tables)?void 0:i.layer)?void 0:r.layers[0].color;let h=0;if(256===e.colorIndex){let i=null==(s=null==(a=t.tables)?void 0:a.layer)?void 0:s.layers,r=i&&i[e.layer],c=i&&n&&i[n.layer];h=r&&"0"!==r.name?r.color:c?c.color:r?r.color:null==(l=null==(o=t.tables)?void 0:o.layer)?void 0:l.layers[0].color}return h}getLineType(e,t,n){var i,r;if(n&&"DIMENSION"===n.type)return this.getLineType(n,t);if(e.lineType!==iy&&e.lineType!==sy)return e.lineType;if(e.lineType===sy)return n?this.getLineType(n,t):e.lineType;let a=null==(r=null==(i=t.tables)?void 0:i.layer)?void 0:r.layers;if("0"!==e.layer){let t=a&&a[e.layer];if(t)return t.lineType}else if(n){let e=a&&a[n.layer];if(e)return e.lineType}return"CONTINUOUS"}addModificationItem(e,t,n,i){i&&(i[n]={old:e,new:t})}baseEntitiesEqual(e,t,n,i,r){var a,s;let o=!0,l=this.getColor(e,this.dxf1,n),h=this.getColor(t,this.dxf2,i);if(l!==h){if(o=!1,!this.enableDetailComparision)return o;this.addModificationItem(l,h,"color",r)}let c=this.getLineType(e,this.dxf1,n),u=this.getLineType(t,this.dxf2,i);return c!==u?(o=!1,this.enableDetailComparision?(this.addModificationItem(c,u,"lineType",r),!1):o):!((null==(a=e.extendedData)?void 0:a.originalType)!==(null==(s=t.extendedData)?void 0:s.originalType)||!this.isComparingBlock&&!this.isComparingDimension&&e.handle!==t.handle||!this.isComparingDimension&&e.ownerHandle!==t.ownerHandle||e.type!==t.type)&&o}arcsEqual(e,t){return!!(this.vectorsEqual(e.center,t.center)&&this.numberEqual(e.radius,t.radius)&&this.numberEqual(e.startAngle,t.startAngle)&&this.numberEqual(e.endAngle,t.endAngle))}linesEqual(e,t,n){let i=!0,r=e.constantWidth,a=t.constantWidth;if(r!==a){if(i=!1,!this.enableDetailComparision)return!1;this.addModificationItem(r||0,a||0,"constantWidth",n)}return!(!this.verticesEqual(e.vertices,t.vertices)||e.shape!==t.shape)&&i}polylinesEqual(e,t){return!(!this.vertexEntitiesEqual(e.vertices,t.vertices)||e.shape!==t.shape||e.isPolyfaceMesh!==t.isPolyfaceMesh)}textsEqual(e,t){if(e.halign!==t.halign)return!1;if(3===e.halign||5===e.halign){if(!this.pointsEqual(e.startPoint,t.startPoint))return!1}else if(!this.pointsEqual(e.endPoint,t.endPoint))return!1;return e.text===t.text}solidsEqual(e,t){return!!this.verticesEqual(e.points,t.points)}pointEntitiesEqual(e,t){return!!this.pointsEqual(e.position,t.position)}splinesEqual(e,t){return!(!this.verticesEqual(e.controlPoints,t.controlPoints)||!this.numbersEqual(e.knotValues,t.knotValues)||!this.numberEqual(e.degreeOfSplineCurve,t.degreeOfSplineCurve))}mtextsEqual(e,t){return!(!this.pointsEqual(e.position,t.position)||e.text!==t.text||!this.numberEqual(e.rotation,t.rotation))}ellipsesEqual(e,t){return!!(this.pointsEqual(e.center,t.center)&&this.pointsEqual(e.majorAxisEndPoint,t.majorAxisEndPoint)&&this.numberEqual(e.axisRatio,t.axisRatio)&&this.numberEqual(e.startAngle,t.startAngle)&&this.numberEqual(e.endAngle,t.endAngle))}attDefsEqual(e,t){return!(!this.pointsEqual(e.startPoint,t.startPoint)||!this.pointsEqual(e.endPoint,t.endPoint)||!this.numberEqual(e.xScale,t.xScale)||e.text!==t.text||e.tag!==t.tag||e.prompt!==t.prompt)}attribsEqual(e,t){return this.attDefsEqual(e,t)}hatchesEqual(e,t){let n=e,i=t;return!!(this.numberEqual(n.elevationX,i.elevationX)&&this.numberEqual(n.elevationY,i.elevationY)&&this.numberEqual(n.elevationZ,i.elevationZ)&&this.hatchBoundaryPathArraysEqual(n.boundaryPaths,i.boundaryPaths))}viewportsEqual(e,t){let n=e,i=t;return!!(this.pointsEqual(n.centerPoint,i.centerPoint)&&this.pointsEqual(n.centerPoint_dcs,i.centerPoint_dcs)&&this.pointsEqual(n.viewDirection,i.viewDirection)&&this.numberEqual(n.viewHeight,i.viewHeight)&&n.width_paperSpace===i.width_paperSpace&&n.height_paperSpace===i.height_paperSpace)}leadersEqual(e,t){return!!(this.pointsEqual(e.position,t.position)&&this.verticesEqual(e.vertices,t.vertices)&&e.arrowHeadBlockHandle===t.arrowHeadBlockHandle&&this.numberEqual(e.arrowHeadSize,t.arrowHeadSize)&&this.numberEqual(e.rotation,t.rotation)&&e.block===t.block)}mleadersEqual(e,t){return!(e.arrowHeadId!==t.arrowHeadId||!this.numberEqual(e.arrowHeadSize,t.arrowHeadSize))&&this.mleaderContextEqual(e.contextData,t.contextData)}ole2framesEqual(e,t){return!(e.leftUpX!==t.leftUpX||e.leftUpY!==t.leftUpY||e.leftUpZ!==t.leftUpZ||e.rightDownX!==t.rightDownX||e.rightDownY!==t.rightDownY||e.rightDownZ!==t.rightDownZ)}insertsEqual(e,t){var n,i,r,a;return"INSERT"===(null==(n=e.extendedData)?void 0:n.originalType)&&"INSERT"===(null==(i=t.extendedData)?void 0:i.originalType)?(se.warn(`[DxfCompare] We cannot compare insert (handle '${e.handle}') yet, ignored!`),!0):!!(this.pointsEqual(e.position,t.position)&&this.numberEqual(void 0===e.xScale?1:e.xScale,void 0===t.xScale?1:t.xScale)&&this.numberEqual(void 0===e.yScale?1:e.yScale,void 0===t.yScale?1:t.yScale)&&this.numberEqual(void 0===e.zScale?1:e.zScale,void 0===t.zScale?1:t.zScale)&&e.block===t.block&&(null==(r=e.entities)?void 0:r.length)===(null==(a=t.entities)?void 0:a.length))}dimensionsEqual(e,t){return!!this.pointsEqual(e.anchorPoint,t.anchorPoint)}regionsEqual(e,t){return se.warn("Cannot compare region yet!"),!0}vectorsEqual(e,t){return!e&&!t||!(!e||!t)&&this.numberEqual(e.x,t.x)&&this.numberEqual(e.y,t.y)&&this.numberEqual(e.z,t.z)}pointsEqual(e,t){return!e&&!t||!(!e||!t)&&this.numberEqual(e.x,t.x)&&this.numberEqual(e.y,t.y)&&this.numberEqual(e.z,t.z)&&this.numberEqual(e.bulge,t.bulge)}vertexEntityEqual(e,t){return!e&&!t||!(!e||!t)&&!(!this.pointsEqual(e,t)||e.polyfaceMeshVertex!==t.polyfaceMeshVertex||e.threeDPolylineMesh!==t.threeDPolylineMesh)}numbersEqual(e,t){if(!e&&!t)return!0;if(e&&t){if(e.length!==t.length)return!1;for(let n=0;n{let t={};return GE.forEach(((e,n)=>t[e]=n)),t})(),Jht=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,aa=String.fromCharCode.bind(String),Rpe="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),Ipe=e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>"+"==e?"-":"_")),Lpe=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),Dpe=e=>{let t,n,i,r,a="",s=e.length%3;for(let o=0;o255||(i=e.charCodeAt(o++))>255||(r=e.charCodeAt(o++))>255)throw new TypeError("invalid character found");t=n<<16|i<<8|r,a+=GE[t>>18&63]+GE[t>>12&63]+GE[t>>6&63]+GE[63&t]}return s?a.slice(0,s-3)+"===".substring(s):a},$5=Zht?e=>btoa(e):hy?e=>Buffer.from(e,"binary").toString("base64"):Dpe,X5=hy?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let n=0,i=e.length;nt?Ipe(X5(e)):X5(e),Qht=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?aa(192|t>>>6)+aa(128|63&t):aa(224|t>>>12&15)+aa(128|t>>>6&63)+aa(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return aa(240|t>>>18&7)+aa(128|t>>>12&63)+aa(128|t>>>6&63)+aa(128|63&t)},edt=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Ope=e=>e.replace(edt,Qht),Ape=hy?e=>Buffer.from(e,"utf8").toString("base64"):Mpe?e=>X5(Mpe.encode(e)):e=>$5(Ope(e)),uy=(e,t=!1)=>t?Ipe(Ape(e)):Ape(e),Cpe=e=>uy(e,!0),tdt=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,ndt=e=>{switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return aa(55296+(t>>>10))+aa(56320+(1023&t));case 3:return aa((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return aa((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},kpe=e=>e.replace(tdt,ndt),Fpe=e=>{if(e=e.replace(/\s+/g,""),!Jht.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let t,n,i,r="";for(let a=0;a>16&255):64===i?aa(t>>16&255,t>>8&255):aa(t>>16&255,t>>8&255,255&t);return r},Z5=$ht?e=>atob(Lpe(e)):hy?e=>Buffer.from(e,"base64").toString("binary"):Fpe,Npe=hy?e=>Rpe(Buffer.from(e,"base64")):e=>Rpe(Z5(e).split("").map((e=>e.charCodeAt(0)))),Bpe=e=>Npe(Upe(e)),rdt=hy?e=>Buffer.from(e,"base64").toString("utf8"):Spe?e=>Spe.decode(Npe(e)):e=>kpe(Z5(e)),Upe=e=>Lpe(e.replace(/[-_]/g,(e=>"-"==e?"+":"/"))),Y5=e=>rdt(Upe(e)),idt=e=>{if("string"!=typeof e)return!1;let t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},Hpe=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),Vpe=function(){let e=(e,t)=>Object.defineProperty(String.prototype,e,Hpe(t));e("fromBase64",(function(){return Y5(this)})),e("toBase64",(function(e){return uy(this,e)})),e("toBase64URI",(function(){return uy(this,!0)})),e("toBase64URL",(function(){return uy(this,!0)})),e("toUint8Array",(function(){return Bpe(this)}))},zpe=function(){let e=(e,t)=>Object.defineProperty(Uint8Array.prototype,e,Hpe(t));e("toBase64",(function(e){return bC(this,e)})),e("toBase64URI",(function(){return bC(this,!0)})),e("toBase64URL",(function(){return bC(this,!0)}))},sdt=()=>{Vpe(),zpe()},Gpe={version:Ppe,VERSION:Yht,atob:Z5,atobPolyfill:Fpe,btoa:$5,btoaPolyfill:Dpe,fromBase64:Y5,toBase64:uy,encode:uy,encodeURI:Cpe,encodeURL:Cpe,utob:Ope,btou:kpe,decode:Y5,isValid:idt,fromUint8Array:bC,toUint8Array:Bpe,extendString:Vpe,extendUint8Array:zpe,extendBuiltins:sdt},Vl=ji(ome(),1),EC=new Qe,vdt=new Qe,Lc=class{static resetMergeInfo(){this.mergeInfo.removedObjects=0,this.mergeInfo.mergedMeshes=0,this.mergeInfo.mergedLines=0,this.mergeInfo.mergedPoints=0,this.mergeInfo.mergedUnknownTypeObjects=0,this.mergeInfo.elapsedTime=0}static merge(e,t=!0){let n=Date.now();this.mergeInner(e,t),this.mergeInfo.elapsedTime+=Date.now()-n}static mergeInner(e,t=!0){if(!e.children||e.children.length<1)return;let n=e.children.length,i={},r=[];for(let h=0;h0){this.mergeInner(n,t);continue}if(n.userData.relativeToCenter||!n.geometry)continue;let a=!1,s=Object.values(i);for(let t=s.length-1;t>=0;--t){let n=s[t].indexes[0];if(a=this.tryHandleMergeableObjects(e,h,n,i,r),a)break}for(let t=r.length-1;!a&&t>=0;--t){let n=r[t];if(a=this.tryHandleMergeableObjects(e,h,n,i,r),a)break}a||r.push(h)}if(Object.keys(i).length<=0)return;let a=[],s=[],o=[],l=[];Object.values(i).forEach((n=>{let i,r=n.indexes,h=e.children[r[0]],c=[],u=0,d=0,p=0,f=[];if(r.forEach((n=>{var i,r,a,s;let o=e.children[n],l=null==(i=o.geometry)?void 0:i.clone();if(l.applyMatrix4(o.matrix),l.userData.isLineSegments=3===o.type,c.push(l),t){let e=null==(a=null==(r=l.attributes)?void 0:r.position)?void 0:a.count,t=(null==(s=l.index)?void 0:s.count)||0;f.push({batchId:u,positionStart:d,positionCount:e,indexStart:p,indexCount:t}),d+=e,p+=t,u++}})),0!==c.length){if(4===h.type){let e=Ni(c);if(!e)return;e.userData={},i=new bn(h.type),i.geometry=e,i.material=h.material,a.push(i)}else if(2===h.type||3===h.type){let e=Ar.mergeLineGeometries(c,t,h.material instanceof Iu||h.material instanceof cn,f);if(!e)return;i=new bn(3),i.geometry=e,i.material=h.material,s.push(i)}else if(1===h.type){let e=Ni(c);if(!e)return;e.userData={},i=new bn(h.type),i.geometry=e,i.material=h.material,o.push(i)}i&&(t?i.userData.batches=f:(i.userData=h.userData,i.userData.batches=void 0),i.userData.layerName=h.userData.layerName,i.name=`[Merged] ${h.name}`,i.renderOrder=h.renderOrder,i.layers.mask=h.layers.mask,l.push(...r)),c.forEach((e=>{e.dispose(),Qt.releaseGeometryManually(e)})),c=[]}})),l.sort(((e,t)=>t-e)),l.forEach((t=>{let n=e.children[t];e.remove(n)})),[...a,...s,...o].forEach((t=>{e.add(t)})),this.mergeInfo.removedObjects+=l.length,this.mergeInfo.mergedMeshes+=a.length,this.mergeInfo.mergedLines+=s.length,this.mergeInfo.mergedPoints+=o.length}static tryHandleMergeableObjects(e,t,n,i,r){let a=!1,s=Array.isArray(e),o=s?e.length:e.children.length;if(t===n||t>=o||n>=o)return a;let l=s?e[t]:e.children[t],h=s?e[n]:e.children[n];return this.areObjectsMergeable(l,h)&&Ar.areGeometriesMergeable(l.geometry,h.geometry)&&es.materialsEquals(l.material,h.material)&&(i[n]||(i[n]={indexes:[n]},this.removeFromArray(r,n)),i[n].indexes.push(t),a=!0),a}static isFilteredByOtherFactors(e,t){let n=e;if(4===n.type&&n.material&&n.material.isShaderMaterial)return!0;let i=!1,r=e;for(;r&&r!==t;){let e=r.userData;if(e.relativeToCenter||e.spatialFilterHandle){i=!0;break}r=r.parent}return i}static deepMerge(e,t=void 0,n=!0,i=!0,r=!0){let a={added:[],removed:[]};if(e.length<=1)return a;let s=Date.now(),o={},l=[];for(let m=0;m=0;--t){let r=i[t].indexes[0];if(n=this.tryHandleMergeableObjects(e,m,r,o,l),n)break}for(let t=l.length-1;!n&&t>=0;--t){let i=l[t];if(n=this.tryHandleMergeableObjects(e,m,i,o,l),n)break}n||l.push(m)}if(Object.keys(o).length<=0)return a;se.debug(`[Merge] Built merged indexes for ${e.length} objects in ${(Date.now()-s)/1e3}s`),s=Date.now();let h=[],c=[],u=[],d=[];Object.values(o).forEach((n=>{let i=n.indexes;if(i.length<2)return;let a,s=e[i[0]],o=[],l=0,p=0,f=0,m=[];if(i.forEach((n=>{var i,a,h,c,u;let d=e[n],g=null==(i=d.geometry)?void 0:i.clone();if(s.material instanceof Gn&&g.deleteAttribute("lineDistance"),this.applyMatrix(g,d,t),g.userData.isLineSegments=3===d.type,o.push(g),r){let e,t=null==(h=null==(a=g.attributes)?void 0:a.position)?void 0:h.count,n=(null==(c=g.index)?void 0:c.count)||0;(2===s.type||3===s.type)&&(g.boundingSphere||g.computeBoundingSphere(),e=null==(u=g.boundingSphere)?void 0:u.clone()),m.push({batchId:l,positionStart:p,positionCount:t,indexStart:f,indexCount:n,boundingSphere:e}),p+=t,f+=n,l++}})),0!==o.length){if(4===s.type){let e=Ni(o);if(!e)return;e.userData={},a=new bn(s.type),a.geometry=e,a.material=s.material,h.push(a)}else if(2===s.type||3===s.type){let e=Ar.mergeLineGeometries(o,r,s.material instanceof Iu||s.material instanceof cn,m);if(!e)return;a=new bn(3),a.geometry=e,a.material=s.material,c.push(a)}else if(1===s.type){let e=Ni(o);if(!e)return;e.userData={},a=new bn(s.type),a.geometry=e,a.material=s.material,u.push(a)}a&&(r?a.userData.batches=m:(a.userData=s.userData,a.userData.batches=void 0),a.userData.layerName=s.userData.layerName,a.name=`[Merged] ${s.name}`,a.renderOrder=s.renderOrder,a.layers.mask=s.layers.mask,i.forEach((e=>d.push(e)))),o.forEach((e=>{e.dispose(),Qt.releaseGeometryManually(e)})),o=[]}})),se.debug(`[Merge] Ran deepMerge() in ${(Date.now()-s)/1e3}s`);let p=a.removed;d.forEach((t=>{let i=e[t];p.push(i),n&&i.removeFromParent()}));let f=a.added;return[...h,...c,...u].forEach((e=>{f.push(e),n&&t&&t.add(e)})),this.mergeInfo.removedObjects+=d.length,this.mergeInfo.mergedMeshes+=h.length,this.mergeInfo.mergedLines+=c.length,this.mergeInfo.mergedPoints+=u.length,i&&t&&zn.removeEmptyObjects(t),a}static applyMatrix(e,t,n){let i=t;for(EC.identity();i&&i!==n&&(EC.premultiply(i.matrix),i.parent);)i=i.parent;return EC.equals(vdt)?e:e.applyMatrix4(EC)}static removeFromArray(e,t){for(let n=e.length-1;n>=0;--n)if(e[n]===t)return void e.splice(n,1)}static areObjectsMergeable(e,t){return e.layers.mask===t.layers.mask&&e.renderOrder===t.renderOrder&&e.userData.layerName===t.userData.layerName&&(e.type===t.type||!(2!==e.type&&3!==e.type||2!==t.type&&3!==t.type))}};function lme(e,t,n,i){let r={u_cameraZoom:n,u_patternLines:{value:e},u_patternAngle:{value:t},u_color:{value:i}},a=`\n uniform mat4 modelMatrix;\n uniform float u_cameraZoom;\n uniform vec3 u_color;\n varying vec3 v_pos;\n\n struct PatternLine {\n vec2 origin;\n vec2 delta;\n float angle;\n float pattern[MAX_PATTERN_SEGMENT_COUNT];\n float patternSum[MAX_PATTERN_SEGMENT_COUNT+1];\n float patternLength;\n };\n\n uniform PatternLine u_patternLines[${e.length}];\n uniform float u_patternAngle;\n\n #include \n\n // Clamp [0..1] range\n #define saturate(a) clamp(a, 0.0, 1.0)\n\n const float EPS = 1000.0;\n\n vec2 getWorldScale() {\n return vec2(length(modelMatrix[0].xyz), length(modelMatrix[1].xyz));\n }\n\n vec2 rotate(vec2 st, float rotation) {\n const float PI = 3.1415926;\n float angle = rotation * PI/180.0;\n float sine = sin(angle), cosine = cos(angle);\n return vec2(cosine * st.x - sine * st.y, cosine * st.y + sine * st.x);\n }\n\n vec2 translate(vec2 samplePosition, vec2 offset) {\n //move sample point in the opposite direction that we want to move shapes in\n return samplePosition - offset;\n }\n\n vec2 scale(vec2 samplePosition, float scale) {\n return samplePosition / scale;\n }\n\n float sdfLine(vec2 st, vec2 a, vec2 b) {\n vec2 ap = st - a;\n vec2 ab = b - a;\n return abs(((ap.x * ab.y) - (ab.x * ap.y))) / length(ab);\n }\n\n float drawSpaceLine(vec2 st, float distanceBetweenLines, float thick) {\n float dist = sdfLine(st , vec2(0.0, 0.0) , vec2(1.0, 0.0));\n \n //vec2 tt = dFdy(st);\n //float scale = (abs(tt.x)+abs(tt.y))/2.0;\n //float scale = length(fwidth(st)) * 0.5;\n // close to a pixel\n //float thick = 2.0;\n //thick = (thick * 0.5 - 0.5) * scale;\n\n float lineDistance = abs(fract(dist / distanceBetweenLines + 0.5) - 0.5) * distanceBetweenLines;\n //float lineDistance = fract(dist / distanceBetweenLines);\n //float distanceChange = fwidth(dist) * 0.5;\n //float threshold = smoothstep(thick - distanceChange, thick + distanceChange, lineDistance);\n //float threshold = step(thick,lineDistance);\n // remove gradient\n //float threshold = step(0.001,lineDistance);\n float threshold = step(thick,lineDistance);\n\n return threshold;\n }\n\n float drawSolidLine(PatternLine patternLine, float thick) {\n vec2 origin = patternLine.origin;\n vec2 delta = patternLine.delta;\n float distanceBetweenLines = length(delta);\n\n origin = rotate(origin,u_patternAngle);\n vec2 st = rotate(v_pos.xy - origin, -(patternLine.angle + u_patternAngle));\n\n return drawSpaceLine(st, distanceBetweenLines , thick);\n }\n\n int getPatternIndex(PatternLine patternLine, float u, out float distance ) {\n //u = mod(u, patternLine.patternLength);\n float y = floor(u/patternLine.patternLength);\n u = u - patternLine.patternLength * y;\n //float distance = 0.0;\n\n #pragma unroll_loop_start\n for(int i = 1; i < patternLine.patternSum.length(); i++){\n if(u <= patternLine.patternSum[i]) {\n distance = u - patternLine.patternSum[i-1];\n return i - 1;\n }\n }\n #pragma unroll_loop_end\n\n return -1;\n }\n\n float drawDashedLine(PatternLine patternLine, float thick){\n float threshold = 1.0;\n vec2 origin = patternLine.origin;\n vec2 delta = patternLine.delta; \n float distanceBetweenLines = abs(delta.y);\n\n origin = rotate(origin, u_patternAngle);\n vec2 st = rotate(v_pos.xy - origin, -(patternLine.angle + u_patternAngle));\n\n float offsetX = st.y * delta.x/delta.y;\n float u = st.x - offsetX;\n float distance = 0.0;\n int index = getPatternIndex(patternLine, u, distance);\n if(index < 0) {\n return threshold;\n }\n\n float size = patternLine.pattern[index];\n if(size >= 0.0) {\n threshold = drawSpaceLine(st, distanceBetweenLines , thick);\n // Try to solve the problem caused by the precision after zooming out by drawing a part of the dashed line\n } else if (distance < thick) {\n //threshold = 0.8;\n threshold = drawSpaceLine(st, distanceBetweenLines , thick);\n }\n \n return threshold;\n }\n\n float drawLine(PatternLine patternLine, float thick) {\n float t = 0.0;\n if(patternLine.patternLength > 0.0) {\n t = drawDashedLine(patternLine, thick);\n } else {\n t = drawSolidLine(patternLine, thick);\n }\n return t;\n }\n\n void main() {\n #include \n \n vec2 worldScale = getWorldScale();\n float averageScale = (abs(worldScale.x) + abs(worldScale.y))/2.0;\n // possible size of a pixel \n float thick = (0.7 / averageScale) / u_cameraZoom;\n\n if(thick > EPS) {\n gl_FragColor = vec4(u_color, 1.0);\n #include \n return;\n }\n\n float total = 0.0;\n\n#if ${e.length} > 1\n #pragma unroll_loop_start\n for (int i = 0; i < u_patternLines.length(); i++) {\n PatternLine pl = u_patternLines[i];\n float t = drawLine(pl, thick);\n total += (1.0 - t);\n }\n #pragma unroll_loop_end\n#else\n float t = drawLine(u_patternLines[0], thick);\n total += (1.0 - t);\n#endif\n\n total = saturate(total);\n if (total < 0.001) {\n discard;\n }\n\n gl_FragColor = vec4(u_color * total, 1.0);\n #include \n }\n `;return new cn({uniforms:r,vertexShader:"\n varying vec3 v_pos;\n\n #include \n void main() {\n //vec4 worldPosition = modelMatrix * vec4(position, 1.0);\n v_pos = position;\n\n #include \n #include \n #include \n }",fragmentShader:a,clipping:!0})}Lc.mergeInfo={removedObjects:0,mergedMeshes:0,mergedLines:0,mergedPoints:0,mergedUnknownTypeObjects:0,elapsedTime:0};var _C=class{static createLineShaderMaterial(e,t,n,i,r){let a=0,s=[];for(let h=0;h\n\n vec2 getWorldScale() {\n return vec2(length(modelMatrix[0].xyz), length(modelMatrix[1].xyz));\n }\n\n void main() {\n\n #include \n\n // vec2 worldScale = getWorldScale();\n // float averageScale = (abs(worldScale.x) + abs(worldScale.y))/2.0;\n // When zoomed out to a certain extent, it is displayed as a solid line.\n if(patternLength * u_viewportScale * u_cameraZoom/1.5 < 1.0){\n gl_FragColor = vec4(u_color, opacity);\n #include \n return;\n }\n\n float pos = mod(vLineDistance, patternLength * u_viewportScale);\n\n for ( int i = 0; i < ${e.length}; i++ ) {\n pos = pos - abs(pattern[i] * u_viewportScale);\n if ( pos < 0.0 ) {\n if ( pattern[i] > 0.0 ) {\n gl_FragColor = vec4(u_color, opacity);\n break;\n }\n discard;\n }\n }\n #include \n }`;return new cn({uniforms:o,vertexShader:"\n attribute float lineDistance;\n varying float vLineDistance;\n\n #include \n\n void main() {\n vLineDistance = lineDistance;\n\n #include \n #include \n #include \n }",fragmentShader:l,clipping:!0})}},e6={};FT(e6,{default:()=>Q5});var J5={};FT(J5,{default:()=>K5});var K5=(e,t)=>void 0===t||0==+t?Math.round(e):(e=+e,t=+t,isNaN(e)||"number"!=typeof t||t%1!=0?NaN:(e=e.toString().split("e"),+((e=(e=Math.round(+(e[0]+"e"+(e[1]?+e[1]-t:-t)))).toString().split("e"))[0]+"e"+(e[1]?+e[1]+t:t)))),Q5=(e,t,n,i,r)=>{let a=n.length,s=n[0].length;if(e<0||e>1)throw new Error("t out of bounds [0,1]: "+e);if(t<1)throw new Error("degree must be at least 1 (linear)");if(t>a-1)throw new Error("degree must be less than or equal to point count - 1");if(i){if(i.length!==a+t+1)throw new Error("bad knot vector length")}else{i=[];for(let e=0;e=i[o]&&e<=i[o+1]);o++);let u,d=[];for(let f=0;fo-t-1+f;n--){u=(e-i[n])/(i[n+t+1-f]-i[n]);for(let e=0;e{if(!e)return[];e=e.replace(/%%(.)/g,((e,t)=>ydt[t]||t));let n,i=null==t?void 0:t.encoding,r=i instanceof TextDecoder?i:void 0,a="",s=[],o=e=>{a&&(s.push(a),a=""),s.push(e)};for(let l=0;l(e=Edt(e),t?_dt(e,t):e),Edt=e=>e.replace(/\\[uU]\+([0-9a-fA-F]{4})/g,((e,t)=>String.fromCodePoint(parseInt(t,16)))),_dt=(e,t)=>{let n=t instanceof TextDecoder?t:new TextDecoder(t);return e.replace(/\\[mM]\+[0|1]([0-9a-fA-F]{2})([0-9a-fA-F]{2})/g,((e,i,r)=>(n=n||new TextDecoder(t)).decode(new Uint8Array([parseInt(i,16),parseInt(r,16)]))))},wC=(e,t)=>{let n=0,i={text:""},r=[i],a=(e=bdt(e,null==t?void 0:t.encoding)).matchAll(/%%(\d\d\d|.)/g);for(let s of a){i.text+=e.slice(n,s.index);let t=s[1].toLowerCase(),a=xdt[t];a?i.text+=a:3===t.length?i.text+=String.fromCodePoint(+t):"k"===t||"o"===t||"u"===t?(i=Ri(wr({},i),{text:""}),i[t]?delete i[t]:i[t]=1,r.push(i)):i.text+=t,n=s.index+s[0].length}return i.text+=e.slice(n),r.filter((e=>e.text))},t6=(e=>(e.Unitless="Unitless",e.Inches="Inches",e.Feet="Feet",e.Millimeters="Millimeters",e.Centimeters="Centimeters",e.Meters="Meters",e))(t6||{}),cme=e=>"Unitless"===e?1:"Inches"===e?.0254:"Feet"===e?.3048:"Millimeters"===e?.001:"Centimeters"===e?.01:("Meters"===e||console.warn(`[Units] Unsupported unit '${e}', will return 1 for unit scale.`),1),ume=(e,t)=>cme(e)/cme(t),SC=class extends ta{constructor(e,t={}){let n=t.font;if(void 0===n)super();else{let i=n.generateShapes(e,t.size);t.depth=void 0!==t.height?t.height:50,void 0===t.bevelThickness&&(t.bevelThickness=10),void 0===t.bevelSize&&(t.bevelSize=8),void 0===t.bevelEnabled&&(t.bevelEnabled=!1),super(i,t)}this.type="TextGeometry"}},MC=class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){let n=[],i=Tdt(e,t,this.data);for(let r=0,a=i.length;rwindow.localStorage.getItem(hme),Mdt=()=>{window.localStorage.setItem(hme,$E)},dme=()=>Sdt()!==$E&&(Mdt(),!0),dy=class{constructor(){this.DATABASE_NAME="gemini_viewer_db",this.TABLES=[{name:"viewpoint",options:{keyPath:"id",autoIncrement:!0},indexArray:[]},{name:"annotation",options:{keyPath:"id",autoIncrement:!0},indexArray:[]},{name:"dxfdata",options:{keyPath:"dxfDataId",autoIncrement:!1},indexArray:[]},{name:"fontdata",options:{keyPath:"fileName",autoIncrement:!0},indexArray:[]}],this.db=void 0}static instance(){return dy._instance||(dy._instance=new dy),dy._instance}getDatabase(){return ft(this,null,(function*(){let e=yield this.getDB(this.DATABASE_NAME);return this.db||(e.close(),dme()&&(yield this.deleteDataBase(this.DATABASE_NAME)),e=yield this.getUpgradedDB(e)),e.onclose=()=>{this.db=void 0,se.debug(`[DB] Db ${e.name} is closed.`)},e.onerror=t=>{this.db=void 0,se.debug(`[DB] Db ${e.name} encountered error.`,t)},e.onabort=t=>{this.db=void 0,se.debug(`[DB] Db ${e.name} aborted.`,t)},e.onversionchange=e=>{se.debug("onversionchange",e)},this.db=e,Promise.resolve(this.db)}))}closeDatabase(){this.db&&this.db.close()}deleteDataBase(e){return new Promise(((t,n)=>{let i=window.indexedDB.deleteDatabase(e);i.onerror=e=>{se.debug(e),n(e)},i.onsuccess=n=>{let i=n.target;se.debug(`[DB] Db ${e} delete old version ${n.oldVersion}.`),t(i)}}))}getDB(e){return ft(this,null,(function*(){return new Promise(((t,n)=>{let i=window.indexedDB.open(e);i.onerror=n,i.onsuccess=e=>{let n=e.target.result;se.debug(`[DB] Db ${n.name} opened (version ${n.version}).`),t(n)}}))}))}getUpgradedDB(e){return ft(this,null,(function*(){return new Promise(((t,n)=>{se.debug(`[DB] Upgrading db ${e.name} (version ${e.version})`);let i=window.indexedDB.open(e.name,e.version+1);i.onerror=n,i.onblocked=e=>{se.debug("onblocked",e)},i.onupgradeneeded=e=>{e.target.transaction.oncomplete=()=>{se.debug(`[DB] Upgrade is done (new version: ${t.version}).`)};let t=e.target.result,n=[];for(let i=0;i0&&Promise.all(n).then((()=>{se.debug(`[DB] All(${n.length}) tables created.`)}))},i.onsuccess=e=>{let n=e.target.result;se.debug(`[DB] Db ${n.name} opened (version ${n.version}).`),t(n)}}))}))}createTable(e,t,n,i){return ft(this,null,(function*(){return new Promise((r=>{let a=e.createObjectStore(t,n);i&&i.forEach((e=>{a.createIndex(e.name,e.fields,{unique:e.unique})})),se.debug(`[DB] Table ${t} created.`),r(e)}))}))}},ns=dy;ns._instance=void 0;var Wu=class{constructor(){if(this.db=void 0,this.isCreatingTable=!1,-1===ns.instance().TABLES.findIndex((e=>e.name===this.tableName())))throw new Error(`Make sure to add table '${this.tableName()}' to IndexedDbManager.TABLES!`)}tableName(){throw new Error("Derived class have to override 'tableName', and set a proper table name!")}add(e,t,n){let i=this.tableName();ns.instance().getDatabase().then((r=>{let a=r.transaction([i],"readwrite").objectStore(i).add(e);a.onsuccess=t,a.onerror=n})).finally((()=>{ns.instance().closeDatabase()})).catch((e=>{n&&n(e)}))}save(e,t,n){let i=this.tableName();ns.instance().getDatabase().then((r=>{let a=r.transaction([i],"readwrite").objectStore(i).put(e);a.onsuccess=t,a.onerror=n})).finally((()=>{ns.instance().closeDatabase()}))}delete(e,t,n){let i=this.tableName();ns.instance().getDatabase().then((r=>{let a=r.transaction([i],"readwrite").objectStore(i).delete(e);a.onsuccess=t,a.onerror=n})).finally((()=>{ns.instance().closeDatabase()}))}update(){ns.instance().getDatabase().then((()=>{}))}query(e,t){let n=this.tableName();ns.instance().getDatabase().then((i=>{let r=i.transaction([n],"readonly").objectStore(n).openCursor();r.onsuccess=t=>{let n=t.target.result;n&&n.continue(),e&&e(n)},r.onerror=t})).finally((()=>{ns.instance().closeDatabase()}))}queryByIndex(e,t,n,i){let r=this.tableName();ns.instance().getDatabase().then((a=>{let s=a.transaction([r],"readonly").objectStore(r).index(e).get(t);s.onerror=i,s.onsuccess=function(e){var t;let i=null==(t=e.target)?void 0:t.result;n&&n(i)}})).finally((()=>{ns.instance().closeDatabase()}))}queryAll(e,t){let n=this.tableName();ns.instance().getDatabase().then((i=>{let r=i.transaction([n],"readonly").objectStore(n).getAll();r.onsuccess=t=>{e&&e(r.result)},r.onerror=t})).finally((()=>{ns.instance().closeDatabase()}))}clearAll(e,t){let n=this.tableName();ns.instance().getDatabase().then((i=>{let r=i.transaction([n],"readwrite").objectStore(n).clear();r.onsuccess=t=>{e&&e(t)},r.onerror=e=>{t&&t(e)}})).finally((()=>{ns.instance().closeDatabase()}))}},fy=class extends Wu{tableName(){return"annotation"}static instance(){return fy._instance||(fy._instance=new fy),fy._instance}query(e,t,n){let i=[];super.query((n=>{n?!n.value||n.value.projectId!==e||i.push(n.value):t&&t(i)}),(e=>{console.log(e)}))}},n6=fy;n6._instance=void 0;var py=class extends Wu{tableName(){return"viewpoint"}static instance(){return py._instance||(py._instance=new py),py._instance}query(e,t,n){let i=[];super.query((n=>{n?!n.value||n.value.projectId!==e||i.push(n.value):t&&t(i)}),(e=>{n&&n(),console.log(e)}))}},r6=py;r6._instance=void 0;var my=class extends Wu{tableName(){return"dxfdata"}static instance(){return my._instance||(my._instance=new my),my._instance}query(e,t,n){let i=[],r=this.tableName();ns.instance().getDatabase().then((a=>{let s=a.transaction([r],"readonly").objectStore(r).get(e);s.onerror=e=>{n&&n(e),se.info("[DxfDataTable] Failed to query !",e)},s.onsuccess=()=>{s.result&&i.push(s.result),t&&t(i)}})).finally((()=>{ns.instance().closeDatabase()}))}},gy=my;gy._instance=void 0;var Ym=class extends Wu{tableName(){return"fontdata"}static instance(){return Ym._instance||(Ym._instance=new Ym),Ym._instance}query(e){let t;return new Promise(((n,i)=>{super.query((i=>{i?!i.value||i.value.fileName!==e||(t=i.value):n(t)}),(e=>{i(e)}))}))}queryAll(){return ft(this,null,(function*(){return new Promise(((e,t)=>{uG(Ym.prototype,this,"queryAll").call(this,(t=>{e(t)}),(e=>{t(e)}))}))}))}},id=Ym;id._instance=void 0;var vy=class extends MC{constructor(e,t){super(t),this.info="",this.orientation=0,this.baseUp=0,this.baseDown=0,this.fileHeader="",this.fileVersion="",this.order=0,this.unsupportedChars={},this.fileName=e}addUnsupportedChar(e){this.unsupportedChars[e]||(this.unsupportedChars[e]=0),this.unsupportedChars[e]++}getFontFile(){return{order:this.order,data:this.data,info:this.info,orientation:this.orientation,baseUp:this.baseUp,baseDown:this.baseDown,fileName:this.fileName,fileHeader:this.fileHeader,fileVersion:this.fileVersion}}setFontFile(e){this.fileName=e.fileName,this.data=e.data,this.info=e.info,this.order=e.order,this.orientation=e.orientation,this.baseUp=e.baseUp,this.baseDown=e.baseDown,this.fileHeader=e.fileHeader,this.fileVersion=e.fileVersion}setFontDataToIndexedDb(){return ft(this,null,(function*(){let e=this.getFontFile();return new Promise(((t,n)=>{id.instance().save(e,(()=>{console.log(`[FontFile] Saved '${this.fileName}' (${this.fileHeader}) to indexedDb`),t()}),(e=>n(`[FontFile] Failed to save '${this.fileName}' (${this.fileHeader}) to indexedDb! ${e}`)))}))}))}getFontDataByIndexedDb(){return ft(this,null,(function*(){return id.instance().query(this.fileName)}))}releaseFontData(){this.data={}}};String.prototype.codePointAt||function(){var e=function(){try{var e={},t=Object.defineProperty,n=t(e,e,e)&&t}catch(e){}return n}(),t=function(e){if(null==this)throw TypeError();var t=String(this),n=t.length,i=e?Number(e):0;if(i!=i&&(i=0),!(i<0||i>=n)){var r,a=t.charCodeAt(i);return a>=55296&&a<=56319&&n>i+1&&(r=t.charCodeAt(i+1))>=56320&&r<=57343?1024*(a-55296)+r-56320+65536:a}};e?e(String.prototype,"codePointAt",{value:t,configurable:!0,writable:!0}):String.prototype.codePointAt=t}();var _6=0,Jme=-3;function JE(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function Rdt(e,t){this.source=e,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=t,this.destLen=0,this.ltree=new JE,this.dtree=new JE}var Qme=new JE,ege=new JE,T6=new Uint8Array(30),w6=new Uint16Array(30),tge=new Uint8Array(30),nge=new Uint16Array(30),Adt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fme=new JE,ju=new Uint8Array(320);function rge(e,t,n,i){var r,a;for(r=0;r>>=1,t}function Xu(e,t,n){if(!t)return n;for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>16-t;return e.tag>>>=t,e.bitcount-=t,i+n}function f6(e,t){for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>=1,++r,n+=t.table[r],i-=t.table[r]}while(i>=0);return e.tag=a,e.bitcount-=r,t.trans[n+i]}function Idt(e,t,n){var i,r,a,s,o,l;for(i=Xu(e,5,257),r=Xu(e,5,1),a=Xu(e,4,4),s=0;s<19;++s)ju[s]=0;for(s=0;s8;)e.sourceIndex--,e.bitcount-=8;if((t=256*(t=e.source[e.sourceIndex+1])+e.source[e.sourceIndex])!==(65535&~(256*e.source[e.sourceIndex+3]+e.source[e.sourceIndex+2])))return Jme;for(e.sourceIndex+=4,n=t;n;--n)e.dest[e.destLen++]=e.source[e.sourceIndex++];return e.bitcount=0,_6}function Ddt(e,t){var n,i,r=new Rdt(e,t);do{switch(n=Pdt(r),Xu(r,2,0)){case 0:i=Ldt(r);break;case 1:i=mme(r,Qme,ege);break;case 2:Idt(r,r.ltree,r.dtree),i=mme(r,r.ltree,r.dtree);break;default:i=Jme}if(i!==_6)throw new Error("Data error")}while(!n);return r.destLenthis.x2&&(this.x2=e)),"number"==typeof t&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=t,this.y2=t),tthis.y2&&(this.y2=t))},Ff.prototype.addX=function(e){this.addPoint(e,null)},Ff.prototype.addY=function(e){this.addPoint(null,e)},Ff.prototype.addBezier=function(e,t,n,i,r,a,s,o){var l=[e,t],h=[n,i],c=[r,a],u=[s,o];this.addPoint(e,t),this.addPoint(s,o);for(var d=0;d<=1;d++){var p=6*l[d]-12*h[d]+6*c[d],f=-3*l[d]+9*h[d]-9*c[d]+3*u[d],m=3*h[d]-3*l[d];if(0!==f){var g=Math.pow(p,2)-4*m*f;if(!(g<0)){var v=(-p+Math.sqrt(g))/(2*f);0=0&&i>0&&(n+=" "),n+=t(r)}return n}e=void 0!==e?e:2;for(var i="",r=0;r"},Fs.prototype.toDOMElement=function(e){var t=this.toPathData(e),n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",t),n};var Yn={fail:ige,argument:gme,assert:gme},vme=32768,yme=2147483648,by={},nn={},Qn={};function Fc(e){return function(){return e}}nn.BYTE=function(e){return Yn.argument(e>=0&&e<=255,"Byte value should be between 0 and 255."),[e]},Qn.BYTE=Fc(1),nn.CHAR=function(e){return[e.charCodeAt(0)]},Qn.CHAR=Fc(1),nn.CHARARRAY=function(e){void 0===e&&(e="",console.warn("Undefined CHARARRAY encountered and treated as an empty string. This is probably caused by a missing glyph name."));for(var t=[],n=0;n>8&255,255&e]},Qn.USHORT=Fc(2),nn.SHORT=function(e){return e>=vme&&(e=-(2*vme-e)),[e>>8&255,255&e]},Qn.SHORT=Fc(2),nn.UINT24=function(e){return[e>>16&255,e>>8&255,255&e]},Qn.UINT24=Fc(3),nn.ULONG=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]},Qn.ULONG=Fc(4),nn.LONG=function(e){return e>=yme&&(e=-(2*yme-e)),[e>>24&255,e>>16&255,e>>8&255,255&e]},Qn.LONG=Fc(4),nn.FIXED=nn.ULONG,Qn.FIXED=Qn.ULONG,nn.FWORD=nn.SHORT,Qn.FWORD=Qn.SHORT,nn.UFWORD=nn.USHORT,Qn.UFWORD=Qn.USHORT,nn.LONGDATETIME=function(e){return[0,0,0,0,e>>24&255,e>>16&255,e>>8&255,255&e]},Qn.LONGDATETIME=Fc(8),nn.TAG=function(e){return Yn.argument(4===e.length,"Tag should be exactly 4 ASCII characters."),[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]},Qn.TAG=Fc(4),nn.Card8=nn.BYTE,Qn.Card8=Qn.BYTE,nn.Card16=nn.USHORT,Qn.Card16=Qn.USHORT,nn.OffSize=nn.BYTE,Qn.OffSize=Qn.BYTE,nn.SID=nn.USHORT,Qn.SID=Qn.USHORT,nn.NUMBER=function(e){return e>=-107&&e<=107?[e+139]:e>=108&&e<=1131?[247+((e-=108)>>8),255&e]:e>=-1131&&e<=-108?[251+((e=-e-108)>>8),255&e]:e>=-32768&&e<=32767?nn.NUMBER16(e):nn.NUMBER32(e)},Qn.NUMBER=function(e){return nn.NUMBER(e).length},nn.NUMBER16=function(e){return[28,e>>8&255,255&e]},Qn.NUMBER16=Fc(3),nn.NUMBER32=function(e){return[29,e>>24&255,e>>16&255,e>>8&255,255&e]},Qn.NUMBER32=Fc(5),nn.REAL=function(e){var t=e.toString(),n=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(t);if(n){var i=parseFloat("1e"+((n[2]?+n[2]:0)+n[1].length));t=(Math.round(e*i)/i).toString()}for(var r="",a=0,s=t.length;a>8&255,t[t.length]=255&i}return t},Qn.UTF16=function(e){return 2*e.length};var p6={"x-mac-croatian":"\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\u2020\xb0\xa2\xa3\xa7\u2022\xb6\xdf\xae\u0160\u2122\xb4\xa8\u2260\u017d\xd8\u221e\xb1\u2264\u2265\u2206\xb5\u2202\u2211\u220f\u0161\u222b\xaa\xba\u03a9\u017e\xf8\xbf\xa1\xac\u221a\u0192\u2248\u0106\xab\u010c\u2026\xa0\xc0\xc3\xd5\u0152\u0153\u0110\u2014\u201c\u201d\u2018\u2019\xf7\u25ca\uf8ff\xa9\u2044\u20ac\u2039\u203a\xc6\xbb\u2013\xb7\u201a\u201e\u2030\xc2\u0107\xc1\u010d\xc8\xcd\xce\xcf\xcc\xd3\xd4\u0111\xd2\xda\xdb\xd9\u0131\u02c6\u02dc\xaf\u03c0\xcb\u02da\xb8\xca\xe6\u02c7","x-mac-cyrillic":"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041a\u041b\u041c\u041d\u041e\u041f\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042a\u042b\u042c\u042d\u042e\u042f\u2020\xb0\u0490\xa3\xa7\u2022\xb6\u0406\xae\xa9\u2122\u0402\u0452\u2260\u0403\u0453\u221e\xb1\u2264\u2265\u0456\xb5\u0491\u0408\u0404\u0454\u0407\u0457\u0409\u0459\u040a\u045a\u0458\u0405\xac\u221a\u0192\u2248\u2206\xab\xbb\u2026\xa0\u040b\u045b\u040c\u045c\u0455\u2013\u2014\u201c\u201d\u2018\u2019\xf7\u201e\u040e\u045e\u040f\u045f\u2116\u0401\u0451\u044f\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043a\u043b\u043c\u043d\u043e\u043f\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044a\u044b\u044c\u044d\u044e","x-mac-gaelic":"\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\u2020\xb0\xa2\xa3\xa7\u2022\xb6\xdf\xae\xa9\u2122\xb4\xa8\u2260\xc6\xd8\u1e02\xb1\u2264\u2265\u1e03\u010a\u010b\u1e0a\u1e0b\u1e1e\u1e1f\u0120\u0121\u1e40\xe6\xf8\u1e41\u1e56\u1e57\u027c\u0192\u017f\u1e60\xab\xbb\u2026\xa0\xc0\xc3\xd5\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\u1e61\u1e9b\xff\u0178\u1e6a\u20ac\u2039\u203a\u0176\u0177\u1e6b\xb7\u1ef2\u1ef3\u204a\xc2\xca\xc1\xcb\xc8\xcd\xce\xcf\xcc\xd3\xd4\u2663\xd2\xda\xdb\xd9\u0131\xdd\xfd\u0174\u0175\u1e84\u1e85\u1e80\u1e81\u1e82\u1e83","x-mac-greek":"\xc4\xb9\xb2\xc9\xb3\xd6\xdc\u0385\xe0\xe2\xe4\u0384\xa8\xe7\xe9\xe8\xea\xeb\xa3\u2122\xee\xef\u2022\xbd\u2030\xf4\xf6\xa6\u20ac\xf9\xfb\xfc\u2020\u0393\u0394\u0398\u039b\u039e\u03a0\xdf\xae\xa9\u03a3\u03aa\xa7\u2260\xb0\xb7\u0391\xb1\u2264\u2265\xa5\u0392\u0395\u0396\u0397\u0399\u039a\u039c\u03a6\u03ab\u03a8\u03a9\u03ac\u039d\xac\u039f\u03a1\u2248\u03a4\xab\xbb\u2026\xa0\u03a5\u03a7\u0386\u0388\u0153\u2013\u2015\u201c\u201d\u2018\u2019\xf7\u0389\u038a\u038c\u038e\u03ad\u03ae\u03af\u03cc\u038f\u03cd\u03b1\u03b2\u03c8\u03b4\u03b5\u03c6\u03b3\u03b7\u03b9\u03be\u03ba\u03bb\u03bc\u03bd\u03bf\u03c0\u03ce\u03c1\u03c3\u03c4\u03b8\u03c9\u03c2\u03c7\u03c5\u03b6\u03ca\u03cb\u0390\u03b0\xad","x-mac-icelandic":"\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\xdd\xb0\xa2\xa3\xa7\u2022\xb6\xdf\xae\xa9\u2122\xb4\xa8\u2260\xc6\xd8\u221e\xb1\u2264\u2265\xa5\xb5\u2202\u2211\u220f\u03c0\u222b\xaa\xba\u03a9\xe6\xf8\xbf\xa1\xac\u221a\u0192\u2248\u2206\xab\xbb\u2026\xa0\xc0\xc3\xd5\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\xf7\u25ca\xff\u0178\u2044\u20ac\xd0\xf0\xde\xfe\xfd\xb7\u201a\u201e\u2030\xc2\xca\xc1\xcb\xc8\xcd\xce\xcf\xcc\xd3\xd4\uf8ff\xd2\xda\xdb\xd9\u0131\u02c6\u02dc\xaf\u02d8\u02d9\u02da\xb8\u02dd\u02db\u02c7","x-mac-inuit":"\u1403\u1404\u1405\u1406\u140a\u140b\u1431\u1432\u1433\u1434\u1438\u1439\u1449\u144e\u144f\u1450\u1451\u1455\u1456\u1466\u146d\u146e\u146f\u1470\u1472\u1473\u1483\u148b\u148c\u148d\u148e\u1490\u1491\xb0\u14a1\u14a5\u14a6\u2022\xb6\u14a7\xae\xa9\u2122\u14a8\u14aa\u14ab\u14bb\u14c2\u14c3\u14c4\u14c5\u14c7\u14c8\u14d0\u14ef\u14f0\u14f1\u14f2\u14f4\u14f5\u1505\u14d5\u14d6\u14d7\u14d8\u14da\u14db\u14ea\u1528\u1529\u152a\u152b\u152d\u2026\xa0\u152e\u153e\u1555\u1556\u1557\u2013\u2014\u201c\u201d\u2018\u2019\u1558\u1559\u155a\u155d\u1546\u1547\u1548\u1549\u154b\u154c\u1550\u157f\u1580\u1581\u1582\u1583\u1584\u1585\u158f\u1590\u1591\u1592\u1593\u1594\u1595\u1671\u1672\u1673\u1674\u1675\u1676\u1596\u15a0\u15a1\u15a2\u15a3\u15a4\u15a5\u15a6\u157c\u0141\u0142","x-mac-ce":"\xc4\u0100\u0101\xc9\u0104\xd6\xdc\xe1\u0105\u010c\xe4\u010d\u0106\u0107\xe9\u0179\u017a\u010e\xed\u010f\u0112\u0113\u0116\xf3\u0117\xf4\xf6\xf5\xfa\u011a\u011b\xfc\u2020\xb0\u0118\xa3\xa7\u2022\xb6\xdf\xae\xa9\u2122\u0119\xa8\u2260\u0123\u012e\u012f\u012a\u2264\u2265\u012b\u0136\u2202\u2211\u0142\u013b\u013c\u013d\u013e\u0139\u013a\u0145\u0146\u0143\xac\u221a\u0144\u0147\u2206\xab\xbb\u2026\xa0\u0148\u0150\xd5\u0151\u014c\u2013\u2014\u201c\u201d\u2018\u2019\xf7\u25ca\u014d\u0154\u0155\u0158\u2039\u203a\u0159\u0156\u0157\u0160\u201a\u201e\u0161\u015a\u015b\xc1\u0164\u0165\xcd\u017d\u017e\u016a\xd3\xd4\u016b\u016e\xda\u016f\u0170\u0171\u0172\u0173\xdd\xfd\u0137\u017b\u0141\u017c\u0122\u02c7",macintosh:"\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\u2020\xb0\xa2\xa3\xa7\u2022\xb6\xdf\xae\xa9\u2122\xb4\xa8\u2260\xc6\xd8\u221e\xb1\u2264\u2265\xa5\xb5\u2202\u2211\u220f\u03c0\u222b\xaa\xba\u03a9\xe6\xf8\xbf\xa1\xac\u221a\u0192\u2248\u2206\xab\xbb\u2026\xa0\xc0\xc3\xd5\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\xf7\u25ca\xff\u0178\u2044\u20ac\u2039\u203a\ufb01\ufb02\u2021\xb7\u201a\u201e\u2030\xc2\xca\xc1\xcb\xc8\xcd\xce\xcf\xcc\xd3\xd4\uf8ff\xd2\xda\xdb\xd9\u0131\u02c6\u02dc\xaf\u02d8\u02d9\u02da\xb8\u02dd\u02db\u02c7","x-mac-romanian":"\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\u2020\xb0\xa2\xa3\xa7\u2022\xb6\xdf\xae\xa9\u2122\xb4\xa8\u2260\u0102\u0218\u221e\xb1\u2264\u2265\xa5\xb5\u2202\u2211\u220f\u03c0\u222b\xaa\xba\u03a9\u0103\u0219\xbf\xa1\xac\u221a\u0192\u2248\u2206\xab\xbb\u2026\xa0\xc0\xc3\xd5\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\xf7\u25ca\xff\u0178\u2044\u20ac\u2039\u203a\u021a\u021b\u2021\xb7\u201a\u201e\u2030\xc2\xca\xc1\xcb\xc8\xcd\xce\xcf\xcc\xd3\xd4\uf8ff\xd2\xda\xdb\xd9\u0131\u02c6\u02dc\xaf\u02d8\u02d9\u02da\xb8\u02dd\u02db\u02c7","x-mac-turkish":"\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\u2020\xb0\xa2\xa3\xa7\u2022\xb6\xdf\xae\xa9\u2122\xb4\xa8\u2260\xc6\xd8\u221e\xb1\u2264\u2265\xa5\xb5\u2202\u2211\u220f\u03c0\u222b\xaa\xba\u03a9\xe6\xf8\xbf\xa1\xac\u221a\u0192\u2248\u2206\xab\xbb\u2026\xa0\xc0\xc3\xd5\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\xf7\u25ca\xff\u0178\u011e\u011f\u0130\u0131\u015e\u015f\u2021\xb7\u201a\u201e\u2030\xc2\xca\xc1\xcb\xc8\xcd\xce\xcf\xcc\xd3\xd4\uf8ff\xd2\xda\xdb\xd9\uf8a0\u02c6\u02dc\xaf\u02d8\u02d9\u02da\xb8\u02dd\u02db\u02c7"};by.MACSTRING=function(e,t,n,i){var r=p6[i];if(void 0!==r){for(var a="",s=0;s=-128&&e<=127}function Fdt(e,t,n){for(var i=0,r=e.length;t>8&255,l+256&255)}return a}nn.MACSTRING=function(e,t){var n=kdt(t);if(void 0!==n){for(var i=[],r=0;r=128&&void 0===(a=n[a]))return;i[r]=a}return i}},Qn.MACSTRING=function(e,t){var n=nn.MACSTRING(e,t);return void 0!==n?n.length:0},nn.VARDELTAS=function(e){for(var t=0,n=[];t=-128&&i<=127?Ndt(e,t,n):Bdt(e,t,n)}return n},nn.INDEX=function(e){for(var t=1,n=[t],i=[],r=0;r>8,t[u+1]=255&d,t=t.concat(i[c])}return t},Qn.TABLE=function(e){for(var t=0,n=e.fields.length,i=0;i0)return new _t(this.data,this.offset+t).parseStruct(e)},_t.prototype.parsePointer32=function(e){var t=this.parseOffset32();if(t>0)return new _t(this.data,this.offset+t).parseStruct(e)},_t.prototype.parseListOfLists=function(e){for(var t=this.parseOffset16List(),n=t.length,i=this.relativeOffset,r=new Array(n),a=0;a>1,t.skip("uShort",3),e.glyphIndexMap={};for(var s=new Tn.Parser(n,i+r+14),o=new Tn.Parser(n,i+r+16+2*a),l=new Tn.Parser(n,i+r+16+4*a),h=new Tn.Parser(n,i+r+16+6*a),c=i+r+16+8*a,u=0;u=0;r-=1){var a=Tn.getUShort(e,t+4+8*r),s=Tn.getUShort(e,t+4+8*r+2);if(3===a&&(0===s||1===s||10===s)||0===a&&(0===s||1===s||2===s||3===s||4===s)){i=Tn.getULong(e,t+4+8*r+4);break}}if(-1===i)throw new Error("No valid cmap sub-tables found.");var o=new Tn.Parser(e,t+i);if(n.format=o.parseUShort(),12===n.format)Wdt(n,o);else{if(4!==n.format)throw new Error("Only format 4 and 12 cmap tables are supported (found format "+n.format+").");jdt(n,o,e,t,i)}return n}function Ydt(e,t,n){e.segments.push({end:t,start:t,delta:-(t-n),offset:0,glyphIndex:n})}function $dt(e){e.segments.push({end:65535,start:65535,delta:1,offset:0})}function Zdt(e){var t,n=!0;for(t=e.length-1;t>0;t-=1)if(e.get(t).unicode>65535){console.log("Adding CMAP format 12 (needed!)"),n=!1;break}var i=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:n?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:n?12:20}];n||(i=i.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),i=i.concat([{name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);var r=new pn.Table("cmap",i);for(r.segments=[],t=0;t>4,a=15&i;if(15===r||(t+=n[r],15===a))break;t+=n[a]}return parseFloat(t)}function uft(e,t){if(28===t)return e.parseByte()<<8|e.parseByte();if(29===t)return e.parseByte()<<24|e.parseByte()<<16|e.parseByte()<<8|e.parseByte();if(30===t)return cft(e);if(t>=32&&t<=246)return t-139;if(t>=247&&t<=250)return 256*(t-247)+e.parseByte()+108;if(t>=251&&t<=254)return 256*-(t-251)-e.parseByte()-108;throw new Error("Invalid b0 "+t)}function hft(e){for(var t={},n=0;n>1,d.length=0,f=!0}return function n(h){for(var y,x,S,M,E,T,A,C,P,R,O,L,I=0;I1&&!f&&(b=d.shift()+c,f=!0),v+=d.pop(),_(g,v);break;case 5:for(;d.length>0;)g+=d.shift(),v+=d.shift(),u.lineTo(g,v);break;case 6:for(;d.length>0&&(g+=d.shift(),u.lineTo(g,v),0!==d.length);)v+=d.shift(),u.lineTo(g,v);break;case 7:for(;d.length>0&&(v+=d.shift(),u.lineTo(g,v),0!==d.length);)g+=d.shift(),u.lineTo(g,v);break;case 8:for(;d.length>0;)i=g+d.shift(),r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+d.shift(),u.curveTo(i,r,a,s,g,v);break;case 10:E=d.pop()+l,(T=o[E])&&n(T);break;case 11:return;case 12:switch(D=h[I],I+=1,D){case 35:i=g+d.shift(),r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),A=a+d.shift(),C=s+d.shift(),P=A+d.shift(),R=C+d.shift(),O=P+d.shift(),L=R+d.shift(),g=O+d.shift(),v=L+d.shift(),d.shift(),u.curveTo(i,r,a,s,A,C),u.curveTo(P,R,O,L,g,v);break;case 34:i=g+d.shift(),r=v,a=i+d.shift(),s=r+d.shift(),A=a+d.shift(),C=s,P=A+d.shift(),R=s,O=P+d.shift(),L=v,g=O+d.shift(),u.curveTo(i,r,a,s,A,C),u.curveTo(P,R,O,L,g,v);break;case 36:i=g+d.shift(),r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),A=a+d.shift(),C=s,P=A+d.shift(),R=s,O=P+d.shift(),L=R+d.shift(),g=O+d.shift(),u.curveTo(i,r,a,s,A,C),u.curveTo(P,R,O,L,g,v);break;case 37:i=g+d.shift(),r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),A=a+d.shift(),C=s+d.shift(),P=A+d.shift(),R=C+d.shift(),O=P+d.shift(),L=R+d.shift(),Math.abs(O-g)>Math.abs(L-v)?g=O+d.shift():v=L+d.shift(),u.curveTo(i,r,a,s,A,C),u.curveTo(P,R,O,L,g,v);break;default:console.log("Glyph "+t.index+": unknown operator 1200"+D),d.length=0}break;case 14:d.length>0&&!f&&(b=d.shift()+c,f=!0),m&&(u.closePath(),m=!1);break;case 19:case 20:w(),I+=p+7>>3;break;case 21:d.length>2&&!f&&(b=d.shift()+c,f=!0),v+=d.pop(),_(g+=d.pop(),v);break;case 22:d.length>1&&!f&&(b=d.shift()+c,f=!0),_(g+=d.pop(),v);break;case 24:for(;d.length>2;)i=g+d.shift(),r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+d.shift(),u.curveTo(i,r,a,s,g,v);g+=d.shift(),v+=d.shift(),u.lineTo(g,v);break;case 25:for(;d.length>6;)g+=d.shift(),v+=d.shift(),u.lineTo(g,v);i=g+d.shift(),r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+d.shift(),u.curveTo(i,r,a,s,g,v);break;case 26:for(d.length%2&&(g+=d.shift());d.length>0;)i=g,r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),g=a,v=s+d.shift(),u.curveTo(i,r,a,s,g,v);break;case 27:for(d.length%2&&(v+=d.shift());d.length>0;)i=g+d.shift(),r=v,a=i+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s,u.curveTo(i,r,a,s,g,v);break;case 28:y=h[I],x=h[I+1],d.push((y<<24|x<<16)>>16),I+=2;break;case 29:E=d.pop()+e.gsubrsBias,(T=e.gsubrs[E])&&n(T);break;case 30:for(;d.length>0&&(i=g,r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+(1===d.length?d.shift():0),u.curveTo(i,r,a,s,g,v),0!==d.length);)i=g+d.shift(),r=v,a=i+d.shift(),s=r+d.shift(),v=s+d.shift(),g=a+(1===d.length?d.shift():0),u.curveTo(i,r,a,s,g,v);break;case 31:for(;d.length>0&&(i=g+d.shift(),r=v,a=i+d.shift(),s=r+d.shift(),v=s+d.shift(),g=a+(1===d.length?d.shift():0),u.curveTo(i,r,a,s,g,v),0!==d.length);)i=g,r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+(1===d.length?d.shift():0),u.curveTo(i,r,a,s,g,v);break;default:D<32?console.log("Glyph "+t.index+": unknown operator "+D):D<247?d.push(D-139):D<251?(y=h[I],I+=1,d.push(256*(D-247)+y+108)):D<255?(y=h[I],I+=1,d.push(256*-(D-251)-y-108)):(y=h[I],x=h[I+1],S=h[I+2],M=h[I+3],I+=4,d.push((y<<24|x<<16|S<<8|M)/65536))}}}(n),t.advanceWidth=b,u}function gft(e,t,n,i){var r,a=[],s=new Tn.Parser(e,t),o=s.parseCard8();if(0===o)for(var l=0;l=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+r+" (FD count "+i+")");a.push(r)}else{if(3!==o)throw new Error("CFF Table CID Font FDSelect table has unsupported format "+o);var h=s.parseCard16(),c=s.parseCard16();if(0!==c)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+c);for(var u,d=0;d=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+r+" (FD count "+i+")");if(u>n)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+u);for(;c=0&&(n=i),(i=t.indexOf(e))>=0?n=i+DC.length:(n=DC.length+t.length,t.push(e)),n}function yft(){return new pn.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function xft(e){var t=new pn.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);t.names=[];for(var n=0;n=n.begin&&e=1&&(n.ulCodePageRange1=i.parseULong(),n.ulCodePageRange2=i.parseULong()),n.version>=2&&(n.sxHeight=i.parseShort(),n.sCapHeight=i.parseShort(),n.usDefaultChar=i.parseUShort(),n.usBreakChar=i.parseUShort(),n.usMaxContent=i.parseUShort()),n}function Yft(e){return new pn.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],e)}var b6={parse:Xft,make:Yft,unicodeRanges:x6,getUnicodeRange:jft};function $ft(e,t){var n={},i=new Tn.Parser(e,t);switch(n.version=i.parseVersion(),n.italicAngle=i.parseFixed(),n.underlinePosition=i.parseShort(),n.underlineThickness=i.parseShort(),n.isFixedPitch=i.parseULong(),n.minMemType42=i.parseULong(),n.maxMemType42=i.parseULong(),n.minMemType1=i.parseULong(),n.maxMemType1=i.parseULong(),n.version){case 1:n.names=Zm.slice();break;case 2:n.numberOfGlyphs=i.parseUShort(),n.glyphNameIndex=new Array(n.numberOfGlyphs);for(var r=0;r=Zm.length){var s=i.parseChar();n.names.push(i.parseString(s))}break;case 2.5:n.numberOfGlyphs=i.parseUShort(),n.offset=new Array(n.numberOfGlyphs);for(var o=0;ot.value.tag?1:-1})),t.fields=t.fields.concat(i),t.fields=t.fields.concat(r),t}function Cme(e,t,n){for(var i=0;i0)return e.glyphs.get(r).getMetrics()}return n}function tpt(e){for(var t=0,n=0;ng||void 0===t)&&g>0&&(t=g),h 123 are reserved for internal usage");p|=1<0?Ege.make(L):void 0,k=Age.make(),N=vge.make(e.glyphs,{version:e.getEnglishName("version"),fullName:C,familyName:T,weightName:A,postScriptName:P,unitsPerEm:e.unitsPerEm,fontBBox:[0,x.yMin,x.ascender,x.advanceWidthMax]}),F=e.metas&&Object.keys(e.metas).length>0?Pge.make(e.metas):void 0,U=[b,_,w,S,I,E,k,N,M];D&&U.push(D),e.tables.gsub&&U.push(Cge.make(e.tables.gsub)),F&&U.push(F);for(var B=Ige(U),z=A6(B.encode()),H=B.fields,V=!1,j=0;j>>1,a=e[r].tag;if(a===t)return r;a>>1,a=e[r];if(a===t)return r;a>>1,s=(n=e[a]).start;if(s===t)return n;s0)return t>(n=e[i-1]).end?0:n}function n_(e,t){this.font=e,this.tableName=t}function r_(e){n_.call(this,e,"gpos")}function tl(e){n_.call(this,e,"gsub")}function ipt(e,t){var n=e.length;if(n!==t.length)return!1;for(var i=0;i0?(a=e.parseByte(),t&r||(a=-a),a=n+a):a=(t&r)>0?n:n+e.parseShort(),a}function Lge(e,t,n){var i,r,a=new Tn.Parser(t,n);if(e.numberOfContours=a.parseShort(),e._xMin=a.parseShort(),e._yMin=a.parseShort(),e._xMax=a.parseShort(),e._yMax=a.parseShort(),e.numberOfContours>0){for(var s=e.endPointIndices=[],o=0;o0)for(var u=a.parseByte(),d=0;d0){var p,f=[];if(h>0){for(var m=0;m=0,f.push(p);for(var g=0,v=0;v0?(2&i)>0?(_.dx=a.parseShort(),_.dy=a.parseShort()):_.matchedPoints=[a.parseUShort(),a.parseUShort()]:(2&i)>0?(_.dx=a.parseChar(),_.dy=a.parseChar()):_.matchedPoints=[a.parseByte(),a.parseByte()],(8&i)>0?_.xScale=_.yScale=a.parseF2Dot14():(64&i)>0?(_.xScale=a.parseF2Dot14(),_.yScale=a.parseF2Dot14()):(128&i)>0&&(_.xScale=a.parseF2Dot14(),_.scale01=a.parseF2Dot14(),_.scale10=a.parseF2Dot14(),_.yScale=a.parseF2Dot14()),e.components.push(_),b=!!(32&i)}if(256&i){e.instructionLength=a.parseUShort(),e.instructions=[];for(var w=0;wt.points.length-1||i.matchedPoints[1]>r.points.length-1)throw Error("Matched points out of range in "+t.name);var s=t.points[i.matchedPoints[0]],o=r.points[i.matchedPoints[1]],l={xScale:i.xScale,scale01:i.scale01,scale10:i.scale10,yScale:i.yScale,dx:0,dy:0};o=o6([o],l)[0],l.dx=s.x-o.x,l.dy=s.y-o.y,a=o6(r.points,l)}t.points=t.points.concat(a)}}return Dge(t.points)}function lpt(e,t,n,i){for(var r=new $u.GlyphSet(i),a=0;a=0)return i[r].script;if(t){var a={tag:e,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return i.splice(-1-r,0,a),a.script}}},getLangSysTable:function(e,t,n){var i=this.getScriptTable(e,n);if(i){if(!t||"dflt"===t||"DFLT"===t)return i.defaultLangSys;var r=a6(i.langSysRecords,t);if(r>=0)return i.langSysRecords[r].langSys;if(n){var a={tag:t,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return i.langSysRecords.splice(-1-r,0,a),a.langSys}}},getFeatureTable:function(e,t,n,i){var r=this.getLangSysTable(e,t,i);if(r){for(var a,s=r.featureIndexes,o=this.font.tables[this.tableName].features,l=0;l=o[h-1].tag,"Features must be added in alphabetical order."),a={tag:n,feature:{params:0,lookupListIndexes:[]}},o.push(a),s.push(h),a.feature}}},getLookupTables:function(e,t,n,i,r){var a=this.getFeatureTable(e,t,n,r),s=[];if(a){for(var o,l=a.lookupListIndexes,h=this.font.tables[this.tableName].lookups,c=0;c=0?n:-1;case 2:var i=Ime(e.ranges,t);return i?i.index+t-i.start:-1}},expandCoverage:function(e){if(1===e.format)return e.glyphs;for(var t=[],n=e.ranges,i=0;i1,'Multiple: "by" must be an array of two or more ids');var r=C6(this.getLookupTables(n,i,e,2,!0)[0],1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});Yn.assert(1===r.coverage.format,"Multiple: unable to modify coverage table format "+r.coverage.format);var a=t.sub,s=this.binSearch(r.coverage.glyphs,a);s<0&&(s=-1-s,r.coverage.glyphs.splice(s,0,a),r.sequences.splice(s,0,0)),r.sequences[s]=t.by},tl.prototype.addAlternate=function(e,t,n,i){var r=C6(this.getLookupTables(n,i,e,3,!0)[0],1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});Yn.assert(1===r.coverage.format,"Alternate: unable to modify coverage table format "+r.coverage.format);var a=t.sub,s=this.binSearch(r.coverage.glyphs,a);s<0&&(s=-1-s,r.coverage.glyphs.splice(s,0,a),r.alternateSets.splice(s,0,0)),r.alternateSets[s]=t.by},tl.prototype.addLigature=function(e,t,n,i){var r=this.getLookupTables(n,i,e,4,!0)[0],a=r.subtables[0];a||(a={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},r.subtables[0]=a),Yn.assert(1===a.coverage.format,"Ligature: unable to modify coverage table format "+a.coverage.format);var s=t.sub[0],o=t.sub.slice(1),l={ligGlyph:t.by,components:o},h=this.binSearch(a.coverage.glyphs,s);if(h>=0){for(var c=a.ligatureSets[h],u=0;u=176&&n<=183)r+=n-176+1;else if(n>=184&&n<=191)r+=2*(n-184+1);else if(t&&1===a&&27===n)break}while(a>0);e.ip=r}function Dme(e,t){exports.DEBUG&&console.log(t.step,"SVTCA["+e.axis+"]"),t.fv=t.pv=t.dpv=e}function Ome(e,t){exports.DEBUG&&console.log(t.step,"SPVTCA["+e.axis+"]"),t.pv=t.dpv=e}function kme(e,t){exports.DEBUG&&console.log(t.step,"SFVTCA["+e.axis+"]"),t.fv=e}function Fme(e,t){var n,i,r=t.stack,a=r.pop(),s=r.pop(),o=t.z2[a],l=t.z1[s];exports.DEBUG&&console.log("SPVTL["+e+"]",a,s),e?(n=o.y-l.y,i=l.x-o.x):(n=l.x-o.x,i=l.y-o.y),t.pv=t.dpv=s_(n,i)}function Nme(e,t){var n,i,r=t.stack,a=r.pop(),s=r.pop(),o=t.z2[a],l=t.z1[s];exports.DEBUG&&console.log("SFVTL["+e+"]",a,s),e?(n=o.y-l.y,i=l.x-o.x):(n=l.x-o.x,i=l.y-o.y),t.fv=s_(n,i)}function vpt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"SPVFS[]",n,i),e.pv=e.dpv=s_(i,n)}function ypt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"SPVFS[]",n,i),e.fv=s_(i,n)}function xpt(e){var t=e.stack,n=e.pv;exports.DEBUG&&console.log(e.step,"GPV[]"),t.push(16384*n.x),t.push(16384*n.y)}function bpt(e){var t=e.stack,n=e.fv;exports.DEBUG&&console.log(e.step,"GFV[]"),t.push(16384*n.x),t.push(16384*n.y)}function Ept(e){e.fv=e.pv,exports.DEBUG&&console.log(e.step,"SFVTPV[]")}function _pt(e){var t=e.stack,n=t.pop(),i=t.pop(),r=t.pop(),a=t.pop(),s=t.pop(),o=e.z0,l=e.z1,h=o[n],c=o[i],u=l[r],d=l[a],p=e.z2[s];exports.DEBUG&&console.log("ISECT[], ",n,i,r,a,s);var f=h.x,m=h.y,g=c.x,v=c.y,y=u.x,x=u.y,b=d.x,_=d.y,w=(f-g)*(x-_)-(m-v)*(y-b),S=f*v-m*g,M=y*_-x*b;p.x=(S*(y-b)-M*(f-g))/w,p.y=(S*(x-_)-M*(m-v))/w}function Tpt(e){e.rp0=e.stack.pop(),exports.DEBUG&&console.log(e.step,"SRP0[]",e.rp0)}function wpt(e){e.rp1=e.stack.pop(),exports.DEBUG&&console.log(e.step,"SRP1[]",e.rp1)}function Spt(e){e.rp2=e.stack.pop(),exports.DEBUG&&console.log(e.step,"SRP2[]",e.rp2)}function Mpt(e){var t=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SZP0[]",t),e.zp0=t,t){case 0:e.tZone||VC(e),e.z0=e.tZone;break;case 1:e.z0=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function Rpt(e){var t=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SZP1[]",t),e.zp1=t,t){case 0:e.tZone||VC(e),e.z1=e.tZone;break;case 1:e.z1=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function Apt(e){var t=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SZP2[]",t),e.zp2=t,t){case 0:e.tZone||VC(e),e.z2=e.tZone;break;case 1:e.z2=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function Cpt(e){var t=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SZPS[]",t),e.zp0=e.zp1=e.zp2=t,t){case 0:e.tZone||VC(e),e.z0=e.z1=e.z2=e.tZone;break;case 1:e.z0=e.z1=e.z2=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function Ppt(e){e.loop=e.stack.pop(),exports.DEBUG&&console.log(e.step,"SLOOP[]",e.loop)}function Ipt(e){exports.DEBUG&&console.log(e.step,"RTG[]"),e.round=Uge}function Lpt(e){exports.DEBUG&&console.log(e.step,"RTHG[]"),e.round=fpt}function Dpt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SMD[]",t),e.minDis=t/64}function Opt(e){exports.DEBUG&&console.log(e.step,"ELSE[]"),Vge(e,!1)}function kpt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"JMPR[]",t),e.ip+=t-1}function Fpt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCVTCI[]",t),e.cvCutIn=t/64}function Npt(e){var t=e.stack;exports.DEBUG&&console.log(e.step,"DUP[]"),t.push(t[t.length-1])}function l6(e){exports.DEBUG&&console.log(e.step,"POP[]"),e.stack.pop()}function Bpt(e){exports.DEBUG&&console.log(e.step,"CLEAR[]"),e.stack.length=0}function Upt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"SWAP[]"),t.push(n),t.push(i)}function Hpt(e){var t=e.stack;exports.DEBUG&&console.log(e.step,"DEPTH[]"),t.push(t.length)}function Vpt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"LOOPCALL[]",n,i);var r=e.ip,a=e.prog;e.prog=e.funcs[n];for(var s=0;s1?"loop "+(t.loop-o)+": ":"")+"SHP["+(e?"rp1":"rp2")+"]",h)}t.loop=1}function Vme(e,t){var n=t.stack,i=e?t.rp1:t.rp2,r=(e?t.z0:t.z1)[i],a=t.fv,s=t.pv,o=n.pop(),l=t.z2[t.contours[o]],h=l;exports.DEBUG&&console.log(t.step,"SHC["+e+"]",o);var c=s.distance(r,r,!1,!0);do{h!==r&&a.setRelative(h,h,c,s),h=h.nextPointOnContour}while(h!==l)}function zme(e,t){var n,i=t.stack,r=e?t.rp1:t.rp2,a=(e?t.z0:t.z1)[r],s=t.fv,o=t.pv,l=i.pop();switch(exports.DEBUG&&console.log(t.step,"SHZ["+e+"]",l),l){case 0:n=t.tZone;break;case 1:n=t.gZone;break;default:throw new Error("Invalid zone")}for(var h,c=o.distance(a,a,!1,!0),u=n.length-2,d=0;d1?"loop "+(e.loop-n)+": ":"")+"SHPIX[]",s,r),i.setRelative(o,o,r),i.touch(o)}e.loop=1}function Xpt(e){for(var t=e.stack,n=e.rp1,i=e.rp2,r=e.loop,a=e.z0[n],s=e.z1[i],o=e.fv,l=e.dpv,h=e.z2;r--;){var c=t.pop(),u=h[c];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-r)+": ":"")+"IP[]",c,n,"<->",i),o.interpolate(u,a,s,l),o.touch(u)}e.loop=1}function Gme(e,t){var n=t.stack,i=n.pop()/64,r=n.pop(),a=t.z1[r],s=t.z0[t.rp0],o=t.fv,l=t.pv;o.setRelative(a,s,i,l),o.touch(a),exports.DEBUG&&console.log(t.step,"MSIRP["+e+"]",i,r),t.rp1=t.rp0,t.rp2=r,e&&(t.rp0=r)}function Ypt(e){for(var t=e.stack,n=e.rp0,i=e.z0[n],r=e.loop,a=e.fv,s=e.pv,o=e.z1;r--;){var l=t.pop(),h=o[l];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-r)+": ":"")+"ALIGNRP[]",l),a.setRelative(h,i,0,s),a.touch(h)}e.loop=1}function $pt(e){exports.DEBUG&&console.log(e.step,"RTDG[]"),e.round=dpt}function qme(e,t){var n=t.stack,i=n.pop(),r=n.pop(),a=t.z0[r],s=t.fv,o=t.pv,l=t.cvt[i];exports.DEBUG&&console.log(t.step,"MIAP["+e+"]",i,"(",l,")",r);var h=o.distance(a,t_);e&&(Math.abs(h-l)",o),t.stack.push(Math.round(64*o))}function nmt(e){exports.DEBUG&&console.log(e.step,"MPPEM[]"),e.stack.push(e.ppem)}function rmt(e){exports.DEBUG&&console.log(e.step,"FLIPON[]"),e.autoFlip=!0}function imt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"LT[]",n,i),t.push(in?1:0)}function omt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"GTEQ[]",n,i),t.push(i>=n?1:0)}function lmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"EQ[]",n,i),t.push(n===i?1:0)}function cmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"NEQ[]",n,i),t.push(n!==i?1:0)}function umt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"ODD[]",n),t.push(Math.trunc(n)%2?1:0)}function hmt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"EVEN[]",n),t.push(Math.trunc(n)%2?0:1)}function dmt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"IF[]",t),t||(Vge(e,!0),exports.DEBUG&&console.log(e.step,"EIF[]"))}function fmt(e){exports.DEBUG&&console.log(e.step,"EIF[]")}function pmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"AND[]",n,i),t.push(n&&i?1:0)}function mmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"OR[]",n,i),t.push(n||i?1:0)}function gmt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"NOT[]",n),t.push(n?0:1)}function c6(e,t){var n=t.stack,i=n.pop(),r=t.fv,a=t.pv,s=t.ppem,o=t.deltaBase+16*(e-1),l=t.deltaShift,h=t.z0;exports.DEBUG&&console.log(t.step,"DELTAP["+e+"]",i,n);for(var c=0;c>4)===s){var p=(15&d)-8;p>=0&&p++,exports.DEBUG&&console.log(t.step,"DELTAPFIX",u,"by",p*l);var f=h[u];r.setRelative(f,f,p*l,a)}}}function vmt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SDB[]",t),e.deltaBase=t}function ymt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SDS[]",t),e.deltaShift=Math.pow(.5,t)}function xmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"ADD[]",n,i),t.push(i+n)}function bmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"SUB[]",n,i),t.push(i-n)}function Emt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"DIV[]",n,i),t.push(64*i/n)}function _mt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"MUL[]",n,i),t.push(i*n/64)}function Tmt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"ABS[]",n),t.push(Math.abs(n))}function wmt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"NEG[]",n),t.push(-n)}function Smt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"FLOOR[]",n),t.push(64*Math.floor(n/64))}function Mmt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"CEILING[]",n),t.push(64*Math.ceil(n/64))}function LC(e,t){var n=t.stack,i=n.pop();exports.DEBUG&&console.log(t.step,"ROUND[]"),n.push(64*t.round(i/64))}function Rmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"WCVTF[]",n,i),e.cvt[i]=n*e.ppem/e.font.unitsPerEm}function u6(e,t){var n=t.stack,i=n.pop(),r=t.ppem,a=t.deltaBase+16*(e-1),s=t.deltaShift;exports.DEBUG&&console.log(t.step,"DELTAC["+e+"]",i,n);for(var o=0;o>4)===r){var c=(15&h)-8;c>=0&&c++;var u=c*s;exports.DEBUG&&console.log(t.step,"DELTACFIX",l,"by",u),t.cvt[l]+=u}}}function Amt(e){var t,n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SROUND[]",n),e.round=Hge,192&n){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(e.srPeriod=t,48&n){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*t;break;case 32:e.srPhase=.5*t;break;case 48:e.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}n&=15,e.srThreshold=0===n?0:(n/8-.5)*t}function Cmt(e){var t,n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"S45ROUND[]",n),e.round=Hge,192&n){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(e.srPeriod=t,48&n){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*t;break;case 32:e.srPhase=.5*t;break;case 48:e.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}n&=15,e.srThreshold=0===n?0:(n/8-.5)*t}function Pmt(e){exports.DEBUG&&console.log(e.step,"ROFF[]"),e.round=hpt}function Imt(e){exports.DEBUG&&console.log(e.step,"RUTG[]"),e.round=ppt}function Lmt(e){exports.DEBUG&&console.log(e.step,"RDTG[]"),e.round=mpt}function Dmt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCANCTRL[]",t)}function Xme(e,t){var n,i,r=t.stack,a=r.pop(),s=r.pop(),o=t.z2[a],l=t.z1[s];exports.DEBUG&&console.log(t.step,"SDPVTL["+e+"]",a,s),e?(n=o.y-l.y,i=l.x-o.x):(n=l.x-o.x,i=l.y-o.y),t.dpv=s_(n,i)}function Omt(e){var t=e.stack,n=t.pop(),i=0;exports.DEBUG&&console.log(e.step,"GETINFO[]",n),1&n&&(i=35),32&n&&(i|=4096),t.push(i)}function kmt(e){var t=e.stack,n=t.pop(),i=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"ROLL[]"),t.push(i),t.push(n),t.push(r)}function Fmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"MAX[]",n,i),t.push(Math.max(i,n))}function Nmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"MIN[]",n,i),t.push(Math.min(i,n))}function Bmt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCANTYPE[]",t)}function Umt(e){var t=e.stack.pop(),n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"INSTCTRL[]",t,n),t){case 1:return void(e.inhibitGridFit=!!n);case 2:return void(e.ignoreCvt=!!n);default:throw new Error("invalid INSTCTRL[] selector")}}function Pf(e,t){var n=t.stack,i=t.prog,r=t.ip;exports.DEBUG&&console.log(t.step,"PUSHB["+e+"]");for(var a=0;a=0?1:-1,o=Math.abs(o),e&&(h=a.cvt[u],i&&Math.abs(o-h)":"_")+(i?"R":"_")+(0===r?"Gr":1===r?"Bl":2===r?"Wh":"")+"]",e?u+"("+a.cvt[u]+","+h+")":"",d,"(d =",s,"->",l*o,")"),a.rp1=a.rp0,a.rp2=d,t&&(a.rp0=d)}function _y(e){this.char=e,this.state={},this.activeState=null}function P6(e,t,n){this.contextName=n,this.startIndex=e,this.endOffset=t}function Hmt(e,t,n){this.contextName=e,this.openRange=null,this.ranges=[],this.checkStart=t,this.checkEnd=n}function Oc(e,t){this.context=e,this.index=t,this.length=e.length,this.current=e[t],this.backtrack=e.slice(0,t),this.lookahead=e.slice(t+1)}function zC(e){this.eventId=e,this.subscribers=[]}function Vmt(e){var t=this,n=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];n.forEach((function(e){Object.defineProperty(t.events,e,{value:new zC(e)})})),e&&n.forEach((function(n){var i=e[n];"function"==typeof i&&t.events[n].subscribe(i)})),["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"].forEach((function(e){t.events[e].subscribe(t.updateContextsRanges)}))}function hs(e){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],Vmt.call(this,e)}function Of(e){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(e)}function zge(e){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(e)}function kf(e){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(e)}function OC(e){return/[A-z]/.test(e)}function zmt(e){return/\s/.test(e)}function nl(e){this.font=e,this.features={}}function Km(e){this.id=e.id,this.tag=e.tag,this.substitution=e.substitution}function a_(e,t){if(!e)return-1;switch(t.format){case 1:return t.glyphs.indexOf(e);case 2:for(var n=t.ranges,i=0;i=r.start&&e<=r.end){var a=e-r.start;return r.index+a}}break;default:return-1}return-1}function Gmt(e,t){return-1===a_(e,t.coverage)?null:e+t.deltaGlyphId}function qmt(e,t){var n=a_(e,t.coverage);return-1===n?null:t.substitute[n]}function h6(e,t){for(var n=[],i=0;i2)){var n=this.font,i=this._prepState;if(!i||i.ppem!==t){var r=this._fpgmState;if(!r){Df.prototype=gpt,(r=this._fpgmState=new Df("fpgm",n.tables.fpgm)).funcs=[],r.font=n,exports.DEBUG&&(console.log("---EXEC FPGM---"),r.step=-1);try{Jm(r)}catch(e){return console.log("Hinting error in FPGM:"+e),void(this._errorState=3)}}Df.prototype=r,(i=this._prepState=new Df("prep",n.tables.prep)).ppem=t;var a=n.tables.cvt;if(a)for(var s=i.cvt=new Array(a.length),o=t/n.unitsPerEm,l=0;l1))try{return Nge(e,i)}catch(e){return this._errorState<1&&(console.log("Hinting error:"+e),console.log("Note: further hinting errors are silenced")),void(this._errorState=1)}}},Nge=function(e,t){var n,i,r,a=t.ppem/t.font.unitsPerEm,s=a,o=e.components;if(Df.prototype=t,o){var l=t.font;i=[],n=[];for(var h=0;h=0&&e0&&e<=this.lookahead.length:return this.lookahead[e-1];default:return null}},hs.prototype.rangeToText=function(e){if(e instanceof P6)return this.getRangeTokens(e).map((function(e){return e.char})).join("")},hs.prototype.getText=function(){return this.tokens.map((function(e){return e.char})).join("")},hs.prototype.getContext=function(e){return this.registeredContexts[e]||null},hs.prototype.on=function(e,t){var n=this.events[e];return n?n.subscribe(t):null},hs.prototype.dispatch=function(e,t){var n=this,i=this.events[e];i instanceof zC&&i.subscribers.forEach((function(e){e.apply(n,t||[])}))},hs.prototype.registerContextChecker=function(e,t,n){if(this.getContext(e))return{FAIL:"context name '"+e+"' is already registered."};if("function"!=typeof t)return{FAIL:"missing context start check."};if("function"!=typeof n)return{FAIL:"missing context end check."};var i=new Hmt(e,t,n);return this.registeredContexts[e]=i,this.contextCheckers.push(i),i},hs.prototype.getRangeTokens=function(e){var t=e.startIndex+e.endOffset;return[].concat(this.tokens.slice(e.startIndex,t))},hs.prototype.getContextRanges=function(e){var t=this.getContext(e);return t?t.ranges:{FAIL:"context checker '"+e+"' is not registered."}},hs.prototype.resetContextsRanges=function(){var e=this.registeredContexts;for(var t in e)e.hasOwnProperty(t)&&(e[t].ranges=[])},hs.prototype.updateContextsRanges=function(){this.resetContextsRanges();for(var e=this.tokens.map((function(e){return e.char})),t=0;t=0;n--){var i=t[n],r=zge(i),a=kf(i);if(!r&&!a)return!0;if(r)return!1}return!1}function sgt(e){if(zge(e.current))return!1;for(var t=0;t=1.2&&(r.markGlyphSets=n.parsePointer(Agt)),r}var Pgt={parse:Cgt},kc=new Array(10);function Igt(e,t){var n=new _t(e,t=t||0),i=n.parseVersion(1);return Yn.argument(1===i||1.1===i,"Unsupported GPOS table version "+i),1===i?{version:i,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(kc)}:{version:i,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(kc),variations:n.parseFeatureVariationsList()}}kc[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();return 1===t?{posFormat:1,coverage:this.parsePointer(_t.coverage),value:this.parseValueRecord()}:2===t?{posFormat:2,coverage:this.parsePointer(_t.coverage),values:this.parseValueRecordList()}:void Yn.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},kc[2]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();Yn.assert(1===t||2===t,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");var n=this.parsePointer(_t.coverage),i=this.parseUShort(),r=this.parseUShort();if(1===t)return{posFormat:t,coverage:n,valueFormat1:i,valueFormat2:r,pairSets:this.parseList(_t.pointer(_t.list((function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(i),value2:this.parseValueRecord(r)}}))))};if(2===t){var a=this.parsePointer(_t.classDef),s=this.parsePointer(_t.classDef),o=this.parseUShort(),l=this.parseUShort();return{posFormat:t,coverage:n,valueFormat1:i,valueFormat2:r,classDef1:a,classDef2:s,class1Count:o,class2Count:l,classRecords:this.parseList(o,_t.list(l,(function(){return{value1:this.parseValueRecord(i),value2:this.parseValueRecord(r)}})))}}},kc[3]=function(){return{error:"GPOS Lookup 3 not supported"}},kc[4]=function(){return{error:"GPOS Lookup 4 not supported"}},kc[5]=function(){return{error:"GPOS Lookup 5 not supported"}},kc[6]=function(){return{error:"GPOS Lookup 6 not supported"}},kc[7]=function(){return{error:"GPOS Lookup 7 not supported"}},kc[8]=function(){return{error:"GPOS Lookup 8 not supported"}},kc[9]=function(){return{error:"GPOS Lookup 9 not supported"}};var Lgt=new Array(10);function Dgt(e){return new pn.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new pn.ScriptList(e.scripts)},{name:"features",type:"TABLE",value:new pn.FeatureList(e.features)},{name:"lookups",type:"TABLE",value:new pn.LookupList(e.lookups,Lgt)}])}var Ogt={parse:Igt,make:Dgt};function kgt(e){var t={};e.skip("uShort");var n=e.parseUShort();Yn.argument(0===n,"Unsupported kern sub-table version."),e.skip("uShort",2);var i=e.parseUShort();e.skip("uShort",3);for(var r=0;r1&&console.warn("Only the first kern subtable is supported."),e.skip("uLong");var n=255&e.parseUShort();if(e.skip("uShort"),0===n){var i=e.parseUShort();e.skip("uShort",3);for(var r=0;r0;n--){let t=e[n],r={type:t.type};void 0!==t.x2&&void 0!==t.y2?(r.x1=t.x2,r.y1=t.y2,r.x2=t.x1,r.y2=t.y1):void 0!==t.x1&&void 0!==t.y1&&(r.x1=t.x1,r.y1=t.y1),r.x=e[n-1].x,r.y=e[n-1].y,i.push(r)}})),i}return function(e,n){let i=Math.round,r={},a=1e5/(72*(e.unitsPerEm||2048)),s=e.encoding.cmap.glyphIndexMap,o=Object.keys(s);for(let l=0;l0){let t=this.bounds.min,n=this.bounds.getSize(Ggt),i=new be(t.x,t.y),r=new be(t.x+n.width,t.y),a=new be(t.x+n.width,t.y+n.height),s=new be(t.x,t.y+n.height);e.push([i,r],[r,a],[a,s],[s,i])}let t=[],n=[],i=0,r=new Dt;for(let a=0;a>8}}return t.subarray(0,n)}var Wgt="\u554a\u963f\u57c3\u6328\u54ce\u5509\u54c0\u7691\u764c\u853c\u77ee\u827e\u788d\u7231\u9698\u978d\u6c28\u5b89\u4ffa\u6309\u6697\u5cb8\u80fa\u6848\u80ae\u6602\u76ce\u51f9\u6556\u71ac\u7ff1\u8884\u50b2\u5965\u61ca\u6fb3\u82ad\u634c\u6252\u53ed\u5427\u7b06\u516b\u75a4\u5df4\u62d4\u8dcb\u9776\u628a\u8019\u575d\u9738\u7f62\u7238\u767d\u67cf\u767e\u6446\u4f70\u8d25\u62dc\u7a17\u6591\u73ed\u642c\u6273\u822c\u9881\u677f\u7248\u626e\u62cc\u4f34\u74e3\u534a\u529e\u7eca\u90a6\u5e2e\u6886\u699c\u8180\u7ed1\u68d2\u78c5\u868c\u9551\u508d\u8c24\u82de\u80de\u5305\u8912\u5265\u8584\u96f9\u4fdd\u5821\u9971\u5b9d\u62b1\u62a5\u66b4\u8c79\u9c8d\u7206\u676f\u7891\u60b2\u5351\u5317\u8f88\u80cc\u8d1d\u94a1\u500d\u72c8\u5907\u60eb\u7119\u88ab\u5954\u82ef\u672c\u7b28\u5d29\u7ef7\u752d\u6cf5\u8e66\u8ff8\u903c\u9f3b\u6bd4\u9119\u7b14\u5f7c\u78a7\u84d6\u853d\u6bd5\u6bd9\u6bd6\u5e01\u5e87\u75f9\u95ed\u655d\u5f0a\u5fc5\u8f9f\u58c1\u81c2\u907f\u965b\u97ad\u8fb9\u7f16\u8d2c\u6241\u4fbf\u53d8\u535e\u8fa8\u8fa9\u8fab\u904d\u6807\u5f6a\u8198\u8868\u9cd6\u618b\u522b\u762a\u5f6c\u658c\u6fd2\u6ee8\u5bbe\u6448\u5175\u51b0\u67c4\u4e19\u79c9\u997c\u70b3\u75c5\u5e76\u73bb\u83e0\u64ad\u62e8\u94b5\u6ce2\u535a\u52c3\u640f\u94c2\u7b94\u4f2f\u5e1b\u8236\u8116\u818a\u6e24\u6cca\u9a73\u6355\u535c\u54fa\u8865\u57e0\u4e0d\u5e03\u6b65\u7c3f\u90e8\u6016\u64e6\u731c\u88c1\u6750\u624d\u8d22\u776c\u8e29\u91c7\u5f69\u83dc\u8521\u9910\u53c2\u8695\u6b8b\u60ed\u60e8\u707f\u82cd\u8231\u4ed3\u6ca7\u85cf\u64cd\u7cd9\u69fd\u66f9\u8349\u5395\u7b56\u4fa7\u518c\u6d4b\u5c42\u8e6d\u63d2\u53c9\u832c\u8336\u67e5\u78b4\u643d\u5bdf\u5c94\u5dee\u8be7\u62c6\u67f4\u8c7a\u6400\u63ba\u8749\u998b\u8c17\u7f20\u94f2\u4ea7\u9610\u98a4\u660c\u7316\u573a\u5c1d\u5e38\u957f\u507f\u80a0\u5382\u655e\u7545\u5531\u5021\u8d85\u6284\u949e\u671d\u5632\u6f6e\u5de2\u5435\u7092\u8f66\u626f\u64a4\u63a3\u5f7b\u6f88\u90f4\u81e3\u8fb0\u5c18\u6668\u5ff1\u6c89\u9648\u8d81\u886c\u6491\u79f0\u57ce\u6a59\u6210\u5448\u4e58\u7a0b\u60e9\u6f84\u8bda\u627f\u901e\u9a8b\u79e4\u5403\u75f4\u6301\u5319\u6c60\u8fdf\u5f1b\u9a70\u803b\u9f7f\u4f88\u5c3a\u8d64\u7fc5\u65a5\u70bd\u5145\u51b2\u866b\u5d07\u5ba0\u62bd\u916c\u7574\u8e0c\u7a20\u6101\u7b79\u4ec7\u7ef8\u7785\u4e11\u81ed\u521d\u51fa\u6a71\u53a8\u8e87\u9504\u96cf\u6ec1\u9664\u695a\u7840\u50a8\u77d7\u6410\u89e6\u5904\u63e3\u5ddd\u7a7f\u693d\u4f20\u8239\u5598\u4e32\u75ae\u7a97\u5e62\u5e8a\u95ef\u521b\u5439\u708a\u6376\u9524\u5782\u6625\u693f\u9187\u5507\u6df3\u7eaf\u8822\u6233\u7ef0\u75b5\u8328\u78c1\u96cc\u8f9e\u6148\u74f7\u8bcd\u6b64\u523a\u8d50\u6b21\u806a\u8471\u56f1\u5306\u4ece\u4e1b\u51d1\u7c97\u918b\u7c07\u4fc3\u8e7f\u7be1\u7a9c\u6467\u5d14\u50ac\u8106\u7601\u7cb9\u6dec\u7fe0\u6751\u5b58\u5bf8\u78cb\u64ae\u6413\u63aa\u632b\u9519\u642d\u8fbe\u7b54\u7629\u6253\u5927\u5446\u6b79\u50a3\u6234\u5e26\u6b86\u4ee3\u8d37\u888b\u5f85\u902e\u6020\u803d\u62c5\u4e39\u5355\u90f8\u63b8\u80c6\u65e6\u6c2e\u4f46\u60ee\u6de1\u8bde\u5f39\u86cb\u5f53\u6321\u515a\u8361\u6863\u5200\u6363\u8e48\u5012\u5c9b\u7977\u5bfc\u5230\u7a3b\u60bc\u9053\u76d7\u5fb7\u5f97\u7684\u8e6c\u706f\u767b\u7b49\u77aa\u51f3\u9093\u5824\u4f4e\u6ef4\u8fea\u654c\u7b1b\u72c4\u6da4\u7fdf\u5ae1\u62b5\u5e95\u5730\u8482\u7b2c\u5e1d\u5f1f\u9012\u7f14\u98a0\u6382\u6ec7\u7898\u70b9\u5178\u975b\u57ab\u7535\u4f43\u7538\u5e97\u60e6\u5960\u6dc0\u6bbf\u7889\u53fc\u96d5\u51cb\u5201\u6389\u540a\u9493\u8c03\u8dcc\u7239\u789f\u8776\u8fed\u8c0d\u53e0\u4e01\u76ef\u53ee\u9489\u9876\u9f0e\u952d\u5b9a\u8ba2\u4e22\u4e1c\u51ac\u8463\u61c2\u52a8\u680b\u4f97\u606b\u51bb\u6d1e\u515c\u6296\u6597\u9661\u8c46\u9017\u75d8\u90fd\u7763\u6bd2\u728a\u72ec\u8bfb\u5835\u7779\u8d4c\u675c\u9540\u809a\u5ea6\u6e21\u5992\u7aef\u77ed\u953b\u6bb5\u65ad\u7f0e\u5806\u5151\u961f\u5bf9\u58a9\u5428\u8e72\u6566\u987f\u56e4\u949d\u76fe\u9041\u6387\u54c6\u591a\u593a\u579b\u8eb2\u6735\u8dfa\u8235\u5241\u60f0\u5815\u86fe\u5ce8\u9e45\u4fc4\u989d\u8bb9\u5a25\u6076\u5384\u627c\u904f\u9102\u997f\u6069\u800c\u513f\u8033\u5c14\u9975\u6d31\u4e8c\u8d30\u53d1\u7f5a\u7b4f\u4f10\u4e4f\u9600\u6cd5\u73d0\u85e9\u5e06\u756a\u7ffb\u6a0a\u77fe\u9492\u7e41\u51e1\u70e6\u53cd\u8fd4\u8303\u8d29\u72af\u996d\u6cdb\u574a\u82b3\u65b9\u80aa\u623f\u9632\u59a8\u4eff\u8bbf\u7eba\u653e\u83f2\u975e\u5561\u98de\u80a5\u532a\u8bfd\u5420\u80ba\u5e9f\u6cb8\u8d39\u82ac\u915a\u5429\u6c1b\u5206\u7eb7\u575f\u711a\u6c7e\u7c89\u594b\u4efd\u5fff\u6124\u7caa\u4e30\u5c01\u67ab\u8702\u5cf0\u950b\u98ce\u75af\u70fd\u9022\u51af\u7f1d\u8bbd\u5949\u51e4\u4f5b\u5426\u592b\u6577\u80a4\u5b75\u6276\u62c2\u8f90\u5e45\u6c1f\u7b26\u4f0f\u4fd8\u670d\u6d6e\u6daa\u798f\u88b1\u5f17\u752b\u629a\u8f85\u4fef\u91dc\u65a7\u812f\u8151\u5e9c\u8150\u8d74\u526f\u8986\u8d4b\u590d\u5085\u4ed8\u961c\u7236\u8179\u8d1f\u5bcc\u8ba3\u9644\u5987\u7f1a\u5490\u5676\u560e\u8be5\u6539\u6982\u9499\u76d6\u6e89\u5e72\u7518\u6746\u67d1\u7aff\u809d\u8d76\u611f\u79c6\u6562\u8d63\u5188\u521a\u94a2\u7f38\u809b\u7eb2\u5c97\u6e2f\u6760\u7bd9\u768b\u9ad8\u818f\u7f94\u7cd5\u641e\u9550\u7a3f\u544a\u54e5\u6b4c\u6401\u6208\u9e3d\u80f3\u7599\u5272\u9769\u845b\u683c\u86e4\u9601\u9694\u94ec\u4e2a\u5404\u7ed9\u6839\u8ddf\u8015\u66f4\u5e9a\u7fb9\u57c2\u803f\u6897\u5de5\u653b\u529f\u606d\u9f9a\u4f9b\u8eac\u516c\u5bab\u5f13\u5de9\u6c5e\u62f1\u8d21\u5171\u94a9\u52fe\u6c9f\u82df\u72d7\u57a2\u6784\u8d2d\u591f\u8f9c\u83c7\u5495\u7b8d\u4f30\u6cbd\u5b64\u59d1\u9f13\u53e4\u86ca\u9aa8\u8c37\u80a1\u6545\u987e\u56fa\u96c7\u522e\u74dc\u5250\u5be1\u6302\u8902\u4e56\u62d0\u602a\u68fa\u5173\u5b98\u51a0\u89c2\u7ba1\u9986\u7f50\u60ef\u704c\u8d2f\u5149\u5e7f\u901b\u7470\u89c4\u572d\u7845\u5f52\u9f9f\u95fa\u8f68\u9b3c\u8be1\u7678\u6842\u67dc\u8dea\u8d35\u523d\u8f8a\u6eda\u68cd\u9505\u90ed\u56fd\u679c\u88f9\u8fc7\u54c8\u9ab8\u5b69\u6d77\u6c26\u4ea5\u5bb3\u9a87\u9163\u61a8\u90af\u97e9\u542b\u6db5\u5bd2\u51fd\u558a\u7f55\u7ff0\u64bc\u634d\u65f1\u61be\u608d\u710a\u6c57\u6c49\u592f\u676d\u822a\u58d5\u568e\u8c6a\u6beb\u90dd\u597d\u8017\u53f7\u6d69\u5475\u559d\u8377\u83cf\u6838\u79be\u548c\u4f55\u5408\u76d2\u8c89\u9602\u6cb3\u6db8\u8d6b\u8910\u9e64\u8d3a\u563f\u9ed1\u75d5\u5f88\u72e0\u6068\u54fc\u4ea8\u6a2a\u8861\u6052\u8f70\u54c4\u70d8\u8679\u9e3f\u6d2a\u5b8f\u5f18\u7ea2\u5589\u4faf\u7334\u543c\u539a\u5019\u540e\u547c\u4e4e\u5ffd\u745a\u58f6\u846b\u80e1\u8774\u72d0\u7cca\u6e56\u5f27\u864e\u552c\u62a4\u4e92\u6caa\u6237\u82b1\u54d7\u534e\u733e\u6ed1\u753b\u5212\u5316\u8bdd\u69d0\u5f8a\u6000\u6dee\u574f\u6b22\u73af\u6853\u8fd8\u7f13\u6362\u60a3\u5524\u75ea\u8c62\u7115\u6da3\u5ba6\u5e7b\u8352\u614c\u9ec4\u78fa\u8757\u7c27\u7687\u51f0\u60f6\u714c\u6643\u5e4c\u604d\u8c0e\u7070\u6325\u8f89\u5fbd\u6062\u86d4\u56de\u6bc1\u6094\u6167\u5349\u60e0\u6666\u8d3f\u79fd\u4f1a\u70e9\u6c47\u8bb3\u8bf2\u7ed8\u8364\u660f\u5a5a\u9b42\u6d51\u6df7\u8c41\u6d3b\u4f19\u706b\u83b7\u6216\u60d1\u970d\u8d27\u7978\u51fb\u573e\u57fa\u673a\u7578\u7a3d\u79ef\u7b95\u808c\u9965\u8ff9\u6fc0\u8ba5\u9e21\u59ec\u7ee9\u7f09\u5409\u6781\u68d8\u8f91\u7c4d\u96c6\u53ca\u6025\u75be\u6c72\u5373\u5ac9\u7ea7\u6324\u51e0\u810a\u5df1\u84df\u6280\u5180\u5b63\u4f0e\u796d\u5242\u60b8\u6d4e\u5bc4\u5bc2\u8ba1\u8bb0\u65e2\u5fcc\u9645\u7ee7\u7eaa\u5609\u67b7\u5939\u4f73\u5bb6\u52a0\u835a\u988a\u8d3e\u7532\u94be\u5047\u7a3c\u4ef7\u67b6\u9a7e\u5ac1\u6b7c\u76d1\u575a\u5c16\u7b3a\u95f4\u714e\u517c\u80a9\u8270\u5978\u7f04\u8327\u68c0\u67ec\u78b1\u7877\u62e3\u6361\u7b80\u4fed\u526a\u51cf\u8350\u69db\u9274\u8df5\u8d31\u89c1\u952e\u7bad\u4ef6\u5065\u8230\u5251\u996f\u6e10\u6e85\u6da7\u5efa\u50f5\u59dc\u5c06\u6d46\u6c5f\u7586\u848b\u6868\u5956\u8bb2\u5320\u9171\u964d\u8549\u6912\u7901\u7126\u80f6\u4ea4\u90ca\u6d47\u9a84\u5a07\u56bc\u6405\u94f0\u77eb\u4fa5\u811a\u72e1\u89d2\u997a\u7f34\u7ede\u527f\u6559\u9175\u8f7f\u8f83\u53eb\u7a96\u63ed\u63a5\u7686\u79f8\u8857\u9636\u622a\u52ab\u8282\u830e\u775b\u6676\u9cb8\u4eac\u60ca\u7cbe\u7cb3\u7ecf\u4e95\u8b66\u666f\u9888\u9759\u5883\u656c\u955c\u5f84\u75c9\u9756\u7adf\u7ade\u51c0\u70af\u7a98\u63ea\u7a76\u7ea0\u7396\u97ed\u4e45\u7078\u4e5d\u9152\u53a9\u6551\u65e7\u81fc\u8205\u548e\u5c31\u759a\u97a0\u62d8\u72d9\u75bd\u5c45\u9a79\u83ca\u5c40\u5480\u77e9\u4e3e\u6cae\u805a\u62d2\u636e\u5de8\u5177\u8ddd\u8e1e\u952f\u4ff1\u53e5\u60e7\u70ac\u5267\u6350\u9e43\u5a1f\u5026\u7737\u5377\u7ee2\u6485\u652b\u6289\u6398\u5014\u7235\u6854\u6770\u6377\u776b\u7aed\u6d01\u7ed3\u89e3\u59d0\u6212\u85c9\u82a5\u754c\u501f\u4ecb\u75a5\u8beb\u5c4a\u5dfe\u7b4b\u65a4\u91d1\u4eca\u6d25\u895f\u7d27\u9526\u4ec5\u8c28\u8fdb\u9773\u664b\u7981\u8fd1\u70ec\u6d78\u5c3d\u52b2\u8346\u5162\u89c9\u51b3\u8bc0\u7edd\u5747\u83cc\u94a7\u519b\u541b\u5cfb\u4fca\u7ae3\u6d5a\u90e1\u9a8f\u5580\u5496\u5361\u54af\u5f00\u63e9\u6977\u51ef\u6168\u520a\u582a\u52d8\u574e\u780d\u770b\u5eb7\u6177\u7ce0\u625b\u6297\u4ea2\u7095\u8003\u62f7\u70e4\u9760\u5777\u82db\u67ef\u68f5\u78d5\u9897\u79d1\u58f3\u54b3\u53ef\u6e34\u514b\u523b\u5ba2\u8bfe\u80af\u5543\u57a6\u6073\u5751\u542d\u7a7a\u6050\u5b54\u63a7\u62a0\u53e3\u6263\u5bc7\u67af\u54ed\u7a9f\u82e6\u9177\u5e93\u88e4\u5938\u57ae\u630e\u8de8\u80ef\u5757\u7b77\u4fa9\u5feb\u5bbd\u6b3e\u5321\u7b50\u72c2\u6846\u77ff\u7736\u65f7\u51b5\u4e8f\u76d4\u5cbf\u7aa5\u8475\u594e\u9b41\u5080\u9988\u6127\u6e83\u5764\u6606\u6346\u56f0\u62ec\u6269\u5ed3\u9614\u5783\u62c9\u5587\u8721\u814a\u8fa3\u5566\u83b1\u6765\u8d56\u84dd\u5a6a\u680f\u62e6\u7bee\u9611\u5170\u6f9c\u8c30\u63fd\u89c8\u61d2\u7f06\u70c2\u6ee5\u7405\u6994\u72fc\u5eca\u90ce\u6717\u6d6a\u635e\u52b3\u7262\u8001\u4f6c\u59e5\u916a\u70d9\u6d9d\u52d2\u4e50\u96f7\u956d\u857e\u78ca\u7d2f\u5121\u5792\u64c2\u808b\u7c7b\u6cea\u68f1\u695e\u51b7\u5398\u68a8\u7281\u9ece\u7bf1\u72f8\u79bb\u6f13\u7406\u674e\u91cc\u9ca4\u793c\u8389\u8354\u540f\u6817\u4e3d\u5389\u52b1\u783e\u5386\u5229\u5088\u4f8b\u4fd0\u75e2\u7acb\u7c92\u6ca5\u96b6\u529b\u7483\u54e9\u4fe9\u8054\u83b2\u8fde\u9570\u5ec9\u601c\u6d9f\u5e18\u655b\u8138\u94fe\u604b\u70bc\u7ec3\u7cae\u51c9\u6881\u7cb1\u826f\u4e24\u8f86\u91cf\u667e\u4eae\u8c05\u64a9\u804a\u50da\u7597\u71ce\u5be5\u8fbd\u6f66\u4e86\u6482\u9563\u5ed6\u6599\u5217\u88c2\u70c8\u52a3\u730e\u7433\u6797\u78f7\u9716\u4e34\u90bb\u9cde\u6dcb\u51db\u8d41\u541d\u62ce\u73b2\u83f1\u96f6\u9f84\u94c3\u4f36\u7f9a\u51cc\u7075\u9675\u5cad\u9886\u53e6\u4ee4\u6e9c\u7409\u69b4\u786b\u998f\u7559\u5218\u7624\u6d41\u67f3\u516d\u9f99\u804b\u5499\u7b3c\u7abf\u9686\u5784\u62e2\u9647\u697c\u5a04\u6402\u7bd3\u6f0f\u964b\u82a6\u5362\u9885\u5e90\u7089\u63b3\u5364\u864f\u9c81\u9e93\u788c\u9732\u8def\u8d42\u9e7f\u6f5e\u7984\u5f55\u9646\u622e\u9a74\u5415\u94dd\u4fa3\u65c5\u5c65\u5c61\u7f15\u8651\u6c2f\u5f8b\u7387\u6ee4\u7eff\u5ce6\u631b\u5b6a\u6ee6\u5375\u4e71\u63a0\u7565\u62a1\u8f6e\u4f26\u4ed1\u6ca6\u7eb6\u8bba\u841d\u87ba\u7f57\u903b\u9523\u7ba9\u9aa1\u88f8\u843d\u6d1b\u9a86\u7edc\u5988\u9ebb\u739b\u7801\u8682\u9a6c\u9a82\u561b\u5417\u57cb\u4e70\u9ea6\u5356\u8fc8\u8109\u7792\u9992\u86ee\u6ee1\u8513\u66fc\u6162\u6f2b\u8c29\u8292\u832b\u76f2\u6c13\u5fd9\u83bd\u732b\u8305\u951a\u6bdb\u77db\u94c6\u536f\u8302\u5192\u5e3d\u8c8c\u8d38\u4e48\u73ab\u679a\u6885\u9176\u9709\u7164\u6ca1\u7709\u5a92\u9541\u6bcf\u7f8e\u6627\u5bd0\u59b9\u5a9a\u95e8\u95f7\u4eec\u840c\u8499\u6aac\u76df\u9530\u731b\u68a6\u5b5f\u772f\u919a\u9761\u7cdc\u8ff7\u8c1c\u5f25\u7c73\u79d8\u89c5\u6ccc\u871c\u5bc6\u5e42\u68c9\u7720\u7ef5\u5195\u514d\u52c9\u5a29\u7f05\u9762\u82d7\u63cf\u7784\u85d0\u79d2\u6e3a\u5e99\u5999\u8511\u706d\u6c11\u62bf\u76bf\u654f\u60af\u95fd\u660e\u879f\u9e23\u94ed\u540d\u547d\u8c2c\u6478\u6479\u8611\u6a21\u819c\u78e8\u6469\u9b54\u62b9\u672b\u83ab\u58a8\u9ed8\u6cab\u6f20\u5bde\u964c\u8c0b\u725f\u67d0\u62c7\u7261\u4ea9\u59c6\u6bcd\u5893\u66ae\u5e55\u52df\u6155\u6728\u76ee\u7766\u7267\u7a46\u62ff\u54ea\u5450\u94a0\u90a3\u5a1c\u7eb3\u6c16\u4e43\u5976\u8010\u5948\u5357\u7537\u96be\u56ca\u6320\u8111\u607c\u95f9\u6dd6\u5462\u9981\u5185\u5ae9\u80fd\u59ae\u9713\u502a\u6ce5\u5c3c\u62df\u4f60\u533f\u817b\u9006\u6eba\u852b\u62c8\u5e74\u78be\u64b5\u637b\u5ff5\u5a18\u917f\u9e1f\u5c3f\u634f\u8042\u5b7d\u556e\u954a\u954d\u6d85\u60a8\u67e0\u72de\u51dd\u5b81\u62e7\u6cde\u725b\u626d\u94ae\u7ebd\u8113\u6d53\u519c\u5f04\u5974\u52aa\u6012\u5973\u6696\u8650\u759f\u632a\u61e6\u7cef\u8bfa\u54e6\u6b27\u9e25\u6bb4\u85d5\u5455\u5076\u6ca4\u556a\u8db4\u722c\u5e15\u6015\u7436\u62cd\u6392\u724c\u5f98\u6e43\u6d3e\u6500\u6f58\u76d8\u78d0\u76fc\u7554\u5224\u53db\u4e53\u5e9e\u65c1\u802a\u80d6\u629b\u5486\u5228\u70ae\u888d\u8dd1\u6ce1\u5478\u80da\u57f9\u88f4\u8d54\u966a\u914d\u4f69\u6c9b\u55b7\u76c6\u7830\u62a8\u70f9\u6f8e\u5f6d\u84ec\u68da\u787c\u7bf7\u81a8\u670b\u9e4f\u6367\u78b0\u576f\u7812\u9739\u6279\u62ab\u5288\u7435\u6bd7\u5564\u813e\u75b2\u76ae\u5339\u75de\u50fb\u5c41\u8b6c\u7bc7\u504f\u7247\u9a97\u98d8\u6f02\u74e2\u7968\u6487\u77a5\u62fc\u9891\u8d2b\u54c1\u8058\u4e52\u576a\u82f9\u840d\u5e73\u51ed\u74f6\u8bc4\u5c4f\u5761\u6cfc\u9887\u5a46\u7834\u9b44\u8feb\u7c95\u5256\u6251\u94fa\u4ec6\u8386\u8461\u83e9\u84b2\u57d4\u6734\u5703\u666e\u6d66\u8c31\u66dd\u7011\u671f\u6b3a\u6816\u621a\u59bb\u4e03\u51c4\u6f06\u67d2\u6c8f\u5176\u68cb\u5947\u6b67\u7566\u5d0e\u8110\u9f50\u65d7\u7948\u7941\u9a91\u8d77\u5c82\u4e5e\u4f01\u542f\u5951\u780c\u5668\u6c14\u8fc4\u5f03\u6c7d\u6ce3\u8bab\u6390\u6d3d\u7275\u6266\u948e\u94c5\u5343\u8fc1\u7b7e\u4edf\u8c26\u4e7e\u9ed4\u94b1\u94b3\u524d\u6f5c\u9063\u6d45\u8c34\u5811\u5d4c\u6b20\u6b49\u67aa\u545b\u8154\u7f8c\u5899\u8537\u5f3a\u62a2\u6a47\u9539\u6572\u6084\u6865\u77a7\u4e54\u4fa8\u5de7\u9798\u64ac\u7fd8\u5ced\u4fcf\u7a8d\u5207\u8304\u4e14\u602f\u7a83\u94a6\u4fb5\u4eb2\u79e6\u7434\u52e4\u82b9\u64d2\u79bd\u5bdd\u6c81\u9752\u8f7b\u6c22\u503e\u537f\u6e05\u64ce\u6674\u6c30\u60c5\u9877\u8bf7\u5e86\u743c\u7a77\u79cb\u4e18\u90b1\u7403\u6c42\u56da\u914b\u6cc5\u8d8b\u533a\u86c6\u66f2\u8eaf\u5c48\u9a71\u6e20\u53d6\u5a36\u9f8b\u8da3\u53bb\u5708\u98a7\u6743\u919b\u6cc9\u5168\u75ca\u62f3\u72ac\u5238\u529d\u7f3a\u7094\u7638\u5374\u9e4a\u69b7\u786e\u96c0\u88d9\u7fa4\u7136\u71c3\u5189\u67d3\u74e4\u58e4\u6518\u56b7\u8ba9\u9976\u6270\u7ed5\u60f9\u70ed\u58ec\u4ec1\u4eba\u5fcd\u97e7\u4efb\u8ba4\u5203\u598a\u7eab\u6254\u4ecd\u65e5\u620e\u8338\u84c9\u8363\u878d\u7194\u6eb6\u5bb9\u7ed2\u5197\u63c9\u67d4\u8089\u8339\u8815\u5112\u5b7a\u5982\u8fb1\u4e73\u6c5d\u5165\u8925\u8f6f\u962e\u854a\u745e\u9510\u95f0\u6da6\u82e5\u5f31\u6492\u6d12\u8428\u816e\u9cc3\u585e\u8d5b\u4e09\u53c1\u4f1e\u6563\u6851\u55d3\u4e27\u6414\u9a9a\u626b\u5ac2\u745f\u8272\u6da9\u68ee\u50e7\u838e\u7802\u6740\u5239\u6c99\u7eb1\u50bb\u5565\u715e\u7b5b\u6652\u73ca\u82eb\u6749\u5c71\u5220\u717d\u886b\u95ea\u9655\u64c5\u8d61\u81b3\u5584\u6c55\u6247\u7f2e\u5892\u4f24\u5546\u8d4f\u664c\u4e0a\u5c1a\u88f3\u68a2\u634e\u7a0d\u70e7\u828d\u52fa\u97f6\u5c11\u54e8\u90b5\u7ecd\u5962\u8d4a\u86c7\u820c\u820d\u8d66\u6444\u5c04\u6151\u6d89\u793e\u8bbe\u7837\u7533\u547b\u4f38\u8eab\u6df1\u5a20\u7ec5\u795e\u6c88\u5ba1\u5a76\u751a\u80be\u614e\u6e17\u58f0\u751f\u7525\u7272\u5347\u7ef3\u7701\u76db\u5269\u80dc\u5723\u5e08\u5931\u72ee\u65bd\u6e7f\u8bd7\u5c38\u8671\u5341\u77f3\u62fe\u65f6\u4ec0\u98df\u8680\u5b9e\u8bc6\u53f2\u77e2\u4f7f\u5c4e\u9a76\u59cb\u5f0f\u793a\u58eb\u4e16\u67ff\u4e8b\u62ed\u8a93\u901d\u52bf\u662f\u55dc\u566c\u9002\u4ed5\u4f8d\u91ca\u9970\u6c0f\u5e02\u6043\u5ba4\u89c6\u8bd5\u6536\u624b\u9996\u5b88\u5bff\u6388\u552e\u53d7\u7626\u517d\u852c\u67a2\u68b3\u6b8a\u6292\u8f93\u53d4\u8212\u6dd1\u758f\u4e66\u8d4e\u5b70\u719f\u85af\u6691\u66d9\u7f72\u8700\u9ecd\u9f20\u5c5e\u672f\u8ff0\u6811\u675f\u620d\u7ad6\u5885\u5eb6\u6570\u6f31\u6055\u5237\u800d\u6454\u8870\u7529\u5e05\u6813\u62f4\u971c\u53cc\u723d\u8c01\u6c34\u7761\u7a0e\u542e\u77ac\u987a\u821c\u8bf4\u7855\u6714\u70c1\u65af\u6495\u5636\u601d\u79c1\u53f8\u4e1d\u6b7b\u8086\u5bfa\u55e3\u56db\u4f3a\u4f3c\u9972\u5df3\u677e\u8038\u6002\u9882\u9001\u5b8b\u8bbc\u8bf5\u641c\u8258\u64de\u55fd\u82cf\u9165\u4fd7\u7d20\u901f\u7c9f\u50f3\u5851\u6eaf\u5bbf\u8bc9\u8083\u9178\u849c\u7b97\u867d\u968b\u968f\u7ee5\u9ad3\u788e\u5c81\u7a57\u9042\u96a7\u795f\u5b59\u635f\u7b0b\u84d1\u68ad\u5506\u7f29\u7410\u7d22\u9501\u6240\u584c\u4ed6\u5b83\u5979\u5854\u736d\u631e\u8e4b\u8e0f\u80ce\u82d4\u62ac\u53f0\u6cf0\u915e\u592a\u6001\u6c70\u574d\u644a\u8d2a\u762b\u6ee9\u575b\u6a80\u75f0\u6f6d\u8c2d\u8c08\u5766\u6bef\u8892\u78b3\u63a2\u53f9\u70ad\u6c64\u5858\u642a\u5802\u68e0\u819b\u5510\u7cd6\u5018\u8eba\u6dcc\u8d9f\u70eb\u638f\u6d9b\u6ed4\u7ee6\u8404\u6843\u9003\u6dd8\u9676\u8ba8\u5957\u7279\u85e4\u817e\u75bc\u8a8a\u68af\u5254\u8e22\u9511\u63d0\u9898\u8e44\u557c\u4f53\u66ff\u568f\u60d5\u6d95\u5243\u5c49\u5929\u6dfb\u586b\u7530\u751c\u606c\u8214\u8146\u6311\u6761\u8fe2\u773a\u8df3\u8d34\u94c1\u5e16\u5385\u542c\u70c3\u6c40\u5ef7\u505c\u4ead\u5ead\u633a\u8247\u901a\u6850\u916e\u77b3\u540c\u94dc\u5f64\u7ae5\u6876\u6345\u7b52\u7edf\u75db\u5077\u6295\u5934\u900f\u51f8\u79c3\u7a81\u56fe\u5f92\u9014\u6d82\u5c60\u571f\u5410\u5154\u6e4d\u56e2\u63a8\u9893\u817f\u8715\u892a\u9000\u541e\u5c6f\u81c0\u62d6\u6258\u8131\u9e35\u9640\u9a6e\u9a7c\u692d\u59a5\u62d3\u553e\u6316\u54c7\u86d9\u6d3c\u5a03\u74e6\u889c\u6b6a\u5916\u8c4c\u5f2f\u6e7e\u73a9\u987d\u4e38\u70f7\u5b8c\u7897\u633d\u665a\u7696\u60cb\u5b9b\u5a49\u4e07\u8155\u6c6a\u738b\u4ea1\u6789\u7f51\u5f80\u65fa\u671b\u5fd8\u5984\u5a01\u5dcd\u5fae\u5371\u97e6\u8fdd\u6845\u56f4\u552f\u60df\u4e3a\u6f4d\u7ef4\u82c7\u840e\u59d4\u4f1f\u4f2a\u5c3e\u7eac\u672a\u851a\u5473\u754f\u80c3\u5582\u9b4f\u4f4d\u6e2d\u8c13\u5c09\u6170\u536b\u761f\u6e29\u868a\u6587\u95fb\u7eb9\u543b\u7a33\u7d0a\u95ee\u55e1\u7fc1\u74ee\u631d\u8717\u6da1\u7a9d\u6211\u65a1\u5367\u63e1\u6c83\u5deb\u545c\u94a8\u4e4c\u6c61\u8bec\u5c4b\u65e0\u829c\u68a7\u543e\u5434\u6bcb\u6b66\u4e94\u6342\u5348\u821e\u4f0d\u4fae\u575e\u620a\u96fe\u6664\u7269\u52ff\u52a1\u609f\u8bef\u6614\u7199\u6790\u897f\u7852\u77fd\u6670\u563b\u5438\u9521\u727a\u7a00\u606f\u5e0c\u6089\u819d\u5915\u60dc\u7184\u70ef\u6eaa\u6c50\u7280\u6a84\u88ad\u5e2d\u4e60\u5ab3\u559c\u94e3\u6d17\u7cfb\u9699\u620f\u7ec6\u778e\u867e\u5323\u971e\u8f96\u6687\u5ce1\u4fa0\u72ed\u4e0b\u53a6\u590f\u5413\u6380\u9528\u5148\u4ed9\u9c9c\u7ea4\u54b8\u8d24\u8854\u8237\u95f2\u6d8e\u5f26\u5acc\u663e\u9669\u73b0\u732e\u53bf\u817a\u9985\u7fa1\u5baa\u9677\u9650\u7ebf\u76f8\u53a2\u9576\u9999\u7bb1\u8944\u6e58\u4e61\u7fd4\u7965\u8be6\u60f3\u54cd\u4eab\u9879\u5df7\u6a61\u50cf\u5411\u8c61\u8427\u785d\u9704\u524a\u54ee\u56a3\u9500\u6d88\u5bb5\u6dc6\u6653\u5c0f\u5b5d\u6821\u8096\u5578\u7b11\u6548\u6954\u4e9b\u6b47\u874e\u978b\u534f\u631f\u643a\u90aa\u659c\u80c1\u8c10\u5199\u68b0\u5378\u87f9\u61c8\u6cc4\u6cfb\u8c22\u5c51\u85aa\u82af\u950c\u6b23\u8f9b\u65b0\u5ffb\u5fc3\u4fe1\u8845\u661f\u8165\u7329\u60fa\u5174\u5211\u578b\u5f62\u90a2\u884c\u9192\u5e78\u674f\u6027\u59d3\u5144\u51f6\u80f8\u5308\u6c79\u96c4\u718a\u4f11\u4fee\u7f9e\u673d\u55c5\u9508\u79c0\u8896\u7ee3\u589f\u620c\u9700\u865a\u5618\u987b\u5f90\u8bb8\u84c4\u9157\u53d9\u65ed\u5e8f\u755c\u6064\u7d6e\u5a7f\u7eea\u7eed\u8f69\u55a7\u5ba3\u60ac\u65cb\u7384\u9009\u7663\u7729\u7eda\u9774\u859b\u5b66\u7a74\u96ea\u8840\u52cb\u718f\u5faa\u65ec\u8be2\u5bfb\u9a6f\u5de1\u6b89\u6c5b\u8bad\u8baf\u900a\u8fc5\u538b\u62bc\u9e26\u9e2d\u5440\u4e2b\u82bd\u7259\u869c\u5d16\u8859\u6daf\u96c5\u54d1\u4e9a\u8bb6\u7109\u54bd\u9609\u70df\u6df9\u76d0\u4e25\u7814\u8712\u5ca9\u5ef6\u8a00\u989c\u960e\u708e\u6cbf\u5944\u63a9\u773c\u884d\u6f14\u8273\u5830\u71d5\u538c\u781a\u96c1\u5501\u5f66\u7130\u5bb4\u8c1a\u9a8c\u6b83\u592e\u9e2f\u79e7\u6768\u626c\u4f6f\u75a1\u7f8a\u6d0b\u9633\u6c27\u4ef0\u75d2\u517b\u6837\u6f3e\u9080\u8170\u5996\u7476\u6447\u5c27\u9065\u7a91\u8c23\u59da\u54ac\u8200\u836f\u8981\u8000\u6930\u564e\u8036\u7237\u91ce\u51b6\u4e5f\u9875\u6396\u4e1a\u53f6\u66f3\u814b\u591c\u6db2\u4e00\u58f9\u533b\u63d6\u94f1\u4f9d\u4f0a\u8863\u9890\u5937\u9057\u79fb\u4eea\u80f0\u7591\u6c82\u5b9c\u59e8\u5f5d\u6905\u8681\u501a\u5df2\u4e59\u77e3\u4ee5\u827a\u6291\u6613\u9091\u5c79\u4ebf\u5f79\u81c6\u9038\u8084\u75ab\u4ea6\u88d4\u610f\u6bc5\u5fc6\u4e49\u76ca\u6ea2\u8be3\u8bae\u8c0a\u8bd1\u5f02\u7ffc\u7fcc\u7ece\u8335\u836b\u56e0\u6bb7\u97f3\u9634\u59fb\u541f\u94f6\u6deb\u5bc5\u996e\u5c39\u5f15\u9690\u5370\u82f1\u6a31\u5a74\u9e70\u5e94\u7f28\u83b9\u8424\u8425\u8367\u8747\u8fce\u8d62\u76c8\u5f71\u9896\u786c\u6620\u54df\u62e5\u4f63\u81c3\u75c8\u5eb8\u96cd\u8e0a\u86f9\u548f\u6cf3\u6d8c\u6c38\u607f\u52c7\u7528\u5e7d\u4f18\u60a0\u5fe7\u5c24\u7531\u90ae\u94c0\u72b9\u6cb9\u6e38\u9149\u6709\u53cb\u53f3\u4f51\u91c9\u8bf1\u53c8\u5e7c\u8fc2\u6de4\u4e8e\u76c2\u6986\u865e\u611a\u8206\u4f59\u4fde\u903e\u9c7c\u6109\u6e1d\u6e14\u9685\u4e88\u5a31\u96e8\u4e0e\u5c7f\u79b9\u5b87\u8bed\u7fbd\u7389\u57df\u828b\u90c1\u5401\u9047\u55bb\u5cea\u5fa1\u6108\u6b32\u72f1\u80b2\u8a89\u6d74\u5bd3\u88d5\u9884\u8c6b\u9a6d\u9e33\u6e0a\u51a4\u5143\u57a3\u8881\u539f\u63f4\u8f95\u56ed\u5458\u5706\u733f\u6e90\u7f18\u8fdc\u82d1\u613f\u6028\u9662\u66f0\u7ea6\u8d8a\u8dc3\u94a5\u5cb3\u7ca4\u6708\u60a6\u9605\u8018\u4e91\u90e7\u5300\u9668\u5141\u8fd0\u8574\u915d\u6655\u97f5\u5b55\u531d\u7838\u6742\u683d\u54c9\u707e\u5bb0\u8f7d\u518d\u5728\u54b1\u6512\u6682\u8d5e\u8d43\u810f\u846c\u906d\u7cdf\u51ff\u85fb\u67a3\u65e9\u6fa1\u86a4\u8e81\u566a\u9020\u7682\u7076\u71e5\u8d23\u62e9\u5219\u6cfd\u8d3c\u600e\u589e\u618e\u66fe\u8d60\u624e\u55b3\u6e23\u672d\u8f67\u94e1\u95f8\u7728\u6805\u69a8\u548b\u4e4d\u70b8\u8bc8\u6458\u658b\u5b85\u7a84\u503a\u5be8\u77bb\u6be1\u8a79\u7c98\u6cbe\u76cf\u65a9\u8f97\u5d2d\u5c55\u8638\u6808\u5360\u6218\u7ad9\u6e5b\u7efd\u6a1f\u7ae0\u5f70\u6f33\u5f20\u638c\u6da8\u6756\u4e08\u5e10\u8d26\u4ed7\u80c0\u7634\u969c\u62db\u662d\u627e\u6cbc\u8d75\u7167\u7f69\u5146\u8087\u53ec\u906e\u6298\u54f2\u86f0\u8f99\u8005\u9517\u8517\u8fd9\u6d59\u73cd\u659f\u771f\u7504\u7827\u81fb\u8d1e\u9488\u4fa6\u6795\u75b9\u8bca\u9707\u632f\u9547\u9635\u84b8\u6323\u7741\u5f81\u72f0\u4e89\u6014\u6574\u62ef\u6b63\u653f\u5e27\u75c7\u90d1\u8bc1\u829d\u679d\u652f\u5431\u8718\u77e5\u80a2\u8102\u6c41\u4e4b\u7ec7\u804c\u76f4\u690d\u6b96\u6267\u503c\u4f84\u5740\u6307\u6b62\u8dbe\u53ea\u65e8\u7eb8\u5fd7\u631a\u63b7\u81f3\u81f4\u7f6e\u5e1c\u5cd9\u5236\u667a\u79e9\u7a1a\u8d28\u7099\u75d4\u6ede\u6cbb\u7a92\u4e2d\u76c5\u5fe0\u949f\u8877\u7ec8\u79cd\u80bf\u91cd\u4ef2\u4f17\u821f\u5468\u5dde\u6d32\u8bcc\u7ca5\u8f74\u8098\u5e1a\u5492\u76b1\u5b99\u663c\u9aa4\u73e0\u682a\u86db\u6731\u732a\u8bf8\u8bdb\u9010\u7af9\u70db\u716e\u62c4\u77a9\u5631\u4e3b\u8457\u67f1\u52a9\u86c0\u8d2e\u94f8\u7b51\u4f4f\u6ce8\u795d\u9a7b\u6293\u722a\u62fd\u4e13\u7816\u8f6c\u64b0\u8d5a\u7bc6\u6869\u5e84\u88c5\u5986\u649e\u58ee\u72b6\u690e\u9525\u8ffd\u8d58\u5760\u7f00\u8c06\u51c6\u6349\u62d9\u5353\u684c\u7422\u8301\u914c\u5544\u7740\u707c\u6d4a\u5179\u54a8\u8d44\u59ff\u6ecb\u6dc4\u5b5c\u7d2b\u4ed4\u7c7d\u6ed3\u5b50\u81ea\u6e0d\u5b57\u9b03\u68d5\u8e2a\u5b97\u7efc\u603b\u7eb5\u90b9\u8d70\u594f\u63cd\u79df\u8db3\u5352\u65cf\u7956\u8bc5\u963b\u7ec4\u94bb\u7e82\u5634\u9189\u6700\u7f6a\u5c0a\u9075\u6628\u5de6\u4f50\u67de\u505a\u4f5c\u5750\u5ea7\u9515\u55f3\u5ad2\u7477\u66a7\u972d\u8c19\u94f5\u9e4c\u5aaa\u9a9c\u9ccc\u94af\u5457\u94a3\u9e28\u9f85\u9e4e\u8d32\u951b\u835c\u54d4\u6ed7\u94cb\u7b5a\u8df8\u82c4\u7f0f\u7b3e\u9aa0\u98d1\u98d9\u9556\u9573\u9cd4\u50a7\u7f24\u69df\u6ba1\u8191\u9554\u9acc\u9b13\u7980\u997d\u94b9\u9e41\u94b8\u9a96\u9eea\u607b\u9538\u4faa\u9497\u5181\u8c04\u8c36\u8487\u5fcf\u5a75\u9aa3\u89c7\u7985\u9561\u4f25\u82cc\u6005\u960a\u9cb3\u7817\u4f27\u8c0c\u6987\u789c\u9f80\u67a8\u67fd\u94d6\u94db\u996c\u9e31\u94f3\u4fe6\u5e31\u96e0\u520d\u7ecc\u8e70\u948f\u6006\u7f0d\u9e51\u8f8d\u9f8a\u9e5a\u82c1\u9aa2\u679e\u8f8f\u64ba\u9509\u9e7e\u54d2\u9791\u9a80\u7ed0\u6b9a\u8d55\u7605\u7baa\u8c20\u7800\u88c6\u7118\u956b\u7c74\u8bcb\u8c1b\u7ee8\u89cc\u955d\u5dc5\u94bf\u766b\u94eb\u9cb7\u9cbd\u94e4\u94e5\u5cbd\u9e2b\u7aa6\u6e0e\u691f\u724d\u7b03\u9ee9\u7c16\u603c\u9566\u7096\u8db8\u94ce\u8c14\u57a9\u960f\u8f6d\u9507\u9537\u9e57\u989a\u989b\u9cc4\u8bf6\u8fe9\u94d2\u9e38\u9c95\u94ab\u9c82\u7eef\u9544\u9cb1\u507e\u6ca3\u51eb\u9a78\u7ec2\u7ecb\u8d59\u9eb8\u9c8b\u9cc6\u9486\u8d45\u5c34\u64c0\u7ec0\u6206\u777e\u8bf0\u7f1f\u9506\u7ea5\u9549\u988d\u4e98\u8d53\u7ee0\u9ca0\u8bdf\u7f11\u89cf\u8bc2\u6bc2\u94b4\u9522\u9e2a\u9e44\u9e58\u9e39\u63b4\u8bd6\u63bc\u9e73\u9ccf\u72b7\u5326\u523f\u59ab\u6867\u9c91\u9cdc\u886e\u7ef2\u9ca7\u57da\u5459\u5e3c\u6901\u8748\u94ea\u961a\u7ed7\u9889\u704f\u98a2\u8bc3\u9616\u86ce\u9ec9\u8ba7\u836d\u95f3\u9c8e\u6d52\u9e55\u9a85\u6866\u94e7\u5942\u7f33\u953e\u9ca9\u9cc7\u8bd9\u835f\u54d5\u6d4d\u7f0b\u73f2\u6656\u8be8\u9984\u960d\u94ac\u956c\u8ba6\u8bd8\u8360\u53fd\u54dc\u9aa5\u7391\u89ca\u9f51\u77f6\u7f81\u867f\u8dfb\u9701\u9c9a\u9cab\u90cf\u6d43\u94d7\u9553\u86f2\u8c0f\u7f23\u620b\u622c\u7751\u9e63\u7b15\u9ca3\u97af\u7edb\u7f30\u6322\u5ce4\u9e6a\u9c9b\u7596\u988c\u9c92\u537a\u8369\u9991\u7f19\u8d46\u89d0\u522d\u6cfe\u8ff3\u5f2a\u80eb\u9753\u9604\u9e20\u9e6b\u8bb5\u5c66\u6989\u98d3\u949c\u9514\u7aad\u9f83\u9529\u954c\u96bd\u8c32\u73cf\u76b2\u5240\u57b2\u5ffe\u607a\u94e0\u9534\u9f9b\u95f6\u94aa\u94d0\u9a92\u7f02\u8f72\u94b6\u951e\u9894\u9f88\u94ff\u55be\u90d0\u54d9\u810d\u72ef\u9acb\u8bd3\u8bf3\u909d\u5739\u7ea9\u8d36\u532e\u8489\u6126\u8069\u7bd1\u9603\u951f\u9cb2\u86f4\u5d03\u5f95\u6d9e\u6fd1\u8d49\u7750\u94fc\u765e\u7c41\u5c9a\u6984\u6593\u9567\u8934\u9606\u9512\u5520\u5d02\u94d1\u94f9\u75e8\u9cd3\u8bd4\u7f27\u4fea\u90e6\u575c\u82c8\u8385\u84e0\u5456\u9026\u9a8a\u7f21\u67a5\u680e\u8f79\u783a\u9502\u9e42\u75a0\u7c9d\u8dde\u96f3\u9ca1\u9ce2\u8539\u5941\u6f4b\u740f\u6b93\u88e2\u88e3\u9ca2\u9b49\u7f2d\u948c\u9e69\u853a\u5eea\u6aa9\u8f9a\u8e8f\u7eeb\u68c2\u86cf\u9cae\u6d4f\u9a9d\u7efa\u954f\u9e68\u830f\u6cf7\u73d1\u680a\u80e7\u783b\u507b\u848c\u55bd\u5d5d\u9542\u7618\u8027\u877c\u9ac5\u5786\u64b8\u565c\u95fe\u6cf8\u6e0c\u680c\u6a79\u8f73\u8f82\u8f98\u6c07\u80ea\u9e2c\u9e6d\u823b\u9c88\u8114\u5a08\u683e\u9e3e\u92ae\u56f5\u8366\u7321\u6cfa\u6924\u8136\u9559\u6988\u891b\u950a\u5452\u551b\u5b37\u6769\u52a2\u7f26\u9558\u98a1\u9cd7\u9ebd\u626a\u7116\u61d1\u9494\u8288\u8c27\u7315\u7962\u6e11\u817c\u9efe\u7f08\u7f2a\u95f5\u7f17\u8c1f\u84e6\u998d\u6b81\u9546\u94bc\u94d9\u8bb7\u94cc\u9cb5\u8f87\u9cb6\u8311\u8885\u9667\u8616\u55eb\u989f\u8e51\u82ce\u549b\u804d\u4fac\u54dd\u9a7d\u9495\u50a9\u8bb4\u6004\u74ef\u8e52\u75b1\u8f94\u7eb0\u7f74\u94cd\u8c1d\u9a88\u7f25\u5ad4\u948b\u9564\u9568\u8572\u9a90\u7eee\u6864\u789b\u9880\u9883\u9ccd\u4f65\u8368\u60ad\u9a9e\u7f31\u6920\u94a4\u5af1\u6a2f\u6217\u709d\u9516\u9535\u956a\u7f9f\u8dc4\u8bee\u8c2f\u835e\u7f32\u7857\u8df7\u60ec\u9532\u7ba7\u9513\u63ff\u9cad\u8315\u86f1\u5def\u8d47\u866e\u9cc5\u8bce\u5c96\u9612\u89d1\u9e32\u8be0\u7efb\u8f81\u94e8\u9615\u9619\u60ab\u835b\u5a06\u6861\u996a\u8f6b\u5d58\u877e\u7f1b\u94f7\u98a6\u86ac\u98d2\u6bf5\u7cc1\u7f2b\u556c\u94ef\u7a51\u94e9\u9ca8\u917e\u8baa\u59d7\u9a9f\u9490\u9cdd\u57a7\u6b87\u89de\u538d\u6ee0\u7572\u8bdc\u8c02\u6e16\u8c25\u57d8\u83b3\u5f11\u8f7c\u8d33\u94c8\u9ca5\u7ef6\u6445\u7ebe\u95e9\u94c4\u53ae\u9a77\u7f0c\u9536\u9e36\u85ae\u998a\u98d5\u953c\u8c21\u7a23\u8c07\u836a\u72f2\u5522\u7743\u95fc\u94ca\u9cce\u949b\u9c90\u6619\u94bd\u952c\u9878\u50a5\u9967\u94f4\u9557\u97ec\u94fd\u7f07\u9e48\u9617\u7c9c\u9f86\u9ca6\u6078\u94ad\u948d\u629f\u9968\u7ba8\u9f0d\u5a32\u817d\u7ea8\u7efe\u8f8b\u8bff\u5e0f\u95f1\u6ca9\u6da0\u73ae\u97ea\u709c\u9c94\u960c\u83b4\u9f8c\u90ac\u5e91\u6003\u59a9\u9a9b\u9e49\u9e5c\u9969\u960b\u73ba\u89cb\u7856\u82cb\u83b6\u85d3\u5c98\u7303\u5a34\u9e47\u75eb\u869d\u7c7c\u8df9\u8297\u9977\u9aa7\u7f03\u98e8\u54d3\u6f47\u9a81\u7ee1\u67ad\u7bab\u4eb5\u64b7\u7ec1\u7f2c\u9649\u8365\u9990\u9e3a\u8be9\u987c\u8c16\u94c9\u955f\u8c11\u6cf6\u9cd5\u57d9\u6d54\u9c9f\u57ad\u5a05\u6860\u6c29\u53a3\u8d5d\u4fe8\u5156\u8c33\u6079\u95eb\u917d\u9b47\u990d\u9f39\u7080\u8f7a\u9e5e\u9cd0\u9765\u8c12\u90ba\u6654\u70e8\u8bd2\u5453\u5cc4\u9974\u603f\u9a7f\u7f22\u8f76\u8d3b\u9487\u9552\u9571\u7617\u8223\u94df\u763e\u8314\u83ba\u8426\u84e5\u6484\u5624\u6ee2\u6f46\u748e\u9e66\u763f\u988f\u7f42\u955b\u83b8\u94d5\u9c7f\u4f1b\u4fe3\u8c00\u8c15\u84e3\u5d5b\u996b\u9608\u59aa\u7ea1\u89ce\u6b24\u94b0\u9e46\u9e6c\u9f89\u6a7c\u9e22\u9f0b\u94ba\u90d3\u82b8\u607d\u6120\u7ead\u97eb\u6b92\u6c32\u74d2\u8db1\u933e\u9a75\u8d5c\u5567\u5e3b\u7ba6\u8c2e\u7f2f\u8c35\u8bcf\u948a\u8c2a\u8f84\u9e67\u6d48\u7f1c\u6862\u8f78\u8d48\u796f\u9e29\u8be4\u5ce5\u94b2\u94ee\u7b5d\u9a98\u6809\u6800\u8f75\u8f7e\u8d3d\u9e37\u86f3\u7d77\u8e2c\u8e2f\u89ef\u953a\u7ea3\u7ec9\u4f2b\u69e0\u94e2\u556d\u9994\u989e\u9a93\u7f12\u8bfc\u956f\u8c18\u7f01\u8f8e\u8d40\u7726\u9531\u9f87\u9cbb\u506c\u8bf9\u9a7a\u9cb0\u955e\u7f35\u8e9c\u9cdf\u8ba0\u8c2b\u90c4\u52d0\u51fc\u5742\u5785\u57b4\u57ef\u57dd\u82d8\u836c\u836e\u839c\u83bc\u83f0\u85c1\u63f8\u5412\u5423\u5494\u549d\u54b4\u5658\u567c\u56af\u5e5e\u5c99\u5d74\u5f77\u5fbc\u72b8\u72cd\u9980\u9987\u9993\u9995\u6123\u61b7\u61d4\u4e2c\u6e86\u6edf\u6eb7\u6f24\u6f74\u6fb9\u752f\u7e9f\u7ed4\u7ef1\u73c9\u67a7\u684a\u6849\u69d4\u6a65\u8f71\u8f77\u8d4d\u80b7\u80e8\u98da\u7173\u7145\u7198\u610d\u6dfc\u781c\u78d9\u770d\u949a\u94b7\u94d8\u94de\u9503\u950d\u950e\u950f\u9518\u951d\u952a\u952b\u953f\u9545\u954e\u9562\u9565\u9569\u9572\u7a06\u9e4b\u9e5b\u9e71\u75ac\u75b4\u75d6\u766f\u88e5\u8941\u8022\u98a5\u87a8\u9eb4\u9c85\u9c86\u9c87\u9c9e\u9cb4\u9cba\u9cbc\u9cca\u9ccb\u9cd8\u9cd9\u9792\u97b4\u9f44",Xge="\u554a\u963f\u57c3\u6328\u54ce\u5509\u54c0\u769a\u764c\u85f9\u77ee\u827e\u7919\u611b\u9698\u978d\u6c28\u5b89\u4ffa\u6309\u6697\u5cb8\u80fa\u6848\u9aaf\u6602\u76ce\u51f9\u6556\u71ac\u7ffa\u8956\u50b2\u5967\u61ca\u6fb3\u82ad\u634c\u6252\u53ed\u5427\u7b06\u516b\u75a4\u5df4\u62d4\u8dcb\u9776\u628a\u8019\u58e9\u9738\u7f77\u7238\u767d\u67cf\u767e\u64fa\u4f70\u6557\u62dc\u7a17\u6591\u73ed\u642c\u6273\u822c\u9812\u677f\u7248\u626e\u62cc\u4f34\u74e3\u534a\u8fa6\u7d46\u90a6\u5e6b\u6886\u699c\u8180\u7d81\u68d2\u78c5\u868c\u938a\u508d\u8b17\u82de\u80de\u5305\u8912\u525d\u8584\u96f9\u4fdd\u5821\u98fd\u5bf6\u62b1\u5831\u66b4\u8c79\u9b91\u7206\u676f\u7891\u60b2\u5351\u5317\u8f29\u80cc\u8c9d\u92c7\u500d\u72fd\u5099\u618a\u7119\u88ab\u5954\u82ef\u672c\u7b28\u5d29\u7e43\u752d\u6cf5\u8e66\u8ff8\u903c\u9f3b\u6bd4\u9119\u7b46\u5f7c\u78a7\u84d6\u853d\u7562\u6583\u6bd6\u5e63\u5e87\u75f9\u9589\u655d\u5f0a\u5fc5\u8f9f\u58c1\u81c2\u907f\u965b\u97ad\u908a\u7de8\u8cb6\u6241\u4fbf\u8b8a\u535e\u8fa8\u8faf\u8fae\u904d\u6a19\u5f6a\u8198\u8868\u9c49\u618b\u5225\u765f\u5f6c\u658c\u7015\u6ff1\u8cd3\u64ef\u5175\u51b0\u67c4\u4e19\u79c9\u9905\u70b3\u75c5\u4e26\u73bb\u83e0\u64ad\u64a5\u7f3d\u6ce2\u535a\u52c3\u640f\u9251\u7b94\u4f2f\u5e1b\u8236\u8116\u818a\u6e24\u6cca\u99c1\u6355\u8514\u54fa\u88dc\u57e0\u4e0d\u5e03\u6b65\u7c3f\u90e8\u6016\u64e6\u731c\u88c1\u6750\u624d\u8ca1\u776c\u8e29\u91c7\u5f69\u83dc\u8521\u9910\u53c3\u8836\u6b98\u615a\u6158\u71e6\u84bc\u8259\u5009\u6ec4\u85cf\u64cd\u7cd9\u69fd\u66f9\u8349\u5ec1\u7b56\u5074\u518a\u6e2c\u5c64\u8e6d\u63d2\u53c9\u832c\u8336\u67e5\u78b4\u643d\u5bdf\u5c94\u5dee\u8a6b\u62c6\u67f4\u8c7a\u6519\u647b\u87ec\u995e\u8b92\u7e8f\u93df\u7522\u95e1\u986b\u660c\u7316\u5834\u5617\u5e38\u9577\u511f\u8178\u5ee0\u655e\u66a2\u5531\u5021\u8d85\u6284\u9214\u671d\u5632\u6f6e\u5de2\u5435\u7092\u8eca\u626f\u64a4\u63a3\u5fb9\u6f88\u90f4\u81e3\u8fb0\u5875\u6668\u5ff1\u6c88\u9673\u8d81\u896f\u6490\u7a31\u57ce\u6a59\u6210\u5448\u4e58\u7a0b\u61f2\u6f84\u8aa0\u627f\u901e\u9a01\u79e4\u5403\u7661\u6301\u5319\u6c60\u9072\u5f1b\u99b3\u6065\u9f52\u4f88\u5c3a\u8d64\u7fc5\u65a5\u71be\u5145\u6c96\u87f2\u5d07\u5bf5\u62bd\u916c\u7587\u8e8a\u7a20\u6101\u7c4c\u4ec7\u7da2\u7785\u919c\u81ed\u521d\u51fa\u6ae5\u5eda\u8e87\u92e4\u96db\u6ec1\u9664\u695a\u790e\u5132\u77d7\u6410\u89f8\u8655\u63e3\u5ddd\u7a7f\u693d\u50b3\u8239\u5598\u4e32\u7621\u7a97\u5e62\u5e8a\u95d6\u5275\u5439\u708a\u6376\u9318\u5782\u6625\u693f\u9187\u5507\u6df3\u7d14\u8822\u6233\u7dbd\u75b5\u8328\u78c1\u96cc\u8fad\u6148\u74f7\u8a5e\u6b64\u523a\u8cdc\u6b21\u8070\u8525\u56ea\u5306\u5f9e\u53e2\u6e4a\u7c97\u918b\u7c07\u4fc3\u8ea5\u7be1\u7ac4\u6467\u5d14\u50ac\u8106\u7601\u7cb9\u6dec\u7fe0\u6751\u5b58\u5bf8\u78cb\u64ae\u6413\u63aa\u632b\u932f\u642d\u9054\u7b54\u7629\u6253\u5927\u5446\u6b79\u50a3\u6234\u5e36\u6b86\u4ee3\u8cb8\u888b\u5f85\u902e\u6020\u803d\u64d4\u4e39\u55ae\u9132\u64a3\u81bd\u65e6\u6c2e\u4f46\u619a\u6de1\u8a95\u5f48\u86cb\u7576\u64cb\u9ee8\u8569\u6a94\u5200\u6417\u8e48\u5012\u5cf6\u79b1\u5c0e\u5230\u7a3b\u60bc\u9053\u76dc\u5fb7\u5f97\u7684\u8e6c\u71c8\u767b\u7b49\u77aa\u51f3\u9127\u5824\u4f4e\u6ef4\u8fea\u6575\u7b1b\u72c4\u6ecc\u7fdf\u5ae1\u62b5\u5e95\u5730\u8482\u7b2c\u5e1d\u5f1f\u905e\u7de0\u985b\u6382\u6ec7\u7898\u9ede\u5178\u975b\u588a\u96fb\u4f43\u7538\u5e97\u60e6\u5960\u6fb1\u6bbf\u7889\u53fc\u96d5\u96d5\u5201\u6389\u540a\u91e3\u8abf\u8dcc\u7239\u789f\u8776\u53e0\u8adc\u758a\u4e01\u76ef\u53ee\u91d8\u9802\u9f0e\u9320\u5b9a\u8a02\u4e1f\u6771\u51ac\u8463\u61c2\u52d5\u68df\u4f97\u606b\u51cd\u6d1e\u515c\u6296\u9b25\u9661\u8c46\u9017\u75d8\u90fd\u7763\u6bd2\u72a2\u7368\u8b80\u5835\u7779\u8ced\u675c\u934d\u809a\u5ea6\u6e21\u5992\u7aef\u77ed\u935b\u6bb5\u65b7\u7dde\u5806\u514c\u968a\u5c0d\u58a9\u5678\u8e72\u6566\u9813\u56e4\u920d\u76fe\u9041\u6387\u54c6\u591a\u596a\u579b\u8eb2\u6735\u8dfa\u8235\u5241\u60f0\u58ae\u86fe\u5ce8\u9d5d\u4fc4\u984d\u8a1b\u5a25\u60e1\u5384\u627c\u904f\u9102\u9913\u6069\u800c\u5152\u8033\u723e\u990c\u6d31\u4e8c\u8cb3\u767c\u7f70\u7b4f\u4f10\u4e4f\u95a5\u6cd5\u743a\u85e9\u5e06\u756a\u7ffb\u6a0a\u792c\u91e9\u7e41\u51e1\u7169\u53cd\u8fd4\u7bc4\u8ca9\u72af\u98ef\u6cdb\u574a\u82b3\u65b9\u80aa\u623f\u9632\u59a8\u4eff\u8a2a\u7d21\u653e\u83f2\u975e\u5561\u98db\u80a5\u532a\u8ab9\u5420\u80ba\u5ee2\u6cb8\u8cbb\u82ac\u915a\u5429\u6c1b\u5206\u7d1b\u58b3\u711a\u6c7e\u7c89\u596e\u4efd\u5fff\u61a4\u7cde\u8c50\u5c01\u6953\u8702\u5cf0\u92d2\u98a8\u760b\u70fd\u9022\u99ae\u7e2b\u8af7\u5949\u9cf3\u4f5b\u5426\u592b\u6577\u819a\u5b75\u6276\u62c2\u8f3b\u5e45\u6c1f\u7b26\u4f0f\u4fd8\u670d\u6d6e\u6daa\u798f\u88b1\u5f17\u752b\u64ab\u8f14\u4fef\u91dc\u65a7\u812f\u8151\u5e9c\u8150\u8d74\u526f\u8986\u8ce6\u5fa9\u5085\u4ed8\u961c\u7236\u8179\u8ca0\u5bcc\u8a03\u9644\u5a66\u7e1b\u5490\u5676\u560e\u8a72\u6539\u6982\u9223\u84cb\u6e89\u5e79\u7518\u687f\u67d1\u7aff\u809d\u8d95\u611f\u7a08\u6562\u8d1b\u5ca1\u525b\u92fc\u7f38\u809b\u7db1\u5d17\u6e2f\u6760\u7bd9\u81ef\u9ad8\u818f\u7f94\u7cd5\u641e\u93ac\u7a3f\u544a\u54e5\u6b4c\u64f1\u6208\u9d3f\u80f3\u7599\u5272\u9769\u845b\u683c\u86e4\u95a3\u9694\u927b\u500b\u5404\u7d66\u6839\u8ddf\u8015\u66f4\u5e9a\u7fb9\u57c2\u803f\u6897\u5de5\u653b\u529f\u606d\u9f94\u4f9b\u8eac\u516c\u5bae\u5f13\u978f\u6c5e\u62f1\u8ca2\u5171\u9264\u52fe\u6e9d\u830d\u72d7\u57a2\u69cb\u8cfc\u5920\u8f9c\u83c7\u5495\u7b8d\u4f30\u6cbd\u5b64\u59d1\u9f13\u53e4\u8831\u9aa8\u8c37\u80a1\u6545\u9867\u56fa\u96c7\u522e\u74dc\u526e\u5be1\u639b\u8902\u4e56\u62d0\u602a\u68fa\u95dc\u5b98\u51a0\u89c0\u7ba1\u9928\u7f50\u6163\u704c\u8cab\u5149\u5ee3\u901b\u7470\u898f\u572d\u77fd\u6b78\u9f9c\u95a8\u8ecc\u9b3c\u8a6d\u7678\u6842\u6ac3\u8dea\u8cb4\u528a\u8f25\u6efe\u68cd\u934b\u90ed\u570b\u679c\u88f9\u904e\u54c8\u9ab8\u5b69\u6d77\u6c26\u4ea5\u5bb3\u99ed\u9163\u61a8\u90af\u97d3\u542b\u6db5\u5bd2\u51fd\u558a\u7f55\u7ff0\u64bc\u634d\u65f1\u61be\u608d\u710a\u6c57\u6f22\u592f\u676d\u822a\u58d5\u568e\u8c6a\u6beb\u90dd\u597d\u8017\u865f\u6d69\u5475\u559d\u8377\u83cf\u6838\u79be\u548c\u4f55\u5408\u76d2\u8c89\u95a1\u6cb3\u6db8\u8d6b\u8910\u9db4\u8cc0\u563f\u9ed1\u75d5\u5f88\u72e0\u6068\u54fc\u4ea8\u6a6b\u8861\u6052\u8f5f\u54c4\u70d8\u8679\u9d3b\u6d2a\u5b8f\u5f18\u7d05\u5589\u4faf\u7334\u543c\u539a\u5019\u5f8c\u547c\u4e4e\u5ffd\u745a\u58fa\u846b\u80e1\u8774\u72d0\u7cca\u6e56\u5f27\u864e\u552c\u8b77\u4e92\u6eec\u6236\u82b1\u5629\u83ef\u733e\u6ed1\u756b\u5283\u5316\u8a71\u69d0\u5f8a\u61f7\u6dee\u58de\u6b61\u74b0\u6853\u9084\u7de9\u63db\u60a3\u559a\u7613\u8c62\u7165\u6e19\u5ba6\u5e7b\u8352\u614c\u9ec3\u78fa\u8757\u7c27\u7687\u51f0\u60f6\u714c\u6643\u5e4c\u604d\u8b0a\u7070\u63ee\u8f1d\u5fbd\u6062\u86d4\u56de\u6bc0\u6094\u6167\u5349\u60e0\u6666\u8cc4\u7a62\u6703\u71f4\u532f\u8af1\u8aa8\u7e6a\u8477\u660f\u5a5a\u9b42\u6e3e\u6df7\u8c41\u6d3b\u5925\u706b\u7372\u6216\u60d1\u970d\u8ca8\u798d\u64ca\u573e\u57fa\u6a5f\u7578\u7a3d\u7a4d\u7b95\u808c\u9951\u8de1\u6fc0\u8b4f\u96de\u59ec\u7e3e\u7ddd\u5409\u6975\u68d8\u8f2f\u7c4d\u96c6\u53ca\u6025\u75be\u6c72\u5373\u5ac9\u7d1a\u64e0\u5e7e\u810a\u5df1\u858a\u6280\u5180\u5b63\u4f0e\u796d\u5291\u60b8\u6fdf\u5bc4\u5bc2\u8a08\u8a18\u65e2\u5fcc\u969b\u7e7c\u7d00\u5609\u67b7\u593e\u4f73\u5bb6\u52a0\u83a2\u9830\u8cc8\u7532\u9240\u5047\u7a3c\u50f9\u67b6\u99d5\u5ac1\u6bb2\u76e3\u5805\u5c16\u7b8b\u9593\u714e\u517c\u80a9\u8271\u5978\u7dd8\u7e6d\u6aa2\u67ec\u583f\u9e7c\u63c0\u64bf\u7c21\u5109\u526a\u6e1b\u85a6\u6abb\u9452\u8e10\u8ce4\u898b\u9375\u7bad\u4ef6\u5065\u8266\u528d\u991e\u6f38\u6ffa\u6f97\u5efa\u50f5\u59dc\u5c07\u6f3f\u6c5f\u7586\u8523\u69f3\u734e\u8b1b\u5320\u91ac\u964d\u8549\u6912\u7901\u7126\u81a0\u4ea4\u90ca\u6f86\u9a55\u5b0c\u56bc\u652a\u9278\u77ef\u50e5\u8173\u72e1\u89d2\u9903\u7e73\u7d5e\u527f\u6559\u9175\u8f4e\u8f03\u53eb\u7a96\u63ed\u63a5\u7686\u7a2d\u8857\u968e\u622a\u52ab\u7bc0\u8396\u775b\u6676\u9be8\u4eac\u9a5a\u7cbe\u7cb3\u7d93\u4e95\u8b66\u666f\u9838\u975c\u5883\u656c\u93e1\u5f91\u75d9\u9756\u7adf\u7af6\u51c8\u70af\u7a98\u63ea\u7a76\u7cfe\u7396\u97ed\u4e45\u7078\u4e5d\u9152\u5ec4\u6551\u820a\u81fc\u8205\u548e\u5c31\u759a\u97a0\u62d8\u72d9\u75bd\u5c45\u99d2\u83ca\u5c40\u5480\u77e9\u8209\u6cae\u805a\u62d2\u64da\u5de8\u5177\u8ddd\u8e1e\u92f8\u4ff1\u53e5\u61fc\u70ac\u5287\u6350\u9d51\u5a1f\u5026\u7737\u5377\u7d79\u6485\u652b\u6289\u6398\u5014\u7235\u6854\u5091\u6377\u776b\u7aed\u6f54\u7d50\u89e3\u59d0\u6212\u85c9\u82a5\u754c\u501f\u4ecb\u75a5\u8aa1\u5c46\u5dfe\u7b4b\u65a4\u91d1\u4eca\u6d25\u895f\u7dca\u9326\u50c5\u8b39\u9032\u9773\u6649\u7981\u8fd1\u71fc\u6d78\u76e1\u52c1\u834a\u5162\u89ba\u6c7a\u8a23\u7d55\u5747\u83cc\u921e\u8ecd\u541b\u5cfb\u4fca\u7ae3\u6d5a\u90e1\u99ff\u5580\u5496\u5361\u54af\u958b\u63e9\u6977\u51f1\u6168\u520a\u582a\u52d8\u574e\u780d\u770b\u5eb7\u6177\u7ce0\u625b\u6297\u4ea2\u7095\u8003\u62f7\u70e4\u9760\u5777\u82db\u67ef\u68f5\u78d5\u9846\u79d1\u6bbc\u54b3\u53ef\u6e34\u514b\u523b\u5ba2\u8ab2\u80af\u5543\u58be\u61c7\u5751\u542d\u7a7a\u6050\u5b54\u63a7\u6473\u53e3\u6263\u5bc7\u67af\u54ed\u7a9f\u82e6\u9177\u5eab\u8932\u8a87\u57ae\u630e\u8de8\u80ef\u584a\u7b77\u5108\u5feb\u5bec\u6b3e\u5321\u7b50\u72c2\u6846\u7926\u7736\u66e0\u6cc1\u8667\u76d4\u5dcb\u7aba\u8475\u594e\u9b41\u5080\u994b\u6127\u6f70\u5764\u6606\u6346\u56f0\u62ec\u64f4\u5ed3\u95ca\u5783\u62c9\u5587\u881f\u81d8\u8fa3\u5566\u840a\u4f86\u8cf4\u85cd\u5a6a\u6b04\u6514\u7c43\u95cc\u862d\u703e\u8b95\u652c\u89bd\u61f6\u7e9c\u721b\u6feb\u746f\u6994\u72fc\u5eca\u90ce\u6717\u6d6a\u6488\u52de\u7262\u8001\u4f6c\u59e5\u916a\u70d9\u6f87\u52d2\u6a02\u96f7\u9433\u857e\u78ca\u7d2f\u5121\u58d8\u64c2\u808b\u985e\u6dda\u68f1\u695e\u51b7\u5398\u68a8\u7281\u9ece\u7c6c\u8c8d\u96e2\u6f13\u7406\u674e\u88cf\u9bc9\u79ae\u8389\u8354\u540f\u6817\u9e97\u53b2\u52f5\u792b\u6b77\u5229\u5088\u4f8b\u4fd0\u75e2\u7acb\u7c92\u701d\u96b8\u529b\u7483\u54e9\u5006\u806f\u84ee\u9023\u942e\u5ec9\u6190\u6f23\u7c3e\u6582\u81c9\u93c8\u6200\u7149\u7df4\u7ce7\u6dbc\u6881\u7cb1\u826f\u5169\u8f1b\u91cf\u667e\u4eae\u8ad2\u64a9\u804a\u50da\u7642\u71ce\u5be5\u907c\u6f66\u4e86\u6482\u9410\u5ed6\u6599\u5217\u88c2\u70c8\u52a3\u7375\u7433\u6797\u78f7\u9716\u81e8\u9130\u9c57\u6dcb\u51dc\u8cc3\u541d\u62ce\u73b2\u83f1\u96f6\u9f61\u9234\u4f36\u7f9a\u6de9\u9748\u9675\u5dba\u9818\u53e6\u4ee4\u6e9c\u7409\u69b4\u786b\u993e\u7559\u5289\u7624\u6d41\u67f3\u516d\u9f8d\u807e\u56a8\u7c60\u7abf\u9686\u58df\u650f\u96b4\u6a13\u5a41\u645f\u7c0d\u6f0f\u964b\u8606\u76e7\u9871\u5eec\u7210\u64c4\u9e75\u865c\u9b6f\u9e93\u788c\u9732\u8def\u8cc2\u9e7f\u6f5e\u797f\u9304\u9678\u622e\u9a62\u5442\u92c1\u4fb6\u65c5\u5c65\u5c62\u7e37\u616e\u6c2f\u5f8b\u7387\u6ffe\u7da0\u5dd2\u6523\u5b7f\u7064\u5375\u4e82\u63a0\u7565\u6384\u8f2a\u502b\u4f96\u6dea\u7db8\u8ad6\u863f\u87ba\u7f85\u908f\u947c\u7c6e\u9a3e\u88f8\u843d\u6d1b\u99f1\u7d61\u5abd\u9ebb\u746a\u78bc\u879e\u99ac\u7f75\u561b\u55ce\u57cb\u8cb7\u9ea5\u8ce3\u9081\u8108\u779e\u9945\u883b\u6eff\u8513\u66fc\u6162\u6f2b\u8b3e\u8292\u832b\u76f2\u6c13\u5fd9\u83bd\u8c93\u8305\u9328\u6bdb\u77db\u925a\u536f\u8302\u5192\u5e3d\u8c8c\u8cbf\u9ebd\u73ab\u679a\u6885\u9176\u9ef4\u7164\u6c92\u7709\u5a92\u9382\u6bcf\u7f8e\u6627\u5bd0\u59b9\u5a9a\u9580\u60b6\u5011\u840c\u8499\u6aac\u76df\u9333\u731b\u5922\u5b5f\u7787\u919a\u9761\u7cdc\u8ff7\u8b0e\u5f4c\u7c73\u79d8\u8993\u6ccc\u871c\u5bc6\u51aa\u68c9\u7720\u7dbf\u5195\u514d\u52c9\u5a29\u7dec\u9762\u82d7\u63cf\u7784\u85d0\u79d2\u6e3a\u5edf\u5999\u8511\u6ec5\u6c11\u62bf\u76bf\u654f\u61ab\u95a9\u660e\u879f\u9cf4\u9298\u540d\u547d\u8b2c\u6478\u6479\u8611\u6a21\u819c\u78e8\u6469\u9b54\u62b9\u672b\u83ab\u58a8\u9ed8\u6cab\u6f20\u5bde\u964c\u8b00\u725f\u67d0\u62c7\u7261\u755d\u59c6\u6bcd\u5893\u66ae\u5e55\u52df\u6155\u6728\u76ee\u7766\u7267\u7a46\u62ff\u54ea\u5436\u9209\u90a3\u5a1c\u7d0d\u6c16\u4e43\u5976\u8010\u5948\u5357\u7537\u96e3\u56ca\u6493\u8166\u60f1\u9b27\u6dd6\u5462\u9912\u5167\u5ae9\u80fd\u59ae\u9713\u502a\u6ce5\u5c3c\u64ec\u59b3\u533f\u81a9\u9006\u6eba\u852b\u62c8\u5e74\u78be\u6506\u649a\u5ff5\u5a18\u91c0\u9ce5\u5c3f\u634f\u8076\u5b7d\u5699\u9477\u93b3\u6d85\u60a8\u6ab8\u7370\u51dd\u5be7\u64f0\u6fd8\u725b\u626d\u9215\u7d10\u81bf\u6fc3\u8fb2\u5f04\u5974\u52aa\u6012\u5973\u6696\u8650\u7627\u632a\u61e6\u7cef\u8afe\u54e6\u6b50\u9dd7\u6bc6\u85d5\u5614\u5076\u6f1a\u556a\u8db4\u722c\u5e15\u6015\u7436\u62cd\u6392\u724c\u5f98\u6e43\u6d3e\u6500\u6f58\u76e4\u78d0\u76fc\u7554\u5224\u53db\u4e53\u9f90\u65c1\u802a\u80d6\u62cb\u5486\u5228\u70ae\u888d\u8dd1\u6ce1\u5478\u80da\u57f9\u88f4\u8ce0\u966a\u914d\u4f69\u6c9b\u5674\u76c6\u7830\u62a8\u70f9\u6f8e\u5f6d\u84ec\u68da\u787c\u7bf7\u81a8\u670b\u9d6c\u6367\u78b0\u576f\u7812\u9739\u6279\u62ab\u5288\u7435\u6bd7\u5564\u813e\u75b2\u76ae\u5339\u75de\u50fb\u5c41\u8b6c\u7bc7\u504f\u7247\u9a19\u98c4\u6f02\u74e2\u7968\u6487\u77a5\u62fc\u983b\u8ca7\u54c1\u8058\u4e52\u576a\u860b\u840d\u5e73\u6191\u74f6\u8a55\u5c4f\u5761\u6f51\u9817\u5a46\u7834\u9b44\u8feb\u7c95\u5256\u64b2\u92ea\u4ec6\u8386\u8461\u83e9\u84b2\u57d4\u6a38\u5703\u666e\u6d66\u8b5c\u66dd\u7011\u671f\u6b3a\u68f2\u621a\u59bb\u4e03\u6dd2\u6f06\u67d2\u6c8f\u5176\u68cb\u5947\u6b67\u7566\u5d0e\u81cd\u9f4a\u65d7\u7948\u7941\u9a0e\u8d77\u8c48\u4e5e\u4f01\u555f\u5951\u780c\u5668\u6c23\u8fc4\u68c4\u6c7d\u6ce3\u8a16\u6390\u6d3d\u727d\u6261\u91ec\u925b\u5343\u9077\u7c3d\u4edf\u8b19\u4e7e\u9ed4\u9322\u9257\u524d\u6f5b\u9063\u6dfa\u8b74\u5879\u5d4c\u6b20\u6b49\u69cd\u55c6\u8154\u7f8c\u58bb\u8594\u5f37\u6436\u6a47\u936c\u6572\u6084\u6a4b\u77a7\u55ac\u50d1\u5de7\u9798\u64ac\u7ff9\u5ced\u4fcf\u7ac5\u5207\u8304\u4e14\u602f\u7aca\u6b3d\u4fb5\u89aa\u79e6\u7434\u52e4\u82b9\u64d2\u79bd\u5be2\u6c81\u9752\u8f15\u6c2b\u50be\u537f\u6e05\u64ce\u6674\u6c30\u60c5\u9803\u8acb\u6176\u74ca\u7aae\u79cb\u4e18\u90b1\u7403\u6c42\u56da\u914b\u6cc5\u8da8\u5340\u86c6\u66f2\u8ec0\u5c48\u9a45\u6e20\u53d6\u5a36\u9f72\u8da3\u53bb\u5708\u9874\u6b0a\u919b\u6cc9\u5168\u75ca\u62f3\u72ac\u5238\u52f8\u7f3a\u7094\u7638\u537b\u9d72\u69b7\u78ba\u96c0\u88d9\u7fa4\u7136\u71c3\u5189\u67d3\u74e4\u58e4\u6518\u56b7\u8b93\u9952\u64fe\u7e5e\u60f9\u71b1\u58ec\u4ec1\u4eba\u5fcd\u97cc\u4efb\u8a8d\u5203\u598a\u7d09\u6254\u4ecd\u65e5\u620e\u8338\u84c9\u69ae\u878d\u7194\u6eb6\u5bb9\u7d68\u5197\u63c9\u67d4\u8089\u8339\u8815\u5112\u5b7a\u5982\u8fb1\u4e73\u6c5d\u5165\u8925\u8edf\u962e\u854a\u745e\u92b3\u958f\u6f64\u82e5\u5f31\u6492\u7051\u85a9\u816e\u9c13\u585e\u8cfd\u4e09\u4e09\u5098\u6563\u6851\u55d3\u55aa\u6414\u9a37\u6383\u5ac2\u745f\u8272\u6f80\u68ee\u50e7\u838e\u7802\u6bba\u524e\u6c99\u7d17\u50bb\u5565\u715e\u7be9\u66ec\u73ca\u82eb\u6749\u5c71\u522a\u717d\u886b\u9583\u965c\u64c5\u8d0d\u81b3\u5584\u6c55\u6247\u7e55\u5891\u50b7\u5546\u8cde\u664c\u4e0a\u5c1a\u88f3\u68a2\u634e\u7a0d\u71d2\u828d\u52fa\u97f6\u5c11\u54e8\u90b5\u7d39\u5962\u8cd2\u86c7\u820c\u820d\u8d66\u651d\u5c04\u61fe\u6d89\u793e\u8a2d\u7837\u7533\u547b\u4f38\u8eab\u6df1\u5a20\u7d33\u795e\u6c88\u5be9\u5b38\u751a\u814e\u614e\u6ef2\u8072\u751f\u7525\u7272\u5347\u7e69\u7701\u76db\u5269\u52dd\u8056\u5e2b\u5931\u7345\u65bd\u6fd5\u8a69\u5c4d\u8671\u5341\u77f3\u62fe\u6642\u4ec0\u98df\u8755\u5be6\u8b58\u53f2\u77e2\u4f7f\u5c4e\u99db\u59cb\u5f0f\u793a\u58eb\u4e16\u67ff\u4e8b\u62ed\u8a93\u901d\u52e2\u662f\u55dc\u566c\u9069\u4ed5\u4f8d\u91cb\u98fe\u6c0f\u5e02\u6043\u5ba4\u8996\u8a66\u6536\u624b\u9996\u5b88\u58fd\u6388\u552e\u53d7\u7626\u7378\u852c\u6a1e\u68b3\u6b8a\u6292\u8f38\u53d4\u8212\u6dd1\u758f\u66f8\u8d16\u5b70\u719f\u85af\u6691\u66d9\u7f72\u8700\u9ecd\u9f20\u5c6c\u8853\u8ff0\u6a39\u675f\u620d\u8c4e\u5885\u5eb6\u6578\u6f31\u6055\u5237\u800d\u6454\u8870\u7529\u5e25\u6813\u62f4\u971c\u96d9\u723d\u8ab0\u6c34\u7761\u7a05\u542e\u77ac\u9806\u821c\u8aaa\u78a9\u6714\u720d\u65af\u6495\u5636\u601d\u79c1\u53f8\u7d72\u6b7b\u8086\u5bfa\u55e3\u56db\u4f3a\u4f3c\u98fc\u5df3\u677e\u8073\u616b\u980c\u9001\u5b8b\u8a1f\u8aa6\u641c\u8258\u64fb\u55fd\u8607\u9165\u4fd7\u7d20\u901f\u7c9f\u50f3\u5851\u6eaf\u5bbf\u8a34\u8085\u9178\u849c\u7b97\u96d6\u968b\u96a8\u7d8f\u9ad3\u788e\u6b72\u7a57\u9042\u96a7\u795f\u5b6b\u640d\u7b4d\u84d1\u68ad\u5506\u7e2e\u7463\u7d22\u9396\u6240\u584c\u4ed6\u5b83\u5979\u5854\u737a\u64bb\u8e4b\u8e0f\u80ce\u82d4\u64e1\u81fa\u6cf0\u915e\u592a\u614b\u6c70\u574d\u6524\u8caa\u7671\u7058\u58c7\u6a80\u75f0\u6f6d\u8b5a\u8ac7\u5766\u6bef\u8892\u78b3\u63a2\u5606\u70ad\u6e6f\u5858\u642a\u5802\u68e0\u819b\u5510\u7cd6\u5018\u8eba\u6dcc\u8d9f\u71d9\u638f\u6fe4\u6ed4\u7d73\u8404\u6843\u9003\u6dd8\u9676\u8a0e\u5957\u7279\u85e4\u9a30\u75bc\u8b04\u68af\u5254\u8e22\u92bb\u63d0\u984c\u8e44\u557c\u9ad4\u66ff\u568f\u60d5\u6d95\u5243\u5c5c\u5929\u6dfb\u586b\u7530\u751c\u606c\u8214\u8146\u6311\u689d\u8fe2\u773a\u8df3\u8cbc\u9435\u5e16\u5ef3\u807d\u70f4\u6c40\u5ef7\u505c\u4ead\u5ead\u633a\u8247\u901a\u6850\u916e\u77b3\u540c\u9285\u5f64\u7ae5\u6876\u6345\u7b52\u7d71\u75db\u5077\u6295\u982d\u900f\u51f8\u79bf\u7a81\u5716\u5f92\u9014\u5857\u5c60\u571f\u5410\u5154\u6e4d\u5718\u63a8\u9839\u817f\u86fb\u892a\u9000\u541e\u5c6f\u81c0\u62d6\u6258\u812b\u9d15\u9640\u99b1\u99dd\u6a62\u59a5\u62d3\u553e\u6316\u54c7\u86d9\u7aaa\u5a03\u74e6\u896a\u6b6a\u5916\u8c4c\u5f4e\u7063\u73a9\u9811\u4e38\u70f7\u5b8c\u7897\u633d\u665a\u7696\u60cb\u5b9b\u5a49\u842c\u8155\u6c6a\u738b\u4ea1\u6789\u7db2\u5f80\u65fa\u671b\u5fd8\u5984\u5a01\u5dcd\u5fae\u5371\u97cb\u9055\u6845\u570d\u552f\u60df\u70ba\u6ff0\u7dad\u8466\u840e\u59d4\u5049\u507d\u5c3e\u7def\u672a\u851a\u5473\u754f\u80c3\u9935\u9b4f\u4f4d\u6e2d\u8b02\u5c09\u6170\u885b\u761f\u6eab\u868a\u6587\u805e\u7d0b\u543b\u7a69\u7d0a\u554f\u55e1\u7fc1\u7515\u64be\u8778\u6e26\u7aa9\u6211\u65a1\u81e5\u63e1\u6c83\u5deb\u55da\u93a2\u70cf\u6c59\u8aa3\u5c4b\u7121\u856a\u68a7\u543e\u5433\u6bcb\u6b66\u4e94\u6342\u5348\u821e\u4f0d\u4fae\u5862\u620a\u9727\u6664\u7269\u52ff\u52d9\u609f\u8aa4\u6614\u7199\u6790\u897f\u7852\u77fd\u6670\u563b\u5438\u932b\u72a7\u7a00\u606f\u5e0c\u6089\u819d\u5915\u60dc\u7184\u70ef\u6eaa\u6c50\u7280\u6a84\u8972\u5e2d\u7fd2\u5ab3\u559c\u9291\u6d17\u7cfb\u9699\u6232\u7d30\u778e\u8766\u5323\u971e\u8f44\u6687\u5cfd\u4fe0\u72f9\u4e0b\u5ec8\u590f\u5687\u6380\u9341\u5148\u4ed9\u9bae\u7e96\u9e79\u8ce2\u929c\u8237\u9591\u6d8e\u5f26\u5acc\u986f\u96aa\u73fe\u737b\u7e23\u817a\u9921\u7fa8\u61b2\u9677\u9650\u7dda\u76f8\u5ec2\u9472\u9999\u7bb1\u8944\u6e58\u9109\u7fd4\u7965\u8a73\u60f3\u97ff\u4eab\u9805\u5df7\u6a61\u50cf\u5411\u8c61\u856d\u785d\u9704\u524a\u54ee\u56c2\u92b7\u6d88\u5bb5\u6dc6\u66c9\u5c0f\u5b5d\u6821\u8096\u562f\u7b11\u6548\u6954\u4e9b\u6b47\u880d\u978b\u5354\u633e\u651c\u90aa\u659c\u8105\u8ae7\u5beb\u68b0\u5378\u87f9\u61c8\u6cc4\u7009\u8b1d\u5c51\u85aa\u82af\u92c5\u6b23\u8f9b\u65b0\u5ffb\u5fc3\u4fe1\u91c1\u661f\u8165\u7329\u60fa\u8208\u5211\u578b\u5f62\u90a2\u884c\u9192\u5e78\u674f\u6027\u59d3\u5144\u5147\u80f8\u5308\u6d36\u96c4\u718a\u4f11\u4fee\u7f9e\u673d\u55c5\u92b9\u79c0\u8896\u7e61\u589f\u620c\u9700\u865b\u5653\u9808\u5f90\u8a31\u84c4\u9157\u6558\u65ed\u5e8f\u755c\u6064\u7d6e\u5a7f\u7dd2\u7e8c\u8ed2\u55a7\u5ba3\u61f8\u65cb\u7384\u9078\u766c\u7729\u7d62\u9774\u859b\u5b78\u7a74\u96ea\u8840\u52db\u718f\u5faa\u65ec\u8a62\u5c0b\u99b4\u5de1\u6b89\u6c5b\u8a13\u8a0a\u905c\u8fc5\u58d3\u62bc\u9d09\u9d28\u5440\u4e2b\u82bd\u7259\u869c\u5d16\u8859\u6daf\u96c5\u555e\u4e9e\u8a1d\u7109\u54bd\u95b9\u7159\u6df9\u9e7d\u56b4\u7814\u8712\u5dd6\u5ef6\u8a00\u984f\u95bb\u708e\u6cbf\u5944\u63a9\u773c\u884d\u6f14\u8277\u5830\u71d5\u53ad\u786f\u96c1\u5501\u5f65\u7130\u5bb4\u8afa\u9a57\u6b83\u592e\u9d26\u79e7\u694a\u63da\u4f6f\u760d\u7f8a\u6d0b\u967d\u6c27\u4ef0\u7662\u990a\u6a23\u6f3e\u9080\u8170\u5996\u7464\u6416\u582f\u9059\u7aaf\u8b20\u59da\u54ac\u8200\u85e5\u8981\u8000\u6930\u564e\u8036\u723a\u91ce\u51b6\u4e5f\u9801\u6396\u696d\u8449\u66f3\u814b\u591c\u6db2\u58f9\u58f9\u91ab\u63d6\u92a5\u4f9d\u4f0a\u8863\u9824\u5937\u907a\u79fb\u5100\u80f0\u7591\u6c82\u5b9c\u59e8\u5f5c\u6905\u87fb\u501a\u5df2\u4e59\u77e3\u4ee5\u85dd\u6291\u6613\u9091\u5c79\u5104\u5f79\u81c6\u9038\u8084\u75ab\u4ea6\u88d4\u610f\u6bc5\u61b6\u7fa9\u76ca\u6ea2\u8a63\u8b70\u8abc\u8b6f\u7570\u7ffc\u7fcc\u7e79\u8335\u852d\u56e0\u6bb7\u97f3\u9670\u59fb\u541f\u9280\u6deb\u5bc5\u98f2\u5c39\u5f15\u96b1\u5370\u82f1\u6afb\u5b30\u9df9\u61c9\u7e93\u7469\u87a2\u71df\u7192\u8805\u8fce\u8d0f\u76c8\u5f71\u7a4e\u786c\u6620\u55b2\u64c1\u50ad\u81c3\u7670\u5eb8\u96cd\u8e34\u86f9\u8a60\u6cf3\u6e67\u6c38\u607f\u52c7\u7528\u5e7d\u512a\u60a0\u6182\u5c24\u7531\u90f5\u923e\u7336\u6cb9\u904a\u9149\u6709\u53cb\u53f3\u4f51\u91c9\u8a98\u53c8\u5e7c\u8fc2\u6de4\u65bc\u76c2\u6986\u865e\u611a\u8f3f\u4f59\u4fde\u903e\u9b5a\u6109\u6e1d\u6f01\u9685\u4e88\u5a1b\u96e8\u8207\u5dbc\u79b9\u5b87\u8a9e\u7fbd\u7389\u57df\u828b\u90c1\u7c72\u9047\u55bb\u5cea\u79a6\u6108\u6b32\u7344\u80b2\u8b7d\u6d74\u5bd3\u88d5\u9810\u8c6b\u99ad\u9d1b\u6df5\u51a4\u5143\u57a3\u8881\u539f\u63f4\u8f45\u5712\u54e1\u5713\u733f\u6e90\u7de3\u9060\u82d1\u9858\u6028\u9662\u66f0\u7d04\u8d8a\u8e8d\u9470\u5dbd\u7cb5\u6708\u6085\u95b1\u8018\u96f2\u9116\u52fb\u9695\u5141\u904b\u860a\u919e\u6688\u97fb\u5b55\u531d\u7838\u96dc\u683d\u54c9\u707d\u5bb0\u8f09\u518d\u5728\u54b1\u6522\u66ab\u8d0a\u8d13\u81df\u846c\u906d\u7cdf\u947f\u85fb\u68d7\u65e9\u6fa1\u86a4\u8e81\u566a\u9020\u7682\u7ac8\u71e5\u8cac\u64c7\u5247\u6fa4\u8cca\u600e\u589e\u618e\u66fe\u8d08\u7d2e\u55b3\u6e23\u5284\u8ecb\u9358\u9598\u7728\u67f5\u69a8\u548b\u4e4d\u70b8\u8a50\u6458\u9f4b\u5b85\u7a84\u50b5\u5be8\u77bb\u6c08\u8a79\u7c98\u6cbe\u76de\u65ac\u8f3e\u5d84\u5c55\u8638\u68e7\u5360\u6230\u7ad9\u6e5b\u7dbb\u6a1f\u7ae0\u5f70\u6f33\u5f35\u638c\u6f32\u6756\u4e08\u5e33\u8cec\u4ed7\u8139\u7634\u969c\u62db\u662d\u627e\u6cbc\u8d99\u7167\u7f69\u5146\u8087\u53ec\u906e\u6298\u54f2\u87c4\u8f4d\u8005\u937a\u8517\u9019\u6d59\u73cd\u659f\u771f\u7504\u7827\u81fb\u8c9e\u91dd\u5075\u6795\u75b9\u8a3a\u9707\u632f\u93ae\u9663\u84b8\u6399\u775c\u5f81\u7319\u722d\u6014\u6574\u62ef\u6b63\u653f\u5e40\u7665\u912d\u8b49\u829d\u679d\u652f\u5431\u8718\u77e5\u80a2\u8102\u6c41\u4e4b\u7e54\u8077\u76f4\u690d\u6b96\u57f7\u503c\u4f84\u5740\u6307\u6b62\u8dbe\u53ea\u65e8\u7d19\u8a8c\u646f\u64f2\u81f3\u81f4\u7f6e\u5e5f\u5cd9\u5236\u667a\u79e9\u7a1a\u8cea\u7099\u75d4\u6eef\u6cbb\u7a92\u4e2d\u76c5\u5fe0\u9418\u8877\u7d42\u7a2e\u816b\u91cd\u4ef2\u773e\u821f\u5468\u5dde\u6d32\u8b05\u7ca5\u8ef8\u8098\u5e1a\u5492\u76ba\u5b99\u665d\u9a5f\u73e0\u682a\u86db\u6731\u8c6c\u8af8\u8a85\u9010\u7af9\u71ed\u716e\u62c4\u77da\u56d1\u4e3b\u8457\u67f1\u52a9\u86c0\u8caf\u9444\u7bc9\u4f4f\u8a3b\u795d\u99d0\u6293\u722a\u62fd\u5c08\u78da\u8f49\u64b0\u8cfa\u7bc6\u6a01\u838a\u88dd\u599d\u649e\u58ef\u72c0\u690e\u9310\u8ffd\u8d05\u589c\u7db4\u8ac4\u6e96\u6349\u62d9\u5353\u684c\u7422\u8301\u914c\u5544\u8457\u707c\u6fc1\u8332\u54a8\u8cc7\u59ff\u6ecb\u6dc4\u5b5c\u7d2b\u4ed4\u7c7d\u6ed3\u5b50\u81ea\u6f2c\u5b57\u9b03\u68d5\u8e64\u5b97\u7d9c\u7e3d\u7e31\u9112\u8d70\u594f\u63cd\u79df\u8db3\u5352\u65cf\u7956\u8a5b\u963b\u7d44\u9246\u7e82\u5634\u9189\u6700\u7f6a\u5c0a\u9075\u6628\u5de6\u4f50\u67de\u505a\u4f5c\u5750\u5ea7\u9312\u566f\u5b21\u74a6\u66d6\u9744\u8af3\u92a8\u9d6a\u5abc\u9a41\u9c32\u9200\u5504\u9211\u9d07\u9f59\u9d6f\u8cc1\u931b\u84fd\u55f6\u6f77\u924d\u7bf3\u8e55\u8290\u7df6\u7c69\u9a43\u98ae\u98c6\u93e2\u9463\u9c3e\u5110\u7e7d\u6ab3\u6baf\u81cf\u944c\u9ad5\u9b22\u7a1f\u9911\u9238\u9d53\u923d\u9a42\u9ef2\u60fb\u9364\u5115\u91f5\u56c5\u8ac2\u8b96\u8546\u61fa\u5b0b\u9a4f\u8998\u79aa\u9414\u5000\u8407\u60b5\u95b6\u9be7\u7868\u5096\u8af6\u6aec\u78e3\u9f54\u68d6\u6a89\u92ee\u943a\u98ed\u9d1f\u9283\u5114\u5e6c\u8b8e\u82bb\u7d40\u8e95\u91e7\u6134\u7d9e\u9d89\u8f1f\u9f6a\u9dbf\u84ef\u9a44\u6a05\u8f33\u651b\u92bc\u9e7a\u5660\u97c3\u99d8\u7d3f\u6bab\u8ce7\u7649\u7c1e\u8b9c\u78ad\u8960\u71fe\u9419\u7cf4\u8a46\u8ae6\u7d88\u89bf\u93d1\u5dd4\u923f\u7672\u929a\u9bdb\u9c08\u92cc\u92a9\u5d20\u9d87\u7ac7\u7006\u6add\u7258\u7be4\u9ef7\u7c6a\u61df\u9413\u71c9\u8e89\u9438\u8ae4\u580a\u95bc\u8edb\u92e8\u9354\u9d9a\u984e\u9853\u9c77\u8a92\u9087\u927a\u9d2f\u9b9e\u9201\u9b74\u7dcb\u9428\u9be1\u50e8\u7043\u9ce7\u99d9\u7d31\u7d3c\u8cfb\u9ea9\u9b92\u9c12\u91d3\u8cc5\u5c37\u641f\u7d3a\u6207\u776a\u8aa5\u7e1e\u92ef\u7d07\u9398\u6f41\u4e99\u8ce1\u7d86\u9bc1\u8a6c\u7df1\u89af\u8a41\u8f42\u9237\u932e\u9d23\u9d60\u9dbb\u9d30\u6451\u8a7f\u645c\u9e1b\u9c25\u7377\u532d\u528c\u5aaf\u6a9c\u9bad\u9c56\u889e\u7dc4\u9bc0\u581d\u54bc\u5e57\u69e8\u87c8\u927f\u95de\u7d4e\u9821\u705d\u9865\u8a36\u95d4\u8823\u9ecc\u8a0c\u8452\u958e\u9c5f\u6ef8\u9d98\u9a4a\u6a3a\u93f5\u5950\u7e6f\u9370\u9bc7\u9c09\u8a7c\u8588\u5666\u6fae\u7e62\u743f\u6689\u8ae2\u991b\u95bd\u9225\u944a\u8a10\u8a70\u85ba\u5630\u568c\u9a65\u74a3\u89ac\u9f4f\u78ef\u7f88\u8806\u8e8b\u973d\u9c6d\u9bfd\u90df\u6d79\u92cf\u93b5\u87ef\u8aeb\u7e11\u6214\u6229\u77bc\u9dbc\u7b67\u9c39\u97c9\u7d73\u97c1\u649f\u5da0\u9de6\u9bab\u7664\u981c\u9b9a\u5df9\u85ce\u9949\u7e09\u8d10\u89b2\u5244\u6d87\u9015\u5f33\u811b\u975a\u9b2e\u9ce9\u9df2\u8a4e\u5c68\u6af8\u98b6\u9245\u92e6\u7ab6\u9f5f\u9308\u942b\u96cb\u8b4e\u73a8\u76b8\u5274\u584f\u613e\u6137\u93a7\u9347\u9f95\u958c\u9227\u92ac\u9a0d\u7dd9\u8efb\u9233\u9301\u9837\u9f66\u93d7\u56b3\u9136\u5672\u81be\u736a\u9ad6\u8a86\u8a91\u913a\u58d9\u7e8a\u8cba\u5331\u8562\u6192\u8075\u7c23\u95ab\u9315\u9be4\u8810\u5d0d\u5fa0\u6df6\u7028\u8cda\u775e\u9338\u7669\u7c5f\u5d50\u6b16\u6595\u946d\u8964\u95ac\u92c3\u562e\u5d97\u92a0\u9412\u7646\u9c33\u8a84\u7e32\u5137\u9148\u58e2\u85f6\u849e\u863a\u56a6\u9090\u9a6a\u7e2d\u6aea\u6adf\u8f62\u792a\u92f0\u9e1d\u7658\u7cf2\u8e92\u9742\u9c7a\u9c67\u861e\u5969\u7032\u7489\u6bae\u8933\u895d\u9c31\u9b4e\u7e5a\u91d5\u9def\u85fa\u5ee9\u6a81\u8f54\u8eaa\u7dbe\u6b1e\u87f6\u9bea\u700f\u9a2e\u7db9\u93a6\u9dda\u8622\u7027\u74cf\u6af3\u6727\u7931\u50c2\u851e\u560d\u5d81\u93e4\u763a\u802c\u87bb\u9acf\u58da\u64fc\u5695\u95ad\u7018\u6de5\u6ae8\u6ad3\u8f64\u8f05\u8f46\u6c0c\u81da\u9e15\u9dfa\u826b\u9c78\u81e0\u5b4c\u6b12\u9e1e\u947e\u5707\u7296\u7380\u6ffc\u6b0f\u8161\u93cd\u6ada\u8938\u92dd\u5638\u561c\u5b24\u69aa\u52f1\u7e35\u93dd\u9859\u9c3b\u9ebc\u636b\u71dc\u61e3\u9346\u7f8b\u8b10\u737c\u79b0\u6fa0\u9766\u9efd\u7df2\u7e46\u9594\u7de1\u8b28\u9a40\u9943\u6b7f\u93cc\u926c\u9403\u8a25\u922e\u9be2\u8f26\u9bf0\u8526\u88ca\u9689\u8617\u56c1\u9862\u8ea1\u82e7\u5680\u8079\u5102\u5665\u99d1\u91f9\u513a\u8b33\u616a\u750c\u8e63\u76b0\u8f61\u7d15\u7f86\u9239\u8ade\u99e2\u7e39\u5b2a\u91d9\u93f7\u9420\u8604\u9a0f\u7dba\u69bf\u78e7\u980e\u980f\u9c2d\u50c9\u8541\u6173\u9a2b\u7e7e\u69e7\u9210\u5b19\u6aa3\u6227\u7197\u9306\u93d8\u93f9\u7fa5\u8e4c\u8a9a\u8b59\u854e\u7e70\u78fd\u8e7a\u611c\u9365\u7bcb\u92df\u64b3\u9bd6\u7162\u86fa\u5df0\u8cd5\u87e3\u9c0d\u8a58\u5d87\u95c3\u89b7\u9d1d\u8a6e\u7da3\u8f07\u9293\u95cb\u95d5\u6128\u8558\u5b08\u6a48\u98ea\u8ed4\u5db8\u8811\u7e1f\u92a3\u9870\u8706\u98af\u6bff\u7cdd\u7e45\u55c7\u92ab\u7a61\u93a9\u9bca\u91c3\u8a15\u59cd\u9a38\u91e4\u9c54\u5770\u6ba4\u89f4\u5399\u7044\u756c\u8a75\u8ad7\u700b\u8b1a\u5852\u8494\u5f12\u8efe\u8cb0\u9230\u9c23\u7dac\u6504\u7d13\u9582\u9460\u5edd\u99df\u7de6\u9376\u9de5\u85ea\u993f\u98bc\u93aa\u8b16\u7a4c\u8ab6\u84c0\u733b\u55e9\u8127\u95e5\u9248\u9c28\u9226\u9b90\u66c7\u926d\u931f\u9807\u513b\u9933\u940b\u93dc\u97dc\u92f1\u7df9\u9d5c\u95d0\u7cf6\u9f60\u9c37\u615f\u9204\u91f7\u6476\u98e9\u7c5c\u9f09\u5aa7\u8183\u7d08\u7db0\u8f1e\u8ac9\u5e43\u95c8\u6e88\u6f7f\u744b\u97d9\u7152\u9baa\u95bf\u8435\u9f77\u9114\u5ee1\u61ae\u5af5\u9a16\u9d61\u9da9\u993c\u9b29\u74bd\u89a1\u7864\u83a7\u859f\u861a\u5cf4\u736b\u5afb\u9df4\u7647\u8814\u79c8\u8e9a\u858c\u9909\u9a64\u7dd7\u9957\u5635\u701f\u9a4d\u7d83\u689f\u7c2b\u893b\u64f7\u7d32\u7e88\u9658\u6ece\u9948\u9d42\u8a61\u980a\u8afc\u9249\u93c7\u8b14\u6fa9\u9c48\u5864\u6f6f\u9c58\u57e1\u5a6d\u690f\u6c2c\u53b4\u8d17\u513c\u5157\u8b9e\u61e8\u9586\u91c5\u9b58\u995c\u9f34\u716c\u8efa\u9dc2\u9c29\u9768\u8b01\u9134\u66c4\u71c1\u8a52\u56c8\u5da7\u98f4\u61cc\u9a5b\u7e0a\u8efc\u8cbd\u91d4\u93b0\u943f\u761e\u8264\u92a6\u766e\u584b\u9daf\u7e08\u93a3\u6516\u56b6\u7005\u7020\u74d4\u9e1a\u766d\u9826\u7f4c\u93de\u8555\u92aa\u9b77\u50b4\u4fc1\u8adb\u8aed\u8577\u5d33\u98eb\u95be\u5ad7\u7d06\u89a6\u6b5f\u923a\u9d52\u9df8\u9f6c\u6ade\u9cf6\u9eff\u925e\u9106\u8553\u60f2\u614d\u7d1c\u97de\u6b9e\u6c33\u74da\u8db2\u93e8\u99d4\u8cfe\u5616\u5e58\u7c00\u8b56\u7e52\u8b6b\u8a54\u91d7\u8b2b\u8f12\u9dd3\u6e5e\u7e1d\u6968\u8eeb\u8cd1\u798e\u9d06\u8acd\u5d22\u9266\u931a\u7b8f\u9a2d\u6adb\u6894\u8ef9\u8f0a\u8d04\u9dd9\u8784\u7e36\u8e93\u8e91\u89f6\u937e\u7d02\u7e10\u4f47\u6ae7\u9296\u56c0\u994c\u9873\u9a05\u7e0b\u8ad1\u9432\u8aee\u7dc7\u8f1c\u8cb2\u7725\u9319\u9f5c\u9bd4\u50af\u8acf\u9a36\u9beb\u93c3\u7e98\u8ea6\u9c52\u8a01\u8b7e\u90e4\u731b\u6c39\u962a\u58df\u5816\u57b5\u588a\u6abe\u8552\u8464\u84e7\u8493\u83c7\u69c1\u6463\u54a4\u551a\u54e2\u565d\u5645\u6485\u5288\u8b14\u8946\u5db4\u810a\u4eff\u50e5\u7341\u9e85\u9918\u9937\u994a\u9962\u695e\u6035\u61cd\u723f\u6f35\u7069\u6df7\u6feb\u7026\u6de1\u5be7\u7cf8\u7d5d\u7dd4\u7449\u6898\u68ec\u6848\u6a70\u6aeb\u8ef2\u8ee4\u8ceb\u8181\u8156\u98c8\u7cca\u7146\u6e9c\u6e63\u6e3a\u78b8\u6efe\u7798\u9208\u9255\u92e3\u92b1\u92e5\u92f6\u9426\u9427\u9369\u9340\u9343\u9307\u9384\u9387\u93bf\u941d\u9465\u9479\u9454\u7a6d\u9d93\u9da5\u9e0c\u7667\u5c59\u7602\u81d2\u8947\u7e48\u802e\u986c\u87ce\u9eaf\u9b81\u9b83\u9b8e\u9bd7\u9bdd\u9bf4\u9c5d\u9bff\u9c20\u9c35\u9c45\u97bd\u97dd\u9f47";function Yge(e){return Wgt.charAt(Xge.indexOf(e.charAt(0)))}var $zt=new RegExp("[\u4e00-\u9fa5]+");function $ge(e){return Xge.includes(e)}var jr=class{static GetBytes(e){switch(typeof e){case"string":{let t=new Uint16Array(e.length);for(let n=0;n4294967295?((t=new Float64Array(1))[0]=e,new Uint8Array(t.buffer)):function(t){return t[0]=e,new Uint8Array(t.buffer)}(new Int32Array(1)):function(t){return t[0]=e,new Uint8Array(t.buffer)}(new Float64Array(1));case"boolean":return function(t){return t[0]=Number(e),t}(new Uint8Array(1));default:if(e instanceof Array){let t=[];for(let a=0;ae.length&&(n-=t);let i="";for(let r=0;re.length&&(n-=t);let i=new Uint8Array(n);for(let r=0;r1?(r.push(a.slice()),a=[]):i.set(0,0);break;case 3:l++,n/=t[l];break;case 4:l++,n*=t[l];break;case 5:if(4===s.length)throw"The position stack is only four locations deep";s.push(i);break;case 6:i=s.pop(),a.length>1&&(r.push(a.slice()),a=[]),o&&a.push(i.clone());break;case 7:{let s,o=0,h=n*e.baseUp,c=i.clone();switch(a.length>1&&(r.push(a.slice()),a=[]),e.fontType){case 0:l++,o=t[l];break;case 1:l++,o=t[l],0==o&&(l++,o=jr.ToUInt16(new Uint8Array([t[l++],t[l++]]),0),c.x=t[l++]*n,c.y=t[l++]*n,h=t[l]*n);break;case 2:l+=2,o=jr.ToUInt16(new Uint8Array([t[l-1],t[l]]),0)}0!==o&&(s=e.getGraphicDataByCodeWithOffset(o,h,c),s&&(r.push(...s.polylines.slice()),i=s.lastPoint.clone()))}break;case 8:{let e=new be;e.x=jr.byteTosbyte(t[++l]),e.y=jr.byteTosbyte(t[++l]),i.add(e.multiplyScalar(n)),o&&a.push(i.clone())}break;case 9:for(;;){let e=new be;if(e.x=jr.byteTosbyte(t[++l]),e.y=jr.byteTosbyte(t[++l]),0==e.x&&0==e.y)break;i.add(e.multiplyScalar(n)),o&&a.push(i.clone())}break;case 10:{let e=t[++l]*n,r=jr.byteTosbyte(t[++l]),s=(112&r)>>4,h=7&r;0==h&&(h=8);let c=Math.PI/4,u=c*h,d=Bf.CIRCLE_SPAN;r<0&&(d=-d,u=-u);let p=c*s,f=p+u,m=i.clone().sub(new be(Math.cos(p)*e,Math.sin(p)*e));if(i=m.clone().add(new be(Math.cos(f)*e,Math.sin(f)*e)),o){let t=p,n=!0;for(;n&&(t+=d,r>=0&&tf);)a.push(m.clone().add(new be(e*Math.cos(t),e*Math.sin(t))));a.push(i.clone())}}break;case 11:{let e=t[++l],r=t[++l],s=(255*t[++l]+t[++l])*n,h=jr.byteTosbyte(t[++l]),c=(112&h)>>4,u=7&h;0==u&&(u=8),0!=r&&u--;let d=Math.PI/4,p=d*u,f=Bf.CIRCLE_SPAN,m=1;h<0&&(f=-f,p=-p,m=-1);let g=d*c,v=g+p;g+=d*e/256*m,v+=d*r/256*m;let y=i.clone().sub(new be(s*Math.cos(g),s*Math.sin(g)));if(i=y.clone().add(new be(s*Math.cos(v),s*Math.sin(v))),o){let e=g,t=!0;for(;t&&(e+=f,h>0&&ev);)a.push(y.clone().add(new be(s*Math.cos(e),s*Math.sin(e))));a.push(i.clone())}}break;case 12:{let e=new be;e.x=jr.byteTosbyte(t[++l])*n,e.y=jr.byteTosbyte(t[++l])*n;let r=jr.byteTosbyte(t[++l]);r<-127&&(r=-127),o&&(0==r?a.push(i.clone().add(e)):a.push(Bf.generateArcPoints(i,e,r/127))),i.add(e)}break;case 13:for(;;){let e=new be;if(e.x=jr.byteTosbyte(t[++l])*n,e.y=jr.byteTosbyte(t[++l])*n,0==e.x&&0==e.y)break;let r=jr.byteTosbyte(t[++l]);r<-127&&(r=-127),o&&(0==r?a.push(i.clone().add(e)):a.push(Bf.generateArcPoints(i.clone(),e,r/127))),i.add(e)}break;case 14:l=Bf.skipCode(e,t,++l);break;default:if(h>15){let e=(240&h)>>4,t=15&h,r=new be;switch(t){case 0:r.x=1;break;case 1:r.x=1,r.y=.5;break;case 2:r.x=1,r.y=1;break;case 3:r.x=.5,r.y=1;break;case 4:r.y=1;break;case 5:r.x=-.5,r.y=1;break;case 6:r.x=-1,r.y=1;break;case 7:r.x=-1,r.y=.5;break;case 8:r.x=-1;break;case 9:r.x=-1,r.y=-.5;break;case 10:r.x=-1,r.y=-1;break;case 11:r.x=-.5,r.y=-1;break;case 12:r.y=-1;break;case 13:r.x=.5,r.y=-1;break;case 14:r.x=1,r.y=-1;break;case 15:r.x=1,r.y=-.5}i.add(r.multiplyScalar(e*n)),o&&a.push(i.clone())}}}return new od(i,r)}static skipCode(e,t,n){switch(t[n]){case 0:case 1:case 2:case 5:case 6:case 14:default:break;case 3:case 4:n++;break;case 7:switch(e.fontType){case 0:n++;break;case 1:0==t[++n]&&(n+=6);break;case 2:n+=2}break;case 8:case 10:n+=2;break;case 9:for(;;){let e=t[++n],i=t[++n];if(0==e&&0==i)break}break;case 11:n+=5;break;case 12:n+=3;break;case 13:for(;;){let e=t[++n],i=t[++n];if(0==e&&0==i)break;t[++n]}}return n}static generateArcPoints(e,t,n){let i=e.clone().add(t),r=n<0;n=Math.abs(n);let a=t.length()/2,s=a*n,o=2*Math.atan(1/n),l=new be(t.y,-t.x);l.normalize(),l.multiplyScalar(s);let h=Math.abs(a/Math.sin(o/2)),c=e.add(t.divideScalar(2));!1!==r?c.add(l):c.sub(l);let u=e.sub(c),d=i.sub(c),p=Math.atan2(u.y,u.x),f=Math.atan2(d.y,d.x),m=Bf.CIRCLE_SPAN;r?(m=-m,pf&&(p-=2*Math.PI);let g=p;for(;;){if(g+=m,!r&&gf)return c.add(new be(h*Math.cos(g),h*Math.sin(g)));break}return i}},Bc=Bf;Bc.FILE_STOP_FLAG=["\r","\n","\x1a"],Bc.CIRCLE_SPAN=Math.PI/18;var Zge=new Ln,WC=class extends vy{constructor(e,t){if(super(e,t),this.isExtend=!1,this.isUniCode=!0,this.isEmbedded=!1,this.fontType=2,this.textShapesCache=new Map,this.graphicData=new Map,t instanceof ArrayBuffer){let e=new Cf(t),n=Bc.parserHeader(e,Bc.FILE_STOP_FLAG).split(" ");switch(n[1]){case"shapes":this.parseShapeFont(e),this.fontType=0;break;case"bigfont":this.parseBigFont(e),this.fontType=1;break;case"unifont":this.parseUniFont(e),this.fontType=2}this.fileHeader=n[0],this.fileVersion=n[2]}else this.setFontFile(t)}generateShapes(e,t){let n=[],i=0;for(let r=0;rnew be(e[0],e[1]))));i=new od(new be,t),this.graphicData.set(e,i)}if(this.graphicData.has(e)){let n=t/WC.DEFAULT_SIZE;Zge.identity().scale(n,n),i=this.graphicData.get(e).transform(Zge)}return i}getGraphicDataByCodeWithOffset(e,t,n){var i;return null==(i=this.getGraphicDataByCode(e,t))?void 0:i.offset(n)}parseBigFont(e){jr.ToInt16(e.readBytes(2),0);let t=jr.ToInt16(e.readBytes(2),0),n=jr.ToInt16(e.readBytes(2),0);for(let o=0;o>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:t+=String.fromCharCode(i);break;case 12:case 13:r=e[n++],t+=String.fromCharCode((31&i)<<6|63&r);break;case 14:r=e[n++],a=e[n++],t+=String.fromCharCode((15&i)<<12|(63&r)<<6|(63&a)<<0)}return t}ld.DEFAULT_SIZE=12;var Hl=class{constructor(){this.fontMap=new Map,this.unsupportedChars={},this.missingFonts={},this.loader=new Kr}loadFonts(e){return ft(this,null,(function*(){if(e=Array.isArray(e)?e:[e],this.fileNames=e.map((e=>Hl.getFileName(e).toLowerCase())),!(yield this.checkAllFontsLoaded(e))){for(let t=0;tft(this,null,(function*(){yield e.setFontDataToIndexedDb()})))),this.releaseFontData())}}))}getTextShape(e,t,n){if(0===this.fontMap.size)return void se.warn("[FontManager] no font loaded.");let i=this.fontMap.get(t.toLowerCase());return i||(i=this.fontMap.get(this.fontMap.keys().next().value),this.missingFonts[t]||(this.missingFonts[t]=0),this.missingFonts[t]++),null==i?void 0:i.generateShapes(e,n)}getCharShape(e,t,n){if(0===this.fontMap.size)return void se.warn("[FontManager] no font loaded.");let i=this.fontMap.get(t.toLowerCase());if(!i){this.missingFonts[t]||(this.missingFonts[t]=0),this.missingFonts[t]++;for(let[t,r]of this.fontMap)if(r.getCharShape(e,n)){i=r;break}}let r=null==i?void 0:i.getCharShape(e,n);if(r){if(i instanceof ld)return r.toThreeGeometry();if(i instanceof Nf)return new SC(e,{font:i,height:0,size:n||12,curveSegments:3,bevelSegments:3})}}getNotFoundTextShape(e){let t,n;for(let[i,r]of this.fontMap){let i=r.getNotFoundTextShape(e);if(i){t=i,n=r;break}}return n instanceof ld?t.toThreeGeometry():n instanceof Nf?new ta(t.toShapes(!1),{curveSegments:3,bevelSegments:3}):void 0}checkAllFontsLoaded(e){return ft(this,null,(function*(){if(!Dn.isBrowser)return!1;let t=!1;for(let n=0;ne.order-t.order));for(let t=0;t{Object.assign(this.unsupportedChars,e.unsupportedChars)})),this.unsupportedChars}releaseFontData(){this.fontMap.forEach((e=>{e.releaseFontData()})),this.fontMap.clear()}destroy(){this.releaseFontData(),this.fontMap.clear()}static isShxFile(e){return"shx"===Hl.getExtension(e)}static isTtfFile(e){return["WOFF","OTF","TTF"].includes(Hl.getExtension(e).toUpperCase())}static isJsonFile(e){return"json"===Hl.getExtension(e)}static getFileName(e){let t=e.lastIndexOf("/");return e.substring(t+1)}static getExtension(e){return e.substring(e.lastIndexOf(".")+1)}},cd=Hl;cd.enableFontCache=!0;var Uc=new O(1,0,0),D6=new O(0,1,0),Zu=new O(0,0,1),Kge=new O(0,0,0),Hf=16777215,Ygt="CONTINUOUS",jC=new xi({color:Hf}),Ea=new Gn({color:Hf}),Ty=new ln({color:Hf}),Jge=(new Dt).setFromPoints([new O]),Qge=new Qe,e0e=new Qe,Eo=new Qe,rr=new O,Vi=new O,wy=new O,o_=new be,Ys=new hr,t0e=new hr,XC=new on,Uf=new Ot,n0e=new xi({color:65280,size:5,depthTest:!1}),r0e=new xi({color:65280,depthTest:!1}),i0e=new xi({color:65280,depthTest:!1}),$gt=e=>void 0!==e.viewDirectionFromTarget,Zgt=e=>{if(e){let t=e.match(/data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+).*,.*/);if(t&&t.length>0){let n=t[1],i=e.replace("data:"+n+";","").split(",");if(i&&2===i.length&&"base64"===i[0]){let e=i[1];return Gpe.decode(e)}}}return null},s0e=(e,t)=>{let n=new be(e.x,e.y),i=new be(t.x,t.y);return i.sub(n),i.normalize(),i.y<0?-Math.acos(i.x):Math.acos(i.x)},a0e=(e,t,n)=>({x:e.x+t*Math.cos(n),y:e.y+t*Math.sin(n)}),Kgt=(e,t,n,i)=>{let r=e?new be(e.x,e.y):new be(0,0),a=t?new be(t.x,t.y):new be(1,0);n=n||1;let s=4*Math.atan(n),o=r.distanceTo(a)/2/Math.sin(s/2),l=a0e(e,o,s0e(r,a)+(Math.PI/2-s/2));i=i||Math.max(Math.abs(Math.ceil(s/(Math.PI/18))),6);let h=s0e(l,r),c=s/i,u=[];u.push(new O(r.x,r.y,0));for(let d=1;d<=i-1;d++){let e=a0e(l,Math.abs(o),h+c*d);u.push(new O(e.x,e.y,0))}return u},Jgt=(e,t,n,i=2*e.length,r)=>{let a=[],s=e.map((e=>[e.x,e.y]));for(let o=0;o<1;o+=1/i){let e=Q5(o,t,s,n,r);a.push(new O(e[0],e[1],0))}return a},O6=(e,t=!1)=>{let n=[],i=e.length;for(let r=0;r{let t=[];return e.faceA&&t.push(e.faceA),e.faceB&&t.push(e.faceB),e.faceC&&t.push(e.faceC),e.faceD&&t.push(e.faceD),t},e0t=e=>{let t=[],n=[];e.forEach((e=>{e.polyfaceMeshVertex&&(e.threeDPolylineMesh?t.push(new O(e.x,e.y,e.z)):n.push(Qgt(e)))}));let i=[];for(let r=0;r=t.length||i<0){s=!1;break}a.push(t[i])}!s||0===a.length||(a.push(a[0]),i.push(a))}return i},Zn=class extends _r{constructor(e,t){super(e),this.timer=Date.now(),this.ignorePaperSpace=!1,this.encoding="UTF-8",this.angBase=0,this.angDir=0,this.header=void 0,this.pointsMaterials={},this.lineBasicMaterials={},this.lineShaderMaterials={},this.meshBasicMaterials={},this.meshTextureMaterials={},this.hatchShaderMaterials=[],this.entityCount=0,this.curveCount=0,this.averageCurveSize=0,this.enableRenderOrder=!1,this.enableLocalCache=!0,this.enableReleaseData=!0,this.enableMerge=!0,this.enableRTC=!0,this.enablePlineWidth=!0,this.dxfDataId=void 0,this.compareContext=void 0,this.statsInfo={unsupportedEntity:{},unsupportedEntityTypes:{},unsupportedTextStyles:{},unsupportedHatchPatterns:{},unsupportedPolylineCount:0,invisibleEntities:{},ignoredFrozenLayersAndEntityCount:{},ignoredInserts:{},entityTypesAndMeshCount:{},ignoredPaperSpaceEntityTypesAndCount:{},rebasedEntityCount:0},this.blockReferencesCache={},this.blockRecordsCache=void 0,this.entitiesCache=void 0,this.blocksCache=void 0,this.dictionaryOwnerHandleAndSpatialFilterHandlesCache=void 0,this.spatialFiltersCache=void 0,this.entityThreejsCache=void 0,this.entityTypesAndTimes=void 0,this.nonSnapableTypes=new Set(["ATTDEF","ATTRIB","LEADER","MTEXT","MULTILEADER","OLE2FRAME","TEXT"]),this.layoutsSnapObjectsMap={},this.entityHandlesWithRenderOrder={},this.addViewport=(e,t)=>{if("VIEWPORT"===e.type){t[e.ownerHandle]||(t[e.ownerHandle]=[]);let n=e;t[e.ownerHandle].push(n)}},Zn.abortJobs=!1,t&&(this.ignorePaperSpace=!0===t.ignorePaperSpace,this.enableLocalCache=!1!==t.enableLocalCache,this.enableMerge=!1!==t.enableMerge,this.encoding=t.encoding||"UTF-8",null!=t.overrideColor&&(this.overrideColor=Cn.rgb2Hex(t.overrideColor))),this.pointsMaterials[Hf]=jC,this.lineBasicMaterials[Hf]=Ea,this.meshBasicMaterials[Hf]=Ty}setFont(e){this.font=e}download(e,t){return ft(this,null,(function*(){let n=Zgt(e);if(!n){let i=Date.now(),r=new Kr(this.manager);r.setResponseType("arraybuffer"),r.setPath(this.path),n=yield r.loadAsync(e,t),se.info(`[DxfLoader] ${e} dxf file downloaded in ${(Date.now()-i)/1e3}s`)}return n}))}load(e,t,n){return ft(this,null,(function*(){return this.enableLocalCache&&t&&(t=t.trim()).length>0&&(this.dxfDataId=t),this.loadAsync(e,n)}))}loadAsync(e,t){return ft(this,null,(function*(){let n=Mt.getUpdateSubProgressFunc(0,50,t),i=Mt.getUpdateSubProgressFunc(50,100,t),r=Mt.getUpdateSubProgressFunc(10,100,t);if(Dn.isBrowser&&this.enableLocalCache&&this.dxfDataId){let t;try{if(this.timer=Date.now(),t=yield this.getDxfDataFromIndexedDb(this.dxfDataId),t){this.tryFixDxfData(t),se.info(`[DxfLoader] Loaded DxfData from indexedDb in ${(Date.now()-this.timer)/1e3}s`);let e=yield this.loadEntities(t,r);return Promise.resolve(e)}}catch(e){se.warn("[DxfLoader] Failed to parse data from indexedDb",e)}}let a=yield this.parse(e,n);return this.tryFixDxfData(a),yield this.loadEntities(a,i)}))}parse(e,t){return ft(this,null,(function*(){let n=Mt.getUpdateProgressFunc(t),i=Mt.getUpdateSubProgressFunc(0,40,t),r=yield this.download(e,i);if(!r)return Promise.reject(`[DxfLoader] Failed to download ${e}`);if(Zn.abortJobs)return Promise.reject("[DxfLoader] Job aborted");this.timer=Date.now(),se.info("[DxfLoader] Start parsing...");let a=new Xm(this.encoding).parseSync(r);if(this.tryFixDxfData(a),n(80),se.info(`[DxfLoader] Parsed in ${(Date.now()-this.timer)/1e3}s, creating entities...`),Zn.abortJobs)return Promise.reject("[DxfLoader] Job aborted");if(a&&Dn.isBrowser&&this.enableLocalCache&&this.dxfDataId){let t=Date.now();try{yield this.setDxfDataToIndexedDb(this.dxfDataId,a),se.info(`[DxfLoader] Saved to indexedDb in ${(Date.now()-t)/1e3}s`)}catch(e){se.warn(`[DxfLoader] Failed to save '${this.dxfDataId}' to indexedDb!`,e)}}return n(100),a}))}parseHeader(e){if(!e)return void se.error("[DxfLoader]: Invalid header!");this.header=e;let t=e.$ACADVER.toString();"AC1032"!==t&&se.warn(`[DxfLoader] Unexpected version: ${t}. But we'll try to continue.`),this.angBase=e.$ANGBASE||0,this.angDir=e.$ANGDIR||0}tryFixDxfData(e){e&&(e.objects||(se.warn("[DxfLoader] No objects found, Will add one."),e.objects={}),e.objects.LAYOUT||(se.warn("[DxfLoader] No layout defined! Will add a default 'Model' layout!"),e.objects.LAYOUT=[{layoutName:Zn.MODEL_LAYOUT_NAME}]),e.tables||(se.warn("[DxfLoader] No tables found, Will add one."),e.tables={}),e.tables.layer||(e.tables.layer={}),e.tables.layer.layers||(e.tables.layer.layers={}))}loadEntities(e,t){return ft(this,null,(function*(){let n=Date.now();this.parseHeader(e.header),this.enableRenderOrder&&(this.initRenderOrderInfo(e),this.enableMerge=!1),this.getFontFilesFromDxf(e);let i=0,r=e.entities.length;this.entityCount=r,Object.keys(e.blocks).forEach((t=>{var n;this.entityCount+=(null==(n=e.blocks[t].entities)?void 0:n.length)||0}));let a=Mt.getUpdateProgressFuncForLoop(r,t),s={},o=e=>{let t=e.userData.layerName,n=s[t];n||(n=[],s[t]=n),n.push(e)},l={},h={},c=new bn;for(let t=0;te.name===s));if(u||(u=new bn,u.name=s,u.userData.isLayoutLevelObject=!0,c.add(u)),r.traverse((e=>{e.userData.isSnapObject&&(this.layoutsSnapObjectsMap[s]||(this.layoutsSnapObjectsMap[s]=[]),this.layoutsSnapObjectsMap[s].push(e))})),this.enableMerge){Lc.merge(r,!1),h[s]||(h[s]={object:u,layerObjects:{}});let e=h[s];if(r.geometry){let t=r.userData.layerName;e.layerObjects[t]||(e.layerObjects[t]=[]),e.layerObjects[t].push(r),r.children.forEach((e=>{e.userData.isSnapObject&&o(e)}))}else r.children.length>0&&(u.add(r),r.traverse((e=>{e.geometry&&o(e)})))}else u.add(r),r.traverse((e=>{e.geometry&&o(e)}));i++,yield a(t)}e.objects.LAYOUT.forEach((t=>{let n=t,i=n.layoutName;if(this.ignorePaperSpace&&i!==Zn.MODEL_LAYOUT_NAME)return;let r=n.associatedBlockName,a=e.blocks[r];a&&this.drawLayout(a,e,n,c,s,l)})),se.debug(`[DxfLoader] Drew entities in ${(Date.now()-n)/1e3}s`);for(let t in this.layoutsSnapObjectsMap){let n=c.children.find((e=>e.name===t)),i=new bn;i.name=Zn.SNAP_GROUP_NAME,i.userData.isSnapGroup=!0,n.add(i);let r=this.layoutsSnapObjectsMap[t];for(let t=0;t=100&&(e=new Set(s));let t=t=>Array.isArray(e)?e.indexOf(t)>=0:e.has(t);for(let r=0,a=i.length;r{let t=e;d[t.layoutName]=t}));let p={};u.children.forEach((t=>{if(zn.setSharedVariablesOfObject(t),!t.userData.isLayoutLevelObject)return;let n,i=t.name;if(i!==Zn.MODEL_LAYOUT_NAME){let e=d[i];e.directAssociatedLeafObjectSet||(e.directAssociatedLeafObjectSet=new Set),n=e.directAssociatedLeafObjectSet}t.traverse((t=>{if(zn.setSharedVariablesOfObject(t),t.userData.isSnapGroup&&(t.visible=Zn.SHOW_SNAP_OBJECT),t.geometry){let i=t.userData.layerName;!1===this.getLayerVisible(e,i)&&(t.visible=!1,t.userData.layerVisible=!1),(e=>{let t=e.userData.layerName,n=p[t];n||(n=[],p[t]=n),n.push(e)})(t),n&&n.add(t)}}))})),se.info(`[DxfLoader] loadEntities() done in ${(Date.now()-n)/1e3}s`);let f=Ri(wr({},e),{threejsObject:u,layersAndThreejsObjects:p,loadedEntityCount:i,layoutViewportsMap:l});return Promise.resolve(f)}))}getFontFilesFromDxf(e){let t=new Set;if(e.tables.style.styles){let n=e.tables.style.styles;for(let e in n){let i=n[e],r=i.fontFile,a=i.bigFontFile;r&&t.add(r),a&&t.add(a)}}se.info(`[DxfLoader] These are fonts used by dxf: ${Array.from(t).join()}`)}loadEntitiesForCompare(e,t,n,i=!0,r){return ft(this,null,(function*(){let a=e.entities.length,s=t.entities.length,o=()=>ft(this,null,(function*(){var o;let l=this.compareContext,h=l.isTheFirstFile,c=h?e:t,u=new bn,d=h?a:s,p=c.entities.length;this.entityCount=p,Object.keys(c.blocks).forEach((e=>{var t;this.entityCount+=(null==(t=c.blocks[e].entities)?void 0:t.length)||0}));let f=Math.round(Math.pow(d,.5)),m=Date.now(),g=e=>ft(this,null,(function*(){if(r&&(e%f==0||e===d-1)){let t=e+1;h||(t+=a),r(new ProgressEvent("parseProgress",{loaded:t,total:a+s}));let n=500,i=Date.now();(i-m>n||e===d-1)&&(yield Mt.sleep(0),m=i)}}));this.parseHeader(c.header);let v={};for(let e=0;ee.name===Zn.MODEL_LAYOUT_NAME));r||(r=new bn,r.name=Zn.MODEL_LAYOUT_NAME,r.userData.isLayoutLevelObject=!0,u.add(r)),r.add(i),i.traverse((e=>{if(e.geometry){let t=e.userData.layerName,r=this.getLayerVisible(c,t);e.userData.isSnapObject&&(this.layoutsSnapObjectsMap[n.layoutName]||(this.layoutsSnapObjectsMap[n.layoutName]=[]),this.layoutsSnapObjectsMap[n.layoutName].push(e),!1===r&&i.layers.disable(11));let a=v[t];a||(a=[],v[t]=a),a.push(e)}})),yield g(e)}i&&h&&(l.preservedHandles||(l.preservedHandles=new Set));for(let e in n){let t=n[e];h&&("Added"===t.type||"Modified"===t.type)&&(null==(o=l.preservedHandles)||o.add(t.handle),t.parentHandles&&t.parentHandles.forEach((e=>{var t;return null==(t=l.preservedHandles)?void 0:t.add(e)})));let i=this.entityThreejsCache&&this.entityThreejsCache[t.handle];if(t.parentHandles&&(i=this.entityThreejsCache&&this.entityThreejsCache[t.parentHandles[t.parentHandles.length-1]]),i){if(i.parent&&i.parent.userData.originalType){this.setObjectColorByChange(i,{type:"NoChange"});continue}i=this.setObjectColorByChange(i,t)}if("NoChange"!==t.type&&i){let e=i.parent,n=Eo.identity();for(;e&&!0!==e.userData.isLayoutLevelObject;)n.premultiply(e.matrix),e=e.parent;Uf.makeEmpty();let r=bn.getBox(i,Uf);r.applyMatrix4(n),"Added"===t.type?!h&&(t.box=(new Ot).copy(r)):"Removed"===t.type?h&&(t.box=(new Ot).copy(r)):"Modified"===t.type&&(t.box?t.box.union(r):t.box=(new Ot).copy(r))}}for(let e in this.layoutsSnapObjectsMap){let t=u.children.find((t=>t.name===e)),n=new bn;n.name=Zn.SNAP_GROUP_NAME,t.add(n);let i=this.layoutsSnapObjectsMap[e];for(let e=0;e{zn.setSharedVariablesOfObject(e),e.userData.isLayoutLevelObject&&e.traverse((e=>{if(zn.setSharedVariablesOfObject(e),e.userData.isSnapGroup&&(e.visible=Zn.SHOW_SNAP_OBJECT),e.geometry){let t=e.userData.layerName;!1===this.getLayerVisible(c,t)&&(e.visible=!1,e.userData.layerVisible=!1),(e=>{let t=e.userData.layerName,n=x[t];n||(n=[],x[t]=n),n.push(e)})(e)}}))}));let b=c;b.threejsObject=y,b.layersAndThreejsObjects=x,b.layoutViewportsMap={}})),l=Date.now();this.compareContext={changes:n,isTheFirstFile:!0},Mt.printMemory("Before loading entities for first dxf"),yield o(),se.info(`[DxfLoader] loadEntities for first dxf in ${(Date.now()-l)/1e3}s`),Mt.printMemory("After loading entities for first dxf"),this.releaseCachedData(!1),this.releaseDxfData(e),Mt.printMemory("Before loading entities for second dxf"),l=Date.now(),this.compareContext.isTheFirstFile=!1,yield o(),se.info(`[DxfLoader] loadEntities for second dxf in ${(Date.now()-l)/1e3}s`),this.printStatsInfo();for(let e of Object.values(n))e.box||delete n[e.id];this.compareContext.preservedHandles=void 0,this.enableReleaseData&&(this.releaseCachedData(),this.releaseDxfData(t)),Mt.printMemory("After loading entities for second dxf")}))}setObjectColorByChange(e,t){let n=(e,t)=>{e.traverse((e=>{if(e.material)if(e.material instanceof Gn)e.material=this.getLineBasicMaterial(t);else if(e.material instanceof ln)e.material=this.getMeshBasicMaterial(t);else if(e.material instanceof xi)e.material=this.getPointsMaterial(t);else if(e.material instanceof cn){let n=e.material.clone();Zn.updateMaterialUniforms(n),n.uniforms.u_color.value.set(t),e.material=n}}))},i=(e=>{var t;let n=us.ENTITY_COLOR_NO_CHANGE;return"Added"===e.type?n=us.ENTITY_COLOR_ADDED:"Removed"===e.type?n=us.ENTITY_COLOR_REMOVED:"Modified"===e.type&&(n=null!=(t=this.compareContext)&&t.isTheFirstFile?us.ENTITY_COLOR_REMOVED:us.ENTITY_COLOR_ADDED),n})(t);return e.traverse((r=>{t.parentHandles?r.userData&&r.userData.handle&&r.userData.handle===t.handle&&(n(r,i),e=r):n(r,i)})),e}releaseCachedData(e=!0){e&&(this.pointsMaterials={},this.lineBasicMaterials={},this.lineShaderMaterials={},this.meshBasicMaterials={},this.meshTextureMaterials={},this.hatchShaderMaterials=[]),this.header=void 0,this.blockReferencesCache={},this.blockRecordsCache=void 0,this.blocksCache=void 0,this.entitiesCache=void 0,this.dictionaryOwnerHandleAndSpatialFilterHandlesCache=void 0,this.spatialFiltersCache=void 0,this.entityThreejsCache=void 0,this.entityTypesAndTimes=void 0,this.entityHandlesWithRenderOrder={},this.layoutsSnapObjectsMap={},this.statsInfo={unsupportedEntity:{},unsupportedEntityTypes:{},unsupportedTextStyles:{},unsupportedHatchPatterns:{},unsupportedPolylineCount:0,invisibleEntities:{},ignoredFrozenLayersAndEntityCount:{},ignoredInserts:{},entityTypesAndMeshCount:{},ignoredPaperSpaceEntityTypesAndCount:{},rebasedEntityCount:0}}releaseEntity(e){e.vertices&&(e.vertices=void 0),e.knotValues&&(e.knotValues=void 0),e.controlPoints&&(e.controlPoints=void 0),e.binaryData&&(e.binaryData=void 0),e.text&&(e.text=void 0),e.extendedData&&(e.extendedData=void 0),e.contextData&&(e.contextData=void 0);let t=e;t.boundaryPaths&&(t.boundaryPaths=[]),t.patternLines&&(t.patternLines=void 0)}releaseDxfData(e){delete e.objects.DICTIONARY,delete e.objects.SORTENTSTABLE,delete e.objects.XRECORD,e.tables&&(delete e.tables.dimStyle,delete e.tables.lineType,delete e.tables.style,delete e.tables.blockRecord),e.entities=[],e.blocks={}}drawEntity(e,t,n,i=!1){if(this.compareContext&&this.compareContext.preservedHandles&&this.compareContext.preservedHandles.has(e.handle)&&qm.includes(e.type)&&(i=!0),!i&&this.compareContext&&this.compareContext.preservedHandles&&!qm.includes(e.type)&&!this.compareContext.preservedHandles.has(e.handle)&&(!n||n&&!this.compareContext.preservedHandles.has(n.handle)))return;if(!0===this.getLayerFrozen(t,e)){let t=e.layer;return this.statsInfo.ignoredFrozenLayersAndEntityCount[t]||(this.statsInfo.ignoredFrozenLayersAndEntityCount[t]=0),void this.statsInfo.ignoredFrozenLayersAndEntityCount[t]++}if(!1===e.visible||e.invisible)return this.statsInfo.invisibleEntities[e.type]||(this.statsInfo.invisibleEntities[e.type]=0),void this.statsInfo.invisibleEntities[e.type]++;if(this.ignorePaperSpace&&e.inPaperSpace)return this.statsInfo.ignoredPaperSpaceEntityTypesAndCount[e.type]||(this.statsInfo.ignoredPaperSpaceEntityTypesAndCount[e.type]=0),void this.statsInfo.ignoredPaperSpaceEntityTypesAndCount[e.type]++;this.entityThreejsCache||(this.entityThreejsCache={});let r,a=Date.now(),s=!1;if(!this.compareContext&&this.entityThreejsCache[e.handle])r=this.entityThreejsCache[e.handle].clone(),s=!0;else if(!this.statsInfo.unsupportedEntity[e.handle]){if("CIRCLE"===e.type||"ARC"===e.type)r=this.drawArc(e,t,n);else if("LINE"===e.type||"POLYLINE"===e.type)r=this.drawLine(e);else if("XLINE"===e.type)r=this.drawXLine(e);else if("SEQEND"!==e.type)if("RAY"===e.type)r=this.drawRay(e);else if("LWPOLYLINE"===e.type)r=this.drawLWPolyline(e,t,n);else if("3DFACE"===e.type)r=this.draw3DFace(e);else if("TEXT"===e.type)r=this.drawText(e,t,n);else if("SOLID"===e.type)r=this.drawSolid(e,t,n);else if("POINT"===e.type)r=this.drawPoint(e,t,n);else if("IMAGE"===e.type)r=this.drawImage(e,t,n);else if("INSERT"===e.type)r=this.drawInsert(e,t,i);else if("SPLINE"===e.type)r=this.drawSpline(e,n);else if("MTEXT"===e.type)r=this.drawMText(e,t,n);else if("ELLIPSE"===e.type)r=this.drawEllipse(e,t,n);else if("DIMENSION"===e.type)r=this.drawDimension(e,t);else if("REGION"!==e.type)if("ATTDEF"===e.type)r=this.drawAttDef(e,t,n);else if("ATTRIB"===e.type){if(!n)for(let i=0;i{r.geometry&&(r.userData.layerName=i,this.setMaterial(r,e,t,n))})),s||(this.nonSnapableTypes.has(e.type)&&r.traverse((e=>{e.layers.disable(11)})),this.enableRenderOrder&&(this.entityHandlesWithRenderOrder[e.handle]?r.renderOrder=parseInt(this.entityHandlesWithRenderOrder[e.handle],16)+.1:r.renderOrder=parseInt(e.handle,16)))}return qm.includes(e.type)||(this.entityTypesAndTimes||(this.entityTypesAndTimes={}),this.entityTypesAndTimes[e.type]||(this.entityTypesAndTimes[e.type]={createCount:0,totalTime:0,averageTime:0}),this.entityTypesAndTimes[e.type].createCount++,this.entityTypesAndTimes[e.type].totalTime+=Date.now()-a),r?this.statsInfo.entityTypesAndMeshCount[e.type]?this.statsInfo.entityTypesAndMeshCount[e.type]++:this.statsInfo.entityTypesAndMeshCount[e.type]=1:(this.statsInfo.unsupportedEntityTypes[e.type]?this.statsInfo.unsupportedEntityTypes[e.type]++:this.statsInfo.unsupportedEntityTypes[e.type]=1,qm.includes(e.type)||(this.statsInfo.unsupportedEntity[e.handle]?this.statsInfo.unsupportedEntity[e.handle]++:this.statsInfo.unsupportedEntity[e.handle]=1)),r}drawEllipse(e,t,n){if(!e.majorAxisEndPoint||!e.center||void 0===e.axisRatio||void 0===e.startAngle||void 0===e.endAngle)return;let i=e.startAngle,r=e.endAngle;if(e.extrusionDirection&&e.extrusionDirection.z<0&&(i=2*Math.PI-e.endAngle,r=2*Math.PI-e.startAngle),Zt.areNumbersEqual(i,r,1e-5))return void se.warn("[DxfLoader] Ellipse entity (handle '%s') contains the same start and end angle, ignored!",e.handle);let a=r-i;for(;a>2*Math.PI;)a-=2*Math.PI;Math.abs(a)<=1e-5&&(r=Zt.floorNumber(i+2*Math.PI,5));let s=Math.sqrt(Math.pow(e.majorAxisEndPoint.x,2)+Math.pow(e.majorAxisEndPoint.y,2)),o=s*e.axisRatio,l=Math.atan2(e.majorAxisEndPoint.y,e.majorAxisEndPoint.x),h=new Zh(e.center.x,e.center.y,s,o,i,r,!1,l),c=1,u=n;null!=u&&u.xScale&&null!=u&&u.yScale&&(c=Math.max(Math.abs(u.xScale),Math.abs(u.yScale)));let d=this.getDivision(i,r,Math.max(s,o)*c),p=h.getPoints(d),f=[],m=p.length;for(let _=0;_{e.geometry&&e.geometry.translate(c,u,0),e.layers.enableAll()})),e.rotation&&Ys.setFromAxisAngle(Zu,e.rotation*Math.PI/180),e.directionVector){let t=e.directionVector,n=new O(t.x,t.y,t.z),i=n.clone().cross(Uc),r=Uc.angleTo(n);Ys.multiply(t0e.setFromAxisAngle(Zu,i.z>0?-r:r))}return Qt.shouldRebasePositionOnRTC(Vi)&&this.setRTCUserData(s),s.matrix.compose(Vi,Ys,wy),s}getMTextGroup(e,t,n,i,r,a=0,s=0,o=[]){var l,h,c;if(0===e.length)return;let u=t.height||t.contextData&&t.contextData.textHeight||0;if(t.textStyle){if(n&&n.fontFile&&n.fontFile.endsWith(".shx")){let e=`${n.fontFile}_${n.styleName}`;this.statsInfo.unsupportedTextStyles[e]||(this.statsInfo.unsupportedTextStyles[e]=0),this.statsInfo.unsupportedTextStyles[e]++}u=u||n.textHeight}let d=t.lineSpaceFactor||1,p="Left";t.width&&t.attachmentPoint&&([1,4,7].includes(t.attachmentPoint)?p="Left":[2,5,8].includes(t.attachmentPoint)?p="Center":[3,6,9].includes(t.attachmentPoint)&&(p="Right"));let f,m,g=t.width||0,v=new bn,y=1,x=1,b=256,_=d*u*.3,w=_+u;for(let S=0;S{let t;if(e.forEach(((e,n)=>{e.boundingBox||e.computeBoundingBox(),0===n?t=e.boundingBox:t.union(e.boundingBox)})),t){let n=t.getSize(rr);switch(p){case"Left":default:break;case"Center":e.forEach((e=>e.translate((g-n.x)/2,0,0)));break;case"Right":e.forEach((e=>e.translate(g-n.x,0,0)))}}S.push(...e)};for(let t=0;t(g||1/0))a=0,s-=w,o.length>0&&E(o),o=[];else{e.boundingBox||e.computeBoundingBox();let t=e.boundingBox.getSize(rr).x;" "===i&&(t=u/2),a+=t+x*(u/6),o.push(e)}else a+=u+x*(u/6);else a=0,s-=w,o.length>0&&E(o),o=[]}o.length>0&&(E(o),o=[]);let T=new bn;if(S.length>0){f||(f=t.colorIndex),void 0!==b&&256!==b?(t.color=Wm(b),t.colorIndex=b):t.colorIndex=f;let e=this.getColor(t,i,r),n=S.filter((e=>e instanceof ta)),a=S.filter((e=>!(e instanceof ta)));if(n.length>0){let t=new bn(4);t.geometry=Ni(n),t.material=this.getMeshBasicMaterial(e),T.add(t)}if(a.length>0){let t=new bn(3);t.geometry=Ni(a),t.material=this.getLineBasicMaterial(e),T.add(t)}}T.matrix.makeTranslation(0,-u,0),v.add(T),m=void 0,y=1,x=1,b=256,d=t.lineSpaceFactor||1}else if(Array.isArray(M)){let e=this.getMTextGroup(M,t,n,i,r,a,s,o);e&&(v.add(e.object),a=e.hOffset,s=e.vOffset)}else"object"==typeof M&&(M.f&&(m=M.f,m&&m.includes(".shx")&&se.info(`[DxfLoader] Doesn't support custom fonts: ${m}`)),M.C&&(b=M.C),M.W&&(y="x"===M.W[1]?M.W[0]*t.width:M.W[0]),M.H&&(u="x"===M.H[1]?M.H[0]*t.height:M.H[0]),M.T&&(x=M.T))}return 0!==v.children.length?(Lc.merge(v,!1),f&&(t.colorIndex=f),1===v.children.length?{object:v.children[0],hOffset:a,vOffset:s}:{object:v,hOffset:a,vOffset:s}):void 0}mtextContentAndFormattingToTextAndStyle(e,t){let n={horizontalAlignment:"",textHeight:t.height||t.contextData&&t.contextData.textHeight},i={},r=1,a=[];for(let s=0;s{a.push(e)})),r=e.lineLength}else if("object"==typeof o)if(o.S&&3===o.S.length){let e=o.S[0]+"/"+o.S[2],t=this.getTextLineNum(e);a.push({text:o.S[0]+"/"+o.S[2],lineNum:r}),r+=t}else void 0!==o.C?i.C=o.C:void 0!==o.W?i.W=o.W:void 0!==o.H?i.H=o.H:void 0!==o.f&&(i.f=o.f)}return{text:a,lineLength:r,style:n}}getTextLineNum(e){let t=e.match(new RegExp("\\n","g"));return t?t.length:0}draw3DFace(e){if(!e.vertices||0===e.vertices.length)return void se.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=e.vertices.map((e=>new O(e.x,e.y,e.z)));if(0===t.length)return;Zt.areVector3sEqual(t[0],t[t.length-1])||t.push(t[0]);let n=new O,i=!1;this.enableRTC&&(i=Qt.checkAndRebasePositionsOnRTC(t,n));let r=(new Dt).setFromPoints(t),a=new bn(2);return a.geometry=r,a.material=Ea,i&&(this.setRTCUserData(a),a.matrix.setPosition(n.x,n.y,0)),a.layers.enableAll(),a}drawSpline(e,t){if(!e.controlPoints||!e.degreeOfSplineCurve||!e.knotValues)return;let n=1/0,i=1/0,r=-1/0,a=-1/0;for(let g of e.controlPoints)g.xr&&(r=g.x),g.y>a&&(a=g.y);let s=1,o=t;null!=o&&o.xScale&&null!=o&&o.yScale&&(s=Math.max(Math.abs(o.xScale),Math.abs(o.yScale)));let l=Math.max(r-n,a-i),h=this.getBSplineInterpolationsPerSplineSegment(e.controlPoints.length,l*s),c=Jgt(e.controlPoints,e.degreeOfSplineCurve,e.knotValues,h),u=new O,d=!1;this.enableRTC&&(d=Qt.checkAndRebasePositionsOnRTC(c,u));let p=Qt.getAdjacentNonRepeatPoints(c);if(p.length<2)return void se.warn("[DxfLoader] Spline entity (handle '%s') contains less than 2 points, ignored!",e.handle);let f=(new Dt).setFromPoints(p),m=new bn(2);return m.geometry=f,m.material=Ea,d&&(this.setRTCUserData(m),m.matrix.setPosition(u.x,u.y,0)),m.layers.enableAll(),m}drawXLine(e){if(!e.vertices||0===e.vertices.length)return void se.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=Mt.arrayOrObjectToVector3(e.directionVector),n=new O(e.vertices[0].x,e.vertices[0].y,0),i=[];if(i.push(t.clone().multiplyScalar(-1e6).add(n)),i.push(t.clone().multiplyScalar(1e6).add(n)),0===i.length)return;let r=new O,a=!1;this.enableRTC&&(a=Qt.checkAndRebasePositionsOnRTC(i,r));let s=(new Dt).setFromPoints(i),o=new bn(2);return o.geometry=s,o.material=Ea,a&&(this.setRTCUserData(o),o.matrix.setPosition(r.x,r.y,0)),o.layers.enableAll(),o}drawRay(e){if(!e.vertices||0===e.vertices.length)return void se.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=Mt.arrayOrObjectToVector3(e.directionVector),n=e.vertices.map((e=>new O(e.x,e.y,0)));if(n.push(t.multiplyScalar(1e6).add(n[0])),0===n.length)return;let i=new O,r=!1;this.enableRTC&&(r=Qt.checkAndRebasePositionsOnRTC(n,i));let a=(new Dt).setFromPoints(n),s=new bn(2);return s.geometry=a,s.material=Ea,r&&(this.setRTCUserData(s),s.matrix.setPosition(i.x,i.y,0)),s.layers.enableAll(),s}drawLine(e){if(!e.vertices||0===e.vertices.length)return void se.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=[];if(e.isPolyfaceMesh)t=e0t(e.vertices);else{let n=O6(e.vertices,e.shape);e.shape&&n.length>0&&n.push(n[0]),n.length>0&&(t=[n])}if(0===t.length)return;let n=[];for(let s=0;s0){if(this.enableRTC){let e=0;t.forEach((t=>{t.forEach((t=>{r.add(t),e++}))})),r.divideScalar(e),a=Qt.shouldRebasePositionOnRTC(r)}let e=[],n=[],s=0,o=0,l=0,h=0;t.forEach((t=>{for(let i=0;i0&&n.push(s+i-1,s+i);s=t.length}));let c=(new Dt).setFromPoints(e);c.setIndex(n),i=new bn(3),i.geometry=c,i.material=Ea}if(n.length>0){this.enableRTC&&(a=Qt.checkAndRebasePositionsOnRTC(n,r));let e=(new Dt).setFromPoints(n);i=new bn(1),i.geometry=e,i.material=jC}return i?(a&&(this.setRTCUserData(i),i.matrix.setPosition(r.x,r.y,0)),i.layers.enableAll(),i):void 0}drawLWPolyline(e,t,n){var i,r,a;if(!e.vertices||e.vertices.length<2)return void se.warn("[DxfLoader] Invalid LWPolyline entity (handle '%s'), ignored!",e.handle);let s=e;if(void 0!==s.extrusionDirectionX&&void 0!==s.extrusionDirectionY&&void 0!==s.extrusionDirectionZ){rr.set(s.extrusionDirectionX,s.extrusionDirectionY,s.extrusionDirectionZ);let e=Zn.getOcsMatrix(rr).invert(),t=0;void 0!==s.elevation&&s.elevation>0&&(t=s.elevation),s.vertices.forEach((n=>{let i=rr.set(n.x,n.y,t).applyMatrix4(e);n.x=i.x,n.y=i.y}))}let o=O6(e.vertices,e.shape);if(e.shape&&o.length>0&&!Zt.areVector3sEqual(o[0],o[o.length-1])&&o.push(o[0]),o.length<2)return void se.warn("[DxfLoader] Invalid LWPolyline entity (handle '%s'), ignored!",e.handle);let l=new bn;if(null!=(i=e.extendedData)&&i.outlines){let t=e.extendedData.outlines,n=[];t.forEach((e=>{let t=new Ss;e.forEach(((e,n)=>{0===n?t.moveTo(e[0],e[1]):t.lineTo(e[0],e[1])})),t.closePath(),n.push(new Al(t))}));let i=Ni(n),r=new bn(4);r.geometry=i,r.material=Ty,r.layers.enableAll(),l.add(r)}let h=new O,c=!1;this.enableRTC&&(c=Qt.checkAndRebasePositionsOnRTC(o,h));let u=Qt.getAdjacentNonRepeatPoints(o);if(u.length<2)return void se.warn("[DxfLoader] Invalid LWPolyline entity (handle '%s'), ignored!",e.handle);if(this.enablePlineWidth&&void 0!==s.constantWidth&&s.constantWidth>0){let i=null==(a=null==(r=t.tables)?void 0:r.lineType)?void 0:a.lineTypes,o=i&&i[this.getLineType(e,t,n)];if(!o||!o.pattern||0===o.pattern.length){this.statsInfo.unsupportedPolylineCount++;let t=Qt.convertWidthLineToMeshGeometry(u,s.constantWidth);if(t){let e=new bn(4);e.geometry=t,e.material=Ty,e.layers.enableAll(),e.layers.disable(11),l.add(e);let n=zn.createOutline(t,Ea,e.matrix),i=new bn(3);i.geometry=n.geometry,i.material=n.material,i.matrix=n.matrix,i.layers.enableAll(),i.layers.disable(11),l.add(i)}else se.warn("[DxfLoader] Failed to convert line with width to mesh geometry: %s",e.handle)}}let d=new bn(2);return d.geometry=(new Dt).setFromPoints(u),d.material=Ea,d.layers.enableAll(),l.children.length>0?l.add(d):l=d,c&&(this.setRTCUserData(l),l.matrix.setPosition(h)),l}drawMLeader(e,t,n){var i,r,a,s,o,l,h;let c=t.tables.dimStyle.dimStyles[e.dimensionStyle]||this.getDefaultDimensionStyle(t),u=null==(i=e.contextData)?void 0:i.defaultTextContents;if(!u)return;let d=new bn,p=TC(u),f=this.getTextStyle(t,e),m=this.getMTextGroup(p,e,f,t,n),g=m&&m.object;if(g){g.matrix.decompose(Vi,Ys,wy),null!=(r=e.contextData)&&r.textLocation&&(Vi.x+=e.contextData.textLocation.x,Vi.y+=e.contextData.textLocation.y,g.matrix.compose(Vi,Ys,wy)),Uf.makeEmpty();let t=bn.getBox(g,Uf).getSize(rr),n=t.x,i=t.y,l=0,h=0;switch(null==(a=e.contextData)?void 0:a.textAttachment){case 1:l=0,h=0;break;case 2:l-=n/2,h=0;break;case 3:l-=n,h=0;break;case 4:l=0,h+=i/2;break;case 5:l-=n/2,h+=i/2;break;case 6:l-=n,h+=i/2;break;case 7:l=0,h+=i;break;case 8:l-=n/2,h+=i;break;case 9:l-=n,h+=i;break;default:return}if(g.traverse((e=>{e.geometry&&e.geometry.translate(l,h,0)})),null!=(s=e.contextData)&&s.textRotation&&Ys.setFromAxisAngle(Zu,e.contextData.textRotation*Math.PI/180),null!=(o=e.contextData)&&o.textDirection){let t=e.contextData.textDirection,n=new O(t.x,t.y,t.z),i=n.clone().cross(Uc),r=Uc.angleTo(n);Ys.multiply(t0e.setFromAxisAngle(Zu,i.z>0?-r:r))}Qt.shouldRebasePositionOnRTC(Vi)&&this.setRTCUserData(g),g.matrix.compose(Vi,Ys,wy),g.renderOrder=5,d.add(g)}if(0===e.leaderLineType)return null==g||g.traverse((e=>{e.layers.enableAll()})),g;{let n=[],i=null==(l=e.contextData)?void 0:l.leaders[0];if(!i)return d;let r=i.lastLeaderLinePoint;if(e.enableDogLeg){let e=new O(r.x,r.y,r.z),t=i.doglegLength,a=new O(i.doglegVector.x,i.doglegVector.y,i.doglegVector.z).multiplyScalar(t),s=e.clone().add(a);n.push(s,e)}let a=(null==(h=e.contextData)?void 0:h.leaders[0].leaderLines)||[];for(let l=0;lnew O(e.x,e.y,e.z))),s=new O(r.x,r.y,r.z);for(let e=0;e{e.layers.enableAll()})),1===d.children.length?d.children[0]:d}drawLeader(e,t,n){let i=[];if(!e.vertices)return void se.warn("[DxfLoader] Entity is missing vertices:",e.handle);if(e.vertices.length<2)return void se.warn("leader's vertices number must be greater than 2");let r=t.tables.dimStyle.dimStyles[e.dimensionStyle]||this.getDefaultDimensionStyle(t),a=e.vertices;if(1===e.pathType&&(a=new vm(e.vertices).getPoints(50)),e.textWidth){let t=e.textWidth,n=new O(a[a.length-1].x,a[a.length-1].y,a[a.length-1].z);if(0===e.direction){let e=new O(1,0,0).multiplyScalar(t);a.push(e.add(n))}else{let e=new O(-1,0,0).multiplyScalar(t);a.push(e.add(n))}}for(let p=0;p0?(l.add(d),Lc.merge(l,!1),l.traverse((e=>{e.layers.enableAll()})),1===l.children.length?l.children[0]:l):(d.layers.enableAll(),d)}drawDefaultLeadArrow(e,t,n,i){let r=n*(e.x-t.x),a=n*(e.y-t.y),s=a,o=-r,l=new O(t.x+r+s/6,t.y+a+o/6,0),h=new O(t.x+r-s/6,t.y+a-o/6,0);i.push(t,l),i.push(t,h),i.push(l,h)}getBlockByHandle(e,t){if(!this.blocksCache){this.blocksCache={};for(let t in e){let n=e[t];this.blocksCache[n.ownerHandle]||(this.blocksCache[n.ownerHandle]=n)}}return this.blocksCache[t]}static updateMaterialUniforms(e){e instanceof cn&&(e.uniforms.u_cameraZoom&&(e.uniforms.u_cameraZoom=Zn.cameraZoomUniform),e.uniforms.u_viewportScale&&(e.uniforms.u_viewportScale=Zn.viewportScaleUniform))}static transformAngleByOcsMatrix(e,t){let n=rr.set(1*Math.cos(t),1*Math.sin(t),0).applyMatrix4(e);return Math.atan2(n.y,n.x)}static getArcAnglesByOcsMatrix(e,t,n){let i,r=Zt.getArcAngleSpanInRadian(t,n),a=Zn.transformAngleByOcsMatrix(e,t),s=Zn.transformAngleByOcsMatrix(e,n);if(Zt.areNumbersClose(r,Math.PI)){r=1;let n=Zn.transformAngleByOcsMatrix(e,t+r);i=Zt.getArcAngleSpanInRadian(a,n)}else{if(Zt.areNumbersClose(r,2*Math.PI))return[a,a+2*Math.PI];i=Zt.getArcAngleSpanInRadian(a,s)}return Zt.areNumbersClose(r,i,1e-5)?[a,s]:[s,a]}drawArc(e,t,n){var i,r,a;if(!e.radius||e.radius<.001)return void se.warn(`[DxfLoader] The radius of arc (handle '${e.handle}') is undefined, ignored!`);if(!e.radius||e.radius<.001)return void se.warn(`[DxfLoader] The radius of arc (handle '${e.handle}') is too small, ignored!`);let s=new O(0,0,1);void 0!==e.extrusionDirectionX&&void 0!==e.extrusionDirectionY&&void 0!==e.extrusionDirectionZ&&s.set(e.extrusionDirectionX,e.extrusionDirectionY,e.extrusionDirectionZ);let o,l,h=Zn.getOcsMatrix(s);if("CIRCLE"===e.type)o=e.startAngle||0,l=o+2*Math.PI;else{if(null==e.startAngle||null==e.endAngle||(o=e.startAngle,l=e.endAngle,Zt.areNumbersEqual(o,l,1e-6)))return;if(!Zt.areNumbersClose(Zt.getArcAngleSpanInRadian(o,l),2*Math.PI)){let e=Zn.getArcAnglesByOcsMatrix(h,o,l);o=e[0],l=e[1]}}let c=new gm(0,0,e.radius,o,l,0!==this.angBase),u=1,d=n;null!=d&&d.xScale&&null!=d&&d.yScale&&(u=Math.max(Math.abs(d.xScale),Math.abs(d.yScale)));let p=this.getDivision(o,l,e.radius*u),f=c.getPoints(p),m=new O,g=!1;this.enableRTC&&(g=Qt.checkAndRebasePositionsOnRTC(f,m));let v=(new Dt).setFromPoints(f),y=new bn(2);y.geometry=v,y.material=Ea;let x=new O;e.center&&(x.x=e.center.x,x.y=e.center.y);let b=new O(null==(i=e.center)?void 0:i.x,null==(r=e.center)?void 0:r.y,null==(a=e.center)?void 0:a.z).applyMatrix4(h.invert());x.x=b.x,x.y=b.y;let _=x,w=new bn(1);return w.geometry=Jge,w.material=jC,w.userData.handle=e.handle,w.userData.isSnapObject=!0,w.userData.type="CircleCenter",w.layers.set(11),y.add(w),g?(this.setRTCUserData(y),_.x+=m.x,_.y+=m.y):Qt.shouldRebasePositionOnRTC(_)&&this.setRTCUserData(y),y.matrix.setPosition(_),y.layers.enableAll(),y}addTriangleFacingCamera(e,t,n,i){let r=new O,a=new O;r.subVectors(n,t),a.subVectors(i,t),r.cross(a);let s=new O(t.x,t.y,t.z),o=new O(n.x,n.y,n.z),l=new O(i.x,i.y,i.z);r.z<0?e.push(l,o,s):e.push(s,o,l)}drawSolid(e,t,n){let i=e.points;if(!i||i.length<4)return;if(e.extrusionDirection&&e.extrusionDirection.z){rr.set(0,0,e.extrusionDirection.z);let t=Zn.getOcsMatrix(rr).invert();i.forEach((e=>{let n=rr.set(e.x,e.y,0).applyMatrix4(t);e.x=n.x,e.y=n.y}))}let r=[],a=[];this.addTriangleFacingCamera(r,i[0],i[1],i[2]),a.push(0,1,2),this.addTriangleFacingCamera(r,i[1],i[2],i[3]),a.push(3,4,5);let s=new O,o=!1;this.enableRTC&&(o=Qt.checkAndRebasePositionsOnRTC(r,s));let l=(new Dt).setFromPoints(r);l.setIndex(a);let h=new bn(4);return h.geometry=l,h.material=Ty,o&&(this.setRTCUserData(h),h.matrix.setPosition(s.x,s.y,0)),h.layers.enableAll(),h}getTextStyle(e,t){var n,i;let r=null==(i=null==(n=e.tables)?void 0:n.style)?void 0:i.styles;return r&&(r[t.textStyle]||r.STANDARD||r.Standard)||{}}getDefaultDimensionStyle(e){return e.tables.dimStyle.dimStyles.STANDARD||e.tables.dimStyle.dimStyles.Standard||{}}getTextEncoding(e){return(null==e?void 0:e.bigFontFile)&&e.bigFontFile.toUpperCase().startsWith("GB")?"gbk":"utf8"}getTextMesh(e,t,n,i){if(!e)return;let r=(null==n?void 0:n.styleName)||"";if(n&&n.fontFile&&n.fontFile.endsWith(".shx")){let e=`${n.fontFile}_${n.styleName}`;this.statsInfo.unsupportedTextStyles[e]||(this.statsInfo.unsupportedTextStyles[e]=0),this.statsInfo.unsupportedTextStyles[e]++}let a=.67,s={_TCH_DIM:1.45,ROMANS:1};r&&s[r]&&(a=s[r]),i.xScale&&(a*=i.xScale),r&&(a*=(null==n?void 0:n.xScale)||1,t=t||(null==n?void 0:n.textHeight)||0),0===t&&(t=r?1:.2);let o=this.createTextMeshByText(e,n,t,0,t/8);return o.traverse((e=>{e.geometry&&e.geometry.scale(a,1,1)})),o}createTextMeshByText(e,t,n=12,i=0,r=0,a=1,s=1/0){var o,l,h;let c=new bn,u=[],d=0,p=0,f=i+n;for(let m=0;ms?(d=0,p-=f):(c.boundingBox||c.computeBoundingBox(),d+=c.boundingBox.getSize(rr).x+r),u.push(c))}if(u.length>0){let e=u.filter((e=>e instanceof ta)),t=u.filter((e=>!(e instanceof ta)));if(e.length>0){let t=new bn(4);t.geometry=Ni(e),t.material=Ty,c.add(t)}if(t.length>0){let e=new bn(3);e.geometry=Ni(t),e.material=Ea,c.add(e)}}return c}transformTextMesh(e,t){Uf.makeEmpty();let n=bn.getBox(t,Uf).getSize(rr),{halign:i,valign:r}=e;t.matrix.decompose(XC.position,XC.quaternion,XC.scale);let a=XC,s=e.width||e.textWidth||n.x,o=e.height||e.textHeight||n.y;if(void 0===i&&void 0===r&&e.startPoint||[3,5].includes(i)&&e.startPoint?(a.position.x+=e.startPoint.x,a.position.y+=e.startPoint.y,a.position.z+=e.startPoint.z):e.endPoint&&(a.position.x+=e.endPoint.x,a.position.y+=e.endPoint.y,a.position.z+=e.endPoint.z),3!==i&&5!==i){if(e.rotation){let t=e.rotation*Math.PI/180;a.rotateZ(t)}2===e.mirrored?a.rotateY(Math.PI):4===e.mirrored&&a.rotateX(Math.PI)}switch(i){case 0:default:break;case 1:a.translateX(-s/2);break;case 2:a.translateX(-s);break;case 3:if(e.startPoint&&e.endPoint){let t=new O(e.startPoint.x,e.startPoint.y,e.startPoint.z),n=new O(e.endPoint.x,e.endPoint.y,e.endPoint.z),i=(new O).subVectors(t,n),r=i.length()/s;a.scale.multiplyScalar(r);let o=i.clone().cross(Uc),l=i.angleTo(Uc);a.rotateZ(o.z>0?Math.PI-l:l-Math.PI),(2===e.mirrored||4===e.mirrored)&&a.rotateX(Math.PI)}break;case 4:a.translateX(-s/2),a.translateY(-o/2);break;case 5:if(e.startPoint&&e.endPoint){let t=new O(e.startPoint.x,e.startPoint.y,e.startPoint.z),n=new O(e.endPoint.x,e.endPoint.y,e.endPoint.z),i=(new O).subVectors(t,n),r=i.length()/s;a.scale.setX(r);let o=i.clone().cross(Uc),l=i.angleTo(Uc);a.rotateZ(o.z>0?Math.PI-l:l-Math.PI),(2===e.mirrored||4===e.mirrored)&&a.rotateX(Math.PI)}}switch(r){case 0:case 1:default:break;case 2:a.translateY(-o/2);break;case 3:a.translateY(-o)}return a.position.z=0,a.updateMatrix(),t.matrix.copy(a.matrix),t}drawText(e,t,n){let i=e.text;if(!i)return;if(!this.font)return void se.info("[DxfLoader] Font file not set, ignoring text entity.");let r=this.getTextStyle(t,e);i=wC(i,{encoding:this.getTextEncoding(r)}).map((e=>e.text)).join("");let a=this.getTextMesh(i,e.textHeight,r,e);if(!a||0===a.children.length)return;this.transformTextMesh(e,a),rr.set(a.matrix.elements[12],a.matrix.elements[13],a.matrix.elements[14]);let s=Qt.shouldRebasePositionOnRTC(rr);return s&&this.setRTCUserData(a),a.traverse((e=>{let t=e.geometry;if(t){if(e instanceof xt&&!t.getIndex()){let e=t.getAttribute("position"),n=[];for(let t=0;te.text)).join();let a=this.getTextMesh(i,e.textHeight,r,e);if(!a||0===a.children.length)return;this.transformTextMesh(e,a),rr.set(a.matrix.elements[12],a.matrix.elements[13],a.matrix.elements[14]);let s=Qt.shouldRebasePositionOnRTC(rr);return s&&this.setRTCUserData(a),a.traverse((e=>{let t=e.geometry;if(t){if(e instanceof xt&&!t.getIndex()){let e=t.getAttribute("position"),n=[];for(let t=0;te.text)).join();let a=this.getTextMesh(i,e.textHeight,r,e);if(!a||0===a.children.length)return;this.transformTextMesh(e,a),rr.set(a.matrix.elements[12],a.matrix.elements[13],a.matrix.elements[14]);let s=Qt.shouldRebasePositionOnRTC(rr);return s&&this.setRTCUserData(a),a.traverse((e=>{let t=e.geometry;if(t){if(e instanceof xt&&!t.getIndex()){let e=t.getAttribute("position"),n=[];for(let t=0;t0&&(e.colorIndex=i.DIMCLRD,e.color=Wm(e.colorIndex));let r=new bn;for(let s=0;s`,r.userData.entityType=e.type;let a=null==e?void 0:e.insertionPoint;return rr.set(0,0,0),a&&rr.set(a.x,a.y,0),Qt.shouldRebasePositionOnRTC(rr)&&this.setRTCUserData(r),r.matrix.setPosition(rr),r}drawImage(e,t,n){var i;if(!e.imageSize||null==(i=t.objects.IMAGEDEF)||!i.length)return;let r=t.objects.IMAGEDEF.filter((t=>t.handle===e.imageDefHandle))[0];if(!r)return;console.log(e,r);let a=e.imageSize.x,s=e.imageSize.y,o=new bn,l=!1;2===e.flags||4===e.flags||8===e.flags||(l=!0);let h=new ui(a,s);if(l){let e=new Rs(this.manager).load(r.filename,void 0,void 0,(()=>{console.warn("Please upload the pictures in the same folder, or use url link in the dxf file.")}));e.colorSpace=tn;let t=new ln({transparent:!0,side:ci,map:e}),n=new bn(4);n.geometry=h,n.material=t,o.add(n)}let c=new Cu(h),u=this.getColor(e,t,n),d=new bn(2);d.geometry=c,d.material=this.getLineBasicMaterial(u);let p=e.uPixel?new O(e.uPixel.x,e.uPixel.y,e.uPixel.z):new O(r.pixelSize.x,0,0),f=e.vPixel?new O(e.vPixel.x,e.vPixel.y,e.vPixel.z):new O(r.pixelSize.y,0,0);if(o.add(d),Vi.set(p.x,f.y,1),rr.set(0,0,0),e.position){let t=new O(e.position.x,e.position.y,e.position.z);t.add(p.multiplyScalar(a/2)).add(f.multiplyScalar(s/2)),rr.copy(t)}return Qt.shouldRebasePositionOnRTC(rr)&&this.setRTCUserData(o),Ys.identity(),o.matrix.compose(rr,Ys,Vi),o}drawInsert(e,t,n=!1){var i,r;if(!e.block)return;let a=t.blocks[e.block];if(!a.entities)return;e.blockPosition=a.position;let s=new bn;for(let u=0;u`,s.userData.entityType=e.type,null!=(i=e.extendedData)&&i.originalType&&(s.userData.originalType=null==(r=e.extendedData)?void 0:r.originalType),null!=e&&e.blockPosition&&s.matrix.setPosition(-e.blockPosition.x,-e.blockPosition.y,0);let o=rr.set(1,1,1);e.xScale&&(o.x=e.xScale),e.yScale&&(o.y=e.yScale);let l=new Xn;e.rotation&&(l.z=e.rotation*Math.PI/180),Ys.setFromEuler(l,!1);let h=Vi.set(0,0,0);e.position&&(h.x=e.position.x,h.y=e.position.y),Eo.compose(h,Ys,o),e.extrusionDirection&&e.extrusionDirection.z<0&&Eo.premultiply(Qge.identity().makeScale(-1,1,1)),e0e.copy(s.matrix),s.matrix.premultiply(Eo),Vi.set(s.matrix.elements[12],s.matrix.elements[13],s.matrix.elements[14]),Qt.shouldRebasePositionOnRTC(Vi)&&this.setRTCUserData(s);let c=this.findSpatialFilterByHandle(e.handle,t);if(c){this.drawSpatialFilter(c);let t=c;t&&t.clipPolylines&&t.clipPolylines.length>0&&(s.userData.spatialFilterHandle=c.handle,this.cloneMaterialsForSpatialFilter(s),se.debug("[DxfLoader] Spatial filter:",e.associatedSpatialFilter))}return s}drawSpatialFilter(e){let t=e;if(t.threejsObject)return t.threejsObject.clone();let n=e.invertBlockMatrix;Eo.set(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11],0,0,0,1);let i=[];e.vertices.forEach((e=>{i.push(new O(e.x,e.y,0))}));let r={polyline:[],bConcave:!1,bReversed:!1};if(2===e.numberOfPointsOnClipBoundary)r.polyline=i;else{let t=e.numberOfPointsOnClipBoundary,n=3;if(te;r--){let o=i[r];if(Zt.areVector3sEqual(n,o)&&e+10)break;a.push(n)}if(s>0)for(let e=s+1;e{o.push(new be(e.x,e.y)),l.push([e.x,e.y])})),!Qt.isConvex(o)){se.warn(`[DxfLoader] Concave polygon is not supported for spatial filter (handle '${e.handle}'), converting to convex polygon!`);let t=(0,o0e.default)(l,1/0);a=[],t.forEach((e=>{a.push(new O(e[0],e[1],0))}))}Zt.areVector3sEqual(a[0],a[a.length-1])||a.push(a[0]),r.polyline=a,r.bReversed=s>0}return this.enableReleaseData&&(e.vertices=[],e.matrix=[],e.invertBlockMatrix=[]),t.localMatrix=Eo.clone(),t.clipPolylines=[],void t.clipPolylines.push(r)}drawLayout(e,t,n,i,r,a){if(!e.entities)return;let s=new bn;for(let h=0;h{if(e.geometry){let t=e.userData.layerName,i=r[t];i||(i=[],r[t]=i),i.push(e),e.userData.isSnapObject&&(this.layoutsSnapObjectsMap[n.layoutName]||(this.layoutsSnapObjectsMap[n.layoutName]=[]),this.layoutsSnapObjectsMap[n.layoutName].push(e))}})))}if(0===s.children.length)return;s.userData.layerName=e.layer;let o=n.layoutName,l=i.children.find((e=>e.name===o));l||(l=new bn,l.name=o,l.userData.isLayoutLevelObject=!0,i.add(l)),l.add(s),e.position&&s.matrix.setPosition(e.position.x,e.position.y,e.position.z||0)}convertEdgeToPoints(e){let t=[];switch(e.type){case 1:{let n=e;t.push(new be(n.startPoint.x,n.startPoint.y)),t.push(new be(n.endPoint.x,n.endPoint.y));break}case 2:{let n=e,i=n.startAngle*An.DEG2RAD,r=n.endAngle*An.DEG2RAD;n.bCounterclockwise||(i=2*Math.PI-i,r=2*Math.PI-r);let a=new gm(n.center.x,n.center.y,n.radius,i,r,!n.bCounterclockwise),s=this.getDivision(i,r,n.radius);t.push(...a.getPoints(s));break}case 3:{let n=e,i=Math.sqrt(Math.pow(n.majorAxisEndPoint.x,2)+Math.pow(n.majorAxisEndPoint.y,2)),r=i*n.minorRatio,a=Math.atan2(n.majorAxisEndPoint.y,n.majorAxisEndPoint.x),s=n.startAngle*An.DEG2RAD,o=n.endAngle*An.DEG2RAD;n.bCounterclockwise||(s=2*Math.PI-s,o=2*Math.PI-o);let l=new Zh(n.center.x,n.center.y,i,r,s,o,!n.bCounterclockwise,a),h=this.getDivision(s,o,Math.max(i,r));t.push(...l.getPoints(h));break}case 4:{let n=e;t.push(...n.controlPoints);break}case 0:{let n=e;t.push(...O6(n.points,n.isClosed));break}}return t}drawHatch(e,t,n){var i;let r=e;if(0==r.boundaryPaths.length)return;let a=[],s=[],o=[],l=e=>{let t=[],n=[];n.push(...this.convertEdgeToPoints(e[0]));for(let i=1;i2){let a=this.convertEdgeToPoints(e[i-1]);Zt.areVector2sEqual(a[a.length-1],r[0])?Zt.areVector2sEqual(n[0],r[r.length-1],1e-5)&&(t.push(n),n=[]):Zt.areVector2sEqual(a[0],r[r.length-1])?Zt.areVector2sEqual(n[1],r[0],1e-5)&&(t.push(n),n=[]):n=[]}}return t};if(r.boundaryPaths.forEach(((e,t)=>{let n=[];if(this.IsfilteredByPathTypeFlag(e.pathTypeFlag)){let n="[DxfLoader] The %d path type flag is filtered at the %dth boundrayPath (hatch handle '%s')";return void se.info(n,e.pathTypeFlag,t,r.handle)}let i=e.edges;if(0===i.length)return;let h=[];for(let a=0;a31&&(!(e=>{for(let t=1;t{Zt.areVector2sEqual(e[0],e[e.length-1])||e.push(e[0]);let t=e.map((e=>new be(Mt.roundNumber(e.x,7),Mt.roundNumber(e.y,7))));if((null==t?void 0:t.length)>0){a.push(t);let e=(new Ji).setFromPoints(t);s.push(e);let n=e.getSize(o_),i=n.x*n.y;o.push({area:i,index:a.length-1})}}))})),0===a.length)return;let h=new be,c=this.checkAndRebasePolygonsOnRTC(a,h);o.sort(((e,t)=>e.area-t.area));let u=[];o.forEach((e=>{u.push(e.index)}));let d,p=this.buildContainHierarchyTree(a,s,u),f=[];if(this.buildHatchGeometry(a,p,f),f.length>0&&(d=Ni(f)),!d||!d.getIndex()||0===(null==(i=d.getIndex())?void 0:i.count))return void se.warn("[DxfLoader] Failed to convert hatch boundaries!");let m=new bn(4);m.geometry=d,m.material=Ty,this.setHatchMaterial(m,r,t,h,n);let g=m;return c&&(this.setRTCUserData(g),g.matrix.setPosition(h.x,h.y,0)),g.traverse((e=>{e.layers.enableAll(),e.layers.disable(11)})),g}drawOle2frame(e,t){let{leftUpX:n,leftUpY:i,rightDownX:r,rightDownY:a}=e;if(!(n&&i&&r&&a))return;let s=[new be(n,i),new be(n,a),new be(r,a),new be(r,i),new be(n,i)],o=new O,l=!1;this.enableRTC&&(l=Qt.checkAndRebasePositionsOnRTC(s,o));let h=(new Dt).setFromPoints(s),c=this.getLineBasicMaterial(16777215),u=new bn(2);u.geometry=h,u.material=c,u.layers.enableAll(),l&&(this.setRTCUserData(u),u.matrix.setPosition(o.x,o.y,0));let d=new bn;d.add(u);let p,f,m=t.objects.DICTIONARY;for(let g of m){let t=g;for(let n in t.entries)if(t.entries[n]===e.handle){p=n;break}}if(p)if(this.meshTextureMaterials[p])f=this.meshTextureMaterials[p];else for(let g=0;g1?d:u}static getOcsMatrix(e){let t=Uc,n=D6,i=Zu,r=new O(0,1,0),a=new O(0,0,1);return Zt.areVectorsClose(e,a)?Eo.identity():(i=e.clone().normalize(),Zt.areVectorsClose(i,a)||(t=Math.abs(i.x)<1/64&&Math.abs(i.y)<1/64?r.cross(i).normalize():a.cross(i).normalize(),n=i.clone().cross(t).normalize()),Eo.set(t.x,t.y,t.z,0,n.x,n.y,n.z,0,i.x,i.y,i.z,0,0,0,0,1))}static getDcs2WcsMatrix(e,t){let n;n=$gt(e)?e.viewDirectionFromTarget:e.viewDirection;let i,r,a,s=new O(Zt.roundNumber(n.x,7),Zt.roundNumber(n.y,7),n.z),o=new O(e.viewTarget.x,e.viewTarget.y,e.viewTarget.z),l=e.viewTwistAngle||0;a=s.clone().normalize(),i=Zu.clone().cross(s),i.length()>0?(i.normalize(),r=a.clone().cross(i)):a.z<0?(i=Uc.clone().negate(),r=D6,a=Zu.clone().negate()):(i=Uc,r=D6,a=Zu);let h=new Qe,c=Eo.identity();return c.makeBasis(i,r,a),h.premultiply(c),h.premultiply(Eo.identity().compose(o.clone(),(new hr).setFromAxisAngle(new O(0,0,1),An.degToRad(t?l:-l)),new O(1,1,1))),h}getViewportMsToPsMatrix(e){let t=new O(e.centerPoint_dcs.x,e.centerPoint_dcs.y,0),n=new O(e.centerPoint.x,e.centerPoint.y,e.centerPoint.z),i=e.viewHeight/e.height_paperSpace,r=Zn.getDcs2WcsMatrix(e,this.angDir),a=new Qe;a.setPosition(Kge.clone().sub(n));let s=Qge.identity();s.scale(rr.set(i,i,i));let o=e0e.identity().setPosition(Kge.clone().sub(n));s.premultiply(o.clone().invert()).multiply(o),a.multiply(s);let l=Eo.identity();l.setPosition(t),r.multiply(l);let h=Eo.identity();return a.invert().multiply(h).multiply(r.invert())}drawViewport(e,t,n){let i=e;if("1"==i.viewportId)return e.psBBox=new Ot,void(e.msToPsMatrix=new Qe);let r=[],a=i.centerPoint,s=i.width_paperSpace/2,o=i.height_paperSpace/2;r.push(new O(a.x-s,a.y-o,0)),r.push(new O(a.x-s,a.y+o,0)),r.push(new O(a.x+s,a.y+o,0)),r.push(new O(a.x+s,a.y-o,0)),r.push(r[0]),e.psBBox=new Ot(r[0],r[2]),e.msToPsMatrix=this.getViewportMsToPsMatrix(i);let l=new O,h=!1;this.enableRTC&&(h=Qt.checkAndRebasePositionsOnRTC(r,l));let c=(new Dt).setFromPoints(r),u=new bn(2);u.geometry=c,u.material=Ea,h&&(this.setRTCUserData(u),u.matrix.setPosition(l.x,l.y,0)),u.userData.entityType=e.type,u.layers.enableAll();let d=new bn;d.add(u);let p=e.psBBox.clone();p.applyMatrix4(e.msToPsMatrix.clone().invert()),p.min.z=0,p.max.z=0;let f=[];f.push(p.min),f.push(new O(p.min.x,p.max.y,0)),f.push(p.max),f.push(new O(p.max.x,p.min.y,0)),f.push(f[0]);let m=new O,g=!1;this.enableRTC&&(g=Qt.checkAndRebasePositionsOnRTC(f,m));let v=(new Dt).setFromPoints(f),y=new bn(2);return y.geometry=v,y.material=Ea,g&&(this.setRTCUserData(y),y.matrix.setPosition(m.x,m.y,0)),y.userData.entityType=e.type,y.userData.inPaperSpace=!0,y.layers.enableAll(),d.add(y),u}getColor(e,t,n){var i,r,a,s;if(this.compareContext)return us.ENTITY_COLOR_NO_CHANGE;if(null!=this.overrideColor)return this.overrideColor;let o=e;if(o&&o.isGradientColor){let t=o.gradientColors;if(t&&t.length>=2){if(t[0]!==t[1]){let t=`[DxfLoader] Gradient colors are not supported for hatch '${e.handle}', will use the first color!`;se.warn(t)}return t[0]}}if(e.isTrueColor||e.colorIndex>0&&e.colorIndex<256)return e.color;if(0===e.colorIndex)return n?this.getColor(n,t):null==(r=null==(i=t.tables)?void 0:i.layer)?void 0:r.layers[0].color;if(256===e.colorIndex){let i=null==(s=null==(a=t.tables)?void 0:a.layer)?void 0:s.layers,r=i&&i[e.layer],o=i&&n&&i[n.layer],l=Hf;return r&&"0"!==r.name?l=r.color:o?l=o.color:r?l=r.color:i&&i[0].color&&(l=i[0].color),l}return se.warn("[DxfLoader] Unknown colorIndex"),Hf}getLineType(e,t,n){var i,r;if(n&&"DIMENSION"===n.type)return this.getLineType(n,t);if(e.lineType!==iy&&e.lineType!==sy)return e.lineType;if(e.lineType===sy)return n?this.getLineType(n,t):e.lineType;let a=null==(r=null==(i=t.tables)?void 0:i.layer)?void 0:r.layers,s=Ygt;if("0"!==e.layer){let t=a&&a[e.layer];if(t)return t.lineType}else if(n){let e=a&&a[n.layer];if(e)return e.lineType}return s}getLayerName(e,t,n){var i,r;let a=t=>{s&&t&&!s[e.layer]&&(console.warn(`[DxfLoader] Failed to find layer object for '${t}', adding a default one.`),s[t]={name:t,handle:"",colorIndex:256,lineType:"",visible:!0})},s=null==(r=null==(i=t.tables)?void 0:i.layer)?void 0:r.layers;a(e.layer);let o=s&&s[e.layer];a(null==n?void 0:n.layer);let l=s&&n&&s[n.layer],h=(null==o?void 0:o.name)||"";return o&&"0"===o.name&&l&&(h=l.name),h}setMaterial(e,t,n,i){var r,a;let s=e;if(!s.geometry||(this.setRenderOrderByObjectType(e),"OLE2FRAME"===t.type))return;if("MTEXT"===t.type)return void(e.renderOrder=5);if("HATCH"===t.type)return o_.set(0,0),void this.setHatchMaterial(e,t,n,o_,i);if("IMAGE"===t.type)return;let o,l=this.getColor(t,n,i);if("LWPOLYLINE"===t.type&&(s.isMesh?(o=this.getMeshBasicMaterial(l),e.renderOrder=1):e.userData.isOutline&&(o=this.getLineBasicMaterial(l),e.renderOrder=3),o))s.material=o;else{if("SOLID"===t.type)o=this.getMeshBasicMaterial(l);else if("TEXT"===t.type||"ATTDEF"===t.type||"ATTRIB"===t.type)o=this.getLineBasicMaterial(l),e.renderOrder=5;else if("LEADER"===t.type||"MULTILEADER"===t.type||"VIEWPORT"===t.type)o=this.getLineBasicMaterial(l);else if("POINT"===t.type)o=this.getPointsMaterial(l);else{if(e.material instanceof xi)return o=this.getPointsMaterial(l),void(s.material=o);let h=null==(a=null==(r=n.tables)?void 0:r.lineType)?void 0:a.lineTypes,c=h&&h[this.getLineType(t,n,i)];if(c&&c.pattern&&0!==c.pattern.length){let n=t.lineTypeScale||1;o=this.getLineShaderMaterial(c,l,n),e.renderOrder=3}else o=this.getLineBasicMaterial(l)}s.material=o}}setHatchMaterial(e,t,n,i,r){let a=e;if(!a.geometry)return;let s=this.getColor(t,n,r);if(2===a.type||3===a.type)return void(a.material=this.getLineBasicMaterial(s));let o,l=-1;if(t.solidFill)o=this.getMeshBasicMaterial(s);else{if(a.material instanceof cn){o=a.material;let e=new ct(s);a.material.uniforms.u_color.value.equals(e)||(o=a.material.clone(),Zn.updateMaterialUniforms(o),o.uniforms.u_color.value.set(s))}else o=this.getHatchShaderMaterial(t,s,i);l=0}o||(o=this.getMeshBasicMaterial(s),l=-1),a.material=o,a.renderOrder=l}setRenderOrderByObjectType(e){let t=e,n=0;t.isMesh?n=-1:t.isLine?n=2:t.isPoints&&(n=4),e.renderOrder=n}getPointsMaterial(e){return this.pointsMaterials[e]||(this.pointsMaterials[e]=new xi({size:.2,color:e})),this.pointsMaterials[e]}getLineBasicMaterial(e){return this.lineBasicMaterials[e]||(this.lineBasicMaterials[e]=new Gn({color:e})),this.lineBasicMaterials[e]}getLineShaderMaterial(e,t,n){let i=`${e.name}_${t}_${n}`;if(!this.lineShaderMaterials[i]){let r=this.getLineTypeScales(),a=r.ltScale*r.celtScale*n;this.lineShaderMaterials[i]=_C.createLineShaderMaterial(e.pattern,t,a,Zn.viewportScaleUniform,Zn.cameraZoomUniform)}return this.lineShaderMaterials[i]}getMeshBasicMaterial(e){return this.meshBasicMaterials[e]||(this.meshBasicMaterials[e]=new ln({color:e})),this.meshBasicMaterials[e]}getHatchShaderMaterial(e,t,n){if(!e.patternLines||e.patternLines.length<1)return;let i=this.findMatchedHatchShaderMaterial(e,t);if(i)return i;let r=2;e.patternLines.forEach((e=>{r=Math.max(e.dashPattern.length,r)}));let a=0,s=[],o=new be;for(let h of e.patternLines){let t=new be(h.origin.x,h.origin.y).sub(n).rotateAround(o,-An.degToRad(e.patternAngle)),i=new be(h.delta.x,h.delta.y).rotateAround(o,-An.degToRad(h.angle));if(0===i.y)return void se.warn("[DxfLoader] delta.y is equal to zero !");let l=h.dashPattern.length,c=!0,u=0;for(let e=0;e0&&(c=!1),u+=Math.abs(t)}let d=c?.05:.005,p=[],f=[],m=0;f[0]=m;for(let e=0;eZn.maxFragmentUniforms){se.warn("[DxfLoader] There will be warning in fragment shader when number of uniforms exceeds 1024, so extra hatch line patterns are ignored here!");break}s.push(g)}let l=lme(s,e.patternAngle,Zn.cameraZoomUniform,new ct(t));return l.defines={MAX_PATTERN_SEGMENT_COUNT:r},this.hatchShaderMaterials.push({patternLines:e.patternLines,patternAngle:e.patternAngle,color:t,material:l}),l}getDivision(e,t,n){let i=Math.round(5e4/this.entityCount);i=Math.max(i,2),i=Math.min(i,10);let r=5*i,a=2*i;this.averageCurveSize&&(a*=Math.pow(n/this.averageCurveSize,.5),a=Math.max(a,i),a=Math.min(a,r));let s=t-e;s<0&&(s+=2*Math.PI),a=Math.ceil(a*(s/Math.PI));let o=8;return s<.087?o=2:s<.174?o=3:s<.52?o=4:s<1.57?o=5:s<3.14?o=6:s<4.71&&(o=7),a=Math.max(a,o),this.averageCurveSize=(this.averageCurveSize*this.curveCount+n)/(this.curveCount+1),this.curveCount++,Math.max(a,12)}getBSplineInterpolationsPerSplineSegment(e,t){let n=1;this.averageCurveSize&&(n=Math.pow(t/this.averageCurveSize,.5),n=Math.max(n,.5),n=Math.min(n,2)),this.averageCurveSize=(this.averageCurveSize*this.curveCount+t)/(this.curveCount+1),this.curveCount++;let i=2*e*n;return e>20&&(i/=Math.log10(e)),i}setDxfDataToIndexedDb(e,t){return ft(this,null,(function*(){let n={dxfDataId:e,dxf:t};return new Promise(((t,i)=>{gy.instance().add(n,(()=>{se.info(`[DxfLoader] Saved '${e}' to indexedDb`),t()}),(e=>{i(e)}))}))}))}getDxfDataFromIndexedDb(e){return ft(this,null,(function*(){return new Promise(((t,n)=>{gy.instance().query(e,(e=>{e&&e.length>0&&t(e[0].dxf),t(void 0)}),(()=>n()))}))}))}buildContainHierarchyTree(e,t,n){var i;let r=new Map,a=n.length;for(let o=0;o{0===e.children.length?i.push(e.index):r.set(e.index,e.children.map((e=>e.index)))}));let a=e=>{try{let t=new Al(e);t.hasAttribute("uv")&&t.deleteAttribute("uv"),t.hasAttribute("normal")&&t.deleteAttribute("normal"),n.push(t)}catch(t){se.warn(`[DxfLoader] triangulate shape error: ${e.getPoints().map((e=>e.toArray())).toString()}`)}};i.forEach((t=>{let n=e[t];if(0===n.length)return;let i=new Ss(n);a(i)}));let s=e=>e.map((e=>e.toArray()));for(let o of r){let t=new Ss(e[o[0]]),n={regions:[],inverted:!1},i=this.findIntersectHole(e,o[1]);i.forEach((i=>{let r={regions:[],inverted:!1};try{i.forEach(((i,a)=>{if(Vl.epsilon(Zt.getVector2RelativeEps(e[i][0]),1e-6),0===a)r=Vl.segments({regions:[s(e[i])],inverted:!1});else{let a=Vl.segments({regions:[s(e[i])],inverted:!1}),o=Vl.combine(r,a);n=Vl.polygon(Vl.selectUnion(o)),n.regions.length>0?n.regions.forEach((e=>{if(0===e.length)return;let n=e.map((e=>new be(e[0],e[1])));t.holes.push(new Ru(n))})):se.warn("[DxfLoader] mergedHoles.regions is empty")}}))}catch(e){se.warn(`[DxfLoader] polybooljs has error: ${e}, epsilon is ${Vl.epsilon()}`)}}));let r=i.flat(2);for(let a=0;a{t.children.forEach((t=>{this.buildHatchGeometry(e,t,n)}))}))}findIntersectHole(e,t){let n=t.length,i=[];for(let r=0;r{e.forEach((e=>{t.add(e),n++}))})),t.divideScalar(n);let i=!1;if(this.enableRTC&&Qt.shouldRebasePositionOnRTC(t)){i=!0;for(let n=0;n{e.entries[n]&&"ACAD_SORTENTS"===e.entries[n]&&t.add(n)}))}if(0===t.size)return;let i=e.objects.SORTENTSTABLE;if(i)for(let r=0;rMath.abs(e-t)<1e-5,r=(e,t)=>i(e.angle,t.angle)&&i(e.delta.x,t.delta.x)&&i(e.delta.y,t.delta.y)&&i(e.origin.x,t.origin.x)&&i(e.origin.y,t.origin.y)&&((e,t)=>{if(e.length!==t.length)return!1;for(let n=0;ni.color===t&&i.patternAngle===e.patternAngle&&((e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n{t[e.handle]=e.layoutHandle}))}let r=this.blockRecordsCache[t.ownerHandle];if(r){let t=e.objects.LAYOUT.find((e=>e.handle===r));if(t)return t}if(!this.entitiesCache){this.entitiesCache={};let t=this.entitiesCache;Object.values(e.entities).forEach((e=>{t[e.handle]=e}))}let a=this.entitiesCache[t.ownerHandle];return a?this.getLayout(e,a):(se.warn("[DxfLoader] Failed to find layout name for entity:",t),e.objects.LAYOUT.find((e=>e.layoutName===Zn.MODEL_LAYOUT_NAME)))}getLayerVisible(e,t){var n,i,r;let a=null==(i=null==(n=e.tables)?void 0:n.layer)?void 0:i.layers;return a&&(null==(r=a[t])?void 0:r.visible)}getLayerFrozen(e,t){var n,i,r;let a=null==(i=null==(n=e.tables)?void 0:n.layer)?void 0:i.layers;return a&&(null==(r=a[t.layer])?void 0:r.frozen)}cloneMaterialsForSpatialFilter(e){let t=new Map;e.traverse((e=>{e.material&&(e.material=(e=>{let n;return Array.isArray(e)?(n=[],e.forEach((e=>{if(t.has(e.id))n.push(t.get(e.id));else{let i=e.clone();Zn.updateMaterialUniforms(i),t.set(e.id,i),n.push(i)}}))):e&&(t.has(e.id)?n=t.get(e.id):(n=e.clone(),Zn.updateMaterialUniforms(n),t.set(e.id,n))),n})(e.material))}))}getLineTypeScales(){let e={ltScale:1,celtScale:1};return this.header&&(e.ltScale=this.header.$LTSCALE||1,e.celtScale=this.header.$CELTSCALE||1),e}static getDxfUnits(e){switch(e||0){case 0:return"Unitless";case 1:return"Inches";case 2:return"Feet";case 4:return"Millimeters";case 5:return"Centimeters";case 6:return"Meters";default:se.warn(`[DxfLoader] Unsupported $INSUNITS '${e}'`)}return"Unitless"}static computeLineDistance(e){let t=!0===e.isLineSegments,n=e.geometry,i=e.matrixWorld;if(n.index&&(se.debug(`[DxfLoader] Line with id '${e.id}' contains index buffer, going to convert it to non-indexed.`),n=Qt.convertGeometryWithIndexedToNonIndexed(n),e.userData.batches&&e.userData.batches.length>0)){se.debug("[DxfLoader] This line has been merged!");let t=0;e.userData.batches.forEach((e=>{e.positionStart=t,e.positionCount=e.indexCount,e.indexStart=0,e.indexCount=0,t+=e.positionCount}))}if(null===n.index){let r=n.attributes.position;if(!r||0===r.count)return;let a=[];if(t)for(let e=0,t=r.count;e{let t=e;t.isLine&&t.material instanceof cn&&Zn.computeLineDistance(t)})),se.debug(`[DxfLoader] Computed line distances in ${(Date.now()-t)/1e3}s`)}static mergeDxfObjects(e){let t=Date.now(),n={},i={},r=0,a=0,s=()=>{let e=Date.now();for(let t in n){let e=n[t];Zn.removeEmptyObjectsFromRemovingMarkedObjects2(e.children,e.object),e.children=[]}r=0,a+=Date.now()-e};for(let l in e.layersAndObjects){let t=e.layersAndObjects[l];if(t.length<=1)continue;let o=Date.now(),h={},c=[];for(let e of t){if(e.userData.isSnapObject){c.push(e);continue}let t,n=e;for(;n;){if(n.userData.isLayoutLevelObject){t=n;break}n=n.parent}if(!t)continue;let i=t.name;h[i]||(h[i]={object:t,children:[]}),h[i].children.push(e)}for(let e in h){let t=h[e],o=Lc.deepMerge(t.children,t.object,!1,!1,!0),l=o.added,u=o.removed;n[e]||(n[e]={object:t.object,children:[]}),i[e]||(i[e]={object:t.object,children:[]});let d=u.length>15e3;if(d){let e=Date.now();Zn.removeEmptyObjectsFromRemovingMarkedObjects2(u,t.object),a+=Date.now()-e}else r+=u.length;if(u.length===t.children.length)d||u.forEach((t=>{n[e].children.push(t)}));else{let i=u;u.length>=100&&(i=new Set(u));let r=e=>Array.isArray(i)?i.indexOf(e)>=0:i.has(e);for(let a=0;a15e3&&s()}e.layersAndObjects[l]=c,se.debug(`[DxfLoader] Merged layer '${l}' in ${(Date.now()-o)/1e3}s`)}r>0&&s();for(let l in i){let t=i[l];e.root.children.find((e=>e.name===l))||e.root.add(t.object),t.children.forEach((e=>{t.object.add(e)})),t.children=[]}se.debug(`[DxfLoader] MergeUtils.deepMerge costed ${Ar.mergeInfo.elapsedTime/1e3}s`),se.debug(`[DxfLoader] The remove operation of deep merge costed ${a/1e3}s`),se.debug(`[DxfLoader] Deep merge totally costed ${(Date.now()-t)/1e3}s`);let o=Ar.mergeInfo;se.debug(`[DxfLoader] Totally merged ${o.removedObjects} objects to ${o.mergedMeshes} meshes, ${o.mergedLines} lines, ${o.mergedPoints} points, ${o.mergedUnknownTypeObjects?o.mergedUnknownTypeObjects+" unknown type,":""} `)}static merge(e,t){return ft(this,null,(function*(){let n=Mt.getUpdateProgressFuncAsync(t),i={};e.objects.LAYOUT.forEach((e=>{var t;let n=e;i[n.layoutName]=n,null==(t=n.directAssociatedLeafObjectSet)||t.clear()}));let r=Date.now(),a={},s={},o=0,l=0,h=()=>{let e=Date.now();for(let t in a){let e=a[t];Zn.removeEmptyObjectsFromRemovingMarkedObjects(e.children,e.object),e.children=[]}o=0,l+=Date.now()-e},c=Object.keys(e.layersAndThreejsObjects).length,u=0;for(let t in e.layersAndThreejsObjects){let r=e.layersAndThreejsObjects[t];if(r.length<=1){yield n(++u/c*100);continue}let d=Date.now(),p={},f=[];for(let e of r){if(e.userData.isSnapObject){f.push(e);continue}let t,n=e;for(;n;){if(n.userData.isLayoutLevelObject){t=n;break}n=n.parent}if(!t)continue;let i=t.name;p[i]||(p[i]={object:t,children:[]}),p[i].children.push(e)}let m=Object.keys(p).length,g=0;for(let e in p){let t;if(e!==Zn.MODEL_LAYOUT_NAME){let n=i[e];n.directAssociatedLeafObjectSet||(n.directAssociatedLeafObjectSet=new Set),t=n.directAssociatedLeafObjectSet}let r=p[e],d=Ar.deepMerge(r.children,r.object,!1,!1,!0),v=d.added,y=d.removed;a[e]||(a[e]={object:r.object,children:[]}),s[e]||(s[e]={object:r.object,children:[]});let x=y.length>15e3;if(x){let e=Date.now();Zn.removeEmptyObjectsFromRemovingMarkedObjects(y,r.object),l+=Date.now()-e}else o+=y.length;if(y.length===r.children.length)x||y.forEach((t=>{a[e].children.push(t)}));else{let n=y;y.length>=100&&(n=new Set(y));let i=e=>Array.isArray(n)?n.indexOf(e)>=0:n.has(e);for(let s=0;s15e3&&h(),yield n((u+ ++g/m)/c*100)}yield n(++u/c*100),e.layersAndThreejsObjects[t]=f,se.debug(`[DxfLoader] Merged layer '${t}' in ${(Date.now()-d)/1e3}s`)}o>0&&h();for(let t in s){let n=s[t],r=e.threejsObject.children.find((e=>e.name===t));if(r){let e=r.children.find((e=>e.name===Zn.SNAP_GROUP_NAME));if(e&&t!==Zn.MODEL_LAYOUT_NAME){let n=i[t];n.directAssociatedLeafObjectSet||(n.directAssociatedLeafObjectSet=new Set),e.children.forEach((e=>{var t;return null==(t=n.directAssociatedLeafObjectSet)?void 0:t.add(e)}))}}r||e.threejsObject.add(n.object),n.children.forEach((e=>{e.visible||(e.userData.layerVisible=!1),n.object.add(e),e.updateWorldMatrix(!1,!1)})),n.children=[]}se.debug(`[DxfLoader] MergeUtils.deepMerge costed ${Ar.mergeInfo.elapsedTime/1e3}s`),se.debug(`[DxfLoader] The remove operation of deep merge costed ${l/1e3}s`),se.debug(`[DxfLoader] Deep merge totally costed ${(Date.now()-r)/1e3}s`);let d=Ar.mergeInfo;se.debug(`[DxfLoader] Totally merged ${d.removedObjects} objects to ${d.mergedMeshes} meshes, ${d.mergedLines} lines, ${d.mergedPoints} points, ${d.mergedUnknownTypeObjects?d.mergedUnknownTypeObjects+" unknown type,":""} `),n(100)}))}printStatsInfo(){for(let n in this.entityTypesAndTimes)this.entityTypesAndTimes[n].averageTime=this.entityTypesAndTimes[n].totalTime/this.entityTypesAndTimes[n].createCount;se.debug("[DxfLoader] Entity types and cost times in ms:",this.entityTypesAndTimes),se.debug("[DxfLoader] Entity types and mesh count:",this.statsInfo.entityTypesAndMeshCount);let e=0;if(Object.values(this.statsInfo.entityTypesAndMeshCount).forEach((t=>{e+=t})),this.enableRTC&&se.debug(`[DxfLoader] Totally rebased ${this.statsInfo.rebasedEntityCount}(out of ${e}) entities`),this.enableMerge){let e=Ar.mergeInfo;se.debug(`[DxfLoader] Inner merged ${e.removedObjects} objects to ${e.mergedMeshes} meshes, ${e.mergedLines} lines, ${e.mergedPoints} points, ${e.mergedUnknownTypeObjects?e.mergedUnknownTypeObjects+" unknown type,":""} in ${e.elapsedTime/1e3}s`)}let t=(e,t,...n)=>{Object.keys(t).length};t(0,this.statsInfo.unsupportedEntityTypes),t(0,this.statsInfo.unsupportedTextStyles),t(0,this.statsInfo.unsupportedHatchPatterns),this.statsInfo.unsupportedPolylineCount&&se.warn(`[DxfLoader] Unsupported polyline (with both width and linetype) count: ${this.statsInfo.unsupportedPolylineCount}, linetype will be ignored.`),t(0,this.statsInfo.invisibleEntities),t(0,this.statsInfo.ignoredFrozenLayersAndEntityCount),t(0,this.statsInfo.ignoredInserts),this.ignorePaperSpace&&t(0,this.statsInfo.ignoredPaperSpaceEntityTypesAndCount),this.font&&t(0,this.font.getUnsupportedChar())}static statLayoutAndLayerObjects(e){let t=new WeakSet,n=0;for(let a in e.layersAndThreejsObjects)e.layersAndThreejsObjects[a].forEach((e=>{e.geometry&&(n++,t.has(e)?console.warn(e):t.add(e))}));let i=new WeakSet,r=0;if(e.threejsObject.traverse((e=>{e.geometry&&(r++,i.has(e)?console.warn(e):i.add(e))})),n!=r)for(let a in e.layersAndThreejsObjects)e.layersAndThreejsObjects[a].forEach((e=>{e.geometry&&(i.has(e)||console.warn(e))}));se.info(`[DxfLoader] The count of layer objects is ${n},The count of layout objects is ${r} `)}static removeEmptyObjectsFromRemovingMarkedObjects(e,t){if(0===e.length)return;let n=e=>{let i=[];for(let n of e){n.userData.validCount=0;let e=n.parent;e&&e!==t&&(void 0===e.userData.validCount&&(e.userData.validCount=e.children.length),0==--e.userData.validCount&&i.push(e))}i.length>0&&n(i)};n(e),this.removeEmptyObjectsFromMark(t)}static removeEmptyObjectsFromMark(e){if(0===e.userData.validCount||zn.isEmptyObject(e))return e.removeFromParent(),!0;for(let t=0;t{let i=[];for(let n of e){n.userData.validCount=0;let e=n.parent;e&&e!==t&&(void 0===e.userData.validCount&&(e.userData.validCount=e.children.length),0==--e.userData.validCount&&i.push(e))}i.length>0&&n(i)};n(e),this.removeEmptyObjectsFromMark2(t)}static removeEmptyObjectsFromMark2(e){if(0===e.userData.validCount||0===e.type&&0===e.children.length)return e.removeFromParent(),!0;for(let t=0;tt.visible=e)),this.viewer.enableRender()}};function _a(e){return(_a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function zl(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function k6(e,t){if("object"!==_a(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==_a(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function l_(e){var t=k6(e,"string");return"symbol"===_a(t)?t:String(t)}function c0e(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,i=new Array(t);n1&&void 0!==arguments[1]?arguments[1]:{};zl(this,e),this.init(t,n)}return Gl(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||t0t,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n1?t-1:0),i=1;i-1?e.replace(/###/g,"."):e}function r(){return!e||"string"==typeof e}for(var a="string"!=typeof t?[].concat(t):t.split(".");a.length>1;){if(r())return{};var s=i(a.shift());!e[s]&&n&&(e[s]=new n),e=Object.prototype.hasOwnProperty.call(e,s)?e[s]:{}}return r()?{}:{obj:e,k:i(a.shift())}}function f0e(e,t,n){var i=z6(e,t,Object);i.obj[i.k]=n}function i0t(e,t,n,i){var r=z6(e,t,Object),a=r.obj,s=r.k;a[s]=a[s]||[],i&&(a[s]=a[s].concat(n)),i||a[s].push(n)}function KC(e,t){var n=z6(e,t),i=n.obj,r=n.k;if(i)return i[r]}function p0e(e,t,n){var i=KC(e,n);return void 0!==i?i:KC(t,n)}function M0e(e,t,n){for(var i in t)"__proto__"!==i&&"constructor"!==i&&(i in e?"string"==typeof e[i]||e[i]instanceof String||"string"==typeof t[i]||t[i]instanceof String?n&&(e[i]=t[i]):M0e(e[i],t[i],n):e[i]=t[i]);return e}function My(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var s0t={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function a0t(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(function(e){return s0t[e]})):e}var QC="undefined"!=typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,o0t=[" ",",","?","!",";"];function l0t(e,t,n){t=t||"",n=n||"";var i=o0t.filter((function(e){return t.indexOf(e)<0&&n.indexOf(e)<0}));if(0===i.length)return!0;var r=new RegExp("(".concat(i.map((function(e){return"?"===e?"\\?":e})).join("|"),")")),a=!r.test(e);if(!a){var s=e.indexOf(n);s>0&&!r.test(e.substring(0,s))&&(a=!0)}return a}function m0e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function $C(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:".";if(e){if(e[t])return e[t];for(var i=t.split(n),r=e,a=0;aa+s;)s++,l=r[o=i.slice(a,a+s).join(n)];if(void 0===l)return;if(null===l)return null;if(t.endsWith(o)){if("string"==typeof l)return l;if(o&&"string"==typeof l[o])return l[o]}var h=i.slice(a+s).join(n);return h?R0e(l,h,n):void 0}r=r[i[a]]}return r}}var h0t=function(e){Sy(n,zf);var t=c0t(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return zl(this,n),i=t.call(this),QC&&zf.call(Hc(i)),i.data=e||{},i.options=r,void 0===i.options.keySeparator&&(i.options.keySeparator="."),void 0===i.options.ignoreJSONStructure&&(i.options.ignoreJSONStructure=!0),i}return Gl(n,[{key:"addNamespaces",value:function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,a=void 0!==i.ignoreJSONStructure?i.ignoreJSONStructure:this.options.ignoreJSONStructure,s=[e,t];n&&"string"!=typeof n&&(s=s.concat(n)),n&&"string"==typeof n&&(s=s.concat(r?n.split(r):n)),e.indexOf(".")>-1&&(s=e.split("."));var o=KC(this.data,s);return o||!a||"string"!=typeof n?o:R0e(this.data&&this.data[e]&&this.data[e][t],n,r)}},{key:"addResource",value:function(e,t,n,i){var r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},a=this.options.keySeparator;void 0===a&&(a=".");var s=[e,t];n&&(s=s.concat(a?n.split(a):n)),e.indexOf(".")>-1&&(i=t,t=(s=e.split("."))[1]),this.addNamespaces(t),f0e(this.data,s,i),r.silent||this.emit("added",e,t,n,i)}},{key:"addResources",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var r in n)("string"==typeof n[r]||"[object Array]"===Object.prototype.toString.apply(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});i.silent||this.emit("added",e,t,n)}},{key:"addResourceBundle",value:function(e,t,n,i,r){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},s=[e,t];e.indexOf(".")>-1&&(i=n,n=t,t=(s=e.split("."))[1]),this.addNamespaces(t);var o=KC(this.data,s)||{};i?M0e(o,n,r):o=$C($C({},o),n),f0e(this.data,s,o),a.silent||this.emit("added",e,t,n)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?$C($C({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find((function(e){return t[e]&&Object.keys(t[e]).length>0}))}},{key:"toJSON",value:function(){return this.data}}]),n}(),A0e={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,n,i,r){var a=this;return e.forEach((function(e){a.processors[e]&&(t=a.processors[e].process(t,n,i,r))})),t}};function g0e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function ja(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{};return zl(this,n),i=t.call(this),QC&&zf.call(Hc(i)),r0t(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,Hc(i)),i.options=r,void 0===i.options.keySeparator&&(i.options.keySeparator="."),i.logger=Qu.create("translator"),i}return Gl(n,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var n=this.resolve(e,t);return n&&void 0!==n.res}},{key:"extractFromKey",value:function(e,t){var n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");var i=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,r=t.ns||this.options.defaultNS||[],a=n&&e.indexOf(n)>-1,s=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||l0t(e,n,i));if(a&&!s){var o=e.match(this.interpolator.nestingRegexp);if(o&&o.length>0)return{key:e,namespaces:r};var l=e.split(n);(n!==i||n===i&&this.options.ns.indexOf(l[0])>-1)&&(r=l.shift()),e=l.join(i)}return"string"==typeof r&&(r=[r]),{key:e,namespaces:r}}},{key:"translate",value:function(e,t,i){var r=this;if("object"!==_a(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var a=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,s=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,o=this.extractFromKey(e[e.length-1],t),l=o.key,h=o.namespaces,c=h[h.length-1],u=t.lng||this.language,d=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&"cimode"===u.toLowerCase()){if(d){var p=t.nsSeparator||this.options.nsSeparator;return a?(f.res="".concat(c).concat(p).concat(l),f):"".concat(c).concat(p).concat(l)}return a?(f.res=l,f):l}var f=this.resolve(e,t),m=f&&f.res,g=f&&f.usedKey||l,v=f&&f.exactUsedKey||l,y=Object.prototype.toString.apply(m),x=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject;if(b&&m&&"string"!=typeof m&&"boolean"!=typeof m&&"number"!=typeof m&&["[object Number]","[object Function]","[object RegExp]"].indexOf(y)<0&&("string"!=typeof x||"[object Array]"!==y)){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var _=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,m,ja(ja({},t),{},{ns:h})):"key '".concat(l," (").concat(this.language,")' returned an object instead of string.");return a?(f.res=_,f):_}if(s){var w="[object Array]"===y,S=w?[]:{},M=w?v:g;for(var E in m)if(Object.prototype.hasOwnProperty.call(m,E)){var T="".concat(M).concat(s).concat(E);S[E]=this.translate(T,ja(ja({},t),{joinArrays:!1,ns:h})),S[E]===T&&(S[E]=m[E])}m=S}}else if(b&&"string"==typeof x&&"[object Array]"===y)(m=m.join(x))&&(m=this.extendTranslation(m,e,t,i));else{var A=!1,C=!1,P=void 0!==t.count&&"string"!=typeof t.count,R=n.hasDefaultValue(t),O=P?this.pluralResolver.getSuffix(u,t.count,t):"",L=t["defaultValue".concat(O)]||t.defaultValue;!this.isValidLookup(m)&&R&&(A=!0,m=L),this.isValidLookup(m)||(C=!0,m=l);var I=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&C?void 0:m,D=R&&L!==m&&this.options.updateMissing;if(C||A||D){if(this.logger.log(D?"updateKey":"missingKey",u,c,l,D?L:m),s){var k=this.resolve(l,ja(ja({},t),{},{keySeparator:!1}));k&&k.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var N=[],F=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&F&&F[0])for(var U=0;U1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach((function(e){if(!s.isValidLookup(t)){var l=s.extractFromKey(e,o),h=l.key;n=h;var c=l.namespaces;s.options.fallbackNS&&(c=c.concat(s.options.fallbackNS));var u=void 0!==o.count&&"string"!=typeof o.count,d=u&&!o.ordinal&&0===o.count&&s.pluralResolver.shouldUseIntlApi(),p=void 0!==o.context&&("string"==typeof o.context||"number"==typeof o.context)&&""!==o.context,f=o.lngs?o.lngs:s.languageUtils.toResolveHierarchy(o.lng||s.language,o.fallbackLng);c.forEach((function(e){s.isValidLookup(t)||(a=e,!v0e["".concat(f[0],"-").concat(e)]&&s.utils&&s.utils.hasLoadedNamespace&&!s.utils.hasLoadedNamespace(a)&&(v0e["".concat(f[0],"-").concat(e)]=!0,s.logger.warn('key "'.concat(n,'" for languages "').concat(f.join(", "),'" won\'t get resolved as namespace "').concat(a,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),f.forEach((function(n){if(!s.isValidLookup(t)){r=n;var a,l=[h];if(s.i18nFormat&&s.i18nFormat.addLookupKeys)s.i18nFormat.addLookupKeys(l,h,n,e,o);else{var c;u&&(c=s.pluralResolver.getSuffix(n,o.count,o));var f="".concat(s.options.pluralSeparator,"zero");if(u&&(l.push(h+c),d&&l.push(h+f)),p){var m="".concat(h).concat(s.options.contextSeparator).concat(o.context);l.push(m),u&&(l.push(m+c),d&&l.push(m+f))}}for(;a=l.pop();)s.isValidLookup(t)||(i=a,t=s.getResource(n,e,a,o))}})))}))}})),{res:t,usedKey:n,exactUsedKey:i,usedLng:r,usedNS:a}}},{key:"isValidLookup",value:function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,n,i):this.resourceStore.getResource(e,t,n,i)}}],[{key:"hasDefaultValue",value:function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&"defaultValue"===t.substring(0,12)&&void 0!==e[t])return!0;return!1}}]),n}();function V6(e){return e.charAt(0).toUpperCase()+e.slice(1)}var p0t=function(){function e(t){zl(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Qu.create("languageUtils")}return Gl(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return 2===t.length||(t.pop(),"x"===t[t.length-1].toLowerCase())?null:this.formatLanguageCode(t.join("-"))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],n=e.split("-");return this.options.lowerCaseLng?n=n.map((function(e){return e.toLowerCase()})):2===n.length?(n[0]=n[0].toLowerCase(),n[1]=n[1].toUpperCase(),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=V6(n[1].toLowerCase()))):3===n.length&&(n[0]=n[0].toLowerCase(),2===n[1].length&&(n[1]=n[1].toUpperCase()),"sgn"!==n[0]&&2===n[2].length&&(n[2]=n[2].toUpperCase()),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=V6(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=V6(n[2].toLowerCase()))),n.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,n=this;return e?(e.forEach((function(e){if(!t){var i=n.formatLanguageCode(e);(!n.options.supportedLngs||n.isSupportedCode(i))&&(t=i)}})),!t&&this.options.supportedLngs&&e.forEach((function(e){if(!t){var i=n.getLanguagePartFromCode(e);if(n.isSupportedCode(i))return t=i;t=n.options.supportedLngs.find((function(e){if(0===e.indexOf(i))return e}))}})),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}},{key:"toResolveHierarchy",value:function(e,t){var n=this,i=this.getFallbackCodes(t||this.options.fallbackLng||[],e),r=[],a=function(e){e&&(n.isSupportedCode(e)?r.push(e):n.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&a(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&a(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&a(this.getLanguagePartFromCode(e))):"string"==typeof e&&a(this.formatLanguageCode(e)),i.forEach((function(e){r.indexOf(e)<0&&a(n.formatLanguageCode(e))})),r}}]),e}(),m0t=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],g0t={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1&&e%100!=11?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},v0t=["v1","v2","v3"],x0e={zero:0,one:1,two:2,few:3,many:4,other:5};function y0t(){var e={};return m0t.forEach((function(t){t.lngs.forEach((function(n){e[n]={numbers:t.nr,plurals:g0t[t.fc]}}))})),e}var x0t=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};zl(this,e),this.languageUtils=t,this.options=n,this.logger=Qu.create("pluralResolver"),(!this.options.compatibilityJSON||"v4"===this.options.compatibilityJSON)&&("undefined"==typeof Intl||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=y0t()}return Gl(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,t);return this.shouldUseIntlApi()?n&&n.resolvedOptions().pluralCategories.length>1:n&&n.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,n).map((function(e){return"".concat(t).concat(e)}))}},{key:"getSuffixes",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.getRule(e,n);return i?this.shouldUseIntlApi()?i.resolvedOptions().pluralCategories.sort((function(e,t){return x0e[e]-x0e[t]})).map((function(e){return"".concat(t.options.prepend).concat(e)})):i.numbers.map((function(i){return t.getSuffix(e,i,n)})):[]}},{key:"getSuffix",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this.getRule(e,n);return i?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(i.select(t)):this.getSuffixRetroCompatible(i,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var n=this,i=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),r=e.numbers[i];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===r?r="plural":1===r&&(r=""));var a=function(){return n.options.prepend&&r.toString()?n.options.prepend+r.toString():r.toString()};return"v1"===this.options.compatibilityJSON?1===r?"":"number"==typeof r?"_plural_".concat(r.toString()):a():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?a():this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString()}},{key:"shouldUseIntlApi",value:function(){return!v0t.includes(this.options.compatibilityJSON)}}]),e}();function b0e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function Vc(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{};zl(this,e),this.logger=Qu.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return Gl(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:a0t,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?My(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?My(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?My(t.nestingPrefix):t.nestingPrefixEscaped||My("$t("),this.nestingSuffix=t.nestingSuffix?My(t.nestingSuffix):t.nestingSuffixEscaped||My(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(t,"g");var n="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(n,"g")}},{key:"interpolate",value:function(e,t,n,i){var r,a,s,o=this,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function h(e){return e.replace(/\$/g,"$$$$")}var c=function(e){if(e.indexOf(o.formatSeparator)<0){var r=p0e(t,l,e);return o.alwaysFormat?o.format(r,void 0,n,Vc(Vc(Vc({},i),t),{},{interpolationkey:e})):r}var a=e.split(o.formatSeparator),s=a.shift().trim(),h=a.join(o.formatSeparator).trim();return o.format(p0e(t,l,s),h,n,Vc(Vc(Vc({},i),t),{},{interpolationkey:s}))};this.resetRegExp();var u=i&&i.missingInterpolationHandler||this.options.missingInterpolationHandler,d=i&&i.interpolation&&void 0!==i.interpolation.skipOnVariables?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return h(e)}},{regex:this.regexp,safeValue:function(e){return o.escapeValue?h(o.escape(e)):h(e)}}].forEach((function(t){for(s=0;r=t.regex.exec(e);){var n=r[1].trim();if(void 0===(a=c(n)))if("function"==typeof u){var l=u(e,r,i);a="string"==typeof l?l:""}else if(i&&i.hasOwnProperty(n))a="";else{if(d){a=r[0];continue}o.logger.warn("missed to pass in variable ".concat(n," for interpolating ").concat(e)),a=""}else"string"!=typeof a&&!o.useRawValueToEscape&&(a=d0e(a));var h=t.safeValue(a);if(e=e.replace(r[0],h),d?(t.regex.lastIndex+=a.length,t.regex.lastIndex-=r[0].length):t.regex.lastIndex=0,++s>=o.maxReplaces)break}})),e}},{key:"nest",value:function(e,t){var n,i,r=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=Vc({},a);function o(e,t){var n=this.nestingOptionsSeparator;if(e.indexOf(n)<0)return e;var i=e.split(new RegExp("".concat(n,"[ ]*{"))),r="{".concat(i[1]);e=i[0];var a=(r=this.interpolate(r,s)).match(/'/g),o=r.match(/"/g);(a&&a.length%2==0&&!o||o.length%2!=0)&&(r=r.replace(/'/g,'"'));try{s=JSON.parse(r),t&&(s=Vc(Vc({},t),s))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(n).concat(r)}return delete s.defaultValue,e}for(s.applyPostProcessor=!1,delete s.defaultValue;n=this.nestingRegexp.exec(e);){var l=[],h=!1;if(-1!==n[0].indexOf(this.formatSeparator)&&!/{.*}/.test(n[1])){var c=n[1].split(this.formatSeparator).map((function(e){return e.trim()}));n[1]=c.shift(),l=c,h=!0}if((i=t(o.call(this,n[1].trim(),s),s))&&n[0]===e&&"string"!=typeof i)return i;"string"!=typeof i&&(i=d0e(i)),i||(this.logger.warn("missed to resolve ".concat(n[1]," for nesting ").concat(e)),i=""),h&&(i=l.reduce((function(e,t){return r.format(e,t,a.lng,Vc(Vc({},a),{},{interpolationkey:n[1].trim()}))}),i.trim())),e=e.replace(n[0],i),this.regexp.lastIndex=0}return e}}]),e}();function E0e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function Vf(e){for(var t=1;t-1){var i=e.split("(");t=i[0].toLowerCase().trim();var r=i[1].substring(0,i[1].length-1);"currency"===t&&r.indexOf(":")<0?n.currency||(n.currency=r.trim()):"relativetime"===t&&r.indexOf(":")<0?n.range||(n.range=r.trim()):r.split(";").forEach((function(e){if(e){var t=H6(e.split(":")),i=t[0],r=t.slice(1).join(":").trim().replace(/^'+|'+$/g,"");n[i.trim()]||(n[i.trim()]=r),"false"===r&&(n[i.trim()]=!1),"true"===r&&(n[i.trim()]=!0),isNaN(r)||(n[i.trim()]=parseInt(r,10))}}))}return{formatName:t,formatOptions:n}}function Ry(e){var t={};return function(n,i,r){var a=i+JSON.stringify(r),s=t[a];return s||(s=e(i,r),t[a]=s),s(n)}}var _0t=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};zl(this,e),this.logger=Qu.create("formatter"),this.options=t,this.formats={number:Ry((function(e,t){var n=new Intl.NumberFormat(e,t);return function(e){return n.format(e)}})),currency:Ry((function(e,t){var n=new Intl.NumberFormat(e,Vf(Vf({},t),{},{style:"currency"}));return function(e){return n.format(e)}})),datetime:Ry((function(e,t){var n=new Intl.DateTimeFormat(e,Vf({},t));return function(e){return n.format(e)}})),relativetime:Ry((function(e,t){var n=new Intl.RelativeTimeFormat(e,Vf({},t));return function(e){return n.format(e,t.range||"day")}})),list:Ry((function(e,t){var n=new Intl.ListFormat(e,Vf({},t));return function(e){return n.format(e)}}))},this.init(t)}return Gl(e,[{key:"init",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=Ry(t)}},{key:"format",value:function(e,t,n,i){var r=this;return t.split(this.formatSeparator).reduce((function(e,t){var a=E0t(t),s=a.formatName,o=a.formatOptions;if(r.formats[s]){var l=e;try{var h=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},c=h.locale||h.lng||i.locale||i.lng||n;l=r.formats[s](e,c,Vf(Vf(Vf({},o),i),h))}catch(e){r.logger.warn(e)}return l}return r.logger.warn("there was no format function for ".concat(s)),e}),e)}}]),e}();function _0e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function T0e(e){for(var t=1;t3&&void 0!==arguments[3]?arguments[3]:{};return zl(this,n),a=t.call(this),QC&&zf.call(Hc(a)),a.backend=e,a.store=i,a.services=r,a.languageUtils=r.languageUtils,a.options=s,a.logger=Qu.create("backendConnector"),a.waitingReads=[],a.maxParallelReads=s.maxParallelReads||10,a.readingCalls=0,a.maxRetries=s.maxRetries>=0?s.maxRetries:5,a.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,a.state={},a.queue=[],a.backend&&a.backend.init&&a.backend.init(r,s.backend,s),a}return Gl(n,[{key:"queueLoad",value:function(e,t,n,i){var r=this,a={},s={},o={},l={};return e.forEach((function(e){var i=!0;t.forEach((function(t){var o="".concat(e,"|").concat(t);!n.reload&&r.store.hasResourceBundle(e,t)?r.state[o]=2:r.state[o]<0||(1===r.state[o]?void 0===s[o]&&(s[o]=!0):(r.state[o]=1,i=!1,void 0===s[o]&&(s[o]=!0),void 0===a[o]&&(a[o]=!0),void 0===l[t]&&(l[t]=!0)))})),i||(o[e]=!0)})),(Object.keys(a).length||Object.keys(s).length)&&this.queue.push({pending:s,pendingCount:Object.keys(s).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(s),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(l)}}},{key:"loaded",value:function(e,t,n){var i=e.split("|"),r=i[0],a=i[1];t&&this.emit("failedLoading",r,a,t),n&&this.store.addResourceBundle(r,a,n),this.state[e]=t?-1:2;var s={};this.queue.forEach((function(n){i0t(n.loaded,[r],a),S0t(n,e),t&&n.errors.push(t),0===n.pendingCount&&!n.done&&(Object.keys(n.loaded).forEach((function(e){s[e]||(s[e]={});var t=n.loaded[e];t.length&&t.forEach((function(t){void 0===s[e][t]&&(s[e][t]=!0)}))})),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())})),this.emit("loaded",s),this.queue=this.queue.filter((function(e){return!e.done}))}},{key:"read",value:function(e,t,n){var i=this,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,s=arguments.length>5?arguments[5]:void 0;return e.length?this.readingCalls>=this.maxParallelReads?void this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:a,callback:s}):(this.readingCalls++,this.backend[n](e,t,(function(o,l){if(i.readingCalls--,i.waitingReads.length>0){var h=i.waitingReads.shift();i.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}o&&l&&r2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var a=this.queueLoad(e,t,i,r);if(!a.toLoad.length)return a.pending.length||r(),null;a.toLoad.forEach((function(e){n.loadOne(e)}))}},{key:"load",value:function(e,t,n){this.prepareLoading(e,t,{},n)}},{key:"reload",value:function(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}},{key:"loadOne",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=e.split("|"),r=i[0],a=i[1];this.read(r,a,"read",void 0,void 0,(function(i,s){i&&t.logger.warn("".concat(n,"loading namespace ").concat(a," for language ").concat(r," failed"),i),!i&&s&&t.logger.log("".concat(n,"loaded namespace ").concat(a," for language ").concat(r),s),t.loaded(e,i,s)}))}},{key:"saveMissing",value:function(e,t,n,i,r){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t)?this.logger.warn('did not save key "'.concat(n,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"):null==n||""===n||(this.backend&&this.backend.create&&this.backend.create(e,t,n,i,null,T0e(T0e({},a),{},{isUpdate:r})),e&&e[0]&&this.store.addResource(e[0],t,n,i))}}]),n}();function R0t(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===_a(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===_a(e[2])||"object"===_a(e[3])){var n=e[3]||e[2];Object.keys(n).forEach((function(e){t[e]=n[e]}))}return t},interpolation:{escapeValue:!0,format:function(e,t,n,i){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function w0e(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function S0e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function Ju(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if(zl(this,n),e=t.call(this),QC&&zf.call(Hc(e)),e.options=w0e(i),e.services={},e.logger=Qu,e.modules={external:[]},P0t(Hc(e)),r&&!e.isInitialized&&!i.isClone){if(!e.options.initImmediate)return e.init(i,r),Qm(e,Hc(e));setTimeout((function(){e.init(i,r)}),0)}return e}return Gl(n,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(n=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));var i=R0t();function r(e){return e?"function"==typeof e?new e:e:null}if(this.options=Ju(Ju(Ju({},i),this.options),w0e(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=Ju(Ju({},i.interpolation),this.options.interpolation)),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){var a;this.modules.logger?Qu.init(r(this.modules.logger),this.options):Qu.init(null,this.options),this.modules.formatter?a=this.modules.formatter:"undefined"!=typeof Intl&&(a=_0t);var s=new p0t(this.options);this.store=new h0t(this.options.resources,this.options);var o=this.services;o.logger=Qu,o.resourceStore=this.store,o.languageUtils=s,o.pluralResolver=new x0t(s,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),a&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(o.formatter=r(a),o.formatter.init(o,this.options),this.options.interpolation.format=o.formatter.format.bind(o.formatter)),o.interpolator=new b0t(this.options),o.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},o.backendConnector=new M0t(r(this.modules.backend),o.resourceStore,o,this.options),o.backendConnector.on("*",(function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r1?n-1:0),r=1;r0&&"dev"!==l[0]&&(this.options.lng=l[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach((function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments)}})),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments),e}}));var h=u_(),c=function(){var t=function(t,i){e.isInitialized&&!e.initializedStoreOnce&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),h.resolve(i),n(t,i)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?c():setTimeout(c,0),h}},{key:"loadResources",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ZC,i="string"==typeof e?e:this.language;if("function"==typeof e&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(i&&"cimode"===i.toLowerCase())return n();var r=[],a=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach((function(e){r.indexOf(e)<0&&r.push(e)}))};i?a(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((function(e){return a(e)})),this.options.preload&&this.options.preload.forEach((function(e){return a(e)})),this.services.backendConnector.load(r,this.options.ns,(function(e){!e&&!t.resolvedLanguage&&t.language&&t.setResolvedLanguage(t.language),n(e)}))}else n(null)}},{key:"reloadResources",value:function(e,t,n){var i=u_();return e||(e=this.languages),t||(t=this.options.ns),n||(n=ZC),this.services.backendConnector.reload(e,t,(function(e){i.resolve(),n(e)})),i}},{key:"use",value:function(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&A0e.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}}},{key:"changeLanguage",value:function(e,t){var n=this;this.isLanguageChangingTo=e;var i=u_();this.emit("languageChanging",e);var r=function(e){n.language=e,n.languages=n.services.languageUtils.toResolveHierarchy(e),n.resolvedLanguage=void 0,n.setResolvedLanguage(e)},a=function(a){!e&&!a&&n.services.languageDetector&&(a=[]);var s="string"==typeof a?a:n.services.languageUtils.getBestMatchFromCodes(a);s&&(n.language||r(s),n.translator.language||n.translator.changeLanguage(s),n.services.languageDetector&&n.services.languageDetector.cacheUserLanguage(s)),n.loadResources(s,(function(e){!function(e,a){a?(r(a),n.translator.changeLanguage(a),n.isLanguageChangingTo=void 0,n.emit("languageChanged",a),n.logger.log("languageChanged",a)):n.isLanguageChangingTo=void 0,i.resolve((function(){return n.t.apply(n,arguments)})),t&&t(e,(function(){return n.t.apply(n,arguments)}))}(e,s)}))};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(a):a(e):a(this.services.languageDetector.detect()),i}},{key:"getFixedT",value:function(e,t,n){var i=this,r=function e(t,r){var a;if("object"!==_a(r)){for(var s=arguments.length,o=new Array(s>2?s-2:0),l=2;l1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var i=this.resolvedLanguage||this.languages[0],r=!!this.options&&this.options.fallbackLng,a=this.languages[this.languages.length-1];if("cimode"===i.toLowerCase())return!0;var s=function(e,n){var i=t.services.backendConnector.state["".concat(e,"|").concat(n)];return-1===i||2===i};if(n.precheck){var o=n.precheck(this,s);if(void 0!==o)return o}return!!(this.hasResourceBundle(i,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||s(i,e)&&(!r||s(a,e)))}},{key:"loadNamespaces",value:function(e,t){var n=this,i=u_();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach((function(e){n.options.ns.indexOf(e)<0&&n.options.ns.push(e)})),this.loadResources((function(e){i.resolve(),t&&t(e)})),i):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var n=u_();"string"==typeof e&&(e=[e]);var i=this.options.preload||[],r=e.filter((function(e){return i.indexOf(e)<0}));return r.length?(this.options.preload=i.concat(r),this.loadResources((function(e){n.resolve(),t&&t(e)})),n):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){return e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),e?["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(this.services.languageUtils.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr":"rtl"}},{key:"cloneInstance",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ZC,r=Ju(Ju(Ju({},this.options),t),{isClone:!0}),a=new n(r);return(void 0!==t.debug||void 0!==t.prefix)&&(a.logger=a.logger.clone(t)),["store","services","language"].forEach((function(t){a[t]=e[t]})),a.services=Ju({},this.services),a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a.translator=new y0e(a.services,a.options),a.translator.on("*",(function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}));var Xa=JC.createInstance();Xa.createInstance=JC.createInstance;var zqt=Xa.createInstance,Gqt=Xa.init,qqt=Xa.loadResources,Wqt=Xa.reloadResources,jqt=Xa.use,Xqt=Xa.changeLanguage,Yqt=Xa.getFixedT,eh=Xa.t,$qt=Xa.exists,Zqt=Xa.setDefaultNamespace,Kqt=Xa.hasLoadedNamespace,Jqt=Xa.loadNamespaces,Qqt=Xa.loadLanguages,eg=Xa,Gf=class{constructor(e){this.progresseItems=[],this.element=document.createElement("div"),this.element.classList.add("progress-bar"),e.appendChild(this.element)}setVisibility(e){this.element&&(e?this.element.classList.remove("hidden"):this.element.classList.add("hidden"))}addProgressItem(e,t){let n=this.progresseItems.find((t=>t.id===e));if(!n){let i=document.createElement("div");i.classList.add("progress-bar-item"),i.innerHTML=t||"",this.element.append(i),n={id:e,div:i},this.progresseItems.push(n)}this.setVisibility(!0)}updateProgress(e,t,n){let i=this.progresseItems.find((t=>t.id===e));if(!i)return;let r=t?`${t}`:"";t&&null!=n&&(r+=": "),null!=n&&(n<0||n>100?(console.warn(`[ProgressBar] Invalid progress value: ${n}`),r+="--%"):r+=`${n.toFixed(2)}%`),i.div.innerHTML=r}removeProgressItem(e){let t=this.progresseItems.find((t=>t.id===e));t&&t.div.remove(),0===this.progresseItems.length&&this.setVisibility(!1)}delayRemoveProgressItem(e,t=3e3){setTimeout((()=>{this.removeProgressItem(e)}),t)}},C0e={enableSpinner:!0,containerId:"myCanvas",units:"meters"};function Ay(e){return{all:e=e||new Map,on:function(t,n){var i=e.get(t);i?i.push(n):e.set(t,[n])},off:function(t,n){var i=e.get(t);i&&(n?i.splice(i.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var i=e.get(t);i&&i.slice().map((function(e){e(n)})),(i=e.get("*"))&&i.slice().map((function(e){e(t,n)}))}}}var eP=class{constructor(e){this.viewer=e,this.itemList={},this.handleMouseWheel=e=>{e.preventDefault(),this.element&&(this.element.scrollLeft+=e.deltaY)},e.addEventListener("ModelLoaded",(()=>{this.init()}))}init(){var e;let t=document.createElement("div");t.classList.add("model-layout-switch-bar");let n=document.createElement("div");n.classList.add("model-layout-switch-bar-content"),n.addEventListener("wheel",this.handleMouseWheel),this.viewer.getLayoutNames().forEach(((e,t)=>{let i=this.createItem(e,t);this.itemList[e]=i,i.resetActivate=()=>{for(let e in this.itemList)this.itemList[e].resetActive()},null==n||n.appendChild(i.element)})),this.element=t,this.content=n,this.element.appendChild(this.content),null==(e=this.viewer.widgetContainer)||e.appendChild(this.element)}createItem(e,t){let n=new G6(this.viewer,e);return 0===t&&n.setActive(!0),n}destroy(){var e,t;for(let n in this.itemList){let t=this.itemList[n];t.destroy(),null==(e=this.content)||e.removeChild(t.element)}this.itemList={},this.element&&this.content&&(this.element.removeChild(this.content),this.element.removeEventListener("wheel",this.handleMouseWheel),null==(t=this.viewer.widgetContainer)||t.removeChild(this.element),this.element=void 0)}show(){this.element&&(this.element.style.display="block")}hide(){this.element&&(this.element.style.display="none")}},G6=class{constructor(e,t){this.viewer=e,this.eventBus=Ay(),this.active=!1,this.element=this.createItem(t),this.eventBus.on("activechange",(e=>{this.resetActivate&&this.resetActivate(),e?(this.element.classList.add("activate"),this.viewer.activateLayout(t)):this.element.classList.remove("activate")}))}createItem(e){let t=document.createElement("div"),n=document.createElement("span");return t.classList.add("model-layout-switch-item"),t.onclick=()=>{this.active=!this.active,this.eventBus.emit("activechange",this.active)},n.innerText=e,t.appendChild(n),t}setActive(e){this.active!==e&&(this.active=e,this.eventBus.emit("activechange",e))}resetActive(){this.active=!1,this.element.classList.remove("activate")}destroy(){this.eventBus.off("activechange")}},tP=class{constructor(e,t){this.flyDuration=500,this.autoRotateRemainingTime=0,this.automaticallyAdjustCameraPosition=!0,this.rotateIntervalStartTime=0,this.camera=e,this.controls=t}flyTo(e,t,n){let i=this.camera,r=this.controls;if(!i||!r)return;if(e.equals(t))return void console.error("[Controls] camera position and lookAt cannot be the same!");if(isNaN(e.x)||isNaN(e.y)||isNaN(e.z)||isNaN(t.x)||isNaN(t.y)||isNaN(t.z))return void console.error("[Controls] invalid position or lookAt!");if(this.automaticallyAdjustCameraPosition){let n=e.distanceTo(t);ni.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*i.far),console.warn("[Controls] camera could be too far to see the object!"))}let a=i.position.clone(),s=r.target.clone(),o=this.flyDuration,l=Date.now();this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=setInterval((()=>{let h=Date.now()-l;h>o&&(h=o);let c=(e,t,n)=>{let i=e.x+(t.x-e.x)*n,r=e.y+(t.y-e.y)*n,a=e.z+(t.z-e.z)*n;return new O(i,r,a)};((e,t)=>{i.lookAt(t),i.position.set(e.x,e.y,e.z),r.target.set(t.x,t.y,t.z),r.update()})(c(a,e,h/o),c(s,t,h/o)),h>=o&&(clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=void 0,n&&n())}),10)}lookTo(e){let t=this.camera,n=this.controls;if(!t||!n)return;let i=t.position,r=n.target.distanceTo(i),a=e.normalize().multiplyScalar(r),s=new O(i.x+a.x,i.y+a.y,i.z+a.z);this.flyTo(i,s)}startAutoRotate(){let e=this.camera,t=this.controls;if(!e||!t)return;t.autoRotate=!0;let n=new O;e.getWorldPosition(n);let i=t.target;if(i.y===n.y)return;let r=(i.y-n.y)/50;for(let a=0;a<50;++a)setTimeout((()=>{let e=t.target.y-r;t.target.setY(e),t.update()}),30*a)}delayAutoRotate(){this.autoRotateRemainingTime=5e3,this.controls&&(this.controls.autoRotate=!1)}startToRotate(e){let t=Date.now()-this.rotateIntervalStartTime;this.rotateIntervalStartTime=Date.now(),!(this.rotateInterval&&t<100)&&(this.rotateInterval&&clearInterval(this.rotateInterval),this.rotateInterval=setInterval((()=>{if(Date.now()-this.rotateIntervalStartTime>=100)return clearInterval(this.rotateInterval),void(this.rotateInterval=void 0);"ArrowLeft"===e.code||"ArrowRight"===e.code?this.rotateLeftOrRight(.3,"ArrowLeft"===e.code):("ArrowUp"===e.code||"ArrowDown"===e.code)&&this.rotateUpOrDown(.3,"ArrowUp"===e.code)}),1))}rotateLeftOrRight(e,t=!0){let n=this.controls;if(!this.camera||!n)return;let i=this.camera.position,r=n.target,a=r.clone(),s=Math.PI*e/180;t&&(s=-s),a.x=(r.x-i.x)*Math.cos(s)-(r.z-i.z)*Math.sin(s)+i.x,a.z=(r.z-i.z)*Math.cos(s)+(r.x-i.x)*Math.sin(s)+i.z,this.camera.lookAt(a),n.target=a,n.update()}rotateUpOrDown(e,t=!0){let n=this.controls;if(!this.camera||!n)return;let i=this.camera.position,r=n.target,a=r.clone(),s=Math.PI*e/180,o=new O(r.x-i.x,r.y-i.y,r.z-i.z).length(),l=r.y-i.y;t||(s=-s);let h=Math.asin(l/o)+s;if(h<-Math.PI/2||h>Math.PI/2)return;let c=Math.sin(h)*o;a.y=r.y+(c-l),n.target=a,n.update()}},P0e=class{constructor(e){this.object=e}instantiate(){let e=Date.now();this.instantiateInner(this.object),console.log(`[Inst] instantiate() costed ${(Date.now()-e)/1e3}s`)}instantiateInner(e){if(!e.children||0===e.children.length)return;let t=e.children.length,n={},i=[];for(let s=0;s0||!t.geometry)continue;let r=!1,a=Object.values(n);for(let o=a.length-1;o>=0;--o){let l=a[o].indexes[0],h=e.children[l];if(this.geometryEquals(t.geometry,h.geometry)&&es.materialsEquals(t.material,h.material)){n[l]||(n[l]={indexes:[l]},this.removeFromArray(i,l)),n[l].indexes.push(s),r=!0;break}}for(let o=i.length-1;!r&&o>=0;--o){let a=i[o],l=e.children[a];if(this.geometryEquals(t.geometry,l.geometry)&&es.materialsEquals(t.material,l.material)){n[a]||(n[a]={indexes:[a]},this.removeFromArray(i,a)),n[a].indexes.push(s),r=!0;break}}r||i.push(s)}if(Object.keys(n).length<=0)return;let r=[],a=[];Object.values(n).forEach((t=>{let n=t.indexes;a.push(...n);let i=e.children[n[0]],s=i.material;if(s instanceof vr)s=s.clone();else if(Array.isArray(s)){let e=[];s.forEach((t=>e.push(t.clone()))),s=e}let o=new Pi(i.geometry,s,n.length);o.name=`[Instanced] ${i.name}`;for(let r=0;rt-e)),a.forEach((t=>e.remove(e.children[t]))),r.forEach((t=>{t.parent=e,e.children.push(t)})),e.updateMatrix(),console.log(`[Inst] ${a.length}(out of ${t}) objects instanced to ${r.length} InstancedMesh`)}removeFromArray(e,t){for(let n=e.length-1;n>=0;--n)if(e[n]===t)return void e.splice(n,1)}geometryEquals(e,t){return Qt.geometryEquals(e,t)}},qf=class{constructor(){this.TIMEOUT="timeout",this.INTERVAL="interval",this.timeoutMap={},this.intervalMap={}}run(e=this.INTERVAL,t,n=16.7){let i=Date.now,r=i(),a=r,s=Symbol(""),o=()=>{this.setIdMap(s,e,o),a=i(),a-r>=n&&(e===this.intervalMap&&(r=i(),a=r),t(),e===this.TIMEOUT&&this.clearTimeout(s))};return this.setIdMap(s,e,o),s}setIdMap(e,t,n){let i=requestAnimationFrame(n);t===this.INTERVAL?this.intervalMap[e]=i:t===this.TIMEOUT&&(this.timeoutMap[e]=i)}setTimeout(e,t){return this.run(this.TIMEOUT,e,t)}clearTimeout(e){cancelAnimationFrame(this.timeoutMap[e])}setInterval(e,t){return this.run(this.INTERVAL,e,t)}clearInterval(e){cancelAnimationFrame(this.intervalMap[e])}},h_=class extends Tm{constructor(e){super(e)}parse(e){e.length<19&&console.error("THREE.TGALoader: Not enough data to contain header.");let t=0,n=new Uint8Array(e),i={id_length:n[t++],colormap_type:n[t++],image_type:n[t++],colormap_index:n[t++]|n[t++]<<8,colormap_length:n[t++]|n[t++]<<8,colormap_size:n[t++],origin:[n[t++]|n[t++]<<8,n[t++]|n[t++]<<8],width:n[t++]|n[t++]<<8,height:n[t++]|n[t++]<<8,pixel_size:n[t++],flags:n[t++]};(function(e){switch(e.image_type){case 1:case 9:(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case 2:case 3:case 10:case 11:e.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case 0:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',e.image_type)}(e.width<=0||e.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error('THREE.TGALoader: Invalid pixel size "%s".',e.pixel_size)})(i),i.id_length+t>e.length&&console.error("THREE.TGALoader: No data."),t+=i.id_length;let r=!1,a=!1,s=!1;switch(i.image_type){case 9:r=!0,a=!0;break;case 1:a=!0;break;case 10:r=!0;break;case 2:break;case 11:r=!0,s=!0;break;case 3:s=!0}let o=new Uint8Array(i.width*i.height*4),l=function(e,t,n,i,r){let a,s,o=n.pixel_size>>3,l=n.width*n.height*o;if(t&&(s=r.subarray(i,i+=n.colormap_length*(n.colormap_size>>3))),e){a=new Uint8Array(l);let e,t,n,s=0,h=new Uint8Array(o);for(;s>4){default:case 2:o=0,h=1,u=t,l=0,c=1,d=n;break;case 0:o=0,h=1,u=t,l=n-1,c=-1,d=-1;break;case 3:o=t-1,h=-1,u=-1,l=0,c=1,d=n;break;case 1:o=t-1,h=-1,u=-1,l=n-1,c=-1,d=-1}if(s)switch(i.pixel_size){case 8:!function(e,t,n,r,a,s,o,l){let h,c,u,d=0,p=i.width;for(u=t;u!==r;u+=n)for(c=a;c!==o;c+=s,d++)h=l[d],e[4*(c+p*u)+0]=h,e[4*(c+p*u)+1]=h,e[4*(c+p*u)+2]=h,e[4*(c+p*u)+3]=255}(e,l,c,d,o,h,u,r);break;case 16:!function(e,t,n,r,a,s,o,l){let h,c,u=0,d=i.width;for(c=t;c!==r;c+=n)for(h=a;h!==o;h+=s,u+=2)e[4*(h+d*c)+0]=l[u+0],e[4*(h+d*c)+1]=l[u+0],e[4*(h+d*c)+2]=l[u+0],e[4*(h+d*c)+3]=l[u+1]}(e,l,c,d,o,h,u,r);break;default:console.error("THREE.TGALoader: Format not supported.")}else switch(i.pixel_size){case 8:!function(e,t,n,r,a,s,o,l,h){let c,u,d,p=h,f=0,m=i.width;for(d=t;d!==r;d+=n)for(u=a;u!==o;u+=s,f++)c=l[f],e[4*(u+m*d)+3]=255,e[4*(u+m*d)+2]=p[3*c+0],e[4*(u+m*d)+1]=p[3*c+1],e[4*(u+m*d)+0]=p[3*c+2]}(e,l,c,d,o,h,u,r,a);break;case 16:!function(e,t,n,r,a,s,o,l){let h,c,u,d=0,p=i.width;for(u=t;u!==r;u+=n)for(c=a;c!==o;c+=s,d+=2)h=l[d+0]+(l[d+1]<<8),e[4*(c+p*u)+0]=(31744&h)>>7,e[4*(c+p*u)+1]=(992&h)>>2,e[4*(c+p*u)+2]=(31&h)<<3,e[4*(c+p*u)+3]=32768&h?0:255}(e,l,c,d,o,h,u,r);break;case 24:!function(e,t,n,r,a,s,o,l){let h,c,u=0,d=i.width;for(c=t;c!==r;c+=n)for(h=a;h!==o;h+=s,u+=3)e[4*(h+d*c)+3]=255,e[4*(h+d*c)+2]=l[u+0],e[4*(h+d*c)+1]=l[u+1],e[4*(h+d*c)+0]=l[u+2]}(e,l,c,d,o,h,u,r);break;case 32:!function(e,t,n,r,a,s,o,l){let h,c,u=0,d=i.width;for(c=t;c!==r;c+=n)for(h=a;h!==o;h+=s,u+=4)e[4*(h+d*c)+2]=l[u+0],e[4*(h+d*c)+1]=l[u+1],e[4*(h+d*c)+0]=l[u+2],e[4*(h+d*c)+3]=l[u+3]}(e,l,c,d,o,h,u,r);break;default:console.error("THREE.TGALoader: Format not supported.")}}(o,i.width,i.height,l.pixel_data,l.palettes),{data:o,width:i.width,height:i.height,flipY:!0,generateMipmaps:!0,minFilter:Ua}}},nP=class extends _r{constructor(e){super(e)}load(e,t,n,i){let r=this,a=""===r.path?ra.extractUrlBase(e):r.path,s=new Kr(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,(function(n){try{t(r.parse(n,a))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e,t){function n(e,t){let n=[],i=e.childNodes;for(let r=0,a=i.length;r0&&t.push(new ho(i+".position",r,a)),s.length>0&&t.push(new Ga(i+".quaternion",r,s)),o.length>0&&t.push(new ho(i+".scale",r,o)),t}function b(e,t,n){let i,r,a,s=!0;for(r=0,a=e.length;r=0;){let i=e[t];if(null!==i.value[n])return i;t--}return null}function w(e,t,n){for(;t>>0));return t="tga"===(n=n.toLowerCase(),n)?qe:Xe,t}(r);if(void 0!==n){let i=n.load(r),a=e.extra;if(void 0!==a&&void 0!==a.technique&&!1===o(a.technique)){let e=a.technique;i.wrapS=e.wrapU?Ci:Ai,i.wrapT=e.wrapV?Ci:Ai,i.offset.set(e.offsetU||0,e.offsetV||0),i.repeat.set(e.repeatU||1,e.repeatV||1)}else i.wrapS=Ci,i.wrapT=Ci;return null!==t&&(i.colorSpace=t),i}return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",r),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",e.id),null}t.name=e.name||"";let a=i.parameters;for(let o in a){let e=a[o];switch(o){case"diffuse":e.color&&t.color.fromArray(e.color),e.texture&&(t.map=r(e.texture,tn));break;case"specular":e.color&&t.specular&&t.specular.fromArray(e.color),e.texture&&(t.specularMap=r(e.texture));break;case"bump":e.texture&&(t.normalMap=r(e.texture));break;case"ambient":e.texture&&(t.lightMap=r(e.texture,tn));break;case"shininess":e.float&&t.shininess&&(t.shininess=e.float);break;case"emission":e.color&&t.emissive&&t.emissive.fromArray(e.color),e.texture&&(t.emissiveMap=r(e.texture,tn))}}t.color.convertSRGBToLinear(),t.specular&&t.specular.convertSRGBToLinear(),t.emissive&&t.emissive.convertSRGBToLinear();let s=a.transparent,l=a.transparency;if(void 0===l&&s&&(l={float:1}),void 0===s&&l&&(s={opaque:"A_ONE",data:{color:[1,1,1,1]}}),s&&l)if(s.data.texture)t.transparent=!0;else{let e=s.data.color;switch(s.opaque){case"A_ONE":t.opacity=e[3]*l.float;break;case"RGB_ZERO":t.opacity=1-e[0]*l.float;break;case"A_ZERO":t.opacity=1-e[3]*l.float;break;case"RGB_ONE":t.opacity=e[0]*l.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',s.opaque)}t.opacity<1&&(t.transparent=!0)}if(void 0!==i.extra&&void 0!==i.extra.technique){let e=i.extra.technique;for(let n in e){let i=e[n];switch(n){case"double_sided":t.side=1===i?Er:ci;break;case"bump":t.normalMap=r(i.texture),t.normalScale=new be(1,1)}}}return t}function J(e){return c(et.materials[e],q)}function Z(e){for(let t=0;t0?n+o:n;t.inputs[l]={id:e,offset:r},t.stride=Math.max(t.stride,r+1),"TEXCOORD"===n&&(t.hasUV=!0);break;case"vcount":t.vcount=a(i.textContent);break;case"p":t.p=a(i.textContent)}}return t}function le(e){let t=0;for(let n=0,i=e.length;n0&&t0&&u.setAttribute("position",new Bt(r.array,r.stride)),a.array.length>0&&u.setAttribute("normal",new Bt(a.array,a.stride)),l.array.length>0&&u.setAttribute("color",new Bt(l.array,l.stride)),s.array.length>0&&u.setAttribute("uv",new Bt(s.array,s.stride)),o.array.length>0&&u.setAttribute("uv1",new Bt(o.array,o.stride)),h.length>0&&u.setAttribute("skinIndex",new Bt(h,4)),c.length>0&&u.setAttribute("skinWeight",new Bt(c,4)),i.data=u,i.type=e[0].type,i.materialKeys=d,i}function ue(e,t,n,i,r=!1){let a=e.p,s=e.stride,o=e.vcount;function l(e){let t=a[e+n]*c,s=t+c;for(;t4)for(let t=1,i=n-2;t<=i;t++){let n=e+s*t,i=e+s*(t+1);l(e+0*s),l(n),l(i)}e+=s*n}}else for(let u=0,d=a.length;u=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function ve(e){let t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]};for(let n=0;ni.limits.max||t{this.parse(e,t,i)}),n,i)}parse(e,t,n){this.decodeDracoFile(e,t,null,null,tn).catch(n)}decodeDracoFile(e,t,n,i,r=Ha){let a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(e,a).then(t)}decodeGeometry(e,t){let n=JSON.stringify(t);if(q6.has(e)){let t=q6.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i,r=this.workerNextTaskID++,a=e.byteLength,s=this._getWorker(r,a).then((n=>(i=n,new Promise(((n,a)=>{i._callbacks[r]={resolve:n,reject:a},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return s.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),q6.set(e,{key:n,promise:s}),s}_createGeometry(e){let t=new Dt;e.index&&t.setIndex(new gn(e.index.array,1));for(let n=0;n{n.load(e,t,void 0,i)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{let n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);let i=I0t.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.lengtht._taskLoad?-1:1}));let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e{let t=e.draco,s=new t.Decoder;try{let e=function(e,t,i,r){let a,s,o=r.attributeIDs,l=r.attributeTypes,h=t.GetEncodedGeometryType(i);if(h===e.TRIANGULAR_MESH)a=new e.Mesh,s=t.DecodeArrayToMesh(i,i.byteLength,a);else{if(h!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,s=t.DecodeArrayToPointCloud(i,i.byteLength,a)}if(!s.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+s.error_msg());let c={index:null,attributes:[]};for(let u in o){let i,s,h=self[l[u]];if(r.useUniqueIDs)s=o[u],i=t.GetAttributeByUniqueId(a,s);else{if(s=t.GetAttributeId(a,e[o[u]]),-1===s)continue;i=t.GetAttribute(a,s)}let d=n(e,t,a,u,h,i);"color"===u&&(d.vertexColorSpace=r.vertexColorSpace),c.attributes.push(d)}return h===e.TRIANGULAR_MESH&&(c.index=function(e,t,n){let i=3*n.num_faces(),r=4*i,a=e._malloc(r);t.GetTrianglesUInt32Array(n,r,a);let s=new Uint32Array(e.HEAPF32.buffer,a,i).slice();return e._free(a),{array:s,itemSize:1}}(e,t,a)),e.destroy(a),c}(t,s,new Int8Array(i),a),o=e.attributes.map((e=>e.array.buffer));e.index&&o.push(e.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:e},o)}catch(e){console.error(e),self.postMessage({type:"error",id:r.id,error:e.message})}finally{t.destroy(s)}}))}}}var I0e=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},L0t=function(e){return new Worker(e)};try{URL.revokeObjectURL(I0e(""))}catch(e){I0e=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},L0t=function(e){return new Worker(e,{type:"module"})}}var Wl=Uint8Array,Wf=Uint16Array,X6=Uint32Array,L0e=new Wl([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),D0e=new Wl([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),D0t=new Wl([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),O0e=function(e,t){for(var n=new Wf(31),i=0;i<31;++i)n[i]=t+=1<>>1|(21845&hi)<<1,ud=(52428&ud)>>>2|(13107&ud)<<2,ud=(61680&ud)>>>4|(3855&ud)<<4,Y6[hi]=((65280&ud)>>>8|(255&ud)<<8)>>>1;var ud,hi,d_=function(e,t,n){for(var i=e.length,r=0,a=new Wf(t);r>>l]=h}else for(s=new Wf(i),r=0;r>>15-e[r]);return s},f_=new Wl(288),hi,hi,hi;for(hi=0;hi<144;++hi)f_[hi]=8;for(hi=144;hi<256;++hi)f_[hi]=9;for(hi=256;hi<280;++hi)f_[hi]=7;for(hi=280;hi<288;++hi)f_[hi]=8;var hi,B0e=new Wl(32),hi;for(hi=0;hi<32;++hi)B0e[hi]=5;var F0t=d_(f_,9,1),N0t=d_(B0e,5,1),W6=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},zc=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&n},j6=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},B0t=function(e){return(e/8|0)+(7&e&&1)},U0t=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var i=new(e instanceof Wf?Wf:e instanceof X6?X6:Wl)(n-t);return i.set(e.subarray(t,n)),i},H0t=function(e,t,n){var i=e.length;if(!i||n&&!n.l&&i<5)return t||new Wl(0);var r=!t||n,a=!n||n.i;n||(n={}),t||(t=new Wl(3*i));var s=function(e){var n=t.length;if(e>n){var i=new Wl(Math.max(2*n,e));i.set(t),t=i}},o=n.f||0,l=n.p||0,h=n.b||0,c=n.l,u=n.d,d=n.m,p=n.n,f=8*i;do{if(!c){n.f=o=zc(e,l,1);var m=zc(e,l+1,3);if(l+=3,!m){var g=e[(A=B0t(l)+4)-4]|e[A-3]<<8,v=A+g;if(v>i){if(a)throw"unexpected EOF";break}r&&s(h+g),t.set(e.subarray(A,v),h),n.b=h+=g,n.p=l=8*v;continue}if(1==m)c=F0t,u=N0t,d=9,p=5;else{if(2!=m)throw"invalid block type";var y=zc(e,l,31)+257,x=zc(e,l+10,15)+4,b=y+zc(e,l+5,31)+1;l+=14;for(var _=new Wl(b),w=new Wl(19),S=0;S>>4)<16)_[S++]=A;else{var P=0,R=0;for(16==A?(R=3+zc(e,l,3),l+=2,P=_[S-1]):17==A?(R=3+zc(e,l,7),l+=3):18==A&&(R=11+zc(e,l,127),l+=7);R--;)_[S++]=P}}var O=_.subarray(0,y),L=_.subarray(y);d=W6(O),p=W6(L),c=d_(O,d,1),u=d_(L,p,1)}if(l>f){if(a)throw"unexpected EOF";break}}r&&s(h+131072);for(var I=(1<>>4;if((l+=15&P)>f){if(a)throw"unexpected EOF";break}if(!P)throw"invalid length/literal";if(N<256)t[h++]=N;else{if(256==N){k=l,c=null;break}var F=N-254;if(N>264){var U=L0e[S=N-257];F=zc(e,l,(1<>>4;if(!B)throw"invalid distance";if(l+=15&B,L=k0t[z],z>3&&(U=D0e[z],L+=j6(e,l)&(1<f){if(a)throw"unexpected EOF";break}r&&s(h+131072);for(var H=h+F;h>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"};function U0e(e,t){return H0t((z0t(e),e.subarray(2,-4)),t)}var G0t="undefined"!=typeof TextDecoder&&new TextDecoder,q0t=0;try{G0t.decode(V0t,{stream:!0}),q0t=1}catch(e){}function H0e(e,t,n){let i=n.length-e-1;if(t>=n[i])return i-1;if(t<=n[e])return e;let r=e,a=i,s=Math.floor((r+a)/2);for(;t=n[s+1];)t=a&&(r[t][0]=r[e][0]/o[h+1][l],i=r[t][0]*o[l][h]);let c=u-1<=h?a-1:n-u;for(let n=l>=-1?1:-l;n<=c;++n)r[t][n]=(r[e][n]-r[e][n-1])/o[h+1][l+n],i+=r[t][n]*o[l+n][h];u<=h&&(r[t][a]=-r[e][a-1]/o[h+1][u],i+=r[t][a]*o[u][h]),s[a][u]=i;let d=e;e=t,t=d}}let c=n;for(let u=1;u<=i;++u){for(let e=0;e<=n;++e)s[u][e]*=c;c*=n-u}return s}function Y0t(e,t,n,i,r){let a=r0,a="string"==typeof r.Content&&""!==r.Content;if(e||a){let e=this.parseImage(n[i]);t[r.RelativeFilename||r.Filename]=e}}}}for(let n in e){let i=e[n];void 0!==t[i]?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){let t,n=e.Content,i=e.RelativeFilename||e.Filename,r=i.slice(i.lastIndexOf(".")+1).toLowerCase();switch(r){case"bmp":t="image/bmp";break;case"jpg":case"jpeg":t="image/jpeg";break;case"png":t="image/png";break;case"tif":t="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",i),t="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+r+'" is not supported.')}if("string"==typeof n)return"data:"+t+";base64,"+n;{let e=new Uint8Array(n);return window.URL.createObjectURL(new Blob([e],{type:t}))}}parseTextures(e){let t=new Map;if("Texture"in Lr.Objects){let n=Lr.Objects.Texture;for(let i in n){let r=this.parseTexture(n[i],e);t.set(parseInt(i),r)}}return t}parseTexture(e,t){let n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;let i=e.WrapModeU,r=e.WrapModeV,a=void 0!==i?i.value:0,s=void 0!==r?r.value:0;if(n.wrapS=0===a?Ci:Ai,n.wrapT=0===s?Ci:Ai,"Scaling"in e){let t=e.Scaling.value;n.repeat.x=t[0],n.repeat.y=t[1]}if("Translation"in e){let t=e.Translation.value;n.offset.x=t[0],n.offset.y=t[1]}return n}loadTexture(e,t){let n,i=this.textureLoader.path,r=xs.get(e.id).children;void 0!==r&&r.length>0&&void 0!==t[r[0].ID]&&(n=t[r[0].ID],(0===n.indexOf("blob:")||0===n.indexOf("data:"))&&this.textureLoader.setPath(void 0));let a,s=e.FileName.slice(-3).toLowerCase();if("tga"===s){let t=this.manager.getHandler(".tga");null===t?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),a=new qr):(t.setPath(this.textureLoader.path),a=t.load(n))}else"psd"===s?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),a=new qr):a=this.textureLoader.load(n);return this.textureLoader.setPath(i),a}parseMaterials(e){let t=new Map;if("Material"in Lr.Objects){let n=Lr.Objects.Material;for(let i in n){let r=this.parseMaterial(n[i],e);null!==r&&t.set(parseInt(i),r)}}return t}parseMaterial(e,t){let n=e.id,i=e.attrName,r=e.ShadingModel;if("object"==typeof r&&(r=r.value),!xs.has(n))return null;let a,s=this.parseParameters(e,t,n);switch(r.toLowerCase()){case"phong":a=new na;break;case"lambert":a=new Pu;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',r),a=new na}return a.setValues(s),a.name=i,a}parseParameters(e,t,n){let i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=(new ct).fromArray(e.Diffuse.value).convertSRGBToLinear():e.DiffuseColor&&("Color"===e.DiffuseColor.type||"ColorRGB"===e.DiffuseColor.type)&&(i.color=(new ct).fromArray(e.DiffuseColor.value).convertSRGBToLinear()),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=(new ct).fromArray(e.Emissive.value).convertSRGBToLinear():e.EmissiveColor&&("Color"===e.EmissiveColor.type||"ColorRGB"===e.EmissiveColor.type)&&(i.emissive=(new ct).fromArray(e.EmissiveColor.value).convertSRGBToLinear()),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=(new ct).fromArray(e.Specular.value).convertSRGBToLinear():e.SpecularColor&&"Color"===e.SpecularColor.type&&(i.specular=(new ct).fromArray(e.SpecularColor.value).convertSRGBToLinear());let r=this;return xs.get(n).children.forEach((function(e){let n=e.relationship;switch(n){case"Bump":i.bumpMap=r.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":i.aoMap=r.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=r.getTexture(t,e.ID),void 0!==i.map&&(i.map.colorSpace=tn);break;case"DisplacementColor":i.displacementMap=r.getTexture(t,e.ID);break;case"EmissiveColor":i.emissiveMap=r.getTexture(t,e.ID),void 0!==i.emissiveMap&&(i.emissiveMap.colorSpace=tn);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=r.getTexture(t,e.ID);break;case"ReflectionColor":i.envMap=r.getTexture(t,e.ID),void 0!==i.envMap&&(i.envMap.mapping=fm,i.envMap.colorSpace=tn);break;case"SpecularColor":i.specularMap=r.getTexture(t,e.ID),void 0!==i.specularMap&&(i.specularMap.colorSpace=tn);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=r.getTexture(t,e.ID),i.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",n)}})),i}getTexture(e,t){return"LayeredTexture"in Lr.Objects&&t in Lr.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=xs.get(t).children[0].ID),e.get(t)}parseDeformers(){let e={},t={};if("Deformer"in Lr.Objects){let n=Lr.Objects.Deformer;for(let i in n){let r=n[i],a=xs.get(parseInt(i));if("Skin"===r.attrType){let t=this.parseSkeleton(a,n);t.ID=i,a.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=a.parents[0].ID,e[i]=t}else if("BlendShape"===r.attrType){let e={id:i};e.rawTargets=this.parseMorphTargets(a,n),e.id=i,a.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){let n=[];return e.children.forEach((function(e){let i=t[e.ID];if("Cluster"!==i.attrType)return;let r={ID:e.ID,indices:[],weights:[],transformLink:(new Qe).fromArray(i.TransformLink.a)};"Indexes"in i&&(r.indices=i.Indexes.a,r.weights=i.Weights.a),n.push(r)})),{rawBones:n,bones:[]}}parseMorphTargets(e,t){let n=[];for(let i=0;i1?a=s:s.length>0?a=s[0]:(a=new na({name:_r.DEFAULT_MATERIAL_NAME,color:13421772}),s.push(a)),"color"in r.attributes&&s.forEach((function(e){e.vertexColors=!0})),r.FBX_Deformer?(i=new Mu(r,a),i.normalizeSkinWeights()):i=new xt(r,a),i}createCurve(e,t){let n=e.children.reduce((function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e}),null),i=new Gn({name:_r.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new ur(n,i)}getTransformData(e,t){let n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder="RotationOrder"in t?j0e(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&xs.get(e.ID).children.forEach((function(t){if("LookAtProperty"===t.relationship){let n=Lr.Objects.Model[t.ID];if("Lcl_Translation"in n){let t=n.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),_o.add(e.target)):e.lookAt((new O).fromArray(t))}}}))}bindSkeleton(e,t,n){let i=this.parsePoseNodes();for(let r in e){let a=e[r];xs.get(parseInt(a.ID)).parents.forEach((function(e){if(t.has(e.ID)){let t=e.ID;xs.get(t).parents.forEach((function(e){n.has(e.ID)&&n.get(e.ID).bind(new Rl(a.bones),i[e.ID])}))}}))}}parsePoseNodes(){let e={};if("Pose"in Lr.Objects){let t=Lr.Objects.Pose;for(let n in t)if("BindPose"===t[n].attrType&&t[n].NbPoseNodes>0){let i=t[n].PoseNode;Array.isArray(i)?i.forEach((function(t){e[t.Node]=(new Qe).fromArray(t.Matrix.a)})):e[i.Node]=(new Qe).fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in Lr&&"AmbientColor"in Lr.GlobalSettings){let e=Lr.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(0!==t||0!==n||0!==i){let e=new ct(t,n,i).convertSRGBToLinear();_o.add(new Pl(e,1))}}}},J6=class{constructor(){this.negativeMaterialIndices=!1}parse(e){let t=new Map;if("Geometry"in Lr.Objects){let n=Lr.Objects.Geometry;for(let i in n){let r=xs.get(parseInt(i)),a=this.parseGeometry(r,n[i],e);t.set(parseInt(i),a)}}return!0===this.negativeMaterialIndices&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){let i=n.skeletons,r=[],a=e.parents.map((function(e){return Lr.Objects.Model[e.ID]}));if(0===a.length)return;let s=e.children.reduce((function(e,t){return void 0!==i[t.ID]&&(e=i[t.ID]),e}),null);e.children.forEach((function(e){void 0!==n.morphTargets[e.ID]&&r.push(n.morphTargets[e.ID])}));let o=a[0],l={};"RotationOrder"in o&&(l.eulerOrder=j0e(o.RotationOrder.value)),"InheritType"in o&&(l.inheritType=parseInt(o.InheritType.value)),"GeometricTranslation"in o&&(l.translation=o.GeometricTranslation.value),"GeometricRotation"in o&&(l.rotation=o.GeometricRotation.value),"GeometricScaling"in o&&(l.scale=o.GeometricScaling.value);let h=W0e(l);return this.genGeometry(t,s,r,h)}genGeometry(e,t,n,i){let r=new Dt;e.attrName&&(r.name=e.attrName);let a=this.parseGeoNode(e,t),s=this.genBuffers(a),o=new Bt(s.vertex,3);if(o.applyMatrix4(i),r.setAttribute("position",o),s.colors.length>0&&r.setAttribute("color",new Bt(s.colors,3)),t&&(r.setAttribute("skinIndex",new pm(s.weightsIndices,4)),r.setAttribute("skinWeight",new Bt(s.vertexWeights,4)),r.FBX_Deformer=t),s.normal.length>0){let e=(new Ln).getNormalMatrix(i),t=new Bt(s.normal,3);t.applyNormalMatrix(e),r.setAttribute("normal",t)}if(s.uvs.forEach((function(e,t){let n=0===t?"uv":`uv${t}`;r.setAttribute(n,new Bt(s.uvs[t],2))})),a.material&&"AllSame"!==a.material.mappingType){let e=s.materialIndex[0],t=0;if(s.materialIndex.forEach((function(n,i){n!==e&&(r.addGroup(t,i-t,e),e=n,t=i)})),r.groups.length>0){let t=r.groups[r.groups.length-1],n=t.start+t.count;n!==s.materialIndex.length&&r.addGroup(n,s.materialIndex.length-n,e)}0===r.groups.length&&r.addGroup(0,s.materialIndex.length,s.materialIndex[0])}return this.addMorphTargets(r,e,n,i),r}parseGeoNode(e,t){let n={};if(n.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],n.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return n.weightTable={},null!==t&&(n.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(i,r){void 0===n.weightTable[i]&&(n.weightTable[i]=[]),n.weightTable[i].push({id:t,weight:e.weights[r]})}))}))),n}genBuffers(e){let t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]},n=0,i=0,r=!1,a=[],s=[],o=[],l=[],h=[],c=[],u=this;return e.vertexIndices.forEach((function(d,p){let f,m=!1;d<0&&(d^=-1,m=!0);let g=[],v=[];if(a.push(3*d,3*d+1,3*d+2),e.color){let t=sP(p,n,d,e.color);o.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[d]&&e.weightTable[d].forEach((function(e){v.push(e.weight),g.push(e.id)})),v.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);let e=[0,0,0,0],t=[0,0,0,0];v.forEach((function(n,i){let r=n,a=g[i];t.forEach((function(t,n,i){if(r>t){i[n]=r,r=t;let s=e[n];e[n]=a,a=s}}))})),g=e,v=t}for(;v.length<4;)v.push(0),g.push(0);for(let e=0;e<4;++e)h.push(v[e]),c.push(g[e])}if(e.normal){let t=sP(p,n,d,e.normal);s.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(f=sP(p,n,d,e.material)[0],f<0&&(u.negativeMaterialIndices=!0,f=0)),e.uv&&e.uv.forEach((function(e,t){let i=sP(p,n,d,e);void 0===l[t]&&(l[t]=[]),l[t].push(i[0]),l[t].push(i[1])})),i++,m&&(i>4&&console.warn("THREE.FBXLoader: Polygons with more than four sides are not supported. Make sure to triangulate the geometry during export."),u.genFace(t,e,a,f,s,o,l,h,c,i),n++,i=0,a=[],s=[],o=[],l=[],h=[],c=[])})),t}genFace(e,t,n,i,r,a,s,o,l,h){for(let c=2;c1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");let a=e.get(r[0].ID);n[i]={name:t[i].attrName,layer:a}}return n}addClip(e){let t=[],n=this;return e.layer.forEach((function(e){t=t.concat(n.generateTracks(e))})),new fo(e.name,-1,t)}generateTracks(e){let t=[],n=new O,i=new hr,r=new O;if(e.transform&&e.transform.decompose(n,i,r),n=n.toArray(),i=(new Xn).setFromQuaternion(i,e.eulerOrder).toArray(),r=r.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){let i=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");void 0!==i&&t.push(i)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){let n=this.generateRotationTrack(e.modelName,e.R.curves,i,e.preRotation,e.postRotation,e.eulerOrder);void 0!==n&&t.push(n)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){let n=this.generateVectorTrack(e.modelName,e.S.curves,r,"scale");void 0!==n&&t.push(n)}if(void 0!==e.DeformPercent){let n=this.generateMorphTrack(e);void 0!==n&&t.push(n)}return t}generateVectorTrack(e,t,n,i){let r=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(r,t,n);return new ho(e+"."+i,r,a)}generateRotationTrack(e,t,n,i,r,a){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(An.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(An.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(An.degToRad));let s=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(s,t,n);void 0!==i&&((i=i.map(An.degToRad)).push(a),i=(new Xn).fromArray(i),i=(new hr).setFromEuler(i)),void 0!==r&&((r=r.map(An.degToRad)).push(a),r=(new Xn).fromArray(r),r=(new hr).setFromEuler(r).invert());let l=new hr,h=new Xn,c=[];for(let u=0;u1){let e=1,n=t[0];for(let i=1;i=180){let a=r/180,s=i/a,o=n+s,l=e.times[t-1],h=(e.times[t]-l)/a,c=l+h,u=[],d=[];for(;c1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),r=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===i&&","===r&&(r=n.replace(/"/g,"").replace(/,$/,"").trim());let a=this.getCurrentNode();if("Properties70"!==a.name){if("C"===i){let e=r.split(",").slice(1),t=parseInt(e[0]),n=parseInt(e[1]),s=r.split(",").slice(3);s=s.map((function(e){return e.trim().replace(/^"/,"")})),i="connections",r=[t,n],nvt(r,s),void 0===a[i]&&(a[i]=[])}"Node"===i&&(a.id=r),i in a&&Array.isArray(a[i])?a[i].push(r):"a"!==i?a[i]=r:a.a=r,this.setCurrentProp(a,i),"a"===i&&","!==r.slice(-1)&&(a.a=Z6(r))}else this.parseNodeSpecialProperty(e,i,r)}parseNodePropertyContinued(e){let t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=Z6(t.a))}parseNodeSpecialProperty(e,t,n){let i=n.split('",').map((function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")})),r=i[0],a=i[1],s=i[2],o=i[3],l=i[4];switch(a){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=Z6(l)}this.getPrevNode()[r]={type:a,type2:s,flag:o,value:l},this.setCurrentProp(this.getPrevNode(),r)}},t4=class{parse(e){let t=new oP(e);t.skip(23);let n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);let i=new lP;for(;!this.endOfContent(t);){let e=this.parseNode(t,n);null!==e&&i.add(e.name,e)}return i}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){let n={},i=t>=7500?e.getUint64():e.getUint32(),r=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();let a=e.getUint8(),s=e.getString(a);if(0===i)return null;let o=[];for(let u=0;u0?o[0]:"",h=o.length>1?o[1]:"",c=o.length>2?o[2]:"";for(n.singleProperty=1===r&&e.getOffset()===i;i>e.getOffset();){let i=this.parseNode(e,t);null!==i&&this.parseSubNode(s,n,i)}return n.propertyList=o,"number"==typeof l&&(n.id=l),""!==h&&(n.attrName=h),""!==c&&(n.attrType=c),""!==s&&(n.name=s),n}parseSubNode(e,t,n){if(!0===n.singleProperty){let e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if("Connections"===e&&"C"===n.name){let e=[];n.propertyList.forEach((function(t,n){0!==n&&e.push(t)})),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===n.name)Object.keys(n).forEach((function(e){t[e]=n[e]}));else if("Properties70"===e&&"P"===n.name){let e,i=n.propertyList[0],r=n.propertyList[1],a=n.propertyList[2],s=n.propertyList[3];0===i.indexOf("Lcl ")&&(i=i.replace("Lcl ","Lcl_")),0===r.indexOf("Lcl ")&&(r=r.replace("Lcl ","Lcl_")),e="Color"===r||"ColorRGB"===r||"Vector"===r||"Vector3D"===r||0===r.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[i]={type:r,type2:a,flag:s,value:e}}else void 0===t[n.name]?"number"==typeof n.id?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:"PoseNode"===n.name?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):void 0===t[n.name][n.id]&&(t[n.name][n.id]=n)}parseProperty(e){let t,n=e.getString(1);switch(n){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return t=e.getUint32(),e.getArrayBuffer(t);case"S":return t=e.getUint32(),e.getString(t);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":let i=e.getUint32(),r=e.getUint32(),a=e.getUint32();if(0===r)switch(n){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}let s=U0e(new Uint8Array(e.getArrayBuffer(a))),o=new oP(s.buffer);switch(n){case"b":case"c":return o.getBooleanArray(i);case"d":return o.getFloat64Array(i);case"f":return o.getFloat32Array(i);case"i":return o.getInt32Array(i);case"l":return o.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+n)}}},oP=class{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(e){let t=[];for(let n=0;n=0&&(n=new Uint8Array(this.dv.buffer,t,i)),this._textDecoder.decode(n)}},lP=class{add(e,t){this[e]=t}};function J0t(e){return e.byteLength>=21&&"Kaydara FBX Binary \0"===X0e(e,0,21)}function Q0t(e){let t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"],n=0;function i(t){let i=e[t-1];return e=e.slice(n+t),n++,i}for(let r=0;r=2.0 are supported.")));let l=new A4(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h=0&&void 0===s[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}l.setExtensions(a),l.setPlugins(s),l.parse(n,i)}parseAsync(e,t){let n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}};function ivt(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}var Xr={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},s4=class{constructor(e){this.parser=e,this.name=Xr.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,a)}},v4=class{constructor(e){this.parser=e,this.name=Xr.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let a=r.extensions[t],s=i.images[a.source],o=n.textureLoader;if(s.uri){let e=n.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,a.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}},y4=class{constructor(e){this.parser=e,this.name=Xr.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let a=r.extensions[t],s=i.images[a.source],o=n.textureLoader;if(s.uri){let e=n.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,a.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}},x4=class{constructor(e){this.name=Xr.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(t){let n=e.byteOffset||0,i=e.byteLength||0,a=e.count,s=e.byteStride,o=new Uint8Array(t,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(a,s,o,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){let t=new ArrayBuffer(a*s);return r.decodeGltfBuffer(new Uint8Array(t),a,s,o,e.mode,e.filter),t}))}))}return null}},b4=class{constructor(e){this.name=Xr.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;let i=t.meshes[n.mesh];for(let o of i.primitives)if(o.mode!==jl.TRIANGLES&&o.mode!==jl.TRIANGLE_STRIP&&o.mode!==jl.TRIANGLE_FAN&&void 0!==o.mode)return null;let r=n.extensions[this.name].attributes,a=[],s={};for(let o in r)a.push(this.parser.getDependency("accessor",r[o]).then((e=>(s[o]=e,s[o]))));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then((e=>{let t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,r=[];for(let a of n){let e=new Qe,t=new O,n=new hr,o=new O(1,1,1),l=new Pi(a.geometry,a.material,i);for(let r=0;r0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":"image/png"}var dvt=new Qe,A4=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new ivt,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=!1,r=-1;"undefined"!=typeof navigator&&(n=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=navigator.userAgent.indexOf("Firefox")>-1,r=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||i&&r<98?this.textureLoader=new Rs(this.options.manager):this.textureLoader=new Lb(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Kr(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){let a={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};tg(r,a,i),Xf(a,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(a)}))).then((function(){e(a)}))})).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i{let n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(let[i,a]of e.children.entries())r(a,t.children[i])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&a.setY(t,u[e*o+1]),o>=3&&a.setZ(t,u[e*o+2]),o>=4&&a.setW(t,u[e*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return a}))}loadTexture(e){let t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i],a=this.textureLoader;if(r.uri){let e=n.manager.getHandler(r.uri);null!==e&&(a=e)}return this.loadTextureImage(e,i,a)}loadTextureImage(e,t,n){let i=this,r=this.json,a=r.textures[e],s=r.images[t],o=(s.uri||s.bufferView)+":"+a.sampler;if(this.textureCache[o])return this.textureCache[o];let l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=a.name||s.name||"",""===t.name&&"string"==typeof s.uri&&!1===s.uri.startsWith("data:image/")&&(t.name=s.uri);let n=(r.samplers||{})[a.sampler]||{};return t.magFilter=$0e[n.magFilter]||Ir,t.minFilter=$0e[n.minFilter]||Ua,t.wrapS=Z0e[n.wrapS]||Ci,t.wrapT=Z0e[n.wrapT]||Ci,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){let n=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));let r=n.images[e],a=self.URL||self.webkitURL,s=r.uri||"",o=!1;if(void 0!==r.bufferView)s=this.getDependency("bufferView",r.bufferView).then((function(e){o=!0;let t=new Blob([e],{type:r.mimeType});return s=a.createObjectURL(t),s}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(s).then((function(e){return new Promise((function(n,r){let a=n;!0===t.isImageBitmapLoader&&(a=function(e){let t=new qr(e);t.needsUpdate=!0,n(t)}),t.load(ra.resolveURL(e,i.path),a,void 0,r)}))})).then((function(e){return!0===o&&a.revokeObjectURL(s),e.userData.mimeType=r.mimeType||hvt(r.uri),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",s),e}));return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then((function(a){if(!a)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((a=a.clone()).channel=n.texCoord),r.extensions[Xr.KHR_TEXTURE_TRANSFORM]){let e=void 0!==n.extensions?n.extensions[Xr.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=r.associations.get(a);a=r.extensions[Xr.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),r.associations.set(a,t)}}return void 0!==i&&(a.colorSpace=i),e[t]=a,a}))}assignFinalMaterial(e){let t=e.geometry,n=e.material,i=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,a=void 0===t.attributes.normal;if(e.isPoints){let e="PointsMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new xi,vr.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e="LineBasicMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new Gn,vr.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(i||r||a){let e="ClonedMaterial:"+n.uuid+":";i&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),a&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),a&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return hf}loadMaterial(e){let t,n=this,i=this.json,r=this.extensions,a=i.materials[e],s={},o=[];if((a.extensions||{})[Xr.KHR_MATERIALS_UNLIT]){let e=r[Xr.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),o.push(e.extendParams(s,a,n))}else{let i=a.pbrMetallicRoughness||{};if(s.color=new ct(1,1,1),s.opacity=1,Array.isArray(i.baseColorFactor)){let e=i.baseColorFactor;s.color.fromArray(e),s.opacity=e[3]}void 0!==i.baseColorTexture&&o.push(n.assignTexture(s,"map",i.baseColorTexture,tn)),s.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,s.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(o.push(n.assignTexture(s,"metalnessMap",i.metallicRoughnessTexture)),o.push(n.assignTexture(s,"roughnessMap",i.metallicRoughnessTexture))),t=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),o.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)}))))}!0===a.doubleSided&&(s.side=Er);let l=a.alphaMode||r4.OPAQUE;if(l===r4.BLEND?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,l===r4.MASK&&(s.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&t!==ln&&(o.push(n.assignTexture(s,"normalMap",a.normalTexture)),s.normalScale=new be(1,1),void 0!==a.normalTexture.scale)){let e=a.normalTexture.scale;s.normalScale.set(e,e)}return void 0!==a.occlusionTexture&&t!==ln&&(o.push(n.assignTexture(s,"aoMap",a.occlusionTexture)),void 0!==a.occlusionTexture.strength&&(s.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&t!==ln&&(s.emissive=(new ct).fromArray(a.emissiveFactor)),void 0!==a.emissiveTexture&&t!==ln&&o.push(n.assignTexture(s,"emissiveMap",a.emissiveTexture,tn)),Promise.all(o).then((function(){let i=new t(s);return a.name&&(i.name=a.name),Xf(i,a),n.associations.set(i,{materials:e}),a.extensions&&tg(r,i,a),i}))}createUniqueName(e){let t=Jn.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(e){return n[Xr.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return K0e(n,e,t)}))}let a=[];for(let s=0,o=e.length;s0&&cvt(n,r),n.name=t.createUniqueName(r.name||"mesh_"+e),Xf(n,r),u.extensions&&tg(i,n,u),t.assignFinalMaterial(n),l.push(n)}for(let i=0,r=l.length;i1?new er:1===t.length?t[0]:new on,s!==t[0])for(let e=0,n=t.length;e{let t=new Map;for(let[n,r]of i.associations)(n instanceof vr||n instanceof qr)&&t.set(n,r);return e.traverse((e=>{let n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}_createAnimationTracks(e,t,n,i,r){let a,s=[],o=e.name?e.name:e.uuid,l=[];switch(jf[r.path]===jf.weights?e.traverse((function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)})):l.push(o),jf[r.path]){case jf.weights:a=Cl;break;case jf.rotation:a=Ga;break;case jf.position:case jf.scale:default:switch(n.itemSize){case 1:a=Cl;break;case 2:case 3:a=ho}}let h=void 0!==i.interpolation?avt[i.interpolation]:wu,c=this._getArrayFromAccessor(n);for(let u=0,d=l.length;u=0?e.substring(0,t):e;s=s.toLowerCase();let l=t>=0?e.substring(t+1):"";if(l=l.trim(),"newmtl"===s)i={name:l},a[l]=i;else if("ka"===s||"kd"===s||"ks"===s||"ke"===s){let e=l.split(r,3);i[s]=[parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2])]}else i[s]=l}let s=new C4(this.resourcePath||t,this.materialOptions);return s.setCrossOrigin(this.crossOrigin),s.setManager(this.manager),s.setMaterials(a),s}},C4=class{constructor(e="",t={}){this.baseUrl=e,this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=void 0!==this.options.side?this.options.side:ci,this.wrap=void 0!==this.options.wrap?this.options.wrap:Ci}setCrossOrigin(e){return this.crossOrigin=e,this}setManager(e){this.manager=e}setMaterials(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(e){if(!this.options)return e;let t={};for(let n in e){let i=e[n],r={};t[n]=r;for(let e in i){let t=!0,n=i[e],a=e.toLowerCase();switch(a){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(n=[n[0]/255,n[1]/255,n[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===n[0]&&0===n[1]&&0===n[2]&&(t=!1)}t&&(r[a]=n)}}return t}preload(){for(let e in this.materialsInfo)this.create(e)}getIndex(e){return this.nameLookup[e]}getAsArray(){let e=0;for(let t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray}create(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]}createMaterial_(e){let t=this,n=this.materialsInfo[e],i={name:e,side:this.side};function r(e,n){if(i[e])return;let r=t.getTextureParams(n,i),a=t.loadTexture(function(e,t){return"string"!=typeof t||""===t?"":/^https?:\/\//i.test(t)?t:e+t}(t.baseUrl,r.url));a.repeat.copy(r.scale),a.offset.copy(r.offset),a.wrapS=t.wrap,a.wrapT=t.wrap,("map"===e||"emissiveMap"===e)&&(a.colorSpace=tn),i[e]=a}for(let a in n){let e,t=n[a];if(""!==t)switch(a.toLowerCase()){case"kd":i.color=(new ct).fromArray(t).convertSRGBToLinear();break;case"ks":i.specular=(new ct).fromArray(t).convertSRGBToLinear();break;case"ke":i.emissive=(new ct).fromArray(t).convertSRGBToLinear();break;case"map_kd":r("map",t);break;case"map_ks":r("specularMap",t);break;case"map_ke":r("emissiveMap",t);break;case"norm":r("normalMap",t);break;case"map_bump":case"bump":r("bumpMap",t);break;case"map_d":r("alphaMap",t),i.transparent=!0;break;case"ns":i.shininess=parseFloat(t);break;case"d":e=parseFloat(t),e<1&&(i.opacity=e,i.transparent=!0);break;case"tr":e=parseFloat(t),this.options&&this.options.invertTrProperty&&(e=1-e),e>0&&(i.opacity=1-e,i.transparent=!0)}}return this.materials[e]=new na(i),this.materials[e]}getTextureParams(e,t){let n,i={scale:new be(1,1),offset:new be(0,0)},r=e.split(/\s+/);return n=r.indexOf("-bm"),n>=0&&(t.bumpScale=parseFloat(r[n+1]),r.splice(n,2)),n=r.indexOf("-s"),n>=0&&(i.scale.set(parseFloat(r[n+1]),parseFloat(r[n+2])),r.splice(n,4)),n=r.indexOf("-o"),n>=0&&(i.offset.set(parseFloat(r[n+1]),parseFloat(r[n+2])),r.splice(n,4)),i.url=r.join(" ").trim(),i}loadTexture(e,t,n,i,r){let a=void 0!==this.manager?this.manager:mo,s=a.getHandler(e);null===s&&(s=new Rs(a)),s.setCrossOrigin&&s.setCrossOrigin(this.crossOrigin);let o=s.load(e,n,i,r);return void 0!==t&&(o.mapping=t),o}},pvt=/^[og]\s*(.+)?/,mvt=/^mtllib /,gvt=/^usemtl /,vvt=/^usemap /,Q0e=/\s+/,eve=new O,P4=new O,tve=new O,nve=new O,Xl=new O,hP=new ct;function yvt(){let e={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&!1===this.object.fromDeclaration)return this.object.name=e,void(this.object.fromDeclaration=!1!==t);let n=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;if(this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:!1!==t,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(e,t){let n=this._finalize(!1);n&&(n.inherited||n.groupCount<=0)&&this.materials.splice(n.index,1);let i={index:this.materials.length,name:e||"",mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:"",smooth:void 0!==n?n.smooth:this.smooth,groupStart:void 0!==n?n.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){let t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(i),i},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){let t=this.currentMaterial();if(t&&-1===t.groupEnd&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(let n=this.materials.length-1;n>=0;n--)this.materials[n].groupCount<=0&&this.materials.splice(n,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},n&&n.name&&"function"==typeof n.clone){let e=n.clone(0);e.inherited=!0,this.object.materials.push(e)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){let n=parseInt(e,10);return 3*(n>=0?n-1:n+t/3)},parseNormalIndex:function(e,t){let n=parseInt(e,10);return 3*(n>=0?n-1:n+t/3)},parseUVIndex:function(e,t){let n=parseInt(e,10);return 2*(n>=0?n-1:n+t/2)},addVertex:function(e,t,n){let i=this.vertices,r=this.object.geometry.vertices;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addVertexPoint:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){let i=this.normals,r=this.object.geometry.normals;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addFaceNormal:function(e,t,n){let i=this.vertices,r=this.object.geometry.normals;eve.fromArray(i,e),P4.fromArray(i,t),tve.fromArray(i,n),Xl.subVectors(tve,P4),nve.subVectors(eve,P4),Xl.cross(nve),Xl.normalize(),r.push(Xl.x,Xl.y,Xl.z),r.push(Xl.x,Xl.y,Xl.z),r.push(Xl.x,Xl.y,Xl.z)},addColor:function(e,t,n){let i=this.colors,r=this.object.geometry.colors;void 0!==i[e]&&r.push(i[e+0],i[e+1],i[e+2]),void 0!==i[t]&&r.push(i[t+0],i[t+1],i[t+2]),void 0!==i[n]&&r.push(i[n+0],i[n+1],i[n+2])},addUV:function(e,t,n){let i=this.uvs,r=this.object.geometry.uvs;r.push(i[e+0],i[e+1]),r.push(i[t+0],i[t+1]),r.push(i[n+0],i[n+1])},addDefaultUV:function(){let e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){let t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,i,r,a,s,o,l){let h=this.vertices.length,c=this.parseVertexIndex(e,h),u=this.parseVertexIndex(t,h),d=this.parseVertexIndex(n,h);if(this.addVertex(c,u,d),this.addColor(c,u,d),void 0!==s&&""!==s){let e=this.normals.length;c=this.parseNormalIndex(s,e),u=this.parseNormalIndex(o,e),d=this.parseNormalIndex(l,e),this.addNormal(c,u,d)}else this.addFaceNormal(c,u,d);if(void 0!==i&&""!==i){let e=this.uvs.length;c=this.parseUVIndex(i,e),u=this.parseUVIndex(r,e),d=this.parseUVIndex(a,e),this.addUV(c,u,d),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";let t=this.vertices.length;for(let n=0,i=e.length;n=7?(hP.setRGB(parseFloat(n[4]),parseFloat(n[5]),parseFloat(n[6])).convertSRGBToLinear(),t.colors.push(hP.r,hP.g,hP.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));break;case"vt":t.uvs.push(parseFloat(n[1]),parseFloat(n[2]))}}else if("f"===r){let n=e.slice(1).trim().split(Q0e),i=[];for(let e=0,t=n.length;e0){let e=t.split("/");i.push(e)}}let r=i[0];for(let e=1,a=i.length-1;e1){let e=i[1].trim().toLowerCase();t.object.smooth="0"!==e&&"off"!==e}else t.object.smooth=!0;let n=t.object.currentMaterial();n&&(n.smooth=t.object.smooth)}else{if("\0"===e)continue;console.warn('THREE.OBJLoader: Unexpected line: "'+e+'"')}}t.finalize();let r=new er;if(r.materialLibraries=[].concat(t.materialLibraries),1==!(1===t.objects.length&&0===t.objects[0].geometry.vertices.length))for(let a=0,s=t.objects.length;a0&&h.setAttribute("normal",new Bt(n.normals,3)),n.colors.length>0&&(l=!0,h.setAttribute("color",new Bt(n.colors,3))),!0===n.hasUVIndices&&h.setAttribute("uv",new Bt(n.uvs,2));let c,u=[];for(let r=0,a=i.length;r1){for(let e=0,t=i.length;e0){let e=new xi({size:1,sizeAttenuation:!1}),n=new Dt;n.setAttribute("position",new Bt(t.vertices,3)),t.colors.length>0&&void 0!==t.colors[0]&&(n.setAttribute("color",new Bt(t.colors,3)),e.vertexColors=!0);let i=new ii(n,e);r.add(i)}return r}},To=new ct,fP=class extends _r{constructor(e){super(e),this.propertyNameMapping={},this.customPropertyMapping={}}load(e,t,n,i){let r=this,a=new Kr(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{t(r.parse(n))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}setPropertyNameMapping(e){this.propertyNameMapping=e}setCustomPropertyNameMapping(e){this.customPropertyMapping=e}parse(e){function t(e,t=0){let n="",i=/^ply([\s\S]*)end_header(\r\n|\r|\n)/.exec(e);null!==i&&(n=i[1]);let r,a={comments:[],elements:[],headerLength:t,objInfo:""},s=n.split(/\r\n|\r|\n/);function o(e,t){let n={type:e[0]};return"list"===n.type?(n.name=e[3],n.countType=e[1],n.itemType=e[2]):n.name=e[1],n.name in t&&(n.name=t[n.name]),n}for(let l=0;le.name));function n(e){for(let n=0,i=e.length;n0&&t.setIndex(e.indices),t.setAttribute("position",new Bt(e.vertices,3)),e.normals.length>0&&t.setAttribute("normal",new Bt(e.normals,3)),e.uvs.length>0&&t.setAttribute("uv",new Bt(e.uvs,2)),e.colors.length>0&&t.setAttribute("color",new Bt(e.colors,3)),(e.faceVertexUvs.length>0||e.faceVertexColors.length>0)&&(t=t.toNonIndexed(),e.faceVertexUvs.length>0&&t.setAttribute("uv",new Bt(e.faceVertexUvs,2)),e.faceVertexColors.length>0&&t.setAttribute("color",new Bt(e.faceVertexColors,3)));for(let n of Object.keys(d.customPropertyMapping))e[n].length>0&&t.setAttribute(n,new Bt(e[n],d.customPropertyMapping[n].length));return t.computeBoundingSphere(),t}function l(e,t,n,i){if("vertex"===t){e.vertices.push(n[i.attrX],n[i.attrY],n[i.attrZ]),null!==i.attrNX&&null!==i.attrNY&&null!==i.attrNZ&&e.normals.push(n[i.attrNX],n[i.attrNY],n[i.attrNZ]),null!==i.attrS&&null!==i.attrT&&e.uvs.push(n[i.attrS],n[i.attrT]),null!==i.attrR&&null!==i.attrG&&null!==i.attrB&&(To.setRGB(n[i.attrR]/255,n[i.attrG]/255,n[i.attrB]/255).convertSRGBToLinear(),e.colors.push(To.r,To.g,To.b));for(let t of Object.keys(d.customPropertyMapping))for(let i of d.customPropertyMapping[t])e[t].push(n[i])}else if("face"===t){let t=n.vertex_indices||n.vertex_index,r=n.texcoord;3===t.length?(e.indices.push(t[0],t[1],t[2]),r&&6===r.length&&(e.faceVertexUvs.push(r[0],r[1]),e.faceVertexUvs.push(r[2],r[3]),e.faceVertexUvs.push(r[4],r[5]))):4===t.length&&(e.indices.push(t[0],t[1],t[3]),e.indices.push(t[1],t[2],t[3])),null!==i.attrR&&null!==i.attrG&&null!==i.attrB&&(To.setRGB(n[i.attrR]/255,n[i.attrG]/255,n[i.attrB]/255).convertSRGBToLinear(),e.faceVertexColors.push(To.r,To.g,To.b),e.faceVertexColors.push(To.r,To.g,To.b),e.faceVertexColors.push(To.r,To.g,To.b))}}function h(e,t){let n={},i=0;for(let r=0;re.getInt8(t),size:1};case"uint8":case"uchar":return{read:t=>e.getUint8(t),size:1};case"int16":case"short":return{read:t=>e.getInt16(t,n),size:2};case"uint16":case"ushort":return{read:t=>e.getUint16(t,n),size:2};case"int32":case"int":return{read:t=>e.getInt32(t,n),size:4};case"uint32":case"uint":return{read:t=>e.getUint32(t,n),size:4};case"float32":case"float":return{read:t=>e.getFloat32(t,n),size:4};case"float64":case"double":return{read:t=>e.getFloat64(t,n),size:8}}}for(let r=0,a=e.length;r=this.arr.length}next(){return this.arr[this.i++]}},pP=class extends _r{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new Kr(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{t(r.parse(n))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e){function t(e,t,n){for(let i=0,r=e.length;i>5&31)/31,i=(r>>10&31)/31)}for(let a=1;a<=3;a++){let s=e+12*a,o=3*g*3+3*(a-1);p[o]=h.getFloat32(s,!0),p[o+1]=h.getFloat32(s+4,!0),p[o+2]=h.getFloat32(s+8,!0),f[o]=l,f[o+1]=c,f[o+2]=d,u&&(m.set(t,n,i).convertSRGBToLinear(),r[o]=m.r,r[o+1]=m.g,r[o+2]=m.b)}}return d.setAttribute("position",new gn(p,3)),d.setAttribute("normal",new gn(f,3)),u&&(d.setAttribute("color",new gn(r,3)),d.hasColors=!0,d.alpha=l),d}(n):function(e){let t,n=new Dt,i=/solid([\s\S]*?)endsolid/g,r=/facet([\s\S]*?)endfacet/g,a=0,s=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,o=new RegExp("vertex"+s+s+s,"g"),l=new RegExp("normal"+s+s+s,"g"),h=[],c=[],u=new O,d=0,p=0,f=0;for(;null!==(t=i.exec(e));){p=f;let e=t[0];for(;null!==(t=r.exec(e));){let e=0,n=0,i=t[0];for(;null!==(t=l.exec(i));)u.x=parseFloat(t[1]),u.y=parseFloat(t[2]),u.z=parseFloat(t[3]),n++;for(;null!==(t=o.exec(i));)h.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])),c.push(u.x,u.y,u.z),e++,f++;1!==n&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+a),3!==e&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+a),a++}let i=p,s=f-p;n.addGroup(i,s,d),d++}return n.setAttribute("position",new Bt(h,3)),n.setAttribute("normal",new Bt(c,3)),n}("string"!=typeof(i=e)?(new TextDecoder).decode(i):i);var i}},ng=class{constructor(e){this.buffer=e,this.u8=new Uint8Array(e)}getBit(e){var t=7&e;return(this.u8[e>>3]&128>>t)>>7-t}setBit(e,t){var n=e>>3,i=this.u8[n],r=7&e;this.u8[n]=t?i|128>>r:i&~(128>>r)}getInt12(e){var t=e/8|0,n=this.u8[t],i=this.u8[t+1],r=this.u8[t+2],a=e%8,s=8-a,o=Math.min(12-s,8);return(((n&=~(255<>12-a)-2048}setInt12(e,t){var n=e/8|0,i=e%8,r=(t+=2048)<<12-i,a=(16711680&r)>>16,s=(65280&r)>>8,o=255&r,l=8-i,h=Math.min(12-l,8),c=Math.max(12-l-h,0),u=255<>8-(2-r))))<<8)+(i&=255<<8-Math.max(6-a,0))>>10-r)-32}setInt6(e,t){var n=e/8|0,i=e%8,r=(t+=32)<<10-i,a=(65280&r)>>8,s=255&r,o=8-i,l=Math.max(6-o,0),h=(255<>8-(2-i));this.u8[n]=(this.u8[n]&h)+a;var c=~(255<<8-l);this.u8[n+1]=(this.u8[n+1]&c)+s}test(){var e,t,n=new ArrayBuffer(3),i=new ng(n);for(t=0;t<12;t++)for(e=-2048;e<2048;e++)if(i.setInt12(t,e),i.getInt12(t)!=e){console.log("12-bit prob at",t,e),console.log("expected",e,"got",i.getInt12(t));break}for(t=0;t<18;t++)for(e=-32;e<32;e++)if(i.setInt6(t,e),i.getInt6(t)!=e){console.log("6-bit prob at",t,e),console.log("expected",e,"got",i.getInt6(t));break}return i}},rve=(e=>(e[e.NULL=0]="NULL",e[e.POINT=1]="POINT",e[e.POLYLINE=3]="POLYLINE",e[e.POLYGON=5]="POLYGON",e))(rve||{}),mP=class{parse(e){var t={},n=new DataView(e),i=0;if(t.fileCode=n.getInt32(i,!1),9994!=t.fileCode)throw new Error("Unknown file code: "+t.fileCode);for(i+=24,t.wordLength=n.getInt32(i,!1),t.byteLength=2*t.wordLength,i+=4,t.version=n.getInt32(i,!0),i+=4,t.shapeType=n.getInt32(i,!0),i+=4,t.minX=n.getFloat64(i,!0),t.minY=n.getFloat64(i+8,!0),t.maxX=n.getFloat64(i+16,!0),t.maxY=n.getFloat64(i+24,!0),t.minZ=n.getFloat64(i+32,!0),t.maxZ=n.getFloat64(i+40,!0),t.minM=n.getFloat64(i+48,!0),t.maxM=n.getFloat64(i+56,!0),i+=64,t.records=[];ir.push(...e)));let a=new Dt;a.setFromPoints(e),a.setIndex(r),t.push(a);let s=new Dt;e.length>2&&!e[0].equals(e[e.length-1])&&e.push(e[0]),s.setFromPoints(e),n.push(s)}else{let t=new Dt;t.setFromPoints(e),n.push(t)}}}var d=new on;for(i=0;i1023||Math.abs(a-e[o+1])>1023?(n.push(i),s+=1,i=[],r=e[o],a=e[o+1],i.push(r,a),s+=4,o++):(i.push((e[o]-r)/8,(e[o+1]-a)/8),r+=8*((e[o]-r)/8|0),a+=8*((e[o+1]-a)/8|0),s+=2,o++):(n.push(i),t.push(n),n=[],i=[],s+=3);return this.storeDeltas(s,t)}deltaEncode6(e){var t=[],n=[],i=[],r=0,a=0,s=0,o=0;for(s=0;s31||Math.abs(a-e[s+1])>31?(n.push(i),o+=1,i=[],r=e[s],a=e[s+1],i.push(r,a),o+=4,s++):(i.push(e[s]-r,e[s+1]-a),r+=e[s]-r,a+=e[s+1]-a,o+=2,s++):(n.push(i),t.push(n),n=[],i=[],o+=3);return this.storeDeltas6(o,t)}storeDeltas(e,t){for(var n=new ArrayBuffer(e),i=new DataView(n),r=0,a=0;a{this.updateProgress(n,50);let e=(new mP).parse(r.response),i=(new gP).createModel(e);this.updateProgress(n,99),t(i)},r.onerror=i,r.open("GET",e),r.send(null)}))}updateProgress(e,t){e&&e(new ProgressEvent("progress",{lengthComputable:!0,loaded:t,total:100}))}},L4=class{constructor(e){this.manager=e}loadLocalModel(e,t,n){return ft(this,null,(function*(){let i=t.toLowerCase();return i.endsWith("fbx")?this.loadFbx(e,n):i.endsWith("obj")?this.loadObj(e,n):i.endsWith("stl")?this.loadStl(e,n):i.endsWith("ifc")?(se.warn("[LoadingHelper] IFC is not supported directly since three.js r150!"),Promise.reject("Not supported!")):i.endsWith("shp")?this.loadShp(e,n):i.endsWith("dae")?this.loadDae(e,n):i.endsWith("dxf")?this.loadDxf(e,n):i.endsWith("jpg")||i.endsWith("jpeg")||i.endsWith("png")?this.loadImage(e,n):this.loadGltf(e,n)}))}loadModel(e,t,n){return ft(this,null,(function*(){let i=e;if(!i)return Promise.resolve();let r=(null==t?void 0:t.toLowerCase())||"";if(!r){let e=i.split("?")[0].toLowerCase();if(e){let t=e.lastIndexOf(".");-1!==t&&(r=e.slice(t+1))}}return r.endsWith("fbx")?this.loadFbx(i,n):r.endsWith("obj")?this.loadObj(i,n):r.endsWith("stl")?this.loadStl(i,n):r.endsWith("ifc")?void se.warn("[LoadingHelper] IFC is not supported directly since three.js r150!"):r.endsWith("shp")?this.loadShp(i,n):r.endsWith("dae")?this.loadDae(i,n):r.endsWith("dxf")?this.loadDxf(i,n):r.endsWith("jpg")||r.endsWith("jpeg")||r.endsWith("png")?this.loadImage(i,n):this.loadGltf(i,n)}))}loadGltf(e,t){return ft(this,null,(function*(){let n=this.getGltfLoader();-1!==e.indexOf("#")&&console.warn(`[LoadingHelper] '#' is not allowed in filename ${e}`),e=e.replace(/#/g,encodeURIComponent("#"));let i=yield n.loadAsync(e,(e=>{0===e.total&&e.loaded>0||t&&t(e)}));return Promise.resolve(i.scene)}))}parseGltf(e,t,n,i){return this.getGltfLoader().parse(e,t,(e=>n(e.scene)),i)}loadFbx(e,t){return ft(this,null,(function*(){let n=yield new aP(this.manager).loadAsync(e,t);return Promise.resolve(n)}))}loadObj(e,t){return ft(this,null,(function*(){let n=new dP(this.manager),i=new uP(this.manager),r=e.replace(".obj",".mtl"),a=yield i.loadAsync(r,t);a.preload(),n.setMaterials(a);let s=yield n.loadAsync(e,t);return Promise.resolve(s)}))}loadStl(e,t){return ft(this,null,(function*(){let n=yield new pP(this.manager).loadAsync(e,t);return Promise.resolve(new xt(n))}))}loadShp(e,t){return ft(this,null,(function*(){let n=new vP;return new Promise(((i,r)=>{n.load(e,(e=>{i(e)}),t,(e=>{r(e)}))}))}))}loadDae(e,t){return ft(this,null,(function*(){let n=yield new nP(this.manager).loadAsync(e,t);return Promise.resolve(n.scene)}))}loadDxf(e,t){return ft(this,null,(function*(){var n;this.font||console.warn("[LoadingHelper] Should set font first!");let i=new vn(this.manager,{ignorePaperSpace:!0,enableLocalCache:!1});i.setFont(this.font),yield null==(n=this.font)?void 0:n.getFontFromIndexeddb();try{let n=yield i.loadAsync(e,t);return Promise.resolve(n.threejsObject)}catch(e){let n=new ErrorEvent("");return Promise.reject(n)}}))}loadPly(e,t){return ft(this,null,(function*(){let n=yield new fP(this.manager).loadAsync(e,t);return Promise.resolve(new xt(n))}))}loadImage(e,t){return ft(this,null,(function*(){let n=yield new Rs(this.manager).loadAsync(e,t);if(!n)return Promise.reject("Failed to load image!");let i=n.image,r=i&&i.height||10,a=i&&i.width||10;r*=10/a,a=10;let s=new ln({map:n,side:Er,transparent:!0}),o=new ui(a,r),l=new xt(o,s);return Promise.resolve(l)}))}loadDxfData(e,t,n,i,r){return ft(this,null,(function*(){var a;this.font||console.warn("[LoadingHelper] Should set font first!");let s=new vn(this.manager,r);return s.setFont(this.font),yield null==(a=this.font)?void 0:a.getFontFromIndexeddb(),s.manager.onLoad=()=>{i&&i()},s.load(e,t,n)}))}setFont(e){this.font=e}static setDracoDecoderPath(e){this.decoderPath=e}getGltfLoader(){if(!this.gltfLoader){this.gltfLoader=new th(this.manager);let e=new rP(this.manager);e.setDecoderPath(L4.decoderPath),this.gltfLoader.setDRACOLoader(e)}return this.gltfLoader}},Ya=L4;function D4(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),i=new Worker(n);return URL.revokeObjectURL(n),i}function O4(){return D4('var Zc=Object.defineProperty,Jc=Object.defineProperties;var $c=Object.getOwnPropertyDescriptors;var Bo=Object.getOwnPropertySymbols;var Kc=Object.prototype.hasOwnProperty,Qc=Object.prototype.propertyIsEnumerable;var zo=(i,t,e)=>t in i?Zc(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,ji=(i,t)=>{for(var e in t||(t={}))Kc.call(t,e)&&zo(i,e,t[e]);if(Bo)for(var e of Bo(t))Qc.call(t,e)&&zo(i,e,t[e]);return i},Vo=(i,t)=>Jc(i,$c(t));var po="154";var jc=0,ko=1,tl=2;var oc=1,el=2,on=3,Ue=0,he=1,Le=2;var Mn=0,fi=1,Ho=2,Go=3,Wo=4,nl=5,li=100,il=101,sl=102,Xo=103,qo=104,rl=200,ol=201,al=202,cl=203,ac=204,cc=205,ll=206,hl=207,ul=208,fl=209,dl=210,pl=0,ml=1,gl=2,Lr=3,_l=4,xl=5,yl=6,vl=7,lc=0,Ml=1,Sl=2,cn=0,bl=1,El=2,Tl=3,wl=4,Al=5,hc=300,mi=301,gi=302,Ir=303,Ur=304,Bs=306,Dr=1e3,ke=1001,Nr=1002,pe=1003,Yo=1004;var er=1005;var Ie=1006,Rl=1007;var ki=1008;var Sn=1009,Cl=1010,Pl=1011,mo=1012,uc=1013,yn=1014,vn=1015,Hi=1016,fc=1017,dc=1018,Fn=1020,Ll=1021,He=1023,Il=1024,Ul=1025,On=1026,_i=1027,Dl=1028,pc=1029,Nl=1030,mc=1031,gc=1033,nr=33776,ir=33777,sr=33778,rr=33779,Zo=35840,Jo=35841,$o=35842,Ko=35843,Fl=36196,Qo=37492,jo=37496,ta=37808,ea=37809,na=37810,ia=37811,sa=37812,ra=37813,oa=37814,aa=37815,ca=37816,la=37817,ha=37818,ua=37819,fa=37820,da=37821,or=36492,Ol=36283,pa=36284,ma=36285,ga=36286;var bs=2300,Es=2301,ar=2302,_a=2400,xa=2401,ya=2402;var _c=3e3,Bn=3001,Bl=3200,zl=3201,Vl=0,kl=1,zn="",Rt="srgb",Je="srgb-linear",xc="display-p3";var cr=7680;var Hl=519,Gl=512,Wl=513,Xl=514,ql=515,Yl=516,Zl=517,Jl=518,$l=519,va=35044;var Ma="300 es",Fr=1035,an=2e3,Ts=2001,bn=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;let n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;let s=this._listeners[t];if(s!==void 0){let r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){if(this._listeners===void 0)return;let n=this._listeners[t.type];if(n!==void 0){t.target=this;let s=n.slice(0);for(let r=0,a=s.length;r>8&255]+ce[i>>16&255]+ce[i>>24&255]+"-"+ce[t&255]+ce[t>>8&255]+"-"+ce[t>>16&15|64]+ce[t>>24&255]+"-"+ce[e&63|128]+ce[e>>8&255]+"-"+ce[e>>16&255]+ce[e>>24&255]+ce[n&255]+ce[n>>8&255]+ce[n>>16&255]+ce[n>>24&255]).toLowerCase()}function me(i,t,e){return Math.max(t,Math.min(e,i))}function Kl(i,t){return(i%t+t)%t}function hr(i,t,e){return(1-e)*i+e*t}function Sa(i){return(i&i-1)===0&&i!==0}function Br(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function ts(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Te(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}var Dt=class{constructor(t=0,e=0){Dt.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(me(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let n=Math.cos(e),s=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*s+t.x,this.y=r*s+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ct=class{constructor(t,e,n,s,r,a,o,c,l){Ct.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,c,l)}set(t,e,n,s,r,a,o,c,l){let h=this.elements;return h[0]=t,h[1]=s,h[2]=o,h[3]=e,h[4]=r,h[5]=c,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],d=n[7],u=n[2],m=n[5],g=n[8],x=s[0],p=s[3],f=s[6],v=s[1],_=s[4],b=s[7],M=s[2],T=s[5],A=s[8];return r[0]=a*x+o*v+c*M,r[3]=a*p+o*_+c*T,r[6]=a*f+o*b+c*A,r[1]=l*x+h*v+d*M,r[4]=l*p+h*_+d*T,r[7]=l*f+h*b+d*A,r[2]=u*x+m*v+g*M,r[5]=u*p+m*_+g*T,r[8]=u*f+m*b+g*A,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-n*r*h+n*o*c+s*r*l-s*a*c}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],d=h*a-o*l,u=o*c-h*r,m=l*r-a*c,g=e*d+n*u+s*m;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let x=1/g;return t[0]=d*x,t[1]=(s*l-h*n)*x,t[2]=(o*n-s*a)*x,t[3]=u*x,t[4]=(h*e-s*c)*x,t[5]=(s*r-o*e)*x,t[6]=m*x,t[7]=(n*c-l*e)*x,t[8]=(a*e-n*r)*x,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,r,a,o){let c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+t,-s*l,s*c,-s*(-l*a+c*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(ur.makeScale(t,e)),this}rotate(t){return this.premultiply(ur.makeRotation(-t)),this}translate(t,e){return this.premultiply(ur.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}},ur=new Ct;function yc(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function ws(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}var ba={};function zi(i){i in ba||(ba[i]=!0,console.warn(i))}function di(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function fr(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Ql=new Ct().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),jl=new Ct().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function th(i){return i.convertSRGBToLinear().applyMatrix3(jl)}function eh(i){return i.applyMatrix3(Ql).convertLinearToSRGB()}var nh={[Je]:i=>i,[Rt]:i=>i.convertSRGBToLinear(),[xc]:th},ih={[Je]:i=>i,[Rt]:i=>i.convertLinearToSRGB(),[xc]:eh},Oe={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(i){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!i},get workingColorSpace(){return Je},set workingColorSpace(i){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(i,t,e){if(this.enabled===!1||t===e||!t||!e)return i;let n=nh[t],s=ih[e];if(n===void 0||s===void 0)throw new Error(`Unsupported color space conversion, "${t}" to "${e}".`);return s(n(i))},fromWorkingColorSpace:function(i,t){return this.convert(i,this.workingColorSpace,t)},toWorkingColorSpace:function(i,t){return this.convert(i,t,this.workingColorSpace)}},Yn,As=class{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement=="undefined")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Yn===void 0&&(Yn=ws("canvas")),Yn.width=t.width,Yn.height=t.height;let n=Yn.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Yn}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement!="undefined"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&t instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&t instanceof ImageBitmap){let e=ws("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let a=0;a0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==hc)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Dr:t.x=t.x-Math.floor(t.x);break;case ke:t.x=t.x<0?0:1;break;case Nr:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Dr:t.y=t.y-Math.floor(t.y);break;case ke:t.y=t.y<0?0:1;break;case Nr:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return zi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Rt?Bn:_c}set encoding(t){zi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=t===Bn?Rt:zn}};ge.DEFAULT_IMAGE=null;ge.DEFAULT_MAPPING=hc;ge.DEFAULT_ANISOTROPY=1;var Kt=class{constructor(t=0,e=0,n=0,s=1){Kt.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,s){return this.x=t,this.y=e,this.z=n,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*s+a[15]*r,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,s,r,c=t.elements,l=c[0],h=c[4],d=c[8],u=c[1],m=c[5],g=c[9],x=c[2],p=c[6],f=c[10];if(Math.abs(h-u)<.01&&Math.abs(d-x)<.01&&Math.abs(g-p)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+x)<.1&&Math.abs(g+p)<.1&&Math.abs(l+m+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let _=(l+1)/2,b=(m+1)/2,M=(f+1)/2,T=(h+u)/4,A=(d+x)/4,L=(g+p)/4;return _>b&&_>M?_<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(_),s=T/n,r=A/n):b>M?b<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(b),n=T/s,r=L/s):M<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(M),n=A/r,s=L/r),this.set(n,s,r,e),this}let v=Math.sqrt((p-g)*(p-g)+(d-x)*(d-x)+(u-h)*(u-h));return Math.abs(v)<.001&&(v=1),this.x=(p-g)/v,this.y=(d-x)/v,this.z=(u-h)/v,this.w=Math.acos((l+m+f-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},hn=class extends bn{constructor(t=1,e=1,n={}){super(),this.isWebGLRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Kt(0,0,t,e),this.scissorTest=!1,this.viewport=new Kt(0,0,t,e);let s={width:t,height:e,depth:1};n.encoding!==void 0&&(zi("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Bn?Rt:zn),this.texture=new ge(s,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:Ie,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(t,e,n=1){(this.width!==t||this.height!==e||this.depth!==n)&&(this.width=t,this.height=e,this.depth=n,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.texture.isRenderTargetTexture=!0;let e=Object.assign({},t.texture.image);return this.texture.source=new Rs(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},Cs=class extends ge{constructor(t=null,e=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=pe,this.minFilter=pe,this.wrapR=ke,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var zr=class extends ge{constructor(t=null,e=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=pe,this.minFilter=pe,this.wrapR=ke,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var En=class{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,r,a,o){let c=n[s+0],l=n[s+1],h=n[s+2],d=n[s+3],u=r[a+0],m=r[a+1],g=r[a+2],x=r[a+3];if(o===0){t[e+0]=c,t[e+1]=l,t[e+2]=h,t[e+3]=d;return}if(o===1){t[e+0]=u,t[e+1]=m,t[e+2]=g,t[e+3]=x;return}if(d!==x||c!==u||l!==m||h!==g){let p=1-o,f=c*u+l*m+h*g+d*x,v=f>=0?1:-1,_=1-f*f;if(_>Number.EPSILON){let M=Math.sqrt(_),T=Math.atan2(M,f*v);p=Math.sin(p*T)/M,o=Math.sin(o*T)/M}let b=o*v;if(c=c*p+u*b,l=l*p+m*b,h=h*p+g*b,d=d*p+x*b,p===1-o){let M=1/Math.sqrt(c*c+l*l+h*h+d*d);c*=M,l*=M,h*=M,d*=M}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=d}static multiplyQuaternionsFlat(t,e,n,s,r,a){let o=n[s],c=n[s+1],l=n[s+2],h=n[s+3],d=r[a],u=r[a+1],m=r[a+2],g=r[a+3];return t[e]=o*g+h*d+c*m-l*u,t[e+1]=c*g+h*u+l*d-o*m,t[e+2]=l*g+h*m+o*u-c*d,t[e+3]=h*g-o*d-c*u-l*m,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){let n=t._x,s=t._y,r=t._z,a=t._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(s/2),d=o(r/2),u=c(n/2),m=c(s/2),g=c(r/2);switch(a){case"XYZ":this._x=u*h*d+l*m*g,this._y=l*m*d-u*h*g,this._z=l*h*g+u*m*d,this._w=l*h*d-u*m*g;break;case"YXZ":this._x=u*h*d+l*m*g,this._y=l*m*d-u*h*g,this._z=l*h*g-u*m*d,this._w=l*h*d+u*m*g;break;case"ZXY":this._x=u*h*d-l*m*g,this._y=l*m*d+u*h*g,this._z=l*h*g+u*m*d,this._w=l*h*d-u*m*g;break;case"ZYX":this._x=u*h*d-l*m*g,this._y=l*m*d+u*h*g,this._z=l*h*g-u*m*d,this._w=l*h*d+u*m*g;break;case"YZX":this._x=u*h*d+l*m*g,this._y=l*m*d+u*h*g,this._z=l*h*g-u*m*d,this._w=l*h*d-u*m*g;break;case"XZY":this._x=u*h*d-l*m*g,this._y=l*m*d-u*h*g,this._z=l*h*g+u*m*d,this._w=l*h*d+u*m*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e!==!1&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],s=e[4],r=e[8],a=e[1],o=e[5],c=e[9],l=e[2],h=e[6],d=e[10],u=n+o+d;if(u>0){let m=.5/Math.sqrt(u+1);this._w=.25/m,this._x=(h-c)*m,this._y=(r-l)*m,this._z=(a-s)*m}else if(n>o&&n>d){let m=2*Math.sqrt(1+n-o-d);this._w=(h-c)/m,this._x=.25*m,this._y=(s+a)/m,this._z=(r+l)/m}else if(o>d){let m=2*Math.sqrt(1+o-n-d);this._w=(r-l)/m,this._x=(s+a)/m,this._y=.25*m,this._z=(c+h)/m}else{let m=2*Math.sqrt(1+d-n-o);this._w=(a-s)/m,this._x=(r+l)/m,this._y=(c+h)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return nMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(me(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let s=Math.min(1,e/n);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let n=t._x,s=t._y,r=t._z,a=t._w,o=e._x,c=e._y,l=e._z,h=e._w;return this._x=n*h+a*o+s*l-r*c,this._y=s*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-s*o,this._w=a*h-n*o-s*c-r*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let n=this._x,s=this._y,r=this._z,a=this._w,o=a*t._w+n*t._x+s*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=s,this._z=r,this;let c=1-o*o;if(c<=Number.EPSILON){let m=1-e;return this._w=m*a+e*this._w,this._x=m*n+e*this._x,this._y=m*s+e*this._y,this._z=m*r+e*this._z,this.normalize(),this._onChangeCallback(),this}let l=Math.sqrt(c),h=Math.atan2(l,o),d=Math.sin((1-e)*h)/l,u=Math.sin(e*h)/l;return this._w=a*d+this._w*u,this._x=n*d+this._x*u,this._y=s*d+this._y*u,this._z=r*d+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=Math.random(),e=Math.sqrt(1-t),n=Math.sqrt(t),s=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(e*Math.cos(s),n*Math.sin(r),n*Math.cos(r),e*Math.sin(s))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},P=class{constructor(t=0,e=0,n=0){P.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Ea.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ea.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*s,this.y=r[1]*e+r[4]*n+r[7]*s,this.z=r[2]*e+r[5]*n+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(t){let e=this.x,n=this.y,s=this.z,r=t.x,a=t.y,o=t.z,c=t.w,l=c*e+a*s-o*n,h=c*n+o*e-r*s,d=c*s+r*n-a*e,u=-r*e-a*n-o*s;return this.x=l*c+u*-r+h*-o-d*-a,this.y=h*c+u*-a+d*-r-l*-o,this.z=d*c+u*-o+l*-a-h*-r,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s,this.y=r[1]*e+r[5]*n+r[9]*s,this.z=r[2]*e+r[6]*n+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let n=t.x,s=t.y,r=t.z,a=e.x,o=e.y,c=e.z;return this.x=s*c-r*o,this.y=r*a-n*c,this.z=n*o-s*a,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return pr.copy(this).projectOnVector(t),this.sub(pr)}reflect(t){return this.sub(pr.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(me(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){let s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=(Math.random()-.5)*2,e=Math.random()*Math.PI*2,n=Math.sqrt(1-t**2);return this.x=n*Math.cos(e),this.y=n*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},pr=new P,Ea=new En,_e=class{constructor(t=new P(1/0,1/0,1/0),e=new P(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,tn),tn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Di),es.subVectors(this.max,Di),Jn.subVectors(t.a,Di),$n.subVectors(t.b,Di),Kn.subVectors(t.c,Di),pn.subVectors($n,Jn),mn.subVectors(Kn,$n),Pn.subVectors(Jn,Kn);let e=[0,-pn.z,pn.y,0,-mn.z,mn.y,0,-Pn.z,Pn.y,pn.z,0,-pn.x,mn.z,0,-mn.x,Pn.z,0,-Pn.x,-pn.y,pn.x,0,-mn.y,mn.x,0,-Pn.y,Pn.x,0];return!mr(e,Jn,$n,Kn,es)||(e=[1,0,0,0,1,0,0,0,1],!mr(e,Jn,$n,Kn,es))?!1:(ns.crossVectors(pn,mn),e=[ns.x,ns.y,ns.z],mr(e,Jn,$n,Kn,es))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,tn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(tn).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(je[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),je[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),je[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),je[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),je[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),je[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),je[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),je[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(je),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},je=[new P,new P,new P,new P,new P,new P,new P,new P],tn=new P,Zn=new _e,Jn=new P,$n=new P,Kn=new P,pn=new P,mn=new P,Pn=new P,Di=new P,es=new P,ns=new P,Ln=new P;function mr(i,t,e,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Ln.fromArray(i,r);let o=s.x*Math.abs(Ln.x)+s.y*Math.abs(Ln.y)+s.z*Math.abs(Ln.z),c=t.dot(Ln),l=e.dot(Ln),h=n.dot(Ln);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}var oh=new _e,Ni=new P,gr=new P,Vn=class{constructor(t=new P,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let n=this.center;e!==void 0?n.copy(e):oh.setFromPoints(t).getCenter(n);let s=0;for(let r=0,a=t.length;rthis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Ni.subVectors(t,this.center);let e=Ni.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Ni,s/n),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(gr.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Ni.copy(t.center).add(gr)),this.expandByPoint(Ni.copy(t.center).sub(gr))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}},en=new P,_r=new P,is=new P,gn=new P,xr=new P,ss=new P,yr=new P,Vr=class{constructor(t=new P,e=new P(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,en)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=en.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(en.copy(this.origin).addScaledVector(this.direction,e),en.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){_r.copy(t).add(e).multiplyScalar(.5),is.copy(e).sub(t).normalize(),gn.copy(this.origin).sub(_r);let r=t.distanceTo(e)*.5,a=-this.direction.dot(is),o=gn.dot(this.direction),c=-gn.dot(is),l=gn.lengthSq(),h=Math.abs(1-a*a),d,u,m,g;if(h>0)if(d=a*c-o,u=a*o-c,g=r*h,d>=0)if(u>=-g)if(u<=g){let x=1/h;d*=x,u*=x,m=d*(d+a*u+2*o)+u*(a*d+u+2*c)+l}else u=r,d=Math.max(0,-(a*u+o)),m=-d*d+u*(u+2*c)+l;else u=-r,d=Math.max(0,-(a*u+o)),m=-d*d+u*(u+2*c)+l;else u<=-g?(d=Math.max(0,-(-a*r+o)),u=d>0?-r:Math.min(Math.max(-r,-c),r),m=-d*d+u*(u+2*c)+l):u<=g?(d=0,u=Math.min(Math.max(-r,-c),r),m=u*(u+2*c)+l):(d=Math.max(0,-(a*r+o)),u=d>0?r:Math.min(Math.max(-r,-c),r),m=-d*d+u*(u+2*c)+l);else u=a>0?-r:r,d=Math.max(0,-(a*u+o)),m=-d*d+u*(u+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(_r).addScaledVector(is,u),m}intersectSphere(t,e){en.subVectors(t.center,this.origin);let n=en.dot(this.direction),s=en.dot(en)-n*n,r=t.radius*t.radius;if(s>r)return null;let a=Math.sqrt(r-s),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){let n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,r,a,o,c,l=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return l>=0?(n=(t.min.x-u.x)*l,s=(t.max.x-u.x)*l):(n=(t.max.x-u.x)*l,s=(t.min.x-u.x)*l),h>=0?(r=(t.min.y-u.y)*h,a=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,a=(t.min.y-u.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a=0?(o=(t.min.z-u.z)*d,c=(t.max.z-u.z)*d):(o=(t.max.z-u.z)*d,c=(t.min.z-u.z)*d),n>c||o>s)||((o>n||n!==n)&&(n=o),(c=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,en)!==null}intersectTriangle(t,e,n,s,r){xr.subVectors(e,t),ss.subVectors(n,t),yr.crossVectors(xr,ss);let a=this.direction.dot(yr),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;gn.subVectors(this.origin,t);let c=o*this.direction.dot(ss.crossVectors(gn,ss));if(c<0)return null;let l=o*this.direction.dot(xr.cross(gn));if(l<0||c+l>a)return null;let h=-o*gn.dot(yr);return h<0?null:this.at(h/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Gt=class{constructor(t,e,n,s,r,a,o,c,l,h,d,u,m,g,x,p){Gt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,c,l,h,d,u,m,g,x,p)}set(t,e,n,s,r,a,o,c,l,h,d,u,m,g,x,p){let f=this.elements;return f[0]=t,f[4]=e,f[8]=n,f[12]=s,f[1]=r,f[5]=a,f[9]=o,f[13]=c,f[2]=l,f[6]=h,f[10]=d,f[14]=u,f[3]=m,f[7]=g,f[11]=x,f[15]=p,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Gt().fromArray(this.elements)}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){let e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,n=t.elements,s=1/Qn.setFromMatrixColumn(t,0).length(),r=1/Qn.setFromMatrixColumn(t,1).length(),a=1/Qn.setFromMatrixColumn(t,2).length();return e[0]=n[0]*s,e[1]=n[1]*s,e[2]=n[2]*s,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,n=t.x,s=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),d=Math.sin(r);if(t.order==="XYZ"){let u=a*h,m=a*d,g=o*h,x=o*d;e[0]=c*h,e[4]=-c*d,e[8]=l,e[1]=m+g*l,e[5]=u-x*l,e[9]=-o*c,e[2]=x-u*l,e[6]=g+m*l,e[10]=a*c}else if(t.order==="YXZ"){let u=c*h,m=c*d,g=l*h,x=l*d;e[0]=u+x*o,e[4]=g*o-m,e[8]=a*l,e[1]=a*d,e[5]=a*h,e[9]=-o,e[2]=m*o-g,e[6]=x+u*o,e[10]=a*c}else if(t.order==="ZXY"){let u=c*h,m=c*d,g=l*h,x=l*d;e[0]=u-x*o,e[4]=-a*d,e[8]=g+m*o,e[1]=m+g*o,e[5]=a*h,e[9]=x-u*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){let u=a*h,m=a*d,g=o*h,x=o*d;e[0]=c*h,e[4]=g*l-m,e[8]=u*l+x,e[1]=c*d,e[5]=x*l+u,e[9]=m*l-g,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){let u=a*c,m=a*l,g=o*c,x=o*l;e[0]=c*h,e[4]=x-u*d,e[8]=g*d+m,e[1]=d,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=m*d+g,e[10]=u-x*d}else if(t.order==="XZY"){let u=a*c,m=a*l,g=o*c,x=o*l;e[0]=c*h,e[4]=-d,e[8]=l*h,e[1]=u*d+x,e[5]=a*h,e[9]=m*d-g,e[2]=g*d-m,e[6]=o*h,e[10]=x*d+u}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(ah,t,ch)}lookAt(t,e,n){let s=this.elements;return we.subVectors(t,e),we.lengthSq()===0&&(we.z=1),we.normalize(),_n.crossVectors(n,we),_n.lengthSq()===0&&(Math.abs(n.z)===1?we.x+=1e-4:we.z+=1e-4,we.normalize(),_n.crossVectors(n,we)),_n.normalize(),rs.crossVectors(we,_n),s[0]=_n.x,s[4]=rs.x,s[8]=we.x,s[1]=_n.y,s[5]=rs.y,s[9]=we.y,s[2]=_n.z,s[6]=rs.z,s[10]=we.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],d=n[5],u=n[9],m=n[13],g=n[2],x=n[6],p=n[10],f=n[14],v=n[3],_=n[7],b=n[11],M=n[15],T=s[0],A=s[4],L=s[8],y=s[12],w=s[1],z=s[5],q=s[9],I=s[13],D=s[2],O=s[6],$=s[10],k=s[14],X=s[3],J=s[7],K=s[11],B=s[15];return r[0]=a*T+o*w+c*D+l*X,r[4]=a*A+o*z+c*O+l*J,r[8]=a*L+o*q+c*$+l*K,r[12]=a*y+o*I+c*k+l*B,r[1]=h*T+d*w+u*D+m*X,r[5]=h*A+d*z+u*O+m*J,r[9]=h*L+d*q+u*$+m*K,r[13]=h*y+d*I+u*k+m*B,r[2]=g*T+x*w+p*D+f*X,r[6]=g*A+x*z+p*O+f*J,r[10]=g*L+x*q+p*$+f*K,r[14]=g*y+x*I+p*k+f*B,r[3]=v*T+_*w+b*D+M*X,r[7]=v*A+_*z+b*O+M*J,r[11]=v*L+_*q+b*$+M*K,r[15]=v*y+_*I+b*k+M*B,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[4],s=t[8],r=t[12],a=t[1],o=t[5],c=t[9],l=t[13],h=t[2],d=t[6],u=t[10],m=t[14],g=t[3],x=t[7],p=t[11],f=t[15];return g*(+r*c*d-s*l*d-r*o*u+n*l*u+s*o*m-n*c*m)+x*(+e*c*m-e*l*u+r*a*u-s*a*m+s*l*h-r*c*h)+p*(+e*l*d-e*o*m-r*a*d+n*a*m+r*o*h-n*l*h)+f*(-s*o*h-e*c*d+e*o*u+s*a*d-n*a*u+n*c*h)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){let s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=n),this}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],d=t[9],u=t[10],m=t[11],g=t[12],x=t[13],p=t[14],f=t[15],v=d*p*l-x*u*l+x*c*m-o*p*m-d*c*f+o*u*f,_=g*u*l-h*p*l-g*c*m+a*p*m+h*c*f-a*u*f,b=h*x*l-g*d*l+g*o*m-a*x*m-h*o*f+a*d*f,M=g*d*c-h*x*c-g*o*u+a*x*u+h*o*p-a*d*p,T=e*v+n*_+s*b+r*M;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/T;return t[0]=v*A,t[1]=(x*u*r-d*p*r-x*s*m+n*p*m+d*s*f-n*u*f)*A,t[2]=(o*p*r-x*c*r+x*s*l-n*p*l-o*s*f+n*c*f)*A,t[3]=(d*c*r-o*u*r-d*s*l+n*u*l+o*s*m-n*c*m)*A,t[4]=_*A,t[5]=(h*p*r-g*u*r+g*s*m-e*p*m-h*s*f+e*u*f)*A,t[6]=(g*c*r-a*p*r-g*s*l+e*p*l+a*s*f-e*c*f)*A,t[7]=(a*u*r-h*c*r+h*s*l-e*u*l-a*s*m+e*c*m)*A,t[8]=b*A,t[9]=(g*d*r-h*x*r-g*n*m+e*x*m+h*n*f-e*d*f)*A,t[10]=(a*x*r-g*o*r+g*n*l-e*x*l-a*n*f+e*o*f)*A,t[11]=(h*o*r-a*d*r-h*n*l+e*d*l+a*n*m-e*o*m)*A,t[12]=M*A,t[13]=(h*x*s-g*d*s+g*n*u-e*x*u-h*n*p+e*d*p)*A,t[14]=(g*o*s-a*x*s-g*n*c+e*x*c+a*n*p-e*o*p)*A,t[15]=(a*d*s-h*o*s+h*n*c-e*d*c-a*n*u+e*o*u)*A,this}scale(t){let e=this.elements,n=t.x,s=t.y,r=t.z;return e[0]*=n,e[4]*=s,e[8]*=r,e[1]*=n,e[5]*=s,e[9]*=r,e[2]*=n,e[6]*=s,e[10]*=r,e[3]*=n,e[7]*=s,e[11]*=r,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,s))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let n=Math.cos(e),s=Math.sin(e),r=1-n,a=t.x,o=t.y,c=t.z,l=r*a,h=r*o;return this.set(l*a+n,l*o-s*c,l*c+s*o,0,l*o+s*c,h*o+n,h*c-s*a,0,l*c-s*o,h*c+s*a,r*c*c+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,s,r,a){return this.set(1,n,r,0,t,1,a,0,e,s,1,0,0,0,0,1),this}compose(t,e,n){let s=this.elements,r=e._x,a=e._y,o=e._z,c=e._w,l=r+r,h=a+a,d=o+o,u=r*l,m=r*h,g=r*d,x=a*h,p=a*d,f=o*d,v=c*l,_=c*h,b=c*d,M=n.x,T=n.y,A=n.z;return s[0]=(1-(x+f))*M,s[1]=(m+b)*M,s[2]=(g-_)*M,s[3]=0,s[4]=(m-b)*T,s[5]=(1-(u+f))*T,s[6]=(p+v)*T,s[7]=0,s[8]=(g+_)*A,s[9]=(p-v)*A,s[10]=(1-(u+x))*A,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){let s=this.elements,r=Qn.set(s[0],s[1],s[2]).length(),a=Qn.set(s[4],s[5],s[6]).length(),o=Qn.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),t.x=s[12],t.y=s[13],t.z=s[14],Be.copy(this);let l=1/r,h=1/a,d=1/o;return Be.elements[0]*=l,Be.elements[1]*=l,Be.elements[2]*=l,Be.elements[4]*=h,Be.elements[5]*=h,Be.elements[6]*=h,Be.elements[8]*=d,Be.elements[9]*=d,Be.elements[10]*=d,e.setFromRotationMatrix(Be),n.x=r,n.y=a,n.z=o,this}makePerspective(t,e,n,s,r,a,o=an){let c=this.elements,l=2*r/(e-t),h=2*r/(n-s),d=(e+t)/(e-t),u=(n+s)/(n-s),m,g;if(o===an)m=-(a+r)/(a-r),g=-2*a*r/(a-r);else if(o===Ts)m=-a/(a-r),g=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=h,c[9]=u,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,s,r,a,o=an){let c=this.elements,l=1/(e-t),h=1/(n-s),d=1/(a-r),u=(e+t)*l,m=(n+s)*h,g,x;if(o===an)g=(a+r)*d,x=-2*d;else if(o===Ts)g=r*d,x=-1*d;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-u,c[1]=0,c[5]=2*h,c[9]=0,c[13]=-m,c[2]=0,c[6]=0,c[10]=x,c[14]=-g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<16;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}},Qn=new P,Be=new Gt,ah=new P(0,0,0),ch=new P(1,1,1),_n=new P,rs=new P,we=new P,Ta=new Gt,wa=new En,xi=class{constructor(t=0,e=0,n=0,s=xi.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,s=this._order){return this._x=t,this._y=e,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){let s=t.elements,r=s[0],a=s[4],o=s[8],c=s[1],l=s[5],h=s[9],d=s[2],u=s[6],m=s[10];switch(e){case"XYZ":this._y=Math.asin(me(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,m),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-me(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(me(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,m),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-me(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,m),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(me(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-me(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Ta.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ta,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return wa.setFromEuler(this),this.setFromQuaternion(wa,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};xi.DEFAULT_ORDER="XYZ";var Ps=class{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let n=0;n0&&(n=n.concat(a))}return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Fi,t,hh),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Fi,uh,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let n=0,s=e.length;n0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l0){s.children=[];for(let o=0;o0){s.animations=[];for(let o=0;o0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),m.length>0&&(n.animations=m),g.length>0&&(n.nodes=g)}return n.object=s,n;function a(o){let c=[];for(let l in o){let h=o[l];delete h.metadata,c.push(h)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations,this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){ze.subVectors(s,e),sn.subVectors(n,e),vr.subVectors(t,e);let a=ze.dot(ze),o=ze.dot(sn),c=ze.dot(vr),l=sn.dot(sn),h=sn.dot(vr),d=a*l-o*o;if(d===0)return r.set(-2,-1,-1);let u=1/d,m=(l*c-o*h)*u,g=(a*h-o*c)*u;return r.set(1-m-g,g,m)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,rn),rn.x>=0&&rn.y>=0&&rn.x+rn.y<=1}static getUV(t,e,n,s,r,a,o,c){return as===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),as=!0),this.getInterpolation(t,e,n,s,r,a,o,c)}static getInterpolation(t,e,n,s,r,a,o,c){return this.getBarycoord(t,e,n,s,rn),c.setScalar(0),c.addScaledVector(r,rn.x),c.addScaledVector(a,rn.y),c.addScaledVector(o,rn.z),c}static isFrontFacing(t,e,n,s){return ze.subVectors(n,e),sn.subVectors(t,e),ze.cross(sn).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return ze.subVectors(this.c,this.b),sn.subVectors(this.a,this.b),ze.cross(sn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return se.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return se.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,n,s,r){return as===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),as=!0),se.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}getInterpolation(t,e,n,s,r){return se.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return se.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return se.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,s=this.b,r=this.c,a,o;ti.subVectors(s,n),ei.subVectors(r,n),Mr.subVectors(t,n);let c=ti.dot(Mr),l=ei.dot(Mr);if(c<=0&&l<=0)return e.copy(n);Sr.subVectors(t,s);let h=ti.dot(Sr),d=ei.dot(Sr);if(h>=0&&d<=h)return e.copy(s);let u=c*d-h*l;if(u<=0&&c>=0&&h<=0)return a=c/(c-h),e.copy(n).addScaledVector(ti,a);br.subVectors(t,r);let m=ti.dot(br),g=ei.dot(br);if(g>=0&&m<=g)return e.copy(r);let x=m*l-c*g;if(x<=0&&l>=0&&g<=0)return o=l/(l-g),e.copy(n).addScaledVector(ei,o);let p=h*g-m*d;if(p<=0&&d-h>=0&&m-g>=0)return Ia.subVectors(r,s),o=(d-h)/(d-h+(m-g)),e.copy(s).addScaledVector(Ia,o);let f=1/(p+x+u);return a=x*f,o=u*f,e.copy(n).addScaledVector(ti,a).addScaledVector(ei,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},dh=0,yi=class extends bn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:dh++}),this.uuid=Xi(),this.name="",this.type="Material",this.blending=fi,this.side=Ue,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=ac,this.blendDst=cc,this.blendEquation=li,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Lr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Hl,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=cr,this.stencilZFail=cr,this.stencilZPass=cr,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter \'${e}\' has value of undefined.`);continue}let s=this[e];if(s===void 0){console.warn(`THREE.Material: \'${e}\' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==fi&&(n.blending=this.blending),this.side!==Ue&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=this.alphaHash),this.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.forceSinglePass===!0&&(n.forceSinglePass=this.forceSinglePass),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=this.flatShading),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let a=[];for(let o in r){let c=r[o];delete c.metadata,a.push(c)}return a}if(e){let r=s(t.textures),a=s(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let s=e.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}},vc={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ve={h:0,s:0,l:0},cs={h:0,s:0,l:0};function Er(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}var kt=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Rt){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Oe.toWorkingColorSpace(this,e),this}setRGB(t,e,n,s=Oe.workingColorSpace){return this.r=t,this.g=e,this.b=n,Oe.toWorkingColorSpace(this,s),this}setHSL(t,e,n,s=Oe.workingColorSpace){if(t=Kl(t,1),e=me(e,0,1),n=me(n,0,1),e===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=Er(a,r,t+1/3),this.g=Er(a,r,t),this.b=Er(a,r,t-1/3)}return Oe.toWorkingColorSpace(this,s),this}setStyle(t,e=Rt){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\\w+)\\(([^\\)]*)\\)/.exec(t)){let r,a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\\s*(\\d*\\.?\\d+)\\s*,\\s*(\\d*\\.?\\d+)\\%\\s*,\\s*(\\d*\\.?\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\\#([A-Fa-f\\d]+)$/.exec(t)){let r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(r,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Rt){let n=vc[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=di(t.r),this.g=di(t.g),this.b=di(t.b),this}copyLinearToSRGB(t){return this.r=fr(t.r),this.g=fr(t.g),this.b=fr(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Rt){return Oe.fromWorkingColorSpace(le.copy(this),t),Math.round(me(le.r*255,0,255))*65536+Math.round(me(le.g*255,0,255))*256+Math.round(me(le.b*255,0,255))}getHexString(t=Rt){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Oe.workingColorSpace){Oe.fromWorkingColorSpace(le.copy(this),e);let n=le.r,s=le.g,r=le.b,a=Math.max(n,s,r),o=Math.min(n,s,r),c,l,h=(o+a)/2;if(o===a)c=0,l=0;else{let d=a-o;switch(l=h<=.5?d/(a+o):d/(2-a-o),a){case n:c=(s-r)/d+(s0&&(t.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let c in n){let l=n[c];t.data.attributes[c]=l.toJSON(t.data)}let s={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],h=[];for(let d=0,u=l.length;d0&&(s[c]=h,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone(e));let s=t.attributes;for(let l in s){let h=s[l];this.setAttribute(l,h.clone(e))}let r=t.morphAttributes;for(let l in r){let h=[],d=r[l];for(let u=0,m=d.length;u0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r(t.far-t.near)**2))&&(Ua.copy(r).invert(),In.copy(t.ray).applyMatrix4(Ua),!(n.boundingBox!==null&&In.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,In)))}_computeIntersections(t,e,n){let s,r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,m=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,x=u.length;ge.far?null:{distance:l,point:gs.clone(),object:i}}function _s(i,t,e,n,s,r,a,o,c,l){i.getVertexPosition(o,ii),i.getVertexPosition(c,si),i.getVertexPosition(l,ri);let h=mh(i,t,e,n,ii,si,ri,ms);if(h){s&&(fs.fromBufferAttribute(s,o),ds.fromBufferAttribute(s,c),ps.fromBufferAttribute(s,l),h.uv=se.getInterpolation(ms,ii,si,ri,fs,ds,ps,new Dt)),r&&(fs.fromBufferAttribute(r,o),ds.fromBufferAttribute(r,c),ps.fromBufferAttribute(r,l),h.uv1=se.getInterpolation(ms,ii,si,ri,fs,ds,ps,new Dt),h.uv2=h.uv1),a&&(Na.fromBufferAttribute(a,o),Fa.fromBufferAttribute(a,c),Oa.fromBufferAttribute(a,l),h.normal=se.getInterpolation(ms,ii,si,ri,Na,Fa,Oa,new P),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let d={a:o,b:c,c:l,normal:new P,materialIndex:0};se.getNormal(ii,si,ri,d.normal),h.face=d}return h}var kn=class extends Ge{constructor(t=1,e=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};let o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);let c=[],l=[],h=[],d=[],u=0,m=0;g("z","y","x",-1,-1,n,e,t,a,r,0),g("z","y","x",1,-1,n,e,-t,a,r,1),g("x","z","y",1,1,t,n,e,s,a,2),g("x","z","y",1,-1,t,n,-e,s,a,3),g("x","y","z",1,-1,t,e,n,s,r,4),g("x","y","z",-1,-1,t,e,-n,s,r,5),this.setIndex(c),this.setAttribute("position",new ln(l,3)),this.setAttribute("normal",new ln(h,3)),this.setAttribute("uv",new ln(d,2));function g(x,p,f,v,_,b,M,T,A,L,y){let w=b/A,z=M/L,q=b/2,I=M/2,D=T/2,O=A+1,$=L+1,k=0,X=0,J=new P;for(let K=0;K<$;K++){let B=K*z-I;for(let Z=0;Z0?1:-1,h.push(J.x,J.y,J.z),d.push(Z/A),d.push(1-K/L),k+=1}}for(let K=0;K0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}},Ds=class extends ye{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Gt,this.projectionMatrix=new Gt,this.projectionMatrixInverse=new Gt,this.coordinateSystem=an}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},Re=class extends Ds{constructor(t=50,e=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){let e=.5*this.getFilmHeight()/t;this.fov=Or*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(lr*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Or*2*Math.atan(Math.tan(lr*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,n,s,r,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=this.near,e=t*Math.tan(lr*.5*this.fov)/this.zoom,n=2*e,s=this.aspect*n,r=-.5*s,a=this.view;if(this.view!==null&&this.view.enabled){let c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,e-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}let o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}},oi=-90,ai=1,kr=class extends ye{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null;let s=new Re(oi,ai,t,e);s.layers=this.layers,this.add(s);let r=new Re(oi,ai,t,e);r.layers=this.layers,this.add(r);let a=new Re(oi,ai,t,e);a.layers=this.layers,this.add(a);let o=new Re(oi,ai,t,e);o.layers=this.layers,this.add(o);let c=new Re(oi,ai,t,e);c.layers=this.layers,this.add(c);let l=new Re(oi,ai,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let t=this.coordinateSystem,e=this.children.concat(),[n,s,r,a,o,c]=e;for(let l of e)this.remove(l);if(t===an)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(t===Ts)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(let l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();let n=this.renderTarget;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());let[s,r,a,o,c,l]=this.children,h=t.getRenderTarget(),d=t.toneMapping,u=t.xr.enabled;t.toneMapping=cn,t.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0),t.render(e,s),t.setRenderTarget(n,1),t.render(e,r),t.setRenderTarget(n,2),t.render(e,a),t.setRenderTarget(n,3),t.render(e,o),t.setRenderTarget(n,4),t.render(e,c),n.texture.generateMipmaps=m,t.setRenderTarget(n,5),t.render(e,l),t.setRenderTarget(h),t.toneMapping=d,t.xr.enabled=u,n.texture.needsPMREMUpdate=!0}},Ns=class extends ge{constructor(t,e,n,s,r,a,o,c,l,h){t=t!==void 0?t:[],e=e!==void 0?e:mi,super(t,e,n,s,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}},Hr=class extends hn{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];e.encoding!==void 0&&(zi("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),e.colorSpace=e.encoding===Bn?Rt:zn),this.texture=new Ns(s,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:Ie}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t`,fragmentShader:`\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t`},s=new kn(5,5,5),r=new un({name:"CubemapFromEquirect",uniforms:vi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:he,blending:Mn});r.uniforms.tEquirect.value=e;let a=new Ze(s,r),o=e.minFilter;return e.minFilter===ki&&(e.minFilter=Ie),new kr(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e,n,s){let r=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,s);t.setRenderTarget(r)}},Ar=new P,vh=new P,Mh=new Ct,Ce=class{constructor(t=new P(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,s){return this.normal.set(t,e,n),this.constant=s,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){let s=Ar.subVectors(n,e).cross(vh.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){let n=t.delta(Ar),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let r=-(t.start.dot(this.normal)+this.constant)/s;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let n=e||Mh.getNormalMatrix(t),s=this.coplanarPoint(Ar).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}},Un=new Vn,xs=new P,Fs=class{constructor(t=new Ce,e=new Ce,n=new Ce,s=new Ce,r=new Ce,a=new Ce){this.planes=[t,e,n,s,r,a]}set(t,e,n,s,r,a){let o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(t){let e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=an){let n=this.planes,s=t.elements,r=s[0],a=s[1],o=s[2],c=s[3],l=s[4],h=s[5],d=s[6],u=s[7],m=s[8],g=s[9],x=s[10],p=s[11],f=s[12],v=s[13],_=s[14],b=s[15];if(n[0].setComponents(c-r,u-l,p-m,b-f).normalize(),n[1].setComponents(c+r,u+l,p+m,b+f).normalize(),n[2].setComponents(c+a,u+h,p+g,b+v).normalize(),n[3].setComponents(c-a,u-h,p-g,b-v).normalize(),n[4].setComponents(c-o,u-d,p-x,b-_).normalize(),e===an)n[5].setComponents(c+o,u+d,p+x,b+_).normalize();else if(e===Ts)n[5].setComponents(o,d,x,_).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Un.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{let e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Un.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Un)}intersectsSprite(t){return Un.center.set(0,0,0),Un.radius=.7071067811865476,Un.applyMatrix4(t.matrixWorld),this.intersectsSphere(Un)}intersectsSphere(t){let e=this.planes,n=t.center,s=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)0?t.max.x:t.min.x,xs.y=s.normal.y>0?t.max.y:t.min.y,xs.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(xs)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function Sc(){let i=null,t=!1,e=null,n=null;function s(r,a){e(r,a),n=i.requestAnimationFrame(s)}return{start:function(){t!==!0&&e!==null&&(n=i.requestAnimationFrame(s),t=!0)},stop:function(){i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){i=r}}}function Sh(i,t){let e=t.isWebGL2,n=new WeakMap;function s(l,h){let d=l.array,u=l.usage,m=i.createBuffer();i.bindBuffer(h,m),i.bufferData(h,d,u),l.onUploadCallback();let g;if(d instanceof Float32Array)g=i.FLOAT;else if(d instanceof Uint16Array)if(l.isFloat16BufferAttribute)if(e)g=i.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else g=i.UNSIGNED_SHORT;else if(d instanceof Int16Array)g=i.SHORT;else if(d instanceof Uint32Array)g=i.UNSIGNED_INT;else if(d instanceof Int32Array)g=i.INT;else if(d instanceof Int8Array)g=i.BYTE;else if(d instanceof Uint8Array)g=i.UNSIGNED_BYTE;else if(d instanceof Uint8ClampedArray)g=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+d);return{buffer:m,type:g,bytesPerElement:d.BYTES_PER_ELEMENT,version:l.version}}function r(l,h,d){let u=h.array,m=h.updateRange;i.bindBuffer(d,l),m.count===-1?i.bufferSubData(d,0,u):(e?i.bufferSubData(d,m.offset*u.BYTES_PER_ELEMENT,u,m.offset,m.count):i.bufferSubData(d,m.offset*u.BYTES_PER_ELEMENT,u.subarray(m.offset,m.offset+m.count)),m.count=-1),h.onUploadCallback()}function a(l){return l.isInterleavedBufferAttribute&&(l=l.data),n.get(l)}function o(l){l.isInterleavedBufferAttribute&&(l=l.data);let h=n.get(l);h&&(i.deleteBuffer(h.buffer),n.delete(l))}function c(l,h){if(l.isGLBufferAttribute){let u=n.get(l);(!u||u.version 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif`,Oh=`#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif`,Bh=`#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif`,zh=`#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif`,Vh=`#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif`,kh=`#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif`,Hh=`#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif`,Gh=`#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif`,Wh=`#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated`,Xh=`#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif`,qh=`vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif`,Yh=`#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif`,Zh=`#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif`,Jh=`#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif`,$h=`#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif`,Kh="gl_FragColor = linearToOutputTexel( gl_FragColor );",Qh=`vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}`,jh=`#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif`,tu=`#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif`,eu=`#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif`,nu=`#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif`,iu=`#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif`,su=`#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif`,ru=`#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif`,ou=`#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif`,au=`#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif`,cu=`#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}`,lu=`#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif`,hu=`#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif`,uu=`LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;`,fu=`varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert`,du=`uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif`,pu=`#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif`,mu=`ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;`,gu=`varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon`,_u=`BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;`,xu=`varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong`,yu=`PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tanisotropyV /= material.anisotropy;\n\tmaterial.anisotropy = saturate( material.anisotropy );\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;\n#endif`,vu=`struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}`,Mu=`\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif`,Su=`#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif`,bu=`#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif`,Eu=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif`,Tu=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif`,wu=`#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif`,Au=`#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif`,Ru=`#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vMapUv );\n#endif`,Cu=`#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif`,Pu=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif`,Lu=`#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif`,Iu=`float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif`,Uu=`#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif`,Du=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif`,Nu=`#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif`,Fu=`#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif`,Ou=`#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif`,Bu=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 geometryNormal = normal;`,zu=`#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif`,Vu=`#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif`,ku=`#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif`,Hu=`#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif`,Gu=`#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif`,Wu=`#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif`,Xu=`#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif`,qu=`#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif`,Yu=`#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif`,Zu=`#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Ju=`vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}`,$u=`#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif`,Ku=`vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;`,Qu=`#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif`,ju=`#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif`,tf=`float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif`,ef=`#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif`,nf=`#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif`,sf=`#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif`,rf=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif`,of=`float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}`,af=`#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif`,cf=`#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif`,lf=`#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif`,hf=`#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif`,uf=`float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif`,ff=`#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif`,df=`#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif`,pf=`#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }`,mf=`#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif`,gf=`#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif`,_f=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif`,xf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif`,yf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif`,vf=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif`,Mf=`varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}`,Sf=`uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}`,bf=`varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}`,Ef=`#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}`,Tf=`varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}`,wf=`uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}`,Af=`#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}`,Rf=`#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}`,Cf=`#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}`,Pf=`#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}`,Lf=`varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}`,If=`uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}`,Uf=`uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Df=`uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Nf=`#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Ff=`uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Of=`#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}`,Bf=`#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,zf=`#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}`,Vf=`#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,kf=`#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}`,Hf=`#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}`,Gf=`#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}`,Wf=`#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Xf=`#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}`,qf=`#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Yf=`#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}`,Zf=`#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Jf=`uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}`,$f=`uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Kf=`#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Qf=`uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}`,jf=`uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}`,td=`uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}`,At={alphahash_fragment:bh,alphahash_pars_fragment:Eh,alphamap_fragment:Th,alphamap_pars_fragment:wh,alphatest_fragment:Ah,alphatest_pars_fragment:Rh,aomap_fragment:Ch,aomap_pars_fragment:Ph,begin_vertex:Lh,beginnormal_vertex:Ih,bsdfs:Uh,iridescence_fragment:Dh,bumpmap_pars_fragment:Nh,clipping_planes_fragment:Fh,clipping_planes_pars_fragment:Oh,clipping_planes_pars_vertex:Bh,clipping_planes_vertex:zh,color_fragment:Vh,color_pars_fragment:kh,color_pars_vertex:Hh,color_vertex:Gh,common:Wh,cube_uv_reflection_fragment:Xh,defaultnormal_vertex:qh,displacementmap_pars_vertex:Yh,displacementmap_vertex:Zh,emissivemap_fragment:Jh,emissivemap_pars_fragment:$h,colorspace_fragment:Kh,colorspace_pars_fragment:Qh,envmap_fragment:jh,envmap_common_pars_fragment:tu,envmap_pars_fragment:eu,envmap_pars_vertex:nu,envmap_physical_pars_fragment:pu,envmap_vertex:iu,fog_vertex:su,fog_pars_vertex:ru,fog_fragment:ou,fog_pars_fragment:au,gradientmap_pars_fragment:cu,lightmap_fragment:lu,lightmap_pars_fragment:hu,lights_lambert_fragment:uu,lights_lambert_pars_fragment:fu,lights_pars_begin:du,lights_toon_fragment:mu,lights_toon_pars_fragment:gu,lights_phong_fragment:_u,lights_phong_pars_fragment:xu,lights_physical_fragment:yu,lights_physical_pars_fragment:vu,lights_fragment_begin:Mu,lights_fragment_maps:Su,lights_fragment_end:bu,logdepthbuf_fragment:Eu,logdepthbuf_pars_fragment:Tu,logdepthbuf_pars_vertex:wu,logdepthbuf_vertex:Au,map_fragment:Ru,map_pars_fragment:Cu,map_particle_fragment:Pu,map_particle_pars_fragment:Lu,metalnessmap_fragment:Iu,metalnessmap_pars_fragment:Uu,morphcolor_vertex:Du,morphnormal_vertex:Nu,morphtarget_pars_vertex:Fu,morphtarget_vertex:Ou,normal_fragment_begin:Bu,normal_fragment_maps:zu,normal_pars_fragment:Vu,normal_pars_vertex:ku,normal_vertex:Hu,normalmap_pars_fragment:Gu,clearcoat_normal_fragment_begin:Wu,clearcoat_normal_fragment_maps:Xu,clearcoat_pars_fragment:qu,iridescence_pars_fragment:Yu,opaque_fragment:Zu,packing:Ju,premultiplied_alpha_fragment:$u,project_vertex:Ku,dithering_fragment:Qu,dithering_pars_fragment:ju,roughnessmap_fragment:tf,roughnessmap_pars_fragment:ef,shadowmap_pars_fragment:nf,shadowmap_pars_vertex:sf,shadowmap_vertex:rf,shadowmask_pars_fragment:of,skinbase_vertex:af,skinning_pars_vertex:cf,skinning_vertex:lf,skinnormal_vertex:hf,specularmap_fragment:uf,specularmap_pars_fragment:ff,tonemapping_fragment:df,tonemapping_pars_fragment:pf,transmission_fragment:mf,transmission_pars_fragment:gf,uv_pars_fragment:_f,uv_pars_vertex:xf,uv_vertex:yf,worldpos_vertex:vf,background_vert:Mf,background_frag:Sf,backgroundCube_vert:bf,backgroundCube_frag:Ef,cube_vert:Tf,cube_frag:wf,depth_vert:Af,depth_frag:Rf,distanceRGBA_vert:Cf,distanceRGBA_frag:Pf,equirect_vert:Lf,equirect_frag:If,linedashed_vert:Uf,linedashed_frag:Df,meshbasic_vert:Nf,meshbasic_frag:Ff,meshlambert_vert:Of,meshlambert_frag:Bf,meshmatcap_vert:zf,meshmatcap_frag:Vf,meshnormal_vert:kf,meshnormal_frag:Hf,meshphong_vert:Gf,meshphong_frag:Wf,meshphysical_vert:Xf,meshphysical_frag:qf,meshtoon_vert:Yf,meshtoon_frag:Zf,points_vert:Jf,points_frag:$f,shadow_vert:Kf,shadow_frag:Qf,sprite_vert:jf,sprite_frag:td},et={common:{diffuse:{value:new kt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ct},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ct}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ct}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ct}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ct},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ct},normalScale:{value:new Dt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ct},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ct}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ct}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ct}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new kt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new kt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0},uvTransform:{value:new Ct}},sprite:{diffuse:{value:new kt(16777215)},opacity:{value:1},center:{value:new Dt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ct},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0}}},Ye={basic:{uniforms:de([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.fog]),vertexShader:At.meshbasic_vert,fragmentShader:At.meshbasic_frag},lambert:{uniforms:de([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.fog,et.lights,{emissive:{value:new kt(0)}}]),vertexShader:At.meshlambert_vert,fragmentShader:At.meshlambert_frag},phong:{uniforms:de([et.common,et.specularmap,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.fog,et.lights,{emissive:{value:new kt(0)},specular:{value:new kt(1118481)},shininess:{value:30}}]),vertexShader:At.meshphong_vert,fragmentShader:At.meshphong_frag},standard:{uniforms:de([et.common,et.envmap,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.roughnessmap,et.metalnessmap,et.fog,et.lights,{emissive:{value:new kt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:At.meshphysical_vert,fragmentShader:At.meshphysical_frag},toon:{uniforms:de([et.common,et.aomap,et.lightmap,et.emissivemap,et.bumpmap,et.normalmap,et.displacementmap,et.gradientmap,et.fog,et.lights,{emissive:{value:new kt(0)}}]),vertexShader:At.meshtoon_vert,fragmentShader:At.meshtoon_frag},matcap:{uniforms:de([et.common,et.bumpmap,et.normalmap,et.displacementmap,et.fog,{matcap:{value:null}}]),vertexShader:At.meshmatcap_vert,fragmentShader:At.meshmatcap_frag},points:{uniforms:de([et.points,et.fog]),vertexShader:At.points_vert,fragmentShader:At.points_frag},dashed:{uniforms:de([et.common,et.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:At.linedashed_vert,fragmentShader:At.linedashed_frag},depth:{uniforms:de([et.common,et.displacementmap]),vertexShader:At.depth_vert,fragmentShader:At.depth_frag},normal:{uniforms:de([et.common,et.bumpmap,et.normalmap,et.displacementmap,{opacity:{value:1}}]),vertexShader:At.meshnormal_vert,fragmentShader:At.meshnormal_frag},sprite:{uniforms:de([et.sprite,et.fog]),vertexShader:At.sprite_vert,fragmentShader:At.sprite_frag},background:{uniforms:{uvTransform:{value:new Ct},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:At.background_vert,fragmentShader:At.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:At.backgroundCube_vert,fragmentShader:At.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:At.cube_vert,fragmentShader:At.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:At.equirect_vert,fragmentShader:At.equirect_frag},distanceRGBA:{uniforms:de([et.common,et.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:At.distanceRGBA_vert,fragmentShader:At.distanceRGBA_frag},shadow:{uniforms:de([et.lights,et.fog,{color:{value:new kt(0)},opacity:{value:1}}]),vertexShader:At.shadow_vert,fragmentShader:At.shadow_frag}};Ye.physical={uniforms:de([Ye.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ct},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ct},clearcoatNormalScale:{value:new Dt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ct},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ct},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ct},sheen:{value:0},sheenColor:{value:new kt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ct},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ct},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ct},transmissionSamplerSize:{value:new Dt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ct},attenuationDistance:{value:0},attenuationColor:{value:new kt(0)},specularColor:{value:new kt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ct},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ct},anisotropyVector:{value:new Dt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ct}}]),vertexShader:At.meshphysical_vert,fragmentShader:At.meshphysical_frag};var ys={r:0,b:0,g:0};function ed(i,t,e,n,s,r,a){let o=new kt(0),c=r===!0?0:1,l,h,d=null,u=0,m=null;function g(p,f){let v=!1,_=f.isScene===!0?f.background:null;switch(_&&_.isTexture&&(_=(f.backgroundBlurriness>0?e:t).get(_)),_===null?x(o,c):_&&_.isColor&&(x(_,1),v=!0),i.xr.getEnvironmentBlendMode()){case"opaque":v=!0;break;case"additive":n.buffers.color.setClear(0,0,0,1,a),v=!0;break;case"alpha-blend":n.buffers.color.setClear(0,0,0,0,a),v=!0;break}(i.autoClear||v)&&i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil),_&&(_.isCubeTexture||_.mapping===Bs)?(h===void 0&&(h=new Ze(new kn(1,1,1),new un({name:"BackgroundCubeMaterial",uniforms:vi(Ye.backgroundCube.uniforms),vertexShader:Ye.backgroundCube.vertexShader,fragmentShader:Ye.backgroundCube.fragmentShader,side:he,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(T,A,L){this.matrixWorld.copyPosition(L.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),h.material.uniforms.envMap.value=_,h.material.uniforms.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=f.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=f.backgroundIntensity,h.material.toneMapped=_.colorSpace!==Rt,(d!==_||u!==_.version||m!==i.toneMapping)&&(h.material.needsUpdate=!0,d=_,u=_.version,m=i.toneMapping),h.layers.enableAll(),p.unshift(h,h.geometry,h.material,0,0,null)):_&&_.isTexture&&(l===void 0&&(l=new Ze(new Gi(2,2),new un({name:"BackgroundMaterial",uniforms:vi(Ye.background.uniforms),vertexShader:Ye.background.vertexShader,fragmentShader:Ye.background.fragmentShader,side:Ue,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(l)),l.material.uniforms.t2D.value=_,l.material.uniforms.backgroundIntensity.value=f.backgroundIntensity,l.material.toneMapped=_.colorSpace!==Rt,_.matrixAutoUpdate===!0&&_.updateMatrix(),l.material.uniforms.uvTransform.value.copy(_.matrix),(d!==_||u!==_.version||m!==i.toneMapping)&&(l.material.needsUpdate=!0,d=_,u=_.version,m=i.toneMapping),l.layers.enableAll(),p.unshift(l,l.geometry,l.material,0,0,null))}function x(p,f){p.getRGB(ys,Mc(i)),n.buffers.color.setClear(ys.r,ys.g,ys.b,f,a)}return{getClearColor:function(){return o},setClearColor:function(p,f=1){o.set(p),c=f,x(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(p){c=p,x(o,c)},render:g}}function nd(i,t,e,n){let s=i.getParameter(i.MAX_VERTEX_ATTRIBS),r=n.isWebGL2?null:t.get("OES_vertex_array_object"),a=n.isWebGL2||r!==null,o={},c=p(null),l=c,h=!1;function d(D,O,$,k,X){let J=!1;if(a){let K=x(k,$,O);l!==K&&(l=K,m(l.object)),J=f(D,k,$,X),J&&v(D,k,$,X)}else{let K=O.wireframe===!0;(l.geometry!==k.id||l.program!==$.id||l.wireframe!==K)&&(l.geometry=k.id,l.program=$.id,l.wireframe=K,J=!0)}X!==null&&e.update(X,i.ELEMENT_ARRAY_BUFFER),(J||h)&&(h=!1,L(D,O,$,k),X!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(X).buffer))}function u(){return n.isWebGL2?i.createVertexArray():r.createVertexArrayOES()}function m(D){return n.isWebGL2?i.bindVertexArray(D):r.bindVertexArrayOES(D)}function g(D){return n.isWebGL2?i.deleteVertexArray(D):r.deleteVertexArrayOES(D)}function x(D,O,$){let k=$.wireframe===!0,X=o[D.id];X===void 0&&(X={},o[D.id]=X);let J=X[O.id];J===void 0&&(J={},X[O.id]=J);let K=J[k];return K===void 0&&(K=p(u()),J[k]=K),K}function p(D){let O=[],$=[],k=[];for(let X=0;X=0){let at=X[Z],ct=J[Z];if(ct===void 0&&(Z==="instanceMatrix"&&D.instanceMatrix&&(ct=D.instanceMatrix),Z==="instanceColor"&&D.instanceColor&&(ct=D.instanceColor)),at===void 0||at.attribute!==ct||ct&&at.data!==ct.data)return!0;K++}return l.attributesNum!==K||l.index!==k}function v(D,O,$,k){let X={},J=O.attributes,K=0,B=$.getAttributes();for(let Z in B)if(B[Z].location>=0){let at=J[Z];at===void 0&&(Z==="instanceMatrix"&&D.instanceMatrix&&(at=D.instanceMatrix),Z==="instanceColor"&&D.instanceColor&&(at=D.instanceColor));let ct={};ct.attribute=at,at&&at.data&&(ct.data=at.data),X[Z]=ct,K++}l.attributes=X,l.attributesNum=K,l.index=k}function _(){let D=l.newAttributes;for(let O=0,$=D.length;O<$;O++)D[O]=0}function b(D){M(D,0)}function M(D,O){let $=l.newAttributes,k=l.enabledAttributes,X=l.attributeDivisors;$[D]=1,k[D]===0&&(i.enableVertexAttribArray(D),k[D]=1),X[D]!==O&&((n.isWebGL2?i:t.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](D,O),X[D]=O)}function T(){let D=l.newAttributes,O=l.enabledAttributes;for(let $=0,k=O.length;$=0){let ot=X[B];if(ot===void 0&&(B==="instanceMatrix"&&D.instanceMatrix&&(ot=D.instanceMatrix),B==="instanceColor"&&D.instanceColor&&(ot=D.instanceColor)),ot!==void 0){let at=ot.normalized,ct=ot.itemSize,gt=e.get(ot);if(gt===void 0)continue;let Tt=gt.buffer,xt=gt.type,zt=gt.bytesPerElement,xe=n.isWebGL2===!0&&(xt===i.INT||xt===i.UNSIGNED_INT||ot.gpuType===uc);if(ot.isInterleavedBufferAttribute){let Ut=ot.data,F=Ut.stride,oe=ot.offset;if(Ut.isInstancedInterleavedBuffer){for(let yt=0;yt0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=typeof WebGL2RenderingContext!="undefined"&&i.constructor.name==="WebGL2RenderingContext",o=e.precision!==void 0?e.precision:"highp",c=r(o);c!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",c,"instead."),o=c);let l=a||t.has("WEBGL_draw_buffers"),h=e.logarithmicDepthBuffer===!0,d=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),u=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=i.getParameter(i.MAX_TEXTURE_SIZE),g=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),x=i.getParameter(i.MAX_VERTEX_ATTRIBS),p=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),f=i.getParameter(i.MAX_VARYING_VECTORS),v=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),_=u>0,b=a||t.has("OES_texture_float"),M=_&&b,T=a?i.getParameter(i.MAX_SAMPLES):0;return{isWebGL2:a,drawBuffers:l,getMaxAnisotropy:s,getMaxPrecision:r,precision:o,logarithmicDepthBuffer:h,maxTextures:d,maxVertexTextures:u,maxTextureSize:m,maxCubemapSize:g,maxAttributes:x,maxVertexUniforms:p,maxVaryings:f,maxFragmentUniforms:v,vertexTextures:_,floatFragmentTextures:b,floatVertexTextures:M,maxSamples:T}}function rd(i){let t=this,e=null,n=0,s=!1,r=!1,a=new Ce,o=new Ct,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){let m=d.length!==0||u||n!==0||s;return s=u,n=d.length,m},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){e=h(d,u,0)},this.setState=function(d,u,m){let g=d.clippingPlanes,x=d.clipIntersection,p=d.clipShadows,f=i.get(d);if(!s||g===null||g.length===0||r&&!p)r?h(null):l();else{let v=r?0:n,_=v*4,b=f.clippingState||null;c.value=b,b=h(g,u,_,m);for(let M=0;M!==_;++M)b[M]=e[M];f.clippingState=b,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=v}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(d,u,m,g){let x=d!==null?d.length:0,p=null;if(x!==0){if(p=c.value,g!==!0||p===null){let f=m+x*4,v=u.matrixWorldInverse;o.getNormalMatrix(v),(p===null||p.length0){let l=new Hr(c.height/2);return l.fromEquirectangularTexture(i,a),t.set(a,l),a.addEventListener("dispose",s),e(l.texture,a.mapping)}else return null}}return a}function s(a){let o=a.target;o.removeEventListener("dispose",s);let c=t.get(o);c!==void 0&&(t.delete(o),c.dispose())}function r(){t=new WeakMap}return{get:n,dispose:r}}var Gr=class extends Ds{constructor(t=-1,e=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2,r=n-t,a=n+t,o=s+e,c=s-e;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}},hi=4,Ba=[.125,.215,.35,.446,.526,.582],Nn=20,Rr=new Gr,za=new kt,Cr=null,Dn=(1+Math.sqrt(5))/2,ci=1/Dn,Va=[new P(1,1,1),new P(-1,1,1),new P(1,1,-1),new P(-1,1,-1),new P(0,Dn,ci),new P(0,Dn,-ci),new P(ci,0,Dn),new P(-ci,0,Dn),new P(Dn,ci,0),new P(-Dn,ci,0)],Os=class{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,s=100){Cr=this._renderer.getRenderTarget(),this._setSize(256);let r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,n,s,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Ga(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ha(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t2?_:0,_,_),h.setRenderTarget(s),x&&h.render(g,o),h.render(t,o)}g.geometry.dispose(),g.material.dispose(),h.toneMapping=u,h.autoClear=d,t.background=p}_textureToCubeUV(t,e){let n=this._renderer,s=t.mapping===mi||t.mapping===gi;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Ga()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ha());let r=s?this._cubemapMaterial:this._equirectMaterial,a=new Ze(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=t;let c=this._cubeSize;vs(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(a,Rr)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;for(let s=1;sNn&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${Nn}`);let f=[],v=0;for(let A=0;A_-hi?s-_+hi:0),T=4*(this._cubeSize-b);vs(e,M,T,3*b,2*b),c.setRenderTarget(e),c.render(d,Rr)}};function ad(i){let t=[],e=[],n=[],s=i,r=i-hi+1+Ba.length;for(let a=0;ai-hi?c=Ba[a-i+hi-1]:a===0&&(c=0),n.push(c);let l=1/(o-2),h=-l,d=1+l,u=[h,h,d,h,d,d,h,h,d,d,h,d],m=6,g=6,x=3,p=2,f=1,v=new Float32Array(x*g*m),_=new Float32Array(p*g*m),b=new Float32Array(f*g*m);for(let T=0;T2?0:-1,y=[A,L,0,A+2/3,L,0,A+2/3,L+1,0,A,L,0,A+2/3,L+1,0,A,L+1,0];v.set(y,x*g*T),_.set(u,p*g*T);let w=[T,T,T,T,T,T];b.set(w,f*g*T)}let M=new Ge;M.setAttribute("position",new Qt(v,x)),M.setAttribute("uv",new Qt(_,p)),M.setAttribute("faceIndex",new Qt(b,f)),t.push(M),s>hi&&s--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function ka(i,t,e){let n=new hn(i,t,e);return n.texture.mapping=Bs,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function vs(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function cd(i,t,e){let n=new Float32Array(Nn),s=new P(0,1,0);return new un({name:"SphericalGaussianBlur",defines:{n:Nn,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:go(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues\' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t`,blending:Mn,depthTest:!1,depthWrite:!1})}function Ha(){return new un({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:go(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t`,blending:Mn,depthTest:!1,depthWrite:!1})}function Ga(){return new un({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:go(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t`,blending:Mn,depthTest:!1,depthWrite:!1})}function go(){return`\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t`}function ld(i){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){let c=o.mapping,l=c===Ir||c===Ur,h=c===mi||c===gi;if(l||h)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let d=t.get(o);return e===null&&(e=new Os(i)),d=l?e.fromEquirectangular(o,d):e.fromCubemap(o,d),t.set(o,d),d.texture}else{if(t.has(o))return t.get(o).texture;{let d=o.image;if(l&&d&&d.height>0||h&&d&&s(d)){e===null&&(e=new Os(i));let u=l?e.fromEquirectangular(o):e.fromCubemap(o);return t.set(o,u),o.addEventListener("dispose",r),u.texture}else return null}}}return o}function s(o){let c=0,l=6;for(let h=0;ht.maxTextureSize&&(w=Math.ceil(y/t.maxTextureSize),y=t.maxTextureSize);let z=new Float32Array(y*w*4*g),q=new Cs(z,y,w,g);q.type=vn,q.needsUpdate=!0;let I=L*4;for(let O=0;O0)return i;let s=t*e,r=Wa[s];if(r===void 0&&(r=new Float32Array(s),Wa[s]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,i[a].toArray(r,o)}return r}function jt(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e":" "} ${o}: ${e[a]}`)}return n.join(`\n`)}function ap(i){switch(i){case Je:return["Linear","( value )"];case Rt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",i),["Linear","( value )"]}}function Ka(i,t,e){let n=i.getShaderParameter(t,i.COMPILE_STATUS),s=i.getShaderInfoLog(t).trim();if(n&&s==="")return"";let r=/ERROR: 0:(\\d+)/.exec(s);if(r){let a=parseInt(r[1]);return e.toUpperCase()+`\n\n`+s+`\n\n`+op(i.getShaderSource(t),a)}else return s}function cp(i,t){let e=ap(t);return"vec4 "+i+"( vec4 value ) { return LinearTo"+e[0]+e[1]+"; }"}function lp(i,t){let e;switch(t){case bl:e="Linear";break;case El:e="Reinhard";break;case Tl:e="OptimizedCineon";break;case wl:e="ACESFilmic";break;case Al:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}function hp(i){return[i.extensionDerivatives||i.envMapCubeUVHeight||i.bumpMap||i.normalMapTangentSpace||i.clearcoatNormalMap||i.flatShading||i.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(i.extensionFragDepth||i.logarithmicDepthBuffer)&&i.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",i.extensionDrawBuffers&&i.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(i.extensionShaderTextureLOD||i.envMap||i.transmission)&&i.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Bi).join(`\n`)}function up(i){let t=[];for(let e in i){let n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`\n`)}function fp(i,t){let e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function Yr(i){return i.replace(dp,mp)}var pp=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function mp(i,t){let e=At[t];if(e===void 0){let n=pp.get(t);if(n!==void 0)e=At[n],console.warn(\'THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.\',t,n);else throw new Error("Can not resolve #include <"+t+">")}return Yr(e)}var gp=/#pragma unroll_loop_start\\s+for\\s*\\(\\s*int\\s+i\\s*=\\s*(\\d+)\\s*;\\s*i\\s*<\\s*(\\d+)\\s*;\\s*i\\s*\\+\\+\\s*\\)\\s*{([\\s\\S]+?)}\\s+#pragma unroll_loop_end/g;function tc(i){return i.replace(gp,_p)}function _p(i,t,e,n){let s="";for(let r=parseInt(t);r0&&(p+=`\n`),f=[m,"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(Bi).join(`\n`),f.length>0&&(f+=`\n`)):(p=[ec(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors&&e.isWebGL2?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.useLegacyLights?"#define LEGACY_LIGHTS":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.logarithmicDepthBuffer&&e.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`\n`].filter(Bi).join(`\n`),f=[m,ec(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+l:"",e.envMap?"#define "+h:"",e.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.useLegacyLights?"#define LEGACY_LIGHTS":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.logarithmicDepthBuffer&&e.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==cn?"#define TONE_MAPPING":"",e.toneMapping!==cn?At.tonemapping_pars_fragment:"",e.toneMapping!==cn?lp("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",At.colorspace_pars_fragment,cp("linearToOutputTexel",e.outputColorSpace),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`\n`].filter(Bi).join(`\n`)),a=Yr(a),a=Qa(a,e),a=ja(a,e),o=Yr(o),o=Qa(o,e),o=ja(o,e),a=tc(a),o=tc(o),e.isWebGL2&&e.isRawShaderMaterial!==!0&&(v=`#version 300 es\n`,p=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`\n`)+`\n`+p,f=["#define varying in",e.glslVersion===Ma?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Ma?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`\n`)+`\n`+f);let _=v+p+a,b=v+f+o,M=$a(s,s.VERTEX_SHADER,_),T=$a(s,s.FRAGMENT_SHADER,b);if(s.attachShader(x,M),s.attachShader(x,T),e.index0AttributeName!==void 0?s.bindAttribLocation(x,0,e.index0AttributeName):e.morphTargets===!0&&s.bindAttribLocation(x,0,"position"),s.linkProgram(x),i.debug.checkShaderErrors){let y=s.getProgramInfoLog(x).trim(),w=s.getShaderInfoLog(M).trim(),z=s.getShaderInfoLog(T).trim(),q=!0,I=!0;if(s.getProgramParameter(x,s.LINK_STATUS)===!1)if(q=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,x,M,T);else{let D=Ka(s,M,"vertex"),O=Ka(s,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(x,s.VALIDATE_STATUS)+`\n\nProgram Info Log: `+y+`\n`+D+`\n`+O)}else y!==""?console.warn("THREE.WebGLProgram: Program Info Log:",y):(w===""||z==="")&&(I=!1);I&&(this.diagnostics={runnable:q,programLog:y,vertexShader:{log:w,prefix:p},fragmentShader:{log:z,prefix:f}})}s.deleteShader(M),s.deleteShader(T);let A;this.getUniforms=function(){return A===void 0&&(A=new pi(s,x)),A};let L;return this.getAttributes=function(){return L===void 0&&(L=fp(s,x)),L},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=rp++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=M,this.fragmentShader=T,this}var Ep=0,Zr=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let e=t.vertexShader,n=t.fragmentShader,s=this._getShaderStage(e),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return a.has(s)===!1&&(a.add(s),s.usedTimes++),a.has(r)===!1&&(a.add(r),r.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){let e=this.shaderCache,n=e.get(t);return n===void 0&&(n=new Jr(t),e.set(t,n)),n}},Jr=class{constructor(t){this.id=Ep++,this.code=t,this.usedTimes=0}};function Tp(i,t,e,n,s,r,a){let o=new Ps,c=new Zr,l=[],h=s.isWebGL2,d=s.logarithmicDepthBuffer,u=s.vertexTextures,m=s.precision,g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function x(y){return y===0?"uv":`uv${y}`}function p(y,w,z,q,I){let D=q.fog,O=I.geometry,$=y.isMeshStandardMaterial?q.environment:null,k=(y.isMeshStandardMaterial?e:t).get(y.envMap||$),X=k&&k.mapping===Bs?k.image.height:null,J=g[y.type];y.precision!==null&&(m=s.getMaxPrecision(y.precision),m!==y.precision&&console.warn("THREE.WebGLProgram.getParameters:",y.precision,"not supported, using",m,"instead."));let K=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,B=K!==void 0?K.length:0,Z=0;O.morphAttributes.position!==void 0&&(Z=1),O.morphAttributes.normal!==void 0&&(Z=2),O.morphAttributes.color!==void 0&&(Z=3);let ot,at,ct,gt;if(J){let Xe=Ye[J];ot=Xe.vertexShader,at=Xe.fragmentShader}else ot=y.vertexShader,at=y.fragmentShader,c.update(y),ct=c.getVertexShaderID(y),gt=c.getFragmentShaderID(y);let Tt=i.getRenderTarget(),xt=I.isInstancedMesh===!0,zt=!!y.map,xe=!!y.matcap,Ut=!!k,F=!!y.aoMap,oe=!!y.lightMap,yt=!!y.bumpMap,wt=!!y.normalMap,bt=!!y.displacementMap,Xt=!!y.emissiveMap,Nt=!!y.metalnessMap,Pt=!!y.roughnessMap,Vt=y.anisotropy>0,re=y.clearcoat>0,ae=y.iridescence>0,R=y.sheen>0,S=y.transmission>0,G=Vt&&!!y.anisotropyMap,Q=re&&!!y.clearcoatMap,j=re&&!!y.clearcoatNormalMap,it=re&&!!y.clearcoatRoughnessMap,dt=ae&&!!y.iridescenceMap,st=ae&&!!y.iridescenceThicknessMap,Y=R&&!!y.sheenColorMap,pt=R&&!!y.sheenRoughnessMap,mt=!!y.specularMap,_t=!!y.specularColorMap,ht=!!y.specularIntensityMap,ut=S&&!!y.transmissionMap,It=S&&!!y.thicknessMap,Ht=!!y.gradientMap,C=!!y.alphaMap,nt=y.alphaTest>0,V=!!y.alphaHash,tt=!!y.extensions,rt=!!O.attributes.uv1,Ot=!!O.attributes.uv2,qt=!!O.attributes.uv3;return{isWebGL2:h,shaderID:J,shaderType:y.type,shaderName:y.name,vertexShader:ot,fragmentShader:at,defines:y.defines,customVertexShaderID:ct,customFragmentShaderID:gt,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:m,instancing:xt,instancingColor:xt&&I.instanceColor!==null,supportsVertexTextures:u,outputColorSpace:Tt===null?i.outputColorSpace:Tt.isXRRenderTarget===!0?Tt.texture.colorSpace:Je,map:zt,matcap:xe,envMap:Ut,envMapMode:Ut&&k.mapping,envMapCubeUVHeight:X,aoMap:F,lightMap:oe,bumpMap:yt,normalMap:wt,displacementMap:u&&bt,emissiveMap:Xt,normalMapObjectSpace:wt&&y.normalMapType===kl,normalMapTangentSpace:wt&&y.normalMapType===Vl,metalnessMap:Nt,roughnessMap:Pt,anisotropy:Vt,anisotropyMap:G,clearcoat:re,clearcoatMap:Q,clearcoatNormalMap:j,clearcoatRoughnessMap:it,iridescence:ae,iridescenceMap:dt,iridescenceThicknessMap:st,sheen:R,sheenColorMap:Y,sheenRoughnessMap:pt,specularMap:mt,specularColorMap:_t,specularIntensityMap:ht,transmission:S,transmissionMap:ut,thicknessMap:It,gradientMap:Ht,opaque:y.transparent===!1&&y.blending===fi,alphaMap:C,alphaTest:nt,alphaHash:V,combine:y.combine,mapUv:zt&&x(y.map.channel),aoMapUv:F&&x(y.aoMap.channel),lightMapUv:oe&&x(y.lightMap.channel),bumpMapUv:yt&&x(y.bumpMap.channel),normalMapUv:wt&&x(y.normalMap.channel),displacementMapUv:bt&&x(y.displacementMap.channel),emissiveMapUv:Xt&&x(y.emissiveMap.channel),metalnessMapUv:Nt&&x(y.metalnessMap.channel),roughnessMapUv:Pt&&x(y.roughnessMap.channel),anisotropyMapUv:G&&x(y.anisotropyMap.channel),clearcoatMapUv:Q&&x(y.clearcoatMap.channel),clearcoatNormalMapUv:j&&x(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:it&&x(y.clearcoatRoughnessMap.channel),iridescenceMapUv:dt&&x(y.iridescenceMap.channel),iridescenceThicknessMapUv:st&&x(y.iridescenceThicknessMap.channel),sheenColorMapUv:Y&&x(y.sheenColorMap.channel),sheenRoughnessMapUv:pt&&x(y.sheenRoughnessMap.channel),specularMapUv:mt&&x(y.specularMap.channel),specularColorMapUv:_t&&x(y.specularColorMap.channel),specularIntensityMapUv:ht&&x(y.specularIntensityMap.channel),transmissionMapUv:ut&&x(y.transmissionMap.channel),thicknessMapUv:It&&x(y.thicknessMap.channel),alphaMapUv:C&&x(y.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(wt||Vt),vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,vertexUv1s:rt,vertexUv2s:Ot,vertexUv3s:qt,pointsUvs:I.isPoints===!0&&!!O.attributes.uv&&(zt||C),fog:!!D,useFog:y.fog===!0,fogExp2:D&&D.isFogExp2,flatShading:y.flatShading===!0,sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:I.isSkinnedMesh===!0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:B,morphTextureStride:Z,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:y.dithering,shadowMapEnabled:i.shadowMap.enabled&&z.length>0,shadowMapType:i.shadowMap.type,toneMapping:y.toneMapped?i.toneMapping:cn,useLegacyLights:i.useLegacyLights,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===Le,flipSided:y.side===he,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionDerivatives:tt&&y.extensions.derivatives===!0,extensionFragDepth:tt&&y.extensions.fragDepth===!0,extensionDrawBuffers:tt&&y.extensions.drawBuffers===!0,extensionShaderTextureLOD:tt&&y.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:h||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||n.has("EXT_shader_texture_lod"),customProgramCacheKey:y.customProgramCacheKey()}}function f(y){let w=[];if(y.shaderID?w.push(y.shaderID):(w.push(y.customVertexShaderID),w.push(y.customFragmentShaderID)),y.defines!==void 0)for(let z in y.defines)w.push(z),w.push(y.defines[z]);return y.isRawShaderMaterial===!1&&(v(w,y),_(w,y),w.push(i.outputColorSpace)),w.push(y.customProgramCacheKey),w.join()}function v(y,w){y.push(w.precision),y.push(w.outputColorSpace),y.push(w.envMapMode),y.push(w.envMapCubeUVHeight),y.push(w.mapUv),y.push(w.alphaMapUv),y.push(w.lightMapUv),y.push(w.aoMapUv),y.push(w.bumpMapUv),y.push(w.normalMapUv),y.push(w.displacementMapUv),y.push(w.emissiveMapUv),y.push(w.metalnessMapUv),y.push(w.roughnessMapUv),y.push(w.anisotropyMapUv),y.push(w.clearcoatMapUv),y.push(w.clearcoatNormalMapUv),y.push(w.clearcoatRoughnessMapUv),y.push(w.iridescenceMapUv),y.push(w.iridescenceThicknessMapUv),y.push(w.sheenColorMapUv),y.push(w.sheenRoughnessMapUv),y.push(w.specularMapUv),y.push(w.specularColorMapUv),y.push(w.specularIntensityMapUv),y.push(w.transmissionMapUv),y.push(w.thicknessMapUv),y.push(w.combine),y.push(w.fogExp2),y.push(w.sizeAttenuation),y.push(w.morphTargetsCount),y.push(w.morphAttributeCount),y.push(w.numDirLights),y.push(w.numPointLights),y.push(w.numSpotLights),y.push(w.numSpotLightMaps),y.push(w.numHemiLights),y.push(w.numRectAreaLights),y.push(w.numDirLightShadows),y.push(w.numPointLightShadows),y.push(w.numSpotLightShadows),y.push(w.numSpotLightShadowsWithMaps),y.push(w.shadowMapType),y.push(w.toneMapping),y.push(w.numClippingPlanes),y.push(w.numClipIntersection),y.push(w.depthPacking)}function _(y,w){o.disableAll(),w.isWebGL2&&o.enable(0),w.supportsVertexTextures&&o.enable(1),w.instancing&&o.enable(2),w.instancingColor&&o.enable(3),w.matcap&&o.enable(4),w.envMap&&o.enable(5),w.normalMapObjectSpace&&o.enable(6),w.normalMapTangentSpace&&o.enable(7),w.clearcoat&&o.enable(8),w.iridescence&&o.enable(9),w.alphaTest&&o.enable(10),w.vertexColors&&o.enable(11),w.vertexAlphas&&o.enable(12),w.vertexUv1s&&o.enable(13),w.vertexUv2s&&o.enable(14),w.vertexUv3s&&o.enable(15),w.vertexTangents&&o.enable(16),w.anisotropy&&o.enable(17),y.push(o.mask),o.disableAll(),w.fog&&o.enable(0),w.useFog&&o.enable(1),w.flatShading&&o.enable(2),w.logarithmicDepthBuffer&&o.enable(3),w.skinning&&o.enable(4),w.morphTargets&&o.enable(5),w.morphNormals&&o.enable(6),w.morphColors&&o.enable(7),w.premultipliedAlpha&&o.enable(8),w.shadowMapEnabled&&o.enable(9),w.useLegacyLights&&o.enable(10),w.doubleSided&&o.enable(11),w.flipSided&&o.enable(12),w.useDepthPacking&&o.enable(13),w.dithering&&o.enable(14),w.transmission&&o.enable(15),w.sheen&&o.enable(16),w.opaque&&o.enable(17),w.pointsUvs&&o.enable(18),y.push(o.mask)}function b(y){let w=g[y.type],z;if(w){let q=Ye[w];z=_h.clone(q.uniforms)}else z=y.uniforms;return z}function M(y,w){let z;for(let q=0,I=l.length;q0?n.push(f):m.transparent===!0?s.push(f):e.push(f)}function c(d,u,m,g,x,p){let f=a(d,u,m,g,x,p);m.transmission>0?n.unshift(f):m.transparent===!0?s.unshift(f):e.unshift(f)}function l(d,u){e.length>1&&e.sort(d||Ap),n.length>1&&n.sort(u||nc),s.length>1&&s.sort(u||nc)}function h(){for(let d=t,u=i.length;d=r.length?(a=new ic,r.push(a)):a=r[s],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function Cp(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new P,color:new kt};break;case"SpotLight":e={position:new P,direction:new P,color:new kt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new P,color:new kt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new P,skyColor:new kt,groundColor:new kt};break;case"RectAreaLight":e={color:new kt,position:new P,halfWidth:new P,halfHeight:new P};break}return i[t.id]=e,e}}}function Pp(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt};break;case"SpotLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt};break;case"PointLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var Lp=0;function Ip(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function Up(i,t){let e=new Cp,n=Pp(),s={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let h=0;h<9;h++)s.probe.push(new P);let r=new P,a=new Gt,o=new Gt;function c(h,d){let u=0,m=0,g=0;for(let z=0;z<9;z++)s.probe[z].set(0,0,0);let x=0,p=0,f=0,v=0,_=0,b=0,M=0,T=0,A=0,L=0;h.sort(Ip);let y=d===!0?Math.PI:1;for(let z=0,q=h.length;z0&&(t.isWebGL2||i.has("OES_texture_float_linear")===!0?(s.rectAreaLTC1=et.LTC_FLOAT_1,s.rectAreaLTC2=et.LTC_FLOAT_2):i.has("OES_texture_half_float_linear")===!0?(s.rectAreaLTC1=et.LTC_HALF_1,s.rectAreaLTC2=et.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),s.ambient[0]=u,s.ambient[1]=m,s.ambient[2]=g;let w=s.hash;(w.directionalLength!==x||w.pointLength!==p||w.spotLength!==f||w.rectAreaLength!==v||w.hemiLength!==_||w.numDirectionalShadows!==b||w.numPointShadows!==M||w.numSpotShadows!==T||w.numSpotMaps!==A)&&(s.directional.length=x,s.spot.length=f,s.rectArea.length=v,s.point.length=p,s.hemi.length=_,s.directionalShadow.length=b,s.directionalShadowMap.length=b,s.pointShadow.length=M,s.pointShadowMap.length=M,s.spotShadow.length=T,s.spotShadowMap.length=T,s.directionalShadowMatrix.length=b,s.pointShadowMatrix.length=M,s.spotLightMatrix.length=T+A-L,s.spotLightMap.length=A,s.numSpotLightShadowsWithMaps=L,w.directionalLength=x,w.pointLength=p,w.spotLength=f,w.rectAreaLength=v,w.hemiLength=_,w.numDirectionalShadows=b,w.numPointShadows=M,w.numSpotShadows=T,w.numSpotMaps=A,s.version=Lp++)}function l(h,d){let u=0,m=0,g=0,x=0,p=0,f=d.matrixWorldInverse;for(let v=0,_=h.length;v<_;v++){let b=h[v];if(b.isDirectionalLight){let M=s.directional[u];M.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(f),u++}else if(b.isSpotLight){let M=s.spot[g];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(f),M.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(f),g++}else if(b.isRectAreaLight){let M=s.rectArea[x];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(f),o.identity(),a.copy(b.matrixWorld),a.premultiply(f),o.extractRotation(a),M.halfWidth.set(b.width*.5,0,0),M.halfHeight.set(0,b.height*.5,0),M.halfWidth.applyMatrix4(o),M.halfHeight.applyMatrix4(o),x++}else if(b.isPointLight){let M=s.point[m];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(f),m++}else if(b.isHemisphereLight){let M=s.hemi[p];M.direction.setFromMatrixPosition(b.matrixWorld),M.direction.transformDirection(f),p++}}}return{setup:c,setupView:l,state:s}}function sc(i,t){let e=new Up(i,t),n=[],s=[];function r(){n.length=0,s.length=0}function a(d){n.push(d)}function o(d){s.push(d)}function c(d){e.setup(n,d)}function l(d){e.setupView(n,d)}return{init:r,state:{lightsArray:n,shadowsArray:s,lights:e},setupLights:c,setupLightsView:l,pushLight:a,pushShadow:o}}function Dp(i,t){let e=new WeakMap;function n(r,a=0){let o=e.get(r),c;return o===void 0?(c=new sc(i,t),e.set(r,[c])):a>=o.length?(c=new sc(i,t),o.push(c)):c=o[a],c}function s(){e=new WeakMap}return{get:n,dispose:s}}var $r=class extends yi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Bl,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}},Kr=class extends yi{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}},Np=`void main() {\n\tgl_Position = vec4( position, 1.0 );\n}`,Fp=`uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}`;function Op(i,t,e){let n=new Fs,s=new Dt,r=new Dt,a=new Kt,o=new $r({depthPacking:zl}),c=new Kr,l={},h=e.maxTextureSize,d={[Ue]:he,[he]:Ue,[Le]:Le},u=new un({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Dt},radius:{value:4}},vertexShader:Np,fragmentShader:Fp}),m=u.clone();m.defines.HORIZONTAL_PASS=1;let g=new Ge;g.setAttribute("position",new Qt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new Ze(g,u),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=oc;let f=this.type;this.render=function(M,T,A){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||M.length===0)return;let L=i.getRenderTarget(),y=i.getActiveCubeFace(),w=i.getActiveMipmapLevel(),z=i.state;z.setBlending(Mn),z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);let q=f!==on&&this.type===on,I=f===on&&this.type!==on;for(let D=0,O=M.length;Dh||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/X.x),s.x=r.x*X.x,k.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/X.y),s.y=r.y*X.y,k.mapSize.y=r.y)),k.map===null||q===!0||I===!0){let K=this.type!==on?{minFilter:pe,magFilter:pe}:{};k.map!==null&&k.map.dispose(),k.map=new hn(s.x,s.y,K),k.map.texture.name=$.name+".shadowMap",k.camera.updateProjectionMatrix()}i.setRenderTarget(k.map),i.clear();let J=k.getViewportCount();for(let K=0;K0||T.map&&T.alphaTest>0){let z=y.uuid,q=T.uuid,I=l[z];I===void 0&&(I={},l[z]=I);let D=I[q];D===void 0&&(D=y.clone(),I[q]=D),y=D}if(y.visible=T.visible,y.wireframe=T.wireframe,L===on?y.side=T.shadowSide!==null?T.shadowSide:T.side:y.side=T.shadowSide!==null?T.shadowSide:d[T.side],y.alphaMap=T.alphaMap,y.alphaTest=T.alphaTest,y.map=T.map,y.clipShadows=T.clipShadows,y.clippingPlanes=T.clippingPlanes,y.clipIntersection=T.clipIntersection,y.displacementMap=T.displacementMap,y.displacementScale=T.displacementScale,y.displacementBias=T.displacementBias,y.wireframeLinewidth=T.wireframeLinewidth,y.linewidth=T.linewidth,A.isPointLight===!0&&y.isMeshDistanceMaterial===!0){let z=i.properties.get(y);z.light=A}return y}function b(M,T,A,L,y){if(M.visible===!1)return;if(M.layers.test(T.layers)&&(M.isMesh||M.isLine||M.isPoints)&&(M.castShadow||M.receiveShadow&&y===on)&&(!M.frustumCulled||n.intersectsObject(M))){M.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,M.matrixWorld);let q=t.update(M),I=M.material;if(Array.isArray(I)){let D=q.groups;for(let O=0,$=D.length;O<$;O++){let k=D[O],X=I[k.materialIndex];if(X&&X.visible){let J=_(M,X,L,y);i.renderBufferDirect(A,null,q,J,M,k)}}}else if(I.visible){let D=_(M,I,L,y);i.renderBufferDirect(A,null,q,D,M,null)}}let z=M.children;for(let q=0,I=z.length;q=1):X.indexOf("OpenGL ES")!==-1&&(k=parseFloat(/^OpenGL ES (\\d)/.exec(X)[1]),$=k>=2);let J=null,K={},B=i.getParameter(i.SCISSOR_BOX),Z=i.getParameter(i.VIEWPORT),ot=new Kt().fromArray(B),at=new Kt().fromArray(Z);function ct(C,nt,V,tt){let rt=new Uint8Array(4),Ot=i.createTexture();i.bindTexture(C,Ot),i.texParameteri(C,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(C,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let qt=0;qtQ||R.height>Q)&&(j=Q/Math.max(R.width,R.height)),j<1||S===!0)if(typeof HTMLImageElement!="undefined"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&R instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&R instanceof ImageBitmap){let it=S?Br:Math.floor,dt=it(j*R.width),st=it(j*R.height);x===void 0&&(x=v(dt,st));let Y=G?v(dt,st):x;return Y.width=dt,Y.height=st,Y.getContext("2d").drawImage(R,0,0,dt,st),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+dt+"x"+st+")."),Y}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function b(R){return Sa(R.width)&&Sa(R.height)}function M(R){return o?!1:R.wrapS!==ke||R.wrapT!==ke||R.minFilter!==pe&&R.minFilter!==Ie}function T(R,S){return R.generateMipmaps&&S&&R.minFilter!==pe&&R.minFilter!==Ie}function A(R){i.generateMipmap(R)}function L(R,S,G,Q,j=!1){if(o===!1)return S;if(R!==null){if(i[R]!==void 0)return i[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format \'"+R+"\'")}let it=S;return S===i.RED&&(G===i.FLOAT&&(it=i.R32F),G===i.HALF_FLOAT&&(it=i.R16F),G===i.UNSIGNED_BYTE&&(it=i.R8)),S===i.RG&&(G===i.FLOAT&&(it=i.RG32F),G===i.HALF_FLOAT&&(it=i.RG16F),G===i.UNSIGNED_BYTE&&(it=i.RG8)),S===i.RGBA&&(G===i.FLOAT&&(it=i.RGBA32F),G===i.HALF_FLOAT&&(it=i.RGBA16F),G===i.UNSIGNED_BYTE&&(it=Q===Rt&&j===!1?i.SRGB8_ALPHA8:i.RGBA8),G===i.UNSIGNED_SHORT_4_4_4_4&&(it=i.RGBA4),G===i.UNSIGNED_SHORT_5_5_5_1&&(it=i.RGB5_A1)),(it===i.R16F||it===i.R32F||it===i.RG16F||it===i.RG32F||it===i.RGBA16F||it===i.RGBA32F)&&t.get("EXT_color_buffer_float"),it}function y(R,S,G){return T(R,G)===!0||R.isFramebufferTexture&&R.minFilter!==pe&&R.minFilter!==Ie?Math.log2(Math.max(S.width,S.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?S.mipmaps.length:1}function w(R){return R===pe||R===Yo||R===er?i.NEAREST:i.LINEAR}function z(R){let S=R.target;S.removeEventListener("dispose",z),I(S),S.isVideoTexture&&g.delete(S)}function q(R){let S=R.target;S.removeEventListener("dispose",q),O(S)}function I(R){let S=n.get(R);if(S.__webglInit===void 0)return;let G=R.source,Q=p.get(G);if(Q){let j=Q[S.__cacheKey];j.usedTimes--,j.usedTimes===0&&D(R),Object.keys(Q).length===0&&p.delete(G)}n.remove(R)}function D(R){let S=n.get(R);i.deleteTexture(S.__webglTexture);let G=R.source,Q=p.get(G);delete Q[S.__cacheKey],a.memory.textures--}function O(R){let S=R.texture,G=n.get(R),Q=n.get(S);if(Q.__webglTexture!==void 0&&(i.deleteTexture(Q.__webglTexture),a.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let j=0;j<6;j++)i.deleteFramebuffer(G.__webglFramebuffer[j]),G.__webglDepthbuffer&&i.deleteRenderbuffer(G.__webglDepthbuffer[j]);else{if(i.deleteFramebuffer(G.__webglFramebuffer),G.__webglDepthbuffer&&i.deleteRenderbuffer(G.__webglDepthbuffer),G.__webglMultisampledFramebuffer&&i.deleteFramebuffer(G.__webglMultisampledFramebuffer),G.__webglColorRenderbuffer)for(let j=0;j=c&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+c),$+=1,R}function J(R){let S=[];return S.push(R.wrapS),S.push(R.wrapT),S.push(R.wrapR||0),S.push(R.magFilter),S.push(R.minFilter),S.push(R.anisotropy),S.push(R.internalFormat),S.push(R.format),S.push(R.type),S.push(R.generateMipmaps),S.push(R.premultiplyAlpha),S.push(R.flipY),S.push(R.unpackAlignment),S.push(R.colorSpace),S.join()}function K(R,S){let G=n.get(R);if(R.isVideoTexture&&re(R),R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){let Q=R.image;if(Q===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Q.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{zt(G,R,S);return}}e.bindTexture(i.TEXTURE_2D,G.__webglTexture,i.TEXTURE0+S)}function B(R,S){let G=n.get(R);if(R.version>0&&G.__version!==R.version){zt(G,R,S);return}e.bindTexture(i.TEXTURE_2D_ARRAY,G.__webglTexture,i.TEXTURE0+S)}function Z(R,S){let G=n.get(R);if(R.version>0&&G.__version!==R.version){zt(G,R,S);return}e.bindTexture(i.TEXTURE_3D,G.__webglTexture,i.TEXTURE0+S)}function ot(R,S){let G=n.get(R);if(R.version>0&&G.__version!==R.version){xe(G,R,S);return}e.bindTexture(i.TEXTURE_CUBE_MAP,G.__webglTexture,i.TEXTURE0+S)}let at={[Dr]:i.REPEAT,[ke]:i.CLAMP_TO_EDGE,[Nr]:i.MIRRORED_REPEAT},ct={[pe]:i.NEAREST,[Yo]:i.NEAREST_MIPMAP_NEAREST,[er]:i.NEAREST_MIPMAP_LINEAR,[Ie]:i.LINEAR,[Rl]:i.LINEAR_MIPMAP_NEAREST,[ki]:i.LINEAR_MIPMAP_LINEAR},gt={[Gl]:i.NEVER,[$l]:i.ALWAYS,[Wl]:i.LESS,[ql]:i.LEQUAL,[Xl]:i.EQUAL,[Jl]:i.GEQUAL,[Yl]:i.GREATER,[Zl]:i.NOTEQUAL};function Tt(R,S,G){if(G?(i.texParameteri(R,i.TEXTURE_WRAP_S,at[S.wrapS]),i.texParameteri(R,i.TEXTURE_WRAP_T,at[S.wrapT]),(R===i.TEXTURE_3D||R===i.TEXTURE_2D_ARRAY)&&i.texParameteri(R,i.TEXTURE_WRAP_R,at[S.wrapR]),i.texParameteri(R,i.TEXTURE_MAG_FILTER,ct[S.magFilter]),i.texParameteri(R,i.TEXTURE_MIN_FILTER,ct[S.minFilter])):(i.texParameteri(R,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(R,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),(R===i.TEXTURE_3D||R===i.TEXTURE_2D_ARRAY)&&i.texParameteri(R,i.TEXTURE_WRAP_R,i.CLAMP_TO_EDGE),(S.wrapS!==ke||S.wrapT!==ke)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),i.texParameteri(R,i.TEXTURE_MAG_FILTER,w(S.magFilter)),i.texParameteri(R,i.TEXTURE_MIN_FILTER,w(S.minFilter)),S.minFilter!==pe&&S.minFilter!==Ie&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),S.compareFunction&&(i.texParameteri(R,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(R,i.TEXTURE_COMPARE_FUNC,gt[S.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){let Q=t.get("EXT_texture_filter_anisotropic");if(S.magFilter===pe||S.minFilter!==er&&S.minFilter!==ki||S.type===vn&&t.has("OES_texture_float_linear")===!1||o===!1&&S.type===Hi&&t.has("OES_texture_half_float_linear")===!1)return;(S.anisotropy>1||n.get(S).__currentAnisotropy)&&(i.texParameterf(R,Q.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,s.getMaxAnisotropy())),n.get(S).__currentAnisotropy=S.anisotropy)}}function xt(R,S){let G=!1;R.__webglInit===void 0&&(R.__webglInit=!0,S.addEventListener("dispose",z));let Q=S.source,j=p.get(Q);j===void 0&&(j={},p.set(Q,j));let it=J(S);if(it!==R.__cacheKey){j[it]===void 0&&(j[it]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,G=!0),j[it].usedTimes++;let dt=j[R.__cacheKey];dt!==void 0&&(j[R.__cacheKey].usedTimes--,dt.usedTimes===0&&D(S)),R.__cacheKey=it,R.__webglTexture=j[it].texture}return G}function zt(R,S,G){let Q=i.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(Q=i.TEXTURE_2D_ARRAY),S.isData3DTexture&&(Q=i.TEXTURE_3D);let j=xt(R,S),it=S.source;e.bindTexture(Q,R.__webglTexture,i.TEXTURE0+G);let dt=n.get(it);if(it.version!==dt.__version||j===!0){e.activeTexture(i.TEXTURE0+G),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,S.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,S.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE);let st=M(S)&&b(S.image)===!1,Y=_(S.image,st,!1,h);Y=ae(S,Y);let pt=b(Y)||o,mt=r.convert(S.format,S.colorSpace),_t=r.convert(S.type),ht=L(S.internalFormat,mt,_t,S.colorSpace);Tt(Q,S,pt);let ut,It=S.mipmaps,Ht=o&&S.isVideoTexture!==!0,C=dt.__version===void 0||j===!0,nt=y(S,Y,pt);if(S.isDepthTexture)ht=i.DEPTH_COMPONENT,o?S.type===vn?ht=i.DEPTH_COMPONENT32F:S.type===yn?ht=i.DEPTH_COMPONENT24:S.type===Fn?ht=i.DEPTH24_STENCIL8:ht=i.DEPTH_COMPONENT16:S.type===vn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),S.format===On&&ht===i.DEPTH_COMPONENT&&S.type!==mo&&S.type!==yn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),S.type=yn,_t=r.convert(S.type)),S.format===_i&&ht===i.DEPTH_COMPONENT&&(ht=i.DEPTH_STENCIL,S.type!==Fn&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),S.type=Fn,_t=r.convert(S.type))),C&&(Ht?e.texStorage2D(i.TEXTURE_2D,1,ht,Y.width,Y.height):e.texImage2D(i.TEXTURE_2D,0,ht,Y.width,Y.height,0,mt,_t,null));else if(S.isDataTexture)if(It.length>0&&pt){Ht&&C&&e.texStorage2D(i.TEXTURE_2D,nt,ht,It[0].width,It[0].height);for(let V=0,tt=It.length;V>=1,tt>>=1}}else if(It.length>0&&pt){Ht&&C&&e.texStorage2D(i.TEXTURE_2D,nt,ht,It[0].width,It[0].height);for(let V=0,tt=It.length;V0&&C++,e.texStorage2D(i.TEXTURE_CUBE_MAP,C,ut,Y[0].width,Y[0].height));for(let V=0;V<6;V++)if(st){It?e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+V,0,0,0,Y[V].width,Y[V].height,_t,ht,Y[V].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+V,0,ut,Y[V].width,Y[V].height,0,_t,ht,Y[V].data);for(let tt=0;tt=i.TEXTURE_CUBE_MAP_POSITIVE_X&&j<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,Q,j,n.get(G).__webglTexture,0),e.bindFramebuffer(i.FRAMEBUFFER,null)}function F(R,S,G){if(i.bindRenderbuffer(i.RENDERBUFFER,R),S.depthBuffer&&!S.stencilBuffer){let Q=i.DEPTH_COMPONENT16;if(G||Vt(S)){let j=S.depthTexture;j&&j.isDepthTexture&&(j.type===vn?Q=i.DEPTH_COMPONENT32F:j.type===yn&&(Q=i.DEPTH_COMPONENT24));let it=Pt(S);Vt(S)?u.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,it,Q,S.width,S.height):i.renderbufferStorageMultisample(i.RENDERBUFFER,it,Q,S.width,S.height)}else i.renderbufferStorage(i.RENDERBUFFER,Q,S.width,S.height);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,R)}else if(S.depthBuffer&&S.stencilBuffer){let Q=Pt(S);G&&Vt(S)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,Q,i.DEPTH24_STENCIL8,S.width,S.height):Vt(S)?u.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Q,i.DEPTH24_STENCIL8,S.width,S.height):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,S.width,S.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,R)}else{let Q=S.isWebGLMultipleRenderTargets===!0?S.texture:[S.texture];for(let j=0;j0&&Vt(R)===!1){let st=it?S:[S];G.__webglMultisampledFramebuffer=i.createFramebuffer(),G.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let Y=0;Y0&&Vt(R)===!1){let S=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],G=R.width,Q=R.height,j=i.COLOR_BUFFER_BIT,it=[],dt=R.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,st=n.get(R),Y=R.isWebGLMultipleRenderTargets===!0;if(Y)for(let pt=0;pt0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function re(R){let S=a.render.frame;g.get(R)!==S&&(g.set(R,S),R.update())}function ae(R,S){let G=R.colorSpace,Q=R.format,j=R.type;return R.isCompressedTexture===!0||R.format===Fr||G!==Je&&G!==zn&&(G===Rt?o===!1?t.has("EXT_sRGB")===!0&&Q===He?(R.format=Fr,R.minFilter=Ie,R.generateMipmaps=!1):S=As.sRGBToLinear(S):(Q!==He||j!==Sn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",G)),S}this.allocateTextureUnit=X,this.resetTextureUnits=k,this.setTexture2D=K,this.setTexture2DArray=B,this.setTexture3D=Z,this.setTextureCube=ot,this.rebindTextures=wt,this.setupRenderTarget=bt,this.updateRenderTargetMipmap=Xt,this.updateMultisampleRenderTarget=Nt,this.setupDepthRenderbuffer=yt,this.setupFrameBufferTexture=Ut,this.useMultisampledRTT=Vt}function Vp(i,t,e){let n=e.isWebGL2;function s(r,a=zn){let o;if(r===Sn)return i.UNSIGNED_BYTE;if(r===fc)return i.UNSIGNED_SHORT_4_4_4_4;if(r===dc)return i.UNSIGNED_SHORT_5_5_5_1;if(r===Cl)return i.BYTE;if(r===Pl)return i.SHORT;if(r===mo)return i.UNSIGNED_SHORT;if(r===uc)return i.INT;if(r===yn)return i.UNSIGNED_INT;if(r===vn)return i.FLOAT;if(r===Hi)return n?i.HALF_FLOAT:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(r===Ll)return i.ALPHA;if(r===He)return i.RGBA;if(r===Il)return i.LUMINANCE;if(r===Ul)return i.LUMINANCE_ALPHA;if(r===On)return i.DEPTH_COMPONENT;if(r===_i)return i.DEPTH_STENCIL;if(r===Fr)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(r===Dl)return i.RED;if(r===pc)return i.RED_INTEGER;if(r===Nl)return i.RG;if(r===mc)return i.RG_INTEGER;if(r===gc)return i.RGBA_INTEGER;if(r===nr||r===ir||r===sr||r===rr)if(a===Rt)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(r===nr)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===ir)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===sr)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===rr)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(r===nr)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===ir)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===sr)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===rr)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===Zo||r===Jo||r===$o||r===Ko)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(r===Zo)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===Jo)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===$o)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===Ko)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===Fl)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(r===Qo||r===jo)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(r===Qo)return a===Rt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(r===jo)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===ta||r===ea||r===na||r===ia||r===sa||r===ra||r===oa||r===aa||r===ca||r===la||r===ha||r===ua||r===fa||r===da)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(r===ta)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===ea)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===na)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===ia)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===sa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===ra)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===oa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===aa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===ca)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===la)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===ha)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===ua)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===fa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===da)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===or)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(r===or)return a===Rt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(r===Ol||r===pa||r===ma||r===ga)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(r===or)return o.COMPRESSED_RED_RGTC1_EXT;if(r===pa)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===ma)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===ga)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===Fn?n?i.UNSIGNED_INT_24_8:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):i[r]!==void 0?i[r]:null}return{convert:s}}var Qr=class extends Re{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},ui=class extends ye{constructor(){super(),this.isGroup=!0,this.type="Group"}},kp={type:"move"},Vi=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ui,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ui,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ui,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let s=null,r=null,a=null,o=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){a=!0;for(let x of t.hand.values()){let p=e.getJointPose(x,n),f=this._getHandJoint(l,x);p!==null&&(f.matrix.fromArray(p.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=p.radius),f.visible=p!==null}let h=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],u=h.position.distanceTo(d.position),m=.02,g=.005;l.inputState.pinching&&u>m+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&u<=m-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(s=e.getPose(t.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(kp)))}return o!==null&&(o.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new ui;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},jr=class extends ge{constructor(t,e,n,s,r,a,o,c,l,h){if(h=h!==void 0?h:On,h!==On&&h!==_i)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===On&&(n=yn),n===void 0&&h===_i&&(n=Fn),super(null,s,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=o!==void 0?o:pe,this.minFilter=c!==void 0?c:pe,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}},to=class extends bn{constructor(t,e){super();let n=this,s=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,d=null,u=null,m=null,g=null,x=e.getContextAttributes(),p=null,f=null,v=[],_=[],b=new Re;b.layers.enable(1),b.viewport=new Kt;let M=new Re;M.layers.enable(2),M.viewport=new Kt;let T=[b,M],A=new Qr;A.layers.enable(1),A.layers.enable(2);let L=null,y=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(B){let Z=v[B];return Z===void 0&&(Z=new Vi,v[B]=Z),Z.getTargetRaySpace()},this.getControllerGrip=function(B){let Z=v[B];return Z===void 0&&(Z=new Vi,v[B]=Z),Z.getGripSpace()},this.getHand=function(B){let Z=v[B];return Z===void 0&&(Z=new Vi,v[B]=Z),Z.getHandSpace()};function w(B){let Z=_.indexOf(B.inputSource);if(Z===-1)return;let ot=v[Z];ot!==void 0&&(ot.update(B.inputSource,B.frame,l||a),ot.dispatchEvent({type:B.type,data:B.inputSource}))}function z(){s.removeEventListener("select",w),s.removeEventListener("selectstart",w),s.removeEventListener("selectend",w),s.removeEventListener("squeeze",w),s.removeEventListener("squeezestart",w),s.removeEventListener("squeezeend",w),s.removeEventListener("end",z),s.removeEventListener("inputsourceschange",q);for(let B=0;B=0&&(_[at]=null,v[at].disconnect(ot))}for(let Z=0;Z=_.length){_.push(ot),at=gt;break}else if(_[gt]===null){_[gt]=ot,at=gt;break}if(at===-1)break}let ct=v[at];ct&&ct.connect(ot)}}let I=new P,D=new P;function O(B,Z,ot){I.setFromMatrixPosition(Z.matrixWorld),D.setFromMatrixPosition(ot.matrixWorld);let at=I.distanceTo(D),ct=Z.projectionMatrix.elements,gt=ot.projectionMatrix.elements,Tt=ct[14]/(ct[10]-1),xt=ct[14]/(ct[10]+1),zt=(ct[9]+1)/ct[5],xe=(ct[9]-1)/ct[5],Ut=(ct[8]-1)/ct[0],F=(gt[8]+1)/gt[0],oe=Tt*Ut,yt=Tt*F,wt=at/(-Ut+F),bt=wt*-Ut;Z.matrixWorld.decompose(B.position,B.quaternion,B.scale),B.translateX(bt),B.translateZ(wt),B.matrixWorld.compose(B.position,B.quaternion,B.scale),B.matrixWorldInverse.copy(B.matrixWorld).invert();let Xt=Tt+wt,Nt=xt+wt,Pt=oe-bt,Vt=yt+(at-bt),re=zt*xt/Nt*Xt,ae=xe*xt/Nt*Xt;B.projectionMatrix.makePerspective(Pt,Vt,re,ae,Xt,Nt),B.projectionMatrixInverse.copy(B.projectionMatrix).invert()}function $(B,Z){Z===null?B.matrixWorld.copy(B.matrix):B.matrixWorld.multiplyMatrices(Z.matrixWorld,B.matrix),B.matrixWorldInverse.copy(B.matrixWorld).invert()}this.updateCamera=function(B){if(s===null)return;A.near=M.near=b.near=B.near,A.far=M.far=b.far=B.far,(L!==A.near||y!==A.far)&&(s.updateRenderState({depthNear:A.near,depthFar:A.far}),L=A.near,y=A.far);let Z=B.parent,ot=A.cameras;$(A,Z);for(let at=0;at0&&(p.alphaTest.value=f.alphaTest);let v=t.get(f).envMap;if(v&&(p.envMap.value=v,p.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=f.reflectivity,p.ior.value=f.ior,p.refractionRatio.value=f.refractionRatio),f.lightMap){p.lightMap.value=f.lightMap;let _=i.useLegacyLights===!0?Math.PI:1;p.lightMapIntensity.value=f.lightMapIntensity*_,e(f.lightMap,p.lightMapTransform)}f.aoMap&&(p.aoMap.value=f.aoMap,p.aoMapIntensity.value=f.aoMapIntensity,e(f.aoMap,p.aoMapTransform))}function a(p,f){p.diffuse.value.copy(f.color),p.opacity.value=f.opacity,f.map&&(p.map.value=f.map,e(f.map,p.mapTransform))}function o(p,f){p.dashSize.value=f.dashSize,p.totalSize.value=f.dashSize+f.gapSize,p.scale.value=f.scale}function c(p,f,v,_){p.diffuse.value.copy(f.color),p.opacity.value=f.opacity,p.size.value=f.size*v,p.scale.value=_*.5,f.map&&(p.map.value=f.map,e(f.map,p.uvTransform)),f.alphaMap&&(p.alphaMap.value=f.alphaMap,e(f.alphaMap,p.alphaMapTransform)),f.alphaTest>0&&(p.alphaTest.value=f.alphaTest)}function l(p,f){p.diffuse.value.copy(f.color),p.opacity.value=f.opacity,p.rotation.value=f.rotation,f.map&&(p.map.value=f.map,e(f.map,p.mapTransform)),f.alphaMap&&(p.alphaMap.value=f.alphaMap,e(f.alphaMap,p.alphaMapTransform)),f.alphaTest>0&&(p.alphaTest.value=f.alphaTest)}function h(p,f){p.specular.value.copy(f.specular),p.shininess.value=Math.max(f.shininess,1e-4)}function d(p,f){f.gradientMap&&(p.gradientMap.value=f.gradientMap)}function u(p,f){p.metalness.value=f.metalness,f.metalnessMap&&(p.metalnessMap.value=f.metalnessMap,e(f.metalnessMap,p.metalnessMapTransform)),p.roughness.value=f.roughness,f.roughnessMap&&(p.roughnessMap.value=f.roughnessMap,e(f.roughnessMap,p.roughnessMapTransform)),t.get(f).envMap&&(p.envMapIntensity.value=f.envMapIntensity)}function m(p,f,v){p.ior.value=f.ior,f.sheen>0&&(p.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),p.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(p.sheenColorMap.value=f.sheenColorMap,e(f.sheenColorMap,p.sheenColorMapTransform)),f.sheenRoughnessMap&&(p.sheenRoughnessMap.value=f.sheenRoughnessMap,e(f.sheenRoughnessMap,p.sheenRoughnessMapTransform))),f.clearcoat>0&&(p.clearcoat.value=f.clearcoat,p.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(p.clearcoatMap.value=f.clearcoatMap,e(f.clearcoatMap,p.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,e(f.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(p.clearcoatNormalMap.value=f.clearcoatNormalMap,e(f.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===he&&p.clearcoatNormalScale.value.negate())),f.iridescence>0&&(p.iridescence.value=f.iridescence,p.iridescenceIOR.value=f.iridescenceIOR,p.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(p.iridescenceMap.value=f.iridescenceMap,e(f.iridescenceMap,p.iridescenceMapTransform)),f.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=f.iridescenceThicknessMap,e(f.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),f.transmission>0&&(p.transmission.value=f.transmission,p.transmissionSamplerMap.value=v.texture,p.transmissionSamplerSize.value.set(v.width,v.height),f.transmissionMap&&(p.transmissionMap.value=f.transmissionMap,e(f.transmissionMap,p.transmissionMapTransform)),p.thickness.value=f.thickness,f.thicknessMap&&(p.thicknessMap.value=f.thicknessMap,e(f.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=f.attenuationDistance,p.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(p.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(p.anisotropyMap.value=f.anisotropyMap,e(f.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=f.specularIntensity,p.specularColor.value.copy(f.specularColor),f.specularColorMap&&(p.specularColorMap.value=f.specularColorMap,e(f.specularColorMap,p.specularColorMapTransform)),f.specularIntensityMap&&(p.specularIntensityMap.value=f.specularIntensityMap,e(f.specularIntensityMap,p.specularIntensityMapTransform))}function g(p,f){f.matcap&&(p.matcap.value=f.matcap)}function x(p,f){let v=t.get(f).light;p.referencePosition.value.setFromMatrixPosition(v.matrixWorld),p.nearDistance.value=v.shadow.camera.near,p.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Gp(i,t,e,n){let s={},r={},a=[],o=e.isWebGL2?i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(v,_){let b=_.program;n.uniformBlockBinding(v,b)}function l(v,_){let b=s[v.id];b===void 0&&(g(v),b=h(v),s[v.id]=b,v.addEventListener("dispose",p));let M=_.program;n.updateUBOMapping(v,M);let T=t.render.frame;r[v.id]!==T&&(u(v),r[v.id]=T)}function h(v){let _=d();v.__bindingPointIndex=_;let b=i.createBuffer(),M=v.__size,T=v.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,M,T),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,_,b),b}function d(){for(let v=0;v0){T=b%M;let q=M-T;T!==0&&q-w.boundary<0&&(b+=M-T,y.__offset=b)}b+=w.storage}return T=b%M,T>0&&(b+=M-T),v.__size=b,v.__cache={},this}function x(v){let _={boundary:0,storage:0};return typeof v=="number"?(_.boundary=4,_.storage=4):v.isVector2?(_.boundary=8,_.storage=8):v.isVector3||v.isColor?(_.boundary=16,_.storage=12):v.isVector4?(_.boundary=16,_.storage=16):v.isMatrix3?(_.boundary=48,_.storage=48):v.isMatrix4?(_.boundary=64,_.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),_}function p(v){let _=v.target;_.removeEventListener("dispose",p);let b=a.indexOf(_.__bindingPointIndex);a.splice(b,1),i.deleteBuffer(s[_.id]),delete s[_.id],delete r[_.id]}function f(){for(let v in s)i.deleteBuffer(s[v]);a=[],s={},r={}}return{bind:c,update:l,dispose:f}}function Wp(){let i=ws("canvas");return i.style.display="block",i}var eo=class{constructor(t={}){let{canvas:e=Wp(),context:n=null,depth:s=!0,stencil:r=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1}=t;this.isWebGLRenderer=!0;let u;n!==null?u=n.getContextAttributes().alpha:u=a;let m=new Uint32Array(4),g=new Int32Array(4),x=null,p=null,f=[],v=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputColorSpace=Rt,this.useLegacyLights=!0,this.toneMapping=cn,this.toneMappingExposure=1;let _=this,b=!1,M=0,T=0,A=null,L=-1,y=null,w=new Kt,z=new Kt,q=null,I=new kt(0),D=0,O=e.width,$=e.height,k=1,X=null,J=null,K=new Kt(0,0,O,$),B=new Kt(0,0,O,$),Z=!1,ot=new Fs,at=!1,ct=!1,gt=null,Tt=new Gt,xt=new Dt,zt=new P,xe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ut(){return A===null?k:1}let F=n;function oe(E,N){for(let H=0;H0?p=v[v.length-1]:p=null,f.pop(),f.length>0?x=f[f.length-1]:x=null};function Io(E,N,H,U){if(E.visible===!1)return;if(E.layers.test(N.layers)){if(E.isGroup)H=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(N);else if(E.isLight)p.pushLight(E),E.castShadow&&p.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||ot.intersectsSprite(E)){U&&zt.setFromMatrixPosition(E.matrixWorld).applyMatrix4(Tt);let ft=S.update(E),Mt=E.material;Mt.visible&&x.push(E,ft,Mt,H,zt.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||ot.intersectsObject(E))){let ft=S.update(E),Mt=E.material;if(U&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),zt.copy(E.boundingSphere.center)):(ft.boundingSphere===null&&ft.computeBoundingSphere(),zt.copy(ft.boundingSphere.center)),zt.applyMatrix4(E.matrixWorld).applyMatrix4(Tt)),Array.isArray(Mt)){let vt=ft.groups;for(let Lt=0,St=vt.length;Lt0&&Gc(W,lt,N,H),U&&bt.viewport(w.copy(U)),W.length>0&&Ki(W,N,H),lt.length>0&&Ki(lt,N,H),ft.length>0&&Ki(ft,N,H),bt.buffers.depth.setTest(!0),bt.buffers.depth.setMask(!0),bt.buffers.color.setMask(!0),bt.setPolygonOffset(!1)}function Gc(E,N,H,U){let W=wt.isWebGL2;gt===null&&(gt=new hn(1,1,{generateMipmaps:!0,type:yt.has("EXT_color_buffer_half_float")?Hi:Sn,minFilter:ki,samples:W?4:0})),_.getDrawingBufferSize(xt),W?gt.setSize(xt.x,xt.y):gt.setSize(Br(xt.x),Br(xt.y));let lt=_.getRenderTarget();_.setRenderTarget(gt),_.getClearColor(I),D=_.getClearAlpha(),D<1&&_.setClearColor(16777215,.5),_.clear();let ft=_.toneMapping;_.toneMapping=cn,Ki(E,H,U),Pt.updateMultisampleRenderTarget(gt),Pt.updateRenderTargetMipmap(gt);let Mt=!1;for(let vt=0,Lt=N.length;vt0),Et=!!H.morphAttributes.position,Wt=!!H.morphAttributes.normal,Zt=!!H.morphAttributes.color,Fe=U.toneMapped?_.toneMapping:cn,Qe=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,Jt=Qe!==void 0?Qe.length:0,Ft=Nt.get(U),Ks=p.state.lights;if(at===!0&&(ct===!0||E!==y)){let Ee=E===y&&U.id===L;dt.setState(U,E,Ee)}let ne=!1;U.version===Ft.__version?(Ft.needsLights&&Ft.lightsStateVersion!==Ks.state.version||Ft.outputColorSpace!==Mt||W.isInstancedMesh&&Ft.instancing===!1||!W.isInstancedMesh&&Ft.instancing===!0||W.isSkinnedMesh&&Ft.skinning===!1||!W.isSkinnedMesh&&Ft.skinning===!0||Ft.envMap!==vt||U.fog===!0&&Ft.fog!==lt||Ft.numClippingPlanes!==void 0&&(Ft.numClippingPlanes!==dt.numPlanes||Ft.numIntersection!==dt.numIntersection)||Ft.vertexAlphas!==Lt||Ft.vertexTangents!==St||Ft.morphTargets!==Et||Ft.morphNormals!==Wt||Ft.morphColors!==Zt||Ft.toneMapping!==Fe||wt.isWebGL2===!0&&Ft.morphTargetsCount!==Jt)&&(ne=!0):(ne=!0,Ft.__version=U.version);let Rn=Ft.currentProgram;ne===!0&&(Rn=Qi(U,N,W));let Fo=!1,Ui=!1,Qs=!1,fe=Rn.getUniforms(),Cn=Ft.uniforms;if(bt.useProgram(Rn.program)&&(Fo=!0,Ui=!0,Qs=!0),U.id!==L&&(L=U.id,Ui=!0),Fo||y!==E){if(fe.setValue(F,"projectionMatrix",E.projectionMatrix),wt.logarithmicDepthBuffer&&fe.setValue(F,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),y!==E&&(y=E,Ui=!0,Qs=!0),U.isShaderMaterial||U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshStandardMaterial||U.envMap){let Ee=fe.map.cameraPosition;Ee!==void 0&&Ee.setValue(F,zt.setFromMatrixPosition(E.matrixWorld))}(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial)&&fe.setValue(F,"isOrthographic",E.isOrthographicCamera===!0),(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial||U.isShadowMaterial||W.isSkinnedMesh)&&fe.setValue(F,"viewMatrix",E.matrixWorldInverse)}if(W.isSkinnedMesh){fe.setOptional(F,W,"bindMatrix"),fe.setOptional(F,W,"bindMatrixInverse");let Ee=W.skeleton;Ee&&(wt.floatVertexTextures?(Ee.boneTexture===null&&Ee.computeBoneTexture(),fe.setValue(F,"boneTexture",Ee.boneTexture,Pt),fe.setValue(F,"boneTextureSize",Ee.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let js=H.morphAttributes;if((js.position!==void 0||js.normal!==void 0||js.color!==void 0&&wt.isWebGL2===!0)&&pt.update(W,H,Rn),(Ui||Ft.receiveShadow!==W.receiveShadow)&&(Ft.receiveShadow=W.receiveShadow,fe.setValue(F,"receiveShadow",W.receiveShadow)),U.isMeshGouraudMaterial&&U.envMap!==null&&(Cn.envMap.value=vt,Cn.flipEnvMap.value=vt.isCubeTexture&&vt.isRenderTargetTexture===!1?-1:1),Ui&&(fe.setValue(F,"toneMappingExposure",_.toneMappingExposure),Ft.needsLights&&Xc(Cn,Qs),lt&&U.fog===!0&&Q.refreshFogUniforms(Cn,lt),Q.refreshMaterialUniforms(Cn,U,k,$,gt),pi.upload(F,Ft.uniformsList,Cn,Pt)),U.isShaderMaterial&&U.uniformsNeedUpdate===!0&&(pi.upload(F,Ft.uniformsList,Cn,Pt),U.uniformsNeedUpdate=!1),U.isSpriteMaterial&&fe.setValue(F,"center",W.center),fe.setValue(F,"modelViewMatrix",W.modelViewMatrix),fe.setValue(F,"normalMatrix",W.normalMatrix),fe.setValue(F,"modelMatrix",W.matrixWorld),U.isShaderMaterial||U.isRawShaderMaterial){let Ee=U.uniformsGroups;for(let tr=0,Yc=Ee.length;tr0&&Pt.useMultisampledRTT(E)===!1?W=Nt.get(E).__webglMultisampledFramebuffer:W=St,w.copy(E.viewport),z.copy(E.scissor),q=E.scissorTest}else w.copy(K).multiplyScalar(k).floor(),z.copy(B).multiplyScalar(k).floor(),q=Z;if(bt.bindFramebuffer(F.FRAMEBUFFER,W)&&wt.drawBuffers&&U&&bt.drawBuffers(E,W),bt.viewport(w),bt.scissor(z),bt.setScissorTest(q),lt){let vt=Nt.get(E.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_CUBE_MAP_POSITIVE_X+N,vt.__webglTexture,H)}else if(ft){let vt=Nt.get(E.texture),Lt=N||0;F.framebufferTextureLayer(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,vt.__webglTexture,H||0,Lt)}L=-1},this.readRenderTargetPixels=function(E,N,H,U,W,lt,ft){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Mt=Nt.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&ft!==void 0&&(Mt=Mt[ft]),Mt){bt.bindFramebuffer(F.FRAMEBUFFER,Mt);try{let vt=E.texture,Lt=vt.format,St=vt.type;if(Lt!==He&&ht.convert(Lt)!==F.getParameter(F.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Et=St===Hi&&(yt.has("EXT_color_buffer_half_float")||wt.isWebGL2&&yt.has("EXT_color_buffer_float"));if(St!==Sn&&ht.convert(St)!==F.getParameter(F.IMPLEMENTATION_COLOR_READ_TYPE)&&!(St===vn&&(wt.isWebGL2||yt.has("OES_texture_float")||yt.has("WEBGL_color_buffer_float")))&&!Et){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=E.width-U&&H>=0&&H<=E.height-W&&F.readPixels(N,H,U,W,ht.convert(Lt),ht.convert(St),lt)}finally{let vt=A!==null?Nt.get(A).__webglFramebuffer:null;bt.bindFramebuffer(F.FRAMEBUFFER,vt)}}},this.copyFramebufferToTexture=function(E,N,H=0){let U=Math.pow(2,-H),W=Math.floor(N.image.width*U),lt=Math.floor(N.image.height*U);Pt.setTexture2D(N,0),F.copyTexSubImage2D(F.TEXTURE_2D,H,0,0,E.x,E.y,W,lt),bt.unbindTexture()},this.copyTextureToTexture=function(E,N,H,U=0){let W=N.image.width,lt=N.image.height,ft=ht.convert(H.format),Mt=ht.convert(H.type);Pt.setTexture2D(H,0),F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,H.flipY),F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),F.pixelStorei(F.UNPACK_ALIGNMENT,H.unpackAlignment),N.isDataTexture?F.texSubImage2D(F.TEXTURE_2D,U,E.x,E.y,W,lt,ft,Mt,N.image.data):N.isCompressedTexture?F.compressedTexSubImage2D(F.TEXTURE_2D,U,E.x,E.y,N.mipmaps[0].width,N.mipmaps[0].height,ft,N.mipmaps[0].data):F.texSubImage2D(F.TEXTURE_2D,U,E.x,E.y,ft,Mt,N.image),U===0&&H.generateMipmaps&&F.generateMipmap(F.TEXTURE_2D),bt.unbindTexture()},this.copyTextureToTexture3D=function(E,N,H,U,W=0){if(_.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let lt=E.max.x-E.min.x+1,ft=E.max.y-E.min.y+1,Mt=E.max.z-E.min.z+1,vt=ht.convert(U.format),Lt=ht.convert(U.type),St;if(U.isData3DTexture)Pt.setTexture3D(U,0),St=F.TEXTURE_3D;else if(U.isDataArrayTexture)Pt.setTexture2DArray(U,0),St=F.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,U.flipY),F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),F.pixelStorei(F.UNPACK_ALIGNMENT,U.unpackAlignment);let Et=F.getParameter(F.UNPACK_ROW_LENGTH),Wt=F.getParameter(F.UNPACK_IMAGE_HEIGHT),Zt=F.getParameter(F.UNPACK_SKIP_PIXELS),Fe=F.getParameter(F.UNPACK_SKIP_ROWS),Qe=F.getParameter(F.UNPACK_SKIP_IMAGES),Jt=H.isCompressedTexture?H.mipmaps[0]:H.image;F.pixelStorei(F.UNPACK_ROW_LENGTH,Jt.width),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,Jt.height),F.pixelStorei(F.UNPACK_SKIP_PIXELS,E.min.x),F.pixelStorei(F.UNPACK_SKIP_ROWS,E.min.y),F.pixelStorei(F.UNPACK_SKIP_IMAGES,E.min.z),H.isDataTexture||H.isData3DTexture?F.texSubImage3D(St,W,N.x,N.y,N.z,lt,ft,Mt,vt,Lt,Jt.data):H.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),F.compressedTexSubImage3D(St,W,N.x,N.y,N.z,lt,ft,Mt,vt,Jt.data)):F.texSubImage3D(St,W,N.x,N.y,N.z,lt,ft,Mt,vt,Lt,Jt),F.pixelStorei(F.UNPACK_ROW_LENGTH,Et),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,Wt),F.pixelStorei(F.UNPACK_SKIP_PIXELS,Zt),F.pixelStorei(F.UNPACK_SKIP_ROWS,Fe),F.pixelStorei(F.UNPACK_SKIP_IMAGES,Qe),W===0&&U.generateMipmaps&&F.generateMipmap(St),bt.unbindTexture()},this.initTexture=function(E){E.isCubeTexture?Pt.setTextureCube(E,0):E.isData3DTexture?Pt.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?Pt.setTexture2DArray(E,0):Pt.setTexture2D(E,0),bt.unbindTexture()},this.resetState=function(){M=0,T=0,A=null,bt.reset(),ut.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return an}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(t){console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!t}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Rt?Bn:_c}set outputEncoding(t){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=t===Bn?Rt:Je}},no=class extends eo{};no.prototype.isWebGL1Renderer=!0;function xn(i,t,e){return Ac(i)?new i.constructor(i.subarray(t,e!==void 0?e:i.length)):i.slice(t,e)}function Ms(i,t,e){return!i||!e&&i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function Ac(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}var Mi=class{constructor(t,e,n,s){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,s=e[n],r=e[n-1];n:{t:{let a;e:{i:if(!(t=r)){let o=e[1];t=r)break t}a=n,n=0;break e}break n}for(;n>>1;te;)--a;if(++a,r!==0||a!==s){r>=a&&(a=Math.max(a,1),r=a-1);let o=this.getValueSize();this.times=xn(n,r,a),this.values=xn(this.values,r*o,a*o)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,s=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==r;o++){let c=n[o];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,c),t=!1;break}if(a!==null&&a>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,c,a),t=!1;break}a=c}if(s!==void 0&&Ac(s))for(let o=0,c=s.length;o!==c;++o){let l=s[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}return t}optimize(){let t=xn(this.times),e=xn(this.values),n=this.getValueSize(),s=this.getInterpolation()===ar,r=t.length-1,a=1;for(let o=1;o0){t[a]=t[r];for(let o=r*n,c=a*n,l=0;l!==n;++l)e[c+l]=e[o+l];++a}return a!==t.length?(this.times=xn(t,0,a),this.values=xn(e,0,a*n)):(this.times=t,this.values=e),this}clone(){let t=xn(this.times,0),e=xn(this.values,0),n=this.constructor,s=new n(this.name,t,e);return s.createInterpolant=this.createInterpolant,s}};We.prototype.TimeBufferType=Float32Array;We.prototype.ValueBufferType=Float32Array;We.prototype.DefaultInterpolation=Es;var Hn=class extends We{};Hn.prototype.ValueTypeName="bool";Hn.prototype.ValueBufferType=Array;Hn.prototype.DefaultInterpolation=bs;Hn.prototype.InterpolantFactoryMethodLinear=void 0;Hn.prototype.InterpolantFactoryMethodSmooth=void 0;var oo=class extends We{};oo.prototype.ValueTypeName="color";var ao=class extends We{};ao.prototype.ValueTypeName="number";var co=class extends Mi{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-e)/(s-e),l=t*o;for(let h=l+o;l!==h;l+=4)En.slerpFlat(r,0,a,l-o,a,l,c);return r}},Wi=class extends We{InterpolantFactoryMethodLinear(t){return new co(this.times,this.values,this.getValueSize(),t)}};Wi.prototype.ValueTypeName="quaternion";Wi.prototype.DefaultInterpolation=Es;Wi.prototype.InterpolantFactoryMethodSmooth=void 0;var Gn=class extends We{};Gn.prototype.ValueTypeName="string";Gn.prototype.ValueBufferType=Array;Gn.prototype.DefaultInterpolation=bs;Gn.prototype.InterpolantFactoryMethodLinear=void 0;Gn.prototype.InterpolantFactoryMethodSmooth=void 0;var lo=class extends We{};lo.prototype.ValueTypeName="vector";var ho=class{constructor(t,e,n){let s=this,r=!1,a=0,o=0,c,l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(h){o++,r===!1&&s.onStart!==void 0&&s.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,s.onProgress!==void 0&&s.onProgress(h,a,o),a===o&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,d){return l.push(h,d),this},this.removeHandler=function(h){let d=l.indexOf(h);return d!==-1&&l.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=l.length;de&&(e=s,t=n)}return t}function vo(i,t){t.set(i)}function Mo(i,t,e){let n,s;for(let r=0;r<3;r++){let a=r+3;n=i[r],s=t[r],e[r]=ns?n:s}}function qi(i,t,e){for(let n=0;n<3;n++){let s=t[i+2*n],r=t[i+2*n+1],a=s-r,o=s+r;ae[n+3]&&(e[n+3]=o)}}function bi(i){let t=i[3]-i[0],e=i[4]-i[1],n=i[5]-i[2];return 2*(t*e+e*n+n*t)}function nm(i,t){if(!i.index){let e=i.attributes.position.count,n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s;e>65535?s=new Uint32Array(new n(4*e)):s=new Uint16Array(new n(2*e)),i.setIndex(new Qt(s,1));for(let r=0;rs-r);for(let s=0;sc&&(c=A),f&&bg&&(g=b);let L=i[v+2],y=i[v+3],w=L-y,z=L+y;wl&&(l=z),f&&Lx&&(x=L);let q=i[v+4],I=i[v+5],D=q-I,O=q+I;Dh&&(h=O),f&&qp&&(p=q)}n[0]=r,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=h,f&&(s[0]=d,s[1]=u,s[2]=m,s[3]=g,s[4]=x,s[5]=p)}function sm(i,t,e,n){let s=1/0,r=1/0,a=1/0,o=-1/0,c=-1/0,l=-1/0;for(let h=t*6,d=(t+e)*6;ho&&(o=u);let m=i[h+2];mc&&(c=m);let g=i[h+4];gl&&(l=g)}n[0]=s,n[1]=r,n[2]=a,n[3]=o,n[4]=c,n[5]=l}function rm(i,t,e,n,s){let r=e,a=e+n-1,o=s.pos,c=s.axis*2;for(;;){for(;r<=a&&t[r*6+c]=o;)a--;if(ri.candidate-t.candidate,Tn=new Array(fn).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Vs=new Float32Array(6);function am(i,t,e,n,s,r){let a=-1,o=0;if(r===0)a=yo(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(r===1)a=yo(i),a!==-1&&(o=cm(e,n,s,a));else if(r===2){let c=bi(i),l=1.25*s,h=n*6,d=(n+s)*6;for(let u=0;u<3;u++){let m=t[u],p=(t[u+3]-m)/fn;if(s=A.candidate?qi(b,e,A.rightCacheBounds):(qi(b,e,A.leftCacheBounds),A.count++)}}for(let b=0;b<_;b++){let M=f[b],T=M.count,A=s-M.count,L=M.leftCacheBounds,y=M.rightCacheBounds,w=0;T!==0&&(w=bi(L)/c);let z=0;A!==0&&(z=bi(y)/c);let q=1+1.25*(w*T+z*A);q=fn&&(T=fn-1);let A=Tn[T];A.count++,qi(_,e,A.bounds)}let f=Tn[fn-1];vo(f.bounds,f.rightCacheBounds);for(let _=fn-2;_>=0;_--){let b=Tn[_],M=Tn[_+1];Mo(b.bounds,M.rightCacheBounds,b.rightCacheBounds)}let v=0;for(let _=0;_T&&(T=_),b>T&&(T=b);let A=(T-M)/2,L=f*2;r[m+L+0]=M+A,r[m+L+1]=A+(Math.abs(M)+A)*Rc,Mt[f+3]&&(t[f+3]=T)}}return r}function hm(i,t){function e(f){u&&u(f/m)}function n(f,v,_,b=null,M=0){if(!g&&M>=c&&(g=!0,l&&(console.warn(`MeshBVH: Max depth of ${c} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),_<=h||M>=c)return e(v+_),f.offset=v,f.count=_,f;let T=am(f.boundingData,b,a,v,_,d);if(T.axis===-1)return e(v+_),f.offset=v,f.count=_,f;let A=rm(o,a,v,_,T);if(A===v||A===v+_)e(v+_),f.offset=v,f.count=_;else{f.splitAxis=T.axis;let L=new Wn,y=v,w=A-v;f.left=L,L.boundingData=new Float32Array(6),bo(a,y,w,L.boundingData,r),n(L,y,w,r,M+1);let z=new Wn,q=A,I=_-w;f.right=z,z.boundingData=new Float32Array(6),bo(a,q,I,z.boundingData,r),n(z,q,I,r,M+1)}return f}nm(i,t);let s=new Float32Array(6),r=new Float32Array(6),a=lm(i,s),o=i.index.array,c=t.maxDepth,l=t.verbose,h=t.maxLeafTris,d=t.strategy,u=t.onProgress,m=i.index.count/3,g=!1,x=[],p=im(i);if(p.length===1){let f=p[0],v=new Wn;v.boundingData=s,sm(a,f.offset,f.count,r),n(v,f.offset,f.count,r),x.push(v)}else for(let f of p){let v=new Wn;v.boundingData=new Float32Array(6),bo(a,f.offset,f.count,v.boundingData,r),n(v,f.offset,f.count,r),x.push(v)}return x}function Lc(i,t){let e=hm(i,t),n,s,r,a=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let h=0;hMath.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[u+6]=_/4,_=l(_,f),s[u+7]=v,_}}}var Me=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,s=-1/0;for(let r=0,a=t.length;rs?c:s}this.min=n,this.max=s}setFromPoints(t,e){let n=1/0,s=-1/0;for(let r=0,a=e.length;rs?c:s}this.min=n,this.max=s}isSeparated(t){return this.min>t.max||t.min>this.max}};Me.prototype.setFromBox=function(){let i=new P;return function(e,n){let s=n.min,r=n.max,a=1/0,o=-1/0;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){i.x=s.x*c+r.x*(1-c),i.y=s.y*l+r.y*(1-l),i.z=s.z*h+r.z*(1-h);let d=e.dot(i);a=Math.min(d,a),o=Math.max(d,o)}this.min=a,this.max=o}}();var Im=function(){let i=new Me;return function(e,n){let s=e.points,r=e.satAxes,a=e.satBounds,o=n.points,c=n.satAxes,l=n.satBounds;for(let h=0;h<3;h++){let d=a[h],u=r[h];if(i.setFromPoints(u,o),d.isSeparated(i))return!1}for(let h=0;h<3;h++){let d=l[h],u=c[h];if(i.setFromPoints(u,s),d.isSeparated(i))return!1}}}();var um=function(){let i=new P,t=new P,e=new P;return function(s,r,a){let o=s.start,c=i,l=r.start,h=t;e.subVectors(o,l),i.subVectors(s.end,s.start),t.subVectors(r.end,r.start);let d=e.dot(h),u=h.dot(c),m=h.dot(h),g=e.dot(c),p=c.dot(c)*m-u*u,f,v;p!==0?f=(d*u-g*m)/p:f=0,v=(d+f*u)/m,a.x=f,a.y=v}}(),Yi=function(){let i=new Dt,t=new P,e=new P;return function(s,r,a,o){um(s,r,i);let c=i.x,l=i.y;if(c>=0&&c<=1&&l>=0&&l<=1){s.at(c,a),r.at(l,o);return}else if(c>=0&&c<=1){l<0?r.at(0,o):r.at(1,o),s.closestPointToPoint(o,!0,a);return}else if(l>=0&&l<=1){c<0?s.at(0,a):s.at(1,a),r.closestPointToPoint(a,!0,o);return}else{let h;c<0?h=s.start:h=s.end;let d;l<0?d=r.start:d=r.end;let u=t,m=e;if(s.closestPointToPoint(d,!0,t),r.closestPointToPoint(h,!0,e),u.distanceToSquared(d)<=m.distanceToSquared(h)){a.copy(u),o.copy(d);return}else{a.copy(h),o.copy(m);return}}}}(),Ic=function(){let i=new P,t=new P,e=new Ce,n=new ve;return function(r,a){let{radius:o,center:c}=r,{a:l,b:h,c:d}=a;if(n.start=l,n.end=h,n.closestPointToPoint(c,!0,i).distanceTo(c)<=o||(n.start=l,n.end=d,n.closestPointToPoint(c,!0,i).distanceTo(c)<=o)||(n.start=h,n.end=d,n.closestPointToPoint(c,!0,i).distanceTo(c)<=o))return!0;let x=a.getPlane(e);if(Math.abs(x.distanceToPoint(c))<=o){let f=x.projectPoint(c,t);if(a.containsPoint(f))return!0}return!1}}();var fm=1e-15;function Ei(i){return Math.abs(i)new P),this.satBounds=new Array(4).fill().map(()=>new Me),this.points=[this.a,this.b,this.c],this.sphere=new Vn,this.plane=new Ce,this.needsUpdate=!0}intersectsSphere(t){return Ic(t,this)}update(){let t=this.a,e=this.b,n=this.c,s=this.points,r=this.satAxes,a=this.satBounds,o=r[0],c=a[0];this.getNormal(o),c.setFromPoints(o,s);let l=r[1],h=a[1];l.subVectors(t,e),h.setFromPoints(l,s);let d=r[2],u=a[2];d.subVectors(e,n),u.setFromPoints(d,s);let m=r[3],g=a[3];m.subVectors(n,t),g.setFromPoints(m,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,t),this.needsUpdate=!1}};Se.prototype.closestPointToSegment=function(){let i=new P,t=new P,e=new ve;return function(s,r=null,a=null){let{start:o,end:c}=s,l=this.points,h,d=1/0;for(let u=0;u<3;u++){let m=(u+1)%3;e.start.copy(l[u]),e.end.copy(l[m]),Yi(e,s,i,t),h=i.distanceToSquared(t),h1-1e-10){let v=this.satBounds,_=this.satAxes;e[0]=m.a,e[1]=m.b,e[2]=m.c;for(let T=0;T<4;T++){let A=v[T],L=_[T];if(n.setFromPoints(L,e),A.isSeparated(n))return!1}let b=m.satBounds,M=m.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let T=0;T<4;T++){let A=b[T],L=M[T];if(n.setFromPoints(L,t),A.isSeparated(n))return!1}for(let T=0;T<4;T++){let A=_[T];for(let L=0;L<4;L++){let y=M[L];if(r.crossVectors(A,y),n.setFromPoints(r,t),s.setFromPoints(r,e),n.isSeparated(s))return!1}}return g&&(x||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),g.start.set(0,0,0),g.end.set(0,0,0)),!0}else{let v=this.points,_=!1,b=0;for(let D=0;D<3;D++){let O=v[D],$=v[(D+1)%3];l.start.copy(O),l.end.copy($),l.delta(a);let k=_?h.start:h.end,X=Ei(f.distanceToPoint(O));if(Ei(f.normal.dot(a))&&X){h.copy(l),b=2;break}if((f.intersectLine(l,k)||X)&&!Ei(k.distanceTo($))){if(b++,_)break;_=!0}}if(b===1&&m.containsPoint(h.end))return g&&(g.start.copy(h.end),g.end.copy(h.end)),!0;if(b!==2)return!1;let M=m.points,T=!1,A=0;for(let D=0;D<3;D++){let O=M[D],$=M[(D+1)%3];l.start.copy(O),l.end.copy($),l.delta(o);let k=T?d.start:d.end,X=Ei(p.distanceToPoint(O));if(Ei(p.normal.dot(o))&&X){d.copy(l),A=2;break}if((p.intersectLine(l,k)||X)&&!Ei(k.distanceTo($))){if(A++,T)break;T=!0}}if(A===1&&this.containsPoint(d.end))return g&&(g.start.copy(d.end),g.end.copy(d.end)),!0;if(A!==2)return!1;if(h.delta(a),d.delta(o),a.dot(o)<0){let D=d.start;d.start=d.end,d.end=D}let L=h.start.dot(a),y=h.end.dot(a),w=d.start.dot(a),z=d.end.dot(a),q=y0?g.start.copy(h.start):g.start.copy(d.start),c.subVectors(h.end,d.end),c.dot(a)<0?g.end.copy(h.end):g.end.copy(d.end)),!0)}}}();Se.prototype.distanceToPoint=function(){let i=new P;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();Se.prototype.distanceToTriangle=function(){let i=new P,t=new P,e=["a","b","c"],n=new ve,s=new ve;return function(a,o=null,c=null){let l=o||c?n:null;if(this.intersectsTriangle(a,l))return(o||c)&&(o&&l.getCenter(o),c&&l.getCenter(c)),0;let h=1/0;for(let d=0;d<3;d++){let u,m=e[d],g=a[m];this.closestPointToPoint(g,i),u=g.distanceToSquared(i),unew P),this.satAxes=new Array(3).fill().map(()=>new P),this.satBounds=new Array(3).fill().map(()=>new Me),this.alignedSatBounds=new Array(3).fill().map(()=>new Me),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),n&&this.matrix.copy(n)}set(t,e,n){this.min.copy(t),this.max.copy(e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};be.prototype.update=function(){return function(){let t=this.matrix,e=this.min,n=this.max,s=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let d=0;d<=1;d++){let u=1*l|2*h|4*d,m=s[u];m.x=l?n.x:e.x,m.y=h?n.y:e.y,m.z=d?n.z:e.z,m.applyMatrix4(t)}let r=this.satBounds,a=this.satAxes,o=s[0];for(let l=0;l<3;l++){let h=a[l],d=r[l],u=1<new ve),e=new Array(12).fill().map(()=>new ve),n=new P,s=new P;return function(a,o=0,c=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(c||l)&&(a.getCenter(s),this.closestPointToPoint(s,n),a.closestPointToPoint(n,s),c&&c.copy(n),l&&l.copy(s)),0;let h=o*o,d=a.min,u=a.max,m=this.points,g=1/0;for(let p=0;p<8;p++){let f=m[p];s.copy(f).clamp(d,u);let v=f.distanceToSquared(s);if(v=0,m,g;u?(m=Ai(i),g=Ri(i,o)):(m=Ri(i,o),g=Ai(i));let p=Js(m,r,n,qs)?Zs(m,t,e,n):null;if(p){let _=p.point[h];if(u?_<=r[g+l]:_>=r[g+l+3])return p}let v=Js(g,r,n,qs)?Zs(g,t,e,n):null;return p&&v?p.distance<=v.distance?p:v:p||v||null}}var Vc=function(){let i,t,e=[],n=new Ti(()=>new _e);return function(...a){i=n.getPrimitive(),t=n.getPrimitive(),e.push(i,t);let o=s(...a);n.releasePrimitive(i),n.releasePrimitive(t),e.pop(),e.pop();let c=e.length;return c>0&&(t=e[c-1],i=e[c-2]),o};function s(r,a,o,c,l=null,h=0,d=0){function u(_){let b=_*2,M=wn,T=An;for(;!dn(b,M);)_=Ai(_),b=_*2;return Xn(_,T)}function m(_){let b=_*2,M=wn,T=An;for(;!dn(b,M);)_=Ri(_,T),b=_*2;return Xn(_,T)+wi(b,M)}let g=r*2,x=Pi,p=wn,f=An;if(dn(g,p)){let _=Xn(r,f),b=wi(g,p);return De(r,x,i),c(_,b,!1,d,h+r,i)}else{let _=Ai(r),b=Ri(r,f),M=_,T=b,A,L,y,w;if(l&&(y=i,w=t,De(M,x,y),De(T,x,w),A=l(y),L=l(w),Ls.intersectsBox(L),intersectsTriangle:L=>{L.a.applyMatrix4(l),L.b.applyMatrix4(l),L.c.applyMatrix4(l),L.needsUpdate=!0;for(let y=M*3,w=(T+M)*3;ynew Se),Ke=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Ke.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e=ji({cloneBuffers:!0},e);let n=t.geometry,s=t._roots,r=n.getIndex(),a;return e.cloneBuffers?a={roots:s.map(o=>o.slice()),index:r.array.slice()}:a={roots:s,index:r.array},a}static deserialize(t,e,n={}){if(typeof n=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Ke.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n=ji({setIndex:!0},n);let{index:s,roots:r}=t,a=new Ke(e,Vo(ji({},n),{[Ro]:!0}));if(a._roots=r,n.setIndex){let o=e.getIndex();if(o===null){let c=new Qt(t.index,1,!1);e.setIndex(c)}else o.array!==s&&(o.array.set(s),o.needsUpdate=!0)}return a}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[Ro]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer=="undefined")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[Ro]||(this._roots=Lc(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new _e))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,n=e.index.array,s=e.attributes.position,r,a,o,c,l=0,h=this._roots;for(let u=0,m=h.length;uT&&(T=q),IA&&(A=I),DL&&(L=D)}return c[u+0]!==_||c[u+1]!==b||c[u+2]!==M||c[u+3]!==T||c[u+4]!==A||c[u+5]!==L?(c[u+0]=_,c[u+1]=b,c[u+2]=M,c[u+3]=T,c[u+4]=A,c[u+5]=L,!0):!1}else{let f=u+8,v=a[u+6],_=f+m,b=v+m,M=g,T=!1,A=!1;t?M||(T=t.has(_),A=t.has(b),M=!T&&!A):(T=!0,A=!0);let L=M||T,y=M||A,w=!1;L&&(w=d(f,m,M));let z=!1;y&&(z=d(v,m,M));let q=w||z;if(q)for(let I=0;I<3;I++){let D=f+I,O=v+I,$=c[D],k=c[D+3],X=c[O],J=c[O+3];c[u+I]=$J?k:J}return q}}}traverse(t,e=0){let n=this._roots[e],s=new Uint32Array(n),r=new Uint16Array(n);a(0);function a(o,c=0){let l=o*2,h=r[l+15]===65535;if(h){let d=s[o+6],u=r[l+14];t(c,h,new Float32Array(n,o*4,6),d,u)}else{let d=o+32/4,u=s[o+6],m=s[o+7];t(c,h,new Float32Array(n,o*4,6),m)||(a(d,c+1),a(u,c+1))}}}raycast(t,e=Ue){let n=this._roots,s=this.geometry,r=[],a=e.isMaterial,o=Array.isArray(e),c=s.groups,l=a?e.side:e;for(let h=0,d=n.length;h{let f=g*3;return u(m,f,f+1,f+2,x,p)}}t={boundsTraverseOrder:n,intersectsBounds:t,intersectsTriangle:e,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let r=$e.getPrimitive(),{boundsTraverseOrder:a,intersectsBounds:o,intersectsRange:c,intersectsTriangle:l}=t;if(c&&l){let u=c;c=(m,g,x,p,f)=>u(m,g,x,p,f)?!0:wo(m,g,s,l,x,p,r)}else c||(l?c=(u,m,g,x)=>wo(u,m,s,l,g,x,r):c=(u,m,g)=>g);let h=!1,d=0;for(let u of this._roots){if(Li(u),h=Vc(0,s,o,c,a,d),Zi(),h)break;d+=u.byteLength}return $e.releasePrimitive(r),h}bvhcast(t,e,n){let{intersectsRanges:s,intersectsTriangles:r}=n,a=this.geometry.index,o=this.geometry.attributes.position,c=t.geometry.index,l=t.geometry.attributes.position;Ii.copy(e).invert();let h=$e.getPrimitive(),d=$e.getPrimitive();if(r){let m=function(g,x,p,f,v,_,b,M){for(let T=p,A=p+f;TPo.intersectsBox(m),intersectsRange:(m,g,x,p,f,v)=>(Co.copy(v),Co.applyMatrix4(Ii),t.shapecast({intersectsBounds:_=>Co.intersectsBox(_),intersectsRange:(_,b,M,T,A)=>s(m,g,_,b,p,f,T,A)}))});return $e.releasePrimitive(h),$e.releasePrimitive(d),u}intersectsBox(t,e){return qn.set(t.min,t.max,e),qn.needsUpdate=!0,this.shapecast({intersectsBounds:n=>qn.intersectsBox(n),intersectsTriangle:n=>qn.intersectsTriangle(n)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},s={},r=0,a=1/0){t.boundingBox||t.computeBoundingBox(),qn.set(t.boundingBox.min,t.boundingBox.max,e),qn.needsUpdate=!0;let o=this.geometry,c=o.attributes.position,l=o.index,h=t.attributes.position,d=t.index,u=$e.getPrimitive(),m=$e.getPrimitive(),g=$s,x=_m,p=null,f=null;s&&(p=xm,f=ym);let v=1/0,_=null,b=null;return Ii.copy(e).invert(),Ji.matrix.copy(Ii),this.shapecast({boundsTraverseOrder:M=>qn.distanceToBox(M),intersectsBounds:(M,T,A)=>A{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:A=>Ji.distanceToBox(A),intersectsBounds:(A,L,y)=>y{for(let y=A*3,w=(A+L)*3;y($i.copy(t).clamp(h.min,h.max),$i.distanceToSquared(t)),intersectsBounds:(h,d,u)=>u{h.closestPointToPoint(t,$i);let u=t.distanceToSquared($i);return u{De(0,new Float32Array(n),Hc),t.union(Hc)}),t}};var Lo=self;Lo.addEventListener("message",async function({data:i}){let t=performance.now();function e(o){let c=performance.now();(c-t>=10||o===1)&&(postMessage({error:void 0,serialized:void 0,position:void 0,progress:o}),t=c)}let{id:n,index:s,position:r,options:a}=i;try{let o=new Ge;if(o.setAttribute("position",new Qt(r,3,!1)),s&&o.setIndex(new Qt(s,1,!1)),a.includedProgressCallback&&(a.onProgress=e),a.groups){let h=a.groups;for(let d in h){let u=h[d];o.addGroup(u.start,u.count,u.materialIndex)}}let c=new Ke(o,a),l=Ke.serialize(c,{cloneBuffers:!1});Lo.postMessage({id:n,error:void 0,serialized:l,position:r,progress:1},[l.index.buffer,r.buffer,...l.roots])}catch(o){Lo.postMessage({id:n,error:o,serialized:void 0,position:void 0,progress:1})}});\n/*! Bundled license information:\n\nthree/build/three.module.js:\n (**\n * @license\n * Copyright 2010-2023 Three.js Authors\n * SPDX-License-Identifier: MIT\n *)\n*/\n')}Ya.decoderPath="libs/draco/gltf/";var yP=class{constructor(){this.running=!1,this.worker=new O4,this.worker.onerror=e=>{throw e.message?new Error(`[GenerateMeshBVHWorker] Could not create Web Worker with error "${e.message}"`):new Error("[GenerateMeshBVHWorker] Could not create Web Worker.")}}isRunning(){return this.running}generate(e,t={}){if(this.running)return void se.warn("[GenerateMeshBVHWorker] Already running job.");if(!this.worker)return void se.warn("[GenerateMeshBVHWorker] Worker has been disposed.");let{worker:n}=this;this.running=!0;let i=new Map;e.forEach((e=>{i.set(e.id,e)}));let r=0;return new Promise(((e,a)=>{let s=()=>{++r===i.size&&(this.running=!1,n.onmessage=null,e())};n.onerror=e=>{se.warn(`[GenerateMeshBVHWorker] ${e.message}`),a(new Error(`[GenerateMeshBVHWorker] ${e.message}`)),this.running=!1},n.onmessage=e=>{this.running=!1;let{data:n}=e;if(n.error)se.warn(n.error),s();else if(n.serialized){let{serialized:e,position:r,id:a}=n,o=i.get(a),l=Rc.deserialize(e,o,{setIndex:!1}),h=Object.assign({setBoundingBox:!0},t);if(h.transferred&&(o.attributes.position.array=r),o.index)t.saveOriginalIndex&&!o.userData.originalIndex&&(o.userData.originalIndex=o.index.array),se.debug("before update, index:",o.index.array),o.index.array=e.index;else{let t=new gn(e.index,1,!1);o.setIndex(t)}o.index&&(se.debug("after update, index:",o.index.array),o.index.needsUpdate=!0),h.setBoundingBox&&!o.boundingBox&&(o.boundingBox=l.getBoundingBox(new Ot)),o.boundsTree=l,s()}else t.onProgress&&t.onProgress(n.progress)};for(let r of i){let e=r[0],i=r[1],a=i.index?i.index.array:void 0,o=i.attributes.position,l=o.array;if(o.isInterleavedBufferAttribute||a&&a.isInterleavedBufferAttribute){se.warn("[GenerateMeshBVHWorker] InterleavedBufferAttribute are not supported for the geometry attributes."),s();continue}let h=[];t.transferred&&(h.push(l),a&&(h.push(a),t.saveOriginalIndex&&(i.userData.originalIndex=a.slice()))),n.postMessage({id:e,index:a,position:l,options:Ri(wr({},t),{onProgress:null,includedProgressCallback:Boolean(t.onProgress),groups:[...i.groups]})},h.length>0?h.map((e=>e.buffer)):[])}}))}dispose(){this.worker.terminate(),this.worker=void 0}},Yf=class{constructor(e){this.running=!1,this.workers=[];let t=1;e?t=e:window.navigator&&(t=Math.max(t,window.navigator.hardwareConcurrency-1));for(let n=0;n{let i=this.workers.length,r=e.length,a=[],s=Math.floor(r/i),o=r%i,l=0,h=0;for(let c=0;c=h)break;se.debug("startIndex: "+l+" endIndex: "+h),a.push(n.generate(e.slice(l,h),t))}Promise.allSettled(a).then((()=>{this.running=!1,n()}))}));se.warn("[BVHHelper] Worker has been disposed.")}}))}dispose(){for(let e=0;e{e.traverse((e=>{let i=e;if(i.isMesh&&i.geometry&&Ar.isMergedMesh(i)&&!(i instanceof Pi)){if(n.has(i.geometry.id))return;i.geometry.index&&t.saveOriginalIndex&&(i.geometry.userData.originalIndex=i.geometry.index.array.slice()),i.geometry.boundsTree=new Rc(i.geometry,t),n.add(i.geometry.id)}}))}))}static createMeshBvhAsync(e,t={}){let n=new Set,i=[];e.forEach((e=>{e.traverse((e=>{let t=e;if(t.isMesh&&t.geometry&&Ar.isMergedMesh(t)&&!(t instanceof Pi)){if(n.has(t.geometry.id))return;i.push(t.geometry),n.add(t.geometry.id)}}))}));let r=new Yf;r.generate(i,t).then((()=>{r.dispose()}))}},ive=class{constructor(e,t,n,i,r){this.targetPixelHeight=100,this.canvasHeight=800,this.camera=e,this.object=n,this.targetPixelHeight=i,this.canvasHeight=r,this.adjustSize(),t.addEventListener("update",(()=>{this.adjustSize()}))}adjustSize(){let e=new Ot;if(this.object.updateMatrix(),e.expandByObject(this.object),!e)return;let t=e.max.x-e.min.x,n=this.camera.position.distanceTo(this.object.position),i=xvt(t,n,this.canvasHeight);if(Math.abs(i-this.targetPixelHeight)<5)return;let r=this.object.scale.x;r*=this.targetPixelHeight/i,this.object.scale.set(r,r,r),this.object.updateMatrix()}},xvt=(e,t,n=800,i=45)=>{let r=i*(Math.PI/180);return n*(e/(2*Math.tan(r/2)*t))},xP,bP=new be,EP=new be,_P=new be,sve=new be,bvt=new be,Evt=new be,wo=class extends Bi{constructor(e){super(Mt.guid()),this.needsFrustumCulled=!1,this.renderOrder=1e3,this.snapType="TripleCross",this.snapLineVisible=!1,this.snapType=e,this.drawSnapFunctions={TripleCross:this.drawTripleCorss.bind(this),Square:this.drawSquare.bind(this),Triangle:this.drawTriangle.bind(this),CircleWithCross:this.drawCircleWithCross.bind(this),Cross:this.drawCross.bind(this),Perpendicular:this.drawPerpendicular.bind(this)}}setSnapLineVisible(e){this.snapLineVisible=e}draw(e,t){this.osnapInfo&&(this.snapLineVisible&&this.drawSnapLine(e,t),e.save(),e.fillStyle=wo.FILL_COLOR_NONE,e.strokeStyle=wo.lineColor,e.lineWidth=wo.lineWidth,e.beginPath(),this.drawSnapFunctions[this.snapType](e,t),xP&&this.drawDebug(e,t),e.closePath(),e.fill(),e.stroke(),e.restore())}drawDebug(e,t){null==xP||xP.forEach((n=>{let i=this.transToScreenCoord(n.start,t),r=this.transToScreenCoord(n.end,t);e.moveTo(i.x,i.y),e.lineTo(r.x,r.y)}))}drawSelect(e,t){}isPointInPath(e){return!1}drawSnapLine(e,t){e.save(),e.strokeStyle=wo.SNAP_LINE_COLOR,e.lineWidth=wo.lineWidth;let n=this.osnapInfo.line;if(!n)return;let i=this.transToScreenCoord(n.start,t),r=this.transToScreenCoord(n.end,t);e.moveTo(i.x,i.y),e.lineTo(r.x,r.y),e.stroke(),e.restore()}drawTripleCorss(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=wo.iconSize/1.6,r=bP.set(n.x,n.y-i),a=EP.set(n.x-.87*i,n.y+i/1.4),s=_P.set(n.x+.87*i,n.y+i/1.4);e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.moveTo(n.x,n.y),e.lineTo(a.x,a.y),e.moveTo(n.x,n.y),e.lineTo(s.x,s.y)}drawSquare(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=wo.iconSize,r=wo.iconSize;e.rect(n.x-i/2,n.y-r/2,i,r)}drawTriangle(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=wo.iconSize/1.6,r=bP.set(n.x,n.y-i),a=EP.set(n.x-.87*i,n.y+i/2),s=_P.set(n.x+.87*i,n.y+i/2);e.moveTo(r.x,r.y),e.lineTo(a.x,a.y),e.lineTo(s.x,s.y)}drawCircleWithCross(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=wo.iconSize/2;e.arc(n.x,n.y,i,0,2*Math.PI),e.moveTo(n.x-i/1.8,n.y),e.lineTo(n.x+i/1.8,n.y),e.moveTo(n.x,n.y-i/1.8),e.lineTo(n.x,n.y+i/1.8)}drawCross(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=wo.iconSize/2,r=bP.set(n.x-i,n.y-i),a=EP.set(n.x+i,n.y+i),s=_P.set(n.x+i,n.y-i),o=sve.set(n.x-i,n.y+i);e.moveTo(r.x,r.y),e.lineTo(a.x,a.y),e.moveTo(s.x,s.y),e.lineTo(o.x,o.y)}drawPerpendicular(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=wo.iconSize/2,r=bP.set(n.x,n.y),a=EP.set(n.x-i,n.y),s=_P.set(n.x,n.y+i),o=sve.set(n.x-i,n.y-i),l=bvt.set(n.x-i,n.y+i),h=Evt.set(n.x+i,n.y+i);e.moveTo(a.x,a.y),e.lineTo(r.x,r.y),e.lineTo(s.x,s.y),e.moveTo(o.x,o.y),e.lineTo(l.x,l.y),e.lineTo(h.x,h.y),e.lineTo(o.x,o.y)}update(e){this.osnapInfo=e}getClassType(){return"SnapDrawable"}},As=wo;As.lineColor="rgba(255, 119, 0, 1)",As.FILL_COLOR_NONE="rgba(0, 0, 0, 0)",As.SNAP_LINE_COLOR="rgba(255, 240, 0, 0.3)",As.lineWidth=2,As.iconSize=14,Hn._registerDrawableClass(As);var k4=(e=>(e[e.None=0]="None",e[e.Vertex=1]="Vertex",e[e.MiddlePoint=2]="MiddlePoint",e[e.Edge=4]="Edge",e[e.Face=8]="Face",e[e.FootOfPerpendicular=16]="FootOfPerpendicular",e[e.Intersection=32]="Intersection",e[e.CircleCenter=64]="CircleCenter",e))(k4||{}),_vt=1e-5,qi=new O,oa=new O,Iy=new O,m_=new O,rg=new Qe,g_=new sa;function Tvt(e,t){let n=Number.MAX_VALUE,i=0;for(let r=0;r65535?new Uint32Array(i):new Uint16Array(i);for(let n=0,r=i;n{e.visible=!1,this.drawableList.addDrawable(e)}))}isOSnapTypeEnabled(e){return!!(this.enabledOSnapTypes&e)}setOSnapTypeEnabled(e,t){if(t)this.enabledOSnapTypes|=e;else{let t=~e;this.enabledOSnapTypes&=t}}setSnapTolerance(e){this.snapToleranceInWorldCoord=e}getSnapTolerance(){return this.snapToleranceInWorldCoord}setIntersectionLimit(e){this.intersectionLimit=e}getIntersectionLimit(){return this.intersectionLimit}getMarkerLineColor(){return Cn.colorStr2Rgba(As.lineColor)}setMarkerLineColor(e){As.lineColor=Cn.rgba2Color(e)}getMarkerLineWidth(){return As.lineWidth}setMarkerLineWidth(e){As.lineWidth=e}getMarkerIconSize(){return As.iconSize}setMarkerIconSize(e){As.iconSize=e}getMarker(e){return this.markers[e]}setAllSnapLinesVisible(e){Object.values(this.markers).forEach((t=>{t.setSnapLineVisible(e)}))}deactivate(){var e;this.activeOSnapType&&(this.markers[this.activeOSnapType].visible=!1,null==(e=this.overlayRender)||e.render()),this.activeOSnapType=0}destroy(){}handleSnap(e,t,n){if(!e||e.length<1)return void this.deactivate();se.debug("[OSnap] intersections before handleSnap:",e);let i,r=[],a=!1;for(let o of e)o.object instanceof xt?(i||(i=o.point),!a&&"groundPlane"!==o.object.name&&(r.push(o),a=!0)):r.push(o);if(!t&&i){i.setZ(0);for(let t of r)t.point.z=0,t.distance=t.point.distanceTo(i);let e=e=>e instanceof ii?0:e instanceof Wr?2:e instanceof ur?1:3;r.sort(((t,n)=>{let i=e(t.object),r=e(n.object);return i!==r?i-r:t.distance-n.distance}))}i||(se.warn("[OSnap] Potential to produce erroneous snap results"),i=r[0].point),se.debug("[OSnap] intersections:",r),se.debug("[OSnap] mousePosition:",i);let s=this.getSnapPointAndUpdateMarker(i,r,t,n);return(null==s?void 0:s.clone())||i}getSnapPointAndUpdateMarker(e,t,n,i){if(!t.length)return void this.activateMarker(0);let r=this.getSnapInfo(e,t,n,i);if(r&&0!==r.type)return this.activateMarker(r.type,r),r.point;this.activateMarker(0)}activateMarker(e,t){var n;this.activeOSnapType&&(this.markers[this.activeOSnapType].visible=!1),this.activeOSnapType=e;let i=this.markers[e];i&&t&&(i.update(t),i.visible=!0),null==(n=this.overlayRender)||n.render()}getFootOfPerpendicular(e,t,n=_vt){let{start:i,end:r}=t,a=i.x-r.x,s=i.y-r.y,o=i.z-r.z;if(i.distanceTo(r){let n=this.osnapTypePriorities[e.type],i=this.osnapTypePriorities[t.type];return n!==i?n-i:e.distance-t.distance})),a[0]}getOsnapInfoListFromMesh(e,t,n,i){if(i=this.osnapTypePriorities[16]&&this.isOSnapTypeEnabled(16)){let t=this.getFootOfPerpendicular(s,o,i),n=e.distanceTo(t);if(n<=i)return{distance:Zt.floorNumber(n,7),type:16,point:t.clone()}}if(ai)return;let h=e.distanceTo(t),c=e.distanceTo(n);if(Math.min(h,c)<=i&&this.isOSnapTypeEnabled(1)){let e=h,i=t;return c{let n=this.osnapTypePriorities[e.type],i=this.osnapTypePriorities[t.type];return n!==i?n-i:e.distance-t.distance})),o[0]}getOsnapInfoListFromPoint(e,t,n,i,r){if(ri)return;let l={distance:o,point:qi.clone(),type:1};if("CircleCenter"===a.userData.type){if(!this.isOSnapTypeEnabled(64))return;l.type=64}else if(se.debug("[OSnap] Other types of vertices !"),!this.isOSnapTypeEnabled(1))return;return l}getIntersectsIncludeOutline(e,t){let n=e.slice(),i=[];for(let a=0;a0&&(r=t.intersectObjects(i)||[],se.debug("[OSnap] Intersected with newly created edges: ",r),r.length>0&&n.push(...r)),n.sort(((e,t)=>e.distance-t.distance)),n}},F4=ji(Fl(),1),Yl=class{constructor(e,t,n){this.follow=e=>{this.node.style.left=e.offsetX+15+"px",this.node.style.top=e.offsetY-30+"px"},this.show=()=>this.node.hasAttribute("hidden")&&this.node.removeAttribute("hidden"),this.hide=()=>!this.node.hasAttribute("hidden")&&this.node.setAttribute("hidden",""),this.destroy=()=>{this.target?this.target.removeEventListener(wf,this.follow):document.removeEventListener(wf,this.follow),this.parentNode.removeChild(this.node)},this.node=document.createElement("div"),this.node.id=e,t&&this.node.append(t),this.childNode=document.createElement("div"),this.target=null==n?void 0:n.target,this.parentNode=(null==n?void 0:n.parentNode)||document.body,null!=n&&n.followPointer&&(this.node.classList.add("follow-tooltip"),this.target?this.target.addEventListener(wf,this.follow):document.addEventListener(wf,this.follow)),this.parentNode.appendChild(this.node),(null==n||!n.showOnCreate)&&this.node.setAttribute("hidden","")}setContent(e){this.node.textContent&&(this.node.textContent=null),(0,F4.forEach)(this.node.children,(e=>{this.node.removeChild(e)})),this.node.append(e),this.node.appendChild(this.childNode)}updateChildContent(e){this.childNode.textContent&&(this.childNode.textContent=null),(0,F4.forEach)(this.childNode.children,(e=>{this.childNode.removeChild(e)})),this.childNode.append(e)}},wP=class{constructor(e){this.active=!1,this.isResolvedOrRejected=!1,this.mouseClicked=e=>{var t;if(e.markupData){let n=e.markupData.id,i=null==(t=this.viewer.overlayRender)?void 0:t.getDrawableById(n);if(i){let e=i.getBounds();e=e.clone().expandByScalar(20*this.viewer.getPixelSizeInWorldCoord());let t=un.worldCoordinate2NormalizedScreenCoordinate(e.min,this.camera,this.viewerContainer),n=un.worldCoordinate2NormalizedScreenCoordinate(e.max,this.camera,this.viewerContainer),r=new Ji(new be(Math.min(t.x,n.x),Math.min(t.y,n.y)),new be(Math.max(t.x,n.x),Math.max(t.y,n.y)));r.min.x=Math.max(r.min.x,0)*this.viewerContainer.clientWidth,r.min.y=Math.max(r.min.y,0)*this.viewerContainer.clientHeight,r.max.x=Math.min(r.max.x,1)*this.viewerContainer.clientWidth,r.max.y=Math.min(r.max.y,1)*this.viewerContainer.clientHeight,this.resolve&&(this.resolve(r),this.isResolvedOrRejected=!0),this.deactivate();let a=this.viewer;"function"==typeof a.clearSelection&&a.clearSelection()}}},this.keydown=e=>{"Escape"===e.code&&this.deactivate()},this.viewer=e}get viewerContainer(){return this.viewer.viewerContainer}get camera(){return this.viewer.camera}isActive(){return this.active}activate(){var e,t;if(this.isActive())return void(this.reject&&(this.deactivate(),this.reject("PickMarkupHelper is already actived!"),this.isResolvedOrRejected=!0));this.active=!0,this.viewer.addEventListener("MouseClicked",this.mouseClicked),null==(e=this.viewer.getInputManager())||e.addEventListener("keydown",this.keydown);let n=this.viewer.translate;if(n){this.tooltip=new Yl("pick-markup-tooltip",n("Tooltip.pickMarkup"),{followPointer:!0,showOnCreate:!0,parentNode:this.viewer.widgetContainer,target:this.viewerContainer});let e=document.getElementById("pick-markup-tooltip");e&&(e.style.pointerEvents="none");let i=n("Tooltip.pickMarkup");i&&this.tooltip&&(null==(t=this.tooltip)||t.setContent(i))}this.viewer.dispatchEvent("PickMarkupActivated")}deactivate(){var e,t,n;this.active=!1,this.viewer.removeEventListener("MouseClicked",this.mouseClicked),null==(e=this.viewer.getInputManager())||e.removeEventListener("keydown",this.keydown),null==(t=this.tooltip)||t.hide(),null==(n=this.tooltip)||n.destroy(),this.tooltip=void 0,this.viewer.dispatchEvent("PickMarkupDeactivated"),this.resolve&&!this.isResolvedOrRejected&&(this.resolve(void 0),this.isResolvedOrRejected=!0)}pick(){return ft(this,null,(function*(){return new Promise(((e,t)=>{this.resolve=e,this.reject=t,this.activate()}))}))}destroy(){this.deactivate(),this.isResolvedOrRejected||this.reject&&this.reject("PickMarkupHelper is not done for some reason!")}},SP=class{constructor(e){this.mouseDown=!1,this.mouseMove=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.tempEnableRotate=!1,this.active=!1,this.isResolvedOrRejected=!1,this.mousedown=e=>{var t,n;if(0===e.button){this.mouseDown=!0;let i=new be(e.x,e.y);this.mouseDownPositionX=i.x,this.mouseDownPositionY=i.y,null==(t=this.tooltip)||t.hide(),null==(n=this.tooltip)||n.destroy(),this.tooltip=void 0}},this.mousemove=e=>{if(!this.mouseDown)return;let t=new be(e.x,e.y);if(this.mouseDownPositionX>=0&&this.mouseDownPositionY>=0&&(Math.abs(t.x-this.mouseDownPositionX)>=5||Math.abs(t.y-this.mouseDownPositionY)>=5)){this.mouseMove=!0;let e=new be(Math.min(this.mouseDownPositionX,t.x),Math.min(this.mouseDownPositionY,t.y)),n=new be(Math.max(this.mouseDownPositionX,t.x),Math.max(this.mouseDownPositionY,t.y));this.drawRect(e,n)}},this.mouseup=e=>{if(this.mouseDown&&this.mouseMove){let t=new be(e.x,e.y),n=new be(Math.min(this.mouseDownPositionX,t.x),Math.min(this.mouseDownPositionY,t.y)),i=new be(Math.max(this.mouseDownPositionX,t.x),Math.max(this.mouseDownPositionY,t.y)),r=new Ji(n,i);this.resolve&&(this.resolve(r),this.isResolvedOrRejected=!0),this.deactivate(),this.setRectDomVisible(!1)}this.mouseDown=!1,this.mouseMove=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1},this.keydown=e=>{"Escape"===e.code&&this.deactivate()},this.viewer=e,this.input=e.getInputManager()}get viewerContainer(){return this.viewer.viewerContainer}isActive(){return this.active}activate(){var e;if(this.isActive())return void(this.reject&&(this.deactivate(),this.reject("BoxSelectHelper is already actived!"),this.isResolvedOrRejected=!0));this.active=!0,this.input.addEventListener("pointerdown",this.mousedown),this.input.addEventListener("pointermove",this.mousemove),this.input.addEventListener("pointerup",this.mouseup),this.input.addEventListener("keydown",this.keydown);let t=this.viewer.controls;this.tempKey=t.mouseButtons.left,this.tempEnableRotate=t.enableRotate,t.mouseButtons.left=yt.NONE,this.tempTouch=t.touches.one,t.touches.one=yt.NONE,t.enableRotate=!1;let n=this.viewer.translate;if(n){this.tooltip=new Yl("box-select-tooltip",n("Tooltip.boxSelect"),{followPointer:!0,showOnCreate:!0,parentNode:this.viewer.widgetContainer,target:this.viewerContainer});let t=document.getElementById("box-select-tooltip");t&&(t.style.pointerEvents="none");let i=n("Tooltip.boxSelect");i&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(i))}this.viewer.dispatchEvent("BoxSelectActivated")}deactivate(){var e,t;this.active=!1,this.input.removeEventListener("pointerdown",this.mousedown),this.input.removeEventListener("pointermove",this.mousemove),this.input.removeEventListener("pointerup",this.mouseup),this.input.removeEventListener("keydown",this.keydown),null==(e=this.tooltip)||e.hide(),null==(t=this.tooltip)||t.destroy(),this.tooltip=void 0,this.viewer.controls.mouseButtons.left=this.tempKey,this.viewer.controls.enableRotate=this.tempEnableRotate,this.viewer.controls.touches.one=this.tempTouch,this.viewer.dispatchEvent("BoxSelectDeactivated"),this.resolve&&!this.isResolvedOrRejected&&(this.resolve(void 0),this.isResolvedOrRejected=!0)}drawRect(e,t){this.rectDom||(this.rectDom=document.createElement("div"),this.rectDom.style.cssText=`position: absolute;border: ${SP.BORDER_WIDTH} solid ${SP.BORDER_COLOR};`,this.viewerContainer.appendChild(this.rectDom)),this.setRectDomVisible(!0),this.rectDom.style.left=`${e.x}px`,this.rectDom.style.top=`${e.y}px`;let n=Math.abs(t.x-e.x),i=Math.abs(t.y-e.y);this.rectDom.style.width=`${n}px`,this.rectDom.style.height=`${i}px`}setRectDomVisible(e){this.rectDom&&(this.rectDom.style.display=e?"inline-block":"none")}select(){return ft(this,null,(function*(){return new Promise(((e,t)=>{this.resolve=e,this.reject=t,this.activate()}))}))}destroy(){var e;this.deactivate(),null==(e=this.rectDom)||e.remove(),this.rectDom=void 0,this.isResolvedOrRejected||this.reject&&this.reject("BoxSelectHelper is not done for some reason!")}},$f=SP;$f.BORDER_COLOR="#fff000",$f.BORDER_WIDTH="2px";var dr=class extends cs{constructor(e,t){if(!t.id)throw new Error("[Plugin] Missing plugin id!");super(),this.id=t.id,this.viewer=e,e.addPlugin(this)}destroy(){this.viewer.removePlugin(this)}},Ly=(e=>(e.BaseViewer="BaseViewer",e.BimViewer="BimViewer",e.DxfViewer="DxfViewer",e.VRViewer="VRViewer",e))(Ly||{}),Zf=class extends cs{constructor(e){super(),this.name="BaseViewer",this.translate=this.initLocalization(),this.height=0,this.width=0,this.jobCount=0,this.enableOverlayRenderer=!0,this.frustumSize=this.width,this.lastFrameExecuteTime=Date.now(),this.minFrameInterval=10,this.plugins=[],this.viewerCfg=e,this.undoRedoManager=new sC,this.initLogLevel(),this.initLocalization(),Dn.isBrowser&&!e.context&&(this.initContainer(),this.initViewerContainer(),this.initWidgetContainer())}initLogLevel(){let e=this.viewerCfg.logLevel;e&&pde(e)}initLocalization(){var e;let t=(null==(e=this.viewerCfg)?void 0:e.language)||"cn";return eg.init({lng:t,debug:!1,resources:{en:{translation:$de},cn:{translation:Zde}}}),eg.t}initContainer(){let e=document.getElementById(this.viewerCfg.containerId);e||(se.error("[Viewer] containerId:",this.viewerCfg.containerId,"is not found in dom tree! will append to document body"),e=document.body);let t=document.createElement("div");t.classList.add("gemini-container"),t.style.cssText="width: 100%; height: 100%; position: relative;",e.appendChild(t),this.container=t}initViewerContainer(){let e=this.container;if(!e)return;let t=document.createElement("div");t.classList.add("gemini-viewer-container"),t.style.cssText="width: 100%; height: 100%;display: inline-block;position: relative; overflow: hidden;",e.appendChild(t),this.width=e.clientWidth,this.height=e.clientHeight,this.viewerContainer=t}initWidgetContainer(){let e=this.container;if(!e)return;let t=document.createElement("div");t.classList.add("gemini-widget-container"),e.appendChild(t),this.widgetContainer=t}initSpinner(){var e;if(!this.viewerCfg.enableSpinner)return;let t=document.createElement("div");t.classList.add("gemini-spinner"),t.appendChild(document.createElement("span")),t.appendChild(document.createElement("span")),t.appendChild(document.createElement("span")),t.appendChild(document.createElement("span")),null==(e=this.viewerContainer)||e.appendChild(t),this.spinner=t,this.setSpinnerVisibility(this.jobCount>0)}setSpinnerVisibility(e){this.spinner&&(e?this.spinner.classList.remove("hidden"):this.spinner.classList.add("hidden"))}increaseJobCount(){this.setSpinnerVisibility(++this.jobCount>0)}decreaseJobCount(){this.jobCount<=0?se.warn("[Viewer] jobCount should be at least 1 here!"):this.setSpinnerVisibility(--this.jobCount>0)}resize(e,t){let n=this.camera;if(n&&t>0){if(n instanceof cr)n.aspect=e/t;else if(n instanceof Ur){let i=e/t;n.left=-this.frustumSize/2,n.right=this.frustumSize/2,n.top=this.frustumSize/i/2,n.bottom=-this.frustumSize/i/2}n.updateProjectionMatrix(),this.renderer&&this.renderer.setSize(e,t,!0),this.overlayRender&&this.overlayRender.setSize(e,t)}this.width=e,this.height=t,this.enableRender()}destroy(){var e,t,n,i;this.clearPlugins(),null==(e=this.widgetContainer)||e.remove(),this.widgetContainer=void 0,null==(t=this.viewerContainer)||t.remove(),this.viewerContainer=void 0,null==(n=this.scene)||n.clear(),this.scene=void 0,this.requestAnimationFrameHandle&&(cancelAnimationFrame(this.requestAnimationFrameHandle),this.requestAnimationFrameHandle=void 0),this.renderer&&(this.renderer.domElement.remove(),this.renderer.clear(),this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer=void 0),this.overlayRender&&(this.overlayRender.destroy(),this.overlayRender=void 0),this.camera=void 0,this.controls&&(this.controls.dispose(),this.controls=void 0),this.groundPlane&&(this.groundPlane.geometry.dispose(),this.groundPlane.clear(),this.groundPlane=void 0),this.removeEventListener(),null==(i=this.undoRedoManager)||i.destroy(),this.spinner&&(this.spinner.remove(),this.spinner=void 0)}getInputManager(){return this.inputManager}getViewConfig(){return this.viewerCfg}enableRender(){}getRaycaster(){}getRaycastableObjectsByMouse(e){return[]}getBBox(){}getActiveSection(){}flyTo(e,t){}is3d(){return!0}get measurePlugin(){}getMarkupManager(){}deactivateMeasurement(){}setMeasurementVisibility(e,t){return!1}screenshot(e){return ft(this,null,(function*(){}))}getPixelSizeInWorldCoord(){let e=this.camera,{clientWidth:t,clientHeight:n}=this.viewerContainer,i=1;if("OrthographicCamera"===e.type){let r=e;i=Math.max(r.right-r.left,r.top-r.bottom)/r.zoom/Math.max(t,n)}else if("PerspectiveCamera"===e.type){let t=e,r=new O;e.getWorldPosition(r);let a=new O,s=this.controls;s.getTarget?s.getTarget(a):s.target&&(a=s.target),r&&a&&(i=r.distanceTo(a)*Math.tan(t.fov/2*Math.PI/180)*2/n)}return i}getUniqueModelId(e){let t=e,n=e=>!!this.loadedModels.find((t=>t.modelId===e));if(n(t)){let e=1;for(;n(`${t}_${e}`);)e++;t=`${t}_${e}`,se.warn(`[Viewer] Model '${t}' is loaded more than once!`)}return t}addPlugin(e){this.plugins.find((t=>t.id===e.id))?se.error(`[Viewer] Plugin already exist: ${e.id}`):(this.plugins.push(e),se.debug(`[Viewer] Added plugin: ${e.id}`))}removePlugin(e){for(let t=0,n=this.plugins.length;tt.id===e))}},Dy=class{constructor(e){this.active=!1,this.viewer=e,this.boxSelectHelper=new $f(e)}get viewerContainer(){return this.viewer.viewerContainer}get camera(){return this.viewer.camera}get raycaster(){return this.viewer.getRaycaster()}isActive(){return this.active}activate(){var e;this.active=!0,null==(e=this.boxSelectHelper)||e.select().then((e=>{e&&this.handleZoomToRect(e.min,e.max)}))}deactivate(){var e;this.active=!1,null==(e=this.boxSelectHelper)||e.deactivate()}pickPositionByScreenPoint(e){let t=un.screenPoint2NdcPoint(e,this.camera,this.viewerContainer);this.raycaster.layers.set(10),this.raycaster.setFromCamera(t,this.camera);let n=[];"BimViewer"===this.viewer.name?n=this.viewer.getRaycastableObjectsByMouse({x:e.x,y:e.y}):"DxfViewer"===this.viewer.name&&(n=[this.viewer.groundPlane]);let i=this.raycaster.intersectObjects(n)||[];if(i.length>0)return i[0].point}handleZoomToRect(e,t){let n=this.pickPositionByScreenPoint(e),i=this.pickPositionByScreenPoint(t);if(n&&i){let e=new O(Math.min(n.x,i.x),Math.min(n.y,i.y),Math.min(n.z,i.z)),t=new O(Math.max(n.x,i.x),Math.max(n.y,i.y),Math.max(n.z,i.z)),r=new Ot(e,t);this.viewer.zoomToBBox(r)}}destroy(){var e;null==(e=this.boxSelectHelper)||e.destroy(),this.boxSelectHelper=void 0}},MP=class extends Bi{constructor(e){super("MobileHelper"),this.needsFrustumCulled=!1,this.renderOrder=1e3,this.position=e}setPosition(e){this.position=e}isPointInPath(e,t){return!1}draw(e,t){this.drawInnerCircle(e),this.drawOuterRing(e),this.drawSnapTriangle(e)}drawInnerCircle(e){let{x:t,y:n}=this.position;e.save(),e.fillStyle="rgba(137, 137, 138, 0.8)",e.beginPath(),e.arc(t,n,25,0,2*Math.PI),e.closePath(),e.fill(),e.restore()}drawOuterRing(e){let{x:t,y:n}=this.position;e.save(),e.strokeStyle="rgba(17, 17, 19, 0.8)",e.lineWidth=10,e.beginPath(),e.arc(t,n,30,0,2*Math.PI),e.closePath(),e.stroke(),e.restore(),e.save(),e.strokeStyle="rgba(173, 173, 174, 0.8)",e.lineWidth=3,e.beginPath(),e.arc(t,n,35,0,2*Math.PI),e.closePath(),e.stroke(),e.restore()}drawSnapTriangle(e){let{x:t,y:n}=this.position;e.save(),e.fillStyle="rgba(17, 17, 19, 0.8)",e.strokeStyle="rgba(137, 137, 138, 0.8)",e.lineWidth=2,e.beginPath(),e.moveTo(t-35,n-35),e.lineTo(t-35+12,n-35),e.lineTo(t-35,n-35+12),e.closePath(),e.fill(),e.stroke(),e.restore()}translate(e,t){this.position.add(new be(e,t))}getTouchPoint(){return{x:this.position.x-35,y:this.position.y-35}}isIntersect(e){return this.position.x-35e.x&&this.position.y+35>e.y}drawSelect(e,t){}getClassType(){return"MobileTouchHelperDrawable"}},$l=(e=>(e.Distance="Distance",e.Area="Area",e.Angle="Angle",e.Coordinate="Coordinate",e))($l||{}),nh=class extends cs{constructor(e,t,n,i,r){super(),this.mouseMoved=!1,this.mouseDowned=!1,this.touchDowned=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.snapPoint=void 0,this.touchstart=e=>{this.mobileTouchHelper&&this.mobileTouchHelper.isIntersect(e)&&!this.touchDowned&&(this.clearClickedDrawable(),this.viewer.controls&&(this.viewer.controls.enabled=!1),this.touchDowned=!0,this.mouseDownPositionX=e.x,this.mouseDownPositionY=e.y)},this.touchmove=e=>{if(e.pointers&&e.pointers.length>1)return;let{width:t,height:n}=this.canvas.getBoundingClientRect();if(!(e.x>t-15||e.x<35||e.y<15||e.y>n-35)&&this.touchDowned&&this.mobileTouchHelper){let t=e.x-this.mouseDownPositionX,n=e.y-this.mouseDownPositionY;this.mobileTouchHelper.translate(t,n),this.mouseDownPositionX=e.x,this.mouseDownPositionY=e.y;let i=this.mobileTouchHelper.getTouchPoint(),r=this.getIntersections(i);if(!r.length)return void this.osnapHelper.deactivate();let a=Date.now();if(this.snapPoint=this.osnapHelper.handleSnap(r,this.viewer.is3d(),this.lastMouseDownPosition),se.debug(`[BaseMeasurement] handleSnap costs ${(Date.now()-a)/1e3}s`),!this.snapPoint)return void console.warn("[BaseMeasurement] Failed to find a snap point!");this.onMouseMove(this.snapPoint)}},this.touchend=e=>{var t;if(this.viewer.controls&&(this.viewer.controls.enabled=!0),!(e.pointers&&e.pointers.length>1)){if(this.touchDowned){this.touchDowned=!1;let e=null==(t=this.mobileTouchHelper)?void 0:t.getTouchPoint();this.onMouseClick(e)}else this.selectMeasurementByEvent(e);Dn.isMobile&&(this.osnapHelper.deactivate(),this.dispatchEvent("Updated"))}},this.mousedown=e=>{this.mouseMoved=!1,this.mouseDowned=!0,this.mouseDownPositionX=e.x,this.mouseDownPositionY=e.y},this.mousemove=e=>{if(this.lastMoveEvent=e,this.mouseDownPositionX>=0&&this.mouseDownPositionY>=0&&(Math.abs(e.x-this.mouseDownPositionX)>5||Math.abs(e.y-this.mouseDownPositionY)>5)&&(this.mouseMoved=!0),this.mouseDowned)return;let t=this.getIntersections(e);if(!t.length)return void this.osnapHelper.deactivate();let n=Date.now();this.snapPoint=this.osnapHelper.handleSnap(t,this.viewer.is3d(),this.lastMouseDownPosition),se.debug(`[BaseMeasurement] this.handleSnap costs ${(Date.now()-n)/1e3}s`),this.snapPoint?this.onMouseMove(this.snapPoint):console.warn("[BaseMeasurement] Failed to find a snap point!")},this.mouseup=e=>{this.mouseDowned=!1,this.mouseMoved||this.onMouseClick(e)},this.dblclick=()=>{se.info("[Measure] Double clicked")},this.keydown=e=>{if("Enter"===e.code){let e={x:0,y:0,pageX:0,pageY:0,clientX:0,clientY:0,deltaX:0,deltaY:0,button:2,movementX:0,movementY:0,deltaMode:0,pointerId:0,timestamp:0,buttons:0,pointerType:"mouse",altKey:!1,ctrlKey:!1,shiftKey:!1,metaKey:!1};this.onMouseClick(e)}else"Escape"===e.code&&this.cancel()},this.getIntersections=e=>{if(!this.raycaster)return[];this.raycaster.layers.set(11);let t=this.viewer.getRaycastableObjectsByMouse(e);se.debug(`[BaseMeasurement] The count of raycastable object is ${t.length}`,t);let n=Date.now(),i=this.raycaster.intersectObjects(t,!0)||[];return se.debug(`[BaseMeasurement] this.raycaster.intersectObjects costs ${(Date.now()-n)/1e3}s`),this.renderer.clippingPlanes.length>0&&(i=i.filter((e=>this.renderer.clippingPlanes.every((function(t){return t.distanceToPoint(e.point)>0}))))),i},this.type=e,this.viewer=t,this.inputManager=n,this.drawList=i,this.osnapHelper=r}get canvas(){var e;return null==(e=this.viewer.renderer)?void 0:e.domElement}get camera(){return this.viewer.camera}get renderer(){return this.viewer.renderer}get isActive(){return!!this.raycaster}get isMeasuring(){return!1===this.completed}setTouchHelper(e){this.mobileTouchHelper=e}createMobileExitButton(){let e=this.viewer.widgetContainer,t=document.createElement("button");return t.innerText="X",t.style.cssText="position: absolute;right: 5%; top: 5%;background-color: #000000;color: #ffffff;padding: 3px 10px;font-weight: bolder;",null==e||e.appendChild(t),this.exitButton=t,this.exitButton.style.display="none",t.addEventListener("touchstart",(()=>{this.exitDrawing(),this.exitButton&&(this.exitButton.style.display="none")})),this.addEventListener("FirstPointPicked",this.firstPickedListener=()=>{this.exitButton&&(this.exitButton.style.display="inline-block")}),this.addEventListener("Completed",this.completedListener=()=>{this.exitButton&&(this.exitButton.style.display="none")}),this.exitButton}activate(){if(Dn.isMobile)this.inputManager.addEventListener("touchstart",this.touchstart),this.inputManager.addEventListener("touchmove",this.touchmove),this.inputManager.addEventListener("touchend",this.touchend);else{this.inputManager.addEventListener("pointerdown",this.mousedown),this.inputManager.addEventListener("pointermove",this.mousemove),this.inputManager.addEventListener("pointerup",this.mouseup);let e=this.viewer.translate;if(e){this.tooltip=new Yl("measure-tooltip",e("Tooltip.measure"),{followPointer:!0,showOnCreate:!0,parentNode:this.viewer.widgetContainer,target:this.viewer.viewerContainer});let t=document.getElementById("measure-tooltip");t&&(t.style.pointerEvents="none")}this.setTooltipContent()}this.inputManager.addEventListener("dblclick",this.dblclick),this.inputManager.addEventListener("keydown",this.keydown),this.raycaster=this.viewer.getRaycaster()}deactivate(){var e,t;Dn.isMobile?(this.inputManager.removeEventListener("touchstart",this.touchstart),this.inputManager.removeEventListener("touchmove",this.touchmove),this.inputManager.removeEventListener("touchend",this.touchend)):(this.inputManager.removeEventListener("pointerdown",this.mousedown),this.inputManager.removeEventListener("pointermove",this.mousemove),this.inputManager.removeEventListener("pointerup",this.mouseup)),this.inputManager.removeEventListener("dblclick",this.dblclick),this.inputManager.removeEventListener("keydown",this.keydown),null==(e=this.tooltip)||e.hide(),null==(t=this.tooltip)||t.destroy(),this.tooltip=void 0,this.raycaster=void 0,this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable),this.osnapHelper.deactivate(),this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0}removeDrawable(e){this.dispatchEvent("WillBeRemoved",e)}clearClickedDrawable(){this.clickedOnMeasurementDrawable&&(this.clickedOnMeasurementDrawable.selected=!1,this.clickedOnMeasurementDrawable=void 0)}onMouseClick(e){if(Dn.isMobile)return;let t=Date.now();this.lastClickTime&&t-this.lastClickTime<500||(this.lastClickTime=t,this.selectMeasurementByEvent(e))}selectMeasurementByEvent(e){if(this.clickedOnMeasurementDrawable&&(this.clickedOnMeasurementDrawable.selected=!1,this.clickedOnMeasurementDrawable=void 0),null==this.completed||!0===this.completed){let t=this.getIntersections(e)[0];if(t){let e=this.drawList.getDrawableByPosition(t.point,this.raycaster);e&&(this.dispatchEvent("ClickedOnMeasurement",e),this.clickedOnMeasurementDrawable=e)}}}onMouseMove(e){this.createOrUpdateMeasureDrawable(e)}createOrUpdateMeasureDrawable(e){if(!this.drawingPoints||this.drawingPoints&&this.drawingPoints.length<1)return;let t=[...this.drawingPoints];if(!this.currentMeasureDrawable)return this.currentMeasureDrawable=this.createMeasureDrawable(),this.currentMeasureDrawable&&(this.currentMeasureDrawable.selected=!0),void this.dispatchEvent("WillBeAdded",this.currentMeasureDrawable);e&&t.push(e),this.currentMeasureDrawable.selected=!0,this.currentMeasureDrawable.update(t),this.currentMeasureDrawable.setDrawingState(!0),this.dispatchEvent("Updated")}},Ta=class extends Bi{constructor(e,t){super(e),this.type="Distance",this.labelBounds=new Ji,this.drawing=!1,this.update(t)}setDrawingState(e){this.drawing=e}drawSelect(e,t){let n=this.getVertexes();this.drawPoints(e,t,n)}drawPoints(e,t,n){e.save(),e.fillStyle=Ta.MAJOR_COLOR,e.strokeStyle=Ta.MINOR_COLOR,e.lineWidth=Ta.LINE_WIDTH,e.beginPath(),(this.drawing?n.slice(0,n.length-1):n).forEach((n=>{let i=this.transToScreenCoord(n,t);e.moveTo(i.x+Ta.POINT_RADIUS,i.y),e.arc(i.x,i.y,Ta.POINT_RADIUS,0,2*Math.PI)})),e.closePath(),e.fill(),e.stroke(),e.restore()}drawText(e,t){if(!this.label||!this.labelPositon)return;e.font=`${Ta.LABEL_FONT_SIZE}px Arial`;let n=1.2*e.measureText(this.label).width,i=1.5*Ta.LABEL_FONT_SIZE;this.labelBounds.setFromCenterAndSize(this.labelPositon,new be(n,i)),this.drawRoundRect(e,this.labelPositon.x-n/2,this.labelPositon.y-i/2,n,i,4),e.save(),e.fillStyle=Ta.MINOR_COLOR,e.textBaseline="middle",e.textAlign="center",e.fillText(this.label,this.labelPositon.x,this.labelPositon.y),e.restore()}drawRoundRect(e,t,n,i,r,a){i<2*a&&(a=i/2),r<2*a&&(a=r/2),e.save(),e.fillStyle=Ta.MAJOR_COLOR,e.strokeStyle=Ta.MINOR_COLOR,e.lineWidth=Ta.LINE_WIDTH,e.beginPath(),e.moveTo(t+a,n),e.arcTo(t+i,n,t+i,n+r,a),e.arcTo(t+i,n+r,t,n+r,a),e.arcTo(t,n+r,t,n,a),e.arcTo(t,n,t+i,n,a),e.closePath(),e.fill(),this.selected&&e.stroke(),e.restore()}getVertexes(){return this.points}update(e){let{min:t,max:n}=(new Ot).setFromPoints(e);return this.x=t.x,this.y=t.y,this.width=Math.abs(n.x-t.x),this.height=Math.abs(n.y-t.y),this.points=e,this}getBounds(){let e=this.getVertexes();return(new Ot).setFromPoints(e)}getData(){return{id:this.id,type:this.type,points:this.points.map((e=>[e.x,e.y,e.z]))}}setData(e){super.setData(e),this.setLineColor(Cn.colorStr2Rgba(Ta.MAJOR_COLOR)),this.setFillColor(Cn.colorStr2Rgba(Ta.AREA_FILL_COLOR)),this.setLineWidth(Ta.LINE_WIDTH)}isPointInPath(e,t){let n=null==t?void 0:t.ray;if(!n)return!1;let i=3*this.tolerance,r=this.transToScreenCoord(e,t.camera);if(this.labelBounds.containsPoint(r))return!0;let a=new O,s=new O,o=this.points;for(let l=0;l{let r=this.transToScreenCoord(n,t);0===i?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),3===this.points.length){let[n,i,r]=this.points.map((e=>this.transToScreenCoord(e,t))),a=(new be).subVectors(n,i).normalize(),s=(new be).subVectors(r,i).normalize(),o=Math.min(n.distanceTo(i),r.distanceTo(i)),l=a.angle(),h=s.angle();e.moveTo(i.x,i.y),e.arc(i.x,i.y,o/5,l,h,a.cross(s)<0)}if(e.stroke(),e.restore(),this.drawing){let n=1===this.points.length?this.points:this.points.slice(0,this.points.length-1);this.drawPoints(e,t,n)}this.drawText(e,t)}drawText(e,t){if(this.points.length<3)return;let[n,i,r]=this.points,a=this.getAngleBisector(n,i,r),s=this.calculateAngle(n,i,r);this.label=`${Bu(s,2)} ${this.getUnitString()}`;let o=.3*Math.min(n.distanceTo(i),r.distanceTo(i));this.labelPositon=this.transToScreenCoord(i.clone().add(new O(a.x*o,a.y*o,a.z*o)),t),super.drawText(e,t)}getAngleBisector(e,t,n){let i=e,r=t,a=n,s=new O(i.x-r.x,i.y-r.y,i.z-r.z).normalize(),o=new O(a.x-r.x,a.y-r.y,a.z-r.z).normalize();return new O(s.x+o.x,s.y+o.y,s.z+o.z).normalize()}calculateAngle(e,t,n){let i=e,r=t,a=n,s=new O(i.x-r.x,i.y-r.y,i.z-r.z),o=new O(a.x-r.x,a.y-r.y,a.z-r.z);return 180*s.angleTo(o)/Math.PI}getClassType(){return"Angle"}};Hn._registerDrawableClass(v_);var RP=class extends nh{constructor(e,t,n,i){super("Angle",e,t,n,i)}createMeasureDrawable(){if(this.drawingPoints)return new v_(Mt.guid(),this.drawingPoints)}onMouseClick(e){var t;if(super.onMouseClick(e),this.clickedOnMeasurementDrawable)return;if(this.drawingPoints||(this.drawingPoints=[]),2===e.button)return void this.exitDrawing();let n=this.getIntersections(e)[0];if(!n)return;let i=null!=(t=this.snapPoint)?t:null==n?void 0:n.point;if(this.drawingPoints[0]&&Zt.areVector3sEqual(this.drawingPoints[0],i))return;let r=this.drawingPoints;r.push(i),this.lastMouseDownPosition=i,1===r.length&&(this.dispatchEvent("FirstPointPicked"),this.completed=!1),this.createOrUpdateMeasureDrawable(),r.length>=3&&this.complete()}exitDrawing(){this.drawingPoints=void 0,this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=void 0,this.lastMouseDownPosition=void 0}complete(){var e;!0!==this.completed&&(null==(e=this.currentMeasureDrawable)||e.setDrawingState(!1),this.dispatchEvent("Completed",this.currentMeasureDrawable),this.completed=!0,this.currentMeasureDrawable=void 0,this.drawingPoints=void 0,this.lastMouseDownPosition=void 0)}cancel(){let e=this.drawingPoints;if(e&&e.length>0&&(e.pop(),0===e.length&&(this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=!0),this.lastMoveEvent)){let e=this.getIntersections(this.lastMoveEvent)[0];e&&this.onMouseMove(e.point)}this.osnapHelper.deactivate(),this.lastMouseDownPosition=void 0}deactivate(){super.deactivate(),this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable)}setTooltipContent(){var e;let t=this.viewer.translate;if(!t)return;let n=t("Tooltip.measure");n&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(n))}},Jf=class extends Dr{constructor(e,t,n){super(e,t),this.type="Area",this.scale=n,this.update(t)}draw(e,t){let n=this.points;if(e.save(),e.lineWidth=Dr.LINE_WIDTH,e.strokeStyle=Dr.MAJOR_COLOR,e.fillStyle=Dr.AREA_FILL_COLOR,e.beginPath(),n.forEach(((n,i)=>{let r=this.transToScreenCoord(n,t);0===i?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.closePath(),e.fill(),e.stroke(),e.restore(),this.drawing){let n=1===this.points.length?this.points:this.points.slice(0,this.points.length-1);this.drawPoints(e,t,n)}this.drawText(e,t)}drawText(e,t){if(this.points.length<3)return;let n=this.points,i=this.calculateArea(n);this.scale&&(i*=Math.pow(this.scale,2)),this.label=`${Bu(i,2)}`,this.labelPositon=this.transToScreenCoord(this.getBarycenter(n),t),super.drawText(e,t)}calculateArea(e){let t=0,n=Fm.getFaces(e);for(let i=0;i{n+=e.x,i+=e.y,r+=e.z})),new O(n/t,i/t,r/t)}isPointInPath(e,t){let n=null==t?void 0:t.ray;if(!n)return!1;let i=this.transToScreenCoord(e,t.camera);if(this.labelBounds.containsPoint(i))return!0;let r=3*this.tolerance,a=new O,s=new O,o=this.points;for(let h=0;h2&&this.drawingPoints[0]){let t=this.drawingPoints[0];ave.subVectors(e,t).length()<3*this.viewer.getPixelSizeInWorldCoord()&&(this.osnapHelper.activateMarker(1,{point:t,type:1,distance:0}),se.info("[AreaMeasurement] auto close area measurement."))}}onMouseClick(e){var t,n;if(super.onMouseClick(e),this.clickedOnMeasurementDrawable)return;this.drawingPoints||(this.drawingPoints=[]);let i=this.drawingPoints;if(2===e.button)return void this.exitDrawing();let r=this.getIntersections(e)[0];if(!r)return void se.warn("[Measure] No intersection found!");let a=null!=(n=null==(t=this.snapPoint)?void 0:t.clone())?n:null==r?void 0:r.point.clone();if(this.drawingPoints&&this.drawingPoints.length>2&&this.drawingPoints[0]){let e=this.drawingPoints[0];if(ave.subVectors(a,e).length()<3*this.viewer.getPixelSizeInWorldCoord())return se.info("[AreaMeasurement] auto close area measurement."),this.touchDowned=!1,void this.exitDrawing()}this.drawingPoints[0]&&Zt.areVector3sEqual(this.drawingPoints[0],a)||(i.push(a),this.lastMouseDownPosition=a,1===i.length&&(this.dispatchEvent("FirstPointPicked"),this.completed=!1),this.createOrUpdateMeasureDrawable())}exitDrawing(){let e=this.drawingPoints||[],t=!0;if(e.length<3&&(se.warn("[Measure] If the number of points is less than 3, the measurement area cannot be formed !"),t=!1),t&&Fm.isSelfIntersecting(e)&&(se.warn("[Measure] The area formed by these points intersects itself, so the correct measurement cannot be obtained !"),t=!1),!t)return this.drawingPoints=void 0,this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=void 0,void(this.lastMouseDownPosition=void 0);this.createOrUpdateMeasureDrawable(),this.complete()}complete(){var e;!0!==this.completed&&(null==(e=this.currentMeasureDrawable)||e.setDrawingState(!1),this.dispatchEvent("Completed",this.currentMeasureDrawable),this.completed=!0,this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0)}cancel(){let e=this.drawingPoints;if(e&&e.length>0&&(e.pop(),0===e.length&&(this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=!0),this.lastMoveEvent)){let e=this.getIntersections(this.lastMoveEvent)[0];e&&this.onMouseMove(e.point)}this.osnapHelper.deactivate(),this.lastMouseDownPosition=void 0}setTooltipContent(){var e;let t=this.viewer.translate;if(t){let n=t("Tooltip.areaMeasurement");n&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(n))}}getScale(){return this.scale}setScale(e){this.scale=e;let t=this.drawList.getDrawables();for(let n of t){let t=n[1];t instanceof Jf&&(t.scale=e)}}},y_=class extends Dr{constructor(e,t){super(e,t),this.type="Coordinate",this.update(t)}draw(e,t){this.drawText(e,t),e.save(),e.lineWidth=Dr.LINE_WIDTH,e.strokeStyle=Dr.MAJOR_COLOR,e.fillStyle=Dr.AREA_FILL_COLOR;let n=this.points;e.beginPath(),n.forEach((n=>{let i=this.transToScreenCoord(n,t);e.arc(i.x,i.y,Dr.POINT_RADIUS,0,2*Math.PI)})),e.fill(),e.stroke(),e.restore()}drawText(e,t){let n=this.points[0];Zt.areNumbersEqual(n.x,0);let i=Zt.areNumbersEqual(n.x,0)?0:n.x,r=Zt.areNumbersEqual(n.y,0)?0:n.y,a=Zt.areNumbersEqual(n.z,0)?0:n.z;this.label=`${Bu(i,2)}, ${Bu(r,2)}, ${Bu(a,2)}`,e.font=`${Dr.LABEL_FONT_SIZE}px Arial`;let s=1.2*e.measureText(this.label).width,o=1.5*Dr.LABEL_FONT_SIZE;this.labelPositon=this.transToScreenCoord(n,t),this.labelPositon.y-=o/2,this.labelBounds.setFromCenterAndSize(this.labelPositon,new be(s,o)),this.drawRoundRect(e,this.labelPositon.x-s/2,this.labelPositon.y-o/2,s,o,4),e.save(),e.fillStyle=Dr.MINOR_COLOR,e.textBaseline="middle",e.textAlign="center",e.fillText(this.label,this.labelPositon.x,this.labelPositon.y),e.restore()}getClassType(){return"Coordinate"}};Hn._registerDrawableClass(y_);var CP=class extends nh{constructor(e,t,n,i){super("Coordinate",e,t,n,i)}createMeasureDrawable(){if(this.drawingPoints)return new y_(Mt.guid(),this.drawingPoints)}onMouseClick(e){var t;if(super.onMouseClick(e),this.clickedOnMeasurementDrawable)return;if(this.drawingPoints||(this.drawingPoints=[]),2===e.button)return void this.exitDrawing();let n=this.getIntersections(e)[0];if(!n)return;let i=null!=(t=this.snapPoint)?t:null==n?void 0:n.point,r=this.drawingPoints;r.push(i),this.lastMouseDownPosition=i,1===r.length&&(this.dispatchEvent("FirstPointPicked"),this.completed=!1),this.createOrUpdateMeasureDrawable(i),r.length>=1&&this.complete()}exitDrawing(){this.drawingPoints=void 0,this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=void 0,this.lastMouseDownPosition=void 0}complete(){!0!==this.completed&&(this.dispatchEvent("Completed",this.currentMeasureDrawable),this.completed=!0,this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0)}cancel(){let e=this.drawingPoints;if(e&&e.length>0&&(e.pop(),0===e.length&&(this.completed=!0),this.lastMoveEvent)){let e=this.getIntersections(this.lastMoveEvent)[0];e&&this.onMouseMove(e.point)}this.osnapHelper.deactivate(),this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0}setTooltipContent(){var e;let t=this.viewer.translate;if(t){let n=t("Tooltip.measure");n&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(n))}}},N4=class extends Dr{constructor(e,t,n){super(e,t),this.type="Distance",this.scale=n,this.update(t)}draw(e,t){let n=this.points;if(e.save(),e.lineWidth=Dr.LINE_WIDTH,e.strokeStyle=Dr.MAJOR_COLOR,e.beginPath(),n.forEach(((n,i)=>{let r=this.transToScreenCoord(n,t);0===i?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.closePath(),e.stroke(),e.restore(),this.drawing){let n=1===this.points.length?this.points:this.points.slice(0,this.points.length-1);this.drawPoints(e,t,n)}else this.selected||this.drawVerticalLine(e,t);this.drawText(e,t)}drawText(e,t){if(this.points.length<2)return;let[n,i]=this.points,r=n.distanceTo(i);this.scale&&(r*=this.scale),this.label=`${Bu(r,2)}`,this.labelPositon=this.transToScreenCoord((new O).lerpVectors(n,i,.5),t),super.drawText(e,t)}drawVerticalLine(e,t){if(this.points.length<2)return;let[n,i]=this.points.map((e=>this.transToScreenCoord(e,t))),[r,a]=this.getShortLineBySegments(n,i),[s,o]=this.getShortLineBySegments(i,n);e.save(),e.lineWidth=Dr.LINE_WIDTH,e.strokeStyle=Dr.MAJOR_COLOR,e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(a.x,a.y),e.moveTo(s.x,s.y),e.lineTo(o.x,o.y),e.stroke(),e.restore()}getShortLineBySegments(e,t){let n=(new be).subVectors(t,e).normalize(),i=N4.SHORT_LINE_LENGTH/2,r=Math.PI/2;return[n.clone().rotateAround(new be,r).normalize().multiplyScalar(i).add(e),n.clone().rotateAround(new be,-r).normalize().multiplyScalar(i).add(e)]}getClassType(){return"Distance"}setScale(e){this.scale=e}},ig=N4;ig.SHORT_LINE_LENGTH=12,Hn._registerDrawableClass(ig);var PP=class extends nh{constructor(e,t,n,i){super("Distance",e,t,n,i)}createMeasureDrawable(){if(this.drawingPoints)return new ig(Mt.guid(),this.drawingPoints,this.scale)}onMouseClick(e){var t;if(super.onMouseClick(e),this.clickedOnMeasurementDrawable)return;if(this.drawingPoints||(this.drawingPoints=[]),2===e.button)return void this.exitDrawing();let n=this.getIntersections(e)[0];if(!n)return;let i=null!=(t=this.snapPoint)?t:null==n?void 0:n.point;if(this.drawingPoints[0]&&Zt.areVector3sEqual(this.drawingPoints[0],i))return;let r=this.drawingPoints;r.length<2&&r.push(i),this.lastMouseDownPosition=i,1===r.length&&(this.dispatchEvent("FirstPointPicked"),this.completed=!1),this.createOrUpdateMeasureDrawable(),r.length>=2&&this.complete()}exitDrawing(){this.drawingPoints=void 0,this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=void 0,this.lastMouseDownPosition=void 0}complete(){var e;!0!==this.completed&&(null==(e=this.currentMeasureDrawable)||e.setDrawingState(!1),this.dispatchEvent("Completed",this.currentMeasureDrawable),this.completed=!0,this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0)}cancel(){let e=this.drawingPoints;e&&e.length>0&&(e.pop(),0===e.length&&(this.completed=!0),this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable)),this.osnapHelper.deactivate(),this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0}deactivate(){super.deactivate(),this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable)}setTooltipContent(){var e;let t=this.viewer.translate;if(t){let n=t("Tooltip.measure");n&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(n))}}getScale(){return this.scale}setScale(e){this.scale=e;let t=this.drawList.getDrawables();for(let n of t){let t=n[1];(t instanceof ig||t instanceof Jf)&&(t.scale=e)}}},ove=class extends dr{constructor(e){var t,n;super(e,{id:"MeasurementPlugin"}),this.selectedDrawable=void 0,this.drawableList=new Ko("measure"),this.drawableHelperList=new Ko("touchHelper"),this.snapToleranceInPixel=3,this.measurements={},this.activeMeasurementType=void 0,this.keydown=e=>{var t;let n,i=this.getActiveMeasurementType();i&&(n=this.measurements[i]);let r=this.selectedDrawable;r&&"Delete"===e.code&&(this.remove(r),null==(t=this.viewer.undoRedoManager)||t.addCommand(new ry(this,r.getData())),this.activeMeasurementType&&this.measurements[this.activeMeasurementType].clearClickedDrawable()),e.ctrlKey&&"KeyZ"===e.code&&null!=n&&n.isMeasuring&&n.cancel(),e.ctrlKey&&"KeyY"===e.code&&null!=n&&n.isMeasuring};let i=e.getInputManager();if(!i)throw"InputManager init error";this.inputManager=i,this.overlayRender=this.viewer.overlayRender,null==(t=this.overlayRender)||t.addDrawableList(this.drawableHelperList),null==(n=this.overlayRender)||n.addDrawableList(this.drawableList);let r=new TP(this.overlayRender);e.is3d()&&(r.setOSnapTypeEnabled(32,!1),r.setOSnapTypeEnabled(64,!1)),this.measurements.Distance=new PP(e,i,this.drawableList,r),this.measurements.Area=new AP(e,i,this.drawableList,r),this.measurements.Angle=new RP(e,i,this.drawableList,r),this.measurements.Coordinate=new CP(e,i,this.drawableList,r),this.osnapHelper=r,this.inputManager.addEventListener("wheel",(()=>{this.updateSnapTolerance()})),this.viewer.addEventListener("LayoutChanged",(()=>{this.updateSnapTolerance()})),this.initEvents()}initEvents(){Object.values(this.measurements).forEach((e=>{e.addEventListener("Completed",(e=>{var t;this.viewer.dispatchEvent("MeasurementAdded",e.getData()),null==(t=this.viewer.undoRedoManager)||t.addCommand(new hE(this,e.getData())),this.select(e)})),e.addEventListener("WillBeAdded",(e=>{this.add(e,!1)})),e.addEventListener("Updated",(()=>{this.render()})),e.addEventListener("WillBeRemoved",(e=>{this.remove(e,!1)})),e.addEventListener("Deactivate",(()=>{this.osnapHelper.deactivate(),this.viewer.deactivateMeasurement()})),e.addEventListener("FirstPointPicked",(()=>{this.unselect()})),e.addEventListener("ClickedOnMeasurement",(e=>{this.select(e)}))}))}get canvas(){var e;return null==(e=this.viewer.renderer)?void 0:e.domElement}get raycaster(){return this.viewer.getRaycaster()}add(e,t=!0){this.drawableList.addDrawable(e),this.selectedDrawable=e,this.render(),t&&this.viewer.dispatchEvent("MeasurementAdded",e.getData())}create(e){return Hn.createDrawable(e)}remove(e,t=!0){this.drawableList.removeDrawable(e),this.render(),t&&this.viewer.dispatchEvent("MeasurementRemoved",e.getData())}setSnapTolerance(e){this.snapToleranceInPixel=e,this.updateSnapTolerance()}updateSnapTolerance(){let e=this.viewer.getPixelSizeInWorldCoord()*this.snapToleranceInPixel;this.osnapHelper.setSnapTolerance(e)}activate(e){this.activeMeasurementType&&this.deactivate(),this.measurements[e]?(this.measurements[e].activate(),this.activeMeasurementType=e,this.updateSnapTolerance()):(this.activeMeasurementType=void 0,se.error("[Measure] Failed to activate measurement, type:",e));let{width:t,height:n}=this.canvas.getBoundingClientRect();Dn.isMobile&&this.canvas&&!this.mobileTouchHelper&&(this.mobileTouchHelper=new MP(new be(t/2,n/2)),this.drawableHelperList.addDrawable(this.mobileTouchHelper)),this.mobileTouchHelper&&(this.mobileTouchHelper.setPosition(new be(t/2,n/2)),this.measurements[e].setTouchHelper(this.mobileTouchHelper),this.mobileTouchHelper.visible=!0,this.render()),this.inputManager.addEventListener("keydown",this.keydown)}deactivate(){this.unselect();let e=this.activeMeasurementType;e&&this.measurements[e].deactivate(),this.activeMeasurementType=void 0,this.mobileTouchHelper&&(this.mobileTouchHelper.visible=!1,this.render()),this.inputManager.removeEventListener("keydown",this.keydown)}getActiveMeasurementType(){return this.activeMeasurementType}isActive(){let e=this.activeMeasurementType;return e?this.measurements[e].isActive:!!this.getActiveMeasurementType()}isMeasuring(){let e=this.activeMeasurementType;return!!e&&this.measurements[e].isMeasuring}getData(){return this.drawableList.getDrawableDatas()}cancel(){let e=this.activeMeasurementType;e&&this.measurements[e].exitDrawing()}setData(e){var t,n;null==(t=this.viewer.undoRedoManager)||t.startTransaction(),e.forEach((e=>{var t;this.measurements[e.type]?e.points.length>=2?(this.add(Hn.createDrawable(e)),null==(t=this.viewer.undoRedoManager)||t.addCommand(new hE(this,e))):se.info("[Measure] Invalid points found in MeasurementData:",e):se.warn("[Measure] Failed to add measurement data for",e)})),null==(n=this.viewer.undoRedoManager)||n.endTransaction()}setVisibilityById(e,t){let n=this.drawableList.getDrawables().get(e);return!!n&&(n.visible!==t&&(n.visible=t,this.render()),!0)}setVisibilities(e){let t=!1;this.drawableList.getDrawables().forEach((n=>{n.visible!==e&&(n.visible=e,t=!0)})),t&&this.render()}clear(){let e=this.activeMeasurementType;e&&this.measurements[e].exitDrawing(),this.drawableList.clear(),this.render()}getById(e){return this.drawableList.getDrawableById(e)}removeById(e){let t=this.drawableList.getDrawableById(e);t?this.remove(t):se.warn("[Measure] Failed to find measurement by id:",e)}selectById(e){let t=this.drawableList.getDrawableById(e);t&&this.select(t)}select(e){this.unselect(!1),e.selected=!0,this.selectedDrawable=e,this.render()}unselect(e=!0){this.selectedDrawable&&(this.selectedDrawable.selected=!1,e&&this.render()),this.selectedDrawable=void 0}getScale(){return this.measurements.Distance.getScale()}setScale(e){if(!e||e<=0)return void se.error("[Measure] Invalid scale value:",e);let t=this.measurements.Distance,n=this.measurements.Area;t.setScale(e),n.setScale(e)}destroy(){super.destroy(),this.deactivate(),this.clear(),this.drawableHelperList.clear(),this.measurements={},this.osnapHelper.destroy(),this.render()}render(e=!1){var t;e?this.viewer.enableRender():null==(t=this.overlayRender)||t.render()}},Oy=new Qe,lve=new Qe,cve=new ya,B4=new O,ky=new Ot,uve=new ct,Qf=class extends Zf{constructor(e){super(e),this.name="DxfViewer",this.CAMERA_Z_POSITION=100,this.CAMERA_MIN_ZOOM=1e-6,this.timer=Date.now(),this.loadedModels=[],this.masterModelId="",this.raycaster=new ia,this.selected=!0,this.raf=new qf,this.clock=new po,this.renderEnabled=!1,this.enableHideVisuallySmallObjects=!0,this.sortedHidableObjects={},this.lastCameraZoom=1/0,this.lastFrame=-1,this.activeLayoutName="",this.layoutInfos={},this.units=void 0,this.fpsUtils=new IA,this.onResize=()=>{this.viewerContainer&&this.viewerContainer&&this.resize(this.viewerContainer.clientWidth,this.viewerContainer.clientHeight)},this.enableRender=(e=1e3)=>{this.renderEnabled=!0,this.raf&&(this.timeoutSymbol&&this.raf.clearTimeout(this.timeoutSymbol),this.timeoutSymbol=this.raf.setTimeout((()=>{this.renderEnabled=!1}),e))},this.loadingDxfCount=0,this.compareMode=!1,this.viewerCfg=e,this.increaseJobCount(),this.init(),this.animate(),this.enableRender(),this.decreaseJobCount(),se.info(`[Viewer] Initialized in ${(Date.now()-this.timer)/1e3}s`)}init(){let e=this.viewerCfg;this.initThree(),Dn.isBrowser&&!e.context&&this.initDom(),this.initInputManager(),this.initEvents(),this.initControls(),this.initOthers(),this.enableSelection=e.enableSelection}initInputManager(){this.viewerContainer&&(this.inputManager=new Jo(this.viewerContainer))}initThree(){this.initScene(),this.initRenderer(),this.initCamera()}initDom(){let e=this.viewerCfg;this.initSpinner(),this.initCSS2DRenderer(),!0===e.enableAxisGizmo&&console.warn("[Viewer] enableAxisGizmo is deprecated, use AxisGizmoPlugin instead!"),!0===e.enableStats&&console.warn("[Viewer] enableStats is deprecated, use StatsPlugin instead!"),e.enableToolbar&&console.warn("[Viewer] enableToolbar is deprecated, use ToolbarPlugin instead!"),e.enableBottomBar&&console.warn("[Viewer] enableBottomBar is deprecated, use BottomBarPlugin instead!"),e.enableProgressBar&&(this.loadingProgressBar=this.initLoadingProgressBar()),e.enableLayoutBar&&(this.dxfLayoutBar=new eP(this))}initScene(){let e=new _i;e.background=new ct(2172976),e.matrixAutoUpdate=!1,e.matrixWorldAutoUpdate=!1,this.scene=e}initRenderer(){var e;let{context:t}=this.viewerCfg,n={context:t,antialias:!0,preserveDrawingBuffer:!0,alpha:!1,stencil:!1};!Dn.isBrowser&&t&&Object.assign(n,{context:t,canvas:Dn.creatReactNativeCanvas(t)}),t&&(this.width=t.drawingBufferWidth,this.height=t.drawingBufferHeight),this.renderer=new Ms(n),this.renderer.setClearColor(11119017,1),this.renderer.localClippingEnabled=!0,Dn.isBrowser&&(!t&&this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.classList.add("webgl-renderer"),null==(e=this.viewerContainer)||e.appendChild(this.renderer.domElement)),this.renderer.setSize(this.width,this.height),Mt.printGpuInfo(this.renderer.getContext()),vn.maxFragmentUniforms=this.renderer.capabilities.maxFragmentUniforms-20,this.enableOverlayRenderer&&(this.overlayRender=new Hn(this))}initCSS2DRenderer(){var e;let t=new Nu;t.setSize(this.width,this.height),t.domElement.style.height="0",t.domElement.style.width="0",t.domElement.style.position="absolute",t.domElement.style.top="0",t.domElement.style.left="0",t.domElement.style.overflow="visible",t.domElement.classList.add("css2d-renderer"),null==(e=this.viewerContainer)||e.appendChild(t.domElement),this.css2dRenderer=t}initCamera(){if(!this.scene)return;let e=new Ur(-this.width/2,this.width/2,this.height/2,-this.height/2,.1,1e5);e.position.set(0,0,this.CAMERA_Z_POSITION),e.zoom=10,e.updateProjectionMatrix(),this.scene.add(e),this.camera=e,this.frustumSize=this.width}initControls(){let e=this.camera;if(!this.inputManager||!e)return;let t=new ba(e,this.inputManager);t.enableRotate=!1,t.enabled=!0,t.keyTruckSpeed=10,t.dollyToCursor=!0,t.dollySpeed=.5,t.truckSpeed=1,t.mouseButtons={left:yt.TRUCK,middle:yt.TRUCK,wheel:yt.ZOOM,right:yt.TRUCK},t.touches={one:yt.TOUCH_TRUCK,two:yt.TOUCH_ZOOM_TRUCK,three:yt.NONE},t.listenToKeyEvents(),t.update(0),this.controls=t,t.addEventListener("control",this.onControlsChange(this))}onControlsChange(e){return()=>{this.updateHidableObjectsVisibility(),e.enableRender()}}initEvents(){if(!this.inputManager||!this.renderer)return;let e=!1,t=!1;this.inputManager.addEventListener("pointerdown",(n=>{var i;t=!1,e=!0,1===n.button&&(null==(i=this.inputManager)||i.setCursor("move"))})),this.inputManager.addEventListener("pointermove",(()=>{var n;e&&(t=!0,null==(n=this.inputManager)||n.setCursor("move"))})),this.inputManager.addEventListener("pointerup",(n=>{var i;if(e=!1,null==(i=this.inputManager)||i.setCursor("default"),t)return void(t=!1);this.handleMouseClick(n);let r={evt:n};if(this.selectedObject&&this.selectedObject instanceof wi&&(r.markupData=this.selectedObject.getData()),this.selectedObject&&this.selectedObject instanceof Dr&&(r.measureData=this.selectedObject.getData()),this.selectedObject&&this.selectedObject instanceof on){let e=t=>t.parent&&!t.parent.isScene?e(t.parent):t.name;r.entityData={modelId:e(this.selectedObject),layerName:this.selectedObject.userData.layerName}}this.dispatchEvent("MouseClicked",r)})),this.inputManager.addEventListener("keydown",(e=>{var t,n,i,r,a;if(e.altKey&&"KeyR"===e.code)this.flyToRandomObject();else if(e.ctrlKey&&"KeyZ"===e.code){if(this.measurePlugin&&this.measurePlugin.isMeasuring())return;null==(t=this.undoRedoManager)||t.undo()}else if(e.ctrlKey&&"KeyY"===e.code){if(this.measurePlugin&&this.measurePlugin.isMeasuring())return;null==(n=this.undoRedoManager)||n.redo()}else"Delete"===e.code&&this.selectedObject&&(this.markupManager&&this.selectedObject instanceof wi&&(this.markupManager.removeMarkup(this.selectedObject),null==(i=this.undoRedoManager)||i.addCommand(new zm(this.markupManager,this.selectedObject.getData()))),this.measurePlugin&&this.selectedObject instanceof Dr&&(null==(r=this.measurePlugin)||r.remove(this.selectedObject),null==(a=this.undoRedoManager)||a.addCommand(new ry(this.measurePlugin,this.selectedObject.getData()))))}))}initOthers(){!this.scene||!this.renderer||!this.camera||(this.renderer.domElement.style.outlineWidth="0")}initLoadingProgressBar(){return new Gf(this.widgetContainer)}showLayoutBar(){var e;null==(e=this.dxfLayoutBar)||e.show()}hideLayoutBar(){var e;null==(e=this.dxfLayoutBar)||e.hide()}animate(){var e,t,n;if(this.minFrameInterval>0&&Date.now()-this.lastFrameExecuteTime{var n;null==(n=this.loadingProgressBar)||n.updateProgress(o,l,e),t&&t(new ProgressEvent("LoadProgress",{loaded:e,total:100}))},c=(e,n,i)=>{var r;let a=100*e.loaded/e.total;a=a*(i-n)/100+n,null==(r=this.loadingProgressBar)||r.updateProgress(o,l,a),t&&t(new ProgressEvent("LoadProgress",{loaded:a,total:100}))};null==(n=this.loadingProgressBar)||n.addProgressItem(o),h(0);let u={ignorePaperSpace:a,enableLocalCache:this.viewerCfg.enableLocalCache,enableMerge:e.merge,encoding:e.encoding,overrideColor:e.overrideColor},d=yield s.loadDxfData(e.src,e.modelId,(e=>c(e,0,90)),void 0,u).finally((()=>{this.loadingDxfCount--,0===this.loadingDxfCount&&this.fontManager&&this.fontManager.releaseFontData()}));if(se.info(`[Viewer] Loaded '${e.src}' in ${(Date.now()-this.timer)/1e3}s, adding to scene...`),vn.abortJobs&&Promise.reject("[Viewer] abort load dxf"),0===d.threejsObject.children.length){let t=`[Viewer] Nothing was loaded from ${e.src}`;return se.warn(t),this.decreaseJobCount(),Promise.reject(t)}let p=d.threejsObject;p.name=r;let f=this.getDxfUnits(d);if(this.masterModelId===e.modelId&&(this.units=f),se.info(`[Viewer] Units of '${e.src}' is '${f}'`),e.matrix&&16===e.matrix.length){let t=new Qe;t.elements=e.matrix,p.applyMatrix4(t)}return this.addModel({modelId:r,dxfData:d}),Mt.printMemory("After addModel()"),se.info(`[Viewer] Added '${e.src}' to scene in ${(Date.now()-this.timer)/1e3}s`),this.decreaseJobCount(),h(100),null==(i=this.loadingProgressBar)||i.delayRemoveProgressItem(o),this.dispatchEvent("ModelLoaded"),Promise.resolve()}))}unloadDxf(){throw new Error("Not implemented yet!")}addModel(e){if(!this.scene||!this.camera)return;let{dxfData:t,pdfData:n}=e,i=this.getUniqueModelId(e.modelId);if(this.masterModelId||(this.masterModelId=i),t){let e=t.threejsObject;e.name=i;let n={modelId:i,dxfData:t};this.loadedModels.push(n),e.matrixAutoUpdate=!1,e.updateMatrix(),e.updateMatrixWorld(!0),vn.computeLineDistances(e),this.getMsTransformMatrix(i),this.masterModelId===i?this.activateLayout(vn.MODEL_LAYOUT_NAME):this.handleOverlayDxf(i),se.debug("[Viewer] dxfData:",t),this.scene.add(e);let r=null==t?void 0:t.threejsObject.children.find((e=>e.name===vn.MODEL_LAYOUT_NAME));r&&this.setLayoutHidableObjectArray(r),this.updateGroundPlane(),this.raycastableObjects=void 0,this.masterModelId===i||this.enableRender()}else if(n){let t=n.threejsObject;this.activeLayoutName=vn.MODEL_LAYOUT_NAME;let i=(new Ot).setFromObject(t);this.layoutInfos[this.activeLayoutName]={homeViewExtent:i,extent:i},this.loadedModels.push(e),t.matrixAutoUpdate=!1,this.scene.add(t);let r=i.max.z;r>this.camera.position.z&&(this.camera.position.z=r,this.camera.updateProjectionMatrix()),this.updateGroundPlane(),this.flyToObject(t)}}isCompareMode(){return this.compareMode}compare(e,t,n,i){return ft(this,null,(function*(){var r,a,s,o;let{src:l,modelId:h}=e,{src:c}=t;if(this.compareMode)return Promise.reject("[Viewer] It is already under comparing mode!");if(this.masterModelId||this.loadedModels.length>0)return Promise.reject("[Viewer] Shouldn't load anything else before compare!");if(this.compareMode=!0,this.timer=Date.now(),this.increaseJobCount(),!this.fontManager)return Promise.reject("[Viewer] Should set font first!");let u={ignorePaperSpace:!0,encoding:e.encoding},d=new vn(this.loadingManager,u);d.setFont(this.fontManager);let p=l+c,f=this.translate("ProgressBar.Comparing"),m=e=>{var t;null==(t=this.loadingProgressBar)||t.updateProgress(p,f,e),i&&i(new ProgressEvent("CompareProgress",{loaded:e,total:100}))},g=(e,t,n)=>{var r;let a=100*e.loaded/e.total;a=a*(n-t)/100+t,null==(r=this.loadingProgressBar)||r.updateProgress(p,f,a),i&&i(new ProgressEvent("CompareProgress",{loaded:a,total:100}))};Mt.printMemory("Before comparing"),this.masterModelId=h||l,this.loadingDxfCount+=2,null==(r=this.loadingProgressBar)||r.addProgressItem(p),m(0);let v=Date.now(),y=yield d.parse(l,(e=>g(e,0,15))),x=yield d.parse(c,(e=>g(e,15,30))),[b,_]=yield Promise.allSettled([y,x]);if("rejected"===b.status)return Promise.reject(`[Viewer] Failed to parse ${l}`);if("rejected"===_.status)return Promise.reject(`[Viewer] Failed to parse ${c}`);if(se.info(`[Viewer] loadFiles in ${(Date.now()-v)/1e3}s`),vn.abortJobs)return Promise.reject("[Viewer] compare loadFile aborted");let w=b.value,S=_.value;v=Date.now();let M=yield new us(w,S,n).compare((e=>g(e,30,60)));if(se.info(`[Viewer] Compared in ${(Date.now()-v)/1e3}s`),se.debug("[Viewer] Compared results:",M),vn.abortJobs)return Promise.reject("[Viewer] compare change aborted");Mt.printMemory("After getting the comparison results"),v=Date.now(),yield d.loadEntitiesForCompare(w,S,M,!0,(e=>g(e,60,95))),Mt.printMemory("After Creating threejs objects based on comparison result"),this.fontManager.releaseFontData(),this.changes=M,se.info(`[Viewer] Creates threejs objects based on comparison result in ${(Date.now()-v)/1e3}s`);let E=w,T=S;if(this.loadingDxfCount-=2,this.decreaseJobCount(),Object.keys(M).length||se.info("[Viewer] No change found"),0===(null==(a=E.threejsObject)?void 0:a.children.length)&&0===(null==(s=T.threejsObject)?void 0:s.children.length)){let e=`[Viewer] Nothing was loaded from ${l} and ${c}`;return se.warn(e),Promise.reject(e)}let A=E.threejsObject,C=T.threejsObject;return A.name=l,C.name=c,v=Date.now(),this.addModel({modelId:e.modelId||e.src,dxfData:E}),Mt.printMemory("After adding first loaded Model to scene"),m(95),this.addModel({modelId:t.modelId||t.src,dxfData:T}),Mt.printMemory("After adding second loaded Model to scene"),se.info(`[Viewer] Added compared objects to scene in ${(Date.now()-v)/1e3}s`),se.info(`[Viewer] The comparison between ${l}' and '${c}' is completed in ${(Date.now()-this.timer)/1e3}s !`),m(100),null==(o=this.loadingProgressBar)||o.delayRemoveProgressItem(p),Promise.resolve()}))}getEntitiesCount(){let e=0;return this.loadedModels.forEach((t=>{var n,i;e+=(null==(n=t.dxfData)?void 0:n.loadedEntityCount)||(null==(i=t.pdfData)?void 0:i.loadedEntityCount)||0})),e}getLoadedDxfModelIds(){return this.loadedModels.map((e=>e.modelId))}getLayoutNames(){let e=[];return this.getLayouts().forEach((t=>{e.push(t.layoutName)})),e}getLayouts(){let e=[],t=this.loadedModels.find((e=>this.masterModelId===e.modelId));if(t){let n=t.dxfData,i=null==n?void 0:n.objects.LAYOUT;null==i||i.forEach((t=>{e.push(t)}))}return e}handleOverlayDxf(e){var t;let n=this.loadedModels.find((t=>e===t.modelId));if(!n)return void se.warn(`[Viewer] Can't find model for modelId '${e}'!`);this.increaseJobCount(),this.switchTransformMs(vn.MODEL_LAYOUT_NAME,e);let i=null==(t=n.dxfData)?void 0:t.threejsObject,r=null==i?void 0:i.children.find((e=>e.name===vn.MODEL_LAYOUT_NAME));r&&r.traverse((e=>{this.addSpatialFilterSection(e,n.dxfData)})),this.showLayoutObjects(this.activeLayoutName),this.decreaseJobCount()}activateLayout(e){var t,n,i,r;if(this.increaseJobCount(),0==e.length)return se.warn("[Viewer] layout name is empty !"),void this.decreaseJobCount();if(e===this.activeLayoutName)return void this.decreaseJobCount();let a=Date.now(),s=this.camera,o=this.getLayoutByName(e);if(!o)return se.warn(`[Viewer] Can't find layout of ${e} !`),void this.decreaseJobCount();let l=this.loadedModels.find((e=>this.masterModelId===e.modelId));if(!l)return se.warn(`[Viewer] Can't find master model for modelId '${this.masterModelId}'!`),void this.decreaseJobCount();if(this.raycastableObjects=void 0,this.activeLayoutName){let e=this.getActiveLayoutInfo();e.lastCameraPosition||(e.lastCameraPosition=new O),null==(t=this.camera)||t.getWorldPosition(e.lastCameraPosition),this.controls.update(0),e.lastCameraZoom=s.zoom}if(!(e=>{let t=this.layoutInfos[e];return!(null==t||!t.lastCameraZoom)})(e)){this.switchTransformMs(e,this.masterModelId);let t=this.getLayoutViewports(o),r=[];t.length>0&&(r=t[0].frozenLayerHandles);let a=e!==vn.MODEL_LAYOUT_NAME,s=null==(n=l.dxfData)?void 0:n.threejsObject,h=null==s?void 0:s.children.find((t=>t.name===e));if(h){let t=[],n=null==(i=l.dxfData)?void 0:i.layersAndThreejsObjects;h.traverse((i=>{this.addSpatialFilterSection(i,l.dxfData);let s=i;if(a&&s.material&&s.geometry){let i=s.userData.layerName;if(!this.isLayerFrozenForViewport(l.dxfData,i,r))return;t.push(s);let a=-1;n&&n[i]&&(a=n[i].indexOf(s),a>=0&&n[i].splice(a,1)),a<0&&se.warn(`[Viewer] Failed to find object for modelId '${this.masterModelId}', layer '${i}', layout '${e}'`)}})),t.forEach((e=>{e.removeFromParent()}))}let c=this.getFilteredViewports(o);se.debug("[Viewer] Active layout:",e,", viewports:",c);let u=Date.now(),d=this.CAMERA_Z_POSITION/10,p=0;c.forEach((t=>{var n;this.generateObjectsByViewport(e,t,l.dxfData);let i=null==(n=null==t?void 0:t.msToPsMatrix)?void 0:n.elements[14];i&&i>p&&(p=i)}));let f=this.controls,m=f.getPosition(new O);if(p>m.z+d){let e=Math.ceil(p+d);se.info(`[Viewer] Changing camera's z value from ${m.z} to ${e}`);let t=f.getTarget(new O);m.setZ(e),f.setLookAt(m.x,m.y,m.z,t.x,t.y,t.z)}se.info(`[Viewer] generateObjectsByViewport in ${(Date.now()-u)/1e3}s`),e!==vn.MODEL_LAYOUT_NAME&&this.switchTransformMs(vn.MODEL_LAYOUT_NAME,this.masterModelId),e!==vn.MODEL_LAYOUT_NAME&&h&&this.setLayoutHidableObjectArray(h)}this.measurePlugin&&this.clearMeasurements(),this.markupManager&&this.clearMarkups(),null==(r=this.undoRedoManager)||r.clear(),this.showLayoutObjects(e),this.activeLayoutName=e;let h=this.getActiveLayoutInfo();if(h.lastCameraPosition)this.goTo(h.lastCameraPosition,h.lastCameraZoom,!1);else{h.extent=this.computeBoundingBox();let e=this.getLayoutExtentEx(o);if(e){let t=e.max.x-e.min.x,n=e.max.y-e.min.y;(t<1e-16||n<1e-16||t>1e16||n>1e16)&&(se.warn(`[Viewer] Got wired bbox, max: ${e.max.toArray()}, min: ${e.min.toArray()}, going to use the calculated one...`),e=h.extent)}else se.warn("[Viewer] Failed to get layout extent, going to use the calculated one..."),e=h.extent;h.homeViewExtent=e,this.zoomToBBox(e)}this.updateGroundPlane(),this.dispatchEvent("LayoutChanged"),Mt.printMemory(`After activated layout '${this.activeLayoutName}'`),this.enableRender(),this.decreaseJobCount(),se.info(`[Viewer] Activated layout '${e}' in ${(Date.now()-a)/1e3}s`)}cancelAllOperations(){var e,t,n,i,r,a;null!=(e=this.measurePlugin)&&e.isActive()&&(null==(t=this.measurePlugin)||t.deactivate()),null!=(n=this.markupManager)&&n.isMarkupActive()&&(null==(i=this.markupManager)||i.deactivate()),null!=(r=this.zoomToRectHelper)&&r.isActive()&&(null==(a=this.zoomToRectHelper)||a.deactivate())}getActiveLayoutName(){return this.activeLayoutName}getLayers(){var e,t,n,i,r,a;let s=[];if(this.masterModelId){let i=this.loadedModels.find((e=>this.masterModelId===e.modelId)),r=(null==(t=null==(e=null==i?void 0:i.dxfData)?void 0:e.tables)?void 0:t.layer.layers)||(null==(n=null==i?void 0:i.pdfData)?void 0:n.layers);r&&s.push({modelId:this.masterModelId,layers:r})}for(let o of this.loadedModels){let e=o.modelId;if(e===this.masterModelId)continue;let t=(null==(r=null==(i=null==o?void 0:o.dxfData)?void 0:i.tables)?void 0:r.layer.layers)||(null==(a=o.pdfData)?void 0:a.layers);t&&s.push({modelId:e,layers:t})}return s}setModelVisibility(e,t){let n=this.loadedModels.find((t=>e===t.modelId)),i=(null==n?void 0:n.dxfData)||(null==n?void 0:n.pdfData);if(!n||!i)throw new Error(`Failed to find model by modelId '${e}'!`);i.threejsObject.visible=t,this.enableRender()}setLayerVisibility(e,t,n){var i;let r=this.camera;n=n||this.masterModelId;let a=this.loadedModels.find((e=>n===e.modelId));if(!a)throw new Error(`Failed to find layer by modelId '${n}'!`);let s=a.dxfData||a.pdfData,o=(null==(i=s.tables)?void 0:i.layer.layers[e])||s.layers[e];o?o.visible=t:se.warn(`[Viewer] Layer '${e}' not found from modelData!`);let l=(null==s?void 0:s.layersAndThreejsObjects)&&(null==s?void 0:s.layersAndThreejsObjects[e]);if(l){let e=r.zoom;for(let n=0;nn===e.modelId));if(!r)throw new Error(`Failed to find layer by modelId '${n}'!`);let a=r.dxfData||r.pdfData;if(!(null==(i=a.tables)?void 0:i.layer.layers[e])&&!a.layers[e])throw new Error(`Failed to find layer by layerName '${e}'!`);this.clearSelection();let s=(null==a?void 0:a.layersAndThreejsObjects)&&(null==a?void 0:a.layersAndThreejsObjects[e]);s?s.forEach((e=>{let n=e;if(n.material){n.userData.originalMaterial||(n.userData.originalMaterial=es.cloneMaterial(n.material));let e=es.cloneMaterial(n.material);es.setMaterialColor(e,new ct(t)),vn.updateMaterialUniforms(e),n.material=e}})):se.info(`[Viewer] No object found for layer '${e}'`),this.enableRender()}resetLayerColor(e,t){var n;t=t||this.masterModelId;let i=this.loadedModels.find((e=>t===e.modelId));if(!i)throw new Error(`Failed to find model by modelId '${t}'!`);let r=i.dxfData||i.pdfData;if(!(null==(n=r.tables)?void 0:n.layer.layers[e])&&!r.layers[e])throw new Error(`Failed to find layer by layerName '${e}'!`);this.clearSelection();let a=(null==r?void 0:r.layersAndThreejsObjects)&&(null==r?void 0:r.layersAndThreejsObjects[e]);a?a.forEach((e=>{let t=e;t.material&&t.userData.originalMaterial&&(t.material.dispose(),t.material=t.userData.originalMaterial,delete t.userData.originalMaterial)})):se.info(`[Viewer] No object found for layer '${e}'`),this.enableRender()}setFont(e){return ft(this,null,(function*(){let t=Date.now();this.fontManager||(this.fontManager=new cd),yield this.fontManager.loadFonts(e),se.info(`[Viewer] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}getFont(){return this.fontManager}setLoadingManager(e){this.loadingManager=e}setDisplayLengthUnits(){throw new Error("Not implemented yet!")}setDisplayAreaUnits(){throw new Error("Not implemented yet!")}setDisplayPrecision(){throw new Error("Not implemented yet!")}getCurrentViewExtent(){return{min:this.getHitResultByNdcCoordinate({x:-1,y:-1}),max:this.getHitResultByNdcCoordinate({x:1,y:1})}}getScreenshot(){return ft(this,arguments,(function*(e="BoxSelection"){this.cancelAllOperations();let t=this.findPlugin("ScreenshotPlugin");if(t)return t.getScreenshotAsync(e);se.warn("[DxfViwer] ScreenshotPlugin doesn't seem to be installed!")}))}get measurePlugin(){return this.plugins.find((e=>"MeasurementPlugin"===e.id))}activateMeasurement(e){this.cancelAllOperations();let t=this.measurePlugin;t?(t.activate(e),this.clearSelection(),this.dispatchEvent("MeasurementActivated")):se.warn("[Viewer] MeasurementPlugin doesn't seem to be installed!")}deactivateMeasurement(){var e;null==(e=this.measurePlugin)||e.deactivate(),this.dispatchEvent("MeasurementDeactivated")}getActiveMeasurementType(){var e;return null==(e=this.measurePlugin)?void 0:e.getActiveMeasurementType()}getMeasurements(){var e;return(null==(e=this.measurePlugin)?void 0:e.getData())||[]}cancelMeasurement(){var e;null==(e=this.measurePlugin)||e.cancel()}setMeasurements(e){let t=this.measurePlugin;t&&(this.clearMeasurements(),t.setData(e))}selectMeasurement(e){var t;null==(t=this.measurePlugin)||t.selectById(e)}unselectMeasurement(){var e;null==(e=this.measurePlugin)||e.unselect()}removeMeasurement(e){var t;null==(t=this.measurePlugin)||t.removeById(e)}setMeasurementVisibility(e,t){let n=this.measurePlugin;return!!n&&n.setVisibilityById(e,t)}clearMeasurements(){var e;null==(e=this.measurePlugin)||e.clear()}getMarkupManager(){return this.markupManager}activateMarkup(e){this.cancelAllOperations(),this.inputManager&&(this.markupManager||(this.markupManager=new dE(this,this.inputManager)),this.markupManager.isMarkupActive()||this.markupManager.activate(),this.markupManager.setDrawType(e),this.clearSelection(),this.dispatchEvent("MarkupActivated"))}deactivateMarkup(){this.markupManager&&this.markupManager.deactivate(),this.dispatchEvent("MarkupDeactivated")}getActiveMarkupType(){var e;return null==(e=this.markupManager)?void 0:e.getActiveMarkupType()}setMarkupLineColor(e,t,n,i){var r;null==(r=this.markupManager)||r.setLineColor([e,t,n,i])}getMarkupLineColor(){var e;return null==(e=this.markupManager)?void 0:e.getLineColor()}setMarkupFillColor(e,t,n,i){var r;null==(r=this.markupManager)||r.setFillColor([e,t,n,i])}getMarkupFillColor(){var e;return null==(e=this.markupManager)?void 0:e.getFillColor()}setMarkupLineWidth(e){var t;null==(t=this.markupManager)||t.setLineWidth(e)}getMarkupLineWidth(){var e;return null==(e=this.markupManager)?void 0:e.getLineWidth()}setMarkupFontSize(e){var t;null==(t=this.markupManager)||t.setFontSize(e)}getMarkupFontSize(){var e;return null==(e=this.markupManager)?void 0:e.getFontSize()}getMarkups(){var e;return(null==(e=this.markupManager)?void 0:e.getMarkupData())||[]}setMarkups(e){this.inputManager&&(this.clearMarkups(),this.markupManager||(this.markupManager=new dE(this,this.inputManager)),this.markupManager.setMarkupData(e))}setMarkupVisibility(e,t){return!!(this.inputManager&&this.markupManager&&e)&&this.markupManager.setMarkupVisibility(e,t)}updateMarkup(e){if(!(this.inputManager&&this.markupManager&&e&&e.id))return!1;let t=!1,n=this.markupManager,i=n.getMarkupById(e.id);return i&&(n.updateMarkup(i,e),t=!0),t}removeMarkup(e){return!(!this.inputManager||!this.markupManager)&&this.markupManager.removeMarkupById(e)}clearMarkups(){var e;null==(e=this.markupManager)||e.clearAll()}getHitResult(e){let t=this.viewerContainer;if(!this.camera||!this.raycaster||!this.groundPlane)return;let n=un.getScreenPointByEvent(e,t),i=un.screenPoint2NdcPoint(n,this.camera,t);return this.getHitResultByNdcCoordinate(i)}getHitResultByNdcCoordinate(e){if(!this.camera||!this.raycaster||!this.groundPlane)return;this.raycaster.setFromCamera(e,this.camera),this.raycaster.layers.set(10);let t=this.raycaster.intersectObject(this.groundPlane,!0);return t&&t.length>0?t[0].point:void 0}zoomToRect(){this.cancelAllOperations(),this.zoomToRectHelper||(this.zoomToRectHelper=new Dy(this)),this.zoomToRectHelper.activate()}deactivateZoomRect(){var e;null==(e=this.zoomToRectHelper)||e.deactivate()}getLayoutByName(e){let t,n=this.getLayouts();for(let i of n)if(i.layoutName===e){t=i;break}return t}getActiveLayoutInfo(){return this.getLayoutInfo(this.activeLayoutName)}getMsTransformMatrix(e){var t,n;let i=this.loadedModels.find((t=>e===t.modelId)),r=null==(t=null==i?void 0:i.dxfData)?void 0:t.header;if(!r)return;let a=r.$ANGDIR,s=this.getDxfUnits(i.dxfData),o=null==(n=i.dxfData)?void 0:n.tables.viewport.viewports.filter((e=>"*ACTIVE"===e.name.toLocaleUpperCase()));if(!o)return;let l=new Qe,h=vn.getDcs2WcsMatrix(o[0],a),c=new O(o[0].center.x,o[0].center.y,0).applyMatrix4(h),u=1;this.units&&s!==this.units&&(u=ume(s,this.units)),c.multiplyScalar(u),l.makeTranslation(c.x,c.y,0);let d=o[0].viewTwistAngle;null!=d&&l.multiply((new Qe).makeRotationZ(An.degToRad(d))),l.multiply((new Qe).makeTranslation(-c.x,-c.y,0)),i.msTransformMatrix=l}switchTransformMs(e,t){var n;let i=this.loadedModels.find((e=>t===e.modelId));if(!i)return void se.warn(`[Viewer] Can't find model whose modelId is ${t}`);let r=i.msTransformMatrix;if(Oy.identity(),!r||!Mt.isMatrixValid(r)||r.equals(Oy))return;let a=null==(n=i.dxfData)?void 0:n.threejsObject,s=null==a?void 0:a.children.find((e=>e.name===vn.MODEL_LAYOUT_NAME));s&&(e===vn.MODEL_LAYOUT_NAME?s.applyMatrix4(r):s.applyMatrix4(r.clone().invert()),s.updateMatrixWorld(!0))}getLayoutExtentEx(e){return e.layoutName===vn.MODEL_LAYOUT_NAME?this.getModelSpaceExtent():this.getLayoutExtent(e)}getModelSpaceExtent(){var e,t;let n=this.loadedModels.find((e=>this.masterModelId===e.modelId));if(!n)return;let i=null==(e=n.dxfData)?void 0:e.header,r=new O,a=new O;if(!i)return void se.error(`Header is undefined in ${this.masterModelId}!`);let s=null==(t=n.dxfData)?void 0:t.tables.viewport.viewports,o=i.$EXTMIN,l=i.$EXTMAX,h=i.$ANGDIR;if(s&&s.length>0)for(let c=0;cthis.masterModelId===e.modelId));if(!n)return;let i=null==(t=n.dxfData)?void 0:t.header,r=new O,a=new O;if(!i)throw new Error(`Header is undefined in ${this.masterModelId}!`);let s=this.getLayoutViewports(e),o=i.$PEXTMIN,l=i.$PEXTMAX,h=i.$ANGDIR;if(s&&s.length>0){let e,t=s.filter((e=>1===parseInt(e.viewportId)));e=t.length>0?t[0]:s[0];let{centerPoint:n,width_paperSpace:i,height_paperSpace:r}=e,a=vn.getDcs2WcsMatrix(e,h),c=new O(n.x,n.y,0);c.applyMatrix4(a),o={x:c.x-i/2,y:c.y-r/2,z:0},l={x:c.x+i/2,y:c.y+r/2,z:0}}return r.set(o.x,o.y,o.z),a.set(l.x,l.y,l.z),new Ot(r,a)}showLayoutObjects(e){this.loadedModels.forEach((t=>{var n;let i=0,r=0,a=null==(n=t.dxfData)?void 0:n.threejsObject;null==a||a.children.forEach((t=>{let n=t.name===e;t.visible=n,n?i++:r++})),se.debug(`[Viewer] showLayoutObjects('${e}') sets ${i} layout level object(s) to visible and ${r} to hidden for model '${null==a?void 0:a.name}'`)}))}getLayoutViewports(e){var t;let n=this.loadedModels.find((e=>this.masterModelId===e.modelId));if(!n)return[];let i=e.ownerHandle;return(null==(t=n.dxfData)?void 0:t.layoutViewportsMap[i])||[]}setMaterialUniforms(e,t){e instanceof cn&&(e.uniforms.u_cameraZoom&&(e.uniforms.u_cameraZoom=vn.cameraZoomUniform),e.uniforms.u_viewportScale&&1===(null==t?void 0:t.header.$PSLTSCALE)&&(e.uniforms.u_viewportScale=vn.viewportScaleUniform))}isLayerFrozenForViewport(e,t,n){if(!e||!t)return!1;let i=e.tables.layer.layers[t];return!!(i&&(1&i.flag)>0)||!(!n||n.length<=0)&&i&&n.indexOf(i.handle)>=0}getFilteredViewports(e){let t=this.getLayoutViewports(e),n=t.filter((e=>"1"!==e.viewportId));return n.length===t.length&&(n=t.filter(((e,t)=>0!==t))),n}generateObjectsByViewport(e,t,n,i=[]){let r=t;if("1"==t.viewportId)return;if(!r.psBBox||!r.msToPsMatrix)throw new Error("The bbox or matrix is invalid in the viewport!");vn.transformMatrixUniform={value:r.msToPsMatrix},vn.viewportScaleUniform={value:t.viewHeight/t.height_paperSpace};let a=r.psBBox.clone();a.applyMatrix4(r.msToPsMatrix.clone().invert()),a.min.setZ(-1),a.max.setZ(1);let s=this.getObjectsByBoundingBox(a);if(0===s.length)return;let o,l=r.psBBox.min,h=r.psBBox.max,c=new Ji(new be(l.x,l.y),new be(h.x,h.y)),u=Hu.generateSectionPlanesByBox(c),d=[],p=e=>(d[e.id]||(d[e.id]=e.clone(),this.setMaterialUniforms(d[e.id],n),Hu.setMaterialSection(d[e.id],u)),d[e.id]),f=[...i,...t.frozenLayerHandles||[]];if(e!==vn.MODEL_LAYOUT_NAME){let e=t;e.associatedLeafObjectSet||(e.associatedLeafObjectSet=new Set),o=e.associatedLeafObjectSet}let m=new er;m.name=t.viewportId;let g=null==n?void 0:n.layersAndThreejsObjects,v=[];if(s.forEach((t=>{let i=t.clone();i.traverse((t=>{if(t.material&&t.geometry){let i=t.userData.layerName;if(this.isLayerFrozenForViewport(n,i,f))return void v.push(t);!1!==t.userData.layerVisible&&(t.visible=!0),t.material=(e=>{if(Array.isArray(e)){let t=[];return e.forEach((e=>{let n=p(e);t.push(n)})),t}return p(e)})(t.material),null==o||o.add(t),g&&g[i]?g[i].push(t):se.warn(`[Viewer] Failed to find object for modelId '${this.masterModelId}', layer '${i}', layout '${e}'`)}})),m.add(i)})),o&&0===o.size)return;let y=null==n?void 0:n.threejsObject,x=null==y?void 0:y.children.find((t=>t.name===e));x||(x=new er,zn.setSharedVariablesOfObject(x),x.name=e,null==y||y.add(x)),x.add(m),m.applyMatrix4(r.msToPsMatrix),m.updateMatrixWorld(!0);let b=x.children.find((e=>e.name===vn.SNAP_GROUP_NAME));b||(b=new er,b.visible=vn.SHOW_SNAP_OBJECT,b.name=vn.SNAP_GROUP_NAME,x.add(b));let _=null==y?void 0:y.children.find((e=>e.name===vn.MODEL_LAYOUT_NAME)),w=null==_?void 0:_.children.find((e=>e.name===vn.SNAP_GROUP_NAME));w&&w.traverse((e=>{if(!e.geometry)return;let t=e.userData.layerName;if(this.isLayerFrozenForViewport(n,t,f)||(ky.makeEmpty(),ky.expandByObject(e),!a.intersectsBox(ky)))return;let i=e.clone();zn.setSharedVariablesOfObject(i);let s=i.parent,l=Oy.identity();for(;s&&!0!==s.userData.isLayoutLevelObject;)l.premultiply(s.matrix),s=s.parent;l.premultiply(r.msToPsMatrix),i.applyMatrix4(l),null==b||b.add(i),null==o||o.add(i),g&&g[t]&&g[t].push(i)})),v.length>0&&zn.removeEmptyObjectsFromRemovingObjects(v,m),m.traverse((e=>{zn.setSharedVariablesOfObject(e),this.addSpatialFilterSection(e,n,!0)}))}findSpatialFilter(e,t){let n,i=t.objects.SPATIAL_FILTER;if(i){for(let t of i)if(t.handle===e){n=t;break}return n}}getAnyMaterial(e){let t,n=e;if(n.material)return Array.isArray(n.material)?n.material[0]:n.material;for(let i=0;i0),r=a.clipIntersection),t&&r!==i.clipPolylines[0].bReversed)return void se.warn("[Viewer] Material cannot set clipIntersection to different values at the same time. clipIntersection needs to be set to true here!");r=i.clipPolylines[0].bReversed;let s=this.generateSectionsBySpatialFilter(i,e.matrixWorld);if(s){let n=e=>{let t=0;return e.clippingPlanes&&(t=e.clippingPlanes.length),t+s.length>vn.maxFragmentUniforms},i=new Set,a=e=>{i.has(e.id)||(i.add(e.id),n(e)||Hu.setMaterialSection(e,s,t,r))};e.traverse((e=>{let t=e.material;Array.isArray(t)?t.forEach((e=>{a(e)})):t&&a(t)}))}}}getObjectsByBoundingBox(e){var t;let n=[];if(e.isEmpty())return se.warn("[Viewer] bbox is empty !"),n;let i=null==(t=this.loadedModels.find((e=>this.masterModelId===e.modelId)).dxfData)?void 0:t.threejsObject,r=null==i?void 0:i.children.find((e=>e.name===vn.MODEL_LAYOUT_NAME));return r&&r.children.forEach((t=>{t.name!==vn.SNAP_GROUP_NAME&&(t=>{let i=ks.getBoundingBox(t,!1);e.intersectsBox(i)&&n.push(t)})(t)})),n}getDxfUnits(e){if(!e&&this.loadedModels.length>0){let t=this.loadedModels.find((e=>this.masterModelId===e.modelId));e=null==t?void 0:t.dxfData}if(!e)return"Unitless";let t=null==e?void 0:e.header;if(!t)return se.warn("DxfData or its header is undefined!"),"Unitless";let n=t.$INSUNITS;return vn.getDxfUnits(n)}generateSectionsBySpatialFilter(e,t){let n=e.clipPolylines[0];if(n.bConcave)return void se.warn("[Viewer] clipPolyline.bConcave = true is not supported yet in spatialFilter !");Oy.copy(t),e.localMatrix&&Oy.multiply(e.localMatrix);let i=n.polyline,r=[];i.forEach((e=>{let t=e.clone().applyMatrix4(Oy);r.push(new be(t.x,t.y))}));let a=qs.isClockWise(r),s=!a&&!n.bReversed||a&&n.bReversed;return Hu.generateSectionPlanesByPoints(r,s)}resize(e,t){super.resize(e,t),t>0&&(this.css2dRenderer&&(this.css2dRenderer.setSize(e,t),this.css2dRenderer.domElement.style.width="0",this.css2dRenderer.domElement.style.height="0"),this.overlayRender&&this.overlayRender.setSize(e,t)),this.enableRender()}getRaycaster(){return this.raycaster}getRaycastableObjects(){var e;if(this.raycastableObjects)return this.raycastableObjects;let t=Date.now(),n=[];for(let i of this.loadedModels){let t=null==(e=i.dxfData)?void 0:e.threejsObject,r=t&&t.children.find((e=>e.name===this.activeLayoutName));r&&r.traverse((e=>{(e.visible||e.userData.isSnapObject)&&zn.isLeafObject(e)&&n.push(e)}))}return this.groundPlane&&n.push(this.groundPlane),this.raycastableObjects=n,se.debug(`[Viewer] getRaycastableObjects() finds ${n.length} objects`),se.debug(`[Viewer] getRaycastableObjects() costs ${(Date.now()-t)/1e3} s`),n}getViewportByPoint(e){if(0===this.activeLayoutName.length||this.activeLayoutName===vn.MODEL_LAYOUT_NAME)return;let t=this.getLayoutByName(this.activeLayoutName);if(!t)return;let n=t=>e.xt.max.x||e.yt.max.y,i=this.getFilteredViewports(t);for(let r=0,a=i.length;r{e.object&&e.object.geometry&&o.push(e.object)})),e.transparent.forEach((e=>{e.object&&e.object.geometry&&o.push(e.object)})))}lve.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),cve.setFromProjectionMatrix(lve);for(let e of this.loadedModels){let t=null==(r=e.dxfData)?void 0:r.threejsObject,n=t&&t.children.find((e=>e.name===this.activeLayoutName));if(n){let e=n.children.find((e=>e.name===vn.SNAP_GROUP_NAME));null==e||e.traverse((e=>{if(zn.isLeafObject(e)){if(ky.makeEmpty(),ky.expandByObject(e),!cve.intersectsBox(ky))return;o.push(e)}}))}}this.groundPlane&&o.push(this.groundPlane),se.debug("[Viewer] getRaycastableObjectsByMouse() from modelSpace"),this.lastFrame=(null==(a=this.renderer)?void 0:a.info.render.frame)||0,this.raycastableObjects=o}else{let e=new WeakSet,t=this.getLayoutByName(this.activeLayoutName);if(t){let n=t.directAssociatedLeafObjectSet;n&&n.forEach((t=>{t.visible&&!e.has(t)&&(o.push(t),e.add(t))}))}let n=this.getViewportByPoint(this.raycaster.ray.origin);n&&n.associatedLeafObjectSet?(null==(s=n.associatedLeafObjectSet)||s.forEach((t=>{!e.has(t)&&(t.visible||t.userData.isSnapObject)&&(o.push(t),e.add(t))})),se.debug("[Viewer] getRaycastableObjectsByMouse() from inside of viewport:",n.viewportId)):se.debug("[Viewer] getRaycastableObjectsByMouse() from out of viewport"),this.groundPlane&&o.push(this.groundPlane)}return se.debug(`[Viewer] getRaycastableObjectsByMouse() costs ${(Date.now()-h)/1e3} s`),o}getIntersections(e){let t=this.getRaycastableObjectsByMouse(e);return this.raycaster&&this.raycaster.intersectObjects(t,!0)||[]}handleMouseClick(e){var t,n;if(null!=(t=this.measurePlugin)&&t.isActive()||null!=(n=this.markupManager)&&n.isMarkupActive()||(this.selectDrawableByEvent(e),this.selectedObject)||!this.enableSelection)return;this.raycaster&&this.raycaster.layers.set(12);let i=this.getIntersections(e);if(i.length>0){let e=e=>Mt.vectorToString(e);se.debug(`[Viewer] Clicked at: ${e(i[0].point)}`)}let r=i.find((e=>e.object.visible)),a=r&&r.object||void 0;this.selectedObject&&this.clearSelection(),a&&this.selectedObject&&this.selectedObject.id===a.id&&(a=void 0),a?this.selectObject(a):this.clearSelection()}selectDrawableByEvent(e){var t,n;this.clearSelection();let i=this.getHitResult(e);if(!i)return;let r=null==(t=this.overlayRender)?void 0:t.getDrawablesByPosition(i,this.raycaster);r&&r.length>0&&(r[0].selected=!0,this.selectedObject=r[0],null==(n=this.overlayRender)||n.render())}selectObject(e,t=!1){if(!this.enableSelection)return;let n=e=>{if(e.children.length>0&&e.children.forEach((e=>n(e))),e instanceof xt||e instanceof ur||e instanceof ii){let n=es.clonedHighlightMaterials(e,{depthTest:t});n&&(e.userData.originalMaterial=e.material,e.material=n)}},i=e=>{if(e.children.length>0&&e.children.forEach((e=>i(e))),(e instanceof xt||e instanceof ur||e instanceof ii)&&e.userData.originalMaterial){let t=e.material;e.material=e.userData.originalMaterial,delete e.userData.originalMaterial,Array.isArray(t)?t.forEach((e=>e.dispose())):t instanceof vr&&t.dispose()}},r=!1;this.selectedObject&&(i(this.selectedObject),this.selectedObject=void 0,r=!0),e&&(n(e),this.selectedObject=e,e.userData.dxfEntity?se.info("[Viewer] Selected entity:",e.userData.dxfEntity):se.info("[Viewer] Selected object:",e),r=!0),r&&this.enableRender()}clearSelection(){var e;this.selectedObject&&this.selectedObject instanceof Bi?(this.selectedObject.selected=!1,null==(e=this.overlayRender)||e.render()):this.selectObject(),this.selectedObject=void 0}flyToObjects(e){if(!e||0===e.length||!this.camera)return;let t=new Ot;e.forEach((e=>{let n=ks.getBoundingBox(e);n.isEmpty()||t.union(n)})),this.zoomToBBox(t)}flyToObject(e){this.flyToObjects([e])}flyToSelectedObject(){if(!this.selectedObject)return;let e=this.selectedObject;(e instanceof Pi&&e.userData.clonedMesh||e instanceof xt&&Ar.isMergedMesh(e)&&e.userData.clonedMesh)&&(e=e.userData.clonedMesh),this.flyToObject(e)}flyToRandomObject(){var e;let t=this.scene,n=[];for(let c of this.loadedModels){let t=null==(e=c.dxfData)?void 0:e.threejsObject;t&&n.push(t.id)}let i=n.length;if(i<=0)return;let r=n[Math.floor(Math.random()*i)],a=t.getObjectById(r);if(!a)return;let s=this.getActiveLayoutName();if(!a.children.find((e=>e.name===s)))return;let o=[];if(t.traverseVisible((e=>{(e instanceof xt||e instanceof ur)&&!["SKYBOX","GROUND_GRID","GROUND_GRASS","BIM_VIEWER_BOX_HELPER"].includes(e.name)&&o.push(e.id)})),o.length<1)return;let l=Math.floor(Math.random()*o.length),h=t.getObjectById(o[l]);h&&(se.info(`[Viewer] Flying to random object: ${h.name}, type: ${h.type}`),this.selectObject(h,void 0),this.flyToObject(h))}flyTo(e,t,n,i){let r=this.camera,a=this.controls;if(!r||!a)return;if(n&&(n=this.checkAndGetLimitedCameraZoom(n)),e.equals(t))return void se.error("[Viewer] Camera position and lookAt cannot be the same!");if(!Mt.isVectorValid(e)||!Mt.isVectorValid(t))return void se.error("[Viewer] Invalid position or lookAt!",e,t);let s=e.distanceTo(t);sr.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*r.far),se.warn("[Viewer] Camera could be too far to see the object!"));let o=(e,t,n)=>{n&&Number.isFinite(n)&&a.zoomTo(n),a.setLookAt(e.x,e.y,e.z,t.x,t.y,t.z),this.updateHidableObjectsVisibility(),this.enableRender()};if(!1===i)return this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),void o(e,t,n);let l=r.position.clone(),h=a.getTarget(new O),c=r.zoom,u=300,d=Date.now();this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=setInterval((()=>{let i=Date.now()-d;i>u&&(i=u);let r,a=(e,t,n)=>{let i=e.x+(t.x-e.x)*n,r=e.y+(t.y-e.y)*n,a=e.z+(t.z-e.z)*n;return new O(i,r,a)},s=a(l,e,i/u),p=a(h,t,i/u);n&&(r=c+(n-c)*i/u),o(s,p,r),i>=u&&(clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=void 0)}),10)}goTo(e,t,n){let i=this.camera,r=this.controls;if(!i||!r)return;let a=new O(e.x,e.y,i.position.z),s=r.getTarget(new O),o=new O(e.x,e.y,s.z);this.flyTo(a,o,t,n)}goToHomeView(){let e=this.getActiveLayoutInfo();e.homeViewExtent?this.zoomToBBox(e.homeViewExtent):se.error(`[Viewer] Failed to find extent for ${this.activeLayoutName}`)}zoomToBBox(e){let t=this.camera;if(!t)return;let n=e.max.x-e.min.x,i=e.max.y-e.min.y,r=t.right-t.left,a=t.top-t.bottom,s=Math.min(r/n,a/i);s/=1.1;let o=new Ot(new O(e.min.x,e.min.y,0),new O(e.max.x,e.max.y,0)),l=new O;o.getCenter(l),l.z=0;let h=l.clone().setZ(Math.max(t.position.z,this.CAMERA_Z_POSITION));h.equals(l)||this.flyTo(h,l,s,!1)}zoomToExtent(){let e=this.getActiveLayoutInfo();e.extent?this.zoomToBBox(e.extent):(console.error("[Viewer] Failed to find extent of current layout! Will go to home view."),this.goToHomeView())}zoomToCompareChange(e){if(this.changes){let t=this.changes[e];if(!t)return;let n=t.box;n&&this.zoomToBBox(n.clone().expandByScalar(1.2))}}getCompareChanges(){return this.changes}setBackgroundColor(e,t,n){!this.scene||!this.renderer||(uve.setRGB(e,t,n,this.renderer.outputColorSpace),(!this.scene.background||!(this.scene.background instanceof ct))&&(this.scene.background=new ct(e,t,n)),this.scene.background.copy(uve),this.enableRender())}getLayoutInfo(e){return this.layoutInfos[e]||(this.layoutInfos[e]={}),this.layoutInfos[e]}updateGroundPlane(){if(!this.scene)return;let e=this.getActiveLayoutInfo();if(!e.homeViewExtent)return;let t=e.homeViewExtent.clone();Mt.expandBoxByScale(t,3);let n=t.min,i=t.max,r=i.x-n.x+i.y-n.y+i.z-n.z;Mt.expandBoxByMinSize(t,r);let a=[],s=(e,t,n)=>{a.push(new O(e,t,n))},o=t.getSize(new O),l=t.getCenter(new O);if(s(-o.x/2,-o.y/2,0),s(o.x/2,-o.y/2,0),s(o.x/2,o.y/2,0),s(-o.x/2,o.y/2,0),this.groundPlane)this.groundPlane.position.set(l.x,l.y,-o.z),this.groundPlane.geometry.setFromPoints(a),this.groundPlane.geometry.computeBoundingSphere(),this.groundPlane.geometry.computeBoundingBox();else{let e=new Dt;e.setFromPoints(a),e.setIndex([0,3,2,0,2,1]);let t=new ln({color:"#888",transparent:!0,opacity:0,side:Er});this.groundPlane=new xt(e,t),this.groundPlane.visible=!0,this.groundPlane.frustumCulled=!1,this.groundPlane.position.set(l.x,l.y,-o.z),this.groundPlane.scale.set(1e5,1e5,1),this.groundPlane.name="groundPlane",this.groundPlane.renderOrder=-1e3,this.groundPlane.layers.enableAll(),zn.disableLayerChannels(this.groundPlane,[12]),this.scene.add(this.groundPlane)}this.groundPlane.updateMatrixWorld()}computeBoundingBox(){var e;let t=new Ot;for(let n of this.loadedModels){let i=null==(e=n.dxfData)?void 0:e.threejsObject;for(let e=0;i&&e{if(!this.isCompareMode()||!e.material)return!1;let t;return t=e.material instanceof cn?e.material.uniforms.u_color.value:e.material.color,t.equals(new ct(us.ENTITY_COLOR_ADDED))||t.equals(new ct(us.ENTITY_COLOR_REMOVED))},o=1;e.traverse((e=>{if(this.isCompareMode()&&s(e)||e.userData.isSnapObject||!zn.isLeafObject(e))return;let t=e.geometry;t.boundingBox||t.computeBoundingBox();let n=t.boundingBox.clone();if(!n||!Mt.isBoxValid(n))return;n.applyMatrix4(e.matrixWorld),n.getSize(B4);let i=Math.max(B4.x,B4.y),a=o/i;a<1/0?r.push({visibleMinZoom:a,object:e}):e instanceof ii?r.push({visibleMinZoom:o,object:e}):se.warn("[Viewer] The size of bbox is 0 ! ",e)})),o=this.getVisiblePixelSize(r.length);let l=0;r.forEach((e=>{let t=e.visibleMinZoom*o;e.visibleMinZoom=t,e.object.userData.visibleMinZoom=t,t>a&&(e.object.visible=!1,l++)})),r.sort(((e,t)=>e.visibleMinZoom-t.visibleMinZoom)),se.debug(`[Viewer] setLayoutHidableObjectArray cost: ${(Date.now()-n)/1e3}s, ${l} objects changed to hidden`)}statObjects(e){let t=this.sortedHidableObjects[this.activeLayoutName],n=t.length,i={},r=0;t.forEach((t=>{let n=t.object;if(n.geometry&&n.material){r++;let n=(t=>{let n=0,i=t;for(;i&&(n++,i!==e);)i=i.parent;return n})(t.object);i[n]||(i[n]=0),i[n]++}}));let a=0;e.traverse((e=>{let t=e;t.geometry&&t.material&&a++})),se.info(`[Viewer] hidableObjects count:${n}, real count:${r}, layout count: ${a}, level:`,i),se.info("[Viewer] scene:",this.scene)}updateHidableObjectsVisibility(){let e=this.camera;if(!e)return;let t=Date.now();this.controls.update(0);let n=e.zoom;if(Math.abs(n-this.lastCameraZoom)<1e-5||(this.updateRaycasterThreshold(),this.updateCameraZoomUniform(n),this.raycastableObjects=void 0,!this.sortedHidableObjects[this.activeLayoutName]))return;let i=this.sortedHidableObjects[this.activeLayoutName];if(0===i.length)return;let r=n>this.lastCameraZoom,a=Math.min(n,this.lastCameraZoom),s=Math.max(n,this.lastCameraZoom),o=[],l=0;for(let h=0;hs)break;i[h].object.visible=r,r&&o.push(i[h].object),l++}this.lastCameraZoom=n,se.debug(`[Viewer] updateHidableObjectsVisibility cost: ${(Date.now()-t)/1e3}s, ${l}(out of ${i.length}) objects changed to ${r?"visible":"hidden"}`)}updateRaycasterThreshold(){if(!this.camera||!this.raycaster)return;let e=3*this.getPixelSizeInWorldCoord(),t=this.raycaster.params;t.Line?t.Line.threshold=e:t.Line={threshold:e},t.Points?t.Points.threshold=e:t.Points={threshold:e}}updateCameraZoomUniform(e){vn.cameraZoomUniform.value=e}},IP=class{constructor(e){this.jobCount=0,this.viewer=new Qf(e);let t=document.getElementById(e.containerId);this.container=(null==t?void 0:t.parentElement)||document.body,this.loadingProgressBar=new Gf(this.container),this.loader=new vn(this.loadingManager,{ignorePaperSpace:!0}),this.initSpinner()}initSpinner(){let e=document.createElement("div");e.classList.add("gemini-spinner"),e.appendChild(document.createElement("span")),e.appendChild(document.createElement("span")),e.appendChild(document.createElement("span")),e.appendChild(document.createElement("span")),this.container.appendChild(e),this.spinner=e,this.setSpinnerVisibility(this.jobCount>0)}setFont(e){return ft(this,null,(function*(){let t=Date.now();this.fontManager||(this.fontManager=new cd),yield this.fontManager.loadFonts(e),se.info(`[DxfCompareHelper] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}compare(e,t,n,i){return ft(this,null,(function*(){var r,a,s,o,l;let{src:h,modelId:c}=e,{src:u}=t;this.viewer.masterModelId=c||h;let d=Date.now();if(this.increaseJobCount(),!this.fontManager)return Promise.reject("[DxfCompareHelper] Should set font first!");this.loader.setFont(this.fontManager),yield this.fontManager.getFontFromIndexeddb();let p=h+u,f=eg.t("ProgressBar.Comparing"),m=e=>{var t;null==(t=this.loadingProgressBar)||t.updateProgress(p,f,e),i&&i(new ProgressEvent("CompareProgress",{loaded:e,total:100}))},g=(e,t,n)=>{var r;let a=100*e.loaded/e.total;a=a*(n-t)/100+t,null==(r=this.loadingProgressBar)||r.updateProgress(p,f,a),i&&i(new ProgressEvent("CompareProgress",{loaded:a,total:100}))};Mt.printMemory("Before comparing"),null==(r=this.loadingProgressBar)||r.addProgressItem(p),m(0);let v=Date.now(),y=yield this.loader.parse(h,(e=>g(e,0,15))),x=yield this.loader.parse(u,(e=>g(e,15,30))),[b,_]=yield Promise.allSettled([y,x]);if("rejected"===b.status)return Promise.reject(`[DxfCompareHelper] Failed to parse ${h}`);if("rejected"===_.status)return Promise.reject(`[DxfCompareHelper] Failed to parse ${u}`);if(se.info(`[DxfCompareHelper] loadFiles in ${(Date.now()-v)/1e3}s`),vn.abortJobs)return Promise.reject("[DxfCompareHelper] compare loadFile aborted");let w=b.value,S=_.value;v=Date.now();let M=yield new us(w,S,n).compare((e=>g(e,30,60)));if(se.info(`[DxfCompareHelper] Compared in ${(Date.now()-v)/1e3}s`),se.debug("[DxfCompareHelper] Compared results:",M),vn.abortJobs)return Promise.reject("[DxfCompareHelper] compare change aborted");Mt.printMemory("After getting the comparison results"),v=Date.now(),yield this.loader.loadEntitiesForCompare(w,S,M,!0,(e=>g(e,60,95))),Mt.printMemory("After Creating threejs objects based on comparison result"),null==(a=this.fontManager)||a.releaseFontData(),this.changes=M,se.info(`[DxfCompareHelper] Creates threejs objects based on comparison result in ${(Date.now()-v)/1e3}s`);let E=w,T=S;if(this.decreaseJobCount(),Object.keys(M).length||se.info("[DxfCompareHelper] No change found"),0===(null==(s=E.threejsObject)?void 0:s.children.length)&&0===(null==(o=T.threejsObject)?void 0:o.children.length)){let e=`[DxfCompareHelper] Nothing was loaded from ${h} and ${u}`;return se.warn(e),Promise.reject(e)}let A=E.threejsObject,C=T.threejsObject;return A.name=h,C.name=u,v=Date.now(),this.viewer.addModel({modelId:e.modelId||e.src,dxfData:E}),Mt.printMemory("After adding first loaded Model to scene"),m(95),this.viewer.addModel({modelId:t.modelId||t.src,dxfData:T}),Mt.printMemory("After adding second loaded Model to scene"),se.info(`[DxfCompareHelper] Added compared objects to scene in ${(Date.now()-v)/1e3}s`),se.info(`[DxfCompareHelper] The comparison between ${h}' and '${u}' is completed in ${(Date.now()-d)/1e3}s !`),m(100),null==(l=this.loadingProgressBar)||l.delayRemoveProgressItem(p),Promise.resolve()}))}getChanges(){return this.changes}zoomToChange(e){if(this.changes){let t=this.changes[e];if(!t)return;let n=t.box;n&&this.viewer.zoomToBBox(n.clone().expandByScalar(1.2))}}setSpinnerVisibility(e){this.spinner&&(e?this.spinner.classList.remove("hidden"):this.spinner.classList.add("hidden"))}increaseJobCount(){this.setSpinnerVisibility(++this.jobCount>0)}decreaseJobCount(){this.setSpinnerVisibility(--this.jobCount>0)}},hve=class extends IP{constructor(e,t){super(e),this.syncCamera=!1,this.syncCameraControls=(e,t,n)=>{let i=new O,r=new O,a=new O;e.getPosition(r),e.getTarget(a),e.getFocalOffset(i),t.setLookAt(r.x,r.y,r.z,a.x,a.y,a.z),t.zoomTo(n),t.dispatchEvent({type:"control"})},this.viewer2=new Qf(t),this.initSyncCameraEvent()}initSyncCameraEvent(){let e=this.viewer.controls,t=this.viewer2.controls,n=!1;e.addEventListener("control",(()=>{n=!1})),e.addEventListener("update",(()=>{!this.syncCamera||n||this.syncCameraControls(e,t,this.viewer.camera.zoom)})),t.addEventListener("control",(()=>{n=!0})),t.addEventListener("update",(()=>{!this.syncCamera||!n||this.syncCameraControls(t,e,this.viewer2.camera.zoom)}))}enableSyncCamera(e){if(this.syncCamera=e,e){let e=this.viewer.controls,t=this.viewer2.controls;this.syncCameraControls(e,t,this.viewer.camera.zoom)}}compare(e,t,n,i){return ft(this,null,(function*(){var r,a,s,o,l;let{src:h,modelId:c}=e,{src:u,modelId:d}=t;this.viewer.masterModelId=c||h,this.viewer2.masterModelId=d||u;let p=Date.now();if(this.increaseJobCount(),!this.fontManager)return Promise.reject("[DxfCompareHelper] Should set font first!");this.loader.setFont(this.fontManager),yield this.fontManager.getFontFromIndexeddb();let f=h+u,m=eg.t("ProgressBar.Comparing"),g=e=>{var t;null==(t=this.loadingProgressBar)||t.updateProgress(f,m,e),i&&i(new ProgressEvent("CompareProgress",{loaded:e,total:100}))},v=(e,t,n)=>{var r;let a=100*e.loaded/e.total;a=a*(n-t)/100+t,null==(r=this.loadingProgressBar)||r.updateProgress(f,m,a),i&&i(new ProgressEvent("CompareProgress",{loaded:a,total:100}))};Mt.printMemory("Before comparing"),null==(r=this.loadingProgressBar)||r.addProgressItem(f),g(0);let y=Date.now(),x=yield this.loader.parse(h,(e=>v(e,0,15))),b=yield this.loader.parse(u,(e=>v(e,15,30))),[_,w]=yield Promise.allSettled([x,b]);if("rejected"===_.status)return Promise.reject(`[DxfCompareHelper] Failed to parse ${h}`);if("rejected"===w.status)return Promise.reject(`[DxfCompareHelper] Failed to parse ${u}`);if(se.info(`[DxfCompareHelper] loadFiles in ${(Date.now()-y)/1e3}s`),vn.abortJobs)return Promise.reject("[DxfCompareHelper] compare loadFile aborted");let S=_.value,M=w.value;y=Date.now();let E=yield new us(S,M,n).compare((e=>v(e,30,60)));if(se.info(`[DxfCompareHelper] Compared in ${(Date.now()-y)/1e3}s`),se.debug("Compared results:",E),vn.abortJobs)return Promise.reject("[DxfCompareHelper] compare change aborted");Mt.printMemory("After getting the comparison results"),y=Date.now(),yield this.loader.loadEntitiesForCompare(S,M,E,!1,(e=>v(e,60,95))),Mt.printMemory("After Creating threejs objects based on comparison result"),null==(a=this.fontManager)||a.releaseFontData(),this.changes=E,se.info(`[DxfCompareHelper] Creates threejs objects based on comparison result in ${(Date.now()-y)/1e3}s`);let T=S,A=M;if(this.decreaseJobCount(),Object.keys(E).length||se.info("[DxfCompareHelper] No change found"),0===(null==(s=T.threejsObject)?void 0:s.children.length)&&0===(null==(o=A.threejsObject)?void 0:o.children.length)){let e=`[DxfCompareHelper] Nothing was loaded from ${h} and ${u}`;return se.warn(e),Promise.reject(e)}let C=T.threejsObject,P=A.threejsObject;return C.name=h,P.name=u,y=Date.now(),this.viewer.addModel({modelId:e.modelId||e.src,dxfData:T}),Mt.printMemory("After adding first loaded Model to scene"),g(95),this.viewer2.addModel({modelId:t.modelId||t.src,dxfData:A}),Mt.printMemory("After adding second loaded Model to scene"),se.info(`[DxfCompareHelper] Added compared objects to scene in ${(Date.now()-y)/1e3}s`),se.info(`[DxfCompareHelper] The comparison between ${h}' and '${u}' is completed in ${(Date.now()-p)/1e3}s !`),g(100),null==(l=this.loadingProgressBar)||l.delayRemoveProgressItem(f),Promise.resolve()}))}zoomToChange(e){if(this.changes){let t=this.changes[e];if(!t)return;let n=t.box;n&&(this.viewer.zoomToBBox(n.clone().expandByScalar(1.2)),this.viewer2.zoomToBBox(n.clone().expandByScalar(1.2)))}}},sg=ji(dve(),1),hd=class{constructor(e,t){this.current=e,this.next=t,this.inNormal=this.inwardsNormal(),this.outNormal=this.outwardsNormal()}outwardsNormal(){let e=this.inwardsNormal();return[-e[0],-e[1]]}inwardsNormal(){let e=this.next[0]-this.current[0],t=this.next[1]-this.current[1],n=Math.sqrt(e*e+t*t);if(0===n)throw new Error("Vertices overlap");return[-t/n,e/n]}offset(e,t){return hd.offsetEdge(this.current,this.next,e,t)}inverseOffset(e,t){return hd.offsetEdge(this.next,this.current,e,t)}inverse(){return new hd(this.next,this.current)}static offsetEdge(e,t,n,i){return new hd([e[0]+n,e[1]+i],[t[0]+n,t[1]+i])}},x_=Array.isArray,fve=(e,t)=>e[0]===t[0]&&e[1]===t[1],V4=e=>Array.isArray(e)&&e.length,mve=(e,t=0,n=!1)=>{let i,r;if(V4(e)&&"number"==typeof e[0][0]){let t=0,a=e;for(i=0,r=a.length;i0||n&&t<0)&&a.reverse()}else for(i=0,r=e.length;i0);if(0===t&&V4(e)&&V4(e[0])&&"number"==typeof e[0][0][0]){let t=e[0].slice(0,1)[0];e[0].pop(),e[0].push([t[0],t[1]])}return e},pve=class{constructor(e,t=5){if(this.distance=0,this.arcSegments=t,!x_(e))throw new Error("Offset requires at least one coodinate to work with");this.edges=[],x_(e)&&"number"==typeof e[0]?this.vertices=e:(this.vertices=mve(e),this.processContour(this.vertices,this.edges))}processContour(e,t){let n,i;if(x_(e[0])&&"number"==typeof e[0][0])for(i=e.length,fve(e[0],e[i-1])&&(i-=1),n=0;nh?l-h:l+o-h,u=(s?-c:o-c)/a;e.push(i);for(let d=1;d0?this.margin(this.distance):this.padding(-this.distance)}offsetSegment(e,t,n,i){let r=[n.offset(n.inNormal[0]*i,n.inNormal[1]*i),n.inverseOffset(n.outNormal[0]*i,n.outNormal[1]*i)],a=[];for(let s=0,o=2;s0&&e.push(n)}e.length>0&&(t=1===e.length?e[0]:(0,sg.union)(e[0],...e.slice(1)))}else t=1===this.vertices.length?this.offsetPoint(e):this.offsetContour(this.vertices,this.edges);return t}offsetContour(e,t){let n=[],i=0,r=0;if(x_(e[0])&&"number"==typeof e[0][0]){for(i=0,r=e.length-1;i0&&(n=1===n.length?[n[0]]:(0,sg.union)(n[0],n.slice(1)))}else{let a=[];for(i=0,r=t.length;i0&&a.push(n)}a.length>0&&(n=1===a.length?a[0]:(0,sg.union)(a[0],...a.slice(1)))}return n}offsetPoint(e){this.setDistance(e);let t=2*this.arcSegments,n=[],i=this.vertices,r=this.distance,a=0;t%2==0&&t++;for(let s=0;se.get(t)}isFull(){return this.itemSet.size>=this.maxSize}add(e,t){let n=this.itemSet;if(n.has(e)||this.isFull())return!1;let i=this.usedSet,r=this.itemList,a=this.callbacks;return r.push(e),i.add(e),n.set(e,Date.now()),a.set(e,t),!0}remove(e){let t=this.usedSet,n=this.itemSet,i=this.itemList,r=this.callbacks;if(n.has(e)){r.get(e)(e);let a=i.indexOf(e);return i.splice(a,1),t.delete(e),n.delete(e),r.delete(e),!0}return!1}markUsed(e){let t=this.itemSet,n=this.usedSet;t.has(e)&&!n.has(e)&&(t.set(e,Date.now()),n.add(e))}markAllUnused(){this.usedSet.clear()}unloadUnusedContent(){let e=this.unloadPercent,t=this.minSize,n=this.itemList,i=this.itemSet,r=this.usedSet,a=this.callbacks,s=n.length-r.size,o=n.length-t,l=this.unloadPriorityCallback||this.defaultPriorityCallback;if(o>0&&s>0){n.sort(((e,t)=>{let n=r.has(e),i=r.has(t);return n&&i?0:n||i?n?1:-1:l(t)-l(e)}));let h=Math.min(o,s),c=Math.max(t*e,h*e),u=Math.min(c,s);u=Math.ceil(u);let d=n.splice(0,u);for(let e=0,t=d.length;e{this.scheduled=!1,this.unloadUnusedContent(),e&&this.markAllUnused()})))}},b_=class{constructor(){this.maxJobs=6,this.items=[],this.callbacks=new Map,this.currJobs=0,this.scheduled=!1,this.autoUpdate=!0,this.priorityCallback=()=>{throw new Error("PriorityQueue: PriorityCallback function not defined.")},this.schedulingCallback=e=>{requestAnimationFrame(e)},this._runjobs=()=>{this.tryRunJobs(),this.scheduled=!1}}sort(){let e=this.priorityCallback;this.items.sort(e)}add(e,t){return new Promise(((n,i)=>{let r=this.items,a=this.callbacks;r.push(e),a.set(e,((...e)=>t(...e).then(n).catch(i))),this.autoUpdate&&this.scheduleJobRun()}))}remove(e){let t=this.items,n=this.callbacks,i=t.indexOf(e);-1!==i&&(t.splice(i,1),n.delete(e))}tryRunJobs(){this.sort();let e=this.items,t=this.callbacks,n=this.maxJobs,i=this.currJobs;for(;n>i&&e.length>0;){i++;let n=e.pop(),r=t.get(n);t.delete(n),r(n).then((()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()})).catch((()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()}))}this.currJobs=i}scheduleJobRun(){this.scheduled||(this.schedulingCallback(this._runjobs),this.scheduled=!0)}},Mvt=.0033528106647474805,gve=-(6378137*Mvt-6378137);function q4(e){return 3===e||4===e}function ag(e,t){return e.__lastFrameVisited===t&&e.__used}function vve(e,t){e.__lastFrameVisited!==t&&(e.__lastFrameVisited=t,e.__used=!1,e.__inFrustum=!1,e.__isLeaf=!1,e.__visible=!1,e.__active=!1,e.__error=1/0,e.__distanceFromCamera=1/0,e.__childrenWereVisible=!1,e.__allChildrenLoaded=!1)}function yve(e,t,n){if(vve(e,t),e.__used=!0,n.markUsed(e),e.__contentEmpty){let i=e.children;for(let e=0,r=i.length;e0&&e.__depth+1>=a))return!0;let h=!1,c=e.children;for(let u=0,d=c.length;ue.__depth!==t.__depth?e.__depth>t.__depth?-1:1:e.__inFrustum!==t.__inFrustum?e.__inFrustum?1:-1:e.__used!==t.__used?e.__used?1:-1:e.__error!==t.__error?e.__error>t.__error?1:-1:e.__distanceFromCamera!==t.__distanceFromCamera?e.__distanceFromCamera>t.__distanceFromCamera?-1:1:0,Rvt=e=>1/(e.__depthFromRenderedParent+1),kP=class{get rootTileSet(){let e=this.tileSets[this.rootURL];return!e||e instanceof Promise?null:e}get root(){let e=this.rootTileSet;return e?e.root:null}constructor(e){this.tileSets={},this.rootURL=e,this.fetchOptions={},this.preprocessURL=null;let t=new LP;t.unloadPriorityCallback=Rvt;let n=new b_;n.maxJobs=4,n.priorityCallback=Eve;let i=new b_;i.maxJobs=1,i.priorityCallback=Eve,this.lruCache=t,this.downloadQueue=n,this.parseQueue=i,this.stats={parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0},this.frameCount=0,this.errorTarget=6,this.errorThreshold=1/0,this.loadSiblings=!0,this.displayActiveTiles=!1,this.maxDepth=1/0,this.stopAtEmptyTiles=!0}traverse(e,t){let n=this.tileSets[this.rootURL];!n||!n.root||OP(n.root,e,t)}update(){let e=this.stats,t=this.lruCache,n=this.tileSets,i=n[this.rootURL];if(!(this.rootURL in n))return void this.loadRootTileSet(this.rootURL);if(!i||!i.root)return;let r=i.root;e.inFrustum=0,e.used=0,e.active=0,e.visible=0,this.frameCount++,W4(r,this),j4(r,this),X4(r,this),Y4(r,this),t.scheduleUnload()}parseTile(e,t,n){return null}disposeTile(e){}preprocessNode(e,t,n){if(e.content&&(!("uri"in e.content)&&"url"in e.content&&(e.content.uri=e.content.url,delete e.content.url),e.content.uri&&(e.content.uri=new URL(e.content.uri,n+"/").toString()),e.content.boundingVolume&&!("box"in e.content.boundingVolume||"sphere"in e.content.boundingVolume||"region"in e.content.boundingVolume)&&delete e.content.boundingVolume),e.parent=t,e.children=e.children||[],e.content&&e.content.uri){let t=z4(e.content.uri),n=Boolean(t&&"json"===t.toLowerCase());e.__externalTileSet=n,e.__contentEmpty=n}else e.__externalTileSet=!1,e.__contentEmpty=!0;e.__distanceFromCamera=1/0,e.__error=1/0,e.__inFrustum=!1,e.__isLeaf=!1,e.__usedLastFrame=!1,e.__used=!1,e.__wasSetVisible=!1,e.__visible=!1,e.__childrenWereVisible=!1,e.__allChildrenLoaded=!1,e.__wasSetActive=!1,e.__active=!1,e.__loadingState=0,e.__loadIndex=0,e.__loadAbort=null,e.__depthFromRenderedParent=-1,null===t?(e.__depth=0,e.refine=e.refine||"REPLACE"):(e.__depth=t.__depth+1,e.refine=e.refine||t.refine)}setTileActive(e,t){}setTileVisible(e,t){}calculateError(e){return 0}tileInView(e){return!0}resetFailedTiles(){let e=this.stats;0!==e.failed&&(this.traverse((e=>{4===e.__loadingState&&(e.__loadingState=0)})),e.failed=0)}fetchTileSet(e,t,n=null){return fetch(e,t).then((t=>{if(t.ok)return t.json();throw new Error(`TilesRenderer: Failed to load tileset "${e}" with status ${t.status} : ${t.statusText}`)})).then((t=>{let i=t.asset.version;console.assert("1.0"===i||"0.0"===i,'asset.version is expected to be a string of "1.0" or "0.0"');let r=e.replace(/\/[^\/]*\/?$/,"");return r=new URL(r,window.location.href).toString(),OP(t.root,((e,t)=>this.preprocessNode(e,t,r)),null,n,n?n.__depth:0),t}))}loadRootTileSet(e){let t=this.tileSets;if(e in t)return t[e]instanceof Error?Promise.reject(t[e]):Promise.resolve(t[e]);{let n=this.fetchTileSet(this.preprocessURL?this.preprocessURL(e):e,this.fetchOptions).then((n=>{t[e]=n}));return n.catch((n=>{console.error(n),t[e]=n})),t[e]=n,n}}requestTileContents(e){if(0!==e.__loadingState)return;let t=this.stats,n=this.lruCache,i=this.downloadQueue,r=this.parseQueue,a=e.__externalTileSet;n.add(e,(e=>{1===e.__loadingState?(e.__loadAbort.abort(),e.__loadAbort=null):a?e.children.length=0:this.disposeTile(e),1===e.__loadingState?t.downloading--:2===e.__loadingState&&t.parsing--,e.__loadingState=0,e.__loadIndex++,r.remove(e),i.remove(e)})),e.__loadIndex++;let s=e.__loadIndex,o=new AbortController,l=o.signal;t.downloading++,e.__loadAbort=o,e.__loadingState=1;let h=a=>{e.__loadIndex===s&&("AbortError"!==a.name?(r.remove(e),i.remove(e),2===e.__loadingState?t.parsing--:1===e.__loadingState&&t.downloading--,t.failed++,console.error(`TilesRenderer : Failed to load tile at url "${e.content.uri}".`),console.error(a),e.__loadingState=4):n.remove(e))};a?i.add(e,(e=>{if(e.__loadIndex!==s)return Promise.resolve();let t=this.preprocessURL?this.preprocessURL(e.content.uri):e.content.uri;return this.fetchTileSet(t,Object.assign({signal:l},this.fetchOptions),e)})).then((n=>{e.__loadIndex===s&&(t.downloading--,e.__loadAbort=null,e.__loadingState=3,e.children.push(n.root))})).catch(h):i.add(e,(e=>{if(e.__loadIndex!==s)return Promise.resolve();let t=this.preprocessURL?this.preprocessURL(e.content.uri):e.content.uri;return fetch(t,Object.assign({signal:l},this.fetchOptions))})).then((t=>{if(e.__loadIndex===s){if(t.ok)return t.arrayBuffer();throw new Error(`Failed to load model with error code ${t.status}`)}})).then((n=>{if(e.__loadIndex===s)return t.downloading--,t.parsing++,e.__loadAbort=null,e.__loadingState=2,r.add(e,(e=>{if(e.__loadIndex!==s)return Promise.resolve();let t=z4(e.content.uri);return this.parseTile(n,e,t)}))})).then((()=>{e.__loadIndex===s&&(t.parsing--,e.__loadingState=3,e.__wasSetVisible&&this.setTileVisible(e,!0),e.__wasSetActive&&this.setTileActive(e,!0))})).catch(h)}dispose(){let e=this.lruCache;this.traverse((t=>{e.remove(t)})),this.stats={parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0},this.frameCount=0}};function FP(e){return(new TextDecoder).decode(e)}var dd=class{constructor(e,t,n,i){this.buffer=e,this.binOffset=t+n,this.binLength=i;let r=null;if(0!==n){let i=new Uint8Array(e,t,n);r=JSON.parse(FP(i))}else r={};this.header=r}getKeys(){return Object.keys(this.header)}getData(e,t,n=null,i=null){let r=this.header;if(!(e in r))return null;let a=r[e];if(a instanceof Object){if(Array.isArray(a))return a;{let r,{buffer:s,binOffset:o,binLength:l}=this,h=a.byteOffset||0,c=a.type||i,u=a.componentType||n;if("type"in a&&i&&a.type!==i)throw new Error("FeatureTable: Specified type does not match expected type.");switch(c){case"SCALAR":r=1;break;case"VEC2":r=2;break;case"VEC3":r=3;break;case"VEC4":r=4;break;default:throw new Error(`FeatureTable : Feature type not provided for "${e}".`)}let d,p=o+h,f=t*r;switch(u){case"BYTE":d=new Int8Array(s,p,f);break;case"UNSIGNED_BYTE":d=new Uint8Array(s,p,f);break;case"SHORT":d=new Int16Array(s,p,f);break;case"UNSIGNED_SHORT":d=new Uint16Array(s,p,f);break;case"INT":d=new Int32Array(s,p,f);break;case"UNSIGNED_INT":d=new Uint32Array(s,p,f);break;case"FLOAT":d=new Float32Array(s,p,f);break;case"DOUBLE":d=new Float64Array(s,p,f);break;default:throw new Error(`FeatureTable : Feature component type not provided for "${e}".`)}if(p+f*d.BYTES_PER_ELEMENT>o+l)throw new Error("FeatureTable: Feature data read outside binary body length.");return d}}return a}getBuffer(e,t){let{buffer:n,binOffset:i}=this;return n.slice(i+e,i+e+t)}},ep=class extends dd{constructor(e,t,n,i,r){super(e,n,i,r),this.batchSize=t}getData(e,t=null,n=null){return super.getData(e,this.batchSize,t,n)}},Zl=class{constructor(){this.fetchOptions={},this.workingPath=""}load(e){return fetch(e,this.fetchOptions).then((t=>{if(!t.ok)throw new Error(`Failed to load file "${e}" with status ${t.status} : ${t.statusText}`);return t.arrayBuffer()})).then((t=>(""===this.workingPath&&(this.workingPath=this.workingPathForURL(e)),this.parse(t))))}resolveExternalURL(e){return/^[^\\/]/.test(e)?this.workingPath+"/"+e:e}workingPathForURL(e){let t=e.split(/[\\/]/g);return t.pop(),t.join("/")+"/"}parse(e){throw new Error("LoaderBase: Parse not implemented.")}};function Gc(e){let t;if(t=e instanceof DataView?e:new DataView(e),"{"===String.fromCharCode(t.getUint8(0)))return null;let n="";for(let i=0;i<4;i++)n+=String.fromCharCode(t.getUint8(i));return n}var NP=class extends Zl{parse(e){let t=new DataView(e),n=Gc(t);console.assert("b3dm"===n);let i=t.getUint32(4,!0);console.assert(1===i);let r=t.getUint32(8,!0);console.assert(r===e.byteLength);let a=t.getUint32(12,!0),s=t.getUint32(16,!0),o=t.getUint32(20,!0),l=t.getUint32(24,!0),h=e.slice(28,28+a+s),c=new dd(h,0,a,s),u=28+a+s,d=e.slice(u,u+o+l),p=new ep(d,c.getData("BATCH_LENGTH"),0,o,l),f=u+o+l;return{version:i,featureTable:c,batchTable:p,glbBytes:new Uint8Array(e,f,r-f)}}},Fy=class extends NP{constructor(e=mo){super(),this.manager=e,this.adjustmentTransform=new Qe}parse(e){let t=super.parse(e),n=t.glbBytes.slice().buffer;return new Promise(((e,i)=>{let r=this.manager,a=this.fetchOptions,s=r.getHandler("path.gltf")||new th(r);"include"===a.credentials&&"cors"===a.mode&&s.setCrossOrigin("use-credentials"),"credentials"in a&&s.setWithCredentials("include"===a.credentials),a.headers&&s.setRequestHeader(a.headers);let o=this.workingPath;!/[\\/]$/.test(o)&&o.length&&(o+="/");let l=this.adjustmentTransform;s.parse(n,o,(n=>{let{batchTable:i,featureTable:r}=t,{scene:a}=n,s=r.getData("RTC_CENTER");s&&(a.position.x+=s[0],a.position.y+=s[1],a.position.z+=s[2]),n.scene.updateMatrix(),n.scene.matrix.multiply(l),n.scene.matrix.decompose(n.scene.position,n.scene.quaternion,n.scene.scale),n.batchTable=i,n.featureTable=r,a.batchTable=i,a.featureTable=r,e(n)}),i)}))}},BP=class extends Zl{parse(e){let t=new DataView(e),n=Gc(t);console.assert("pnts"===n);let i=t.getUint32(4,!0);console.assert(1===i);let r=t.getUint32(8,!0);console.assert(r===e.byteLength);let a=t.getUint32(12,!0),s=t.getUint32(16,!0),o=t.getUint32(20,!0),l=t.getUint32(24,!0),h=e.slice(28,28+a+s),c=new dd(h,0,a,s),u=28+a+s,d=e.slice(u,u+o+l),p=new ep(d,c.getData("BATCH_LENGTH")||c.getData("POINTS_LENGTH"),0,o,l);return Promise.resolve({version:i,featureTable:c,batchTable:p})}},_ve={RGB:"color",POSITION:"position"},Ny=class extends BP{constructor(e=mo){super(),this.manager=e}parse(e){return super.parse(e).then((e=>ft(this,null,(function*(){let t,{featureTable:n}=e,i=new xi,r=n.header.extensions;if(r&&r["3DTILES_draco_point_compression"]){let{byteOffset:e,byteLength:a,properties:s}=r["3DTILES_draco_point_compression"],o=this.manager.getHandler("draco.drc");if(null==o)throw new Error("PNTSLoader: dracoLoader not available.");let l={};for(let t in s)t in _ve&&t in s&&(l[_ve[t]]=s[t]);let h={attributeIDs:l,attributeTypes:{position:"Float32Array",color:"Uint8Array"},useUniqueIDs:!0},c=n.getBuffer(e,a);t=yield o.decodeGeometry(c,h),t.attributes.color&&(i.vertexColors=!0)}else{let e=n.getData("POINTS_LENGTH"),r=n.getData("POSITION",e,"FLOAT","VEC3"),a=n.getData("RGB",e,"UNSIGNED_BYTE","VEC3");t=new Dt,t.setAttribute("position",new gn(r,3,!1)),null!==a&&(t.setAttribute("color",new gn(a,3,!0)),i.vertexColors=!0)}["QUANTIZED_VOLUME_OFFSET","QUANTIZED_VOLUME_SCALE","CONSTANT_RGBA","BATCH_LENGTH","POSITION_QUANTIZED","RGBA","RGB565","NORMAL","NORMAL_OCT16P"].forEach((e=>{e in n.header&&console.warn(`PNTSLoader: Unsupported FeatureTable feature "${e}" detected.`)}));let a=new ii(t,i);e.scene=a,e.scene.featureTable=n;let s=n.getData("RTC_CENTER");return s&&(e.scene.position.x+=s[0],e.scene.position.y+=s[1],e.scene.position.z+=s[2]),e}))))}},UP=class extends Zl{parse(e){let t=new DataView(e),n=Gc(t);console.assert("i3dm"===n);let i=t.getUint32(4,!0);console.assert(1===i);let r=t.getUint32(8,!0);console.assert(r===e.byteLength);let a=t.getUint32(12,!0),s=t.getUint32(16,!0),o=t.getUint32(20,!0),l=t.getUint32(24,!0),h=t.getUint32(28,!0),c=e.slice(32,32+a+s),u=new dd(c,0,a,s),d=32+a+s,p=e.slice(d,d+o+l),f=new ep(p,u.getData("INSTANCES_LENGTH"),0,o,l),m=d+o+l,g=new Uint8Array(e,m,r-m),v=null,y=null;if(h)v=g,y=Promise.resolve();else{let e=this.resolveExternalURL(FP(g));y=fetch(e,this.fetchOptions).then((t=>{if(!t.ok)throw new Error(`I3DMLoaderBase : Failed to load file "${e}" with status ${t.status} : ${t.statusText}`);return t.arrayBuffer()})).then((e=>{v=new Uint8Array(e)}))}return y.then((()=>({version:i,featureTable:u,batchTable:f,glbBytes:v})))}},Tve=new O,K4=new O,J4=new O,wve=new O,Q4=new hr,HP=new O,VP=new Qe,By=class extends UP{constructor(e=mo){super(),this.manager=e,this.adjustmentTransform=new Qe}resolveExternalURL(e){return this.manager.resolveURL(super.resolveExternalURL(e))}parse(e){return super.parse(e).then((e=>{let{featureTable:t,batchTable:n}=e,i=e.glbBytes.slice().buffer;return new Promise(((e,r)=>{let a=this.fetchOptions,s=this.manager,o=s.getHandler("path.gltf")||new th(s);"include"===a.credentials&&"cors"===a.mode&&o.setCrossOrigin("use-credentials"),"credentials"in a&&o.setWithCredentials("include"===a.credentials),a.headers&&o.setRequestHeader(a.headers);let l=this.workingPath;/[\\/]$/.test(l)||(l+="/");let h=this.adjustmentTransform;o.parse(i,l,(i=>{let r=t.getData("INSTANCES_LENGTH"),a=t.getData("POSITION",r,"FLOAT","VEC3"),s=t.getData("NORMAL_UP",r,"FLOAT","VEC3"),o=t.getData("NORMAL_RIGHT",r,"FLOAT","VEC3"),l=t.getData("SCALE_NON_UNIFORM",r,"FLOAT","VEC3"),c=t.getData("SCALE",r,"FLOAT","SCALAR");["RTC_CENTER","QUANTIZED_VOLUME_OFFSET","QUANTIZED_VOLUME_SCALE","EAST_NORTH_UP","POSITION_QUANTIZED","NORMAL_UP_OCT32P","NORMAL_RIGHT_OCT32P"].forEach((e=>{e in t.header&&console.warn(`I3DMLoader: Unsupported FeatureTable feature "${e}" detected.`)}));let u=new Map,d=[];i.scene.traverse((e=>{if(e.isMesh){let{geometry:t,material:n}=e,i=new Pi(t,n,r);i.position.copy(e.position),i.rotation.copy(e.rotation),i.scale.copy(e.scale),d.push(i),u.set(e,i)}}));let p=new O;for(let e=0;e{let n=t.parent;n&&(n.remove(t),n.add(e),e.updateMatrixWorld(),e.position.copy(p).applyMatrix4(e.matrixWorld))}));for(let e=0;e{let t=new er;return e.forEach((e=>{t.add(e.scene)})),{tiles:e,scene:t}}))}},qP=class{constructor(){this.name="CESIUM_RTC"}afterRoot(e){if(e.parser.json.extensions&&e.parser.json.extensions.CESIUM_RTC){let{center:t}=e.parser.json.extensions.CESIUM_RTC;t&&(e.scene.position.x+=t[0],e.scene.position.y+=t[1],e.scene.position.z+=t[2])}}},WP=class extends Zl{constructor(e=mo){super(),this.manager=e}parse(e){return new Promise(((t,n)=>{let i=this.manager,r=this.fetchOptions,a=i.getHandler("path.gltf")||i.getHandler("path.glb");a||(a=new th(i),a.register((()=>new qP)),"include"===r.credentials&&"cors"===r.mode&&a.setCrossOrigin("use-credentials"),"credentials"in r&&a.setWithCredentials("include"===r.credentials),r.headers&&a.setRequestHeader(r.headers));let s=a.resourcePath||a.path||this.workingPath;!/[\\/]$/.test(s)&&s.length&&(s+="/"),a.parse(e,s,(e=>{t(e)}),n)}))}},jP=new Qe,XP=class extends er{constructor(e){super(),this.name="TilesRenderer.TilesGroup",this.tilesRenderer=e}raycast(e,t){this.tilesRenderer.optimizeRaycast&&this.tilesRenderer.raycast(e,t)}updateMatrixWorld(e){if(this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldNeedsUpdate||e){null===this.parent?jP.copy(this.matrix):jP.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1;let e=jP.elements,t=this.matrixWorld.elements,n=!1;for(let i=0;i<16;i++){let r=e[i],a=t[i];if(Math.abs(r-a)>Number.EPSILON){n=!0;break}}if(n){this.matrixWorld.copy(jP);let e=this.children;for(let t=0,n=e.length;t=t&&s<=n&&l>=i&&l<=r){let t=Cvt(e);u.push(t),this.getCartographicToPosition(s,l,o,t)}}}return u}getBoundingBox(e,t){Rve();let{latStart:n,latEnd:i,lonStart:r,lonEnd:a}=this;if(i-n{Object.getPrototypeOf(e).raycast.call(e,t,n)}))}function rV(e,t,n,i){if(n.has(e)){if(nV(e.cached.scene,i,Kl),Kl.length>0){Kl.length>1&&Kl.sort(tV);let e=Kl[0];return Kl.length=0,e}return null}let r=[],a=e.children;for(let l=0,h=a.length;l1e-6&&console.warn("ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when raycasting.");let n={distance:1/0,tile:null};r.push(n),h.containsPoint(lg.origin)?n.distance=0:n.distance=Ave.distanceToSquared(lg.origin)*t*t,n.tile=e}}}r.sort(tV);let s=1/0,o=null;for(let l=0,h=r.length;ls)break;{let r=e.tile,a=r.cached.scene,l=null;if(n.has(r)?(nV(a,i,Kl),Kl.length>0&&(Kl.length>1&&Kl.sort(tV),l=Kl[0])):l=rV(r,t,n,i),l){let e=l.distance*l.distance;e{e.frustumCulled=e[Ive]&&t}))}var w_=class extends kP{get autoDisableRendererCulling(){return this._autoDisableRendererCulling}set autoDisableRendererCulling(e){this._autoDisableRendererCulling!==e&&(super._autoDisableRendererCulling=e,this.forEachLoadedModel((t=>{Pve(t,!e)})))}constructor(...e){super(...e),this.group=new XP(this),this.cameras=[],this.cameraMap=new Map,this.cameraInfo=[],this.activeTiles=new Set,this.visibleTiles=new Set,this._autoDisableRendererCulling=!0,this.optimizeRaycast=!0,this.onLoadTileSet=null,this.onLoadModel=null,this.onDisposeModel=null,this.onTileVisibilityChange=null;let t=new Lu;t.setURLModifier((e=>this.preprocessURL?this.preprocessURL(e):e)),this.manager=t;let n=this;this._overridenRaycast=function(e,t){n.optimizeRaycast||Object.getPrototypeOf(this).raycast.call(this,e,t)}}getBounds(e){if(!this.root)return!1;let t=this.root.cached,n=t.box,i=t.boxTransform;return!!n&&(e.copy(n),e.applyMatrix4(i),!0)}getOrientedBounds(e,t){if(!this.root)return!1;let n=this.root.cached,i=n.box,r=n.boxTransform;return!!i&&(e.copy(i),t.copy(r),!0)}getBoundingSphere(e){if(!this.root)return!1;let t=this.root.cached.sphere;return!!t&&(e.copy(t),!0)}forEachLoadedModel(e){this.traverse((t=>{let n=t.cached.scene;n&&e(n,t)}))}raycast(e,t){if(this.root)if(e.firstHitOnly){let n=rV(this.root,this.group,this.activeTiles,e);n&&t.push(n)}else iV(this.root,this.group,this.activeTiles,e,t)}hasCamera(e){return this.cameraMap.has(e)}setCamera(e){let t=this.cameras,n=this.cameraMap;return!n.has(e)&&(n.set(e,new be),t.push(e),!0)}setResolution(e,t,n){let i=this.cameraMap;return!!i.has(e)&&(t instanceof be?i.get(e).copy(t):i.get(e).set(t,n),!0)}setResolutionFromRenderer(e,t){let n=this.cameraMap;if(!n.has(e))return!1;let i=n.get(e);return t.getSize(i),i.multiplyScalar(t.getPixelRatio()),!0}deleteCamera(e){let t=this.cameras,n=this.cameraMap;if(n.has(e)){let i=t.indexOf(e);return t.splice(i,1),n.delete(e),!0}return!1}fetchTileSet(e,...t){let n=super.fetchTileSet(e,...t);return n.then((t=>{this.onLoadTileSet&&Promise.resolve().then((()=>{this.onLoadTileSet(t,e)}))})),n}update(){let e=this.group,t=this.cameras,n=this.cameraMap,i=this.cameraInfo;if(0===t.length)return void console.warn("TilesRenderer: no cameras defined. Cannot update 3d tiles.");for(;i.length>t.length;)i.pop();for(;i.length1e-6&&console.warn("ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when calculating screen space error.");for(let a=0,s=i.length;ae.scene));break}case"pnts":{let t=new Ny(s);t.workingPath=r,t.fetchOptions=a,l=t.parse(e).then((e=>e.scene));break}case"i3dm":{let t=new By(s);t.workingPath=r,t.fetchOptions=a,t.adjustmentTransform.copy(qc),l=t.parse(e).then((e=>e.scene));break}case"cmpt":{let t=new GP(s);t.workingPath=r,t.fetchOptions=a,t.adjustmentTransform.copy(qc),l=t.parse(e).then((e=>e.scene));break}case"gltf":case"glb":let t=new WP(s);t.workingPath=r,t.fetchOptions=a,l=t.parse(e).then((e=>e.scene));break;default:console.warn(`TilesRenderer: Content type "${d}" not supported.`),l=Promise.resolve(null)}return l.then((e=>{if(t._loadIndex!==o)return;e.updateMatrix(),("glb"===d||"gltf"===d)&&e.matrix.multiply(qc),e.matrix.premultiply(u),e.matrix.decompose(e.position,e.quaternion,e.scale),e.traverse((e=>{e[Ive]=e.frustumCulled})),Pve(e,!this.autoDisableRendererCulling),c.scene=e,e.traverse((e=>{e.raycast=this._overridenRaycast}));let n=[],i=[],r=[];e.traverse((e=>{if(e.geometry&&i.push(e.geometry),e.material){let t=e.material;n.push(e.material);for(let e in t){let n=t[e];n&&n.isTexture&&r.push(n)}}})),c.materials=n,c.geometry=i,c.textures=r,this.onLoadModel&&this.onLoadModel(e,t)}))}disposeTile(e){let t=e.cached;if(t.scene){let n=t.materials,i=t.geometry,r=t.textures,a=t.scene.parent;for(let e=0,t=i.length;e25&&(t=25);let n=.5*(t-1),i=new Array(t),r=0;for(let a=0;a0){e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();let t=e.autoClear;e.autoClear=!1,r&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this.changeVisibilityOfSelectedObjects(!1);let i=this.renderScene.background;if(this.renderScene.background=null,this.renderScene.overrideMaterial=this.depthMaterial,e.setRenderTarget(this.renderTargetDepthBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this.updateTextureMatrix(),this.changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this.prepareMaskMaterial.uniforms.depthTexture.value=this.renderTargetDepthBuffer.texture,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.renderScene.overrideMaterial=null,this.changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this.renderScene.background=i,this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){let e=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(e),this.tempPulseColor2.multiplyScalar(e)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=jc.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=jc.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=jc.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=jc.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,r&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=t}this.renderToScreen&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=n.texture,e.setRenderTarget(null),this.fsQuad.render(e))}getPrepareMaskMaterial(){return new cn({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new be(.5,.5)},textureMatrix:{value:null}},vertexShader:"#include \n\t\t\t\t#include \n\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tuniform mat4 textureMatrix;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t\tvPosition = mvPosition;\n\n\t\t\t\t\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t\t\t\t\t#ifdef USE_INSTANCING\n\n\t\t\t\t\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t\t\t\t\t#endif\n\t\t\t\t\t\n\t\t\t\t\tworldPosition = modelMatrix * worldPosition;\n\n\t\t\t\t\tprojTexCoord = textureMatrix * worldPosition;\n\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tuniform sampler2D depthTexture;\n\t\t\t\tuniform vec2 cameraNearFar;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tfloat depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\n\t\t\t\t\tfloat viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );\n\t\t\t\t\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\n\t\t\t\t\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\n\n\t\t\t\t}"})}getEdgeDetectionMaterial(){return new cn({uniforms:{maskTexture:{value:null},texSize:{value:new be(.5,.5)},visibleEdgeColor:{value:new O(1,1,1)},hiddenEdgeColor:{value:new O(1,1,1)}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec3 visibleEdgeColor;\n\t\t\t\tuniform vec3 hiddenEdgeColor;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\n\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\n\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\n\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\n\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\n\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\n\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\n\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\n\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\n\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\n\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n\t\t\t\t}"})}getSeperableBlurMaterial(e){return new cn({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new be(.5,.5)},direction:{value:new be(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float kernelRadius;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat sigma = kernelRadius/2.0;\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, sigma);\n\t\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\n\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n\t\t\t\t\tvec2 uvOffset = delta;\n\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = kernelRadius * float(i) / float(MAX_RADIUS);\n\t\t\t\t\t\tfloat w = gaussianPdf(x, sigma);\n\t\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\n\t\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\n\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\n\t\t\t\t\t\tweightSum += (2.0 * w);\n\t\t\t\t\t\tuvOffset += delta;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = diffuseSum/weightSum;\n\t\t\t\t}"})}getOverlayMaterial(){return new cn({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform sampler2D edgeTexture1;\n\t\t\t\tuniform sampler2D edgeTexture2;\n\t\t\t\tuniform sampler2D patternTexture;\n\t\t\t\tuniform float edgeStrength;\n\t\t\t\tuniform float edgeGlow;\n\t\t\t\tuniform bool usePatternTexture;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\n\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n\t\t\t\t\tif(usePatternTexture)\n\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n\t\t\t\t\tgl_FragColor = finalColor;\n\t\t\t\t}",blending:_c,depthTest:!1,depthWrite:!1,transparent:!0})}};jc.BlurDirectionX=new be(1,0),jc.BlurDirectionY=new be(0,1);var n2=class extends bs{constructor(e,t,n,i,r){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=i,this.clearAlpha=void 0!==r?r:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new ct}render(e,t,n){let i,r,a=e.autoClear;e.autoClear=!1,void 0!==this.overrideMaterial&&(r=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor&&(e.getClearColor(this._oldClearColor),i=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor&&e.setClearColor(this._oldClearColor,i),void 0!==this.overrideMaterial&&(this.scene.overrideMaterial=r),e.autoClear=a}},A_={defines:{NUM_SAMPLES:7,NUM_RINGS:4,NORMAL_TEXTURE:0,DIFFUSE_TEXTURE:0,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},tDiffuse:{value:null},tNormal:{value:null},size:{value:new be(512,512)},cameraNear:{value:1},cameraFar:{value:100},cameraProjectionMatrix:{value:new Qe},cameraInverseProjectionMatrix:{value:new Qe},scale:{value:1},intensity:{value:.1},bias:{value:.5},minResolution:{value:0},kernelRadius:{value:100},randomSeed:{value:0}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\t#include \n\n\t\tvarying vec2 vUv;\n\n\t\t#if DIFFUSE_TEXTURE == 1\n\t\tuniform sampler2D tDiffuse;\n\t\t#endif\n\n\t\tuniform sampler2D tDepth;\n\n\t\t#if NORMAL_TEXTURE == 1\n\t\tuniform sampler2D tNormal;\n\t\t#endif\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\n\t\tuniform float scale;\n\t\tuniform float intensity;\n\t\tuniform float bias;\n\t\tuniform float kernelRadius;\n\t\tuniform float minResolution;\n\t\tuniform vec2 size;\n\t\tuniform float randomSeed;\n\n\t\t// RGBA depth\n\n\t\t#include \n\n\t\tvec4 getDefaultColor( const in vec2 screenPosition ) {\n\t\t\t#if DIFFUSE_TEXTURE == 1\n\t\t\treturn texture2D( tDiffuse, vUv );\n\t\t\t#else\n\t\t\treturn vec4( 1.0 );\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n\t\t\tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );\n\t\t\tclipPosition *= clipW; // unprojection.\n\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;\n\t\t}\n\n\t\tvec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {\n\t\t\t#if NORMAL_TEXTURE == 1\n\t\t\treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );\n\t\t\t#else\n\t\t\treturn normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );\n\t\t\t#endif\n\t\t}\n\n\t\tfloat scaleDividedByCameraFar;\n\t\tfloat minResolutionMultipliedByCameraFar;\n\n\t\tfloat getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {\n\t\t\tvec3 viewDelta = sampleViewPosition - centerViewPosition;\n\t\t\tfloat viewDistance = length( viewDelta );\n\t\t\tfloat scaledScreenDistance = scaleDividedByCameraFar * viewDistance;\n\n\t\t\treturn max(0.0, (dot(centerViewNormal, viewDelta) - minResolutionMultipliedByCameraFar) / scaledScreenDistance - bias) / (1.0 + pow2( scaledScreenDistance ) );\n\t\t}\n\n\t\t// moving costly divides into consts\n\t\tconst float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );\n\t\tconst float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );\n\n\t\tfloat getAmbientOcclusion( const in vec3 centerViewPosition ) {\n\t\t\t// precompute some variables require in getOcclusion.\n\t\t\tscaleDividedByCameraFar = scale / cameraFar;\n\t\t\tminResolutionMultipliedByCameraFar = minResolution * cameraFar;\n\t\t\tvec3 centerViewNormal = getViewNormal( centerViewPosition, vUv );\n\n\t\t\t// jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/\n\t\t\tfloat angle = rand( vUv + randomSeed ) * PI2;\n\t\t\tvec2 radius = vec2( kernelRadius * INV_NUM_SAMPLES ) / size;\n\t\t\tvec2 radiusStep = radius;\n\n\t\t\tfloat occlusionSum = 0.0;\n\t\t\tfloat weightSum = 0.0;\n\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i ++ ) {\n\t\t\t\tvec2 sampleUv = vUv + vec2( cos( angle ), sin( angle ) ) * radius;\n\t\t\t\tradius += radiusStep;\n\t\t\t\tangle += ANGLE_STEP;\n\n\t\t\t\tfloat sampleDepth = getDepth( sampleUv );\n\t\t\t\tif( sampleDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tfloat sampleViewZ = getViewZ( sampleDepth );\n\t\t\t\tvec3 sampleViewPosition = getViewPosition( sampleUv, sampleDepth, sampleViewZ );\n\t\t\t\tocclusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );\n\t\t\t\tweightSum += 1.0;\n\t\t\t}\n\n\t\t\tif( weightSum == 0.0 ) discard;\n\n\t\t\treturn occlusionSum * ( intensity / weightSum );\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat centerDepth = getDepth( vUv );\n\t\t\tif( centerDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\tfloat centerViewZ = getViewZ( centerDepth );\n\t\t\tvec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );\n\n\t\t\tfloat ambientOcclusion = getAmbientOcclusion( viewPosition );\n\n\t\t\tgl_FragColor = getDefaultColor( vUv );\n\t\t\tgl_FragColor.xyz *= 1.0 - ambientOcclusion;\n\t\t}"},vd={defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{value:null},size:{value:new be(512,512)},sampleUvOffsets:{value:[new be(0,0)]},sampleWeights:{value:[1]},tDepth:{value:null},cameraNear:{value:10},cameraFar:{value:1e3},depthCutoff:{value:10}},vertexShader:"\n\n\t\t#include \n\n\t\tuniform vec2 size;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec2 vInvSize;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tvInvSize = 1.0 / size;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\t#include \n\t\t#include \n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tDepth;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform float depthCutoff;\n\n\t\tuniform vec2 sampleUvOffsets[ KERNEL_RADIUS + 1 ];\n\t\tuniform float sampleWeights[ KERNEL_RADIUS + 1 ];\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec2 vInvSize;\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth( vUv );\n\t\t\tif( depth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\tfloat centerViewZ = -getViewZ( depth );\n\t\t\tbool rBreak = false, lBreak = false;\n\n\t\t\tfloat weightSum = sampleWeights[0];\n\t\t\tvec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;\n\n\t\t\tfor( int i = 1; i <= KERNEL_RADIUS; i ++ ) {\n\n\t\t\t\tfloat sampleWeight = sampleWeights[i];\n\t\t\t\tvec2 sampleUvOffset = sampleUvOffsets[i] * vInvSize;\n\n\t\t\t\tvec2 sampleUv = vUv + sampleUvOffset;\n\t\t\t\tfloat viewZ = -getViewZ( getDepth( sampleUv ) );\n\n\t\t\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) rBreak = true;\n\n\t\t\t\tif( ! rBreak ) {\n\t\t\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;\n\t\t\t\t\tweightSum += sampleWeight;\n\t\t\t\t}\n\n\t\t\t\tsampleUv = vUv - sampleUvOffset;\n\t\t\t\tviewZ = -getViewZ( getDepth( sampleUv ) );\n\n\t\t\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) lBreak = true;\n\n\t\t\t\tif( ! lBreak ) {\n\t\t\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;\n\t\t\t\t\tweightSum += sampleWeight;\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tgl_FragColor = diffuseSum / weightSum;\n\t\t}"},C_={createSampleWeights:function(e,t){let n=[];for(let i=0;i<=e;i++)n.push(Ovt(i,t));return n},createSampleOffsets:function(e,t){let n=[];for(let i=0;i<=e;i++)n.push(t.clone().multiplyScalar(i));return n},configure:function(e,t,n,i){e.defines.KERNEL_RADIUS=t,e.uniforms.sampleUvOffsets.value=C_.createSampleOffsets(t,i),e.uniforms.sampleWeights.value=C_.createSampleWeights(t,n),e.needsUpdate=!0}};function Ovt(e,t){return Math.exp(-e*e/(t*t*2))/(Math.sqrt(2*Math.PI)*t)}var r2={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\t#include \n\n\t\tvoid main() {\n\n\t\t\tfloat depth = 1.0 - unpackRGBAToDepth( texture2D( tDiffuse, vUv ) );\n\t\t\tgl_FragColor = vec4( vec3( depth ), opacity );\n\n\t\t}"},P_=class extends bs{constructor(e,t,n=!1,i=!1,r=new be(256,256)){let a;super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.supportsDepthTextureExtension=n,this.supportsNormalTexture=i,this.originalClearColor=new ct,this._oldClearColor=new ct,this.oldClearAlpha=1,this.params={output:0,saoBias:.5,saoIntensity:.18,saoScale:1,saoKernelRadius:100,saoMinResolution:0,saoBlur:!0,saoBlurRadius:8,saoBlurStdDev:4,saoBlurDepthCutoff:.01},this.resolution=new be(r.x,r.y),this.saoRenderTarget=new sr(this.resolution.x,this.resolution.y,{type:Rr}),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone(),this.beautyRenderTarget=this.saoRenderTarget.clone(),this.normalRenderTarget=new sr(this.resolution.x,this.resolution.y,{minFilter:Qr,magFilter:Qr,type:Rr}),this.depthRenderTarget=this.normalRenderTarget.clone(),this.supportsDepthTextureExtension&&(a=new cf,a.type=Sv,this.beautyRenderTarget.depthTexture=a,this.beautyRenderTarget.depthBuffer=!0),this.depthMaterial=new Tc,this.depthMaterial.depthPacking=Rv,this.depthMaterial.blending=ei,this.normalMaterial=new df,this.normalMaterial.blending=ei,this.saoMaterial=new cn({defines:Object.assign({},A_.defines),fragmentShader:A_.fragmentShader,vertexShader:A_.vertexShader,uniforms:Ti.clone(A_.uniforms)}),this.saoMaterial.extensions.derivatives=!0,this.saoMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.saoMaterial.defines.NORMAL_TEXTURE=this.supportsNormalTexture?1:0,this.saoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.saoMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?a:this.depthRenderTarget.texture,this.saoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.saoMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.blending=ei,this.vBlurMaterial=new cn({uniforms:Ti.clone(vd.uniforms),defines:Object.assign({},vd.defines),vertexShader:vd.vertexShader,fragmentShader:vd.fragmentShader}),this.vBlurMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.vBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.vBlurMaterial.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.vBlurMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?a:this.depthRenderTarget.texture,this.vBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.vBlurMaterial.blending=ei,this.hBlurMaterial=new cn({uniforms:Ti.clone(vd.uniforms),defines:Object.assign({},vd.defines),vertexShader:vd.vertexShader,fragmentShader:vd.fragmentShader}),this.hBlurMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.hBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.hBlurMaterial.uniforms.tDiffuse.value=this.blurIntermediateRenderTarget.texture,this.hBlurMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?a:this.depthRenderTarget.texture,this.hBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.hBlurMaterial.blending=ei,this.materialCopy=new cn({uniforms:Ti.clone(Sa.uniforms),vertexShader:Sa.vertexShader,fragmentShader:Sa.fragmentShader,blending:ei}),this.materialCopy.transparent=!0,this.materialCopy.depthTest=!1,this.materialCopy.depthWrite=!1,this.materialCopy.blending=Mm,this.materialCopy.blendSrc=Tv,this.materialCopy.blendDst=pf,this.materialCopy.blendEquation=Go,this.materialCopy.blendSrcAlpha=_v,this.materialCopy.blendDstAlpha=pf,this.materialCopy.blendEquationAlpha=Go,this.depthCopy=new cn({uniforms:Ti.clone(r2.uniforms),vertexShader:r2.vertexShader,fragmentShader:r2.fragmentShader,blending:ei}),this.fsQuad=new wa(null)}render(e,t,n){if(this.renderToScreen&&(this.materialCopy.blending=ei,this.materialCopy.uniforms.tDiffuse.value=n.texture,this.materialCopy.needsUpdate=!0,this.renderPass(e,this.materialCopy,null)),1===this.params.output)return;e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();let i=e.autoClear;e.autoClear=!1,e.setRenderTarget(this.depthRenderTarget),e.clear(),this.saoMaterial.uniforms.bias.value=this.params.saoBias,this.saoMaterial.uniforms.intensity.value=this.params.saoIntensity,this.saoMaterial.uniforms.scale.value=this.params.saoScale,this.saoMaterial.uniforms.kernelRadius.value=this.params.saoKernelRadius,this.saoMaterial.uniforms.minResolution.value=this.params.saoMinResolution,this.saoMaterial.uniforms.cameraNear.value=this.camera.near,this.saoMaterial.uniforms.cameraFar.value=this.camera.far;let r=this.params.saoBlurDepthCutoff*(this.camera.far-this.camera.near);this.vBlurMaterial.uniforms.depthCutoff.value=r,this.hBlurMaterial.uniforms.depthCutoff.value=r,this.vBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.vBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.hBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.hBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.params.saoBlurRadius=Math.floor(this.params.saoBlurRadius),(this.prevStdDev!==this.params.saoBlurStdDev||this.prevNumSamples!==this.params.saoBlurRadius)&&(C_.configure(this.vBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new be(0,1)),C_.configure(this.hBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new be(1,0)),this.prevStdDev=this.params.saoBlurStdDev,this.prevNumSamples=this.params.saoBlurRadius),e.setClearColor(0),e.setRenderTarget(this.beautyRenderTarget),e.clear(),e.render(this.scene,this.camera),this.supportsDepthTextureExtension||this.renderOverride(e,this.depthMaterial,this.depthRenderTarget,0,1),this.supportsNormalTexture&&this.renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this.renderPass(e,this.saoMaterial,this.saoRenderTarget,16777215,1),this.params.saoBlur&&(this.renderPass(e,this.vBlurMaterial,this.blurIntermediateRenderTarget,16777215,1),this.renderPass(e,this.hBlurMaterial,this.saoRenderTarget,16777215,1));let a=this.materialCopy;3===this.params.output?this.supportsDepthTextureExtension?(this.materialCopy.uniforms.tDiffuse.value=this.beautyRenderTarget.depthTexture,this.materialCopy.needsUpdate=!0):(this.depthCopy.uniforms.tDiffuse.value=this.depthRenderTarget.texture,this.depthCopy.needsUpdate=!0,a=this.depthCopy):4===this.params.output?(this.materialCopy.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.materialCopy.needsUpdate=!0):(this.materialCopy.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.materialCopy.needsUpdate=!0),0===this.params.output?a.blending=Mm:a.blending=ei,this.renderPass(e,a,this.renderToScreen?null:n),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=i}renderPass(e,t,n,i,r){e.getClearColor(this.originalClearColor);let a=e.getClearAlpha(),s=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,null!=i&&(e.setClearColor(i),e.setClearAlpha(r||0),e.clear()),this.fsQuad.material=t,this.fsQuad.render(e),e.autoClear=s,e.setClearColor(this.originalClearColor),e.setClearAlpha(a)}renderOverride(e,t,n,i,r){e.getClearColor(this.originalClearColor);let a=e.getClearAlpha(),s=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i=t.clearColor||i,r=t.clearAlpha||r,null!=i&&(e.setClearColor(i),e.setClearAlpha(r||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=s,e.setClearColor(this.originalClearColor),e.setClearAlpha(a)}setSize(e,t){this.beautyRenderTarget.setSize(e,t),this.saoRenderTarget.setSize(e,t),this.blurIntermediateRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.depthRenderTarget.setSize(e,t),this.saoMaterial.uniforms.size.value.set(e,t),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.needsUpdate=!0,this.vBlurMaterial.uniforms.size.value.set(e,t),this.vBlurMaterial.needsUpdate=!0,this.hBlurMaterial.uniforms.size.value.set(e,t),this.hBlurMaterial.needsUpdate=!0}dispose(){this.saoRenderTarget.dispose(),this.blurIntermediateRenderTarget.dispose(),this.beautyRenderTarget.dispose(),this.normalRenderTarget.dispose(),this.depthRenderTarget.dispose(),this.depthMaterial.dispose(),this.normalMaterial.dispose(),this.saoMaterial.dispose(),this.vBlurMaterial.dispose(),this.hBlurMaterial.dispose(),this.materialCopy.dispose(),this.depthCopy.dispose(),this.fsQuad.dispose()}};P_.OUTPUT={Beauty:1,Default:0,SAO:2,Depth:3,Normal:4};var i2=class extends bs{constructor(e,t,n,i){super(),this.scene=e,this.camera=t,this.sampleLevel=4,this.unbiased=!0,this.clearColor=void 0!==n?n:0,this.clearAlpha=void 0!==i?i:0,this._oldClearColor=new ct;let r=Sa;this.copyUniforms=Ti.clone(r.uniforms),this.copyMaterial=new cn({uniforms:this.copyUniforms,vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,premultipliedAlpha:!0,blending:_c}),this.fsQuad=new wa(this.copyMaterial)}dispose(){this.sampleRenderTarget&&(this.sampleRenderTarget.dispose(),this.sampleRenderTarget=null),this.copyMaterial.dispose(),this.fsQuad.dispose()}setSize(e,t){this.sampleRenderTarget&&this.sampleRenderTarget.setSize(e,t)}render(e,t,n){this.sampleRenderTarget||(this.sampleRenderTarget=new sr(n.width,n.height,{type:Rr}),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");let i=kvt[Math.max(0,Math.min(this.sampleLevel,5))],r=e.autoClear;e.autoClear=!1,e.getClearColor(this._oldClearColor);let a=e.getClearAlpha(),s=1/i.length;this.copyUniforms.tDiffuse.value=this.sampleRenderTarget.texture;let o={fullWidth:n.width,fullHeight:n.height,offsetX:0,offsetY:0,width:n.width,height:n.height},l=Object.assign({},this.camera.view);l.enabled&&Object.assign(o,l);for(let h=0;hp?(a=1,s=0):(a=0,s=1);let f=d-a+c,m=p-s+c,g=d-1+2*c,v=p-1+2*c,y=255&l,x=255&h,b=this.perm[y+this.perm[x]]%12,_=this.perm[y+a+this.perm[x+s]]%12,w=this.perm[y+1+this.perm[x+1]]%12,S=.5-d*d-p*p;S<0?n=0:(S*=S,n=S*S*this.dot(this.grad3[b],d,p));let M=.5-f*f-m*m;M<0?i=0:(M*=M,i=M*M*this.dot(this.grad3[_],f,m));let E=.5-g*g-v*v;return E<0?r=0:(E*=E,r=E*E*this.dot(this.grad3[w],g,v)),70*(n+i+r)}noise3d(e,t,n){let i,r,a,s,o,l,h,c,u,d,p=.3333333333333333*(e+t+n),f=Math.floor(e+p),m=Math.floor(t+p),g=Math.floor(n+p),v=1/6,y=(f+m+g)*v,x=e-(f-y),b=t-(m-y),_=n-(g-y);x>=b?b>=_?(o=1,l=0,h=0,c=1,u=1,d=0):x>=_?(o=1,l=0,h=0,c=1,u=0,d=1):(o=0,l=0,h=1,c=1,u=0,d=1):b<_?(o=0,l=0,h=1,c=0,u=1,d=1):x<_?(o=0,l=1,h=0,c=0,u=1,d=1):(o=0,l=1,h=0,c=1,u=1,d=0);let w=x-o+v,S=b-l+v,M=_-h+v,E=x-c+2*v,T=b-u+2*v,A=_-d+2*v,C=x-1+.5,P=b-1+.5,R=_-1+.5,O=255&f,L=255&m,I=255&g,D=this.perm[O+this.perm[L+this.perm[I]]]%12,k=this.perm[O+o+this.perm[L+l+this.perm[I+h]]]%12,N=this.perm[O+c+this.perm[L+u+this.perm[I+d]]]%12,F=this.perm[O+1+this.perm[L+1+this.perm[I+1]]]%12,U=.6-x*x-b*b-_*_;U<0?i=0:(U*=U,i=U*U*this.dot3(this.grad3[D],x,b,_));let B=.6-w*w-S*S-M*M;B<0?r=0:(B*=B,r=B*B*this.dot3(this.grad3[k],w,S,M));let z=.6-E*E-T*T-A*A;z<0?a=0:(z*=z,a=z*z*this.dot3(this.grad3[N],E,T,A));let H=.6-C*C-P*P-R*R;return H<0?s=0:(H*=H,s=H*H*this.dot3(this.grad3[F],C,P,R)),32*(i+r+a+s)}noise4d(e,t,n,i){let r,a,s,o,l,h=this.grad4,c=this.simplex,u=this.perm,d=(Math.sqrt(5)-1)/4,p=(5-Math.sqrt(5))/20,f=(e+t+n+i)*d,m=Math.floor(e+f),g=Math.floor(t+f),v=Math.floor(n+f),y=Math.floor(i+f),x=(m+g+v+y)*p,b=e-(m-x),_=t-(g-x),w=n-(v-x),S=i-(y-x),M=(b>_?32:0)+(b>w?16:0)+(_>w?8:0)+(b>S?4:0)+(_>S?2:0)+(w>S?1:0),E=c[M][0]>=3?1:0,T=c[M][1]>=3?1:0,A=c[M][2]>=3?1:0,C=c[M][3]>=3?1:0,P=c[M][0]>=2?1:0,R=c[M][1]>=2?1:0,O=c[M][2]>=2?1:0,L=c[M][3]>=2?1:0,I=c[M][0]>=1?1:0,D=c[M][1]>=1?1:0,k=c[M][2]>=1?1:0,N=c[M][3]>=1?1:0,F=b-E+p,U=_-T+p,B=w-A+p,z=S-C+p,H=b-P+2*p,V=_-R+2*p,j=w-O+2*p,G=S-L+2*p,W=b-I+3*p,X=_-D+3*p,Y=w-k+3*p,q=S-N+3*p,J=b-1+4*p,Z=_-1+4*p,K=w-1+4*p,$=S-1+4*p,Q=255&m,ee=255&g,te=255&v,ne=255&y,ie=u[Q+u[ee+u[te+u[ne]]]]%32,re=u[Q+E+u[ee+T+u[te+A+u[ne+C]]]]%32,ae=u[Q+P+u[ee+R+u[te+O+u[ne+L]]]]%32,se=u[Q+I+u[ee+D+u[te+k+u[ne+N]]]]%32,oe=u[Q+1+u[ee+1+u[te+1+u[ne+1]]]]%32,le=.6-b*b-_*_-w*w-S*S;le<0?r=0:(le*=le,r=le*le*this.dot4(h[ie],b,_,w,S));let he=.6-F*F-U*U-B*B-z*z;he<0?a=0:(he*=he,a=he*he*this.dot4(h[re],F,U,B,z));let ce=.6-H*H-V*V-j*j-G*G;ce<0?s=0:(ce*=ce,s=ce*ce*this.dot4(h[ae],H,V,j,G));let ue=.6-W*W-X*X-Y*Y-q*q;ue<0?o=0:(ue*=ue,o=ue*ue*this.dot4(h[se],W,X,Y,q));let de=.6-J*J-Z*Z-K*K-$*$;return de<0?l=0:(de*=de,l=de*de*this.dot4(h[oe],J,Z,K,$)),27*(r+a+s+o+l)}},I_={defines:{PERSPECTIVE_CAMERA:1,KERNEL_SIZE:32},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},kernel:{value:null},cameraNear:{value:null},cameraFar:{value:null},resolution:{value:new be},cameraProjectionMatrix:{value:new Qe},cameraInverseProjectionMatrix:{value:new Qe},kernelRadius:{value:8},minDistance:{value:.005},maxDistance:{value:.05}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tNormal;\n\t\tuniform sampler2D tDepth;\n\t\tuniform sampler2D tNoise;\n\n\t\tuniform vec3 kernel[ KERNEL_SIZE ];\n\n\t\tuniform vec2 resolution;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\n\t\tuniform float kernelRadius;\n\t\tuniform float minDistance; // avoid artifacts caused by neighbour fragments with minimal depth difference\n\t\tuniform float maxDistance; // avoid the influence of fragments which are too far away\n\n\t\tvarying vec2 vUv;\n\n\t\t#include \n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\n\t\t}\n\n\t\tfloat getLinearDepth( const in vec2 screenPosition ) {\n\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\n\t\t\t\tfloat fragCoordZ = texture2D( tDepth, screenPosition ).x;\n\t\t\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n\t\t\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\n\t\t\t#else\n\n\t\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\n\t\t\t#endif\n\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\n\t\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\n\t\t\t#else\n\n\t\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\n\t\t\t#endif\n\n\t\t}\n\n\t\tvec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n\n\t\t\tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );\n\n\t\t\tclipPosition *= clipW; // unprojection.\n\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;\n\n\t\t}\n\n\t\tvec3 getViewNormal( const in vec2 screenPosition ) {\n\n\t\t\treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat depth = getDepth( vUv );\n\t\t\tfloat viewZ = getViewZ( depth );\n\n\t\t\tvec3 viewPosition = getViewPosition( vUv, depth, viewZ );\n\t\t\tvec3 viewNormal = getViewNormal( vUv );\n\n\t\t\tvec2 noiseScale = vec2( resolution.x / 4.0, resolution.y / 4.0 );\n\t\t\tvec3 random = vec3( texture2D( tNoise, vUv * noiseScale ).r );\n\n\t\t\t// compute matrix used to reorient a kernel vector\n\n\t\t\tvec3 tangent = normalize( random - viewNormal * dot( random, viewNormal ) );\n\t\t\tvec3 bitangent = cross( viewNormal, tangent );\n\t\t\tmat3 kernelMatrix = mat3( tangent, bitangent, viewNormal );\n\n\t\t float occlusion = 0.0;\n\n\t\t for ( int i = 0; i < KERNEL_SIZE; i ++ ) {\n\n\t\t\t\tvec3 sampleVector = kernelMatrix * kernel[ i ]; // reorient sample vector in view space\n\t\t\t\tvec3 samplePoint = viewPosition + ( sampleVector * kernelRadius ); // calculate sample point\n\n\t\t\t\tvec4 samplePointNDC = cameraProjectionMatrix * vec4( samplePoint, 1.0 ); // project point and calculate NDC\n\t\t\t\tsamplePointNDC /= samplePointNDC.w;\n\n\t\t\t\tvec2 samplePointUv = samplePointNDC.xy * 0.5 + 0.5; // compute uv coordinates\n\n\t\t\t\tfloat realDepth = getLinearDepth( samplePointUv ); // get linear depth from depth texture\n\t\t\t\tfloat sampleDepth = viewZToOrthographicDepth( samplePoint.z, cameraNear, cameraFar ); // compute linear depth of the sample view Z value\n\t\t\t\tfloat delta = sampleDepth - realDepth;\n\n\t\t\t\tif ( delta > minDistance && delta < maxDistance ) { // if fragment is before sample point, increase occlusion\n\n\t\t\t\t\tocclusion += 1.0;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tocclusion = clamp( occlusion / float( KERNEL_SIZE ), 0.0, 1.0 );\n\n\t\t\tgl_FragColor = vec4( vec3( 1.0 - occlusion ), 1.0 );\n\n\t\t}"},L_={defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:"varying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"uniform sampler2D tDepth;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\n\t\tvarying vec2 vUv;\n\n\t\t#include \n\n\t\tfloat getLinearDepth( const in vec2 screenPosition ) {\n\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\n\t\t\t\tfloat fragCoordZ = texture2D( tDepth, screenPosition ).x;\n\t\t\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n\t\t\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\n\t\t\t#else\n\n\t\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\n\t\t\t#endif\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat depth = getLinearDepth( vUv );\n\t\t\tgl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );\n\n\t\t}"},D_={uniforms:{tDiffuse:{value:null},resolution:{value:new be}},vertexShader:"varying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"uniform sampler2D tDiffuse;\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec2 texelSize = ( 1.0 / resolution );\n\t\t\tfloat result = 0.0;\n\n\t\t\tfor ( int i = - 2; i <= 2; i ++ ) {\n\n\t\t\t\tfor ( int j = - 2; j <= 2; j ++ ) {\n\n\t\t\t\t\tvec2 offset = ( vec2( float( i ), float( j ) ) ) * texelSize;\n\t\t\t\t\tresult += texture2D( tDiffuse, vUv + offset ).r;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tgl_FragColor = vec4( vec3( result / ( 5.0 * 5.0 ) ), 1.0 );\n\n\t\t}"},Jl=class extends bs{constructor(e,t,n,i){super(),this.width=void 0!==n?n:512,this.height=void 0!==i?i:512,this.clear=!0,this.camera=t,this.scene=e,this.kernelRadius=8,this.kernelSize=32,this.kernel=[],this.noiseTexture=null,this.output=0,this.minDistance=.005,this.maxDistance=.1,this._visibilityCache=new Map,this.generateSampleKernel(),this.generateRandomKernelRotations();let r=new cf;r.format=Gh,r.type=Eu,this.beautyRenderTarget=new sr(this.width,this.height,{type:Rr}),this.normalRenderTarget=new sr(this.width,this.height,{minFilter:Qr,magFilter:Qr,type:Rr,depthTexture:r}),this.ssaoRenderTarget=new sr(this.width,this.height,{type:Rr}),this.blurRenderTarget=this.ssaoRenderTarget.clone(),this.ssaoMaterial=new cn({defines:Object.assign({},I_.defines),uniforms:Ti.clone(I_.uniforms),vertexShader:I_.vertexShader,fragmentShader:I_.fragmentShader,blending:ei}),this.ssaoMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.ssaoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.ssaoMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture,this.ssaoMaterial.uniforms.tNoise.value=this.noiseTexture,this.ssaoMaterial.uniforms.kernel.value=this.kernel,this.ssaoMaterial.uniforms.cameraNear.value=this.camera.near,this.ssaoMaterial.uniforms.cameraFar.value=this.camera.far,this.ssaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.ssaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssaoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.normalMaterial=new df,this.normalMaterial.blending=ei,this.blurMaterial=new cn({defines:Object.assign({},D_.defines),uniforms:Ti.clone(D_.uniforms),vertexShader:D_.vertexShader,fragmentShader:D_.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new cn({defines:Object.assign({},L_.defines),uniforms:Ti.clone(L_.uniforms),vertexShader:L_.vertexShader,fragmentShader:L_.fragmentShader,blending:ei}),this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture,this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new cn({uniforms:Ti.clone(Sa.uniforms),vertexShader:Sa.vertexShader,fragmentShader:Sa.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:Tv,blendDst:pf,blendEquation:Go,blendSrcAlpha:_v,blendDstAlpha:pf,blendEquationAlpha:Go}),this.fsQuad=new wa(null),this.originalClearColor=new ct}dispose(){this.beautyRenderTarget.dispose(),this.normalRenderTarget.dispose(),this.ssaoRenderTarget.dispose(),this.blurRenderTarget.dispose(),this.normalMaterial.dispose(),this.blurMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this.fsQuad.dispose()}render(e,t){switch(!1===e.capabilities.isWebGL2&&(this.noiseTexture.format=XR),e.setRenderTarget(this.beautyRenderTarget),e.clear(),e.render(this.scene,this.camera),this.overrideVisibility(),this.renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this.restoreVisibility(),this.ssaoMaterial.uniforms.kernelRadius.value=this.kernelRadius,this.ssaoMaterial.uniforms.minDistance.value=this.minDistance,this.ssaoMaterial.uniforms.maxDistance.value=this.maxDistance,this.renderPass(e,this.ssaoMaterial,this.ssaoRenderTarget),this.renderPass(e,this.blurMaterial,this.blurRenderTarget),this.output){case Jl.OUTPUT.SSAO:this.copyMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.copyMaterial.blending=ei,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Jl.OUTPUT.Blur:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=ei,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Jl.OUTPUT.Beauty:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=ei,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Jl.OUTPUT.Depth:this.renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case Jl.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=ei,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Jl.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=ei,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=Mm,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;default:console.warn("THREE.SSAOPass: Unknown output type.")}}renderPass(e,t,n,i,r){e.getClearColor(this.originalClearColor);let a=e.getClearAlpha(),s=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,null!=i&&(e.setClearColor(i),e.setClearAlpha(r||0),e.clear()),this.fsQuad.material=t,this.fsQuad.render(e),e.autoClear=s,e.setClearColor(this.originalClearColor),e.setClearAlpha(a)}renderOverride(e,t,n,i,r){e.getClearColor(this.originalClearColor);let a=e.getClearAlpha(),s=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i=t.clearColor||i,r=t.clearAlpha||r,null!=i&&(e.setClearColor(i),e.setClearAlpha(r||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=s,e.setClearColor(this.originalClearColor),e.setClearAlpha(a)}setSize(e,t){this.width=e,this.height=t,this.beautyRenderTarget.setSize(e,t),this.ssaoRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.blurRenderTarget.setSize(e,t),this.ssaoMaterial.uniforms.resolution.value.set(e,t),this.ssaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssaoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.blurMaterial.uniforms.resolution.value.set(e,t)}generateSampleKernel(){let e=this.kernelSize,t=this.kernel;for(let n=0;n\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec2 direction;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat fSigma = float(SIGMA);\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, fSigma);\n\t\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\n\t\t\t\t\tfor( int i = 1; i < KERNEL_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = float(i);\n\t\t\t\t\t\tfloat w = gaussianPdf(x, fSigma);\n\t\t\t\t\t\tvec2 uvOffset = direction * invSize * x;\n\t\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;\n\t\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;\n\t\t\t\t\t\tdiffuseSum += (sample1 + sample2) * w;\n\t\t\t\t\t\tweightSum += 2.0 * w;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n\t\t\t\t}"})}getCompositeMaterial(e){return new cn({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\t\t\t\tuniform sampler2D blurTexture1;\n\t\t\t\tuniform sampler2D blurTexture2;\n\t\t\t\tuniform sampler2D blurTexture3;\n\t\t\t\tuniform sampler2D blurTexture4;\n\t\t\t\tuniform sampler2D blurTexture5;\n\t\t\t\tuniform float bloomStrength;\n\t\t\t\tuniform float bloomRadius;\n\t\t\t\tuniform float bloomFactors[NUM_MIPS];\n\t\t\t\tuniform vec3 bloomTintColors[NUM_MIPS];\n\n\t\t\t\tfloat lerpBloomFactor(const in float factor) {\n\t\t\t\t\tfloat mirrorFactor = 1.2 - factor;\n\t\t\t\t\treturn mix(factor, mirrorFactor, bloomRadius);\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tgl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );\n\t\t\t\t}"})}};yd.BlurDirectionX=new be(1,0),yd.BlurDirectionY=new be(0,1);var Ove={uniforms:{tDiffuse:{value:null},resolution:{value:new be(1/1024,1/512)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\tprecision highp float;\n\n\tuniform sampler2D tDiffuse;\n\n\tuniform vec2 resolution;\n\n\tvarying vec2 vUv;\n\n\t// FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com)\n\n\t//----------------------------------------------------------------------------------\n\t// File: es3-keplerFXAAassetsshaders/FXAA_DefaultES.frag\n\t// SDK Version: v3.00\n\t// Email: gameworks@nvidia.com\n\t// Site: http://developer.nvidia.com/\n\t//\n\t// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.\n\t//\n\t// Redistribution and use in source and binary forms, with or without\n\t// modification, are permitted provided that the following conditions\n\t// are met:\n\t// * Redistributions of source code must retain the above copyright\n\t// notice, this list of conditions and the following disclaimer.\n\t// * Redistributions in binary form must reproduce the above copyright\n\t// notice, this list of conditions and the following disclaimer in the\n\t// documentation and/or other materials provided with the distribution.\n\t// * Neither the name of NVIDIA CORPORATION nor the names of its\n\t// contributors may be used to endorse or promote products derived\n\t// from this software without specific prior written permission.\n\t//\n\t// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY\n\t// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\t// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n\t// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n\t// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n\t// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n\t// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n\t// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n\t// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\t// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\t// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\t//\n\t//----------------------------------------------------------------------------------\n\n\t#ifndef FXAA_DISCARD\n\t\t\t//\n\t\t\t// Only valid for PC OpenGL currently.\n\t\t\t// Probably will not work when FXAA_GREEN_AS_LUMA = 1.\n\t\t\t//\n\t\t\t// 1 = Use discard on pixels which don't need AA.\n\t\t\t// For APIs which enable concurrent TEX+ROP from same surface.\n\t\t\t// 0 = Return unchanged color on pixels which don't need AA.\n\t\t\t//\n\t\t\t#define FXAA_DISCARD 0\n\t#endif\n\n\t/*--------------------------------------------------------------------------*/\n\t#define FxaaTexTop(t, p) texture2D(t, p, -100.0)\n\t#define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), -100.0)\n\t/*--------------------------------------------------------------------------*/\n\n\t#define NUM_SAMPLES 5\n\n\t// assumes colors have premultipliedAlpha, so that the calculated color contrast is scaled by alpha\n\tfloat contrast( vec4 a, vec4 b ) {\n\t\t\tvec4 diff = abs( a - b );\n\t\t\treturn max( max( max( diff.r, diff.g ), diff.b ), diff.a );\n\t}\n\n\t/*============================================================================\n\n\t\t\t\t\t\t\t\t\tFXAA3 QUALITY - PC\n\n\t============================================================================*/\n\n\t/*--------------------------------------------------------------------------*/\n\tvec4 FxaaPixelShader(\n\t\t\tvec2 posM,\n\t\t\tsampler2D tex,\n\t\t\tvec2 fxaaQualityRcpFrame,\n\t\t\tfloat fxaaQualityEdgeThreshold,\n\t\t\tfloat fxaaQualityinvEdgeThreshold\n\t) {\n\t\t\tvec4 rgbaM = FxaaTexTop(tex, posM);\n\t\t\tvec4 rgbaS = FxaaTexOff(tex, posM, vec2( 0.0, 1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaE = FxaaTexOff(tex, posM, vec2( 1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaN = FxaaTexOff(tex, posM, vec2( 0.0,-1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaW = FxaaTexOff(tex, posM, vec2(-1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\t// . S .\n\t\t\t// W M E\n\t\t\t// . N .\n\n\t\t\tbool earlyExit = max( max( max(\n\t\t\t\t\tcontrast( rgbaM, rgbaN ),\n\t\t\t\t\tcontrast( rgbaM, rgbaS ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaE ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaW ) )\n\t\t\t\t\t< fxaaQualityEdgeThreshold;\n\t\t\t// . 0 .\n\t\t\t// 0 0 0\n\t\t\t// . 0 .\n\n\t\t\t#if (FXAA_DISCARD == 1)\n\t\t\t\t\tif(earlyExit) FxaaDiscard;\n\t\t\t#else\n\t\t\t\t\tif(earlyExit) return rgbaM;\n\t\t\t#endif\n\n\t\t\tfloat contrastN = contrast( rgbaM, rgbaN );\n\t\t\tfloat contrastS = contrast( rgbaM, rgbaS );\n\t\t\tfloat contrastE = contrast( rgbaM, rgbaE );\n\t\t\tfloat contrastW = contrast( rgbaM, rgbaW );\n\n\t\t\tfloat relativeVContrast = ( contrastN + contrastS ) - ( contrastE + contrastW );\n\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\tbool horzSpan = relativeVContrast > 0.;\n\t\t\t// . 1 .\n\t\t\t// 0 0 0\n\t\t\t// . 1 .\n\n\t\t\t// 45 deg edge detection and corners of objects, aka V/H contrast is too similar\n\t\t\tif( abs( relativeVContrast ) < .3 ) {\n\t\t\t\t\t// locate the edge\n\t\t\t\t\tvec2 dirToEdge;\n\t\t\t\t\tdirToEdge.x = contrastE > contrastW ? 1. : -1.;\n\t\t\t\t\tdirToEdge.y = contrastS > contrastN ? 1. : -1.;\n\t\t\t\t\t// . 2 . . 1 .\n\t\t\t\t\t// 1 0 2 ~= 0 0 1\n\t\t\t\t\t// . 1 . . 0 .\n\n\t\t\t\t\t// tap 2 pixels and see which ones are \"outside\" the edge, to\n\t\t\t\t\t// determine if the edge is vertical or horizontal\n\n\t\t\t\t\tvec4 rgbaAlongH = FxaaTexOff(tex, posM, vec2( dirToEdge.x, -dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\t\tfloat matchAlongH = contrast( rgbaM, rgbaAlongH );\n\t\t\t\t\t// . 1 .\n\t\t\t\t\t// 0 0 1\n\t\t\t\t\t// . 0 H\n\n\t\t\t\t\tvec4 rgbaAlongV = FxaaTexOff(tex, posM, vec2( -dirToEdge.x, dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\t\tfloat matchAlongV = contrast( rgbaM, rgbaAlongV );\n\t\t\t\t\t// V 1 .\n\t\t\t\t\t// 0 0 1\n\t\t\t\t\t// . 0 .\n\n\t\t\t\t\trelativeVContrast = matchAlongV - matchAlongH;\n\t\t\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\t\t\tif( abs( relativeVContrast ) < .3 ) { // 45 deg edge\n\t\t\t\t\t\t\t// 1 1 .\n\t\t\t\t\t\t\t// 0 0 1\n\t\t\t\t\t\t\t// . 0 1\n\n\t\t\t\t\t\t\t// do a simple blur\n\t\t\t\t\t\t\treturn mix(\n\t\t\t\t\t\t\t\t\trgbaM,\n\t\t\t\t\t\t\t\t\t(rgbaN + rgbaS + rgbaE + rgbaW) * .25,\n\t\t\t\t\t\t\t\t\t.4\n\t\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\thorzSpan = relativeVContrast > 0.;\n\t\t\t}\n\n\t\t\tif(!horzSpan) rgbaN = rgbaW;\n\t\t\tif(!horzSpan) rgbaS = rgbaE;\n\t\t\t// . 0 . 1\n\t\t\t// 1 0 1 -> 0\n\t\t\t// . 0 . 1\n\n\t\t\tbool pairN = contrast( rgbaM, rgbaN ) > contrast( rgbaM, rgbaS );\n\t\t\tif(!pairN) rgbaN = rgbaS;\n\n\t\t\tvec2 offNP;\n\t\t\toffNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n\t\t\toffNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n\n\t\t\tbool doneN = false;\n\t\t\tbool doneP = false;\n\n\t\t\tfloat nDist = 0.;\n\t\t\tfloat pDist = 0.;\n\n\t\t\tvec2 posN = posM;\n\t\t\tvec2 posP = posM;\n\n\t\t\tint iterationsUsed = 0;\n\t\t\tint iterationsUsedN = 0;\n\t\t\tint iterationsUsedP = 0;\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i++ ) {\n\t\t\t\t\titerationsUsed = i;\n\n\t\t\t\t\tfloat increment = float(i + 1);\n\n\t\t\t\t\tif(!doneN) {\n\t\t\t\t\t\t\tnDist += increment;\n\t\t\t\t\t\t\tposN = posM + offNP * nDist;\n\t\t\t\t\t\t\tvec4 rgbaEndN = FxaaTexTop(tex, posN.xy);\n\t\t\t\t\t\t\tdoneN = contrast( rgbaEndN, rgbaM ) > contrast( rgbaEndN, rgbaN );\n\t\t\t\t\t\t\titerationsUsedN = i;\n\t\t\t\t\t}\n\n\t\t\t\t\tif(!doneP) {\n\t\t\t\t\t\t\tpDist += increment;\n\t\t\t\t\t\t\tposP = posM - offNP * pDist;\n\t\t\t\t\t\t\tvec4 rgbaEndP = FxaaTexTop(tex, posP.xy);\n\t\t\t\t\t\t\tdoneP = contrast( rgbaEndP, rgbaM ) > contrast( rgbaEndP, rgbaN );\n\t\t\t\t\t\t\titerationsUsedP = i;\n\t\t\t\t\t}\n\n\t\t\t\t\tif(doneN || doneP) break;\n\t\t\t}\n\n\n\t\t\tif ( !doneP && !doneN ) return rgbaM; // failed to find end of edge\n\n\t\t\tfloat dist = min(\n\t\t\t\t\tdoneN ? float( iterationsUsedN ) / float( NUM_SAMPLES - 1 ) : 1.,\n\t\t\t\t\tdoneP ? float( iterationsUsedP ) / float( NUM_SAMPLES - 1 ) : 1.\n\t\t\t);\n\n\t\t\t// hacky way of reduces blurriness of mostly diagonal edges\n\t\t\t// but reduces AA quality\n\t\t\tdist = pow(dist, .5);\n\n\t\t\tdist = 1. - dist;\n\n\t\t\treturn mix(\n\t\t\t\t\trgbaM,\n\t\t\t\t\trgbaN,\n\t\t\t\t\tdist * .5\n\t\t\t);\n\t}\n\n\tvoid main() {\n\t\t\tconst float edgeDetectionQuality = .2;\n\t\t\tconst float invEdgeDetectionQuality = 1. / edgeDetectionQuality;\n\n\t\t\tgl_FragColor = FxaaPixelShader(\n\t\t\t\t\tvUv,\n\t\t\t\t\ttDiffuse,\n\t\t\t\t\tresolution,\n\t\t\t\t\tedgeDetectionQuality, // [0,1] contrast needed, otherwise early discard\n\t\t\t\t\tinvEdgeDetectionQuality\n\t\t\t);\n\n\t}\n\t"},a2=class{constructor(){this.vertexShader="\n varying vec2 vUv;\n void main( void ) {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);\n }",this.fragmentShader="\n uniform vec3 keyColor;\n uniform float similarity;\n uniform float smoothness;\n varying vec2 vUv;\n uniform sampler2D map;\n void main() {\n vec4 videoColor = texture2D(map, vUv);\n\n float Y1 = 0.299 * keyColor.r + 0.587 * keyColor.g + 0.114 * keyColor.b;\n float Cr1 = keyColor.r - Y1;\n float Cb1 = keyColor.b - Y1;\n \n float Y2 = 0.299 * videoColor.r + 0.587 * videoColor.g + 0.114 * videoColor.b;\n float Cr2 = videoColor.r - Y2; \n float Cb2 = videoColor.b - Y2; \n \n float blend = smoothstep(similarity, similarity + smoothness, distance(vec2(Cr2, Cb2), vec2(Cr1, Cb1)));\n gl_FragColor = vec4(videoColor.rgb, videoColor.a * blend); \n }";let e=document.createElement("video");this.webcam=e,navigator.mediaDevices.getUserMedia({video:{width:600,height:400}}).then((t=>{e.srcObject=t,e.onloadedmetadata=()=>{e.setAttribute("autoplay","true"),e.setAttribute("playsinline","true"),e.play()}})).catch((function(e){alert(e.name+": "+e.message)})),this.webcamCanvas=document.createElement("canvas");let t=this.webcamCanvas.getContext("2d");this.canvasCtx=t,t.fillStyle="#000000",t.fillRect(0,0,this.webcamCanvas.width,this.webcamCanvas.height);let n=new qr(this.webcamCanvas);this.webcamTexture=n,n.minFilter=Ir,n.magFilter=Ir,this.shaderMaterial=new cn({transparent:!0,uniforms:{map:{value:n},keyColor:{value:[0,1,0]},similarity:{value:.3},smoothness:{value:0}},vertexShader:this.vertexShader,fragmentShader:this.fragmentShader})}getShaderMaterial(){return this.shaderMaterial}createWebCamPlane(e=5,t=4){let n=new ui(e,t);return new xt(n,this.shaderMaterial)}animate(){this.webcam.readyState===this.webcam.HAVE_ENOUGH_DATA&&(this.canvasCtx.drawImage(this.webcam,0,0,this.webcamCanvas.width,this.webcamCanvas.height),this.webcamTexture.needsUpdate=!0)}},$a=new O(1,0,0),np=new O(0,1,0),rp=new O(0,0,1),kve=new O(0,1,0),O_=new Qe,qy=2,Xc=class extends er{constructor(e=$a){super(),this.redMaterial=new ln({color:16711680,depthTest:!1}),this.greenMaterial=new ln({color:65280,depthTest:!1}),this.blueMaterial=new ln({color:255,depthTest:!1}),this.highlightMaterial=new ln({color:16776960,depthTest:!1}),this.pickableMaterial=new ln({color:9807270,depthTest:!1}),this.initIgnoreClipMaterial(),this.initOrUpdateByAxis(e)}initIgnoreClipMaterial(){[this.redMaterial,this.greenMaterial,this.blueMaterial,this.highlightMaterial,this.pickableMaterial].forEach((e=>{e.onBeforeCompile=function(e,t){e.fragmentShader=e.fragmentShader.replace("#include ","").replace("#include ",""),e.vertexShader=e.vertexShader.replace("#include ","").replace("#include ","")}}))}setDirection(e){let t=new hr;t.setFromUnitVectors($a,e),this.applyQuaternion(t)}initOrUpdateByAxis(e){this.clear(),[{actionType:"TranslateX",direction:$a,material:this.redMaterial},{actionType:"TranslateY",direction:np,material:this.greenMaterial},{actionType:"TranslateZ",direction:rp,material:this.blueMaterial}].forEach((t=>{let{actionType:n,direction:i,material:r}=t,a=this.createTranslateGizmo(n,i,qy,0===i.angleTo(e)?r:this.pickableMaterial);this.add(a)})),[{actionType:"RotateX",direction:$a,material:this.redMaterial,degree:90},{actionType:"RotateY",direction:np,material:this.greenMaterial,degree:90},{actionType:"RotateZ",direction:rp,material:this.blueMaterial,degree:90}].forEach((t=>{let{actionType:n,direction:i,material:r,degree:a}=t;if(0!==i.angleTo(e)){let e=this.createRotateGizmo(n,i,qy,r,a);this.add(e)}})),this.createSphere(1,this.pickableMaterial),this.createSphere(1,this.pickableMaterial,new O(12*qy,0,0)),this.createSphere(1,this.pickableMaterial,new O(0,12*qy,0)),this.createSphere(1,this.pickableMaterial,new O(0,0,12*qy))}createTranslateGizmo(e,t,n,i){let r=t.angleTo(kve),a=kve.clone().cross(t);O_.makeRotationAxis(a,r);let s=new wc(n/5,n/5,20*n),o=10*n;s.translate(0,o,0),s.applyMatrix4(O_);let l=new wc(0,n,3*n),h=2*o;l.translate(0,h,0),l.applyMatrix4(O_);let c=Ni([l,s]),u=new xt(c,i);return u.layers.enable(12),u.userData.actionType=e,i===this.pickableMaterial&&u.layers.disable(12),u}createRotateGizmo(e,t,n,i,r){let a=new O(0,0,1),s=t.clone().cross(a),o=t.angleTo(a);O_.makeRotationAxis(s,o);let l=new uf(12*n,n/5,24,36,An.degToRad(r));l.applyMatrix4(O_);let h=new xt(l,i);return h.layers.enable(12),h.userData.actionType=e,h}createSphere(e,t,n=new O){let i=new za(e,32,16),r=new xt(i,t);r.position.copy(n),r.layers.disable(12),this.add(r)}setActiveAxis(e){this.initOrUpdateByAxis(e)}createHoverRotateObjectByAxis(e){let t=$a;switch(e){case"RotateX":t=$a;break;case"RotateY":t=np;break;case"RotateZ":t=rp}return this.createRotateGizmo("",t,qy,this.highlightMaterial,360)}setActive(e,t){var n;let i=t.userData.actionType;["RotateX","RotateY","RotateZ"].includes(i)?e?(this.hoverObject=this.createHoverRotateObjectByAxis(i),this.add(this.hoverObject),t.visible=!1):(null==(n=this.hoverObject)||n.removeFromParent(),t.visible=!0,this.hoverObject=void 0):e?(this.originalMaterial=t.material,t.material=this.highlightMaterial):this.originalMaterial&&(t.material=this.originalMaterial)}adjustSize(e){let t=new O;this.getWorldPosition(t);let n=e.position,i=1;e instanceof Ur?i=(e.top-e.bottom)/e.zoom:e instanceof cr&&(i=t.distanceTo(n)*Math.min(1.9*Math.tan(Math.PI*e.fov/360)/e.zoom,7)),this.scale.set(1,1,1).multiplyScalar(i/180)}},ip=class{constructor(e,t){if(this.raycaster=new ia,this.sectionBox=new Ot,this.mouseDown=!1,this.lastWorldPos=new O,this.mouseMoved=!1,this.dragStarted=!1,this.refrencePlane=new Gr,this.active=!1,this.showSectionPlane=!1,this.mousedown=e=>{if(0===e.button){if(Dn.isMobile){let t=this.getIntersections(e);t?(this.inputManager.setCursor("grab"),this.selectedObject=t.object,this.activateSelectedObject(!0),this.enableDefaultControl(!1),this.viewer.enableRender()):this.enableDefaultControl(!0)}this.camera&&this.selectedObject&&(this.inputManager.setCursor("grabbing"),this.mouseDown=!0)}},this.mousemove=e=>{if(this.dragStarted)this.updateRaycasterByMouse(e),this.inputManager.setCursor("grabbing"),this.onDragMove(e);else{this.activateSelectedObject(!1);let t=this.getIntersections(e);t?(this.inputManager.setCursor("grab"),this.selectedObject=t.object,this.activateSelectedObject(!0),this.mouseDown&&(this.dragStarted||(this.dragStarted=!0,this.enableDefaultControl(!1),this.onDragStart(e)))):(this.inputManager.setCursor("default"),this.selectedObject=void 0)}this.viewer.enableRender()},this.mouseup=e=>{0===e.button&&(this.activateSelectedObject(!1),this.mouseDown&&this.dragStarted&&(this.inputManager.setCursor("grab"),this.onDragEnd(e),this.dragStarted=!1,this.enableDefaultControl(!0)),this.mouseDown=!1,this.selectedObject=void 0)},this.keydown=e=>{"Escape"===e.code&&this.deactivate()},!(e.camera&&e.renderer&&e.controls&&e.scene))throw new Error("Invalid bimViewer!");this.viewer=e,this.inputManager=t,this.scene=e.scene,this.renderer=e.renderer,this.raycaster.layers.set(12)}get canvas(){var e;return null==(e=this.viewer.renderer)?void 0:e.domElement}get isActive(){return!!this.active}get camera(){return this.viewer.camera}get controls(){return this.viewer.controls}setGlobalClippingEnabled(e){if(!this.clipPlanes)return;let t=e?this.clipPlanes:[];this.renderer.localClippingEnabled=e,this.renderer.clippingPlanes=t}setObjectClippingEnabled(e){var t,n;if(!this.clipPlanes||null==(t=this.clippingObjetIds)||!t.length)return;this.renderer.localClippingEnabled=e;let i=e?this.clipPlanes:[];null==(n=this.clippingObjetIds)||n.forEach((e=>{let t=this.scene.getObjectById(e);t&&t.traverse((e=>{e.material&&(Array.isArray(e.material)?e.material.forEach((e=>{e.clippingPlanes=i,e.clipIntersection=!1})):e.material&&(e.material.clippingPlanes=i,e.material.clipIntersection=!1))}))}))}clearClippingObjectIds(){this.setObjectClippingEnabled(!1),this.clippingObjetIds=[]}setClippingEnabled(e){var t;null!=(t=this.clippingObjetIds)&&t.length?(this.setGlobalClippingEnabled(!1),this.setObjectClippingEnabled(e)):this.setGlobalClippingEnabled(e)}activate(){if(this.inputManager.addEventListener("pointerdown",this.mousedown),this.inputManager.addEventListener("pointermove",this.mousemove),this.inputManager.addEventListener("pointerup",this.mouseup),this.inputManager.addEventListener("keydown",this.keydown),this.sectionBox.isEmpty()){let e=this.viewer.getBBox();e&&this.sectionBox.copy(e)}this.active=!0}deactivate(){var e;this.inputManager.removeEventListener("pointerdown",this.mousedown),this.inputManager.removeEventListener("pointermove",this.mousemove),this.inputManager.removeEventListener("pointerup",this.mouseup),this.inputManager.removeEventListener("keydown",this.keydown),null==(e=this.selectedObject)||e.removeFromParent(),this.selectedObject=void 0,this.dragStarted=!1,this.active=!1,this.inputManager.setCursor("default"),this.enableDefaultControl(!0)}enableDefaultControl(e){this.controls.enableRotate=e,this.controls.azimuthRotateSpeed=Number(e),this.controls.polarRotateSpeed=Number(e)}getIntersections(e){if(!this.raycaster)return;this.updateRaycasterByMouse(e);let t=this.raycaster.intersectObjects(this.getIntersectObjects())||[];return t.find((e=>e.object&&e.object.parent instanceof Xc))||t[0]}updateRaycasterByMouse(e){if(!this.raycaster)return;let t=new be(e.x,e.y),n=un.screenPoint2NdcPoint(t,this.camera,this.canvas);this.raycaster.setFromCamera(n,this.camera)}destroy(){this.deactivate()}},Nve=new Ot,Bve=new hr,o2=class extends xt{constructor(e,t){super(),this.vertices=[],this.layers.enable(12),this.actionType=e,this.geometry=new Dt,this.vertices=t,this.geometry.setFromPoints(t),this.geometry.setIndex([0,1,2,0,2,3]),this.material=new ln({depthTest:!1,color:o2.normalPlaneColor,transparent:!0,opacity:.01,side:Er}),this.createIgnoreClipMaterials(this.material),this.geometry.computeVertexNormals(),this.edge=this.createEdge(t),this.add(this.edge)}createIgnoreClipMaterials(e){e.onBeforeCompile=function(e,t){e.fragmentShader=e.fragmentShader.replace("#include ","").replace("#include ",""),e.vertexShader=e.vertexShader.replace("#include ","").replace("#include ","")}}createEdge(e){let t=new Dt;t.setFromPoints(e),t.setIndex([0,1,1,2,2,3,3,0]);let n=new Gn({color:o2.normalLineColor});return this.createIgnoreClipMaterials(n),new ur(t,n)}update(e){this.geometry.setFromPoints(e),this.geometry.computeBoundingSphere(),this.geometry.computeVertexNormals(),this.edge.geometry.setFromPoints(e),this.vertices=e}rotatePlane(e,t){let n=this.getPlaneCenter();Bve.setFromAxisAngle(e,t),this.vertices=this.vertices.map((e=>e.sub(n).applyQuaternion(Bve).add(n))),this.update(this.vertices)}setDirection(e){let t=new hr;t.setFromUnitVectors($a,e);let n=this.getPlaneCenter();this.vertices=this.vertices.map((e=>e.sub(n).applyQuaternion(t).add(n))),this.update(this.vertices)}getPlaneNormal(){let[e,t,n]=this.vertices,i=new O;return Zr.getNormal(e,t,n,i),i}setActive(e){this.material.opacity=e?.1:.01}getPlaneCenter(){Nve.setFromPoints(this.vertices);let e=new O;return Nve.getCenter(e),e}},Li=o2;Li.normalPlaneColor=new ct(0,.855,.718),Li.activePlaneColor=new ct(1,1,0),Li.normalLineColor=16777215;var Uve=(e=>(e.X="X",e.Y="Y",e.Z="Z",e))(Uve||{}),l2=class extends ip{constructor(e,t){super(e,t),this.activeAxis="X",this.center=new O,this.axisInfoMap={X:{normal:new O(1,0,0)},Y:{normal:new O(0,1,0)},Z:{normal:new O(0,0,1)}},this.viewer.addEventListener("AfterRender",(()=>{var e;this.isActive&&(null==(e=this.gizmo)||e.adjustSize(this.camera))}))}activate(){super.activate(),this.sectionBox&&this.sectionBox.getCenter(this.center),this.setActiveAxis("X")}deactivate(){var e,t;super.deactivate(),null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.planeMesh=void 0,this.gizmo=void 0}resetSection(){var e,t;null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.setClippingEnabled(!1),this.planeMesh=void 0,this.gizmo=void 0,this.setActiveAxis("X")}setActiveAxis(e){this.activeAxis=e,this.initOrUpdateGizmo(),this.initOrUpdateSectionPlane(),this.initOrUpdateClipPlane(),this.setClippingEnabled(!0),this.viewer.enableRender()}setSectionVisible(e){this.gizmo&&this.planeMesh&&(this.gizmo.visible=e,this.planeMesh.visible=e),this.showSectionPlane=e,this.viewer.enableRender()}initOrUpdateClipPlane(){switch(this.activeAxis){case"X":this.clipPlane=new Gr(new O(-1,0,0),this.center.x);break;case"Y":this.clipPlane=new Gr(new O(0,-1,0),this.center.y);break;case"Z":this.clipPlane=new Gr(new O(0,0,-1),this.center.z)}this.clipPlane&&(this.clipPlanes=[this.clipPlane])}initOrUpdateSectionPlane(){var e;let t=new O;this.sectionBox.getSize(t);let n=t.length(),i=this.center,r=(new Ot).setFromCenterAndSize(i,new O(n,n,n)),{min:a,max:s}=r;switch(null==(e=this.planeMesh)||e.removeFromParent(),this.activeAxis){case"X":this.planeMesh=new Li("X",[new O(i.x,s.y,a.z),new O(i.x,s.y,s.z),new O(i.x,a.y,s.z),new O(i.x,a.y,a.z)]);break;case"Y":this.planeMesh=new Li("Y",[new O(s.x,i.y,a.z),new O(a.x,i.y,a.z),new O(a.x,i.y,s.z),new O(s.x,i.y,s.z)]);break;case"Z":this.planeMesh=new Li("Z",[new O(s.x,s.y,i.z),new O(a.x,s.y,i.z),new O(a.x,a.y,i.z),new O(s.x,a.y,i.z)])}this.planeMesh&&this.scene.add(this.planeMesh),this.viewer.enableRender()}initOrUpdateGizmo(){var e,t;null==(e=this.gizmo)||e.removeFromParent();let n=this.axisInfoMap[this.activeAxis].normal;this.gizmo=new Xc,this.gizmo.setDirection(n),this.sectionBox.getCenter(this.gizmo.position),null==(t=this.scene)||t.add(this.gizmo)}onDragStart(e){var t;if(this.selectedObject instanceof Li)return;se.info("[AxisPlaneSection] onDragStart:",e);let n=new O;this.sectionBox.getCenter(n),this.refrencePlane.setFromNormalAndCoplanarPoint(this.camera.getWorldDirection(this.refrencePlane.normal),n),null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,this.lastWorldPos)}onDragMove(e){var t,n,i;if(!this.lastWorldPos||!this.selectedObject||!this.clipPlane||!this.planeMesh||!this.gizmo||this.selectedObject&&this.selectedObject instanceof Li)return;let r=new O;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,r);let a=this.selectedObject.userData.actionType,s=(new O).subVectors(this.lastWorldPos,this.center).normalize(),o=(new O).subVectors(r,this.center).normalize(),l=(new O).subVectors(r,this.lastWorldPos).projectOnVector($a.clone().applyQuaternion(this.gizmo.quaternion)),h=s.angleTo(o),c=(new O).crossVectors(s,o),u=new O;this.sectionBox.getSize(u);let d,p=Math.max(u.x,u.y,u.z);switch(a){case"TranslateX":case"TranslateY":case"TranslateZ":d=(new O).addVectors(this.gizmo.position,l),this.sectionBox.clone().setFromCenterAndSize(this.center,new O(p,p,p)).containsPoint(d)&&(null==(n=this.gizmo)||n.position.add(l),null==(i=this.planeMesh)||i.position.add(l));break;case"RotateX":{let e=$a.clone().applyQuaternion(this.gizmo.quaternion);c.dot(e)<0&&(h=-h),this.gizmo.rotateX(h),this.planeMesh.rotatePlane(e,h)}break;case"RotateY":{let e=np.clone().applyQuaternion(this.gizmo.quaternion);c.dot(e)<0&&(h=-h),this.gizmo.rotateY(h),this.planeMesh.rotatePlane(e,h)}break;case"RotateZ":{let e=rp.clone().applyQuaternion(this.gizmo.quaternion);c.dot(e)<0&&(h=-h),this.gizmo.rotateZ(h),this.planeMesh.rotatePlane(e,h)}}this.clipPlane.setFromNormalAndCoplanarPoint(this.planeMesh.getPlaneNormal().negate(),this.gizmo.position),this.lastWorldPos=r}onDragEnd(e){this.selectedObject instanceof Li||se.info("[AxisPlaneSection] onDragEnd:",e)}getIntersectObjects(){return this.planeMesh&&this.gizmo?[this.planeMesh,this.gizmo]:[]}activateSelectedObject(e){this.selectedObject&&(this.selectedObject instanceof Li?this.selectedObject.setActive(e):this.selectedObject.parent instanceof Xc&&this.selectedObject.parent.setActive(e,this.selectedObject))}},Fvt=new O(1,0,0),Nvt=new O(0,1,0),Bvt=new O(0,0,1),c2=class extends ip{constructor(e,t){super(e,t),this.sectionRange={}}activate(){super.activate();let e=this.viewer.getBBox();if(e){let{min:t,max:n}=e;this.sectionRange={x:[t.x,n.x],y:[t.y,n.y],z:[t.z,n.z]}}this.initOrUpdateClipPlane(),this.initOrUpdateVertices(),this.initOrUpdateSectionPlane(),this.setClippingEnabled(!0)}deactivate(){super.deactivate(),this.planesMesh&&this.scene.remove(...this.planesMesh),this.planesMesh=void 0}initOrUpdateVertices(){if(!this.sectionBox)return;let{min:e,max:t}=this.sectionBox;this.vertices=[new O(t.x,t.y,t.z),new O(e.x,t.y,t.z),new O(e.x,e.y,t.z),new O(t.x,e.y,t.z),new O(t.x,t.y,e.z),new O(e.x,t.y,e.z),new O(e.x,e.y,e.z),new O(t.x,e.y,e.z)]}initOrUpdateClipPlane(){let{min:e,max:t}=this.sectionBox;this.clipPlanes?(this.clipPlanes[0].constant=t.x,this.clipPlanes[1].constant=-e.x,this.clipPlanes[2].constant=t.y,this.clipPlanes[3].constant=-e.y,this.clipPlanes[4].constant=t.z,this.clipPlanes[5].constant=-e.z):this.clipPlanes=[new Gr(new O(-1,0,0),t.x),new Gr(new O(1,0,0),-e.x),new Gr(new O(0,-1,0),t.y),new Gr(new O(0,1,0),-e.y),new Gr(new O(0,0,-1),t.z),new Gr(new O(0,0,1),-e.z)]}initOrUpdateSectionPlane(){let e=this.vertices;if(e){if(this.planesMesh)this.planesMesh[0].update([e[4],e[0],e[3],e[7]]),this.planesMesh[1].update([e[1],e[5],e[6],e[2]]),this.planesMesh[2].update([e[4],e[5],e[1],e[0]]),this.planesMesh[3].update([e[6],e[7],e[3],e[2]]),this.planesMesh[4].update([e[0],e[1],e[2],e[3]]),this.planesMesh[5].update([e[5],e[4],e[7],e[6]]);else{let t=[new Li("Right",[e[4],e[0],e[3],e[7]]),new Li("Left",[e[1],e[5],e[6],e[2]]),new Li("Top",[e[4],e[5],e[1],e[0]]),new Li("Bottom",[e[6],e[7],e[3],e[2]]),new Li("Front",[e[0],e[1],e[2],e[3]]),new Li("Back",[e[5],e[4],e[7],e[6]])];this.planesMesh=t,this.scene.add(...t)}this.viewer.enableRender()}}activateSelectedObject(e){var t;null==(t=this.selectedObject)||t.setActive(e)}onDragStart(e){var t;this.selectedObject&&(se.info("[ObjectsBoxSection] onDragStart:",e),this.refrencePlane.setFromNormalAndCoplanarPoint(this.camera.getWorldDirection(this.refrencePlane.normal),this.selectedObject.getPlaneCenter()),null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,this.lastWorldPos))}onDragMove(e){var t;if(!this.lastWorldPos||!this.selectedObject)return;let n=new O;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,n);let i=this.selectedObject.actionType;switch(i){case"Top":case"Bottom":this.dragTranslateSectionPlane(Nvt,this.lastWorldPos,n,i);break;case"Left":case"Right":this.dragTranslateSectionPlane(Fvt,this.lastWorldPos,n,i);break;case"Front":case"Back":this.dragTranslateSectionPlane(Bvt,this.lastWorldPos,n,i)}this.lastWorldPos=n}onDragEnd(e){se.info("[ObjectsBoxSection] onDragEnd:",e)}dragTranslateSectionPlane(e,t,n,i){let r,{min:a,max:s}=this.sectionBox,o=n.clone().sub(t).projectOnVector(e);switch(i){case"Top":r=s.y+o.y,this.isInRange(r,this.sectionRange.y)&&(s.y=r);break;case"Bottom":r=a.y+o.y,this.isInRange(r,this.sectionRange.y)&&(a.y=r);break;case"Left":r=a.x+o.x,this.isInRange(r,this.sectionRange.x)&&(a.x=r);break;case"Right":r=s.x+o.x,this.isInRange(r,this.sectionRange.x)&&(s.x=r);break;case"Front":r=s.z+o.z,this.isInRange(r,this.sectionRange.z)&&(s.z=r);break;case"Back":r=a.z+o.z,this.isInRange(r,this.sectionRange.z)&&(a.z=r)}this.initOrUpdateVertices(),this.initOrUpdateSectionPlane(),this.initOrUpdateClipPlane(),this.viewer.enableRender()}isInRange(e,t){return e>t[0]&&et.visible=e)),this.showSectionPlane=e,this.viewer.enableRender()}},u2=class extends ip{constructor(e,t){super(e,t),this.mousedown=e=>{var t;if(0===e.button){if(!this.faceInfo){let n=this.pickFace(e);if(n&&n.face){let e=n.face.normal,i=new Ln;e.applyNormalMatrix(i.getNormalMatrix(n.object.matrixWorld)),this.faceInfo={position:n.point,normal:e.normalize()},this.setSection(),null==(t=this.tooltip)||t.hide()}return}if(Dn.isMobile){let t=this.getIntersections(e);t&&(this.inputManager.setCursor("grab"),this.selectedObject=t.object,this.activateSelectedObject(!0),this.enableDefaultControl(!1),this.viewer.enableRender())}this.camera&&this.selectedObject&&(this.mouseDown=!0)}},this.mousemove=e=>{var t,n,i;if(this.faceInfo){if(this.dragStarted)this.updateRaycasterByMouse(e),this.onDragMove(e);else{this.activateSelectedObject(!1);let t=this.getIntersections(e);t?(this.selectedObject=t.object,this.activateSelectedObject(!0),this.mouseDown&&(null==(i=this.selectedObject)?void 0:i.parent)instanceof Xc&&(this.dragStarted||(this.dragStarted=!0,this.enableDefaultControl(!1),this.onDragStart(e)))):this.selectedObject=void 0}this.viewer.enableRender()}else this.pickFace(e)?null==(t=this.tooltip)||t.show():null==(n=this.tooltip)||n.hide()},this.center=new O,this.viewer.addEventListener("AfterRender",(()=>{var e;this.isActive&&(null==(e=this.gizmo)||e.adjustSize(this.camera))}))}activate(){super.activate(),this.sectionBox.getCenter(this.center),this.tooltip=new Yl("pick-section-plane",eh("Tooltip.section"),{parentNode:this.viewer.widgetContainer,followPointer:!0})}deactivate(){var e,t,n;super.deactivate(),null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.planeMesh=void 0,this.gizmo=void 0,this.faceInfo=void 0,null==(n=this.tooltip)||n.destroy(),this.tooltip=void 0}setSection(){this.initOrUpdateGizmo(),this.initOrUpdateSectionPlane(),this.initOrUpdateClipPlane(),this.setClippingEnabled(!0),this.viewer.enableRender()}resetSection(){var e,t,n;null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.setClippingEnabled(!1),this.planeMesh=void 0,this.gizmo=void 0,this.faceInfo=void 0,null==(n=this.tooltip)||n.show(),this.viewer.enableRender()}setSectionVisible(e){this.gizmo&&this.planeMesh&&(this.gizmo.visible=e,this.planeMesh.visible=e),this.showSectionPlane=e,this.viewer.enableRender()}initOrUpdateClipPlane(){if(!this.faceInfo)return;let{normal:e,position:t}=this.faceInfo;this.clipPlane=(new Gr).setFromNormalAndCoplanarPoint(e.clone().negate(),t),this.clipPlane&&(this.clipPlanes=[this.clipPlane])}initOrUpdateSectionPlane(){var e;if(!this.faceInfo)return;let{normal:t,position:n}=this.faceInfo,i=new O;this.sectionBox.getSize(i);let r=i.length(),a=n,s=(new Ot).setFromCenterAndSize(a,new O(r,r,r)),{min:o,max:l}=s;null==(e=this.planeMesh)||e.removeFromParent(),this.planeMesh=new Li("Plane",[new O(a.x,l.y,o.z),new O(a.x,l.y,l.z),new O(a.x,o.y,l.z),new O(a.x,o.y,o.z)]),this.planeMesh.setDirection(t),this.planeMesh&&this.scene.add(this.planeMesh),this.viewer.enableRender()}initOrUpdateGizmo(){var e,t;if(!this.faceInfo)return;null==(e=this.gizmo)||e.removeFromParent();let{normal:n,position:i}=this.faceInfo;this.gizmo=new Xc,this.gizmo.setDirection(n),this.gizmo.position.copy(i),null==(t=this.scene)||t.add(this.gizmo)}onDragStart(e){var t;if(!this.faceInfo||this.selectedObject instanceof Li)return;se.info("[PickPlaneSection] onDragStart:",e);let{position:n}=this.faceInfo;this.refrencePlane.setFromNormalAndCoplanarPoint(this.camera.getWorldDirection(this.refrencePlane.normal),n),null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,this.lastWorldPos)}onDragMove(e){var t,n,i;if(!this.lastWorldPos||!this.selectedObject||!this.clipPlane||!this.planeMesh||!this.gizmo||!this.faceInfo||this.selectedObject&&this.selectedObject instanceof Li)return;let r=new O;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,r);let a=this.selectedObject.userData.actionType,{position:s}=this.faceInfo,o=(new O).subVectors(this.lastWorldPos,s).normalize(),l=(new O).subVectors(r,s).normalize(),h=(new O).subVectors(r,this.lastWorldPos).projectOnVector($a.clone().applyQuaternion(this.gizmo.quaternion)),c=o.angleTo(l),u=(new O).crossVectors(o,l),d=new O;this.sectionBox.getSize(d);let p,f=Math.max(d.x,d.y,d.z);switch(a){case"TranslateX":case"TranslateY":case"TranslateZ":p=(new O).addVectors(this.gizmo.position,h),this.sectionBox.clone().setFromCenterAndSize(this.center,new O(f,f,f)).containsPoint(p)&&(null==(n=this.gizmo)||n.position.add(h),null==(i=this.planeMesh)||i.position.add(h));break;case"RotateX":{let e=$a.clone().applyQuaternion(this.gizmo.quaternion);u.dot(e)<0&&(c=-c),this.gizmo.rotateX(c),this.planeMesh.rotatePlane(e,c)}break;case"RotateY":{let e=np.clone().applyQuaternion(this.gizmo.quaternion);u.dot(e)<0&&(c=-c),this.gizmo.rotateY(c),this.planeMesh.rotatePlane(e,c)}break;case"RotateZ":{let e=rp.clone().applyQuaternion(this.gizmo.quaternion);u.dot(e)<0&&(c=-c),this.gizmo.rotateZ(c),this.planeMesh.rotatePlane(e,c)}}this.clipPlane.setFromNormalAndCoplanarPoint(this.planeMesh.getPlaneNormal().negate(),this.gizmo.position),this.lastWorldPos=r}onDragEnd(e){this.selectedObject instanceof Li||se.info("[PickPlaneSection] onDragEnd:",e)}getIntersectObjects(){return this.planeMesh&&this.gizmo?[this.planeMesh,this.gizmo]:[]}activateSelectedObject(e){this.selectedObject&&(this.selectedObject instanceof Li?this.selectedObject.setActive(e):this.selectedObject.parent instanceof Xc&&this.selectedObject.parent.setActive(e,this.selectedObject))}pickFace(e){if(!this.raycaster)return;let t=new be(e.x,e.y),n=un.screenPoint2NdcPoint(t,this.camera,this.canvas);this.raycaster.setFromCamera(n,this.camera);let i=[];return this.viewer.loadedModels.forEach((e=>{let t=e.object;t&&t.visible&&i.push(t)})),(this.raycaster.intersectObjects(this.viewer.getRaycastableObjectsByMouse(e))||[]).find((e=>{let t=e.object;return t.visible&&t instanceof xt}))}},h2=class extends dr{constructor(e){super(e,{id:"SectionPlugin"}),this.sections={},this.viewer=e;let t=e.getInputManager();t&&(this.sections.ObjectsBoxSection=new c2(e,t),this.sections.AxisPlaneSection=new l2(e,t),this.sections.PickPlaneSection=new u2(e,t))}get raycaster(){return this.viewer.getRaycaster()}activate(e){this.activeSectionType&&this.deactivate(),this.activeSectionType=e,this.sections[e].activate()}deactivate(){let e=this.activeSectionType;e&&this.sections[e].deactivate(),this.activeSectionType=void 0}resetSection(){}isActive(){let e=this.activeSectionType;return e?this.sections[e].isActive:!!this.getActiveSectionType()}getActiveSectionType(){return this.activeSectionType}getActiveSection(){if(this.activeSectionType)return this.sections[this.activeSectionType]}setClippingObjectIds(e){for(let t in this.sections)this.setClippingObjectIdsForType(t,e)}setClippingObjectIdsForType(e,t){this.sections[e].clearClippingObjectIds(),null!=t&&t.length&&(this.sections[e].clippingObjetIds=t,this.sections[e].setClippingEnabled(!0))}destroy(){super.destroy(),this.deactivate(),this.activeSectionType=void 0}},Hve=new O,Vve=new gr,zve=class extends Zf{constructor(e,t){var n;super(e),this.name="BimViewer",this.timer=Date.now(),this.enableSelection=!0,this.selectedObject=void 0,this.loadedModels=[],this.composerRenderEnabled=!0,this.composerEnabled=!1,this.savedMaterialsForOpacity=[],this.raf=new qf,this.clock=new po,this.renderEnabled=!0,this.enableModelLevelFrustumCulling=!0,this.isFrustumInsectChecking=!1,this.settings=Gv,this.twoDModelCount=0,this.enableFastOperation=!0,this.edgesVisible=!0,this.distanceCullingFactor=150,this.operationTimeoutMs=500,this.bbox=new Ot,this.onResize=()=>{this.viewerContainer&&this.viewerContainer.parentElement&&this.resize(this.viewerContainer.parentElement.clientWidth,this.viewerContainer.parentElement.clientHeight)},this.onKeyDown=e=>{let t=this.camera,n=this.controls;if(!t||!n)return;let i=this.settings.keyboard.sensitivity||3,r=n.getPosition(new O),a=n.getTarget(new O),s=a.clone();if("ArrowLeft"===e.code||"ArrowRight"===e.code){let t=Math.PI*i/180;"ArrowLeft"===e.code&&(t=-t),s.x=(a.x-r.x)*Math.cos(t)-(a.z-r.z)*Math.sin(t)+r.x,s.z=(a.z-r.z)*Math.cos(t)+(a.x-r.x)*Math.sin(t)+r.z,n.setLookAt(r.x,r.y,r.z,s.x,s.y,s.z,!0)}else if("ArrowUp"===e.code||"ArrowDown"===e.code){let t=Math.PI*i/180,o=new O(a.x-r.x,a.y-r.y,a.z-r.z).length(),l=a.y-r.y;"ArrowDown"===e.code&&(t=-t);let h=Math.asin(l/o)+t;if(h<-Math.PI/2||h>Math.PI/2)return;let c=Math.sin(h)*o;s.y=a.y+(c-l),n.setLookAt(r.x,r.y,r.z,s.x,s.y,s.z,!0)}else if("KeyW"===e.code){let e=.01*i,s=r.distanceTo(a);if(s<10*t.near){let e=n.getTarget(new O).lerp(r,-t.near/s);n.setTarget(e.x,e.y,e.z)}r.lerp(a,e),n.setLookAt(r.x,r.y,r.z,a.x,a.y,a.z)}else if("KeyS"===e.code){let e=.01*i;r.lerp(a,-e),n.setLookAt(r.x,r.y,r.z,a.x,a.y,a.z,!1)}else"KeyF"===e.code?this.flyToSelectedObject():"KeyY"===e.code?this.flyTo(r,a.clone().setY(r.y)):"KeyR"===e.code&&this.flyToRandomObject();this.enableRender()},this.enableRender=(e=1e3)=>{this.renderEnabled=!0,this.raf&&(this.timeoutSymbol&&this.raf.clearTimeout(this.timeoutSymbol),this.timeoutSymbol=this.raf.setTimeout((()=>{this.renderEnabled=!1,this.composerRenderEnabled=!0}),e))},this.applyOptionsAndAddToScene=(e,t,n,i)=>ft(this,null,(function*(){let r=Mt.getUpdateProgressFunc(i),a=Mt.getUpdateSubProgressFunc(70,90,i);r(0),se.info(`[Viewer] '${e}' is loaded in ${(Date.now()-this.timer)/1e3}s, adding to scene...`),this.timer=Date.now();let s,o=n.src&&n.src.toLowerCase();if(o&&o.endsWith("dxf")&&this.twoDModelCount++,n.matrix&&16===n.matrix.length){let e=new Qe;e.elements=n.matrix,t.applyMatrix4(e)}if(t.matrixAutoUpdate=!1,t.updateMatrix(),t.traverse((e=>{e.matrixAutoUpdate&&(e.matrixAutoUpdate=!1,e.updateMatrix())})),n.merge&&this.merge(t),r(50),n.merge){let e=Date.now();Yf.createMeshBvhAsync([t],{saveOriginalIndex:!0}),se.info(`[Viewer] Creates mesh bvh cost ${(Date.now()-e)/1e3}s`)}r(60),t.traverse((e=>{e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0,e.userData.surfaceArea=this.calculateMeshSurfaceArea(e)),e.geometry&&e.layers.enableAll(),e instanceof Ws&&(e.visible=!1)})),r(70),n.edges&&(s=yield zn.createOutlines(t,void 0,a)),r(90);let l={modelId:this.getUniqueModelId(n.modelId||n.src),object:t,edges:s};this.addModel(l),r(100)})),this.onAnchorPointerDown=e=>{var t,n;null==(t=this.controls)||!t.enableRotate||!this.renderer||null!=(n=this.sectionPlugin)&&n.isActive()||this.setOrbitPoint(e)},this.onAnchorPointerUp=()=>{this.anchor&&(this.anchor.className="anchor"),!this.viewerContainer||!this.camera||this.controls},this.onOperation=()=>{let e=this.renderer;if(!this.enableFastOperation||!e)return;let t=e=>{let t=this.renderer;void 0!==t.distanceCullingFactor&&(t.distanceCullingFactor=e)},n=e=>{this.loadedModels.forEach((t=>{t.edges&&t.edges.forEach((t=>t.visible=e))})),this.edgesVisible=e},i=e=>{let t=this.directionalLight;t&&(t.castShadow=e)};t(this.distanceCullingFactor),this.edgesVisible&&n(!1),i(!1),this.operationTimeout&&clearTimeout(this.operationTimeout),this.operationTimeout=setTimeout((()=>{this.operationTimeout=void 0,i(!0),n(!0),t(0),this.enableRender()}),this.operationTimeoutMs)},this.viewerCfg=wr(wr({},C0e),e),se.info("[Viewer]","viewerCfg:",this.viewerCfg),this.settings=Gv,this.cameraCfg=t,this.cameraCfg&&this.cameraCfg.near&&(this.settings.camera.near=this.cameraCfg.near),this.cameraCfg&&this.cameraCfg.far&&(this.settings.camera.far=this.cameraCfg.far),this.increaseJobCount(),this.init(),this.animate(),this.renderer&&(null==(n=this.viewerContainer)||n.append(this.renderer.domElement)),this.decreaseJobCount(),se.info(`[Viewer] Initialized in ${(Date.now()-this.timer)/1e3}s`)}init(){let e=this.viewerCfg;this.initThree(),Dn.isBrowser&&!e.context&&this.initDom(),this.initEvents(),this.initControls()}initThree(){this.initScene(),this.initRenderer(),this.initCamera(),this.initLights()}initDom(){let e=this.viewerCfg;this.initSpinner(),this.initCSS2DRenderer(),this.initOthers(),!0===e.enableAxisGizmo&&se.warn("[Viewer] enableAxisGizmo is deprecated, use AxisGizmoPlugin instead!"),!0===e.enableStats&&se.warn("[Viewer] enableStats is deprecated, use StatsPlugin instead!"),e.enableToolbar&&se.warn("[Viewer] enableToolbar is deprecated, use ToolbarPlugin instead!"),e.enableBottomBar&&se.warn("[Viewer] enableBottomBar is deprecated, use BottomBarPlugin instead!"),e.enableNavCube&&se.warn("[Viewer] enableNavCube is deprecated, use NavCubePlugin instead!"),e.enableProgressBar&&(this.loadingProgressBar=this.initLoadingProgressBar()),e.enableContextMenu&&se.warn("[Viewer] enableContextMenu is deprecated, use ContextMenuPlugin instead!"),null!=e.enableSelection&&(this.enableSelection=e.enableSelection)}initScene(){this.scene=new _i,this.scene.matrixAutoUpdate=!1}initRenderer(){this.renderer=new Ms({antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),this.renderer.outputColorSpace=tn,this.renderer.toneMappingExposure=1,this.renderer.useLegacyLights=!1,this.renderer.setClearColor(11119017,1),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=Ev,this.renderer.shadowMap.autoUpdate=!1,Mt.printGpuInfo(this.renderer.getContext()),this.pmremGenerator=new jh(this.renderer),this.pmremGenerator.compileEquirectangularShader(),this.enableOverlayRenderer&&(this.overlayRender=new Hn(this)),this.setEnvironmentFromDataArray()}initCSS2DRenderer(){var e;let t=new Nu;t.setSize(this.width,this.height),t.domElement.style.height="0",t.domElement.style.width="0",t.domElement.style.position="absolute",t.domElement.style.top="0",t.domElement.style.left="0",t.domElement.style.overflow="visible",t.domElement.classList.add("css2d-renderer"),null==(e=this.viewerContainer)||e.appendChild(t.domElement),this.css2dRenderer=t}initCamera(){this.scene&&(this.perspectiveCamera=new cr(45,this.width/this.height,this.settings.camera.near,this.settings.camera.far),this.perspectiveCamera.position.set(0,100,0),this.scene.add(this.perspectiveCamera),this.camera=this.perspectiveCamera)}initControls(e=!1){if(!this.renderer)return;Dn.printDeviceInfo();let t,n=e?this.orthoCamera:this.perspectiveCamera;n&&this.inputManager&&((!this.perspectiveCameraControls||!this.orthoCameraConrols)&&(t=new ba(n,this.inputManager),t.dollySpeed=.3,t.dollyToCursor=!0,t.infinityDolly=!0,t.enabled=!0,t.keyTruckSpeed=10,t.restThreshold=0,t.smoothTime=.05,t.keys={left:"KeyD",up:"KeyE",right:"KeyA",bottom:"KeyQ"},t.listenToKeyEvents(),t.update(0)),t&&(e?(this.orthoCameraConrols=t,t.minZoom=3):(this.perspectiveCameraControls=t,this.bbox&&(t.minDistance=.1,t.maxDistance=10*this.bbox.getSize(new O).length())),this.controls=t,this.enableFastOperation&&t.addEventListener("control",this.onOperation)))}initRotateToCursor(){this.anchor=this.createAnchor()}initLights(){if(!this.scene)return;let e=16777215,t=new js(e,1.5);t.name="sun",t.castShadow=!0,t.position.set(-2,2,4),t.shadow.autoUpdate=!1,t.shadow.mapSize.width=1024,t.shadow.mapSize.height=1024,this.directionalLight=t,this.scene.add(t),this.scene.add(t.target),this.directionalLightHelper=new kb(this.directionalLight),this.directionalLightHelper.visible=!1,this.scene.add(this.directionalLightHelper),this.shadowCameraHelper=new Fb(this.directionalLight.shadow.camera),this.shadowCameraHelper.visible=!1,this.scene.add(this.shadowCameraHelper),this.ambientLight=new Pl(e),this.hemisphereLight=new Du(e,14540253,.2),this.hemisphereLight.position.set(0,300,0),this.scene.add(this.ambientLight),this.scene.add(this.hemisphereLight)}initEvents(){if(!this.renderer||!this.viewerContainer)return;let e=new Jo(this.viewerContainer);this.inputManager=e;let t=!1,n=!1,i=0,r=0,a=0,s=e=>-1!==r&&-1!==a&&Math.abs(e.x-r)<5&&Math.abs(e.y-a)<5;e.addEventListener("pointerdown",(e=>{n=!1,t=!0,0===e.button&&this.onAnchorPointerDown(e)})),e.addEventListener("pointermove",(e=>{t&&(n=!s(e))})),e.addEventListener("pointerup",(e=>{if(t=!1,n)return n=!1,void this.onAnchorPointerUp();if(0===e.button)if((e=>{let t=e.timestamp-i;return!!(0===e.button&&t<300&&s(e))})(e)){let t=this.getClickedObject(e);t?this.flyToObject(t):this.viewFitAll(),i=0,r=-1,a=-1}else i=e.timestamp,r=e.x,a=e.y,this.handleMouseClick(e);else e.button;this.onAnchorPointerUp()})),e.addEventListener("keydown",(e=>{this.onKeyDown(e)})),this.initRotateToCursor(),this.raycaster=new ia}initOthers(){!this.scene||!this.renderer||!this.camera||(this.renderer.domElement.style.outlineWidth="0")}initLoadingProgressBar(){return new Gf(this.widgetContainer)}sycnCameraAndControls(e){let t=e?this.orthoCamera:this.perspectiveCamera,n=e?this.perspectiveCameraControls:this.orthoCameraConrols,i=e?this.orthoCameraConrols:this.perspectiveCameraControls,r=new O;n.getPosition(r),i.setPosition(r.x,r.y,r.z);let a=n.getTarget(new O);if(i.setTarget(a.x,a.y,a.z),e){let e=t;e.zoom=10,e.updateProjectionMatrix()}}setToOrthographicCamera(e=!1){var t;if(!this.scene||!this.controls)return;let n=this.perspectiveCamera,i=this.perspectiveCameraControls,r=this.orthoCamera,a=this.orthoCameraConrols;e?(r||(r=new Ur(-this.width/2,this.width/2,this.height/2,-this.height/2,this.settings.camera.near,this.settings.camera.far),r.position.set(0,100,0),r.zoom=10,r.updateProjectionMatrix(),this.scene.add(r),this.orthoCamera=r,this.frustumSize=this.width),a||(this.initControls(!0),a=this.orthoCameraConrols),this.camera=r,this.controls=a):(this.camera=n,this.controls=i),this.sycnCameraAndControls(e),this.resize(this.width,this.height),null==(t=this.composer)||t.passes.forEach((e=>{e.camera&&(e.camera=this.camera)})),this.dispatchEvent("CameraChanged")}animate(){var e,t,n;if(this.minFrameInterval>0&&Date.now()-this.lastFrameExecuteTime!!e.tilesRenderer));0!==e.length&&(this.camera.updateMatrixWorld(),e.forEach((e=>{e.tilesRenderer.update()})))}frustumCullingByModelBBox(){if(!this.enableModelLevelFrustumCulling)return;let e=this.camera,t=this.scene;if(!e||!t)return;e.updateMatrixWorld();let n=new Qe;n.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse);let i=new ya;i.setFromProjectionMatrix(n);let r=(e,t)=>{if(e&&t&&(void 0===e.userData._visible&&(e.userData._visible=!0,Object.defineProperties(e,{visible:{set:t=>{e.userData._visible=t,this.isFrustumInsectChecking||(e.userData.userConfigVisibility=!0)},get:()=>e.userData._visible}})),void 0===e.userData.userConfigVisibility)){let n=i.intersectsBox(t);e.visible!==n&&(e.visible=n,se.debug(`[Viewer] frustumCullingByModelBBox() set model (id ${e.id})'s visible to:`,n))}};this.isFrustumInsectChecking=!0,this.loadedModels.forEach((e=>{if(e.tilesRenderer){let t=e.tilesRenderer.group;r(t,e.bbox)}else r(e.object,e.bbox)})),this.isFrustumInsectChecking=!1}destroy(){var e,t,n,i;null==(e=this.inputManager)||e.removeEventListener();let r=this.webcamPlane;this.scene&&r&&(this.scene.remove(r),r.geometry.dispose(),r.material.dispose(),this.webcamPlane=void 0),this.webcam=void 0,this.composer=void 0,this.renderPass=void 0,this.effectFxaaPass=void 0,this.saoPass=void 0,this.ssaoPass=void 0,this.outlinePass=void 0,this.ambientLight=void 0,this.directionalLight=void 0,this.hemisphereLight=void 0,this.directionalLightHelper&&(this.directionalLightHelper.dispose(),this.directionalLightHelper=void 0),this.controls&&(this.disposeRotateToCursor(),this.controls.dispose(),this.controls=void 0),this.perspectiveCameraControls&&(this.perspectiveCameraControls.dispose(),this.perspectiveCameraControls=void 0),this.shadowCameraHelper&&(this.shadowCameraHelper.dispose(),this.shadowCameraHelper=void 0),this.css2dRenderer&&(null==(t=this.viewerContainer)||t.removeChild(this.css2dRenderer.domElement),this.css2dRenderer=void 0),this.raycaster=void 0,this.selectedObject=void 0,this.savedMaterialsForOpacity=void 0,this.section=void 0,this.sectionType=void 0,this.loadedModels.forEach((e=>{e.tilesRenderer&&e.tilesRenderer.dispose()})),this.loadedModels=[],this.perspectiveCamera=void 0,this.perspectiveCameraControls=void 0,this.raf&&(this.timeoutSymbol&&this.raf.clearTimeout(this.timeoutSymbol),this.raf=void 0),null==(n=this.fontManager)||n.destroy(),this.fontManager=void 0,this.pmremGenerator&&(this.pmremGenerator.dispose(),this.pmremGenerator=void 0),null==(i=this.zoomToRectHelper)||i.destroy(),this.zoomToRectHelper=void 0,super.destroy()}loadLocalModel(e,t,n,i){return ft(this,null,(function*(){var r,a;this.timer=Date.now(),this.increaseJobCount();let s=t.modelId||t.src,o=this.translate("ProgressBar.Loading"),l=e=>{var t;null==(t=this.loadingProgressBar)||t.updateProgress(s,o,e),i&&i(new ProgressEvent("LoadProgress",{loaded:e,total:100}))},h=!1,c=(e,t,n)=>{var r;let a=100*e.loaded/e.total;a=a*(n-t)/100+t,a>n&&(h||(se.warn("[Progress] Invalid ProgressEvent:",e),h=!0),a=n),null==(r=this.loadingProgressBar)||r.updateProgress(s,o,a),i&&i(new ProgressEvent("LoadProgress",{loaded:a,total:100}))},u=e=>c(e,0,50),d=e=>c(e,50,99);null==(r=this.loadingProgressBar)||r.addProgressItem(s),l(0);try{let i=new Ya(n);this.fontManager&&i.setFont(this.fontManager);let r=yield i.loadLocalModel(e,t.src,u);if(r)return yield this.applyOptionsAndAddToScene(e,r,t,d),Promise.resolve()}catch(e){let i=`Error loading ${t.src}`;return se.error(i,e),Promise.reject(i)}finally{this.decreaseJobCount(),l(100),null==(a=this.loadingProgressBar)||a.delayRemoveProgressItem(s)}return Promise.reject()}))}loadModel(e,t){return ft(this,null,(function*(){var n,i;this.timer=Date.now(),this.increaseJobCount();let r=e.modelId||e.src,a=this.translate("ProgressBar.Loading"),s=e=>{var n;null==(n=this.loadingProgressBar)||n.updateProgress(r,a,e),t&&t(new ProgressEvent("LoadProgress",{loaded:e,total:100}))},o=!1,l=(e,n,i)=>{var s;let l=100*e.loaded/e.total;l=l*(i-n)/100+n,l>i&&(o||(se.warn("[Progress] Invalid ProgressEvent:",e),o=!0),l=i),null==(s=this.loadingProgressBar)||s.updateProgress(r,a,l),t&&t(new ProgressEvent("LoadProgress",{loaded:l,total:100}))},h=e=>l(e,0,50),c=e=>l(e,50,99);null==(n=this.loadingProgressBar)||n.addProgressItem(r),s(0);try{let t=new Ya;this.fontManager&&t.setFont(this.fontManager);let n=yield t.loadModel(e.src,e.fileFormat,h);if(n)return yield this.applyOptionsAndAddToScene(e.src,n,e,c),Promise.resolve()}catch(t){let i=`Error loading ${e.src}`;return se.error(i,t),Promise.reject(i)}finally{this.decreaseJobCount(),s(100),null==(i=this.loadingProgressBar)||i.delayRemoveProgressItem(r)}return Promise.reject()}))}load3dTiles(e){return ft(this,null,(function*(){var t;this.timer=Date.now(),this.increaseJobCount();let n=new w_(e.src),i=new Ot,r=yield new Promise(((t,r)=>{n.onLoadTileSet=()=>{n.getBounds(i)||(n.getBoundingSphere(Vve)?Vve.getBoundingBox(i):(se.warn(`[Viewer] Can't get the correct bounding box of 3dTiles '${e.src}'!`),r())),se.debug(i),n.onLoadTileSet=null;let a=n.group;se.debug(a),t(a)},n.onLoadModel=e=>{e.traverse((e=>{e.matrixAutoUpdate&&(e.matrixAutoUpdate=!1,e.updateMatrix()),e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0),e.geometry&&e.layers.enableAll()})),e.updateWorldMatrix(!1,!0),this.updateDirectionalLightShadow(),this.enableRender()},n.setCamera(this.camera),n.setResolutionFromRenderer(this.camera,this.renderer),n.update()}));if(r){let a=Date.now(),s={modelId:this.getUniqueModelId(e.modelId||e.src),object:r,bbox:i,tilesRenderer:n};if(this.loadedModels.push(s),e.matrix&&16===e.matrix.length){let t=new Qe;t.elements=e.matrix,r.applyMatrix4(t)}return r.matrixAutoUpdate=!1,r.updateMatrix(),r.updateMatrixWorld(!0),null==(t=this.scene)||t.add(r),i.applyMatrix4(r.matrix),this.computeBoundingBox(),this.tryAdjustDirectionalLight(),1===this.loadedModels.length&&(this.tryAdjustCameraNearAndFar(),this.goToHomeView()),se.info(`[Viewer] Added 3dTiles '${e.src}' to scene in ${(Date.now()-a)/1e3}s`),this.enableRender(),this.decreaseJobCount(),this.dispatchEvent("ModelLoaded"),Promise.resolve()}return this.decreaseJobCount(),this.dispatchEvent("ModelLoaded"),Promise.reject()}))}setFont(e){return ft(this,null,(function*(){let t=Date.now();this.fontManager||(this.fontManager=new cd),yield this.fontManager.loadFonts(e),se.info(`[Viewer] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}setDracoDecoderPath(e){Ya.setDracoDecoderPath(e)}addModel(e){if(!this.scene||!this.renderer)return;this.increaseJobCount();let t=(new Ot).setFromObject(e.object);e.bbox||(e.bbox=t),this.scene.add(e.object),this.loadedModels.push(e),this.computeBoundingBox(),this.tryAdjustDirectionalLight(),1===this.loadedModels.length&&(this.tryAdjustCameraNearAndFar(),this.goToHomeView()),se.info(`[Viewer] Added '${e.modelId}' to scene in ${(Date.now()-this.timer)/1e3}s`),this.renderer.shadowMap.needsUpdate=!0,this.enableRender(),this.dispatchEvent("ModelLoaded",{modelId:e.modelId,bbox:t}),this.decreaseJobCount()}calculateMeshSurfaceArea(e){let t=new Zr,n=[0,0,0],i=e.geometry,r=i.getAttribute("position"),a=i.getIndex(),s=a?a.count:r.count,o=0;for(let l=0;le.object.id)).forEach((s=>{if(e){this.savedMaterialsForOpacity&&this.savedMaterialsForOpacity.length>0&&zn.revertObjectOpacityById(r,s,this.savedMaterialsForOpacity);let e=zn.setObjectOpacityById(r,s,t,n,i);a.push(...e)}else this.savedMaterialsForOpacity&&zn.revertObjectOpacityById(r,s,this.savedMaterialsForOpacity)})),this.savedMaterialsForOpacity=e?a:[],this.enableRender()}hasTransparentObject(){return!!(this.savedMaterialsForOpacity&&this.savedMaterialsForOpacity.length>0)}showVertexNormals(e,t=.1){var n,i,r;e?(this.vertexNormalsHelpers||(this.vertexNormalsHelpers=new er),null==(n=this.scene)||n.traverseVisible((e=>{var n;if(e instanceof xt&&!["SKYBOX","GROUND_GRID","GROUND_GRASS","BIM_VIEWER_BOX_HELPER"].includes(e.name)){if(!e.geometry.attributes.normal)return;let i=new JP(e,t,16711680);null==(n=this.vertexNormalsHelpers)||n.add(i)}})),null==(i=this.scene)||i.add(this.vertexNormalsHelpers)):this.vertexNormalsHelpers&&(null==(r=this.scene)||r.remove(this.vertexNormalsHelpers),this.vertexNormalsHelpers=void 0)}resize(e,t){super.resize(e,t),t>0&&(this.composer&&this.composer.setSize(e,t),this.effectFxaaPass&&this.effectFxaaPass.uniforms.resolution.value.set(1/e,1/t),this.css2dRenderer&&(this.css2dRenderer.setSize(e,t),this.css2dRenderer.domElement.style.height="0",this.css2dRenderer.domElement.style.width="0")),this.enableRender()}getRaycaster(){return this.raycaster}getRaycastableObjectsByMouse(e){let t=[];if(!(this.raycaster&&this.camera&&this.scene&&e&&this.viewerContainer))return t;let n=new be(e.x,e.y),i=un.screenPoint2NdcPoint(n,this.camera,this.viewerContainer);return this.camera.updateMatrixWorld(),this.raycaster.setFromCamera(i,this.camera),t=this.getRaycastableObjects(),t}getRaycastableObjects(){let e=[];return this.loadedModels.forEach((t=>{let n=t.object;n&&n.visible&&e.push(n)})),e}getIntersections(e){let t=this.getRaycastableObjectsByMouse(e),n=this.raycaster&&this.raycaster.intersectObjects(t,!0)||[];return this.renderer&&this.renderer.clippingPlanes.length>0&&(n=n.filter((e=>{var t;return null==(t=this.renderer)?void 0:t.clippingPlanes.every((function(t){return t.distanceToPoint(e.point)>0}))}))),n}getAllIntersections(e){if(!(this.raycaster&&this.camera&&this.scene&&this.viewerContainer))return[];let t=new be(null==e?void 0:e.x,null==e?void 0:e.y),n=un.screenPoint2NdcPoint(t,this.camera,this.viewerContainer);this.raycaster.setFromCamera(n,this.camera);let i=this.scene.children,r=this.raycaster.intersectObjects(i,!0)||[];return this.renderer&&this.renderer.clippingPlanes.length>0&&(r=r.filter((e=>{var t;return null==(t=this.renderer)?void 0:t.clippingPlanes.every((function(t){return t.distanceToPoint(e.point)>0}))}))),r}getClickedObject(e){if(!this.raycaster)return;let t=Date.now();this.raycaster.layers.set(12);let n=this.getIntersections(e);se.debug(`[Viewer] getIntersections costs ${(Date.now()-t)/1e3}s`);let i=n.find((e=>{let t=e.object;return t.visible&&t instanceof xt}));return null==i?void 0:i.object}handleMouseClick(e){var t,n,i;if(null!=(t=this.measurePlugin)&&t.isActive()||null!=(n=this.sectionPlugin)&&n.isActive()||!this.raycaster)return;let r=Date.now();this.raycaster.layers.set(12);let a=this.getIntersections(e);se.debug(`[Viewer] getIntersections costs ${(Date.now()-r)/1e3}s`);let s,o,l=a.find((e=>{let t=e.object;return t.visible&&t instanceof xt})),h=l&&l.object||void 0;if(h)if(h instanceof Pi)s=l.instanceId,this.selectedObject&&this.selectedObject.id===h.id&&this.selectedObject.userData.instanceId===s&&(h=void 0);else if(Ar.isMergedMesh(h)){let e=l&&l.faceIndex||-1;e>=0?(o=Ar.getBatchIdByFaceIndex(h,e),this.selectedObject&&this.selectedObject.id===h.id&&this.selectedObject.userData.batchId===o&&(h=void 0)):h=void 0}else this.selectedObject&&this.selectedObject.id===h.id&&(h=void 0);if(a.length>0&&a[0].point){let e=null==(i=this.overlayRender)?void 0:i.getDrawablesByPosition(a[0].point,this.raycaster);e&&e.length>0?h=e[0]:this.enableSelection||(h=void 0)}this.selectedObject&&this.clearSelection(),h?this.selectObject(h,s,o):this.clearSelection()}selectObject(e,t,n,i=void 0){if(e instanceof Bi)return this.selectedObject=e,this.selectedObject.selected=!0,void this.enableRender();if(this.selectedObject){let t=this.selectedObject.userData;if(null!=t.instanceId&&t.originalMatrix&&t.clonedMesh){this.scene&&this.scene.remove(t.clonedMesh);let n=this.selectedObject;if(n.setMatrixAt(t.instanceId,t.originalMatrix),n.instanceMatrix.needsUpdate=!0,n.updateMatrix(),delete t.instanceId,delete t.originalMatrix,e===t.clonedMesh)return t.clonedMesh.geometry.dispose(),delete t.clonedMesh,this.selectedObject=void 0,void(this.outlinePass&&(this.outlinePass.selectedObjects=[]));t.clonedMesh.geometry.dispose(),delete t.clonedMesh}else if(null!=t.batchId&&t.clonedMesh){if(this.scene&&this.scene.remove(t.clonedMesh),delete t.batchId,e===t.clonedMesh)return t.clonedMesh.geometry.dispose(),delete t.clonedMesh,this.selectedObject=void 0,void(this.outlinePass&&(this.outlinePass.selectedObjects=[]));t.clonedMesh.geometry.dispose(),delete t.clonedMesh}else if(t.originalMaterial){if(this.selectedObject.material){let e=this.selectedObject.material;Array.isArray(e)?e.forEach((e=>e.dispose())):e instanceof vr&&e.dispose()}this.selectedObject.material=t.originalMaterial,delete t.originalMaterial}this.selectedObject=void 0,this.outlinePass&&(this.outlinePass.selectedObjects=[])}if(this.scene&&e){if(e instanceof Pi&&null!=t){let n=e,r=new Qe,a=new Qe;a.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n.getMatrixAt(t,r),this.selectedObject=e,this.outlinePass&&(this.outlinePass.selectedObjects=[e]);let s=es.clonedHighlightMaterials(e,{depthTest:i});if(s){let i=new xt(n.geometry.clone(),s);i.applyMatrix4(e.matrixWorld.multiply(r)),i.matrixWorldNeedsUpdate=!0,i.name="Cloned mesh for highlighting",i.layers.enableAll();let o=r.clone();o.multiplyMatrices(r,a),n.setMatrixAt(t,o),n.instanceMatrix.needsUpdate=!0,n.updateMatrix(),this.selectedObject.userData.instanceId=t,this.selectedObject.userData.originalMatrix=r,this.selectedObject.userData.clonedMesh=i,this.scene.add(i)}}else if(Ar.isMergedMesh(e)&&null!=n){let t=Ar.getBatchByBatchId(e,n),r=`[Viewer] Clicked on merged mesh(id: ${e.id}).`;r+=` batchId: ${n}, object name before merge: ${null==t?void 0:t.name}`,null!=t&&t.userData&&(r+=`, userData before merge: ${JSON.stringify(t.userData)}`),se.info(r);let a=es.clonedHighlightMaterials(e,{depthTest:i}),s=Ar.cloneGeometryForBatch(e,t);if(a&&s){let t=new xt(s,a);t.applyMatrix4(e.matrixWorld),t.matrixWorldNeedsUpdate=!0,t.name="Cloned mesh for highlighting",t.layers.enableAll(),this.selectedObject=e,this.selectedObject.userData.batchId=n,this.selectedObject.userData.clonedMesh=t,this.scene.add(t)}}else{let t=es.clonedHighlightMaterials(e,{depthTest:i});t&&(this.selectedObject=e,this.selectedObject.userData.originalMaterial=this.selectedObject.material,this.selectedObject.material=t,this.outlinePass&&(this.outlinePass.selectedObjects=[e]))}this.enableRender()}else this.enableRender()}clearSelection(){this.selectedObject&&this.selectedObject instanceof Bi?this.selectedObject.selected=!1:this.selectObject(),this.selectedObject=void 0}getBBox(){return this.bbox}enableModelEdges(e,t){return ft(this,null,(function*(){let n=Mt.getUpdateProgressFunc(t);n(0),this.increaseJobCount();let i=this.loadedModels.length;for(let r=0;rt.visible=e))}this.decreaseJobCount(),n(100),this.enableRender()}))}flyToObjects(e){if(!e||0===e.length||!this.camera)return;let t=new Ot;e.forEach((e=>{let n=ks.getBoundingBox(e);t.union(n)}));let n=new gr;t.getBoundingSphere(n),this.controls.fitToSphere(n,!0)}flyToObject(e){this.flyToObjects([e])}flyToSelectedObject(){if(!this.selectedObject)return;let e=this.selectedObject;(e instanceof Pi&&e.userData.clonedMesh||Ar.isMergedMesh(e)&&e.userData.clonedMesh)&&(e=e.userData.clonedMesh),this.flyToObject(e)}flyToRandomObject(){var e,t,n;let i=this.loadedModels.map((e=>e.object.id)),r=i.length;if(r<=0)return;let a=i[Math.floor(Math.random()*r)];if(!(null==(e=this.scene)?void 0:e.getObjectById(a)))return;let s=[];if(null==(t=this.scene)||t.traverseVisible((e=>{(e instanceof xt||e instanceof ur)&&!["SKYBOX","GROUND_GRID","GROUND_GRASS","BIM_VIEWER_BOX_HELPER"].includes(e.name)&&s.push(e.id)})),s.length<1)return;let o=Math.floor(Math.random()*s.length),l=null==(n=this.scene)?void 0:n.getObjectById(s[o]);l&&(se.info(`[Viewer] Flying to random object: ${l.name}, type: ${l.type}`),this.selectObject(l,void 0,void 0,!1),this.flyToObject(l))}flyTo(e,t){let n=this.camera,i=this.controls;if(!n||!i)return;if(e.equals(t))return void se.error("[Viewer] camera position and lookAt cannot be the same!");if(!Mt.isVectorValid(e)||!Mt.isVectorValid(t))return void se.error("[Viewer] invalid position or lookAt!");let r=e.distanceTo(t);rn.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*n.far),se.warn("[Viewer] camera could be too far to see the object!")),i.setLookAt(e.x,e.y,e.z,t.x,t.y,t.z,!0),i.setFocalOffset(0,0,0,!0)}viewFitAll(){if(!this.scene||!this.camera||!this.controls)return;let e=ks.getVisibleObjectBoundingBox(this.scene),t=new gr;e.getBoundingSphere(t),this.controls.fitToSphere(t,!0)}goToHomeView(){if(!this.scene)return;let e=this.camera,t=this.cameraCfg,n=t&&Mt.arrayToVector3(t.eye),i=t&&Mt.arrayToVector3(t.look);if(n&&i){let e=this.controls;e.setLookAt(n.x,n.y,n.z,i.x,i.y,i.z,!0),e.setFocalOffset(0,0,0,!0)}else{let t=new O,n=new O,i=new O(-1,-.5,-1);this.bbox.getCenter(n),t.subVectors(n,i);let r=new gr;this.bbox.getBoundingSphere(r);let a=this.controls;if(a.setLookAt(t.x,t.y,t.z,n.x,n.y,n.z,!0),a.fitToSphere(r,!0),a.getPosition(t),(!this.cameraCfg||this.cameraCfg&&(!this.cameraCfg.eye||!this.cameraCfg.look))&&(this.cameraCfg={eye:t.toArray(),look:n.toArray()}),e instanceof Ur){let t=this.bbox,n=t.max.x-t.min.x,i=t.max.z-t.min.z,r=e.right-e.left,a=e.top-e.bottom;e.zoom=Math.max(r,a)/Math.max(n,i),e.zoom/=2,e.updateProjectionMatrix()}t.equals(n)||this.flyTo(t,n)}}zoomToBBox(e){if(!this.controls)return;let t=new gr;e.getBoundingSphere(t),this.controls.fitToSphere(t,!0)}tryAdjustCameraNearAndFar(){let e=this.camera;if(!this.scene||!e)return;let t=this.bbox,n=e.near,i=e.far,r=t.max.x-t.min.x,a=t.max.y-t.min.y,s=t.max.z-t.min.z,o=Math.max(r,a,s),l=o/5,h=5*o;if(n>l||iMt.numberToString(e);se.info(`[Viewer] BBox's longest side is: ${t(o)}`),n>l&&(se.warn(`[Viewer] camera.near(${t(n)}) shouldn't bigger than ${t(l)}, will change it!`),e.near=l),i"SectionPlugin"===e.id))}activateSection(e="ObjectsBoxSection"){var t,n;!this.inputManager||null!=(t=this.sectionPlugin)&&t.isActive()?this.sectionPlugin||se.warn("[Viewer] SectionPlugin doesn't seem to be installed!"):(this.sectionType=e,this.clearSelection(),null==(n=this.sectionPlugin)||n.activate(e),this.enableRender())}deactivateSection(){var e;null==(e=this.sectionPlugin)||e.deactivate(),this.enableRender()}getActiveSection(){var e;return null==(e=this.sectionPlugin)?void 0:e.getActiveSection()}get measurePlugin(){return this.plugins.find((e=>"MeasurementPlugin"===e.id))}getMeasurements(){let e=this.measurePlugin;return e?e.getData():[]}activateMeasurement(e){let t=this.measurePlugin;t?(t.activate(e),this.clearSelection()):se.warn("[Viewer] MeasurementPlugin doesn't seem to be installed!")}deactivateMeasurement(){var e;null==(e=this.measurePlugin)||e.deactivate()}setMeasurementVisibility(e,t){let n=this.measurePlugin;return!!n&&n.setVisibilityById(e,t)}clearMeasurements(){var e;null==(e=this.measurePlugin)||e.clear()}zoomToRect(){this.zoomToRectHelper||(this.zoomToRectHelper=new Dy(this)),this.zoomToRectHelper.activate()}deactivateZoomRect(){var e;null==(e=this.zoomToRectHelper)||e.deactivate()}enableWebCam(){this.scene&&(this.webcam||(this.webcam=new a2),this.webcamPlane||(this.webcamPlane=this.webcam.createWebCamPlane(),this.webcamPlane.position.set(10,2,0)),this.scene.add(this.webcamPlane))}disableWebCam(){this.scene&&this.webcamPlane&&(this.webcamPlane.geometry.dispose(),this.webcamPlane.material.dispose(),this.scene.remove(this.webcamPlane))}setEnvironment(e){Cc.createEnvTexture(this.pmremGenerator,e).then((e=>{this.scene&&(this.scene.environment&&this.scene.environment.dispose(),this.scene.environment=e,this.enableRender())}))}setEnvironmentFromDataArray(e){Cc.createEnvTextureFromDataArray(this.pmremGenerator,e).then((e=>{this.scene&&(this.scene.environment=e,this.enableRender())}))}takeObjectsScreenshot(e){return ft(this,null,(function*(){return new Promise(((t,n)=>{var i;this.renderer||n("renderer is undefined"),null==(i=this.scene)||i.traverse((t=>{t instanceof xt&&((0,d2.includes)(e,(0,d2.get)(t.userData,"UniqueId"))?t.visible=!0:t.visible=!1)})),this.enableRender(),setTimeout((()=>{var e;t(null==(e=this.renderer)?void 0:e.domElement.toDataURL("image/png"))}),1e3)}))}))}setObjectColor(e,t){this.clearSelection();let n={};e.traverse((e=>{let t=e.material;t&&(Array.isArray(t)?t.forEach((e=>{n[e.id]=e})):n[t.id]=t)}));for(let i in n)es.setMaterialColor(n[i],new ct(t));this.enableRender()}updateRaycasterThreshold(){let e=this.camera;if(!e||!this.raycaster)return;let t=12/e.zoom,n=this.raycaster.params;n.Line?n.Line.threshold=t:n.Line={threshold:t},n.Points?n.Points.threshold=t:n.Points={threshold:t}}merge(e){this.increaseJobCount();try{let t=[];e.traverse((e=>{e.geometry&&e.material&&t.push(e)})),Ar.deepMerge(t,e)}finally{this.decreaseJobCount()}}updateProjectSettings(e){this.settings=e;let t=(e,t)=>{e&&t&&(e.near=t.near,e.far=t.far,e.updateProjectionMatrix())};t(this.perspectiveCamera,this.settings.camera),t(this.orthoCamera,this.settings.camera),this.enableRender(10)}computeBoundingBox(){let e=new Ot;return this.loadedModels.forEach((t=>{t.bbox&&!t.bbox.isEmpty()&&e.union(t.bbox)})),this.bbox=e,this.controls&&(this.controls.minDistance=.1,this.controls.maxDistance=10*this.bbox.getSize(new O).length()),e}setDistanceCullingFactor(e){this.distanceCullingFactor=e}getDistanceCullingFactor(){return this.distanceCullingFactor}getCameraPositionAndDirection(){let e=this.camera;if(!e)return;let t=e.position,n=new O;return e.getWorldDirection(n),{position:{x:t.x,y:t.y,z:t.z},direction:{x:n.x,y:n.y,z:n.z}}}},f2=ji(Fl(),1),Uvt=(e=>(e[e.Browser=0]="Browser",e[e.Browserless=1]="Browserless",e[e.Headless=2]="Headless",e))(Uvt||{}),Gve=class{constructor(e,t,n){if(this.scene=this.initScene(),this.selectedObject=void 0,this.loadedModels=[],this.clock=new po,this.viewerMode=0,this.raycaster=new ia,this.savedMaterialsForOpacity=[],this.jobCount=0,this.bbox=new Ot,this.outlineMaterial=new Gn({color:1118481}),this.outlineRoot=new er,this.transparentObjectIds=[],this.applyOptionsAndAddToScene=(e,t,n,i)=>ft(this,null,(function*(){if(se.info(`[Viewer] '${e}' is loaded, adding to scene...`),n.matrix&&16===n.matrix.length){let e=new Qe;e.elements=n.matrix,t.applyMatrix4(e)}let r;t.traverse((e=>{e.geometry&&e.layers.enableAll(),e instanceof Ws&&(e.visible=!1)})),n.edges&&(r=yield zn.createOutlines(t,void 0,i));let a=n.modelId||n.src,s=e=>!!this.loadedModels.find((t=>t.modelId===e));if(s(a)){let e=1;for(;s(`${a}_${e}`);)e++;a=`${a}_${e}`,se.warn(`[Viewer] Model '${a}' is loaded more than once!`)}let o={modelId:a,object:t,edges:r};this.addModel(o)})),this.getMeshes=e=>{let t=[];return e instanceof xt?t.push(e):e.traverseVisible((e=>{e instanceof xt&&t.push(e)})),t},this.containerOrCanvas=e,t&&(this.viewerMode=t),this.glContext=n,1===this.viewerMode&&(e instanceof HTMLDivElement||!n))throw new Error("[Viewer] Parameters don't match Browserless viewerMode !");this.increaseJobCount(),this.init(),this.decreaseJobCount(),se.info("[Viewer] Initialized"),this.animate()}init(){this.initRenderer(),this.initCamera(),this.initControls(),this.initLights(),this.initPointerEvents(),this.scene.add(this.outlineRoot)}initScene(){let e=new _i;return e.background=new ct(7112861),e.matrixAutoUpdate=!0,e}isBrowserlessMode(){return 1===this.viewerMode}isBrowserMode(){return 0===this.viewerMode}initRenderer(){let e={antialias:!0,preserveDrawingBuffer:!0},t=this.isBrowserlessMode();t&&Object.assign(e,{canvas:this.containerOrCanvas,context:this.glContext});let n=new Ms(e);if(t){let e=this.containerOrCanvas.width,t=this.containerOrCanvas.height;se.info(`[Viewer] Render target size: ${e} x ${t}`),this.renderTarget=new sr(e,t,{minFilter:Ir,magFilter:Qr,format:ea,type:Ec}),n.setRenderTarget(this.renderTarget)}else{let e=this.containerOrCanvas.clientWidth,t=this.containerOrCanvas.clientHeight;this.containerOrCanvas.append(n.domElement),n.setPixelRatio(window.devicePixelRatio),n.setSize(e,t)}n.outputColorSpace=tn,n.toneMappingExposure=1,n.useLegacyLights=!1,n.setClearColor(11119017,1),n.shadowMap.enabled=!0,n.shadowMap.type=Ev,this.renderer=n,t||(this.pmremGenerator=new jh(n),this.pmremGenerator.compileEquirectangularShader(),this.setEnvironmentFromDataArray())}initCamera(){if(!this.scene)return;let e=this.containerOrCanvas.clientWidth||this.containerOrCanvas.width||0,t=this.containerOrCanvas.clientHeight||this.containerOrCanvas.height||0,n=1;e&&t&&(n=e/t),this.camera=new cr(68,n,.05,1e4),this.camera.position.set(10,10,10),this.camera.lookAt(0,0,0),this.scene.add(this.camera)}initControls(){if(!this.renderer)return;let e=this.camera;if(!e)return;let t=new ba(e,this.renderer.domElement);t.smoothTime=.05,t.enabled=!0,t.keyTruckSpeed=10,t.keys={left:"KeyD",up:"KeyE",right:"KeyA",bottom:"KeyQ"},t.update(0),this.controls=t,t.addEventListener("update",(()=>{!this.isBrowserMode()&&this.renderer&&this.renderer.render(this.scene,e)}))}initLights(){if(!this.scene)return;let e=16777215,t=new js(e,.3);t.position.set(-2,2,4);let n=new Pl(3158064),i=new Du(e,14540253,3);i.position.set(0,300,0),this.scene.add(t),this.scene.add(n),this.scene.add(i)}initPointerEvents(){if(!this.renderer||!this.camera||!this.controls)return;let e=!1,t=!1,n=-1,i=-1;this.renderer.domElement.addEventListener("pointerdown",(t=>{n=t.x,i=t.y,e=!1})),this.renderer.domElement.addEventListener("pointermove",(t=>{n>=0&&i>=0&&(Math.abs(t.x-n)>5||Math.abs(t.y-i)>5)&&(e=!0)})),this.renderer.domElement.addEventListener("pointerup",(()=>{t&&setTimeout((()=>{t=!1}),200),n=-1,i=-1})),this.renderer.domElement.addEventListener("dblclick",(n=>{t=!0,e||(this.handleMouseClick(n),this.flyToSelectedObject())}))}animate(){var e;this.isBrowserMode()&&requestAnimationFrame(this.animate.bind(this));let t=this.clock.getDelta();this.controls&&this.controls.update(t),this.scene&&this.camera&&(null==(e=this.renderer)||e.render(this.scene,this.camera))}destroy(){this.camera=void 0,this.scene&&this.scene.clear(),this.requestAnimationFrameHandle&&(cancelAnimationFrame(this.requestAnimationFrameHandle),this.requestAnimationFrameHandle=void 0),this.renderer&&(this.containerOrCanvas.removeChild(this.renderer.domElement),this.renderer.clear(),this.renderer.dispose(),this.renderer=void 0),this.controls&&(this.controls.dispose(),this.controls=void 0),this.renderTarget&&(this.renderTarget.dispose(),this.renderTarget=void 0),this.raycaster=void 0,this.selectedObject=void 0,this.savedMaterialsForOpacity=void 0,this.loadedModels=[]}loadLocalModel(e,t,n){return ft(this,null,(function*(){let i=yield(new Ya).loadLocalModel(e,t.src,n);return i?(yield this.applyOptionsAndAddToScene(e,i,t),Promise.resolve()):Promise.reject()}))}loadModel(e,t){return ft(this,null,(function*(){this.increaseJobCount();let n=yield(new Ya).loadModel(e.src,e.fileFormat,t);return n?(yield this.applyOptionsAndAddToScene(e.src,n,e),Promise.resolve()):Promise.reject()}))}parseGltf(e,t,n,i){this.increaseJobCount(),(new Ya).parseGltf(e,t.src,(e=>{this.applyOptionsAndAddToScene(t.src,e,t),n&&n(e)}),(e=>{i&&i(e)}))}addModel(e){if(!this.scene||!this.renderer)return;this.increaseJobCount();let t=(new Ot).setFromObject(e.object);e.bbox||(e.bbox=t),this.scene.add(e.object),this.loadedModels.push(e),this.computeBoundingBox(),1===this.loadedModels.length&&(this.tryAdjustCameraNearAndFar(),this.goToHomeView()),this.renderer.shadowMap.needsUpdate=!0,se.info(`[Viewer] Added '${e.modelId}' to scene`),this.decreaseJobCount()}addOrRemoveObjectOpacity(e=!0,t=.3,n,i){if(this.savedMaterialsForOpacity||(this.savedMaterialsForOpacity=[]),!this.scene)return;let r=this.scene,a=[];this.loadedModels.forEach((s=>{if(e){this.savedMaterialsForOpacity&&this.savedMaterialsForOpacity.length>0&&zn.revertObjectOpacityById(r,s.object.id,this.savedMaterialsForOpacity);let e=zn.setObjectOpacityById(r,s.object.id,t,n,i);a.push(...e)}else this.savedMaterialsForOpacity&&zn.revertObjectOpacityById(r,s.object.id,this.savedMaterialsForOpacity)})),this.savedMaterialsForOpacity=e?a:[]}hasTransparentObject(){return!!(this.savedMaterialsForOpacity&&this.savedMaterialsForOpacity.length>0)}getIntersections(e){if(!this.raycaster||!this.camera||!this.scene)return[];let t=new be;e&&(t=un.getScreenPointByEvent(e,this.containerOrCanvas));let n=un.screenPoint2NdcPoint(t,this.camera,this.containerOrCanvas);this.raycaster.setFromCamera(n,this.camera);let i=[];return this.loadedModels.forEach((e=>{let t=e.object;t&&t.visible&&i.push(t)})),this.raycaster.intersectObjects(i,!0)||[]}handleMouseClick(e){this.raycaster&&this.raycaster.layers.set(12);let t=this.getIntersections(e).find((e=>{let t=e.object;return t.visible&&t instanceof xt})),n=t&&t.object||void 0;n&&this.selectedObject&&this.selectedObject.id===n.id&&(n=void 0),n?this.selectObject(n):this.clearSelection()}selectObject(e){if(this.selectedObject){let e=this.selectedObject.userData;if(e.originalMaterial){if(this.selectedObject.material){let e=this.selectedObject.material;Array.isArray(e)?e.forEach((e=>e.dispose())):e instanceof vr&&e.dispose()}this.selectedObject.material=e.originalMaterial,delete e.originalMaterial}this.selectedObject=void 0}if(!this.scene||!e)return;let t=es.clonedHighlightMaterials(e);t&&(this.selectedObject=e,this.selectedObject.userData.originalMaterial=this.selectedObject.material,this.selectedObject.material=t)}clearSelection(){this.selectObject()}flyToObjects(e){if(!e||0===e.length||!this.camera)return;let t=new Ot;e.forEach((e=>{let n=ks.getBoundingBox(e);t.union(n)}));let n=new gr;t.getBoundingSphere(n),this.controls.fitToSphere(n,!0)}flyToObject(e){this.flyToObjects([e])}flyToSelectedObject(){this.selectedObject&&this.flyToObject(this.selectedObject)}flyTo(e,t,n){var i;let r=this.camera,a=this.controls;if(!r||!a)return;let s=e=Array.isArray(e)?new O(e[0],e[1],e[2]):e,o=t=Array.isArray(t)?new O(t[0],t[1],t[2]):t;se.info("[Viewer] flyTo: ",Mt.vectorToString(s)),a.setPosition(s.x,s.y,s.z),a.setTarget(o.x,o.y,o.z),this.isBrowserMode()||null==(i=this.renderer)||i.render(this.scene,r),n&&n()}goToHomeView(){let e=new gr;this.bbox.getBoundingSphere(e),this.controls.fitToSphere(e,!0)}setEnvironmentFromDataArray(e){Cc.createEnvTextureFromDataArray(this.pmremGenerator,e).then((e=>{this.scene.environment=e,this.isBrowserMode()||this.animate()}))}tryAdjustCameraNearAndFar(){let e=this.camera;if(!this.scene||!e)return;let t=this.bbox,n=e.near,i=e.far,r=t.max.x-t.min.x,a=t.max.y-t.min.y,s=t.max.z-t.min.z,o=Math.max(r,a,s),l=o/5,h=5*o;if(n>l||iMt.numberToString(e);se.info(`[Viewer] BBox's longest side is: ${t(o)}`),n>l&&(se.warn(`[Viewer] camera.near(${t(n)}) shouldn't bigger than ${t(l)}, will change it!`),e.near=l),i0?void 0:this.transparentObjectIds,n=this.transparentObjectIds.length>0?this.transparentObjectIds:void 0,i=new ln({color:16777215,transparent:!0,opacity:.1});this.loadedModels.forEach((e=>{zn.applyMaterialToObjectById(this.scene,e.object.id,i,n,t)})),this.outlineRoot.clear();let r=[];if(e.forEach((e=>{let t=e.modelId,n=this.loadedModels.find((e=>e.modelId===t)),i=null==n?void 0:n.object;i||(se.warn(`[Viewer] The ModelId of ${t} has no corresponding model.`),i=this.scene),i.traverse((t=>{if((0,f2.includes)(e.id,(0,f2.get)(t.userData,"UniqueId"))){let e=this.getMeshes(t);r=r.concat(e)}}))})),r.length>0){r.forEach((e=>{let t=zn.createOutline(e.geometry,this.outlineMaterial);t.applyMatrix4(e.matrixWorld),this.outlineRoot.add(t),t.updateWorldMatrix(!0,!1)}));let e=r.map((e=>e.id));this.loadedModels.forEach((t=>{zn.revertAppliedMaterialToObjectById(this.scene,t.object.id,e)})),this.transparentObjectIds=e,this.flyToObjects(r)}else se.warn(`[Viewer] No object found with uniqueIds: ${e.map((e=>e.id))}`);this.isBrowserMode()||this.animate()}increaseJobCount(){++this.jobCount}decreaseJobCount(){--this.jobCount}computeBoundingBox(){let e=new Ot;return this.loadedModels.forEach((t=>{t.bbox&&!t.bbox.isEmpty()&&e.union(t.bbox)})),this.bbox=e,e}getContext(){var e;return null==(e=this.renderer)?void 0:e.getContext()}getCameraDirection(){var e;let t=new O;return null==(e=this.camera)||e.getWorldDirection(t),{x:t.x,y:t.y,z:t.z}}setFov(e){this.camera&&(this.camera.fov=e,this.camera.updateProjectionMatrix())}},qve=new O,Hvt=new hr,Wve=new O,cg=class extends on{constructor(e=document.createElement("div")){super(),this.isCSS3DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.addEventListener("removed",(function(){this.traverse((function(e){e.element instanceof Element&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this}},ih=new Qe,Vvt=new Qe,p2=class{constructor(e={}){let t,n,i,r,a=this,s={camera:{fov:0,style:""},objects:new WeakMap},o=void 0!==e.element?e.element:document.createElement("div");o.style.overflow="hidden",this.domElement=o;let l=document.createElement("div");l.style.transformOrigin="0 0",l.style.pointerEvents="none",o.appendChild(l);let h=document.createElement("div");function c(e){return Math.abs(e)<1e-10?0:e}function u(e){let t=e.elements;return"matrix3d("+c(t[0])+","+c(-t[1])+","+c(t[2])+","+c(t[3])+","+c(t[4])+","+c(-t[5])+","+c(t[6])+","+c(t[7])+","+c(t[8])+","+c(-t[9])+","+c(t[10])+","+c(t[11])+","+c(t[12])+","+c(-t[13])+","+c(t[14])+","+c(t[15])+")"}function d(e){let t=e.elements;return"translate(-50%,-50%)matrix3d("+c(t[0])+","+c(t[1])+","+c(t[2])+","+c(t[3])+","+c(-t[4])+","+c(-t[5])+","+c(-t[6])+","+c(-t[7])+","+c(t[8])+","+c(t[9])+","+c(t[10])+","+c(t[11])+","+c(t[12])+","+c(t[13])+","+c(t[14])+","+c(t[15])+")"}function p(e,t,n,i){if(e.isCSS3DObject){let i=!0===e.visible&&!0===e.layers.test(n.layers);if(e.element.style.display=!0===i?"":"none",!0===i){let i;e.onBeforeRender(a,t,n),e.isCSS3DSprite?(ih.copy(n.matrixWorldInverse),ih.transpose(),0!==e.rotation2D&&ih.multiply(Vvt.makeRotationZ(e.rotation2D)),e.matrixWorld.decompose(qve,Hvt,Wve),ih.setPosition(qve),ih.scale(Wve),ih.elements[3]=0,ih.elements[7]=0,ih.elements[11]=0,ih.elements[15]=1,i=d(ih)):i=d(e.matrixWorld);let r=e.element,o=s.objects.get(e);if(void 0===o||o.style!==i){r.style.transform=i;let t={style:i};s.objects.set(e,t)}r.parentNode!==h&&h.appendChild(r),e.onAfterRender(a,t,n)}}for(let r=0,a=e.children.length;r0))return void(this.visible=!0);t.forEach((e=>e.opacity=0));let n=1/(e/10);this.visible=!0,this.clearFading(),this.renderOrder+=1,this.fadingInInterval=setInterval((()=>{let e=1,i=this.getMaterials();this.materialEquals(t,i)||(t=i),t.length>0&&(e=Math.min(t[0].opacity+n,1),t.forEach((t=>t.opacity=e))),e>=1&&this.clearFading()}),10)}materialEquals(e,t){return jve.default.isEqualWith(e,t,((e,t)=>{if(!Array.isArray(e)||!Array.isArray(t))return e.id===t.id}))}fadeOut(e=1e3){let t=this.getMaterials(),n=1/(e/10),i=1/(e/10);this.clearFading(),this.scale.set(2,2,2),this.fadingOutInterval=setInterval((()=>{let e=this.scale.x+i;this.scale.set(e,e,e);let r=0;t.length>0&&(r=Math.max(t[0].opacity-n,0),t.forEach((e=>e.opacity=r))),(r<=0||e>=3)&&this.clearFading()}),10)}clearFading(){let e=this.getMaterials();this.fadingInInterval&&(clearInterval(this.fadingInInterval),this.fadingInInterval=void 0,this.visible=!0,e.forEach((e=>e.opacity=1)),this.renderOrder-=1),this.fadingOutInterval&&(clearInterval(this.fadingOutInterval),this.fadingOutInterval=void 0,this.visible=!1,e.forEach((e=>e.opacity=1)),this.scale.set(1,1,1))}getMaterials(){let e=this.thumbnailMesh;e||(e=this.mesh);let t=[];return Array.isArray(e.material)?t.push(...e.material):e.material&&t.push(e.material),t}create(){}createThumbnailMesh(e){return ft(this,null,(function*(){if(!this.thumbnailImages||6!=this.thumbnailImages.length)return;this.thumbnailMesh=new xt(new va(e,e,e)),this.thumbnailMesh.geometry.scale(1,1,-1);let t=(yield this.loadTexturesAsync(this.thumbnailImages)).map((e=>new ln({map:e,side:ci,transparent:!0})));this.thumbnailMesh&&(this.thumbnailMesh.material=t,this.add(this.thumbnailMesh))}))}loadTextures(e){return e.map((e=>{let t=this.textureLoader.load(e);return t.colorSpace=tn,t}))}loadTexturesAsync(e){return ft(this,null,(function*(){let t=e.map((e=>this.textureLoader.loadAsync(e))),n=yield Promise.all(t);return n.forEach((e=>e.colorSpace=tn)),n}))}destroyMesh(e){var t;this.remove(e),e.clear(),e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach((e=>{var t;null==(t=e.map)||t.dispose(),e.dispose()})):(null==(t=e.material.map)||t.dispose(),e.material.dispose())}destroy(){this.clearFading(),this.images=[],this.mesh&&(this.mesh instanceof xt?this.destroyMesh(this.mesh):this.mesh.traverse((e=>{e instanceof xt&&this.destroyMesh(e)})),this.mesh=void 0)}},m2=class extends sp{constructor(e,t,n=200){if(super(e,t,n),6!==e.length)throw new Error(`[VRCube] Wrong number of images! Expected 6, got ${e.length}`)}create(){return ft(this,null,(function*(){yield this.createThumbnailMesh(this.size),this.thumbnailMesh?this.updateMesh():yield this.createMesh()}))}updateMesh(){let e=this.thumbnailMesh,t=this.thumbnailImages.length;this.images.forEach(((n,i)=>ft(this,null,(function*(){let r=yield this.loadTexturesAsync([n]);e.material[i].map=r[0],t--,0===t&&(this.thumbnailImages=void 0)})))),this.destroyMesh(this.mesh),this.mesh=void 0}createMesh(){return ft(this,null,(function*(){let e=this.mesh;e.geometry=new va(this.size,this.size,this.size),e.geometry.scale(1,1,-1);let t=(yield this.loadTexturesAsync(this.images)).map((e=>new ln({map:e,side:ci,transparent:!0})));e.material=t,this.add(e),this.thumbnailMesh&&(this.destroyMesh(this.thumbnailMesh),this.thumbnailMesh=void 0,this.thumbnailImages=void 0)}))}},g2=class extends sp{constructor(e,t,n=200){if(super(e,t,n),24!==e.length)throw new Error(`[VRCube24Faces] Wrong number of images! Expected 24, got ${e.length}`);this.ratio=1,this.subPlaneWidth0=this.size*(this.ratio/(this.ratio+1)),this.subPlaneWidth1=this.size-this.subPlaneWidth0}create(){return ft(this,null,(function*(){yield this.createThumbnailMesh(this.size+.1),this.thumbnailMesh?this.createMesh():yield this.createMesh()}))}createMesh(){return ft(this,null,(function*(){var e;this.mesh=new er,this.mesh.scale.set(1,1,-1);let t=(yield this.loadTexturesAsync(this.images)).map((e=>new ln({map:e,side:Ki,transparent:!0})));if(24!==t.length)throw new Error(`[VRCube24Faces] Wrong number of materials! Expected 24, got ${t.length}`);let n=this.createPlaneOfAFace(t.slice(0,4));n.rotateOnAxis(new O(0,1,0),-Math.PI/2),n.position.set(this.size/2,0,0);let i=this.createPlaneOfAFace(t.slice(4,8));i.rotateOnAxis(new O(0,1,0),Math.PI/2),i.position.set(-this.size/2,0,0);let r=this.createPlaneOfAFace(t.slice(8,12));r.rotateOnAxis(new O(1,0,0),-Math.PI/2),r.rotateOnAxis(new O(0,0,1),Math.PI),r.rotateOnAxis(new O(1,0,0),Math.PI),r.position.set(0,this.size/2,0);let a=this.createPlaneOfAFace(t.slice(12,16));a.rotateOnAxis(new O(1,0,0),Math.PI/2),a.rotateOnAxis(new O(0,0,1),Math.PI),a.rotateOnAxis(new O(1,0,0),Math.PI),a.position.set(0,-this.size/2,0);let s=this.createPlaneOfAFace(t.slice(16,20));s.rotateOnAxis(new O(0,1,0),Math.PI),s.position.set(0,0,this.size/2),this.createPlaneOfAFace(t.slice(20,24)).position.set(0,0,-this.size/2),this.add(this.mesh),this.thumbnailMesh&&(this.destroyMesh(this.thumbnailMesh),this.remove(this.thumbnailMesh),null==(e=this.thumbnailMesh)||e.clear(),this.thumbnailMesh=void 0)}))}createPlaneOfAFace(e){var t;let n=new er,i=new ui(this.subPlaneWidth0,this.subPlaneWidth0),r=new ui(this.subPlaneWidth1,this.subPlaneWidth0),a=new ui(this.subPlaneWidth0,this.subPlaneWidth1),s=new ui(this.subPlaneWidth1,this.subPlaneWidth1),o=new xt(i,e[0]),l=new xt(r,e[1]),h=new xt(a,e[2]),c=new xt(s,e[3]);return o.position.set(this.subPlaneWidth1/2,this.subPlaneWidth1/2,0),l.position.set(-this.subPlaneWidth0/2,this.subPlaneWidth1/2,0),h.position.set(this.subPlaneWidth1/2,-this.subPlaneWidth0/2,0),c.position.set(-this.subPlaneWidth0/2,-this.subPlaneWidth0/2,0),o.geometry.scale(-1,1,1),l.geometry.scale(-1,1,1),h.geometry.scale(-1,1,1),c.geometry.scale(-1,1,1),n.add(o,l,h,c),null==(t=this.mesh)||t.add(n),n}},v2=class extends sp{constructor(e,t,n=100){if(super(e,t,n),1!==e.length)throw new Error(`[VRSphere] Wrong number of images! Expected 1, got ${e.length}`)}create(){return ft(this,null,(function*(){yield this.createThumbnailMesh(this.size+.1),this.thumbnailMesh?this.createMesh():yield this.createMesh()}))}createMesh(){return ft(this,null,(function*(){var e;let t=this.mesh;t.geometry=new za(this.size,100,100),t.geometry.scale(-1,1,1);let n=(yield this.loadTexturesAsync(this.images)).map((e=>new ln({map:e,side:ci,transparent:!0})));t.material=n[0],this.add(t),this.thumbnailMesh&&(this.destroyMesh(this.thumbnailMesh),this.remove(this.thumbnailMesh),null==(e=this.thumbnailMesh)||e.clear(),this.thumbnailMesh=void 0)}))}},Xve=class extends Zf{constructor(e,t){super(e),this.name="VRViewer",this.timer=Date.now(),this.loadedModels=[],this.minFov=50,this.maxFov=95,this.raycaster=new ia,this.autoRotate=!0,this.events=[],this.isMousePressing=!1,this.settings=Gv,this.viewpoints=[],this.activeViewpointId="",this.activePanoramaId="",this.viewpointAssetsMap=new Map,this.loadingPanos=[],this.onResize=()=>{this.viewerContainer&&this.viewerContainer.parentElement&&this.resize(this.viewerContainer.parentElement.clientWidth,this.viewerContainer.parentElement.clientHeight)},this.onMouseWheel=e=>{let t=e.deltaY<0?-5:5;this.updateFov(t)},this.applyOptionsAndAddToScene=(e,t,n,i)=>ft(this,null,(function*(){let r,a=Mt.getUpdateProgressFunc(i),s=Mt.getUpdateSubProgressFunc(70,90,i);if(a(0),se.info(`[Viewer] '${e}' is loaded in ${(Date.now()-this.timer)/1e3}s, adding to scene...`),this.timer=Date.now(),n.matrix&&16===n.matrix.length){let e=new Qe;e.elements=n.matrix,t.applyMatrix4(e)}if(t.matrixAutoUpdate=!1,t.updateMatrix(),t.traverse((e=>{e.matrixAutoUpdate&&(e.matrixAutoUpdate=!1,e.updateMatrix())})),n.merge&&this.merge(t),a(50),n.merge){let e=Date.now();Yf.createMeshBvhAsync([t],{saveOriginalIndex:!0}),se.info(`[Viewer] Creates mesh bvh cost ${(Date.now()-e)/1e3}s`)}a(60),t.traverse((e=>{e.geometry&&e.layers.enableAll(),e instanceof Ws&&(e.visible=!1)})),a(70),n.edges&&(r=yield zn.createOutlines(t,void 0,s)),a(90);let o={modelId:this.getUniqueModelId(n.modelId||n.src),object:t,edges:r};this.addModel(o),a(100)})),this.viewerCfg=e,this.cameraCfg=t||{eye:[0,0,0],look:[0,0,0]},this.settings=Gv,this.cameraCfg.near&&(this.settings.camera.near=this.cameraCfg.near),this.cameraCfg.far&&(this.settings.camera.far=this.cameraCfg.far),this.setSpinnerVisibility(++this.jobCount>0),this.init(),this.animate(),this.setSpinnerVisibility(--this.jobCount>0)}init(){this.initSpinner(),this.initScene(),this.initRenderer(),this.initCamera(),this.initControls(),this.initLights(),this.initInputManager(),this.initEvents(),this.initOthers()}initScene(){let e=new _i;e.background=new ct(16777215),e.matrixAutoUpdate=!0,this.scene=e}initRenderer(){var e,t;this.renderer=new Ms({antialias:!0,preserveDrawingBuffer:!1}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),this.renderer.useLegacyLights=!1,this.css2dRenderer=new Nu,this.css2dRenderer.setSize(this.width,this.height),this.css2dRenderer.domElement.style.height="0",this.css2dRenderer.domElement.style.width="0",null==(e=this.viewerContainer)||e.appendChild(this.renderer.domElement),null==(t=this.viewerContainer)||t.appendChild(this.css2dRenderer.domElement)}initCamera(){this.scene&&(this.camera=new cr(75,this.width/this.height,this.settings.camera.near,this.settings.camera.far),this.scene.add(this.camera))}initControls(){if(!this.renderer||!this.camera)return;let e=this.camera,t=this.viewerCfg,n=new KA(e,this.renderer.domElement,!0);n.enabled=!0,n.autoRotate=this.autoRotate,n.autoRotateSpeed=t.autoRotateSpeed||-2,n.enablePan=!1,n.enableZoom=!1,n.enableRotate=!0,n.rotateSpeed=.3,n.minPolarAngle=.05*Math.PI,n.maxPolarAngle=.95*Math.PI,n.listenToKeyEvents(document.body),n.update(),this.controls=n,this.controlsHelper=new tP(e,n),this.controls.controlsHelper=this.controlsHelper,this.autoRotate&&this.controlsHelper.delayAutoRotate(),this.controlsHelper.automaticallyAdjustCameraPosition=!1,this.controls.addEventListener("end",(()=>{this.handleDragEnd&&this.handleDragEnd()}));let i=new O(0,0,0),r=new O(10,0,0);this.setCameraPositionAndDirection(i,r)}onKeyDown(e){return t=>{var n,i;let r=e.camera,a=e.controls;!r||!a||(("ArrowLeft"===t.code||"ArrowRight"===t.code||"ArrowUp"===t.code||"ArrowDown"===t.code)&&(null==(n=this.controlsHelper)||n.startToRotate(t)),null==(i=this.controlsHelper)||i.delayAutoRotate())}}initLights(){if(!this.scene)return;let e=new js(16777215,.3);e.position.set(-2,2,4),this.scene.add(e);let t=new Du(16777215,14540253,2);t.position.set(0,300,0),this.scene.add(t)}initInputManager(){this.viewerContainer&&(this.inputManager=new Jo(this.viewerContainer))}initEvents(){let e=this.renderer,t=this.camera;if(!e||!t)return;let n=!1,i=-1,r=-1;this.addEvent("keydown",this.onKeyDown(this)),this.addEvent("wheel",this.onMouseWheel),this.addEvent("pointerdown",(t=>{var a,s;i=t.x,r=t.y,n=!1,this.isMousePressing=!0,this.autoRotate&&(null==(a=this.controlsHelper)||a.delayAutoRotate()),t.button===WR.LEFT&&(null==(s=t.originalEvent)?void 0:s.target)instanceof HTMLCanvasElement&&(e.domElement.style.cursor="move")})),this.addEvent("pointermove",(e=>{i>=0&&r>=0&&(Math.abs(e.x-i)>5||Math.abs(e.y-r)>5)&&(n=!0)})),this.addEvent("pointerup",(i=>{var r,a,s;this.isMousePressing=!1,this.autoRotate&&(null==(r=this.controlsHelper)||r.delayAutoRotate()),e.domElement.style.cursor="auto";let o=i.button;if(!n&&o===WR.LEFT)if(null!=(a=i.originalEvent)&&a.target&&i.originalEvent.target instanceof HTMLDivElement){let e=Tf.tryFindObjectId(i.originalEvent.target);if(e){let t=null==(s=this.scene)?void 0:s.getObjectById(e);if(t){let e=t.userData.hotpoint;e&&(se.info("[Viewer] Clicked on hotpoint: ",e.hotpointId||e),this.onHotpointClicked&&this.onHotpointClicked(e))}}}else{let e=this.getIntersection(i);if(e){let n=e=>Mt.vectorToString(e),i=e.point,r=i.clone().sub(t.position).normalize();se.info(`[Viewer] Clicked at: ${n(i)},\n Camera position: ${n(t.position)},\n Target direction: ${n(r)}`)}}}))}initOthers(){!this.controls||!this.renderer||!this.camera||(this.renderer.domElement.style.outlineWidth="0")}animate(){var e,t,n;if(this.requestAnimationFrameHandle=requestAnimationFrame(this.animate.bind(this)),this.minFrameInterval>0){let e=Date.now()-this.lastFrameExecuteTime;if(e0&&!this.isMousePressing&&(t.autoRotateRemainingTime-=e,t.autoRotateRemainingTime<=0&&this.controls&&t.startAutoRotate())}}if(this.viewerContainer&&this.viewerContainer){let{width:e,height:t}=this.viewerContainer.getBoundingClientRect();(this.width!==e||this.height!==t)&&this.resize(e,t)}this.controls&&this.controls.update(),this.scene&&this.camera&&(this.dispatchEvent("BeforeRender"),null==(e=this.renderer)||e.render(this.scene,this.camera),null==(t=this.css2dRenderer)||t.render(this.scene,this.camera),null==(n=this.css3dRenderer)||n.render(this.scene,this.camera),this.dispatchEvent("AfterRender")),this.dispatchEvent("OnAnimate")}clearAllCachedPanoramas(){this.handleCameraUpdateInterval(),this.loadingPanos.forEach((e=>{e.creationPromise&&(e.creationPromise.cancel(),e.creationPromise=void 0)})),this.viewpointAssetsMap.forEach((e=>{var t;let n=e.panoramas;for(let i=n.length-1;i>=0;--i){let e=n[i];e.box.destroy(),null==(t=this.scene)||t.remove(e.box)}})),this.loadingPanos=[],this.viewpointAssetsMap.clear(),this.activePanoramaId="",this.activePanoramaId=""}destroy(){var e;this.events.forEach((e=>{var t;return null==(t=this.inputManager)?void 0:t.removeEventListener(e.type,e.func)})),this.events=[],this.clearAllCachedPanoramas(),this.css2dRenderer&&(null==(e=this.viewerContainer)||e.removeChild(this.css2dRenderer.domElement)),super.destroy()}updateFov(e){var t;let n=this.camera;if(!n)return;let i=this.minFov,r=this.maxFov,a=e=>{let t=n.fov+e;t=Math.min(t,r),t=Math.max(t,i),n.fov!==t&&(n.fov=t,n.updateProjectionMatrix())},s=e/20;for(let o=0;o<20;++o)setTimeout((()=>a(s)),5*o);this.autoRotate&&(null==(t=this.controlsHelper)||t.delayAutoRotate())}setMinAndMaxFov(e,t){let n=this.controls;n&&(this.minFov=e,this.maxFov=t,n.minFov=e,n.maxFov=t)}resize(e,t){super.resize(e,t),t>0&&(this.css2dRenderer&&(this.css2dRenderer.setSize(e,t),this.css2dRenderer.domElement.style.height="0",this.css2dRenderer.domElement.style.width="0"),this.css3dRenderer&&this.css3dRenderer.setSize(e,t))}enableAutoRotate(e){this.controls&&(this.autoRotate=e,this.controls.autoRotate=e)}setAutoRotateSpeed(e=1){this.controls&&(this.controls.autoRotateSpeed=e)}setCameraFov(e=75){let t=this.camera;t&&(t.fov=e,t.updateProjectionMatrix())}addEvent(e,t){var n;null==(n=this.inputManager)||n.addEventListener(e,t),this.events.push({type:e,func:t})}setCameraPositionAndDirection(e,t,n){let i,r,a=this.camera,s=this.controls;if(!a||!s)return;i=t?Array.isArray(t)?new O(t[0],t[1],t[2]):new O(t.x,t.y,t.z):s.target.clone().sub(a.position),i.normalize(),r=Array.isArray(e)?new O(e[0],e[1],e[2]):new O(e.x,e.y,e.z);let o=r.clone().addScaledVector(i,.01);this.fianlCameraPosition=r,this.finalCameraTarget=o;let l=(e,t)=>{a.position.set(e.x,e.y,e.z),s.target.set(t.x,t.y,t.z),s.update()};if(!1===n)return this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),void l(r,o);let h=a.position.clone(),c=s.target.clone(),u=500,d=Date.now();this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=setInterval((()=>{let e=Date.now()-d;e>u&&(e=u);let t=(e,t,n)=>{let i=e.x+(t.x-e.x)*n,r=e.y+(t.y-e.y)*n,a=e.z+(t.z-e.z)*n;return new O(i,r,a)},n=t(h,r,e/u),i=t(c,o,e/u);l(n,i),e>=u&&(clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=void 0)}),10)}getCameraPositionAndDirection(){let e=this.camera;if(!e)return;let t=e.position,n=new O;return e.getWorldDirection(n),{position:{x:t.x,y:t.y,z:t.z},direction:{x:n.x,y:n.y,z:n.z}}}getCameraFov(){let e=this.camera;if(e)return e.fov}setViewpoints(e){this.handleCameraUpdateInterval(),this.viewpointAssetsMap.size>0&&(this.viewpointAssetsMap.forEach((e=>{let t=e.panoramas,n=e.css2dObjects;t.forEach((e=>{var t;e.box.destroy(),null==(t=this.scene)||t.remove(e.box)})),n.forEach((e=>{var t;null==(t=this.scene)||t.remove(e)}))})),this.viewpointAssetsMap.clear()),this.loadingPanos.forEach((e=>{e.creationPromise&&(e.creationPromise.cancel(),e.creationPromise=void 0)})),this.loadingPanos=[],this.activeViewpointId="",this.activePanoramaId="",this.viewpoints=e}loadModel(e,t){return ft(this,null,(function*(){var n,i;this.timer=Date.now(),this.increaseJobCount();let r=e.modelId||e.src,a=this.translate("ProgressBar.Loading"),s=e=>{var n;null==(n=this.loadingProgressBar)||n.updateProgress(r,a,e),t&&t(new ProgressEvent("LoadProgress",{loaded:e,total:100}))},o=(e,n,i)=>{var s;let o=100*e.loaded/e.total;o=o*(i-n)/100+n,null==(s=this.loadingProgressBar)||s.updateProgress(r,a,o),t&&t(new ProgressEvent("LoadProgress",{loaded:o,total:100}))},l=e=>o(e,0,50),h=e=>o(e,50,99);null==(n=this.loadingProgressBar)||n.addProgressItem(r),s(0);try{let t=yield(new Ya).loadModel(e.src,e.fileFormat,l);if(t)return yield this.applyOptionsAndAddToScene(e.src,t,e,h),Promise.resolve()}catch(t){let i=`Error loading ${e.src}`;return se.error(i,t),Promise.reject(i)}finally{this.decreaseJobCount(),s(100),null==(i=this.loadingProgressBar)||i.delayRemoveProgressItem(r)}return Promise.reject()}))}setModelVisibility(e,t){let n=this.loadedModels.find((t=>t.modelId===e)),i=n&&n.object;if(!i)throw new Error(`Failed to find model by modelId '${e}'!`);i.visible=t,this.enableRender()}addModel(e){if(!this.scene||!this.renderer)return;this.increaseJobCount();let t=(new Ot).setFromObject(e.object);e.bbox||(e.bbox=t),this.scene.add(e.object),this.loadedModels.push(e),se.info(`[Viewer] Added '${e.modelId}' to scene in ${(Date.now()-this.timer)/1e3}s`),this.renderer.shadowMap.needsUpdate=!0,this.enableRender(),this.dispatchEvent("ModelLoaded",{modelId:e.modelId,bbox:t}),this.decreaseJobCount()}addPanorama(e,t){let n=this.viewpoints.find((t=>t.id===e));if(!n)throw new Error(`[Viewer] Failed to find viewpoint by id '${e}'`);n.panoramas||(n.panoramas=[]),n.panoramas.push(t)}findPanorama(e,t){let n=this.viewpoints.find((t=>t.id===e));if(n&&n.panoramas)return n.panoramas.find((e=>e.id===t))}setHotpointsVisibility(e,t="",n=[]){if(!this.viewpoints)return;let i=t=>{var i;let r=this.viewpointAssetsMap.get(t.id),a=(null==r?void 0:r.css2dObjects)||[];null==(i=t.hotpoints)||i.forEach((i=>{if(n&&n.length>0){if(-1===n.findIndex((e=>e===i.hotpointId)))return;if(i.visible=e,this.activeViewpointId===t.id){let t=a.find((e=>e.userData.hotpoint.hotpointId===i.hotpointId));t&&(t.visible=e)}}else i.visible=e,this.activeViewpointId===t.id&&a.forEach((t=>t.visible=e))}))};if(t){let e=this.viewpoints.find((e=>e.id===t));e&&i(e)}else this.viewpoints.forEach((e=>i(e)))}addHotpoints(e){if(!this.activeViewpointId||!e)return;let t=this.viewpoints.find((e=>e.id===this.activeViewpointId)),n=this.viewpointAssetsMap.get(this.activeViewpointId);!t||!n||(t.hotpoints||(t.hotpoints=[]),e.forEach((e=>{var i,r;if(-1!==(null==(i=t.hotpoints)?void 0:i.findIndex((t=>t.hotpointId===e.hotpointId))))return void se.warn(`[Viewer] Duplicated hotpointId: ${e.hotpointId}`);let a=t.position||[0,0,0],s=e.anchorPosition,o=Tf.createHotpoint(e.html),l=new O(s[0],s[1],s[2]),h=new O(a[0],a[1],a[2]);this.relocateAnchorIfTooCloseToCamera(o,l,h),o.visible=!1!==e.visible,o.userData.hotpoint=e,n.css2dObjects.push(o),null==(r=this.scene)||r.add(o),t.hotpoints.push(e)})))}removeHotpoints(e){if(!this.activeViewpointId||!e)return;let t=this.viewpoints.find((e=>e.id===this.activeViewpointId)),n=this.viewpointAssetsMap.get(this.activeViewpointId);!t||!n||e.forEach((e=>{var i,r;if(t.hotpoints)for(let n=t.hotpoints.length-1;n>=0;--n)e===t.hotpoints[n].hotpointId&&t.hotpoints.splice(n,1);for(let t=n.css2dObjects.length-1;t>=0;--t){let a=n.css2dObjects[t];e===(null==(i=a.userData.hotpoint)?void 0:i.hotpointId)&&(n.css2dObjects.splice(t,1),null==(r=this.scene)||r.remove(a))}}))}activeViewpointById(e,t,n,i){this.activatePanoramaById(e,"",!0,t,n,i)}activatePanoramaById(e,t,n=!0,i,r,a){if(e===this.activeViewpointId&&t===this.activePanoramaId)return;let s=this.viewpoints.find((t=>t.id===e));s&&this.activatePanorama(s,t,n,i,r,a)}removeCachedPanoramas(e={}){this.viewpointAssetsMap.forEach(((t,n)=>{var i;let r=t.panoramas;for(let a=r.length-1;a>=0;--a){let t=r[a];if(n===this.activeViewpointId&&t.id===this.activePanoramaId||e[n]&&e[n].includes(t.id))return;t.box.destroy(),null==(i=this.scene)||i.remove(t.box),r.splice(a,1)}}))}unlimitControlsAndShowAssets(e=!1){if(this.controls){let e=this.controls;e.enablePan=!0,e.enableZoom=!0}this.viewpointAssetsMap.forEach((t=>{t.panoramas.forEach((e=>{e.box.visible=!0})),e&&t.css2dObjects.forEach((e=>{e.visible=!0}))}))}relocateAnchorIfTooCloseToCamera(e,t,n){let i=this.camera;if(!i)return se.error("[Viewer] Camera is not initialized"),void e.position.set(t.x,t.y,t.z);let r,a=Math.abs(t.distanceTo(n));if(a{let i=e.panoramas.find((e=>e.id===t)),r=null==i?void 0:i.box;r&&(n?this.fadeIn(r):this.fadeOut(r))},c=(e,t)=>{e.css2dObjects.forEach((e=>{t?!1!==e.userData.hotpoint.visible&&(e.visible=t):e.visible=t}))},u=()=>{var t;let r=new O(0,0,0),a=new O(1,0,0),s=null==(t=this.getCameraPositionAndDirection())?void 0:t.direction;s&&a.set(s.x,s.y,s.z);let o=e.position;if(o&&3===o.length&&r.set(o[0],o[1],o[2]),n){let t=e.initialDirection;t&&3===t.length&&a.set(t[0],t[1],t[2])}this.setCameraPositionAndDirection(r,a,i)};!t&&(null==(s=e.panoramas)?void 0:s.length)>0&&(t=e.panoramas[0].id||""),this.handleCameraUpdateInterval();let d=this.viewpointAssetsMap.get(this.activeViewpointId),p=this.viewpointAssetsMap.get(e.id);if(this.activeViewpointId&&d&&(this.activeViewpointId!==e.id&&c(d,!1),h(d,this.activePanoramaId,!1)),p&&p.panoramas.find((e=>e.id===t)))return h(p,t,!0),this.activeViewpointId!==e.id&&c(p,!0),this.activeViewpointId!==e.id&&u(),this.activeViewpointId=e.id,this.activePanoramaId=t,void(r&&r(e));this.activeViewpointId=e.id,this.activePanoramaId=t;try{if(this.loadingPanos.some((n=>n.viewpointId===e.id&&n.panoramaId===t)))return void se.warn(`[Viewer] Panorama with viewpointId=${e.id} and panoramaId=${t} is being created`);let n=new EA(this.createBoxByImageOrImages(e,t));this.loadingPanos.push({viewpointId:e.id,panoramaId:t,creationPromise:n});let i=yield n.promise;this.loadingPanos=this.loadingPanos.filter((n=>n.viewpointId!==e.id||n.panoramaId!==t));let a=e.position;a&&3===a.length&&i.position.set(a[0],a[1],a[2]),this.activeViewpointId===e.id&&this.activePanoramaId===t?(this.fadeIn(i),null==(o=this.scene)||o.add(i),u()):(i.visible=!1,null==(l=this.scene)||l.add(i));let s={id:t,box:i},h=this.viewpointAssetsMap.get(e.id);if(h)h.panoramas.push(s),c(h,!0);else{let n=[];e.hotpoints&&e.hotpoints.forEach((r=>{let a=r.anchorPosition,s=Tf.createHotpoint(r.html);s.visible=!1!==r.visible,s.userData.hotpoint=r;let o=new O(a[0],a[1],a[2]);this.relocateAnchorIfTooCloseToCamera(s,o,i.position),(this.activeViewpointId!==e.id||this.activePanoramaId!==t)&&(s.visible=!1),n.push(s)}));let r={panoramas:[s],css2dObjects:n};this.viewpointAssetsMap.set(e.id,r),n.forEach((e=>{var t;return null==(t=this.scene)?void 0:t.add(e)}))}r&&r(e)}catch(e){"cancel"!==e.type&&a&&a(e)}}))}createBoxByImageOrImages(e,t){var n;let i=e.imageOrImages,r=e.thumbnailImages;if((null==(n=e.panoramas)?void 0:n.length)>0){let n=this.findPanorama(e.id,t);n||(n=e.panoramas[0],se.warn(`[Viewer] Failed to find panorama by id '${t}', will use the first one`)),i=n.images,r=n.thumbnails}if(!i)throw new Error("[Viewer] Invalid images!");if(Array.isArray(i)||(i=[i]),1===i.length)return this.createBoxByImage(i,r);if(6===i.length)return this.createBoxBy6Images(i,r);if(24===i.length)return this.createBoxBy24Images(i,r);throw new Error(`[Viewer] Wrong number of images! Expected 1/6/24, got ${i.length}`)}createBoxByImage(e,t){return ft(this,null,(function*(){let n=new v2(e,t);return yield n.create(),n}))}createBoxBy6Images(e,t){return ft(this,null,(function*(){if(6!==e.length)throw new Error(`[VRCube] Wrong number of images! Expected 6, got ${e.length}`);let n=new m2(e,t);return yield n.create(),n}))}createBoxBy24Images(e,t){return ft(this,null,(function*(){if(24!==e.length)throw new Error(`[VRCube] Wrong number of images! Expected 24, got ${e.length}`);let n=new g2(e,t);return yield n.create(),n}))}getIntersection(e){if(!this.camera||!this.scene)return;let t=this.viewpointAssetsMap.get(this.activeViewpointId);if(!t)return;let n=t.panoramas.find((e=>e.id===this.activePanoramaId));if(!n)return;let i=n.box,r=this.viewerContainer,a=new be;e&&(a=un.getScreenPointByEvent(e,r));let s=un.screenPoint2NdcPoint(a,this.camera,r);this.raycaster.setFromCamera(s,this.camera);let o=[i],l=this.raycaster.intersectObjects(o,!0)||[];return l.length>0?l.find((e=>{let t=e.object;return t.visible&&t instanceof xt})):void 0}fadeIn(e,t=500){e.fadeIn(t)}fadeOut(e,t=1e3){e.fadeOut(t)}handleCameraUpdateInterval(){if(this.cameraUpdateInterval){clearInterval(this.cameraUpdateInterval);let e=this.fianlCameraPosition,t=this.finalCameraTarget;if(e&&t&&this.controls&&this.camera){this.camera.position.set(e.x,e.y,e.z);let n=this.controls;n.target.set(t.x,t.y,t.z),n.update()}this.cameraUpdateInterval=void 0}this.fianlCameraPosition=void 0,this.finalCameraTarget=void 0}getHitResult(e){let t={location:null};if(!this.camera)return t;let n=this.getIntersection(e);return t.location=n?{x:n.point.x,y:n.point.y,z:n.point.z}:null,t}lookToPosition(e){var t;if(!this.camera)return;this.handleCameraUpdateInterval();let n=new O(e[0],e[1],e[2]).clone().sub(this.camera.position);null==(t=this.controlsHelper)||t.lookTo(n)}merge(e){this.increaseJobCount();try{let t=[];e.traverse((e=>{e.geometry&&e.material&&t.push(e)})),Ar.deepMerge(t,e)}finally{this.decreaseJobCount()}}},y2=class extends on{constructor(e=!0,t=!1){super(),this.name="COORDINATE_AXES",this.AXIS_LENGTH=1,this.AXIS_COLOR_X=16711680,this.AXIS_COLOR_Y=65280,this.AXIS_COLOR_Z=255;let n=new O(0,0,0),i=new O(1,0,0),r=new O(0,1,0),a=new Mc(i,n,this.AXIS_LENGTH,this.AXIS_COLOR_X,0,0),s=new Mc(r,n,this.AXIS_LENGTH,this.AXIS_COLOR_Y,0,0);if(this.add(a,s),!t){let e=new O(0,0,1),t=new Mc(e,n,this.AXIS_LENGTH,this.AXIS_COLOR_Z,0,0);this.add(t)}e&&this.addTexts(t)}addTexts(e=!1){let t=this.createText("X","#ff0000"),n=this.createText("Y","#00ff00");if(t.position.set(this.AXIS_LENGTH+.1,0,0),n.position.set(.1,this.AXIS_LENGTH,.1),this.add(t,n),!e){let e=this.createText("Z","#0000ff");e.position.set(0,0,this.AXIS_LENGTH+.1),this.add(e)}}createText(e,t,n=14){let i=document.createElement("div");i.innerHTML=e;let r=i.style;return r.color=t,r.width=`${n}px`,r.height=`${n}px`,r.textAlign="center",r.top="0px",r.left="0px",new zv(i)}},Yve=class extends dr{constructor(e,t){super(e,{id:"AxisGizmoPlugin"}),this.ignoreZAxis=!1,this.cfg=t||{},this.ignoreZAxis=!(null==t||!t.ignoreZAxis),this.hostCamera=e.camera,this.init()}init(){this.initRenderer(),this.initScene(),this.animate(),this.viewer.addEventListener("CameraChanged",(()=>{this.hostCamera=this.viewer.camera}))}initRenderer(){var e;let t,n=100,i=100;if(this.cfg.containerId&&(t=document.getElementById(this.cfg.containerId),t&&(n=t.clientWidth,i=t.clientHeight)),!t){let n="axisGizmo";t=document.createElement("div"),t.id=n,null==(e=this.viewer.widgetContainer)||e.appendChild(t)}this.renderer=new Ms({antialias:!0,alpha:!0}),this.renderer.setSize(n,i),t.appendChild(this.renderer.domElement),this.css2dRenderer=new Nu,this.css2dRenderer.setSize(n,i),this.css2dRenderer.domElement.style.height="0",this.css2dRenderer.domElement.style.width="0",t.appendChild(this.css2dRenderer.domElement)}initScene(){this.scene=new _i,this.camera=new Ur(-1,1,1,-1,.1,100),this.scene.add(this.camera),this.coordinateAxes=new y2(!0,this.ignoreZAxis),this.scene.add(this.coordinateAxes)}setHostCamera(e){this.hostCamera=e}render(){var e;!this.scene||!this.camera||(this.renderer&&(this.update(),this.renderer.render(this.scene,this.camera)),null==(e=this.css2dRenderer)||e.render(this.scene,this.camera))}animate(){requestAnimationFrame(this.animate.bind(this)),this.render()}update(){if(!this.hostCamera)return;let e=this.hostCamera;if(e){let t=new O;e.getWorldDirection(t);let n=e.up;this.updateCameraDirection(t,n)}}updateCameraDirection(e,t){if(!this.camera||!e)return;e.normalize();let n=.3;this.camera.position.set(2*-e.x+n,2*-e.y+n,2*-e.z+n),this.camera.lookAt(n,n,n),this.camera.up=t}destroy(){var e,t;super.destroy(),this.scene&&this.camera&&this.coordinateAxes&&(this.scene.clear(),this.scene=void 0,this.css2dRenderer&&(null==(e=this.container)||e.removeChild(this.css2dRenderer.domElement),this.css2dRenderer=void 0),this.renderer&&(null==(t=this.container)||t.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer=void 0),this.hostCamera=void 0,this.camera=void 0,this.coordinateAxes=void 0)}},cV=ji(Fl(),1),zvt="bottomBar",Gvt={"gemini-viewer-threejs-statistics":{icon:{default:"icon-info",active:"icon-info-filled",iconFont:"gemini-viewer-icon"},mutexIds:["gemini-viewer-threejs-cameraInfo","gemini-viewer-threejs-tips"],onActive:e=>{let t=document.createElement("span");if(!e.viewer.scene)return void(t.textContent="Failed!");t.textContent="Comupting...";let n={components:{},points:0,faces:0,materials:{},lights:{}},i=["SKYBOX","GROUND_GRID","GROUND_GRASS","BIM_VIEWER_BOX_HELPER"];e.viewer.scene.traverse((e=>{(e instanceof xt||e instanceof ur||e instanceof ii)&&!i.includes(e.name)?((e,t)=>{if(t.components[e.type]?t.components[e.type]++:t.components[e.type]=1,e.geometry){let n=e.geometry;if(e instanceof xt)if(n.index&&n.index.count){let i=Math.round(n.index.count/3);e instanceof Pi&&(i*=e.count),t.faces+=i}else if(n.groups.length>0)for(let e=0;e{t.materials[e]?t.materials[e]++:t.materials[e]=1},i=e.material;i instanceof vr?n(i.id):Array.isArray(i)&&i.forEach((e=>n(e.id)))})(e,n):e instanceof Ws&&(n.lights[e.type]?n.lights[e.type]++:n.lights[e.type]=1)}));let r=(e,n)=>{t.innerHTML+=`

${e}:${n}

`};t.innerHTML="";let a=` (${(e=>{var t;let n=null==(t=e.renderer)?void 0:t.domElement;return null==n?void 0:n.dataset.engine})(e.viewer)})`;r("Version",`${$E}${a}`),r("Components",JSON.stringify(n.components)),r("Points",n.points),r("Faces",n.faces),r("Materials",Object.keys(n.materials).length),r("Lights",JSON.stringify(n.lights)),"DxfViewer"===e.viewer.name&&r("Entities",e.viewer.getEntitiesCount()),e.tooltip.setContent(t),e.tooltip.show()},onDeactive:e=>{e.tooltip.hide()},onUpdate:e=>{let t=e.viewer.renderer,n=document.createElement("span"),i=(e,t)=>{n.innerHTML+=`

${e}:${t}

`};n.innerHTML="

-- Renderer Info --

";let r=null==t?void 0:t.info;i("Drawcalls",JSON.stringify(null==r?void 0:r.render.calls)),i("Points",JSON.stringify(null==r?void 0:r.render.points)),i("Lines",JSON.stringify(null==r?void 0:r.render.lines)),i("Triangles",JSON.stringify(null==r?void 0:r.render.triangles)),i("Geometries",JSON.stringify(null==r?void 0:r.memory.geometries)),i("Textures",JSON.stringify(null==r?void 0:r.memory.textures)),e.tooltip.updateChildContent(n)}},"gemini-viewer-threejs-cameraInfo":{icon:{default:"icon-view",active:"icon-view-filled",iconFont:"gemini-viewer-icon"},mutexIds:["gemini-viewer-threejs-statistics","gemini-viewer-threejs-tips"],onActive:e=>{let t=()=>{if(!e.viewer||!e.viewer.camera||!e.viewer.controls)return;let n=e.viewer.camera,i=e.viewer.controls,r=e=>Mt.numberToString(e),a=e=>Mt.vectorToString(e),s=n.position,o=i instanceof ba?i.getTarget(new O):i.target;if(s){let t=document.createElement("span");t.innerHTML=`\n

Camera position:${a(s)}

\n

Camera target:${a(o)}

`,n instanceof Ur&&(t.innerHTML+=`\n

top: ${r(n.top)}, bottom: ${r(n.bottom)}, left: ${r(n.left)}, right: ${r(n.right)}

\n

zoom: ${r(n.zoom)}

`),e.tooltip.setContent(t)}e.active||window.removeEventListener("mouseup",t)};if(t(),window.addEventListener("mouseup",t),"BimViewer"===e.viewer.name){let n=e.viewer.controls;null==n||n.addEventListener("update",t)}else e.viewer.controls.addEventListener("change",t);e.tooltip.show()},onDeactive:e=>{e.tooltip.hide()}},"gemini-viewer-threejs-tips":{icon:{default:"icon-more",iconFont:"gemini-viewer-icon"},mutexIds:["gemini-viewer-threejs-cameraInfo","gemini-viewer-threejs-cameraInfo"],onActive:e=>{let t=document.createElement("span");"BimViewer"===e.viewer.name?t.innerHTML="\n

W: Move forward

\n

A: Move backward

\n

S: Move left

\n

D: Move right

\n

Q: Rise up

\n

E: Lower down

\n

\u2191: Rotate up

\n

\u2193: Rotate down

\n

\u2190: Rotate to left

\n

\u2192: Rotate to right

\n ":"DxfViewer"===e.viewer.name?t.innerHTML="\n

\u2191: Move up

\n

\u2193: Move down

\n

\u2190: Move to left

\n

\u2192: Move to right

\n ":"VRViewer"===e.viewer.name?t.innerHTML="\n

\u2191: Rotate up

\n

\u2193: Rotate down

\n

\u2190: Rotate to left

\n

\u2192: Rotate to right

\n ":t.innerHTML="\n

Nothing to show

\n ",e.tooltip.setContent(t),e.tooltip.show()},onDeactive:e=>{e.tooltip.hide()}}},$ve=class extends dr{constructor(e){super(e,{id:"BottomBarPlugin"}),this.itemList=new Map,this.init()}update(){this.itemList.forEach((e=>{e.update()}))}init(){var e;let t=document.createElement("div");t.id=zvt,t.classList.add("bottom-bar"),(0,cV.forEach)(Gvt,((e,n)=>{let i=this.createItem(this.viewer,n,e);t.appendChild(i.element)})),this.element=t,null==(e=this.viewer.widgetContainer)||e.appendChild(this.element),this.viewer.addEventListener("AfterRender",(()=>{this.update()}))}createItem(e,t,n){let i=new lV(e,this,t,n);return this.itemList.set(t,i),i}},lV=class{constructor(e,t,n,i){this.viewer=e,this.bottomBar=t,this.menuId=n,this.cfg=i,this.eventBus=Ay(),this.active=!1,this.itemconfig=i,this.element=this.createButton(this.menuId,i),this.tooltip=new Yl(n+"-tooltip",null,{parentNode:e.widgetContainer}),this.eventBus.on("activeChange",(e=>{e?(this.element.classList.add("active"),(0,cV.forEach)(i.mutexIds,(e=>{var t;let n=null==(t=this.bottomBar)?void 0:t.itemList.get(e);n&&n.active&&n.setActive(!1)})),i.onActive&&i.onActive(this)):(this.element.classList.remove("active"),i.onDeactive&&i.onDeactive(this)),this.element instanceof HTMLElement&&wA(this.element.classList,i.icon,this.active)}))}createButton(e,t){let n=document.createElement("i");n.id=e;let{default:i="icon-new",iconFont:r=qv}=t.icon;return n.classList.add("icon"),n.classList.add(r),n.classList.add(i),n.onclick=()=>{this.active=!this.active,t.onClick&&t.onClick(this),this.eventBus.emit("activeChange",this.active)},n}setActive(e){this.active=e,this.eventBus.emit("activeChange",this.active)}update(){this.active&&this.itemconfig.onUpdate&&this.itemconfig.onUpdate(this)}},ug=ji(Fl(),1),k_=ji(Fl(),1),ds=ji(Fl(),1),x2=(e=>(e[e.ClickEvent=1]="ClickEvent",e[e.Popup=2]="Popup",e[e.SubMenu=3]="SubMenu",e[e.Switch=4]="Switch",e))(x2||{}),b2=(e=>(e.HomeView="HomeView",e.OrthoMode="OrthoMode",e.Measure="Measure",e.MeasureDistance="MeasureDistance",e.MeasureArea="MeasureArea",e.MeasureAngle="MeasureAngle",e.MeasureCoordinate="MeasureCoordinate",e.MeasureClear="MeasureClear",e.MarkupVisibility="MarkupVisibility",e.Markup="Markup",e.MarkupArrow="Arrow",e.MarkupRect="Rect",e.MarkupCloudRect="CloudRect",e.MarkupPolyLine="PolyLine",e.MarkupCloudLine="CloudLine",e.MarkupEllipse="Ellipse",e.MarkupCircle="Circle",e.MarkupDot="Dot",e.MarkupText="Text",e.MarkupX="X",e.MarkupStrokeStyle="StrokeStyle",e.MarkupLineWidth="LineWidth",e.MarkupLineWidth2="LineWidth2",e.MarkupLineWidth5="LineWidth5",e.MarkupLineWidth10="LineWidth10",e.MarkupFontSize="FontSize",e.MarkupFontSize14="FontSize14",e.MarkupFontSize18="FontSize18",e.MarkupFontSize24="FontSize24",e.MarkupClear="MarkupClear",e.MarkupQuit="MarkupQuit",e.Section="Section",e.SectionBox="SectionBox",e.SectionPlane="SectionPlane",e.SectionAxis="SectionAxis",e.BimTree="BimTree",e.Viewpoint="Viewpoint",e.Annotation="Annotation",e.Property="Property",e.Settings="Settings",e.Compared="Compared",e.QuitCompare="QuitCompare",e.Fullscreen="FullScreen",e.SceneClear="SceneClear",e.Layers="Layers",e.ZoomToRectangle="ZoomToRectangle",e.Screenshot="GetScreenshot",e))(b2||{}),E2=[["HomeView","OrthoMode","FullScreen","ZoomToRectangle","GetScreenshot"],["Measure","Markup","MarkupVisibility","Section"],["BimTree","Viewpoint","Annotation","Property","Compared","QuitCompare","Layers"],["Settings"]],ap=class{constructor(e,t,n=[]){this.visible=!0,this.menuList=new Map,this.keydown=e=>{var t,n;if(this.visible&&"Escape"===e.code){if(null!=(t=this.viewer.measurePlugin)&&t.isMeasuring()||null!=(n=this.viewer.getMarkupManager())&&n.isMarkupActive())return;this.clearActive()}},this.viewer=e,this.menuCfg=t,this.groupCfg=n,this.init(),window.addEventListener("keydown",this.keydown,!1)}init(){var e;let t=document.createElement("div");t.classList.add("toolbar");let n=this.menuCfg;this.groupCfg.forEach(((e,i)=>{let r=document.createElement("div");r.classList.add("toolbar-group");let a=document.createElement("div");a.classList.add("toolbar-group-division"),e.forEach((e=>{let t=(0,ds.get)(n,e);if(t&&!1!==t.visible){let n=this.createToolbarMenu(this.viewer,e,t);r.appendChild(n.element)}})),r.hasChildNodes()&&(i&&t.appendChild(a),t.appendChild(r))})),this.element=t,null==(e=this.viewer.widgetContainer)||e.appendChild(t),t.oncontextmenu=e=>{e.preventDefault()}}clearActive(){if(this.activateMenuId){let e=this.menuList.get(this.activateMenuId);null==e||e.setActive(!1),this.activateMenuId=void 0}}setActive(e,t){let n=this.menuList.get(e);null==n||n.setActive(t),this.activateMenuId=t?e:void 0}createToolbarMenu(e,t,n,i){let r=new uV(e,this,t,n,i);if(this.menuList.set(t,r),n.children){let t=document.createElement("div");t.classList.add("toolbar-sub-menu");let i=document.createElement("div");i.classList.add("toolbar-sub-menu-list"),t.appendChild(i),(0,ds.forIn)(n.children,((t,n)=>{if(t&&!1!==t.visible){let a=this.createToolbarMenu(e,n,t,r);i.appendChild(a.element)}})),r.element.appendChild(t)}return r}updateMenu(e,t){(0,ds.assign)(this.menuCfg[e],t),this.refresh()}updateMenus(e){(0,ds.forEach)(e,(({menuId:e,config:t})=>{(0,ds.assign)(this.menuCfg[e],t)})),this.refresh()}addMenu(e,t,n){if((0,ds.keys)(this.menuCfg).includes(e))se.error("[Toolbar]",e,"exists.");else{if((0,ds.assign)(this.menuCfg,{[e]:t}),n){let[t,i]=n;if(t>this.groupCfg.length-1)this.groupCfg=(0,ds.concat)(this.groupCfg,[[e]]);else{let n=this.groupCfg[t];this.groupCfg[t]=i>n.length-1?(0,ds.concat)(n,e):(0,ds.concat)((0,ds.take)(n,i),e,(0,ds.takeRight)(n,n.length-i))}}else this.groupCfg=(0,ds.concat)(this.groupCfg,[[e]]);this.refresh()}}refresh(){this.element&&this.element.remove(),this.element=void 0,this.menuList.clear(),this.init()}show(){this.element&&(this.element.style.display=""),this.visible=!0}hide(){this.element&&(this.element.style.display="none"),this.visible=!1}destroy(){this.element&&this.element.remove(),this.element=void 0,this.menuList.clear(),window.removeEventListener("keydown",this.keydown,!1)}},uV=class{constructor(e,t,n,i,r){this.eventBus=Ay(),this.toolbar=t,this.menuId=n,this.active=i.defaultActive||!1,this.element=i.customElement&&i.customElement(e,this.menuId,i)||this.createButton(e,this.menuId,i),this.eventBus.on("activeChange",(t=>{t?(this.element.classList.add("active"),(0,ds.forEach)(i.mutexIds,(e=>{var t;let n=null==(t=this.toolbar)?void 0:t.menuList.get(e);n&&n.active&&n.setActive(!1)})),i.onActive&&i.onActive(e)):(this.element.classList.remove("active"),i.onDeactive&&i.onDeactive(e)),this.element.firstChild instanceof HTMLElement&&wA(this.element.firstChild.classList,i.icon,this.active),r&&r.setActive(t)})),Dn.isMobile?(this.element.ontouchstart=t=>{switch(this.element.classList.toggle("toolbar-parent-menu-active"),this.element.classList.toggle("toolbar-menu-active"),t.stopPropagation(),i.type){case 1:i.onClick&&i.onClick(e,this.toolbar,t);break;case 4:i.onClick&&i.onClick(e,this.toolbar,t),this.active=!this.active,this.toolbar.activateMenuId=this.menuId,this.eventBus.emit("activeChange",this.active)}},this.element.addEventListener("touchend",(()=>{r&&r.element.classList.remove("toolbar-parent-menu-active")}))):(this.element.onclick=t=>{switch(t.stopPropagation(),i.type){case 1:i.onClick&&i.onClick(e,this.toolbar,t);break;case 4:i.onClick&&i.onClick(e,this.toolbar,t),this.active=!this.active,this.toolbar.activateMenuId=this.menuId,this.eventBus.emit("activeChange",this.active)}r&&r.element.classList.remove("toolbar-parent-menu-active")},this.element.addEventListener("mouseover",(()=>{this.element.classList.toggle("toolbar-parent-menu-active"),this.element.classList.add("toolbar-menu-active")})),this.element.addEventListener("mouseout",(()=>{this.element.classList.contains("toolbar-parent-menu-active")&&this.element.classList.remove("toolbar-parent-menu-active"),this.element.classList.remove("toolbar-menu-active")})))}createButton(e,t,n){let i=document.createElement("div");i.id=t,i.classList.add("toolbar-menu"),n.defaultActive&&i.classList.add("active"),n.children&&i.classList.add("toolbar-parent-menu");let{default:r="icon-new",iconFont:a=qv}=n.icon;return i.innerHTML=`
`,i.title=eh(n.menuName),i.innerHTML+=`${i.title}`,i}setActive(e){this.active=e,e?this.element.classList.add("toolbar-menu-active"):this.element.classList.remove("toolbar-menu-active"),this.eventBus.emit("activeChange",this.active)}},Zve={Arrow:{menuName:"Toolbar.markupArrow",icon:{default:"icon-arrow"},type:4,onActive:e=>{e.activateMarkup("ArrowMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","CloudLine","Ellipse","Circle","Dot","Text","X"]},Rect:{defaultActive:!1,menuName:"Toolbar.markupRect",icon:{default:"icon-rectangle"},type:4,onActive:e=>{e.activateMarkup("RectMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Arrow","CloudRect","PolyLine","CloudLine","Ellipse","Circle","Dot","Text","X"]},CloudRect:{defaultActive:!0,menuName:"Toolbar.markupCloudRect",icon:{default:"icon-cloud"},type:4,onActive:e=>{e.activateMarkup("CloudRectWithTextMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","Arrow","PolyLine","CloudLine","Ellipse","Circle","Dot","Text","X"]},PolyLine:{menuName:"Toolbar.markupPolyLine",icon:{default:"icon-polyline"},type:4,onActive:e=>{e.activateMarkup("PolylineMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","Arrow","CloudRect","CloudLine","Ellipse","Circle","Dot","Text","X"]},CloudLine:{menuName:"Toolbar.markupCloudLine",icon:{default:"icon-cloud-segment"},type:4,onActive:e=>{e.activateMarkup("CloudLineMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","Arrow","Ellipse","Circle","Dot","Text","X"]},Ellipse:{menuName:"Toolbar.markupEllipse",icon:{default:"icon-oval"},type:4,onActive:e=>{e.activateMarkup("EllipseMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","CloudLine","Arrow","Circle","Dot","Text","X"]},Circle:{menuName:"Toolbar.markupCircle",icon:{default:"icon-round"},type:4,onActive:e=>{e.activateMarkup("CircleMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","CloudLine","Ellipse","Arrow","Dot","Text","X"]},Dot:{menuName:"Toolbar.markupDot",icon:{default:"icon-round"},type:4,onActive:e=>{e.activateMarkup("DotMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","CloudLine","Ellipse","Arrow","Circle","Text","X"]},X:{menuName:"Toolbar.markupX",icon:{default:"icon-cross"},type:4,onActive:e=>{e.activateMarkup("XMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","CloudLine","Ellipse","Circle","Dot","Arrow","Text"]},Text:{menuName:"Toolbar.markupText",icon:{default:"icon-text"},type:4,onActive:e=>{e.activateMarkup("TextMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","CloudLine","Ellipse","Circle","Dot","Arrow","X"]},StrokeStyle:{menuName:"Toolbar.markupStroke",icon:{default:"icon-color-red"},type:1,onClick:(e,t,n)=>{let i=n.target.parentElement,r=null==i?void 0:i.firstElementChild,a=document.createElement("input");a.setAttribute("type","color"),a.value=Cn.rgba2Color(e.getMarkupLineColor()),a.click(),a.oninput=t=>{let n=t.target.value;e.setMarkupLineColor(...Cn.color2rgba(n)),r.style.color=n}}},LineWidth:{menuName:"Toolbar.markupLineWidth",icon:{default:"icon-line"},customElement(e,t,n){let i=document.createElement("div");return i.id=t,i.classList.add("toolbar-menu"),n.children&&i.classList.add("toolbar-parent-menu"),i.title=eh(n.menuName),i.innerHTML+=`${i.title}`,i},type:3,children:{LineWidth2:{defaultActive:!0,icon:{default:"icon-line-2"},onClick:e=>{e.setMarkupLineWidth(2)},type:4,menuName:"Toolbar.markupLineWidth2",mutexIds:["LineWidth5","LineWidth10"]},LineWidth5:{icon:{default:"icon-line-3"},onClick:e=>{e.setMarkupLineWidth(3)},type:4,menuName:"Toolbar.markupLineWidth5",mutexIds:["LineWidth2","LineWidth10"]},LineWidth10:{icon:{default:"icon-line-4"},onClick:e=>{e.setMarkupLineWidth(4)},type:4,menuName:"Toolbar.markupLineWidth10",mutexIds:["LineWidth2","LineWidth5"]}}},FontSize:{menuName:"Toolbar.markupFontSize",icon:{default:"icon-font"},customElement(e,t,n){let i=document.createElement("div");return i.id=t,i.classList.add("toolbar-menu"),n.children&&i.classList.add("toolbar-parent-menu"),i.title=eh(n.menuName),i.innerHTML+=`${i.title}`,i},type:3,children:{FontSize14:{icon:{default:"icon-font14"},onClick:e=>{e.setMarkupFontSize(14)},type:4,menuName:"",mutexIds:["FontSize18","FontSize24"]},FontSize18:{defaultActive:!0,icon:{default:"icon-font18"},onClick:e=>{e.setMarkupFontSize(18)},type:4,menuName:"",mutexIds:["FontSize14","FontSize24"]},FontSize24:{icon:{default:"icon-font24"},onClick:e=>{e.setMarkupFontSize(24)},type:4,menuName:"",mutexIds:["FontSize14","FontSize18"]}}},MarkupClear:{icon:{default:"icon-eraser"},onClick:e=>{se.info("[Toolbar]","Clear Markup",e),e.clearMarkups()},type:1,menuName:"Toolbar.clearMarkup"},MarkupQuit:{icon:{default:""},customElement(e,t,n){let i=document.createElement("div");return i.id=t,i.classList.add("toolbar-menu"),n.children&&i.classList.add("toolbar-parent-menu"),i.title=eh(n.menuName),i.innerHTML+=`${i.title}`,i},onClick:e=>{var t;null==(t=e.getMarkupManager())||t.deactivate(),e.dispatchEvent("MarkupDeactivated")},type:1,menuName:"Toolbar.quitMarkup"}},Kve=[["Arrow","Rect","CloudRect","PolyLine","Ellipse","Circle","Text","StrokeStyle","FontSize","MarkupClear","MarkupQuit"]],_2=class extends ap{constructor(e,t,n=[]){super(e,t,n),this.keydown=()=>{}}},Wy=class{constructor(e,t,n=document.body){this.container=n,this.isFollowing=!1,this.diffX=0,this.diffY=0,this.start=e=>{this.isFollowing=!0,this.diffX=e.clientX-this.element.offsetLeft,this.diffY=e.clientY-this.element.offsetTop},this.stop=()=>{this.isFollowing=!1},this.follow=e=>{if(!this.isFollowing)return;let t=e.clientX-this.diffX,n=e.clientY-this.diffY;this.element.style.left=t+"px",this.element.style.top=n+"px"},this.element=document.createElement("div"),this.element.id=e,this.element.classList.add("pop-panel");let i=document.createElement("div");i.classList.add("pop-panel-header"),i.append(t),this.element.appendChild(i),this.header=i;let r=document.createElement("div");r.classList.add("pop-panel-body"),this.element.appendChild(r),this.body=r,i.addEventListener(wH,this.start),i.addEventListener(TH,this.stop),document.body.addEventListener(wf,this.follow),this.container.appendChild(this.element)}destroy(){document.body.removeEventListener(wf,this.follow),this.element.removeEventListener(wH,this.start),this.element.removeEventListener(TH,this.stop),this.element.remove()}},T2=class extends Wy{constructor(e){super("axis-section-pop-panel","\u8f74\u5411\u5256\u5207",e.widgetContainer),this.axis="x",this.isVisible=!0,this.keydown=e=>{"Escape"===e.code&&this.destroy()},this.section=e.getActiveSection(),this.createGroupSelectLayout(),this.addGroupSelectItems(),this.createActiveSelectLayout(),this.addActiveItems(),window.addEventListener("keydown",this.keydown)}destroy(){super.destroy(),window.removeEventListener("keydown",this.keydown)}createGroupSelectLayout(){let e=document.createElement("div");e.classList.add("pop-panel-group-select"),this.body.appendChild(e),this.groupSelectNode=e}addGroupSelectItems(){let e=(e,t,n=!1)=>{let i=document.createElement("div");return i.classList.add("pop-panel-item"),i.setAttribute("itemName",e),i.append(t),n&&i.classList.add("active"),this.groupSelectNode&&this.groupSelectNode.appendChild(i),i},t=(e,t)=>a=>{a.stopPropagation(),this.activeItem!==e&&(n.classList.remove("active"),i.classList.remove("active"),r.classList.remove("active"),this.activeItem=e,t.classList.add("active"),this.section.setActiveAxis(e))},n=e("X","X",!0);n.onclick=t("X",n);let i=e("Y","Y");i.onclick=t("Y",i);let r=e("Z","Z");r.onclick=t("Z",r)}createActiveSelectLayout(){let e=document.createElement("div");e.classList.add("pop-panel-active-select"),this.body.appendChild(e),this.activeSelectNode=e}addActiveItems(){let e=(e,t)=>{let n=document.createElement("i");n.classList.add(qv),n.classList.add(t),e.innerHTML="",e.appendChild(n)},t=((t,n,i="")=>{let r=document.createElement("div");return r.classList.add("pop-panel-item"),n&&r.setAttribute("title",n),r.setAttribute("itemName",t),r.setAttribute("isActive","false"),e(r,i),r})("visible","\u9690\u85cf\u5256\u5207\u9762","icon-hidesectionplane");t.onclick=()=>{this.isVisible=!this.isVisible,this.isVisible?(e(t,"icon-hidesectionplane"),t.setAttribute("title","\u9690\u85cf\u5256\u5207\u9762")):(e(t,"icon-showsectionplane"),t.setAttribute("title","\u663e\u793a\u5256\u5207\u9762")),this.section.setSectionVisible(this.isVisible)}}},w2=class extends Wy{constructor(e){super("pick-section-pop-panel","\u62fe\u53d6\u9762\u5256\u5207",e.widgetContainer),this.isVisible=!0,this.enabled=!0,this.keydown=e=>{"Escape"===e.code&&this.destroy()},this.section=e.getActiveSection(),this.createActiveSelectLayout(),this.addActiveItems(),window.addEventListener("keydown",this.keydown)}destroy(){super.destroy(),window.removeEventListener("keydown",this.keydown)}createActiveSelectLayout(){let e=document.createElement("div");e.classList.add("pop-panel-active-select"),this.body.appendChild(e),this.activeSelectNode=e}addActiveItems(){let e=(e,t)=>{let n=document.createElement("i");n.classList.add("gemini-viewer-icon"),n.classList.add(t),e.innerHTML="",e.appendChild(n)},t=(t,n,i="")=>{let r=document.createElement("div");return r.classList.add("pop-panel-item"),n&&r.setAttribute("title",n),r.setAttribute("itemName",t),r.setAttribute("isActive","false"),e(r,i),r},n=t("visible","\u9690\u85cf\u5256\u5207\u9762","icon-hidesectionplane");n.onclick=()=>{this.enabled&&(this.isVisible=!this.isVisible,this.isVisible?(e(n,"icon-hidesectionplane"),n.setAttribute("title","\u9690\u85cf\u5256\u5207\u9762")):(e(n,"icon-showsectionplane"),n.setAttribute("title","\u663e\u793a\u5256\u5207\u9762")),this.section.setSectionVisible(this.isVisible))},this.activeSelectNode&&this.activeSelectNode.appendChild(n),this.visibleNode=n;let i=t("reset","\u91cd\u7f6e","icon-reset");i.onclick=t=>{t.stopPropagation(),this.enabled&&(this.isVisible=!0,e(n,"icon-hidesectionplane"),n.setAttribute("title","\u9690\u85cf\u5256\u5207\u9762"),this.section.resetSection())},this.activeSelectNode&&this.activeSelectNode.appendChild(i),this.resetNode=i}enable(){this.enabled=!0,this.visibleNode&&this.visibleNode.classList.remove("disable")}disable(){this.enabled=!1,this.visibleNode&&this.visibleNode.classList.add("disable")}},Ma,Jve={HomeView:{icon:{default:"icon-home",active:"icon-home-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.homeView",type:1,onClick:e=>{e.goToHomeView()}},OrthoMode:{icon:{default:"icon-orthomode",active:"icon-orthomode-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.orthoView",type:4,onActive:e=>{se.info("[Toolbar]","Enter OrthoMode"),e.setToOrthographicCamera(!0)},onDeactive:e=>{se.info("[Toolbar]","Exit OrthoMode"),e.setToOrthographicCamera(!1)}},Measure:{icon:{default:"icon-measure",active:"icon-measure-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.measurement",type:3,children:{MeasureDistance:{icon:{default:"icon-measure-distance"},menuName:"Toolbar.distanceMeasurement",onActive:e=>{let t=e;t.deactivateSection(),t.activateMeasurement("Distance")},onDeactive:e=>{e.deactivateMeasurement()},type:4,mutexIds:["MeasureArea","MeasureAngle","MeasureCoordinate"]},MeasureArea:{icon:{default:"icon-measure-area-color"},onActive:e=>{let t=e;t.deactivateSection(),t.activateMeasurement("Area")},onDeactive:e=>{e.deactivateMeasurement()},type:4,menuName:"Toolbar.areaMeasurement",mutexIds:["MeasureDistance","MeasureAngle","MeasureCoordinate"]},MeasureAngle:{menuName:"Toolbar.angleMeasurement",icon:{default:"icon-angle-measure"},type:4,onActive:e=>{let t=e;t.deactivateSection(),t.activateMeasurement("Angle")},onDeactive:e=>{e.deactivateMeasurement()},mutexIds:["MeasureDistance","MeasureArea","MeasureCoordinate"]},MeasureCoordinate:{menuName:"Toolbar.coordinateMeasurement",icon:{default:"icon-distancemeasure",iconFont:"gemini-viewer-icon"},type:4,onActive:e=>{let t=e;t.deactivateSection(),t.activateMeasurement("Coordinate")},onDeactive:e=>{e.deactivateMeasurement()},mutexIds:["MeasureDistance","MeasureArea","MeasureAngle"]},MeasureClear:{icon:{default:"icon-clear",active:"icon-clear-filled",iconFont:"gemini-viewer-icon"},onClick:e=>{let t=e;se.debug("[Toolbar]","Clearing Measure",e),t.clearMeasurements()},type:1,menuName:"Toolbar.clearMeasurement"}},mutexIds:["Section","SectionAxis","SectionBox","SectionPlane"]},Section:{icon:{default:"icon-section",active:"icon-section-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.section",type:3,children:{SectionAxis:{icon:{default:"icon-sectionplane",active:"icon-sectionplane-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.axisSection",type:4,onActive:e=>{let t=e;t.deactivateMeasurement(),t.getMeasurements().forEach((e=>t.setMeasurementVisibility(e.id,!1))),null==Ma||Ma.destroy(),t.activateSection("AxisPlaneSection"),Ma=new T2(t)},onDeactive:e=>{let t=e;t.getMeasurements().forEach((e=>t.setMeasurementVisibility(e.id,!0))),t.deactivateSection(),null==Ma||Ma.destroy(),Ma=void 0},mutexIds:["SectionBox","SectionPlane"]},SectionPlane:{icon:{default:"icon-choosesectionplane",active:"icon-choosesectionplane-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.pickSectionPlane",type:4,onActive:e=>{let t=e;t.deactivateMeasurement(),t.getMeasurements().forEach((e=>t.setMeasurementVisibility(e.id,!1))),null==Ma||Ma.destroy(),t.activateSection("PickPlaneSection"),Ma=new w2(t)},onDeactive:e=>{let t=e;t.getMeasurements().forEach((e=>t.setMeasurementVisibility(e.id,!0))),t.deactivateSection(),null==Ma||Ma.destroy(),Ma=void 0},mutexIds:["SectionAxis","SectionBox"]},SectionBox:{icon:{default:"icon-sectionbox",active:"icon-sectionbox-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.sectionBox",type:4,onActive:e=>{let t=e;t.deactivateMeasurement(),t.getMeasurements().forEach((e=>t.setMeasurementVisibility(e.id,!1))),t.activateSection()},onDeactive:e=>{let t=e;t.getMeasurements().forEach((e=>t.setMeasurementVisibility(e.id,!0))),t.deactivateSection()},mutexIds:["SectionAxis","SectionPlane"]}},mutexIds:["Measure","MeasureDistance","MeasureArea","MeasureAngle","MeasureCoordinate"]},BimTree:{icon:{default:"icon-bimtree",active:"icon-bimtree-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.bimTree",type:4,onActive:()=>{se.info("[Toolbar]","Activate Bim Tree")},onDeactive:()=>{se.info("[Toolbar]","Deactivate Bim Tree")},visible:!1},Viewpoint:{icon:{default:"icon-viewpoint",active:"icon-viewpoint-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.viewpoint",type:4,onActive:()=>{se.info("[Toolbar]","Activate Viewpoint")},onDeactive:()=>{se.info("[Toolbar]","Deactivate Viewpoint")},visible:!1},Annotation:{icon:{default:"icon-annotation",active:"icon-annotation-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.annotation",type:4,onActive:()=>{se.info("[Toolbar]","Activate Annotation")},onDeactive:()=>{se.info("[Toolbar]","Deactivate Annotation")},visible:!1},Property:{icon:{default:"icon-property",active:"icon-property-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.property",type:4,onActive:()=>{se.info("[Toolbar]","Activate Property")},onDeactive:()=>{se.info("[Toolbar]","Deactivate Property")},visible:!1},Settings:{icon:{default:"icon-settings",active:"icon-settings-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.settings",type:4,onActive:()=>{se.info("[Toolbar]","Activate Settings")},onDeactive:()=>{se.info("[Toolbar]","Deactivate Settings")},visible:!1},FullScreen:{icon:{default:"icon-fullscreen",active:"icon-fullscreen-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.fullscreen",type:4,onClick:(e,t)=>{var n;let i=()=>{let e=null==t?void 0:t.menuList.get("FullScreen");e&&e.setActive(Mt.isFullScreen())};Mt.isFullScreen()?(Mt.exitFullscreen(),window.removeEventListener("resize",i)):Mt.fullScreen(null==(n=e.viewerContainer)?void 0:n.parentElement),window.addEventListener("resize",i)}}},Qve={HomeView:{icon:{default:"icon-zhushitu",active:"icon-zhushitu"},menuName:"Toolbar.homeView",type:1,onClick:e=>{e.goToHomeView()}},ZoomToRectangle:{icon:{default:"icon-kuangxuanfangda",active:"icon-kuangxuanfangda"},menuName:"Toolbar.zoomToRectangle",type:4,onClick:(e,t)=>{let n=e;n.removeEventListener("BoxSelectDeactivated"),n.addEventListener("BoxSelectDeactivated",(()=>{null==t||t.setActive("ZoomToRectangle",!1)})),n.zoomToRect()},mutexIds:["GetScreenshot"]},GetScreenshot:{icon:{default:"icon-frame-clipping",active:"icon-frame-clipping"},menuName:"Toolbar.screenshot",type:4,onClick:(e,t)=>{let n=e;n.removeEventListener("BoxSelectDeactivated"),n.addEventListener("BoxSelectDeactivated",(()=>{null==t||t.setActive("GetScreenshot",!1)})),n.getScreenshot().then((e=>{if(se.info("[Toolbar] getScreenshot() returns:",null==e?void 0:e.base64Image),null==e||!e.base64Image)throw"[Toolbar] Image data is empty!";let t=document.createElement("a");t.href=null==e?void 0:e.base64Image,t.download="",t.click()})).catch((e=>{se.error("[Toolbar] Failed to get screenshot, reason:",e),null==t||t.setActive("GetScreenshot",!1)}))},mutexIds:["ZoomToRectangle"]},Measure:{icon:{default:"icon-celiang1",active:"icon-celiang1"},menuName:"Toolbar.measurement",type:3,children:{MeasureDistance:{icon:{default:"icon-measure-distance"},menuName:"Toolbar.distanceMeasurement",onActive:e=>{e.activateMeasurement("Distance")},onDeactive:e=>{e.deactivateMeasurement()},type:4,mutexIds:["MeasureArea","MeasureAngle","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureArea:{icon:{default:"icon-measure-area-color"},onActive:e=>{e.activateMeasurement("Area")},onDeactive:e=>{e.deactivateMeasurement()},type:4,menuName:"Toolbar.areaMeasurement",mutexIds:["MeasureDistance","MeasureAngle","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureAngle:{menuName:"Toolbar.angleMeasurement",icon:{default:"icon-angle-measure"},type:4,onActive:e=>{e.activateMeasurement("Angle")},onDeactive:e=>{e.deactivateMeasurement()},mutexIds:["MeasureDistance","MeasureArea","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureCoordinate:{menuName:"Toolbar.coordinateMeasurement",icon:{default:"icon-distancemeasure",iconFont:"gemini-viewer-icon"},type:4,onActive:e=>{e.activateMeasurement("Coordinate")},onDeactive:e=>{e.deactivateMeasurement()},visible:!1,mutexIds:["MeasureDistance","MeasureArea","MeasureAngle","ZoomToRectangle","GetScreenshot"]},MeasureClear:{icon:{default:"icon-clear",active:"icon-clear-filled",iconFont:"gemini-viewer-icon"},onClick:e=>{let t=e;se.debug("[Toolbar]","Clearing Measure",e),t.clearMeasurements()},type:1,menuName:"Toolbar.clearMeasurement"}}},Markup:{icon:{default:"icon-annotation"},menuName:"Toolbar.markup",type:1,onClick:(e,t)=>{let n=e;null==t||t.updateMenu("Measure",{defaultActive:!1}),null==t||t.setActive("ZoomToRectangle",!1),n.getMarkups().forEach((e=>n.setMarkupVisibility(e.id,!0))),null==t||t.setActive("MarkupVisibility",!1),n.activateMarkup("CloudRectWithTextMarkup"),e.dispatchEvent("MarkupActivated")}},MarkupVisibility:{icon:{default:"icon-annotation-show",active:"icon-annotation-hide"},menuName:"Toolbar.markupVisibility",type:4,onActive:e=>{let t=e;t.getMarkups().forEach((e=>t.setMarkupVisibility(e.id,!1)))},onDeactive:e=>{let t=e;t.getMarkups().forEach((e=>t.setMarkupVisibility(e.id,!0)))},visible:!0},Settings:{icon:{default:"icon-settings",active:"icon-settings-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.settings",type:4,onActive:()=>{se.info("[Toolbar]","Activate Settings")},onDeactive:()=>{se.info("[Toolbar]","Deactivate Settings")},visible:!0},Compared:{icon:{default:"icon-compared"},menuName:"Toolbar.compared",type:4,onActive:()=>{se.info("[Toolbar]","Activate Compare")},onDeactive:()=>{se.info("[Toolbar]","Deactivate Compare")},visible:!1},QuitCompare:{icon:{default:"icon-compared"},menuName:"Toolbar.quitCompare",type:4,onActive:()=>{se.info("[Toolbar]","Activate Compare")},onDeactive:()=>{se.info("[Toolbar]","Deactivate Compare")},visible:!1},Layers:{icon:{default:"icon-tucengkongzhi",active:"icon-tucengkongzhi"},menuName:"Toolbar.layers",type:4,onClick:()=>{}},FullScreen:{icon:{default:"icon-quanping",active:"icon-quanping"},menuName:"Toolbar.fullscreen",type:4,onClick:(e,t)=>{var n;let i=()=>{let e=null==t?void 0:t.menuList.get("FullScreen");e&&e.setActive(Mt.isFullScreen())};Mt.isFullScreen()?(Mt.exitFullscreen(),window.removeEventListener("resize",i)):Mt.fullScreen(null==(n=e.viewerContainer)?void 0:n.parentElement),window.addEventListener("resize",i)}}},eye=class extends dr{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||"DxfViewerToolbarPlugin"}),this.onMarkupActivated=()=>{if(!this.markupToolbar){let e=(0,k_.merge)(this.cfg.markupMenuCfg||[],Zve),t=(0,k_.merge)(this.cfg.markupGroupCfg||[],Kve);this.markupToolbar=new _2(this.viewer,e,t),this.markupToolbar.hide()}this.toolbar.hide(),this.markupToolbar.show()},this.onMarkupDeactivated=()=>{var e;null==(e=this.markupToolbar)||e.hide(),this.toolbar.show()},this.cfg=t||{};let n=(0,k_.merge)({},Qve,this.cfg.menuConfig),i=(0,k_.merge)(this.cfg.groupConfig||[],E2);this.toolbar=new ap(e,n,i),this.viewer.addEventListener("MarkupActivated",this.onMarkupActivated),this.viewer.addEventListener("MarkupDeactivated",this.onMarkupDeactivated)}setActive(e,t){this.toolbar.setActive(e,t)}destroy(){super.destroy()}},nye=ji(Fl(),1),tye=class extends dr{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||"BimViewerToolbarPlugin"}),this.cfg=t||{};let n=(0,nye.merge)({},Jve,this.cfg.menuConfig),i=this.cfg.groupConfig||E2;this.toolbar=new ap(e,n,i)}setActive(e,t){this.toolbar.setActive(e,t)}destroy(){super.destroy()}},So=e=>({viewer:t})=>t.translate(`ContextMenu.${e}`),iye=e=>{var t;let n=0;return null==(t=e.scene)||t.traverseVisible((e=>{e instanceof xt&&n++})),n>0},qvt=e=>{var t,n;let i=0;return null==(t=e.scene)||t.traverse((e=>{e instanceof xt&&i++})),null==(n=e.scene)||n.traverseVisible((e=>{e instanceof xt&&i--})),i>0},hV=e=>e.hasTransparentObject(),S2=e=>zn.isObjectSelectable(e),rye=(e,t,n,i)=>{let r=e.selectedObject;return!(!r||!t||r.id!==t.id)&&(null!=n&&r.isInstancedMesh?n===r.userData.instanceId:null==i||!Ar.isMergedMesh(r)||i===r.userData.batchId)},Wvt={getTitle:So("viewFitEntity"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{e.flyToObject(t)}},jvt={getTitle:So("viewFitAll"),getEnabled:({viewer:e})=>iye(e),doAction:({viewer:e})=>e.viewFitAll()},Xvt={getTitle:So("hideEntity"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{let n=e;S2(t)&&(n.clearSelection(),t.visible=!1,n.enableRender())}},Yvt={getTitle:So("hideOthers"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{var n;let i=e;i.clearSelection(),null==(n=i.scene)||n.traverse((e=>{e instanceof xt&&S2(e)&&(e.visible=!1)})),t.visible=!0,i.enableRender()}},$vt={getTitle:So("hideAll"),getEnabled:({viewer:e})=>iye(e),doAction:({viewer:e})=>{var t;let n=e;n.clearSelection(),null==(t=n.scene)||t.traverse((e=>{e instanceof xt&&S2(e)&&(e.visible=!1)})),n.enableRender()}},Zvt={getTitle:So("showAll"),getEnabled:({viewer:e})=>qvt(e),doAction:({viewer:e})=>{var t;let n=e;null==(t=n.scene)||t.traverse((e=>{e instanceof xt&&S2(e)&&(e.visible=!0)})),n.enableRender()}},Kvt={getTitle:({hit:e,viewer:t,instanceId:n,batchId:i})=>rye(t,e,n,i)?So("deselect")({viewer:t}):So("select")({viewer:t}),getShown:({hit:e,viewer:t})=>t.enableSelection&&e,doAction:({hit:e,viewer:t,instanceId:n,batchId:i})=>{let r=t;zn.isObjectSelectable(e)?rye(r,e,n,i)?r.clearSelection():r.selectObject(e,e.instanceId,i):se.debug(`[ContextMenu] object(type: ${e.type}, name: ${e.name}) not selectable!`)}},Jvt={getTitle:So("selectNone"),getShown:({viewer:e})=>e.enableSelection,getEnabled:({viewer:e})=>e.selectedObject,doAction:({viewer:e})=>e.clearSelection()},Qvt={getTitle:So("xRayAll"),getShown:({viewer:e})=>!hV(e),doAction:({viewer:e})=>{let t=e;t.clearSelection(),t.addOrRemoveObjectOpacity(!0),t.enableRender()}},eyt={getTitle:So("xRayNone"),getEnabled:({viewer:e})=>hV(e),doAction:({viewer:e})=>{let t=e;t.clearSelection(),hV(t)&&(t.addOrRemoveObjectOpacity(!1),t.enableRender())}},tyt={getTitle:So("xRayEntity"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{let n=e;n.clearSelection(),n.addOrRemoveObjectOpacity(!0,void 0,[t.id],void 0)}},nyt={getTitle:So("xRayOthers"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{let n=e;n.clearSelection(),n.addOrRemoveObjectOpacity(!0,.1,void 0,[t.id]),n.enableRender()}},ryt={getTitle:({viewer:e})=>{let t=e,n="";switch(t.sectionType){case"PickPlaneSection":n="*showSectionPlane";break;case"AxisPlaneSection":n="showAxisSection";break;case"ObjectsBoxSection":n="*showSectionBox"}return t.translate(`ContextMenu.${n}`)},getShown:({viewer:e,section:t})=>{let n=e;return("PickPlaneSection"===n.sectionType||"AxisPlaneSection"===n.sectionType)&&!!t&&!t.showSectionPlane},doAction:({viewer:e,section:t})=>{let n=e;("PickPlaneSection"===n.sectionType||"AxisPlaneSection"===n.sectionType)&&(null==t||t.setSectionVisible(!0))}},iyt={getTitle:({viewer:e})=>{let t=e,n="";switch(t.sectionType){case"PickPlaneSection":n="hideSectionPlane";break;case"AxisPlaneSection":n="hideAxisSection";break;case"ObjectsBoxSection":n="hideSectionBox"}return t.translate(`ContextMenu.${n}`)},getShown:e=>sye(e),doAction:({viewer:e,section:t})=>{let n=e;("PickPlaneSection"===n.sectionType||"AxisPlaneSection"===n.sectionType)&&(null==t||t.setSectionVisible(!1))}},syt={getTitle:So("undoSection"),getShown:e=>sye(e),doAction:({viewer:e,toolbar:t})=>{let n=e;if("PickPlaneSection"===n.sectionType){let e=null==t?void 0:t.menuList.get("SectionPlane");null==e||e.setActive(!1)}else if("AxisPlaneSection"===n.sectionType){let e=null==t?void 0:t.menuList.get("SectionAxis");null==e||e.setActive(!1)}else if("ObjectsBoxSection"===n.sectionType){let e=null==t?void 0:t.menuList.get("SectionBox");null==e||e.setActive(!1)}}},sye=({viewer:e,hit:t,section:n})=>{let i=e;return("PickPlaneSection"===i.sectionType||"AxisPlaneSection"===i.sectionType)&&!!n&&n.showSectionPlane&&(null==t?void 0:t.name)===SH},aye=[[ryt],[iyt,syt],[Wvt,jvt],[Xvt,Yvt,$vt,Zvt],[tyt,nyt,Qvt,eyt],[Kvt,Jvt]],oye=class extends dr{constructor(e){super(e,{id:"ContextMenuPlugin"}),this.itemList=[],this.handleClick=()=>{this.hide()},this.container=e.widgetContainer||document.body,this.context={viewer:e},this.element=this.createMenuUI(aye||[]),window.oncontextmenu=e=>e.preventDefault(),this.hide(),this.initEvents()}initEvents(){let e=this.viewer.getInputManager();if(!e)return;let t=!1,n=!1,i=0,r=0;e.addEventListener("pointerdown",(()=>{n=!1,t=!0,this.hide()})),e.addEventListener("pointermove",(e=>{t&&!n&&(n=!(e=>-1!==i&&-1!==r&&Math.abs(e.x-i)<5&&Math.abs(e.y-r)<5)(e))})),e.addEventListener("pointerup",(e=>{if(t=!1,n)return n=!1,void this.hide();i=e.x,r=e.y,2===e.button?this.showContextMenu(e):this.hide()})),document.addEventListener("click",this.handleClick)}showContextMenu(e){let t=this.context,n=this.viewer;if(n.selectedObject){let e=n.selectedObject.userData.instanceId,i=n.selectedObject.userData.batchId;this.context=Ri(wr({},t),{hit:n.selectedObject,instanceId:e,batchId:i})}else{let i=n.getRaycaster();i&&i.layers.set(10);let r=n.getAllIntersections(e);se.debug("[Viewer] showContextMenu intersections = ",r);let a,s=(0,ug.find)(r,(e=>{let t=e.object;return t instanceof xt&&t.visible})),o=null==s?void 0:s.instanceId,l=null==s?void 0:s.faceIndex;l&&(a=Ar.getBatchIdByFaceIndex(null==s?void 0:s.object,l)),this.context=Ri(wr({},t),{hit:null==s?void 0:s.object,instanceId:o,batchId:a})}let{x:i,y:r}=e;this.show(i,r)}isEnabled(e){return e.getEnabled?e.getEnabled(this.context):void 0===e.enabled||e.enabled}isShown(e){return e.getShown?e.getShown(this.context):void 0===e.shown||e.shown}getTitle(e){return e.title||e.getTitle&&e.getTitle(this.context)||""}createMenuUI(e){let t=document.createElement("div");t.id=this.id,t.classList.add("context-menu");let n=this.createMenuGroup(e);return t.append(...n),this.container.appendChild(t),t}createMenuGroup(e){return(0,ug.map)(e,(e=>{let t=document.createElement("ul");return(0,ug.forEach)(e,(e=>{let n=this.createMenuItem(e);t.append(n)})),t}))}createMenuItem(e){let t=document.createElement("li");return t.innerHTML=this.getTitle(e),t.onclick=()=>e.doAction&&e.doAction(this.context),this.isEnabled(e)?t.classList.remove("disabled"):t.classList.add("disabled"),this.isShown(e)?t.removeAttribute("hidden"):t.setAttribute("hidden",""),this.itemList.push([e,t]),t}updateMenuItems(){(0,ug.forEach)(this.itemList,(([e,t])=>{this.isEnabled(e)?t.classList.remove("disabled"):t.classList.add("disabled"),this.isShown(e)?t.removeAttribute("hidden"):t.setAttribute("hidden",""),t.innerHTML=this.getTitle(e)}))}showMenuElement(e,t){let n=this.element.offsetHeight,i=this.element.offsetWidth;t+n>window.innerHeight&&(t=window.innerHeight-n-5),e+i>window.innerWidth&&(e=window.innerWidth-i-5),this.element.style.left=e+"px",this.element.style.top=t+"px"}show(e,t){this.updateMenuItems(),this.element.removeAttribute("hidden"),this.showMenuElement(e,t)}hide(){this.element.setAttribute("hidden","")}destroy(){document.removeEventListener("click",this.handleClick),this.container.removeChild(this.element)}};function ayt(e){if(e&&"undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}function Yy(e,t){var n=e.__state.conversionName.toString(),i=Math.round(e.r),r=Math.round(e.g),a=Math.round(e.b),s=e.a,o=Math.round(e.h),l=e.s.toFixed(1),h=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var c=e.hex.toString(16);c.length<6;)c="0"+c;return"#"+c}return"CSS_RGB"===n?"rgb("+i+","+r+","+a+")":"CSS_RGBA"===n?"rgba("+i+","+r+","+a+","+s+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+i+","+r+","+a+"]":"RGBA_ARRAY"===n?"["+i+","+r+","+a+","+s+"]":"RGB_OBJ"===n?"{r:"+i+",g:"+r+",b:"+a+"}":"RGBA_OBJ"===n?"{r:"+i+",g:"+r+",b:"+a+",a:"+s+"}":"HSV_OBJ"===n?"{h:"+o+",s:"+l+",v:"+h+"}":"HSVA_OBJ"===n?"{h:"+o+",s:"+l+",v:"+h+",a:"+s+"}":"unknown format"}var lye=Array.prototype.forEach,F_=Array.prototype.slice,Ht={BREAK:{},extend:function(e){return this.each(F_.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(t[n])||(e[n]=t[n])}.bind(this))}),this),e},defaults:function(e){return this.each(F_.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(e[n])&&(e[n]=t[n])}.bind(this))}),this),e},compose:function(){var e=F_.call(arguments);return function(){for(var t=F_.call(arguments),n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e)if(lye&&e.forEach&&e.forEach===lye)e.forEach(t,n);else if(e.length===e.length+0){var i,r=void 0;for(r=0,i=e.length;r1?Ht.toArray(arguments):arguments[0];return Ht.each(oyt,(function(t){if(t.litmus(e))return Ht.each(t.conversions,(function(t,n){if(N_=t.read(e),!1===M2&&!1!==N_)return M2=N_,N_.conversionName=n,N_.conversion=t,Ht.BREAK})),Ht.BREAK})),M2},cye=void 0,A2={hsv_to_rgb:function(e,t,n){var i=Math.floor(e/60)%6,r=e/60-Math.floor(e/60),a=n*(1-t),s=n*(1-r*t),o=n*(1-(1-r)*t),l=[[n,o,a],[s,n,a],[a,n,o],[a,s,n],[o,a,n],[n,a,s]][i];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var i=Math.min(e,t,n),r=Math.max(e,t,n),a=r-i,s=void 0;return 0===r?{h:NaN,s:0,v:0}:(s=e===r?(t-n)/a:t===r?2+(n-e)/a:4+(e-t)/a,(s/=6)<0&&(s+=1),{h:360*s,s:a/r,v:r/255})},rgb_to_hex:function(e,t,n){var i=this.hex_with_component(0,2,e);return i=this.hex_with_component(i,1,t),this.hex_with_component(i,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(cye=8*t)|e&~(255<-1?t.length-t.indexOf(".")-1:0}var Eye=function(e){function t(e,n,i){Yc(this,t);var r=cp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=i||{};return r.__min=a.min,r.__max=a.max,r.__step=a.step,Ht.isUndefined(r.__step)?0===r.initialValue?r.__impliedStep=1:r.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(r.initialValue))/Math.LN10))/10:r.__impliedStep=r.__step,r.__precision=uye(r.__impliedStep),r}return lp(t,hg),$c(t,[{key:"setValue",value:function(e){var n=e;return void 0!==this.__min&&nthis.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!=0&&(n=Math.round(n/this.__step)*this.__step),op(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=uye(e),this}}]),t}();function fyt(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}var C2=function(e){function t(e,n,i){Yc(this,t);var r=cp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,i));r.__truncationSuspended=!1;var a=r,s=void 0;function o(){a.__onFinishChange&&a.__onFinishChange.call(a,a.getValue())}function l(e){var t=s-e.clientY;a.setValue(a.getValue()+t*a.__impliedStep),s=e.clientY}function h(){bt.unbind(window,"mousemove",l),bt.unbind(window,"mouseup",h),o()}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),bt.bind(r.__input,"change",(function(){var e=parseFloat(a.__input.value);Ht.isNaN(e)||a.setValue(e)})),bt.bind(r.__input,"blur",(function(){o()})),bt.bind(r.__input,"mousedown",(function(e){bt.bind(window,"mousemove",l),bt.bind(window,"mouseup",h),s=e.clientY})),bt.bind(r.__input,"keydown",(function(e){13===e.keyCode&&(a.__truncationSuspended=!0,this.blur(),a.__truncationSuspended=!1,o())})),r.updateDisplay(),r.domElement.appendChild(r.__input),r}return lp(t,Eye),$c(t,[{key:"updateDisplay",value:function(){return this.__input.value=this.__truncationSuspended?this.getValue():fyt(this.getValue(),this.__precision),op(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}();function hye(e,t,n,i,r){return i+(e-t)/(n-t)*(r-i)}var pV=function(e){function t(e,n,i,r,a){Yc(this,t);var s=cp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,{min:i,max:r,step:a})),o=s;function l(e){e.preventDefault();var t=o.__background.getBoundingClientRect();return o.setValue(hye(e.clientX,t.left,t.right,o.__min,o.__max)),!1}function h(){bt.unbind(window,"mousemove",l),bt.unbind(window,"mouseup",h),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function c(e){var t=e.touches[0].clientX,n=o.__background.getBoundingClientRect();o.setValue(hye(t,n.left,n.right,o.__min,o.__max))}function u(){bt.unbind(window,"touchmove",c),bt.unbind(window,"touchend",u),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}return s.__background=document.createElement("div"),s.__foreground=document.createElement("div"),bt.bind(s.__background,"mousedown",(function(e){document.activeElement.blur(),bt.bind(window,"mousemove",l),bt.bind(window,"mouseup",h),l(e)})),bt.bind(s.__background,"touchstart",(function(e){1===e.touches.length&&(bt.bind(window,"touchmove",c),bt.bind(window,"touchend",u),c(e))})),bt.addClass(s.__background,"slider"),bt.addClass(s.__foreground,"slider-fg"),s.updateDisplay(),s.__background.appendChild(s.__foreground),s.domElement.appendChild(s.__background),s}return lp(t,Eye),$c(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",op(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(),_ye=function(e){function t(e,n,i){Yc(this,t);var r=cp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=r;return r.__button=document.createElement("div"),r.__button.innerHTML=void 0===i?"Fire":i,bt.bind(r.__button,"click",(function(e){return e.preventDefault(),a.fire(),!1})),bt.addClass(r.__button,"button"),r.domElement.appendChild(r.__button),r}return lp(t,hg),$c(t,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),t}(),mV=function(e){function t(e,n){Yc(this,t);var i=cp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.__color=new $s(i.getValue()),i.__temp=new $s(0);var r=i;i.domElement=document.createElement("div"),bt.makeSelectable(i.domElement,!1),i.__selector=document.createElement("div"),i.__selector.className="selector",i.__saturation_field=document.createElement("div"),i.__saturation_field.className="saturation-field",i.__field_knob=document.createElement("div"),i.__field_knob.className="field-knob",i.__field_knob_border="2px solid ",i.__hue_knob=document.createElement("div"),i.__hue_knob.className="hue-knob",i.__hue_field=document.createElement("div"),i.__hue_field.className="hue-field",i.__input=document.createElement("input"),i.__input.type="text",i.__input_textShadow="0 1px 1px ",bt.bind(i.__input,"keydown",(function(e){13===e.keyCode&&c.call(this)})),bt.bind(i.__input,"blur",c),bt.bind(i.__selector,"mousedown",(function(){bt.addClass(this,"drag").bind(window,"mouseup",(function(){bt.removeClass(r.__selector,"drag")}))})),bt.bind(i.__selector,"touchstart",(function(){bt.addClass(this,"drag").bind(window,"touchend",(function(){bt.removeClass(r.__selector,"drag")}))}));var a=document.createElement("div");function s(e){d(e),bt.bind(window,"mousemove",d),bt.bind(window,"touchmove",d),bt.bind(window,"mouseup",l),bt.bind(window,"touchend",l)}function o(e){p(e),bt.bind(window,"mousemove",p),bt.bind(window,"touchmove",p),bt.bind(window,"mouseup",h),bt.bind(window,"touchend",h)}function l(){bt.unbind(window,"mousemove",d),bt.unbind(window,"touchmove",d),bt.unbind(window,"mouseup",l),bt.unbind(window,"touchend",l),u()}function h(){bt.unbind(window,"mousemove",p),bt.unbind(window,"touchmove",p),bt.unbind(window,"mouseup",h),bt.unbind(window,"touchend",h),u()}function c(){var e=fV(this.value);!1!==e?(r.__color.__state=e,r.setValue(r.__color.toOriginal())):this.value=r.__color.toString()}function u(){r.__onFinishChange&&r.__onFinishChange.call(r,r.__color.toOriginal())}function d(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,i=n.clientX,a=n.clientY,s=(i-t.left)/(t.right-t.left),o=1-(a-t.top)/(t.bottom-t.top);return o>1?o=1:o<0&&(o=0),s>1?s=1:s<0&&(s=0),r.__color.v=o,r.__color.s=s,r.setValue(r.__color.toOriginal()),!1}function p(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),r.__color.h=360*n,r.setValue(r.__color.toOriginal()),!1}return Ht.extend(i.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),Ht.extend(i.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:i.__field_knob_border+(i.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),Ht.extend(i.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),Ht.extend(i.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),Ht.extend(a.style,{width:"100%",height:"100%",background:"none"}),dye(a,"top","rgba(0,0,0,0)","#000"),Ht.extend(i.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),myt(i.__hue_field),Ht.extend(i.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:i.__input_textShadow+"rgba(0,0,0,0.7)"}),bt.bind(i.__saturation_field,"mousedown",s),bt.bind(i.__saturation_field,"touchstart",s),bt.bind(i.__field_knob,"mousedown",s),bt.bind(i.__field_knob,"touchstart",s),bt.bind(i.__hue_field,"mousedown",o),bt.bind(i.__hue_field,"touchstart",o),i.__saturation_field.appendChild(a),i.__selector.appendChild(i.__field_knob),i.__selector.appendChild(i.__saturation_field),i.__selector.appendChild(i.__hue_field),i.__hue_field.appendChild(i.__hue_knob),i.domElement.appendChild(i.__input),i.domElement.appendChild(i.__selector),i.updateDisplay(),i}return lp(t,hg),$c(t,[{key:"updateDisplay",value:function(){var e=fV(this.getValue());if(!1!==e){var t=!1;Ht.each($s.COMPONENTS,(function(n){if(!Ht.isUndefined(e[n])&&!Ht.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}}),this),t&&Ht.extend(this.__color.__state,e)}Ht.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,i=255-n;Ht.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,dye(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),Ht.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+i+","+i+","+i+",.7)"})}}]),t}(),pyt=["-moz-","-o-","-webkit-","-ms-",""];function dye(e,t,n,i){e.style.background="",Ht.each(pyt,(function(r){e.style.cssText+="background: "+r+"linear-gradient("+t+", "+n+" 0%, "+i+" 100%); "}))}function myt(e){e.style.background="",e.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",e.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"}var gyt={load:function(e,t){var n=t||document,i=n.createElement("link");i.type="text/css",i.rel="stylesheet",i.href=e,n.getElementsByTagName("head")[0].appendChild(i)},inject:function(e,t){var n=t||document,i=document.createElement("style");i.type="text/css",i.innerHTML=e;var r=n.getElementsByTagName("head")[0];try{r.appendChild(i)}catch(e){}}},vyt='
\n\n Here\'s the new load parameter for your GUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n\n
\n\n
\n\n
',yyt=function(e,t){var n=e[t];return Ht.isArray(arguments[2])||Ht.isObject(arguments[2])?new hyt(e,t,arguments[2]):Ht.isNumber(n)?Ht.isNumber(arguments[2])&&Ht.isNumber(arguments[3])?Ht.isNumber(arguments[4])?new pV(e,t,arguments[2],arguments[3],arguments[4]):new pV(e,t,arguments[2],arguments[3]):Ht.isNumber(arguments[4])?new C2(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new C2(e,t,{min:arguments[2],max:arguments[3]}):Ht.isString(n)?new dyt(e,t):Ht.isFunction(n)?new _ye(e,t,""):Ht.isBoolean(n)?new bye(e,t):null};function xyt(e){setTimeout(e,1e3/60)}var byt=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||xyt,Eyt=function(){function e(){Yc(this,e),this.backgroundElement=document.createElement("div"),Ht.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),bt.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),Ht.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;bt.bind(this.backgroundElement,"click",(function(){t.hide()}))}return $c(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),Ht.defer((function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"}))}},{key:"hide",value:function(){var e=this,t=function t(){e.domElement.style.display="none",e.backgroundElement.style.display="none",bt.unbind(e.domElement,"webkitTransitionEnd",t),bt.unbind(e.domElement,"transitionend",t),bt.unbind(e.domElement,"oTransitionEnd",t)};bt.bind(this.domElement,"webkitTransitionEnd",t),bt.bind(this.domElement,"transitionend",t),bt.bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-bt.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-bt.getHeight(this.domElement)/2+"px"}}]),e}(),_yt=ayt(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n");gyt.inject(_yt);var fye="dg",pye=72,mye=20,V_="Default",B_=function(){try{return!!window.localStorage}catch(e){return!1}}(),U_=void 0,gye=!0,jy=void 0,dV=!1,Tye=[],Di=function e(t){var n=this,i=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),bt.addClass(this.domElement,fye),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],i=Ht.defaults(i,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),i=Ht.defaults(i,{resizable:i.autoPlace,hideable:i.autoPlace}),Ht.isUndefined(i.load)?i.load={preset:V_}:i.preset&&(i.load.preset=i.preset),Ht.isUndefined(i.parent)&&i.hideable&&Tye.push(this),i.resizable=Ht.isUndefined(i.parent)&&i.resizable,i.autoPlace&&Ht.isUndefined(i.scrollable)&&(i.scrollable=!0);var r,a=B_&&"true"===localStorage.getItem(Xy(this,"isLocal")),s=void 0,o=void 0;if(Object.defineProperties(this,{parent:{get:function(){return i.parent}},scrollable:{get:function(){return i.scrollable}},autoPlace:{get:function(){return i.autoPlace}},closeOnTop:{get:function(){return i.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:i.load.preset},set:function(e){n.parent?n.getRoot().preset=e:i.load.preset=e,Myt(this),n.revert()}},width:{get:function(){return i.width},set:function(e){i.width=e,yV(n,e)}},name:{get:function(){return i.name},set:function(e){i.name=e,o&&(o.innerHTML=i.name)}},closed:{get:function(){return i.closed},set:function(t){i.closed=t,i.closed?bt.addClass(n.__ul,e.CLASS_CLOSED):bt.removeClass(n.__ul,e.CLASS_CLOSED),this.onResize(),n.__closeButton&&(n.__closeButton.innerHTML=t?e.TEXT_OPEN:e.TEXT_CLOSED)}},load:{get:function(){return i.load}},useLocalStorage:{get:function(){return a},set:function(e){B_&&(a=e,e?bt.bind(window,"unload",s):bt.unbind(window,"unload",s),localStorage.setItem(Xy(n,"isLocal"),e))}}}),Ht.isUndefined(i.parent)){if(this.closed=i.closed||!1,bt.addClass(this.domElement,e.CLASS_MAIN),bt.makeSelectable(this.domElement,!1),B_&&a){n.useLocalStorage=!0;var l=localStorage.getItem(Xy(this,"gui"));l&&(i.load=JSON.parse(l))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=e.TEXT_CLOSED,bt.addClass(this.__closeButton,e.CLASS_CLOSE_BUTTON),i.closeOnTop?(bt.addClass(this.__closeButton,e.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(bt.addClass(this.__closeButton,e.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),bt.bind(this.__closeButton,"click",(function(){n.closed=!n.closed}))}else{void 0===i.closed&&(i.closed=!0);var h=document.createTextNode(i.name);bt.addClass(h,"controller-name"),o=EV(n,h),bt.addClass(this.__ul,e.CLASS_CLOSED),bt.addClass(o,"title"),bt.bind(o,"click",(function(e){return e.preventDefault(),n.closed=!n.closed,!1})),i.closed||(this.closed=!1)}i.autoPlace&&(Ht.isUndefined(i.parent)&&(gye&&(jy=document.createElement("div"),bt.addClass(jy,fye),bt.addClass(jy,e.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(jy),gye=!1),jy.appendChild(this.domElement),bt.addClass(this.domElement,e.CLASS_AUTO_PLACE)),this.parent||yV(n,i.width)),this.__resizeHandler=function(){n.onResizeDebounced()},bt.bind(window,"resize",this.__resizeHandler),bt.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),bt.bind(this.__ul,"transitionend",this.__resizeHandler),bt.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),i.resizable&&Syt(this),s=function(){B_&&"true"===localStorage.getItem(Xy(n,"isLocal"))&&localStorage.setItem(Xy(n,"gui"),JSON.stringify(n.getSaveObject()))},this.saveToLocalStorageIfPossible=s,i.parent||((r=n.getRoot()).width+=1,Ht.defer((function(){r.width-=1})))};function EV(e,t,n){var i=document.createElement("li");return t&&i.appendChild(t),n?e.__ul.insertBefore(i,n):e.__ul.appendChild(i),e.onResize(),i}function vye(e){bt.unbind(window,"resize",e.__resizeHandler),e.saveToLocalStorageIfPossible&&bt.unbind(window,"unload",e.saveToLocalStorageIfPossible)}function gV(e,t){var n=e.__preset_select[e.__preset_select.selectedIndex];n.innerHTML=t?n.value+"*":n.value}function Tyt(e,t,n){if(n.__li=t,n.__gui=e,Ht.extend(n,{options:function(t){if(arguments.length>1){var i=n.__li.nextElementSibling;return n.remove(),H_(e,n.object,n.property,{before:i,factoryArgs:[Ht.toArray(arguments)]})}if(Ht.isArray(t)||Ht.isObject(t)){var r=n.__li.nextElementSibling;return n.remove(),H_(e,n.object,n.property,{before:r,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof pV){var i=new C2(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});Ht.each(["updateDisplay","onChange","onFinishChange","step","min","max"],(function(e){var t=n[e],r=i[e];n[e]=i[e]=function(){var e=Array.prototype.slice.call(arguments);return r.apply(i,e),t.apply(n,e)}})),bt.addClass(t,"has-slider"),n.domElement.insertBefore(i.domElement,n.domElement.firstElementChild)}else if(n instanceof C2){var r=function(t){if(Ht.isNumber(n.__min)&&Ht.isNumber(n.__max)){var i=n.__li.firstElementChild.firstElementChild.innerHTML,r=n.__gui.__listening.indexOf(n)>-1;n.remove();var a=H_(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return a.name(i),r&&a.listen(),a}return t};n.min=Ht.compose(r,n.min),n.max=Ht.compose(r,n.max)}else n instanceof bye?(bt.bind(t,"click",(function(){bt.fakeEvent(n.__checkbox,"click")})),bt.bind(n.__checkbox,"click",(function(e){e.stopPropagation()}))):n instanceof _ye?(bt.bind(t,"click",(function(){bt.fakeEvent(n.__button,"click")})),bt.bind(t,"mouseover",(function(){bt.addClass(n.__button,"hover")})),bt.bind(t,"mouseout",(function(){bt.removeClass(n.__button,"hover")}))):n instanceof mV&&(bt.addClass(t,"color"),n.updateDisplay=Ht.compose((function(e){return t.style.borderLeftColor=n.__color.toString(),e}),n.updateDisplay),n.updateDisplay());n.setValue=Ht.compose((function(t){return e.getRoot().__preset_select&&n.isModified()&&gV(e.getRoot(),!0),t}),n.setValue)}function wye(e,t){var n=e.getRoot(),i=n.__rememberedObjects.indexOf(t.object);if(-1!==i){var r=n.__rememberedObjectIndecesToControllers[i];if(void 0===r&&(r={},n.__rememberedObjectIndecesToControllers[i]=r),r[t.property]=t,n.load&&n.load.remembered){var a=n.load.remembered,s=void 0;if(a[e.preset])s=a[e.preset];else{if(!a[V_])return;s=a[V_]}if(s[i]&&void 0!==s[i][t.property]){var o=s[i][t.property];t.initialValue=o,t.setValue(o)}}}}function H_(e,t,n,i){if(void 0===t[n])throw new Error('Object "'+t+'" has no property "'+n+'"');var r=void 0;if(i.color)r=new mV(t,n);else{var a=[t,n].concat(i.factoryArgs);r=yyt.apply(e,a)}i.before instanceof hg&&(i.before=i.before.__li),wye(e,r),bt.addClass(r.domElement,"c");var s=document.createElement("span");bt.addClass(s,"property-name"),s.innerHTML=r.property;var o=document.createElement("div");o.appendChild(s),o.appendChild(r.domElement);var l=EV(e,o,i.before);return bt.addClass(l,Di.CLASS_CONTROLLER_ROW),r instanceof mV?bt.addClass(l,"color"):bt.addClass(l,lyt(r.getValue())),Tyt(e,l,r),e.__controllers.push(r),r}function Xy(e,t){return document.location.href+"."+t}function vV(e,t,n){var i=document.createElement("option");i.innerHTML=t,i.value=t,e.__preset_select.appendChild(i),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function yye(e,t){t.style.display=e.useLocalStorage?"block":"none"}function wyt(e){var t=e.__save_row=document.createElement("li");bt.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),bt.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML=" ",bt.addClass(n,"button gears");var i=document.createElement("span");i.innerHTML="Save",bt.addClass(i,"button"),bt.addClass(i,"save");var r=document.createElement("span");r.innerHTML="New",bt.addClass(r,"button"),bt.addClass(r,"save-as");var a=document.createElement("span");a.innerHTML="Revert",bt.addClass(a,"button"),bt.addClass(a,"revert");var s=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?Ht.each(e.load.remembered,(function(t,n){vV(e,n,n===e.preset)})):vV(e,V_,!1),bt.bind(s,"change",(function(){for(var t=0;t0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=R2(this)),e.folders={},Ht.each(this.__folders,(function(t,n){e.folders[n]=t.getSaveObject()})),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=R2(this),gV(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[V_]=R2(this,!0)),this.load.remembered[e]=R2(this),this.preset=e,vV(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){Ht.each(this.__controllers,(function(t){this.getRoot().load.remembered?wye(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())}),this),Ht.each(this.__folders,(function(e){e.revert(e)})),e||gV(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&Sye(this.__listening)},updateDisplay:function(){Ht.each(this.__controllers,(function(e){e.updateDisplay()})),Ht.each(this.__folders,(function(e){e.updateDisplay()}))}});var Mye=Di,Rye=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],xd=(()=>{if("undefined"==typeof document)return!1;let e=Rye[0],t={};for(let n of Rye)if((null==n?void 0:n[1])in document){for(let[i,r]of n.entries())t[e[i]]=r;return t}return!1})(),Aye={change:xd.fullscreenchange,error:xd.fullscreenerror},rl={request:(e=document.documentElement,t)=>new Promise(((n,i)=>{let r=()=>{rl.off("change",r),n()};rl.on("change",r);let a=e[xd.requestFullscreen](t);a instanceof Promise&&a.then(r).catch(i)})),exit:()=>new Promise(((e,t)=>{if(!rl.isFullscreen)return void e();let n=()=>{rl.off("change",n),e()};rl.on("change",n);let i=document[xd.exitFullscreen]();i instanceof Promise&&i.then(n).catch(t)})),toggle:(e,t)=>rl.isFullscreen?rl.exit():rl.request(e,t),onchange(e){rl.on("change",e)},onerror(e){rl.on("error",e)},on(e,t){let n=Aye[e];n&&document.addEventListener(n,t,!1)},off(e,t){let n=Aye[e];n&&document.removeEventListener(n,t,!1)},raw:xd};Object.defineProperties(rl,{isFullscreen:{get:()=>Boolean(document[xd.fullscreenElement])},element:{enumerable:!0,get:()=>{var e;return null!=(e=document[xd.fullscreenElement])?e:void 0}},isEnabled:{enumerable:!0,get:()=>Boolean(document[xd.fullscreenEnabled])}}),xd||(rl={isEnabled:!1});var P2=rl,I2=new O,L2=class{constructor(e,t,n=void 0){this.scale=1,this.explodeUp=!1,this.scene=e,this.objectId=t,t||se.debug(`[EXP] Invalid objectId: ${t}`),n?this.explodeCenter=n:(this.explodeCenter=new O,this.getObjectCenter(this.explodeCenter));let i=this.scene.getObjectById(this.objectId);null==i||i.updateWorldMatrix(!0,!0)}explode(e){if(this.scale=e,!this.objectId||!this.explodeCenter||!this.scale)return void se.debug(`[EXP] Invalid objectId: ${this.objectId}, or position: ${this.explodeCenter}, or this.power: ${this.scale}`);let t=this.scene.getObjectById(this.objectId);t&&t.children?(se.debug(`[EXP] Exploding object '${t.name}'(id: ${t.id}) at: ${Mt.vectorToString(this.explodeCenter)}`),this.explodeObject(t)):se.debug("[EXP] No children to explode!")}explodeObject(e){e.geometry?this.explodeLeafObject(e):e.children.length>0?e.children.forEach((e=>this.explodeObject(e))):this.explodeLeafObject(e)}explodeLeafObject(e){var t;let n=e;if(!n.geometry)return;n.userData.originalMatrixWorld||(n.userData.originalMatrixWorld=n.matrixWorld);let i=n.userData.originalMatrixWorld;n.userData.originalCenter||(n.geometry.boundingBox||n.geometry.computeBoundingBox(),I2.set(0,0,0),null==(t=n.geometry.boundingBox)||t.getCenter(I2),I2.applyMatrix4(n.matrixWorld),n.userData.originalCenter=I2.clone());let r=n.userData.originalCenter.clone();r.sub(this.explodeCenter),r.multiplyScalar(this.scale-1),this.explodeUp&&(r.setX(0),r.setZ(0));let a=new Qe;a.setPosition(r),a.multiply(i),n.matrixWorld=a,n.children.length>0&&n.children.forEach((e=>e.updateMatrix()))}unexplode(){let e=this.scene.getObjectById(this.objectId);e&&e.children?(se.debug(`[EXP] Unexploding '${e.name}'(id: ${e.id}) at: ${Mt.vectorToString(this.explodeCenter)}`),this.unexplodeObject(e)):se.debug("[EXP] No children to explode!")}unexplodeObject(e){e.geometry?this.unexplodeLeafObject(e):e.children.length>0?e.children.forEach((e=>this.unexplodeObject(e))):this.unexplodeLeafObject(e)}unexplodeLeafObject(e){let t=e.userData.originalMatrixWorld;t&&(e.matrixWorld=t,e.children.length>0&&e.children.forEach((e=>e.updateMatrix())))}setExplodeUp(e){this.explodeUp=e}getObjectCenter(e){let t=new Ot;if(!this.objectId)return void se.debug(`[EXP] Invalid objectId: ${this.objectId}`);let n=this.scene.getObjectById(this.objectId);n&&n.children?(n.traverse((e=>{t.expandByObject(e)})),t.getCenter(e)):se.debug("[EXP] No children to explode!")}},D2=class extends dr{constructor(e,t){super(e,{id:"ExplodePlugin"}),this.exploders=[],this.onModelLoaded=()=>{this.init()},this.viewer=e,this.cfg=t||{},this.viewer.addEventListener("ModelLoaded",this.onModelLoaded)}get scene(){return this.viewer.scene}init(){this.viewer.loadedModels.forEach((e=>{if(this.hasExploderForModel(e.object.id))return;let t=new O;if(this.cfg.explodeCenter){let e=this.cfg.explodeCenter;t.set(e.x,e.y,e.z)}else!this.cfg.explodeCenter&&e.bbox&&e.bbox.getCenter(t);let n=new L2(this.scene,e.object.id,t);n.setExplodeUp(!!this.cfg.explodeUp),this.exploders.push(n)}))}explode(e){0===this.exploders.length&&this.init();for(let t of this.exploders)t.explode(e),this.viewer.enableRender()}unexplode(){for(let e of this.exploders)e.unexplode(),this.viewer.enableRender()}hasExploderForModel(e){return!!this.exploders.find((t=>t.objectId===e))}destroy(){super.destroy(),this.viewer.removeEventListener("ModelLoaded",this.onModelLoaded),this.unexplode()}},O2=class extends dr{constructor(e,t){super(e,{id:"GroundGrassPlugin"}),this.NAME="GROUND_GRASS",this.DEFAULT_SIZE=1e3,this.DEFAULT_REPEAT=20,this.onModelLoaded=()=>{!1!==this.cfg.visible&&(this.init(),this.viewer.enableRender())},this.cfg=t||{},!1!==this.cfg.visible&&this.init(),this.viewer.addEventListener("ModelLoaded",this.onModelLoaded)}init(){var e;this.groundGrass&&(null==(e=this.viewer.scene)||e.remove(this.groundGrass),this.groundGrass=void 0);let t=this.cfg.texture||"images/terrain/grass.jpg",n=this.cfg.width||this.DEFAULT_SIZE,i=this.cfg.height||this.DEFAULT_SIZE,r=this.cfg.repeatX||this.DEFAULT_REPEAT,a=this.cfg.repeatY||this.DEFAULT_REPEAT,s=new O,o=this.viewer.getBBox();o&&o.getCenter(s),ft(this,null,(function*(){var e;this.groundGrass=yield this.createGrassGround(t,n,i,r,a),null==(e=this.viewer.scene)||e.add(this.groundGrass),this.viewer.enableRender()}))}setVisible(e){e&&!this.groundGrass&&this.init(),this.groundGrass&&(this.groundGrass.visible=e),this.viewer.enableRender()}createGrassGround(e,t,n,i,r){return ft(this,null,(function*(){return new Promise((a=>{(new Rs).load(e,(e=>{e.wrapS=e.wrapT=Ci,e.repeat.set(i,r),e.anisotropy=16,e.encoding=_u;let s=new Pu({map:e});s.side=ci;let o=new xt(new ui(t,n),s);return o.rotation.x=-Math.PI/2,o.position.y=0,o.receiveShadow=!0,o.name=this.NAME,o.layers.enableAll(),o.layers.disable(12),o.matrixAutoUpdate=!1,o.updateMatrix(),a(o)}))}))}))}destroy(){super.destroy(),this.groundGrass&&(this.groundGrass.removeFromParent(),this.groundGrass.geometry.dispose(),this.groundGrass.clear(),this.groundGrass=void 0),this.viewer.removeEventListener("ModelLoaded",this.onModelLoaded)}},k2=class extends dr{constructor(e,t){super(e,{id:"GroundGridPlugin"}),this.NAME="GROUND_GRID",this.DEFAULT_SIZE=1e3,this.DEFAULT_DIVISIONS=100,this.DEFAULT_MAT_PARAMS={color:12829635,transparent:!0,opacity:.5,wireframeLinewidth:.5},this.onModelLoaded=()=>{!1!==this.cfg.visible&&(this.init(),this.viewer.enableRender())},this.cfg=t||{},!1!==this.cfg.visible&&this.init(),this.viewer.addEventListener("ModelLoaded",this.onModelLoaded)}init(){var e,t;this.gridHelper&&(null==(e=this.viewer.scene)||e.remove(this.gridHelper),this.gridHelper=void 0);let n=this.cfg.size,i=this.cfg.divisions,r=new O,a=this.viewer.getBBox();a&&a.getCenter(r),this.gridHelper=this.createGroundGrid(n,i,r),null==(t=this.viewer.scene)||t.add(this.gridHelper),this.viewer.enableRender()}setVisible(e){e&&!this.gridHelper&&this.init(),this.gridHelper&&(this.gridHelper.visible=e),this.viewer.enableRender()}createGroundGrid(e,t,n){e=e||this.DEFAULT_SIZE,t=t||this.DEFAULT_DIVISIONS;let i=new Ob(e,t);n?i.position.set(n.x,n.y,n.z):i.position.y=0;let r=i.material;return Array.isArray(r)||(r.opacity=this.DEFAULT_MAT_PARAMS.opacity,r.transparent=this.DEFAULT_MAT_PARAMS.transparent),i.name=this.NAME,i.layers.enableAll(),i.layers.disable(12),i.matrixAutoUpdate=!1,i.updateMatrix(),i}destroy(){super.destroy(),this.gridHelper&&(this.gridHelper.removeFromParent(),this.gridHelper.geometry.dispose(),this.gridHelper.clear(),this.gridHelper=void 0),this.viewer.removeEventListener("ModelLoaded",this.onModelLoaded)}},F2=class extends dr{constructor(e,t){super(e,{id:"ScreenshotPlugin"}),this.cfg=t||{},this.cfg.type=this.cfg.type||"image/png",this.cfg.quality=this.cfg.quality||.8}getScreenshot(){var e;let t=null==(e=this.viewer.renderer)?void 0:e.domElement;if(t)return t.toDataURL(this.cfg.type,this.cfg.quality)}getScreenshotAsync(){return ft(this,arguments,(function*(e="BoxSelection"){var t;this.cancel();let n,i="image/png",r=this.viewer,a=null==(t=r.renderer)?void 0:t.domElement;if(!a||!r.viewerContainer||!r.camera)return;if("PickMarkup"===e?(this.pickMarkupHelper||(this.pickMarkupHelper=new wP(r)),n=yield this.pickMarkupHelper.pick()):"BoxSelection"===e&&(this.boxSelectHelper||(this.boxSelectHelper=new $f(r)),n=yield this.boxSelectHelper.select()),"Default"!==e&&!n)return;let s=yield Mt.canvasToImage(a),o=document.createElement("canvas");o.width=a.width,o.height=a.height;let l=window.devicePixelRatio,h=o.getContext("2d");if(h.drawImage(s,0,0,s.width/l,s.height/l),r.overlayRender){let e=yield r.overlayRender.getImage((e=>e instanceof Dr||e instanceof wi));h.drawImage(e,0,0,e.width/l,e.height/l)}let c=Mt.renderingContextToImage(h,n,i,.8);return r instanceof Qf?{base64Image:c,viewExtent:r.getCurrentViewExtent(),imageType:i}:{base64Image:c,imageType:i}}))}isActive(){var e,t;return(null==(e=this.boxSelectHelper)?void 0:e.isActive)||(null==(t=this.pickMarkupHelper)?void 0:t.isActive)}cancel(){var e,t;null!=(e=this.boxSelectHelper)&&e.isActive&&this.boxSelectHelper.deactivate(),null!=(t=this.pickMarkupHelper)&&t.isActive&&this.pickMarkupHelper.deactivate()}},up=class{constructor(e="uploadModelFile"){this.input=document.createElement("input"),this.input.id=e,this.input.type="file",this.input.multiple=!0,this.input.accept=this.formats().map((e=>"."+e)).join(","),this.input.style.display="none",this.input.onchange=e=>{let t=e.target.files;!t||t.length<=0?se.error("[Uploader] No files to be uploaded!"):this.uploadFiles(t)}}formats(){return se.warn("[Uploader]: Should call derived class instead!"),[]}uploadFiles(e){se.warn(`[Uploader]: Should call derived class instead! files: ${e}`)}openFileBrowserToUpload(){this.input.click()}},N2=class extends up{constructor(e,t){super(t),this.defaultModelConfig={src:"",merge:!1},this.viewer=e}formats(){return["gltf","glb","dxf","obj","stl","fbx","ifc","dae","*"]}uploadFiles(e){let t=e.length;if(0===t)return;if(this.checkAllFilesWithTheSameFormat(e)){for(let n=0;n{r&&(n=URL.createObjectURL(r),o.push(n),a.src=r.name)};if(r){l();let e=ra.extractUrlBase(n);i=new Lu,i.setURLModifier((t=>{let n=decodeURI(t).replace(e,"").replace(/^(\.?\/)/,"");if(s.has(n)){let e=s.get(n),t=URL.createObjectURL(e);return o.push(t),t}return t}))}else r=e[0],l();this.viewer.loadLocalModel(n,a,i,(e=>{let t=Math.floor(100*e.loaded/e.total);se.info(`[Uploader] Loading ${null==r?void 0:r.name}, ${t}%`)})).then((()=>{se.info(`[Uploader] Loaded ${null==r?void 0:r.name}`),o.forEach(URL.revokeObjectURL)}))}checkAllFilesWithTheSameFormat(e){let t=e=>{let t=e.lastIndexOf(".");return e.substring(t+1).toLowerCase()},n=e.length,i=t(e[0].name);for(let r=0;r{let n=Math.floor(100*t.loaded/t.total);se.info(`[Uploader] Loading ${null==e?void 0:e.name}, ${n}%`)}))}};function Cye(e,t,n,i,r,a,s){let o=e.addFolder(t);o.add(n,"x",r,a,s).onChange(i),o.add(n,"y",r,a,s).onChange(i),o.add(n,"z",r,a,s).onChange(i)}var Pye=class extends dr{constructor(e){super(e,{id:"BimViewerDatGuiPlugin"}),this.controls={showGroundGrid:!1,showGroundGrass:!1,skyMode:["None","Black Background","White Background","Gradient ramp","Cloudy"],environments:["None","Default (City Streat 64x32)","Venice Sunset","Footprint Court (HDR Labs)","City Street"],homeView:()=>console.log("[DGH] Go to home view"),views:["Top","Bottom","Front","Back","Left","Right"],OrthographicCamera:!1,viewpoints:!1,annotations:!1,takeSnapshot:()=>console.log("[DGH] Taking snapshot..."),fullScreen:()=>console.log("[DGH] Full screen..."),webcam:!1,uploadFile:()=>console.log("[DGH] Upload file..."),showBimTree:!1,showPropertyPanel:!1,transparentMode:!1,showVertexNormals:!1,explode:1,sectionMode:["No section","Box section","Pick plane section","Axis plane section"],alVisible:!0,alColor:"#cccccc",alIntensity:1,dlColor:"#dddddd",showDlHelper:!1,hlVisible:!0,hlIntensity:1,hlColor:[255,255,255,.6],hlGroundColor:[200,255,200,.6],fogEnabled:!1,fogColor:14540253,fogNearDistance:1,fogFarDistance:1e3,composerEnabled:!1,renderPassEnabled:!1,fxaaEnabled:!1,saoEnabled:!1,ssaoEnabled:!1,outlineEnabled:!1,ssaaEnabled:!1,bloomEnabled:!1,unrealBloomEnabled:!1,enableFastOperation:!1,distanceCullingFactor:100},this.viewer=e,this.init()}init(){if(!this.viewer||!this.viewer.renderer||!this.viewer.scene)throw new Error("Need to initialize renderer, scene first!");let e=this.viewer,t=this.viewer.scene,n=this.controls;this.gui=new Mye({name:"controls",autoPlace:!0,width:300,closed:!0}),this.gui.domElement.style.opacity="0.6";let i=this.gui.addFolder("Common settings");i.add(n,"showGroundGrid").name("Show ground grid").onChange((t=>{let n=e.findPlugin("GroundGridPlugin");n?n.setVisible(t):n=new k2(e)})),i.add(n,"showGroundGrass").name("Show ground grass").onChange((t=>{let n=e.findPlugin("GroundGrassPlugin");n?n.setVisible(t):n=new O2(e)})),i.add(n,"environments",n.environments).name("Environments").onChange((n=>{let i="";if("Default (City Streat 64x32)"===n){if(e.pmremGenerator)return Cc.createEnvTextureFromDataArray(e.pmremGenerator).then((e=>{t.environment=e})),void e.enableRender()}else"Venice Sunset"===n?i="venice_sunset_1k.hdr":"Footprint Court (HDR Labs)"===n?i="footprint_court_2k.hdr":"City Street"===n&&(i="city_street_256.hdr");""===i?t.environment=null:(i=`${window.location.origin}/images/envmap/${i}`,Cc.createEnvTexture(e.pmremGenerator,i).then((e=>{t.environment=e}))),e.enableRender()})),i.add(n,"homeView").name("Go to home view").onChange((()=>{e.goToHomeView()})),i.add(n,"views",n.views).name("Views").onChange((n=>{var i;let r=new O,a=new O,s=ks.getVisibleObjectBoundingBox(t),o=aE.getCameraDirectionByView(n);aE.getCameraPositionByBboxAndDirection(s,r,a,null==(i=e.camera)?void 0:i.projectionMatrix,o),e.flyTo(r,a)})),i.add(n,"OrthographicCamera").name("Orth Camera").onChange((t=>{e.setToOrthographicCamera(t)})),i.add(n,"takeSnapshot").name("Take snapshot").onChange((()=>{let t=e.findPlugin("ScreenshotPlugin");t||(t=new F2(e));let n=t.getScreenshot(),i=document.createElement("a");i.href=n,i.download="",i.click()})),i.add(n,"fullScreen").name("Full screen").onChange((()=>{P2&&P2.isEnabled&&P2.request(),e.enableRender()})),i.add(n,"uploadFile").name("Upload file").onChange((()=>{new N2(e).openFileBrowserToUpload()}));let r=this.gui.addFolder("Model operations");r.add(n,"transparentMode",n.transparentMode).name("Transparent mode").onChange((t=>{e.addOrRemoveObjectOpacity(t),e.enableRender()})),r.add(n,"showVertexNormals",n.showVertexNormals).name("Show Vertex Normals").onChange((t=>{e.showVertexNormals(t),e.enableRender()})),r.add(n,"explode",1,5).name("Explode tool").onChange((t=>{let n=e.findPlugin("ExplodePlugin");n||(n=new D2(e)),n.explode(t)})),r.add(n,"sectionMode",n.sectionMode).name("Section mode").onChange((t=>{let n=e.findPlugin("SectionPlugin");n||(n=new h2(e)),"No section"===t?n.deactivate():"Box section"===t?n.activate("ObjectsBoxSection"):"Pick plane section"===t?n.activate("PickPlaneSection"):"Axis plane section"===t&&n.activate("AxisPlaneSection"),e.enableRender()}));let a=this.viewer.ambientLight,s=this.gui.addFolder("Ambient light");s.add(n,"alVisible",n.alVisible).name("visible").onChange((t=>{a&&(a.visible=t),e.enableRender()})),s.addColor(n,"alColor").name("color").onChange((t=>{a&&(a.color=new ct(t)),e.enableRender()})),s.add(n,"alIntensity",0,5).name("intensity").onChange((t=>{a&&(a.intensity=t),e.enableRender()}));let o=this.viewer.directionalLight;if(o){let t=this.gui.addFolder("Directional light");t.add(o,"visible").name("visible").onChange((t=>{o&&(o.visible=t),e.enableRender()})),t.addColor(n,"dlColor").name("color").onChange((t=>{o&&(o.color=new ct(t)),e.enableRender()})),t.add(o,"intensity",0,5).name("intensity").onChange((t=>{o&&(o.intensity=t),e.enableRender()})),t.add(o,"castShadow").name("castShadow").onChange((t=>{o&&(o.castShadow=t),e.enableRender()})),t.add(n,"showDlHelper").name("showDlHelper").onChange((t=>{e.showDirectionalLightHelper(t),e.enableRender()}));let i=()=>{e.updateDirectionalLight(),e.enableRender()};Cye(t,"position",o.position,i),Cye(t,"target",o.target.position,i);let r=t.addFolder("shadow");r.add(o.shadow.camera,"near").name("near").onChange(i),r.add(o.shadow.camera,"far").name("far").onChange(i),r.add(o.shadow.camera,"zoom").name("zoom").onChange(i)}let l=this.viewer.hemisphereLight,h=this.gui.addFolder("Hemisphere Light");h.add(n,"hlVisible",n.hlVisible).name("visible").onChange((t=>{l&&(l.visible=t),e.enableRender()})),h.add(n,"hlIntensity",0,5).name("intensity").onChange((t=>{l&&(l.intensity=t),e.enableRender()})),h.addColor(n,"hlColor").name("color").onChange((t=>{l&&(l.color=new ct(t)),e.enableRender()})),h.addColor(n,"hlGroundColor").name("groundColor").onChange((t=>{l&&(l.groundColor=new ct(t)),e.enableRender()}));let c=this.gui.addFolder("Fog");c.add(n,"fogEnabled",n.fogEnabled).name("Enabled").onChange((i=>{t.fog=i?new Su(n.fogColor,n.fogNearDistance,n.fogFarDistance):null,e.enableRender()})),c.add(n,"fogNearDistance",0,100).name("Near").onChange((i=>{n.fogEnabled&&t&&(t.fog=new Su(n.fogColor,i,n.fogFarDistance)),e.enableRender()})),c.add(n,"fogFarDistance",100,2e3).name("Far").onChange((i=>{n.fogEnabled&&t&&(t.fog=new Su(n.fogColor,n.fogNearDistance,i)),e.enableRender()}));let u=this.gui.addFolder("Composer");u.add(n,"composerEnabled",n.composerEnabled).name("Composer Enabled").onChange((t=>{e.enableComposer(t)})),u.add(n,"renderPassEnabled",n.renderPassEnabled).name("RenderPass Enabled").onChange((t=>{e.enableRenderPass(t)})),u.add(n,"fxaaEnabled",n.fxaaEnabled).name("Effect FXAA Enabled").onChange((t=>{e.enableFxaaPass(t)})),u.add(n,"saoEnabled",n.saoEnabled).name("SAO Enabled").onChange((t=>{e.enableSaoPass(t)})),u.add(n,"ssaoEnabled",n.ssaoEnabled).name("SSAO Enabled").onChange((t=>{e.enableSsaoPass(t)})),u.add(n,"outlineEnabled",n.outlineEnabled).name("OutlinePass Enabled").onChange((t=>{e.enableOutlinePass(t)})),u.add(n,"ssaaEnabled",n.ssaaEnabled).name("SSAA Enabled").onChange((t=>{e.enableSsaaPass(t)})),u.add(n,"bloomEnabled",n.bloomEnabled).name("Bloom Enabled").onChange((t=>{e.enableBloomPass(t)})),u.add(n,"unrealBloomEnabled",n.unrealBloomEnabled).name("Unreal Bloom Enabled").onChange((t=>{e.enableUnrealBloomPass(t)}));let d=this.gui.addFolder("Performance");d.add(n,"enableFastOperation",n.enableFastOperation).name("Enable Fast Operation").onChange((t=>{e.enableFastOperation=t,e.enableRender()})).setValue(e.enableFastOperation),d.add(n,"distanceCullingFactor",10,1e3).name("Distance Culling Factor").onChange((t=>{e.setDistanceCullingFactor(t),e.enableRender()})).setValue(e.getDistanceCullingFactor())}open(){this.gui&&this.gui.open()}close(){this.gui&&this.gui.close()}destroy(){super.destroy(),this.gui&&this.gui.destroy(),this.gui=void 0}},Iye=class extends dr{constructor(e,t){super(e,{id:"LayerManagerPlugin"}),this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.onPointerDown=e=>{let t=e.target;null!=t&&t.classList.contains("draggable")&&0===e.button&&(this.mouseDownPositionX=e.x,this.mouseDownPositionY=e.y,document.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp))},this.onPointerMove=e=>{let t=this.layerMgrRoot,n=this.viewer.viewerContainer;if(!t||!n)return;let i=n.clientLeft+n.clientWidth,r=n.clientTop+n.clientHeight,a=e.x-this.mouseDownPositionX,s=e.y-this.mouseDownPositionY,o=t.offsetLeft+a,l=t.offsetTop+s;o<0&&(o=0),o>0&&o+t.clientWidth>i&&a>0&&(o=t.offsetLeft),l<0&&(l=0),l>0&&l+t.clientHeight>r&&s>0&&(l=t.offsetTop),t.style.left=`${o}px`,t.style.top=`${l}px`,this.mouseDownPositionX=e.x,this.mouseDownPositionY=e.y},this.onPointerUp=()=>{document.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp)},this.cfg=t||{},!1!==this.cfg.visible&&this.init()}init(){let e=this.viewer;this.cfg.containerId&&(this.container=document.getElementById(this.cfg.containerId)),this.container||(this.container=e.widgetContainer),this.dxfLayersArray=e.getLayers(),this.buildPage(),this.addContent(),this.addEventHandlers()}setVisible(e){e&&!this.container&&this.init();let t=this.layerMgrRoot;"none"!==t.style.display!==e&&(e?(this.updatePage(),t.style.display=""):t.style.display="none",this.dispatchEvent("Visibilitychange",e))}show(){this.setVisible(!0)}hide(){this.setVisible(!1)}destroy(){var e,t,n;super.destroy(),null==(e=this.closeBtn)||e.removeEventListener("click",this.closePanel),null==(t=this.checkboxes)||t.forEach((e=>{e.removeEventListener("change",(()=>{this.checkboxHandler(e)}))})),null==(n=this.layerMgrRoot)||n.remove()}buildPage(){var e;this.layerMgrRoot=document.createElement("div"),this.layerMgrRoot.classList.add("layer-manager");let t=document.createElement("div");t.classList.add("header","draggable"),this.headerText=document.createElement("span"),this.headerText.innerHTML="Layers",this.headerText.classList.add("draggable"),this.closeBtn=document.createElement("span"),this.closeBtn.classList.add("close"),this.closeBtn.innerHTML="X",t.appendChild(this.headerText),t.appendChild(this.closeBtn),this.layerMgrRoot.appendChild(t),this.layerList=document.createElement("div"),this.layerList.classList.add("layer-list"),this.layerMgrRoot.appendChild(this.layerList),null==(e=this.container)||e.appendChild(this.layerMgrRoot),this.updateHeaderText()}addContent(){var e;let t='\n
\n \n Color\n   Layer name\n
\n ';if(this.dxfLayersArray){let e=this.dxfLayersArray.length>1;for(let n=0;n{let n=/[a-zA-Z0-9]/,i=e.toString(),r=t.toString();return n.test(i[0])||n.test(r[0])?i>r?1:i{e.addEventListener("change",(()=>{this.checkboxHandler(e)}))}))}generateListItem(e,t,n){return`\n
\n \n
\n ${e}\n
\n `}closePanel(){this.hide()}addEventHandlers(){var e,t;null==(e=this.closeBtn)||e.addEventListener("click",this.closePanel.bind(this)),null==(t=this.layerMgrRoot)||t.addEventListener("pointerdown",this.onPointerDown)}checkboxHandler(e){var t;if(!this.dxfLayersArray||!this.checkboxes)return;let n=this.viewer;if("toggleAllLayers"===e.id){for(let t=0;t{n.setLayerVisibility(t,e.checked,i)}))}return void(null==(t=this.checkboxes)||t.forEach((t=>t.checked=e.checked)))}let i="",r=e.value,a=r.indexOf(">");-1!==a&&(i=r.slice(1,a),r=r.slice(a+2)),i||(i=this.dxfLayersArray[0].modelId),n.setLayerVisibility(r,e.checked,i)}updatePage(){if(!this.dxfLayersArray)return;let e=this.viewer.getLayers();e.length!==this.dxfLayersArray.length&&(this.dxfLayersArray=e,this.addContent(),this.updateHeaderText())}updateHeaderText(){if(!this.dxfLayersArray||!this.headerText)return;let e=0;for(let t=0;t{this.initMaterial(),this.initRenderTarget(),this.createGroundShadowByBBox(e,t)},this.onShadowRender=()=>{var e,t,n,i,r;this.shouldUpdateShadow()&&(this.render(),null==(e=this.shadowCamera)||e.removeFromParent(),this.shadowCamera=void 0,null==(t=this.blurPlane)||t.removeFromParent(),this.blurPlane=void 0,null==(n=this.depthMaterial)||n.dispose(),this.depthMaterial=void 0,null==(i=this.horizontalBlurMaterial)||i.dispose(),this.horizontalBlurMaterial=void 0,null==(r=this.verticalBlurMaterial)||r.dispose(),this.verticalBlurMaterial=void 0)},this.cfg=t,this.viewer.addEventListener("ModelLoaded",this.onModelLoaded),this.viewer.addEventListener("BeforeRender",this.onShadowRender)}get scene(){return this.viewer.scene}get renderer(){return this.viewer.renderer}shouldUpdateShadow(){let e=!1,t=this.viewer.loadedModels.length;return this.modelCount!==t&&(this.modelCount=t,e=!0),e}initMaterial(){this.depthMaterial=new Tc,this.depthMaterial.userData.darkness={value:this.cfg.darkness},this.depthMaterial.onBeforeCompile=e=>{var t;e.uniforms.darkness=null==(t=this.depthMaterial)?void 0:t.userData.darkness,e.fragmentShader=`\n uniform float darkness;\n ${e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * darkness );")}\n `},this.depthMaterial.depthTest=!1,this.depthMaterial.depthWrite=!1,this.horizontalBlurMaterial=new cn(Lye),this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial=new cn(Dye),this.verticalBlurMaterial.depthTest=!1}initRenderTarget(){this.renderTarget=new sr(128,128),this.renderTarget.texture.generateMipmaps=!1,this.renderTargetBlur=new sr(128,128),this.renderTargetBlur.texture.generateMipmaps=!1}createGroundShadowByBBox(e,t){var n,i,r;this.shadowGroup=new er,this.shadowGroup.name=`${e}-ground-shadow`,zn.disableLayerChannels(this.shadowGroup,[12,11]),null==(n=this.scene)||n.add(this.shadowGroup);let{min:a,max:s}=t,o=new O;t.getSize(o),o.multiplyScalar(2);let l=new O;t.getCenter(l);let h=new ui(o.x,o.z).rotateX(Math.PI/2),c=new ln({map:null==(i=this.renderTarget)?void 0:i.texture,transparent:!0,depthWrite:!1}),u=new xt(h,c);u.renderOrder=1,u.position.set(l.x,a.y,l.z),u.scale.y=-1,null==(r=this.shadowGroup)||r.add(u),this.shadowCamera=new Ur(-o.x/2,o.x/2,o.z/2,-o.z/2,-o.y/2,o.y),this.shadowCamera.position.set(l.x,a.y,l.z),this.shadowCamera.lookAt(l.x,s.y,l.z),this.shadowGroup.add(this.shadowCamera),this.blurPlane=new xt(h),this.blurPlane.position.set(l.x,a.y,l.z),this.blurPlane.visible=!1,this.shadowGroup.add(this.blurPlane)}blurShadow(e){this.renderer&&this.blurPlane&&this.renderTarget&&this.renderTargetBlur&&this.shadowCamera&&this.horizontalBlurMaterial&&this.verticalBlurMaterial&&(this.blurPlane.visible=!0,this.blurPlane.material=this.horizontalBlurMaterial,this.horizontalBlurMaterial.uniforms.tDiffuse.value=this.renderTarget.texture,this.horizontalBlurMaterial.uniforms.h.value=1*e/256,this.renderer.setRenderTarget(this.renderTargetBlur),this.renderer.render(this.blurPlane,this.shadowCamera),this.blurPlane.material=this.verticalBlurMaterial,this.verticalBlurMaterial.uniforms.tDiffuse.value=this.renderTargetBlur.texture,this.verticalBlurMaterial.uniforms.v.value=1*e/256,this.renderer.setRenderTarget(this.renderTarget),this.renderer.render(this.blurPlane,this.shadowCamera),this.blurPlane.visible=!1)}render(){if(!(this.renderer&&this.scene&&this.renderTarget&&this.shadowCamera&&this.depthMaterial))return;let e=this.scene.background;this.scene.background=null,this.scene.overrideMaterial=this.depthMaterial;let t=this.renderer.getClearAlpha();this.renderer.setClearAlpha(0),this.renderer.setRenderTarget(this.renderTarget),this.renderer.render(this.scene,this.shadowCamera),this.scene.overrideMaterial=null,this.blurShadow(this.cfg.blur),this.blurShadow(.4*this.cfg.blur),this.renderer.setRenderTarget(null),this.renderer.setClearAlpha(t),this.scene.background=e}destroy(){var e,t,n,i,r,a,s;super.destroy(),this.viewer.removeEventListener("ModelLoaded",this.onModelLoaded),this.viewer.removeEventListener("BeforeRender",this.onShadowRender),null==(e=this.shadowCamera)||e.removeFromParent(),this.shadowCamera=void 0,null==(t=this.blurPlane)||t.removeFromParent(),this.blurPlane=void 0,null==(n=this.depthMaterial)||n.dispose(),this.depthMaterial=void 0,null==(i=this.horizontalBlurMaterial)||i.dispose(),this.horizontalBlurMaterial=void 0,null==(r=this.verticalBlurMaterial)||r.dispose(),this.verticalBlurMaterial=void 0,null==(a=this.renderTarget)||a.dispose(),this.renderTarget=void 0,null==(s=this.renderTargetBlur)||s.dispose(),this.renderTargetBlur=void 0}},kye=class extends dr{constructor(e){super(e,{id:"HotpointPlugin"}),this.onAfterRender=()=>{var e;let t=this.viewer.scene,n=this.viewer.camera;!t||!n||!this.hotpointRoot||0===this.hotpointRoot.children.length||null==(e=this.css2dRenderer)||e.render(t,n)},this.css2dRenderer=this.viewer.css2dRenderer,this.viewer.addEventListener("AfterRender",this.onAfterRender)}add(e){var t;if(this.has(e.hotpointId))return void se.warn(`[Hotpoint] Hotpoint with id '${e.hotpointId}' already exist!`);let n=e.anchorPosition,i=Tf.createHotpoint(e.html);i.position.set(n[0]||0,n[1]||0,n[2]||0),i.visible=!1!==e.visible,i.userData.hotpoint=e,this.hotpointRoot||(this.hotpointRoot=new er,this.hotpointRoot.matrixAutoUpdate=!1,this.hotpointRoot.matrixWorldAutoUpdate=!1,this.hotpointRoot.name="HotpointRoot",null==(t=this.viewer.scene)||t.add(this.hotpointRoot)),this.hotpointRoot.add(i),i.updateWorldMatrix(!1,!1),this.viewer.enableRender()}remove(e){var t,n;let i=(null==(t=this.hotpointRoot)?void 0:t.children)||[];for(let r=0;r{var n;return(null==(n=t.userData.hotpoint)?void 0:n.hotpointId)===e}))}},Ns=ji(Fye(),1),ai=ji(g1e(),1),YV={Fill:"Fill",Stroke:"Stroke",Shading:"Shading"},ec={Fill:0,Stroke:1,FillStroke:2,Invisible:3,FillAddToPath:4,StrokeAddToPath:5,FillStrokeAddToPath:6,AddToPath:7,FillStrokeMask:3,AddToPathFlag:4},v1e=16,y1e=100,$V=[1,0,0,1,0,0],ZV=[.001,0,0,.001,0,0],Ayt=["butt","round","square"],Cyt=["miter","round","bevel"],Pyt={},x1e={},b1e=new ct,X2=new Qe,E1e=0,Iyt=.01,KV=class extends _r{constructor(e){if(super(),this.contentVisible=!0,this.markedContentStack=[],this.stateStack=[],this.current=new Y2(1,1),this.tempSMask=null,this.pendingEOFill=!1,this.activeLayoutName="Model",this.defaultLayerId="0",this.currentLayerId="0",this.layers={0:{name:"0",id:"0",index:"0",visible:!0}},this.loadedEntityCount=0,this.viewportScale=1,this.baseTransform=new Qe,this.currentTransform=new Qe,this.transformStack=[],this.clipType=Ns.PolyFillType.pftNonZero,this.paths=[],this.pointsMaterials={},this.lineBasicMaterials={},this.meshBasicMaterials={},this.lineWithWidthCount=0,void 0===ai)throw"[PdfLoader] need load pdf.js first";"3.8.162"!==ai.version&&se.warn("[PdfLoader] The pdf.js version we are using now is 3.8.162,if not maybe wrong."),this.fontManager=e.font,ai.GlobalWorkerOptions.workerSrc=e.pdfWorker}load(e,t,n,i){this.loadAsync(e,n).then((e=>{t(e)})).catch((e=>{i(e)}))}loadAsync(e,t){return ft(this,null,(function*(){var n,i,r;let a=Mt.getUpdateProgressFunc(t),s=Mt.getUpdateSubProgressFunc(0,10,t),o=Mt.getUpdateSubProgressFunc(30,90,t);a(0);let{src:l}=e;this.modelCfg=e;let h=e.modelId||l,c=Date.now(),u=ai.getDocument(l);u.onProgress=s;let d=yield u.promise;this.pdf=d,se.info(`[PdfLoader] Pdf document loaded in ${(Date.now()-c)/1e3}s`),c=Date.now(),se.log(d),this.pdfDocumentGroup=new er,this.pdfDocumentGroup.name=`PdfDocument-${h}`,this.optionalContentConfig=yield d.getOptionalContentConfig(),d.numPages>1&&se.info("[PdfLoader] Only the first page can be render others will be ignore.");let p=yield d.getPage(1);a(20),se.info(`[PdfLoader] Pdf page loaded in ${(Date.now()-c)/1e3}s`),c=Date.now(),se.log(p),this.pdfPage=p,this.pdfPageGroup=new er,this.pdfPageGroup.name=KV.MODEL_LAYOUT_NAME,this.pdfDocumentGroup.add(this.pdfPageGroup),this.commonObjs=d._transport.commonObjs,this.objs=p.objs,yield null==(n=this.fontManager)?void 0:n.getFontFromIndexeddb(),se.log("[PdfLoader] Font loaded.");let f=p.view,m=8192/Math.max(f[2]-f[0],f[3]-f[1]),g=Math.min(300/72,m),v=p.getViewport({scale:g});return this.beginDrawing(v),this.current=new Y2(v.width,v.height),yield this.buildLayers(p),a(30),yield this.getOperatorList(o),null!=(i=this.fontManager)&&i.missingFonts&&se.warn("[PdfLoader] Missing fonts and reference count:",null==(r=this.fontManager)?void 0:r.missingFonts,", used other fonts instead."),this.lineWithWidthCount>0&&se.warn(`[PdfLoader] Found ${this.lineWithWidthCount} line(s) with width, line width is not supported and was ignored.`),a(100),se.info(`[PdfLoader] Loaded '${e.src}' in ${(Date.now()-c)/1e3}s, adding to scene...`),{modelId:h,pdfData:{threejsObject:this.pdfDocumentGroup,layers:this.layers||[],layersAndThreejsObjects:this.layersAndThreejsObjects,loadedEntityCount:this.loadedEntityCount}}}))}getOperatorList(e){return ft(this,null,(function*(){let t=this.pdfPage;if(!t)return;let n,i=ai.AnnotationMode.ENABLE,r=t._transport.getRenderingIntent("display",i,null,!0),a=t._intentStates.get(r.cacheKey);return a||(a=Object.create(null),t._intentStates.set(r.cacheKey,a)),a.opListReadCapability||(n=Object.create(null),n.operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(n))},a.opListReadCapability=new ai.PromiseCapability,(a.renderTasks||(a.renderTasks=new Set)).add(n),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null}),yield this._pumpOperatorList(r,e)}))}_pumpOperatorList(e,t){return ft(this,null,(function*(){var n,i;let r=this.pdfPage;if(!r)return;let{renderingIntent:a,cacheKey:s,annotationStorageSerializable:o}=e,{map:l,transfers:h}=o,c=r._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:r._pageIndex,intent:a,cacheKey:s,annotationStorage:l},h).getReader(),u=r._intentStates.get(s);for(u.streamReader=c;;)try{let{value:e,done:a}=yield c.read();if(a)return void(u.streamReader=null);if(r._transport.destroyed)return;let s=e;yield this.executeOperatorList(s,t),null==(n=this.pdfPageGroup)||n.updateMatrixWorld(!0),null!=(i=this.modelCfg)&&i.merge&&this.mergePdfObjects(),s.lastChunk&&this.endDrawing()}catch(e){if(u.streamReader=null,r._transport.destroyed)return;if(u.operatorList){u.operatorList.lastChunk=!0;for(let e of u.renderTasks)e.operatorListChanged();this.tryCleanup()}if(u.displayReadyCapability)u.displayReadyCapability.reject(e);else{if(!u.opListReadCapability)throw e;u.opListReadCapability.reject(e)}}}))}tryCleanup(){let e=this.pdfPage;e&&e._intentStates.clear()}mergePdfObjects(){for(let e in this.layersAndThreejsObjects){let t=this.layersAndThreejsObjects[e];if(t.length<=1)continue;let n=Ar.deepMerge(t,this.pdfPageGroup,!1,!1,!1),i=n.added,r=n.removed;r.forEach((e=>{var t,n;null==(t=this.pdfPageGroup)||t.remove(e);let i=e;i.geometry.dispose(),i.material.dispose(),null==(n=i.material.map)||n.dispose()})),i.forEach((e=>{var t;null==(t=this.pdfPageGroup)||t.add(e)}));let a=t.filter((e=>!r.includes(e)));a.push(...i),this.layersAndThreejsObjects[e]=a}}getPointsMaterial(e,t=1){return this.pointsMaterials[`${e}-${t}`]||(this.pointsMaterials[`${e}-${t}`]=new xi({color:e,transparent:!0,opacity:t})),this.pointsMaterials[`${e}-${t}`]}getLineBasicMaterial(e,t=1){return this.lineBasicMaterials[`${e}-${t}`]||(this.lineBasicMaterials[`${e}-${t}`]=new Gn({color:e,transparent:!0,opacity:t})),this.lineBasicMaterials[`${e}-${t}`]}getMeshBasicMaterial(e,t=1){return this.meshBasicMaterials[`${e}-${t}`]||(this.meshBasicMaterials[`${e}-${t}`]=new ln({color:e,transparent:!0,opacity:t,side:Er})),this.meshBasicMaterials[`${e}-${t}`]}getTransformByMatrix4(e){return[e.elements[0],e.elements[1],e.elements[4],e.elements[5],e.elements[12],e.elements[13]]}getObject(e,t=null){return"string"==typeof e?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):t}beginDrawing(e){var t,n,i;se.log("beginDrawing",e),this.viewportScale=e.scale;let[r,a,s,o,l,h]=e.transform;this.baseTransform.set(r,s,0,l,a,o,0,h,0,0,1,0,0,0,0,1),this.currentTransform.copy(this.baseTransform),null==(t=this.pdfDocumentGroup)||t.applyMatrix4(this.baseTransform),null==(n=this.pdfDocumentGroup)||n.rotateZ(An.degToRad(-e.rotation));let{width:c,height:u}=e,d=(new Dt).setFromPoints([new O(0,0,0),new O(c,0,0),new O(c,u,0),new O(0,0,0),new O(c,u,0),new O(0,u,0)]),p=new ln({color:16777215}),f=new xt(d,p);f.renderOrder=-999,null==(i=this.pdfDocumentGroup)||i.add(f)}endDrawing(){var e;null==(e=this.pdfPageGroup)||e.updateMatrixWorld(!0),this.tryCleanup(),this.releaseData()}releaseData(){var e;null==(e=this.fontManager)||e.releaseFontData(),this.operatorList=void 0,this.optionalContentConfig=void 0,this.commonObjs=void 0,this.objs=void 0,this.pdfPage=void 0,this.pdf=void 0}buildLayers(e){return ft(this,null,(function*(){if(!this.pdf)return;let t=yield e.getOperatorList(),n=t.fnArray,i=t.argsArray,r={},a=1;for(let e=0;n&&e1&&this.lineWithWidthCount++}setLineCap(e){se.log("setLineCap",Ayt[e]),this.current.lineCap=e}setLineJoin(e){se.log("setLineJoin",Cyt[e]),this.current.lineJoin=e}setMiterLimit(e){se.log("setMiterLimit",e),this.current.miterLimit=e}setDash(e,t){se.log("setDash",e,t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(let[t,n]of e)switch(t){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n[0],n[1]);break;case"CA":this.current.strokeAlpha=n;break;case"ca":this.current.fillAlpha=n;break;case"BM":case"TR":break;case"SMask":this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null}}save(){se.log("[PdfLoader] ================save");let e=this.current;this.transformStack.push(this.currentTransform.clone()),this.stateStack.push(e),this.current=e.clone()}restore(){se.log("[PdfLoader] ================restore"),0!==this.stateStack.length&&(this.current=this.stateStack.pop()),0!==this.transformStack.length&&this.currentTransform.copy(this.transformStack.pop()),this.pendingClip=null,this.paths=[]}transform(e,t,n,i,r,a){let s=X2.set(e,n,0,r,t,i,0,a,0,0,1,0,0,0,0,1);this.currentTransform.multiply(s)}moveTo(){}lineTo(){}curveTo(){}curveTo2(){}curveTo3(){}closePath(){this.currentPath&&this.currentPath.curves.length>0&&(this.currentPath.closePath(),this.paths.push(this.currentPath.clone()),this.currentPath=void 0)}rectangle(){}stroke(e=!0){if(this.contentVisible){let e=this.current.strokeColor,t=this.current.strokeAlpha,n=[],i=[];for(let r=0;r0){let i=Ni(n),r=new ii(i,this.getPointsMaterial(e,t));this.addObjectToModel(r)}if(i.length>0){let n=Ni(i),r=new ur(n,this.getLineBasicMaterial(e,t));this.addObjectToModel(r)}}e&&this.consumePath(this.current.getClippedPathBoundingBox())}closeStroke(){this.closePath(),this.stroke()}fill(e=!0){if(0===this.paths.length)return;this.current.patternFill&&se.warn("[PdfLoader] fill pattern not supported now.");let t=this.current.getClippedPathBoundingBox();if(this.contentVisible&&null!==t){let e,t=[];if(this.clipPaths){let e=new Ns.PolyTree,n=new Ns.Clipper,i=this.paths.map((e=>e.getPoints().map((e=>({X:e.x,Y:e.y}))))),r=this.clipPaths.map((e=>e.getPoints().map((e=>({X:e.x,Y:e.y}))))),a=100;Ns.JS.ScaleUpPaths(i,a),Ns.JS.ScaleUpPaths(r,a),n.AddPaths(i,Ns.PolyType.ptSubject,!0),n.AddPaths(r,Ns.PolyType.ptClip,!0),n.Execute(Ns.ClipType.ctIntersection,e,this.pendingEOFill?Ns.PolyFillType.pftEvenOdd:Ns.PolyFillType.pftNonZero,this.clipType);let s=Ns.JS.PolyTreeToExPolygons(e);for(let o=0;onew be(e.X/a,e.Y/a)))),n.length>0&&n.forEach((e=>{let t=new Ss;t.setFromPoints(e.map((e=>new be(e.X/a,e.Y/a)))),i.holes.push(t)})),t.push(i)}this.clipPaths=void 0}e=t.length>0?new Al(t):Ni(this.paths.map((e=>new Al(e)))),e.applyMatrix4(this.currentTransform);let n=this.current.fillColor,i=this.current.fillAlpha,r=new xt(e,this.getMeshBasicMaterial(n,i));this.addObjectToModel(r),this.pendingEOFill=!1}e&&this.consumePath(t)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Pyt}eoClip(){this.pendingClip=x1e}beginText(){this.current.textMatrix=$V,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){this.currentPath=new Ss}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,t){var n;let i=this.commonObjs.get(e),r=this.current;if(!i)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=i.fontMatrix||ZV,(0===r.fontMatrix[0]||0===r.fontMatrix[3])&&se.warn("Invalid font matrix for font "+e),t<0?(t=-t,r.fontDirection=-1):r.fontDirection=1,this.current.font=i,this.current.fontSize=t,i.isType3Font)return;let a=i.loadedName||"sans-serif",s=(null==(n=i.systemFontInfo)?void 0:n.css)||`"${a}", ${i.fallbackName}`,o="normal";i.black?o="900":i.bold&&(o="bold");let l=i.italic?"italic":"normal",h=t;ty1e&&(h=y1e),this.current.fontSizeScale=t/h,this.current.browserFontSize=h,se.log(`[PdfLoader] font: ${l} ${o} ${h}px ${s}`),se.log(`[PdfLoader] current font is: ${i.name}`)}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(){}setTextMatrix(e,t,n,i,r,a){this.current.textMatrix=[e,t,n,i,r,a],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(e,t,n){var i,r,a,s;se.log("paintChar",e,t,n);let o,l,h=this.current,c=h.font,u=h.textRenderingMode,d=h.fontSize/h.fontSizeScale,p=u&ec.FillStrokeMask,f=!!(u&ec.AddToPathFlag),m=h.patternFill&&!c.missingFile;return(c.disableFontFace||f||m)&&(o=c.getPathGenerator(this.commonObjs,e)),c.disableFontFace||m?se.log("paintChar path:",o,d,p):((p===ec.Fill||p===ec.FillStroke)&&(l=null==(r=this.fontManager)?void 0:r.getCharShape(e,null==(i=this.current.font)?void 0:i.name,.8*this.current.browserFontSize)),(p===ec.Stroke||p===ec.FillStroke)&&(l=null==(s=this.fontManager)?void 0:s.getCharShape(e,null==(a=this.current.font)?void 0:a.name,.8*this.current.browserFontSize))),l}showText(e){var t,n;let i=this.current,r=i.font;if(r.isType3Font)return this.showType3Text(e);let a=i.fontSize;if(0===a)return;let s=i.fontSizeScale,o=i.charSpacing,l=i.wordSpacing,h=i.fontDirection,c=i.textHScale*h,u=e.length,d=r.vertical,p=d?1:-1,f=r.defaultVMetrics,m=a*i.fontMatrix[0],g=i.textRenderingMode===ec.Fill&&!r.disableFontFace&&!i.patternFill,[v,y,x,b,_,w]=i.textMatrix,S=this.currentTransform.clone();S.multiply(X2.set(v,x,0,_,y,b,0,w,0,0,1,0,0,0,0,1)),S.multiply(X2.makeTranslation(i.x,i.y+i.textRise,0)),h>0?S.scale(new O(c,1,1)):S.scale(new O(c,-1,1));let M=i.lineWidth,E=i.textMatrixScale;0===E||0===M?(i.textRenderingMode&ec.FillStrokeMask)===ec.Stroke||ec.FillStroke:M/=E,1!==s&&(S.scale(new O(s,s,1)),M/=s);let T,A=0,C=[];for(T=0;T0){let e,t=C[0]instanceof ta,n=Ni(C);e=t?new xt(n,this.getMeshBasicMaterial(this.current.fillColor)):new Wr(n,this.getLineBasicMaterial(this.current.fillColor)),e&&(this.addObjectToModel(e),e.layers.disable(11))}d?i.y-=A:i.x+=A*c}showType3Text(e){}setCharWidth(e,t){}setCharWidthAndBounds(e,t,n,i,r,a){}setStrokeColor(){}setStrokeColorN(){}setFillColorN(){this.current.patternFill=!0}setStrokeRGBColor(e,t,n){se.log("setStrokeRGBColor",[e,t,n]),this.current.strokeColor=b1e.setRGB(e/255,t/255,n/255).convertSRGBToLinear().getHex()}setFillRGBColor(e,t,n){se.log("setFillRGBColor",[e,t,n]),this.current.fillColor=b1e.setRGB(e/255,t/255,n/255).convertSRGBToLinear().getHex(),this.current.patternFill=!1}shadingFill(){}beginInlineImage(){}beginImageData(){}markPoint(e){}markPointProps(e,t){}beginMarkedContent(e){se.log("beginMarkedContent",e),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t){if("OC"===e){this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(t)});let e=this.optionalContentConfig.getGroup(null==t?void 0:t.id);this.currentLayerId=(null==e?void 0:e.name)||this.defaultLayerId,se.log("current layer:",null==e?void 0:e.name)}else this.markedContentStack.push({visible:!0});this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(e){let t=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip,this.pendingClip&&(t||(this.pendingClip===x1e?this.clipType=Ns.PolyFillType.pftEvenOdd:this.clipType=Ns.PolyFillType.pftNonZero,this.clipPaths=this.paths.slice()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),this.paths=[],this.currentPath=void 0}paintFormXObjectBegin(e,t){se.log("paintFormXObjectBegin",e,t)}paintFormXObjectEnd(){}beginGroup(){}endGroup(){}beginAnnotation(){}endAnnotation(){}paintImageMaskXObject(){}paintImageMaskXObjectGroup(){}paintImageXObject(e){if(!this.contentVisible)return;let t=this.getObject(e);t?this.paintInlineImageXObject(t):se.warn("Dependent image isn't ready yet")}paintInlineImageXObject(e){if(!this.contentVisible)return;se.log("paintInlineImageXObject",e),this.save();let{bitmap:t,width:n,height:i}=e;this.currentTransform.multiply(X2.makeScale(1/n,-1/i,1));let r=new Eb(t),a=new ln({map:r,transparent:!0}),s=new ui(n,i),o=new xt(s,a);o.translateX(n/2),o.translateY(-i/2),o.applyMatrix4(this.currentTransform),this.addObjectToModel(o),this.restore()}paintInlineImageXObjectGroup(){}paintImageXObjectRepeat(){}paintImageMaskXObjectRepeat(){}paintSolidColorImageMask(){}_scaleImage(e,t){let n=e.width,i=e.height,r=Math.max(Math.hypot(t.elements[0],t.elements[4]),1),a=Math.max(Math.hypot(t.elements[1],t.elements[5]),1),s=n,o=i,l=s,h=o;for(;r>2&&s>1||a>2&&o>1;)r>2&&s>1&&(l=s>=16384?Math.floor(s/2)-1||1:Math.ceil(s/2),r/=s/l),a>2&&o>1&&(h=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o)/2,a/=o/h),s=l,o=h;return{paintWidth:s,paintHeight:o}}constructPath(e,t,n){let i,r,a=this.current,s=a.x,o=a.y,l=[this.currentTransform.elements[0],this.currentTransform.elements[1],this.currentTransform.elements[4],this.currentTransform.elements[5],this.currentTransform.elements[12],this.currentTransform.elements[13]],h=0===l[0]&&0===l[3]||0===l[1]&&0===l[2],c=h?n.slice(0):null;for(let u=0,d=0,p=e.length;u=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}},ah=KV;ah.MODEL_LAYOUT_NAME="Model";for(let t in ai.OPS)void 0!==ah.prototype[t]&&(ah.prototype[ai.OPS[t]]=ah.prototype[t]);var Y2=class{constructor(e,t){this.textMatrix=$V,this.fontMatrix=ZV,this.textRenderingMode=ec.Fill,this.fillColor=0,this.strokeColor=0,this.activeSMask=null,this.lineCap=0,this.lineJoin=0,this.miterLimit=0,this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.browserFontSize=1,this.textMatrix=$V,this.textMatrixScale=1,this.fontMatrix=ZV,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=ec.Fill,this.textRise=0,this.fillColor=0,this.strokeColor=0,this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.ctxMatrix=new Ln,this.clipBox=[0,0,e,t],this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}clone(){return Object.create(this)}setCurrentPoint(e,t){this.x=e,this.y=t}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}updatePathMinMax(e,t,n){[t,n]=ai.Util.applyTransform([t,n],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,n)}getPathBoundingBox(e=YV.Fill,t=null){let n=[this.minX,this.minY,this.maxX,this.maxY];if(e===YV.Stroke){if(!t)throw new Error("Stroke bounding box must include transform.");let e=ai.Util.singularValueDecompose2dScale(t),i=e[0]*this.lineWidth/2,r=e[1]*this.lineWidth/2;n[0]-=i,n[1]-=r,n[2]+=i,n[3]+=r}return n}updateRectMinMax(e,t){let n=ai.Util.applyTransform(t,e),i=ai.Util.applyTransform(t.slice(2),e);this.minX=Math.min(this.minX,n[0],i[0]),this.minY=Math.min(this.minY,n[1],i[1]),this.maxX=Math.max(this.maxX,n[0],i[0]),this.maxY=Math.max(this.maxY,n[1],i[1])}updateScalingPathMinMax(e,t){ai.Util.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.maxX=Math.max(this.maxX,t[1]),this.minY=Math.min(this.minY,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,n,i,r,a,s,o,l,h){let c=ai.Util.bezierBoundingBox(t,n,i,r,a,s,o,l);if(h)return h[0]=Math.min(h[0],c[0],c[2]),h[1]=Math.max(h[1],c[0],c[2]),h[2]=Math.min(h[2],c[1],c[3]),void(h[3]=Math.max(h[3],c[1],c[3]));this.updateRectMinMax(e,c)}updateClipFromPath(){let e=ai.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}getClippedPathBoundingBox(e=YV.Fill,t=null){return ai.Util.intersect(this.clipBox,this.getPathBoundingBox(e,t))||[]}},_1e=class extends dr{constructor(e,t){super(e,{id:"PdfLoaderPlugin"}),this.cfg=t||{}}loadAsync(e,t){return ft(this,null,(function*(){let n=this.viewer;n.increaseJobCount();let i=this.cfg.font,r=this.cfg.pdfWorker,a=yield new ah({font:i,pdfWorker:r}).loadAsync(e,t);return n.decreaseJobCount(),a}))}},T1e=class extends up{constructor(e,t){super(t),this.defaultModelConfig={src:"",merge:!0},this.viewer=e}formats(){return["dxf","pdf"]}uploadFiles(e){for(let t=0;t{let n=Math.floor(100*t.loaded/t.total);se.info(`[Uploader] Loading ${null==e?void 0:e.name}, ${n}%`)}))}))}uploadSinglePdf(e){return ft(this,null,(function*(){let t=t=>{let n=Math.floor(100*t.loaded/t.total);se.info(`[Uploader] Loading ${null==e?void 0:e.name}, ${n}%`)};try{let n=this.viewer;n.increaseJobCount();let i={font:n.fontManager,pdfWorker:"libs/pdf/pdf.worker.min.js"},r={merge:!0,src:URL.createObjectURL(e),modelId:e.name};new ah(i).loadAsync(r,t).then((e=>{this.viewer.addModel(e),this.onSuccess&&this.onSuccess({}),n.decreaseJobCount(),se.info(`[Uploader] Loaded model '${r.src}'`)}))}catch(e){se.info(e)}}))}},w1e=class extends up{constructor(e,t){super(t),this.viewer=e}formats(){return["png","jpg","jpeg"]}uploadFiles(e){let t={panoramas:[],id:"viewpoint_1",name:"",position:[0,1,0],initialDirection:[0,0,1]};if(1===e.length){let n=[];n.push(URL.createObjectURL(e[0])),t.panoramas.push({id:"panorama_1",images:n}),this.viewer.setViewpoints([t]),this.viewer.activatePanoramaById(t.id,t.panoramas[0].id)}else if(6===e.length){let n=t=>{let n="";for(let i=0;i({position:new O(e,t,n),rotation:new Xn(i,r,a)}),Lyt={Front:Ri(wr({},Zs([0,0,1],[0,0,0])),{label:"NavCube.front"}),Right:Ri(wr({},Zs([1,0,0],[0,mi,0])),{label:"NavCube.right"}),Back:Ri(wr({},Zs([0,0,-1],[0,Math.PI,0])),{label:"NavCube.back"}),Left:Ri(wr({},Zs([-1,0,0],[0,-mi,0])),{label:"NavCube.left"}),Top:Ri(wr({},Zs([0,1,0],[-mi,0,0])),{label:"NavCube.top"}),Bottom:Ri(wr({},Zs([0,-1,0],[mi,0,0])),{label:"NavCube.bottom"})},Dyt=[Zs([0,1,1],[-Vr,0,-mi]),Zs([0,1,-1],[-3*Vr,0,-mi]),Zs([0,-1,1],[Vr,0,-mi]),Zs([0,-1,-1],[3*Vr,0,-mi]),Zs([1,1,0],[-mi,Vr,0]),Zs([1,-1,0],[-mi,3*Vr,0]),Zs([-1,1,0],[-mi,-Vr,0]),Zs([-1,-1,0],[-mi,-3*Vr,0]),Zs([1,0,1],[0,Vr,0]),Zs([1,0,-1],[0,3*Vr,0]),Zs([-1,0,1],[0,-Vr,0]),Zs([-1,0,-1],[0,-3*Vr,0])],Oyt=[{position:new O(1,1,1),rotation:[new Xn(-mi,mi,-Vr),new Xn(-mi,0,Vr),new Xn(0,0,3*Vr)]},{position:new O(1,1,-1),rotation:[new Xn(0,mi,3*Vr),new Xn(-mi,0,3*Vr),new Xn(0,Math.PI,-3*Vr)]},{position:new O(-1,1,-1),rotation:[new Xn(Math.PI,-mi,Vr),new Xn(-mi,0,-3*Vr),new Xn(0,Math.PI,3*Vr)]},{position:new O(-1,1,1),rotation:[new Xn(0,-mi,3*Vr),new Xn(-mi,0,-Vr),new Xn(0,0,-3*Vr)]},{position:new O(1,-1,1),rotation:[new Xn(0,mi,-Vr),new Xn(-mi,Math.PI,-Vr),new Xn(0,0,Vr)]},{position:new O(1,-1,-1),rotation:[new Xn(-mi,mi,3*Vr),new Xn(mi,0,Vr),new Xn(0,Math.PI,-Vr)]},{position:new O(-1,-1,1),rotation:[new Xn(0,-mi,Vr),new Xn(mi,0,-3*Vr),new Xn(0,0,-Vr)]},{position:new O(-1,-1,-1),rotation:[new Xn(0,-mi,-Vr),new Xn(mi,0,-Vr),new Xn(0,Math.PI,Vr)]}],$2=class extends on{constructor(e={}){super(),this.NAVCUBE_SIZE=100,this.clickHandler=e.onClick,(0,fg.forEach)(Lyt,(e=>{this.createPlane(e)})),(0,fg.forEach)(Dyt,(e=>{this.createEdge(e)})),(0,fg.forEach)(Oyt,((e,t)=>{this.createCorner(e,t)}))}createPlane(e){let t=e.position.clone().multiplyScalar(this.NAVCUBE_SIZE/2),{rotation:n,label:i}=e,r=document.createElement("div");r.style.width=this.NAVCUBE_SIZE+"px",r.style.height=this.NAVCUBE_SIZE+"px",r.classList.add("navcube-plane"),r.classList.add("outer");let a=document.createElement("div");a.style.width=this.NAVCUBE_SIZE-4+"px",a.style.height=this.NAVCUBE_SIZE-4+"px",a.innerHTML=eh(i),a.classList.add("navcube-plane"),a.classList.add("inner"),r.appendChild(a);let s=new cg(r);s.position.copy(t),s.rotation.copy(n),this.add(s),r.addEventListener("click",(()=>{this.clickHandler&&this.clickHandler(t.clone().normalize(),n)}))}createEdge(e){let t=e.position.clone().multiplyScalar(this.NAVCUBE_SIZE/2),n=document.createElement("div");n.style.width="4px",n.style.height=this.NAVCUBE_SIZE-40+"px",n.style.background=S1e,n.classList.add("navcube-edge");let i=new cg(n);i.position.copy(t),i.rotation.copy(e.rotation),this.add(i),n.addEventListener("click",(()=>{this.clickHandler&&this.clickHandler(t.clone().normalize(),e.rotation)}))}createCorner(e,t){let n=n=>{n.addEventListener("click",(()=>{this.clickHandler&&this.clickHandler(e.position.clone().normalize(),new Xn)})),n.addEventListener("mouseenter",(()=>{let e=document.getElementsByClassName("group-"+t);(0,fg.forEach)(e,(e=>{e instanceof HTMLElement&&e.classList.add("highlight")}))})),n.addEventListener("mouseleave",(()=>{let e=document.getElementsByClassName("group-"+t);(0,fg.forEach)(e,(e=>{e instanceof HTMLElement&&e.classList.remove("highlight")}))}))},i=e.position.clone().multiplyScalar(this.NAVCUBE_SIZE/2+.5),r=document.createElement("div");r.style.borderTop=14*Math.sqrt(3)+"px solid #efefef",r.style.borderLeft="14px solid transparent",r.style.borderRight="14px solid transparent",r.classList.add("navcube-corner"),r.classList.add("group-"+t);let a=new cg(r);a.position.copy(i).lerp(e.position,.14);let s=Math.atan2(i.z,i.x);a.rotateY(i.z*i.x<0?Math.PI+s:s);let o=(new Xn).setFromVector3(i.clone().normalize());a.rotateX(-o.y),i.y<0&&a.rotateZ(Math.PI),this.add(a);let l=(t,r,a)=>{let s=document.createElement("div");s.style.borderTop=`13px solid ${S1e}`,s.style.borderLeft="13px solid transparent",s.style.borderRight="13px solid transparent",s.classList.add("navcube-corner-plane"),s.classList.add("group-"+r);let o=new cg(s),l=e.position.clone();l.setComponent(a,0),o.position.copy(i).sub(l),o.rotateX(t.x),o.rotateY(t.y),o.rotateZ(t.z),this.add(o),n(s)};(0,fg.forEach)(e.rotation,((e,n)=>{l(e,t,n)})),n(r)}},M1e=class extends dr{constructor(e,t){super(e,{id:"NavCubePlugin"}),this.cfg=t||{},this.init()}init(){this.initRenderer(),this.initScene(),this.animate()}initRenderer(){var e;let t,n=135,i=135;if(this.cfg.containerId&&(t=document.getElementById(this.cfg.containerId),t&&(n=t.clientWidth,i=t.clientHeight)),!t){let n="navCube";t=document.createElement("div"),t.id=n,null==(e=this.viewer.widgetContainer)||e.appendChild(t)}this.renderer=new p2,this.renderer.setSize(n,i),this.renderer.domElement.classList.add("css3d-navcube"),t.appendChild(this.renderer.domElement)}initScene(){this.scene=new _i;let e=window.innerWidth/window.innerHeight;this.camera=new Ur(200*e/-2,200*e/2,100,-100,1,1e3),this.camera.position.set(-200,200,200),this.scene.add(this.camera),this.navCube=new $2({onClick:e=>{let t=this.viewer.controls;if(!(this.camera&&e&&this.viewer.camera&&t))return;let n=t instanceof ba?t.getTarget(new O):t.target,i=this.viewer.camera.position.distanceTo(n);this.viewer.flyTo(n.clone().add(e.clone().multiplyScalar(i)),n)}}),this.scene.add(this.navCube)}render(){this.renderer&&this.scene&&this.camera&&(this.update(),this.renderer.render(this.scene,this.camera))}animate(){requestAnimationFrame(this.animate.bind(this)),this.render()}update(){if(!this.viewer||!this.viewer.camera)return;let e=this.viewer.camera;if(e){let t=new O;e.getWorldDirection(t);let n=e.up;this.updateCameraDirection(t,n)}}updateCameraDirection(e,t){this.camera&&e&&(e.normalize(),this.camera.position.set(20*-e.x+0,20*-e.y+0,20*-e.z+0),this.camera.lookAt(0,0,0),this.camera.up=t)}destroy(){super.destroy(),this.scene&&this.camera&&this.navCube&&(this.scene.clear(),this.camera=void 0,this.navCube=void 0,this.scene=void 0)}},X_=function(){var e=0,t=document.createElement("div");function n(e){return t.appendChild(e.dom),e}function i(n){for(var i=0;i=a+1e3&&(o.update(1e3*s/(e-a),100),a=e,s=0,h)){var t=performance.memory;h.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){r=this.end()},domElement:t,setMode:i}};X_.Panel=function(e,t,n){var i=1/0,r=0,a=Math.round,s=a(window.devicePixelRatio||1),o=80*s,l=48*s,h=3*s,c=2*s,u=3*s,d=15*s,p=74*s,f=30*s,m=document.createElement("canvas");m.width=o,m.height=l,m.style.cssText="width:80px;height:48px";var g=m.getContext("2d");return g.font="bold "+9*s+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=n,g.fillRect(0,0,o,l),g.fillStyle=t,g.fillText(e,h,c),g.fillRect(u,d,p,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(u,d,p,f),{dom:m,update:function(l,v){i=Math.min(i,l),r=Math.max(r,l),g.fillStyle=n,g.globalAlpha=1,g.fillRect(0,0,o,d),g.fillStyle=t,g.fillText(a(l)+" "+e+" ("+a(i)+"-"+a(r)+")",h,c),g.drawImage(m,u+s,d,p-s,f,u,d,p-s,f),g.fillRect(u+p-s,d,s,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(u+p-s,d,s,a((1-l/v)*f))}}};var R1e=X_,A1e=class extends dr{constructor(e){super(e,{id:"StatsPlugin"}),this.init()}init(){var e;let t=new R1e;t.setMode(0);let n=document.createElement("div");n.classList.add("statsOutput"),n.appendChild(t.domElement),null==(e=this.viewer.widgetContainer)||e.append(n),this.stats=t,this.viewer.addEventListener("OnAnimate",(()=>{var e;null==(e=this.stats)||e.update()}))}show(){var e;null==(e=this.stats)||e.showPanel(0)}hide(){var e;null==(e=this.stats)||e.showPanel(-1)}destroy(){super.destroy(),this.stats=void 0}},Y_=class extends xt{constructor(e,t,n,i=4e3,r=32,a=15,s=new O,o=new O(0,.7,.5)){super();let l={topColor:{value:e},skylineColor:{value:t},bottomColor:{value:n},offset:{value:400},exponent:{value:.9},skyCenter:{value:s||new O},sunDirection:{value:o.normalize()}};this.geometry=new za(i,r,a),this.material=new cn({uniforms:l,vertexShader:Y_.vertexShader,fragmentShader:Y_.fragmentShader,side:Ki}),this.name=Y_.NAME,this.matrixAutoUpdate=!1,this.layers.disable(12)}},il=Y_;il.NAME="SKYBOX",il.MIN_SKY_RADIUS=4e3,il.MAX_SKY_RADIUS=2e4,il.vertexShader="\n varying vec3 vWorldPosition;\n void main() {\n vec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n vWorldPosition = worldPosition.xyz;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",il.fragmentShader="\n uniform vec3 topColor;\n uniform vec3 skylineColor;\n uniform vec3 bottomColor;\n uniform float offset;\n uniform float exponent;\n uniform vec3 skyCenter;\n uniform vec3 sunDirection;\n varying vec3 vWorldPosition;\n // Used to find the position to draw the sun. Sun size is bigger when this value is smaller\n const float sunDirectionDotThreshold = 0.98;\n\n void main() {\n vec3 position = vec3(vWorldPosition.x - skyCenter.x, vWorldPosition.y - skyCenter.y, vWorldPosition.z - skyCenter.z);\n vec3 normalizedPosition = normalize( position + offset );\n float h = normalizedPosition.y;\n vec3 color;\n if (h > 0.0) {\n color = mix( skylineColor, topColor, pow( h, exponent ) );\n\n // draw the sun\n float dotResult = dot(sunDirection, normalizedPosition);\n if (dotResult > sunDirectionDotThreshold) {\n const float sunSize = 1.0 - sunDirectionDotThreshold; // maximum sun size\n const vec3 sunColor = vec3(1.0, 1.0, 1.0);\n color = mix(color, sunColor, pow((dotResult + sunSize - 1.0) / sunSize, 3.0));\n }\n } else {\n color = mix( skylineColor, bottomColor, pow( -h, exponent ) );\n }\n gl_FragColor = vec4(color , 1.0);\n }";var C1e=class extends dr{constructor(e,t){super(e,{id:"SkyboxPlugin"}),null!=t&&t.color?this.setSkyboxByColor(t.color):this.setSkyboxByGradientColors(),e.addEventListener("ModelLoaded",(()=>{let t=e.getBBox(),n=this.viewer.cameraCfg;if(t){if(t=t.clone(),n&&n.eye&&n.look){let e=n&&Mt.arrayToVector3(n.eye),i=n&&Mt.arrayToVector3(n.look),r=new Ot;r.setFromPoints([e,i]),t.union(r)}this.updateGradientColorSkybox(t)}}))}setSkyboxByColor(e=[.92,.95,.96]){let t=this.viewer;!t||!t.scene||(this.gradientColorSkybox&&(this.gradientColorSkybox.visible=!1),t.scene.background=this.rgb2Color(e),t.enableRender())}setSkyboxByGradientColors(e=[.52,.71,.96],t=[1,1,1],n=[.6,.6,.6]){var i;this.gradientColorSkybox&&(this.gradientColorSkybox.removeFromParent(),this.gradientColorSkybox=void 0);let r=this.rgb2Color(e),a=this.rgb2Color(t),s=this.rgb2Color(n);this.gradientColorSkybox=new il(r,a,s),null==(i=this.viewer.scene)||i.add(this.gradientColorSkybox),this.viewer.enableRender()}setSkyboxByCubeTexture(e){let t=this.viewer;if(!t||!t.scene)return;this.gradientColorSkybox&&(this.gradientColorSkybox.visible=!1);let n=new Pb;t.scene.background=n.load(e),t.enableRender()}updateGradientColorSkybox(e){if(!this.gradientColorSkybox)return;let t=2*(e.max.x-e.min.x+(e.max.y-e.min.y)+(e.max.z-e.min.z));til.MAX_SKY_RADIUS&&(t=il.MAX_SKY_RADIUS),this.gradientColorSkybox.geometry=new za(t,32,15),this.viewer.enableRender()}destroy(){var e;super.destroy(),null==(e=this.gradientColorSkybox)||e.removeFromParent(),this.gradientColorSkybox=void 0,this.viewer.scene&&(this.viewer.scene.background=null)}rgb2Color(e){let t=e[0]||0,n=e[1]||0,i=e[2]||0,r=new ct;return r.setRGB(t,n,i),r}};function kyt(e,t,n,i,r){let a=document.createElement("span");return a.style.font="1px serif",a.style.fontFamily=e,a.style.fontSize=`${t}px`,a.style.fontStyle=n,a.style.fontVariant=i,a.style.fontWeight=r,a.style.font}var Fyt=Object.freeze({text:"",color:"#fff",alignment:"center",backgroundColor:0,fontFamily:"sans-serif",fontSize:16,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",lineGap:1/4,padding:.5,strokeColor:"#000",strokeWidth:0}),Z2=class extends qr{constructor(e,t=document.createElement("canvas")){super(t),this.canvas=t,this.isTextTexture=!0,this.needsRedraw=!0,this.contentOffset=0,this.lineOffset=0,this.width=0,this.height=0,this.pixelRatio=Math.max(window.devicePixelRatio||1),this.computeOptimalPixelRatio=()=>{let e=new O,t=new be,n=new O,i=new O,r=new be;return(a,s,o)=>{var l,h;if(r.set(this.width,this.height),r.x&&r.y){a.getWorldPosition(n),o.getWorldPosition(e);let c=n.distanceTo(e);if(o.isPerspectiveCamera&&(c*=2*Math.tan(An.degToRad(o.fov)/2)),(o.isPerspectiveCamera||o.isOrthographicCamera)&&(c/=o.zoom),c){a.getWorldScale(i);let e=null!=(h=null==(l=s.capabilities)?void 0:l.maxTextureSize)?h:1/0;return s.getDrawingBufferSize(t),Math.min(Math.max(i.x/c*(t.x/r.x),i.y/c*(t.y/r.y)),e/r.x,e/r.y)}}return 0}},this.cfg=wr(wr({},Fyt),e)}get lines(){let{text:e}=this.cfg;return e?e.split("\n"):[]}get font(){let{fontFamily:e,fontSize:t,fontStyle:n,fontVariant:i,fontWeight:r}=this.cfg;return kyt(e,t,n,i,r)}getContentWidth(){let{font:e,lines:t}=this,n=document.createElement("canvas").getContext("2d");return n.font=e,Math.max(...t.map((e=>n.measureText(e).width)))}initDraw(){let{lineGap:e,padding:t,strokeWidth:n}=this.cfg;t*=this.cfg.fontSize,e*=this.cfg.fontSize,n*=this.cfg.fontSize;let i=this.lines.length,r=this.cfg.fontSize+e,a=t+n/2,s=(i?this.getContentWidth():0)+2*a,o=(i?this.cfg.fontSize+r*(i-1):0)+2*a;this.width=s,this.height=o,this.contentOffset=a,this.lineOffset=r}getDrawPosition(e){let t=this.contentOffset+this.cfg.fontSize/2;switch(e){case"left":return{x:this.contentOffset,y:t};case"right":return{x:this.width-this.contentOffset,y:t}}return{x:this.width/2,y:t}}draw(){let e=this.canvas.getContext("2d"),{alignment:t,backgroundColor:n,color:i,strokeColor:r,strokeWidth:a}=this.cfg;e.fillStyle="#"+n.toString(16),e.fillRect(0,0,e.canvas.width,e.canvas.height),Object.assign(e,{fillStyle:i,font:this.font,lineWidth:a,miterLimit:1,strokeStyle:r,textAlign:t,textBaseline:"middle"});let{x:s,y:o}=this.getDrawPosition(t),l=o;this.lines.forEach((t=>{e.fillText(t,s,l),a&&e.strokeText(t,s,l),l+=this.lineOffset}))}getDrawingBufferWidth(){return An.ceilPowerOfTwo(this.width*this.pixelRatio)}getDrawingBufferHeight(){return An.ceilPowerOfTwo(this.height*this.pixelRatio)}redrew(){if(this.needsRedraw){this.initDraw();let e=this.canvas,t=e.getContext("2d");t.clearRect(0,0,e.width,e.height),e.width=this.getDrawingBufferWidth(),e.height=this.getDrawingBufferHeight(),e.width&&e.height?(t.save(),t.scale(e.width/this.width,e.height/this.height),this.draw(),t.restore()):e.width=e.height=1,this.needsRedraw=!1,this.needsUpdate=!0}}setPixelRatio(e){if(this.pixelRatio!==e){let t=this.getDrawingBufferWidth(),n=this.getDrawingBufferHeight();this.pixelRatio=e;let i=this.getDrawingBufferWidth(),r=this.getDrawingBufferHeight();(i!==t||r!==n)&&(this.needsRedraw=!0)}}setOptimalPixelRatio(e,t,n){let i=this.computeOptimalPixelRatio();this.setPixelRatio(i(e,t,n))}updateConfig(e){this.cfg=wr(wr({},this.cfg),e),this.needsRedraw=!0}};function JV(e,t,n){let i=new ct(e),r=new ct(t);return i.lerp(r,n).getHex()}var Or=(e=>(e[e.Rotate0=0]="Rotate0",e[e.Rotate90=Math.PI/2]="Rotate90",e[e.Rotate180=Math.PI]="Rotate180",e[e.Rotate270=1.5*Math.PI]="Rotate270",e))(Or||{}),oh=new O(1,0,0),Ra=new O(0,1,0),Cs=new O(0,0,1),P1e={right:{text:"\u53f3",name:"RightFace",position:new O(50,0,0),rotation:{axis:Ra,rad:Or.Rotate90}},left:{text:"\u5de6",name:"LeftFace",position:new O(-50,0,0),rotation:{axis:Ra,rad:Or.Rotate270}},top:{text:"\u4e0a",name:"TopFace",position:new O(0,50,0),rotation:{axis:oh,rad:Or.Rotate270}},bottom:{text:"\u4e0b",name:"BottomFace",position:new O(0,-50,0),rotation:{axis:oh,rad:Or.Rotate90}},front:{text:"\u524d",name:"FrontFace",position:new O(0,0,50),rotation:{axis:Ra,rad:0}},back:{text:"\u540e",name:"BackFace",position:new O(0,0,-50),rotation:{axis:Ra,rad:Or.Rotate180}}},K2=class extends on{constructor(e){super(),this.name="ViewCube",this.AXIS_LENGTH=130,this.AXIS_COLOR_X=16711680,this.AXIS_COLOR_Y=65280,this.AXIS_COLOR_Z=255,this.FACE_BACKGROUND_COLOR=16777215,this.FACE_HOVER_BACKGROUND_COLOR=8618481,this.EDGE_COLOUR=13290452,this.EDGE_OPACITY=.1,this.EDGE_SIZE=new be(70,12),this.CORNER_WIDTH=12,this.CORNER_COLOR=13290452,this.CORNER_OPACITY=1,this.faces=[],this.dirty=!1,this.showAxes=(null==e?void 0:e.showAxes)||!1,this.lineColor=(null==e?void 0:e.lineColor)||9343125,this.init()}init(){this.showAxes&&this.add(this.createAxes()),this.add(this.createViewCubeFaces()),this.add(this.createViewCubeEdges()),this.add(this.createViewCubeCorners())}createAxes(){let e=new on,t=new O(-50,-50,-50),n=new O(1,0,0),i=new O(0,1,0),r=new O(0,0,1),a=this.AXIS_LENGTH/15,s=this.AXIS_LENGTH/20,o=new Mc(n,t,this.AXIS_LENGTH,this.AXIS_COLOR_X,a,s),l=new Mc(i,t,this.AXIS_LENGTH,this.AXIS_COLOR_Y,a,s),h=new Mc(r,t,this.AXIS_LENGTH,this.AXIS_COLOR_Z,a,s);return e.add(o,l,h),e}createViewCubeFaces(){let e=new on,t=[],n=new ln({color:this.FACE_BACKGROUND_COLOR,opacity:0,transparent:!0});Object.keys(P1e).forEach((e=>{let i=P1e[e],r=new Z2({text:i.text,fontSize:100,color:"#cccccc",backgroundColor:this.FACE_BACKGROUND_COLOR,padding:.8,fontWeight:"bold"});r.redrew();let a=new ln({map:r,opacity:1,transparent:!0});t.push(a);let s=this.createViewCubeFace(i.name,n,i.position,i.rotation);s.layers.enableAll(),s.userData={textTexture:r,tick:0,translateTick:0},this.faces.push(s)})),e.add(...this.faces);let i=new va(76,76,76),r=new xt(i,t);this.innerViewCubeMesh=r,e.add(r);let a=new Cu(new va(100,100,100)),s=new ln({color:this.lineColor}),o=new Wr(a,s);return e.add(o),e.position.set(0,0,0),e}createViewCubeFace(e,t,n,i){let r=new ui(76,76),a=new xt(r,t);return a.name=e,a.rotateOnAxis(i.axis,i.rad),a.position.copy(n),a}createViewCubeEdges(){let e=new on,t=this.createEdge("TopFrontEdge",new O(0,51,51),[{axis:Cs,rad:Or.Rotate180}]),n=this.createEdge("TopRightEdge",new O(51,51,0),[{axis:oh,rad:Or.Rotate180},{axis:Ra,rad:Or.Rotate90},{axis:Cs,rad:0}]),i=this.createEdge("TopBackEdge",new O(0,51,-51),[{axis:Cs,rad:Or.Rotate180},{axis:Ra,rad:Or.Rotate180}]),r=this.createEdge("TopLeftEdge",new O(-51,51,0),[{axis:oh,rad:Or.Rotate90},{axis:Ra,rad:Or.Rotate180},{axis:Cs,rad:Or.Rotate90}]),a=this.createEdge("BottomFrontEdge",new O(0,-51,51),[{axis:Cs,rad:0}]),s=this.createEdge("BottomRightEdge",new O(51,-51,0),[{axis:oh,rad:Or.Rotate90},{axis:Ra,rad:0},{axis:Cs,rad:Or.Rotate90}]),o=this.createEdge("BottomBackEdge",new O(0,-51,-51),[{axis:Cs,rad:0},{axis:Ra,rad:Or.Rotate180}]),l=this.createEdge("BottomLeftEdge",new O(-51,-51,0),[{axis:oh,rad:Or.Rotate90},{axis:Ra,rad:Or.Rotate270},{axis:Cs,rad:Or.Rotate90}]),h=this.createEdge("FrontRightEdge",new O(51,0,51),[{axis:Cs,rad:Or.Rotate90}]),c=this.createEdge("BackRightEdge",new O(51,0,-51),[{axis:Cs,rad:Or.Rotate90},{axis:Ra,rad:Or.Rotate180}]),u=this.createEdge("BackLeftEdge",new O(-51,0,-51),[{axis:Cs,rad:Or.Rotate270},{axis:Ra,rad:Or.Rotate180}]),d=this.createEdge("FrontLeftEdge",new O(-51,0,51),[{axis:Cs,rad:Or.Rotate270}]);return e.add(t),e.add(n),e.add(i),e.add(r),e.add(a),e.add(s),e.add(o),e.add(l),e.add(h),e.add(c),e.add(u),e.add(d),e}createEdge(e,t,n){let i=new on,r=new ui(this.EDGE_SIZE.x,this.EDGE_SIZE.y),a=new ln({color:this.EDGE_COLOUR,opacity:this.EDGE_OPACITY,transparent:!0}),s={tick:0},o=new xt(r,a);o.name=e,o.userData=s,o.position.setY(this.EDGE_SIZE.y/2),o.layers.enableAll();let l=new xt(r,a);return l.name=e,l.userData=s,l.position.setZ(-this.EDGE_SIZE.y/2),l.rotateOnAxis(new O(1,0,0),Math.PI/2),l.layers.enableAll(),i.add(o),i.add(l),i.position.copy(t),n.forEach((e=>{i.rotateOnAxis(e.axis,e.rad)})),i}createViewCubeCorners(){let e=new on,t=this.createCorner("TopFrontLeftCorner",new O(-51,51,51),[{axis:Cs,rad:Or.Rotate270}]),n=this.createCorner("TopFrontRightCorner",new O(51,51,51),[{axis:Cs,rad:Or.Rotate180}]),i=this.createCorner("TopBackRightCorner",new O(51,51,-51),[{axis:oh,rad:Or.Rotate90},{axis:Ra,rad:Or.Rotate180},{axis:Cs,rad:0}]),r=this.createCorner("TopBackLeftCorner",new O(-51,51,-51),[{axis:oh,rad:Or.Rotate90},{axis:Ra,rad:Or.Rotate180},{axis:Cs,rad:Or.Rotate90}]),a=this.createCorner("BottomFrontLeftCorner",new O(-51,-51,51),[{axis:Cs,rad:0}]),s=this.createCorner("BottomFrontRightCorner",new O(51,-51,51),[{axis:Cs,rad:Or.Rotate90}]),o=this.createCorner("BottomBackRightCorner",new O(51,-51,-51),[{axis:oh,rad:0},{axis:Ra,rad:Or.Rotate180},{axis:Cs,rad:0}]),l=this.createCorner("BottomBackLeftCorner",new O(-51,-51,-51),[{axis:oh,rad:0},{axis:Ra,rad:Or.Rotate180},{axis:Cs,rad:Or.Rotate90}]);return e.add(t),e.add(n),e.add(i),e.add(r),e.add(a),e.add(s),e.add(o),e.add(l),e}createCorner(e,t,n){let i=new on,r=new ui(this.CORNER_WIDTH,this.CORNER_WIDTH),a=new ln({color:this.CORNER_COLOR,opacity:this.CORNER_OPACITY,transparent:!0}),s={tick:0},o=new xt(r,a);o.name=e,o.userData=s,o.position.set(this.CORNER_WIDTH/2,this.CORNER_WIDTH/2,0),o.layers.enableAll();let l=new xt(r,a);l.name=e,l.userData=s,l.position.set(this.CORNER_WIDTH/2,0,-this.CORNER_WIDTH/2),l.rotateOnAxis(new O(1,0,0),Math.PI/2),l.layers.enableAll();let h=new xt(r,a);return h.name=e,h.userData=s,h.position.set(0,this.CORNER_WIDTH/2,-this.CORNER_WIDTH/2),h.rotateOnAxis(new O(0,1,0),-Math.PI/2),h.layers.enableAll(),i.add(o),i.add(l),i.add(h),i.position.copy(t),n.forEach((e=>{i.rotateOnAxis(e.axis,e.rad)})),i}getBbox(){let e=new Ot;return e.setFromObject(this),e}getDirectionByViewCubeName(e){let t;switch(e){case"TopFace":t=new O(0,1,0);break;case"BottomFace":t=new O(0,-1,0);break;case"FrontFace":t=new O(0,0,1);break;case"BackFace":t=new O(0,0,-1);break;case"LeftFace":t=new O(-1,0,0);break;case"RightFace":t=new O(1,0,0);break;case"TopFrontEdge":t=new O(0,1,1);break;case"TopRightEdge":t=new O(1,1,0);break;case"TopBackEdge":t=new O(0,1,-1);break;case"TopLeftEdge":t=new O(-1,1,0);break;case"BottomFrontEdge":t=new O(0,-1,1);break;case"BottomRightEdge":t=new O(1,-1,0);break;case"BottomBackEdge":t=new O(0,-1,-1);break;case"BottomLeftEdge":t=new O(-1,-1,0);break;case"FrontLeftEdge":t=new O(-1,0,1);break;case"FrontRightEdge":t=new O(1,0,1);break;case"BackRightEdge":t=new O(1,0,-1);break;case"BackLeftEdge":t=new O(-1,0,-1);break;case"TopFrontLeftCorner":t=new O(-1,1,1);break;case"TopFrontRightCorner":t=new O(1,1,1);break;case"TopBackRightCorner":t=new O(1,1,-1);break;case"TopBackLeftCorner":t=new O(-1,1,-1);break;case"BottomFrontLeftCorner":t=new O(-1,-1,1);break;case"BottomFrontRightCorner":t=new O(1,-1,1);break;case"BottomBackRightCorner":t=new O(1,-1,-1);break;case"BottomBackLeftCorner":t=new O(-1,-1,-1)}return t}update(){this.traverse((e=>{e instanceof xt&&this.updateViewCube(e)}))}updateViewCube(e){if(this.updateMeshTick(e),e.name.indexOf("Face")>-1){let t=e.userData.textTexture;if(t){let n=JV(this.FACE_BACKGROUND_COLOR,this.FACE_HOVER_BACKGROUND_COLOR,e.userData.tick);t.updateConfig({backgroundColor:n}),e.userData.tick>0&&t.redrew()}if(this.innerViewCubeMesh){this.updateMeshTick(e,"translateTick",2);let t=e.position.clone().normalize(),n=Math.max(2*e.userData.translateTick-2,0);t.multiplyScalar(7*n),n>0&&this.innerViewCubeMesh.position.copy(t)}}else if(e.name.indexOf("Edge")>-1){let t=e.material,n=JV(this.EDGE_COLOUR,this.FACE_HOVER_BACKGROUND_COLOR,e.userData.tick);t.color.set(n),t.opacity=e.userData.tick}else if(e.name.indexOf("Corner")>-1){let t=e.material,n=JV(this.CORNER_COLOR,this.FACE_HOVER_BACKGROUND_COLOR,e.userData.tick);t.color.set(n);let i=1+.3*e.userData.tick;e.parent&&e.parent.scale.set(i,i,i)}}updateMeshTick(e,t="tick",n=1){void 0!==e.userData[t]&&(e.name===this.activateMeshName&&e.userData[t]0&&(e.userData[t]-=.05),e.userData[t]>0&&e.userData[t]{var t,n;let i=this.getNdcPointByEvent(e);if(!i)return;null==(t=e.originalEvent)||t.stopPropagation();let r=this.getIntersects(i);if(this.lastCoords=i,!r||0===r.length)return;let a=r[0].object.name,s=null==(n=this.viewCube)?void 0:n.getDirectionByViewCubeName(a);s&&this.updateViewerCamera(s)},this.onPointerMove=e=>{var t;let n=this.getNdcPointByEvent(e);n&&(null==(t=e.originalEvent)||t.stopPropagation(),this.updateActivateMeshName(n),this.lastCoords=n)},this.onPointerleave=e=>{var t,n;null==(t=e.originalEvent)||t.stopPropagation(),this.lastCoords=void 0,null!=(n=this.viewCube)&&n.activateMeshName&&(this.viewCube.activateMeshName=void 0)},this.onClick=e=>{var t;null==(t=e.originalEvent)||t.stopPropagation()},this.updateCameraAndMeshName=()=>{var e;if(null==(e=this.viewer)||!e.camera)return;let t=this.viewer.camera,n=new O;t.getWorldDirection(n);let i=t.up;this.updateCameraDirection(n,i),this.renderEnabled=!0,this.lastCoords&&this.updateActivateMeshName(this.lastCoords)},this.cfg=t||{},this.init(),this.animate()}init(){Dn.isBrowser&&!this.cfg.context&&this.initDom(),this.initInputManager(),this.initScene(),this.initRenderer(),this.initCamera(),this.initLights(),this.initViewCube(),this.initEvents()}initDom(){var e;let t=document.getElementById(this.cfg.containerId);if(!t){se.error("[ViewCube] containerId:",this.cfg.containerId,"is not found in dom tree! will append to gemini-widget-container");let n="viewCube";t=document.createElement("div"),t.id=n,null==(e=this.viewer.widgetContainer)||e.appendChild(t),this.cfg.containerId=n}this.width=t.clientWidth,this.height=t.clientHeight,this.container=t}initInputManager(){this.container&&(this.inputManager=new Jo(this.container))}initScene(){let e=new _i;e.matrixAutoUpdate=!1,this.scene=e}initCamera(){if(!this.scene)return;let e=new Ur(-this.width/2,this.width/2,this.height/2,-this.height/2,.1,1e5);e.position.set(300,300,300),e.lookAt(0,0,0),e.zoom=10,e.updateProjectionMatrix(),this.scene.add(e),this.camera=e}initRenderer(){var e;this.renderer=new Ms({antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),this.renderer.setClearColor(11119017,0),null==(e=this.container)||e.appendChild(this.renderer.domElement)}initLights(){if(!this.scene)return;let e=new js(16777215,1.5);e.name="sun",this.directionalLight=e,this.scene.add(e),this.scene.add(e.target)}initViewCube(){if(!this.scene)return;let e=new K2(this.cfg);this.viewCube=e,this.scene.add(e),this.zoomToBbox(e.getBbox())}initEvents(){var e,t,n,i;null==(e=this.inputManager)||e.addEventListener("pointerdown",this.onPointerDown),null==(t=this.inputManager)||t.addEventListener("pointermove",this.onPointerMove),null==(n=this.inputManager)||n.addEventListener("pointerleave",this.onPointerleave),null==(i=this.inputManager)||i.addEventListener("click",this.onClick),this.viewer.addEventListener("AfterRender",this.updateCameraAndMeshName)}updateViewerCamera(e){var t,n;if(null==(t=this.viewer)||!t.camera||null==(n=this.viewer)||!n.controls)return;e.normalize();let i=this.viewer.controls instanceof ba?this.viewer.getBBox().getCenter(new O):this.viewer.controls.target,r=this.viewer.camera.position.distanceTo(i);this.viewer.flyTo(i.clone().add(e.clone().multiplyScalar(r)),i)}updateActivateMeshName(e){if(!this.viewCube)return;let t=this.getIntersects(e);if(this.viewCube.activateMeshName&&(this.viewCube.activateMeshName=void 0),!t||0===t.length)return;let n=t[0].object;this.viewCube.activateMeshName=n.name}getNdcPointByEvent(e){if(!this.container||!this.camera)return;let t=un.getScreenPointByEvent(e,this.container);return un.screenPoint2NdcPoint(t,this.camera,this.container)}getIntersects(e){return this.scene&&this.camera&&this.viewCube?(this.camera.updateMatrixWorld(),this.raycaster.layers.set(12),this.raycaster.setFromCamera(e,this.camera),this.raycaster&&this.raycaster.intersectObjects(this.viewCube.children,!0)||[]):void 0}updateCameraDirection(e,t){this.camera&&e&&(e.normalize(),this.camera.position.set(200*-e.x+0,200*-e.y+0,200*-e.z+0),this.camera.lookAt(0,0,0),this.camera.up=t,this.camera.updateMatrixWorld())}animate(){var e,t;this.requestAnimationFrameHandle=requestAnimationFrame(this.animate.bind(this)),this.scene&&this.camera&&this.viewCube&&(this.renderEnabled||this.viewCube.dirty)&&(null==(e=this.renderer)||e.render(this.scene,this.camera),this.renderEnabled=!1,this.viewCube.dirty=!1),null==(t=this.viewCube)||t.update()}zoomToBbox(e){if(!this.camera)return;let t=this.camera.right-this.camera.left,n=this.camera.top-this.camera.bottom,i=new O;e.getSize(i);let r=Math.sqrt(Math.pow(i.x,2)+Math.pow(i.y,2)+Math.pow(i.z,2)),a=Math.min(t/r,n/r);this.camera.position.set(i.x/2,i.y/2,i.z/2),this.camera.zoom=a,this.camera.updateProjectionMatrix()}destroy(){var e,t,n,i,r,a,s;super.destroy(),this.requestAnimationFrameHandle&&(cancelAnimationFrame(this.requestAnimationFrameHandle),this.requestAnimationFrameHandle=void 0),this.renderer&&(this.renderer.domElement.remove(),this.renderer.clear(),this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer=void 0),null==(e=this.container)||e.remove(),this.container=void 0,null==(t=this.scene)||t.clear(),this.scene=void 0,null==(n=this.directionalLight)||n.dispose(),this.directionalLight=void 0,null==(i=this.inputManager)||i.removeEventListener("pointerdown",this.onPointerDown),null==(r=this.inputManager)||r.removeEventListener("pointermove",this.onPointerMove),null==(a=this.inputManager)||a.removeEventListener("pointerleave",this.onPointerleave),null==(s=this.inputManager)||s.removeEventListener("click",this.onClick),this.viewer.removeEventListener("AfterRender",this.updateCameraAndMeshName)}},J2=class extends Bi{constructor(e,t){super(e),this.needsFrustumCulled=!1,this.image=t.image,this.min=t.min,this.max=t.max,this.radius=t.radius}getClassType(){return"OverviewMapDrawable"}getImageScreenSize(e,t,n){let i=this.transToScreenCoord(e,n),r=this.transToScreenCoord(t,n);return{width:Math.floor(Math.abs(i.x-r.x)),height:Math.floor(Math.abs(i.y-r.y))}}draw(e,t){let n=this.getImageScreenSize(this.max,this.min,t),i=new O;i.addVectors(this.max,this.min).multiplyScalar(.5);let r=this.transToScreenCoord(i,t),a=this.transToScreenCoord(t.position,t);e.save(),e.beginPath(),this.radius&&(e.arc(a.x,a.y,this.radius/this.tolerance,0,2*Math.PI,!0),e.clip()),e.drawImage(this.image,r.x-this.width/2,r.y-this.height/2,this.width,this.height),e.closePath(),e.restore(),this.width=n.width,this.height=n.height}drawSelect(){}getBounds(){let e=new O(-1,-3,-1),t=new O(1,-3,1);return new Ot(e,t)}isPointInPath(){return!1}getBBox(){return new Ot(this.min,this.max)}},$_=class extends Bi{constructor(e,t){super(e),this.hover=!1,this.needsFrustumCulled=!1,this.image=t.image,this.hoverImage=t.hoverImage,this.translate=t.translate,this.scale=t.scale||1,this.position=t.position instanceof O?t.position:new O(t.position.x,t.position.y,t.position.z),this.direction=t.direction?t.direction instanceof O?t.direction:new O(t.direction.x,t.direction.y,t.direction.z):void 0,this.radius=t.radius,this.rotation=t.rotation,this.enabledHover=!!t.enabledHover}direction2Rotation(e){return new be(e.x,e.z).angle()+Math.PI}getRotation(){let e=this.direction?this.direction2Rotation(this.direction):0,t=this.rotation?this.rotation:0;return t+=e,t}drawImage(e,t,n){let i=new be(1,1);this.translate&&i.set(this.translate.x,this.translate.y);let r=t.width*this.scale,a=t.height*this.scale,s=this.getRotation();s?(e.translate(n.x,n.y),e.rotate(s),e.drawImage(t,i.x*r,i.y*a,r,a),e.translate(-n.x,-n.y)):e.drawImage(t,n.x+i.x*r,n.y+i.y*a,r,a),this.width=r*this.tolerance,this.height=a*this.tolerance}draw(e,t){let n=this.position;if(this.radius){let e=new be(n.x,n.z),i=new be(t.position.x,t.position.z),r=e.distanceTo(i);0!==r&&n.lerp(t.position,1-this.radius/r)}let i=this.transToScreenCoord(n,t),r=this.hover&&this.hoverImage?this.hoverImage:this.image;e.save(),e.beginPath(),this.drawImage(e,r,i),e.closePath(),e.restore()}drawSelect(){}getBounds(){let e=new O(-1,0,-1),t=new O(1,0,1);return new Ot(e,t)}getClassType(){return"ImageDrawable"}isPointInPath(e,t){var n,i;if(null==t||!t.camera||!this.ctx||!this.enabledHover)return!1;let r=this.transToScreenCoord(this.position,t.camera),a=this.transToScreenCoord(e,t.camera);this.ctx.save(),this.ctx.clearRect(0,0,null==(n=this.ctx)?void 0:n.canvas.width,null==(i=this.ctx)?void 0:i.canvas.height),this.drawImage(this.ctx,this.image,r);let s=Math.max(devicePixelRatio,1),o=this.ctx.getImageData(a.x*s,a.y*s,1,1);return this.ctx.restore(),!!(o&&o.data[3]>0)}getBBox(){let e=this.position,t=new be(e.x,e.z),n=new Ot,i=new be(1,1);this.translate&&i.set(this.translate.x,this.translate.y);let r=[],a=i.x*this.width,s=i.y*this.height,o=(t,n)=>r.push(new be(e.x+t,e.z+n));o(a,s),o(a,s+this.height),o(a+this.width,s+this.height),o(a+this.width,s);let l=r.map((n=>{let i=this.getRotation();return i&&n.rotateAround(t,i),new O(n.x,e.y,n.y)}));return n.setFromPoints(l),n}},L1e=class extends Bi{constructor(e,t){super(e),this.needsFrustumCulled=!1,this.positions=t.positions,this.lineWidth=t.lineWidth||1,this.lineColor=t.lineColor||[0,0,0,1]}draw(e,t){let n=this.positions.map((e=>{let n=new O(e.x,e.y,e.z);return this.transToScreenCoord(n,t)}));e.save(),e.beginPath(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor),n.forEach(((t,n)=>{0===n?e.moveTo(t.x,t.y):e.lineTo(t.x,t.y)})),e.stroke(),e.restore()}getBounds(){let e=new O(-1,-2,-1),t=new O(1,-2,1);return new Ot(e,t)}drawSelect(){}getClassType(){return"LineDrawable"}isPointInPath(){return!1}getBBox(){let e=this.positions.map((e=>new O(e.x,e.y,e.z)));return(new Ot).setFromPoints(e)}},D1e=class extends Bi{constructor(e,t){super(e),this.needsFrustumCulled=!1,this.text=t.text,this.position=t.position,this.offset=t.offset||{x:0,y:0},this.textStyle=t.textStyle||{},this.radius=t.radius}getFont(){let e=this.textStyle,t="";return t+=(e.fontSize?e.fontSize:12)+"px ",t+=e.fontWeight?e.fontWeight+" ":"",t+=e.fontFamily?e.fontFamily:"Arial",t}drawRoundRect(e,t,n,i,r){let a=this.textStyle,s=a.borderRadius||0;i<2*s&&(s=i/2),r<2*s&&(s=r/2),e.save(),a.backgroundColor&&(e.fillStyle=a.backgroundColor),a.borderColor&&(e.strokeStyle=a.borderColor),a.borderWidth&&(e.lineWidth=a.borderWidth),e.beginPath(),e.moveTo(t+s,n),e.arcTo(t+i,n,t+i,n+r,s),e.arcTo(t+i,n+r,t,n+r,s),e.arcTo(t,n+r,t,n,s),e.arcTo(t,n,t+i,n,s),a.borderWidth&&e.stroke(),a.backgroundColor&&e.fill(),e.closePath(),a.backgroundColor&&e.fill(),e.restore()}draw(e,t){let n=this.textStyle,i=new O(this.position.x,this.position.y,this.position.z);if(this.radius){let e=new be(i.x,i.z),n=new be(t.position.x,t.position.z),r=e.distanceTo(n);0!==r&&i.lerp(t.position,1-this.radius/r)}let r=this.transToScreenCoord(i,t),a=this.getFont(),s=n.fontSize?n.fontSize:12;e.font=a,e.textAlign="center",e.textBaseline="middle";let o=e.measureText(this.text).width,l=s;n.outlineWidth&&(e.lineWidth=n.outlineWidth,e.strokeStyle=n.outlineColor||"black");let h=new be(this.offset.x,this.offset.y);(n.borderWidth||n.backgroundColor)&&(o*=1.2,l*=1.5,this.drawRoundRect(e,r.x+(h.x-.5)*o,r.y+(h.y-.5)*l,o,l)),e.save(),e.beginPath(),n.outlineWidth&&e.strokeText(this.text,r.x+h.x*o,r.y+h.y*l),e.fillStyle=n.fontColor||"white",e.fillText(this.text,r.x+h.x*o,r.y+h.y*l),e.restore(),this.width=o*this.tolerance,this.height=l*this.tolerance}getBounds(){let e=new O(-1,-1,-1),t=new O(1,-1,1);return new Ot(e,t)}drawSelect(){}getClassType(){return"TextMarker"}isPointInPath(){return!1}getBBox(){let e=new O(this.position.x,this.position.y,this.position.z),t=new Ot;return t.min.x=e.x+(this.offset.x-.5)*this.width,t.min.y=e.y,t.min.z=e.z+(this.offset.y-.5)*this.height,t.max.x=e.x+(this.offset.x+.5)*this.width,t.max.y=e.y,t.max.z=e.z+(this.offset.y+.5)*this.height,t}},O1e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABgCAMAAACuYkXGAAAAulBMVEUAAABJSV9pdntRWmdeaHZMW21ZYnJqcH9PV2dSWmtTXmtXX3Jka3tfZ3daY3NXYHBbZHNbZHJaYXNWX3D9/f5cZnT+/v6xs7zKzdKusbr6+vvs7e/Z29/s7e/09faPlaCVmaX6+vz6+vv5+fnw8fP3+Pjh4+Xu7/Da2+Dp6uz+/v719vjz9PX09PRfYXP///+vsLlpa3vDxMv19ffr6+7r6+2lprCHiJZ9fo1zdITNzdObnKeRkp9zdYQN9RLUAAAALnRSTlMAAwQICgYSBwsPDRUMDxcZHRsjH+Mg8TwvIMZ+UpGIMizVtqael3VrZ1zTuq2q+zBSvwAABtBJREFUaN7tmXlD00AQxSW7yeYsPaktKJcgeBRbbsHv/7V8b3ZjTOiRrfylTnoIpD+eb2dmD978j789dtzrjry8HrYWIL8u91Xx+HxgOYG88FHGK2gNbOxUb+7720It2BFNiAh4BXw66bjPMwlKA4gJTWiMUsrgUoZflrL9ra4sMCo0mlilldb4lxY6hQvbU7HDUipQiFjrPLYXvlKiXdAU7a03JCCWyNM8jfFM81znuRI0fmtovW7vr1ANpIGbpmmBSHglSZEiAIcr8JyOtLbDyoUarSGO2MnB/umn4RViOD3ZP0iKIi1yjQDY2EFsiUVwtHLITSaX072rWuydfIwgnG4rzWFsQxYsEkppcPGfn7wH9WUMT99Cth3HINysmQYzceECvU2IXRXv3yYp0YZFA3Abe0PYAG5xWWKvF3fPj/PZbPZ4f7e4KVV/TAr6oQwSb0PWkWsQzIVicuao3+5ntXgo2WcT2JHHSm3Q/Ct5NdI2efvJYam0GU8WPYQdcaxlBNc1DnIN0zcGd3jFAHZ5fHPkqKAbBK8mUzGqCeNWRJZ78zBbGT9unGaIps9rzEB5SmdIU8ddQO7qmH+v3IBm2ryKC3AIg4tiItxvFWSNHZ8mURLbQoGy5U6w3nRaJNGZ47Yin8HmnPnM/r3cYQMw8iz6yPu/z1rEgndeQnKs7AAuFwwfWMdi8M28DXh+Q5snEcbPlsnOipRQcV5E7ynjcdYqHqS6owRmhMsTQ+Y2ZAQyraXBlc17E9hMMwh+KTikExi5Uxoxaxvza5Ec5bDZvHRZ5mM6nBYZHX5qDXaSUSZQDEqzGUlXU2gRTAkK9pN8ic5PyS8Vsw2rGNzohCXnARbJ0wjj5yTXGzxTQhOcsQc/+IDv3fClOeoaAhsWg6vQfLIDPycY9OIgklxmw3jR4JWmE/ueTrjy288wnWhKRtSsMHboMlp85we+w0dOsyhx4GaHDy14irvu/cDP+MgxwbnSMvnVyxn9J0mizlDK2St+sF9kyAu2ZWj8XTPqmf0nirIrxMwv5vxMlqGsCa5lBZNCoeyiqOMLZpRgKnZeVE7I1BFlW4M7NFk18o1r0RDlUYLnW4B3Ac6RyBRcnz2M1N3WgwfFUcq5Lwga2YZZH2O3e4y7nv3ArOmpWKHZ7UVx1TSNyUXx1+0K5DPBhWazB7jeKix425ImmOlmalbYiTQnmE3o2g98yybkrDC1PHbpVhB8tOdb0w9sm71OmcdBo7sBzHTLelNOpb5OnAgYrb7RN6mYiYy06F3Qi7mnE+e9TOYQExqIrE9MRkki78ILL8lPzOIu6yPR0ukbM17AZTHBvXd+kin4C8GsD9PwGF64GSTr9Pwky7pw3KNigMEluV4hkm9Rp9el5KuHtuWMeNft2R7UXLKQLOCCXnSP2C9u2y0KacRwTCeK1K0461aUK0Ka3L24alt+sqg/7zonYhO8OHeBNdKRE3ox+OCz8P4w6O52skTWyA3BCPwq2X4kIvnouP1WYXjkBNvyaFj8a8mSsEZ6g/FQFvXrNzcL4Y4H4Eo962qD01wU0guRPLLk28c1LeLWcmkEBAOslu7WA9lDx1gCZB3aDPI6O+awwXEpmHs9dqA1WwWZ+KC578i3T0ux1/LD4/HICU4xQLUkbnY4DckkdwejQ+YG0YtGsdwTK/lwSL2Sw9wpALsCHMi+n82TZoz65xDt2Hf3j1T6+Hy3IFVsuOgPrF4Wh+aybcV+LJB2n8tEAnJ31B+julfE3rvD/qhLLo3gCtZW3XIwybG1mT4P+v3xl+FK7ACJ1ukIV8HgFVzaI6cKKpdZFT7TaLDPP+81qNMLwVZcdolVYGHLLh0tg/tpS4bTiIP9z1NRPjz+sn9wiO8MaK/4m3CRaeBwE9yskoAHFgBD9C7sABrsRozgbm/X+Ztq1Jw9ytpwOKboM8k0moMosivqgNiexRZJzoQwELzxEEt2qCQDDTbRZLsYIIC1XIDlWM9uzzeRgdaaI1iADD8QhDMGeBKKQetEkdgQIx/K7fkmdKioGXawCEs2ebwE6tSmItcm8MaTQueGNrKxLiy6YwNQJhipxNo0Y2W0PzWlaHEaqsXsKoSawIVcM89U24NvJzpkd1bidUG0C1KZClCLHyoFrPcBckgy0XGaJ0mBB4US6rxltTm5vkf0CkE20FCe5kVKKAtC8TIV1/OUHuMCWWTHuQZf57o8+scglNQd/7+DSLsj2GjrKJGa2NBiPeU6uKAlDM/5AeMbs8vIgUeD62kH4S4ok0IBbVC3RANUxU5FrcDbiy5pVMu3BnQ7dJl+AnZCeeHx5yE0C9us1R8uz//xD8RPQ80FqUsWMbIAAAAASUVORK5CYII=",k1e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKoAAACqCAMAAAAKqCSwAAAAh1BMVEUAAABfTP9eTP9fTP9eTP9fTP9fTP9fTf9fTf9fTP9fTP9fTP9fTf9fTP9eTf9eTP9fTP9fTP9eTP9eTP9eTP9fTf9fTf9fTf9fTf9fTf9fTf9eTP9fTf9cSP9dS/9eTP9fTf9fTf9fTP9fTf9cSv9fTf9fTf9fTf9fTf9fTf9fTf9fTf9fTf/hY9QXAAAALXRSTlMARjRhS0HMZ1M5PVgva1wrTyYbFyJwlnx0gaATeAUPH4mmjYUKm5Gvv7m0q8X/SpWnAAAGcklEQVR42tXcCXriMAwFYEFhBsqeQIEGB2jTjc79zzdmFaDEjgmyhU/wf6+yvIUCxxhE8CBj3Kw9iHXZbNYew7p81tSHsEbPe2pDvDVuH6nSrVkdqcMlCB6q2z6jtgRb1aB+pGrpsCXYOq4jdZuqXGtcR2ptl2qrI9Oadi+oO2unMwZ5Q43OqY0DVaR11L2kDvfUfl+cNRl0SQHsqU/CrNmAUlsHqiyrGg+KU316GoGcEY+M1L9yrOnojNo8dQCkirGq5ciSqhhrMkYq6at7aq8nwqrGhEoKQFsHEH5EudThOVVLe5Pw1nSJ1PbFduUy1Ulwq4o01TStkDoLbE1s1P6ROpvNuhBiYKj51GFOqrNFkFwxVHuqSF2EyzWLojK1itRpMGsckVSbeLbKo4ayZoRqTXU6D2NN4tidGsSaxXGMtWrcA5xT3+vgfaTxRQF0Tc0KqSGsKjmnDooKgKb6vvJtzZBarq8i1bc10VRDX20ZUl29ebVmSeLQASZXVK/WVEtdlgCk7qyf/qxqR7Wn2iepznepfn62wdPIMNXRsQO0Cw4sdFqtNPXFk1WlJNWucVrRVF88WbMtNTF2ALK1XpxNK2194bcilU4rWgB92qxOqb58eLCqLDVMK3oMLKKyWpGaklSte4Apob4+A/PITqlGBiqdVpTKbVUHqvPWmlKJlY8a3URdnVHXfFakJnkLK1LNBYDUdRPOh+ACWK8Zc1VFBeCwsL6dqNr6i7kyUXEPYE8Vm9X8ulY1Fa081L0Vqe7NCqlfJ6uQApjmU381Fa1M1Pg+02pL3aCVmWpP9WpnRaibGofUdQnoFXYALIANi7UClRbAWg8t1dSfnxprqsvbDtdb6yFVpGorF1Vbb6PSDnCgftfCpkoP1/nTaqOp2spCNd4EUuqisFlhqt/fDa5U3W5XpjmbQKzVzY76r8GUqlMBWPrqz56KVg8FQKeVvQAwVbT6KABaqxNDB8BmdaD+abBQ3Y+Bc9qsrqlo5acW7AGmZQrgrlZSq873q6vcJQBTRWtVae4xsGvtAJZUkYpW/iWAvgXQZkX7KlLR6nsJ6BmpNFW08lC7tpvAhW21QipaWVarrjFVWqufhlTvZdVSMq0sBUCalbkDoNX/gcWxA9zNqhhOrISK1oAdYJ5XAGRaoZX1wEKpDqlSayWq6dLS7Wz1YWhWaPW6tZ5cXa+ZlwBi5aTSFxaknlarDwsVrR7PVo4LK7VyUOm3K/bV6pfUKrXemdq+U1+l1q+IoQNYD9e0AOiBhUoZa1VL899YaQd4JVQq5TxcD7FWXU8BxLqJgJPqXqs4raiUmdqq3qzwrx+0r+LCSvcARHo36qh6ql+kVomUcwlwfws4UkmdyplWhIqZ+r8Ictta/yNS1mlF+ursQLWfWFHq89KyU+EYiNLKVHwOrlYAtAOglDXVpuGTsPKpolTc4ZrsV4k0yGo1t6a6k0qgYqpFZyuUVh7GWjVRp+WWACKtmmpa4lvrjvuVxVYq5XsAPFznp/qLUuZmVfUiCKX8BYCrFVLJC0vhErCO4TCE9tVTqlr6INR1LOrTBcMS8EqljFtrOq3+kmn1XrCwotRjquQxyH62QilvB3B/Y6UF8IFSP99ZNfN/c23fWaGUi7q8z2MQkxSwAGK6Wu1jHTo2qxci9bSzajhuAtmkANW2KzTVT5QyUqu/W11IxVCneZtAVilStdXxLYDeWrNKARy/te4ZvrN6S4B1ZOV+GmansktBOfw0zNhXVwlwD4dNoGm1eueUIlVbb0sVO4APKSjrtGrZfhuIUuZhP7BYC2DuRwrZjT8MwYXVlxSU6YWlYf/KAqX8w+k5mL6wTP1JIavw20BmKY21wv3qwqsUspuvLHxLAW7+txvepZA5XQUjdZaC76HofpW+W1FqAClAesu0moSQgnL7zGaxpXqWYqzOtdoLJAXl2qxCSDFWSj1KabP6m0K4UXoTqKWzoFJIS/+DiNBSgPIXQaGlkJ2oXfPvrZ5SCD3icqkKkIJa7qgD00WQDClAWuI1sC9CChBZP7ORIgV1ubDSJaAjRQqQmKeVICnAspgqTApqVExtZSBqpIU3gdKkAFF+qgKlAKPcL9iHAqWgclKVKQXI6C8uGzKlAPHVw6VcKcDysgBqcqUAg7MCkC0F1UWqbKm21o8F0BQuBcjae6p8KUCqqY8hBYg19fkhpFvro0gBEhbpfwjbOY5gXmpMAAAAAElFTkSuQmCC",F1e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAABgCAMAAACuYkXGAAAAt1BMVEUAAABRUmRVYHFcZHBRWWZia3plb39aYnFeZnVYYXNZYnJPWGdZYnJRWWtZYnJZY3JWYG9eZnVcY3RXXnH+/v7+/v78/P2xs7zKzdKusbr6+vv4+frz9PXn6evs7e/09faPlaCVmaX6+vz09PX5+fns7fDa2+Dp6uzS1Nni4+X+/v7l5+rx8vL9/f1fTf////+vpv9pWP/DvP/19P9zY//r6f/r6P+lm/+Hef99bv/Nx/+bkP+RhP+tEDdkAAAALnRSTlMAAQMGCAsIDQ8UEgsXEB0gGhojJOLx5DwvIMa4m3CRiDIs1aymfWdcV03ShXjTY8FN1QAABtZJREFUaN7tmWlb2kAUhS1knSFAXFBArFtduoAgbtX//7t67gITEsCM+rFHwNZHXs9z5t6bybDzX376hi/5Bx5fxsSTeIBD8qPPUxUndP6f0+fITo0GngUs/ZEPMl0ADVAbKgf3J+siLaxWpOY1HV8yIQvQZlOeJeNedaJWHLhZlrJ94/imKkCjZhAEUYDXSMjCVtN14c4tM/GIAA3CILRhRPyo6HunJrhoVuwCGQIZxqF8t4TH3xK0rqEPmJiwZ4UXx7GN6ZX+AtwHTTYOMkf9DlkqV1MAFO9nZKLK8Iwh0C24hG7UQmv5arphBHcgJf3b35c/9yfQ/mD4+5bxFIx6hriZ6q0arVZsbZL1rwcHkxUdDEcZ0KFkzZ5JW/2qXc6B7fa/g1rV/uUR0FhGVCEHLdo6y5gb0YLFjN2k70dZHGNlIwl6KxdSbmCBTa4X2PvZ09t8Oh6P589Ps8eFawSCqB1586hecqPQIoVjpd49j1f0smAf9xEH6iMQ8nospaBlBm4cZ0c/FQunFb0Kev8oS6Q6dHBU2cAqOEC+KIYjlBek2KrulGyEvCVm4WoORrgPL+ONmj+qZ8QRcdWtn3WLhUOvLbkz2N2s6V8lI+dA04DWcRnM68bcOwfZEsefvkls4EbSGjD3G7oiM8fKrUU+NlR1FIakUSkJDSJOzGgC/R3X0GwCXWeJDXkgrUkCaOLS2JGCeJjWAU8fKea+iS1bXkvmimDD38nGfFxLL9zdJkPNsWWozG1C4KKCawbsYj7oI2Ys4DrLmjCCMJcUxLiupvdkOUXNWYArMS97LklSSvi1Nlgto02WA3SlKggcseGRGPazfG2SxFrpkp2y4ygirhlSy3mA2fLAGFh289MVW4OXDuCUZvCLD/hZlw9kBrsW4Qsdd12SpbeeSUCUxa0xMVfct6JjvoCKYfPDMwltvx8pli8ky4C5peMoaEyYlCJ+8gM/4S2Xqcli6mvFqnSuJYh4gN969gO/4S3nBI65rXcaxdEGLkfc2ud29tKc5kXL0CjSEVdYPFk7Y1oTaOyn6QRqpdzWAJf6GVw4VrCnFAzHq+NCRzFd6tJPgBGFXlRXJ0WEokgFPP0QOEVZVBZPGxqOex9dvJRaJGByybG1Bo7P8VtvHlTt6QE5FrBm7EZQzI4vPtYgw5Z0SECtt2pYo/hoSzvHxcVjMEYFGuSG9mt+YLqg3pBjrWOXBNzTdZQdnx349vQLjc2c6xjgJsAlyzyDWl0aFne+SQxzqmOOuNR6dC8TMviKsph6JjHqEjjWXYsrYwYHvHo5svCy/Ipf77UZHHKDAOjAHEVoMSta+Qlb9jJ80c6pPyw7Lu1X5MpEWfhY1n3hYQ5wRhu4BuSi0ClkefXyNlmevNRtZ+iEkjC8swC2UdmvhGy52z7r+W0Ke4ftnKdxZcuiyxdowbWvJnXbjzf1o3YuY94Cu7qvwFWvyWMoyQjc8dt4d6QmLDtGwkWw7oSk+fL22Xn9W4XeWbvbJcOxcNWwWz2qi8Dy8nXbhz3e1G+/uZkx9xB+5boUuYSd5M6cLbcQhpIf5ltGxKNwOQgj29gq190yUcoIowPytjimiMFxOeEI4DIZKWtbWw1jSX54XYu9n5DOwVXDga3eKrgmCSJYlvVrd06PJ4KelZrlGVjW8Sn8Sm9QETdk31YFO8uoOZA7I5hW9tPznJzO355moEoMV7sdCRhgWbl1jvGQlOXSx553D08mm3RwcrrLOWhv8Cnf+jMnhCyW44TJOci7hxe9TVji5i2pCHc2VKGS9OY/pphTJnc6u3uj4UGJOriCW2DbLeLKfSn8rgW7YzE6akuSTMjIY29vd+/m13DAznvnF79uTvEj4nYxIpZcvRXbdsKCyqA+UTK7hvacQAWWY0izLNFjIT30rapwhEUdyFWHpLk8CA4gqSNYVJnYxcKBSwkTY/OpMU+5gD0jjZTIXbINuqpNWOVyAUdR4eht8znh8tgtzhLDprtd2HbKc1AhYzgGq+eQ2w/tGYwGFNOJVAeUgw7lOR6gils5dVNuCbux6Li56QiSAhE4VXZLoIJN5CxIRwT0DlhLA2i4RhtCJmUByVAJwfIJtY40UY1TaTnpDijqhBJZSKkUQhDyialy3/9wwZ1383k5H54SHDgg8SpHpUrV02OttBrkRRNGajvGQxXGQo0W3KLbWqZ1EZWNpyX7eOGT/yVWPzurx5X+dlk3iQ4envRFlaBYpZa575aHsiMMPXoqdJmtygPr6oO19gMhNcxcL8NVdqMELcwzL8/uY4ay8DPH9ZW+UcQwkeAqHwT5w6va+aLPTPW1QJXTni+QYuW7gr9SHO5/eesfYdwFkua/O6kAAAAASUVORK5CYII=",N1e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKoAAACqCAMAAAAKqCSwAAAB0VBMVEUAAAB5d55fTP9fTf9fTP9eTf9eTP9fTP9fTf5fTf9aYnFfTP9fTP9RV2hfTP9fTf9fTP9fTP9eTP9eTf9eTf9eTP9fTv5fTf9fTP9fTf9fTf9fTP9fTf9fTf9eTP9eTP9fTP9fTf9YX3BaYnRfTf9fTf9fTP9fTP9QVmZeTf9eTf9fTf9fTf9fTP9fTf9fTf9fTf9eTP9fTf9eTf9jantgTv1fTP9fTf9fTf9fTf9fTP9fTf9eTP9eTftfTf9fTf9eTf9fTP9fTf9fTf9gTvxfTf9aY3RaYnJfTf9fTf9fTf9eTf9aYnNZYXJeTP9fTf9eTuxbYnRfTv1cTuBfTvJfTf9eTP1fUPhfUuVcVsJbT91cT9tbWKtcWLFbXpNdVM5ZX3ReTvtcUsxbVMRcU8heUOb8/P5cWLlcVMheTPxZWZ79/v7+/v63ucpcXJvw8fSvs7r29vmVmarp6e7NztNWU7j7+/vR0eH7+/zh4uTy8/Tr7O2wsbr39/z3+Pj3+Pjl5+rKytSnptWpqsqKisD5+vro6PLs7PTa2ulfTf////9zY//r6P/19P9pWP/DvP+Hef+bkP/r6f+vpv/X0v+5sf/h3v/Nx/+lm/+RhP99bv89/FqOAAAAiXRSTlMABMw/RS9kbCdWB092BUIslzo8U180Ko9Zh5syI4RbNjh9DRBxaUd5CWdRrXNhXaNLSYpvCyBNgIGxjHtMG76UkqG6nh60JhnIqKbEExWqtyciFh4jwRkTIR0mGx0iISAdDycZFRjkKCQKGeLxOSeNP6ksby4QxVnUT5yAHsnJuF9HREI213iiZ4OOOrcAAA/ESURBVHja1NhPj5pAGAbwIYrr4gLVXf9lqavJFi3RZtHFblpJe/ATcIAzR7JNeuhemjTp3U/deWccRxjsSTLjYzTG0y9P3nkBURXpxehC4lj1EF1EAsuqX4Z1W6tZdde9AOu204FWfX+LFE/U7tQw1fX9jeLWrIupNdyq+7RpKW3V9DGlukD1AqRsNPuBUmFW1y3vVl2r02VU14dWvWtVrfF9l7f6BK1eK2pNdULlx6qFqQMVrVpTL7Ta8jB14CDl0tSPqO6BOvqknDWyCbW9p9IBINQ7xaxZj1L5rMKxuiXUhVJWzQFqYQBYq4tGE6mTuNmzbeFYsVYbClnTJqbqeeoG9iqjflTFqgWcyvfqGmaVUT8oYo2cIhVuAumsDvbUKyWsmiNQ6wfqiFGvekh+wgLVosdq7eWpK/nWNAjKWl23itRH2VYt5FTeqnu8Vxd76txGUpNsxVaBKrY6n99ItWrhNnDEDYCpa3YJuGuwVm+kWhNKFVsVNgChTnUkK1mMqUFJq/4GNkCx1en0qzRrFOap7fILK6dOJpKsWZRvtctaFQeAtTr5fI9kJGFUYa9SqnCsgPoiw5pFhHriwup5+3uARb7Vl/cSrGkUc6pd2KvlG2AC1IqtGrzJi/+URFF4guoL1Eeg0laHwy6qMsCEcG2WlA6AxfaqB9RR8VhBq8Mlt1ahNIGJvxw6TkQqf7Zie3VU2uryC7NWUadpsk+T9poxaumdFW2VD8Bqlaf2H1AFASIIDfIiZOCnSVRKtWir/OFaPFbD5bJfiZW2aRrG20/DMGmzCBkpH4CSVhl1dNzq9KjV/vfx+aEmxMB5/fGGrRCMT4EqbIDTDyz5AVhi6rfxuaEadc5mv3a7v7MZfAdt+r9WXfL/qjgAvFWgvmuf30qkf153u93v5+cZsWaEGpdT3dJba5H6j1Vz+00iCsJ4vDz4Um8x3qIxYdUYjalGaqJ4ibb1UkFbwQhCiwK1TcHUFrFatfEW4w5QWrHV+tc6c85ujzA7sCDzwusv337nm5lzQNYei0qgweAs/KjDa0RVrCWGymcApipDPdxbVg0aeAVQXq7AN2RF2GAp95hQ3SGQN1bKVSEBCPWyRkXWHgVqn/r6QSQNzEHNtjeg8D4QOBU8VSo9e5x7OImoQre6iA7gjTUUcsNKoSLr4N4eiYqkWtPAR6iWbdv+CbOWhbAlUpVQhxpQ93jNAGebDXDUGGBw8MbenoiqfEqklpWHuo21AoVXiBpA1Nwk1tWrA8LC0sarlzdRkbUHRaQIiqRF+GGrWoPXlqVIc48nUVU5AQiV71amW2mvDt7o79/WA1kJVZG+ysOqRl2uwlvLylFNEqqUAHKuEqo5Vqhq/8i2HpAqp1qWNQe/bKfqkA9bM0Sape8vtAC9BQiqGgPsVqqO3N3WC6cqo1JQ2W5V4F1kZmYml82RqkOCqsIW0JQAhx3U+zt7Ean4/cMUVLr0yZqfwcpOJpNJQdWmyeqERiVSMwMYAyDqmZ3/Q6qTKoikeKaMqBRYi0SazRLqkHysnNF6n6BqI6ph7fZUBUlUdaZMlQE+Sah8smpADXkcq36Nemnn/3x/R1Rs/obTCayURo1Gh3xNVuZYyahds24hqxIqBdWGwXQCayGVUqioasxzt8K+6qdbGQNcGh7e3jWrJrXoTDXVb3g+n0JSpWpMVLVVAhzgqg4/2N5tVOlOpYKqudZhNpVNtDCAeQ6WGytHvdmdrq5V30CdkarASiSS0WR0aCAWGxXerXyijjgGQNRuWGl7Uk21CNWVMq91mEslElFUNU4G2O+FeloMK1HVm9dOdmNVJWogD1ItJJLEGv/XAMfYDCCpyr06rFC7YHXOfzGv6rlHzSWUWQdadSt+FcznVST9F/XR+c7nP2KlBhC5/fTp2NjYLafGsJ5OTKTw+6eTJOpArAF1r2sAM6+ae4CQVlVIAI1671zn3x9RkTR8+zaxGlSqCWRNKK/G0QA7PEdrX8dqsMkAhHqvM111VhFqRKvawDqhUdPRNKLGRkfbvwbyIVBW9d6dc51d/ehNhb6/a4CvL1/Ob6Km0AHpdDoajcViXl41j+z7vK/XjKoc9c6VzkTto+9vRTTq/LulAlAtLS5o1nGSVanKDaA31u5VvbP1ov9DpRuAi7qwRJTVSqVKv/kikiLreFqjxvgLix6teViFzE2gV1g92ERlrHJX1VmlrTq/iJi11bKaVFZqFYDnL4mUDBAnVOZVWq5ZAvA18LpCRVKG2gErTYBoVYus+iIP1fqybWq1AoXvWtW4QkVSn+NKqH0L0KpiXfEpq5uqkcinAqw3zSvlGsDsOKFqVY/sN6iiAeRuNeKBylhlVHSq/v44rdaMpGZthaJinUZSMoD8xCajyqoqVp8e6NNZhah5vVZz1sKX8fHp6bg3aoOqZ8U7Kz1aC6oyXcVYRVH1skKa8qrBB0RF1iejox7HSj9biAnADWCO1SNC5azyAqBQww1zNVtaNCqy8ptAfr963MwA4hBowsqti+3XakJtvADgS8sHQn2iUXfxboVDIHtiI1U5qmQAzipvgOE8iSrL6qJSAnADiI9Bh5rWwLsc1T+rE1VvYd0Waw1mpzKOqgxVJwC/s/Kbq/5YTauyFmFNRl2BD1PTGUJFWduH1XF5ub7LjxVnlXcVGlXCr2FDRl2GwlQmk9Gouzz+ECIYwNe44p+VVEXUN/DHlqsKX6ccVO7V5o31gnC9JqByVpkUUfWpkqsCnxXqE6Oq2QLwhUXIVd5YDSozAGflBqBW1R41g4WkfAZgLyzcq/xYyagya5+zq7Q2AMCUqyrPVWe3OthqsrouG4CzSq//zq76t5oz/5EhCuJ4T4hr3UcciXMY1yJYZwhCTCJGXBnERGYdw65da9Z93yTNYtz8tar6Tc3r6W/XPNpMtpX1C798Ultdd72qX9NJf9FndVm0alCXLA61LP4is3Kj7tithYB6Wv2glbOq+Y8ElYeBOGSH1QXdVrEKQFK9BGTUe/6IjvrBfw2ocsIQGVyuwNWFFiGAWJFU/6wMav6u/xEQbe/6ua5VQZ2Hg0vMrLTA6ib1uLFmUIf8L7pSq5cJVUIAtte6lK41ahWdFZKqapVqdXjA/6ErVVBBq2QAzu6KAxVI9S4wOStWq5kCo9C4/Q2RXuHfv/WreMSEy0t6IwhQkRSFbFU6a1UeBKF89ysvL4e06t4IwhDgLliQFB1rowmYH74bw/r+i195ce0ao15BAzCoEq2c4+B9WhKIpCiCmuXOCrGOROz14zsmZdTz1lanYWptDQCc1U7HZ4WkurGaKpAbltxc+VQLgX7x/VdMyvUKpNaupiW2gvdpgRVJUSQISBvwRoVgP9RoJvCr9pX6QANDB68xap31ZAN1TthWuyJ+tVvRqqBCtHKTZpjVNFdZrWViZVgRAqXWZUAalIEnw1qd0XQcyqiLkjaCkFQfBBnXKi3rZw+ePK5UXj0ZunOQhEkF9SRWrDmpWPUqwJFaI6meBYpaiVUmAVaov8qopr92VJqWjrlVNwTWPWofAEgdxir+qhxhNQ12aa9RIwgKFj2wLv3TaIWkeieQm5YyCmBWS2pRSaBnNXMqNIJcVQB+VkDqrq+tWoX1WAO11GhaKmMLrK1WulBFq0iq+4AQqrCGx1YkJaPV2FZwzlYBLT2AZqtri3+5DMQW8PDmzUGW600yGEhjbAFazTVWF+bBCQOgYmB1k2LbgqfBqlQFVfEAYqvKhEX3AEeKyXYsbvNgBWXErwzawSUagCSBCfyqQuo01uy9+IT1nT9Ec0uaXKJW7asL2F2J3bNq7lkdAlKnVqVxVY2rWWp+pSRDVmV7LXQXsBpsVdWqQuqw1bpaHw5gKfj2nX9DULcog8uuuBDgHFxuKCZcCOoxu0vfYkpAnrGePasYgKQrjpYFFiwbjidaspB5AK2D/4AScJBQeXmFd1ccu9aOEBDOV/cRaWLWeuPifaSwqhrSs7wOoG0EMaq+ZwWfFaHu10jdxioF1m3/a+SbCpRqtHpasVVtxqr3V5ORZmTPKkivnzWPhOibOlcytkqs4WuLOTBi+4uu9QIHqXt2zZXA/bDD+uxXyv1MatYXTzt2AiEHUFAdpO702gyvh0MO6+2I/7RMrGdKsr0GBjBVdq1VZ4Wp9fSkpDJnk+z6Ac0vraPKl/sJtW6rFFhlywK6K4CqBtbkpOICBLVM63bWUeXzbAAXAls9razaKkuhSma1959ITbySQuAOOSwJ/mVC7S+ZVdtAq3FPGVjU2c7UWkiTokrZakpBcVjkqIbz+UI/CbEWT8C1haQreMaof1YJSbFoMYXAYPBlvSdHVTaoFwK1FpWlUO00LG5uNTcRKXYDpMI2XWE6CmDSw4cD0kvFS81anaPvBG5W/erOU225s2RUo1Z2WD/NN1UoHM5eZFb92iLnyletVhOTYoG1TFjJYVHwzwdKzd66GJww7FbPGNmvYisYndUmIE0YsEyB1fiy/IG6UpdlgyOWs0yK91birCBdwbHFfCBNHAWkxGa93qOVpUKBdZpd1sOkJKBVJbVW+qsLT7XzLtSwsg0Unlwl0EKWSXtuMSsfXOLJbWPE5spXgTS5mHu7VYaVd66eskYZla4DDWrLk1vX9tr2tpFmjF5XkbkaVgZllZJMmnTrFN2GFdmv6q8ugFabbFUhTewEmJXbLCQBJwufh07h1wGsreKQHSYs0XRlWxtIMRcUWCbtWUUq5TtxPg62L4SoBYt2GbS03aTm3ppIA9oeEjkPntLHatUOmR0b7G0ixQwrYxRLP/TXHF1nSPg6VD8N29pSqyuBtF32ynhMazQ6ie/uGw9EKI9EbW3lV9tEipkAsxKtEaKkH/vsBh4yu/dXJwNpu58ImGJISYwr65P3AVquhc8GrXb3eh2RDP8hMbyk4UDMf4EBwLK9bQVbZ9UBUnzPQlQq0otJoHsfYDmQtlOtQsuk8g8smegDETPw4jL6QgiRdliaEK1a40NADt9eEwMYD6SdACWRD0oko9iqbAXDazYdIkVelF5Exf6qrQJWdJYUYfGZOKwCcMTW3c2koyi9ylsWsGZDqKuJdDSlqLxlgQXLuFEm9fqU54y2hi/Z2VmtI9JRluNKdyViq7NHn9TLxNlqtL2WClL6stBWoWBZnwpSz9utPLthN4IWpYSU3rUVA1BCwLy0kHreqVa11ew0kXreAfAAoWg1MU2k9K49ttdEq7P6vFRJL+wDiK2mjZTia0wnkFHXpI7U8yZEcgBjAF0pJPUy02Ie4d+aRlLKW9Cv7konKZmroMr+6sa0knrelqY1m65cekk9bxqvL0ojaGyaSclcra2mm5RY54gBTE05KbEuMS2LMaknpQjLIeC/IKVSi7T6f5CSe5068z8hpUS7I6S/ARbzgdCIDH2vAAAAAElFTkSuQmCC",Vyt=(e=>(e.ZoomChanged="ZoomChanged",e.SyncCamera="SyncCamera",e.CameraChanged="CameraChanged",e))(Vyt||{}),B1e=class extends cs{constructor(e){var t,n,i;super(),this.CAMERA_Z_POSITION=100,this.width=0,this.height=0,this.frustumSize=this.width,this.renderEnabled=!1,this.drawableList=new Ko("overviewMap"),this.clock=new po,this.raf=new qf,this.raycaster=new ia,this.translateStart=new be,this.rotateStart=new be,this.markerRotateState=!1,this.markerTranslateState=!1,this.isMarkerRotating=!1,this.isMarkerTranslating=!1,this.isUpdateWhenPawnMove=!0,this.allMarkersBBox=new Ot,this.tolerance=5,this.enableLookToAllMarkers=!1,this.handlePointerDown=e=>{let t=this.cameraDrawable,n=this.cameraDirDrawable;if(!(t&&n&&this.viewerContainer&&this.camera&&this.controls))return;let i=this.getDrawableByEvent(e),r=un.getScreenPointByEvent(e,this.viewerContainer),a=this.lockCameraInViewCenter?this.camera.position:un.worldPosition2ScreenPoint(t.position,this.camera,this.viewerContainer);i&&i===n&&(this.isMarkerRotating=!0,this.rotateStart.set(r.x-a.x,r.y-a.y),this.controls.enabled=!1),i&&i===t&&(this.isMarkerTranslating=!0,this.translateStart.set(r.x,r.y),this.controls.enabled=!1)},this.onCameraMove=e=>{var t,n;let i=this.cameraDrawable,r=this.cameraDirDrawable;if(!(i&&r&&this.camera&&this.viewerContainer))return;let a=un.getScreenPointByEvent(e,this.viewerContainer),s=this.lockCameraInViewCenter?this.camera.position:un.worldPosition2ScreenPoint(i.position,this.camera,this.viewerContainer);if(this.isMarkerRotating){let e=new be(a.x-s.x,a.y-s.y),n=(new be).subVectors(e,this.rotateStart);if(Math.abs(n.x)>this.tolerance||Math.abs(n.y)>this.tolerance){let n=e.angle()-this.rotateStart.angle();n=(n+2*Math.PI)%(2*Math.PI),null==(t=r.direction)||t.applyAxisAngle(this.camera.up,-n),this.rotateStart.copy(e)}}if(this.isMarkerTranslating){let e=new be(a.x,a.y),t=(new be).subVectors(e,this.translateStart);if(Math.abs(t.x)>this.tolerance||Math.abs(t.y)>this.tolerance){let t=un.screenPoint2worldPosition(this.translateStart,this.camera,this.viewerContainer),r=un.screenPoint2worldPosition(e,this.camera,this.viewerContainer),a=(new O).subVectors(r,t);a.setY(0),this.lockCameraInViewCenter?null==(n=this.controls)||n.truck(a.x,a.z):i.position.add(a),this.translateStart.copy(e)}}if(this.isMarkerRotating||this.isMarkerTranslating){let e=this.lockCameraInViewCenter?this.camera.position.clone():i.position.clone(),t=r.direction.clone(),n=this.transformMatrix.clone().invert();e.applyMatrix4(n),t.applyMatrix4(n),this.syncCamera(e,t)}},this.handlePointerUp=()=>{this.isMarkerTranslating=!1,this.isMarkerRotating=!1,this.markerRotateState=!1,this.markerTranslateState=!1,this.controls.enabled=!0},this.handlePointerLeave=()=>{this.markerRotateState=this.isMarkerRotating,this.markerTranslateState=this.isMarkerTranslating,this.isMarkerTranslating=!1,this.isMarkerRotating=!1,this.controls.enabled=!0},this.handlePointerEnter=e=>{1&e.buttons?(this.isMarkerTranslating=this.markerTranslateState,this.isMarkerRotating=this.markerRotateState,this.controls.enabled=!1):(this.markerRotateState=!1,this.markerTranslateState=!1)},this.handleDblClick=e=>{var t;let n=this.cameraDrawable,i=this.cameraDirDrawable;if(this.animationId&&window.cancelAnimationFrame(this.animationId),!(n&&i&&this.camera&&this.viewerContainer))return;let r=un.getScreenPointByEvent(e,this.viewerContainer),a=un.screenPoint2worldPosition(r,this.camera,this.viewerContainer);this.lockCameraInViewCenter?(a.setY(this.camera.position.y),null==(t=this.controls)||t.setLookAt(a.x,a.y,a.z,a.x,0,a.z)):(a.setY(n.position.y),n.position.copy(a));let s=i.direction.clone(),o=this.transformMatrix.clone().invert();a.applyMatrix4(o),s.applyMatrix4(o),this.syncCamera(a,s)},this.handlePointerMove=e=>{this.onCameraHover(e),this.onCameraMove(e),this.enableRender()},this.enableRender=(e=1e3)=>{this.renderEnabled=!0,this.raf&&(this.timeoutSymbol&&this.raf.clearTimeout(this.timeoutSymbol),this.timeoutSymbol=this.raf.setTimeout((()=>{this.renderEnabled=!1}),e))},this.isPointInBoundary=e=>{var t;if(null==(t=this.boundaries)||!t.size)return;let n,i=new be(e.x,e.y);return this.boundaries.forEach((e=>{e.polygon.length<3||Qt.isPointInPolygon(i,e.polygon)&&(n={id:e.id,name:e.name})})),n},this.animate=()=>{var e,t,n;this.requestAnimationFrameHandle=requestAnimationFrame(this.animate);let i=this.clock.getDelta(),r=null==(e=this.controls)?void 0:e.update(i);if(this.scene&&this.camera){if(this.viewerContainer&&this.viewerContainer){let{width:e,height:t}=this.viewerContainer.getBoundingClientRect();(this.width!==e||this.height!==t)&&(r=!0,this.resize(e,t))}if(this.renderEnabled||r){if(null==(t=this.renderer)||t.render(this.scene,this.camera),!Dn.isBrowser){let e=null==(n=this.renderer)?void 0:n.getContext();e&&e.endFrameEXP&&(e.flush(),e.endFrameEXP())}this.enableLookToAllMarkers&&this.lookToAllMarkers(),this.dispatchEvent("AfterRender")}}},this.cfg=e||{},this.transformMatrix=new Qe,this.transformMatrix.elements=this.cfg.transformMatrix||[0,0,-1,0,1,0,0,0,0,1,0,0,0,0,0,1],this.enabled=null==(t=this.cfg.enabled)||t,this.lockCameraInViewCenter=!!this.cfg.lockCameraInViewCenter,this.radius=this.cfg.radius,this.size=this.cfg.size,this.minZoomFactor=null!=(n=this.cfg.minZoomFactor)?n:.3,this.maxZoomFactor=null!=(i=this.cfg.maxZoomFactor)?i:5,this.init(),this.animate(),this.enableRender()}get cameraDrawable(){return this.getMarker("cameraDrawable")}get cameraDirDrawable(){return this.getMarker("cameraDirDrawable")}get overviewMapDrawable(){return this.getMarker("overviewMap")}init(){Dn.isBrowser&&!this.cfg.context&&this.initDom(),this.initScene(),this.initRenderer(),this.initCamera(),this.initInputManager(),this.initEvents(),this.initControls()}initDom(){let e=document.getElementById(this.cfg.containerId);if(!e){se.error("[ViewCube] containerId:",this.cfg.containerId,"is not found in dom tree! will append to document.body.");let t="overview-map";e=document.createElement("div"),e.id=t,document.body.appendChild(e),this.cfg.containerId=t}this.width=e.clientWidth,this.height=e.clientHeight,this.viewerContainer=e}initInputManager(){this.viewerContainer&&(this.inputManager=new Jo(this.viewerContainer))}initScene(){let e=new _i;e.background=null,e.matrixAutoUpdate=!1,e.matrixWorldAutoUpdate=!1,this.scene=e}initCamera(){if(!this.scene)return;let e=new Ur(-this.width/2,this.width/2,this.height/2,-this.height/2,.1,1e5);e.position.set(0,0,this.CAMERA_Z_POSITION),e.zoom=10,e.updateProjectionMatrix(),this.scene.add(e),this.camera=e,this.frustumSize=this.width}initRenderer(){var e;let{context:t}=this.cfg,n={context:t,antialias:!0,preserveDrawingBuffer:!0,alpha:!1,stencil:!1};!Dn.isBrowser&&t&&Object.assign(n,{context:t,canvas:Dn.creatReactNativeCanvas(t)}),t&&(this.width=t.drawingBufferWidth,this.height=t.drawingBufferHeight),this.renderer=new Ms(n),this.renderer.setClearColor(11119017,1),this.renderer.setClearAlpha(0),Dn.isBrowser&&(!t&&this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.classList.add("webgl-renderer"),null==(e=this.viewerContainer)||e.appendChild(this.renderer.domElement)),this.renderer.setSize(this.width,this.height),this.overlayRender=new Hn(this),this.overlayRender.addDrawableList(this.drawableList)}initControls(){let e=this.camera;if(!this.inputManager||!e)return;let t=new ba(e,this.inputManager);t.enableRotate=!1,t.enabled=this.enabled,t.keyTruckSpeed=10,t.dollyToCursor=!0,t.dollySpeed=.1,t.truckSpeed=1,t.mouseButtons={left:yt.TRUCK,middle:yt.TRUCK,wheel:yt.ZOOM,right:yt.TRUCK},t.touches={one:yt.TOUCH_TRUCK,two:yt.TOUCH_ZOOM_TRUCK,three:yt.NONE},t.update(0),this.controls=t,t.addEventListener("control",this.onControlsChange()),t.addEventListener("update",this.onControlsUpdate())}onControlsChange(){return()=>{this.enableRender()}}onControlsUpdate(){return()=>{if(!this.camera||!this.cameraZoom||!this.initialZoom)return;let e=this.camera.zoom;Zt.areNumbersEqual(e,this.cameraZoom)||(this.cameraZoom=e,this.dispatchEvent("ZoomChanged",(e/this.initialZoom).toFixed(2)))}}initEvents(){var e,t,n,i,r,a;!this.enabled||this.lockCameraInViewCenter||(null==(e=this.inputManager)||e.addEventListener("pointermove",this.handlePointerMove),null==(t=this.inputManager)||t.addEventListener("pointerdown",this.handlePointerDown),null==(n=this.inputManager)||n.addEventListener("pointerup",this.handlePointerUp),null==(i=this.inputManager)||i.addEventListener("dblclick",this.handleDblClick),null==(r=this.inputManager)||r.addEventListener("pointerleave",this.handlePointerLeave),null==(a=this.inputManager)||a.addEventListener("pointerenter",this.handlePointerEnter))}getDrawableByEvent(e){var t;if(!this.camera||!this.groundPlane||!this.viewerContainer)return;let n=this.raycaster;if(!n)return;let i=un.getScreenPointByEvent(e,this.viewerContainer),r=un.screenPoint2NdcPoint(i,this.camera,this.viewerContainer);n.setFromCamera(r,this.camera);let a=n.intersectObject(this.groundPlane);if(0===a.length||!a[0].point)return;let s=null==(t=this.overlayRender)?void 0:t.getDrawablesByPosition(a[0].point,n);return s&&s.length>0?s[0]:void 0}onCameraHover(e){let t=this.cameraDrawable,n=this.cameraDirDrawable;if(!t||!n)return;t.hover=!1,n.hover=!1;let i=this.getDrawableByEvent(e);i&&i===n&&(n.hover=!0),i&&i===t&&(t.hover=!0),this.enableRender()}syncCamera(e,t){this.timeout&&clearTimeout(this.timeout),this.isUpdateWhenPawnMove=!1,this.dispatchEvent("SyncCamera",{location:e,direction:t}),this.dispatchEvent("CameraChanged",e.applyMatrix4(this.transformMatrix)),this.timeout=setTimeout((()=>{this.timeout&&clearTimeout(this.timeout),this.isUpdateWhenPawnMove=!0}),500)}updateZoomFromRadius(){if(!this.camera||!this.radius||!this.controls)return;this.controls.minZoom=0,this.controls.maxZoom=1/0;let e=this.getContainerRadius(),t=this.camera.zoom*Number((e/this.radius).toFixed(2));this.controls.zoomTo(t),this.initMaxAndMinZoom()}getContainerRadius(){if(!this.viewerContainer)return;let e=this.viewerContainer,{width:t,height:n}=e.getBoundingClientRect();return this.size&&(t=this.size.width,n=this.size.height),this.screenDistance2WorldDistance(Math.min(t,n)/2)}screenDistance2WorldDistance(e){let t=this.camera,n=this.viewerContainer,i=un.screenPoint2worldPosition(new be(0,e),t,n),r=un.screenPoint2worldPosition(new be(0,0),t,n);return Math.abs(new be(i.x,i.z).distanceTo(new be(r.x,r.z)))}initGroundPlane(e){var t;Mt.expandBoxByScale(e,3);let n=e.min,i=e.max,r=i.x-n.x+i.y-n.y+i.z-n.z;Mt.expandBoxByMinSize(e,r);let a=[],s=(e,t,n)=>{a.push(new O(e,t,n))},o=e.getSize(new O),l=e.getCenter(new O);if(s(-o.x/2,0,-o.z/2),s(o.x/2,0,-o.z/2),s(o.x/2,0,o.z/2),s(-o.x/2,0,o.z/2),this.groundPlane)this.groundPlane.geometry.setFromPoints(a),this.groundPlane.geometry.computeBoundingSphere(),this.groundPlane.geometry.computeBoundingBox(),this.groundPlane.geometry.computeVertexNormals();else{let e=new Dt;e.setFromPoints(a),e.setIndex([0,3,2,0,2,1]),e.computeVertexNormals();let n=new ln({color:"#888",transparent:!0,opacity:0,side:Er});this.groundPlane=new xt(e,n),this.groundPlane.frustumCulled=!1,this.groundPlane.position.copy(l),this.groundPlane.scale.set(1e5,1e5,1),this.groundPlane.name="groundPlane",this.groundPlane.userData.selectable=!1,this.groundPlane.renderOrder=-1e3,this.groundPlane.layers.enableAll(),zn.disableLayerChannels(this.groundPlane,[12]),null==(t=this.scene)||t.add(this.groundPlane)}this.groundPlane.updateMatrixWorld()}initMaxAndMinZoom(){if(!this.controls)return;this.controls.update(0);let e=this.camera.zoom;this.controls.minZoom=e*this.minZoomFactor,this.controls.maxZoom=e*this.maxZoomFactor,this.initialZoom=e,this.cameraZoom=e}getImageElementFromUrl(e){let t=new Image;return t.src=e,new Promise(((e,n)=>{t.onload=()=>{e(t)},t.onerror=e=>{n(e)}}))}updateOverviewMap(e){return ft(this,null,(function*(){let t=new O,n=new O;t.set(e.min.x,e.min.y,e.min.z),n.set(e.max.x,e.max.y,e.max.z),t.applyMatrix4(this.transformMatrix),n.applyMatrix4(this.transformMatrix);let i=yield this.getImageElementFromUrl(e.image),r=new O(Math.min(t.x,n.x),0,Math.min(t.z,n.z)),a=new O(Math.max(t.x,n.x),0,Math.max(t.z,n.z)),s=new Ot(r,a);this.zoomToBBox(s),this.initMaxAndMinZoom(),this.initGroundPlane(s.clone());let o=this.overviewMapDrawable;o?(o.image=i,o.radius=this.radius,o.max.copy(n),o.min.copy(t)):this.addMarker(new J2("overviewMap",{image:i,min:t,max:n,radius:this.radius})),this.imgBBox=s,this.enableRender()}))}createCameraMarkers(e,t){return ft(this,null,(function*(){var n,i;if(!this.camera||!this.viewerContainer)return;let r=this.cameraDrawable,a=this.cameraDirDrawable;if(r)r.position.copy(e),null==(n=r.direction)||n.copy(t);else{let n=yield this.getImageElementFromUrl(k1e),i=yield this.getImageElementFromUrl(N1e);this.addMarker(new $_("cameraDirDrawable",{image:n,hoverImage:i,translate:new be(-1,-.5),scale:.25,position:e,direction:t,enabledHover:this.enabled}))}if(a)a.position.copy(e),null==(i=a.direction)||i.copy(t);else{let n=yield this.getImageElementFromUrl(O1e),i=yield this.getImageElementFromUrl(F1e);this.addMarker(new $_("cameraDrawable",{image:n,hoverImage:i,translate:new be(-.5,-.5),scale:.25,position:e,direction:t,enabledHover:this.enabled}))}this.enableRender()}))}initCameraMarkers(e,t){return ft(this,null,(function*(){var n;let i=new O(e.x,e.y,e.z),r=new O(t.x,t.y,t.z);if(i.applyMatrix4(this.transformMatrix),r.applyMatrix4(this.transformMatrix),this.lockCameraInViewCenter){let e=this.camera;yield this.createCameraMarkers(e.position,r),i.setY(e.position.y),null==(n=this.controls)||n.setLookAt(i.x,i.y,i.z,i.x,0,i.z)}else yield this.createCameraMarkers(i,r);this.updateZoomFromRadius()}))}updateOverviewMapCameraAnimation(){var e,t;let n=this.animationParam;if(!n)return void(this.animationId&&cancelAnimationFrame(this.animationId));let{startTime:i,positionStart:r,positionEnd:a,directionStart:s,directionEnd:o}=n,l=Math.min(1,(Date.now()-i)/500),h=r.lerp(a,l),c=s.lerp(o,l),u=this.cameraDrawable,d=this.cameraDirDrawable;if(null==(e=null==d?void 0:d.direction)||e.copy(c),this.lockCameraInViewCenter?null==(t=this.controls)||t.setLookAt(h.x,h.y,h.z,h.x,0,h.z):(null==u||u.position.copy(h),null==d||d.position.copy(h)),this.enableRender(),1===l)return this.animationParam=void 0,void(this.animationId&&cancelAnimationFrame(this.animationId));this.animationId=requestAnimationFrame(this.updateOverviewMapCameraAnimation.bind(this))}updateOverviewMapCamera(e,t){let n=this.cameraDrawable,i=this.cameraDirDrawable;if(!(this.camera&&this.viewerContainer&&n&&i&&this.isUpdateWhenPawnMove))return;this.animationId&&cancelAnimationFrame(this.animationId);let r,a=new O(e.x,e.y,e.z),s=new O(t.x,t.y,t.z);a.applyMatrix4(this.transformMatrix),s.applyMatrix4(this.transformMatrix),this.lockCameraInViewCenter?(r=this.camera.position.clone(),a.setY(r.y)):r=n.position.clone();let o=Date.now(),l=i.direction.clone();this.animationParam={startTime:o,positionStart:r,positionEnd:a,directionStart:l,directionEnd:s},this.updateOverviewMapCameraAnimation(),this.dispatchEvent("CameraChanged",a)}zoomToBBox(e){if(!this.scene||!this.camera||!this.controls)return;let t=this.camera,n=e.max.x-e.min.x,i=e.max.z-e.min.z,r=t.right-t.left,a=t.top-t.bottom,s=Math.min(r/n,a/i);this.controls.zoomTo(s);let o=new O;e.getCenter(o);let l=o.clone().setY(e.max.y+2);l.equals(o)||this.controls.setLookAt(l.x,l.y,l.z,o.x,o.y,o.z)}addMarker(e){this.drawableList.addDrawable(e),this.enableRender()}getMarker(e){return this.drawableList.getDrawableById(e)}removeMarker(e){this.drawableList.removeDrawable(e),this.enableRender()}dollyIn(e=.2){let t=this.camera;if(!t||!this.controls||!this.initialZoom)return;let n=t.zoom,i=Math.min(n+e*this.initialZoom,this.controls.maxZoom);this.controls.zoomTo(i)}dollyOut(e=.2){let t=this.camera;if(!t||!this.controls||!this.initialZoom)return;let n=t.zoom,i=Math.max(n-e*this.initialZoom,this.controls.minZoom);this.controls.zoomTo(i)}goToHomeView(){this.imgBBox&&this.zoomToBBox(this.imgBBox)}setRadius(e){this.radius=e;let t=this.overviewMapDrawable;t&&(t.radius=e),this.updateZoomFromRadius()}registerBoundaries(e){this.boundaries||(this.boundaries=new Map),e.forEach((e=>{var t;let n=e.points.map((e=>new be(e.x,e.y)));null==(t=this.boundaries)||t.set(e.id,{id:e.id,name:e.name,polygon:n})}))}screenShot(){return ft(this,null,(function*(){var e;try{let t=yield null==(e=this.overlayRender)?void 0:e.getImage((()=>!0));return null==t?void 0:t.src}catch(e){return void se.error(e)}}))}getViewConfig(){return this.cfg}getPixelSizeInWorldCoord(){let e=this.camera,{clientWidth:t,clientHeight:n}=this.viewerContainer;return Math.max(e.right-e.left,e.top-e.bottom)/e.zoom/Math.max(t,n)}lookToAllMarkers(){var e,t;let n=new Ot;this.drawableList.getDrawables().forEach((e=>{if("overviewMap"===e.id||"cameraDrawable"===e.id||"cameraDirDrawable"===e.id||!this.camera||!this.viewerContainer)return;let t=e;n.union(t.getBBox())})),n.min.setY(0),n.max.setY(0);let i=n.min.distanceTo(n.max);n.expandByVector(new O(.01*i,0,.01*i)),Zt.areVector3sEqual(null==(e=this.allMarkersBBox)?void 0:e.min,n.min)&&Zt.areVector3sEqual(null==(t=this.allMarkersBBox)?void 0:t.max,n.max)?this.enableLookToAllMarkers=!1:(this.allMarkersBBox=n,this.zoomToBBox(n))}resize(e,t){let n=this.camera;if(n&&t>0){let i=e/t;n.left=-this.frustumSize/2,n.right=this.frustumSize/2,n.top=this.frustumSize/i/2,n.bottom=-this.frustumSize/i/2,n.updateProjectionMatrix(),this.renderer&&this.renderer.setSize(e,t,!0),this.overlayRender&&this.overlayRender.setSize(e,t)}this.width=e,this.height=t,this.enableRender()}destroy(){var e,t,n;this.raycaster=void 0,null==(e=this.inputManager)||e.removeEventListener(),this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=void 0),this.timeout&&(clearTimeout(this.timeout),this.timeout=void 0),this.drawableList.clear(),null==(t=this.viewerContainer)||t.remove(),this.viewerContainer=void 0,null==(n=this.scene)||n.clear(),this.scene=void 0,this.requestAnimationFrameHandle&&(cancelAnimationFrame(this.requestAnimationFrameHandle),this.requestAnimationFrameHandle=void 0),this.renderer&&(this.renderer.domElement.remove(),this.renderer.clear(),this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer=void 0),this.overlayRender&&(this.overlayRender.destroy(),this.overlayRender=void 0),this.camera=void 0,this.controls&&(this.controls.dispose(),this.controls=void 0),this.groundPlane&&(this.groundPlane.geometry.dispose(),this.groundPlane.clear(),this.groundPlane=void 0),this.removeEventListener()}};export{SA as ANGLE_THRESHOLD_FOR_EDGE,$Lt as AXIS_SECTION_PLANE_CONTROL_ID,YLt as AXIS_SECTION_PLANE_ID,n6 as AnnotationTable,h5 as ArrowMarkup,Yve as AxisGizmoPlugin,l2 as AxisPlaneSection,Uve as AxisType,sy as BYBLOCK,iy as BYLAYER,IP as BaseDxfCompareHelper,Dr as BaseMeasureDrawable,nh as BaseMeasurement,ip as BaseSection,Wu as BaseTable,sp as BaseVRMesh,Zf as BaseViewer,zve as BimViewer,Pye as BimViewerDatGuiPlugin,tye as BimViewerToolbarPlugin,Cf as BinaryReader,ng as BitView,$ve as BottomBarPlugin,$f as BoxSelectHelper,Tf as CSS2DObjectUtils,ba as CameraControlsEx,EA as CancelablePromise,Hn as CanvasRender,d5 as CircleMarkup,Pc as CloudLineMarkup,f5 as CloudRectMarkup,Cn as ColorUtils,Mt as CommonUtils,Gm as CompareDrawable,oye as ContextMenuPlugin,tP as ControlsHelper,un as CoordinateConversionUtils,Jve as DEFAULT_BIMVIEWER_TOOLBAR_CONFIG,C0e as DEFAULT_BIM_VIEWER_CONFIG,Qve as DEFAULT_DXFVIEWER_TOOLBAR_CONFIG,Zve as DEFAULT_MARKUP_TOOLBAR_CONFIG,Dn as DeviceUtils,p5 as DotMarkup,Bi as Drawable,Ko as DrawableList,B5 as DxfChangeType,us as DxfCompare,hve as DxfCompareHelper,l0e as DxfCompareMarkupManager,gy as DxfDataTable,vn as DxfLoader,Xm as DxfParser,Yfe as DxfRenderOrder,Lc as DxfUtils,Qf as DxfViewer,eye as DxfViewerToolbarPlugin,XLt as ENTER_KEY,jLt as ESC_KEY,MA as EdgeUtils,m5 as EllipseMarkup,cs as Event,D2 as ExplodePlugin,Lm as ExportUtils,id as FontDataTable,cd as FontManager,IA as FpsUtils,bde as GROUND_PLANE_RENDER_ORDER,E2 as GROUP_CONFIG,yP as GenerateMeshBvhWorker,Qt as GeometryUtils,O2 as GroundGrassPlugin,k2 as GroundGridPlugin,Oye as GroundShadowPlugin,kye as HotpointPlugin,qv as ICON_FONT_CLASS,$_ as ImageDrawable,ns as IndexedDbManager,Jo as InputManager,P0e as InstantiateHelper,qLt as KEYDOWN_EVENT,WLt as KEYUP_EVENT,mht as Keys,Iye as LayerManagerPlugin,g5 as LeaderLineMarkup,ur as Line,L1e as LineDrawable,_C as LinePatternShaders,Ya as LoadingHelper,T1e as LocalDxfUploader,w1e as LocalImageUploader,N2 as LocalModelUploader,Kve as MARKUP_GROUP_CONFIG,wH as MOUSEDOWN_EVENT,wf as MOUSEMOVE_EVENT,TH as MOUSEUP_EVENT,dE as MarkupManager,_2 as MarkupToolbar,qa as MarkupType,es as MaterialUtils,Zt as MathUtils,ove as MeasurementPlugin,$l as MeasurementType,x2 as MenuTypeEnums,Ar as MergeUtils,xt as Mesh,Yf as MeshBvhHelper,MP as MobileTouchHelperDrawable,M1e as NavCubePlugin,qm as NestCompareTypes,TP as OSnapHelper,Pfe as OSnapMarkerType,k4 as OSnapType,ive as ObjectPixelSizeHelper,zn as ObjectUtils,c2 as ObjectsBoxSection,pve as Offset,J2 as OverviewMapDrawable,B1e as OverviewMapPlugin,Vyt as OverviewMapPluginEvent,ah as PdfLoader,_1e as PdfLoaderPlugin,wP as PickMarkupHelper,u2 as PickPlaneSection,dr as Plugin,ii as Points,Fm as PolygonUtils,v5 as PolylineMarkup,Gf as ProgressBar,qf as RafHelper,y5 as RectMarkup,JLt as SECTION_BOX_ID,KLt as SECTION_PLANE_CONTROL_ID,ZLt as SECTION_PLANE_ID,SH as SECTION_PLANE_NAME,rve as SHP,vP as SHPLoader,mP as SHPParser,TOt as SNAP_ICON_SIZE,pht as STATE,sde as SVGObject,Cfe as SVGObjectUtils,ade as SVGRenderer,ks as SceneUtils,MH as ScreenshotMode,F2 as ScreenshotPlugin,h2 as SectionPlugin,Wv as SectionType,Hu as SectionUtils,$n as ShaderChunk,gP as ShpThree,Gve as SimplifiedBimViewer,Afe as SimplifyUtils,C1e as SkyboxPlugin,As as SnapDrawable,A1e as StatsPlugin,D1e as TextDrawable,Ol as TextMarkup,Cc as TextureUtils,ap as Toolbar,uV as ToolbarMenu,b2 as ToolbarMenuId,t6 as Units,KA as VRControls,m2 as VRCube,g2 as VRCube24Faces,v2 as VRSphere,Xve as VRViewer,I1e as ViewCubePlugin,aE as Viewer3DUtils,Ii as ViewerEvent,Uvt as ViewerMode,Ly as ViewerName,r6 as ViewpointTable,u5 as Views,a2 as WebCam,x5 as XMarkup,Dy as ZoomToRectHelper,e6 as bspline,dme as checkIsNewVersion,Zde as cn,aye as contextMenuItems,lme as createHatchPatternShaderMaterial,bdt as decodeDxfTextCharacterCodes,_dt as decodeDxfTextMbcsCharacterCodes,Edt as decodeDxfTextUnicodeCodePoints,$de as en,IOt as getLengthValueByUnit,sE as getUnitStr,Sdt as getVersionFromLocalStorage,Uu as layerForHitableObjects,ti as layerForSelectableObjects,vs as layerForSnapableObjects,se as log,si as matrixAutoUpdate,TC as parseDxfMTextContent,wC as parseDxfTextContent,J5 as round10,GLt as sceneAutoUpdate,wA as setIcon,pde as setLogLevel,Mdt as setVersionToLocalStorage,Bu as showPrecisionValue,Ife as unitConversionByMeter,lht as unitLabel,ume as unitScaleConversion,cme as unitScaleToMeter}; \ No newline at end of file +var ySe=Object.create,m1=Object.defineProperty,xSe=Object.defineProperties,bSe=Object.getOwnPropertyDescriptor,ESe=Object.getOwnPropertyDescriptors,_Se=Object.getOwnPropertyNames,aG=Object.getOwnPropertySymbols,oG=Object.getPrototypeOf,lG=Object.prototype.hasOwnProperty,TSe=Object.prototype.propertyIsEnumerable,wSe=Reflect.get,Oo=Math.pow,a3=(e,t,n)=>t in e?m1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tr=(e,t)=>{for(var n in t||(t={}))lG.call(t,n)&&a3(e,n,t[n]);if(aG)for(var n of aG(t))TSe.call(t,n)&&a3(e,n,t[n]);return e},Ri=(e,t)=>xSe(e,ESe(t)),o3=(e=>"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(e,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):e)((function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')})),SSe=(e,t)=>()=>(e&&(t=e(e=0)),t),J=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),FT=(e,t)=>{for(var n in t)m1(e,n,{get:t[n],enumerable:!0})},cG=(e,t,n,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of _Se(t))!lG.call(e,r)&&r!==n&&m1(e,r,{get:()=>t[r],enumerable:!(i=bSe(t,r))||i.enumerable});return e},ji=(e,t,n)=>(n=null!=e?ySe(oG(e)):{},cG(!t&&e&&e.__esModule?n:m1(n,"default",{value:e,enumerable:!0}),e)),MSe=e=>cG(m1({},"__esModule",{value:!0}),e),Xi=(e,t,n)=>(a3(e,"symbol"!=typeof t?t+"":t,n),n),l3=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},ce=(e,t,n)=>(l3(e,t,"read from private field"),n?n.call(e):t.get(e)),Je=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},St=(e,t,n,i)=>(l3(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),NT=(e,t,n,i)=>({set _(i){St(e,t,i,n)},get _(){return ce(e,t,i)}}),dt=(e,t,n)=>(l3(e,t,"access private method"),n),uG=(e,t,n)=>wSe(oG(e),n,t),ft=(e,t,n)=>new Promise(((i,r)=>{var a=e=>{try{o(n.next(e))}catch(e){r(e)}},s=e=>{try{o(n.throw(e))}catch(e){r(e)}},o=e=>e.done?i(e.value):Promise.resolve(e.value).then(a,s);o((n=n.apply(e,t)).next())})),fG={};function BT(e){return(BT="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ASe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function hG(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};ASe(this,r),this._locale=function(e){for(var t=dG(e),n=0;nDSe});var PSe,dG,ISe,LSe,pG=SSe((()=>{PSe=function(e){return e.split("-").every((function(e){return/[a-z0-9]+/i.test(e)}))},dG=function(e){if(!e)return[];Array.isArray(e)||(e=[e]);for(var t={},n=0;n{"use strict";function n(e,t){for(var n=0;n="0"&&r<="9"&&++n}return nthis._maxSD?e.toPrecision(this._maxSD):t}return this._minFD>0?e.toFixed(this._minFD):0===this._maxFD?e.toFixed(0):String(e)}}]),e}();t.exports=i})),SG=J(((e,t)=>{"use strict";var n=(pG(),MSe(fG)),i=vG();function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=r(n),s=r(i);function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var h,c,u,d,p,f,m,g,v={exports:{}};h=v,u=function(e,t){return t?"other":1==e?"one":"other"},d=function(e,t){return t?"other":0==e||1==e?"one":"other"},p=function(e,t){return t?"other":e>=0&&e<=1?"one":"other"},f=function(e,t){var n=!String(e).split(".")[1];return t?"other":1==e&&n?"one":"other"},g=function(e,t){return t?"other":1==e?"one":2==e?"two":"other"},c={_in:m=function(e,t){return"other"},af:u,ak:d,am:p,an:u,ar:function(e,t){var n=String(e).split("."),i=Number(n[0])==e&&n[0].slice(-2);return t?"other":0==e?"zero":1==e?"one":2==e?"two":i>=3&&i<=10?"few":i>=11&&i<=99?"many":"other"},ars:function(e,t){var n=String(e).split("."),i=Number(n[0])==e&&n[0].slice(-2);return t?"other":0==e?"zero":1==e?"one":2==e?"two":i>=3&&i<=10?"few":i>=11&&i<=99?"many":"other"},as:function(e,t){return t?1==e||5==e||7==e||8==e||9==e||10==e?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":e>=0&&e<=1?"one":"other"},asa:u,ast:f,az:function(e,t){var n=String(e).split(".")[0],i=n.slice(-1),r=n.slice(-2),a=n.slice(-3);return t?1==i||2==i||5==i||7==i||8==i||20==r||50==r||70==r||80==r?"one":3==i||4==i||100==a||200==a||300==a||400==a||500==a||600==a||700==a||800==a||900==a?"few":0==n||6==i||40==r||60==r||90==r?"many":"other":1==e?"one":"other"},be:function(e,t){var n=String(e).split("."),i=Number(n[0])==e,r=i&&n[0].slice(-1),a=i&&n[0].slice(-2);return t?2!=r&&3!=r||12==a||13==a?"other":"few":1==r&&11!=a?"one":r>=2&&r<=4&&(a<12||a>14)?"few":i&&0==r||r>=5&&r<=9||a>=11&&a<=14?"many":"other"},bem:u,bez:u,bg:u,bho:d,bm:m,bn:function(e,t){return t?1==e||5==e||7==e||8==e||9==e||10==e?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":e>=0&&e<=1?"one":"other"},bo:m,br:function(e,t){var n=String(e).split("."),i=Number(n[0])==e,r=i&&n[0].slice(-1),a=i&&n[0].slice(-2),s=i&&n[0].slice(-6);return t?"other":1==r&&11!=a&&71!=a&&91!=a?"one":2==r&&12!=a&&72!=a&&92!=a?"two":(3==r||4==r||9==r)&&(a<10||a>19)&&(a<70||a>79)&&(a<90||a>99)?"few":0!=e&&i&&0==s?"many":"other"},brx:u,bs:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=i.slice(-2),l=r.slice(-1),h=r.slice(-2);return t?"other":a&&1==s&&11!=o||1==l&&11!=h?"one":a&&s>=2&&s<=4&&(o<12||o>14)||l>=2&&l<=4&&(h<12||h>14)?"few":"other"},ca:function(e,t){var n=!String(e).split(".")[1];return t?1==e||3==e?"one":2==e?"two":4==e?"few":"other":1==e&&n?"one":"other"},ce:u,ceb:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=r.slice(-1);return t?"other":a&&(1==i||2==i||3==i)||a&&4!=s&&6!=s&&9!=s||!a&&4!=o&&6!=o&&9!=o?"one":"other"},cgg:u,chr:u,ckb:u,cs:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1];return t?"other":1==e&&r?"one":i>=2&&i<=4&&r?"few":r?"other":"many"},cy:function(e,t){return t?0==e||7==e||8==e||9==e?"zero":1==e?"one":2==e?"two":3==e||4==e?"few":5==e||6==e?"many":"other":0==e?"zero":1==e?"one":2==e?"two":3==e?"few":6==e?"many":"other"},da:function(e,t){var n=String(e).split("."),i=n[0],r=Number(n[0])==e;return t||1!=e&&(r||0!=i&&1!=i)?"other":"one"},de:f,doi:p,dsb:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-2),o=r.slice(-2);return t?"other":a&&1==s||1==o?"one":a&&2==s||2==o?"two":a&&(3==s||4==s)||3==o||4==o?"few":"other"},dv:u,dz:m,ee:u,el:u,en:function(e,t){var n=String(e).split("."),i=!n[1],r=Number(n[0])==e,a=r&&n[0].slice(-1),s=r&&n[0].slice(-2);return t?1==a&&11!=s?"one":2==a&&12!=s?"two":3==a&&13!=s?"few":"other":1==e&&i?"one":"other"},eo:u,es:u,et:f,eu:u,fa:p,ff:function(e,t){return t?"other":e>=0&&e<2?"one":"other"},fi:f,fil:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=r.slice(-1);return t?1==e?"one":"other":a&&(1==i||2==i||3==i)||a&&4!=s&&6!=s&&9!=s||!a&&4!=o&&6!=o&&9!=o?"one":"other"},fo:u,fr:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=i.slice(-6);return t?1==e?"one":"other":e>=0&&e<2?"one":0!=i&&0==a&&r?"many":"other"},fur:u,fy:f,ga:function(e,t){var n=String(e).split("."),i=Number(n[0])==e;return t?1==e?"one":"other":1==e?"one":2==e?"two":i&&e>=3&&e<=6?"few":i&&e>=7&&e<=10?"many":"other"},gd:function(e,t){var n=String(e).split("."),i=Number(n[0])==e;return t?1==e||11==e?"one":2==e||12==e?"two":3==e||13==e?"few":"other":1==e||11==e?"one":2==e||12==e?"two":i&&e>=3&&e<=10||i&&e>=13&&e<=19?"few":"other"},gl:f,gsw:u,gu:function(e,t){return t?1==e?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":e>=0&&e<=1?"one":"other"},guw:d,gv:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=i.slice(-1),s=i.slice(-2);return t?"other":r&&1==a?"one":r&&2==a?"two":!r||0!=s&&20!=s&&40!=s&&60!=s&&80!=s?r?"other":"many":"few"},ha:u,haw:u,he:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=Number(n[0])==e,s=a&&n[0].slice(-1);return t?"other":1==e&&r?"one":2==i&&r?"two":r&&(e<0||e>10)&&a&&0==s?"many":"other"},hi:function(e,t){return t?1==e?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":e>=0&&e<=1?"one":"other"},hr:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=i.slice(-2),l=r.slice(-1),h=r.slice(-2);return t?"other":a&&1==s&&11!=o||1==l&&11!=h?"one":a&&s>=2&&s<=4&&(o<12||o>14)||l>=2&&l<=4&&(h<12||h>14)?"few":"other"},hsb:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-2),o=r.slice(-2);return t?"other":a&&1==s||1==o?"one":a&&2==s||2==o?"two":a&&(3==s||4==s)||3==o||4==o?"few":"other"},hu:function(e,t){return t?1==e||5==e?"one":"other":1==e?"one":"other"},hy:function(e,t){return t?1==e?"one":"other":e>=0&&e<2?"one":"other"},ia:f,id:m,ig:m,ii:m,io:f,is:function(e,t){var n=String(e).split("."),i=n[0],r=Number(n[0])==e,a=i.slice(-1),s=i.slice(-2);return t?"other":r&&1==a&&11!=s||!r?"one":"other"},it:function(e,t){var n=!String(e).split(".")[1];return t?11==e||8==e||80==e||800==e?"many":"other":1==e&&n?"one":"other"},iu:g,iw:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=Number(n[0])==e,s=a&&n[0].slice(-1);return t?"other":1==e&&r?"one":2==i&&r?"two":r&&(e<0||e>10)&&a&&0==s?"many":"other"},ja:m,jbo:m,jgo:u,ji:f,jmc:u,jv:m,jw:m,ka:function(e,t){var n=String(e).split(".")[0],i=n.slice(-2);return t?1==n?"one":0==n||i>=2&&i<=20||40==i||60==i||80==i?"many":"other":1==e?"one":"other"},kab:function(e,t){return t?"other":e>=0&&e<2?"one":"other"},kaj:u,kcg:u,kde:m,kea:m,kk:function(e,t){var n=String(e).split("."),i=Number(n[0])==e,r=i&&n[0].slice(-1);return t?6==r||9==r||i&&0==r&&0!=e?"many":"other":1==e?"one":"other"},kkj:u,kl:u,km:m,kn:p,ko:m,ks:u,ksb:u,ksh:function(e,t){return t?"other":0==e?"zero":1==e?"one":"other"},ku:u,kw:function(e,t){var n=String(e).split("."),i=Number(n[0])==e,r=i&&n[0].slice(-2),a=i&&n[0].slice(-3),s=i&&n[0].slice(-5),o=i&&n[0].slice(-6);return t?i&&e>=1&&e<=4||r>=1&&r<=4||r>=21&&r<=24||r>=41&&r<=44||r>=61&&r<=64||r>=81&&r<=84?"one":5==e||5==r?"many":"other":0==e?"zero":1==e?"one":2==r||22==r||42==r||62==r||82==r||i&&0==a&&(s>=1e3&&s<=2e4||4e4==s||6e4==s||8e4==s)||0!=e&&1e5==o?"two":3==r||23==r||43==r||63==r||83==r?"few":1==e||1!=r&&21!=r&&41!=r&&61!=r&&81!=r?"other":"many"},ky:u,lag:function(e,t){var n=String(e).split(".")[0];return t?"other":0==e?"zero":0!=n&&1!=n||0==e?"other":"one"},lb:u,lg:u,lij:function(e,t){var n=String(e).split("."),i=!n[1],r=Number(n[0])==e;return t?11==e||8==e||r&&e>=80&&e<=89||r&&e>=800&&e<=899?"many":"other":1==e&&i?"one":"other"},lkt:m,ln:d,lo:function(e,t){return t&&1==e?"one":"other"},lt:function(e,t){var n=String(e).split("."),i=n[1]||"",r=Number(n[0])==e,a=r&&n[0].slice(-1),s=r&&n[0].slice(-2);return t?"other":1==a&&(s<11||s>19)?"one":a>=2&&a<=9&&(s<11||s>19)?"few":0!=i?"many":"other"},lv:function(e,t){var n=String(e).split("."),i=n[1]||"",r=i.length,a=Number(n[0])==e,s=a&&n[0].slice(-1),o=a&&n[0].slice(-2),l=i.slice(-2),h=i.slice(-1);return t?"other":a&&0==s||o>=11&&o<=19||2==r&&l>=11&&l<=19?"zero":1==s&&11!=o||2==r&&1==h&&11!=l||2!=r&&1==h?"one":"other"},mas:u,mg:d,mgo:u,mk:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=i.slice(-2),l=r.slice(-1),h=r.slice(-2);return t?1==s&&11!=o?"one":2==s&&12!=o?"two":7!=s&&8!=s||17==o||18==o?"other":"many":a&&1==s&&11!=o||1==l&&11!=h?"one":"other"},ml:u,mn:u,mo:function(e,t){var n=String(e).split("."),i=!n[1],r=Number(n[0])==e&&n[0].slice(-2);return t?1==e?"one":"other":1==e&&i?"one":!i||0==e||r>=2&&r<=19?"few":"other"},mr:function(e,t){return t?1==e?"one":2==e||3==e?"two":4==e?"few":"other":1==e?"one":"other"},ms:function(e,t){return t&&1==e?"one":"other"},mt:function(e,t){var n=String(e).split("."),i=Number(n[0])==e&&n[0].slice(-2);return t?"other":1==e?"one":0==e||i>=2&&i<=10?"few":i>=11&&i<=19?"many":"other"},my:m,nah:u,naq:g,nb:u,nd:u,ne:function(e,t){var n=String(e).split("."),i=Number(n[0])==e;return t?i&&e>=1&&e<=4?"one":"other":1==e?"one":"other"},nl:f,nn:u,nnh:u,no:u,nqo:m,nr:u,nso:d,ny:u,nyn:u,om:u,or:function(e,t){var n=String(e).split("."),i=Number(n[0])==e;return t?1==e||5==e||i&&e>=7&&e<=9?"one":2==e||3==e?"two":4==e?"few":6==e?"many":"other":1==e?"one":"other"},os:u,osa:m,pa:d,pap:u,pcm:p,pl:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=i.slice(-1),s=i.slice(-2);return t?"other":1==e&&r?"one":r&&a>=2&&a<=4&&(s<12||s>14)?"few":r&&1!=i&&(0==a||1==a)||r&&a>=5&&a<=9||r&&s>=12&&s<=14?"many":"other"},prg:function(e,t){var n=String(e).split("."),i=n[1]||"",r=i.length,a=Number(n[0])==e,s=a&&n[0].slice(-1),o=a&&n[0].slice(-2),l=i.slice(-2),h=i.slice(-1);return t?"other":a&&0==s||o>=11&&o<=19||2==r&&l>=11&&l<=19?"zero":1==s&&11!=o||2==r&&1==h&&11!=l||2!=r&&1==h?"one":"other"},ps:u,pt:function(e,t){var n=String(e).split(".")[0];return t?"other":0==n||1==n?"one":"other"},pt_PT:f,rm:u,ro:function(e,t){var n=String(e).split("."),i=!n[1],r=Number(n[0])==e&&n[0].slice(-2);return t?1==e?"one":"other":1==e&&i?"one":!i||0==e||r>=2&&r<=19?"few":"other"},rof:u,root:m,ru:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=i.slice(-1),s=i.slice(-2);return t?"other":r&&1==a&&11!=s?"one":r&&a>=2&&a<=4&&(s<12||s>14)?"few":r&&0==a||r&&a>=5&&a<=9||r&&s>=11&&s<=14?"many":"other"},rwk:u,sah:m,saq:u,sat:g,sc:function(e,t){var n=!String(e).split(".")[1];return t?11==e||8==e||80==e||800==e?"many":"other":1==e&&n?"one":"other"},scn:function(e,t){var n=!String(e).split(".")[1];return t?11==e||8==e||80==e||800==e?"many":"other":1==e&&n?"one":"other"},sd:u,sdh:u,se:g,seh:u,ses:m,sg:m,sh:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=i.slice(-2),l=r.slice(-1),h=r.slice(-2);return t?"other":a&&1==s&&11!=o||1==l&&11!=h?"one":a&&s>=2&&s<=4&&(o<12||o>14)||l>=2&&l<=4&&(h<12||h>14)?"few":"other"},shi:function(e,t){var n=String(e).split("."),i=Number(n[0])==e;return t?"other":e>=0&&e<=1?"one":i&&e>=2&&e<=10?"few":"other"},si:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"";return t?"other":0==e||1==e||0==i&&1==r?"one":"other"},sk:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1];return t?"other":1==e&&r?"one":i>=2&&i<=4&&r?"few":r?"other":"many"},sl:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=i.slice(-2);return t?"other":r&&1==a?"one":r&&2==a?"two":r&&(3==a||4==a)||!r?"few":"other"},sma:g,smi:g,smj:g,smn:g,sms:g,sn:u,so:u,sq:function(e,t){var n=String(e).split("."),i=Number(n[0])==e,r=i&&n[0].slice(-1),a=i&&n[0].slice(-2);return t?1==e?"one":4==r&&14!=a?"many":"other":1==e?"one":"other"},sr:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=i.slice(-2),l=r.slice(-1),h=r.slice(-2);return t?"other":a&&1==s&&11!=o||1==l&&11!=h?"one":a&&s>=2&&s<=4&&(o<12||o>14)||l>=2&&l<=4&&(h<12||h>14)?"few":"other"},ss:u,ssy:u,st:u,su:m,sv:function(e,t){var n=String(e).split("."),i=!n[1],r=Number(n[0])==e,a=r&&n[0].slice(-1),s=r&&n[0].slice(-2);return t?1!=a&&2!=a||11==s||12==s?"other":"one":1==e&&i?"one":"other"},sw:f,syr:u,ta:u,te:u,teo:u,th:m,ti:d,tig:u,tk:function(e,t){var n=String(e).split("."),i=Number(n[0])==e&&n[0].slice(-1);return t?6==i||9==i||10==e?"few":"other":1==e?"one":"other"},tl:function(e,t){var n=String(e).split("."),i=n[0],r=n[1]||"",a=!n[1],s=i.slice(-1),o=r.slice(-1);return t?1==e?"one":"other":a&&(1==i||2==i||3==i)||a&&4!=s&&6!=s&&9!=s||!a&&4!=o&&6!=o&&9!=o?"one":"other"},tn:u,to:m,tr:u,ts:u,tzm:function(e,t){var n=String(e).split("."),i=Number(n[0])==e;return t?"other":0==e||1==e||i&&e>=11&&e<=99?"one":"other"},ug:u,uk:function(e,t){var n=String(e).split("."),i=n[0],r=!n[1],a=Number(n[0])==e,s=a&&n[0].slice(-1),o=a&&n[0].slice(-2),l=i.slice(-1),h=i.slice(-2);return t?3==s&&13!=o?"few":"other":r&&1==l&&11!=h?"one":r&&l>=2&&l<=4&&(h<12||h>14)?"few":r&&0==l||r&&l>=5&&l<=9||r&&h>=11&&h<=14?"many":"other"},ur:f,uz:u,ve:u,vi:function(e,t){return t&&1==e?"one":"other"},vo:u,vun:u,wa:d,wae:u,wo:m,xh:u,xog:u,yi:f,yo:m,yue:m,zh:m,zu:p},Object.defineProperty(c,"__esModule",{value:!0}),h.exports=c;var y=l(v.exports),x=Object.freeze(Object.assign(Object.create(null),v.exports,{default:y})),b={exports:{}};!function(e,t){var n,i="zero",r="one",a="two",s="few",o="many",l="other",h={cardinal:[r,l],ordinal:[l]},c={cardinal:[l],ordinal:[l]},u={cardinal:[r,s,o,l],ordinal:[l]},d={cardinal:[r,l],ordinal:[r,l]},p={cardinal:[r,a,l],ordinal:[l]};n={_in:c,af:h,ak:h,am:h,an:h,ar:{cardinal:[i,r,a,s,o,l],ordinal:[l]},ars:{cardinal:[i,r,a,s,o,l],ordinal:[l]},as:{cardinal:[r,l],ordinal:[r,a,s,o,l]},asa:h,ast:h,az:{cardinal:[r,l],ordinal:[r,s,o,l]},be:{cardinal:[r,s,o,l],ordinal:[s,l]},bem:h,bez:h,bg:h,bho:h,bm:c,bn:{cardinal:[r,l],ordinal:[r,a,s,o,l]},bo:c,br:{cardinal:[r,a,s,o,l],ordinal:[l]},brx:h,bs:{cardinal:[r,s,l],ordinal:[l]},ca:{cardinal:[r,l],ordinal:[r,a,s,l]},ce:h,ceb:h,cgg:h,chr:h,ckb:h,cs:u,cy:{cardinal:[i,r,a,s,o,l],ordinal:[i,r,a,s,o,l]},da:h,de:h,doi:h,dsb:{cardinal:[r,a,s,l],ordinal:[l]},dv:h,dz:c,ee:h,el:h,en:{cardinal:[r,l],ordinal:[r,a,s,l]},eo:h,es:h,et:h,eu:h,fa:h,ff:h,fi:h,fil:d,fo:h,fr:{cardinal:[r,o,l],ordinal:[r,l]},fur:h,fy:h,ga:{cardinal:[r,a,s,o,l],ordinal:[r,l]},gd:{cardinal:[r,a,s,l],ordinal:[r,a,s,l]},gl:h,gsw:h,gu:{cardinal:[r,l],ordinal:[r,a,s,o,l]},guw:h,gv:{cardinal:[r,a,s,o,l],ordinal:[l]},ha:h,haw:h,he:{cardinal:[r,a,o,l],ordinal:[l]},hi:{cardinal:[r,l],ordinal:[r,a,s,o,l]},hr:{cardinal:[r,s,l],ordinal:[l]},hsb:{cardinal:[r,a,s,l],ordinal:[l]},hu:d,hy:d,ia:h,id:c,ig:c,ii:c,io:h,is:h,it:{cardinal:[r,l],ordinal:[o,l]},iu:p,iw:{cardinal:[r,a,o,l],ordinal:[l]},ja:c,jbo:c,jgo:h,ji:h,jmc:h,jv:c,jw:c,ka:{cardinal:[r,l],ordinal:[r,o,l]},kab:h,kaj:h,kcg:h,kde:c,kea:c,kk:{cardinal:[r,l],ordinal:[o,l]},kkj:h,kl:h,km:c,kn:h,ko:c,ks:h,ksb:h,ksh:{cardinal:[i,r,l],ordinal:[l]},ku:h,kw:{cardinal:[i,r,a,s,o,l],ordinal:[r,o,l]},ky:h,lag:{cardinal:[i,r,l],ordinal:[l]},lb:h,lg:h,lij:{cardinal:[r,l],ordinal:[o,l]},lkt:c,ln:h,lo:{cardinal:[l],ordinal:[r,l]},lt:u,lv:{cardinal:[i,r,l],ordinal:[l]},mas:h,mg:h,mgo:h,mk:{cardinal:[r,l],ordinal:[r,a,o,l]},ml:h,mn:h,mo:{cardinal:[r,s,l],ordinal:[r,l]},mr:{cardinal:[r,l],ordinal:[r,a,s,l]},ms:{cardinal:[l],ordinal:[r,l]},mt:u,my:c,nah:h,naq:p,nb:h,nd:h,ne:d,nl:h,nn:h,nnh:h,no:h,nqo:c,nr:h,nso:h,ny:h,nyn:h,om:h,or:{cardinal:[r,l],ordinal:[r,a,s,o,l]},os:h,osa:c,pa:h,pap:h,pcm:h,pl:u,prg:{cardinal:[i,r,l],ordinal:[l]},ps:h,pt:h,pt_PT:h,rm:h,ro:{cardinal:[r,s,l],ordinal:[r,l]},rof:h,root:c,ru:u,rwk:h,sah:c,saq:h,sat:p,sc:{cardinal:[r,l],ordinal:[o,l]},scn:{cardinal:[r,l],ordinal:[o,l]},sd:h,sdh:h,se:p,seh:h,ses:c,sg:c,sh:{cardinal:[r,s,l],ordinal:[l]},shi:{cardinal:[r,s,l],ordinal:[l]},si:h,sk:u,sl:{cardinal:[r,a,s,l],ordinal:[l]},sma:p,smi:p,smj:p,smn:p,sms:p,sn:h,so:h,sq:{cardinal:[r,l],ordinal:[r,o,l]},sr:{cardinal:[r,s,l],ordinal:[l]},ss:h,ssy:h,st:h,su:c,sv:d,sw:h,syr:h,ta:h,te:h,teo:h,th:c,ti:h,tig:h,tk:{cardinal:[r,l],ordinal:[s,l]},tl:d,tn:h,to:c,tr:h,ts:h,tzm:h,ug:h,uk:{cardinal:[r,s,o,l],ordinal:[s,l]},ur:h,uz:h,ve:h,vi:{cardinal:[l],ordinal:[r,l]},vo:h,vun:h,wa:h,wae:h,wo:c,xh:h,xog:h,yi:h,yo:c,yue:c,zh:c,zu:h},Object.defineProperty(n,"__esModule",{value:!0}),e.exports=n}(b);var _=l(b.exports),w=Object.freeze(Object.assign(Object.create(null),b.exports,{default:_})),S=y||x,M=_||w,T="object"===("undefined"==typeof Intl?"undefined":o(Intl))&&Intl.NumberFormat||s.default,E=function(e){return"in"===e?"_in":"pt-PT"===e?"pt_PT":e},A=a.default(T,(function(e){return S[E(e)]}),(function(e,t){return M[E(e)][t?"ordinal":"cardinal"]}));t.exports=A})),AG=J((e=>{"use strict";var t,n,i=(t=SG())&&"object"==typeof t&&"default"in t?t:{default:t};"undefined"==typeof Intl?("undefined"!=typeof global?global.Intl={PluralRules:i.default}:"undefined"!=typeof window?window.Intl={PluralRules:i.default}:e.Intl={PluralRules:i.default},i.default.polyfill=!0):Intl.PluralRules?(n=["en","es","ru","zh"],Intl.PluralRules.supportedLocalesOf(n).length{var n=function(e){return e&&e.Math==Math&&e};t.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof global&&global)||function(){return this}()||e||Function("return this")()})),Yt=J(((e,t)=>{t.exports=function(e){try{return!!e()}catch(e){return!0}}})),Kn=J(((e,t)=>{var n=Yt();t.exports=!n((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))})),Mg=J(((e,t)=>{var n=Yt();t.exports=!n((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))})),wr=J(((e,t)=>{var n=Mg(),i=Function.prototype.call;t.exports=n?i.bind(i):function(){return i.apply(i,arguments)}})),g1=J((e=>{"use strict";var t={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor,i=n&&!t.call({1:2},1);e.f=i?function(e){var t=n(this,e);return!!t&&t.enumerable}:t})),ko=J(((e,t)=>{t.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}})),en=J(((e,t)=>{var n=Mg(),i=Function.prototype,r=i.call,a=n&&i.bind.bind(r,r);t.exports=n?a:function(e){return function(){return r.apply(e,arguments)}}})),ha=J(((e,t)=>{var n=en(),i=n({}.toString),r=n("".slice);t.exports=function(e){return r(i(e),8,-1)}})),bp=J(((e,t)=>{var n=en(),i=Yt(),r=ha(),a=Object,s=n("".split);t.exports=i((function(){return!a("z").propertyIsEnumerable(0)}))?function(e){return"String"==r(e)?s(e,""):a(e)}:a})),La=J(((e,t)=>{t.exports=function(e){return null==e}})),_s=J(((e,t)=>{var n=La(),i=TypeError;t.exports=function(e){if(n(e))throw i("Can't call method on "+e);return e}})),Ls=J(((e,t)=>{var n=bp(),i=_s();t.exports=function(e){return n(i(e))}})),m3=J(((e,t)=>{var n="object"==typeof document&&document.all,i=void 0===n&&void 0!==n;t.exports={all:n,IS_HTMLDDA:i}})),Fr=J(((e,t)=>{var n=m3(),i=n.all;t.exports=n.IS_HTMLDDA?function(e){return"function"==typeof e||e===i}:function(e){return"function"==typeof e}})),Nr=J(((e,t)=>{var n=Fr(),i=m3(),r=i.all;t.exports=i.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:n(e)||e===r}:function(e){return"object"==typeof e?null!==e:n(e)}})),ki=J(((e,t)=>{var n=Mn(),i=Fr();t.exports=function(e,t){return arguments.length<2?function(e){return i(e)?e:void 0}(n[e]):n[e]&&n[e][t]}})),Fo=J(((e,t)=>{var n=en();t.exports=n({}.isPrototypeOf)})),iu=J(((e,t)=>{t.exports="undefined"!=typeof navigator&&String(navigator.userAgent)||""})),su=J(((e,t)=>{var n,i,r=Mn(),a=iu(),s=r.process,o=r.Deno,l=s&&s.versions||o&&o.version,h=l&&l.v8;h&&(i=(n=h.split("."))[0]>0&&n[0]<4?1:+(n[0]+n[1])),!i&&a&&(!(n=a.match(/Edge\/(\d+)/))||n[1]>=74)&&(n=a.match(/Chrome\/(\d+)/))&&(i=+n[1]),t.exports=i})),Ep=J(((e,t)=>{var n=su(),i=Yt(),r=Mn().String;t.exports=!!Object.getOwnPropertySymbols&&!i((function(){var e=Symbol();return!r(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&n&&n<41}))})),y3=J(((e,t)=>{var n=Ep();t.exports=n&&!Symbol.sham&&"symbol"==typeof Symbol.iterator})),Od=J(((e,t)=>{var n=ki(),i=Fr(),r=Fo(),a=y3(),s=Object;t.exports=a?function(e){return"symbol"==typeof e}:function(e){var t=n("Symbol");return i(t)&&r(t.prototype,s(e))}})),kd=J(((e,t)=>{var n=String;t.exports=function(e){try{return n(e)}catch(e){return"Object"}}})),ss=J(((e,t)=>{var n=Fr(),i=kd(),r=TypeError;t.exports=function(e){if(n(e))return e;throw r(i(e)+" is not a function")}})),au=J(((e,t)=>{var n=ss(),i=La();t.exports=function(e,t){var r=e[t];return i(r)?void 0:n(r)}})),_3=J(((e,t)=>{var n=wr(),i=Fr(),r=Nr(),a=TypeError;t.exports=function(e,t){var s,o;if("string"===t&&i(s=e.toString)&&!r(o=n(s,e))||i(s=e.valueOf)&&!r(o=n(s,e))||"string"!==t&&i(s=e.toString)&&!r(o=n(s,e)))return o;throw a("Can't convert object to primitive value")}})),as=J(((e,t)=>{t.exports=!1})),GT=J(((e,t)=>{var n=Mn(),i=Object.defineProperty;t.exports=function(e,t){try{i(n,e,{value:t,configurable:!0,writable:!0})}catch(i){n[e]=t}return t}})),qT=J(((e,t)=>{var n=Mn(),i=GT(),r="__core-js_shared__",a=n[r]||i(r,{});t.exports=a})),_p=J(((e,t)=>{var n=as(),i=qT();(t.exports=function(e,t){return i[e]||(i[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.30.2",mode:n?"pure":"global",copyright:"\xa9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.30.2/LICENSE",source:"https://github.com/zloirock/core-js"})})),ci=J(((e,t)=>{var n=_s(),i=Object;t.exports=function(e){return i(n(e))}})),$r=J(((e,t)=>{var n=en(),i=ci(),r=n({}.hasOwnProperty);t.exports=Object.hasOwn||function(e,t){return r(i(e),t)}})),Tp=J(((e,t)=>{var n=en(),i=0,r=Math.random(),a=n(1..toString);t.exports=function(e){return"Symbol("+(void 0===e?"":e)+")_"+a(++i+r,36)}})),Br=J(((e,t)=>{var n=Mn(),i=_p(),r=$r(),a=Tp(),s=Ep(),o=y3(),l=n.Symbol,h=i("wks"),c=o?l.for||l:l&&l.withoutSetter||a;t.exports=function(e){return r(h,e)||(h[e]=s&&r(l,e)?l[e]:c("Symbol."+e)),h[e]}})),v1=J(((e,t)=>{var n=wr(),i=Nr(),r=Od(),a=au(),s=_3(),o=Br(),l=TypeError,h=o("toPrimitive");t.exports=function(e,t){if(!i(e)||r(e))return e;var o,c=a(e,h);if(c){if(void 0===t&&(t="default"),o=n(c,e,t),!i(o)||r(o))return o;throw l("Can't convert object to primitive value")}return void 0===t&&(t="number"),s(e,t)}})),vh=J(((e,t)=>{var n=v1(),i=Od();t.exports=function(e){var t=n(e,"string");return i(t)?t:t+""}})),y1=J(((e,t)=>{var n=Mn(),i=Nr(),r=n.document,a=i(r)&&i(r.createElement);t.exports=function(e){return a?r.createElement(e):{}}})),S3=J(((e,t)=>{var n=Kn(),i=Yt(),r=y1();t.exports=!n&&!i((function(){return 7!=Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a}))})),Qs=J((e=>{var t=Kn(),n=wr(),i=g1(),r=ko(),a=Ls(),s=vh(),o=$r(),l=S3(),h=Object.getOwnPropertyDescriptor;e.f=t?h:function(e,t){if(e=a(e),t=s(t),l)try{return h(e,t)}catch(e){}if(o(e,t))return r(!n(i.f,e,t),e[t])}})),M3=J(((e,t)=>{var n=Kn(),i=Yt();t.exports=n&&i((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))})),br=J(((e,t)=>{var n=Nr(),i=String,r=TypeError;t.exports=function(e){if(n(e))return e;throw r(i(e)+" is not an object")}})),Gi=J((e=>{var t=Kn(),n=S3(),i=M3(),r=br(),a=vh(),s=TypeError,o=Object.defineProperty,l=Object.getOwnPropertyDescriptor,h="enumerable",c="configurable",u="writable";e.f=t?i?function(e,t,n){if(r(e),t=a(t),r(n),"function"==typeof e&&"prototype"===t&&"value"in n&&u in n&&!n[u]){var i=l(e,t);i&&i[u]&&(e[t]=n.value,n={configurable:c in n?n[c]:i[c],enumerable:h in n?n[h]:i[h],writable:!1})}return o(e,t,n)}:o:function(e,t,i){if(r(e),t=a(t),r(i),n)try{return o(e,t,i)}catch(e){}if("get"in i||"set"in i)throw s("Accessors not supported");return"value"in i&&(e[t]=i.value),e}})),da=J(((e,t)=>{var n=Kn(),i=Gi(),r=ko();t.exports=n?function(e,t,n){return i.f(e,t,r(1,n))}:function(e,t,n){return e[t]=n,e}})),wp=J(((e,t)=>{var n=Kn(),i=$r(),r=Function.prototype,a=n&&Object.getOwnPropertyDescriptor,s=i(r,"name"),o=s&&"something"===function(){}.name,l=s&&(!n||n&&a(r,"name").configurable);t.exports={EXISTS:s,PROPER:o,CONFIGURABLE:l}})),jT=J(((e,t)=>{var n=en(),i=Fr(),r=qT(),a=n(Function.toString);i(r.inspectSource)||(r.inspectSource=function(e){return a(e)}),t.exports=r.inspectSource})),O3=J(((e,t)=>{var n=Mn(),i=Fr(),r=n.WeakMap;t.exports=i(r)&&/native code/.test(String(r))})),x1=J(((e,t)=>{var n=_p(),i=Tp(),r=n("keys");t.exports=function(e){return r[e]||(r[e]=i(e))}})),Ag=J(((e,t)=>{t.exports={}})),Ts=J(((e,t)=>{var n,i,r,a,s,o=O3(),l=Mn(),h=Nr(),c=da(),u=$r(),d=qT(),p=x1(),f=Ag(),m="Object already initialized",g=l.TypeError,v=l.WeakMap;o||d.state?((a=d.state||(d.state=new v)).get=a.get,a.has=a.has,a.set=a.set,n=function(e,t){if(a.has(e))throw g(m);return t.facade=e,a.set(e,t),t},i=function(e){return a.get(e)||{}},r=function(e){return a.has(e)}):(f[s=p("state")]=!0,n=function(e,t){if(u(e,s))throw g(m);return t.facade=e,c(e,s,t),t},i=function(e){return u(e,s)?e[s]:{}},r=function(e){return u(e,s)}),t.exports={set:n,get:i,has:r,enforce:function(e){return r(e)?i(e):n(e,{})},getterFor:function(e){return function(t){var n;if(!h(t)||(n=i(t)).type!==e)throw g("Incompatible receiver, "+e+" required");return n}}}})),KT=J(((e,t)=>{var n=en(),i=Yt(),r=Fr(),a=$r(),s=Kn(),o=wp().CONFIGURABLE,l=jT(),h=Ts(),c=h.enforce,u=h.get,d=String,p=Object.defineProperty,f=n("".slice),m=n("".replace),g=n([].join),v=s&&!i((function(){return 8!==p((function(){}),"length",{value:8}).length})),y=String(String).split("String"),x=t.exports=function(e,t,n){"Symbol("===f(d(t),0,7)&&(t="["+m(d(t),/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(t="get "+t),n&&n.setter&&(t="set "+t),(!a(e,"name")||o&&e.name!==t)&&(s?p(e,"name",{value:t,configurable:!0}):e.name=t),v&&n&&a(n,"arity")&&e.length!==n.arity&&p(e,"length",{value:n.arity});try{n&&a(n,"constructor")&&n.constructor?s&&p(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var i=c(e);return a(i,"source")||(i.source=g(y,"string"==typeof t?t:"")),e};Function.prototype.toString=x((function(){return r(this)&&u(this).source||l(this)}),"toString")})),Yi=J(((e,t)=>{var n=Fr(),i=Gi(),r=KT(),a=GT();t.exports=function(e,t,s,o){o||(o={});var l=o.enumerable,h=void 0!==o.name?o.name:t;if(n(s)&&r(s,h,o),o.global)l?e[t]=s:a(t,s);else{try{o.unsafe?e[t]&&(l=!0):delete e[t]}catch(e){}l?e[t]=s:i.f(e,t,{value:s,enumerable:!1,configurable:!o.nonConfigurable,writable:!o.nonWritable})}return e}})),H3=J(((e,t)=>{var n=Math.ceil,i=Math.floor;t.exports=Math.trunc||function(e){var t=+e;return(t>0?i:n)(t)}})),os=J(((e,t)=>{var n=H3();t.exports=function(e){var t=+e;return t!=t||0===t?0:n(t)}})),lc=J(((e,t)=>{var n=os(),i=Math.max,r=Math.min;t.exports=function(e,t){var a=n(e);return a<0?i(a+t,0):r(a,t)}})),to=J(((e,t)=>{var n=os(),i=Math.min;t.exports=function(e){return e>0?i(n(e),9007199254740991):0}})),fi=J(((e,t)=>{var n=to();t.exports=function(e){return n(e.length)}})),Cg=J(((e,t)=>{var n=Ls(),i=lc(),r=fi(),a=function(e){return function(t,a,s){var o,l=n(t),h=r(l),c=i(s,h);if(e&&a!=a){for(;h>c;)if((o=l[c++])!=o)return!0}else for(;h>c;c++)if((e||c in l)&&l[c]===a)return e||c||0;return!e&&-1}};t.exports={includes:a(!0),indexOf:a(!1)}})),z3=J(((e,t)=>{var n=en(),i=$r(),r=Ls(),a=Cg().indexOf,s=Ag(),o=n([].push);t.exports=function(e,t){var n,l=r(e),h=0,c=[];for(n in l)!i(s,n)&&i(l,n)&&o(c,n);for(;t.length>h;)i(l,n=t[h++])&&(~a(c,n)||o(c,n));return c}})),JT=J(((e,t)=>{t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]})),yh=J((e=>{var t=z3(),n=JT().concat("length","prototype");e.f=Object.getOwnPropertyNames||function(e){return t(e,n)}})),E1=J((e=>{e.f=Object.getOwnPropertySymbols})),QT=J(((e,t)=>{var n=ki(),i=en(),r=yh(),a=E1(),s=br(),o=i([].concat);t.exports=n("Reflect","ownKeys")||function(e){var t=r.f(s(e)),n=a.f;return n?o(t,n(e)):t}})),_1=J(((e,t)=>{var n=$r(),i=QT(),r=Qs(),a=Gi();t.exports=function(e,t,s){for(var o=i(t),l=a.f,h=r.f,c=0;c{var n=Yt(),i=Fr(),r=/#|\.prototype\./,a=function(e,t){var r=o[s(e)];return r==h||r!=l&&(i(t)?n(t):!!t)},s=a.normalize=function(e){return String(e).replace(r,".").toLowerCase()},o=a.data={},l=a.NATIVE="N",h=a.POLYFILL="P";t.exports=a})),tt=J(((e,t)=>{var n=Mn(),i=Qs().f,r=da(),a=Yi(),s=GT(),o=_1(),l=Pg();t.exports=function(e,t){var h,c,u,d,p,f=e.target,m=e.global,g=e.stat;if(h=m?n:g?n[f]||s(f,{}):(n[f]||{}).prototype)for(c in t){if(d=t[c],u=e.dontCallGetSet?(p=i(h,c))&&p.value:h[c],!l(m?c:f+(g?".":"#")+c,e.forced)&&void 0!==u){if(typeof d==typeof u)continue;o(d,u)}(e.sham||u&&u.sham)&&r(d,"sham",!0),a(h,c,d,e)}}})),ew=J(((e,t)=>{var n={};n[Br()("toStringTag")]="z",t.exports="[object z]"===String(n)})),cc=J(((e,t)=>{var n=ew(),i=Fr(),r=ha(),a=Br()("toStringTag"),s=Object,o="Arguments"==r(function(){return arguments}());t.exports=n?r:function(e){var t,n,l;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=s(e),a))?n:o?r(t):"Object"==(l=r(t))&&i(t.callee)?"Arguments":l}})),Mr=J(((e,t)=>{var n=cc(),i=String;t.exports=function(e){if("Symbol"===n(e))throw TypeError("Cannot convert a Symbol value to a string");return i(e)}})),Ig=J(((e,t)=>{var n=z3(),i=JT();t.exports=Object.keys||function(e){return n(e,i)}})),nw=J((e=>{var t=Kn(),n=M3(),i=Gi(),r=br(),a=Ls(),s=Ig();e.f=t&&!n?Object.defineProperties:function(e,t){r(e);for(var n,o=a(t),l=s(t),h=l.length,c=0;h>c;)i.f(e,n=l[c++],o[n]);return e}})),q3=J(((e,t)=>{var n=ki();t.exports=n("document","documentElement")})),no=J(((e,t)=>{var n,i=br(),r=nw(),a=JT(),s=Ag(),o=q3(),l=y1(),h=x1(),c="prototype",u="script",d=h("IE_PROTO"),p=function(){},f=function(e){return"<"+u+">"+e+""},m=function(e){e.write(f("")),e.close();var t=e.parentWindow.Object;return e=null,t},g=function(){try{n=new ActiveXObject("htmlfile")}catch(e){}g="undefined"!=typeof document?document.domain&&n?m(n):function(){var e,t=l("iframe"),n="java"+u+":";return t.style.display="none",o.appendChild(t),t.src=String(n),(e=t.contentWindow.document).open(),e.write(f("document.F=Object")),e.close(),e.F}():m(n);for(var e=a.length;e--;)delete g[c][a[e]];return g()};s[d]=!0,t.exports=Object.create||function(e,t){var n;return null!==e?(p[c]=i(e),n=new p,p[c]=null,n[d]=e):n=g(),void 0===t?n:r.f(n,t)}})),ou=J(((e,t)=>{"use strict";var n=vh(),i=Gi(),r=ko();t.exports=function(e,t,a){var s=n(t);s in e?i.f(e,s,r(0,a)):e[s]=a}})),Lg=J(((e,t)=>{var n=lc(),i=fi(),r=ou(),a=Array,s=Math.max;t.exports=function(e,t,o){for(var l=i(e),h=n(t,l),c=n(void 0===o?l:o,l),u=a(s(c-h,0)),d=0;h{var n=ha(),i=Ls(),r=yh().f,a=Lg(),s="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];t.exports.f=function(e){return s&&"Window"==n(e)?function(e){try{return r(e)}catch(e){return a(s)}}(e):r(i(e))}})),Hs=J(((e,t)=>{var n=KT(),i=Gi();t.exports=function(e,t,r){return r.get&&n(r.get,t,{getter:!0}),r.set&&n(r.set,t,{setter:!0}),i.f(e,t,r)}})),Y3=J((e=>{var t=Br();e.f=t})),aw=J(((e,t)=>{var n=Mn();t.exports=n})),Da=J(((e,t)=>{var n=aw(),i=$r(),r=Y3(),a=Gi().f;t.exports=function(e){var t=n.Symbol||(n.Symbol={});i(t,e)||a(t,e,{value:r.f(e)})}})),$3=J(((e,t)=>{var n=wr(),i=ki(),r=Br(),a=Yi();t.exports=function(){var e=i("Symbol"),t=e&&e.prototype,s=t&&t.valueOf,o=r("toPrimitive");t&&!t[o]&&a(t,o,(function(e){return n(s,this)}),{arity:1})}})),ro=J(((e,t)=>{var n=Gi().f,i=$r(),r=Br()("toStringTag");t.exports=function(e,t,a){e&&!a&&(e=e.prototype),e&&!i(e,r)&&n(e,r,{configurable:!0,value:t})}})),xh=J(((e,t)=>{var n=ha(),i=en();t.exports=function(e){if("Function"===n(e))return i(e)}})),fl=J(((e,t)=>{var n=xh(),i=ss(),r=Mg(),a=n(n.bind);t.exports=function(e,t){return i(e),void 0===t?e:r?a(e,t):function(){return e.apply(t,arguments)}}})),bh=J(((e,t)=>{var n=ha();t.exports=Array.isArray||function(e){return"Array"==n(e)}})),Mp=J(((e,t)=>{var n=en(),i=Yt(),r=Fr(),a=cc(),s=ki(),o=jT(),l=function(){},h=[],c=s("Reflect","construct"),u=/^\s*(?:class|function)\b/,d=n(u.exec),p=!u.exec(l),f=function(e){if(!r(e))return!1;try{return c(l,h,e),!0}catch(e){return!1}},m=function(e){if(!r(e))return!1;switch(a(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return p||!!d(u,o(e))}catch(e){return!0}};m.sham=!0,t.exports=!c||i((function(){var e;return f(f.call)||!f(Object)||!f((function(){e=!0}))||e}))?m:f})),l9=J(((e,t)=>{var n=bh(),i=Mp(),r=Nr(),a=Br()("species"),s=Array;t.exports=function(e){var t;return n(e)&&(t=e.constructor,(i(t)&&(t===s||n(t.prototype))||r(t)&&null===(t=t[a]))&&(t=void 0)),void 0===t?s:t}})),Dg=J(((e,t)=>{var n=l9();t.exports=function(e,t){return new(n(e))(0===t?0:t)}})),Vs=J(((e,t)=>{var n=fl(),i=en(),r=bp(),a=ci(),s=fi(),o=Dg(),l=i([].push),h=function(e){var t=1==e,i=2==e,h=3==e,c=4==e,u=6==e,d=7==e,p=5==e||u;return function(f,m,g,v){for(var y,x,b=a(f),_=r(b),w=n(m,g),S=s(_),M=0,T=v||o,E=t?T(f,S):i||d?T(f,0):void 0;S>M;M++)if((p||M in _)&&(x=w(y=_[M],M,b),e))if(t)E[M]=x;else if(x)switch(e){case 3:return!0;case 5:return y;case 6:return M;case 2:l(E,y)}else switch(e){case 4:return!1;case 7:l(E,y)}return u?-1:h||c?c:E}};t.exports={forEach:h(0),map:h(1),filter:h(2),some:h(3),every:h(4),find:h(5),findIndex:h(6),filterReject:h(7)}})),R9=J((()=>{"use strict";var e=tt(),t=Mn(),n=wr(),i=en(),r=as(),a=Kn(),s=Ep(),o=Yt(),l=$r(),h=Fo(),c=br(),u=Ls(),d=vh(),p=Mr(),f=ko(),m=no(),g=Ig(),v=yh(),y=sw(),x=E1(),b=Qs(),_=Gi(),w=nw(),S=g1(),M=Yi(),T=Hs(),E=_p(),A=x1(),C=Ag(),P=Tp(),R=Br(),O=Y3(),L=Da(),I=$3(),D=ro(),k=Ts(),N=Vs().forEach,F=A("hidden"),U="Symbol",B="prototype",z=k.set,H=k.getterFor(U),V=Object[B],j=t.Symbol,G=j&&j[B],W=t.TypeError,X=t.QObject,Y=b.f,q=_.f,J=y.f,Z=S.f,K=i([].push),$=E("symbols"),Q=E("op-symbols"),ee=E("wks"),te=!X||!X[B]||!X[B].findChild,ne=a&&o((function(){return 7!=m(q({},"a",{get:function(){return q(this,"a",{value:7}).a}})).a}))?function(e,t,n){var i=Y(V,t);i&&delete V[t],q(e,t,n),i&&e!==V&&q(V,t,i)}:q,ie=function(e,t){var n=$[e]=m(G);return z(n,{type:U,tag:e,description:t}),a||(n.description=t),n},re=function(e,t,n){e===V&&re(Q,t,n),c(e);var i=d(t);return c(n),l($,i)?(n.enumerable?(l(e,F)&&e[F][i]&&(e[F][i]=!1),n=m(n,{enumerable:f(0,!1)})):(l(e,F)||q(e,F,f(1,{})),e[F][i]=!0),ne(e,i,n)):q(e,i,n)},ae=function(e,t){c(e);var i=u(t),r=g(i).concat(he(i));return N(r,(function(t){(!a||n(se,i,t))&&re(e,t,i[t])})),e},se=function(e){var t=d(e),i=n(Z,this,t);return!(this===V&&l($,t)&&!l(Q,t))&&(!(i||!l(this,t)||!l($,t)||l(this,F)&&this[F][t])||i)},oe=function(e,t){var n=u(e),i=d(t);if(n!==V||!l($,i)||l(Q,i)){var r=Y(n,i);return r&&l($,i)&&!(l(n,F)&&n[F][i])&&(r.enumerable=!0),r}},le=function(e){var t=J(u(e)),n=[];return N(t,(function(e){!l($,e)&&!l(C,e)&&K(n,e)})),n},he=function(e){var t=e===V,n=J(t?Q:u(e)),i=[];return N(n,(function(e){l($,e)&&(!t||l(V,e))&&K(i,$[e])})),i};s||(M(G=(j=function(){if(h(G,this))throw W("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?p(arguments[0]):void 0,t=P(e),i=function(e){this===V&&n(i,Q,e),l(this,F)&&l(this[F],t)&&(this[F][t]=!1),ne(this,t,f(1,e))};return a&&te&&ne(V,t,{configurable:!0,set:i}),ie(t,e)})[B],"toString",(function(){return H(this).tag})),M(j,"withoutSetter",(function(e){return ie(P(e),e)})),S.f=se,_.f=re,w.f=ae,b.f=oe,v.f=y.f=le,x.f=he,O.f=function(e){return ie(R(e),e)},a&&(T(G,"description",{configurable:!0,get:function(){return H(this).description}}),r||M(V,"propertyIsEnumerable",se,{unsafe:!0}))),e({global:!0,constructor:!0,wrap:!0,forced:!s,sham:!s},{Symbol:j}),N(g(ee),(function(e){L(e)})),e({target:U,stat:!0,forced:!s},{useSetter:function(){te=!0},useSimple:function(){te=!1}}),e({target:"Object",stat:!0,forced:!s,sham:!a},{create:function(e,t){return void 0===t?m(e):ae(m(e),t)},defineProperty:re,defineProperties:ae,getOwnPropertyDescriptor:oe}),e({target:"Object",stat:!0,forced:!s},{getOwnPropertyNames:le}),I(),D(j,U),C[F]=!0})),uL=J(((e,t)=>{var n=Ep();t.exports=n&&!!Symbol.for&&!!Symbol.keyFor})),P9=J((()=>{var e=tt(),t=ki(),n=$r(),i=Mr(),r=_p(),a=uL(),s=r("string-to-symbol-registry"),o=r("symbol-to-string-registry");e({target:"Symbol",stat:!0,forced:!a},{for:function(e){var r=i(e);if(n(s,r))return s[r];var a=t("Symbol")(r);return s[r]=a,o[a]=r,a}})})),L9=J((()=>{var e=tt(),t=$r(),n=Od(),i=kd(),r=_p(),a=uL(),s=r("symbol-to-string-registry");e({target:"Symbol",stat:!0,forced:!a},{keyFor:function(e){if(!n(e))throw TypeError(i(e)+" is not a symbol");if(t(s,e))return s[e]}})})),No=J(((e,t)=>{var n=Mg(),i=Function.prototype,r=i.apply,a=i.call;t.exports="object"==typeof Reflect&&Reflect.apply||(n?a.bind(r):function(){return a.apply(r,arguments)})})),Nd=J(((e,t)=>{var n=en();t.exports=n([].slice)})),z9=J(((e,t)=>{var n=en(),i=bh(),r=Fr(),a=ha(),s=Mr(),o=n([].push);t.exports=function(e){if(r(e))return e;if(i(e)){for(var t=e.length,n=[],l=0;l{var e=tt(),t=ki(),n=No(),i=wr(),r=en(),a=Yt(),s=Fr(),o=Od(),l=Nd(),h=z9(),c=Ep(),u=String,d=t("JSON","stringify"),p=r(/./.exec),f=r("".charAt),m=r("".charCodeAt),g=r("".replace),v=r(1..toString),y=/[\uD800-\uDFFF]/g,x=/^[\uD800-\uDBFF]$/,b=/^[\uDC00-\uDFFF]$/,_=!c||a((function(){var e=t("Symbol")();return"[null]"!=d([e])||"{}"!=d({a:e})||"{}"!=d(Object(e))})),w=a((function(){return'"\\udf06\\ud834"'!==d("\udf06\ud834")||'"\\udead"'!==d("\udead")})),S=function(e,t){var r=l(arguments),a=h(t);if(s(a)||void 0!==e&&!o(e))return r[1]=function(e,t){if(s(a)&&(t=i(a,this,u(e),t)),!o(t))return t},n(d,null,r)},M=function(e,t,n){var i=f(n,t-1),r=f(n,t+1);return p(x,e)&&!p(b,r)||p(b,e)&&!p(x,i)?"\\u"+v(m(e,0),16):e};d&&e({target:"JSON",stat:!0,arity:3,forced:_||w},{stringify:function(e,t,i){var r=l(arguments),a=n(_?S:d,null,r);return w&&"string"==typeof a?g(a,y,M):a}})})),tW=J((()=>{var e=tt(),t=Ep(),n=Yt(),i=E1(),r=ci();e({target:"Object",stat:!0,forced:!t||n((function(){i.f(1)}))},{getOwnPropertySymbols:function(e){var t=i.f;return t?t(r(e)):[]}})})),nW=J((()=>{R9(),P9(),L9(),dL(),tW()})),cW=J((()=>{"use strict";var e,t,n,i,r,a,s,o,l=tt(),h=Kn(),c=Mn(),u=en(),d=$r(),p=Fr(),f=Fo(),m=Mr(),g=Hs(),v=_1(),y=c.Symbol,x=y&&y.prototype;h&&p(y)&&(!("description"in x)||void 0!==y().description)&&(e={},v(t=function(){var t=arguments.length<1||void 0===arguments[0]?void 0:m(arguments[0]),n=f(x,this)?new y(t):void 0===t?y():y(t);return""===t&&(e[n]=!0),n},y),t.prototype=x,x.constructor=t,n="Symbol(test)"==String(y("test")),i=u(x.valueOf),r=u(x.toString),a=/^Symbol\((.*)\)[^)]+$/,s=u("".replace),o=u("".slice),g(x,"description",{configurable:!0,get:function(){var t=i(this);if(d(e,t))return"";var l=r(t),h=n?o(l,7,-1):s(l,a,"$1");return""===h?void 0:h}}),l({global:!0,constructor:!0,forced:!0},{Symbol:t}))})),uW=J((()=>{Da()("asyncIterator")})),hW=J((()=>{Da()("hasInstance")})),dW=J((()=>{Da()("isConcatSpreadable")})),fW=J((()=>{Da()("iterator")})),pW=J((()=>{Da()("match")})),mW=J((()=>{Da()("matchAll")})),gW=J((()=>{Da()("replace")})),vW=J((()=>{Da()("search")})),yW=J((()=>{Da()("species")})),xW=J((()=>{Da()("split")})),bW=J((()=>{var e=Da(),t=$3();e("toPrimitive"),t()})),EW=J((()=>{var e=ki(),t=Da(),n=ro();t("toStringTag"),n(e("Symbol"),"Symbol")})),_W=J((()=>{Da()("unscopables")})),wW=J(((e,t)=>{var n=en(),i=ss();t.exports=function(e,t,r){try{return n(i(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(e){}}})),pL=J(((e,t)=>{var n=Fr(),i=String,r=TypeError;t.exports=function(e){if("object"==typeof e||n(e))return e;throw r("Can't set "+i(e)+" as a prototype")}})),uc=J(((e,t)=>{var n=wW(),i=br(),r=pL();t.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,a={};try{(e=n(Object.prototype,"__proto__","set"))(a,[]),t=a instanceof Array}catch(e){}return function(n,a){return i(n),r(a),t?e(n,a):n.__proto__=a,n}}():void 0)})),mL=J(((e,t)=>{var n=Gi().f;t.exports=function(e,t,i){i in e||n(e,i,{configurable:!0,get:function(){return t[i]},set:function(e){t[i]=e}})}})),Pp=J(((e,t)=>{var n=Fr(),i=Nr(),r=uc();t.exports=function(e,t,a){var s,o;return r&&n(s=t.constructor)&&s!==a&&i(o=s.prototype)&&o!==a.prototype&&r(e,o),e}})),Fg=J(((e,t)=>{var n=Mr();t.exports=function(e,t){return void 0===e?arguments.length<2?"":t:n(e)}})),gL=J(((e,t)=>{var n=Nr(),i=da();t.exports=function(e,t){n(t)&&"cause"in t&&i(e,"cause",t.cause)}})),pw=J(((e,t)=>{var n=en(),i=Error,r=n("".replace),a=String(i("zxcasd").stack),s=/\n\s*at [^:]*:[^\n]*/,o=s.test(a);t.exports=function(e,t){if(o&&"string"==typeof e&&!i.prepareStackTrace)for(;t--;)e=r(e,s,"");return e}})),vL=J(((e,t)=>{var n=Yt(),i=ko();t.exports=!n((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",i(1,7)),7!==e.stack)}))})),yL=J(((e,t)=>{var n=da(),i=pw(),r=vL(),a=Error.captureStackTrace;t.exports=function(e,t,s,o){r&&(a?a(e,t):n(e,"stack",i(s,o)))}})),xL=J(((e,t)=>{"use strict";var n=ki(),i=$r(),r=da(),a=Fo(),s=uc(),o=_1(),l=mL(),h=Pp(),c=Fg(),u=gL(),d=yL(),p=Kn(),f=as();t.exports=function(e,t,m,g){var v="stackTraceLimit",y=g?2:1,x=e.split("."),b=x[x.length-1],_=n.apply(null,x);if(_){var w=_.prototype;if(!f&&i(w,"cause")&&delete w.cause,!m)return _;var S=n("Error"),M=t((function(e,t){var n=c(g?t:e,void 0),i=g?new _(e):new _;return void 0!==n&&r(i,"message",n),d(i,M,i.stack,2),this&&a(w,this)&&h(i,this,M),arguments.length>y&&u(i,arguments[y]),i}));if(M.prototype=w,"Error"!==b?s?s(M,S):o(M,S,{name:!0}):p&&v in _&&(l(M,_,v),l(M,_,"prepareStackTrace")),o(M,_),!f)try{w.name!==b&&r(w,"name",b),w.constructor=M}catch(e){}return M}}})),YW=J((()=>{var e=tt(),t=Mn(),n=No(),i=xL(),r="WebAssembly",a=t[r],s=7!==Error("e",{cause:7}).cause,o=function(t,n){var r={};r[t]=i(t,n,s),e({global:!0,constructor:!0,arity:1,forced:s},r)},l=function(t,n){if(a&&a[t]){var o={};o[t]=i(r+"."+t,n,s),e({target:r,stat:!0,constructor:!0,arity:1,forced:s},o)}};o("Error",(function(e){return function(t){return n(e,this,arguments)}})),o("EvalError",(function(e){return function(t){return n(e,this,arguments)}})),o("RangeError",(function(e){return function(t){return n(e,this,arguments)}})),o("ReferenceError",(function(e){return function(t){return n(e,this,arguments)}})),o("SyntaxError",(function(e){return function(t){return n(e,this,arguments)}})),o("TypeError",(function(e){return function(t){return n(e,this,arguments)}})),o("URIError",(function(e){return function(t){return n(e,this,arguments)}})),l("CompileError",(function(e){return function(t){return n(e,this,arguments)}})),l("LinkError",(function(e){return function(t){return n(e,this,arguments)}})),l("RuntimeError",(function(e){return function(t){return n(e,this,arguments)}}))})),_L=J(((e,t)=>{"use strict";var n=Kn(),i=Yt(),r=br(),a=no(),s=Fg(),o=Error.prototype.toString,l=i((function(){if(n){var e=a(Object.defineProperty({},"name",{get:function(){return this===e}}));if("true"!==o.call(e))return!0}return"2: 1"!==o.call({message:1,name:2})||"Error"!==o.call({})}));t.exports=l?function(){var e=r(this),t=s(e.name,"Error"),n=s(e.message);return t?n?t+": "+n:t:n}:o})),QW=J((()=>{var e=Yi(),t=_L(),n=Error.prototype;n.toString!==t&&e(n,"toString",t)})),vw=J(((e,t)=>{var n=Yt();t.exports=!n((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}))})),Bo=J(((e,t)=>{var n=$r(),i=Fr(),r=ci(),a=x1(),s=vw(),o=a("IE_PROTO"),l=Object,h=l.prototype;t.exports=s?l.getPrototypeOf:function(e){var t=r(e);if(n(t,o))return t[o];var a=t.constructor;return i(a)&&t instanceof a?a.prototype:t instanceof l?h:null}})),Ng=J(((e,t)=>{t.exports={}})),yw=J(((e,t)=>{var n=Br(),i=Ng(),r=n("iterator"),a=Array.prototype;t.exports=function(e){return void 0!==e&&(i.Array===e||a[r]===e)}})),Bg=J(((e,t)=>{var n=cc(),i=au(),r=La(),a=Ng(),s=Br()("iterator");t.exports=function(e){if(!r(e))return i(e,s)||i(e,"@@iterator")||a[n(e)]}})),I1=J(((e,t)=>{var n=wr(),i=ss(),r=br(),a=kd(),s=Bg(),o=TypeError;t.exports=function(e,t){var l=arguments.length<2?s(e):t;if(i(l))return r(n(l,e));throw o(a(e)+" is not iterable")}})),wL=J(((e,t)=>{var n=wr(),i=br(),r=au();t.exports=function(e,t,a){var s,o;i(e);try{if(!(s=r(e,"return"))){if("throw"===t)throw a;return a}s=n(s,e)}catch(e){o=!0,s=e}if("throw"===t)throw a;if(o)throw s;return i(s),a}})),hc=J(((e,t)=>{var n=fl(),i=wr(),r=br(),a=kd(),s=yw(),o=fi(),l=Fo(),h=I1(),c=Bg(),u=wL(),d=TypeError,p=function(e,t){this.stopped=e,this.result=t},f=p.prototype;t.exports=function(e,t,m){var g,v,y,x,b,_,w,S=m&&m.that,M=!(!m||!m.AS_ENTRIES),T=!(!m||!m.IS_RECORD),E=!(!m||!m.IS_ITERATOR),A=!(!m||!m.INTERRUPTED),C=n(t,S),P=function(e){return g&&u(g,"normal",e),new p(!0,e)},R=function(e){return M?(r(e),A?C(e[0],e[1],P):C(e[0],e[1])):A?C(e,P):C(e)};if(T)g=e.iterator;else if(E)g=e;else{if(!(v=c(e)))throw d(a(e)+" is not iterable");if(s(v)){for(y=0,x=o(e);x>y;y++)if((b=R(e[y]))&&l(f,b))return b;return new p(!1)}g=h(e,v)}for(_=T?e.next:g.next;!(w=i(_,g)).done;){try{b=R(w.value)}catch(e){u(g,"throw",e)}if("object"==typeof b&&b&&l(f,b))return b}return new p(!1)}})),mj=J((()=>{"use strict";var e=tt(),t=Fo(),n=Bo(),i=uc(),r=_1(),a=no(),s=da(),o=ko(),l=gL(),h=yL(),c=hc(),u=Fg(),d=Br()("toStringTag"),p=Error,f=[].push,m=function(e,r){var o,v=t(g,this);i?o=i(p(),v?n(this):g):(o=v?this:a(g),s(o,d,"Error")),void 0!==r&&s(o,"message",u(r)),h(o,m,o.stack,1),arguments.length>2&&l(o,arguments[2]);var y=[];return c(e,f,{that:y}),s(o,"errors",y),o};i?i(m,p):r(m,p,{name:!0});var g=m.prototype=a(p.prototype,{constructor:o(1,m),message:o(1,""),name:o(1,"AggregateError")});e({global:!0,constructor:!0,arity:2},{AggregateError:m})})),gj=J((()=>{mj()})),bj=J((()=>{var e=tt(),t=ki(),n=No(),i=Yt(),r=xL(),a="AggregateError",s=t(a),o=!i((function(){return 1!==s([1]).errors[0]}))&&i((function(){return 7!==s([1],a,{cause:7}).cause}));e({global:!0,constructor:!0,arity:2,forced:o},{AggregateError:r(a,(function(e){return function(t,i){return n(e,this,arguments)}}),o,!0)})})),Oa=J(((e,t)=>{var n=Br(),i=no(),r=Gi().f,a=n("unscopables"),s=Array.prototype;null==s[a]&&r(s,a,{configurable:!0,value:i(null)}),t.exports=function(e){s[a][e]=!0}})),_j=J((()=>{"use strict";var e=tt(),t=ci(),n=fi(),i=os(),r=Oa();e({target:"Array",proto:!0},{at:function(e){var r=t(this),a=n(r),s=i(e),o=s>=0?s:a+s;return o<0||o>=a?void 0:r[o]}}),r("at")})),Lp=J(((e,t)=>{var n=TypeError;t.exports=function(e){if(e>9007199254740991)throw n("Maximum allowed index exceeded");return e}})),Hg=J(((e,t)=>{var n=Yt(),i=Br(),r=su(),a=i("species");t.exports=function(e){return r>=51||!n((function(){var t=[];return(t.constructor={})[a]=function(){return{foo:1}},1!==t[e](Boolean).foo}))}})),Aj=J((()=>{"use strict";var e=tt(),t=Yt(),n=bh(),i=Nr(),r=ci(),a=fi(),s=Lp(),o=ou(),l=Dg(),h=Hg(),c=Br(),u=su(),d=c("isConcatSpreadable"),p=u>=51||!t((function(){var e=[];return e[d]=!1,e.concat()[0]!==e})),f=function(e){if(!i(e))return!1;var t=e[d];return void 0!==t?!!t:n(e)};e({target:"Array",proto:!0,arity:1,forced:!p||!h("concat")},{concat:function(e){var t,n,i,h,c,u=r(this),d=l(u,0),p=0;for(t=-1,i=arguments.length;t{"use strict";var n=kd(),i=TypeError;t.exports=function(e,t){if(!delete e[t])throw i("Cannot delete property "+n(t)+" of "+n(e))}})),LL=J(((e,t)=>{"use strict";var n=ci(),i=lc(),r=fi(),a=L1(),s=Math.min;t.exports=[].copyWithin||function(e,t){var o=n(this),l=r(o),h=i(e,l),c=i(t,l),u=arguments.length>2?arguments[2]:void 0,d=s((void 0===u?l:i(u,l))-c,l-h),p=1;for(c0;)c in o?o[h]=o[c]:a(o,h),h+=p,c+=p;return o}})),Lj=J((()=>{var e=tt(),t=LL(),n=Oa();e({target:"Array",proto:!0},{copyWithin:t}),n("copyWithin")})),cu=J(((e,t)=>{"use strict";var n=Yt();t.exports=function(e,t){var i=[][e];return!!i&&n((function(){i.call(null,t||function(){return 1},1)}))}})),Oj=J((()=>{"use strict";var e=tt(),t=Vs().every;e({target:"Array",proto:!0,forced:!cu()("every")},{every:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),_w=J(((e,t)=>{"use strict";var n=ci(),i=lc(),r=fi();t.exports=function(e){for(var t=n(this),a=r(t),s=arguments.length,o=i(s>1?arguments[1]:void 0,a),l=s>2?arguments[2]:void 0,h=void 0===l?a:i(l,a);h>o;)t[o++]=e;return t}})),Nj=J((()=>{var e=tt(),t=_w(),n=Oa();e({target:"Array",proto:!0},{fill:t}),n("fill")})),Bj=J((()=>{"use strict";var e=tt(),t=Vs().filter;e({target:"Array",proto:!0,forced:!Hg()("filter")},{filter:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),Hj=J((()=>{"use strict";var e=tt(),t=Vs().find,n=Oa(),i="find",r=!0;i in[]&&Array(1)[i]((function(){r=!1})),e({target:"Array",proto:!0,forced:r},{find:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),n(i)})),zj=J((()=>{"use strict";var e=tt(),t=Vs().findIndex,n=Oa(),i="findIndex",r=!0;i in[]&&Array(1)[i]((function(){r=!1})),e({target:"Array",proto:!0,forced:r},{findIndex:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),n(i)})),D1=J(((e,t)=>{var n=fl(),i=bp(),r=ci(),a=fi(),s=function(e){var t=1==e;return function(s,o,l){for(var h,c=r(s),u=i(c),d=n(o,l),p=a(u);p-- >0;)if(d(h=u[p],p,c))switch(e){case 0:return h;case 1:return p}return t?-1:void 0}};t.exports={findLast:s(0),findLastIndex:s(1)}})),Wj=J((()=>{"use strict";var e=tt(),t=D1().findLast,n=Oa();e({target:"Array",proto:!0},{findLast:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),n("findLast")})),jj=J((()=>{"use strict";var e=tt(),t=D1().findLastIndex,n=Oa();e({target:"Array",proto:!0},{findLastIndex:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),n("findLastIndex")})),kL=J(((e,t)=>{"use strict";var n=bh(),i=fi(),r=Lp(),a=fl(),s=function(e,t,o,l,h,c,u,d){for(var p,f,m=h,g=0,v=!!u&&a(u,d);g0&&n(p)?(f=i(p),m=s(e,t,p,f,m,c-1)-1):(r(m+1),e[m]=p),m++),g++;return m};t.exports=s})),$j=J((()=>{"use strict";var e=tt(),t=kL(),n=ci(),i=fi(),r=os(),a=Dg();e({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,s=n(this),o=i(s),l=a(s,0);return l.length=t(l,s,s,o,0,void 0===e?1:r(e)),l}})})),Zj=J((()=>{"use strict";var e=tt(),t=kL(),n=ss(),i=ci(),r=fi(),a=Dg();e({target:"Array",proto:!0},{flatMap:function(e){var s,o=i(this),l=r(o);return n(e),(s=a(o,0)).length=t(s,o,o,l,0,1,e,arguments.length>1?arguments[1]:void 0),s}})})),FL=J(((e,t)=>{"use strict";var n=Vs().forEach,i=cu()("forEach");t.exports=i?[].forEach:function(e){return n(this,e,arguments.length>1?arguments[1]:void 0)}})),Qj=J((()=>{"use strict";var e=tt(),t=FL();e({target:"Array",proto:!0,forced:[].forEach!=t},{forEach:t})})),tX=J(((e,t)=>{var n=br(),i=wL();t.exports=function(e,t,r,a){try{return a?t(n(r)[0],r[1]):t(r)}catch(t){i(e,"throw",t)}}})),NL=J(((e,t)=>{"use strict";var n=fl(),i=wr(),r=ci(),a=tX(),s=yw(),o=Mp(),l=fi(),h=ou(),c=I1(),u=Bg(),d=Array;t.exports=function(e){var t=r(e),p=o(this),f=arguments.length,m=f>1?arguments[1]:void 0,g=void 0!==m;g&&(m=n(m,f>2?arguments[2]:void 0));var v,y,x,b,_,w,S=u(t),M=0;if(!S||this===d&&s(S))for(v=l(t),y=p?new this(v):d(v);v>M;M++)w=g?m(t[M],M):t[M],h(y,M,w);else for(_=(b=c(t,S)).next,y=p?new this:[];!(x=i(_,b)).done;M++)w=g?a(b,m,[x.value,M],!0):x.value,h(y,M,w);return y.length=M,y}})),O1=J(((e,t)=>{var n,i,r=Br()("iterator"),a=!1;try{n=0,(i={next:function(){return{done:!!n++}},return:function(){a=!0}})[r]=function(){return this},Array.from(i,(function(){throw 2}))}catch(e){}t.exports=function(e,t){if(!t&&!a)return!1;var n=!1;try{var i={};i[r]=function(){return{next:function(){return{done:n=!0}}}},e(i)}catch(e){}return n}})),cX=J((()=>{var e=tt(),t=NL();e({target:"Array",stat:!0,forced:!O1()((function(e){Array.from(e)}))},{from:t})})),uX=J((()=>{"use strict";var e=tt(),t=Cg().includes,n=Yt(),i=Oa();e({target:"Array",proto:!0,forced:n((function(){return!Array(1).includes()}))},{includes:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}}),i("includes")})),dX=J((()=>{"use strict";var e=tt(),t=xh(),n=Cg().indexOf,i=cu(),r=t([].indexOf),a=!!r&&1/r([1],1,-0)<0;e({target:"Array",proto:!0,forced:a||!i("indexOf")},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return a?r(this,e,t)||0:n(this,e,t)}})})),fX=J((()=>{tt()({target:"Array",stat:!0},{isArray:bh()})})),GL=J(((e,t)=>{"use strict";var n,i,r,a=Yt(),s=Fr(),o=Nr(),l=no(),h=Bo(),c=Yi(),u=Br(),d=as(),p=u("iterator"),f=!1;[].keys&&("next"in(r=[].keys())?(i=h(h(r)))!==Object.prototype&&(n=i):f=!0),!o(n)||a((function(){var e={};return n[p].call(e)!==e}))?n={}:d&&(n=l(n)),s(n[p])||c(n,p,(function(){return this})),t.exports={IteratorPrototype:n,BUGGY_SAFARI_ITERATORS:f}})),Tw=J(((e,t)=>{"use strict";var n=GL().IteratorPrototype,i=no(),r=ko(),a=ro(),s=Ng(),o=function(){return this};t.exports=function(e,t,l,h){var c=t+" Iterator";return e.prototype=i(n,{next:r(+!h,l)}),a(e,c,!1,!0),s[c]=o,e}})),Mw=J(((e,t)=>{"use strict";var n=tt(),i=wr(),r=as(),a=wp(),s=Fr(),o=Tw(),l=Bo(),h=uc(),c=ro(),u=da(),d=Yi(),p=Br(),f=Ng(),m=GL(),g=a.PROPER,v=a.CONFIGURABLE,y=m.IteratorPrototype,x=m.BUGGY_SAFARI_ITERATORS,b=p("iterator"),_="keys",w="values",S="entries",M=function(){return this};t.exports=function(e,t,a,p,m,T,E){o(a,t,p);var A,C,P,R=function(e){if(e===m&&k)return k;if(!x&&e in I)return I[e];switch(e){case _:case w:case S:return function(){return new a(this,e)}}return function(){return new a(this)}},O=t+" Iterator",L=!1,I=e.prototype,D=I[b]||I["@@iterator"]||m&&I[m],k=!x&&D||R(m),N="Array"==t&&I.entries||D;if(N&&(A=l(N.call(new e)))!==Object.prototype&&A.next&&(!r&&l(A)!==y&&(h?h(A,y):s(A[b])||d(A,b,M)),c(A,O,!0,!0),r&&(f[O]=M)),g&&m==w&&D&&D.name!==w&&(!r&&v?u(I,"name",w):(L=!0,k=function(){return i(D,this)})),m)if(C={values:R(w),keys:T?k:R(_),entries:R(S)},E)for(P in C)(x||L||!(P in I))&&d(I,P,C[P]);else n({target:t,proto:!0,forced:x||L},C);return(!r||E)&&I[b]!==k&&d(I,b,k,{name:m}),f[t]=k,C}})),N1=J(((e,t)=>{t.exports=function(e,t){return{value:e,done:t}}})),B1=J(((e,t)=>{"use strict";var n=Ls(),i=Oa(),r=Ng(),a=Ts(),s=Gi().f,o=Mw(),l=N1(),h=as(),c=Kn(),u="Array Iterator",d=a.set,p=a.getterFor(u);t.exports=o(Array,"Array",(function(e,t){d(this,{type:u,target:n(e),index:0,kind:t})}),(function(){var e=p(this),t=e.target,n=e.kind,i=e.index++;return!t||i>=t.length?(e.target=void 0,l(void 0,!0)):l("keys"==n?i:"values"==n?t[i]:[i,t[i]],!1)}),"values");var f=r.Arguments=r.Array;if(i("keys"),i("values"),i("entries"),!h&&c&&"values"!==f.name)try{s(f,"name",{value:"values"})}catch(e){}})),OX=J((()=>{"use strict";var e=tt(),t=en(),n=bp(),i=Ls(),r=cu(),a=t([].join);e({target:"Array",proto:!0,forced:n!=Object||!r("join",",")},{join:function(e){return a(i(this),void 0===e?",":e)}})})),XL=J(((e,t)=>{"use strict";var n=No(),i=Ls(),r=os(),a=fi(),s=cu(),o=Math.min,l=[].lastIndexOf,h=!!l&&1/[1].lastIndexOf(1,-0)<0,c=s("lastIndexOf"),u=h||!c;t.exports=u?function(e){if(h)return n(l,this,arguments)||0;var t=i(this),s=a(t),c=s-1;for(arguments.length>1&&(c=o(c,r(arguments[1]))),c<0&&(c=s+c);c>=0;c--)if(c in t&&t[c]===e)return c||0;return-1}:l})),BX=J((()=>{var e=tt(),t=XL();e({target:"Array",proto:!0,forced:t!==[].lastIndexOf},{lastIndexOf:t})})),UX=J((()=>{"use strict";var e=tt(),t=Vs().map;e({target:"Array",proto:!0,forced:!Hg()("map")},{map:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),VX=J((()=>{"use strict";var e=tt(),t=Yt(),n=Mp(),i=ou(),r=Array;e({target:"Array",stat:!0,forced:t((function(){function e(){}return!(r.of.call(e)instanceof e)}))},{of:function(){for(var e=0,t=arguments.length,a=new(n(this)?this:r)(t);t>e;)i(a,e,arguments[e++]);return a.length=t,a}})})),Aw=J(((e,t)=>{"use strict";var n=Kn(),i=bh(),r=TypeError,a=Object.getOwnPropertyDescriptor,s=n&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}();t.exports=s?function(e,t){if(i(e)&&!a(e,"length").writable)throw r("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t}})),GX=J((()=>{"use strict";var e=tt(),t=ci(),n=fi(),i=Aw(),r=Lp();e({target:"Array",proto:!0,arity:1,forced:Yt()((function(){return 4294967297!==[].push.call({length:4294967296},1)}))||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(e){return e instanceof TypeError}}()},{push:function(e){var a=t(this),s=n(a),o=arguments.length;r(s+o);for(var l=0;l{var n=ss(),i=ci(),r=bp(),a=fi(),s=TypeError,o=function(e){return function(t,o,l,h){n(o);var c=i(t),u=r(c),d=a(c),p=e?d-1:0,f=e?-1:1;if(l<2)for(;;){if(p in u){h=u[p],p+=f;break}if(p+=f,e?p<0:d<=p)throw s("Reduce of empty array with no initial value")}for(;e?p>=0:d>p;p+=f)p in u&&(h=o(h,u[p],p,c));return h}};t.exports={left:o(!1),right:o(!0)}})),uu=J(((e,t)=>{var n=ha();t.exports="undefined"!=typeof process&&"process"==n(process)})),YX=J((()=>{"use strict";var e=tt(),t=U1().left,n=cu(),i=su();e({target:"Array",proto:!0,forced:!uu()&&i>79&&i<83||!n("reduce")},{reduce:function(e){var n=arguments.length;return t(this,e,n,n>1?arguments[1]:void 0)}})})),ZX=J((()=>{"use strict";var e=tt(),t=U1().right,n=cu(),i=su();e({target:"Array",proto:!0,forced:!uu()&&i>79&&i<83||!n("reduceRight")},{reduceRight:function(e){return t(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}})})),JX=J((()=>{"use strict";var e=tt(),t=en(),n=bh(),i=t([].reverse),r=[1,2];e({target:"Array",proto:!0,forced:String(r)===String(r.reverse())},{reverse:function(){return n(this)&&(this.length=this.length),i(this)}})})),tY=J((()=>{"use strict";var e=tt(),t=bh(),n=Mp(),i=Nr(),r=lc(),a=fi(),s=Ls(),o=ou(),l=Br(),h=Hg(),c=Nd(),u=h("slice"),d=l("species"),p=Array,f=Math.max;e({target:"Array",proto:!0,forced:!u},{slice:function(e,l){var h,u,m,g=s(this),v=a(g),y=r(e,v),x=r(void 0===l?v:l,v);if(t(g)&&(h=g.constructor,(n(h)&&(h===p||t(h.prototype))||i(h)&&null===(h=h[d]))&&(h=void 0),h===p||void 0===h))return c(g,y,x);for(u=new(void 0===h?p:h)(f(x-y,0)),m=0;y{"use strict";var e=tt(),t=Vs().some;e({target:"Array",proto:!0,forced:!cu()("some")},{some:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),Cw=J(((e,t)=>{var n=Lg(),i=Math.floor,r=function(e,t){var o=e.length,l=i(o/2);return o<8?a(e,t):s(e,r(n(e,0,l),t),r(n(e,l),t),t)},a=function(e,t){for(var n,i,r=e.length,a=1;a0;)e[i]=e[--i];i!==a++&&(e[i]=n)}return e},s=function(e,t,n,i){for(var r=t.length,a=n.length,s=0,o=0;s{var n=iu().match(/firefox\/(\d+)/i);t.exports=!!n&&+n[1]})),KL=J(((e,t)=>{var n=iu();t.exports=/MSIE|Trident/.test(n)})),Pw=J(((e,t)=>{var n=iu().match(/AppleWebKit\/(\d+)\./);t.exports=!!n&&+n[1]})),yY=J((()=>{"use strict";var e=tt(),t=en(),n=ss(),i=ci(),r=fi(),a=L1(),s=Mr(),o=Yt(),l=Cw(),h=cu(),c=ZL(),u=KL(),d=su(),p=Pw(),f=[],m=t(f.sort),g=t(f.push),v=o((function(){f.sort(void 0)})),y=o((function(){f.sort(null)})),x=h("sort"),b=!o((function(){if(d)return d<70;if(!(c&&c>3)){if(u)return!0;if(p)return p<603;var e,t,n,i,r="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(i=0;i<47;i++)f.push({k:t+i,v:n})}for(f.sort((function(e,t){return t.v-e.v})),i=0;is(n)?1:-1}}(e)),o=r(c),h=0;h{"use strict";var n=ki(),i=Hs(),r=Br(),a=Kn(),s=r("species");t.exports=function(e){var t=n(e);a&&t&&!t[s]&&i(t,s,{configurable:!0,get:function(){return this}})}})),EY=J((()=>{Dp()("Array")})),_Y=J((()=>{"use strict";var e=tt(),t=ci(),n=lc(),i=os(),r=fi(),a=Aw(),s=Lp(),o=Dg(),l=ou(),h=L1(),c=Hg()("splice"),u=Math.max,d=Math.min;e({target:"Array",proto:!0,forced:!c},{splice:function(e,c){var p,f,m,g,v,y,x=t(this),b=r(x),_=n(e,b),w=arguments.length;for(0===w?p=f=0:1===w?(p=0,f=b-_):(p=w-2,f=d(u(i(c),0),b-_)),s(b+p-f),m=o(x,f),g=0;gb-f+p;g--)h(x,g-1)}else if(p>f)for(g=b-f;g>_;g--)y=g+p-1,(v=g+f-1)in x?x[y]=x[v]:h(x,y);for(g=0;g{var n=fi();t.exports=function(e,t){for(var i=n(e),r=new t(i),a=0;a{"use strict";var e=tt(),t=eD(),n=Ls(),i=Oa(),r=Array;e({target:"Array",proto:!0},{toReversed:function(){return t(n(this),r)}}),i("toReversed")})),Iw=J(((e,t)=>{var n=fi();t.exports=function(e,t){for(var i=0,r=n(t),a=new e(r);r>i;)a[i]=t[i++];return a}})),RY=J(((e,t)=>{var n=Mn();t.exports=function(e){return n[e].prototype}})),AY=J((()=>{"use strict";var e=tt(),t=en(),n=ss(),i=Ls(),r=Iw(),a=RY(),s=Oa(),o=Array,l=t(a("Array").sort);e({target:"Array",proto:!0},{toSorted:function(e){void 0!==e&&n(e);var t=i(this),a=r(o,t);return l(a,e)}}),s("toSorted")})),CY=J((()=>{"use strict";var e=tt(),t=Oa(),n=Lp(),i=fi(),r=lc(),a=Ls(),s=os(),o=Array,l=Math.max,h=Math.min;e({target:"Array",proto:!0},{toSpliced:function(e,t){var c,u,d,p,f=a(this),m=i(f),g=r(e,m),v=arguments.length,y=0;for(0===v?c=u=0:1===v?(c=0,u=m-g):(c=v-2,u=h(l(s(t),0),m-g)),d=n(m+c-u),p=o(d);y{Oa()("flat")})),IY=J((()=>{Oa()("flatMap")})),LY=J((()=>{"use strict";var e=tt(),t=ci(),n=fi(),i=Aw(),r=L1(),a=Lp();e({target:"Array",proto:!0,arity:1,forced:1!==[].unshift(0)||!function(){try{Object.defineProperty([],"length",{writable:!1}).unshift()}catch(e){return e instanceof TypeError}}()},{unshift:function(e){var s=t(this),o=n(s),l=arguments.length;if(l){a(o+l);for(var h=o;h--;){var c=h+l;h in s?s[c]=s[h]:r(s,c)}for(var u=0;u{var n=fi(),i=os(),r=RangeError;t.exports=function(e,t,a,s){var o=n(e),l=i(a),h=l<0?o+l:l;if(h>=o||h<0)throw r("Incorrect index");for(var c=new t(o),u=0;u{"use strict";var e=tt(),t=tD(),n=Ls(),i=Array;e({target:"Array",proto:!0},{with:function(e,r){return t(n(this),i,e,r)}})})),Lw=J(((e,t)=>{t.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView})),Vg=J(((e,t)=>{var n=Yi();t.exports=function(e,t,i){for(var r in t)n(e,r,t[r],i);return e}})),dc=J(((e,t)=>{var n=Fo(),i=TypeError;t.exports=function(e,t){if(n(t,e))return e;throw i("Incorrect invocation")}})),nD=J(((e,t)=>{var n=os(),i=to(),r=RangeError;t.exports=function(e){if(void 0===e)return 0;var t=n(e),a=i(t);if(t!==a)throw r("Wrong length or index");return a}})),HY=J(((e,t)=>{var n=Array,i=Math.abs,r=Math.pow,a=Math.floor,s=Math.log,o=Math.LN2;t.exports={pack:function(e,t,l){var h,c,u,d=n(l),p=8*l-t-1,f=(1<>1,g=23===t?r(2,-24)-r(2,-77):0,v=e<0||0===e&&1/e<0?1:0,y=0;for((e=i(e))!=e||e===1/0?(c=e!=e?1:0,h=f):(h=a(s(e)/o),e*(u=r(2,-h))<1&&(h--,u*=2),(e+=h+m>=1?g/u:g*r(2,1-m))*u>=2&&(h++,u/=2),h+m>=f?(c=0,h=f):h+m>=1?(c=(e*u-1)*r(2,t),h+=m):(c=e*r(2,m-1)*r(2,t),h=0));t>=8;)d[y++]=255&c,c/=256,t-=8;for(h=h<0;)d[y++]=255&h,h/=256,p-=8;return d[--y]|=128*v,d},unpack:function(e,t){var n,i=e.length,a=8*i-t-1,s=(1<>1,l=a-7,h=i-1,c=e[h--],u=127&c;for(c>>=7;l>0;)u=256*u+e[h--],l-=8;for(n=u&(1<<-l)-1,u>>=-l,l+=t;l>0;)n=256*n+e[h--],l-=8;if(0===u)u=1-o;else{if(u===s)return n?NaN:c?-1/0:1/0;n+=r(2,t),u-=o}return(c?-1:1)*n*r(2,u-t)}}})),z1=J(((e,t)=>{"use strict";var n,i,r,a,s,o,l=Mn(),h=en(),c=Kn(),u=Lw(),d=wp(),p=da(),f=Hs(),m=Vg(),g=Yt(),v=dc(),y=os(),x=to(),b=nD(),_=HY(),w=Bo(),S=uc(),M=yh().f,T=_w(),E=Lg(),A=ro(),C=Ts(),P=d.PROPER,R=d.CONFIGURABLE,O="ArrayBuffer",L="DataView",I="prototype",D="Wrong index",k=C.getterFor(O),N=C.getterFor(L),F=C.set,U=l[O],B=U,z=B&&B[I],H=l[L],V=H&&H[I],j=Object.prototype,G=l.Array,W=l.RangeError,X=h(T),Y=h([].reverse),q=_.pack,J=_.unpack,Z=function(e){return[255&e]},K=function(e){return[255&e,e>>8&255]},$=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},Q=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},ee=function(e){return q(e,23,4)},te=function(e){return q(e,52,8)},ne=function(e,t,n){f(e[I],t,{configurable:!0,get:function(){return n(this)[t]}})},ie=function(e,t,n,i){var r=b(n),a=N(e);if(r+t>a.byteLength)throw W(D);var s=a.bytes,o=r+a.byteOffset,l=E(s,o,o+t);return i?l:Y(l)},re=function(e,t,n,i,r,a){var s=b(n),o=N(e);if(s+t>o.byteLength)throw W(D);for(var l=o.bytes,h=s+o.byteOffset,c=i(+r),u=0;ur;)(a=i[r++])in B||p(B,a,U[a]);z.constructor=B}S&&w(V)!==j&&S(V,j),s=new H(new B(2)),o=h(V.setInt8),s.setInt8(0,2147483648),s.setInt8(1,2147483649),(s.getInt8(0)||!s.getInt8(1))&&m(V,{setInt8:function(e,t){o(this,e,t<<24>>24)},setUint8:function(e,t){o(this,e,t<<24>>24)}},{unsafe:!0})}else z=(B=function(e){v(this,z);var t=b(e);F(this,{type:O,bytes:X(G(t),0),byteLength:t}),c||(this.byteLength=t,this.detached=!1)})[I],V=(H=function(e,t,n){v(this,V),v(e,z);var i=k(e),r=i.byteLength,a=y(t);if(a<0||a>r)throw W("Wrong offset");if(a+(n=void 0===n?r-a:x(n))>r)throw W("Wrong length");F(this,{type:L,buffer:e,byteLength:n,byteOffset:a,bytes:i.bytes}),c||(this.buffer=e,this.byteLength=n,this.byteOffset=a)})[I],c&&(ne(B,"byteLength",k),ne(H,"buffer",N),ne(H,"byteLength",N),ne(H,"byteOffset",N)),m(V,{getInt8:function(e){return ie(this,1,e)[0]<<24>>24},getUint8:function(e){return ie(this,1,e)[0]},getInt16:function(e){var t=ie(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=ie(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return Q(ie(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return Q(ie(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return J(ie(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return J(ie(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){re(this,1,e,Z,t)},setUint8:function(e,t){re(this,1,e,Z,t)},setInt16:function(e,t){re(this,2,e,K,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){re(this,2,e,K,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){re(this,4,e,$,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){re(this,4,e,$,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){re(this,4,e,ee,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){re(this,8,e,te,t,arguments.length>2?arguments[2]:void 0)}});A(B,O),A(H,L),t.exports={ArrayBuffer:B,DataView:H}})),a$=J((()=>{"use strict";var e=tt(),t=Mn(),n=z1(),i=Dp(),r="ArrayBuffer",a=n[r];e({global:!0,constructor:!0,forced:t[r]!==a},{ArrayBuffer:a}),i(r)})),Pr=J(((e,t)=>{"use strict";var n,i,r,a=Lw(),s=Kn(),o=Mn(),l=Fr(),h=Nr(),c=$r(),u=cc(),d=kd(),p=da(),f=Yi(),m=Hs(),g=Fo(),v=Bo(),y=uc(),x=Br(),b=Tp(),_=Ts(),w=_.enforce,S=_.get,M=o.Int8Array,T=M&&M.prototype,E=o.Uint8ClampedArray,A=E&&E.prototype,C=M&&v(M),P=T&&v(T),R=Object.prototype,O=o.TypeError,L=x("toStringTag"),I=b("TYPED_ARRAY_TAG"),D="TypedArrayConstructor",k=a&&!!y&&"Opera"!==u(o.opera),N=!1,F={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},U={BigInt64Array:8,BigUint64Array:8},B=function(e){var t=v(e);if(h(t)){var n=S(t);return n&&c(n,D)?n[D]:B(t)}},z=function(e){if(!h(e))return!1;var t=u(e);return c(F,t)||c(U,t)};for(n in F)(r=(i=o[n])&&i.prototype)?w(r)[D]=i:k=!1;for(n in U)(r=(i=o[n])&&i.prototype)&&(w(r)[D]=i);if((!k||!l(C)||C===Function.prototype)&&(C=function(){throw O("Incorrect invocation")},k))for(n in F)o[n]&&y(o[n],C);if((!k||!P||P===R)&&(P=C.prototype,k))for(n in F)o[n]&&y(o[n].prototype,P);if(k&&v(A)!==P&&y(A,P),s&&!c(P,L))for(n in N=!0,m(P,L,{configurable:!0,get:function(){return h(this)?this[I]:void 0}}),F)o[n]&&p(o[n],I,n);t.exports={NATIVE_ARRAY_BUFFER_VIEWS:k,TYPED_ARRAY_TAG:N&&I,aTypedArray:function(e){if(z(e))return e;throw O("Target is not a typed array")},aTypedArrayConstructor:function(e){if(l(e)&&(!y||g(C,e)))return e;throw O(d(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,i){if(s){if(n)for(var r in F){var a=o[r];if(a&&c(a.prototype,e))try{delete a.prototype[e]}catch(n){try{a.prototype[e]=t}catch(e){}}}(!P[e]||n)&&f(P,e,n?t:k&&T[e]||t,i)}},exportTypedArrayStaticMethod:function(e,t,n){var i,r;if(s){if(y){if(n)for(i in F)if((r=o[i])&&c(r,e))try{delete r[e]}catch(e){}if(C[e]&&!n)return;try{return f(C,e,n?t:k&&C[e]||t)}catch(e){}}for(i in F)(r=o[i])&&(!r[e]||n)&&f(r,e,t)}},getTypedArrayConstructor:B,isView:function(e){if(!h(e))return!1;var t=u(e);return"DataView"===t||c(F,t)||c(U,t)},isTypedArray:z,TypedArray:C,TypedArrayPrototype:P}})),y$=J((()=>{var e=tt(),t=Pr();e({target:"ArrayBuffer",stat:!0,forced:!t.NATIVE_ARRAY_BUFFER_VIEWS},{isView:t.isView})})),qw=J(((e,t)=>{var n=Mp(),i=kd(),r=TypeError;t.exports=function(e){if(n(e))return e;throw r(i(e)+" is not a constructor")}})),kp=J(((e,t)=>{var n=br(),i=qw(),r=La(),a=Br()("species");t.exports=function(e,t){var s,o=n(e).constructor;return void 0===o||r(s=n(o)[a])?t:i(s)}})),R$=J((()=>{"use strict";var e=tt(),t=xh(),n=Yt(),i=z1(),r=br(),a=lc(),s=to(),o=kp(),l=i.ArrayBuffer,h=i.DataView,c=h.prototype,u=t(l.prototype.slice),d=t(c.getUint8),p=t(c.setUint8);e({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:n((function(){return!new l(2).slice(1,void 0).byteLength}))},{slice:function(e,t){if(u&&void 0===t)return u(r(this),e);for(var n=r(this).byteLength,i=a(e,n),c=a(void 0===t?n:t,n),f=new(o(this,l))(s(c-i)),m=new h(this),g=new h(f),v=0;i{var e=tt(),t=z1();e({global:!0,constructor:!0,forced:!Lw()},{DataView:t.DataView})})),C$=J((()=>{A$()})),P$=J((()=>{"use strict";var e=tt(),t=en(),n=Yt()((function(){return 120!==new Date(16e11).getYear()})),i=t(Date.prototype.getFullYear);e({target:"Date",proto:!0,forced:n},{getYear:function(){return i(this)-1900}})})),L$=J((()=>{var e=tt(),t=en(),n=Date,i=t(n.prototype.getTime);e({target:"Date",stat:!0},{now:function(){return i(new n)}})})),k$=J((()=>{"use strict";var e=tt(),t=en(),n=os(),i=Date.prototype,r=t(i.getTime),a=t(i.setFullYear);e({target:"Date",proto:!0},{setYear:function(e){r(this);var t=n(e);return a(this,0<=t&&t<=99?t+1900:t)}})})),F$=J((()=>{tt()({target:"Date",proto:!0},{toGMTString:Date.prototype.toUTCString})})),G1=J(((e,t)=>{"use strict";var n=os(),i=Mr(),r=_s(),a=RangeError;t.exports=function(e){var t=i(r(this)),s="",o=n(e);if(o<0||o==1/0)throw a("Wrong number of repetitions");for(;o>0;(o>>>=1)&&(t+=t))1&o&&(s+=t);return s}})),Ww=J(((e,t)=>{var n=en(),i=to(),r=Mr(),a=G1(),s=_s(),o=n(a),l=n("".slice),h=Math.ceil,c=function(e){return function(t,n,a){var c,u,d=r(s(t)),p=i(n),f=d.length,m=void 0===a?" ":r(a);return p<=f||""==m?d:((u=o(m,h((c=p-f)/m.length))).length>c&&(u=l(u,0,c)),e?d+u:u+d)}};t.exports={start:c(!1),end:c(!0)}})),q$=J(((e,t)=>{"use strict";var n=en(),i=Yt(),r=Ww().start,a=RangeError,s=isFinite,o=Math.abs,l=Date.prototype,h=l.toISOString,c=n(l.getTime),u=n(l.getUTCDate),d=n(l.getUTCFullYear),p=n(l.getUTCHours),f=n(l.getUTCMilliseconds),m=n(l.getUTCMinutes),g=n(l.getUTCMonth),v=n(l.getUTCSeconds);t.exports=i((function(){return"0385-07-25T07:06:39.999Z"!=h.call(new Date(-50000000000001))}))||!i((function(){h.call(new Date(NaN))}))?function(){if(!s(c(this)))throw a("Invalid time value");var e=this,t=d(e),n=f(e),i=t<0?"-":t>9999?"+":"";return i+r(o(t),i?6:4,0)+"-"+r(g(e)+1,2,0)+"-"+r(u(e),2,0)+"T"+r(p(e),2,0)+":"+r(m(e),2,0)+":"+r(v(e),2,0)+"."+r(n,3,0)+"Z"}:h})),j$=J((()=>{var e=tt(),t=q$();e({target:"Date",proto:!0,forced:Date.prototype.toISOString!==t},{toISOString:t})})),X$=J((()=>{"use strict";var e=tt(),t=Yt(),n=ci(),i=v1();e({target:"Date",proto:!0,arity:1,forced:t((function(){return null!==new Date(NaN).toJSON()||1!==Date.prototype.toJSON.call({toISOString:function(){return 1}})}))},{toJSON:function(e){var t=n(this),r=i(t,"number");return"number"!=typeof r||isFinite(r)?t.toISOString():null}})})),$$=J(((e,t)=>{"use strict";var n=br(),i=_3(),r=TypeError;t.exports=function(e){if(n(this),"string"===e||"default"===e)e="string";else if("number"!==e)throw r("Incorrect hint");return i(this,e)}})),J$=J((()=>{var e=$r(),t=Yi(),n=$$(),i=Br()("toPrimitive"),r=Date.prototype;e(r,i)||t(r,i,n)})),nZ=J((()=>{var e=en(),t=Yi(),n=Date.prototype,i="Invalid Date",r="toString",a=e(n[r]),s=e(n.getTime);String(new Date(NaN))!=i&&t(n,r,(function(){var e=s(this);return e==e?a(this):i}))})),iZ=J((()=>{"use strict";var e=tt(),t=en(),n=Mr(),i=t("".charAt),r=t("".charCodeAt),a=t(/./.exec),s=t(1..toString),o=t("".toUpperCase),l=/[\w*+\-./@]/,h=function(e,t){for(var n=s(e,16);n.length{"use strict";var n=en(),i=ss(),r=Nr(),a=$r(),s=Nd(),o=Mg(),l=Function,h=n([].concat),c=n([].join),u={};t.exports=o?l.bind:function(e){var t=i(this),n=t.prototype,o=s(arguments,1),d=function(){var n=h(o,s(arguments));return this instanceof d?function(e,t,n){if(!a(u,t)){for(var i=[],r=0;r{var e=tt(),t=SD();e({target:"Function",proto:!0,forced:Function.bind!==t},{bind:t})})),fZ=J((()=>{"use strict";var e=Fr(),t=Nr(),n=Gi(),i=Bo(),r=Br(),a=KT(),s=r("hasInstance"),o=Function.prototype;s in o||n.f(o,s,{value:a((function(n){if(!e(this)||!t(n))return!1;var r=this.prototype;if(!t(r))return n instanceof this;for(;n=i(n);)if(r===n)return!0;return!1}),s)})})),vZ=J((()=>{var e=Kn(),t=wp().EXISTS,n=en(),i=Hs(),r=Function.prototype,a=n(r.toString),s=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,o=n(s.exec);e&&!t&&i(r,"name",{configurable:!0,get:function(){try{return o(s,a(this))[1]}catch(e){return""}}})})),yZ=J((()=>{var e=tt(),t=Mn();e({global:!0,forced:t.globalThis!==t},{globalThis:t})})),xZ=J((()=>{var e=Mn();ro()(e.JSON,"JSON",!0)})),jw=J(((e,t)=>{var n=Yt();t.exports=n((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}))})),Yw=J(((e,t)=>{var n=Yt(),i=Nr(),r=ha(),a=jw(),s=Object.isExtensible,o=n((function(){s(1)}));t.exports=o||a?function(e){return!(!i(e)||a&&"ArrayBuffer"==r(e))&&(!s||s(e))}:s})),Np=J(((e,t)=>{var n=Yt();t.exports=!n((function(){return Object.isExtensible(Object.preventExtensions({}))}))})),Wd=J(((e,t)=>{var n=tt(),i=en(),r=Ag(),a=Nr(),s=$r(),o=Gi().f,l=yh(),h=sw(),c=Yw(),u=Tp(),d=Np(),p=!1,f=u("meta"),m=0,g=function(e){o(e,f,{value:{objectID:"O"+m++,weakData:{}}})},v=t.exports={enable:function(){v.enable=function(){},p=!0;var e=l.f,t=i([].splice),r={};r[f]=1,e(r).length&&(l.f=function(n){for(var i=e(n),r=0,a=i.length;r{"use strict";var n=tt(),i=Mn(),r=en(),a=Pg(),s=Yi(),o=Wd(),l=hc(),h=dc(),c=Fr(),u=La(),d=Nr(),p=Yt(),f=O1(),m=ro(),g=Pp();t.exports=function(e,t,v){var y=-1!==e.indexOf("Map"),x=-1!==e.indexOf("Weak"),b=y?"set":"add",_=i[e],w=_&&_.prototype,S=_,M={},T=function(e){var t=r(w[e]);s(w,e,"add"==e?function(e){return t(this,0===e?0:e),this}:"delete"==e?function(e){return!(x&&!d(e))&&t(this,0===e?0:e)}:"get"==e?function(e){return x&&!d(e)?void 0:t(this,0===e?0:e)}:"has"==e?function(e){return!(x&&!d(e))&&t(this,0===e?0:e)}:function(e,n){return t(this,0===e?0:e,n),this})};if(a(e,!c(_)||!(x||w.forEach&&!p((function(){(new _).entries().next()})))))S=v.getConstructor(t,e,y,b),o.enable();else if(a(e,!0)){var E=new S,A=E[b](x?{}:-0,1)!=E,C=p((function(){E.has(1)})),P=f((function(e){new _(e)})),R=!x&&p((function(){for(var e=new _,t=5;t--;)e[b](t,t);return!e.has(-0)}));P||((S=t((function(e,t){h(e,w);var n=g(new _,e,S);return u(t)||l(t,n[b],{that:n,AS_ENTRIES:y}),n}))).prototype=w,w.constructor=S),(C||R)&&(T("delete"),T("has"),y&&T("get")),(R||A)&&T(b),x&&w.clear&&delete w.clear}return M[e]=S,n({global:!0,constructor:!0,forced:S!=_},M),m(S,e),x||v.setStrong(S,e,y),S}})),OD=J(((e,t)=>{"use strict";var n=no(),i=Hs(),r=Vg(),a=fl(),s=dc(),o=La(),l=hc(),h=Mw(),c=N1(),u=Dp(),d=Kn(),p=Wd().fastKey,f=Ts(),m=f.set,g=f.getterFor;t.exports={getConstructor:function(e,t,h,c){var u=e((function(e,i){s(e,f),m(e,{type:t,index:n(null),first:void 0,last:void 0,size:0}),d||(e.size=0),o(i)||l(i,e[c],{that:e,AS_ENTRIES:h})})),f=u.prototype,v=g(t),y=function(e,t,n){var i,r,a=v(e),s=x(e,t);return s?s.value=n:(a.last=s={index:r=p(t,!0),key:t,value:n,previous:i=a.last,next:void 0,removed:!1},a.first||(a.first=s),i&&(i.next=s),d?a.size++:e.size++,"F"!==r&&(a.index[r]=s)),e},x=function(e,t){var n,i=v(e),r=p(t);if("F"!==r)return i.index[r];for(n=i.first;n;n=n.next)if(n.key==t)return n};return r(f,{clear:function(){for(var e=v(this),t=e.index,n=e.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete t[n.index],n=n.next;e.first=e.last=void 0,d?e.size=0:this.size=0},delete:function(e){var t=this,n=v(t),i=x(t,e);if(i){var r=i.next,a=i.previous;delete n.index[i.index],i.removed=!0,a&&(a.next=r),r&&(r.previous=a),n.first==i&&(n.first=r),n.last==i&&(n.last=a),d?n.size--:t.size--}return!!i},forEach:function(e){for(var t,n=v(this),i=a(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:n.first;)for(i(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!x(this,e)}}),r(f,h?{get:function(e){var t=x(this,e);return t&&t.value},set:function(e,t){return y(this,0===e?0:e,t)}}:{add:function(e){return y(this,e=0===e?0:e,e)}}),d&&i(f,"size",{configurable:!0,get:function(){return v(this).size}}),u},setStrong:function(e,t,n){var i=t+" Iterator",r=g(t),a=g(i);h(e,t,(function(e,t){m(this,{type:i,target:e,state:r(e),kind:t,last:void 0})}),(function(){for(var e=a(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?c("keys"==t?n.key:"values"==t?n.value:[n.key,n.value],!1):(e.target=void 0,c(void 0,!0))}),n?"entries":"values",!n,!0),u(t)}}})),OZ=J((()=>{"use strict";W1()("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),OD())})),kZ=J((()=>{OZ()})),kD=J(((e,t)=>{var n=Math.log;t.exports=Math.log1p||function(e){var t=+e;return t>-1e-8&&t<1e-8?t-t*t/2:n(1+t)}})),BZ=J((()=>{var e=tt(),t=kD(),n=Math.acosh,i=Math.log,r=Math.sqrt,a=Math.LN2;e({target:"Math",stat:!0,forced:!n||710!=Math.floor(n(Number.MAX_VALUE))||n(1/0)!=1/0},{acosh:function(e){var n=+e;return n<1?NaN:n>94906265.62425156?i(n)+a:t(n-1+r(n-1)*r(n+1))}})})),VZ=J((()=>{var e=tt(),t=Math.asinh,n=Math.log,i=Math.sqrt;e({target:"Math",stat:!0,forced:!(t&&1/t(0)>0)},{asinh:function e(t){var r=+t;return isFinite(r)&&0!=r?r<0?-e(-r):n(r+i(r*r+1)):r}})})),GZ=J((()=>{var e=tt(),t=Math.atanh,n=Math.log;e({target:"Math",stat:!0,forced:!(t&&1/t(-0)<0)},{atanh:function(e){var t=+e;return 0==t?t:n((1+t)/(1-t))/2}})})),Zw=J(((e,t)=>{t.exports=Math.sign||function(e){var t=+e;return 0==t||t!=t?t:t<0?-1:1}})),WZ=J((()=>{var e=tt(),t=Zw(),n=Math.abs,i=Math.pow;e({target:"Math",stat:!0},{cbrt:function(e){var r=+e;return t(r)*i(n(r),1/3)}})})),jZ=J((()=>{var e=tt(),t=Math.floor,n=Math.log,i=Math.LOG2E;e({target:"Math",stat:!0},{clz32:function(e){var r=e>>>0;return r?31-t(n(r+.5)*i):32}})})),Y1=J(((e,t)=>{var n=Math.expm1,i=Math.exp;t.exports=!n||n(10)>22025.465794806718||n(10)<22025.465794806718||-2e-17!=n(-2e-17)?function(e){var t=+e;return 0==t?t:t>-1e-6&&t<1e-6?t+t*t/2:i(t)-1}:n})),$Z=J((()=>{var e=tt(),t=Y1(),n=Math.cosh,i=Math.abs,r=Math.E;e({target:"Math",stat:!0,forced:!n||n(710)===1/0},{cosh:function(e){var n=t(i(e)-1)+1;return(n+1/(n*r*r))*(r/2)}})})),KZ=J((()=>{var e=tt(),t=Y1();e({target:"Math",stat:!0,forced:t!=Math.expm1},{expm1:t})})),QZ=J(((e,t)=>{var n=Zw(),i=Math.abs,r=Math.pow,a=r(2,-52),s=r(2,-23),o=r(2,127)*(2-s),l=r(2,-126);t.exports=Math.fround||function(e){var t,r,h=+e,c=i(h),u=n(h);return co||r!=r?u*(1/0):u*r}})),eK=J((()=>{tt()({target:"Math",stat:!0},{fround:QZ()})})),nK=J((()=>{var e=tt(),t=Math.hypot,n=Math.abs,i=Math.sqrt;e({target:"Math",stat:!0,arity:2,forced:!!t&&t(1/0,NaN)!==1/0},{hypot:function(e,t){for(var r,a,s=0,o=0,l=arguments.length,h=0;o0?(a=r/h)*a:r;return h===1/0?1/0:h*i(s)}})})),iK=J((()=>{var e=tt(),t=Yt(),n=Math.imul;e({target:"Math",stat:!0,forced:t((function(){return-5!=n(4294967295,5)||2!=n.length}))},{imul:function(e,t){var n=65535,i=+e,r=+t,a=n&i,s=n&r;return 0|a*s+((n&i>>>16)*s+a*(n&r>>>16)<<16>>>0)}})})),HD=J(((e,t)=>{var n=Math.log,i=Math.LOG10E;t.exports=Math.log10||function(e){return n(e)*i}})),aK=J((()=>{tt()({target:"Math",stat:!0},{log10:HD()})})),oK=J((()=>{tt()({target:"Math",stat:!0},{log1p:kD()})})),lK=J((()=>{var e=tt(),t=Math.log,n=Math.LN2;e({target:"Math",stat:!0},{log2:function(e){return t(e)/n}})})),cK=J((()=>{tt()({target:"Math",stat:!0},{sign:Zw()})})),dK=J((()=>{var e=tt(),t=Yt(),n=Y1(),i=Math.abs,r=Math.exp,a=Math.E;e({target:"Math",stat:!0,forced:t((function(){return-2e-17!=Math.sinh(-2e-17)}))},{sinh:function(e){var t=+e;return i(t)<1?(n(t)-n(-t))/2:(r(t-1)-r(-t-1))*(a/2)}})})),mK=J((()=>{var e=tt(),t=Y1(),n=Math.exp;e({target:"Math",stat:!0},{tanh:function(e){var i=+e,r=t(i),a=t(-i);return r==1/0?1:a==1/0?-1:(r-a)/(n(i)+n(-i))}})})),gK=J((()=>{ro()(Math,"Math",!0)})),vK=J((()=>{tt()({target:"Math",stat:!0},{trunc:H3()})})),$1=J(((e,t)=>{var n=en();t.exports=n(1..valueOf)})),Z1=J(((e,t)=>{t.exports="\t\n\v\f\r \xa0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029\ufeff"})),Bp=J(((e,t)=>{var n=en(),i=_s(),r=Mr(),a=Z1(),s=n("".replace),o=RegExp("^["+a+"]+"),l=RegExp("(^|[^"+a+"])["+a+"]+$"),h=function(e){return function(t){var n=r(i(t));return 1&e&&(n=s(n,o,"")),2&e&&(n=s(n,l,"$1")),n}};t.exports={start:h(1),end:h(2),trim:h(3)}})),AK=J((()=>{"use strict";var e=tt(),t=as(),n=Kn(),i=Mn(),r=aw(),a=en(),s=Pg(),o=$r(),l=Pp(),h=Fo(),c=Od(),u=v1(),d=Yt(),p=yh().f,f=Qs().f,m=Gi().f,g=$1(),v=Bp().trim,y="Number",x=i[y],b=r[y],_=x.prototype,w=i.TypeError,S=a("".slice),M=a("".charCodeAt),T=s(y,!x(" 0o1")||!x("0b1")||x("+0x1")),E=function(e){var t,n=arguments.length<1?0:x(function(e){var t=u(e,"number");return"bigint"==typeof t?t:function(e){var t,n,i,r,a,s,o,l,h=u(e,"number");if(c(h))throw w("Cannot convert a Symbol value to a number");if("string"==typeof h&&h.length>2)if(h=v(h),43===(t=M(h,0))||45===t){if(88===(n=M(h,2))||120===n)return NaN}else if(48===t){switch(M(h,1)){case 66:case 98:i=2,r=49;break;case 79:case 111:i=8,r=55;break;default:return+h}for(s=(a=S(h,2)).length,o=0;or)return NaN;return parseInt(a,i)}return+h}(t)}(e));return h(_,t=this)&&d((function(){g(t)}))?l(Object(n),this,E):n};E.prototype=_,T&&!t&&(_.constructor=E),e({global:!0,constructor:!0,wrap:!0,forced:T},{Number:E});var A=function(e,t){for(var i,r=n?p(t):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),a=0;r.length>a;a++)o(t,i=r[a])&&!o(e,i)&&m(e,i,f(t,i))};t&&b&&A(r[y],b),(T||t)&&A(r[y],x)})),CK=J((()=>{tt()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{EPSILON:Math.pow(2,-52)})})),IK=J(((e,t)=>{var n=Mn().isFinite;t.exports=Number.isFinite||function(e){return"number"==typeof e&&n(e)}})),LK=J((()=>{tt()({target:"Number",stat:!0},{isFinite:IK()})})),tS=J(((e,t)=>{var n=Nr(),i=Math.floor;t.exports=Number.isInteger||function(e){return!n(e)&&isFinite(e)&&i(e)===e}})),OK=J((()=>{tt()({target:"Number",stat:!0},{isInteger:tS()})})),kK=J((()=>{tt()({target:"Number",stat:!0},{isNaN:function(e){return e!=e}})})),FK=J((()=>{var e=tt(),t=tS(),n=Math.abs;e({target:"Number",stat:!0},{isSafeInteger:function(e){return t(e)&&n(e)<=9007199254740991}})})),NK=J((()=>{tt()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991})})),BK=J((()=>{tt()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MIN_SAFE_INTEGER:-9007199254740991})})),XD=J(((e,t)=>{var n=Mn(),i=Yt(),r=en(),a=Mr(),s=Bp().trim,o=Z1(),l=r("".charAt),h=n.parseFloat,c=n.Symbol,u=c&&c.iterator,d=1/h(o+"-0")!=-1/0||u&&!i((function(){h(Object(u))}));t.exports=d?function(e){var t=s(a(e)),n=h(t);return 0===n&&"-"==l(t,0)?-0:n}:h})),qK=J((()=>{var e=tt(),t=XD();e({target:"Number",stat:!0,forced:Number.parseFloat!=t},{parseFloat:t})})),YD=J(((e,t)=>{var n=Mn(),i=Yt(),r=en(),a=Mr(),s=Bp().trim,o=Z1(),l=n.parseInt,h=n.Symbol,c=h&&h.iterator,u=/^[+-]?0x/i,d=r(u.exec),p=8!==l(o+"08")||22!==l(o+"0x16")||c&&!i((function(){l(Object(c))}));t.exports=p?function(e,t){var n=s(a(e));return l(n,t>>>0||(d(u,n)?16:10))}:l})),JK=J((()=>{var e=tt(),t=YD();e({target:"Number",stat:!0,forced:Number.parseInt!=t},{parseInt:t})})),rJ=J((()=>{"use strict";var e=tt(),t=en(),n=os(),i=$1(),r=G1(),a=HD(),s=Yt(),o=RangeError,l=String,h=isFinite,c=Math.abs,u=Math.floor,d=Math.pow,p=Math.round,f=t(1..toExponential),m=t(r),g=t("".slice),v="-6.9000e-11"===f(-69e-12,4)&&"1.25e+0"===f(1.255,2)&&"1.235e+4"===f(12345,3)&&"3e+1"===f(25,0);e({target:"Number",proto:!0,forced:!v||!(s((function(){f(1,1/0)}))&&s((function(){f(1,-1/0)})))||!!s((function(){f(1/0,1/0),f(NaN,1/0)}))},{toExponential:function(e){var t=i(this);if(void 0===e)return f(t);var r=n(e);if(!h(t))return String(t);if(r<0||r>20)throw o("Incorrect fraction digits");if(v)return f(t,r);var s="",y="",x=0,b="",_="";if(t<0&&(s="-",t=-t),0===t)x=0,y=m("0",r+1);else{var w=a(t);x=u(w);var S=0,M=d(10,x-r);2*t>=(2*(S=p(t/M))+1)*M&&(S+=1),S>=d(10,r+1)&&(S/=10,x+=1),y=l(S)}return 0!==r&&(y=g(y,0,1)+"."+g(y,1)),0===x?(b="+",_="0"):(b=x>0?"+":"-",_=l(c(x))),s+(y+"e")+b+_}})})),cJ=J((()=>{"use strict";var e=tt(),t=en(),n=os(),i=$1(),r=G1(),a=Yt(),s=RangeError,o=String,l=Math.floor,h=t(r),c=t("".slice),u=t(1..toFixed),d=function(e,t,n){return 0===t?n:t%2==1?d(e,t-1,n*e):d(e*e,t/2,n)},p=function(e,t,n){for(var i=-1,r=n;++i<6;)r+=t*e[i],e[i]=r%1e7,r=l(r/1e7)},f=function(e,t){for(var n=6,i=0;--n>=0;)i+=e[n],e[n]=l(i/t),i=i%t*1e7},m=function(e){for(var t=6,n="";--t>=0;)if(""!==n||0===t||0!==e[t]){var i=o(e[t]);n=""===n?i:n+h("0",7-i.length)+i}return n};e({target:"Number",proto:!0,forced:a((function(){return"0.000"!==u(8e-5,3)||"1"!==u(.9,0)||"1.25"!==u(1.255,2)||"1000000000000000128"!==u(0xde0b6b3a7640080,0)}))||!a((function(){u({})}))},{toFixed:function(e){var t,r,a,l,u=i(this),g=n(e),v=[0,0,0,0,0,0],y="",x="0";if(g<0||g>20)throw s("Incorrect fraction digits");if(u!=u)return"NaN";if(u<=-1e21||u>=1e21)return o(u);if(u<0&&(y="-",u=-u),u>1e-21)if(t=function(e){for(var t=0,n=e;n>=4096;)t+=12,n/=4096;for(;n>=2;)t+=1,n/=2;return t}(u*d(2,69,1))-69,r=t<0?u*d(2,-t,1):u/d(2,t,1),r*=4503599627370496,(t=52-t)>0){for(p(v,0,r),a=g;a>=7;)p(v,1e7,0),a-=7;for(p(v,d(10,a,1),0),a=t-1;a>=23;)f(v,1<<23),a-=23;f(v,1<0?y+((l=x.length)<=g?"0."+h("0",g-l)+x:c(x,0,l-g)+"."+c(x,l-g)):y+x}})})),dJ=J((()=>{"use strict";var e=tt(),t=en(),n=Yt(),i=$1(),r=t(1..toPrecision);e({target:"Number",proto:!0,forced:n((function(){return"1"!==r(1,void 0)}))||!n((function(){r({})}))},{toPrecision:function(e){return void 0===e?r(i(this)):r(i(this),e)}})})),tO=J(((e,t)=>{"use strict";var n=Kn(),i=en(),r=wr(),a=Yt(),s=Ig(),o=E1(),l=g1(),h=ci(),c=bp(),u=Object.assign,d=Object.defineProperty,p=i([].concat);t.exports=!u||a((function(){if(n&&1!==u({b:1},u(d({},"a",{enumerable:!0,get:function(){d(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},i=Symbol(),r="abcdefghijklmnopqrst";return e[i]=7,r.split("").forEach((function(e){t[e]=e})),7!=u({},e)[i]||s(u({},t)).join("")!=r}))?function(e,t){for(var i=h(e),a=arguments.length,u=1,d=o.f,f=l.f;a>u;)for(var m,g=c(arguments[u++]),v=d?p(s(g),d(g)):s(g),y=v.length,x=0;y>x;)m=v[x++],(!n||r(f,g,m))&&(i[m]=g[m]);return i}:u})),vJ=J((()=>{var e=tt(),t=tO();e({target:"Object",stat:!0,arity:2,forced:Object.assign!==t},{assign:t})})),yJ=J((()=>{tt()({target:"Object",stat:!0,sham:!Kn()},{create:no()})})),ex=J(((e,t)=>{"use strict";var n=as(),i=Mn(),r=Yt(),a=Pw();t.exports=n||!r((function(){if(!(a&&a<535)){var e=Math.random();__defineSetter__.call(null,e,(function(){})),delete i[e]}}))})),EJ=J((()=>{"use strict";var e=tt(),t=Kn(),n=ex(),i=ss(),r=ci(),a=Gi();t&&e({target:"Object",proto:!0,forced:n},{__defineGetter__:function(e,t){a.f(r(this),e,{get:i(t),enumerable:!0,configurable:!0})}})})),TJ=J((()=>{var e=tt(),t=Kn(),n=nw().f;e({target:"Object",stat:!0,forced:Object.defineProperties!==n,sham:!t},{defineProperties:n})})),SJ=J((()=>{var e=tt(),t=Kn(),n=Gi().f;e({target:"Object",stat:!0,forced:Object.defineProperty!==n,sham:!t},{defineProperty:n})})),MJ=J((()=>{"use strict";var e=tt(),t=Kn(),n=ex(),i=ss(),r=ci(),a=Gi();t&&e({target:"Object",proto:!0,forced:n},{__defineSetter__:function(e,t){a.f(r(this),e,{set:i(t),enumerable:!0,configurable:!0})}})})),nO=J(((e,t)=>{var n=Kn(),i=en(),r=Ig(),a=Ls(),s=i(g1().f),o=i([].push),l=function(e){return function(t){for(var i,l=a(t),h=r(l),c=h.length,u=0,d=[];c>u;)i=h[u++],(!n||s(l,i))&&o(d,e?[i,l[i]]:l[i]);return d}};t.exports={entries:l(!0),values:l(!1)}})),PJ=J((()=>{var e=tt(),t=nO().entries;e({target:"Object",stat:!0},{entries:function(e){return t(e)}})})),IJ=J((()=>{var e=tt(),t=Np(),n=Yt(),i=Nr(),r=Wd().onFreeze,a=Object.freeze;e({target:"Object",stat:!0,forced:n((function(){a(1)})),sham:!t},{freeze:function(e){return a&&i(e)?a(r(e)):e}})})),LJ=J((()=>{var e=tt(),t=hc(),n=ou();e({target:"Object",stat:!0},{fromEntries:function(e){var i={};return t(e,(function(e,t){n(i,e,t)}),{AS_ENTRIES:!0}),i}})})),kJ=J((()=>{var e=tt(),t=Yt(),n=Ls(),i=Qs().f,r=Kn();e({target:"Object",stat:!0,forced:!r||t((function(){i(1)})),sham:!r},{getOwnPropertyDescriptor:function(e,t){return i(n(e),t)}})})),FJ=J((()=>{var e=tt(),t=Kn(),n=QT(),i=Ls(),r=Qs(),a=ou();e({target:"Object",stat:!0,sham:!t},{getOwnPropertyDescriptors:function(e){for(var t,s,o=i(e),l=r.f,h=n(o),c={},u=0;h.length>u;)void 0!==(s=l(o,t=h[u++]))&&a(c,t,s);return c}})})),NJ=J((()=>{var e=tt(),t=Yt(),n=sw().f;e({target:"Object",stat:!0,forced:t((function(){return!Object.getOwnPropertyNames(1)}))},{getOwnPropertyNames:n})})),UJ=J((()=>{var e=tt(),t=Yt(),n=ci(),i=Bo(),r=vw();e({target:"Object",stat:!0,forced:t((function(){i(1)})),sham:!r},{getPrototypeOf:function(e){return i(n(e))}})})),HJ=J((()=>{tt()({target:"Object",stat:!0},{hasOwn:$r()})})),iO=J(((e,t)=>{t.exports=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}})),zJ=J((()=>{tt()({target:"Object",stat:!0},{is:iO()})})),qJ=J((()=>{var e=tt(),t=Yw();e({target:"Object",stat:!0,forced:Object.isExtensible!==t},{isExtensible:t})})),jJ=J((()=>{var e=tt(),t=Yt(),n=Nr(),i=ha(),r=jw(),a=Object.isFrozen;e({target:"Object",stat:!0,forced:r||t((function(){a(1)}))},{isFrozen:function(e){return!(n(e)&&(!r||"ArrayBuffer"!=i(e)))||!!a&&a(e)}})})),YJ=J((()=>{var e=tt(),t=Yt(),n=Nr(),i=ha(),r=jw(),a=Object.isSealed;e({target:"Object",stat:!0,forced:r||t((function(){a(1)}))},{isSealed:function(e){return!(n(e)&&(!r||"ArrayBuffer"!=i(e)))||!!a&&a(e)}})})),ZJ=J((()=>{var e=tt(),t=ci(),n=Ig();e({target:"Object",stat:!0,forced:Yt()((function(){n(1)}))},{keys:function(e){return n(t(e))}})})),KJ=J((()=>{"use strict";var e=tt(),t=Kn(),n=ex(),i=ci(),r=vh(),a=Bo(),s=Qs().f;t&&e({target:"Object",proto:!0,forced:n},{__lookupGetter__:function(e){var t,n=i(this),o=r(e);do{if(t=s(n,o))return t.get}while(n=a(n))}})})),JJ=J((()=>{"use strict";var e=tt(),t=Kn(),n=ex(),i=ci(),r=vh(),a=Bo(),s=Qs().f;t&&e({target:"Object",proto:!0,forced:n},{__lookupSetter__:function(e){var t,n=i(this),o=r(e);do{if(t=s(n,o))return t.set}while(n=a(n))}})})),QJ=J((()=>{var e=tt(),t=Nr(),n=Wd().onFreeze,i=Np(),r=Yt(),a=Object.preventExtensions;e({target:"Object",stat:!0,forced:r((function(){a(1)})),sham:!i},{preventExtensions:function(e){return a&&t(e)?a(n(e)):e}})})),sQ=J((()=>{"use strict";var e=Kn(),t=Hs(),n=Nr(),i=ci(),r=_s(),a=Object.getPrototypeOf,s=Object.setPrototypeOf,o=Object.prototype,l="__proto__";if(e&&a&&s&&!(l in o))try{t(o,l,{configurable:!0,get:function(){return a(i(this))},set:function(e){var t=r(this);!n(e)&&null!==e||!n(t)||s(t,e)}})}catch(e){}})),aQ=J((()=>{var e=tt(),t=Nr(),n=Wd().onFreeze,i=Np(),r=Yt(),a=Object.seal;e({target:"Object",stat:!0,forced:r((function(){a(1)})),sham:!i},{seal:function(e){return a&&t(e)?a(n(e)):e}})})),oQ=J((()=>{tt()({target:"Object",stat:!0},{setPrototypeOf:uc()})})),cQ=J(((e,t)=>{"use strict";var n=ew(),i=cc();t.exports=n?{}.toString:function(){return"[object "+i(this)+"]"}})),uQ=J((()=>{var e=ew(),t=Yi(),n=cQ();e||t(Object.prototype,"toString",n,{unsafe:!0})})),hQ=J((()=>{var e=tt(),t=nO().values;e({target:"Object",stat:!0},{values:function(e){return t(e)}})})),fQ=J((()=>{var e=tt(),t=XD();e({global:!0,forced:parseFloat!=t},{parseFloat:t})})),mQ=J((()=>{var e=tt(),t=YD();e({global:!0,forced:parseInt!=t},{parseInt:t})})),pu=J(((e,t)=>{var n=TypeError;t.exports=function(e,t){if(e{var n=iu();t.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(n)})),rx=J(((e,t)=>{var n,i,r,a,s=Mn(),o=No(),l=fl(),h=Fr(),c=$r(),u=Yt(),d=q3(),p=Nd(),f=y1(),m=pu(),g=cO(),v=uu(),y=s.setImmediate,x=s.clearImmediate,b=s.process,_=s.Dispatch,w=s.Function,S=s.MessageChannel,M=s.String,T=0,E={},A="onreadystatechange";u((function(){n=s.location}));var C=function(e){if(c(E,e)){var t=E[e];delete E[e],t()}},P=function(e){return function(){C(e)}},R=function(e){C(e.data)},O=function(e){s.postMessage(M(e),n.protocol+"//"+n.host)};(!y||!x)&&(y=function(e){m(arguments.length,1);var t=h(e)?e:w(e),n=p(arguments,1);return E[++T]=function(){o(t,void 0,n)},i(T),T},x=function(e){delete E[e]},v?i=function(e){b.nextTick(P(e))}:_&&_.now?i=function(e){_.now(P(e))}:S&&!g?(a=(r=new S).port2,r.port1.onmessage=R,i=l(a.postMessage,a)):s.addEventListener&&h(s.postMessage)&&!s.importScripts&&n&&"file:"!==n.protocol&&!u(O)?(i=O,s.addEventListener("message",R,!1)):i=A in f("script")?function(e){d.appendChild(f("script"))[A]=function(){d.removeChild(this),C(e)}}:function(e){setTimeout(P(e),0)}),t.exports={set:y,clear:x}})),yO=J(((e,t)=>{var n=function(){this.head=null,this.tail=null};n.prototype={add:function(e){var t={item:e,next:null},n=this.tail;n?n.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}},t.exports=n})),PQ=J(((e,t)=>{var n=iu();t.exports=/ipad|iphone|ipod/i.test(n)&&"undefined"!=typeof Pebble})),LQ=J(((e,t)=>{var n=iu();t.exports=/web0s(?!.*chrome)/i.test(n)})),wO=J(((e,t)=>{var n,i,r,a,s,o,l,h=Mn(),c=fl(),u=Qs().f,d=rx().set,p=yO(),f=cO(),m=PQ(),g=LQ(),v=uu(),y=h.MutationObserver||h.WebKitMutationObserver,x=h.document,b=h.process,_=h.Promise,w=u(h,"queueMicrotask"),S=w&&w.value;S||(o=new p,l=function(){var e,t;for(v&&(e=b.domain)&&e.exit();t=o.get();)try{t()}catch(e){throw o.head&&n(),e}e&&e.enter()},f||v||g||!y||!x?!m&&_&&_.resolve?((a=_.resolve(void 0)).constructor=_,s=c(a.then,a),n=function(){s(l)}):v?n=function(){b.nextTick(l)}:(d=c(d,h),n=function(){d(l)}):(i=!0,r=x.createTextNode(""),new y(l).observe(r,{characterData:!0}),n=function(){r.data=i=!i}),S=function(e){o.head||n(),o.add(e)}),t.exports=S})),VQ=J(((e,t)=>{t.exports=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(e){}}})),Jg=J(((e,t)=>{t.exports=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}}})),Vp=J(((e,t)=>{var n=Mn();t.exports=n.Promise})),aS=J(((e,t)=>{t.exports="object"==typeof Deno&&Deno&&"object"==typeof Deno.version})),SO=J(((e,t)=>{var n=aS(),i=uu();t.exports=!n&&!i&&"object"==typeof window&&"object"==typeof document})),Qg=J(((e,t)=>{var n=Mn(),i=Vp(),r=Fr(),a=Pg(),s=jT(),o=Br(),l=SO(),h=aS(),c=as(),u=su(),d=i&&i.prototype,p=o("species"),f=!1,m=r(n.PromiseRejectionEvent),g=a("Promise",(function(){var e=s(i),t=e!==String(i);if(!t&&66===u||c&&(!d.catch||!d.finally))return!0;if(!u||u<51||!/native code/.test(e)){var n=new i((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((n.constructor={})[p]=r,!(f=n.then((function(){}))instanceof r))return!0}return!t&&(l||h)&&!m}));t.exports={CONSTRUCTOR:g,REJECTION_EVENT:m,SUBCLASSING:f}})),jd=J(((e,t)=>{"use strict";var n=ss(),i=TypeError,r=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw i("Bad Promise constructor");t=e,r=n})),this.resolve=n(t),this.reject=n(r)};t.exports.f=function(e){return new r(e)}})),mee=J((()=>{"use strict";var e,t,n,i=tt(),r=as(),a=uu(),s=Mn(),o=wr(),l=Yi(),h=uc(),c=ro(),u=Dp(),d=ss(),p=Fr(),f=Nr(),m=dc(),g=kp(),v=rx().set,y=wO(),x=VQ(),b=Jg(),_=yO(),w=Ts(),S=Vp(),M=Qg(),T=jd(),E="Promise",A=M.CONSTRUCTOR,C=M.REJECTION_EVENT,P=M.SUBCLASSING,R=w.getterFor(E),O=w.set,L=S&&S.prototype,I=S,D=L,k=s.TypeError,N=s.document,F=s.process,U=T.f,B=U,z=!!(N&&N.createEvent&&s.dispatchEvent),H="unhandledrejection",V=function(e){var t;return!(!f(e)||!p(t=e.then))&&t},j=function(e,t){var n,i,r,a=t.value,s=1==t.state,l=s?e.ok:e.fail,h=e.resolve,c=e.reject,u=e.domain;try{l?(s||(2===t.rejection&&q(t),t.rejection=1),!0===l?n=a:(u&&u.enter(),n=l(a),u&&(u.exit(),r=!0)),n===e.promise?c(k("Promise-chain cycle")):(i=V(n))?o(i,n,h,c):h(n)):c(a)}catch(e){u&&!r&&u.exit(),c(e)}},G=function(e,t){e.notified||(e.notified=!0,y((function(){for(var n,i=e.reactions;n=i.get();)j(n,e);e.notified=!1,t&&!e.rejection&&X(e)})))},W=function(e,t,n){var i,r;z?((i=N.createEvent("Event")).promise=t,i.reason=n,i.initEvent(e,!1,!0),s.dispatchEvent(i)):i={promise:t,reason:n},!C&&(r=s["on"+e])?r(i):e===H&&x("Unhandled promise rejection",n)},X=function(e){o(v,s,(function(){var t,n=e.facade,i=e.value;if(Y(e)&&(t=b((function(){a?F.emit("unhandledRejection",i,n):W(H,n,i)})),e.rejection=a||Y(e)?2:1,t.error))throw t.value}))},Y=function(e){return 1!==e.rejection&&!e.parent},q=function(e){o(v,s,(function(){var t=e.facade;a?F.emit("rejectionHandled",t):W("rejectionhandled",t,e.value)}))},J=function(e,t,n){return function(i){e(t,i,n)}},Z=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,G(e,!0))},K=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw k("Promise can't be resolved itself");var i=V(t);i?y((function(){var n={done:!1};try{o(i,t,J(K,n,e),J(Z,n,e))}catch(t){Z(n,t,e)}})):(e.value=t,e.state=1,G(e,!1))}catch(t){Z({done:!1},t,e)}}};if(A&&(D=(I=function(t){m(this,D),d(t),o(e,this);var n=R(this);try{t(J(K,n),J(Z,n))}catch(e){Z(n,e)}}).prototype,(e=function(e){O(this,{type:E,done:!1,notified:!1,parent:!1,reactions:new _,rejection:!1,state:0,value:void 0})}).prototype=l(D,"then",(function(e,t){var n=R(this),i=U(g(this,I));return n.parent=!0,i.ok=!p(e)||e,i.fail=p(t)&&t,i.domain=a?F.domain:void 0,0==n.state?n.reactions.add(i):y((function(){j(i,n)})),i.promise})),t=function(){var t=new e,n=R(t);this.promise=t,this.resolve=J(K,n),this.reject=J(Z,n)},T.f=U=function(e){return e===I||void 0===e?new t(e):B(e)},!r&&p(S)&&L!==Object.prototype)){n=L.then,P||l(L,"then",(function(e,t){var i=this;return new I((function(e,t){o(n,i,e,t)})).then(e,t)}),{unsafe:!0});try{delete L.constructor}catch(e){}h&&h(L,D)}i({global:!0,constructor:!0,wrap:!0,forced:A},{Promise:I}),c(I,E,!1,!0),u(E)})),ox=J(((e,t)=>{var n=Vp(),i=O1(),r=Qg().CONSTRUCTOR;t.exports=r||!i((function(e){n.all(e).then(void 0,(function(){}))}))})),vee=J((()=>{"use strict";var e=tt(),t=wr(),n=ss(),i=jd(),r=Jg(),a=hc();e({target:"Promise",stat:!0,forced:ox()},{all:function(e){var s=this,o=i.f(s),l=o.resolve,h=o.reject,c=r((function(){var i=n(s.resolve),r=[],o=0,c=1;a(e,(function(e){var n=o++,a=!1;c++,t(i,s,e).then((function(e){a||(a=!0,r[n]=e,--c||l(r))}),h)})),--c||l(r)}));return c.error&&h(c.value),o.promise}})})),xee=J((()=>{"use strict";var e,t=tt(),n=as(),i=Qg().CONSTRUCTOR,r=Vp(),a=ki(),s=Fr(),o=Yi(),l=r&&r.prototype;t({target:"Promise",proto:!0,forced:i,real:!0},{catch:function(e){return this.then(void 0,e)}}),!n&&s(r)&&(e=a("Promise").prototype.catch,l.catch!==e&&o(l,"catch",e,{unsafe:!0}))})),bee=J((()=>{"use strict";var e=tt(),t=wr(),n=ss(),i=jd(),r=Jg(),a=hc();e({target:"Promise",stat:!0,forced:ox()},{race:function(e){var s=this,o=i.f(s),l=o.reject,h=r((function(){var i=n(s.resolve);a(e,(function(e){t(i,s,e).then(o.resolve,l)}))}));return h.error&&l(h.value),o.promise}})})),Eee=J((()=>{"use strict";var e=tt(),t=wr(),n=jd();e({target:"Promise",stat:!0,forced:Qg().CONSTRUCTOR},{reject:function(e){var i=n.f(this);return t(i.reject,void 0,e),i.promise}})})),BO=J(((e,t)=>{var n=br(),i=Nr(),r=jd();t.exports=function(e,t){if(n(e),i(t)&&t.constructor===e)return t;var a=r.f(e);return(0,a.resolve)(t),a.promise}})),See=J((()=>{"use strict";var e=tt(),t=ki(),n=as(),i=Vp(),r=Qg().CONSTRUCTOR,a=BO(),s=t("Promise"),o=n&&!r;e({target:"Promise",stat:!0,forced:n||r},{resolve:function(e){return a(o&&this===s?i:this,e)}})})),Mee=J((()=>{mee(),vee(),xee(),bee(),Eee(),See()})),Ree=J((()=>{"use strict";var e=tt(),t=wr(),n=ss(),i=jd(),r=Jg(),a=hc();e({target:"Promise",stat:!0,forced:ox()},{allSettled:function(e){var s=this,o=i.f(s),l=o.resolve,h=o.reject,c=r((function(){var i=n(s.resolve),r=[],o=0,h=1;a(e,(function(e){var n=o++,a=!1;h++,t(i,s,e).then((function(e){a||(a=!0,r[n]={status:"fulfilled",value:e},--h||l(r))}),(function(e){a||(a=!0,r[n]={status:"rejected",reason:e},--h||l(r))}))})),--h||l(r)}));return c.error&&h(c.value),o.promise}})})),Cee=J((()=>{"use strict";var e=tt(),t=wr(),n=ss(),i=ki(),r=jd(),a=Jg(),s=hc(),o=ox(),l="No one promise resolved";e({target:"Promise",stat:!0,forced:o},{any:function(e){var o=this,h=i("AggregateError"),c=r.f(o),u=c.resolve,d=c.reject,p=a((function(){var i=n(o.resolve),r=[],a=0,c=1,p=!1;s(e,(function(e){var n=a++,s=!1;c++,t(i,o,e).then((function(e){s||p||(p=!0,u(e))}),(function(e){s||p||(s=!0,r[n]=e,--c||d(new h(r,l)))}))})),--c||d(new h(r,l))}));return p.error&&d(p.value),c.promise}})})),Dee=J((()=>{"use strict";var e,t=tt(),n=as(),i=Vp(),r=Yt(),a=ki(),s=Fr(),o=kp(),l=BO(),h=Yi(),c=i&&i.prototype;t({target:"Promise",proto:!0,real:!0,forced:!!i&&r((function(){c.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=o(this,a("Promise")),n=s(e);return this.then(n?function(n){return l(t,e()).then((function(){return n}))}:e,n?function(n){return l(t,e()).then((function(){throw n}))}:e)}}),!n&&s(i)&&(e=a("Promise").prototype.finally,c.finally!==e&&h(c,"finally",e,{unsafe:!0}))})),Oee=J((()=>{var e=tt(),t=No(),n=ss(),i=br();e({target:"Reflect",stat:!0,forced:!Yt()((function(){Reflect.apply((function(){}))}))},{apply:function(e,r,a){return t(n(e),r,i(a))}})})),Vee=J((()=>{var e=tt(),t=ki(),n=No(),i=SD(),r=qw(),a=br(),s=Nr(),o=no(),l=Yt(),h=t("Reflect","construct"),c=Object.prototype,u=[].push,d=l((function(){function e(){}return!(h((function(){}),[],e)instanceof e)})),p=!l((function(){h((function(){}))})),f=d||p;e({target:"Reflect",stat:!0,forced:f,sham:f},{construct:function(e,t){r(e),a(t);var l=arguments.length<3?e:r(arguments[2]);if(p&&!d)return h(e,t,l);if(e==l){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var f=[null];return n(u,f,t),new(n(i,e,f))}var m=l.prototype,g=o(s(m)?m:c),v=n(e,g,t);return s(v)?v:g}})})),qee=J((()=>{var e=tt(),t=Kn(),n=br(),i=vh(),r=Gi();e({target:"Reflect",stat:!0,forced:Yt()((function(){Reflect.defineProperty(r.f({},1,{value:1}),1,{value:2})})),sham:!t},{defineProperty:function(e,t,a){n(e);var s=i(t);n(a);try{return r.f(e,s,a),!0}catch(e){return!1}}})})),Wee=J((()=>{var e=tt(),t=br(),n=Qs().f;e({target:"Reflect",stat:!0},{deleteProperty:function(e,i){var r=n(t(e),i);return!(r&&!r.configurable)&&delete e[i]}})})),GO=J(((e,t)=>{var n=$r();t.exports=function(e){return void 0!==e&&(n(e,"value")||n(e,"writable"))}})),$ee=J((()=>{var e=tt(),t=wr(),n=Nr(),i=br(),r=GO(),a=Qs(),s=Bo();e({target:"Reflect",stat:!0},{get:function e(o,l){var h,c,u=arguments.length<3?o:arguments[2];return i(o)===u?o[l]:(h=a.f(o,l))?r(h)?h.value:void 0===h.get?void 0:t(h.get,u):n(c=s(o))?e(c,l,u):void 0}})})),Zee=J((()=>{var e=tt(),t=Kn(),n=br(),i=Qs();e({target:"Reflect",stat:!0,sham:!t},{getOwnPropertyDescriptor:function(e,t){return i.f(n(e),t)}})})),Kee=J((()=>{var e=tt(),t=br(),n=Bo();e({target:"Reflect",stat:!0,sham:!vw()},{getPrototypeOf:function(e){return n(t(e))}})})),Jee=J((()=>{tt()({target:"Reflect",stat:!0},{has:function(e,t){return t in e}})})),Qee=J((()=>{var e=tt(),t=br(),n=Yw();e({target:"Reflect",stat:!0},{isExtensible:function(e){return t(e),n(e)}})})),ete=J((()=>{tt()({target:"Reflect",stat:!0},{ownKeys:QT()})})),tte=J((()=>{var e=tt(),t=ki(),n=br();e({target:"Reflect",stat:!0,sham:!Np()},{preventExtensions:function(e){n(e);try{var i=t("Object","preventExtensions");return i&&i(e),!0}catch(e){return!1}}})})),ate=J((()=>{var e=tt(),t=wr(),n=br(),i=Nr(),r=GO(),a=Yt(),s=Gi(),o=Qs(),l=Bo(),h=ko();e({target:"Reflect",stat:!0,forced:a((function(){var e=function(){},t=s.f(new e,"a",{configurable:!0});return!1!==Reflect.set(e.prototype,"a",1,t)}))},{set:function e(a,c,u){var d,p,f,m=arguments.length<4?a:arguments[3],g=o.f(n(a),c);if(!g){if(i(p=l(a)))return e(p,c,u,m);g=h(0)}if(r(g)){if(!1===g.writable||!i(m))return!1;if(d=o.f(m,c)){if(d.get||d.set||!1===d.writable)return!1;d.value=u,s.f(m,c,d)}else s.f(m,c,h(0,u))}else{if(void 0===(f=g.set))return!1;t(f,m,u)}return!0}})})),lte=J((()=>{var e=tt(),t=br(),n=pL(),i=uc();i&&e({target:"Reflect",stat:!0},{setPrototypeOf:function(e,r){t(e),n(r);try{return i(e,r),!0}catch(e){return!1}}})})),cte=J((()=>{var e=tt(),t=Mn(),n=ro();e({global:!0},{Reflect:{}}),n(t.Reflect,"Reflect",!0)})),i0=J(((e,t)=>{var n=Nr(),i=ha(),r=Br()("match");t.exports=function(e){var t;return n(e)&&(void 0!==(t=e[r])?!!t:"RegExp"==i(e))}})),pS=J(((e,t)=>{"use strict";var n=br();t.exports=function(){var e=n(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t}})),s0=J(((e,t)=>{var n=wr(),i=$r(),r=Fo(),a=pS(),s=RegExp.prototype;t.exports=function(e){var t=e.flags;return void 0!==t||"flags"in s||i(e,"flags")||!r(s,e)?t:n(a,e)}})),lx=J(((e,t)=>{var n=Yt(),i=Mn().RegExp,r=n((function(){var e=i("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),a=r||n((function(){return!i("a","y").sticky})),s=r||n((function(){var e=i("^r","gy");return e.lastIndex=2,null!=e.exec("str")}));t.exports={BROKEN_CARET:s,MISSED_STICKY:a,UNSUPPORTED_Y:r}})),mS=J(((e,t)=>{var n=Yt(),i=Mn().RegExp;t.exports=n((function(){var e=i(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)}))})),YO=J(((e,t)=>{var n=Yt(),i=Mn().RegExp;t.exports=n((function(){var e=i("(?
b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$c")}))})),Ste=J((()=>{var e,t,n,i=Kn(),r=Mn(),a=en(),s=Pg(),o=Pp(),l=da(),h=yh().f,c=Fo(),u=i0(),d=Mr(),p=s0(),f=lx(),m=mL(),g=Yi(),v=Yt(),y=$r(),x=Ts().enforce,b=Dp(),_=Br(),w=mS(),S=YO(),M=_("match"),T=r.RegExp,E=T.prototype,A=r.SyntaxError,C=a(E.exec),P=a("".charAt),R=a("".replace),O=a("".indexOf),L=a("".slice),I=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,D=/a/g,k=/a/g,N=new T(D)!==D,F=f.MISSED_STICKY,U=f.UNSUPPORTED_Y;if(s("RegExp",i&&(!N||F||w||S||v((function(){return k[M]=!1,T(D)!=D||T(k)==k||"/a/i"!=T(D,"i")}))))){for(e=function(t,n){var i,r,a,s,h,f,m=c(E,this),g=u(t),v=void 0===n,b=[],_=t;if(!m&&g&&v&&t.constructor===e)return t;if((g||c(E,t))&&(t=t.source,v&&(n=p(_))),t=void 0===t?"":d(t),n=void 0===n?"":d(n),_=t,w&&"dotAll"in D&&(r=!!n&&O(n,"s")>-1)&&(n=R(n,/s/g,"")),i=n,F&&"sticky"in D&&(a=!!n&&O(n,"y")>-1)&&U&&(n=R(n,/y/g,"")),S&&(s=function(e){for(var t,n=e.length,i=0,r="",a=[],s={},o=!1,l=!1,h=0,c="";i<=n;i++){if("\\"===(t=P(e,i)))t+=P(e,++i);else if("]"===t)o=!1;else if(!o)switch(!0){case"["===t:o=!0;break;case"("===t:C(I,L(e,i+1))&&(i+=2,l=!0),r+=t,h++;continue;case">"===t&&l:if(""===c||y(s,c))throw new A("Invalid capture group name");s[c]=!0,a[a.length]=[c,h],l=!1,c="";continue}l?c+=t:r+=t}return[r,a]}(t),t=s[0],b=s[1]),h=o(T(t,n),m?this:E,e),(r||a||b.length)&&(f=x(h),r&&(f.dotAll=!0,f.raw=e(function(e){for(var t,n=e.length,i=0,r="",a=!1;i<=n;i++)"\\"!==(t=P(e,i))?a||"."!==t?("["===t?a=!0:"]"===t&&(a=!1),r+=t):r+="[\\s\\S]":r+=t+P(e,++i);return r}(t),i)),a&&(f.sticky=!0),b.length&&(f.groups=b)),t!==_)try{l(h,"source",""===_?"(?:)":_)}catch(e){}return h},t=h(T),n=0;t.length>n;)m(e,T,t[n++]);E.constructor=e,e.prototype=E,g(r,"RegExp",e,{constructor:!0})}b("RegExp")})),Rte=J((()=>{var e=Kn(),t=mS(),n=ha(),i=Hs(),r=Ts().get,a=RegExp.prototype,s=TypeError;e&&t&&i(a,"dotAll",{configurable:!0,get:function(){if(this!==a){if("RegExp"===n(this))return!!r(this).dotAll;throw s("Incompatible receiver, RegExp required")}}})})),ux=J(((e,t)=>{"use strict";var n,i,r=wr(),a=en(),s=Mr(),o=pS(),l=lx(),h=_p(),c=no(),u=Ts().get,d=mS(),p=YO(),f=h("native-string-replace",String.prototype.replace),m=RegExp.prototype.exec,g=m,v=a("".charAt),y=a("".indexOf),x=a("".replace),b=a("".slice),_=(i=/b*/g,r(m,n=/a/,"a"),r(m,i,"a"),0!==n.lastIndex||0!==i.lastIndex),w=l.BROKEN_CARET,S=void 0!==/()??/.exec("")[1];(_||S||w||d||p)&&(g=function(e){var t,n,i,a,l,h,d,p=this,M=u(p),T=s(e),E=M.raw;if(E)return E.lastIndex=p.lastIndex,t=r(g,E,T),p.lastIndex=E.lastIndex,t;var A=M.groups,C=w&&p.sticky,P=r(o,p),R=p.source,O=0,L=T;if(C&&(P=x(P,"y",""),-1===y(P,"g")&&(P+="g"),L=b(T,p.lastIndex),p.lastIndex>0&&(!p.multiline||p.multiline&&"\n"!==v(T,p.lastIndex-1))&&(R="(?: "+R+")",L=" "+L,O++),n=new RegExp("^(?:"+R+")",P)),S&&(n=new RegExp("^"+R+"$(?!\\s)",P)),_&&(i=p.lastIndex),a=r(m,C?n:p,L),C?a?(a.input=b(a.input,O),a[0]=b(a[0],O),a.index=p.lastIndex,p.lastIndex+=a[0].length):p.lastIndex=0:_&&a&&(p.lastIndex=p.global?a.index+a[0].length:i),S&&a&&a.length>1&&r(f,a[0],n,(function(){for(l=1;l{"use strict";var e=tt(),t=ux();e({target:"RegExp",proto:!0,forced:/./.exec!==t},{exec:t})})),Dte=J((()=>{var e=Mn(),t=Kn(),n=Hs(),i=pS(),r=Yt(),a=e.RegExp,s=a.prototype;t&&r((function(){var e=!0;try{a(".","d")}catch(t){e=!1}var t={},n="",i=e?"dgimsy":"gimsy",r=function(e,i){Object.defineProperty(t,e,{get:function(){return n+=i,!0}})},o={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var l in e&&(o.hasIndices="d"),o)r(l,o[l]);return Object.getOwnPropertyDescriptor(s,"flags").get.call(t)!==i||n!==i}))&&n(s,"flags",{configurable:!0,get:i})})),kte=J((()=>{var e=Kn(),t=lx().MISSED_STICKY,n=ha(),i=Hs(),r=Ts().get,a=RegExp.prototype,s=TypeError;e&&t&&i(a,"sticky",{configurable:!0,get:function(){if(this!==a){if("RegExp"===n(this))return!!r(this).sticky;throw s("Incompatible receiver, RegExp required")}}})})),Bte=J((()=>{"use strict";xS();var e,t,n=tt(),i=wr(),r=Fr(),a=br(),s=Mr(),o=(e=!1,(t=/[ac]/).exec=function(){return e=!0,/./.exec.apply(this,arguments)},!0===t.test("abc")&&e),l=/./.test;n({target:"RegExp",proto:!0,forced:!o},{test:function(e){var t=a(this),n=s(e),o=t.exec;if(!r(o))return i(l,t,n);var h=i(o,t,n);return null!==h&&(a(h),!0)}})})),Vte=J((()=>{"use strict";var e=wp().PROPER,t=Yi(),n=br(),i=Mr(),r=Yt(),a=s0(),s="toString",o=RegExp.prototype[s],l=r((function(){return"/a/b"!=o.call({source:"a",flags:"b"})})),h=e&&o.name!=s;(l||h)&&t(RegExp.prototype,s,(function(){var e=n(this);return"/"+i(e.source)+"/"+i(a(e))}),{unsafe:!0})})),zte=J((()=>{"use strict";W1()("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),OD())})),Gte=J((()=>{zte()})),qte=J((()=>{"use strict";var e=tt(),t=en(),n=_s(),i=os(),r=Mr(),a=Yt(),s=t("".charAt);e({target:"String",proto:!0,forced:a((function(){return"\ud842"!=="\ud842\udfb7".at(-2)}))},{at:function(e){var t=r(n(this)),a=t.length,o=i(e),l=o>=0?o:a+o;return l<0||l>=a?void 0:s(t,l)}})})),hx=J(((e,t)=>{var n=en(),i=os(),r=Mr(),a=_s(),s=n("".charAt),o=n("".charCodeAt),l=n("".slice),h=function(e){return function(t,n){var h,c,u=r(a(t)),d=i(n),p=u.length;return d<0||d>=p?e?"":void 0:(h=o(u,d))<55296||h>56319||d+1===p||(c=o(u,d+1))<56320||c>57343?e?s(u,d):h:e?l(u,d,d+2):c-56320+(h-55296<<10)+65536}};t.exports={codeAt:h(!1),charAt:h(!0)}})),Yte=J((()=>{"use strict";var e=tt(),t=hx().codeAt;e({target:"String",proto:!0},{codePointAt:function(e){return t(this,e)}})})),bS=J(((e,t)=>{var n=i0(),i=TypeError;t.exports=function(e){if(n(e))throw i("The method doesn't accept regular expressions");return e}})),ES=J(((e,t)=>{var n=Br()("match");t.exports=function(e){var t=/./;try{"/./"[e](t)}catch(i){try{return t[n]=!1,"/./"[e](t)}catch(e){}}return!1}})),tne=J((()=>{"use strict";var e,t=tt(),n=xh(),i=Qs().f,r=to(),a=Mr(),s=bS(),o=_s(),l=ES(),h=as(),c=n("".endsWith),u=n("".slice),d=Math.min,p=l("endsWith");t({target:"String",proto:!0,forced:!(!h&&!p&&(e=i(String.prototype,"endsWith"),e&&!e.writable))&&!p},{endsWith:function(e){var t=a(o(this));s(e);var n=arguments.length>1?arguments[1]:void 0,i=t.length,l=void 0===n?i:d(r(n),i),h=a(e);return c?c(t,h,l):u(t,l-h.length,l)===h}})})),ine=J((()=>{var e=tt(),t=en(),n=lc(),i=RangeError,r=String.fromCharCode,a=String.fromCodePoint,s=t([].join);e({target:"String",stat:!0,arity:1,forced:!!a&&1!=a.length},{fromCodePoint:function(e){for(var t,a=[],o=arguments.length,l=0;o>l;){if(t=+arguments[l++],n(t,1114111)!==t)throw i(t+" is not a valid code point");a[l]=t<65536?r(t):r(55296+((t-=65536)>>10),t%1024+56320)}return s(a,"")}})})),ane=J((()=>{"use strict";var e=tt(),t=en(),n=bS(),i=_s(),r=Mr(),a=ES(),s=t("".indexOf);e({target:"String",proto:!0,forced:!a("includes")},{includes:function(e){return!!~s(r(i(this)),r(n(e)),arguments.length>1?arguments[1]:void 0)}})})),sk=J((()=>{"use strict";var e=hx().charAt,t=Mr(),n=Ts(),i=Mw(),r=N1(),a="String Iterator",s=n.set,o=n.getterFor(a);i(String,"String",(function(e){s(this,{type:a,string:t(e),index:0})}),(function(){var t,n=o(this),i=n.string,a=n.index;return a>=i.length?r(void 0,!0):(t=e(i,a),n.index+=t.length,r(t,!1))}))})),dx=J(((e,t)=>{"use strict";xS();var n=xh(),i=Yi(),r=ux(),a=Yt(),s=Br(),o=da(),l=s("species"),h=RegExp.prototype;t.exports=function(e,t,c,u){var d=s(e),p=!a((function(){var t={};return t[d]=function(){return 7},7!=""[e](t)})),f=p&&!a((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[l]=function(){return n},n.flags="",n[d]=/./[d]),n.exec=function(){return t=!0,null},n[d](""),!t}));if(!p||!f||c){var m=n(/./[d]),g=t(d,""[e],(function(e,t,i,a,s){var o=n(e),l=t.exec;return l===r||l===h.exec?p&&!s?{done:!0,value:m(t,i,a)}:{done:!0,value:o(i,t,a)}:{done:!1}}));i(String.prototype,e,g[0]),i(h,d,g[1])}u&&o(h[d],"sham",!0)}})),fx=J(((e,t)=>{"use strict";var n=hx().charAt;t.exports=function(e,t,i){return t+(i?n(e,t).length:1)}})),l0=J(((e,t)=>{var n=wr(),i=br(),r=Fr(),a=ha(),s=ux(),o=TypeError;t.exports=function(e,t){var l=e.exec;if(r(l)){var h=n(l,e,t);return null!==h&&i(h),h}if("RegExp"===a(e))return n(s,e,t);throw o("RegExp#exec called on incompatible receiver")}})),xne=J((()=>{"use strict";var e=wr(),t=dx(),n=br(),i=La(),r=to(),a=Mr(),s=_s(),o=au(),l=fx(),h=l0();t("match",(function(t,c,u){return[function(n){var r=s(this),l=i(n)?void 0:o(n,t);return l?e(l,n,r):new RegExp(n)[t](a(r))},function(e){var t=n(this),i=a(e),s=u(c,t,i);if(s.done)return s.value;if(!t.global)return h(t,i);var o=t.unicode;t.lastIndex=0;for(var d,p=[],f=0;null!==(d=h(t,i));){var m=a(d[0]);p[f]=m,""===m&&(t.lastIndex=l(i,r(t.lastIndex),o)),f++}return 0===f?null:p}]}))})),Cne=J((()=>{"use strict";var e=tt(),t=wr(),n=xh(),i=Tw(),r=N1(),a=_s(),s=to(),o=Mr(),l=br(),h=La(),c=ha(),u=i0(),d=s0(),p=au(),f=Yi(),m=Yt(),g=Br(),v=kp(),y=fx(),x=l0(),b=Ts(),_=as(),w=g("matchAll"),S="RegExp String",M=S+" Iterator",T=b.set,E=b.getterFor(M),A=RegExp.prototype,C=TypeError,P=n("".indexOf),R=n("".matchAll),O=!!R&&!m((function(){R("a",/./)})),L=i((function(e,t,n,i){T(this,{type:M,regexp:e,string:t,global:n,unicode:i,done:!1})}),S,(function(){var e=E(this);if(e.done)return r(void 0,!0);var t=e.regexp,n=e.string,i=x(t,n);return null===i?(e.done=!0,r(void 0,!0)):e.global?(""===o(i[0])&&(t.lastIndex=y(n,s(t.lastIndex),e.unicode)),r(i,!1)):(e.done=!0,r(i,!1))})),I=function(e){var t,n,i,r=l(this),a=o(e),h=v(r,RegExp),c=o(d(r));return t=new h(h===RegExp?r.source:r,c),n=!!~P(c,"g"),i=!!~P(c,"u"),t.lastIndex=s(r.lastIndex),new L(t,a,n,i)};e({target:"String",proto:!0,forced:O},{matchAll:function(e){var n,i,r,s,l=a(this);if(h(e)){if(O)return R(l,e)}else{if(u(e)&&(n=o(a(d(e))),!~P(n,"g")))throw C("`.matchAll` does not allow non-global regexes");if(O)return R(l,e);if(void 0===(r=p(e,w))&&_&&"RegExp"==c(e)&&(r=I),r)return t(r,e,l)}return i=o(l),s=new RegExp(e,"g"),_?t(I,s,i):s[w](i)}}),_||w in A||f(A,w,I)})),dk=J(((e,t)=>{var n=iu();t.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(n)})),Ine=J((()=>{"use strict";var e=tt(),t=Ww().end;e({target:"String",proto:!0,forced:dk()},{padEnd:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),Lne=J((()=>{"use strict";var e=tt(),t=Ww().start;e({target:"String",proto:!0,forced:dk()},{padStart:function(e){return t(this,e,arguments.length>1?arguments[1]:void 0)}})})),Fne=J((()=>{var e=tt(),t=en(),n=Ls(),i=ci(),r=Mr(),a=fi(),s=t([].push),o=t([].join);e({target:"String",stat:!0},{raw:function(e){var t=n(i(e).raw),l=a(t);if(!l)return"";for(var h=arguments.length,c=[],u=0;;){if(s(c,r(t[u++])),u===l)return o(c,"");u{tt()({target:"String",proto:!0},{repeat:G1()})})),gk=J(((e,t)=>{var n=en(),i=ci(),r=Math.floor,a=n("".charAt),s=n("".replace),o=n("".slice),l=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,h=/\$([$&'`]|\d{1,2})/g;t.exports=function(e,t,n,c,u,d){var p=n+e.length,f=c.length,m=h;return void 0!==u&&(u=i(u),m=l),s(d,m,(function(i,s){var l;switch(a(s,0)){case"$":return"$";case"&":return e;case"`":return o(t,0,n);case"'":return o(t,p);case"<":l=u[o(s,1,-1)];break;default:var h=+s;if(0===h)return i;if(h>f){var d=r(h/10);return 0===d?i:d<=f?void 0===c[d-1]?a(s,1):c[d-1]+a(s,1):i}l=c[h-1]}return void 0===l?"":l}))}})),Gne=J((()=>{"use strict";var e=No(),t=wr(),n=en(),i=dx(),r=Yt(),a=br(),s=Fr(),o=La(),l=os(),h=to(),c=Mr(),u=_s(),d=fx(),p=au(),f=gk(),m=l0(),g=Br()("replace"),v=Math.max,y=Math.min,x=n([].concat),b=n([].push),_=n("".indexOf),w=n("".slice),S=function(e){return void 0===e?e:String(e)},M="$0"==="a".replace(/./,"$0"),T=!!/./[g]&&""===/./[g]("a","$0");i("replace",(function(n,i,r){var M=T?"$":"$0";return[function(e,n){var r=u(this),a=o(e)?void 0:p(e,g);return a?t(a,e,r,n):t(i,c(r),e,n)},function(t,n){var o=a(this),u=c(t);if("string"==typeof n&&-1===_(n,M)&&-1===_(n,"$<")){var p=r(i,o,u,n);if(p.done)return p.value}var g=s(n);g||(n=c(n));var T=o.global;if(T){var E=o.unicode;o.lastIndex=0}for(var A=[];;){var C=m(o,u);if(null===C||(b(A,C),!T))break;""===c(C[0])&&(o.lastIndex=d(u,h(o.lastIndex),E))}for(var P="",R=0,O=0;O=R&&(P+=w(u,R,I)+U,R=I+L.length)}return P+w(u,R)}]}),!!r((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$")}))||!M||T)})),Yne=J((()=>{"use strict";var e=tt(),t=wr(),n=en(),i=_s(),r=Fr(),a=La(),s=i0(),o=Mr(),l=au(),h=s0(),c=gk(),u=Br(),d=as(),p=u("replace"),f=TypeError,m=n("".indexOf),g=n("".replace),v=n("".slice),y=Math.max,x=function(e,t,n){return n>e.length?-1:""===t?n:m(e,t,n)};e({target:"String",proto:!0},{replaceAll:function(e,n){var u,b,_,w,S,M,T,E,A,C=i(this),P=0,R=0,O="";if(!a(e)){if((u=s(e))&&(b=o(i(h(e))),!~m(b,"g")))throw f("`.replaceAll` does not allow non-global regexes");if(_=l(e,p))return t(_,e,C,n);if(d&&u)return g(o(C),e,n)}for(w=o(C),S=o(e),(M=r(n))||(n=o(n)),T=S.length,E=y(1,T),P=x(w,S,0);-1!==P;)A=M?o(n(S,P,w)):c(S,w,P,[],void 0,n),O+=v(w,R,P)+A,R=P+T,P=x(w,S,P+E);return R{"use strict";var e=wr(),t=dx(),n=br(),i=La(),r=_s(),a=iO(),s=Mr(),o=au(),l=l0();t("search",(function(t,h,c){return[function(n){var a=r(this),l=i(n)?void 0:o(n,t);return l?e(l,n,a):new RegExp(n)[t](s(a))},function(e){var t=n(this),i=s(e),r=c(h,t,i);if(r.done)return r.value;var o=t.lastIndex;a(o,0)||(t.lastIndex=0);var u=l(t,i);return a(t.lastIndex,o)||(t.lastIndex=o),null===u?-1:u.index}]}))})),rre=J((()=>{"use strict";var e=No(),t=wr(),n=en(),i=dx(),r=br(),a=La(),s=i0(),o=_s(),l=kp(),h=fx(),c=to(),u=Mr(),d=au(),p=Lg(),f=l0(),m=ux(),g=lx(),v=Yt(),y=g.UNSUPPORTED_Y,x=4294967295,b=Math.min,_=[].push,w=n(/./.exec),S=n(_),M=n("".slice);i("split",(function(n,i,g){var v;return v="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(n,r){var a=u(o(this)),l=void 0===r?x:r>>>0;if(0===l)return[];if(void 0===n)return[a];if(!s(n))return t(i,a,n,l);for(var h,c,d,f=[],g=(n.ignoreCase?"i":"")+(n.multiline?"m":"")+(n.unicode?"u":"")+(n.sticky?"y":""),v=0,y=new RegExp(n.source,g+"g");(h=t(m,y,a))&&!((c=y.lastIndex)>v&&(S(f,M(a,v,h.index)),h.length>1&&h.index=l));)y.lastIndex===h.index&&y.lastIndex++;return v===a.length?(d||!w(y,""))&&S(f,""):S(f,M(a,v)),f.length>l?p(f,0,l):f}:"0".split(void 0,0).length?function(e,n){return void 0===e&&0===n?[]:t(i,this,e,n)}:i,[function(e,i){var r=o(this),s=a(e)?void 0:d(e,n);return s?t(s,e,r,i):t(v,u(r),e,i)},function(e,t){var n=r(this),a=u(e),s=g(v,n,a,t,v!==i);if(s.done)return s.value;var o=l(n,RegExp),d=n.unicode,p=(n.ignoreCase?"i":"")+(n.multiline?"m":"")+(n.unicode?"u":"")+(y?"g":"y"),m=new o(y?"^(?:"+n.source+")":n,p),_=void 0===t?x:t>>>0;if(0===_)return[];if(0===a.length)return null===f(m,a)?[a]:[];for(var w=0,T=0,E=[];T{"use strict";var e,t=tt(),n=xh(),i=Qs().f,r=to(),a=Mr(),s=bS(),o=_s(),l=ES(),h=as(),c=n("".startsWith),u=n("".slice),d=Math.min,p=l("startsWith");t({target:"String",proto:!0,forced:!(!h&&!p&&(e=i(String.prototype,"startsWith"),e&&!e.writable))&&!p},{startsWith:function(e){var t=a(o(this));s(e);var n=r(d(arguments.length>1?arguments[1]:void 0,t.length)),i=a(e);return c?c(t,i,n):u(t,n,n+i.length)===i}})})),ure=J((()=>{"use strict";var e=tt(),t=en(),n=_s(),i=os(),r=Mr(),a=t("".slice),s=Math.max,o=Math.min;e({target:"String",proto:!0,forced:!"".substr||"b"!=="ab".substr(-1)},{substr:function(e,t){var l,h,c=r(n(this)),u=c.length,d=i(e);return d===1/0&&(d=0),d<0&&(d=s(u+d,0)),(l=void 0===t?u:i(t))<=0||l===1/0||d>=(h=o(d+l,u))?"":a(c,d,h)}})})),MS=J(((e,t)=>{var n=wp().PROPER,i=Yt(),r=Z1();t.exports=function(e){return i((function(){return!!r[e]()||"\u200b\x85\u180e"!=="\u200b\x85\u180e"[e]()||n&&r[e].name!==e}))}})),pre=J((()=>{"use strict";var e=tt(),t=Bp().trim;e({target:"String",proto:!0,forced:MS()("trim")},{trim:function(){return t(this)}})})),_k=J(((e,t)=>{"use strict";var n=Bp().end,i=MS();t.exports=i("trimEnd")?function(){return n(this)}:"".trimEnd})),vre=J((()=>{var e=tt(),t=_k();e({target:"String",proto:!0,name:"trimEnd",forced:"".trimRight!==t},{trimRight:t})})),xre=J((()=>{vre();var e=tt(),t=_k();e({target:"String",proto:!0,name:"trimEnd",forced:"".trimEnd!==t},{trimEnd:t})})),Tk=J(((e,t)=>{"use strict";var n=Bp().start,i=MS();t.exports=i("trimStart")?function(){return n(this)}:"".trimStart})),_re=J((()=>{var e=tt(),t=Tk();e({target:"String",proto:!0,name:"trimStart",forced:"".trimLeft!==t},{trimLeft:t})})),wre=J((()=>{_re();var e=tt(),t=Tk();e({target:"String",proto:!0,name:"trimStart",forced:"".trimStart!==t},{trimStart:t})})),ao=J(((e,t)=>{var n=en(),i=_s(),r=Mr(),a=/"/g,s=n("".replace);t.exports=function(e,t,n,o){var l=r(i(e)),h="<"+t;return""!==n&&(h+=" "+n+'="'+s(r(o),a,""")+'"'),h+">"+l+""}})),oo=J(((e,t)=>{var n=Yt();t.exports=function(e){return n((function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3}))}})),Are=J((()=>{"use strict";var e=tt(),t=ao();e({target:"String",proto:!0,forced:oo()("anchor")},{anchor:function(e){return t(this,"a","name",e)}})})),Cre=J((()=>{"use strict";var e=tt(),t=ao();e({target:"String",proto:!0,forced:oo()("big")},{big:function(){return t(this,"big","","")}})})),Pre=J((()=>{"use strict";var e=tt(),t=ao();e({target:"String",proto:!0,forced:oo()("blink")},{blink:function(){return t(this,"blink","","")}})})),Ire=J((()=>{"use strict";var e=tt(),t=ao();e({target:"String",proto:!0,forced:oo()("bold")},{bold:function(){return t(this,"b","","")}})})),Lre=J((()=>{"use strict";var e=tt(),t=ao();e({target:"String",proto:!0,forced:oo()("fixed")},{fixed:function(){return t(this,"tt","","")}})})),Dre=J((()=>{"use strict";var e=tt(),t=ao();e({target:"String",proto:!0,forced:oo()("fontcolor")},{fontcolor:function(e){return t(this,"font","color",e)}})})),Ore=J((()=>{"use strict";var e=tt(),t=ao();e({target:"String",proto:!0,forced:oo()("fontsize")},{fontsize:function(e){return t(this,"font","size",e)}})})),kre=J((()=>{"use strict";var e=tt(),t=ao();e({target:"String",proto:!0,forced:oo()("italics")},{italics:function(){return t(this,"i","","")}})})),Fre=J((()=>{"use strict";var e=tt(),t=ao();e({target:"String",proto:!0,forced:oo()("link")},{link:function(e){return t(this,"a","href",e)}})})),Nre=J((()=>{"use strict";var e=tt(),t=ao();e({target:"String",proto:!0,forced:oo()("small")},{small:function(){return t(this,"small","","")}})})),Bre=J((()=>{"use strict";var e=tt(),t=ao();e({target:"String",proto:!0,forced:oo()("strike")},{strike:function(){return t(this,"strike","","")}})})),Ure=J((()=>{"use strict";var e=tt(),t=ao();e({target:"String",proto:!0,forced:oo()("sub")},{sub:function(){return t(this,"sub","","")}})})),Hre=J((()=>{"use strict";var e=tt(),t=ao();e({target:"String",proto:!0,forced:oo()("sup")},{sup:function(){return t(this,"sup","","")}})})),RS=J(((e,t)=>{var n=Mn(),i=Yt(),r=O1(),a=Pr().NATIVE_ARRAY_BUFFER_VIEWS,s=n.ArrayBuffer,o=n.Int8Array;t.exports=!a||!i((function(){o(1)}))||!i((function(){new o(-1)}))||!r((function(e){new o,new o(null),new o(1.5),new o(e)}),!0)||i((function(){return 1!==new o(new s(2),1,void 0).length}))})),qre=J(((e,t)=>{var n=os(),i=RangeError;t.exports=function(e){var t=n(e);if(t<0)throw i("The argument can't be less than 0");return t}})),Sk=J(((e,t)=>{var n=qre(),i=RangeError;t.exports=function(e,t){var r=n(e);if(r%t)throw i("Wrong offset");return r}})),Mk=J(((e,t)=>{var n=cc();t.exports=function(e){var t=n(e);return"BigInt64Array"==t||"BigUint64Array"==t}})),AS=J(((e,t)=>{var n=v1(),i=TypeError;t.exports=function(e){var t=n(e,"number");if("number"==typeof t)throw i("Can't convert number to bigint");return BigInt(t)}})),Rk=J(((e,t)=>{var n=fl(),i=wr(),r=qw(),a=ci(),s=fi(),o=I1(),l=Bg(),h=yw(),c=Mk(),u=Pr().aTypedArrayConstructor,d=AS();t.exports=function(e){var t,p,f,m,g,v,y,x,b=r(this),_=a(e),w=arguments.length,S=w>1?arguments[1]:void 0,M=void 0!==S,T=l(_);if(T&&!h(T))for(x=(y=o(_,T)).next,_=[];!(v=i(x,y)).done;)_.push(v.value);for(M&&w>2&&(S=n(S,arguments[2])),p=s(_),f=new(u(b))(p),m=c(f),t=0;p>t;t++)g=M?S(_[t],t):_[t],f[t]=m?d(g):+g;return f}})),mu=J(((e,t)=>{"use strict";var n=tt(),i=Mn(),r=wr(),a=Kn(),s=RS(),o=Pr(),l=z1(),h=dc(),c=ko(),u=da(),d=tS(),p=to(),f=nD(),m=Sk(),g=vh(),v=$r(),y=cc(),x=Nr(),b=Od(),_=no(),w=Fo(),S=uc(),M=yh().f,T=Rk(),E=Vs().forEach,A=Dp(),C=Hs(),P=Gi(),R=Qs(),O=Ts(),L=Pp(),I=O.get,D=O.set,k=O.enforce,N=P.f,F=R.f,U=Math.round,B=i.RangeError,z=l.ArrayBuffer,H=z.prototype,V=l.DataView,j=o.NATIVE_ARRAY_BUFFER_VIEWS,G=o.TYPED_ARRAY_TAG,W=o.TypedArray,X=o.TypedArrayPrototype,Y=o.aTypedArrayConstructor,q=o.isTypedArray,J="BYTES_PER_ELEMENT",Z="Wrong length",K=function(e,t){Y(e);for(var n=0,i=t.length,r=new e(i);i>n;)r[n]=t[n++];return r},$=function(e,t){C(e,t,{configurable:!0,get:function(){return I(this)[t]}})},Q=function(e){var t;return w(H,e)||"ArrayBuffer"==(t=y(e))||"SharedArrayBuffer"==t},ee=function(e,t){return q(e)&&!b(t)&&t in e&&d(+t)&&t>=0},te=function(e,t){return t=g(t),ee(e,t)?c(2,e[t]):F(e,t)},ne=function(e,t,n){return t=g(t),!(ee(e,t)&&x(n)&&v(n,"value"))||v(n,"get")||v(n,"set")||n.configurable||v(n,"writable")&&!n.writable||v(n,"enumerable")&&!n.enumerable?N(e,t,n):(e[t]=n.value,e)};a?(j||(R.f=te,P.f=ne,$(X,"buffer"),$(X,"byteOffset"),$(X,"byteLength"),$(X,"length")),n({target:"Object",stat:!0,forced:!j},{getOwnPropertyDescriptor:te,defineProperty:ne}),t.exports=function(e,t,a){var o=e.match(/\d+/)[0]/8,l=e+(a?"Clamped":"")+"Array",c="get"+e,d="set"+e,g=i[l],v=g,y=v&&v.prototype,b={},w=function(e,t){N(e,t,{get:function(){return function(e,t){var n=I(e);return n.view[c](t*o+n.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,n){var i=I(e);a&&(n=(n=U(n))<0?0:n>255?255:255&n),i.view[d](t*o+i.byteOffset,n,!0)}(this,t,e)},enumerable:!0})};j?s&&(v=t((function(e,t,n,i){return h(e,y),L(x(t)?Q(t)?void 0!==i?new g(t,m(n,o),i):void 0!==n?new g(t,m(n,o)):new g(t):q(t)?K(v,t):r(T,v,t):new g(f(t)),e,v)})),S&&S(v,W),E(M(g),(function(e){e in v||u(v,e,g[e])})),v.prototype=y):(v=t((function(e,t,n,i){h(e,y);var a,s,l,c=0,u=0;if(x(t)){if(!Q(t))return q(t)?K(v,t):r(T,v,t);a=t,u=m(n,o);var d=t.byteLength;if(void 0===i){if(d%o||(s=d-u)<0)throw B(Z)}else if((s=p(i)*o)+u>d)throw B(Z);l=s/o}else l=f(t),a=new z(s=l*o);for(D(e,{buffer:a,byteOffset:u,byteLength:s,length:l,view:new V(a)});c{mu()("Float32",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),mie=J((()=>{mu()("Float64",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),gie=J((()=>{mu()("Int8",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),vie=J((()=>{mu()("Int16",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),yie=J((()=>{mu()("Int32",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),xie=J((()=>{mu()("Uint8",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),bie=J((()=>{mu()("Uint8",(function(e){return function(t,n,i){return e(this,t,n,i)}}),!0)})),Eie=J((()=>{mu()("Uint16",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),_ie=J((()=>{mu()("Uint32",(function(e){return function(t,n,i){return e(this,t,n,i)}}))})),wie=J((()=>{"use strict";var e=Pr(),t=fi(),n=os(),i=e.aTypedArray;(0,e.exportTypedArrayMethod)("at",(function(e){var r=i(this),a=t(r),s=n(e),o=s>=0?s:a+s;return o<0||o>=a?void 0:r[o]}))})),Mie=J((()=>{"use strict";var e=en(),t=Pr(),n=e(LL()),i=t.aTypedArray;(0,t.exportTypedArrayMethod)("copyWithin",(function(e,t){return n(i(this),e,t,arguments.length>2?arguments[2]:void 0)}))})),Aie=J((()=>{"use strict";var e=Pr(),t=Vs().every,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("every",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),Pie=J((()=>{"use strict";var e=Pr(),t=_w(),n=AS(),i=cc(),r=wr(),a=en(),s=Yt(),o=e.aTypedArray,l=e.exportTypedArrayMethod,h=a("".slice);l("fill",(function(e){var a=arguments.length;o(this);var s="Big"===h(i(this),0,3)?n(e):+e;return r(t,this,s,a>1?arguments[1]:void 0,a>2?arguments[2]:void 0)}),s((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e})))})),bx=J(((e,t)=>{var n=Pr(),i=kp(),r=n.aTypedArrayConstructor,a=n.getTypedArrayConstructor;t.exports=function(e){return r(i(e,a(e)))}})),Oie=J(((e,t)=>{var n=Iw(),i=bx();t.exports=function(e,t){return n(i(e),t)}})),Fie=J((()=>{"use strict";var e=Pr(),t=Vs().filter,n=Oie(),i=e.aTypedArray;(0,e.exportTypedArrayMethod)("filter",(function(e){var r=t(i(this),e,arguments.length>1?arguments[1]:void 0);return n(this,r)}))})),Bie=J((()=>{"use strict";var e=Pr(),t=Vs().find,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("find",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),Hie=J((()=>{"use strict";var e=Pr(),t=Vs().findIndex,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("findIndex",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),zie=J((()=>{"use strict";var e=Pr(),t=D1().findLast,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLast",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),qie=J((()=>{"use strict";var e=Pr(),t=D1().findLastIndex,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("findLastIndex",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),jie=J((()=>{"use strict";var e=Pr(),t=Vs().forEach,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("forEach",(function(e){t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),Xie=J((()=>{"use strict";var e=RS();(0,Pr().exportTypedArrayStaticMethod)("from",Rk(),e)})),$ie=J((()=>{"use strict";var e=Pr(),t=Cg().includes,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("includes",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),Kie=J((()=>{"use strict";var e=Pr(),t=Cg().indexOf,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("indexOf",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),nse=J((()=>{"use strict";var e=Mn(),t=Yt(),n=en(),i=Pr(),r=B1(),a=Br()("iterator"),s=e.Uint8Array,o=n(r.values),l=n(r.keys),h=n(r.entries),c=i.aTypedArray,u=i.exportTypedArrayMethod,d=s&&s.prototype,p=!t((function(){d[a].call([1])})),f=!!d&&d.values&&d[a]===d.values&&"values"===d.values.name,m=function(){return o(c(this))};u("entries",(function(){return h(c(this))}),p),u("keys",(function(){return l(c(this))}),p),u("values",m,p||!f,{name:"values"}),u(a,m,p||!f,{name:"values"})})),ise=J((()=>{"use strict";var e=Pr(),t=en(),n=e.aTypedArray,i=e.exportTypedArrayMethod,r=t([].join);i("join",(function(e){return r(n(this),e)}))})),ase=J((()=>{"use strict";var e=Pr(),t=No(),n=XL(),i=e.aTypedArray;(0,e.exportTypedArrayMethod)("lastIndexOf",(function(e){var r=arguments.length;return t(n,i(this),r>1?[e,arguments[1]]:[e])}))})),lse=J((()=>{"use strict";var e=Pr(),t=Vs().map,n=bx(),i=e.aTypedArray;(0,e.exportTypedArrayMethod)("map",(function(e){return t(i(this),e,arguments.length>1?arguments[1]:void 0,(function(e,t){return new(n(e))(t)}))}))})),use=J((()=>{"use strict";var e=Pr(),t=RS(),n=e.aTypedArrayConstructor;(0,e.exportTypedArrayStaticMethod)("of",(function(){for(var e=0,t=arguments.length,i=new(n(this))(t);t>e;)i[e]=arguments[e++];return i}),t)})),dse=J((()=>{"use strict";var e=Pr(),t=U1().left,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("reduce",(function(e){var i=arguments.length;return t(n(this),e,i,i>1?arguments[1]:void 0)}))})),pse=J((()=>{"use strict";var e=Pr(),t=U1().right,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("reduceRight",(function(e){var i=arguments.length;return t(n(this),e,i,i>1?arguments[1]:void 0)}))})),gse=J((()=>{"use strict";var e=Pr(),t=e.aTypedArray,n=e.exportTypedArrayMethod,i=Math.floor;n("reverse",(function(){for(var e,n=this,r=t(n).length,a=i(r/2),s=0;s{"use strict";var e=Mn(),t=wr(),n=Pr(),i=fi(),r=Sk(),a=ci(),s=Yt(),o=e.RangeError,l=e.Int8Array,h=l&&l.prototype,c=h&&h.set,u=n.aTypedArray,d=n.exportTypedArrayMethod,p=!s((function(){var e=new Uint8ClampedArray(2);return t(c,e,{length:1,0:3},1),3!==e[1]})),f=p&&n.NATIVE_ARRAY_BUFFER_VIEWS&&s((function(){var e=new l(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));d("set",(function(e){u(this);var n=r(arguments.length>1?arguments[1]:void 0,1),s=a(e);if(p)return t(c,this,s,n);var l=this.length,h=i(s),d=0;if(h+n>l)throw o("Wrong length");for(;d{"use strict";var e=Pr(),t=bx(),n=Yt(),i=Nd(),r=e.aTypedArray;(0,e.exportTypedArrayMethod)("slice",(function(e,n){for(var a=i(r(this),e,n),s=t(this),o=0,l=a.length,h=new s(l);l>o;)h[o]=a[o++];return h}),n((function(){new Int8Array(1).slice()})))})),Mse=J((()=>{"use strict";var e=Pr(),t=Vs().some,n=e.aTypedArray;(0,e.exportTypedArrayMethod)("some",(function(e){return t(n(this),e,arguments.length>1?arguments[1]:void 0)}))})),Lse=J((()=>{"use strict";var e=Mn(),t=xh(),n=Yt(),i=ss(),r=Cw(),a=Pr(),s=ZL(),o=KL(),l=su(),h=Pw(),c=a.aTypedArray,u=a.exportTypedArrayMethod,d=e.Uint16Array,p=d&&t(d.prototype.sort),f=!(!p||n((function(){p(new d(2),null)}))&&n((function(){p(new d(2),{})}))),m=!!p&&!n((function(){if(l)return l<74;if(s)return s<67;if(o)return!0;if(h)return h<602;var e,t,n=new d(516),i=Array(516);for(e=0;e<516;e++)t=e%4,n[e]=515-e,i[e]=e-2*t+3;for(p(n,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(n[e]!==i[e])return!0}));u("sort",(function(e){return void 0!==e&&i(e),m?p(this,e):r(c(this),(t=e,function(e,n){return void 0!==t?+t(e,n)||0:n!=n?-1:e!=e?1:0===e&&0===n?1/e>0&&1/n<0?1:-1:e>n}));var t}),!m||f)})),kse=J((()=>{"use strict";var e=Pr(),t=to(),n=lc(),i=bx(),r=e.aTypedArray;(0,e.exportTypedArrayMethod)("subarray",(function(e,a){var s=r(this),o=s.length,l=n(e,o);return new(i(s))(s.buffer,s.byteOffset+l*s.BYTES_PER_ELEMENT,t((void 0===a?o:n(a,o))-l))}))})),Hse=J((()=>{"use strict";var e=Mn(),t=No(),n=Pr(),i=Yt(),r=Nd(),a=e.Int8Array,s=n.aTypedArray,o=n.exportTypedArrayMethod,l=[].toLocaleString,h=!!a&&i((function(){l.call(new a(1))}));o("toLocaleString",(function(){return t(l,h?r(s(this)):s(this),r(arguments))}),i((function(){return[1,2].toLocaleString()!=new a([1,2]).toLocaleString()}))||!i((function(){a.prototype.toLocaleString.call([1,2])})))})),Vse=J((()=>{"use strict";var e=eD(),t=Pr(),n=t.aTypedArray,i=t.exportTypedArrayMethod,r=t.getTypedArrayConstructor;i("toReversed",(function(){return e(n(this),r(this))}))})),zse=J((()=>{"use strict";var e=Pr(),t=en(),n=ss(),i=Iw(),r=e.aTypedArray,a=e.getTypedArrayConstructor,s=e.exportTypedArrayMethod,o=t(e.TypedArrayPrototype.sort);s("toSorted",(function(e){void 0!==e&&n(e);var t=r(this),s=i(a(t),t);return o(s,e)}))})),qse=J((()=>{"use strict";var e=Pr().exportTypedArrayMethod,t=Yt(),n=Mn(),i=en(),r=n.Uint8Array,a=r&&r.prototype||{},s=[].toString,o=i([].join);t((function(){s.call({})}))&&(s=function(){return o(this)});var l=a.toString!=s;e("toString",s,l)})),Wse=J((()=>{"use strict";var e=tD(),t=Pr(),n=Mk(),i=os(),r=AS(),a=t.aTypedArray,s=t.getTypedArrayConstructor;(0,t.exportTypedArrayMethod)("with",(function(t,o){var l=a(this),h=i(t),c=n(l)?r(o):+o;return e(l,s(l),h,c)}),!function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(e){return 8===e}}())})),Zse=J((()=>{"use strict";var e=tt(),t=en(),n=Mr(),i=String.fromCharCode,r=t("".charAt),a=t(/./.exec),s=t("".slice),o=/^[\da-f]{2}$/i,l=/^[\da-f]{4}$/i;e({global:!0},{unescape:function(e){for(var t,h,c=n(e),u="",d=c.length,p=0;p{"use strict";var n=en(),i=Vg(),r=Wd().getWeakData,a=dc(),s=br(),o=La(),l=Nr(),h=hc(),c=Vs(),u=$r(),d=Ts(),p=d.set,f=d.getterFor,m=c.find,g=c.findIndex,v=n([].splice),y=0,x=function(e){return e.frozen||(e.frozen=new b)},b=function(){this.entries=[]},_=function(e,t){return m(e.entries,(function(e){return e[0]===t}))};b.prototype={get:function(e){var t=_(this,e);if(t)return t[1]},has:function(e){return!!_(this,e)},set:function(e,t){var n=_(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=g(this.entries,(function(t){return t[0]===e}));return~t&&v(this.entries,t,1),!!~t}},t.exports={getConstructor:function(e,t,n,c){var d=e((function(e,i){a(e,m),p(e,{type:t,id:y++,frozen:void 0}),o(i)||h(i,e[c],{that:e,AS_ENTRIES:n})})),m=d.prototype,g=f(t),v=function(e,t,n){var i=g(e),a=r(s(t),!0);return!0===a?x(i).set(t,n):a[i.id]=n,e};return i(m,{delete:function(e){var t=g(this);if(!l(e))return!1;var n=r(e);return!0===n?x(t).delete(e):n&&u(n,t.id)&&delete n[t.id]},has:function(e){var t=g(this);if(!l(e))return!1;var n=r(e);return!0===n?x(t).has(e):n&&u(n,t.id)}}),i(m,n?{get:function(e){var t=g(this);if(l(e)){var n=r(e);return!0===n?x(t).get(e):n?n[t.id]:void 0}},set:function(e,t){return v(this,e,t)}}:{add:function(e){return v(this,e,!0)}}),d}}})),dae=J((()=>{"use strict";var e,t,n,i,r=Np(),a=Mn(),s=en(),o=Vg(),l=Wd(),h=W1(),c=Zk(),u=Nr(),d=Ts().enforce,p=Yt(),f=O3(),m=Object,g=Array.isArray,v=m.isExtensible,y=m.isFrozen,x=m.isSealed,b=m.freeze,_=m.seal,w={},S={},M=!a.ActiveXObject&&"ActiveXObject"in a,T=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},E=h("WeakMap",T,c),A=E.prototype,C=s(A.set);f&&(M?(e=c.getConstructor(T,"WeakMap",!0),l.enable(),t=s(A.delete),n=s(A.has),i=s(A.get),o(A,{delete:function(n){if(u(n)&&!v(n)){var i=d(this);return i.frozen||(i.frozen=new e),t(this,n)||i.frozen.delete(n)}return t(this,n)},has:function(t){if(u(t)&&!v(t)){var i=d(this);return i.frozen||(i.frozen=new e),n(this,t)||i.frozen.has(t)}return n(this,t)},get:function(t){if(u(t)&&!v(t)){var r=d(this);return r.frozen||(r.frozen=new e),n(this,t)?i(this,t):r.frozen.get(t)}return i(this,t)},set:function(t,i){if(u(t)&&!v(t)){var r=d(this);r.frozen||(r.frozen=new e),n(this,t)?C(this,t,i):r.frozen.set(t,i)}else C(this,t,i);return this}})):r&&p((function(){var e=b([]);return C(new E,e,1),!y(e)}))&&o(A,{set:function(e,t){var n;return g(e)&&(y(e)?n=w:x(e)&&(n=S)),C(this,e,t),n==w&&b(e),n==S&&_(e),this}}))})),fae=J((()=>{dae()})),pae=J((()=>{"use strict";W1()("WeakSet",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),Zk())})),mae=J((()=>{pae()})),Qk=J(((e,t)=>{var n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r={};for(n=0;n<66;n++)r[i.charAt(n)]=n;t.exports={itoc:i,ctoi:r}})),wae=J((()=>{var e=tt(),t=Mn(),n=ki(),i=en(),r=wr(),a=Yt(),s=Mr(),o=$r(),l=pu(),h=Qk().ctoi,c=/[^\d+/a-z]/i,u=/[\t\n\f\r ]+/g,d=/[=]{1,2}$/,p=n("atob"),f=String.fromCharCode,m=i("".charAt),g=i("".replace),v=i(c.exec),y=a((function(){return""!==p(" ")})),x=!a((function(){p("a")})),b=!y&&!x&&!a((function(){p()})),_=!y&&!x&&1!==p.length;e({global:!0,bind:!0,enumerable:!0,forced:y||x||b||_},{atob:function(e){if(l(arguments.length,1),b||_)return r(p,t,e);var i,a,y=g(s(e),u,""),x="",w=0,S=0;if(y.length%4==0&&(y=g(y,d,"")),y.length%4==1||v(c,y))throw new(n("DOMException"))("The string is not correctly encoded","InvalidCharacterError");for(;i=m(y,w++);)o(h,i)&&(a=S%4?64*a+h[i]:h[i],S++%4&&(x+=f(255&a>>(-2*S&6))));return x}})})),Dae=J((()=>{var e=tt(),t=Mn(),n=ki(),i=en(),r=wr(),a=Yt(),s=Mr(),o=pu(),l=Qk().itoc,h=n("btoa"),c=i("".charAt),u=i("".charCodeAt),d=!!h&&!a((function(){h()})),p=!!h&&a((function(){return"bnVsbA=="!==h(null)})),f=!!h&&1!==h.length;e({global:!0,bind:!0,enumerable:!0,forced:d||p||f},{btoa:function(e){if(o(arguments.length,1),d||p||f)return r(h,t,s(e));for(var i,a,m=s(e),g="",v=0,y=l;c(m,v)||(y="=",v%1);){if((a=u(m,v+=3/4))>255)throw new(n("DOMException"))("The string contains characters outside of the Latin1 range","InvalidCharacterError");g+=c(y,63&(i=i<<8|a)>>8-v%1*8)}return g}})})),sF=J(((e,t)=>{t.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}})),oF=J(((e,t)=>{var n=y1()("span").classList,i=n&&n.constructor&&n.constructor.prototype;t.exports=i===Object.prototype?void 0:i})),Hae=J((()=>{var e,t=Mn(),n=sF(),i=oF(),r=FL(),a=da(),s=function(e){if(e&&e.forEach!==r)try{a(e,"forEach",r)}catch(t){e.forEach=r}};for(e in n)n[e]&&s(t[e]&&t[e].prototype);s(i)})),jae=J((()=>{var e,t=Mn(),n=sF(),i=oF(),r=B1(),a=da(),s=Br(),o=s("iterator"),l=s("toStringTag"),h=r.values,c=function(e,t){if(e){if(e[o]!==h)try{a(e,o,h)}catch(t){e[o]=h}if(e[l]||a(e,l,t),n[t])for(var i in r)if(e[i]!==r[i])try{a(e,i,r[i])}catch(t){e[i]=r[i]}}};for(e in n)c(t[e]&&t[e].prototype,e);c(i,"DOMTokenList")})),Yae=J(((e,t)=>{var n=uu();t.exports=function(e){try{if(n)return Function('return require("'+e+'")')()}catch(e){}}})),dF=J(((e,t)=>{t.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}})),aoe=J((()=>{"use strict";var e=tt(),t=Yae(),n=ki(),i=Yt(),r=no(),a=ko(),s=Gi().f,o=Yi(),l=Hs(),h=$r(),c=dc(),u=br(),d=_L(),p=Fg(),f=dF(),m=pw(),g=Ts(),v=Kn(),y=as(),x="DOMException",b="DATA_CLONE_ERR",_=n("Error"),w=n(x)||function(){try{(new(n("MessageChannel")||t("worker_threads").MessageChannel)).port1.postMessage(new WeakMap)}catch(e){if(e.name==b&&25==e.code)return e.constructor}}(),S=w&&w.prototype,M=_.prototype,T=g.set,E=g.getterFor(x),A="stack"in _(x),C=function(e){return h(f,e)&&f[e].m?f[e].c:0},P=function(){c(this,R);var e=arguments.length,t=p(e<1?void 0:arguments[0]),n=p(e<2?void 0:arguments[1],"Error"),i=C(n);if(T(this,{type:x,name:n,message:t,code:i}),v||(this.name=n,this.message=t,this.code=i),A){var r=_(t);r.name=x,s(this,"stack",a(1,m(r.stack,1)))}},R=P.prototype=r(M),O=function(e){return{enumerable:!0,configurable:!0,get:e}},L=function(e){return O((function(){return E(this)[e]}))};v&&(l(R,"code",L("code")),l(R,"message",L("message")),l(R,"name",L("name"))),s(R,"constructor",a(1,P));var I=i((function(){return!(new w instanceof _)})),D=I||i((function(){return M.toString!==d||"2: 1"!==String(new w(1,2))})),k=I||i((function(){return 25!==new w(1,"DataCloneError").code})),N=I||25!==w[b]||25!==S[b],F=y?D||k||N:I;e({global:!0,constructor:!0,forced:F},{DOMException:F?P:w});var U,B,z,H,V=n(x),j=V.prototype;for(H in D&&(y||w===V)&&o(j,"toString",d),k&&v&&w===V&&l(j,"code",O((function(){return C(u(this).name)}))),f)h(f,H)&&(B=(U=f[H]).s,z=a(6,U.c),h(V,B)||s(V,B,z),h(j,B)||s(j,B,z))})),foe=J((()=>{"use strict";var e=tt(),t=Mn(),n=ki(),i=ko(),r=Gi().f,a=$r(),s=dc(),o=Pp(),l=Fg(),h=dF(),c=pw(),u=Kn(),d=as(),p="DOMException",f=n("Error"),m=n(p),g=function(){s(this,v);var e=arguments.length,t=l(e<1?void 0:arguments[0]),n=l(e<2?void 0:arguments[1],"Error"),a=new m(t,n),h=f(t);return h.name=p,r(a,"stack",i(1,c(h.stack,1))),o(a,this,g),a},v=g.prototype=m.prototype,y="stack"in f(p),x="stack"in new m(1,2),b=m&&u&&Object.getOwnPropertyDescriptor(t,p),_=!(!b||b.writable&&b.configurable),w=y&&!_&&!x;e({global:!0,constructor:!0,forced:d||w},{DOMException:w?g:m});var S,M,T,E=n(p),A=E.prototype;if(A.constructor!==E)for(T in d||r(A,"constructor",i(1,E)),h)a(h,T)&&(a(E,M=(S=h[T]).s)||r(E,M,i(6,S.c)))})),moe=J((()=>{var e=ki(),t="DOMException";ro()(e(t),t)})),voe=J((()=>{var e=tt(),t=Mn(),n=rx().clear;e({global:!0,bind:!0,enumerable:!0,forced:t.clearImmediate!==n},{clearImmediate:n})})),xoe=J(((e,t)=>{t.exports="function"==typeof Bun&&Bun&&"string"==typeof Bun.version})),eM=J(((e,t)=>{"use strict";var n,i=Mn(),r=No(),a=Fr(),s=xoe(),o=iu(),l=Nd(),h=pu(),c=i.Function,u=/MSIE .\./.test(o)||s&&((n=i.Bun.version.split(".")).length<3||0==n[0]&&(n[1]<3||3==n[1]&&0==n[2]));t.exports=function(e,t){var n=t?2:1;return u?function(i,s){var o=h(arguments.length,1)>n,u=a(i)?i:c(i),d=o?l(arguments,n):[],p=o?function(){r(u,this,d)}:u;return t?e(p,s):e(p)}:e}})),Soe=J((()=>{var e=tt(),t=Mn(),n=rx().set,i=eM(),r=t.setImmediate?i(n,!1):n;e({global:!0,bind:!0,enumerable:!0,forced:t.setImmediate!==r},{setImmediate:r})})),Moe=J((()=>{voe(),Soe()})),Roe=J((()=>{var e=tt(),t=Mn(),n=wO(),i=ss(),r=pu(),a=uu(),s=t.process;e({global:!0,enumerable:!0,dontCallGetSet:!0},{queueMicrotask:function(e){r(arguments.length,1),i(e);var t=a&&s.domain;n(t?t.bind(e):e)}})})),Coe=J((()=>{"use strict";var e,t=tt(),n=Mn(),i=Hs(),r=Kn(),a=TypeError,s=Object.defineProperty,o=n.self!==n;try{r?(e=Object.getOwnPropertyDescriptor(n,"self"),(o||!e||!e.get||!e.enumerable)&&i(n,"self",{get:function(){return n},set:function(e){if(this!==n)throw a("Illegal invocation");s(n,"self",{value:e,writable:!0,configurable:!0,enumerable:!0})},configurable:!0,enumerable:!0})):t({global:!0,simple:!0,forced:o},{self:n})}catch(e){}})),Ioe=J(((e,t)=>{var n=en(),i=Map.prototype;t.exports={Map:Map,set:n(i.set),get:n(i.get),has:n(i.has),remove:n(i.delete),proto:i}})),Doe=J(((e,t)=>{var n=en(),i=Set.prototype;t.exports={Set:Set,add:n(i.add),has:n(i.has),remove:n(i.delete),proto:i}})),Foe=J(((e,t)=>{var n=Mn(),i=Yt(),r=su(),a=SO(),s=aS(),o=uu(),l=n.structuredClone;t.exports=!!l&&!i((function(){if(s&&r>92||o&&r>94||a&&r>97)return!1;var e=new ArrayBuffer(8),t=l(e,{transfer:[e]});return 0!=e.byteLength||8!=t.byteLength}))})),Woe=J((()=>{var e,t=as(),n=tt(),i=Mn(),r=ki(),a=en(),s=Yt(),o=Tp(),l=Fr(),h=Mp(),c=La(),u=Nr(),d=Od(),p=hc(),f=br(),m=cc(),g=$r(),v=ou(),y=da(),x=fi(),b=pu(),_=s0(),w=Ioe(),S=Doe(),M=vL(),T=Foe(),E=i.Object,A=i.Array,C=i.Date,P=i.Error,R=i.EvalError,O=i.RangeError,L=i.ReferenceError,I=i.SyntaxError,D=i.TypeError,k=i.URIError,N=i.PerformanceMark,F=i.WebAssembly,U=F&&F.CompileError||P,B=F&&F.LinkError||P,z=F&&F.RuntimeError||P,H=r("DOMException"),V=w.Map,j=w.has,G=w.get,W=w.set,X=S.Set,Y=S.add,q=r("Object","keys"),J=a([].push),Z=a((!0).valueOf),K=a(1..valueOf),$=a("".valueOf),Q=a(C.prototype.getTime),ee=o("structuredClone"),te="DataCloneError",ne="Transferring",ie=function(e){return!s((function(){var t=new i.Set([7]),n=e(t),r=e(E(7));return n==t||!n.has(7)||"object"!=typeof r||7!=r}))&&e},re=function(e,t){return!s((function(){var n=new t,i=e({a:n,b:n});return!(i&&i.a===i.b&&i.a instanceof t&&i.a.stack===n.stack)}))},ae=i.structuredClone,se=t||!re(ae,P)||!re(ae,H)||(e=ae,!!s((function(){var t=e(new i.AggregateError([1],ee,{cause:3}));return"AggregateError"!=t.name||1!=t.errors[0]||t.message!=ee||3!=t.cause}))),oe=!ae&&ie((function(e){return new N(ee,{detail:e}).detail})),le=ie(ae)||oe,he=function(e){throw new H("Uncloneable type: "+e,te)},ce=function(e,t){throw new H((t||"Cloning")+" of "+e+" cannot be properly polyfilled in this engine",te)},ue=function(e,t){return le||ce(t),le(e)},de=function(e,t){if(d(e)&&he("Symbol"),!u(e))return e;if(t){if(j(t,e))return G(t,e)}else t=new V;var n,a,s,o,h,c,p,f,b,w,S,T=m(e),N=!1;switch(T){case"Array":s=A(x(e)),N=!0;break;case"Object":s={},N=!0;break;case"Map":s=new V,N=!0;break;case"Set":s=new X,N=!0;break;case"RegExp":s=new RegExp(e.source,_(e));break;case"Error":switch(a=e.name){case"AggregateError":s=r("AggregateError")([]);break;case"EvalError":s=R();break;case"RangeError":s=O();break;case"ReferenceError":s=L();break;case"SyntaxError":s=I();break;case"TypeError":s=D();break;case"URIError":s=k();break;case"CompileError":s=U();break;case"LinkError":s=B();break;case"RuntimeError":s=z();break;default:s=P()}N=!0;break;case"DOMException":s=new H(e.message,e.name),N=!0;break;case"DataView":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":n=i[T],u(n)||ce(T),s=new n(de(e.buffer,t),e.byteOffset,"DataView"===T?e.byteLength:e.length);break;case"DOMQuad":try{s=new DOMQuad(de(e.p1,t),de(e.p2,t),de(e.p3,t),de(e.p4,t))}catch(t){s=ue(e,T)}break;case"File":if(le)try{s=le(e),m(s)!==T&&(s=void 0)}catch(e){}if(!s)try{s=new File([e],e.name,e)}catch(e){}s||ce(T);break;case"FileList":if(o=function(){var e;try{e=new i.DataTransfer}catch(t){try{e=new i.ClipboardEvent("").clipboardData}catch(e){}}return e&&e.items&&e.files?e:null}(),o){for(h=0,c=x(e);h1&&!c(arguments[1])?f(arguments[1]):void 0,r=n?n.transfer:void 0;return void 0!==r&&function(e,t){if(!u(e))throw D("Transfer option cannot be converted to a sequence");var n=[];p(e,(function(e){J(n,f(e))}));var r,a,s,o,c,d,g=0,v=x(n);if(T)for(o=ae(n,{transfer:n});g{var e=tt(),t=Mn(),n=eM()(t.setInterval,!0);e({global:!0,bind:!0,forced:t.setInterval!==n},{setInterval:n})})),Koe=J((()=>{var e=tt(),t=Mn(),n=eM()(t.setTimeout,!0);e({global:!0,bind:!0,forced:t.setTimeout!==n},{setTimeout:n})})),Joe=J((()=>{Yoe(),Koe()})),cM=J(((e,t)=>{var n=Yt(),i=Br(),r=Kn(),a=as(),s=i("iterator");t.exports=!n((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,n="";return e.pathname="c%20d",t.forEach((function(e,i){t.delete("b"),n+=i+e})),a&&!e.toJSON||!t.size&&(a||!r)||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[s]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://\u0442\u0435\u0441\u0442").host||"#%D0%B1"!==new URL("http://a#\u0431").hash||"a1c3"!==n||"x"!==new URL("http://x",void 0).host}))})),cle=J(((e,t)=>{var n=en(),i=2147483647,r=/[^\0-\u007E]/,a=/[.\u3002\uFF0E\uFF61]/g,s="Overflow: input needs wider integers to process",o=RangeError,l=n(a.exec),h=Math.floor,c=String.fromCharCode,u=n("".charCodeAt),d=n([].join),p=n([].push),f=n("".replace),m=n("".split),g=n("".toLowerCase),v=function(e){return e+22+75*(e<26)},y=function(e,t,n){var i=0;for(e=n?h(e/700):e>>1,e+=h(e/t);e>455;)e=h(e/35),i+=36;return h(i+36*e/(e+38))},x=function(e){var t=[];e=function(e){for(var t=[],n=0,i=e.length;n=55296&&r<=56319&&n=l&&rh((i-f)/_))throw o(s);for(f+=(b-l)*_,l=b,n=0;ni)throw o(s);if(r==l){for(var w=f,S=36;;){var M=S<=m?1:S>=m+26?26:S-m;if(w{"use strict";B1();var n=tt(),i=Mn(),r=wr(),a=en(),s=Kn(),o=cM(),l=Yi(),h=Hs(),c=Vg(),u=ro(),d=Tw(),p=Ts(),f=dc(),m=Fr(),g=$r(),v=fl(),y=cc(),x=br(),b=Nr(),_=Mr(),w=no(),S=ko(),M=I1(),T=Bg(),E=pu(),A=Br(),C=Cw(),P=A("iterator"),R="URLSearchParams",O=R+"Iterator",L=p.set,I=p.getterFor(R),D=p.getterFor(O),k=Object.getOwnPropertyDescriptor,N=function(e){if(!s)return i[e];var t=k(i,e);return t&&t.value},F=N("fetch"),U=N("Request"),B=N("Headers"),z=U&&U.prototype,H=B&&B.prototype,V=i.RegExp,j=i.TypeError,G=i.decodeURIComponent,W=i.encodeURIComponent,X=a("".charAt),Y=a([].join),q=a([].push),J=a("".replace),Z=a([].shift),K=a([].splice),$=a("".split),Q=a("".slice),ee=/\+/g,te=Array(4),ne=function(e){return te[e-1]||(te[e-1]=V("((?:%[\\da-f]{2}){"+e+"})","gi"))},ie=function(e){try{return G(e)}catch(t){return e}},re=function(e){var t=J(e,ee," "),n=4;try{return G(t)}catch(e){for(;n;)t=J(t,ne(n--),ie);return t}},ae=/[!'()~]|%20/g,se={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},oe=function(e){return se[e]},le=function(e){return J(W(e),ae,oe)},he=d((function(e,t){L(this,{type:O,iterator:M(I(e).entries),kind:t})}),"Iterator",(function(){var e=D(this),t=e.kind,n=e.iterator.next(),i=n.value;return n.done||(n.value="keys"===t?i.key:"values"===t?i.value:[i.key,i.value]),n}),!0),ce=function(e){this.entries=[],this.url=null,void 0!==e&&(b(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===X(e,0)?Q(e,1):e:_(e)))};ce.prototype={type:R,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,n,i,a,s,o,l,h=T(e);if(h)for(n=(t=M(e,h)).next;!(i=r(n,t)).done;){if(s=(a=M(x(i.value))).next,(o=r(s,a)).done||(l=r(s,a)).done||!r(s,a).done)throw j("Expected sequence with length 2");q(this.entries,{key:_(o.value),value:_(l.value)})}else for(var c in e)g(e,c)&&q(this.entries,{key:c,value:_(e[c])})},parseQuery:function(e){if(e)for(var t,n,i=$(e,"&"),r=0;r0?arguments[0]:void 0));s||(this.length=e.entries.length)},ge=me.prototype;c(ge,{append:function(e,t){E(arguments.length,2);var n=I(this);q(n.entries,{key:_(e),value:_(t)}),s||this.length++,n.updateURL()},delete:function(e){E(arguments.length,1);for(var t=I(this),n=t.entries,i=_(e),r=0;rt.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,n=I(this).entries,i=v(e,arguments.length>1?arguments[1]:void 0),r=0;r1?pe(arguments[1]):{})}}),m(U)&&(fe=function(e){return f(this,z),new U(e,arguments.length>1?pe(arguments[1]):{})},z.constructor=fe,fe.prototype=z,n({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:fe}))),t.exports={URLSearchParams:me,getState:I}})),Xle=J((()=>{"use strict";sk();var e,t=tt(),n=Kn(),i=cM(),r=Mn(),a=fl(),s=en(),o=Yi(),l=Hs(),h=dc(),c=$r(),u=tO(),d=NL(),p=Lg(),f=hx().codeAt,m=cle(),g=Mr(),v=ro(),y=pu(),x=tN(),b=Ts(),_=b.set,w=b.getterFor("URL"),S=x.URLSearchParams,M=x.getState,T=r.URL,E=r.TypeError,A=r.parseInt,C=Math.floor,P=Math.pow,R=s("".charAt),O=s(/./.exec),L=s([].join),I=s(1..toString),D=s([].pop),k=s([].push),N=s("".replace),F=s([].shift),U=s("".split),B=s("".slice),z=s("".toLowerCase),H=s([].unshift),V="Invalid scheme",j="Invalid host",G="Invalid port",W=/[a-z]/i,X=/[\d+-.a-z]/i,Y=/\d/,q=/^0x/i,J=/^[0-7]+$/,Z=/^\d+$/,K=/^[\da-f]+$/i,$=/[\0\t\n\r #%/:<>?@[\\\]^|]/,Q=/[\0\t\n\r #/:<>?@[\\\]^|]/,ee=/^[\u0000-\u0020]+/,te=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,ne=/[\t\n\r]/g,ie=function(e){var t,n,i,r;if("number"==typeof e){for(t=[],n=0;n<4;n++)H(t,e%256),e=C(e/256);return L(t,".")}if("object"==typeof e){for(t="",i=function(e){for(var t=null,n=1,i=null,r=0,a=0;a<8;a++)0!==e[a]?(r>n&&(t=i,n=r),i=null,r=0):(null===i&&(i=a),++r);return r>n&&(t=i,n=r),t}(e),n=0;n<8;n++)r&&0===e[n]||(r&&(r=!1),i===n?(t+=n?":":"::",r=!0):(t+=I(e[n],16),n<7&&(t+=":")));return"["+t+"]"}return e},re={},ae=u({},re,{" ":1,'"':1,"<":1,">":1,"`":1}),se=u({},ae,{"#":1,"?":1,"{":1,"}":1}),oe=u({},se,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),le=function(e,t){var n=f(e,0);return n>32&&n<127&&!c(t,e)?e:encodeURIComponent(e)},he={ftp:21,file:null,http:80,https:443,ws:80,wss:443},ce=function(e,t){var n;return 2==e.length&&O(W,R(e,0))&&(":"==(n=R(e,1))||!t&&"|"==n)},ue=function(e){var t;return e.length>1&&ce(B(e,0,2))&&(2==e.length||"/"===(t=R(e,2))||"\\"===t||"?"===t||"#"===t)},de=function(e){return"."===e||"%2e"===z(e)},pe=function(e){return".."===(e=z(e))||"%2e."===e||".%2e"===e||"%2e%2e"===e},fe={},me={},ge={},ve={},ye={},xe={},be={},_e={},we={},Se={},Me={},Te={},Ee={},Ae={},Ce={},Pe={},Re={},Oe={},Le={},Ie={},De={},ke=function(e,t,n){var i,r,a,s=g(e);if(t){if(r=this.parse(s))throw E(r);this.searchParams=null}else{if(void 0!==n&&(i=new ke(n,!0)),r=this.parse(s,null,i))throw E(r);(a=M(new S)).bindURL(this),this.searchParams=a}};ke.prototype={type:"URL",parse:function(t,n,i){var r,a,s,o,l=this,h=n||fe,u=0,f="",m=!1,v=!1,y=!1;for(t=g(t),n||(l.scheme="",l.username="",l.password="",l.host=null,l.port=null,l.path=[],l.query=null,l.fragment=null,l.cannotBeABaseURL=!1,t=N(t,ee,""),t=N(t,te,"$1")),t=N(t,ne,""),r=d(t);u<=r.length;){switch(a=r[u],h){case fe:if(!a||!O(W,a)){if(n)return V;h=ge;continue}f+=z(a),h=me;break;case me:if(a&&(O(X,a)||"+"==a||"-"==a||"."==a))f+=z(a);else{if(":"!=a){if(n)return V;f="",h=ge,u=0;continue}if(n&&(l.isSpecial()!=c(he,f)||"file"==f&&(l.includesCredentials()||null!==l.port)||"file"==l.scheme&&!l.host))return;if(l.scheme=f,n)return void(l.isSpecial()&&he[l.scheme]==l.port&&(l.port=null));f="","file"==l.scheme?h=Ae:l.isSpecial()&&i&&i.scheme==l.scheme?h=ve:l.isSpecial()?h=_e:"/"==r[u+1]?(h=ye,u++):(l.cannotBeABaseURL=!0,k(l.path,""),h=Le)}break;case ge:if(!i||i.cannotBeABaseURL&&"#"!=a)return V;if(i.cannotBeABaseURL&&"#"==a){l.scheme=i.scheme,l.path=p(i.path),l.query=i.query,l.fragment="",l.cannotBeABaseURL=!0,h=De;break}h="file"==i.scheme?Ae:xe;continue;case ve:if("/"!=a||"/"!=r[u+1]){h=xe;continue}h=we,u++;break;case ye:if("/"==a){h=Se;break}h=Oe;continue;case xe:if(l.scheme=i.scheme,a==e)l.username=i.username,l.password=i.password,l.host=i.host,l.port=i.port,l.path=p(i.path),l.query=i.query;else if("/"==a||"\\"==a&&l.isSpecial())h=be;else if("?"==a)l.username=i.username,l.password=i.password,l.host=i.host,l.port=i.port,l.path=p(i.path),l.query="",h=Ie;else{if("#"!=a){l.username=i.username,l.password=i.password,l.host=i.host,l.port=i.port,l.path=p(i.path),l.path.length--,h=Oe;continue}l.username=i.username,l.password=i.password,l.host=i.host,l.port=i.port,l.path=p(i.path),l.query=i.query,l.fragment="",h=De}break;case be:if(!l.isSpecial()||"/"!=a&&"\\"!=a){if("/"!=a){l.username=i.username,l.password=i.password,l.host=i.host,l.port=i.port,h=Oe;continue}h=Se}else h=we;break;case _e:if(h=we,"/"!=a||"/"!=R(f,u+1))continue;u++;break;case we:if("/"!=a&&"\\"!=a){h=Se;continue}break;case Se:if("@"==a){m&&(f="%40"+f),m=!0,s=d(f);for(var x=0;x65535)return G;l.port=l.isSpecial()&&w===he[l.scheme]?null:w,f=""}if(n)return;h=Re;continue}return G}f+=a;break;case Ae:if(l.scheme="file","/"==a||"\\"==a)h=Ce;else{if(!i||"file"!=i.scheme){h=Oe;continue}if(a==e)l.host=i.host,l.path=p(i.path),l.query=i.query;else if("?"==a)l.host=i.host,l.path=p(i.path),l.query="",h=Ie;else{if("#"!=a){ue(L(p(r,u),""))||(l.host=i.host,l.path=p(i.path),l.shortenPath()),h=Oe;continue}l.host=i.host,l.path=p(i.path),l.query=i.query,l.fragment="",h=De}}break;case Ce:if("/"==a||"\\"==a){h=Pe;break}i&&"file"==i.scheme&&!ue(L(p(r,u),""))&&(ce(i.path[0],!0)?k(l.path,i.path[0]):l.host=i.host),h=Oe;continue;case Pe:if(a==e||"/"==a||"\\"==a||"?"==a||"#"==a){if(!n&&ce(f))h=Oe;else if(""==f){if(l.host="",n)return;h=Re}else{if(o=l.parseHost(f))return o;if("localhost"==l.host&&(l.host=""),n)return;f="",h=Re}continue}f+=a;break;case Re:if(l.isSpecial()){if(h=Oe,"/"!=a&&"\\"!=a)continue}else if(n||"?"!=a)if(n||"#"!=a){if(a!=e&&(h=Oe,"/"!=a))continue}else l.fragment="",h=De;else l.query="",h=Ie;break;case Oe:if(a==e||"/"==a||"\\"==a&&l.isSpecial()||!n&&("?"==a||"#"==a)){if(pe(f)?(l.shortenPath(),"/"!=a&&!("\\"==a&&l.isSpecial())&&k(l.path,"")):de(f)?"/"!=a&&!("\\"==a&&l.isSpecial())&&k(l.path,""):("file"==l.scheme&&!l.path.length&&ce(f)&&(l.host&&(l.host=""),f=R(f,0)+":"),k(l.path,f)),f="","file"==l.scheme&&(a==e||"?"==a||"#"==a))for(;l.path.length>1&&""===l.path[0];)F(l.path);"?"==a?(l.query="",h=Ie):"#"==a&&(l.fragment="",h=De)}else f+=le(a,se);break;case Le:"?"==a?(l.query="",h=Ie):"#"==a?(l.fragment="",h=De):a!=e&&(l.path[0]+=le(a,re));break;case Ie:n||"#"!=a?a!=e&&("'"==a&&l.isSpecial()?l.query+="%27":l.query+="#"==a?"%23":le(a,re)):(l.fragment="",h=De);break;case De:a!=e&&(l.fragment+=le(a,ae))}u++}},parseHost:function(e){var t,n,i;if("["==R(e,0)){if("]"!=R(e,e.length-1)||(t=function(e){var t,n,i,r,a,s,o,l=[0,0,0,0,0,0,0,0],h=0,c=null,u=0,d=function(){return R(e,u)};if(":"==d()){if(":"!=R(e,1))return;u+=2,c=++h}for(;d();){if(8==h)return;if(":"!=d()){for(t=n=0;n<4&&O(K,d());)t=16*t+A(d(),16),u++,n++;if("."==d()){if(0==n||(u-=n,h>6))return;for(i=0;d();){if(r=null,i>0){if(!("."==d()&&i<4))return;u++}if(!O(Y,d()))return;for(;O(Y,d());){if(a=A(d(),10),null===r)r=a;else{if(0==r)return;r=10*r+a}if(r>255)return;u++}l[h]=256*l[h]+r,(2==++i||4==i)&&h++}if(4!=i)return;break}if(":"==d()){if(u++,!d())return}else if(d())return;l[h++]=t}else{if(null!==c)return;u++,c=++h}}if(null!==c)for(s=h-c,h=7;0!=h&&s>0;)o=l[h],l[h--]=l[c+s-1],l[c+--s]=o;else if(8!=h)return;return l}(B(e,1,-1)),!t))return j;this.host=t}else if(this.isSpecial()){if(e=m(e),O($,e)||(t=function(e){var t,n,i,r,a,s,o,l=U(e,".");if(l.length&&""==l[l.length-1]&&l.length--,(t=l.length)>4)return e;for(n=[],i=0;i1&&"0"==R(r,0)&&(a=O(q,r)?16:8,r=B(r,8==a?1:2)),""===r)s=0;else{if(!O(10==a?Z:8==a?J:K,r))return e;s=A(r,a)}k(n,s)}for(i=0;i=P(256,5-t))return null}else if(s>255)return null;for(o=D(n),i=0;i1?arguments[1]:void 0,r=_(t,new ke(e,!1,i));n||(t.href=r.serialize(),t.origin=r.getOrigin(),t.protocol=r.getProtocol(),t.username=r.getUsername(),t.password=r.getPassword(),t.host=r.getHost(),t.hostname=r.getHostname(),t.port=r.getPort(),t.pathname=r.getPathname(),t.search=r.getSearch(),t.searchParams=r.getSearchParams(),t.hash=r.getHash())},Be=Ue.prototype,ze=function(e,t){return{get:function(){return w(this)[e]()},set:t&&function(e){return w(this)[t](e)},configurable:!0,enumerable:!0}};n&&(l(Be,"href",ze("serialize","setHref")),l(Be,"origin",ze("getOrigin")),l(Be,"protocol",ze("getProtocol","setProtocol")),l(Be,"username",ze("getUsername","setUsername")),l(Be,"password",ze("getPassword","setPassword")),l(Be,"host",ze("getHost","setHost")),l(Be,"hostname",ze("getHostname","setHostname")),l(Be,"port",ze("getPort","setPort")),l(Be,"pathname",ze("getPathname","setPathname")),l(Be,"search",ze("getSearch","setSearch")),l(Be,"searchParams",ze("getSearchParams")),l(Be,"hash",ze("getHash","setHash"))),o(Be,"toJSON",(function(){return w(this).serialize()}),{enumerable:!0}),o(Be,"toString",(function(){return w(this).serialize()}),{enumerable:!0}),T&&(Ne=T.createObjectURL,Fe=T.revokeObjectURL,Ne&&o(Ue,"createObjectURL",a(Ne,T)),Fe&&o(Ue,"revokeObjectURL",a(Fe,T))),v(Ue,"URL"),t({global:!0,constructor:!0,forced:!i,sham:!n},{URL:Ue})})),Yle=J((()=>{Xle()})),Kle=J((()=>{var e=tt(),t=ki(),n=Yt(),i=pu(),r=Mr(),a=cM(),s=t("URL");e({target:"URL",stat:!0,forced:!(a&&n((function(){s.canParse()})))},{canParse:function(e){var t=i(arguments.length,1),n=r(e),a=t<2||void 0===arguments[1]?void 0:r(arguments[1]);try{return!!new s(n,a)}catch(e){return!1}}})})),Jle=J((()=>{"use strict";var e=tt(),t=wr();e({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return t(URL.prototype.toString,this)}})})),Qle=J((()=>{tN()})),ece=J((()=>{"use strict";var e=Kn(),t=en(),n=Hs(),i=URLSearchParams.prototype,r=t(i.forEach);e&&!("size"in i)&&n(i,"size",{get:function(){var e=0;return r(this,(function(){e++})),e},configurable:!0,enumerable:!0})})),nce=J(((e,t)=>{nW(),cW(),uW(),hW(),dW(),fW(),pW(),mW(),gW(),vW(),yW(),xW(),bW(),EW(),_W(),YW(),QW(),gj(),bj(),_j(),Aj(),Lj(),Oj(),Nj(),Bj(),Hj(),zj(),Wj(),jj(),$j(),Zj(),Qj(),cX(),uX(),dX(),fX(),B1(),OX(),BX(),UX(),VX(),GX(),YX(),ZX(),JX(),tY(),nY(),yY(),EY(),_Y(),wY(),AY(),CY(),PY(),IY(),LY(),OY(),a$(),y$(),R$(),C$(),P$(),L$(),k$(),F$(),j$(),X$(),J$(),nZ(),iZ(),uZ(),fZ(),vZ(),yZ(),dL(),xZ(),kZ(),BZ(),VZ(),GZ(),WZ(),jZ(),$Z(),KZ(),eK(),nK(),iK(),aK(),oK(),lK(),cK(),dK(),mK(),gK(),vK(),AK(),CK(),LK(),OK(),kK(),FK(),NK(),BK(),qK(),JK(),rJ(),cJ(),dJ(),vJ(),yJ(),EJ(),TJ(),SJ(),MJ(),PJ(),IJ(),LJ(),kJ(),FJ(),NJ(),UJ(),HJ(),zJ(),qJ(),jJ(),YJ(),ZJ(),KJ(),JJ(),QJ(),sQ(),aQ(),oQ(),uQ(),hQ(),fQ(),mQ(),Mee(),Ree(),Cee(),Dee(),Oee(),Vee(),qee(),Wee(),$ee(),Zee(),Kee(),Jee(),Qee(),ete(),tte(),ate(),lte(),cte(),Ste(),Rte(),xS(),Dte(),kte(),Bte(),Vte(),Gte(),qte(),Yte(),tne(),ine(),ane(),sk(),xne(),Cne(),Ine(),Lne(),Fne(),Nne(),Gne(),Yne(),Kne(),rre(),lre(),ure(),pre(),xre(),wre(),Are(),Cre(),Pre(),Ire(),Lre(),Dre(),Ore(),kre(),Fre(),Nre(),Bre(),Ure(),Hre(),pie(),mie(),gie(),vie(),yie(),xie(),bie(),Eie(),_ie(),wie(),Mie(),Aie(),Pie(),Fie(),Bie(),Hie(),zie(),qie(),jie(),Xie(),$ie(),Kie(),nse(),ise(),ase(),lse(),use(),dse(),pse(),gse(),_se(),wse(),Mse(),Lse(),kse(),Hse(),Vse(),zse(),qse(),Wse(),Zse(),fae(),mae(),wae(),Dae(),Hae(),jae(),aoe(),foe(),moe(),Moe(),Roe(),Coe(),Woe(),Joe(),Yle(),Kle(),Jle(),Qle(),ece(),t.exports=aw()})),rce=J(((e,t)=>{var n=function(e){"use strict";var t,n=Object.prototype,i=n.hasOwnProperty,r=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",l=a.toStringTag||"@@toStringTag";function h(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{h({},"")}catch(e){h=function(e,t,n){return e[t]=n}}function c(e,t,n,i){var a=t&&t.prototype instanceof v?t:v,s=Object.create(a.prototype),o=new R(i||[]);return r(s,"_invoke",{value:E(e,n,o)}),s}function u(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var d="suspendedStart",p="suspendedYield",f="executing",m="completed",g={};function v(){}function y(){}function x(){}var b={};h(b,s,(function(){return this}));var _=Object.getPrototypeOf,w=_&&_(_(O([])));w&&w!==n&&i.call(w,s)&&(b=w);var S=x.prototype=v.prototype=Object.create(b);function M(e){["next","throw","return"].forEach((function(t){h(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){function n(r,a,s,o){var l=u(e[r],e,a);if("throw"!==l.type){var h=l.arg,c=h.value;return c&&"object"==typeof c&&i.call(c,"__await")?t.resolve(c.__await).then((function(e){n("next",e,s,o)}),(function(e){n("throw",e,s,o)})):t.resolve(c).then((function(e){h.value=e,s(h)}),(function(e){return n("throw",e,s,o)}))}o(l.arg)}var a;r(this,"_invoke",{value:function(e,i){function r(){return new t((function(t,r){n(e,i,t,r)}))}return a=a?a.then(r,r):r()}})}function E(e,t,n){var i=d;return function(r,a){if(i===f)throw new Error("Generator is already running");if(i===m){if("throw"===r)throw a;return L()}for(n.method=r,n.arg=a;;){var s=n.delegate;if(s){var o=A(s,n);if(o){if(o===g)continue;return o}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===d)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=f;var l=u(e,t,n);if("normal"===l.type){if(i=n.done?m:p,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(i=m,n.method="throw",n.arg=l.arg)}}}function A(e,n){var i=n.method,r=e.iterator[i];if(r===t)return n.delegate=null,"throw"===i&&e.iterator.return&&(n.method="return",n.arg=t,A(e,n),"throw"===n.method)||"return"!==i&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+i+"' method")),g;var a=u(r,e.iterator,n.arg);if("throw"===a.type)return n.method="throw",n.arg=a.arg,n.delegate=null,g;var s=a.arg;return s?s.done?(n[e.resultName]=s.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,g):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function C(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(C,this),this.reset(!0)}function O(e){if(e){var n=e[s];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function n(){for(;++r=0;--a){var s=this.tryEntries[a],o=s.completion;if("root"===s.tryLoc)return r("end");if(s.tryLoc<=this.prev){var l=i.call(s,"catchLoc"),h=i.call(s,"finallyLoc");if(l&&h){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),P(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var i=n.completion;if("throw"===i.type){var r=i.arg;P(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,i){return this.delegate={iterator:O(e),resultName:n,nextLoc:i},"next"===this.method&&(this.arg=t),g}},e}("object"==typeof t?t.exports:{});try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}})),mde=J(((e,t)=>{!function(e,n){"use strict";"function"==typeof define&&define.amd?define(n):"object"==typeof t&&t.exports?t.exports=n():e.log=n()}(e,(function(){"use strict";var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"];function r(e,t){var n=e[t];if("function"==typeof n.bind)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch(t){return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function a(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function s(t,n){for(var r=0;r=0&&n<=o.levels.SILENT))throw"log.setLevel() called with invalid level: "+n;if(a=n,!1!==r&&function(e){var n=(i[e]||"silent").toUpperCase();if(typeof window!==t&&h){try{return void(window.localStorage[h]=n)}catch(e){}try{window.document.cookie=encodeURIComponent(h)+"="+n+";"}catch(e){}}}(n),s.call(o,n,e),typeof console===t&&n{"use strict";t.exports=function(e,t,i){var r=e*t,a=n*e,s=a-(a-e),o=e-s,l=n*t,h=l-(l-t),c=t-h,u=o*c-(r-s*h-o*h-s*c);return i?(i[0]=u,i[1]=r,i):[u,r]};var n=+(Math.pow(2,27)+1)})),e5=J(((e,t)=>{"use strict";t.exports=function(e,t){var n=0|e.length,i=0|t.length;if(1===n&&1===i)return function(e,t){var n=e+t,i=n-e,r=e-(n-i)+(t-i);return r?[r,n]:[n]}(e[0],t[0]);var r,a,s=new Array(n+i),o=0,l=0,h=0,c=Math.abs,u=e[l],d=c(u),p=t[h],f=c(p);d=i?(r=u,(l+=1){"use strict";t.exports=function(e,t,n){var i=e+t,r=i-e,a=t-r,s=e-(i-r);return n?(n[0]=s+a,n[1]=i,n):[s+a,i]}})),n5=J(((e,t)=>{"use strict";var n=UA(),i=sfe();t.exports=function(e,t){var r=e.length;if(1===r){var a=n(e[0],t);return a[0]?a:[a[1]]}var s=new Array(2*r),o=[.1,.1],l=[.1,.1],h=0;n(e[0],t,o),o[0]&&(s[h++]=o[0]);for(var c=1;c{"use strict";t.exports=function(e){for(var t=e.length,n=e[e.length-1],i=t,r=t-2;r>=0;--r){var a=n;(l=(o=e[r])-((n=a+o)-a))&&(e[--i]=n,n=l)}var s=0;for(r=i;r{"use strict";t.exports=function(e,t){var n=0|e.length,i=0|t.length;if(1===n&&1===i)return function(e,t){var n=e+t,i=n-e,r=e-(n-i)+(t-i);return r?[r,n]:[n]}(e[0],-t[0]);var r,a,s=new Array(n+i),o=0,l=0,h=0,c=Math.abs,u=e[l],d=c(u),p=-t[h],f=c(p);d=i?(r=u,(l+=1){"use strict";var n=UA(),i=e5(),r=n5(),a=ufe();function s(e,t,n,i){return function(n,r,a){var s=e(e(t(r[1],a[0]),t(-a[1],r[0])),e(t(n[1],r[0]),t(-r[1],n[0]))),o=e(t(n[1],a[0]),t(-a[1],n[0])),l=i(s,o);return l[l.length-1]}}function o(e,t,n,i){return function(r,a,s,o){var l=e(e(n(e(t(s[1],o[0]),t(-o[1],s[0])),a[2]),e(n(e(t(a[1],o[0]),t(-o[1],a[0])),-s[2]),n(e(t(a[1],s[0]),t(-s[1],a[0])),o[2]))),e(n(e(t(a[1],o[0]),t(-o[1],a[0])),r[2]),e(n(e(t(r[1],o[0]),t(-o[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),o[2])))),h=e(e(n(e(t(s[1],o[0]),t(-o[1],s[0])),r[2]),e(n(e(t(r[1],o[0]),t(-o[1],r[0])),-s[2]),n(e(t(r[1],s[0]),t(-s[1],r[0])),o[2]))),e(n(e(t(a[1],s[0]),t(-s[1],a[0])),r[2]),e(n(e(t(r[1],s[0]),t(-s[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),s[2])))),c=i(l,h);return c[c.length-1]}}function l(e,t,n,i){return function(r,a,s,o,l){var h=e(e(e(n(e(n(e(t(o[1],l[0]),t(-l[1],o[0])),s[2]),e(n(e(t(s[1],l[0]),t(-l[1],s[0])),-o[2]),n(e(t(s[1],o[0]),t(-o[1],s[0])),l[2]))),a[3]),e(n(e(n(e(t(o[1],l[0]),t(-l[1],o[0])),a[2]),e(n(e(t(a[1],l[0]),t(-l[1],a[0])),-o[2]),n(e(t(a[1],o[0]),t(-o[1],a[0])),l[2]))),-s[3]),n(e(n(e(t(s[1],l[0]),t(-l[1],s[0])),a[2]),e(n(e(t(a[1],l[0]),t(-l[1],a[0])),-s[2]),n(e(t(a[1],s[0]),t(-s[1],a[0])),l[2]))),o[3]))),e(n(e(n(e(t(s[1],o[0]),t(-o[1],s[0])),a[2]),e(n(e(t(a[1],o[0]),t(-o[1],a[0])),-s[2]),n(e(t(a[1],s[0]),t(-s[1],a[0])),o[2]))),-l[3]),e(n(e(n(e(t(o[1],l[0]),t(-l[1],o[0])),a[2]),e(n(e(t(a[1],l[0]),t(-l[1],a[0])),-o[2]),n(e(t(a[1],o[0]),t(-o[1],a[0])),l[2]))),r[3]),n(e(n(e(t(o[1],l[0]),t(-l[1],o[0])),r[2]),e(n(e(t(r[1],l[0]),t(-l[1],r[0])),-o[2]),n(e(t(r[1],o[0]),t(-o[1],r[0])),l[2]))),-a[3])))),e(e(n(e(n(e(t(a[1],l[0]),t(-l[1],a[0])),r[2]),e(n(e(t(r[1],l[0]),t(-l[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),l[2]))),o[3]),e(n(e(n(e(t(a[1],o[0]),t(-o[1],a[0])),r[2]),e(n(e(t(r[1],o[0]),t(-o[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),o[2]))),-l[3]),n(e(n(e(t(s[1],o[0]),t(-o[1],s[0])),a[2]),e(n(e(t(a[1],o[0]),t(-o[1],a[0])),-s[2]),n(e(t(a[1],s[0]),t(-s[1],a[0])),o[2]))),r[3]))),e(n(e(n(e(t(s[1],o[0]),t(-o[1],s[0])),r[2]),e(n(e(t(r[1],o[0]),t(-o[1],r[0])),-s[2]),n(e(t(r[1],s[0]),t(-s[1],r[0])),o[2]))),-a[3]),e(n(e(n(e(t(a[1],o[0]),t(-o[1],a[0])),r[2]),e(n(e(t(r[1],o[0]),t(-o[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),o[2]))),s[3]),n(e(n(e(t(a[1],s[0]),t(-s[1],a[0])),r[2]),e(n(e(t(r[1],s[0]),t(-s[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),s[2]))),-o[3]))))),c=e(e(e(n(e(n(e(t(o[1],l[0]),t(-l[1],o[0])),s[2]),e(n(e(t(s[1],l[0]),t(-l[1],s[0])),-o[2]),n(e(t(s[1],o[0]),t(-o[1],s[0])),l[2]))),r[3]),n(e(n(e(t(o[1],l[0]),t(-l[1],o[0])),r[2]),e(n(e(t(r[1],l[0]),t(-l[1],r[0])),-o[2]),n(e(t(r[1],o[0]),t(-o[1],r[0])),l[2]))),-s[3])),e(n(e(n(e(t(s[1],l[0]),t(-l[1],s[0])),r[2]),e(n(e(t(r[1],l[0]),t(-l[1],r[0])),-s[2]),n(e(t(r[1],s[0]),t(-s[1],r[0])),l[2]))),o[3]),n(e(n(e(t(s[1],o[0]),t(-o[1],s[0])),r[2]),e(n(e(t(r[1],o[0]),t(-o[1],r[0])),-s[2]),n(e(t(r[1],s[0]),t(-s[1],r[0])),o[2]))),-l[3]))),e(e(n(e(n(e(t(s[1],l[0]),t(-l[1],s[0])),a[2]),e(n(e(t(a[1],l[0]),t(-l[1],a[0])),-s[2]),n(e(t(a[1],s[0]),t(-s[1],a[0])),l[2]))),r[3]),n(e(n(e(t(s[1],l[0]),t(-l[1],s[0])),r[2]),e(n(e(t(r[1],l[0]),t(-l[1],r[0])),-s[2]),n(e(t(r[1],s[0]),t(-s[1],r[0])),l[2]))),-a[3])),e(n(e(n(e(t(a[1],l[0]),t(-l[1],a[0])),r[2]),e(n(e(t(r[1],l[0]),t(-l[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),l[2]))),s[3]),n(e(n(e(t(a[1],s[0]),t(-s[1],a[0])),r[2]),e(n(e(t(r[1],s[0]),t(-s[1],r[0])),-a[2]),n(e(t(r[1],a[0]),t(-a[1],r[0])),s[2]))),-l[3])))),u=i(h,c);return u[u.length-1]}}function h(e){return(3===e?s:4===e?o:l)(i,n,r,a)}var c=h(3),u=h(4),d=[function(){return 0},function(){return 0},function(e,t){return t[0]-e[0]},function(e,t,n){var i,r=(e[1]-n[1])*(t[0]-n[0]),a=(e[0]-n[0])*(t[1]-n[1]),s=r-a;if(r>0){if(a<=0)return s;i=r+a}else{if(!(r<0))return s;if(a>=0)return s;i=-(r+a)}var o=33306690738754716e-32*i;return s>=o||s<=-o?s:c(e,t,n)},function(e,t,n,i){var r=e[0]-i[0],a=t[0]-i[0],s=n[0]-i[0],o=e[1]-i[1],l=t[1]-i[1],h=n[1]-i[1],c=e[2]-i[2],d=t[2]-i[2],p=n[2]-i[2],f=a*h,m=s*l,g=s*o,v=r*h,y=r*l,x=a*o,b=c*(f-m)+d*(g-v)+p*(y-x),_=7771561172376103e-31*((Math.abs(f)+Math.abs(m))*Math.abs(c)+(Math.abs(g)+Math.abs(v))*Math.abs(d)+(Math.abs(y)+Math.abs(x))*Math.abs(p));return b>_||-b>_?b:u(e,t,n,i)}];function p(e){var t=d[e.length];return t||(t=d[e.length]=h(e.length)),t.apply(void 0,e)}function f(e,t,n,i,r,a,s){return function(t,n,o,l,h){switch(arguments.length){case 0:case 1:return 0;case 2:return i(t,n);case 3:return r(t,n,o);case 4:return a(t,n,o,l);case 5:return s(t,n,o,l,h)}for(var c=new Array(arguments.length),u=0;u{"use strict";t.exports=function(e,t,i,r){var a=n(e,i,r),s=n(t,i,r);if(a>0&&s>0||a<0&&s<0)return!1;var o=n(i,e,t),l=n(r,e,t);return!(o>0&&l>0||o<0&&l<0)&&(0!==a||0!==s||0!==o||0!==l||function(e,t,n,i){for(var r=0;r<2;++r){var a=e[r],s=t[r],o=Math.min(a,s),l=Math.max(a,s),h=n[r],c=i[r],u=Math.min(h,c);if(Math.max(h,c){"use strict";t.exports=function(e,t,o,l){if(!s(e,t,o,l))return[[0],[0],[0]];var h=i([o[1]],[-l[1]]),c=i([-o[0]],[l[0]]),u=i(i(r(c,e[1]),r(c,-t[1])),i(r(h,e[0]),r(h,-t[0]))),d=i(n(-e[0],t[1]),n(e[1],t[0])),p=i(n(-o[0],l[1]),n(o[1],l[0])),f=i(i(r(p,e[0]),r(p,-t[0])),i(r(d,-o[0]),r(d,l[0]))),m=i(i(r(p,e[1]),r(p,-t[1])),i(r(d,-o[1]),r(d,l[1])));return[a(f),a(m),a(u)]};var n=UA(),i=e5(),r=n5(),a=lfe(),s=pfe()})),yfe=J(((e,t)=>{t.exports=function(e){var t=0,n=e.length;switch(n){case 1:t=e[0];break;case 2:t=e[0]+e[1];break;case 3:t=e[0]+e[1]+e[2];break;case 4:t=e[0]+e[1]+e[2]+e[3];break;default:for(var i=0;i{var n=gfe(),i=yfe();function r(e,t){return e[0]===t[0]&&e[1]===t[1]}t.exports=function(e,t){for(var c={},u=e.length,d=[],p=0;p{function n(e){if(e)return function(e){for(var t in n.prototype)e[t]=n.prototype[t];return e}(e)}t.exports=n,n.prototype.on=n.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[e]=this._callbacks[e]||[]).push(t),this},n.prototype.once=function(e,t){var n=this;function i(){n.off(e,i),t.apply(this,arguments)}return this._callbacks=this._callbacks||{},i.fn=t,this.on(e,i),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks[e];if(!n)return this;if(1==arguments.length)return delete this._callbacks[e],this;for(var i,r=0;r{var n=Jfe();function i(){n.call(this)}i.prototype=new n,t.exports=i,i.Stream=i,i.prototype.pipe=function(e,t){var n=this;function i(t){e.writable&&!1===e.write(t)&&n.pause&&n.pause()}function r(){n.readable&&n.resume&&n.resume()}n.on("data",i),e.on("drain",r),!e._isStdio&&(!t||!1!==t.end)&&(n.on("end",s),n.on("close",o));var a=!1;function s(){a||(a=!0,e.end())}function o(){a||(a=!0,"function"==typeof e.destroy&&e.destroy())}function l(e){if(h(),!this.hasListeners("error"))throw e}function h(){n.off("data",i),e.off("drain",r),n.off("end",s),n.off("close",o),n.off("error",l),e.off("error",l),n.off("end",h),n.off("close",h),e.off("end",h),e.off("close",h)}return n.on("error",l),e.on("error",l),n.on("end",h),n.on("close",h),e.on("end",h),e.on("close",h),e.emit("pipe",n),e}})),npe=J(((e,t)=>{var n,i;n=e,i=function(){"use strict";var e=Math.imul,t=Math.clz32;function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var n,i=0;ie.length)&&(t=e.length);for(var n=0,i=Array(t);no.__kMaxLength)throw new RangeError("Maximum BigInt size exceeded");return n}!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&a(e,t)}(o,e);var l=c(o);return function(e,t,n){t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1})}(o,[{key:"toDebugString",value:function(){var e,t=["BigInt["],n=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=d(e))){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,s=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){o=!0,a=e},f:function(){try{s||null==n.return||n.return()}finally{if(o)throw a}}}}(this);try{for(n.s();!(e=n.n()).done;){var i=e.value;t.push((i&&(i>>>0).toString(16))+", ")}}catch(e){n.e(e)}finally{n.f()}return t.push("]"),t.join("")}},{key:"toString",value:function(){var e=0e||36this.length&&(n=this.length);for(var i=32767&e,r=e>>>15,a=0,s=t,l=0;l>>15,d=o.__imul(c,i),p=o.__imul(c,r),f=o.__imul(u,i),m=s+d+a;a=m>>>30,m&=1073741823,a+=(m+=((32767&p)<<15)+((32767&f)<<15))>>>30,s=o.__imul(u,r)+(p>>>15)+(f>>>15),this.__setDigit(l,1073741823&m)}if(0!==a||0!==s)throw new Error("implementation bug")}},{key:"__inplaceAdd",value:function(e,t,n){for(var i,r=0,a=0;a>>15,this.__setHalfDigit(t+a,32767&i);return r}},{key:"__inplaceSub",value:function(e,t,n){var i=0;if(1&t){t>>=1;for(var r=this.__digit(t),a=32767&r,s=0;s>>1;s++){var o=e.__digit(s),l=(r>>>15)-(32767&o)-i;i=1&l>>>15,this.__setDigit(t+s,(32767&l)<<15|32767&a),i=1&(a=(32767&(r=this.__digit(t+s+1)))-(o>>>15)-i)>>>15}var h=e.__digit(s),c=(r>>>15)-(32767&h)-i;if(i=1&c>>>15,this.__setDigit(t+s,(32767&c)<<15|32767&a),t+s+1>=this.length)throw new RangeError("out of bounds");!(1&n)&&(i=1&(a=(32767&(r=this.__digit(t+s+1)))-(h>>>15)-i)>>>15,this.__setDigit(t+e.length,1073709056&r|32767&a))}else{t>>=1;for(var u=0;u>>15)-(p>>>15)-(i=1&f>>>15);i=1&m>>>15,this.__setDigit(t+u,(32767&m)<<15|32767&f)}var g=this.__digit(t+u),v=e.__digit(u),y=(32767&g)-(32767&v)-i;i=1&y>>>15;var x=0;!(1&n)&&(i=1&(x=(g>>>15)-(v>>>15)-i)>>>15),this.__setDigit(t+u,(32767&x)<<15|32767&y)}return i}},{key:"__inplaceRightShift",value:function(e){if(0!==e){for(var t,n=this.__digit(0)>>>e,i=this.length-1,r=0;r>>e;this.__setDigit(i,n)}}},{key:"__digit",value:function(e){return this[e]}},{key:"__unsignedDigit",value:function(e){return this[e]>>>0}},{key:"__setDigit",value:function(e,t){this[e]=0|t}},{key:"__setDigitGrow",value:function(e,t){this[e]=0|t}},{key:"__halfDigitLength",value:function(){var e=this.length;return 32767>=this.__unsignedDigit(e-1)?2*e-1:2*e}},{key:"__halfDigit",value:function(e){return 32767&this[e>>>1]>>>15*(1&e)}},{key:"__setHalfDigit",value:function(e,t){var n=e>>>1,i=this.__digit(n),r=1&e?32767&i|t<<15:1073709056&i|32767&t;this.__setDigit(n,r)}}],[{key:"BigInt",value:function(e){var t=Number.isFinite;if("number"==typeof e){if(0===e)return o.__zero();if(o.__isOneDigitInt(e))return 0>e?o.__oneDigit(-e,!0):o.__oneDigit(e,!1);if(!t(e)||s(e)!==e)throw new RangeError("The number "+e+" cannot be converted to BigInt because it is not an integer");return o.__fromDouble(e)}if("string"==typeof e){var i=o.__fromString(e);if(null===i)throw new SyntaxError("Cannot convert "+e+" to a BigInt");return i}if("boolean"==typeof e)return!0===e?o.__oneDigit(1,!1):o.__zero();if("object"===n(e)){if(e.constructor===o)return e;var r=o.__toPrimitive(e);return o.BigInt(r)}throw new TypeError("Cannot convert "+e+" to a BigInt")}},{key:"toNumber",value:function(e){var t=e.length;if(0===t)return 0;if(1===t){var n=e.__unsignedDigit(0);return e.sign?-n:n}var i=e.__digit(t-1),r=o.__clz30(i),a=30*t-r;if(1024>>=12;var d=c-12,p=12<=c?0:l<<20+c,f=20+c;for(0>>30-d,p=l<>>30-f,f-=30;var m=o.__decideRounding(e,f,h,l);if((1===m||0===m&&1==(1&p))&&0==(p=p+1>>>0)&&++u>>>20!=0&&(u=0,1023<++s))return e.sign?-1/0:1/0;var g=e.sign?-2147483648:0;return s=s+1023<<20,o.__kBitConversionInts[1]=g|s|u,o.__kBitConversionInts[0]=p,o.__kBitConversionDouble[0]}},{key:"unaryMinus",value:function(e){if(0===e.length)return e;var t=e.__copy();return t.sign=!e.sign,t}},{key:"bitwiseNot",value:function(e){return e.sign?o.__absoluteSubOne(e).__trim():o.__absoluteAddOne(e,!0)}},{key:"exponentiate",value:function(e,t){if(t.sign)throw new RangeError("Exponent must be positive");if(0===t.length)return o.__oneDigit(1,!1);if(0===e.length)return e;if(1===e.length&&1===e.__digit(0))return!e.sign||1&t.__digit(0)?e:o.unaryMinus(e);if(1=o.__kMaxLengthBits)throw new RangeError("BigInt too big");if(1===e.length&&2===e.__digit(0)){var i=1+(0|n/30),r=new o(i,e.sign&&0!=(1&n));r.__initializeDigits();var a=1<>=1;0!==n;n>>=1)l=o.multiply(l,l),1&n&&(s=null===s?l:o.multiply(s,l));return s}},{key:"multiply",value:function(e,t){if(0===e.length)return e;if(0===t.length)return t;var n=e.length+t.length;30<=e.__clzmsd()+t.__clzmsd()&&n--;var i=new o(n,e.sign!==t.sign);i.__initializeDigits();for(var r=0;ro.__absoluteCompare(e,t))return o.__zero();var n,i=e.sign!==t.sign,r=t.__unsignedDigit(0);if(1===t.length&&32767>=r){if(1===r)return i===e.sign?e:o.unaryMinus(e);n=o.__absoluteDivSmall(e,r,null)}else n=o.__absoluteDivLarge(e,t,!0,!1);return n.sign=i,n.__trim()}},{key:"remainder",value:function(e,t){if(0===t.length)throw new RangeError("Division by zero");if(0>o.__absoluteCompare(e,t))return e;var n=t.__unsignedDigit(0);if(1===t.length&&32767>=n){if(1===n)return o.__zero();var i=o.__absoluteModSmall(e,n);return 0===i?o.__zero():o.__oneDigit(i,e.sign)}var r=o.__absoluteDivLarge(e,t,!1,!0);return r.sign=e.sign,r.__trim()}},{key:"add",value:function(e,t){var n=e.sign;return n===t.sign?o.__absoluteAdd(e,t,n):0<=o.__absoluteCompare(e,t)?o.__absoluteSub(e,t,n):o.__absoluteSub(t,e,!n)}},{key:"subtract",value:function(e,t){var n=e.sign;return n===t.sign?0<=o.__absoluteCompare(e,t)?o.__absoluteSub(e,t,n):o.__absoluteSub(t,e,!n):o.__absoluteAdd(e,t,n)}},{key:"leftShift",value:function(e,t){return 0===t.length||0===e.length?e:t.sign?o.__rightShiftByAbsolute(e,t):o.__leftShiftByAbsolute(e,t)}},{key:"signedRightShift",value:function(e,t){return 0===t.length||0===e.length?e:t.sign?o.__leftShiftByAbsolute(e,t):o.__rightShiftByAbsolute(e,t)}},{key:"unsignedRightShift",value:function(){throw new TypeError("BigInts have no unsigned right shift; use >> instead")}},{key:"lessThan",value:function(e,t){return 0>o.__compareToBigInt(e,t)}},{key:"lessThanOrEqual",value:function(e,t){return 0>=o.__compareToBigInt(e,t)}},{key:"greaterThan",value:function(e,t){return 0(e=s(e)))throw new RangeError("Invalid value: not (convertible to) a safe integer");if(0===e)return o.__zero();if(e>=o.__kMaxLengthBits)return t;var n=0|(e+29)/30;if(t.length(e=s(e)))throw new RangeError("Invalid value: not (convertible to) a safe integer");if(0===e)return o.__zero();if(t.sign){if(e>o.__kMaxLengthBits)throw new RangeError("BigInt too big");return o.__truncateAndSubFromPowerOfTwo(e,t,!1)}if(e>=o.__kMaxLengthBits)return t;var n=0|(e+29)/30;if(t.length>>i))return t}return o.__truncateToNBits(e,t)}},{key:"ADD",value:function(e,t){if(e=o.__toPrimitive(e),t=o.__toPrimitive(t),"string"==typeof e)return"string"!=typeof t&&(t=t.toString()),e+t;if("string"==typeof t)return e.toString()+t;if(e=o.__toNumeric(e),t=o.__toNumeric(t),o.__isBigInt(e)&&o.__isBigInt(t))return o.add(e,t);if("number"==typeof e&&"number"==typeof t)return e+t;throw new TypeError("Cannot mix BigInt and other types, use explicit conversions")}},{key:"LT",value:function(e,t){return o.__compare(e,t,0)}},{key:"LE",value:function(e,t){return o.__compare(e,t,1)}},{key:"GT",value:function(e,t){return o.__compare(e,t,2)}},{key:"GE",value:function(e,t){return o.__compare(e,t,3)}},{key:"EQ",value:function(e,t){for(;;){if(o.__isBigInt(e))return o.__isBigInt(t)?o.equal(e,t):o.EQ(t,e);if("number"==typeof e){if(o.__isBigInt(t))return o.__equalToNumber(t,e);if("object"!==n(t))return e==t;t=o.__toPrimitive(t)}else if("string"==typeof e){if(o.__isBigInt(t))return null!==(e=o.__fromString(e))&&o.equal(e,t);if("object"!==n(t))return e==t;t=o.__toPrimitive(t)}else if("boolean"==typeof e){if(o.__isBigInt(t))return o.__equalToNumber(t,+e);if("object"!==n(t))return e==t;t=o.__toPrimitive(t)}else if("symbol"===n(e)){if(o.__isBigInt(t))return!1;if("object"!==n(t))return e==t;t=o.__toPrimitive(t)}else{if("object"!==n(e))return e==t;if("object"===n(t)&&t.constructor!==o)return e==t;e=o.__toPrimitive(e)}}}},{key:"NE",value:function(e,t){return!o.EQ(e,t)}},{key:"DataViewGetBigInt64",value:function(e,t){var n=2>>30),h.__setDigit(2,s>>>28),h.__trim()}},{key:"DataViewSetBigInt64",value:function(e,t,n){var i=3>>2,2t)r=-t-1;else{if(0===n)return-1;n--,i=e.__digit(n),r=29}var a=1<>>20)-1023,i=1+(0|n/30),r=new o(i,0>e),a=1048575&o.__kBitConversionInts[1]|1048576,s=o.__kBitConversionInts[0],l=n%30,h=0;if(l<20){var c=20-l;h=c+32,t=a>>>c,a=a<<32-c|s>>>c,s<<=32-c}else if(20===l)h=32,t=a,a=s,s=0;else{var u=l-20;h=32-u,t=a<>>32-u,a=s<>>2,a=a<<30|s>>>2,s<<=30):t=0,r.__setDigit(d,t);return r.__trim()}},{key:"__isWhitespace",value:function(e){return 13>=e&&9<=e||(159>=e?32==e:131071>=e?160==e||5760==e:196607>=e?10>=(e&=131071)||40==e||41==e||47==e||95==e||4096==e:65279==e)}},{key:"__fromString",value:function(e){var t=11073741824/l)return null;var c=new o(0|(29+(l*s+h>>>o.__kBitsPerCharTableShift))/30,!1),u=10>t?t:10,d=10>>0>>0>>o.__kBitsPerCharTableShift)/30;c.__inplaceMultiplyAdd(v,g,x)}while(!p)}else{l>>=o.__kBitsPerCharTableShift;var b=[],_=[],w=!1;do{for(var S,M=0,T=0;;){if(S=void 0,a-48>>>0>>0>>l-(a-=30))}if(0!==r){if(i>=e.length)throw new Error("implementation bug");e.__setDigit(i++,r)}for(;i>>1)+(85&i))>>>2)+(51&i))>>>4)+(15&i),a=t-1,s=e.__digit(n-1),l=0|(30*n-o.__clz30(s)+r-1)/r;if(e.sign&&l++,268435456>>g,d=30-g;d>=r;)h[c--]=o.__kConversionChars[u&a],u>>>=r,d-=r}var v=(u|s<>>r-d;0!==u;)h[c--]=o.__kConversionChars[u&a],u>>>=r;if(e.sign&&(h[c--]="-"),-1!==c)throw new Error("implementation bug");return h.join("")}},{key:"__toStringGeneric",value:function(e,t,n){var i=e.length;if(0===i)return"";if(1===i){var r=e.__unsignedDigit(0).toString(t);return!1===n&&e.sign&&(r="-"+r),r}var a,s,l=30*i-o.__clz30(e.__digit(i-1)),h=o.__kMaxBitsPerChar[t]-1,c=l*o.__kBitsPerCharTableMultiplier,u=1+(c=0|(c+=h-1)/h)>>1,d=o.exponentiate(o.__oneDigit(t,!1),o.__oneDigit(u,!1)),p=d.__unsignedDigit(0);if(1===d.length&&32767>=p){(a=new o(e.length,!1)).__initializeDigits();for(var f,m=0,g=2*e.length-1;0<=g;g--)f=m<<15|e.__halfDigit(g),a.__setHalfDigit(g,0|f/p),m=0|f%p;s=m.toString(t)}else{var v=o.__absoluteDivLarge(e,d,!0,!0);a=v.quotient;var y=v.remainder.__trim();s=o.__toStringGeneric(y,t,!0)}a.__trim();for(var x=o.__toStringGeneric(a,t,!0);s.lengthi?o.__absoluteLess(n):0}},{key:"__compareToNumber",value:function(e,n){if(o.__isOneDigitInt(n)){var i=e.sign,r=0>n;if(i!==r)return o.__unequalSign(i);if(0===e.length){if(r)throw new Error("implementation bug");return 0===n?0:-1}if(1a?o.__absoluteGreater(i):st)return o.__unequalSign(n);if(0===t)throw new Error("implementation bug: should be handled elsewhere");if(0===e.length)return-1;o.__kBitConversionDouble[0]=t;var i=2047&o.__kBitConversionInts[1]>>>20;if(2047==i)throw new Error("implementation bug: handled elsewhere");var r=i-1023;if(0>r)return o.__absoluteGreater(n);var a=e.length,s=e.__digit(a-1),l=o.__clz30(s),h=30*a-l,c=r+1;if(hc)return o.__absoluteGreater(n);var u=1048576|1048575&o.__kBitConversionInts[1],d=o.__kBitConversionInts[0],p=29-l;if(p!==(0|(h-1)%30))throw new Error("implementation bug");var f,m=0;if(p<20){var g=20-p;m=g+32,f=u>>>g,u=u<<32-g|d>>>g,d<<=32-g}else if(20===p)m=32,f=u,u=d,d=0;else{var v=p-20;m=32-v,f=u<>>32-v,u=d<>>=0)>(f>>>=0))return o.__absoluteGreater(n);if(s>>2,u=u<<30|d>>>2,d<<=30):f=0;var x=e.__unsignedDigit(y);if(x>f)return o.__absoluteGreater(n);if(xn&&e.__unsignedDigit(0)===t(n):0===o.__compareToDouble(e,n)}},{key:"__comparisonResultToBool",value:function(e,t){return 0===t?0>e:1===t?0>=e:2===t?0t;case 3:return e>=t}if(o.__isBigInt(e)&&"string"==typeof t)return null!==(t=o.__fromString(t))&&o.__comparisonResultToBool(o.__compareToBigInt(e,t),n);if("string"==typeof e&&o.__isBigInt(t))return null!==(e=o.__fromString(e))&&o.__comparisonResultToBool(o.__compareToBigInt(e,t),n);if(e=o.__toNumeric(e),t=o.__toNumeric(t),o.__isBigInt(e)){if(o.__isBigInt(t))return o.__comparisonResultToBool(o.__compareToBigInt(e,t),n);if("number"!=typeof t)throw new Error("implementation bug");return o.__comparisonResultToBool(o.__compareToNumber(e,t),n)}if("number"!=typeof e)throw new Error("implementation bug");if(o.__isBigInt(t))return o.__comparisonResultToBool(o.__compareToNumber(t,e),2^n);if("number"!=typeof t)throw new Error("implementation bug");return 0===n?et:3===n?e>=t:void 0}},{key:"__absoluteAdd",value:function(e,t,n){if(e.length>>30,a.__setDigit(l,1073741823&r);for(;l>>30,a.__setDigit(l,1073741823&h)}return l>>30,r.__setDigit(s,1073741823&i);for(;s>>30,r.__setDigit(s,1073741823&l)}return r.__trim()}},{key:"__absoluteAddOne",value:function(e,t){var n=2>>30,n.__setDigit(s,1073741823&r);return 0!==a&&n.__setDigitGrow(i,1),n}},{key:"__absoluteSubOne",value:function(e,t){for(var n,i=e.length,r=new o(t=t||i,!1),a=1,s=0;s>>30,r.__setDigit(s,1073741823&n);if(0!==a)throw new Error("implementation bug");for(var l=i;li?0:e.__unsignedDigit(i)>t.__unsignedDigit(i)?1:-1}},{key:"__multiplyAccumulate",value:function(e,t,n,i){if(0!==t){for(var r=32767&t,a=t>>>15,s=0,l=0,h=0;h>>15,f=o.__imul(d,r),m=o.__imul(d,a),g=o.__imul(p,r);s=(c+=l+f+s)>>>30,c&=1073741823,s+=(c+=((32767&m)<<15)+((32767&g)<<15))>>>30,l=o.__imul(p,a)+(m>>>15)+(g>>>15),n.__setDigit(i,1073741823&c)}for(;0!==s||0!==l;i++){var v=n.__digit(i);v+=s+l,l=0,s=v>>>30,n.__setDigit(i,1073741823&v)}}}},{key:"__internalMultiplyAdd",value:function(e,t,n,i,r){for(var a=n,s=0,l=0;l>>15,t),d=c+((32767&u)<<15)+s+a;a=d>>>30,s=u>>>15,r.__setDigit(l,1073741823&d)}if(r.length>i)for(r.__setDigit(i++,a+s);i>>0,s=0|a/t,l=0|(a=((i=0|a%t)<<15|e.__halfDigit(r-1))>>>0)/t;i=0|a%t,n.__setDigit(r>>>1,s<<15|l)}return n}},{key:"__absoluteModSmall",value:function(e,t){for(var n=0,i=2*e.length-1;0<=i;i--)n=0|((n<<15|e.__halfDigit(i))>>>0)%t;return n}},{key:"__absoluteDivLarge",value:function(e,t,n,i){var r=t.__halfDigitLength(),a=t.length,s=e.__halfDigitLength()-r,l=null;n&&(l=new o(s+2>>>1,!1)).__initializeDigits();var h=new o(r+2>>>1,!1);h.__initializeDigits();var c=o.__clz15(t.__halfDigit(r-1));0>>0;m=0|v/d;for(var y=0|v%d,x=t.__halfDigit(r-2),b=u.__halfDigit(f+r-2);o.__imul(m,x)>>>0>(y<<16|b)>>>0&&(m--,!(32767<(y+=d))););}o.__internalMultiplyAdd(t,m,0,a,h);var _=u.__inplaceSub(h,f,r+1);0!==_&&(_=u.__inplaceAdd(t,f,r),u.__setHalfDigit(f+r,32767&u.__halfDigit(f+r)+_),m--),n&&(1&f?p=m<<15:l.__setDigit(f>>>1,p|m))}if(i)return u.__inplaceRightShift(c),n?{quotient:l,remainder:u}:u;if(n)return l;throw new Error("unreachable")}},{key:"__clz15",value:function(e){return o.__clz30(e)-15}},{key:"__specialLeftShift",value:function(e,t,n){var i=e.length,r=new o(i+n,!1);if(0===t){for(var a=0;a>>30-t;return 0n)throw new RangeError("BigInt too big");var i=0|n/30,r=n%30,a=e.length,s=0!==r&&e.__digit(a-1)>>>30-r!=0,l=a+i+(s?1:0),h=new o(l,e.sign);if(0===r){for(var c=0;c>>30-r;if(s)h.__setDigit(a+i,u);else if(0!==u)throw new Error("implementation bug")}return h.__trim()}},{key:"__rightShiftByAbsolute",value:function(e,t){var n=e.length,i=e.sign,r=o.__toShiftAmount(t);if(0>r)return o.__rightShiftByMaximum(i);var a=0|r/30,s=r%30,l=n-a;if(0>=l)return o.__rightShiftByMaximum(i);var h=!1;if(i)if(e.__digit(a)&(1<>>s,m=n-a-1,g=0;g>>s;u.__setDigit(m,f)}return h&&(u=o.__absoluteAddOne(u,!0,u)),u.__trim()}},{key:"__rightShiftByMaximum",value:function(e){return e?o.__oneDigit(1,!0):o.__zero()}},{key:"__toShiftAmount",value:function(e){if(1o.__kMaxLengthBits?-1:t}},{key:"__toPrimitive",value:function(e){var t=1>>l}return i.__setDigit(r,s),i.__trim()}},{key:"__truncateAndSubFromPowerOfTwo",value:function(e,t,n){for(var i,r=Math.min,a=0|(e+29)/30,s=new o(a,n),l=0,h=a-1,c=0,u=r(h,t.length);l>>30,s.__setDigit(l,1073741823&i);for(;l>>m)-c,d&=g-1}return s.__setDigit(h,d),s.__trim()}},{key:"__digitPow",value:function(e,t){for(var n=1;0>>=1,e*=e;return n}},{key:"__isOneDigitInt",value:function(e){return(1073741823&e)===e}}]),o}(l(Array));return f.__kMaxLength=33554432,f.__kMaxLengthBits=f.__kMaxLength<<5,f.__kMaxBitsPerChar=[0,0,32,51,64,75,83,90,96,102,107,111,115,119,122,126,128,131,134,136,139,141,143,145,147,149,151,153,154,156,158,159,160,162,163,165,166],f.__kBitsPerCharTableShift=5,f.__kBitsPerCharTableMultiplier=1<>>0)/t)},f.__imul=e||function(e,t){return 0|e*t},f},"object"==typeof e&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define(i):(n=n||self).JSBI=i()})),Fl=J(((e,t)=>{(function(){var n,i="Expected a function",r="__lodash_hash_undefined__",a="__lodash_placeholder__",s=32,o=128,l=1/0,h=9007199254740991,c=NaN,u=4294967295,d=[["ary",o],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",s],["partialRight",64],["rearg",256]],p="[object Arguments]",f="[object Array]",m="[object Boolean]",g="[object Date]",v="[object Error]",y="[object Function]",x="[object GeneratorFunction]",b="[object Map]",_="[object Number]",w="[object Object]",S="[object Promise]",M="[object RegExp]",T="[object Set]",E="[object String]",A="[object Symbol]",C="[object WeakMap]",P="[object ArrayBuffer]",R="[object DataView]",O="[object Float32Array]",L="[object Float64Array]",I="[object Int8Array]",D="[object Int16Array]",k="[object Int32Array]",N="[object Uint8Array]",F="[object Uint8ClampedArray]",U="[object Uint16Array]",B="[object Uint32Array]",z=/\b__p \+= '';/g,H=/\b(__p \+=) '' \+/g,V=/(__e\(.*?\)|\b__t\)) \+\n'';/g,j=/&(?:amp|lt|gt|quot|#39);/g,G=/[&<>"']/g,W=RegExp(j.source),X=RegExp(G.source),Y=/<%-([\s\S]+?)%>/g,q=/<%([\s\S]+?)%>/g,J=/<%=([\s\S]+?)%>/g,Z=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,K=/^\w*$/,$=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Q=/[\\^$.*+?()[\]{}|]/g,ee=RegExp(Q.source),te=/^\s+/,ne=/\s/,ie=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,re=/\{\n\/\* \[wrapped with (.+)\] \*/,ae=/,? & /,se=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,oe=/[()=,{}\[\]\/\s]/,le=/\\(\\)?/g,he=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ce=/\w*$/,ue=/^[-+]0x[0-9a-f]+$/i,de=/^0b[01]+$/i,pe=/^\[object .+?Constructor\]$/,fe=/^0o[0-7]+$/i,me=/^(?:0|[1-9]\d*)$/,ge=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ve=/($^)/,ye=/['\n\r\u2028\u2029\\]/g,xe="\\ud800-\\udfff",be="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",_e="\\u2700-\\u27bf",we="a-z\\xdf-\\xf6\\xf8-\\xff",Se="A-Z\\xc0-\\xd6\\xd8-\\xde",Me="\\ufe0e\\ufe0f",Te="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ee="["+xe+"]",Ae="["+Te+"]",Ce="["+be+"]",Pe="\\d+",Re="["+_e+"]",Oe="["+we+"]",Le="[^"+xe+Te+Pe+_e+we+Se+"]",Ie="\\ud83c[\\udffb-\\udfff]",De="[^"+xe+"]",ke="(?:\\ud83c[\\udde6-\\uddff]){2}",Ne="[\\ud800-\\udbff][\\udc00-\\udfff]",Fe="["+Se+"]",Ue="\\u200d",Be="(?:"+Oe+"|"+Le+")",ze="(?:"+Fe+"|"+Le+")",He="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",Ve="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",je="(?:"+Ce+"|"+Ie+")?",Ge="["+Me+"]?",We=Ge+je+"(?:"+Ue+"(?:"+[De,ke,Ne].join("|")+")"+Ge+je+")*",Xe="(?:"+[Re,ke,Ne].join("|")+")"+We,Ye="(?:"+[De+Ce+"?",Ce,ke,Ne,Ee].join("|")+")",qe=RegExp("['\u2019]","g"),Je=RegExp(Ce,"g"),Ze=RegExp(Ie+"(?="+Ie+")|"+Ye+We,"g"),Ke=RegExp([Fe+"?"+Oe+"+"+He+"(?="+[Ae,Fe,"$"].join("|")+")",ze+"+"+Ve+"(?="+[Ae,Fe+Be,"$"].join("|")+")",Fe+"?"+Be+"+"+He,Fe+"+"+Ve,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Pe,Xe].join("|"),"g"),$e=RegExp("["+Ue+xe+be+Me+"]"),Qe=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,et=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],tt=-1,nt={};nt[O]=nt[L]=nt[I]=nt[D]=nt[k]=nt[N]=nt[F]=nt[U]=nt[B]=!0,nt[p]=nt[f]=nt[P]=nt[m]=nt[R]=nt[g]=nt[v]=nt[y]=nt[b]=nt[_]=nt[w]=nt[M]=nt[T]=nt[E]=nt[C]=!1;var it={};it[p]=it[f]=it[P]=it[R]=it[m]=it[g]=it[O]=it[L]=it[I]=it[D]=it[k]=it[b]=it[_]=it[w]=it[M]=it[T]=it[E]=it[A]=it[N]=it[F]=it[U]=it[B]=!0,it[v]=it[y]=it[C]=!1;var rt={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},at=parseFloat,st=parseInt,ot="object"==typeof global&&global&&global.Object===Object&&global,lt="object"==typeof self&&self&&self.Object===Object&&self,ht=ot||lt||Function("return this")(),ct="object"==typeof e&&e&&!e.nodeType&&e,ut=ct&&"object"==typeof t&&t&&!t.nodeType&&t,dt=ut&&ut.exports===ct,pt=dt&&ot.process,ft=function(){try{return ut&&ut.require&&ut.require("util").types||pt&&pt.binding&&pt.binding("util")}catch(e){}}(),mt=ft&&ft.isArrayBuffer,gt=ft&&ft.isDate,vt=ft&&ft.isMap,yt=ft&&ft.isRegExp,xt=ft&&ft.isSet,bt=ft&&ft.isTypedArray;function _t(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function wt(e,t,n,i){for(var r=-1,a=null==e?0:e.length;++r-1}function Ct(e,t,n){for(var i=-1,r=null==e?0:e.length;++i-1;);return n}function Kt(e,t){for(var n=e.length;n--&&Ft(t,e[n],0)>-1;);return n}var $t=Vt({"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss","\u0100":"A","\u0102":"A","\u0104":"A","\u0101":"a","\u0103":"a","\u0105":"a","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u010e":"D","\u0110":"D","\u010f":"d","\u0111":"d","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g","\u0124":"H","\u0126":"H","\u0125":"h","\u0127":"h","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u0131":"i","\u0134":"J","\u0135":"j","\u0136":"K","\u0137":"k","\u0138":"k","\u0139":"L","\u013b":"L","\u013d":"L","\u013f":"L","\u0141":"L","\u013a":"l","\u013c":"l","\u013e":"l","\u0140":"l","\u0142":"l","\u0143":"N","\u0145":"N","\u0147":"N","\u014a":"N","\u0144":"n","\u0146":"n","\u0148":"n","\u014b":"n","\u014c":"O","\u014e":"O","\u0150":"O","\u014d":"o","\u014f":"o","\u0151":"o","\u0154":"R","\u0156":"R","\u0158":"R","\u0155":"r","\u0157":"r","\u0159":"r","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0162":"T","\u0164":"T","\u0166":"T","\u0163":"t","\u0165":"t","\u0167":"t","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u017a":"z","\u017c":"z","\u017e":"z","\u0132":"IJ","\u0133":"ij","\u0152":"Oe","\u0153":"oe","\u0149":"'n","\u017f":"s"}),Qt=Vt({"&":"&","<":"<",">":">",'"':""","'":"'"});function en(e){return"\\"+rt[e]}function tn(e){return $e.test(e)}function nn(e){var t=-1,n=Array(e.size);return e.forEach((function(e,i){n[++t]=[i,e]})),n}function rn(e,t){return function(n){return e(t(n))}}function an(e,t){for(var n=-1,i=e.length,r=0,s=[];++n",""":'"',"'":"'"}),un=function e(t){var ne,xe=(t=null==t?ht:un.defaults(ht.Object(),t,un.pick(ht,et))).Array,be=t.Date,_e=t.Error,we=t.Function,Se=t.Math,Me=t.Object,Te=t.RegExp,Ee=t.String,Ae=t.TypeError,Ce=xe.prototype,Pe=we.prototype,Re=Me.prototype,Oe=t["__core-js_shared__"],Le=Pe.toString,Ie=Re.hasOwnProperty,De=0,ke=(ne=/[^.]+$/.exec(Oe&&Oe.keys&&Oe.keys.IE_PROTO||""))?"Symbol(src)_1."+ne:"",Ne=Re.toString,Fe=Le.call(Me),Ue=ht._,Be=Te("^"+Le.call(Ie).replace(Q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ze=dt?t.Buffer:n,He=t.Symbol,Ve=t.Uint8Array,je=ze?ze.allocUnsafe:n,Ge=rn(Me.getPrototypeOf,Me),We=Me.create,Xe=Re.propertyIsEnumerable,Ye=Ce.splice,Ze=He?He.isConcatSpreadable:n,$e=He?He.iterator:n,rt=He?He.toStringTag:n,ot=function(){try{var e=oa(Me,"defineProperty");return e({},"",{}),e}catch(e){}}(),lt=t.clearTimeout!==ht.clearTimeout&&t.clearTimeout,ct=be&&be.now!==ht.Date.now&&be.now,ut=t.setTimeout!==ht.setTimeout&&t.setTimeout,pt=Se.ceil,ft=Se.floor,Dt=Me.getOwnPropertySymbols,Vt=ze?ze.isBuffer:n,dn=t.isFinite,pn=Ce.join,fn=rn(Me.keys,Me),mn=Se.max,gn=Se.min,vn=be.now,yn=t.parseInt,xn=Se.random,bn=Ce.reverse,_n=oa(t,"DataView"),wn=oa(t,"Map"),Sn=oa(t,"Promise"),Mn=oa(t,"Set"),Tn=oa(t,"WeakMap"),En=oa(Me,"create"),An=Tn&&new Tn,Cn={},Pn=Ia(_n),Rn=Ia(wn),On=Ia(Sn),Ln=Ia(Mn),In=Ia(Tn),Dn=He?He.prototype:n,kn=Dn?Dn.valueOf:n,Nn=Dn?Dn.toString:n;function Fn(e){if(Zs(e)&&!Bs(e)&&!(e instanceof Hn)){if(e instanceof zn)return e;if(Ie.call(e,"__wrapped__"))return Da(e)}return new zn(e)}var Un=function(){function e(){}return function(t){if(!Js(t))return{};if(We)return We(t);e.prototype=t;var i=new e;return e.prototype=n,i}}();function Bn(){}function zn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=n}function Hn(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=u,this.__views__=[]}function Vn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function ai(e,t,i,r,a,s){var o,l=1&t,h=2&t,c=4&t;if(i&&(o=a?i(e,r,a,s):i(e)),o!==n)return o;if(!Js(e))return e;var u=Bs(e);if(u){if(o=function(e){var t=e.length,n=new e.constructor(t);return t&&"string"==typeof e[0]&&Ie.call(e,"index")&&(n.index=e.index,n.input=e.input),n}(e),!l)return Tr(e,o)}else{var d=ca(e),f=d==y||d==x;if(js(e))return xr(e,l);if(d==w||d==p||f&&!a){if(o=h||f?{}:da(e),!l)return h?function(e,t){return Er(e,ha(e),t)}(e,function(e,t){return e&&Er(t,Co(t),e)}(o,e)):function(e,t){return Er(e,la(e),t)}(e,ti(o,e))}else{if(!it[d])return a?e:{};o=function(e,t,n){var i=e.constructor;switch(t){case P:return br(e);case m:case g:return new i(+e);case R:return function(e,t){var n=t?br(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case O:case L:case I:case D:case k:case N:case F:case U:case B:return _r(e,n);case b:return new i;case _:case E:return new i(e);case M:return function(e){var t=new e.constructor(e.source,ce.exec(e));return t.lastIndex=e.lastIndex,t}(e);case T:return new i;case A:return function(e){return kn?Me(kn.call(e)):{}}(e)}}(e,d,l)}}s||(s=new Xn);var v=s.get(e);if(v)return v;s.set(e,o),to(e)?e.forEach((function(n){o.add(ai(n,t,i,n,e,s))})):Ks(e)&&e.forEach((function(n,r){o.set(r,ai(n,t,i,r,e,s))}));var S=u?n:(c?h?ea:Qr:h?Co:Ao)(e);return St(S||e,(function(n,r){S&&(n=e[r=n]),$n(o,r,ai(n,t,i,r,e,s))})),o}function si(e,t,i){var r=i.length;if(null==e)return!r;for(e=Me(e);r--;){var a=i[r],s=t[a],o=e[a];if(o===n&&!(a in e)||!s(o))return!1}return!0}function oi(e,t,r){if("function"!=typeof e)throw new Ae(i);return Ea((function(){e.apply(n,r)}),t)}function li(e,t,n,i){var r=-1,a=At,s=!0,o=e.length,l=[],h=t.length;if(!o)return l;n&&(t=Pt(t,Yt(n))),i?(a=Ct,s=!1):t.length>=200&&(a=Jt,s=!1,t=new Wn(t));e:for(;++r-1},jn.prototype.set=function(e,t){var n=this.__data__,i=Qn(n,e);return i<0?(++this.size,n.push([e,t])):n[i][1]=t,this},Gn.prototype.clear=function(){this.size=0,this.__data__={hash:new Vn,map:new(wn||jn),string:new Vn}},Gn.prototype.delete=function(e){var t=aa(this,e).delete(e);return this.size-=t?1:0,t},Gn.prototype.get=function(e){return aa(this,e).get(e)},Gn.prototype.has=function(e){return aa(this,e).has(e)},Gn.prototype.set=function(e,t){var n=aa(this,e),i=n.size;return n.set(e,t),this.size+=n.size==i?0:1,this},Wn.prototype.add=Wn.prototype.push=function(e){return this.__data__.set(e,r),this},Wn.prototype.has=function(e){return this.__data__.has(e)},Xn.prototype.clear=function(){this.__data__=new jn,this.size=0},Xn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Xn.prototype.get=function(e){return this.__data__.get(e)},Xn.prototype.has=function(e){return this.__data__.has(e)},Xn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof jn){var i=n.__data__;if(!wn||i.length<199)return i.push([e,t]),this.size=++n.size,this;n=this.__data__=new Gn(i)}return n.set(e,t),this.size=n.size,this};var hi=Pr(vi),ci=Pr(yi,!0);function ui(e,t){var n=!0;return hi(e,(function(e,i,r){return n=!!t(e,i,r)})),n}function di(e,t,i){for(var r=-1,a=e.length;++r0&&n(o)?t>1?fi(o,t-1,n,i,r):Rt(r,o):i||(r[r.length]=o)}return r}var mi=Rr(),gi=Rr(!0);function vi(e,t){return e&&mi(e,t,Ao)}function yi(e,t){return e&&gi(e,t,Ao)}function xi(e,t){return Et(t,(function(t){return Xs(e[t])}))}function bi(e,t){for(var i=0,r=(t=mr(t,e)).length;null!=e&&it}function Mi(e,t){return null!=e&&Ie.call(e,t)}function Ti(e,t){return null!=e&&t in Me(e)}function Ei(e,t,i){for(var r=i?Ct:At,a=e[0].length,s=e.length,o=s,l=xe(s),h=1/0,c=[];o--;){var u=e[o];o&&t&&(u=Pt(u,Yt(t))),h=gn(u.length,h),l[o]=!i&&(t||a>=120&&u.length>=120)?new Wn(o&&u):n}u=e[0];var d=-1,p=l[0];e:for(;++d=o?l:l*("desc"==n[i]?-1:1)}return e.index-t.index}(e,t,n)}))}function Hi(e,t,n){for(var i=-1,r=t.length,a={};++i-1;)o!==e&&Ye.call(o,l,1),Ye.call(e,l,1);return e}function ji(e,t){for(var n=e?t.length:0,i=n-1;n--;){var r=t[n];if(n==i||r!==a){var a=r;fa(r)?Ye.call(e,r,1):or(e,r)}}return e}function Gi(e,t){return e+ft(xn()*(t-e+1))}function Wi(e,t){var n="";if(!e||t<1||t>h)return n;do{t%2&&(n+=e),(t=ft(t/2))&&(e+=e)}while(t);return n}function Xi(e,t){return Aa(wa(e,t,Qo),e+"")}function Yi(e){return qn(No(e))}function qi(e,t){var n=No(e);return Ra(n,ri(t,0,n.length))}function Ji(e,t,i,r){if(!Js(e))return e;for(var a=-1,s=(t=mr(t,e)).length,o=s-1,l=e;null!=l&&++ar?0:r+t),(n=n>r?r:n)<0&&(n+=r),r=t>n?0:n-t>>>0,t>>>=0;for(var a=xe(r);++i>>1,s=e[a];null!==s&&!io(s)&&(n?s<=t:s=200){var h=t?null:Wr(e);if(h)return sn(h);s=!1,r=Jt,l=new Wn}else l=t?[]:o;e:for(;++i=r?e:Qi(e,t,i)}var yr=lt||function(e){return ht.clearTimeout(e)};function xr(e,t){if(t)return e.slice();var n=e.length,i=je?je(n):new e.constructor(n);return e.copy(i),i}function br(e){var t=new e.constructor(e.byteLength);return new Ve(t).set(new Ve(e)),t}function _r(e,t){var n=t?br(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function wr(e,t){if(e!==t){var i=e!==n,r=null===e,a=e==e,s=io(e),o=t!==n,l=null===t,h=t==t,c=io(t);if(!l&&!c&&!s&&e>t||s&&o&&h&&!l&&!c||r&&o&&h||!i&&h||!a)return 1;if(!r&&!s&&!c&&e1?i[a-1]:n,o=a>2?i[2]:n;for(s=e.length>3&&"function"==typeof s?(a--,s):n,o&&ma(i[0],i[1],o)&&(s=a<3?n:s,a=1),t=Me(t);++r-1?a[s?t[o]:o]:n}}function kr(e){return $r((function(t){var r=t.length,a=r,s=zn.prototype.thru;for(e&&t.reverse();a--;){var o=t[a];if("function"!=typeof o)throw new Ae(i);if(s&&!l&&"wrapper"==na(o))var l=new zn([],!0)}for(a=l?a:r;++a1&&x.reverse(),d&&cl))return!1;var c=s.get(e),u=s.get(t);if(c&&u)return c==t&&u==e;var d=-1,p=!0,f=2&i?new Wn:n;for(s.set(e,t),s.set(t,e);++d-1&&e%1==0&&e1?"& ":"")+t[i],t=t.join(n>2?", ":" "),e.replace(ie,"{\n/* [wrapped with "+t+"] */\n")}(i,function(e,t){return St(d,(function(n){var i="_."+n[0];t&n[1]&&!At(e,i)&&e.push(i)})),e.sort()}(function(e){var t=e.match(re);return t?t[1].split(ae):[]}(i),n)))}function Pa(e){var t=0,i=0;return function(){var r=vn(),a=16-(r-i);if(i=r,a>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(n,arguments)}}function Ra(e,t){var i=-1,r=e.length,a=r-1;for(t=t===n?r:t;++i1?e[t-1]:n;return i="function"==typeof i?(e.pop(),i):n,es(e,i)}));function os(e){var t=Fn(e);return t.__chain__=!0,t}function ls(e,t){return t(e)}var hs=$r((function(e){var t=e.length,i=t?e[0]:0,r=this.__wrapped__,a=function(t){return ii(t,e)};return!(t>1||this.__actions__.length)&&r instanceof Hn&&fa(i)?((r=r.slice(i,+i+(t?1:0))).__actions__.push({func:ls,args:[a],thisArg:n}),new zn(r,this.__chain__).thru((function(e){return t&&!e.length&&e.push(n),e}))):this.thru(a)})),cs=Ar((function(e,t,n){Ie.call(e,n)?++e[n]:ni(e,n,1)})),us=Dr(Ua),ds=Dr(Ba);function ps(e,t){return(Bs(e)?St:hi)(e,ra(t,3))}function fs(e,t){return(Bs(e)?Mt:ci)(e,ra(t,3))}var ms=Ar((function(e,t,n){Ie.call(e,n)?e[n].push(t):ni(e,n,[t])})),gs=Xi((function(e,t,n){var i=-1,r="function"==typeof t,a=Hs(e)?xe(e.length):[];return hi(e,(function(e){a[++i]=r?_t(t,e,n):Ai(e,t,n)})),a})),vs=Ar((function(e,t,n){ni(e,n,t)}));function ys(e,t){return(Bs(e)?Pt:ki)(e,ra(t,3))}var xs=Ar((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]})),bs=Xi((function(e,t){if(null==e)return[];var n=t.length;return n>1&&ma(e,t[0],t[1])?t=[]:n>2&&ma(t[0],t[1],t[2])&&(t=[t[0]]),zi(e,fi(t,1),[])})),_s=ct||function(){return ht.Date.now()};function ws(e,t,i){return t=i?n:t,t=e&&null==t?e.length:t,Yr(e,o,n,n,n,n,t)}function Ss(e,t){var r;if("function"!=typeof t)throw new Ae(i);return e=ho(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=n),r}}var Ms=Xi((function(e,t,n){var i=1;if(n.length){var r=an(n,ia(Ms));i|=s}return Yr(e,i,t,n,r)})),Ts=Xi((function(e,t,n){var i=3;if(n.length){var r=an(n,ia(Ts));i|=s}return Yr(t,i,e,n,r)}));function Es(e,t,r){var a,s,o,l,h,c,u=0,d=!1,p=!1,f=!0;if("function"!=typeof e)throw new Ae(i);function m(t){var i=a,r=s;return a=s=n,u=t,l=e.apply(r,i)}function g(e){var i=e-c;return c===n||i>=t||i<0||p&&e-u>=o}function v(){var e=_s();if(g(e))return y(e);h=Ea(v,function(e){var n=t-(e-c);return p?gn(n,o-(e-u)):n}(e))}function y(e){return h=n,f&&a?m(e):(a=s=n,l)}function x(){var e=_s(),i=g(e);if(a=arguments,s=this,c=e,i){if(h===n)return function(e){return u=e,h=Ea(v,t),d?m(e):l}(c);if(p)return yr(h),h=Ea(v,t),m(c)}return h===n&&(h=Ea(v,t)),l}return t=uo(t)||0,Js(r)&&(d=!!r.leading,o=(p="maxWait"in r)?mn(uo(r.maxWait)||0,t):o,f="trailing"in r?!!r.trailing:f),x.cancel=function(){h!==n&&yr(h),u=0,a=c=s=h=n},x.flush=function(){return h===n?l:y(_s())},x}var As=Xi((function(e,t){return oi(e,1,t)})),Cs=Xi((function(e,t,n){return oi(e,uo(t)||0,n)}));function Ps(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ae(i);var n=function(){var i=arguments,r=t?t.apply(this,i):i[0],a=n.cache;if(a.has(r))return a.get(r);var s=e.apply(this,i);return n.cache=a.set(r,s)||a,s};return n.cache=new(Ps.Cache||Gn),n}function Rs(e){if("function"!=typeof e)throw new Ae(i);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Ps.Cache=Gn;var Os=gr((function(e,t){var n=(t=1==t.length&&Bs(t[0])?Pt(t[0],Yt(ra())):Pt(fi(t,1),Yt(ra()))).length;return Xi((function(i){for(var r=-1,a=gn(i.length,n);++r=t})),Us=Ci(function(){return arguments}())?Ci:function(e){return Zs(e)&&Ie.call(e,"callee")&&!Xe.call(e,"callee")},Bs=xe.isArray,zs=mt?Yt(mt):function(e){return Zs(e)&&wi(e)==P};function Hs(e){return null!=e&&qs(e.length)&&!Xs(e)}function Vs(e){return Zs(e)&&Hs(e)}var js=Vt||dl,Gs=gt?Yt(gt):function(e){return Zs(e)&&wi(e)==g};function Ws(e){if(!Zs(e))return!1;var t=wi(e);return t==v||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!Qs(e)}function Xs(e){if(!Js(e))return!1;var t=wi(e);return t==y||t==x||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Ys(e){return"number"==typeof e&&e==ho(e)}function qs(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=h}function Js(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Zs(e){return null!=e&&"object"==typeof e}var Ks=vt?Yt(vt):function(e){return Zs(e)&&ca(e)==b};function $s(e){return"number"==typeof e||Zs(e)&&wi(e)==_}function Qs(e){if(!Zs(e)||wi(e)!=w)return!1;var t=Ge(e);if(null===t)return!0;var n=Ie.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Le.call(n)==Fe}var eo=yt?Yt(yt):function(e){return Zs(e)&&wi(e)==M},to=xt?Yt(xt):function(e){return Zs(e)&&ca(e)==T};function no(e){return"string"==typeof e||!Bs(e)&&Zs(e)&&wi(e)==E}function io(e){return"symbol"==typeof e||Zs(e)&&wi(e)==A}var ro=bt?Yt(bt):function(e){return Zs(e)&&qs(e.length)&&!!nt[wi(e)]},ao=Vr(Di),so=Vr((function(e,t){return e<=t}));function oo(e){if(!e)return[];if(Hs(e))return no(e)?ln(e):Tr(e);if($e&&e[$e])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[$e]());var t=ca(e);return(t==b?nn:t==T?sn:No)(e)}function lo(e){return e?(e=uo(e))===l||e===-l?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function ho(e){var t=lo(e),n=t%1;return t==t?n?t-n:t:0}function co(e){return e?ri(ho(e),0,u):0}function uo(e){if("number"==typeof e)return e;if(io(e))return c;if(Js(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Js(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Xt(e);var n=de.test(e);return n||fe.test(e)?st(e.slice(2),n?2:8):ue.test(e)?c:+e}function po(e){return Er(e,Co(e))}function fo(e){return null==e?"":ar(e)}var mo=Cr((function(e,t){if(xa(t)||Hs(t))Er(t,Ao(t),e);else for(var n in t)Ie.call(t,n)&&$n(e,n,t[n])})),go=Cr((function(e,t){Er(t,Co(t),e)})),vo=Cr((function(e,t,n,i){Er(t,Co(t),e,i)})),yo=Cr((function(e,t,n,i){Er(t,Ao(t),e,i)})),xo=$r(ii),bo=Xi((function(e,t){e=Me(e);var i=-1,r=t.length,a=r>2?t[2]:n;for(a&&ma(t[0],t[1],a)&&(r=1);++i1),t})),Er(e,ea(e),n),i&&(n=ai(n,7,Zr));for(var r=t.length;r--;)or(n,t[r]);return n})),Lo=$r((function(e,t){return null==e?{}:function(e,t){return Hi(e,t,(function(t,n){return So(e,n)}))}(e,t)}));function Io(e,t){if(null==e)return{};var n=Pt(ea(e),(function(e){return[e]}));return t=ra(t),Hi(e,n,(function(e,n){return t(e,n[0])}))}var Do=Xr(Ao),ko=Xr(Co);function No(e){return null==e?[]:qt(e,Ao(e))}var Fo=Lr((function(e,t,n){return t=t.toLowerCase(),e+(n?Uo(t):t)}));function Uo(e){return Xo(fo(e).toLowerCase())}function Bo(e){return(e=fo(e))&&e.replace(ge,$t).replace(Je,"")}var zo=Lr((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),Ho=Lr((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),Vo=Or("toLowerCase"),jo=Lr((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()})),Go=Lr((function(e,t,n){return e+(n?" ":"")+Xo(t)})),Wo=Lr((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Xo=Or("toUpperCase");function Yo(e,t,i){return e=fo(e),(t=i?n:t)===n?function(e){return Qe.test(e)}(e)?function(e){return e.match(Ke)||[]}(e):function(e){return e.match(se)||[]}(e):e.match(t)||[]}var qo=Xi((function(e,t){try{return _t(e,n,t)}catch(e){return Ws(e)?e:new _e(e)}})),Jo=$r((function(e,t){return St(t,(function(t){t=La(t),ni(e,t,Ms(e[t],e))})),e}));function Zo(e){return function(){return e}}var Ko=kr(),$o=kr(!0);function Qo(e){return e}function el(e){return Li("function"==typeof e?e:ai(e,1))}var tl=Xi((function(e,t){return function(n){return Ai(n,e,t)}})),nl=Xi((function(e,t){return function(n){return Ai(e,n,t)}}));function il(e,t,n){var i=Ao(t),r=xi(t,i);null==n&&(!Js(t)||!r.length&&i.length)&&(n=t,t=e,e=this,r=xi(t,Ao(t)));var a=!(Js(n)&&"chain"in n&&!n.chain),s=Xs(e);return St(r,(function(n){var i=t[n];e[n]=i,s&&(e.prototype[n]=function(){var t=this.__chain__;if(a||t){var n=e(this.__wrapped__);return(n.__actions__=Tr(this.__actions__)).push({func:i,args:arguments,thisArg:e}),n.__chain__=t,n}return i.apply(e,Rt([this.value()],arguments))})})),e}function rl(){}var al=Br(Pt),sl=Br(Tt),ol=Br(It);function ll(e){return ga(e)?Ht(La(e)):function(e){return function(t){return bi(t,e)}}(e)}var hl=Hr(),cl=Hr(!0);function ul(){return[]}function dl(){return!1}var pl=Ur((function(e,t){return e+t}),0),fl=Gr("ceil"),ml=Ur((function(e,t){return e/t}),1),gl=Gr("floor"),vl=Ur((function(e,t){return e*t}),1),yl=Gr("round"),xl=Ur((function(e,t){return e-t}),0);return Fn.after=function(e,t){if("function"!=typeof t)throw new Ae(i);return e=ho(e),function(){if(--e<1)return t.apply(this,arguments)}},Fn.ary=ws,Fn.assign=mo,Fn.assignIn=go,Fn.assignInWith=vo,Fn.assignWith=yo,Fn.at=xo,Fn.before=Ss,Fn.bind=Ms,Fn.bindAll=Jo,Fn.bindKey=Ts,Fn.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Bs(e)?e:[e]},Fn.chain=os,Fn.chunk=function(e,t,i){t=(i?ma(e,t,i):t===n)?1:mn(ho(t),0);var r=null==e?0:e.length;if(!r||t<1)return[];for(var a=0,s=0,o=xe(pt(r/t));aa?0:a+i),(r=r===n||r>a?a:ho(r))<0&&(r+=a),r=i>r?0:co(r);i>>0)?(e=fo(e))&&("string"==typeof t||null!=t&&!eo(t))&&!(t=ar(t))&&tn(e)?vr(ln(e),0,i):e.split(t,i):[]},Fn.spread=function(e,t){if("function"!=typeof e)throw new Ae(i);return t=null==t?0:mn(ho(t),0),Xi((function(n){var i=n[t],r=vr(n,0,t);return i&&Rt(r,i),_t(e,this,r)}))},Fn.tail=function(e){var t=null==e?0:e.length;return t?Qi(e,1,t):[]},Fn.take=function(e,t,i){return e&&e.length?Qi(e,0,(t=i||t===n?1:ho(t))<0?0:t):[]},Fn.takeRight=function(e,t,i){var r=null==e?0:e.length;return r?Qi(e,(t=r-(t=i||t===n?1:ho(t)))<0?0:t,r):[]},Fn.takeRightWhile=function(e,t){return e&&e.length?hr(e,ra(t,3),!1,!0):[]},Fn.takeWhile=function(e,t){return e&&e.length?hr(e,ra(t,3)):[]},Fn.tap=function(e,t){return t(e),e},Fn.throttle=function(e,t,n){var r=!0,a=!0;if("function"!=typeof e)throw new Ae(i);return Js(n)&&(r="leading"in n?!!n.leading:r,a="trailing"in n?!!n.trailing:a),Es(e,t,{leading:r,maxWait:t,trailing:a})},Fn.thru=ls,Fn.toArray=oo,Fn.toPairs=Do,Fn.toPairsIn=ko,Fn.toPath=function(e){return Bs(e)?Pt(e,La):io(e)?[e]:Tr(Oa(fo(e)))},Fn.toPlainObject=po,Fn.transform=function(e,t,n){var i=Bs(e),r=i||js(e)||ro(e);if(t=ra(t,4),null==n){var a=e&&e.constructor;n=r?i?new a:[]:Js(e)&&Xs(a)?Un(Ge(e)):{}}return(r?St:vi)(e,(function(e,i,r){return t(n,e,i,r)})),n},Fn.unary=function(e){return ws(e,1)},Fn.union=Za,Fn.unionBy=Ka,Fn.unionWith=$a,Fn.uniq=function(e){return e&&e.length?sr(e):[]},Fn.uniqBy=function(e,t){return e&&e.length?sr(e,ra(t,2)):[]},Fn.uniqWith=function(e,t){return t="function"==typeof t?t:n,e&&e.length?sr(e,n,t):[]},Fn.unset=function(e,t){return null==e||or(e,t)},Fn.unzip=Qa,Fn.unzipWith=es,Fn.update=function(e,t,n){return null==e?e:lr(e,t,fr(n))},Fn.updateWith=function(e,t,i,r){return r="function"==typeof r?r:n,null==e?e:lr(e,t,fr(i),r)},Fn.values=No,Fn.valuesIn=function(e){return null==e?[]:qt(e,Co(e))},Fn.without=ts,Fn.words=Yo,Fn.wrap=function(e,t){return Ls(fr(t),e)},Fn.xor=ns,Fn.xorBy=is,Fn.xorWith=rs,Fn.zip=as,Fn.zipObject=function(e,t){return dr(e||[],t||[],$n)},Fn.zipObjectDeep=function(e,t){return dr(e||[],t||[],Ji)},Fn.zipWith=ss,Fn.entries=Do,Fn.entriesIn=ko,Fn.extend=go,Fn.extendWith=vo,il(Fn,Fn),Fn.add=pl,Fn.attempt=qo,Fn.camelCase=Fo,Fn.capitalize=Uo,Fn.ceil=fl,Fn.clamp=function(e,t,i){return i===n&&(i=t,t=n),i!==n&&(i=(i=uo(i))==i?i:0),t!==n&&(t=(t=uo(t))==t?t:0),ri(uo(e),t,i)},Fn.clone=function(e){return ai(e,4)},Fn.cloneDeep=function(e){return ai(e,5)},Fn.cloneDeepWith=function(e,t){return ai(e,5,t="function"==typeof t?t:n)},Fn.cloneWith=function(e,t){return ai(e,4,t="function"==typeof t?t:n)},Fn.conformsTo=function(e,t){return null==t||si(e,t,Ao(t))},Fn.deburr=Bo,Fn.defaultTo=function(e,t){return null==e||e!=e?t:e},Fn.divide=ml,Fn.endsWith=function(e,t,i){e=fo(e),t=ar(t);var r=e.length,a=i=i===n?r:ri(ho(i),0,r);return(i-=t.length)>=0&&e.slice(i,a)==t},Fn.eq=ks,Fn.escape=function(e){return(e=fo(e))&&X.test(e)?e.replace(G,Qt):e},Fn.escapeRegExp=function(e){return(e=fo(e))&&ee.test(e)?e.replace(Q,"\\$&"):e},Fn.every=function(e,t,i){var r=Bs(e)?Tt:ui;return i&&ma(e,t,i)&&(t=n),r(e,ra(t,3))},Fn.find=us,Fn.findIndex=Ua,Fn.findKey=function(e,t){return kt(e,ra(t,3),vi)},Fn.findLast=ds,Fn.findLastIndex=Ba,Fn.findLastKey=function(e,t){return kt(e,ra(t,3),yi)},Fn.floor=gl,Fn.forEach=ps,Fn.forEachRight=fs,Fn.forIn=function(e,t){return null==e?e:mi(e,ra(t,3),Co)},Fn.forInRight=function(e,t){return null==e?e:gi(e,ra(t,3),Co)},Fn.forOwn=function(e,t){return e&&vi(e,ra(t,3))},Fn.forOwnRight=function(e,t){return e&&yi(e,ra(t,3))},Fn.get=wo,Fn.gt=Ns,Fn.gte=Fs,Fn.has=function(e,t){return null!=e&&ua(e,t,Mi)},Fn.hasIn=So,Fn.head=Ha,Fn.identity=Qo,Fn.includes=function(e,t,n,i){e=Hs(e)?e:No(e),n=n&&!i?ho(n):0;var r=e.length;return n<0&&(n=mn(r+n,0)),no(e)?n<=r&&e.indexOf(t,n)>-1:!!r&&Ft(e,t,n)>-1},Fn.indexOf=function(e,t,n){var i=null==e?0:e.length;if(!i)return-1;var r=null==n?0:ho(n);return r<0&&(r=mn(i+r,0)),Ft(e,t,r)},Fn.inRange=function(e,t,i){return t=lo(t),i===n?(i=t,t=0):i=lo(i),function(e,t,n){return e>=gn(t,n)&&e=-h&&e<=h},Fn.isSet=to,Fn.isString=no,Fn.isSymbol=io,Fn.isTypedArray=ro,Fn.isUndefined=function(e){return e===n},Fn.isWeakMap=function(e){return Zs(e)&&ca(e)==C},Fn.isWeakSet=function(e){return Zs(e)&&"[object WeakSet]"==wi(e)},Fn.join=function(e,t){return null==e?"":pn.call(e,t)},Fn.kebabCase=zo,Fn.last=Wa,Fn.lastIndexOf=function(e,t,i){var r=null==e?0:e.length;if(!r)return-1;var a=r;return i!==n&&(a=(a=ho(i))<0?mn(r+a,0):gn(a,r-1)),t==t?function(e,t,n){for(var i=n+1;i--;)if(e[i]===t)return i;return i}(e,t,a):Nt(e,Bt,a,!0)},Fn.lowerCase=Ho,Fn.lowerFirst=Vo,Fn.lt=ao,Fn.lte=so,Fn.max=function(e){return e&&e.length?di(e,Qo,Si):n},Fn.maxBy=function(e,t){return e&&e.length?di(e,ra(t,2),Si):n},Fn.mean=function(e){return zt(e,Qo)},Fn.meanBy=function(e,t){return zt(e,ra(t,2))},Fn.min=function(e){return e&&e.length?di(e,Qo,Di):n},Fn.minBy=function(e,t){return e&&e.length?di(e,ra(t,2),Di):n},Fn.stubArray=ul,Fn.stubFalse=dl,Fn.stubObject=function(){return{}},Fn.stubString=function(){return""},Fn.stubTrue=function(){return!0},Fn.multiply=vl,Fn.nth=function(e,t){return e&&e.length?Bi(e,ho(t)):n},Fn.noConflict=function(){return ht._===this&&(ht._=Ue),this},Fn.noop=rl,Fn.now=_s,Fn.pad=function(e,t,n){e=fo(e);var i=(t=ho(t))?on(e):0;if(!t||i>=t)return e;var r=(t-i)/2;return zr(ft(r),n)+e+zr(pt(r),n)},Fn.padEnd=function(e,t,n){e=fo(e);var i=(t=ho(t))?on(e):0;return t&&it){var r=e;e=t,t=r}if(i||e%1||t%1){var a=xn();return gn(e+a*(t-e+at("1e-"+((a+"").length-1))),t)}return Gi(e,t)},Fn.reduce=function(e,t,n){var i=Bs(e)?Ot:jt,r=arguments.length<3;return i(e,ra(t,4),n,r,hi)},Fn.reduceRight=function(e,t,n){var i=Bs(e)?Lt:jt,r=arguments.length<3;return i(e,ra(t,4),n,r,ci)},Fn.repeat=function(e,t,i){return t=(i?ma(e,t,i):t===n)?1:ho(t),Wi(fo(e),t)},Fn.replace=function(){var e=arguments,t=fo(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Fn.result=function(e,t,i){var r=-1,a=(t=mr(t,e)).length;for(a||(a=1,e=n);++rh)return[];var n=u,i=gn(e,u);t=ra(t),e-=u;for(var r=Wt(i,t);++n=s)return e;var l=i-on(r);if(l<1)return r;var h=o?vr(o,0,l).join(""):e.slice(0,l);if(a===n)return h+r;if(o&&(l+=h.length-l),eo(a)){if(e.slice(l).search(a)){var c,u=h;for(a.global||(a=Te(a.source,fo(ce.exec(a))+"g")),a.lastIndex=0;c=a.exec(u);)var d=c.index;h=h.slice(0,d===n?l:d)}}else if(e.indexOf(ar(a),l)!=l){var p=h.lastIndexOf(a);p>-1&&(h=h.slice(0,p))}return h+r},Fn.unescape=function(e){return(e=fo(e))&&W.test(e)?e.replace(j,cn):e},Fn.uniqueId=function(e){var t=++De;return fo(e)+t},Fn.upperCase=Wo,Fn.upperFirst=Xo,Fn.each=ps,Fn.eachRight=fs,Fn.first=Ha,il(Fn,function(){var e={};return vi(Fn,(function(t,n){Ie.call(Fn.prototype,n)||(e[n]=t)})),e}(),{chain:!1}),Fn.VERSION="4.17.21",St(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Fn[e].placeholder=Fn})),St(["drop","take"],(function(e,t){Hn.prototype[e]=function(i){i=i===n?1:mn(ho(i),0);var r=this.__filtered__&&!t?new Hn(this):this.clone();return r.__filtered__?r.__takeCount__=gn(i,r.__takeCount__):r.__views__.push({size:gn(i,u),type:e+(r.__dir__<0?"Right":"")}),r},Hn.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),St(["filter","map","takeWhile"],(function(e,t){var n=t+1,i=1==n||3==n;Hn.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:ra(e,3),type:n}),t.__filtered__=t.__filtered__||i,t}})),St(["head","last"],(function(e,t){var n="take"+(t?"Right":"");Hn.prototype[e]=function(){return this[n](1).value()[0]}})),St(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");Hn.prototype[e]=function(){return this.__filtered__?new Hn(this):this[n](1)}})),Hn.prototype.compact=function(){return this.filter(Qo)},Hn.prototype.find=function(e){return this.filter(e).head()},Hn.prototype.findLast=function(e){return this.reverse().find(e)},Hn.prototype.invokeMap=Xi((function(e,t){return"function"==typeof e?new Hn(this):this.map((function(n){return Ai(n,e,t)}))})),Hn.prototype.reject=function(e){return this.filter(Rs(ra(e)))},Hn.prototype.slice=function(e,t){e=ho(e);var i=this;return i.__filtered__&&(e>0||t<0)?new Hn(i):(e<0?i=i.takeRight(-e):e&&(i=i.drop(e)),t!==n&&(i=(t=ho(t))<0?i.dropRight(-t):i.take(t-e)),i)},Hn.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Hn.prototype.toArray=function(){return this.take(u)},vi(Hn.prototype,(function(e,t){var i=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),a=Fn[r?"take"+("last"==t?"Right":""):t],s=r||/^find/.test(t);a&&(Fn.prototype[t]=function(){var t=this.__wrapped__,o=r?[1]:arguments,l=t instanceof Hn,h=o[0],c=l||Bs(t),u=function(e){var t=a.apply(Fn,Rt([e],o));return r&&d?t[0]:t};c&&i&&"function"==typeof h&&1!=h.length&&(l=c=!1);var d=this.__chain__,p=!!this.__actions__.length,f=s&&!d,m=l&&!p;if(!s&&c){t=m?t:new Hn(this);var g=e.apply(t,o);return g.__actions__.push({func:ls,args:[u],thisArg:n}),new zn(g,d)}return f&&m?e.apply(this,o):(g=this.thru(u),f?r?g.value()[0]:g.value():g)})})),St(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Ce[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",i=/^(?:pop|shift)$/.test(e);Fn.prototype[e]=function(){var e=arguments;if(i&&!this.__chain__){var r=this.value();return t.apply(Bs(r)?r:[],e)}return this[n]((function(n){return t.apply(Bs(n)?n:[],e)}))}})),vi(Hn.prototype,(function(e,t){var n=Fn[t];if(n){var i=n.name+"";Ie.call(Cn,i)||(Cn[i]=[]),Cn[i].push({name:t,func:n})}})),Cn[Nr(n,2).name]=[{name:"wrapper",func:n}],Hn.prototype.clone=function(){var e=new Hn(this.__wrapped__);return e.__actions__=Tr(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Tr(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Tr(this.__views__),e},Hn.prototype.reverse=function(){if(this.__filtered__){var e=new Hn(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Hn.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Bs(e),i=t<0,r=n?e.length:0,a=function(e,t,n){for(var i=-1,r=n.length;++i=this.__values__.length;return{done:e,value:e?n:this.__values__[this.__index__++]}},Fn.prototype.plant=function(e){for(var t,i=this;i instanceof Bn;){var r=Da(i);r.__index__=0,r.__values__=n,t?a.__wrapped__=r:t=r;var a=r;i=i.__wrapped__}return a.__wrapped__=e,t},Fn.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Hn){var t=e;return this.__actions__.length&&(t=new Hn(this)),(t=t.reverse()).__actions__.push({func:ls,args:[Ja],thisArg:n}),new zn(t,this.__chain__)}return this.thru(Ja)},Fn.prototype.toJSON=Fn.prototype.valueOf=Fn.prototype.value=function(){return cr(this.__wrapped__,this.__actions__)},Fn.prototype.first=Fn.prototype.head,$e&&(Fn.prototype[$e]=function(){return this}),Fn}();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(ht._=un,define((function(){return un}))):ut?((ut.exports=un)._=un,ct._=un):ht._=un}).call(e)})),upe=J(((e,t)=>{var n,i;n=e,i=function(){"use strict";function e(e,i,r,a,s){!function e(n,i,r,a,s){for(;a>r;){if(a-r>600){var o=a-r+1,l=i-r+1,h=Math.log(o),c=.5*Math.exp(2*h/3),u=.5*Math.sqrt(h*c*(o-c)/o)*(l-o/2<0?-1:1);e(n,i,Math.max(r,Math.floor(i-l*c/o+u)),Math.min(a,Math.floor(i+(o-l)*c/o+u)),s)}var d=n[i],p=r,f=a;for(t(n,r,i),s(n[a],d)>0&&t(n,r,a);p0;)f--}0===s(n[r],d)?t(n,r,f):t(n,++f,a),f<=i&&(r=f+1),i<=f&&(a=f-1)}}(e,i,r||0,a||e.length-1,s||n)}function t(e,t,n){var i=e[t];e[t]=e[n],e[n]=i}function n(e,t){return et?1:0}var i=function(e){void 0===e&&(e=9),this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()};function r(e,t,n){if(!n)return t.indexOf(e);for(var i=0;i=e.minX&&t.maxY>=e.minY}function f(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function m(t,n,i,r,a){for(var s=[n,i];s.length;)if(!((i=s.pop())-(n=s.pop())<=r)){var o=n+Math.ceil((i-n)/r/2)*r;e(t,o,n,i,a),s.push(n,o,o,i)}}return i.prototype.all=function(){return this._all(this.data,[])},i.prototype.search=function(e){var t=this.data,n=[];if(!p(e,t))return n;for(var i=this.toBBox,r=[];t;){for(var a=0;a=0&&r[t].children.length>this._maxEntries;)this._split(r,t),t--;this._adjustParentBBoxes(i,r,t)},i.prototype._split=function(e,t){var n=e[t],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);var s=this._chooseSplitIndex(n,r,i),o=f(n.children.splice(s,n.children.length-s));o.height=n.height,o.leaf=n.leaf,a(n,this.toBBox),a(o,this.toBBox),t?e[t-1].children.push(o):this._splitRoot(n,o)},i.prototype._splitRoot=function(e,t){this.data=f([e,t]),this.data.height=e.height+1,this.data.leaf=!1,a(this.data,this.toBBox)},i.prototype._chooseSplitIndex=function(e,t,n){for(var i,r,a,o,l,h,u,d=1/0,p=1/0,f=t;f<=n-t;f++){var m=s(e,0,f,this.toBBox),g=s(e,f,n,this.toBBox),v=(r=m,a=g,o=Math.max(r.minX,a.minX),l=Math.max(r.minY,a.minY),h=Math.min(r.maxX,a.maxX),u=Math.min(r.maxY,a.maxY),Math.max(0,h-o)*Math.max(0,u-l)),y=c(m)+c(g);v=t;p--){var f=e.children[p];o(l,e.leaf?r(f):f),h+=u(l)}return h},i.prototype._adjustParentBBoxes=function(e,t,n){for(var i=n;i>=0;i--)o(t[i],e)},i.prototype._condense=function(e){for(var t=e.length-1,n=void 0;t>=0;t--)0===e[t].children.length?t>0?(n=e[t-1].children).splice(n.indexOf(e[t]),1):this.clear():a(e[t],this.toBBox)},i},"object"==typeof e&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define(i):(n=n||self).RBush=i()})),hpe=J(((e,t)=>{var n,i;n=e,i=function(){"use strict";var e=function(e,n){if(void 0===e&&(e=[]),void 0===n&&(n=t),this.data=e,this.length=this.data.length,this.compare=n,this.length>0)for(var i=(this.length>>1)-1;i>=0;i--)this._down(i)};function t(e,t){return et?1:0}return e.prototype.push=function(e){this.data.push(e),this.length++,this._up(this.length-1)},e.prototype.pop=function(){if(0!==this.length){var e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}},e.prototype.peek=function(){return this.data[0]},e.prototype._up=function(e){for(var t=this.data,n=this.compare,i=t[e];e>0;){var r=e-1>>1,a=t[r];if(n(i,a)>=0)break;t[e]=a,e=r}t[e]=i},e.prototype._down=function(e){for(var t=this.data,n=this.compare,i=this.length>>1,r=t[e];e=0)break;t[e]=s,e=a}t[e]=r},e},"object"==typeof e&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define(i):(n=n||self).TinyQueue=i()})),fpe=J(((e,t)=>{t.exports=function(e,t,n,i){var r=e[0],a=e[1],s=!1;void 0===n&&(n=0),void 0===i&&(i=t.length);for(var o=(i-n)/2,l=0,h=o-1;la!=p>a&&r<(d-c)*(a-u)/(p-u)+c&&(s=!s)}return s}})),mpe=J(((e,t)=>{t.exports=function(e,t,n,i){var r=e[0],a=e[1],s=!1;void 0===n&&(n=0),void 0===i&&(i=t.length);for(var o=i-n,l=0,h=o-1;la!=p>a&&r<(d-c)*(a-u)/(p-u)+c&&(s=!s)}return s}})),ype=J(((e,t)=>{var n=fpe(),i=mpe();t.exports=function(e,t,r,a){return t.length>0&&Array.isArray(t[0])?i(e,t,r,a):n(e,t,r,a)},t.exports.nested=i,t.exports.flat=n})),bpe=J(((e,t)=>{var n,i;n=e,i=function(e){"use strict";function t(e,t,n,i,r){let a,s,o,l,h=t[0],c=i[0],u=0,d=0;c>h==c>-h?(a=h,h=t[++u]):(a=c,c=i[++d]);let p=0;if(uh==c>-h?(o=a-((s=h+a)-h),h=t[++u]):(o=a-((s=c+a)-c),c=i[++d]),a=s,0!==o&&(r[p++]=o);uh==c>-h?(o=a-((s=a+h)-(l=s-a))+(h-l),h=t[++u]):(o=a-((s=a+c)-(l=s-a))+(c-l),c=i[++d]),a=s,0!==o&&(r[p++]=o);for(;u0!=p>0)return f;let m=Math.abs(d+p);return Math.abs(f)>=33306690738754716e-32*m?f:-function(e,n,l,h,c,u,d){let p,f,m,g,v,y,x,b,_,w,S,M,T,E,A,C,P,R,O=e-c,L=l-c,I=n-u,D=h-u;v=(A=(b=O-(x=(y=134217729*O)-(y-O)))*(w=D-(_=(y=134217729*D)-(y-D)))-((E=O*D)-x*_-b*_-x*w))-(S=A-(P=(b=I-(x=(y=134217729*I)-(y-I)))*(w=L-(_=(y=134217729*L)-(y-L)))-((C=I*L)-x*_-b*_-x*w))),i[0]=A-(S+v)+(v-P),v=(T=E-((M=E+S)-(v=M-E))+(S-v))-(S=T-C),i[1]=T-(S+v)+(v-C),v=(R=M+S)-M,i[2]=M-(R-v)+(S-v),i[3]=R;let k=function(e,t){let n=t[0];for(let i=1;i<4;i++)n+=t[i];return n}(0,i),N=22204460492503146e-32*d;if(k>=N||-k>=N||(p=e-(O+(v=e-O))+(v-c),m=l-(L+(v=l-L))+(v-c),f=n-(I+(v=n-I))+(v-u),g=h-(D+(v=h-D))+(v-u),0===p&&0===f&&0===m&&0===g)||(N=11093356479670487e-47*d+33306690738754706e-32*Math.abs(k),(k+=O*g+D*p-(I*m+L*f))>=N||-k>=N))return k;v=(A=(b=p-(x=(y=134217729*p)-(y-p)))*(w=D-(_=(y=134217729*D)-(y-D)))-((E=p*D)-x*_-b*_-x*w))-(S=A-(P=(b=f-(x=(y=134217729*f)-(y-f)))*(w=L-(_=(y=134217729*L)-(y-L)))-((C=f*L)-x*_-b*_-x*w))),o[0]=A-(S+v)+(v-P),v=(T=E-((M=E+S)-(v=M-E))+(S-v))-(S=T-C),o[1]=T-(S+v)+(v-C),v=(R=M+S)-M,o[2]=M-(R-v)+(S-v),o[3]=R;let F=t(4,i,4,o,r);v=(A=(b=O-(x=(y=134217729*O)-(y-O)))*(w=g-(_=(y=134217729*g)-(y-g)))-((E=O*g)-x*_-b*_-x*w))-(S=A-(P=(b=I-(x=(y=134217729*I)-(y-I)))*(w=m-(_=(y=134217729*m)-(y-m)))-((C=I*m)-x*_-b*_-x*w))),o[0]=A-(S+v)+(v-P),v=(T=E-((M=E+S)-(v=M-E))+(S-v))-(S=T-C),o[1]=T-(S+v)+(v-C),v=(R=M+S)-M,o[2]=M-(R-v)+(S-v),o[3]=R;let U=t(F,r,4,o,a);v=(A=(b=p-(x=(y=134217729*p)-(y-p)))*(w=g-(_=(y=134217729*g)-(y-g)))-((E=p*g)-x*_-b*_-x*w))-(S=A-(P=(b=f-(x=(y=134217729*f)-(y-f)))*(w=m-(_=(y=134217729*m)-(y-m)))-((C=f*m)-x*_-b*_-x*w))),o[0]=A-(S+v)+(v-P),v=(T=E-((M=E+S)-(v=M-E))+(S-v))-(S=T-C),o[1]=T-(S+v)+(v-C),v=(R=M+S)-M,o[2]=M-(R-v)+(S-v),o[3]=R;let B=t(U,a,4,o,s);return s[B-1]}(e,n,l,h,c,u,m)},e.orient2dfast=function(e,t,n,i,r,a){return(t-a)*(n-r)-(e-r)*(i-a)},Object.defineProperty(e,"__esModule",{value:!0})},"object"==typeof e&&void 0!==t?i(e):"function"==typeof define&&define.amd?define(["exports"],i):i((n=n||self).predicates={})})),Mpe=J(((e,t)=>{"use strict";var n=upe(),i=hpe(),r=ype(),a=bpe().orient2d;function s(e,t,i){t=Math.max(0,void 0===t?2:t),i=i||0;var a=function(e){for(var t=e[0],n=e[0],i=e[0],a=e[0],s=0;si[0]&&(i=o),o[1]a[1]&&(a=o)}var l=[t,n,i,a],h=l.slice();for(s=0;s=2&&d(t[t.length-2],t[t.length-1],e[n])<=0;)t.pop();t.push(e[n])}for(var i=[],r=e.length-1;r>=0;r--){for(;i.length>=2&&d(i[i.length-2],i[i.length-1],e[r])<=0;)i.pop();i.push(e[r])}return i.pop(),t.pop(),t.concat(i)}(h)}(e),s=new n(16);s.toBBox=function(e){return{minX:e[0],minY:e[1],maxX:e[0],maxY:e[1]}},s.compareMinX=function(e,t){return e[0]-t[0]},s.compareMinY=function(e,t){return e[1]-t[1]},s.load(e);for(var l,h=[],c=0;cs||c.push({node:f,dist:m})}for(;c.length&&!c.peek().node.children;){var g=c.pop(),y=g.node,x=v(y,t,n),b=v(y,r,a);if(g.dist=t.minX&&e[0]<=t.maxX&&e[1]>=t.minY&&e[1]<=t.maxY}function u(e,t,n){for(var i=Math.min(e[0],t[0]),r=Math.min(e[1],t[1]),a=Math.max(e[0],t[0]),s=Math.max(e[1],t[1]),o=n.search({minX:i,minY:r,maxX:a,maxY:s}),l=0;l0!=d(e,t,i)>0&&d(n,i,e)>0!=d(n,i,t)>0}function f(e){var t=e.p,n=e.next.p;return e.minX=Math.min(t[0],n[0]),e.minY=Math.min(t[1],n[1]),e.maxX=Math.max(t[0],n[0]),e.maxY=Math.max(t[1],n[1]),e}function m(e,t){var n={p:e,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return t?(n.next=t.next,n.prev=t,t.next.prev=n,t.next=n):(n.prev=n,n.next=n),n}function g(e,t){var n=e[0]-t[0],i=e[1]-t[1];return n*n+i*i}function v(e,t,n){var i=t[0],r=t[1],a=n[0]-i,s=n[1]-r;if(0!==a||0!==s){var o=((e[0]-i)*a+(e[1]-r)*s)/(a*a+s*s);o>1?(i=n[0],r=n[1]):o>0&&(i+=a*o,r+=s*o)}return(a=e[0]-i)*a+(s=e[1]-r)*s}function y(e,t,n,i,r,a,s,o){var l,h,c,u,d=n-e,p=i-t,f=s-r,m=o-a,g=e-r,v=t-a,y=d*d+p*p,x=d*f+p*m,b=f*f+m*m,_=d*g+p*v,w=f*g+m*v,S=y*b-x*x,M=S,T=S;0===S?(h=0,M=1,u=w,T=b):(u=y*w-x*_,(h=x*w-b*_)<0?(h=0,u=w,T=b):h>M&&(h=M,u=w+x,T=b)),u<0?(u=0,-_<0?h=0:-_>y?h=M:(h=-_,M=y)):u>T&&(u=T,-_+x<0?h=0:-_+x>y?h=M:(h=-_+x,M=y));var E=(1-(c=0===u?0:u/T))*r+c*s-((1-(l=0===h?0:h/M))*e+l*n),A=(1-c)*a+c*o-((1-l)*t+l*i);return E*E+A*A}function x(e,t){return e[0]===t[0]?e[1]-t[1]:e[0]-t[0]}i.default&&(i=i.default),t.exports=s,t.exports.default=s})),Xpe=J(((e,t)=>{t.exports=function(){var e,t=0,n=!1;function i(t,n){return e.list.push({type:t,data:n?JSON.parse(JSON.stringify(n)):void 0}),e}return e={list:[],segmentId:function(){return t++},checkIntersection:function(e,t){return i("check",{seg1:e,seg2:t})},segmentChop:function(e,t){return i("div_seg",{seg:e,pt:t}),i("chop",{seg:e,pt:t})},statusRemove:function(e){return i("pop_seg",{seg:e})},segmentUpdate:function(e){return i("seg_update",{seg:e})},segmentNew:function(e,t){return i("new_seg",{seg:e,primary:t})},segmentRemove:function(e){return i("rem_seg",{seg:e})},tempStatus:function(e,t,n){return i("temp_status",{seg:e,above:t,below:n})},rewind:function(e){return i("rewind",{seg:e})},status:function(e,t,n){return i("status",{seg:e,above:t,below:n})},vert:function(t){return t===n?e:(n=t,i("vert",{x:t}))},log:function(e){return"string"!=typeof e&&(e=JSON.stringify(e,!1," ")),i("log",{txt:e})},reset:function(){return i("reset")},selected:function(e){return i("selected",{segs:e})},chainStart:function(e){return i("chain_start",{seg:e})},chainRemoveHead:function(e,t){return i("chain_rem_head",{index:e,pt:t})},chainRemoveTail:function(e,t){return i("chain_rem_tail",{index:e,pt:t})},chainNew:function(e,t){return i("chain_new",{pt1:e,pt2:t})},chainMatch:function(e){return i("chain_match",{index:e})},chainClose:function(e){return i("chain_close",{index:e})},chainAddHead:function(e,t){return i("chain_add_head",{index:e,pt:t})},chainAddTail:function(e,t){return i("chain_add_tail",{index:e,pt:t})},chainConnect:function(e,t){return i("chain_con",{index1:e,index2:t})},chainReverse:function(e){return i("chain_rev",{index:e})},chainJoin:function(e,t){return i("chain_join",{index1:e,index2:t})},done:function(){return i("done")}}}})),$pe=J(((e,t)=>{t.exports=function(e){"number"!=typeof e&&(e=1e-10);var t={epsilon:function(t){return"number"==typeof t&&(e=t),e},pointAboveOrOnLine:function(t,n,i){var r=n[0],a=n[1],s=i[0],o=i[1],l=t[0];return(s-r)*(t[1]-a)-(o-a)*(l-r)>=-e},pointBetween:function(t,n,i){var r=t[1]-n[1],a=i[0]-n[0],s=t[0]-n[0],o=i[1]-n[1],l=s*a+r*o;return!(l-e)},pointsSameX:function(t,n){return Math.abs(t[0]-n[0])e!=s-r>e&&(a-h)*(r-c)/(s-c)+h-i>e&&(o=!o),a=h,s=c}return o}};return t}})),Kpe=J(((e,t)=>{t.exports={create:function(){var e={root:{root:!0,next:null},exists:function(t){return!(null===t||t===e.root)},isEmpty:function(){return null===e.root.next},getHead:function(){return e.root.next},insertBefore:function(t,n){for(var i=e.root,r=e.root.next;null!==r;){if(n(r))return t.prev=r.prev,t.next=r,r.prev.next=t,void(r.prev=t);i=r,r=r.next}i.next=t,t.prev=i,t.next=null},findTransition:function(t){for(var n=e.root,i=e.root.next;null!==i&&!t(i);)n=i,i=i.next;return{before:n===e.root?null:n,after:i,insert:function(e){return e.prev=n,e.next=i,n.next=e,null!==i&&(i.prev=e),e}}}};return e},node:function(e){return e.prev=null,e.next=null,e.remove=function(){e.prev.next=e.next,e.next&&(e.next.prev=e.prev),e.prev=null,e.next=null},e}}})),Qpe=J(((e,t)=>{var n=Kpe();t.exports=function(e,t,i){function r(e,t){return{id:i?i.segmentId():-1,start:e,end:t,myFill:{above:null,below:null},otherFill:null}}function a(e,t,n){return{id:i?i.segmentId():-1,start:e,end:t,myFill:{above:n.myFill.above,below:n.myFill.below},otherFill:null}}var s=n.create();function o(e,n){s.insertBefore(e,(function(i){var r=function(e,n,i,r,a,s){var o=t.pointsCompare(n,a);return 0!==o?o:t.pointsSame(i,s)?0:e!==r?e?1:-1:t.pointAboveOrOnLine(i,r?a:s,r?s:a)?1:-1}(e.isStart,e.pt,n,i.isStart,i.pt,i.other.pt);return r<0}))}function l(e,t){var i=function(e,t){var i=n.node({isStart:!0,pt:e.start,seg:e,primary:t,other:null,status:null});return o(i,e.end),i}(e,t);return function(e,t,i){var r=n.node({isStart:!1,pt:t.end,seg:t,primary:i,other:e,status:null});e.other=r,o(r,e.pt)}(i,e,t),i}function h(e,t){var n=a(t,e.seg.end,e.seg);return function(e,t){i&&i.segmentChop(e.seg,t),e.other.remove(),e.seg.end=t,e.other.pt=t,o(e.other,e.pt)}(e,t),l(n,e.primary)}function c(r,a){var o=n.create();function l(e){return o.findTransition((function(n){var i=function(e,n){var i=e.seg.start,r=e.seg.end,a=n.seg.start,s=n.seg.end;return t.pointsCollinear(i,a,s)?t.pointsCollinear(r,a,s)||t.pointAboveOrOnLine(r,a,s)?1:-1:t.pointAboveOrOnLine(i,a,s)?1:-1}(e,n.ev);return i>0}))}function c(e,n){var r=e.seg,a=n.seg,s=r.start,o=r.end,l=a.start,c=a.end;i&&i.checkIntersection(r,a);var u=t.linesIntersect(s,o,l,c);if(!1===u){if(!t.pointsCollinear(s,o,l)||t.pointsSame(s,c)||t.pointsSame(o,l))return!1;var d=t.pointsSame(s,l),p=t.pointsSame(o,c);if(d&&p)return n;var f=!d&&t.pointBetween(s,l,c),m=!p&&t.pointBetween(o,l,c);if(d)return m?h(n,o):h(e,c),n;f&&(p||(m?h(n,o):h(e,c)),h(n,s))}else 0===u.alongA&&(-1===u.alongB?h(e,l):0===u.alongB?h(e,u.pt):1===u.alongB&&h(e,c)),0===u.alongB&&(-1===u.alongA?h(n,s):0===u.alongA?h(n,u.pt):1===u.alongA&&h(n,o));return!1}for(var u=[];!s.isEmpty();){var d=s.getHead();if(i&&i.vert(d.pt[0]),d.isStart){let t=function(){if(f){var e=c(d,f);if(e)return e}return!!m&&c(d,m)};i&&i.segmentNew(d.seg,d.primary);var p=l(d),f=p.before?p.before.ev:null,m=p.after?p.after.ev:null;i&&i.tempStatus(d.seg,!!f&&f.seg,!!m&&m.seg);var g,v=t();if(v)e?(g=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below)&&(v.seg.myFill.above=!v.seg.myFill.above):v.seg.otherFill=d.seg.myFill,i&&i.segmentUpdate(v.seg),d.other.remove(),d.remove();if(s.getHead()!==d){i&&i.rewind(d.seg);continue}if(e)g=null===d.seg.myFill.below||d.seg.myFill.above!==d.seg.myFill.below,d.seg.myFill.below=m?m.seg.myFill.above:r,d.seg.myFill.above=g?!d.seg.myFill.below:d.seg.myFill.below;else if(null===d.seg.otherFill){var y;y=m?d.primary===m.primary?m.seg.otherFill.above:m.seg.myFill.above:d.primary?a:r,d.seg.otherFill={above:y,below:y}}i&&i.status(d.seg,!!f&&f.seg,!!m&&m.seg),d.other.status=p.insert(n.node({ev:d}))}else{var x=d.status;if(null===x)throw new Error("PolyBool: Zero-length segment detected; your epsilon is probably too small or too large");if(o.exists(x.prev)&&o.exists(x.next)&&c(x.prev.ev,x.next.ev),i&&i.statusRemove(x.ev.seg),x.remove(),!d.primary){var b=d.seg.myFill;d.seg.myFill=d.seg.otherFill,d.seg.otherFill=b}u.push(d.seg)}s.getHead().remove()}return i&&i.done(),u}return e?{addRegion:function(e){for(var n,i=e[e.length-1],a=0;a{t.exports=function(e,t,n){var i=[],r=[];return e.forEach((function(e){var a=e.start,s=e.end;if(t.pointsSame(a,s))console.warn("PolyBool: Warning: Zero-length segment detected; your epsilon is probably too small or too large");else{n&&n.chainStart(e);for(var o={index:0,matches_head:!1,matches_pt1:!1},l={index:0,matches_head:!1,matches_pt1:!1},h=o,c=0;c{function n(e,t,n){var i=[];return e.forEach((function(e){var r=(e.myFill.above?8:0)+(e.myFill.below?4:0)+(e.otherFill&&e.otherFill.above?2:0)+(e.otherFill&&e.otherFill.below?1:0);0!==t[r]&&i.push({id:n?n.segmentId():-1,start:e.start,end:e.end,myFill:{above:1===t[r],below:2===t[r]},otherFill:null})})),n&&n.selected(i),i}var i={union:function(e,t){return n(e,[0,2,1,0,2,2,0,0,1,0,1,0,0,0,0,0],t)},intersect:function(e,t){return n(e,[0,0,0,0,0,2,0,2,0,0,1,1,0,2,1,0],t)},difference:function(e,t){return n(e,[0,0,0,0,2,0,2,0,1,1,0,0,0,1,2,0],t)},differenceRev:function(e,t){return n(e,[0,2,1,0,0,0,1,1,0,2,0,2,0,0,0,0],t)},xor:function(e,t){return n(e,[0,2,1,0,2,0,0,1,1,0,0,2,0,1,2,0],t)}};t.exports=i})),sme=J(((e,t)=>{var n={toPolygon:function(e,t){function n(t){if(t.length<=0)return e.segments({inverted:!1,regions:[]});function n(t){var n=t.slice(0,t.length-1);return e.segments({inverted:!1,regions:[n]})}for(var i=n(t[0]),r=1;r{var n,i=Xpe(),r=$pe(),a=Qpe(),s=tme(),o=rme(),l=sme(),h=!1,c=r();function u(e,t,i){var r=n.segments(e),a=n.segments(t),s=i(n.combine(r,a));return n.polygon(s)}n={buildLog:function(e){return!0===e?h=i():!1===e&&(h=!1),!1!==h&&h.list},epsilon:function(e){return c.epsilon(e)},segments:function(e){var t=a(!0,c,h);return e.regions.forEach(t.addRegion),{segments:t.calculate(e.inverted),inverted:e.inverted}},combine:function(e,t){return{combined:a(!1,c,h).calculate(e.segments,e.inverted,t.segments,t.inverted),inverted1:e.inverted,inverted2:t.inverted}},selectUnion:function(e){return{segments:o.union(e.combined,h),inverted:e.inverted1||e.inverted2}},selectIntersect:function(e){return{segments:o.intersect(e.combined,h),inverted:e.inverted1&&e.inverted2}},selectDifference:function(e){return{segments:o.difference(e.combined,h),inverted:e.inverted1&&!e.inverted2}},selectDifferenceRev:function(e){return{segments:o.differenceRev(e.combined,h),inverted:!e.inverted1&&e.inverted2}},selectXor:function(e){return{segments:o.xor(e.combined,h),inverted:e.inverted1!==e.inverted2}},polygon:function(e){return{regions:s(e.segments,c,h),inverted:e.inverted}},polygonFromGeoJSON:function(e){return l.toPolygon(n,e)},polygonToGeoJSON:function(e){return l.fromPolygon(n,c,e)},union:function(e,t){return u(e,t,n.selectUnion)},intersect:function(e,t){return u(e,t,n.selectIntersect)},difference:function(e,t){return u(e,t,n.selectDifference)},differenceRev:function(e,t){return u(e,t,n.selectDifferenceRev)},xor:function(e,t){return u(e,t,n.selectXor)}},"object"==typeof window&&(window.PolyBool=n),t.exports=n})),AC=J((()=>{})),fve=J(((e,t)=>{var n,i;n=e,i=function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;nt?1:e0))break;if(null===t.right)break;if(n(e,t.right.key)>0&&(l=t.right,t.right=l.left,l.left=t,null===(t=l).right))break;a.right=t,a=t,t=t.right}}return a.right=t.left,s.left=t.right,t.left=r.right,t.right=r.left,t}function s(e,t,n,r){var s=new i(e,t);if(null===n)return s.left=s.right=null,s;var o=r(e,(n=a(e,n,r)).key);return o<0?(s.left=n.left,s.right=n,n.left=null):o>=0&&(s.right=n.right,s.left=n,n.right=null),s}function o(e,t,n){var i=null,r=null;if(t){var s=n((t=a(e,t,n)).key,e);0===s?(i=t.left,r=t.right):s<0?(r=t.right,t.right=null,i=t):(i=t.left,t.left=null,r=t)}return{left:i,right:r}}function l(e,t,n,i,r){if(e){i(t+(n?"\u2514\u2500\u2500 ":"\u251c\u2500\u2500 ")+r(e)+"\n");var a=t+(n?" ":"\u2502 ");e.left&&l(e.left,a,!1,i,r),e.right&&l(e.right,a,!0,i,r)}}var h=function(){function e(e){void 0===e&&(e=r),this._root=null,this._size=0,this._comparator=e}return e.prototype.insert=function(e,t){return this._size++,this._root=s(e,t,this._root,this._comparator)},e.prototype.add=function(e,t){var n=new i(e,t);null===this._root&&(n.left=n.right=null,this._size++,this._root=n);var r=this._comparator,s=a(e,this._root,r),o=r(e,s.key);return 0===o?this._root=s:(o<0?(n.left=s.left,n.right=s,s.left=null):o>0&&(n.right=s.right,n.left=s,s.right=null),this._size++,this._root=n),this._root},e.prototype.remove=function(e){this._root=this._remove(e,this._root,this._comparator)},e.prototype._remove=function(e,t,n){var i;return null===t?null:0===n(e,(t=a(e,t,n)).key)?(null===t.left?i=t.right:(i=a(e,t.left,n)).right=t.right,this._size--,i):t},e.prototype.pop=function(){var e=this._root;if(e){for(;e.left;)e=e.left;return this._root=a(e.key,this._root,this._comparator),this._root=this._remove(e.key,this._root,this._comparator),{key:e.key,data:e.data}}return null},e.prototype.findStatic=function(e){for(var t=this._root,n=this._comparator;t;){var i=n(e,t.key);if(0===i)return t;t=i<0?t.left:t.right}return null},e.prototype.find=function(e){return this._root&&(this._root=a(e,this._root,this._comparator),0!==this._comparator(e,this._root.key))?null:this._root},e.prototype.contains=function(e){for(var t=this._root,n=this._comparator;t;){var i=n(e,t.key);if(0===i)return!0;t=i<0?t.left:t.right}return!1},e.prototype.forEach=function(e,t){for(var n=this._root,i=[],r=!1;!r;)null!==n?(i.push(n),n=n.left):0!==i.length?(n=i.pop(),e.call(t,n),n=n.right):r=!0;return this},e.prototype.range=function(e,t,n,i){for(var r=[],a=this._comparator,s=this._root;0!==r.length||s;)if(s)r.push(s),s=s.left;else{if(a((s=r.pop()).key,t)>0)break;if(a(s.key,e)>=0&&n.call(i,s))return this;s=s.right}return this},e.prototype.keys=function(){var e=[];return this.forEach((function(t){var n=t.key;return e.push(n)})),e},e.prototype.values=function(){var e=[];return this.forEach((function(t){var n=t.data;return e.push(n)})),e},e.prototype.min=function(){return this._root?this.minNode(this._root).key:null},e.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},e.prototype.minNode=function(e){if(void 0===e&&(e=this._root),e)for(;e.left;)e=e.left;return e},e.prototype.maxNode=function(e){if(void 0===e&&(e=this._root),e)for(;e.right;)e=e.right;return e},e.prototype.at=function(e){for(var t=this._root,n=!1,i=0,r=[];!n;)if(t)r.push(t),t=t.left;else if(r.length>0){if(t=r.pop(),i===e)return t;i++,t=t.right}else n=!0;return null},e.prototype.next=function(e){var t=this._root,n=null;if(e.right){for(n=e.right;n.left;)n=n.left;return n}for(var i=this._comparator;t;){var r=i(e.key,t.key);if(0===r)break;r<0?(n=t,t=t.left):t=t.right}return n},e.prototype.prev=function(e){var t=this._root,n=null;if(null!==e.left){for(n=e.left;n.right;)n=n.right;return n}for(var i=this._comparator;t;){var r=i(e.key,t.key);if(0===r)break;r<0?t=t.left:(n=t,t=t.right)}return n},e.prototype.clear=function(){return this._root=null,this._size=0,this},e.prototype.toList=function(){return function(e){for(var t=e,n=[],r=!1,a=new i(null,null),s=a;!r;)t?(n.push(t),t=t.left):n.length>0?t=(t=s=s.next=n.pop()).right:r=!0;return s.next=null,a.next}(this._root)},e.prototype.load=function(e,t,n){void 0===t&&(t=[]),void 0===n&&(n=!1);var r=e.length,a=this._comparator;if(n&&d(e,t,0,r-1,a),null===this._root)this._root=c(e,t,0,r),this._size=r;else{var s=function(e,t,n){for(var r=new i(null,null),a=r,s=e,o=t;null!==s&&null!==o;)n(s.key,o.key)<0?(a.next=s,s=s.next):(a.next=o,o=o.next),a=a.next;return null!==s?a.next=s:null!==o&&(a.next=o),r.next}(this.toList(),function(e,t){for(var n=new i(null,null),r=n,a=0;a0){var s=n+Math.floor(a/2),o=e[s],l=t[s],h=new i(o,l);return h.left=c(e,t,n,s),h.right=c(e,t,s+1,r),h}return null}function u(e,t,n){var i=n-t;if(i>0){var r=t+Math.floor(i/2),a=u(e,t,r),s=e.head;return s.left=a,e.head=e.head.next,s.right=u(e,r+1,n),s}return null}function d(e,t,n,i,r){if(!(n>=i)){for(var a=e[n+i>>1],s=n-1,o=i+1;;){do{s++}while(r(e[s],a)<0);do{o--}while(r(e[o],a)>0);if(s>=o)break;var l=e[s];e[s]=e[o],e[o]=l,l=t[s],t[s]=t[o],t[o]=l}d(e,t,n,o,r),d(e,t,o+1,i,r)}}var p=function(e,t){return e.ll.x<=t.x&&t.x<=e.ur.x&&e.ll.y<=t.y&&t.y<=e.ur.y},f=function(e,t){if(t.ur.xt.x?1:e.yt.y?1:0}}]),n(t,[{key:"link",value:function(e){if(e.point===this.point)throw new Error("Tried to link already linked events");for(var t=e.point.events,n=0,i=t.length;n=0&&l>=0?sh?-1:0:a<0&&l<0?sh?1:0:la?1:0}}}]),t}(),R=0,O=function(){function t(n,i,r,a){e(this,t),this.id=++R,this.leftSE=n,n.segment=this,n.otherSE=i,this.rightSE=i,i.segment=this,i.otherSE=n,this.rings=r,this.windings=a}return n(t,null,[{key:"compare",value:function(e,t){var n=e.leftSE.point.x,i=t.leftSE.point.x,r=e.rightSE.point.x,a=t.rightSE.point.x;if(as&&o>l)return-1;var c=e.comparePoint(t.leftSE.point);if(c<0)return 1;if(c>0)return-1;var u=t.comparePoint(e.rightSE.point);return 0!==u?u:-1}if(n>i){if(so&&s>h)return 1;var d=t.comparePoint(e.leftSE.point);if(0!==d)return d;var p=e.comparePoint(t.rightSE.point);return p<0?1:p>0?-1:1}if(so)return 1;if(ra){var m=e.comparePoint(t.rightSE.point);if(m<0)return 1;if(m>0)return-1}if(r!==a){var g=l-s,v=r-n,y=h-o,x=a-i;if(g>v&&yx)return-1}return r>a?1:rh?1:e.idt.id?1:0}}]),n(t,[{key:"replaceRightSE",value:function(e){this.rightSE=e,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}},{key:"bbox",value:function(){var e=this.leftSE.point.y,t=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:et?e:t}}}},{key:"vector",value:function(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}},{key:"isAnEndpoint",value:function(e){return e.x===this.leftSE.point.x&&e.y===this.leftSE.point.y||e.x===this.rightSE.point.x&&e.y===this.rightSE.point.y}},{key:"comparePoint",value:function(e){if(this.isAnEndpoint(e))return 0;var t=this.leftSE.point,n=this.rightSE.point,i=this.vector();if(t.x===n.x)return e.x===t.x?0:e.x0&&o.swapEvents(),P.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),i&&(r.checkForConsuming(),a.checkForConsuming()),n}},{key:"swapEvents",value:function(){var e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(var t=0,n=this.windings.length;t0){var a=n;n=i,i=a}if(n.prev===i){var s=n;n=i,i=s}for(var o=0,l=i.rings.length;o0))throw new Error("Tried to create degenerate segment at [".concat(e.x,", ").concat(e.y,"]"));r=n,a=e,s=-1}return new t(new P(r,!0),new P(a,!1),[i],[s])}}]),t}(),L=function(){function t(n,i,r){if(e(this,t),!Array.isArray(n)||0===n.length)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=i,this.isExterior=r,this.segments=[],"number"!=typeof n[0][0]||"number"!=typeof n[0][1])throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var a=b.round(n[0][0],n[0][1]);this.bbox={ll:{x:a.x,y:a.y},ur:{x:a.x,y:a.y}};for(var s=a,o=1,l=n.length;othis.bbox.ur.x&&(this.bbox.ur.x=h.x),h.y>this.bbox.ur.y&&(this.bbox.ur.y=h.y),s=h)}(a.x!==s.x||a.y!==s.y)&&this.segments.push(O.fromRing(s,a,this))}return n(t,[{key:"getSweepEvents",value:function(){for(var e=[],t=0,n=this.segments.length;tthis.bbox.ur.x&&(this.bbox.ur.x=s.bbox.ur.x),s.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=s.bbox.ur.y),this.interiorRings.push(s)}this.multiPoly=i}return n(t,[{key:"getSweepEvents",value:function(){for(var e=this.exteriorRing.getSweepEvents(),t=0,n=this.interiorRings.length;tthis.bbox.ur.x&&(this.bbox.ur.x=s.bbox.ur.x),s.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=s.bbox.ur.y),this.polys.push(s)}this.isSubject=i}return n(t,[{key:"getSweepEvents",value:function(){for(var e=[],t=0,n=this.polys.length;t0&&(e=i)}for(var r=e.segment.prevInResult(),a=r?r.prevInResult():null;;){if(!r)return null;if(!a)return r.ringOut;if(a.ringOut!==r.ringOut)return a.ringOut.enclosingRing()!==r.ringOut?r.ringOut:r.ringOut.enclosingRing();r=a.prevInResult(),a=r?r.prevInResult():null}}}]),t}(),N=function(){function t(n){e(this,t),this.exteriorRing=n,n.poly=this,this.interiorRings=[]}return n(t,[{key:"addInterior",value:function(e){this.interiorRings.push(e),e.poly=this}},{key:"getGeom",value:function(){var e=[this.exteriorRing.getGeom()];if(null===e[0])return null;for(var t=0,n=this.interiorRings.length;t1&&void 0!==arguments[1]?arguments[1]:O.compare;e(this,t),this.queue=n,this.tree=new h(i),this.segments=[]}return n(t,[{key:"process",value:function(e){var t=e.segment,n=[];if(e.consumedBy)return e.isLeft?this.queue.remove(e.otherSE):this.tree.remove(t),n;var i=e.isLeft?this.tree.insert(t):this.tree.find(t);if(!i)throw new Error("Unable to find segment #".concat(t.id," ")+"[".concat(t.leftSE.point.x,", ").concat(t.leftSE.point.y,"] -> ")+"[".concat(t.rightSE.point.x,", ").concat(t.rightSE.point.y,"] ")+"in SweepLine tree. Please submit a bug report.");for(var r=i,a=i,s=void 0,o=void 0;void 0===s;)null===(r=this.tree.prev(r))?s=null:void 0===r.key.consumedBy&&(s=r.key);for(;void 0===o;)null===(a=this.tree.next(a))?o=null:void 0===a.key.consumedBy&&(o=a.key);if(e.isLeft){var l=null;if(s){var h=s.getIntersection(t);if(null!==h&&(t.isAnEndpoint(h)||(l=h),!s.isAnEndpoint(h)))for(var c=this._splitSafely(s,h),u=0,d=c.length;u0?(this.tree.remove(t),n.push(e)):(this.segments.push(t),t.prev=s)}else{if(s&&o){var w=s.getIntersection(o);if(null!==w){if(!s.isAnEndpoint(w))for(var S=this._splitSafely(s,w),M=0,T=S.length;MB)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big). Please file a bug report.");for(var w=new U(m),S=m.size,M=m.pop();M;){var T=M.key;if(m.size===S){var E=T.segment;throw new Error("Unable to pop() ".concat(T.isLeft?"left":"right"," SweepEvent ")+"[".concat(T.point.x,", ").concat(T.point.y,"] from segment #").concat(E.id," ")+"[".concat(E.leftSE.point.x,", ").concat(E.leftSE.point.y,"] -> ")+"[".concat(E.rightSE.point.x,", ").concat(E.rightSE.point.y,"] from queue. ")+"Please file a bug report.")}if(m.size>B)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big). Please file a bug report.");if(w.segments.length>z)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments). Please file a bug report.");for(var A=w.process(T),C=0,R=A.length;C1?t-1:0),i=1;i1?t-1:0),i=1;i1?t-1:0),i=1;i1?t-1:0),i=1;i{!function(){"use strict";var e,n={version:"6.4.2.2",use_lines:!0,use_xyz:!1},i=!1;if(void 0!==t&&t.exports?(t.exports=n,i=!0):("function"==typeof define&&define.amd&&define(n),"undefined"!=typeof document?window.ClipperLib=n:self.ClipperLib=n),i){var r="chrome";e="Netscape"}else r=navigator.userAgent.toString().toLowerCase(),e=navigator.appName;var a,s={};function o(e,t,i){n.biginteger_used=1,null!=e&&("number"==typeof e&&void 0===t?this.fromInt(e):"number"==typeof e?this.fromNumber(e,t,i):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function l(){return new o(null,void 0,void 0)}-1!=r.indexOf("chrome")&&-1==r.indexOf("chromium")?s.chrome=1:s.chrome=0,-1!=r.indexOf("chromium")?s.chromium=1:s.chromium=0,-1!=r.indexOf("safari")&&-1==r.indexOf("chrome")&&-1==r.indexOf("chromium")?s.safari=1:s.safari=0,-1!=r.indexOf("firefox")?s.firefox=1:s.firefox=0,-1!=r.indexOf("firefox/17")?s.firefox17=1:s.firefox17=0,-1!=r.indexOf("firefox/15")?s.firefox15=1:s.firefox15=0,-1!=r.indexOf("firefox/3")?s.firefox3=1:s.firefox3=0,-1!=r.indexOf("opera")?s.opera=1:s.opera=0,-1!=r.indexOf("msie 10")?s.msie10=1:s.msie10=0,-1!=r.indexOf("msie 9")?s.msie9=1:s.msie9=0,-1!=r.indexOf("msie 8")?s.msie8=1:s.msie8=0,-1!=r.indexOf("msie 7")?s.msie7=1:s.msie7=0,-1!=r.indexOf("msie ")?s.msie=1:s.msie=0,n.biginteger_used=null,"Microsoft Internet Explorer"==e?(o.prototype.am=function(e,t,n,i,r,a){for(var s=32767&t,o=t>>15;--a>=0;){var l=32767&this[e],h=this[e++]>>15,c=o*l+h*s;r=((l=s*l+((32767&c)<<15)+n[i]+(1073741823&r))>>>30)+(c>>>15)+o*h+(r>>>30),n[i++]=1073741823&l}return r},a=30):"Netscape"!=e?(o.prototype.am=function(e,t,n,i,r,a){for(;--a>=0;){var s=t*this[e++]+n[i]+r;r=Math.floor(s/67108864),n[i++]=67108863&s}return r},a=26):(o.prototype.am=function(e,t,n,i,r,a){for(var s=16383&t,o=t>>14;--a>=0;){var l=16383&this[e],h=this[e++]>>14,c=o*l+h*s;r=((l=s*l+((16383&c)<<14)+n[i]+r)>>28)+(c>>14)+o*h,n[i++]=268435455&l}return r},a=28),o.prototype.DB=a,o.prototype.DM=(1<>>16)&&(e=t,n+=16),0!=(t=e>>8)&&(e=t,n+=8),0!=(t=e>>4)&&(e=t,n+=4),0!=(t=e>>2)&&(e=t,n+=2),0!=(t=e>>1)&&(e=t,n+=1),n}function g(e){this.m=e}function v(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function S(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function M(){}function T(e){return e}function E(e){this.r2=l(),this.q3=l(),o.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}g.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},g.prototype.revert=function(e){return e},g.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},g.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n),this.reduce(n)},g.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},v.prototype.convert=function(e){var t=l();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(o.ZERO)>0&&this.m.subTo(t,t),t},v.prototype.revert=function(e){var t=l();return e.copyTo(t),this.reduce(t),t},v.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(e[n=t+this.m.t]+=this.m.am(0,i,e,t,0,this.m.t);e[n]>=e.DV;)e[n]-=e.DV,e[++n]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},v.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n),this.reduce(n)},v.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},o.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},o.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0},o.prototype.fromString=function(e,t){var n;if(16==t)n=4;else if(8==t)n=3;else if(256==t)n=8;else if(2==t)n=1;else if(32==t)n=5;else{if(4!=t)return void this.fromRadix(e,t);n=2}this.t=0,this.s=0;for(var i=e.length,r=!1,a=0;--i>=0;){var s=8==n?255&e[i]:p(e,i);s<0?"-"==e.charAt(i)&&(r=!0):(r=!1,0==a?this[this.t++]=s:a+n>this.DB?(this[this.t-1]|=(s&(1<>this.DB-a):this[this.t-1]|=s<=this.DB&&(a-=this.DB))}8==n&&128&e[0]&&(this.s=-1,a>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t},o.prototype.dlShiftTo=function(e,t){var n;for(n=this.t-1;n>=0;--n)t[n+e]=this[n];for(n=e-1;n>=0;--n)t[n]=0;t.t=this.t+e,t.s=this.s},o.prototype.drShiftTo=function(e,t){for(var n=e;n=0;--n)t[n+s+1]=this[n]>>r|o,o=(this[n]&a)<=0;--n)t[n]=0;t[s]=o,t.t=this.t+s+1,t.s=this.s,t.clamp()},o.prototype.rShiftTo=function(e,t){t.s=this.s;var n=Math.floor(e/this.DB);if(n>=this.t)t.t=0;else{var i=e%this.DB,r=this.DB-i,a=(1<>i;for(var s=n+1;s>i;i>0&&(t[this.t-n-1]|=(this.s&a)<>=this.DB;if(e.t>=this.DB;i+=this.s}else{for(i+=this.s;n>=this.DB;i-=e.s}t.s=i<0?-1:0,i<-1?t[n++]=this.DV+i:i>0&&(t[n++]=i),t.t=n,t.clamp()},o.prototype.multiplyTo=function(e,t){var n=this.abs(),i=e.abs(),r=n.t;for(t.t=r+i.t;--r>=0;)t[r]=0;for(r=0;r=0;)e[n]=0;for(n=0;n=t.DV&&(e[n+t.t]-=t.DV,e[n+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(n,t[n],e,2*n,0,1)),e.s=0,e.clamp()},o.prototype.divRemTo=function(e,t,n){var i=e.abs();if(!(i.t<=0)){var r=this.abs();if(r.t0?(i.lShiftTo(c,a),r.lShiftTo(c,n)):(i.copyTo(a),r.copyTo(n));var u=a.t,d=a[u-1];if(0!=d){var p=d*(1<1?a[u-2]>>this.F2:0),f=this.FV/p,g=(1<=0&&(n[n.t++]=1,n.subTo(b,n)),o.ONE.dlShiftTo(u,b),b.subTo(a,a);a.t=0;){var _=n[--y]==d?this.DM:Math.floor(n[y]*f+(n[y-1]+v)*g);if((n[y]+=a.am(0,_,n,x,0,u))<_)for(a.dlShiftTo(x,b),n.subTo(b,n);n[y]<--_;)n.subTo(b,n)}null!=t&&(n.drShiftTo(u,t),s!=h&&o.ZERO.subTo(t,t)),n.t=u,n.clamp(),c>0&&n.rShiftTo(c,n),s<0&&o.ZERO.subTo(n,n)}}},o.prototype.invDigit=function(){if(this.t<1)return 0;var e=this[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},o.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},o.prototype.exp=function(e,t){if(e>4294967295||e<1)return o.ONE;var n=l(),i=l(),r=t.convert(this),a=m(e)-1;for(r.copyTo(n);--a>=0;)if(t.sqrTo(n,i),(e&1<0)t.mulTo(i,r,n);else{var s=n;n=i,i=s}return t.revert(n)},o.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var n,i=(1<0)for(o>o)>0&&(r=!0,a=d(n));s>=0;)o>(o+=this.DB-t)):(n=this[s]>>(o-=t)&i,o<=0&&(o+=this.DB,--s)),n>0&&(r=!0),r&&(a+=d(n));return r?a:"0"},o.prototype.negate=function(){var e=l();return o.ZERO.subTo(this,e),e},o.prototype.abs=function(){return this.s<0?this.negate():this},o.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var n=this.t;if(0!=(t=n-e.t))return this.s<0?-t:t;for(;--n>=0;)if(0!=(t=this[n]-e[n]))return t;return 0},o.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+m(this[this.t-1]^this.s&this.DM)},o.prototype.mod=function(e){var t=l();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(o.ZERO)>0&&e.subTo(t,t),t},o.prototype.modPowInt=function(e,t){var n;return n=e<256||t.isEven()?new g(t):new v(t),this.exp(e,n)},o.ZERO=f(0),o.ONE=f(1),M.prototype.convert=T,M.prototype.revert=T,M.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n)},M.prototype.sqrTo=function(e,t){e.squareTo(t)},E.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=l();return e.copyTo(t),this.reduce(t),t},E.prototype.revert=function(e){return e},E.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},E.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n),this.reduce(n)},E.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var A=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],C=(1<<26)/A[A.length-1];o.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},o.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),n=Math.pow(e,t),i=f(n),r=l(),a=l(),s="";for(this.divRemTo(i,r,a);r.signum()>0;)s=(n+a.intValue()).toString(e).substr(1)+s,r.divRemTo(i,r,a);return a.intValue().toString(e)+s},o.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var n=this.chunkSize(t),i=Math.pow(t,n),r=!1,a=0,s=0,l=0;l=n&&(this.dMultiply(i),this.dAddOffset(s,0),a=0,s=0))}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(s,0)),r&&o.ZERO.subTo(this,this)},o.prototype.fromNumber=function(e,t,n){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo(o.ONE.shiftLeft(e-1),x,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(o.ONE.shiftLeft(e-1),this);else{var i=new Array,r=7&e;i.length=1+(e>>3),t.nextBytes(i),r>0?i[0]&=(1<>=this.DB;if(e.t>=this.DB;i+=this.s}else{for(i+=this.s;n>=this.DB;i+=e.s}t.s=i<0?-1:0,i>0?t[n++]=i:i<-1&&(t[n++]=this.DV+i),t.t=n,t.clamp()},o.prototype.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},o.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},o.prototype.multiplyLowerTo=function(e,t,n){var i,r=Math.min(this.t+e.t,t);for(n.s=0,n.t=r;r>0;)n[--r]=0;for(i=n.t-this.t;r=0;)n[i]=0;for(i=Math.max(t-this.t,0);i0)if(0==t)n=this[0]%e;else for(var i=this.t-1;i>=0;--i)n=(t*n+this[i])%e;return n},o.prototype.millerRabin=function(e){var t=this.subtract(o.ONE),n=t.getLowestSetBit();if(n<=0)return!1;var i=t.shiftRight(n);(e=e+1>>1)>A.length&&(e=A.length);for(var r=l(),a=0;a>24},o.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},o.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},o.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var n,i=this.DB-e*this.DB%8,r=0;if(e-- >0)for(i>i)!=(this.s&this.DM)>>i&&(t[r++]=n|this.s<=0;)i<8?(n=(this[e]&(1<>(i+=this.DB-8)):(n=this[e]>>(i-=8)&255,i<=0&&(i+=this.DB,--e)),128&n&&(n|=-256),0==r&&(128&this.s)!=(128&n)&&++r,(r>0||n!=this.s)&&(t[r++]=n);return t},o.prototype.equals=function(e){return 0==this.compareTo(e)},o.prototype.min=function(e){return this.compareTo(e)<0?this:e},o.prototype.max=function(e){return this.compareTo(e)>0?this:e},o.prototype.and=function(e){var t=l();return this.bitwiseTo(e,y,t),t},o.prototype.or=function(e){var t=l();return this.bitwiseTo(e,x,t),t},o.prototype.xor=function(e){var t=l();return this.bitwiseTo(e,b,t),t},o.prototype.andNot=function(e){var t=l();return this.bitwiseTo(e,_,t),t},o.prototype.not=function(){for(var e=l(),t=0;t=this.t?0!=this.s:0!=(this[t]&1<1){var u=l();for(i.sqrTo(s[1],u);o<=c;)s[o]=l(),i.mulTo(u,s[o-2],s[o]),o+=2}var d,p,y=e.t-1,x=!0,b=l();for(r=m(e[y])-1;y>=0;){for(r>=h?d=e[y]>>r-h&c:(d=(e[y]&(1<0&&(d|=e[y-1]>>this.DB+r-h)),o=n;!(1&d);)d>>=1,--o;if((r-=o)<0&&(r+=this.DB,--y),x)s[d].copyTo(a),x=!1;else{for(;o>1;)i.sqrTo(a,b),i.sqrTo(b,a),o-=2;o>0?i.sqrTo(a,b):(p=a,a=b,b=p),i.mulTo(b,s[d],a)}for(;y>=0&&!(e[y]&1<=0?(n.subTo(i,n),t&&r.subTo(s,r),a.subTo(l,a)):(i.subTo(n,i),t&&s.subTo(r,s),l.subTo(a,l))}return 0!=i.compareTo(o.ONE)?o.ZERO:l.compareTo(e)>=0?l.subtract(e):l.signum()<0?(l.addTo(e,l),l.signum()<0?l.add(e):l):l},o.prototype.pow=function(e){return this.exp(e,new M)},o.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),n=e.s<0?e.negate():e.clone();if(t.compareTo(n)<0){var i=t;t=n,n=i}var r=t.getLowestSetBit(),a=n.getLowestSetBit();if(a<0)return t;for(r0&&(t.rShiftTo(a,t),n.rShiftTo(a,n));t.signum()>0;)(r=t.getLowestSetBit())>0&&t.rShiftTo(r,t),(r=n.getLowestSetBit())>0&&n.rShiftTo(r,n),t.compareTo(n)>=0?(t.subTo(n,t),t.rShiftTo(1,t)):(n.subTo(t,n),n.rShiftTo(1,n));return a>0&&n.lShiftTo(a,n),n},o.prototype.isProbablePrime=function(e){var t,n=this.abs();if(1==n.t&&n[0]<=A[A.length-1]){for(t=0;t0},P.op_LessThan=function(e,t){return e.compareTo(t)<0},P.op_Addition=function(e,t){return new P(e,void 0,void 0).add(new P(t,void 0,void 0))},P.op_Subtraction=function(e,t){return new P(e,void 0,void 0).subtract(new P(t,void 0,void 0))},P.Int128Mul=function(e,t){return new P(e,void 0,void 0).multiply(new P(t,void 0,void 0))},P.op_Division=function(e,t){return e.divide(t)},P.prototype.ToDouble=function(){return parseFloat(this.toString())};var R=function(e,t){var n;if(void 0===Object.getOwnPropertyNames){for(n in t.prototype)(void 0===e.prototype[n]||e.prototype[n]===Object.prototype[n])&&(e.prototype[n]=t.prototype[n]);for(n in t)void 0===e[n]&&(e[n]=t[n]);e.$baseCtor=t}else{for(var i=Object.getOwnPropertyNames(t.prototype),r=0;r0?this.m_Childs[0]:this.GetNextSiblingUp()},n.PolyNode.prototype.GetNextSiblingUp=function(){return null===this.m_Parent?null:this.m_Index===this.m_Parent.m_Childs.length-1?this.m_Parent.GetNextSiblingUp():this.m_Parent.m_Childs[this.m_Index+1]},n.PolyNode.prototype.Childs=function(){return this.m_Childs},n.PolyNode.prototype.Parent=function(){return this.m_Parent},n.PolyNode.prototype.IsHole=function(){return this.IsHoleNode()},n.PolyTree=function(){this.m_AllPolys=[],n.PolyNode.call(this)},n.PolyTree.prototype.Clear=function(){for(var e=0,t=this.m_AllPolys.length;e0?this.m_Childs[0]:null},n.PolyTree.prototype.Total=function(){var e=this.m_AllPolys.length;return e>0&&this.m_Childs[0]!==this.m_AllPolys[0]&&e--,e},R(n.PolyTree,n.PolyNode),n.Math_Abs_Int64=n.Math_Abs_Int32=n.Math_Abs_Double=function(e){return Math.abs(e)},n.Math_Max_Int32_Int32=function(e,t){return Math.max(e,t)},s.msie||s.opera||s.safari?n.Cast_Int32=function(e){return 0|e}:n.Cast_Int32=function(e){return~~e},void 0===Number.toInteger&&(Number.toInteger=null),s.chrome?n.Cast_Int64=function(e){return e<-2147483648||e>2147483647?e<0?Math.ceil(e):Math.floor(e):~~e}:s.firefox&&"function"==typeof Number.toInteger?n.Cast_Int64=function(e){return Number.toInteger(e)}:s.msie7||s.msie8?n.Cast_Int64=function(e){return parseInt(e,10)}:s.msie?n.Cast_Int64=function(e){return e<-2147483648||e>2147483647?e<0?Math.ceil(e):Math.floor(e):0|e}:n.Cast_Int64=function(e){return e<0?Math.ceil(e):Math.floor(e)},n.Clear=function(e){e.length=0},n.PI=3.141592653589793,n.PI2=6.283185307179586,n.IntPoint=function(){var e=arguments,t=e.length;if(this.X=0,this.Y=0,n.use_xyz)if(this.Z=0,3===t)this.X=e[0],this.Y=e[1],this.Z=e[2];else if(2===t)this.X=e[0],this.Y=e[1],this.Z=0;else if(1===t)if(e[0]instanceof n.DoublePoint){var i=e[0];this.X=n.Clipper.Round(i.X),this.Y=n.Clipper.Round(i.Y),this.Z=0}else void 0===(r=e[0]).Z&&(r.Z=0),this.X=r.X,this.Y=r.Y,this.Z=r.Z;else this.X=0,this.Y=0,this.Z=0;else if(2===t)this.X=e[0],this.Y=e[1];else if(1===t)if(e[0]instanceof n.DoublePoint)i=e[0],this.X=n.Clipper.Round(i.X),this.Y=n.Clipper.Round(i.Y);else{var r=e[0];this.X=r.X,this.Y=r.Y}else this.X=0,this.Y=0},n.IntPoint.op_Equality=function(e,t){return e.X===t.X&&e.Y===t.Y},n.IntPoint.op_Inequality=function(e,t){return e.X!==t.X||e.Y!==t.Y},n.IntPoint0=function(){this.X=0,this.Y=0,n.use_xyz&&(this.Z=0)},n.IntPoint0.prototype=n.IntPoint.prototype,n.IntPoint1=function(e){this.X=e.X,this.Y=e.Y,n.use_xyz&&(void 0===e.Z?this.Z=0:this.Z=e.Z)},n.IntPoint1.prototype=n.IntPoint.prototype,n.IntPoint1dp=function(e){this.X=n.Clipper.Round(e.X),this.Y=n.Clipper.Round(e.Y),n.use_xyz&&(this.Z=0)},n.IntPoint1dp.prototype=n.IntPoint.prototype,n.IntPoint2=function(e,t,i){this.X=e,this.Y=t,n.use_xyz&&(this.Z=void 0===i?0:i)},n.IntPoint2.prototype=n.IntPoint.prototype,n.IntRect=function(){var e=arguments,t=e.length;if(4===t)this.left=e[0],this.top=e[1],this.right=e[2],this.bottom=e[3];else if(1===t){var n=e[0];this.left=n.left,this.top=n.top,this.right=n.right,this.bottom=n.bottom}else this.left=0,this.top=0,this.right=0,this.bottom=0},n.IntRect0=function(){this.left=0,this.top=0,this.right=0,this.bottom=0},n.IntRect0.prototype=n.IntRect.prototype,n.IntRect1=function(e){this.left=e.left,this.top=e.top,this.right=e.right,this.bottom=e.bottom},n.IntRect1.prototype=n.IntRect.prototype,n.IntRect4=function(e,t,n,i){this.left=e,this.top=t,this.right=n,this.bottom=i},n.IntRect4.prototype=n.IntRect.prototype,n.ClipType={ctIntersection:0,ctUnion:1,ctDifference:2,ctXor:3},n.PolyType={ptSubject:0,ptClip:1},n.PolyFillType={pftEvenOdd:0,pftNonZero:1,pftPositive:2,pftNegative:3},n.JoinType={jtSquare:0,jtRound:1,jtMiter:2},n.EndType={etOpenSquare:0,etOpenRound:1,etOpenButt:2,etClosedLine:3,etClosedPolygon:4},n.EdgeSide={esLeft:0,esRight:1},n.Direction={dRightToLeft:0,dLeftToRight:1},n.TEdge=function(){this.Bot=new n.IntPoint0,this.Curr=new n.IntPoint0,this.Top=new n.IntPoint0,this.Delta=new n.IntPoint0,this.Dx=0,this.PolyTyp=n.PolyType.ptSubject,this.Side=n.EdgeSide.esLeft,this.WindDelta=0,this.WindCnt=0,this.WindCnt2=0,this.OutIdx=0,this.Next=null,this.Prev=null,this.NextInLML=null,this.NextInAEL=null,this.PrevInAEL=null,this.NextInSEL=null,this.PrevInSEL=null},n.IntersectNode=function(){this.Edge1=null,this.Edge2=null,this.Pt=new n.IntPoint0},n.MyIntersectNodeSort=function(){},n.MyIntersectNodeSort.Compare=function(e,t){var n=t.Pt.Y-e.Pt.Y;return n>0?1:n<0?-1:0},n.LocalMinima=function(){this.Y=0,this.LeftBound=null,this.RightBound=null,this.Next=null},n.Scanbeam=function(){this.Y=0,this.Next=null},n.Maxima=function(){this.X=0,this.Next=null,this.Prev=null},n.OutRec=function(){this.Idx=0,this.IsHole=!1,this.IsOpen=!1,this.FirstLeft=null,this.Pts=null,this.BottomPt=null,this.PolyNode=null},n.OutPt=function(){this.Idx=0,this.Pt=new n.IntPoint0,this.Next=null,this.Prev=null},n.Join=function(){this.OutPt1=null,this.OutPt2=null,this.OffPt=new n.IntPoint0},n.ClipperBase=function(){this.m_MinimaList=null,this.m_CurrentLM=null,this.m_edges=new Array,this.m_UseFullRange=!1,this.m_HasOpenPaths=!1,this.PreserveCollinear=!1,this.m_Scanbeam=null,this.m_PolyOuts=null,this.m_ActiveEdges=null},n.ClipperBase.horizontal=-9007199254740992,n.ClipperBase.Skip=-2,n.ClipperBase.Unassigned=-1,n.ClipperBase.tolerance=1e-20,n.ClipperBase.loRange=47453132,n.ClipperBase.hiRange=0xfffffffffffff,n.ClipperBase.near_zero=function(e){return e>-n.ClipperBase.tolerance&&et.X==e.Xt.Y==e.Yt.X==e.Xt.Y==e.Yn.ClipperBase.hiRange||e.Y>n.ClipperBase.hiRange||-e.X>n.ClipperBase.hiRange||-e.Y>n.ClipperBase.hiRange)&&n.Error("Coordinate outside allowed range in RangeTest()."):(e.X>n.ClipperBase.loRange||e.Y>n.ClipperBase.loRange||-e.X>n.ClipperBase.loRange||-e.Y>n.ClipperBase.loRange)&&(t.Value=!0,this.RangeTest(e,t))},n.ClipperBase.prototype.InitEdge=function(e,t,i,r){e.Next=t,e.Prev=i,e.Curr.X=r.X,e.Curr.Y=r.Y,n.use_xyz&&(e.Curr.Z=r.Z),e.OutIdx=-1},n.ClipperBase.prototype.InitEdge2=function(e,t){e.Curr.Y>=e.Next.Curr.Y?(e.Bot.X=e.Curr.X,e.Bot.Y=e.Curr.Y,n.use_xyz&&(e.Bot.Z=e.Curr.Z),e.Top.X=e.Next.Curr.X,e.Top.Y=e.Next.Curr.Y,n.use_xyz&&(e.Top.Z=e.Next.Curr.Z)):(e.Top.X=e.Curr.X,e.Top.Y=e.Curr.Y,n.use_xyz&&(e.Top.Z=e.Curr.Z),e.Bot.X=e.Next.Curr.X,e.Bot.Y=e.Next.Curr.Y,n.use_xyz&&(e.Bot.Z=e.Next.Curr.Z)),this.SetDx(e),e.PolyTyp=t},n.ClipperBase.prototype.FindNextLocMin=function(e){for(var t;;){for(;n.IntPoint.op_Inequality(e.Bot,e.Prev.Bot)||n.IntPoint.op_Equality(e.Curr,e.Top);)e=e.Next;if(e.Dx!==n.ClipperBase.horizontal&&e.Prev.Dx!==n.ClipperBase.horizontal)break;for(;e.Prev.Dx===n.ClipperBase.horizontal;)e=e.Prev;for(t=e;e.Dx===n.ClipperBase.horizontal;)e=e.Next;if(e.Top.Y!==e.Prev.Bot.Y){t.Prev.Bot.Xa.Next.Top.X&&(a=r.Prev)}for(;e!==a;)e.NextInLML=e.Next,e.Dx===n.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),e=e.Next;e.Dx===n.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Prev.Top.X&&this.ReverseHorizontal(e),a=a.Next}else{for(;a.Top.Y===a.Prev.Bot.Y&&a.Prev.OutIdx!==n.ClipperBase.Skip;)a=a.Prev;if(a.Dx===n.ClipperBase.horizontal&&a.Prev.OutIdx!==n.ClipperBase.Skip){for(r=a;r.Next.Dx===n.ClipperBase.horizontal;)r=r.Next;(r.Next.Top.X===a.Prev.Top.X||r.Next.Top.X>a.Prev.Top.X)&&(a=r.Next)}for(;e!==a;)e.NextInLML=e.Prev,e.Dx===n.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),e=e.Prev;e.Dx===n.ClipperBase.horizontal&&e!==i&&e.Bot.X!==e.Next.Top.X&&this.ReverseHorizontal(e),a=a.Prev}return a},n.ClipperBase.prototype.AddPath=function(e,t,i){n.use_lines?!i&&t===n.PolyType.ptClip&&n.Error("AddPath: Open paths must be subject."):i||n.Error("AddPath: Open paths have been disabled.");var r=e.length-1;if(i)for(;r>0&&n.IntPoint.op_Equality(e[r],e[0]);)--r;for(;r>0&&n.IntPoint.op_Equality(e[r],e[r-1]);)--r;if(i&&r<2||!i&&r<1)return!1;for(var a=new Array,s=0;s<=r;s++)a.push(new n.TEdge);var o=!0;a[1].Curr.X=e[1].X,a[1].Curr.Y=e[1].Y,n.use_xyz&&(a[1].Curr.Z=e[1].Z);var l={Value:this.m_UseFullRange};for(this.RangeTest(e[0],l),this.m_UseFullRange=l.Value,l.Value=this.m_UseFullRange,this.RangeTest(e[r],l),this.m_UseFullRange=l.Value,this.InitEdge(a[0],a[1],a[r],e[0]),this.InitEdge(a[r],a[0],a[r-1],e[r]),s=r-1;s>=1;--s)l.Value=this.m_UseFullRange,this.RangeTest(e[s],l),this.m_UseFullRange=l.Value,this.InitEdge(a[s],a[s+1],a[s-1],e[s]);for(var h=a[0],c=h,u=h;;)if(c.Curr!==c.Next.Curr||!i&&c.Next===h){if(c.Prev===c.Next)break;if(!i||!n.ClipperBase.SlopesEqual4(c.Prev.Curr,c.Curr,c.Next.Curr,this.m_UseFullRange)||this.PreserveCollinear&&this.Pt2IsBetweenPt1AndPt3(c.Prev.Curr,c.Curr,c.Next.Curr)){if((c=c.Next)===u||!i&&c.Next===h)break}else c===h&&(h=c.Next),u=c=(c=this.RemoveEdge(c)).Prev}else{if(c===c.Next)break;c===h&&(h=c.Next),u=c=this.RemoveEdge(c)}if(!i&&c===c.Next||i&&c.Prev===c.Next)return!1;i||(this.m_HasOpenPaths=!0,h.Prev.OutIdx=n.ClipperBase.Skip),c=h;do{this.InitEdge2(c,t),c=c.Next,o&&c.Curr.Y!==h.Curr.Y&&(o=!1)}while(c!==h);if(o){if(i)return!1;for(c.Prev.OutIdx=n.ClipperBase.Skip,(f=new n.LocalMinima).Next=null,f.Y=c.Bot.Y,f.LeftBound=null,f.RightBound=c,f.RightBound.Side=n.EdgeSide.esRight,f.RightBound.WindDelta=0;c.Bot.X!==c.Prev.Top.X&&this.ReverseHorizontal(c),c.Next.OutIdx!==n.ClipperBase.Skip;)c.NextInLML=c.Next,c=c.Next;return this.InsertLocalMinima(f),this.m_edges.push(a),!0}this.m_edges.push(a);var d,p=null;for(n.IntPoint.op_Equality(c.Prev.Bot,c.Prev.Top)&&(c=c.Next);(c=this.FindNextLocMin(c))!==p;){var f;null===p&&(p=c),(f=new n.LocalMinima).Next=null,f.Y=c.Bot.Y,c.Dxe.X==t.Xe.Y==t.Y=this.m_MinimaList.Y)e.Next=this.m_MinimaList,this.m_MinimaList=e;else{for(var t=this.m_MinimaList;null!==t.Next&&e.Ythis.m_Scanbeam.Y){var t=new n.Scanbeam;t.Y=e,t.Next=this.m_Scanbeam,this.m_Scanbeam=t}else{for(var i=this.m_Scanbeam;null!==i.Next&&e<=i.Next.Y;)i=i.Next;if(e===i.Y)return;var r=new n.Scanbeam;r.Y=e,r.Next=i.Next,i.Next=r}},n.ClipperBase.prototype.PopScanbeam=function(e){return null===this.m_Scanbeam?(e.v=0,!1):(e.v=this.m_Scanbeam.Y,this.m_Scanbeam=this.m_Scanbeam.Next,!0)},n.ClipperBase.prototype.LocalMinimaPending=function(){return null!==this.m_CurrentLM},n.ClipperBase.prototype.CreateOutRec=function(){var e=new n.OutRec;return e.Idx=n.ClipperBase.Unassigned,e.IsHole=!1,e.IsOpen=!1,e.FirstLeft=null,e.Pts=null,e.BottomPt=null,e.PolyNode=null,this.m_PolyOuts.push(e),e.Idx=this.m_PolyOuts.length-1,e},n.ClipperBase.prototype.DisposeOutRec=function(e){var t=this.m_PolyOuts[e];t.Pts=null,t=null,this.m_PolyOuts[e]=null},n.ClipperBase.prototype.UpdateEdgeIntoAEL=function(e){null===e.NextInLML&&n.Error("UpdateEdgeIntoAEL: invalid call");var t=e.PrevInAEL,i=e.NextInAEL;return e.NextInLML.OutIdx=e.OutIdx,null!==t?t.NextInAEL=e.NextInLML:this.m_ActiveEdges=e.NextInLML,null!==i&&(i.PrevInAEL=e.NextInLML),e.NextInLML.Side=e.Side,e.NextInLML.WindDelta=e.WindDelta,e.NextInLML.WindCnt=e.WindCnt,e.NextInLML.WindCnt2=e.WindCnt2,(e=e.NextInLML).Curr.X=e.Bot.X,e.Curr.Y=e.Bot.Y,e.PrevInAEL=t,e.NextInAEL=i,n.ClipperBase.IsHorizontal(e)||this.InsertScanbeam(e.Top.Y),e},n.ClipperBase.prototype.SwapPositionsInAEL=function(e,t){if(e.NextInAEL!==e.PrevInAEL&&t.NextInAEL!==t.PrevInAEL){if(e.NextInAEL===t){var n=t.NextInAEL;null!==n&&(n.PrevInAEL=e);var i=e.PrevInAEL;null!==i&&(i.NextInAEL=t),t.PrevInAEL=i,t.NextInAEL=e,e.PrevInAEL=t,e.NextInAEL=n}else if(t.NextInAEL===e){var r=e.NextInAEL;null!==r&&(r.PrevInAEL=t);var a=t.PrevInAEL;null!==a&&(a.NextInAEL=e),e.PrevInAEL=a,e.NextInAEL=t,t.PrevInAEL=e,t.NextInAEL=r}else{var s=e.NextInAEL,o=e.PrevInAEL;e.NextInAEL=t.NextInAEL,null!==e.NextInAEL&&(e.NextInAEL.PrevInAEL=e),e.PrevInAEL=t.PrevInAEL,null!==e.PrevInAEL&&(e.PrevInAEL.NextInAEL=e),t.NextInAEL=s,null!==t.NextInAEL&&(t.NextInAEL.PrevInAEL=t),t.PrevInAEL=o,null!==t.PrevInAEL&&(t.PrevInAEL.NextInAEL=t)}null===e.PrevInAEL?this.m_ActiveEdges=e:null===t.PrevInAEL&&(this.m_ActiveEdges=t)}},n.ClipperBase.prototype.DeleteFromAEL=function(e){var t=e.PrevInAEL,n=e.NextInAEL;null===t&&null===n&&e!==this.m_ActiveEdges||(null!==t?t.NextInAEL=n:this.m_ActiveEdges=n,null!==n&&(n.PrevInAEL=t),e.NextInAEL=null,e.PrevInAEL=null)},n.Clipper=function(e){void 0===e&&(e=0),this.m_PolyOuts=null,this.m_ClipType=n.ClipType.ctIntersection,this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=null,this.m_IntersectNodeComparer=null,this.m_ExecuteLocked=!1,this.m_ClipFillType=n.PolyFillType.pftEvenOdd,this.m_SubjFillType=n.PolyFillType.pftEvenOdd,this.m_Joins=null,this.m_GhostJoins=null,this.m_UsingPolyTree=!1,this.ReverseSolution=!1,this.StrictlySimple=!1,n.ClipperBase.call(this),this.m_Scanbeam=null,this.m_Maxima=null,this.m_ActiveEdges=null,this.m_SortedEdges=null,this.m_IntersectList=new Array,this.m_IntersectNodeComparer=n.MyIntersectNodeSort.Compare,this.m_ExecuteLocked=!1,this.m_UsingPolyTree=!1,this.m_PolyOuts=new Array,this.m_Joins=new Array,this.m_GhostJoins=new Array,this.ReverseSolution=0!=(1&e),this.StrictlySimple=0!=(2&e),this.PreserveCollinear=0!=(4&e),n.use_xyz&&(this.ZFillFunction=null)},n.Clipper.ioReverseSolution=1,n.Clipper.ioStrictlySimple=2,n.Clipper.ioPreserveCollinear=4,n.Clipper.prototype.Clear=function(){0!==this.m_edges.length&&(this.DisposeAllPolyPts(),n.ClipperBase.prototype.Clear.call(this))},n.Clipper.prototype.InsertMaxima=function(e){var t=new n.Maxima;if(t.X=e,null===this.m_Maxima)this.m_Maxima=t,this.m_Maxima.Next=null,this.m_Maxima.Prev=null;else if(e=i.Next.X;)i=i.Next;if(e===i.X)return;t.Next=i.Next,t.Prev=i,null!==i.Next&&(i.Next.Prev=t),i.Next=t}},n.Clipper.prototype.Execute=function(){var e=arguments,t=e.length,i=e[1]instanceof n.PolyTree;if(4===t&&!i){var r=e[0],a=e[1],s=e[2],o=e[3];if(this.m_ExecuteLocked)return!1;this.m_HasOpenPaths&&n.Error("Error: PolyTree struct is needed for open path clipping."),this.m_ExecuteLocked=!0,n.Clear(a),this.m_SubjFillType=s,this.m_ClipFillType=o,this.m_ClipType=r,this.m_UsingPolyTree=!1;try{(h=this.ExecuteInternal())&&this.BuildResult(a)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return h}if(4===t&&i){r=e[0];var l=e[1];if(s=e[2],o=e[3],this.m_ExecuteLocked)return!1;this.m_ExecuteLocked=!0,this.m_SubjFillType=s,this.m_ClipFillType=o,this.m_ClipType=r,this.m_UsingPolyTree=!0;try{var h;(h=this.ExecuteInternal())&&this.BuildResult2(l)}finally{this.DisposeAllPolyPts(),this.m_ExecuteLocked=!1}return h}return 2!==t||i?2===t&&i?(r=e[0],l=e[1],this.Execute(r,l,n.PolyFillType.pftEvenOdd,n.PolyFillType.pftEvenOdd)):void 0:(r=e[0],a=e[1],this.Execute(r,a,n.PolyFillType.pftEvenOdd,n.PolyFillType.pftEvenOdd))},n.Clipper.prototype.FixHoleLinkage=function(e){if(null!==e.FirstLeft&&(e.IsHole===e.FirstLeft.IsHole||null===e.FirstLeft.Pts)){for(var t=e.FirstLeft;null!==t&&(t.IsHole===e.IsHole||null===t.Pts);)t=t.FirstLeft;e.FirstLeft=t}},n.Clipper.prototype.ExecuteInternal=function(){try{this.Reset(),this.m_SortedEdges=null,this.m_Maxima=null;var e,t,n,i={},r={};if(!this.PopScanbeam(i))return!1;for(this.InsertLocalMinimaIntoAEL(i.v);this.PopScanbeam(r)||this.LocalMinimaPending();){if(this.ProcessHorizontals(),this.m_GhostJoins.length=0,!this.ProcessIntersections(r.v))return!1;this.ProcessEdgesAtTopOfScanbeam(r.v),i.v=r.v,this.InsertLocalMinimaIntoAEL(i.v)}for(t=0,n=this.m_PolyOuts.length;t0&&this.ReversePolyPtLinks(e.Pts);for(this.JoinCommonEdges(),t=0,n=this.m_PolyOuts.length;t0&&0!==i.WindDelta)for(var s=0,o=this.m_GhostJoins.length;s=0&&null!==t.PrevInAEL&&t.PrevInAEL.Curr.X===t.Bot.X&&t.PrevInAEL.OutIdx>=0&&n.ClipperBase.SlopesEqual5(t.PrevInAEL.Curr,t.PrevInAEL.Top,t.Curr,t.Top,this.m_UseFullRange)&&0!==t.WindDelta&&0!==t.PrevInAEL.WindDelta){var h=this.AddOutPt(t.PrevInAEL,t.Bot);this.AddJoin(a,h,t.Top)}if(t.NextInAEL!==i){i.OutIdx>=0&&i.PrevInAEL.OutIdx>=0&&n.ClipperBase.SlopesEqual5(i.PrevInAEL.Curr,i.PrevInAEL.Top,i.Curr,i.Top,this.m_UseFullRange)&&0!==i.WindDelta&&0!==i.PrevInAEL.WindDelta&&(h=this.AddOutPt(i.PrevInAEL,i.Bot),this.AddJoin(a,h,i.Top));var c=t.NextInAEL;if(null!==c)for(;c!==i;)this.IntersectEdges(i,c,t.Curr),c=c.NextInAEL}}}},n.Clipper.prototype.InsertEdgeIntoAEL=function(e,t){if(null===this.m_ActiveEdges)e.PrevInAEL=null,e.NextInAEL=null,this.m_ActiveEdges=e;else if(null===t&&this.E2InsertsBeforeE1(this.m_ActiveEdges,e))e.PrevInAEL=null,e.NextInAEL=this.m_ActiveEdges,this.m_ActiveEdges.PrevInAEL=e,this.m_ActiveEdges=e;else{for(null===t&&(t=this.m_ActiveEdges);null!==t.NextInAEL&&!this.E2InsertsBeforeE1(t.NextInAEL,e);)t=t.NextInAEL;e.NextInAEL=t.NextInAEL,null!==t.NextInAEL&&(t.NextInAEL.PrevInAEL=e),e.PrevInAEL=t,t.NextInAEL=e}},n.Clipper.prototype.E2InsertsBeforeE1=function(e,t){return t.Curr.X===e.Curr.X?t.Top.Y>e.Top.Y?t.Top.Xn.Clipper.TopX(t,e.Top.Y):t.Curr.X0;default:return e.WindCnt2<0}case n.ClipType.ctUnion:switch(i){case n.PolyFillType.pftEvenOdd:case n.PolyFillType.pftNonZero:return 0===e.WindCnt2;case n.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}case n.ClipType.ctDifference:if(e.PolyTyp===n.PolyType.ptSubject)switch(i){case n.PolyFillType.pftEvenOdd:case n.PolyFillType.pftNonZero:return 0===e.WindCnt2;case n.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}else switch(i){case n.PolyFillType.pftEvenOdd:case n.PolyFillType.pftNonZero:return 0!==e.WindCnt2;case n.PolyFillType.pftPositive:return e.WindCnt2>0;default:return e.WindCnt2<0}case n.ClipType.ctXor:if(0!==e.WindDelta)return!0;switch(i){case n.PolyFillType.pftEvenOdd:case n.PolyFillType.pftNonZero:return 0===e.WindCnt2;case n.PolyFillType.pftPositive:return e.WindCnt2<=0;default:return e.WindCnt2>=0}}return!0},n.Clipper.prototype.SetWindingCount=function(e){for(var t=e.PrevInAEL;null!==t&&(t.PolyTyp!==e.PolyTyp||0===t.WindDelta);)t=t.PrevInAEL;if(null===t){var i=e.PolyTyp===n.PolyType.ptSubject?this.m_SubjFillType:this.m_ClipFillType;0===e.WindDelta?e.WindCnt=i===n.PolyFillType.pftNegative?-1:1:e.WindCnt=e.WindDelta,e.WindCnt2=0,t=this.m_ActiveEdges}else if(0===e.WindDelta&&this.m_ClipType!==n.ClipType.ctUnion)e.WindCnt=1,e.WindCnt2=t.WindCnt2,t=t.NextInAEL;else if(this.IsEvenOddFillType(e)){if(0===e.WindDelta){for(var r=!0,a=t.PrevInAEL;null!==a;)a.PolyTyp===t.PolyTyp&&0!==a.WindDelta&&(r=!r),a=a.PrevInAEL;e.WindCnt=r?0:1}else e.WindCnt=e.WindDelta;e.WindCnt2=t.WindCnt2,t=t.NextInAEL}else t.WindCnt*t.WindDelta<0?Math.abs(t.WindCnt)>1?t.WindDelta*e.WindDelta<0?e.WindCnt=t.WindCnt:e.WindCnt=t.WindCnt+e.WindDelta:e.WindCnt=0===e.WindDelta?1:e.WindDelta:0===e.WindDelta?e.WindCnt=t.WindCnt<0?t.WindCnt-1:t.WindCnt+1:t.WindDelta*e.WindDelta<0?e.WindCnt=t.WindCnt:e.WindCnt=t.WindCnt+e.WindDelta,e.WindCnt2=t.WindCnt2,t=t.NextInAEL;if(this.IsEvenOddAltFillType(e))for(;t!==e;)0!==t.WindDelta&&(e.WindCnt2=0===e.WindCnt2?1:0),t=t.NextInAEL;else for(;t!==e;)e.WindCnt2+=t.WindDelta,t=t.NextInAEL},n.Clipper.prototype.AddEdgeToSEL=function(e){null===this.m_SortedEdges?(this.m_SortedEdges=e,e.PrevInSEL=null,e.NextInSEL=null):(e.NextInSEL=this.m_SortedEdges,e.PrevInSEL=null,this.m_SortedEdges.PrevInSEL=e,this.m_SortedEdges=e)},n.Clipper.prototype.PopEdgeFromSEL=function(e){if(e.v=this.m_SortedEdges,null===e.v)return!1;var t=e.v;return this.m_SortedEdges=e.v.NextInSEL,null!==this.m_SortedEdges&&(this.m_SortedEdges.PrevInSEL=null),t.NextInSEL=null,t.PrevInSEL=null,!0},n.Clipper.prototype.CopyAELToSEL=function(){var e=this.m_ActiveEdges;for(this.m_SortedEdges=e;null!==e;)e.PrevInSEL=e.PrevInAEL,e.NextInSEL=e.NextInAEL,e=e.NextInAEL},n.Clipper.prototype.SwapPositionsInSEL=function(e,t){if(!(null===e.NextInSEL&&null===e.PrevInSEL||null===t.NextInSEL&&null===t.PrevInSEL)){if(e.NextInSEL===t)null!==(n=t.NextInSEL)&&(n.PrevInSEL=e),null!==(i=e.PrevInSEL)&&(i.NextInSEL=t),t.PrevInSEL=i,t.NextInSEL=e,e.PrevInSEL=t,e.NextInSEL=n;else if(t.NextInSEL===e)null!==(n=e.NextInSEL)&&(n.PrevInSEL=t),null!==(i=t.PrevInSEL)&&(i.NextInSEL=e),e.PrevInSEL=i,e.NextInSEL=t,t.PrevInSEL=e,t.NextInSEL=n;else{var n=e.NextInSEL,i=e.PrevInSEL;e.NextInSEL=t.NextInSEL,null!==e.NextInSEL&&(e.NextInSEL.PrevInSEL=e),e.PrevInSEL=t.PrevInSEL,null!==e.PrevInSEL&&(e.PrevInSEL.NextInSEL=e),t.NextInSEL=n,null!==t.NextInSEL&&(t.NextInSEL.PrevInSEL=t),t.PrevInSEL=i,null!==t.PrevInSEL&&(t.PrevInSEL.NextInSEL=t)}null===e.PrevInSEL?this.m_SortedEdges=e:null===t.PrevInSEL&&(this.m_SortedEdges=t)}},n.Clipper.prototype.AddLocalMaxPoly=function(e,t,n){this.AddOutPt(e,n),0===t.WindDelta&&this.AddOutPt(t,n),e.OutIdx===t.OutIdx?(e.OutIdx=-1,t.OutIdx=-1):e.OutIdxt.Dx?(r=this.AddOutPt(e,i),t.OutIdx=e.OutIdx,e.Side=n.EdgeSide.esLeft,t.Side=n.EdgeSide.esRight,s=(a=e).PrevInAEL===t?t.PrevInAEL:a.PrevInAEL):(r=this.AddOutPt(t,i),e.OutIdx=t.OutIdx,e.Side=n.EdgeSide.esRight,t.Side=n.EdgeSide.esLeft,s=(a=t).PrevInAEL===e?e.PrevInAEL:a.PrevInAEL),null!==s&&s.OutIdx>=0&&s.Top.Yt&&(r=e,e=t,t=r),n>i&&(r=n,n=i,i=r),e=0&&0!==n.WindDelta&&(null===i?i=n:i.OutIdx===n.OutIdx&&(i=null)),n=n.PrevInAEL;null===i?(t.FirstLeft=null,t.IsHole=!1):(t.FirstLeft=this.m_PolyOuts[i.OutIdx],t.IsHole=!t.FirstLeft.IsHole)},n.Clipper.prototype.GetDx=function(e,t){return e.Y===t.Y?n.ClipperBase.horizontal:(t.X-e.X)/(t.Y-e.Y)},n.Clipper.prototype.FirstIsBottomPt=function(e,t){for(var i=e.Prev;n.IntPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Prev;var r=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=e.Next;n.IntPoint.op_Equality(i.Pt,e.Pt)&&i!==e;)i=i.Next;var a=Math.abs(this.GetDx(e.Pt,i.Pt));for(i=t.Prev;n.IntPoint.op_Equality(i.Pt,t.Pt)&&i!==t;)i=i.Prev;var s=Math.abs(this.GetDx(t.Pt,i.Pt));for(i=t.Next;n.IntPoint.op_Equality(i.Pt,t.Pt)&&i!==t;)i=i.Next;var o=Math.abs(this.GetDx(t.Pt,i.Pt));return Math.max(r,a)===Math.max(s,o)&&Math.min(r,a)===Math.min(s,o)?this.Area(e)>0:r>=s&&r>=o||a>=s&&a>=o},n.Clipper.prototype.GetBottomPt=function(e){for(var t=null,i=e.Next;i!==e;)i.Pt.Y>e.Pt.Y?(e=i,t=null):i.Pt.Y===e.Pt.Y&&i.Pt.X<=e.Pt.X&&(i.Pt.Xi.Pt.Y?e:n.Pt.Yi.Pt.X||n.Next===n?t:i.Next===i||this.FirstIsBottomPt(n,i)?e:t},n.Clipper.prototype.OutRec1RightOfOutRec2=function(e,t){do{if((e=e.FirstLeft)===t)return!0}while(null!==e);return!1},n.Clipper.prototype.GetOutRec=function(e){for(var t=this.m_PolyOuts[e];t!==this.m_PolyOuts[t.Idx];)t=this.m_PolyOuts[t.Idx];return t},n.Clipper.prototype.AppendPolygon=function(e,t){var i,r=this.m_PolyOuts[e.OutIdx],a=this.m_PolyOuts[t.OutIdx];i=this.OutRec1RightOfOutRec2(r,a)?a:this.OutRec1RightOfOutRec2(a,r)?r:this.GetLowermostRec(r,a);var s=r.Pts,o=s.Prev,l=a.Pts,h=l.Prev;e.Side===n.EdgeSide.esLeft?t.Side===n.EdgeSide.esLeft?(this.ReversePolyPtLinks(l),l.Next=s,s.Prev=l,o.Next=h,h.Prev=o,r.Pts=h):(h.Next=s,s.Prev=h,l.Prev=o,o.Next=l,r.Pts=l):t.Side===n.EdgeSide.esRight?(this.ReversePolyPtLinks(l),o.Next=h,h.Prev=o,l.Next=s,s.Prev=l):(o.Next=l,l.Prev=o,s.Prev=h,h.Next=s),r.BottomPt=null,i===a&&(a.FirstLeft!==r&&(r.FirstLeft=a.FirstLeft),r.IsHole=a.IsHole),a.Pts=null,a.BottomPt=null,a.FirstLeft=r;var c=e.OutIdx,u=t.OutIdx;e.OutIdx=-1,t.OutIdx=-1;for(var d=this.m_ActiveEdges;null!==d;){if(d.OutIdx===u){d.OutIdx=c,d.Side=e.Side;break}d=d.NextInAEL}a.Idx=r.Idx},n.Clipper.prototype.ReversePolyPtLinks=function(e){if(null!==e){var t,n;t=e;do{n=t.Next,t.Next=t.Prev,t.Prev=n,t=n}while(t!==e)}},n.Clipper.SwapSides=function(e,t){var n=e.Side;e.Side=t.Side,t.Side=n},n.Clipper.SwapPolyIndexes=function(e,t){var n=e.OutIdx;e.OutIdx=t.OutIdx,t.OutIdx=n},n.Clipper.prototype.IntersectEdges=function(e,t,i){var r=e.OutIdx>=0,a=t.OutIdx>=0;if(n.use_xyz&&this.SetZ(i,e,t),!n.use_lines||0!==e.WindDelta&&0!==t.WindDelta){if(e.PolyTyp===t.PolyTyp)if(this.IsEvenOddFillType(e)){var s=e.WindCnt;e.WindCnt=t.WindCnt,t.WindCnt=s}else e.WindCnt+t.WindDelta===0?e.WindCnt=-e.WindCnt:e.WindCnt+=t.WindDelta,t.WindCnt-e.WindDelta==0?t.WindCnt=-t.WindCnt:t.WindCnt-=e.WindDelta;else this.IsEvenOddFillType(t)?e.WindCnt2=0===e.WindCnt2?1:0:e.WindCnt2+=t.WindDelta,this.IsEvenOddFillType(e)?t.WindCnt2=0===t.WindCnt2?1:0:t.WindCnt2-=e.WindDelta;var o,l,h,c,u,d;switch(e.PolyTyp===n.PolyType.ptSubject?(o=this.m_SubjFillType,h=this.m_ClipFillType):(o=this.m_ClipFillType,h=this.m_SubjFillType),t.PolyTyp===n.PolyType.ptSubject?(l=this.m_SubjFillType,c=this.m_ClipFillType):(l=this.m_ClipFillType,c=this.m_SubjFillType),o){case n.PolyFillType.pftPositive:u=e.WindCnt;break;case n.PolyFillType.pftNegative:u=-e.WindCnt;break;default:u=Math.abs(e.WindCnt)}switch(l){case n.PolyFillType.pftPositive:d=t.WindCnt;break;case n.PolyFillType.pftNegative:d=-t.WindCnt;break;default:d=Math.abs(t.WindCnt)}if(r&&a)0!==u&&1!==u||0!==d&&1!==d||e.PolyTyp!==t.PolyTyp&&this.m_ClipType!==n.ClipType.ctXor?this.AddLocalMaxPoly(e,t,i):(this.AddOutPt(e,i),this.AddOutPt(t,i),n.Clipper.SwapSides(e,t),n.Clipper.SwapPolyIndexes(e,t));else if(r)(0===d||1===d)&&(this.AddOutPt(e,i),n.Clipper.SwapSides(e,t),n.Clipper.SwapPolyIndexes(e,t));else if(a)(0===u||1===u)&&(this.AddOutPt(t,i),n.Clipper.SwapSides(e,t),n.Clipper.SwapPolyIndexes(e,t));else if(!(0!==u&&1!==u||0!==d&&1!==d)){var p,f;switch(h){case n.PolyFillType.pftPositive:p=e.WindCnt2;break;case n.PolyFillType.pftNegative:p=-e.WindCnt2;break;default:p=Math.abs(e.WindCnt2)}switch(c){case n.PolyFillType.pftPositive:f=t.WindCnt2;break;case n.PolyFillType.pftNegative:f=-t.WindCnt2;break;default:f=Math.abs(t.WindCnt2)}if(e.PolyTyp!==t.PolyTyp)this.AddLocalMinPoly(e,t,i);else if(1===u&&1===d)switch(this.m_ClipType){case n.ClipType.ctIntersection:p>0&&f>0&&this.AddLocalMinPoly(e,t,i);break;case n.ClipType.ctUnion:p<=0&&f<=0&&this.AddLocalMinPoly(e,t,i);break;case n.ClipType.ctDifference:(e.PolyTyp===n.PolyType.ptClip&&p>0&&f>0||e.PolyTyp===n.PolyType.ptSubject&&p<=0&&f<=0)&&this.AddLocalMinPoly(e,t,i);break;case n.ClipType.ctXor:this.AddLocalMinPoly(e,t,i)}else n.Clipper.SwapSides(e,t)}}else{if(0===e.WindDelta&&0===t.WindDelta)return;e.PolyTyp===t.PolyTyp&&e.WindDelta!==t.WindDelta&&this.m_ClipType===n.ClipType.ctUnion?0===e.WindDelta?a&&(this.AddOutPt(e,i),r&&(e.OutIdx=-1)):r&&(this.AddOutPt(t,i),a&&(t.OutIdx=-1)):e.PolyTyp!==t.PolyTyp&&(0!==e.WindDelta||1!==Math.abs(t.WindCnt)||this.m_ClipType===n.ClipType.ctUnion&&0!==t.WindCnt2?0===t.WindDelta&&1===Math.abs(e.WindCnt)&&(this.m_ClipType!==n.ClipType.ctUnion||0===e.WindCnt2)&&(this.AddOutPt(t,i),a&&(t.OutIdx=-1)):(this.AddOutPt(e,i),r&&(e.OutIdx=-1)))}},n.Clipper.prototype.DeleteFromSEL=function(e){var t=e.PrevInSEL,n=e.NextInSEL;null===t&&null===n&&e!==this.m_SortedEdges||(null!==t?t.NextInSEL=n:this.m_SortedEdges=n,null!==n&&(n.PrevInSEL=t),e.NextInSEL=null,e.PrevInSEL=null)},n.Clipper.prototype.ProcessHorizontals=function(){for(var e={};this.PopEdgeFromSEL(e);)this.ProcessHorizontal(e.v)},n.Clipper.prototype.GetHorzDirection=function(e,t){e.Bot.X=o.Top.X&&(h=null)}else{for(;null!==h.Next&&h.Next.X=0&&!s&&this.AddOutPt(e,new n.IntPoint2(h.X,e.Bot.Y)),h=h.Next;else for(;null!==h&&h.X>d.Curr.X;)e.OutIdx>=0&&!s&&this.AddOutPt(e,new n.IntPoint2(h.X,e.Bot.Y)),h=h.Prev;if(i===n.Direction.dLeftToRight&&d.Curr.X>a||i===n.Direction.dRightToLeft&&d.Curr.X=0&&!s){n.use_xyz&&(i===n.Direction.dLeftToRight?this.SetZ(d.Curr,e,d):this.SetZ(d.Curr,d,e)),c=this.AddOutPt(e,d.Curr);for(var p=this.m_SortedEdges;null!==p;){if(p.OutIdx>=0&&this.HorzSegmentsOverlap(e.Bot.X,e.Top.X,p.Bot.X,p.Top.X)){var f=this.GetLastOutPt(p);this.AddJoin(f,c,p.Top)}p=p.NextInSEL}this.AddGhostJoin(c,e.Bot)}if(d===l&&u)return e.OutIdx>=0&&this.AddLocalMaxPoly(e,l,e.Top),this.DeleteFromAEL(e),void this.DeleteFromAEL(l);if(i===n.Direction.dLeftToRight){var m=new n.IntPoint2(d.Curr.X,e.Curr.Y);this.IntersectEdges(e,d,m)}else m=new n.IntPoint2(d.Curr.X,e.Curr.Y),this.IntersectEdges(d,e,m);var g=this.GetNextInAEL(d,i);this.SwapPositionsInAEL(e,d),d=g}if(null===e.NextInLML||!n.ClipperBase.IsHorizontal(e.NextInLML))break;(e=this.UpdateEdgeIntoAEL(e)).OutIdx>=0&&this.AddOutPt(e,e.Bot),t={Dir:i,Left:r,Right:a},this.GetHorzDirection(e,t),i=t.Dir,r=t.Left,a=t.Right}if(e.OutIdx>=0&&null===c){for(c=this.GetLastOutPt(e),p=this.m_SortedEdges;null!==p;)p.OutIdx>=0&&this.HorzSegmentsOverlap(e.Bot.X,e.Top.X,p.Bot.X,p.Top.X)&&(f=this.GetLastOutPt(p),this.AddJoin(f,c,p.Top)),p=p.NextInSEL;this.AddGhostJoin(c,e.Top)}if(null!==e.NextInLML)if(e.OutIdx>=0){if(c=this.AddOutPt(e,e.Top),0===(e=this.UpdateEdgeIntoAEL(e)).WindDelta)return;var v=e.PrevInAEL;g=e.NextInAEL,null!==v&&v.Curr.X===e.Bot.X&&v.Curr.Y===e.Bot.Y&&0===v.WindDelta&&v.OutIdx>=0&&v.Curr.Y>v.Top.Y&&n.ClipperBase.SlopesEqual3(e,v,this.m_UseFullRange)?(f=this.AddOutPt(v,e.Bot),this.AddJoin(c,f,e.Top)):null!==g&&g.Curr.X===e.Bot.X&&g.Curr.Y===e.Bot.Y&&0!==g.WindDelta&&g.OutIdx>=0&&g.Curr.Y>g.Top.Y&&n.ClipperBase.SlopesEqual3(e,g,this.m_UseFullRange)&&(f=this.AddOutPt(g,e.Bot),this.AddJoin(c,f,e.Top))}else e=this.UpdateEdgeIntoAEL(e);else e.OutIdx>=0&&this.AddOutPt(e,e.Top),this.DeleteFromAEL(e)},n.Clipper.prototype.GetNextInAEL=function(e,t){return t===n.Direction.dLeftToRight?e.NextInAEL:e.PrevInAEL},n.Clipper.prototype.IsMinima=function(e){return null!==e&&e.Prev.NextInLML!==e&&e.Next.NextInLML!==e},n.Clipper.prototype.IsMaxima=function(e,t){return null!==e&&e.Top.Y===t&&null===e.NextInLML},n.Clipper.prototype.IsIntermediate=function(e,t){return e.Top.Y===t&&null!==e.NextInLML},n.Clipper.prototype.GetMaximaPair=function(e){return n.IntPoint.op_Equality(e.Next.Top,e.Top)&&null===e.Next.NextInLML?e.Next:n.IntPoint.op_Equality(e.Prev.Top,e.Top)&&null===e.Prev.NextInLML?e.Prev:null},n.Clipper.prototype.GetMaximaPairEx=function(e){var t=this.GetMaximaPair(e);return null===t||t.OutIdx===n.ClipperBase.Skip||t.NextInAEL===t.PrevInAEL&&!n.ClipperBase.IsHorizontal(t)?null:t},n.Clipper.prototype.ProcessIntersections=function(e){if(null===this.m_ActiveEdges)return!0;try{if(this.BuildIntersectList(e),0===this.m_IntersectList.length)return!0;if(1!==this.m_IntersectList.length&&!this.FixupIntersectionOrder())return!1;this.ProcessIntersectList()}catch(e){this.m_SortedEdges=null,this.m_IntersectList.length=0,n.Error("ProcessIntersections error")}return this.m_SortedEdges=null,!0},n.Clipper.prototype.BuildIntersectList=function(e){if(null!==this.m_ActiveEdges){var t=this.m_ActiveEdges;for(this.m_SortedEdges=t;null!==t;)t.PrevInSEL=t.PrevInAEL,t.NextInSEL=t.NextInAEL,t.Curr.X=n.Clipper.TopX(t,e),t=t.NextInAEL;for(var i=!0;i&&null!==this.m_SortedEdges;){for(i=!1,t=this.m_SortedEdges;null!==t.NextInSEL;){var r=t.NextInSEL,a=new n.IntPoint0;if(t.Curr.X>r.Curr.X){this.IntersectPoint(t,r,a),a.Y2147483647?Math.floor(e):0|e}:n.Clipper.Round=function(e){return e<0?Math.ceil(e-.5):Math.floor(e+.5)},n.Clipper.TopX=function(e,t){return t===e.Top.Y?e.Top.X:e.Bot.X+n.Clipper.Round(e.Dx*(t-e.Bot.Y))},n.Clipper.prototype.IntersectPoint=function(e,t,i){var r,a;if(i.X=0,i.Y=0,e.Dx===t.Dx)return i.Y=e.Curr.Y,void(i.X=n.Clipper.TopX(e,i.Y));if(0===e.Delta.X)i.X=e.Bot.X,n.ClipperBase.IsHorizontal(t)?i.Y=t.Bot.Y:(a=t.Bot.Y-t.Bot.X/t.Dx,i.Y=n.Clipper.Round(i.X/t.Dx+a));else if(0===t.Delta.X)i.X=t.Bot.X,n.ClipperBase.IsHorizontal(e)?i.Y=e.Bot.Y:(r=e.Bot.Y-e.Bot.X/e.Dx,i.Y=n.Clipper.Round(i.X/e.Dx+r));else{r=e.Bot.X-e.Bot.Y*e.Dx;var s=((a=t.Bot.X-t.Bot.Y*t.Dx)-r)/(e.Dx-t.Dx);i.Y=n.Clipper.Round(s),Math.abs(e.Dx)t.Top.Y)return i.Y=e.Top.Y,i.X=n.Clipper.TopX(t,e.Top.Y),i.Xe.Curr.Y&&(i.Y=e.Curr.Y,Math.abs(e.Dx)>Math.abs(t.Dx)?i.X=n.Clipper.TopX(t,i.Y):i.X=n.Clipper.TopX(e,i.Y))},n.Clipper.prototype.ProcessEdgesAtTopOfScanbeam=function(e){for(var t=this.m_ActiveEdges;null!==t;){var i=this.IsMaxima(t,e);if(i){var r=this.GetMaximaPairEx(t);i=null===r||!n.ClipperBase.IsHorizontal(r)}if(i){this.StrictlySimple&&this.InsertMaxima(t.Top.X);var a=t.PrevInAEL;this.DoMaxima(t),t=null===a?this.m_ActiveEdges:a.NextInAEL}else{if(this.IsIntermediate(t,e)&&n.ClipperBase.IsHorizontal(t.NextInLML)?((t=this.UpdateEdgeIntoAEL(t)).OutIdx>=0&&this.AddOutPt(t,t.Bot),this.AddEdgeToSEL(t)):(t.Curr.X=n.Clipper.TopX(t,e),t.Curr.Y=e),n.use_xyz&&(t.Top.Y===e?t.Curr.Z=t.Top.Z:t.Bot.Y===e?t.Curr.Z=t.Bot.Z:t.Curr.Z=0),this.StrictlySimple&&(a=t.PrevInAEL,t.OutIdx>=0&&0!==t.WindDelta&&null!==a&&a.OutIdx>=0&&a.Curr.X===t.Curr.X&&0!==a.WindDelta)){var s=new n.IntPoint1(t.Curr);n.use_xyz&&this.SetZ(s,a,t);var o=this.AddOutPt(a,s),l=this.AddOutPt(t,s);this.AddJoin(o,l,s)}t=t.NextInAEL}}for(this.ProcessHorizontals(),this.m_Maxima=null,t=this.m_ActiveEdges;null!==t;){if(this.IsIntermediate(t,e)){o=null,t.OutIdx>=0&&(o=this.AddOutPt(t,t.Top)),a=(t=this.UpdateEdgeIntoAEL(t)).PrevInAEL;var h=t.NextInAEL;null!==a&&a.Curr.X===t.Bot.X&&a.Curr.Y===t.Bot.Y&&null!==o&&a.OutIdx>=0&&a.Curr.Y===a.Top.Y&&n.ClipperBase.SlopesEqual5(t.Curr,t.Top,a.Curr,a.Top,this.m_UseFullRange)&&0!==t.WindDelta&&0!==a.WindDelta?(l=this.AddOutPt(ePrev2,t.Bot),this.AddJoin(o,l,t.Top)):null!==h&&h.Curr.X===t.Bot.X&&h.Curr.Y===t.Bot.Y&&null!==o&&h.OutIdx>=0&&h.Curr.Y===h.Top.Y&&n.ClipperBase.SlopesEqual5(t.Curr,t.Top,h.Curr,h.Top,this.m_UseFullRange)&&0!==t.WindDelta&&0!==h.WindDelta&&(l=this.AddOutPt(h,t.Bot),this.AddJoin(o,l,t.Top))}t=t.NextInAEL}},n.Clipper.prototype.DoMaxima=function(e){var t=this.GetMaximaPairEx(e);if(null===t)return e.OutIdx>=0&&this.AddOutPt(e,e.Top),void this.DeleteFromAEL(e);for(var i=e.NextInAEL;null!==i&&i!==t;)this.IntersectEdges(e,i,e.Top),this.SwapPositionsInAEL(e,i),i=e.NextInAEL;-1===e.OutIdx&&-1===t.OutIdx?(this.DeleteFromAEL(e),this.DeleteFromAEL(t)):e.OutIdx>=0&&t.OutIdx>=0?(e.OutIdx>=0&&this.AddLocalMaxPoly(e,t,e.Top),this.DeleteFromAEL(e),this.DeleteFromAEL(t)):n.use_lines&&0===e.WindDelta?(e.OutIdx>=0&&(this.AddOutPt(e,e.Top),e.OutIdx=n.ClipperBase.Unassigned),this.DeleteFromAEL(e),t.OutIdx>=0&&(this.AddOutPt(t,e.Top),t.OutIdx=n.ClipperBase.Unassigned),this.DeleteFromAEL(t)):n.Error("DoMaxima error")},n.Clipper.ReversePaths=function(e){for(var t=0,n=e.length;t=0},n.Clipper.prototype.PointCount=function(e){if(null===e)return 0;var t=0,n=e;do{t++,n=n.Next}while(n!==e);return t},n.Clipper.prototype.BuildResult=function(e){n.Clear(e);for(var t=0,i=this.m_PolyOuts.length;tt.Pt.X?n.Direction.dRightToLeft:n.Direction.dLeftToRight,l=i.Pt.X>r.Pt.X?n.Direction.dRightToLeft:n.Direction.dLeftToRight;if(o===l)return!1;if(o===n.Direction.dLeftToRight){for(;e.Next.Pt.X<=a.X&&e.Next.Pt.X>=e.Pt.X&&e.Next.Pt.Y===a.Y;)e=e.Next;s&&e.Pt.X!==a.X&&(e=e.Next),t=this.DupOutPt(e,!s),n.IntPoint.op_Inequality(t.Pt,a)&&((e=t).Pt.X=a.X,e.Pt.Y=a.Y,n.use_xyz&&(e.Pt.Z=a.Z),t=this.DupOutPt(e,!s))}else{for(;e.Next.Pt.X>=a.X&&e.Next.Pt.X<=e.Pt.X&&e.Next.Pt.Y===a.Y;)e=e.Next;!s&&e.Pt.X!==a.X&&(e=e.Next),t=this.DupOutPt(e,s),n.IntPoint.op_Inequality(t.Pt,a)&&((e=t).Pt.X=a.X,e.Pt.Y=a.Y,n.use_xyz&&(e.Pt.Z=a.Z),t=this.DupOutPt(e,s))}if(l===n.Direction.dLeftToRight){for(;i.Next.Pt.X<=a.X&&i.Next.Pt.X>=i.Pt.X&&i.Next.Pt.Y===a.Y;)i=i.Next;s&&i.Pt.X!==a.X&&(i=i.Next),r=this.DupOutPt(i,!s),n.IntPoint.op_Inequality(r.Pt,a)&&((i=r).Pt.X=a.X,i.Pt.Y=a.Y,n.use_xyz&&(i.Pt.Z=a.Z),r=this.DupOutPt(i,!s))}else{for(;i.Next.Pt.X>=a.X&&i.Next.Pt.X<=i.Pt.X&&i.Next.Pt.Y===a.Y;)i=i.Next;!s&&i.Pt.X!==a.X&&(i=i.Next),r=this.DupOutPt(i,s),n.IntPoint.op_Inequality(r.Pt,a)&&((i=r).Pt.X=a.X,i.Pt.Y=a.Y,n.use_xyz&&(i.Pt.Z=a.Z),r=this.DupOutPt(i,s))}return o===n.Direction.dLeftToRight===s?(e.Prev=i,i.Next=e,t.Next=r,r.Prev=t):(e.Next=i,i.Prev=e,t.Prev=r,r.Next=t),!0},n.Clipper.prototype.JoinPoints=function(e,t,i){var r=e.OutPt1,a=new n.OutPt,s=e.OutPt2,o=new n.OutPt,l=e.OutPt1.Pt.Y===e.OffPt.Y;if(l&&n.IntPoint.op_Equality(e.OffPt,e.OutPt1.Pt)&&n.IntPoint.op_Equality(e.OffPt,e.OutPt2.Pt)){if(t!==i)return!1;for(a=e.OutPt1.Next;a!==r&&n.IntPoint.op_Equality(a.Pt,e.OffPt);)a=a.Next;var h=a.Pt.Y>e.OffPt.Y;for(o=e.OutPt2.Next;o!==s&&n.IntPoint.op_Equality(o.Pt,e.OffPt);)o=o.Next;return h!==o.Pt.Y>e.OffPt.Y&&(h?(a=this.DupOutPt(r,!1),o=this.DupOutPt(s,!0),r.Prev=s,s.Next=r,a.Next=o,o.Prev=a,e.OutPt1=r,e.OutPt2=a,!0):(a=this.DupOutPt(r,!0),o=this.DupOutPt(s,!1),r.Next=s,s.Prev=r,a.Prev=o,o.Next=a,e.OutPt1=r,e.OutPt2=a,!0))}if(l){for(a=r;r.Prev.Pt.Y===r.Pt.Y&&r.Prev!==a&&r.Prev!==s;)r=r.Prev;for(;a.Next.Pt.Y===a.Pt.Y&&a.Next!==r&&a.Next!==s;)a=a.Next;if(a.Next===r||a.Next===s)return!1;for(o=s;s.Prev.Pt.Y===s.Pt.Y&&s.Prev!==o&&s.Prev!==a;)s=s.Prev;for(;o.Next.Pt.Y===o.Pt.Y&&o.Next!==s&&o.Next!==r;)o=o.Next;if(o.Next===s||o.Next===r)return!1;var c={Left:null,Right:null};if(!this.GetOverlap(r.Pt.X,a.Pt.X,s.Pt.X,o.Pt.X,c))return!1;var u,d=c.Left,p=c.Right,f=new n.IntPoint0;return r.Pt.X>=d&&r.Pt.X<=p?(f.X=r.Pt.X,f.Y=r.Pt.Y,n.use_xyz&&(f.Z=r.Pt.Z),u=r.Pt.X>a.Pt.X):s.Pt.X>=d&&s.Pt.X<=p?(f.X=s.Pt.X,f.Y=s.Pt.Y,n.use_xyz&&(f.Z=s.Pt.Z),u=s.Pt.X>o.Pt.X):a.Pt.X>=d&&a.Pt.X<=p?(f.X=a.Pt.X,f.Y=a.Pt.Y,n.use_xyz&&(f.Z=a.Pt.Z),u=a.Pt.X>r.Pt.X):(f.X=o.Pt.X,f.Y=o.Pt.Y,n.use_xyz&&(f.Z=o.Pt.Z),u=o.Pt.X>s.Pt.X),e.OutPt1=r,e.OutPt2=s,this.JoinHorz(r,a,s,o,f,u)}for(a=r.Next;n.IntPoint.op_Equality(a.Pt,r.Pt)&&a!==r;)a=a.Next;var m=a.Pt.Y>r.Pt.Y||!n.ClipperBase.SlopesEqual4(r.Pt,a.Pt,e.OffPt,this.m_UseFullRange);if(m){for(a=r.Prev;n.IntPoint.op_Equality(a.Pt,r.Pt)&&a!==r;)a=a.Prev;if(a.Pt.Y>r.Pt.Y||!n.ClipperBase.SlopesEqual4(r.Pt,a.Pt,e.OffPt,this.m_UseFullRange))return!1}for(o=s.Next;n.IntPoint.op_Equality(o.Pt,s.Pt)&&o!==s;)o=o.Next;var g=o.Pt.Y>s.Pt.Y||!n.ClipperBase.SlopesEqual4(s.Pt,o.Pt,e.OffPt,this.m_UseFullRange);if(g){for(o=s.Prev;n.IntPoint.op_Equality(o.Pt,s.Pt)&&o!==s;)o=o.Prev;if(o.Pt.Y>s.Pt.Y||!n.ClipperBase.SlopesEqual4(s.Pt,o.Pt,e.OffPt,this.m_UseFullRange))return!1}return a!==r&&o!==s&&a!==o&&(t!==i||m!==g)&&(m?(a=this.DupOutPt(r,!1),o=this.DupOutPt(s,!0),r.Prev=s,s.Next=r,a.Next=o,o.Prev=a,e.OutPt1=r,e.OutPt2=a,!0):(a=this.DupOutPt(r,!0),o=this.DupOutPt(s,!1),r.Next=s,s.Prev=r,a.Prev=o,o.Next=a,e.OutPt1=r,e.OutPt2=a,!0))},n.Clipper.GetBounds=function(e){for(var t=0,i=e.length;tr.right&&(r.right=e[t][a].X),e[t][a].Yr.bottom&&(r.bottom=e[t][a].Y);return r},n.Clipper.prototype.GetBounds2=function(e){var t=e,i=new n.IntRect;for(i.left=e.Pt.X,i.right=e.Pt.X,i.top=e.Pt.Y,i.bottom=e.Pt.Y,e=e.Next;e!==t;)e.Pt.Xi.right&&(i.right=e.Pt.X),e.Pt.Yi.bottom&&(i.bottom=e.Pt.Y),e=e.Next;return i},n.Clipper.PointInPolygon=function(e,t){var n=0,i=t.length;if(i<3)return 0;for(var r=t[0],a=1;a<=i;++a){var s=a===i?t[0]:t[a];if(s.Y===e.Y&&(s.X===e.X||r.Y===e.Y&&s.X>e.X==r.X=e.X)if(s.X>e.X)n=1-n;else{if(0===(o=(r.X-e.X)*(s.Y-e.Y)-(s.X-e.X)*(r.Y-e.Y)))return-1;o>0==s.Y>r.Y&&(n=1-n)}else if(s.X>e.X){var o;if(0===(o=(r.X-e.X)*(s.Y-e.Y)-(s.X-e.X)*(r.Y-e.Y)))return-1;o>0==s.Y>r.Y&&(n=1-n)}r=s}return n},n.Clipper.prototype.PointInPolygon=function(e,t){var n=0,i=t,r=e.X,a=e.Y,s=t.Pt.X,o=t.Pt.Y;do{var l=(t=t.Next).Pt.X,h=t.Pt.Y;if(h===a&&(l===r||o===a&&l>r==s=r)if(l>r)n=1-n;else{if(0===(c=(s-r)*(h-a)-(l-r)*(o-a)))return-1;c>0==h>o&&(n=1-n)}else if(l>r){var c;if(0===(c=(s-r)*(h-a)-(l-r)*(o-a)))return-1;c>0==h>o&&(n=1-n)}s=l,o=h}while(i!==t);return n},n.Clipper.prototype.Poly2ContainsPoly1=function(e,t){var n=e;do{var i=this.PointInPolygon(n.Pt,t);if(i>=0)return i>0;n=n.Next}while(n!==e);return!0},n.Clipper.prototype.FixupFirstLefts1=function(e,t){for(var i,r,a=0,s=this.m_PolyOuts.length;a0&&this.ReversePolyPtLinks(a.Pts)):this.Poly2ContainsPoly1(r.Pts,a.Pts)?(a.IsHole=r.IsHole,r.IsHole=!a.IsHole,a.FirstLeft=r.FirstLeft,r.FirstLeft=a,this.m_UsingPolyTree&&this.FixupFirstLefts2(r,a),(r.IsHole^this.ReverseSolution)==this.Area$1(r)>0&&this.ReversePolyPtLinks(r.Pts)):(a.IsHole=r.IsHole,a.FirstLeft=r.FirstLeft,this.m_UsingPolyTree&&this.FixupFirstLefts1(r,a))):(a.Pts=null,a.BottomPt=null,a.Idx=r.Idx,r.IsHole=n.IsHole,n===a&&(r.FirstLeft=a.FirstLeft),a.FirstLeft=r,this.m_UsingPolyTree&&this.FixupFirstLefts3(a,r))))}},n.Clipper.prototype.UpdateOutPtIdxs=function(e){var t=e.Pts;do{t.Idx=e.Idx,t=t.Prev}while(t!==e.Pts)},n.Clipper.prototype.DoSimplePolygons=function(){for(var e=0;eMath.abs(e.Y-t.Y)?e.X>t.X==e.Xe.X==t.Xt.Y==e.Ye.Y==t.Y0&&r&&i.push(e.m_polygon);for(var a=0,s=e.Childs(),o=s.length,l=s[a];a0&&n.IntPoint.op_Equality(e[0],e[r]);)r--;a.m_polygon.push(e[0]);for(var s=0,o=0,l=1;l<=r;l++)n.IntPoint.op_Inequality(a.m_polygon[s],e[l])&&(s++,a.m_polygon.push(e[l]),(e[l].Y>a.m_polygon[o].Y||e[l].Y===a.m_polygon[o].Y&&e[l].Xh.Y||a.m_polygon[o].Y===h.Y&&a.m_polygon[o].X=0&&!n.Clipper.Orientation(this.m_polyNodes.Childs()[this.m_lowest.X].m_polygon))for(var e=0;e2?this.m_miterLim=2/(this.MiterLimit*this.MiterLimit):this.m_miterLim=.5,i=this.ArcTolerance<=0?n.ClipperOffset.def_arc_tolerance:this.ArcTolerance>Math.abs(e)*n.ClipperOffset.def_arc_tolerance?Math.abs(e)*n.ClipperOffset.def_arc_tolerance:this.ArcTolerance;var r=3.14159265358979/Math.acos(1-i/Math.abs(e));for(this.m_sin=Math.sin(n.ClipperOffset.two_pi/r),this.m_cos=Math.cos(n.ClipperOffset.two_pi/r),this.m_StepsPerRad=r/n.ClipperOffset.two_pi,e<0&&(this.m_sin=-this.m_sin),t=0;t0;h--)this.m_normals[h]=new n.DoublePoint2(-this.m_normals[h-1].X,-this.m_normals[h-1].Y);for(this.m_normals[0]=new n.DoublePoint2(-d.X,-d.Y),u=0,h=s-1;h>=0;h--)u=this.OffsetPoint(h,u,a.m_jointype);this.m_destPolys.push(this.m_destPoly)}else{for(u=0,h=1;h0;h--)this.m_normals[h]=new n.DoublePoint2(-this.m_normals[h-1].X,-this.m_normals[h-1].Y);for(this.m_normals[0]=new n.DoublePoint2(-this.m_normals[1].X,-this.m_normals[1].Y),h=(u=s-1)-1;h>0;--h)u=this.OffsetPoint(h,u,a.m_jointype);a.m_endtype===n.EndType.etOpenButt?(p=new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[0].X-this.m_normals[0].X*e),n.ClipperOffset.Round(this.m_srcPoly[0].Y-this.m_normals[0].Y*e)),this.m_destPoly.push(p),p=new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[0].X+this.m_normals[0].X*e),n.ClipperOffset.Round(this.m_srcPoly[0].Y+this.m_normals[0].Y*e)),this.m_destPoly.push(p)):(u=1,this.m_sinA=0,a.m_endtype===n.EndType.etOpenSquare?this.DoSquare(0,1):this.DoRound(0,1)),this.m_destPolys.push(this.m_destPoly)}}}}},n.ClipperOffset.prototype.Execute=function(){var e=arguments;if(e[0]instanceof n.PolyTree){var t=e[1];if((l=e[0]).Clear(),this.FixOrientations(),this.DoOffset(t),(s=new n.Clipper(0)).AddPaths(this.m_destPolys,n.PolyType.ptSubject,!0),t>0)s.Execute(n.ClipType.ctUnion,l,n.PolyFillType.pftPositive,n.PolyFillType.pftPositive);else{var i=n.Clipper.GetBounds(this.m_destPolys);if((o=new n.Path).push(new n.IntPoint2(i.left-10,i.bottom+10)),o.push(new n.IntPoint2(i.right+10,i.bottom+10)),o.push(new n.IntPoint2(i.right+10,i.top-10)),o.push(new n.IntPoint2(i.left-10,i.top-10)),s.AddPath(o,n.PolyType.ptSubject,!0),s.ReverseSolution=!0,s.Execute(n.ClipType.ctUnion,l,n.PolyFillType.pftNegative,n.PolyFillType.pftNegative),1===l.ChildCount()&&l.Childs()[0].ChildCount()>0){var r=l.Childs()[0];l.Childs()[0]=r.Childs()[0],l.Childs()[0].m_Parent=l;for(var a=1;a0)s.Execute(n.ClipType.ctUnion,l,n.PolyFillType.pftPositive,n.PolyFillType.pftPositive);else i=n.Clipper.GetBounds(this.m_destPolys),(o=new n.Path).push(new n.IntPoint2(i.left-10,i.bottom+10)),o.push(new n.IntPoint2(i.right+10,i.bottom+10)),o.push(new n.IntPoint2(i.right+10,i.top-10)),o.push(new n.IntPoint2(i.left-10,i.top-10)),s.AddPath(o,n.PolyType.ptSubject,!0),s.ReverseSolution=!0,s.Execute(n.ClipType.ctUnion,l,n.PolyFillType.pftNegative,n.PolyFillType.pftNegative),l.length>0&&l.splice(0,1)}},n.ClipperOffset.prototype.OffsetPoint=function(e,t,i){if(this.m_sinA=this.m_normals[t].X*this.m_normals[e].Y-this.m_normals[e].X*this.m_normals[t].Y,Math.abs(this.m_sinA*this.m_delta)<1){if(this.m_normals[t].X*this.m_normals[e].X+this.m_normals[e].Y*this.m_normals[t].Y>0)return this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[t].X*this.m_delta),n.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[t].Y*this.m_delta))),t}else this.m_sinA>1?this.m_sinA=1:this.m_sinA<-1&&(this.m_sinA=-1);if(this.m_sinA*this.m_delta<0)this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[t].X*this.m_delta),n.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[t].Y*this.m_delta))),this.m_destPoly.push(new n.IntPoint1(this.m_srcPoly[e])),this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_normals[e].X*this.m_delta),n.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_normals[e].Y*this.m_delta)));else switch(i){case n.JoinType.jtMiter:var r=this.m_normals[e].X*this.m_normals[t].X+this.m_normals[e].Y*this.m_normals[t].Y+1;r>=this.m_miterLim?this.DoMiter(e,t,r):this.DoSquare(e,t);break;case n.JoinType.jtSquare:this.DoSquare(e,t);break;case n.JoinType.jtRound:this.DoRound(e,t)}return e},n.ClipperOffset.prototype.DoSquare=function(e,t){var i=Math.tan(Math.atan2(this.m_sinA,this.m_normals[t].X*this.m_normals[e].X+this.m_normals[t].Y*this.m_normals[e].Y)/4);this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[t].X-this.m_normals[t].Y*i)),n.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[t].Y+this.m_normals[t].X*i)))),this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+this.m_delta*(this.m_normals[e].X+this.m_normals[e].Y*i)),n.ClipperOffset.Round(this.m_srcPoly[e].Y+this.m_delta*(this.m_normals[e].Y-this.m_normals[e].X*i))))},n.ClipperOffset.prototype.DoMiter=function(e,t,i){var r=this.m_delta/i;this.m_destPoly.push(new n.IntPoint2(n.ClipperOffset.Round(this.m_srcPoly[e].X+(this.m_normals[t].X+this.m_normals[e].X)*r),n.ClipperOffset.Round(this.m_srcPoly[e].Y+(this.m_normals[t].Y+this.m_normals[e].Y)*r)))},n.ClipperOffset.prototype.DoRound=function(e,t){for(var i,r=Math.atan2(this.m_sinA,this.m_normals[t].X*this.m_normals[e].X+this.m_normals[t].Y*this.m_normals[e].Y),a=Math.max(n.Cast_Int32(n.ClipperOffset.Round(this.m_StepsPerRad*Math.abs(r))),1),s=this.m_normals[t].X,o=this.m_normals[t].Y,l=0;l1?(y=u.X,x=u.Y):v>0&&(y+=m*v,x+=g*v)),(m=d.X-y)*m+(g=d.Y-x)*g<=_&&(p[a+1]=1,a++);for(l.push({X:s[0].X,Y:s[0].Y}),a=1;a2&&w.push(l)}return i||(w=w[0]),void 0===w&&(w=[]),w},n.JS.PerimeterOfPath=function(e,t,n){if(void 0===e)return 0;var i,r,a=Math.sqrt,s=0,o=0,l=0,h=0,c=0,u=e.length;if(u<2)return 0;for(t&&(e[u]=e[0],u++);--u;)o=(i=e[u]).X,l=i.Y,s+=a((o-(h=(r=e[u-1]).X))*(o-h)+(l-(c=r.Y))*(l-c));return t&&e.pop(),s/n},n.JS.PerimeterOfPaths=function(e,t,i){i||(i=1);for(var r=0,a=0;a{})),Uye=J((()=>{})),Hye=J((()=>{})),Vye=J((()=>{})),zye=J((()=>{})),v1e=J(((exports,module)=>{var t,e;t=globalThis,e=()=>(()=>{"use strict";var __webpack_modules__=[,(e,t)=>{var n;Object.defineProperty(t,"__esModule",{value:!0}),t.VerbosityLevel=t.Util=t.UnknownErrorException=t.UnexpectedResponseException=t.TextRenderingMode=t.RenderingIntentFlag=t.PromiseCapability=t.PermissionFlag=t.PasswordResponses=t.PasswordException=t.PageActionEventType=t.OPS=t.MissingPDFException=t.MAX_IMAGE_SIZE_TO_CACHE=t.LINE_FACTOR=t.LINE_DESCENT_FACTOR=t.InvalidPDFException=t.ImageKind=t.IDENTITY_MATRIX=t.FormatError=t.FeatureTest=t.FONT_IDENTITY_MATRIX=t.DocumentActionEventType=t.CMapCompressionType=t.BaseException=t.BASELINE_FACTOR=t.AnnotationType=t.AnnotationReplyType=t.AnnotationMode=t.AnnotationFlag=t.AnnotationFieldFlag=t.AnnotationEditorType=t.AnnotationEditorPrefix=t.AnnotationEditorParamsType=t.AnnotationBorderStyleType=t.AnnotationActionEventType=t.AbortException=void 0,t.assert=function(e,t){e||s(t)},t.bytesToString=function(e){("object"!=typeof e||void 0===(null==e?void 0:e.length))&&s("Invalid argument for bytesToString");let t=e.length,n=8192;if(t=2&&(e=`http://${e}`)}if(n.tryConvertEncoding)try{e=d(e)}catch(e){}}let i=t?new URL(e,t):new URL(e);if(function(e){switch(null==e?void 0:e.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(i))return i}catch(e){}return null},t.getModificationDate=function(e=new Date){return[e.getUTCFullYear().toString(),(e.getUTCMonth()+1).toString().padStart(2,"0"),e.getUTCDate().toString().padStart(2,"0"),e.getUTCHours().toString().padStart(2,"0"),e.getUTCMinutes().toString().padStart(2,"0"),e.getUTCSeconds().toString().padStart(2,"0")].join("")},t.getVerbosityLevel=function(){return r},t.info=function(e){r>=i.INFOS&&console.log(`Info: ${e}`)},t.isArrayBuffer=function(e){return"object"==typeof e&&void 0!==(null==e?void 0:e.byteLength)},t.isArrayEqual=function(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;nt?t.normalize("NFKC"):f.get(n)))},t.objectFromMap=function(e){let t=Object.create(null);for(let[n,i]of e)t[n]=i;return t},t.objectSize=function(e){return Object.keys(e).length},t.setVerbosityLevel=function(e){Number.isInteger(e)&&(r=e)},t.shadow=o,t.string32=function(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)},t.stringToBytes=h,t.stringToPDFString=function(e){if(e[0]>="\xef"){let t;if("\xfe"===e[0]&&"\xff"===e[1]?t="utf-16be":"\xff"===e[0]&&"\xfe"===e[1]?t="utf-16le":"\xef"===e[0]&&"\xbb"===e[1]&&"\xbf"===e[2]&&(t="utf-8"),t)try{let n=new TextDecoder(t,{fatal:!0}),i=h(e);return n.decode(i)}catch(e){a(`stringToPDFString: "${e}".`)}}let t=[];for(let n=0,i=e.length;n=i.WARNINGS&&console.log(`Warning: ${e}`)}function s(e){throw new Error(e)}function o(e,t,n,i=!1){return Object.defineProperty(e,t,{value:n,enumerable:!i,configurable:!0,writable:!1}),n}let l=function(){function e(t,n){this.constructor===e&&s("Cannot initialize BaseException."),this.message=t,this.name=n}return e.prototype=new Error,e.constructor=e,e}();function h(e){"string"!=typeof e&&s("Invalid argument for stringToBytes");let t=e.length,n=new Uint8Array(t);for(let i=0;ie.toString(16).padStart(2,"0")));t.Util=class{static makeHexColor(e,t,n){return`#${c[e]}${c[t]}${c[n]}`}static scaleMinMax(e,t){let n;e[0]?(e[0]<0&&(n=t[0],t[0]=t[1],t[1]=n),t[0]*=e[0],t[1]*=e[0],e[3]<0&&(n=t[2],t[2]=t[3],t[3]=n),t[2]*=e[3],t[3]*=e[3]):(n=t[0],t[0]=t[2],t[2]=n,n=t[1],t[1]=t[3],t[3]=n,e[1]<0&&(n=t[2],t[2]=t[3],t[3]=n),t[2]*=e[1],t[3]*=e[1],e[2]<0&&(n=t[0],t[0]=t[1],t[1]=n),t[0]*=e[2],t[1]*=e[2]),t[0]+=e[4],t[1]+=e[4],t[2]+=e[5],t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){return[e[0]*t[0]+e[1]*t[2]+t[4],e[0]*t[1]+e[1]*t[3]+t[5]]}static applyInverseTransform(e,t){let n=t[0]*t[3]-t[1]*t[2];return[(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/n,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/n]}static getAxialAlignedBoundingBox(e,t){let n=this.applyTransform(e,t),i=this.applyTransform(e.slice(2,4),t),r=this.applyTransform([e[0],e[3]],t),a=this.applyTransform([e[2],e[1]],t);return[Math.min(n[0],i[0],r[0],a[0]),Math.min(n[1],i[1],r[1],a[1]),Math.max(n[0],i[0],r[0],a[0]),Math.max(n[1],i[1],r[1],a[1])]}static inverseTransform(e){let t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e){let t=[e[0],e[2],e[1],e[3]],n=e[0]*t[0]+e[1]*t[2],i=e[0]*t[1]+e[1]*t[3],r=e[2]*t[0]+e[3]*t[2],a=e[2]*t[1]+e[3]*t[3],s=(n+a)/2,o=Math.sqrt(Oo(n+a,2)-4*(n*a-r*i))/2,l=s+o||1,h=s-o||1;return[Math.sqrt(l),Math.sqrt(h)]}static normalizeRect(e){let t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){let n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),i=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>i)return null;let r=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),a=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return r>a?null:[n,r,i,a]}static bezierBoundingBox(e,t,n,i,r,a,s,o){let l,h,c,u,d,p,f,m,g=[],v=[[],[]];for(let _=0;_<2;++_)if(0===_?(h=6*e-12*n+6*r,l=-3*e+9*n-9*r+3*s,c=3*n-3*e):(h=6*t-12*i+6*a,l=-3*t+9*i-9*a+3*o,c=3*i-3*t),Math.abs(l)<1e-12){if(Math.abs(h)<1e-12)continue;u=-c/h,0{this.resolve=t=>{St(this,n,!0),e(t)},this.reject=e=>{St(this,n,!0),t(e)}}))}get settled(){return ce(this,n)}};let p=null,f=null},(__unused_webpack_module,exports,__w_pdfjs_require__)=>{var i,e,n,r,$y,a,H2,l,c,u,h,d,f,p,g,_V,v,E,TV,_,R;Object.defineProperty(exports,"__esModule",{value:!0}),exports.build=exports.RenderTask=exports.PDFWorkerUtil=exports.PDFWorker=exports.PDFPageProxy=exports.PDFDocumentProxy=exports.PDFDocumentLoadingTask=exports.PDFDataRangeTransport=exports.LoopbackPort=exports.DefaultStandardFontDataFactory=exports.DefaultFilterFactory=exports.DefaultCanvasFactory=exports.DefaultCMapReaderFactory=void 0,exports.getDocument=getDocument,exports.version=void 0;var _util=__w_pdfjs_require__(1),_annotation_storage=__w_pdfjs_require__(3),_display_utils=__w_pdfjs_require__(6),_font_loader=__w_pdfjs_require__(9),_canvas=__w_pdfjs_require__(11),_worker_options=__w_pdfjs_require__(14),_is_node=__w_pdfjs_require__(10),_message_handler=__w_pdfjs_require__(15),_metadata=__w_pdfjs_require__(16),_optional_content_config=__w_pdfjs_require__(17),_transport_stream=__w_pdfjs_require__(18),_xfa_text=__w_pdfjs_require__(19);let DEFAULT_RANGE_CHUNK_SIZE=65536,RENDERING_CANCELLED_TIMEOUT=100,DELAYED_CLEANUP_TIMEOUT=5e3,DefaultCanvasFactory=_is_node.isNodeJS?__w_pdfjs_require__(20).NodeCanvasFactory:_display_utils.DOMCanvasFactory;exports.DefaultCanvasFactory=DefaultCanvasFactory;let DefaultCMapReaderFactory=_is_node.isNodeJS?__w_pdfjs_require__(20).NodeCMapReaderFactory:_display_utils.DOMCMapReaderFactory;exports.DefaultCMapReaderFactory=DefaultCMapReaderFactory;let DefaultFilterFactory=_is_node.isNodeJS?__w_pdfjs_require__(20).NodeFilterFactory:_display_utils.DOMFilterFactory;exports.DefaultFilterFactory=DefaultFilterFactory;let DefaultStandardFontDataFactory=_is_node.isNodeJS?__w_pdfjs_require__(20).NodeStandardFontDataFactory:_display_utils.DOMStandardFontDataFactory,createPDFNetworkStream;if(exports.DefaultStandardFontDataFactory=DefaultStandardFontDataFactory,_is_node.isNodeJS){let{PDFNodeStream:e}=__w_pdfjs_require__(21);createPDFNetworkStream=t=>new e(t)}else{let{PDFNetworkStream:e}=__w_pdfjs_require__(24),{PDFFetchStream:t}=__w_pdfjs_require__(25);createPDFNetworkStream=n=>(0,_display_utils.isValidFetchUrl)(n.url)?new t(n):new e(n)}function getDocument(e){var t,n;if("string"==typeof e||e instanceof URL?e={url:e}:(0,_util.isArrayBuffer)(e)&&(e={data:e}),"object"!=typeof e)throw new Error("Invalid parameter in getDocument, need parameter object.");if(!e.url&&!e.data&&!e.range)throw new Error("Invalid parameter object: need either .data, .range or .url");let i=new PDFDocumentLoadingTask,{docId:r}=i,a=e.url?getUrlProp(e.url):null,s=e.data?getDataProp(e.data):null,o=e.httpHeaders||null,l=!0===e.withCredentials,h=null!=(t=e.password)?t:null,c=e.range instanceof PDFDataRangeTransport?e.range:null,u=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:DEFAULT_RANGE_CHUNK_SIZE,d=e.worker instanceof PDFWorker?e.worker:null,p=e.verbosity,f="string"!=typeof e.docBaseUrl||(0,_display_utils.isDataScheme)(e.docBaseUrl)?null:e.docBaseUrl,m="string"==typeof e.cMapUrl?e.cMapUrl:null,g=!1!==e.cMapPacked,v=e.CMapReaderFactory||DefaultCMapReaderFactory,y="string"==typeof e.standardFontDataUrl?e.standardFontDataUrl:null,x=e.StandardFontDataFactory||DefaultStandardFontDataFactory,b=!0!==e.stopAtErrors,_=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,w=!1!==e.isEvalSupported,S="boolean"==typeof e.isOffscreenCanvasSupported?e.isOffscreenCanvasSupported:!_is_node.isNodeJS,M=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,T="boolean"==typeof e.disableFontFace?e.disableFontFace:_is_node.isNodeJS,E=!0===e.fontExtraProperties,A=!0===e.enableXfa,C=e.ownerDocument||globalThis.document,P=!0===e.disableRange,R=!0===e.disableStream,O=!0===e.disableAutoFetch,L=!0===e.pdfBug,I=c?c.length:null!=(n=e.length)?n:NaN,D="boolean"==typeof e.useSystemFonts?e.useSystemFonts:!_is_node.isNodeJS&&!T,k="boolean"==typeof e.useWorkerFetch?e.useWorkerFetch:v===_display_utils.DOMCMapReaderFactory&&x===_display_utils.DOMStandardFontDataFactory&&(0,_display_utils.isValidFetchUrl)(m,document.baseURI)&&(0,_display_utils.isValidFetchUrl)(y,document.baseURI),N=e.canvasFactory||new DefaultCanvasFactory({ownerDocument:C}),F=e.filterFactory||new DefaultFilterFactory({docId:r,ownerDocument:C});(0,_util.setVerbosityLevel)(p);let U={canvasFactory:N,filterFactory:F};if(k||(U.cMapReaderFactory=new v({baseUrl:m,isCompressed:g}),U.standardFontDataFactory=new x({baseUrl:y})),!d){let e={verbosity:p,port:_worker_options.GlobalWorkerOptions.workerPort};d=e.port?PDFWorker.fromPort(e):new PDFWorker(e),i._worker=d}let B={docId:r,apiVersion:"3.8.162",data:s,password:h,disableAutoFetch:O,rangeChunkSize:u,length:I,docBaseUrl:f,enableXfa:A,evaluatorOptions:{maxImageSize:_,disableFontFace:T,ignoreErrors:b,isEvalSupported:w,isOffscreenCanvasSupported:S,canvasMaxAreaInBytes:M,fontExtraProperties:E,useSystemFonts:D,cMapUrl:k?m:null,standardFontDataUrl:k?y:null}},z={ignoreErrors:b,isEvalSupported:w,disableFontFace:T,fontExtraProperties:E,enableXfa:A,ownerDocument:C,disableAutoFetch:O,pdfBug:L,styleElement:null};return d.promise.then((function(){if(i.destroyed)throw new Error("Loading aborted");let e=_fetchDocument(d,B),t=new Promise((function(e){let t;c?t=new _transport_stream.PDFDataTransportStream({length:I,initialData:c.initialData,progressiveDone:c.progressiveDone,contentDispositionFilename:c.contentDispositionFilename,disableRange:P,disableStream:R},c):s||(t=createPDFNetworkStream({url:a,length:I,httpHeaders:o,withCredentials:l,rangeChunkSize:u,disableRange:P,disableStream:R})),e(t)}));return Promise.all([e,t]).then((function([e,t]){if(i.destroyed)throw new Error("Loading aborted");let n=new _message_handler.MessageHandler(r,e,d.port),a=new WorkerTransport(n,i,t,z,U);i._transport=a,n.send("Ready",null)}))})).catch(i._capability.reject),i}function _fetchDocument(e,t){return ft(this,null,(function*(){if(e.destroyed)throw new Error("Worker was destroyed");let n=yield e.messageHandler.sendWithPromise("GetDocRequest",t,t.data?[t.data.buffer]:null);if(e.destroyed)throw new Error("Worker was destroyed");return n}))}function getUrlProp(e){if(e instanceof URL)return e.href;try{return new URL(e,window.location).href}catch(t){if(_is_node.isNodeJS&&"string"==typeof e)return e}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function getDataProp(e){if(_is_node.isNodeJS&&"undefined"!=typeof Buffer&&e instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if("string"==typeof e)return(0,_util.stringToBytes)(e);if("object"==typeof e&&!isNaN(null==e?void 0:e.length)||(0,_util.isArrayBuffer)(e))return new Uint8Array(e);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}let t=class{constructor(){this._capability=new _util.PromiseCapability,this._transport=null,this._worker=null,this.docId="d"+NT(t,i)._++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}destroy(){return ft(this,null,(function*(){var e;this.destroyed=!0,yield null==(e=this._transport)?void 0:e.destroy(),this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}))}},PDFDocumentLoadingTask=t;i=new WeakMap,Je(PDFDocumentLoadingTask,i,0),exports.PDFDocumentLoadingTask=PDFDocumentLoadingTask;class PDFDataRangeTransport{constructor(e,t,n=!1,i=null){this.length=e,this.initialData=t,this.progressiveDone=n,this.contentDispositionFilename=i,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=new _util.PromiseCapability}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(let n of this._rangeListeners)n(e,t)}onDataProgress(e,t){this._readyCapability.promise.then((()=>{for(let n of this._progressListeners)n(e,t)}))}onDataProgressiveRead(e){this._readyCapability.promise.then((()=>{for(let t of this._progressiveReadListeners)t(e)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(let e of this._progressiveDoneListeners)e()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){(0,_util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}exports.PDFDataRangeTransport=PDFDataRangeTransport;class PDFDocumentProxy{constructor(e,t){this._pdfInfo=e,this._transport=t}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return(0,_util.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJavaScript(){return this._transport.getJavaScript()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig(){return this._transport.getOptionalContentConfig()}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}exports.PDFDocumentProxy=PDFDocumentProxy;class PDFPageProxy{constructor(t,i,s,o=!1){Je(this,r),Je(this,a),Je(this,e,null),Je(this,n,!1),this._pageIndex=t,this._pageInfo=i,this._transport=s,this._stats=o?new _display_utils.StatTimer:null,this._pdfBug=o,this.commonObjs=s.commonObjs,this.objs=new PDFObjects,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:n=0,offsetY:i=0,dontFlip:r=!1}={}){return new _display_utils.PageViewport({viewBox:this.view,scale:e,rotation:t,offsetX:n,offsetY:i,dontFlip:r})}getAnnotations({intent:e="display"}={}){let t=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t.renderingIntent)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return(0,_util.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}getXfa(){return ft(this,null,(function*(){var e;return(null==(e=this._transport._htmlForXfa)?void 0:e.children[this._pageIndex])||null}))}render({canvasContext:e,viewport:t,intent:i="display",annotationMode:s=_util.AnnotationMode.ENABLE,transform:o=null,background:l=null,optionalContentConfigPromise:h=null,annotationCanvasMap:c=null,pageColors:u=null,printAnnotationStorage:d=null}){var p,f;null==(p=this._stats)||p.time("Overall");let m=this._transport.getRenderingIntent(i,s,d);St(this,n,!1),dt(this,a,H2).call(this),h||(h=this._transport.getOptionalContentConfig());let g=this._intentStates.get(m.cacheKey);g||(g=Object.create(null),this._intentStates.set(m.cacheKey,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);let v=!!(m.renderingIntent&_util.RenderingIntentFlag.PRINT);g.displayReadyCapability||(g.displayReadyCapability=new _util.PromiseCapability,g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(f=this._stats)||f.time("Page Request"),this._pumpOperatorList(m));let y=e=>{var t,i;g.renderTasks.delete(x),(this._maybeCleanupAfterRender||v)&&St(this,n,!0),dt(this,r,$y).call(this,!v),e?(x.capability.reject(e),this._abortOperatorList({intentState:g,reason:e instanceof Error?e:new Error(e)})):x.capability.resolve(),null==(t=this._stats)||t.timeEnd("Rendering"),null==(i=this._stats)||i.timeEnd("Overall")},x=new InternalRenderTask({callback:y,params:{canvasContext:e,viewport:t,transform:o,background:l},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:u});(g.renderTasks||(g.renderTasks=new Set)).add(x);let b=x.task;return Promise.all([g.displayReadyCapability.promise,h]).then((([e,t])=>{var n;this.destroyed?y():(null==(n=this._stats)||n.time("Rendering"),x.initializeGraphics({transparency:e,optionalContentConfig:t}),x.operatorListChanged())})).catch(y),b}getOperatorList({intent:e="display",annotationMode:t=_util.AnnotationMode.ENABLE,printAnnotationStorage:n=null}={}){var i;let r,a=this._transport.getRenderingIntent(e,t,n,!0),s=this._intentStates.get(a.cacheKey);return s||(s=Object.create(null),this._intentStates.set(a.cacheKey,s)),s.opListReadCapability||(r=Object.create(null),r.operatorListChanged=function(){s.operatorList.lastChunk&&(s.opListReadCapability.resolve(s.operatorList),s.renderTasks.delete(r))},s.opListReadCapability=new _util.PromiseCapability,(s.renderTasks||(s.renderTasks=new Set)).add(r),s.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(i=this._stats)||i.time("Page Request"),this._pumpOperatorList(a)),s.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===e,disableNormalization:!0===t},{highWaterMark:100,size:e=>e.items.length})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then((e=>_xfa_text.XfaText.textContent(e)));let t=this.streamTextContent(e);return new Promise((function(e,n){let i=t.getReader(),r={items:[],styles:Object.create(null)};!function t(){i.read().then((function({value:n,done:i}){i?e(r):(Object.assign(r.styles,n.styles),r.items.push(...n.items),t())}),n)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let e=[];for(let t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0}),!t.opListReadCapability)for(let n of t.renderTasks)e.push(n.completed),n.cancel();return this.objs.clear(),St(this,n,!1),dt(this,a,H2).call(this),Promise.all(e)}cleanup(e=!1){St(this,n,!0);let t=dt(this,r,$y).call(this,!1);return e&&t&&this._stats&&(this._stats=new _display_utils.StatTimer),t}_startRenderPage(e,t){var n,i;let r=this._intentStates.get(t);r&&(null==(n=this._stats)||n.timeEnd("Page Request"),null==(i=r.displayReadyCapability)||i.resolve(e))}_renderPageChunk(e,t){for(let n=0,i=e.length;n{s.read().then((({value:e,done:t})=>{t?o.streamReader=null:this._transport.destroyed||(this._renderPageChunk(e,o),l())}),(e=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(let e of o.renderTasks)e.operatorListChanged();dt(this,r,$y).call(this,!0)}if(o.displayReadyCapability)o.displayReadyCapability.reject(e);else{if(!o.opListReadCapability)throw e;o.opListReadCapability.reject(e)}}}))};l()}_abortOperatorList({intentState:e,reason:t,force:n=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!n){if(e.renderTasks.size>0)return;if(t instanceof _display_utils.RenderingCancelledException){let n=RENDERING_CANCELLED_TIMEOUT;return t.extraDelay>0&&t.extraDelay<1e3&&(n+=t.extraDelay),void(e.streamReaderCancelTimeout=setTimeout((()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})}),n))}}if(e.streamReader.cancel(new _util.AbortException(t.message)).catch((()=>{})),e.streamReader=null,!this._transport.destroyed){for(let[t,n]of this._intentStates)if(n===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}}e=new WeakMap,n=new WeakMap,r=new WeakSet,$y=function(t=!1){if(dt(this,a,H2).call(this),!ce(this,n)||this.destroyed)return!1;if(t)return St(this,e,setTimeout((()=>{St(this,e,null),dt(this,r,$y).call(this,!1)}),DELAYED_CLEANUP_TIMEOUT)),!1;for(let{renderTasks:e,operatorList:n}of this._intentStates.values())if(e.size>0||!n.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),St(this,n,!1),!0},a=new WeakSet,H2=function(){ce(this,e)&&(clearTimeout(ce(this,e)),St(this,e,null))},exports.PDFPageProxy=PDFPageProxy;class LoopbackPort{constructor(){Je(this,l,new Set),Je(this,c,Promise.resolve())}postMessage(e,t){let n={data:structuredClone(e,t?{transfer:t}:null)};ce(this,c).then((()=>{for(let e of ce(this,l))e.call(this,n)}))}addEventListener(e,t){ce(this,l).add(t)}removeEventListener(e,t){ce(this,l).delete(t)}terminate(){ce(this,l).clear()}}l=new WeakMap,c=new WeakMap,exports.LoopbackPort=LoopbackPort;let PDFWorkerUtil={isWorkerDisabled:!1,fallbackWorkerSrc:null,fakeWorkerId:0};if(exports.PDFWorkerUtil=PDFWorkerUtil,_is_node.isNodeJS&&"function"==typeof o3)PDFWorkerUtil.isWorkerDisabled=!0,PDFWorkerUtil.fallbackWorkerSrc="./pdf.worker.js";else if("object"==typeof document){let e=null==(u=null==document?void 0:document.currentScript)?void 0:u.src;e&&(PDFWorkerUtil.fallbackWorkerSrc=e.replace(/(\.(?:min\.)?js)(\?.*)?$/i,".worker$1$2"))}PDFWorkerUtil.isSameOrigin=function(e,t){let n;try{if(n=new URL(e),!n.origin||"null"===n.origin)return!1}catch(e){return!1}let i=new URL(t,n);return n.origin===i.origin},PDFWorkerUtil.createCDNWrapper=function(e){let t=`importScripts("${e}");`;return URL.createObjectURL(new Blob([t]))};let _PDFWorker=class{constructor({name:e=null,port:t=null,verbosity:n=(0,_util.getVerbosityLevel)()}={}){if(t&&ce(_PDFWorker,h).has(t))throw new Error("Cannot use more than one PDFWorker per port.");if(this.name=e,this.destroyed=!1,this.verbosity=n,this._readyCapability=new _util.PromiseCapability,this._port=null,this._webWorker=null,this._messageHandler=null,t)return ce(_PDFWorker,h).set(t,this),void this._initializeFromPort(t);this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e,this._messageHandler=new _message_handler.MessageHandler("main","worker",e),this._messageHandler.on("ready",(function(){})),this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}_initialize(){if(!PDFWorkerUtil.isWorkerDisabled&&!_PDFWorker._mainThreadWorkerMessageHandler){let{workerSrc:t}=_PDFWorker;try{PDFWorkerUtil.isSameOrigin(window.location.href,t)||(t=PDFWorkerUtil.createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t),n=new _message_handler.MessageHandler("main","worker",e),i=()=>{e.removeEventListener("error",r),n.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},r=()=>{this._webWorker||i()};e.addEventListener("error",r),n.on("test",(t=>{e.removeEventListener("error",r),this.destroyed?i():t?(this._messageHandler=n,this._port=e,this._webWorker=e,this._readyCapability.resolve(),n.send("configure",{verbosity:this.verbosity})):(this._setupFakeWorker(),n.destroy(),e.terminate())})),n.on("ready",(t=>{if(e.removeEventListener("error",r),this.destroyed)i();else try{a()}catch(t){this._setupFakeWorker()}}));let a=()=>{let e=new Uint8Array;n.send("test",e,[e.buffer])};return void a()}catch(e){(0,_util.info)("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){PDFWorkerUtil.isWorkerDisabled||((0,_util.warn)("Setting up fake worker."),PDFWorkerUtil.isWorkerDisabled=!0),_PDFWorker._setupFakeWorkerGlobal.then((e=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));let t=new LoopbackPort;this._port=t;let n="fake"+PDFWorkerUtil.fakeWorkerId++,i=new _message_handler.MessageHandler(n+"_worker",n,t);e.setup(i,t);let r=new _message_handler.MessageHandler(n,n+"_worker",t);this._messageHandler=r,this._readyCapability.resolve(),r.send("configure",{verbosity:this.verbosity})})).catch((e=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${e.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),ce(_PDFWorker,h).delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(e){if(null==e||!e.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return ce(this,h).has(e.port)?ce(this,h).get(e.port):new _PDFWorker(e)}static get workerSrc(){if(_worker_options.GlobalWorkerOptions.workerSrc)return _worker_options.GlobalWorkerOptions.workerSrc;if(null!==PDFWorkerUtil.fallbackWorkerSrc)return _is_node.isNodeJS||(0,_display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.'),PDFWorkerUtil.fallbackWorkerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _mainThreadWorkerMessageHandler(){var e;try{return(null==(e=globalThis.pdfjsWorker)?void 0:e.WorkerMessageHandler)||null}catch(e){return null}}static get _setupFakeWorkerGlobal(){let loader=()=>ft(this,null,(function*(){let mainWorkerMessageHandler=this._mainThreadWorkerMessageHandler;if(mainWorkerMessageHandler)return mainWorkerMessageHandler;if(_is_node.isNodeJS&&"function"==typeof o3){let worker=eval("require")(this.workerSrc);return worker.WorkerMessageHandler}return yield(0,_display_utils.loadScript)(this.workerSrc),window.pdfjsWorker.WorkerMessageHandler}));return(0,_util.shadow)(this,"_setupFakeWorkerGlobal",loader())}},PDFWorker=_PDFWorker;h=new WeakMap,Je(PDFWorker,h,new WeakMap),exports.PDFWorker=PDFWorker;class WorkerTransport{constructor(e,t,n,i,r){Je(this,g),Je(this,d,new Map),Je(this,f,new Map),Je(this,p,new Map),this.messageHandler=e,this.loadingTask=t,this.commonObjs=new PDFObjects,this.fontLoader=new _font_loader.FontLoader({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._passwordCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=new _util.PromiseCapability,this.setupMessageHandler()}get annotationStorage(){return(0,_util.shadow)(this,"annotationStorage",new _annotation_storage.AnnotationStorage)}getRenderingIntent(e,t=_util.AnnotationMode.ENABLE,n=null,i=!1){let r=_util.RenderingIntentFlag.DISPLAY,a=_annotation_storage.SerializableEmpty;switch(e){case"any":r=_util.RenderingIntentFlag.ANY;break;case"display":break;case"print":r=_util.RenderingIntentFlag.PRINT;break;default:(0,_util.warn)(`getRenderingIntent - invalid intent: ${e}`)}switch(t){case _util.AnnotationMode.DISABLE:r+=_util.RenderingIntentFlag.ANNOTATIONS_DISABLE;break;case _util.AnnotationMode.ENABLE:break;case _util.AnnotationMode.ENABLE_FORMS:r+=_util.RenderingIntentFlag.ANNOTATIONS_FORMS;break;case _util.AnnotationMode.ENABLE_STORAGE:r+=_util.RenderingIntentFlag.ANNOTATIONS_STORAGE,a=(r&_util.RenderingIntentFlag.PRINT&&n instanceof _annotation_storage.PrintAnnotationStorage?n:this.annotationStorage).serializable;break;default:(0,_util.warn)(`getRenderingIntent - invalid annotationMode: ${t}`)}return i&&(r+=_util.RenderingIntentFlag.OPLIST),{renderingIntent:r,cacheKey:`${r}_${a.hash}`,annotationStorageSerializable:a}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=new _util.PromiseCapability,this._passwordCapability&&this._passwordCapability.reject(new Error("Worker was destroyed during onPassword callback"));let e=[];for(let n of ce(this,f).values())e.push(n._destroy());ce(this,f).clear(),ce(this,p).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let t=this.messageHandler.sendWithPromise("Terminate",null);return e.push(t),Promise.all(e).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),ce(this,d).clear(),this.filterFactory.destroy(),this._networkStream&&this._networkStream.cancelAllRequests(new _util.AbortException("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:e,loadingTask:t}=this;e.on("GetReader",((e,t)=>{(0,_util.assert)(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=e=>{this._lastProgress={loaded:e.loaded,total:e.total}},t.onPull=()=>{this._fullReader.read().then((function({value:e,done:n}){n?t.close():((0,_util.assert)(e instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),t.enqueue(new Uint8Array(e),1,[e]))})).catch((e=>{t.error(e)}))},t.onCancel=e=>{this._fullReader.cancel(e),t.ready.catch((e=>{if(!this.destroyed)throw e}))}})),e.on("ReaderHeadersReady",(e=>{let n=new _util.PromiseCapability,i=this._fullReader;return i.headersReady.then((()=>{var e;(!i.isStreamingSupported||!i.isRangeSupported)&&(this._lastProgress&&(null==(e=t.onProgress)||e.call(t,this._lastProgress)),i.onProgress=e=>{var n;null==(n=t.onProgress)||n.call(t,{loaded:e.loaded,total:e.total})}),n.resolve({isStreamingSupported:i.isStreamingSupported,isRangeSupported:i.isRangeSupported,contentLength:i.contentLength})}),n.reject),n.promise})),e.on("GetRangeReader",((e,t)=>{(0,_util.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let n=this._networkStream.getRangeReader(e.begin,e.end);n?(t.onPull=()=>{n.read().then((function({value:e,done:n}){n?t.close():((0,_util.assert)(e instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),t.enqueue(new Uint8Array(e),1,[e]))})).catch((e=>{t.error(e)}))},t.onCancel=e=>{n.cancel(e),t.ready.catch((e=>{if(!this.destroyed)throw e}))}):t.close()})),e.on("GetDoc",(({pdfInfo:e})=>{this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,t._capability.resolve(new PDFDocumentProxy(e,this))})),e.on("DocException",(function(e){let n;switch(e.name){case"PasswordException":n=new _util.PasswordException(e.message,e.code);break;case"InvalidPDFException":n=new _util.InvalidPDFException(e.message);break;case"MissingPDFException":n=new _util.MissingPDFException(e.message);break;case"UnexpectedResponseException":n=new _util.UnexpectedResponseException(e.message,e.status);break;case"UnknownErrorException":n=new _util.UnknownErrorException(e.message,e.details);break;default:(0,_util.unreachable)("DocException - expected a valid Error.")}t._capability.reject(n)})),e.on("PasswordRequest",(e=>{if(this._passwordCapability=new _util.PromiseCapability,t.onPassword){let n=e=>{e instanceof Error?this._passwordCapability.reject(e):this._passwordCapability.resolve({password:e})};try{t.onPassword(n,e.code)}catch(e){this._passwordCapability.reject(e)}}else this._passwordCapability.reject(new _util.PasswordException(e.message,e.code));return this._passwordCapability.promise})),e.on("DataLoaded",(e=>{var n;null==(n=t.onProgress)||n.call(t,{loaded:e.length,total:e.length}),this.downloadInfoCapability.resolve(e)})),e.on("StartRenderPage",(e=>{this.destroyed||ce(this,f).get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)})),e.on("commonobj",(([t,n,i])=>{var r;if(!this.destroyed&&!this.commonObjs.has(t))switch(n){case"Font":let a=this._params;if("error"in i){let e=i.error;(0,_util.warn)(`Error during font loading: ${e}`),this.commonObjs.resolve(t,e);break}let s=a.pdfBug&&null!=(r=globalThis.FontInspector)&&r.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null,o=new _font_loader.FontFaceObject(i,{isEvalSupported:a.isEvalSupported,disableFontFace:a.disableFontFace,ignoreErrors:a.ignoreErrors,inspectFont:s});this.fontLoader.bind(o).catch((n=>e.sendWithPromise("FontFallback",{id:t}))).finally((()=>{!a.fontExtraProperties&&o.data&&(o.data=null),this.commonObjs.resolve(t,o)}));break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(t,i);break;default:throw new Error(`Got unknown common object type ${n}`)}})),e.on("obj",(([e,t,n,i])=>{var r;if(this.destroyed)return;let a=ce(this,f).get(t);if(!a.objs.has(e))switch(n){case"Image":if(a.objs.resolve(e,i),i){let e;if(i.bitmap){let{width:t,height:n}=i;e=t*n*4}else e=(null==(r=i.data)?void 0:r.length)||0;e>_util.MAX_IMAGE_SIZE_TO_CACHE&&(a._maybeCleanupAfterRender=!0)}break;case"Pattern":a.objs.resolve(e,i);break;default:throw new Error(`Got unknown object type ${n}`)}})),e.on("DocProgress",(e=>{var n;this.destroyed||null==(n=t.onProgress)||n.call(t,{loaded:e.loaded,total:e.total})})),e.on("FetchBuiltInCMap",(e=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(e):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.")))),e.on("FetchStandardFontData",(e=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(e):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."))))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var e,t;this.annotationStorage.size<=0&&(0,_util.warn)("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:n,transfers:i}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:n,filename:null!=(t=null==(e=this._fullReader)?void 0:e.filename)?t:null},i).finally((()=>{this.annotationStorage.resetModified()}))}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request."));let t=e-1,n=ce(this,p).get(t);if(n)return n;let i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then((e=>{if(this.destroyed)throw new Error("Transport destroyed");let n=new PDFPageProxy(t,e,this,this._params.pdfBug);return ce(this,f).set(t,n),n}));return ce(this,p).set(t,i),i}getPageIndex(e){return"object"!=typeof e||null===e||!Number.isInteger(e.num)||e.num<0||!Number.isInteger(e.gen)||e.gen<0?Promise.reject(new Error("Invalid pageIndex request.")):this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen})}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:t})}getFieldObjects(){return dt(this,g,_V).call(this,"GetFieldObjects")}hasJSActions(){return dt(this,g,_V).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return"string"!=typeof e?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getJavaScript(){return this.messageHandler.sendWithPromise("GetJavaScript",null)}getDocJSActions(){return this.messageHandler.sendWithPromise("GetDocJSActions",null)}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(){return this.messageHandler.sendWithPromise("GetOptionalContentConfig",null).then((e=>new _optional_content_config.OptionalContentConfig(e)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let e="GetMetadata",t=ce(this,d).get(e);if(t)return t;let n=this.messageHandler.sendWithPromise(e,null).then((e=>{var t,n,i,r;return{info:e[0],metadata:e[1]?new _metadata.Metadata(e[1]):null,contentDispositionFilename:null!=(n=null==(t=this._fullReader)?void 0:t.filename)?n:null,contentLength:null!=(r=null==(i=this._fullReader)?void 0:i.contentLength)?r:null}}));return ce(this,d).set(e,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}startCleanup(e=!1){return ft(this,null,(function*(){if(!this.destroyed){yield this.messageHandler.sendWithPromise("Cleanup",null);for(let e of ce(this,f).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),ce(this,d).clear(),this.filterFactory.destroy(!0)}}))}get loadingParams(){let{disableAutoFetch:e,enableXfa:t}=this._params;return(0,_util.shadow)(this,"loadingParams",{disableAutoFetch:e,enableXfa:t})}}d=new WeakMap,f=new WeakMap,p=new WeakMap,g=new WeakSet,_V=function(e,t=null){let n=ce(this,d).get(e);if(n)return n;let i=this.messageHandler.sendWithPromise(e,t);return ce(this,d).set(e,i),i};class PDFObjects{constructor(){Je(this,E),Je(this,v,Object.create(null))}get(e,t=null){if(t){let n=dt(this,E,TV).call(this,e);return n.capability.promise.then((()=>t(n.data))),null}let n=ce(this,v)[e];if(null==n||!n.capability.settled)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return n.data}has(e){let t=ce(this,v)[e];return(null==t?void 0:t.capability.settled)||!1}resolve(e,t=null){let n=dt(this,E,TV).call(this,e);n.data=t,n.capability.resolve()}clear(){var e;for(let t in ce(this,v)){let{data:n}=ce(this,v)[t];null==(e=null==n?void 0:n.bitmap)||e.close()}St(this,v,Object.create(null))}}v=new WeakMap,E=new WeakSet,TV=function(e){return ce(this,v)[e]||(ce(this,v)[e]={capability:new _util.PromiseCapability,data:null})};class RenderTask{constructor(e){Je(this,_,null),St(this,_,e),this.onContinue=null}get promise(){return ce(this,_).capability.promise}cancel(e=0){ce(this,_).cancel(null,e)}get separateAnnots(){let{separateAnnots:e}=ce(this,_).operatorList;if(!e)return!1;let{annotationCanvasMap:t}=ce(this,_);return e.form||e.canvas&&(null==t?void 0:t.size)>0}}_=new WeakMap,exports.RenderTask=RenderTask;let M=class{constructor({callback:e,params:t,objs:n,commonObjs:i,annotationCanvasMap:r,operatorList:a,pageIndex:s,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:c=!1,pageColors:u=null}){this.callback=e,this.params=t,this.objs=n,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=s,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=c,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"undefined"!=typeof window,this.cancelled=!1,this.capability=new _util.PromiseCapability,this.task=new RenderTask(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=t.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){var n,i;if(this.cancelled)return;if(this._canvas){if(ce(M,R).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");ce(M,R).add(this._canvas)}this._pdfBug&&null!=(n=globalThis.StepperManager)&&n.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{canvasContext:r,viewport:a,transform:s,background:o}=this.params;this.gfx=new _canvas.CanvasGraphics(r,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:s,viewport:a,transparency:e,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,null==(i=this.graphicsReadyCallback)||i.call(this)}cancel(e=null,t=0){var n;this.running=!1,this.cancelled=!0,null==(n=this.gfx)||n.endDrawing(),this._canvas&&ce(M,R).delete(this._canvas),this.callback(e||new _display_utils.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,t))}operatorListChanged(){var e;this.graphicsReady?(null==(e=this.stepper)||e.updateOperatorList(this.operatorList),!this.running&&this._continue()):this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound)}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?window.requestAnimationFrame((()=>{this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}_next(){return ft(this,null,(function*(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(this.pageColors),this._canvas&&ce(M,R).delete(this._canvas),this.callback())))}))}},InternalRenderTask=M;R=new WeakMap,Je(InternalRenderTask,R,new WeakSet);let version="3.8.162";exports.version=version;let build="2c74323e3";exports.build=build},(e,t,n)=>{var i,r,a,s,o;Object.defineProperty(t,"__esModule",{value:!0}),t.SerializableEmpty=t.PrintAnnotationStorage=t.AnnotationStorage=void 0;var l=n(1),h=n(4),c=n(8);let u=Object.freeze({map:null,hash:"",transfers:void 0});t.SerializableEmpty=u;class d{constructor(){Je(this,a),Je(this,i,!1),Je(this,r,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){let n=ce(this,r).get(e);return void 0===n?t:Object.assign(t,n)}getRawValue(e){return ce(this,r).get(e)}remove(e){if(ce(this,r).delete(e),0===ce(this,r).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(let e of ce(this,r).values())if(e instanceof h.AnnotationEditor)return;this.onAnnotationEditor(null)}}setValue(e,t){let n=ce(this,r).get(e),i=!1;if(void 0!==n)for(let[r,a]of Object.entries(t))n[r]!==a&&(i=!0,n[r]=a);else i=!0,ce(this,r).set(e,t);i&&dt(this,a,s).call(this),t instanceof h.AnnotationEditor&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(t.constructor._type)}has(e){return ce(this,r).has(e)}getAll(){return ce(this,r).size>0?(0,l.objectFromMap)(ce(this,r)):null}setAll(e){for(let[t,n]of Object.entries(e))this.setValue(t,n)}get size(){return ce(this,r).size}resetModified(){ce(this,i)&&(St(this,i,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new p(this)}get serializable(){if(0===ce(this,r).size)return u;let e=new Map,t=new c.MurmurHash3_64,n=[];for(let[i,a]of ce(this,r)){let r=a instanceof h.AnnotationEditor?a.serialize():a;r&&(e.set(i,r),t.update(`${i}:${JSON.stringify(r)}`),r.bitmap&&n.push(r.bitmap))}return e.size>0?{map:e,hash:t.hexdigest(),transfers:n}:u}}i=new WeakMap,r=new WeakMap,a=new WeakSet,s=function(){ce(this,i)||(St(this,i,!0),"function"==typeof this.onSetModified&&this.onSetModified())},t.AnnotationStorage=d;class p extends d{constructor(e){super(),Je(this,o,void 0);let{map:t,hash:n,transfers:i}=e.serializable,r=structuredClone(t,i?{transfer:i}:null);St(this,o,{map:r,hash:n,transfers:i})}get print(){(0,l.unreachable)("Should not call PrintAnnotationStorage.print")}get serializable(){return ce(this,o)}}o=new WeakMap,t.PrintAnnotationStorage=p},(e,t,n)=>{var i,r,a,s,o,l;Object.defineProperty(t,"__esModule",{value:!0}),t.AnnotationEditor=void 0;var h=n(5),c=n(1);let u=class{constructor(e){Je(this,i,this.focusin.bind(this)),Je(this,r,this.focusout.bind(this)),Je(this,a,!1),Je(this,s,!1),Je(this,o,!1),Xi(this,"_uiManager",null),Je(this,l,u._zIndex++),this.constructor===u&&(0,c.unreachable)("Cannot initialize AnnotationEditor."),this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null;let{rotation:t,rawDims:{pageWidth:n,pageHeight:h,pageX:d,pageY:p}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,h],this.pageTranslation=[d,p];let[f,m]=this.parentDimensions;this.x=e.x/f,this.y=e.y/m,this.isAttachedToDOM=!1,this.deleted=!1}static get _defaultLineColor(){return(0,c.shadow)(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){let t=new p({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=ce(this,l)}setParent(e){null!==e&&(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions),this.parent=e}focusin(e){ce(this,a)?St(this,a,!1):this.parent.setSelected(this)}focusout(e){var t;if(!this.isAttachedToDOM)return;let n=e.relatedTarget;null!=n&&n.closest(`#${this.id}`)||(e.preventDefault(),null!=(t=this.parent)&&t.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}dragstart(e){let t=this.parent.div.getBoundingClientRect();this.startX=e.clientX-t.x,this.startY=e.clientY-t.y,e.dataTransfer.setData("text/plain",this.id),e.dataTransfer.effectAllowed="move"}setAt(e,t,n,i){let[r,a]=this.parentDimensions;[n,i]=this.screenToPageTranslation(n,i),this.x=(e+n)/r,this.y=(t+i)/a,this.div.style.left=100*this.x+"%",this.div.style.top=100*this.y+"%"}translate(e,t){let[n,i]=this.parentDimensions;[e,t]=this.screenToPageTranslation(e,t),this.x+=e/n,this.y+=t/i,this.div.style.left=100*this.x+"%",this.div.style.top=100*this.y+"%"}screenToPageTranslation(e,t){switch(this.parentRotation){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{realScale:e}=this._uiManager.viewParameters,[t,n]=this.pageDimensions;return[t*e,n*e]}setDims(e,t){let[n,i]=this.parentDimensions;this.div.style.width=100*e/n+"%",this.div.style.height=100*t/i+"%"}fixDims(){let{style:e}=this.div,{height:t,width:n}=e,i=n.endsWith("%"),r=t.endsWith("%");if(i&&r)return;let[a,s]=this.parentDimensions;i||(e.width=100*parseFloat(n)/a+"%"),r||(e.height=100*parseFloat(t)/s+"%")}getInitialTranslation(){return[0,0]}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.setAttribute("tabIndex",0),this.setInForeground(),this.div.addEventListener("focusin",ce(this,i)),this.div.addEventListener("focusout",ce(this,r));let[e,t]=this.getInitialTranslation();return this.translate(e,t),(0,h.bindEvents)(this,this.div,["dragstart","pointerdown"]),this.div}pointerdown(e){let{isMac:t}=c.FeatureTest.platform;0!==e.button||e.ctrlKey&&t?e.preventDefault():(e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this),St(this,a,!0))}getRect(e,t){let n=this.parentScale,[i,r]=this.pageDimensions,[a,s]=this.pageTranslation,o=e/n,l=t/n,h=this.x*i,c=this.y*r,u=this.width*i,d=this.height*r;switch(this.rotation){case 0:return[h+o+a,r-c-l-d+s,h+o+u+a,r-c-l+s];case 90:return[h+l+a,r-c+o+s,h+l+d+a,r-c+o+u+s];case 180:return[h-o-u+a,r-c+l+s,h-o+a,r-c+l+d+s];case 270:return[h-l-d+a,r-c-o-u+s,h-l+a,r-c-o+s];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,t){let[n,i,r,a]=e,s=r-n,o=a-i;switch(this.rotation){case 0:return[n,t-a,s,o];case 90:return[n,t-i,o,s];case 180:return[r,t-i,s,o];case 270:return[r,t-a,o,s];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){St(this,o,!0)}disableEditMode(){St(this,o,!1)}isInEditMode(){return ce(this,o)}shouldGetKeyboardEvents(){return!1}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){var e,t;null==(e=this.div)||e.addEventListener("focusin",ce(this,i)),null==(t=this.div)||t.addEventListener("focusout",ce(this,r))}serialize(e=!1){(0,c.unreachable)("An editor must be serializable")}static deserialize(e,t,n){let i=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:n});i.rotation=e.rotation;let[r,a]=i.pageDimensions,[s,o,l,h]=i.getRectInCurrentCoords(e.rect,a);return i.x=s/r,i.y=o/a,i.width=l/r,i.height=h/a,i}remove(){this.div.removeEventListener("focusin",ce(this,i)),this.div.removeEventListener("focusout",ce(this,r)),this.isEmpty()||this.commit(),this.parent.remove(this)}select(){var e;null==(e=this.div)||e.classList.add("selectedEditor")}unselect(){var e;null==(e=this.div)||e.classList.remove("selectedEditor")}updateParams(e,t){}disableEditing(){}enableEditing(){}get propertiesToUpdate(){return{}}get contentDiv(){return this.div}get isEditing(){return ce(this,s)}set isEditing(e){St(this,s,e),e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null)}},d=u;i=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap,Xi(d,"_colorManager",new h.ColorManager),Xi(d,"_zIndex",1),t.AnnotationEditor=d;class p extends d{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}},(e,t,n)=>{var i,r,a,s,o,l,h,c,u,d,p,f,m,g,v,y,x,b,_,w,S,M,T,E,A,C,P,R,O,L,I,D,k,N,F,U,B,z,H,V,j,G,W,X,Y,q,J,Z,K,$,Q,ee,te;Object.defineProperty(t,"__esModule",{value:!0}),t.KeyboardManager=t.CommandManager=t.ColorManager=t.AnnotationEditorUIManager=void 0,t.bindEvents=function(e,t,n){for(let i of n)t.addEventListener(i,e[i].bind(e))},t.opacityToHex=function(e){return Math.round(Math.min(255,Math.max(1,255*e))).toString(16).padStart(2,"0")};var ne=n(1),ie=n(6);class re{constructor(){Je(this,i,0)}getId(){return`${ne.AnnotationEditorPrefix}${NT(this,i)._++}`}}i=new WeakMap;class ae{constructor(e=128){Je(this,r,[]),Je(this,a,!1),Je(this,s,void 0),Je(this,o,-1),St(this,s,e)}add({cmd:e,undo:t,mustExec:n,type:i=NaN,overwriteIfSameType:l=!1,keepUndo:h=!1}){if(n&&e(),ce(this,a))return;let c={cmd:e,undo:t,type:i};if(-1===ce(this,o))return ce(this,r).length>0&&(ce(this,r).length=0),St(this,o,0),void ce(this,r).push(c);if(l&&ce(this,r)[ce(this,o)].type===i)return h&&(c.undo=ce(this,r)[ce(this,o)].undo),void(ce(this,r)[ce(this,o)]=c);let u=ce(this,o)+1;u===ce(this,s)?ce(this,r).splice(0,1):(St(this,o,u),ue===t[n])))return oe._colorsMapping.get(n);return t}getHexCode(e){let t=this._colors.get(e);return t?ne.Util.makeHexColor(...t):e}},le=oe;Xi(le,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]])),t.ColorManager=le;let he=class{constructor(e,t,n){Je(this,D),Je(this,N),Je(this,U),Je(this,z),Je(this,V),Je(this,G),Je(this,X),Je(this,q),Je(this,Z),Je(this,$),Je(this,ee),Je(this,c,null),Je(this,u,new Map),Je(this,d,new Map),Je(this,p,null),Je(this,f,new ae),Je(this,m,0),Je(this,g,new Set),Je(this,v,null),Je(this,y,new Set),Je(this,x,null),Je(this,b,new re),Je(this,_,!1),Je(this,w,ne.AnnotationEditorType.NONE),Je(this,S,new Set),Je(this,M,this.copy.bind(this)),Je(this,T,this.cut.bind(this)),Je(this,E,this.paste.bind(this)),Je(this,A,this.keydown.bind(this)),Je(this,C,this.onEditingAction.bind(this)),Je(this,P,this.onPageChanging.bind(this)),Je(this,R,this.onScaleChanging.bind(this)),Je(this,O,this.onRotationChanging.bind(this)),Je(this,L,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1}),Je(this,I,null),St(this,I,e),St(this,x,t),ce(this,x)._on("editingaction",ce(this,C)),ce(this,x)._on("pagechanging",ce(this,P)),ce(this,x)._on("scalechanging",ce(this,R)),ce(this,x)._on("rotationchanging",ce(this,O)),St(this,p,n),this.viewParameters={realScale:ie.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:0}}static get _keyboardManager(){return(0,ne.shadow)(this,"_keyboardManager",new se([[["ctrl+a","mac+meta+a"],he.prototype.selectAll],[["ctrl+z","mac+meta+z"],he.prototype.undo],[["ctrl+y","ctrl+shift+Z","mac+meta+shift+Z"],he.prototype.redo],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete"],he.prototype.delete],[["Escape","mac+Escape"],he.prototype.unselectAll]]))}destroy(){dt(this,N,F).call(this),ce(this,x)._off("editingaction",ce(this,C)),ce(this,x)._off("pagechanging",ce(this,P)),ce(this,x)._off("scalechanging",ce(this,R)),ce(this,x)._off("rotationchanging",ce(this,O));for(let e of ce(this,d).values())e.destroy();ce(this,d).clear(),ce(this,u).clear(),ce(this,y).clear(),St(this,c,null),ce(this,S).clear(),ce(this,f).destroy()}onPageChanging({pageNumber:e}){St(this,m,e-1)}focusMainContainer(){ce(this,I).focus()}addShouldRescale(e){ce(this,y).add(e)}removeShouldRescale(e){ce(this,y).delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*ie.PixelsPerInch.PDF_TO_CSS_UNITS;for(let t of ce(this,y))t.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}addToAnnotationStorage(e){!e.isEmpty()&&ce(this,p)&&!ce(this,p).has(e.id)&&ce(this,p).setValue(e.id,e)}copy(e){if(e.preventDefault(),ce(this,c)&&ce(this,c).commitOrRemove(),!this.hasSelection)return;let t=[];for(let n of ce(this,S)){let e=n.serialize(!0);e&&t.push(e)}0!==t.length&&e.clipboardData.setData("application/pdfjs",JSON.stringify(t))}cut(e){this.copy(e),this.delete()}paste(e){e.preventDefault();let t=e.clipboardData.getData("application/pdfjs");if(!t)return;try{t=JSON.parse(t)}catch(e){return void(0,ne.warn)(`paste: "${e.message}".`)}if(!Array.isArray(t))return;this.unselectAll();let n=ce(this,d).get(ce(this,m));try{let e=[];for(let a of t){let t=n.deserialize(a);if(!t)return;e.push(t)}let i=()=>{for(let t of e)dt(this,Z,K).call(this,t);dt(this,ee,te).call(this,e)},r=()=>{for(let t of e)t.remove()};this.addCommands({cmd:i,undo:r,mustExec:!0})}catch(e){(0,ne.warn)(`paste: "${e.message}".`)}}keydown(e){var t;null!=(t=this.getActive())&&t.shouldGetKeyboardEvents()||he._keyboardManager.exec(this,e)}onEditingAction(e){["undo","redo","delete","selectAll"].includes(e.name)&&this[e.name]()}setEditingState(e){e?(dt(this,D,k).call(this),dt(this,U,B).call(this),dt(this,V,j).call(this,{isEditing:ce(this,w)!==ne.AnnotationEditorType.NONE,isEmpty:dt(this,$,Q).call(this),hasSomethingToUndo:ce(this,f).hasSomethingToUndo(),hasSomethingToRedo:ce(this,f).hasSomethingToRedo(),hasSelectedEditor:!1})):(dt(this,N,F).call(this),dt(this,z,H).call(this),dt(this,V,j).call(this,{isEditing:!1}))}registerEditorTypes(e){if(!ce(this,v)){St(this,v,e);for(let e of ce(this,v))dt(this,G,W).call(this,e.defaultPropertiesToUpdate)}}getId(){return ce(this,b).getId()}get currentLayer(){return ce(this,d).get(ce(this,m))}get currentPageIndex(){return ce(this,m)}addLayer(e){ce(this,d).set(e.pageIndex,e),ce(this,_)?e.enable():e.disable()}removeLayer(e){ce(this,d).delete(e.pageIndex)}updateMode(e){if(St(this,w,e),e===ne.AnnotationEditorType.NONE)this.setEditingState(!1),dt(this,q,J).call(this);else{this.setEditingState(!0),dt(this,X,Y).call(this);for(let t of ce(this,d).values())t.updateMode(e)}}updateToolbar(e){e!==ce(this,w)&&ce(this,x).dispatch("switchannotationeditormode",{source:this,mode:e})}updateParams(e,t){if(ce(this,v)){for(let n of ce(this,S))n.updateParams(e,t);for(let n of ce(this,v))n.updateDefaultParams(e,t)}}getEditors(e){let t=[];for(let n of ce(this,u).values())n.pageIndex===e&&t.push(n);return t}getEditor(e){return ce(this,u).get(e)}addEditor(e){ce(this,u).set(e.id,e)}removeEditor(e){var t;ce(this,u).delete(e.id),this.unselect(e),(!e.annotationElementId||!ce(this,g).has(e.annotationElementId))&&(null==(t=ce(this,p))||t.remove(e.id))}addDeletedAnnotationElement(e){ce(this,g).add(e.annotationElementId),e.deleted=!0}isDeletedAnnotationElement(e){return ce(this,g).has(e)}removeDeletedAnnotationElement(e){ce(this,g).delete(e.annotationElementId),e.deleted=!1}setActiveEditor(e){ce(this,c)!==e&&(St(this,c,e),e&&dt(this,G,W).call(this,e.propertiesToUpdate))}toggleSelected(e){if(ce(this,S).has(e))return ce(this,S).delete(e),e.unselect(),void dt(this,V,j).call(this,{hasSelectedEditor:this.hasSelection});ce(this,S).add(e),e.select(),dt(this,G,W).call(this,e.propertiesToUpdate),dt(this,V,j).call(this,{hasSelectedEditor:!0})}setSelected(e){for(let t of ce(this,S))t!==e&&t.unselect();ce(this,S).clear(),ce(this,S).add(e),e.select(),dt(this,G,W).call(this,e.propertiesToUpdate),dt(this,V,j).call(this,{hasSelectedEditor:!0})}isSelected(e){return ce(this,S).has(e)}unselect(e){e.unselect(),ce(this,S).delete(e),dt(this,V,j).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==ce(this,S).size}undo(){ce(this,f).undo(),dt(this,V,j).call(this,{hasSomethingToUndo:ce(this,f).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:dt(this,$,Q).call(this)})}redo(){ce(this,f).redo(),dt(this,V,j).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:ce(this,f).hasSomethingToRedo(),isEmpty:dt(this,$,Q).call(this)})}addCommands(e){ce(this,f).add(e),dt(this,V,j).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:dt(this,$,Q).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;let e=[...ce(this,S)];this.addCommands({cmd:()=>{for(let t of e)t.remove()},undo:()=>{for(let t of e)dt(this,Z,K).call(this,t)},mustExec:!0})}commitOrRemove(){var e;null==(e=ce(this,c))||e.commitOrRemove()}selectAll(){for(let e of ce(this,S))e.commit();dt(this,ee,te).call(this,ce(this,u).values())}unselectAll(){if(ce(this,c))ce(this,c).commitOrRemove();else if(0!==ce(this,S).size){for(let e of ce(this,S))e.unselect();ce(this,S).clear(),dt(this,V,j).call(this,{hasSelectedEditor:!1})}}isActive(e){return ce(this,c)===e}getActive(){return ce(this,c)}getMode(){return ce(this,w)}},ue=he;c=new WeakMap,u=new WeakMap,d=new WeakMap,p=new WeakMap,f=new WeakMap,m=new WeakMap,g=new WeakMap,v=new WeakMap,y=new WeakMap,x=new WeakMap,b=new WeakMap,_=new WeakMap,w=new WeakMap,S=new WeakMap,M=new WeakMap,T=new WeakMap,E=new WeakMap,A=new WeakMap,C=new WeakMap,P=new WeakMap,R=new WeakMap,O=new WeakMap,L=new WeakMap,I=new WeakMap,D=new WeakSet,k=function(){ce(this,I).addEventListener("keydown",ce(this,A))},N=new WeakSet,F=function(){ce(this,I).removeEventListener("keydown",ce(this,A))},U=new WeakSet,B=function(){document.addEventListener("copy",ce(this,M)),document.addEventListener("cut",ce(this,T)),document.addEventListener("paste",ce(this,E))},z=new WeakSet,H=function(){document.removeEventListener("copy",ce(this,M)),document.removeEventListener("cut",ce(this,T)),document.removeEventListener("paste",ce(this,E))},V=new WeakSet,j=function(e){Object.entries(e).some((([e,t])=>ce(this,L)[e]!==t))&&ce(this,x).dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(ce(this,L),e)})},G=new WeakSet,W=function(e){ce(this,x).dispatch("annotationeditorparamschanged",{source:this,details:e})},X=new WeakSet,Y=function(){if(!ce(this,_)){St(this,_,!0);for(let e of ce(this,d).values())e.enable()}},q=new WeakSet,J=function(){if(this.unselectAll(),ce(this,_)){St(this,_,!1);for(let e of ce(this,d).values())e.disable()}},Z=new WeakSet,K=function(e){let t=ce(this,d).get(e.pageIndex);t?t.addOrRebuild(e):this.addEditor(e)},$=new WeakSet,Q=function(){if(0===ce(this,u).size)return!0;if(1===ce(this,u).size)for(let e of ce(this,u).values())return e.isEmpty();return!1},ee=new WeakSet,te=function(e){ce(this,S).clear();for(let t of e)t.isEmpty()||(ce(this,S).add(t),t.select());dt(this,V,j).call(this,{hasSelectedEditor:!0})},t.AnnotationEditorUIManager=ue},(e,t,n)=>{var i,r,a,s,o,l,h,c,u,d,p,f,m,g,v,y,x,b,_,w,S,M,T,E,A;Object.defineProperty(t,"__esModule",{value:!0}),t.StatTimer=t.RenderingCancelledException=t.PixelsPerInch=t.PageViewport=t.PDFDateString=t.DOMStandardFontDataFactory=t.DOMSVGFactory=t.DOMFilterFactory=t.DOMCanvasFactory=t.DOMCMapReaderFactory=t.AnnotationPrefix=void 0,t.deprecated=function(e){console.log("Deprecated API usage: "+e)},t.getColorValues=function(e){let t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(let n of e.keys()){t.style.color=n;let i=window.getComputedStyle(t).color;e.set(n,G(i))}t.remove()},t.getCurrentTransform=function(e){let{a:t,b:n,c:i,d:r,e:a,f:s}=e.getTransform();return[t,n,i,r,a,s]},t.getCurrentTransformInverse=function(e){let{a:t,b:n,c:i,d:r,e:a,f:s}=e.getTransform().invertSelf();return[t,n,i,r,a,s]},t.getFilenameFromUrl=function(e,t=!1){return t||([e]=e.split(/[#?]/,1)),e.substring(e.lastIndexOf("/")+1)},t.getPdfFilenameFromUrl=function(e,t="document.pdf"){if("string"!=typeof e)return t;if(V(e))return(0,P.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;let n=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,i=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(e),r=n.exec(i[1])||n.exec(i[2])||n.exec(i[3]);if(r&&(r=r[0],r.includes("%")))try{r=n.exec(decodeURIComponent(r))[0]}catch(e){}return r||t},t.getRGB=G,t.getXfaPageViewport=function(e,{scale:t=1,rotation:n=0}){let{width:i,height:r}=e.attributes.style,a=[0,0,parseInt(i),parseInt(r)];return new z({viewBox:a,scale:t,rotation:n})},t.isDataScheme=V,t.isPdfFile=function(e){return"string"==typeof e&&/\.pdf$/i.test(e)},t.isValidFetchUrl=j,t.loadScript=function(e,t=!1){return new Promise(((n,i)=>{let r=document.createElement("script");r.src=e,r.onload=function(e){t&&r.remove(),n(e)},r.onerror=function(){i(new Error(`Cannot load script at: ${r.src}`))},(document.head||document.documentElement).append(r)}))},t.setLayerDimensions=function(e,t,n=!1,i=!0){if(t instanceof z){let{pageWidth:i,pageHeight:r}=t.rawDims,{style:a}=e,s=`calc(var(--scale-factor) * ${i}px)`,o=`calc(var(--scale-factor) * ${r}px)`;n&&t.rotation%180!=0?(a.width=o,a.height=s):(a.width=s,a.height=o)}i&&e.setAttribute("data-main-rotation",t.rotation)};var C=n(7),P=n(1);let R="http://www.w3.org/2000/svg";t.AnnotationPrefix="pdfjs_internal_id_";let O,L=class{},I=L;Xi(I,"CSS",96),Xi(I,"PDF",72),Xi(I,"PDF_TO_CSS_UNITS",L.CSS/L.PDF),t.PixelsPerInch=I;class D extends C.BaseFilterFactory{constructor({docId:e,ownerDocument:t=globalThis.document}={}){super(),Je(this,f),Je(this,g),Je(this,y),Je(this,b),Je(this,w),Je(this,M),Je(this,E),Je(this,i,void 0),Je(this,r,void 0),Je(this,a,void 0),Je(this,s,void 0),Je(this,o,void 0),Je(this,l,void 0),Je(this,h,void 0),Je(this,c,void 0),Je(this,u,void 0),Je(this,d,void 0),Je(this,p,0),St(this,a,e),St(this,s,t)}addFilter(e){if(!e)return"none";let t,n,i,r,s=ce(this,f,m).get(e);if(s)return s;if(1===e.length){let a=e[0],s=new Array(256);for(let e=0;e<256;e++)s[e]=a[e]/255;r=t=n=i=s.join(",")}else{let[a,s,o]=e,l=new Array(256),h=new Array(256),c=new Array(256);for(let e=0;e<256;e++)l[e]=a[e]/255,h[e]=s[e]/255,c[e]=o[e]/255;t=l.join(","),n=h.join(","),i=c.join(","),r=`${t}${n}${i}`}if(s=ce(this,f,m).get(r),s)return ce(this,f,m).set(e,s),s;let o=`g_${ce(this,a)}_transfer_map_${NT(this,p)._++}`,l=`url(#${o})`;ce(this,f,m).set(e,l),ce(this,f,m).set(r,l);let h=dt(this,b,_).call(this,o);return dt(this,M,T).call(this,t,n,i,h),l}addHCMFilter(e,t){var n;let i=`${e}-${t}`;if(ce(this,l)===i)return ce(this,h);if(St(this,l,i),St(this,h,"none"),null==(n=ce(this,o))||n.remove(),!e||!t)return ce(this,h);let r=dt(this,E,A).call(this,e);e=P.Util.makeHexColor(...r);let s=dt(this,E,A).call(this,t);if(t=P.Util.makeHexColor(...s),ce(this,g,v).style.color="","#000000"===e&&"#ffffff"===t||e===t)return ce(this,h);let u=new Array(256);for(let a=0;a<=255;a++){let e=a/255;u[a]=e<=.03928?e/12.92:Oo((e+.055)/1.055,2.4)}let d=u.join(","),p=`g_${ce(this,a)}_hcm_filter`,f=St(this,c,dt(this,b,_).call(this,p));dt(this,M,T).call(this,d,d,d,f),dt(this,y,x).call(this,f);let m=(e,t)=>{let n=r[e]/255,i=s[e]/255,a=new Array(t+1);for(let r=0;r<=t;r++)a[r]=n+r/t*(i-n);return a.join(",")};return dt(this,M,T).call(this,m(0,5),m(1,5),m(2,5),f),St(this,h,`url(#${p})`),ce(this,h)}addHighlightHCMFilter(e,t,n,i){var r;let s=`${e}-${t}-${n}-${i}`;if(ce(this,u)===s)return ce(this,d);if(St(this,u,s),St(this,d,"none"),null==(r=ce(this,c))||r.remove(),!e||!t)return ce(this,d);let[o,l]=[e,t].map(dt(this,E,A).bind(this)),h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),p=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[f,m]=[n,i].map(dt(this,E,A).bind(this));p{let i=new Array(256),r=(p-h)/n,a=e/255,s=(t-e)/(255*n),o=0;for(let l=0;l<=n;l++){let e=Math.round(h+l*r),t=a+l*s;for(let n=o;n<=e;n++)i[n]=t;o=e+1}for(let l=o;l<256;l++)i[l]=i[o-1];return i.join(",")},S=`g_${ce(this,a)}_hcm_highlight_filter`,C=St(this,c,dt(this,b,_).call(this,S));return dt(this,y,x).call(this,C),dt(this,M,T).call(this,w(f[0],m[0],5),w(f[1],m[1],5),w(f[2],m[2],5),C),St(this,d,`url(#${S})`),ce(this,d)}destroy(e=!1){e&&(ce(this,h)||ce(this,d))||(ce(this,r)&&(ce(this,r).parentNode.parentNode.remove(),St(this,r,null)),ce(this,i)&&(ce(this,i).clear(),St(this,i,null)),St(this,p,0))}}i=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,u=new WeakMap,d=new WeakMap,p=new WeakMap,f=new WeakSet,m=function(){return ce(this,i)||St(this,i,new Map)},g=new WeakSet,v=function(){if(!ce(this,r)){let e=ce(this,s).createElement("div"),{style:t}=e;t.visibility="hidden",t.contain="strict",t.width=t.height=0,t.position="absolute",t.top=t.left=0,t.zIndex=-1;let n=ce(this,s).createElementNS(R,"svg");n.setAttribute("width",0),n.setAttribute("height",0),St(this,r,ce(this,s).createElementNS(R,"defs")),e.append(n),n.append(ce(this,r)),ce(this,s).body.append(e)}return ce(this,r)},y=new WeakSet,x=function(e){let t=ce(this,s).createElementNS(R,"feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(t)},b=new WeakSet,_=function(e){let t=ce(this,s).createElementNS(R,"filter");return t.setAttribute("color-interpolation-filters","sRGB"),t.setAttribute("id",e),ce(this,g,v).append(t),t},w=new WeakSet,S=function(e,t,n){let i=ce(this,s).createElementNS(R,t);i.setAttribute("type","discrete"),i.setAttribute("tableValues",n),e.append(i)},M=new WeakSet,T=function(e,t,n,i){let r=ce(this,s).createElementNS(R,"feComponentTransfer");i.append(r),dt(this,w,S).call(this,r,"feFuncR",e),dt(this,w,S).call(this,r,"feFuncG",t),dt(this,w,S).call(this,r,"feFuncB",n)},E=new WeakSet,A=function(e){return ce(this,g,v).style.color=e,G(getComputedStyle(ce(this,g,v)).getPropertyValue("color"))},t.DOMFilterFactory=D;class k extends C.BaseCanvasFactory{constructor({ownerDocument:e=globalThis.document}={}){super(),this._document=e}_createCanvas(e,t){let n=this._document.createElement("canvas");return n.width=e,n.height=t,n}}function N(e,t=!1){return ft(this,null,(function*(){if(j(e,document.baseURI)){let n=yield fetch(e);if(!n.ok)throw new Error(n.statusText);return t?new Uint8Array(yield n.arrayBuffer()):(0,P.stringToBytes)(yield n.text())}return new Promise(((n,i)=>{let r=new XMLHttpRequest;r.open("GET",e,!0),t&&(r.responseType="arraybuffer"),r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){if(200===r.status||0===r.status){let e;if(t&&r.response?e=new Uint8Array(r.response):!t&&r.responseText&&(e=(0,P.stringToBytes)(r.responseText)),e)return void n(e)}i(new Error(r.statusText))}},r.send(null)}))}))}t.DOMCanvasFactory=k;class F extends C.BaseCMapReaderFactory{_fetchData(e,t){return N(e,this.isCompressed).then((e=>({cMapData:e,compressionType:t})))}}t.DOMCMapReaderFactory=F;class U extends C.BaseStandardFontDataFactory{_fetchData(e){return N(e,!0)}}t.DOMStandardFontDataFactory=U;class B extends C.BaseSVGFactory{_createSVG(e){return document.createElementNS(R,e)}}t.DOMSVGFactory=B;class z{constructor({viewBox:e,scale:t,rotation:n,offsetX:i=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=e,this.scale=t,this.rotation=n,this.offsetX=i,this.offsetY=r;let s,o,l,h,c,u,d,p,f=(e[2]+e[0])/2,m=(e[3]+e[1])/2;switch((n%=360)<0&&(n+=360),n){case 180:s=-1,o=0,l=0,h=1;break;case 90:s=0,o=1,l=1,h=0;break;case 270:s=0,o=-1,l=-1,h=0;break;case 0:s=1,o=0,l=0,h=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(l=-l,h=-h),0===s?(c=Math.abs(m-e[1])*t+i,u=Math.abs(f-e[0])*t+r,d=(e[3]-e[1])*t,p=(e[2]-e[0])*t):(c=Math.abs(f-e[0])*t+i,u=Math.abs(m-e[1])*t+r,d=(e[2]-e[0])*t,p=(e[3]-e[1])*t),this.transform=[s*t,o*t,l*t,h*t,c-s*t*f-l*t*m,u-o*t*f-h*t*m],this.width=d,this.height=p}get rawDims(){let{viewBox:e}=this;return(0,P.shadow)(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:n=this.offsetX,offsetY:i=this.offsetY,dontFlip:r=!1}={}){return new z({viewBox:this.viewBox.slice(),scale:e,rotation:t,offsetX:n,offsetY:i,dontFlip:r})}convertToViewportPoint(e,t){return P.Util.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){let t=P.Util.applyTransform([e[0],e[1]],this.transform),n=P.Util.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],n[0],n[1]]}convertToPdfPoint(e,t){return P.Util.applyInverseTransform([e,t],this.transform)}}t.PageViewport=z;class H extends P.BaseException{constructor(e,t=0){super(e,"RenderingCancelledException"),this.extraDelay=t}}function V(e){let t=e.length,n=0;for(;n>16,(65280&t)>>8,255&t]}return e.startsWith("rgb(")?e.slice(4,-1).split(",").map((e=>parseInt(e))):e.startsWith("rgba(")?e.slice(5,-1).split(",").map((e=>parseInt(e))).slice(0,3):((0,P.warn)(`Not a valid color format: "${e}"`),[0,0,0])}t.RenderingCancelledException=H,t.StatTimer=class{constructor(){Xi(this,"started",Object.create(null)),Xi(this,"times",[])}time(e){e in this.started&&(0,P.warn)(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||(0,P.warn)(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){let e=[],t=0;for(let{name:n}of this.times)t=Math.max(n.length,t);for(let{name:n,start:i,end:r}of this.times)e.push(`${n.padEnd(t)} ${r-i}ms\n`);return e.join("")}},t.PDFDateString=class{static toDateObject(e){if(!e||"string"!=typeof e)return null;O||(O=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));let t=O.exec(e);if(!t)return null;let n=parseInt(t[1],10),i=parseInt(t[2],10);i=i>=1&&i<=12?i-1:0;let r=parseInt(t[3],10);r=r>=1&&r<=31?r:1;let a=parseInt(t[4],10);a=a>=0&&a<=23?a:0;let s=parseInt(t[5],10);s=s>=0&&s<=59?s:0;let o=parseInt(t[6],10);o=o>=0&&o<=59?o:0;let l=t[7]||"Z",h=parseInt(t[8],10);h=h>=0&&h<=23?h:0;let c=parseInt(t[9],10)||0;return c=c>=0&&c<=59?c:0,"-"===l?(a+=h,s+=c):"+"===l&&(a-=h,s-=c),new Date(Date.UTC(n,i,r,a,s,o))}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BaseStandardFontDataFactory=t.BaseSVGFactory=t.BaseFilterFactory=t.BaseCanvasFactory=t.BaseCMapReaderFactory=void 0;var i=n(1);class r{constructor(){this.constructor===r&&(0,i.unreachable)("Cannot initialize BaseFilterFactory.")}addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addHighlightHCMFilter(e,t,n,i){return"none"}destroy(e=!1){}}t.BaseFilterFactory=r;class a{constructor(){this.constructor===a&&(0,i.unreachable)("Cannot initialize BaseCanvasFactory.")}create(e,t){if(e<=0||t<=0)throw new Error("Invalid canvas size");let n=this._createCanvas(e,t);return{canvas:n,context:n.getContext("2d")}}reset(e,t,n){if(!e.canvas)throw new Error("Canvas is not specified");if(t<=0||n<=0)throw new Error("Invalid canvas size");e.canvas.width=t,e.canvas.height=n}destroy(e){if(!e.canvas)throw new Error("Canvas is not specified");e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){(0,i.unreachable)("Abstract method `_createCanvas` called.")}}t.BaseCanvasFactory=a;class s{constructor({baseUrl:e=null,isCompressed:t=!0}){this.constructor===s&&(0,i.unreachable)("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=e,this.isCompressed=t}fetch(e){return ft(this,arguments,(function*({name:e}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!e)throw new Error("CMap name must be specified.");let t=this.baseUrl+e+(this.isCompressed?".bcmap":""),n=this.isCompressed?i.CMapCompressionType.BINARY:i.CMapCompressionType.NONE;return this._fetchData(t,n).catch((e=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${t}`)}))}))}_fetchData(e,t){(0,i.unreachable)("Abstract method `_fetchData` called.")}}t.BaseCMapReaderFactory=s;class o{constructor({baseUrl:e=null}){this.constructor===o&&(0,i.unreachable)("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=e}fetch(e){return ft(this,arguments,(function*({filename:e}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!e)throw new Error("Font filename must be specified.");let t=`${this.baseUrl}${e}`;return this._fetchData(t).catch((e=>{throw new Error(`Unable to load font data at: ${t}`)}))}))}_fetchData(e){(0,i.unreachable)("Abstract method `_fetchData` called.")}}t.BaseStandardFontDataFactory=o;class l{constructor(){this.constructor===l&&(0,i.unreachable)("Cannot initialize BaseSVGFactory.")}create(e,t,n=!1){if(e<=0||t<=0)throw new Error("Invalid SVG dimensions");let i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),n||(i.setAttribute("width",`${e}px`),i.setAttribute("height",`${t}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${e} ${t}`),i}createElement(e){if("string"!=typeof e)throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){(0,i.unreachable)("Abstract method `_createSVG` called.")}}t.BaseSVGFactory=l},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MurmurHash3_64=void 0;var i=n(1);let r=3285377520,a=4294901760,s=65535;t.MurmurHash3_64=class{constructor(e){this.h1=e?4294967295&e:r,this.h2=e?4294967295&e:r}update(e){let t,n;if("string"==typeof e){t=new Uint8Array(2*e.length),n=0;for(let i=0,r=e.length;i>>8,t[n++]=255&r)}}else{if(!(0,i.isArrayBuffer)(e))throw new Error("Wrong data format in MurmurHash3_64_update. Input must be a string or array.");t=e.slice(),n=t.byteLength}let r=n>>2,o=n-4*r,l=new Uint32Array(t.buffer,0,r),h=0,c=0,u=this.h1,d=this.h2,p=3432918353,f=461845907,m=p&s,g=f&s;for(let i=0;i>>17,h=h*f&a|h*g&s,u^=h,u=u<<13|u>>>19,u=5*u+3864292196):(c=l[i],c=c*p&a|c*m&s,c=c<<15|c>>>17,c=c*f&a|c*g&s,d^=c,d=d<<13|d>>>19,d=5*d+3864292196);switch(h=0,o){case 3:h^=t[4*r+2]<<16;case 2:h^=t[4*r+1]<<8;case 1:h^=t[4*r],h=h*p&a|h*m&s,h=h<<15|h>>>17,h=h*f&a|h*g&s,1&r?u^=h:d^=h}this.h1=u,this.h2=d}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=3981806797*e&a|36045*e&s,t=4283543511*t&a|(2950163797*(t<<16|e>>>16)&a)>>>16,e^=t>>>1,e=444984403*e&a|60499*e&s,t=3301882366*t&a|(3120437893*(t<<16|e>>>16)&a)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}},(e,t,n)=>{var i;Object.defineProperty(t,"__esModule",{value:!0}),t.FontLoader=t.FontFaceObject=void 0;var r=n(1),a=n(10);i=new WeakMap,t.FontLoader=class{constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){Je(this,i,new Set),this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));let t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(let e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),ce(this,i).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}loadSystemFont(e){return ft(this,null,(function*(){if(e&&!ce(this,i).has(e.loadedName)){if((0,r.assert)(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:n,src:a,style:s}=e,o=new FontFace(n,a,s);this.addNativeFontFace(o);try{yield o.load(),ce(this,i).add(n)}catch(t){(0,r.warn)(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}(0,r.unreachable)("Not implemented: loadSystemFont without the Font Loading API.")}}))}bind(e){return ft(this,null,(function*(){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo)return void(yield this.loadSystemFont(e.systemFontInfo));if(this.isFontLoadingAPISupported){let t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{yield t.loaded}catch(n){throw(0,r.warn)(`Failed to load font '${t.family}': '${n}'.`),e.disableFontFace=!0,n}}return}let t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;yield new Promise((t=>{let n=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,n)}))}}))}get isFontLoadingAPISupported(){var e;let t=!(null==(e=this._document)||!e.fonts);return(0,r.shadow)(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let e=!1;return(a.isNodeJS||"undefined"!=typeof navigator&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),(0,r.shadow)(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){let{loadingRequests:t}=this,n={done:!1,complete:function(){for((0,r.assert)(!n.done,"completeRequest() cannot be called twice."),n.done=!0;t.length>0&&t[0].done;){let e=t.shift();setTimeout(e.callback,0)}},callback:e};return t.push(n),n}get _loadTestFont(){let e=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return(0,r.shadow)(this,"_loadTestFont",e)}_prepareFontLoadEvent(e,t){function n(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|255&e.charCodeAt(t+3)}function i(e,t,n,i){return e.substring(0,t)+i+e.substring(t+n)}let a,s,o=this._document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d"),h=0,c=`lt${Date.now()}${this.loadTestFontId++}`,u=this._loadTestFont;u=i(u,976,c.length,c);let d=1482184792,p=n(u,16);for(a=0,s=c.length-3;a30)return(0,r.warn)("Load test font never loaded."),void n();l.font="30px "+t,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0?n():setTimeout(e.bind(null,t,n))}(c,(()=>{m.remove(),t.complete()}))}},t.FontFaceObject=class{constructor(e,{isEvalSupported:t=!0,disableFontFace:n=!1,ignoreErrors:i=!1,inspectFont:r=null}){this.compiledGlyphs=Object.create(null);for(let a in e)this[a]=e[a];this.isEvalSupported=!1!==t,this.disableFontFace=!0===n,this.ignoreErrors=!0===i,this._inspectFont=r}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){let e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return null==(e=this._inspectFont)||e.call(this,this),t}createFontFaceRule(){var e;if(!this.data||this.disableFontFace)return null;let t,n=(0,r.bytesToString)(this.data),i=`url(data:${this.mimetype};base64,${btoa(n)});`;if(this.cssFontInfo){let e=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(e+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${e}src:${i}}`}else t=`@font-face {font-family:"${this.loadedName}";src:${i}}`;return null==(e=this._inspectFont)||e.call(this,this,i),t}getPathGenerator(e,t){if(void 0!==this.compiledGlyphs[t])return this.compiledGlyphs[t];let n;try{n=e.get(this.loadedName+"_path_"+t)}catch(e){if(!this.ignoreErrors)throw e;return(0,r.warn)(`getPathGenerator - ignoring character: "${e}".`),this.compiledGlyphs[t]=function(e,t){}}if(this.isEvalSupported&&r.FeatureTest.isEvalSupported){let e=[];for(let t of n){let n=void 0!==t.args?t.args.join(","):"";e.push("c.",t.cmd,"(",n,");\n")}return this.compiledGlyphs[t]=new Function("c","size",e.join(""))}return this.compiledGlyphs[t]=function(e,t){for(let i of n)"scale"===i.cmd&&(i.args=[t,-t]),e[i.cmd].apply(e,i.args)}}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNodeJS=void 0;let n=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type);t.isNodeJS=n},(e,t,n)=>{var i,r,a,s;Object.defineProperty(t,"__esModule",{value:!0}),t.CanvasGraphics=void 0;var o=n(1),l=n(6),h=n(12),c=n(13),u=n(10);let d=4096,p=16;class f{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,n){let i;return void 0!==this.cache[e]?(i=this.cache[e],this.canvasFactory.reset(i,t,n)):(i=this.canvasFactory.create(t,n),this.cache[e]=i),i}delete(e){delete this.cache[e]}clear(){for(let e in this.cache){let t=this.cache[e];this.canvasFactory.destroy(t),delete this.cache[e]}}}function m(e,t,n,i,r,a,s,o,h,c){let[u,d,p,f,m,g]=(0,l.getCurrentTransform)(e);if(0===d&&0===p){let l=s*u+m,v=Math.round(l),y=o*f+g,x=Math.round(y),b=(s+h)*u+m,_=Math.abs(Math.round(b)-v)||1,w=(o+c)*f+g,S=Math.abs(Math.round(w)-x)||1;return e.setTransform(Math.sign(u),0,0,Math.sign(f),v,x),e.drawImage(t,n,i,r,a,0,0,_,S),e.setTransform(u,d,p,f,m,g),[_,S]}if(0===u&&0===f){let l=o*p+m,v=Math.round(l),y=s*d+g,x=Math.round(y),b=(o+c)*p+m,_=Math.abs(Math.round(b)-v)||1,w=(s+h)*d+g,S=Math.abs(Math.round(w)-x)||1;return e.setTransform(0,Math.sign(d),Math.sign(p),0,v,x),e.drawImage(t,n,i,r,a,0,0,S,_),e.setTransform(u,d,p,f,m,g),[S,_]}return e.drawImage(t,n,i,r,a,s,o,h,c),[Math.hypot(u,d)*h,Math.hypot(p,f)*c]}class g{constructor(e,t){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=o.IDENTITY_MATRIX,this.textMatrixScale=1,this.fontMatrix=o.FONT_IDENTITY_MATRIX,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=o.TextRenderingMode.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,e,t])}clone(){let e=Object.create(this);return e.clipBox=this.clipBox.slice(),e}setCurrentPoint(e,t){this.x=e,this.y=t}updatePathMinMax(e,t,n){[t,n]=o.Util.applyTransform([t,n],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,n)}updateRectMinMax(e,t){let n=o.Util.applyTransform(t,e),i=o.Util.applyTransform(t.slice(2),e);this.minX=Math.min(this.minX,n[0],i[0]),this.minY=Math.min(this.minY,n[1],i[1]),this.maxX=Math.max(this.maxX,n[0],i[0]),this.maxY=Math.max(this.maxY,n[1],i[1])}updateScalingPathMinMax(e,t){o.Util.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.maxX=Math.max(this.maxX,t[1]),this.minY=Math.min(this.minY,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,n,i,r,a,s,l,h,c){let u=o.Util.bezierBoundingBox(t,n,i,r,a,s,l,h);if(c)return c[0]=Math.min(c[0],u[0],u[2]),c[1]=Math.max(c[1],u[0],u[2]),c[2]=Math.min(c[2],u[1],u[3]),void(c[3]=Math.max(c[3],u[1],u[3]));this.updateRectMinMax(e,u)}getPathBoundingBox(e=h.PathType.FILL,t=null){let n=[this.minX,this.minY,this.maxX,this.maxY];if(e===h.PathType.STROKE){t||(0,o.unreachable)("Stroke bounding box must include transform.");let e=o.Util.singularValueDecompose2dScale(t),i=e[0]*this.lineWidth/2,r=e[1]*this.lineWidth/2;n[0]-=i,n[1]-=r,n[2]+=i,n[3]+=r}return n}updateClipFromPath(){let e=o.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(e=h.PathType.FILL,t=null){return o.Util.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function v(e,t){if("undefined"!=typeof ImageData&&t instanceof ImageData)return void e.putImageData(t,0,0);let n,i,r,a,s,l=t.height,h=t.width,c=l%p,u=(l-c)/p,d=0===c?u:u+1,f=e.createImageData(h,p),m=0,g=t.data,v=f.data;if(t.kind===o.ImageKind.GRAYSCALE_1BPP){let t=g.byteLength,s=new Uint32Array(v.buffer,0,v.byteLength>>2),l=s.length,y=h+7>>3,x=4294967295,b=o.FeatureTest.isLittleEndian?4278190080:255;for(i=0;iy?h:8*e-7,a=-8&r,o=0,l=0;for(;i>=1}for(;n=u&&(a=c,s=h*a),n=0,r=s;r--;)v[n++]=g[m++],v[n++]=g[m++],v[n++]=g[m++],v[n++]=255;e.putImageData(f,0,i*p)}}}function y(e,t){if(t.bitmap)return void e.drawImage(t.bitmap,0,0);let n=t.height,i=t.width,r=n%p,a=(n-r)/p,s=0===r?a:a+1,o=e.createImageData(i,p),l=0,h=t.data,u=o.data;for(let d=0;d>8,e[a-2]=e[a-2]*r+n*s>>8,e[a-1]=e[a-1]*r+i*s>>8}}}function w(e,t,n){let i=e.length;for(let r=3;r>8]>>8:t[r]*i>>16}}function M(e,t){let n=o.Util.singularValueDecompose2dScale(e);n[0]=Math.fround(n[0]),n[1]=Math.fround(n[1]);let i=Math.fround((globalThis.devicePixelRatio||1)*l.PixelsPerInch.PDF_TO_CSS_UNITS);return void 0!==t?t:n[0]<=i||n[1]<=i}let T=["butt","round","square"],E=["miter","round","bevel"],A={},C={},P=class{constructor(e,t,n,r,s,{optionalContentConfig:o,markedContentStack:l=null},h,c){Je(this,i),Je(this,a),this.ctx=e,this.current=new g(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=t,this.objs=n,this.canvasFactory=r,this.filterFactory=s,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=l||[],this.optionalContentConfig=o,this.cachedCanvases=new f(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=h,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(e,t=null){return"string"==typeof e?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):t}beginDrawing({transform:e,viewport:t,transparency:n=!1,background:i=null}){let r=this.ctx.canvas.width,a=this.ctx.canvas.height,s=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,r,a),this.ctx.fillStyle=s,n){let e=this.cachedCanvases.getCanvas("transparent",r,a);this.compositeCtx=this.ctx,this.transparentCanvas=e.canvas,this.ctx=e.context,this.ctx.save(),this.ctx.transform(...(0,l.getCurrentTransform)(this.compositeCtx))}this.ctx.save(),b(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...t.transform),this.viewportScale=t.scale,this.baseTransform=(0,l.getCurrentTransform)(this.ctx)}executeOperatorList(e,t,n,i){let r=e.argsArray,a=e.fnArray,s=t||0,l=r.length;if(l===s)return s;let h,c=l-s>10&&"function"==typeof n,u=c?Date.now()+15:0,d=0,p=this.commonObjs,f=this.objs;for(;;){if(void 0!==i&&s===i.nextBreakPoint)return i.breakIt(s,n),s;if(h=a[s],h!==o.OPS.dependency)this[h].apply(this,r[s]);else for(let e of r[s]){let t=e.startsWith("g_")?p:f;if(!t.has(e))return t.get(e,n),s}if(s++,s===l)return s;if(c&&++d>10){if(Date.now()>u)return n(),s;d=0}}}endDrawing(){dt(this,i,r).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(let e of this._cachedBitmapsMap.values()){for(let t of e.values())"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),dt(this,a,s).call(this)}_scaleImage(e,t){let n,i,r=e.width,a=e.height,s=Math.max(Math.hypot(t[0],t[1]),1),o=Math.max(Math.hypot(t[2],t[3]),1),l=r,h=a,c="prescale1";for(;s>2&&l>1||o>2&&h>1;){let t=l,r=h;s>2&&l>1&&(t=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),s/=l/t),o>2&&h>1&&(r=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/r),n=this.cachedCanvases.getCanvas(c,t,r),i=n.context,i.clearRect(0,0,t,r),i.drawImage(e,0,0,l,h,0,0,t,r),e=n.canvas,l=t,h=r,c="prescale1"===c?"prescale2":"prescale1"}return{img:e,paintWidth:l,paintHeight:h}}_createMaskCanvas(e){let t,n,i,r,a=this.ctx,{width:s,height:c}=e,u=this.current.fillColor,d=this.current.patternFill,p=(0,l.getCurrentTransform)(a);if((e.bitmap||e.data)&&e.count>1){let r=e.bitmap||e.data.buffer;n=JSON.stringify(d?p:[p.slice(0,4),u]),t=this._cachedBitmapsMap.get(r),t||(t=new Map,this._cachedBitmapsMap.set(r,t));let a=t.get(n);if(a&&!d)return{canvas:a,offsetX:Math.round(Math.min(p[0],p[2])+p[4]),offsetY:Math.round(Math.min(p[1],p[3])+p[5])};i=a}i||(r=this.cachedCanvases.getCanvas("maskCanvas",s,c),y(r.context,e));let f=o.Util.transform(p,[1/s,0,0,-1/c,0,0]);f=o.Util.transform(f,[1,0,0,1,0,-c]);let g=o.Util.applyTransform([0,0],f),v=o.Util.applyTransform([s,c],f),x=o.Util.normalizeRect([g[0],g[1],v[0],v[1]]),b=Math.round(x[2]-x[0])||1,_=Math.round(x[3]-x[1])||1,w=this.cachedCanvases.getCanvas("fillCanvas",b,_),S=w.context,T=Math.min(g[0],v[0]),E=Math.min(g[1],v[1]);S.translate(-T,-E),S.transform(...f),i||(i=this._scaleImage(r.canvas,(0,l.getCurrentTransformInverse)(S)),i=i.img,t&&d&&t.set(n,i)),S.imageSmoothingEnabled=M((0,l.getCurrentTransform)(S),e.interpolate),m(S,i,0,0,i.width,i.height,0,0,s,c),S.globalCompositeOperation="source-in";let A=o.Util.transform((0,l.getCurrentTransformInverse)(S),[1,0,0,1,-T,-E]);return S.fillStyle=d?u.getPattern(a,this,A,h.PathType.FILL):u,S.fillRect(0,0,s,c),t&&!d&&(this.cachedCanvases.delete("fillCanvas"),t.set(n,w.canvas)),{canvas:w.canvas,offsetX:Math.round(T),offsetY:Math.round(E)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=T[e]}setLineJoin(e){this.ctx.lineJoin=E[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){let n=this.ctx;void 0!==n.setLineDash&&(n.setLineDash(e),n.lineDashOffset=t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(let[t,n]of e)switch(t){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n[0],n[1]);break;case"CA":this.current.strokeAlpha=n;break;case"ca":this.current.fillAlpha=n,this.ctx.globalAlpha=n;break;case"BM":this.ctx.globalCompositeOperation=n;break;case"SMask":this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){let e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");let e=this.ctx.canvas.width,t=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(n,e,t);this.suspendedCtx=this.ctx,this.ctx=i.context;let r=this.ctx;r.setTransform(...(0,l.getCurrentTransform)(this.suspendedCtx)),x(this.suspendedCtx,r),function(e,t){if(e._removeMirroring)throw new Error("Context is already forwarding operations.");e.__originalSave=e.save,e.__originalRestore=e.restore,e.__originalRotate=e.rotate,e.__originalScale=e.scale,e.__originalTranslate=e.translate,e.__originalTransform=e.transform,e.__originalSetTransform=e.setTransform,e.__originalResetTransform=e.resetTransform,e.__originalClip=e.clip,e.__originalMoveTo=e.moveTo,e.__originalLineTo=e.lineTo,e.__originalBezierCurveTo=e.bezierCurveTo,e.__originalRect=e.rect,e.__originalClosePath=e.closePath,e.__originalBeginPath=e.beginPath,e._removeMirroring=()=>{e.save=e.__originalSave,e.restore=e.__originalRestore,e.rotate=e.__originalRotate,e.scale=e.__originalScale,e.translate=e.__originalTranslate,e.transform=e.__originalTransform,e.setTransform=e.__originalSetTransform,e.resetTransform=e.__originalResetTransform,e.clip=e.__originalClip,e.moveTo=e.__originalMoveTo,e.lineTo=e.__originalLineTo,e.bezierCurveTo=e.__originalBezierCurveTo,e.rect=e.__originalRect,e.closePath=e.__originalClosePath,e.beginPath=e.__originalBeginPath,delete e._removeMirroring},e.save=function(){t.save(),this.__originalSave()},e.restore=function(){t.restore(),this.__originalRestore()},e.translate=function(e,n){t.translate(e,n),this.__originalTranslate(e,n)},e.scale=function(e,n){t.scale(e,n),this.__originalScale(e,n)},e.transform=function(e,n,i,r,a,s){t.transform(e,n,i,r,a,s),this.__originalTransform(e,n,i,r,a,s)},e.setTransform=function(e,n,i,r,a,s){t.setTransform(e,n,i,r,a,s),this.__originalSetTransform(e,n,i,r,a,s)},e.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},e.rotate=function(e){t.rotate(e),this.__originalRotate(e)},e.clip=function(e){t.clip(e),this.__originalClip(e)},e.moveTo=function(e,n){t.moveTo(e,n),this.__originalMoveTo(e,n)},e.lineTo=function(e,n){t.lineTo(e,n),this.__originalLineTo(e,n)},e.bezierCurveTo=function(e,n,i,r,a,s){t.bezierCurveTo(e,n,i,r,a,s),this.__originalBezierCurveTo(e,n,i,r,a,s)},e.rect=function(e,n,i,r){t.rect(e,n,i,r),this.__originalRect(e,n,i,r)},e.closePath=function(){t.closePath(),this.__originalClosePath()},e.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}(r,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),x(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];let t=this.current.activeSMask;(function(e,t,n,i){let r=i[0],a=i[1],s=i[2]-r,o=i[3]-a;0===s||0===o||(function(e,t,n,i,r,a,s,o,l,h,c){let u,d=!!a,p=d?a[0]:0,f=d?a[1]:0,m=d?a[2]:0;u="Luminosity"===r?S:w;let g=Math.min(i,Math.ceil(1048576/n));for(let v=0;v100&&(c=100),this.current.fontSizeScale=t/c,this.ctx.font=`${h} ${l} ${c}px ${s}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(e,t){this.setLeading(-t),this.moveText(e,t)}setTextMatrix(e,t,n,i,r,a){this.current.textMatrix=[e,t,n,i,r,a],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(e,t,n,i){let r,a=this.ctx,s=this.current,h=s.font,c=s.textRenderingMode,u=s.fontSize/s.fontSizeScale,d=c&o.TextRenderingMode.FILL_STROKE_MASK,p=!!(c&o.TextRenderingMode.ADD_TO_PATH_FLAG),f=s.patternFill&&!h.missingFile;(h.disableFontFace||p||f)&&(r=h.getPathGenerator(this.commonObjs,e)),h.disableFontFace||f?(a.save(),a.translate(t,n),a.beginPath(),r(a,u),i&&a.setTransform(...i),(d===o.TextRenderingMode.FILL||d===o.TextRenderingMode.FILL_STROKE)&&a.fill(),(d===o.TextRenderingMode.STROKE||d===o.TextRenderingMode.FILL_STROKE)&&a.stroke(),a.restore()):((d===o.TextRenderingMode.FILL||d===o.TextRenderingMode.FILL_STROKE)&&a.fillText(e,t,n),(d===o.TextRenderingMode.STROKE||d===o.TextRenderingMode.FILL_STROKE)&&a.strokeText(e,t,n)),p&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:(0,l.getCurrentTransform)(a),x:t,y:n,fontSize:u,addToPath:r})}get isFontSubpixelAAEnabled(){let{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);let t=e.getImageData(0,0,10,10).data,n=!1;for(let i=3;i0&&t[i]<255){n=!0;break}return(0,o.shadow)(this,"isFontSubpixelAAEnabled",n)}showText(e){let t=this.current,n=t.font;if(n.isType3Font)return this.showType3Text(e);let i=t.fontSize;if(0===i)return;let r,a=this.ctx,s=t.fontSizeScale,c=t.charSpacing,u=t.wordSpacing,d=t.fontDirection,p=t.textHScale*d,f=e.length,m=n.vertical,g=m?1:-1,v=n.defaultVMetrics,y=i*t.fontMatrix[0],x=t.textRenderingMode===o.TextRenderingMode.FILL&&!n.disableFontFace&&!t.patternFill;if(a.save(),a.transform(...t.textMatrix),a.translate(t.x,t.y+t.textRise),d>0?a.scale(p,-1):a.scale(p,1),t.patternFill){a.save();let e=t.fillColor.getPattern(a,this,(0,l.getCurrentTransformInverse)(a),h.PathType.FILL);r=(0,l.getCurrentTransform)(a),a.restore(),a.fillStyle=e}let b=t.lineWidth,_=t.textMatrixScale;if(0===_||0===b){let e=t.textRenderingMode&o.TextRenderingMode.FILL_STROKE_MASK;(e===o.TextRenderingMode.STROKE||e===o.TextRenderingMode.FILL_STROKE)&&(b=this.getSinglePixelWidth())}else b/=_;if(1!==s&&(a.scale(s,s),b/=s),a.lineWidth=b,n.isInvalidPDFjsFont){let n=[],i=0;for(let t of e)n.push(t.unicode),i+=t.width;return a.fillText(n.join(""),0,0),t.x+=i*y*p,a.restore(),void this.compose()}let w,S=0;for(w=0;w0){let e=1e3*a.measureText(b).width/i*s;if(Mnew P(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};t=new h.TilingPattern(e,n,this.ctx,r,i)}else t=this._getPattern(e[1],e[2]);return t}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e,t,n){let i=o.Util.makeHexColor(e,t,n);this.ctx.strokeStyle=i,this.current.strokeColor=i}setFillRGBColor(e,t,n){let i=o.Util.makeHexColor(e,t,n);this.ctx.fillStyle=i,this.current.fillColor=i,this.current.patternFill=!1}_getPattern(e,t=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=(0,h.getShadingPattern)(this.getObject(e)),this.cachedPatterns.set(e,n)),t&&(n.matrix=t),n}shadingFill(e){if(!this.contentVisible)return;let t=this.ctx;this.save();let n=this._getPattern(e);t.fillStyle=n.getPattern(t,this,(0,l.getCurrentTransformInverse)(t),h.PathType.SHADING);let i=(0,l.getCurrentTransformInverse)(t);if(i){let{width:e,height:n}=t.canvas,[r,a,s,l]=o.Util.getAxialAlignedBoundingBox([0,0,e,n],i);this.ctx.fillRect(r,a,s-r,l-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){(0,o.unreachable)("Should not call beginInlineImage")}beginImageData(){(0,o.unreachable)("Should not call beginImageData")}paintFormXObjectBegin(e,t){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),Array.isArray(e)&&6===e.length&&this.transform(...e),this.baseTransform=(0,l.getCurrentTransform)(this.ctx),t)){let e=t[2]-t[0],n=t[3]-t[1];this.ctx.rect(t[0],t[1],e,n),this.current.updateRectMinMax((0,l.getCurrentTransform)(this.ctx),t),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);let t=this.ctx;e.isolated||(0,o.info)("TODO: Support non-isolated groups."),e.knockout&&(0,o.warn)("Knockout groups not supported.");let n=(0,l.getCurrentTransform)(t);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let i=o.Util.getAxialAlignedBoundingBox(e.bbox,(0,l.getCurrentTransform)(t)),r=[0,0,t.canvas.width,t.canvas.height];i=o.Util.intersect(i,r)||[0,0,0,0];let a=Math.floor(i[0]),s=Math.floor(i[1]),h=Math.max(Math.ceil(i[2])-a,1),c=Math.max(Math.ceil(i[3])-s,1),u=1,p=1;h>d&&(u=h/d,h=d),c>d&&(p=c/d,c=d),this.current.startNewPathAndClipBox([0,0,h,c]);let f="groupAt"+this.groupLevel;e.smask&&(f+="_smask_"+this.smaskCounter++%2);let m=this.cachedCanvases.getCanvas(f,h,c),g=m.context;g.scale(1/u,1/p),g.translate(-a,-s),g.transform(...n),e.smask?this.smaskStack.push({canvas:m.canvas,context:g,offsetX:a,offsetY:s,scaleX:u,scaleY:p,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(t.setTransform(1,0,0,1,0,0),t.translate(a,s),t.scale(u,p),t.save()),x(t,g),this.ctx=g,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(t),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;let t=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,e.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();let e=(0,l.getCurrentTransform)(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...e);let n=o.Util.getAxialAlignedBoundingBox([0,0,t.canvas.width,t.canvas.height],e);this.ctx.drawImage(t.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(e,t,n,a,s){if(dt(this,i,r).call(this),b(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),Array.isArray(t)&&4===t.length){let i=t[2]-t[0],r=t[3]-t[1];if(s&&this.annotationCanvasMap){(n=n.slice())[4]-=t[0],n[5]-=t[1],(t=t.slice())[0]=t[1]=0,t[2]=i,t[3]=r;let[a,s]=o.Util.singularValueDecompose2dScale((0,l.getCurrentTransform)(this.ctx)),{viewportScale:h}=this,c=Math.ceil(i*this.outputScaleX*h),u=Math.ceil(r*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(c,u);let{canvas:d,context:p}=this.annotationCanvas;this.annotationCanvasMap.set(e,d),this.annotationCanvas.savedCtx=this.ctx,this.ctx=p,this.ctx.save(),this.ctx.setTransform(a,0,0,-s,0,r*s),b(this.ctx)}else b(this.ctx),this.ctx.rect(t[0],t[1],i,r),this.ctx.clip(),this.endPath()}this.current=new g(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...a)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),dt(this,a,s).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;let t=e.count;(e=this.getObject(e.data,e)).count=t;let n=this.ctx,i=this.processingType3;if(i&&(void 0===i.compiled&&(i.compiled=function(e){let{width:t,height:n}=e;if(t>1e3||n>1e3)return null;let i,r,a,s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),o=t+1,l=new Uint8Array(o*(n+1)),h=t+7&-8,c=new Uint8Array(h*n),u=0;for(let m of e.data){let e=128;for(;e>0;)c[u++]=m&e?0:255,e>>=1}let d=0;for(u=0,0!==c[u]&&(l[0]=1,++d),r=1;r>2)+(c[u+1]?4:0)+(c[u-h+1]?8:0),s[e]&&(l[a+r]=s[e],++d),u++;if(c[u-h]!==c[u]&&(l[a+r]=c[u]?2:4,++d),d>1e3)return null}for(u=h*(n-1),a=i*o,0!==c[u]&&(l[a]=8,++d),r=1;r1e3)return null;let p=new Int32Array([0,o,-1,0,-o,0,0,0,1]),f=new Path2D;for(i=0;d&&i<=n;i++){let e=i*o,n=e+t;for(;e>4,l[e]&=a>>2|a<<2),f.lineTo(e%o,e/o|0),l[e]||--d}while(r!==e);--i}return c=null,l=null,function(e){e.save(),e.scale(1/t,-1/n),e.translate(0,-n),e.fill(f),e.beginPath(),e.restore()}}(e)),i.compiled))return void i.compiled(n);let r=this._createMaskCanvas(e),a=r.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(a,r.offsetX,r.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(e,t,n=0,i=0,r,a){if(!this.contentVisible)return;e=this.getObject(e.data,e);let s=this.ctx;s.save();let h=(0,l.getCurrentTransform)(s);s.transform(t,n,i,r,0,0);let c=this._createMaskCanvas(e);s.setTransform(1,0,0,1,c.offsetX-h[4],c.offsetY-h[5]);for(let l=0,u=a.length;li?h/i:1,t=l>i?l/i:1}}this._cachedScaleForStroking[0]=e,this._cachedScaleForStroking[1]=t}return this._cachedScaleForStroking}rescaleAndStroke(e){let{ctx:t}=this,{lineWidth:n}=this.current,[i,r]=this.getScaleForStroking();if(t.lineWidth=n||1,1===i&&1===r)return void t.stroke();let a=t.getLineDash();if(e&&t.save(),t.scale(i,r),a.length>0){let e=Math.max(i,r);t.setLineDash(a.map((t=>t/e))),t.lineDashOffset/=e}t.stroke(),e&&t.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}},R=P;i=new WeakSet,r=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},a=new WeakSet,s=function(){if(this.pageColors){let e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==e){let t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}},t.CanvasGraphics=R;for(let O in o.OPS)void 0!==R.prototype[O]&&(R.prototype[o.OPS[O]]=R.prototype[O])},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TilingPattern=t.PathType=void 0,t.getShadingPattern=function(e){switch(e[0]){case"RadialAxial":return new l(e);case"Mesh":return new u(e);case"Dummy":return new d}throw new Error(`Unknown IR type: ${e[0]}`)};var i=n(1),r=n(6);let a={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function s(e,t){if(!t)return;let n=t[2]-t[0],i=t[3]-t[1],r=new Path2D;r.rect(t[0],t[1],n,i),e.clip(r)}t.PathType=a;class o{constructor(){this.constructor===o&&(0,i.unreachable)("Cannot initialize BaseShadingPattern.")}getPattern(){(0,i.unreachable)("Abstract method `getPattern` called.")}}class l extends o{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let t;"axial"===this._type?t=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(t=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(let n of this._colorStops)t.addColorStop(n[0],n[1]);return t}getPattern(e,t,n,o){let l;if(o===a.STROKE||o===a.FILL){let a=t.current.getClippedPathBoundingBox(o,(0,r.getCurrentTransform)(e))||[0,0,0,0],h=Math.ceil(a[2]-a[0])||1,c=Math.ceil(a[3]-a[1])||1,u=t.cachedCanvases.getCanvas("pattern",h,c,!0),d=u.context;d.clearRect(0,0,d.canvas.width,d.canvas.height),d.beginPath(),d.rect(0,0,d.canvas.width,d.canvas.height),d.translate(-a[0],-a[1]),n=i.Util.transform(n,[1,0,0,1,a[0],a[1]]),d.transform(...t.baseTransform),this.matrix&&d.transform(...this.matrix),s(d,this._bbox),d.fillStyle=this._createGradient(d),d.fill(),l=e.createPattern(u.canvas,"no-repeat");let p=new DOMMatrix(n);l.setTransform(p)}else s(e,this._bbox),l=this._createGradient(e);return l}}function h(e,t,n,i,r,a,s,o){let l,h=t.coords,c=t.colors,u=e.data,d=4*e.width;h[n+1]>h[i+1]&&(l=n,n=i,i=l,l=a,a=s,s=l),h[i+1]>h[r+1]&&(l=i,i=r,r=l,l=s,s=o,o=l),h[n+1]>h[i+1]&&(l=n,n=i,i=l,l=a,a=s,s=l);let p=(h[n]+t.offsetX)*t.scaleX,f=(h[n+1]+t.offsetY)*t.scaleY,m=(h[i]+t.offsetX)*t.scaleX,g=(h[i+1]+t.offsetY)*t.scaleY,v=(h[r]+t.offsetX)*t.scaleX,y=(h[r+1]+t.offsetY)*t.scaleY;if(f>=y)return;let x,b,_,w,S,M,T,E,A=c[a],C=c[a+1],P=c[a+2],R=c[s],O=c[s+1],L=c[s+2],I=c[o],D=c[o+1],k=c[o+2],N=Math.round(f),F=Math.round(y);for(let U=N;U<=F;U++){if(Uy?1:g===y?0:(g-U)/(g-y),x=m-(m-v)*e,b=R-(R-I)*e,_=O-(O-D)*e,w=L-(L-k)*e}let e;e=Uy?1:(f-U)/(f-y),S=p-(p-v)*e,M=A-(A-I)*e,T=C-(C-D)*e,E=P-(P-k)*e;let t=Math.round(Math.min(x,S)),n=Math.round(Math.max(x,S)),i=d*U+4*t;for(let r=t;r<=n;r++)e=(x-r)/(x-S),e<0?e=0:e>1&&(e=1),u[i++]=b-(b-M)*e|0,u[i++]=_-(_-T)*e|0,u[i++]=w-(w-E)*e|0,u[i++]=255}}function c(e,t,n){let i,r,a=t.coords,s=t.colors;switch(t.type){case"lattice":let o=t.verticesPerRow,l=Math.floor(a.length/o)-1,c=o-1;for(i=0;i=i?r=i:n=r/e,{scale:n,size:r}}clipBbox(e,t,n,i,a){let s=i-t,o=a-n;e.ctx.rect(t,n,s,o),e.current.updateRectMinMax((0,r.getCurrentTransform)(e.ctx),[t,n,i,a]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,t,n){let r=e.ctx,a=e.current;switch(t){case 1:let e=this.ctx;r.fillStyle=e.fillStyle,r.strokeStyle=e.strokeStyle,a.fillColor=e.fillStyle,a.strokeColor=e.strokeStyle;break;case 2:let s=i.Util.makeHexColor(n[0],n[1],n[2]);r.fillStyle=s,r.strokeStyle=s,a.fillColor=s,a.strokeColor=s;break;default:throw new i.FormatError(`Unsupported paint type: ${t}`)}}getPattern(e,t,n,r){let s=n;r!==a.SHADING&&(s=i.Util.transform(s,t.baseTransform),this.matrix&&(s=i.Util.transform(s,this.matrix)));let o=this.createPatternCanvas(t),l=new DOMMatrix(s);l=l.translate(o.offsetX,o.offsetY),l=l.scale(1/o.scaleX,1/o.scaleY);let h=e.createPattern(o.canvas,"repeat");return h.setTransform(l),h}},f=p;Xi(f,"MAX_PATTERN_SIZE",3e3),t.TilingPattern=f},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.convertBlackAndWhiteToRGBA=r,t.convertToRGBA=function(e){switch(e.kind){case i.ImageKind.GRAYSCALE_1BPP:return r(e);case i.ImageKind.RGB_24BPP:return function({src:e,srcPos:t=0,dest:n,destPos:r=0,width:a,height:s}){let o=0,l=e.length>>2,h=new Uint32Array(e.buffer,t,l);if(i.FeatureTest.isLittleEndian){for(;o>>24|t<<8|4278190080,n[r+2]=t>>>16|i<<16|4278190080,n[r+3]=i>>>8|4278190080}for(let t=4*o,i=e.length;t>>8|255,n[r+2]=t<<16|i>>>16|255,n[r+3]=i<<8|255}for(let t=4*o,i=e.length;t>3,d=7&r,p=e.length;n=new Uint32Array(n.buffer);let f=0;for(let i=0;i{Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalWorkerOptions=void 0;let n=Object.create(null);t.GlobalWorkerOptions=n,n.workerPort=null,n.workerSrc=""},(e,t,n)=>{var i,r,a,s,o,l;Object.defineProperty(t,"__esModule",{value:!0}),t.MessageHandler=void 0;var h=n(1);function c(e){switch(e instanceof Error||"object"==typeof e&&null!==e||(0,h.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),e.name){case"AbortException":return new h.AbortException(e.message);case"MissingPDFException":return new h.MissingPDFException(e.message);case"PasswordException":return new h.PasswordException(e.message,e.code);case"UnexpectedResponseException":return new h.UnexpectedResponseException(e.message,e.status);case"UnknownErrorException":return new h.UnknownErrorException(e.message,e.details);default:return new h.UnknownErrorException(e.message,e.toString())}}i=new WeakSet,r=function(e){let t=e.streamId,n=this.sourceName,i=e.sourceName,r=this.comObj,a=this,s=this.actionHandler[e.action],o={enqueue(e,a=1,s){if(this.isCancelled)return;let o=this.desiredSize;this.desiredSize-=a,o>0&&this.desiredSize<=0&&(this.sinkCapability=new h.PromiseCapability,this.ready=this.sinkCapability.promise),r.postMessage({sourceName:n,targetName:i,stream:4,streamId:t,chunk:e},s)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:n,targetName:i,stream:3,streamId:t}),delete a.streamSinks[t])},error(e){(0,h.assert)(e instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:n,targetName:i,stream:5,streamId:t,reason:c(e)}))},sinkCapability:new h.PromiseCapability,onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[t]=o,new Promise((function(t){t(s(e.data,o))})).then((function(){r.postMessage({sourceName:n,targetName:i,stream:8,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:n,targetName:i,stream:8,streamId:t,reason:c(e)})}))},a=new WeakSet,s=function(e){let t=e.streamId,n=this.sourceName,i=e.sourceName,r=this.comObj,a=this.streamControllers[t],s=this.streamSinks[t];switch(e.stream){case 8:e.success?a.startCall.resolve():a.startCall.reject(c(e.reason));break;case 7:e.success?a.pullCall.resolve():a.pullCall.reject(c(e.reason));break;case 6:if(!s){r.postMessage({sourceName:n,targetName:i,stream:7,streamId:t,success:!0});break}s.desiredSize<=0&&e.desiredSize>0&&s.sinkCapability.resolve(),s.desiredSize=e.desiredSize,new Promise((function(e){var t;e(null==(t=s.onPull)?void 0:t.call(s))})).then((function(){r.postMessage({sourceName:n,targetName:i,stream:7,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:n,targetName:i,stream:7,streamId:t,reason:c(e)})}));break;case 4:if((0,h.assert)(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(e.chunk);break;case 3:if((0,h.assert)(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),dt(this,o,l).call(this,a,t);break;case 5:(0,h.assert)(a,"error should have stream controller"),a.controller.error(c(e.reason)),dt(this,o,l).call(this,a,t);break;case 2:e.success?a.cancelCall.resolve():a.cancelCall.reject(c(e.reason)),dt(this,o,l).call(this,a,t);break;case 1:if(!s)break;new Promise((function(t){var n;t(null==(n=s.onCancel)?void 0:n.call(s,c(e.reason)))})).then((function(){r.postMessage({sourceName:n,targetName:i,stream:2,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:n,targetName:i,stream:2,streamId:t,reason:c(e)})})),s.sinkCapability.reject(c(e.reason)),s.isCancelled=!0,delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}},o=new WeakSet,l=function(e,t){return ft(this,null,(function*(){var n,i,r;yield Promise.allSettled([null==(n=e.startCall)?void 0:n.promise,null==(i=e.pullCall)?void 0:i.promise,null==(r=e.cancelCall)?void 0:r.promise]),delete this.streamControllers[t]}))},t.MessageHandler=class{constructor(e,t,n){Je(this,i),Je(this,a),Je(this,o),this.sourceName=e,this.targetName=t,this.comObj=n,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),this._onComObjOnMessage=e=>{let t=e.data;if(t.targetName!==this.sourceName)return;if(t.stream)return void dt(this,a,s).call(this,t);if(t.callback){let e=t.callbackId,n=this.callbackCapabilities[e];if(!n)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],1===t.callback)n.resolve(t.data);else{if(2!==t.callback)throw new Error("Unexpected callback case");n.reject(c(t.reason))}return}let o=this.actionHandler[t.action];if(!o)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let e=this.sourceName,i=t.sourceName;new Promise((function(e){e(o(t.data))})).then((function(r){n.postMessage({sourceName:e,targetName:i,callback:1,callbackId:t.callbackId,data:r})}),(function(r){n.postMessage({sourceName:e,targetName:i,callback:2,callbackId:t.callbackId,reason:c(r)})}))}else t.streamId?dt(this,i,r).call(this,t):o(t.data)},n.addEventListener("message",this._onComObjOnMessage)}on(e,t){let n=this.actionHandler;if(n[e])throw new Error(`There is already an actionName called "${e}"`);n[e]=t}send(e,t,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},n)}sendWithPromise(e,t,n){let i=this.callbackId++,r=new h.PromiseCapability;this.callbackCapabilities[i]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:i,data:t},n)}catch(e){r.reject(e)}return r.promise}sendWithStream(e,t,n,i){let r=this.streamId++,a=this.sourceName,s=this.targetName,o=this.comObj;return new ReadableStream({start:n=>{let l=new h.PromiseCapability;return this.streamControllers[r]={controller:n,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:a,targetName:s,action:e,streamId:r,data:t,desiredSize:n.desiredSize},i),l.promise},pull:e=>{let t=new h.PromiseCapability;return this.streamControllers[r].pullCall=t,o.postMessage({sourceName:a,targetName:s,stream:6,streamId:r,desiredSize:e.desiredSize}),t.promise},cancel:e=>{(0,h.assert)(e instanceof Error,"cancel must have a valid reason");let t=new h.PromiseCapability;return this.streamControllers[r].cancelCall=t,this.streamControllers[r].isClosed=!0,o.postMessage({sourceName:a,targetName:s,stream:1,streamId:r,reason:c(e)}),t.promise}},n)}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}},(e,t,n)=>{var i,r;Object.defineProperty(t,"__esModule",{value:!0}),t.Metadata=void 0;var a=n(1);i=new WeakMap,r=new WeakMap,t.Metadata=class{constructor({parsedData:e,rawData:t}){Je(this,i,void 0),Je(this,r,void 0),St(this,i,e),St(this,r,t)}getRaw(){return ce(this,r)}get(e){var t;return null!=(t=ce(this,i).get(e))?t:null}getAll(){return(0,a.objectFromMap)(ce(this,i))}has(e){return ce(this,i).has(e)}}},(e,t,n)=>{var i,r,a,s,o,l,h;Object.defineProperty(t,"__esModule",{value:!0}),t.OptionalContentConfig=void 0;var c=n(1),u=n(8);let d=Symbol("INTERNAL");class p{constructor(e,t){Je(this,i,!0),this.name=e,this.intent=t}get visible(){return ce(this,i)}_setVisible(e,t){e!==d&&(0,c.unreachable)("Internal method `_setVisible` called."),St(this,i,t)}}i=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakSet,h=function(e){let t=e.length;if(t<2)return!0;let n=e[0];for(let i=1;i0?(0,c.objectFromMap)(ce(this,a)):null}getGroup(e){return ce(this,a).get(e)||null}getHash(){if(null!==ce(this,r))return ce(this,r);let e=new u.MurmurHash3_64;for(let[t,n]of ce(this,a))e.update(`${t}:${n.visible}`);return St(this,r,e.hexdigest())}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFDataTransportStream=void 0;var i=n(1),r=n(6);t.PDFDataTransportStream=class{constructor({length:e,initialData:t,progressiveDone:n=!1,contentDispositionFilename:r=null,disableRange:a=!1,disableStream:s=!1},o){if((0,i.assert)(o,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.'),this._queuedChunks=[],this._progressiveDone=n,this._contentDispositionFilename=r,(null==t?void 0:t.length)>0){let e=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;this._queuedChunks.push(e)}this._pdfDataRangeTransport=o,this._isStreamingSupported=!s,this._isRangeSupported=!a,this._contentLength=e,this._fullRequestReader=null,this._rangeReaders=[],this._pdfDataRangeTransport.addRangeListener(((e,t)=>{this._onReceiveData({begin:e,chunk:t})})),this._pdfDataRangeTransport.addProgressListener(((e,t)=>{this._onProgress({loaded:e,total:t})})),this._pdfDataRangeTransport.addProgressiveReadListener((e=>{this._onReceiveData({chunk:e})})),this._pdfDataRangeTransport.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),this._pdfDataRangeTransport.transportReady()}_onReceiveData({begin:e,chunk:t}){let n=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;if(void 0===e)this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n);else{let t=this._rangeReaders.some((function(t){return t._begin===e&&(t._enqueue(n),!0)}));(0,i.assert)(t,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var e,t;return null!=(t=null==(e=this._fullRequestReader)?void 0:e._loaded)?t:0}_onProgress(e){var t,n,i,r;void 0===e.total?null==(n=null==(t=this._rangeReaders[0])?void 0:t.onProgress)||n.call(t,{loaded:e.loaded}):null==(r=null==(i=this._fullRequestReader)?void 0:i.onProgress)||r.call(i,{loaded:e.loaded,total:e.total})}_onProgressiveDone(){var e;null==(e=this._fullRequestReader)||e.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){let t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){(0,i.assert)(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let e=this._queuedChunks;return this._queuedChunks=null,new a(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new s(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(n),n}cancelAllRequests(e){var t;null==(t=this._fullRequestReader)||t.cancel(e);for(let n of this._rangeReaders.slice(0))n.cancel(e);this._pdfDataRangeTransport.abort()}};class a{constructor(e,t,n=!1,i=null){this._stream=e,this._done=n||!1,this._filename=(0,r.isPdfFile)(i)?i:null,this._queuedChunks=t||[],this._loaded=0;for(let r of this._queuedChunks)this._loaded+=r.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}read(){return ft(this,null,(function*(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=new i.PromiseCapability;return this._requests.push(e),e.promise}))}cancel(e){this._done=!0;for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class s{constructor(e,t,n){this._stream=e,this._begin=t,this._end=n,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(0===this._requests.length)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}read(){return ft(this,null,(function*(){if(this._queuedChunk){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let e=new i.PromiseCapability;return this._requests.push(e),e.promise}))}cancel(e){this._done=!0;for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XfaText=void 0;class n{static textContent(e){let t=[],i={items:t,styles:Object.create(null)};return function e(i){var r;if(!i)return;let a=null,s=i.name;if("#text"===s)a=i.value;else{if(!n.shouldBuildText(s))return;null!=(r=null==i?void 0:i.attributes)&&r.textContent?a=i.attributes.textContent:i.value&&(a=i.value)}if(null!==a&&t.push({str:a}),i.children)for(let t of i.children)e(t)}(e),i}static shouldBuildText(e){return!("textarea"===e||"input"===e||"option"===e||"select"===e)}}t.XfaText=n},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NodeStandardFontDataFactory=t.NodeFilterFactory=t.NodeCanvasFactory=t.NodeCMapReaderFactory=void 0;var i=n(7);let r=function(e){return new Promise(((t,n)=>{AC().readFile(e,((e,i)=>{!e&&i?t(new Uint8Array(i)):n(new Error(e))}))}))};class a extends i.BaseFilterFactory{}t.NodeFilterFactory=a;class s extends i.BaseCanvasFactory{_createCanvas(e,t){return Bye().createCanvas(e,t)}}t.NodeCanvasFactory=s;class o extends i.BaseCMapReaderFactory{_fetchData(e,t){return r(e).then((e=>({cMapData:e,compressionType:t})))}}t.NodeCMapReaderFactory=o;class l extends i.BaseStandardFontDataFactory{_fetchData(e){return r(e)}}t.NodeStandardFontDataFactory=l},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFNodeStream=void 0;var i=n(1),r=n(22);let a=AC(),s=Uye(),o=Hye(),l=Vye(),h=/^file:\/\/\/[a-zA-Z]:\//;t.PDFNodeStream=class{constructor(e){this.source=e,this.url=function(e){let t=l.parse(e);return"file:"===t.protocol||t.host?t:/^[a-z]:[/\\]/i.test(e)?l.parse(`file:///${e}`):(t.host||(t.protocol="file:"),t)}(e.url),this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol,this.isFsUrl="file:"===this.url.protocol,this.httpHeaders=this.isHttp&&e.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var e,t;return null!=(t=null==(e=this._fullRequestReader)?void 0:e._loaded)?t:0}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new m(this):new p(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=this.isFsUrl?new g(this,e,t):new f(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){var t;null==(t=this._fullRequestReader)||t.cancel(e);for(let n of this._rangeRequestReaders.slice(0))n.cancel(e)}};class c{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;let t=e.source;this._contentLength=t.length,this._loaded=0,this._filename=null,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._readableStream=null,this._readCapability=new i.PromiseCapability,this._headersCapability=new i.PromiseCapability}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){return ft(this,null,(function*(){var e;if(yield this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return null===t?(this._readCapability=new i.PromiseCapability,this.read()):(this._loaded+=t.length,null==(e=this.onProgress)||e.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}))}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",(()=>{this._readCapability.resolve()})),e.on("end",(()=>{e.destroy(),this._done=!0,this._readCapability.resolve()})),e.on("error",(e=>{this._error(e)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new i.AbortException("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class u{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=new i.PromiseCapability;let t=e.source;this._isStreamingSupported=!t.disableStream}get isStreamingSupported(){return this._isStreamingSupported}read(){return ft(this,null,(function*(){var e;if(yield this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;let t=this._readableStream.read();return null===t?(this._readCapability=new i.PromiseCapability,this.read()):(this._loaded+=t.length,null==(e=this.onProgress)||e.call(this,{loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}))}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",(()=>{this._readCapability.resolve()})),e.on("end",(()=>{e.destroy(),this._done=!0,this._readCapability.resolve()})),e.on("error",(e=>{this._error(e)})),this._storedError&&this._readableStream.destroy(this._storedError)}}function d(e,t){return{protocol:e.protocol,auth:e.auth,host:e.hostname,port:e.port,path:e.path,method:"GET",headers:t}}class p extends c{constructor(e){super(e);let t=t=>{if(404===t.statusCode){let e=new i.MissingPDFException(`Missing PDF "${this._url}".`);return this._storedError=e,void this._headersCapability.reject(e)}this._headersCapability.resolve(),this._setReadableStream(t);let n=e=>this._readableStream.headers[e.toLowerCase()],{allowRangeRequests:a,suggestedLength:s}=(0,r.validateRangeRequestCapabilities)({getResponseHeader:n,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=s||this._contentLength,this._filename=(0,r.extractFilenameFromHeader)(n)};this._request=null,"http:"===this._url.protocol?this._request=s.request(d(this._url,e.httpHeaders),t):this._request=o.request(d(this._url,e.httpHeaders),t),this._request.on("error",(e=>{this._storedError=e,this._headersCapability.reject(e)})),this._request.end()}}class f extends u{constructor(e,t,n){super(e),this._httpHeaders={};for(let i in e.httpHeaders){let t=e.httpHeaders[i];void 0!==t&&(this._httpHeaders[i]=t)}this._httpHeaders.Range=`bytes=${t}-${n-1}`;let r=e=>{if(404!==e.statusCode)this._setReadableStream(e);else{let e=new i.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=e}};this._request=null,"http:"===this._url.protocol?this._request=s.request(d(this._url,this._httpHeaders),r):this._request=o.request(d(this._url,this._httpHeaders),r),this._request.on("error",(e=>{this._storedError=e})),this._request.end()}}class m extends c{constructor(e){super(e);let t=decodeURIComponent(this._url.path);h.test(this._url.href)&&(t=t.replace(/^\//,"")),a.lstat(t,((e,n)=>{if(e)return"ENOENT"===e.code&&(e=new i.MissingPDFException(`Missing PDF "${t}".`)),this._storedError=e,void this._headersCapability.reject(e);this._contentLength=n.size,this._setReadableStream(a.createReadStream(t)),this._headersCapability.resolve()}))}}class g extends u{constructor(e,t,n){super(e);let i=decodeURIComponent(this._url.path);h.test(this._url.href)&&(i=i.replace(/^\//,"")),this._setReadableStream(a.createReadStream(i,{start:t,end:n-1}))}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createResponseStatusError=function(e,t){return 404===e||0===e&&t.startsWith("file:")?new i.MissingPDFException('Missing PDF "'+t+'".'):new i.UnexpectedResponseException(`Unexpected server response (${e}) while retrieving PDF "${t}".`,e)},t.extractFilenameFromHeader=function(e){let t=e("Content-Disposition");if(t){let n=(0,r.getFilenameFromContentDispositionHeader)(t);if(n.includes("%"))try{n=decodeURIComponent(n)}catch(e){}if((0,a.isPdfFile)(n))return n}return null},t.validateRangeRequestCapabilities=function({getResponseHeader:e,isHttp:t,rangeChunkSize:n,disableRange:i}){let r={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(e("Content-Length"),10);return!Number.isInteger(a)||(r.suggestedLength=a,a<=2*n)||i||!t||"bytes"!==e("Accept-Ranges")||"identity"!==(e("Content-Encoding")||"identity")||(r.allowRangeRequests=!0),r},t.validateResponseStatus=function(e){return 200===e||206===e};var i=n(1),r=n(23),a=n(6)},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getFilenameFromContentDispositionHeader=function(e){let t=!0,n=r("filename\\*","i").exec(e);if(n){n=n[1];let e=o(n);return e=unescape(e),e=l(e),e=h(e),s(e)}if(n=function(e){let t,n=[],i=r("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(t=i.exec(e));){let[,e,i,r]=t;if(e=parseInt(e,10),e in n){if(0===e)break}else n[e]=[i,r]}let a=[];for(let r=0;r{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFNetworkStream=void 0;var i=n(1),r=n(22);class a{constructor(e,t={}){this.url=e,this.isHttp=/^https?:/i.test(e),this.httpHeaders=this.isHttp&&t.httpHeaders||Object.create(null),this.withCredentials=t.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(e,t,n){let i={begin:e,end:t};for(let r in n)i[r]=n[r];return this.request(i)}requestFull(e){return this.request(e)}request(e){let t=new XMLHttpRequest,n=this.currXhrId++,i=this.pendingRequests[n]={xhr:t};t.open("GET",this.url),t.withCredentials=this.withCredentials;for(let r in this.httpHeaders){let e=this.httpHeaders[r];void 0!==e&&t.setRequestHeader(r,e)}return this.isHttp&&"begin"in e&&"end"in e?(t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),i.expectedStatus=206):i.expectedStatus=200,t.responseType="arraybuffer",e.onError&&(t.onerror=function(n){e.onError(t.status)}),t.onreadystatechange=this.onStateChange.bind(this,n),t.onprogress=this.onProgress.bind(this,n),i.onHeadersReceived=e.onHeadersReceived,i.onDone=e.onDone,i.onError=e.onError,i.onProgress=e.onProgress,t.send(null),n}onProgress(e,t){var n;let i=this.pendingRequests[e];i&&(null==(n=i.onProgress)||n.call(i,t))}onStateChange(e,t){var n,r,a;let s=this.pendingRequests[e];if(!s)return;let o=s.xhr;if(o.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),4!==o.readyState||!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],0===o.status&&this.isHttp)return void(null==(n=s.onError)||n.call(s,o.status));let l=o.status||200;if((200!==l||206!==s.expectedStatus)&&l!==s.expectedStatus)return void(null==(r=s.onError)||r.call(s,o.status));let h=function(e){let t=e.response;return"string"!=typeof t?t:(0,i.stringToBytes)(t).buffer}(o);if(206===l){let e=o.getResponseHeader("Content-Range"),t=/bytes (\d+)-(\d+)\/(\d+)/.exec(e);s.onDone({begin:parseInt(t[1],10),chunk:h})}else h?s.onDone({begin:0,chunk:h}):null==(a=s.onError)||a.call(s,o.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){let t=this.pendingRequests[e].xhr;delete this.pendingRequests[e],t.abort()}}t.PDFNetworkStream=class{constructor(e){this._source=e,this._manager=new a(e.url,{httpHeaders:e.httpHeaders,withCredentials:e.withCredentials}),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){let t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new s(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){let n=new o(this._manager,e,t);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(e){var t;null==(t=this._fullRequestReader)||t.cancel(e);for(let n of this._rangeRequestReaders.slice(0))n.cancel(e)}};class s{constructor(e,t){this._manager=e;let n={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._fullRequestId=e.requestFull(n),this._headersReceivedCapability=new i.PromiseCapability,this._disableRange=t.disableRange||!1,this._contentLength=t.length,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){let e=this._fullRequestId,t=this._manager.getRequestXhr(e),n=e=>t.getResponseHeader(e),{allowRangeRequests:i,suggestedLength:a}=(0,r.validateRangeRequestCapabilities)({getResponseHeader:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=(0,r.extractFilenameFromHeader)(n),this._isRangeSupported&&this._manager.abortRequest(e),this._headersReceivedCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=(0,r.createResponseStatusError)(e,this._url),this._headersReceivedCapability.reject(this._storedError);for(let t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){var t;null==(t=this.onProgress)||t.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}read(){return ft(this,null,(function*(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let e=new i.PromiseCapability;return this._requests.push(e),e.promise}))}cancel(e){this._done=!0,this._headersReceivedCapability.reject(e);for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class o{constructor(e,t,n){this._manager=e;let i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._requestId=e.requestRange(t,n,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){var e;null==(e=this.onClosed)||e.call(this,this)}_onDone(e){let t=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0;for(let n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError=(0,r.createResponseStatusError)(e,this._url);for(let t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){var t;this.isStreamingSupported||null==(t=this.onProgress)||t.call(this,{loaded:e.loaded})}get isStreamingSupported(){return!1}read(){return ft(this,null,(function*(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let e=new i.PromiseCapability;return this._requests.push(e),e.promise}))}cancel(e){this._done=!0;for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFFetchStream=void 0;var i=n(1),r=n(22);function a(e,t,n){return{method:"GET",headers:e,signal:n.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function s(e){let t=new Headers;for(let n in e){let i=e[n];void 0!==i&&t.append(n,i)}return t}function o(e){return e instanceof Uint8Array?e.buffer:e instanceof ArrayBuffer?e:((0,i.warn)(`getArrayBuffer - unexpected data format: ${e}`),new Uint8Array(e).buffer)}t.PDFFetchStream=class{constructor(e){this.source=e,this.isHttp=/^https?:/i.test(e.url),this.httpHeaders=this.isHttp&&e.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var e,t;return null!=(t=null==(e=this._fullRequestReader)?void 0:e._loaded)?t:0}getFullReader(){return(0,i.assert)(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new l(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new h(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){var t;null==(t=this._fullRequestReader)||t.cancel(e);for(let n of this._rangeRequestReaders.slice(0))n.cancel(e)}};class l{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;let t=e.source;this._withCredentials=t.withCredentials||!1,this._contentLength=t.length,this._headersCapability=new i.PromiseCapability,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._headers=s(this._stream.httpHeaders);let n=t.url;fetch(n,a(this._headers,this._withCredentials,this._abortController)).then((e=>{if(!(0,r.validateResponseStatus)(e.status))throw(0,r.createResponseStatusError)(e.status,n);this._reader=e.body.getReader(),this._headersCapability.resolve();let t=t=>e.headers.get(t),{allowRangeRequests:a,suggestedLength:s}=(0,r.validateRangeRequestCapabilities)({getResponseHeader:t,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=s||this._contentLength,this._filename=(0,r.extractFilenameFromHeader)(t),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new i.AbortException("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}read(){return ft(this,null,(function*(){var e;yield this._headersCapability.promise;let{value:t,done:n}=yield this._reader.read();return n?{value:t,done:n}:(this._loaded+=t.byteLength,null==(e=this.onProgress)||e.call(this,{loaded:this._loaded,total:this._contentLength}),{value:o(t),done:!1})}))}cancel(e){var t;null==(t=this._reader)||t.cancel(e),this._abortController.abort()}}class h{constructor(e,t,n){this._stream=e,this._reader=null,this._loaded=0;let o=e.source;this._withCredentials=o.withCredentials||!1,this._readCapability=new i.PromiseCapability,this._isStreamingSupported=!o.disableStream,this._abortController=new AbortController,this._headers=s(this._stream.httpHeaders),this._headers.append("Range",`bytes=${t}-${n-1}`);let l=o.url;fetch(l,a(this._headers,this._withCredentials,this._abortController)).then((e=>{if(!(0,r.validateResponseStatus)(e.status))throw(0,r.createResponseStatusError)(e.status,l);this._readCapability.resolve(),this._reader=e.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}read(){return ft(this,null,(function*(){var e;yield this._readCapability.promise;let{value:t,done:n}=yield this._reader.read();return n?{value:t,done:n}:(this._loaded+=t.byteLength,null==(e=this.onProgress)||e.call(this,{loaded:this._loaded}),{value:o(t),done:!1})}))}cancel(e){var t;null==(t=this._reader)||t.cancel(e),this._abortController.abort()}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TextLayerRenderTask=void 0,t.renderTextLayer=function(e){!e.textContentSource&&(e.textContent||e.textContentStream)&&((0,r.deprecated)("The TextLayerRender `textContent`/`textContentStream` parameters will be removed in the future, please use `textContentSource` instead."),e.textContentSource=e.textContent||e.textContentStream);let{container:t,viewport:n}=e,i=getComputedStyle(t),a=i.getPropertyValue("visibility"),s=parseFloat(i.getPropertyValue("--scale-factor"));"visible"===a&&(!s||Math.abs(s-n.scale)>1e-5)&&console.error("The `--scale-factor` CSS-variable must be set, to the same value as `viewport.scale`, either on the `container`-element itself or higher up in the DOM.");let o=new c(e);return o._render(),o},t.updateTextLayer=function({container:e,viewport:t,textDivs:n,textDivProperties:i,isOffscreenCanvasSupported:a,mustRotate:s=!0,mustRescale:l=!0}){if(s&&(0,r.setLayerDimensions)(e,{rotation:t.rotation}),l){let e=o(0,a),r={prevFontSize:null,prevFontFamily:null,div:null,scale:t.scale*(globalThis.devicePixelRatio||1),properties:null,ctx:e};for(let t of n)r.properties=i.get(t),r.div=t,h(r)}};var i=n(1),r=n(6);let a=30,s=new Map;function o(e,t){let n;if(t&&i.FeatureTest.isOffscreenCanvasSupported)n=new OffscreenCanvas(e,e).getContext("2d",{alpha:!1});else{let t=document.createElement("canvas");t.width=t.height=e,n=t.getContext("2d",{alpha:!1})}return n}function l(e,t,n){let r=document.createElement("span"),l={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};e._textDivs.push(r);let h=i.Util.transform(e._transform,t.transform),c=Math.atan2(h[1],h[0]),u=n[t.fontName];u.vertical&&(c+=Math.PI/2);let d,p,f=Math.hypot(h[2],h[3]),m=f*function(e,t){let n=s.get(e);if(n)return n;let i=o(a,t);i.font=`30px ${e}`;let r=i.measureText(""),l=r.fontBoundingBoxAscent,h=Math.abs(r.fontBoundingBoxDescent);if(l){let t=l/(l+h);return s.set(e,t),i.canvas.width=i.canvas.height=0,t}i.strokeStyle="red",i.clearRect(0,0,a,a),i.strokeText("g",0,0);let c=i.getImageData(0,0,a,a).data;h=0;for(let s=c.length-1-3;s>=0;s-=4)if(c[s]>0){h=Math.ceil(s/4/a);break}i.clearRect(0,0,a,a),i.strokeText("A",0,a),c=i.getImageData(0,0,a,a).data,l=0;for(let s=0,o=c.length;s0){l=a-Math.floor(s/4/a);break}if(i.canvas.width=i.canvas.height=0,l){let t=l/(l+h);return s.set(e,t),t}return s.set(e,.8),.8}(u.fontFamily,e._isOffscreenCanvasSupported);0===c?(d=h[4],p=h[5]-m):(d=h[4]+m*Math.sin(c),p=h[5]-m*Math.cos(c));let g="calc(var(--scale-factor)*",v=r.style;e._container===e._rootContainer?(v.left=`${(100*d/e._pageWidth).toFixed(2)}%`,v.top=`${(100*p/e._pageHeight).toFixed(2)}%`):(v.left=`${g}${d.toFixed(2)}px)`,v.top=`${g}${p.toFixed(2)}px)`),v.fontSize=`${g}${f.toFixed(2)}px)`,v.fontFamily=u.fontFamily,l.fontSize=f,r.setAttribute("role","presentation"),r.textContent=t.str,r.dir=t.dir,e._fontInspectorEnabled&&(r.dataset.fontName=t.fontName),0!==c&&(l.angle=c*(180/Math.PI));let y=!1;if(t.str.length>1)y=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){let e=Math.abs(t.transform[0]),n=Math.abs(t.transform[3]);e!==n&&Math.max(e,n)/Math.min(e,n)>1.5&&(y=!0)}y&&(l.canvasWidth=u.vertical?t.height:t.width),e._textDivProperties.set(r,l),e._isReadableStream&&e._layoutText(r)}function h(e){let{div:t,scale:n,properties:i,ctx:r,prevFontSize:a,prevFontFamily:s}=e,{style:o}=t,l="";if(0!==i.canvasWidth&&i.hasText){let{fontFamily:h}=o,{canvasWidth:c,fontSize:u}=i;(a!==u||s!==h)&&(r.font=`${u*n}px ${h}`,e.prevFontSize=u,e.prevFontFamily=h);let{width:d}=r.measureText(t.textContent);d>0&&(l=`scaleX(${c*n/d})`)}0!==i.angle&&(l=`rotate(${i.angle}deg) ${l}`),l.length>0&&(o.transform=l)}class c{constructor({textContentSource:e,container:t,viewport:n,textDivs:a,textDivProperties:s,textContentItemsStr:l,isOffscreenCanvasSupported:h}){var c;this._textContentSource=e,this._isReadableStream=e instanceof ReadableStream,this._container=this._rootContainer=t,this._textDivs=a||[],this._textContentItemsStr=l||[],this._isOffscreenCanvasSupported=h,this._fontInspectorEnabled=!(null==(c=globalThis.FontInspector)||!c.enabled),this._reader=null,this._textDivProperties=s||new WeakMap,this._canceled=!1,this._capability=new i.PromiseCapability,this._layoutTextParams={prevFontSize:null,prevFontFamily:null,div:null,scale:n.scale*(globalThis.devicePixelRatio||1),properties:null,ctx:o(0,h)};let{pageWidth:u,pageHeight:d,pageX:p,pageY:f}=n.rawDims;this._transform=[1,0,0,-1,-p,f+d],this._pageWidth=u,this._pageHeight=d,(0,r.setLayerDimensions)(t,n),this._capability.promise.finally((()=>{this._layoutTextParams=null})).catch((()=>{}))}get promise(){return this._capability.promise}cancel(){this._canceled=!0,this._reader&&(this._reader.cancel(new i.AbortException("TextLayer task cancelled.")).catch((()=>{})),this._reader=null),this._capability.reject(new i.AbortException("TextLayer task cancelled."))}_processItems(e,t){for(let n of e)if(void 0!==n.str)this._textContentItemsStr.push(n.str),l(this,n,t);else if("beginMarkedContentProps"===n.type||"beginMarkedContent"===n.type){let e=this._container;this._container=document.createElement("span"),this._container.classList.add("markedContent"),null!==n.id&&this._container.setAttribute("id",`${n.id}`),e.append(this._container)}else"endMarkedContent"===n.type&&(this._container=this._container.parentNode)}_layoutText(e){let t=this._layoutTextParams.properties=this._textDivProperties.get(e);if(this._layoutTextParams.div=e,h(this._layoutTextParams),t.hasText&&this._container.append(e),t.hasEOL){let e=document.createElement("br");e.setAttribute("role","presentation"),this._container.append(e)}}_render(){let e=new i.PromiseCapability,t=Object.create(null);if(this._isReadableStream){let n=()=>{this._reader.read().then((({value:i,done:r})=>{r?e.resolve():(Object.assign(t,i.styles),this._processItems(i.items,t),n())}),e.reject)};this._reader=this._textContentSource.getReader(),n()}else{if(!this._textContentSource)throw new Error('No "textContentSource" parameter specified.');{let{items:t,styles:n}=this._textContentSource;this._processItems(t,n),e.resolve()}}e.promise.then((()=>{t=null,function(e){if(e._canceled)return;let t=e._textDivs,n=e._capability;if(t.length>1e5)n.resolve();else{if(!e._isReadableStream)for(let n of t)e._layoutText(n);n.resolve()}}(this)}),this._capability.reject)}}t.TextLayerRenderTask=c},(e,t,n)=>{var i,r,a,s,o,l,h,c,u,d,p,f,m,g,v,y,x,b;Object.defineProperty(t,"__esModule",{value:!0}),t.AnnotationEditorLayer=void 0;var _=n(1),w=n(4),S=n(5),M=n(28),T=n(33),E=n(6);let A=class{constructor(e){Je(this,p),Je(this,m),Je(this,v),Je(this,x),Je(this,i,void 0),Je(this,r,!1),Je(this,a,null),Je(this,s,this.pointerup.bind(this)),Je(this,o,this.pointerdown.bind(this)),Je(this,l,new Map),Je(this,h,!1),Je(this,c,!1),Je(this,u,!1),Je(this,d,void 0),A._initialized||(A._initialized=!0,M.FreeTextEditor.initialize(e.l10n),T.InkEditor.initialize(e.l10n)),e.uiManager.registerEditorTypes([M.FreeTextEditor,T.InkEditor]),St(this,d,e.uiManager),this.pageIndex=e.pageIndex,this.div=e.div,St(this,i,e.accessibilityManager),St(this,a,e.annotationLayer),this.viewport=e.viewport,ce(this,d).addLayer(this)}get isEmpty(){return 0===ce(this,l).size}updateToolbar(e){ce(this,d).updateToolbar(e)}updateMode(e=ce(this,d).getMode()){dt(this,x,b).call(this),e===_.AnnotationEditorType.INK?(this.addInkEditorIfNeeded(!1),this.disableClick()):this.enableClick(),ce(this,d).unselectAll(),e!==_.AnnotationEditorType.NONE&&(this.div.classList.toggle("freeTextEditing",e===_.AnnotationEditorType.FREETEXT),this.div.classList.toggle("inkEditing",e===_.AnnotationEditorType.INK),this.div.hidden=!1)}addInkEditorIfNeeded(e){if(e||ce(this,d).getMode()===_.AnnotationEditorType.INK){if(!e)for(let e of ce(this,l).values())if(e.isEmpty())return void e.setInBackground();dt(this,v,y).call(this,{offsetX:0,offsetY:0}).setInBackground()}}setEditingState(e){ce(this,d).setEditingState(e)}addCommands(e){ce(this,d).addCommands(e)}enable(){this.div.style.pointerEvents="auto";let e=new Set;for(let n of ce(this,l).values())n.enableEditing(),n.annotationElementId&&e.add(n.annotationElementId);if(!ce(this,a))return;let t=ce(this,a).getEditableAnnotations();for(let n of t){if(n.hide(),ce(this,d).isDeletedAnnotationElement(n.data.id)||e.has(n.data.id))continue;let t=this.deserialize(n);t&&(this.addOrRebuild(t),t.enableEditing())}}disable(){var e;St(this,u,!0),this.div.style.pointerEvents="none";let t=new Set;for(let n of ce(this,l).values())n.disableEditing(),n.annotationElementId&&null===n.serialize()?(null==(e=this.getEditableAnnotation(n.annotationElementId))||e.show(),n.remove()):t.add(n.annotationElementId);if(ce(this,a)){let e=ce(this,a).getEditableAnnotations();for(let n of e){let{id:e}=n.data;t.has(e)||ce(this,d).isDeletedAnnotationElement(e)||n.show()}}dt(this,x,b).call(this),this.isEmpty&&(this.div.hidden=!0),St(this,u,!1)}getEditableAnnotation(e){var t;return(null==(t=ce(this,a))?void 0:t.getEditableAnnotation(e))||null}setActiveEditor(e){ce(this,d).getActive()!==e&&ce(this,d).setActiveEditor(e)}enableClick(){this.div.addEventListener("pointerdown",ce(this,o)),this.div.addEventListener("pointerup",ce(this,s))}disableClick(){this.div.removeEventListener("pointerdown",ce(this,o)),this.div.removeEventListener("pointerup",ce(this,s))}attach(e){ce(this,l).set(e.id,e);let{annotationElementId:t}=e;t&&ce(this,d).isDeletedAnnotationElement(t)&&ce(this,d).removeDeletedAnnotationElement(e)}detach(e){var t;ce(this,l).delete(e.id),null==(t=ce(this,i))||t.removePointerInTextLayer(e.contentDiv),!ce(this,u)&&e.annotationElementId&&ce(this,d).addDeletedAnnotationElement(e)}remove(e){this.detach(e),ce(this,d).removeEditor(e),e.div.style.display="none",setTimeout((()=>{e.div.style.display="",e.div.remove(),e.isAttachedToDOM=!1,document.activeElement===document.body&&ce(this,d).focusMainContainer()}),0),ce(this,c)||this.addInkEditorIfNeeded(!1)}add(e){if(dt(this,p,f).call(this,e),ce(this,d).addEditor(e),this.attach(e),!e.isAttachedToDOM){let t=e.render();this.div.append(t),e.isAttachedToDOM=!0}this.moveEditorInDOM(e),e.onceAdded(),ce(this,d).addToAnnotationStorage(e)}moveEditorInDOM(e){var t;null==(t=ce(this,i))||t.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?e.rebuild():this.add(e)}getNextId(){return ce(this,d).getId()}deserialize(e){var t;switch(null!=(t=e.annotationType)?t:e.annotationEditorType){case _.AnnotationEditorType.FREETEXT:return M.FreeTextEditor.deserialize(e,this,ce(this,d));case _.AnnotationEditorType.INK:return T.InkEditor.deserialize(e,this,ce(this,d))}return null}setSelected(e){ce(this,d).setSelected(e)}toggleSelected(e){ce(this,d).toggleSelected(e)}isSelected(e){return ce(this,d).isSelected(e)}unselect(e){ce(this,d).unselect(e)}pointerup(e){let{isMac:t}=_.FeatureTest.platform;if(!(0!==e.button||e.ctrlKey&&t)&&e.target===this.div&&ce(this,h)){if(St(this,h,!1),!ce(this,r))return void St(this,r,!0);dt(this,v,y).call(this,e)}}pointerdown(e){let{isMac:t}=_.FeatureTest.platform;if(0!==e.button||e.ctrlKey&&t||e.target!==this.div)return;St(this,h,!0);let n=ce(this,d).getActive();St(this,r,!n||n.isEmpty())}drop(e){let t=e.dataTransfer.getData("text/plain"),n=ce(this,d).getEditor(t);if(!n)return;e.preventDefault(),e.dataTransfer.dropEffect="move",dt(this,p,f).call(this,n);let i=this.div.getBoundingClientRect(),r=e.clientX-i.x,a=e.clientY-i.y;n.translate(r-n.startX,a-n.startY),this.moveEditorInDOM(n),n.div.focus()}dragover(e){e.preventDefault()}destroy(){var e,t;(null==(e=ce(this,d).getActive())?void 0:e.parent)===this&&ce(this,d).setActiveEditor(null);for(let n of ce(this,l).values())null==(t=ce(this,i))||t.removePointerInTextLayer(n.contentDiv),n.setParent(null),n.isAttachedToDOM=!1,n.div.remove();this.div=null,ce(this,l).clear(),ce(this,d).removeLayer(this)}render({viewport:e}){this.viewport=e,(0,E.setLayerDimensions)(this.div,e),(0,S.bindEvents)(this,this.div,["dragover","drop"]);for(let t of ce(this,d).getEditors(this.pageIndex))this.add(t);this.updateMode()}update({viewport:e}){ce(this,d).commitOrRemove(),this.viewport=e,(0,E.setLayerDimensions)(this.div,{rotation:e.rotation}),this.updateMode()}get pageDimensions(){let{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}},C=A;i=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,u=new WeakMap,d=new WeakMap,p=new WeakSet,f=function(e){var t;e.parent!==this&&(e.annotationElementId&&(ce(this,d).addDeletedAnnotationElement(e.annotationElementId),w.AnnotationEditor.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),null==(t=e.parent)||t.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))},m=new WeakSet,g=function(e){switch(ce(this,d).getMode()){case _.AnnotationEditorType.FREETEXT:return new M.FreeTextEditor(e);case _.AnnotationEditorType.INK:return new T.InkEditor(e)}return null},v=new WeakSet,y=function(e){let t=this.getNextId(),n=dt(this,m,g).call(this,{parent:this,id:t,x:e.offsetX,y:e.offsetY,uiManager:ce(this,d)});return n&&this.add(n),n},x=new WeakSet,b=function(){St(this,c,!0);for(let e of ce(this,l).values())e.isEmpty()&&e.remove();St(this,c,!1)},Xi(C,"_initialized",!1),t.AnnotationEditorLayer=C},(e,t,n)=>{var i,r,a,s,o,l,h,c,u,d,p,f,m,g,v,y,x,b,_,w,S,M,T;Object.defineProperty(t,"__esModule",{value:!0}),t.FreeTextEditor=void 0;var E=n(1),A=n(5),C=n(4),P=n(29);let R=class extends C.AnnotationEditor{constructor(e){super(Ri(Tr({},e),{name:"freeTextEditor"})),Je(this,d),Je(this,f),Je(this,g),Je(this,y),Je(this,b),Je(this,w),Je(this,M),Je(this,i,this.editorDivBlur.bind(this)),Je(this,r,this.editorDivFocus.bind(this)),Je(this,a,this.editorDivInput.bind(this)),Je(this,s,this.editorDivKeydown.bind(this)),Je(this,o,void 0),Je(this,l,""),Je(this,h,`${this.id}-editor`),Je(this,c,void 0),Je(this,u,null),St(this,o,e.color||R._defaultColor||C.AnnotationEditor._defaultLineColor),St(this,c,e.fontSize||R._defaultFontSize)}static get _keyboardManager(){return(0,E.shadow)(this,"_keyboardManager",new A.KeyboardManager([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],R.prototype.commitOrRemove,!0],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],R.prototype.commitOrRemove]]))}static initialize(e){this._l10nPromise=new Map(["free_text2_default_content","editor_free_text2_aria_label"].map((t=>[t,e.get(t)])));let t=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(t.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,t){switch(e){case E.AnnotationEditorParamsType.FREETEXT_SIZE:R._defaultFontSize=t;break;case E.AnnotationEditorParamsType.FREETEXT_COLOR:R._defaultColor=t}}updateParams(e,t){switch(e){case E.AnnotationEditorParamsType.FREETEXT_SIZE:dt(this,d,p).call(this,t);break;case E.AnnotationEditorParamsType.FREETEXT_COLOR:dt(this,f,m).call(this,t)}}static get defaultPropertiesToUpdate(){return[[E.AnnotationEditorParamsType.FREETEXT_SIZE,R._defaultFontSize],[E.AnnotationEditorParamsType.FREETEXT_COLOR,R._defaultColor||C.AnnotationEditor._defaultLineColor]]}get propertiesToUpdate(){return[[E.AnnotationEditorParamsType.FREETEXT_SIZE,ce(this,c)],[E.AnnotationEditorParamsType.FREETEXT_COLOR,ce(this,o)]]}getInitialTranslation(){let e=this.parentScale;return[-R._internalPadding*e,-(R._internalPadding+ce(this,c))*e]}rebuild(){super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this))}enableEditMode(){this.isInEditMode()||(this.parent.setEditingState(!1),this.parent.updateToolbar(E.AnnotationEditorType.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this.div.draggable=!1,this.div.removeAttribute("aria-activedescendant"),this.editorDiv.addEventListener("keydown",ce(this,s)),this.editorDiv.addEventListener("focus",ce(this,r)),this.editorDiv.addEventListener("blur",ce(this,i)),this.editorDiv.addEventListener("input",ce(this,a)))}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",ce(this,h)),this.div.draggable=!0,this.editorDiv.removeEventListener("keydown",ce(this,s)),this.editorDiv.removeEventListener("focus",ce(this,r)),this.editorDiv.removeEventListener("blur",ce(this,i)),this.editorDiv.removeEventListener("input",ce(this,a)),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freeTextEditing"))}focusin(e){super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus()}onceAdded(){this.width?dt(this,M,T).call(this):(this.enableEditMode(),this.editorDiv.focus())}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent.setEditingState(!0),this.parent.div.classList.add("freeTextEditing"),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let e=ce(this,l),t=St(this,l,dt(this,g,v).call(this).trimEnd());if(e===t)return;let n=e=>{St(this,l,e),e?(dt(this,b,_).call(this),this.rebuild(),dt(this,y,x).call(this)):this.remove()};this.addCommands({cmd:()=>{n(t)},undo:()=>{n(e)},mustExec:!1}),dt(this,y,x).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}dblclick(e){this.enableEditMode(),this.editorDiv.focus()}keydown(e){e.target===this.div&&"Enter"===e.key&&(this.enableEditMode(),this.editorDiv.focus())}editorDivKeydown(e){R._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freeTextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let e,t;this.width&&(e=this.x,t=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",ce(this,h)),this.enableEditing(),R._l10nPromise.get("editor_free_text2_aria_label").then((e=>{var t;return null==(t=this.editorDiv)?void 0:t.setAttribute("aria-label",e)})),R._l10nPromise.get("free_text2_default_content").then((e=>{var t;return null==(t=this.editorDiv)?void 0:t.setAttribute("default-content",e)})),this.editorDiv.contentEditable=!0;let{style:n}=this.editorDiv;if(n.fontSize=`calc(${ce(this,c)}px * var(--scale-factor))`,n.color=ce(this,o),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),(0,A.bindEvents)(this,this.div,["dblclick","keydown"]),this.width){let[n,i]=this.parentDimensions;if(this.annotationElementId){let[r]=this.getInitialTranslation();this.setAt(e*n,t*i,r,r)}else this.setAt(e*n,t*i,this.width*n,this.height*i);dt(this,b,_).call(this),this.div.draggable=!0,this.editorDiv.contentEditable=!1}else this.div.draggable=!1,this.editorDiv.contentEditable=!0;return this.div}get contentDiv(){return this.editorDiv}static deserialize(e,t,n){let i=null;if(e instanceof P.FreeTextAnnotationElement){let{data:{defaultAppearanceData:{fontSize:t,fontColor:n},rect:r,rotation:a,id:s},textContent:o,parent:{page:{pageNumber:l}}}=e;if(!o||0===o.length)return null;i=e={annotationType:E.AnnotationEditorType.FREETEXT,color:Array.from(n),fontSize:t,value:o.join("\n"),pageIndex:l-1,rect:r,rotation:a,id:s,deleted:!1}}let r=super.deserialize(e,t,n);return St(r,c,e.fontSize),St(r,o,E.Util.makeHexColor(...e.color)),St(r,l,e.value),r.annotationElementId=e.id||null,St(r,u,i),r}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};let t=R._internalPadding*this.parentScale,n=this.getRect(t,t),i=C.AnnotationEditor._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:ce(this,o)),r={annotationType:E.AnnotationEditorType.FREETEXT,color:i,fontSize:ce(this,c),value:ce(this,l),pageIndex:this.pageIndex,rect:n,rotation:this.rotation};return e?r:this.annotationElementId&&!dt(this,w,S).call(this,r)?null:(r.id=this.annotationElementId,r)}},O=R;i=new WeakMap,r=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,u=new WeakMap,d=new WeakSet,p=function(e){let t=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--scale-factor))`,this.translate(0,-(e-ce(this,c))*this.parentScale),St(this,c,e),dt(this,y,x).call(this)},n=ce(this,c);this.addCommands({cmd:()=>{t(e)},undo:()=>{t(n)},mustExec:!0,type:E.AnnotationEditorParamsType.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},f=new WeakSet,m=function(e){let t=ce(this,o);this.addCommands({cmd:()=>{St(this,o,this.editorDiv.style.color=e)},undo:()=>{St(this,o,this.editorDiv.style.color=t)},mustExec:!0,type:E.AnnotationEditorParamsType.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},g=new WeakSet,v=function(){let e=this.editorDiv.getElementsByTagName("div");if(0===e.length)return this.editorDiv.innerText;let t=[];for(let n of e)t.push(n.innerText.replace(/\r\n?|\n/,""));return t.join("\n")},y=new WeakSet,x=function(){let e,[t,n]=this.parentDimensions;if(this.isAttachedToDOM)e=this.div.getBoundingClientRect();else{let{currentLayer:t,div:n}=this,i=n.style.display;n.style.display="hidden",t.div.append(this.div),e=n.getBoundingClientRect(),n.remove(),n.style.display=i}this.width=e.width/t,this.height=e.height/n},b=new WeakSet,_=function(){if(this.editorDiv.replaceChildren(),ce(this,l))for(let e of ce(this,l).split("\n")){let t=document.createElement("div");t.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(t)}},w=new WeakSet,S=function(e){let{value:t,fontSize:n,color:i,rect:r,pageIndex:a}=ce(this,u);return e.value!==t||e.fontSize!==n||e.rect.some(((e,t)=>Math.abs(e-r[t])>=1))||e.color.some(((e,t)=>e!==i[t]))||e.pageIndex!==a},M=new WeakSet,T=function(e=!1){if(!this.annotationElementId)return;if(dt(this,y,x).call(this),!e&&(0===this.width||0===this.height))return void setTimeout((()=>dt(this,M,T).call(this,!0)),0);let t=R._internalPadding*this.parentScale;ce(this,u).rect=this.getRect(t,t)},Xi(O,"_freeTextDefaultContent",""),Xi(O,"_l10nPromise"),Xi(O,"_internalPadding",0),Xi(O,"_defaultColor",null),Xi(O,"_defaultFontSize",10),Xi(O,"_type","freetext"),t.FreeTextEditor=O},(e,t,n)=>{var i,r,a,s,o,l,h,c,u,d,p,f,m,g,v,y,x,b,_,w,S,M,T,E,A,C,P,R,O,L,I,D,k,N,F,U,B,z,H;Object.defineProperty(t,"__esModule",{value:!0}),t.InkAnnotationElement=t.FreeTextAnnotationElement=t.AnnotationLayer=void 0;var V=n(1),j=n(6),G=n(3),W=n(30),X=n(31);let Y=1e3,q=new WeakSet;function J(e){return{width:e[2]-e[0],height:e[3]-e[1]}}class Z{static create(e){switch(e.data.annotationType){case V.AnnotationType.LINK:return new $(e);case V.AnnotationType.TEXT:return new Q(e);case V.AnnotationType.WIDGET:switch(e.data.fieldType){case"Tx":return new te(e);case"Btn":return e.data.radioButton?new re(e):e.data.checkBox?new ie(e):new ae(e);case"Ch":return new se(e);case"Sig":return new ne(e)}return new ee(e);case V.AnnotationType.POPUP:return new oe(e);case V.AnnotationType.FREETEXT:return new he(e);case V.AnnotationType.LINE:return new ue(e);case V.AnnotationType.SQUARE:return new de(e);case V.AnnotationType.CIRCLE:return new pe(e);case V.AnnotationType.POLYLINE:return new fe(e);case V.AnnotationType.CARET:return new ge(e);case V.AnnotationType.INK:return new ve(e);case V.AnnotationType.POLYGON:return new me(e);case V.AnnotationType.HIGHLIGHT:return new ye(e);case V.AnnotationType.UNDERLINE:return new xe(e);case V.AnnotationType.SQUIGGLY:return new be(e);case V.AnnotationType.STRIKEOUT:return new _e(e);case V.AnnotationType.STAMP:return new we(e);case V.AnnotationType.FILEATTACHMENT:return new Se(e);default:return new K(e)}}}class K{constructor(e,{isRenderable:t=!1,ignoreBorder:n=!1,createQuadrilaterals:i=!1}={}){this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,t&&(this.container=this._createContainer(n)),i&&(this.quadrilaterals=this._createQuadrilaterals(n))}_createContainer(e){let{data:t,parent:{page:n,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",t.id),r.style.zIndex=this.parent.zIndex++,this.data.popupRef&&r.setAttribute("aria-haspopup","dialog"),t.noRotate&&r.classList.add("norotate");let{pageWidth:a,pageHeight:s,pageX:o,pageY:l}=i.rawDims;if(!t.rect||this instanceof oe){let{rotation:e}=t;return!t.hasOwnCanvas&&0!==e&&this.setRotation(e,r),r}let{width:h,height:c}=J(t.rect),u=V.Util.normalizeRect([t.rect[0],n.view[3]-t.rect[1]+n.view[1],t.rect[2],n.view[3]-t.rect[3]+n.view[1]]);if(!e&&t.borderStyle.width>0){r.style.borderWidth=`${t.borderStyle.width}px`;let e=t.borderStyle.horizontalCornerRadius,n=t.borderStyle.verticalCornerRadius;if(e>0||n>0){let t=`calc(${e}px * var(--scale-factor)) / calc(${n}px * var(--scale-factor))`;r.style.borderRadius=t}else if(this instanceof re){let e=`calc(${h}px * var(--scale-factor)) / calc(${c}px * var(--scale-factor))`;r.style.borderRadius=e}switch(t.borderStyle.style){case V.AnnotationBorderStyleType.SOLID:r.style.borderStyle="solid";break;case V.AnnotationBorderStyleType.DASHED:r.style.borderStyle="dashed";break;case V.AnnotationBorderStyleType.BEVELED:(0,V.warn)("Unimplemented border style: beveled");break;case V.AnnotationBorderStyleType.INSET:(0,V.warn)("Unimplemented border style: inset");break;case V.AnnotationBorderStyleType.UNDERLINE:r.style.borderBottomStyle="solid"}let i=t.borderColor||null;i?r.style.borderColor=V.Util.makeHexColor(0|i[0],0|i[1],0|i[2]):r.style.borderWidth=0}r.style.left=100*(u[0]-o)/a+"%",r.style.top=100*(u[1]-l)/s+"%";let{rotation:d}=t;return t.hasOwnCanvas||0===d?(r.style.width=100*h/a+"%",r.style.height=100*c/s+"%"):this.setRotation(d,r),r}setRotation(e,t=this.container){let n,i,{pageWidth:r,pageHeight:a}=this.parent.viewport.rawDims,{width:s,height:o}=J(this.data.rect);e%180==0?(n=100*s/r,i=100*o/a):(n=100*o/r,i=100*s/a),t.style.width=`${n}%`,t.style.height=`${i}%`,t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){let e=(e,t,n)=>{let i=n.detail[e];n.target.style[t]=W.ColorConverters[`${i[0]}_HTML`](i.slice(1))};return(0,V.shadow)(this,"_commonActions",{display:e=>{let t=e.detail.display%2==1;this.container.style.visibility=t?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{hidden:t,print:0===e.detail.display||3===e.detail.display})},print:e=>{this.annotationStorage.setValue(this.data.id,{print:e.detail.print})},hidden:e=>{this.container.style.visibility=e.detail.hidden?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{hidden:e.detail.hidden})},focus:e=>{setTimeout((()=>e.target.focus({preventScroll:!1})),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.detail.readonly?e.target.setAttribute("readonly",""):e.target.removeAttribute("readonly")},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:t=>{e("bgColor","backgroundColor",t)},fillColor:t=>{e("fillColor","backgroundColor",t)},fgColor:t=>{e("fgColor","color",t)},textColor:t=>{e("textColor","color",t)},borderColor:t=>{e("borderColor","borderColor",t)},strokeColor:t=>{e("strokeColor","borderColor",t)},rotation:e=>{let t=e.detail.rotation;this.setRotation(t),this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){let n=this._commonActions;for(let i of Object.keys(t.detail)){let r=e[i]||n[i];null==r||r(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;let t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;let n=this._commonActions;for(let[i,r]of Object.entries(t)){let a=n[i];a&&(a({detail:{[i]:r},target:e}),delete t[i])}}_createQuadrilaterals(e=!1){if(!this.data.quadPoints)return null;let t=[],n=this.data.rect,i=null;for(let r of this.data.quadPoints)this.data.rect=[r[2].x,r[2].y,r[1].x,r[1].y],t.push(this._createContainer(e)),i||(i=this.data.rect);return this.data.rect=n,this.firstQuadRect=i,t}_createPopup(){let{container:e,data:t}=this;e.setAttribute("aria-haspopup","dialog");let n=new oe({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:this.firstQuadRect||t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(n.render())}_renderQuadrilaterals(e){for(let t of this.quadrilaterals)t.classList.add(e);return this.quadrilaterals}render(){(0,V.unreachable)("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){let n=[];if(this._fieldObjects){let i=this._fieldObjects[e];if(i)for(let{page:e,id:r,exportValues:a}of i){if(-1===e||r===t)continue;let i="string"==typeof a?a:null,s=document.querySelector(`[data-element-id="${r}"]`);!s||q.has(s)?n.push({id:r,exportValue:i,domElement:s}):(0,V.warn)(`_getElementsByName - element not allowed: ${r}`)}return n}for(let i of document.getElementsByName(e)){let{exportValue:e}=i,r=i.getAttribute("data-element-id");r!==t&&q.has(i)&&n.push({id:r,exportValue:e,domElement:i})}return n}show(){var e;this.container&&(this.container.hidden=!1),null==(e=this.popup)||e.maybeShow()}hide(){var e;this.container&&(this.container.hidden=!0),null==(e=this.popup)||e.forceHide()}getElementsToTriggerPopup(){return this.quadrilaterals||this.container}addHighlightArea(){let e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(let t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}}class $ extends K{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!(null==t||!t.ignoreBorder),createQuadrilaterals:!0}),Je(this,i),Je(this,a),this.isTooltipOnly=e.data.isTooltipOnly}render(){let{data:e,linkService:t}=this,n=document.createElement("a");n.setAttribute("data-element-id",e.id);let i=!1;return e.url?(t.addLinkAttributes(n,e.url,e.newWindow),i=!0):e.action?(this._bindNamedAction(n,e.action),i=!0):e.attachment?(this._bindAttachment(n,e.attachment),i=!0):e.setOCGState?(dt(this,a,s).call(this,n,e.setOCGState),i=!0):e.dest?(this._bindLink(n,e.dest),i=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),i=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(n,""),i=!0)),this.quadrilaterals?this._renderQuadrilaterals("linkAnnotation").map(((e,t)=>{let i=0===t?n:n.cloneNode();return e.append(i),e})):(this.container.classList.add("linkAnnotation"),i&&this.container.append(n),this.container)}_bindLink(e,t){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.goToDestination(t),!1),(t||""===t)&&dt(this,i,r).call(this)}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),dt(this,i,r).call(this)}_bindAttachment(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>{var e;return null==(e=this.downloadManager)||e.openOrDownloadData(this.container,t.content,t.filename),!1},dt(this,i,r).call(this)}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl("");let n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let i of Object.keys(t.actions)){let r=n.get(i);r&&(e[r]=()=>{var e;return null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t.id,name:i}}),!1})}e.onclick||(e.onclick=()=>!1),dt(this,i,r).call(this)}_bindResetFormAction(e,t){let n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl("")),dt(this,i,r).call(this),!this._fieldObjects)return(0,V.warn)('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(n||(e.onclick=()=>!1));e.onclick=()=>{var e;null==n||n();let{fields:i,refs:r,include:a}=t,s=[];if(0!==i.length||0!==r.length){let e=new Set(r);for(let t of i){let n=this._fieldObjects[t]||[];for(let{id:t}of n)e.add(t)}for(let t of Object.values(this._fieldObjects))for(let n of t)e.has(n.id)===a&&s.push(n)}else for(let t of Object.values(this._fieldObjects))s.push(...t);let o=this.annotationStorage,l=[];for(let t of s){let{id:e}=t;switch(l.push(e),t.type){case"text":{let n=t.defaultValue||"";o.setValue(e,{value:n});break}case"checkbox":case"radiobutton":{let n=t.defaultValue===t.exportValues;o.setValue(e,{value:n});break}case"combobox":case"listbox":{let n=t.defaultValue||"";o.setValue(e,{value:n});break}default:continue}let n=document.querySelector(`[data-element-id="${e}"]`);n&&(q.has(n)?n.dispatchEvent(new Event("resetform")):(0,V.warn)(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&(null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:l,name:"ResetForm"}})),!1}}}i=new WeakSet,r=function(){this.container.setAttribute("data-internal-link","")},a=new WeakSet,s=function(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(t),!1),dt(this,i,r).call(this)};class Q extends K{constructor(e){var t,n,i;super(e,{isRenderable:!!(e.data.popupRef||null!=(t=e.data.titleObj)&&t.str||null!=(n=e.data.contentsObj)&&n.str||null!=(i=e.data.richText)&&i.str)})}render(){this.container.classList.add("textAnnotation");let e=document.createElement("img");return e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.alt="[{{type}} Annotation]",e.dataset.l10nId="text_annotation_type",e.dataset.l10nArgs=JSON.stringify({type:this.data.name}),this.data.popupRef||this._createPopup(),this.container.append(e),this.container}}class ee extends K{render(){return this.data.alternativeText&&(this.container.title=this.data.alternativeText),this.container}showElementAndHideCanvas(e){var t;this.data.hasOwnCanvas&&("CANVAS"===(null==(t=e.previousSibling)?void 0:t.nodeName)&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){let{isWin:t,isMac:n}=V.FeatureTest.platform;return t&&e.ctrlKey||n&&e.metaKey}_setEventListener(e,t,n,i){t.includes("mouse")?e.addEventListener(t,(e=>{var t;null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:i(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})})):e.addEventListener(t,(e=>{var t;null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:i(e)}})}))}_setEventListeners(e,t,n){var i;for(let[r,a]of t)("Action"===a||null!=(i=this.data.actions)&&i[a])&&this._setEventListener(e,r,a,n)}_setBackgroundColor(e){let t=this.data.backgroundColor||null;e.style.backgroundColor=null===t?"transparent":V.Util.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){let t,{fontColor:n}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||9,r=e.style,a=e=>Math.round(10*e)/10;if(this.data.multiLine){let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),n=e/(Math.round(e/(V.LINE_FACTOR*i))||1);t=Math.min(i,a(n/V.LINE_FACTOR))}else{let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);t=Math.min(i,a(e/V.LINE_FACTOR))}r.fontSize=`calc(${t}px * var(--scale-factor))`,r.color=V.Util.makeHexColor(n[0],n[1],n[2]),null!==this.data.textAlignment&&(r.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",t)}}class te extends ee{constructor(e){super(e,{isRenderable:e.renderForms||!e.data.hasAppearance&&!!e.data.fieldValue})}setPropertyOnSiblings(e,t,n,i){let r=this.annotationStorage;for(let a of this._getElementsByName(e.name,e.id))a.domElement&&(a.domElement[t]=n),r.setValue(a.id,{[i]:n})}render(){var e,t;let n=this.annotationStorage,i=this.data.id;this.container.classList.add("textWidgetAnnotation");let r=null;if(this.renderForms){let a=n.getValue(i,{value:this.data.fieldValue}),s=a.value||"",o=n.getValue(i,{charLimit:this.data.maxLen}).charLimit;o&&s.length>o&&(s=s.slice(0,o));let l=a.formattedValue||(null==(e=this.data.textContent)?void 0:e.join("\n"))||null;l&&this.data.comb&&(l=l.replaceAll(/\s+/g,""));let h={userValue:s,formattedValue:l,lastCommittedValue:null,commitKey:1};this.data.multiLine?(r=document.createElement("textarea"),r.textContent=null!=l?l:s,this.data.doNotScroll&&(r.style.overflowY="hidden")):(r=document.createElement("input"),r.type="text",r.setAttribute("value",null!=l?l:s),this.data.doNotScroll&&(r.style.overflowX="hidden")),this.data.hasOwnCanvas&&(r.hidden=!0),q.add(r),r.setAttribute("data-element-id",i),r.disabled=this.data.readOnly,r.name=this.data.baseFieldName||this.data.fieldName,r.tabIndex=Y,this._setRequired(r,this.data.required),o&&(r.maxLength=o),r.addEventListener("input",(e=>{n.setValue(i,{value:e.target.value}),this.setPropertyOnSiblings(r,"value",e.target.value,"value"),h.formattedValue=null})),r.addEventListener("resetform",(e=>{var t;let n=null!=(t=this.data.defaultFieldValue)?t:"";r.value=h.userValue=n,h.formattedValue=null}));let c=e=>{let{formattedValue:t}=h;null!=t&&(e.target.value=t),e.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){r.addEventListener("focus",(e=>{let{target:t}=e;h.userValue&&(t.value=h.userValue),h.lastCommittedValue=t.value,h.commitKey=1})),r.addEventListener("updatefromsandbox",(e=>{this.showElementAndHideCanvas(e.target);let t={value(e){var t;h.userValue=null!=(t=e.detail.value)?t:"",n.setValue(i,{value:h.userValue.toString()}),e.target.value=h.userValue},formattedValue(e){let{formattedValue:t}=e.detail;h.formattedValue=t,null!=t&&e.target!==document.activeElement&&(e.target.value=t),n.setValue(i,{formattedValue:t})},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:e=>{var t;let{charLimit:r}=e.detail,{target:a}=e;if(0===r)return void a.removeAttribute("maxLength");a.setAttribute("maxLength",r);let s=h.userValue;!s||s.length<=r||(s=s.slice(0,r),a.value=h.userValue=s,n.setValue(i,{value:s}),null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:s,willCommit:!0,commitKey:1,selStart:a.selectionStart,selEnd:a.selectionEnd}}))}};this._dispatchEventFromSandbox(t,e)})),r.addEventListener("keydown",(e=>{var t;h.commitKey=1;let n=-1;if("Escape"===e.key?n=0:"Enter"!==e.key||this.data.multiLine?"Tab"===e.key&&(h.commitKey=3):n=2,-1===n)return;let{value:r}=e.target;h.lastCommittedValue!==r&&(h.lastCommittedValue=r,h.userValue=r,null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:r,willCommit:!0,commitKey:n,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}))}));let e=c;c=null,r.addEventListener("blur",(t=>{var n;if(!t.relatedTarget)return;let{value:r}=t.target;h.userValue=r,h.lastCommittedValue!==r&&(null==(n=this.linkService.eventBus)||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:r,willCommit:!0,commitKey:h.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}})),e(t)})),null!=(t=this.data.actions)&&t.Keystroke&&r.addEventListener("beforeinput",(e=>{var t;h.lastCommittedValue=null;let{data:n,target:r}=e,{value:a,selectionStart:s,selectionEnd:o}=r,l=s,c=o;switch(e.inputType){case"deleteWordBackward":{let e=a.substring(0,s).match(/\w*[^\w]*$/);e&&(l-=e[0].length);break}case"deleteWordForward":{let e=a.substring(s).match(/^[^\w]*\w*/);e&&(c+=e[0].length);break}case"deleteContentBackward":s===o&&(l-=1);break;case"deleteContentForward":s===o&&(c+=1)}e.preventDefault(),null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:a,change:n||"",willCommit:!1,selStart:l,selEnd:c}})})),this._setEventListeners(r,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.value))}if(c&&r.addEventListener("blur",c),this.data.comb){let e=(this.data.rect[2]-this.data.rect[0])/o;r.classList.add("comb"),r.style.letterSpacing=`calc(${e}px * var(--scale-factor) - 1ch)`}}else r=document.createElement("div"),r.textContent=this.data.fieldValue,r.style.verticalAlign="middle",r.style.display="table-cell";return this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class ne extends ee{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class ie extends ee{constructor(e){super(e,{isRenderable:e.renderForms})}render(){let e=this.annotationStorage,t=this.data,n=t.id,i=e.getValue(n,{value:t.exportValue===t.fieldValue}).value;"string"==typeof i&&(i="Off"!==i,e.setValue(n,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let r=document.createElement("input");return q.add(r),r.setAttribute("data-element-id",n),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=t.baseFieldName||t.fieldName,i&&r.setAttribute("checked",!0),r.setAttribute("exportValue",t.exportValue),r.tabIndex=Y,r.addEventListener("change",(i=>{let{name:r,checked:a}=i.target;for(let s of this._getElementsByName(r,n)){let n=a&&s.exportValue===t.exportValue;s.domElement&&(s.domElement.checked=n),e.setValue(s.id,{value:n})}e.setValue(n,{value:a})})),r.addEventListener("resetform",(e=>{let n=t.defaultFieldValue||"Off";e.target.checked=n===t.exportValue})),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",(t=>{let i={value(t){t.target.checked="Off"!==t.detail.value,e.setValue(n,{value:t.target.checked})}};this._dispatchEventFromSandbox(i,t)})),this._setEventListeners(r,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.checked))),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class re extends ee{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let e=this.annotationStorage,t=this.data,n=t.id,i=e.getValue(n,{value:t.fieldValue===t.buttonValue}).value;"string"==typeof i&&(i=i!==t.buttonValue,e.setValue(n,{value:i}));let r=document.createElement("input");if(q.add(r),r.setAttribute("data-element-id",n),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=t.baseFieldName||t.fieldName,i&&r.setAttribute("checked",!0),r.tabIndex=Y,r.addEventListener("change",(t=>{let{name:i,checked:r}=t.target;for(let a of this._getElementsByName(i,n))e.setValue(a.id,{value:!1});e.setValue(n,{value:r})})),r.addEventListener("resetform",(e=>{let n=t.defaultFieldValue;e.target.checked=null!=n&&n===t.buttonValue})),this.enableScripting&&this.hasJSActions){let i=t.buttonValue;r.addEventListener("updatefromsandbox",(t=>{let r={value:t=>{let r=i===t.detail.value;for(let i of this._getElementsByName(t.target.name)){let t=r&&i.id===n;i.domElement&&(i.domElement.checked=t),e.setValue(i.id,{value:t})}}};this._dispatchEventFromSandbox(r,t)})),this._setEventListeners(r,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.checked))}return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class ae extends ${constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){let e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton"),this.data.alternativeText&&(e.title=this.data.alternativeText);let t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({},e)}))),e}}class se extends ee{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let e=this.annotationStorage,t=this.data.id,n=e.getValue(t,{value:this.data.fieldValue}),i=document.createElement("select");q.add(i),i.setAttribute("data-element-id",t),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.baseFieldName||this.data.fieldName,i.tabIndex=Y;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",(e=>{let t=this.data.defaultFieldValue;for(let n of i.options)n.selected=n.value===t}));for(let h of this.data.options){let e=document.createElement("option");e.textContent=h.displayValue,e.value=h.exportValue,n.value.includes(h.exportValue)&&(e.setAttribute("selected",!0),r=!1),i.append(e)}let a=null;if(r){let e=document.createElement("option");e.value=" ",e.setAttribute("hidden",!0),e.setAttribute("selected",!0),i.prepend(e),a=()=>{e.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}let s=e=>{let t=e?"value":"textContent",{options:n,multiple:r}=i;return r?Array.prototype.filter.call(n,(e=>e.selected)).map((e=>e[t])):-1===n.selectedIndex?null:n[n.selectedIndex][t]},o=s(!1),l=e=>{let t=e.target.options;return Array.prototype.map.call(t,(e=>({displayValue:e.textContent,exportValue:e.value})))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",(n=>{let r={value(n){null==a||a();let r=n.detail.value,l=new Set(Array.isArray(r)?r:[r]);for(let e of i.options)e.selected=l.has(e.value);e.setValue(t,{value:s(!0)}),o=s(!1)},multipleSelection(e){i.multiple=!0},remove(n){let r=i.options,a=n.detail.remove;r[a].selected=!1,i.remove(a),r.length>0&&-1===Array.prototype.findIndex.call(r,(e=>e.selected))&&(r[0].selected=!0),e.setValue(t,{value:s(!0),items:l(n)}),o=s(!1)},clear(n){for(;0!==i.length;)i.remove(0);e.setValue(t,{value:null,items:[]}),o=s(!1)},insert(n){let{index:r,displayValue:a,exportValue:h}=n.detail.insert,c=i.children[r],u=document.createElement("option");u.textContent=a,u.value=h,c?c.before(u):i.append(u),e.setValue(t,{value:s(!0),items:l(n)}),o=s(!1)},items(n){let{items:r}=n.detail;for(;0!==i.length;)i.remove(0);for(let e of r){let{displayValue:t,exportValue:n}=e,r=document.createElement("option");r.textContent=t,r.value=n,i.append(r)}i.options.length>0&&(i.options[0].selected=!0),e.setValue(t,{value:s(!0),items:l(n)}),o=s(!1)},indices(n){let i=new Set(n.detail.indices);for(let e of n.target.options)e.selected=i.has(e.index);e.setValue(t,{value:s(!0)}),o=s(!1)},editable(e){e.target.disabled=!e.detail.editable}};this._dispatchEventFromSandbox(r,n)})),i.addEventListener("input",(n=>{var i;let r=s(!0);e.setValue(t,{value:r}),n.preventDefault(),null==(i=this.linkService.eventBus)||i.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:o,changeEx:r,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(i,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(e=>e.target.value))):i.addEventListener("input",(function(n){e.setValue(t,{value:s(!0)})})),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class oe extends K{constructor(e){var t,n,i;let{data:r,elements:a}=e;super(e,{isRenderable:!!(null!=(t=r.titleObj)&&t.str||null!=(n=r.contentsObj)&&n.str||null!=(i=r.richText)&&i.str)}),this.elements=a}render(){this.container.classList.add("popupAnnotation");let e=new le({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),t=[];for(let n of this.elements)n.popup=e,t.push(n.data.id),n.addHighlightArea();return this.container.setAttribute("aria-controls",t.join(",")),this.container}}class le{constructor({container:e,color:t,elements:n,titleObj:i,modificationDate:r,contentsObj:a,richText:s,parent:P,rect:R,parentRect:O,open:L}){Je(this,S),Je(this,T),Je(this,A),Je(this,o,null),Je(this,l,dt(this,A,C).bind(this)),Je(this,h,dt(this,T,E).bind(this)),Je(this,c,dt(this,S,M).bind(this)),Je(this,u,null),Je(this,d,null),Je(this,p,null),Je(this,f,null),Je(this,m,null),Je(this,g,null),Je(this,v,!1),Je(this,y,null),Je(this,x,null),Je(this,b,null),Je(this,_,null),Je(this,w,!1),St(this,d,e),St(this,_,i),St(this,p,a),St(this,b,s),St(this,m,P),St(this,u,t),St(this,x,R),St(this,g,O),St(this,f,n);let I=j.PDFDateString.toDateObject(r);I&&St(this,o,P.l10n.get("annotation_date_string",{date:I.toLocaleDateString(),time:I.toLocaleTimeString()})),this.trigger=n.flatMap((e=>e.getElementsToTriggerPopup()));for(let o of this.trigger)o.addEventListener("click",ce(this,c)),o.addEventListener("mouseenter",ce(this,h)),o.addEventListener("mouseleave",ce(this,l));ce(this,d).hidden=!0,L&&dt(this,S,M).call(this)}render(){if(ce(this,y))return;let{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:n,pageX:i,pageY:r}}}=ce(this,m),a=St(this,y,document.createElement("div"));if(a.className="popup",ce(this,u)){let e=a.style.outlineColor=V.Util.makeHexColor(...ce(this,u));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?a.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`:a.style.backgroundColor=V.Util.makeHexColor(...ce(this,u).map((e=>Math.floor(.7*(255-e)+e))))}let s=document.createElement("span");s.className="header";let l=document.createElement("h1");if(s.append(l),({dir:l.dir,str:l.textContent}=ce(this,_)),a.append(s),ce(this,o)){let e=document.createElement("span");e.classList.add("popupDate"),ce(this,o).then((t=>{e.textContent=t})),s.append(e)}let h=ce(this,p),c=ce(this,b);if(null==c||!c.str||null!=h&&h.str&&h.str!==c.str){let e=this._formatContents(h);a.append(e)}else X.XfaLayer.render({xfaHtml:c.html,intent:"richText",div:a}),a.lastChild.classList.add("richText","popupContent");let v=!!ce(this,g),w=ce(this,v?g:x);for(let o of ce(this,f))if(!w||null!==V.Util.intersect(o.data.rect,w)){w=o.data.rect,v=!0;break}let S=V.Util.normalizeRect([w[0],e[3]-w[1]+e[1],w[2],e[3]-w[3]+e[1]]),M=v?w[2]-w[0]+5:0,T=S[0]+M,E=S[1],{style:A}=ce(this,d);A.left=100*(T-i)/t+"%",A.top=100*(E-r)/n+"%",ce(this,d).append(a)}_formatContents({str:e,dir:t}){let n=document.createElement("p");n.classList.add("popupContent"),n.dir=t;let i=e.split(/(?:\r\n?|\n)/);for(let r=0,a=i.length;r0&&ce(this,F).set(n.data.id,n);let a=n.render();if(e.hidden&&(a.style.visibility="hidden"),Array.isArray(a))for(let i of a)dt(this,U,B).call(this,i,e.id);else dt(this,U,B).call(this,a,e.id)}dt(this,z,H).call(this),yield this.l10n.translate(n)}))}update({viewport:e}){let t=this.div;this.viewport=e,(0,j.setLayerDimensions)(t,{rotation:e.rotation}),dt(this,z,H).call(this),t.hidden=!1}getEditableAnnotations(){return Array.from(ce(this,F).values())}getEditableAnnotation(e){return ce(this,F).get(e)}}},(e,t)=>{function n(e){return Math.floor(255*Math.max(0,Math.min(1,e))).toString(16).padStart(2,"0")}Object.defineProperty(t,"__esModule",{value:!0}),t.ColorConverters=void 0,t.ColorConverters=class{static CMYK_G([e,t,n,i]){return["G",1-Math.min(1,.3*e+.59*n+.11*t+i)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_HTML([e]){let t=n(e);return`#${t}${t}${t}`}static RGB_G([e,t,n]){return["G",.3*e+.59*t+.11*n]}static RGB_HTML([e,t,i]){return`#${n(e)}${n(t)}${n(i)}`}static T_HTML(){return"#00000000"}static CMYK_RGB([e,t,n,i]){return["RGB",1-Math.min(1,e+i),1-Math.min(1,n+i),1-Math.min(1,t+i)]}static CMYK_HTML(e){let t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,n]){let i=1-e,r=1-t,a=1-n;return["CMYK",i,r,a,Math.min(i,r,a)]}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XfaLayer=void 0;var i=n(19);t.XfaLayer=class{static setupStorage(e,t,n,i,r){let a=i.getValue(t,{value:null});switch(n.name){case"textarea":if(null!==a.value&&(e.textContent=a.value),"print"===r)break;e.addEventListener("input",(e=>{i.setValue(t,{value:e.target.value})}));break;case"input":if("radio"===n.attributes.type||"checkbox"===n.attributes.type){if(a.value===n.attributes.xfaOn?e.setAttribute("checked",!0):a.value===n.attributes.xfaOff&&e.removeAttribute("checked"),"print"===r)break;e.addEventListener("change",(e=>{i.setValue(t,{value:e.target.checked?e.target.getAttribute("xfaOn"):e.target.getAttribute("xfaOff")})}))}else{if(null!==a.value&&e.setAttribute("value",a.value),"print"===r)break;e.addEventListener("input",(e=>{i.setValue(t,{value:e.target.value})}))}break;case"select":if(null!==a.value)for(let e of n.children)e.attributes.value===a.value&&(e.attributes.selected=!0);e.addEventListener("input",(e=>{let n=e.target.options,r=-1===n.selectedIndex?"":n[n.selectedIndex].value;i.setValue(t,{value:r})}))}}static setAttributes({html:e,element:t,storage:n=null,intent:i,linkService:r}){let{attributes:a}=t,s=e instanceof HTMLAnchorElement;"radio"===a.type&&(a.name=`${a.name}-${i}`);for(let[o,l]of Object.entries(a))if(null!=l)switch(o){case"class":l.length&&e.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",l);break;case"style":Object.assign(e.style,l);break;case"textContent":e.textContent=l;break;default:(!s||"href"!==o&&"newWindow"!==o)&&e.setAttribute(o,l)}s&&r.addLinkAttributes(e,a.href,a.newWindow),n&&a.dataId&&this.setupStorage(e,a.dataId,t,n)}static render(e){var t;let n=e.annotationStorage,r=e.linkService,a=e.xfaHtml,s=e.intent||"display",o=document.createElement(a.name);a.attributes&&this.setAttributes({html:o,element:a,intent:s,linkService:r});let l=[[a,-1,o]],h=e.div;if(h.append(o),e.viewport){let t=`matrix(${e.viewport.transform.join(",")})`;h.style.transform=t}"richText"!==s&&h.setAttribute("class","xfaLayer xfaFont");let c=[];for(;l.length>0;){let[e,a,o]=l.at(-1);if(a+1===e.children.length){l.pop();continue}let h=e.children[++l.at(-1)[1]];if(null===h)continue;let u,{name:d}=h;if("#text"!==d){if(u=null!=(t=null==h?void 0:h.attributes)&&t.xmlns?document.createElementNS(h.attributes.xmlns,d):document.createElement(d),o.append(u),h.attributes&&this.setAttributes({html:u,element:h,storage:n,intent:s,linkService:r}),h.children&&h.children.length>0)l.push([h,-1,u]);else if(h.value){let e=document.createTextNode(h.value);i.XfaText.shouldBuildText(d)&&c.push(e),u.append(e)}}else{let e=document.createTextNode(h.value);c.push(e),o.append(e)}}for(let i of h.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))i.setAttribute("readOnly",!0);return{textDivs:c}}static update(e){let t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t,e.div.hidden=!1}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NullL10n=void 0,t.getL10nFallback=i;let n={of_pages:"of {{pagesCount}}",page_of_pages:"({{pageNumber}} of {{pagesCount}})",document_properties_kb:"{{size_kb}} KB ({{size_b}} bytes)",document_properties_mb:"{{size_mb}} MB ({{size_b}} bytes)",document_properties_date_string:"{{date}}, {{time}}",document_properties_page_size_unit_inches:"in",document_properties_page_size_unit_millimeters:"mm",document_properties_page_size_orientation_portrait:"portrait",document_properties_page_size_orientation_landscape:"landscape",document_properties_page_size_name_a3:"A3",document_properties_page_size_name_a4:"A4",document_properties_page_size_name_letter:"Letter",document_properties_page_size_name_legal:"Legal",document_properties_page_size_dimension_string:"{{width}} \xd7 {{height}} {{unit}} ({{orientation}})",document_properties_page_size_dimension_name_string:"{{width}} \xd7 {{height}} {{unit}} ({{name}}, {{orientation}})",document_properties_linearized_yes:"Yes",document_properties_linearized_no:"No",additional_layers:"Additional Layers",page_landmark:"Page {{page}}",thumb_page_title:"Page {{page}}",thumb_page_canvas:"Thumbnail of Page {{page}}",find_reached_top:"Reached top of document, continued from bottom",find_reached_bottom:"Reached end of document, continued from top","find_match_count[one]":"{{current}} of {{total}} match","find_match_count[other]":"{{current}} of {{total}} matches","find_match_count_limit[one]":"More than {{limit}} match","find_match_count_limit[other]":"More than {{limit}} matches",find_not_found:"Phrase not found",page_scale_width:"Page Width",page_scale_fit:"Page Fit",page_scale_auto:"Automatic Zoom",page_scale_actual:"Actual Size",page_scale_percent:"{{scale}}%",loading_error:"An error occurred while loading the PDF.",invalid_file_error:"Invalid or corrupted PDF file.",missing_file_error:"Missing PDF file.",unexpected_response_error:"Unexpected server response.",rendering_error:"An error occurred while rendering the page.",annotation_date_string:"{{date}}, {{time}}",printing_not_supported:"Warning: Printing is not fully supported by this browser.",printing_not_ready:"Warning: The PDF is not fully loaded for printing.",web_fonts_disabled:"Web fonts are disabled: unable to use embedded PDF fonts.",free_text2_default_content:"Start typing\u2026",editor_free_text2_aria_label:"Text Editor",editor_ink2_aria_label:"Draw Editor",editor_ink_canvas_aria_label:"User-created image"};function i(e,t){switch(e){case"find_match_count":e=`find_match_count[${1===t.total?"one":"other"}]`;break;case"find_match_count_limit":e=`find_match_count_limit[${1===t.limit?"one":"other"}]`}return n[e]||""}n.print_progress_percent="{{progress}}%";let r={getLanguage(){return ft(this,null,(function*(){return"en-us"}))},getDirection(){return ft(this,null,(function*(){return"ltr"}))},get(e){return ft(this,arguments,(function*(e,t=null,n=i(e,t)){return function(e,t){return t?e.replaceAll(/\{\{\s*(\w+)\s*\}\}/g,((e,n)=>n in t?t[n]:"{{"+n+"}}")):e}(n,t)}))},translate(e){return ft(this,null,(function*(){}))}};t.NullL10n=r},(e,t,n)=>{var i,r,a,s,o,l,h,c,u,d,p,f,m,g,v,y,x,b,_,w,S,M,T,E,A,C,P,R,O,L,I,D,k,N,F,U,B,z,H,V,j,G,W,X,Y,q,J,Z,K,$,Q,ee,te,ne,ie,re,ae,se,oe,le,he,ue,de,pe,fe,me,ge,ve,ye,xe;Object.defineProperty(t,"__esModule",{value:!0}),t.InkEditor=void 0;var be=n(1),_e=n(4),we=n(29),Se=n(5);let Me=16,Te=class extends _e.AnnotationEditor{constructor(e){super(Ri(Tr({},e),{name:"inkEditor"})),Je(this,x),Je(this,_),Je(this,S),Je(this,T),Je(this,A),Je(this,P),Je(this,O),Je(this,I),Je(this,k),Je(this,F),Je(this,B),Je(this,H),Je(this,j),Je(this,W),Je(this,Y),Je(this,J),Je(this,K),Je(this,Q),Je(this,te),Je(this,he),Je(this,de),Je(this,fe),Je(this,ge),Je(this,ye),Je(this,i,0),Je(this,r,0),Je(this,a,0),Je(this,s,this.canvasContextMenu.bind(this)),Je(this,o,this.canvasPointermove.bind(this)),Je(this,l,this.canvasPointerleave.bind(this)),Je(this,h,this.canvasPointerup.bind(this)),Je(this,c,this.canvasPointerdown.bind(this)),Je(this,u,new Path2D),Je(this,d,!1),Je(this,p,!1),Je(this,f,!1),Je(this,m,null),Je(this,g,0),Je(this,v,0),Je(this,y,null),this.color=e.color||null,this.thickness=e.thickness||null,this.opacity=e.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0}static initialize(e){this._l10nPromise=new Map(["editor_ink_canvas_aria_label","editor_ink2_aria_label"].map((t=>[t,e.get(t)])))}static updateDefaultParams(e,t){switch(e){case be.AnnotationEditorParamsType.INK_THICKNESS:Te._defaultThickness=t;break;case be.AnnotationEditorParamsType.INK_COLOR:Te._defaultColor=t;break;case be.AnnotationEditorParamsType.INK_OPACITY:Te._defaultOpacity=t/100}}updateParams(e,t){switch(e){case be.AnnotationEditorParamsType.INK_THICKNESS:dt(this,x,b).call(this,t);break;case be.AnnotationEditorParamsType.INK_COLOR:dt(this,_,w).call(this,t);break;case be.AnnotationEditorParamsType.INK_OPACITY:dt(this,S,M).call(this,t)}}static get defaultPropertiesToUpdate(){return[[be.AnnotationEditorParamsType.INK_THICKNESS,Te._defaultThickness],[be.AnnotationEditorParamsType.INK_COLOR,Te._defaultColor||_e.AnnotationEditor._defaultLineColor],[be.AnnotationEditorParamsType.INK_OPACITY,Math.round(100*Te._defaultOpacity)]]}get propertiesToUpdate(){var e;return[[be.AnnotationEditorParamsType.INK_THICKNESS,this.thickness||Te._defaultThickness],[be.AnnotationEditorParamsType.INK_COLOR,this.color||Te._defaultColor||_e.AnnotationEditor._defaultLineColor],[be.AnnotationEditorParamsType.INK_OPACITY,Math.round(100*(null!=(e=this.opacity)?e:Te._defaultOpacity))]]}rebuild(){super.rebuild(),null!==this.div&&(this.canvas||(dt(this,Y,q).call(this),dt(this,J,Z).call(this)),this.isAttachedToDOM||(this.parent.add(this),dt(this,K,$).call(this)),dt(this,ge,ve).call(this))}remove(){null!==this.canvas&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,ce(this,m).disconnect(),St(this,m,null),super.remove())}setParent(e){!this.parent&&e?this._uiManager.removeShouldRescale(this):this.parent&&null===e&&this._uiManager.addShouldRescale(this),super.setParent(e)}onScaleChanging(){let[e,t]=this.parentDimensions,n=this.width*e,i=this.height*t;this.setDimensions(n,i)}enableEditMode(){ce(this,d)||null===this.canvas||(super.enableEditMode(),this.div.draggable=!1,this.canvas.addEventListener("pointerdown",ce(this,c)))}disableEditMode(){!this.isInEditMode()||null===this.canvas||(super.disableEditMode(),this.div.draggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",ce(this,c)))}onceAdded(){this.div.draggable=!this.isEmpty()}isEmpty(){return 0===this.paths.length||1===this.paths.length&&0===this.paths[0].length}commit(){ce(this,d)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),St(this,d,!0),this.div.classList.add("disabled"),dt(this,ge,ve).call(this,!0),this.parent.addInkEditorIfNeeded(!0),this.parent.moveEditorInDOM(this),this.div.focus({preventScroll:!0}))}focusin(e){super.focusin(e),this.enableEditMode()}canvasPointerdown(e){0!==e.button||!this.isInEditMode()||ce(this,d)||(this.setInForeground(),e.preventDefault(),"mouse"!==e.type&&this.div.focus(),dt(this,P,R).call(this,e.offsetX,e.offsetY))}canvasContextMenu(e){e.preventDefault()}canvasPointermove(e){e.preventDefault(),dt(this,O,L).call(this,e.offsetX,e.offsetY)}canvasPointerup(e){e.preventDefault(),dt(this,W,X).call(this,e)}canvasPointerleave(e){dt(this,W,X).call(this,e)}render(){if(this.div)return this.div;let e,t;this.width&&(e=this.x,t=this.y),super.render(),Te._l10nPromise.get("editor_ink2_aria_label").then((e=>{var t;return null==(t=this.div)?void 0:t.setAttribute("aria-label",e)}));let[n,i,r,a]=dt(this,T,E).call(this);if(this.setAt(n,i,0,0),this.setDims(r,a),dt(this,Y,q).call(this),this.width){let[n,i]=this.parentDimensions;this.setAt(e*n,t*i,this.width*n,this.height*i),St(this,f,!0),dt(this,K,$).call(this),this.setDims(this.width*n,this.height*i),dt(this,j,G).call(this),dt(this,ye,xe).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return dt(this,J,Z).call(this),this.div}setDimensions(e,t){let n=Math.round(e),r=Math.round(t);if(ce(this,g)===n&&ce(this,v)===r)return;St(this,g,n),St(this,v,r),this.canvas.style.visibility="hidden",ce(this,i)&&Math.abs(ce(this,i)-e/t)>.01&&(t=Math.ceil(e/ce(this,i)),this.setDims(e,t));let[a,s]=this.parentDimensions;this.width=e/a,this.height=t/s,ce(this,d)&&dt(this,Q,ee).call(this,e,t),dt(this,K,$).call(this),dt(this,j,G).call(this),this.canvas.style.visibility="visible",this.fixDims()}static deserialize(e,t,n){var s,o,l;if(e instanceof we.InkAnnotationElement)return null;let h=super.deserialize(e,t,n);h.thickness=e.thickness,h.color=be.Util.makeHexColor(...e.color),h.opacity=e.opacity;let[c,u]=h.pageDimensions,p=h.width*c,f=h.height*u,m=h.parentScale,y=e.thickness/2;St(h,i,p/f),St(h,d,!0),St(h,g,Math.round(p)),St(h,v,Math.round(f));let{paths:x,rect:b,rotation:_}=e;for(let{bezier:i}of x){i=dt(s=Te,oe,le).call(s,i,b,_);let e=[];h.paths.push(e);let t=m*(i[0]-y),n=m*(i[1]-y);for(let a=2,s=i.length;a{this.thickness=e,dt(this,ge,ve).call(this)},undo:()=>{this.thickness=t,dt(this,ge,ve).call(this)},mustExec:!0,type:be.AnnotationEditorParamsType.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},_=new WeakSet,w=function(e){let t=this.color;this.addCommands({cmd:()=>{this.color=e,dt(this,j,G).call(this)},undo:()=>{this.color=t,dt(this,j,G).call(this)},mustExec:!0,type:be.AnnotationEditorParamsType.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},S=new WeakSet,M=function(e){e/=100;let t=this.opacity;this.addCommands({cmd:()=>{this.opacity=e,dt(this,j,G).call(this)},undo:()=>{this.opacity=t,dt(this,j,G).call(this)},mustExec:!0,type:be.AnnotationEditorParamsType.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},T=new WeakSet,E=function(){let{parentRotation:e,parentDimensions:[t,n]}=this;switch(e){case 90:return[0,n,n,t];case 180:return[t,n,t,n];case 270:return[t,0,n,t];default:return[0,0,t,n]}},A=new WeakSet,C=function(){let{ctx:e,color:t,opacity:n,thickness:i,parentScale:r,scaleFactor:a}=this;e.lineWidth=i*r/a,e.lineCap="round",e.lineJoin="round",e.miterLimit=10,e.strokeStyle=`${t}${(0,Se.opacityToHex)(n)}`},P=new WeakSet,R=function(e,t){this.canvas.addEventListener("contextmenu",ce(this,s)),this.canvas.addEventListener("pointerleave",ce(this,l)),this.canvas.addEventListener("pointermove",ce(this,o)),this.canvas.addEventListener("pointerup",ce(this,h)),this.canvas.removeEventListener("pointerdown",ce(this,c)),this.isEditing=!0,ce(this,f)||(St(this,f,!0),dt(this,K,$).call(this),this.thickness||(this.thickness=Te._defaultThickness),this.color||(this.color=Te._defaultColor||_e.AnnotationEditor._defaultLineColor),null!=this.opacity||(this.opacity=Te._defaultOpacity)),this.currentPath.push([e,t]),St(this,p,!1),dt(this,A,C).call(this),St(this,y,(()=>{dt(this,F,U).call(this),ce(this,y)&&window.requestAnimationFrame(ce(this,y))})),window.requestAnimationFrame(ce(this,y))},O=new WeakSet,L=function(e,t){let[n,i]=this.currentPath.at(-1);if(this.currentPath.length>1&&e===n&&t===i)return;let r=this.currentPath,a=ce(this,u);if(r.push([e,t]),St(this,p,!0),r.length<=2)return a.moveTo(...r[0]),void a.lineTo(e,t);3===r.length&&(St(this,u,a=new Path2D),a.moveTo(...r[0])),dt(this,B,z).call(this,a,...r.at(-3),...r.at(-2),e,t)},I=new WeakSet,D=function(){if(0===this.currentPath.length)return;let e=this.currentPath.at(-1);ce(this,u).lineTo(...e)},k=new WeakSet,N=function(e,t){let n;if(St(this,y,null),e=Math.min(Math.max(e,0),this.canvas.width),t=Math.min(Math.max(t,0),this.canvas.height),dt(this,O,L).call(this,e,t),dt(this,I,D).call(this),1!==this.currentPath.length)n=dt(this,H,V).call(this);else{let i=[e,t];n=[[i,i.slice(),i.slice(),i]]}let i=ce(this,u),r=this.currentPath;this.currentPath=[],St(this,u,new Path2D),this.addCommands({cmd:()=>{this.allRawPaths.push(r),this.paths.push(n),this.bezierPath2D.push(i),this.rebuild()},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),0===this.paths.length?this.remove():(this.canvas||(dt(this,Y,q).call(this),dt(this,J,Z).call(this)),dt(this,ge,ve).call(this))},mustExec:!0})},F=new WeakSet,U=function(){if(!ce(this,p))return;St(this,p,!1),Math.ceil(this.thickness*this.parentScale);let e=this.currentPath.slice(-3),t=e.map((e=>e[0])),n=e.map((e=>e[1])),{ctx:i}=(Math.min(...t),Math.max(...t),Math.min(...n),Math.max(...n),this);i.save(),i.clearRect(0,0,this.canvas.width,this.canvas.height);for(let r of this.bezierPath2D)i.stroke(r);i.stroke(ce(this,u)),i.restore()},B=new WeakSet,z=function(e,t,n,i,r,a,s){let o=(t+i)/2,l=(n+r)/2,h=(i+a)/2,c=(r+s)/2;e.bezierCurveTo(o+2*(i-o)/3,l+2*(r-l)/3,h+2*(i-h)/3,c+2*(r-c)/3,h,c)},H=new WeakSet,V=function(){let e=this.currentPath;if(e.length<=2)return[[e[0],e[0],e.at(-1),e.at(-1)]];let t,n=[],[i,r]=e[0];for(t=1;t{this.canvas.removeEventListener("contextmenu",ce(this,s))}),10),dt(this,k,N).call(this,e.offsetX,e.offsetY),this.addToAnnotationStorage(),this.setInBackground()},Y=new WeakSet,q=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",Te._l10nPromise.get("editor_ink_canvas_aria_label").then((e=>{var t;return null==(t=this.canvas)?void 0:t.setAttribute("aria-label",e)})),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},J=new WeakSet,Z=function(){St(this,m,new ResizeObserver((e=>{let t=e[0].contentRect;t.width&&t.height&&this.setDimensions(t.width,t.height)}))),ce(this,m).observe(this.div)},K=new WeakSet,$=function(){if(!ce(this,f))return;let[e,t]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*e),this.canvas.height=Math.ceil(this.height*t),dt(this,te,ne).call(this)},Q=new WeakSet,ee=function(e,t){let n=dt(this,fe,me).call(this),i=(e-n)/ce(this,a),s=(t-n)/ce(this,r);this.scaleFactor=Math.min(i,s)},te=new WeakSet,ne=function(){let e=dt(this,fe,me).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+e,this.translationY*this.scaleFactor+e)},ie=new WeakSet,re=function(e){let t=new Path2D;for(let n=0,i=e.length;n=1?(e.minHeight="16px",e.minWidth=`${Math.round(ce(this,i)*Me)}px`):(e.minWidth="16px",e.minHeight=`${Math.round(Me/ce(this,i))}px`)},Je(Ee,ie),Je(Ee,ae),Je(Ee,oe),Xi(Ee,"_defaultColor",null),Xi(Ee,"_defaultOpacity",1),Xi(Ee,"_defaultThickness",1),Xi(Ee,"_l10nPromise"),Xi(Ee,"_type","ink"),t.InkEditor=Ee},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SVGGraphics=void 0;var i=n(6),r=n(1),a=n(10);let s="normal",o="#000000",l=["butt","round","square"],h=["miter","round","bevel"],c=function(e,t="",n=!1){if(URL.createObjectURL&&"undefined"!=typeof Blob&&!n)return URL.createObjectURL(new Blob([e],{type:t}));let i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",r=`data:${t};base64,`;for(let a=0,s=e.length;a>2]+i[(3&t)<<4|n>>4]+i[a+1>6:64]+i[a+2>1&2147483647:e>>1&2147483647;t[r]=e}function n(e,n,i,r){let a=r,s=n.length;i[a]=s>>24&255,i[a+1]=s>>16&255,i[a+2]=s>>8&255,i[a+3]=255&s,a+=4,i[a]=255&e.charCodeAt(0),i[a+1]=255&e.charCodeAt(1),i[a+2]=255&e.charCodeAt(2),i[a+3]=255&e.charCodeAt(3),a+=4,i.set(n,a),a+=n.length;let o=function(e,n,i){let r=-1;for(let a=n;a>>8^t[n]}return-1^r}(i,r+4,a);i[a]=o>>24&255,i[a+1]=o>>16&255,i[a+2]=o>>8&255,i[a+3]=255&o}function i(e){let t=e.length,n=65535,i=Math.ceil(t/n),r=new Uint8Array(2+t+5*i+4),a=0;r[a++]=120,r[a++]=156;let s=0;for(;t>n;)r[a++]=0,r[a++]=255,r[a++]=255,r[a++]=0,r[a++]=0,r.set(e.subarray(s,s+n),a),a+=n,s+=n,t-=n;r[a++]=1,r[a++]=255&t,r[a++]=t>>8&255,r[a++]=255&~t,r[a++]=(65535&~t)>>8&255,r.set(e.subarray(s),a),a+=e.length-s;let o=function(e,t,n){let i=1,r=0;for(let a=0;a>24&255,r[a++]=o>>16&255,r[a++]=o>>8&255,r[a++]=255&o,r}function s(t,s,o,l){let h,u,d,p=t.width,f=t.height,m=t.data;switch(s){case r.ImageKind.GRAYSCALE_1BPP:u=0,h=1,d=p+7>>3;break;case r.ImageKind.RGB_24BPP:u=2,h=8,d=3*p;break;case r.ImageKind.RGBA_32BPP:u=6,h=8,d=4*p;break;default:throw new Error("invalid format")}let g=new Uint8Array((1+d)*f),v=0,y=0;for(let e=0;e>24&255,p>>16&255,p>>8&255,255&p,f>>24&255,f>>16&255,f>>8&255,255&f,h,u,0,0,0]),b=function(e){if(!a.isNodeJS)return i(e);try{let t;t=parseInt(process.versions.node)>=8?e:Buffer.from(e);let n=zye().deflateSync(t,{level:9});return n instanceof Uint8Array?n:new Uint8Array(n)}catch(e){(0,r.warn)("Not compressing PNG because zlib.deflateSync is unavailable: "+e)}return i(e)}(g),_=e.length+36+x.length+b.length,w=new Uint8Array(_),S=0;return w.set(e,S),S+=e.length,n("IHDR",x,w,S),S+=12+x.length,n("IDATA",b,w,S),S+=12+b.length,n("IEND",new Uint8Array(0),w,S),c(w,"image/png",o)}return function(e,t,n){return s(e,void 0===e.kind?r.ImageKind.GRAYSCALE_1BPP:e.kind,t,n)}}();class d{constructor(){this.fontSizeScale=1,this.fontWeight=s,this.fontSize=0,this.textMatrix=r.IDENTITY_MATRIX,this.fontMatrix=r.FONT_IDENTITY_MATRIX,this.leading=0,this.textRenderingMode=r.TextRenderingMode.FILL,this.textMatrixScale=1,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRise=0,this.fillColor=o,this.strokeColor="#000000",this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.lineJoin="",this.lineCap="",this.miterLimit=0,this.dashArray=[],this.dashPhase=0,this.dependencies=[],this.activeClipUrl=null,this.clipGroup=null,this.maskId=""}clone(){return Object.create(this)}setCurrentPoint(e,t){this.x=e,this.y=t}}function p(e){if(Number.isInteger(e))return e.toString();let t=e.toFixed(10),n=t.length-1;if("0"!==t[n])return t;do{n--}while("0"===t[n]);return t.substring(0,"."===t[n]?n:n+1)}function f(e){if(0===e[4]&&0===e[5]){if(0===e[1]&&0===e[2])return 1===e[0]&&1===e[3]?"":`scale(${p(e[0])} ${p(e[3])})`;if(e[0]===e[3]&&e[1]===-e[2])return`rotate(${p(180*Math.acos(e[0])/Math.PI)})`}else if(1===e[0]&&0===e[1]&&0===e[2]&&1===e[3])return`translate(${p(e[4])} ${p(e[5])})`;return`matrix(${p(e[0])} ${p(e[1])} ${p(e[2])} ${p(e[3])} ${p(e[4])} ${p(e[5])})`}let m=0,g=0,v=0;t.SVGGraphics=class{constructor(e,t,n=!1){(0,i.deprecated)("The SVG back-end is no longer maintained and *may* be removed in the future."),this.svgFactory=new i.DOMSVGFactory,this.current=new d,this.transformMatrix=r.IDENTITY_MATRIX,this.transformStack=[],this.extraStack=[],this.commonObjs=e,this.objs=t,this.pendingClip=null,this.pendingEOFill=!1,this.embedFonts=!1,this.embeddedFonts=Object.create(null),this.cssStyle=null,this.forceDataSchema=!!n,this._operatorIdMapping=[];for(let i in r.OPS)this._operatorIdMapping[r.OPS[i]]=i}getObject(e,t=null){return"string"==typeof e?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):t}save(){this.transformStack.push(this.transformMatrix);let e=this.current;this.extraStack.push(e),this.current=e.clone()}restore(){this.transformMatrix=this.transformStack.pop(),this.current=this.extraStack.pop(),this.pendingClip=null,this.tgrp=null}group(e){this.save(),this.executeOpTree(e),this.restore()}loadDependencies(e){let t=e.fnArray,n=e.argsArray;for(let i=0,a=t.length;i{t.get(e,n)}));this.current.dependencies.push(n)}return Promise.all(this.current.dependencies)}transform(e,t,n,i,a,s){let o=[e,t,n,i,a,s];this.transformMatrix=r.Util.transform(this.transformMatrix,o),this.tgrp=null}getSVG(e,t){this.viewport=t;let n=this._initialize(t);return this.loadDependencies(e).then((()=>(this.transformMatrix=r.IDENTITY_MATRIX,this.executeOpTree(this.convertOpList(e)),n)))}convertOpList(e){let t=this._operatorIdMapping,n=e.argsArray,i=e.fnArray,r=[];for(let a=0,s=i.length;a0&&(this.current.lineWidth=e)}setLineCap(e){this.current.lineCap=l[e]}setLineJoin(e){this.current.lineJoin=h[e]}setMiterLimit(e){this.current.miterLimit=e}setStrokeAlpha(e){this.current.strokeAlpha=e}setStrokeRGBColor(e,t,n){this.current.strokeColor=r.Util.makeHexColor(e,t,n)}setFillAlpha(e){this.current.fillAlpha=e}setFillRGBColor(e,t,n){this.current.fillColor=r.Util.makeHexColor(e,t,n),this.current.tspan=this.svgFactory.createElement("svg:tspan"),this.current.xcoords=[],this.current.ycoords=[]}setStrokeColorN(e){this.current.strokeColor=this._makeColorN_Pattern(e)}setFillColorN(e){this.current.fillColor=this._makeColorN_Pattern(e)}shadingFill(e){let{width:t,height:n}=this.viewport,i=r.Util.inverseTransform(this.transformMatrix),[a,s,o,l]=r.Util.getAxialAlignedBoundingBox([0,0,t,n],i),h=this.svgFactory.createElement("svg:rect");h.setAttributeNS(null,"x",a),h.setAttributeNS(null,"y",s),h.setAttributeNS(null,"width",o-a),h.setAttributeNS(null,"height",l-s),h.setAttributeNS(null,"fill",this._makeShadingPattern(e)),this.current.fillAlpha<1&&h.setAttributeNS(null,"fill-opacity",this.current.fillAlpha),this._ensureTransformGroup().append(h)}_makeColorN_Pattern(e){return"TilingPattern"===e[0]?this._makeTilingPattern(e):this._makeShadingPattern(e)}_makeTilingPattern(e){let t=e[1],n=e[2],i=e[3]||r.IDENTITY_MATRIX,[a,s,o,l]=e[4],h=e[5],c=e[6],u=e[7],d="shading"+v++,[p,f,m,g]=r.Util.normalizeRect([...r.Util.applyTransform([a,s],i),...r.Util.applyTransform([o,l],i)]),[y,x]=r.Util.singularValueDecompose2dScale(i),b=h*y,_=c*x,w=this.svgFactory.createElement("svg:pattern");w.setAttributeNS(null,"id",d),w.setAttributeNS(null,"patternUnits","userSpaceOnUse"),w.setAttributeNS(null,"width",b),w.setAttributeNS(null,"height",_),w.setAttributeNS(null,"x",`${p}`),w.setAttributeNS(null,"y",`${f}`);let S=this.svg,M=this.transformMatrix,T=this.current.fillColor,E=this.current.strokeColor,A=this.svgFactory.create(m-p,g-f);if(this.svg=A,this.transformMatrix=i,2===u){let e=r.Util.makeHexColor(...t);this.current.fillColor=e,this.current.strokeColor=e}return this.executeOpTree(this.convertOpList(n)),this.svg=S,this.transformMatrix=M,this.current.fillColor=T,this.current.strokeColor=E,w.append(A.childNodes[0]),this.defs.append(w),`url(#${d})`}_makeShadingPattern(e){switch("string"==typeof e&&(e=this.objs.get(e)),e[0]){case"RadialAxial":let t,n="shading"+v++,i=e[3];switch(e[1]){case"axial":let i=e[4],r=e[5];t=this.svgFactory.createElement("svg:linearGradient"),t.setAttributeNS(null,"id",n),t.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),t.setAttributeNS(null,"x1",i[0]),t.setAttributeNS(null,"y1",i[1]),t.setAttributeNS(null,"x2",r[0]),t.setAttributeNS(null,"y2",r[1]);break;case"radial":let a=e[4],s=e[5],o=e[6],l=e[7];t=this.svgFactory.createElement("svg:radialGradient"),t.setAttributeNS(null,"id",n),t.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),t.setAttributeNS(null,"cx",s[0]),t.setAttributeNS(null,"cy",s[1]),t.setAttributeNS(null,"r",l),t.setAttributeNS(null,"fx",a[0]),t.setAttributeNS(null,"fy",a[1]),t.setAttributeNS(null,"fr",o);break;default:throw new Error(`Unknown RadialAxial type: ${e[1]}`)}for(let e of i){let n=this.svgFactory.createElement("svg:stop");n.setAttributeNS(null,"offset",e[0]),n.setAttributeNS(null,"stop-color",e[1]),t.append(n)}return this.defs.append(t),`url(#${n})`;case"Mesh":return(0,r.warn)("Unimplemented pattern Mesh"),null;case"Dummy":return"hotpink";default:throw new Error(`Unknown IR type: ${e[0]}`)}}setDash(e,t){this.current.dashArray=e,this.current.dashPhase=t}constructPath(e,t){let n=this.current,i=n.x,a=n.y,s=[],o=0;for(let l of e)switch(0|l){case r.OPS.rectangle:i=t[o++],a=t[o++];let e=i+t[o++],n=a+t[o++];s.push("M",p(i),p(a),"L",p(e),p(a),"L",p(e),p(n),"L",p(i),p(n),"Z");break;case r.OPS.moveTo:i=t[o++],a=t[o++],s.push("M",p(i),p(a));break;case r.OPS.lineTo:i=t[o++],a=t[o++],s.push("L",p(i),p(a));break;case r.OPS.curveTo:i=t[o+4],a=t[o+5],s.push("C",p(t[o]),p(t[o+1]),p(t[o+2]),p(t[o+3]),p(i),p(a)),o+=6;break;case r.OPS.curveTo2:s.push("C",p(i),p(a),p(t[o]),p(t[o+1]),p(t[o+2]),p(t[o+3])),i=t[o+2],a=t[o+3],o+=4;break;case r.OPS.curveTo3:i=t[o+2],a=t[o+3],s.push("C",p(t[o]),p(t[o+1]),p(i),p(a),p(i),p(a)),o+=4;break;case r.OPS.closePath:s.push("Z")}s=s.join(" "),n.path&&e.length>0&&e[0]!==r.OPS.rectangle&&e[0]!==r.OPS.moveTo?s=n.path.getAttributeNS(null,"d")+s:(n.path=this.svgFactory.createElement("svg:path"),this._ensureTransformGroup().append(n.path)),n.path.setAttributeNS(null,"d",s),n.path.setAttributeNS(null,"fill","none"),n.element=n.path,n.setCurrentPoint(i,a)}endPath(){let e=this.current;if(e.path=null,!this.pendingClip)return;if(!e.element)return void(this.pendingClip=null);let t="clippath"+m++,n=this.svgFactory.createElement("svg:clipPath");n.setAttributeNS(null,"id",t),n.setAttributeNS(null,"transform",f(this.transformMatrix));let i=e.element.cloneNode(!0);if("evenodd"===this.pendingClip?i.setAttributeNS(null,"clip-rule","evenodd"):i.setAttributeNS(null,"clip-rule","nonzero"),this.pendingClip=null,n.append(i),this.defs.append(n),e.activeClipUrl){e.clipGroup=null;for(let e of this.extraStack)e.clipGroup=null;n.setAttributeNS(null,"clip-path",e.activeClipUrl)}e.activeClipUrl=`url(#${t})`,this.tgrp=null}clip(e){this.pendingClip=e}closePath(){let e=this.current;if(e.path){let t=`${e.path.getAttributeNS(null,"d")}Z`;e.path.setAttributeNS(null,"d",t)}}setLeading(e){this.current.leading=-e}setTextRise(e){this.current.textRise=e}setTextRenderingMode(e){this.current.textRenderingMode=e}setHScale(e){this.current.textHScale=e/100}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(let[t,n]of e)switch(t){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n);break;case"CA":this.setStrokeAlpha(n);break;case"ca":this.setFillAlpha(n);break;default:(0,r.warn)(`Unimplemented graphic state operator ${t}`)}}fill(){let e=this.current;e.element&&(e.element.setAttributeNS(null,"fill",e.fillColor),e.element.setAttributeNS(null,"fill-opacity",e.fillAlpha),this.endPath())}stroke(){let e=this.current;e.element&&(this._setStrokeAttributes(e.element),e.element.setAttributeNS(null,"fill","none"),this.endPath())}_setStrokeAttributes(e,t=1){let n=this.current,i=n.dashArray;1!==t&&i.length>0&&(i=i.map((function(e){return t*e}))),e.setAttributeNS(null,"stroke",n.strokeColor),e.setAttributeNS(null,"stroke-opacity",n.strokeAlpha),e.setAttributeNS(null,"stroke-miterlimit",p(n.miterLimit)),e.setAttributeNS(null,"stroke-linecap",n.lineCap),e.setAttributeNS(null,"stroke-linejoin",n.lineJoin),e.setAttributeNS(null,"stroke-width",p(t*n.lineWidth)+"px"),e.setAttributeNS(null,"stroke-dasharray",i.map(p).join(" ")),e.setAttributeNS(null,"stroke-dashoffset",p(t*n.dashPhase)+"px")}eoFill(){var e;null==(e=this.current.element)||e.setAttributeNS(null,"fill-rule","evenodd"),this.fill()}fillStroke(){this.stroke(),this.fill()}eoFillStroke(){var e;null==(e=this.current.element)||e.setAttributeNS(null,"fill-rule","evenodd"),this.fillStroke()}closeStroke(){this.closePath(),this.stroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.closePath(),this.eoFillStroke()}paintSolidColorImageMask(){let e=this.svgFactory.createElement("svg:rect");e.setAttributeNS(null,"x","0"),e.setAttributeNS(null,"y","0"),e.setAttributeNS(null,"width","1px"),e.setAttributeNS(null,"height","1px"),e.setAttributeNS(null,"fill",this.current.fillColor),this._ensureTransformGroup().append(e)}paintImageXObject(e){let t=this.getObject(e);t?this.paintInlineImageXObject(t):(0,r.warn)(`Dependent image with object ID ${e} is not ready yet`)}paintInlineImageXObject(e,t){let n=e.width,i=e.height,r=u(e,this.forceDataSchema,!!t),a=this.svgFactory.createElement("svg:rect");a.setAttributeNS(null,"x","0"),a.setAttributeNS(null,"y","0"),a.setAttributeNS(null,"width",p(n)),a.setAttributeNS(null,"height",p(i)),this.current.element=a,this.clip("nonzero");let s=this.svgFactory.createElement("svg:image");s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r),s.setAttributeNS(null,"x","0"),s.setAttributeNS(null,"y",p(-i)),s.setAttributeNS(null,"width",p(n)+"px"),s.setAttributeNS(null,"height",p(i)+"px"),s.setAttributeNS(null,"transform",`scale(${p(1/n)} ${p(-1/i)})`),t?t.append(s):this._ensureTransformGroup().append(s)}paintImageMaskXObject(e){let t=this.getObject(e.data,e);if(t.bitmap)return void(0,r.warn)("paintImageMaskXObject: ImageBitmap support is not implemented, ensure that the `isOffscreenCanvasSupported` API parameter is disabled.");let n=this.current,i=t.width,a=t.height,s=n.fillColor;n.maskId="mask"+g++;let o=this.svgFactory.createElement("svg:mask");o.setAttributeNS(null,"id",n.maskId);let l=this.svgFactory.createElement("svg:rect");l.setAttributeNS(null,"x","0"),l.setAttributeNS(null,"y","0"),l.setAttributeNS(null,"width",p(i)),l.setAttributeNS(null,"height",p(a)),l.setAttributeNS(null,"fill",s),l.setAttributeNS(null,"mask",`url(#${n.maskId})`),this.defs.append(o),this._ensureTransformGroup().append(l),this.paintInlineImageXObject(t,o)}paintFormXObjectBegin(e,t){if(Array.isArray(e)&&6===e.length&&this.transform(e[0],e[1],e[2],e[3],e[4],e[5]),t){let e=t[2]-t[0],n=t[3]-t[1],i=this.svgFactory.createElement("svg:rect");i.setAttributeNS(null,"x",t[0]),i.setAttributeNS(null,"y",t[1]),i.setAttributeNS(null,"width",p(e)),i.setAttributeNS(null,"height",p(n)),this.current.element=i,this.clip("nonzero"),this.endPath()}}paintFormXObjectEnd(){}_initialize(e){let t=this.svgFactory.create(e.width,e.height),n=this.svgFactory.createElement("svg:defs");t.append(n),this.defs=n;let i=this.svgFactory.createElement("svg:g");return i.setAttributeNS(null,"transform",f(e.transform)),t.append(i),this.svg=i,t}_ensureClipGroup(){if(!this.current.clipGroup){let e=this.svgFactory.createElement("svg:g");e.setAttributeNS(null,"clip-path",this.current.activeClipUrl),this.svg.append(e),this.current.clipGroup=e}return this.current.clipGroup}_ensureTransformGroup(){return this.tgrp||(this.tgrp=this.svgFactory.createElement("svg:g"),this.tgrp.setAttributeNS(null,"transform",f(this.transformMatrix)),this.current.activeClipUrl?this._ensureClipGroup().append(this.tgrp):this.svg.append(this.tgrp)),this.tgrp}}}],__webpack_module_cache__={};function __w_pdfjs_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e](n,n.exports,__w_pdfjs_require__),n.exports}var __webpack_exports__={};return(()=>{var e=__webpack_exports__;Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"AbortException",{enumerable:!0,get:function(){return t.AbortException}}),Object.defineProperty(e,"AnnotationEditorLayer",{enumerable:!0,get:function(){return a.AnnotationEditorLayer}}),Object.defineProperty(e,"AnnotationEditorParamsType",{enumerable:!0,get:function(){return t.AnnotationEditorParamsType}}),Object.defineProperty(e,"AnnotationEditorType",{enumerable:!0,get:function(){return t.AnnotationEditorType}}),Object.defineProperty(e,"AnnotationEditorUIManager",{enumerable:!0,get:function(){return s.AnnotationEditorUIManager}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return o.AnnotationLayer}}),Object.defineProperty(e,"AnnotationMode",{enumerable:!0,get:function(){return t.AnnotationMode}}),Object.defineProperty(e,"CMapCompressionType",{enumerable:!0,get:function(){return t.CMapCompressionType}}),Object.defineProperty(e,"FeatureTest",{enumerable:!0,get:function(){return t.FeatureTest}}),Object.defineProperty(e,"GlobalWorkerOptions",{enumerable:!0,get:function(){return l.GlobalWorkerOptions}}),Object.defineProperty(e,"ImageKind",{enumerable:!0,get:function(){return t.ImageKind}}),Object.defineProperty(e,"InvalidPDFException",{enumerable:!0,get:function(){return t.InvalidPDFException}}),Object.defineProperty(e,"MissingPDFException",{enumerable:!0,get:function(){return t.MissingPDFException}}),Object.defineProperty(e,"OPS",{enumerable:!0,get:function(){return t.OPS}}),Object.defineProperty(e,"PDFDataRangeTransport",{enumerable:!0,get:function(){return n.PDFDataRangeTransport}}),Object.defineProperty(e,"PDFDateString",{enumerable:!0,get:function(){return i.PDFDateString}}),Object.defineProperty(e,"PDFWorker",{enumerable:!0,get:function(){return n.PDFWorker}}),Object.defineProperty(e,"PasswordResponses",{enumerable:!0,get:function(){return t.PasswordResponses}}),Object.defineProperty(e,"PermissionFlag",{enumerable:!0,get:function(){return t.PermissionFlag}}),Object.defineProperty(e,"PixelsPerInch",{enumerable:!0,get:function(){return i.PixelsPerInch}}),Object.defineProperty(e,"PromiseCapability",{enumerable:!0,get:function(){return t.PromiseCapability}}),Object.defineProperty(e,"RenderingCancelledException",{enumerable:!0,get:function(){return i.RenderingCancelledException}}),e.SVGGraphics=void 0,Object.defineProperty(e,"UnexpectedResponseException",{enumerable:!0,get:function(){return t.UnexpectedResponseException}}),Object.defineProperty(e,"Util",{enumerable:!0,get:function(){return t.Util}}),Object.defineProperty(e,"VerbosityLevel",{enumerable:!0,get:function(){return t.VerbosityLevel}}),Object.defineProperty(e,"XfaLayer",{enumerable:!0,get:function(){return h.XfaLayer}}),Object.defineProperty(e,"build",{enumerable:!0,get:function(){return n.build}}),Object.defineProperty(e,"createValidAbsoluteUrl",{enumerable:!0,get:function(){return t.createValidAbsoluteUrl}}),Object.defineProperty(e,"getDocument",{enumerable:!0,get:function(){return n.getDocument}}),Object.defineProperty(e,"getFilenameFromUrl",{enumerable:!0,get:function(){return i.getFilenameFromUrl}}),Object.defineProperty(e,"getPdfFilenameFromUrl",{enumerable:!0,get:function(){return i.getPdfFilenameFromUrl}}),Object.defineProperty(e,"getXfaPageViewport",{enumerable:!0,get:function(){return i.getXfaPageViewport}}),Object.defineProperty(e,"isDataScheme",{enumerable:!0,get:function(){return i.isDataScheme}}),Object.defineProperty(e,"isPdfFile",{enumerable:!0,get:function(){return i.isPdfFile}}),Object.defineProperty(e,"loadScript",{enumerable:!0,get:function(){return i.loadScript}}),Object.defineProperty(e,"normalizeUnicode",{enumerable:!0,get:function(){return t.normalizeUnicode}}),Object.defineProperty(e,"renderTextLayer",{enumerable:!0,get:function(){return r.renderTextLayer}}),Object.defineProperty(e,"setLayerDimensions",{enumerable:!0,get:function(){return i.setLayerDimensions}}),Object.defineProperty(e,"shadow",{enumerable:!0,get:function(){return t.shadow}}),Object.defineProperty(e,"updateTextLayer",{enumerable:!0,get:function(){return r.updateTextLayer}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return n.version}});var t=__w_pdfjs_require__(1),n=__w_pdfjs_require__(2),i=__w_pdfjs_require__(6),r=__w_pdfjs_require__(26),a=__w_pdfjs_require__(27),s=__w_pdfjs_require__(5),o=__w_pdfjs_require__(29),l=__w_pdfjs_require__(14),h=__w_pdfjs_require__(31);let c=__w_pdfjs_require__(34).SVGGraphics;e.SVGGraphics=c})(),__webpack_exports__})(),"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("pdfjs-dist/build/pdf",[],e):"object"==typeof exports?exports["pdfjs-dist/build/pdf"]=e():t["pdfjs-dist/build/pdf"]=t.pdfjsLib=e()}));!function(){if("undefined"!=typeof document&&!document.getElementById("1f8ddc6a348599fa26443f88f3fc0e483209f94f84f312835ae5d382490673f0")){var e=document.createElement("style");e.id="1f8ddc6a348599fa26443f88f3fc0e483209f94f84f312835ae5d382490673f0",e.textContent='@import"https://at.alicdn.com/t/c/font_2809422_kipm6ycaet.css";@import"https://at.alicdn.com/t/c/font_2802048_dc945363jlf.css";.model-layout-switch-bar{position:absolute;bottom:0;width:100%;height:24px;background:#ffffff;opacity:.7;display:flex;font-size:14px;line-height:1;overflow-x:scroll;overflow-y:hidden;z-index:1}.model-layout-switch-bar .model-layout-switch-bar-content{white-space:nowrap}.model-layout-switch-bar .model-layout-switch-bar-content .model-layout-switch-item{position:relative;display:inline-block;padding:3px 10px 0;color:#000;height:22px;cursor:pointer;transform:translate(0)}.model-layout-switch-bar .model-layout-switch-bar-content .model-layout-switch-item:before{content:"";position:absolute;inset:0;z-index:-1;background:#fff;border:1px solid #000;border-top:0px}.model-layout-switch-bar .model-layout-switch-bar-content .model-layout-switch-item:hover{color:#8080f0}.model-layout-switch-bar .model-layout-switch-bar-content .model-layout-switch-item:nth-child(n+2){margin-left:-1px}.model-layout-switch-bar .model-layout-switch-bar-content .model-layout-switch-item.activate{color:#fff!important}.model-layout-switch-bar .model-layout-switch-bar-content .model-layout-switch-item.activate:before{background:#212830!important}.model-layout-switch-bar.hidden{display:none}.model-layout-switch-bar::-webkit-scrollbar{display:none}.pop-panel{z-index:99999999;top:calc(70% - 100px);left:calc(90% - 160px);position:absolute;background:#ffffff;color:#333;border-radius:4px;width:160px;box-shadow:0 12px 48px 16px #00000008,0 9px 28px #0000000d,0 6px 16px -8px #00000014}.pop-panel .pop-panel-header{font-size:16px;font-weight:bolder;padding:16px 24px 8px;color:#333;border-bottom:1px solid #EFEFEF;cursor:move;user-select:none}.pop-panel .pop-panel-body{display:flex;flex-direction:row;justify-content:space-between;align-items:center;padding:16px 24px}.pop-panel .pop-panel-body .pop-panel-item{display:inline-block;cursor:pointer;margin-right:16px;font-size:16px}.pop-panel .pop-panel-body .pop-panel-item .gemini-viewer-icon{font-size:24px}.pop-panel .pop-panel-body .pop-panel-item:last-child{margin-right:0}.pop-panel .pop-panel-body .pop-panel-item:hover,.pop-panel .pop-panel-body .pop-panel-item.active{color:#2c7be5}.pop-panel .pop-panel-body .pop-panel-item.disable{color:#999;cursor:not-allowed}.progress-bar{z-index:3;bottom:20%;left:25%;position:absolute;color:#ffffffa0;width:50%;user-select:none;font-size:14px}.progress-bar.hidden{display:none}.progress-bar .progress-bar-item{width:100%;text-align:center;padding:2px}.follow-tooltip{z-index:99999999;position:absolute;left:-500px;padding:6px;background:rgba(25,25,25,.3);color:#fffc;font-size:12px;border-radius:2px}.layer-manager{position:absolute;top:30px;left:20px;width:330px;height:600px;max-height:90%;border-radius:4px;box-shadow:1px 3px 10px #0006;background-color:#ffffffe6;color:#000;z-index:2;overflow:hidden;user-select:none}.layer-manager:hover{background-color:#fffffff2}.layer-manager input[type=checkbox]{width:16px;height:16px;cursor:pointer}.layer-manager input[type=color]{width:30px;height:16px;border:0;padding:0;background-color:#0000;overflow:hidden}.layer-manager ::-webkit-color-swatch{position:relative;margin-top:-5px;width:40px;height:16px}.layer-manager .header{display:flex;align-items:center;padding-left:6px;width:100%;height:40px;border-bottom:1px solid #ccc;cursor:move;font-size:16px}.layer-manager .header .close{position:absolute;right:8px;cursor:pointer;padding:10px}.layer-manager .header .close:hover{font-weight:700}.layer-manager .layer-list{width:100%;height:calc(100% - 40px);padding:0;margin:0;border-bottom:1px solid #ccc;overflow-y:scroll}.layer-manager .layer-list-item{display:flex;align-items:center;padding:6px;border-bottom:1px solid #ccc;white-space:nowrap}.layer-manager .layer-list-item:hover{background-color:#f0f8ff}.layer-manager .popup-layer-color{display:inline-block;margin-left:5px;width:20px;font-size:12px}.layer-manager .item-color{margin-left:8px;font-size:12px;border:1px solid black;width:18px;height:16px;min-width:18px}.layer-manager .item-layer-name{display:inline-block;margin-left:10px;padding:1px 0;width:280px;font-size:12px;text-overflow:ellipsis;overflow:hidden}.layer-manager .popup-freeze{margin-right:5px;color:#ccc;font-size:12px;width:50px}#axisGizmo{width:100px;height:100px;position:absolute;display:block;bottom:1px;left:10px;background:#ffffff00}.bottom-bar{position:absolute;bottom:0;right:0;display:flex;color:#666;z-index:3;overflow:hidden;user-select:none}.bottom-bar i{font-size:18px;padding:3px;align-self:center;opacity:.4;cursor:pointer;line-height:1}.bottom-bar i:hover,.bottom-bar i.active{color:#2c7be5;opacity:1}.bottom-bar .fps{width:4rem}.bottom-bar span{align-self:center;padding:4px;font-size:14px}#gemini-viewer-threejs-statistics-tooltip,#gemini-viewer-threejs-tips-tooltip,#gemini-viewer-threejs-cameraInfo-tooltip{position:absolute;right:5px;bottom:30px;background:#666666;color:#fff;padding:8px 8px 5px;font-size:.8rem;border-radius:4px;z-index:3;opacity:.9;user-select:none}#gemini-viewer-threejs-statistics-tooltip p,#gemini-viewer-threejs-tips-tooltip p,#gemini-viewer-threejs-cameraInfo-tooltip p{padding-bottom:3px;margin:3px}#gemini-viewer-threejs-statistics-tooltip p span,#gemini-viewer-threejs-tips-tooltip p span,#gemini-viewer-threejs-cameraInfo-tooltip p span{float:left;margin-right:10px}.context-menu{position:absolute;box-sizing:border-box;background-color:#fff;width:200px;padding:2px;border-radius:2px;box-shadow:0 4px 8px #0003,0 6px 20px #00000030;cursor:pointer;z-index:2}.context-menu ul{list-style:none;padding:0}.context-menu ul:last-child li{border-bottom:0px}.context-menu li{height:2rem;padding:.5rem;box-sizing:border-box}.context-menu li:hover{background-color:#d3d3d3}.context-menu li.disabled{color:#ccc;cursor:not-allowed}.context-menu li:last-child{border-bottom:1px solid #000}#navCube{width:135px;height:135px;position:absolute;bottom:10px;right:10px;z-index:1;pointer-events:none;cursor:pointer}#navCube:hover{opacity:1}.css3d-navcube .navcube-plane{backface-visibility:hidden;z-index:1;transition:all .2s}.css3d-navcube .navcube-plane.outer{opacity:.7;background:linear-gradient(-45deg,transparent 15px,#efefef 0) bottom right,linear-gradient(-135deg,transparent 15px,#efefef 0) top right,linear-gradient(135deg,transparent 15px,#efefef 0) top left,linear-gradient(45deg,transparent 15px,#efefef 0) bottom left;background-size:70% 70%;background-repeat:no-repeat}.css3d-navcube .navcube-plane.inner{margin:2px;font-size:30px;text-align:center;line-height:100px;background:linear-gradient(-45deg,transparent 14px,#2c7be5 0) bottom right,linear-gradient(-135deg,transparent 14px,#2c7be5 0) top right,linear-gradient(135deg,transparent 14px,#2c7be5 0) top left,linear-gradient(45deg,transparent 14px,#2c7be5 0) bottom left;background-size:70% 70%;background-repeat:no-repeat}.css3d-navcube .navcube-plane:hover{opacity:1!important}.css3d-navcube .navcube-edge{opacity:0;z-index:2;transition:all .2s}.css3d-navcube .navcube-edge:hover{opacity:1!important}.css3d-navcube .navcube-corner{opacity:.7;backface-visibility:hidden;box-sizing:content-box;transform-origin:50% 33%;top:4px;z-index:3;transition:all .2s}.css3d-navcube .navcube-corner-plane{opacity:0;backface-visibility:hidden;transform-origin:bottom;top:-6.5px;z-index:3;transition:all .2s}.css3d-navcube .highlight{opacity:1}#overview-map{width:200px;height:200px;top:10px;left:10px;position:absolute;z-index:1;border:1px #50505090 solid;background-color:#80808030}.gemini-spinner{display:flex;flex-flow:row nowrap;align-items:center;justify-content:space-between;width:2em;position:absolute;pointer-events:none;top:50%;left:50%;transform:translate(-50%,-50%);font-size:14px}.gemini-spinner.hidden{display:none}.gemini-spinner span{width:.3em;height:1em;background-color:#3cefff}.gemini-spinner span:nth-of-type(1){animation:grow 1s -.45s ease-in-out infinite}.gemini-spinner span:nth-of-type(2){animation:grow 1s -.3s ease-in-out infinite}.gemini-spinner span:nth-of-type(3){animation:grow 1s -.15s ease-in-out infinite}.gemini-spinner span:nth-of-type(4){animation:grow 1s ease-in-out infinite}@keyframes grow{0%,to{transform:scaleY(1)}50%{transform:scaleY(2)}}.statsOutput{position:absolute;opacity:.6;top:1px;left:1px}.toolbar{position:absolute;display:flex;box-sizing:border-box;height:68px;left:50%;bottom:40px;padding:8px 20px;box-shadow:1px 3px 10px #0006;border-radius:4px;background:rgba(255,255,255,.8);transform:translate(-50%);align-items:center;z-index:10;user-select:none}.toolbar .toolbar-group{display:flex;padding:0 2px;box-sizing:border-box}.toolbar .toolbar-group-division{width:1px;background-color:#999c;height:60%}.toolbar .toolbar-menu{display:flex;box-sizing:border-box;flex-direction:column;word-break:break-word;width:50px;height:50px;padding:3px 1px;margin:0 2px;transition:all .3s;cursor:pointer;color:#666;border-radius:4px}.toolbar .toolbar-menu.active{color:#2c7be5}.toolbar .toolbar-menu .icon{width:24px;height:24px;margin:auto;font-size:24px;line-height:normal}.toolbar .toolbar-menu span{display:block;width:100%;margin:auto;font-size:12px;text-align:center;user-select:none}.toolbar .toolbar-menu-active{color:#2c7be5;background-color:#fffc}.toolbar .toolbar-parent-menu{position:relative}.toolbar .toolbar-parent-menu-active .toolbar-sub-menu{display:block}.toolbar .toolbar-parent-menu-active .toolbar-sub-menu-list{background:rgba(255,255,255,.8)}.toolbar .toolbar-parent-menu:after{content:"";position:absolute;box-sizing:border-box;width:0;height:0;right:2px;top:2px;border-width:4px;border-style:solid;border-top-color:#666;border-right-color:#666;border-bottom-color:transparent;border-left-color:transparent;border-radius:1px}.toolbar .toolbar-sub-menu{display:none;position:absolute;min-width:50px;bottom:100%;box-shadow:1px 3px 10px #0006}.toolbar .toolbar-sub-menu .toolbar-sub-menu-list{margin-bottom:2px;border-radius:4px}.toolbar .toolbar-sub-menu .toolbar-sub-menu-list .toolbar-menu{margin:0}@media screen and (max-width:768px){.toolbar .toolbar-menu{width:30px;height:30px;margin:0}.toolbar .toolbar-menu .icon+span{display:none}.toolbar .toolbar-parent-menu:after{top:1px;right:0}.toolbar .toolbar-sub-menu{min-width:30px}}#viewCube{width:150px;height:150px;position:absolute;bottom:10px;right:10px;z-index:1}.anchor{position:absolute;top:0;left:0;opacity:0;width:20px;height:20px;transform:translate(-50%,-50%);pointer-events:none;user-select:none;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAAAXNSR0IArs4c6QAADjRJREFUeF7tXQnQttUYvq4Zxr5MqBgaihRlKakUU7SYSBQljUhaxijtso2MTCrRn8YoldKIUlIIJRplSyKyqzGyJDSDLGHmMtfvvOb19n7fe7Zn+/7nnnnn+/7/O8t9zrne+5xzn3sh1hCS9GUA20UO9xqS20eWHXQxDpr7BOZHAMyfrBEA8+dllAAJX65BFB0lwCgBxjPAHAyMW8C4BQxCghczOW4B4xYwbgHjFjDqAWYxMJ4BxjNA8fY6iAbGM8B4BhjPAGvKGUDSYwA8FcAmAJ4EYOPw8/6R4upvAH4I4Efh580AbiJ5W2T9wRRbEWcASTuFBX/a1KLfq/Iq/HsKDN8NgLiych+tNzdYAEh6JoAXAdgtLHrrkwfAkuEyAJeTvL4LBkr7HBQAJK0fFtwLH/u0WzpHsfWvMRAMCJK3xlbqutwgACDplVMLf++uJ21B//+aAsL5PecVvQaApB0BHA3AP4dIVwE4maR/9pJ6CYBwij8GwOt7OWvpTJ0O4KQ+3iJ6BwBJXnQvvq9yK4l8hTQIDIbeUG8AsALEfeyi9mpb6AUAJL0bwBtjZ3CFlDuR5LFdj6VzAEi6EMCeXU9ER/1fRHKvjvpe3W1nAJC0NoDPAnhGwxNwF4DbZz6/m/q3u183fNaZ+n3yfw9smL8bALyA5B0N9zO3+U4AIMmL/gUAazU0aKtor/CH5M9K+pD0BAC7hI9Vzk3QnQB2JmkwtEqtA0DS7gAuqTxKn7C96F8EcBXJP1Zuf3Vzkh4WdBI7ADAYat9U9iD5ySZ4X6rNVgEg6TAA76s4wKsBnBa+6X6saY0k+bHJkuFQAM+r2PHhJE+t2N6yTbUGAEkHADiz0sBu8sKTPKdSe0XNSHpNAIKfoGvQgSQ/VKOhRW20AoDwcvfNRcxE/P034Rvvxf97RPnWiki6XwCBJcKjKnS8ZRsvjI0DILzg3VI4IX5gsahf1Ud16vTYghr7DQEMpQ9XGzT9stgoACQ9BMD3Cw9LlhyvI3ljIYharS5pMwAfALBlQcc+3G5K8k8FbXR3BpDkE+1LCpj3+/o+JH2XHxxJsg7ho8FwJZf/S0n65tQINSYBJH0QwEEFXJ9F0gfHwZMkH+heWzCQM0geXFB/yaqNAEDS8QDeUsDwsSRPLKjfu6qS/NbhN49cehfJt+ZWXqpedQCEV70SY8ltSX619kD70J6kbQBcV8DLTrWNS5oAgBc/y4KHZHV+Cia7saqSlNm4tZxV1dFVJzwYc7w/c3BPJPnTzLqDqiZpQwA/yWT6kJpGJdUAEO6/Ft05+vFdSX4mc0IGWU3SCwF8OoN5Xw23qaUPqQkAf/NzbPiOJPnejIkYfBVJRwA4JWMgp5M8JKPePapUAUDBwa+x602NyWmjjYLrcpUDYS0A5Bz87Ky5C8l/tDHRs31IesTUdnUbyd93xMd9g+1CalzCKgfCYgAEp42PJE6edftbtaXeDWrZ59ryJiz6owHcZ4bnuwH8CoD3WFsqfall/r4BIPXtYF+SRc4nNQBwMYA9EgFwCsmjEuskFZe0c7A1tAuZXcpyyC5edvmy7Z4tmBojSe8BcGRiB5eQfGlinf8rXgSA8NL340Tk+knX3/5GXK0l+U3ehievLpmYOXXPBXAqSdsiVKdwi7IUSHlKtiTdqOTFsBQAhwNIPcE3ouaVZN9/q0q9+H6bb4Jsg2BrneNJOoZAVcpUFx9BMtvKqhQAKVE3PFn+9mxd25hD0tMB+PHJLuNtkF3BDyb5nZqdBaOSr4dYB7FNF4W1zQZAppXP/rXNuCS9HMDHYmercrm9SX68ZpvBvOzsxDazrYdKAJD64nc1SVvTViNJbwdwXLUG8xo6juQ78qrOryXJ1s0phqbZL4UlALClj2PwxNJuJG3gUYXCKf/zVRorb+RZJC26q5AkB8Bw5JFYupnkprGFp8tlASBD8/dbAOuRrGK6XeFZNWeuFtV5HMlfLCoU8/dgcv5LAI+MKR/KZGkGcwHg+6rvrbF0Acl9YgsvVy5c8+z1k3JdqtH1ojasDfWj1j8XFYz5uySbkr0ipmwocxTJ5HeFXAD4TvyqBOaq2blL8jaya0LfbRY9geSba3SY4UdxHslk3UcuAL4NwFavsbRODefHgifUWD5Ly1lP4GtusbIoOM/aiTWWbiS5eWzhSblkAEiy6PVeF6u3vpbkc1IZm1e+59/+Ccvnktyv0ni/AuDZkW1ZK/hYkta0RlMOAGySlKIXr6L5G8C3f3rSn1/j7SBDM2gP4yR7zBwApKp/Nybp94IiknQBgL2LGmmvctZ+PMuepI1CuNpYzpPVwjkAsJbKzpAxdBfJB8UUXK6MJLfxawDFbZXyElnf9gXrRZZdtpikvwCIDVJxDsn9U/rNAYBdtWJ17j8n6QALRSRpXwDnFTXSfuUqyiFJDnDx+Ej2ryeZ5IrGEEc/sv3VxbYA8IDICteRjD3ELNlkBRezSHarFnsbSavLi0jStQC2jWzkrwC+FVl2dTEDINdGPaafi0m+LKbggi2gSR5L2VuqftEr3aRRSZ8AUGT0sdwAmwZAsfWqpAcDaMw7tqnVB3ALyVjRvZz0y7W2jhpa0wAoFoOSbL/XiPVQ1AzlF7qbpA0+i0iSjVzeWdTIMpWbBsABJM8qYV6SM378oKSNDuuuXWptLMlexY2Fi2kaAMUeP5K2BvC1DhexpOvNSy2Lm1aAjQAoWd7Fddd4AIxbQKHDydC3gPEQuFhKLFti6IfA8RpYDoBBXwNHRVA5ABpXBNm2P4X8DhCbgLGWKjjVPCplPE2VPZpkitncXD4SVcF2VklKX5fzGGRdc2yI91qPQQ4112oQ5QqoKL4BmIfEx6AbSPqtJppyAGBPYKdxi6Faz8F+DrXnrgNPDoFuJblBDUYTn4PPJ+mX02jKAYDTnJwQ3QOwYWnM/vBNSAFeAnuNFE1+l5/HRchVkBI36U0kk0LR5QAgNbbNYSRXlU5z0xqxUv5m6tcyCXPM4ZTQ8cma1xwAOAiU/eZjkzNfSdK++sW0BhqF2vYyNiycnW7WT3W7TwZAEMc2e35Kwoo+vEYWjwFIgZpm4c5O8oeEOf4eyeR8BbkASL2WVfOi7bkUqOkYkur1nOV9lQsA5/M9KQGdZ5MsCZb8v64kbQXgcwAemtB/G0V9/96+VuAISX5GTzHwPIbkyakDzQVAqm+ADTq8P9VyDrXPnKVQn2izWgEjgnOoz1kpQTeTfQI8eVkACOeArt3DHSjRWUT6QNW2uDC3/XYPD0yOASL+C701NkCE3wRSE0E1ESLGV8yuAkVUue9Pi7DBhIgJUqAvQaIch/+iFmMG2AFzz9p5DQYVJCoAINVP0NWqOIvObvwhcIStZ5uOHeAI3zZ0KXYBnzOGnKwiyf6A0/1mHwIDAByBs2+BIq2qPrABIHjhz2wqrP0gA0UGEPQ1VKyB4Ouif+Y6ldox03kMrGRpNJ/BIEPFBgD4abi3waKDZ7HtCV6ckMLuUgCfAuCUbQZBoxSCWQ8zWHQAQU64eN8gdmg7J2BwNbO7mT8T+wK7nv3ZH5L+2RqF3IKOC5jk1RuypMc+FC05nqIzwKTVjLBxk6qXk9yttdnuYUeSHA/Qip9UygoLN9tJFQAEKZBrvbpiEkSmrmBBQslia+sJrzUBYL11btKoRq6GqQvSZvmM+D8T9vqZNCpIASeNyk0bt2ITRs6575ckkOxn2rip80DOgXB19TFx5EIZVCVP0HQv1baACgfCSRMrNoFkYcJIz0+Vg1+jAAhbgS1TrdbMpWTjxtyO2qpXwZztRJK2yK5K1SXAlCS4MCRtymV4xSSULEgQOZk7J63aK3cil6vXGACCJEjxIprH5xnOAdRVbsHSCZfkEDE26z6ooK1kb5+UvpoGwNoh0uVaKUzNlPWTs0Oh31jQRutVg3rXvoGpCSGneb0TgCOt3tHUABoFQJAC9iNMil03Z7AOhGzzr1Wpdu9NTdxS7YZXPTt0HJoQUHup5rYgeUOTY2gcAAEEuwO4pMJAbIhhIJxWO/NYKW/BmMOL7k+NZBZ7kGzcIbYVAAQQOJ9fdn67mQWyMYZBcE7pwtWoH8y4vPDJjhlL9H84yRSXsOxhtAaAAIIDbFSRze09K14dJMIVtUzOY3kLptu7hG98SoavRV1Uy66yqCP/vVUABBDkGJMuGouTUvmw6Dy/lzV1aApZPPx66XzEPtylJHVaNAb/PTv/X0zj88q0DoAAApuSebFSHB9SxugAy84AbjAU5SoIMfu96M48Xhz4eolB+IFnu5IcwCmTM122EwAEENgY48MJVjq5Y7wLwO0zH+fimfyf2103fNaZ+n3yf7Gx+nP5s/XRfiQ7iYfcGQAmsyXJOX9LFCW5E9+HemeQPLhLRjoHQJAGqV5GXc5Zrb6z073WYqCTQ+BSzAezMnsd71hzgD1s6yoAJ5P0z86pFxJgehYk2ajkmAYPiF1Nug96J5E8vSsGenMLWDQBQZ1qEBgMK4G86F783uU96J0EmJEG3g6GvC30StwPRgLMMirJzie+i9t8OjZjaVeSww9Xzm9sHcT5XTER22+vJcAcIFiBNAGCtXF9Iiu2Jgvv6B6DoEEBYGZ7sErZEsGA2KSj2b7Z33QvPMmkGL0d8XuPbgcLgDlnBYet23TqU3ursGh3WJzJx2HZenGVKwHTigDAnK3C7/GWCk8OPye/xya8dAJGJ6ryN9yf1b+nZuYuWZi26q5IAMybvJAhNfbcUCXpY1uLWNLPCID5szcCoARVfaw7SoD5qzJKgFEC9PH7Wp+nUQKMEiAlpN14Bqj/Hey2xVECjBJglABzMDAeAsdDYLeiua3exy1g3ALGLWDcAlY7dMTQGnML+A8qtnUcTFYqYAAAAABJRU5ErkJggg==) no-repeat center center;background-size:100% 100%;background-blend-mode:lighten;filter:invert(61%) sepia(87%) saturate(845%) hue-rotate(120deg) brightness(94%) contrast(101%);transition:opacity .5s ease-in-out}.anchor.active{opacity:1}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(360deg)}}\n',document.head.appendChild(e)}}();var RSe=fetch;window.fetch=(...e)=>Promise.resolve(RSe(...e));var kcn=ji(AG(),1),Fcn=ji(nce(),1),Ncn=ji(rce(),1),Wt={};FT(Wt,{ACESFilmicToneMapping:()=>Jue,AddEquation:()=>qo,AddOperation:()=>Yue,AdditiveAnimationBlendMode:()=>GU,AdditiveBlending:()=>_c,AlphaFormat:()=>nhe,AlwaysCompare:()=>bhe,AlwaysDepth:()=>Vue,AlwaysStencilFunc:()=>dhe,AmbientLight:()=>Pl,AmbientLightProbe:()=>dU,AnimationAction:()=>qR,AnimationClip:()=>po,AnimationLoader:()=>iU,AnimationMixer:()=>xU,AnimationObjectGroup:()=>yU,AnimationUtils:()=>Blt,ArcCurve:()=>gm,ArrayCamera:()=>_R,ArrowHelper:()=>Mc,Audio:()=>zR,AudioAnalyser:()=>gU,AudioContext:()=>Db,AudioListener:()=>pU,AudioLoader:()=>uU,AxesHelper:()=>DU,BackSide:()=>Ki,BasicDepthPacking:()=>uhe,BasicShadowMap:()=>Mnt,Bone:()=>Ml,BooleanKeyframeTrack:()=>Qh,Box2:()=>Ji,Box3:()=>Ot,Box3Helper:()=>IU,BoxGeometry:()=>va,BoxHelper:()=>PU,BufferAttribute:()=>mn,BufferGeometry:()=>Dt,BufferGeometryLoader:()=>VR,ByteType:()=>ehe,Cache:()=>Em,Camera:()=>Xh,CameraHelper:()=>Fb,CanvasTexture:()=>Eb,CapsuleGeometry:()=>uv,CatmullRomCurve3:()=>MR,CineonToneMapping:()=>Kue,CircleGeometry:()=>hv,ClampToEdgeWrapping:()=>Ai,Clock:()=>mo,Color:()=>ct,ColorKeyframeTrack:()=>Cb,ColorManagement:()=>Tl,CompressedArrayTexture:()=>JB,CompressedCubeTexture:()=>QB,CompressedTexture:()=>Mu,CompressedTextureLoader:()=>sU,ConeGeometry:()=>dv,CubeCamera:()=>bR,CubeReflectionMapping:()=>Gh,CubeRefractionMapping:()=>af,CubeTexture:()=>mm,CubeTextureLoader:()=>Pb,CubeUVReflectionMapping:()=>wv,CubicBezierCurve:()=>_b,CubicBezierCurve3:()=>RR,CubicInterpolant:()=>kR,CullFaceBack:()=>rB,CullFaceFront:()=>Iue,CullFaceFrontBack:()=>Snt,CullFaceNone:()=>Pue,Curve:()=>Va,CurvePath:()=>CR,CustomBlending:()=>Mm,CustomToneMapping:()=>Que,CylinderGeometry:()=>wc,Cylindrical:()=>wU,Data3DTexture:()=>gb,DataArrayTexture:()=>sv,DataTexture:()=>Sl,DataTextureLoader:()=>Tm,DataUtils:()=>Av,DecrementStencilOp:()=>knt,DecrementWrapStencilOp:()=>Nnt,DefaultLoadingManager:()=>go,DepthFormat:()=>sf,DepthStencilFormat:()=>Wh,DepthTexture:()=>cf,DirectionalLight:()=>js,DirectionalLightHelper:()=>kb,DiscreteInterpolant:()=>FR,DisplayP3ColorSpace:()=>jU,DodecahedronGeometry:()=>fv,DoubleSide:()=>Sr,DstAlphaFactor:()=>_v,DstColorFactor:()=>Tv,DynamicCopyUsage:()=>Jnt,DynamicDrawUsage:()=>jnt,DynamicReadUsage:()=>$nt,EdgesGeometry:()=>Cu,EllipseCurve:()=>Kh,EqualCompare:()=>mhe,EqualDepth:()=>Gue,EqualStencilFunc:()=>Vnt,EquirectangularReflectionMapping:()=>fm,EquirectangularRefractionMapping:()=>ub,Euler:()=>Xn,EventDispatcher:()=>jo,ExtrudeGeometry:()=>ta,FileLoader:()=>Kr,Float16BufferAttribute:()=>HB,Float32BufferAttribute:()=>Bt,Float64BufferAttribute:()=>VB,FloatType:()=>ga,Fog:()=>wu,FogExp2:()=>ov,FramebufferTexture:()=>KB,FrontSide:()=>pi,Frustum:()=>ya,GLBufferAttribute:()=>_U,GLSL1:()=>ert,GLSL3:()=>IB,GreaterCompare:()=>vhe,GreaterDepth:()=>Wue,GreaterEqualCompare:()=>xhe,GreaterEqualDepth:()=>que,GreaterEqualStencilFunc:()=>Wnt,GreaterStencilFunc:()=>Gnt,GridHelper:()=>Ob,Group:()=>er,HalfFloatType:()=>Rr,HemisphereLight:()=>Du,HemisphereLightHelper:()=>AU,HemisphereLightProbe:()=>hU,IcosahedronGeometry:()=>pv,ImageBitmapLoader:()=>Lb,ImageLoader:()=>_m,ImageUtils:()=>mb,IncrementStencilOp:()=>Ont,IncrementWrapStencilOp:()=>Fnt,InstancedBufferAttribute:()=>Zh,InstancedBufferGeometry:()=>HR,InstancedInterleavedBuffer:()=>EU,InstancedMesh:()=>Pi,Int16BufferAttribute:()=>BB,Int32BufferAttribute:()=>UB,Int8BufferAttribute:()=>FB,IntType:()=>NU,InterleavedBuffer:()=>$h,InterleavedBufferAttribute:()=>fo,Interpolant:()=>Jh,InterpolateDiscrete:()=>jh,InterpolateLinear:()=>Tu,InterpolateSmooth:()=>pR,InvertStencilOp:()=>Bnt,KeepStencilOp:()=>mR,KeyframeTrack:()=>Yo,LOD:()=>SR,LatheGeometry:()=>ym,Layers:()=>lf,LessCompare:()=>phe,LessDepth:()=>zue,LessEqualCompare:()=>ghe,LessEqualDepth:()=>gR,LessEqualStencilFunc:()=>znt,LessStencilFunc:()=>Hnt,Light:()=>Ws,LightProbe:()=>xv,Line:()=>hr,Line3:()=>sa,LineBasicMaterial:()=>Gn,LineCurve:()=>cv,LineCurve3:()=>AR,LineDashedMaterial:()=>Iu,LineLoop:()=>lv,LineSegments:()=>Wr,LinearEncoding:()=>WU,LinearFilter:()=>Ir,LinearInterpolant:()=>Ab,LinearMipMapLinearFilter:()=>Int,LinearMipMapNearestFilter:()=>Pnt,LinearMipmapLinearFilter:()=>Ua,LinearMipmapNearestFilter:()=>Rm,LinearSRGBColorSpace:()=>Ha,LinearToneMapping:()=>$ue,Loader:()=>Er,LoaderUtils:()=>ra,LoadingManager:()=>Lu,LoopOnce:()=>ohe,LoopPingPong:()=>che,LoopRepeat:()=>lhe,LuminanceAlphaFormat:()=>rhe,LuminanceFormat:()=>YR,MOUSE:()=>jR,Material:()=>yr,MaterialLoader:()=>bv,MathUtils:()=>An,Matrix3:()=>Ln,Matrix4:()=>et,MaxEquation:()=>oB,Mesh:()=>xt,MeshBasicMaterial:()=>on,MeshDepthMaterial:()=>Tc,MeshDistanceMaterial:()=>xb,MeshLambertMaterial:()=>Pu,MeshMatcapMaterial:()=>OR,MeshNormalMaterial:()=>df,MeshPhongMaterial:()=>na,MeshPhysicalMaterial:()=>Xo,MeshStandardMaterial:()=>hf,MeshToonMaterial:()=>DR,MinEquation:()=>aB,MirroredRepeatWrapping:()=>qh,MixOperation:()=>Xue,MultiplyBlending:()=>sB,MultiplyOperation:()=>Nb,NearestFilter:()=>Jr,NearestMipMapLinearFilter:()=>Cnt,NearestMipMapNearestFilter:()=>Ant,NearestMipmapLinearFilter:()=>zh,NearestMipmapNearestFilter:()=>of,NeverCompare:()=>fhe,NeverDepth:()=>Hue,NeverStencilFunc:()=>Unt,NoBlending:()=>Qr,NoColorSpace:()=>_u,NoToneMapping:()=>Vh,NormalAnimationBlendMode:()=>ZR,NormalBlending:()=>hm,NotEqualCompare:()=>yhe,NotEqualDepth:()=>jue,NotEqualStencilFunc:()=>qnt,NumberKeyframeTrack:()=>Cl,Object3D:()=>an,ObjectLoader:()=>cU,ObjectSpaceNormalMap:()=>hhe,OctahedronGeometry:()=>bm,OneFactor:()=>Oue,OneMinusDstAlphaFactor:()=>Nue,OneMinusDstColorFactor:()=>Bue,OneMinusSrcAlphaFactor:()=>FU,OneMinusSrcColorFactor:()=>Fue,OrthographicCamera:()=>Ur,PCFShadowMap:()=>OU,PCFSoftShadowMap:()=>Ev,PMREMGenerator:()=>Yh,Path:()=>Ru,PerspectiveCamera:()=>ur,Plane:()=>Gr,PlaneGeometry:()=>ui,PlaneHelper:()=>LU,PointLight:()=>Sc,PointLightHelper:()=>RU,Points:()=>ii,PointsMaterial:()=>xi,PolarGridHelper:()=>CU,PolyhedronGeometry:()=>Au,PositionalAudio:()=>mU,PropertyBinding:()=>Jn,PropertyMixer:()=>GR,QuadraticBezierCurve:()=>Tb,QuadraticBezierCurve3:()=>wb,Quaternion:()=>dr,QuaternionKeyframeTrack:()=>Ga,QuaternionLinearInterpolant:()=>NR,RED_GREEN_RGTC2_Format:()=>CB,RED_RGTC1_Format:()=>ahe,REVISION:()=>WR,RGBADepthPacking:()=>Rv,RGBAFormat:()=>ea,RGBAIntegerFormat:()=>zU,RGBA_ASTC_10x10_Format:()=>SB,RGBA_ASTC_10x5_Format:()=>_B,RGBA_ASTC_10x6_Format:()=>TB,RGBA_ASTC_10x8_Format:()=>wB,RGBA_ASTC_12x10_Format:()=>MB,RGBA_ASTC_12x12_Format:()=>RB,RGBA_ASTC_4x4_Format:()=>pB,RGBA_ASTC_5x4_Format:()=>mB,RGBA_ASTC_5x5_Format:()=>gB,RGBA_ASTC_6x5_Format:()=>vB,RGBA_ASTC_6x6_Format:()=>yB,RGBA_ASTC_8x5_Format:()=>xB,RGBA_ASTC_8x6_Format:()=>bB,RGBA_ASTC_8x8_Format:()=>EB,RGBA_BPTC_Format:()=>fR,RGBA_ETC2_EAC_Format:()=>fB,RGBA_PVRTC_2BPPV1_Format:()=>hB,RGBA_PVRTC_4BPPV1_Format:()=>uB,RGBA_S3TC_DXT1_Format:()=>uR,RGBA_S3TC_DXT3_Format:()=>hR,RGBA_S3TC_DXT5_Format:()=>dR,RGB_ETC1_Format:()=>she,RGB_ETC2_Format:()=>dB,RGB_PVRTC_2BPPV1_Format:()=>cB,RGB_PVRTC_4BPPV1_Format:()=>lB,RGB_S3TC_DXT1_Format:()=>cR,RGFormat:()=>ihe,RGIntegerFormat:()=>VU,RawShaderMaterial:()=>LR,Ray:()=>ho,Raycaster:()=>ia,RectAreaLight:()=>BR,RedFormat:()=>$R,RedIntegerFormat:()=>HU,ReinhardToneMapping:()=>Zue,RenderTarget:()=>xR,RepeatWrapping:()=>Ci,ReplaceStencilOp:()=>Dnt,ReverseSubtractEquation:()=>Due,RingGeometry:()=>mv,SIGNED_RED_GREEN_RGTC2_Format:()=>PB,SIGNED_RED_RGTC1_Format:()=>AB,SRGBColorSpace:()=>tn,Scene:()=>_i,ShaderChunk:()=>$n,ShaderLib:()=>xc,ShaderMaterial:()=>ln,ShadowMaterial:()=>IR,Shape:()=>Ss,ShapeGeometry:()=>Al,ShapePath:()=>Sm,ShapeUtils:()=>qs,ShortType:()=>the,Skeleton:()=>Rl,SkeletonHelper:()=>MU,SkinnedMesh:()=>Su,Source:()=>bc,Sphere:()=>vr,SphereGeometry:()=>za,Spherical:()=>ff,SphericalHarmonics3:()=>UR,SplineCurve:()=>vm,SpotLight:()=>Ou,SpotLightHelper:()=>SU,Sprite:()=>wR,SpriteMaterial:()=>bb,SrcAlphaFactor:()=>kU,SrcAlphaSaturateFactor:()=>Uue,SrcColorFactor:()=>kue,StaticCopyUsage:()=>Knt,StaticDrawUsage:()=>db,StaticReadUsage:()=>Ynt,StereoCamera:()=>fU,StreamCopyUsage:()=>Qnt,StreamDrawUsage:()=>Xnt,StreamReadUsage:()=>Znt,StringKeyframeTrack:()=>ed,SubtractEquation:()=>Lue,SubtractiveBlending:()=>iB,TOUCH:()=>wnt,TangentSpaceNormalMap:()=>mf,TetrahedronGeometry:()=>gv,Texture:()=>qr,TextureLoader:()=>Rs,TorusGeometry:()=>uf,TorusKnotGeometry:()=>vv,Triangle:()=>Zr,TriangleFanDrawMode:()=>Mv,TriangleStripDrawMode:()=>Bb,TrianglesDrawMode:()=>qU,TubeGeometry:()=>yv,TwoPassDoubleSide:()=>Rnt,UVMapping:()=>XR,Uint16BufferAttribute:()=>pm,Uint32BufferAttribute:()=>yb,Uint8BufferAttribute:()=>vb,Uint8ClampedBufferAttribute:()=>NB,Uniform:()=>wm,UniformsGroup:()=>bU,UniformsLib:()=>Jt,UniformsUtils:()=>Ti,UnsignedByteType:()=>Ec,UnsignedInt248Type:()=>bu,UnsignedIntType:()=>Hh,UnsignedShort4444Type:()=>BU,UnsignedShort5551Type:()=>UU,UnsignedShortType:()=>Sv,VSMShadowMap:()=>yu,Vector2:()=>be,Vector3:()=>O,Vector4:()=>gr,VectorKeyframeTrack:()=>qa,VideoTexture:()=>ZB,WebGL1Renderer:()=>TR,WebGL3DRenderTarget:()=>OB,WebGLArrayRenderTarget:()=>DB,WebGLCoordinateSystem:()=>xu,WebGLCubeRenderTarget:()=>ER,WebGLMultipleRenderTargets:()=>kB,WebGLRenderTarget:()=>sr,WebGLRenderer:()=>Ms,WebGLUtils:()=>Phe,WebGPUCoordinateSystem:()=>fb,WireframeGeometry:()=>PR,WrapAroundEnding:()=>hb,ZeroCurvatureEnding:()=>lm,ZeroFactor:()=>pf,ZeroSlopeEnding:()=>cm,ZeroStencilOp:()=>Lnt,_SRGBAFormat:()=>vR,sRGBEncoding:()=>Eu});var WR="155",jR={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},wnt={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Pue=0,rB=1,Iue=2,Snt=3,Mnt=0,OU=1,Ev=2,yu=3,pi=0,Ki=1,Sr=2,Rnt=2,Qr=0,hm=1,_c=2,iB=3,sB=4,Mm=5,qo=100,Lue=101,Due=102,aB=103,oB=104,pf=200,Oue=201,kue=202,Fue=203,kU=204,FU=205,_v=206,Nue=207,Tv=208,Bue=209,Uue=210,Hue=0,Vue=1,zue=2,gR=3,Gue=4,que=5,Wue=6,jue=7,Nb=0,Xue=1,Yue=2,Vh=0,$ue=1,Zue=2,Kue=3,Jue=4,Que=5,XR=300,Gh=301,af=302,fm=303,ub=304,wv=306,Ci=1e3,Ai=1001,qh=1002,Jr=1003,of=1004,Ant=1004,zh=1005,Cnt=1005,Ir=1006,Rm=1007,Pnt=1007,Ua=1008,Int=1008,Ec=1009,ehe=1010,the=1011,Sv=1012,NU=1013,Hh=1014,ga=1015,Rr=1016,BU=1017,UU=1018,bu=1020,nhe=1021,ea=1023,YR=1024,rhe=1025,sf=1026,Wh=1027,$R=1028,HU=1029,ihe=1030,VU=1031,zU=1033,cR=33776,uR=33777,hR=33778,dR=33779,lB=35840,cB=35841,uB=35842,hB=35843,she=36196,dB=37492,fB=37496,pB=37808,mB=37809,gB=37810,vB=37811,yB=37812,xB=37813,bB=37814,EB=37815,_B=37816,TB=37817,wB=37818,SB=37819,MB=37820,RB=37821,fR=36492,ahe=36283,AB=36284,CB=36285,PB=36286,ohe=2200,lhe=2201,che=2202,jh=2300,Tu=2301,pR=2302,lm=2400,cm=2401,hb=2402,ZR=2500,GU=2501,qU=0,Bb=1,Mv=2,WU=3e3,Eu=3001,uhe=3200,Rv=3201,mf=0,hhe=1,_u="",tn="srgb",Ha="srgb-linear",jU="display-p3",Lnt=0,mR=7680,Dnt=7681,Ont=7682,knt=7683,Fnt=34055,Nnt=34056,Bnt=5386,Unt=512,Hnt=513,Vnt=514,znt=515,Gnt=516,qnt=517,Wnt=518,dhe=519,fhe=512,phe=513,mhe=514,ghe=515,vhe=516,yhe=517,xhe=518,bhe=519,db=35044,jnt=35048,Xnt=35040,Ynt=35045,$nt=35049,Znt=35041,Knt=35046,Jnt=35050,Qnt=35042,ert="100",IB="300 es",vR=1035,xu=2e3,fb=2001,jo=class{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});let n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;let n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;let n=this._listeners[e];if(void 0!==n){let e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;let t=this._listeners[e.type];if(void 0!==t){e.target=this;let n=t.slice(0);for(let t=0,i=n.length;t>8&255]+pa[e>>16&255]+pa[e>>24&255]+"-"+pa[255&t]+pa[t>>8&255]+"-"+pa[t>>16&15|64]+pa[t>>24&255]+"-"+pa[63&n|128]+pa[n>>8&255]+"-"+pa[n>>16&255]+pa[n>>24&255]+pa[255&i]+pa[i>>8&255]+pa[i>>16&255]+pa[i>>24&255]).toLowerCase()}function cs(e,t,n){return Math.max(t,Math.min(n,e))}function XU(e,t){return(e%t+t)%t}function trt(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)}function nrt(e,t,n){return e!==t?(n-e)/(t-e):0}function sb(e,t,n){return(1-n)*e+n*t}function rrt(e,t,n,i){return sb(e,t,1-Math.exp(-n*i))}function irt(e,t=1){return t-Math.abs(XU(e,2*t)-t)}function srt(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)}function art(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)}function ort(e,t){return e+Math.floor(Math.random()*(t-e+1))}function lrt(e,t){return e+Math.random()*(t-e)}function crt(e){return e*(.5-Math.random())}function urt(e){void 0!==e&&(ice=e);let t=ice+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}function hrt(e){return e*dm}function drt(e){return e*iv}function LB(e){return 0==(e&e-1)&&0!==e}function Ehe(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function yR(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function frt(e,t,n,i,r){let a=Math.cos,s=Math.sin,o=a(n/2),l=s(n/2),h=a((t+i)/2),c=s((t+i)/2),u=a((t-i)/2),d=s((t-i)/2),p=a((i-t)/2),f=s((i-t)/2);switch(r){case"XYX":e.set(o*c,l*u,l*d,o*h);break;case"YZY":e.set(l*d,o*c,l*u,o*h);break;case"ZXZ":e.set(l*u,l*d,o*c,o*h);break;case"XZX":e.set(o*c,l*f,l*p,o*h);break;case"YXY":e.set(l*p,o*c,l*f,o*h);break;case"ZYZ":e.set(l*f,l*p,o*c,o*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function uo(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function mr(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}var An={DEG2RAD:dm,RAD2DEG:iv,generateUUID:Wo,clamp:cs,euclideanModulo:XU,mapLinear:trt,inverseLerp:nrt,lerp:sb,damp:rrt,pingpong:irt,smoothstep:srt,smootherstep:art,randInt:ort,randFloat:lrt,randFloatSpread:crt,seededRandom:urt,degToRad:hrt,radToDeg:drt,isPowerOfTwo:LB,ceilPowerOfTwo:Ehe,floorPowerOfTwo:yR,setQuaternionFromProperEuler:frt,normalize:mr,denormalize:uo},be=class{constructor(e=0,t=0){be.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(cs(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ln=class{constructor(e,t,n,i,r,a,s,o,l){Ln.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l)}set(e,t,n,i,r,a,s,o,l){let h=this.elements;return h[0]=e,h[1]=i,h[2]=s,h[3]=t,h[4]=r,h[5]=o,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[3],o=n[6],l=n[1],h=n[4],c=n[7],u=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],v=i[1],y=i[4],x=i[7],b=i[2],_=i[5],w=i[8];return r[0]=a*f+s*v+o*b,r[3]=a*m+s*y+o*_,r[6]=a*g+s*x+o*w,r[1]=l*f+h*v+c*b,r[4]=l*m+h*y+c*_,r[7]=l*g+h*x+c*w,r[2]=u*f+d*v+p*b,r[5]=u*m+d*y+p*_,r[8]=u*g+d*x+p*w,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],h=e[8];return t*a*h-t*s*l-n*r*h+n*s*o+i*r*l-i*a*o}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],h=e[8],c=h*a-s*l,u=s*o-h*r,d=l*r-a*o,p=t*c+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);let f=1/p;return e[0]=c*f,e[1]=(i*l-h*n)*f,e[2]=(s*n-i*a)*f,e[3]=u*f,e[4]=(h*t-i*o)*f,e[5]=(i*r-s*t)*f,e[6]=d*f,e[7]=(n*o-l*t)*f,e[8]=(a*t-n*r)*f,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,a,s){let o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*a+l*s)+a+e,-i*l,i*o,-i*(-l*a+o*s)+s+t,0,0,1),this}scale(e,t){return this.premultiply(SN.makeScale(e,t)),this}rotate(e){return this.premultiply(SN.makeRotation(-e)),this}translate(e,t){return this.premultiply(SN.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<9;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}},SN=new Ln;function _he(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}var prt={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function Q0(e,t){return new prt[e](t)}function pb(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}var sce={};function ab(e){e in sce||(sce[e]=!0,console.warn(e))}function nv(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function MN(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}var mrt=(new Ln).fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),grt=(new Ln).fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function vrt(e){return e.convertSRGBToLinear().applyMatrix3(grt)}function yrt(e){return e.applyMatrix3(mrt).convertLinearToSRGB()}var xrt={[Ha]:e=>e,[tn]:e=>e.convertSRGBToLinear(),[jU]:vrt},brt={[Ha]:e=>e,[tn]:e=>e.convertLinearToSRGB(),[jU]:yrt},Tl={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(e){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!e},get workingColorSpace(){return Ha},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,n){if(!1===this.enabled||t===n||!t||!n)return e;let i=xrt[t],r=brt[n];if(void 0===i||void 0===r)throw new Error(`Unsupported color space conversion, "${t}" to "${n}".`);return r(i(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}},I0,mb=class{static getDataURL(e){if(/^data:/i.test(e.src)||"undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===I0&&(I0=pb("canvas")),I0.width=e.width,I0.height=e.height;let n=I0.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=I0}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){let t=pb("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==XR)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ci:e.x=e.x-Math.floor(e.x);break;case Ai:e.x=e.x<0?0:1;break;case qh:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case Ci:e.y=e.y-Math.floor(e.y);break;case Ai:e.y=e.y<0?0:1;break;case qh:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return ab("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===tn?Eu:WU}set encoding(e){ab("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Eu?tn:_u}};qr.DEFAULT_IMAGE=null,qr.DEFAULT_MAPPING=XR,qr.DEFAULT_ANISOTROPY=1;var gr=class{constructor(e=0,t=0,n=0,i=1){gr.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,a=e.elements,s=a[0],o=a[4],l=a[8],h=a[1],c=a[5],u=a[9],d=a[2],p=a[6],f=a[10];if(Math.abs(o-h)<.01&&Math.abs(l-d)<.01&&Math.abs(u-p)<.01){if(Math.abs(o+h)<.1&&Math.abs(l+d)<.1&&Math.abs(u+p)<.1&&Math.abs(s+c+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let e=(s+1)/2,a=(c+1)/2,m=(f+1)/2,g=(o+h)/4,v=(l+d)/4,y=(u+p)/4;return e>a&&e>m?e<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(e),i=g/n,r=v/n):a>m?a<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(a),n=g/i,r=y/i):m<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(m),n=v/r,i=y/r),this.set(n,i,r,t),this}let m=Math.sqrt((p-u)*(p-u)+(l-d)*(l-d)+(h-o)*(h-o));return Math.abs(m)<.001&&(m=1),this.x=(p-u)/m,this.y=(l-d)/m,this.z=(h-o)/m,this.w=Math.acos((s+c+f-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},xR=class extends jo{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new gr(0,0,e,t),this.scissorTest=!1,this.viewport=new gr(0,0,e,t);let i={width:e,height:t,depth:1};void 0!==n.encoding&&(ab("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Eu?tn:_u),this.texture=new qr(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.internalFormat=void 0!==n.internalFormat?n.internalFormat:null,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:Ir,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0!==n.stencilBuffer&&n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null,this.samples=void 0!==n.samples?n.samples:0}setSize(e,t,n=1){(this.width!==e||this.height!==t||this.depth!==n)&&(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new bc(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},sr=class extends xR{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},sv=class extends qr{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Jr,this.minFilter=Jr,this.wrapR=Ai,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},DB=class extends sr{constructor(e=1,t=1,n=1){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new sv(null,e,t,n),this.texture.isRenderTargetTexture=!0}},gb=class extends qr{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=Jr,this.minFilter=Jr,this.wrapR=Ai,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},OB=class extends sr{constructor(e=1,t=1,n=1){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new gb(null,e,t,n),this.texture.isRenderTargetTexture=!0}},kB=class extends sr{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLMultipleRenderTargets=!0;let r=this.texture;this.texture=[];for(let a=0;a=0?1:-1,i=1-t*t;if(i>Number.EPSILON){let r=Math.sqrt(i),a=Math.atan2(r,t*n);e=Math.sin(e*a)/r,s=Math.sin(s*a)/r}let r=s*n;if(o=o*e+u*r,l=l*e+d*r,h=h*e+p*r,c=c*e+f*r,e===1-s){let e=1/Math.sqrt(o*o+l*l+h*h+c*c);o*=e,l*=e,h*=e,c*=e}}e[t]=o,e[t+1]=l,e[t+2]=h,e[t+3]=c}static multiplyQuaternionsFlat(e,t,n,i,r,a){let s=n[i],o=n[i+1],l=n[i+2],h=n[i+3],c=r[a],u=r[a+1],d=r[a+2],p=r[a+3];return e[t]=s*p+h*c+o*d-l*u,e[t+1]=o*p+h*u+l*c-s*d,e[t+2]=l*p+h*d+s*u-o*c,e[t+3]=h*p-s*c-o*u-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){let n=e._x,i=e._y,r=e._z,a=e._order,s=Math.cos,o=Math.sin,l=s(n/2),h=s(i/2),c=s(r/2),u=o(n/2),d=o(i/2),p=o(r/2);switch(a){case"XYZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"YXZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"ZXY":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"ZYX":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"YZX":this._x=u*h*c+l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c-u*d*p;break;case"XZY":this._x=u*h*c-l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],s=t[5],o=t[9],l=t[2],h=t[6],c=t[10],u=n+s+c;if(u>0){let e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(h-o)*e,this._y=(r-l)*e,this._z=(a-i)*e}else if(n>s&&n>c){let e=2*Math.sqrt(1+n-s-c);this._w=(h-o)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(r+l)/e}else if(s>c){let e=2*Math.sqrt(1+s-n-c);this._w=(r-l)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(o+h)/e}else{let e=2*Math.sqrt(1+c-n-s);this._w=(a-i)/e,this._x=(r+l)/e,this._y=(o+h)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(cs(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(0===n)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,i=e._y,r=e._z,a=e._w,s=t._x,o=t._y,l=t._z,h=t._w;return this._x=n*h+a*s+i*l-r*o,this._y=i*h+a*o+r*s-n*l,this._z=r*h+a*l+n*o-i*s,this._w=a*h-n*s-i*o-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);let n=this._x,i=this._y,r=this._z,a=this._w,s=a*e._w+n*e._x+i*e._y+r*e._z;if(s<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,s=-s):this.copy(e),s>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;let o=1-s*s;if(o<=Number.EPSILON){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}let l=Math.sqrt(o),h=Math.atan2(l,s),c=Math.sin((1-t)*h)/l,u=Math.sin(t*h)/l;return this._w=a*c+this._w*u,this._x=n*c+this._x*u,this._y=i*c+this._y*u,this._z=r*c+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(r),n*Math.cos(r),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},O=class{constructor(e=0,t=0,n=0){O.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(ace.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(ace.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,s=e.z,o=e.w,l=o*t+a*i-s*n,h=o*n+s*t-r*i,c=o*i+r*n-a*t,u=-r*t-a*n-s*i;return this.x=l*o+u*-r+h*-s-c*-a,this.y=h*o+u*-a+c*-r-l*-s,this.z=c*o+u*-s+l*-a-h*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,i=e.y,r=e.z,a=t.x,s=t.y,o=t.z;return this.x=i*o-r*s,this.y=r*a-n*o,this.z=n*s-i*a,this}projectOnVector(e){let t=e.lengthSq();if(0===t)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return AN.copy(this).projectOnVector(e),this.sub(AN)}reflect(e){return this.sub(AN.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(cs(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,n=Math.sqrt(1-Oo(e,2));return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},AN=new O,ace=new dr,Ot=class{constructor(e=new O(1/0,1/0,1/0),t=new O(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Dh),Dh.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Xx),_M.subVectors(this.max,Xx),D0.subVectors(e.a,Xx),O0.subVectors(e.b,Xx),k0.subVectors(e.c,Xx),Qd.subVectors(O0,D0),ef.subVectors(k0,O0),Kp.subVectors(D0,k0);let t=[0,-Qd.z,Qd.y,0,-ef.z,ef.y,0,-Kp.z,Kp.y,Qd.z,0,-Qd.x,ef.z,0,-ef.x,Kp.z,0,-Kp.x,-Qd.y,Qd.x,0,-ef.y,ef.x,0,-Kp.y,Kp.x,0];return!(!CN(t,D0,O0,k0,_M)||(t=[1,0,0,0,1,0,0,0,1],!CN(t,D0,O0,k0,_M)))&&(TM.crossVectors(Qd,ef),t=[TM.x,TM.y,TM.z],CN(t,D0,O0,k0,_M))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Dh).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(Dh).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Lh[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Lh[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Lh[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Lh[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Lh[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Lh[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Lh[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Lh[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Lh)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Lh=[new O,new O,new O,new O,new O,new O,new O,new O],Dh=new O,L0=new Ot,D0=new O,O0=new O,k0=new O,Qd=new O,ef=new O,Kp=new O,Xx=new O,_M=new O,TM=new O,Jp=new O;function CN(e,t,n,i,r){for(let a=0,s=e.length-3;a<=s;a+=3){Jp.fromArray(e,a);let s=r.x*Math.abs(Jp.x)+r.y*Math.abs(Jp.y)+r.z*Math.abs(Jp.z),o=t.dot(Jp),l=n.dot(Jp),h=i.dot(Jp);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>s)return!1}return!0}var Trt=new Ot,Yx=new O,PN=new O,vr=class{constructor(e=new O,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;void 0!==t?n.copy(t):Trt.setFromPoints(e).getCenter(n);let i=0;for(let r=0,a=e.length;rthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Yx.subVectors(e,this.center);let t=Yx.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(Yx,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(PN.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Yx.copy(e.center).add(PN)),this.expandByPoint(Yx.copy(e.center).sub(PN))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}},Oh=new O,IN=new O,wM=new O,tf=new O,LN=new O,SM=new O,DN=new O,ho=class{constructor(e=new O,t=new O(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Oh)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Oh.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Oh.copy(this.origin).addScaledVector(this.direction,t),Oh.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){IN.copy(e).add(t).multiplyScalar(.5),wM.copy(t).sub(e).normalize(),tf.copy(this.origin).sub(IN);let r,a,s,o,l=.5*e.distanceTo(t),h=-this.direction.dot(wM),c=tf.dot(this.direction),u=-tf.dot(wM),d=tf.lengthSq(),p=Math.abs(1-h*h);if(p>0)if(r=h*u-c,a=h*c-u,o=l*p,r>=0)if(a>=-o)if(a<=o){let e=1/p;r*=e,a*=e,s=r*(r+h*a+2*c)+a*(h*r+a+2*u)+d}else a=l,r=Math.max(0,-(h*a+c)),s=-r*r+a*(a+2*u)+d;else a=-l,r=Math.max(0,-(h*a+c)),s=-r*r+a*(a+2*u)+d;else a<=-o?(r=Math.max(0,-(-h*l+c)),a=r>0?-l:Math.min(Math.max(-l,-u),l),s=-r*r+a*(a+2*u)+d):a<=o?(r=0,a=Math.min(Math.max(-l,-u),l),s=a*(a+2*u)+d):(r=Math.max(0,-(h*l+c)),a=r>0?l:Math.min(Math.max(-l,-u),l),s=-r*r+a*(a+2*u)+d);else a=h>0?-l:l,r=Math.max(0,-(h*a+c)),s=-r*r+a*(a+2*u)+d;return n&&n.copy(this.origin).addScaledVector(this.direction,r),i&&i.copy(IN).addScaledVector(wM,a),s}intersectSphere(e,t){Oh.subVectors(e.center,this.origin);let n=Oh.dot(this.direction),i=Oh.dot(Oh)-n*n,r=e.radius*e.radius;if(i>r)return null;let a=Math.sqrt(r-i),s=n-a,o=n+a;return o<0?null:s<0?this.at(o,t):this.at(s,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,a,s,o,l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,u=this.origin;return l>=0?(n=(e.min.x-u.x)*l,i=(e.max.x-u.x)*l):(n=(e.max.x-u.x)*l,i=(e.min.x-u.x)*l),h>=0?(r=(e.min.y-u.y)*h,a=(e.max.y-u.y)*h):(r=(e.max.y-u.y)*h,a=(e.min.y-u.y)*h),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a=0?(s=(e.min.z-u.z)*c,o=(e.max.z-u.z)*c):(s=(e.max.z-u.z)*c,o=(e.min.z-u.z)*c),n>o||s>i)||((s>n||n!=n)&&(n=s),(o=0?n:i,t)}intersectsBox(e){return null!==this.intersectBox(e,Oh)}intersectTriangle(e,t,n,i,r){LN.subVectors(t,e),SM.subVectors(n,e),DN.crossVectors(LN,SM);let a,s=this.direction.dot(DN);if(s>0){if(i)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}tf.subVectors(this.origin,e);let o=a*this.direction.dot(SM.crossVectors(tf,SM));if(o<0)return null;let l=a*this.direction.dot(LN.cross(tf));if(l<0||o+l>s)return null;let h=-a*tf.dot(DN);return h<0?null:this.at(h/s,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}},et=class{constructor(e,t,n,i,r,a,s,o,l,h,c,u,d,p,f,m){et.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l,h,c,u,d,p,f,m)}set(e,t,n,i,r,a,s,o,l,h,c,u,d,p,f,m){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=s,g[13]=o,g[2]=l,g[6]=h,g[10]=c,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new et).fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,i=1/F0.setFromMatrixColumn(e,0).length(),r=1/F0.setFromMatrixColumn(e,1).length(),a=1/F0.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),s=Math.sin(n),o=Math.cos(i),l=Math.sin(i),h=Math.cos(r),c=Math.sin(r);if("XYZ"===e.order){let e=a*h,n=a*c,i=s*h,r=s*c;t[0]=o*h,t[4]=-o*c,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-s*o,t[2]=r-e*l,t[6]=i+n*l,t[10]=a*o}else if("YXZ"===e.order){let e=o*h,n=o*c,i=l*h,r=l*c;t[0]=e+r*s,t[4]=i*s-n,t[8]=a*l,t[1]=a*c,t[5]=a*h,t[9]=-s,t[2]=n*s-i,t[6]=r+e*s,t[10]=a*o}else if("ZXY"===e.order){let e=o*h,n=o*c,i=l*h,r=l*c;t[0]=e-r*s,t[4]=-a*c,t[8]=i+n*s,t[1]=n+i*s,t[5]=a*h,t[9]=r-e*s,t[2]=-a*l,t[6]=s,t[10]=a*o}else if("ZYX"===e.order){let e=a*h,n=a*c,i=s*h,r=s*c;t[0]=o*h,t[4]=i*l-n,t[8]=e*l+r,t[1]=o*c,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=s*o,t[10]=a*o}else if("YZX"===e.order){let e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*h,t[4]=r-e*c,t[8]=i*c+n,t[1]=c,t[5]=a*h,t[9]=-s*h,t[2]=-l*h,t[6]=n*c+i,t[10]=e-r*c}else if("XZY"===e.order){let e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*h,t[4]=-c,t[8]=l*h,t[1]=e*c+r,t[5]=a*h,t[9]=n*c-i,t[2]=i*c-n,t[6]=s*h,t[10]=r*c+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(wrt,e,Srt)}lookAt(e,t,n){let i=this.elements;return zo.subVectors(e,t),0===zo.lengthSq()&&(zo.z=1),zo.normalize(),nf.crossVectors(n,zo),0===nf.lengthSq()&&(1===Math.abs(n.z)?zo.x+=1e-4:zo.z+=1e-4,zo.normalize(),nf.crossVectors(n,zo)),nf.normalize(),MM.crossVectors(zo,nf),i[0]=nf.x,i[4]=MM.x,i[8]=zo.x,i[1]=nf.y,i[5]=MM.y,i[9]=zo.y,i[2]=nf.z,i[6]=MM.z,i[10]=zo.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[4],o=n[8],l=n[12],h=n[1],c=n[5],u=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],y=n[7],x=n[11],b=n[15],_=i[0],w=i[4],S=i[8],M=i[12],T=i[1],E=i[5],A=i[9],C=i[13],P=i[2],R=i[6],O=i[10],L=i[14],I=i[3],D=i[7],k=i[11],N=i[15];return r[0]=a*_+s*T+o*P+l*I,r[4]=a*w+s*E+o*R+l*D,r[8]=a*S+s*A+o*O+l*k,r[12]=a*M+s*C+o*L+l*N,r[1]=h*_+c*T+u*P+d*I,r[5]=h*w+c*E+u*R+d*D,r[9]=h*S+c*A+u*O+d*k,r[13]=h*M+c*C+u*L+d*N,r[2]=p*_+f*T+m*P+g*I,r[6]=p*w+f*E+m*R+g*D,r[10]=p*S+f*A+m*O+g*k,r[14]=p*M+f*C+m*L+g*N,r[3]=v*_+y*T+x*P+b*I,r[7]=v*w+y*E+x*R+b*D,r[11]=v*S+y*A+x*O+b*k,r[15]=v*M+y*C+x*L+b*N,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],s=e[5],o=e[9],l=e[13],h=e[2],c=e[6],u=e[10],d=e[14];return e[3]*(+r*o*c-i*l*c-r*s*u+n*l*u+i*s*d-n*o*d)+e[7]*(+t*o*d-t*l*u+r*a*u-i*a*d+i*l*h-r*o*h)+e[11]*(+t*l*c-t*s*d-r*a*c+n*a*d+r*s*h-n*l*h)+e[15]*(-i*s*h-t*o*c+t*s*u+i*a*c-n*a*u+n*o*h)}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(e,t,n){let i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],h=e[8],c=e[9],u=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=c*m*l-f*u*l+f*o*d-s*m*d-c*o*g+s*u*g,y=p*u*l-h*m*l-p*o*d+a*m*d+h*o*g-a*u*g,x=h*f*l-p*c*l+p*s*d-a*f*d-h*s*g+a*c*g,b=p*c*o-h*f*o-p*s*u+a*f*u+h*s*m-a*c*m,_=t*v+n*y+i*x+r*b;if(0===_)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let w=1/_;return e[0]=v*w,e[1]=(f*u*r-c*m*r-f*i*d+n*m*d+c*i*g-n*u*g)*w,e[2]=(s*m*r-f*o*r+f*i*l-n*m*l-s*i*g+n*o*g)*w,e[3]=(c*o*r-s*u*r-c*i*l+n*u*l+s*i*d-n*o*d)*w,e[4]=y*w,e[5]=(h*m*r-p*u*r+p*i*d-t*m*d-h*i*g+t*u*g)*w,e[6]=(p*o*r-a*m*r-p*i*l+t*m*l+a*i*g-t*o*g)*w,e[7]=(a*u*r-h*o*r+h*i*l-t*u*l-a*i*d+t*o*d)*w,e[8]=x*w,e[9]=(p*c*r-h*f*r-p*n*d+t*f*d+h*n*g-t*c*g)*w,e[10]=(a*f*r-p*s*r+p*n*l-t*f*l-a*n*g+t*s*g)*w,e[11]=(h*s*r-a*c*r-h*n*l+t*c*l+a*n*d-t*s*d)*w,e[12]=b*w,e[13]=(h*f*i-p*c*i+p*n*u-t*f*u-h*n*m+t*c*m)*w,e[14]=(p*s*i-a*f*i-p*n*o+t*f*o+a*n*m-t*s*m)*w,e[15]=(a*c*i-h*s*i+h*n*o-t*c*o-a*n*u+t*s*u)*w,this}scale(e){let t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,s=e.y,o=e.z,l=r*a,h=r*s;return this.set(l*a+n,l*s-i*o,l*o+i*s,0,l*s+i*o,h*s+n,h*o-i*a,0,l*o-i*s,h*o+i*a,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,r=t._x,a=t._y,s=t._z,o=t._w,l=r+r,h=a+a,c=s+s,u=r*l,d=r*h,p=r*c,f=a*h,m=a*c,g=s*c,v=o*l,y=o*h,x=o*c,b=n.x,_=n.y,w=n.z;return i[0]=(1-(f+g))*b,i[1]=(d+x)*b,i[2]=(p-y)*b,i[3]=0,i[4]=(d-x)*_,i[5]=(1-(u+g))*_,i[6]=(m+v)*_,i[7]=0,i[8]=(p+y)*w,i[9]=(m-v)*w,i[10]=(1-(u+f))*w,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements,r=F0.set(i[0],i[1],i[2]).length(),a=F0.set(i[4],i[5],i[6]).length(),s=F0.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],gc.copy(this);let o=1/r,l=1/a,h=1/s;return gc.elements[0]*=o,gc.elements[1]*=o,gc.elements[2]*=o,gc.elements[4]*=l,gc.elements[5]*=l,gc.elements[6]*=l,gc.elements[8]*=h,gc.elements[9]*=h,gc.elements[10]*=h,t.setFromRotationMatrix(gc),n.x=r,n.y=a,n.z=s,this}makePerspective(e,t,n,i,r,a,s=xu){let o,l,h=this.elements,c=2*r/(t-e),u=2*r/(n-i),d=(t+e)/(t-e),p=(n+i)/(n-i);if(s===xu)o=-(a+r)/(a-r),l=-2*a*r/(a-r);else{if(s!==fb)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);o=-a/(a-r),l=-a*r/(a-r)}return h[0]=c,h[4]=0,h[8]=d,h[12]=0,h[1]=0,h[5]=u,h[9]=p,h[13]=0,h[2]=0,h[6]=0,h[10]=o,h[14]=l,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,t,n,i,r,a,s=xu){let o,l,h=this.elements,c=1/(t-e),u=1/(n-i),d=1/(a-r),p=(t+e)*c,f=(n+i)*u;if(s===xu)o=(a+r)*d,l=-2*d;else{if(s!==fb)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);o=r*d,l=-1*d}return h[0]=2*c,h[4]=0,h[8]=0,h[12]=-p,h[1]=0,h[5]=2*u,h[9]=0,h[13]=-f,h[2]=0,h[6]=0,h[10]=l,h[14]=-o,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let i=0;i<16;i++)if(t[i]!==n[i])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},F0=new O,gc=new et,wrt=new O(0,0,0),Srt=new O(1,1,1),nf=new O,MM=new O,zo=new O,oce=new et,lce=new dr,Xn=class{constructor(e=0,t=0,n=0,i=Xn.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],a=i[4],s=i[8],o=i[1],l=i[5],h=i[9],c=i[2],u=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(cs(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-cs(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(s,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(cs(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-cs(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(cs(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(s,d));break;case"XZY":this._z=Math.asin(-cs(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-h,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return oce.makeRotationFromQuaternion(e),this.setFromRotationMatrix(oce,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return lce.setFromEuler(this),this.setFromQuaternion(lce,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Xn.DEFAULT_ORDER="XYZ";var lf=class{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(n=n.concat(r))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose($x,e,Rrt),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose($x,Art,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let n=0,i=t.length;n0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){let n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),s.length>0&&(n.images=s),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),h.length>0&&(n.animations=h),c.length>0&&(n.nodes=c)}return n.object=i,n;function a(e){let t=[];for(let n in e){let i=e[n];delete i.metadata,t.push(i)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let n=0;n0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){vc.subVectors(i,t),Fh.subVectors(n,t),ON.subVectors(e,t);let a=vc.dot(vc),s=vc.dot(Fh),o=vc.dot(ON),l=Fh.dot(Fh),h=Fh.dot(ON),c=a*l-s*s;if(0===c)return r.set(-2,-1,-1);let u=1/c,d=(l*o-s*h)*u,p=(a*h-s*o)*u;return r.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Nh),Nh.x>=0&&Nh.y>=0&&Nh.x+Nh.y<=1}static getUV(e,t,n,i,r,a,s,o){return!1===AM&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),AM=!0),this.getInterpolation(e,t,n,i,r,a,s,o)}static getInterpolation(e,t,n,i,r,a,s,o){return this.getBarycoord(e,t,n,i,Nh),o.setScalar(0),o.addScaledVector(r,Nh.x),o.addScaledVector(a,Nh.y),o.addScaledVector(s,Nh.z),o}static isFrontFacing(e,t,n,i){return vc.subVectors(n,t),Fh.subVectors(e,t),vc.cross(Fh).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return vc.subVectors(this.c,this.b),Fh.subVectors(this.a,this.b),.5*vc.cross(Fh).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Zr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Zr.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return!1===AM&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),AM=!0),Zr.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}getInterpolation(e,t,n,i,r){return Zr.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return Zr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Zr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n,i,r=this.a,a=this.b,s=this.c;B0.subVectors(a,r),U0.subVectors(s,r),kN.subVectors(e,r);let o=B0.dot(kN),l=U0.dot(kN);if(o<=0&&l<=0)return t.copy(r);FN.subVectors(e,a);let h=B0.dot(FN),c=U0.dot(FN);if(h>=0&&c<=h)return t.copy(a);let u=o*c-h*l;if(u<=0&&o>=0&&h<=0)return n=o/(o-h),t.copy(r).addScaledVector(B0,n);NN.subVectors(e,s);let d=B0.dot(NN),p=U0.dot(NN);if(p>=0&&d<=p)return t.copy(s);let f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return i=l/(l-p),t.copy(r).addScaledVector(U0,i);let m=h*p-d*c;if(m<=0&&c-h>=0&&d-p>=0)return pce.subVectors(s,a),i=(c-h)/(c-h+(d-p)),t.copy(a).addScaledVector(pce,i);let g=1/(m+f+u);return n=f*g,i=u*g,t.copy(r).addScaledVector(B0,n).addScaledVector(U0,i)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Prt=0,yr=class extends jo{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Prt++}),this.uuid=Wo(),this.name="",this.type="Material",this.blending=hm,this.side=pi,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=kU,this.blendDst=FU,this.blendEquation=qo,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=gR,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=dhe,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=mR,this.stencilZFail=mR,this.stencilZPass=mR,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(let t in e){let n=e[t];if(void 0===n){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){let t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});let n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(e){let t=[];for(let n in e){let i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==hm&&(n.blending=this.blending),this.side!==pi&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=this.alphaHash),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.forceSinglePass&&(n.forceSinglePass=this.forceSinglePass),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){let t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(null!==t){let e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}},The={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},yc={h:0,s:0,l:0},CM={h:0,s:0,l:0};function BN(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}var ct=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(void 0===t&&void 0===n){let t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=tn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Tl.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=Tl.workingColorSpace){return this.r=e,this.g=t,this.b=n,Tl.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=Tl.workingColorSpace){if(e=XU(e,1),t=cs(t,0,1),n=cs(n,0,1),0===t)this.r=this.g=this.b=n;else{let i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=BN(r,i,e+1/3),this.g=BN(r,i,e),this.b=BN(r,i,e-1/3)}return Tl.toWorkingColorSpace(this,i),this}setStyle(e,t=tn){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,a=i[1],s=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(n,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=tn){let n=The[e.toLowerCase()];return void 0!==n?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=nv(e.r),this.g=nv(e.g),this.b=nv(e.b),this}copyLinearToSRGB(e){return this.r=MN(e.r),this.g=MN(e.g),this.b=MN(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=tn){return Tl.fromWorkingColorSpace(ma.copy(this),e),65536*Math.round(cs(255*ma.r,0,255))+256*Math.round(cs(255*ma.g,0,255))+Math.round(cs(255*ma.b,0,255))}getHexString(e=tn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Tl.workingColorSpace){Tl.fromWorkingColorSpace(ma.copy(this),t);let n,i,r=ma.r,a=ma.g,s=ma.b,o=Math.max(r,a,s),l=Math.min(r,a,s),h=(l+o)/2;if(l===o)n=0,i=0;else{let e=o-l;switch(i=h<=.5?e/(o+l):e/(2-o-l),o){case r:n=(a-s)/e+(a>-e-14,i[256|l]=1024>>-e-14|32768,r[l]=-e-1,r[256|l]=-e-1):e<=15?(i[l]=e+15<<10,i[256|l]=e+15<<10|32768,r[l]=13,r[256|l]=13):e<128?(i[l]=31744,i[256|l]=64512,r[l]=24,r[256|l]=24):(i[l]=31744,i[256|l]=64512,r[l]=13,r[256|l]=13)}let a=new Uint32Array(2048),s=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let e=l<<13,t=0;for(;!(8388608&e);)e<<=1,t-=8388608;e&=-8388609,t+=947912704,a[l]=e|t}for(let l=1024;l<2048;++l)a[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)s[l]=l<<23;s[31]=1199570944,s[32]=2147483648;for(let l=33;l<63;++l)s[l]=2147483648+(l-32<<23);s[63]=3347054592;for(let l=1;l<64;++l)32!==l&&(o[l]=1024);return{floatView:t,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:a,exponentTable:s,offsetTable:o}}function co(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=cs(e,-65504,65504),Uh.floatView[0]=e;let t=Uh.uint32View[0],n=t>>23&511;return Uh.baseTable[n]+((8388607&t)>>Uh.shiftTable[n])}function rb(e){let t=e>>10;return Uh.uint32View[0]=Uh.mantissaTable[Uh.offsetTable[t]+(1023&e)]+Uh.exponentTable[t],Uh.floatView[0]}var Av={toHalfFloat:co,fromHalfFloat:rb},ws=new O,PM=new be,mn=class{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=db,this.updateRange={offset:0,count:-1},this.gpuType=ga,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i0&&(e.userData=this.userData),void 0!==this.parameters){let t=this.parameters;for(let n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let o in n){let t=n[o];e.data.attributes[o]=t.toJSON(e.data)}let i={},r=!1;for(let o in this.morphAttributes){let t=this.morphAttributes[o],n=[];for(let i=0,r=t.length;i0&&(i[o]=n,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let s=this.boundingSphere;return null!==s&&(e.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;null!==n&&this.setIndex(n.clone(t));let i=e.attributes;for(let l in i){let e=i[l];this.setAttribute(l,e.clone(t))}let r=e.morphAttributes;for(let l in r){let e=[],n=r[l];for(let i=0,r=n.length;i0){let n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;eOo(e.far-e.near,2)))&&(mce.copy(r).invert(),Qp.copy(e.ray).applyMatrix4(mce),(null===n.boundingBox||!1!==Qp.intersectsBox(n.boundingBox))&&this._computeIntersections(e,t,Qp)))}_computeIntersections(e,t,n){let i,r=this.geometry,a=this.material,s=r.index,o=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,c=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==s)if(Array.isArray(a))for(let p=0,f=u.length;pn.far?null:{distance:h,point:NM.clone(),object:e}}function BM(e,t,n,i,r,a,s,o,l,h){e.getVertexPosition(o,V0),e.getVertexPosition(l,z0),e.getVertexPosition(h,G0);let c=Drt(e,t,n,i,V0,z0,G0,FM);if(c){r&&(DM.fromBufferAttribute(r,o),OM.fromBufferAttribute(r,l),kM.fromBufferAttribute(r,h),c.uv=Zr.getInterpolation(FM,V0,z0,G0,DM,OM,kM,new be)),a&&(DM.fromBufferAttribute(a,o),OM.fromBufferAttribute(a,l),kM.fromBufferAttribute(a,h),c.uv1=Zr.getInterpolation(FM,V0,z0,G0,DM,OM,kM,new be),c.uv2=c.uv1),s&&(vce.fromBufferAttribute(s,o),yce.fromBufferAttribute(s,l),xce.fromBufferAttribute(s,h),c.normal=Zr.getInterpolation(FM,V0,z0,G0,vce,yce,xce,new O),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));let e={a:o,b:l,c:h,normal:new O,materialIndex:0};Zr.getNormal(V0,z0,G0,e.normal),c.face=e}return c}var va=class extends Dt{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};let s=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);let o=[],l=[],h=[],c=[],u=0,d=0;function p(e,t,n,i,r,a,p,f,m,g,v){let y=a/m,x=p/g,b=a/2,_=p/2,w=f/2,S=m+1,M=g+1,T=0,E=0,A=new O;for(let s=0;s0?1:-1,h.push(A.x,A.y,A.z),c.push(o/m),c.push(1-s/g),T+=1}}for(let s=0;s0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let i in this.extensions)!0===this.extensions[i]&&(n[i]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},Xh=class extends an{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new et,this.projectionMatrix=new et,this.projectionMatrixInverse=new et,this.coordinateSystem=xu}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}},ur=class extends Xh{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=2*iv*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(.5*dm*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*iv*Math.atan(Math.tan(.5*dm*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,r,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(.5*dm*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i,a=this.view;if(null!==this.view&&this.view.enabled){let e=a.fullWidth,s=a.fullHeight;r+=a.offsetX*i/e,t-=a.offsetY*n/s,i*=a.width/e,n*=a.height/s}let s=this.filmOffset;0!==s&&(r+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},q0=-90,W0=1,bR=class extends an{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null;let i=new ur(q0,W0,e,t);i.layers=this.layers,this.add(i);let r=new ur(q0,W0,e,t);r.layers=this.layers,this.add(r);let a=new ur(q0,W0,e,t);a.layers=this.layers,this.add(a);let s=new ur(q0,W0,e,t);s.layers=this.layers,this.add(s);let o=new ur(q0,W0,e,t);o.layers=this.layers,this.add(o);let l=new ur(q0,W0,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,s,o]=t;for(let l of t)this.remove(l);if(e===xu)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),s.up.set(0,1,0),s.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(e!==fb)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),s.up.set(0,-1,0),s.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();let n=this.renderTarget;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[i,r,a,s,o,l]=this.children,h=e.getRenderTarget(),c=e.xr.enabled;e.xr.enabled=!1;let u=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,r),e.setRenderTarget(n,2),e.render(t,a),e.setRenderTarget(n,3),e.render(t,s),e.setRenderTarget(n,4),e.render(t,o),n.texture.generateMipmaps=u,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(h),e.xr.enabled=c,n.texture.needsPMREMUpdate=!0}},mm=class extends qr{constructor(e,t,n,i,r,a,s,o,l,h){super(e=void 0!==e?e:[],t=void 0!==t?t:Gh,n,i,r,a,s,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},ER=class extends sr{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];void 0!==t.encoding&&(ab("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===Eu?tn:_u),this.texture=new mm(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:Ir}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={tEquirect:{value:null}},i="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",r="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",a=new va(5,5,5),s=new ln({name:"CubemapFromEquirect",uniforms:av(n),vertexShader:i,fragmentShader:r,side:Ki,blending:Qr});s.uniforms.tEquirect.value=t;let o=new xt(a,s),l=t.minFilter;return t.minFilter===Ua&&(t.minFilter=Ir),new bR(1,10,this).update(e,o),t.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,i){let r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,i);e.setRenderTarget(r)}},VN=new O,Nrt=new O,Brt=new Ln,Gr=class{constructor(e=new O(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let i=VN.subVectors(n,t).cross(Nrt.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(VN),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;let r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||Brt.getNormalMatrix(e),i=this.coplanarPoint(VN).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}},em=new vr,UM=new O,ya=class{constructor(e=new Gr,t=new Gr,n=new Gr,i=new Gr,r=new Gr,a=new Gr){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){let s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(n),s[3].copy(i),s[4].copy(r),s[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=xu){let n=this.planes,i=e.elements,r=i[0],a=i[1],s=i[2],o=i[3],l=i[4],h=i[5],c=i[6],u=i[7],d=i[8],p=i[9],f=i[10],m=i[11],g=i[12],v=i[13],y=i[14],x=i[15];if(n[0].setComponents(o-r,u-l,m-d,x-g).normalize(),n[1].setComponents(o+r,u+l,m+d,x+g).normalize(),n[2].setComponents(o+a,u+h,m+p,x+v).normalize(),n[3].setComponents(o-a,u-h,m-p,x-v).normalize(),n[4].setComponents(o-s,u-c,m-f,x-y).normalize(),t===xu)n[5].setComponents(o+s,u+c,m+f,x+y).normalize();else{if(t!==fb)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(s,c,f,y).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),em.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),em.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(em)}intersectsSprite(e){return em.center.set(0,0,0),em.radius=.7071067811865476,em.applyMatrix4(e.matrixWorld),this.intersectsSphere(em)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)0?e.max.x:e.min.x,UM.y=i.normal.y>0?e.max.y:e.min.y,UM.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(UM)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}};function She(){let e=null,t=!1,n=null,i=null;function r(t,a){n(t,a),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Urt(e,t){let n=t.isWebGL2,i=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);let n=i.get(t);n&&(e.deleteBuffer(n.buffer),i.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){let e=i.get(t);return void((!e||e.version0?n:t).get(v)),null===v?f(h,c):v&&v.isColor&&(f(v,1),g=!0),e.xr.getEnvironmentBlendMode()){case"opaque":g=!0;break;case"additive":i.buffers.color.setClear(0,0,0,1,s),g=!0;break;case"alpha-blend":i.buffers.color.setClear(0,0,0,0,s),g=!0}(e.autoClear||g)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),v&&(v.isCubeTexture||v.mapping===wv)?(void 0===l&&(l=new xt(new va(1,1,1),new ln({name:"BackgroundCubeMaterial",uniforms:av(xc.backgroundCube.uniforms),vertexShader:xc.backgroundCube.vertexShader,fragmentShader:xc.backgroundCube.fragmentShader,side:Ki,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),l.material.uniforms.envMap.value=v,l.material.uniforms.flipEnvMap.value=v.isCubeTexture&&!1===v.isRenderTargetTexture?-1:1,l.material.uniforms.backgroundBlurriness.value=m.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,l.material.toneMapped=v.colorSpace!==tn,(u!==v||d!==v.version||p!==e.toneMapping)&&(l.material.needsUpdate=!0,u=v,d=v.version,p=e.toneMapping),l.layers.enableAll(),a.unshift(l,l.geometry,l.material,0,0,null)):v&&v.isTexture&&(void 0===o&&(o=new xt(new ui(2,2),new ln({name:"BackgroundMaterial",uniforms:av(xc.background.uniforms),vertexShader:xc.background.vertexShader,fragmentShader:xc.background.fragmentShader,side:pi,depthTest:!1,depthWrite:!1,fog:!1})),o.geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(o)),o.material.uniforms.t2D.value=v,o.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,o.material.toneMapped=v.colorSpace!==tn,!0===v.matrixAutoUpdate&&v.updateMatrix(),o.material.uniforms.uvTransform.value.copy(v.matrix),(u!==v||d!==v.version||p!==e.toneMapping)&&(o.material.needsUpdate=!0,u=v,d=v.version,p=e.toneMapping),o.layers.enableAll(),a.unshift(o,o.geometry,o.material,0,0,null))}}}function yat(e,t,n,i){let r=e.getParameter(e.MAX_VERTEX_ATTRIBS),a=i.isWebGL2?null:t.get("OES_vertex_array_object"),s=i.isWebGL2||null!==a,o={},l=p(null),h=l,c=!1;function u(t){return i.isWebGL2?e.bindVertexArray(t):a.bindVertexArrayOES(t)}function d(t){return i.isWebGL2?e.deleteVertexArray(t):a.deleteVertexArrayOES(t)}function p(e){let t=[],n=[],i=[];for(let a=0;a=0){let t=r[l],n=a[l];if(void 0===n&&("instanceMatrix"===l&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===l&&e.instanceColor&&(n=e.instanceColor)),void 0===t||t.attribute!==n||n&&t.data!==n.data)return!0;s++}return h.attributesNum!==s||h.index!==i}(r,x,d,b),_&&function(e,t,n,i){let r={},a=t.attributes,s=0,o=n.getAttributes();for(let l in o)if(o[l].location>=0){let t=a[l];void 0===t&&("instanceMatrix"===l&&e.instanceMatrix&&(t=e.instanceMatrix),"instanceColor"===l&&e.instanceColor&&(t=e.instanceColor));let n={};n.attribute=t,t&&t.data&&(n.data=t.data),r[l]=n,s++}h.attributes=r,h.attributesNum=s,h.index=i}(r,x,d,b)}else{let e=!0===l.wireframe;(h.geometry!==x.id||h.program!==d.id||h.wireframe!==e)&&(h.geometry=x.id,h.program=d.id,h.wireframe=e,_=!0)}null!==b&&n.update(b,e.ELEMENT_ARRAY_BUFFER),(_||c)&&(c=!1,function(r,a,s,o){if(!1===i.isWebGL2&&(r.isInstancedMesh||o.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;f();let l=o.attributes,h=s.getAttributes(),c=a.defaultAttributeValues;for(let t in h){let a=h[t];if(a.location>=0){let s=l[t];if(void 0===s&&("instanceMatrix"===t&&r.instanceMatrix&&(s=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(s=r.instanceColor)),void 0!==s){let t=s.normalized,l=s.itemSize,h=n.get(s);if(void 0===h)continue;let c=h.buffer,u=h.type,d=h.bytesPerElement,p=!0===i.isWebGL2&&(u===e.INT||u===e.UNSIGNED_INT||s.gpuType===NU);if(s.isInterleavedBufferAttribute){let n=s.data,i=n.stride,h=s.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name,s=void 0!==n.precision?n.precision:"highp",o=r(s);o!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",o,"instead."),s=o);let l=a||t.has("WEBGL_draw_buffers"),h=!0===n.logarithmicDepthBuffer,c=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),u=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),f=e.getParameter(e.MAX_VERTEX_ATTRIBS),m=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),g=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),y=u>0,x=a||t.has("OES_texture_float");return{isWebGL2:a,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){let n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,precision:s,logarithmicDepthBuffer:h,maxTextures:c,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:p,maxAttributes:f,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:y,floatFragmentTextures:x,floatVertexTextures:y&&x,maxSamples:a?e.getParameter(e.MAX_SAMPLES):0}}function Eat(e){let t=this,n=null,i=0,r=!1,a=!1,s=new Gr,o=new Ln,l={value:null,needsUpdate:!1};function h(e,n,i,r){let a=null!==e?e.length:0,h=null;if(0!==a){if(h=l.value,!0!==r||null===h){let t=i+4*a,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===h||h.length0),t.numPlanes=i,t.numIntersection=0);else{let e=a?0:i,t=4*e,r=f.clippingState||null;l.value=r,r=h(u,o,t,c);for(let i=0;i!==t;++i)r[i]=n[i];f.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}}}function _at(e){let t=new WeakMap;function n(e,t){return t===fm?e.mapping=Gh:t===ub&&(e.mapping=af),e}function i(e){let n=e.target;n.removeEventListener("dispose",i);let r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture&&!1===r.isRenderTargetTexture){let a=r.mapping;if(a===fm||a===ub){if(t.has(r))return n(t.get(r).texture,r.mapping);{let a=r.image;if(a&&a.height>0){let s=new ER(a.height/2);return s.fromEquirectangularTexture(e,r),t.set(r,s),r.addEventListener("dispose",i),n(s.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}var Ur=class extends Xh{constructor(e=-1,t=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=n-e,a=n+e,s=i+t,o=i-t;if(null!==this.view&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,a=r+e*this.view.width,s-=t*this.view.offsetY,o=s-t*this.view.height}this.projectionMatrix.makeOrthographic(r,a,s,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}},ev=4,bce=[.125,.215,.35,.446,.526,.582],om=20,zN=new Ur,Ece=new ct,GN=null,am=(1+Math.sqrt(5))/2,j0=1/am,_ce=[new O(1,1,1),new O(-1,1,1),new O(1,1,-1),new O(-1,1,-1),new O(0,am,j0),new O(0,am,-j0),new O(j0,0,am),new O(-j0,0,am),new O(am,j0,0),new O(-am,j0,0)],Yh=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){GN=this._renderer.getRenderTarget(),this._setSize(256);let r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Sce(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=wce(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e2?n:0,n,n),o.setRenderTarget(i),d&&o.render(u,r),o.render(e,r)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=h,o.autoClear=l,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,i=e.mapping===Gh||e.mapping===af;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Sce()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=wce());let r=i?this._cubemapMaterial:this._equirectMaterial,a=new xt(this._lodPlanes[0],r);r.uniforms.envMap.value=e;let s=this._cubeSize;VM(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,zN)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let i=1;iom&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${om}`);let m=[],g=0;for(let x=0;xv-ev?i-v+ev:0),4*(this._cubeSize-y),3*y,2*y),o.setRenderTarget(t),o.render(h,zN)}};function Tat(e){let t=[],n=[],i=[],r=e,a=e-ev+1+bce.length;for(let s=0;se-ev?o=bce[s-e+ev-1]:0===s&&(o=0),i.push(o);let l=1/(a-2),h=-l,c=1+l,u=[h,h,c,h,c,c,h,h,c,c,h,c],d=6,p=6,f=3,m=2,g=1,v=new Float32Array(f*p*d),y=new Float32Array(m*p*d),x=new Float32Array(g*p*d);for(let e=0;e2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];v.set(i,f*p*e),y.set(u,m*p*e);let r=[e,e,e,e,e,e];x.set(r,g*p*e)}let b=new Dt;b.setAttribute("position",new mn(v,f)),b.setAttribute("uv",new mn(y,m)),b.setAttribute("faceIndex",new mn(x,g)),t.push(b),r>ev&&r--}return{lodPlanes:t,sizeLods:n,sigmas:i}}function Tce(e,t,n){let i=new sr(e,t,n);return i.texture.mapping=wv,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function VM(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function wat(e,t,n){let i=new Float32Array(om),r=new O(0,1,0);return new ln({name:"SphericalGaussianBlur",defines:{n:om,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:YU(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:Qr,depthTest:!1,depthWrite:!1})}function wce(){return new ln({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:YU(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:Qr,depthTest:!1,depthWrite:!1})}function Sce(){return new ln({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:YU(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:Qr,depthTest:!1,depthWrite:!1})}function YU(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function Sat(e){let t=new WeakMap,n=null;function i(e){let n=e.target;n.removeEventListener("dispose",i);let r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){let a=r.mapping,s=a===fm||a===ub,o=a===Gh||a===af;if(s||o){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let i=t.get(r);return null===n&&(n=new Yh(e)),i=s?n.fromEquirectangular(r,i):n.fromCubemap(r,i),t.set(r,i),i.texture}if(t.has(r))return t.get(r).texture;{let a=r.image;if(s&&a&&a.height>0||o&&a&&function(e){let t=0;for(let n=0;n<6;n++)void 0!==e[n]&&t++;return 6===t}(a)){null===n&&(n=new Yh(e));let a=s?n.fromEquirectangular(r):n.fromCubemap(r);return t.set(r,a),r.addEventListener("dispose",i),a.texture}return null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Mat(e){let t={};function n(n){if(void 0!==t[n])return t[n];let i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(e){let t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function Rat(e,t,n,i){let r={},a=new WeakMap;function s(e){let o=e.target;null!==o.index&&t.remove(o.index);for(let n in o.attributes)t.remove(o.attributes[n]);for(let n in o.morphAttributes){let e=o.morphAttributes[n];for(let n=0,i=e.length;nt.maxTextureSize&&(m=Math.ceil(f/t.maxTextureSize),f=t.maxTextureSize);let g=new Float32Array(f*m*4*r),v=new sv(g,f,m,r);v.type=ga,v.needsUpdate=!0;let y=4*p;for(let t=0;t0)return e;let r=t*n,a=Mce[r];if(void 0===a&&(a=new Float32Array(r),Mce[r]=a),0!==t){i.toArray(a,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(a,r)}return a}function Ds(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n":" "} ${e}: ${n[s]}`)}return i.join("\n")}function Tot(e){switch(e){case Ha:return["Linear","( value )"];case tn:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),["Linear","( value )"]}}function Dce(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),r=e.getShaderInfoLog(t).trim();if(i&&""===r)return"";let a=/ERROR: 0:(\d+)/.exec(r);if(a){let i=parseInt(a[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+_ot(e.getShaderSource(t),i)}return r}function wot(e,t){let n=Tot(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function Sot(e,t){let n;switch(t){case $ue:n="Linear";break;case Zue:n="Reinhard";break;case Kue:n="OptimizedCineon";break;case Jue:n="ACESFilmic";break;case Que:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function Mot(e){return[e.extensionDerivatives||e.envMapCubeUVHeight||e.bumpMap||e.normalMapTangentSpace||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(ib).join("\n")}function Rot(e){let t=[];for(let n in e){let i=e[n];!1!==i&&t.push("#define "+n+" "+i)}return t.join("\n")}function Aot(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function WB(e){return e.replace(Cot,Iot)}var Pot=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function Iot(e,t){let n=$n[t];if(void 0===n){let e=Pot.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");n=$n[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return WB(n)}var Lot=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function Fce(e){return e.replace(Lot,Dot)}function Dot(e,t,n,i){let r="";for(let a=parseInt(t);a0&&(r+="\n"),a=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g].filter(ib).join("\n"),a.length>0&&(a+="\n")):(r=[Nce(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ib).join("\n"),a=[m,Nce(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,g,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+p:"",f?"#define CUBEUV_TEXEL_WIDTH "+f.texelWidth:"",f?"#define CUBEUV_TEXEL_HEIGHT "+f.texelHeight:"",f?"#define CUBEUV_MAX_MIP "+f.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Vh?"#define TONE_MAPPING":"",n.toneMapping!==Vh?$n.tonemapping_pars_fragment:"",n.toneMapping!==Vh?Sot("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",$n.colorspace_pars_fragment,wot("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(ib).join("\n")),l=WB(l),l=Oce(l,n),l=kce(l,n),h=WB(h),h=Oce(h,n),h=kce(h,n),l=Fce(l),h=Fce(h),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",r=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+r,a=["#define varying in",n.glslVersion===IB?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===IB?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+a);let x,b,_=y+r+l,w=y+a+h,S=Lce(s,s.VERTEX_SHADER,_),M=Lce(s,s.FRAGMENT_SHADER,w);if(s.attachShader(v,S),s.attachShader(v,M),void 0!==n.index0AttributeName?s.bindAttribLocation(v,0,n.index0AttributeName):!0===n.morphTargets&&s.bindAttribLocation(v,0,"position"),s.linkProgram(v),e.debug.checkShaderErrors){let t=s.getProgramInfoLog(v).trim(),n=s.getShaderInfoLog(S).trim(),i=s.getShaderInfoLog(M).trim(),o=!0,l=!0;if(!1===s.getProgramParameter(v,s.LINK_STATUS))if(o=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(s,v,S,M);else{let e=Dce(s,S,"vertex"),n=Dce(s,M,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(v,s.VALIDATE_STATUS)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+n)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):(""===n||""===i)&&(l=!1);l&&(this.diagnostics={runnable:o,programLog:t,vertexShader:{log:n,prefix:r},fragmentShader:{log:i,prefix:a}})}return s.deleteShader(S),s.deleteShader(M),this.getUniforms=function(){return void 0===x&&(x=new rv(s,v)),x},this.getAttributes=function(){return void 0===b&&(b=Aot(s,v)),b},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(v),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Eot++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=S,this.fragmentShader=M,this}var Hot=0,jB=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return!1===a.has(i)&&(a.add(i),i.usedTimes++),!1===a.has(r)&&(a.add(r),r.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,0===n.usedTimes&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return void 0===n&&(n=new XB(e),t.set(e,n)),n}},XB=class{constructor(e){this.id=Hot++,this.code=e,this.usedTimes=0}};function Vot(e,t,n,i,r,a,s){let o=new lf,l=new jB,h=[],c=r.isWebGL2,u=r.logarithmicDepthBuffer,d=r.vertexTextures,p=r.precision,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function m(e){return 0===e?"uv":`uv${e}`}return{getParameters:function(a,o,h,g,v){let y=g.fog,x=v.geometry,b=a.isMeshStandardMaterial?g.environment:null,_=(a.isMeshStandardMaterial?n:t).get(a.envMap||b),w=_&&_.mapping===wv?_.image.height:null,S=f[a.type];null!==a.precision&&(p=r.getMaxPrecision(a.precision),p!==a.precision&&console.warn("THREE.WebGLProgram.getParameters:",a.precision,"not supported, using",p,"instead."));let M,T,E,A,C=x.morphAttributes.position||x.morphAttributes.normal||x.morphAttributes.color,P=void 0!==C?C.length:0,R=0;if(void 0!==x.morphAttributes.position&&(R=1),void 0!==x.morphAttributes.normal&&(R=2),void 0!==x.morphAttributes.color&&(R=3),S){let e=xc[S];M=e.vertexShader,T=e.fragmentShader}else M=a.vertexShader,T=a.fragmentShader,l.update(a),E=l.getVertexShaderID(a),A=l.getFragmentShaderID(a);let O=e.getRenderTarget(),L=!0===v.isInstancedMesh,I=!!a.map,D=!!a.matcap,k=!!_,N=!!a.aoMap,F=!!a.lightMap,U=!!a.bumpMap,B=!!a.normalMap,z=!!a.displacementMap,H=!!a.emissiveMap,V=!!a.metalnessMap,j=!!a.roughnessMap,G=a.anisotropy>0,W=a.clearcoat>0,X=a.iridescence>0,Y=a.sheen>0,q=a.transmission>0,J=G&&!!a.anisotropyMap,Z=W&&!!a.clearcoatMap,K=W&&!!a.clearcoatNormalMap,$=W&&!!a.clearcoatRoughnessMap,Q=X&&!!a.iridescenceMap,ee=X&&!!a.iridescenceThicknessMap,te=Y&&!!a.sheenColorMap,ne=Y&&!!a.sheenRoughnessMap,ie=!!a.specularMap,re=!!a.specularColorMap,ae=!!a.specularIntensityMap,se=q&&!!a.transmissionMap,oe=q&&!!a.thicknessMap,le=!!a.gradientMap,he=!!a.alphaMap,ce=a.alphaTest>0,ue=!!a.alphaHash,de=!!a.extensions,pe=!!x.attributes.uv1,fe=!!x.attributes.uv2,me=!!x.attributes.uv3,ge=Vh;return a.toneMapped&&(null===O||!0===O.isXRRenderTarget)&&(ge=e.toneMapping),{isWebGL2:c,shaderID:S,shaderType:a.type,shaderName:a.name,vertexShader:M,fragmentShader:T,defines:a.defines,customVertexShaderID:E,customFragmentShaderID:A,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:p,instancing:L,instancingColor:L&&null!==v.instanceColor,supportsVertexTextures:d,outputColorSpace:null===O?e.outputColorSpace:!0===O.isXRRenderTarget?O.texture.colorSpace:Ha,map:I,matcap:D,envMap:k,envMapMode:k&&_.mapping,envMapCubeUVHeight:w,aoMap:N,lightMap:F,bumpMap:U,normalMap:B,displacementMap:d&&z,emissiveMap:H,normalMapObjectSpace:B&&a.normalMapType===hhe,normalMapTangentSpace:B&&a.normalMapType===mf,metalnessMap:V,roughnessMap:j,anisotropy:G,anisotropyMap:J,clearcoat:W,clearcoatMap:Z,clearcoatNormalMap:K,clearcoatRoughnessMap:$,iridescence:X,iridescenceMap:Q,iridescenceThicknessMap:ee,sheen:Y,sheenColorMap:te,sheenRoughnessMap:ne,specularMap:ie,specularColorMap:re,specularIntensityMap:ae,transmission:q,transmissionMap:se,thicknessMap:oe,gradientMap:le,opaque:!1===a.transparent&&a.blending===hm,alphaMap:he,alphaTest:ce,alphaHash:ue,combine:a.combine,mapUv:I&&m(a.map.channel),aoMapUv:N&&m(a.aoMap.channel),lightMapUv:F&&m(a.lightMap.channel),bumpMapUv:U&&m(a.bumpMap.channel),normalMapUv:B&&m(a.normalMap.channel),displacementMapUv:z&&m(a.displacementMap.channel),emissiveMapUv:H&&m(a.emissiveMap.channel),metalnessMapUv:V&&m(a.metalnessMap.channel),roughnessMapUv:j&&m(a.roughnessMap.channel),anisotropyMapUv:J&&m(a.anisotropyMap.channel),clearcoatMapUv:Z&&m(a.clearcoatMap.channel),clearcoatNormalMapUv:K&&m(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:$&&m(a.clearcoatRoughnessMap.channel),iridescenceMapUv:Q&&m(a.iridescenceMap.channel),iridescenceThicknessMapUv:ee&&m(a.iridescenceThicknessMap.channel),sheenColorMapUv:te&&m(a.sheenColorMap.channel),sheenRoughnessMapUv:ne&&m(a.sheenRoughnessMap.channel),specularMapUv:ie&&m(a.specularMap.channel),specularColorMapUv:re&&m(a.specularColorMap.channel),specularIntensityMapUv:ae&&m(a.specularIntensityMap.channel),transmissionMapUv:se&&m(a.transmissionMap.channel),thicknessMapUv:oe&&m(a.thicknessMap.channel),alphaMapUv:he&&m(a.alphaMap.channel),vertexTangents:!!x.attributes.tangent&&(B||G),vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!x.attributes.color&&4===x.attributes.color.itemSize,vertexUv1s:pe,vertexUv2s:fe,vertexUv3s:me,pointsUvs:!0===v.isPoints&&!!x.attributes.uv&&(I||he),fog:!!y,useFog:!0===a.fog,fogExp2:y&&y.isFogExp2,flatShading:!0===a.flatShading,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==x.morphAttributes.position,morphNormals:void 0!==x.morphAttributes.normal,morphColors:void 0!==x.morphAttributes.color,morphTargetsCount:P,morphTextureStride:R,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&h.length>0,shadowMapType:e.shadowMap.type,toneMapping:ge,useLegacyLights:e._useLegacyLights,premultipliedAlpha:a.premultipliedAlpha,doubleSided:a.side===Sr,flipSided:a.side===Ki,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionDerivatives:de&&!0===a.extensions.derivatives,extensionFragDepth:de&&!0===a.extensions.fragDepth,extensionDrawBuffers:de&&!0===a.extensions.drawBuffers,extensionShaderTextureLOD:de&&!0===a.extensions.shaderTextureLOD,rendererExtensionFragDepth:c||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||i.has("EXT_shader_texture_lod"),customProgramCacheKey:a.customProgramCacheKey()}},getProgramCacheKey:function(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.isWebGL2&&o.enable(0),t.supportsVertexTextures&&o.enable(1),t.instancing&&o.enable(2),t.instancingColor&&o.enable(3),t.matcap&&o.enable(4),t.envMap&&o.enable(5),t.normalMapObjectSpace&&o.enable(6),t.normalMapTangentSpace&&o.enable(7),t.clearcoat&&o.enable(8),t.iridescence&&o.enable(9),t.alphaTest&&o.enable(10),t.vertexColors&&o.enable(11),t.vertexAlphas&&o.enable(12),t.vertexUv1s&&o.enable(13),t.vertexUv2s&&o.enable(14),t.vertexUv3s&&o.enable(15),t.vertexTangents&&o.enable(16),t.anisotropy&&o.enable(17),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.skinning&&o.enable(4),t.morphTargets&&o.enable(5),t.morphNormals&&o.enable(6),t.morphColors&&o.enable(7),t.premultipliedAlpha&&o.enable(8),t.shadowMapEnabled&&o.enable(9),t.useLegacyLights&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){let t,n=f[e.type];if(n){let e=xc[n];t=Ti.clone(e.uniforms)}else t=e.uniforms;return t},acquireProgram:function(t,n){let i;for(let e=0,r=h.length;e0?i.push(c):!0===s.transparent?r.push(c):n.push(c)},unshift:function(e,t,s,o,l,h){let c=a(e,t,s,o,l,h);s.transmission>0?i.unshift(c):!0===s.transparent?r.unshift(c):n.unshift(c)},finish:function(){for(let n=t,i=e.length;n1&&n.sort(e||Got),i.length>1&&i.sort(t||Bce),r.length>1&&r.sort(t||Bce)}}}function qot(){let e=new WeakMap;return{get:function(t,n){let i,r=e.get(t);return void 0===r?(i=new Uce,e.set(t,[i])):n>=r.length?(i=new Uce,r.push(i)):i=r[n],i},dispose:function(){e=new WeakMap}}}function Wot(){let e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new O,color:new ct};break;case"SpotLight":n={position:new O,direction:new O,color:new ct,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new O,color:new ct,distance:0,decay:0};break;case"HemisphereLight":n={direction:new O,skyColor:new ct,groundColor:new ct};break;case"RectAreaLight":n={color:new ct,position:new O,halfWidth:new O,halfHeight:new O}}return e[t.id]=n,n}}}function jot(){let e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new be};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new be,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}var Xot=0;function Yot(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function $ot(e,t){let n=new Wot,i=jot(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let l=0;l<9;l++)r.probe.push(new O);let a=new O,s=new et,o=new et;return{setup:function(a,s){let o=0,l=0,h=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,u=0,d=0,p=0,f=0,m=0,g=0,v=0,y=0,x=0;a.sort(Yot);let b=!0===s?Math.PI:1;for(let e=0,t=a.length;e0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=Jt.LTC_FLOAT_1,r.rectAreaLTC2=Jt.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=Jt.LTC_HALF_1,r.rectAreaLTC2=Jt.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=l,r.ambient[2]=h;let _=r.hash;(_.directionalLength!==c||_.pointLength!==u||_.spotLength!==d||_.rectAreaLength!==p||_.hemiLength!==f||_.numDirectionalShadows!==m||_.numPointShadows!==g||_.numSpotShadows!==v||_.numSpotMaps!==y)&&(r.directional.length=c,r.spot.length=d,r.rectArea.length=p,r.point.length=u,r.hemi.length=f,r.directionalShadow.length=m,r.directionalShadowMap.length=m,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=v,r.spotShadowMap.length=v,r.directionalShadowMatrix.length=m,r.pointShadowMatrix.length=g,r.spotLightMatrix.length=v+y-x,r.spotLightMap.length=y,r.numSpotLightShadowsWithMaps=x,_.directionalLength=c,_.pointLength=u,_.spotLength=d,_.rectAreaLength=p,_.hemiLength=f,_.numDirectionalShadows=m,_.numPointShadows=g,_.numSpotShadows=v,_.numSpotMaps=y,r.version=Xot++)},setupView:function(e,t){let n=0,i=0,l=0,h=0,c=0,u=t.matrixWorldInverse;for(let d=0,p=e.length;d=s.length?(a=new Hce(e,t),s.push(a)):a=s[r],a},dispose:function(){n=new WeakMap}}}var Tc=class extends yr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=uhe,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},xb=class extends yr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},Kot="void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",Jot="uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}";function Qot(e,t,n){let i=new ya,r=new be,a=new be,s=new gr,o=new Tc({depthPacking:Rv}),l=new xb,h={},c=n.maxTextureSize,u={[pi]:Ki,[Ki]:pi,[Sr]:Sr},d=new ln({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new be},radius:{value:4}},vertexShader:Kot,fragmentShader:Jot}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new Dt;f.setAttribute("position",new mn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new xt(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=OU;let v=this.type;function y(n,i){let a=t.update(m);d.defines.VSM_SAMPLES!==n.blurSamples&&(d.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new sr(r.x,r.y)),d.uniforms.shadow_pass.value=n.map.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,a,d,m,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,a,p,m,null)}function x(t,n,i,r){let a=null,s=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==s)a=s;else if(a=!0===i.isPointLight?l:o,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){let e=a.uuid,t=n.uuid,i=h[e];void 0===i&&(i={},h[e]=i);let r=i[t];void 0===r&&(r=a.clone(),i[t]=r),a=r}return a.visible=n.visible,a.wireframe=n.wireframe,a.side=r===yu?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],a.alphaMap=n.alphaMap,a.alphaTest=n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===i.isPointLight&&!0===a.isMeshDistanceMaterial&&(e.properties.get(a).light=i),a}function b(n,r,a,s,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&o===yu)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let i=t.update(n),r=n.material;if(Array.isArray(r)){let t=i.groups;for(let l=0,h=t.length;lc||r.y>c)&&(r.x>c&&(a.x=Math.floor(c/u.x),r.x=a.x*u.x,h.mapSize.x=a.x),r.y>c&&(a.y=Math.floor(c/u.y),r.y=a.y*u.y,h.mapSize.y=a.y)),null===h.map||!0===p||!0===f){let e=this.type!==yu?{minFilter:Jr,magFilter:Jr}:{};null!==h.map&&h.map.dispose(),h.map=new sr(r.x,r.y,e),h.map.texture.name=l.name+".shadowMap",h.camera.updateProjectionMatrix()}e.setRenderTarget(h.map),e.clear();let g=h.getViewportCount();for(let e=0;e=1):-1!==O.indexOf("OpenGL ES")&&(R=parseFloat(/^OpenGL ES (\d)/.exec(O)[1]),P=R>=2);let L=null,I={},D=e.getParameter(e.SCISSOR_BOX),k=e.getParameter(e.VIEWPORT),N=(new gr).fromArray(D),F=(new gr).fromArray(k);function U(t,n,r,a){let s=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let l=0;li||e.height>i)&&(r=i/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){let i=t?yR:Math.floor,a=i(r*e.width),s=i(r*e.height);void 0===o&&(o=y(a,s));let l=n?y(a,s):o;return l.width=a,l.height=s,l.getContext("2d").drawImage(e,0,0,a,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+a+"x"+s+")."),l}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function b(e){return LB(e.width)&&LB(e.height)}function _(e,t){return e.generateMipmaps&&t&&e.minFilter!==Jr&&e.minFilter!==Ir}function w(t){e.generateMipmap(t)}function S(n,i,r,a,s=!1){if(!1===l)return i;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;return i===e.RED&&(r===e.FLOAT&&(o=e.R32F),r===e.HALF_FLOAT&&(o=e.R16F),r===e.UNSIGNED_BYTE&&(o=e.R8)),i===e.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.R8UI),r===e.UNSIGNED_SHORT&&(o=e.R16UI),r===e.UNSIGNED_INT&&(o=e.R32UI),r===e.BYTE&&(o=e.R8I),r===e.SHORT&&(o=e.R16I),r===e.INT&&(o=e.R32I)),i===e.RG&&(r===e.FLOAT&&(o=e.RG32F),r===e.HALF_FLOAT&&(o=e.RG16F),r===e.UNSIGNED_BYTE&&(o=e.RG8)),i===e.RGBA&&(r===e.FLOAT&&(o=e.RGBA32F),r===e.HALF_FLOAT&&(o=e.RGBA16F),r===e.UNSIGNED_BYTE&&(o=a===tn&&!1===s?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(o=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(o=e.RGB5_A1)),(o===e.R16F||o===e.R32F||o===e.RG16F||o===e.RG32F||o===e.RGBA16F||o===e.RGBA32F)&&t.get("EXT_color_buffer_float"),o}function M(e,t,n){return!0===_(e,n)||e.isFramebufferTexture&&e.minFilter!==Jr&&e.minFilter!==Ir?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function T(t){return t===Jr||t===of||t===zh?e.NEAREST:e.LINEAR}function E(e){let t=e.target;t.removeEventListener("dispose",E),function(e){let t=i.get(e);if(void 0===t.__webglInit)return;let n=e.source,r=g.get(n);if(r){let i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&C(e),0===Object.keys(r).length&&g.delete(n)}i.remove(e)}(t),t.isVideoTexture&&m.delete(t)}function A(t){let n=t.target;n.removeEventListener("dispose",A),function(t){let n=t.texture,r=i.get(t),a=i.get(n);if(void 0!==a.__webglTexture&&(e.deleteTexture(a.__webglTexture),s.memory.textures--),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let i=0;i<6;i++){if(Array.isArray(r.__webglFramebuffer[i]))for(let t=0;t0&&a.__version!==t.version){let e=t.image;if(null===e)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void N(a,t,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+r)}let O={[Ci]:e.REPEAT,[Ai]:e.CLAMP_TO_EDGE,[qh]:e.MIRRORED_REPEAT},L={[Jr]:e.NEAREST,[of]:e.NEAREST_MIPMAP_NEAREST,[zh]:e.NEAREST_MIPMAP_LINEAR,[Ir]:e.LINEAR,[Rm]:e.LINEAR_MIPMAP_NEAREST,[Ua]:e.LINEAR_MIPMAP_LINEAR},I={[fhe]:e.NEVER,[bhe]:e.ALWAYS,[phe]:e.LESS,[ghe]:e.LEQUAL,[mhe]:e.EQUAL,[xhe]:e.GEQUAL,[vhe]:e.GREATER,[yhe]:e.NOTEQUAL};function D(n,a,s){if(s?(e.texParameteri(n,e.TEXTURE_WRAP_S,O[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,O[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,O[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,L[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,L[a.minFilter])):(e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),(a.wrapS!==Ai||a.wrapT!==Ai)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,e.TEXTURE_MAG_FILTER,T(a.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,T(a.minFilter)),a.minFilter!==Jr&&a.minFilter!==Ir&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,I[a.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){let s=t.get("EXT_texture_filter_anisotropic");if(a.magFilter===Jr||a.minFilter!==zh&&a.minFilter!==Ua||a.type===ga&&!1===t.has("OES_texture_float_linear")||!1===l&&a.type===Rr&&!1===t.has("OES_texture_half_float_linear"))return;(a.anisotropy>1||i.get(a).__currentAnisotropy)&&(e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy)}}function k(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",E));let r=n.source,a=g.get(r);void 0===a&&(a={},g.set(r,a));let o=function(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(o!==t.__cacheKey){void 0===a[o]&&(a[o]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,i=!0),a[o].usedTimes++;let r=a[t.__cacheKey];void 0!==r&&(a[t.__cacheKey].usedTimes--,0===r.usedTimes&&C(n)),t.__cacheKey=o,t.__webglTexture=a[o].texture}return i}function N(t,r,s){let o=e.TEXTURE_2D;(r.isDataArrayTexture||r.isCompressedArrayTexture)&&(o=e.TEXTURE_2D_ARRAY),r.isData3DTexture&&(o=e.TEXTURE_3D);let h=k(t,r),c=r.source;n.bindTexture(o,t.__webglTexture,e.TEXTURE0+s);let d=i.get(c);if(c.version!==d.__version||!0===h){n.activeTexture(e.TEXTURE0+s),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);let t=function(e){return!l&&(e.wrapS!==Ai||e.wrapT!==Ai||e.minFilter!==Jr&&e.minFilter!==Ir)}(r)&&!1===b(r.image),i=x(r.image,t,!1,u);i=V(r,i);let p=b(i)||l,f=a.convert(r.format,r.colorSpace),m=a.convert(r.type),g=S(r.internalFormat,f,m,r.colorSpace);D(o,r,p);let v,y=r.mipmaps,T=l&&!0!==r.isVideoTexture,E=void 0===d.__version||!0===h,A=M(r,i,p);if(r.isDepthTexture)g=e.DEPTH_COMPONENT,l?g=r.type===ga?e.DEPTH_COMPONENT32F:r.type===Hh?e.DEPTH_COMPONENT24:r.type===bu?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:r.type===ga&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===sf&&g===e.DEPTH_COMPONENT&&r.type!==Sv&&r.type!==Hh&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Hh,m=a.convert(r.type)),r.format===Wh&&g===e.DEPTH_COMPONENT&&(g=e.DEPTH_STENCIL,r.type!==bu&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=bu,m=a.convert(r.type))),E&&(T?n.texStorage2D(e.TEXTURE_2D,1,g,i.width,i.height):n.texImage2D(e.TEXTURE_2D,0,g,i.width,i.height,0,f,m,null));else if(r.isDataTexture)if(y.length>0&&p){T&&E&&n.texStorage2D(e.TEXTURE_2D,A,g,y[0].width,y[0].height);for(let t=0,i=y.length;t>=1,r>>=1}}else if(y.length>0&&p){T&&E&&n.texStorage2D(e.TEXTURE_2D,A,g,y[0].width,y[0].height);for(let t=0,i=y.length;t>h),i=Math.max(1,r.height>>h);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,h,d,t,i,r.depth,0,c,u,null):n.texImage2D(l,h,d,t,i,0,c,u,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),H(r)?p.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,o,l,i.get(s).__webglTexture,0,z(r)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,o,l,i.get(s).__webglTexture,h),n.bindFramebuffer(e.FRAMEBUFFER,null)}function U(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer&&!n.stencilBuffer){let r=e.DEPTH_COMPONENT16;if(i||H(n)){let t=n.depthTexture;t&&t.isDepthTexture&&(t.type===ga?r=e.DEPTH_COMPONENT32F:t.type===Hh&&(r=e.DEPTH_COMPONENT24));let i=z(n);H(n)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,i,r,n.width,n.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,i,r,n.width,n.height)}else e.renderbufferStorage(e.RENDERBUFFER,r,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(n.depthBuffer&&n.stencilBuffer){let r=z(n);i&&!1===H(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):H(n)?p.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{let t=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let r=0;r0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function V(e,n){let i=e.colorSpace,r=e.format,a=e.type;return!0===e.isCompressedTexture||e.format===vR||i!==Ha&&i!==_u&&(i===tn?!1===l?!0===t.has("EXT_sRGB")&&r===ea?(e.format=vR,e.minFilter=Ir,e.generateMipmaps=!1):n=mb.sRGBToLinear(n):(r!==ea||a!==Ec)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",i)),n}this.allocateTextureUnit=function(){let e=P;return e>=h&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+h),P+=1,e},this.resetTextureUnits=function(){P=0},this.setTexture2D=R,this.setTexture2DArray=function(t,r){let a=i.get(t);t.version>0&&a.__version!==t.version?N(a,t,r):n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+r)},this.setTexture3D=function(t,r){let a=i.get(t);t.version>0&&a.__version!==t.version?N(a,t,r):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,r){let s=i.get(t);t.version>0&&s.__version!==t.version?function(t,r,s){if(6!==r.image.length)return;let o=k(t,r),h=r.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+s);let u=i.get(h);if(h.version!==u.__version||!0===o){n.activeTexture(e.TEXTURE0+s),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);let t=r.isCompressedTexture||r.image[0].isCompressedTexture,i=r.image[0]&&r.image[0].isDataTexture,d=[];for(let e=0;e<6;e++)d[e]=t||i?i?r.image[e].image:r.image[e]:x(r.image[e],!1,!0,c),d[e]=V(r,d[e]);let p,f=d[0],m=b(f)||l,g=a.convert(r.format,r.colorSpace),v=a.convert(r.type),y=S(r.internalFormat,g,v,r.colorSpace),T=l&&!0!==r.isVideoTexture,E=void 0===u.__version||!0===o,A=M(r,f,m);if(D(e.TEXTURE_CUBE_MAP,r,m),t){T&&E&&n.texStorage2D(e.TEXTURE_CUBE_MAP,A,y,f.width,f.height);for(let t=0;t<6;t++){p=d[t].mipmaps;for(let i=0;i0&&A++,n.texStorage2D(e.TEXTURE_CUBE_MAP,A,y,d[0].width,d[0].height));for(let t=0;t<6;t++)if(i){T?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,d[t].width,d[t].height,g,v,d[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,y,d[t].width,d[t].height,0,g,v,d[t].data);for(let i=0;i0){h.__webglFramebuffer[t]=[];for(let n=0;n0){h.__webglFramebuffer=[];for(let t=0;t0&&!1===H(t)){let i=d?o:[o];h.__webglMultisampledFramebuffer=e.createFramebuffer(),h.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,h.__webglMultisampledFramebuffer);for(let n=0;n0)for(let i=0;i0)for(let n=0;n0&&!1===H(t)){let r=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],a=t.width,s=t.height,o=e.COLOR_BUFFER_BIT,l=[],h=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=i.get(t),u=!0===t.isWebGLMultipleRenderTargets;if(u)for(let t=0;to+h?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&s<=o-h&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==s&&(i=t.getPose(e.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(nlt)))}return null!==s&&(s.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==a),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){let n=new er;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},cf=class extends qr{constructor(e,t,n,i,r,a,s,o,l,h){if((h=void 0!==h?h:sf)!==sf&&h!==Wh)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&h===sf&&(n=Hh),void 0===n&&h===Wh&&(n=bu),super(null,i,r,a,s,o,h,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==s?s:Jr,this.minFilter=void 0!==o?o:Jr,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}},YB=class extends jo{constructor(e,t){super();let n=this,i=null,r=1,a=null,s="local-floor",o=1,l=null,h=null,c=null,u=null,d=null,p=null,f=t.getContextAttributes(),m=null,g=null,v=[],y=[],x=new ur;x.layers.enable(1),x.viewport=new gr;let b=new ur;b.layers.enable(2),b.viewport=new gr;let _=[x,b],w=new _R;w.layers.enable(1),w.layers.enable(2);let S=null,M=null;function T(e){let t=y.indexOf(e.inputSource);if(-1===t)return;let n=v[t];void 0!==n&&(n.update(e.inputSource,e.frame,l||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function E(){i.removeEventListener("select",T),i.removeEventListener("selectstart",T),i.removeEventListener("selectend",T),i.removeEventListener("squeeze",T),i.removeEventListener("squeezestart",T),i.removeEventListener("squeezeend",T),i.removeEventListener("end",E),i.removeEventListener("inputsourceschange",A);for(let e=0;e=0&&(y[i]=null,v[i].disconnect(n))}for(let t=0;t=y.length){y.push(n),i=e;break}if(null===y[e]){y[e]=n,i=e;break}}if(-1===i)break}let r=v[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=v[e];return void 0===t&&(t=new ob,v[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=v[e];return void 0===t&&(t=new ob,v[e]=t),t.getGripSpace()},this.getHand=function(e){let t=v[e];return void 0===t&&(t=new ob,v[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){s=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return c},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=function(h){return ft(this,null,(function*(){if(i=h,null!==i){if(m=e.getRenderTarget(),i.addEventListener("select",T),i.addEventListener("selectstart",T),i.addEventListener("selectend",T),i.addEventListener("squeeze",T),i.addEventListener("squeezestart",T),i.addEventListener("squeezeend",T),i.addEventListener("end",E),i.addEventListener("inputsourceschange",A),!0!==f.xrCompatible&&(yield t.makeXRCompatible()),void 0===i.renderState.layers||!1===e.capabilities.isWebGL2){let n={antialias:void 0!==i.renderState.layers||f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,n),i.updateRenderState({baseLayer:d}),g=new sr(d.framebufferWidth,d.framebufferHeight,{format:ea,type:Ec,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil})}else{let n=null,a=null,s=null;f.depth&&(s=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=f.stencil?Wh:sf,a=f.stencil?bu:Hh);let o={colorFormat:t.RGBA8,depthFormat:s,scaleFactor:r};c=new XRWebGLBinding(i,t),u=c.createProjectionLayer(o),i.updateRenderState({layers:[u]}),g=new sr(u.textureWidth,u.textureHeight,{format:ea,type:Ec,depthTexture:new cf(u.textureWidth,u.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0}),e.properties.get(g).__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=yield i.requestReferenceSpace(s),I.setContext(i),I.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}}))},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode};let C=new O,P=new O;function R(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===i)return;w.near=b.near=x.near=e.near,w.far=b.far=x.far=e.far,(S!==w.near||M!==w.far)&&(i.updateRenderState({depthNear:w.near,depthFar:w.far}),S=w.near,M=w.far);let t=e.parent,n=w.cameras;R(w,t);for(let i=0;i0&&(i.alphaTest.value=r.alphaTest);let a=t.get(r).envMap;if(a&&(i.envMap.value=a,i.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,i.reflectivity.value=r.reflectivity,i.ior.value=r.ior,i.refractionRatio.value=r.refractionRatio),r.lightMap){i.lightMap.value=r.lightMap;let t=!0===e._useLegacyLights?Math.PI:1;i.lightMapIntensity.value=r.lightMapIntensity*t,n(r.lightMap,i.lightMapTransform)}r.aoMap&&(i.aoMap.value=r.aoMap,i.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,i.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,whe(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,a,s,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(i(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(i(e,r),function(e,i){e.metalness.value=i.metalness,i.metalnessMap&&(e.metalnessMap.value=i.metalnessMap,n(i.metalnessMap,e.metalnessMapTransform)),e.roughness.value=i.roughness,i.roughnessMap&&(e.roughnessMap.value=i.roughnessMap,n(i.roughnessMap,e.roughnessMapTransform)),t.get(i).envMap&&(e.envMapIntensity.value=i.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===Ki&&e.clearcoatNormalScale.value.negate())),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,o)):r.isMeshMatcapMaterial?(i(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),function(e,n){let i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,a,s):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function ilt(e,t,n,i){let r={},a={},s=[],o=n.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(e,t,n){let i=e.value;if(void 0===n[t]){if("number"==typeof i)n[t]=i;else{let e=Array.isArray(i)?i:[i],r=[];for(let t=0;t0&&(i=n%16,0!==i&&16-i-a.boundary<0&&(n+=16-i,e.__offset=n)),n+=a.storage}i=n%16,i>0&&(n+=16-i),e.__size=n,e.__cache={}}(n),d=function(t){let n=function(){for(let e=0;e0),u=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,p=!!n.morphAttributes.color,f=Vh;i.toneMapped&&(null===w||!0===w.isXRRenderTarget)&&(f=y.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,v=void 0!==g?g.length:0,x=$.get(i),b=m.state.lights;if(!0===z&&(!0===H||e!==M)){let t=e===M&&i.id===S;he.setState(i,e,t)}let _=!1;i.version===x.__version?(x.needsLights&&x.lightsStateVersion!==b.state.version||x.outputColorSpace!==o||r.isInstancedMesh&&!1===x.instancing||!r.isInstancedMesh&&!0===x.instancing||r.isSkinnedMesh&&!1===x.skinning||!r.isSkinnedMesh&&!0===x.skinning||r.isInstancedMesh&&!0===x.instancingColor&&null===r.instanceColor||r.isInstancedMesh&&!1===x.instancingColor&&null!==r.instanceColor||x.envMap!==l||!0===i.fog&&x.fog!==a||void 0!==x.numClippingPlanes&&(x.numClippingPlanes!==he.numPlanes||x.numIntersection!==he.numIntersection)||x.vertexAlphas!==h||x.vertexTangents!==c||x.morphTargets!==u||x.morphNormals!==d||x.morphColors!==p||x.toneMapping!==f||!0===J.isWebGL2&&x.morphTargetsCount!==v)&&(_=!0):(_=!0,x.__version=i.version);let T=x.currentProgram;!0===_&&(T=ke(i,t,r));let E=!1,A=!1,C=!1,P=T.getUniforms(),R=x.uniforms;if(Z.useProgram(T.program)&&(E=!0,A=!0,C=!0),i.id!==S&&(S=i.id,A=!0),E||M!==e){if(P.setValue(ye,"projectionMatrix",e.projectionMatrix),J.logarithmicDepthBuffer&&P.setValue(ye,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),M!==e&&(M=e,A=!0,C=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshStandardMaterial||i.envMap){let t=P.map.cameraPosition;void 0!==t&&t.setValue(ye,W.setFromMatrixPosition(e.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&P.setValue(ye,"isOrthographic",!0===e.isOrthographicCamera),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.isShadowMaterial||r.isSkinnedMesh)&&P.setValue(ye,"viewMatrix",e.matrixWorldInverse)}if(r.isSkinnedMesh){P.setOptional(ye,r,"bindMatrix"),P.setOptional(ye,r,"bindMatrixInverse");let e=r.skeleton;e&&(J.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),P.setValue(ye,"boneTexture",e.boneTexture,Q),P.setValue(ye,"boneTextureSize",e.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let O=n.morphAttributes;if((void 0!==O.position||void 0!==O.normal||void 0!==O.color&&!0===J.isWebGL2)&&de.update(r,n,T),(A||x.receiveShadow!==r.receiveShadow)&&(x.receiveShadow=r.receiveShadow,P.setValue(ye,"receiveShadow",r.receiveShadow)),i.isMeshGouraudMaterial&&null!==i.envMap&&(R.envMap.value=l,R.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1),A&&(P.setValue(ye,"toneMappingExposure",y.toneMappingExposure),x.needsLights&&function(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}(R,C),a&&!0===i.fog&&se.refreshFogUniforms(R,a),se.refreshMaterialUniforms(R,i,I,L,V),rv.upload(ye,x.uniformsList,R,Q)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(rv.upload(ye,x.uniformsList,R,Q),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&P.setValue(ye,"center",r.center),P.setValue(ye,"modelViewMatrix",r.modelViewMatrix),P.setValue(ye,"normalMatrix",r.normalMatrix),P.setValue(ye,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){let e=i.uniformsGroups;for(let t=0,n=e.length;t0&&function(e,t,n,i){let r=J.isWebGL2;null===V&&(V=new sr(1,1,{generateMipmaps:!0,type:q.has("EXT_color_buffer_half_float")?Rr:Ec,minFilter:Ua,samples:r?4:0})),y.getDrawingBufferSize(G),r?V.setSize(G.x,G.y):V.setSize(yR(G.x),yR(G.y));let a=y.getRenderTarget();y.setRenderTarget(V),y.getClearColor(C),P=y.getClearAlpha(),P<1&&y.setClearColor(16777215,.5),y.clear();let s=y.toneMapping;y.toneMapping=Vh,Ie(e,n,i),Q.updateMultisampleRenderTarget(V),Q.updateRenderTargetMipmap(V);let o=!1;for(let l=0,h=t.length;l0&&Ie(r,t,n),a.length>0&&Ie(a,t,n),s.length>0&&Ie(s,t,n),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function Ie(e,t,n){let i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,a=e.length;r0?v[v.length-1]:null,g.pop(),f=g.length>0?g[g.length-1]:null},this.getActiveCubeFace=function(){return b},this.getActiveMipmapLevel=function(){return _},this.getRenderTarget=function(){return w},this.setRenderTargetTextures=function(e,t,n){$.get(e.texture).__webglTexture=t,$.get(e.depthTexture).__webglTexture=n;let i=$.get(e);i.__hasExternalTextures=!0,i.__hasExternalTextures&&(i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===q.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){let n=$.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){w=e,b=t,_=n;let i=!0,r=null,a=!1,s=!1;if(e){let o=$.get(e);void 0!==o.__useDefaultFramebuffer?(Z.bindFramebuffer(ye.FRAMEBUFFER,null),i=!1):void 0===o.__webglFramebuffer?Q.setupRenderTarget(e):o.__hasExternalTextures&&Q.rebindTextures(e,$.get(e.texture).__webglTexture,$.get(e.depthTexture).__webglTexture);let l=e.texture;(l.isData3DTexture||l.isDataArrayTexture||l.isCompressedArrayTexture)&&(s=!0);let h=$.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(h[t])?h[t][n]:h[t],a=!0):r=J.isWebGL2&&e.samples>0&&!1===Q.useMultisampledRTT(e)?$.get(e).__webglMultisampledFramebuffer:Array.isArray(h)?h[n]:h,T.copy(e.viewport),E.copy(e.scissor),A=e.scissorTest}else T.copy(N).multiplyScalar(I).floor(),E.copy(F).multiplyScalar(I).floor(),A=U;if(Z.bindFramebuffer(ye.FRAMEBUFFER,r)&&J.drawBuffers&&i&&Z.drawBuffers(e,r),Z.viewport(T),Z.scissor(E),Z.setScissorTest(A),a){let i=$.get(e.texture);ye.framebufferTexture2D(ye.FRAMEBUFFER,ye.COLOR_ATTACHMENT0,ye.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(s){let i=$.get(e.texture),r=t||0;ye.framebufferTextureLayer(ye.FRAMEBUFFER,ye.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}S=-1},this.readRenderTargetPixels=function(e,t,n,i,r,a,s){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=$.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==s&&(o=o[s]),o){Z.bindFramebuffer(ye.FRAMEBUFFER,o);try{let s=e.texture,o=s.format,l=s.type;if(o!==ea&&me.convert(o)!==ye.getParameter(ye.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");let h=l===Rr&&(q.has("EXT_color_buffer_half_float")||J.isWebGL2&&q.has("EXT_color_buffer_float"));if(!(l===Ec||me.convert(l)===ye.getParameter(ye.IMPLEMENTATION_COLOR_READ_TYPE)||l===ga&&(J.isWebGL2||q.has("OES_texture_float")||q.has("WEBGL_color_buffer_float"))||h))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&ye.readPixels(t,n,i,r,me.convert(o),me.convert(l),a)}finally{let e=null!==w?$.get(w).__webglFramebuffer:null;Z.bindFramebuffer(ye.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){let i=Math.pow(2,-n),r=Math.floor(t.image.width*i),a=Math.floor(t.image.height*i);Q.setTexture2D(t,0),ye.copyTexSubImage2D(ye.TEXTURE_2D,n,0,0,e.x,e.y,r,a),Z.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){let r=t.image.width,a=t.image.height,s=me.convert(n.format),o=me.convert(n.type);Q.setTexture2D(n,0),ye.pixelStorei(ye.UNPACK_FLIP_Y_WEBGL,n.flipY),ye.pixelStorei(ye.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),ye.pixelStorei(ye.UNPACK_ALIGNMENT,n.unpackAlignment),t.isDataTexture?ye.texSubImage2D(ye.TEXTURE_2D,i,e.x,e.y,r,a,s,o,t.image.data):t.isCompressedTexture?ye.compressedTexSubImage2D(ye.TEXTURE_2D,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,s,t.mipmaps[0].data):ye.texSubImage2D(ye.TEXTURE_2D,i,e.x,e.y,s,o,t.image),0===i&&n.generateMipmaps&&ye.generateMipmap(ye.TEXTURE_2D),Z.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i,r=0){if(y.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");let a,s=e.max.x-e.min.x+1,o=e.max.y-e.min.y+1,l=e.max.z-e.min.z+1,h=me.convert(i.format),c=me.convert(i.type);if(i.isData3DTexture)Q.setTexture3D(i,0),a=ye.TEXTURE_3D;else{if(!i.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");Q.setTexture2DArray(i,0),a=ye.TEXTURE_2D_ARRAY}ye.pixelStorei(ye.UNPACK_FLIP_Y_WEBGL,i.flipY),ye.pixelStorei(ye.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),ye.pixelStorei(ye.UNPACK_ALIGNMENT,i.unpackAlignment);let u=ye.getParameter(ye.UNPACK_ROW_LENGTH),d=ye.getParameter(ye.UNPACK_IMAGE_HEIGHT),p=ye.getParameter(ye.UNPACK_SKIP_PIXELS),f=ye.getParameter(ye.UNPACK_SKIP_ROWS),m=ye.getParameter(ye.UNPACK_SKIP_IMAGES),g=n.isCompressedTexture?n.mipmaps[0]:n.image;ye.pixelStorei(ye.UNPACK_ROW_LENGTH,g.width),ye.pixelStorei(ye.UNPACK_IMAGE_HEIGHT,g.height),ye.pixelStorei(ye.UNPACK_SKIP_PIXELS,e.min.x),ye.pixelStorei(ye.UNPACK_SKIP_ROWS,e.min.y),ye.pixelStorei(ye.UNPACK_SKIP_IMAGES,e.min.z),n.isDataTexture||n.isData3DTexture?ye.texSubImage3D(a,r,t.x,t.y,t.z,s,o,l,h,c,g.data):n.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ye.compressedTexSubImage3D(a,r,t.x,t.y,t.z,s,o,l,h,g.data)):ye.texSubImage3D(a,r,t.x,t.y,t.z,s,o,l,h,c,g),ye.pixelStorei(ye.UNPACK_ROW_LENGTH,u),ye.pixelStorei(ye.UNPACK_IMAGE_HEIGHT,d),ye.pixelStorei(ye.UNPACK_SKIP_PIXELS,p),ye.pixelStorei(ye.UNPACK_SKIP_ROWS,f),ye.pixelStorei(ye.UNPACK_SKIP_IMAGES,m),0===r&&i.generateMipmaps&&ye.generateMipmap(a),Z.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?Q.setTextureCube(e,0):e.isData3DTexture?Q.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?Q.setTexture2DArray(e,0):Q.setTexture2D(e,0),Z.unbindTexture()},this.resetState=function(){b=0,_=0,w=null,Z.reset(),ge.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return xu}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===tn?Eu:WU}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Eu?tn:Ha}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}},TR=class extends Ms{};TR.prototype.isWebGL1Renderer=!0;var ov=class{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new ct(e),this.density=t}clone(){return new ov(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}},wu=class{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new ct(e),this.near=t,this.far=n}clone(){return new wu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}},_i=class extends an{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t}},$h=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=db,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Wo()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;ie.far||t.push({distance:o,point:Kx.clone(),uv:Zr.getInterpolation(Kx,zM,Qx,GM,Vce,WN,zce,new be),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}};function qM(e,t,n,i,r,a){Z0.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?(Jx.x=a*Z0.x-r*Z0.y,Jx.y=r*Z0.x+a*Z0.y):Jx.copy(Z0),e.copy(t),e.x+=Jx.x,e.y+=Jx.y,e.applyMatrix4(Ihe)}var WM=new O,Gce=new O,SR=class extends an{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let n=0,i=t.length;n0){let n,i;for(n=1,i=t.length;n0){WM.setFromMatrixPosition(this.matrixWorld);let n=e.ray.origin.distanceTo(WM);this.getObjectForDistance(n).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){WM.setFromMatrixPosition(e.matrixWorld),Gce.setFromMatrixPosition(this.matrixWorld);let n,i,r=WM.distanceTo(Gce)/e.zoom;for(t[0].object.visible=!0,n=1,i=t.length;n=e))break;t[n-1].object.visible=!1,t[n].object.visible=!0}for(this._currentLevel=n-1;no)continue;u.applyMatrix4(this.matrixWorld);let r=e.ray.origin.distanceTo(u);re.far||t.push({distance:r,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}else for(let m=Math.max(0,a.start),g=Math.min(f.count,a.start+a.count)-1;mo)continue;u.applyMatrix4(this.matrixWorld);let n=e.ray.origin.distanceTo(u);ne.far||t.push({distance:n,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e0){let n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er.far)return;a.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:t,face:null,object:s})}}var ZB=class extends qr{constructor(e,t,n,i,r,a,s,o,l){super(e,t,n,i,r,a,s,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==a?a:Ir,this.magFilter=void 0!==r?r:Ir,this.generateMipmaps=!1;let h=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){h.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e==0&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},KB=class extends qr{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Jr,this.minFilter=Jr,this.generateMipmaps=!1,this.needsUpdate=!0}},Mu=class extends qr{constructor(e,t,n,i,r,a,s,o,l,h,c,u){super(null,a,s,o,l,h,i,r,c,u),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},JB=class extends Mu{constructor(e,t,n,i,r,a){super(e,t,n,r,a),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Ai}},QB=class extends Mu{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,Gh),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},Eb=class extends qr{constructor(e,t,n,i,r,a,s,o,l){super(e,t,n,i,r,a,s,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Va=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t,n=[],i=this.getPoint(0),r=0;n.push(0);for(let a=1;a<=e;a++)t=this.getPoint(a/e),r+=t.distanceTo(i),n.push(r),i=t;return this.cacheArcLengths=n,n}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let n,i=this.getLengths(),r=0,a=i.length;n=t||e*i[a-1];let s,o=0,l=a-1;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),s=i[r]-n,s<0)o=r+1;else{if(!(s>0)){l=r;break}l=r-1}if(r=l,i[r]===n)return r/(a-1);let h=i[r];return(r+(n-h)/(i[r+1]-h))/(a-1)}getTangent(e,t){let n=e-1e-4,i=e+1e-4;n<0&&(n=0),i>1&&(i=1);let r=this.getPoint(n),a=this.getPoint(i),s=t||(r.isVector2?new be:new O);return s.copy(a).sub(r).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){let n=new O,i=[],r=[],a=[],s=new O,o=new et;for(let d=0;d<=e;d++){let t=d/e;i[d]=this.getTangentAt(t,new O)}r[0]=new O,a[0]=new O;let l=Number.MAX_VALUE,h=Math.abs(i[0].x),c=Math.abs(i[0].y),u=Math.abs(i[0].z);h<=l&&(l=h,n.set(1,0,0)),c<=l&&(l=c,n.set(0,1,0)),u<=l&&n.set(0,0,1),s.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],s),a[0].crossVectors(i[0],r[0]);for(let d=1;d<=e;d++){if(r[d]=r[d-1].clone(),a[d]=a[d-1].clone(),s.crossVectors(i[d-1],i[d]),s.length()>Number.EPSILON){s.normalize();let e=Math.acos(cs(i[d-1].dot(i[d]),-1,1));r[d].applyMatrix4(o.makeRotationAxis(s,e))}a[d].crossVectors(i[d],r[d])}if(!0===t){let t=Math.acos(cs(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(s.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],t*n)),a[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:a}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},Kh=class extends Va{constructor(e=0,t=0,n=1,i=1,r=0,a=2*Math.PI,s=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=s,this.aRotation=o}getPoint(e,t){let n=t||new be,i=2*Math.PI,r=this.aEndAngle-this.aStartAngle,a=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(l)/s)+1)*s:0===h&&l===s-1&&(l=s-2,h=1),this.closed||l>0?n=a[(l-1)%s]:(ZM.subVectors(a[0],a[1]).add(a[0]),n=ZM);let c=a[l%s],u=a[(l+1)%s];if(this.closed||l+2i.length-2?i.length-1:a+1],c=i[a>i.length-3?i.length-1:a+2];return n.set(sue(s,o.x,l.x,h.x,c.x),sue(s,o.y,l.y,h.y,c.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){let e=i[r]-n,a=this.curves[r],s=a.getLength(),o=0===s?0:1-e/s;return a.getPointAt(o,t)}r++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,i=this.curves.length;n1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){let e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},ym=class extends Dt{constructor(e=[new be(0,-.5),new be(.5,0),new be(0,.5)],t=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=cs(i,0,2*Math.PI);let r=[],a=[],s=[],o=[],l=[],h=1/t,c=new O,u=new be,d=new O,p=new O,f=new O,m=0,g=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,d.x=1*g,d.y=-m,d.z=0*g,f.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(f.x,f.y,f.z);break;default:m=e[v+1].x-e[v].x,g=e[v+1].y-e[v].y,d.x=1*g,d.y=-m,d.z=0*g,p.copy(d),d.x+=f.x,d.y+=f.y,d.z+=f.z,d.normalize(),o.push(d.x,d.y,d.z),f.copy(p)}for(let v=0;v<=t;v++){let r=n+v*h*i,d=Math.sin(r),p=Math.cos(r);for(let n=0;n<=e.length-1;n++){c.x=e[n].x*d,c.y=e[n].y,c.z=e[n].x*p,a.push(c.x,c.y,c.z),u.x=v/t,u.y=n/(e.length-1),s.push(u.x,u.y);let i=o[3*n+0]*d,r=o[3*n+1],h=o[3*n+0]*p;l.push(i,r,h)}}for(let v=0;v0&&v(!0),t>0&&v(!1)),this.setIndex(h),this.setAttribute("position",new Bt(c,3)),this.setAttribute("normal",new Bt(u,3)),this.setAttribute("uv",new Bt(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new wc(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},dv=class extends wc{constructor(e=1,t=1,n=32,i=1,r=!1,a=0,s=2*Math.PI){super(0,e,t,n,i,r,a,s),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:s}}static fromJSON(e){return new dv(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Au=class extends Dt{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};let r=[],a=[];function s(e,t,n,i){let r=i+1,a=[];for(let s=0;s<=r;s++){a[s]=[];let i=e.clone().lerp(n,s/r),o=t.clone().lerp(n,s/r),l=r-s;for(let e=0;e<=l;e++)a[s][e]=0===e&&s===r?i:i.clone().lerp(o,e/l)}for(let s=0;s.9&&s<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),i<.2&&(a[e+4]+=1))}}()}(),this.setAttribute("position",new Bt(r,3)),this.setAttribute("normal",new Bt(r.slice(),3)),this.setAttribute("uv",new Bt(a,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Au(e.vertices,e.indices,e.radius,e.details)}},fv=class extends Au{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new fv(e.radius,e.detail)}},KM=new O,JM=new O,JN=new O,QM=new Zr,Cu=class extends Dt{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){let n=Math.pow(10,4),i=Math.cos(dm*t),r=e.getIndex(),a=e.getAttribute("position"),s=r?r.count:a.count,o=[0,0,0],l=["a","b","c"],h=new Array(3),c={},u=[];for(let e=0;e80*n){i=a=e[0],r=s=e[1];for(let t=n;ta&&(a=o),l>s&&(s=l);h=Math.max(a-i,s-r),h=0!==h?32767/h:0}return Sb(d,p,n,i,r,h,0),p}};function Lhe(e,t,n,i,r){let a,s;if(r===Llt(e,t,n,i)>0)for(a=t;a=t;a-=i)s=aue(a,e[a],e[a+1],s);return s&&JR(s,s.next)&&(Rb(s),s=s.next),s}function xm(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!JR(i,i.next)&&0!==Zi(i.prev,i,i.next))i=i.next;else{if(Rb(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function Sb(e,t,n,i,r,a,s){if(!e)return;!s&&a&&Mlt(e,i,r,a);let o,l,h=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,a?ylt(e,i,r,a):vlt(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),Rb(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?Sb(e=xlt(xm(e),t,n),t,n,i,r,a,2):2===s&&blt(e,t,n,i,r,a):Sb(xm(e),t,n,i,r,a,1);break}}function vlt(e){let t=e.prev,n=e,i=e.next;if(Zi(t,n,i)>=0)return!1;let r=t.x,a=n.x,s=i.x,o=t.y,l=n.y,h=i.y,c=ra?r>s?r:s:a>s?a:s,p=o>l?o>h?o:h:l>h?l:h,f=i.next;for(;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&tv(r,o,a,l,s,h,f.x,f.y)&&Zi(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function ylt(e,t,n,i){let r=e.prev,a=e,s=e.next;if(Zi(r,a,s)>=0)return!1;let o=r.x,l=a.x,h=s.x,c=r.y,u=a.y,d=s.y,p=ol?o>h?o:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,v=eU(p,f,t,n,i),y=eU(m,g,t,n,i),x=e.prevZ,b=e.nextZ;for(;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&tv(o,c,l,u,h,d,x.x,x.y)&&Zi(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==s&&tv(o,c,l,u,h,d,b.x,b.y)&&Zi(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&tv(o,c,l,u,h,d,x.x,x.y)&&Zi(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==s&&tv(o,c,l,u,h,d,b.x,b.y)&&Zi(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function xlt(e,t,n){let i=e;do{let r=i.prev,a=i.next.next;!JR(r,a)&&Dhe(r,i,i.next,a)&&Mb(r,a)&&Mb(a,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(a.i/n|0),Rb(i),Rb(i.next),i=e=a),i=i.next}while(i!==e);return xm(i)}function blt(e,t,n,i,r,a){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&Clt(s,e)){let o=Ohe(s,e);return s=xm(s,s.next),o=xm(o,o.next),Sb(s,t,n,i,r,a,0),void Sb(o,t,n,i,r,a,0)}e=e.next}s=s.next}while(s!==e)}function Elt(e,t,n,i){let r,a,s,o,l,h=[];for(r=0,a=t.length;r=i.next.y&&i.next.y!==i.y){let e=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=a&&e>r&&(r=e,n=i.x=i.x&&i.x>=h&&a!==i.x&&tv(sn.x||i.x===n.x&&Slt(n,i)))&&(n=i,u=o)),i=i.next}while(i!==l);return n}function Slt(e,t){return Zi(e.prev,e,t.prev)<0&&Zi(t.next,e,e.next)<0}function Mlt(e,t,n,i){let r=e;do{0===r.z&&(r.z=eU(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,Rlt(r)}function Rlt(e){let t,n,i,r,a,s,o,l,h=1;do{for(n=e,e=null,a=null,s=0;n;){for(s++,i=n,o=0,t=0;t0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,l--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,h*=2}while(s>1);return e}function eU(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Alt(e){let t=e,n=e;do{(t.x=(e-s)*(a-o)&&(e-s)*(i-o)>=(n-s)*(t-o)&&(n-s)*(a-o)>=(r-s)*(i-o)}function Clt(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Plt(e,t)&&(Mb(e,t)&&Mb(t,e)&&Ilt(e,t)&&(Zi(e.prev,e,t.prev)||Zi(e,t.prev,t))||JR(e,t)&&Zi(e.prev,e,e.next)>0&&Zi(t.prev,t,t.next)>0)}function Zi(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function JR(e,t){return e.x===t.x&&e.y===t.y}function Dhe(e,t,n,i){let r=tR(Zi(e,t,n)),a=tR(Zi(e,t,i)),s=tR(Zi(n,i,e)),o=tR(Zi(n,i,t));return!!(r!==a&&s!==o||0===r&&eR(e,n,t)||0===a&&eR(e,i,t)||0===s&&eR(n,e,i)||0===o&&eR(n,t,i))}function eR(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function tR(e){return e>0?1:e<0?-1:0}function Plt(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Dhe(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Mb(e,t){return Zi(e.prev,e,e.next)<0?Zi(e,t,e.next)>=0&&Zi(e,e.prev,t)>=0:Zi(e,t,e.prev)<0||Zi(e,e.next,t)<0}function Ilt(e,t){let n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}function Ohe(e,t){let n=new tU(e.i,e.x,e.y),i=new tU(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function aue(e,t,n,i){let r=new tU(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Rb(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function tU(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Llt(e,t,n,i){let r=0;for(let a=t,s=n-i;a2&&e[t-1].equals(e[0])&&e.pop()}function lue(e,t){for(let n=0;nNumber.EPSILON){let u=Math.sqrt(c),d=Math.sqrt(l*l+h*h),p=t.x-o/u,f=t.y+s/u,m=((n.x-h/d-p)*h-(n.y+l/d-f)*l)/(s*h-o*l);i=p+s*m-e.x,r=f+o*m-e.y;let g=i*i+r*r;if(g<=2)return new be(i,r);a=Math.sqrt(g/2)}else{let e=!1;s>Number.EPSILON?l>Number.EPSILON&&(e=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(h)&&(e=!0),e?(i=-o,r=s,a=Math.sqrt(c)):(i=s,r=o,a=Math.sqrt(c/2))}return new be(i/a,r/a)}let L=[];for(let t=0,n=E.length,i=n-1,r=t+1;t=0;t--){let e=t/y,n=m*Math.cos(e*Math.PI/2),i=g*Math.sin(e*Math.PI/2)+v;for(let t=0,r=E.length;t=0;){let i=n,r=n-1;r<0&&(r=e.length-1);for(let e=0,n=d+2*y;e0)&&d.push(t,i,s),(g!==n-1||o0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},na=class extends yr{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ct(16777215),this.specular=new ct(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ct(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mf,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Nb,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},DR=class extends yr{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ct(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ct(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mf,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},df=class extends yr{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mf,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},Pu=class extends yr{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ct(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ct(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mf,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Nb,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},OR=class extends yr{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ct(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=mf,this.normalScale=new be(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}},Iu=class extends Gn{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};function wl(e,t,n){return KU(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)}function um(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function KU(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function khe(e){let t=e.length,n=new Array(t);for(let i=0;i!==t;++i)n[i]=i;return n.sort((function(t,n){return e[t]-e[n]})),n}function nU(e,t,n){let i=e.length,r=new e.constructor(i);for(let a=0,s=0;s!==i;++a){let i=n[a]*t;for(let n=0;n!==t;++n)r[s++]=e[i+n]}return r}function JU(e,t,n,i){let r=1,a=e[0];for(;void 0!==a&&void 0===a[i];)a=e[r++];if(void 0===a)return;let s=a[i];if(void 0!==s)if(Array.isArray(s))do{s=a[i],void 0!==s&&(t.push(a.time),n.push.apply(n,s)),a=e[r++]}while(void 0!==a);else if(void 0!==s.toArray)do{s=a[i],void 0!==s&&(t.push(a.time),s.toArray(n,n.length)),a=e[r++]}while(void 0!==a);else do{s=a[i],void 0!==s&&(t.push(a.time),n.push(s)),a=e[r++]}while(void 0!==a)}function Flt(e,t,n,i,r=30){let a=e.clone();a.name=t;let s=[];for(let l=0;l=i)){o.push(e.times[a]);for(let n=0;na.tracks[l].times[0]&&(o=a.tracks[l].times[0]);for(let l=0;l=t.times[d]){let e=d*l+o,n=e+l-o;u=wl(t.values,e,n)}else{let e=t.createInterpolant(),n=o,i=l-o;e.evaluate(a),u=wl(e.resultBuffer,n,i)}"quaternion"===i&&(new dr).fromArray(u).normalize().conjugate().toArray(u);let p=r.times.length;for(let e=0;e=r)break e;{let s=t[1];e=r)break t}a=n,n=0}}for(;n>>1;et;)--a;if(++a,0!==r||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);let e=this.getValueSize();this.times=wl(n,r,a),this.values=wl(this.values,r*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let s=0;s!==r;s++){let t=n[s];if("number"==typeof t&&isNaN(t)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,s,t),e=!1;break}if(null!==a&&a>t){console.error("THREE.KeyframeTrack: Out of order keys.",this,s,t,a),e=!1;break}a=t}if(void 0!==i&&KU(i))for(let s=0,o=i.length;s!==o;++s){let t=i[s];if(isNaN(t)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,s,t),e=!1;break}}return e}optimize(){let e=wl(this.times),t=wl(this.values),n=this.getValueSize(),i=this.getInterpolation()===pR,r=e.length-1,a=1;for(let s=1;s0){e[a]=e[r];for(let e=r*n,i=a*n,s=0;s!==n;++s)t[i+s]=t[e+s];++a}return a!==e.length?(this.times=wl(e,0,a),this.values=wl(t,0,a*n)):(this.times=e,this.values=t),this}clone(){let e=wl(this.times,0),t=wl(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}};Yo.prototype.TimeBufferType=Float32Array,Yo.prototype.ValueBufferType=Float32Array,Yo.prototype.DefaultInterpolation=Tu;var Qh=class extends Yo{};Qh.prototype.ValueTypeName="bool",Qh.prototype.ValueBufferType=Array,Qh.prototype.DefaultInterpolation=jh,Qh.prototype.InterpolantFactoryMethodLinear=void 0,Qh.prototype.InterpolantFactoryMethodSmooth=void 0;var Cb=class extends Yo{};Cb.prototype.ValueTypeName="color";var Cl=class extends Yo{};Cl.prototype.ValueTypeName="number";var NR=class extends Jh{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=(n-t)/(i-t),l=e*s;for(let h=l+s;l!==h;l+=4)dr.slerpFlat(r,0,a,l-s,a,l,o);return r}},Ga=class extends Yo{InterpolantFactoryMethodLinear(e){return new NR(this.times,this.values,this.getValueSize(),e)}};Ga.prototype.ValueTypeName="quaternion",Ga.prototype.DefaultInterpolation=Tu,Ga.prototype.InterpolantFactoryMethodSmooth=void 0;var ed=class extends Yo{};ed.prototype.ValueTypeName="string",ed.prototype.ValueBufferType=Array,ed.prototype.DefaultInterpolation=jh,ed.prototype.InterpolantFactoryMethodLinear=void 0,ed.prototype.InterpolantFactoryMethodSmooth=void 0;var qa=class extends Yo{};qa.prototype.ValueTypeName="vector";var po=class{constructor(e,t=-1,n,i=ZR){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Wo(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let a=0,s=n.length;a!==s;++a)t.push(Hlt(n[a]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let r=0,a=n.length;r!==a;++r)t.push(Yo.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,a=[];for(let s=0;s1){let e=n[1],r=i[e];r||(i[e]=r=[]),r.push(t)}}let a=[];for(let s in i)a.push(this.CreateFromMorphTargetSequence(s,i[s],t,n));return a}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(e,t,n,i,r){if(0!==n.length){let a=[],s=[];JU(n,a,s,i),0!==a.length&&r.push(new e(t,a,s))}},i=[],r=e.name||"default",a=e.fps||30,s=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let h=0;h{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==Bh[e])return void Bh[e].push({onLoad:t,onProgress:n,onError:i});Bh[e]=[],Bh[e].push({onLoad:t,onProgress:n,onError:i});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),s=this.mimeType,o=this.responseType;fetch(a).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;let n=Bh[e],i=t.body.getReader(),r=t.headers.get("Content-Length")||t.headers.get("X-File-Size"),a=r?parseInt(r):0,s=0!==a,o=0,l=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{o+=r.byteLength;let i=new ProgressEvent("progress",{lengthComputable:s,loaded:o,total:a});for(let e=0,t=n.length;e{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,s)));case"json":return e.json();default:if(void 0===s)return e.text();{let t=/charset="?([^;"\s]*)"?/i.exec(s),n=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(n);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{Em.add(e,t);let n=Bh[e];delete Bh[e];for(let e=0,i=n.length;e{let n=Bh[e];if(void 0===n)throw this.manager.itemError(e),t;delete Bh[e];for(let e=0,i=n.length;e{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},iU=class extends Er{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new Kr(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e){let t=[];for(let n=0;n0:i.vertexColors=e.vertexColors),void 0!==e.uniforms)for(let r in e.uniforms){let t=e.uniforms[r];switch(i.uniforms[r]={},t.type){case"t":i.uniforms[r].value=n(t.value);break;case"c":i.uniforms[r].value=(new ct).setHex(t.value);break;case"v2":i.uniforms[r].value=(new be).fromArray(t.value);break;case"v3":i.uniforms[r].value=(new O).fromArray(t.value);break;case"v4":i.uniforms[r].value=(new gr).fromArray(t.value);break;case"m3":i.uniforms[r].value=(new Ln).fromArray(t.value);break;case"m4":i.uniforms[r].value=(new et).fromArray(t.value);break;default:i.uniforms[r].value=t.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(i.glslVersion=e.glslVersion),void 0!==e.extensions)for(let r in e.extensions)i.extensions[r]=e.extensions[r];if(void 0!==e.lights&&(i.lights=e.lights),void 0!==e.clipping&&(i.clipping=e.clipping),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=n(e.map)),void 0!==e.matcap&&(i.matcap=n(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),i.normalScale=(new be).fromArray(t)}return void 0!==e.displacementMap&&(i.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=n(e.specularMap)),void 0!==e.specularIntensityMap&&(i.specularIntensityMap=n(e.specularIntensityMap)),void 0!==e.specularColorMap&&(i.specularColorMap=n(e.specularColorMap)),void 0!==e.envMap&&(i.envMap=n(e.envMap)),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=(new be).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(i.iridescenceMap=n(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(i.transmissionMap=n(e.transmissionMap)),void 0!==e.thicknessMap&&(i.thicknessMap=n(e.thicknessMap)),void 0!==e.anisotropyMap&&(i.anisotropyMap=n(e.anisotropyMap)),void 0!==e.sheenColorMap&&(i.sheenColorMap=n(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){return new{ShadowMaterial:IR,SpriteMaterial:bb,RawShaderMaterial:LR,ShaderMaterial:ln,PointsMaterial:xi,MeshPhysicalMaterial:Xo,MeshStandardMaterial:hf,MeshPhongMaterial:na,MeshToonMaterial:DR,MeshNormalMaterial:df,MeshLambertMaterial:Pu,MeshDepthMaterial:Tc,MeshDistanceMaterial:xb,MeshBasicMaterial:on,MeshMatcapMaterial:OR,LineDashedMaterial:Iu,LineBasicMaterial:Gn,Material:yr}[e]}},ra=class{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;n0){let i=new Lu(t);n=new _m(i),n.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t0){t=new _m(this.manager),t.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let o=t,l=t+t;o!==l;++o)if(n[o]!==n[o+t]){s.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let r=n,a=i;r!==a;++r)t[r]=t[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let a=0;a!==r;++a)e[t+a]=e[n+a]}_slerp(e,t,n,i){dr.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let a=this._workIndex*r;dr.multiplyQuaternionsFlat(e,a,e,t,e,n),dr.slerpFlat(e,t,e,t,e,a,i)}_lerp(e,t,n,i,r){let a=1-i;for(let s=0;s!==r;++s){let r=t+s;e[r]=e[r]*a+e[n+s]*i}}_lerpAdditive(e,t,n,i,r){for(let a=0;a!==r;++a){let r=t+a;e[r]=e[r]+e[n+a]*i}}},QU="\\[\\]\\.:\\/",qlt=new RegExp("["+QU+"]","g"),eH="[^"+QU+"]",Wlt="[^"+QU.replace("\\.","")+"]",jlt=/((?:WC+[\/:])*)/.source.replace("WC",eH),Xlt=/(WCOD+)?/.source.replace("WCOD",Wlt),Ylt=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",eH),$lt=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",eH),Zlt=new RegExp("^"+jlt+Xlt+Ylt+$lt+"$"),Klt=["material","materials","bones","map"],vU=class{constructor(e,t,n){let i=n||Jn.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},Jn=class{constructor(e,t,n){this.path=t,this.parsedPath=n||Jn.parseTrackName(t),this.node=Jn.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Jn.Composite(e,t,n):new Jn(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(qlt,"")}static parseTrackName(e){let t=Zlt.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){let e=n.nodeName.substring(i+1);-1!==Klt.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){let n=function(e){for(let i=0;i=r){let a=r++,h=e[a];t[h.uuid]=l,e[l]=h,t[o]=a,e[a]=s;for(let e=0,t=i;e!==t;++e){let t=n[e],i=t[a],r=t[l];t[l]=i,t[a]=r}}}this.nCachedObjects_=r}uncache(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length,r=this.nCachedObjects_,a=e.length;for(let s=0,o=arguments.length;s!==o;++s){let o=arguments[s].uuid,l=t[o];if(void 0!==l)if(delete t[o],l0&&(t[s.uuid]=l),e[l]=s,e.pop();for(let e=0,t=i;e!==t;++e){let t=n[e];t[l]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){let n=this._bindingsIndicesByPath,i=n[e],r=this._bindings;if(void 0!==i)return r[i];let a=this._paths,s=this._parsedPaths,o=this._objects,l=o.length,h=this.nCachedObjects_,c=new Array(l);i=r.length,n[e]=i,a.push(e),s.push(t),r.push(c);for(let u=h,d=o.length;u!==d;++u){let n=o[u];c[u]=new Jn(n,e,t)}return c}unsubscribe_(e){let t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){let i=this._paths,r=this._parsedPaths,a=this._bindings,s=a.length-1,o=a[s];t[e[s]]=n,a[n]=o,a.pop(),r[n]=r[s],r.pop(),i[n]=i[s],i.pop()}}},qR=class{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;let r=t.tracks,a=r.length,s=new Array(a),o={endingStart:lm,endingEnd:lm};for(let l=0;l!==a;++l){let e=r[l].createInterpolant(null);s[l]=e,e.settings=o}this._interpolantSettings=o,this._interpolants=s,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=lhe,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){let n=this._clip.duration,i=e._clip.duration,r=i/n,a=n/i;e.warp(1,r,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,a=this.timeScale,s=this._timeScaleInterpolant;null===s&&(s=i._lendControlInterpolant(),this._timeScaleInterpolant=s);let o=s.parameterPositions,l=s.sampleValues;return o[0]=r,o[1]=r+n,l[0]=e/a,l[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled)return void this._updateWeight(e);let r=this._startTime;if(null!==r){let i=(e-r)*n;i<0||0===n?t=0:(this._startTime=null,t=n*i)}t*=this._updateTimeScale(e);let a=this._updateTime(t),s=this._updateWeight(e);if(s>0){let e=this._interpolants,t=this._propertyBindings;if(this.blendMode===GU)for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(a),t[n].accumulateAdditive(s);else for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(a),t[n].accumulate(i,s)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(null!==n){let i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;null!==n&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,a=n===che;if(0===e)return-1===r?i:a&&1==(1&r)?t-i:i;if(n===ohe){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),i>=t||i<0){let n=Math.floor(i/t);i-=t*n,r+=Math.abs(n);let s=this.repetitions-r;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===s){let t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(a&&1==(1&r))return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;n?(i.endingStart=cm,i.endingEnd=cm):(i.endingStart=e?this.zeroSlopeAtStart?cm:lm:hb,i.endingEnd=t?this.zeroSlopeAtEnd?cm:lm:hb)}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);let s=a.parameterPositions,o=a.sampleValues;return s[0]=r,o[0]=t,s[1]=r+e,o[1]=n,this}},Jlt=new Float32Array(1),xU=class extends jo{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,a=e._propertyBindings,s=e._interpolants,o=n.uuid,l=this._bindingsByRootAndName,h=l[o];void 0===h&&(h={},l[o]=h);for(let c=0;c!==r;++c){let e=i[c],r=e.name,l=h[r];if(void 0!==l)++l.referenceCount,a[c]=l;else{if(l=a[c],void 0!==l){null===l._cacheIndex&&(++l.referenceCount,this._addInactiveBinding(l,o,r));continue}let i=t&&t._propertyBindings[c].binding.parsedPath;l=new GR(Jn.create(n,r,i),e.ValueTypeName,e.getValueSize()),++l.referenceCount,this._addInactiveBinding(l,o,r),a[c]=l}s[c].resultBuffer=l.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){let t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return null!==t&&t=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),a=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(i,e,r,a);let s=this._bindings,o=this._nActiveBindings;for(let l=0;l!==o;++l)s[l].apply(a);return this}setTime(e){this.time=0;for(let t=0;tthis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,_ue).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Tue=new O,rR=new O,sa=class{constructor(e=new O,t=new O){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Tue.subVectors(e,this.start),rR.subVectors(this.end,this.start);let n=rR.dot(rR),i=rR.dot(Tue)/n;return t&&(i=cs(i,0,1)),i}closestPointToPoint(e,t,n){let i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}},wue=new O,SU=class extends an{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let n=new Dt,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,s=1,o=32;a1)for(let h=0;h.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Cue.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Cue,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},DU=class extends Wr{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=new Dt;n.setAttribute("position",new Bt(t,3)),n.setAttribute("color",new Bt([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(n,new Gn({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){let i=new ct,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},Sm=class{constructor(){this.type="ShapePath",this.color=new ct,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Ru,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,r,a){return this.currentPath.bezierCurveTo(e,t,n,i,r,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e,t){let n=t.length,i=!1;for(let r=n-1,a=0;aNumber.EPSILON){if(l<0&&(n=t[a],o=-o,s=t[r],l=-l),e.ys.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{let t=l*(e.x-n.x)-o*(e.y-n.y);if(0===t)return!0;if(t<0)continue;i=!i}}else{if(e.y!==n.y)continue;if(s.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=s.x)return!0}}return i}let n=qs.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,a,s,o=[];if(1===i.length)return a=i[0],s=new Ss,s.curves=a.curves,o.push(s),o;let l=!n(i[0].getPoints());l=e?!l:l;let h,c,u=[],d=[],p=[],f=0;d[f]=void 0,p[f]=[];for(let m=0,g=i.length;m1){let e=!1,n=0;for(let t=0,i=d.length;t0&&!1===e&&(p=u)}for(let m=0,g=d.length;ma)return!1;let o=n.ray.origin.distanceTo(Hhe);return!(on.far)&&(s.push({distance:o,point:Uhe.clone(),index:i,object:e}),!0)}hr.prototype.raycast=function(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Line.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),ku.copy(n.boundingSphere),ku.applyMatrix4(i),ku.radius+=r,!1===e.ray.intersectsSphere(ku))return;let s=r*r,o=this.isLineSegments?2:1,l=n.index,h=n.attributes.position,c=t.length;if(null!==l){let n=this.userData.batches;if(n&&n.length>0&&n[0].boundingSphere)for(let r=0;r=1))return}else for(let i=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count)-1;i=1))return}else{let n=this.userData.batches;if(n&&n.length>0&&n[0].boundingSphere)for(let r=0;r=1)return}else for(let i=Math.max(0,a.start),r=Math.min(h.count,a.start+a.count)-1;i=1)return}};var Vhe=Math.pow(2,-24),Cm=class{constructor(){}};function Il(e,t,n){return n.min.x=t[e],n.min.y=t[e+1],n.min.z=t[e+2],n.max.x=t[e+3],n.max.y=t[e+4],n.max.z=t[e+5],n}function tH(e){let t=-1,n=-1/0;for(let i=0;i<3;i++){let r=e[i+3]-e[i];r>n&&(n=r,t=i)}return t}function nH(e,t){t.set(e)}function rH(e,t,n){let i,r;for(let a=0;a<3;a++){let s=a+3;i=e[a],r=t[a],n[a]=ir?i:r}}function Ub(e,t,n){for(let i=0;i<3;i++){let r=t[e+2*i],a=t[e+2*i+1],s=r-a,o=r+a;sn[i+3]&&(n[i+3]=o)}}function Pv(e){let t=e[3]-e[0],n=e[4]-e[1],i=e[5]-e[2];return 2*(t*n+n*i+i*t)}function rct(e,t){if(!e.index){let n,i=e.attributes.position.count,r=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;n=i>65535?new Uint32Array(new r(4*i)):new Uint16Array(new r(2*i)),e.setIndex(new mn(n,1));for(let e=0;ee-t));for(let r=0;rl&&(l=r),v&&tf&&(f=t);let x=e[y+2],b=e[y+3],_=x-b,w=x+b;_h&&(h=w),v&&xm&&(m=x);let S=e[y+4],M=e[y+5],T=S-M,E=S+M;Tc&&(c=E),v&&Sg&&(g=S)}i[0]=a,i[1]=s,i[2]=o,i[3]=l,i[4]=h,i[5]=c,v&&(r[0]=u,r[1]=d,r[2]=p,r[3]=f,r[4]=m,r[5]=g)}function sct(e,t,n,i){let r=1/0,a=1/0,s=1/0,o=-1/0,l=-1/0,h=-1/0;for(let c=6*t,u=6*(t+n);co&&(o=t);let n=e[c+2];nl&&(l=n);let i=e[c+4];ih&&(h=i)}i[0]=r,i[1]=a,i[2]=s,i[3]=o,i[4]=l,i[5]=h}function act(e,t,n,i,r){let a=n,s=n+i-1,o=r.pos,l=2*r.axis;for(;;){for(;a<=s&&t[6*a+l]=o;)s--;if(!(ae.candidate-t.candidate,gf=new Array(td).fill().map((()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0}))),eA=new Float32Array(6);function lct(e,t,n,i,r,a){let s=-1,o=0;if(0===a)s=tH(t),-1!==s&&(o=(t[s]+t[s+3])/2);else if(1===a)s=tH(e),-1!==s&&(o=cct(n,i,r,s));else if(2===a){let a=Pv(e),l=1.25*r,h=6*i,c=6*(i+r);for(let e=0;e<3;e++){let i=t[e],u=(t[e+3]-i)/td;if(r=a.candidate?Ub(r,n,a.rightCacheBounds):(Ub(r,n,a.leftCacheBounds),a.count++)}}for(let n=0;n=td&&(t=td-1);let a=gf[t];a.count++,Ub(r,n,a.bounds)}let t=gf[td-1];nH(t.bounds,t.rightCacheBounds);for(let e=td-2;e>=0;e--){let t=gf[e],n=gf[e+1];rH(t.bounds,n.rightCacheBounds,t.rightCacheBounds)}let d=0;for(let n=0;nm&&(m=h),u>m&&(m=u);let g=(m-p)/2,v=2*i;a[f+v+0]=p+g,a[f+v+1]=g+(Math.abs(p)+g)*Vhe,pt[i+3]&&(t[i+3]=m)}}return a}function hct(e,t){function n(e){d&&d(e/p)}function i(t,r,d,p=null,m=0){if(!f&&m>=l&&(f=!0,h&&(console.warn(`MeshBVH: Max depth of ${l} reached when generating BVH. Consider increasing maxDepth.`),console.warn(e))),d<=c||m>=l)return n(r+d),t.offset=r,t.count=d,t;let g=lct(t.boundingData,p,s,r,d,u);if(-1===g.axis)return n(r+d),t.offset=r,t.count=d,t;let v=act(o,s,r,d,g);if(v===r||v===r+d)n(r+d),t.offset=r,t.count=d;else{t.splitAxis=g.axis;let e=new Cm,n=r,o=v-r;t.left=e,e.boundingData=new Float32Array(6),sH(s,n,o,e.boundingData,a),i(e,n,o,a,m+1);let l=new Cm,h=v,c=d-o;t.right=l,l.boundingData=new Float32Array(6),sH(s,h,c,l.boundingData,a),i(l,h,c,a,m+1)}return t}rct(e,t);let r=new Float32Array(6),a=new Float32Array(6),s=uct(e,r),o=e.index.array,l=t.maxDepth,h=t.verbose,c=t.maxLeafTris,u=t.strategy,d=t.onProgress,p=e.index.count/3,f=!1,m=[],g=ict(e);if(1===g.length){let e=g[0],t=new Cm;t.boundingData=r,sct(s,e.offset,e.count,a),i(t,e.offset,e.count,a),m.push(t)}else for(let v of g){let e=new Cm;e.boundingData=new Float32Array(6),sH(s,v.offset,v.count,e.boundingData,a),i(e,v.offset,v.count,a),m.push(e)}return m}function qhe(e,t){let n,i,r,a=hct(e,t),s=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let c=0;cMath.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return i[a+6]=n/4,n=h(n,s),i[a+7]=o,n}}}var vo=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let r=0,a=e.length;ri?a:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let r=0,a=t.length;ri?s:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}};vo.prototype.setFromBox=function(){let e=new O;return function(t,n){let i=n.min,r=n.max,a=1/0,s=-1/0;for(let o=0;o<=1;o++)for(let n=0;n<=1;n++)for(let l=0;l<=1;l++){e.x=i.x*o+r.x*(1-o),e.y=i.y*n+r.y*(1-n),e.z=i.z*l+r.z*(1-l);let h=t.dot(e);a=Math.min(h,a),s=Math.max(h,s)}this.min=a,this.max=s}}();var QIt=function(){let e=new vo;return function(t,n){let i=t.points,r=t.satAxes,a=t.satBounds,s=n.points,o=n.satAxes,l=n.satBounds;for(let h=0;h<3;h++){let t=a[h],n=r[h];if(e.setFromPoints(n,s),t.isSeparated(e))return!1}for(let h=0;h<3;h++){let t=l[h],n=o[h];if(e.setFromPoints(n,i),t.isSeparated(e))return!1}}}(),dct=function(){let e=new O,t=new O,n=new O;return function(i,r,a){let s=i.start,o=e,l=r.start,h=t;n.subVectors(s,l),e.subVectors(i.end,i.start),t.subVectors(r.end,r.start);let c,u,d=n.dot(h),p=h.dot(o),f=h.dot(h),m=n.dot(o),g=o.dot(o)*f-p*p;c=0!==g?(d*p-m*f)/g:0,u=(d+c*p)/f,a.x=c,a.y=u}}(),Hb=function(){let e=new be,t=new O,n=new O;return function(i,r,a,s){dct(i,r,e);let o=e.x,l=e.y;if(o>=0&&o<=1&&l>=0&&l<=1)return i.at(o,a),void r.at(l,s);if(o>=0&&o<=1)return l<0?r.at(0,s):r.at(1,s),void i.closestPointToPoint(s,!0,a);if(l>=0&&l<=1)return o<0?i.at(0,a):i.at(1,a),void r.closestPointToPoint(a,!0,s);{let e,h;e=o<0?i.start:i.end,h=l<0?r.start:r.end;let c=t,u=n;return i.closestPointToPoint(h,!0,t),r.closestPointToPoint(e,!0,n),c.distanceToSquared(h)<=u.distanceToSquared(e)?(a.copy(c),void s.copy(h)):(a.copy(e),void s.copy(u))}}}(),Whe=function(){let e=new O,t=new O,n=new Gr,i=new sa;return function(r,a){let{radius:s,center:o}=r,{a:l,b:h,c:c}=a;if(i.start=l,i.end=h,i.closestPointToPoint(o,!0,e).distanceTo(o)<=s||(i.start=l,i.end=c,i.closestPointToPoint(o,!0,e).distanceTo(o)<=s)||(i.start=h,i.end=c,i.closestPointToPoint(o,!0,e).distanceTo(o)<=s))return!0;let u=a.getPlane(n);if(Math.abs(u.distanceToPoint(o))<=s){let e=u.projectPoint(o,t);if(a.containsPoint(e))return!0}return!1}}(),fct=1e-15;function Iv(e){return Math.abs(e)new O)),this.satBounds=new Array(4).fill().map((()=>new vo)),this.points=[this.a,this.b,this.c],this.sphere=new vr,this.plane=new Gr,this.needsUpdate=!0}intersectsSphere(e){return Whe(e,this)}update(){let e=this.a,t=this.b,n=this.c,i=this.points,r=this.satAxes,a=this.satBounds,s=r[0],o=a[0];this.getNormal(s),o.setFromPoints(s,i);let l=r[1],h=a[1];l.subVectors(e,t),h.setFromPoints(l,i);let c=r[2],u=a[2];c.subVectors(t,n),u.setFromPoints(c,i);let d=r[3],p=a[3];d.subVectors(n,e),p.setFromPoints(d,i),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(s,e),this.needsUpdate=!1}};yo.prototype.closestPointToSegment=function(){let e=new O,t=new O,n=new sa;return function(i,r=null,a=null){let s,{start:o,end:l}=i,h=this.points,c=1/0;for(let u=0;u<3;u++){let o=(u+1)%3;n.start.copy(h[u]),n.end.copy(h[o]),Hb(n,i,e,t),s=e.distanceToSquared(t),s1-1e-10){let e=this.satBounds,s=this.satAxes;n[0]=d.a,n[1]=d.b,n[2]=d.c;for(let t=0;t<4;t++){let r=e[t],a=s[t];if(i.setFromPoints(a,n),r.isSeparated(i))return!1}let o=d.satBounds,l=d.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let n=0;n<4;n++){let e=o[n],r=l[n];if(i.setFromPoints(r,t),e.isSeparated(i))return!1}for(let h=0;h<4;h++){let e=s[h];for(let s=0;s<4;s++){let o=l[s];if(a.crossVectors(e,o),i.setFromPoints(a,t),r.setFromPoints(a,n),i.isSeparated(r))return!1}}return p&&(f||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}{let e=this.points,t=!1,n=0;for(let o=0;o<3;o++){let i=e[o],r=e[(o+1)%3];h.start.copy(i),h.end.copy(r),h.delta(s);let a=t?c.start:c.end,l=Iv(g.distanceToPoint(i));if(Iv(g.normal.dot(s))&&l){c.copy(h),n=2;break}if((g.intersectLine(h,a)||l)&&!Iv(a.distanceTo(r))){if(n++,t)break;t=!0}}if(1===n&&d.containsPoint(c.end))return p&&(p.start.copy(c.end),p.end.copy(c.end)),!0;if(2!==n)return!1;let i=d.points,r=!1,a=0;for(let s=0;s<3;s++){let e=i[s],t=i[(s+1)%3];h.start.copy(e),h.end.copy(t),h.delta(o);let n=r?u.start:u.end,l=Iv(m.distanceToPoint(e));if(Iv(m.normal.dot(o))&&l){u.copy(h),a=2;break}if((m.intersectLine(h,n)||l)&&!Iv(n.distanceTo(t))){if(a++,r)break;r=!0}}if(1===a&&this.containsPoint(u.end))return p&&(p.start.copy(u.end),p.end.copy(u.end)),!0;if(2!==a)return!1;if(c.delta(s),u.delta(o),s.dot(o)<0){let e=u.start;u.start=u.end,u.end=e}let f=c.start.dot(s),v=c.end.dot(s),y=u.start.dot(s),x=u.end.dot(s);return(f===x||y===v||v0?p.start.copy(c.start):p.start.copy(u.start),l.subVectors(c.end,u.end),l.dot(s)<0?p.end.copy(c.end):p.end.copy(u.end)),!0)}}}(),yo.prototype.distanceToPoint=function(){let e=new O;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),yo.prototype.distanceToTriangle=function(){let e=new O,t=new O,n=["a","b","c"],i=new sa,r=new sa;return function(a,s=null,o=null){let l=s||o?i:null;if(this.intersectsTriangle(a,l))return(s||o)&&(s&&l.getCenter(s),o&&l.getCenter(o)),0;let h=1/0;for(let t=0;t<3;t++){let i,r=n[t],l=a[r];this.closestPointToPoint(l,e),i=l.distanceToSquared(e),inew O)),this.satAxes=new Array(3).fill().map((()=>new O)),this.satBounds=new Array(3).fill().map((()=>new vo)),this.alignedSatBounds=new Array(3).fill().map((()=>new vo)),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};xo.prototype.update=function(){let e=this.matrix,t=this.min,n=this.max,i=this.points;for(let l=0;l<=1;l++)for(let r=0;r<=1;r++)for(let a=0;a<=1;a++){let s=i[1*l|2*r|4*a];s.x=l?n.x:t.x,s.y=r?n.y:t.y,s.z=a?n.z:t.z,s.applyMatrix4(e)}let r=this.satBounds,a=this.satAxes,s=i[0];for(let l=0;l<3;l++){let e=a[l],t=r[l],n=i[1<new sa)),n=new Array(12).fill().map((()=>new sa)),i=new O,r=new O;return function(a,s=0,o=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(o||l)&&(a.getCenter(r),this.closestPointToPoint(r,i),a.closestPointToPoint(i,r),o&&o.copy(i),l&&l.copy(r)),0;let h=s*s,c=a.min,u=a.max,d=this.points,p=1/0;for(let e=0;e<8;e++){let t=d[e];r.copy(t).clamp(c,u);let n=t.distanceToSquared(r);if(nn.far)?null:e}function Ll(e,t,n,i){let r=e.a,a=e.b,s=e.c,o=t,l=t+1,h=t+2;n&&(o=n.getX(t),l=n.getX(t+1),h=n.getX(t+2)),r.x=i.getX(o),r.y=i.getY(o),r.z=i.getZ(o),a.x=i.getX(l),a.y=i.getY(l),a.z=i.getZ(l),s.x=i.getX(h),s.y=i.getY(h),s.z=i.getZ(h)}function cH(e,t,n,i,r,a,s){let o=n.index,l=n.attributes.position;for(let h=e,c=t+e;h=0;c?(r=Ov(e),s=kv(e,o)):(r=kv(e,o),s=Ov(e));let u=cA(r,a,i,aA)?lA(r,t,n,i):null;if(u){let e=u.point[h];if(c?e<=a[s+l]:e>=a[s+l+3])return u}let d=cA(s,a,i,aA)?lA(s,t,n,i):null;return u&&d?u.distance<=d.distance?u:d:u||d||null}}var Qhe=function(){let e,t,n=[],i=new Lv((()=>new Ot));return function(...a){e=i.getPrimitive(),t=i.getPrimitive(),n.push(e,t);let s=r(...a);i.releasePrimitive(e),i.releasePrimitive(t),n.pop(),n.pop();let o=n.length;return o>0&&(t=n[o-1],e=n[o-2]),s};function r(n,i,a,s,o=null,l=0,h=0){function c(e){let t=2*e,n=vf,i=yf;for(;!nd(t,n);)t=2*(e=Ov(e));return Pm(e,i)}function u(e){let t=2*e,n=vf,i=yf;for(;!nd(t,n);)t=2*(e=kv(e,i));return Pm(e,i)+Dv(t,n)}let d=2*n,p=Nv,f=vf,m=yf;if(nd(d,f)){let t=Pm(n,m),i=Dv(d,f);return Il(n,p,e),s(t,i,!1,h,l+n,e)}{let d,g,v,y,x=Ov(n),b=kv(n,m),_=x,w=b;if(o&&(v=e,y=t,Il(_,p,v),Il(w,p,y),d=o(v),g=o(y),gr.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(h),e.b.applyMatrix4(h),e.c.applyMatrix4(h),e.needsUpdate=!0;for(let n=3*v,i=3*(y+v);nnew yo)),Rc=class{static serialize(e,t={}){if(t.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),Rc.serialize(arguments[0],{cloneBuffers:void 0===arguments[2]||arguments[2]});t=Tr({cloneBuffers:!0},t);let n,i=e.geometry,r=e._roots,a=i.getIndex();return n=t.cloneBuffers?{roots:r.map((e=>e.slice())),index:a.array.slice()}:{roots:r,index:a.array},n}static deserialize(e,t,n={}){if("boolean"==typeof n)return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),Rc.deserialize(arguments[0],arguments[1],{setIndex:void 0===arguments[2]||arguments[2]});n=Tr({setIndex:!0},n);let{index:i,roots:r}=e,a=new Rc(t,Ri(Tr({},n),{[hH]:!0}));if(a._roots=r,n.setIndex){let n=t.getIndex();if(null===n){let n=new mn(e.index,1,!1);t.setIndex(n)}else n.array!==i&&(n.array.set(i),n.needsUpdate=!0)}return a}constructor(e,t={}){if(!e.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if((t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[hH]:!1},t)).useSharedArrayBuffer&&"undefined"==typeof SharedArrayBuffer)throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,t[hH]||(this._roots=qhe(e,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new Ot))),this.geometry=e}refit(e=null){e&&Array.isArray(e)&&(e=new Set(e));let t,n,i,r,a=this.geometry,s=a.index.array,o=a.attributes.position,l=0,h=this._roots;for(let u=0,d=h.length;uu&&(u=n),id&&(d=i),rp&&(p=r)}return(r[t+0]!==a||r[t+1]!==l||r[t+2]!==c||r[t+3]!==u||r[t+4]!==d||r[t+5]!==p)&&(r[t+0]=a,r[t+1]=l,r[t+2]=c,r[t+3]=u,r[t+4]=d,r[t+5]=p,!0)}{let i=t+8,s=n[t+6],o=i+a,h=s+a,u=l,d=!1,p=!1;e?u||(d=e.has(o),p=e.has(h),u=!d&&!p):(d=!0,p=!0);let f=u||p,m=!1;(u||d)&&(m=c(i,a,u));let g=!1;f&&(g=c(s,a,u));let v=m||g;if(v)for(let e=0;e<3;e++){let n=i+e,a=s+e,o=r[n],l=r[n+3],h=r[a],c=r[a+3];r[t+e]=oc?l:c}return v}}}traverse(e,t=0){let n=this._roots[t],i=new Uint32Array(n),r=new Uint16Array(n);!function t(a,s=0){let o=2*a,l=65535===r[o+15];if(l){let t=i[a+6],h=r[o+14];e(s,l,new Float32Array(n,4*a,6),t,h)}else{let r=a+8,o=i[a+6],h=i[a+7];e(s,l,new Float32Array(n,4*a,6),h)||(t(r,s+1),t(o,s+1))}}(0)}raycast(e,t=pi){let n=this._roots,i=this.geometry,r=[],a=t.isMaterial,s=Array.isArray(t),o=i.groups,l=a?t.side:t;for(let h=0,c=n.length;h{let a=3*n;return e(t,a,a+1,a+2,i,r)}}e={boundsTraverseOrder:n,intersectsBounds:e,intersectsTriangle:t,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let r=Fu.getPrimitive(),{boundsTraverseOrder:a,intersectsBounds:s,intersectsRange:o,intersectsTriangle:l}=e;if(o&&l){let e=o;o=(t,n,a,s,o)=>!!e(t,n,a,s,o)||cH(t,n,i,l,a,s,r)}else o||(o=l?(e,t,n,a)=>cH(e,t,i,l,n,a,r):(e,t,n)=>n);let h=!1,c=0;for(let u of this._roots){if(Bv(u),h=Qhe(0,i,s,o,a,c),Vb(),h)break;c+=u.byteLength}return Fu.releasePrimitive(r),h}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:r}=n,a=this.geometry.index,s=this.geometry.attributes.position,o=e.geometry.index,l=e.geometry.attributes.position;Uv.copy(t).invert();let h=Fu.getPrimitive(),c=Fu.getPrimitive();if(r){let e=function(e,n,i,u,d,p,f,m){for(let g=i,v=i+u;gfH.intersectsBox(e),intersectsRange:(t,n,r,a,s,o)=>(dH.copy(o),dH.applyMatrix4(Uv),e.shapecast({intersectsBounds:e=>dH.intersectsBox(e),intersectsRange:(e,r,o,l,h)=>i(t,n,e,r,a,s,l,h)}))});return Fu.releasePrimitive(h),Fu.releasePrimitive(c),u}intersectsBox(e,t){return Im.set(e.min,e.max,t),Im.needsUpdate=!0,this.shapecast({intersectsBounds:e=>Im.intersectsBox(e),intersectsTriangle:e=>Im.intersectsTriangle(e)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},r=0,a=1/0){e.boundingBox||e.computeBoundingBox(),Im.set(e.boundingBox.min,e.boundingBox.max,t),Im.needsUpdate=!0;let s=this.geometry,o=s.attributes.position,l=s.index,h=e.attributes.position,c=e.index,u=Fu.getPrimitive(),d=Fu.getPrimitive(),p=uA,f=yct,m=null,g=null;i&&(m=xct,g=bct);let v=1/0,y=null,x=null;return Uv.copy(t).invert(),zb.matrix.copy(Uv),this.shapecast({boundsTraverseOrder:e=>Im.distanceToBox(e),intersectsBounds:(e,t,n)=>n{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:e=>zb.distanceToBox(e),intersectsBounds:(e,t,n)=>n{for(let s=3*e,b=3*(e+a);s(Gb.copy(e).clamp(t.min,t.max),Gb.distanceToSquared(e)),intersectsBounds:(e,t,n)=>n{t.closestPointToPoint(e,Gb);let i=e.distanceToSquared(Gb);return i{Il(0,new Float32Array(t),tde),e.union(tde)})),e}},pH=new ho,nde=new et,Ect=xt.prototype.raycast;function mH(e,t){if(this.geometry.boundsTree){if(void 0===this.material)return;nde.copy(this.matrixWorld).invert(),pH.copy(e.ray).applyMatrix4(nde);let n=this.geometry.boundsTree;if(!0===e.firstHitOnly){let i=lH(n.raycastFirst(pH,this.material),this,e);i&&t.push(i)}else{let i=n.raycast(pH,this.material);for(let n=0,r=i.length;nn.far?null:{distance:h,point:vA.clone(),object:e}}function yA(e,t,n,i,r,a,s,o,l,h,c,u){xf.fromBufferAttribute(r,h),bf.fromBufferAttribute(r,c),Ef.fromBufferAttribute(r,u);let d=e.morphTargetInfluences;if(a&&d){hA.set(0,0,0),dA.set(0,0,0),fA.set(0,0,0);for(let e=0,t=a.length;ei.far)return;r.push({distance:o,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,object:a})}}ii.prototype.raycast=function(e,t){let n=this.geometry,i=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),xA.copy(n.boundingSphere),xA.applyMatrix4(i),xA.radius+=r,!1===e.ray.intersectsSphere(xA))return;let s=r*r,o=n.index,l=n.attributes.position,h=t.length;if(null!==o)for(let c=Math.max(0,a.start),u=Math.min(o.count,a.start+a.count);c=1)return}else for(let c=Math.max(0,a.start),u=Math.min(l.count,a.start+a.count);c=1)return};var EH=class{constructor(){this.id=0,this.object=null,this.z=0,this.renderOrder=0}},qb=class{constructor(){this.id=0,this.v1=new _f,this.v2=new _f,this.v3=new _f,this.normalModel=new O,this.vertexNormalsModel=[new O,new O,new O],this.vertexNormalsLength=0,this.color=new ct,this.material=null,this.uvs=[new be,new be,new be],this.z=0,this.renderOrder=0}},_f=class{constructor(){this.position=new O,this.positionWorld=new O,this.positionScreen=new gr,this.visible=!0}copy(e){this.positionWorld.copy(e.positionWorld),this.positionScreen.copy(e.positionScreen)}},Wb=class{constructor(){this.id=0,this.v1=new _f,this.v2=new _f,this.vertexColors=[new ct,new ct],this.material=null,this.z=0,this.renderOrder=0}},jb=class{constructor(){this.id=0,this.object=null,this.x=0,this.y=0,this.z=0,this.rotation=0,this.scale=new be,this.material=null,this.renderOrder=0}},EA=class{constructor(){let e,t,n,i,r,a,s,o,l,h,c,u=0,d=0,p=0,f=0,m=0,g={objects:[],lights:[],elements:[]},v=new O,y=new gr,x=new Ot(new O(-1,-1,-1),new O(1,1,1)),b=new Ot,_=new Array(3),w=new et,S=new et,M=new et,T=new ya,E=[],A=[],C=[],P=[],R=[],L=new function(){let e=[],t=[],l=[],h=null,u=new Ln;function m(e){let t=e.position,n=e.positionWorld,i=e.positionScreen;n.copy(t).applyMatrix4(c),i.copy(n).applyMatrix4(S);let r=1/i.w;i.x*=r,i.y*=r,i.z*=r,e.visible=i.x>=-1&&i.x<=1&&i.y>=-1&&i.y<=1&&i.z>=-1&&i.z<=1}function w(e,t,n){return!0===e.visible||!0===t.visible||!0===n.visible||(_[0]=e.positionScreen,_[1]=t.positionScreen,_[2]=n.positionScreen,x.intersectsBox(b.setFromPoints(_)))}function T(e,t,n){return(n.positionScreen.x-e.positionScreen.x)*(t.positionScreen.y-e.positionScreen.y)-(n.positionScreen.y-e.positionScreen.y)*(t.positionScreen.x-e.positionScreen.x)<0}return{setObject:function(n){h=n,u.getNormalMatrix(h.matrixWorld),e.length=0,t.length=0,l.length=0},projectVertex:m,checkTriangleVisibility:w,checkBackfaceCulling:T,pushVertex:function(e,t,r){n=function(){if(i===d){let e=new _f;return A.push(e),d++,i++,e}return A[i++]}(),n.position.set(e,t,r),m(n)},pushNormal:function(t,n,i){e.push(t,n,i)},pushColor:function(e,n,i){t.push(e,n,i)},pushUv:function(e,t){l.push(e,t)},pushLine:function(e,n){let i=A[e],r=A[n];i.positionScreen.copy(i.position).applyMatrix4(M),r.positionScreen.copy(r.position).applyMatrix4(M),!0===function(e,t){let n=0,i=1,r=e.z+e.w,a=t.z+t.w,s=-e.z+e.w,o=-t.z+t.w;return r>=0&&a>=0&&s>=0&&o>=0||!(r<0&&a<0||s<0&&o<0)&&(r<0?n=Math.max(n,r/(r-a)):a<0&&(i=Math.min(i,r/(r-a))),s<0?n=Math.max(n,s/(s-o)):o<0&&(i=Math.min(i,s/(s-o))),!(i=-1&&e.z<=1&&(l=function(){if(h===m){let e=new jb;return R.push(e),m++,h++,e}return R[h++]}(),l.id=t.id,l.x=e.x*i,l.y=e.y*i,l.z=e.z,l.renderOrder=t.renderOrder,l.object=t,l.rotation=t.rotation,l.scale.x=t.scale.x*Math.abs(l.x-(e.x+n.projectionMatrix.elements[0])/(e.w+n.projectionMatrix.elements[12])),l.scale.y=t.scale.y*Math.abs(l.y-(e.y+n.projectionMatrix.elements[5])/(e.w+n.projectionMatrix.elements[13])),l.material=t.material,g.elements.push(l))}function N(e,t){return e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id!==t.id?e.id-t.id:0}this.projectScene=function(e,n,r,s){a=0,o=0,h=0,g.elements.length=0,!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===n.parent&&!0===n.matrixWorldAutoUpdate&&n.updateMatrixWorld(),w.copy(n.matrixWorldInverse),S.multiplyMatrices(n.projectionMatrix,w),T.setFromProjectionMatrix(S),t=0,g.objects.length=0,g.lights.length=0,I(e),!0===r&&g.objects.sort(N);let l=g.objects;for(let t=0,a=l.length;t0)for(let r=0;r0)for(let r=0;r0;)k.removeChild(k.childNodes[0])}function F(e){return null!==g?e.toFixed(g):e}function U(e,t,n){let i=t.scale.x*a,r=t.scale.y*s;n.isPointsMaterial&&(i*=n.size,r*=n.size);let o="M"+F(e.x-.5*i)+","+F(e.y-.5*r)+"h"+F(i)+"v"+F(r)+"h"+F(-i)+"z",l="";(n.isSpriteMaterial||n.isPointsMaterial)&&(l="fill:"+n.color.getStyle()+";fill-opacity:"+n.opacity),V(l,o)}function B(e,t,n){let i="M"+F(e.positionScreen.x)+","+F(e.positionScreen.y)+"L"+F(t.positionScreen.x)+","+F(t.positionScreen.y);if(n.isLineBasicMaterial){let e="fill:none;stroke:"+n.color.getStyle()+";stroke-opacity:"+n.opacity+";stroke-width:"+n.linewidth+";stroke-linecap:"+n.linecap;n.isLineDashedMaterial&&(e=e+";stroke-dasharray:"+n.dashSize+","+n.gapSize),V(e,i)}}function z(e,t,i,r,a){y.info.render.vertices+=3,y.info.render.faces++;let s="M"+F(e.positionScreen.x)+","+F(e.positionScreen.y)+"L"+F(t.positionScreen.x)+","+F(t.positionScreen.y)+"L"+F(i.positionScreen.x)+","+F(i.positionScreen.y)+"z",o="";a.isMeshBasicMaterial?(_.copy(a.color),a.vertexColors&&_.multiply(r.color)):a.isMeshLambertMaterial||a.isMeshPhongMaterial||a.isMeshStandardMaterial?(w.copy(a.color),a.vertexColors&&w.multiply(r.color),_.copy(S),A.copy(e.positionWorld).add(t.positionWorld).add(i.positionWorld).divideScalar(3),function(e,t,n,i){for(let r=0,a=e.length;r1||l.positionScreen.z<-1||l.positionScreen.z>1||h.positionScreen.z<-1||h.positionScreen.z>1)continue;o.positionScreen.x*=a,o.positionScreen.y*=-s,l.positionScreen.x*=a,l.positionScreen.y*=-s,h.positionScreen.x*=a,h.positionScreen.y*=-s,this.overdraw>0&&(H(o.positionScreen,l.positionScreen,this.overdraw),H(l.positionScreen,h.positionScreen,this.overdraw),H(h.positionScreen,o.positionScreen,this.overdraw)),b.setFromPoints([o.positionScreen,l.positionScreen,h.positionScreen]),!0===x.intersectsBox(b)&&z(o,l,h,n,i)}}j(),i.traverseVisible((function(e){if(e.isSVGObject){if(E.setFromMatrixPosition(e.matrixWorld),E.applyMatrix4(L),E.z<-1||E.z>1)return;let t=E.x*a,n=-E.y*s,i=e.node;i.setAttribute("transform",`translate(${t}, ${n}) rotate(${e.rotation.z})`),k.appendChild(i)}}))}}};function Tct(e){let t={};return t.r=(e>>16&255)/255,t.g=(e>>8&255)/255,t.b=(255&e)/255,t}var ode="\n #if defined(USE_BC_OUTLINE)\n // Restore barycentric coordinates\n int barycentricX = int(barycentric) & 0x1;\n int barycentricY = int(barycentric) & 0x2;\n int barycentricZ = int(barycentric) & 0x4;\n vBarycentric = vec3(float(barycentricX), float(barycentricY), float(barycentricZ));\n #endif\n",lde="\n #if defined(USE_BC_OUTLINE)\n vec3 finWireFrameColor = outLineColor;\n vec3 _tempColor = gl_FragColor.rgb;\n\n gl_FragColor.rgb = mix(finWireFrameColor, _tempColor, edgeFactor3());\n #endif\n",cde="\n #if defined(USE_BC_OUTLINE)\n varying vec3 vBarycentric;\n uniform vec3 outLineColor;\n\n float edgeFactor3(){\n vec3 d = fwidth(vBarycentric);\n float minValue = 0.0000001;\n // make sure d is not 0\n d = clamp(d, vec3(minValue), vec3(10.0));\n vec3 a3 = smoothstep(vec3(0.0), d*0.8, vBarycentric);\n return min(min(a3.x, a3.y), a3.z);\n }\n #endif\n",ude="\n #ifdef USE_BC_OUTLINE \n attribute float barycentric;\n varying vec3 vBarycentric;\n #endif\n",hde="\n#define STANDARD\n\nvarying vec3 vViewPosition;\n\n#ifdef USE_TRANSMISSION\n\n\tvarying vec3 vWorldPosition;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n #include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\t#include \n\n#ifdef USE_TRANSMISSION\n\n\tvWorldPosition = worldPosition.xyz;\n\n#endif\n}\n",dde="\n#define STANDARD\n\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n\n#ifdef IOR\n\tuniform float ior;\n#endif\n\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\n\nvarying vec3 vViewPosition;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// modulation\n\t#include \n\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\n\t#include \n\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\n\t#ifdef USE_SHEEN\n\n\t\t// Sheen energy compensation approximation calculation can be found at the end of\n\t\t// https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\n\t#endif\n\n\t#ifdef USE_CLEARCOAT\n\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n #include \n}\n";$n.outline_bc_vertex=ode,$n.outline_bc_fragment=lde,$n.outline_bc_pars_fragment=cde,$n.outline_bc_pars_vertex=ude,$n.gemini_standard_vertex=hde,$n.gemini_standard_fragment=dde;var _A=class{constructor(e){this.isCanceled=!1;let t=new Promise(((e,t)=>{this.cancelReject=t}));this.promise=Promise.race([t,e])}cancel(){this.cancelReject&&this.cancelReject({type:"cancel"})}},fde={enableSpinner:!0,containerId:"myCanvas",units:"meters"},Sct=ji(mde(),1),se=Sct;se.setLevel("warn");var gde=e=>{try{se.setLevel(e)}catch(e){se.setLevel("error"),se.error(e)}},_H=class{static isTouchScreenDevice(){return"ontouchstart"in window}static printDeviceInfo(){let e=navigator.userAgent,t=/(?:Android)/.test(e),n=/(?:Firefox)/.test(e),i=/(?:Chrome|CriOS)/.test(e),r=/(?:iPad|PlayBook)/.test(e)||t&&!/(?:Mobile)/.test(e)||n&&/(?:Tablet)/.test(e),a=/(?:iPhone)/.test(e)&&!r,s=!a&&!t,o=_H.isTouchScreenDevice();t&&se.debug("[DI] is android"),n&&se.debug("[DI] is fireFox"),i&&se.debug("[DI] is chrome"),r&&se.debug("[DI] is tablet"),a&&se.debug("[DI] is iPhone"),s&&se.debug("[DI] is PC"),o&&se.debug("[DI] is touch device")}static creatReactNativeCanvas(e){let t=e.drawingBufferWidth||e.width||0,n=e.drawingBufferHeight||e.height||0;return{style:{},width:t,height:n,clientWidth:Math.ceil(t/(window.devicePixelRatio||1)),clientHeight:Math.ceil(n/(window.devicePixelRatio||1)),addEventListener:()=>{},removeEventListener:()=>{}}}},Dn=_H;Dn.isMobile=/mobile/i.test(navigator.userAgent),Dn.isBrowser="undefined"!=typeof document,Dn.isNode="undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process);var wA=class{static isFullScreen(){return!(!document.fullscreenElement&&!document.mozFullScreenElement)}static fullScreen(e=document.documentElement){(e.requestFullscreen||e.mozRequestFullScreen||e.webkitRequestFullscreen||e.msRequestFullscreen).call(e)}static exitFullscreen(){(document.exitFullscreen||document.mozCancelFullscreen||document.webkitExitFullscreen||document.msExitFullscreen).call(document)}static joinStrings(...e){return e.join("")}static numberToString(e){let t=2;return Math.abs(e)<1e-6?t=2:Math.abs(e)<1e-5?t=7:Math.abs(e)<1e-4?t=6:Math.abs(e)<.001?t=5:Math.abs(e)<.01?t=4:Math.abs(e)<.1&&(t=3),e.toFixed(t)}static hexToBase64(e){return btoa((e.match(/\w{2}/g)||[]).map((function(e){return String.fromCharCode(parseInt(e,16))})).join(""))}static vectorToString(e){return e instanceof O?`(${this.numberToString(e.x)}, ${this.numberToString(e.y)}, ${this.numberToString(e.z)})`:`(${this.numberToString(e.x)}, ${this.numberToString(e.y)})`}static arrayToVector2(e){return e?e instanceof be?e:Array.isArray(e)&&e.length>=2?new be(e[0],e[1]):void 0:e}static arrayToVector3(e){return e?e instanceof O?e:Array.isArray(e)&&e.length>=2?new O(e[0],e[1],e.length>2?e[2]:0):void 0:e}static arrayToEuler(e){return e?e instanceof Xn?e:Array.isArray(e)&&e.length>=3?new Xn(e[0],e[1],e[2]):void 0:e}static arrayOrObjectToVector3(e){if(!e)return e;if(e instanceof O)return e;if(e instanceof be)return new O(e.x,e.y,0);if(Array.isArray(e)&&e.length>=2)return new O(e[0],e[1],e[2]||0);let t=e;return null!=t.x&&null!=t.y?new O(t.x,t.y,t.z||0):void 0}static isVectorValid(e){let t=e&&!isNaN(e.x)&&!isNaN(e.y)&&isFinite(e.x)&&isFinite(e.y);return t&&e instanceof O&&(t=!isNaN(e.z)&&isFinite(e.z)),t}static isBoxValid(e){return e&&!e.isEmpty()&&this.isVectorValid(e.min)&&this.isVectorValid(e.max)}static isMatrixValid(e){let t=e&&e.elements;if(!t||t.length<16)return!1;for(let n=0;n<16;++n){let e=t[n];if(Number.isNaN(e))return!1}return!0}static guid(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{let t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}static expandBoxByScale(e,t){let n=new O;e.getCenter(n);let i=(e.max.x-e.min.x)*t,r=(e.max.y-e.min.y)*t,a=(e.max.z-e.min.z)*t,s=new O(n.x-i/2,n.y-r/2,n.z-a/2),o=new O(n.x+i/2,n.y+r/2,n.z+a/2);e.set(s,o)}static expandBoxByMinSize(e,t){let n=new O;e.getCenter(n);let i=e.max.x-e.min.x,r=e.max.y-e.min.y,a=e.max.z-e.min.z;i{n.onload=function(){e(n)}}))}static renderingContextToImage(e,t,n="image/png",i=.8){if(t){let r=Math.max(t.min.x,0),a=Math.max(t.min.y,0),s=Math.max(t.max.x-r,0),o=Math.max(t.max.y-a,0),l=e.getImageData(r,a,s,o),h=document.createElement("canvas");return h.width=s,h.height=o,h.getContext("2d").putImageData(l,0,0),h.toDataURL(n,i)}return e.canvas.toDataURL(n,i)}static printMemory(e){if(Dn.isBrowser){let t=performance.memory;if(!t)return void se.warn("[CommonUtils] performance.memory is not available in this browser");let n=(t.jsHeapSizeLimit/1048576).toFixed(2),i=(t.totalJSHeapSize/1048576).toFixed(2),r=(t.usedJSHeapSize/1048576).toFixed(2);se.info(`[CommonUtils] ${e}. jsHeapSizeLimit: ${n}M , totalJSHeapSize: ${i}M , usedJSHeapSize: ${r}M `)}}static printGpuInfo(e){if(Dn.isBrowser){let t=e.getExtension("webgl_debug_renderer_info"),n=e.getParameter(t.UNMASKED_RENDERER_WEBGL);se.info("[CommonUtils] gpu:",n)}}static sleep(e){return ft(this,null,(function*(){let t;return new Promise((n=>{t=setTimeout((()=>{n("")}),e)})).then((()=>{clearTimeout(t)}))}))}static twinkle(e,t=500){return ft(this,null,(function*(){let n=this.twinklingObjectIds;n[e.id]||(n[e.id]=!0,e.visible=!e.visible,yield this.sleep(t),e.visible=!e.visible,yield this.sleep(t),e.visible=!e.visible,yield this.sleep(t),e.visible=!e.visible,yield this.sleep(t),e.visible=!e.visible,yield this.sleep(t),e.visible=!e.visible,delete n[e.id])}))}static getUpdateProgressFunc(e){return t=>{e&&e(new ProgressEvent("",{loaded:t,total:100}))}}static getUpdateProgressFuncAsync(e){let t=Date.now();return n=>ft(this,null,(function*(){if(e){e(new ProgressEvent("",{loaded:n,total:100}));let i=500,r=Date.now();r-t>i&&(yield wA.sleep(0),t=r)}}))}static getUpdateProgressFuncForLoop(e,t){let n=Math.round(Math.pow(e,.5)),i=Date.now();return r=>ft(this,null,(function*(){if(t&&(r%n==0||r===e-1)){t(new ProgressEvent("",{loaded:r+1,total:e}));let n=500,a=Date.now();(a-i>n||r===e-1)&&(yield wA.sleep(0),i=a)}}))}static getUpdateSubProgressFunc(e,t,n){let i=!1;return r=>{let a=100*r.loaded/r.total;a=a*(t-e)/100+e,a>t&&(i||(se.warn("[Progress] Invalid ProgressEvent:",r),i=!0),a=t),n&&n(new ProgressEvent(r.type,{loaded:a,total:100}))}}},Mt=wA;Mt.twinklingObjectIds={};var SA=(e,t,n)=>{let{default:i,active:r}=t;n?(e.remove(i),e.add(r||i)):(r&&e.remove(r),e.add(i))},Cn=class{static color2rgba(e){let t,n=[0,0,0,1];if(t=/^(\w+)\(([^)]*)\)/.exec(e)){let i,r=t[1],a=t[2];switch(r){case"rgb":case"rgba":(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))&&(n=[Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,Number(i[4]||1)]),(i=/^\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))&&(n=[Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,Number(i[4]||1)]);break;case"hsl":case"hsla":(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)%\s*,\s*(\d*\.?\d+)%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))&&(n=[parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,Number(i[4]||1)]);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(t=/^#([A-Fa-f\d]+)$/.exec(e)){let i=t[1],r=i.length;if(3===r)n=[parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,1];else if(6===r){let e=parseInt(i,16);n=[(e>>16&255)/255,(e>>8&255)/255,(255&e)/255,1]}else console.warn("THREE.Color: Invalid hex color "+e)}return n}static rgba2Color(e){return`rgba(${this.to255(e[0])},${this.to255(e[1])},${this.to255(e[2])},${null!=e[3]?e[3]:1})`}static colorStr2Rgba(e){let t=e.replace("rgba(","");t=t.replace(")","");let n=t.split(","),i=[];return i.push(this.to1(parseInt(n[0]))),i.push(this.to1(parseInt(n[1]))),i.push(this.to1(parseInt(n[2]))),null!=n[3]&&i.push(parseFloat(n[3])),i}static rgb2Hex(e){return(this.to255(e[0])<<16)+(this.to255(e[1])<<8)+this.to255(e[2])}static to255(e){let t=Math.max(e,0);return t=Math.min(e,1),255*t}static to1(e){let t=Math.max(e,0);return t=Math.min(e,255),t/255}},cn=class{static getScreenPointByEvent(e,t){let n=new be,{left:i,top:r}=t.getBoundingClientRect();return n.x=e.clientX-i,n.y=e.clientY-r,n}static getScreenPointByTouchEvent(e,t){let n=new be,{left:i,top:r}=t.getBoundingClientRect();return n.x=e.touches[0].clientX-i,n.y=e.touches[0].clientY-r,n}static worldPosition2ScreenPoint(e,t,n){let{clientWidth:i,clientHeight:r}=n,a=e.clone(),s=new be;return a.project(t),s.x=Math.round((.5+a.x/2)*i),s.y=Math.round((.5-a.y/2)*r),s}static screenPoint2worldPosition(e,t,n){let i=cn.screenPoint2NdcPoint(e,t,n);return new O(i.x,i.y,1).unproject(t)}static screenPoint2NdcPoint(e,t,n){let{clientWidth:i,clientHeight:r}=n,a=new be;return a.x=e.x/i*2-1,a.y=-e.y/r*2+1,a}static worldCoordinate2NormalizedScreenCoordinate(e,t,n){let i=new O;e instanceof be?i.set(e.x,e.y,0):i.set(e.x,e.y,e.z);let r=cn.worldPosition2ScreenPoint(i,t,n);return r.x/=n.clientWidth,r.y/=n.clientHeight,r}},zv=class extends an{constructor(e=document.createElement("div")){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.center=new be(.5,.5),this.addEventListener("removed",(function(){this.traverse((function(e){e.element instanceof Element&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this}},Vv=new O,vde=new et,yde=new et,xde=new O,bde=new O,Nu=class{constructor(e={}){let t,n,i,r,a=this,s={objects:new WeakMap},o=void 0!==e.element?e.element:document.createElement("div");function l(e,t,n){if(e.isCSS2DObject){Vv.setFromMatrixPosition(e.matrixWorld),Vv.applyMatrix4(yde);let l=!0===e.visible&&Vv.z>=-1&&Vv.z<=1&&!0===e.layers.test(n.layers);if(e.element.style.display=!0===l?"":"none",!0===l){e.onBeforeRender(a,t,n);let s=e.element;s.style.transform="translate("+-100*e.center.x+"%,"+-100*e.center.y+"%)translate("+(Vv.x*i+i)+"px,"+(-Vv.y*r+r)+"px)",s.parentNode!==o&&o.appendChild(s),e.onAfterRender(a,t,n)}let c={distanceToCameraSquared:h(n,e)};s.objects.set(e,c)}for(let i=0,r=e.children.length;ie.toFixed(t===Ede["Precision from file"]?2:t),si=!1,YLt=!1,Uu=10,vs=11,ei=12,qv="gemini-viewer-iconfont",$Lt="keydown",ZLt="keyup",wf="mousemove",TH="mouseup",wH="mousedown",KLt="Escape",JLt="Enter",QLt="axis-section-plane",eDt="axis-section-plane-control",tDt="section-plane",nDt="section-plane-control",rDt="section-box",SH="plane-section-boxface",_de=-1e3,MA=10,Wv=(e=>(e.ObjectsBoxSection="ObjectsBoxSection",e.PickPlaneSection="PickPlaneSection",e.AxisPlaneSection="AxisPlaneSection",e))(Wv||{}),MH=(e=>(e.Default="Default",e.BoxSelection="BoxSelection",e.PickMarkup="PickMarkup",e))(MH||{}),Tde=new O,wde=new O,Sde=new O,Xb=new O,rd=new O,Mde=new Zr;function Mct(e,t,n,i,r){let a,s,o,l,h,c,u=[],d={},p=Math.pow(10,4),f=0;for(h=0,c=e.length;hy))&&(m=r[d.index1],g=r[d.index2],(!b&&m>65535||g>65535)&&(b=!0),v.push(m),v.push(g));return b?new Uint32Array(v):new Uint16Array(v)}static buildBarycentrics(e){let t=e.getAttribute("position");if(!t||0===t.count)return console.warn(" no positions in geometry !"),!1;let n=Math.pow(10,4),i=Math.cos(20*An.DEG2RAD),r=e.getIndex(),a=r?r.count:t.count,s=[0,0,0],o=new Array(3),l=RH.length,h=[];for(let S=0;S0))break;g=new Set;for(let e of m[v])g.add(e.a),g.add(e.b),g.add(e.c);m.splice(v,1),v=0}}let y=new Set;for(let S=0;S{y.has(e)?se.warn(`${e} is already in positionIndexSet !`):y.add(e)}));let x=(e,t)=>{let n=!1,i=d[e];if(!i)return console.warn(`${e} is not in positionIndexHash !`),n;let r=d[t];if(!r)return console.warn(`${t} is not in positionIndexHash !`),n;let a=`${i}_${r}`;if(p[a])n=p[a].outer;else{let e=`${r}_${i}`;p[e]&&(n=p[e].outer)}return n},b=(e,t,n)=>{let i=[];return i.push(x(e,t)),i.push(x(t,n)),i.push(x(n,e)),i.filter((e=>!0===e)).length>=2},_=(e,t)=>{if(!c[e])return se.warn(`${e} position isn't used !`),!0;let n=c[e];for(let r of n){let n=x(e,r),i=h[r];if(!i.inited)continue;let a=Act(t,i.point);if(n&&!a||!n&&a)return!1}let i=u[e];for(let r of i){let n=t,i=h[r.b],a=h[r.c];if(r.b===e?i=h[r.a]:r.c===e&&(a=h[r.a]),b(r.a,r.b,r.c)&&(i.inited&&n.equals(i.point)||a.inited&&n.equals(a.point)))return!1;if(i.inited&&a.inited&&(rd.addVectors(n,i.point),rd.add(a.point),rd.x+rd.y+rd.z<2))return!1}return!0},w=!1;for(let S=0;S=0;){t=e[n];let i=h[t].inited?h[t].barycentricIndex+1:0;for(;ie(t)))}hasEventListener(e){return!!this.map.get(e)}removeEventListener(e,t){if(!e)return void this.map.clear();if(!t)return void this.map.delete(e);let n=this.map.get(e);n&&n.delete(t)}},xa=class{parse(e,t={}){if(t=Object.assign({decodeSpeed:5,encodeSpeed:5,encoderMethod:xa.MESH_EDGEBREAKER_ENCODING,quantization:[16,8,8,8,8],exportUvs:!0,exportNormals:!0,exportColor:!1},t),void 0===DracoEncoderModule)throw new Error("THREE.DRACOExporter: required the draco_encoder to work.");let n,i,r=e.geometry,a=DracoEncoderModule(),s=new a.Encoder;if(!0===e.isMesh){n=new a.MeshBuilder,i=new a.Mesh;let e=r.getAttribute("position");n.AddFloatAttributeToMesh(i,a.POSITION,e.count,e.itemSize,e.array);let s=r.getIndex();if(null!==s)n.AddFacesToMesh(i,s.count/3,s.array);else{let t=new(e.count>65535?Uint32Array:Uint16Array)(e.count);for(let e=0;e4?n=e.array[r*e.itemSize+t]:(0===t?n=e.getX(r):1===t?n=e.getY(r):2===t?n=e.getZ(r):3===t&&(n=e.getW(r)),!0===e.normalized&&(n=An.normalize(n,e.array))),i.min[t]=Math.min(i.min[t],n),i.max[t]=Math.max(i.max[t],n)}return i}function Ode(e){return 4*Math.ceil(e/4)}function PH(e,t=0){let n=Ode(e.byteLength);if(n!==e.byteLength){let i=new Uint8Array(n);if(i.set(new Uint8Array(e)),0!==t)for(let r=e.byteLength;re.toBlob(n,t)));let n;return"image/jpeg"===t?n=.92:"image/webp"===t&&(n=.8),e.convertToBlob({type:t,quality:n})}var IH=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}write(e,t){return ft(this,arguments,(function*(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),yield Promise.all(this.pending);let i=this,r=i.buffers,a=i.json;n=i.options;let s=i.extensionsUsed,o=i.extensionsRequired,l=new Blob(r,{type:"application/octet-stream"}),h=Object.keys(s),c=Object.keys(o);if(h.length>0&&(a.extensionsUsed=h),c.length>0&&(a.extensionsRequired=c),a.buffers&&a.buffers.length>0&&(a.buffers[0].byteLength=l.size),!0===n.binary){let e=new FileReader;e.readAsArrayBuffer(l),e.onloadend=function(){let n=PH(e.result),i=new DataView(new ArrayBuffer(Ide));i.setUint32(0,n.byteLength,!0),i.setUint32(4,Dct,!0);let r=PH(Oct(JSON.stringify(a)),32),s=new DataView(new ArrayBuffer(Ide));s.setUint32(0,r.byteLength,!0),s.setUint32(4,Lct,!0);let o=new ArrayBuffer(Pde),l=new DataView(o);l.setUint32(0,Pct,!0),l.setUint32(4,Ict,!0);let h=Pde+s.byteLength+r.byteLength+i.byteLength+n.byteLength;l.setUint32(8,h,!0);let c=new Blob([o,s,r,i,n],{type:"application/octet-stream"}),u=new FileReader;u.readAsArrayBuffer(c),u.onloadend=function(){t(u.result)}}}else if(a.buffers&&a.buffers.length>0){let e=new FileReader;e.readAsDataURL(l),e.onloadend=function(){let n=e.result;a.buffers[0].uri=n,t(a)}}else t(a)}))}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;let n=this.options,i=this.extensionsUsed;try{let r=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&r.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(let e in r.gltfExtensions)t.extensions[e]=r.gltfExtensions[e],i[e]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(t.extras=r)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let t=new O;for(let n=0,i=e.count;n5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),i=new O;for(let r=0,a=n.count;r4?i=e.array[u*e.itemSize+n]:(0===n?i=e.getX(u):1===n?i=e.getY(u):2===n?i=e.getZ(u):3===n&&(i=e.getW(u)),!0===e.normalized&&(i=An.normalize(i,e.array))),t===Hr.FLOAT?l.setFloat32(h,i,!0):t===Hr.INT?l.setInt32(h,i,!0):t===Hr.UNSIGNED_INT?l.setUint32(h,i,!0):t===Hr.SHORT?l.setInt16(h,i,!0):t===Hr.UNSIGNED_SHORT?l.setUint16(h,i,!0):t===Hr.BYTE?l.setInt8(h,i):t===Hr.UNSIGNED_BYTE&&l.setUint8(h,i),h+=a}let c={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:o};return void 0!==r&&(c.target=r),r===Hr.ARRAY_BUFFER&&(c.byteStride=e.itemSize*a),this.byteOffset+=o,s.bufferViews.push(c),{id:s.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise((function(i){let r=new FileReader;r.readAsArrayBuffer(e),r.onloadend=function(){let e=PH(r.result),a={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,i(n.bufferViews.push(a)-1)}}))}processAccessor(e,t,n,i){let r,a=this.json;if(e.array.constructor===Float32Array)r=Hr.FLOAT;else if(e.array.constructor===Int32Array)r=Hr.INT;else if(e.array.constructor===Uint32Array)r=Hr.UNSIGNED_INT;else if(e.array.constructor===Int16Array)r=Hr.SHORT;else if(e.array.constructor===Uint16Array)r=Hr.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)r=Hr.BYTE;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);r=Hr.UNSIGNED_BYTE}if(void 0===n&&(n=0),void 0===i&&(i=e.count),0===i)return null;let s,o=Fct(e,n,i);void 0!==t&&(s=e===t.index?Hr.ELEMENT_ARRAY_BUFFER:Hr.ARRAY_BUFFER);let l=this.processBufferView(e,r,n,i,s),h={bufferView:l.id,byteOffset:l.byteOffset,componentType:r,count:i,max:o.max,min:o.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(h.normalized=!0),a.accessors||(a.accessors=[]),a.accessors.push(h)-1}processImage(e,t,n,i="image/png"){if(null!==e){let r=this,a=r.cache,s=r.json,o=r.options,l=r.pending;a.images.has(e)||a.images.set(e,{});let h=a.images.get(e),c=i+":flipY/"+n.toString();if(void 0!==h[c])return h[c];s.images||(s.images=[]);let u={mimeType:i},d=Lde();d.width=Math.min(e.width,o.maxTextureSize),d.height=Math.min(e.height,o.maxTextureSize);let p=d.getContext("2d");if(!0===n&&(p.translate(0,d.height),p.scale(1,-1)),void 0!==e.data){t!==ea&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>o.maxTextureSize||e.height>o.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;tr.processBufferViewImage(e))).then((e=>{u.bufferView=e}))):void 0!==d.toDataURL?u.uri=d.toDataURL(i):l.push(Dde(d,i).then((e=>(new FileReader).readAsDataURL(e))).then((e=>{u.uri=e})));let f=s.images.push(u)-1;return h[c]=f,f}throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let n={magFilter:$o[e.magFilter],minFilter:$o[e.minFilter],wrapS:$o[e.wrapS],wrapT:$o[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){let t=this.options,n=this.cache,i=this.json;if(n.textures.has(e))return n.textures.get(e);i.textures||(i.textures=[]),e instanceof Mu&&(e=PA(e,t.maxTextureSize));let r=e.userData.mimeType;"image/webp"===r&&(r="image/png");let a={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,r)};e.name&&(a.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,a)}));let s=i.textures.push(a)-1;return n.textures.set(e,s),s}processMaterial(e){let t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);let i={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let r=e.color.toArray().concat([e.opacity]);if(Yb(r,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=r),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){let t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),n={index:this.processTexture(t),channel:t.channel};this.applyTextureTransform(n,t),i.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){let t={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),i.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(i.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),i.emissiveTexture=t}}if(e.normalMap){let t={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),i.normalTexture=t}if(e.aoMap){let t={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),i.occlusionTexture=t}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===Sr&&(i.doubleSided=!0),""!==e.name&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,i)}));let a=n.materials.push(i)-1;return t.materials.set(e,a),a}processMesh(e){let t=this.cache,n=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let y=0,x=e.material.length;y0){let n=[],i=[],r={};if(void 0!==e.morphTargetDictionary)for(let t in e.morphTargetDictionary)r[e.morphTargetDictionary[t]]=t;for(let a=0;a0&&(o.extras={},o.extras.targetNames=i)}let f=Array.isArray(e.material);if(f&&0===s.groups.length)return null;let m=f?e.material:[e.material],g=f?s.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let y=0,x=g.length;y0&&(e.targets=c),null!==s.index){let n=this.getUID(s.index);(void 0!==g[y].start||void 0!==g[y].count)&&(n+=":"+g[y].start+":"+g[y].count),t.attributes.has(n)?e.indices=t.attributes.get(n):(e.indices=this.processAccessor(s.index,s,g[y].start,g[y].count),t.attributes.set(n,e.indices)),null===e.indices&&delete e.indices}let n=this.processMaterial(m[g[y].materialIndex]);null!==n&&(e.material=n),h.push(e)}o.primitives=h,n.meshes||(n.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,o)}));let v=n.meshes.push(o)-1;return t.meshes.set(r,v),v}detectMeshQuantization(e,t){if(this.extensionsUsed[CH])return;let n;switch(t.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}t.normalized&&(n+=" normalized");let i=e.split("_",1)[0];Ade[i]&&Ade[i].includes(n)&&(this.extensionsUsed[CH]=!0,this.extensionsRequired[CH]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let n=e.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:An.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){let n=this.json,i=this.nodeMap;n.animations||(n.animations=[]);let r=(e=Xv.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,a=[],s=[];for(let o=0;o0){let t=[];for(let i=0,r=e.children.length;i0&&(r.children=t)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,r)}));let a=t.nodes.push(r)-1;return i.set(e,a),a}processScene(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let i={};""!==e.name&&(i.name=e.name),t.scenes.push(i);let r=[];for(let a=0,s=e.children.length;a0&&(i.nodes=r),this.serializeUserData(e,i)}processObjects(e){let t=new _i;t.name="AuxScene";for(let n=0;n0&&this.processObjects(n);for(let i=0;i0&&(a.range=e.distance)):e.isSpotLight&&(a.type="spot",e.distance>0&&(a.range=e.distance),a.spot={},a.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,a.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||0!==e.target.position.x||0!==e.target.position.y||-1!==e.target.position.z)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),r[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},r[this.name]=!0);let s=i.extensions[this.name].lights;s.push(a),t.extensions=t.extensions||{},t.extensions[this.name]={light:s.length-1}}},DH=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},OH=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(t,e.clearcoatMap),r.clearcoatTexture=t}if(r.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(t,e.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};n.applyTextureTransform(t,e.clearcoatNormalMap),r.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},kH=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(t,e.iridescenceMap),r.iridescenceTexture=t}if(r.iridescenceIor=e.iridescenceIOR,r.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(t,e.iridescenceThicknessMap),r.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},FH=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.transmissionFactor=e.transmission,e.transmissionMap){let t={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(t,e.transmissionMap),r.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},NH=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let n=this.writer,i=n.extensionsUsed,r={};if(r.thicknessFactor=e.thickness,e.thicknessMap){let t={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(t,e.thicknessMap),r.thicknessTexture=t}r.attenuationDistance=e.attenuationDistance,r.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},BH=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;let n=this.writer.extensionsUsed,i={};i.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0}},UH=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(Cct)&&!e.specularIntensityMap&&!e.specularColorTexture)return;let n=this.writer,i=n.extensionsUsed,r={};if(e.specularIntensityMap){let t={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(t,e.specularIntensityMap),r.specularTexture=t}if(e.specularColorMap){let t={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(t,e.specularColorMap),r.specularColorTexture=t}r.specularFactor=e.specularIntensity,r.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},HH=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;let n=this.writer,i=n.extensionsUsed,r={};if(e.sheenRoughnessMap){let t={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(t,e.sheenRoughnessMap),r.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(t,e.sheenColorMap),r.sheenColorTexture=t}r.sheenRoughnessFactor=e.sheenRoughness,r.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},VH=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;let n=this.writer,i=n.extensionsUsed,r={};if(e.anisotropyMap){let t={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(t,e.anisotropyMap),r.anisotropyTexture=t}r.anisotropyStrength=e.anisotropy,r.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}},zH=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;let n=this.writer.extensionsUsed,i={};i.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=i,n[this.name]=!0}};Xv.Utils={insertKeyframe:function(e,t){let n,i=e.getValueSize(),r=new e.TimeBufferType(e.times.length+1),a=new e.ValueBufferType(e.values.length+i),s=e.createInterpolant(new e.ValueBufferType(i));if(0===e.times.length){r[0]=t;for(let e=0;ee.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<.001)return e.times.length-1;r[r.length-1]=t,r.set(e.times,0),a.set(e.values,0),a.set(s.evaluate(t),e.values.length),n=r.length-1}else for(let o=0;ot){r.set(e.times.slice(0,o+1),0),r[o+1]=t,r.set(e.times.slice(o+1),o+2),a.set(e.values.slice(0,(o+1)*i),0),a.set(s.evaluate(t),(o+1)*i),a.set(e.values.slice((o+1)*i),(o+2)*i),n=o+1;break}}return e.times=r,e.values=a,n},mergeMorphTargetTracks:function(e,t){let n=[],i={},r=e.tracks;for(let a=0;a{if(n.binary){t=Fi.addExtention(t,Fi.EXTENSION_GLB);let n=e;Fi.saveArrayBuffer(n,t)}else t=Fi.addExtention(t,Fi.EXTENSION_GLTF),Fi.saveJson(e,t)}),(e=>console.log(e)),n)}static exportToObj(e,t){if(!e||!t)throw new Error("Invalid input or filename!");t=Fi.addExtention(t,Fi.EXTENSION_OBJ);let n=(new IA).parse(e);Fi.saveString(n,t)}static exportToDraco(e,t,n={}){if(!e||!t)throw new Error("Invalid input or filename!");t=Fi.addExtention(t,Fi.EXTENSION_DRACO);let i=new xa;n=Object.assign({},{encodeSpeed:5},n);let r=i.parse(e,n);Fi.saveArrayBuffer(r,t)}static exportToThreeJsJson(e,t){let n=e.toJSON();t.toLowerCase().endsWith(Fi.EXTENSION_JSON)||(t+=Fi.EXTENSION_JSON),Fi.saveJson(n,t)}static save(e,t){let n=Fi.downloadLink;n||(n=document.createElement("a"),n.style.display="none",document.body.appendChild(n),Fi.downloadLink=n),n.href=URL.createObjectURL(e),n.download=t,n.click()}static saveArrayBuffer(e,t){Fi.save(new Blob([e],{type:"application/octet-stream"}),t)}static saveJson(e,t){Fi.saveJsonString(JSON.stringify(e),t)}static saveJsonString(e,t){Fi.save(new Blob([e],{type:"application/json"}),t)}static saveString(e,t){Fi.save(new Blob([e],{type:"text/csv"}),t)}static addExtention(e,t){return e.toLowerCase().endsWith(t.toLowerCase())||(e+=t),e}},Lm=Fi;Lm.EXTENSION_GLTF=".gltf",Lm.EXTENSION_GLB=".glb",Lm.EXTENSION_OBJ=".obj",Lm.EXTENSION_DRACO=".drc",Lm.EXTENSION_JSON=".json";var LA=class{constructor(){this.prevTime=(performance||Date).now(),this.beginTime=(performance||Date).now(),this.frames=0,this.fps=Number.NaN}begin(){this.beginTime=(performance||Date).now()}end(){this.frames++;let e=(performance||Date).now();return e>=this.prevTime+1e3&&(this.fps=Math.round(1e3*this.frames/(e-this.prevTime)),this.frames=0,this.prevTime=e),e}update(){this.beginTime=this.end()}},YH={exports:{}};function kA(e,t,n){n=n||2;var i,r,a,s,o,l,h,c=t&&t.length,u=c?t[0]*n:e.length,d=Hde(e,0,u,n,!0),p=[];if(!d||d.next===d.prev)return p;if(c&&(d=Vct(e,t,d,n)),e.length>80*n){i=a=e[0],r=s=e[1];for(var f=n;fa&&(a=o),l>s&&(s=l);h=0!==(h=Math.max(a-i,s-r))?32767/h:0}return $b(d,p,n,i,r,h,0),p}function Hde(e,t,n,i,r){var a,s;if(r===XH(e,t,n,i)>0)for(a=t;a=t;a-=i)s=kde(a,e[a],e[a+1],s);return s&&FA(s,s.next)&&(Kb(s),s=s.next),s}function Dm(e,t){if(!e)return e;t||(t=e);var n,i=e;do{if(n=!1,i.steiner||!FA(i,i.next)&&0!==Qi(i.prev,i,i.next))i=i.next;else{if(Kb(i),(i=t=i.prev)===i.next)break;n=!0}}while(n||i!==t);return t}function $b(e,t,n,i,r,a,s){if(e){!s&&a&&jct(e,i,r,a);for(var o,l,h=e;e.prev!==e.next;)if(o=e.prev,l=e.next,a?Bct(e,i,r,a):Nct(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),Kb(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?$b(e=Uct(Dm(e),t,n),t,n,i,r,a,2):2===s&&Hct(e,t,n,i,r,a):$b(Dm(e),t,n,i,r,a,1);break}}}function Nct(e){var t=e.prev,n=e,i=e.next;if(Qi(t,n,i)>=0)return!1;for(var r=t.x,a=n.x,s=i.x,o=t.y,l=n.y,h=i.y,c=ra?r>s?r:s:a>s?a:s,p=o>l?o>h?o:h:l>h?l:h,f=i.next;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&Yv(r,o,a,l,s,h,f.x,f.y)&&Qi(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Bct(e,t,n,i){var r=e.prev,a=e,s=e.next;if(Qi(r,a,s)>=0)return!1;for(var o=r.x,l=a.x,h=s.x,c=r.y,u=a.y,d=s.y,p=ol?o>h?o:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,v=WH(p,f,t,n,i),y=WH(m,g,t,n,i),x=e.prevZ,b=e.nextZ;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&Yv(o,c,l,u,h,d,x.x,x.y)&&Qi(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==s&&Yv(o,c,l,u,h,d,b.x,b.y)&&Qi(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&Yv(o,c,l,u,h,d,x.x,x.y)&&Qi(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==s&&Yv(o,c,l,u,h,d,b.x,b.y)&&Qi(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Uct(e,t,n){var i=e;do{var r=i.prev,a=i.next.next;!FA(r,a)&&Vde(r,i,i.next,a)&&Zb(r,a)&&Zb(a,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(a.i/n|0),Kb(i),Kb(i.next),i=e=a),i=i.next}while(i!==e);return Dm(i)}function Hct(e,t,n,i,r,a){var s=e;do{for(var o=s.next.next;o!==s.prev;){if(s.i!==o.i&&$ct(s,o)){var l=zde(s,o);return s=Dm(s,s.next),l=Dm(l,l.next),$b(s,t,n,i,r,a,0),void $b(l,t,n,i,r,a,0)}o=o.next}s=s.next}while(s!==e)}function Vct(e,t,n,i){var r,a,s,o=[];for(r=0,a=t.length;r=i.next.y&&i.next.y!==i.y){var o=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(o<=r&&o>s&&(s=o,n=i.x=i.x&&i.x>=c&&r!==i.x&&Yv(an.x||i.x===n.x&&Wct(n,i)))&&(n=i,d=l)),i=i.next}while(i!==h);return n}function Wct(e,t){return Qi(e.prev,e,t.prev)<0&&Qi(t.next,e,e.next)<0}function jct(e,t,n,i){var r=e;do{0===r.z&&(r.z=WH(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,Xct(r)}function Xct(e){var t,n,i,r,a,s,o,l,h=1;do{for(n=e,e=null,a=null,s=0;n;){for(s++,i=n,o=0,t=0;t0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,l--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,h*=2}while(s>1);return e}function WH(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Yct(e){var t=e,n=e;do{(t.x=(e-s)*(a-o)&&(e-s)*(i-o)>=(n-s)*(t-o)&&(n-s)*(a-o)>=(r-s)*(i-o)}function $ct(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Zct(e,t)&&(Zb(e,t)&&Zb(t,e)&&Kct(e,t)&&(Qi(e.prev,e,t.prev)||Qi(e,t.prev,t))||FA(e,t)&&Qi(e.prev,e,e.next)>0&&Qi(t.prev,t,t.next)>0)}function Qi(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function FA(e,t){return e.x===t.x&&e.y===t.y}function Vde(e,t,n,i){var r=OA(Qi(e,t,n)),a=OA(Qi(e,t,i)),s=OA(Qi(n,i,e)),o=OA(Qi(n,i,t));return!!(r!==a&&s!==o||0===r&&DA(e,n,t)||0===a&&DA(e,i,t)||0===s&&DA(n,e,i)||0===o&&DA(n,t,i))}function DA(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function OA(e){return e>0?1:e<0?-1:0}function Zct(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Vde(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Zb(e,t){return Qi(e.prev,e,e.next)<0?Qi(e,t,e.next)>=0&&Qi(e,e.prev,t)>=0:Qi(e,t,e.prev)<0||Qi(e,e.next,t)<0}function Kct(e,t){var n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}function zde(e,t){var n=new jH(e.i,e.x,e.y),i=new jH(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function kde(e,t,n,i){var r=new jH(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function Kb(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function jH(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function XH(e,t,n,i){for(var r=0,a=t,s=n-i;a0&&(i+=e[r-1].length,n.holes.push(i))}return n};var wDt=YH.exports;function Fde(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function Jct(e,t){var n=t[0],i=t[1],r=t[2],a=Math.sqrt(n*n+i*i+r*r)||1;return e[0]=n/a,e[1]=i/a,e[2]=r/a,e}function Qct(e,t,n){var i=t[0],r=t[1],a=t[2],s=n[0],o=n[1],l=n[2];return e[0]=r*l-a*o,e[1]=a*s-i*l,e[2]=i*o-r*s,e}function eut(e,t){function n(e,t,n,i){e[0]=t,e[1]=n,e[2]=i}for(var i=[],r=[],a=[],s=[],o=[],l=[],h=e.length,c=new Float32Array(t.length),u=0;u0&&(d=(d=d.map((function(e){return e}))).reverse());for(var p=0,f=d.length-1;p0}var $H=1e-15,qde=(new et).set(0,0,-1,0,1,0,0,0,0,1,0,0,0,0,0,1),Wde=(new et).set(0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1),Zt=class{static roundNumber(e,t){return Math.round(e*Math.pow(10,t))/Math.pow(10,t)}static floorNumber(e,t){return Math.floor(e*Math.pow(10,t))/Math.pow(10,t)}static areNumbersEqual(e,t,n=1e-7){return Math.abs(e-t){let n=e.attributes[t];if(n instanceof fo){let i=n.clone();e.attributes[t]=i}}))}static isPointInPolygon(e,t,n=!1){let i=e.x,r=e.y,a=!1,s=t.length;for(let o=0,l=s-1;or!=c>r;n&&(u=s>=r!=c>=r),u&&i<(h-e)*(r-s)/(c-s)+e&&(a=!a)}return a}static caculateGeometryCenter(e){if(!e.hasAttribute("position"))return null;let t=e.getAttribute("position");if(0===t.count)return null;let n=new O,i=t.itemSize,r=t.array,a=[0,0,0];for(let s=0;s0&&n<0||i<0&&n>0)return!1;n=i}}return!0}static areLineSegmentsIntersecting(e,t){let{start:n,end:i}=e,{start:r,end:a}=t,s=r.clone().sub(n),o=i.clone().sub(n),l=a.clone().sub(n),h=s.cross(o).dot(l.cross(o)),c=n.clone().sub(r),u=a.clone().sub(r),d=i.clone().sub(r),p=c.cross(u).dot(d.cross(u));return h<0&&p<0}static getLineSegmentsIntersectingPoint(e,t){let{start:n,end:i}=e,{start:r,end:a}=t,s=Yde.subVectors(i,n).normalize(),o=$de.subVectors(a,r).normalize();if(1===s.dot(o))return null;let l=Zde.subVectors(r,n),h=s.clone().cross(o),c=l.clone().cross(o),u=l.clone().dot(h);if(u>=1e-5||u<=-1e-5)return null;let d=h.lengthSq();if(Zt.areNumbersEqual(0,d))return;let p=c.clone().dot(h)/d,f=n.clone().add(s.multiplyScalar(p));return f.equals(n)||f.equals(i)?null:f}static isPointOnLineSegment(e,t,n=.001){let{start:i,end:r}=t,a=Yde.subVectors(i,r).length(),s=$de.subVectors(e,i).length(),o=Zde.subVectors(e,r).length();return Math.abs(a-(s+o))<=n}static isPointOnLineSegments(e,t,n=.001){let i=!1;for(let r=0;r{n?t.add(e):(t.x+=e.x,t.y+=e.y)})),t.divideScalar(e.length);let i=!1;if(Qt.shouldRebasePositionOnRTC(t)){i=!0;for(let i=0;iZH||Math.abs(e.y)>ZH||e instanceof O&&Math.abs(e.z)>ZH}static calculateSurfaceArea(e){let t=0,n=e.getAttribute("position"),i=e.index;if(i)for(let r=0;r2&&(a=t?2*r:2*r-2);let s=new i(a),o=0;for(let l=0;l0&&l{let n=e.geometry.attributes.position.array;return e.localToWorld(new O(n[3*t],n[3*t+1],n[3*t+2]))};e.updateWorldMatrix(!0,!1);let s=(null==(n=e.geometry.getIndex())?void 0:n.array)||[],o=null!=(i=s[t])?i:t,l=null!=(r=s[t+1])?r:t+1;return[a(o),a(l)]}static arePolygonsIntersect(e,t){if(0===e.length||0===t.length||(jde.setFromPoints(e),Xde.setFromPoints(t),!jde.intersectsBox(Xde)))return!1;for(let n=0;n1-r)return;let o=t.y-e.y,l=e.x-t.x,h=o*e.x+l*e.y,c=i.y-n.y,u=n.x-i.x,d=c*n.x+u*n.y,p=o*u-c*l;return Math.abs(p){n.push([e.x,e.y])}));try{let{indices:e,position:i}=Gde([n],{lineWidth:t,depth:1}),r=new Dt;return r.setAttribute("position",new Bt(i,3)),r.setIndex(Array.from(e)),r}catch(e){return}}static releaseGeometryManually(e){e.index=null,e.attributes={}}static getAdjacentNonRepeatPoints(e,t=1e-7){let n=[],i=e.length;for(let r=0;r0){let e=[];return n.forEach((n=>{e.push(this.clonedHighlightMaterial(n,t))})),e}if(n instanceof yr)return this.clonedHighlightMaterial(n,t);console.warn(`[MaterialUtils] Invalid material: ${n}`)}static clonedHighlightMaterial(e,t={}){let{depthTest:n,highlightColor:i=new ct(583902),opacity:r=.7}=t,a=e.clone();return this.setMaterialColor(a,i),a.opacity=r,a.transparent=!0,void 0!==n&&(a.depthTest=n,a.side=Sr),a}static cloneMaterial(e){if(!e)return e;if(Array.isArray(e)){let t=[];return e.forEach((e=>{t.push(e.clone())})),t}return e.clone()}static getMaterialColor(e){let t=new ct(16777215);return e instanceof xi||e instanceof Gn||e instanceof on?t=e.color:e instanceof ln&&e.uniforms.u_color&&(t=e.uniforms.u_color.value),t}static setMaterialColor(e,t){var n,i,r;let a=e;null==(n=a.color)||n.set(t),null==(i=a.emissive)||i.set(t),null!=(r=a.uniforms)&&r.u_color&&a.uniforms.u_color.value.set(t)}static cloneMaterials(e){let t=new Map;e.traverse((e=>{e.material&&(e.material=(e=>{let n;return Array.isArray(e)?(n=[],e.forEach((e=>{if(t.has(e))n.push(t.get(e));else{let i=e.clone();t.set(e,i),n.push(i)}}))):e&&(t.has(e)?n=t.get(e):(n=e.clone(),t.set(e,n))),n})(e.material))}))}};function Ni(e,t=!1){let n=null!==e[0].index,i=new Set(Object.keys(e[0].attributes)),r=new Set(Object.keys(e[0].morphAttributes)),a={},s={},o=e[0].morphTargetsRelative,l=new Dt,h=0;for(let c=0;c0){e.matrixWorld||(e.matrixWorld=new et),e.matrixWorld.copy(e.matrix),n&&e.matrixWorld.premultiply(n);let i=e.children;for(let n=0,r=i.length;n{r.find((t=>t.id===e.id))||(r.push({id:e.id,opacity:e.opacity,transparent:e.transparent,side:e.side}),e.opacity*=t,e.transparent=!0,e.side=Sr)},s=e=>{let n=r.find((t=>t.id===e.id));if(!n){let n=e.clone();return r.push({id:e.id,opacity:e.opacity,transparent:e.transparent,side:e.side,material:e,clonedMaterial:n}),n.opacity*=t,n.transparent=!0,n}return n.clonedMaterial};return e.traverse((e=>{if((!i||-1===i.indexOf(e.id))&&(!n||-1!==n.indexOf(e.id))&&e instanceof xt){let t=e;if(n||i){if(Array.isArray(t.material)){let e=[];t.material.forEach((t=>{let n=s(t);n&&e.push(n)})),t.material=e}else if(t.material){let e=s(t.material);e&&(t.material=e)}}else if(Array.isArray(t.material))t.material.forEach((e=>{a(e)}));else if(t.material){let e=t.material;a(e)}}})),r}static revertObjectOpacity(e,t,n,i){let r=new Set,a=e=>{if(!e||null==e.id||r.has(e.id))return;r.add(e.id);let n=t.find((t=>t.id===e.id));n&&(e.opacity=n.opacity,e.transparent=n.transparent,e.side=n.side,0===e.opacity&&se.warn(`[ObjectUtils] Material '${e.name}'s opacity is 0, you may not be able to see your objects!`))},s=e=>{let n=t.find((t=>t.clonedMaterial&&t.clonedMaterial.id===e.id));if(n)return n.material};e.traverse((e=>{if((!i||-1===i.indexOf(e.id))&&(!n||-1!==n.indexOf(e.id))&&e instanceof xt)if(Array.isArray(e.material)){let t=[];e.material.forEach((e=>{let n=s(e);n?t.push(n):a(e)})),e.material=t}else if(e.material){let t=s(e.material);t?e.material=t:a(e.material)}}))}static setObjectOpacityById(e,t,n=.3,i,r){let a=e.getObjectById(t);if(!a)throw new Error(`Failed to find object by id: ${t}`);return Ac.setObjectOpacity(a,n,i,r)}static revertObjectOpacityById(e,t,n,i,r){let a=e.getObjectById(t);if(!a)throw new Error(`Failed to find object by id: ${t}`);Ac.revertObjectOpacity(a,n,i,r)}static applyMaterialToObject(e,t,n,i){e.traverse((e=>{i&&-1!==i.indexOf(e.id)||n&&-1===n.indexOf(e.id)||e instanceof xt&&(e.userData.originalMaterial||(e.userData.originalMaterial=e.material),e.material=t)}))}static revertAppliedMaterialToObject(e,t,n){e.traverse((e=>{n&&-1!==n.indexOf(e.id)||t&&-1===t.indexOf(e.id)||e.userData.originalMaterial&&(e.material=e.userData.originalMaterial,e.userData.originalMaterial=void 0)}))}static applyMaterialToObjectById(e,t,n,i,r){let a=e.getObjectById(t);if(!a)throw new Error(`Failed to find object by id: ${t}`);this.applyMaterialToObject(a,n,i,r)}static revertAppliedMaterialToObjectById(e,t,n,i){let r=e.getObjectById(t);if(!r)throw new Error(`Failed to find object by id: ${t}`);this.revertAppliedMaterialToObject(r,n,i)}static applyOpacityMaterialToObject(e,t,n){let i=new on({color:0,transparent:!0,opacity:.05});this.applyMaterialToObject(e,i,t,n)}static setWireframeMode(e){let t=new on({color:16732160,wireframe:!0,transparent:!0,opacity:.8});e.traverseVisible((e=>{if(e instanceof xt){let n=e;n.userData.materialForWireframe=n.material,n.material=t}}))}static setWireframeModeById(e,t){let n=e.getObjectById(t);if(!n)throw new Error(`Failed to find object by id: ${t}`);Ac.setWireframeMode(n)}static revertWireframeMode(e){e.traverseVisible((e=>{e instanceof xt&&e.userData.materialForWireframe&&(e.material=e.userData.materialForWireframe,e.userData.materialForWireframe=void 0)}))}static revertWireframeModeById(e,t){let n=e.getObjectById(t);if(!n)throw new Error(`Failed to find object by id: ${t}`);Ac.revertWireframeMode(n)}static findInner(e,t,n=[],i=!1){let r=t.toLowerCase(),a=[],s=e=>-1!==e.toLowerCase().indexOf(r),o=e=>-1!==e.toString().indexOf(r),l=e=>{if(e.name&&-1!==e.name.toLowerCase().indexOf(r))return!0;if(e.gltfExtensions){let t=e.gltfExtensions,n=t.objectId&&t.objectId.Value||t.elementId&&t.elementId.Value;if(n&&-1!==n.toLowerCase().indexOf(r))return!0}return!1};if(n.length>0)for(let h=0;h{(s(e.name)||o(e.id)||l(e.userData))&&a.push(e)})),i&&a.length>0)return[a[0]]}else if(e.traverse((e=>{(s(e.name)||o(e.id)||l(e.userData))&&a.push(e)})),i&&a.length>0)return[a[0]];return a}static find(e,t,n=[],i=!1){return this.findInner(e,t,n,i)}static findFirst(e,t,n=[],i=!1){let r=this.findInner(e,t,n,i);if(r.length>0)return r[0]}static getFloorsFromString(e){let t=[],n=new RegExp(/(?:-?(?:\d+(?:\.5)?)F)(?=\W|$)/,"g").exec(e);return n&&n.length>0&&n.forEach((e=>{if(e){let n=e.replace("F",""),i=Number(n);i?t.push(i):console.log(`[OU] invalid floor: ${e}`)}})),t}static matchFloor(e,t){return-1!==this.getFloorsFromString(e).findIndex((e=>e===t))}static matchFloors(e,t){return-1!==this.getFloorsFromString(e).findIndex((e=>-1!==t.findIndex((t=>t===e))))}static distinctFloors(e,t){let n=[],i=e=>{this.getFloorsFromString(e).forEach((e=>{n[e]=!0}))};return t.forEach((t=>{let n=e.getObjectById(t);n&&n.traverse((e=>{if(i(e.name),e.userData.gltfExtensions){let t=e.userData.gltfExtensions;t.level&&t.level.Value&&i(t.level.Value)}}))})),Object.keys(n).sort()}static traverseObjectByFloors(e,t,n,i,r){let a=e.getObjectById(t);if(!a)return[];a.traverse((e=>{let t=this.matchFloors(e.name,n);if(!t&&e.userData&&e.userData.gltfExtensions){let i=e.userData.gltfExtensions;i.level&&i.level.Value&&(t=this.matchFloors(i.level.Value,n))}t&&i&&i(e),!t&&r&&r(e)}))}static setVisibleForFloors(e,t,n,i=!0){this.traverseObjectByFloors(e,t,n,(e=>{let t=e;for(;t;)t.visible=!0,t=t.parent||void 0}),(e=>{i&&(e.visible=!1)}))}static revertVisibleForFloors(e){e.traverse((e=>{e.visible=!0}))}static revertVisibleForFloorsById(e,t){let n=this.getObjectById(e,t);this.revertVisibleForFloors(n)}static getObjectById(e,t){let n=e.getObjectById(t);if(!n)throw new Error(`Failed to find object by id: ${t}`);return n}static createOutlines(e){return ft(this,arguments,(function*(e,t={onlyVisible:!0,meshOnly:!0},n){if(!e)return[];if(0===e.children.length&&(t.onlyVisible&&!e.visible||t.meshOnly&&!(e instanceof xt)))return[];let i=[],r=e,a=r.children.length,s=Math.round(Math.pow(a,.5)),o=Mt.getUpdateProgressFuncAsync(n);for(let l=a-1;l>=0;--l){let e,o=a-l-1;if(n&&(o%s==0||0===o||o===a-1)){let t=90*o/a,i=90*(o+1)/a;e=Mt.getUpdateSubProgressFunc(t,i,n)}let h=r.children[l],c=yield this.createOutlines(h,t,e);i.push(...c)}if(!r.geometry)return yield o(100),i;if(r instanceof xt&&!this.hasOutline(r,!1)){yield o(50);let e=this.createOutline(r.geometry);r.add(e),e.updateWorldMatrix(!0,!1),i.push(e)}return yield o(100),i}))}static removeOutlines(e){if(e&&Array.isArray(e.children))for(let t=e.children.length-1;t>=0;--t){let n=e.children[t];n.children.length>0&&this.removeOutlines(n),n.userData.isOutline&&e.remove(n)}}static hasOutline(e,t=!0){let n=!1;for(let i=0;i0&&(n=this.hasOutline(r),n))break}return n}static setOutlinesVisibility(e,t){e.traverse((e=>{e.userData.isOutline&&(e.visible=t)}))}static createOutline(e,t=this.OUTLINE_MATERIAL,n){let i=new Cu(e,10),r=new Wr(i,t);return r.layers.enableAll(),Ac.disableLayerChannels(r,[12,11]),r.userData.isOutline=!0,r.matrixAutoUpdate=!1,n&&r.applyMatrix4(n),r}static cloneObject(e,t=!0){let n=e.clone();return t&&n.traverse((e=>{(e instanceof xt||e instanceof hr)&&(e.material=es.cloneMaterial(e.material))})),n}static createBox(e,t,n,i=Ac.BOX_FACE_MATERIAL,r=!0){let a=[],s=(e,t,n)=>{a.push(new O(e,t,n))};s(0,0,0),s(e,0,0),s(e,t,0),s(0,t,0),s(0,0,n),s(e,0,n),s(e,t,n),s(0,t,n);let o=new Dt;o.setFromPoints(a);let l=[0,3,2,0,2,1,4,6,7,4,5,6,0,7,3,0,4,7,3,6,2,3,7,6,1,6,5,1,2,6];return r&&l.push(0,5,4,0,1,5),o.setIndex(l),o.computeVertexNormals(),new xt(o,i)}static rebaseObjectOnRTC(e){let t=e;if(!((t.isMesh||t.isLine||t.isPoints)&&t.geometry&&t.geometry instanceof Dt))return e;let n=t.geometry;if(!n.hasAttribute("position"))return e;let i=n.getAttribute("position");if(0===i.count)return e;let r=i.itemSize,a=i.array,s=[];for(let h=0;h2?s[2]:0);let l=e.matrixAutoUpdate;return e.matrixAutoUpdate=!1,e.applyMatrix4(o),e.matrixAutoUpdate=l,e}static isEmptyObject(e){if(0===e.children.length){let t=e.geometry;if(!t||!t.hasAttribute("position")||0===t.getAttribute("position").count)return!0}return!1}static removeEmptyObjects(e){for(let t=0;t{e.removeFromParent()})),this.removeEmptyObjects(t))}static setSharedVariablesOfObject(e){e.uuid="",e.up=cut;let t=e;t.material&&(Array.isArray(t.material)?t.material.forEach((e=>{e.uuid&&(e.uuid="")})):t.material.uuid&&(t.material.uuid=""))}static isLeafObject(e){return(e instanceof xt||e instanceof hr||e instanceof ii)&&!!e.geometry}static enableLayerChannels(e,t,n=!0){for(let i=0,r=t.length;i0){this.mergeInner(n,t);continue}if(n.isInstancedMesh||!n.geometry||!(n.geometry instanceof Dt))continue;let a=!1,s=Object.values(i);for(let t=s.length-1;t>=0;--t){let n=s[t].indexes[0];if(a=this.tryHandleMergeableObjects(e,h,n,i,r),a)break}for(let t=r.length-1;!a&&t>=0;--t){let n=r[t];if(a=this.tryHandleMergeableObjects(e,h,n,i,r),a)break}a||r.push(h)}if(Object.keys(i).length<=0)return;let a=[],s=[],o=[],l=[];Object.values(i).forEach((n=>{let i,r=n.indexes,h=e.children[r[0]],c=[],u=0,d=0,p=0,f=[];if(r.forEach((n=>{var i,r,a;let s=e.children[n],o=s.geometry.clone();if(o.applyMatrix4(s.matrix),Qt.tryConvertInterleavedBufferAttributes(o),o.userData.isLineSegments=!0===s.isLineSegments,c.push(o),t){let e=s.name,t=null==(r=null==(i=o.attributes)?void 0:i.position)?void 0:r.count,n=(null==(a=o.index)?void 0:a.count)||0,l={batchId:u,name:e,positionStart:d,positionCount:t,indexStart:p,indexCount:n};0!==Object.keys(s.userData).length&&(l.userData=s.userData),f.push(l),d+=t,p+=n,u++}})),0!==c.length){if(h.isMesh){let e=Ni(c);if(!e)return;e.userData={},i=new xt(e,h.material),a.push(i)}else if(h.isLine){let e=this.mergeLineGeometries(c,t,h.material instanceof Iu||h.material instanceof ln,f);if(!e)return;i=new Wr(e,h.material),s.push(i)}else if(h.isPoints){let e=Ni(c);if(!e)return;e.userData={},i=new ii(e,h.material),o.push(i)}i&&(t?i.userData.batches=f:(i.userData=h.userData,i.userData.batches=void 0),i.userData.layerName=h.userData.layerName,i.name=`[Merged] ${h.name}`,i.matrixAutoUpdate=!1,i.renderOrder=h.renderOrder,i.layers.mask=h.layers.mask,i.visible=h.visible,l.push(...r)),c.forEach((e=>{e.dispose(),Qt.releaseGeometryManually(e)})),c=[]}})),l.sort(((e,t)=>t-e)),l.forEach((t=>{let n=e.children[t];e.remove(n)})),[...a,...s,...o].forEach((t=>{e.add(t)})),e.updateMatrix(),this.mergeInfo.removedObjects+=l.length,this.mergeInfo.mergedMeshes+=a.length,this.mergeInfo.mergedLines+=s.length,this.mergeInfo.mergedPoints+=o.length}static tryHandleMergeableObjects(e,t,n,i,r){let a=!1,s=Array.isArray(e),o=s?e.length:e.children.length;if(t===n||t>=o||n>=o)return a;let l=s?e[t]:e.children[t],h=s?e[n]:e.children[n];return this.areObjectsMergeable(l,h)&&this.areGeometriesMergeable(l.geometry,h.geometry)&&es.materialsEquals(l.material,h.material)&&(i[n]||(i[n]={indexes:[n]},this.removeFromArray(r,n)),i[n].indexes.push(t),a=!0),a}static deepMerge(e,t=void 0,n=!0,i=!0,r=!0){let a={added:[],removed:[]};if(e.length<=1)return a;let s=Date.now(),o={},l=[];for(let m=0;m=0;--r){let t=i[r].indexes[0];if(n=this.tryHandleMergeableObjects(e,m,t,o,l),n)break}for(let r=l.length-1;!n&&r>=0;--r){let t=l[r];if(n=this.tryHandleMergeableObjects(e,m,t,o,l),n)break}n||l.push(m)}if(Object.keys(o).length<=0)return a;se.debug(`[Merge] Built merged indexes for ${e.length} objects in ${(Date.now()-s)/1e3}s`),s=Date.now();let h=[],c=[],u=[],d=[];Object.values(o).forEach((n=>{let i=n.indexes;if(i.length<2)return;let a,s=e[i[0]],o=[],l=0,p=0,f=0,m=[];if(i.forEach((n=>{var i,a,h;let c=e[n],u=c.geometry.clone();if(s.material instanceof Gn&&u.deleteAttribute("lineDistance"),this.applyMatrix(u,c,t),u.userData.isLineSegments=!0===c.isLineSegments,o.push(u),r){let e,t=c.name,n=null==(a=null==(i=u.attributes)?void 0:i.position)?void 0:a.count,r=(null==(h=u.index)?void 0:h.count)||0;s.isLine&&(u.boundingSphere||u.computeBoundingSphere(),e=u.boundingSphere.clone());let o={batchId:l,name:t,positionStart:p,positionCount:n,indexStart:f,indexCount:r,boundingSphere:e};0!==Object.keys(c.userData).length&&(o.userData=c.userData),m.push(o),p+=n,f+=r,l++}})),0!==o.length){if(s.isMesh){let e=Ni(o);if(!e)return;e.userData={},a=new xt(e,s.material),h.push(a)}else if(s.isLine){let e=this.mergeLineGeometries(o,r,s.material instanceof Iu||s.material instanceof ln,m);if(!e)return;a=new Wr(e,s.material),c.push(a)}else if(s.isPoints){let e=Ni(o);if(!e)return;e.userData={},a=new ii(e,s.material),u.push(a)}a&&(r?a.userData.batches=m:(a.userData=s.userData,a.userData.batches=void 0),a.userData.layerName=s.userData.layerName,a.name=`[Merged] ${s.name}`,a.matrixAutoUpdate=!1,a.renderOrder=s.renderOrder,a.layers.mask=s.layers.mask,a.visible=s.visible,i.forEach((e=>d.push(e)))),o.forEach((e=>{e.dispose(),Qt.releaseGeometryManually(e)})),o=[]}})),se.debug(`[Merge] Ran deepMerge() in ${(Date.now()-s)/1e3}s`);let p=a.removed;d.forEach((t=>{let i=e[t];p.push(i),n&&i.removeFromParent()}));let f=a.added;return[...h,...c,...u].forEach((e=>{f.push(e),n&&t&&(t.add(e),e.updateWorldMatrix(!1,!1))})),this.mergeInfo.removedObjects+=d.length,this.mergeInfo.mergedMeshes+=h.length,this.mergeInfo.mergedLines+=c.length,this.mergeInfo.mergedPoints+=u.length,i&&t&&Hn.removeEmptyObjects(t),a}static applyMatrix(e,t,n){let i=t;for(NA.identity();i&&i!==n&&(NA.premultiply(i.matrix),i.parent);)i=i.parent;return NA.equals(uut)?e:e.applyMatrix4(NA)}static mergeLineGeometries(e,t,n,i){let r;if(n)r=BA.mergeBufferGeometriesWithLinesToLineSegments(e,t,i);else{if(r=Ni(e),!r)return;r.userData={};let n=[],a=0;e.forEach(((e,r)=>{let s=e.attributes.position;if(!s)return;let o=e.index,l=!0===e.userData.isLineSegments,h=n.length;if(o)for(let t=0;t0&&n.push(a+o.array[t-1],a+e)}else for(let t=0;t0&&(l?t%2==1&&n.push(a+t-1,a+t):n.push(a+t-1,a+t));a+=s.count,t&&i&&(i[r].indexStart=h,i[r].indexCount=n.length-h)})),r.setIndex(n)}return r}static mergeBufferGeometriesWithLinesToLineSegments(e,t,n){let i=new Set(Object.keys(e[0].attributes)),r={},a=new Dt,s=[],o=0;for(let l=0;l=0;--n)if(e[n]===t)return void e.splice(n,1)}static removeObjectFromArray(e,t){for(let n=e.length-1;n>=0;--n)if(e[n]===t)return void e.splice(n,1)}static areGeometriesMergeable(e,t){if(!e||!t||"InstancedBufferGeometry"===e.type||"InstancedBufferGeometry"===t.type||!!e.index!=!!t.index)return!1;let n=Object.keys(e.attributes);if(n.length!==Object.keys(t.attributes).length)return!1;for(let i of n)if(!t.attributes[i])return!1;return!0}static areObjectsMergeable(e,t){if(e.layers.mask!==t.layers.mask||e.renderOrder!==t.renderOrder||e.visible!==t.visible||e.userData.layerName!==t.userData.layerName)return!1;if(e.type===t.type)return!0;let n=e,i=t;return n.isMesh&&i.isMesh||n.isLine&&i.isLine||n.isPoints&&i.isPoints}static isMergedMesh(e){return!(!e||!e.userData.batches)}static isFaceIndexInBatch(e,t,n){if(e.boundsTree){let i=e.index.getX(3*n);if(i>=t.positionStart&&i=e&&n<=i)return!0}else{let e=3*n;if(e>=t.positionStart&&e=e.indexStart&&t=e.positionStart&&t80*n){i=a=e[0],r=s=e[1];for(let t=n;ta&&(a=o),l>s&&(s=l);h=Math.max(a-i,s-r),h=0!==h?32767/h:0}return nE(d,p,n,i,r,h,0),p}};function Tfe(e,t,n,i,r){let a,s;if(r===nht(e,t,n,i)>0)for(a=t;a=t;a-=i)s=Efe(a,e[a],e[a+1],s);return s&&XA(s,s.next)&&(iE(s),s=s.next),s}function km(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!XA(i,i.next)&&0!==ts(i.prev,i,i.next))i=i.next;else{if(iE(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function nE(e,t,n,i,r,a,s){if(!e)return;!s&&a&&Zut(e,i,r,a);let o,l,h=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,a?zut(e,i,r,a):Vut(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),iE(e),e=l.next,h=l.next;else if((e=l)===h){s?1===s?nE(e=Gut(km(e),t,n),t,n,i,r,a,2):2===s&&qut(e,t,n,i,r,a):nE(km(e),t,n,i,r,a,1);break}}function Vut(e){let t=e.prev,n=e,i=e.next;if(ts(t,n,i)>=0)return!1;let r=t.x,a=n.x,s=i.x,o=t.y,l=n.y,h=i.y,c=ra?r>s?r:s:a>s?a:s,p=o>l?o>h?o:h:l>h?l:h,f=i.next;for(;f!==t;){if(f.x>=c&&f.x<=d&&f.y>=u&&f.y<=p&&$v(r,o,a,l,s,h,f.x,f.y)&&ts(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function zut(e,t,n,i){let r=e.prev,a=e,s=e.next;if(ts(r,a,s)>=0)return!1;let o=r.x,l=a.x,h=s.x,c=r.y,u=a.y,d=s.y,p=ol?o>h?o:h:l>h?l:h,g=c>u?c>d?c:d:u>d?u:d,v=a5(p,f,t,n,i),y=a5(m,g,t,n,i),x=e.prevZ,b=e.nextZ;for(;x&&x.z>=v&&b&&b.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&$v(o,c,l,u,h,d,x.x,x.y)&&ts(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==s&&$v(o,c,l,u,h,d,b.x,b.y)&&ts(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&$v(o,c,l,u,h,d,x.x,x.y)&&ts(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=f&&b.y<=g&&b!==r&&b!==s&&$v(o,c,l,u,h,d,b.x,b.y)&&ts(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Gut(e,t,n){let i=e;do{let r=i.prev,a=i.next.next;!XA(r,a)&&wfe(r,i,i.next,a)&&rE(r,a)&&rE(a,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(a.i/n|0),iE(i),iE(i.next),i=e=a),i=i.next}while(i!==e);return km(i)}function qut(e,t,n,i,r,a){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&Qut(s,e)){let o=Sfe(s,e);return s=km(s,s.next),o=km(o,o.next),nE(s,t,n,i,r,a,0),void nE(o,t,n,i,r,a,0)}e=e.next}s=s.next}while(s!==e)}function Wut(e,t,n,i){let r,a,s,o,l,h=[];for(r=0,a=t.length;r=i.next.y&&i.next.y!==i.y){let e=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=a&&e>r&&(r=e,n=i.x=i.x&&i.x>=h&&a!==i.x&&$v(sn.x||i.x===n.x&&$ut(n,i)))&&(n=i,u=o)),i=i.next}while(i!==l);return n}function $ut(e,t){return ts(e.prev,e,t.prev)<0&&ts(t.next,e,e.next)<0}function Zut(e,t,n,i){let r=e;do{0===r.z&&(r.z=a5(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,Kut(r)}function Kut(e){let t,n,i,r,a,s,o,l,h=1;do{for(n=e,e=null,a=null,s=0;n;){for(s++,i=n,o=0,t=0;t0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,l--),a?a.nextZ=r:e=r,r.prevZ=a,a=r;n=i}a.nextZ=null,h*=2}while(s>1);return e}function a5(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Jut(e){let t=e,n=e;do{(t.x=(e-s)*(a-o)&&(e-s)*(i-o)>=(n-s)*(t-o)&&(n-s)*(a-o)>=(r-s)*(i-o)}function Qut(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!eht(e,t)&&(rE(e,t)&&rE(t,e)&&tht(e,t)&&(ts(e.prev,e,t.prev)||ts(e,t.prev,t))||XA(e,t)&&ts(e.prev,e,e.next)>0&&ts(t.prev,t,t.next)>0)}function ts(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function XA(e,t){return e.x===t.x&&e.y===t.y}function wfe(e,t,n,i){let r=jA(ts(e,t,n)),a=jA(ts(e,t,i)),s=jA(ts(n,i,e)),o=jA(ts(n,i,t));return!!(r!==a&&s!==o||0===r&&WA(e,n,t)||0===a&&WA(e,i,t)||0===s&&WA(n,e,i)||0===o&&WA(n,t,i))}function WA(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function jA(e){return e>0?1:e<0?-1:0}function eht(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&wfe(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function rE(e,t){return ts(e.prev,e,e.next)<0?ts(e,t,e.next)>=0&&ts(e,e.prev,t)>=0:ts(e,t,e.prev)<0||ts(e,e.next,t)<0}function tht(e,t){let n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}function Sfe(e,t){let n=new o5(e.i,e.x,e.y),i=new o5(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function Efe(e,t,n,i){let r=new o5(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function iE(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function o5(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function nht(e,t,n,i){let r=0;for(let a=t,s=n-i;ae.toArray())).reduce(((e,t)=>(e.push(...t),e)),[]),n=[];return _fe.triangulate(t,[],3).forEach((e=>n.push(e))),n}static arePointsCoplanar(e){if(e.length<4)return!0;let t=e[1].clone().sub(e[0]),n=e[2].clone().sub(e[0]).cross(t).normalize();for(let i=3;irht)return!1;return!0}static isSelfIntersecting(e){let t=e.map((e=>e.toArray().slice(0,-1)));return(0,Mfe.default)(t).length>0}},ks=class{static getVisibleObjectBoundingBox(e){let t=new Ot;return e.traverse((e=>{e.visible&&(e instanceof xt||e instanceof hr)&&Hn.isObjectSelectable(e)&&t.expandByObject(e)})),t}static getObjectsBoundingBox(e,t,n){let i=new Ot;return t.forEach((t=>{let r=e.getObjectById(t);if(r){let e=ks.getBoundingBox(r,n);e.isEmpty()||i.union(e)}})),i}static getBoundingBox(e,t=!0){let n=new Ot;if(e instanceof Pi)return ks.getInstancedMeshBoundingBox(e);if(0===e.children.length)return n.expandByObject(e),n;let i=e.children.length,r=1;i>20&&(r=3),i>100&&(r=5),i>200&&(r=10),i>1e3&&(r=100),e.updateMatrixWorld(!1);for(let a=0;a{let t=e.material;Array.isArray(t)?t.forEach((e=>{e.clippingPlanes=[]})):t&&(t.clippingPlanes=[])}))}static addSection(e,t,n=!1,i=!1){e&&e.traverse((e=>{let r=e.material;Array.isArray(r)?r.forEach((e=>{Hu.setMaterialSection(e,t,n,i)})):r&&Hu.setMaterialSection(r,t,n,i)}))}static generateSectionPlanesByBox(e){let t=e.min,n=e.max;return[new Gr(new O(0,-1,0),n.y),new Gr(new O(0,1,0),-t.y),new Gr(new O(1,0,0),-t.x),new Gr(new O(-1,0,0),n.x)]}static generateSectionPlanesByPoints(e,t=!0){let n=e.length;if(n<2)return;let i=[];for(let r=0;r-1&&e.splice(n,1)}function sht(e,t){let n=t.position.distanceTo(e.position),i=0,r=[];for(let a=0,s=e.faces.length;a=0;a--)n.faces[a]&&n.faces[a].hasVertex(i)&&aht(n.faces[a],t);for(let a=n.faces.length-1;a>=0;a--)n.faces[a].replaceVertex(n,i);Afe(n,e);for(let a=0;a0?(new YA).modify(e,n):e}static getNumberOfVerticesToRemove(e,t){let n=0;e instanceof Dt&&e.index&&(n=e.attributes.position.count);let i=Math.floor(n*t);return n<20?0:i}},ZA=class extends an{constructor(e){super(),this.isSVGObject=!0,this.node=e}},AOt=10,Lfe=(e=>(e.TripleCross="TripleCross",e.Square="Square",e.Triangle="Triangle",e.CircleWithCross="CircleWithCross",e.Cross="Cross",e.Perpendicular="Perpendicular",e))(Lfe||{}),Ife=class{static createSVGObject(e){return new ZA(e)}},KA=class extends Tm{constructor(e){super(e),this.type=Rr}parse(e){let t=function(e,t){switch(e){case 1:console.error("THREE.RGBELoader Read Error: "+(t||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(t||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(t||""));break;default:console.error("THREE.RGBELoader: Error: "+(t||""))}return-1},n=function(e,t,n){t=t||1024;let i=e.pos,r=-1,a=0,s="",o=String.fromCharCode.apply(null,new Uint16Array(e.subarray(i,i+128)));for(;0>(r=o.indexOf("\n"))&&a=e.byteLength||!(i=n(e)))return t(1,"no header found");if(!(r=i.match(/^#\?(\S+)/)))return t(3,"bad initial token");for(h.valid|=1,h.programtype=r[1],h.string+=i+"\n";i=n(e),!1!==i;)if(h.string+=i+"\n","#"!==i.charAt(0)){if((r=i.match(a))&&(h.gamma=parseFloat(r[1])),(r=i.match(s))&&(h.exposure=parseFloat(r[1])),(r=i.match(o))&&(h.valid|=2,h.format=r[1]),(r=i.match(l))&&(h.valid|=4,h.height=parseInt(r[1],10),h.width=parseInt(r[2],10)),2&h.valid&&4&h.valid)break}else h.comments+=i+"\n";return 2&h.valid?4&h.valid?h:t(3,"missing image size specifier"):t(3,"missing format specifier")}(a);if(-1!==s){let e=s.width,n=s.height,o=function(e,n,i){let r=n;if(r<8||r>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(r!==(e[2]<<8|e[3]))return t(3,"wrong scanline width");let a=new Uint8Array(4*n*i);if(!a.length)return t(4,"unable to allocate buffer space");let s=0,o=0,l=4*r,h=new Uint8Array(4),c=new Uint8Array(l),u=i;for(;u>0&&oe.byteLength)return t(1);if(h[0]=e[o++],h[1]=e[o++],h[2]=e[o++],h[3]=e[o++],2!=h[0]||2!=h[1]||(h[2]<<8|h[3])!=r)return t(3,"bad rgbe scanline format");let n,i=0;for(;i128;if(r&&(n-=128),0===n||i+n>l)return t(3,"bad scanline data");if(r){let t=e[o++];for(let e=0;e{n.load(t,(t=>{if(e){let n=e.fromEquirectangular(t).texture;e.dispose(),i(n)}}))}))}))}static createEnvTextureFromDataArray(e){return ft(this,arguments,(function*(e,t=this.HDR_CITY_STREET_64x32,n=64,i=32){if(e){let r=new Sl(t,n,i);r.flipY=!0,r.magFilter=Ir,r.minFilter=Ir,r.type=Rr,r.version=1;let a=e.fromEquirectangular(r).texture;return e.dispose(),Promise.resolve(a)}return Promise.reject("Invalid pmremGenerator!")}))}};function cht(){if(Dn.isBrowser){let e=document.createElement("div");return e.setAttribute("style","height: 1in; visibility: hidden; position: absolute; margin: 0; padding: 0;"),document.body.appendChild(e),.0254/e.clientHeight}return.0254/96}Cc.HDR_CITY_STREET_64x32=Uint16Array.from([11910,12340,12797,15360,11926,12348,12806,15360,11958,12364,12814,15360,11974,12380,12830,15360,11958,12364,12822,15360,11926,12348,12797,15360,11878,12324,12773,15360,11830,12308,12749,15360,11798,12292,12733,15360,11782,12279,12725,15360,11765,12263,12709,15360,11749,12247,12701,15360,11733,12231,12701,15360,11701,12215,12693,15360,11685,12199,12685,15360,11685,12199,12685,15360,11701,12215,12693,15360,11717,12231,12701,15360,11733,12247,12709,15360,11749,12263,12717,15360,11749,12279,12717,15360,11765,12279,12725,15360,11765,12279,12725,15360,11765,12292,12725,15360,11798,12300,12733,15360,11830,12316,12749,15360,11846,12324,12757,15360,11894,12340,12781,15360,11926,12356,12797,15360,11942,12356,12797,15360,11926,12348,12789,15360,11926,12348,12789,15360,11942,12356,12797,15360,11942,12356,12797,15360,11942,12348,12806,15360,11942,12356,12806,15360,11942,12356,12814,15360,11958,12372,12830,15360,11974,12372,12830,15360,11974,12372,12838,15360,11990,12388,12854,15360,12055,12420,12886,15360,12119,12452,12918,15360,12167,12476,12950,15360,12231,12500,12982,15360,12263,12516,12998,15360,12231,12500,12974,15360,12199,12484,12958,15360,12199,12484,12958,15360,12199,12492,12966,15360,12247,12508,12982,15360,12247,12508,12990,15360,12231,12500,12982,15360,12199,12484,12966,15360,12167,12468,12942,15360,12119,12444,12918,15360,12087,12436,12902,15360,12055,12420,12886,15360,12055,12412,12878,15360,12039,12412,12878,15360,12022,12396,12862,15360,12006,12388,12846,15360,11958,12364,12830,15360,11910,12340,12806,15360,12119,12508,13103,15360,12087,12484,13071,15360,12055,12468,13046,15360,12006,12436,13006,15360,11926,12396,12958,15360,11878,12364,12926,15360,11846,12348,12894,15360,11782,12308,12854,15360,11749,12292,12830,15360,11717,12263,12814,15360,11685,12247,12806,15360,11669,12215,12789,15360,11685,12231,12789,15360,11701,12247,12797,15360,11701,12247,12806,15360,11717,12263,12814,15360,11749,12292,12822,15360,11782,12308,12838,15360,11798,12316,12846,15360,11814,12332,12862,15360,11846,12340,12870,15360,11862,12348,12878,15360,11846,12340,12870,15360,11846,12340,12862,15360,11878,12356,12886,15360,11910,12372,12910,15360,11942,12396,12934,15360,11958,12412,12958,15360,12039,12452,12998,15360,12071,12468,13022,15360,12039,12452,12998,15360,12039,12452,12998,15360,12006,12444,13006,15360,11974,12436,12998,15360,11942,12412,12982,15360,11926,12396,12974,15360,11926,12404,12974,15360,11958,12420,12998,15360,12006,12452,13038,15360,12055,12476,13071,15360,12039,12476,13079,15360,12087,12508,13127,15360,12247,12597,13231,15360,12388,12693,13332,15360,12420,12741,13364,15360,12436,12757,13372,15360,12468,12773,13380,15360,12500,12806,13388,15360,12516,12822,13404,15360,12629,12934,13452,15360,12741,13046,13508,15360,12806,13095,13532,15360,12757,13046,13516,15360,12645,12950,13460,15360,12565,12870,13428,15360,12532,12838,13412,15360,12549,12854,13412,15360,12516,12838,13396,15360,12452,12757,13356,15360,12420,12725,13340,15360,12404,12709,13332,15360,12372,12677,13316,15360,12279,12589,13207,15360,12135,12516,13119,15360,12388,12709,13348,15360,12247,12581,13223,15360,12055,12476,13087,15360,11910,12388,12982,15360,11733,12308,12886,15360,11669,12247,12846,15360,11621,12199,12814,15360,11541,12103,12765,15360,11492,12055,12733,15360,11508,12055,12733,15360,11476,12022,12717,15360,11525,12055,12725,15360,11589,12135,12757,15360,11669,12199,12765,15360,11765,12292,12814,15360,11862,12348,12886,15360,11910,12372,12910,15360,12006,12420,12966,15360,12071,12452,12998,15360,12119,12476,13022,15360,12167,12492,13046,15360,12183,12500,13063,15360,12199,12524,13079,15360,12308,12589,13151,15360,12300,12581,13151,15360,12167,12516,13087,15360,12087,12468,13030,15360,12022,12444,13014,15360,11990,12420,12990,15360,11974,12420,12990,15360,11974,12420,12990,15360,11990,12436,13014,15360,11990,12444,13030,15360,12103,12500,13103,15360,12087,12508,13111,15360,12039,12484,13103,15360,12039,12476,13103,15360,11942,12436,13054,15360,11974,12452,13087,15360,12039,12492,13135,15360,12103,12532,13199,15360,12183,12581,13263,15360,12308,12661,13340,15360,12484,12822,13436,15360,12613,12918,13484,15360,12725,13046,13540,15360,13046,13332,13677,15360,13143,13380,13717,15360,13223,13420,13741,15360,13396,13540,13862,15360,13436,13589,13902,15360,13484,13629,13942,15360,13468,13621,13934,15360,13412,13564,13878,15360,13372,13524,13846,15360,13287,13452,13781,15360,13223,13428,13749,15360,13340,13492,13805,15360,13239,13428,13749,15360,13095,13364,13685,15360,12918,13223,13597,15360,12822,13111,13556,15360,12613,12934,13468,15360,12532,12854,13428,15360,12565,12870,13444,15360,12468,12789,13396,15360,12372,12693,13340,15360,12087,12492,13111,15360,11846,12364,12958,15360,11717,12300,12878,15360,11557,12135,12781,15360,11476,12055,12741,15360,11460,12022,12725,15360,11476,12022,12725,15360,11476,12022,12709,15360,11476,11958,12605,15360,11364,11733,12332,15360,11111,11412,11661,15360,11223,11476,11773,15360,11388,11669,12095,15360,11765,12119,12492,15360,12388,12613,13079,15360,12661,12902,13356,15360,12998,13255,13564,15360,13372,13508,13797,15360,13412,13548,13846,15360,13287,13436,13725,15360,13271,13428,13709,15360,13287,13428,13717,15360,13014,13287,13597,15360,12709,12998,13460,15360,12452,12741,13332,15360,12364,12653,13271,15360,12404,12693,13316,15360,12420,12709,13316,15360,12420,12709,13332,15360,12263,12589,13231,15360,12332,12661,13312,15360,12300,12629,13295,15360,12263,12605,13287,15360,12231,12597,13279,15360,12247,12613,13303,15360,12231,12597,13295,15360,12231,12605,13312,15360,12199,12597,13324,15360,12231,12613,13340,15360,12516,12870,13468,15360,12725,13063,13564,15360,12741,13079,13573,15360,12854,13175,13613,15360,12902,13223,13629,15360,13046,13348,13693,15360,13356,13516,13846,15360,13605,13765,14078,15360,13717,13870,14191,15360,13765,13918,14255,15360,13765,13910,14247,15360,13701,13854,14191,15360,13573,13733,14070,15360,13508,13677,14006,15360,13380,13548,13886,15360,13111,13380,13741,15360,13063,13348,13709,15360,12886,13207,13629,15360,12725,13046,13548,15360,12645,12966,13508,15360,12677,12982,13508,15360,12629,12950,13492,15360,12452,12789,13412,15360,12324,12661,13332,15360,12356,12677,13340,15360,12388,12693,13348,15360,12279,12597,13247,15360,11894,12396,12998,15360,11637,12231,12846,15360,11573,12135,12789,15360,11589,12151,12797,15360,11621,12167,12797,15360,11637,12119,12677,15360,11079,11404,11693,15360,10517,10701,10653,15360,10252,10348,10007,15360,9902,9999,9428,15360,9846,9886,9047,15360,10135,10260,9685,15360,10412,10533,10412,15360,11268,11436,11549,15360,12364,12605,13087,15360,12444,12709,13255,15360,12549,12822,13348,15360,12613,12886,13396,15360,12597,12886,13412,15360,12581,12870,13404,15360,12661,12950,13460,15360,12725,13014,13492,15360,13079,13332,13645,15360,12757,13046,13500,15360,12677,12982,13476,15360,12854,13143,13556,15360,12693,12982,13492,15360,12581,12886,13452,15360,12709,13030,13508,15360,12372,12709,13364,15360,12324,12661,13348,15360,12292,12645,13340,15360,12292,12645,13348,15360,12468,12806,13436,15360,12532,12854,13460,15360,12500,12854,13468,15360,12500,12854,13484,15360,12725,13063,13589,15360,12982,13324,13701,15360,13111,13388,13741,15360,13014,13340,13709,15360,13014,13332,13717,15360,13287,13476,13862,15360,13436,13621,13974,15360,13532,13717,14095,15360,13725,13902,14295,15360,13942,14103,14420,15360,13974,14135,14436,15360,13862,14022,14388,15360,13725,13894,14295,15360,13789,13958,14336,15360,13830,13990,14348,15360,13372,13548,13942,15360,13014,13332,13733,15360,12886,13239,13661,15360,12854,13207,13637,15360,12757,13095,13589,15360,12757,13079,13573,15360,12645,12982,13516,15360,12629,12966,13532,15360,12549,12870,13468,15360,12356,12693,13372,15360,12151,12549,13231,15360,12215,12573,13247,15360,12199,12565,13231,15360,12071,12492,13135,15360,12055,12468,13087,15360,11878,12372,12958,15360,11685,12199,12781,15360,10774,11159,11412,15360,9533,9621,8870,15360,9308,9340,8071,15360,9276,9300,7878,15360,9324,9332,8420,15360,9191,9216,7991,15360,8950,8983,7766,15360,9493,9525,8677,15360,10252,10332,10007,15360,10661,10846,10894,15360,10701,10926,10998,15360,10950,11276,11428,15360,11364,11637,12063,15360,11958,12388,12926,15360,12183,12540,13175,15360,12340,12645,13295,15360,12420,12693,13316,15360,12757,13030,13460,15360,13046,13324,13645,15360,13095,13348,13677,15360,13303,13460,13781,15360,13207,13404,13741,15360,13127,13372,13717,15360,13372,13524,13862,15360,12693,13030,13540,15360,12725,13046,13548,15360,12468,12822,13436,15360,12263,12629,13348,15360,12436,12773,13428,15360,12693,12998,13524,15360,12725,13046,13564,15360,12645,12982,13556,15360,12613,12966,13556,15360,12886,13255,13685,15360,13436,13629,14022,15360,13637,13813,14231,15360,13621,13789,14215,15360,13878,14038,14412,15360,14022,14183,14468,15360,13926,14119,14452,15360,14054,14231,14508,15360,14135,14311,14540,15360,14348,14436,14669,15360,14460,14540,14749,15360,14404,14484,14709,15360,14420,14500,14709,15360,14653,14717,14894,15360,14119,14279,14508,15360,13484,13669,14078,15360,13063,13380,13773,15360,12677,13079,13613,15360,12484,12886,13516,15360,12436,12822,13476,15360,12468,12838,13476,15360,12039,12532,13316,15360,12231,12613,13340,15360,12468,12789,13436,15360,12388,12725,13396,15360,12135,12557,13287,15360,12151,12557,13271,15360,12039,12484,13175,15360,11878,12396,13038,15360,11814,12348,12950,15360,11492,11894,12460,15360,9950,10103,9621,15360,8830,8838,7220,15360,8565,8533,7015,15360,8541,8501,6919,15360,8332,8300,6822,15360,8412,8372,7220,15360,8710,8701,7686,15360,9372,9404,8549,15360,9533,9621,9079,15360,9268,9292,8196,15360,9452,9460,8167,15360,9533,9581,8533,15360,9742,9870,9316,15360,11460,11814,12348,15360,11942,12388,12902,15360,11749,12167,12573,15360,11300,11492,11621,15360,11974,12332,12669,15360,12436,12741,13364,15360,12597,12886,13460,15360,12966,13271,13653,15360,12998,13303,13669,15360,13476,13629,13974,15360,13733,13886,14239,15360,13364,13524,13894,15360,13063,13356,13725,15360,12982,13287,13669,15360,12484,12806,13444,15360,12565,12902,13500,15360,12950,13287,13693,15360,12934,13271,13677,15360,12693,13046,13589,15360,12661,13030,13605,15360,12870,13271,13717,15360,13348,13548,13966,15360,13621,13813,14271,15360,13797,13974,14412,15360,13942,14119,14484,15360,14263,14388,14629,15360,14420,14508,14733,15360,14460,14548,14773,15360,14982,15046,15231,15360,15564,15580,15669,15360,15974,15982,16078,15360,15805,15821,15926,15360,15460,15476,15572,15360,15436,15460,15556,15360,14781,14862,15127,15360,13621,13813,14348,15360,12789,13207,13757,15360,12452,12886,13581,15360,12263,12709,13476,15360,12039,12597,13396,15360,11942,12516,13340,15360,11846,12468,13271,15360,11733,12380,13127,15360,11926,12460,13191,15360,12055,12524,13263,15360,11878,12428,13159,15360,11605,12231,12886,15360,11412,11990,12709,15360,11508,12103,12789,15360,11637,12231,12854,15360,10661,11079,11380,15360,9541,9685,9252,15360,8573,8605,7493,15360,8404,8388,7348,15360,8830,8822,8212,15360,9308,9324,9095,15360,9324,9364,9220,15360,9047,9119,8653,15360,9023,9055,8404,15360,9055,9063,8167,15360,8870,8846,7541,15360,8862,8806,7380,15360,8950,8910,7252,15360,9268,9284,7557,15360,10316,10468,10380,15360,11239,11476,11677,15360,10653,10942,11047,15360,9661,9814,9324,15360,10693,10958,11047,15360,11396,11653,11990,15360,11878,12292,12597,15360,12468,12789,13396,15360,12773,13095,13589,15360,13364,13516,13894,15360,13894,14054,14380,15360,13717,13870,14247,15360,13420,13589,13958,15360,13255,13452,13830,15360,12806,13143,13637,15360,13159,13412,13830,15360,13629,13813,14215,15360,13303,13500,13910,15360,13079,13396,13805,15360,13191,13452,13878,15360,13412,13621,14062,15360,14103,14279,14540,15360,14773,14854,15086,15360,14717,14805,15046,15360,14295,14420,14685,15360,14380,14476,14733,15360,14572,14661,14902,15360,15596,15612,15701,15360,16351,16335,16384,15360,16484,16476,16492,15360,16516,16500,16516,15360,16388,16375,16404,15360,16054,16054,16118,15360,15918,15926,16006,15360,15556,15572,15669,15360,14653,14725,14982,15360,13637,13838,14319,15360,13412,13613,14054,15360,12870,13287,13789,15360,12404,12838,13524,15360,12199,12677,13428,15360,12324,12741,13452,15360,11942,12516,13324,15360,11765,12380,13111,15360,11428,11942,12589,15360,10886,11388,11902,15360,10372,10717,11006,15360,9846,10240,10191,15360,10252,10549,10766,15360,10613,11079,11484,15360,10581,10998,11388,15360,9613,9846,9629,15360,8525,8557,7541,15360,8605,8613,7814,15360,9292,9324,9079,15360,9388,9396,9220,15360,10709,10846,11031,15360,9894,9966,9854,15360,9252,9236,8774,15360,8822,8790,8183,15360,8292,8260,6533,15360,8111,8007,6324,15360,8228,8183,6405,15360,8501,8501,6565,15360,8814,8878,7172,15360,9260,9364,8244,15360,8902,9095,8252,15360,9444,9581,9047,15360,9509,9637,8790,15360,9477,9613,8806,15360,10725,11063,11079,15360,11508,11910,12356,15360,12484,12789,13380,15360,12838,13159,13629,15360,13428,13589,13974,15360,14135,14279,14484,15360,13942,14087,14396,15360,13677,13846,14247,15360,13436,13613,14006,15360,13597,13781,14183,15360,14183,14340,14540,15360,14022,14215,14484,15360,13637,13838,14271,15360,14038,14231,14508,15360,14380,14476,14701,15360,14757,14854,15078,15360,15030,15111,15343,15360,15420,15452,15556,15360,15476,15500,15588,15360,15351,15388,15492,15360,15572,15596,15677,15360,15653,15669,15717,15360,15821,15821,15853,15360,15845,15845,15869,15360,15998,15990,16022,15360,15926,15926,15974,15360,15653,15669,15733,15360,15661,15677,15749,15360,15612,15629,15717,15360,15271,15335,15452,15360,14484,14572,14821,15360,14215,14372,14588,15360,13468,13677,14167,15360,12773,13175,13653,15360,12725,13143,13637,15360,12452,12886,13532,15360,12263,12709,13444,15360,11894,12436,13103,15360,10252,10533,10661,15360,8613,8693,7445,15360,8742,8782,7047,15360,8420,8412,6565,15360,7926,7910,6405,15360,8806,8854,7300,15360,9127,9228,8007,15360,8685,8750,7300,15360,8348,8356,6758,15360,8380,8340,7300,15360,8991,8918,8388,15360,9838,9790,9549,15360,10055,10127,10047,15360,9501,9493,9268,15360,9332,9292,8902,15360,9079,9007,8509,15360,8300,8260,7252,15360,8693,8701,8196,15360,8228,8212,7111,15360,8469,8501,7380,15360,8420,8501,6919,15360,8549,8645,6983,15360,8581,8661,6951,15360,9268,9332,7718,15360,9063,9207,7445,15360,9284,9380,7718,15360,9412,9557,8693,15360,10276,10517,10103,15360,11830,12279,12589,15360,12725,13079,13589,15360,13127,13396,13773,15360,14087,14231,14460,15360,13974,14119,14412,15360,13677,13854,14247,15360,14119,14279,14500,15360,13990,14167,14460,15360,14364,14452,14653,15360,14564,14653,14837,15360,14404,14492,14701,15360,14870,14942,15135,15360,15388,15420,15500,15360,15207,15287,15420,15360,14797,14894,15127,15360,15271,15335,15452,15360,15926,15942,15990,15360,16207,16207,16231,15360,16118,16110,16126,15360,15741,15733,15741,15360,16239,16207,16175,15360,16444,16460,16484,15360,16046,16022,16006,15360,15942,15950,15966,15360,15773,15789,15829,15360,15789,15797,15845,15360,15693,15709,15757,15360,15540,15564,15653,15360,15303,15364,15468,15360,14733,14813,15014,15360,13862,14054,14420,15360,12838,13255,13725,15360,12789,13207,13693,15360,12468,12918,13564,15360,12404,12838,13500,15360,11428,11862,12412,15360,9143,9276,8388,15360,8541,8533,6726,15360,8444,8428,6629,15360,8212,8183,6597,15360,8388,8380,7015,15360,8726,8710,6758,15360,8332,8316,6437,15360,8453,8428,6565,15360,8597,8605,7814,15360,8701,8661,8151,15360,9452,9396,9015,15360,10581,10557,10380,15360,10950,10974,10846,15360,10380,10356,10252,15360,10749,10741,10685,15360,9870,9854,9693,15360,9023,9039,8669,15360,8790,8854,8509,15360,8196,8167,7332,15360,7975,8015,7079,15360,8589,8750,7445,15360,9095,9260,7111,15360,8983,9135,7188,15360,8902,8991,7252,15360,8862,9007,7015,15360,8967,9111,7300,15360,8742,8878,7493,15360,9557,9999,9549,15360,11292,11613,11862,15360,12135,12468,12982,15360,12215,12460,12878,15360,13356,13468,13685,15360,13821,13934,14199,15360,13548,13701,14022,15360,14103,14263,14468,15360,14279,14388,14572,15360,14364,14452,14645,15360,14709,14789,14950,15360,15143,15199,15327,15360,15388,15412,15468,15360,15476,15500,15548,15360,15420,15444,15492,15360,15436,15460,15516,15360,15612,15637,15685,15360,16086,16086,16110,15360,16396,16388,16396,15360,16094,16094,16110,15360,15869,15861,15861,15360,16135,16110,16070,15360,16428,16420,16404,15360,15588,15556,15524,15360,15484,15500,15508,15360,15335,15364,15396,15360,15677,15685,15717,15360,15604,15621,15661,15360,15420,15444,15500,15360,15303,15372,15452,15360,14717,14805,14998,15360,14412,14508,14701,15360,13548,13765,14199,15360,13271,13508,13942,15360,12661,13159,13709,15360,12468,12854,13436,15360,10260,10484,10509,15360,8613,8669,6951,15360,8151,8143,6469,15360,8653,8629,7814,15360,8469,8444,7541,15360,8718,8693,7814,15360,8372,8332,6597,15360,8356,8308,7111,15360,9047,8983,8396,15360,8822,8798,8308,15360,9372,9348,8967,15360,10364,10364,10183,15360,10268,10260,9894,15360,10541,10533,10468,15360,10380,10364,10276,15360,10621,10613,10549,15360,9910,9942,9758,15360,8364,8380,7621,15360,8581,8637,8135,15360,8252,8300,7573,15360,8119,8175,7300,15360,8372,8453,7493,15360,8420,8501,6983,15360,8742,8822,7573,15360,8782,8854,8151,15360,8581,8661,7079,15360,9220,9268,8340,15360,9549,9645,8854,15360,11717,11950,12127,15360,12468,12741,13207,15360,12709,12966,13388,15360,12300,12508,12886,15360,12492,12709,13063,15360,13239,13372,13548,15360,12476,12597,12814,15360,13581,13685,13878,15360,14476,14548,14685,15360,14556,14629,14773,15360,14765,14829,14966,15360,15159,15207,15303,15360,15372,15396,15444,15360,15516,15532,15572,15360,15653,15661,15693,15360,15829,15837,15853,15360,16022,16014,16022,15360,16311,16295,16279,15360,16343,16319,16303,15360,16412,16388,16359,15360,15813,15797,15773,15360,13063,13151,13183,15360,11484,11701,11798,15360,12300,12412,12468,15360,14613,14637,14653,15360,11974,12215,12316,15360,14135,14215,14303,15360,15604,15629,15677,15360,15524,15548,15596,15360,15351,15380,15428,15360,14797,14894,15054,15360,13990,14231,14500,15360,13492,13709,14070,15360,12886,13316,13701,15360,12613,13207,13749,15360,11525,11974,12428,15360,9284,9412,8629,15360,8597,8653,6951,15360,7806,7790,6292,15360,7589,7541,6437,15360,7485,7437,6597,15360,7453,7404,6180,15360,7774,7686,6565,15360,8300,8260,7332,15360,9918,9942,9862,15360,10348,10372,10231,15360,9725,9709,9228,15360,10613,10621,10509,15360,10199,10175,9838,15360,10380,10388,10340,15360,11207,11255,11284,15360,10661,10717,10725,15360,10103,10135,9950,15360,8444,8436,7669,15360,8469,8501,7445,15360,8950,9111,8854,15360,9485,9798,10071,15360,8364,8501,8039,15360,7959,7951,6806,15360,8597,8605,8039,15360,8501,8533,7557,15360,8758,8830,7509,15360,10758,10830,10693,15360,11508,11605,11621,15360,13524,13669,13886,15360,13830,14022,14327,15360,13926,14103,14364,15360,13460,13621,13886,15360,12854,13191,13420,15360,13597,13733,13926,15360,13846,13990,14223,15360,13773,13942,14199,15360,13910,14087,14356,15360,13813,14022,14319,15360,14247,14396,14540,15360,14693,14765,14878,15360,15223,15279,15343,15360,15508,15524,15540,15360,15540,15548,15564,15360,15327,15335,15319,15360,15303,15311,15303,15360,15918,15910,15886,15360,16247,16207,16151,15360,16175,16143,16086,15360,14436,14452,14436,15360,12263,12380,12404,15360,11476,11701,11773,15360,12380,12492,12532,15360,14797,14797,14757,15360,11372,11589,11677,15360,12597,12934,13356,15360,13990,14364,14725,15360,14183,14444,14773,15360,14231,14444,14717,15360,14412,14532,14709,15360,14054,14199,14380,15360,12372,12500,12605,15360,12199,12565,13006,15360,12581,13175,13653,15360,10055,10380,10324,15360,8557,8573,6726,15360,8167,8196,6533,15360,7517,7485,6119,15360,7244,7172,5798,15360,7071,6959,5718,15360,7669,7581,6260,15360,8661,8605,7975,15360,10942,11079,11151,15360,12573,12741,13014,15360,11902,12030,12191,15360,10308,10332,10135,15360,11255,11300,11284,15360,11276,11348,11396,15360,10055,10215,10292,15360,12183,12332,12468,15360,9918,9966,9798,15360,8734,8742,8196,15360,8967,8950,8469,15360,10260,10276,10039,15360,9734,9758,9605,15360,9388,9404,9308,15360,7943,7878,7095,15360,7726,7637,6645,15360,8047,7983,7204,15360,9284,9236,8693,15360,9621,9565,9143,15360,11255,11268,11047,15360,13175,13332,13420,15360,13773,13934,14175,15360,13854,14022,14271,15360,13870,14038,14279,15360,13388,13516,13677,15360,12279,12629,12966,15360,13348,13452,13564,15360,13821,13918,14054,15360,13701,13846,14022,15360,13460,13605,13781,15360,13492,13637,13821,15360,13709,13821,13950,15360,14372,14428,14476,15360,14516,14572,14613,15360,14741,14789,14813,15360,14725,14749,14749,15360,13452,13484,13468,15360,13476,13500,13492,15360,14990,15022,15022,15360,14556,14572,14564,15360,15094,15111,15094,15360,13231,13287,13215,15360,11255,11380,11175,15360,10677,10886,10492,15360,11846,12006,11934,15360,14327,14340,14279,15360,10766,11039,10862,15360,12918,13255,13452,15360,14231,14548,14886,15360,13878,14380,14765,15360,13444,13862,14412,15360,12151,12404,12621,15360,12637,12902,13215,15360,11549,11749,11870,15360,12279,12653,13119,15360,13223,13404,13516,15360,9228,9260,8276,15360,8087,7991,6308,15360,7918,7814,6919,15360,7469,7364,6148,15360,7485,7380,6212,15360,8228,7991,7204,15360,9276,8967,8212,15360,9806,9573,8742,15360,10135,10087,9621,15360,11452,11452,11452,15360,10629,10637,10509,15360,10693,10733,10637,15360,11095,11111,10982,15360,11292,11348,11372,15360,10199,10244,10167,15360,10814,10926,10846,15360,8669,8774,7493,15360,7870,7910,6244,15360,8204,8183,6919,15360,9806,9758,9159,15360,9460,9436,8629,15360,9159,9087,8260,15360,7637,7509,6790,15360,7758,7629,6838,15360,7967,7918,6774,15360,10854,10749,10501,15360,11508,11412,11316,15360,12372,12300,12151,15360,12030,12119,12063,15360,12781,12910,12982,15360,13476,13581,13661,15360,13484,13589,13677,15360,12404,12428,12380,15360,11605,11765,11798,15360,11492,11533,11452,15360,11838,11886,11798,15360,12263,12372,12380,15360,12151,12231,12175,15360,11492,11508,11412,15360,11119,11111,10838,15360,12508,12581,12573,15360,12621,12693,12677,15360,12573,12629,12589,15360,12292,12324,12231,15360,12476,12565,12573,15360,11998,12159,12215,15360,12950,13071,13159,15360,12263,12372,12428,15360,12380,12428,12444,15360,11300,11308,11143,15360,10199,10244,9734,15360,9709,9701,9252,15360,10492,10581,10404,15360,11476,11516,11388,15360,9477,9517,8790,15360,11717,11854,11838,15360,14247,14420,14524,15360,14054,14311,14436,15360,13597,13805,13982,15360,11364,11533,11597,15360,12263,12428,12549,15360,11436,11605,11653,15360,13079,13324,13444,15360,12516,12613,12605,15360,10039,10015,9605,15360,8693,8621,7878,15360,7951,7862,6902,15360,8196,8204,7015,15360,8677,8589,7637,15360,9284,9031,8340,15360,9814,9605,8902,15360,10685,10428,9910,15360,10492,10260,9685,15360,9404,9252,7943,15360,8830,8766,7220,15360,9220,9047,7943,15360,9693,9669,9015,15360,11412,11468,11372,15360,11135,11159,11023,15360,10087,10055,9428,15360,9910,10007,9621,15360,9236,9300,8934,15360,9597,9557,8902,15360,10669,10549,9782,15360,9926,9870,9127,15360,9894,9918,9047,15360,8685,8742,7910,15360,9958,10167,10284,15360,10215,10332,10396,15360,11396,11428,11452,15360,11223,11255,11300,15360,11814,11862,11958,15360,10685,10846,10870,15360,10340,10380,10007,15360,11175,11207,10894,15360,12103,12207,12215,15360,11143,11103,10902,15360,9910,9966,9613,15360,10015,10079,9493,15360,10806,10846,10517,15360,10862,10934,10637,15360,10838,10942,10661,15360,10958,11087,10878,15360,10709,10838,10701,15360,10669,10741,10589,15360,10581,10669,10525,15360,10252,10348,9974,15360,11396,11500,11525,15360,11207,11255,11264,15360,10878,10910,10934,15360,11031,11063,11159,15360,11292,11324,11396,15360,11223,11255,11300,15360,10693,10685,10645,15360,10428,10420,10324,15360,10300,10252,9991,15360,10838,10846,10798,15360,10428,10428,10364,15360,9669,9605,9380,15360,10167,10244,10087,15360,11709,11854,11910,15360,11223,11284,11268,15360,10231,10244,9878,15360,10199,10244,9862,15360,10183,10260,9942,15360,10525,10653,10541,15360,12500,12597,12621,15360,11814,11741,11597,15360,11533,11460,11175,15360,11103,11006,10557,15360,10444,10396,9846,15360,10007,10023,9228,15360,9653,9790,8469,15360,9316,9372,8039,15360,9557,9830,8071,15360,9621,9918,8071,15360,9677,10015,8167,15360,9991,10284,8420,15360,10215,10436,8581,15360,10260,10484,8645,15360,10292,10476,8902,15360,10324,10468,9252,15360,9910,9894,8886,15360,10525,10573,9701,15360,9782,10039,8581,15360,9565,9814,8167,15360,9950,10039,8934,15360,10749,10758,10199,15360,10669,10685,10244,15360,10838,10838,10460,15360,11215,10910,10087,15360,11492,11364,10806,15360,11095,11159,11055,15360,11364,11388,11356,15360,11023,11039,10990,15360,11653,11653,11613,15360,11798,11725,11557,15360,11974,11862,11637,15360,12039,11942,11765,15360,12119,12047,11934,15360,12151,12071,11950,15360,12087,12006,11886,15360,12047,11966,11838,15360,11990,11926,11790,15360,11974,11910,11798,15360,11998,11934,11814,15360,12111,12039,11886,15360,12231,12143,11998,15360,12292,12199,12039,15360,12039,11974,11846,15360,11822,11782,11653,15360,11862,11838,11765,15360,11798,11765,11701,15360,11782,11733,11669,15360,11798,11749,11685,15360,11838,11790,11725,15360,11870,11822,11749,15360,11741,11701,11621,15360,11565,11541,11452,15360,11533,11500,11412,15360,11621,11581,11484,15360,11605,11557,11460,15360,11516,11468,11372,15360,11565,11533,11444,15360,11677,11637,11541,15360,11725,11661,11557,15360,11725,11661,11557,15360,11733,11669,11573,15360,11838,11773,11677,15360,11998,11926,11814,15360,12014,11926,11798,15360,11460,11404,11332,15360,11637,11557,11428,15360,12014,11894,11693,15360,12167,12022,11765,15360,12119,11982,11709,15360,11926,11806,11516,15360,11685,11589,11300,15360,11476,11404,10886,15360,11239,11151,10468,15360,10766,10733,9894,15360,10565,10565,9589,15360,10436,10444,9332,15360,10308,10308,9031,15360,10308,10316,8999,15360,10199,10244,8774,15360,9725,9645,8549,15360,10244,10276,8967,15360,10878,10838,10183,15360,11055,10966,10348,15360,11119,11006,10404,15360,11264,11135,10565,15360,11404,11316,10822,15360,11492,11388,10982,15360,11798,11613,11223,15360,12047,11830,11412,15360,12039,11894,11597,15360,12127,11990,11693,15360,12127,11990,11725,15360,12191,12055,11806,15360,12191,12055,11830,15360,11870,11773,11613,15360,11573,11516,11428,15360,11533,11484,11412,15360,11541,11492,11420,15360,11565,11516,11452,15360,11589,11541,11476,15360,11605,11557,11500,15360,11637,11589,11533,15360,11669,11621,11557,15360,11701,11645,11573,15360,11733,11669,11589,15360,11798,11717,11605,15360,11838,11749,11621,15360,11878,11782,11661,15360,11894,11798,11661,15360,11926,11806,11653,15360,11958,11822,11661,15360,11982,11846,11677,15360,12006,11870,11685,15360,12095,11950,11765,15360,12047,11910,11741,15360,11886,11765,11605,15360,11838,11733,11589,15360,11814,11717,11589,15360,11814,11709,11573,15360,11790,11693,11565,15360,11741,11677,11589,15360,11733,11677,11613,15360,11733,11685,11629,15360,11717,11669,11621,15360,11685,11645,11589,15360,11629,11589,11533,15360,11573,11525,11468,15360,11492,11444,11380,15360,11316,11255,11111,15360,11348,11292,11143,15360,11516,11436,11316,15360,11854,11749,11589,15360,12127,11990,11765,15360,12199,12055,11782,15360,12340,12231,11910,15360,12372,12292,11958,15360,12380,12300,11974,15360,12348,12247,11910,15360,12324,12215,11878,15360,12247,12103,11773,15360,12095,11958,11637,15360,12055,11926,11613,15360,11974,11854,11541,15360,11870,11765,11468,15360,11966,11854,11541,15360,12300,12151,11846,15360,12396,12316,12006,15360,12388,12308,11990,15360,12388,12308,12006,15360,12396,12316,12022,15360,12396,12308,12022,15360,12396,12308,12022,15360,12364,12279,11974,15360,12340,12247,11942,15360,12340,12231,11926,15360,12215,12071,11806,15360,12095,11966,11749,15360,11741,11645,11500,15360,11420,11356,11255,15360,11364,11308,11207,15360,11356,11300,11175,15360,11348,11292,11191,15360,11372,11324,11255,15360,11412,11364,11308,15360,11420,11372,11316,15360,11428,11380,11324,15360,11444,11388,11332,15360,11484,11428,11364,15360,11508,11460,11396,15360,11557,11500,11436,15360,11589,11533,11460,15360,11613,11557,11484,15360,11621,11557,11492,15360,11613,11557,11500,15360,11621,11557,11500,15360,11629,11573,11508,15360,11629,11573,11508,15360,11605,11557,11484,15360,11589,11533,11468,15360,11557,11508,11436,15360,11549,11500,11428,15360,11557,11500,11436,15360,11549,11492,11436,15360,11533,11484,11428,15360,11525,11476,11428,15360,11516,11476,11428,15360,11525,11484,11444,15360,11516,11476,11428,15360,11468,11428,11380,15360,11428,11388,11332,15360,11356,11308,11239,15360,11308,11255,11127,15360,11167,11071,10926,15360,11223,11119,10966,15360,11276,11175,10998,15360,11404,11332,11191,15360,11773,11693,11557,15360,11926,11798,11613,15360,12207,12039,11773,15360,12348,12231,11894,15360,12308,12151,11846,15360,12332,12215,11894,15360,12364,12279,11958,15360,12380,12292,11974,15360,12396,12316,12022,15360,12404,12316,12039,15360,12412,12332,12087,15360,12412,12332,12103,15360,12436,12356,12135,15360,12372,12292,12039,15360,12420,12332,12087,15360,12396,12316,12055,15360,12356,12263,11990,15360,12340,12231,11942,15360,12271,12127,11854,15360,12215,12071,11814,15360,12292,12135,11878,15360,12288,12135,11870,15360,12111,11982,11765,15360,11990,11886,11717,15360,11637,11557,11428,15360,11364,11300,11143,15360,11316,11239,11079,15360,11300,11207,11047,15360,11268,11159,11015,15360,11268,11159,11015,15360,11268,11159,11031,15360,11300,11223,11095,15360,11340,11292,11191,15360,11348,11300,11223,15360,11372,11324,11255,15360,11380,11332,11255,15360,11372,11316,11239,15360,11396,11340,11268,15360,11468,11404,11300,15360,11460,11404,11324,15360,11484,11428,11356,15360,11492,11436,11372,15360,11500,11444,11388,15360,11508,11460,11404,15360,11500,11452,11396,15360,11492,11436,11380,15360,11468,11412,11356,15360,11444,11388,11324,15360,11444,11388,11324,15360,11428,11380,11316,15360,11412,11356,11300,15360,11404,11348,11300,15360,11404,11356,11308,15360,11396,11356,11308,15360,11388,11348,11308,15360,11372,11340,11292,15360,11348,11308,11255,15360,11284,11223,11111,15360,11231,11143,11023,15360,11199,11111,10974,15360,11047,10958,10814,15360,11127,11023,10870,15360,11119,11006,10846,15360,11175,11055,10886,15360,11292,11191,10998,15360,11525,11404,11284,15360,11822,11637,11476,15360,11878,11733,11549,15360,11918,11790,11573,15360,12063,11918,11653,15360,12223,12063,11765,15360,12300,12151,11846,15360,12255,12103,11814,15360,12271,12127,11846,15360,12271,12127,11862,15360,12271,12127,11886,15360,12308,12183,11942,15360,12175,12039,11814,15360,12063,11934,11709,15360,12159,12014,11765,15360,12215,12063,11798,15360,12143,11998,11757,15360,12071,11934,11693,15360,11998,11870,11661,15360,11974,11870,11685,15360,11998,11910,11757,15360,11846,11765,11629,15360,11468,11396,11284,15360,11308,11223,11031,15360,11215,11103,10934,15360,11207,11095,10942,15360,11215,11103,10950,15360,11191,11087,10942,15360,11175,11079,10942,15360,11167,11063,10934,15360,11143,11031,10902,15360,11247,11143,11015,15360,11284,11191,11079,15360,11300,11223,11095,15360,11316,11268,11127,15360,11340,11284,11143,15360,11340,11284,11159,15360,11356,11300,11191,15360,11372,11316,11239,15360,11380,11324,11255,15360,11372,11316,11255,15360,11380,11324,11276,15360,11380,11324,11268,15360,11372,11316,11255,15360,11364,11316,11255,15360,11364,11308,11239,15360,11348,11292,11207,15360,11340,11284,11191,15360,11348,11292,11191,15360,11348,11292,11207,15360,11340,11292,11207,15360,11340,11292,11207,15360,11324,11276,11207,15360,11308,11255,11175,15360,11264,11175,11079,15360,11119,11039,10934,15360,11103,11015,10902,15360,11095,11006,10878,15360,11031,10942,10806,15360,10990,10902,10766,15360,11047,10942,10814,15360,11031,10926,10790,15360,11055,10942,10806,15360,11119,10998,10846,15360,11151,11015,10830,15360,11268,11095,10886,15360,11484,11396,11268,15360,11790,11701,11549,15360,11886,11790,11637,15360,11838,11741,11581,15360,11838,11725,11541,15360,11902,11782,11581,15360,11966,11838,11629,15360,11974,11846,11629,15360,11958,11838,11629,15360,11950,11838,11637,15360,11814,11701,11525,15360,11581,11492,11332,15360,11645,11541,11380,15360,11806,11701,11533,15360,11902,11806,11637,15360,11950,11862,11717,15360,12014,11934,11790,15360,11942,11862,11725,15360,11565,11492,11388,15360,11292,11191,11015,15360,11231,11111,10950,15360,11159,11047,10894,15360,11119,11006,10854,15360,11127,11023,10878,15360,11159,11055,10902,15360,11135,11031,10894,15360,11111,11006,10878,15360,11095,10990,10870,15360,11095,10998,10886,15360,11071,10966,10846,15360,11111,11006,10902,15360,11191,11095,10974,15360,11268,11159,11031,15360,11284,11191,11063,15360,11292,11207,11063,15360,11300,11223,11079,15360,11332,11268,11143,15360,11316,11255,11127,15360,11316,11255,11143,15360,11308,11239,11127,15360,11316,11255,11159,15360,11300,11223,11127,15360,11292,11207,11095,15360,11300,11223,11111,15360,11300,11223,11095,15360,11300,11223,11095,15360,11308,11239,11111,15360,11300,11223,11111,15360,11292,11207,11111,15360,11264,11167,11071,15360,11215,11127,11047,15360,11135,11055,10966,15360,11015,10934,10846,15360,10918,10838,10733,15360,10982,10894,10782,15360,10974,10886,10766,15360,10982,10894,10766,15360,10958,10862,10749,15360,10982,10886,10774,15360,10958,10862,10758,15360,10958,10862,10749,15360,11015,10910,10790,15360,11023,10910,10774,15360,11079,10958,10806,15360,11103,10974,10798,15360,11191,11047,10846,15360,11468,11388,11276,15360,11846,11765,11637,15360,12006,11918,11782,15360,11998,11910,11782,15360,11902,11822,11693,15360,11838,11749,11637,15360,11782,11709,11605,15360,11806,11741,11645,15360,11782,11717,11629,15360,11773,11717,11621,15360,11870,11806,11701,15360,11942,11862,11757,15360,12183,12103,11974,15360,11974,11894,11765,15360,11476,11404,11308,15360,11268,11143,10966,15360,11183,11063,10902,15360,11111,10998,10854,15360,11055,10942,10806,15360,11023,10910,10766,15360,11047,10934,10782,15360,11039,10926,10782,15360,11079,10966,10830,15360,11031,10918,10782,15360,11031,10926,10806,15360,10990,10894,10782,15360,10974,10886,10790,15360,10966,10870,10774,15360,11006,10902,10806,15360,11039,10942,10838,15360,11127,11023,10910,15360,11175,11079,10958,15360,11191,11087,10958,15360,11207,11095,10958,15360,11268,11143,11015,15360,11276,11175,11047,15360,11284,11191,11079,15360,11292,11191,11079,15360,11276,11175,11079,15360,11239,11135,11031,15360,11268,11159,11047,15360,11215,11111,11006,15360,11239,11127,11015,15360,11255,11143,11031,15360,11223,11119,11015,15360,11199,11103,10998,15360,11175,11087,10982,15360,11143,11047,10958,15360,11031,10942,10854,15360,10958,10878,10790,15360,10910,10830,10741,15360,10942,10862,10758,15360,10926,10838,10733,15360,10854,10758,10637,15360,10918,10830,10709,15360,10910,10822,10717,15360,10942,10846,10749,15360,10942,10854,10741,15360,10942,10854,10749,15360,10966,10870,10758,15360,10966,10870,10758,15360,10958,10854,10733,15360,10998,10886,10741,15360,10942,10830,10677,15360,11039,10918,10749,15360,11095,10974,10806,15360,11308,11223,11031,15360,11468,11396,11292,15360,11605,11533,11428,15360,11701,11621,11525,15360,11693,11629,11541,15360,11685,11621,11549,15360,11685,11629,11549,15360,11629,11565,11484,15360,11589,11533,11444,15360,11364,11308,11191,15360,11191,11087,10958,15360,11135,11031,10902,15360,11135,11031,10894,15360,11055,10950,10830,15360,11015,10910,10782,15360,10958,10854,10733,15360,10942,10838,10717,15360,10974,10870,10733,15360,10982,10878,10749,15360,10990,10886,10758,15360,11015,10910,10798,15360,10966,10862,10758,15360,10950,10854,10758,15360,10910,10822,10733,15360,10894,10798,10709,15360,10902,10814,10725,15360,10934,10846,10758,15360,10910,10822,10733,15360,10950,10854,10749,15360,10974,10878,10766,15360,11047,10942,10830,15360,11095,10990,10878,15360,11167,11055,10942,15360,11199,11103,10990,15360,11191,11087,10982,15360,11151,11047,10950,15360,11135,11031,10934,15360,11095,10998,10902,15360,11143,11047,10950,15360,11079,10990,10894,15360,11079,10990,10902,15360,11103,11006,10910,15360,11079,10982,10886,15360,11023,10926,10822,15360,10982,10894,10798,15360,10958,10870,10782,15360,10910,10814,10725,15360,10926,10838,10741,15360,10934,10838,10733,15360,10950,10854,10749,15360,10886,10798,10709,15360,10910,10814,10709,15360,10926,10830,10725,15360,10910,10814,10701,15360,10862,10774,10677,15360,10950,10854,10733,15360,10926,10830,10717,15360,10926,10838,10725,15360,10926,10830,10725,15360,10894,10798,10685,15360,10926,10830,10701,15360,10958,10854,10717,15360,10934,10830,10685,15360,10950,10846,10709,15360,10974,10862,10717,15360,10942,10830,10685,15360,10958,10846,10701,15360,11006,10894,10749,15360,10950,10846,10725,15360,10958,10862,10741,15360,10894,10806,10701,15360,10854,10774,10669,15360,10886,10806,10701,15360,10862,10790,10693,15360,10878,10806,10717,15360,10982,10902,10798,15360,10990,10902,10798,15360,10950,10862,10758,15360,10942,10846,10733,15360,10870,10774,10669,15360,10894,10798,10693,15360,10918,10830,10725,15360,10894,10806,10701,15360,10926,10830,10733,15360,10902,10830,10725,15360,10870,10790,10693,15360,10886,10814,10725,15360,10814,10741,10661,15360,10838,10766,10677,15360,10822,10741,10661,15360,10822,10741,10669,15360,10862,10790,10709,15360,10846,10758,10669,15360,10894,10798,10693,15360,10974,10878,10766,15360,10966,10870,10766,15360,11023,10926,10814,15360,11079,10974,10862,15360,11006,10910,10814,15360,10950,10862,10766,15360,10982,10894,10798,15360,10958,10862,10774,15360,10958,10870,10782,15360,10910,10830,10741,15360,10950,10862,10766,15360,10982,10886,10790,15360,10918,10822,10725,15360,10886,10798,10701,15360,10854,10766,10669,15360,10894,10806,10709,15360,10926,10830,10725,15360,10926,10830,10725,15360,10958,10862,10749,15360,10958,10862,10749,15360,10894,10806,10717,15360,10902,10814,10717,15360,10878,10790,10677,15360,10942,10838,10717,15360,10918,10814,10701,15360,10886,10790,10661,15360,10942,10838,10717,15360,10950,10854,10725,15360,10950,10854,10725,15360,10910,10814,10693,15360,10910,10814,10685,15360,10942,10838,10709,15360,10894,10790,10661,15360,10910,10806,10669,15360,10822,10725,10597,15360,10749,10661,10541,15360,10830,10733,10613,15360,10838,10741,10629,15360,10806,10709,10597,15360,10854,10766,10653,15360,10862,10774,10669,15360,10798,10725,10629,15360,10822,10749,10653,15360,10854,10782,10693,15360,10806,10741,10661,15360,10862,10790,10701,15360,10870,10790,10685,15360,10870,10790,10693,15360,10878,10790,10677,15360,10862,10782,10677,15360,10870,10790,10693,15360,10870,10782,10685,15360,10894,10814,10709,15360,10886,10814,10709,15360,10846,10782,10685,15360,10741,10669,10573,15360,10766,10693,10589,15360,10709,10637,10541,15360,10741,10669,10589,15360,10741,10677,10589,15360,10709,10637,10557,15360,10774,10701,10613,15360,10862,10774,10677,15360,11006,10918,10806,15360,11006,10902,10782,15360,10974,10870,10749,15360,10958,10854,10733,15360,10934,10838,10725,15360,10934,10838,10733,15360,10934,10838,10725,15360,10886,10790,10685,15360,10854,10766,10661,15360,10886,10798,10701,15360,10838,10749,10645,15360,10878,10782,10661,15360,10822,10725,10613,15360,10822,10717,10605,15360,10846,10749,10629,15360,10854,10749,10637,15360,10950,10854,10733,15360,10958,10854,10741,15360,10910,10806,10693,15360,10926,10822,10693,15360,10934,10838,10725,15360,10910,10822,10709,15360,10910,10822,10709,15360,10886,10782,10661,15360,10910,10814,10677,15360,10910,10806,10677,15360,10926,10822,10685,15360,10958,10854,10717,15360,10974,10870,10725,15360,10926,10830,10693,15360,10926,10830,10693,15360,10918,10822,10693,15360,10934,10838,10701,15360,10918,10814,10685,15360,10878,10782,10653,15360,10870,10774,10645,15360,10838,10749,10629,15360,10806,10717,10605,15360,10822,10733,10621,15360,10822,10733,10621,15360,10846,10758,10653,15360,10846,10766,10653,15360,10822,10741,10629,15360,10806,10733,10629,15360,10806,10725,10621,15360,10790,10709,10605,15360,10766,10693,10589,15360,10814,10741,10629,15360,10846,10766,10653,15360,10838,10758,10653,15360,10878,10790,10677,15360,10894,10798,10685,15360,10830,10741,10629,15360,10830,10758,10653,15360,10798,10725,10629,15360,10806,10733,10629,15360,10717,10637,10525,15360,10661,10581,10476,15360,10701,10621,10517,15360,10733,10661,10565,15360,10782,10685,10557,15360,10862,10758,10613,15360,10974,10862,10725,15360,10958,10846,10709,15360,11006,10902,10766,15360,11006,10902,10774,15360,11039,10934,10814,15360,11006,10902,10790,15360,11006,10910,10790,15360,10950,10854,10741,15360,10934,10830,10709,15360,10918,10814,10701,15360,10854,10758,10653,15360,10918,10814,10701,15360,10870,10766,10645,15360,10830,10733,10621,15360,10934,10830,10709,15360,10990,10886,10758,15360,10950,10838,10717,15360,10910,10814,10701,15360,10926,10822,10693,15360,10934,10830,10709,15360,10878,10774,10653,15360,10934,10830,10701,15360,10926,10822,10693,15360,10878,10782,10661,15360,10878,10782,10661,15360,10862,10766,10621,15360,10886,10782,10645,15360,10886,10782,10653,15360,10926,10822,10701,15360,10902,10806,10685,15360,10926,10822,10701,15360,10918,10814,10685,15360,10878,10782,10645,15360,10910,10806,10669,15360,10854,10758,10621,15360,10886,10790,10645,15360,10854,10758,10629,15360,10830,10741,10613,15360,10918,10814,10685,15360,10862,10766,10645,15360,10830,10741,10613,15360,10806,10717,10597,15360,10741,10661,10557,15360,10774,10693,10581,15360,10749,10669,10557,15360,10774,10693,10581,15360,10766,10685,10573,15360,10790,10709,10597,15360,10782,10701,10589,15360,10790,10709,10597,15360,10838,10749,10621,15360,10870,10774,10645,15360,10894,10790,10661,15360,10878,10782,10653,15360,10846,10741,10613,15360,10790,10693,10557,15360,10814,10717,10597,15360,10790,10701,10581,15360,10741,10645,10525,15360,10717,10629,10509,15360,10774,10685,10573,15360,10725,10637,10525,15360,10854,10749,10621,15360,10950,10846,10701,15360,10966,10854,10709,15360,10934,10814,10677,15360,10926,10822,10701,15360,10982,10878,10766,15360,10998,10894,10782,15360,10990,10878,10766,15360,10998,10894,10782,15360,10998,10886,10774,15360,10998,10886,10758,15360,11006,10894,10774,15360,10942,10838,10733,15360,10958,10854,10741,15360,10958,10854,10749,15360,11006,10902,10790,15360,11015,10902,10798,15360,10982,10870,10758,15360,10998,10894,10782,15360,10974,10870,10758,15360,11006,10902,10790,15360,10998,10894,10774,15360,10974,10870,10758,15360,10950,10854,10741,15360,10878,10790,10693,15360,10902,10814,10701,15360,10918,10822,10709,15360,10838,10733,10613,15360,10878,10782,10661,15360,10934,10838,10717,15360,10902,10806,10693,15360,10918,10822,10709,15360,10926,10830,10709,15360,10838,10733,10605,15360,10910,10806,10661,15360,10942,10838,10693,15360,10886,10782,10645,15360,10886,10782,10637,15360,10854,10749,10621,15360,10926,10830,10709,15360,10966,10862,10741,15360,10846,10749,10629,15360,10830,10733,10605,15360,10854,10758,10637,15360,10822,10725,10605,15360,10886,10790,10661,15360,10902,10806,10669,15360,10918,10814,10677,15360,10830,10733,10605,15360,10806,10717,10589,15360,10870,10774,10645,15360,10934,10838,10709,15360,10958,10862,10733,15360,10886,10790,10661,15360,10894,10798,10661,15360,10958,10854,10709,15360,10934,10830,10709,15360,10814,10717,10581,15360,10862,10758,10613,15360,10854,10741,10589,15360,10814,10717,10573,15360,10886,10782,10645,15360,10814,10725,10597,15360,10862,10766,10637,15360,10910,10806,10669,15360,10942,10838,10709,15360,10966,10862,10733,15360,10974,10870,10741,15360,10974,10870,10749,15360,10958,10862,10749,15360,11031,10934,10822,15360,10998,10894,10782,15360,10974,10870,10766,15360,11023,10918,10814,15360,11039,10926,10822,15360,10958,10846,10741,15360,10918,10814,10693,15360,10966,10870,10741,15360,10982,10886,10766,15360,10982,10878,10766,15360,10942,10846,10733,15360,10958,10862,10758,15360,10950,10854,10758,15360,10934,10830,10717,15360,10966,10862,10733,15360,10942,10846,10725,15360,10934,10846,10733,15360,10934,10846,10733,15360,10878,10798,10693,15360,10886,10798,10693,15360,10910,10814,10709,15360,10942,10846,10733,15360,10838,10733,10597,15360,10878,10774,10645,15360,10918,10822,10701,15360,10878,10782,10653,15360,10894,10790,10661,15360,10934,10838,10725,15360,10958,10854,10725,15360,10966,10862,10733,15360,10910,10806,10685,15360,10982,10878,10758,15360,10942,10854,10749,15360,10934,10838,10733,15360,10918,10814,10701,15360,10894,10798,10669,15360,10894,10798,10669,15360,10814,10725,10605,15360,10902,10798,10669,15360,10814,10725,10605,15360,10894,10798,10685,15360,10958,10862,10749,15360,10910,10814,10701,15360,10910,10806,10685,15360,10918,10814,10693,15360,10926,10822,10709,15360,10894,10790,10661,15360,10902,10806,10677,15360,10902,10806,10685,15360,10934,10838,10717,15360,10934,10838,10701,15360,10934,10838,10717,15360,10950,10854,10725,15360,10894,10798,10661,15360,10862,10749,10597,15360,10894,10798,10677,15360,10878,10782,10661,15360,10926,10838,10717,15360,10926,10838,10717,15360,10918,10822,10709,15360,10934,10838,10733,15360,10926,10838,10733,15360,10958,10870,10766,15360,10942,10854,10749,15360,10958,10870,10774,15360,10974,10878,10774,15360,10958,10854,10741,15360,10950,10846,10741,15360,10950,10854,10758,15360,10934,10838,10733,15360,10942,10846,10725,15360,10966,10862,10741,15360,10926,10838,10733,15360,10958,10862,10749,15360,10910,10822,10709,15360,10942,10854,10758,15360,10926,10838,10733,15360,10910,10822,10717,15360,10934,10838,10733,15360,10934,10846,10733,15360,10902,10814,10709,15360,10926,10830,10717,15360,10918,10822,10709,15360,10838,10749,10637,15360,10878,10790,10677,15360,10942,10846,10733,15360,10926,10822,10701,15360,10958,10862,10749,15360,10886,10790,10685,15360,10918,10814,10693,15360,10910,10814,10693,15360,10902,10806,10701,15360,10878,10774,10637,15360,10798,10693,10565,15360,10822,10725,10597,15360,10934,10838,10709,15360,10958,10854,10725,15360,10886,10790,10669,15360,10910,10806,10677,15360,10886,10782,10645,15360,10830,10725,10597,15360,10822,10717,10581,15360,10862,10758,10637,15360,10878,10782,10669,15360,10926,10822,10709,15360,10974,10878,10774,15360,10966,10870,10758,15360,10918,10822,10709,15360,10846,10749,10645,15360,10894,10798,10693,15360,10918,10822,10709,15360,10974,10878,10774,15360,10918,10822,10717,15360,10982,10886,10774,15360,10974,10878,10758,15360,10950,10854,10741,15360,10958,10854,10725,15360,10982,10886,10766,15360,10918,10822,10701,15360,10878,10782,10669,15360,10886,10790,10669,15360,10934,10838,10717,15360,10950,10854,10741,15360,10934,10838,10733,15360,10982,10886,10782,15360,10886,10798,10701,15360,10870,10782,10685,15360,10894,10814,10717,15360,10910,10822,10725,15360,10934,10838,10733,15360,10950,10846,10741,15360,10934,10838,10725,15360,10934,10846,10749,15360,10902,10814,10717,15360,10878,10790,10677,15360,10878,10782,10669,15360,10854,10766,10645,15360,10838,10749,10629,15360,10902,10814,10701,15360,10910,10814,10693,15360,10902,10798,10669,15360,10910,10806,10677,15360,10886,10782,10653,15360,10854,10749,10629,15360,10870,10774,10653,15360,10974,10870,10758,15360,10990,10878,10758,15360,10918,10822,10709,15360,10926,10838,10725,15360,10958,10854,10733,15360,10894,10790,10653,15360,10822,10725,10605,15360,10878,10782,10661,15360,10974,10870,10749,15360,10902,10806,10677,15360,10934,10838,10725,15360,10870,10774,10653,15360,10798,10701,10581,15360,10854,10749,10621,15360,10894,10798,10669,15360,10934,10822,10685,15360,10942,10830,10701,15360,10910,10806,10669,15360,10870,10758,10629,15360,10886,10774,10645,15360,10950,10838,10701,15360,10966,10870,10749,15360,10886,10790,10685,15360,10870,10782,10677,15360,10934,10838,10733,15360,10934,10838,10725,15360,10822,10725,10621,15360,10878,10790,10677,15360,10894,10798,10693,15360,10822,10733,10629,15360,10894,10798,10685,15360,10998,10902,10790,15360,11015,10918,10806,15360,10950,10854,10741,15360,10950,10846,10741,15360,10934,10838,10733,15360,10942,10846,10749,15360,10910,10822,10725,15360,10846,10758,10653,15360,10878,10790,10685,15360,10894,10798,10701,15360,10862,10774,10669,15360,10814,10725,10621,15360,10846,10758,10645,15360,10870,10774,10661,15360,10870,10774,10677,15360,10878,10790,10693,15360,10878,10782,10677,15360,10830,10741,10637,15360,10870,10782,10677,15360,10966,10870,10766,15360,11015,10918,10814,15360,10910,10814,10701,15360,10942,10846,10725,15360,10950,10846,10725,15360,10942,10838,10725,15360,10934,10830,10701,15360,10910,10798,10677,15360,10886,10782,10653,15360,10838,10733,10597,15360,10902,10806,10669,15360,10830,10733,10613,15360,10838,10741,10621,15360,10838,10741,10621,15360,10894,10798,10669,15360,10934,10830,10685,15360,10886,10790,10669,15360,10902,10806,10685,15360,10854,10749,10637,15360]);var Dfe={file:1,m:1,mm:.001,cm:.01,ft:.3048,in:.0254,pt:cht()},uht={file:"m",m:"m",mm:"mm",cm:"cm",ft:"ft",in:"in",pt:"pt"},Ofe=e=>2===e?"\xb2":3===e?"\xb3":"",sE=(e,t=1)=>uht[e]+Ofe(t),FOt=(e,t,n,i=1)=>(null==n&&(n=t),n===t?{value:e,unit:sE(n)}:{value:e*Math.pow(Dfe[t]/Dfe[n],i),unit:sE(n)+Ofe(i)}),u5=(e=>(e.Top="Top",e.Bottom="Bottom",e.Front="Front",e.Back="Back",e.Left="Left",e.Right="Right",e))(u5||{}),aE=class{static getCameraPositionByBboxAndDirection(e,t,n,i,r){if(e.isEmpty()||!i)return;let a=new O,s=new O,o=new O(0,1,0);e.getSize(s),e.getCenter(a);let l,h,c=(s.x+s.y+s.z)/3*1.5;if(!r||null!=r&&r.equals(new O))l=new O(a.x+c,a.y+c/1.5,a.z+c),h=l.clone().sub(a);else{let e=new O(c,c/1.5,c).length();h=new O(-r.x,-r.y,-r.z).normalize().multiplyScalar(e),l=h.clone().add(a)}c=h.length(),h=h.normalize();let u=new et;u.lookAt(l,a,o);let d=new et;d.makeTranslation(-l.x,-l.y,-l.z);let p=e.clone().applyMatrix4(d).applyMatrix4(u.invert()).applyMatrix4(i),f=Math.max(Math.abs(p.max.x),Math.abs(p.min.x)),m=Math.max(Math.abs(p.max.y),Math.abs(p.min.y));c*=1.1*Math.sqrt(Math.pow(f,2)+Math.pow(m,2)),l=h.multiplyScalar(c).add(a),n.set(a.x,a.y,a.z),t.set(l.x,l.y,l.z)}static getCameraDirectionByView(e){let t=new O(1,0,0);return"Top"===e?t.set(0,-1,0):"Bottom"===e?t.set(0,1,0):"Front"===e?t.set(0,0,-1):"Back"===e?t.set(0,0,1):"Left"===e?t.set(1,0,0):"Right"===e&&t.set(-1,0,0),t}},hht=!1,Bi=class extends us{constructor(e){super(),this.DEFAULT_LINE_WIDTH=1,this.DEFAULT_STROKE_STYLE=[0,0,0,1],this.DEFAULT_FILL_STYLE=[0,0,0,1],this.lineWidth=this.DEFAULT_LINE_WIDTH,this.lineColor=this.DEFAULT_STROKE_STYLE,this.fillColor=this.DEFAULT_FILL_STYLE,this.x=0,this.y=0,this.width=0,this.height=0,this.points=[],this.userData={},this.tolerance=1,this.visible=!0,this.selected=!1,this.renderOrder=1,this.needsFrustumCulled=!0,this.editPointSize=3,this.editPointFillColor="#ffffff",this.editPointStrokeColor="#939ea4",this.matrix=new et,this.id=e||Mt.guid()}setTolerance(e){this.tolerance=e}render(e,t){this.ctx=e,this.draw(e,t),this.selected&&this.drawSelect(e,t),hht&&(this.drawBounds(e,t),this.drawCenter(e,t))}getData(){return{id:this.id,points:this.points.map((e=>[e.x,e.y])),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,type:this.getClassType()}}setData(e){this.id=e.id,this.setLineWidth(e.lineWidth),this.setLineColor(e.lineColor),this.setFillColor(e.fillColor)}getVertexes(){return[new O(this.x,this.y,0),new O(this.x+this.width,this.y,0),new O(this.x+this.width,this.y-this.height,0),new O(this.x,this.y-this.height,0)]}setLineWidth(e){this.lineWidth=e||this.DEFAULT_LINE_WIDTH}setLineColor(e){this.lineColor=e||this.DEFAULT_STROKE_STYLE}setFillColor(e){this.fillColor=e||this.DEFAULT_FILL_STYLE}isSelected(){return this.selected}getCenter(){return this.getBounds().getCenter(new O)}transToScreenCoord(e,t){return this.ctx?cn.worldPosition2ScreenPoint(e,t,this.ctx.canvas):new be}drawBounds(e,t){let{min:n,max:i}=this.getBounds(),r=[],a=(e,t,n)=>r.push(new O(e,t,n));a(i.x,i.y,i.z),a(n.x,i.y,i.z),a(n.x,n.y,i.z),a(i.x,n.y,i.z),a(i.x,i.y,n.z),a(n.x,i.y,n.z),a(n.x,n.y,n.z),a(i.x,n.y,n.z),a(n.x,i.y,i.z),a(n.x,n.y,i.z),a(i.x,i.y,i.z),a(i.x,n.y,i.z),a(i.x,i.y,n.z),a(i.x,n.y,n.z),a(n.x,i.y,n.z),a(n.x,n.y,n.z),a(n.x,i.y,i.z),a(n.x,i.y,n.z),a(i.x,i.y,i.z),a(i.x,i.y,n.z),a(n.x,n.y,i.z),a(n.x,n.y,n.z),a(i.x,n.y,i.z),a(i.x,n.y,n.z),e.save(),e.strokeStyle="yellow",e.beginPath(),r.forEach(((n,i)=>{let r=this.transToScreenCoord(n,t);i%2==0?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.closePath(),e.stroke(),e.restore()}drawCenter(e,t){let n=this.transToScreenCoord(this.getCenter(),t);e.save(),e.fillStyle="yellow",e.beginPath(),e.arc(n.x,n.y,5,0,2*Math.PI),e.closePath(),e.fill(),e.restore()}getBounds(){let e=this.getVertexes();return(new Ot).setFromPoints(e)}},Ii=(e=>(e.MouseClicked="MouseClicked",e.LayoutChanged="LayoutChanged",e.ModelLoaded="ModelLoaded",e.BeforeRender="BeforeRender",e.AfterRender="AfterRender",e.OnAnimate="OnAnimate",e.CameraChanged="CameraChanged",e.BoxSelectActivated="BoxSelectActivated",e.BoxSelectDeactivated="BoxSelectDeactivated",e.PickMarkupActivated="PickMarkupActivated",e.PickMarkupDeactivated="PickMarkupDeactivated",e.MarkupActivated="MarkupActivated",e.MarkupDeactivated="MarkupDeactivated",e.MarkupAdded="MarkupAdded",e.MarkupUpdated="MarkupUpdated",e.MarkupRemoved="MarkupRemoved",e.BeforeRemoveMarkup="BeforeRemoveMarkup",e.MeasurementActivated="MeasurementActivated",e.MeasurementDeactivated="MeasurementDeactivated",e.MeasurementAdded="MeasurementAdded",e.MeasurementRemoved="MeasurementRemoved",e))(Ii||{}),kfe={},Un=class extends us{constructor(e){super(),this.drawableLists=[],this.frustum=new ya,this.projScreenMatrix=new et,this.viewer=e,this.init()}static _registerDrawableClass(e){kfe[e.prototype.getClassType()]=e}static createDrawable(e){let t=kfe[e.type];if(!t)throw new Error(`Invalid drawable type: ${t}`);let n=e.points.map((e=>new O(e[0],e[1],e[2]||0))),i=new t(e.id,n);return i.setData(e),i}get container(){return this.viewer.viewerContainer}get camera(){return this.viewer.camera}get raycaster(){return this.viewer.getRaycaster()}init(){this.initCanvas(),this.viewer.addEventListener("AfterRender",(()=>{this.projScreenMatrix.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),this.frustum.setFromProjectionMatrix(this.projScreenMatrix),this.render()}))}initCanvas(){let e=this.viewer.getViewConfig();if(Dn.isBrowser&&!e.context2d){let e=this.canvas=document.createElement("canvas"),t=this.viewer.viewerContainer;t.appendChild(e),e.classList.add("overlay-renderer"),e.style.pointerEvents="none",e.style.position="absolute",e.style.left="0px",e.style.top="0px",e.style.userSelect="none",this.context=e.getContext("2d",{willReadFrequently:!0});let{clientWidth:n,clientHeight:i}=t;this.setSize(n,i)}else e.context2d&&(this.context=e.context2d,this.canvas=Dn.creatReactNativeCanvas(this.context),this.context.canvas||(this.context.canvas=this.canvas))}toHighDpr(e,t,n){let i=Math.max(window.devicePixelRatio||1,1),r=this.canvas;return r.width=t*i,r.height=n*i,e.scale(i,i),r.style.width=`${t}px`,r.style.height=`${n}px`,e}clearCanvas(){var e,t,n;null==(n=this.context)||n.clearRect(0,0,null==(e=this.canvas)?void 0:e.width,null==(t=this.canvas)?void 0:t.height)}addDrawableList(e){this.drawableLists.push(e)}render(){if(!this.canvas||!this.context||this.drawableLists.length<1)return;this.clearCanvas();let e=this.getSortedDrawables(!1);if(0===e.length)return;let t=new vr,n=this.viewer.getPixelSizeInWorldCoord();for(let i=0;i{let i=Array.from(n.getDrawables().values());e&&(i=i.filter((e=>e.visible))),i.length>0&&t.push(...i)})),t.sort(((e,t)=>e.renderOrder===t.renderOrder?t.getCenter().distanceTo(this.camera.position)-e.getCenter().distanceTo(this.camera.position):e.renderOrder-t.renderOrder)),t}getDrawablesByPosition(e,t){let n=this.getSortedDrawables(),i=[];for(let r=0;rt.id===e))}measureTextLength(e,t){let n=this.context,i=e.split("\n"),r=0;for(let a=0;ae.clear())),this.drawableLists=[],this.canvas&&(null==(e=this.viewer.viewerContainer)||e.removeChild(this.canvas),this.canvas=void 0)}},Ko=class extends us{constructor(e){super(),this.drawableMap=new Map,this.category=e}addDrawable(e){this.drawableMap.set(e.id,e),this.dispatchEvent("addDrawable",e.getData())}updateDrawable(e,t){e.setData(t),this.dispatchEvent("updateDrawable",e.getData())}removeDrawable(e){this.drawableMap.delete(e.id),this.dispatchEvent("removeDrawable",e.getData())}getDrawableById(e){return this.drawableMap.get(e)}clear(){this.drawableMap.forEach((e=>this.removeDrawable(e)))}getDrawables(){return this.drawableMap}getDrawableDatas(){return Array.from(this.drawableMap).map((([e,t])=>t.getData()))}setDrawableDatas(e){for(let t=0;t{let i=this.transToScreenCoord(n,t);e.moveTo(i.x,i.y),e.arc(i.x,i.y,this.editPointSize,0,2*Math.PI)})),e.closePath(),e.stroke(),e.fill(),e.restore()}setEditPointSize(e){this.editPointSize=e}setEditPointFillColor(e){this.editPointFillColor=e}setEditPointStrokeColor(e){this.editPointStrokeColor=e}getCenter(){return this.getBounds().getCenter(new O)}isPointInPath(e){let t=this.getVertexes().map((e=>new be(e.x,e.y)));return Qt.isPointInPolygon(new be(e.x,e.y),t,!0)}setData(e){super.setData(e),this.update(e.points.map((e=>new O(e[0],e[1],0))))}setParent(e){this.parent=e}setLeaderText(e){this.leaderText=e,e.setParent(this)}update(e){let{min:t,max:n}=dht.setFromPoints(e);return this.x=t.x,this.y=n.y,this.width=Math.abs(n.x-t.x),this.height=Math.abs(n.y-t.y),this.points=e,this}translate(e,t){let n=new O(e,t,0);return this.points.forEach((e=>e.add(n))),this.update(this.points),this}rotate(){return this}scale(){return this}},Wa=(e=>(e.Arrow="ArrowMarkup",e.Circle="CircleMarkup",e.CloudLine="CloudLineMarkup",e.CloudLineRectangle="CloudRectMarkup",e.CloudRectWithText="CloudRectWithTextMarkup",e.Dot="DotMarkup",e.Ellipse="EllipseMarkup",e.LeaderLine="LeaderLineMarkup",e.PolyLine="PolylineMarkup",e.Rectangle="RectMarkup",e.Text="TextMarkup",e.X="XMarkup",e))(Wa||{}),h5=class extends wi{constructor(e,t){super(e),this.type="ArrowMarkup",this.update(t)}draw(e,t){let n=this.points.map((e=>this.transToScreenCoord(e,t))),[i,r]=this.points,a=(new O).subVectors(i,r).length()/10/this.tolerance;this.drawArrowLine(e,n,a),this.drawArrowHead(e,n[0],n[1],10,a)}drawArrowLine(e,t,n){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor);let[i,r]=t,a=(new be).subVectors(r,i).normalize();e.beginPath(),e.moveTo(i.x,i.y);let s=r.clone().sub(a.multiplyScalar(n));e.lineTo(s.x,s.y),e.closePath(),e.stroke(),e.restore()}drawArrowHead(e,t,n,i,r){let a=180*Math.atan2(t.y-n.y,t.x-n.x)/Math.PI,s=(a+i)*Math.PI/180,o=(a-i)*Math.PI/180,l=r*Math.cos(s),h=r*Math.sin(s),c=r*Math.cos(o),u=r*Math.sin(o),d=new be(n.x+l,n.y+h),p=new be(n.x+c,n.y+u);e.save(),e.fillStyle=Cn.rgba2Color(this.lineColor),e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(d.x,d.y),e.lineTo(p.x,p.y),e.closePath(),e.fill(),e.restore()}getVertexes(){return this.points}update(e){let[t,n]=e;return this.points=e,this.x=Math.min(t.x,n.x),this.y=Math.max(t.y,n.y),this.width=Math.abs(n.x-t.x),this.height=Math.abs(n.y-t.y),this}isPointInPath(e){return Qt.isPointOnLineSegments(e,this.points,this.tolerance)}getClassType(){return"ArrowMarkup"}};Un._registerDrawableClass(h5);var fht=new be,Ffe=new O,d5=class extends wi{constructor(e,t){super(e),this.radius=1,this.type="CircleMarkup",this.update(t)}draw(e,t){let[n,i]=this.points.map((e=>this.transToScreenCoord(e,t)));this.radius=fht.subVectors(i,n).length(),e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor),e.fillStyle=Cn.rgba2Color(this.fillColor),e.beginPath(),e.arc(n.x,n.y,this.radius,0,2*Math.PI),e.closePath(),e.stroke(),e.restore()}update(e){let[t,n]=e,i=Ffe.subVectors(n,t).length();return this.width=2*i,this.height=2*i,this.x=t.x-this.width/2,this.y=t.y+this.height/2,this.points=e,this}isPointInPath(e){let[t,n]=this.points,i=Ffe.subVectors(t,n).length();return Math.abs(e.distanceTo(t)-i)<=2*this.tolerance}getClassType(){return"CircleMarkup"}};Un._registerDrawableClass(d5);var Nfe=new Ot,Pc=class extends wi{constructor(e,t){super(e),this.type="CloudLineMarkup",this.update(t)}draw(e,t){let n=this.points,i=[];e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor),e.fillStyle=Cn.rgba2Color(this.fillColor),e.beginPath();for(let s=0;sthis.transToScreenCoord(e,t))),r=(new be).lerpVectors(n,i,.5);this.radiusX=Math.abs(i.x-n.x)/2,this.radiusY=Math.abs(i.y-n.y)/2,e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor),e.fillStyle=Cn.rgba2Color(this.fillColor),e.beginPath(),e.ellipse(r.x,r.y,this.radiusX,this.radiusY,0,0,2*Math.PI),e.closePath(),e.stroke(),e.restore()}isPointInPath(e){let[t,n]=this.points,i=(new O).lerpVectors(t,n,.5),r=Math.pow(e.x-i.x,2),a=Math.pow(e.y-i.y,2),s=2*this.tolerance,o=Math.abs(n.x-t.x)/2-s,l=Math.abs(n.y-t.y)/2-s,h=r/(o*o),c=a/(l*l),u=Math.abs(n.x-t.x)/2+s,d=Math.abs(n.y-t.y)/2+s;return h+c>=1&&r/(u*u)+a/(d*d)<=1}getClassType(){return"EllipseMarkup"}};Un._registerDrawableClass(m5);var oE=class extends wi{constructor(e,t,n){super(e),this.text="",this.fontSize=12,this.type="TextMarkup",this.padding=300,this.inputStatus="CHAR_TYPING",this.isEditing=!1,this.handleClick=()=>{},this.handleKeydown=e=>{if(this.textInput)if("Enter"===e.key){let e=parseInt(this.textInput.style.height);this.textInput.style.height=`${Math.round(e+this.fontSize/this.tolerance)}px`}else"Escape"===e.code&&this.exitEditing()},this.handleInput=()=>{var e;if(!this.textInput||!this.manager||"CHINESE_TYPING"===this.inputStatus)return;let t=this.textInput.value,n=(null==(e=this.manager.overlayRender)?void 0:e.measureTextLength(t,this.fontSize/this.tolerance+"px Arial"))||0;n>oE.DEFAULT_INPUT_WIDTH&&(this.textInput.style.width=`${Math.round(n+this.padding/this.tolerance*2)}px`),this.inputStatus="CHAR_TYPING",this.text=t},this.handleCompositionStart=()=>{this.inputStatus="CHINESE_TYPING"},this.handleCompositionEnd=()=>{var e;if(!this.textInput||!this.manager||"CHINESE_TYPING"!==this.inputStatus)return;let t=this.textInput.value,n=(null==(e=this.manager.overlayRender)?void 0:e.measureTextLength(t,this.fontSize/this.tolerance+"px Arial"))||0;n>oE.DEFAULT_INPUT_WIDTH&&(this.textInput.style.width=`${Math.round(n+this.padding/this.tolerance*2)}px`),this.text=t,this.inputStatus="CHAR_TYPING"},this.handleBlur=()=>{this.exitEditing()},this.handleFoucs=()=>{},this.update(t),this.text=n}draw(e,t){this.isEditing||this.drawText(e,t,this.text)}drawText(e,t,n){let i=this.transToScreenCoord(new O(this.x,this.y,0),t),r=n.split("\n"),a=this.fontSize/this.tolerance,s=0;e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor),e.fillStyle=Cn.rgba2Color(this.lineColor),e.textAlign="left",e.textBaseline="top",e.font=`${a}px Arial`;for(let h=0;hs&&(s=n)}let o=this.padding/this.tolerance,l=new be(i.x,i.y);for(let h=0;h[e.x,e.y])),text:this.text,lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,fontSize:this.fontSize,type:this.getClassType()}}getClassType(){return"TextMarkup"}addInput(e,t,n){var i;this.textInput||(this.textInput=document.createElement("textarea"),this.textInput.style.cssText=`\n position: absolute;\n border: ${this.lineWidth}px solid ${Cn.rgba2Color(this.lineColor)};\n background: transparent;\n outline: none;\n resize: none;\n overflow: hidden;\n z-index: 1000;\n box-sizing: content-box;\n display: inline-block;\n padding: ${this.padding/this.tolerance}px;\n whiteSpace: 'nowrap';\n color: ${this.lineColor}`,this.textInput.style.display="inline-block",null==(i=e.viewerCanvas.parentElement)||i.appendChild(this.textInput),this.addInputEvents()),this.manager=e,this.enterEditing(),this.textInput.style.left=`${t}px`,this.textInput.style.top=`${n}px`,this.textInput.style.width=`${oE.DEFAULT_INPUT_WIDTH}px`,this.textInput.style.height=this.fontSize/this.tolerance+"px",this.textInput.style.lineHeight=this.fontSize/this.tolerance+"px",this.textInput.style.fontSize=this.fontSize/this.tolerance+"px",this.textInput.style.color=Cn.rgba2Color(this.lineColor)}addInputEvents(){var e,t,n,i,r,a,s;null==(e=this.textInput)||e.addEventListener("click",this.handleClick),null==(t=this.textInput)||t.addEventListener("blur",this.handleBlur),null==(n=this.textInput)||n.addEventListener("foucs",this.handleFoucs),null==(i=this.textInput)||i.addEventListener("keydown",this.handleKeydown),null==(r=this.textInput)||r.addEventListener("input",this.handleInput),null==(a=this.textInput)||a.addEventListener("compositionstart",this.handleCompositionStart),null==(s=this.textInput)||s.addEventListener("compositionend",this.handleCompositionEnd)}enterEditing(){this.textInput&&(this.textInput.value=this.text,this.textInput.focus(),this.isEditing=!0,this.dispatchEvent("EnterEditing"))}exitEditing(){var e,t,n,i,r,a,s,o;null==(e=this.textInput)||e.removeEventListener("click",this.handleClick),null==(t=this.textInput)||t.removeEventListener("blur",this.handleBlur),null==(n=this.textInput)||n.removeEventListener("foucs",this.handleFoucs),null==(i=this.textInput)||i.removeEventListener("keydown",this.handleKeydown),null==(r=this.textInput)||r.removeEventListener("input",this.handleInput),null==(a=this.textInput)||a.removeEventListener("compositionstart",this.handleCompositionStart),null==(s=this.textInput)||s.removeEventListener("compositionend",this.handleCompositionEnd),null==(o=this.textInput)||o.remove(),this.textInput=void 0,this.isEditing=!1,this.dispatchEvent("ExitEditing")}},Ol=oE;Ol.DEFAULT_INPUT_WIDTH=50,Un._registerDrawableClass(Ol);var Bfe=new be,Ufe=new be(1,0),Hfe=new be(0,-1),g5=class extends Ol{constructor(e,t,n){super(e,t,n),this.type="LeaderLineMarkup",this.text="LeaderLine",this.fontSize=12,this.textBounds=new Ot,this.handleInput=()=>{!this.textInput||!this.manager||"CHINESE_TYPING"===this.inputStatus||(this.text=this.textInput.value,this.calcuTextInputPositionByText(this.text),this.inputStatus="CHAR_TYPING")},this.handleCompositionEnd=()=>{!this.textInput||!this.manager||"CHINESE_TYPING"!==this.inputStatus||(this.text=this.textInput.value,this.calcuTextInputPositionByText(this.text),this.inputStatus="CHAR_TYPING")}}draw(e,t){if(this.points.length<2)return;let n=this.points.map((e=>this.transToScreenCoord(e,t))),[i,r]=this.points,a=(new O).subVectors(i,r).length()/10/this.tolerance;this.drawArrowLine(e,n,a),this.drawArrowHead(e,n[1],n[0],10,a),!this.isEditing&&this.text.length>0&&this.drawText(e,t,this.text)}drawArrowHead(e,t,n,i,r){let a=180*Math.atan2(t.y-n.y,t.x-n.x)/Math.PI,s=(a+i)*Math.PI/180,o=(a-i)*Math.PI/180,l=r*Math.cos(s),h=r*Math.sin(s),c=r*Math.cos(o),u=r*Math.sin(o),d=new be(n.x+l,n.y+h),p=new be(n.x+c,n.y+u);e.save(),e.fillStyle=Cn.rgba2Color(this.lineColor),e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(d.x,d.y),e.lineTo(p.x,p.y),e.closePath(),e.fill(),e.restore()}drawArrowLine(e,t,n){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor);let[i,r]=t,a=(new be).subVectors(i,r).normalize();e.beginPath(),e.moveTo(r.x,r.y);let s=i.clone().sub(a.multiplyScalar(n));e.lineTo(s.x,s.y),e.closePath(),e.stroke(),e.restore()}drawText(e,t,n){let[i,r]=this.points.map((e=>this.transToScreenCoord(e,t))),a=(new be).subVectors(r,i).normalize(),s=a.cross(Hfe)<0,o=a.cross(Ufe)<0,l=n.split("\n"),h=this.fontSize/this.tolerance,c=0;e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor),e.fillStyle=Cn.rgba2Color(this.lineColor),e.textAlign="left",e.textBaseline="top",e.font=`${h}px Arial`;for(let v=0;vc&&(c=n)}let u=this.padding/this.tolerance,d=u+h/2,p=l.length*h+2*u,f=new be(s?r.x:r.x-c-2*u,o?r.y-d:r.y-p+(p-d));for(let v=0;v[e.x,e.y])),text:this.text,lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,fontSize:this.fontSize,type:this.getClassType()}}isPointInPath(e){return Qt.isPointOnLineSegments(e,this.points,this.tolerance)||this.textBounds.containsPoint(e)}updateText(e){this.text=e}getClassType(){return"LeaderLineMarkup"}addInput(e,t,n){let[i,r]=this.points.map((t=>cn.worldPosition2ScreenPoint(t,e.camera,e.viewerCanvas))),a=(new be).subVectors(r,i).normalize(),s=a.cross(Hfe)<0,o=a.cross(Ufe)<0,l=this.fontSize/this.tolerance,h=this.padding/this.tolerance,c=h+l/2,u=Ol.DEFAULT_INPUT_WIDTH,d=l;super.addInput(e,s?t:t-u-2*h,o?n-c:n-d+(d-c))}calcuTextInputPositionByText(e){var t;if(!this.textInput||!this.manager)return;let n=(null==(t=this.manager.overlayRender)?void 0:t.measureTextLength(e,this.fontSize/this.tolerance+"px Arial"))||0;if(n>Ol.DEFAULT_INPUT_WIDTH){let e=this.points[1],t=cn.worldPosition2ScreenPoint(this.points[0],this.manager.camera,this.manager.viewerCanvas),i=cn.worldPosition2ScreenPoint(e,this.manager.camera,this.manager.viewerCanvas).clone().sub(t).normalize().cross(new be(0,-1))<0,r=cn.worldPosition2ScreenPoint(e,this.manager.camera,this.manager.viewerCanvas);i||(this.textInput.style.left=r.x-n-this.padding/this.tolerance*2+"px"),this.textInput.style.width=`${Math.round(n)}px`}}};Un._registerDrawableClass(g5);var v5=class extends wi{constructor(e,t){super(e),this.type="PolylineMarkup",this.update(t)}draw(e,t){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor),e.fillStyle=Cn.rgba2Color(this.fillColor);let n=this.points;e.beginPath(),n.forEach(((n,i)=>{let r=this.transToScreenCoord(n,t);0===i?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.stroke(),e.restore()}isPointInPath(e){let t=this.points,n=[];for(let i=0;i{let r=this.transToScreenCoord(n,t);0===i?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.closePath(),e.stroke(),e.restore()}isPointInPath(e){let t=this.getVertexes(),n=[];for(let i=0;ithis.transToScreenCoord(e,t)));e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.moveTo(i.x,i.y),e.lineTo(a.x,a.y),e.closePath(),e.stroke(),e.restore()}isPointInPath(e){let[t,n,i,r]=this.getVertexes();return Qt.isPointOnLineSegments(e,[t,i,n,r],.1)}getClassType(){return"XMarkup"}};Un._registerDrawableClass(x5);var Vfe=new Ot,b5=new O,E5=new be,pht=new be(1,0),mht=new be(0,-1),_5=class extends Ol{constructor(e,t,n=""){super(e,t,n),this.type="CloudRectWithTextMarkup",this.textPosition=new O,this.textBounds=new Ot,this.text="CloudRectWithText",this.fontSize=12,this.handleClick=()=>{var e;null==(e=this.textInput)||e.blur()},this.handleInput=()=>{!this.textInput||!this.manager||"CHINESE_TYPING"===this.inputStatus||(this.text=this.textInput.value,this.calcInputPositionByText(this.text),this.inputStatus="CHAR_TYPING")},this.handleCompositionEnd=()=>{!this.textInput||!this.manager||"CHINESE_TYPING"!==this.inputStatus||(this.text=this.textInput.value,this.calcInputPositionByText(this.text),this.inputStatus="CHAR_TYPING")}}draw(e,t){this.drawCloudRect(e,t),(this.isEditing||this.text.length>0)&&this.drawLeaderLine(e,t),!this.isEditing&&this.text.length>0&&this.drawText(e,t,this.text)}drawCloudRect(e,t){e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor),e.fillStyle=Cn.rgba2Color(this.fillColor),e.beginPath();let n=this.getCloudPoints();n.push(n[0]);let i,r=[];for(let a=0;an.distanceTo(e)-n.distanceTo(t)));let i=this.controlPoints[0];e.save(),e.lineWidth=_5.LEADER_LINE_WIDTH,e.strokeStyle=Cn.rgba2Color(this.lineColor),e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(n.x,n.y),e.closePath(),e.stroke(),e.restore()}drawText(e,t,n){let i=this.transToScreenCoord(this.points[0],t),r=this.transToScreenCoord(this.textPosition,t),a=E5.subVectors(r,i).normalize(),s=a.cross(pht)<0,o=a.cross(mht)<0,l=n.split("\n"),h=this.fontSize/this.tolerance,c=0;e.save(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor),e.fillStyle=Cn.rgba2Color(this.lineColor),e.textAlign="left",e.textBaseline="top",e.font=`${h}px Arial`;for(let v=0;vc&&(c=n)}let u=this.padding/this.tolerance,d=u+h/2,p=l.length*h+2*u,f=new be(o?r.x:r.x-c-2*u,s?r.y-d:r.y-p+(p-d));for(let v=0;ve.add(n))),this.textPosition.add(n);let[i,r]=this.points;return this.x=Math.min(i.x,r.x),this.y=Math.max(i.y,r.y),this.width=Math.abs(r.x-i.x),this.height=Math.abs(r.y-i.y),this}update(e){let[t,n]=e;return this.points=e,this.x=Math.min(t.x,n.x),this.y=Math.max(t.y,n.y),this.width=Math.abs(n.x-t.x),this.height=Math.abs(n.y-t.y),this.textPosition||(this.textPosition=new O),this.textPosition.set(Math.max(t.x,n.x),Math.max(t.y,n.y),0),this}getCloudPoints(){return[new O(this.x,this.y,0),new O(this.x+this.width,this.y,0),new O(this.x+this.width,this.y-this.height,0),new O(this.x,this.y-this.height,0)]}getBounds(){return Vfe.setFromPoints([...this.points,...this.vertexes||[]]),Vfe.union(this.textBounds)}getVertexes(){let e=this.getBounds(),t=e.min,n=e.getSize(b5);return[new O(t.x,t.y,0),new O(t.x+n.x,t.y,0),new O(t.x+n.x,t.y+n.y,0),new O(t.x,t.y+n.y,0)]}isLeaderTextSelected(e){return this.textBounds.containsPoint(e)}translateLeaderText(e,t){let n=new O(e,t,0);return this.textPosition.add(n),this}isPointInPath(e){let t=this.getCloudPoints(),n=[];for(let i=0;i[e.x,e.y])),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,fontSize:this.fontSize,text:this.text,textPosition:[this.textPosition.x,this.textPosition.y],type:this.getClassType()}}getClassType(){return"CloudRectWithTextMarkup"}addInput(e,t,n){let i=this.padding/this.tolerance+this.fontSize/this.tolerance/2;super.addInput(e,t,n-i)}updateInputPosition(e,t){var n;if(!this.manager||!this.textInput)return;let i=t.clone().sub(e).normalize().cross(new be(0,-1))<0,r=this.textInput.value,a=(null==(n=this.manager.overlayRender)?void 0:n.measureTextLength(r,this.fontSize/this.tolerance+"px Arial"))||Ol.DEFAULT_INPUT_WIDTH,s=this.padding/this.tolerance+this.fontSize/this.tolerance/2;this.textInput.style.left=`${i?t.x:t.x-this.padding/this.tolerance*2-a}px`,this.textInput.style.top=t.y-s+"px",this.textPosition.copy(cn.screenPoint2worldPosition(t,this.manager.camera,this.manager.viewerCanvas))}calcInputPositionByText(e){var t;if(!this.textInput||!this.manager)return;let n=(null==(t=this.manager.overlayRender)?void 0:t.measureTextLength(e,this.fontSize/this.tolerance+"px Arial"))||0;if(n>Ol.DEFAULT_INPUT_WIDTH){let e=cn.worldPosition2ScreenPoint(this.points[0],this.manager.camera,this.manager.viewerCanvas),t=cn.worldPosition2ScreenPoint(this.textPosition,this.manager.camera,this.manager.viewerCanvas).clone().sub(e).normalize().cross(new be(0,-1))<0,i=cn.worldPosition2ScreenPoint(this.textPosition,this.manager.camera,this.manager.viewerCanvas);t||(this.textInput.style.left=i.x-n-this.padding/this.tolerance*2+"px"),this.textInput.style.width=`${Math.round(n)}px`}}},Bm=_5;Bm.LEADER_LINE_WIDTH=1,Un._registerDrawableClass(Bm);var tr={LEFT:1,RIGHT:2,MIDDLE:4},yt=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768});function Rf(e){return e.isPerspectiveCamera}function Vu(e){return e.isOrthographicCamera}var ght=(e=>(e[e.NONE=-1]="NONE",e[e.ROTATE=0]="ROTATE",e[e.DOLLY=1]="DOLLY",e[e.PAN=2]="PAN",e[e.TOUCH_ROTATE=3]="TOUCH_ROTATE",e[e.TOUCH_DOLLY=4]="TOUCH_DOLLY",e))(ght||{}),vht=(e=>(e.LEFT="ArrowLeft",e.UP="ArrowUp",e.RIGHT="ArrowRight",e.BOTTOM="ArrowDown",e))(vht||{});function Zv(e){return{type:e}}var zu={movable:!1,startDistBetweenFingers:0,scale:1},Kv=2*Math.PI,zfe=1e-6,JA=class extends jo{constructor(e,t,n=!1){super(),this.enabled=!0,this.target=new O,this.enableZoom=!1,this.enablePan=!1,this.enableRotate=!0,this.state=-1,this.rotateSpeed=1,this.zoomSpeed=1,this.panSpeed=1,this.scale=1,this.minZoom=0,this.maxZoom=1/0,this.screenSpacePanning=!0,this.autoRotate=!0,this.autoRotateSpeed=2,this.enableDamping=!1,this.dampingFactor=.05,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minDistance=0,this.maxDistance=1/0,this.keyPanSpeed=7,this.minFov=50,this.maxFov=95,this.zoomChanged=!1,this.panOffset=new O,this.pointerPositions={},this.rotateStart=new be,this.rotateEnd=new be,this.rotateDelta=new be,this.dollyStart=new be,this.dollyEnd=new be,this.dollyDelta=new be,this.panStart=new be,this.panEnd=new be,this.panDelta=new be,this.pointers=[],this.spherical=new ff,this.sphericalDelta=new ff,this.update=function(e){let t=new O,n=new O,i=new dr;return function(){let r=e.quat,a=r.clone().invert(),s=e.object.position;t.copy(s).sub(e.target),t.applyQuaternion(r),e.spherical.setFromVector3(t),e.autoRotate&&-1===e.state&&(e.isVRMode?e.sphericalDelta.theta+=Kv/60/60*e.autoRotateSpeed:e.sphericalDelta.theta-=Kv/60/60*e.autoRotateSpeed),e.enableDamping?(e.spherical.theta+=e.sphericalDelta.theta*e.dampingFactor,e.spherical.phi+=e.sphericalDelta.phi*e.dampingFactor):(e.spherical.theta+=e.sphericalDelta.theta,e.spherical.phi+=e.sphericalDelta.phi);let o=e.minAzimuthAngle,l=e.maxAzimuthAngle;return isFinite(o)&&isFinite(l)&&(o<-Math.PI?o+=Kv:o>Math.PI&&(o-=Kv),l<-Math.PI?l+=Kv:l>Math.PI&&(l-=Kv),e.spherical.theta=o<=l?Math.max(o,Math.min(l,e.spherical.theta)):e.spherical.theta>(o+l)/2?Math.max(o,e.spherical.theta):Math.min(l,e.spherical.theta)),e.spherical.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,e.spherical.phi)),e.spherical.makeSafe(),e.spherical.radius*=e.scale,e.spherical.radius=Math.max(e.minDistance,Math.min(e.maxDistance,e.spherical.radius)),!0===e.enableDamping?e.target.addScaledVector(e.panOffset,e.dampingFactor):e.target.add(e.panOffset),t.setFromSpherical(e.spherical),t.applyQuaternion(a),s.copy(e.target).add(t),e.object.lookAt(e.target),!0===e.enableDamping?(e.sphericalDelta.theta*=1-e.dampingFactor,e.sphericalDelta.phi*=1-e.dampingFactor,e.panOffset.multiplyScalar(1-e.dampingFactor)):(e.sphericalDelta.set(0,0,0),e.panOffset.set(0,0,0)),e.scale=1,!!(e.zoomChanged||n.distanceToSquared(e.object.position)>zfe||8*(1-i.dot(e.object.quaternion))>zfe)&&(e.dispatchEvent(Zv("change")),n.copy(e.object.position),i.copy(e.object.quaternion),e.zoomChanged=!1,!0)}}(this),this.onContextMenu=function(e){return t=>{!1!==e.enabled&&t.preventDefault()}}(this),this.onPointerDown=function(e){return t=>{!1!==e.enabled&&(0===e.pointers.length&&(e.domElement.setPointerCapture(t.pointerId),e.domElement.addEventListener("pointermove",e.onPointerMove),e.domElement.addEventListener("pointerup",e.onPointerUp)),e.addPointer(t),"touch"===t.pointerType?e.onTouchStart(t):e.onMouseDown(t))}}(this),this.onPointerMove=function(e){return t=>{!1!==e.enabled&&("touch"===t.pointerType?e.onTouchMove(t):e.onMouseMove(t))}}(this),this.onPointerUp=function(e){return t=>{e.removePointer(t),0===e.pointers.length&&(e.domElement.releasePointerCapture(t.pointerId),e.domElement.removeEventListener("pointermove",e.onPointerMove),e.domElement.removeEventListener("pointerup",e.onPointerUp)),"touch"===t.pointerType&&e.handlerTouchEnd(t),e.dispatchEvent(Zv("end")),e.state=-1}}(this),this.onPointerCancel=function(e){return t=>{e.removePointer(t),e.handlerTouchEnd(t)}}(this),this.onMouseWheel=function(e){return t=>{!1===e.enabled||!1===e.enableZoom||-1!==e.state||(t.preventDefault(),t.stopPropagation(),e.dispatchEvent(Zv("start")),e.handleMouseWheel(t),e.dispatchEvent(Zv("end")))}}(this),this.pan=function(e){let t=new O;return function(n,i){let r=e.domElement;if(e.object instanceof ur){let a=e.object.position;t.copy(a).sub(e.target);let s=t.length();s*=Math.tan(e.object.fov/2*Math.PI/180),e.panLeft(2*n*s/r.clientHeight,e.object.matrix),e.panUp(2*i*s/r.clientHeight,e.object.matrix)}else console.warn("WARNING: VRControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1}}(this),this.panLeft=function(e){let t=new O;return function(n,i){t.setFromMatrixColumn(i,0),t.multiplyScalar(-n),e.panOffset.add(t)}}(this),this.panUp=function(e){let t=new O;return function(n,i){!0===e.screenSpacePanning?t.setFromMatrixColumn(i,1):(t.setFromMatrixColumn(i,0),t.crossVectors(e.object.up,t)),t.multiplyScalar(n),e.panOffset.add(t)}}(this),this.onKeyDown=e=>{!1===this.enabled||!1===this.enablePan||this.handleKeyDown(e)},this.object=e,this.domElement=t,this.isVRMode=n,this.quat=(new dr).setFromUnitVectors(this.object.up,new O(0,1,0)),this.domElement&&this.domElement.style&&(this.domElement.style.touchAction="none"),this.domElement.addEventListener("contextmenu",this.onContextMenu),this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointercancel",this.onPointerCancel),this.domElement.addEventListener("wheel",this.onMouseWheel,{passive:!1}),this.update()}dispose(){this.domElement.removeEventListener("contextmenu",this.onContextMenu),this.domElement.removeEventListener("pointerdown",this.onPointerDown),this.domElement.removeEventListener("pointercancel",this.onPointerCancel),this.domElement.removeEventListener("wheel",this.onMouseWheel),this.domElement.removeEventListener("pointermove",this.onPointerMove),this.domElement.removeEventListener("pointerup",this.onPointerUp),this.domElementKeyEvents&&this.domElementKeyEvents.removeEventListener("keydown",this.onKeyDown)}addPointer(e){this.pointers.push(e)}removePointer(e){delete this.pointerPositions[e.pointerId];for(let t=0;t0&&this.dollyOut(t),this.update()}handleMouseDownRotate(e){this.rotateStart.set(e.clientX,e.clientY)}handleMouseDownDolly(e){this.dollyStart.set(e.clientX,e.clientY)}handleMouseDownPan(e){this.panStart.set(e.clientX,e.clientY)}handleTouchStartRotate(){if(1===this.pointers.length)this.rotateStart.set(this.pointers[0].pageX,this.pointers[0].pageY);else{let e=.5*(this.pointers[0].pageX+this.pointers[1].pageX),t=.5*(this.pointers[0].pageY+this.pointers[1].pageY);this.rotateStart.set(e,t)}}handleTouchStartDolly(e){if(e.length<2)return;let t=e[0],n=e[1];zu.startDistBetweenFingers=this.getDist([t.pageX,t.pageY],[n.pageX,n.pageY]),zu.movable=!0,zu.scale=1}updateRotate(){let e=this.isVRMode,t=this.sphericalDelta;this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(this.rotateSpeed);let n=this.domElement;e?(t.theta+=2*Math.PI*this.rotateDelta.x/n.clientHeight,t.phi+=2*Math.PI*this.rotateDelta.y/n.clientHeight):(t.theta-=2*Math.PI*this.rotateDelta.x/n.clientHeight,t.phi-=2*Math.PI*this.rotateDelta.y/n.clientHeight),this.rotateStart.copy(this.rotateEnd)}handleMouseMoveRotate(e){this.rotateEnd.set(e.clientX,e.clientY),this.updateRotate()}dollyOut(e){this.object instanceof ur?this.scale/=e:(console.warn("WARNING: VRControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}dollyIn(e){this.object instanceof ur?this.scale*=e:(console.warn("WARNING: VRControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}handleMouseMoveDolly(e){this.dollyEnd.set(e.clientX,e.clientY),this.dollyDelta.subVectors(this.dollyEnd,this.dollyStart);let t=Math.pow(.95,this.zoomSpeed);this.dollyDelta.y>0?this.dollyOut(t):this.dollyIn(t),this.dollyStart.copy(this.dollyEnd)}handleMouseMovePan(e){this.panEnd.set(e.clientX,e.clientY),this.panDelta.subVectors(this.panEnd,this.panStart).multiplyScalar(this.panSpeed),this.pan(this.panDelta.x,this.panDelta.y),this.panStart.copy(this.panEnd)}getSecondPointerPosition(e){let t=e.pointerId===this.pointers[0].pointerId?this.pointers[1]:this.pointers[0];return this.pointerPositions[t.pointerId]}handleTouchMoveRotate(e){if(1==this.pointers.length)this.rotateEnd.set(e.pageX,e.pageY);else{let t=this.getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this.rotateEnd.set(n,i)}this.updateRotate()}updateFov(e){var t;let n=this.object;if(!(n&&n instanceof ur))return void console.warn("WARNING: VRControls.js encountered an unknown camera type - updateFov disabled.");let i=this.minFov,r=this.maxFov,a=e=>{let t=n.fov+e;t=Math.min(t,r),t=Math.max(t,i),n.fov!==t&&(n.fov=t,n.updateProjectionMatrix(),this.dispatchEvent({type:"change"}))},s=e/20;for(let o=0;o<20;++o)setTimeout((()=>a(s)),5*o);this.autoRotate&&(null==(t=this.controlsHelper)||t.delayAutoRotate())}handleTouchMoveDolly(e){if(!zu.movable||this.pointers.length<2)return;let t=this.getSecondPointerPosition(e),n=[e.pageX,e.pageY],i=[t.x,t.y],r=zu.startDistBetweenFingers,a=this.getDist(n,i);if(!r||!a||Math.abs(r-a)<10)return;let s=a/r;console.log(s),s=Math.min(s,3),s=Math.max(s,1/3);let o=s-zu.scale;if(Math.abs(o)<.05)return;let l=0;l=o>0?10*-o:10*(zu.scale/s-1),this.updateFov(l),zu.scale=s}handleKeyDown(e){let t=!1;switch(e.code){case"ArrowUp":this.pan(0,this.keyPanSpeed),t=!0;break;case"ArrowDown":this.pan(0,-this.keyPanSpeed),t=!0;break;case"ArrowLeft":this.pan(this.keyPanSpeed,0),t=!0;break;case"ArrowRight":this.pan(-this.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),this.update())}listenToKeyEvents(e){e.addEventListener("keydown",this.onKeyDown),this.domElementKeyEvents=e}},Jo=class extends us{constructor(e){super(),this.enabled=!0,this.keyboardEnabled=!0,this.mouseDownPositionX=0,this.mouseDownPositionY=0,this.lastLeftPointerUpTime=0,this.pointers=[],this.handleClick=e=>{if(!this.enabled)return;let t=this.getBaseEvent(e);this.dispatchEvent("click",t)},this.handlePointerDown=e=>{if(!this.enabled)return;this.stop(e);let t=this.getBaseEvent(e);this.isDoubleClick(t)?(this.lastLeftPointerUpTime=0,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.dispatchEvent("dblclick",t)):(this.mouseDownPositionX=t.x,this.mouseDownPositionY=t.y),this.dispatchEvent("pointerdown",t),"touch"===e.pointerType?(this.pointers.push(t),t.pointers=this.pointers,this.dispatchEvent("touchstart",t)):this.dispatchEvent("mousedown",t)},this.handlePointerMove=e=>{if(!this.enabled)return;this.stop(e);let t=this.getBaseEvent(e);this.isCloseToLastPosition(t)||(this.dispatchEvent("pointermove",t),"touch"===e.pointerType?(this.updatePointers(t),t.pointers=this.pointers,this.dispatchEvent("touchmove",t)):this.dispatchEvent("mousemove",t))},this.handlePointerUp=e=>{if(!this.enabled)return;this.stop(e);let t=this.getBaseEvent(e);0===t.button&&(this.lastLeftPointerUpTime=t.timestamp),this.dispatchEvent("pointerup",t),"touch"===e.pointerType?(this.removePointers(t),t.pointers=this.pointers,this.dispatchEvent("touchend",t)):this.dispatchEvent("mouseup",t)},this.handlePointerCancel=e=>{this.enabled&&(this.stop(e),this.dispatchEvent("pointercancel",this.getBaseEvent(e)))},this.handleMouseWheel=e=>{this.enabled&&(this.stop(e),this.dispatchEvent("wheel",this.getBaseEvent(e)))},this.handleContextMenu=e=>{if(this.enabled)return this.stop(e),this.dispatchEvent("contextmenu",this.getBaseEvent(e)),!1},this.handlePointerEnter=e=>{this.enabled&&(this.stop(e),this.dispatchEvent("pointerenter",this.getBaseEvent(e)))},this.handlePointerLeave=e=>{this.enabled&&(this.stop(e),this.dispatchEvent("pointerleave",this.getBaseEvent(e)))},this.handleResize=e=>{this.enabled&&(this.stop(e),this.dispatchEvent("resize",this.getBaseEvent(e)))},this.handleKeydown=e=>{!this.enabled||!this.keyboardEnabled||this.dispatchEvent("keydown",this.getBaseEvent(e))},this.handleKeyup=e=>{!this.enabled||!this.keyboardEnabled||this.dispatchEvent("keyup",this.getBaseEvent(e))},this.style={},this.element=e,this.bindEvents()}getEnabled(){return this.enabled}setEnabled(e){this.enabled=e}getkKeyboardEnabled(){return this.keyboardEnabled}setkKeyboardEnabled(e){this.keyboardEnabled=e}setCursor(e){this.element.style&&(this.element.style.cursor=e||"default")}bindEvents(){this.element.style.touchAction="none",this.element.style.userSelect="none",this.element.style.webkitUserSelect="none",this.element.addEventListener("click",this.handleClick),this.element.addEventListener("pointerdown",this.handlePointerDown),this.element.addEventListener("pointermove",this.handlePointerMove),this.element.addEventListener("pointerup",this.handlePointerUp),this.element.addEventListener("pointercancel",this.handlePointerCancel),this.element.addEventListener("pointerenter",this.handlePointerEnter),this.element.addEventListener("pointerleave",this.handlePointerLeave),this.element.addEventListener("contextmenu",this.handleContextMenu),this.element.addEventListener("wheel",this.handleMouseWheel),window.addEventListener("resize",this.handleResize),window.addEventListener("keydown",this.handleKeydown),window.addEventListener("keyup",this.handleKeyup)}unBindEvents(){this.element.removeEventListener("pointerdown",this.handlePointerDown),this.element.removeEventListener("pointermove",this.handlePointerMove),this.element.removeEventListener("pointerup",this.handlePointerUp),this.element.removeEventListener("pointerenter",this.handlePointerEnter),this.element.removeEventListener("pointerleave",this.handlePointerLeave),this.element.removeEventListener("contextmenu",this.handleContextMenu),this.element.removeEventListener("wheel",this.handleMouseWheel),window.removeEventListener("resize",this.handleResize),window.removeEventListener("keydown",this.handleKeydown),window.removeEventListener("keyup",this.handleKeyup),this.element.style.touchAction="",this.element.style.userSelect="",this.element.style.webkitUserSelect=""}getBaseEvent(e){let t={x:0,y:0,pageX:0,pageY:0,clientX:0,clientY:0,deltaX:0,deltaY:0,movementX:0,movementY:0,deltaMode:0,pointerId:0,timestamp:0,buttons:0,pointerType:"mouse",altKey:!1,ctrlKey:!1,shiftKey:!1,metaKey:!1,originalEvent:e};if(t.timestamp=e.timeStamp,QA(e,"clientX"))if(t.altKey=e.altKey,t.ctrlKey=e.ctrlKey,t.shiftKey=e.shiftKey,t.clientX=e.clientX,t.clientY=e.clientY,t.button=e.button,QA(e,"pointerId")){t.pointerType=e.pointerType,t.buttons=e.buttons,t.pageX=e.pageX,t.pageY=e.pageY,t.pointerId=e.pointerId;let n=cn.getScreenPointByEvent(e,this.element);t.x=n.x,t.y=n.y,t.movementX=e.movementX,t.movementY=e.movementY}else QA(e,"deltaX")&&(t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaY=e.deltaY);else QA(e,"code")&&(t.altKey=e.altKey,t.ctrlKey=e.ctrlKey,t.shiftKey=e.shiftKey,t.metaKey=e.metaKey,t.code=e.code);return t}stop(e){e.preventDefault()}updatePointers(e){for(let t=0;t0==p>c&&(p=c,n.value=(p-c)/a),p}function S5(e,t,n,i,r=1/0,a,s){let o=2/(i=Math.max(1e-4,i)),l=o*a,h=1/(1+l+.48*l*l+.235*l*l*l),c=t.x,u=t.y,d=t.z,p=e.x-c,f=e.y-u,m=e.z-d,g=c,v=u,y=d,x=r*i,b=p*p+f*f+m*m;if(b>x*x){let e=Math.sqrt(b);p=p/e*x,f=f/e*x,m=m/e*x}c=e.x-p,u=e.y-f,d=e.z-m;let _=(n.x+o*p)*a,w=(n.y+o*f)*a,S=(n.z+o*m)*a;n.x=(n.x-o*_)*h,n.y=(n.y-o*w)*h,n.z=(n.z-o*S)*h,s.x=c+(p+_)*h,s.y=u+(f+w)*h,s.z=d+(m+S)*h;let M=g-e.x,T=v-e.y,E=y-e.z;return M*(s.x-g)+T*(s.y-v)+E*(s.z-y)>0&&(s.x=g,s.y=v,s.z=y,n.x=(s.x-g)/a,n.y=(s.y-v)/a,n.z=(s.z-y)/a),s}function eC(e,t){t.set(0,0),e.forEach((e=>{t.x+=e.clientX,t.y+=e.clientY})),t.x/=e.length,t.y/=e.length}function tC(e,t){return!!Vu(e)&&(console.warn(`${t} is not supported in OrthographicCamera`),!0)}var nC=class{constructor(){this._listeners={}}addEventListener(e,t){let n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){let n=this._listeners[e];if(void 0!==n){let e=n.indexOf(t);-1!==e&&n.splice(e,1)}}removeAllEventListeners(e){e?Array.isArray(this._listeners[e])&&(this._listeners[e].length=0):this._listeners={}}dispatchEvent(e){let t=this._listeners[e.type];if(void 0!==t){e.target=this;let n=t.slice(0);for(let t=0,i=n.length;t{},this._enabled=!0,this._state=yt.NONE,this._viewport=null,this._dollyControlAmount=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=Dn.isBrowser?new DOMRect:{x:0,y:0,width:0,height:0,left:0,right:0,top:0,bottom:0},this._activePointers=[],this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new nr.Vector3,this._focalOffsetVelocity=new nr.Vector3,this._zoomVelocity={value:0},this._truckInternal=(e,t,n)=>{if(Rf(this._camera)){let i=ar.copy(this._camera.position).sub(this._target),r=this._camera.getEffectiveFOV()*Jv,a=i.length()*Math.tan(.5*r),s=this.truckSpeed*e*a/this._elementRect.height,o=this.truckSpeed*t*a/this._elementRect.height;this.verticalDragToForward?(n?this.setFocalOffset(this._focalOffsetEnd.x+s,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(s,0,!0),this.forward(-o,!0)):n?this.setFocalOffset(this._focalOffsetEnd.x+s,this._focalOffsetEnd.y+o,this._focalOffsetEnd.z,!0):this.truck(s,o,!0)}else if(Vu(this._camera)){let i=this._camera,r=e*(i.right-i.left)/i.zoom/this._elementRect.width,a=t*(i.top-i.bottom)/i.zoom/this._elementRect.height;n?this.setFocalOffset(this._focalOffsetEnd.x+r,this._focalOffsetEnd.y+a,this._focalOffsetEnd.z,!0):this.truck(r,a,!0)}},this._rotateInternal=(e,t)=>{let n=Um*this.azimuthRotateSpeed*e/this._elementRect.height,i=Um*this.polarRotateSpeed*t/this._elementRect.height;this.rotate(n,i,!0)},this._dollyInternal=(e,t,n)=>{let i=Math.pow(.95,-e*this.dollySpeed),r=this._sphericalEnd.radius*i,a=this._sphericalEnd.radius,s=a*(e>=0?-1:1);this.dollyTo(r),this.infinityDolly&&(r{let i=Math.pow(.95,e*this.dollySpeed),r=this._zoomEnd;this.zoomTo(this._zoom*i),this.dollyToCursor&&(this._dollyControlAmount+=this._zoomEnd-r,this._dollyControlCoord.set(t,n))},void 0===nr&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=(new nr.Quaternion).setFromUnitVectors(this._camera.up,iC),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=yt.NONE,this._target=new nr.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new nr.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=(new nr.Spherical).setFromVector3(ar.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._nearPlaneCorners=[new nr.Vector3,new nr.Vector3,new nr.Vector3,new nr.Vector3],this._updateNearPlaneCorners(),this._boundary=new nr.Box3(new nr.Vector3(-1/0,-1/0,-1/0),new nr.Vector3(1/0,1/0,1/0)),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlAmount=0,this._dollyControlCoord=new nr.Vector2,this.mouseButtons={left:yt.ROTATE,middle:yt.DOLLY,right:yt.TRUCK,wheel:Rf(this._camera)?yt.DOLLY:Vu(this._camera)?yt.ZOOM:yt.NONE},this.touches={one:yt.TOUCH_ROTATE,two:Rf(this._camera)?yt.TOUCH_DOLLY_TRUCK:Vu(this._camera)?yt.TOUCH_ZOOM_TRUCK:yt.NONE,three:yt.TOUCH_TRUCK};let n=new nr.Vector2,i=new nr.Vector2,r=new nr.Vector2,a=e=>{if(!this._enabled||!this._domElement)return;let t="mouse"!==e.pointerType?null:(e.buttons&tr.LEFT)===tr.LEFT?tr.LEFT:(e.buttons&tr.MIDDLE)===tr.MIDDLE?tr.MIDDLE:(e.buttons&tr.RIGHT)===tr.RIGHT?tr.RIGHT:null;if(null!==t){let e=this._findPointerByMouseButton(t);e&&this._activePointers.splice(this._activePointers.indexOf(e),1)}let n={pointerId:e.pointerId,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:0,mouseButton:t};this._activePointers.push(n),this._domElement.removeEventListener("pointermove",o),this._domElement.removeEventListener("pointerup",h),this._domElement.addEventListener("pointermove",o),this._domElement.addEventListener("pointerup",h),f(e)},s=e=>{if(!this._enabled||!this._domElement)return;let t=(e.buttons&tr.LEFT)===tr.LEFT?tr.LEFT:(e.buttons&tr.MIDDLE)===tr.MIDDLE?tr.MIDDLE:(e.buttons&tr.RIGHT)===tr.RIGHT?tr.RIGHT:null;if(null!==t){let e=this._findPointerByMouseButton(t);e&&this._activePointers.splice(this._activePointers.indexOf(e),1)}let n={pointerId:0,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:0,mouseButton:(e.buttons&tr.LEFT)===tr.LEFT?tr.LEFT:(e.buttons&tr.MIDDLE)===tr.LEFT?tr.MIDDLE:(e.buttons&tr.RIGHT)===tr.LEFT?tr.RIGHT:null};this._activePointers.push(n),this._domElement.removeEventListener("mousemove",l),this._domElement.removeEventListener("mouseup",c),this._domElement.addEventListener("mousemove",l),this._domElement.addEventListener("mouseup",c),f(e)},o=e=>{let t=e.pointerId,n=this._findPointerById(t);if(n){if(n.clientX=e.clientX,n.clientY=e.clientY,n.deltaX=e.movementX,n.deltaY=e.movementY,"touch"===e.pointerType)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else this._state=0,(e.buttons&tr.LEFT)===tr.LEFT&&(this._state=this._state|this.mouseButtons.left),(e.buttons&tr.MIDDLE)===tr.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&tr.RIGHT)===tr.RIGHT&&(this._state=this._state|this.mouseButtons.right);m()}},l=e=>{let t=this._findPointerById(0);t&&(t.clientX=e.clientX,t.clientY=e.clientY,t.deltaX=e.movementX,t.deltaY=e.movementY,this._state=0,(e.buttons&tr.LEFT)===tr.LEFT&&(this._state=this._state|this.mouseButtons.left),(e.buttons&tr.MIDDLE)===tr.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&tr.RIGHT)===tr.RIGHT&&(this._state=this._state|this.mouseButtons.right),m())},h=e=>{let t=e.pointerId,n=this._findPointerById(t);if(n&&this._activePointers.splice(this._activePointers.indexOf(n),1),"touch"===e.pointerType)switch(this._activePointers.length){case 0:this._state=yt.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else this._state=yt.NONE;g()},c=()=>{let e=this._findPointerById(0);e&&this._activePointers.splice(this._activePointers.indexOf(e),1),this._state=yt.NONE,g()},u=-1,d=e=>{if(!this._enabled||this.mouseButtons.wheel===yt.NONE)return;if(this.dollyToCursor||this.mouseButtons.wheel===yt.ROTATE||this.mouseButtons.wheel===yt.TRUCK){let e=performance.now();u-e<1e3&&this._getClientRect(this._elementRect),u=e}let t=yht?-1:-3,n=1===e.deltaMode?e.deltaY/t:e.deltaY/(10*t),i=this.dollyToCursor?(e.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,r=this.dollyToCursor?(e.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case yt.ROTATE:this._rotateInternal(e.deltaX,e.deltaY),this._isUserControllingRotate=!0;break;case yt.TRUCK:this._truckInternal(e.deltaX,e.deltaY,!1),this._isUserControllingTruck=!0;break;case yt.OFFSET:this._truckInternal(e.deltaX,e.deltaY,!0),this._isUserControllingOffset=!0;break;case yt.DOLLY:this._dollyInternal(-n,i,r),this._isUserControllingDolly=!0;break;case yt.ZOOM:this._zoomInternal(-n,i,r),this._isUserControllingZoom=!0}this.dispatchEvent({type:"control"})},p=e=>{if(this._domElement&&this._enabled&&this.mouseButtons.right===Af.ACTION.NONE){let t=e instanceof PointerEvent?e.pointerId:(MouseEvent,0),n=this._findPointerById(t);return n&&this._activePointers.splice(this._activePointers.indexOf(n),1),this._domElement.removeEventListener("pointermove",o),this._domElement.removeEventListener("pointerup",h),this._domElement.removeEventListener("mousemove",l),void this._domElement.removeEventListener("mouseup",c)}},f=e=>{if(this._enabled){if(eC(this._activePointers,bo),this._getClientRect(this._elementRect),n.copy(bo),i.copy(bo),this._activePointers.length>=2){let e=bo.x-this._activePointers[1].clientX,t=bo.y-this._activePointers[1].clientY,n=Math.sqrt(e*e+t*t);r.set(0,n);let a=.5*(this._activePointers[0].clientX+this._activePointers[1].clientX),s=.5*(this._activePointers[0].clientY+this._activePointers[1].clientY);i.set(a,s)}if("pointerType"in e&&"touch"===e.pointerType)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else this._state=0,(e.buttons&tr.LEFT)===tr.LEFT&&(this._state=this._state|this.mouseButtons.left),(e.buttons&tr.MIDDLE)===tr.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(e.buttons&tr.RIGHT)===tr.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&yt.ROTATE)===yt.ROTATE||(this._state&yt.TOUCH_ROTATE)===yt.TOUCH_ROTATE||(this._state&yt.TOUCH_DOLLY_ROTATE)===yt.TOUCH_DOLLY_ROTATE||(this._state&yt.TOUCH_ZOOM_ROTATE)===yt.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&yt.TRUCK)===yt.TRUCK||(this._state&yt.TOUCH_TRUCK)===yt.TOUCH_TRUCK||(this._state&yt.TOUCH_DOLLY_TRUCK)===yt.TOUCH_DOLLY_TRUCK||(this._state&yt.TOUCH_ZOOM_TRUCK)===yt.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&yt.DOLLY)===yt.DOLLY||(this._state&yt.TOUCH_DOLLY)===yt.TOUCH_DOLLY||(this._state&yt.TOUCH_DOLLY_TRUCK)===yt.TOUCH_DOLLY_TRUCK||(this._state&yt.TOUCH_DOLLY_OFFSET)===yt.TOUCH_DOLLY_OFFSET||(this._state&yt.TOUCH_DOLLY_ROTATE)===yt.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&yt.ZOOM)===yt.ZOOM||(this._state&yt.TOUCH_ZOOM)===yt.TOUCH_ZOOM||(this._state&yt.TOUCH_ZOOM_TRUCK)===yt.TOUCH_ZOOM_TRUCK||(this._state&yt.TOUCH_ZOOM_OFFSET)===yt.TOUCH_ZOOM_OFFSET||(this._state&yt.TOUCH_ZOOM_ROTATE)===yt.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&yt.OFFSET)===yt.OFFSET||(this._state&yt.TOUCH_OFFSET)===yt.TOUCH_OFFSET||(this._state&yt.TOUCH_DOLLY_OFFSET)===yt.TOUCH_DOLLY_OFFSET||(this._state&yt.TOUCH_ZOOM_OFFSET)===yt.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})}},m=()=>{if(!this._enabled)return;eC(this._activePointers,bo);let e=!!Dn.isBrowser&&this._domElement&&document.pointerLockElement===this._domElement,t=e?-this._activePointers[0].deltaX:i.x-bo.x,a=e?-this._activePointers[0].deltaY:i.y-bo.y;if(i.copy(bo),((this._state&yt.ROTATE)===yt.ROTATE||(this._state&yt.TOUCH_ROTATE)===yt.TOUCH_ROTATE||(this._state&yt.TOUCH_DOLLY_ROTATE)===yt.TOUCH_DOLLY_ROTATE||(this._state&yt.TOUCH_ZOOM_ROTATE)===yt.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(t,a),this._isUserControllingRotate=!0),(this._state&yt.DOLLY)===yt.DOLLY||(this._state&yt.ZOOM)===yt.ZOOM){let e=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,t=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&yt.DOLLY)===yt.DOLLY?(this._dollyInternal(a*rC,e,t),this._isUserControllingDolly=!0):(this._zoomInternal(a*rC,e,t),this._isUserControllingZoom=!0)}if((this._state&yt.TOUCH_DOLLY)===yt.TOUCH_DOLLY||(this._state&yt.TOUCH_ZOOM)===yt.TOUCH_ZOOM||(this._state&yt.TOUCH_DOLLY_TRUCK)===yt.TOUCH_DOLLY_TRUCK||(this._state&yt.TOUCH_ZOOM_TRUCK)===yt.TOUCH_ZOOM_TRUCK||(this._state&yt.TOUCH_DOLLY_OFFSET)===yt.TOUCH_DOLLY_OFFSET||(this._state&yt.TOUCH_ZOOM_OFFSET)===yt.TOUCH_ZOOM_OFFSET||(this._state&yt.TOUCH_DOLLY_ROTATE)===yt.TOUCH_DOLLY_ROTATE||(this._state&yt.TOUCH_ZOOM_ROTATE)===yt.TOUCH_ZOOM_ROTATE){let e=bo.x-this._activePointers[1].clientX,t=bo.y-this._activePointers[1].clientY,n=Math.sqrt(e*e+t*t),a=r.y-n;r.set(0,n);let s=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,o=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&yt.TOUCH_DOLLY)===yt.TOUCH_DOLLY||(this._state&yt.TOUCH_DOLLY_ROTATE)===yt.TOUCH_DOLLY_ROTATE||(this._state&yt.TOUCH_DOLLY_TRUCK)===yt.TOUCH_DOLLY_TRUCK||(this._state&yt.TOUCH_DOLLY_OFFSET)===yt.TOUCH_DOLLY_OFFSET?(this._dollyInternal(a*rC,s,o),this._isUserControllingDolly=!0):(this._zoomInternal(a*rC,s,o),this._isUserControllingZoom=!0)}((this._state&yt.TRUCK)===yt.TRUCK||(this._state&yt.TOUCH_TRUCK)===yt.TOUCH_TRUCK||(this._state&yt.TOUCH_DOLLY_TRUCK)===yt.TOUCH_DOLLY_TRUCK||(this._state&yt.TOUCH_ZOOM_TRUCK)===yt.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(t,a,!1),this._isUserControllingTruck=!0),((this._state&yt.OFFSET)===yt.OFFSET||(this._state&yt.TOUCH_OFFSET)===yt.TOUCH_OFFSET||(this._state&yt.TOUCH_DOLLY_OFFSET)===yt.TOUCH_DOLLY_OFFSET||(this._state&yt.TOUCH_ZOOM_OFFSET)===yt.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(t,a,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},g=()=>{eC(this._activePointers,bo),i.copy(bo),0===this._activePointers.length&&this._domElement&&(this._domElement.removeEventListener("pointermove",o),this._domElement.removeEventListener("mousemove",l),this._domElement.removeEventListener("pointerup",h),this._domElement.removeEventListener("mouseup",c),this.dispatchEvent({type:"controlend"}))};this._addAllEventListeners=e=>{this._domElement=e,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",a),xht&&this._domElement.addEventListener("mousedown",s),this._domElement.addEventListener("pointercancel",h),this._domElement.addEventListener("wheel",d),this._domElement.addEventListener("contextmenu",p)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",a),this._domElement.removeEventListener("mousedown",s),this._domElement.removeEventListener("pointercancel",h),this._domElement.removeEventListener("wheel",d),this._domElement.removeEventListener("contextmenu",p),this._domElement.removeEventListener("pointermove",o),this._domElement.removeEventListener("mousemove",l),this._domElement.removeEventListener("pointerup",h),this._domElement.removeEventListener("mouseup",c))},this.cancel=()=>{this._state!==yt.NONE&&(this._state=yt.NONE,this._activePointers.length=0,g())},t&&this.connect(t),this.update(0)}static install(e){nr=e.THREE,Gfe=Object.freeze(new nr.Vector3(0,0,0)),iC=Object.freeze(new nr.Vector3(0,1,0)),M5=Object.freeze(new nr.Vector3(0,0,1)),bo=new nr.Vector2,ar=new nr.Vector3,bi=new nr.Vector3,ty=new nr.Vector3,Gu=new nr.Vector3,qu=new nr.Vector3,Vm=new nr.Vector3,qfe=new nr.Vector3,Wfe=new nr.Vector3,Ic=new nr.Spherical,cE=new nr.Spherical,ny=new nr.Box3,jfe=new nr.Box3,R5=new nr.Sphere,Xfe=new nr.Quaternion,A5=new nr.Quaternion,C5=new nr.Matrix4,sC=new nr.Raycaster}static get ACTION(){return yt}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,n=!1){this._isUserControllingRotate=!1;let i=Hm(e,this.minAzimuthAngle,this.maxAzimuthAngle),r=Hm(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=i,this._sphericalEnd.phi=r,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);let a=!n||Hi(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Hi(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(a)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){this._isUserControllingDolly=!1;let n=this._sphericalEnd.radius,i=Hm(e,this.minDistance,this.maxDistance);if(this.colliderMeshes.length>=1){let e=this._collisionTest(),t=Hi(e,this._spherical.radius);if(!(n>i)&&t)return Promise.resolve();this._sphericalEnd.radius=Math.min(i,e)}else this._sphericalEnd.radius=i;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);let r=!t||Hi(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=Hm(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);let n=!t||Hi(this._zoom,this._zoomEnd,this.restThreshold);return this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),Gu.setFromMatrixColumn(this._camera.matrix,0),qu.setFromMatrixColumn(this._camera.matrix,1),Gu.multiplyScalar(e),qu.multiplyScalar(-t);let i=ar.copy(Gu).add(qu),r=bi.copy(this._targetEnd).add(i);return this.moveTo(r.x,r.y,r.z,n)}forward(e,t=!1){ar.setFromMatrixColumn(this._camera.matrix,0),ar.crossVectors(this._camera.up,ar),ar.multiplyScalar(e);let n=bi.copy(this._targetEnd).add(ar);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return ar.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+ar.x,this._targetEnd.y+ar.y,this._targetEnd.z+ar.z,t)}moveTo(e,t,n,i=!1){this._isUserControllingTruck=!1;let r=ar.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,r,this.boundaryFriction),this._needsUpdate=!0,i||this._target.copy(this._targetEnd);let a=!i||Hi(this._target.x,this._targetEnd.x,this.restThreshold)&&Hi(this._target.y,this._targetEnd.y,this.restThreshold)&&Hi(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}lookInDirectionOf(e,t,n,i=!1){let r=ar.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius);return this.setPosition(r.x,r.y,r.z,i)}fitToBox(e,t,{cover:n=!1,paddingLeft:i=0,paddingRight:r=0,paddingBottom:a=0,paddingTop:s=0}={}){let o=[],l=e.isBox3?ny.copy(e):ny.setFromObject(e);l.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());let h=w5(this._sphericalEnd.theta,T5),c=w5(this._sphericalEnd.phi,T5);o.push(this.rotateTo(h,c,t));let u=ar.setFromSpherical(this._sphericalEnd).normalize(),d=Xfe.setFromUnitVectors(u,M5),p=Hi(Math.abs(u.y),1);p&&d.multiply(A5.setFromAxisAngle(iC,h)),d.multiply(this._yAxisUpSpaceInverse);let f=jfe.makeEmpty();bi.copy(l.min).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.min).setX(l.max.x).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.min).setY(l.max.y).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.max).setZ(l.min.z).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.min).setZ(l.max.z).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.max).setY(l.min.y).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.max).setX(l.min.x).applyQuaternion(d),f.expandByPoint(bi),bi.copy(l.max).applyQuaternion(d),f.expandByPoint(bi),f.min.x-=i,f.min.y-=a,f.max.x+=r,f.max.y+=s,d.setFromUnitVectors(M5,u),p&&d.premultiply(A5.invert()),d.premultiply(this._yAxisUpSpace);let m=f.getSize(ar),g=f.getCenter(bi).applyQuaternion(d);if(Rf(this._camera)){let e=this.getDistanceToFitBox(m.x,m.y,m.z,n);o.push(this.moveTo(g.x,g.y,g.z,t)),o.push(this.dollyTo(e,t)),o.push(this.setFocalOffset(0,0,0,t))}else if(Vu(this._camera)){let e=this._camera,i=e.right-e.left,r=e.top-e.bottom,a=n?Math.max(i/m.x,r/m.y):Math.min(i/m.x,r/m.y);o.push(this.moveTo(g.x,g.y,g.z,t)),o.push(this.zoomTo(a,t)),o.push(this.setFocalOffset(0,0,0,t))}return Promise.all(o)}fitToSphere(e,t){let n=[],i=e instanceof nr.Sphere?R5.copy(e):Af.createBoundingSphere(e,R5);if(n.push(this.moveTo(i.center.x,i.center.y,i.center.z,t)),Rf(this._camera)){let e=this.getDistanceToFitSphere(i.radius);n.push(this.dollyTo(e,t))}else if(Vu(this._camera)){let e=this._camera.right-this._camera.left,r=this._camera.top-this._camera.bottom,a=2*i.radius,s=Math.min(e/a,r/a);n.push(this.zoomTo(s,t))}return n.push(this.setFocalOffset(0,0,0,t)),Promise.all(n)}setLookAt(e,t,n,i,r,a,s=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1;let o=bi.set(i,r,a),l=ar.set(e,t,n);this._targetEnd.copy(o),this._sphericalEnd.setFromVector3(l.sub(o).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,s||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));let h=!s||Hi(this._target.x,this._targetEnd.x,this.restThreshold)&&Hi(this._target.y,this._targetEnd.y,this.restThreshold)&&Hi(this._target.z,this._targetEnd.z,this.restThreshold)&&Hi(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Hi(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Hi(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(h)}lerpLookAt(e,t,n,i,r,a,s,o,l,h,c,u,d,p=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1;let f=ar.set(i,r,a),m=bi.set(e,t,n);Ic.setFromVector3(m.sub(f).applyQuaternion(this._yAxisUpSpace));let g=ty.set(h,c,u),v=bi.set(s,o,l);cE.setFromVector3(v.sub(g).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(f.lerp(g,d));let y=cE.theta-Ic.theta,x=cE.phi-Ic.phi,b=cE.radius-Ic.radius;this._sphericalEnd.set(Ic.radius+b*d,Ic.phi+x*d,Ic.theta+y*d),this.normalizeRotations(),this._needsUpdate=!0,p||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));let _=!p||Hi(this._target.x,this._targetEnd.x,this.restThreshold)&&Hi(this._target.y,this._targetEnd.y,this.restThreshold)&&Hi(this._target.z,this._targetEnd.z,this.restThreshold)&&Hi(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Hi(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Hi(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(_)}setPosition(e,t,n,i=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,i)}setTarget(e,t,n,i=!1){let r=this.getPosition(ar),a=this.setLookAt(r.x,r.y,r.z,e,t,n,i);return this._sphericalEnd.phi=Hm(this.polarAngle,this.minPolarAngle,this.maxPolarAngle),a}setFocalOffset(e,t,n,i=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,i||this._focalOffset.copy(this._focalOffsetEnd);let r=!i||Hi(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Hi(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Hi(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),Gu.setFromMatrixColumn(this._camera.matrixWorldInverse,0),qu.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Vm.setFromMatrixColumn(this._camera.matrixWorldInverse,2);let i=ar.set(e,t,n),r=i.distanceTo(this._camera.position),a=i.sub(this._camera.position);Gu.multiplyScalar(a.x),qu.multiplyScalar(a.y),Vm.multiplyScalar(a.z),ar.copy(Gu).add(qu).add(Vm),ar.z=ar.z+r,this.dollyTo(r,!1),this.setFocalOffset(-ar.x,ar.y,-ar.z,!1),this.moveTo(e,t,n,!1)}setBoundary(e){if(!e)return this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),void(this._needsUpdate=!0);this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,n,i){null!==e?(this._viewport=this._viewport||new nr.Vector4,"number"==typeof e?this._viewport.set(e,t,n,i):this._viewport.copy(e)):this._viewport=null}getDistanceToFitBox(e,t,n,i=!1){if(tC(this._camera,"getDistanceToFitBox"))return this._spherical.radius;let r=e/t,a=this._camera.getEffectiveFOV()*Jv,s=this._camera.aspect;return.5*((i?r>s:rt.pointerId===e))}_findPointerByMouseButton(e){return this._activePointers.find((t=>t.mouseButton===e))}_encloseToBoundary(e,t,n){let i=t.lengthSq();if(0===i)return e;let r=bi.copy(t).add(e),a=this._boundary.clampPoint(r,ty).sub(r),s=a.lengthSq();if(0===s)return e.add(t);if(s===i)return e;if(0===n)return e.add(t).add(a);{let i=1+n*s/t.dot(a);return e.add(bi.copy(t).multiplyScalar(i)).add(a.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(Rf(this._camera)){let e=this._camera,t=e.near,n=e.getEffectiveFOV()*Jv,i=Math.tan(.5*n)*t,r=i*e.aspect;this._nearPlaneCorners[0].set(-r,-i,0),this._nearPlaneCorners[1].set(r,-i,0),this._nearPlaneCorners[2].set(r,i,0),this._nearPlaneCorners[3].set(-r,i,0)}else if(Vu(this._camera)){let e=this._camera,t=1/e.zoom,n=e.left*t,i=e.right*t,r=e.top*t,a=e.bottom*t;this._nearPlaneCorners[0].set(n,r,0),this._nearPlaneCorners[1].set(i,r,0),this._nearPlaneCorners[2].set(i,a,0),this._nearPlaneCorners[3].set(n,a,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||tC(this._camera,"_collisionTest"))return e;let t=ar.setFromSpherical(this._spherical).divideScalar(this._spherical.radius);C5.lookAt(Gfe,t,this._camera.up);for(let n=0;n<4;n++){let i=bi.copy(this._nearPlaneCorners[n]);i.applyMatrix4(C5);let r=ty.addVectors(this._target,i);sC.set(r,t),sC.far=this._spherical.radius+1;let a=sC.intersectObjects(this.colliderMeshes);0!==a.length&&a[0].distance{let t=()=>{this.removeEventListener("rest",t),e()};this.addEventListener("rest",t)})))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new nr.Sphere){let n=t,i=n.center;ny.makeEmpty(),e.traverseVisible((e=>{e.isMesh&&ny.expandByObject(e)})),ny.getCenter(i);let r=0;return e.traverseVisible((e=>{if(!e.isMesh)return;let t=e,n=t.geometry.clone();if(n.applyMatrix4(t.matrixWorld),n.isBufferGeometry){let e=n.attributes.position;for(let t=0,n=e.count;t{if(this.enabled){switch(e.code){case this.keys.up:e.ctrlKey||e.metaKey||e.shiftKey?(this._rotateInternal(0,1),this._isUserControllingRotate=!0):(this._truckInternal(0,this.keyTruckSpeed,!1),this._isUserControllingTruck=!0);break;case this.keys.bottom:e.ctrlKey||e.metaKey||e.shiftKey?(this._rotateInternal(0,-1),this._isUserControllingRotate=!0):(this._truckInternal(0,-this.keyTruckSpeed,!1),this._isUserControllingTruck=!0);break;case this.keys.left:e.ctrlKey||e.metaKey||e.shiftKey?(this._rotateInternal(1,0),this._isUserControllingRotate=!0):(this._truckInternal(this.keyTruckSpeed,0,!1),this._isUserControllingTruck=!0);break;case this.keys.right:e.ctrlKey||e.metaKey||e.shiftKey?(this._rotateInternal(-1,0),this._isUserControllingRotate=!0):(this._truckInternal(-this.keyTruckSpeed,0,!1),this._isUserControllingTruck=!0)}this.dispatchEvent({type:"control"})}},this.onKeyUp=e=>{this.dispatchEvent({type:"controlend"})},this._getClientRect(this._elementRect),this.dollySpeedBackup=this.dollySpeed,this.azimuthRotateSpeedBackup=this.azimuthRotateSpeed,this.polarRotateSpeedBackup=this.polarRotateSpeed,this.truckSpeedBackup=this.truckSpeed}get enableZoom(){return!!this.dollySpeed}set enableZoom(e){e?this.dollySpeed=this.dollySpeedBackup:(this.dollySpeedBackup=this.dollySpeed,this.dollySpeed=0)}get enableRotate(){return!!this.azimuthRotateSpeed||!!this.polarRotateSpeed}set enableRotate(e){e?(this.azimuthRotateSpeed=this.azimuthRotateSpeedBackup,this.polarRotateSpeed=this.polarRotateSpeedBackup):(this.azimuthRotateSpeedBackup=this.azimuthRotateSpeed,this.polarRotateSpeedBackup=this.polarRotateSpeed,this.azimuthRotateSpeed=0,this.polarRotateSpeed=0)}get enableTruck(){return!!this.truckSpeed}set enableTruck(e){e?this.truckSpeed=this.truckSpeedBackup:(this.truckSpeedBackup=this.truckSpeed,this.truckSpeed=0)}listenToKeyEvents(){var e,t;null==(e=this._domElement)||e.addEventListener("keydown",this.onKeyDown),null==(t=this._domElement)||t.addEventListener("keyup",this.onKeyUp)}stopListenToKeyEvents(){var e,t;null==(e=this._domElement)||e.removeEventListener("keydown",this.onKeyDown),null==(t=this._domElement)||t.removeEventListener("keyup",this.onKeyUp)}dispose(){super.dispose(),this.stopListenToKeyEvents()}},kl=class{constructor(e){this.name=e}},aC=class{constructor(e){this.history=[],this.step=0,this.maxCount=50,this.isBatchCommand=!1,this.batchCommands=[],this.maxCount=e||this.maxCount}addCommand(e){this.isBatchCommand?this.batchCommands.push(e):(this.history.length===this.maxCount&&this.history.shift(),this.step!==this.history.length&&this.history.splice(this.step),this.history.push(e),this.step++)}startTransaction(){this.isBatchCommand=!0}endTransaction(){this.history.length===this.maxCount&&this.history.shift(),this.step!==this.history.length&&this.history.splice(this.step),this.batchCommands.length>0&&(this.history.push(this.batchCommands.slice()),this.step++),this.isBatchCommand=!1,this.batchCommands=[]}undo(){if(this.canUndo())return!1;this.step--;let e=this.history[this.step];return e&&(Array.isArray(e)?e.forEach((e=>e.undo())):e.undo()),!0}redo(){if(this.canRedo())return!1;this.step++;let e=this.history[this.step-1];return e&&(Array.isArray(e)?e.forEach((e=>e.redo())):e.redo()),!0}getCommands(){return this.history}canUndo(){return this.step<=0}canRedo(){return this.step>=this.history.length}clear(){this.history=[],this.step=0}destroy(){this.clear(),this.maxCount=0}},uE=class extends kl{constructor(e,t){super("AddMarkup"),this.manager=e,this.data=t}undo(){let e=this.manager.getMarkupById(this.data.id);return!!e&&(this.manager.removeMarkup(e),!0)}redo(){let e=this.manager.createMarkup(this.data);return!!e&&(this.manager.addMarkup(e),!0)}},oC=class extends kl{constructor(e,t,n){super("UpdateMarkup"),this.manager=e,this.oldData=t,this.newData=n}undo(){let e=this.manager.getMarkupById(this.oldData.id);return!!e&&(this.manager.updateMarkup(e,this.oldData),!0)}redo(){let e=this.manager.getMarkupById(this.newData.id);return!!e&&(this.manager.updateMarkup(e,this.newData),!0)}},zm=class extends kl{constructor(e,t){super("RemoveMarkup"),this.manager=e,this.data=t}undo(){let e=this.manager.createMarkup(this.data);return!!e&&(this.manager.addMarkup(e),!0)}redo(){let e=this.manager.getMarkupById(this.data.id);return!!e&&(this.manager.removeMarkup(e),!0)}},hE=class extends kl{constructor(e,t){super("AddMeasurement"),this.manager=e,this.data=t}undo(){let e=this.manager.getById(this.data.id);return!!e&&(this.manager.remove(e),!0)}redo(){let e=this.manager.create(this.data);return!!e&&(this.manager.add(e),!0)}},ry=class extends kl{constructor(e,t){super("RemoveMeasurement"),this.manager=e,this.data=t}undo(){let e=this.manager.create(this.data);return!!e&&(this.manager.add(e),!0)}redo(){let e=this.manager.getById(this.data.id);return!!e&&(this.manager.remove(e),!0)}},Yfe=new O,dE=class extends us{constructor(e,t){var n;super(),this.drawableList=new Ko("markup"),this.lineWidth=2,this.lineColor=[1,0,0,1],this.fillColor=[1,0,0,.3],this.fontSize=20,this.mouseDown=!1,this.mouseDownPositionX=void 0,this.mouseDownPositionY=void 0,this.isSelectLeaderText=!1,this.isDrawing=!1,this.tempPoints=[],this.activated=!1,this.handleDbClick=()=>{},this.handleInputMousemove=e=>{if(!this.mouseDown&&"CloudRectWithTextMarkup"===this.type&&this.isDrawing&&this.creatingShape){let t=cn.getScreenPointByEvent(e,this.viewerCanvas);this.creatingShape.updateInputPosition(this.mousedownPoint,t),this.render()}},this.mousedown=e=>{var t;if(e.pointers&&e.pointers.length>1)return;let n=this.pickThreejsPositionByMouse(e);if(n){if(n.z=0,this.mouseDownPositionX=n.x,this.mouseDownPositionY=n.y,this.mousedownPoint=new be(e.x,e.y),0===e.button&&(this.mouseDown=!0),2===e.button)return void(this.isDrawing&&this.endDraw(this.creatingShape));if(this.selectedShape&&(this.selectedShape.selected=!1,this.selectedShape=void 0,this.render()),!this.isDrawing){let e=this.drawableList.getDrawableByPosition(n);e&&(this.selectedShape=e,e.selected=!0,e instanceof Bm&&(this.isSelectLeaderText=e.isLeaderTextSelected(n)),this.render())}if(this.isCreateTextMode()&&this.mouseDown&&!this.selectedShape){this.creatingShape||(this.creatingShape=this.drawText(n,""));let t=this.creatingShape;0===t.text.length?(t.setTolerance(this.viewer.getPixelSizeInWorldCoord()),t.update([n]),t.addInput(this,e.x,e.y)):(t.exitEditing(),this.addMarkup(t,!1),this.endDraw(t)),this.render()}if(this.isCreateLineMode()&&this.mouseDown&&!this.selectedShape){if(this.tempPoints.length>0){let e=this.tempPoints[0];if(Yfe.subVectors(e,n).length()<5*this.viewer.getPixelSizeInWorldCoord())return n=this.tempPoints[0].clone(),this.tempPoints.push(n),void this.endDraw(this.creatingShape)}if(this.isDrawing=!0,this.tempPoints.push(n),!this.creatingShape){let e=this.creatingShape=this.drawLine([...this.tempPoints,n]);e&&this.addMarkup(e,!1)}this.creatingShape&&(this.creatingShape.update([...this.tempPoints,n]),this.render()),this.dispatchEvent("StartDraw",this.creatingShape)}if(this.isCreateDotMode()&&this.mouseDown&&!this.selectedShape){if(!this.creatingShape){let e=this.creatingShape=this.drawShape(n);e&&this.addMarkup(e,!1)}this.isDrawing=!0,this.render()}null==(t=this.creatingShape)||t.setTolerance(this.viewer.getPixelSizeInWorldCoord())}},this.mousemove=e=>{if(e.pointers&&e.pointers.length>1)return;let t=this.pickThreejsPositionByMouse(e);if(t)if(t.z=0,this.selectedShape){if(this.mouseDown&&void 0!==this.mouseDownPositionX&&void 0!==this.mouseDownPositionY){this.isEditing()||(this.initialDataForEditing=this.selectedShape.getData());let e=t.x-this.mouseDownPositionX,n=t.y-this.mouseDownPositionY;this.selectedShape instanceof Bm&&this.isSelectLeaderText?this.selectedShape.translateLeaderText(e,n):this.selectedShape.translate(e,n),this.render(),this.mouseDownPositionX=t.x,this.mouseDownPositionY=t.y}}else{if(this.isCreateDotMode())return;if(this.mouseDown&&this.isCreateShapeMode()&&void 0!==this.mouseDownPositionX&&void 0!==this.mouseDownPositionY){let e=new O(this.mouseDownPositionX,this.mouseDownPositionY,0);if(!this.creatingShape){let n=this.creatingShape=this.drawShape(e,t);n&&this.addMarkup(n,!1)}this.creatingShape.update([e,t]),this.isDrawing=!0,this.render()}if(this.isCreateLineMode()&&this.tempPoints.length>0&&this.isDrawing){let e=this.tempPoints[0];Yfe.subVectors(e,t).length()<5*this.viewer.getPixelSizeInWorldCoord()&&(t=this.tempPoints[0].clone()),this.creatingShape.update([...this.tempPoints,t]),this.render()}}},this.mouseup=e=>{if(this.mouseDown=!1,this.selectedShape&&this.isEditing()&&this.endEdit(this.selectedShape),this.isCreateShapeMode()&&this.isDrawing&&this.creatingShape)if("LeaderLineMarkup"===this.type){let t=this.creatingShape;t.isEditing?t.exitEditing():(t.setFontSize(this.fontSize*this.viewer.getPixelSizeInWorldCoord()),t.addInput(this,e.x,e.y)),t.addEventListener("ExitEditing",(()=>{this.isDrawing=!1,this.endDraw(this.creatingShape)}))}else if("CloudRectWithTextMarkup"===this.type){let t=this.creatingShape;t.setFontSize(this.fontSize*this.viewer.getPixelSizeInWorldCoord()),t.addInput(this,e.x,e.y),t.addEventListener("ExitEditing",(()=>{this.isDrawing=!1,this.endDraw(this.creatingShape)}))}else this.endDraw(this.creatingShape)},this.keydown=e=>{var t;"Delete"===e.code?this.selectedShape&&(this.viewer.hasEventListener("BeforeRemoveMarkup")?this.viewer.dispatchEvent("BeforeRemoveMarkup",this.confirmToRemove.bind(this)):(this.removeMarkup(this.selectedShape),null==(t=this.viewer.undoRedoManager)||t.addCommand(new zm(this,this.selectedShape.getData())),this.selectedShape=void 0)):"Escape"===e.code&&this.cancelDraw(this.creatingShape)},this.viewer=e,this.inputManager=t,this.overlayRender=this.viewer.overlayRender,null==(n=this.overlayRender)||n.addDrawableList(this.drawableList)}get viewerCanvas(){var e;return null==(e=this.viewer.renderer)?void 0:e.domElement}get camera(){return this.viewer.camera}get raycaster(){return this.viewer.getRaycaster()}setMarkupVisibility(e,t){let n=this.drawableList.getDrawables().get(e);return!!n&&(n.visible!==t&&(n.visible=t,this.render()),!0)}setMarkupsVisibility(e){let t=!1;this.drawableList.getDrawables().forEach((n=>{n.visible!==e&&(n.visible=e,t=!0)})),t&&this.render()}clearAll(){this.drawableList.clear(),this.isDrawing&&this.reset(),this.render()}isMarkupActive(){return this.activated}createMobileExitButton(){let e=this.viewer.widgetContainer,t=document.createElement("button");return t.innerText="X",t.style.cssText="position: absolute;right: 5%; top: 5%;background-color: #000000;color: #ffffff;padding: 3px 10px;font-weight: bolder;",null==e||e.appendChild(t),this.exitButton=t,this.exitButton.style.display="none",t.addEventListener("touchstart",(()=>{this.isDrawing&&this.endDraw(this.creatingShape),this.exitButton&&(this.exitButton.style.display="none")})),this.addEventListener("StartDraw",(()=>{this.exitButton&&(this.exitButton.style.display="inline")})),this.addEventListener("EndDraw",(()=>{this.exitButton&&(this.exitButton.style.display="none")})),this.exitButton}activate(){this.activated=!0,Dn.isMobile?(this.inputManager.addEventListener("touchstart",this.mousedown),this.inputManager.addEventListener("touchmove",this.mousemove),this.inputManager.addEventListener("touchend",this.mouseup)):(this.inputManager.addEventListener("mousedown",this.mousedown),this.inputManager.addEventListener("mousemove",this.mousemove),this.inputManager.addEventListener("mouseup",this.mouseup),this.inputManager.addEventListener("dblclick",this.handleDbClick)),this.inputManager.addEventListener("keydown",this.keydown),window.addEventListener("mousemove",this.handleInputMousemove);let e=this.viewer.controls;this.tempKey=e.mouseButtons.left,e.mouseButtons.left=yt.NONE,this.tempTouch=e.touches.one,e.touches.one=yt.NONE,this.tempArrowKeys=e.keys,e.keys={},this.render()}deactivate(){this.activated=!1,Dn.isMobile?(this.inputManager.removeEventListener("touchstart",this.mousedown),this.inputManager.removeEventListener("touchmove",this.mousemove),this.inputManager.removeEventListener("touchend",this.mouseup)):(this.inputManager.removeEventListener("mousedown",this.mousedown),this.inputManager.removeEventListener("mousemove",this.mousemove),this.inputManager.removeEventListener("mouseup",this.mouseup),this.inputManager.removeEventListener("dblclick",this.handleDbClick)),this.inputManager.removeEventListener("keydown",this.keydown),window.removeEventListener("mousemove",this.handleInputMousemove),this.viewer.controls.mouseButtons.left=this.tempKey,this.viewer.controls.keys=this.tempArrowKeys,this.viewer.controls.touches.one=this.tempTouch,this.mouseDown=!1,this.tempPoints=[],this.isDrawing=!1,this.creatingShape=void 0,this.selectedShape&&(this.selectedShape.selected=!1,this.selectedShape=void 0),this.render()}getActiveMarkupType(){return this.type}setDrawType(e){this.type=e,this.reset()}setLineWidth(e){this.lineWidth=e}getLineWidth(){return this.lineWidth}setLineColor(e){this.lineColor=e}getLineColor(){return this.lineColor}setFillColor(e){this.fillColor=e}getFillColor(){return this.fillColor}setFontSize(e){this.fontSize=e}getFontSize(){return this.fontSize}pickPositionByScreenPoint(e){let t,n=cn.screenPoint2NdcPoint(e,this.camera,this.viewerCanvas);this.raycaster.layers.set(10),this.raycaster.setFromCamera(n,this.camera);let i=this.viewer.scene,r=this.raycaster.intersectObject(this.viewer.groundPlane||i)||[];return r.length>0&&(t=r[0].point),t}pickThreejsPositionByMouse(e){return this.pickPositionByScreenPoint(new be(e.x,e.y))}confirmToRemove(e){var t;this.selectedShape&&e&&(this.removeMarkup(this.selectedShape),null==(t=this.viewer.undoRedoManager)||t.addCommand(new zm(this,this.selectedShape.getData())),this.selectedShape=void 0)}isEditing(){return!!this.initialDataForEditing}endEdit(e){var t;if(!this.initialDataForEditing)return;let n=e.getData();this.viewer.dispatchEvent("MarkupUpdated",{oldData:this.initialDataForEditing,newData:n}),this.dispatchEvent("EndEdit",e),null==(t=this.viewer.undoRedoManager)||t.addCommand(new oC(this,this.initialDataForEditing,n)),this.initialDataForEditing=void 0,this.isSelectLeaderText=!1}endDraw(e){var t;if("PolylineMarkup"===this.type&&this.creatingShape&&(this.tempPoints.length<2?(this.removeMarkup(this.creatingShape,!1),this.creatingShape=void 0):this.creatingShape.update(this.tempPoints)),e){let n=e.getData();this.viewer.dispatchEvent("MarkupAdded",n),null==(t=this.viewer.undoRedoManager)||t.addCommand(new uE(this,n))}this.dispatchEvent("EndDraw",e),this.reset()}cancelDraw(e){e&&this.removeMarkup(e,!1),this.reset()}reset(){this.tempPoints=[],this.isDrawing=!1,this.creatingShape=void 0,this.mouseDownPositionX=void 0,this.mouseDownPositionY=void 0,this.mousedownPoint=void 0,this.isSelectLeaderText=!1,this.selectedShape&&(this.selectedShape.selected=!1,this.selectedShape=void 0),this.render()}render(){var e;null==(e=this.overlayRender)||e.render()}addMarkup(e,t=!0){this.drawableList.addDrawable(e),this.render(),t&&this.viewer.dispatchEvent("MarkupAdded",e.getData())}updateMarkup(e,t,n=!0){this.drawableList.updateDrawable(e,t),this.render(),n&&this.viewer.dispatchEvent("MarkupUpdated",{oldData:e.getData(),newData:t})}removeMarkup(e,t=!0){this.drawableList.removeDrawable(e),this.render(),t&&this.viewer.dispatchEvent("MarkupRemoved",e.getData())}removeMarkupById(e){let t=this.getMarkupById(e);return!!t&&(this.removeMarkup(t,!1),!0)}createMarkup(e){return Un.createDrawable(e)}getMarkupById(e){return this.drawableList.getDrawableById(e)}getMarkupData(){return this.drawableList.getDrawableDatas()}setMarkupData(e){var t,n;null==(t=this.viewer.undoRedoManager)||t.startTransaction(),e.forEach((e=>{var t;this.addMarkup(this.createMarkup(e)),null==(t=this.viewer.undoRedoManager)||t.addCommand(new uE(this,e))})),null==(n=this.viewer.undoRedoManager)||n.endTransaction(),this.render()}isCreateLineMode(){return["PolylineMarkup","CloudLineMarkup"].includes(this.type)}isCreateDotMode(){return["DotMarkup"].includes(this.type)}isCreateTextMode(){return["TextMarkup"].includes(this.type)}isCreateShapeMode(){return["XMarkup","RectMarkup","CloudRectMarkup","CircleMarkup","EllipseMarkup","ArrowMarkup","LeaderLineMarkup","CloudRectWithTextMarkup","DotMarkup"].includes(this.type)}drawShape(e,t){let n=[[e.x,e.y]];return t&&n.push([t.x,t.y]),Un.createDrawable({id:Mt.guid(),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,type:this.type,points:n})}drawLine(e){return Un.createDrawable({id:Mt.guid(),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,type:this.type,points:e.map((e=>[e.x,e.y]))})}drawText(e,t){return Un.createDrawable({id:Mt.guid(),lineWidth:this.lineWidth,lineColor:this.lineColor,fillColor:this.fillColor,fontSize:this.fontSize*this.viewer.getPixelSizeInWorldCoord(),type:this.type,text:t,points:[[e.x,e.y]]})}destroy(){this.deactivate(),this.clearAll()}},$fe=new O,Gm=class extends Bi{constructor(e,t){super(e),this.lineSegments=[],this.boxes=t,this.lineColor=[1,0,0,1],this.lineWidth=2,this.calculateCloudLineSegments(t)}calculateCloudLineSegments(e){var t;for(let n=0;n(e[e.Mesh=-1]="Mesh",e[e.MeshWithPattern=0]="MeshWithPattern",e[e.LineWithWidth=1]="LineWithWidth",e[e.Line=2]="Line",e[e.LineWithPattern=3]="LineWithPattern",e[e.Point=4]="Point",e[e.Text=5]="Text",e))(Zfe||{}),qm=["INSERT","DIMENSION"],aVt=ji(tpe(),1),lC=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215],ay=class{constructor(){this.pointer=0,this.eof=!1}},L5=ji(npe(),1),Cf=class{constructor(e,t){this.endian=t&&"big"===t?"big":"little",this.position=0,this.data=new DataView(e)}readAsciiString(e){if(this.data.byteLength=0&&e<=9)return this.readNullTerminatedString();if(e>=10&&e<=59)return this.reader.readFloat64();if(e>=60&&e<=79)return this.reader.readInt16();if(e>=90&&e<=99)return this.reader.readInt32();if(e>=100&&e<=109)return this.readNullTerminatedString();if(e>=110&&e<=149)return this.reader.readFloat64();if(e>=160&&e<=169)return this.reader.readInt64();if(e>=170&&e<=179)return this.reader.readInt16();if(e>=210&&e<=239)return this.reader.readFloat64();if(e>=270&&e<=289)return this.reader.readInt16();if(e>=290&&e<=299)return this.reader.readInt8()>0;if(e>=300&&e<=309)return this.readNullTerminatedString();if(e>=310&&e<=319)return ipe(this.ReadBinaryData());if(e>=320&&e<=369)return this.readNullTerminatedString();if(e>=370&&e<=389)return this.reader.readInt16();if(e>=390&&e<=399)return this.readNullTerminatedString();if(e>=400&&e<=409)return this.reader.readInt16();if(e>=410&&e<=419)return this.readNullTerminatedString();if(e>=420&&e<=429)return this.reader.readInt32();if(e>=430&&e<=439)return this.readNullTerminatedString();if(e>=440&&e<=459)return this.reader.readInt32();if(e>=460&&e<=469)return this.reader.readFloat64();if(e>=470&&e<=481)return this.readNullTerminatedString();if(999===e)throw new Error("The comment group 999, is not used in binary DXF files at byte address!");return 1004===e?ipe(this.ReadBinaryData()):e>=1e3&&e<=1009?this.readNullTerminatedString():e>=1010&&e<=1059?this.reader.readFloat64():e>=1060&&e<=1070?this.reader.readInt16():1071===e?this.reader.readInt32():void se.warn(`[DxfBinReader] Invalid code '${e}' at byte address ${this.reader.getPosition()}`)}readNullTerminatedString(){var e;this.decoder||(this.decoder=new TextDecoder("utf-8"));let t=0,n=this.reader.readInt8();for(;0!==n;)this.int8Array[t++]=n,n=this.reader.readInt8();if(0===t)return"";if(t>rpe)return se.warn(`[DxfBinReader] Failed to read string! The number of bytes is ${t} !`),"";let i=this.int8Array.subarray(0,t),r=i.toString();if(this.caches.get(r))return this.caches.get(r);let a=null==(e=this.decoder)?void 0:e.decode(i);return this.caches.set(r,a),a}ReadBinaryData(){let e=this.reader.readUint8();return this.reader.readBytes(e)}};function ipe(e){return Array.prototype.map.call(e,(e=>("00"+e.toString(16)).slice(-2))).join("")}var oy=class extends ay{constructor(e){super(),this.data=e}next(){if(!this.hasNext())throw this.eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this.data[this.pointer]);let e={code:parseInt(this.data[this.pointer])};return this.pointer++,e.value=Eht(e.code,this.data[this.pointer].trim()),this.pointer++,0===e.code&&"EOF"===e.value&&(this.eof=!0),this.lastReadGroup=e,e}hasNext(){return!(this.eof||this.pointer>this.data.length-2)}isEOF(){return this.eof}};function Eht(e,t){return e>=0&&e<=9?t:e>=10&&e<=59?parseFloat(t):e>=60&&e<=99?parseInt(t):e>=100&&e<=109?t:e>=110&&e<=149?parseFloat(t):e>=160&&e<=179?parseInt(t):e>=210&&e<=239?parseFloat(t):e>=270&&e<=289?parseInt(t):e>=290&&e<=299?_ht(t):e>=300&&e<=369?t:e>=370&&e<=389?parseInt(t):e>=390&&e<=399?t:e>=400&&e<=409?parseInt(t):e>=410&&e<=419?t:e>=420&&e<=429?parseInt(t):e>=430&&e<=439?t:e>=440&&e<=459?parseInt(t):e>=460&&e<=469?parseFloat(t):e>=470&&e<=481||999===e||e>=1e3&&e<=1009?t:e>=1010&&e<=1059?parseFloat(t):e>=1060&&e<=1071?parseInt(t):(se.info("WARNING: Group code does not have a defined type: %j",{code:e,value:t}),t)}function _ht(e){if("0"===e)return!1;if("1"===e)return!0;throw TypeError("String '"+e+"' cannot be cast to Boolean type")}var ope=ji(Fl(),1),Tht="OriginalHandle",wht="OriginalType",Sht="Outlines",spe=["PROXY","REGION","INSERT","HATCH"];function Wm(e){return lC[e]}function Ft(e){let t={},n=e.lastReadGroup,i=n.code;if(t.x=n.value,i+=10,n=e.next(),n.code!=i)throw new Error(`Expected code for point value to be ${i} but got ${n.code}`);return t.y=n.value,i+=10,n=e.next(),n.code!=i||(t.z=n.value,e.next()),t}function ape(e,t){let n=e.lastReadGroup,i=[];for(let r=0;r<16;r++){if(n.code!==t)throw new Error(`Expected code for matrix value to be ${t} but got ${n.code}`);i.push(n.value),n=e.next()}return i}function Nn(e,t){switch(t.code){case 0:e.type=t.value;break;case 5:e.handle=t.value;break;case 6:e.lineType=t.value.toUpperCase();break;case 8:e.layer=t.value;break;case 48:e.lineTypeScale=t.value,e.lineTypeScale<=0&&(e.lineTypeScale=1);break;case 60:e.visible=0===t.value;break;case 62:e.isTrueColor||(e.colorIndex=t.value,e.colorIndex<0&&se.warn("[DxfParser] a negative value of colorIndex indicates that the layer is turned off"),e.color=Wm(Math.abs(t.value)));break;case 67:e.inPaperSpace=0!==t.value;break;case 100:case 1001:break;case 330:e.ownerHandle=t.value;break;case 347:e.materialObjectHandle=t.value;break;case 370:e.lineweight=t.value;break;case 410:e.layoutName=t.value;break;case 420:e.isTrueColor=!0,e.color=t.value;break;case 1e3:if(t.value&&t.value.includes(Tht)){let n=t.value.split(":").map((e=>e.trim()));e.extendedData||(e.extendedData={}),e.extendedData.originalHandle=n[1]}if(e.extendedData&&e.extendedData.outlines)try{e.extendedData.outlines=JSON.parse(t.value||"[]")}catch(t){e.extendedData.outlines=void 0}if(t.value&&t.value.includes(Sht)&&(e.extendedData||(e.extendedData={}),e.extendedData.outlines=[]),t.value&&t.value.includes(wht)){let n=t.value.split(":").map((e=>e.trim()));e.extendedData||(e.extendedData={}),e.extendedData.originalType=n[1]}break;default:return!1}return!0}function Nl(e,t){switch(t.code){case 0:e.type=t.value;break;case 5:e.handle=t.value;break;case 330:e.ownerHandle=t.value;break;case 1e3:case 1001:break;default:return!1}return!0}var gE=class{constructor(){this.ForEntityName="3DFACE"}parseEntity(e,t){let n={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 70:if(0!==t.value){let e=Math.log2(t.value)-1;n.vertices.splice(e,1)}t=e.next();break;case 10:n.vertices=Mht(e,t),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}return n}};function Mht(e,t){let n=[],i=!1,r=!1;for(let a=0;a<=4;a++){let a={};for(;!e.isEOF()&&0!==t.code&&!r;){switch(t.code){case 10:case 11:case 12:case 13:if(i){r=!0;continue}a.x=t.value,i=!0;break;case 20:case 21:case 22:case 23:a.y=t.value;break;case 30:case 31:case 32:case 33:a.z=t.value;break;default:return n}t=e.next()}(0,ope.isEmpty)(a)||n.push(a),i=!1,r=!1}return n}var vE=class{constructor(){this.ForEntityName="ARC"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.center=Ft(e),t=e.lastReadGroup;break;case 40:n.radius=t.value,t=e.next();break;case 50:n.startAngle=Math.PI/180*t.value,t=e.next();break;case 51:n.endAngle=Math.PI/180*t.value,n.angleLength=n.endAngle-n.startAngle,t=e.next();break;case 210:n.extrusionDirectionX=t.value,t=e.next();break;case 220:n.extrusionDirectionY=t.value,t=e.next();break;case 230:n.extrusionDirectionZ=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}return n}},yE=class{constructor(){this.ForEntityName="ATTDEF"}parseEntity(e,t){let n={type:t.value,xScale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 1:n.text=t.value,t=e.next();break;case 2:n.tag=t.value,t=e.next();break;case 3:n.prompt=t.value,t=e.next();break;case 7:n.textStyle=t.value,t=e.next();break;case 10:n.startPoint=Ft(e),t=e.lastReadGroup;break;case 11:n.endPoint=Ft(e),t=e.lastReadGroup;break;case 39:n.thickness=t.value,t=e.next();break;case 40:n.textHeight=t.value,t=e.next();break;case 41:n.xScale=t.value,t=e.next();break;case 50:n.rotation=t.value,t=e.next();break;case 51:n.obliqueAngle=t.value,t=e.next();break;case 70:n.invisible=!!(1&t.value),n.constant=!!(2&t.value),n.verificationRequired=!!(4&t.value),n.preset=!!(8&t.value),t=e.next();break;case 71:n.backwards=!!(2&t.value),n.mirrored=!!(4&t.value),t=e.next();break;case 72:n.horizontalJustification=t.value,t=e.next();break;case 73:n.fieldLength=t.value,t=e.next();break;case 74:n.verticalJustification=t.value,t=e.next();break;case 100:t=e.next();break;case 210:n.extrusionDirectionX=t.value,t=e.next();break;case 220:n.extrusionDirectionY=t.value,t=e.next();break;case 230:n.extrusionDirectionZ=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}return n}},xE=class{constructor(){this.ForEntityName="ATTRIB"}parseEntity(e,t){let n={type:t.value,xScale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 1:n.text=t.value,t=e.next();break;case 2:n.tag=t.value,t=e.next();break;case 3:n.prompt=t.value,t=e.next();break;case 7:n.textStyle=t.value,t=e.next();break;case 10:n.startPoint=Ft(e),t=e.lastReadGroup;break;case 11:n.endPoint=Ft(e),t=e.lastReadGroup;break;case 39:n.thickness=t.value,t=e.next();break;case 40:n.textHeight=t.value,t=e.next();break;case 41:n.xScale=t.value,t=e.next();break;case 50:n.rotation=t.value,t=e.next();break;case 51:n.obliqueAngle=t.value,t=e.next();break;case 70:n.invisible=!!(1&t.value),n.constant=!!(2&t.value),n.verificationRequired=!!(4&t.value),n.preset=!!(8&t.value),t=e.next();break;case 71:n.backwards=!!(2&t.value),n.mirrored=!!(4&t.value),t=e.next();break;case 72:n.horizontalJustification=t.value,t=e.next();break;case 73:n.fieldLength=t.value,t=e.next();break;case 74:n.verticalJustification=t.value,t=e.next();break;case 100:t=e.next();break;case 210:n.extrusionDirectionX=t.value,t=e.next();break;case 220:n.extrusionDirectionY=t.value,t=e.next();break;case 230:n.extrusionDirectionZ=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}return n}},bE=class{constructor(){this.ForEntityName="CIRCLE"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.center=Ft(e),t=e.lastReadGroup;break;case 40:n.radius=t.value,t=e.next();break;case 50:n.startAngle=Math.PI/180*t.value,t=e.next();break;case 51:let i=Math.PI/180*t.value;i=0&&n.push({angle:e,origin:r,delta:a,dashPattern:o})}return n}function Iht(e,t){let n=[],i=t.next();for(;n.length0&&(n.colorIndex=t.value,n.color=Wm(Math.abs(t.value))))}t=e.next();break;default:Nn(n,t),t=e.next()}return n}};function Lht(e){switch(e){case 40:return"DIMSCALE";case 41:return"DIMASZ";case 42:return"DIMEXO";case 44:return"DIMEXE";case 75:return"DIMSE1";case 76:return"DIMSE2";case 77:return"DIMTAD";case 140:return"DIMTXT";case 144:return"DIMLFAC";case 147:return"DIMGAP";case 176:return"DIMCLRD";case 178:return"DIMCLRT";case 271:return"DIMDEC";case 341:return"DIMLDRBLK";default:return null}}var RE=class{constructor(){this.ForEntityName="LINE"}parseEntity(e,t){let n={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.vertices.unshift(Ft(e)),t=e.lastReadGroup;break;case 11:n.vertices.push(Ft(e)),t=e.lastReadGroup;break;case 210:n.extrusionDirection=Ft(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}return n}},AE=class{constructor(){this.ForEntityName="LWPOLYLINE"}parseEntity(e,t){let n={type:t.value,vertices:[]},i=0;for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 38:n.elevation=t.value,t=e.next();break;case 39:n.thickness=t.value,t=e.next();break;case 70:n.shape=1==(1&t.value),n.hasContinuousLinetypePattern=128==(128&t.value),t=e.next();break;case 90:i=t.value,t=e.next();break;case 10:n.vertices.push(...Dht(i,e)),t=e.lastReadGroup;break;case 43:0!==t.value&&(n.constantWidth=t.value),t=e.next();break;case 210:n.extrusionDirectionX=t.value,t=e.next();break;case 220:n.extrusionDirectionY=t.value,t=e.next();break;case 230:n.extrusionDirectionZ=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}return n}};function Dht(e,t){if(!e||e<=0)throw Error("n must be greater than 0 verticies");let n=[],i=!1,r=!1,a=t.lastReadGroup,s={};for(;!t.isEOF()&&0!==a.code&&!r;)switch(a.code){case 10:if(i){r=!0;continue}s.x=a.value,i=!0,a=t.next();break;case 20:s.y=a.value,a=t.next();break;case 30:s.z=a.value,a=t.next();break;case 40:s.startWidth=a.value,a=t.next();break;case 41:s.endWidth=a.value,a=t.next();break;case 42:0!=a.value&&(s.bulge=a.value),a=t.next();break;default:return i&&n.push(s),n}return n.push(s),i=!1,r=!1,n}var CE=class{constructor(){this.ForEntityName="MULTILEADER"}parseEntity(e,t){let n={type:t.value};function i(){for(;!e.isEOF();)switch(t.code){case 40:n.contextData.contentScale=t.value,t=e.next();break;case 10:n.contextData.contentBasePosition=Ft(e),t=e.lastReadGroup;break;case 145:n.contextData.landingGap=t.value,t=e.next();break;case 290:n.contextData.hasMText=t.value,t=e.next();break;case 304:n.contextData.defaultTextContents=t.value,t=e.next();break;case 11:n.contextData.textNormalDirection=Ft(e),t=e.lastReadGroup;break;case 12:n.contextData.textLocation=Ft(e),t=e.lastReadGroup;break;case 13:n.contextData.textDirection=Ft(e),t=e.lastReadGroup;break;case 140:n.contextData.arrowHeadSize=t.value,t=e.next();break;case 41:n.contextData.textHeight=t.value,t=e.next();break;case 42:n.contextData.textRotation=t.value,t=e.next();break;case 43:n.contextData.textWidth=t.value,t=e.next();break;case 44:default:t=e.next();break;case 45:n.contextData.textLineSpacingFactor=t.value,t=e.next();break;case 90:n.contextData.textColor=t.value,t=e.next();break;case 170:n.contextData.textLineSpacingStyle=t.value,t=e.next();break;case 171:n.contextData.textAttachment=t.value,t=e.next();break;case 172:n.contextData.textFlowDirection=t.value,t=e.next();break;case 141:n.contextData.textBackgroundScaleFactor=t.value,t=e.next();break;case 92:n.contextData.textBackgroundTransparency=t.value,t=e.next();break;case 291:n.contextData.textBackgroundColorOn=t.value,t=e.next();break;case 292:n.contextData.textBackgroundFillOn=t.value,t=e.next();break;case 293:n.contextData.textUseAutoHeight=t.value,t=e.next();break;case 173:n.contextData.textColumnType=t.value,t=e.next();break;case 142:n.contextData.textColumnWidth=t.value,t=e.next();break;case 143:n.contextData.textColumnGutterWidth=t.value,t=e.next();break;case 144:n.contextData.textColumnHeight=t.value,t=e.next();break;case 295:n.contextData.textUseWordBreak=t.value,t=e.next();break;case 296:n.contextData.hasBlock=t.value,t=e.next();break;case 341:n.contextData.blockContentId=t.value,t=e.next();break;case 14:n.contextData.blockContentNormalDirection=Ft(e),t=e.lastReadGroup;break;case 15:n.contextData.blockContentPosition=Ft(e),t=e.lastReadGroup;break;case 16:n.contextData.blockContentScale=t.value,t=e.next();break;case 46:n.contextData.blockContentRotation=t.value,t=e.next();break;case 93:n.contextData.blockContentColor=t.value,t=e.next();break;case 47:n.contextData.blockTransformationMatrix=ape(e,47),t=e.lastReadGroup;break;case 110:n.contextData.planeOriginPoint=Ft(e),t=e.lastReadGroup;break;case 111:n.contextData.planeXAxisDirection=Ft(e),t=e.lastReadGroup;break;case 112:n.contextData.planeYAxisDirection=Ft(e),t=e.lastReadGroup;break;case 297:n.contextData.planeNormalReversed=t.value,t=e.next();break;case 301:return;case 302:r(),t=e.lastReadGroup}}function r(){let i={leaderLines:[]};for(n.contextData.leaders.push(i);!e.isEOF();)switch(t.code){case 290:i.hasSetLastLeaderLinePoint=t.value,t=e.next();break;case 291:i.hasSetDoglegVector=t.value,t=e.next();break;case 10:i.lastLeaderLinePoint=Ft(e),t=e.lastReadGroup;break;case 11:i.doglegVector=Ft(e),t=e.lastReadGroup;break;case 90:i.leaderBranchIndex=t.value,t=e.next();break;case 40:i.doglegLength=t.value,t=e.next();break;case 303:return;case 304:a(),t=e.lastReadGroup;break;default:t=e.next()}}function a(){let i={vertices:[[]]};for(n.contextData.leaders[n.contextData.leaders.length-1].leaderLines.push(i);!e.isEOF();)switch(t.code){case 10:i.vertices[0].push(Ft(e)),t=e.lastReadGroup;break;case 305:return;default:t=e.next()}}return n.contextData={leaders:[]},t=e.next(),function(){for(;!e.isEOF();)switch(t.code){case 0:return;case 340:n.leaderStyleId=t.value,t=e.next();break;case 170:n.leaderLineType=t.value,t=e.next();break;case 91:n.leaderLineColor=t.value,t=e.next();break;case 341:n.leaderLineTypeId=t.value,t=e.next();break;case 171:n.leaderLineWeight=t.value,t=e.next();break;case 41:n.doglegLength=t.value,t=e.next();break;case 290:n.enableLanding=t.value,t=e.next();break;case 291:n.enableDogLeg=t.value,t=e.next();break;case 342:n.arrowHeadId=t.value,t=e.next();break;case 42:n.arrowHeadSize=t.value,t=e.next();break;case 172:n.contentType=t.value,t=e.next();break;case 173:case 95:n.textLeftAttachmentType=t.value,t=e.next();break;case 174:n.textAngleType=t.value,t=e.next();break;case 175:n.textAlignmentType=t.value,t=e.next();break;case 343:n.textStyleId=t.value,t=e.next();break;case 92:n.textColor=t.value,t=e.next();break;case 292:n.enableFrameText=t.value,t=e.next();break;case 344:n.blockContentId=t.value,t=e.next();break;case 93:n.blockContentColor=t.value,t=e.next();break;case 10:n.blockContentScale=Ft(e),t=e.lastReadGroup;break;case 43:n.blockContentRotation=t.value,t=e.next();break;case 176:n.blockContentConnectionType=t.value,t=e.next();break;case 293:n.enableAnotationScale=t.value,t=e.next();break;case 94:n.arrowHeadIndex=t.value,t=e.next();break;case 177:n.blockAttributeIndex=t.value,t=e.next();break;case 44:n.blockAttributeWidth=t.value,t=e.next();break;case 302:n.blockAttributeTextString=t.value,t=e.next();break;case 294:n.textDirectionNegative=t.value,t=e.next();break;case 178:n.textAlignInIPE=t.value,t=e.next();break;case 179:n.textAttachmentPoint=t.value,t=e.next();break;case 271:n.textAttachmentDirectionMText=t.value,t=e.next();break;case 272:n.textAttachmentDirectionBottom=t.value,t=e.next();break;case 273:n.textAttachmentDirectionTop=t.value,t=e.next();break;case 300:i(),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}}(),n}},PE=class{constructor(){this.ForEntityName="MTEXT"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 3:case 1:n.text?n.text+=t.value:n.text=t.value,t=e.next();break;case 10:n.position=Ft(e),t=e.lastReadGroup;break;case 7:n.textStyle=t.value,t=e.next();break;case 44:n.lineSpaceFactor=t.value,t=e.next();break;case 11:n.directionVector=Ft(e),n.rotation=void 0,t=e.lastReadGroup;break;case 40:n.height=t.value,t=e.next();break;case 41:n.width=t.value,t=e.next();break;case 50:n.rotation=t.value,n.directionVector=void 0,t=e.next();break;case 71:n.attachmentPoint=t.value,t=e.next();break;case 72:n.drawingDirection=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}return n}},IE=class{constructor(){this.ForEntityName="OLE2FRAME"}parseEntity(e,t){let n={type:t.value,binaryData:""};for(t=e.next();"OLE"!==t.value&&0!==t.code;)switch(t.code){case 3:n.documentType=t.value,t=e.next();break;case 70:n.version=t.value,t=e.next();break;case 10:n.leftUpX=t.value,t=e.next();break;case 20:n.leftUpY=t.value,t=e.next();break;case 30:n.leftUpZ=t.value,t=e.next();break;case 11:n.rightDownX=t.value,t=e.next();break;case 21:n.rightDownY=t.value,t=e.next();break;case 31:n.rightDownZ=t.value,t=e.next();break;case 90:n.lengthOfBinaryData=t.value,t=e.next();break;case 310:n.binaryData+=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}return n}},LE=class{constructor(){this.ForEntityName="POINT"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.position=Ft(e),t=e.lastReadGroup;break;case 39:n.thickness=t.value,t=e.next();break;case 210:n.extrusionDirection=Ft(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}return n}},DE=class{constructor(){this.ForEntityName="VERTEX"}parseEntity(e,t){var n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.x=t.value,t=e.next();break;case 20:n.y=t.value,t=e.next();break;case 30:n.z=t.value,t=e.next();break;case 40:case 41:case 50:t=e.next();break;case 42:0!=t.value&&(n.bulge=t.value),t=e.next();break;case 70:n.curveFittingVertex=0!=(1&t.value),n.curveFitTangent=0!=(2&t.value),n.splineVertex=0!=(8&t.value),n.splineControlPoint=0!=(16&t.value),n.threeDPolylineVertex=0!=(32&t.value),n.threeDPolylineMesh=0!=(64&t.value),n.polyfaceMeshVertex=0!=(128&t.value),t=e.next();break;case 71:n.faceA=t.value,t=e.next();break;case 72:n.faceB=t.value,t=e.next();break;case 73:n.faceC=t.value,t=e.next();break;case 74:n.faceD=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}return n}},OE=class{constructor(){this.ForEntityName="POLYLINE"}parseEntity(e,t){var n={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:case 20:case 30:case 40:case 41:case 71:case 72:case 73:case 74:case 75:t=e.next();break;case 39:t=e.next(),n.thickness=t.value;break;case 70:n.shape=0!=(1&t.value),n.includesCurveFitVertices=0!=(2&t.value),n.includesSplineFitVertices=0!=(4&t.value),n.is3dPolyline=0!=(8&t.value),n.is3dPolygonMesh=0!=(16&t.value),n.is3dPolygonMeshClosed=0!=(32&t.value),n.isPolyfaceMesh=0!=(64&t.value),n.hasContinuousLinetypePattern=0!=(128&t.value),t=e.next();break;case 210:n.extrusionDirection=Ft(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}return n.vertices=Oht(e,t),n}};function Oht(e,t){let n=new DE,i=[];for(;!e.isEOF();)if(0===t.code)if("VERTEX"===t.value)i.push(n.parseEntity(e,t)),t=e.lastReadGroup;else if("SEQEND"===t.value){kht(e,t);break}return i}function kht(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)if(101===t.code)for(;0!=t.code;)t=e.next();else Nn(n,t),t=e.next();return n}var kE=class{constructor(){this.ForEntityName="RAY"}parseEntity(e,t){let n={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.vertices.unshift(Ft(e)),t=e.lastReadGroup;break;case 11:n.directionVector=Ft(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}return n}},FE=class{constructor(){this.ForEntityName="REGION"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 70:n.modelerVersion=t.value,t=e.next();break;case 1:n.proprietaryData=t.value,t=e.next();break;case 3:n.proprietaryData+=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}return n}},NE=class{constructor(){this.ForEntityName="SEQEND"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)-2===t.code||(Nn(n,t),t=e.next());return n}},BE=class{constructor(){this.ForEntityName="SOLID"}parseEntity(e,t){let n={type:t.value,points:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.points[0]=Ft(e),t=e.lastReadGroup;break;case 11:n.points[1]=Ft(e),t=e.lastReadGroup;break;case 12:n.points[2]=Ft(e),t=e.lastReadGroup;break;case 13:n.points[3]=Ft(e),t=e.lastReadGroup;break;case 210:n.extrusionDirection=Ft(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}return n}},UE=class{constructor(){this.ForEntityName="SPLINE"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.controlPoints||(n.controlPoints=[]),n.controlPoints.push(Ft(e)),t=e.lastReadGroup;break;case 11:n.fitPoints||(n.fitPoints=[]),n.fitPoints.push(Ft(e)),t=e.lastReadGroup;break;case 12:n.startTangent=Ft(e),t=e.lastReadGroup;break;case 13:n.endTangent=Ft(e),t=e.lastReadGroup;break;case 40:n.knotValues||(n.knotValues=[]),n.knotValues.push(t.value),t=e.next();break;case 70:1&t.value&&(n.closed=!0),2&t.value&&(n.periodic=!0),4&t.value&&(n.rational=!0),8&t.value&&(n.planar=!0),16&t.value&&(n.planar=!0,n.linear=!0),t=e.next();break;case 71:n.degreeOfSplineCurve=t.value,t=e.next();break;case 72:n.numberOfKnots=t.value,t=e.next();break;case 73:n.numberOfControlPoints=t.value,t=e.next();break;case 74:n.numberOfFitPoints=t.value,t=e.next();break;case 210:n.normalVector=Ft(e),t=e.lastReadGroup;break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}return n}},HE=class{constructor(){this.ForEntityName="TEXT"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.startPoint=Ft(e),t=e.lastReadGroup;break;case 11:n.endPoint=Ft(e),t=e.lastReadGroup;break;case 40:n.textHeight=t.value,t=e.next();break;case 41:n.xScale=t.value,t=e.next();break;case 50:n.rotation=t.value,t=e.next();break;case 1:n.text=t.value,t=e.next();break;case 72:n.halign=t.value,t=e.next();break;case 73:n.valign=t.value,t=e.next();break;case 7:n.textStyle=t.value,t=e.next();break;case 71:n.mirrored=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}return n}},VE=class{constructor(){this.ForEntityName="VIEWPORT"}parseEntity(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 68:n.viewportStatus=t.value,t=e.next();break;case 40:n.width_paperSpace=t.value,t=e.next();break;case 41:n.height_paperSpace=t.value,t=e.next();break;case 69:n.viewportId=t.value,t=e.next();break;case 10:n.centerPoint=Ft(e),t=e.lastReadGroup;break;case 12:n.centerPoint_dcs=Ft(e),t=e.lastReadGroup;break;case 13:n.snapBasePoint_dcs=Ft(e),t=e.lastReadGroup;break;case 14:n.snapSpacing_dcs=Ft(e),t=e.lastReadGroup;break;case 15:n.gridSpacing_dcs=Ft(e),t=e.lastReadGroup;break;case 16:n.viewDirection=Ft(e),t=e.lastReadGroup;break;case 17:n.viewTarget=Ft(e),t=e.lastReadGroup;break;case 42:n.perspectiveLens=t.value,t=e.next();break;case 43:n.frontClippingPlaneZ=t.value,t=e.next();break;case 44:n.backClippingPlaneZ=t.value,t=e.next();break;case 45:n.viewHeight=t.value,t=e.next();break;case 50:n.snapAngle=t.value,t=e.next();break;case 51:n.viewTwistAngle=t.value,t=e.next();break;case 72:n.circleZoomPercent=t.value,t=e.next();break;case 331:n.frozenLayerHandles=n.frozenLayerHandles||[],n.frozenLayerHandles.push(t.value),t=e.next();break;case 90:n.viewportStatusFlags=t.value,t=e.next();break;case 340:n.viewportClippingBoundaryhandleId=t.value,t=e.next();break;case 1:n.plotStyleSheetName=t.value,t=e.next();break;case 281:n.renderMode=t.value,t=e.next();break;case 71:n.viewportFlag_ucs=t.value,t=e.next();break;case 74:n.ucsIcon=t.value,t=e.next();break;case 110:n.ucsOrigin=Ft(e),t=e.lastReadGroup;break;case 111:n.ucsXAxis=Ft(e),t=e.lastReadGroup;break;case 112:n.ucsYAxis=Ft(e),t=e.lastReadGroup;break;case 345:n.ucsTableRecordHandle=t.value,t=e.next();break;case 346:n.baseUcsTableRecordHandle=t.value,t=e.next();break;case 79:n.orthographicType=t.value,t=e.next();break;case 146:n.elevation=t.value,t=e.next();break;case 170:n.shadePlotMode=t.value,t=e.next();break;case 61:n.frequency=t.value,t=e.next();break;case 292:n.lightingFlag=t.value,t=e.next();break;case 282:n.lightingType=t.value,t=e.next();break;case 141:n.viewBrightness=t.value,t=e.next();break;case 142:n.viewContrast=t.value,t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}return n}},zE=class{constructor(){this.ForEntityName="XLINE"}parseEntity(e,t){let n={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 10:n.vertices.unshift(Ft(e)),t=e.lastReadGroup;break;case 11:n.directionVector=Ft(e),t=e.lastReadGroup;break;case 100:t=e.next();break;case 101:for(;0!=t.code;)t=e.next();break;default:Nn(n,t),t=e.next()}return n}},cC=class{constructor(){this.ForObjectName="DICTIONARY"}parseObject(e,t){let n={type:t.value},i=[],r=[];for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 280:n.isHardOwner=1===t.value,t=e.next();break;case 281:n.cloningFlag=t.value,t=e.next();break;case 3:i.push(t.value),t=e.next();break;case 350:case 360:r.push(t.value),t=e.next();break;case 100:case 102:t=e.next();break;default:Nl(n,t),t=e.next()}if(i.length!==r.length)throw new Error("The number of Dictionary entries does not match !");return n.entries={},i.forEach(((e,t)=>{n.entries[r[t]]=e})),n}},uC=class{constructor(){this.ForObjectName="IMAGEDEF"}parseObject(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 90:n.classVersion=t.value,t=e.next();break;case 1:n.filename=t.value,t=e.next();break;case 10:n.imageSize=Ft(e),t=e.next();break;case 11:n.pixelSize=Ft(e),t=e.next();break;case 280:n.loaded=t.value,t=e.next();break;case 281:n.resolutionUnits=t.value,t=e.next();break;default:Nl(n,t),t=e.next()}return n}},hC=class{constructor(){this.ForObjectName="LAYOUT"}parseObject(e,t){let n={type:t.value};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 100:t=e.next();break;case 1:n.layoutName=t.value,t=e.next();break;case 70:n.flag=t.value,t=e.next();break;case 71:n.tabOrder=t.value,t=e.next();break;case 76:n.orthographicType=t.value,t=e.next();break;case 10:n.minLimit=Ft(e),t=e.lastReadGroup;break;case 11:n.maxLimit=Ft(e),t=e.lastReadGroup;break;case 12:n.basePoint=Ft(e),t=e.lastReadGroup;break;case 13:n.origin=Ft(e),t=e.lastReadGroup;break;case 14:n.minExtent=Ft(e),t=e.lastReadGroup;break;case 15:n.maxExtent=Ft(e),t=e.lastReadGroup;break;case 16:n.XAxis=Ft(e),t=e.lastReadGroup;break;case 17:n.YAxis=Ft(e),t=e.lastReadGroup;break;case 146:n.elevation=t.value,t=e.next();break;case 331:n.viewportHandle=t.value,t=e.next();break;default:Nl(n,t),t=e.next()}return n.blockTableHandle=n.ownerHandle,n}},dC=class{constructor(){this.ForObjectName="SORTENTSTABLE"}parseObject(e,t){let n={type:t.value},i=!1;n.sortEntsObject={},n.sortEntsObject.entityHandles=[];let r=[];for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 5:i?(r.push(t.value),n.sortEntsObject.entityHandles.push(r),r=[]):n.handle=t.value,t=e.next();break;case 100:t=e.next(),i=!0;break;case 102:t=e.next();break;case 330:i?n.sortEntsObject.ownerHandle=t.value:n.ownerHandle=t.value,t=e.next();break;case 331:r.push(t.value),t=e.next();break;default:Nl(n,t),t=e.next()}return n}},fC=class{constructor(){this.ForObjectName="SPATIAL_FILTER"}parseObject(e,t){let n,i,r={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&0!==t.code;)switch(t.code){case 11:r.origin=Ft(e),t=e.lastReadGroup;break;case 70:r.numberOfPointsOnClipBoundary=t.value,2===r.numberOfPointsOnClipBoundary?(t=e.next(),n=Ft(e),t=e.lastReadGroup,i=Ft(e),t=e.lastReadGroup,r.vertices.push(n,{x:i.x,y:n.y},i,{x:n.x,y:i.y},n)):r.numberOfPointsOnClipBoundary>2?(r.vertices=Fht(r.numberOfPointsOnClipBoundary,e),t=e.lastReadGroup):t=e.next();break;case 71:r.clipBoundaryVisible=1===t.value,t=e.next();break;case 72:r.frontClippingPlaneFlag=1===t.value,t=e.next(),r.frontClippingPlaneFlag&&40===t.code&&(r.frontClippingPlaneDistance=t.value,t=e.next());break;case 73:r.backClippingPlaneFlag=1===t.value,t=e.next(),r.backClippingPlaneFlag&&41===t.code&&(r.backClippingPlaneDistance=t.value,t=e.next());break;case 100:case 102:t=e.next();break;case 210:r.extrusionDirectionX=t.value,t=e.next();break;case 220:r.extrusionDirectionY=t.value,t=e.next();break;case 230:r.extrusionDirectionZ=t.value,t=e.next();break;case 40:r.invertBlockMatrix=lpe(e,40),r.matrix=lpe(e,40),t=e.lastReadGroup;break;default:Nl(r,t),t=e.next()}return r}};function Fht(e,t){t.next();let n=[];for(;n.length{e.on("data",(e=>{t+=e})),e.on("end",(()=>{try{i(n.parse(t))}catch(e){r(e)}})),e.on("error",(e=>{r(e)}))}))}_parse(e){let t={},n=0;if(!e.hasNext())throw Error("Empty file");let i,r=this;function a(){let t=null,n=null,r={};for(i=e.next();;){if(el(i,0,"ENDSEC")){t&&(r[t]=n);break}9===i.code?(t&&(r[t]=n),t=i.value):10===i.code?n={x:i.value}:20===i.code?n.y=i.value:30===i.code?n.z=i.value:n=i.value,i=e.next()}return i=e.next(),r}function s(){let t={};for(i=e.next();"EOF"!==i.value&&!el(i,0,"ENDSEC");)if(el(i,0,"BLOCK")){se.trace("block {");let e=o();se.trace("}"),m(e),e.name?t[e.name]=e:se.error(`[DxfParser] Block with handle '${e.handle}' is missing a name, ignored!`)}else id(i),i=e.next();return t}function o(){let t={};for(i=e.next();"EOF"!==i.value;){switch(i.code){case 1:t.xrefPath=i.value,i=e.next();break;case 2:t.name=i.value,i=e.next();break;case 3:t.name2=i.value,i=e.next();break;case 4:t.description=i.value,i=e.next();break;case 5:t.handle=i.value,i=e.next();break;case 8:t.layer=i.value,i=e.next();break;case 10:t.position=f(i),i=e.lastReadGroup;break;case 67:t.paperSpace=!(!i.value||1!==i.value),i=e.next();break;case 70:t.blockType=i.value,i=e.next();break;case 100:i=e.next();break;case 330:t.ownerHandle=i.value,i=e.next();break;case 0:if("ENDBLK"==i.value)break;t.entities=d(!0);break;default:id(i),i=e.next()}if(el(i,0,"ENDBLK")){i=e.next();break}}return t}function l(){let t={};for(i=e.next();"EOF"!==i.value&&!el(i,0,"ENDSEC");)el(i,0,"TABLE")?(i=e.next(),u[i.value]?(se.trace(i.value+" Table {"),t[u[i.value].tableName]=c(i),se.trace("}")):se.trace("Unhandled Table "+i.value)):i=e.next();return i=e.next(),t}let h="ENDTAB";function c(t){let n=u[t.value],r={},a=0;for(i=e.next();!el(i,0,h);)switch(i.code){case 5:r.handle=i.value,i=e.next();break;case 330:r.ownerHandle=i.value,i=e.next();break;case 100:"AcDbSymbolTable"===i.value||id(i),i=e.next();break;case 70:a=i.value,i=e.next();break;case 0:i.value===n.dxfSymbolName?r[n.tableRecordsProperty]=n.parseTableRecords():(id(i),i=e.next());break;default:id(i),i=e.next()}let s=r[n.tableRecordsProperty];if(s){let e=s.constructor===Array?s.length:"object"==typeof s?Object.keys(s).length:void 0;a!==e&&se.warn(`[DxfParser] Parsed ${e} ${n.dxfSymbolName}s but expected ${a}`)}return i=e.next(),r}let u={VPORT:{tableRecordsProperty:"viewports",tableName:"viewport",dxfSymbolName:"VPORT",parseTableRecords:function(){let t=[],n={};for(se.trace("Viewport {"),i=e.next();!el(i,0,h);)switch(i.code){case 2:n.name=i.value,i=e.next();break;case 10:n.lowerLeftCorner=f(i),i=e.lastReadGroup;break;case 11:n.upperRightCorner=f(i),i=e.lastReadGroup;break;case 12:n.center=f(i),i=e.lastReadGroup;break;case 13:n.snapBasePoint=f(i),i=e.lastReadGroup;break;case 14:n.snapSpacing=f(i),i=e.lastReadGroup;break;case 15:n.gridSpacing=f(i),i=e.lastReadGroup;break;case 16:n.viewDirectionFromTarget=f(i),i=e.lastReadGroup;break;case 17:n.viewTarget=f(i),i=e.lastReadGroup;break;case 40:case 45:n.viewHeight=i.value,i=e.next();break;case 41:n.aspectRatio=i.value,i=e.next();break;case 42:n.lensLength=i.value,i=e.next();break;case 43:n.frontClippingPlane=i.value,i=e.next();break;case 44:n.backClippingPlane=i.value,i=e.next();break;case 50:n.snapRotationAngle=i.value,i=e.next();break;case 51:n.viewTwistAngle=i.value,i=e.next();break;case 79:n.orthographicType=i.value,i=e.next();break;case 110:n.ucsOrigin=f(i),i=e.lastReadGroup;break;case 111:n.ucsXAxis=f(i),i=e.lastReadGroup;break;case 112:n.ucsYAxis=f(i),i=e.lastReadGroup;break;case 281:n.renderMode=i.value,i=e.next();break;case 282:n.defaultLightingType=i.value,i=e.next();break;case 292:n.defaultLightingOn=i.value,i=e.next();break;case 330:n.ownerHandle=i.value,i=e.next();break;case 63:case 421:case 431:n.ambientColor=i.value,i=e.next();break;case 0:"VPORT"===i.value&&(se.trace("}"),t.push(n),se.trace("Viewport {"),n={},i=e.next());break;default:id(i),i=e.next()}return se.trace("}"),t.push(n),t}},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:function(){let t={},n={},a=0,s="",o=!1;for(se.trace("LType {"),i=e.next();!el(i,0,"ENDTAB");)switch(i.code){case 2:n.name=i.value.toUpperCase(),s=n.name,i=e.next();break;case 3:n.description=i.value,i=e.next();break;case 9:case 44:case 45:case 46:case 70:case 75:default:i=e.next();break;case 40:n.patternLength=i.value,i=e.next();break;case 49:let l=i.value;o&&(l=Math.abs(l),o=!1),n.pattern.push(l),i=e.next();break;case 73:a=i.value,a>0&&(n.pattern=[]),i=e.next();break;case 74:0!==i.value&&(o=!0,r.unsupportedLineTypes[n.name]?r.unsupportedLineTypes[n.name]++:r.unsupportedLineTypes[n.name]=1),i=e.next();break;case 0:se.trace("}"),a>0&&a!==n.pattern.length&&se.warn("[DxfParser] lengths do not match on LTYPE pattern"),t[s]=n,n={},se.trace("LType {"),i=e.next()}return se.trace("}"),t[s]=n,t}},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:function(){let t,n={},r={};for(se.trace("Layer {"),i=e.next();!el(i,0,"ENDTAB");)switch(i.code){case 2:r.name=i.value,t=i.value,i=e.next();break;case 5:r.handle=i.value,i=e.next();break;case 62:r.visible=i.value>=0,r.colorIndex=Math.abs(i.value),r.color=Hht(r.colorIndex),i=e.next();break;case 70:r.flag=i.value,r.frozen=(1&r.flag)>0,i=e.next();break;case 420:r.color=Math.abs(i.value),i=e.next();break;case 6:r.lineType=i.value.toUpperCase(),i=e.next();break;case 370:r.lineweight=i.value,i=e.next();break;case 0:"LAYER"===i.value&&(se.trace("}"),t&&(n[t]=r),se.trace("Layer {"),r={},t=void 0,i=e.next());break;default:id(i),i=e.next()}return se.trace("}"),t&&(n[t]=r),n}},BLOCK_RECORD:{tableRecordsProperty:"blockRecords",tableName:"blockRecord",dxfSymbolName:"BLOCK_RECORD",parseTableRecords:function(){let t,n={},a={};for(se.trace("BlockRecord {"),i=e.next();!el(i,0,"ENDTAB");)switch(i.code){case 5:a.handle=i.value,i=e.next();break;case 330:a.ownerHandle=i.value,i=e.next();break;case 2:a.blockName=i.value,t=a.blockName,i=e.next();break;case 340:a.layoutHandle=i.value,i=e.next();break;case 70:a.blockInsertUnits=i.value,i=e.next();break;case 280:a.blockExplodability=i.value,i=e.next();break;case 281:a.blockScalability=i.value,i=e.next();break;case 310:a.bitmap=i.value,i=e.next();break;case 0:if("BLOCK_RECORD"===i.value){se.trace("}"),t&&(n[t]=a);let s=a.layoutHandle;t&&s&&s.length>0&&"0"!==s&&(r._layoutBlocks[s]=a),se.trace("BlockRecord {"),a={},t=void 0,i=e.next()}else id(i),i=e.next();break;default:id(i),i=e.next()}se.trace("}"),t&&(n[t]=a);let s=a.layoutHandle;return t&&s&&s.length>0&&"0"!==s&&(r._layoutBlocks[s]=a),n}},STYLE:{tableRecordsProperty:"styles",tableName:"style",dxfSymbolName:"STYLE",parseTableRecords:function(){let t,n={},r={};for(se.trace("Style {"),i=e.next();!el(i,0,"ENDTAB");)switch(i.code){case 2:r.styleName=i.value,t=i.value,i=e.next();break;case 3:r.fontFile=i.value,i=e.next();break;case 4:r.bigFontFile=i.value,i=e.next();break;case 5:r.handle=i.value,i=e.next();break;case 40:r.textHeight=i.value,i=e.next();break;case 41:r.xScale=i.value,i=e.next();break;case 42:r.priorTextHeight=i.value,i=e.next();break;case 50:r.rotation=i.value,i=e.next();break;case 70:default:i=e.next();break;case 71:r.mirrorType=i.value,i=e.next();break;case 330:r.ownerHandle=i.value,i=e.next();break;case 0:"STYLE"===i.value&&(se.trace("}"),t&&(n[t]=r),se.trace("Style {"),r={},t=void 0,i=e.next())}return se.trace("}"),t&&(n[t]=r),n}},DIMSTYLE:{tableRecordsProperty:"dimStyles",tableName:"dimStyle",dxfSymbolName:"DIMSTYLE",parseTableRecords:function(){let t,n={},r={};for(se.trace("DimStyle {"),i=e.next();!el(i,0,"ENDTAB");)switch(i.code){case 2:r.styleName=i.value,t=i.value,i=e.next();break;case 40:r.DIMSCALE=i.value,i=e.next();break;case 41:r.DIMASZ=i.value,i=e.next();break;case 42:r.DIMEXO=i.value,i=e.next();break;case 44:r.DIMEXE=i.value,i=e.next();break;case 75:r.DIMSE1=i.value,i=e.next();break;case 76:r.DIMSE2=i.value,i=e.next();break;case 77:r.DIMTAD=i.value,i=e.next();break;case 140:r.DIMTXT=i.value,i=e.next();break;case 144:r.DIMLFAC=i.value,i=e.next();break;case 147:r.DIMGAP=i.value,i=e.next();break;case 176:r.DIMCLRD=i.value,i=e.next();break;case 178:r.DIMCLRT=i.value,i=e.next();break;case 271:r.DIMDEC=i.value,i=e.next();break;case 341:r.DIMLDRBLK=i.value,i=e.next();break;case 70:default:i=e.next();break;case 0:"DIMSTYLE"===i.value&&(se.trace("}"),t&&(n[t]=r),se.trace("DimStyle {"),r={},t=void 0,i=e.next())}return se.trace("}"),t&&(n[t]=r),n}}};function d(t){let n=[],a=t?"ENDBLK":"ENDSEC";for(t||(i=e.next());;)if(0===i.code){if(i.value===a)break;let t=r._entityHandlers[i.value];if(null==t){let t=i.value;r.unhandledEntities[t]||(r.unhandledEntities[t]=0),r.unhandledEntities[t]++,i=e.next();continue}{se.trace(i.value+" {");let r=t.parseEntity(e,i);r&&(r.layer||(r.layer="0"),void 0===r.colorIndex&&(r.colorIndex=256),r.lineType||(r.lineType=iy)),i=e.lastReadGroup,se.trace("}"),m(r),n.push(r)}}else i=e.next();return"ENDSEC"==a&&(i=e.next()),n}function p(){let t={};for(i=e.next();"EOF"!==i.value;)if(0===i.code){if("ENDSEC"===i.value)break;let n=r._objectHandlers[i.value];if(null==n){let t=i.value;r.unhandledObjects[t]||(r.unhandledObjects[t]=0),r.unhandledObjects[t]++,i=e.next();continue}{se.trace(i.value+" {");let r=n.parseObject(e,i),a=i.value;i=e.lastReadGroup,se.trace("}"),m(r),t[a]||(t[a]=[]),t[a].push(r)}}else i=e.next();return i=e.next(),t.LAYOUT&&(Object.keys(r._layoutBlocks).length!==t.LAYOUT.length&&se.warn("[DxfParser] The number of layout and block associations does not match!"),t.LAYOUT.forEach((e=>{r._layoutBlocks[e.handle]&&(e.associatedBlockName=r._layoutBlocks[e.handle].blockName)})),t.LAYOUT.sort(((e,t)=>e.tabOrder-t.tabOrder))),t}function f(t){let n={},i=t.code;if(n.x=t.value,i+=10,(t=e.next()).code!=i)throw new Error(`Expected code for point value to be ${i} but got ${t.code}.`);return n.y=t.value,i+=10,(t=e.next()).code!=i||(n.z=t.value,t=e.next()),n}function m(e){if(!e)throw new TypeError("entity cannot be undefined or null");e.handle||(e.handle=(n++).toString())}return function(){for(i=e.next();999===i.code;)i=e.next();for(;!e.isEOF();)if(0===i.code&&"SECTION"===i.value){if(i=e.next(),2!==i.code){se.error("Unexpected code %s after 0:SECTION",cpe(i)),i=e.next();continue}if("HEADER"===i.value)se.trace("> HEADER"),t.header=a(),se.trace("<");else if("TABLES"===i.value)se.trace("> TABLES"),t.tables=l(),se.trace("<");else if("BLOCKS"===i.value)se.trace("> BLOCKS"),t.blocks=s(),se.trace("<");else if("ENTITIES"===i.value)se.trace("> ENTITIES"),t.entities=d(!1),se.trace("<");else if("OBJECTS"===i.value)se.trace("> OBJECTS"),t.objects=p(),se.trace("<");else if("EOF"===i.value)se.trace("EOF");else{let e=i.value;r.unhandledSections[e]?r.unhandledSections[e]++:r.unhandledSections[e]=1}}else i=e.next();r.unhandledSections={},r.unhandledEntities={},r.unhandledObjects={},r.unsupportedLineTypes={}}(),t}splitByLineSeparator(e){let t=[],n=0;for(let i=0,r=e.length;i(e.Added="Added",e.Removed="Removed",e.Modified="Modified",e.NoChange="NoChange",e))(B5||{}),ja=1,mC=class{constructor(e,t,n){if(this.changes={},this.comparedBlocks=new Map,this.isComparingBlock=!1,this.isComparingDimension=!1,this.enableDetailComparision=!0,this.dxf1=e,this.dxf2=t,this.enableDetailComparision=!n||(null==n?void 0:n.enableDetailComparision),!e||!t)throw new Error("Invalid dxf data to compare!")}getLayerFrozen(e,t){var n,i,r;let a=null==(i=null==(n=e.tables)?void 0:n.layer)?void 0:i.layers;return a&&(null==(r=a[t.layer])?void 0:r.frozen)}compare(e){return ft(this,null,(function*(){this.changes={};let t=[],n=new Map;return this.dxf1.entities.forEach((e=>{if(!0!==e.inPaperSpace){let n=!0===this.getLayerFrozen(this.dxf1,e);!mC.ignoreEntityTypes.includes(e.type)&&!n&&t.push(e)}})),this.dxf2.entities.forEach((e=>{if(!0!==e.inPaperSpace){let t=!0===this.getLayerFrozen(this.dxf2,e);!mC.ignoreEntityTypes.includes(e.type)&&!t&&n.set(e.handle,e)}})),yield this.compareEntities(t,n,e),Promise.resolve(this.changes)}))}isDimensionBlock(e){return e.includes("*D")}compareInsertOrDemensionEntities(e,t,n,i){if(!e.block||!t.block)return;let r,a=e.block;if(this.isComparingBlock=!0,this.isDimensionBlock(a)){let n=this.dxf1.blocks[e.block],i=this.dxf2.blocks[t.block],s=Date.now();this.isComparingDimension=!0,r=this.compareBlock(e,t,n,i),this.isComparingDimension=!1,se.debug(`[DxfCompare] compare block: ${a} cost ${(Date.now()-s)/1e3}s`)}else{if(!this.comparedBlocks.has(a)){let n=this.dxf1.blocks[a],i=this.dxf2.blocks[a],r=Date.now(),s=this.compareBlock(e,t,n,i);this.comparedBlocks.set(a,s),se.debug(`[DxfCompare] compare block: ${a} cost ${(Date.now()-r)/1e3}s`)}r=this.comparedBlocks.get(a)}return null==r||r.forEach((t=>{if(t.parentHandles||(t.parentHandles=[]),n&&i)"Added"===t.type?t.parentHandles.push(i):"Removed"===t.type&&t.parentHandles.push(n);else{let n=[...t.parentHandles,e.handle];("Added"===t.type||"Removed"===t.type)&&(this.changes[ja]=Ri(Tr({id:ja},t),{parentHandles:n})),ja++}})),!n&&!i&&(this.isComparingBlock=!1),r}compareBlock(e,t,n,i){var r,a;let s=[],o=[];null==(r=null==n?void 0:n.entities)||r.forEach((e=>{"ATTDEF"!==e.type&&!this.bIgnoreChildEntitiesOriginalType(e)&&s.push(e)})),null==(a=null==i?void 0:i.entities)||a.forEach((e=>{"ATTDEF"!==e.type&&!this.bIgnoreChildEntitiesOriginalType(e)&&o.push(e)}));let l=[],h=[];for(let c=0;c0&&l.push(...e),i=!1,o.splice(r--,1);break}i=!1,o.splice(r--,1);break}i=!0}i&&(l.push({type:"Removed",handle:n.handle}),h.push(n.handle))}return o.forEach((e=>{h.includes(e.handle)||l.push({type:"Added",handle:e.handle})})),l}compareEntities(e,t,n){return ft(this,null,(function*(){var i,r;let a=Mt.getUpdateProgressFuncForLoop(e.length,n);for(let n=0;n0&&(this.changes[ja].detailChanges=l),ja++}t.delete(s)}else this.changes[ja]={id:ja,type:"Removed",handle:s},ja++;yield a(n)}for(let e of t){let t=e[0];this.changes[ja]={id:ja,type:"Added",handle:t},ja++}}))}bIgnoreChildEntitiesOriginalType(e){var t;return spe.includes(null==(t=e.extendedData)?void 0:t.originalType)}entitiesEqual(e,t,n,i,r){if(!this.baseEntitiesEqual(e,t,n,i,r))return!1;let a=e.type,s=!0;return"CIRCLE"===a||"ARC"===a?s=this.arcsEqual(e,t):"LWPOLYLINE"===a||"LINE"===a?s=this.linesEqual(e,t,r):"POLYLINE"===a?s=this.polylinesEqual(e,t):"TEXT"===a?s=this.textsEqual(e,t):"SOLID"===a?s=this.solidsEqual(e,t):"POINT"===a?s=this.pointEntitiesEqual(e,t):"INSERT"===a?s=this.insertsEqual(e,t):"SPLINE"===a?s=this.splinesEqual(e,t):"MTEXT"===a?s=this.mtextsEqual(e,t):"ELLIPSE"===a?s=this.ellipsesEqual(e,t):"DIMENSION"===a?s=this.dimensionsEqual(e,t):"REGION"===a?s=this.regionsEqual(e,t):"ATTDEF"===a?s=this.attDefsEqual(e,t):"ATTRIB"===a?s=this.attribsEqual(e,t):"HATCH"===a?s=this.hatchesEqual(e,t):"VIEWPORT"===a?s=this.viewportsEqual(e,t):"LEADER"===a?s=this.leadersEqual(e,t):"MULTILEADER"===a?s=this.mleadersEqual(e,t):"OLE2FRAME"===a&&(s=this.ole2framesEqual(e,t)),s}getColor(e,t,n){var i,r,a,s,o,l;if(e.isTrueColor||e.colorIndex>0&&e.colorIndex<256)return e.color;if(0===e.colorIndex)return n?this.getColor(n,t):null==(r=null==(i=t.tables)?void 0:i.layer)?void 0:r.layers[0].color;let h=0;if(256===e.colorIndex){let i=null==(s=null==(a=t.tables)?void 0:a.layer)?void 0:s.layers,r=i&&i[e.layer],c=i&&n&&i[n.layer];h=r&&"0"!==r.name?r.color:c?c.color:r?r.color:null==(l=null==(o=t.tables)?void 0:o.layer)?void 0:l.layers[0].color}return h}getLineType(e,t,n){var i,r;if(n&&"DIMENSION"===n.type)return this.getLineType(n,t);if(e.lineType!==iy&&e.lineType!==sy)return e.lineType;if(e.lineType===sy)return n?this.getLineType(n,t):e.lineType;let a=null==(r=null==(i=t.tables)?void 0:i.layer)?void 0:r.layers;if("0"!==e.layer){let t=a&&a[e.layer];if(t)return t.lineType}else if(n){let e=a&&a[n.layer];if(e)return e.lineType}return"CONTINUOUS"}addModificationItem(e,t,n,i){i&&(i[n]={old:e,new:t})}baseEntitiesEqual(e,t,n,i,r){var a,s;let o=!0,l=this.getColor(e,this.dxf1,n),h=this.getColor(t,this.dxf2,i);if(l!==h){if(o=!1,!this.enableDetailComparision)return o;this.addModificationItem(l,h,"color",r)}let c=this.getLineType(e,this.dxf1,n),u=this.getLineType(t,this.dxf2,i);return c!==u?(o=!1,this.enableDetailComparision?(this.addModificationItem(c,u,"lineType",r),!1):o):!((null==(a=e.extendedData)?void 0:a.originalType)!==(null==(s=t.extendedData)?void 0:s.originalType)||!this.isComparingBlock&&!this.isComparingDimension&&e.handle!==t.handle||!this.isComparingDimension&&e.ownerHandle!==t.ownerHandle||e.type!==t.type)&&o}arcsEqual(e,t){return!!(this.vectorsEqual(e.center,t.center)&&this.numberEqual(e.radius,t.radius)&&this.numberEqual(e.startAngle,t.startAngle)&&this.numberEqual(e.endAngle,t.endAngle))}linesEqual(e,t,n){let i=!0,r=e.constantWidth,a=t.constantWidth;if(r!==a){if(i=!1,!this.enableDetailComparision)return!1;this.addModificationItem(r||0,a||0,"constantWidth",n)}return!(!this.verticesEqual(e.vertices,t.vertices)||e.shape!==t.shape)&&i}polylinesEqual(e,t){return!(!this.vertexEntitiesEqual(e.vertices,t.vertices)||e.shape!==t.shape||e.isPolyfaceMesh!==t.isPolyfaceMesh)}textsEqual(e,t){if(e.halign!==t.halign)return!1;if(3===e.halign||5===e.halign){if(!this.pointsEqual(e.startPoint,t.startPoint))return!1}else if(!this.pointsEqual(e.endPoint,t.endPoint))return!1;return e.text===t.text}solidsEqual(e,t){return!!this.verticesEqual(e.points,t.points)}pointEntitiesEqual(e,t){return!!this.pointsEqual(e.position,t.position)}splinesEqual(e,t){return!(!this.verticesEqual(e.controlPoints,t.controlPoints)||!this.numbersEqual(e.knotValues,t.knotValues)||!this.numberEqual(e.degreeOfSplineCurve,t.degreeOfSplineCurve))}mtextsEqual(e,t){return!(!this.pointsEqual(e.position,t.position)||e.text!==t.text||!this.numberEqual(e.rotation,t.rotation))}ellipsesEqual(e,t){return!!(this.pointsEqual(e.center,t.center)&&this.pointsEqual(e.majorAxisEndPoint,t.majorAxisEndPoint)&&this.numberEqual(e.axisRatio,t.axisRatio)&&this.numberEqual(e.startAngle,t.startAngle)&&this.numberEqual(e.endAngle,t.endAngle))}attDefsEqual(e,t){return!(!this.pointsEqual(e.startPoint,t.startPoint)||!this.pointsEqual(e.endPoint,t.endPoint)||!this.numberEqual(e.xScale,t.xScale)||e.text!==t.text||e.tag!==t.tag||e.prompt!==t.prompt)}attribsEqual(e,t){return this.attDefsEqual(e,t)}hatchesEqual(e,t){let n=e,i=t;return!!(this.numberEqual(n.elevationX,i.elevationX)&&this.numberEqual(n.elevationY,i.elevationY)&&this.numberEqual(n.elevationZ,i.elevationZ)&&this.hatchBoundaryPathArraysEqual(n.boundaryPaths,i.boundaryPaths))}viewportsEqual(e,t){let n=e,i=t;return!!(this.pointsEqual(n.centerPoint,i.centerPoint)&&this.pointsEqual(n.centerPoint_dcs,i.centerPoint_dcs)&&this.pointsEqual(n.viewDirection,i.viewDirection)&&this.numberEqual(n.viewHeight,i.viewHeight)&&n.width_paperSpace===i.width_paperSpace&&n.height_paperSpace===i.height_paperSpace)}leadersEqual(e,t){return!!(this.pointsEqual(e.position,t.position)&&this.verticesEqual(e.vertices,t.vertices)&&e.arrowHeadBlockHandle===t.arrowHeadBlockHandle&&this.numberEqual(e.arrowHeadSize,t.arrowHeadSize)&&this.numberEqual(e.rotation,t.rotation)&&e.block===t.block)}mleadersEqual(e,t){return!(e.arrowHeadId!==t.arrowHeadId||!this.numberEqual(e.arrowHeadSize,t.arrowHeadSize))&&this.mleaderContextEqual(e.contextData,t.contextData)}ole2framesEqual(e,t){return!(e.leftUpX!==t.leftUpX||e.leftUpY!==t.leftUpY||e.leftUpZ!==t.leftUpZ||e.rightDownX!==t.rightDownX||e.rightDownY!==t.rightDownY||e.rightDownZ!==t.rightDownZ)}insertsEqual(e,t){var n,i,r,a;return"INSERT"===(null==(n=e.extendedData)?void 0:n.originalType)&&"INSERT"===(null==(i=t.extendedData)?void 0:i.originalType)?(se.warn(`[DxfCompare] We cannot compare insert (handle '${e.handle}') yet, ignored!`),!0):!!(this.pointsEqual(e.position,t.position)&&this.numberEqual(void 0===e.xScale?1:e.xScale,void 0===t.xScale?1:t.xScale)&&this.numberEqual(void 0===e.yScale?1:e.yScale,void 0===t.yScale?1:t.yScale)&&this.numberEqual(void 0===e.zScale?1:e.zScale,void 0===t.zScale?1:t.zScale)&&e.block===t.block&&(null==(r=e.entities)?void 0:r.length)===(null==(a=t.entities)?void 0:a.length))}dimensionsEqual(e,t){return!!this.pointsEqual(e.anchorPoint,t.anchorPoint)}regionsEqual(e,t){return se.warn("Cannot compare region yet!"),!0}vectorsEqual(e,t){return!e&&!t||!(!e||!t)&&this.numberEqual(e.x,t.x)&&this.numberEqual(e.y,t.y)&&this.numberEqual(e.z,t.z)}pointsEqual(e,t){return!e&&!t||!(!e||!t)&&this.numberEqual(e.x,t.x)&&this.numberEqual(e.y,t.y)&&this.numberEqual(e.z,t.z)&&this.numberEqual(e.bulge,t.bulge)}vertexEntityEqual(e,t){return!e&&!t||!(!e||!t)&&!(!this.pointsEqual(e,t)||e.polyfaceMeshVertex!==t.polyfaceMeshVertex||e.threeDPolylineMesh!==t.threeDPolylineMesh)}numbersEqual(e,t){if(!e&&!t)return!0;if(e&&t){if(e.length!==t.length)return!1;for(let n=0;n{let t={};return GE.forEach(((e,n)=>t[e]=n)),t})(),edt=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,aa=String.fromCharCode.bind(String),Cpe="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),Dpe=e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>"+"==e?"-":"_")),Ope=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),kpe=e=>{let t,n,i,r,a="",s=e.length%3;for(let o=0;o255||(i=e.charCodeAt(o++))>255||(r=e.charCodeAt(o++))>255)throw new TypeError("invalid character found");t=n<<16|i<<8|r,a+=GE[t>>18&63]+GE[t>>12&63]+GE[t>>6&63]+GE[63&t]}return s?a.slice(0,s-3)+"===".substring(s):a},$5=Jht?e=>btoa(e):hy?e=>Buffer.from(e,"binary").toString("base64"):kpe,X5=hy?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let n=0,i=e.length;nt?Dpe(X5(e)):X5(e),tdt=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?aa(192|t>>>6)+aa(128|63&t):aa(224|t>>>12&15)+aa(128|t>>>6&63)+aa(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return aa(240|t>>>18&7)+aa(128|t>>>12&63)+aa(128|t>>>6&63)+aa(128|63&t)},ndt=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Fpe=e=>e.replace(ndt,tdt),Ppe=hy?e=>Buffer.from(e,"utf8").toString("base64"):Ape?e=>X5(Ape.encode(e)):e=>$5(Fpe(e)),uy=(e,t=!1)=>t?Dpe(Ppe(e)):Ppe(e),Ipe=e=>uy(e,!0),rdt=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,idt=e=>{switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return aa(55296+(t>>>10))+aa(56320+(1023&t));case 3:return aa((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return aa((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},Npe=e=>e.replace(rdt,idt),Bpe=e=>{if(e=e.replace(/\s+/g,""),!edt.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let t,n,i,r="";for(let a=0;a>16&255):64===i?aa(t>>16&255,t>>8&255):aa(t>>16&255,t>>8&255,255&t);return r},Z5=Kht?e=>atob(Ope(e)):hy?e=>Buffer.from(e,"base64").toString("binary"):Bpe,Upe=hy?e=>Cpe(Buffer.from(e,"base64")):e=>Cpe(Z5(e).split("").map((e=>e.charCodeAt(0)))),Hpe=e=>Upe(Vpe(e)),sdt=hy?e=>Buffer.from(e,"base64").toString("utf8"):Rpe?e=>Rpe.decode(Upe(e)):e=>Npe(Z5(e)),Vpe=e=>Ope(e.replace(/[-_]/g,(e=>"-"==e?"+":"/"))),Y5=e=>sdt(Vpe(e)),adt=e=>{if("string"!=typeof e)return!1;let t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},zpe=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),Gpe=function(){let e=(e,t)=>Object.defineProperty(String.prototype,e,zpe(t));e("fromBase64",(function(){return Y5(this)})),e("toBase64",(function(e){return uy(this,e)})),e("toBase64URI",(function(){return uy(this,!0)})),e("toBase64URL",(function(){return uy(this,!0)})),e("toUint8Array",(function(){return Hpe(this)}))},qpe=function(){let e=(e,t)=>Object.defineProperty(Uint8Array.prototype,e,zpe(t));e("toBase64",(function(e){return EC(this,e)})),e("toBase64URI",(function(){return EC(this,!0)})),e("toBase64URL",(function(){return EC(this,!0)}))},odt=()=>{Gpe(),qpe()},Wpe={version:Lpe,VERSION:Zht,atob:Z5,atobPolyfill:Bpe,btoa:$5,btoaPolyfill:kpe,fromBase64:Y5,toBase64:uy,encode:uy,encodeURI:Ipe,encodeURL:Ipe,utob:Fpe,btou:Npe,decode:Y5,isValid:adt,fromUint8Array:EC,toUint8Array:Hpe,extendString:Gpe,extendUint8Array:qpe,extendBuiltins:odt},Vl=ji(cme(),1),_C=new et,xdt=new et,Lc=class{static resetMergeInfo(){this.mergeInfo.removedObjects=0,this.mergeInfo.mergedMeshes=0,this.mergeInfo.mergedLines=0,this.mergeInfo.mergedPoints=0,this.mergeInfo.mergedUnknownTypeObjects=0,this.mergeInfo.elapsedTime=0}static merge(e,t=!0){let n=Date.now();this.mergeInner(e,t),this.mergeInfo.elapsedTime+=Date.now()-n}static mergeInner(e,t=!0){if(!e.children||e.children.length<1)return;let n=e.children.length,i={},r=[];for(let h=0;h0){this.mergeInner(n,t);continue}if(n.userData.relativeToCenter||!n.geometry)continue;let a=!1,s=Object.values(i);for(let t=s.length-1;t>=0;--t){let n=s[t].indexes[0];if(a=this.tryHandleMergeableObjects(e,h,n,i,r),a)break}for(let t=r.length-1;!a&&t>=0;--t){let n=r[t];if(a=this.tryHandleMergeableObjects(e,h,n,i,r),a)break}a||r.push(h)}if(Object.keys(i).length<=0)return;let a=[],s=[],o=[],l=[];Object.values(i).forEach((n=>{let i,r=n.indexes,h=e.children[r[0]],c=[],u=0,d=0,p=0,f=[];if(r.forEach((n=>{var i,r,a,s;let o=e.children[n],l=null==(i=o.geometry)?void 0:i.clone();if(l.applyMatrix4(o.matrix),l.userData.isLineSegments=3===o.type,c.push(l),t){let e=null==(a=null==(r=l.attributes)?void 0:r.position)?void 0:a.count,t=(null==(s=l.index)?void 0:s.count)||0;f.push({batchId:u,positionStart:d,positionCount:e,indexStart:p,indexCount:t}),d+=e,p+=t,u++}})),0!==c.length){if(4===h.type){let e=Ni(c);if(!e)return;e.userData={},i=new bn(h.type),i.geometry=e,i.material=h.material,a.push(i)}else if(2===h.type||3===h.type){let e=Ar.mergeLineGeometries(c,t,h.material instanceof Iu||h.material instanceof ln,f);if(!e)return;i=new bn(3),i.geometry=e,i.material=h.material,s.push(i)}else if(1===h.type){let e=Ni(c);if(!e)return;e.userData={},i=new bn(h.type),i.geometry=e,i.material=h.material,o.push(i)}i&&(t?i.userData.batches=f:(i.userData=h.userData,i.userData.batches=void 0),i.userData.layerName=h.userData.layerName,i.name=`[Merged] ${h.name}`,i.renderOrder=h.renderOrder,i.layers.mask=h.layers.mask,l.push(...r)),c.forEach((e=>{e.dispose(),Qt.releaseGeometryManually(e)})),c=[]}})),l.sort(((e,t)=>t-e)),l.forEach((t=>{let n=e.children[t];e.remove(n)})),[...a,...s,...o].forEach((t=>{e.add(t)})),this.mergeInfo.removedObjects+=l.length,this.mergeInfo.mergedMeshes+=a.length,this.mergeInfo.mergedLines+=s.length,this.mergeInfo.mergedPoints+=o.length}static tryHandleMergeableObjects(e,t,n,i,r){let a=!1,s=Array.isArray(e),o=s?e.length:e.children.length;if(t===n||t>=o||n>=o)return a;let l=s?e[t]:e.children[t],h=s?e[n]:e.children[n];return this.areObjectsMergeable(l,h)&&Ar.areGeometriesMergeable(l.geometry,h.geometry)&&es.materialsEquals(l.material,h.material)&&(i[n]||(i[n]={indexes:[n]},this.removeFromArray(r,n)),i[n].indexes.push(t),a=!0),a}static isFilteredByOtherFactors(e,t){let n=e;if(4===n.type&&n.material&&n.material.isShaderMaterial)return!0;let i=!1,r=e;for(;r&&r!==t;){let e=r.userData;if(e.relativeToCenter||e.spatialFilterHandle){i=!0;break}r=r.parent}return i}static deepMerge(e,t=void 0,n=!0,i=!0,r=!0){let a={added:[],removed:[]};if(e.length<=1)return a;let s=Date.now(),o={},l=[];for(let m=0;m=0;--t){let r=i[t].indexes[0];if(n=this.tryHandleMergeableObjects(e,m,r,o,l),n)break}for(let t=l.length-1;!n&&t>=0;--t){let i=l[t];if(n=this.tryHandleMergeableObjects(e,m,i,o,l),n)break}n||l.push(m)}if(Object.keys(o).length<=0)return a;se.debug(`[Merge] Built merged indexes for ${e.length} objects in ${(Date.now()-s)/1e3}s`),s=Date.now();let h=[],c=[],u=[],d=[];Object.values(o).forEach((n=>{let i=n.indexes;if(i.length<2)return;let a,s=e[i[0]],o=[],l=0,p=0,f=0,m=[];if(i.forEach((n=>{var i,a,h,c,u;let d=e[n],g=null==(i=d.geometry)?void 0:i.clone();if(s.material instanceof Gn&&g.deleteAttribute("lineDistance"),this.applyMatrix(g,d,t),g.userData.isLineSegments=3===d.type,o.push(g),r){let e,t=null==(h=null==(a=g.attributes)?void 0:a.position)?void 0:h.count,n=(null==(c=g.index)?void 0:c.count)||0;(2===s.type||3===s.type)&&(g.boundingSphere||g.computeBoundingSphere(),e=null==(u=g.boundingSphere)?void 0:u.clone()),m.push({batchId:l,positionStart:p,positionCount:t,indexStart:f,indexCount:n,boundingSphere:e}),p+=t,f+=n,l++}})),0!==o.length){if(4===s.type){let e=Ni(o);if(!e)return;e.userData={},a=new bn(s.type),a.geometry=e,a.material=s.material,h.push(a)}else if(2===s.type||3===s.type){let e=Ar.mergeLineGeometries(o,r,s.material instanceof Iu||s.material instanceof ln,m);if(!e)return;a=new bn(3),a.geometry=e,a.material=s.material,c.push(a)}else if(1===s.type){let e=Ni(o);if(!e)return;e.userData={},a=new bn(s.type),a.geometry=e,a.material=s.material,u.push(a)}a&&(r?a.userData.batches=m:(a.userData=s.userData,a.userData.batches=void 0),a.userData.layerName=s.userData.layerName,a.name=`[Merged] ${s.name}`,a.renderOrder=s.renderOrder,a.layers.mask=s.layers.mask,i.forEach((e=>d.push(e)))),o.forEach((e=>{e.dispose(),Qt.releaseGeometryManually(e)})),o=[]}})),se.debug(`[Merge] Ran deepMerge() in ${(Date.now()-s)/1e3}s`);let p=a.removed;d.forEach((t=>{let i=e[t];p.push(i),n&&i.removeFromParent()}));let f=a.added;return[...h,...c,...u].forEach((e=>{f.push(e),n&&t&&t.add(e)})),this.mergeInfo.removedObjects+=d.length,this.mergeInfo.mergedMeshes+=h.length,this.mergeInfo.mergedLines+=c.length,this.mergeInfo.mergedPoints+=u.length,i&&t&&Hn.removeEmptyObjects(t),a}static applyMatrix(e,t,n){let i=t;for(_C.identity();i&&i!==n&&(_C.premultiply(i.matrix),i.parent);)i=i.parent;return _C.equals(xdt)?e:e.applyMatrix4(_C)}static removeFromArray(e,t){for(let n=e.length-1;n>=0;--n)if(e[n]===t)return void e.splice(n,1)}static areObjectsMergeable(e,t){return e.layers.mask===t.layers.mask&&e.renderOrder===t.renderOrder&&e.userData.layerName===t.userData.layerName&&(e.type===t.type||!(2!==e.type&&3!==e.type||2!==t.type&&3!==t.type))}};function ume(e,t,n,i){let r={u_cameraZoom:n,u_patternLines:{value:e},u_patternAngle:{value:t},u_color:{value:i}},a=`\n uniform mat4 modelMatrix;\n uniform float u_cameraZoom;\n uniform vec3 u_color;\n varying vec3 v_pos;\n\n struct PatternLine {\n vec2 origin;\n vec2 delta;\n float angle;\n float pattern[MAX_PATTERN_SEGMENT_COUNT];\n float patternSum[MAX_PATTERN_SEGMENT_COUNT+1];\n float patternLength;\n };\n\n uniform PatternLine u_patternLines[${e.length}];\n uniform float u_patternAngle;\n\n #include \n\n // Clamp [0..1] range\n #define saturate(a) clamp(a, 0.0, 1.0)\n\n const float EPS = 1000.0;\n\n vec2 getWorldScale() {\n return vec2(length(modelMatrix[0].xyz), length(modelMatrix[1].xyz));\n }\n\n vec2 rotate(vec2 st, float rotation) {\n const float PI = 3.1415926;\n float angle = rotation * PI/180.0;\n float sine = sin(angle), cosine = cos(angle);\n return vec2(cosine * st.x - sine * st.y, cosine * st.y + sine * st.x);\n }\n\n vec2 translate(vec2 samplePosition, vec2 offset) {\n //move sample point in the opposite direction that we want to move shapes in\n return samplePosition - offset;\n }\n\n vec2 scale(vec2 samplePosition, float scale) {\n return samplePosition / scale;\n }\n\n float sdfLine(vec2 st, vec2 a, vec2 b) {\n vec2 ap = st - a;\n vec2 ab = b - a;\n return abs(((ap.x * ab.y) - (ab.x * ap.y))) / length(ab);\n }\n\n float drawSpaceLine(vec2 st, float distanceBetweenLines, float thick) {\n float dist = sdfLine(st , vec2(0.0, 0.0) , vec2(1.0, 0.0));\n \n //vec2 tt = dFdy(st);\n //float scale = (abs(tt.x)+abs(tt.y))/2.0;\n //float scale = length(fwidth(st)) * 0.5;\n // close to a pixel\n //float thick = 2.0;\n //thick = (thick * 0.5 - 0.5) * scale;\n\n float lineDistance = abs(fract(dist / distanceBetweenLines + 0.5) - 0.5) * distanceBetweenLines;\n //float lineDistance = fract(dist / distanceBetweenLines);\n //float distanceChange = fwidth(dist) * 0.5;\n //float threshold = smoothstep(thick - distanceChange, thick + distanceChange, lineDistance);\n //float threshold = step(thick,lineDistance);\n // remove gradient\n //float threshold = step(0.001,lineDistance);\n float threshold = step(thick,lineDistance);\n\n return threshold;\n }\n\n float drawSolidLine(PatternLine patternLine, float thick) {\n vec2 origin = patternLine.origin;\n vec2 delta = patternLine.delta;\n float distanceBetweenLines = length(delta);\n\n origin = rotate(origin,u_patternAngle);\n vec2 st = rotate(v_pos.xy - origin, -(patternLine.angle + u_patternAngle));\n\n return drawSpaceLine(st, distanceBetweenLines , thick);\n }\n\n int getPatternIndex(PatternLine patternLine, float u, out float distance ) {\n //u = mod(u, patternLine.patternLength);\n float y = floor(u/patternLine.patternLength);\n u = u - patternLine.patternLength * y;\n //float distance = 0.0;\n\n #pragma unroll_loop_start\n for(int i = 1; i < patternLine.patternSum.length(); i++){\n if(u <= patternLine.patternSum[i]) {\n distance = u - patternLine.patternSum[i-1];\n return i - 1;\n }\n }\n #pragma unroll_loop_end\n\n return -1;\n }\n\n float drawDashedLine(PatternLine patternLine, float thick){\n float threshold = 1.0;\n vec2 origin = patternLine.origin;\n vec2 delta = patternLine.delta; \n float distanceBetweenLines = abs(delta.y);\n\n origin = rotate(origin, u_patternAngle);\n vec2 st = rotate(v_pos.xy - origin, -(patternLine.angle + u_patternAngle));\n\n float offsetX = st.y * delta.x/delta.y;\n float u = st.x - offsetX;\n float distance = 0.0;\n int index = getPatternIndex(patternLine, u, distance);\n if(index < 0) {\n return threshold;\n }\n\n float size = patternLine.pattern[index];\n if(size >= 0.0) {\n threshold = drawSpaceLine(st, distanceBetweenLines , thick);\n // Try to solve the problem caused by the precision after zooming out by drawing a part of the dashed line\n } else if (distance < thick) {\n //threshold = 0.8;\n threshold = drawSpaceLine(st, distanceBetweenLines , thick);\n }\n \n return threshold;\n }\n\n float drawLine(PatternLine patternLine, float thick) {\n float t = 0.0;\n if(patternLine.patternLength > 0.0) {\n t = drawDashedLine(patternLine, thick);\n } else {\n t = drawSolidLine(patternLine, thick);\n }\n return t;\n }\n\n void main() {\n #include \n \n vec2 worldScale = getWorldScale();\n float averageScale = (abs(worldScale.x) + abs(worldScale.y))/2.0;\n // possible size of a pixel \n float thick = (0.7 / averageScale) / u_cameraZoom;\n\n if(thick > EPS) {\n gl_FragColor = vec4(u_color, 1.0);\n #include \n return;\n }\n\n float total = 0.0;\n\n#if ${e.length} > 1\n #pragma unroll_loop_start\n for (int i = 0; i < u_patternLines.length(); i++) {\n PatternLine pl = u_patternLines[i];\n float t = drawLine(pl, thick);\n total += (1.0 - t);\n }\n #pragma unroll_loop_end\n#else\n float t = drawLine(u_patternLines[0], thick);\n total += (1.0 - t);\n#endif\n\n total = saturate(total);\n if (total < 0.001) {\n discard;\n }\n\n gl_FragColor = vec4(u_color * total, 1.0);\n #include \n }\n `;return new ln({uniforms:r,vertexShader:"\n varying vec3 v_pos;\n\n #include \n void main() {\n //vec4 worldPosition = modelMatrix * vec4(position, 1.0);\n v_pos = position;\n\n #include \n #include \n #include \n }",fragmentShader:a,clipping:!0})}Lc.mergeInfo={removedObjects:0,mergedMeshes:0,mergedLines:0,mergedPoints:0,mergedUnknownTypeObjects:0,elapsedTime:0};var TC=class{static createLineShaderMaterial(e,t,n,i,r){let a=0,s=[];for(let h=0;h\n\n vec2 getWorldScale() {\n return vec2(length(modelMatrix[0].xyz), length(modelMatrix[1].xyz));\n }\n\n void main() {\n\n #include \n\n // vec2 worldScale = getWorldScale();\n // float averageScale = (abs(worldScale.x) + abs(worldScale.y))/2.0;\n // When zoomed out to a certain extent, it is displayed as a solid line.\n if(patternLength * u_viewportScale * u_cameraZoom/1.5 < 1.0){\n gl_FragColor = vec4(u_color, opacity);\n #include \n return;\n }\n\n float pos = mod(vLineDistance, patternLength * u_viewportScale);\n\n for ( int i = 0; i < ${e.length}; i++ ) {\n pos = pos - abs(pattern[i] * u_viewportScale);\n if ( pos < 0.0 ) {\n if ( pattern[i] > 0.0 ) {\n gl_FragColor = vec4(u_color, opacity);\n break;\n }\n discard;\n }\n }\n #include \n }`;return new ln({uniforms:o,vertexShader:"\n attribute float lineDistance;\n varying float vLineDistance;\n\n #include \n\n void main() {\n vLineDistance = lineDistance;\n\n #include \n #include \n #include \n }",fragmentShader:l,clipping:!0})}},e6={};FT(e6,{default:()=>Q5});var J5={};FT(J5,{default:()=>K5});var K5=(e,t)=>void 0===t||0==+t?Math.round(e):(e=+e,t=+t,isNaN(e)||"number"!=typeof t||t%1!=0?NaN:(e=e.toString().split("e"),+((e=(e=Math.round(+(e[0]+"e"+(e[1]?+e[1]-t:-t)))).toString().split("e"))[0]+"e"+(e[1]?+e[1]+t:t)))),Q5=(e,t,n,i,r)=>{let a=n.length,s=n[0].length;if(e<0||e>1)throw new Error("t out of bounds [0,1]: "+e);if(t<1)throw new Error("degree must be at least 1 (linear)");if(t>a-1)throw new Error("degree must be less than or equal to point count - 1");if(i){if(i.length!==a+t+1)throw new Error("bad knot vector length")}else{i=[];for(let e=0;e=i[o]&&e<=i[o+1]);o++);let u,d=[];for(let f=0;fo-t-1+f;n--){u=(e-i[n])/(i[n+t+1-f]-i[n]);for(let e=0;e{if(!e)return[];e=e.replace(/%%(.)/g,((e,t)=>bdt[t]||t));let n,i=null==t?void 0:t.encoding,r=i instanceof TextDecoder?i:void 0,a="",s=[],o=e=>{a&&(s.push(a),a=""),s.push(e)};for(let l=0;l(e=Tdt(e),t?wdt(e,t):e),Tdt=e=>e.replace(/\\[uU]\+([0-9a-fA-F]{4})/g,((e,t)=>String.fromCodePoint(parseInt(t,16)))),wdt=(e,t)=>{let n=t instanceof TextDecoder?t:new TextDecoder(t);return e.replace(/\\[mM]\+[0|1]([0-9a-fA-F]{2})([0-9a-fA-F]{2})/g,((e,i,r)=>(n=n||new TextDecoder(t)).decode(new Uint8Array([parseInt(i,16),parseInt(r,16)]))))},SC=(e,t)=>{let n=0,i={text:""},r=[i],a=(e=_dt(e,null==t?void 0:t.encoding)).matchAll(/%%(\d\d\d|.)/g);for(let s of a){i.text+=e.slice(n,s.index);let t=s[1].toLowerCase(),a=Edt[t];a?i.text+=a:3===t.length?i.text+=String.fromCodePoint(+t):"k"===t||"o"===t||"u"===t?(i=Ri(Tr({},i),{text:""}),i[t]?delete i[t]:i[t]=1,r.push(i)):i.text+=t,n=s.index+s[0].length}return i.text+=e.slice(n),r.filter((e=>e.text))},t6=(e=>(e.Unitless="Unitless",e.Inches="Inches",e.Feet="Feet",e.Millimeters="Millimeters",e.Centimeters="Centimeters",e.Meters="Meters",e))(t6||{}),hme=e=>"Unitless"===e?1:"Inches"===e?.0254:"Feet"===e?.3048:"Millimeters"===e?.001:"Centimeters"===e?.01:("Meters"===e||console.warn(`[Units] Unsupported unit '${e}', will return 1 for unit scale.`),1),dme=(e,t)=>hme(e)/hme(t),MC=class extends ta{constructor(e,t={}){let n=t.font;if(void 0===n)super();else{let i=n.generateShapes(e,t.size);t.depth=void 0!==t.height?t.height:50,void 0===t.bevelThickness&&(t.bevelThickness=10),void 0===t.bevelSize&&(t.bevelSize=8),void 0===t.bevelEnabled&&(t.bevelEnabled=!1),super(i,t)}this.type="TextGeometry"}},RC=class{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){let n=[],i=Sdt(e,t,this.data);for(let r=0,a=i.length;rwindow.localStorage.getItem(fme),Adt=()=>{window.localStorage.setItem(fme,$E)},pme=()=>Rdt()!==$E&&(Adt(),!0),dy=class{constructor(){this.DATABASE_NAME="gemini_viewer_db",this.TABLES=[{name:"viewpoint",options:{keyPath:"id",autoIncrement:!0},indexArray:[]},{name:"annotation",options:{keyPath:"id",autoIncrement:!0},indexArray:[]},{name:"dxfdata",options:{keyPath:"dxfDataId",autoIncrement:!1},indexArray:[]},{name:"fontdata",options:{keyPath:"fileName",autoIncrement:!0},indexArray:[]}],this.db=void 0}static instance(){return dy._instance||(dy._instance=new dy),dy._instance}getDatabase(){return ft(this,null,(function*(){let e=yield this.getDB(this.DATABASE_NAME);return this.db||(e.close(),pme()&&(yield this.deleteDataBase(this.DATABASE_NAME)),e=yield this.getUpgradedDB(e)),e.onclose=()=>{this.db=void 0,se.debug(`[DB] Db ${e.name} is closed.`)},e.onerror=t=>{this.db=void 0,se.debug(`[DB] Db ${e.name} encountered error.`,t)},e.onabort=t=>{this.db=void 0,se.debug(`[DB] Db ${e.name} aborted.`,t)},e.onversionchange=e=>{se.debug("onversionchange",e)},this.db=e,Promise.resolve(this.db)}))}closeDatabase(){this.db&&this.db.close()}deleteDataBase(e){return new Promise(((t,n)=>{let i=window.indexedDB.deleteDatabase(e);i.onerror=e=>{se.debug(e),n(e)},i.onsuccess=n=>{let i=n.target;se.debug(`[DB] Db ${e} delete old version ${n.oldVersion}.`),t(i)}}))}getDB(e){return ft(this,null,(function*(){return new Promise(((t,n)=>{let i=window.indexedDB.open(e);i.onerror=n,i.onsuccess=e=>{let n=e.target.result;se.debug(`[DB] Db ${n.name} opened (version ${n.version}).`),t(n)}}))}))}getUpgradedDB(e){return ft(this,null,(function*(){return new Promise(((t,n)=>{se.debug(`[DB] Upgrading db ${e.name} (version ${e.version})`);let i=window.indexedDB.open(e.name,e.version+1);i.onerror=n,i.onblocked=e=>{se.debug("onblocked",e)},i.onupgradeneeded=e=>{e.target.transaction.oncomplete=()=>{se.debug(`[DB] Upgrade is done (new version: ${t.version}).`)};let t=e.target.result,n=[];for(let i=0;i0&&Promise.all(n).then((()=>{se.debug(`[DB] All(${n.length}) tables created.`)}))},i.onsuccess=e=>{let n=e.target.result;se.debug(`[DB] Db ${n.name} opened (version ${n.version}).`),t(n)}}))}))}createTable(e,t,n,i){return ft(this,null,(function*(){return new Promise((r=>{let a=e.createObjectStore(t,n);i&&i.forEach((e=>{a.createIndex(e.name,e.fields,{unique:e.unique})})),se.debug(`[DB] Table ${t} created.`),r(e)}))}))}},ns=dy;ns._instance=void 0;var Wu=class{constructor(){if(this.db=void 0,this.isCreatingTable=!1,-1===ns.instance().TABLES.findIndex((e=>e.name===this.tableName())))throw new Error(`Make sure to add table '${this.tableName()}' to IndexedDbManager.TABLES!`)}tableName(){throw new Error("Derived class have to override 'tableName', and set a proper table name!")}add(e,t,n){let i=this.tableName();ns.instance().getDatabase().then((r=>{let a=r.transaction([i],"readwrite").objectStore(i).add(e);a.onsuccess=t,a.onerror=n})).finally((()=>{ns.instance().closeDatabase()})).catch((e=>{n&&n(e)}))}save(e,t,n){let i=this.tableName();ns.instance().getDatabase().then((r=>{let a=r.transaction([i],"readwrite").objectStore(i).put(e);a.onsuccess=t,a.onerror=n})).finally((()=>{ns.instance().closeDatabase()}))}delete(e,t,n){let i=this.tableName();ns.instance().getDatabase().then((r=>{let a=r.transaction([i],"readwrite").objectStore(i).delete(e);a.onsuccess=t,a.onerror=n})).finally((()=>{ns.instance().closeDatabase()}))}update(){ns.instance().getDatabase().then((()=>{}))}query(e,t){let n=this.tableName();ns.instance().getDatabase().then((i=>{let r=i.transaction([n],"readonly").objectStore(n).openCursor();r.onsuccess=t=>{let n=t.target.result;n&&n.continue(),e&&e(n)},r.onerror=t})).finally((()=>{ns.instance().closeDatabase()}))}queryByIndex(e,t,n,i){let r=this.tableName();ns.instance().getDatabase().then((a=>{let s=a.transaction([r],"readonly").objectStore(r).index(e).get(t);s.onerror=i,s.onsuccess=function(e){var t;let i=null==(t=e.target)?void 0:t.result;n&&n(i)}})).finally((()=>{ns.instance().closeDatabase()}))}queryAll(e,t){let n=this.tableName();ns.instance().getDatabase().then((i=>{let r=i.transaction([n],"readonly").objectStore(n).getAll();r.onsuccess=t=>{e&&e(r.result)},r.onerror=t})).finally((()=>{ns.instance().closeDatabase()}))}clearAll(e,t){let n=this.tableName();ns.instance().getDatabase().then((i=>{let r=i.transaction([n],"readwrite").objectStore(n).clear();r.onsuccess=t=>{e&&e(t)},r.onerror=e=>{t&&t(e)}})).finally((()=>{ns.instance().closeDatabase()}))}},fy=class extends Wu{tableName(){return"annotation"}static instance(){return fy._instance||(fy._instance=new fy),fy._instance}query(e,t,n){let i=[];super.query((n=>{n?!n.value||n.value.projectId!==e||i.push(n.value):t&&t(i)}),(e=>{console.log(e)}))}},n6=fy;n6._instance=void 0;var py=class extends Wu{tableName(){return"viewpoint"}static instance(){return py._instance||(py._instance=new py),py._instance}query(e,t,n){let i=[];super.query((n=>{n?!n.value||n.value.projectId!==e||i.push(n.value):t&&t(i)}),(e=>{n&&n(),console.log(e)}))}},r6=py;r6._instance=void 0;var my=class extends Wu{tableName(){return"dxfdata"}static instance(){return my._instance||(my._instance=new my),my._instance}query(e,t,n){let i=[],r=this.tableName();ns.instance().getDatabase().then((a=>{let s=a.transaction([r],"readonly").objectStore(r).get(e);s.onerror=e=>{n&&n(e),se.info("[DxfDataTable] Failed to query !",e)},s.onsuccess=()=>{s.result&&i.push(s.result),t&&t(i)}})).finally((()=>{ns.instance().closeDatabase()}))}},gy=my;gy._instance=void 0;var Ym=class extends Wu{tableName(){return"fontdata"}static instance(){return Ym._instance||(Ym._instance=new Ym),Ym._instance}query(e){let t;return new Promise(((n,i)=>{super.query((i=>{i?!i.value||i.value.fileName!==e||(t=i.value):n(t)}),(e=>{i(e)}))}))}queryAll(){return ft(this,null,(function*(){return new Promise(((e,t)=>{uG(Ym.prototype,this,"queryAll").call(this,(t=>{e(t)}),(e=>{t(e)}))}))}))}},sd=Ym;sd._instance=void 0;var vy=class extends RC{constructor(e,t){super(t),this.info="",this.orientation=0,this.baseUp=0,this.baseDown=0,this.fileHeader="",this.fileVersion="",this.order=0,this.unsupportedChars={},this.fileName=e}addUnsupportedChar(e){this.unsupportedChars[e]||(this.unsupportedChars[e]=0),this.unsupportedChars[e]++}getFontFile(){return{order:this.order,data:this.data,info:this.info,orientation:this.orientation,baseUp:this.baseUp,baseDown:this.baseDown,fileName:this.fileName,fileHeader:this.fileHeader,fileVersion:this.fileVersion}}setFontFile(e){this.fileName=e.fileName,this.data=e.data,this.info=e.info,this.order=e.order,this.orientation=e.orientation,this.baseUp=e.baseUp,this.baseDown=e.baseDown,this.fileHeader=e.fileHeader,this.fileVersion=e.fileVersion}setFontDataToIndexedDb(){return ft(this,null,(function*(){let e=this.getFontFile();return new Promise(((t,n)=>{sd.instance().save(e,(()=>{console.log(`[FontFile] Saved '${this.fileName}' (${this.fileHeader}) to indexedDb`),t()}),(e=>n(`[FontFile] Failed to save '${this.fileName}' (${this.fileHeader}) to indexedDb! ${e}`)))}))}))}getFontDataByIndexedDb(){return ft(this,null,(function*(){return sd.instance().query(this.fileName)}))}releaseFontData(){this.data={}}};String.prototype.codePointAt||function(){var e=function(){try{var e={},t=Object.defineProperty,n=t(e,e,e)&&t}catch(e){}return n}(),t=function(e){if(null==this)throw TypeError();var t=String(this),n=t.length,i=e?Number(e):0;if(i!=i&&(i=0),!(i<0||i>=n)){var r,a=t.charCodeAt(i);return a>=55296&&a<=56319&&n>i+1&&(r=t.charCodeAt(i+1))>=56320&&r<=57343?1024*(a-55296)+r-56320+65536:a}};e?e(String.prototype,"codePointAt",{value:t,configurable:!0,writable:!0}):String.prototype.codePointAt=t}();var _6=0,ege=-3;function JE(){this.table=new Uint16Array(16),this.trans=new Uint16Array(288)}function Cdt(e,t){this.source=e,this.sourceIndex=0,this.tag=0,this.bitcount=0,this.dest=t,this.destLen=0,this.ltree=new JE,this.dtree=new JE}var tge=new JE,nge=new JE,T6=new Uint8Array(30),w6=new Uint16Array(30),rge=new Uint8Array(30),ige=new Uint16Array(30),Pdt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),mme=new JE,ju=new Uint8Array(320);function sge(e,t,n,i){var r,a;for(r=0;r>>=1,t}function Xu(e,t,n){if(!t)return n;for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>16-t;return e.tag>>>=t,e.bitcount-=t,i+n}function f6(e,t){for(;e.bitcount<24;)e.tag|=e.source[e.sourceIndex++]<>>=1,++r,n+=t.table[r],i-=t.table[r]}while(i>=0);return e.tag=a,e.bitcount-=r,t.trans[n+i]}function Ddt(e,t,n){var i,r,a,s,o,l;for(i=Xu(e,5,257),r=Xu(e,5,1),a=Xu(e,4,4),s=0;s<19;++s)ju[s]=0;for(s=0;s8;)e.sourceIndex--,e.bitcount-=8;if((t=256*(t=e.source[e.sourceIndex+1])+e.source[e.sourceIndex])!==(65535&~(256*e.source[e.sourceIndex+3]+e.source[e.sourceIndex+2])))return ege;for(e.sourceIndex+=4,n=t;n;--n)e.dest[e.destLen++]=e.source[e.sourceIndex++];return e.bitcount=0,_6}function kdt(e,t){var n,i,r=new Cdt(e,t);do{switch(n=Ldt(r),Xu(r,2,0)){case 0:i=Odt(r);break;case 1:i=vme(r,tge,nge);break;case 2:Ddt(r,r.ltree,r.dtree),i=vme(r,r.ltree,r.dtree);break;default:i=ege}if(i!==_6)throw new Error("Data error")}while(!n);return r.destLenthis.x2&&(this.x2=e)),"number"==typeof t&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=t,this.y2=t),tthis.y2&&(this.y2=t))},Ff.prototype.addX=function(e){this.addPoint(e,null)},Ff.prototype.addY=function(e){this.addPoint(null,e)},Ff.prototype.addBezier=function(e,t,n,i,r,a,s,o){var l=[e,t],h=[n,i],c=[r,a],u=[s,o];this.addPoint(e,t),this.addPoint(s,o);for(var d=0;d<=1;d++){var p=6*l[d]-12*h[d]+6*c[d],f=-3*l[d]+9*h[d]-9*c[d]+3*u[d],m=3*h[d]-3*l[d];if(0!==f){var g=Math.pow(p,2)-4*m*f;if(!(g<0)){var v=(-p+Math.sqrt(g))/(2*f);0=0&&i>0&&(n+=" "),n+=t(r)}return n}e=void 0!==e?e:2;for(var i="",r=0;r"},Fs.prototype.toDOMElement=function(e){var t=this.toPathData(e),n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",t),n};var Yn={fail:age,argument:yme,assert:yme},xme=32768,bme=2147483648,by={},nn={},Qn={};function Fc(e){return function(){return e}}nn.BYTE=function(e){return Yn.argument(e>=0&&e<=255,"Byte value should be between 0 and 255."),[e]},Qn.BYTE=Fc(1),nn.CHAR=function(e){return[e.charCodeAt(0)]},Qn.CHAR=Fc(1),nn.CHARARRAY=function(e){void 0===e&&(e="",console.warn("Undefined CHARARRAY encountered and treated as an empty string. This is probably caused by a missing glyph name."));for(var t=[],n=0;n>8&255,255&e]},Qn.USHORT=Fc(2),nn.SHORT=function(e){return e>=xme&&(e=-(2*xme-e)),[e>>8&255,255&e]},Qn.SHORT=Fc(2),nn.UINT24=function(e){return[e>>16&255,e>>8&255,255&e]},Qn.UINT24=Fc(3),nn.ULONG=function(e){return[e>>24&255,e>>16&255,e>>8&255,255&e]},Qn.ULONG=Fc(4),nn.LONG=function(e){return e>=bme&&(e=-(2*bme-e)),[e>>24&255,e>>16&255,e>>8&255,255&e]},Qn.LONG=Fc(4),nn.FIXED=nn.ULONG,Qn.FIXED=Qn.ULONG,nn.FWORD=nn.SHORT,Qn.FWORD=Qn.SHORT,nn.UFWORD=nn.USHORT,Qn.UFWORD=Qn.USHORT,nn.LONGDATETIME=function(e){return[0,0,0,0,e>>24&255,e>>16&255,e>>8&255,255&e]},Qn.LONGDATETIME=Fc(8),nn.TAG=function(e){return Yn.argument(4===e.length,"Tag should be exactly 4 ASCII characters."),[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]},Qn.TAG=Fc(4),nn.Card8=nn.BYTE,Qn.Card8=Qn.BYTE,nn.Card16=nn.USHORT,Qn.Card16=Qn.USHORT,nn.OffSize=nn.BYTE,Qn.OffSize=Qn.BYTE,nn.SID=nn.USHORT,Qn.SID=Qn.USHORT,nn.NUMBER=function(e){return e>=-107&&e<=107?[e+139]:e>=108&&e<=1131?[247+((e-=108)>>8),255&e]:e>=-1131&&e<=-108?[251+((e=-e-108)>>8),255&e]:e>=-32768&&e<=32767?nn.NUMBER16(e):nn.NUMBER32(e)},Qn.NUMBER=function(e){return nn.NUMBER(e).length},nn.NUMBER16=function(e){return[28,e>>8&255,255&e]},Qn.NUMBER16=Fc(3),nn.NUMBER32=function(e){return[29,e>>24&255,e>>16&255,e>>8&255,255&e]},Qn.NUMBER32=Fc(5),nn.REAL=function(e){var t=e.toString(),n=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(t);if(n){var i=parseFloat("1e"+((n[2]?+n[2]:0)+n[1].length));t=(Math.round(e*i)/i).toString()}for(var r="",a=0,s=t.length;a>8&255,t[t.length]=255&i}return t},Qn.UTF16=function(e){return 2*e.length};var p6={"x-mac-croatian":"\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\u2020\xb0\xa2\xa3\xa7\u2022\xb6\xdf\xae\u0160\u2122\xb4\xa8\u2260\u017d\xd8\u221e\xb1\u2264\u2265\u2206\xb5\u2202\u2211\u220f\u0161\u222b\xaa\xba\u03a9\u017e\xf8\xbf\xa1\xac\u221a\u0192\u2248\u0106\xab\u010c\u2026\xa0\xc0\xc3\xd5\u0152\u0153\u0110\u2014\u201c\u201d\u2018\u2019\xf7\u25ca\uf8ff\xa9\u2044\u20ac\u2039\u203a\xc6\xbb\u2013\xb7\u201a\u201e\u2030\xc2\u0107\xc1\u010d\xc8\xcd\xce\xcf\xcc\xd3\xd4\u0111\xd2\xda\xdb\xd9\u0131\u02c6\u02dc\xaf\u03c0\xcb\u02da\xb8\xca\xe6\u02c7","x-mac-cyrillic":"\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041a\u041b\u041c\u041d\u041e\u041f\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042a\u042b\u042c\u042d\u042e\u042f\u2020\xb0\u0490\xa3\xa7\u2022\xb6\u0406\xae\xa9\u2122\u0402\u0452\u2260\u0403\u0453\u221e\xb1\u2264\u2265\u0456\xb5\u0491\u0408\u0404\u0454\u0407\u0457\u0409\u0459\u040a\u045a\u0458\u0405\xac\u221a\u0192\u2248\u2206\xab\xbb\u2026\xa0\u040b\u045b\u040c\u045c\u0455\u2013\u2014\u201c\u201d\u2018\u2019\xf7\u201e\u040e\u045e\u040f\u045f\u2116\u0401\u0451\u044f\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043a\u043b\u043c\u043d\u043e\u043f\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044a\u044b\u044c\u044d\u044e","x-mac-gaelic":"\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\u2020\xb0\xa2\xa3\xa7\u2022\xb6\xdf\xae\xa9\u2122\xb4\xa8\u2260\xc6\xd8\u1e02\xb1\u2264\u2265\u1e03\u010a\u010b\u1e0a\u1e0b\u1e1e\u1e1f\u0120\u0121\u1e40\xe6\xf8\u1e41\u1e56\u1e57\u027c\u0192\u017f\u1e60\xab\xbb\u2026\xa0\xc0\xc3\xd5\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\u1e61\u1e9b\xff\u0178\u1e6a\u20ac\u2039\u203a\u0176\u0177\u1e6b\xb7\u1ef2\u1ef3\u204a\xc2\xca\xc1\xcb\xc8\xcd\xce\xcf\xcc\xd3\xd4\u2663\xd2\xda\xdb\xd9\u0131\xdd\xfd\u0174\u0175\u1e84\u1e85\u1e80\u1e81\u1e82\u1e83","x-mac-greek":"\xc4\xb9\xb2\xc9\xb3\xd6\xdc\u0385\xe0\xe2\xe4\u0384\xa8\xe7\xe9\xe8\xea\xeb\xa3\u2122\xee\xef\u2022\xbd\u2030\xf4\xf6\xa6\u20ac\xf9\xfb\xfc\u2020\u0393\u0394\u0398\u039b\u039e\u03a0\xdf\xae\xa9\u03a3\u03aa\xa7\u2260\xb0\xb7\u0391\xb1\u2264\u2265\xa5\u0392\u0395\u0396\u0397\u0399\u039a\u039c\u03a6\u03ab\u03a8\u03a9\u03ac\u039d\xac\u039f\u03a1\u2248\u03a4\xab\xbb\u2026\xa0\u03a5\u03a7\u0386\u0388\u0153\u2013\u2015\u201c\u201d\u2018\u2019\xf7\u0389\u038a\u038c\u038e\u03ad\u03ae\u03af\u03cc\u038f\u03cd\u03b1\u03b2\u03c8\u03b4\u03b5\u03c6\u03b3\u03b7\u03b9\u03be\u03ba\u03bb\u03bc\u03bd\u03bf\u03c0\u03ce\u03c1\u03c3\u03c4\u03b8\u03c9\u03c2\u03c7\u03c5\u03b6\u03ca\u03cb\u0390\u03b0\xad","x-mac-icelandic":"\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\xdd\xb0\xa2\xa3\xa7\u2022\xb6\xdf\xae\xa9\u2122\xb4\xa8\u2260\xc6\xd8\u221e\xb1\u2264\u2265\xa5\xb5\u2202\u2211\u220f\u03c0\u222b\xaa\xba\u03a9\xe6\xf8\xbf\xa1\xac\u221a\u0192\u2248\u2206\xab\xbb\u2026\xa0\xc0\xc3\xd5\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\xf7\u25ca\xff\u0178\u2044\u20ac\xd0\xf0\xde\xfe\xfd\xb7\u201a\u201e\u2030\xc2\xca\xc1\xcb\xc8\xcd\xce\xcf\xcc\xd3\xd4\uf8ff\xd2\xda\xdb\xd9\u0131\u02c6\u02dc\xaf\u02d8\u02d9\u02da\xb8\u02dd\u02db\u02c7","x-mac-inuit":"\u1403\u1404\u1405\u1406\u140a\u140b\u1431\u1432\u1433\u1434\u1438\u1439\u1449\u144e\u144f\u1450\u1451\u1455\u1456\u1466\u146d\u146e\u146f\u1470\u1472\u1473\u1483\u148b\u148c\u148d\u148e\u1490\u1491\xb0\u14a1\u14a5\u14a6\u2022\xb6\u14a7\xae\xa9\u2122\u14a8\u14aa\u14ab\u14bb\u14c2\u14c3\u14c4\u14c5\u14c7\u14c8\u14d0\u14ef\u14f0\u14f1\u14f2\u14f4\u14f5\u1505\u14d5\u14d6\u14d7\u14d8\u14da\u14db\u14ea\u1528\u1529\u152a\u152b\u152d\u2026\xa0\u152e\u153e\u1555\u1556\u1557\u2013\u2014\u201c\u201d\u2018\u2019\u1558\u1559\u155a\u155d\u1546\u1547\u1548\u1549\u154b\u154c\u1550\u157f\u1580\u1581\u1582\u1583\u1584\u1585\u158f\u1590\u1591\u1592\u1593\u1594\u1595\u1671\u1672\u1673\u1674\u1675\u1676\u1596\u15a0\u15a1\u15a2\u15a3\u15a4\u15a5\u15a6\u157c\u0141\u0142","x-mac-ce":"\xc4\u0100\u0101\xc9\u0104\xd6\xdc\xe1\u0105\u010c\xe4\u010d\u0106\u0107\xe9\u0179\u017a\u010e\xed\u010f\u0112\u0113\u0116\xf3\u0117\xf4\xf6\xf5\xfa\u011a\u011b\xfc\u2020\xb0\u0118\xa3\xa7\u2022\xb6\xdf\xae\xa9\u2122\u0119\xa8\u2260\u0123\u012e\u012f\u012a\u2264\u2265\u012b\u0136\u2202\u2211\u0142\u013b\u013c\u013d\u013e\u0139\u013a\u0145\u0146\u0143\xac\u221a\u0144\u0147\u2206\xab\xbb\u2026\xa0\u0148\u0150\xd5\u0151\u014c\u2013\u2014\u201c\u201d\u2018\u2019\xf7\u25ca\u014d\u0154\u0155\u0158\u2039\u203a\u0159\u0156\u0157\u0160\u201a\u201e\u0161\u015a\u015b\xc1\u0164\u0165\xcd\u017d\u017e\u016a\xd3\xd4\u016b\u016e\xda\u016f\u0170\u0171\u0172\u0173\xdd\xfd\u0137\u017b\u0141\u017c\u0122\u02c7",macintosh:"\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\u2020\xb0\xa2\xa3\xa7\u2022\xb6\xdf\xae\xa9\u2122\xb4\xa8\u2260\xc6\xd8\u221e\xb1\u2264\u2265\xa5\xb5\u2202\u2211\u220f\u03c0\u222b\xaa\xba\u03a9\xe6\xf8\xbf\xa1\xac\u221a\u0192\u2248\u2206\xab\xbb\u2026\xa0\xc0\xc3\xd5\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\xf7\u25ca\xff\u0178\u2044\u20ac\u2039\u203a\ufb01\ufb02\u2021\xb7\u201a\u201e\u2030\xc2\xca\xc1\xcb\xc8\xcd\xce\xcf\xcc\xd3\xd4\uf8ff\xd2\xda\xdb\xd9\u0131\u02c6\u02dc\xaf\u02d8\u02d9\u02da\xb8\u02dd\u02db\u02c7","x-mac-romanian":"\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\u2020\xb0\xa2\xa3\xa7\u2022\xb6\xdf\xae\xa9\u2122\xb4\xa8\u2260\u0102\u0218\u221e\xb1\u2264\u2265\xa5\xb5\u2202\u2211\u220f\u03c0\u222b\xaa\xba\u03a9\u0103\u0219\xbf\xa1\xac\u221a\u0192\u2248\u2206\xab\xbb\u2026\xa0\xc0\xc3\xd5\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\xf7\u25ca\xff\u0178\u2044\u20ac\u2039\u203a\u021a\u021b\u2021\xb7\u201a\u201e\u2030\xc2\xca\xc1\xcb\xc8\xcd\xce\xcf\xcc\xd3\xd4\uf8ff\xd2\xda\xdb\xd9\u0131\u02c6\u02dc\xaf\u02d8\u02d9\u02da\xb8\u02dd\u02db\u02c7","x-mac-turkish":"\xc4\xc5\xc7\xc9\xd1\xd6\xdc\xe1\xe0\xe2\xe4\xe3\xe5\xe7\xe9\xe8\xea\xeb\xed\xec\xee\xef\xf1\xf3\xf2\xf4\xf6\xf5\xfa\xf9\xfb\xfc\u2020\xb0\xa2\xa3\xa7\u2022\xb6\xdf\xae\xa9\u2122\xb4\xa8\u2260\xc6\xd8\u221e\xb1\u2264\u2265\xa5\xb5\u2202\u2211\u220f\u03c0\u222b\xaa\xba\u03a9\xe6\xf8\xbf\xa1\xac\u221a\u0192\u2248\u2206\xab\xbb\u2026\xa0\xc0\xc3\xd5\u0152\u0153\u2013\u2014\u201c\u201d\u2018\u2019\xf7\u25ca\xff\u0178\u011e\u011f\u0130\u0131\u015e\u015f\u2021\xb7\u201a\u201e\u2030\xc2\xca\xc1\xcb\xc8\xcd\xce\xcf\xcc\xd3\xd4\uf8ff\xd2\xda\xdb\xd9\uf8a0\u02c6\u02dc\xaf\u02d8\u02d9\u02da\xb8\u02dd\u02db\u02c7"};by.MACSTRING=function(e,t,n,i){var r=p6[i];if(void 0!==r){for(var a="",s=0;s=-128&&e<=127}function Bdt(e,t,n){for(var i=0,r=e.length;t>8&255,l+256&255)}return a}nn.MACSTRING=function(e,t){var n=Ndt(t);if(void 0!==n){for(var i=[],r=0;r=128&&void 0===(a=n[a]))return;i[r]=a}return i}},Qn.MACSTRING=function(e,t){var n=nn.MACSTRING(e,t);return void 0!==n?n.length:0},nn.VARDELTAS=function(e){for(var t=0,n=[];t=-128&&i<=127?Udt(e,t,n):Hdt(e,t,n)}return n},nn.INDEX=function(e){for(var t=1,n=[t],i=[],r=0;r>8,t[u+1]=255&d,t=t.concat(i[c])}return t},Qn.TABLE=function(e){for(var t=0,n=e.fields.length,i=0;i0)return new Tt(this.data,this.offset+t).parseStruct(e)},Tt.prototype.parsePointer32=function(e){var t=this.parseOffset32();if(t>0)return new Tt(this.data,this.offset+t).parseStruct(e)},Tt.prototype.parseListOfLists=function(e){for(var t=this.parseOffset16List(),n=t.length,i=this.relativeOffset,r=new Array(n),a=0;a>1,t.skip("uShort",3),e.glyphIndexMap={};for(var s=new wn.Parser(n,i+r+14),o=new wn.Parser(n,i+r+16+2*a),l=new wn.Parser(n,i+r+16+4*a),h=new wn.Parser(n,i+r+16+6*a),c=i+r+16+8*a,u=0;u=0;r-=1){var a=wn.getUShort(e,t+4+8*r),s=wn.getUShort(e,t+4+8*r+2);if(3===a&&(0===s||1===s||10===s)||0===a&&(0===s||1===s||2===s||3===s||4===s)){i=wn.getULong(e,t+4+8*r+4);break}}if(-1===i)throw new Error("No valid cmap sub-tables found.");var o=new wn.Parser(e,t+i);if(n.format=o.parseUShort(),12===n.format)Xdt(n,o);else{if(4!==n.format)throw new Error("Only format 4 and 12 cmap tables are supported (found format "+n.format+").");Ydt(n,o,e,t,i)}return n}function Zdt(e,t,n){e.segments.push({end:t,start:t,delta:-(t-n),offset:0,glyphIndex:n})}function Kdt(e){e.segments.push({end:65535,start:65535,delta:1,offset:0})}function Jdt(e){var t,n=!0;for(t=e.length-1;t>0;t-=1)if(e.get(t).unicode>65535){console.log("Adding CMAP format 12 (needed!)"),n=!1;break}var i=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:n?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:n?12:20}];n||(i=i.concat([{name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}])),i=i.concat([{name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0}]);var r=new fn.Table("cmap",i);for(r.segments=[],t=0;t>4,a=15&i;if(15===r||(t+=n[r],15===a))break;t+=n[a]}return parseFloat(t)}function dft(e,t){if(28===t)return e.parseByte()<<8|e.parseByte();if(29===t)return e.parseByte()<<24|e.parseByte()<<16|e.parseByte()<<8|e.parseByte();if(30===t)return hft(e);if(t>=32&&t<=246)return t-139;if(t>=247&&t<=250)return 256*(t-247)+e.parseByte()+108;if(t>=251&&t<=254)return 256*-(t-251)-e.parseByte()-108;throw new Error("Invalid b0 "+t)}function fft(e){for(var t={},n=0;n>1,d.length=0,f=!0}return function n(h){for(var y,x,S,M,T,E,A,C,P,R,O,L,I=0;I1&&!f&&(b=d.shift()+c,f=!0),v+=d.pop(),_(g,v);break;case 5:for(;d.length>0;)g+=d.shift(),v+=d.shift(),u.lineTo(g,v);break;case 6:for(;d.length>0&&(g+=d.shift(),u.lineTo(g,v),0!==d.length);)v+=d.shift(),u.lineTo(g,v);break;case 7:for(;d.length>0&&(v+=d.shift(),u.lineTo(g,v),0!==d.length);)g+=d.shift(),u.lineTo(g,v);break;case 8:for(;d.length>0;)i=g+d.shift(),r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+d.shift(),u.curveTo(i,r,a,s,g,v);break;case 10:T=d.pop()+l,(E=o[T])&&n(E);break;case 11:return;case 12:switch(D=h[I],I+=1,D){case 35:i=g+d.shift(),r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),A=a+d.shift(),C=s+d.shift(),P=A+d.shift(),R=C+d.shift(),O=P+d.shift(),L=R+d.shift(),g=O+d.shift(),v=L+d.shift(),d.shift(),u.curveTo(i,r,a,s,A,C),u.curveTo(P,R,O,L,g,v);break;case 34:i=g+d.shift(),r=v,a=i+d.shift(),s=r+d.shift(),A=a+d.shift(),C=s,P=A+d.shift(),R=s,O=P+d.shift(),L=v,g=O+d.shift(),u.curveTo(i,r,a,s,A,C),u.curveTo(P,R,O,L,g,v);break;case 36:i=g+d.shift(),r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),A=a+d.shift(),C=s,P=A+d.shift(),R=s,O=P+d.shift(),L=R+d.shift(),g=O+d.shift(),u.curveTo(i,r,a,s,A,C),u.curveTo(P,R,O,L,g,v);break;case 37:i=g+d.shift(),r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),A=a+d.shift(),C=s+d.shift(),P=A+d.shift(),R=C+d.shift(),O=P+d.shift(),L=R+d.shift(),Math.abs(O-g)>Math.abs(L-v)?g=O+d.shift():v=L+d.shift(),u.curveTo(i,r,a,s,A,C),u.curveTo(P,R,O,L,g,v);break;default:console.log("Glyph "+t.index+": unknown operator 1200"+D),d.length=0}break;case 14:d.length>0&&!f&&(b=d.shift()+c,f=!0),m&&(u.closePath(),m=!1);break;case 19:case 20:w(),I+=p+7>>3;break;case 21:d.length>2&&!f&&(b=d.shift()+c,f=!0),v+=d.pop(),_(g+=d.pop(),v);break;case 22:d.length>1&&!f&&(b=d.shift()+c,f=!0),_(g+=d.pop(),v);break;case 24:for(;d.length>2;)i=g+d.shift(),r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+d.shift(),u.curveTo(i,r,a,s,g,v);g+=d.shift(),v+=d.shift(),u.lineTo(g,v);break;case 25:for(;d.length>6;)g+=d.shift(),v+=d.shift(),u.lineTo(g,v);i=g+d.shift(),r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+d.shift(),u.curveTo(i,r,a,s,g,v);break;case 26:for(d.length%2&&(g+=d.shift());d.length>0;)i=g,r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),g=a,v=s+d.shift(),u.curveTo(i,r,a,s,g,v);break;case 27:for(d.length%2&&(v+=d.shift());d.length>0;)i=g+d.shift(),r=v,a=i+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s,u.curveTo(i,r,a,s,g,v);break;case 28:y=h[I],x=h[I+1],d.push((y<<24|x<<16)>>16),I+=2;break;case 29:T=d.pop()+e.gsubrsBias,(E=e.gsubrs[T])&&n(E);break;case 30:for(;d.length>0&&(i=g,r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+(1===d.length?d.shift():0),u.curveTo(i,r,a,s,g,v),0!==d.length);)i=g+d.shift(),r=v,a=i+d.shift(),s=r+d.shift(),v=s+d.shift(),g=a+(1===d.length?d.shift():0),u.curveTo(i,r,a,s,g,v);break;case 31:for(;d.length>0&&(i=g+d.shift(),r=v,a=i+d.shift(),s=r+d.shift(),v=s+d.shift(),g=a+(1===d.length?d.shift():0),u.curveTo(i,r,a,s,g,v),0!==d.length);)i=g,r=v+d.shift(),a=i+d.shift(),s=r+d.shift(),g=a+d.shift(),v=s+(1===d.length?d.shift():0),u.curveTo(i,r,a,s,g,v);break;default:D<32?console.log("Glyph "+t.index+": unknown operator "+D):D<247?d.push(D-139):D<251?(y=h[I],I+=1,d.push(256*(D-247)+y+108)):D<255?(y=h[I],I+=1,d.push(256*-(D-251)-y-108)):(y=h[I],x=h[I+1],S=h[I+2],M=h[I+3],I+=4,d.push((y<<24|x<<16|S<<8|M)/65536))}}}(n),t.advanceWidth=b,u}function yft(e,t,n,i){var r,a=[],s=new wn.Parser(e,t),o=s.parseCard8();if(0===o)for(var l=0;l=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+r+" (FD count "+i+")");a.push(r)}else{if(3!==o)throw new Error("CFF Table CID Font FDSelect table has unsupported format "+o);var h=s.parseCard16(),c=s.parseCard16();if(0!==c)throw new Error("CFF Table CID Font FDSelect format 3 range has bad initial GID "+c);for(var u,d=0;d=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+r+" (FD count "+i+")");if(u>n)throw new Error("CFF Table CID Font FDSelect format 3 range has bad GID "+u);for(;c=0&&(n=i),(i=t.indexOf(e))>=0?n=i+OC.length:(n=OC.length+t.length,t.push(e)),n}function bft(){return new fn.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function Eft(e){var t=new fn.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);t.names=[];for(var n=0;n=n.begin&&e=1&&(n.ulCodePageRange1=i.parseULong(),n.ulCodePageRange2=i.parseULong()),n.version>=2&&(n.sxHeight=i.parseShort(),n.sCapHeight=i.parseShort(),n.usDefaultChar=i.parseUShort(),n.usBreakChar=i.parseUShort(),n.usMaxContent=i.parseUShort()),n}function Zft(e){return new fn.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],e)}var b6={parse:$ft,make:Zft,unicodeRanges:x6,getUnicodeRange:Yft};function Kft(e,t){var n={},i=new wn.Parser(e,t);switch(n.version=i.parseVersion(),n.italicAngle=i.parseFixed(),n.underlinePosition=i.parseShort(),n.underlineThickness=i.parseShort(),n.isFixedPitch=i.parseULong(),n.minMemType42=i.parseULong(),n.maxMemType42=i.parseULong(),n.minMemType1=i.parseULong(),n.maxMemType1=i.parseULong(),n.version){case 1:n.names=Zm.slice();break;case 2:n.numberOfGlyphs=i.parseUShort(),n.glyphNameIndex=new Array(n.numberOfGlyphs);for(var r=0;r=Zm.length){var s=i.parseChar();n.names.push(i.parseString(s))}break;case 2.5:n.numberOfGlyphs=i.parseUShort(),n.offset=new Array(n.numberOfGlyphs);for(var o=0;ot.value.tag?1:-1})),t.fields=t.fields.concat(i),t.fields=t.fields.concat(r),t}function Ime(e,t,n){for(var i=0;i0)return e.glyphs.get(r).getMetrics()}return n}function rpt(e){for(var t=0,n=0;ng||void 0===t)&&g>0&&(t=g),h 123 are reserved for internal usage");p|=1<0?Tge.make(L):void 0,k=Pge.make(),N=xge.make(e.glyphs,{version:e.getEnglishName("version"),fullName:C,familyName:E,weightName:A,postScriptName:P,unitsPerEm:e.unitsPerEm,fontBBox:[0,x.yMin,x.ascender,x.advanceWidthMax]}),F=e.metas&&Object.keys(e.metas).length>0?Lge.make(e.metas):void 0,U=[b,_,w,S,I,T,k,N,M];D&&U.push(D),e.tables.gsub&&U.push(Ige.make(e.tables.gsub)),F&&U.push(F);for(var B=Dge(U),z=A6(B.encode()),H=B.fields,V=!1,j=0;j>>1,a=e[r].tag;if(a===t)return r;a>>1,a=e[r];if(a===t)return r;a>>1,s=(n=e[a]).start;if(s===t)return n;s0)return t>(n=e[i-1]).end?0:n}function n_(e,t){this.font=e,this.tableName=t}function r_(e){n_.call(this,e,"gpos")}function tl(e){n_.call(this,e,"gsub")}function apt(e,t){var n=e.length;if(n!==t.length)return!1;for(var i=0;i0?(a=e.parseByte(),t&r||(a=-a),a=n+a):a=(t&r)>0?n:n+e.parseShort(),a}function Oge(e,t,n){var i,r,a=new wn.Parser(t,n);if(e.numberOfContours=a.parseShort(),e._xMin=a.parseShort(),e._yMin=a.parseShort(),e._xMax=a.parseShort(),e._yMax=a.parseShort(),e.numberOfContours>0){for(var s=e.endPointIndices=[],o=0;o0)for(var u=a.parseByte(),d=0;d0){var p,f=[];if(h>0){for(var m=0;m=0,f.push(p);for(var g=0,v=0;v0?(2&i)>0?(_.dx=a.parseShort(),_.dy=a.parseShort()):_.matchedPoints=[a.parseUShort(),a.parseUShort()]:(2&i)>0?(_.dx=a.parseChar(),_.dy=a.parseChar()):_.matchedPoints=[a.parseByte(),a.parseByte()],(8&i)>0?_.xScale=_.yScale=a.parseF2Dot14():(64&i)>0?(_.xScale=a.parseF2Dot14(),_.yScale=a.parseF2Dot14()):(128&i)>0&&(_.xScale=a.parseF2Dot14(),_.scale01=a.parseF2Dot14(),_.scale10=a.parseF2Dot14(),_.yScale=a.parseF2Dot14()),e.components.push(_),b=!!(32&i)}if(256&i){e.instructionLength=a.parseUShort(),e.instructions=[];for(var w=0;wt.points.length-1||i.matchedPoints[1]>r.points.length-1)throw Error("Matched points out of range in "+t.name);var s=t.points[i.matchedPoints[0]],o=r.points[i.matchedPoints[1]],l={xScale:i.xScale,scale01:i.scale01,scale10:i.scale10,yScale:i.yScale,dx:0,dy:0};o=o6([o],l)[0],l.dx=s.x-o.x,l.dy=s.y-o.y,a=o6(r.points,l)}t.points=t.points.concat(a)}}return kge(t.points)}function upt(e,t,n,i){for(var r=new $u.GlyphSet(i),a=0;a=0)return i[r].script;if(t){var a={tag:e,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return i.splice(-1-r,0,a),a.script}}},getLangSysTable:function(e,t,n){var i=this.getScriptTable(e,n);if(i){if(!t||"dflt"===t||"DFLT"===t)return i.defaultLangSys;var r=a6(i.langSysRecords,t);if(r>=0)return i.langSysRecords[r].langSys;if(n){var a={tag:t,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return i.langSysRecords.splice(-1-r,0,a),a.langSys}}},getFeatureTable:function(e,t,n,i){var r=this.getLangSysTable(e,t,i);if(r){for(var a,s=r.featureIndexes,o=this.font.tables[this.tableName].features,l=0;l=o[h-1].tag,"Features must be added in alphabetical order."),a={tag:n,feature:{params:0,lookupListIndexes:[]}},o.push(a),s.push(h),a.feature}}},getLookupTables:function(e,t,n,i,r){var a=this.getFeatureTable(e,t,n,r),s=[];if(a){for(var o,l=a.lookupListIndexes,h=this.font.tables[this.tableName].lookups,c=0;c=0?n:-1;case 2:var i=Dme(e.ranges,t);return i?i.index+t-i.start:-1}},expandCoverage:function(e){if(1===e.format)return e.glyphs;for(var t=[],n=e.ranges,i=0;i1,'Multiple: "by" must be an array of two or more ids');var r=C6(this.getLookupTables(n,i,e,2,!0)[0],1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});Yn.assert(1===r.coverage.format,"Multiple: unable to modify coverage table format "+r.coverage.format);var a=t.sub,s=this.binSearch(r.coverage.glyphs,a);s<0&&(s=-1-s,r.coverage.glyphs.splice(s,0,a),r.sequences.splice(s,0,0)),r.sequences[s]=t.by},tl.prototype.addAlternate=function(e,t,n,i){var r=C6(this.getLookupTables(n,i,e,3,!0)[0],1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});Yn.assert(1===r.coverage.format,"Alternate: unable to modify coverage table format "+r.coverage.format);var a=t.sub,s=this.binSearch(r.coverage.glyphs,a);s<0&&(s=-1-s,r.coverage.glyphs.splice(s,0,a),r.alternateSets.splice(s,0,0)),r.alternateSets[s]=t.by},tl.prototype.addLigature=function(e,t,n,i){var r=this.getLookupTables(n,i,e,4,!0)[0],a=r.subtables[0];a||(a={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},r.subtables[0]=a),Yn.assert(1===a.coverage.format,"Ligature: unable to modify coverage table format "+a.coverage.format);var s=t.sub[0],o=t.sub.slice(1),l={ligGlyph:t.by,components:o},h=this.binSearch(a.coverage.glyphs,s);if(h>=0){for(var c=a.ligatureSets[h],u=0;u=176&&n<=183)r+=n-176+1;else if(n>=184&&n<=191)r+=2*(n-184+1);else if(t&&1===a&&27===n)break}while(a>0);e.ip=r}function kme(e,t){exports.DEBUG&&console.log(t.step,"SVTCA["+e.axis+"]"),t.fv=t.pv=t.dpv=e}function Fme(e,t){exports.DEBUG&&console.log(t.step,"SPVTCA["+e.axis+"]"),t.pv=t.dpv=e}function Nme(e,t){exports.DEBUG&&console.log(t.step,"SFVTCA["+e.axis+"]"),t.fv=e}function Bme(e,t){var n,i,r=t.stack,a=r.pop(),s=r.pop(),o=t.z2[a],l=t.z1[s];exports.DEBUG&&console.log("SPVTL["+e+"]",a,s),e?(n=o.y-l.y,i=l.x-o.x):(n=l.x-o.x,i=l.y-o.y),t.pv=t.dpv=s_(n,i)}function Ume(e,t){var n,i,r=t.stack,a=r.pop(),s=r.pop(),o=t.z2[a],l=t.z1[s];exports.DEBUG&&console.log("SFVTL["+e+"]",a,s),e?(n=o.y-l.y,i=l.x-o.x):(n=l.x-o.x,i=l.y-o.y),t.fv=s_(n,i)}function xpt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"SPVFS[]",n,i),e.pv=e.dpv=s_(i,n)}function bpt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"SPVFS[]",n,i),e.fv=s_(i,n)}function Ept(e){var t=e.stack,n=e.pv;exports.DEBUG&&console.log(e.step,"GPV[]"),t.push(16384*n.x),t.push(16384*n.y)}function _pt(e){var t=e.stack,n=e.fv;exports.DEBUG&&console.log(e.step,"GFV[]"),t.push(16384*n.x),t.push(16384*n.y)}function Tpt(e){e.fv=e.pv,exports.DEBUG&&console.log(e.step,"SFVTPV[]")}function wpt(e){var t=e.stack,n=t.pop(),i=t.pop(),r=t.pop(),a=t.pop(),s=t.pop(),o=e.z0,l=e.z1,h=o[n],c=o[i],u=l[r],d=l[a],p=e.z2[s];exports.DEBUG&&console.log("ISECT[], ",n,i,r,a,s);var f=h.x,m=h.y,g=c.x,v=c.y,y=u.x,x=u.y,b=d.x,_=d.y,w=(f-g)*(x-_)-(m-v)*(y-b),S=f*v-m*g,M=y*_-x*b;p.x=(S*(y-b)-M*(f-g))/w,p.y=(S*(x-_)-M*(m-v))/w}function Spt(e){e.rp0=e.stack.pop(),exports.DEBUG&&console.log(e.step,"SRP0[]",e.rp0)}function Mpt(e){e.rp1=e.stack.pop(),exports.DEBUG&&console.log(e.step,"SRP1[]",e.rp1)}function Rpt(e){e.rp2=e.stack.pop(),exports.DEBUG&&console.log(e.step,"SRP2[]",e.rp2)}function Apt(e){var t=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SZP0[]",t),e.zp0=t,t){case 0:e.tZone||zC(e),e.z0=e.tZone;break;case 1:e.z0=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function Cpt(e){var t=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SZP1[]",t),e.zp1=t,t){case 0:e.tZone||zC(e),e.z1=e.tZone;break;case 1:e.z1=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function Ppt(e){var t=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SZP2[]",t),e.zp2=t,t){case 0:e.tZone||zC(e),e.z2=e.tZone;break;case 1:e.z2=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function Ipt(e){var t=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SZPS[]",t),e.zp0=e.zp1=e.zp2=t,t){case 0:e.tZone||zC(e),e.z0=e.z1=e.z2=e.tZone;break;case 1:e.z0=e.z1=e.z2=e.gZone;break;default:throw new Error("Invalid zone pointer")}}function Lpt(e){e.loop=e.stack.pop(),exports.DEBUG&&console.log(e.step,"SLOOP[]",e.loop)}function Dpt(e){exports.DEBUG&&console.log(e.step,"RTG[]"),e.round=Vge}function Opt(e){exports.DEBUG&&console.log(e.step,"RTHG[]"),e.round=mpt}function kpt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SMD[]",t),e.minDis=t/64}function Fpt(e){exports.DEBUG&&console.log(e.step,"ELSE[]"),Gge(e,!1)}function Npt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"JMPR[]",t),e.ip+=t-1}function Bpt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCVTCI[]",t),e.cvCutIn=t/64}function Upt(e){var t=e.stack;exports.DEBUG&&console.log(e.step,"DUP[]"),t.push(t[t.length-1])}function l6(e){exports.DEBUG&&console.log(e.step,"POP[]"),e.stack.pop()}function Hpt(e){exports.DEBUG&&console.log(e.step,"CLEAR[]"),e.stack.length=0}function Vpt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"SWAP[]"),t.push(n),t.push(i)}function zpt(e){var t=e.stack;exports.DEBUG&&console.log(e.step,"DEPTH[]"),t.push(t.length)}function Gpt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"LOOPCALL[]",n,i);var r=e.ip,a=e.prog;e.prog=e.funcs[n];for(var s=0;s1?"loop "+(t.loop-o)+": ":"")+"SHP["+(e?"rp1":"rp2")+"]",h)}t.loop=1}function Gme(e,t){var n=t.stack,i=e?t.rp1:t.rp2,r=(e?t.z0:t.z1)[i],a=t.fv,s=t.pv,o=n.pop(),l=t.z2[t.contours[o]],h=l;exports.DEBUG&&console.log(t.step,"SHC["+e+"]",o);var c=s.distance(r,r,!1,!0);do{h!==r&&a.setRelative(h,h,c,s),h=h.nextPointOnContour}while(h!==l)}function qme(e,t){var n,i=t.stack,r=e?t.rp1:t.rp2,a=(e?t.z0:t.z1)[r],s=t.fv,o=t.pv,l=i.pop();switch(exports.DEBUG&&console.log(t.step,"SHZ["+e+"]",l),l){case 0:n=t.tZone;break;case 1:n=t.gZone;break;default:throw new Error("Invalid zone")}for(var h,c=o.distance(a,a,!1,!0),u=n.length-2,d=0;d1?"loop "+(e.loop-n)+": ":"")+"SHPIX[]",s,r),i.setRelative(o,o,r),i.touch(o)}e.loop=1}function $pt(e){for(var t=e.stack,n=e.rp1,i=e.rp2,r=e.loop,a=e.z0[n],s=e.z1[i],o=e.fv,l=e.dpv,h=e.z2;r--;){var c=t.pop(),u=h[c];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-r)+": ":"")+"IP[]",c,n,"<->",i),o.interpolate(u,a,s,l),o.touch(u)}e.loop=1}function Wme(e,t){var n=t.stack,i=n.pop()/64,r=n.pop(),a=t.z1[r],s=t.z0[t.rp0],o=t.fv,l=t.pv;o.setRelative(a,s,i,l),o.touch(a),exports.DEBUG&&console.log(t.step,"MSIRP["+e+"]",i,r),t.rp1=t.rp0,t.rp2=r,e&&(t.rp0=r)}function Zpt(e){for(var t=e.stack,n=e.rp0,i=e.z0[n],r=e.loop,a=e.fv,s=e.pv,o=e.z1;r--;){var l=t.pop(),h=o[l];exports.DEBUG&&console.log(e.step,(e.loop>1?"loop "+(e.loop-r)+": ":"")+"ALIGNRP[]",l),a.setRelative(h,i,0,s),a.touch(h)}e.loop=1}function Kpt(e){exports.DEBUG&&console.log(e.step,"RTDG[]"),e.round=ppt}function jme(e,t){var n=t.stack,i=n.pop(),r=n.pop(),a=t.z0[r],s=t.fv,o=t.pv,l=t.cvt[i];exports.DEBUG&&console.log(t.step,"MIAP["+e+"]",i,"(",l,")",r);var h=o.distance(a,t_);e&&(Math.abs(h-l)",o),t.stack.push(Math.round(64*o))}function imt(e){exports.DEBUG&&console.log(e.step,"MPPEM[]"),e.stack.push(e.ppem)}function smt(e){exports.DEBUG&&console.log(e.step,"FLIPON[]"),e.autoFlip=!0}function amt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"LT[]",n,i),t.push(in?1:0)}function cmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"GTEQ[]",n,i),t.push(i>=n?1:0)}function umt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"EQ[]",n,i),t.push(n===i?1:0)}function hmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"NEQ[]",n,i),t.push(n!==i?1:0)}function dmt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"ODD[]",n),t.push(Math.trunc(n)%2?1:0)}function fmt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"EVEN[]",n),t.push(Math.trunc(n)%2?0:1)}function pmt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"IF[]",t),t||(Gge(e,!0),exports.DEBUG&&console.log(e.step,"EIF[]"))}function mmt(e){exports.DEBUG&&console.log(e.step,"EIF[]")}function gmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"AND[]",n,i),t.push(n&&i?1:0)}function vmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"OR[]",n,i),t.push(n||i?1:0)}function ymt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"NOT[]",n),t.push(n?0:1)}function c6(e,t){var n=t.stack,i=n.pop(),r=t.fv,a=t.pv,s=t.ppem,o=t.deltaBase+16*(e-1),l=t.deltaShift,h=t.z0;exports.DEBUG&&console.log(t.step,"DELTAP["+e+"]",i,n);for(var c=0;c>4)===s){var p=(15&d)-8;p>=0&&p++,exports.DEBUG&&console.log(t.step,"DELTAPFIX",u,"by",p*l);var f=h[u];r.setRelative(f,f,p*l,a)}}}function xmt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SDB[]",t),e.deltaBase=t}function bmt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SDS[]",t),e.deltaShift=Math.pow(.5,t)}function Emt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"ADD[]",n,i),t.push(i+n)}function _mt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"SUB[]",n,i),t.push(i-n)}function Tmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"DIV[]",n,i),t.push(64*i/n)}function wmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"MUL[]",n,i),t.push(i*n/64)}function Smt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"ABS[]",n),t.push(Math.abs(n))}function Mmt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"NEG[]",n),t.push(-n)}function Rmt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"FLOOR[]",n),t.push(64*Math.floor(n/64))}function Amt(e){var t=e.stack,n=t.pop();exports.DEBUG&&console.log(e.step,"CEILING[]",n),t.push(64*Math.ceil(n/64))}function DC(e,t){var n=t.stack,i=n.pop();exports.DEBUG&&console.log(t.step,"ROUND[]"),n.push(64*t.round(i/64))}function Cmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"WCVTF[]",n,i),e.cvt[i]=n*e.ppem/e.font.unitsPerEm}function u6(e,t){var n=t.stack,i=n.pop(),r=t.ppem,a=t.deltaBase+16*(e-1),s=t.deltaShift;exports.DEBUG&&console.log(t.step,"DELTAC["+e+"]",i,n);for(var o=0;o>4)===r){var c=(15&h)-8;c>=0&&c++;var u=c*s;exports.DEBUG&&console.log(t.step,"DELTACFIX",l,"by",u),t.cvt[l]+=u}}}function Pmt(e){var t,n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"SROUND[]",n),e.round=zge,192&n){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(e.srPeriod=t,48&n){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*t;break;case 32:e.srPhase=.5*t;break;case 48:e.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}n&=15,e.srThreshold=0===n?0:(n/8-.5)*t}function Imt(e){var t,n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"S45ROUND[]",n),e.round=zge,192&n){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(e.srPeriod=t,48&n){case 0:e.srPhase=0;break;case 16:e.srPhase=.25*t;break;case 32:e.srPhase=.5*t;break;case 48:e.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}n&=15,e.srThreshold=0===n?0:(n/8-.5)*t}function Lmt(e){exports.DEBUG&&console.log(e.step,"ROFF[]"),e.round=fpt}function Dmt(e){exports.DEBUG&&console.log(e.step,"RUTG[]"),e.round=gpt}function Omt(e){exports.DEBUG&&console.log(e.step,"RDTG[]"),e.round=vpt}function kmt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCANCTRL[]",t)}function $me(e,t){var n,i,r=t.stack,a=r.pop(),s=r.pop(),o=t.z2[a],l=t.z1[s];exports.DEBUG&&console.log(t.step,"SDPVTL["+e+"]",a,s),e?(n=o.y-l.y,i=l.x-o.x):(n=l.x-o.x,i=l.y-o.y),t.dpv=s_(n,i)}function Fmt(e){var t=e.stack,n=t.pop(),i=0;exports.DEBUG&&console.log(e.step,"GETINFO[]",n),1&n&&(i=35),32&n&&(i|=4096),t.push(i)}function Nmt(e){var t=e.stack,n=t.pop(),i=t.pop(),r=t.pop();exports.DEBUG&&console.log(e.step,"ROLL[]"),t.push(i),t.push(n),t.push(r)}function Bmt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"MAX[]",n,i),t.push(Math.max(i,n))}function Umt(e){var t=e.stack,n=t.pop(),i=t.pop();exports.DEBUG&&console.log(e.step,"MIN[]",n,i),t.push(Math.min(i,n))}function Hmt(e){var t=e.stack.pop();exports.DEBUG&&console.log(e.step,"SCANTYPE[]",t)}function Vmt(e){var t=e.stack.pop(),n=e.stack.pop();switch(exports.DEBUG&&console.log(e.step,"INSTCTRL[]",t,n),t){case 1:return void(e.inhibitGridFit=!!n);case 2:return void(e.ignoreCvt=!!n);default:throw new Error("invalid INSTCTRL[] selector")}}function Pf(e,t){var n=t.stack,i=t.prog,r=t.ip;exports.DEBUG&&console.log(t.step,"PUSHB["+e+"]");for(var a=0;a=0?1:-1,o=Math.abs(o),e&&(h=a.cvt[u],i&&Math.abs(o-h)":"_")+(i?"R":"_")+(0===r?"Gr":1===r?"Bl":2===r?"Wh":"")+"]",e?u+"("+a.cvt[u]+","+h+")":"",d,"(d =",s,"->",l*o,")"),a.rp1=a.rp0,a.rp2=d,t&&(a.rp0=d)}function _y(e){this.char=e,this.state={},this.activeState=null}function P6(e,t,n){this.contextName=n,this.startIndex=e,this.endOffset=t}function zmt(e,t,n){this.contextName=e,this.openRange=null,this.ranges=[],this.checkStart=t,this.checkEnd=n}function Oc(e,t){this.context=e,this.index=t,this.length=e.length,this.current=e[t],this.backtrack=e.slice(0,t),this.lookahead=e.slice(t+1)}function GC(e){this.eventId=e,this.subscribers=[]}function Gmt(e){var t=this,n=["start","end","next","newToken","contextStart","contextEnd","insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD","updateContextsRanges"];n.forEach((function(e){Object.defineProperty(t.events,e,{value:new GC(e)})})),e&&n.forEach((function(n){var i=e[n];"function"==typeof i&&t.events[n].subscribe(i)})),["insertToken","removeToken","removeRange","replaceToken","replaceRange","composeRUD"].forEach((function(e){t.events[e].subscribe(t.updateContextsRanges)}))}function ds(e){this.tokens=[],this.registeredContexts={},this.contextCheckers=[],this.events={},this.registeredModifiers=[],Gmt.call(this,e)}function Of(e){return/[\u0600-\u065F\u066A-\u06D2\u06FA-\u06FF]/.test(e)}function qge(e){return/[\u0630\u0690\u0621\u0631\u0661\u0671\u0622\u0632\u0672\u0692\u06C2\u0623\u0673\u0693\u06C3\u0624\u0694\u06C4\u0625\u0675\u0695\u06C5\u06E5\u0676\u0696\u06C6\u0627\u0677\u0697\u06C7\u0648\u0688\u0698\u06C8\u0689\u0699\u06C9\u068A\u06CA\u066B\u068B\u06CB\u068C\u068D\u06CD\u06FD\u068E\u06EE\u06FE\u062F\u068F\u06CF\u06EF]/.test(e)}function kf(e){return/[\u0600-\u0605\u060C-\u060E\u0610-\u061B\u061E\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED]/.test(e)}function kC(e){return/[A-z]/.test(e)}function qmt(e){return/\s/.test(e)}function nl(e){this.font=e,this.features={}}function Km(e){this.id=e.id,this.tag=e.tag,this.substitution=e.substitution}function a_(e,t){if(!e)return-1;switch(t.format){case 1:return t.glyphs.indexOf(e);case 2:for(var n=t.ranges,i=0;i=r.start&&e<=r.end){var a=e-r.start;return r.index+a}}break;default:return-1}return-1}function Wmt(e,t){return-1===a_(e,t.coverage)?null:e+t.deltaGlyphId}function jmt(e,t){var n=a_(e,t.coverage);return-1===n?null:t.substitute[n]}function h6(e,t){for(var n=[],i=0;i2)){var n=this.font,i=this._prepState;if(!i||i.ppem!==t){var r=this._fpgmState;if(!r){Df.prototype=ypt,(r=this._fpgmState=new Df("fpgm",n.tables.fpgm)).funcs=[],r.font=n,exports.DEBUG&&(console.log("---EXEC FPGM---"),r.step=-1);try{Jm(r)}catch(e){return console.log("Hinting error in FPGM:"+e),void(this._errorState=3)}}Df.prototype=r,(i=this._prepState=new Df("prep",n.tables.prep)).ppem=t;var a=n.tables.cvt;if(a)for(var s=i.cvt=new Array(a.length),o=t/n.unitsPerEm,l=0;l1))try{return Uge(e,i)}catch(e){return this._errorState<1&&(console.log("Hinting error:"+e),console.log("Note: further hinting errors are silenced")),void(this._errorState=1)}}},Uge=function(e,t){var n,i,r,a=t.ppem/t.font.unitsPerEm,s=a,o=e.components;if(Df.prototype=t,o){var l=t.font;i=[],n=[];for(var h=0;h=0&&e0&&e<=this.lookahead.length:return this.lookahead[e-1];default:return null}},ds.prototype.rangeToText=function(e){if(e instanceof P6)return this.getRangeTokens(e).map((function(e){return e.char})).join("")},ds.prototype.getText=function(){return this.tokens.map((function(e){return e.char})).join("")},ds.prototype.getContext=function(e){return this.registeredContexts[e]||null},ds.prototype.on=function(e,t){var n=this.events[e];return n?n.subscribe(t):null},ds.prototype.dispatch=function(e,t){var n=this,i=this.events[e];i instanceof GC&&i.subscribers.forEach((function(e){e.apply(n,t||[])}))},ds.prototype.registerContextChecker=function(e,t,n){if(this.getContext(e))return{FAIL:"context name '"+e+"' is already registered."};if("function"!=typeof t)return{FAIL:"missing context start check."};if("function"!=typeof n)return{FAIL:"missing context end check."};var i=new zmt(e,t,n);return this.registeredContexts[e]=i,this.contextCheckers.push(i),i},ds.prototype.getRangeTokens=function(e){var t=e.startIndex+e.endOffset;return[].concat(this.tokens.slice(e.startIndex,t))},ds.prototype.getContextRanges=function(e){var t=this.getContext(e);return t?t.ranges:{FAIL:"context checker '"+e+"' is not registered."}},ds.prototype.resetContextsRanges=function(){var e=this.registeredContexts;for(var t in e)e.hasOwnProperty(t)&&(e[t].ranges=[])},ds.prototype.updateContextsRanges=function(){this.resetContextsRanges();for(var e=this.tokens.map((function(e){return e.char})),t=0;t=0;n--){var i=t[n],r=qge(i),a=kf(i);if(!r&&!a)return!0;if(r)return!1}return!1}function ogt(e){if(qge(e.current))return!1;for(var t=0;t=1.2&&(r.markGlyphSets=n.parsePointer(Pgt)),r}var Lgt={parse:Igt},kc=new Array(10);function Dgt(e,t){var n=new Tt(e,t=t||0),i=n.parseVersion(1);return Yn.argument(1===i||1.1===i,"Unsupported GPOS table version "+i),1===i?{version:i,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(kc)}:{version:i,scripts:n.parseScriptList(),features:n.parseFeatureList(),lookups:n.parseLookupList(kc),variations:n.parseFeatureVariationsList()}}kc[1]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();return 1===t?{posFormat:1,coverage:this.parsePointer(Tt.coverage),value:this.parseValueRecord()}:2===t?{posFormat:2,coverage:this.parsePointer(Tt.coverage),values:this.parseValueRecordList()}:void Yn.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")},kc[2]=function(){var e=this.offset+this.relativeOffset,t=this.parseUShort();Yn.assert(1===t||2===t,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");var n=this.parsePointer(Tt.coverage),i=this.parseUShort(),r=this.parseUShort();if(1===t)return{posFormat:t,coverage:n,valueFormat1:i,valueFormat2:r,pairSets:this.parseList(Tt.pointer(Tt.list((function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(i),value2:this.parseValueRecord(r)}}))))};if(2===t){var a=this.parsePointer(Tt.classDef),s=this.parsePointer(Tt.classDef),o=this.parseUShort(),l=this.parseUShort();return{posFormat:t,coverage:n,valueFormat1:i,valueFormat2:r,classDef1:a,classDef2:s,class1Count:o,class2Count:l,classRecords:this.parseList(o,Tt.list(l,(function(){return{value1:this.parseValueRecord(i),value2:this.parseValueRecord(r)}})))}}},kc[3]=function(){return{error:"GPOS Lookup 3 not supported"}},kc[4]=function(){return{error:"GPOS Lookup 4 not supported"}},kc[5]=function(){return{error:"GPOS Lookup 5 not supported"}},kc[6]=function(){return{error:"GPOS Lookup 6 not supported"}},kc[7]=function(){return{error:"GPOS Lookup 7 not supported"}},kc[8]=function(){return{error:"GPOS Lookup 8 not supported"}},kc[9]=function(){return{error:"GPOS Lookup 9 not supported"}};var Ogt=new Array(10);function kgt(e){return new fn.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new fn.ScriptList(e.scripts)},{name:"features",type:"TABLE",value:new fn.FeatureList(e.features)},{name:"lookups",type:"TABLE",value:new fn.LookupList(e.lookups,Ogt)}])}var Fgt={parse:Dgt,make:kgt};function Ngt(e){var t={};e.skip("uShort");var n=e.parseUShort();Yn.argument(0===n,"Unsupported kern sub-table version."),e.skip("uShort",2);var i=e.parseUShort();e.skip("uShort",3);for(var r=0;r1&&console.warn("Only the first kern subtable is supported."),e.skip("uLong");var n=255&e.parseUShort();if(e.skip("uShort"),0===n){var i=e.parseUShort();e.skip("uShort",3);for(var r=0;r0;n--){let t=e[n],r={type:t.type};void 0!==t.x2&&void 0!==t.y2?(r.x1=t.x2,r.y1=t.y2,r.x2=t.x1,r.y2=t.y1):void 0!==t.x1&&void 0!==t.y1&&(r.x1=t.x1,r.y1=t.y1),r.x=e[n-1].x,r.y=e[n-1].y,i.push(r)}})),i}return function(e,n){let i=Math.round,r={},a=1e5/(72*(e.unitsPerEm||2048)),s=e.encoding.cmap.glyphIndexMap,o=Object.keys(s);for(let l=0;l0){let t=this.bounds.min,n=this.bounds.getSize(Wgt),i=new be(t.x,t.y),r=new be(t.x+n.width,t.y),a=new be(t.x+n.width,t.y+n.height),s=new be(t.x,t.y+n.height);e.push([i,r],[r,a],[a,s],[s,i])}let t=[],n=[],i=0,r=new Dt;for(let a=0;a>8}}return t.subarray(0,n)}var Xgt="\u554a\u963f\u57c3\u6328\u54ce\u5509\u54c0\u7691\u764c\u853c\u77ee\u827e\u788d\u7231\u9698\u978d\u6c28\u5b89\u4ffa\u6309\u6697\u5cb8\u80fa\u6848\u80ae\u6602\u76ce\u51f9\u6556\u71ac\u7ff1\u8884\u50b2\u5965\u61ca\u6fb3\u82ad\u634c\u6252\u53ed\u5427\u7b06\u516b\u75a4\u5df4\u62d4\u8dcb\u9776\u628a\u8019\u575d\u9738\u7f62\u7238\u767d\u67cf\u767e\u6446\u4f70\u8d25\u62dc\u7a17\u6591\u73ed\u642c\u6273\u822c\u9881\u677f\u7248\u626e\u62cc\u4f34\u74e3\u534a\u529e\u7eca\u90a6\u5e2e\u6886\u699c\u8180\u7ed1\u68d2\u78c5\u868c\u9551\u508d\u8c24\u82de\u80de\u5305\u8912\u5265\u8584\u96f9\u4fdd\u5821\u9971\u5b9d\u62b1\u62a5\u66b4\u8c79\u9c8d\u7206\u676f\u7891\u60b2\u5351\u5317\u8f88\u80cc\u8d1d\u94a1\u500d\u72c8\u5907\u60eb\u7119\u88ab\u5954\u82ef\u672c\u7b28\u5d29\u7ef7\u752d\u6cf5\u8e66\u8ff8\u903c\u9f3b\u6bd4\u9119\u7b14\u5f7c\u78a7\u84d6\u853d\u6bd5\u6bd9\u6bd6\u5e01\u5e87\u75f9\u95ed\u655d\u5f0a\u5fc5\u8f9f\u58c1\u81c2\u907f\u965b\u97ad\u8fb9\u7f16\u8d2c\u6241\u4fbf\u53d8\u535e\u8fa8\u8fa9\u8fab\u904d\u6807\u5f6a\u8198\u8868\u9cd6\u618b\u522b\u762a\u5f6c\u658c\u6fd2\u6ee8\u5bbe\u6448\u5175\u51b0\u67c4\u4e19\u79c9\u997c\u70b3\u75c5\u5e76\u73bb\u83e0\u64ad\u62e8\u94b5\u6ce2\u535a\u52c3\u640f\u94c2\u7b94\u4f2f\u5e1b\u8236\u8116\u818a\u6e24\u6cca\u9a73\u6355\u535c\u54fa\u8865\u57e0\u4e0d\u5e03\u6b65\u7c3f\u90e8\u6016\u64e6\u731c\u88c1\u6750\u624d\u8d22\u776c\u8e29\u91c7\u5f69\u83dc\u8521\u9910\u53c2\u8695\u6b8b\u60ed\u60e8\u707f\u82cd\u8231\u4ed3\u6ca7\u85cf\u64cd\u7cd9\u69fd\u66f9\u8349\u5395\u7b56\u4fa7\u518c\u6d4b\u5c42\u8e6d\u63d2\u53c9\u832c\u8336\u67e5\u78b4\u643d\u5bdf\u5c94\u5dee\u8be7\u62c6\u67f4\u8c7a\u6400\u63ba\u8749\u998b\u8c17\u7f20\u94f2\u4ea7\u9610\u98a4\u660c\u7316\u573a\u5c1d\u5e38\u957f\u507f\u80a0\u5382\u655e\u7545\u5531\u5021\u8d85\u6284\u949e\u671d\u5632\u6f6e\u5de2\u5435\u7092\u8f66\u626f\u64a4\u63a3\u5f7b\u6f88\u90f4\u81e3\u8fb0\u5c18\u6668\u5ff1\u6c89\u9648\u8d81\u886c\u6491\u79f0\u57ce\u6a59\u6210\u5448\u4e58\u7a0b\u60e9\u6f84\u8bda\u627f\u901e\u9a8b\u79e4\u5403\u75f4\u6301\u5319\u6c60\u8fdf\u5f1b\u9a70\u803b\u9f7f\u4f88\u5c3a\u8d64\u7fc5\u65a5\u70bd\u5145\u51b2\u866b\u5d07\u5ba0\u62bd\u916c\u7574\u8e0c\u7a20\u6101\u7b79\u4ec7\u7ef8\u7785\u4e11\u81ed\u521d\u51fa\u6a71\u53a8\u8e87\u9504\u96cf\u6ec1\u9664\u695a\u7840\u50a8\u77d7\u6410\u89e6\u5904\u63e3\u5ddd\u7a7f\u693d\u4f20\u8239\u5598\u4e32\u75ae\u7a97\u5e62\u5e8a\u95ef\u521b\u5439\u708a\u6376\u9524\u5782\u6625\u693f\u9187\u5507\u6df3\u7eaf\u8822\u6233\u7ef0\u75b5\u8328\u78c1\u96cc\u8f9e\u6148\u74f7\u8bcd\u6b64\u523a\u8d50\u6b21\u806a\u8471\u56f1\u5306\u4ece\u4e1b\u51d1\u7c97\u918b\u7c07\u4fc3\u8e7f\u7be1\u7a9c\u6467\u5d14\u50ac\u8106\u7601\u7cb9\u6dec\u7fe0\u6751\u5b58\u5bf8\u78cb\u64ae\u6413\u63aa\u632b\u9519\u642d\u8fbe\u7b54\u7629\u6253\u5927\u5446\u6b79\u50a3\u6234\u5e26\u6b86\u4ee3\u8d37\u888b\u5f85\u902e\u6020\u803d\u62c5\u4e39\u5355\u90f8\u63b8\u80c6\u65e6\u6c2e\u4f46\u60ee\u6de1\u8bde\u5f39\u86cb\u5f53\u6321\u515a\u8361\u6863\u5200\u6363\u8e48\u5012\u5c9b\u7977\u5bfc\u5230\u7a3b\u60bc\u9053\u76d7\u5fb7\u5f97\u7684\u8e6c\u706f\u767b\u7b49\u77aa\u51f3\u9093\u5824\u4f4e\u6ef4\u8fea\u654c\u7b1b\u72c4\u6da4\u7fdf\u5ae1\u62b5\u5e95\u5730\u8482\u7b2c\u5e1d\u5f1f\u9012\u7f14\u98a0\u6382\u6ec7\u7898\u70b9\u5178\u975b\u57ab\u7535\u4f43\u7538\u5e97\u60e6\u5960\u6dc0\u6bbf\u7889\u53fc\u96d5\u51cb\u5201\u6389\u540a\u9493\u8c03\u8dcc\u7239\u789f\u8776\u8fed\u8c0d\u53e0\u4e01\u76ef\u53ee\u9489\u9876\u9f0e\u952d\u5b9a\u8ba2\u4e22\u4e1c\u51ac\u8463\u61c2\u52a8\u680b\u4f97\u606b\u51bb\u6d1e\u515c\u6296\u6597\u9661\u8c46\u9017\u75d8\u90fd\u7763\u6bd2\u728a\u72ec\u8bfb\u5835\u7779\u8d4c\u675c\u9540\u809a\u5ea6\u6e21\u5992\u7aef\u77ed\u953b\u6bb5\u65ad\u7f0e\u5806\u5151\u961f\u5bf9\u58a9\u5428\u8e72\u6566\u987f\u56e4\u949d\u76fe\u9041\u6387\u54c6\u591a\u593a\u579b\u8eb2\u6735\u8dfa\u8235\u5241\u60f0\u5815\u86fe\u5ce8\u9e45\u4fc4\u989d\u8bb9\u5a25\u6076\u5384\u627c\u904f\u9102\u997f\u6069\u800c\u513f\u8033\u5c14\u9975\u6d31\u4e8c\u8d30\u53d1\u7f5a\u7b4f\u4f10\u4e4f\u9600\u6cd5\u73d0\u85e9\u5e06\u756a\u7ffb\u6a0a\u77fe\u9492\u7e41\u51e1\u70e6\u53cd\u8fd4\u8303\u8d29\u72af\u996d\u6cdb\u574a\u82b3\u65b9\u80aa\u623f\u9632\u59a8\u4eff\u8bbf\u7eba\u653e\u83f2\u975e\u5561\u98de\u80a5\u532a\u8bfd\u5420\u80ba\u5e9f\u6cb8\u8d39\u82ac\u915a\u5429\u6c1b\u5206\u7eb7\u575f\u711a\u6c7e\u7c89\u594b\u4efd\u5fff\u6124\u7caa\u4e30\u5c01\u67ab\u8702\u5cf0\u950b\u98ce\u75af\u70fd\u9022\u51af\u7f1d\u8bbd\u5949\u51e4\u4f5b\u5426\u592b\u6577\u80a4\u5b75\u6276\u62c2\u8f90\u5e45\u6c1f\u7b26\u4f0f\u4fd8\u670d\u6d6e\u6daa\u798f\u88b1\u5f17\u752b\u629a\u8f85\u4fef\u91dc\u65a7\u812f\u8151\u5e9c\u8150\u8d74\u526f\u8986\u8d4b\u590d\u5085\u4ed8\u961c\u7236\u8179\u8d1f\u5bcc\u8ba3\u9644\u5987\u7f1a\u5490\u5676\u560e\u8be5\u6539\u6982\u9499\u76d6\u6e89\u5e72\u7518\u6746\u67d1\u7aff\u809d\u8d76\u611f\u79c6\u6562\u8d63\u5188\u521a\u94a2\u7f38\u809b\u7eb2\u5c97\u6e2f\u6760\u7bd9\u768b\u9ad8\u818f\u7f94\u7cd5\u641e\u9550\u7a3f\u544a\u54e5\u6b4c\u6401\u6208\u9e3d\u80f3\u7599\u5272\u9769\u845b\u683c\u86e4\u9601\u9694\u94ec\u4e2a\u5404\u7ed9\u6839\u8ddf\u8015\u66f4\u5e9a\u7fb9\u57c2\u803f\u6897\u5de5\u653b\u529f\u606d\u9f9a\u4f9b\u8eac\u516c\u5bab\u5f13\u5de9\u6c5e\u62f1\u8d21\u5171\u94a9\u52fe\u6c9f\u82df\u72d7\u57a2\u6784\u8d2d\u591f\u8f9c\u83c7\u5495\u7b8d\u4f30\u6cbd\u5b64\u59d1\u9f13\u53e4\u86ca\u9aa8\u8c37\u80a1\u6545\u987e\u56fa\u96c7\u522e\u74dc\u5250\u5be1\u6302\u8902\u4e56\u62d0\u602a\u68fa\u5173\u5b98\u51a0\u89c2\u7ba1\u9986\u7f50\u60ef\u704c\u8d2f\u5149\u5e7f\u901b\u7470\u89c4\u572d\u7845\u5f52\u9f9f\u95fa\u8f68\u9b3c\u8be1\u7678\u6842\u67dc\u8dea\u8d35\u523d\u8f8a\u6eda\u68cd\u9505\u90ed\u56fd\u679c\u88f9\u8fc7\u54c8\u9ab8\u5b69\u6d77\u6c26\u4ea5\u5bb3\u9a87\u9163\u61a8\u90af\u97e9\u542b\u6db5\u5bd2\u51fd\u558a\u7f55\u7ff0\u64bc\u634d\u65f1\u61be\u608d\u710a\u6c57\u6c49\u592f\u676d\u822a\u58d5\u568e\u8c6a\u6beb\u90dd\u597d\u8017\u53f7\u6d69\u5475\u559d\u8377\u83cf\u6838\u79be\u548c\u4f55\u5408\u76d2\u8c89\u9602\u6cb3\u6db8\u8d6b\u8910\u9e64\u8d3a\u563f\u9ed1\u75d5\u5f88\u72e0\u6068\u54fc\u4ea8\u6a2a\u8861\u6052\u8f70\u54c4\u70d8\u8679\u9e3f\u6d2a\u5b8f\u5f18\u7ea2\u5589\u4faf\u7334\u543c\u539a\u5019\u540e\u547c\u4e4e\u5ffd\u745a\u58f6\u846b\u80e1\u8774\u72d0\u7cca\u6e56\u5f27\u864e\u552c\u62a4\u4e92\u6caa\u6237\u82b1\u54d7\u534e\u733e\u6ed1\u753b\u5212\u5316\u8bdd\u69d0\u5f8a\u6000\u6dee\u574f\u6b22\u73af\u6853\u8fd8\u7f13\u6362\u60a3\u5524\u75ea\u8c62\u7115\u6da3\u5ba6\u5e7b\u8352\u614c\u9ec4\u78fa\u8757\u7c27\u7687\u51f0\u60f6\u714c\u6643\u5e4c\u604d\u8c0e\u7070\u6325\u8f89\u5fbd\u6062\u86d4\u56de\u6bc1\u6094\u6167\u5349\u60e0\u6666\u8d3f\u79fd\u4f1a\u70e9\u6c47\u8bb3\u8bf2\u7ed8\u8364\u660f\u5a5a\u9b42\u6d51\u6df7\u8c41\u6d3b\u4f19\u706b\u83b7\u6216\u60d1\u970d\u8d27\u7978\u51fb\u573e\u57fa\u673a\u7578\u7a3d\u79ef\u7b95\u808c\u9965\u8ff9\u6fc0\u8ba5\u9e21\u59ec\u7ee9\u7f09\u5409\u6781\u68d8\u8f91\u7c4d\u96c6\u53ca\u6025\u75be\u6c72\u5373\u5ac9\u7ea7\u6324\u51e0\u810a\u5df1\u84df\u6280\u5180\u5b63\u4f0e\u796d\u5242\u60b8\u6d4e\u5bc4\u5bc2\u8ba1\u8bb0\u65e2\u5fcc\u9645\u7ee7\u7eaa\u5609\u67b7\u5939\u4f73\u5bb6\u52a0\u835a\u988a\u8d3e\u7532\u94be\u5047\u7a3c\u4ef7\u67b6\u9a7e\u5ac1\u6b7c\u76d1\u575a\u5c16\u7b3a\u95f4\u714e\u517c\u80a9\u8270\u5978\u7f04\u8327\u68c0\u67ec\u78b1\u7877\u62e3\u6361\u7b80\u4fed\u526a\u51cf\u8350\u69db\u9274\u8df5\u8d31\u89c1\u952e\u7bad\u4ef6\u5065\u8230\u5251\u996f\u6e10\u6e85\u6da7\u5efa\u50f5\u59dc\u5c06\u6d46\u6c5f\u7586\u848b\u6868\u5956\u8bb2\u5320\u9171\u964d\u8549\u6912\u7901\u7126\u80f6\u4ea4\u90ca\u6d47\u9a84\u5a07\u56bc\u6405\u94f0\u77eb\u4fa5\u811a\u72e1\u89d2\u997a\u7f34\u7ede\u527f\u6559\u9175\u8f7f\u8f83\u53eb\u7a96\u63ed\u63a5\u7686\u79f8\u8857\u9636\u622a\u52ab\u8282\u830e\u775b\u6676\u9cb8\u4eac\u60ca\u7cbe\u7cb3\u7ecf\u4e95\u8b66\u666f\u9888\u9759\u5883\u656c\u955c\u5f84\u75c9\u9756\u7adf\u7ade\u51c0\u70af\u7a98\u63ea\u7a76\u7ea0\u7396\u97ed\u4e45\u7078\u4e5d\u9152\u53a9\u6551\u65e7\u81fc\u8205\u548e\u5c31\u759a\u97a0\u62d8\u72d9\u75bd\u5c45\u9a79\u83ca\u5c40\u5480\u77e9\u4e3e\u6cae\u805a\u62d2\u636e\u5de8\u5177\u8ddd\u8e1e\u952f\u4ff1\u53e5\u60e7\u70ac\u5267\u6350\u9e43\u5a1f\u5026\u7737\u5377\u7ee2\u6485\u652b\u6289\u6398\u5014\u7235\u6854\u6770\u6377\u776b\u7aed\u6d01\u7ed3\u89e3\u59d0\u6212\u85c9\u82a5\u754c\u501f\u4ecb\u75a5\u8beb\u5c4a\u5dfe\u7b4b\u65a4\u91d1\u4eca\u6d25\u895f\u7d27\u9526\u4ec5\u8c28\u8fdb\u9773\u664b\u7981\u8fd1\u70ec\u6d78\u5c3d\u52b2\u8346\u5162\u89c9\u51b3\u8bc0\u7edd\u5747\u83cc\u94a7\u519b\u541b\u5cfb\u4fca\u7ae3\u6d5a\u90e1\u9a8f\u5580\u5496\u5361\u54af\u5f00\u63e9\u6977\u51ef\u6168\u520a\u582a\u52d8\u574e\u780d\u770b\u5eb7\u6177\u7ce0\u625b\u6297\u4ea2\u7095\u8003\u62f7\u70e4\u9760\u5777\u82db\u67ef\u68f5\u78d5\u9897\u79d1\u58f3\u54b3\u53ef\u6e34\u514b\u523b\u5ba2\u8bfe\u80af\u5543\u57a6\u6073\u5751\u542d\u7a7a\u6050\u5b54\u63a7\u62a0\u53e3\u6263\u5bc7\u67af\u54ed\u7a9f\u82e6\u9177\u5e93\u88e4\u5938\u57ae\u630e\u8de8\u80ef\u5757\u7b77\u4fa9\u5feb\u5bbd\u6b3e\u5321\u7b50\u72c2\u6846\u77ff\u7736\u65f7\u51b5\u4e8f\u76d4\u5cbf\u7aa5\u8475\u594e\u9b41\u5080\u9988\u6127\u6e83\u5764\u6606\u6346\u56f0\u62ec\u6269\u5ed3\u9614\u5783\u62c9\u5587\u8721\u814a\u8fa3\u5566\u83b1\u6765\u8d56\u84dd\u5a6a\u680f\u62e6\u7bee\u9611\u5170\u6f9c\u8c30\u63fd\u89c8\u61d2\u7f06\u70c2\u6ee5\u7405\u6994\u72fc\u5eca\u90ce\u6717\u6d6a\u635e\u52b3\u7262\u8001\u4f6c\u59e5\u916a\u70d9\u6d9d\u52d2\u4e50\u96f7\u956d\u857e\u78ca\u7d2f\u5121\u5792\u64c2\u808b\u7c7b\u6cea\u68f1\u695e\u51b7\u5398\u68a8\u7281\u9ece\u7bf1\u72f8\u79bb\u6f13\u7406\u674e\u91cc\u9ca4\u793c\u8389\u8354\u540f\u6817\u4e3d\u5389\u52b1\u783e\u5386\u5229\u5088\u4f8b\u4fd0\u75e2\u7acb\u7c92\u6ca5\u96b6\u529b\u7483\u54e9\u4fe9\u8054\u83b2\u8fde\u9570\u5ec9\u601c\u6d9f\u5e18\u655b\u8138\u94fe\u604b\u70bc\u7ec3\u7cae\u51c9\u6881\u7cb1\u826f\u4e24\u8f86\u91cf\u667e\u4eae\u8c05\u64a9\u804a\u50da\u7597\u71ce\u5be5\u8fbd\u6f66\u4e86\u6482\u9563\u5ed6\u6599\u5217\u88c2\u70c8\u52a3\u730e\u7433\u6797\u78f7\u9716\u4e34\u90bb\u9cde\u6dcb\u51db\u8d41\u541d\u62ce\u73b2\u83f1\u96f6\u9f84\u94c3\u4f36\u7f9a\u51cc\u7075\u9675\u5cad\u9886\u53e6\u4ee4\u6e9c\u7409\u69b4\u786b\u998f\u7559\u5218\u7624\u6d41\u67f3\u516d\u9f99\u804b\u5499\u7b3c\u7abf\u9686\u5784\u62e2\u9647\u697c\u5a04\u6402\u7bd3\u6f0f\u964b\u82a6\u5362\u9885\u5e90\u7089\u63b3\u5364\u864f\u9c81\u9e93\u788c\u9732\u8def\u8d42\u9e7f\u6f5e\u7984\u5f55\u9646\u622e\u9a74\u5415\u94dd\u4fa3\u65c5\u5c65\u5c61\u7f15\u8651\u6c2f\u5f8b\u7387\u6ee4\u7eff\u5ce6\u631b\u5b6a\u6ee6\u5375\u4e71\u63a0\u7565\u62a1\u8f6e\u4f26\u4ed1\u6ca6\u7eb6\u8bba\u841d\u87ba\u7f57\u903b\u9523\u7ba9\u9aa1\u88f8\u843d\u6d1b\u9a86\u7edc\u5988\u9ebb\u739b\u7801\u8682\u9a6c\u9a82\u561b\u5417\u57cb\u4e70\u9ea6\u5356\u8fc8\u8109\u7792\u9992\u86ee\u6ee1\u8513\u66fc\u6162\u6f2b\u8c29\u8292\u832b\u76f2\u6c13\u5fd9\u83bd\u732b\u8305\u951a\u6bdb\u77db\u94c6\u536f\u8302\u5192\u5e3d\u8c8c\u8d38\u4e48\u73ab\u679a\u6885\u9176\u9709\u7164\u6ca1\u7709\u5a92\u9541\u6bcf\u7f8e\u6627\u5bd0\u59b9\u5a9a\u95e8\u95f7\u4eec\u840c\u8499\u6aac\u76df\u9530\u731b\u68a6\u5b5f\u772f\u919a\u9761\u7cdc\u8ff7\u8c1c\u5f25\u7c73\u79d8\u89c5\u6ccc\u871c\u5bc6\u5e42\u68c9\u7720\u7ef5\u5195\u514d\u52c9\u5a29\u7f05\u9762\u82d7\u63cf\u7784\u85d0\u79d2\u6e3a\u5e99\u5999\u8511\u706d\u6c11\u62bf\u76bf\u654f\u60af\u95fd\u660e\u879f\u9e23\u94ed\u540d\u547d\u8c2c\u6478\u6479\u8611\u6a21\u819c\u78e8\u6469\u9b54\u62b9\u672b\u83ab\u58a8\u9ed8\u6cab\u6f20\u5bde\u964c\u8c0b\u725f\u67d0\u62c7\u7261\u4ea9\u59c6\u6bcd\u5893\u66ae\u5e55\u52df\u6155\u6728\u76ee\u7766\u7267\u7a46\u62ff\u54ea\u5450\u94a0\u90a3\u5a1c\u7eb3\u6c16\u4e43\u5976\u8010\u5948\u5357\u7537\u96be\u56ca\u6320\u8111\u607c\u95f9\u6dd6\u5462\u9981\u5185\u5ae9\u80fd\u59ae\u9713\u502a\u6ce5\u5c3c\u62df\u4f60\u533f\u817b\u9006\u6eba\u852b\u62c8\u5e74\u78be\u64b5\u637b\u5ff5\u5a18\u917f\u9e1f\u5c3f\u634f\u8042\u5b7d\u556e\u954a\u954d\u6d85\u60a8\u67e0\u72de\u51dd\u5b81\u62e7\u6cde\u725b\u626d\u94ae\u7ebd\u8113\u6d53\u519c\u5f04\u5974\u52aa\u6012\u5973\u6696\u8650\u759f\u632a\u61e6\u7cef\u8bfa\u54e6\u6b27\u9e25\u6bb4\u85d5\u5455\u5076\u6ca4\u556a\u8db4\u722c\u5e15\u6015\u7436\u62cd\u6392\u724c\u5f98\u6e43\u6d3e\u6500\u6f58\u76d8\u78d0\u76fc\u7554\u5224\u53db\u4e53\u5e9e\u65c1\u802a\u80d6\u629b\u5486\u5228\u70ae\u888d\u8dd1\u6ce1\u5478\u80da\u57f9\u88f4\u8d54\u966a\u914d\u4f69\u6c9b\u55b7\u76c6\u7830\u62a8\u70f9\u6f8e\u5f6d\u84ec\u68da\u787c\u7bf7\u81a8\u670b\u9e4f\u6367\u78b0\u576f\u7812\u9739\u6279\u62ab\u5288\u7435\u6bd7\u5564\u813e\u75b2\u76ae\u5339\u75de\u50fb\u5c41\u8b6c\u7bc7\u504f\u7247\u9a97\u98d8\u6f02\u74e2\u7968\u6487\u77a5\u62fc\u9891\u8d2b\u54c1\u8058\u4e52\u576a\u82f9\u840d\u5e73\u51ed\u74f6\u8bc4\u5c4f\u5761\u6cfc\u9887\u5a46\u7834\u9b44\u8feb\u7c95\u5256\u6251\u94fa\u4ec6\u8386\u8461\u83e9\u84b2\u57d4\u6734\u5703\u666e\u6d66\u8c31\u66dd\u7011\u671f\u6b3a\u6816\u621a\u59bb\u4e03\u51c4\u6f06\u67d2\u6c8f\u5176\u68cb\u5947\u6b67\u7566\u5d0e\u8110\u9f50\u65d7\u7948\u7941\u9a91\u8d77\u5c82\u4e5e\u4f01\u542f\u5951\u780c\u5668\u6c14\u8fc4\u5f03\u6c7d\u6ce3\u8bab\u6390\u6d3d\u7275\u6266\u948e\u94c5\u5343\u8fc1\u7b7e\u4edf\u8c26\u4e7e\u9ed4\u94b1\u94b3\u524d\u6f5c\u9063\u6d45\u8c34\u5811\u5d4c\u6b20\u6b49\u67aa\u545b\u8154\u7f8c\u5899\u8537\u5f3a\u62a2\u6a47\u9539\u6572\u6084\u6865\u77a7\u4e54\u4fa8\u5de7\u9798\u64ac\u7fd8\u5ced\u4fcf\u7a8d\u5207\u8304\u4e14\u602f\u7a83\u94a6\u4fb5\u4eb2\u79e6\u7434\u52e4\u82b9\u64d2\u79bd\u5bdd\u6c81\u9752\u8f7b\u6c22\u503e\u537f\u6e05\u64ce\u6674\u6c30\u60c5\u9877\u8bf7\u5e86\u743c\u7a77\u79cb\u4e18\u90b1\u7403\u6c42\u56da\u914b\u6cc5\u8d8b\u533a\u86c6\u66f2\u8eaf\u5c48\u9a71\u6e20\u53d6\u5a36\u9f8b\u8da3\u53bb\u5708\u98a7\u6743\u919b\u6cc9\u5168\u75ca\u62f3\u72ac\u5238\u529d\u7f3a\u7094\u7638\u5374\u9e4a\u69b7\u786e\u96c0\u88d9\u7fa4\u7136\u71c3\u5189\u67d3\u74e4\u58e4\u6518\u56b7\u8ba9\u9976\u6270\u7ed5\u60f9\u70ed\u58ec\u4ec1\u4eba\u5fcd\u97e7\u4efb\u8ba4\u5203\u598a\u7eab\u6254\u4ecd\u65e5\u620e\u8338\u84c9\u8363\u878d\u7194\u6eb6\u5bb9\u7ed2\u5197\u63c9\u67d4\u8089\u8339\u8815\u5112\u5b7a\u5982\u8fb1\u4e73\u6c5d\u5165\u8925\u8f6f\u962e\u854a\u745e\u9510\u95f0\u6da6\u82e5\u5f31\u6492\u6d12\u8428\u816e\u9cc3\u585e\u8d5b\u4e09\u53c1\u4f1e\u6563\u6851\u55d3\u4e27\u6414\u9a9a\u626b\u5ac2\u745f\u8272\u6da9\u68ee\u50e7\u838e\u7802\u6740\u5239\u6c99\u7eb1\u50bb\u5565\u715e\u7b5b\u6652\u73ca\u82eb\u6749\u5c71\u5220\u717d\u886b\u95ea\u9655\u64c5\u8d61\u81b3\u5584\u6c55\u6247\u7f2e\u5892\u4f24\u5546\u8d4f\u664c\u4e0a\u5c1a\u88f3\u68a2\u634e\u7a0d\u70e7\u828d\u52fa\u97f6\u5c11\u54e8\u90b5\u7ecd\u5962\u8d4a\u86c7\u820c\u820d\u8d66\u6444\u5c04\u6151\u6d89\u793e\u8bbe\u7837\u7533\u547b\u4f38\u8eab\u6df1\u5a20\u7ec5\u795e\u6c88\u5ba1\u5a76\u751a\u80be\u614e\u6e17\u58f0\u751f\u7525\u7272\u5347\u7ef3\u7701\u76db\u5269\u80dc\u5723\u5e08\u5931\u72ee\u65bd\u6e7f\u8bd7\u5c38\u8671\u5341\u77f3\u62fe\u65f6\u4ec0\u98df\u8680\u5b9e\u8bc6\u53f2\u77e2\u4f7f\u5c4e\u9a76\u59cb\u5f0f\u793a\u58eb\u4e16\u67ff\u4e8b\u62ed\u8a93\u901d\u52bf\u662f\u55dc\u566c\u9002\u4ed5\u4f8d\u91ca\u9970\u6c0f\u5e02\u6043\u5ba4\u89c6\u8bd5\u6536\u624b\u9996\u5b88\u5bff\u6388\u552e\u53d7\u7626\u517d\u852c\u67a2\u68b3\u6b8a\u6292\u8f93\u53d4\u8212\u6dd1\u758f\u4e66\u8d4e\u5b70\u719f\u85af\u6691\u66d9\u7f72\u8700\u9ecd\u9f20\u5c5e\u672f\u8ff0\u6811\u675f\u620d\u7ad6\u5885\u5eb6\u6570\u6f31\u6055\u5237\u800d\u6454\u8870\u7529\u5e05\u6813\u62f4\u971c\u53cc\u723d\u8c01\u6c34\u7761\u7a0e\u542e\u77ac\u987a\u821c\u8bf4\u7855\u6714\u70c1\u65af\u6495\u5636\u601d\u79c1\u53f8\u4e1d\u6b7b\u8086\u5bfa\u55e3\u56db\u4f3a\u4f3c\u9972\u5df3\u677e\u8038\u6002\u9882\u9001\u5b8b\u8bbc\u8bf5\u641c\u8258\u64de\u55fd\u82cf\u9165\u4fd7\u7d20\u901f\u7c9f\u50f3\u5851\u6eaf\u5bbf\u8bc9\u8083\u9178\u849c\u7b97\u867d\u968b\u968f\u7ee5\u9ad3\u788e\u5c81\u7a57\u9042\u96a7\u795f\u5b59\u635f\u7b0b\u84d1\u68ad\u5506\u7f29\u7410\u7d22\u9501\u6240\u584c\u4ed6\u5b83\u5979\u5854\u736d\u631e\u8e4b\u8e0f\u80ce\u82d4\u62ac\u53f0\u6cf0\u915e\u592a\u6001\u6c70\u574d\u644a\u8d2a\u762b\u6ee9\u575b\u6a80\u75f0\u6f6d\u8c2d\u8c08\u5766\u6bef\u8892\u78b3\u63a2\u53f9\u70ad\u6c64\u5858\u642a\u5802\u68e0\u819b\u5510\u7cd6\u5018\u8eba\u6dcc\u8d9f\u70eb\u638f\u6d9b\u6ed4\u7ee6\u8404\u6843\u9003\u6dd8\u9676\u8ba8\u5957\u7279\u85e4\u817e\u75bc\u8a8a\u68af\u5254\u8e22\u9511\u63d0\u9898\u8e44\u557c\u4f53\u66ff\u568f\u60d5\u6d95\u5243\u5c49\u5929\u6dfb\u586b\u7530\u751c\u606c\u8214\u8146\u6311\u6761\u8fe2\u773a\u8df3\u8d34\u94c1\u5e16\u5385\u542c\u70c3\u6c40\u5ef7\u505c\u4ead\u5ead\u633a\u8247\u901a\u6850\u916e\u77b3\u540c\u94dc\u5f64\u7ae5\u6876\u6345\u7b52\u7edf\u75db\u5077\u6295\u5934\u900f\u51f8\u79c3\u7a81\u56fe\u5f92\u9014\u6d82\u5c60\u571f\u5410\u5154\u6e4d\u56e2\u63a8\u9893\u817f\u8715\u892a\u9000\u541e\u5c6f\u81c0\u62d6\u6258\u8131\u9e35\u9640\u9a6e\u9a7c\u692d\u59a5\u62d3\u553e\u6316\u54c7\u86d9\u6d3c\u5a03\u74e6\u889c\u6b6a\u5916\u8c4c\u5f2f\u6e7e\u73a9\u987d\u4e38\u70f7\u5b8c\u7897\u633d\u665a\u7696\u60cb\u5b9b\u5a49\u4e07\u8155\u6c6a\u738b\u4ea1\u6789\u7f51\u5f80\u65fa\u671b\u5fd8\u5984\u5a01\u5dcd\u5fae\u5371\u97e6\u8fdd\u6845\u56f4\u552f\u60df\u4e3a\u6f4d\u7ef4\u82c7\u840e\u59d4\u4f1f\u4f2a\u5c3e\u7eac\u672a\u851a\u5473\u754f\u80c3\u5582\u9b4f\u4f4d\u6e2d\u8c13\u5c09\u6170\u536b\u761f\u6e29\u868a\u6587\u95fb\u7eb9\u543b\u7a33\u7d0a\u95ee\u55e1\u7fc1\u74ee\u631d\u8717\u6da1\u7a9d\u6211\u65a1\u5367\u63e1\u6c83\u5deb\u545c\u94a8\u4e4c\u6c61\u8bec\u5c4b\u65e0\u829c\u68a7\u543e\u5434\u6bcb\u6b66\u4e94\u6342\u5348\u821e\u4f0d\u4fae\u575e\u620a\u96fe\u6664\u7269\u52ff\u52a1\u609f\u8bef\u6614\u7199\u6790\u897f\u7852\u77fd\u6670\u563b\u5438\u9521\u727a\u7a00\u606f\u5e0c\u6089\u819d\u5915\u60dc\u7184\u70ef\u6eaa\u6c50\u7280\u6a84\u88ad\u5e2d\u4e60\u5ab3\u559c\u94e3\u6d17\u7cfb\u9699\u620f\u7ec6\u778e\u867e\u5323\u971e\u8f96\u6687\u5ce1\u4fa0\u72ed\u4e0b\u53a6\u590f\u5413\u6380\u9528\u5148\u4ed9\u9c9c\u7ea4\u54b8\u8d24\u8854\u8237\u95f2\u6d8e\u5f26\u5acc\u663e\u9669\u73b0\u732e\u53bf\u817a\u9985\u7fa1\u5baa\u9677\u9650\u7ebf\u76f8\u53a2\u9576\u9999\u7bb1\u8944\u6e58\u4e61\u7fd4\u7965\u8be6\u60f3\u54cd\u4eab\u9879\u5df7\u6a61\u50cf\u5411\u8c61\u8427\u785d\u9704\u524a\u54ee\u56a3\u9500\u6d88\u5bb5\u6dc6\u6653\u5c0f\u5b5d\u6821\u8096\u5578\u7b11\u6548\u6954\u4e9b\u6b47\u874e\u978b\u534f\u631f\u643a\u90aa\u659c\u80c1\u8c10\u5199\u68b0\u5378\u87f9\u61c8\u6cc4\u6cfb\u8c22\u5c51\u85aa\u82af\u950c\u6b23\u8f9b\u65b0\u5ffb\u5fc3\u4fe1\u8845\u661f\u8165\u7329\u60fa\u5174\u5211\u578b\u5f62\u90a2\u884c\u9192\u5e78\u674f\u6027\u59d3\u5144\u51f6\u80f8\u5308\u6c79\u96c4\u718a\u4f11\u4fee\u7f9e\u673d\u55c5\u9508\u79c0\u8896\u7ee3\u589f\u620c\u9700\u865a\u5618\u987b\u5f90\u8bb8\u84c4\u9157\u53d9\u65ed\u5e8f\u755c\u6064\u7d6e\u5a7f\u7eea\u7eed\u8f69\u55a7\u5ba3\u60ac\u65cb\u7384\u9009\u7663\u7729\u7eda\u9774\u859b\u5b66\u7a74\u96ea\u8840\u52cb\u718f\u5faa\u65ec\u8be2\u5bfb\u9a6f\u5de1\u6b89\u6c5b\u8bad\u8baf\u900a\u8fc5\u538b\u62bc\u9e26\u9e2d\u5440\u4e2b\u82bd\u7259\u869c\u5d16\u8859\u6daf\u96c5\u54d1\u4e9a\u8bb6\u7109\u54bd\u9609\u70df\u6df9\u76d0\u4e25\u7814\u8712\u5ca9\u5ef6\u8a00\u989c\u960e\u708e\u6cbf\u5944\u63a9\u773c\u884d\u6f14\u8273\u5830\u71d5\u538c\u781a\u96c1\u5501\u5f66\u7130\u5bb4\u8c1a\u9a8c\u6b83\u592e\u9e2f\u79e7\u6768\u626c\u4f6f\u75a1\u7f8a\u6d0b\u9633\u6c27\u4ef0\u75d2\u517b\u6837\u6f3e\u9080\u8170\u5996\u7476\u6447\u5c27\u9065\u7a91\u8c23\u59da\u54ac\u8200\u836f\u8981\u8000\u6930\u564e\u8036\u7237\u91ce\u51b6\u4e5f\u9875\u6396\u4e1a\u53f6\u66f3\u814b\u591c\u6db2\u4e00\u58f9\u533b\u63d6\u94f1\u4f9d\u4f0a\u8863\u9890\u5937\u9057\u79fb\u4eea\u80f0\u7591\u6c82\u5b9c\u59e8\u5f5d\u6905\u8681\u501a\u5df2\u4e59\u77e3\u4ee5\u827a\u6291\u6613\u9091\u5c79\u4ebf\u5f79\u81c6\u9038\u8084\u75ab\u4ea6\u88d4\u610f\u6bc5\u5fc6\u4e49\u76ca\u6ea2\u8be3\u8bae\u8c0a\u8bd1\u5f02\u7ffc\u7fcc\u7ece\u8335\u836b\u56e0\u6bb7\u97f3\u9634\u59fb\u541f\u94f6\u6deb\u5bc5\u996e\u5c39\u5f15\u9690\u5370\u82f1\u6a31\u5a74\u9e70\u5e94\u7f28\u83b9\u8424\u8425\u8367\u8747\u8fce\u8d62\u76c8\u5f71\u9896\u786c\u6620\u54df\u62e5\u4f63\u81c3\u75c8\u5eb8\u96cd\u8e0a\u86f9\u548f\u6cf3\u6d8c\u6c38\u607f\u52c7\u7528\u5e7d\u4f18\u60a0\u5fe7\u5c24\u7531\u90ae\u94c0\u72b9\u6cb9\u6e38\u9149\u6709\u53cb\u53f3\u4f51\u91c9\u8bf1\u53c8\u5e7c\u8fc2\u6de4\u4e8e\u76c2\u6986\u865e\u611a\u8206\u4f59\u4fde\u903e\u9c7c\u6109\u6e1d\u6e14\u9685\u4e88\u5a31\u96e8\u4e0e\u5c7f\u79b9\u5b87\u8bed\u7fbd\u7389\u57df\u828b\u90c1\u5401\u9047\u55bb\u5cea\u5fa1\u6108\u6b32\u72f1\u80b2\u8a89\u6d74\u5bd3\u88d5\u9884\u8c6b\u9a6d\u9e33\u6e0a\u51a4\u5143\u57a3\u8881\u539f\u63f4\u8f95\u56ed\u5458\u5706\u733f\u6e90\u7f18\u8fdc\u82d1\u613f\u6028\u9662\u66f0\u7ea6\u8d8a\u8dc3\u94a5\u5cb3\u7ca4\u6708\u60a6\u9605\u8018\u4e91\u90e7\u5300\u9668\u5141\u8fd0\u8574\u915d\u6655\u97f5\u5b55\u531d\u7838\u6742\u683d\u54c9\u707e\u5bb0\u8f7d\u518d\u5728\u54b1\u6512\u6682\u8d5e\u8d43\u810f\u846c\u906d\u7cdf\u51ff\u85fb\u67a3\u65e9\u6fa1\u86a4\u8e81\u566a\u9020\u7682\u7076\u71e5\u8d23\u62e9\u5219\u6cfd\u8d3c\u600e\u589e\u618e\u66fe\u8d60\u624e\u55b3\u6e23\u672d\u8f67\u94e1\u95f8\u7728\u6805\u69a8\u548b\u4e4d\u70b8\u8bc8\u6458\u658b\u5b85\u7a84\u503a\u5be8\u77bb\u6be1\u8a79\u7c98\u6cbe\u76cf\u65a9\u8f97\u5d2d\u5c55\u8638\u6808\u5360\u6218\u7ad9\u6e5b\u7efd\u6a1f\u7ae0\u5f70\u6f33\u5f20\u638c\u6da8\u6756\u4e08\u5e10\u8d26\u4ed7\u80c0\u7634\u969c\u62db\u662d\u627e\u6cbc\u8d75\u7167\u7f69\u5146\u8087\u53ec\u906e\u6298\u54f2\u86f0\u8f99\u8005\u9517\u8517\u8fd9\u6d59\u73cd\u659f\u771f\u7504\u7827\u81fb\u8d1e\u9488\u4fa6\u6795\u75b9\u8bca\u9707\u632f\u9547\u9635\u84b8\u6323\u7741\u5f81\u72f0\u4e89\u6014\u6574\u62ef\u6b63\u653f\u5e27\u75c7\u90d1\u8bc1\u829d\u679d\u652f\u5431\u8718\u77e5\u80a2\u8102\u6c41\u4e4b\u7ec7\u804c\u76f4\u690d\u6b96\u6267\u503c\u4f84\u5740\u6307\u6b62\u8dbe\u53ea\u65e8\u7eb8\u5fd7\u631a\u63b7\u81f3\u81f4\u7f6e\u5e1c\u5cd9\u5236\u667a\u79e9\u7a1a\u8d28\u7099\u75d4\u6ede\u6cbb\u7a92\u4e2d\u76c5\u5fe0\u949f\u8877\u7ec8\u79cd\u80bf\u91cd\u4ef2\u4f17\u821f\u5468\u5dde\u6d32\u8bcc\u7ca5\u8f74\u8098\u5e1a\u5492\u76b1\u5b99\u663c\u9aa4\u73e0\u682a\u86db\u6731\u732a\u8bf8\u8bdb\u9010\u7af9\u70db\u716e\u62c4\u77a9\u5631\u4e3b\u8457\u67f1\u52a9\u86c0\u8d2e\u94f8\u7b51\u4f4f\u6ce8\u795d\u9a7b\u6293\u722a\u62fd\u4e13\u7816\u8f6c\u64b0\u8d5a\u7bc6\u6869\u5e84\u88c5\u5986\u649e\u58ee\u72b6\u690e\u9525\u8ffd\u8d58\u5760\u7f00\u8c06\u51c6\u6349\u62d9\u5353\u684c\u7422\u8301\u914c\u5544\u7740\u707c\u6d4a\u5179\u54a8\u8d44\u59ff\u6ecb\u6dc4\u5b5c\u7d2b\u4ed4\u7c7d\u6ed3\u5b50\u81ea\u6e0d\u5b57\u9b03\u68d5\u8e2a\u5b97\u7efc\u603b\u7eb5\u90b9\u8d70\u594f\u63cd\u79df\u8db3\u5352\u65cf\u7956\u8bc5\u963b\u7ec4\u94bb\u7e82\u5634\u9189\u6700\u7f6a\u5c0a\u9075\u6628\u5de6\u4f50\u67de\u505a\u4f5c\u5750\u5ea7\u9515\u55f3\u5ad2\u7477\u66a7\u972d\u8c19\u94f5\u9e4c\u5aaa\u9a9c\u9ccc\u94af\u5457\u94a3\u9e28\u9f85\u9e4e\u8d32\u951b\u835c\u54d4\u6ed7\u94cb\u7b5a\u8df8\u82c4\u7f0f\u7b3e\u9aa0\u98d1\u98d9\u9556\u9573\u9cd4\u50a7\u7f24\u69df\u6ba1\u8191\u9554\u9acc\u9b13\u7980\u997d\u94b9\u9e41\u94b8\u9a96\u9eea\u607b\u9538\u4faa\u9497\u5181\u8c04\u8c36\u8487\u5fcf\u5a75\u9aa3\u89c7\u7985\u9561\u4f25\u82cc\u6005\u960a\u9cb3\u7817\u4f27\u8c0c\u6987\u789c\u9f80\u67a8\u67fd\u94d6\u94db\u996c\u9e31\u94f3\u4fe6\u5e31\u96e0\u520d\u7ecc\u8e70\u948f\u6006\u7f0d\u9e51\u8f8d\u9f8a\u9e5a\u82c1\u9aa2\u679e\u8f8f\u64ba\u9509\u9e7e\u54d2\u9791\u9a80\u7ed0\u6b9a\u8d55\u7605\u7baa\u8c20\u7800\u88c6\u7118\u956b\u7c74\u8bcb\u8c1b\u7ee8\u89cc\u955d\u5dc5\u94bf\u766b\u94eb\u9cb7\u9cbd\u94e4\u94e5\u5cbd\u9e2b\u7aa6\u6e0e\u691f\u724d\u7b03\u9ee9\u7c16\u603c\u9566\u7096\u8db8\u94ce\u8c14\u57a9\u960f\u8f6d\u9507\u9537\u9e57\u989a\u989b\u9cc4\u8bf6\u8fe9\u94d2\u9e38\u9c95\u94ab\u9c82\u7eef\u9544\u9cb1\u507e\u6ca3\u51eb\u9a78\u7ec2\u7ecb\u8d59\u9eb8\u9c8b\u9cc6\u9486\u8d45\u5c34\u64c0\u7ec0\u6206\u777e\u8bf0\u7f1f\u9506\u7ea5\u9549\u988d\u4e98\u8d53\u7ee0\u9ca0\u8bdf\u7f11\u89cf\u8bc2\u6bc2\u94b4\u9522\u9e2a\u9e44\u9e58\u9e39\u63b4\u8bd6\u63bc\u9e73\u9ccf\u72b7\u5326\u523f\u59ab\u6867\u9c91\u9cdc\u886e\u7ef2\u9ca7\u57da\u5459\u5e3c\u6901\u8748\u94ea\u961a\u7ed7\u9889\u704f\u98a2\u8bc3\u9616\u86ce\u9ec9\u8ba7\u836d\u95f3\u9c8e\u6d52\u9e55\u9a85\u6866\u94e7\u5942\u7f33\u953e\u9ca9\u9cc7\u8bd9\u835f\u54d5\u6d4d\u7f0b\u73f2\u6656\u8be8\u9984\u960d\u94ac\u956c\u8ba6\u8bd8\u8360\u53fd\u54dc\u9aa5\u7391\u89ca\u9f51\u77f6\u7f81\u867f\u8dfb\u9701\u9c9a\u9cab\u90cf\u6d43\u94d7\u9553\u86f2\u8c0f\u7f23\u620b\u622c\u7751\u9e63\u7b15\u9ca3\u97af\u7edb\u7f30\u6322\u5ce4\u9e6a\u9c9b\u7596\u988c\u9c92\u537a\u8369\u9991\u7f19\u8d46\u89d0\u522d\u6cfe\u8ff3\u5f2a\u80eb\u9753\u9604\u9e20\u9e6b\u8bb5\u5c66\u6989\u98d3\u949c\u9514\u7aad\u9f83\u9529\u954c\u96bd\u8c32\u73cf\u76b2\u5240\u57b2\u5ffe\u607a\u94e0\u9534\u9f9b\u95f6\u94aa\u94d0\u9a92\u7f02\u8f72\u94b6\u951e\u9894\u9f88\u94ff\u55be\u90d0\u54d9\u810d\u72ef\u9acb\u8bd3\u8bf3\u909d\u5739\u7ea9\u8d36\u532e\u8489\u6126\u8069\u7bd1\u9603\u951f\u9cb2\u86f4\u5d03\u5f95\u6d9e\u6fd1\u8d49\u7750\u94fc\u765e\u7c41\u5c9a\u6984\u6593\u9567\u8934\u9606\u9512\u5520\u5d02\u94d1\u94f9\u75e8\u9cd3\u8bd4\u7f27\u4fea\u90e6\u575c\u82c8\u8385\u84e0\u5456\u9026\u9a8a\u7f21\u67a5\u680e\u8f79\u783a\u9502\u9e42\u75a0\u7c9d\u8dde\u96f3\u9ca1\u9ce2\u8539\u5941\u6f4b\u740f\u6b93\u88e2\u88e3\u9ca2\u9b49\u7f2d\u948c\u9e69\u853a\u5eea\u6aa9\u8f9a\u8e8f\u7eeb\u68c2\u86cf\u9cae\u6d4f\u9a9d\u7efa\u954f\u9e68\u830f\u6cf7\u73d1\u680a\u80e7\u783b\u507b\u848c\u55bd\u5d5d\u9542\u7618\u8027\u877c\u9ac5\u5786\u64b8\u565c\u95fe\u6cf8\u6e0c\u680c\u6a79\u8f73\u8f82\u8f98\u6c07\u80ea\u9e2c\u9e6d\u823b\u9c88\u8114\u5a08\u683e\u9e3e\u92ae\u56f5\u8366\u7321\u6cfa\u6924\u8136\u9559\u6988\u891b\u950a\u5452\u551b\u5b37\u6769\u52a2\u7f26\u9558\u98a1\u9cd7\u9ebd\u626a\u7116\u61d1\u9494\u8288\u8c27\u7315\u7962\u6e11\u817c\u9efe\u7f08\u7f2a\u95f5\u7f17\u8c1f\u84e6\u998d\u6b81\u9546\u94bc\u94d9\u8bb7\u94cc\u9cb5\u8f87\u9cb6\u8311\u8885\u9667\u8616\u55eb\u989f\u8e51\u82ce\u549b\u804d\u4fac\u54dd\u9a7d\u9495\u50a9\u8bb4\u6004\u74ef\u8e52\u75b1\u8f94\u7eb0\u7f74\u94cd\u8c1d\u9a88\u7f25\u5ad4\u948b\u9564\u9568\u8572\u9a90\u7eee\u6864\u789b\u9880\u9883\u9ccd\u4f65\u8368\u60ad\u9a9e\u7f31\u6920\u94a4\u5af1\u6a2f\u6217\u709d\u9516\u9535\u956a\u7f9f\u8dc4\u8bee\u8c2f\u835e\u7f32\u7857\u8df7\u60ec\u9532\u7ba7\u9513\u63ff\u9cad\u8315\u86f1\u5def\u8d47\u866e\u9cc5\u8bce\u5c96\u9612\u89d1\u9e32\u8be0\u7efb\u8f81\u94e8\u9615\u9619\u60ab\u835b\u5a06\u6861\u996a\u8f6b\u5d58\u877e\u7f1b\u94f7\u98a6\u86ac\u98d2\u6bf5\u7cc1\u7f2b\u556c\u94ef\u7a51\u94e9\u9ca8\u917e\u8baa\u59d7\u9a9f\u9490\u9cdd\u57a7\u6b87\u89de\u538d\u6ee0\u7572\u8bdc\u8c02\u6e16\u8c25\u57d8\u83b3\u5f11\u8f7c\u8d33\u94c8\u9ca5\u7ef6\u6445\u7ebe\u95e9\u94c4\u53ae\u9a77\u7f0c\u9536\u9e36\u85ae\u998a\u98d5\u953c\u8c21\u7a23\u8c07\u836a\u72f2\u5522\u7743\u95fc\u94ca\u9cce\u949b\u9c90\u6619\u94bd\u952c\u9878\u50a5\u9967\u94f4\u9557\u97ec\u94fd\u7f07\u9e48\u9617\u7c9c\u9f86\u9ca6\u6078\u94ad\u948d\u629f\u9968\u7ba8\u9f0d\u5a32\u817d\u7ea8\u7efe\u8f8b\u8bff\u5e0f\u95f1\u6ca9\u6da0\u73ae\u97ea\u709c\u9c94\u960c\u83b4\u9f8c\u90ac\u5e91\u6003\u59a9\u9a9b\u9e49\u9e5c\u9969\u960b\u73ba\u89cb\u7856\u82cb\u83b6\u85d3\u5c98\u7303\u5a34\u9e47\u75eb\u869d\u7c7c\u8df9\u8297\u9977\u9aa7\u7f03\u98e8\u54d3\u6f47\u9a81\u7ee1\u67ad\u7bab\u4eb5\u64b7\u7ec1\u7f2c\u9649\u8365\u9990\u9e3a\u8be9\u987c\u8c16\u94c9\u955f\u8c11\u6cf6\u9cd5\u57d9\u6d54\u9c9f\u57ad\u5a05\u6860\u6c29\u53a3\u8d5d\u4fe8\u5156\u8c33\u6079\u95eb\u917d\u9b47\u990d\u9f39\u7080\u8f7a\u9e5e\u9cd0\u9765\u8c12\u90ba\u6654\u70e8\u8bd2\u5453\u5cc4\u9974\u603f\u9a7f\u7f22\u8f76\u8d3b\u9487\u9552\u9571\u7617\u8223\u94df\u763e\u8314\u83ba\u8426\u84e5\u6484\u5624\u6ee2\u6f46\u748e\u9e66\u763f\u988f\u7f42\u955b\u83b8\u94d5\u9c7f\u4f1b\u4fe3\u8c00\u8c15\u84e3\u5d5b\u996b\u9608\u59aa\u7ea1\u89ce\u6b24\u94b0\u9e46\u9e6c\u9f89\u6a7c\u9e22\u9f0b\u94ba\u90d3\u82b8\u607d\u6120\u7ead\u97eb\u6b92\u6c32\u74d2\u8db1\u933e\u9a75\u8d5c\u5567\u5e3b\u7ba6\u8c2e\u7f2f\u8c35\u8bcf\u948a\u8c2a\u8f84\u9e67\u6d48\u7f1c\u6862\u8f78\u8d48\u796f\u9e29\u8be4\u5ce5\u94b2\u94ee\u7b5d\u9a98\u6809\u6800\u8f75\u8f7e\u8d3d\u9e37\u86f3\u7d77\u8e2c\u8e2f\u89ef\u953a\u7ea3\u7ec9\u4f2b\u69e0\u94e2\u556d\u9994\u989e\u9a93\u7f12\u8bfc\u956f\u8c18\u7f01\u8f8e\u8d40\u7726\u9531\u9f87\u9cbb\u506c\u8bf9\u9a7a\u9cb0\u955e\u7f35\u8e9c\u9cdf\u8ba0\u8c2b\u90c4\u52d0\u51fc\u5742\u5785\u57b4\u57ef\u57dd\u82d8\u836c\u836e\u839c\u83bc\u83f0\u85c1\u63f8\u5412\u5423\u5494\u549d\u54b4\u5658\u567c\u56af\u5e5e\u5c99\u5d74\u5f77\u5fbc\u72b8\u72cd\u9980\u9987\u9993\u9995\u6123\u61b7\u61d4\u4e2c\u6e86\u6edf\u6eb7\u6f24\u6f74\u6fb9\u752f\u7e9f\u7ed4\u7ef1\u73c9\u67a7\u684a\u6849\u69d4\u6a65\u8f71\u8f77\u8d4d\u80b7\u80e8\u98da\u7173\u7145\u7198\u610d\u6dfc\u781c\u78d9\u770d\u949a\u94b7\u94d8\u94de\u9503\u950d\u950e\u950f\u9518\u951d\u952a\u952b\u953f\u9545\u954e\u9562\u9565\u9569\u9572\u7a06\u9e4b\u9e5b\u9e71\u75ac\u75b4\u75d6\u766f\u88e5\u8941\u8022\u98a5\u87a8\u9eb4\u9c85\u9c86\u9c87\u9c9e\u9cb4\u9cba\u9cbc\u9cca\u9ccb\u9cd8\u9cd9\u9792\u97b4\u9f44",$ge="\u554a\u963f\u57c3\u6328\u54ce\u5509\u54c0\u769a\u764c\u85f9\u77ee\u827e\u7919\u611b\u9698\u978d\u6c28\u5b89\u4ffa\u6309\u6697\u5cb8\u80fa\u6848\u9aaf\u6602\u76ce\u51f9\u6556\u71ac\u7ffa\u8956\u50b2\u5967\u61ca\u6fb3\u82ad\u634c\u6252\u53ed\u5427\u7b06\u516b\u75a4\u5df4\u62d4\u8dcb\u9776\u628a\u8019\u58e9\u9738\u7f77\u7238\u767d\u67cf\u767e\u64fa\u4f70\u6557\u62dc\u7a17\u6591\u73ed\u642c\u6273\u822c\u9812\u677f\u7248\u626e\u62cc\u4f34\u74e3\u534a\u8fa6\u7d46\u90a6\u5e6b\u6886\u699c\u8180\u7d81\u68d2\u78c5\u868c\u938a\u508d\u8b17\u82de\u80de\u5305\u8912\u525d\u8584\u96f9\u4fdd\u5821\u98fd\u5bf6\u62b1\u5831\u66b4\u8c79\u9b91\u7206\u676f\u7891\u60b2\u5351\u5317\u8f29\u80cc\u8c9d\u92c7\u500d\u72fd\u5099\u618a\u7119\u88ab\u5954\u82ef\u672c\u7b28\u5d29\u7e43\u752d\u6cf5\u8e66\u8ff8\u903c\u9f3b\u6bd4\u9119\u7b46\u5f7c\u78a7\u84d6\u853d\u7562\u6583\u6bd6\u5e63\u5e87\u75f9\u9589\u655d\u5f0a\u5fc5\u8f9f\u58c1\u81c2\u907f\u965b\u97ad\u908a\u7de8\u8cb6\u6241\u4fbf\u8b8a\u535e\u8fa8\u8faf\u8fae\u904d\u6a19\u5f6a\u8198\u8868\u9c49\u618b\u5225\u765f\u5f6c\u658c\u7015\u6ff1\u8cd3\u64ef\u5175\u51b0\u67c4\u4e19\u79c9\u9905\u70b3\u75c5\u4e26\u73bb\u83e0\u64ad\u64a5\u7f3d\u6ce2\u535a\u52c3\u640f\u9251\u7b94\u4f2f\u5e1b\u8236\u8116\u818a\u6e24\u6cca\u99c1\u6355\u8514\u54fa\u88dc\u57e0\u4e0d\u5e03\u6b65\u7c3f\u90e8\u6016\u64e6\u731c\u88c1\u6750\u624d\u8ca1\u776c\u8e29\u91c7\u5f69\u83dc\u8521\u9910\u53c3\u8836\u6b98\u615a\u6158\u71e6\u84bc\u8259\u5009\u6ec4\u85cf\u64cd\u7cd9\u69fd\u66f9\u8349\u5ec1\u7b56\u5074\u518a\u6e2c\u5c64\u8e6d\u63d2\u53c9\u832c\u8336\u67e5\u78b4\u643d\u5bdf\u5c94\u5dee\u8a6b\u62c6\u67f4\u8c7a\u6519\u647b\u87ec\u995e\u8b92\u7e8f\u93df\u7522\u95e1\u986b\u660c\u7316\u5834\u5617\u5e38\u9577\u511f\u8178\u5ee0\u655e\u66a2\u5531\u5021\u8d85\u6284\u9214\u671d\u5632\u6f6e\u5de2\u5435\u7092\u8eca\u626f\u64a4\u63a3\u5fb9\u6f88\u90f4\u81e3\u8fb0\u5875\u6668\u5ff1\u6c88\u9673\u8d81\u896f\u6490\u7a31\u57ce\u6a59\u6210\u5448\u4e58\u7a0b\u61f2\u6f84\u8aa0\u627f\u901e\u9a01\u79e4\u5403\u7661\u6301\u5319\u6c60\u9072\u5f1b\u99b3\u6065\u9f52\u4f88\u5c3a\u8d64\u7fc5\u65a5\u71be\u5145\u6c96\u87f2\u5d07\u5bf5\u62bd\u916c\u7587\u8e8a\u7a20\u6101\u7c4c\u4ec7\u7da2\u7785\u919c\u81ed\u521d\u51fa\u6ae5\u5eda\u8e87\u92e4\u96db\u6ec1\u9664\u695a\u790e\u5132\u77d7\u6410\u89f8\u8655\u63e3\u5ddd\u7a7f\u693d\u50b3\u8239\u5598\u4e32\u7621\u7a97\u5e62\u5e8a\u95d6\u5275\u5439\u708a\u6376\u9318\u5782\u6625\u693f\u9187\u5507\u6df3\u7d14\u8822\u6233\u7dbd\u75b5\u8328\u78c1\u96cc\u8fad\u6148\u74f7\u8a5e\u6b64\u523a\u8cdc\u6b21\u8070\u8525\u56ea\u5306\u5f9e\u53e2\u6e4a\u7c97\u918b\u7c07\u4fc3\u8ea5\u7be1\u7ac4\u6467\u5d14\u50ac\u8106\u7601\u7cb9\u6dec\u7fe0\u6751\u5b58\u5bf8\u78cb\u64ae\u6413\u63aa\u632b\u932f\u642d\u9054\u7b54\u7629\u6253\u5927\u5446\u6b79\u50a3\u6234\u5e36\u6b86\u4ee3\u8cb8\u888b\u5f85\u902e\u6020\u803d\u64d4\u4e39\u55ae\u9132\u64a3\u81bd\u65e6\u6c2e\u4f46\u619a\u6de1\u8a95\u5f48\u86cb\u7576\u64cb\u9ee8\u8569\u6a94\u5200\u6417\u8e48\u5012\u5cf6\u79b1\u5c0e\u5230\u7a3b\u60bc\u9053\u76dc\u5fb7\u5f97\u7684\u8e6c\u71c8\u767b\u7b49\u77aa\u51f3\u9127\u5824\u4f4e\u6ef4\u8fea\u6575\u7b1b\u72c4\u6ecc\u7fdf\u5ae1\u62b5\u5e95\u5730\u8482\u7b2c\u5e1d\u5f1f\u905e\u7de0\u985b\u6382\u6ec7\u7898\u9ede\u5178\u975b\u588a\u96fb\u4f43\u7538\u5e97\u60e6\u5960\u6fb1\u6bbf\u7889\u53fc\u96d5\u96d5\u5201\u6389\u540a\u91e3\u8abf\u8dcc\u7239\u789f\u8776\u53e0\u8adc\u758a\u4e01\u76ef\u53ee\u91d8\u9802\u9f0e\u9320\u5b9a\u8a02\u4e1f\u6771\u51ac\u8463\u61c2\u52d5\u68df\u4f97\u606b\u51cd\u6d1e\u515c\u6296\u9b25\u9661\u8c46\u9017\u75d8\u90fd\u7763\u6bd2\u72a2\u7368\u8b80\u5835\u7779\u8ced\u675c\u934d\u809a\u5ea6\u6e21\u5992\u7aef\u77ed\u935b\u6bb5\u65b7\u7dde\u5806\u514c\u968a\u5c0d\u58a9\u5678\u8e72\u6566\u9813\u56e4\u920d\u76fe\u9041\u6387\u54c6\u591a\u596a\u579b\u8eb2\u6735\u8dfa\u8235\u5241\u60f0\u58ae\u86fe\u5ce8\u9d5d\u4fc4\u984d\u8a1b\u5a25\u60e1\u5384\u627c\u904f\u9102\u9913\u6069\u800c\u5152\u8033\u723e\u990c\u6d31\u4e8c\u8cb3\u767c\u7f70\u7b4f\u4f10\u4e4f\u95a5\u6cd5\u743a\u85e9\u5e06\u756a\u7ffb\u6a0a\u792c\u91e9\u7e41\u51e1\u7169\u53cd\u8fd4\u7bc4\u8ca9\u72af\u98ef\u6cdb\u574a\u82b3\u65b9\u80aa\u623f\u9632\u59a8\u4eff\u8a2a\u7d21\u653e\u83f2\u975e\u5561\u98db\u80a5\u532a\u8ab9\u5420\u80ba\u5ee2\u6cb8\u8cbb\u82ac\u915a\u5429\u6c1b\u5206\u7d1b\u58b3\u711a\u6c7e\u7c89\u596e\u4efd\u5fff\u61a4\u7cde\u8c50\u5c01\u6953\u8702\u5cf0\u92d2\u98a8\u760b\u70fd\u9022\u99ae\u7e2b\u8af7\u5949\u9cf3\u4f5b\u5426\u592b\u6577\u819a\u5b75\u6276\u62c2\u8f3b\u5e45\u6c1f\u7b26\u4f0f\u4fd8\u670d\u6d6e\u6daa\u798f\u88b1\u5f17\u752b\u64ab\u8f14\u4fef\u91dc\u65a7\u812f\u8151\u5e9c\u8150\u8d74\u526f\u8986\u8ce6\u5fa9\u5085\u4ed8\u961c\u7236\u8179\u8ca0\u5bcc\u8a03\u9644\u5a66\u7e1b\u5490\u5676\u560e\u8a72\u6539\u6982\u9223\u84cb\u6e89\u5e79\u7518\u687f\u67d1\u7aff\u809d\u8d95\u611f\u7a08\u6562\u8d1b\u5ca1\u525b\u92fc\u7f38\u809b\u7db1\u5d17\u6e2f\u6760\u7bd9\u81ef\u9ad8\u818f\u7f94\u7cd5\u641e\u93ac\u7a3f\u544a\u54e5\u6b4c\u64f1\u6208\u9d3f\u80f3\u7599\u5272\u9769\u845b\u683c\u86e4\u95a3\u9694\u927b\u500b\u5404\u7d66\u6839\u8ddf\u8015\u66f4\u5e9a\u7fb9\u57c2\u803f\u6897\u5de5\u653b\u529f\u606d\u9f94\u4f9b\u8eac\u516c\u5bae\u5f13\u978f\u6c5e\u62f1\u8ca2\u5171\u9264\u52fe\u6e9d\u830d\u72d7\u57a2\u69cb\u8cfc\u5920\u8f9c\u83c7\u5495\u7b8d\u4f30\u6cbd\u5b64\u59d1\u9f13\u53e4\u8831\u9aa8\u8c37\u80a1\u6545\u9867\u56fa\u96c7\u522e\u74dc\u526e\u5be1\u639b\u8902\u4e56\u62d0\u602a\u68fa\u95dc\u5b98\u51a0\u89c0\u7ba1\u9928\u7f50\u6163\u704c\u8cab\u5149\u5ee3\u901b\u7470\u898f\u572d\u77fd\u6b78\u9f9c\u95a8\u8ecc\u9b3c\u8a6d\u7678\u6842\u6ac3\u8dea\u8cb4\u528a\u8f25\u6efe\u68cd\u934b\u90ed\u570b\u679c\u88f9\u904e\u54c8\u9ab8\u5b69\u6d77\u6c26\u4ea5\u5bb3\u99ed\u9163\u61a8\u90af\u97d3\u542b\u6db5\u5bd2\u51fd\u558a\u7f55\u7ff0\u64bc\u634d\u65f1\u61be\u608d\u710a\u6c57\u6f22\u592f\u676d\u822a\u58d5\u568e\u8c6a\u6beb\u90dd\u597d\u8017\u865f\u6d69\u5475\u559d\u8377\u83cf\u6838\u79be\u548c\u4f55\u5408\u76d2\u8c89\u95a1\u6cb3\u6db8\u8d6b\u8910\u9db4\u8cc0\u563f\u9ed1\u75d5\u5f88\u72e0\u6068\u54fc\u4ea8\u6a6b\u8861\u6052\u8f5f\u54c4\u70d8\u8679\u9d3b\u6d2a\u5b8f\u5f18\u7d05\u5589\u4faf\u7334\u543c\u539a\u5019\u5f8c\u547c\u4e4e\u5ffd\u745a\u58fa\u846b\u80e1\u8774\u72d0\u7cca\u6e56\u5f27\u864e\u552c\u8b77\u4e92\u6eec\u6236\u82b1\u5629\u83ef\u733e\u6ed1\u756b\u5283\u5316\u8a71\u69d0\u5f8a\u61f7\u6dee\u58de\u6b61\u74b0\u6853\u9084\u7de9\u63db\u60a3\u559a\u7613\u8c62\u7165\u6e19\u5ba6\u5e7b\u8352\u614c\u9ec3\u78fa\u8757\u7c27\u7687\u51f0\u60f6\u714c\u6643\u5e4c\u604d\u8b0a\u7070\u63ee\u8f1d\u5fbd\u6062\u86d4\u56de\u6bc0\u6094\u6167\u5349\u60e0\u6666\u8cc4\u7a62\u6703\u71f4\u532f\u8af1\u8aa8\u7e6a\u8477\u660f\u5a5a\u9b42\u6e3e\u6df7\u8c41\u6d3b\u5925\u706b\u7372\u6216\u60d1\u970d\u8ca8\u798d\u64ca\u573e\u57fa\u6a5f\u7578\u7a3d\u7a4d\u7b95\u808c\u9951\u8de1\u6fc0\u8b4f\u96de\u59ec\u7e3e\u7ddd\u5409\u6975\u68d8\u8f2f\u7c4d\u96c6\u53ca\u6025\u75be\u6c72\u5373\u5ac9\u7d1a\u64e0\u5e7e\u810a\u5df1\u858a\u6280\u5180\u5b63\u4f0e\u796d\u5291\u60b8\u6fdf\u5bc4\u5bc2\u8a08\u8a18\u65e2\u5fcc\u969b\u7e7c\u7d00\u5609\u67b7\u593e\u4f73\u5bb6\u52a0\u83a2\u9830\u8cc8\u7532\u9240\u5047\u7a3c\u50f9\u67b6\u99d5\u5ac1\u6bb2\u76e3\u5805\u5c16\u7b8b\u9593\u714e\u517c\u80a9\u8271\u5978\u7dd8\u7e6d\u6aa2\u67ec\u583f\u9e7c\u63c0\u64bf\u7c21\u5109\u526a\u6e1b\u85a6\u6abb\u9452\u8e10\u8ce4\u898b\u9375\u7bad\u4ef6\u5065\u8266\u528d\u991e\u6f38\u6ffa\u6f97\u5efa\u50f5\u59dc\u5c07\u6f3f\u6c5f\u7586\u8523\u69f3\u734e\u8b1b\u5320\u91ac\u964d\u8549\u6912\u7901\u7126\u81a0\u4ea4\u90ca\u6f86\u9a55\u5b0c\u56bc\u652a\u9278\u77ef\u50e5\u8173\u72e1\u89d2\u9903\u7e73\u7d5e\u527f\u6559\u9175\u8f4e\u8f03\u53eb\u7a96\u63ed\u63a5\u7686\u7a2d\u8857\u968e\u622a\u52ab\u7bc0\u8396\u775b\u6676\u9be8\u4eac\u9a5a\u7cbe\u7cb3\u7d93\u4e95\u8b66\u666f\u9838\u975c\u5883\u656c\u93e1\u5f91\u75d9\u9756\u7adf\u7af6\u51c8\u70af\u7a98\u63ea\u7a76\u7cfe\u7396\u97ed\u4e45\u7078\u4e5d\u9152\u5ec4\u6551\u820a\u81fc\u8205\u548e\u5c31\u759a\u97a0\u62d8\u72d9\u75bd\u5c45\u99d2\u83ca\u5c40\u5480\u77e9\u8209\u6cae\u805a\u62d2\u64da\u5de8\u5177\u8ddd\u8e1e\u92f8\u4ff1\u53e5\u61fc\u70ac\u5287\u6350\u9d51\u5a1f\u5026\u7737\u5377\u7d79\u6485\u652b\u6289\u6398\u5014\u7235\u6854\u5091\u6377\u776b\u7aed\u6f54\u7d50\u89e3\u59d0\u6212\u85c9\u82a5\u754c\u501f\u4ecb\u75a5\u8aa1\u5c46\u5dfe\u7b4b\u65a4\u91d1\u4eca\u6d25\u895f\u7dca\u9326\u50c5\u8b39\u9032\u9773\u6649\u7981\u8fd1\u71fc\u6d78\u76e1\u52c1\u834a\u5162\u89ba\u6c7a\u8a23\u7d55\u5747\u83cc\u921e\u8ecd\u541b\u5cfb\u4fca\u7ae3\u6d5a\u90e1\u99ff\u5580\u5496\u5361\u54af\u958b\u63e9\u6977\u51f1\u6168\u520a\u582a\u52d8\u574e\u780d\u770b\u5eb7\u6177\u7ce0\u625b\u6297\u4ea2\u7095\u8003\u62f7\u70e4\u9760\u5777\u82db\u67ef\u68f5\u78d5\u9846\u79d1\u6bbc\u54b3\u53ef\u6e34\u514b\u523b\u5ba2\u8ab2\u80af\u5543\u58be\u61c7\u5751\u542d\u7a7a\u6050\u5b54\u63a7\u6473\u53e3\u6263\u5bc7\u67af\u54ed\u7a9f\u82e6\u9177\u5eab\u8932\u8a87\u57ae\u630e\u8de8\u80ef\u584a\u7b77\u5108\u5feb\u5bec\u6b3e\u5321\u7b50\u72c2\u6846\u7926\u7736\u66e0\u6cc1\u8667\u76d4\u5dcb\u7aba\u8475\u594e\u9b41\u5080\u994b\u6127\u6f70\u5764\u6606\u6346\u56f0\u62ec\u64f4\u5ed3\u95ca\u5783\u62c9\u5587\u881f\u81d8\u8fa3\u5566\u840a\u4f86\u8cf4\u85cd\u5a6a\u6b04\u6514\u7c43\u95cc\u862d\u703e\u8b95\u652c\u89bd\u61f6\u7e9c\u721b\u6feb\u746f\u6994\u72fc\u5eca\u90ce\u6717\u6d6a\u6488\u52de\u7262\u8001\u4f6c\u59e5\u916a\u70d9\u6f87\u52d2\u6a02\u96f7\u9433\u857e\u78ca\u7d2f\u5121\u58d8\u64c2\u808b\u985e\u6dda\u68f1\u695e\u51b7\u5398\u68a8\u7281\u9ece\u7c6c\u8c8d\u96e2\u6f13\u7406\u674e\u88cf\u9bc9\u79ae\u8389\u8354\u540f\u6817\u9e97\u53b2\u52f5\u792b\u6b77\u5229\u5088\u4f8b\u4fd0\u75e2\u7acb\u7c92\u701d\u96b8\u529b\u7483\u54e9\u5006\u806f\u84ee\u9023\u942e\u5ec9\u6190\u6f23\u7c3e\u6582\u81c9\u93c8\u6200\u7149\u7df4\u7ce7\u6dbc\u6881\u7cb1\u826f\u5169\u8f1b\u91cf\u667e\u4eae\u8ad2\u64a9\u804a\u50da\u7642\u71ce\u5be5\u907c\u6f66\u4e86\u6482\u9410\u5ed6\u6599\u5217\u88c2\u70c8\u52a3\u7375\u7433\u6797\u78f7\u9716\u81e8\u9130\u9c57\u6dcb\u51dc\u8cc3\u541d\u62ce\u73b2\u83f1\u96f6\u9f61\u9234\u4f36\u7f9a\u6de9\u9748\u9675\u5dba\u9818\u53e6\u4ee4\u6e9c\u7409\u69b4\u786b\u993e\u7559\u5289\u7624\u6d41\u67f3\u516d\u9f8d\u807e\u56a8\u7c60\u7abf\u9686\u58df\u650f\u96b4\u6a13\u5a41\u645f\u7c0d\u6f0f\u964b\u8606\u76e7\u9871\u5eec\u7210\u64c4\u9e75\u865c\u9b6f\u9e93\u788c\u9732\u8def\u8cc2\u9e7f\u6f5e\u797f\u9304\u9678\u622e\u9a62\u5442\u92c1\u4fb6\u65c5\u5c65\u5c62\u7e37\u616e\u6c2f\u5f8b\u7387\u6ffe\u7da0\u5dd2\u6523\u5b7f\u7064\u5375\u4e82\u63a0\u7565\u6384\u8f2a\u502b\u4f96\u6dea\u7db8\u8ad6\u863f\u87ba\u7f85\u908f\u947c\u7c6e\u9a3e\u88f8\u843d\u6d1b\u99f1\u7d61\u5abd\u9ebb\u746a\u78bc\u879e\u99ac\u7f75\u561b\u55ce\u57cb\u8cb7\u9ea5\u8ce3\u9081\u8108\u779e\u9945\u883b\u6eff\u8513\u66fc\u6162\u6f2b\u8b3e\u8292\u832b\u76f2\u6c13\u5fd9\u83bd\u8c93\u8305\u9328\u6bdb\u77db\u925a\u536f\u8302\u5192\u5e3d\u8c8c\u8cbf\u9ebd\u73ab\u679a\u6885\u9176\u9ef4\u7164\u6c92\u7709\u5a92\u9382\u6bcf\u7f8e\u6627\u5bd0\u59b9\u5a9a\u9580\u60b6\u5011\u840c\u8499\u6aac\u76df\u9333\u731b\u5922\u5b5f\u7787\u919a\u9761\u7cdc\u8ff7\u8b0e\u5f4c\u7c73\u79d8\u8993\u6ccc\u871c\u5bc6\u51aa\u68c9\u7720\u7dbf\u5195\u514d\u52c9\u5a29\u7dec\u9762\u82d7\u63cf\u7784\u85d0\u79d2\u6e3a\u5edf\u5999\u8511\u6ec5\u6c11\u62bf\u76bf\u654f\u61ab\u95a9\u660e\u879f\u9cf4\u9298\u540d\u547d\u8b2c\u6478\u6479\u8611\u6a21\u819c\u78e8\u6469\u9b54\u62b9\u672b\u83ab\u58a8\u9ed8\u6cab\u6f20\u5bde\u964c\u8b00\u725f\u67d0\u62c7\u7261\u755d\u59c6\u6bcd\u5893\u66ae\u5e55\u52df\u6155\u6728\u76ee\u7766\u7267\u7a46\u62ff\u54ea\u5436\u9209\u90a3\u5a1c\u7d0d\u6c16\u4e43\u5976\u8010\u5948\u5357\u7537\u96e3\u56ca\u6493\u8166\u60f1\u9b27\u6dd6\u5462\u9912\u5167\u5ae9\u80fd\u59ae\u9713\u502a\u6ce5\u5c3c\u64ec\u59b3\u533f\u81a9\u9006\u6eba\u852b\u62c8\u5e74\u78be\u6506\u649a\u5ff5\u5a18\u91c0\u9ce5\u5c3f\u634f\u8076\u5b7d\u5699\u9477\u93b3\u6d85\u60a8\u6ab8\u7370\u51dd\u5be7\u64f0\u6fd8\u725b\u626d\u9215\u7d10\u81bf\u6fc3\u8fb2\u5f04\u5974\u52aa\u6012\u5973\u6696\u8650\u7627\u632a\u61e6\u7cef\u8afe\u54e6\u6b50\u9dd7\u6bc6\u85d5\u5614\u5076\u6f1a\u556a\u8db4\u722c\u5e15\u6015\u7436\u62cd\u6392\u724c\u5f98\u6e43\u6d3e\u6500\u6f58\u76e4\u78d0\u76fc\u7554\u5224\u53db\u4e53\u9f90\u65c1\u802a\u80d6\u62cb\u5486\u5228\u70ae\u888d\u8dd1\u6ce1\u5478\u80da\u57f9\u88f4\u8ce0\u966a\u914d\u4f69\u6c9b\u5674\u76c6\u7830\u62a8\u70f9\u6f8e\u5f6d\u84ec\u68da\u787c\u7bf7\u81a8\u670b\u9d6c\u6367\u78b0\u576f\u7812\u9739\u6279\u62ab\u5288\u7435\u6bd7\u5564\u813e\u75b2\u76ae\u5339\u75de\u50fb\u5c41\u8b6c\u7bc7\u504f\u7247\u9a19\u98c4\u6f02\u74e2\u7968\u6487\u77a5\u62fc\u983b\u8ca7\u54c1\u8058\u4e52\u576a\u860b\u840d\u5e73\u6191\u74f6\u8a55\u5c4f\u5761\u6f51\u9817\u5a46\u7834\u9b44\u8feb\u7c95\u5256\u64b2\u92ea\u4ec6\u8386\u8461\u83e9\u84b2\u57d4\u6a38\u5703\u666e\u6d66\u8b5c\u66dd\u7011\u671f\u6b3a\u68f2\u621a\u59bb\u4e03\u6dd2\u6f06\u67d2\u6c8f\u5176\u68cb\u5947\u6b67\u7566\u5d0e\u81cd\u9f4a\u65d7\u7948\u7941\u9a0e\u8d77\u8c48\u4e5e\u4f01\u555f\u5951\u780c\u5668\u6c23\u8fc4\u68c4\u6c7d\u6ce3\u8a16\u6390\u6d3d\u727d\u6261\u91ec\u925b\u5343\u9077\u7c3d\u4edf\u8b19\u4e7e\u9ed4\u9322\u9257\u524d\u6f5b\u9063\u6dfa\u8b74\u5879\u5d4c\u6b20\u6b49\u69cd\u55c6\u8154\u7f8c\u58bb\u8594\u5f37\u6436\u6a47\u936c\u6572\u6084\u6a4b\u77a7\u55ac\u50d1\u5de7\u9798\u64ac\u7ff9\u5ced\u4fcf\u7ac5\u5207\u8304\u4e14\u602f\u7aca\u6b3d\u4fb5\u89aa\u79e6\u7434\u52e4\u82b9\u64d2\u79bd\u5be2\u6c81\u9752\u8f15\u6c2b\u50be\u537f\u6e05\u64ce\u6674\u6c30\u60c5\u9803\u8acb\u6176\u74ca\u7aae\u79cb\u4e18\u90b1\u7403\u6c42\u56da\u914b\u6cc5\u8da8\u5340\u86c6\u66f2\u8ec0\u5c48\u9a45\u6e20\u53d6\u5a36\u9f72\u8da3\u53bb\u5708\u9874\u6b0a\u919b\u6cc9\u5168\u75ca\u62f3\u72ac\u5238\u52f8\u7f3a\u7094\u7638\u537b\u9d72\u69b7\u78ba\u96c0\u88d9\u7fa4\u7136\u71c3\u5189\u67d3\u74e4\u58e4\u6518\u56b7\u8b93\u9952\u64fe\u7e5e\u60f9\u71b1\u58ec\u4ec1\u4eba\u5fcd\u97cc\u4efb\u8a8d\u5203\u598a\u7d09\u6254\u4ecd\u65e5\u620e\u8338\u84c9\u69ae\u878d\u7194\u6eb6\u5bb9\u7d68\u5197\u63c9\u67d4\u8089\u8339\u8815\u5112\u5b7a\u5982\u8fb1\u4e73\u6c5d\u5165\u8925\u8edf\u962e\u854a\u745e\u92b3\u958f\u6f64\u82e5\u5f31\u6492\u7051\u85a9\u816e\u9c13\u585e\u8cfd\u4e09\u4e09\u5098\u6563\u6851\u55d3\u55aa\u6414\u9a37\u6383\u5ac2\u745f\u8272\u6f80\u68ee\u50e7\u838e\u7802\u6bba\u524e\u6c99\u7d17\u50bb\u5565\u715e\u7be9\u66ec\u73ca\u82eb\u6749\u5c71\u522a\u717d\u886b\u9583\u965c\u64c5\u8d0d\u81b3\u5584\u6c55\u6247\u7e55\u5891\u50b7\u5546\u8cde\u664c\u4e0a\u5c1a\u88f3\u68a2\u634e\u7a0d\u71d2\u828d\u52fa\u97f6\u5c11\u54e8\u90b5\u7d39\u5962\u8cd2\u86c7\u820c\u820d\u8d66\u651d\u5c04\u61fe\u6d89\u793e\u8a2d\u7837\u7533\u547b\u4f38\u8eab\u6df1\u5a20\u7d33\u795e\u6c88\u5be9\u5b38\u751a\u814e\u614e\u6ef2\u8072\u751f\u7525\u7272\u5347\u7e69\u7701\u76db\u5269\u52dd\u8056\u5e2b\u5931\u7345\u65bd\u6fd5\u8a69\u5c4d\u8671\u5341\u77f3\u62fe\u6642\u4ec0\u98df\u8755\u5be6\u8b58\u53f2\u77e2\u4f7f\u5c4e\u99db\u59cb\u5f0f\u793a\u58eb\u4e16\u67ff\u4e8b\u62ed\u8a93\u901d\u52e2\u662f\u55dc\u566c\u9069\u4ed5\u4f8d\u91cb\u98fe\u6c0f\u5e02\u6043\u5ba4\u8996\u8a66\u6536\u624b\u9996\u5b88\u58fd\u6388\u552e\u53d7\u7626\u7378\u852c\u6a1e\u68b3\u6b8a\u6292\u8f38\u53d4\u8212\u6dd1\u758f\u66f8\u8d16\u5b70\u719f\u85af\u6691\u66d9\u7f72\u8700\u9ecd\u9f20\u5c6c\u8853\u8ff0\u6a39\u675f\u620d\u8c4e\u5885\u5eb6\u6578\u6f31\u6055\u5237\u800d\u6454\u8870\u7529\u5e25\u6813\u62f4\u971c\u96d9\u723d\u8ab0\u6c34\u7761\u7a05\u542e\u77ac\u9806\u821c\u8aaa\u78a9\u6714\u720d\u65af\u6495\u5636\u601d\u79c1\u53f8\u7d72\u6b7b\u8086\u5bfa\u55e3\u56db\u4f3a\u4f3c\u98fc\u5df3\u677e\u8073\u616b\u980c\u9001\u5b8b\u8a1f\u8aa6\u641c\u8258\u64fb\u55fd\u8607\u9165\u4fd7\u7d20\u901f\u7c9f\u50f3\u5851\u6eaf\u5bbf\u8a34\u8085\u9178\u849c\u7b97\u96d6\u968b\u96a8\u7d8f\u9ad3\u788e\u6b72\u7a57\u9042\u96a7\u795f\u5b6b\u640d\u7b4d\u84d1\u68ad\u5506\u7e2e\u7463\u7d22\u9396\u6240\u584c\u4ed6\u5b83\u5979\u5854\u737a\u64bb\u8e4b\u8e0f\u80ce\u82d4\u64e1\u81fa\u6cf0\u915e\u592a\u614b\u6c70\u574d\u6524\u8caa\u7671\u7058\u58c7\u6a80\u75f0\u6f6d\u8b5a\u8ac7\u5766\u6bef\u8892\u78b3\u63a2\u5606\u70ad\u6e6f\u5858\u642a\u5802\u68e0\u819b\u5510\u7cd6\u5018\u8eba\u6dcc\u8d9f\u71d9\u638f\u6fe4\u6ed4\u7d73\u8404\u6843\u9003\u6dd8\u9676\u8a0e\u5957\u7279\u85e4\u9a30\u75bc\u8b04\u68af\u5254\u8e22\u92bb\u63d0\u984c\u8e44\u557c\u9ad4\u66ff\u568f\u60d5\u6d95\u5243\u5c5c\u5929\u6dfb\u586b\u7530\u751c\u606c\u8214\u8146\u6311\u689d\u8fe2\u773a\u8df3\u8cbc\u9435\u5e16\u5ef3\u807d\u70f4\u6c40\u5ef7\u505c\u4ead\u5ead\u633a\u8247\u901a\u6850\u916e\u77b3\u540c\u9285\u5f64\u7ae5\u6876\u6345\u7b52\u7d71\u75db\u5077\u6295\u982d\u900f\u51f8\u79bf\u7a81\u5716\u5f92\u9014\u5857\u5c60\u571f\u5410\u5154\u6e4d\u5718\u63a8\u9839\u817f\u86fb\u892a\u9000\u541e\u5c6f\u81c0\u62d6\u6258\u812b\u9d15\u9640\u99b1\u99dd\u6a62\u59a5\u62d3\u553e\u6316\u54c7\u86d9\u7aaa\u5a03\u74e6\u896a\u6b6a\u5916\u8c4c\u5f4e\u7063\u73a9\u9811\u4e38\u70f7\u5b8c\u7897\u633d\u665a\u7696\u60cb\u5b9b\u5a49\u842c\u8155\u6c6a\u738b\u4ea1\u6789\u7db2\u5f80\u65fa\u671b\u5fd8\u5984\u5a01\u5dcd\u5fae\u5371\u97cb\u9055\u6845\u570d\u552f\u60df\u70ba\u6ff0\u7dad\u8466\u840e\u59d4\u5049\u507d\u5c3e\u7def\u672a\u851a\u5473\u754f\u80c3\u9935\u9b4f\u4f4d\u6e2d\u8b02\u5c09\u6170\u885b\u761f\u6eab\u868a\u6587\u805e\u7d0b\u543b\u7a69\u7d0a\u554f\u55e1\u7fc1\u7515\u64be\u8778\u6e26\u7aa9\u6211\u65a1\u81e5\u63e1\u6c83\u5deb\u55da\u93a2\u70cf\u6c59\u8aa3\u5c4b\u7121\u856a\u68a7\u543e\u5433\u6bcb\u6b66\u4e94\u6342\u5348\u821e\u4f0d\u4fae\u5862\u620a\u9727\u6664\u7269\u52ff\u52d9\u609f\u8aa4\u6614\u7199\u6790\u897f\u7852\u77fd\u6670\u563b\u5438\u932b\u72a7\u7a00\u606f\u5e0c\u6089\u819d\u5915\u60dc\u7184\u70ef\u6eaa\u6c50\u7280\u6a84\u8972\u5e2d\u7fd2\u5ab3\u559c\u9291\u6d17\u7cfb\u9699\u6232\u7d30\u778e\u8766\u5323\u971e\u8f44\u6687\u5cfd\u4fe0\u72f9\u4e0b\u5ec8\u590f\u5687\u6380\u9341\u5148\u4ed9\u9bae\u7e96\u9e79\u8ce2\u929c\u8237\u9591\u6d8e\u5f26\u5acc\u986f\u96aa\u73fe\u737b\u7e23\u817a\u9921\u7fa8\u61b2\u9677\u9650\u7dda\u76f8\u5ec2\u9472\u9999\u7bb1\u8944\u6e58\u9109\u7fd4\u7965\u8a73\u60f3\u97ff\u4eab\u9805\u5df7\u6a61\u50cf\u5411\u8c61\u856d\u785d\u9704\u524a\u54ee\u56c2\u92b7\u6d88\u5bb5\u6dc6\u66c9\u5c0f\u5b5d\u6821\u8096\u562f\u7b11\u6548\u6954\u4e9b\u6b47\u880d\u978b\u5354\u633e\u651c\u90aa\u659c\u8105\u8ae7\u5beb\u68b0\u5378\u87f9\u61c8\u6cc4\u7009\u8b1d\u5c51\u85aa\u82af\u92c5\u6b23\u8f9b\u65b0\u5ffb\u5fc3\u4fe1\u91c1\u661f\u8165\u7329\u60fa\u8208\u5211\u578b\u5f62\u90a2\u884c\u9192\u5e78\u674f\u6027\u59d3\u5144\u5147\u80f8\u5308\u6d36\u96c4\u718a\u4f11\u4fee\u7f9e\u673d\u55c5\u92b9\u79c0\u8896\u7e61\u589f\u620c\u9700\u865b\u5653\u9808\u5f90\u8a31\u84c4\u9157\u6558\u65ed\u5e8f\u755c\u6064\u7d6e\u5a7f\u7dd2\u7e8c\u8ed2\u55a7\u5ba3\u61f8\u65cb\u7384\u9078\u766c\u7729\u7d62\u9774\u859b\u5b78\u7a74\u96ea\u8840\u52db\u718f\u5faa\u65ec\u8a62\u5c0b\u99b4\u5de1\u6b89\u6c5b\u8a13\u8a0a\u905c\u8fc5\u58d3\u62bc\u9d09\u9d28\u5440\u4e2b\u82bd\u7259\u869c\u5d16\u8859\u6daf\u96c5\u555e\u4e9e\u8a1d\u7109\u54bd\u95b9\u7159\u6df9\u9e7d\u56b4\u7814\u8712\u5dd6\u5ef6\u8a00\u984f\u95bb\u708e\u6cbf\u5944\u63a9\u773c\u884d\u6f14\u8277\u5830\u71d5\u53ad\u786f\u96c1\u5501\u5f65\u7130\u5bb4\u8afa\u9a57\u6b83\u592e\u9d26\u79e7\u694a\u63da\u4f6f\u760d\u7f8a\u6d0b\u967d\u6c27\u4ef0\u7662\u990a\u6a23\u6f3e\u9080\u8170\u5996\u7464\u6416\u582f\u9059\u7aaf\u8b20\u59da\u54ac\u8200\u85e5\u8981\u8000\u6930\u564e\u8036\u723a\u91ce\u51b6\u4e5f\u9801\u6396\u696d\u8449\u66f3\u814b\u591c\u6db2\u58f9\u58f9\u91ab\u63d6\u92a5\u4f9d\u4f0a\u8863\u9824\u5937\u907a\u79fb\u5100\u80f0\u7591\u6c82\u5b9c\u59e8\u5f5c\u6905\u87fb\u501a\u5df2\u4e59\u77e3\u4ee5\u85dd\u6291\u6613\u9091\u5c79\u5104\u5f79\u81c6\u9038\u8084\u75ab\u4ea6\u88d4\u610f\u6bc5\u61b6\u7fa9\u76ca\u6ea2\u8a63\u8b70\u8abc\u8b6f\u7570\u7ffc\u7fcc\u7e79\u8335\u852d\u56e0\u6bb7\u97f3\u9670\u59fb\u541f\u9280\u6deb\u5bc5\u98f2\u5c39\u5f15\u96b1\u5370\u82f1\u6afb\u5b30\u9df9\u61c9\u7e93\u7469\u87a2\u71df\u7192\u8805\u8fce\u8d0f\u76c8\u5f71\u7a4e\u786c\u6620\u55b2\u64c1\u50ad\u81c3\u7670\u5eb8\u96cd\u8e34\u86f9\u8a60\u6cf3\u6e67\u6c38\u607f\u52c7\u7528\u5e7d\u512a\u60a0\u6182\u5c24\u7531\u90f5\u923e\u7336\u6cb9\u904a\u9149\u6709\u53cb\u53f3\u4f51\u91c9\u8a98\u53c8\u5e7c\u8fc2\u6de4\u65bc\u76c2\u6986\u865e\u611a\u8f3f\u4f59\u4fde\u903e\u9b5a\u6109\u6e1d\u6f01\u9685\u4e88\u5a1b\u96e8\u8207\u5dbc\u79b9\u5b87\u8a9e\u7fbd\u7389\u57df\u828b\u90c1\u7c72\u9047\u55bb\u5cea\u79a6\u6108\u6b32\u7344\u80b2\u8b7d\u6d74\u5bd3\u88d5\u9810\u8c6b\u99ad\u9d1b\u6df5\u51a4\u5143\u57a3\u8881\u539f\u63f4\u8f45\u5712\u54e1\u5713\u733f\u6e90\u7de3\u9060\u82d1\u9858\u6028\u9662\u66f0\u7d04\u8d8a\u8e8d\u9470\u5dbd\u7cb5\u6708\u6085\u95b1\u8018\u96f2\u9116\u52fb\u9695\u5141\u904b\u860a\u919e\u6688\u97fb\u5b55\u531d\u7838\u96dc\u683d\u54c9\u707d\u5bb0\u8f09\u518d\u5728\u54b1\u6522\u66ab\u8d0a\u8d13\u81df\u846c\u906d\u7cdf\u947f\u85fb\u68d7\u65e9\u6fa1\u86a4\u8e81\u566a\u9020\u7682\u7ac8\u71e5\u8cac\u64c7\u5247\u6fa4\u8cca\u600e\u589e\u618e\u66fe\u8d08\u7d2e\u55b3\u6e23\u5284\u8ecb\u9358\u9598\u7728\u67f5\u69a8\u548b\u4e4d\u70b8\u8a50\u6458\u9f4b\u5b85\u7a84\u50b5\u5be8\u77bb\u6c08\u8a79\u7c98\u6cbe\u76de\u65ac\u8f3e\u5d84\u5c55\u8638\u68e7\u5360\u6230\u7ad9\u6e5b\u7dbb\u6a1f\u7ae0\u5f70\u6f33\u5f35\u638c\u6f32\u6756\u4e08\u5e33\u8cec\u4ed7\u8139\u7634\u969c\u62db\u662d\u627e\u6cbc\u8d99\u7167\u7f69\u5146\u8087\u53ec\u906e\u6298\u54f2\u87c4\u8f4d\u8005\u937a\u8517\u9019\u6d59\u73cd\u659f\u771f\u7504\u7827\u81fb\u8c9e\u91dd\u5075\u6795\u75b9\u8a3a\u9707\u632f\u93ae\u9663\u84b8\u6399\u775c\u5f81\u7319\u722d\u6014\u6574\u62ef\u6b63\u653f\u5e40\u7665\u912d\u8b49\u829d\u679d\u652f\u5431\u8718\u77e5\u80a2\u8102\u6c41\u4e4b\u7e54\u8077\u76f4\u690d\u6b96\u57f7\u503c\u4f84\u5740\u6307\u6b62\u8dbe\u53ea\u65e8\u7d19\u8a8c\u646f\u64f2\u81f3\u81f4\u7f6e\u5e5f\u5cd9\u5236\u667a\u79e9\u7a1a\u8cea\u7099\u75d4\u6eef\u6cbb\u7a92\u4e2d\u76c5\u5fe0\u9418\u8877\u7d42\u7a2e\u816b\u91cd\u4ef2\u773e\u821f\u5468\u5dde\u6d32\u8b05\u7ca5\u8ef8\u8098\u5e1a\u5492\u76ba\u5b99\u665d\u9a5f\u73e0\u682a\u86db\u6731\u8c6c\u8af8\u8a85\u9010\u7af9\u71ed\u716e\u62c4\u77da\u56d1\u4e3b\u8457\u67f1\u52a9\u86c0\u8caf\u9444\u7bc9\u4f4f\u8a3b\u795d\u99d0\u6293\u722a\u62fd\u5c08\u78da\u8f49\u64b0\u8cfa\u7bc6\u6a01\u838a\u88dd\u599d\u649e\u58ef\u72c0\u690e\u9310\u8ffd\u8d05\u589c\u7db4\u8ac4\u6e96\u6349\u62d9\u5353\u684c\u7422\u8301\u914c\u5544\u8457\u707c\u6fc1\u8332\u54a8\u8cc7\u59ff\u6ecb\u6dc4\u5b5c\u7d2b\u4ed4\u7c7d\u6ed3\u5b50\u81ea\u6f2c\u5b57\u9b03\u68d5\u8e64\u5b97\u7d9c\u7e3d\u7e31\u9112\u8d70\u594f\u63cd\u79df\u8db3\u5352\u65cf\u7956\u8a5b\u963b\u7d44\u9246\u7e82\u5634\u9189\u6700\u7f6a\u5c0a\u9075\u6628\u5de6\u4f50\u67de\u505a\u4f5c\u5750\u5ea7\u9312\u566f\u5b21\u74a6\u66d6\u9744\u8af3\u92a8\u9d6a\u5abc\u9a41\u9c32\u9200\u5504\u9211\u9d07\u9f59\u9d6f\u8cc1\u931b\u84fd\u55f6\u6f77\u924d\u7bf3\u8e55\u8290\u7df6\u7c69\u9a43\u98ae\u98c6\u93e2\u9463\u9c3e\u5110\u7e7d\u6ab3\u6baf\u81cf\u944c\u9ad5\u9b22\u7a1f\u9911\u9238\u9d53\u923d\u9a42\u9ef2\u60fb\u9364\u5115\u91f5\u56c5\u8ac2\u8b96\u8546\u61fa\u5b0b\u9a4f\u8998\u79aa\u9414\u5000\u8407\u60b5\u95b6\u9be7\u7868\u5096\u8af6\u6aec\u78e3\u9f54\u68d6\u6a89\u92ee\u943a\u98ed\u9d1f\u9283\u5114\u5e6c\u8b8e\u82bb\u7d40\u8e95\u91e7\u6134\u7d9e\u9d89\u8f1f\u9f6a\u9dbf\u84ef\u9a44\u6a05\u8f33\u651b\u92bc\u9e7a\u5660\u97c3\u99d8\u7d3f\u6bab\u8ce7\u7649\u7c1e\u8b9c\u78ad\u8960\u71fe\u9419\u7cf4\u8a46\u8ae6\u7d88\u89bf\u93d1\u5dd4\u923f\u7672\u929a\u9bdb\u9c08\u92cc\u92a9\u5d20\u9d87\u7ac7\u7006\u6add\u7258\u7be4\u9ef7\u7c6a\u61df\u9413\u71c9\u8e89\u9438\u8ae4\u580a\u95bc\u8edb\u92e8\u9354\u9d9a\u984e\u9853\u9c77\u8a92\u9087\u927a\u9d2f\u9b9e\u9201\u9b74\u7dcb\u9428\u9be1\u50e8\u7043\u9ce7\u99d9\u7d31\u7d3c\u8cfb\u9ea9\u9b92\u9c12\u91d3\u8cc5\u5c37\u641f\u7d3a\u6207\u776a\u8aa5\u7e1e\u92ef\u7d07\u9398\u6f41\u4e99\u8ce1\u7d86\u9bc1\u8a6c\u7df1\u89af\u8a41\u8f42\u9237\u932e\u9d23\u9d60\u9dbb\u9d30\u6451\u8a7f\u645c\u9e1b\u9c25\u7377\u532d\u528c\u5aaf\u6a9c\u9bad\u9c56\u889e\u7dc4\u9bc0\u581d\u54bc\u5e57\u69e8\u87c8\u927f\u95de\u7d4e\u9821\u705d\u9865\u8a36\u95d4\u8823\u9ecc\u8a0c\u8452\u958e\u9c5f\u6ef8\u9d98\u9a4a\u6a3a\u93f5\u5950\u7e6f\u9370\u9bc7\u9c09\u8a7c\u8588\u5666\u6fae\u7e62\u743f\u6689\u8ae2\u991b\u95bd\u9225\u944a\u8a10\u8a70\u85ba\u5630\u568c\u9a65\u74a3\u89ac\u9f4f\u78ef\u7f88\u8806\u8e8b\u973d\u9c6d\u9bfd\u90df\u6d79\u92cf\u93b5\u87ef\u8aeb\u7e11\u6214\u6229\u77bc\u9dbc\u7b67\u9c39\u97c9\u7d73\u97c1\u649f\u5da0\u9de6\u9bab\u7664\u981c\u9b9a\u5df9\u85ce\u9949\u7e09\u8d10\u89b2\u5244\u6d87\u9015\u5f33\u811b\u975a\u9b2e\u9ce9\u9df2\u8a4e\u5c68\u6af8\u98b6\u9245\u92e6\u7ab6\u9f5f\u9308\u942b\u96cb\u8b4e\u73a8\u76b8\u5274\u584f\u613e\u6137\u93a7\u9347\u9f95\u958c\u9227\u92ac\u9a0d\u7dd9\u8efb\u9233\u9301\u9837\u9f66\u93d7\u56b3\u9136\u5672\u81be\u736a\u9ad6\u8a86\u8a91\u913a\u58d9\u7e8a\u8cba\u5331\u8562\u6192\u8075\u7c23\u95ab\u9315\u9be4\u8810\u5d0d\u5fa0\u6df6\u7028\u8cda\u775e\u9338\u7669\u7c5f\u5d50\u6b16\u6595\u946d\u8964\u95ac\u92c3\u562e\u5d97\u92a0\u9412\u7646\u9c33\u8a84\u7e32\u5137\u9148\u58e2\u85f6\u849e\u863a\u56a6\u9090\u9a6a\u7e2d\u6aea\u6adf\u8f62\u792a\u92f0\u9e1d\u7658\u7cf2\u8e92\u9742\u9c7a\u9c67\u861e\u5969\u7032\u7489\u6bae\u8933\u895d\u9c31\u9b4e\u7e5a\u91d5\u9def\u85fa\u5ee9\u6a81\u8f54\u8eaa\u7dbe\u6b1e\u87f6\u9bea\u700f\u9a2e\u7db9\u93a6\u9dda\u8622\u7027\u74cf\u6af3\u6727\u7931\u50c2\u851e\u560d\u5d81\u93e4\u763a\u802c\u87bb\u9acf\u58da\u64fc\u5695\u95ad\u7018\u6de5\u6ae8\u6ad3\u8f64\u8f05\u8f46\u6c0c\u81da\u9e15\u9dfa\u826b\u9c78\u81e0\u5b4c\u6b12\u9e1e\u947e\u5707\u7296\u7380\u6ffc\u6b0f\u8161\u93cd\u6ada\u8938\u92dd\u5638\u561c\u5b24\u69aa\u52f1\u7e35\u93dd\u9859\u9c3b\u9ebc\u636b\u71dc\u61e3\u9346\u7f8b\u8b10\u737c\u79b0\u6fa0\u9766\u9efd\u7df2\u7e46\u9594\u7de1\u8b28\u9a40\u9943\u6b7f\u93cc\u926c\u9403\u8a25\u922e\u9be2\u8f26\u9bf0\u8526\u88ca\u9689\u8617\u56c1\u9862\u8ea1\u82e7\u5680\u8079\u5102\u5665\u99d1\u91f9\u513a\u8b33\u616a\u750c\u8e63\u76b0\u8f61\u7d15\u7f86\u9239\u8ade\u99e2\u7e39\u5b2a\u91d9\u93f7\u9420\u8604\u9a0f\u7dba\u69bf\u78e7\u980e\u980f\u9c2d\u50c9\u8541\u6173\u9a2b\u7e7e\u69e7\u9210\u5b19\u6aa3\u6227\u7197\u9306\u93d8\u93f9\u7fa5\u8e4c\u8a9a\u8b59\u854e\u7e70\u78fd\u8e7a\u611c\u9365\u7bcb\u92df\u64b3\u9bd6\u7162\u86fa\u5df0\u8cd5\u87e3\u9c0d\u8a58\u5d87\u95c3\u89b7\u9d1d\u8a6e\u7da3\u8f07\u9293\u95cb\u95d5\u6128\u8558\u5b08\u6a48\u98ea\u8ed4\u5db8\u8811\u7e1f\u92a3\u9870\u8706\u98af\u6bff\u7cdd\u7e45\u55c7\u92ab\u7a61\u93a9\u9bca\u91c3\u8a15\u59cd\u9a38\u91e4\u9c54\u5770\u6ba4\u89f4\u5399\u7044\u756c\u8a75\u8ad7\u700b\u8b1a\u5852\u8494\u5f12\u8efe\u8cb0\u9230\u9c23\u7dac\u6504\u7d13\u9582\u9460\u5edd\u99df\u7de6\u9376\u9de5\u85ea\u993f\u98bc\u93aa\u8b16\u7a4c\u8ab6\u84c0\u733b\u55e9\u8127\u95e5\u9248\u9c28\u9226\u9b90\u66c7\u926d\u931f\u9807\u513b\u9933\u940b\u93dc\u97dc\u92f1\u7df9\u9d5c\u95d0\u7cf6\u9f60\u9c37\u615f\u9204\u91f7\u6476\u98e9\u7c5c\u9f09\u5aa7\u8183\u7d08\u7db0\u8f1e\u8ac9\u5e43\u95c8\u6e88\u6f7f\u744b\u97d9\u7152\u9baa\u95bf\u8435\u9f77\u9114\u5ee1\u61ae\u5af5\u9a16\u9d61\u9da9\u993c\u9b29\u74bd\u89a1\u7864\u83a7\u859f\u861a\u5cf4\u736b\u5afb\u9df4\u7647\u8814\u79c8\u8e9a\u858c\u9909\u9a64\u7dd7\u9957\u5635\u701f\u9a4d\u7d83\u689f\u7c2b\u893b\u64f7\u7d32\u7e88\u9658\u6ece\u9948\u9d42\u8a61\u980a\u8afc\u9249\u93c7\u8b14\u6fa9\u9c48\u5864\u6f6f\u9c58\u57e1\u5a6d\u690f\u6c2c\u53b4\u8d17\u513c\u5157\u8b9e\u61e8\u9586\u91c5\u9b58\u995c\u9f34\u716c\u8efa\u9dc2\u9c29\u9768\u8b01\u9134\u66c4\u71c1\u8a52\u56c8\u5da7\u98f4\u61cc\u9a5b\u7e0a\u8efc\u8cbd\u91d4\u93b0\u943f\u761e\u8264\u92a6\u766e\u584b\u9daf\u7e08\u93a3\u6516\u56b6\u7005\u7020\u74d4\u9e1a\u766d\u9826\u7f4c\u93de\u8555\u92aa\u9b77\u50b4\u4fc1\u8adb\u8aed\u8577\u5d33\u98eb\u95be\u5ad7\u7d06\u89a6\u6b5f\u923a\u9d52\u9df8\u9f6c\u6ade\u9cf6\u9eff\u925e\u9106\u8553\u60f2\u614d\u7d1c\u97de\u6b9e\u6c33\u74da\u8db2\u93e8\u99d4\u8cfe\u5616\u5e58\u7c00\u8b56\u7e52\u8b6b\u8a54\u91d7\u8b2b\u8f12\u9dd3\u6e5e\u7e1d\u6968\u8eeb\u8cd1\u798e\u9d06\u8acd\u5d22\u9266\u931a\u7b8f\u9a2d\u6adb\u6894\u8ef9\u8f0a\u8d04\u9dd9\u8784\u7e36\u8e93\u8e91\u89f6\u937e\u7d02\u7e10\u4f47\u6ae7\u9296\u56c0\u994c\u9873\u9a05\u7e0b\u8ad1\u9432\u8aee\u7dc7\u8f1c\u8cb2\u7725\u9319\u9f5c\u9bd4\u50af\u8acf\u9a36\u9beb\u93c3\u7e98\u8ea6\u9c52\u8a01\u8b7e\u90e4\u731b\u6c39\u962a\u58df\u5816\u57b5\u588a\u6abe\u8552\u8464\u84e7\u8493\u83c7\u69c1\u6463\u54a4\u551a\u54e2\u565d\u5645\u6485\u5288\u8b14\u8946\u5db4\u810a\u4eff\u50e5\u7341\u9e85\u9918\u9937\u994a\u9962\u695e\u6035\u61cd\u723f\u6f35\u7069\u6df7\u6feb\u7026\u6de1\u5be7\u7cf8\u7d5d\u7dd4\u7449\u6898\u68ec\u6848\u6a70\u6aeb\u8ef2\u8ee4\u8ceb\u8181\u8156\u98c8\u7cca\u7146\u6e9c\u6e63\u6e3a\u78b8\u6efe\u7798\u9208\u9255\u92e3\u92b1\u92e5\u92f6\u9426\u9427\u9369\u9340\u9343\u9307\u9384\u9387\u93bf\u941d\u9465\u9479\u9454\u7a6d\u9d93\u9da5\u9e0c\u7667\u5c59\u7602\u81d2\u8947\u7e48\u802e\u986c\u87ce\u9eaf\u9b81\u9b83\u9b8e\u9bd7\u9bdd\u9bf4\u9c5d\u9bff\u9c20\u9c35\u9c45\u97bd\u97dd\u9f47";function Zge(e){return Xgt.charAt($ge.indexOf(e.charAt(0)))}var eGt=new RegExp("[\u4e00-\u9fa5]+");function Kge(e){return $ge.includes(e)}var jr=class{static GetBytes(e){switch(typeof e){case"string":{let t=new Uint16Array(e.length);for(let n=0;n4294967295?((t=new Float64Array(1))[0]=e,new Uint8Array(t.buffer)):function(t){return t[0]=e,new Uint8Array(t.buffer)}(new Int32Array(1)):function(t){return t[0]=e,new Uint8Array(t.buffer)}(new Float64Array(1));case"boolean":return function(t){return t[0]=Number(e),t}(new Uint8Array(1));default:if(e instanceof Array){let t=[];for(let a=0;ae.length&&(n-=t);let i="";for(let r=0;re.length&&(n-=t);let i=new Uint8Array(n);for(let r=0;r1?(r.push(a.slice()),a=[]):i.set(0,0);break;case 3:l++,n/=t[l];break;case 4:l++,n*=t[l];break;case 5:if(4===s.length)throw"The position stack is only four locations deep";s.push(i);break;case 6:i=s.pop(),a.length>1&&(r.push(a.slice()),a=[]),o&&a.push(i.clone());break;case 7:{let s,o=0,h=n*e.baseUp,c=i.clone();switch(a.length>1&&(r.push(a.slice()),a=[]),e.fontType){case 0:l++,o=t[l];break;case 1:l++,o=t[l],0==o&&(l++,o=jr.ToUInt16(new Uint8Array([t[l++],t[l++]]),0),c.x=t[l++]*n,c.y=t[l++]*n,h=t[l]*n);break;case 2:l+=2,o=jr.ToUInt16(new Uint8Array([t[l-1],t[l]]),0)}0!==o&&(s=e.getGraphicDataByCodeWithOffset(o,h,c),s&&(r.push(...s.polylines.slice()),i=s.lastPoint.clone()))}break;case 8:{let e=new be;e.x=jr.byteTosbyte(t[++l]),e.y=jr.byteTosbyte(t[++l]),i.add(e.multiplyScalar(n)),o&&a.push(i.clone())}break;case 9:for(;;){let e=new be;if(e.x=jr.byteTosbyte(t[++l]),e.y=jr.byteTosbyte(t[++l]),0==e.x&&0==e.y)break;i.add(e.multiplyScalar(n)),o&&a.push(i.clone())}break;case 10:{let e=t[++l]*n,r=jr.byteTosbyte(t[++l]),s=(112&r)>>4,h=7&r;0==h&&(h=8);let c=Math.PI/4,u=c*h,d=Bf.CIRCLE_SPAN;r<0&&(d=-d,u=-u);let p=c*s,f=p+u,m=i.clone().sub(new be(Math.cos(p)*e,Math.sin(p)*e));if(i=m.clone().add(new be(Math.cos(f)*e,Math.sin(f)*e)),o){let t=p,n=!0;for(;n&&(t+=d,r>=0&&tf);)a.push(m.clone().add(new be(e*Math.cos(t),e*Math.sin(t))));a.push(i.clone())}}break;case 11:{let e=t[++l],r=t[++l],s=(255*t[++l]+t[++l])*n,h=jr.byteTosbyte(t[++l]),c=(112&h)>>4,u=7&h;0==u&&(u=8),0!=r&&u--;let d=Math.PI/4,p=d*u,f=Bf.CIRCLE_SPAN,m=1;h<0&&(f=-f,p=-p,m=-1);let g=d*c,v=g+p;g+=d*e/256*m,v+=d*r/256*m;let y=i.clone().sub(new be(s*Math.cos(g),s*Math.sin(g)));if(i=y.clone().add(new be(s*Math.cos(v),s*Math.sin(v))),o){let e=g,t=!0;for(;t&&(e+=f,h>0&&ev);)a.push(y.clone().add(new be(s*Math.cos(e),s*Math.sin(e))));a.push(i.clone())}}break;case 12:{let e=new be;e.x=jr.byteTosbyte(t[++l])*n,e.y=jr.byteTosbyte(t[++l])*n;let r=jr.byteTosbyte(t[++l]);r<-127&&(r=-127),o&&(0==r?a.push(i.clone().add(e)):a.push(Bf.generateArcPoints(i,e,r/127))),i.add(e)}break;case 13:for(;;){let e=new be;if(e.x=jr.byteTosbyte(t[++l])*n,e.y=jr.byteTosbyte(t[++l])*n,0==e.x&&0==e.y)break;let r=jr.byteTosbyte(t[++l]);r<-127&&(r=-127),o&&(0==r?a.push(i.clone().add(e)):a.push(Bf.generateArcPoints(i.clone(),e,r/127))),i.add(e)}break;case 14:l=Bf.skipCode(e,t,++l);break;default:if(h>15){let e=(240&h)>>4,t=15&h,r=new be;switch(t){case 0:r.x=1;break;case 1:r.x=1,r.y=.5;break;case 2:r.x=1,r.y=1;break;case 3:r.x=.5,r.y=1;break;case 4:r.y=1;break;case 5:r.x=-.5,r.y=1;break;case 6:r.x=-1,r.y=1;break;case 7:r.x=-1,r.y=.5;break;case 8:r.x=-1;break;case 9:r.x=-1,r.y=-.5;break;case 10:r.x=-1,r.y=-1;break;case 11:r.x=-.5,r.y=-1;break;case 12:r.y=-1;break;case 13:r.x=.5,r.y=-1;break;case 14:r.x=1,r.y=-1;break;case 15:r.x=1,r.y=-.5}i.add(r.multiplyScalar(e*n)),o&&a.push(i.clone())}}}return new ld(i,r)}static skipCode(e,t,n){switch(t[n]){case 0:case 1:case 2:case 5:case 6:case 14:default:break;case 3:case 4:n++;break;case 7:switch(e.fontType){case 0:n++;break;case 1:0==t[++n]&&(n+=6);break;case 2:n+=2}break;case 8:case 10:n+=2;break;case 9:for(;;){let e=t[++n],i=t[++n];if(0==e&&0==i)break}break;case 11:n+=5;break;case 12:n+=3;break;case 13:for(;;){let e=t[++n],i=t[++n];if(0==e&&0==i)break;t[++n]}}return n}static generateArcPoints(e,t,n){let i=e.clone().add(t),r=n<0;n=Math.abs(n);let a=t.length()/2,s=a*n,o=2*Math.atan(1/n),l=new be(t.y,-t.x);l.normalize(),l.multiplyScalar(s);let h=Math.abs(a/Math.sin(o/2)),c=e.add(t.divideScalar(2));!1!==r?c.add(l):c.sub(l);let u=e.sub(c),d=i.sub(c),p=Math.atan2(u.y,u.x),f=Math.atan2(d.y,d.x),m=Bf.CIRCLE_SPAN;r?(m=-m,pf&&(p-=2*Math.PI);let g=p;for(;;){if(g+=m,!r&&gf)return c.add(new be(h*Math.cos(g),h*Math.sin(g)));break}return i}},Bc=Bf;Bc.FILE_STOP_FLAG=["\r","\n","\x1a"],Bc.CIRCLE_SPAN=Math.PI/18;var Jge=new Ln,jC=class extends vy{constructor(e,t){if(super(e,t),this.isExtend=!1,this.isUniCode=!0,this.isEmbedded=!1,this.fontType=2,this.textShapesCache=new Map,this.graphicData=new Map,t instanceof ArrayBuffer){let e=new Cf(t),n=Bc.parserHeader(e,Bc.FILE_STOP_FLAG).split(" ");switch(n[1]){case"shapes":this.parseShapeFont(e),this.fontType=0;break;case"bigfont":this.parseBigFont(e),this.fontType=1;break;case"unifont":this.parseUniFont(e),this.fontType=2}this.fileHeader=n[0],this.fileVersion=n[2]}else this.setFontFile(t)}generateShapes(e,t){let n=[],i=0;for(let r=0;rnew be(e[0],e[1]))));i=new ld(new be,t),this.graphicData.set(e,i)}if(this.graphicData.has(e)){let n=t/jC.DEFAULT_SIZE;Jge.identity().scale(n,n),i=this.graphicData.get(e).transform(Jge)}return i}getGraphicDataByCodeWithOffset(e,t,n){var i;return null==(i=this.getGraphicDataByCode(e,t))?void 0:i.offset(n)}parseBigFont(e){jr.ToInt16(e.readBytes(2),0);let t=jr.ToInt16(e.readBytes(2),0),n=jr.ToInt16(e.readBytes(2),0);for(let o=0;o>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:t+=String.fromCharCode(i);break;case 12:case 13:r=e[n++],t+=String.fromCharCode((31&i)<<6|63&r);break;case 14:r=e[n++],a=e[n++],t+=String.fromCharCode((15&i)<<12|(63&r)<<6|(63&a)<<0)}return t}cd.DEFAULT_SIZE=12;var Hl=class{constructor(){this.fontMap=new Map,this.unsupportedChars={},this.missingFonts={},this.loader=new Kr}loadFonts(e){return ft(this,null,(function*(){if(e=Array.isArray(e)?e:[e],this.fileNames=e.map((e=>Hl.getFileName(e.toLowerCase()))),!(yield this.checkAllFontsLoaded(e))){for(let t=0;tft(this,null,(function*(){yield e.setFontDataToIndexedDb()})))),this.releaseFontData())}}))}getTextShape(e,t,n){if(0===this.fontMap.size)return void se.warn("[FontManager] no font loaded.");let i=this.fontMap.get(t.toLowerCase());return i||(i=this.fontMap.get(this.fontMap.keys().next().value),this.missingFonts[t]||(this.missingFonts[t]=0),this.missingFonts[t]++),null==i?void 0:i.generateShapes(e,n)}getCharShape(e,t,n){if(0===this.fontMap.size)return void se.warn("[FontManager] no font loaded.");let i=this.fontMap.get(t.toLowerCase());if(!i){this.missingFonts[t]||(this.missingFonts[t]=0),this.missingFonts[t]++;for(let[t,r]of this.fontMap)if(r.getCharShape(e,n)){i=r;break}}let r=null==i?void 0:i.getCharShape(e,n);if(r){if(i instanceof cd)return r.toThreeGeometry();if(i instanceof Nf)return new MC(e,{font:i,height:0,size:n||12,curveSegments:3,bevelSegments:3})}}getNotFoundTextShape(e){let t,n;for(let[i,r]of this.fontMap){let i=r.getNotFoundTextShape(e);if(i){t=i,n=r;break}}return n instanceof cd?t.toThreeGeometry():n instanceof Nf?new ta(t.toShapes(!1),{curveSegments:3,bevelSegments:3}):void 0}checkAllFontsLoaded(e){return ft(this,null,(function*(){if(!Dn.isBrowser)return!1;let t=!1;for(let n=0;ne.order-t.order));for(let t=0;t{Object.assign(this.unsupportedChars,e.unsupportedChars)})),this.unsupportedChars}releaseFontData(){this.fontMap.forEach((e=>{e.releaseFontData()})),this.fontMap.clear()}destroy(){this.releaseFontData(),this.fontMap.clear()}static isShxFile(e){return"shx"===Hl.getExtension(e)}static isTtfFile(e){return["WOFF","OTF","TTF"].includes(Hl.getExtension(e).toUpperCase())}static isJsonFile(e){return"json"===Hl.getExtension(e)}static getFileName(e){let t=e.lastIndexOf("/");return e.substring(t+1)}static getExtension(e){return e.substring(e.lastIndexOf(".")+1)}},ud=Hl;ud.enableFontCache=!0;var Uc=new O(1,0,0),D6=new O(0,1,0),Zu=new O(0,0,1),Qge=new O(0,0,0),Hf=16777215,Zgt="CONTINUOUS",XC=new xi({color:Hf}),Ea=new Gn({color:Hf}),Ty=new on({color:Hf}),e0e=(new Dt).setFromPoints([new O]),t0e=new et,n0e=new et,_o=new et,rr=new O,Vi=new O,wy=new O,o_=new be,Ys=new dr,r0e=new dr,YC=new an,Uf=new Ot,i0e=new xi({color:65280,size:5,depthTest:!1}),s0e=new xi({color:65280,depthTest:!1}),a0e=new xi({color:65280,depthTest:!1}),Kgt=e=>void 0!==e.viewDirectionFromTarget,Jgt=e=>{if(e){let t=e.match(/data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+).*,.*/);if(t&&t.length>0){let n=t[1],i=e.replace("data:"+n+";","").split(",");if(i&&2===i.length&&"base64"===i[0]){let e=i[1];return Wpe.decode(e)}}}return null},o0e=(e,t)=>{let n=new be(e.x,e.y),i=new be(t.x,t.y);return i.sub(n),i.normalize(),i.y<0?-Math.acos(i.x):Math.acos(i.x)},l0e=(e,t,n)=>({x:e.x+t*Math.cos(n),y:e.y+t*Math.sin(n)}),Qgt=(e,t,n,i)=>{let r=e?new be(e.x,e.y):new be(0,0),a=t?new be(t.x,t.y):new be(1,0);n=n||1;let s=4*Math.atan(n),o=r.distanceTo(a)/2/Math.sin(s/2),l=l0e(e,o,o0e(r,a)+(Math.PI/2-s/2));i=i||Math.max(Math.abs(Math.ceil(s/(Math.PI/18))),6);let h=o0e(l,r),c=s/i,u=[];u.push(new O(r.x,r.y,0));for(let d=1;d<=i-1;d++){let e=l0e(l,Math.abs(o),h+c*d);u.push(new O(e.x,e.y,0))}return u},e0t=(e,t,n,i=2*e.length,r)=>{let a=[],s=e.map((e=>[e.x,e.y]));for(let o=0;o<1;o+=1/i){let e=Q5(o,t,s,n,r);a.push(new O(e[0],e[1],0))}return a},O6=(e,t=!1)=>{let n=[],i=e.length;for(let r=0;r{let t=[];return e.faceA&&t.push(e.faceA),e.faceB&&t.push(e.faceB),e.faceC&&t.push(e.faceC),e.faceD&&t.push(e.faceD),t},n0t=e=>{let t=[],n=[];e.forEach((e=>{e.polyfaceMeshVertex&&(e.threeDPolylineMesh?t.push(new O(e.x,e.y,e.z)):n.push(t0t(e)))}));let i=[];for(let r=0;r=t.length||i<0){s=!1;break}a.push(t[i])}!s||0===a.length||(a.push(a[0]),i.push(a))}return i},Zn=class extends Er{constructor(e,t){super(e),this.timer=Date.now(),this.ignorePaperSpace=!1,this.encoding="UTF-8",this.angBase=0,this.angDir=0,this.header=void 0,this.pointsMaterials={},this.lineBasicMaterials={},this.lineShaderMaterials={},this.meshBasicMaterials={},this.meshTextureMaterials={},this.hatchShaderMaterials=[],this.entityCount=0,this.curveCount=0,this.averageCurveSize=0,this.enableRenderOrder=!1,this.enableLocalCache=!0,this.enableReleaseData=!0,this.enableMerge=!0,this.enableRTC=!0,this.enablePlineWidth=!0,this.dxfDataId=void 0,this.compareContext=void 0,this.statsInfo={unsupportedEntity:{},unsupportedEntityTypes:{},unsupportedTextStyles:{},unsupportedHatchPatterns:{},unsupportedPolylineCount:0,invisibleEntities:{},ignoredFrozenLayersAndEntityCount:{},ignoredInserts:{},entityTypesAndMeshCount:{},ignoredPaperSpaceEntityTypesAndCount:{},rebasedEntityCount:0},this.blockReferencesCache={},this.blockRecordsCache=void 0,this.entitiesCache=void 0,this.blocksCache=void 0,this.dictionaryOwnerHandleAndSpatialFilterHandlesCache=void 0,this.spatialFiltersCache=void 0,this.entityThreejsCache=void 0,this.entityTypesAndTimes=void 0,this.nonSnapableTypes=new Set(["ATTDEF","ATTRIB","LEADER","MTEXT","MULTILEADER","OLE2FRAME","TEXT"]),this.layoutsSnapObjectsMap={},this.entityHandlesWithRenderOrder={},this.addViewport=(e,t)=>{if("VIEWPORT"===e.type){t[e.ownerHandle]||(t[e.ownerHandle]=[]);let n=e;t[e.ownerHandle].push(n)}},Zn.abortJobs=!1,t&&(this.ignorePaperSpace=!0===t.ignorePaperSpace,this.enableLocalCache=!1!==t.enableLocalCache,this.enableMerge=!1!==t.enableMerge,this.encoding=t.encoding||"UTF-8",null!=t.overrideColor&&(this.overrideColor=Cn.rgb2Hex(t.overrideColor))),this.pointsMaterials[Hf]=XC,this.lineBasicMaterials[Hf]=Ea,this.meshBasicMaterials[Hf]=Ty}setFont(e){this.font=e}download(e,t){return ft(this,null,(function*(){let n=Jgt(e);if(!n){let i=Date.now(),r=new Kr(this.manager);r.setResponseType("arraybuffer"),r.setPath(this.path),n=yield r.loadAsync(e,t),se.info(`[DxfLoader] ${e} dxf file downloaded in ${(Date.now()-i)/1e3}s`)}return n}))}load(e,t,n){return ft(this,null,(function*(){return this.enableLocalCache&&t&&(t=t.trim()).length>0&&(this.dxfDataId=t),this.loadAsync(e,n)}))}loadAsync(e,t){return ft(this,null,(function*(){let n=Mt.getUpdateSubProgressFunc(0,50,t),i=Mt.getUpdateSubProgressFunc(50,100,t),r=Mt.getUpdateSubProgressFunc(10,100,t);if(Dn.isBrowser&&this.enableLocalCache&&this.dxfDataId){let t;try{if(this.timer=Date.now(),t=yield this.getDxfDataFromIndexedDb(this.dxfDataId),t){this.tryFixDxfData(t),se.info(`[DxfLoader] Loaded DxfData from indexedDb in ${(Date.now()-this.timer)/1e3}s`);let e=yield this.loadEntities(t,r);return Promise.resolve(e)}}catch(e){se.warn("[DxfLoader] Failed to parse data from indexedDb",e)}}let a=yield this.parse(e,n);return this.tryFixDxfData(a),yield this.loadEntities(a,i)}))}parse(e,t){return ft(this,null,(function*(){let n=Mt.getUpdateProgressFunc(t),i=Mt.getUpdateSubProgressFunc(0,40,t),r=yield this.download(e,i);if(!r)return Promise.reject(`[DxfLoader] Failed to download ${e}`);if(Zn.abortJobs)return Promise.reject("[DxfLoader] Job aborted");this.timer=Date.now(),se.info("[DxfLoader] Start parsing...");let a=new Xm(this.encoding).parseSync(r);if(this.tryFixDxfData(a),n(80),se.info(`[DxfLoader] Parsed in ${(Date.now()-this.timer)/1e3}s, creating entities...`),Zn.abortJobs)return Promise.reject("[DxfLoader] Job aborted");if(a&&Dn.isBrowser&&this.enableLocalCache&&this.dxfDataId){let t=Date.now();try{yield this.setDxfDataToIndexedDb(this.dxfDataId,a),se.info(`[DxfLoader] Saved to indexedDb in ${(Date.now()-t)/1e3}s`)}catch(e){se.warn(`[DxfLoader] Failed to save '${this.dxfDataId}' to indexedDb!`,e)}}return n(100),a}))}parseHeader(e){if(!e)return void se.error("[DxfLoader]: Invalid header!");this.header=e;let t=e.$ACADVER.toString();"AC1032"!==t&&se.warn(`[DxfLoader] Unexpected version: ${t}. But we'll try to continue.`),this.angBase=e.$ANGBASE||0,this.angDir=e.$ANGDIR||0}tryFixDxfData(e){e&&(e.objects||(se.warn("[DxfLoader] No objects found, Will add one."),e.objects={}),e.objects.LAYOUT||(se.warn("[DxfLoader] No layout defined! Will add a default 'Model' layout!"),e.objects.LAYOUT=[{layoutName:Zn.MODEL_LAYOUT_NAME}]),e.tables||(se.warn("[DxfLoader] No tables found, Will add one."),e.tables={}),e.tables.layer||(e.tables.layer={}),e.tables.layer.layers||(e.tables.layer.layers={}))}loadEntities(e,t){return ft(this,null,(function*(){let n=Date.now();this.parseHeader(e.header),this.enableRenderOrder&&(this.initRenderOrderInfo(e),this.enableMerge=!1),this.getFontFilesFromDxf(e);let i=0,r=e.entities.length;this.entityCount=r,Object.keys(e.blocks).forEach((t=>{var n;this.entityCount+=(null==(n=e.blocks[t].entities)?void 0:n.length)||0}));let a=Mt.getUpdateProgressFuncForLoop(r,t),s={},o=e=>{let t=e.userData.layerName,n=s[t];n||(n=[],s[t]=n),n.push(e)},l={},h={},c=new bn;for(let t=0;te.name===s));if(u||(u=new bn,u.name=s,u.userData.isLayoutLevelObject=!0,c.add(u)),r.traverse((e=>{e.userData.isSnapObject&&(this.layoutsSnapObjectsMap[s]||(this.layoutsSnapObjectsMap[s]=[]),this.layoutsSnapObjectsMap[s].push(e))})),this.enableMerge){Lc.merge(r,!1),h[s]||(h[s]={object:u,layerObjects:{}});let e=h[s];if(r.geometry){let t=r.userData.layerName;e.layerObjects[t]||(e.layerObjects[t]=[]),e.layerObjects[t].push(r),r.children.forEach((e=>{e.userData.isSnapObject&&o(e)}))}else r.children.length>0&&(u.add(r),r.traverse((e=>{e.geometry&&o(e)})))}else u.add(r),r.traverse((e=>{e.geometry&&o(e)}));i++,yield a(t)}e.objects.LAYOUT.forEach((t=>{let n=t,i=n.layoutName;if(this.ignorePaperSpace&&i!==Zn.MODEL_LAYOUT_NAME)return;let r=n.associatedBlockName,a=e.blocks[r];a&&this.drawLayout(a,e,n,c,s,l)})),se.debug(`[DxfLoader] Drew entities in ${(Date.now()-n)/1e3}s`);for(let t in this.layoutsSnapObjectsMap){let n=c.children.find((e=>e.name===t)),i=new bn;i.name=Zn.SNAP_GROUP_NAME,i.userData.isSnapGroup=!0,n.add(i);let r=this.layoutsSnapObjectsMap[t];for(let t=0;t=100&&(e=new Set(s));let t=t=>Array.isArray(e)?e.indexOf(t)>=0:e.has(t);for(let r=0,a=i.length;r{let t=e;d[t.layoutName]=t}));let p={};u.children.forEach((t=>{if(Hn.setSharedVariablesOfObject(t),!t.userData.isLayoutLevelObject)return;let n,i=t.name;if(i!==Zn.MODEL_LAYOUT_NAME){let e=d[i];e.directAssociatedLeafObjectSet||(e.directAssociatedLeafObjectSet=new Set),n=e.directAssociatedLeafObjectSet}t.traverse((t=>{if(Hn.setSharedVariablesOfObject(t),t.userData.isSnapGroup&&(t.visible=Zn.SHOW_SNAP_OBJECT),t.geometry){let i=t.userData.layerName;!1===this.getLayerVisible(e,i)&&(t.visible=!1,t.userData.layerVisible=!1),(e=>{let t=e.userData.layerName,n=p[t];n||(n=[],p[t]=n),n.push(e)})(t),n&&n.add(t)}}))})),se.info(`[DxfLoader] loadEntities() done in ${(Date.now()-n)/1e3}s`);let f=Ri(Tr({},e),{threejsObject:u,layersAndThreejsObjects:p,loadedEntityCount:i,layoutViewportsMap:l});return Promise.resolve(f)}))}getFontFilesFromDxf(e){let t=new Set;if(e.tables.style.styles){let n=e.tables.style.styles;for(let e in n){let i=n[e],r=i.fontFile,a=i.bigFontFile;r&&t.add(r),a&&t.add(a)}}se.info(`[DxfLoader] These are fonts used by dxf: ${Array.from(t).join()}`)}loadEntitiesForCompare(e,t,n,i=!0,r){return ft(this,null,(function*(){let a=e.entities.length,s=t.entities.length,o=()=>ft(this,null,(function*(){var o;let l=this.compareContext,h=l.isTheFirstFile,c=h?e:t,u=new bn,d=h?a:s,p=c.entities.length;this.entityCount=p,Object.keys(c.blocks).forEach((e=>{var t;this.entityCount+=(null==(t=c.blocks[e].entities)?void 0:t.length)||0}));let f=Math.round(Math.pow(d,.5)),m=Date.now(),g=e=>ft(this,null,(function*(){if(r&&(e%f==0||e===d-1)){let t=e+1;h||(t+=a),r(new ProgressEvent("parseProgress",{loaded:t,total:a+s}));let n=500,i=Date.now();(i-m>n||e===d-1)&&(yield Mt.sleep(0),m=i)}}));this.parseHeader(c.header);let v={};for(let e=0;ee.name===Zn.MODEL_LAYOUT_NAME));r||(r=new bn,r.name=Zn.MODEL_LAYOUT_NAME,r.userData.isLayoutLevelObject=!0,u.add(r)),r.add(i),i.traverse((e=>{if(e.geometry){let t=e.userData.layerName,r=this.getLayerVisible(c,t);e.userData.isSnapObject&&(this.layoutsSnapObjectsMap[n.layoutName]||(this.layoutsSnapObjectsMap[n.layoutName]=[]),this.layoutsSnapObjectsMap[n.layoutName].push(e),!1===r&&i.layers.disable(11));let a=v[t];a||(a=[],v[t]=a),a.push(e)}})),yield g(e)}i&&h&&(l.preservedHandles||(l.preservedHandles=new Set));for(let e in n){let t=n[e];h&&("Added"===t.type||"Modified"===t.type)&&(null==(o=l.preservedHandles)||o.add(t.handle),t.parentHandles&&t.parentHandles.forEach((e=>{var t;return null==(t=l.preservedHandles)?void 0:t.add(e)})));let i=this.entityThreejsCache&&this.entityThreejsCache[t.handle];if(t.parentHandles&&(i=this.entityThreejsCache&&this.entityThreejsCache[t.parentHandles[t.parentHandles.length-1]]),i){if(i.parent&&i.parent.userData.originalType){this.setObjectColorByChange(i,{type:"NoChange"});continue}i=this.setObjectColorByChange(i,t)}if("NoChange"!==t.type&&i){let e=i.parent,n=_o.identity();for(;e&&!0!==e.userData.isLayoutLevelObject;)n.premultiply(e.matrix),e=e.parent;Uf.makeEmpty();let r=bn.getBox(i,Uf);r.applyMatrix4(n),"Added"===t.type?!h&&(t.box=(new Ot).copy(r)):"Removed"===t.type?h&&(t.box=(new Ot).copy(r)):"Modified"===t.type&&(t.box?t.box.union(r):t.box=(new Ot).copy(r))}}for(let e in this.layoutsSnapObjectsMap){let t=u.children.find((t=>t.name===e)),n=new bn;n.name=Zn.SNAP_GROUP_NAME,t.add(n);let i=this.layoutsSnapObjectsMap[e];for(let e=0;e{Hn.setSharedVariablesOfObject(e),e.userData.isLayoutLevelObject&&e.traverse((e=>{if(Hn.setSharedVariablesOfObject(e),e.userData.isSnapGroup&&(e.visible=Zn.SHOW_SNAP_OBJECT),e.geometry){let t=e.userData.layerName;!1===this.getLayerVisible(c,t)&&(e.visible=!1,e.userData.layerVisible=!1),(e=>{let t=e.userData.layerName,n=x[t];n||(n=[],x[t]=n),n.push(e)})(e)}}))}));let b=c;b.threejsObject=y,b.layersAndThreejsObjects=x,b.layoutViewportsMap={}})),l=Date.now();this.compareContext={changes:n,isTheFirstFile:!0},Mt.printMemory("Before loading entities for first dxf"),yield o(),se.info(`[DxfLoader] loadEntities for first dxf in ${(Date.now()-l)/1e3}s`),Mt.printMemory("After loading entities for first dxf"),this.releaseCachedData(!1),this.releaseDxfData(e),Mt.printMemory("Before loading entities for second dxf"),l=Date.now(),this.compareContext.isTheFirstFile=!1,yield o(),se.info(`[DxfLoader] loadEntities for second dxf in ${(Date.now()-l)/1e3}s`),this.printStatsInfo();for(let e of Object.values(n))e.box||delete n[e.id];this.compareContext.preservedHandles=void 0,this.enableReleaseData&&(this.releaseCachedData(),this.releaseDxfData(t)),Mt.printMemory("After loading entities for second dxf")}))}setObjectColorByChange(e,t){let n=(e,t)=>{e.traverse((e=>{if(e.material)if(e.material instanceof Gn)e.material=this.getLineBasicMaterial(t);else if(e.material instanceof on)e.material=this.getMeshBasicMaterial(t);else if(e.material instanceof xi)e.material=this.getPointsMaterial(t);else if(e.material instanceof ln){let n=e.material.clone();Zn.updateMaterialUniforms(n),n.uniforms.u_color.value.set(t),e.material=n}}))},i=(e=>{var t;let n=hs.ENTITY_COLOR_NO_CHANGE;return"Added"===e.type?n=hs.ENTITY_COLOR_ADDED:"Removed"===e.type?n=hs.ENTITY_COLOR_REMOVED:"Modified"===e.type&&(n=null!=(t=this.compareContext)&&t.isTheFirstFile?hs.ENTITY_COLOR_REMOVED:hs.ENTITY_COLOR_ADDED),n})(t);return e.traverse((r=>{t.parentHandles?r.userData&&r.userData.handle&&r.userData.handle===t.handle&&(n(r,i),e=r):n(r,i)})),e}releaseCachedData(e=!0){e&&(this.pointsMaterials={},this.lineBasicMaterials={},this.lineShaderMaterials={},this.meshBasicMaterials={},this.meshTextureMaterials={},this.hatchShaderMaterials=[]),this.header=void 0,this.blockReferencesCache={},this.blockRecordsCache=void 0,this.blocksCache=void 0,this.entitiesCache=void 0,this.dictionaryOwnerHandleAndSpatialFilterHandlesCache=void 0,this.spatialFiltersCache=void 0,this.entityThreejsCache=void 0,this.entityTypesAndTimes=void 0,this.entityHandlesWithRenderOrder={},this.layoutsSnapObjectsMap={},this.statsInfo={unsupportedEntity:{},unsupportedEntityTypes:{},unsupportedTextStyles:{},unsupportedHatchPatterns:{},unsupportedPolylineCount:0,invisibleEntities:{},ignoredFrozenLayersAndEntityCount:{},ignoredInserts:{},entityTypesAndMeshCount:{},ignoredPaperSpaceEntityTypesAndCount:{},rebasedEntityCount:0}}releaseEntity(e){e.vertices&&(e.vertices=void 0),e.knotValues&&(e.knotValues=void 0),e.controlPoints&&(e.controlPoints=void 0),e.binaryData&&(e.binaryData=void 0),e.text&&(e.text=void 0),e.extendedData&&(e.extendedData=void 0),e.contextData&&(e.contextData=void 0);let t=e;t.boundaryPaths&&(t.boundaryPaths=[]),t.patternLines&&(t.patternLines=void 0)}releaseDxfData(e){delete e.objects.DICTIONARY,delete e.objects.SORTENTSTABLE,delete e.objects.XRECORD,e.tables&&(delete e.tables.dimStyle,delete e.tables.lineType,delete e.tables.style,delete e.tables.blockRecord),e.entities=[],e.blocks={}}drawEntity(e,t,n,i=!1){if(this.compareContext&&this.compareContext.preservedHandles&&this.compareContext.preservedHandles.has(e.handle)&&qm.includes(e.type)&&(i=!0),!i&&this.compareContext&&this.compareContext.preservedHandles&&!qm.includes(e.type)&&!this.compareContext.preservedHandles.has(e.handle)&&(!n||n&&!this.compareContext.preservedHandles.has(n.handle)))return;if(!0===this.getLayerFrozen(t,e)){let t=e.layer;return this.statsInfo.ignoredFrozenLayersAndEntityCount[t]||(this.statsInfo.ignoredFrozenLayersAndEntityCount[t]=0),void this.statsInfo.ignoredFrozenLayersAndEntityCount[t]++}if(!1===e.visible||e.invisible)return this.statsInfo.invisibleEntities[e.type]||(this.statsInfo.invisibleEntities[e.type]=0),void this.statsInfo.invisibleEntities[e.type]++;if(this.ignorePaperSpace&&e.inPaperSpace)return this.statsInfo.ignoredPaperSpaceEntityTypesAndCount[e.type]||(this.statsInfo.ignoredPaperSpaceEntityTypesAndCount[e.type]=0),void this.statsInfo.ignoredPaperSpaceEntityTypesAndCount[e.type]++;this.entityThreejsCache||(this.entityThreejsCache={});let r,a=Date.now(),s=!1;if(!this.compareContext&&this.entityThreejsCache[e.handle])r=this.entityThreejsCache[e.handle].clone(),s=!0;else if(!this.statsInfo.unsupportedEntity[e.handle]){if("CIRCLE"===e.type||"ARC"===e.type)r=this.drawArc(e,t,n);else if("LINE"===e.type||"POLYLINE"===e.type)r=this.drawLine(e);else if("XLINE"===e.type)r=this.drawXLine(e);else if("SEQEND"!==e.type)if("RAY"===e.type)r=this.drawRay(e);else if("LWPOLYLINE"===e.type)r=this.drawLWPolyline(e,t,n);else if("3DFACE"===e.type)r=this.draw3DFace(e);else if("TEXT"===e.type)r=this.drawText(e,t,n);else if("SOLID"===e.type)r=this.drawSolid(e,t,n);else if("POINT"===e.type)r=this.drawPoint(e,t,n);else if("IMAGE"===e.type)r=this.drawImage(e,t,n);else if("INSERT"===e.type)r=this.drawInsert(e,t,i);else if("SPLINE"===e.type)r=this.drawSpline(e,n);else if("MTEXT"===e.type)r=this.drawMText(e,t,n);else if("ELLIPSE"===e.type)r=this.drawEllipse(e,t,n);else if("DIMENSION"===e.type)r=this.drawDimension(e,t);else if("REGION"!==e.type)if("ATTDEF"===e.type)r=this.drawAttDef(e,t,n);else if("ATTRIB"===e.type){if(!n)for(let i=0;i{r.geometry&&(r.userData.layerName=i,this.setMaterial(r,e,t,n))})),s||(this.nonSnapableTypes.has(e.type)&&r.traverse((e=>{e.layers.disable(11)})),this.enableRenderOrder&&(this.entityHandlesWithRenderOrder[e.handle]?r.renderOrder=parseInt(this.entityHandlesWithRenderOrder[e.handle],16)+.1:r.renderOrder=parseInt(e.handle,16)))}return qm.includes(e.type)||(this.entityTypesAndTimes||(this.entityTypesAndTimes={}),this.entityTypesAndTimes[e.type]||(this.entityTypesAndTimes[e.type]={createCount:0,totalTime:0,averageTime:0}),this.entityTypesAndTimes[e.type].createCount++,this.entityTypesAndTimes[e.type].totalTime+=Date.now()-a),r?this.statsInfo.entityTypesAndMeshCount[e.type]?this.statsInfo.entityTypesAndMeshCount[e.type]++:this.statsInfo.entityTypesAndMeshCount[e.type]=1:(this.statsInfo.unsupportedEntityTypes[e.type]?this.statsInfo.unsupportedEntityTypes[e.type]++:this.statsInfo.unsupportedEntityTypes[e.type]=1,qm.includes(e.type)||(this.statsInfo.unsupportedEntity[e.handle]?this.statsInfo.unsupportedEntity[e.handle]++:this.statsInfo.unsupportedEntity[e.handle]=1)),r}drawEllipse(e,t,n){if(!e.majorAxisEndPoint||!e.center||void 0===e.axisRatio||void 0===e.startAngle||void 0===e.endAngle)return;let i=e.startAngle,r=e.endAngle;if(e.extrusionDirection&&e.extrusionDirection.z<0&&(i=2*Math.PI-e.endAngle,r=2*Math.PI-e.startAngle),Zt.areNumbersEqual(i,r,1e-5))return void se.warn("[DxfLoader] Ellipse entity (handle '%s') contains the same start and end angle, ignored!",e.handle);let a=r-i;for(;a>2*Math.PI;)a-=2*Math.PI;Math.abs(a)<=1e-5&&(r=Zt.floorNumber(i+2*Math.PI,5));let s=Math.sqrt(Math.pow(e.majorAxisEndPoint.x,2)+Math.pow(e.majorAxisEndPoint.y,2)),o=s*e.axisRatio,l=Math.atan2(e.majorAxisEndPoint.y,e.majorAxisEndPoint.x),h=new Kh(e.center.x,e.center.y,s,o,i,r,!1,l),c=1,u=n;null!=u&&u.xScale&&null!=u&&u.yScale&&(c=Math.max(Math.abs(u.xScale),Math.abs(u.yScale)));let d=this.getDivision(i,r,Math.max(s,o)*c),p=h.getPoints(d),f=[],m=p.length;for(let _=0;_{e.geometry&&e.geometry.translate(c,u,0),e.layers.enableAll()})),e.rotation&&Ys.setFromAxisAngle(Zu,e.rotation*Math.PI/180),e.directionVector){let t=e.directionVector,n=new O(t.x,t.y,t.z),i=n.clone().cross(Uc),r=Uc.angleTo(n);Ys.multiply(r0e.setFromAxisAngle(Zu,i.z>0?-r:r))}return Qt.shouldRebasePositionOnRTC(Vi)&&this.setRTCUserData(s),s.matrix.compose(Vi,Ys,wy),s}getMTextGroup(e,t,n,i,r,a=0,s=0,o=[]){var l,h,c;if(0===e.length)return;let u=t.height||t.contextData&&t.contextData.textHeight||0;if(t.textStyle){if(n&&n.fontFile&&n.fontFile.endsWith(".shx")){let e=`${n.fontFile}_${n.styleName}`;this.statsInfo.unsupportedTextStyles[e]||(this.statsInfo.unsupportedTextStyles[e]=0),this.statsInfo.unsupportedTextStyles[e]++}u=u||n.textHeight}let d=t.lineSpaceFactor||1,p="Left";t.width&&t.attachmentPoint&&([1,4,7].includes(t.attachmentPoint)?p="Left":[2,5,8].includes(t.attachmentPoint)?p="Center":[3,6,9].includes(t.attachmentPoint)&&(p="Right"));let f,m,g=t.width||0,v=new bn,y=1,x=1,b=256,_=d*u*.3,w=_+u;for(let S=0;S{let t;if(e.forEach(((e,n)=>{e.boundingBox||e.computeBoundingBox(),0===n?t=e.boundingBox:t.union(e.boundingBox)})),t){let n=t.getSize(rr);switch(p){case"Left":default:break;case"Center":e.forEach((e=>e.translate((g-n.x)/2,0,0)));break;case"Right":e.forEach((e=>e.translate(g-n.x,0,0)))}}S.push(...e)};for(let t=0;t(g||1/0))a=0,s-=w,o.length>0&&T(o),o=[];else{e.boundingBox||e.computeBoundingBox();let t=e.boundingBox.getSize(rr).x;" "===i&&(t=u/2),a+=t+x*(u/6),o.push(e)}else a+=u+x*(u/6);else a=0,s-=w,o.length>0&&T(o),o=[]}o.length>0&&(T(o),o=[]);let E=new bn;if(S.length>0){f||(f=t.colorIndex),void 0!==b&&256!==b?(t.color=Wm(b),t.colorIndex=b):t.colorIndex=f;let e=this.getColor(t,i,r),n=S.filter((e=>e instanceof ta)),a=S.filter((e=>!(e instanceof ta)));if(n.length>0){let t=new bn(4);t.geometry=Ni(n),t.material=this.getMeshBasicMaterial(e),E.add(t)}if(a.length>0){let t=new bn(3);t.geometry=Ni(a),t.material=this.getLineBasicMaterial(e),E.add(t)}}E.matrix.makeTranslation(0,-u,0),v.add(E),m=void 0,y=1,x=1,b=256,d=t.lineSpaceFactor||1}else if(Array.isArray(M)){let e=this.getMTextGroup(M,t,n,i,r,a,s,o);e&&(v.add(e.object),a=e.hOffset,s=e.vOffset)}else"object"==typeof M&&(M.f&&(m=M.f,m&&m.includes(".shx")&&se.info(`[DxfLoader] Doesn't support custom fonts: ${m}`)),M.C&&(b=M.C),M.W&&(y="x"===M.W[1]?M.W[0]*t.width:M.W[0]),M.H&&(u="x"===M.H[1]?M.H[0]*t.height:M.H[0]),M.T&&(x=M.T))}return 0!==v.children.length?(Lc.merge(v,!1),f&&(t.colorIndex=f),1===v.children.length?{object:v.children[0],hOffset:a,vOffset:s}:{object:v,hOffset:a,vOffset:s}):void 0}mtextContentAndFormattingToTextAndStyle(e,t){let n={horizontalAlignment:"",textHeight:t.height||t.contextData&&t.contextData.textHeight},i={},r=1,a=[];for(let s=0;s{a.push(e)})),r=e.lineLength}else if("object"==typeof o)if(o.S&&3===o.S.length){let e=o.S[0]+"/"+o.S[2],t=this.getTextLineNum(e);a.push({text:o.S[0]+"/"+o.S[2],lineNum:r}),r+=t}else void 0!==o.C?i.C=o.C:void 0!==o.W?i.W=o.W:void 0!==o.H?i.H=o.H:void 0!==o.f&&(i.f=o.f)}return{text:a,lineLength:r,style:n}}getTextLineNum(e){let t=e.match(new RegExp("\\n","g"));return t?t.length:0}draw3DFace(e){if(!e.vertices||0===e.vertices.length)return void se.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=e.vertices.map((e=>new O(e.x,e.y,e.z)));if(0===t.length)return;Zt.areVector3sEqual(t[0],t[t.length-1])||t.push(t[0]);let n=new O,i=!1;this.enableRTC&&(i=Qt.checkAndRebasePositionsOnRTC(t,n));let r=(new Dt).setFromPoints(t),a=new bn(2);return a.geometry=r,a.material=Ea,i&&(this.setRTCUserData(a),a.matrix.setPosition(n.x,n.y,0)),a.layers.enableAll(),a}drawSpline(e,t){if(!e.controlPoints||!e.degreeOfSplineCurve||!e.knotValues)return;let n=1/0,i=1/0,r=-1/0,a=-1/0;for(let g of e.controlPoints)g.xr&&(r=g.x),g.y>a&&(a=g.y);let s=1,o=t;null!=o&&o.xScale&&null!=o&&o.yScale&&(s=Math.max(Math.abs(o.xScale),Math.abs(o.yScale)));let l=Math.max(r-n,a-i),h=this.getBSplineInterpolationsPerSplineSegment(e.controlPoints.length,l*s),c=e0t(e.controlPoints,e.degreeOfSplineCurve,e.knotValues,h),u=new O,d=!1;this.enableRTC&&(d=Qt.checkAndRebasePositionsOnRTC(c,u));let p=Qt.getAdjacentNonRepeatPoints(c);if(p.length<2)return void se.warn("[DxfLoader] Spline entity (handle '%s') contains less than 2 points, ignored!",e.handle);let f=(new Dt).setFromPoints(p),m=new bn(2);return m.geometry=f,m.material=Ea,d&&(this.setRTCUserData(m),m.matrix.setPosition(u.x,u.y,0)),m.layers.enableAll(),m}drawXLine(e){if(!e.vertices||0===e.vertices.length)return void se.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=Mt.arrayOrObjectToVector3(e.directionVector),n=new O(e.vertices[0].x,e.vertices[0].y,0),i=[];if(i.push(t.clone().multiplyScalar(-1e6).add(n)),i.push(t.clone().multiplyScalar(1e6).add(n)),0===i.length)return;let r=new O,a=!1;this.enableRTC&&(a=Qt.checkAndRebasePositionsOnRTC(i,r));let s=(new Dt).setFromPoints(i),o=new bn(2);return o.geometry=s,o.material=Ea,a&&(this.setRTCUserData(o),o.matrix.setPosition(r.x,r.y,0)),o.layers.enableAll(),o}drawRay(e){if(!e.vertices||0===e.vertices.length)return void se.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=Mt.arrayOrObjectToVector3(e.directionVector),n=e.vertices.map((e=>new O(e.x,e.y,0)));if(n.push(t.multiplyScalar(1e6).add(n[0])),0===n.length)return;let i=new O,r=!1;this.enableRTC&&(r=Qt.checkAndRebasePositionsOnRTC(n,i));let a=(new Dt).setFromPoints(n),s=new bn(2);return s.geometry=a,s.material=Ea,r&&(this.setRTCUserData(s),s.matrix.setPosition(i.x,i.y,0)),s.layers.enableAll(),s}drawLine(e){if(!e.vertices||0===e.vertices.length)return void se.warn("[DxfLoader] Entity is missing vertices:",e.handle);let t=[];if(e.isPolyfaceMesh)t=n0t(e.vertices);else{let n=O6(e.vertices,e.shape);e.shape&&n.length>0&&n.push(n[0]),n.length>0&&(t=[n])}if(0===t.length)return;let n=[];for(let s=0;s0){if(this.enableRTC){let e=0;t.forEach((t=>{t.forEach((t=>{r.add(t),e++}))})),r.divideScalar(e),a=Qt.shouldRebasePositionOnRTC(r)}let e=[],n=[],s=0,o=0,l=0,h=0;t.forEach((t=>{for(let i=0;i0&&n.push(s+i-1,s+i);s=t.length}));let c=(new Dt).setFromPoints(e);c.setIndex(n),i=new bn(3),i.geometry=c,i.material=Ea}if(n.length>0){this.enableRTC&&(a=Qt.checkAndRebasePositionsOnRTC(n,r));let e=(new Dt).setFromPoints(n);i=new bn(1),i.geometry=e,i.material=XC}return i?(a&&(this.setRTCUserData(i),i.matrix.setPosition(r.x,r.y,0)),i.layers.enableAll(),i):void 0}drawLWPolyline(e,t,n){var i,r,a;if(!e.vertices||e.vertices.length<2)return void se.warn("[DxfLoader] Invalid LWPolyline entity (handle '%s'), ignored!",e.handle);let s=e;if(void 0!==s.extrusionDirectionX&&void 0!==s.extrusionDirectionY&&void 0!==s.extrusionDirectionZ){rr.set(s.extrusionDirectionX,s.extrusionDirectionY,s.extrusionDirectionZ);let e=Zn.getOcsMatrix(rr).invert(),t=0;void 0!==s.elevation&&s.elevation>0&&(t=s.elevation),s.vertices.forEach((n=>{let i=rr.set(n.x,n.y,t).applyMatrix4(e);n.x=i.x,n.y=i.y}))}let o=O6(e.vertices,e.shape);if(e.shape&&o.length>0&&!Zt.areVector3sEqual(o[0],o[o.length-1])&&o.push(o[0]),o.length<2)return void se.warn("[DxfLoader] Invalid LWPolyline entity (handle '%s'), ignored!",e.handle);let l=new bn;if(null!=(i=e.extendedData)&&i.outlines){let t=e.extendedData.outlines,n=[];t.forEach((e=>{let t=new Ss;e.forEach(((e,n)=>{0===n?t.moveTo(e[0],e[1]):t.lineTo(e[0],e[1])})),t.closePath(),n.push(new Al(t))}));let i=Ni(n),r=new bn(4);r.geometry=i,r.material=Ty,r.layers.enableAll(),l.add(r)}let h=new O,c=!1;this.enableRTC&&(c=Qt.checkAndRebasePositionsOnRTC(o,h));let u=Qt.getAdjacentNonRepeatPoints(o);if(u.length<2)return void se.warn("[DxfLoader] Invalid LWPolyline entity (handle '%s'), ignored!",e.handle);if(this.enablePlineWidth&&void 0!==s.constantWidth&&s.constantWidth>0){let i=null==(a=null==(r=t.tables)?void 0:r.lineType)?void 0:a.lineTypes,o=i&&i[this.getLineType(e,t,n)];if(!o||!o.pattern||0===o.pattern.length){this.statsInfo.unsupportedPolylineCount++;let t=Qt.convertWidthLineToMeshGeometry(u,s.constantWidth);if(t){let e=new bn(4);e.geometry=t,e.material=Ty,e.layers.enableAll(),e.layers.disable(11),l.add(e);let n=Hn.createOutline(t,Ea,e.matrix),i=new bn(3);i.geometry=n.geometry,i.material=n.material,i.matrix=n.matrix,i.layers.enableAll(),i.layers.disable(11),l.add(i)}else se.warn("[DxfLoader] Failed to convert line with width to mesh geometry: %s",e.handle)}}let d=new bn(2);return d.geometry=(new Dt).setFromPoints(u),d.material=Ea,d.layers.enableAll(),l.children.length>0?l.add(d):l=d,c&&(this.setRTCUserData(l),l.matrix.setPosition(h)),l}drawMLeader(e,t,n){var i,r,a,s,o,l,h;let c=t.tables.dimStyle.dimStyles[e.dimensionStyle]||this.getDefaultDimensionStyle(t),u=null==(i=e.contextData)?void 0:i.defaultTextContents;if(!u)return;let d=new bn,p=wC(u),f=this.getTextStyle(t,e),m=this.getMTextGroup(p,e,f,t,n),g=m&&m.object;if(g){g.matrix.decompose(Vi,Ys,wy),null!=(r=e.contextData)&&r.textLocation&&(Vi.x+=e.contextData.textLocation.x,Vi.y+=e.contextData.textLocation.y,g.matrix.compose(Vi,Ys,wy)),Uf.makeEmpty();let t=bn.getBox(g,Uf).getSize(rr),n=t.x,i=t.y,l=0,h=0;switch(null==(a=e.contextData)?void 0:a.textAttachment){case 1:l=0,h=0;break;case 2:l-=n/2,h=0;break;case 3:l-=n,h=0;break;case 4:l=0,h+=i/2;break;case 5:l-=n/2,h+=i/2;break;case 6:l-=n,h+=i/2;break;case 7:l=0,h+=i;break;case 8:l-=n/2,h+=i;break;case 9:l-=n,h+=i;break;default:return}if(g.traverse((e=>{e.geometry&&e.geometry.translate(l,h,0)})),null!=(s=e.contextData)&&s.textRotation&&Ys.setFromAxisAngle(Zu,e.contextData.textRotation*Math.PI/180),null!=(o=e.contextData)&&o.textDirection){let t=e.contextData.textDirection,n=new O(t.x,t.y,t.z),i=n.clone().cross(Uc),r=Uc.angleTo(n);Ys.multiply(r0e.setFromAxisAngle(Zu,i.z>0?-r:r))}Qt.shouldRebasePositionOnRTC(Vi)&&this.setRTCUserData(g),g.matrix.compose(Vi,Ys,wy),g.renderOrder=5,d.add(g)}if(0===e.leaderLineType)return null==g||g.traverse((e=>{e.layers.enableAll()})),g;{let n=[],i=null==(l=e.contextData)?void 0:l.leaders[0];if(!i)return d;let r=i.lastLeaderLinePoint;if(e.enableDogLeg){let e=new O(r.x,r.y,r.z),t=i.doglegLength,a=new O(i.doglegVector.x,i.doglegVector.y,i.doglegVector.z).multiplyScalar(t),s=e.clone().add(a);n.push(s,e)}let a=(null==(h=e.contextData)?void 0:h.leaders[0].leaderLines)||[];for(let l=0;lnew O(e.x,e.y,e.z))),s=new O(r.x,r.y,r.z);for(let e=0;e{e.layers.enableAll()})),1===d.children.length?d.children[0]:d}drawLeader(e,t,n){let i=[];if(!e.vertices)return void se.warn("[DxfLoader] Entity is missing vertices:",e.handle);if(e.vertices.length<2)return void se.warn("leader's vertices number must be greater than 2");let r=t.tables.dimStyle.dimStyles[e.dimensionStyle]||this.getDefaultDimensionStyle(t),a=e.vertices;if(1===e.pathType&&(a=new vm(e.vertices).getPoints(50)),e.textWidth){let t=e.textWidth,n=new O(a[a.length-1].x,a[a.length-1].y,a[a.length-1].z);if(0===e.direction){let e=new O(1,0,0).multiplyScalar(t);a.push(e.add(n))}else{let e=new O(-1,0,0).multiplyScalar(t);a.push(e.add(n))}}for(let p=0;p0?(l.add(d),Lc.merge(l,!1),l.traverse((e=>{e.layers.enableAll()})),1===l.children.length?l.children[0]:l):(d.layers.enableAll(),d)}drawDefaultLeadArrow(e,t,n,i){let r=n*(e.x-t.x),a=n*(e.y-t.y),s=a,o=-r,l=new O(t.x+r+s/6,t.y+a+o/6,0),h=new O(t.x+r-s/6,t.y+a-o/6,0);i.push(t,l),i.push(t,h),i.push(l,h)}getBlockByHandle(e,t){if(!this.blocksCache){this.blocksCache={};for(let t in e){let n=e[t];this.blocksCache[n.ownerHandle]||(this.blocksCache[n.ownerHandle]=n)}}return this.blocksCache[t]}static updateMaterialUniforms(e){e instanceof ln&&(e.uniforms.u_cameraZoom&&(e.uniforms.u_cameraZoom=Zn.cameraZoomUniform),e.uniforms.u_viewportScale&&(e.uniforms.u_viewportScale=Zn.viewportScaleUniform))}static transformAngleByOcsMatrix(e,t){let n=rr.set(1*Math.cos(t),1*Math.sin(t),0).applyMatrix4(e);return Math.atan2(n.y,n.x)}static getArcAnglesByOcsMatrix(e,t,n){let i,r=Zt.getArcAngleSpanInRadian(t,n),a=Zn.transformAngleByOcsMatrix(e,t),s=Zn.transformAngleByOcsMatrix(e,n);if(Zt.areNumbersClose(r,Math.PI)){r=1;let n=Zn.transformAngleByOcsMatrix(e,t+r);i=Zt.getArcAngleSpanInRadian(a,n)}else{if(Zt.areNumbersClose(r,2*Math.PI))return[a,a+2*Math.PI];i=Zt.getArcAngleSpanInRadian(a,s)}return Zt.areNumbersClose(r,i,1e-5)?[a,s]:[s,a]}drawArc(e,t,n){var i,r,a;if(!e.radius||e.radius<.001)return void se.warn(`[DxfLoader] The radius of arc (handle '${e.handle}') is undefined, ignored!`);if(!e.radius||e.radius<.001)return void se.warn(`[DxfLoader] The radius of arc (handle '${e.handle}') is too small, ignored!`);let s=new O(0,0,1);void 0!==e.extrusionDirectionX&&void 0!==e.extrusionDirectionY&&void 0!==e.extrusionDirectionZ&&s.set(e.extrusionDirectionX,e.extrusionDirectionY,e.extrusionDirectionZ);let o,l,h=Zn.getOcsMatrix(s);if("CIRCLE"===e.type)o=e.startAngle||0,l=o+2*Math.PI;else{if(null==e.startAngle||null==e.endAngle||(o=e.startAngle,l=e.endAngle,Zt.areNumbersEqual(o,l,1e-6)))return;if(!Zt.areNumbersClose(Zt.getArcAngleSpanInRadian(o,l),2*Math.PI)){let e=Zn.getArcAnglesByOcsMatrix(h,o,l);o=e[0],l=e[1]}}let c=new gm(0,0,e.radius,o,l,0!==this.angBase),u=1,d=n;null!=d&&d.xScale&&null!=d&&d.yScale&&(u=Math.max(Math.abs(d.xScale),Math.abs(d.yScale)));let p=this.getDivision(o,l,e.radius*u),f=c.getPoints(p),m=new O,g=!1;this.enableRTC&&(g=Qt.checkAndRebasePositionsOnRTC(f,m));let v=(new Dt).setFromPoints(f),y=new bn(2);y.geometry=v,y.material=Ea;let x=new O;e.center&&(x.x=e.center.x,x.y=e.center.y);let b=new O(null==(i=e.center)?void 0:i.x,null==(r=e.center)?void 0:r.y,null==(a=e.center)?void 0:a.z).applyMatrix4(h.invert());x.x=b.x,x.y=b.y;let _=x,w=new bn(1);return w.geometry=e0e,w.material=XC,w.userData.handle=e.handle,w.userData.isSnapObject=!0,w.userData.type="CircleCenter",w.layers.set(11),y.add(w),g?(this.setRTCUserData(y),_.x+=m.x,_.y+=m.y):Qt.shouldRebasePositionOnRTC(_)&&this.setRTCUserData(y),y.matrix.setPosition(_),y.layers.enableAll(),y}addTriangleFacingCamera(e,t,n,i){let r=new O,a=new O;r.subVectors(n,t),a.subVectors(i,t),r.cross(a);let s=new O(t.x,t.y,t.z),o=new O(n.x,n.y,n.z),l=new O(i.x,i.y,i.z);r.z<0?e.push(l,o,s):e.push(s,o,l)}drawSolid(e,t,n){let i=e.points;if(!i||i.length<4)return;if(e.extrusionDirection&&e.extrusionDirection.z){rr.set(0,0,e.extrusionDirection.z);let t=Zn.getOcsMatrix(rr).invert();i.forEach((e=>{let n=rr.set(e.x,e.y,0).applyMatrix4(t);e.x=n.x,e.y=n.y}))}let r=[],a=[];this.addTriangleFacingCamera(r,i[0],i[1],i[2]),a.push(0,1,2),this.addTriangleFacingCamera(r,i[1],i[2],i[3]),a.push(3,4,5);let s=new O,o=!1;this.enableRTC&&(o=Qt.checkAndRebasePositionsOnRTC(r,s));let l=(new Dt).setFromPoints(r);l.setIndex(a);let h=new bn(4);return h.geometry=l,h.material=Ty,o&&(this.setRTCUserData(h),h.matrix.setPosition(s.x,s.y,0)),h.layers.enableAll(),h}getTextStyle(e,t){var n,i;let r=null==(i=null==(n=e.tables)?void 0:n.style)?void 0:i.styles;return r&&(r[t.textStyle]||r.STANDARD||r.Standard)||{}}getDefaultDimensionStyle(e){return e.tables.dimStyle.dimStyles.STANDARD||e.tables.dimStyle.dimStyles.Standard||{}}getTextEncoding(e){return(null==e?void 0:e.bigFontFile)&&e.bigFontFile.toUpperCase().startsWith("GB")?"gbk":"utf8"}getTextMesh(e,t,n,i){if(!e)return;let r=(null==n?void 0:n.styleName)||"";if(n&&n.fontFile&&n.fontFile.endsWith(".shx")){let e=`${n.fontFile}_${n.styleName}`;this.statsInfo.unsupportedTextStyles[e]||(this.statsInfo.unsupportedTextStyles[e]=0),this.statsInfo.unsupportedTextStyles[e]++}let a=.67,s={_TCH_DIM:1.45,ROMANS:1};r&&s[r]&&(a=s[r]),i.xScale&&(a*=i.xScale),r&&(a*=(null==n?void 0:n.xScale)||1,t=t||(null==n?void 0:n.textHeight)||0),0===t&&(t=r?1:.2);let o=this.createTextMeshByText(e,n,t,0,t/8);return o.traverse((e=>{e.geometry&&e.geometry.scale(a,1,1)})),o}createTextMeshByText(e,t,n=12,i=0,r=0,a=1,s=1/0){var o,l,h;let c=new bn,u=[],d=0,p=0,f=i+n;for(let m=0;ms?(d=0,p-=f):(c.boundingBox||c.computeBoundingBox(),d+=c.boundingBox.getSize(rr).x+r),u.push(c))}if(u.length>0){let e=u.filter((e=>e instanceof ta)),t=u.filter((e=>!(e instanceof ta)));if(e.length>0){let t=new bn(4);t.geometry=Ni(e),t.material=Ty,c.add(t)}if(t.length>0){let e=new bn(3);e.geometry=Ni(t),e.material=Ea,c.add(e)}}return c}transformTextMesh(e,t){Uf.makeEmpty();let n=bn.getBox(t,Uf).getSize(rr),{halign:i,valign:r}=e;t.matrix.decompose(YC.position,YC.quaternion,YC.scale);let a=YC,s=e.width||e.textWidth||n.x,o=e.height||e.textHeight||n.y;if(void 0===i&&void 0===r&&e.startPoint||[3,5].includes(i)&&e.startPoint?(a.position.x+=e.startPoint.x,a.position.y+=e.startPoint.y,a.position.z+=e.startPoint.z):e.endPoint&&(a.position.x+=e.endPoint.x,a.position.y+=e.endPoint.y,a.position.z+=e.endPoint.z),3!==i&&5!==i){if(e.rotation){let t=e.rotation*Math.PI/180;a.rotateZ(t)}2===e.mirrored?a.rotateY(Math.PI):4===e.mirrored&&a.rotateX(Math.PI)}switch(i){case 0:default:break;case 1:a.translateX(-s/2);break;case 2:a.translateX(-s);break;case 3:if(e.startPoint&&e.endPoint){let t=new O(e.startPoint.x,e.startPoint.y,e.startPoint.z),n=new O(e.endPoint.x,e.endPoint.y,e.endPoint.z),i=(new O).subVectors(t,n),r=i.length()/s;a.scale.multiplyScalar(r);let o=i.clone().cross(Uc),l=i.angleTo(Uc);a.rotateZ(o.z>0?Math.PI-l:l-Math.PI),(2===e.mirrored||4===e.mirrored)&&a.rotateX(Math.PI)}break;case 4:a.translateX(-s/2),a.translateY(-o/2);break;case 5:if(e.startPoint&&e.endPoint){let t=new O(e.startPoint.x,e.startPoint.y,e.startPoint.z),n=new O(e.endPoint.x,e.endPoint.y,e.endPoint.z),i=(new O).subVectors(t,n),r=i.length()/s;a.scale.setX(r);let o=i.clone().cross(Uc),l=i.angleTo(Uc);a.rotateZ(o.z>0?Math.PI-l:l-Math.PI),(2===e.mirrored||4===e.mirrored)&&a.rotateX(Math.PI)}}switch(r){case 0:case 1:default:break;case 2:a.translateY(-o/2);break;case 3:a.translateY(-o)}return a.position.z=0,a.updateMatrix(),t.matrix.copy(a.matrix),t}drawText(e,t,n){let i=e.text;if(!i)return;if(!this.font)return void se.info("[DxfLoader] Font file not set, ignoring text entity.");let r=this.getTextStyle(t,e);i=SC(i,{encoding:this.getTextEncoding(r)}).map((e=>e.text)).join("");let a=this.getTextMesh(i,e.textHeight,r,e);if(!a||0===a.children.length)return;this.transformTextMesh(e,a),rr.set(a.matrix.elements[12],a.matrix.elements[13],a.matrix.elements[14]);let s=Qt.shouldRebasePositionOnRTC(rr);return s&&this.setRTCUserData(a),a.traverse((e=>{let t=e.geometry;if(t){if(e instanceof xt&&!t.getIndex()){let e=t.getAttribute("position"),n=[];for(let t=0;te.text)).join();let a=this.getTextMesh(i,e.textHeight,r,e);if(!a||0===a.children.length)return;this.transformTextMesh(e,a),rr.set(a.matrix.elements[12],a.matrix.elements[13],a.matrix.elements[14]);let s=Qt.shouldRebasePositionOnRTC(rr);return s&&this.setRTCUserData(a),a.traverse((e=>{let t=e.geometry;if(t){if(e instanceof xt&&!t.getIndex()){let e=t.getAttribute("position"),n=[];for(let t=0;te.text)).join();let a=this.getTextMesh(i,e.textHeight,r,e);if(!a||0===a.children.length)return;this.transformTextMesh(e,a),rr.set(a.matrix.elements[12],a.matrix.elements[13],a.matrix.elements[14]);let s=Qt.shouldRebasePositionOnRTC(rr);return s&&this.setRTCUserData(a),a.traverse((e=>{let t=e.geometry;if(t){if(e instanceof xt&&!t.getIndex()){let e=t.getAttribute("position"),n=[];for(let t=0;t0&&(e.colorIndex=i.DIMCLRD,e.color=Wm(e.colorIndex));let r=new bn;for(let s=0;s`,r.userData.entityType=e.type;let a=null==e?void 0:e.insertionPoint;return rr.set(0,0,0),a&&rr.set(a.x,a.y,0),Qt.shouldRebasePositionOnRTC(rr)&&this.setRTCUserData(r),r.matrix.setPosition(rr),r}drawImage(e,t,n){var i;if(!e.imageSize||null==(i=t.objects.IMAGEDEF)||!i.length)return;let r=t.objects.IMAGEDEF.filter((t=>t.handle===e.imageDefHandle))[0];if(!r)return;console.log(e,r);let a=e.imageSize.x,s=e.imageSize.y,o=new bn,l=!1;2===e.flags||4===e.flags||8===e.flags||(l=!0);let h=new ui(a,s);if(l){let e=new Rs(this.manager).load(r.filename,void 0,void 0,(()=>{console.warn("Please upload the pictures in the same folder, or use url link in the dxf file.")}));e.colorSpace=tn;let t=new on({transparent:!0,side:pi,map:e}),n=new bn(4);n.geometry=h,n.material=t,o.add(n)}let c=new Cu(h),u=this.getColor(e,t,n),d=new bn(2);d.geometry=c,d.material=this.getLineBasicMaterial(u);let p=e.uPixel?new O(e.uPixel.x,e.uPixel.y,e.uPixel.z):new O(r.pixelSize.x,0,0),f=e.vPixel?new O(e.vPixel.x,e.vPixel.y,e.vPixel.z):new O(r.pixelSize.y,0,0);if(o.add(d),Vi.set(p.x,f.y,1),rr.set(0,0,0),e.position){let t=new O(e.position.x,e.position.y,e.position.z);t.add(p.multiplyScalar(a/2)).add(f.multiplyScalar(s/2)),rr.copy(t)}return Qt.shouldRebasePositionOnRTC(rr)&&this.setRTCUserData(o),Ys.identity(),o.matrix.compose(rr,Ys,Vi),o}drawInsert(e,t,n=!1){var i,r;if(!e.block)return;let a=t.blocks[e.block];if(!a.entities)return;e.blockPosition=a.position;let s=new bn;for(let u=0;u`,s.userData.entityType=e.type,null!=(i=e.extendedData)&&i.originalType&&(s.userData.originalType=null==(r=e.extendedData)?void 0:r.originalType),null!=e&&e.blockPosition&&s.matrix.setPosition(-e.blockPosition.x,-e.blockPosition.y,0);let o=rr.set(1,1,1);e.xScale&&(o.x=e.xScale),e.yScale&&(o.y=e.yScale);let l=new Xn;e.rotation&&(l.z=e.rotation*Math.PI/180),Ys.setFromEuler(l,!1);let h=Vi.set(0,0,0);e.position&&(h.x=e.position.x,h.y=e.position.y),_o.compose(h,Ys,o),e.extrusionDirection&&e.extrusionDirection.z<0&&_o.premultiply(t0e.identity().makeScale(-1,1,1)),n0e.copy(s.matrix),s.matrix.premultiply(_o),Vi.set(s.matrix.elements[12],s.matrix.elements[13],s.matrix.elements[14]),Qt.shouldRebasePositionOnRTC(Vi)&&this.setRTCUserData(s);let c=this.findSpatialFilterByHandle(e.handle,t);if(c){this.drawSpatialFilter(c);let t=c;t&&t.clipPolylines&&t.clipPolylines.length>0&&(s.userData.spatialFilterHandle=c.handle,this.cloneMaterialsForSpatialFilter(s),se.debug("[DxfLoader] Spatial filter:",e.associatedSpatialFilter))}return s}drawSpatialFilter(e){let t=e;if(t.threejsObject)return t.threejsObject.clone();let n=e.invertBlockMatrix;_o.set(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11],0,0,0,1);let i=[];e.vertices.forEach((e=>{i.push(new O(e.x,e.y,0))}));let r={polyline:[],bConcave:!1,bReversed:!1};if(2===e.numberOfPointsOnClipBoundary)r.polyline=i;else{let t=e.numberOfPointsOnClipBoundary,n=3;if(te;r--){let o=i[r];if(Zt.areVector3sEqual(n,o)&&e+10)break;a.push(n)}if(s>0)for(let e=s+1;e{o.push(new be(e.x,e.y)),l.push([e.x,e.y])})),!Qt.isConvex(o)){se.warn(`[DxfLoader] Concave polygon is not supported for spatial filter (handle '${e.handle}'), converting to convex polygon!`);let t=(0,c0e.default)(l,1/0);a=[],t.forEach((e=>{a.push(new O(e[0],e[1],0))}))}Zt.areVector3sEqual(a[0],a[a.length-1])||a.push(a[0]),r.polyline=a,r.bReversed=s>0}return this.enableReleaseData&&(e.vertices=[],e.matrix=[],e.invertBlockMatrix=[]),t.localMatrix=_o.clone(),t.clipPolylines=[],void t.clipPolylines.push(r)}drawLayout(e,t,n,i,r,a){if(!e.entities)return;let s=new bn;for(let h=0;h{if(e.geometry){let t=e.userData.layerName,i=r[t];i||(i=[],r[t]=i),i.push(e),e.userData.isSnapObject&&(this.layoutsSnapObjectsMap[n.layoutName]||(this.layoutsSnapObjectsMap[n.layoutName]=[]),this.layoutsSnapObjectsMap[n.layoutName].push(e))}})))}if(0===s.children.length)return;s.userData.layerName=e.layer;let o=n.layoutName,l=i.children.find((e=>e.name===o));l||(l=new bn,l.name=o,l.userData.isLayoutLevelObject=!0,i.add(l)),l.add(s),e.position&&s.matrix.setPosition(e.position.x,e.position.y,e.position.z||0)}convertEdgeToPoints(e){let t=[];switch(e.type){case 1:{let n=e;t.push(new be(n.startPoint.x,n.startPoint.y)),t.push(new be(n.endPoint.x,n.endPoint.y));break}case 2:{let n=e,i=n.startAngle*An.DEG2RAD,r=n.endAngle*An.DEG2RAD;n.bCounterclockwise||(i=2*Math.PI-i,r=2*Math.PI-r);let a=new gm(n.center.x,n.center.y,n.radius,i,r,!n.bCounterclockwise),s=this.getDivision(i,r,n.radius);t.push(...a.getPoints(s));break}case 3:{let n=e,i=Math.sqrt(Math.pow(n.majorAxisEndPoint.x,2)+Math.pow(n.majorAxisEndPoint.y,2)),r=i*n.minorRatio,a=Math.atan2(n.majorAxisEndPoint.y,n.majorAxisEndPoint.x),s=n.startAngle*An.DEG2RAD,o=n.endAngle*An.DEG2RAD;n.bCounterclockwise||(s=2*Math.PI-s,o=2*Math.PI-o);let l=new Kh(n.center.x,n.center.y,i,r,s,o,!n.bCounterclockwise,a),h=this.getDivision(s,o,Math.max(i,r));t.push(...l.getPoints(h));break}case 4:{let n=e;t.push(...n.controlPoints);break}case 0:{let n=e;t.push(...O6(n.points,n.isClosed));break}}return t}drawHatch(e,t,n){var i;let r=e;if(0==r.boundaryPaths.length)return;let a=[],s=[],o=[],l=e=>{let t=[],n=[];n.push(...this.convertEdgeToPoints(e[0]));for(let i=1;i2){let a=this.convertEdgeToPoints(e[i-1]);Zt.areVector2sEqual(a[a.length-1],r[0])?Zt.areVector2sEqual(n[0],r[r.length-1],1e-5)&&(t.push(n),n=[]):Zt.areVector2sEqual(a[0],r[r.length-1])?Zt.areVector2sEqual(n[1],r[0],1e-5)&&(t.push(n),n=[]):n=[]}}return t};if(r.boundaryPaths.forEach(((e,t)=>{let n=[];if(this.IsfilteredByPathTypeFlag(e.pathTypeFlag)){let n="[DxfLoader] The %d path type flag is filtered at the %dth boundrayPath (hatch handle '%s')";return void se.info(n,e.pathTypeFlag,t,r.handle)}let i=e.edges;if(0===i.length)return;let h=[];for(let a=0;a31&&(!(e=>{for(let t=1;t{Zt.areVector2sEqual(e[0],e[e.length-1])||e.push(e[0]);let t=e.map((e=>new be(Mt.roundNumber(e.x,7),Mt.roundNumber(e.y,7))));if((null==t?void 0:t.length)>0){a.push(t);let e=(new Ji).setFromPoints(t);s.push(e);let n=e.getSize(o_),i=n.x*n.y;o.push({area:i,index:a.length-1})}}))})),0===a.length)return;let h=new be,c=this.checkAndRebasePolygonsOnRTC(a,h);o.sort(((e,t)=>e.area-t.area));let u=[];o.forEach((e=>{u.push(e.index)}));let d,p=this.buildContainHierarchyTree(a,s,u),f=[];if(this.buildHatchGeometry(a,p,f),f.length>0&&(d=Ni(f)),!d||!d.getIndex()||0===(null==(i=d.getIndex())?void 0:i.count))return void se.warn("[DxfLoader] Failed to convert hatch boundaries!");let m=new bn(4);m.geometry=d,m.material=Ty,this.setHatchMaterial(m,r,t,h,n);let g=m;return c&&(this.setRTCUserData(g),g.matrix.setPosition(h.x,h.y,0)),g.traverse((e=>{e.layers.enableAll(),e.layers.disable(11)})),g}drawOle2frame(e,t){let{leftUpX:n,leftUpY:i,rightDownX:r,rightDownY:a}=e;if(!(n&&i&&r&&a))return;let s=[new be(n,i),new be(n,a),new be(r,a),new be(r,i),new be(n,i)],o=new O,l=!1;this.enableRTC&&(l=Qt.checkAndRebasePositionsOnRTC(s,o));let h=(new Dt).setFromPoints(s),c=this.getLineBasicMaterial(16777215),u=new bn(2);u.geometry=h,u.material=c,u.layers.enableAll(),l&&(this.setRTCUserData(u),u.matrix.setPosition(o.x,o.y,0));let d=new bn;d.add(u);let p,f,m=t.objects.DICTIONARY;for(let g of m){let t=g;for(let n in t.entries)if(t.entries[n]===e.handle){p=n;break}}if(p)if(this.meshTextureMaterials[p])f=this.meshTextureMaterials[p];else for(let g=0;g1?d:u}static getOcsMatrix(e){let t=Uc,n=D6,i=Zu,r=new O(0,1,0),a=new O(0,0,1);return Zt.areVectorsClose(e,a)?_o.identity():(i=e.clone().normalize(),Zt.areVectorsClose(i,a)||(t=Math.abs(i.x)<1/64&&Math.abs(i.y)<1/64?r.cross(i).normalize():a.cross(i).normalize(),n=i.clone().cross(t).normalize()),_o.set(t.x,t.y,t.z,0,n.x,n.y,n.z,0,i.x,i.y,i.z,0,0,0,0,1))}static getDcs2WcsMatrix(e,t){let n;n=Kgt(e)?e.viewDirectionFromTarget:e.viewDirection;let i,r,a,s=new O(Zt.roundNumber(n.x,7),Zt.roundNumber(n.y,7),n.z),o=new O(e.viewTarget.x,e.viewTarget.y,e.viewTarget.z),l=e.viewTwistAngle||0;a=s.clone().normalize(),i=Zu.clone().cross(s),i.length()>0?(i.normalize(),r=a.clone().cross(i)):a.z<0?(i=Uc.clone().negate(),r=D6,a=Zu.clone().negate()):(i=Uc,r=D6,a=Zu);let h=new et,c=_o.identity();return c.makeBasis(i,r,a),h.premultiply(c),h.premultiply(_o.identity().compose(o.clone(),(new dr).setFromAxisAngle(new O(0,0,1),An.degToRad(t?l:-l)),new O(1,1,1))),h}getViewportMsToPsMatrix(e){let t=new O(e.centerPoint_dcs.x,e.centerPoint_dcs.y,0),n=new O(e.centerPoint.x,e.centerPoint.y,e.centerPoint.z),i=e.viewHeight/e.height_paperSpace,r=Zn.getDcs2WcsMatrix(e,this.angDir),a=new et;a.setPosition(Qge.clone().sub(n));let s=t0e.identity();s.scale(rr.set(i,i,i));let o=n0e.identity().setPosition(Qge.clone().sub(n));s.premultiply(o.clone().invert()).multiply(o),a.multiply(s);let l=_o.identity();l.setPosition(t),r.multiply(l);let h=_o.identity();return a.invert().multiply(h).multiply(r.invert())}drawViewport(e,t,n){let i=e;if("1"==i.viewportId)return e.psBBox=new Ot,void(e.msToPsMatrix=new et);let r=[],a=i.centerPoint,s=i.width_paperSpace/2,o=i.height_paperSpace/2;r.push(new O(a.x-s,a.y-o,0)),r.push(new O(a.x-s,a.y+o,0)),r.push(new O(a.x+s,a.y+o,0)),r.push(new O(a.x+s,a.y-o,0)),r.push(r[0]),e.psBBox=new Ot(r[0],r[2]),e.msToPsMatrix=this.getViewportMsToPsMatrix(i);let l=new O,h=!1;this.enableRTC&&(h=Qt.checkAndRebasePositionsOnRTC(r,l));let c=(new Dt).setFromPoints(r),u=new bn(2);u.geometry=c,u.material=Ea,h&&(this.setRTCUserData(u),u.matrix.setPosition(l.x,l.y,0)),u.userData.entityType=e.type,u.layers.enableAll();let d=new bn;d.add(u);let p=e.psBBox.clone();p.applyMatrix4(e.msToPsMatrix.clone().invert()),p.min.z=0,p.max.z=0;let f=[];f.push(p.min),f.push(new O(p.min.x,p.max.y,0)),f.push(p.max),f.push(new O(p.max.x,p.min.y,0)),f.push(f[0]);let m=new O,g=!1;this.enableRTC&&(g=Qt.checkAndRebasePositionsOnRTC(f,m));let v=(new Dt).setFromPoints(f),y=new bn(2);return y.geometry=v,y.material=Ea,g&&(this.setRTCUserData(y),y.matrix.setPosition(m.x,m.y,0)),y.userData.entityType=e.type,y.userData.inPaperSpace=!0,y.layers.enableAll(),d.add(y),u}getColor(e,t,n){var i,r,a,s;if(this.compareContext)return hs.ENTITY_COLOR_NO_CHANGE;if(null!=this.overrideColor)return this.overrideColor;let o=e;if(o&&o.isGradientColor){let t=o.gradientColors;if(t&&t.length>=2){if(t[0]!==t[1]){let t=`[DxfLoader] Gradient colors are not supported for hatch '${e.handle}', will use the first color!`;se.warn(t)}return t[0]}}if(e.isTrueColor||e.colorIndex>0&&e.colorIndex<256)return e.color;if(0===e.colorIndex)return n?this.getColor(n,t):null==(r=null==(i=t.tables)?void 0:i.layer)?void 0:r.layers[0].color;if(256===e.colorIndex){let i=null==(s=null==(a=t.tables)?void 0:a.layer)?void 0:s.layers,r=i&&i[e.layer],o=i&&n&&i[n.layer],l=Hf;return r&&"0"!==r.name?l=r.color:o?l=o.color:r?l=r.color:i&&i[0].color&&(l=i[0].color),l}return se.warn("[DxfLoader] Unknown colorIndex"),Hf}getLineType(e,t,n){var i,r;if(n&&"DIMENSION"===n.type)return this.getLineType(n,t);if(e.lineType!==iy&&e.lineType!==sy)return e.lineType;if(e.lineType===sy)return n?this.getLineType(n,t):e.lineType;let a=null==(r=null==(i=t.tables)?void 0:i.layer)?void 0:r.layers,s=Zgt;if("0"!==e.layer){let t=a&&a[e.layer];if(t)return t.lineType}else if(n){let e=a&&a[n.layer];if(e)return e.lineType}return s}getLayerName(e,t,n){var i,r;let a=t=>{s&&t&&!s[e.layer]&&(console.warn(`[DxfLoader] Failed to find layer object for '${t}', adding a default one.`),s[t]={name:t,handle:"",colorIndex:256,lineType:"",visible:!0})},s=null==(r=null==(i=t.tables)?void 0:i.layer)?void 0:r.layers;a(e.layer);let o=s&&s[e.layer];a(null==n?void 0:n.layer);let l=s&&n&&s[n.layer],h=(null==o?void 0:o.name)||"";return o&&"0"===o.name&&l&&(h=l.name),h}setMaterial(e,t,n,i){var r,a;let s=e;if(!s.geometry||(this.setRenderOrderByObjectType(e),"OLE2FRAME"===t.type))return;if("MTEXT"===t.type)return void(e.renderOrder=5);if("HATCH"===t.type)return o_.set(0,0),void this.setHatchMaterial(e,t,n,o_,i);if("IMAGE"===t.type)return;let o,l=this.getColor(t,n,i);if("LWPOLYLINE"===t.type&&(s.isMesh?(o=this.getMeshBasicMaterial(l),e.renderOrder=1):e.userData.isOutline&&(o=this.getLineBasicMaterial(l),e.renderOrder=3),o))s.material=o;else{if("SOLID"===t.type)o=this.getMeshBasicMaterial(l);else if("TEXT"===t.type||"ATTDEF"===t.type||"ATTRIB"===t.type)o=this.getLineBasicMaterial(l),e.renderOrder=5;else if("LEADER"===t.type||"MULTILEADER"===t.type||"VIEWPORT"===t.type)o=this.getLineBasicMaterial(l);else if("POINT"===t.type)o=this.getPointsMaterial(l);else{if(e.material instanceof xi)return o=this.getPointsMaterial(l),void(s.material=o);let h=null==(a=null==(r=n.tables)?void 0:r.lineType)?void 0:a.lineTypes,c=h&&h[this.getLineType(t,n,i)];if(c&&c.pattern&&0!==c.pattern.length){let n=t.lineTypeScale||1;o=this.getLineShaderMaterial(c,l,n),e.renderOrder=3}else o=this.getLineBasicMaterial(l)}s.material=o}}setHatchMaterial(e,t,n,i,r){let a=e;if(!a.geometry)return;let s=this.getColor(t,n,r);if(2===a.type||3===a.type)return void(a.material=this.getLineBasicMaterial(s));let o,l=-1;if(t.solidFill)o=this.getMeshBasicMaterial(s);else{if(a.material instanceof ln){o=a.material;let e=new ct(s);a.material.uniforms.u_color.value.equals(e)||(o=a.material.clone(),Zn.updateMaterialUniforms(o),o.uniforms.u_color.value.set(s))}else o=this.getHatchShaderMaterial(t,s,i);l=0}o||(o=this.getMeshBasicMaterial(s),l=-1),a.material=o,a.renderOrder=l}setRenderOrderByObjectType(e){let t=e,n=0;t.isMesh?n=-1:t.isLine?n=2:t.isPoints&&(n=4),e.renderOrder=n}getPointsMaterial(e){return this.pointsMaterials[e]||(this.pointsMaterials[e]=new xi({size:.2,color:e})),this.pointsMaterials[e]}getLineBasicMaterial(e){return this.lineBasicMaterials[e]||(this.lineBasicMaterials[e]=new Gn({color:e})),this.lineBasicMaterials[e]}getLineShaderMaterial(e,t,n){let i=`${e.name}_${t}_${n}`;if(!this.lineShaderMaterials[i]){let r=this.getLineTypeScales(),a=r.ltScale*r.celtScale*n;this.lineShaderMaterials[i]=TC.createLineShaderMaterial(e.pattern,t,a,Zn.viewportScaleUniform,Zn.cameraZoomUniform)}return this.lineShaderMaterials[i]}getMeshBasicMaterial(e){return this.meshBasicMaterials[e]||(this.meshBasicMaterials[e]=new on({color:e})),this.meshBasicMaterials[e]}getHatchShaderMaterial(e,t,n){if(!e.patternLines||e.patternLines.length<1)return;let i=this.findMatchedHatchShaderMaterial(e,t);if(i)return i;let r=2;e.patternLines.forEach((e=>{r=Math.max(e.dashPattern.length,r)}));let a=0,s=[],o=new be;for(let h of e.patternLines){let t=new be(h.origin.x,h.origin.y).sub(n).rotateAround(o,-An.degToRad(e.patternAngle)),i=new be(h.delta.x,h.delta.y).rotateAround(o,-An.degToRad(h.angle));if(0===i.y)return void se.warn("[DxfLoader] delta.y is equal to zero !");let l=h.dashPattern.length,c=!0,u=0;for(let e=0;e0&&(c=!1),u+=Math.abs(t)}let d=c?.05:.005,p=[],f=[],m=0;f[0]=m;for(let e=0;eZn.maxFragmentUniforms){se.warn("[DxfLoader] There will be warning in fragment shader when number of uniforms exceeds 1024, so extra hatch line patterns are ignored here!");break}s.push(g)}let l=ume(s,e.patternAngle,Zn.cameraZoomUniform,new ct(t));return l.defines={MAX_PATTERN_SEGMENT_COUNT:r},this.hatchShaderMaterials.push({patternLines:e.patternLines,patternAngle:e.patternAngle,color:t,material:l}),l}getDivision(e,t,n){let i=Math.round(5e4/this.entityCount);i=Math.max(i,2),i=Math.min(i,10);let r=5*i,a=2*i;this.averageCurveSize&&(a*=Math.pow(n/this.averageCurveSize,.5),a=Math.max(a,i),a=Math.min(a,r));let s=t-e;s<0&&(s+=2*Math.PI),a=Math.ceil(a*(s/Math.PI));let o=8;return s<.087?o=2:s<.174?o=3:s<.52?o=4:s<1.57?o=5:s<3.14?o=6:s<4.71&&(o=7),a=Math.max(a,o),this.averageCurveSize=(this.averageCurveSize*this.curveCount+n)/(this.curveCount+1),this.curveCount++,Math.max(a,12)}getBSplineInterpolationsPerSplineSegment(e,t){let n=1;this.averageCurveSize&&(n=Math.pow(t/this.averageCurveSize,.5),n=Math.max(n,.5),n=Math.min(n,2)),this.averageCurveSize=(this.averageCurveSize*this.curveCount+t)/(this.curveCount+1),this.curveCount++;let i=2*e*n;return e>20&&(i/=Math.log10(e)),i}setDxfDataToIndexedDb(e,t){return ft(this,null,(function*(){let n={dxfDataId:e,dxf:t};return new Promise(((t,i)=>{gy.instance().add(n,(()=>{se.info(`[DxfLoader] Saved '${e}' to indexedDb`),t()}),(e=>{i(e)}))}))}))}getDxfDataFromIndexedDb(e){return ft(this,null,(function*(){return new Promise(((t,n)=>{gy.instance().query(e,(e=>{e&&e.length>0&&t(e[0].dxf),t(void 0)}),(()=>n()))}))}))}buildContainHierarchyTree(e,t,n){var i;let r=new Map,a=n.length;for(let o=0;o{0===e.children.length?i.push(e.index):r.set(e.index,e.children.map((e=>e.index)))}));let a=e=>{try{let t=new Al(e);t.hasAttribute("uv")&&t.deleteAttribute("uv"),t.hasAttribute("normal")&&t.deleteAttribute("normal"),n.push(t)}catch(t){se.warn(`[DxfLoader] triangulate shape error: ${e.getPoints().map((e=>e.toArray())).toString()}`)}};i.forEach((t=>{let n=e[t];if(0===n.length)return;let i=new Ss(n);a(i)}));let s=e=>e.map((e=>e.toArray()));for(let o of r){let t=new Ss(e[o[0]]),n={regions:[],inverted:!1},i=this.findIntersectHole(e,o[1]);i.forEach((i=>{let r={regions:[],inverted:!1};try{i.forEach(((i,a)=>{if(Vl.epsilon(Zt.getVector2RelativeEps(e[i][0]),1e-6),0===a)r=Vl.segments({regions:[s(e[i])],inverted:!1});else{let a=Vl.segments({regions:[s(e[i])],inverted:!1}),o=Vl.combine(r,a);n=Vl.polygon(Vl.selectUnion(o)),n.regions.length>0?n.regions.forEach((e=>{if(0===e.length)return;let n=e.map((e=>new be(e[0],e[1])));t.holes.push(new Ru(n))})):se.warn("[DxfLoader] mergedHoles.regions is empty")}}))}catch(e){se.warn(`[DxfLoader] polybooljs has error: ${e}, epsilon is ${Vl.epsilon()}`)}}));let r=i.flat(2);for(let a=0;a{t.children.forEach((t=>{this.buildHatchGeometry(e,t,n)}))}))}findIntersectHole(e,t){let n=t.length,i=[];for(let r=0;r{e.forEach((e=>{t.add(e),n++}))})),t.divideScalar(n);let i=!1;if(this.enableRTC&&Qt.shouldRebasePositionOnRTC(t)){i=!0;for(let n=0;n{e.entries[n]&&"ACAD_SORTENTS"===e.entries[n]&&t.add(n)}))}if(0===t.size)return;let i=e.objects.SORTENTSTABLE;if(i)for(let r=0;rMath.abs(e-t)<1e-5,r=(e,t)=>i(e.angle,t.angle)&&i(e.delta.x,t.delta.x)&&i(e.delta.y,t.delta.y)&&i(e.origin.x,t.origin.x)&&i(e.origin.y,t.origin.y)&&((e,t)=>{if(e.length!==t.length)return!1;for(let n=0;ni.color===t&&i.patternAngle===e.patternAngle&&((e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n{t[e.handle]=e.layoutHandle}))}let r=this.blockRecordsCache[t.ownerHandle];if(r){let t=e.objects.LAYOUT.find((e=>e.handle===r));if(t)return t}if(!this.entitiesCache){this.entitiesCache={};let t=this.entitiesCache;Object.values(e.entities).forEach((e=>{t[e.handle]=e}))}let a=this.entitiesCache[t.ownerHandle];return a?this.getLayout(e,a):(se.warn("[DxfLoader] Failed to find layout name for entity:",t),e.objects.LAYOUT.find((e=>e.layoutName===Zn.MODEL_LAYOUT_NAME)))}getLayerVisible(e,t){var n,i,r;let a=null==(i=null==(n=e.tables)?void 0:n.layer)?void 0:i.layers;return a&&(null==(r=a[t])?void 0:r.visible)}getLayerFrozen(e,t){var n,i,r;let a=null==(i=null==(n=e.tables)?void 0:n.layer)?void 0:i.layers;return a&&(null==(r=a[t.layer])?void 0:r.frozen)}cloneMaterialsForSpatialFilter(e){let t=new Map;e.traverse((e=>{e.material&&(e.material=(e=>{let n;return Array.isArray(e)?(n=[],e.forEach((e=>{if(t.has(e.id))n.push(t.get(e.id));else{let i=e.clone();Zn.updateMaterialUniforms(i),t.set(e.id,i),n.push(i)}}))):e&&(t.has(e.id)?n=t.get(e.id):(n=e.clone(),Zn.updateMaterialUniforms(n),t.set(e.id,n))),n})(e.material))}))}getLineTypeScales(){let e={ltScale:1,celtScale:1};return this.header&&(e.ltScale=this.header.$LTSCALE||1,e.celtScale=this.header.$CELTSCALE||1),e}static getDxfUnits(e){switch(e||0){case 0:return"Unitless";case 1:return"Inches";case 2:return"Feet";case 4:return"Millimeters";case 5:return"Centimeters";case 6:return"Meters";default:se.warn(`[DxfLoader] Unsupported $INSUNITS '${e}'`)}return"Unitless"}static computeLineDistance(e){let t=!0===e.isLineSegments,n=e.geometry,i=e.matrixWorld;if(n.index&&(se.debug(`[DxfLoader] Line with id '${e.id}' contains index buffer, going to convert it to non-indexed.`),n=Qt.convertGeometryWithIndexedToNonIndexed(n),e.userData.batches&&e.userData.batches.length>0)){se.debug("[DxfLoader] This line has been merged!");let t=0;e.userData.batches.forEach((e=>{e.positionStart=t,e.positionCount=e.indexCount,e.indexStart=0,e.indexCount=0,t+=e.positionCount}))}if(null===n.index){let r=n.attributes.position;if(!r||0===r.count)return;let a=[];if(t)for(let e=0,t=r.count;e{let t=e;t.isLine&&t.material instanceof ln&&Zn.computeLineDistance(t)})),se.debug(`[DxfLoader] Computed line distances in ${(Date.now()-t)/1e3}s`)}static mergeDxfObjects(e){let t=Date.now(),n={},i={},r=0,a=0,s=()=>{let e=Date.now();for(let t in n){let e=n[t];Zn.removeEmptyObjectsFromRemovingMarkedObjects2(e.children,e.object),e.children=[]}r=0,a+=Date.now()-e};for(let l in e.layersAndObjects){let t=e.layersAndObjects[l];if(t.length<=1)continue;let o=Date.now(),h={},c=[];for(let e of t){if(e.userData.isSnapObject){c.push(e);continue}let t,n=e;for(;n;){if(n.userData.isLayoutLevelObject){t=n;break}n=n.parent}if(!t)continue;let i=t.name;h[i]||(h[i]={object:t,children:[]}),h[i].children.push(e)}for(let e in h){let t=h[e],o=Lc.deepMerge(t.children,t.object,!1,!1,!0),l=o.added,u=o.removed;n[e]||(n[e]={object:t.object,children:[]}),i[e]||(i[e]={object:t.object,children:[]});let d=u.length>15e3;if(d){let e=Date.now();Zn.removeEmptyObjectsFromRemovingMarkedObjects2(u,t.object),a+=Date.now()-e}else r+=u.length;if(u.length===t.children.length)d||u.forEach((t=>{n[e].children.push(t)}));else{let i=u;u.length>=100&&(i=new Set(u));let r=e=>Array.isArray(i)?i.indexOf(e)>=0:i.has(e);for(let a=0;a15e3&&s()}e.layersAndObjects[l]=c,se.debug(`[DxfLoader] Merged layer '${l}' in ${(Date.now()-o)/1e3}s`)}r>0&&s();for(let l in i){let t=i[l];e.root.children.find((e=>e.name===l))||e.root.add(t.object),t.children.forEach((e=>{t.object.add(e)})),t.children=[]}se.debug(`[DxfLoader] MergeUtils.deepMerge costed ${Ar.mergeInfo.elapsedTime/1e3}s`),se.debug(`[DxfLoader] The remove operation of deep merge costed ${a/1e3}s`),se.debug(`[DxfLoader] Deep merge totally costed ${(Date.now()-t)/1e3}s`);let o=Ar.mergeInfo;se.debug(`[DxfLoader] Totally merged ${o.removedObjects} objects to ${o.mergedMeshes} meshes, ${o.mergedLines} lines, ${o.mergedPoints} points, ${o.mergedUnknownTypeObjects?o.mergedUnknownTypeObjects+" unknown type,":""} `)}static merge(e,t){return ft(this,null,(function*(){let n=Mt.getUpdateProgressFuncAsync(t),i={};e.objects.LAYOUT.forEach((e=>{var t;let n=e;i[n.layoutName]=n,null==(t=n.directAssociatedLeafObjectSet)||t.clear()}));let r=Date.now(),a={},s={},o=0,l=0,h=()=>{let e=Date.now();for(let t in a){let e=a[t];Zn.removeEmptyObjectsFromRemovingMarkedObjects(e.children,e.object),e.children=[]}o=0,l+=Date.now()-e},c=Object.keys(e.layersAndThreejsObjects).length,u=0;for(let t in e.layersAndThreejsObjects){let r=e.layersAndThreejsObjects[t];if(r.length<=1){yield n(++u/c*100);continue}let d=Date.now(),p={},f=[];for(let e of r){if(e.userData.isSnapObject){f.push(e);continue}let t,n=e;for(;n;){if(n.userData.isLayoutLevelObject){t=n;break}n=n.parent}if(!t)continue;let i=t.name;p[i]||(p[i]={object:t,children:[]}),p[i].children.push(e)}let m=Object.keys(p).length,g=0;for(let e in p){let t;if(e!==Zn.MODEL_LAYOUT_NAME){let n=i[e];n.directAssociatedLeafObjectSet||(n.directAssociatedLeafObjectSet=new Set),t=n.directAssociatedLeafObjectSet}let r=p[e],d=Ar.deepMerge(r.children,r.object,!1,!1,!0),v=d.added,y=d.removed;a[e]||(a[e]={object:r.object,children:[]}),s[e]||(s[e]={object:r.object,children:[]});let x=y.length>15e3;if(x){let e=Date.now();Zn.removeEmptyObjectsFromRemovingMarkedObjects(y,r.object),l+=Date.now()-e}else o+=y.length;if(y.length===r.children.length)x||y.forEach((t=>{a[e].children.push(t)}));else{let n=y;y.length>=100&&(n=new Set(y));let i=e=>Array.isArray(n)?n.indexOf(e)>=0:n.has(e);for(let s=0;s15e3&&h(),yield n((u+ ++g/m)/c*100)}yield n(++u/c*100),e.layersAndThreejsObjects[t]=f,se.debug(`[DxfLoader] Merged layer '${t}' in ${(Date.now()-d)/1e3}s`)}o>0&&h();for(let t in s){let n=s[t],r=e.threejsObject.children.find((e=>e.name===t));if(r){let e=r.children.find((e=>e.name===Zn.SNAP_GROUP_NAME));if(e&&t!==Zn.MODEL_LAYOUT_NAME){let n=i[t];n.directAssociatedLeafObjectSet||(n.directAssociatedLeafObjectSet=new Set),e.children.forEach((e=>{var t;return null==(t=n.directAssociatedLeafObjectSet)?void 0:t.add(e)}))}}r||e.threejsObject.add(n.object),n.children.forEach((e=>{e.visible||(e.userData.layerVisible=!1),n.object.add(e),e.updateWorldMatrix(!1,!1)})),n.children=[]}se.debug(`[DxfLoader] MergeUtils.deepMerge costed ${Ar.mergeInfo.elapsedTime/1e3}s`),se.debug(`[DxfLoader] The remove operation of deep merge costed ${l/1e3}s`),se.debug(`[DxfLoader] Deep merge totally costed ${(Date.now()-r)/1e3}s`);let d=Ar.mergeInfo;se.debug(`[DxfLoader] Totally merged ${d.removedObjects} objects to ${d.mergedMeshes} meshes, ${d.mergedLines} lines, ${d.mergedPoints} points, ${d.mergedUnknownTypeObjects?d.mergedUnknownTypeObjects+" unknown type,":""} `),n(100)}))}printStatsInfo(){for(let n in this.entityTypesAndTimes)this.entityTypesAndTimes[n].averageTime=this.entityTypesAndTimes[n].totalTime/this.entityTypesAndTimes[n].createCount;se.debug("[DxfLoader] Entity types and cost times in ms:",this.entityTypesAndTimes),se.debug("[DxfLoader] Entity types and mesh count:",this.statsInfo.entityTypesAndMeshCount);let e=0;if(Object.values(this.statsInfo.entityTypesAndMeshCount).forEach((t=>{e+=t})),this.enableRTC&&se.debug(`[DxfLoader] Totally rebased ${this.statsInfo.rebasedEntityCount}(out of ${e}) entities`),this.enableMerge){let e=Ar.mergeInfo;se.debug(`[DxfLoader] Inner merged ${e.removedObjects} objects to ${e.mergedMeshes} meshes, ${e.mergedLines} lines, ${e.mergedPoints} points, ${e.mergedUnknownTypeObjects?e.mergedUnknownTypeObjects+" unknown type,":""} in ${e.elapsedTime/1e3}s`)}let t=(e,t,...n)=>{Object.keys(t).length};t(0,this.statsInfo.unsupportedEntityTypes),t(0,this.statsInfo.unsupportedTextStyles),t(0,this.statsInfo.unsupportedHatchPatterns),this.statsInfo.unsupportedPolylineCount&&se.warn(`[DxfLoader] Unsupported polyline (with both width and linetype) count: ${this.statsInfo.unsupportedPolylineCount}, linetype will be ignored.`),t(0,this.statsInfo.invisibleEntities),t(0,this.statsInfo.ignoredFrozenLayersAndEntityCount),t(0,this.statsInfo.ignoredInserts),this.ignorePaperSpace&&t(0,this.statsInfo.ignoredPaperSpaceEntityTypesAndCount),this.font&&t(0,this.font.getUnsupportedChar())}static statLayoutAndLayerObjects(e){let t=new WeakSet,n=0;for(let a in e.layersAndThreejsObjects)e.layersAndThreejsObjects[a].forEach((e=>{e.geometry&&(n++,t.has(e)?console.warn(e):t.add(e))}));let i=new WeakSet,r=0;if(e.threejsObject.traverse((e=>{e.geometry&&(r++,i.has(e)?console.warn(e):i.add(e))})),n!=r)for(let a in e.layersAndThreejsObjects)e.layersAndThreejsObjects[a].forEach((e=>{e.geometry&&(i.has(e)||console.warn(e))}));se.info(`[DxfLoader] The count of layer objects is ${n},The count of layout objects is ${r} `)}static removeEmptyObjectsFromRemovingMarkedObjects(e,t){if(0===e.length)return;let n=e=>{let i=[];for(let n of e){n.userData.validCount=0;let e=n.parent;e&&e!==t&&(void 0===e.userData.validCount&&(e.userData.validCount=e.children.length),0==--e.userData.validCount&&i.push(e))}i.length>0&&n(i)};n(e),this.removeEmptyObjectsFromMark(t)}static removeEmptyObjectsFromMark(e){if(0===e.userData.validCount||Hn.isEmptyObject(e))return e.removeFromParent(),!0;for(let t=0;t{let i=[];for(let n of e){n.userData.validCount=0;let e=n.parent;e&&e!==t&&(void 0===e.userData.validCount&&(e.userData.validCount=e.children.length),0==--e.userData.validCount&&i.push(e))}i.length>0&&n(i)};n(e),this.removeEmptyObjectsFromMark2(t)}static removeEmptyObjectsFromMark2(e){if(0===e.userData.validCount||0===e.type&&0===e.children.length)return e.removeFromParent(),!0;for(let t=0;tt.visible=e)),this.viewer.enableRender()}};function _a(e){return(_a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function zl(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function k6(e,t){if("object"!==_a(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!==_a(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function l_(e){var t=k6(e,"string");return"symbol"===_a(t)?t:String(t)}function h0e(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,i=new Array(t);n1&&void 0!==arguments[1]?arguments[1]:{};zl(this,e),this.init(t,n)}return Gl(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||r0t,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n1?t-1:0),i=1;i-1?e.replace(/###/g,"."):e}function r(){return!e||"string"==typeof e}for(var a="string"!=typeof t?[].concat(t):t.split(".");a.length>1;){if(r())return{};var s=i(a.shift());!e[s]&&n&&(e[s]=new n),e=Object.prototype.hasOwnProperty.call(e,s)?e[s]:{}}return r()?{}:{obj:e,k:i(a.shift())}}function m0e(e,t,n){var i=z6(e,t,Object);i.obj[i.k]=n}function a0t(e,t,n,i){var r=z6(e,t,Object),a=r.obj,s=r.k;a[s]=a[s]||[],i&&(a[s]=a[s].concat(n)),i||a[s].push(n)}function JC(e,t){var n=z6(e,t),i=n.obj,r=n.k;if(i)return i[r]}function g0e(e,t,n){var i=JC(e,n);return void 0!==i?i:JC(t,n)}function A0e(e,t,n){for(var i in t)"__proto__"!==i&&"constructor"!==i&&(i in e?"string"==typeof e[i]||e[i]instanceof String||"string"==typeof t[i]||t[i]instanceof String?n&&(e[i]=t[i]):A0e(e[i],t[i],n):e[i]=t[i]);return e}function My(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var o0t={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function l0t(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(function(e){return o0t[e]})):e}var eP="undefined"!=typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,c0t=[" ",",","?","!",";"];function u0t(e,t,n){t=t||"",n=n||"";var i=c0t.filter((function(e){return t.indexOf(e)<0&&n.indexOf(e)<0}));if(0===i.length)return!0;var r=new RegExp("(".concat(i.map((function(e){return"?"===e?"\\?":e})).join("|"),")")),a=!r.test(e);if(!a){var s=e.indexOf(n);s>0&&!r.test(e.substring(0,s))&&(a=!0)}return a}function v0e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function ZC(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:".";if(e){if(e[t])return e[t];for(var i=t.split(n),r=e,a=0;aa+s;)s++,l=r[o=i.slice(a,a+s).join(n)];if(void 0===l)return;if(null===l)return null;if(t.endsWith(o)){if("string"==typeof l)return l;if(o&&"string"==typeof l[o])return l[o]}var h=i.slice(a+s).join(n);return h?C0e(l,h,n):void 0}r=r[i[a]]}return r}}var f0t=function(e){Sy(n,zf);var t=h0t(n);function n(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return zl(this,n),i=t.call(this),eP&&zf.call(Hc(i)),i.data=e||{},i.options=r,void 0===i.options.keySeparator&&(i.options.keySeparator="."),void 0===i.options.ignoreJSONStructure&&(i.options.ignoreJSONStructure=!0),i}return Gl(n,[{key:"addNamespaces",value:function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,a=void 0!==i.ignoreJSONStructure?i.ignoreJSONStructure:this.options.ignoreJSONStructure,s=[e,t];n&&"string"!=typeof n&&(s=s.concat(n)),n&&"string"==typeof n&&(s=s.concat(r?n.split(r):n)),e.indexOf(".")>-1&&(s=e.split("."));var o=JC(this.data,s);return o||!a||"string"!=typeof n?o:C0e(this.data&&this.data[e]&&this.data[e][t],n,r)}},{key:"addResource",value:function(e,t,n,i){var r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},a=this.options.keySeparator;void 0===a&&(a=".");var s=[e,t];n&&(s=s.concat(a?n.split(a):n)),e.indexOf(".")>-1&&(i=t,t=(s=e.split("."))[1]),this.addNamespaces(t),m0e(this.data,s,i),r.silent||this.emit("added",e,t,n,i)}},{key:"addResources",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var r in n)("string"==typeof n[r]||"[object Array]"===Object.prototype.toString.apply(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});i.silent||this.emit("added",e,t,n)}},{key:"addResourceBundle",value:function(e,t,n,i,r){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},s=[e,t];e.indexOf(".")>-1&&(i=n,n=t,t=(s=e.split("."))[1]),this.addNamespaces(t);var o=JC(this.data,s)||{};i?A0e(o,n,r):o=ZC(ZC({},o),n),m0e(this.data,s,o),a.silent||this.emit("added",e,t,n)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?ZC(ZC({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find((function(e){return t[e]&&Object.keys(t[e]).length>0}))}},{key:"toJSON",value:function(){return this.data}}]),n}(),P0e={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,n,i,r){var a=this;return e.forEach((function(e){a.processors[e]&&(t=a.processors[e].process(t,n,i,r))})),t}};function y0e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function Xa(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{};return zl(this,n),i=t.call(this),eP&&zf.call(Hc(i)),s0t(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,Hc(i)),i.options=r,void 0===i.options.keySeparator&&(i.options.keySeparator="."),i.logger=Qu.create("translator"),i}return Gl(n,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var n=this.resolve(e,t);return n&&void 0!==n.res}},{key:"extractFromKey",value:function(e,t){var n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");var i=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,r=t.ns||this.options.defaultNS||[],a=n&&e.indexOf(n)>-1,s=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||u0t(e,n,i));if(a&&!s){var o=e.match(this.interpolator.nestingRegexp);if(o&&o.length>0)return{key:e,namespaces:r};var l=e.split(n);(n!==i||n===i&&this.options.ns.indexOf(l[0])>-1)&&(r=l.shift()),e=l.join(i)}return"string"==typeof r&&(r=[r]),{key:e,namespaces:r}}},{key:"translate",value:function(e,t,i){var r=this;if("object"!==_a(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var a=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,s=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,o=this.extractFromKey(e[e.length-1],t),l=o.key,h=o.namespaces,c=h[h.length-1],u=t.lng||this.language,d=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&"cimode"===u.toLowerCase()){if(d){var p=t.nsSeparator||this.options.nsSeparator;return a?(f.res="".concat(c).concat(p).concat(l),f):"".concat(c).concat(p).concat(l)}return a?(f.res=l,f):l}var f=this.resolve(e,t),m=f&&f.res,g=f&&f.usedKey||l,v=f&&f.exactUsedKey||l,y=Object.prototype.toString.apply(m),x=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject;if(b&&m&&"string"!=typeof m&&"boolean"!=typeof m&&"number"!=typeof m&&["[object Number]","[object Function]","[object RegExp]"].indexOf(y)<0&&("string"!=typeof x||"[object Array]"!==y)){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var _=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,m,Xa(Xa({},t),{},{ns:h})):"key '".concat(l," (").concat(this.language,")' returned an object instead of string.");return a?(f.res=_,f):_}if(s){var w="[object Array]"===y,S=w?[]:{},M=w?v:g;for(var T in m)if(Object.prototype.hasOwnProperty.call(m,T)){var E="".concat(M).concat(s).concat(T);S[T]=this.translate(E,Xa(Xa({},t),{joinArrays:!1,ns:h})),S[T]===E&&(S[T]=m[T])}m=S}}else if(b&&"string"==typeof x&&"[object Array]"===y)(m=m.join(x))&&(m=this.extendTranslation(m,e,t,i));else{var A=!1,C=!1,P=void 0!==t.count&&"string"!=typeof t.count,R=n.hasDefaultValue(t),O=P?this.pluralResolver.getSuffix(u,t.count,t):"",L=t["defaultValue".concat(O)]||t.defaultValue;!this.isValidLookup(m)&&R&&(A=!0,m=L),this.isValidLookup(m)||(C=!0,m=l);var I=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&C?void 0:m,D=R&&L!==m&&this.options.updateMissing;if(C||A||D){if(this.logger.log(D?"updateKey":"missingKey",u,c,l,D?L:m),s){var k=this.resolve(l,Xa(Xa({},t),{},{keySeparator:!1}));k&&k.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var N=[],F=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&F&&F[0])for(var U=0;U1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach((function(e){if(!s.isValidLookup(t)){var l=s.extractFromKey(e,o),h=l.key;n=h;var c=l.namespaces;s.options.fallbackNS&&(c=c.concat(s.options.fallbackNS));var u=void 0!==o.count&&"string"!=typeof o.count,d=u&&!o.ordinal&&0===o.count&&s.pluralResolver.shouldUseIntlApi(),p=void 0!==o.context&&("string"==typeof o.context||"number"==typeof o.context)&&""!==o.context,f=o.lngs?o.lngs:s.languageUtils.toResolveHierarchy(o.lng||s.language,o.fallbackLng);c.forEach((function(e){s.isValidLookup(t)||(a=e,!x0e["".concat(f[0],"-").concat(e)]&&s.utils&&s.utils.hasLoadedNamespace&&!s.utils.hasLoadedNamespace(a)&&(x0e["".concat(f[0],"-").concat(e)]=!0,s.logger.warn('key "'.concat(n,'" for languages "').concat(f.join(", "),'" won\'t get resolved as namespace "').concat(a,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),f.forEach((function(n){if(!s.isValidLookup(t)){r=n;var a,l=[h];if(s.i18nFormat&&s.i18nFormat.addLookupKeys)s.i18nFormat.addLookupKeys(l,h,n,e,o);else{var c;u&&(c=s.pluralResolver.getSuffix(n,o.count,o));var f="".concat(s.options.pluralSeparator,"zero");if(u&&(l.push(h+c),d&&l.push(h+f)),p){var m="".concat(h).concat(s.options.contextSeparator).concat(o.context);l.push(m),u&&(l.push(m+c),d&&l.push(m+f))}}for(;a=l.pop();)s.isValidLookup(t)||(i=a,t=s.getResource(n,e,a,o))}})))}))}})),{res:t,usedKey:n,exactUsedKey:i,usedLng:r,usedNS:a}}},{key:"isValidLookup",value:function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,n,i):this.resourceStore.getResource(e,t,n,i)}}],[{key:"hasDefaultValue",value:function(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&"defaultValue"===t.substring(0,12)&&void 0!==e[t])return!0;return!1}}]),n}();function V6(e){return e.charAt(0).toUpperCase()+e.slice(1)}var g0t=function(){function e(t){zl(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Qu.create("languageUtils")}return Gl(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return 2===t.length||(t.pop(),"x"===t[t.length-1].toLowerCase())?null:this.formatLanguageCode(t.join("-"))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],n=e.split("-");return this.options.lowerCaseLng?n=n.map((function(e){return e.toLowerCase()})):2===n.length?(n[0]=n[0].toLowerCase(),n[1]=n[1].toUpperCase(),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=V6(n[1].toLowerCase()))):3===n.length&&(n[0]=n[0].toLowerCase(),2===n[1].length&&(n[1]=n[1].toUpperCase()),"sgn"!==n[0]&&2===n[2].length&&(n[2]=n[2].toUpperCase()),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=V6(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=V6(n[2].toLowerCase()))),n.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,n=this;return e?(e.forEach((function(e){if(!t){var i=n.formatLanguageCode(e);(!n.options.supportedLngs||n.isSupportedCode(i))&&(t=i)}})),!t&&this.options.supportedLngs&&e.forEach((function(e){if(!t){var i=n.getLanguagePartFromCode(e);if(n.isSupportedCode(i))return t=i;t=n.options.supportedLngs.find((function(e){if(0===e.indexOf(i))return e}))}})),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}},{key:"toResolveHierarchy",value:function(e,t){var n=this,i=this.getFallbackCodes(t||this.options.fallbackLng||[],e),r=[],a=function(e){e&&(n.isSupportedCode(e)?r.push(e):n.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&a(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&a(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&a(this.getLanguagePartFromCode(e))):"string"==typeof e&&a(this.formatLanguageCode(e)),i.forEach((function(e){r.indexOf(e)<0&&a(n.formatLanguageCode(e))})),r}}]),e}(),v0t=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],y0t={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1&&e%100!=11?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},x0t=["v1","v2","v3"],E0e={zero:0,one:1,two:2,few:3,many:4,other:5};function b0t(){var e={};return v0t.forEach((function(t){t.lngs.forEach((function(n){e[n]={numbers:t.nr,plurals:y0t[t.fc]}}))})),e}var E0t=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};zl(this,e),this.languageUtils=t,this.options=n,this.logger=Qu.create("pluralResolver"),(!this.options.compatibilityJSON||"v4"===this.options.compatibilityJSON)&&("undefined"==typeof Intl||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=b0t()}return Gl(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,t);return this.shouldUseIntlApi()?n&&n.resolvedOptions().pluralCategories.length>1:n&&n.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,n).map((function(e){return"".concat(t).concat(e)}))}},{key:"getSuffixes",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this.getRule(e,n);return i?this.shouldUseIntlApi()?i.resolvedOptions().pluralCategories.sort((function(e,t){return E0e[e]-E0e[t]})).map((function(e){return"".concat(t.options.prepend).concat(e)})):i.numbers.map((function(i){return t.getSuffix(e,i,n)})):[]}},{key:"getSuffix",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this.getRule(e,n);return i?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(i.select(t)):this.getSuffixRetroCompatible(i,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var n=this,i=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),r=e.numbers[i];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===r?r="plural":1===r&&(r=""));var a=function(){return n.options.prepend&&r.toString()?n.options.prepend+r.toString():r.toString()};return"v1"===this.options.compatibilityJSON?1===r?"":"number"==typeof r?"_plural_".concat(r.toString()):a():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?a():this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString()}},{key:"shouldUseIntlApi",value:function(){return!x0t.includes(this.options.compatibilityJSON)}}]),e}();function _0e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function Vc(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{};zl(this,e),this.logger=Qu.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return Gl(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:l0t,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?My(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?My(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?My(t.nestingPrefix):t.nestingPrefixEscaped||My("$t("),this.nestingSuffix=t.nestingSuffix?My(t.nestingSuffix):t.nestingSuffixEscaped||My(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(t,"g");var n="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(n,"g")}},{key:"interpolate",value:function(e,t,n,i){var r,a,s,o=this,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function h(e){return e.replace(/\$/g,"$$$$")}var c=function(e){if(e.indexOf(o.formatSeparator)<0){var r=g0e(t,l,e);return o.alwaysFormat?o.format(r,void 0,n,Vc(Vc(Vc({},i),t),{},{interpolationkey:e})):r}var a=e.split(o.formatSeparator),s=a.shift().trim(),h=a.join(o.formatSeparator).trim();return o.format(g0e(t,l,s),h,n,Vc(Vc(Vc({},i),t),{},{interpolationkey:s}))};this.resetRegExp();var u=i&&i.missingInterpolationHandler||this.options.missingInterpolationHandler,d=i&&i.interpolation&&void 0!==i.interpolation.skipOnVariables?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return h(e)}},{regex:this.regexp,safeValue:function(e){return o.escapeValue?h(o.escape(e)):h(e)}}].forEach((function(t){for(s=0;r=t.regex.exec(e);){var n=r[1].trim();if(void 0===(a=c(n)))if("function"==typeof u){var l=u(e,r,i);a="string"==typeof l?l:""}else if(i&&i.hasOwnProperty(n))a="";else{if(d){a=r[0];continue}o.logger.warn("missed to pass in variable ".concat(n," for interpolating ").concat(e)),a=""}else"string"!=typeof a&&!o.useRawValueToEscape&&(a=p0e(a));var h=t.safeValue(a);if(e=e.replace(r[0],h),d?(t.regex.lastIndex+=a.length,t.regex.lastIndex-=r[0].length):t.regex.lastIndex=0,++s>=o.maxReplaces)break}})),e}},{key:"nest",value:function(e,t){var n,i,r=this,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=Vc({},a);function o(e,t){var n=this.nestingOptionsSeparator;if(e.indexOf(n)<0)return e;var i=e.split(new RegExp("".concat(n,"[ ]*{"))),r="{".concat(i[1]);e=i[0];var a=(r=this.interpolate(r,s)).match(/'/g),o=r.match(/"/g);(a&&a.length%2==0&&!o||o.length%2!=0)&&(r=r.replace(/'/g,'"'));try{s=JSON.parse(r),t&&(s=Vc(Vc({},t),s))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(n).concat(r)}return delete s.defaultValue,e}for(s.applyPostProcessor=!1,delete s.defaultValue;n=this.nestingRegexp.exec(e);){var l=[],h=!1;if(-1!==n[0].indexOf(this.formatSeparator)&&!/{.*}/.test(n[1])){var c=n[1].split(this.formatSeparator).map((function(e){return e.trim()}));n[1]=c.shift(),l=c,h=!0}if((i=t(o.call(this,n[1].trim(),s),s))&&n[0]===e&&"string"!=typeof i)return i;"string"!=typeof i&&(i=p0e(i)),i||(this.logger.warn("missed to resolve ".concat(n[1]," for nesting ").concat(e)),i=""),h&&(i=l.reduce((function(e,t){return r.format(e,t,a.lng,Vc(Vc({},a),{},{interpolationkey:n[1].trim()}))}),i.trim())),e=e.replace(n[0],i),this.regexp.lastIndex=0}return e}}]),e}();function T0e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function Vf(e){for(var t=1;t-1){var i=e.split("(");t=i[0].toLowerCase().trim();var r=i[1].substring(0,i[1].length-1);"currency"===t&&r.indexOf(":")<0?n.currency||(n.currency=r.trim()):"relativetime"===t&&r.indexOf(":")<0?n.range||(n.range=r.trim()):r.split(";").forEach((function(e){if(e){var t=H6(e.split(":")),i=t[0],r=t.slice(1).join(":").trim().replace(/^'+|'+$/g,"");n[i.trim()]||(n[i.trim()]=r),"false"===r&&(n[i.trim()]=!1),"true"===r&&(n[i.trim()]=!0),isNaN(r)||(n[i.trim()]=parseInt(r,10))}}))}return{formatName:t,formatOptions:n}}function Ry(e){var t={};return function(n,i,r){var a=i+JSON.stringify(r),s=t[a];return s||(s=e(i,r),t[a]=s),s(n)}}var w0t=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};zl(this,e),this.logger=Qu.create("formatter"),this.options=t,this.formats={number:Ry((function(e,t){var n=new Intl.NumberFormat(e,t);return function(e){return n.format(e)}})),currency:Ry((function(e,t){var n=new Intl.NumberFormat(e,Vf(Vf({},t),{},{style:"currency"}));return function(e){return n.format(e)}})),datetime:Ry((function(e,t){var n=new Intl.DateTimeFormat(e,Vf({},t));return function(e){return n.format(e)}})),relativetime:Ry((function(e,t){var n=new Intl.RelativeTimeFormat(e,Vf({},t));return function(e){return n.format(e,t.range||"day")}})),list:Ry((function(e,t){var n=new Intl.ListFormat(e,Vf({},t));return function(e){return n.format(e)}}))},this.init(t)}return Gl(e,[{key:"init",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=Ry(t)}},{key:"format",value:function(e,t,n,i){var r=this;return t.split(this.formatSeparator).reduce((function(e,t){var a=T0t(t),s=a.formatName,o=a.formatOptions;if(r.formats[s]){var l=e;try{var h=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},c=h.locale||h.lng||i.locale||i.lng||n;l=r.formats[s](e,c,Vf(Vf(Vf({},o),i),h))}catch(e){r.logger.warn(e)}return l}return r.logger.warn("there was no format function for ".concat(s)),e}),e)}}]),e}();function w0e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function S0e(e){for(var t=1;t3&&void 0!==arguments[3]?arguments[3]:{};return zl(this,n),a=t.call(this),eP&&zf.call(Hc(a)),a.backend=e,a.store=i,a.services=r,a.languageUtils=r.languageUtils,a.options=s,a.logger=Qu.create("backendConnector"),a.waitingReads=[],a.maxParallelReads=s.maxParallelReads||10,a.readingCalls=0,a.maxRetries=s.maxRetries>=0?s.maxRetries:5,a.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,a.state={},a.queue=[],a.backend&&a.backend.init&&a.backend.init(r,s.backend,s),a}return Gl(n,[{key:"queueLoad",value:function(e,t,n,i){var r=this,a={},s={},o={},l={};return e.forEach((function(e){var i=!0;t.forEach((function(t){var o="".concat(e,"|").concat(t);!n.reload&&r.store.hasResourceBundle(e,t)?r.state[o]=2:r.state[o]<0||(1===r.state[o]?void 0===s[o]&&(s[o]=!0):(r.state[o]=1,i=!1,void 0===s[o]&&(s[o]=!0),void 0===a[o]&&(a[o]=!0),void 0===l[t]&&(l[t]=!0)))})),i||(o[e]=!0)})),(Object.keys(a).length||Object.keys(s).length)&&this.queue.push({pending:s,pendingCount:Object.keys(s).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(s),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(l)}}},{key:"loaded",value:function(e,t,n){var i=e.split("|"),r=i[0],a=i[1];t&&this.emit("failedLoading",r,a,t),n&&this.store.addResourceBundle(r,a,n),this.state[e]=t?-1:2;var s={};this.queue.forEach((function(n){a0t(n.loaded,[r],a),R0t(n,e),t&&n.errors.push(t),0===n.pendingCount&&!n.done&&(Object.keys(n.loaded).forEach((function(e){s[e]||(s[e]={});var t=n.loaded[e];t.length&&t.forEach((function(t){void 0===s[e][t]&&(s[e][t]=!0)}))})),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())})),this.emit("loaded",s),this.queue=this.queue.filter((function(e){return!e.done}))}},{key:"read",value:function(e,t,n){var i=this,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,s=arguments.length>5?arguments[5]:void 0;return e.length?this.readingCalls>=this.maxParallelReads?void this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:a,callback:s}):(this.readingCalls++,this.backend[n](e,t,(function(o,l){if(i.readingCalls--,i.waitingReads.length>0){var h=i.waitingReads.shift();i.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.callback)}o&&l&&r2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),r&&r();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var a=this.queueLoad(e,t,i,r);if(!a.toLoad.length)return a.pending.length||r(),null;a.toLoad.forEach((function(e){n.loadOne(e)}))}},{key:"load",value:function(e,t,n){this.prepareLoading(e,t,{},n)}},{key:"reload",value:function(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}},{key:"loadOne",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=e.split("|"),r=i[0],a=i[1];this.read(r,a,"read",void 0,void 0,(function(i,s){i&&t.logger.warn("".concat(n,"loading namespace ").concat(a," for language ").concat(r," failed"),i),!i&&s&&t.logger.log("".concat(n,"loaded namespace ").concat(a," for language ").concat(r),s),t.loaded(e,i,s)}))}},{key:"saveMissing",value:function(e,t,n,i,r){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t)?this.logger.warn('did not save key "'.concat(n,'" as the namespace "').concat(t,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!"):null==n||""===n||(this.backend&&this.backend.create&&this.backend.create(e,t,n,i,null,S0e(S0e({},a),{},{isUpdate:r})),e&&e[0]&&this.store.addResource(e[0],t,n,i))}}]),n}();function C0t(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if("object"===_a(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===_a(e[2])||"object"===_a(e[3])){var n=e[3]||e[2];Object.keys(n).forEach((function(e){t[e]=n[e]}))}return t},interpolation:{escapeValue:!0,format:function(e,t,n,i){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function M0e(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function R0e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function Ju(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if(zl(this,n),e=t.call(this),eP&&zf.call(Hc(e)),e.options=M0e(i),e.services={},e.logger=Qu,e.modules={external:[]},L0t(Hc(e)),r&&!e.isInitialized&&!i.isClone){if(!e.options.initImmediate)return e.init(i,r),Qm(e,Hc(e));setTimeout((function(){e.init(i,r)}),0)}return e}return Gl(n,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(n=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));var i=C0t();function r(e){return e?"function"==typeof e?new e:e:null}if(this.options=Ju(Ju(Ju({},i),this.options),M0e(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=Ju(Ju({},i.interpolation),this.options.interpolation)),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){var a;this.modules.logger?Qu.init(r(this.modules.logger),this.options):Qu.init(null,this.options),this.modules.formatter?a=this.modules.formatter:"undefined"!=typeof Intl&&(a=w0t);var s=new g0t(this.options);this.store=new f0t(this.options.resources,this.options);var o=this.services;o.logger=Qu,o.resourceStore=this.store,o.languageUtils=s,o.pluralResolver=new E0t(s,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),a&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(o.formatter=r(a),o.formatter.init(o,this.options),this.options.interpolation.format=o.formatter.format.bind(o.formatter)),o.interpolator=new _0t(this.options),o.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},o.backendConnector=new A0t(r(this.modules.backend),o.resourceStore,o,this.options),o.backendConnector.on("*",(function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r1?n-1:0),r=1;r0&&"dev"!==l[0]&&(this.options.lng=l[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach((function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments)}})),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments),e}}));var h=u_(),c=function(){var t=function(t,i){e.isInitialized&&!e.initializedStoreOnce&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),h.resolve(i),n(t,i)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?c():setTimeout(c,0),h}},{key:"loadResources",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:KC,i="string"==typeof e?e:this.language;if("function"==typeof e&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(i&&"cimode"===i.toLowerCase())return n();var r=[],a=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach((function(e){r.indexOf(e)<0&&r.push(e)}))};i?a(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((function(e){return a(e)})),this.options.preload&&this.options.preload.forEach((function(e){return a(e)})),this.services.backendConnector.load(r,this.options.ns,(function(e){!e&&!t.resolvedLanguage&&t.language&&t.setResolvedLanguage(t.language),n(e)}))}else n(null)}},{key:"reloadResources",value:function(e,t,n){var i=u_();return e||(e=this.languages),t||(t=this.options.ns),n||(n=KC),this.services.backendConnector.reload(e,t,(function(e){i.resolve(),n(e)})),i}},{key:"use",value:function(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&P0e.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}}},{key:"changeLanguage",value:function(e,t){var n=this;this.isLanguageChangingTo=e;var i=u_();this.emit("languageChanging",e);var r=function(e){n.language=e,n.languages=n.services.languageUtils.toResolveHierarchy(e),n.resolvedLanguage=void 0,n.setResolvedLanguage(e)},a=function(a){!e&&!a&&n.services.languageDetector&&(a=[]);var s="string"==typeof a?a:n.services.languageUtils.getBestMatchFromCodes(a);s&&(n.language||r(s),n.translator.language||n.translator.changeLanguage(s),n.services.languageDetector&&n.services.languageDetector.cacheUserLanguage(s)),n.loadResources(s,(function(e){!function(e,a){a?(r(a),n.translator.changeLanguage(a),n.isLanguageChangingTo=void 0,n.emit("languageChanged",a),n.logger.log("languageChanged",a)):n.isLanguageChangingTo=void 0,i.resolve((function(){return n.t.apply(n,arguments)})),t&&t(e,(function(){return n.t.apply(n,arguments)}))}(e,s)}))};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(a):a(e):a(this.services.languageDetector.detect()),i}},{key:"getFixedT",value:function(e,t,n){var i=this,r=function e(t,r){var a;if("object"!==_a(r)){for(var s=arguments.length,o=new Array(s>2?s-2:0),l=2;l1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var i=this.resolvedLanguage||this.languages[0],r=!!this.options&&this.options.fallbackLng,a=this.languages[this.languages.length-1];if("cimode"===i.toLowerCase())return!0;var s=function(e,n){var i=t.services.backendConnector.state["".concat(e,"|").concat(n)];return-1===i||2===i};if(n.precheck){var o=n.precheck(this,s);if(void 0!==o)return o}return!!(this.hasResourceBundle(i,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||s(i,e)&&(!r||s(a,e)))}},{key:"loadNamespaces",value:function(e,t){var n=this,i=u_();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach((function(e){n.options.ns.indexOf(e)<0&&n.options.ns.push(e)})),this.loadResources((function(e){i.resolve(),t&&t(e)})),i):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var n=u_();"string"==typeof e&&(e=[e]);var i=this.options.preload||[],r=e.filter((function(e){return i.indexOf(e)<0}));return r.length?(this.options.preload=i.concat(r),this.loadResources((function(e){n.resolve(),t&&t(e)})),n):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){return e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),e?["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(this.services.languageUtils.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr":"rtl"}},{key:"cloneInstance",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:KC,r=Ju(Ju(Ju({},this.options),t),{isClone:!0}),a=new n(r);return(void 0!==t.debug||void 0!==t.prefix)&&(a.logger=a.logger.clone(t)),["store","services","language"].forEach((function(t){a[t]=e[t]})),a.services=Ju({},this.services),a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a.translator=new b0e(a.services,a.options),a.translator.on("*",(function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}));var Ya=QC.createInstance();Ya.createInstance=QC.createInstance;var Xqt=Ya.createInstance,Yqt=Ya.init,$qt=Ya.loadResources,Zqt=Ya.reloadResources,Kqt=Ya.use,Jqt=Ya.changeLanguage,Qqt=Ya.getFixedT,eh=Ya.t,e9t=Ya.exists,t9t=Ya.setDefaultNamespace,n9t=Ya.hasLoadedNamespace,r9t=Ya.loadNamespaces,i9t=Ya.loadLanguages,eg=Ya,Gf=class{constructor(e){this.progresseItems=[],this.element=document.createElement("div"),this.element.classList.add("progress-bar"),e.appendChild(this.element)}setVisibility(e){this.element&&(e?this.element.classList.remove("hidden"):this.element.classList.add("hidden"))}addProgressItem(e,t){let n=this.progresseItems.find((t=>t.id===e));if(!n){let i=document.createElement("div");i.classList.add("progress-bar-item"),i.innerHTML=t||"",this.element.append(i),n={id:e,div:i},this.progresseItems.push(n)}this.setVisibility(!0)}updateProgress(e,t,n){let i=this.progresseItems.find((t=>t.id===e));if(!i)return;let r=t?`${t}`:"";t&&null!=n&&(r+=": "),null!=n&&(n<0||n>100?(console.warn(`[ProgressBar] Invalid progress value: ${n}`),r+="--%"):r+=`${n.toFixed(2)}%`),i.div.innerHTML=r}removeProgressItem(e){let t=this.progresseItems.find((t=>t.id===e));t&&t.div.remove(),0===this.progresseItems.length&&this.setVisibility(!1)}delayRemoveProgressItem(e,t=3e3){setTimeout((()=>{this.removeProgressItem(e)}),t)}};function Ay(e){return{all:e=e||new Map,on:function(t,n){var i=e.get(t);i?i.push(n):e.set(t,[n])},off:function(t,n){var i=e.get(t);i&&(n?i.splice(i.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var i=e.get(t);i&&i.slice().map((function(e){e(n)})),(i=e.get("*"))&&i.slice().map((function(e){e(t,n)}))}}}var tP=class{constructor(e){this.viewer=e,this.itemList={},this.handleMouseWheel=e=>{e.preventDefault(),this.element&&(this.element.scrollLeft+=e.deltaY)},e.addEventListener("ModelLoaded",(()=>{this.init()}))}init(){var e;let t=document.createElement("div");t.classList.add("model-layout-switch-bar");let n=document.createElement("div");n.classList.add("model-layout-switch-bar-content"),n.addEventListener("wheel",this.handleMouseWheel),this.viewer.getLayoutNames().forEach(((e,t)=>{let i=this.createItem(e,t);this.itemList[e]=i,i.resetActivate=()=>{for(let e in this.itemList)this.itemList[e].resetActive()},null==n||n.appendChild(i.element)})),this.element=t,this.content=n,this.element.appendChild(this.content),null==(e=this.viewer.widgetContainer)||e.appendChild(this.element)}createItem(e,t){let n=new G6(this.viewer,e);return 0===t&&n.setActive(!0),n}destroy(){var e,t;for(let n in this.itemList){let t=this.itemList[n];t.destroy(),null==(e=this.content)||e.removeChild(t.element)}this.itemList={},this.element&&this.content&&(this.element.removeChild(this.content),this.element.removeEventListener("wheel",this.handleMouseWheel),null==(t=this.viewer.widgetContainer)||t.removeChild(this.element),this.element=void 0)}show(){this.element&&(this.element.style.display="block")}hide(){this.element&&(this.element.style.display="none")}},G6=class{constructor(e,t){this.viewer=e,this.eventBus=Ay(),this.active=!1,this.element=this.createItem(t),this.eventBus.on("activechange",(e=>{this.resetActivate&&this.resetActivate(),e?(this.element.classList.add("activate"),this.viewer.activateLayout(t)):this.element.classList.remove("activate")}))}createItem(e){let t=document.createElement("div"),n=document.createElement("span");return t.classList.add("model-layout-switch-item"),t.onclick=()=>{this.active=!this.active,this.eventBus.emit("activechange",this.active)},n.innerText=e,t.appendChild(n),t}setActive(e){this.active!==e&&(this.active=e,this.eventBus.emit("activechange",e))}resetActive(){this.active=!1,this.element.classList.remove("activate")}destroy(){this.eventBus.off("activechange")}},nP=class{constructor(e,t){this.flyDuration=500,this.autoRotateRemainingTime=0,this.automaticallyAdjustCameraPosition=!0,this.rotateIntervalStartTime=0,this.camera=e,this.controls=t}flyTo(e,t,n){let i=this.camera,r=this.controls;if(!i||!r)return;if(e.equals(t))return void console.error("[Controls] camera position and lookAt cannot be the same!");if(isNaN(e.x)||isNaN(e.y)||isNaN(e.z)||isNaN(t.x)||isNaN(t.y)||isNaN(t.z))return void console.error("[Controls] invalid position or lookAt!");if(this.automaticallyAdjustCameraPosition){let n=e.distanceTo(t);ni.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*i.far),console.warn("[Controls] camera could be too far to see the object!"))}let a=i.position.clone(),s=r.target.clone(),o=this.flyDuration,l=Date.now();this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=setInterval((()=>{let h=Date.now()-l;h>o&&(h=o);let c=(e,t,n)=>{let i=e.x+(t.x-e.x)*n,r=e.y+(t.y-e.y)*n,a=e.z+(t.z-e.z)*n;return new O(i,r,a)};((e,t)=>{i.lookAt(t),i.position.set(e.x,e.y,e.z),r.target.set(t.x,t.y,t.z),r.update()})(c(a,e,h/o),c(s,t,h/o)),h>=o&&(clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=void 0,n&&n())}),10)}lookTo(e){let t=this.camera,n=this.controls;if(!t||!n)return;let i=t.position,r=n.target.distanceTo(i),a=e.normalize().multiplyScalar(r),s=new O(i.x+a.x,i.y+a.y,i.z+a.z);this.flyTo(i,s)}startAutoRotate(){let e=this.camera,t=this.controls;if(!e||!t)return;t.autoRotate=!0;let n=new O;e.getWorldPosition(n);let i=t.target;if(i.y===n.y)return;let r=(i.y-n.y)/50;for(let a=0;a<50;++a)setTimeout((()=>{let e=t.target.y-r;t.target.setY(e),t.update()}),30*a)}delayAutoRotate(){this.autoRotateRemainingTime=5e3,this.controls&&(this.controls.autoRotate=!1)}startToRotate(e){let t=Date.now()-this.rotateIntervalStartTime;this.rotateIntervalStartTime=Date.now(),!(this.rotateInterval&&t<100)&&(this.rotateInterval&&clearInterval(this.rotateInterval),this.rotateInterval=setInterval((()=>{if(Date.now()-this.rotateIntervalStartTime>=100)return clearInterval(this.rotateInterval),void(this.rotateInterval=void 0);"ArrowLeft"===e.code||"ArrowRight"===e.code?this.rotateLeftOrRight(.3,"ArrowLeft"===e.code):("ArrowUp"===e.code||"ArrowDown"===e.code)&&this.rotateUpOrDown(.3,"ArrowUp"===e.code)}),1))}rotateLeftOrRight(e,t=!0){let n=this.controls;if(!this.camera||!n)return;let i=this.camera.position,r=n.target,a=r.clone(),s=Math.PI*e/180;t&&(s=-s),a.x=(r.x-i.x)*Math.cos(s)-(r.z-i.z)*Math.sin(s)+i.x,a.z=(r.z-i.z)*Math.cos(s)+(r.x-i.x)*Math.sin(s)+i.z,this.camera.lookAt(a),n.target=a,n.update()}rotateUpOrDown(e,t=!0){let n=this.controls;if(!this.camera||!n)return;let i=this.camera.position,r=n.target,a=r.clone(),s=Math.PI*e/180,o=new O(r.x-i.x,r.y-i.y,r.z-i.z).length(),l=r.y-i.y;t||(s=-s);let h=Math.asin(l/o)+s;if(h<-Math.PI/2||h>Math.PI/2)return;let c=Math.sin(h)*o;a.y=r.y+(c-l),n.target=a,n.update()}},I0e=class{constructor(e){this.object=e}instantiate(){let e=Date.now();this.instantiateInner(this.object),console.log(`[Inst] instantiate() costed ${(Date.now()-e)/1e3}s`)}instantiateInner(e){if(!e.children||0===e.children.length)return;let t=e.children.length,n={},i=[];for(let s=0;s0||!t.geometry)continue;let r=!1,a=Object.values(n);for(let o=a.length-1;o>=0;--o){let l=a[o].indexes[0],h=e.children[l];if(this.geometryEquals(t.geometry,h.geometry)&&es.materialsEquals(t.material,h.material)){n[l]||(n[l]={indexes:[l]},this.removeFromArray(i,l)),n[l].indexes.push(s),r=!0;break}}for(let o=i.length-1;!r&&o>=0;--o){let a=i[o],l=e.children[a];if(this.geometryEquals(t.geometry,l.geometry)&&es.materialsEquals(t.material,l.material)){n[a]||(n[a]={indexes:[a]},this.removeFromArray(i,a)),n[a].indexes.push(s),r=!0;break}}r||i.push(s)}if(Object.keys(n).length<=0)return;let r=[],a=[];Object.values(n).forEach((t=>{let n=t.indexes;a.push(...n);let i=e.children[n[0]],s=i.material;if(s instanceof yr)s=s.clone();else if(Array.isArray(s)){let e=[];s.forEach((t=>e.push(t.clone()))),s=e}let o=new Pi(i.geometry,s,n.length);o.name=`[Instanced] ${i.name}`;for(let r=0;rt-e)),a.forEach((t=>e.remove(e.children[t]))),r.forEach((t=>{t.parent=e,e.children.push(t)})),e.updateMatrix(),console.log(`[Inst] ${a.length}(out of ${t}) objects instanced to ${r.length} InstancedMesh`)}removeFromArray(e,t){for(let n=e.length-1;n>=0;--n)if(e[n]===t)return void e.splice(n,1)}geometryEquals(e,t){return Qt.geometryEquals(e,t)}},qf=class{constructor(){this.TIMEOUT="timeout",this.INTERVAL="interval",this.timeoutMap={},this.intervalMap={}}run(e=this.INTERVAL,t,n=16.7){let i=Date.now,r=i(),a=r,s=Symbol(""),o=()=>{this.setIdMap(s,e,o),a=i(),a-r>=n&&(e===this.intervalMap&&(r=i(),a=r),t(),e===this.TIMEOUT&&this.clearTimeout(s))};return this.setIdMap(s,e,o),s}setIdMap(e,t,n){let i=requestAnimationFrame(n);t===this.INTERVAL?this.intervalMap[e]=i:t===this.TIMEOUT&&(this.timeoutMap[e]=i)}setTimeout(e,t){return this.run(this.TIMEOUT,e,t)}clearTimeout(e){cancelAnimationFrame(this.timeoutMap[e])}setInterval(e,t){return this.run(this.INTERVAL,e,t)}clearInterval(e){cancelAnimationFrame(this.intervalMap[e])}},h_=class extends Tm{constructor(e){super(e)}parse(e){if(e.length<19)throw new Error("THREE.TGALoader: Not enough data to contain header.");let t=0,n=new Uint8Array(e),i={id_length:n[t++],colormap_type:n[t++],image_type:n[t++],colormap_index:n[t++]|n[t++]<<8,colormap_length:n[t++]|n[t++]<<8,colormap_size:n[t++],origin:[n[t++]|n[t++]<<8,n[t++]|n[t++]<<8],width:n[t++]|n[t++]<<8,height:n[t++]|n[t++]<<8,pixel_size:n[t++],flags:n[t++]};if(function(e){switch(e.image_type){case 1:case 9:if(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case 2:case 3:case 10:case 11:if(e.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case 0:throw new Error("THREE.TGALoader: No data.");default:throw new Error("THREE.TGALoader: Invalid type "+e.image_type)}if(e.width<=0||e.height<=0)throw new Error("THREE.TGALoader: Invalid image size.");if(8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size)throw new Error("THREE.TGALoader: Invalid pixel size "+e.pixel_size)}(i),i.id_length+t>e.length)throw new Error("THREE.TGALoader: No data.");t+=i.id_length;let r=!1,a=!1,s=!1;switch(i.image_type){case 9:r=!0,a=!0;break;case 1:a=!0;break;case 10:r=!0;break;case 2:break;case 11:r=!0,s=!0;break;case 3:s=!0}let o=new Uint8Array(i.width*i.height*4),l=function(e,t,n,i,r){let a,s,o=n.pixel_size>>3,l=n.width*n.height*o;if(t&&(s=r.subarray(i,i+=n.colormap_length*(n.colormap_size>>3))),e){a=new Uint8Array(l);let e,t,n,s=0,h=new Uint8Array(o);for(;s>4){default:case 2:o=0,h=1,u=t,l=0,c=1,d=n;break;case 0:o=0,h=1,u=t,l=n-1,c=-1,d=-1;break;case 3:o=t-1,h=-1,u=-1,l=0,c=1,d=n;break;case 1:o=t-1,h=-1,u=-1,l=n-1,c=-1,d=-1}if(s)switch(i.pixel_size){case 8:!function(e,t,n,r,a,s,o,l){let h,c,u,d=0,p=i.width;for(u=t;u!==r;u+=n)for(c=a;c!==o;c+=s,d++)h=l[d],e[4*(c+p*u)+0]=h,e[4*(c+p*u)+1]=h,e[4*(c+p*u)+2]=h,e[4*(c+p*u)+3]=255}(e,l,c,d,o,h,u,r);break;case 16:!function(e,t,n,r,a,s,o,l){let h,c,u=0,d=i.width;for(c=t;c!==r;c+=n)for(h=a;h!==o;h+=s,u+=2)e[4*(h+d*c)+0]=l[u+0],e[4*(h+d*c)+1]=l[u+0],e[4*(h+d*c)+2]=l[u+0],e[4*(h+d*c)+3]=l[u+1]}(e,l,c,d,o,h,u,r);break;default:throw new Error("THREE.TGALoader: Format not supported.")}else switch(i.pixel_size){case 8:!function(e,t,n,r,a,s,o,l,h){let c,u,d,p=h,f=0,m=i.width;for(d=t;d!==r;d+=n)for(u=a;u!==o;u+=s,f++)c=l[f],e[4*(u+m*d)+3]=255,e[4*(u+m*d)+2]=p[3*c+0],e[4*(u+m*d)+1]=p[3*c+1],e[4*(u+m*d)+0]=p[3*c+2]}(e,l,c,d,o,h,u,r,a);break;case 16:!function(e,t,n,r,a,s,o,l){let h,c,u,d=0,p=i.width;for(u=t;u!==r;u+=n)for(c=a;c!==o;c+=s,d+=2)h=l[d+0]+(l[d+1]<<8),e[4*(c+p*u)+0]=(31744&h)>>7,e[4*(c+p*u)+1]=(992&h)>>2,e[4*(c+p*u)+2]=(31&h)<<3,e[4*(c+p*u)+3]=32768&h?0:255}(e,l,c,d,o,h,u,r);break;case 24:!function(e,t,n,r,a,s,o,l){let h,c,u=0,d=i.width;for(c=t;c!==r;c+=n)for(h=a;h!==o;h+=s,u+=3)e[4*(h+d*c)+3]=255,e[4*(h+d*c)+2]=l[u+0],e[4*(h+d*c)+1]=l[u+1],e[4*(h+d*c)+0]=l[u+2]}(e,l,c,d,o,h,u,r);break;case 32:!function(e,t,n,r,a,s,o,l){let h,c,u=0,d=i.width;for(c=t;c!==r;c+=n)for(h=a;h!==o;h+=s,u+=4)e[4*(h+d*c)+2]=l[u+0],e[4*(h+d*c)+1]=l[u+1],e[4*(h+d*c)+0]=l[u+2],e[4*(h+d*c)+3]=l[u+3]}(e,l,c,d,o,h,u,r);break;default:throw new Error("THREE.TGALoader: Format not supported.")}}(o,i.width,i.height,l.pixel_data,l.palettes),{data:o,width:i.width,height:i.height,flipY:!0,generateMipmaps:!0,minFilter:Ua}}},rP=class extends Er{constructor(e){super(e)}load(e,t,n,i){let r=this,a=""===r.path?ra.extractUrlBase(e):r.path,s=new Kr(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,(function(n){try{t(r.parse(n,a))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e,t){function n(e,t){let n=[],i=e.childNodes;for(let r=0,a=i.length;r0&&t.push(new qa(i+".position",r,a)),s.length>0&&t.push(new Ga(i+".quaternion",r,s)),o.length>0&&t.push(new qa(i+".scale",r,o)),t}function b(e,t,n){let i,r,a,s=!0;for(r=0,a=e.length;r=0;){let i=e[t];if(null!==i.value[n])return i;t--}return null}function w(e,t,n){for(;t>>0));return t="tga"===(n=n.toLowerCase(),n)?qe:Xe,t}(r);if(void 0!==n){let i=n.load(r),a=e.extra;if(void 0!==a&&void 0!==a.technique&&!1===o(a.technique)){let e=a.technique;i.wrapS=e.wrapU?Ci:Ai,i.wrapT=e.wrapV?Ci:Ai,i.offset.set(e.offsetU||0,e.offsetV||0),i.repeat.set(e.repeatU||1,e.repeatV||1)}else i.wrapS=Ci,i.wrapT=Ci;return null!==t&&(i.colorSpace=t),i}return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",r),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",e.id),null}t.name=e.name||"";let a=i.parameters;for(let o in a){let e=a[o];switch(o){case"diffuse":e.color&&t.color.fromArray(e.color),e.texture&&(t.map=r(e.texture,tn));break;case"specular":e.color&&t.specular&&t.specular.fromArray(e.color),e.texture&&(t.specularMap=r(e.texture));break;case"bump":e.texture&&(t.normalMap=r(e.texture));break;case"ambient":e.texture&&(t.lightMap=r(e.texture,tn));break;case"shininess":e.float&&t.shininess&&(t.shininess=e.float);break;case"emission":e.color&&t.emissive&&t.emissive.fromArray(e.color),e.texture&&(t.emissiveMap=r(e.texture,tn))}}t.color.convertSRGBToLinear(),t.specular&&t.specular.convertSRGBToLinear(),t.emissive&&t.emissive.convertSRGBToLinear();let s=a.transparent,l=a.transparency;if(void 0===l&&s&&(l={float:1}),void 0===s&&l&&(s={opaque:"A_ONE",data:{color:[1,1,1,1]}}),s&&l)if(s.data.texture)t.transparent=!0;else{let e=s.data.color;switch(s.opaque){case"A_ONE":t.opacity=e[3]*l.float;break;case"RGB_ZERO":t.opacity=1-e[0]*l.float;break;case"A_ZERO":t.opacity=1-e[3]*l.float;break;case"RGB_ONE":t.opacity=e[0]*l.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',s.opaque)}t.opacity<1&&(t.transparent=!0)}if(void 0!==i.extra&&void 0!==i.extra.technique){let e=i.extra.technique;for(let n in e){let i=e[n];switch(n){case"double_sided":t.side=1===i?Sr:pi;break;case"bump":t.normalMap=r(i.texture),t.normalScale=new be(1,1)}}}return t}function J(e){return c(Qe.materials[e],q)}function Z(e){for(let t=0;t0?n+o:n;t.inputs[l]={id:e,offset:r},t.stride=Math.max(t.stride,r+1),"TEXCOORD"===n&&(t.hasUV=!0);break;case"vcount":t.vcount=a(i.textContent);break;case"p":t.p=a(i.textContent)}}return t}function le(e){let t=0;for(let n=0,i=e.length;n0&&t0&&u.setAttribute("position",new Bt(r.array,r.stride)),a.array.length>0&&u.setAttribute("normal",new Bt(a.array,a.stride)),l.array.length>0&&u.setAttribute("color",new Bt(l.array,l.stride)),s.array.length>0&&u.setAttribute("uv",new Bt(s.array,s.stride)),o.array.length>0&&u.setAttribute("uv1",new Bt(o.array,o.stride)),h.length>0&&u.setAttribute("skinIndex",new Bt(h,4)),c.length>0&&u.setAttribute("skinWeight",new Bt(c,4)),i.data=u,i.type=e[0].type,i.materialKeys=d,i}function ue(e,t,n,i,r=!1){let a=e.p,s=e.stride,o=e.vcount;function l(e){let t=a[e+n]*c,s=t+c;for(;t4)for(let t=1,i=n-2;t<=i;t++){let n=e+s*t,i=e+s*(t+1);l(e+0*s),l(n),l(i)}e+=s*n}}else for(let u=0,d=a.length;u=t.limits.max&&(t.static=!0),t.middlePosition=(t.limits.min+t.limits.max)/2,t}function ve(e){let t={sid:e.getAttribute("sid"),name:e.getAttribute("name")||"",attachments:[],transforms:[]};for(let n=0;ni.limits.max||t{this.parse(e,t,i)}),n,i)}parse(e,t,n){this.decodeDracoFile(e,t,null,null,tn).catch(n)}decodeDracoFile(e,t,n,i,r=Ha){let a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(e,a).then(t)}decodeGeometry(e,t){let n=JSON.stringify(t);if(q6.has(e)){let t=q6.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i,r=this.workerNextTaskID++,a=e.byteLength,s=this._getWorker(r,a).then((n=>(i=n,new Promise(((n,a)=>{i._callbacks[r]={resolve:n,reject:a},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return s.catch((()=>!0)).then((()=>{i&&r&&this._releaseTask(i,r)})),q6.set(e,{key:n,promise:s}),s}_createGeometry(e){let t=new Dt;e.index&&t.setIndex(new mn(e.index.array,1));for(let n=0;n{n.load(e,t,void 0,i)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{let n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);let i=D0t.toString(),r=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([r]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.lengtht._taskLoad?-1:1}));let n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e{let t=e.draco,s=new t.Decoder;try{let e=function(e,t,i,r){let a,s,o=r.attributeIDs,l=r.attributeTypes,h=t.GetEncodedGeometryType(i);if(h===e.TRIANGULAR_MESH)a=new e.Mesh,s=t.DecodeArrayToMesh(i,i.byteLength,a);else{if(h!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,s=t.DecodeArrayToPointCloud(i,i.byteLength,a)}if(!s.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+s.error_msg());let c={index:null,attributes:[]};for(let u in o){let i,s,h=self[l[u]];if(r.useUniqueIDs)s=o[u],i=t.GetAttributeByUniqueId(a,s);else{if(s=t.GetAttributeId(a,e[o[u]]),-1===s)continue;i=t.GetAttribute(a,s)}let d=n(e,t,a,u,h,i);"color"===u&&(d.vertexColorSpace=r.vertexColorSpace),c.attributes.push(d)}return h===e.TRIANGULAR_MESH&&(c.index=function(e,t,n){let i=3*n.num_faces(),r=4*i,a=e._malloc(r);t.GetTrianglesUInt32Array(n,r,a);let s=new Uint32Array(e.HEAPF32.buffer,a,i).slice();return e._free(a),{array:s,itemSize:1}}(e,t,a)),e.destroy(a),c}(t,s,new Int8Array(i),a),o=e.attributes.map((e=>e.array.buffer));e.index&&o.push(e.index.array.buffer),self.postMessage({type:"decode",id:r.id,geometry:e},o)}catch(e){console.error(e),self.postMessage({type:"error",id:r.id,error:e.message})}finally{t.destroy(s)}}))}}}var L0e=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},O0t=function(e){return new Worker(e)};try{URL.revokeObjectURL(L0e(""))}catch(e){L0e=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},O0t=function(e){return new Worker(e,{type:"module"})}}var Wl=Uint8Array,Wf=Uint16Array,X6=Uint32Array,D0e=new Wl([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),O0e=new Wl([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),k0t=new Wl([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),k0e=function(e,t){for(var n=new Wf(31),i=0;i<31;++i)n[i]=t+=1<>>1|(21845&hi)<<1,hd=(52428&hd)>>>2|(13107&hd)<<2,hd=(61680&hd)>>>4|(3855&hd)<<4,Y6[hi]=((65280&hd)>>>8|(255&hd)<<8)>>>1;var hd,hi,d_=function(e,t,n){for(var i=e.length,r=0,a=new Wf(t);r>>l]=h}else for(s=new Wf(i),r=0;r>>15-e[r]);return s},f_=new Wl(288),hi,hi,hi;for(hi=0;hi<144;++hi)f_[hi]=8;for(hi=144;hi<256;++hi)f_[hi]=9;for(hi=256;hi<280;++hi)f_[hi]=7;for(hi=280;hi<288;++hi)f_[hi]=8;var hi,U0e=new Wl(32),hi;for(hi=0;hi<32;++hi)U0e[hi]=5;var B0t=d_(f_,9,1),U0t=d_(U0e,5,1),W6=function(e){for(var t=e[0],n=1;nt&&(t=e[n]);return t},zc=function(e,t,n){var i=t/8|0;return(e[i]|e[i+1]<<8)>>(7&t)&n},j6=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},H0t=function(e){return(e/8|0)+(7&e&&1)},V0t=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var i=new(e instanceof Wf?Wf:e instanceof X6?X6:Wl)(n-t);return i.set(e.subarray(t,n)),i},z0t=function(e,t,n){var i=e.length;if(!i||n&&!n.l&&i<5)return t||new Wl(0);var r=!t||n,a=!n||n.i;n||(n={}),t||(t=new Wl(3*i));var s=function(e){var n=t.length;if(e>n){var i=new Wl(Math.max(2*n,e));i.set(t),t=i}},o=n.f||0,l=n.p||0,h=n.b||0,c=n.l,u=n.d,d=n.m,p=n.n,f=8*i;do{if(!c){n.f=o=zc(e,l,1);var m=zc(e,l+1,3);if(l+=3,!m){var g=e[(A=H0t(l)+4)-4]|e[A-3]<<8,v=A+g;if(v>i){if(a)throw"unexpected EOF";break}r&&s(h+g),t.set(e.subarray(A,v),h),n.b=h+=g,n.p=l=8*v;continue}if(1==m)c=B0t,u=U0t,d=9,p=5;else{if(2!=m)throw"invalid block type";var y=zc(e,l,31)+257,x=zc(e,l+10,15)+4,b=y+zc(e,l+5,31)+1;l+=14;for(var _=new Wl(b),w=new Wl(19),S=0;S>>4)<16)_[S++]=A;else{var P=0,R=0;for(16==A?(R=3+zc(e,l,3),l+=2,P=_[S-1]):17==A?(R=3+zc(e,l,7),l+=3):18==A&&(R=11+zc(e,l,127),l+=7);R--;)_[S++]=P}}var O=_.subarray(0,y),L=_.subarray(y);d=W6(O),p=W6(L),c=d_(O,d,1),u=d_(L,p,1)}if(l>f){if(a)throw"unexpected EOF";break}}r&&s(h+131072);for(var I=(1<>>4;if((l+=15&P)>f){if(a)throw"unexpected EOF";break}if(!P)throw"invalid length/literal";if(N<256)t[h++]=N;else{if(256==N){k=l,c=null;break}var F=N-254;if(N>264){var U=D0e[S=N-257];F=zc(e,l,(1<>>4;if(!B)throw"invalid distance";if(l+=15&B,L=N0t[z],z>3&&(U=O0e[z],L+=j6(e,l)&(1<f){if(a)throw"unexpected EOF";break}r&&s(h+131072);for(var H=h+F;h>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"};function H0e(e,t){return z0t((q0t(e),e.subarray(2,-4)),t)}var W0t="undefined"!=typeof TextDecoder&&new TextDecoder,j0t=0;try{W0t.decode(G0t,{stream:!0}),j0t=1}catch(e){}function V0e(e,t,n){let i=n.length-e-1;if(t>=n[i])return i-1;if(t<=n[e])return e;let r=e,a=i,s=Math.floor((r+a)/2);for(;t=n[s+1];)t=a&&(r[t][0]=r[e][0]/o[h+1][l],i=r[t][0]*o[l][h]);let c=u-1<=h?a-1:n-u;for(let n=l>=-1?1:-l;n<=c;++n)r[t][n]=(r[e][n]-r[e][n-1])/o[h+1][l+n],i+=r[t][n]*o[l+n][h];u<=h&&(r[t][a]=-r[e][a-1]/o[h+1][u],i+=r[t][a]*o[u][h]),s[a][u]=i;let d=e;e=t,t=d}}let c=n;for(let u=1;u<=i;++u){for(let e=0;e<=n;++e)s[u][e]*=c;c*=n-u}return s}function Z0t(e,t,n,i,r){let a=r0,a="string"==typeof r.Content&&""!==r.Content;if(e||a){let e=this.parseImage(n[i]);t[r.RelativeFilename||r.Filename]=e}}}}for(let n in e){let i=e[n];void 0!==t[i]?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){let t,n=e.Content,i=e.RelativeFilename||e.Filename,r=i.slice(i.lastIndexOf(".")+1).toLowerCase();switch(r){case"bmp":t="image/bmp";break;case"jpg":case"jpeg":t="image/jpeg";break;case"png":t="image/png";break;case"tif":t="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",i),t="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+r+'" is not supported.')}if("string"==typeof n)return"data:"+t+";base64,"+n;{let e=new Uint8Array(n);return window.URL.createObjectURL(new Blob([e],{type:t}))}}parseTextures(e){let t=new Map;if("Texture"in Lr.Objects){let n=Lr.Objects.Texture;for(let i in n){let r=this.parseTexture(n[i],e);t.set(parseInt(i),r)}}return t}parseTexture(e,t){let n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;let i=e.WrapModeU,r=e.WrapModeV,a=void 0!==i?i.value:0,s=void 0!==r?r.value:0;if(n.wrapS=0===a?Ci:Ai,n.wrapT=0===s?Ci:Ai,"Scaling"in e){let t=e.Scaling.value;n.repeat.x=t[0],n.repeat.y=t[1]}if("Translation"in e){let t=e.Translation.value;n.offset.x=t[0],n.offset.y=t[1]}return n}loadTexture(e,t){let n,i=this.textureLoader.path,r=xs.get(e.id).children;void 0!==r&&r.length>0&&void 0!==t[r[0].ID]&&(n=t[r[0].ID],(0===n.indexOf("blob:")||0===n.indexOf("data:"))&&this.textureLoader.setPath(void 0));let a,s=e.FileName.slice(-3).toLowerCase();if("tga"===s){let t=this.manager.getHandler(".tga");null===t?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),a=new qr):(t.setPath(this.textureLoader.path),a=t.load(n))}else"psd"===s?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),a=new qr):a=this.textureLoader.load(n);return this.textureLoader.setPath(i),a}parseMaterials(e){let t=new Map;if("Material"in Lr.Objects){let n=Lr.Objects.Material;for(let i in n){let r=this.parseMaterial(n[i],e);null!==r&&t.set(parseInt(i),r)}}return t}parseMaterial(e,t){let n=e.id,i=e.attrName,r=e.ShadingModel;if("object"==typeof r&&(r=r.value),!xs.has(n))return null;let a,s=this.parseParameters(e,t,n);switch(r.toLowerCase()){case"phong":a=new na;break;case"lambert":a=new Pu;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',r),a=new na}return a.setValues(s),a.name=i,a}parseParameters(e,t,n){let i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=(new ct).fromArray(e.Diffuse.value).convertSRGBToLinear():e.DiffuseColor&&("Color"===e.DiffuseColor.type||"ColorRGB"===e.DiffuseColor.type)&&(i.color=(new ct).fromArray(e.DiffuseColor.value).convertSRGBToLinear()),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=(new ct).fromArray(e.Emissive.value).convertSRGBToLinear():e.EmissiveColor&&("Color"===e.EmissiveColor.type||"ColorRGB"===e.EmissiveColor.type)&&(i.emissive=(new ct).fromArray(e.EmissiveColor.value).convertSRGBToLinear()),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=(new ct).fromArray(e.Specular.value).convertSRGBToLinear():e.SpecularColor&&"Color"===e.SpecularColor.type&&(i.specular=(new ct).fromArray(e.SpecularColor.value).convertSRGBToLinear());let r=this;return xs.get(n).children.forEach((function(e){let n=e.relationship;switch(n){case"Bump":i.bumpMap=r.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":i.aoMap=r.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=r.getTexture(t,e.ID),void 0!==i.map&&(i.map.colorSpace=tn);break;case"DisplacementColor":i.displacementMap=r.getTexture(t,e.ID);break;case"EmissiveColor":i.emissiveMap=r.getTexture(t,e.ID),void 0!==i.emissiveMap&&(i.emissiveMap.colorSpace=tn);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=r.getTexture(t,e.ID);break;case"ReflectionColor":i.envMap=r.getTexture(t,e.ID),void 0!==i.envMap&&(i.envMap.mapping=fm,i.envMap.colorSpace=tn);break;case"SpecularColor":i.specularMap=r.getTexture(t,e.ID),void 0!==i.specularMap&&(i.specularMap.colorSpace=tn);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=r.getTexture(t,e.ID),i.transparent=!0;break;default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",n)}})),i}getTexture(e,t){return"LayeredTexture"in Lr.Objects&&t in Lr.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=xs.get(t).children[0].ID),e.get(t)}parseDeformers(){let e={},t={};if("Deformer"in Lr.Objects){let n=Lr.Objects.Deformer;for(let i in n){let r=n[i],a=xs.get(parseInt(i));if("Skin"===r.attrType){let t=this.parseSkeleton(a,n);t.ID=i,a.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=a.parents[0].ID,e[i]=t}else if("BlendShape"===r.attrType){let e={id:i};e.rawTargets=this.parseMorphTargets(a,n),e.id=i,a.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){let n=[];return e.children.forEach((function(e){let i=t[e.ID];if("Cluster"!==i.attrType)return;let r={ID:e.ID,indices:[],weights:[],transformLink:(new et).fromArray(i.TransformLink.a)};"Indexes"in i&&(r.indices=i.Indexes.a,r.weights=i.Weights.a),n.push(r)})),{rawBones:n,bones:[]}}parseMorphTargets(e,t){let n=[];for(let i=0;i1?a=s:s.length>0?a=s[0]:(a=new na({name:Er.DEFAULT_MATERIAL_NAME,color:13421772}),s.push(a)),"color"in r.attributes&&s.forEach((function(e){e.vertexColors=!0})),r.FBX_Deformer?(i=new Su(r,a),i.normalizeSkinWeights()):i=new xt(r,a),i}createCurve(e,t){let n=e.children.reduce((function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e}),null),i=new Gn({name:Er.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new hr(n,i)}getTransformData(e,t){let n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder="RotationOrder"in t?X0e(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&xs.get(e.ID).children.forEach((function(t){if("LookAtProperty"===t.relationship){let n=Lr.Objects.Model[t.ID];if("Lcl_Translation"in n){let t=n.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),To.add(e.target)):e.lookAt((new O).fromArray(t))}}}))}bindSkeleton(e,t,n){let i=this.parsePoseNodes();for(let r in e){let a=e[r];xs.get(parseInt(a.ID)).parents.forEach((function(e){if(t.has(e.ID)){let t=e.ID;xs.get(t).parents.forEach((function(e){n.has(e.ID)&&n.get(e.ID).bind(new Rl(a.bones),i[e.ID])}))}}))}}parsePoseNodes(){let e={};if("Pose"in Lr.Objects){let t=Lr.Objects.Pose;for(let n in t)if("BindPose"===t[n].attrType&&t[n].NbPoseNodes>0){let i=t[n].PoseNode;Array.isArray(i)?i.forEach((function(t){e[t.Node]=(new et).fromArray(t.Matrix.a)})):e[i.Node]=(new et).fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in Lr&&"AmbientColor"in Lr.GlobalSettings){let e=Lr.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(0!==t||0!==n||0!==i){let e=new ct(t,n,i).convertSRGBToLinear();To.add(new Pl(e,1))}}}},J6=class{constructor(){this.negativeMaterialIndices=!1}parse(e){let t=new Map;if("Geometry"in Lr.Objects){let n=Lr.Objects.Geometry;for(let i in n){let r=xs.get(parseInt(i)),a=this.parseGeometry(r,n[i],e);t.set(parseInt(i),a)}}return!0===this.negativeMaterialIndices&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){let i=n.skeletons,r=[],a=e.parents.map((function(e){return Lr.Objects.Model[e.ID]}));if(0===a.length)return;let s=e.children.reduce((function(e,t){return void 0!==i[t.ID]&&(e=i[t.ID]),e}),null);e.children.forEach((function(e){void 0!==n.morphTargets[e.ID]&&r.push(n.morphTargets[e.ID])}));let o=a[0],l={};"RotationOrder"in o&&(l.eulerOrder=X0e(o.RotationOrder.value)),"InheritType"in o&&(l.inheritType=parseInt(o.InheritType.value)),"GeometricTranslation"in o&&(l.translation=o.GeometricTranslation.value),"GeometricRotation"in o&&(l.rotation=o.GeometricRotation.value),"GeometricScaling"in o&&(l.scale=o.GeometricScaling.value);let h=j0e(l);return this.genGeometry(t,s,r,h)}genGeometry(e,t,n,i){let r=new Dt;e.attrName&&(r.name=e.attrName);let a=this.parseGeoNode(e,t),s=this.genBuffers(a),o=new Bt(s.vertex,3);if(o.applyMatrix4(i),r.setAttribute("position",o),s.colors.length>0&&r.setAttribute("color",new Bt(s.colors,3)),t&&(r.setAttribute("skinIndex",new pm(s.weightsIndices,4)),r.setAttribute("skinWeight",new Bt(s.vertexWeights,4)),r.FBX_Deformer=t),s.normal.length>0){let e=(new Ln).getNormalMatrix(i),t=new Bt(s.normal,3);t.applyNormalMatrix(e),r.setAttribute("normal",t)}if(s.uvs.forEach((function(e,t){let n=0===t?"uv":`uv${t}`;r.setAttribute(n,new Bt(s.uvs[t],2))})),a.material&&"AllSame"!==a.material.mappingType){let e=s.materialIndex[0],t=0;if(s.materialIndex.forEach((function(n,i){n!==e&&(r.addGroup(t,i-t,e),e=n,t=i)})),r.groups.length>0){let t=r.groups[r.groups.length-1],n=t.start+t.count;n!==s.materialIndex.length&&r.addGroup(n,s.materialIndex.length-n,e)}0===r.groups.length&&r.addGroup(0,s.materialIndex.length,s.materialIndex[0])}return this.addMorphTargets(r,e,n,i),r}parseGeoNode(e,t){let n={};if(n.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],n.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return n.weightTable={},null!==t&&(n.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(i,r){void 0===n.weightTable[i]&&(n.weightTable[i]=[]),n.weightTable[i].push({id:t,weight:e.weights[r]})}))}))),n}genBuffers(e){let t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]},n=0,i=0,r=!1,a=[],s=[],o=[],l=[],h=[],c=[],u=this;return e.vertexIndices.forEach((function(d,p){let f,m=!1;d<0&&(d^=-1,m=!0);let g=[],v=[];if(a.push(3*d,3*d+1,3*d+2),e.color){let t=aP(p,n,d,e.color);o.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[d]&&e.weightTable[d].forEach((function(e){v.push(e.weight),g.push(e.id)})),v.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);let e=[0,0,0,0],t=[0,0,0,0];v.forEach((function(n,i){let r=n,a=g[i];t.forEach((function(t,n,i){if(r>t){i[n]=r,r=t;let s=e[n];e[n]=a,a=s}}))})),g=e,v=t}for(;v.length<4;)v.push(0),g.push(0);for(let e=0;e<4;++e)h.push(v[e]),c.push(g[e])}if(e.normal){let t=aP(p,n,d,e.normal);s.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(f=aP(p,n,d,e.material)[0],f<0&&(u.negativeMaterialIndices=!0,f=0)),e.uv&&e.uv.forEach((function(e,t){let i=aP(p,n,d,e);void 0===l[t]&&(l[t]=[]),l[t].push(i[0]),l[t].push(i[1])})),i++,m&&(i>4&&console.warn("THREE.FBXLoader: Polygons with more than four sides are not supported. Make sure to triangulate the geometry during export."),u.genFace(t,e,a,f,s,o,l,h,c,i),n++,i=0,a=[],s=[],o=[],l=[],h=[],c=[])})),t}genFace(e,t,n,i,r,a,s,o,l,h){for(let c=2;c1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");let a=e.get(r[0].ID);n[i]={name:t[i].attrName,layer:a}}return n}addClip(e){let t=[],n=this;return e.layer.forEach((function(e){t=t.concat(n.generateTracks(e))})),new po(e.name,-1,t)}generateTracks(e){let t=[],n=new O,i=new dr,r=new O;if(e.transform&&e.transform.decompose(n,i,r),n=n.toArray(),i=(new Xn).setFromQuaternion(i,e.eulerOrder).toArray(),r=r.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){let i=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");void 0!==i&&t.push(i)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){let n=this.generateRotationTrack(e.modelName,e.R.curves,i,e.preRotation,e.postRotation,e.eulerOrder);void 0!==n&&t.push(n)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){let n=this.generateVectorTrack(e.modelName,e.S.curves,r,"scale");void 0!==n&&t.push(n)}if(void 0!==e.DeformPercent){let n=this.generateMorphTrack(e);void 0!==n&&t.push(n)}return t}generateVectorTrack(e,t,n,i){let r=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(r,t,n);return new qa(e+"."+i,r,a)}generateRotationTrack(e,t,n,i,r,a){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(An.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(An.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(An.degToRad));let s=this.getTimesForAllAxes(t),o=this.getKeyframeTrackValues(s,t,n);void 0!==i&&((i=i.map(An.degToRad)).push(a),i=(new Xn).fromArray(i),i=(new dr).setFromEuler(i)),void 0!==r&&((r=r.map(An.degToRad)).push(a),r=(new Xn).fromArray(r),r=(new dr).setFromEuler(r).invert());let l=new dr,h=new Xn,c=[];for(let u=0;u1){let e=1,n=t[0];for(let i=1;i=180){let a=r/180,s=i/a,o=n+s,l=e.times[t-1],h=(e.times[t]-l)/a,c=l+h,u=[],d=[];for(;c1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),r=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===i&&","===r&&(r=n.replace(/"/g,"").replace(/,$/,"").trim());let a=this.getCurrentNode();if("Properties70"!==a.name){if("C"===i){let e=r.split(",").slice(1),t=parseInt(e[0]),n=parseInt(e[1]),s=r.split(",").slice(3);s=s.map((function(e){return e.trim().replace(/^"/,"")})),i="connections",r=[t,n],ivt(r,s),void 0===a[i]&&(a[i]=[])}"Node"===i&&(a.id=r),i in a&&Array.isArray(a[i])?a[i].push(r):"a"!==i?a[i]=r:a.a=r,this.setCurrentProp(a,i),"a"===i&&","!==r.slice(-1)&&(a.a=Z6(r))}else this.parseNodeSpecialProperty(e,i,r)}parseNodePropertyContinued(e){let t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=Z6(t.a))}parseNodeSpecialProperty(e,t,n){let i=n.split('",').map((function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")})),r=i[0],a=i[1],s=i[2],o=i[3],l=i[4];switch(a){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=Z6(l)}this.getPrevNode()[r]={type:a,type2:s,flag:o,value:l},this.setCurrentProp(this.getPrevNode(),r)}},t4=class{parse(e){let t=new lP(e);t.skip(23);let n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);let i=new cP;for(;!this.endOfContent(t);){let e=this.parseNode(t,n);null!==e&&i.add(e.name,e)}return i}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){let n={},i=t>=7500?e.getUint64():e.getUint32(),r=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();let a=e.getUint8(),s=e.getString(a);if(0===i)return null;let o=[];for(let u=0;u0?o[0]:"",h=o.length>1?o[1]:"",c=o.length>2?o[2]:"";for(n.singleProperty=1===r&&e.getOffset()===i;i>e.getOffset();){let i=this.parseNode(e,t);null!==i&&this.parseSubNode(s,n,i)}return n.propertyList=o,"number"==typeof l&&(n.id=l),""!==h&&(n.attrName=h),""!==c&&(n.attrType=c),""!==s&&(n.name=s),n}parseSubNode(e,t,n){if(!0===n.singleProperty){let e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if("Connections"===e&&"C"===n.name){let e=[];n.propertyList.forEach((function(t,n){0!==n&&e.push(t)})),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===n.name)Object.keys(n).forEach((function(e){t[e]=n[e]}));else if("Properties70"===e&&"P"===n.name){let e,i=n.propertyList[0],r=n.propertyList[1],a=n.propertyList[2],s=n.propertyList[3];0===i.indexOf("Lcl ")&&(i=i.replace("Lcl ","Lcl_")),0===r.indexOf("Lcl ")&&(r=r.replace("Lcl ","Lcl_")),e="Color"===r||"ColorRGB"===r||"Vector"===r||"Vector3D"===r||0===r.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[i]={type:r,type2:a,flag:s,value:e}}else void 0===t[n.name]?"number"==typeof n.id?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:"PoseNode"===n.name?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):void 0===t[n.name][n.id]&&(t[n.name][n.id]=n)}parseProperty(e){let t,n=e.getString(1);switch(n){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return t=e.getUint32(),e.getArrayBuffer(t);case"S":return t=e.getUint32(),e.getString(t);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":let i=e.getUint32(),r=e.getUint32(),a=e.getUint32();if(0===r)switch(n){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}let s=H0e(new Uint8Array(e.getArrayBuffer(a))),o=new lP(s.buffer);switch(n){case"b":case"c":return o.getBooleanArray(i);case"d":return o.getFloat64Array(i);case"f":return o.getFloat32Array(i);case"i":return o.getInt32Array(i);case"l":return o.getInt64Array(i)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+n)}}},lP=class{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(e){let t=[];for(let n=0;n=0&&(n=new Uint8Array(this.dv.buffer,t,i)),this._textDecoder.decode(n)}},cP=class{add(e,t){this[e]=t}};function evt(e){return e.byteLength>=21&&"Kaydara FBX Binary \0"===Y0e(e,0,21)}function tvt(e){let t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"],n=0;function i(t){let i=e[t-1];return e=e.slice(n+t),n++,i}for(let r=0;r=2.0 are supported.")));let l=new A4(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h=0&&void 0===s[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}l.setExtensions(a),l.setPlugins(s),l.parse(n,i)}parseAsync(e,t){let n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}};function avt(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}var Xr={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},s4=class{constructor(e){this.parser=e,this.name=Xr.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,a)}},v4=class{constructor(e){this.parser=e,this.name=Xr.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let a=r.extensions[t],s=i.images[a.source],o=n.textureLoader;if(s.uri){let e=n.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,a.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}},y4=class{constructor(e){this.parser=e,this.name=Xr.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;let a=r.extensions[t],s=i.images[a.source],o=n.textureLoader;if(s.uri){let e=n.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,a.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}},x4=class{constructor(e){this.name=Xr.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(t){let n=e.byteOffset||0,i=e.byteLength||0,a=e.count,s=e.byteStride,o=new Uint8Array(t,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(a,s,o,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){let t=new ArrayBuffer(a*s);return r.decodeGltfBuffer(new Uint8Array(t),a,s,o,e.mode,e.filter),t}))}))}return null}},b4=class{constructor(e){this.name=Xr.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;let i=t.meshes[n.mesh];for(let o of i.primitives)if(o.mode!==jl.TRIANGLES&&o.mode!==jl.TRIANGLE_STRIP&&o.mode!==jl.TRIANGLE_FAN&&void 0!==o.mode)return null;let r=n.extensions[this.name].attributes,a=[],s={};for(let o in r)a.push(this.parser.getDependency("accessor",r[o]).then((e=>(s[o]=e,s[o]))));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then((e=>{let t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,r=[];for(let a of n){let e=new et,t=new O,n=new dr,o=new O(1,1,1),l=new Pi(a.geometry,a.material,i);for(let r=0;r0||0===e.search(/^data\:image\/jpeg/)?"image/jpeg":e.search(/\.webp($|\?)/i)>0||0===e.search(/^data\:image\/webp/)?"image/webp":"image/png"}var pvt=new et,A4=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new avt,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=!1,r=-1;"undefined"!=typeof navigator&&(n=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=navigator.userAgent.indexOf("Firefox")>-1,r=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||i&&r<98?this.textureLoader=new Rs(this.options.manager):this.textureLoader=new Lb(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Kr(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){let a={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};tg(r,a,i),Xf(a,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(a)}))).then((function(){e(a)}))})).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=t.length;i{let n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(let[i,a]of e.children.entries())r(a,t.children[i])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&a.setY(t,u[e*o+1]),o>=3&&a.setZ(t,u[e*o+2]),o>=4&&a.setW(t,u[e*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return a}))}loadTexture(e){let t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i],a=this.textureLoader;if(r.uri){let e=n.manager.getHandler(r.uri);null!==e&&(a=e)}return this.loadTextureImage(e,i,a)}loadTextureImage(e,t,n){let i=this,r=this.json,a=r.textures[e],s=r.images[t],o=(s.uri||s.bufferView)+":"+a.sampler;if(this.textureCache[o])return this.textureCache[o];let l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=a.name||s.name||"",""===t.name&&"string"==typeof s.uri&&!1===s.uri.startsWith("data:image/")&&(t.name=s.uri);let n=(r.samplers||{})[a.sampler]||{};return t.magFilter=Z0e[n.magFilter]||Ir,t.minFilter=Z0e[n.minFilter]||Ua,t.wrapS=K0e[n.wrapS]||Ci,t.wrapT=K0e[n.wrapT]||Ci,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){let n=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));let r=n.images[e],a=self.URL||self.webkitURL,s=r.uri||"",o=!1;if(void 0!==r.bufferView)s=this.getDependency("bufferView",r.bufferView).then((function(e){o=!0;let t=new Blob([e],{type:r.mimeType});return s=a.createObjectURL(t),s}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(s).then((function(e){return new Promise((function(n,r){let a=n;!0===t.isImageBitmapLoader&&(a=function(e){let t=new qr(e);t.needsUpdate=!0,n(t)}),t.load(ra.resolveURL(e,i.path),a,void 0,r)}))})).then((function(e){return!0===o&&a.revokeObjectURL(s),e.userData.mimeType=r.mimeType||fvt(r.uri),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",s),e}));return this.sourceCache[e]=l,l}assignTexture(e,t,n,i){let r=this;return this.getDependency("texture",n.index).then((function(a){if(!a)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((a=a.clone()).channel=n.texCoord),r.extensions[Xr.KHR_TEXTURE_TRANSFORM]){let e=void 0!==n.extensions?n.extensions[Xr.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=r.associations.get(a);a=r.extensions[Xr.KHR_TEXTURE_TRANSFORM].extendTexture(a,e),r.associations.set(a,t)}}return void 0!==i&&(a.colorSpace=i),e[t]=a,a}))}assignFinalMaterial(e){let t=e.geometry,n=e.material,i=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,a=void 0===t.attributes.normal;if(e.isPoints){let e="PointsMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new xi,yr.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){let e="LineBasicMaterial:"+n.uuid,t=this.cache.get(e);t||(t=new Gn,yr.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(i||r||a){let e="ClonedMaterial:"+n.uuid+":";i&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),a&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),a&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return hf}loadMaterial(e){let t,n=this,i=this.json,r=this.extensions,a=i.materials[e],s={},o=[];if((a.extensions||{})[Xr.KHR_MATERIALS_UNLIT]){let e=r[Xr.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),o.push(e.extendParams(s,a,n))}else{let i=a.pbrMetallicRoughness||{};if(s.color=new ct(1,1,1),s.opacity=1,Array.isArray(i.baseColorFactor)){let e=i.baseColorFactor;s.color.fromArray(e),s.opacity=e[3]}void 0!==i.baseColorTexture&&o.push(n.assignTexture(s,"map",i.baseColorTexture,tn)),s.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,s.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(o.push(n.assignTexture(s,"metalnessMap",i.metallicRoughnessTexture)),o.push(n.assignTexture(s,"roughnessMap",i.metallicRoughnessTexture))),t=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),o.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,s)}))))}!0===a.doubleSided&&(s.side=Sr);let l=a.alphaMode||r4.OPAQUE;if(l===r4.BLEND?(s.transparent=!0,s.depthWrite=!1):(s.transparent=!1,l===r4.MASK&&(s.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&t!==on&&(o.push(n.assignTexture(s,"normalMap",a.normalTexture)),s.normalScale=new be(1,1),void 0!==a.normalTexture.scale)){let e=a.normalTexture.scale;s.normalScale.set(e,e)}return void 0!==a.occlusionTexture&&t!==on&&(o.push(n.assignTexture(s,"aoMap",a.occlusionTexture)),void 0!==a.occlusionTexture.strength&&(s.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&t!==on&&(s.emissive=(new ct).fromArray(a.emissiveFactor)),void 0!==a.emissiveTexture&&t!==on&&o.push(n.assignTexture(s,"emissiveMap",a.emissiveTexture,tn)),Promise.all(o).then((function(){let i=new t(s);return a.name&&(i.name=a.name),Xf(i,a),n.associations.set(i,{materials:e}),a.extensions&&tg(r,i,a),i}))}createUniqueName(e){let t=Jn.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,i=this.primitiveCache;function r(e){return n[Xr.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return J0e(n,e,t)}))}let a=[];for(let s=0,o=e.length;s0&&hvt(n,r),n.name=t.createUniqueName(r.name||"mesh_"+e),Xf(n,r),u.extensions&&tg(i,n,u),t.assignFinalMaterial(n),l.push(n)}for(let i=0,r=l.length;i1?new er:1===t.length?t[0]:new an,s!==t[0])for(let e=0,n=t.length;e{let t=new Map;for(let[n,r]of i.associations)(n instanceof yr||n instanceof qr)&&t.set(n,r);return e.traverse((e=>{let n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}_createAnimationTracks(e,t,n,i,r){let a,s=[],o=e.name?e.name:e.uuid,l=[];switch(jf[r.path]===jf.weights?e.traverse((function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)})):l.push(o),jf[r.path]){case jf.weights:a=Cl;break;case jf.rotation:a=Ga;break;case jf.position:case jf.scale:a=qa;break;default:a=1===n.itemSize?Cl:qa}let h=void 0!==i.interpolation?lvt[i.interpolation]:Tu,c=this._getArrayFromAccessor(n);for(let u=0,d=l.length;u=0?e.substring(0,t):e;s=s.toLowerCase();let l=t>=0?e.substring(t+1):"";if(l=l.trim(),"newmtl"===s)i={name:l},a[l]=i;else if("ka"===s||"kd"===s||"ks"===s||"ke"===s){let e=l.split(r,3);i[s]=[parseFloat(e[0]),parseFloat(e[1]),parseFloat(e[2])]}else i[s]=l}let s=new C4(this.resourcePath||t,this.materialOptions);return s.setCrossOrigin(this.crossOrigin),s.setManager(this.manager),s.setMaterials(a),s}},C4=class{constructor(e="",t={}){this.baseUrl=e,this.options=t,this.materialsInfo={},this.materials={},this.materialsArray=[],this.nameLookup={},this.crossOrigin="anonymous",this.side=void 0!==this.options.side?this.options.side:pi,this.wrap=void 0!==this.options.wrap?this.options.wrap:Ci}setCrossOrigin(e){return this.crossOrigin=e,this}setManager(e){this.manager=e}setMaterials(e){this.materialsInfo=this.convert(e),this.materials={},this.materialsArray=[],this.nameLookup={}}convert(e){if(!this.options)return e;let t={};for(let n in e){let i=e[n],r={};t[n]=r;for(let e in i){let t=!0,n=i[e],a=e.toLowerCase();switch(a){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(n=[n[0]/255,n[1]/255,n[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===n[0]&&0===n[1]&&0===n[2]&&(t=!1)}t&&(r[a]=n)}}return t}preload(){for(let e in this.materialsInfo)this.create(e)}getIndex(e){return this.nameLookup[e]}getAsArray(){let e=0;for(let t in this.materialsInfo)this.materialsArray[e]=this.create(t),this.nameLookup[t]=e,e++;return this.materialsArray}create(e){return void 0===this.materials[e]&&this.createMaterial_(e),this.materials[e]}createMaterial_(e){let t=this,n=this.materialsInfo[e],i={name:e,side:this.side};function r(e,n){if(i[e])return;let r=t.getTextureParams(n,i),a=t.loadTexture(function(e,t){return"string"!=typeof t||""===t?"":/^https?:\/\//i.test(t)?t:e+t}(t.baseUrl,r.url));a.repeat.copy(r.scale),a.offset.copy(r.offset),a.wrapS=t.wrap,a.wrapT=t.wrap,("map"===e||"emissiveMap"===e)&&(a.colorSpace=tn),i[e]=a}for(let a in n){let e,t=n[a];if(""!==t)switch(a.toLowerCase()){case"kd":i.color=(new ct).fromArray(t).convertSRGBToLinear();break;case"ks":i.specular=(new ct).fromArray(t).convertSRGBToLinear();break;case"ke":i.emissive=(new ct).fromArray(t).convertSRGBToLinear();break;case"map_kd":r("map",t);break;case"map_ks":r("specularMap",t);break;case"map_ke":r("emissiveMap",t);break;case"norm":r("normalMap",t);break;case"map_bump":case"bump":r("bumpMap",t);break;case"map_d":r("alphaMap",t),i.transparent=!0;break;case"ns":i.shininess=parseFloat(t);break;case"d":e=parseFloat(t),e<1&&(i.opacity=e,i.transparent=!0);break;case"tr":e=parseFloat(t),this.options&&this.options.invertTrProperty&&(e=1-e),e>0&&(i.opacity=1-e,i.transparent=!0)}}return this.materials[e]=new na(i),this.materials[e]}getTextureParams(e,t){let n,i={scale:new be(1,1),offset:new be(0,0)},r=e.split(/\s+/);return n=r.indexOf("-bm"),n>=0&&(t.bumpScale=parseFloat(r[n+1]),r.splice(n,2)),n=r.indexOf("-s"),n>=0&&(i.scale.set(parseFloat(r[n+1]),parseFloat(r[n+2])),r.splice(n,4)),n=r.indexOf("-o"),n>=0&&(i.offset.set(parseFloat(r[n+1]),parseFloat(r[n+2])),r.splice(n,4)),i.url=r.join(" ").trim(),i}loadTexture(e,t,n,i,r){let a=void 0!==this.manager?this.manager:go,s=a.getHandler(e);null===s&&(s=new Rs(a)),s.setCrossOrigin&&s.setCrossOrigin(this.crossOrigin);let o=s.load(e,n,i,r);return void 0!==t&&(o.mapping=t),o}},gvt=/^[og]\s*(.+)?/,vvt=/^mtllib /,yvt=/^usemtl /,xvt=/^usemap /,eve=/\s+/,tve=new O,P4=new O,nve=new O,rve=new O,Xl=new O,dP=new ct;function bvt(){let e={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&!1===this.object.fromDeclaration)return this.object.name=e,void(this.object.fromDeclaration=!1!==t);let n=this.object&&"function"==typeof this.object.currentMaterial?this.object.currentMaterial():void 0;if(this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:!1!==t,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(e,t){let n=this._finalize(!1);n&&(n.inherited||n.groupCount<=0)&&this.materials.splice(n.index,1);let i={index:this.materials.length,name:e||"",mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:"",smooth:void 0!==n?n.smooth:this.smooth,groupStart:void 0!==n?n.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){let t={index:"number"==typeof e?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(i),i},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){let t=this.currentMaterial();if(t&&-1===t.groupEnd&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(let n=this.materials.length-1;n>=0;n--)this.materials[n].groupCount<=0&&this.materials.splice(n,1);return e&&0===this.materials.length&&this.materials.push({name:"",smooth:this.smooth}),t}},n&&n.name&&"function"==typeof n.clone){let e=n.clone(0);e.inherited=!0,this.object.materials.push(e)}this.objects.push(this.object)},finalize:function(){this.object&&"function"==typeof this.object._finalize&&this.object._finalize(!0)},parseVertexIndex:function(e,t){let n=parseInt(e,10);return 3*(n>=0?n-1:n+t/3)},parseNormalIndex:function(e,t){let n=parseInt(e,10);return 3*(n>=0?n-1:n+t/3)},parseUVIndex:function(e,t){let n=parseInt(e,10);return 2*(n>=0?n-1:n+t/2)},addVertex:function(e,t,n){let i=this.vertices,r=this.object.geometry.vertices;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addVertexPoint:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){let i=this.normals,r=this.object.geometry.normals;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[n+0],i[n+1],i[n+2])},addFaceNormal:function(e,t,n){let i=this.vertices,r=this.object.geometry.normals;tve.fromArray(i,e),P4.fromArray(i,t),nve.fromArray(i,n),Xl.subVectors(nve,P4),rve.subVectors(tve,P4),Xl.cross(rve),Xl.normalize(),r.push(Xl.x,Xl.y,Xl.z),r.push(Xl.x,Xl.y,Xl.z),r.push(Xl.x,Xl.y,Xl.z)},addColor:function(e,t,n){let i=this.colors,r=this.object.geometry.colors;void 0!==i[e]&&r.push(i[e+0],i[e+1],i[e+2]),void 0!==i[t]&&r.push(i[t+0],i[t+1],i[t+2]),void 0!==i[n]&&r.push(i[n+0],i[n+1],i[n+2])},addUV:function(e,t,n){let i=this.uvs,r=this.object.geometry.uvs;r.push(i[e+0],i[e+1]),r.push(i[t+0],i[t+1]),r.push(i[n+0],i[n+1])},addDefaultUV:function(){let e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){let t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,i,r,a,s,o,l){let h=this.vertices.length,c=this.parseVertexIndex(e,h),u=this.parseVertexIndex(t,h),d=this.parseVertexIndex(n,h);if(this.addVertex(c,u,d),this.addColor(c,u,d),void 0!==s&&""!==s){let e=this.normals.length;c=this.parseNormalIndex(s,e),u=this.parseNormalIndex(o,e),d=this.parseNormalIndex(l,e),this.addNormal(c,u,d)}else this.addFaceNormal(c,u,d);if(void 0!==i&&""!==i){let e=this.uvs.length;c=this.parseUVIndex(i,e),u=this.parseUVIndex(r,e),d=this.parseUVIndex(a,e),this.addUV(c,u,d),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";let t=this.vertices.length;for(let n=0,i=e.length;n=7?(dP.setRGB(parseFloat(n[4]),parseFloat(n[5]),parseFloat(n[6])).convertSRGBToLinear(),t.colors.push(dP.r,dP.g,dP.b)):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(n[1]),parseFloat(n[2]),parseFloat(n[3]));break;case"vt":t.uvs.push(parseFloat(n[1]),parseFloat(n[2]))}}else if("f"===r){let n=e.slice(1).trim().split(eve),i=[];for(let e=0,t=n.length;e0){let e=t.split("/");i.push(e)}}let r=i[0];for(let e=1,a=i.length-1;e1){let e=i[1].trim().toLowerCase();t.object.smooth="0"!==e&&"off"!==e}else t.object.smooth=!0;let n=t.object.currentMaterial();n&&(n.smooth=t.object.smooth)}else{if("\0"===e)continue;console.warn('THREE.OBJLoader: Unexpected line: "'+e+'"')}}t.finalize();let r=new er;if(r.materialLibraries=[].concat(t.materialLibraries),1==!(1===t.objects.length&&0===t.objects[0].geometry.vertices.length))for(let a=0,s=t.objects.length;a0&&h.setAttribute("normal",new Bt(n.normals,3)),n.colors.length>0&&(l=!0,h.setAttribute("color",new Bt(n.colors,3))),!0===n.hasUVIndices&&h.setAttribute("uv",new Bt(n.uvs,2));let c,u=[];for(let r=0,a=i.length;r1){for(let e=0,t=i.length;e0){let e=new xi({size:1,sizeAttenuation:!1}),n=new Dt;n.setAttribute("position",new Bt(t.vertices,3)),t.colors.length>0&&void 0!==t.colors[0]&&(n.setAttribute("color",new Bt(t.colors,3)),e.vertexColors=!0);let i=new ii(n,e);r.add(i)}return r}},wo=new ct,pP=class extends Er{constructor(e){super(e),this.propertyNameMapping={},this.customPropertyMapping={}}load(e,t,n,i){let r=this,a=new Kr(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{t(r.parse(n))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}setPropertyNameMapping(e){this.propertyNameMapping=e}setCustomPropertyNameMapping(e){this.customPropertyMapping=e}parse(e){function t(e,t=0){let n="",i=/^ply([\s\S]*)end_header(\r\n|\r|\n)/.exec(e);null!==i&&(n=i[1]);let r,a={comments:[],elements:[],headerLength:t,objInfo:""},s=n.split(/\r\n|\r|\n/);function o(e,t){let n={type:e[0]};return"list"===n.type?(n.name=e[3],n.countType=e[1],n.itemType=e[2]):n.name=e[1],n.name in t&&(n.name=t[n.name]),n}for(let l=0;le.name));function n(e){for(let n=0,i=e.length;n0&&t.setIndex(e.indices),t.setAttribute("position",new Bt(e.vertices,3)),e.normals.length>0&&t.setAttribute("normal",new Bt(e.normals,3)),e.uvs.length>0&&t.setAttribute("uv",new Bt(e.uvs,2)),e.colors.length>0&&t.setAttribute("color",new Bt(e.colors,3)),(e.faceVertexUvs.length>0||e.faceVertexColors.length>0)&&(t=t.toNonIndexed(),e.faceVertexUvs.length>0&&t.setAttribute("uv",new Bt(e.faceVertexUvs,2)),e.faceVertexColors.length>0&&t.setAttribute("color",new Bt(e.faceVertexColors,3)));for(let n of Object.keys(d.customPropertyMapping))e[n].length>0&&t.setAttribute(n,new Bt(e[n],d.customPropertyMapping[n].length));return t.computeBoundingSphere(),t}function l(e,t,n,i){if("vertex"===t){e.vertices.push(n[i.attrX],n[i.attrY],n[i.attrZ]),null!==i.attrNX&&null!==i.attrNY&&null!==i.attrNZ&&e.normals.push(n[i.attrNX],n[i.attrNY],n[i.attrNZ]),null!==i.attrS&&null!==i.attrT&&e.uvs.push(n[i.attrS],n[i.attrT]),null!==i.attrR&&null!==i.attrG&&null!==i.attrB&&(wo.setRGB(n[i.attrR]/255,n[i.attrG]/255,n[i.attrB]/255).convertSRGBToLinear(),e.colors.push(wo.r,wo.g,wo.b));for(let t of Object.keys(d.customPropertyMapping))for(let i of d.customPropertyMapping[t])e[t].push(n[i])}else if("face"===t){let t=n.vertex_indices||n.vertex_index,r=n.texcoord;3===t.length?(e.indices.push(t[0],t[1],t[2]),r&&6===r.length&&(e.faceVertexUvs.push(r[0],r[1]),e.faceVertexUvs.push(r[2],r[3]),e.faceVertexUvs.push(r[4],r[5]))):4===t.length&&(e.indices.push(t[0],t[1],t[3]),e.indices.push(t[1],t[2],t[3])),null!==i.attrR&&null!==i.attrG&&null!==i.attrB&&(wo.setRGB(n[i.attrR]/255,n[i.attrG]/255,n[i.attrB]/255).convertSRGBToLinear(),e.faceVertexColors.push(wo.r,wo.g,wo.b),e.faceVertexColors.push(wo.r,wo.g,wo.b),e.faceVertexColors.push(wo.r,wo.g,wo.b))}}function h(e,t){let n={},i=0;for(let r=0;re.getInt8(t),size:1};case"uint8":case"uchar":return{read:t=>e.getUint8(t),size:1};case"int16":case"short":return{read:t=>e.getInt16(t,n),size:2};case"uint16":case"ushort":return{read:t=>e.getUint16(t,n),size:2};case"int32":case"int":return{read:t=>e.getInt32(t,n),size:4};case"uint32":case"uint":return{read:t=>e.getUint32(t,n),size:4};case"float32":case"float":return{read:t=>e.getFloat32(t,n),size:4};case"float64":case"double":return{read:t=>e.getFloat64(t,n),size:8}}}for(let r=0,a=e.length;r=this.arr.length}next(){return this.arr[this.i++]}},mP=class extends Er{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new Kr(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{t(r.parse(n))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e){function t(e,t,n){for(let i=0,r=e.length;i>5&31)/31,i=(r>>10&31)/31)}for(let a=1;a<=3;a++){let s=e+12*a,o=3*g*3+3*(a-1);p[o]=h.getFloat32(s,!0),p[o+1]=h.getFloat32(s+4,!0),p[o+2]=h.getFloat32(s+8,!0),f[o]=l,f[o+1]=c,f[o+2]=d,u&&(m.set(t,n,i).convertSRGBToLinear(),r[o]=m.r,r[o+1]=m.g,r[o+2]=m.b)}}return d.setAttribute("position",new mn(p,3)),d.setAttribute("normal",new mn(f,3)),u&&(d.setAttribute("color",new mn(r,3)),d.hasColors=!0,d.alpha=l),d}(n):function(e){let t,n=new Dt,i=/solid([\s\S]*?)endsolid/g,r=/facet([\s\S]*?)endfacet/g,a=0,s=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,o=new RegExp("vertex"+s+s+s,"g"),l=new RegExp("normal"+s+s+s,"g"),h=[],c=[],u=new O,d=0,p=0,f=0;for(;null!==(t=i.exec(e));){p=f;let e=t[0];for(;null!==(t=r.exec(e));){let e=0,n=0,i=t[0];for(;null!==(t=l.exec(i));)u.x=parseFloat(t[1]),u.y=parseFloat(t[2]),u.z=parseFloat(t[3]),n++;for(;null!==(t=o.exec(i));)h.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])),c.push(u.x,u.y,u.z),e++,f++;1!==n&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+a),3!==e&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+a),a++}let i=p,s=f-p;n.addGroup(i,s,d),d++}return n.setAttribute("position",new Bt(h,3)),n.setAttribute("normal",new Bt(c,3)),n}("string"!=typeof(i=e)?(new TextDecoder).decode(i):i);var i}},ng=class{constructor(e){this.buffer=e,this.u8=new Uint8Array(e)}getBit(e){var t=7&e;return(this.u8[e>>3]&128>>t)>>7-t}setBit(e,t){var n=e>>3,i=this.u8[n],r=7&e;this.u8[n]=t?i|128>>r:i&~(128>>r)}getInt12(e){var t=e/8|0,n=this.u8[t],i=this.u8[t+1],r=this.u8[t+2],a=e%8,s=8-a,o=Math.min(12-s,8);return(((n&=~(255<>12-a)-2048}setInt12(e,t){var n=e/8|0,i=e%8,r=(t+=2048)<<12-i,a=(16711680&r)>>16,s=(65280&r)>>8,o=255&r,l=8-i,h=Math.min(12-l,8),c=Math.max(12-l-h,0),u=255<>8-(2-r))))<<8)+(i&=255<<8-Math.max(6-a,0))>>10-r)-32}setInt6(e,t){var n=e/8|0,i=e%8,r=(t+=32)<<10-i,a=(65280&r)>>8,s=255&r,o=8-i,l=Math.max(6-o,0),h=(255<>8-(2-i));this.u8[n]=(this.u8[n]&h)+a;var c=~(255<<8-l);this.u8[n+1]=(this.u8[n+1]&c)+s}test(){var e,t,n=new ArrayBuffer(3),i=new ng(n);for(t=0;t<12;t++)for(e=-2048;e<2048;e++)if(i.setInt12(t,e),i.getInt12(t)!=e){console.log("12-bit prob at",t,e),console.log("expected",e,"got",i.getInt12(t));break}for(t=0;t<18;t++)for(e=-32;e<32;e++)if(i.setInt6(t,e),i.getInt6(t)!=e){console.log("6-bit prob at",t,e),console.log("expected",e,"got",i.getInt6(t));break}return i}},ive=(e=>(e[e.NULL=0]="NULL",e[e.POINT=1]="POINT",e[e.POLYLINE=3]="POLYLINE",e[e.POLYGON=5]="POLYGON",e))(ive||{}),gP=class{parse(e){var t={},n=new DataView(e),i=0;if(t.fileCode=n.getInt32(i,!1),9994!=t.fileCode)throw new Error("Unknown file code: "+t.fileCode);for(i+=24,t.wordLength=n.getInt32(i,!1),t.byteLength=2*t.wordLength,i+=4,t.version=n.getInt32(i,!0),i+=4,t.shapeType=n.getInt32(i,!0),i+=4,t.minX=n.getFloat64(i,!0),t.minY=n.getFloat64(i+8,!0),t.maxX=n.getFloat64(i+16,!0),t.maxY=n.getFloat64(i+24,!0),t.minZ=n.getFloat64(i+32,!0),t.maxZ=n.getFloat64(i+40,!0),t.minM=n.getFloat64(i+48,!0),t.maxM=n.getFloat64(i+56,!0),i+=64,t.records=[];ir.push(...e)));let a=new Dt;a.setFromPoints(e),a.setIndex(r),t.push(a);let s=new Dt;e.length>2&&!e[0].equals(e[e.length-1])&&e.push(e[0]),s.setFromPoints(e),n.push(s)}else{let t=new Dt;t.setFromPoints(e),n.push(t)}}}var d=new an;for(i=0;i1023||Math.abs(a-e[o+1])>1023?(n.push(i),s+=1,i=[],r=e[o],a=e[o+1],i.push(r,a),s+=4,o++):(i.push((e[o]-r)/8,(e[o+1]-a)/8),r+=8*((e[o]-r)/8|0),a+=8*((e[o+1]-a)/8|0),s+=2,o++):(n.push(i),t.push(n),n=[],i=[],s+=3);return this.storeDeltas(s,t)}deltaEncode6(e){var t=[],n=[],i=[],r=0,a=0,s=0,o=0;for(s=0;s31||Math.abs(a-e[s+1])>31?(n.push(i),o+=1,i=[],r=e[s],a=e[s+1],i.push(r,a),o+=4,s++):(i.push(e[s]-r,e[s+1]-a),r+=e[s]-r,a+=e[s+1]-a,o+=2,s++):(n.push(i),t.push(n),n=[],i=[],o+=3);return this.storeDeltas6(o,t)}storeDeltas(e,t){for(var n=new ArrayBuffer(e),i=new DataView(n),r=0,a=0;a{this.updateProgress(n,50);let e=(new gP).parse(r.response),i=(new vP).createModel(e);this.updateProgress(n,99),t(i)},r.onerror=i,r.open("GET",e),r.send(null)}))}updateProgress(e,t){e&&e(new ProgressEvent("progress",{lengthComputable:!0,loaded:t,total:100}))}},L4=class{constructor(e){this.manager=e}loadLocalModel(e,t,n){return ft(this,null,(function*(){let i=t.toLowerCase();return i.endsWith("fbx")?this.loadFbx(e,n):i.endsWith("obj")?this.loadObj(e,n):i.endsWith("stl")?this.loadStl(e,n):i.endsWith("ifc")?(se.warn("[LoadingHelper] IFC is not supported directly since three.js r150!"),Promise.reject("Not supported!")):i.endsWith("shp")?this.loadShp(e,n):i.endsWith("dae")?this.loadDae(e,n):i.endsWith("dxf")?this.loadDxf(e,n):i.endsWith("jpg")||i.endsWith("jpeg")||i.endsWith("png")?this.loadImage(e,n):this.loadGltf(e,n)}))}loadModel(e,t,n){return ft(this,null,(function*(){let i=e;if(!i)return Promise.resolve();let r=(null==t?void 0:t.toLowerCase())||"";if(!r){let e=i.split("?")[0].toLowerCase();if(e){let t=e.lastIndexOf(".");-1!==t&&(r=e.slice(t+1))}}return r.endsWith("fbx")?this.loadFbx(i,n):r.endsWith("obj")?this.loadObj(i,n):r.endsWith("stl")?this.loadStl(i,n):r.endsWith("ifc")?void se.warn("[LoadingHelper] IFC is not supported directly since three.js r150!"):r.endsWith("shp")?this.loadShp(i,n):r.endsWith("dae")?this.loadDae(i,n):r.endsWith("dxf")?this.loadDxf(i,n):r.endsWith("jpg")||r.endsWith("jpeg")||r.endsWith("png")?this.loadImage(i,n):this.loadGltf(i,n)}))}loadGltf(e,t){return ft(this,null,(function*(){let n=this.getGltfLoader();-1!==e.indexOf("#")&&console.warn(`[LoadingHelper] '#' is not allowed in filename ${e}`),e=e.replace(/#/g,encodeURIComponent("#"));let i=yield n.loadAsync(e,(e=>{0===e.total&&e.loaded>0||t&&t(e)}));return Promise.resolve(i.scene)}))}parseGltf(e,t,n,i){return this.getGltfLoader().parse(e,t,(e=>n(e.scene)),i)}loadFbx(e,t){return ft(this,null,(function*(){let n=yield new oP(this.manager).loadAsync(e,t);return Promise.resolve(n)}))}loadObj(e,t){return ft(this,null,(function*(){let n=new fP(this.manager),i=new hP(this.manager),r=e.replace(".obj",".mtl"),a=yield i.loadAsync(r,t);a.preload(),n.setMaterials(a);let s=yield n.loadAsync(e,t);return Promise.resolve(s)}))}loadStl(e,t){return ft(this,null,(function*(){let n=yield new mP(this.manager).loadAsync(e,t);return Promise.resolve(new xt(n))}))}loadShp(e,t){return ft(this,null,(function*(){let n=new yP;return new Promise(((i,r)=>{n.load(e,(e=>{i(e)}),t,(e=>{r(e)}))}))}))}loadDae(e,t){return ft(this,null,(function*(){let n=yield new rP(this.manager).loadAsync(e,t);return Promise.resolve(n.scene)}))}loadDxf(e,t){return ft(this,null,(function*(){var n;this.font||console.warn("[LoadingHelper] Should set font first!");let i=new gn(this.manager,{ignorePaperSpace:!0,enableLocalCache:!1});i.setFont(this.font),yield null==(n=this.font)?void 0:n.getFontFromIndexeddb();try{let n=yield i.loadAsync(e,t);return Promise.resolve(n.threejsObject)}catch(e){let n=new ErrorEvent("");return Promise.reject(n)}}))}loadPly(e,t){return ft(this,null,(function*(){let n=yield new pP(this.manager).loadAsync(e,t);return Promise.resolve(new xt(n))}))}loadImage(e,t){return ft(this,null,(function*(){let n=yield new Rs(this.manager).loadAsync(e,t);if(!n)return Promise.reject("Failed to load image!");let i=n.image,r=i&&i.height||10,a=i&&i.width||10;r*=10/a,a=10;let s=new on({map:n,side:Sr,transparent:!0}),o=new ui(a,r),l=new xt(o,s);return Promise.resolve(l)}))}loadDxfData(e,t,n,i,r){return ft(this,null,(function*(){var a;this.font||console.warn("[LoadingHelper] Should set font first!");let s=new gn(this.manager,r);return s.setFont(this.font),yield null==(a=this.font)?void 0:a.getFontFromIndexeddb(),s.manager.onLoad=()=>{i&&i()},s.load(e,t,n)}))}setFont(e){this.font=e}static setDracoDecoderPath(e){this.decoderPath=e}getGltfLoader(){if(!this.gltfLoader){this.gltfLoader=new th(this.manager);let e=new iP(this.manager);e.setDecoderPath(L4.decoderPath),this.gltfLoader.setDRACOLoader(e)}return this.gltfLoader}},$a=L4;function D4(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),i=new Worker(n);return URL.revokeObjectURL(n),i}function O4(){return D4('var Jc=Object.defineProperty,$c=Object.defineProperties;var Kc=Object.getOwnPropertyDescriptors;var zo=Object.getOwnPropertySymbols;var Qc=Object.prototype.hasOwnProperty,jc=Object.prototype.propertyIsEnumerable;var Vo=(i,t,e)=>t in i?Jc(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,ts=(i,t)=>{for(var e in t||(t={}))Qc.call(t,e)&&Vo(i,e,t[e]);if(zo)for(var e of zo(t))jc.call(t,e)&&Vo(i,e,t[e]);return i},ko=(i,t)=>$c(i,Kc(t));var mo="155";var tl=0,Ho=1,el=2;var ac=1,nl=2,rn=3,He=0,he=1,ze=2;var vn=0,fi=1,Go=2,Wo=3,Xo=4,il=5,li=100,sl=101,rl=102,qo=103,Yo=104,ol=200,al=201,cl=202,ll=203,cc=204,lc=205,hl=206,ul=207,fl=208,dl=209,pl=210,ml=0,gl=1,_l=2,Lr=3,xl=4,yl=5,vl=6,Ml=7,hc=0,Sl=1,bl=2,Mn=0,El=1,Tl=2,wl=3,Al=4,Rl=5,uc=300,mi=301,gi=302,Ir=303,Ur=304,Bs=306,Dr=1e3,Ve=1001,Nr=1002,pe=1003,Zo=1004;var er=1005;var Ie=1006,Cl=1007;var Hi=1008;var Sn=1009,Pl=1010,Ll=1011,go=1012,fc=1013,xn=1014,yn=1015,Gi=1016,dc=1017,pc=1018,Fn=1020,Il=1021,ke=1023,Ul=1024,Dl=1025,On=1026,_i=1027,Nl=1028,mc=1029,Fl=1030,gc=1031,_c=1033,nr=33776,ir=33777,sr=33778,rr=33779,Jo=35840,$o=35841,Ko=35842,Qo=35843,Ol=36196,jo=37492,ta=37496,ea=37808,na=37809,ia=37810,sa=37811,ra=37812,oa=37813,aa=37814,ca=37815,la=37816,ha=37817,ua=37818,fa=37819,da=37820,pa=37821,or=36492,Bl=36283,ma=36284,ga=36285,_a=36286;var bs=2300,Es=2301,ar=2302,xa=2400,ya=2401,va=2402;var xc=3e3,Bn=3001,zl=3200,Vl=3201,kl=0,Hl=1,zn="",Rt="srgb",Ze="srgb-linear",yc="display-p3";var cr=7680;var Gl=519,Wl=512,Xl=513,ql=514,Yl=515,Zl=516,Jl=517,$l=518,Kl=519,Ma=35044;var Sa="300 es",Fr=1035,on=2e3,Ts=2001,bn=class{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;let n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;let s=this._listeners[t];if(s!==void 0){let r=s.indexOf(e);r!==-1&&s.splice(r,1)}}dispatchEvent(t){if(this._listeners===void 0)return;let n=this._listeners[t.type];if(n!==void 0){t.target=this;let s=n.slice(0);for(let r=0,a=s.length;r>8&255]+ce[i>>16&255]+ce[i>>24&255]+"-"+ce[t&255]+ce[t>>8&255]+"-"+ce[t>>16&15|64]+ce[t>>24&255]+"-"+ce[e&63|128]+ce[e>>8&255]+"-"+ce[e>>16&255]+ce[e>>24&255]+ce[n&255]+ce[n>>8&255]+ce[n>>16&255]+ce[n>>24&255]).toLowerCase()}function me(i,t,e){return Math.max(t,Math.min(e,i))}function Ql(i,t){return(i%t+t)%t}function hr(i,t,e){return(1-e)*i+e*t}function ba(i){return(i&i-1)===0&&i!==0}function Br(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Di(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function ye(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}var Nt=class{constructor(t=0,e=0){Nt.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,n=this.y,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(me(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let n=Math.cos(e),s=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*s+t.x,this.y=r*s+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Ct=class{constructor(t,e,n,s,r,a,o,c,l){Ct.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,c,l)}set(t,e,n,s,r,a,o,c,l){let h=this.elements;return h[0]=t,h[1]=s,h[2]=o,h[3]=e,h[4]=r,h[5]=c,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],d=n[7],u=n[2],m=n[5],g=n[8],x=s[0],p=s[3],f=s[6],v=s[1],_=s[4],b=s[7],S=s[2],T=s[5],A=s[8];return r[0]=a*x+o*v+c*S,r[3]=a*p+o*_+c*T,r[6]=a*f+o*b+c*A,r[1]=l*x+h*v+d*S,r[4]=l*p+h*_+d*T,r[7]=l*f+h*b+d*A,r[2]=u*x+m*v+g*S,r[5]=u*p+m*_+g*T,r[8]=u*f+m*b+g*A,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-n*r*h+n*o*c+s*r*l-s*a*c}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],d=h*a-o*l,u=o*c-h*r,m=l*r-a*c,g=e*d+n*u+s*m;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let x=1/g;return t[0]=d*x,t[1]=(s*l-h*n)*x,t[2]=(o*n-s*a)*x,t[3]=u*x,t[4]=(h*e-s*c)*x,t[5]=(s*r-o*e)*x,t[6]=m*x,t[7]=(n*c-l*e)*x,t[8]=(a*e-n*r)*x,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,s,r,a,o){let c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+t,-s*l,s*c,-s*(-l*a+c*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(ur.makeScale(t,e)),this}rotate(t){return this.premultiply(ur.makeRotation(-t)),this}translate(t,e){return this.premultiply(ur.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<9;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}},ur=new Ct;function vc(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function ws(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}var Ea={};function Vi(i){i in Ea||(Ea[i]=!0,console.warn(i))}function di(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function fr(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var jl=new Ct().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),th=new Ct().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);function eh(i){return i.convertSRGBToLinear().applyMatrix3(th)}function nh(i){return i.applyMatrix3(jl).convertLinearToSRGB()}var ih={[Ze]:i=>i,[Rt]:i=>i.convertSRGBToLinear(),[yc]:eh},sh={[Ze]:i=>i,[Rt]:i=>i.convertLinearToSRGB(),[yc]:nh},Ne={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(i){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!i},get workingColorSpace(){return Ze},set workingColorSpace(i){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(i,t,e){if(this.enabled===!1||t===e||!t||!e)return i;let n=ih[t],s=sh[e];if(n===void 0||s===void 0)throw new Error(`Unsupported color space conversion, "${t}" to "${e}".`);return s(n(i))},fromWorkingColorSpace:function(i,t){return this.convert(i,this.workingColorSpace,t)},toWorkingColorSpace:function(i,t){return this.convert(i,t,this.workingColorSpace)}},Yn,As=class{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement=="undefined")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Yn===void 0&&(Yn=ws("canvas")),Yn.width=t.width,Yn.height=t.height;let n=Yn.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Yn}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement!="undefined"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&t instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&t instanceof ImageBitmap){let e=ws("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let a=0;a0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==uc)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Dr:t.x=t.x-Math.floor(t.x);break;case Ve:t.x=t.x<0?0:1;break;case Nr:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Dr:t.y=t.y-Math.floor(t.y);break;case Ve:t.y=t.y<0?0:1;break;case Nr:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return Vi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Rt?Bn:xc}set encoding(t){Vi("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=t===Bn?Rt:zn}};ge.DEFAULT_IMAGE=null;ge.DEFAULT_MAPPING=uc;ge.DEFAULT_ANISOTROPY=1;var jt=class{constructor(t=0,e=0,n=0,s=1){jt.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,s){return this.x=t,this.y=e,this.z=n,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*s+a[15]*r,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,s,r,c=t.elements,l=c[0],h=c[4],d=c[8],u=c[1],m=c[5],g=c[9],x=c[2],p=c[6],f=c[10];if(Math.abs(h-u)<.01&&Math.abs(d-x)<.01&&Math.abs(g-p)<.01){if(Math.abs(h+u)<.1&&Math.abs(d+x)<.1&&Math.abs(g+p)<.1&&Math.abs(l+m+f-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let _=(l+1)/2,b=(m+1)/2,S=(f+1)/2,T=(h+u)/4,A=(d+x)/4,L=(g+p)/4;return _>b&&_>S?_<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(_),s=T/n,r=A/n):b>S?b<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(b),n=T/s,r=L/s):S<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(S),n=A/r,s=L/r),this.set(n,s,r,e),this}let v=Math.sqrt((p-g)*(p-g)+(d-x)*(d-x)+(u-h)*(u-h));return Math.abs(v)<.001&&(v=1),this.x=(p-g)/v,this.y=(d-x)/v,this.z=(u-h)/v,this.w=Math.acos((l+m+f-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}},zr=class extends bn{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new jt(0,0,t,e),this.scissorTest=!1,this.viewport=new jt(0,0,t,e);let s={width:t,height:e,depth:1};n.encoding!==void 0&&(Vi("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Bn?Rt:zn),this.texture=new ge(s,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.internalFormat=n.internalFormat!==void 0?n.internalFormat:null,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:Ie,this.depthBuffer=n.depthBuffer!==void 0?n.depthBuffer:!0,this.stencilBuffer=n.stencilBuffer!==void 0?n.stencilBuffer:!1,this.depthTexture=n.depthTexture!==void 0?n.depthTexture:null,this.samples=n.samples!==void 0?n.samples:0}setSize(t,e,n=1){(this.width!==t||this.height!==e||this.depth!==n)&&(this.width=t,this.height=e,this.depth=n,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.texture.isRenderTargetTexture=!0;let e=Object.assign({},t.texture.image);return this.texture.source=new Rs(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},cn=class extends zr{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}},Cs=class extends ge{constructor(t=null,e=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=pe,this.minFilter=pe,this.wrapR=Ve,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var Vr=class extends ge{constructor(t=null,e=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=pe,this.minFilter=pe,this.wrapR=Ve,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};var En=class{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,r,a,o){let c=n[s+0],l=n[s+1],h=n[s+2],d=n[s+3],u=r[a+0],m=r[a+1],g=r[a+2],x=r[a+3];if(o===0){t[e+0]=c,t[e+1]=l,t[e+2]=h,t[e+3]=d;return}if(o===1){t[e+0]=u,t[e+1]=m,t[e+2]=g,t[e+3]=x;return}if(d!==x||c!==u||l!==m||h!==g){let p=1-o,f=c*u+l*m+h*g+d*x,v=f>=0?1:-1,_=1-f*f;if(_>Number.EPSILON){let S=Math.sqrt(_),T=Math.atan2(S,f*v);p=Math.sin(p*T)/S,o=Math.sin(o*T)/S}let b=o*v;if(c=c*p+u*b,l=l*p+m*b,h=h*p+g*b,d=d*p+x*b,p===1-o){let S=1/Math.sqrt(c*c+l*l+h*h+d*d);c*=S,l*=S,h*=S,d*=S}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=d}static multiplyQuaternionsFlat(t,e,n,s,r,a){let o=n[s],c=n[s+1],l=n[s+2],h=n[s+3],d=r[a],u=r[a+1],m=r[a+2],g=r[a+3];return t[e]=o*g+h*d+c*m-l*u,t[e+1]=c*g+h*u+l*d-o*m,t[e+2]=l*g+h*m+o*u-c*d,t[e+3]=h*g-o*d-c*u-l*m,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,s){return this._x=t,this._y=e,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){let n=t._x,s=t._y,r=t._z,a=t._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(s/2),d=o(r/2),u=c(n/2),m=c(s/2),g=c(r/2);switch(a){case"XYZ":this._x=u*h*d+l*m*g,this._y=l*m*d-u*h*g,this._z=l*h*g+u*m*d,this._w=l*h*d-u*m*g;break;case"YXZ":this._x=u*h*d+l*m*g,this._y=l*m*d-u*h*g,this._z=l*h*g-u*m*d,this._w=l*h*d+u*m*g;break;case"ZXY":this._x=u*h*d-l*m*g,this._y=l*m*d+u*h*g,this._z=l*h*g+u*m*d,this._w=l*h*d-u*m*g;break;case"ZYX":this._x=u*h*d-l*m*g,this._y=l*m*d+u*h*g,this._z=l*h*g-u*m*d,this._w=l*h*d+u*m*g;break;case"YZX":this._x=u*h*d+l*m*g,this._y=l*m*d+u*h*g,this._z=l*h*g-u*m*d,this._w=l*h*d-u*m*g;break;case"XZY":this._x=u*h*d-l*m*g,this._y=l*m*d-u*h*g,this._z=l*h*g+u*m*d,this._w=l*h*d+u*m*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e!==!1&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],s=e[4],r=e[8],a=e[1],o=e[5],c=e[9],l=e[2],h=e[6],d=e[10],u=n+o+d;if(u>0){let m=.5/Math.sqrt(u+1);this._w=.25/m,this._x=(h-c)*m,this._y=(r-l)*m,this._z=(a-s)*m}else if(n>o&&n>d){let m=2*Math.sqrt(1+n-o-d);this._w=(h-c)/m,this._x=.25*m,this._y=(s+a)/m,this._z=(r+l)/m}else if(o>d){let m=2*Math.sqrt(1+o-n-d);this._w=(r-l)/m,this._x=(s+a)/m,this._y=.25*m,this._z=(c+h)/m}else{let m=2*Math.sqrt(1+d-n-o);this._w=(a-s)/m,this._x=(r+l)/m,this._y=(c+h)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return nMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(me(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let s=Math.min(1,e/n);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let n=t._x,s=t._y,r=t._z,a=t._w,o=e._x,c=e._y,l=e._z,h=e._w;return this._x=n*h+a*o+s*l-r*c,this._y=s*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-s*o,this._w=a*h-n*o-s*c-r*l,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);let n=this._x,s=this._y,r=this._z,a=this._w,o=a*t._w+n*t._x+s*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=s,this._z=r,this;let c=1-o*o;if(c<=Number.EPSILON){let m=1-e;return this._w=m*a+e*this._w,this._x=m*n+e*this._x,this._y=m*s+e*this._y,this._z=m*r+e*this._z,this.normalize(),this._onChangeCallback(),this}let l=Math.sqrt(c),h=Math.atan2(l,o),d=Math.sin((1-e)*h)/l,u=Math.sin(e*h)/l;return this._w=a*d+this._w*u,this._x=n*d+this._x*u,this._y=s*d+this._y*u,this._z=r*d+this._z*u,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=Math.random(),e=Math.sqrt(1-t),n=Math.sqrt(t),s=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(e*Math.cos(s),n*Math.sin(r),n*Math.cos(r),e*Math.sin(s))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},P=class{constructor(t=0,e=0,n=0){P.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Ta.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Ta.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*s,this.y=r[1]*e+r[4]*n+r[7]*s,this.z=r[2]*e+r[5]*n+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,s=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(t){let e=this.x,n=this.y,s=this.z,r=t.x,a=t.y,o=t.z,c=t.w,l=c*e+a*s-o*n,h=c*n+o*e-r*s,d=c*s+r*n-a*e,u=-r*e-a*n-o*s;return this.x=l*c+u*-r+h*-o-d*-a,this.y=h*c+u*-a+d*-r-l*-o,this.z=d*c+u*-o+l*-a-h*-r,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s,this.y=r[1]*e+r[5]*n+r[9]*s,this.z=r[2]*e+r[6]*n+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let n=t.x,s=t.y,r=t.z,a=e.x,o=e.y,c=e.z;return this.x=s*c-r*o,this.y=r*a-n*c,this.z=n*o-s*a,this}projectOnVector(t){let e=t.lengthSq();if(e===0)return this.set(0,0,0);let n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return pr.copy(this).projectOnVector(t),this.sub(pr)}reflect(t){return this.sub(pr.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;let n=this.dot(t)/e;return Math.acos(me(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){let s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=(Math.random()-.5)*2,e=Math.random()*Math.PI*2,n=Math.sqrt(1-t**2);return this.x=n*Math.cos(e),this.y=n*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},pr=new P,Ta=new En,_e=class{constructor(t=new P(1/0,1/0,1/0),e=new P(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,je),je.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ni),es.subVectors(this.max,Ni),Jn.subVectors(t.a,Ni),$n.subVectors(t.b,Ni),Kn.subVectors(t.c,Ni),dn.subVectors($n,Jn),pn.subVectors(Kn,$n),Pn.subVectors(Jn,Kn);let e=[0,-dn.z,dn.y,0,-pn.z,pn.y,0,-Pn.z,Pn.y,dn.z,0,-dn.x,pn.z,0,-pn.x,Pn.z,0,-Pn.x,-dn.y,dn.x,0,-pn.y,pn.x,0,-Pn.y,Pn.x,0];return!mr(e,Jn,$n,Kn,es)||(e=[1,0,0,0,1,0,0,0,1],!mr(e,Jn,$n,Kn,es))?!1:(ns.crossVectors(dn,pn),e=[ns.x,ns.y,ns.z],mr(e,Jn,$n,Kn,es))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,je).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(je).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Qe[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Qe[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Qe[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Qe[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Qe[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Qe[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Qe[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Qe[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Qe),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}},Qe=[new P,new P,new P,new P,new P,new P,new P,new P],je=new P,Zn=new _e,Jn=new P,$n=new P,Kn=new P,dn=new P,pn=new P,Pn=new P,Ni=new P,es=new P,ns=new P,Ln=new P;function mr(i,t,e,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Ln.fromArray(i,r);let o=s.x*Math.abs(Ln.x)+s.y*Math.abs(Ln.y)+s.z*Math.abs(Ln.z),c=t.dot(Ln),l=e.dot(Ln),h=n.dot(Ln);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}var ah=new _e,Fi=new P,gr=new P,Vn=class{constructor(t=new P,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let n=this.center;e!==void 0?n.copy(e):ah.setFromPoints(t).getCenter(n);let s=0;for(let r=0,a=t.length;rthis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Fi.subVectors(t,this.center);let e=Fi.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Fi,s/n),this.radius+=s}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(gr.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Fi.copy(t.center).add(gr)),this.expandByPoint(Fi.copy(t.center).sub(gr))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}},tn=new P,_r=new P,is=new P,mn=new P,xr=new P,ss=new P,yr=new P,kr=class{constructor(t=new P,e=new P(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,tn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=tn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(tn.copy(this.origin).addScaledVector(this.direction,e),tn.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){_r.copy(t).add(e).multiplyScalar(.5),is.copy(e).sub(t).normalize(),mn.copy(this.origin).sub(_r);let r=t.distanceTo(e)*.5,a=-this.direction.dot(is),o=mn.dot(this.direction),c=-mn.dot(is),l=mn.lengthSq(),h=Math.abs(1-a*a),d,u,m,g;if(h>0)if(d=a*c-o,u=a*o-c,g=r*h,d>=0)if(u>=-g)if(u<=g){let x=1/h;d*=x,u*=x,m=d*(d+a*u+2*o)+u*(a*d+u+2*c)+l}else u=r,d=Math.max(0,-(a*u+o)),m=-d*d+u*(u+2*c)+l;else u=-r,d=Math.max(0,-(a*u+o)),m=-d*d+u*(u+2*c)+l;else u<=-g?(d=Math.max(0,-(-a*r+o)),u=d>0?-r:Math.min(Math.max(-r,-c),r),m=-d*d+u*(u+2*c)+l):u<=g?(d=0,u=Math.min(Math.max(-r,-c),r),m=u*(u+2*c)+l):(d=Math.max(0,-(a*r+o)),u=d>0?r:Math.min(Math.max(-r,-c),r),m=-d*d+u*(u+2*c)+l);else u=a>0?-r:r,d=Math.max(0,-(a*u+o)),m=-d*d+u*(u+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(_r).addScaledVector(is,u),m}intersectSphere(t,e){tn.subVectors(t.center,this.origin);let n=tn.dot(this.direction),s=tn.dot(tn)-n*n,r=t.radius*t.radius;if(s>r)return null;let a=Math.sqrt(r-s),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){let n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,s,r,a,o,c,l=1/this.direction.x,h=1/this.direction.y,d=1/this.direction.z,u=this.origin;return l>=0?(n=(t.min.x-u.x)*l,s=(t.max.x-u.x)*l):(n=(t.max.x-u.x)*l,s=(t.min.x-u.x)*l),h>=0?(r=(t.min.y-u.y)*h,a=(t.max.y-u.y)*h):(r=(t.max.y-u.y)*h,a=(t.min.y-u.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a=0?(o=(t.min.z-u.z)*d,c=(t.max.z-u.z)*d):(o=(t.max.z-u.z)*d,c=(t.min.z-u.z)*d),n>c||o>s)||((o>n||n!==n)&&(n=o),(c=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,tn)!==null}intersectTriangle(t,e,n,s,r){xr.subVectors(e,t),ss.subVectors(n,t),yr.crossVectors(xr,ss);let a=this.direction.dot(yr),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;mn.subVectors(this.origin,t);let c=o*this.direction.dot(ss.crossVectors(mn,ss));if(c<0)return null;let l=o*this.direction.dot(xr.cross(mn));if(l<0||c+l>a)return null;let h=-o*mn.dot(yr);return h<0?null:this.at(h/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Gt=class{constructor(t,e,n,s,r,a,o,c,l,h,d,u,m,g,x,p){Gt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,c,l,h,d,u,m,g,x,p)}set(t,e,n,s,r,a,o,c,l,h,d,u,m,g,x,p){let f=this.elements;return f[0]=t,f[4]=e,f[8]=n,f[12]=s,f[1]=r,f[5]=a,f[9]=o,f[13]=c,f[2]=l,f[6]=h,f[10]=d,f[14]=u,f[3]=m,f[7]=g,f[11]=x,f[15]=p,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Gt().fromArray(this.elements)}copy(t){let e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){let e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){let e=this.elements,n=t.elements,s=1/Qn.setFromMatrixColumn(t,0).length(),r=1/Qn.setFromMatrixColumn(t,1).length(),a=1/Qn.setFromMatrixColumn(t,2).length();return e[0]=n[0]*s,e[1]=n[1]*s,e[2]=n[2]*s,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,n=t.x,s=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),d=Math.sin(r);if(t.order==="XYZ"){let u=a*h,m=a*d,g=o*h,x=o*d;e[0]=c*h,e[4]=-c*d,e[8]=l,e[1]=m+g*l,e[5]=u-x*l,e[9]=-o*c,e[2]=x-u*l,e[6]=g+m*l,e[10]=a*c}else if(t.order==="YXZ"){let u=c*h,m=c*d,g=l*h,x=l*d;e[0]=u+x*o,e[4]=g*o-m,e[8]=a*l,e[1]=a*d,e[5]=a*h,e[9]=-o,e[2]=m*o-g,e[6]=x+u*o,e[10]=a*c}else if(t.order==="ZXY"){let u=c*h,m=c*d,g=l*h,x=l*d;e[0]=u-x*o,e[4]=-a*d,e[8]=g+m*o,e[1]=m+g*o,e[5]=a*h,e[9]=x-u*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){let u=a*h,m=a*d,g=o*h,x=o*d;e[0]=c*h,e[4]=g*l-m,e[8]=u*l+x,e[1]=c*d,e[5]=x*l+u,e[9]=m*l-g,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){let u=a*c,m=a*l,g=o*c,x=o*l;e[0]=c*h,e[4]=x-u*d,e[8]=g*d+m,e[1]=d,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=m*d+g,e[10]=u-x*d}else if(t.order==="XZY"){let u=a*c,m=a*l,g=o*c,x=o*l;e[0]=c*h,e[4]=-d,e[8]=l*h,e[1]=u*d+x,e[5]=a*h,e[9]=m*d-g,e[2]=g*d-m,e[6]=o*h,e[10]=x*d+u}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(ch,t,lh)}lookAt(t,e,n){let s=this.elements;return we.subVectors(t,e),we.lengthSq()===0&&(we.z=1),we.normalize(),gn.crossVectors(n,we),gn.lengthSq()===0&&(Math.abs(n.z)===1?we.x+=1e-4:we.z+=1e-4,we.normalize(),gn.crossVectors(n,we)),gn.normalize(),rs.crossVectors(we,gn),s[0]=gn.x,s[4]=rs.x,s[8]=we.x,s[1]=gn.y,s[5]=rs.y,s[9]=we.y,s[2]=gn.z,s[6]=rs.z,s[10]=we.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,s=e.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],d=n[5],u=n[9],m=n[13],g=n[2],x=n[6],p=n[10],f=n[14],v=n[3],_=n[7],b=n[11],S=n[15],T=s[0],A=s[4],L=s[8],y=s[12],w=s[1],z=s[5],Y=s[9],I=s[13],D=s[2],O=s[6],$=s[10],G=s[14],q=s[3],J=s[7],K=s[11],B=s[15];return r[0]=a*T+o*w+c*D+l*q,r[4]=a*A+o*z+c*O+l*J,r[8]=a*L+o*Y+c*$+l*K,r[12]=a*y+o*I+c*G+l*B,r[1]=h*T+d*w+u*D+m*q,r[5]=h*A+d*z+u*O+m*J,r[9]=h*L+d*Y+u*$+m*K,r[13]=h*y+d*I+u*G+m*B,r[2]=g*T+x*w+p*D+f*q,r[6]=g*A+x*z+p*O+f*J,r[10]=g*L+x*Y+p*$+f*K,r[14]=g*y+x*I+p*G+f*B,r[3]=v*T+_*w+b*D+S*q,r[7]=v*A+_*z+b*O+S*J,r[11]=v*L+_*Y+b*$+S*K,r[15]=v*y+_*I+b*G+S*B,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],n=t[4],s=t[8],r=t[12],a=t[1],o=t[5],c=t[9],l=t[13],h=t[2],d=t[6],u=t[10],m=t[14],g=t[3],x=t[7],p=t[11],f=t[15];return g*(+r*c*d-s*l*d-r*o*u+n*l*u+s*o*m-n*c*m)+x*(+e*c*m-e*l*u+r*a*u-s*a*m+s*l*h-r*c*h)+p*(+e*l*d-e*o*m-r*a*d+n*a*m+r*o*h-n*l*h)+f*(-s*o*h-e*c*d+e*o*u+s*a*d-n*a*u+n*c*h)}transpose(){let t=this.elements,e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){let s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=n),this}invert(){let t=this.elements,e=t[0],n=t[1],s=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],d=t[9],u=t[10],m=t[11],g=t[12],x=t[13],p=t[14],f=t[15],v=d*p*l-x*u*l+x*c*m-o*p*m-d*c*f+o*u*f,_=g*u*l-h*p*l-g*c*m+a*p*m+h*c*f-a*u*f,b=h*x*l-g*d*l+g*o*m-a*x*m-h*o*f+a*d*f,S=g*d*c-h*x*c-g*o*u+a*x*u+h*o*p-a*d*p,T=e*v+n*_+s*b+r*S;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/T;return t[0]=v*A,t[1]=(x*u*r-d*p*r-x*s*m+n*p*m+d*s*f-n*u*f)*A,t[2]=(o*p*r-x*c*r+x*s*l-n*p*l-o*s*f+n*c*f)*A,t[3]=(d*c*r-o*u*r-d*s*l+n*u*l+o*s*m-n*c*m)*A,t[4]=_*A,t[5]=(h*p*r-g*u*r+g*s*m-e*p*m-h*s*f+e*u*f)*A,t[6]=(g*c*r-a*p*r-g*s*l+e*p*l+a*s*f-e*c*f)*A,t[7]=(a*u*r-h*c*r+h*s*l-e*u*l-a*s*m+e*c*m)*A,t[8]=b*A,t[9]=(g*d*r-h*x*r-g*n*m+e*x*m+h*n*f-e*d*f)*A,t[10]=(a*x*r-g*o*r+g*n*l-e*x*l-a*n*f+e*o*f)*A,t[11]=(h*o*r-a*d*r-h*n*l+e*d*l+a*n*m-e*o*m)*A,t[12]=S*A,t[13]=(h*x*s-g*d*s+g*n*u-e*x*u-h*n*p+e*d*p)*A,t[14]=(g*o*s-a*x*s-g*n*c+e*x*c+a*n*p-e*o*p)*A,t[15]=(a*d*s-h*o*s+h*n*c-e*d*c-a*n*u+e*o*u)*A,this}scale(t){let e=this.elements,n=t.x,s=t.y,r=t.z;return e[0]*=n,e[4]*=s,e[8]*=r,e[1]*=n,e[5]*=s,e[9]*=r,e[2]*=n,e[6]*=s,e[10]*=r,e[3]*=n,e[7]*=s,e[11]*=r,this}getMaxScaleOnAxis(){let t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,s))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let n=Math.cos(e),s=Math.sin(e),r=1-n,a=t.x,o=t.y,c=t.z,l=r*a,h=r*o;return this.set(l*a+n,l*o-s*c,l*c+s*o,0,l*o+s*c,h*o+n,h*c-s*a,0,l*c-s*o,h*c+s*a,r*c*c+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,s,r,a){return this.set(1,n,r,0,t,1,a,0,e,s,1,0,0,0,0,1),this}compose(t,e,n){let s=this.elements,r=e._x,a=e._y,o=e._z,c=e._w,l=r+r,h=a+a,d=o+o,u=r*l,m=r*h,g=r*d,x=a*h,p=a*d,f=o*d,v=c*l,_=c*h,b=c*d,S=n.x,T=n.y,A=n.z;return s[0]=(1-(x+f))*S,s[1]=(m+b)*S,s[2]=(g-_)*S,s[3]=0,s[4]=(m-b)*T,s[5]=(1-(u+f))*T,s[6]=(p+v)*T,s[7]=0,s[8]=(g+_)*A,s[9]=(p-v)*A,s[10]=(1-(u+x))*A,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){let s=this.elements,r=Qn.set(s[0],s[1],s[2]).length(),a=Qn.set(s[4],s[5],s[6]).length(),o=Qn.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),t.x=s[12],t.y=s[13],t.z=s[14],Fe.copy(this);let l=1/r,h=1/a,d=1/o;return Fe.elements[0]*=l,Fe.elements[1]*=l,Fe.elements[2]*=l,Fe.elements[4]*=h,Fe.elements[5]*=h,Fe.elements[6]*=h,Fe.elements[8]*=d,Fe.elements[9]*=d,Fe.elements[10]*=d,e.setFromRotationMatrix(Fe),n.x=r,n.y=a,n.z=o,this}makePerspective(t,e,n,s,r,a,o=on){let c=this.elements,l=2*r/(e-t),h=2*r/(n-s),d=(e+t)/(e-t),u=(n+s)/(n-s),m,g;if(o===on)m=-(a+r)/(a-r),g=-2*a*r/(a-r);else if(o===Ts)m=-a/(a-r),g=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=h,c[9]=u,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,s,r,a,o=on){let c=this.elements,l=1/(e-t),h=1/(n-s),d=1/(a-r),u=(e+t)*l,m=(n+s)*h,g,x;if(o===on)g=(a+r)*d,x=-2*d;else if(o===Ts)g=r*d,x=-1*d;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-u,c[1]=0,c[5]=2*h,c[9]=0,c[13]=-m,c[2]=0,c[6]=0,c[10]=x,c[14]=-g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let s=0;s<16;s++)if(e[s]!==n[s])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){let n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}},Qn=new P,Fe=new Gt,ch=new P(0,0,0),lh=new P(1,1,1),gn=new P,rs=new P,we=new P,wa=new Gt,Aa=new En,xi=class{constructor(t=0,e=0,n=0,s=xi.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,s=this._order){return this._x=t,this._y=e,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){let s=t.elements,r=s[0],a=s[4],o=s[8],c=s[1],l=s[5],h=s[9],d=s[2],u=s[6],m=s[10];switch(e){case"XYZ":this._y=Math.asin(me(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,m),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-me(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,m),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-d,r),this._z=0);break;case"ZXY":this._x=Math.asin(me(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-d,m),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-me(d,-1,1)),Math.abs(d)<.9999999?(this._x=Math.atan2(u,m),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(me(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-d,r)):(this._x=0,this._y=Math.atan2(o,m));break;case"XZY":this._z=Math.asin(-me(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return wa.makeRotationFromQuaternion(t),this.setFromRotationMatrix(wa,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Aa.setFromEuler(this),this.setFromQuaternion(Aa,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};xi.DEFAULT_ORDER="XYZ";var Ps=class{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let n=0;n0&&(n=n.concat(a))}return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oi,t,uh),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oi,fh,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);let e=this.children;for(let n=0,s=e.length;n0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);let o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){let c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l0){s.children=[];for(let o=0;o0){s.animations=[];for(let o=0;o0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),d.length>0&&(n.shapes=d),u.length>0&&(n.skeletons=u),m.length>0&&(n.animations=m),g.length>0&&(n.nodes=g)}return n.object=s,n;function a(o){let c=[];for(let l in o){let h=o[l];delete h.metadata,c.push(h)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){Oe.subVectors(s,e),nn.subVectors(n,e),vr.subVectors(t,e);let a=Oe.dot(Oe),o=Oe.dot(nn),c=Oe.dot(vr),l=nn.dot(nn),h=nn.dot(vr),d=a*l-o*o;if(d===0)return r.set(-2,-1,-1);let u=1/d,m=(l*c-o*h)*u,g=(a*h-o*c)*u;return r.set(1-m-g,g,m)}static containsPoint(t,e,n,s){return this.getBarycoord(t,e,n,s,sn),sn.x>=0&&sn.y>=0&&sn.x+sn.y<=1}static getUV(t,e,n,s,r,a,o,c){return as===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),as=!0),this.getInterpolation(t,e,n,s,r,a,o,c)}static getInterpolation(t,e,n,s,r,a,o,c){return this.getBarycoord(t,e,n,s,sn),c.setScalar(0),c.addScaledVector(r,sn.x),c.addScaledVector(a,sn.y),c.addScaledVector(o,sn.z),c}static isFrontFacing(t,e,n,s){return Oe.subVectors(n,e),nn.subVectors(t,e),Oe.cross(nn).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Oe.subVectors(this.c,this.b),nn.subVectors(this.a,this.b),Oe.cross(nn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return se.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return se.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,n,s,r){return as===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),as=!0),se.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}getInterpolation(t,e,n,s,r){return se.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return se.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return se.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,s=this.b,r=this.c,a,o;ti.subVectors(s,n),ei.subVectors(r,n),Mr.subVectors(t,n);let c=ti.dot(Mr),l=ei.dot(Mr);if(c<=0&&l<=0)return e.copy(n);Sr.subVectors(t,s);let h=ti.dot(Sr),d=ei.dot(Sr);if(h>=0&&d<=h)return e.copy(s);let u=c*d-h*l;if(u<=0&&c>=0&&h<=0)return a=c/(c-h),e.copy(n).addScaledVector(ti,a);br.subVectors(t,r);let m=ti.dot(br),g=ei.dot(br);if(g>=0&&m<=g)return e.copy(r);let x=m*l-c*g;if(x<=0&&l>=0&&g<=0)return o=l/(l-g),e.copy(n).addScaledVector(ei,o);let p=h*g-m*d;if(p<=0&&d-h>=0&&m-g>=0)return Ua.subVectors(r,s),o=(d-h)/(d-h+(m-g)),e.copy(s).addScaledVector(Ua,o);let f=1/(p+x+u);return a=x*f,o=u*f,e.copy(n).addScaledVector(ti,a).addScaledVector(ei,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},ph=0,yi=class extends bn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ph++}),this.uuid=qi(),this.name="",this.type="Material",this.blending=fi,this.side=He,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=cc,this.blendDst=lc,this.blendEquation=li,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=Lr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Gl,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=cr,this.stencilZFail=cr,this.stencilZPass=cr,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(let e in t){let n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter \'${e}\' has value of undefined.`);continue}let s=this[e];if(s===void 0){console.warn(`THREE.Material: \'${e}\' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[e]=n}}toJSON(t){let e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});let n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==fi&&(n.blending=this.blending),this.side!==He&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=this.alphaHash),this.alphaToCoverage===!0&&(n.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=this.premultipliedAlpha),this.forceSinglePass===!0&&(n.forceSinglePass=this.forceSinglePass),this.wireframe===!0&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=this.flatShading),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function s(r){let a=[];for(let o in r){let c=r[o];delete c.metadata,a.push(c)}return a}if(e){let r=s(t.textures),a=s(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,n=null;if(e!==null){let s=e.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}},Mc={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Be={h:0,s:0,l:0},cs={h:0,s:0,l:0};function Er(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}var kt=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){let s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Rt){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Ne.toWorkingColorSpace(this,e),this}setRGB(t,e,n,s=Ne.workingColorSpace){return this.r=t,this.g=e,this.b=n,Ne.toWorkingColorSpace(this,s),this}setHSL(t,e,n,s=Ne.workingColorSpace){if(t=Ql(t,1),e=me(e,0,1),n=me(n,0,1),e===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=Er(a,r,t+1/3),this.g=Er(a,r,t),this.b=Er(a,r,t-1/3)}return Ne.toWorkingColorSpace(this,s),this}setStyle(t,e=Rt){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\\w+)\\(([^\\)]*)\\)/.exec(t)){let r,a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\\s*(\\d*\\.?\\d+)\\s*,\\s*(\\d*\\.?\\d+)\\%\\s*,\\s*(\\d*\\.?\\d+)\\%\\s*(?:,\\s*(\\d*\\.?\\d+)\\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(s=/^\\#([A-Fa-f\\d]+)$/.exec(t)){let r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(r,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Rt){let n=Mc[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=di(t.r),this.g=di(t.g),this.b=di(t.b),this}copyLinearToSRGB(t){return this.r=fr(t.r),this.g=fr(t.g),this.b=fr(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Rt){return Ne.fromWorkingColorSpace(le.copy(this),t),Math.round(me(le.r*255,0,255))*65536+Math.round(me(le.g*255,0,255))*256+Math.round(me(le.b*255,0,255))}getHexString(t=Rt){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Ne.workingColorSpace){Ne.fromWorkingColorSpace(le.copy(this),e);let n=le.r,s=le.g,r=le.b,a=Math.max(n,s,r),o=Math.min(n,s,r),c,l,h=(o+a)/2;if(o===a)c=0,l=0;else{let d=a-o;switch(l=h<=.5?d/(a+o):d/(2-a-o),a){case n:c=(s-r)/d+(s0&&(t.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};let e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let n=this.attributes;for(let c in n){let l=n[c];t.data.attributes[c]=l.toJSON(t.data)}let s={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],h=[];for(let d=0,u=l.length;d0&&(s[c]=h,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let n=t.index;n!==null&&this.setIndex(n.clone(e));let s=t.attributes;for(let l in s){let h=s[l];this.setAttribute(l,h.clone(e))}let r=t.morphAttributes;for(let l in r){let h=[],d=r[l];for(let u=0,m=d.length;u0){let s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r(t.far-t.near)**2))&&(Da.copy(r).invert(),In.copy(t.ray).applyMatrix4(Da),!(n.boundingBox!==null&&In.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,In)))}_computeIntersections(t,e,n){let s,r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,d=r.attributes.normal,u=r.groups,m=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,x=u.length;ge.far?null:{distance:l,point:gs.clone(),object:i}}function _s(i,t,e,n,s,r,a,o,c,l){i.getVertexPosition(o,ii),i.getVertexPosition(c,si),i.getVertexPosition(l,ri);let h=gh(i,t,e,n,ii,si,ri,ms);if(h){s&&(fs.fromBufferAttribute(s,o),ds.fromBufferAttribute(s,c),ps.fromBufferAttribute(s,l),h.uv=se.getInterpolation(ms,ii,si,ri,fs,ds,ps,new Nt)),r&&(fs.fromBufferAttribute(r,o),ds.fromBufferAttribute(r,c),ps.fromBufferAttribute(r,l),h.uv1=se.getInterpolation(ms,ii,si,ri,fs,ds,ps,new Nt),h.uv2=h.uv1),a&&(Fa.fromBufferAttribute(a,o),Oa.fromBufferAttribute(a,c),Ba.fromBufferAttribute(a,l),h.normal=se.getInterpolation(ms,ii,si,ri,Fa,Oa,Ba,new P),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let d={a:o,b:c,c:l,normal:new P,materialIndex:0};se.getNormal(ii,si,ri,d.normal),h.face=d}return h}var kn=class extends Ge{constructor(t=1,e=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};let o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);let c=[],l=[],h=[],d=[],u=0,m=0;g("z","y","x",-1,-1,n,e,t,a,r,0),g("z","y","x",1,-1,n,e,-t,a,r,1),g("x","z","y",1,1,t,n,e,s,a,2),g("x","z","y",1,-1,t,n,-e,s,a,3),g("x","y","z",1,-1,t,e,n,s,r,4),g("x","y","z",-1,-1,t,e,-n,s,r,5),this.setIndex(c),this.setAttribute("position",new an(l,3)),this.setAttribute("normal",new an(h,3)),this.setAttribute("uv",new an(d,2));function g(x,p,f,v,_,b,S,T,A,L,y){let w=b/A,z=S/L,Y=b/2,I=S/2,D=T/2,O=A+1,$=L+1,G=0,q=0,J=new P;for(let K=0;K<$;K++){let B=K*z-I;for(let Z=0;Z0?1:-1,h.push(J.x,J.y,J.z),d.push(Z/A),d.push(1-K/L),G+=1}}for(let K=0;K0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}},Ds=class extends ve{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Gt,this.projectionMatrix=new Gt,this.projectionMatrixInverse=new Gt,this.coordinateSystem=on}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){this.updateWorldMatrix(!0,!1);let e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},Re=class extends Ds{constructor(t=50,e=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){let e=.5*this.getFilmHeight()/t;this.fov=Or*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(lr*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Or*2*Math.atan(Math.tan(lr*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,n,s,r,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=this.near,e=t*Math.tan(lr*.5*this.fov)/this.zoom,n=2*e,s=this.aspect*n,r=-.5*s,a=this.view;if(this.view!==null&&this.view.enabled){let c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,e-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}let o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}},oi=-90,ai=1,Hr=class extends ve{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null;let s=new Re(oi,ai,t,e);s.layers=this.layers,this.add(s);let r=new Re(oi,ai,t,e);r.layers=this.layers,this.add(r);let a=new Re(oi,ai,t,e);a.layers=this.layers,this.add(a);let o=new Re(oi,ai,t,e);o.layers=this.layers,this.add(o);let c=new Re(oi,ai,t,e);c.layers=this.layers,this.add(c);let l=new Re(oi,ai,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let t=this.coordinateSystem,e=this.children.concat(),[n,s,r,a,o,c]=e;for(let l of e)this.remove(l);if(t===on)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(t===Ts)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(let l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();let n=this.renderTarget;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());let[s,r,a,o,c,l]=this.children,h=t.getRenderTarget(),d=t.xr.enabled;t.xr.enabled=!1;let u=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0),t.render(e,s),t.setRenderTarget(n,1),t.render(e,r),t.setRenderTarget(n,2),t.render(e,a),t.setRenderTarget(n,3),t.render(e,o),t.setRenderTarget(n,4),t.render(e,c),n.texture.generateMipmaps=u,t.setRenderTarget(n,5),t.render(e,l),t.setRenderTarget(h),t.xr.enabled=d,n.texture.needsPMREMUpdate=!0}},Ns=class extends ge{constructor(t,e,n,s,r,a,o,c,l,h){t=t!==void 0?t:[],e=e!==void 0?e:mi,super(t,e,n,s,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}},Gr=class extends cn{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];e.encoding!==void 0&&(Vi("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),e.colorSpace=e.encoding===Bn?Rt:zn),this.texture=new Ns(s,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:Ie}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t`,fragmentShader:`\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t`},s=new kn(5,5,5),r=new ln({name:"CubemapFromEquirect",uniforms:vi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:he,blending:vn});r.uniforms.tEquirect.value=e;let a=new Ye(s,r),o=e.minFilter;return e.minFilter===Hi&&(e.minFilter=Ie),new Hr(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e,n,s){let r=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,s);t.setRenderTarget(r)}},Ar=new P,Mh=new P,Sh=new Ct,Ce=class{constructor(t=new P(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,s){return this.normal.set(t,e,n),this.constant=s,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){let s=Ar.subVectors(n,e).cross(Mh.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){let t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){let n=t.delta(Ar),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let r=-(t.start.dot(this.normal)+this.constant)/s;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){let e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let n=e||Sh.getNormalMatrix(t),s=this.coplanarPoint(Ar).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}},Un=new Vn,xs=new P,Fs=class{constructor(t=new Ce,e=new Ce,n=new Ce,s=new Ce,r=new Ce,a=new Ce){this.planes=[t,e,n,s,r,a]}set(t,e,n,s,r,a){let o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(t){let e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=on){let n=this.planes,s=t.elements,r=s[0],a=s[1],o=s[2],c=s[3],l=s[4],h=s[5],d=s[6],u=s[7],m=s[8],g=s[9],x=s[10],p=s[11],f=s[12],v=s[13],_=s[14],b=s[15];if(n[0].setComponents(c-r,u-l,p-m,b-f).normalize(),n[1].setComponents(c+r,u+l,p+m,b+f).normalize(),n[2].setComponents(c+a,u+h,p+g,b+v).normalize(),n[3].setComponents(c-a,u-h,p-g,b-v).normalize(),n[4].setComponents(c-o,u-d,p-x,b-_).normalize(),e===on)n[5].setComponents(c+o,u+d,p+x,b+_).normalize();else if(e===Ts)n[5].setComponents(o,d,x,_).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Un.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{let e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Un.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Un)}intersectsSprite(t){return Un.center.set(0,0,0),Un.radius=.7071067811865476,Un.applyMatrix4(t.matrixWorld),this.intersectsSphere(Un)}intersectsSphere(t){let e=this.planes,n=t.center,s=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)0?t.max.x:t.min.x,xs.y=s.normal.y>0?t.max.y:t.min.y,xs.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(xs)<0)return!1}return!0}containsPoint(t){let e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function bc(){let i=null,t=!1,e=null,n=null;function s(r,a){e(r,a),n=i.requestAnimationFrame(s)}return{start:function(){t!==!0&&e!==null&&(n=i.requestAnimationFrame(s),t=!0)},stop:function(){i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){i=r}}}function bh(i,t){let e=t.isWebGL2,n=new WeakMap;function s(l,h){let d=l.array,u=l.usage,m=i.createBuffer();i.bindBuffer(h,m),i.bufferData(h,d,u),l.onUploadCallback();let g;if(d instanceof Float32Array)g=i.FLOAT;else if(d instanceof Uint16Array)if(l.isFloat16BufferAttribute)if(e)g=i.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else g=i.UNSIGNED_SHORT;else if(d instanceof Int16Array)g=i.SHORT;else if(d instanceof Uint32Array)g=i.UNSIGNED_INT;else if(d instanceof Int32Array)g=i.INT;else if(d instanceof Int8Array)g=i.BYTE;else if(d instanceof Uint8Array)g=i.UNSIGNED_BYTE;else if(d instanceof Uint8ClampedArray)g=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+d);return{buffer:m,type:g,bytesPerElement:d.BYTES_PER_ELEMENT,version:l.version}}function r(l,h,d){let u=h.array,m=h.updateRange;i.bindBuffer(d,l),m.count===-1?i.bufferSubData(d,0,u):(e?i.bufferSubData(d,m.offset*u.BYTES_PER_ELEMENT,u,m.offset,m.count):i.bufferSubData(d,m.offset*u.BYTES_PER_ELEMENT,u.subarray(m.offset,m.offset+m.count)),m.count=-1),h.onUploadCallback()}function a(l){return l.isInterleavedBufferAttribute&&(l=l.data),n.get(l)}function o(l){l.isInterleavedBufferAttribute&&(l=l.data);let h=n.get(l);h&&(i.deleteBuffer(h.buffer),n.delete(l))}function c(l,h){if(l.isGLBufferAttribute){let u=n.get(l);(!u||u.version 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif`,Bh=`#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif`,zh=`#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif`,Vh=`#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif`,kh=`#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif`,Hh=`#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif`,Gh=`#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif`,Wh=`#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif`,Xh=`#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated`,qh=`#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif`,Yh=`vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif`,Zh=`#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif`,Jh=`#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif`,$h=`#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif`,Kh=`#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif`,Qh="gl_FragColor = linearToOutputTexel( gl_FragColor );",jh=`vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}`,tu=`#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif`,eu=`#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif`,nu=`#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif`,iu=`#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif`,su=`#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif`,ru=`#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif`,ou=`#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif`,au=`#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif`,cu=`#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif`,lu=`#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}`,hu=`#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif`,uu=`#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif`,fu=`LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;`,du=`varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert`,pu=`uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif`,mu=`#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif`,gu=`ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;`,_u=`varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon`,xu=`BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;`,yu=`varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong`,vu=`PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tanisotropyV /= material.anisotropy;\n\tmaterial.anisotropy = saturate( material.anisotropy );\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;\n#endif`,Mu=`struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}`,Su=`\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif`,bu=`#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif`,Eu=`#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif`,Tu=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif`,wu=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif`,Au=`#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif`,Ru=`#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif`,Cu=`#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vMapUv );\n#endif`,Pu=`#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif`,Lu=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif`,Iu=`#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif`,Uu=`float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif`,Du=`#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif`,Nu=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif`,Fu=`#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif`,Ou=`#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif`,Bu=`#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif`,zu=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 geometryNormal = normal;`,Vu=`#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif`,ku=`#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif`,Hu=`#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif`,Gu=`#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif`,Wu=`#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif`,Xu=`#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif`,qu=`#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif`,Yu=`#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif`,Zu=`#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif`,Ju=`#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );`,$u=`vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}`,Ku=`#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif`,Qu=`vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;`,ju=`#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif`,tf=`#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif`,ef=`float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif`,nf=`#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif`,sf=`#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif`,rf=`#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif`,of=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif`,af=`float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}`,cf=`#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif`,lf=`#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif`,hf=`#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif`,uf=`#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif`,ff=`float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif`,df=`#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif`,pf=`#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif`,mf=`#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }`,gf=`#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif`,_f=`#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif`,xf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif`,yf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif`,vf=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif`,Mf=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif`,Sf=`varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}`,bf=`uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}`,Ef=`varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}`,Tf=`#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}`,wf=`varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}`,Af=`uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}`,Rf=`#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}`,Cf=`#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}`,Pf=`#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}`,Lf=`#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}`,If=`varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}`,Uf=`uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}`,Df=`uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Nf=`uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Ff=`#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Of=`uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Bf=`#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}`,zf=`#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Vf=`#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}`,kf=`#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Hf=`#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}`,Gf=`#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}`,Wf=`#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}`,Xf=`#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,qf=`#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}`,Yf=`#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Zf=`#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}`,Jf=`#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,$f=`uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}`,Kf=`uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,Qf=`#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}`,jf=`uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}`,td=`uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}`,ed=`uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}`,At={alphahash_fragment:Eh,alphahash_pars_fragment:Th,alphamap_fragment:wh,alphamap_pars_fragment:Ah,alphatest_fragment:Rh,alphatest_pars_fragment:Ch,aomap_fragment:Ph,aomap_pars_fragment:Lh,begin_vertex:Ih,beginnormal_vertex:Uh,bsdfs:Dh,iridescence_fragment:Nh,bumpmap_pars_fragment:Fh,clipping_planes_fragment:Oh,clipping_planes_pars_fragment:Bh,clipping_planes_pars_vertex:zh,clipping_planes_vertex:Vh,color_fragment:kh,color_pars_fragment:Hh,color_pars_vertex:Gh,color_vertex:Wh,common:Xh,cube_uv_reflection_fragment:qh,defaultnormal_vertex:Yh,displacementmap_pars_vertex:Zh,displacementmap_vertex:Jh,emissivemap_fragment:$h,emissivemap_pars_fragment:Kh,colorspace_fragment:Qh,colorspace_pars_fragment:jh,envmap_fragment:tu,envmap_common_pars_fragment:eu,envmap_pars_fragment:nu,envmap_pars_vertex:iu,envmap_physical_pars_fragment:mu,envmap_vertex:su,fog_vertex:ru,fog_pars_vertex:ou,fog_fragment:au,fog_pars_fragment:cu,gradientmap_pars_fragment:lu,lightmap_fragment:hu,lightmap_pars_fragment:uu,lights_lambert_fragment:fu,lights_lambert_pars_fragment:du,lights_pars_begin:pu,lights_toon_fragment:gu,lights_toon_pars_fragment:_u,lights_phong_fragment:xu,lights_phong_pars_fragment:yu,lights_physical_fragment:vu,lights_physical_pars_fragment:Mu,lights_fragment_begin:Su,lights_fragment_maps:bu,lights_fragment_end:Eu,logdepthbuf_fragment:Tu,logdepthbuf_pars_fragment:wu,logdepthbuf_pars_vertex:Au,logdepthbuf_vertex:Ru,map_fragment:Cu,map_pars_fragment:Pu,map_particle_fragment:Lu,map_particle_pars_fragment:Iu,metalnessmap_fragment:Uu,metalnessmap_pars_fragment:Du,morphcolor_vertex:Nu,morphnormal_vertex:Fu,morphtarget_pars_vertex:Ou,morphtarget_vertex:Bu,normal_fragment_begin:zu,normal_fragment_maps:Vu,normal_pars_fragment:ku,normal_pars_vertex:Hu,normal_vertex:Gu,normalmap_pars_fragment:Wu,clearcoat_normal_fragment_begin:Xu,clearcoat_normal_fragment_maps:qu,clearcoat_pars_fragment:Yu,iridescence_pars_fragment:Zu,opaque_fragment:Ju,packing:$u,premultiplied_alpha_fragment:Ku,project_vertex:Qu,dithering_fragment:ju,dithering_pars_fragment:tf,roughnessmap_fragment:ef,roughnessmap_pars_fragment:nf,shadowmap_pars_fragment:sf,shadowmap_pars_vertex:rf,shadowmap_vertex:of,shadowmask_pars_fragment:af,skinbase_vertex:cf,skinning_pars_vertex:lf,skinning_vertex:hf,skinnormal_vertex:uf,specularmap_fragment:ff,specularmap_pars_fragment:df,tonemapping_fragment:pf,tonemapping_pars_fragment:mf,transmission_fragment:gf,transmission_pars_fragment:_f,uv_pars_fragment:xf,uv_pars_vertex:yf,uv_vertex:vf,worldpos_vertex:Mf,background_vert:Sf,background_frag:bf,backgroundCube_vert:Ef,backgroundCube_frag:Tf,cube_vert:wf,cube_frag:Af,depth_vert:Rf,depth_frag:Cf,distanceRGBA_vert:Pf,distanceRGBA_frag:Lf,equirect_vert:If,equirect_frag:Uf,linedashed_vert:Df,linedashed_frag:Nf,meshbasic_vert:Ff,meshbasic_frag:Of,meshlambert_vert:Bf,meshlambert_frag:zf,meshmatcap_vert:Vf,meshmatcap_frag:kf,meshnormal_vert:Hf,meshnormal_frag:Gf,meshphong_vert:Wf,meshphong_frag:Xf,meshphysical_vert:qf,meshphysical_frag:Yf,meshtoon_vert:Zf,meshtoon_frag:Jf,points_vert:$f,points_frag:Kf,shadow_vert:Qf,shadow_frag:jf,sprite_vert:td,sprite_frag:ed},it={common:{diffuse:{value:new kt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ct},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ct}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ct}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ct}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ct},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ct},normalScale:{value:new Nt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ct},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ct}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ct}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ct}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new kt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new kt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0},uvTransform:{value:new Ct}},sprite:{diffuse:{value:new kt(16777215)},opacity:{value:1},center:{value:new Nt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ct},alphaMap:{value:null},alphaMapTransform:{value:new Ct},alphaTest:{value:0}}},qe={basic:{uniforms:de([it.common,it.specularmap,it.envmap,it.aomap,it.lightmap,it.fog]),vertexShader:At.meshbasic_vert,fragmentShader:At.meshbasic_frag},lambert:{uniforms:de([it.common,it.specularmap,it.envmap,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.fog,it.lights,{emissive:{value:new kt(0)}}]),vertexShader:At.meshlambert_vert,fragmentShader:At.meshlambert_frag},phong:{uniforms:de([it.common,it.specularmap,it.envmap,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.fog,it.lights,{emissive:{value:new kt(0)},specular:{value:new kt(1118481)},shininess:{value:30}}]),vertexShader:At.meshphong_vert,fragmentShader:At.meshphong_frag},standard:{uniforms:de([it.common,it.envmap,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.roughnessmap,it.metalnessmap,it.fog,it.lights,{emissive:{value:new kt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:At.meshphysical_vert,fragmentShader:At.meshphysical_frag},toon:{uniforms:de([it.common,it.aomap,it.lightmap,it.emissivemap,it.bumpmap,it.normalmap,it.displacementmap,it.gradientmap,it.fog,it.lights,{emissive:{value:new kt(0)}}]),vertexShader:At.meshtoon_vert,fragmentShader:At.meshtoon_frag},matcap:{uniforms:de([it.common,it.bumpmap,it.normalmap,it.displacementmap,it.fog,{matcap:{value:null}}]),vertexShader:At.meshmatcap_vert,fragmentShader:At.meshmatcap_frag},points:{uniforms:de([it.points,it.fog]),vertexShader:At.points_vert,fragmentShader:At.points_frag},dashed:{uniforms:de([it.common,it.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:At.linedashed_vert,fragmentShader:At.linedashed_frag},depth:{uniforms:de([it.common,it.displacementmap]),vertexShader:At.depth_vert,fragmentShader:At.depth_frag},normal:{uniforms:de([it.common,it.bumpmap,it.normalmap,it.displacementmap,{opacity:{value:1}}]),vertexShader:At.meshnormal_vert,fragmentShader:At.meshnormal_frag},sprite:{uniforms:de([it.sprite,it.fog]),vertexShader:At.sprite_vert,fragmentShader:At.sprite_frag},background:{uniforms:{uvTransform:{value:new Ct},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:At.background_vert,fragmentShader:At.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:At.backgroundCube_vert,fragmentShader:At.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:At.cube_vert,fragmentShader:At.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:At.equirect_vert,fragmentShader:At.equirect_frag},distanceRGBA:{uniforms:de([it.common,it.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:At.distanceRGBA_vert,fragmentShader:At.distanceRGBA_frag},shadow:{uniforms:de([it.lights,it.fog,{color:{value:new kt(0)},opacity:{value:1}}]),vertexShader:At.shadow_vert,fragmentShader:At.shadow_frag}};qe.physical={uniforms:de([qe.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ct},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ct},clearcoatNormalScale:{value:new Nt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ct},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ct},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ct},sheen:{value:0},sheenColor:{value:new kt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ct},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ct},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ct},transmissionSamplerSize:{value:new Nt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ct},attenuationDistance:{value:0},attenuationColor:{value:new kt(0)},specularColor:{value:new kt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ct},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ct},anisotropyVector:{value:new Nt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ct}}]),vertexShader:At.meshphysical_vert,fragmentShader:At.meshphysical_frag};var ys={r:0,b:0,g:0};function nd(i,t,e,n,s,r,a){let o=new kt(0),c=r===!0?0:1,l,h,d=null,u=0,m=null;function g(p,f){let v=!1,_=f.isScene===!0?f.background:null;switch(_&&_.isTexture&&(_=(f.backgroundBlurriness>0?e:t).get(_)),_===null?x(o,c):_&&_.isColor&&(x(_,1),v=!0),i.xr.getEnvironmentBlendMode()){case"opaque":v=!0;break;case"additive":n.buffers.color.setClear(0,0,0,1,a),v=!0;break;case"alpha-blend":n.buffers.color.setClear(0,0,0,0,a),v=!0;break}(i.autoClear||v)&&i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil),_&&(_.isCubeTexture||_.mapping===Bs)?(h===void 0&&(h=new Ye(new kn(1,1,1),new ln({name:"BackgroundCubeMaterial",uniforms:vi(qe.backgroundCube.uniforms),vertexShader:qe.backgroundCube.vertexShader,fragmentShader:qe.backgroundCube.fragmentShader,side:he,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(T,A,L){this.matrixWorld.copyPosition(L.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(h)),h.material.uniforms.envMap.value=_,h.material.uniforms.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=f.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=f.backgroundIntensity,h.material.toneMapped=_.colorSpace!==Rt,(d!==_||u!==_.version||m!==i.toneMapping)&&(h.material.needsUpdate=!0,d=_,u=_.version,m=i.toneMapping),h.layers.enableAll(),p.unshift(h,h.geometry,h.material,0,0,null)):_&&_.isTexture&&(l===void 0&&(l=new Ye(new Wi(2,2),new ln({name:"BackgroundMaterial",uniforms:vi(qe.background.uniforms),vertexShader:qe.background.vertexShader,fragmentShader:qe.background.fragmentShader,side:He,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(l)),l.material.uniforms.t2D.value=_,l.material.uniforms.backgroundIntensity.value=f.backgroundIntensity,l.material.toneMapped=_.colorSpace!==Rt,_.matrixAutoUpdate===!0&&_.updateMatrix(),l.material.uniforms.uvTransform.value.copy(_.matrix),(d!==_||u!==_.version||m!==i.toneMapping)&&(l.material.needsUpdate=!0,d=_,u=_.version,m=i.toneMapping),l.layers.enableAll(),p.unshift(l,l.geometry,l.material,0,0,null))}function x(p,f){p.getRGB(ys,Sc(i)),n.buffers.color.setClear(ys.r,ys.g,ys.b,f,a)}return{getClearColor:function(){return o},setClearColor:function(p,f=1){o.set(p),c=f,x(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(p){c=p,x(o,c)},render:g}}function id(i,t,e,n){let s=i.getParameter(i.MAX_VERTEX_ATTRIBS),r=n.isWebGL2?null:t.get("OES_vertex_array_object"),a=n.isWebGL2||r!==null,o={},c=p(null),l=c,h=!1;function d(D,O,$,G,q){let J=!1;if(a){let K=x(G,$,O);l!==K&&(l=K,m(l.object)),J=f(D,G,$,q),J&&v(D,G,$,q)}else{let K=O.wireframe===!0;(l.geometry!==G.id||l.program!==$.id||l.wireframe!==K)&&(l.geometry=G.id,l.program=$.id,l.wireframe=K,J=!0)}q!==null&&e.update(q,i.ELEMENT_ARRAY_BUFFER),(J||h)&&(h=!1,L(D,O,$,G),q!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(q).buffer))}function u(){return n.isWebGL2?i.createVertexArray():r.createVertexArrayOES()}function m(D){return n.isWebGL2?i.bindVertexArray(D):r.bindVertexArrayOES(D)}function g(D){return n.isWebGL2?i.deleteVertexArray(D):r.deleteVertexArrayOES(D)}function x(D,O,$){let G=$.wireframe===!0,q=o[D.id];q===void 0&&(q={},o[D.id]=q);let J=q[O.id];J===void 0&&(J={},q[O.id]=J);let K=J[G];return K===void 0&&(K=p(u()),J[G]=K),K}function p(D){let O=[],$=[],G=[];for(let q=0;q=0){let at=q[Z],ct=J[Z];if(ct===void 0&&(Z==="instanceMatrix"&&D.instanceMatrix&&(ct=D.instanceMatrix),Z==="instanceColor"&&D.instanceColor&&(ct=D.instanceColor)),at===void 0||at.attribute!==ct||ct&&at.data!==ct.data)return!0;K++}return l.attributesNum!==K||l.index!==G}function v(D,O,$,G){let q={},J=O.attributes,K=0,B=$.getAttributes();for(let Z in B)if(B[Z].location>=0){let at=J[Z];at===void 0&&(Z==="instanceMatrix"&&D.instanceMatrix&&(at=D.instanceMatrix),Z==="instanceColor"&&D.instanceColor&&(at=D.instanceColor));let ct={};ct.attribute=at,at&&at.data&&(ct.data=at.data),q[Z]=ct,K++}l.attributes=q,l.attributesNum=K,l.index=G}function _(){let D=l.newAttributes;for(let O=0,$=D.length;O<$;O++)D[O]=0}function b(D){S(D,0)}function S(D,O){let $=l.newAttributes,G=l.enabledAttributes,q=l.attributeDivisors;$[D]=1,G[D]===0&&(i.enableVertexAttribArray(D),G[D]=1),q[D]!==O&&((n.isWebGL2?i:t.get("ANGLE_instanced_arrays"))[n.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](D,O),q[D]=O)}function T(){let D=l.newAttributes,O=l.enabledAttributes;for(let $=0,G=O.length;$=0){let ot=q[B];if(ot===void 0&&(B==="instanceMatrix"&&D.instanceMatrix&&(ot=D.instanceMatrix),B==="instanceColor"&&D.instanceColor&&(ot=D.instanceColor)),ot!==void 0){let at=ot.normalized,ct=ot.itemSize,_t=e.get(ot);if(_t===void 0)continue;let Et=_t.buffer,xt=_t.type,zt=_t.bytesPerElement,xe=n.isWebGL2===!0&&(xt===i.INT||xt===i.UNSIGNED_INT||ot.gpuType===fc);if(ot.isInterleavedBufferAttribute){let Pt=ot.data,F=Pt.stride,oe=ot.offset;if(Pt.isInstancedInterleavedBuffer){for(let yt=0;yt0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";A="mediump"}return A==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let a=typeof WebGL2RenderingContext!="undefined"&&i.constructor.name==="WebGL2RenderingContext",o=e.precision!==void 0?e.precision:"highp",c=r(o);c!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",c,"instead."),o=c);let l=a||t.has("WEBGL_draw_buffers"),h=e.logarithmicDepthBuffer===!0,d=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),u=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=i.getParameter(i.MAX_TEXTURE_SIZE),g=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),x=i.getParameter(i.MAX_VERTEX_ATTRIBS),p=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),f=i.getParameter(i.MAX_VARYING_VECTORS),v=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),_=u>0,b=a||t.has("OES_texture_float"),S=_&&b,T=a?i.getParameter(i.MAX_SAMPLES):0;return{isWebGL2:a,drawBuffers:l,getMaxAnisotropy:s,getMaxPrecision:r,precision:o,logarithmicDepthBuffer:h,maxTextures:d,maxVertexTextures:u,maxTextureSize:m,maxCubemapSize:g,maxAttributes:x,maxVertexUniforms:p,maxVaryings:f,maxFragmentUniforms:v,vertexTextures:_,floatFragmentTextures:b,floatVertexTextures:S,maxSamples:T}}function od(i){let t=this,e=null,n=0,s=!1,r=!1,a=new Ce,o=new Ct,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(d,u){let m=d.length!==0||u||n!==0||s;return s=u,n=d.length,m},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,u){e=h(d,u,0)},this.setState=function(d,u,m){let g=d.clippingPlanes,x=d.clipIntersection,p=d.clipShadows,f=i.get(d);if(!s||g===null||g.length===0||r&&!p)r?h(null):l();else{let v=r?0:n,_=v*4,b=f.clippingState||null;c.value=b,b=h(g,u,_,m);for(let S=0;S!==_;++S)b[S]=e[S];f.clippingState=b,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=v}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(d,u,m,g){let x=d!==null?d.length:0,p=null;if(x!==0){if(p=c.value,g!==!0||p===null){let f=m+x*4,v=u.matrixWorldInverse;o.getNormalMatrix(v),(p===null||p.length0){let l=new Gr(c.height/2);return l.fromEquirectangularTexture(i,a),t.set(a,l),a.addEventListener("dispose",s),e(l.texture,a.mapping)}else return null}}return a}function s(a){let o=a.target;o.removeEventListener("dispose",s);let c=t.get(o);c!==void 0&&(t.delete(o),c.dispose())}function r(){t=new WeakMap}return{get:n,dispose:r}}var Wr=class extends Ds{constructor(t=-1,e=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2,r=n-t,a=n+t,o=s+e,c=s-e;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}},hi=4,za=[.125,.215,.35,.446,.526,.582],Nn=20,Rr=new Wr,Va=new kt,Cr=null,Dn=(1+Math.sqrt(5))/2,ci=1/Dn,ka=[new P(1,1,1),new P(-1,1,1),new P(1,1,-1),new P(-1,1,-1),new P(0,Dn,ci),new P(0,Dn,-ci),new P(ci,0,Dn),new P(-ci,0,Dn),new P(Dn,ci,0),new P(-Dn,ci,0)],Os=class{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,s=100){Cr=this._renderer.getRenderTarget(),this._setSize(256);let r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,n,s,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Wa(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Ga(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t2?_:0,_,_),h.setRenderTarget(s),x&&h.render(g,o),h.render(t,o)}g.geometry.dispose(),g.material.dispose(),h.toneMapping=u,h.autoClear=d,t.background=p}_textureToCubeUV(t,e){let n=this._renderer,s=t.mapping===mi||t.mapping===gi;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=Wa()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Ga());let r=s?this._cubemapMaterial:this._equirectMaterial,a=new Ye(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=t;let c=this._cubeSize;vs(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(a,Rr)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;for(let s=1;sNn&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${Nn}`);let f=[],v=0;for(let A=0;A_-hi?s-_+hi:0),T=4*(this._cubeSize-b);vs(e,S,T,3*b,2*b),c.setRenderTarget(e),c.render(d,Rr)}};function cd(i){let t=[],e=[],n=[],s=i,r=i-hi+1+za.length;for(let a=0;ai-hi?c=za[a-i+hi-1]:a===0&&(c=0),n.push(c);let l=1/(o-2),h=-l,d=1+l,u=[h,h,d,h,d,d,h,h,d,d,h,d],m=6,g=6,x=3,p=2,f=1,v=new Float32Array(x*g*m),_=new Float32Array(p*g*m),b=new Float32Array(f*g*m);for(let T=0;T2?0:-1,y=[A,L,0,A+2/3,L,0,A+2/3,L+1,0,A,L,0,A+2/3,L+1,0,A,L+1,0];v.set(y,x*g*T),_.set(u,p*g*T);let w=[T,T,T,T,T,T];b.set(w,f*g*T)}let S=new Ge;S.setAttribute("position",new te(v,x)),S.setAttribute("uv",new te(_,p)),S.setAttribute("faceIndex",new te(b,f)),t.push(S),s>hi&&s--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function Ha(i,t,e){let n=new cn(i,t,e);return n.texture.mapping=Bs,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function vs(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function ld(i,t,e){let n=new Float32Array(Nn),s=new P(0,1,0);return new ln({name:"SphericalGaussianBlur",defines:{n:Nn,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:_o(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues\' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t`,blending:vn,depthTest:!1,depthWrite:!1})}function Ga(){return new ln({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:_o(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t`,blending:vn,depthTest:!1,depthWrite:!1})}function Wa(){return new ln({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:_o(),fragmentShader:`\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t`,blending:vn,depthTest:!1,depthWrite:!1})}function _o(){return`\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t`}function hd(i){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){let c=o.mapping,l=c===Ir||c===Ur,h=c===mi||c===gi;if(l||h)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let d=t.get(o);return e===null&&(e=new Os(i)),d=l?e.fromEquirectangular(o,d):e.fromCubemap(o,d),t.set(o,d),d.texture}else{if(t.has(o))return t.get(o).texture;{let d=o.image;if(l&&d&&d.height>0||h&&d&&s(d)){e===null&&(e=new Os(i));let u=l?e.fromEquirectangular(o):e.fromCubemap(o);return t.set(o,u),o.addEventListener("dispose",r),u.texture}else return null}}}return o}function s(o){let c=0,l=6;for(let h=0;ht.maxTextureSize&&(w=Math.ceil(y/t.maxTextureSize),y=t.maxTextureSize);let z=new Float32Array(y*w*4*g),Y=new Cs(z,y,w,g);Y.type=yn,Y.needsUpdate=!0;let I=L*4;for(let O=0;O0)return i;let s=t*e,r=Xa[s];if(r===void 0&&(r=new Float32Array(s),Xa[s]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,i[a].toArray(r,o)}return r}function ee(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e":" "} ${o}: ${e[a]}`)}return n.join(`\n`)}function cp(i){switch(i){case Ze:return["Linear","( value )"];case Rt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",i),["Linear","( value )"]}}function Qa(i,t,e){let n=i.getShaderParameter(t,i.COMPILE_STATUS),s=i.getShaderInfoLog(t).trim();if(n&&s==="")return"";let r=/ERROR: 0:(\\d+)/.exec(s);if(r){let a=parseInt(r[1]);return e.toUpperCase()+`\n\n`+s+`\n\n`+ap(i.getShaderSource(t),a)}else return s}function lp(i,t){let e=cp(t);return"vec4 "+i+"( vec4 value ) { return LinearTo"+e[0]+e[1]+"; }"}function hp(i,t){let e;switch(t){case El:e="Linear";break;case Tl:e="Reinhard";break;case wl:e="OptimizedCineon";break;case Al:e="ACESFilmic";break;case Rl:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}function up(i){return[i.extensionDerivatives||i.envMapCubeUVHeight||i.bumpMap||i.normalMapTangentSpace||i.clearcoatNormalMap||i.flatShading||i.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(i.extensionFragDepth||i.logarithmicDepthBuffer)&&i.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",i.extensionDrawBuffers&&i.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(i.extensionShaderTextureLOD||i.envMap||i.transmission)&&i.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(zi).join(`\n`)}function fp(i){let t=[];for(let e in i){let n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`\n`)}function dp(i,t){let e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function Zr(i){return i.replace(pp,gp)}var mp=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function gp(i,t){let e=At[t];if(e===void 0){let n=mp.get(t);if(n!==void 0)e=At[n],console.warn(\'THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.\',t,n);else throw new Error("Can not resolve #include <"+t+">")}return Zr(e)}var _p=/#pragma unroll_loop_start\\s+for\\s*\\(\\s*int\\s+i\\s*=\\s*(\\d+)\\s*;\\s*i\\s*<\\s*(\\d+)\\s*;\\s*i\\s*\\+\\+\\s*\\)\\s*{([\\s\\S]+?)}\\s+#pragma unroll_loop_end/g;function ec(i){return i.replace(_p,xp)}function xp(i,t,e,n){let s="";for(let r=parseInt(t);r0&&(p+=`\n`),f=[m,"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(zi).join(`\n`),f.length>0&&(f+=`\n`)):(p=[nc(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors&&e.isWebGL2?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0&&e.isWebGL2?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.useLegacyLights?"#define LEGACY_LIGHTS":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.logarithmicDepthBuffer&&e.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",`\n`].filter(zi).join(`\n`),f=[m,nc(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+l:"",e.envMap?"#define "+h:"",e.envMap?"#define "+d:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.useLegacyLights?"#define LEGACY_LIGHTS":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.logarithmicDepthBuffer&&e.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==Mn?"#define TONE_MAPPING":"",e.toneMapping!==Mn?At.tonemapping_pars_fragment:"",e.toneMapping!==Mn?hp("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",At.colorspace_pars_fragment,lp("linearToOutputTexel",e.outputColorSpace),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`\n`].filter(zi).join(`\n`)),a=Zr(a),a=ja(a,e),a=tc(a,e),o=Zr(o),o=ja(o,e),o=tc(o,e),a=ec(a),o=ec(o),e.isWebGL2&&e.isRawShaderMaterial!==!0&&(v=`#version 300 es\n`,p=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`\n`)+`\n`+p,f=["#define varying in",e.glslVersion===Sa?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===Sa?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`\n`)+`\n`+f);let _=v+p+a,b=v+f+o,S=Ka(s,s.VERTEX_SHADER,_),T=Ka(s,s.FRAGMENT_SHADER,b);if(s.attachShader(x,S),s.attachShader(x,T),e.index0AttributeName!==void 0?s.bindAttribLocation(x,0,e.index0AttributeName):e.morphTargets===!0&&s.bindAttribLocation(x,0,"position"),s.linkProgram(x),i.debug.checkShaderErrors){let y=s.getProgramInfoLog(x).trim(),w=s.getShaderInfoLog(S).trim(),z=s.getShaderInfoLog(T).trim(),Y=!0,I=!0;if(s.getProgramParameter(x,s.LINK_STATUS)===!1)if(Y=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,x,S,T);else{let D=Qa(s,S,"vertex"),O=Qa(s,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(x,s.VALIDATE_STATUS)+`\n\nProgram Info Log: `+y+`\n`+D+`\n`+O)}else y!==""?console.warn("THREE.WebGLProgram: Program Info Log:",y):(w===""||z==="")&&(I=!1);I&&(this.diagnostics={runnable:Y,programLog:y,vertexShader:{log:w,prefix:p},fragmentShader:{log:z,prefix:f}})}s.deleteShader(S),s.deleteShader(T);let A;this.getUniforms=function(){return A===void 0&&(A=new pi(s,x)),A};let L;return this.getAttributes=function(){return L===void 0&&(L=dp(s,x)),L},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=op++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=S,this.fragmentShader=T,this}var Tp=0,Jr=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let e=t.vertexShader,n=t.fragmentShader,s=this._getShaderStage(e),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return a.has(s)===!1&&(a.add(s),s.usedTimes++),a.has(r)===!1&&(a.add(r),r.usedTimes++),this}remove(t){let e=this.materialCache.get(t);for(let n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){let e=this.materialCache,n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){let e=this.shaderCache,n=e.get(t);return n===void 0&&(n=new $r(t),e.set(t,n)),n}},$r=class{constructor(t){this.id=Tp++,this.code=t,this.usedTimes=0}};function wp(i,t,e,n,s,r,a){let o=new Ps,c=new Jr,l=[],h=s.isWebGL2,d=s.logarithmicDepthBuffer,u=s.vertexTextures,m=s.precision,g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function x(y){return y===0?"uv":`uv${y}`}function p(y,w,z,Y,I){let D=Y.fog,O=I.geometry,$=y.isMeshStandardMaterial?Y.environment:null,G=(y.isMeshStandardMaterial?e:t).get(y.envMap||$),q=G&&G.mapping===Bs?G.image.height:null,J=g[y.type];y.precision!==null&&(m=s.getMaxPrecision(y.precision),m!==y.precision&&console.warn("THREE.WebGLProgram.getParameters:",y.precision,"not supported, using",m,"instead."));let K=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,B=K!==void 0?K.length:0,Z=0;O.morphAttributes.position!==void 0&&(Z=1),O.morphAttributes.normal!==void 0&&(Z=2),O.morphAttributes.color!==void 0&&(Z=3);let ot,at,ct,_t;if(J){let Wt=qe[J];ot=Wt.vertexShader,at=Wt.fragmentShader}else ot=y.vertexShader,at=y.fragmentShader,c.update(y),ct=c.getVertexShaderID(y),_t=c.getFragmentShaderID(y);let Et=i.getRenderTarget(),xt=I.isInstancedMesh===!0,zt=!!y.map,xe=!!y.matcap,Pt=!!G,F=!!y.aoMap,oe=!!y.lightMap,yt=!!y.bumpMap,Tt=!!y.normalMap,bt=!!y.displacementMap,Xt=!!y.emissiveMap,Ft=!!y.metalnessMap,Lt=!!y.roughnessMap,Vt=y.anisotropy>0,re=y.clearcoat>0,ae=y.iridescence>0,R=y.sheen>0,M=y.transmission>0,V=Vt&&!!y.anisotropyMap,j=re&&!!y.clearcoatMap,Q=re&&!!y.clearcoatNormalMap,tt=re&&!!y.clearcoatRoughnessMap,ft=ae&&!!y.iridescenceMap,et=ae&&!!y.iridescenceThicknessMap,H=R&&!!y.sheenColorMap,mt=R&&!!y.sheenRoughnessMap,dt=!!y.specularMap,pt=!!y.specularColorMap,ht=!!y.specularIntensityMap,ut=M&&!!y.transmissionMap,It=M&&!!y.thicknessMap,Ht=!!y.gradientMap,C=!!y.alphaMap,st=y.alphaTest>0,k=!!y.alphaHash,nt=!!y.extensions,rt=!!O.attributes.uv1,Ot=!!O.attributes.uv2,qt=!!O.attributes.uv3,Jt=Mn;return y.toneMapped&&(Et===null||Et.isXRRenderTarget===!0)&&(Jt=i.toneMapping),{isWebGL2:h,shaderID:J,shaderType:y.type,shaderName:y.name,vertexShader:ot,fragmentShader:at,defines:y.defines,customVertexShaderID:ct,customFragmentShaderID:_t,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:m,instancing:xt,instancingColor:xt&&I.instanceColor!==null,supportsVertexTextures:u,outputColorSpace:Et===null?i.outputColorSpace:Et.isXRRenderTarget===!0?Et.texture.colorSpace:Ze,map:zt,matcap:xe,envMap:Pt,envMapMode:Pt&&G.mapping,envMapCubeUVHeight:q,aoMap:F,lightMap:oe,bumpMap:yt,normalMap:Tt,displacementMap:u&&bt,emissiveMap:Xt,normalMapObjectSpace:Tt&&y.normalMapType===Hl,normalMapTangentSpace:Tt&&y.normalMapType===kl,metalnessMap:Ft,roughnessMap:Lt,anisotropy:Vt,anisotropyMap:V,clearcoat:re,clearcoatMap:j,clearcoatNormalMap:Q,clearcoatRoughnessMap:tt,iridescence:ae,iridescenceMap:ft,iridescenceThicknessMap:et,sheen:R,sheenColorMap:H,sheenRoughnessMap:mt,specularMap:dt,specularColorMap:pt,specularIntensityMap:ht,transmission:M,transmissionMap:ut,thicknessMap:It,gradientMap:Ht,opaque:y.transparent===!1&&y.blending===fi,alphaMap:C,alphaTest:st,alphaHash:k,combine:y.combine,mapUv:zt&&x(y.map.channel),aoMapUv:F&&x(y.aoMap.channel),lightMapUv:oe&&x(y.lightMap.channel),bumpMapUv:yt&&x(y.bumpMap.channel),normalMapUv:Tt&&x(y.normalMap.channel),displacementMapUv:bt&&x(y.displacementMap.channel),emissiveMapUv:Xt&&x(y.emissiveMap.channel),metalnessMapUv:Ft&&x(y.metalnessMap.channel),roughnessMapUv:Lt&&x(y.roughnessMap.channel),anisotropyMapUv:V&&x(y.anisotropyMap.channel),clearcoatMapUv:j&&x(y.clearcoatMap.channel),clearcoatNormalMapUv:Q&&x(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:tt&&x(y.clearcoatRoughnessMap.channel),iridescenceMapUv:ft&&x(y.iridescenceMap.channel),iridescenceThicknessMapUv:et&&x(y.iridescenceThicknessMap.channel),sheenColorMapUv:H&&x(y.sheenColorMap.channel),sheenRoughnessMapUv:mt&&x(y.sheenRoughnessMap.channel),specularMapUv:dt&&x(y.specularMap.channel),specularColorMapUv:pt&&x(y.specularColorMap.channel),specularIntensityMapUv:ht&&x(y.specularIntensityMap.channel),transmissionMapUv:ut&&x(y.transmissionMap.channel),thicknessMapUv:It&&x(y.thicknessMap.channel),alphaMapUv:C&&x(y.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(Tt||Vt),vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,vertexUv1s:rt,vertexUv2s:Ot,vertexUv3s:qt,pointsUvs:I.isPoints===!0&&!!O.attributes.uv&&(zt||C),fog:!!D,useFog:y.fog===!0,fogExp2:D&&D.isFogExp2,flatShading:y.flatShading===!0,sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:I.isSkinnedMesh===!0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:B,morphTextureStride:Z,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:y.dithering,shadowMapEnabled:i.shadowMap.enabled&&z.length>0,shadowMapType:i.shadowMap.type,toneMapping:Jt,useLegacyLights:i._useLegacyLights,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===ze,flipSided:y.side===he,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionDerivatives:nt&&y.extensions.derivatives===!0,extensionFragDepth:nt&&y.extensions.fragDepth===!0,extensionDrawBuffers:nt&&y.extensions.drawBuffers===!0,extensionShaderTextureLOD:nt&&y.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:h||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||n.has("EXT_shader_texture_lod"),customProgramCacheKey:y.customProgramCacheKey()}}function f(y){let w=[];if(y.shaderID?w.push(y.shaderID):(w.push(y.customVertexShaderID),w.push(y.customFragmentShaderID)),y.defines!==void 0)for(let z in y.defines)w.push(z),w.push(y.defines[z]);return y.isRawShaderMaterial===!1&&(v(w,y),_(w,y),w.push(i.outputColorSpace)),w.push(y.customProgramCacheKey),w.join()}function v(y,w){y.push(w.precision),y.push(w.outputColorSpace),y.push(w.envMapMode),y.push(w.envMapCubeUVHeight),y.push(w.mapUv),y.push(w.alphaMapUv),y.push(w.lightMapUv),y.push(w.aoMapUv),y.push(w.bumpMapUv),y.push(w.normalMapUv),y.push(w.displacementMapUv),y.push(w.emissiveMapUv),y.push(w.metalnessMapUv),y.push(w.roughnessMapUv),y.push(w.anisotropyMapUv),y.push(w.clearcoatMapUv),y.push(w.clearcoatNormalMapUv),y.push(w.clearcoatRoughnessMapUv),y.push(w.iridescenceMapUv),y.push(w.iridescenceThicknessMapUv),y.push(w.sheenColorMapUv),y.push(w.sheenRoughnessMapUv),y.push(w.specularMapUv),y.push(w.specularColorMapUv),y.push(w.specularIntensityMapUv),y.push(w.transmissionMapUv),y.push(w.thicknessMapUv),y.push(w.combine),y.push(w.fogExp2),y.push(w.sizeAttenuation),y.push(w.morphTargetsCount),y.push(w.morphAttributeCount),y.push(w.numDirLights),y.push(w.numPointLights),y.push(w.numSpotLights),y.push(w.numSpotLightMaps),y.push(w.numHemiLights),y.push(w.numRectAreaLights),y.push(w.numDirLightShadows),y.push(w.numPointLightShadows),y.push(w.numSpotLightShadows),y.push(w.numSpotLightShadowsWithMaps),y.push(w.shadowMapType),y.push(w.toneMapping),y.push(w.numClippingPlanes),y.push(w.numClipIntersection),y.push(w.depthPacking)}function _(y,w){o.disableAll(),w.isWebGL2&&o.enable(0),w.supportsVertexTextures&&o.enable(1),w.instancing&&o.enable(2),w.instancingColor&&o.enable(3),w.matcap&&o.enable(4),w.envMap&&o.enable(5),w.normalMapObjectSpace&&o.enable(6),w.normalMapTangentSpace&&o.enable(7),w.clearcoat&&o.enable(8),w.iridescence&&o.enable(9),w.alphaTest&&o.enable(10),w.vertexColors&&o.enable(11),w.vertexAlphas&&o.enable(12),w.vertexUv1s&&o.enable(13),w.vertexUv2s&&o.enable(14),w.vertexUv3s&&o.enable(15),w.vertexTangents&&o.enable(16),w.anisotropy&&o.enable(17),y.push(o.mask),o.disableAll(),w.fog&&o.enable(0),w.useFog&&o.enable(1),w.flatShading&&o.enable(2),w.logarithmicDepthBuffer&&o.enable(3),w.skinning&&o.enable(4),w.morphTargets&&o.enable(5),w.morphNormals&&o.enable(6),w.morphColors&&o.enable(7),w.premultipliedAlpha&&o.enable(8),w.shadowMapEnabled&&o.enable(9),w.useLegacyLights&&o.enable(10),w.doubleSided&&o.enable(11),w.flipSided&&o.enable(12),w.useDepthPacking&&o.enable(13),w.dithering&&o.enable(14),w.transmission&&o.enable(15),w.sheen&&o.enable(16),w.opaque&&o.enable(17),w.pointsUvs&&o.enable(18),y.push(o.mask)}function b(y){let w=g[y.type],z;if(w){let Y=qe[w];z=xh.clone(Y.uniforms)}else z=y.uniforms;return z}function S(y,w){let z;for(let Y=0,I=l.length;Y0?n.push(f):m.transparent===!0?s.push(f):e.push(f)}function c(d,u,m,g,x,p){let f=a(d,u,m,g,x,p);m.transmission>0?n.unshift(f):m.transparent===!0?s.unshift(f):e.unshift(f)}function l(d,u){e.length>1&&e.sort(d||Rp),n.length>1&&n.sort(u||ic),s.length>1&&s.sort(u||ic)}function h(){for(let d=t,u=i.length;d=r.length?(a=new sc,r.push(a)):a=r[s],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function Pp(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new P,color:new kt};break;case"SpotLight":e={position:new P,direction:new P,color:new kt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new P,color:new kt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new P,skyColor:new kt,groundColor:new kt};break;case"RectAreaLight":e={color:new kt,position:new P,halfWidth:new P,halfHeight:new P};break}return i[t.id]=e,e}}}function Lp(){let i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nt};break;case"SpotLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nt};break;case"PointLight":e={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Nt,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}var Ip=0;function Up(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function Dp(i,t){let e=new Pp,n=Lp(),s={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let h=0;h<9;h++)s.probe.push(new P);let r=new P,a=new Gt,o=new Gt;function c(h,d){let u=0,m=0,g=0;for(let z=0;z<9;z++)s.probe[z].set(0,0,0);let x=0,p=0,f=0,v=0,_=0,b=0,S=0,T=0,A=0,L=0;h.sort(Up);let y=d===!0?Math.PI:1;for(let z=0,Y=h.length;z0&&(t.isWebGL2||i.has("OES_texture_float_linear")===!0?(s.rectAreaLTC1=it.LTC_FLOAT_1,s.rectAreaLTC2=it.LTC_FLOAT_2):i.has("OES_texture_half_float_linear")===!0?(s.rectAreaLTC1=it.LTC_HALF_1,s.rectAreaLTC2=it.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),s.ambient[0]=u,s.ambient[1]=m,s.ambient[2]=g;let w=s.hash;(w.directionalLength!==x||w.pointLength!==p||w.spotLength!==f||w.rectAreaLength!==v||w.hemiLength!==_||w.numDirectionalShadows!==b||w.numPointShadows!==S||w.numSpotShadows!==T||w.numSpotMaps!==A)&&(s.directional.length=x,s.spot.length=f,s.rectArea.length=v,s.point.length=p,s.hemi.length=_,s.directionalShadow.length=b,s.directionalShadowMap.length=b,s.pointShadow.length=S,s.pointShadowMap.length=S,s.spotShadow.length=T,s.spotShadowMap.length=T,s.directionalShadowMatrix.length=b,s.pointShadowMatrix.length=S,s.spotLightMatrix.length=T+A-L,s.spotLightMap.length=A,s.numSpotLightShadowsWithMaps=L,w.directionalLength=x,w.pointLength=p,w.spotLength=f,w.rectAreaLength=v,w.hemiLength=_,w.numDirectionalShadows=b,w.numPointShadows=S,w.numSpotShadows=T,w.numSpotMaps=A,s.version=Ip++)}function l(h,d){let u=0,m=0,g=0,x=0,p=0,f=d.matrixWorldInverse;for(let v=0,_=h.length;v<_;v++){let b=h[v];if(b.isDirectionalLight){let S=s.directional[u];S.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(f),u++}else if(b.isSpotLight){let S=s.spot[g];S.position.setFromMatrixPosition(b.matrixWorld),S.position.applyMatrix4(f),S.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),S.direction.sub(r),S.direction.transformDirection(f),g++}else if(b.isRectAreaLight){let S=s.rectArea[x];S.position.setFromMatrixPosition(b.matrixWorld),S.position.applyMatrix4(f),o.identity(),a.copy(b.matrixWorld),a.premultiply(f),o.extractRotation(a),S.halfWidth.set(b.width*.5,0,0),S.halfHeight.set(0,b.height*.5,0),S.halfWidth.applyMatrix4(o),S.halfHeight.applyMatrix4(o),x++}else if(b.isPointLight){let S=s.point[m];S.position.setFromMatrixPosition(b.matrixWorld),S.position.applyMatrix4(f),m++}else if(b.isHemisphereLight){let S=s.hemi[p];S.direction.setFromMatrixPosition(b.matrixWorld),S.direction.transformDirection(f),p++}}}return{setup:c,setupView:l,state:s}}function rc(i,t){let e=new Dp(i,t),n=[],s=[];function r(){n.length=0,s.length=0}function a(d){n.push(d)}function o(d){s.push(d)}function c(d){e.setup(n,d)}function l(d){e.setupView(n,d)}return{init:r,state:{lightsArray:n,shadowsArray:s,lights:e},setupLights:c,setupLightsView:l,pushLight:a,pushShadow:o}}function Np(i,t){let e=new WeakMap;function n(r,a=0){let o=e.get(r),c;return o===void 0?(c=new rc(i,t),e.set(r,[c])):a>=o.length?(c=new rc(i,t),o.push(c)):c=o[a],c}function s(){e=new WeakMap}return{get:n,dispose:s}}var Kr=class extends yi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=zl,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}},Qr=class extends yi{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}},Fp=`void main() {\n\tgl_Position = vec4( position, 1.0 );\n}`,Op=`uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}`;function Bp(i,t,e){let n=new Fs,s=new Nt,r=new Nt,a=new jt,o=new Kr({depthPacking:Vl}),c=new Qr,l={},h=e.maxTextureSize,d={[He]:he,[he]:He,[ze]:ze},u=new ln({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Nt},radius:{value:4}},vertexShader:Fp,fragmentShader:Op}),m=u.clone();m.defines.HORIZONTAL_PASS=1;let g=new Ge;g.setAttribute("position",new te(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new Ye(g,u),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ac;let f=this.type;this.render=function(S,T,A){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||S.length===0)return;let L=i.getRenderTarget(),y=i.getActiveCubeFace(),w=i.getActiveMipmapLevel(),z=i.state;z.setBlending(vn),z.buffers.color.setClear(1,1,1,1),z.buffers.depth.setTest(!0),z.setScissorTest(!1);let Y=f!==rn&&this.type===rn,I=f===rn&&this.type!==rn;for(let D=0,O=S.length;Dh||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/q.x),s.x=r.x*q.x,G.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/q.y),s.y=r.y*q.y,G.mapSize.y=r.y)),G.map===null||Y===!0||I===!0){let K=this.type!==rn?{minFilter:pe,magFilter:pe}:{};G.map!==null&&G.map.dispose(),G.map=new cn(s.x,s.y,K),G.map.texture.name=$.name+".shadowMap",G.camera.updateProjectionMatrix()}i.setRenderTarget(G.map),i.clear();let J=G.getViewportCount();for(let K=0;K0||T.map&&T.alphaTest>0){let z=y.uuid,Y=T.uuid,I=l[z];I===void 0&&(I={},l[z]=I);let D=I[Y];D===void 0&&(D=y.clone(),I[Y]=D),y=D}if(y.visible=T.visible,y.wireframe=T.wireframe,L===rn?y.side=T.shadowSide!==null?T.shadowSide:T.side:y.side=T.shadowSide!==null?T.shadowSide:d[T.side],y.alphaMap=T.alphaMap,y.alphaTest=T.alphaTest,y.map=T.map,y.clipShadows=T.clipShadows,y.clippingPlanes=T.clippingPlanes,y.clipIntersection=T.clipIntersection,y.displacementMap=T.displacementMap,y.displacementScale=T.displacementScale,y.displacementBias=T.displacementBias,y.wireframeLinewidth=T.wireframeLinewidth,y.linewidth=T.linewidth,A.isPointLight===!0&&y.isMeshDistanceMaterial===!0){let z=i.properties.get(y);z.light=A}return y}function b(S,T,A,L,y){if(S.visible===!1)return;if(S.layers.test(T.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&y===rn)&&(!S.frustumCulled||n.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,S.matrixWorld);let Y=t.update(S),I=S.material;if(Array.isArray(I)){let D=Y.groups;for(let O=0,$=D.length;O<$;O++){let G=D[O],q=I[G.materialIndex];if(q&&q.visible){let J=_(S,q,L,y);i.renderBufferDirect(A,null,Y,J,S,G)}}}else if(I.visible){let D=_(S,I,L,y);i.renderBufferDirect(A,null,Y,D,S,null)}}let z=S.children;for(let Y=0,I=z.length;Y=1):q.indexOf("OpenGL ES")!==-1&&(G=parseFloat(/^OpenGL ES (\\d)/.exec(q)[1]),$=G>=2);let J=null,K={},B=i.getParameter(i.SCISSOR_BOX),Z=i.getParameter(i.VIEWPORT),ot=new jt().fromArray(B),at=new jt().fromArray(Z);function ct(C,st,k,nt){let rt=new Uint8Array(4),Ot=i.createTexture();i.bindTexture(C,Ot),i.texParameteri(C,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(C,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let qt=0;qtj||R.height>j)&&(Q=j/Math.max(R.width,R.height)),Q<1||M===!0)if(typeof HTMLImageElement!="undefined"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&R instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&R instanceof ImageBitmap){let tt=M?Br:Math.floor,ft=tt(Q*R.width),et=tt(Q*R.height);x===void 0&&(x=v(ft,et));let H=V?v(ft,et):x;return H.width=ft,H.height=et,H.getContext("2d").drawImage(R,0,0,ft,et),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+R.width+"x"+R.height+") to ("+ft+"x"+et+")."),H}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+R.width+"x"+R.height+")."),R;return R}function b(R){return ba(R.width)&&ba(R.height)}function S(R){return o?!1:R.wrapS!==Ve||R.wrapT!==Ve||R.minFilter!==pe&&R.minFilter!==Ie}function T(R,M){return R.generateMipmaps&&M&&R.minFilter!==pe&&R.minFilter!==Ie}function A(R){i.generateMipmap(R)}function L(R,M,V,j,Q=!1){if(o===!1)return M;if(R!==null){if(i[R]!==void 0)return i[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format \'"+R+"\'")}let tt=M;return M===i.RED&&(V===i.FLOAT&&(tt=i.R32F),V===i.HALF_FLOAT&&(tt=i.R16F),V===i.UNSIGNED_BYTE&&(tt=i.R8)),M===i.RED_INTEGER&&(V===i.UNSIGNED_BYTE&&(tt=i.R8UI),V===i.UNSIGNED_SHORT&&(tt=i.R16UI),V===i.UNSIGNED_INT&&(tt=i.R32UI),V===i.BYTE&&(tt=i.R8I),V===i.SHORT&&(tt=i.R16I),V===i.INT&&(tt=i.R32I)),M===i.RG&&(V===i.FLOAT&&(tt=i.RG32F),V===i.HALF_FLOAT&&(tt=i.RG16F),V===i.UNSIGNED_BYTE&&(tt=i.RG8)),M===i.RGBA&&(V===i.FLOAT&&(tt=i.RGBA32F),V===i.HALF_FLOAT&&(tt=i.RGBA16F),V===i.UNSIGNED_BYTE&&(tt=j===Rt&&Q===!1?i.SRGB8_ALPHA8:i.RGBA8),V===i.UNSIGNED_SHORT_4_4_4_4&&(tt=i.RGBA4),V===i.UNSIGNED_SHORT_5_5_5_1&&(tt=i.RGB5_A1)),(tt===i.R16F||tt===i.R32F||tt===i.RG16F||tt===i.RG32F||tt===i.RGBA16F||tt===i.RGBA32F)&&t.get("EXT_color_buffer_float"),tt}function y(R,M,V){return T(R,V)===!0||R.isFramebufferTexture&&R.minFilter!==pe&&R.minFilter!==Ie?Math.log2(Math.max(M.width,M.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?M.mipmaps.length:1}function w(R){return R===pe||R===Zo||R===er?i.NEAREST:i.LINEAR}function z(R){let M=R.target;M.removeEventListener("dispose",z),I(M),M.isVideoTexture&&g.delete(M)}function Y(R){let M=R.target;M.removeEventListener("dispose",Y),O(M)}function I(R){let M=n.get(R);if(M.__webglInit===void 0)return;let V=R.source,j=p.get(V);if(j){let Q=j[M.__cacheKey];Q.usedTimes--,Q.usedTimes===0&&D(R),Object.keys(j).length===0&&p.delete(V)}n.remove(R)}function D(R){let M=n.get(R);i.deleteTexture(M.__webglTexture);let V=R.source,j=p.get(V);delete j[M.__cacheKey],a.memory.textures--}function O(R){let M=R.texture,V=n.get(R),j=n.get(M);if(j.__webglTexture!==void 0&&(i.deleteTexture(j.__webglTexture),a.memory.textures--),R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let Q=0;Q<6;Q++){if(Array.isArray(V.__webglFramebuffer[Q]))for(let tt=0;tt=c&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+c),$+=1,R}function J(R){let M=[];return M.push(R.wrapS),M.push(R.wrapT),M.push(R.wrapR||0),M.push(R.magFilter),M.push(R.minFilter),M.push(R.anisotropy),M.push(R.internalFormat),M.push(R.format),M.push(R.type),M.push(R.generateMipmaps),M.push(R.premultiplyAlpha),M.push(R.flipY),M.push(R.unpackAlignment),M.push(R.colorSpace),M.join()}function K(R,M){let V=n.get(R);if(R.isVideoTexture&&re(R),R.isRenderTargetTexture===!1&&R.version>0&&V.__version!==R.version){let j=R.image;if(j===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(j.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{zt(V,R,M);return}}e.bindTexture(i.TEXTURE_2D,V.__webglTexture,i.TEXTURE0+M)}function B(R,M){let V=n.get(R);if(R.version>0&&V.__version!==R.version){zt(V,R,M);return}e.bindTexture(i.TEXTURE_2D_ARRAY,V.__webglTexture,i.TEXTURE0+M)}function Z(R,M){let V=n.get(R);if(R.version>0&&V.__version!==R.version){zt(V,R,M);return}e.bindTexture(i.TEXTURE_3D,V.__webglTexture,i.TEXTURE0+M)}function ot(R,M){let V=n.get(R);if(R.version>0&&V.__version!==R.version){xe(V,R,M);return}e.bindTexture(i.TEXTURE_CUBE_MAP,V.__webglTexture,i.TEXTURE0+M)}let at={[Dr]:i.REPEAT,[Ve]:i.CLAMP_TO_EDGE,[Nr]:i.MIRRORED_REPEAT},ct={[pe]:i.NEAREST,[Zo]:i.NEAREST_MIPMAP_NEAREST,[er]:i.NEAREST_MIPMAP_LINEAR,[Ie]:i.LINEAR,[Cl]:i.LINEAR_MIPMAP_NEAREST,[Hi]:i.LINEAR_MIPMAP_LINEAR},_t={[Wl]:i.NEVER,[Kl]:i.ALWAYS,[Xl]:i.LESS,[Yl]:i.LEQUAL,[ql]:i.EQUAL,[$l]:i.GEQUAL,[Zl]:i.GREATER,[Jl]:i.NOTEQUAL};function Et(R,M,V){if(V?(i.texParameteri(R,i.TEXTURE_WRAP_S,at[M.wrapS]),i.texParameteri(R,i.TEXTURE_WRAP_T,at[M.wrapT]),(R===i.TEXTURE_3D||R===i.TEXTURE_2D_ARRAY)&&i.texParameteri(R,i.TEXTURE_WRAP_R,at[M.wrapR]),i.texParameteri(R,i.TEXTURE_MAG_FILTER,ct[M.magFilter]),i.texParameteri(R,i.TEXTURE_MIN_FILTER,ct[M.minFilter])):(i.texParameteri(R,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(R,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),(R===i.TEXTURE_3D||R===i.TEXTURE_2D_ARRAY)&&i.texParameteri(R,i.TEXTURE_WRAP_R,i.CLAMP_TO_EDGE),(M.wrapS!==Ve||M.wrapT!==Ve)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),i.texParameteri(R,i.TEXTURE_MAG_FILTER,w(M.magFilter)),i.texParameteri(R,i.TEXTURE_MIN_FILTER,w(M.minFilter)),M.minFilter!==pe&&M.minFilter!==Ie&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),M.compareFunction&&(i.texParameteri(R,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(R,i.TEXTURE_COMPARE_FUNC,_t[M.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){let j=t.get("EXT_texture_filter_anisotropic");if(M.magFilter===pe||M.minFilter!==er&&M.minFilter!==Hi||M.type===yn&&t.has("OES_texture_float_linear")===!1||o===!1&&M.type===Gi&&t.has("OES_texture_half_float_linear")===!1)return;(M.anisotropy>1||n.get(M).__currentAnisotropy)&&(i.texParameterf(R,j.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(M.anisotropy,s.getMaxAnisotropy())),n.get(M).__currentAnisotropy=M.anisotropy)}}function xt(R,M){let V=!1;R.__webglInit===void 0&&(R.__webglInit=!0,M.addEventListener("dispose",z));let j=M.source,Q=p.get(j);Q===void 0&&(Q={},p.set(j,Q));let tt=J(M);if(tt!==R.__cacheKey){Q[tt]===void 0&&(Q[tt]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,V=!0),Q[tt].usedTimes++;let ft=Q[R.__cacheKey];ft!==void 0&&(Q[R.__cacheKey].usedTimes--,ft.usedTimes===0&&D(M)),R.__cacheKey=tt,R.__webglTexture=Q[tt].texture}return V}function zt(R,M,V){let j=i.TEXTURE_2D;(M.isDataArrayTexture||M.isCompressedArrayTexture)&&(j=i.TEXTURE_2D_ARRAY),M.isData3DTexture&&(j=i.TEXTURE_3D);let Q=xt(R,M),tt=M.source;e.bindTexture(j,R.__webglTexture,i.TEXTURE0+V);let ft=n.get(tt);if(tt.version!==ft.__version||Q===!0){e.activeTexture(i.TEXTURE0+V),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,M.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,M.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,M.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.NONE);let et=S(M)&&b(M.image)===!1,H=_(M.image,et,!1,h);H=ae(M,H);let mt=b(H)||o,dt=r.convert(M.format,M.colorSpace),pt=r.convert(M.type),ht=L(M.internalFormat,dt,pt,M.colorSpace);Et(j,M,mt);let ut,It=M.mipmaps,Ht=o&&M.isVideoTexture!==!0,C=ft.__version===void 0||Q===!0,st=y(M,H,mt);if(M.isDepthTexture)ht=i.DEPTH_COMPONENT,o?M.type===yn?ht=i.DEPTH_COMPONENT32F:M.type===xn?ht=i.DEPTH_COMPONENT24:M.type===Fn?ht=i.DEPTH24_STENCIL8:ht=i.DEPTH_COMPONENT16:M.type===yn&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),M.format===On&&ht===i.DEPTH_COMPONENT&&M.type!==go&&M.type!==xn&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),M.type=xn,pt=r.convert(M.type)),M.format===_i&&ht===i.DEPTH_COMPONENT&&(ht=i.DEPTH_STENCIL,M.type!==Fn&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),M.type=Fn,pt=r.convert(M.type))),C&&(Ht?e.texStorage2D(i.TEXTURE_2D,1,ht,H.width,H.height):e.texImage2D(i.TEXTURE_2D,0,ht,H.width,H.height,0,dt,pt,null));else if(M.isDataTexture)if(It.length>0&&mt){Ht&&C&&e.texStorage2D(i.TEXTURE_2D,st,ht,It[0].width,It[0].height);for(let k=0,nt=It.length;k>=1,nt>>=1}}else if(It.length>0&&mt){Ht&&C&&e.texStorage2D(i.TEXTURE_2D,st,ht,It[0].width,It[0].height);for(let k=0,nt=It.length;k0&&C++,e.texStorage2D(i.TEXTURE_CUBE_MAP,C,ut,H[0].width,H[0].height));for(let k=0;k<6;k++)if(et){It?e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,0,0,H[k].width,H[k].height,pt,ht,H[k].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,ut,H[k].width,H[k].height,0,pt,ht,H[k].data);for(let nt=0;nt>tt),pt=Math.max(1,M.height>>tt);Q===i.TEXTURE_3D||Q===i.TEXTURE_2D_ARRAY?e.texImage3D(Q,tt,H,dt,pt,M.depth,0,ft,et,null):e.texImage2D(Q,tt,H,dt,pt,0,ft,et,null)}e.bindFramebuffer(i.FRAMEBUFFER,R),Vt(M)?u.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,j,Q,n.get(V).__webglTexture,0,Lt(M)):(Q===i.TEXTURE_2D||Q>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Q<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,j,Q,n.get(V).__webglTexture,tt),e.bindFramebuffer(i.FRAMEBUFFER,null)}function F(R,M,V){if(i.bindRenderbuffer(i.RENDERBUFFER,R),M.depthBuffer&&!M.stencilBuffer){let j=i.DEPTH_COMPONENT16;if(V||Vt(M)){let Q=M.depthTexture;Q&&Q.isDepthTexture&&(Q.type===yn?j=i.DEPTH_COMPONENT32F:Q.type===xn&&(j=i.DEPTH_COMPONENT24));let tt=Lt(M);Vt(M)?u.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,tt,j,M.width,M.height):i.renderbufferStorageMultisample(i.RENDERBUFFER,tt,j,M.width,M.height)}else i.renderbufferStorage(i.RENDERBUFFER,j,M.width,M.height);i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.RENDERBUFFER,R)}else if(M.depthBuffer&&M.stencilBuffer){let j=Lt(M);V&&Vt(M)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,j,i.DEPTH24_STENCIL8,M.width,M.height):Vt(M)?u.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,j,i.DEPTH24_STENCIL8,M.width,M.height):i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,M.width,M.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.RENDERBUFFER,R)}else{let j=M.isWebGLMultipleRenderTargets===!0?M.texture:[M.texture];for(let Q=0;Q0){V.__webglFramebuffer[et]=[];for(let H=0;H0){V.__webglFramebuffer=[];for(let et=0;et0&&Vt(R)===!1){let et=tt?M:[M];V.__webglMultisampledFramebuffer=i.createFramebuffer(),V.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,V.__webglMultisampledFramebuffer);for(let H=0;H0)for(let H=0;H0)for(let H=0;H0&&Vt(R)===!1){let M=R.isWebGLMultipleRenderTargets?R.texture:[R.texture],V=R.width,j=R.height,Q=i.COLOR_BUFFER_BIT,tt=[],ft=R.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,et=n.get(R),H=R.isWebGLMultipleRenderTargets===!0;if(H)for(let mt=0;mt0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&M.__useRenderToTexture!==!1}function re(R){let M=a.render.frame;g.get(R)!==M&&(g.set(R,M),R.update())}function ae(R,M){let V=R.colorSpace,j=R.format,Q=R.type;return R.isCompressedTexture===!0||R.format===Fr||V!==Ze&&V!==zn&&(V===Rt?o===!1?t.has("EXT_sRGB")===!0&&j===ke?(R.format=Fr,R.minFilter=Ie,R.generateMipmaps=!1):M=As.sRGBToLinear(M):(j!==ke||Q!==Sn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",V)),M}this.allocateTextureUnit=q,this.resetTextureUnits=G,this.setTexture2D=K,this.setTexture2DArray=B,this.setTexture3D=Z,this.setTextureCube=ot,this.rebindTextures=Tt,this.setupRenderTarget=bt,this.updateRenderTargetMipmap=Xt,this.updateMultisampleRenderTarget=Ft,this.setupDepthRenderbuffer=yt,this.setupFrameBufferTexture=Pt,this.useMultisampledRTT=Vt}function kp(i,t,e){let n=e.isWebGL2;function s(r,a=zn){let o;if(r===Sn)return i.UNSIGNED_BYTE;if(r===dc)return i.UNSIGNED_SHORT_4_4_4_4;if(r===pc)return i.UNSIGNED_SHORT_5_5_5_1;if(r===Pl)return i.BYTE;if(r===Ll)return i.SHORT;if(r===go)return i.UNSIGNED_SHORT;if(r===fc)return i.INT;if(r===xn)return i.UNSIGNED_INT;if(r===yn)return i.FLOAT;if(r===Gi)return n?i.HALF_FLOAT:(o=t.get("OES_texture_half_float"),o!==null?o.HALF_FLOAT_OES:null);if(r===Il)return i.ALPHA;if(r===ke)return i.RGBA;if(r===Ul)return i.LUMINANCE;if(r===Dl)return i.LUMINANCE_ALPHA;if(r===On)return i.DEPTH_COMPONENT;if(r===_i)return i.DEPTH_STENCIL;if(r===Fr)return o=t.get("EXT_sRGB"),o!==null?o.SRGB_ALPHA_EXT:null;if(r===Nl)return i.RED;if(r===mc)return i.RED_INTEGER;if(r===Fl)return i.RG;if(r===gc)return i.RG_INTEGER;if(r===_c)return i.RGBA_INTEGER;if(r===nr||r===ir||r===sr||r===rr)if(a===Rt)if(o=t.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(r===nr)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===ir)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===sr)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===rr)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=t.get("WEBGL_compressed_texture_s3tc"),o!==null){if(r===nr)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===ir)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===sr)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===rr)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===Jo||r===$o||r===Ko||r===Qo)if(o=t.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(r===Jo)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===$o)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===Ko)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===Qo)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===Ol)return o=t.get("WEBGL_compressed_texture_etc1"),o!==null?o.COMPRESSED_RGB_ETC1_WEBGL:null;if(r===jo||r===ta)if(o=t.get("WEBGL_compressed_texture_etc"),o!==null){if(r===jo)return a===Rt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(r===ta)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===ea||r===na||r===ia||r===sa||r===ra||r===oa||r===aa||r===ca||r===la||r===ha||r===ua||r===fa||r===da||r===pa)if(o=t.get("WEBGL_compressed_texture_astc"),o!==null){if(r===ea)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===na)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===ia)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===sa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===ra)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===oa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===aa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===ca)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===la)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===ha)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===ua)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===fa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===da)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===pa)return a===Rt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===or)if(o=t.get("EXT_texture_compression_bptc"),o!==null){if(r===or)return a===Rt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(r===Bl||r===ma||r===ga||r===_a)if(o=t.get("EXT_texture_compression_rgtc"),o!==null){if(r===or)return o.COMPRESSED_RED_RGTC1_EXT;if(r===ma)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===ga)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===_a)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===Fn?n?i.UNSIGNED_INT_24_8:(o=t.get("WEBGL_depth_texture"),o!==null?o.UNSIGNED_INT_24_8_WEBGL:null):i[r]!==void 0?i[r]:null}return{convert:s}}var jr=class extends Re{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},ui=class extends ve{constructor(){super(),this.isGroup=!0,this.type="Group"}},Hp={type:"move"},ki=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ui,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ui,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ui,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let s=null,r=null,a=null,o=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){a=!0;for(let x of t.hand.values()){let p=e.getJointPose(x,n),f=this._getHandJoint(l,x);p!==null&&(f.matrix.fromArray(p.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=p.radius),f.visible=p!==null}let h=l.joints["index-finger-tip"],d=l.joints["thumb-tip"],u=h.position.distanceTo(d.position),m=.02,g=.005;l.inputState.pinching&&u>m+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&u<=m-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1));o!==null&&(s=e.getPose(t.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Hp)))}return o!==null&&(o.visible=s!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let n=new ui;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},to=class extends ge{constructor(t,e,n,s,r,a,o,c,l,h){if(h=h!==void 0?h:On,h!==On&&h!==_i)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&h===On&&(n=xn),n===void 0&&h===_i&&(n=Fn),super(null,s,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=o!==void 0?o:pe,this.minFilter=c!==void 0?c:pe,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}},eo=class extends bn{constructor(t,e){super();let n=this,s=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,d=null,u=null,m=null,g=null,x=e.getContextAttributes(),p=null,f=null,v=[],_=[],b=new Re;b.layers.enable(1),b.viewport=new jt;let S=new Re;S.layers.enable(2),S.viewport=new jt;let T=[b,S],A=new jr;A.layers.enable(1),A.layers.enable(2);let L=null,y=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(B){let Z=v[B];return Z===void 0&&(Z=new ki,v[B]=Z),Z.getTargetRaySpace()},this.getControllerGrip=function(B){let Z=v[B];return Z===void 0&&(Z=new ki,v[B]=Z),Z.getGripSpace()},this.getHand=function(B){let Z=v[B];return Z===void 0&&(Z=new ki,v[B]=Z),Z.getHandSpace()};function w(B){let Z=_.indexOf(B.inputSource);if(Z===-1)return;let ot=v[Z];ot!==void 0&&(ot.update(B.inputSource,B.frame,l||a),ot.dispatchEvent({type:B.type,data:B.inputSource}))}function z(){s.removeEventListener("select",w),s.removeEventListener("selectstart",w),s.removeEventListener("selectend",w),s.removeEventListener("squeeze",w),s.removeEventListener("squeezestart",w),s.removeEventListener("squeezeend",w),s.removeEventListener("end",z),s.removeEventListener("inputsourceschange",Y);for(let B=0;B=0&&(_[at]=null,v[at].disconnect(ot))}for(let Z=0;Z=_.length){_.push(ot),at=_t;break}else if(_[_t]===null){_[_t]=ot,at=_t;break}if(at===-1)break}let ct=v[at];ct&&ct.connect(ot)}}let I=new P,D=new P;function O(B,Z,ot){I.setFromMatrixPosition(Z.matrixWorld),D.setFromMatrixPosition(ot.matrixWorld);let at=I.distanceTo(D),ct=Z.projectionMatrix.elements,_t=ot.projectionMatrix.elements,Et=ct[14]/(ct[10]-1),xt=ct[14]/(ct[10]+1),zt=(ct[9]+1)/ct[5],xe=(ct[9]-1)/ct[5],Pt=(ct[8]-1)/ct[0],F=(_t[8]+1)/_t[0],oe=Et*Pt,yt=Et*F,Tt=at/(-Pt+F),bt=Tt*-Pt;Z.matrixWorld.decompose(B.position,B.quaternion,B.scale),B.translateX(bt),B.translateZ(Tt),B.matrixWorld.compose(B.position,B.quaternion,B.scale),B.matrixWorldInverse.copy(B.matrixWorld).invert();let Xt=Et+Tt,Ft=xt+Tt,Lt=oe-bt,Vt=yt+(at-bt),re=zt*xt/Ft*Xt,ae=xe*xt/Ft*Xt;B.projectionMatrix.makePerspective(Lt,Vt,re,ae,Xt,Ft),B.projectionMatrixInverse.copy(B.projectionMatrix).invert()}function $(B,Z){Z===null?B.matrixWorld.copy(B.matrix):B.matrixWorld.multiplyMatrices(Z.matrixWorld,B.matrix),B.matrixWorldInverse.copy(B.matrixWorld).invert()}this.updateCamera=function(B){if(s===null)return;A.near=S.near=b.near=B.near,A.far=S.far=b.far=B.far,(L!==A.near||y!==A.far)&&(s.updateRenderState({depthNear:A.near,depthFar:A.far}),L=A.near,y=A.far);let Z=B.parent,ot=A.cameras;$(A,Z);for(let at=0;at0&&(p.alphaTest.value=f.alphaTest);let v=t.get(f).envMap;if(v&&(p.envMap.value=v,p.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,p.reflectivity.value=f.reflectivity,p.ior.value=f.ior,p.refractionRatio.value=f.refractionRatio),f.lightMap){p.lightMap.value=f.lightMap;let _=i._useLegacyLights===!0?Math.PI:1;p.lightMapIntensity.value=f.lightMapIntensity*_,e(f.lightMap,p.lightMapTransform)}f.aoMap&&(p.aoMap.value=f.aoMap,p.aoMapIntensity.value=f.aoMapIntensity,e(f.aoMap,p.aoMapTransform))}function a(p,f){p.diffuse.value.copy(f.color),p.opacity.value=f.opacity,f.map&&(p.map.value=f.map,e(f.map,p.mapTransform))}function o(p,f){p.dashSize.value=f.dashSize,p.totalSize.value=f.dashSize+f.gapSize,p.scale.value=f.scale}function c(p,f,v,_){p.diffuse.value.copy(f.color),p.opacity.value=f.opacity,p.size.value=f.size*v,p.scale.value=_*.5,f.map&&(p.map.value=f.map,e(f.map,p.uvTransform)),f.alphaMap&&(p.alphaMap.value=f.alphaMap,e(f.alphaMap,p.alphaMapTransform)),f.alphaTest>0&&(p.alphaTest.value=f.alphaTest)}function l(p,f){p.diffuse.value.copy(f.color),p.opacity.value=f.opacity,p.rotation.value=f.rotation,f.map&&(p.map.value=f.map,e(f.map,p.mapTransform)),f.alphaMap&&(p.alphaMap.value=f.alphaMap,e(f.alphaMap,p.alphaMapTransform)),f.alphaTest>0&&(p.alphaTest.value=f.alphaTest)}function h(p,f){p.specular.value.copy(f.specular),p.shininess.value=Math.max(f.shininess,1e-4)}function d(p,f){f.gradientMap&&(p.gradientMap.value=f.gradientMap)}function u(p,f){p.metalness.value=f.metalness,f.metalnessMap&&(p.metalnessMap.value=f.metalnessMap,e(f.metalnessMap,p.metalnessMapTransform)),p.roughness.value=f.roughness,f.roughnessMap&&(p.roughnessMap.value=f.roughnessMap,e(f.roughnessMap,p.roughnessMapTransform)),t.get(f).envMap&&(p.envMapIntensity.value=f.envMapIntensity)}function m(p,f,v){p.ior.value=f.ior,f.sheen>0&&(p.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),p.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(p.sheenColorMap.value=f.sheenColorMap,e(f.sheenColorMap,p.sheenColorMapTransform)),f.sheenRoughnessMap&&(p.sheenRoughnessMap.value=f.sheenRoughnessMap,e(f.sheenRoughnessMap,p.sheenRoughnessMapTransform))),f.clearcoat>0&&(p.clearcoat.value=f.clearcoat,p.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(p.clearcoatMap.value=f.clearcoatMap,e(f.clearcoatMap,p.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,e(f.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(p.clearcoatNormalMap.value=f.clearcoatNormalMap,e(f.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===he&&p.clearcoatNormalScale.value.negate())),f.iridescence>0&&(p.iridescence.value=f.iridescence,p.iridescenceIOR.value=f.iridescenceIOR,p.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(p.iridescenceMap.value=f.iridescenceMap,e(f.iridescenceMap,p.iridescenceMapTransform)),f.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=f.iridescenceThicknessMap,e(f.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),f.transmission>0&&(p.transmission.value=f.transmission,p.transmissionSamplerMap.value=v.texture,p.transmissionSamplerSize.value.set(v.width,v.height),f.transmissionMap&&(p.transmissionMap.value=f.transmissionMap,e(f.transmissionMap,p.transmissionMapTransform)),p.thickness.value=f.thickness,f.thicknessMap&&(p.thicknessMap.value=f.thicknessMap,e(f.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=f.attenuationDistance,p.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(p.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(p.anisotropyMap.value=f.anisotropyMap,e(f.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=f.specularIntensity,p.specularColor.value.copy(f.specularColor),f.specularColorMap&&(p.specularColorMap.value=f.specularColorMap,e(f.specularColorMap,p.specularColorMapTransform)),f.specularIntensityMap&&(p.specularIntensityMap.value=f.specularIntensityMap,e(f.specularIntensityMap,p.specularIntensityMapTransform))}function g(p,f){f.matcap&&(p.matcap.value=f.matcap)}function x(p,f){let v=t.get(f).light;p.referencePosition.value.setFromMatrixPosition(v.matrixWorld),p.nearDistance.value=v.shadow.camera.near,p.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function Wp(i,t,e,n){let s={},r={},a=[],o=e.isWebGL2?i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(v,_){let b=_.program;n.uniformBlockBinding(v,b)}function l(v,_){let b=s[v.id];b===void 0&&(g(v),b=h(v),s[v.id]=b,v.addEventListener("dispose",p));let S=_.program;n.updateUBOMapping(v,S);let T=t.render.frame;r[v.id]!==T&&(u(v),r[v.id]=T)}function h(v){let _=d();v.__bindingPointIndex=_;let b=i.createBuffer(),S=v.__size,T=v.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,S,T),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,_,b),b}function d(){for(let v=0;v0){T=b%S;let Y=S-T;T!==0&&Y-w.boundary<0&&(b+=S-T,y.__offset=b)}b+=w.storage}return T=b%S,T>0&&(b+=S-T),v.__size=b,v.__cache={},this}function x(v){let _={boundary:0,storage:0};return typeof v=="number"?(_.boundary=4,_.storage=4):v.isVector2?(_.boundary=8,_.storage=8):v.isVector3||v.isColor?(_.boundary=16,_.storage=12):v.isVector4?(_.boundary=16,_.storage=16):v.isMatrix3?(_.boundary=48,_.storage=48):v.isMatrix4?(_.boundary=64,_.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),_}function p(v){let _=v.target;_.removeEventListener("dispose",p);let b=a.indexOf(_.__bindingPointIndex);a.splice(b,1),i.deleteBuffer(s[_.id]),delete s[_.id],delete r[_.id]}function f(){for(let v in s)i.deleteBuffer(s[v]);a=[],s={},r={}}return{bind:c,update:l,dispose:f}}function Xp(){let i=ws("canvas");return i.style.display="block",i}var no=class{constructor(t={}){let{canvas:e=Xp(),context:n=null,depth:s=!0,stencil:r=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:d=!1}=t;this.isWebGLRenderer=!0;let u;n!==null?u=n.getContextAttributes().alpha:u=a;let m=new Uint32Array(4),g=new Int32Array(4),x=null,p=null,f=[],v=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputColorSpace=Rt,this._useLegacyLights=!1,this.toneMapping=Mn,this.toneMappingExposure=1;let _=this,b=!1,S=0,T=0,A=null,L=-1,y=null,w=new jt,z=new jt,Y=null,I=new kt(0),D=0,O=e.width,$=e.height,G=1,q=null,J=null,K=new jt(0,0,O,$),B=new jt(0,0,O,$),Z=!1,ot=new Fs,at=!1,ct=!1,_t=null,Et=new Gt,xt=new Nt,zt=new P,xe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Pt(){return A===null?G:1}let F=n;function oe(E,N){for(let X=0;X0?p=v[v.length-1]:p=null,f.pop(),f.length>0?x=f[f.length-1]:x=null};function Uo(E,N,X,U){if(E.visible===!1)return;if(E.layers.test(N.layers)){if(E.isGroup)X=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(N);else if(E.isLight)p.pushLight(E),E.castShadow&&p.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||ot.intersectsSprite(E)){U&&zt.setFromMatrixPosition(E.matrixWorld).applyMatrix4(Et);let gt=M.update(E),Mt=E.material;Mt.visible&&x.push(E,gt,Mt,X,zt.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||ot.intersectsObject(E))){let gt=M.update(E),Mt=E.material;if(U&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),zt.copy(E.boundingSphere.center)):(gt.boundingSphere===null&>.computeBoundingSphere(),zt.copy(gt.boundingSphere.center)),zt.applyMatrix4(E.matrixWorld).applyMatrix4(Et)),Array.isArray(Mt)){let St=gt.groups;for(let Ut=0,vt=St.length;Ut0&&Wc(W,lt,N,X),U&&bt.viewport(w.copy(U)),W.length>0&&Qi(W,N,X),lt.length>0&&Qi(lt,N,X),gt.length>0&&Qi(gt,N,X),bt.buffers.depth.setTest(!0),bt.buffers.depth.setMask(!0),bt.buffers.color.setMask(!0),bt.setPolygonOffset(!1)}function Wc(E,N,X,U){let W=Tt.isWebGL2;_t===null&&(_t=new cn(1,1,{generateMipmaps:!0,type:yt.has("EXT_color_buffer_half_float")?Gi:Sn,minFilter:Hi,samples:W?4:0})),_.getDrawingBufferSize(xt),W?_t.setSize(xt.x,xt.y):_t.setSize(Br(xt.x),Br(xt.y));let lt=_.getRenderTarget();_.setRenderTarget(_t),_.getClearColor(I),D=_.getClearAlpha(),D<1&&_.setClearColor(16777215,.5),_.clear();let gt=_.toneMapping;_.toneMapping=Mn,Qi(E,X,U),Lt.updateMultisampleRenderTarget(_t),Lt.updateRenderTargetMipmap(_t);let Mt=!1;for(let St=0,Ut=N.length;St0),wt=!!X.morphAttributes.position,Yt=!!X.morphAttributes.normal,Zt=!!X.morphAttributes.color,Pe=Mn;U.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(Pe=_.toneMapping);let Ke=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,$t=Ke!==void 0?Ke.length:0,Dt=Ft.get(U),Ks=p.state.lights;if(at===!0&&(ct===!0||E!==y)){let Te=E===y&&U.id===L;ft.setState(U,E,Te)}let Kt=!1;U.version===Dt.__version?(Dt.needsLights&&Dt.lightsStateVersion!==Ks.state.version||Dt.outputColorSpace!==Mt||W.isInstancedMesh&&Dt.instancing===!1||!W.isInstancedMesh&&Dt.instancing===!0||W.isSkinnedMesh&&Dt.skinning===!1||!W.isSkinnedMesh&&Dt.skinning===!0||W.isInstancedMesh&&Dt.instancingColor===!0&&W.instanceColor===null||W.isInstancedMesh&&Dt.instancingColor===!1&&W.instanceColor!==null||Dt.envMap!==St||U.fog===!0&&Dt.fog!==lt||Dt.numClippingPlanes!==void 0&&(Dt.numClippingPlanes!==ft.numPlanes||Dt.numIntersection!==ft.numIntersection)||Dt.vertexAlphas!==Ut||Dt.vertexTangents!==vt||Dt.morphTargets!==wt||Dt.morphNormals!==Yt||Dt.morphColors!==Zt||Dt.toneMapping!==Pe||Tt.isWebGL2===!0&&Dt.morphTargetsCount!==$t)&&(Kt=!0):(Kt=!0,Dt.__version=U.version);let Rn=Dt.currentProgram;Kt===!0&&(Rn=ji(U,N,W));let Oo=!1,Ui=!1,Qs=!1,fe=Rn.getUniforms(),Cn=Dt.uniforms;if(bt.useProgram(Rn.program)&&(Oo=!0,Ui=!0,Qs=!0),U.id!==L&&(L=U.id,Ui=!0),Oo||y!==E){if(fe.setValue(F,"projectionMatrix",E.projectionMatrix),Tt.logarithmicDepthBuffer&&fe.setValue(F,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),y!==E&&(y=E,Ui=!0,Qs=!0),U.isShaderMaterial||U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshStandardMaterial||U.envMap){let Te=fe.map.cameraPosition;Te!==void 0&&Te.setValue(F,zt.setFromMatrixPosition(E.matrixWorld))}(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial)&&fe.setValue(F,"isOrthographic",E.isOrthographicCamera===!0),(U.isMeshPhongMaterial||U.isMeshToonMaterial||U.isMeshLambertMaterial||U.isMeshBasicMaterial||U.isMeshStandardMaterial||U.isShaderMaterial||U.isShadowMaterial||W.isSkinnedMesh)&&fe.setValue(F,"viewMatrix",E.matrixWorldInverse)}if(W.isSkinnedMesh){fe.setOptional(F,W,"bindMatrix"),fe.setOptional(F,W,"bindMatrixInverse");let Te=W.skeleton;Te&&(Tt.floatVertexTextures?(Te.boneTexture===null&&Te.computeBoneTexture(),fe.setValue(F,"boneTexture",Te.boneTexture,Lt),fe.setValue(F,"boneTextureSize",Te.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let js=X.morphAttributes;if((js.position!==void 0||js.normal!==void 0||js.color!==void 0&&Tt.isWebGL2===!0)&&mt.update(W,X,Rn),(Ui||Dt.receiveShadow!==W.receiveShadow)&&(Dt.receiveShadow=W.receiveShadow,fe.setValue(F,"receiveShadow",W.receiveShadow)),U.isMeshGouraudMaterial&&U.envMap!==null&&(Cn.envMap.value=St,Cn.flipEnvMap.value=St.isCubeTexture&&St.isRenderTargetTexture===!1?-1:1),Ui&&(fe.setValue(F,"toneMappingExposure",_.toneMappingExposure),Dt.needsLights&&qc(Cn,Qs),lt&&U.fog===!0&&j.refreshFogUniforms(Cn,lt),j.refreshMaterialUniforms(Cn,U,G,$,_t),pi.upload(F,Dt.uniformsList,Cn,Lt)),U.isShaderMaterial&&U.uniformsNeedUpdate===!0&&(pi.upload(F,Dt.uniformsList,Cn,Lt),U.uniformsNeedUpdate=!1),U.isSpriteMaterial&&fe.setValue(F,"center",W.center),fe.setValue(F,"modelViewMatrix",W.modelViewMatrix),fe.setValue(F,"normalMatrix",W.normalMatrix),fe.setValue(F,"modelMatrix",W.matrixWorld),U.isShaderMaterial||U.isRawShaderMaterial){let Te=U.uniformsGroups;for(let tr=0,Zc=Te.length;tr0&&Lt.useMultisampledRTT(E)===!1?W=Ft.get(E).__webglMultisampledFramebuffer:Array.isArray(vt)?W=vt[X]:W=vt,w.copy(E.viewport),z.copy(E.scissor),Y=E.scissorTest}else w.copy(K).multiplyScalar(G).floor(),z.copy(B).multiplyScalar(G).floor(),Y=Z;if(bt.bindFramebuffer(F.FRAMEBUFFER,W)&&Tt.drawBuffers&&U&&bt.drawBuffers(E,W),bt.viewport(w),bt.scissor(z),bt.setScissorTest(Y),lt){let St=Ft.get(E.texture);F.framebufferTexture2D(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,F.TEXTURE_CUBE_MAP_POSITIVE_X+N,St.__webglTexture,X)}else if(gt){let St=Ft.get(E.texture),Ut=N||0;F.framebufferTextureLayer(F.FRAMEBUFFER,F.COLOR_ATTACHMENT0,St.__webglTexture,X||0,Ut)}L=-1},this.readRenderTargetPixels=function(E,N,X,U,W,lt,gt){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Mt=Ft.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&>!==void 0&&(Mt=Mt[gt]),Mt){bt.bindFramebuffer(F.FRAMEBUFFER,Mt);try{let St=E.texture,Ut=St.format,vt=St.type;if(Ut!==ke&&ht.convert(Ut)!==F.getParameter(F.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let wt=vt===Gi&&(yt.has("EXT_color_buffer_half_float")||Tt.isWebGL2&&yt.has("EXT_color_buffer_float"));if(vt!==Sn&&ht.convert(vt)!==F.getParameter(F.IMPLEMENTATION_COLOR_READ_TYPE)&&!(vt===yn&&(Tt.isWebGL2||yt.has("OES_texture_float")||yt.has("WEBGL_color_buffer_float")))&&!wt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=E.width-U&&X>=0&&X<=E.height-W&&F.readPixels(N,X,U,W,ht.convert(Ut),ht.convert(vt),lt)}finally{let St=A!==null?Ft.get(A).__webglFramebuffer:null;bt.bindFramebuffer(F.FRAMEBUFFER,St)}}},this.copyFramebufferToTexture=function(E,N,X=0){let U=Math.pow(2,-X),W=Math.floor(N.image.width*U),lt=Math.floor(N.image.height*U);Lt.setTexture2D(N,0),F.copyTexSubImage2D(F.TEXTURE_2D,X,0,0,E.x,E.y,W,lt),bt.unbindTexture()},this.copyTextureToTexture=function(E,N,X,U=0){let W=N.image.width,lt=N.image.height,gt=ht.convert(X.format),Mt=ht.convert(X.type);Lt.setTexture2D(X,0),F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,X.flipY),F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,X.premultiplyAlpha),F.pixelStorei(F.UNPACK_ALIGNMENT,X.unpackAlignment),N.isDataTexture?F.texSubImage2D(F.TEXTURE_2D,U,E.x,E.y,W,lt,gt,Mt,N.image.data):N.isCompressedTexture?F.compressedTexSubImage2D(F.TEXTURE_2D,U,E.x,E.y,N.mipmaps[0].width,N.mipmaps[0].height,gt,N.mipmaps[0].data):F.texSubImage2D(F.TEXTURE_2D,U,E.x,E.y,gt,Mt,N.image),U===0&&X.generateMipmaps&&F.generateMipmap(F.TEXTURE_2D),bt.unbindTexture()},this.copyTextureToTexture3D=function(E,N,X,U,W=0){if(_.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let lt=E.max.x-E.min.x+1,gt=E.max.y-E.min.y+1,Mt=E.max.z-E.min.z+1,St=ht.convert(U.format),Ut=ht.convert(U.type),vt;if(U.isData3DTexture)Lt.setTexture3D(U,0),vt=F.TEXTURE_3D;else if(U.isDataArrayTexture)Lt.setTexture2DArray(U,0),vt=F.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}F.pixelStorei(F.UNPACK_FLIP_Y_WEBGL,U.flipY),F.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),F.pixelStorei(F.UNPACK_ALIGNMENT,U.unpackAlignment);let wt=F.getParameter(F.UNPACK_ROW_LENGTH),Yt=F.getParameter(F.UNPACK_IMAGE_HEIGHT),Zt=F.getParameter(F.UNPACK_SKIP_PIXELS),Pe=F.getParameter(F.UNPACK_SKIP_ROWS),Ke=F.getParameter(F.UNPACK_SKIP_IMAGES),$t=X.isCompressedTexture?X.mipmaps[0]:X.image;F.pixelStorei(F.UNPACK_ROW_LENGTH,$t.width),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,$t.height),F.pixelStorei(F.UNPACK_SKIP_PIXELS,E.min.x),F.pixelStorei(F.UNPACK_SKIP_ROWS,E.min.y),F.pixelStorei(F.UNPACK_SKIP_IMAGES,E.min.z),X.isDataTexture||X.isData3DTexture?F.texSubImage3D(vt,W,N.x,N.y,N.z,lt,gt,Mt,St,Ut,$t.data):X.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),F.compressedTexSubImage3D(vt,W,N.x,N.y,N.z,lt,gt,Mt,St,$t.data)):F.texSubImage3D(vt,W,N.x,N.y,N.z,lt,gt,Mt,St,Ut,$t),F.pixelStorei(F.UNPACK_ROW_LENGTH,wt),F.pixelStorei(F.UNPACK_IMAGE_HEIGHT,Yt),F.pixelStorei(F.UNPACK_SKIP_PIXELS,Zt),F.pixelStorei(F.UNPACK_SKIP_ROWS,Pe),F.pixelStorei(F.UNPACK_SKIP_IMAGES,Ke),W===0&&U.generateMipmaps&&F.generateMipmap(vt),bt.unbindTexture()},this.initTexture=function(E){E.isCubeTexture?Lt.setTextureCube(E,0):E.isData3DTexture?Lt.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?Lt.setTexture2DArray(E,0):Lt.setTexture2D(E,0),bt.unbindTexture()},this.resetState=function(){S=0,T=0,A=null,bt.reset(),ut.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return on}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(t){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!t}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Rt?Bn:xc}set outputEncoding(t){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=t===Bn?Rt:Ze}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(t){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=t}},io=class extends no{};io.prototype.isWebGL1Renderer=!0;function _n(i,t,e){return Rc(i)?new i.constructor(i.subarray(t,e!==void 0?e:i.length)):i.slice(t,e)}function Ms(i,t,e){return!i||!e&&i.constructor===t?i:typeof t.BYTES_PER_ELEMENT=="number"?new t(i):Array.prototype.slice.call(i)}function Rc(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}var Mi=class{constructor(t,e,n,s){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=s!==void 0?s:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,n=this._cachedIndex,s=e[n],r=e[n-1];n:{t:{let a;e:{i:if(!(t=r)){let o=e[1];t=r)break t}a=n,n=0;break e}break n}for(;n>>1;te;)--a;if(++a,r!==0||a!==s){r>=a&&(a=Math.max(a,1),r=a-1);let o=this.getValueSize();this.times=_n(n,r,a),this.values=_n(this.values,r*o,a*o)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let n=this.times,s=this.values,r=n.length;r===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==r;o++){let c=n[o];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,c),t=!1;break}if(a!==null&&a>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,c,a),t=!1;break}a=c}if(s!==void 0&&Rc(s))for(let o=0,c=s.length;o!==c;++o){let l=s[o];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}return t}optimize(){let t=_n(this.times),e=_n(this.values),n=this.getValueSize(),s=this.getInterpolation()===ar,r=t.length-1,a=1;for(let o=1;o0){t[a]=t[r];for(let o=r*n,c=a*n,l=0;l!==n;++l)e[c+l]=e[o+l];++a}return a!==t.length?(this.times=_n(t,0,a),this.values=_n(e,0,a*n)):(this.times=t,this.values=e),this}clone(){let t=_n(this.times,0),e=_n(this.values,0),n=this.constructor,s=new n(this.name,t,e);return s.createInterpolant=this.createInterpolant,s}};We.prototype.TimeBufferType=Float32Array;We.prototype.ValueBufferType=Float32Array;We.prototype.DefaultInterpolation=Es;var Hn=class extends We{};Hn.prototype.ValueTypeName="bool";Hn.prototype.ValueBufferType=Array;Hn.prototype.DefaultInterpolation=bs;Hn.prototype.InterpolantFactoryMethodLinear=void 0;Hn.prototype.InterpolantFactoryMethodSmooth=void 0;var ao=class extends We{};ao.prototype.ValueTypeName="color";var co=class extends We{};co.prototype.ValueTypeName="number";var lo=class extends Mi{constructor(t,e,n,s){super(t,e,n,s)}interpolate_(t,e,n,s){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-e)/(s-e),l=t*o;for(let h=l+o;l!==h;l+=4)En.slerpFlat(r,0,a,l-o,a,l,c);return r}},Xi=class extends We{InterpolantFactoryMethodLinear(t){return new lo(this.times,this.values,this.getValueSize(),t)}};Xi.prototype.ValueTypeName="quaternion";Xi.prototype.DefaultInterpolation=Es;Xi.prototype.InterpolantFactoryMethodSmooth=void 0;var Gn=class extends We{};Gn.prototype.ValueTypeName="string";Gn.prototype.ValueBufferType=Array;Gn.prototype.DefaultInterpolation=bs;Gn.prototype.InterpolantFactoryMethodLinear=void 0;Gn.prototype.InterpolantFactoryMethodSmooth=void 0;var ho=class extends We{};ho.prototype.ValueTypeName="vector";var uo=class{constructor(t,e,n){let s=this,r=!1,a=0,o=0,c,l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(h){o++,r===!1&&s.onStart!==void 0&&s.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,s.onProgress!==void 0&&s.onProgress(h,a,o),a===o&&(r=!1,s.onLoad!==void 0&&s.onLoad())},this.itemError=function(h){s.onError!==void 0&&s.onError(h)},this.resolveURL=function(h){return c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,d){return l.push(h,d),this},this.removeHandler=function(h){let d=l.indexOf(h);return d!==-1&&l.splice(d,2),this},this.getHandler=function(h){for(let d=0,u=l.length;de&&(e=s,t=n)}return t}function Mo(i,t){t.set(i)}function So(i,t,e){let n,s;for(let r=0;r<3;r++){let a=r+3;n=i[r],s=t[r],e[r]=ns?n:s}}function Yi(i,t,e){for(let n=0;n<3;n++){let s=t[i+2*n],r=t[i+2*n+1],a=s-r,o=s+r;ae[n+3]&&(e[n+3]=o)}}function bi(i){let t=i[3]-i[0],e=i[4]-i[1],n=i[5]-i[2];return 2*(t*e+e*n+n*t)}function im(i,t){if(!i.index){let e=i.attributes.position.count,n=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s;e>65535?s=new Uint32Array(new n(4*e)):s=new Uint16Array(new n(2*e)),i.setIndex(new te(s,1));for(let r=0;rs-r);for(let s=0;sc&&(c=A),f&&bg&&(g=b);let L=i[v+2],y=i[v+3],w=L-y,z=L+y;wl&&(l=z),f&&Lx&&(x=L);let Y=i[v+4],I=i[v+5],D=Y-I,O=Y+I;Dh&&(h=O),f&&Yp&&(p=Y)}n[0]=r,n[1]=a,n[2]=o,n[3]=c,n[4]=l,n[5]=h,f&&(s[0]=d,s[1]=u,s[2]=m,s[3]=g,s[4]=x,s[5]=p)}function rm(i,t,e,n){let s=1/0,r=1/0,a=1/0,o=-1/0,c=-1/0,l=-1/0;for(let h=t*6,d=(t+e)*6;ho&&(o=u);let m=i[h+2];mc&&(c=m);let g=i[h+4];gl&&(l=g)}n[0]=s,n[1]=r,n[2]=a,n[3]=o,n[4]=c,n[5]=l}function om(i,t,e,n,s){let r=e,a=e+n-1,o=s.pos,c=s.axis*2;for(;;){for(;r<=a&&t[r*6+c]=o;)a--;if(ri.candidate-t.candidate,Tn=new Array(hn).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Vs=new Float32Array(6);function cm(i,t,e,n,s,r){let a=-1,o=0;if(r===0)a=vo(t),a!==-1&&(o=(t[a]+t[a+3])/2);else if(r===1)a=vo(i),a!==-1&&(o=lm(e,n,s,a));else if(r===2){let c=bi(i),l=1.25*s,h=n*6,d=(n+s)*6;for(let u=0;u<3;u++){let m=t[u],p=(t[u+3]-m)/hn;if(s=A.candidate?Yi(b,e,A.rightCacheBounds):(Yi(b,e,A.leftCacheBounds),A.count++)}}for(let b=0;b<_;b++){let S=f[b],T=S.count,A=s-S.count,L=S.leftCacheBounds,y=S.rightCacheBounds,w=0;T!==0&&(w=bi(L)/c);let z=0;A!==0&&(z=bi(y)/c);let Y=1+1.25*(w*T+z*A);Y=hn&&(T=hn-1);let A=Tn[T];A.count++,Yi(_,e,A.bounds)}let f=Tn[hn-1];Mo(f.bounds,f.rightCacheBounds);for(let _=hn-2;_>=0;_--){let b=Tn[_],S=Tn[_+1];So(b.bounds,S.rightCacheBounds,b.rightCacheBounds)}let v=0;for(let _=0;_T&&(T=_),b>T&&(T=b);let A=(T-S)/2,L=f*2;r[m+L+0]=S+A,r[m+L+1]=A+(Math.abs(S)+A)*Cc,St[f+3]&&(t[f+3]=T)}}return r}function um(i,t){function e(f){u&&u(f/m)}function n(f,v,_,b=null,S=0){if(!g&&S>=c&&(g=!0,l&&(console.warn(`MeshBVH: Max depth of ${c} reached when generating BVH. Consider increasing maxDepth.`),console.warn(i))),_<=h||S>=c)return e(v+_),f.offset=v,f.count=_,f;let T=cm(f.boundingData,b,a,v,_,d);if(T.axis===-1)return e(v+_),f.offset=v,f.count=_,f;let A=om(o,a,v,_,T);if(A===v||A===v+_)e(v+_),f.offset=v,f.count=_;else{f.splitAxis=T.axis;let L=new Wn,y=v,w=A-v;f.left=L,L.boundingData=new Float32Array(6),Eo(a,y,w,L.boundingData,r),n(L,y,w,r,S+1);let z=new Wn,Y=A,I=_-w;f.right=z,z.boundingData=new Float32Array(6),Eo(a,Y,I,z.boundingData,r),n(z,Y,I,r,S+1)}return f}im(i,t);let s=new Float32Array(6),r=new Float32Array(6),a=hm(i,s),o=i.index.array,c=t.maxDepth,l=t.verbose,h=t.maxLeafTris,d=t.strategy,u=t.onProgress,m=i.index.count/3,g=!1,x=[],p=sm(i);if(p.length===1){let f=p[0],v=new Wn;v.boundingData=s,rm(a,f.offset,f.count,r),n(v,f.offset,f.count,r),x.push(v)}else for(let f of p){let v=new Wn;v.boundingData=new Float32Array(6),Eo(a,f.offset,f.count,v.boundingData,r),n(v,f.offset,f.count,r),x.push(v)}return x}function Ic(i,t){let e=um(i,t),n,s,r,a=[],o=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let h=0;hMath.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return s[u+6]=_/4,_=l(_,f),s[u+7]=v,_}}}var Se=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let n=1/0,s=-1/0;for(let r=0,a=t.length;rs?c:s}this.min=n,this.max=s}setFromPoints(t,e){let n=1/0,s=-1/0;for(let r=0,a=e.length;rs?c:s}this.min=n,this.max=s}isSeparated(t){return this.min>t.max||t.min>this.max}};Se.prototype.setFromBox=function(){let i=new P;return function(e,n){let s=n.min,r=n.max,a=1/0,o=-1/0;for(let c=0;c<=1;c++)for(let l=0;l<=1;l++)for(let h=0;h<=1;h++){i.x=s.x*c+r.x*(1-c),i.y=s.y*l+r.y*(1-l),i.z=s.z*h+r.z*(1-h);let d=e.dot(i);a=Math.min(d,a),o=Math.max(d,o)}this.min=a,this.max=o}}();var Um=function(){let i=new Se;return function(e,n){let s=e.points,r=e.satAxes,a=e.satBounds,o=n.points,c=n.satAxes,l=n.satBounds;for(let h=0;h<3;h++){let d=a[h],u=r[h];if(i.setFromPoints(u,o),d.isSeparated(i))return!1}for(let h=0;h<3;h++){let d=l[h],u=c[h];if(i.setFromPoints(u,s),d.isSeparated(i))return!1}}}();var fm=function(){let i=new P,t=new P,e=new P;return function(s,r,a){let o=s.start,c=i,l=r.start,h=t;e.subVectors(o,l),i.subVectors(s.end,s.start),t.subVectors(r.end,r.start);let d=e.dot(h),u=h.dot(c),m=h.dot(h),g=e.dot(c),p=c.dot(c)*m-u*u,f,v;p!==0?f=(d*u-g*m)/p:f=0,v=(d+f*u)/m,a.x=f,a.y=v}}(),Zi=function(){let i=new Nt,t=new P,e=new P;return function(s,r,a,o){fm(s,r,i);let c=i.x,l=i.y;if(c>=0&&c<=1&&l>=0&&l<=1){s.at(c,a),r.at(l,o);return}else if(c>=0&&c<=1){l<0?r.at(0,o):r.at(1,o),s.closestPointToPoint(o,!0,a);return}else if(l>=0&&l<=1){c<0?s.at(0,a):s.at(1,a),r.closestPointToPoint(a,!0,o);return}else{let h;c<0?h=s.start:h=s.end;let d;l<0?d=r.start:d=r.end;let u=t,m=e;if(s.closestPointToPoint(d,!0,t),r.closestPointToPoint(h,!0,e),u.distanceToSquared(d)<=m.distanceToSquared(h)){a.copy(u),o.copy(d);return}else{a.copy(h),o.copy(m);return}}}}(),Uc=function(){let i=new P,t=new P,e=new Ce,n=new Me;return function(r,a){let{radius:o,center:c}=r,{a:l,b:h,c:d}=a;if(n.start=l,n.end=h,n.closestPointToPoint(c,!0,i).distanceTo(c)<=o||(n.start=l,n.end=d,n.closestPointToPoint(c,!0,i).distanceTo(c)<=o)||(n.start=h,n.end=d,n.closestPointToPoint(c,!0,i).distanceTo(c)<=o))return!0;let x=a.getPlane(e);if(Math.abs(x.distanceToPoint(c))<=o){let f=x.projectPoint(c,t);if(a.containsPoint(f))return!0}return!1}}();var dm=1e-15;function Ei(i){return Math.abs(i)new P),this.satBounds=new Array(4).fill().map(()=>new Se),this.points=[this.a,this.b,this.c],this.sphere=new Vn,this.plane=new Ce,this.needsUpdate=!0}intersectsSphere(t){return Uc(t,this)}update(){let t=this.a,e=this.b,n=this.c,s=this.points,r=this.satAxes,a=this.satBounds,o=r[0],c=a[0];this.getNormal(o),c.setFromPoints(o,s);let l=r[1],h=a[1];l.subVectors(t,e),h.setFromPoints(l,s);let d=r[2],u=a[2];d.subVectors(e,n),u.setFromPoints(d,s);let m=r[3],g=a[3];m.subVectors(n,t),g.setFromPoints(m,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(o,t),this.needsUpdate=!1}};be.prototype.closestPointToSegment=function(){let i=new P,t=new P,e=new Me;return function(s,r=null,a=null){let{start:o,end:c}=s,l=this.points,h,d=1/0;for(let u=0;u<3;u++){let m=(u+1)%3;e.start.copy(l[u]),e.end.copy(l[m]),Zi(e,s,i,t),h=i.distanceToSquared(t),h1-1e-10){let v=this.satBounds,_=this.satAxes;e[0]=m.a,e[1]=m.b,e[2]=m.c;for(let T=0;T<4;T++){let A=v[T],L=_[T];if(n.setFromPoints(L,e),A.isSeparated(n))return!1}let b=m.satBounds,S=m.satAxes;t[0]=this.a,t[1]=this.b,t[2]=this.c;for(let T=0;T<4;T++){let A=b[T],L=S[T];if(n.setFromPoints(L,t),A.isSeparated(n))return!1}for(let T=0;T<4;T++){let A=_[T];for(let L=0;L<4;L++){let y=S[L];if(r.crossVectors(A,y),n.setFromPoints(r,t),s.setFromPoints(r,e),n.isSeparated(s))return!1}}return g&&(x||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),g.start.set(0,0,0),g.end.set(0,0,0)),!0}else{let v=this.points,_=!1,b=0;for(let D=0;D<3;D++){let O=v[D],$=v[(D+1)%3];l.start.copy(O),l.end.copy($),l.delta(a);let G=_?h.start:h.end,q=Ei(f.distanceToPoint(O));if(Ei(f.normal.dot(a))&&q){h.copy(l),b=2;break}if((f.intersectLine(l,G)||q)&&!Ei(G.distanceTo($))){if(b++,_)break;_=!0}}if(b===1&&m.containsPoint(h.end))return g&&(g.start.copy(h.end),g.end.copy(h.end)),!0;if(b!==2)return!1;let S=m.points,T=!1,A=0;for(let D=0;D<3;D++){let O=S[D],$=S[(D+1)%3];l.start.copy(O),l.end.copy($),l.delta(o);let G=T?d.start:d.end,q=Ei(p.distanceToPoint(O));if(Ei(p.normal.dot(o))&&q){d.copy(l),A=2;break}if((p.intersectLine(l,G)||q)&&!Ei(G.distanceTo($))){if(A++,T)break;T=!0}}if(A===1&&this.containsPoint(d.end))return g&&(g.start.copy(d.end),g.end.copy(d.end)),!0;if(A!==2)return!1;if(h.delta(a),d.delta(o),a.dot(o)<0){let D=d.start;d.start=d.end,d.end=D}let L=h.start.dot(a),y=h.end.dot(a),w=d.start.dot(a),z=d.end.dot(a),Y=y0?g.start.copy(h.start):g.start.copy(d.start),c.subVectors(h.end,d.end),c.dot(a)<0?g.end.copy(h.end):g.end.copy(d.end)),!0)}}}();be.prototype.distanceToPoint=function(){let i=new P;return function(e){return this.closestPointToPoint(e,i),e.distanceTo(i)}}();be.prototype.distanceToTriangle=function(){let i=new P,t=new P,e=["a","b","c"],n=new Me,s=new Me;return function(a,o=null,c=null){let l=o||c?n:null;if(this.intersectsTriangle(a,l))return(o||c)&&(o&&l.getCenter(o),c&&l.getCenter(c)),0;let h=1/0;for(let d=0;d<3;d++){let u,m=e[d],g=a[m];this.closestPointToPoint(g,i),u=g.distanceToSquared(i),unew P),this.satAxes=new Array(3).fill().map(()=>new P),this.satBounds=new Array(3).fill().map(()=>new Se),this.alignedSatBounds=new Array(3).fill().map(()=>new Se),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),n&&this.matrix.copy(n)}set(t,e,n){this.min.copy(t),this.max.copy(e),this.matrix.copy(n),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}};Ee.prototype.update=function(){return function(){let t=this.matrix,e=this.min,n=this.max,s=this.points;for(let l=0;l<=1;l++)for(let h=0;h<=1;h++)for(let d=0;d<=1;d++){let u=1*l|2*h|4*d,m=s[u];m.x=l?n.x:e.x,m.y=h?n.y:e.y,m.z=d?n.z:e.z,m.applyMatrix4(t)}let r=this.satBounds,a=this.satAxes,o=s[0];for(let l=0;l<3;l++){let h=a[l],d=r[l],u=1<new Me),e=new Array(12).fill().map(()=>new Me),n=new P,s=new P;return function(a,o=0,c=null,l=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(c||l)&&(a.getCenter(s),this.closestPointToPoint(s,n),a.closestPointToPoint(n,s),c&&c.copy(n),l&&l.copy(s)),0;let h=o*o,d=a.min,u=a.max,m=this.points,g=1/0;for(let p=0;p<8;p++){let f=m[p];s.copy(f).clamp(d,u);let v=f.distanceToSquared(s);if(v=0,m,g;u?(m=Ai(i),g=Ri(i,o)):(m=Ri(i,o),g=Ai(i));let p=Js(m,r,n,qs)?Zs(m,t,e,n):null;if(p){let _=p.point[h];if(u?_<=r[g+l]:_>=r[g+l+3])return p}let v=Js(g,r,n,qs)?Zs(g,t,e,n):null;return p&&v?p.distance<=v.distance?p:v:p||v||null}}var kc=function(){let i,t,e=[],n=new Ti(()=>new _e);return function(...a){i=n.getPrimitive(),t=n.getPrimitive(),e.push(i,t);let o=s(...a);n.releasePrimitive(i),n.releasePrimitive(t),e.pop(),e.pop();let c=e.length;return c>0&&(t=e[c-1],i=e[c-2]),o};function s(r,a,o,c,l=null,h=0,d=0){function u(_){let b=_*2,S=wn,T=An;for(;!un(b,S);)_=Ai(_),b=_*2;return Xn(_,T)}function m(_){let b=_*2,S=wn,T=An;for(;!un(b,S);)_=Ri(_,T),b=_*2;return Xn(_,T)+wi(b,S)}let g=r*2,x=Pi,p=wn,f=An;if(un(g,p)){let _=Xn(r,f),b=wi(g,p);return Ue(r,x,i),c(_,b,!1,d,h+r,i)}else{let _=Ai(r),b=Ri(r,f),S=_,T=b,A,L,y,w;if(l&&(y=i,w=t,Ue(S,x,y),Ue(T,x,w),A=l(y),L=l(w),Ls.intersectsBox(L),intersectsTriangle:L=>{L.a.applyMatrix4(l),L.b.applyMatrix4(l),L.c.applyMatrix4(l),L.needsUpdate=!0;for(let y=S*3,w=(T+S)*3;ynew be),$e=class{static serialize(t,e={}){if(e.isBufferGeometry)return console.warn("MeshBVH.serialize: The arguments for the function have changed. See documentation for new signature."),$e.serialize(arguments[0],{cloneBuffers:arguments[2]===void 0?!0:arguments[2]});e=ts({cloneBuffers:!0},e);let n=t.geometry,s=t._roots,r=n.getIndex(),a;return e.cloneBuffers?a={roots:s.map(o=>o.slice()),index:r.array.slice()}:a={roots:s,index:r.array},a}static deserialize(t,e,n={}){if(typeof n=="boolean")return console.warn("MeshBVH.deserialize: The arguments for the function have changed. See documentation for new signature."),$e.deserialize(arguments[0],arguments[1],{setIndex:arguments[2]===void 0?!0:arguments[2]});n=ts({setIndex:!0},n);let{index:s,roots:r}=t,a=new $e(e,ko(ts({},n),{[Co]:!0}));if(a._roots=r,n.setIndex){let o=e.getIndex();if(o===null){let c=new te(t.index,1,!1);e.setIndex(c)}else o.array!==s&&(o.array.set(s),o.needsUpdate=!0)}return a}constructor(t,e={}){if(t.isBufferGeometry){if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,[Co]:!1},e),e.useSharedArrayBuffer&&typeof SharedArrayBuffer=="undefined")throw new Error("MeshBVH: SharedArrayBuffer is not available.");this._roots=null,e[Co]||(this._roots=Ic(t,e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new _e))),this.geometry=t}refit(t=null){t&&Array.isArray(t)&&(t=new Set(t));let e=this.geometry,n=e.index.array,s=e.attributes.position,r,a,o,c,l=0,h=this._roots;for(let u=0,m=h.length;uT&&(T=Y),IA&&(A=I),DL&&(L=D)}return c[u+0]!==_||c[u+1]!==b||c[u+2]!==S||c[u+3]!==T||c[u+4]!==A||c[u+5]!==L?(c[u+0]=_,c[u+1]=b,c[u+2]=S,c[u+3]=T,c[u+4]=A,c[u+5]=L,!0):!1}else{let f=u+8,v=a[u+6],_=f+m,b=v+m,S=g,T=!1,A=!1;t?S||(T=t.has(_),A=t.has(b),S=!T&&!A):(T=!0,A=!0);let L=S||T,y=S||A,w=!1;L&&(w=d(f,m,S));let z=!1;y&&(z=d(v,m,S));let Y=w||z;if(Y)for(let I=0;I<3;I++){let D=f+I,O=v+I,$=c[D],G=c[D+3],q=c[O],J=c[O+3];c[u+I]=$J?G:J}return Y}}}traverse(t,e=0){let n=this._roots[e],s=new Uint32Array(n),r=new Uint16Array(n);a(0);function a(o,c=0){let l=o*2,h=r[l+15]===65535;if(h){let d=s[o+6],u=r[l+14];t(c,h,new Float32Array(n,o*4,6),d,u)}else{let d=o+32/4,u=s[o+6],m=s[o+7];t(c,h,new Float32Array(n,o*4,6),m)||(a(d,c+1),a(u,c+1))}}}raycast(t,e=He){let n=this._roots,s=this.geometry,r=[],a=e.isMaterial,o=Array.isArray(e),c=s.groups,l=a?e.side:e;for(let h=0,d=n.length;h{let f=g*3;return u(m,f,f+1,f+2,x,p)}}t={boundsTraverseOrder:n,intersectsBounds:t,intersectsTriangle:e,intersectsRange:null},console.warn("MeshBVH: Shapecast function signature has changed and now takes an object of callbacks as a second argument. See docs for new signature.")}let r=Je.getPrimitive(),{boundsTraverseOrder:a,intersectsBounds:o,intersectsRange:c,intersectsTriangle:l}=t;if(c&&l){let u=c;c=(m,g,x,p,f)=>u(m,g,x,p,f)?!0:Ao(m,g,s,l,x,p,r)}else c||(l?c=(u,m,g,x)=>Ao(u,m,s,l,g,x,r):c=(u,m,g)=>g);let h=!1,d=0;for(let u of this._roots){if(Li(u),h=kc(0,s,o,c,a,d),Ji(),h)break;d+=u.byteLength}return Je.releasePrimitive(r),h}bvhcast(t,e,n){let{intersectsRanges:s,intersectsTriangles:r}=n,a=this.geometry.index,o=this.geometry.attributes.position,c=t.geometry.index,l=t.geometry.attributes.position;Ii.copy(e).invert();let h=Je.getPrimitive(),d=Je.getPrimitive();if(r){let m=function(g,x,p,f,v,_,b,S){for(let T=p,A=p+f;TLo.intersectsBox(m),intersectsRange:(m,g,x,p,f,v)=>(Po.copy(v),Po.applyMatrix4(Ii),t.shapecast({intersectsBounds:_=>Po.intersectsBox(_),intersectsRange:(_,b,S,T,A)=>s(m,g,_,b,p,f,T,A)}))});return Je.releasePrimitive(h),Je.releasePrimitive(d),u}intersectsBox(t,e){return qn.set(t.min,t.max,e),qn.needsUpdate=!0,this.shapecast({intersectsBounds:n=>qn.intersectsBox(n),intersectsTriangle:n=>qn.intersectsTriangle(n)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,n={},s={},r=0,a=1/0){t.boundingBox||t.computeBoundingBox(),qn.set(t.boundingBox.min,t.boundingBox.max,e),qn.needsUpdate=!0;let o=this.geometry,c=o.attributes.position,l=o.index,h=t.attributes.position,d=t.index,u=Je.getPrimitive(),m=Je.getPrimitive(),g=$s,x=xm,p=null,f=null;s&&(p=ym,f=vm);let v=1/0,_=null,b=null;return Ii.copy(e).invert(),$i.matrix.copy(Ii),this.shapecast({boundsTraverseOrder:S=>qn.distanceToBox(S),intersectsBounds:(S,T,A)=>A{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:A=>$i.distanceToBox(A),intersectsBounds:(A,L,y)=>y{for(let y=A*3,w=(A+L)*3;y(Ki.copy(t).clamp(h.min,h.max),Ki.distanceToSquared(t)),intersectsBounds:(h,d,u)=>u{h.closestPointToPoint(t,Ki);let u=t.distanceToSquared(Ki);return u{Ue(0,new Float32Array(n),Gc),t.union(Gc)}),t}};var Io=self;Io.addEventListener("message",async function({data:i}){let t=performance.now();function e(o){let c=performance.now();(c-t>=10||o===1)&&(postMessage({error:void 0,serialized:void 0,position:void 0,progress:o}),t=c)}let{id:n,index:s,position:r,options:a}=i;try{let o=new Ge;if(o.setAttribute("position",new te(r,3,!1)),s&&o.setIndex(new te(s,1,!1)),a.includedProgressCallback&&(a.onProgress=e),a.groups){let h=a.groups;for(let d in h){let u=h[d];o.addGroup(u.start,u.count,u.materialIndex)}}let c=new $e(o,a),l=$e.serialize(c,{cloneBuffers:!1});Io.postMessage({id:n,error:void 0,serialized:l,position:r,progress:1},[l.index.buffer,r.buffer,...l.roots])}catch(o){Io.postMessage({id:n,error:o,serialized:void 0,position:void 0,progress:1})}});\n/*! Bundled license information:\n\nthree/build/three.module.js:\n (**\n * @license\n * Copyright 2010-2023 Three.js Authors\n * SPDX-License-Identifier: MIT\n *)\n*/\n')}$a.decoderPath="libs/draco/gltf/";var xP=class{constructor(){this.running=!1,this.worker=new O4,this.worker.onerror=e=>{throw e.message?new Error(`[GenerateMeshBVHWorker] Could not create Web Worker with error "${e.message}"`):new Error("[GenerateMeshBVHWorker] Could not create Web Worker.")}}isRunning(){return this.running}generate(e,t={}){if(this.running)return void se.warn("[GenerateMeshBVHWorker] Already running job.");if(!this.worker)return void se.warn("[GenerateMeshBVHWorker] Worker has been disposed.");let{worker:n}=this;this.running=!0;let i=new Map;e.forEach((e=>{i.set(e.id,e)}));let r=0;return new Promise(((e,a)=>{let s=()=>{++r===i.size&&(this.running=!1,n.onmessage=null,e())};n.onerror=e=>{se.warn(`[GenerateMeshBVHWorker] ${e.message}`),a(new Error(`[GenerateMeshBVHWorker] ${e.message}`)),this.running=!1},n.onmessage=e=>{this.running=!1;let{data:n}=e;if(n.error)se.warn(n.error),s();else if(n.serialized){let{serialized:e,position:r,id:a}=n,o=i.get(a),l=Rc.deserialize(e,o,{setIndex:!1}),h=Object.assign({setBoundingBox:!0},t);if(h.transferred&&(o.attributes.position.array=r),o.index)t.saveOriginalIndex&&!o.userData.originalIndex&&(o.userData.originalIndex=o.index.array),se.debug("before update, index:",o.index.array),o.index.array=e.index;else{let t=new mn(e.index,1,!1);o.setIndex(t)}o.index&&(se.debug("after update, index:",o.index.array),o.index.needsUpdate=!0),h.setBoundingBox&&!o.boundingBox&&(o.boundingBox=l.getBoundingBox(new Ot)),o.boundsTree=l,s()}else t.onProgress&&t.onProgress(n.progress)};for(let r of i){let e=r[0],i=r[1],a=i.index?i.index.array:void 0,o=i.attributes.position,l=o.array;if(o.isInterleavedBufferAttribute||a&&a.isInterleavedBufferAttribute){se.warn("[GenerateMeshBVHWorker] InterleavedBufferAttribute are not supported for the geometry attributes."),s();continue}let h=[];t.transferred&&(h.push(l),a&&(h.push(a),t.saveOriginalIndex&&(i.userData.originalIndex=a.slice()))),n.postMessage({id:e,index:a,position:l,options:Ri(Tr({},t),{onProgress:null,includedProgressCallback:Boolean(t.onProgress),groups:[...i.groups]})},h.length>0?h.map((e=>e.buffer)):[])}}))}dispose(){this.worker.terminate(),this.worker=void 0}},Yf=class{constructor(e){this.running=!1,this.workers=[];let t=1;e?t=e:window.navigator&&(t=Math.max(t,window.navigator.hardwareConcurrency-1));for(let n=0;n{let i=this.workers.length,r=e.length,a=[],s=Math.floor(r/i),o=r%i,l=0,h=0;for(let c=0;c=h)break;se.debug("startIndex: "+l+" endIndex: "+h),a.push(n.generate(e.slice(l,h),t))}Promise.allSettled(a).then((()=>{this.running=!1,n()}))}));se.warn("[BVHHelper] Worker has been disposed.")}}))}dispose(){for(let e=0;e{e.traverse((e=>{let i=e;if(i.isMesh&&i.geometry&&Ar.isMergedMesh(i)&&!(i instanceof Pi)){if(n.has(i.geometry.id))return;i.geometry.index&&t.saveOriginalIndex&&(i.geometry.userData.originalIndex=i.geometry.index.array.slice()),i.geometry.boundsTree=new Rc(i.geometry,t),n.add(i.geometry.id)}}))}))}static createMeshBvhAsync(e,t={}){let n=new Set,i=[];e.forEach((e=>{e.traverse((e=>{let t=e;if(t.isMesh&&t.geometry&&Ar.isMergedMesh(t)&&!(t instanceof Pi)){if(n.has(t.geometry.id))return;i.push(t.geometry),n.add(t.geometry.id)}}))}));let r=new Yf;r.generate(i,t).then((()=>{r.dispose()}))}},sve=class{constructor(e,t,n,i,r){this.targetPixelHeight=100,this.canvasHeight=800,this.camera=e,this.object=n,this.targetPixelHeight=i,this.canvasHeight=r,this.adjustSize(),t.addEventListener("update",(()=>{this.adjustSize()}))}adjustSize(){let e=new Ot;if(this.object.updateMatrix(),e.expandByObject(this.object),!e)return;let t=e.max.x-e.min.x,n=this.camera.position.distanceTo(this.object.position),i=Evt(t,n,this.canvasHeight);if(Math.abs(i-this.targetPixelHeight)<5)return;let r=this.object.scale.x;r*=this.targetPixelHeight/i,this.object.scale.set(r,r,r),this.object.updateMatrix()}},Evt=(e,t,n=800,i=45)=>{let r=i*(Math.PI/180);return n*(e/(2*Math.tan(r/2)*t))},bP,EP=new be,_P=new be,TP=new be,ave=new be,_vt=new be,Tvt=new be,So=class extends Bi{constructor(e){super(Mt.guid()),this.needsFrustumCulled=!1,this.renderOrder=1e3,this.snapType="TripleCross",this.snapLineVisible=!1,this.snapType=e,this.drawSnapFunctions={TripleCross:this.drawTripleCorss.bind(this),Square:this.drawSquare.bind(this),Triangle:this.drawTriangle.bind(this),CircleWithCross:this.drawCircleWithCross.bind(this),Cross:this.drawCross.bind(this),Perpendicular:this.drawPerpendicular.bind(this)}}setSnapLineVisible(e){this.snapLineVisible=e}draw(e,t){this.osnapInfo&&(this.snapLineVisible&&this.drawSnapLine(e,t),e.save(),e.fillStyle=So.FILL_COLOR_NONE,e.strokeStyle=So.lineColor,e.lineWidth=So.lineWidth,e.beginPath(),this.drawSnapFunctions[this.snapType](e,t),bP&&this.drawDebug(e,t),e.closePath(),e.fill(),e.stroke(),e.restore())}drawDebug(e,t){null==bP||bP.forEach((n=>{let i=this.transToScreenCoord(n.start,t),r=this.transToScreenCoord(n.end,t);e.moveTo(i.x,i.y),e.lineTo(r.x,r.y)}))}drawSelect(e,t){}isPointInPath(e){return!1}drawSnapLine(e,t){e.save(),e.strokeStyle=So.SNAP_LINE_COLOR,e.lineWidth=So.lineWidth;let n=this.osnapInfo.line;if(!n)return;let i=this.transToScreenCoord(n.start,t),r=this.transToScreenCoord(n.end,t);e.moveTo(i.x,i.y),e.lineTo(r.x,r.y),e.stroke(),e.restore()}drawTripleCorss(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=So.iconSize/1.6,r=EP.set(n.x,n.y-i),a=_P.set(n.x-.87*i,n.y+i/1.4),s=TP.set(n.x+.87*i,n.y+i/1.4);e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.moveTo(n.x,n.y),e.lineTo(a.x,a.y),e.moveTo(n.x,n.y),e.lineTo(s.x,s.y)}drawSquare(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=So.iconSize,r=So.iconSize;e.rect(n.x-i/2,n.y-r/2,i,r)}drawTriangle(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=So.iconSize/1.6,r=EP.set(n.x,n.y-i),a=_P.set(n.x-.87*i,n.y+i/2),s=TP.set(n.x+.87*i,n.y+i/2);e.moveTo(r.x,r.y),e.lineTo(a.x,a.y),e.lineTo(s.x,s.y)}drawCircleWithCross(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=So.iconSize/2;e.arc(n.x,n.y,i,0,2*Math.PI),e.moveTo(n.x-i/1.8,n.y),e.lineTo(n.x+i/1.8,n.y),e.moveTo(n.x,n.y-i/1.8),e.lineTo(n.x,n.y+i/1.8)}drawCross(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=So.iconSize/2,r=EP.set(n.x-i,n.y-i),a=_P.set(n.x+i,n.y+i),s=TP.set(n.x+i,n.y-i),o=ave.set(n.x-i,n.y+i);e.moveTo(r.x,r.y),e.lineTo(a.x,a.y),e.moveTo(s.x,s.y),e.lineTo(o.x,o.y)}drawPerpendicular(e,t){let n=this.transToScreenCoord(this.osnapInfo.point,t),i=So.iconSize/2,r=EP.set(n.x,n.y),a=_P.set(n.x-i,n.y),s=TP.set(n.x,n.y+i),o=ave.set(n.x-i,n.y-i),l=_vt.set(n.x-i,n.y+i),h=Tvt.set(n.x+i,n.y+i);e.moveTo(a.x,a.y),e.lineTo(r.x,r.y),e.lineTo(s.x,s.y),e.moveTo(o.x,o.y),e.lineTo(l.x,l.y),e.lineTo(h.x,h.y),e.lineTo(o.x,o.y)}update(e){this.osnapInfo=e}getClassType(){return"SnapDrawable"}},As=So;As.lineColor="rgba(255, 119, 0, 1)",As.FILL_COLOR_NONE="rgba(0, 0, 0, 0)",As.SNAP_LINE_COLOR="rgba(255, 240, 0, 0.3)",As.lineWidth=2,As.iconSize=14,Un._registerDrawableClass(As);var k4=(e=>(e[e.None=0]="None",e[e.Vertex=1]="Vertex",e[e.MiddlePoint=2]="MiddlePoint",e[e.Edge=4]="Edge",e[e.Face=8]="Face",e[e.FootOfPerpendicular=16]="FootOfPerpendicular",e[e.Intersection=32]="Intersection",e[e.CircleCenter=64]="CircleCenter",e))(k4||{}),wvt=1e-5,qi=new O,oa=new O,Iy=new O,m_=new O,rg=new et,g_=new sa;function Svt(e,t){let n=Number.MAX_VALUE,i=0;for(let r=0;r65535?new Uint32Array(i):new Uint16Array(i);for(let n=0,r=i;n{e.visible=!1,this.drawableList.addDrawable(e)}))}isOSnapTypeEnabled(e){return!!(this.enabledOSnapTypes&e)}setOSnapTypeEnabled(e,t){if(t)this.enabledOSnapTypes|=e;else{let t=~e;this.enabledOSnapTypes&=t}}setSnapTolerance(e){this.snapToleranceInWorldCoord=e}getSnapTolerance(){return this.snapToleranceInWorldCoord}setIntersectionLimit(e){this.intersectionLimit=e}getIntersectionLimit(){return this.intersectionLimit}getMarkerLineColor(){return Cn.colorStr2Rgba(As.lineColor)}setMarkerLineColor(e){As.lineColor=Cn.rgba2Color(e)}getMarkerLineWidth(){return As.lineWidth}setMarkerLineWidth(e){As.lineWidth=e}getMarkerIconSize(){return As.iconSize}setMarkerIconSize(e){As.iconSize=e}getMarker(e){return this.markers[e]}setAllSnapLinesVisible(e){Object.values(this.markers).forEach((t=>{t.setSnapLineVisible(e)}))}deactivate(){var e;this.activeOSnapType&&(this.markers[this.activeOSnapType].visible=!1,null==(e=this.overlayRender)||e.render()),this.activeOSnapType=0}destroy(){}handleSnap(e,t,n){if(!e||e.length<1)return void this.deactivate();se.debug("[OSnap] intersections before handleSnap:",e);let i,r=[],a=!1;for(let o of e)o.object instanceof xt?(i||(i=o.point),!a&&"groundPlane"!==o.object.name&&(r.push(o),a=!0)):r.push(o);if(!t&&i){i.setZ(0);for(let t of r)t.point.z=0,t.distance=t.point.distanceTo(i);let e=e=>e instanceof ii?0:e instanceof Wr?2:e instanceof hr?1:3;r.sort(((t,n)=>{let i=e(t.object),r=e(n.object);return i!==r?i-r:t.distance-n.distance}))}i||(se.warn("[OSnap] Potential to produce erroneous snap results"),i=r[0].point),se.debug("[OSnap] intersections:",r),se.debug("[OSnap] mousePosition:",i);let s=this.getSnapPointAndUpdateMarker(i,r,t,n);return(null==s?void 0:s.clone())||i}getSnapPointAndUpdateMarker(e,t,n,i){if(!t.length)return void this.activateMarker(0);let r=this.getSnapInfo(e,t,n,i);if(r&&0!==r.type)return this.activateMarker(r.type,r),r.point;this.activateMarker(0)}activateMarker(e,t){var n;this.activeOSnapType&&(this.markers[this.activeOSnapType].visible=!1),this.activeOSnapType=e;let i=this.markers[e];i&&t&&(i.update(t),i.visible=!0),null==(n=this.overlayRender)||n.render()}getFootOfPerpendicular(e,t,n=wvt){let{start:i,end:r}=t,a=i.x-r.x,s=i.y-r.y,o=i.z-r.z;if(i.distanceTo(r){let n=this.osnapTypePriorities[e.type],i=this.osnapTypePriorities[t.type];return n!==i?n-i:e.distance-t.distance})),a[0]}getOsnapInfoListFromMesh(e,t,n,i){if(i=this.osnapTypePriorities[16]&&this.isOSnapTypeEnabled(16)){let t=this.getFootOfPerpendicular(s,o,i),n=e.distanceTo(t);if(n<=i)return{distance:Zt.floorNumber(n,7),type:16,point:t.clone()}}if(ai)return;let h=e.distanceTo(t),c=e.distanceTo(n);if(Math.min(h,c)<=i&&this.isOSnapTypeEnabled(1)){let e=h,i=t;return c{let n=this.osnapTypePriorities[e.type],i=this.osnapTypePriorities[t.type];return n!==i?n-i:e.distance-t.distance})),o[0]}getOsnapInfoListFromPoint(e,t,n,i,r){if(ri)return;let l={distance:o,point:qi.clone(),type:1};if("CircleCenter"===a.userData.type){if(!this.isOSnapTypeEnabled(64))return;l.type=64}else if(se.debug("[OSnap] Other types of vertices !"),!this.isOSnapTypeEnabled(1))return;return l}getIntersectsIncludeOutline(e,t){let n=e.slice(),i=[];for(let a=0;a0&&(r=t.intersectObjects(i)||[],se.debug("[OSnap] Intersected with newly created edges: ",r),r.length>0&&n.push(...r)),n.sort(((e,t)=>e.distance-t.distance)),n}},F4=ji(Fl(),1),Yl=class{constructor(e,t,n){this.follow=e=>{this.node.style.left=e.offsetX+15+"px",this.node.style.top=e.offsetY-30+"px"},this.show=()=>this.node.hasAttribute("hidden")&&this.node.removeAttribute("hidden"),this.hide=()=>!this.node.hasAttribute("hidden")&&this.node.setAttribute("hidden",""),this.destroy=()=>{this.target?this.target.removeEventListener(wf,this.follow):document.removeEventListener(wf,this.follow),this.parentNode.removeChild(this.node)},this.node=document.createElement("div"),this.node.id=e,t&&this.node.append(t),this.childNode=document.createElement("div"),this.target=null==n?void 0:n.target,this.parentNode=(null==n?void 0:n.parentNode)||document.body,null!=n&&n.followPointer&&(this.node.classList.add("follow-tooltip"),this.target?this.target.addEventListener(wf,this.follow):document.addEventListener(wf,this.follow)),this.parentNode.appendChild(this.node),(null==n||!n.showOnCreate)&&this.node.setAttribute("hidden","")}setContent(e){this.node.textContent&&(this.node.textContent=null),(0,F4.forEach)(this.node.children,(e=>{this.node.removeChild(e)})),this.node.append(e),this.node.appendChild(this.childNode)}updateChildContent(e){this.childNode.textContent&&(this.childNode.textContent=null),(0,F4.forEach)(this.childNode.children,(e=>{this.childNode.removeChild(e)})),this.childNode.append(e)}},SP=class{constructor(e){this.active=!1,this.isResolvedOrRejected=!1,this.mouseClicked=e=>{var t;if(e.markupData){let n=e.markupData.id,i=null==(t=this.viewer.overlayRender)?void 0:t.getDrawableById(n);if(i){let e=i.getBounds();e=e.clone().expandByScalar(20*this.viewer.getPixelSizeInWorldCoord());let t=cn.worldCoordinate2NormalizedScreenCoordinate(e.min,this.camera,this.viewerContainer),n=cn.worldCoordinate2NormalizedScreenCoordinate(e.max,this.camera,this.viewerContainer),r=new Ji(new be(Math.min(t.x,n.x),Math.min(t.y,n.y)),new be(Math.max(t.x,n.x),Math.max(t.y,n.y)));r.min.x=Math.max(r.min.x,0)*this.viewerContainer.clientWidth,r.min.y=Math.max(r.min.y,0)*this.viewerContainer.clientHeight,r.max.x=Math.min(r.max.x,1)*this.viewerContainer.clientWidth,r.max.y=Math.min(r.max.y,1)*this.viewerContainer.clientHeight,this.resolve&&(this.resolve(r),this.isResolvedOrRejected=!0),this.deactivate();let a=this.viewer;"function"==typeof a.clearSelection&&a.clearSelection()}}},this.keydown=e=>{"Escape"===e.code&&this.deactivate()},this.viewer=e}get viewerContainer(){return this.viewer.viewerContainer}get camera(){return this.viewer.camera}isActive(){return this.active}activate(){var e,t;if(this.isActive())return void(this.reject&&(this.deactivate(),this.reject("PickMarkupHelper is already actived!"),this.isResolvedOrRejected=!0));this.active=!0,this.viewer.addEventListener("MouseClicked",this.mouseClicked),null==(e=this.viewer.getInputManager())||e.addEventListener("keydown",this.keydown);let n=this.viewer.translate;if(n){this.tooltip=new Yl("pick-markup-tooltip",n("Tooltip.pickMarkup"),{followPointer:!0,showOnCreate:!0,parentNode:this.viewer.widgetContainer,target:this.viewerContainer});let e=document.getElementById("pick-markup-tooltip");e&&(e.style.pointerEvents="none");let i=n("Tooltip.pickMarkup");i&&this.tooltip&&(null==(t=this.tooltip)||t.setContent(i))}this.viewer.dispatchEvent("PickMarkupActivated")}deactivate(){var e,t,n;this.active=!1,this.viewer.removeEventListener("MouseClicked",this.mouseClicked),null==(e=this.viewer.getInputManager())||e.removeEventListener("keydown",this.keydown),null==(t=this.tooltip)||t.hide(),null==(n=this.tooltip)||n.destroy(),this.tooltip=void 0,this.viewer.dispatchEvent("PickMarkupDeactivated"),this.resolve&&!this.isResolvedOrRejected&&(this.resolve(void 0),this.isResolvedOrRejected=!0)}pick(){return ft(this,null,(function*(){return new Promise(((e,t)=>{this.resolve=e,this.reject=t,this.activate()}))}))}destroy(){this.deactivate(),this.isResolvedOrRejected||this.reject&&this.reject("PickMarkupHelper is not done for some reason!")}},MP=class{constructor(e){this.mouseDown=!1,this.mouseMove=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.tempEnableRotate=!1,this.active=!1,this.isResolvedOrRejected=!1,this.mousedown=e=>{var t,n;if(0===e.button){this.mouseDown=!0;let i=new be(e.x,e.y);this.mouseDownPositionX=i.x,this.mouseDownPositionY=i.y,null==(t=this.tooltip)||t.hide(),null==(n=this.tooltip)||n.destroy(),this.tooltip=void 0}},this.mousemove=e=>{if(!this.mouseDown)return;let t=new be(e.x,e.y);if(this.mouseDownPositionX>=0&&this.mouseDownPositionY>=0&&(Math.abs(t.x-this.mouseDownPositionX)>=5||Math.abs(t.y-this.mouseDownPositionY)>=5)){this.mouseMove=!0;let e=new be(Math.min(this.mouseDownPositionX,t.x),Math.min(this.mouseDownPositionY,t.y)),n=new be(Math.max(this.mouseDownPositionX,t.x),Math.max(this.mouseDownPositionY,t.y));this.drawRect(e,n)}},this.mouseup=e=>{if(this.mouseDown&&this.mouseMove){let t=new be(e.x,e.y),n=new be(Math.min(this.mouseDownPositionX,t.x),Math.min(this.mouseDownPositionY,t.y)),i=new be(Math.max(this.mouseDownPositionX,t.x),Math.max(this.mouseDownPositionY,t.y)),r=new Ji(n,i);this.resolve&&(this.resolve(r),this.isResolvedOrRejected=!0),this.deactivate(),this.setRectDomVisible(!1)}this.mouseDown=!1,this.mouseMove=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1},this.keydown=e=>{"Escape"===e.code&&this.deactivate()},this.viewer=e,this.input=e.getInputManager()}get viewerContainer(){return this.viewer.viewerContainer}isActive(){return this.active}activate(){var e;if(this.isActive())return void(this.reject&&(this.deactivate(),this.reject("BoxSelectHelper is already actived!"),this.isResolvedOrRejected=!0));this.active=!0,this.input.addEventListener("pointerdown",this.mousedown),this.input.addEventListener("pointermove",this.mousemove),this.input.addEventListener("pointerup",this.mouseup),this.input.addEventListener("keydown",this.keydown);let t=this.viewer.controls;this.tempKey=t.mouseButtons.left,this.tempEnableRotate=t.enableRotate,t.mouseButtons.left=yt.NONE,this.tempTouch=t.touches.one,t.touches.one=yt.NONE,t.enableRotate=!1;let n=this.viewer.translate;if(n){this.tooltip=new Yl("box-select-tooltip",n("Tooltip.boxSelect"),{followPointer:!0,showOnCreate:!0,parentNode:this.viewer.widgetContainer,target:this.viewerContainer});let t=document.getElementById("box-select-tooltip");t&&(t.style.pointerEvents="none");let i=n("Tooltip.boxSelect");i&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(i))}this.viewer.dispatchEvent("BoxSelectActivated")}deactivate(){var e,t;this.active=!1,this.input.removeEventListener("pointerdown",this.mousedown),this.input.removeEventListener("pointermove",this.mousemove),this.input.removeEventListener("pointerup",this.mouseup),this.input.removeEventListener("keydown",this.keydown),null==(e=this.tooltip)||e.hide(),null==(t=this.tooltip)||t.destroy(),this.tooltip=void 0,this.viewer.controls.mouseButtons.left=this.tempKey,this.viewer.controls.enableRotate=this.tempEnableRotate,this.viewer.controls.touches.one=this.tempTouch,this.viewer.dispatchEvent("BoxSelectDeactivated"),this.resolve&&!this.isResolvedOrRejected&&(this.resolve(void 0),this.isResolvedOrRejected=!0)}drawRect(e,t){this.rectDom||(this.rectDom=document.createElement("div"),this.rectDom.style.cssText=`position: absolute;border: ${MP.BORDER_WIDTH} solid ${MP.BORDER_COLOR};`,this.viewerContainer.appendChild(this.rectDom)),this.setRectDomVisible(!0),this.rectDom.style.left=`${e.x}px`,this.rectDom.style.top=`${e.y}px`;let n=Math.abs(t.x-e.x),i=Math.abs(t.y-e.y);this.rectDom.style.width=`${n}px`,this.rectDom.style.height=`${i}px`}setRectDomVisible(e){this.rectDom&&(this.rectDom.style.display=e?"inline-block":"none")}select(){return ft(this,null,(function*(){return new Promise(((e,t)=>{this.resolve=e,this.reject=t,this.activate()}))}))}destroy(){var e;this.deactivate(),null==(e=this.rectDom)||e.remove(),this.rectDom=void 0,this.isResolvedOrRejected||this.reject&&this.reject("BoxSelectHelper is not done for some reason!")}},$f=MP;$f.BORDER_COLOR="#fff000",$f.BORDER_WIDTH="2px";var fr=class extends us{constructor(e,t){if(!t.id)throw new Error("[Plugin] Missing plugin id!");super(),this.id=t.id,this.viewer=e,e.addPlugin(this)}destroy(){this.viewer.removePlugin(this)}},Ly=(e=>(e.BaseViewer="BaseViewer",e.BimViewer="BimViewer",e.DxfViewer="DxfViewer",e.VRViewer="VRViewer",e))(Ly||{}),Zf=class extends us{constructor(e){super(),this.name="BaseViewer",this.translate=this.initLocalization(),this.height=0,this.width=0,this.jobCount=0,this.enableOverlayRenderer=!0,this.frustumSize=this.width,this.lastFrameExecuteTime=Date.now(),this.minFrameInterval=10,this.plugins=[],this.viewerCfg=e,this.undoRedoManager=new aC,this.initLogLevel(),this.initLocalization(),Dn.isBrowser&&!e.context&&(this.initContainer(),this.initViewerContainer(),this.initWidgetContainer())}initLogLevel(){let e=this.viewerCfg.logLevel;e&&gde(e)}initLocalization(){var e;let t=(null==(e=this.viewerCfg)?void 0:e.language)||"cn";return eg.init({lng:t,debug:!1,resources:{en:{translation:Kde},cn:{translation:Jde}}}),eg.t}initContainer(){let e=document.getElementById(this.viewerCfg.containerId);e||(se.error("[Viewer] containerId:",this.viewerCfg.containerId,"is not found in dom tree! will append to document body"),e=document.body);let t=document.createElement("div");t.classList.add("gemini-container"),t.style.cssText="width: 100%; height: 100%; position: relative;",e.appendChild(t),this.container=t}initViewerContainer(){let e=this.container;if(!e)return;let t=document.createElement("div");t.classList.add("gemini-viewer-container"),t.style.cssText="width: 100%; height: 100%;display: inline-block;position: relative; overflow: hidden;",e.appendChild(t),this.width=e.clientWidth,this.height=e.clientHeight,this.viewerContainer=t}initWidgetContainer(){let e=this.container;if(!e)return;let t=document.createElement("div");t.classList.add("gemini-widget-container"),e.appendChild(t),this.widgetContainer=t}initSpinner(){var e;if(!this.viewerCfg.enableSpinner)return;let t=document.createElement("div");t.classList.add("gemini-spinner"),t.appendChild(document.createElement("span")),t.appendChild(document.createElement("span")),t.appendChild(document.createElement("span")),t.appendChild(document.createElement("span")),null==(e=this.viewerContainer)||e.appendChild(t),this.spinner=t,this.setSpinnerVisibility(this.jobCount>0)}setSpinnerVisibility(e){this.spinner&&(e?this.spinner.classList.remove("hidden"):this.spinner.classList.add("hidden"))}increaseJobCount(){this.setSpinnerVisibility(++this.jobCount>0)}decreaseJobCount(){this.jobCount<=0?se.warn("[Viewer] jobCount should be at least 1 here!"):this.setSpinnerVisibility(--this.jobCount>0)}resize(e,t){let n=this.camera;if(n&&t>0){if(n instanceof ur)n.aspect=e/t;else if(n instanceof Ur){let i=e/t;n.left=-this.frustumSize/2,n.right=this.frustumSize/2,n.top=this.frustumSize/i/2,n.bottom=-this.frustumSize/i/2}n.updateProjectionMatrix(),this.renderer&&this.renderer.setSize(e,t,!0),this.overlayRender&&this.overlayRender.setSize(e,t)}this.width=e,this.height=t,this.enableRender()}destroy(){var e,t,n,i;this.clearPlugins(),null==(e=this.widgetContainer)||e.remove(),this.widgetContainer=void 0,null==(t=this.viewerContainer)||t.remove(),this.viewerContainer=void 0,null==(n=this.scene)||n.clear(),this.scene=void 0,this.requestAnimationFrameHandle&&(cancelAnimationFrame(this.requestAnimationFrameHandle),this.requestAnimationFrameHandle=void 0),this.renderer&&(this.renderer.domElement.remove(),this.renderer.clear(),this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer=void 0),this.overlayRender&&(this.overlayRender.destroy(),this.overlayRender=void 0),this.camera=void 0,this.controls&&(this.controls.dispose(),this.controls=void 0),this.groundPlane&&(this.groundPlane.geometry.dispose(),this.groundPlane.clear(),this.groundPlane=void 0),this.removeEventListener(),null==(i=this.undoRedoManager)||i.destroy(),this.spinner&&(this.spinner.remove(),this.spinner=void 0)}getInputManager(){return this.inputManager}getViewConfig(){return this.viewerCfg}enableRender(){}getRaycaster(){}getRaycastableObjectsByMouse(e){return[]}getBBox(){}getActiveSection(){}flyTo(e,t){}is3d(){return!0}get measurePlugin(){}getMarkupManager(){}deactivateMeasurement(){}setMeasurementVisibility(e,t){return!1}screenshot(e){return ft(this,null,(function*(){}))}getPixelSizeInWorldCoord(){let e=this.camera,{clientWidth:t,clientHeight:n}=this.viewerContainer,i=1;if("OrthographicCamera"===e.type){let r=e;i=Math.max(r.right-r.left,r.top-r.bottom)/r.zoom/Math.max(t,n)}else if("PerspectiveCamera"===e.type){let t=e,r=new O;e.getWorldPosition(r);let a=new O,s=this.controls;s.getTarget?s.getTarget(a):s.target&&(a=s.target),r&&a&&(i=r.distanceTo(a)*Math.tan(t.fov/2*Math.PI/180)*2/n)}return i}getUniqueModelId(e){let t=e,n=e=>!!this.loadedModels.find((t=>t.modelId===e));if(n(t)){let e=1;for(;n(`${t}_${e}`);)e++;t=`${t}_${e}`,se.warn(`[Viewer] Model '${t}' is loaded more than once!`)}return t}addPlugin(e){this.plugins.find((t=>t.id===e.id))?se.error(`[Viewer] Plugin already exist: ${e.id}`):(this.plugins.push(e),se.debug(`[Viewer] Added plugin: ${e.id}`))}removePlugin(e){for(let t=0,n=this.plugins.length;tt.id===e))}},Dy=class{constructor(e){this.active=!1,this.viewer=e,this.boxSelectHelper=new $f(e)}get viewerContainer(){return this.viewer.viewerContainer}get camera(){return this.viewer.camera}get raycaster(){return this.viewer.getRaycaster()}isActive(){return this.active}activate(){var e;this.active=!0,null==(e=this.boxSelectHelper)||e.select().then((e=>{e&&this.handleZoomToRect(e.min,e.max)}))}deactivate(){var e;this.active=!1,null==(e=this.boxSelectHelper)||e.deactivate()}pickPositionByScreenPoint(e){let t=cn.screenPoint2NdcPoint(e,this.camera,this.viewerContainer);this.raycaster.layers.set(10),this.raycaster.setFromCamera(t,this.camera);let n=[];"BimViewer"===this.viewer.name?n=this.viewer.getRaycastableObjectsByMouse({x:e.x,y:e.y}):"DxfViewer"===this.viewer.name&&(n=[this.viewer.groundPlane]);let i=this.raycaster.intersectObjects(n)||[];if(i.length>0)return i[0].point}handleZoomToRect(e,t){let n=this.pickPositionByScreenPoint(e),i=this.pickPositionByScreenPoint(t);if(n&&i){let e=new O(Math.min(n.x,i.x),Math.min(n.y,i.y),Math.min(n.z,i.z)),t=new O(Math.max(n.x,i.x),Math.max(n.y,i.y),Math.max(n.z,i.z)),r=new Ot(e,t);this.viewer.zoomToBBox(r)}}destroy(){var e;null==(e=this.boxSelectHelper)||e.destroy(),this.boxSelectHelper=void 0}},RP=class extends Bi{constructor(e){super("MobileHelper"),this.needsFrustumCulled=!1,this.renderOrder=1e3,this.position=e}setPosition(e){this.position=e}isPointInPath(e,t){return!1}draw(e,t){this.drawInnerCircle(e),this.drawOuterRing(e),this.drawSnapTriangle(e)}drawInnerCircle(e){let{x:t,y:n}=this.position;e.save(),e.fillStyle="rgba(137, 137, 138, 0.8)",e.beginPath(),e.arc(t,n,25,0,2*Math.PI),e.closePath(),e.fill(),e.restore()}drawOuterRing(e){let{x:t,y:n}=this.position;e.save(),e.strokeStyle="rgba(17, 17, 19, 0.8)",e.lineWidth=10,e.beginPath(),e.arc(t,n,30,0,2*Math.PI),e.closePath(),e.stroke(),e.restore(),e.save(),e.strokeStyle="rgba(173, 173, 174, 0.8)",e.lineWidth=3,e.beginPath(),e.arc(t,n,35,0,2*Math.PI),e.closePath(),e.stroke(),e.restore()}drawSnapTriangle(e){let{x:t,y:n}=this.position;e.save(),e.fillStyle="rgba(17, 17, 19, 0.8)",e.strokeStyle="rgba(137, 137, 138, 0.8)",e.lineWidth=2,e.beginPath(),e.moveTo(t-35,n-35),e.lineTo(t-35+12,n-35),e.lineTo(t-35,n-35+12),e.closePath(),e.fill(),e.stroke(),e.restore()}translate(e,t){this.position.add(new be(e,t))}getTouchPoint(){return{x:this.position.x-35,y:this.position.y-35}}isIntersect(e){return this.position.x-35e.x&&this.position.y+35>e.y}drawSelect(e,t){}getClassType(){return"MobileTouchHelperDrawable"}},$l=(e=>(e.Distance="Distance",e.Area="Area",e.Angle="Angle",e.Coordinate="Coordinate",e))($l||{}),nh=class extends us{constructor(e,t,n,i,r){super(),this.mouseMoved=!1,this.mouseDowned=!1,this.touchDowned=!1,this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.snapPoint=void 0,this.touchstart=e=>{this.mobileTouchHelper&&this.mobileTouchHelper.isIntersect(e)&&!this.touchDowned&&(this.clearClickedDrawable(),this.viewer.controls&&(this.viewer.controls.enabled=!1),this.touchDowned=!0,this.mouseDownPositionX=e.x,this.mouseDownPositionY=e.y)},this.touchmove=e=>{if(e.pointers&&e.pointers.length>1)return;let{width:t,height:n}=this.canvas.getBoundingClientRect();if(!(e.x>t-15||e.x<35||e.y<15||e.y>n-35)&&this.touchDowned&&this.mobileTouchHelper){let t=e.x-this.mouseDownPositionX,n=e.y-this.mouseDownPositionY;this.mobileTouchHelper.translate(t,n),this.mouseDownPositionX=e.x,this.mouseDownPositionY=e.y;let i=this.mobileTouchHelper.getTouchPoint(),r=this.getIntersections(i);if(!r.length)return void this.osnapHelper.deactivate();let a=Date.now();if(this.snapPoint=this.osnapHelper.handleSnap(r,this.viewer.is3d(),this.lastMouseDownPosition),se.debug(`[BaseMeasurement] handleSnap costs ${(Date.now()-a)/1e3}s`),!this.snapPoint)return void console.warn("[BaseMeasurement] Failed to find a snap point!");this.onMouseMove(this.snapPoint)}},this.touchend=e=>{var t;if(this.viewer.controls&&(this.viewer.controls.enabled=!0),!(e.pointers&&e.pointers.length>1)){if(this.touchDowned){this.touchDowned=!1;let e=null==(t=this.mobileTouchHelper)?void 0:t.getTouchPoint();this.onMouseClick(e)}else this.selectMeasurementByEvent(e);Dn.isMobile&&(this.osnapHelper.deactivate(),this.dispatchEvent("Updated"))}},this.mousedown=e=>{this.mouseMoved=!1,this.mouseDowned=!0,this.mouseDownPositionX=e.x,this.mouseDownPositionY=e.y},this.mousemove=e=>{if(this.lastMoveEvent=e,this.mouseDownPositionX>=0&&this.mouseDownPositionY>=0&&(Math.abs(e.x-this.mouseDownPositionX)>5||Math.abs(e.y-this.mouseDownPositionY)>5)&&(this.mouseMoved=!0),this.mouseDowned)return;let t=this.getIntersections(e);if(!t.length)return void this.osnapHelper.deactivate();let n=Date.now();this.snapPoint=this.osnapHelper.handleSnap(t,this.viewer.is3d(),this.lastMouseDownPosition),se.debug(`[BaseMeasurement] this.handleSnap costs ${(Date.now()-n)/1e3}s`),this.snapPoint?this.onMouseMove(this.snapPoint):console.warn("[BaseMeasurement] Failed to find a snap point!")},this.mouseup=e=>{this.mouseDowned=!1,this.mouseMoved||this.onMouseClick(e)},this.dblclick=()=>{se.info("[Measure] Double clicked")},this.keydown=e=>{if("Enter"===e.code){let e={x:0,y:0,pageX:0,pageY:0,clientX:0,clientY:0,deltaX:0,deltaY:0,button:2,movementX:0,movementY:0,deltaMode:0,pointerId:0,timestamp:0,buttons:0,pointerType:"mouse",altKey:!1,ctrlKey:!1,shiftKey:!1,metaKey:!1};this.onMouseClick(e)}else"Escape"===e.code&&this.cancel()},this.getIntersections=e=>{if(!this.raycaster)return[];this.raycaster.layers.set(11);let t=this.viewer.getRaycastableObjectsByMouse(e);se.debug(`[BaseMeasurement] The count of raycastable object is ${t.length}`,t);let n=Date.now(),i=this.raycaster.intersectObjects(t,!0)||[];return se.debug(`[BaseMeasurement] this.raycaster.intersectObjects costs ${(Date.now()-n)/1e3}s`),this.renderer.clippingPlanes.length>0&&(i=i.filter((e=>this.renderer.clippingPlanes.every((function(t){return t.distanceToPoint(e.point)>0}))))),i},this.type=e,this.viewer=t,this.inputManager=n,this.drawList=i,this.osnapHelper=r}get canvas(){var e;return null==(e=this.viewer.renderer)?void 0:e.domElement}get camera(){return this.viewer.camera}get renderer(){return this.viewer.renderer}get isActive(){return!!this.raycaster}get isMeasuring(){return!1===this.completed}setTouchHelper(e){this.mobileTouchHelper=e}createMobileExitButton(){let e=this.viewer.widgetContainer,t=document.createElement("button");return t.innerText="X",t.style.cssText="position: absolute;right: 5%; top: 5%;background-color: #000000;color: #ffffff;padding: 3px 10px;font-weight: bolder;",null==e||e.appendChild(t),this.exitButton=t,this.exitButton.style.display="none",t.addEventListener("touchstart",(()=>{this.exitDrawing(),this.exitButton&&(this.exitButton.style.display="none")})),this.addEventListener("FirstPointPicked",this.firstPickedListener=()=>{this.exitButton&&(this.exitButton.style.display="inline-block")}),this.addEventListener("Completed",this.completedListener=()=>{this.exitButton&&(this.exitButton.style.display="none")}),this.exitButton}activate(){if(Dn.isMobile)this.inputManager.addEventListener("touchstart",this.touchstart),this.inputManager.addEventListener("touchmove",this.touchmove),this.inputManager.addEventListener("touchend",this.touchend);else{this.inputManager.addEventListener("pointerdown",this.mousedown),this.inputManager.addEventListener("pointermove",this.mousemove),this.inputManager.addEventListener("pointerup",this.mouseup);let e=this.viewer.translate;if(e){this.tooltip=new Yl("measure-tooltip",e("Tooltip.measure"),{followPointer:!0,showOnCreate:!0,parentNode:this.viewer.widgetContainer,target:this.viewer.viewerContainer});let t=document.getElementById("measure-tooltip");t&&(t.style.pointerEvents="none")}this.setTooltipContent()}this.inputManager.addEventListener("dblclick",this.dblclick),this.inputManager.addEventListener("keydown",this.keydown),this.raycaster=this.viewer.getRaycaster()}deactivate(){var e,t;Dn.isMobile?(this.inputManager.removeEventListener("touchstart",this.touchstart),this.inputManager.removeEventListener("touchmove",this.touchmove),this.inputManager.removeEventListener("touchend",this.touchend)):(this.inputManager.removeEventListener("pointerdown",this.mousedown),this.inputManager.removeEventListener("pointermove",this.mousemove),this.inputManager.removeEventListener("pointerup",this.mouseup)),this.inputManager.removeEventListener("dblclick",this.dblclick),this.inputManager.removeEventListener("keydown",this.keydown),null==(e=this.tooltip)||e.hide(),null==(t=this.tooltip)||t.destroy(),this.tooltip=void 0,this.raycaster=void 0,this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable),this.osnapHelper.deactivate(),this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0}removeDrawable(e){this.dispatchEvent("WillBeRemoved",e)}clearClickedDrawable(){this.clickedOnMeasurementDrawable&&(this.clickedOnMeasurementDrawable.selected=!1,this.clickedOnMeasurementDrawable=void 0)}onMouseClick(e){if(Dn.isMobile)return;let t=Date.now();this.lastClickTime&&t-this.lastClickTime<500||(this.lastClickTime=t,this.selectMeasurementByEvent(e))}selectMeasurementByEvent(e){if(this.clickedOnMeasurementDrawable&&(this.clickedOnMeasurementDrawable.selected=!1,this.clickedOnMeasurementDrawable=void 0),null==this.completed||!0===this.completed){let t=this.getIntersections(e)[0];if(t){let e=this.drawList.getDrawableByPosition(t.point,this.raycaster);e&&(this.dispatchEvent("ClickedOnMeasurement",e),this.clickedOnMeasurementDrawable=e)}}}onMouseMove(e){this.createOrUpdateMeasureDrawable(e)}createOrUpdateMeasureDrawable(e){if(!this.drawingPoints||this.drawingPoints&&this.drawingPoints.length<1)return;let t=[...this.drawingPoints];if(!this.currentMeasureDrawable)return this.currentMeasureDrawable=this.createMeasureDrawable(),this.currentMeasureDrawable&&(this.currentMeasureDrawable.selected=!0),void this.dispatchEvent("WillBeAdded",this.currentMeasureDrawable);e&&t.push(e),this.currentMeasureDrawable.selected=!0,this.currentMeasureDrawable.update(t),this.currentMeasureDrawable.setDrawingState(!0),this.dispatchEvent("Updated")}},Ta=class extends Bi{constructor(e,t){super(e),this.type="Distance",this.labelBounds=new Ji,this.drawing=!1,this.update(t)}setDrawingState(e){this.drawing=e}drawSelect(e,t){let n=this.getVertexes();this.drawPoints(e,t,n)}drawPoints(e,t,n){e.save(),e.fillStyle=Ta.MAJOR_COLOR,e.strokeStyle=Ta.MINOR_COLOR,e.lineWidth=Ta.LINE_WIDTH,e.beginPath(),(this.drawing?n.slice(0,n.length-1):n).forEach((n=>{let i=this.transToScreenCoord(n,t);e.moveTo(i.x+Ta.POINT_RADIUS,i.y),e.arc(i.x,i.y,Ta.POINT_RADIUS,0,2*Math.PI)})),e.closePath(),e.fill(),e.stroke(),e.restore()}drawText(e,t){if(!this.label||!this.labelPositon)return;e.font=`${Ta.LABEL_FONT_SIZE}px Arial`;let n=1.2*e.measureText(this.label).width,i=1.5*Ta.LABEL_FONT_SIZE;this.labelBounds.setFromCenterAndSize(this.labelPositon,new be(n,i)),this.drawRoundRect(e,this.labelPositon.x-n/2,this.labelPositon.y-i/2,n,i,4),e.save(),e.fillStyle=Ta.MINOR_COLOR,e.textBaseline="middle",e.textAlign="center",e.fillText(this.label,this.labelPositon.x,this.labelPositon.y),e.restore()}drawRoundRect(e,t,n,i,r,a){i<2*a&&(a=i/2),r<2*a&&(a=r/2),e.save(),e.fillStyle=Ta.MAJOR_COLOR,e.strokeStyle=Ta.MINOR_COLOR,e.lineWidth=Ta.LINE_WIDTH,e.beginPath(),e.moveTo(t+a,n),e.arcTo(t+i,n,t+i,n+r,a),e.arcTo(t+i,n+r,t,n+r,a),e.arcTo(t,n+r,t,n,a),e.arcTo(t,n,t+i,n,a),e.closePath(),e.fill(),this.selected&&e.stroke(),e.restore()}getVertexes(){return this.points}update(e){let{min:t,max:n}=(new Ot).setFromPoints(e);return this.x=t.x,this.y=t.y,this.width=Math.abs(n.x-t.x),this.height=Math.abs(n.y-t.y),this.points=e,this}getBounds(){let e=this.getVertexes();return(new Ot).setFromPoints(e)}getData(){return{id:this.id,type:this.type,points:this.points.map((e=>[e.x,e.y,e.z]))}}setData(e){super.setData(e),this.setLineColor(Cn.colorStr2Rgba(Ta.MAJOR_COLOR)),this.setFillColor(Cn.colorStr2Rgba(Ta.AREA_FILL_COLOR)),this.setLineWidth(Ta.LINE_WIDTH)}isPointInPath(e,t){let n=null==t?void 0:t.ray;if(!n)return!1;let i=3*this.tolerance,r=this.transToScreenCoord(e,t.camera);if(this.labelBounds.containsPoint(r))return!0;let a=new O,s=new O,o=this.points;for(let l=0;l{let r=this.transToScreenCoord(n,t);0===i?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),3===this.points.length){let[n,i,r]=this.points.map((e=>this.transToScreenCoord(e,t))),a=(new be).subVectors(n,i).normalize(),s=(new be).subVectors(r,i).normalize(),o=Math.min(n.distanceTo(i),r.distanceTo(i)),l=a.angle(),h=s.angle();e.moveTo(i.x,i.y),e.arc(i.x,i.y,o/5,l,h,a.cross(s)<0)}if(e.stroke(),e.restore(),this.drawing){let n=1===this.points.length?this.points:this.points.slice(0,this.points.length-1);this.drawPoints(e,t,n)}this.drawText(e,t)}drawText(e,t){if(this.points.length<3)return;let[n,i,r]=this.points,a=this.getAngleBisector(n,i,r),s=this.calculateAngle(n,i,r);this.label=`${Bu(s,2)} ${this.getUnitString()}`;let o=.3*Math.min(n.distanceTo(i),r.distanceTo(i));this.labelPositon=this.transToScreenCoord(i.clone().add(new O(a.x*o,a.y*o,a.z*o)),t),super.drawText(e,t)}getAngleBisector(e,t,n){let i=e,r=t,a=n,s=new O(i.x-r.x,i.y-r.y,i.z-r.z).normalize(),o=new O(a.x-r.x,a.y-r.y,a.z-r.z).normalize();return new O(s.x+o.x,s.y+o.y,s.z+o.z).normalize()}calculateAngle(e,t,n){let i=e,r=t,a=n,s=new O(i.x-r.x,i.y-r.y,i.z-r.z),o=new O(a.x-r.x,a.y-r.y,a.z-r.z);return 180*s.angleTo(o)/Math.PI}getClassType(){return"Angle"}};Un._registerDrawableClass(v_);var AP=class extends nh{constructor(e,t,n,i){super("Angle",e,t,n,i)}createMeasureDrawable(){if(this.drawingPoints)return new v_(Mt.guid(),this.drawingPoints)}onMouseClick(e){var t;if(super.onMouseClick(e),this.clickedOnMeasurementDrawable)return;if(this.drawingPoints||(this.drawingPoints=[]),2===e.button)return void this.exitDrawing();let n=this.getIntersections(e)[0];if(!n)return;let i=null!=(t=this.snapPoint)?t:null==n?void 0:n.point;if(this.drawingPoints[0]&&Zt.areVector3sEqual(this.drawingPoints[0],i))return;let r=this.drawingPoints;r.push(i),this.lastMouseDownPosition=i,1===r.length&&(this.dispatchEvent("FirstPointPicked"),this.completed=!1),this.createOrUpdateMeasureDrawable(),r.length>=3&&this.complete()}exitDrawing(){this.drawingPoints=void 0,this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=void 0,this.lastMouseDownPosition=void 0}complete(){var e;!0!==this.completed&&(null==(e=this.currentMeasureDrawable)||e.setDrawingState(!1),this.dispatchEvent("Completed",this.currentMeasureDrawable),this.completed=!0,this.currentMeasureDrawable=void 0,this.drawingPoints=void 0,this.lastMouseDownPosition=void 0)}cancel(){let e=this.drawingPoints;if(e&&e.length>0&&(e.pop(),0===e.length&&(this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=!0),this.lastMoveEvent)){let e=this.getIntersections(this.lastMoveEvent)[0];e&&this.onMouseMove(e.point)}this.osnapHelper.deactivate(),this.lastMouseDownPosition=void 0}deactivate(){super.deactivate(),this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable)}setTooltipContent(){var e;let t=this.viewer.translate;if(!t)return;let n=t("Tooltip.measure");n&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(n))}},Jf=class extends Dr{constructor(e,t,n){super(e,t),this.type="Area",this.scale=n,this.update(t)}draw(e,t){let n=this.points;if(e.save(),e.lineWidth=Dr.LINE_WIDTH,e.strokeStyle=Dr.MAJOR_COLOR,e.fillStyle=Dr.AREA_FILL_COLOR,e.beginPath(),n.forEach(((n,i)=>{let r=this.transToScreenCoord(n,t);0===i?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.closePath(),e.fill(),e.stroke(),e.restore(),this.drawing){let n=1===this.points.length?this.points:this.points.slice(0,this.points.length-1);this.drawPoints(e,t,n)}this.drawText(e,t)}drawText(e,t){if(this.points.length<3)return;let n=this.points,i=this.calculateArea(n);this.scale&&(i*=Math.pow(this.scale,2)),this.label=`${Bu(i,2)}`,this.labelPositon=this.transToScreenCoord(this.getBarycenter(n),t),super.drawText(e,t)}calculateArea(e){let t=0,n=Fm.getFaces(e);for(let i=0;i{n+=e.x,i+=e.y,r+=e.z})),new O(n/t,i/t,r/t)}isPointInPath(e,t){let n=null==t?void 0:t.ray;if(!n)return!1;let i=this.transToScreenCoord(e,t.camera);if(this.labelBounds.containsPoint(i))return!0;let r=3*this.tolerance,a=new O,s=new O,o=this.points;for(let h=0;h2&&this.drawingPoints[0]){let t=this.drawingPoints[0];ove.subVectors(e,t).length()<3*this.viewer.getPixelSizeInWorldCoord()&&(this.osnapHelper.activateMarker(1,{point:t,type:1,distance:0}),se.info("[AreaMeasurement] auto close area measurement."))}}onMouseClick(e){var t,n;if(super.onMouseClick(e),this.clickedOnMeasurementDrawable)return;this.drawingPoints||(this.drawingPoints=[]);let i=this.drawingPoints;if(2===e.button)return void this.exitDrawing();let r=this.getIntersections(e)[0];if(!r)return void se.warn("[Measure] No intersection found!");let a=null!=(n=null==(t=this.snapPoint)?void 0:t.clone())?n:null==r?void 0:r.point.clone();if(this.drawingPoints&&this.drawingPoints.length>2&&this.drawingPoints[0]){let e=this.drawingPoints[0];if(ove.subVectors(a,e).length()<3*this.viewer.getPixelSizeInWorldCoord())return se.info("[AreaMeasurement] auto close area measurement."),this.touchDowned=!1,void this.exitDrawing()}this.drawingPoints[0]&&Zt.areVector3sEqual(this.drawingPoints[0],a)||(i.push(a),this.lastMouseDownPosition=a,1===i.length&&(this.dispatchEvent("FirstPointPicked"),this.completed=!1),this.createOrUpdateMeasureDrawable())}exitDrawing(){let e=this.drawingPoints||[],t=!0;if(e.length<3&&(se.warn("[Measure] If the number of points is less than 3, the measurement area cannot be formed !"),t=!1),t&&Fm.isSelfIntersecting(e)&&(se.warn("[Measure] The area formed by these points intersects itself, so the correct measurement cannot be obtained !"),t=!1),!t)return this.drawingPoints=void 0,this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=void 0,void(this.lastMouseDownPosition=void 0);this.createOrUpdateMeasureDrawable(),this.complete()}complete(){var e;!0!==this.completed&&(null==(e=this.currentMeasureDrawable)||e.setDrawingState(!1),this.dispatchEvent("Completed",this.currentMeasureDrawable),this.completed=!0,this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0)}cancel(){let e=this.drawingPoints;if(e&&e.length>0&&(e.pop(),0===e.length&&(this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=!0),this.lastMoveEvent)){let e=this.getIntersections(this.lastMoveEvent)[0];e&&this.onMouseMove(e.point)}this.osnapHelper.deactivate(),this.lastMouseDownPosition=void 0}setTooltipContent(){var e;let t=this.viewer.translate;if(t){let n=t("Tooltip.areaMeasurement");n&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(n))}}getScale(){return this.scale}setScale(e){this.scale=e;let t=this.drawList.getDrawables();for(let n of t){let t=n[1];t instanceof Jf&&(t.scale=e)}}},y_=class extends Dr{constructor(e,t){super(e,t),this.type="Coordinate",this.update(t)}draw(e,t){this.drawText(e,t),e.save(),e.lineWidth=Dr.LINE_WIDTH,e.strokeStyle=Dr.MAJOR_COLOR,e.fillStyle=Dr.AREA_FILL_COLOR;let n=this.points;e.beginPath(),n.forEach((n=>{let i=this.transToScreenCoord(n,t);e.arc(i.x,i.y,Dr.POINT_RADIUS,0,2*Math.PI)})),e.fill(),e.stroke(),e.restore()}drawText(e,t){let n=this.points[0];Zt.areNumbersEqual(n.x,0);let i=Zt.areNumbersEqual(n.x,0)?0:n.x,r=Zt.areNumbersEqual(n.y,0)?0:n.y,a=Zt.areNumbersEqual(n.z,0)?0:n.z;this.label=`${Bu(i,2)}, ${Bu(r,2)}, ${Bu(a,2)}`,e.font=`${Dr.LABEL_FONT_SIZE}px Arial`;let s=1.2*e.measureText(this.label).width,o=1.5*Dr.LABEL_FONT_SIZE;this.labelPositon=this.transToScreenCoord(n,t),this.labelPositon.y-=o/2,this.labelBounds.setFromCenterAndSize(this.labelPositon,new be(s,o)),this.drawRoundRect(e,this.labelPositon.x-s/2,this.labelPositon.y-o/2,s,o,4),e.save(),e.fillStyle=Dr.MINOR_COLOR,e.textBaseline="middle",e.textAlign="center",e.fillText(this.label,this.labelPositon.x,this.labelPositon.y),e.restore()}getClassType(){return"Coordinate"}};Un._registerDrawableClass(y_);var PP=class extends nh{constructor(e,t,n,i){super("Coordinate",e,t,n,i)}createMeasureDrawable(){if(this.drawingPoints)return new y_(Mt.guid(),this.drawingPoints)}onMouseClick(e){var t;if(super.onMouseClick(e),this.clickedOnMeasurementDrawable)return;if(this.drawingPoints||(this.drawingPoints=[]),2===e.button)return void this.exitDrawing();let n=this.getIntersections(e)[0];if(!n)return;let i=null!=(t=this.snapPoint)?t:null==n?void 0:n.point,r=this.drawingPoints;r.push(i),this.lastMouseDownPosition=i,1===r.length&&(this.dispatchEvent("FirstPointPicked"),this.completed=!1),this.createOrUpdateMeasureDrawable(i),r.length>=1&&this.complete()}exitDrawing(){this.drawingPoints=void 0,this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=void 0,this.lastMouseDownPosition=void 0}complete(){!0!==this.completed&&(this.dispatchEvent("Completed",this.currentMeasureDrawable),this.completed=!0,this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0)}cancel(){let e=this.drawingPoints;if(e&&e.length>0&&(e.pop(),0===e.length&&(this.completed=!0),this.lastMoveEvent)){let e=this.getIntersections(this.lastMoveEvent)[0];e&&this.onMouseMove(e.point)}this.osnapHelper.deactivate(),this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0}setTooltipContent(){var e;let t=this.viewer.translate;if(t){let n=t("Tooltip.measure");n&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(n))}}},N4=class extends Dr{constructor(e,t,n){super(e,t),this.type="Distance",this.scale=n,this.update(t)}draw(e,t){let n=this.points;if(e.save(),e.lineWidth=Dr.LINE_WIDTH,e.strokeStyle=Dr.MAJOR_COLOR,e.beginPath(),n.forEach(((n,i)=>{let r=this.transToScreenCoord(n,t);0===i?e.moveTo(r.x,r.y):e.lineTo(r.x,r.y)})),e.closePath(),e.stroke(),e.restore(),this.drawing){let n=1===this.points.length?this.points:this.points.slice(0,this.points.length-1);this.drawPoints(e,t,n)}else this.selected||this.drawVerticalLine(e,t);this.drawText(e,t)}drawText(e,t){if(this.points.length<2)return;let[n,i]=this.points,r=n.distanceTo(i);this.scale&&(r*=this.scale),this.label=`${Bu(r,2)}`,this.labelPositon=this.transToScreenCoord((new O).lerpVectors(n,i,.5),t),super.drawText(e,t)}drawVerticalLine(e,t){if(this.points.length<2)return;let[n,i]=this.points.map((e=>this.transToScreenCoord(e,t))),[r,a]=this.getShortLineBySegments(n,i),[s,o]=this.getShortLineBySegments(i,n);e.save(),e.lineWidth=Dr.LINE_WIDTH,e.strokeStyle=Dr.MAJOR_COLOR,e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(a.x,a.y),e.moveTo(s.x,s.y),e.lineTo(o.x,o.y),e.stroke(),e.restore()}getShortLineBySegments(e,t){let n=(new be).subVectors(t,e).normalize(),i=N4.SHORT_LINE_LENGTH/2,r=Math.PI/2;return[n.clone().rotateAround(new be,r).normalize().multiplyScalar(i).add(e),n.clone().rotateAround(new be,-r).normalize().multiplyScalar(i).add(e)]}getClassType(){return"Distance"}setScale(e){this.scale=e}},ig=N4;ig.SHORT_LINE_LENGTH=12,Un._registerDrawableClass(ig);var IP=class extends nh{constructor(e,t,n,i){super("Distance",e,t,n,i)}createMeasureDrawable(){if(this.drawingPoints)return new ig(Mt.guid(),this.drawingPoints,this.scale)}onMouseClick(e){var t;if(super.onMouseClick(e),this.clickedOnMeasurementDrawable)return;if(this.drawingPoints||(this.drawingPoints=[]),2===e.button)return void this.exitDrawing();let n=this.getIntersections(e)[0];if(!n)return;let i=null!=(t=this.snapPoint)?t:null==n?void 0:n.point;if(this.drawingPoints[0]&&Zt.areVector3sEqual(this.drawingPoints[0],i))return;let r=this.drawingPoints;r.length<2&&r.push(i),this.lastMouseDownPosition=i,1===r.length&&(this.dispatchEvent("FirstPointPicked"),this.completed=!1),this.createOrUpdateMeasureDrawable(),r.length>=2&&this.complete()}exitDrawing(){this.drawingPoints=void 0,this.currentMeasureDrawable&&(this.removeDrawable(this.currentMeasureDrawable),this.currentMeasureDrawable=void 0),this.completed=void 0,this.lastMouseDownPosition=void 0}complete(){var e;!0!==this.completed&&(null==(e=this.currentMeasureDrawable)||e.setDrawingState(!1),this.dispatchEvent("Completed",this.currentMeasureDrawable),this.completed=!0,this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0)}cancel(){let e=this.drawingPoints;e&&e.length>0&&(e.pop(),0===e.length&&(this.completed=!0),this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable)),this.osnapHelper.deactivate(),this.drawingPoints=void 0,this.currentMeasureDrawable=void 0,this.lastMouseDownPosition=void 0}deactivate(){super.deactivate(),this.currentMeasureDrawable&&this.removeDrawable(this.currentMeasureDrawable)}setTooltipContent(){var e;let t=this.viewer.translate;if(t){let n=t("Tooltip.measure");n&&this.tooltip&&(null==(e=this.tooltip)||e.setContent(n))}}getScale(){return this.scale}setScale(e){this.scale=e;let t=this.drawList.getDrawables();for(let n of t){let t=n[1];(t instanceof ig||t instanceof Jf)&&(t.scale=e)}}},lve=class extends fr{constructor(e){var t,n;super(e,{id:"MeasurementPlugin"}),this.selectedDrawable=void 0,this.drawableList=new Ko("measure"),this.drawableHelperList=new Ko("touchHelper"),this.snapToleranceInPixel=3,this.measurements={},this.activeMeasurementType=void 0,this.keydown=e=>{var t;let n,i=this.getActiveMeasurementType();i&&(n=this.measurements[i]);let r=this.selectedDrawable;r&&"Delete"===e.code&&(this.remove(r),null==(t=this.viewer.undoRedoManager)||t.addCommand(new ry(this,r.getData())),this.activeMeasurementType&&this.measurements[this.activeMeasurementType].clearClickedDrawable()),e.ctrlKey&&"KeyZ"===e.code&&null!=n&&n.isMeasuring&&n.cancel(),e.ctrlKey&&"KeyY"===e.code&&null!=n&&n.isMeasuring};let i=e.getInputManager();if(!i)throw"InputManager init error";this.inputManager=i,this.overlayRender=this.viewer.overlayRender,null==(t=this.overlayRender)||t.addDrawableList(this.drawableHelperList),null==(n=this.overlayRender)||n.addDrawableList(this.drawableList);let r=new wP(this.overlayRender);e.is3d()&&(r.setOSnapTypeEnabled(32,!1),r.setOSnapTypeEnabled(64,!1)),this.measurements.Distance=new IP(e,i,this.drawableList,r),this.measurements.Area=new CP(e,i,this.drawableList,r),this.measurements.Angle=new AP(e,i,this.drawableList,r),this.measurements.Coordinate=new PP(e,i,this.drawableList,r),this.osnapHelper=r,this.inputManager.addEventListener("wheel",(()=>{this.updateSnapTolerance()})),this.viewer.addEventListener("LayoutChanged",(()=>{this.updateSnapTolerance()})),this.initEvents()}initEvents(){Object.values(this.measurements).forEach((e=>{e.addEventListener("Completed",(e=>{var t;this.viewer.dispatchEvent("MeasurementAdded",e.getData()),null==(t=this.viewer.undoRedoManager)||t.addCommand(new hE(this,e.getData())),this.select(e)})),e.addEventListener("WillBeAdded",(e=>{this.add(e,!1)})),e.addEventListener("Updated",(()=>{this.render()})),e.addEventListener("WillBeRemoved",(e=>{this.remove(e,!1)})),e.addEventListener("Deactivate",(()=>{this.osnapHelper.deactivate(),this.viewer.deactivateMeasurement()})),e.addEventListener("FirstPointPicked",(()=>{this.unselect()})),e.addEventListener("ClickedOnMeasurement",(e=>{this.select(e)}))}))}get canvas(){var e;return null==(e=this.viewer.renderer)?void 0:e.domElement}get raycaster(){return this.viewer.getRaycaster()}add(e,t=!0){this.drawableList.addDrawable(e),this.selectedDrawable=e,this.render(),t&&this.viewer.dispatchEvent("MeasurementAdded",e.getData())}create(e){return Un.createDrawable(e)}remove(e,t=!0){this.drawableList.removeDrawable(e),this.render(),t&&this.viewer.dispatchEvent("MeasurementRemoved",e.getData())}setSnapTolerance(e){this.snapToleranceInPixel=e,this.updateSnapTolerance()}updateSnapTolerance(){let e=this.viewer.getPixelSizeInWorldCoord()*this.snapToleranceInPixel;this.osnapHelper.setSnapTolerance(e)}activate(e){this.activeMeasurementType&&this.deactivate(),this.measurements[e]?(this.measurements[e].activate(),this.activeMeasurementType=e,this.updateSnapTolerance()):(this.activeMeasurementType=void 0,se.error("[Measure] Failed to activate measurement, type:",e));let{width:t,height:n}=this.canvas.getBoundingClientRect();Dn.isMobile&&this.canvas&&!this.mobileTouchHelper&&(this.mobileTouchHelper=new RP(new be(t/2,n/2)),this.drawableHelperList.addDrawable(this.mobileTouchHelper)),this.mobileTouchHelper&&(this.mobileTouchHelper.setPosition(new be(t/2,n/2)),this.measurements[e].setTouchHelper(this.mobileTouchHelper),this.mobileTouchHelper.visible=!0,this.render()),this.inputManager.addEventListener("keydown",this.keydown)}deactivate(){this.unselect();let e=this.activeMeasurementType;e&&this.measurements[e].deactivate(),this.activeMeasurementType=void 0,this.mobileTouchHelper&&(this.mobileTouchHelper.visible=!1,this.render()),this.inputManager.removeEventListener("keydown",this.keydown)}getActiveMeasurementType(){return this.activeMeasurementType}isActive(){let e=this.activeMeasurementType;return e?this.measurements[e].isActive:!!this.getActiveMeasurementType()}isMeasuring(){let e=this.activeMeasurementType;return!!e&&this.measurements[e].isMeasuring}getData(){return this.drawableList.getDrawableDatas()}cancel(){let e=this.activeMeasurementType;e&&this.measurements[e].exitDrawing()}setData(e){var t,n;null==(t=this.viewer.undoRedoManager)||t.startTransaction(),e.forEach((e=>{var t;this.measurements[e.type]?e.points.length>=2?(this.add(Un.createDrawable(e)),null==(t=this.viewer.undoRedoManager)||t.addCommand(new hE(this,e))):se.info("[Measure] Invalid points found in MeasurementData:",e):se.warn("[Measure] Failed to add measurement data for",e)})),null==(n=this.viewer.undoRedoManager)||n.endTransaction()}setVisibilityById(e,t){let n=this.drawableList.getDrawables().get(e);return!!n&&(n.visible!==t&&(n.visible=t,this.render()),!0)}setVisibilities(e){let t=!1;this.drawableList.getDrawables().forEach((n=>{n.visible!==e&&(n.visible=e,t=!0)})),t&&this.render()}clear(){let e=this.activeMeasurementType;e&&this.measurements[e].exitDrawing(),this.drawableList.clear(),this.render()}getById(e){return this.drawableList.getDrawableById(e)}removeById(e){let t=this.drawableList.getDrawableById(e);t?this.remove(t):se.warn("[Measure] Failed to find measurement by id:",e)}selectById(e){let t=this.drawableList.getDrawableById(e);t&&this.select(t)}select(e){this.unselect(!1),e.selected=!0,this.selectedDrawable=e,this.render()}unselect(e=!0){this.selectedDrawable&&(this.selectedDrawable.selected=!1,e&&this.render()),this.selectedDrawable=void 0}getScale(){return this.measurements.Distance.getScale()}setScale(e){if(!e||e<=0)return void se.error("[Measure] Invalid scale value:",e);let t=this.measurements.Distance,n=this.measurements.Area;t.setScale(e),n.setScale(e)}destroy(){super.destroy(),this.deactivate(),this.clear(),this.drawableHelperList.clear(),this.measurements={},this.osnapHelper.destroy(),this.render()}render(e=!1){var t;e?this.viewer.enableRender():null==(t=this.overlayRender)||t.render()}},Oy=new et,cve=new et,uve=new ya,B4=new O,ky=new Ot,hve=new ct,Qf=class extends Zf{constructor(e){super(e),this.name="DxfViewer",this.CAMERA_Z_POSITION=100,this.CAMERA_MIN_ZOOM=1e-6,this.timer=Date.now(),this.loadedModels=[],this.masterModelId="",this.raycaster=new ia,this.selected=!0,this.raf=new qf,this.clock=new mo,this.renderEnabled=!1,this.enableHideVisuallySmallObjects=!0,this.sortedHidableObjects={},this.lastCameraZoom=1/0,this.lastFrame=-1,this.activeLayoutName="",this.layoutInfos={},this.units=void 0,this.fpsUtils=new LA,this.onResize=()=>{this.viewerContainer&&this.viewerContainer&&this.resize(this.viewerContainer.clientWidth,this.viewerContainer.clientHeight)},this.enableRender=(e=1e3)=>{this.renderEnabled=!0,this.raf&&(this.timeoutSymbol&&this.raf.clearTimeout(this.timeoutSymbol),this.timeoutSymbol=this.raf.setTimeout((()=>{this.renderEnabled=!1}),e))},this.loadingDxfCount=0,this.compareMode=!1,this.viewerCfg=e,this.increaseJobCount(),this.init(),this.animate(),this.enableRender(),this.decreaseJobCount(),se.info(`[Viewer] Initialized in ${(Date.now()-this.timer)/1e3}s`)}init(){let e=this.viewerCfg;this.initThree(),Dn.isBrowser&&!e.context&&this.initDom(),this.initInputManager(),this.initEvents(),this.initControls(),this.initOthers(),this.enableSelection=e.enableSelection}initInputManager(){this.viewerContainer&&(this.inputManager=new Jo(this.viewerContainer))}initThree(){this.initScene(),this.initRenderer(),this.initCamera()}initDom(){let e=this.viewerCfg;this.initSpinner(),this.initCSS2DRenderer(),!0===e.enableAxisGizmo&&console.warn("[Viewer] enableAxisGizmo is deprecated, use AxisGizmoPlugin instead!"),!0===e.enableStats&&console.warn("[Viewer] enableStats is deprecated, use StatsPlugin instead!"),e.enableToolbar&&console.warn("[Viewer] enableToolbar is deprecated, use ToolbarPlugin instead!"),e.enableBottomBar&&console.warn("[Viewer] enableBottomBar is deprecated, use BottomBarPlugin instead!"),e.enableProgressBar&&(this.loadingProgressBar=this.initLoadingProgressBar()),e.enableLayoutBar&&(this.dxfLayoutBar=new tP(this))}initScene(){let e=new _i;e.background=new ct(2172976),e.matrixAutoUpdate=!1,e.matrixWorldAutoUpdate=!1,this.scene=e}initRenderer(){var e;let{context:t}=this.viewerCfg,n={context:t,antialias:!0,preserveDrawingBuffer:!0,alpha:!1,stencil:!1};!Dn.isBrowser&&t&&Object.assign(n,{context:t,canvas:Dn.creatReactNativeCanvas(t)}),t&&(this.width=t.drawingBufferWidth,this.height=t.drawingBufferHeight),this.renderer=new Ms(n),this.renderer.setClearColor(11119017,1),this.renderer.localClippingEnabled=!0,Dn.isBrowser&&(!t&&this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.classList.add("webgl-renderer"),null==(e=this.viewerContainer)||e.appendChild(this.renderer.domElement)),this.renderer.setSize(this.width,this.height),Mt.printGpuInfo(this.renderer.getContext()),gn.maxFragmentUniforms=this.renderer.capabilities.maxFragmentUniforms-20,this.enableOverlayRenderer&&(this.overlayRender=new Un(this))}initCSS2DRenderer(){var e;let t=new Nu;t.setSize(this.width,this.height),t.domElement.style.height="0",t.domElement.style.width="0",t.domElement.style.position="absolute",t.domElement.style.top="0",t.domElement.style.left="0",t.domElement.style.overflow="visible",t.domElement.classList.add("css2d-renderer"),null==(e=this.viewerContainer)||e.appendChild(t.domElement),this.css2dRenderer=t}initCamera(){if(!this.scene)return;let e=new Ur(-this.width/2,this.width/2,this.height/2,-this.height/2,.1,1e5);e.position.set(0,0,this.CAMERA_Z_POSITION),e.zoom=10,e.updateProjectionMatrix(),this.scene.add(e),this.camera=e,this.frustumSize=this.width}initControls(){let e=this.camera;if(!this.inputManager||!e)return;let t=new ba(e,this.inputManager);t.enableRotate=!1,t.enabled=!0,t.keyTruckSpeed=10,t.dollyToCursor=!0,t.dollySpeed=.5,t.truckSpeed=1,t.mouseButtons={left:yt.TRUCK,middle:yt.TRUCK,wheel:yt.ZOOM,right:yt.TRUCK},t.touches={one:yt.TOUCH_TRUCK,two:yt.TOUCH_ZOOM_TRUCK,three:yt.NONE},t.listenToKeyEvents(),t.update(0),this.controls=t,t.addEventListener("control",this.onControlsChange(this))}onControlsChange(e){return()=>{this.updateHidableObjectsVisibility(),e.enableRender()}}initEvents(){if(!this.inputManager||!this.renderer)return;let e=!1,t=!1;this.inputManager.addEventListener("pointerdown",(n=>{var i;t=!1,e=!0,1===n.button&&(null==(i=this.inputManager)||i.setCursor("move"))})),this.inputManager.addEventListener("pointermove",(()=>{var n;e&&(t=!0,null==(n=this.inputManager)||n.setCursor("move"))})),this.inputManager.addEventListener("pointerup",(n=>{var i;if(e=!1,null==(i=this.inputManager)||i.setCursor("default"),t)return void(t=!1);this.handleMouseClick(n);let r={evt:n};if(this.selectedObject&&this.selectedObject instanceof wi&&(r.markupData=this.selectedObject.getData()),this.selectedObject&&this.selectedObject instanceof Dr&&(r.measureData=this.selectedObject.getData()),this.selectedObject&&this.selectedObject instanceof an){let e=t=>t.parent&&!t.parent.isScene?e(t.parent):t.name;r.entityData={modelId:e(this.selectedObject),layerName:this.selectedObject.userData.layerName}}this.dispatchEvent("MouseClicked",r)})),this.inputManager.addEventListener("keydown",(e=>{var t,n,i,r,a;if(e.altKey&&"KeyR"===e.code)this.flyToRandomObject();else if(e.ctrlKey&&"KeyZ"===e.code){if(this.measurePlugin&&this.measurePlugin.isMeasuring())return;null==(t=this.undoRedoManager)||t.undo()}else if(e.ctrlKey&&"KeyY"===e.code){if(this.measurePlugin&&this.measurePlugin.isMeasuring())return;null==(n=this.undoRedoManager)||n.redo()}else"Delete"===e.code&&this.selectedObject&&(this.markupManager&&this.selectedObject instanceof wi&&(this.markupManager.removeMarkup(this.selectedObject),null==(i=this.undoRedoManager)||i.addCommand(new zm(this.markupManager,this.selectedObject.getData()))),this.measurePlugin&&this.selectedObject instanceof Dr&&(null==(r=this.measurePlugin)||r.remove(this.selectedObject),null==(a=this.undoRedoManager)||a.addCommand(new ry(this.measurePlugin,this.selectedObject.getData()))))}))}initOthers(){!this.scene||!this.renderer||!this.camera||(this.renderer.domElement.style.outlineWidth="0")}initLoadingProgressBar(){return new Gf(this.widgetContainer)}showLayoutBar(){var e;null==(e=this.dxfLayoutBar)||e.show()}hideLayoutBar(){var e;null==(e=this.dxfLayoutBar)||e.hide()}animate(){var e,t,n;if(this.minFrameInterval>0&&Date.now()-this.lastFrameExecuteTime{var n;null==(n=this.loadingProgressBar)||n.updateProgress(o,l,e),t&&t(new ProgressEvent("LoadProgress",{loaded:e,total:100}))},c=(e,n,i)=>{var r;let a=100*e.loaded/e.total;a=a*(i-n)/100+n,null==(r=this.loadingProgressBar)||r.updateProgress(o,l,a),t&&t(new ProgressEvent("LoadProgress",{loaded:a,total:100}))};null==(n=this.loadingProgressBar)||n.addProgressItem(o),h(0);let u={ignorePaperSpace:a,enableLocalCache:this.viewerCfg.enableLocalCache,enableMerge:e.merge,encoding:e.encoding,overrideColor:e.overrideColor},d=yield s.loadDxfData(e.src,e.modelId,(e=>c(e,0,90)),void 0,u).finally((()=>{this.loadingDxfCount--,0===this.loadingDxfCount&&this.fontManager&&this.fontManager.releaseFontData()}));if(se.info(`[Viewer] Loaded '${e.src}' in ${(Date.now()-this.timer)/1e3}s, adding to scene...`),gn.abortJobs&&Promise.reject("[Viewer] abort load dxf"),0===d.threejsObject.children.length){let t=`[Viewer] Nothing was loaded from ${e.src}`;return se.warn(t),this.decreaseJobCount(),Promise.reject(t)}let p=d.threejsObject;p.name=r;let f=this.getDxfUnits(d);if(this.masterModelId===e.modelId&&(this.units=f),se.info(`[Viewer] Units of '${e.src}' is '${f}'`),e.matrix&&16===e.matrix.length){let t=new et;t.elements=e.matrix,p.applyMatrix4(t)}return this.addModel({modelId:r,dxfData:d}),Mt.printMemory("After addModel()"),se.info(`[Viewer] Added '${e.src}' to scene in ${(Date.now()-this.timer)/1e3}s`),this.decreaseJobCount(),h(100),null==(i=this.loadingProgressBar)||i.delayRemoveProgressItem(o),this.dispatchEvent("ModelLoaded"),Promise.resolve()}))}unloadDxf(){throw new Error("Not implemented yet!")}addModel(e){if(!this.scene||!this.camera)return;let{dxfData:t,pdfData:n}=e,i=this.getUniqueModelId(e.modelId);if(this.masterModelId||(this.masterModelId=i),t){let e=t.threejsObject;e.name=i;let n={modelId:i,dxfData:t};this.loadedModels.push(n),e.matrixAutoUpdate=!1,e.updateMatrix(),e.updateMatrixWorld(!0),gn.computeLineDistances(e),this.getMsTransformMatrix(i),this.masterModelId===i?this.activateLayout(gn.MODEL_LAYOUT_NAME):this.handleOverlayDxf(i),se.debug("[Viewer] dxfData:",t),this.scene.add(e);let r=null==t?void 0:t.threejsObject.children.find((e=>e.name===gn.MODEL_LAYOUT_NAME));r&&this.setLayoutHidableObjectArray(r),this.updateGroundPlane(),this.raycastableObjects=void 0,this.masterModelId===i||this.enableRender()}else if(n){let t=n.threejsObject;this.activeLayoutName=gn.MODEL_LAYOUT_NAME;let i=(new Ot).setFromObject(t);this.layoutInfos[this.activeLayoutName]={homeViewExtent:i,extent:i},this.loadedModels.push(e),t.matrixAutoUpdate=!1,this.scene.add(t);let r=i.max.z;r>this.camera.position.z&&(this.camera.position.z=r,this.camera.updateProjectionMatrix()),this.updateGroundPlane(),this.flyToObject(t)}}isCompareMode(){return this.compareMode}compare(e,t,n,i){return ft(this,null,(function*(){var r,a,s,o;let{src:l,modelId:h}=e,{src:c}=t;if(this.compareMode)return Promise.reject("[Viewer] It is already under comparing mode!");if(this.masterModelId||this.loadedModels.length>0)return Promise.reject("[Viewer] Shouldn't load anything else before compare!");if(this.compareMode=!0,this.timer=Date.now(),this.increaseJobCount(),!this.fontManager)return Promise.reject("[Viewer] Should set font first!");let u={ignorePaperSpace:!0,encoding:e.encoding},d=new gn(this.loadingManager,u);d.setFont(this.fontManager);let p=l+c,f=this.translate("ProgressBar.Comparing"),m=e=>{var t;null==(t=this.loadingProgressBar)||t.updateProgress(p,f,e),i&&i(new ProgressEvent("CompareProgress",{loaded:e,total:100}))},g=(e,t,n)=>{var r;let a=100*e.loaded/e.total;a=a*(n-t)/100+t,null==(r=this.loadingProgressBar)||r.updateProgress(p,f,a),i&&i(new ProgressEvent("CompareProgress",{loaded:a,total:100}))};Mt.printMemory("Before comparing"),this.masterModelId=h||l,this.loadingDxfCount+=2,null==(r=this.loadingProgressBar)||r.addProgressItem(p),m(0);let v=Date.now(),y=yield d.parse(l,(e=>g(e,0,15))),x=yield d.parse(c,(e=>g(e,15,30))),[b,_]=yield Promise.allSettled([y,x]);if("rejected"===b.status)return Promise.reject(`[Viewer] Failed to parse ${l}`);if("rejected"===_.status)return Promise.reject(`[Viewer] Failed to parse ${c}`);if(se.info(`[Viewer] loadFiles in ${(Date.now()-v)/1e3}s`),gn.abortJobs)return Promise.reject("[Viewer] compare loadFile aborted");let w=b.value,S=_.value;v=Date.now();let M=yield new hs(w,S,n).compare((e=>g(e,30,60)));if(se.info(`[Viewer] Compared in ${(Date.now()-v)/1e3}s`),se.debug("[Viewer] Compared results:",M),gn.abortJobs)return Promise.reject("[Viewer] compare change aborted");Mt.printMemory("After getting the comparison results"),v=Date.now(),yield d.loadEntitiesForCompare(w,S,M,!0,(e=>g(e,60,95))),Mt.printMemory("After Creating threejs objects based on comparison result"),this.fontManager.releaseFontData(),this.changes=M,se.info(`[Viewer] Creates threejs objects based on comparison result in ${(Date.now()-v)/1e3}s`);let T=w,E=S;if(this.loadingDxfCount-=2,this.decreaseJobCount(),Object.keys(M).length||se.info("[Viewer] No change found"),0===(null==(a=T.threejsObject)?void 0:a.children.length)&&0===(null==(s=E.threejsObject)?void 0:s.children.length)){let e=`[Viewer] Nothing was loaded from ${l} and ${c}`;return se.warn(e),Promise.reject(e)}let A=T.threejsObject,C=E.threejsObject;return A.name=l,C.name=c,v=Date.now(),this.addModel({modelId:e.modelId||e.src,dxfData:T}),Mt.printMemory("After adding first loaded Model to scene"),m(95),this.addModel({modelId:t.modelId||t.src,dxfData:E}),Mt.printMemory("After adding second loaded Model to scene"),se.info(`[Viewer] Added compared objects to scene in ${(Date.now()-v)/1e3}s`),se.info(`[Viewer] The comparison between ${l}' and '${c}' is completed in ${(Date.now()-this.timer)/1e3}s !`),m(100),null==(o=this.loadingProgressBar)||o.delayRemoveProgressItem(p),Promise.resolve()}))}getEntitiesCount(){let e=0;return this.loadedModels.forEach((t=>{var n,i;e+=(null==(n=t.dxfData)?void 0:n.loadedEntityCount)||(null==(i=t.pdfData)?void 0:i.loadedEntityCount)||0})),e}getLoadedDxfModelIds(){return this.loadedModels.map((e=>e.modelId))}getLayoutNames(){let e=[];return this.getLayouts().forEach((t=>{e.push(t.layoutName)})),e}getLayouts(){let e=[],t=this.loadedModels.find((e=>this.masterModelId===e.modelId));if(t){let n=t.dxfData,i=null==n?void 0:n.objects.LAYOUT;null==i||i.forEach((t=>{e.push(t)}))}return e}handleOverlayDxf(e){var t;let n=this.loadedModels.find((t=>e===t.modelId));if(!n)return void se.warn(`[Viewer] Can't find model for modelId '${e}'!`);this.increaseJobCount(),this.switchTransformMs(gn.MODEL_LAYOUT_NAME,e);let i=null==(t=n.dxfData)?void 0:t.threejsObject,r=null==i?void 0:i.children.find((e=>e.name===gn.MODEL_LAYOUT_NAME));r&&r.traverse((e=>{this.addSpatialFilterSection(e,n.dxfData)})),this.showLayoutObjects(this.activeLayoutName),this.decreaseJobCount()}activateLayout(e){var t,n,i,r;if(this.increaseJobCount(),0==e.length)return se.warn("[Viewer] layout name is empty !"),void this.decreaseJobCount();if(e===this.activeLayoutName)return void this.decreaseJobCount();let a=Date.now(),s=this.camera,o=this.getLayoutByName(e);if(!o)return se.warn(`[Viewer] Can't find layout of ${e} !`),void this.decreaseJobCount();let l=this.loadedModels.find((e=>this.masterModelId===e.modelId));if(!l)return se.warn(`[Viewer] Can't find master model for modelId '${this.masterModelId}'!`),void this.decreaseJobCount();if(this.raycastableObjects=void 0,this.activeLayoutName){let e=this.getActiveLayoutInfo();e.lastCameraPosition||(e.lastCameraPosition=new O),null==(t=this.camera)||t.getWorldPosition(e.lastCameraPosition),this.controls.update(0),e.lastCameraZoom=s.zoom}if(!(e=>{let t=this.layoutInfos[e];return!(null==t||!t.lastCameraZoom)})(e)){this.switchTransformMs(e,this.masterModelId);let t=this.getLayoutViewports(o),r=[];t.length>0&&(r=t[0].frozenLayerHandles);let a=e!==gn.MODEL_LAYOUT_NAME,s=null==(n=l.dxfData)?void 0:n.threejsObject,h=null==s?void 0:s.children.find((t=>t.name===e));if(h){let t=[],n=null==(i=l.dxfData)?void 0:i.layersAndThreejsObjects;h.traverse((i=>{this.addSpatialFilterSection(i,l.dxfData);let s=i;if(a&&s.material&&s.geometry){let i=s.userData.layerName;if(!this.isLayerFrozenForViewport(l.dxfData,i,r))return;t.push(s);let a=-1;n&&n[i]&&(a=n[i].indexOf(s),a>=0&&n[i].splice(a,1)),a<0&&se.warn(`[Viewer] Failed to find object for modelId '${this.masterModelId}', layer '${i}', layout '${e}'`)}})),t.forEach((e=>{e.removeFromParent()}))}let c=this.getFilteredViewports(o);se.debug("[Viewer] Active layout:",e,", viewports:",c);let u=Date.now(),d=this.CAMERA_Z_POSITION/10,p=0;c.forEach((t=>{var n;this.generateObjectsByViewport(e,t,l.dxfData);let i=null==(n=null==t?void 0:t.msToPsMatrix)?void 0:n.elements[14];i&&i>p&&(p=i)}));let f=this.controls,m=f.getPosition(new O);if(p>m.z+d){let e=Math.ceil(p+d);se.info(`[Viewer] Changing camera's z value from ${m.z} to ${e}`);let t=f.getTarget(new O);m.setZ(e),f.setLookAt(m.x,m.y,m.z,t.x,t.y,t.z)}se.info(`[Viewer] generateObjectsByViewport in ${(Date.now()-u)/1e3}s`),e!==gn.MODEL_LAYOUT_NAME&&this.switchTransformMs(gn.MODEL_LAYOUT_NAME,this.masterModelId),e!==gn.MODEL_LAYOUT_NAME&&h&&this.setLayoutHidableObjectArray(h)}this.measurePlugin&&this.clearMeasurements(),this.markupManager&&this.clearMarkups(),null==(r=this.undoRedoManager)||r.clear(),this.showLayoutObjects(e),this.activeLayoutName=e;let h=this.getActiveLayoutInfo();if(h.lastCameraPosition)this.goTo(h.lastCameraPosition,h.lastCameraZoom,!1);else{h.extent=this.computeBoundingBox();let e=this.getLayoutExtentEx(o);if(e){let t=e.max.x-e.min.x,n=e.max.y-e.min.y;(t<1e-16||n<1e-16||t>1e16||n>1e16)&&(se.warn(`[Viewer] Got wired bbox, max: ${e.max.toArray()}, min: ${e.min.toArray()}, going to use the calculated one...`),e=h.extent)}else se.warn("[Viewer] Failed to get layout extent, going to use the calculated one..."),e=h.extent;h.homeViewExtent=e,this.zoomToBBox(e)}this.updateGroundPlane(),this.dispatchEvent("LayoutChanged"),Mt.printMemory(`After activated layout '${this.activeLayoutName}'`),this.enableRender(),this.decreaseJobCount(),se.info(`[Viewer] Activated layout '${e}' in ${(Date.now()-a)/1e3}s`)}cancelAllOperations(){var e,t,n,i,r,a;null!=(e=this.measurePlugin)&&e.isActive()&&(null==(t=this.measurePlugin)||t.deactivate()),null!=(n=this.markupManager)&&n.isMarkupActive()&&(null==(i=this.markupManager)||i.deactivate()),null!=(r=this.zoomToRectHelper)&&r.isActive()&&(null==(a=this.zoomToRectHelper)||a.deactivate())}getActiveLayoutName(){return this.activeLayoutName}getLayers(){var e,t,n,i,r,a;let s=[];if(this.masterModelId){let i=this.loadedModels.find((e=>this.masterModelId===e.modelId)),r=(null==(t=null==(e=null==i?void 0:i.dxfData)?void 0:e.tables)?void 0:t.layer.layers)||(null==(n=null==i?void 0:i.pdfData)?void 0:n.layers);r&&s.push({modelId:this.masterModelId,layers:r})}for(let o of this.loadedModels){let e=o.modelId;if(e===this.masterModelId)continue;let t=(null==(r=null==(i=null==o?void 0:o.dxfData)?void 0:i.tables)?void 0:r.layer.layers)||(null==(a=o.pdfData)?void 0:a.layers);t&&s.push({modelId:e,layers:t})}return s}setModelVisibility(e,t){let n=this.loadedModels.find((t=>e===t.modelId)),i=(null==n?void 0:n.dxfData)||(null==n?void 0:n.pdfData);if(!n||!i)throw new Error(`Failed to find model by modelId '${e}'!`);i.threejsObject.visible=t,this.enableRender()}setLayerVisibility(e,t,n){var i;let r=this.camera;n=n||this.masterModelId;let a=this.loadedModels.find((e=>n===e.modelId));if(!a)throw new Error(`Failed to find layer by modelId '${n}'!`);let s=a.dxfData||a.pdfData,o=(null==(i=s.tables)?void 0:i.layer.layers[e])||s.layers[e];o?o.visible=t:se.warn(`[Viewer] Layer '${e}' not found from modelData!`);let l=(null==s?void 0:s.layersAndThreejsObjects)&&(null==s?void 0:s.layersAndThreejsObjects[e]);if(l){let e=r.zoom;for(let n=0;nn===e.modelId));if(!r)throw new Error(`Failed to find layer by modelId '${n}'!`);let a=r.dxfData||r.pdfData;if(!(null==(i=a.tables)?void 0:i.layer.layers[e])&&!a.layers[e])throw new Error(`Failed to find layer by layerName '${e}'!`);this.clearSelection();let s=(null==a?void 0:a.layersAndThreejsObjects)&&(null==a?void 0:a.layersAndThreejsObjects[e]);s?s.forEach((e=>{let n=e;if(n.material){n.userData.originalMaterial||(n.userData.originalMaterial=es.cloneMaterial(n.material));let e=es.cloneMaterial(n.material);es.setMaterialColor(e,new ct(t)),gn.updateMaterialUniforms(e),n.material=e}})):se.info(`[Viewer] No object found for layer '${e}'`),this.enableRender()}resetLayerColor(e,t){var n;t=t||this.masterModelId;let i=this.loadedModels.find((e=>t===e.modelId));if(!i)throw new Error(`Failed to find model by modelId '${t}'!`);let r=i.dxfData||i.pdfData;if(!(null==(n=r.tables)?void 0:n.layer.layers[e])&&!r.layers[e])throw new Error(`Failed to find layer by layerName '${e}'!`);this.clearSelection();let a=(null==r?void 0:r.layersAndThreejsObjects)&&(null==r?void 0:r.layersAndThreejsObjects[e]);a?a.forEach((e=>{let t=e;t.material&&t.userData.originalMaterial&&(t.material.dispose(),t.material=t.userData.originalMaterial,delete t.userData.originalMaterial)})):se.info(`[Viewer] No object found for layer '${e}'`),this.enableRender()}setFont(e){return ft(this,null,(function*(){this.increaseJobCount();let t=Date.now();this.fontManager||(this.fontManager=new ud),yield this.fontManager.loadFonts(e),this.decreaseJobCount(),se.info(`[Viewer] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}getFont(){return this.fontManager}setLoadingManager(e){this.loadingManager=e}setDisplayLengthUnits(){throw new Error("Not implemented yet!")}setDisplayAreaUnits(){throw new Error("Not implemented yet!")}setDisplayPrecision(){throw new Error("Not implemented yet!")}getCurrentViewExtent(){return{min:this.getHitResultByNdcCoordinate({x:-1,y:-1}),max:this.getHitResultByNdcCoordinate({x:1,y:1})}}getScreenshot(){return ft(this,arguments,(function*(e="BoxSelection"){this.cancelAllOperations();let t=this.findPlugin("ScreenshotPlugin");if(t)return t.getScreenshotAsync(e);se.warn("[DxfViwer] ScreenshotPlugin doesn't seem to be installed!")}))}get measurePlugin(){return this.plugins.find((e=>"MeasurementPlugin"===e.id))}activateMeasurement(e){this.cancelAllOperations();let t=this.measurePlugin;t?(t.activate(e),this.clearSelection(),this.dispatchEvent("MeasurementActivated")):se.warn("[Viewer] MeasurementPlugin doesn't seem to be installed!")}deactivateMeasurement(){var e;null==(e=this.measurePlugin)||e.deactivate(),this.dispatchEvent("MeasurementDeactivated")}getActiveMeasurementType(){var e;return null==(e=this.measurePlugin)?void 0:e.getActiveMeasurementType()}getMeasurements(){var e;return(null==(e=this.measurePlugin)?void 0:e.getData())||[]}cancelMeasurement(){var e;null==(e=this.measurePlugin)||e.cancel()}setMeasurements(e){let t=this.measurePlugin;t&&(this.clearMeasurements(),t.setData(e))}selectMeasurement(e){var t;null==(t=this.measurePlugin)||t.selectById(e)}unselectMeasurement(){var e;null==(e=this.measurePlugin)||e.unselect()}removeMeasurement(e){var t;null==(t=this.measurePlugin)||t.removeById(e)}setMeasurementVisibility(e,t){let n=this.measurePlugin;return!!n&&n.setVisibilityById(e,t)}clearMeasurements(){var e;null==(e=this.measurePlugin)||e.clear()}getMarkupManager(){return this.markupManager}activateMarkup(e){this.cancelAllOperations(),this.inputManager&&(this.markupManager||(this.markupManager=new dE(this,this.inputManager)),this.markupManager.isMarkupActive()||this.markupManager.activate(),this.markupManager.setDrawType(e),this.clearSelection(),this.dispatchEvent("MarkupActivated"))}deactivateMarkup(){this.markupManager&&this.markupManager.deactivate(),this.dispatchEvent("MarkupDeactivated")}getActiveMarkupType(){var e;return null==(e=this.markupManager)?void 0:e.getActiveMarkupType()}setMarkupLineColor(e,t,n,i){var r;null==(r=this.markupManager)||r.setLineColor([e,t,n,i])}getMarkupLineColor(){var e;return null==(e=this.markupManager)?void 0:e.getLineColor()}setMarkupFillColor(e,t,n,i){var r;null==(r=this.markupManager)||r.setFillColor([e,t,n,i])}getMarkupFillColor(){var e;return null==(e=this.markupManager)?void 0:e.getFillColor()}setMarkupLineWidth(e){var t;null==(t=this.markupManager)||t.setLineWidth(e)}getMarkupLineWidth(){var e;return null==(e=this.markupManager)?void 0:e.getLineWidth()}setMarkupFontSize(e){var t;null==(t=this.markupManager)||t.setFontSize(e)}getMarkupFontSize(){var e;return null==(e=this.markupManager)?void 0:e.getFontSize()}getMarkups(){var e;return(null==(e=this.markupManager)?void 0:e.getMarkupData())||[]}setMarkups(e){this.inputManager&&(this.clearMarkups(),this.markupManager||(this.markupManager=new dE(this,this.inputManager)),this.markupManager.setMarkupData(e))}setMarkupVisibility(e,t){return!!(this.inputManager&&this.markupManager&&e)&&this.markupManager.setMarkupVisibility(e,t)}updateMarkup(e){if(!(this.inputManager&&this.markupManager&&e&&e.id))return!1;let t=!1,n=this.markupManager,i=n.getMarkupById(e.id);return i&&(n.updateMarkup(i,e),t=!0),t}removeMarkup(e){return!(!this.inputManager||!this.markupManager)&&this.markupManager.removeMarkupById(e)}clearMarkups(){var e;null==(e=this.markupManager)||e.clearAll()}getHitResult(e){let t=this.viewerContainer;if(!this.camera||!this.raycaster||!this.groundPlane)return;let n=cn.getScreenPointByEvent(e,t),i=cn.screenPoint2NdcPoint(n,this.camera,t);return this.getHitResultByNdcCoordinate(i)}getHitResultByNdcCoordinate(e){if(!this.camera||!this.raycaster||!this.groundPlane)return;this.raycaster.setFromCamera(e,this.camera),this.raycaster.layers.set(10);let t=this.raycaster.intersectObject(this.groundPlane,!0);return t&&t.length>0?t[0].point:void 0}zoomToRect(){this.cancelAllOperations(),this.zoomToRectHelper||(this.zoomToRectHelper=new Dy(this)),this.zoomToRectHelper.activate()}deactivateZoomRect(){var e;null==(e=this.zoomToRectHelper)||e.deactivate()}getLayoutByName(e){let t,n=this.getLayouts();for(let i of n)if(i.layoutName===e){t=i;break}return t}getActiveLayoutInfo(){return this.getLayoutInfo(this.activeLayoutName)}getMsTransformMatrix(e){var t,n;let i=this.loadedModels.find((t=>e===t.modelId)),r=null==(t=null==i?void 0:i.dxfData)?void 0:t.header;if(!r)return;let a=r.$ANGDIR,s=this.getDxfUnits(i.dxfData),o=null==(n=i.dxfData)?void 0:n.tables.viewport.viewports.filter((e=>"*ACTIVE"===e.name.toLocaleUpperCase()));if(!o)return;let l=new et,h=gn.getDcs2WcsMatrix(o[0],a),c=new O(o[0].center.x,o[0].center.y,0).applyMatrix4(h),u=1;this.units&&s!==this.units&&(u=dme(s,this.units)),c.multiplyScalar(u),l.makeTranslation(c.x,c.y,0);let d=o[0].viewTwistAngle;null!=d&&l.multiply((new et).makeRotationZ(An.degToRad(d))),l.multiply((new et).makeTranslation(-c.x,-c.y,0)),i.msTransformMatrix=l}switchTransformMs(e,t){var n;let i=this.loadedModels.find((e=>t===e.modelId));if(!i)return void se.warn(`[Viewer] Can't find model whose modelId is ${t}`);let r=i.msTransformMatrix;if(Oy.identity(),!r||!Mt.isMatrixValid(r)||r.equals(Oy))return;let a=null==(n=i.dxfData)?void 0:n.threejsObject,s=null==a?void 0:a.children.find((e=>e.name===gn.MODEL_LAYOUT_NAME));s&&(e===gn.MODEL_LAYOUT_NAME?s.applyMatrix4(r):s.applyMatrix4(r.clone().invert()),s.updateMatrixWorld(!0))}getLayoutExtentEx(e){return e.layoutName===gn.MODEL_LAYOUT_NAME?this.getModelSpaceExtent():this.getLayoutExtent(e)}getModelSpaceExtent(){var e,t;let n=this.loadedModels.find((e=>this.masterModelId===e.modelId));if(!n)return;let i=null==(e=n.dxfData)?void 0:e.header,r=new O,a=new O;if(!i)return void se.error(`Header is undefined in ${this.masterModelId}!`);let s=null==(t=n.dxfData)?void 0:t.tables.viewport.viewports,o=i.$EXTMIN,l=i.$EXTMAX,h=i.$ANGDIR;if(s&&s.length>0)for(let c=0;cthis.masterModelId===e.modelId));if(!n)return;let i=null==(t=n.dxfData)?void 0:t.header,r=new O,a=new O;if(!i)throw new Error(`Header is undefined in ${this.masterModelId}!`);let s=this.getLayoutViewports(e),o=i.$PEXTMIN,l=i.$PEXTMAX,h=i.$ANGDIR;if(s&&s.length>0){let e,t=s.filter((e=>1===parseInt(e.viewportId)));e=t.length>0?t[0]:s[0];let{centerPoint:n,width_paperSpace:i,height_paperSpace:r}=e,a=gn.getDcs2WcsMatrix(e,h),c=new O(n.x,n.y,0);c.applyMatrix4(a),o={x:c.x-i/2,y:c.y-r/2,z:0},l={x:c.x+i/2,y:c.y+r/2,z:0}}return r.set(o.x,o.y,o.z),a.set(l.x,l.y,l.z),new Ot(r,a)}showLayoutObjects(e){this.loadedModels.forEach((t=>{var n;let i=0,r=0,a=null==(n=t.dxfData)?void 0:n.threejsObject;null==a||a.children.forEach((t=>{let n=t.name===e;t.visible=n,n?i++:r++})),se.debug(`[Viewer] showLayoutObjects('${e}') sets ${i} layout level object(s) to visible and ${r} to hidden for model '${null==a?void 0:a.name}'`)}))}getLayoutViewports(e){var t;let n=this.loadedModels.find((e=>this.masterModelId===e.modelId));if(!n)return[];let i=e.ownerHandle;return(null==(t=n.dxfData)?void 0:t.layoutViewportsMap[i])||[]}setMaterialUniforms(e,t){e instanceof ln&&(e.uniforms.u_cameraZoom&&(e.uniforms.u_cameraZoom=gn.cameraZoomUniform),e.uniforms.u_viewportScale&&1===(null==t?void 0:t.header.$PSLTSCALE)&&(e.uniforms.u_viewportScale=gn.viewportScaleUniform))}isLayerFrozenForViewport(e,t,n){if(!e||!t)return!1;let i=e.tables.layer.layers[t];return!!(i&&(1&i.flag)>0)||!(!n||n.length<=0)&&i&&n.indexOf(i.handle)>=0}getFilteredViewports(e){let t=this.getLayoutViewports(e),n=t.filter((e=>"1"!==e.viewportId));return n.length===t.length&&(n=t.filter(((e,t)=>0!==t))),n}generateObjectsByViewport(e,t,n,i=[]){let r=t;if("1"==t.viewportId)return;if(!r.psBBox||!r.msToPsMatrix)throw new Error("The bbox or matrix is invalid in the viewport!");gn.transformMatrixUniform={value:r.msToPsMatrix},gn.viewportScaleUniform={value:t.viewHeight/t.height_paperSpace};let a=r.psBBox.clone();a.applyMatrix4(r.msToPsMatrix.clone().invert()),a.min.setZ(-1),a.max.setZ(1);let s=this.getObjectsByBoundingBox(a);if(0===s.length)return;let o,l=r.psBBox.min,h=r.psBBox.max,c=new Ji(new be(l.x,l.y),new be(h.x,h.y)),u=Hu.generateSectionPlanesByBox(c),d=[],p=e=>(d[e.id]||(d[e.id]=e.clone(),this.setMaterialUniforms(d[e.id],n),Hu.setMaterialSection(d[e.id],u)),d[e.id]),f=[...i,...t.frozenLayerHandles||[]];if(e!==gn.MODEL_LAYOUT_NAME){let e=t;e.associatedLeafObjectSet||(e.associatedLeafObjectSet=new Set),o=e.associatedLeafObjectSet}let m=new er;m.name=t.viewportId;let g=null==n?void 0:n.layersAndThreejsObjects,v=[];if(s.forEach((t=>{let i=t.clone();i.traverse((t=>{if(t.material&&t.geometry){let i=t.userData.layerName;if(this.isLayerFrozenForViewport(n,i,f))return void v.push(t);!1!==t.userData.layerVisible&&(t.visible=!0),t.material=(e=>{if(Array.isArray(e)){let t=[];return e.forEach((e=>{let n=p(e);t.push(n)})),t}return p(e)})(t.material),null==o||o.add(t),g&&g[i]?g[i].push(t):se.warn(`[Viewer] Failed to find object for modelId '${this.masterModelId}', layer '${i}', layout '${e}'`)}})),m.add(i)})),o&&0===o.size)return;let y=null==n?void 0:n.threejsObject,x=null==y?void 0:y.children.find((t=>t.name===e));x||(x=new er,Hn.setSharedVariablesOfObject(x),x.name=e,null==y||y.add(x)),x.add(m),m.applyMatrix4(r.msToPsMatrix),m.updateMatrixWorld(!0);let b=x.children.find((e=>e.name===gn.SNAP_GROUP_NAME));b||(b=new er,b.visible=gn.SHOW_SNAP_OBJECT,b.name=gn.SNAP_GROUP_NAME,x.add(b));let _=null==y?void 0:y.children.find((e=>e.name===gn.MODEL_LAYOUT_NAME)),w=null==_?void 0:_.children.find((e=>e.name===gn.SNAP_GROUP_NAME));w&&w.traverse((e=>{if(!e.geometry)return;let t=e.userData.layerName;if(this.isLayerFrozenForViewport(n,t,f)||(ky.makeEmpty(),ky.expandByObject(e),!a.intersectsBox(ky)))return;let i=e.clone();Hn.setSharedVariablesOfObject(i);let s=i.parent,l=Oy.identity();for(;s&&!0!==s.userData.isLayoutLevelObject;)l.premultiply(s.matrix),s=s.parent;l.premultiply(r.msToPsMatrix),i.applyMatrix4(l),null==b||b.add(i),null==o||o.add(i),g&&g[t]&&g[t].push(i)})),v.length>0&&Hn.removeEmptyObjectsFromRemovingObjects(v,m),m.traverse((e=>{Hn.setSharedVariablesOfObject(e),this.addSpatialFilterSection(e,n,!0)}))}findSpatialFilter(e,t){let n,i=t.objects.SPATIAL_FILTER;if(i){for(let t of i)if(t.handle===e){n=t;break}return n}}getAnyMaterial(e){let t,n=e;if(n.material)return Array.isArray(n.material)?n.material[0]:n.material;for(let i=0;i0),r=a.clipIntersection),t&&r!==i.clipPolylines[0].bReversed)return void se.warn("[Viewer] Material cannot set clipIntersection to different values at the same time. clipIntersection needs to be set to true here!");r=i.clipPolylines[0].bReversed;let s=this.generateSectionsBySpatialFilter(i,e.matrixWorld);if(s){let n=e=>{let t=0;return e.clippingPlanes&&(t=e.clippingPlanes.length),t+s.length>gn.maxFragmentUniforms},i=new Set,a=e=>{i.has(e.id)||(i.add(e.id),n(e)||Hu.setMaterialSection(e,s,t,r))};e.traverse((e=>{let t=e.material;Array.isArray(t)?t.forEach((e=>{a(e)})):t&&a(t)}))}}}getObjectsByBoundingBox(e){var t;let n=[];if(e.isEmpty())return se.warn("[Viewer] bbox is empty !"),n;let i=null==(t=this.loadedModels.find((e=>this.masterModelId===e.modelId)).dxfData)?void 0:t.threejsObject,r=null==i?void 0:i.children.find((e=>e.name===gn.MODEL_LAYOUT_NAME));return r&&r.children.forEach((t=>{t.name!==gn.SNAP_GROUP_NAME&&(t=>{let i=ks.getBoundingBox(t,!1);e.intersectsBox(i)&&n.push(t)})(t)})),n}getDxfUnits(e){if(!e&&this.loadedModels.length>0){let t=this.loadedModels.find((e=>this.masterModelId===e.modelId));e=null==t?void 0:t.dxfData}if(!e)return"Unitless";let t=null==e?void 0:e.header;if(!t)return se.warn("DxfData or its header is undefined!"),"Unitless";let n=t.$INSUNITS;return gn.getDxfUnits(n)}generateSectionsBySpatialFilter(e,t){let n=e.clipPolylines[0];if(n.bConcave)return void se.warn("[Viewer] clipPolyline.bConcave = true is not supported yet in spatialFilter !");Oy.copy(t),e.localMatrix&&Oy.multiply(e.localMatrix);let i=n.polyline,r=[];i.forEach((e=>{let t=e.clone().applyMatrix4(Oy);r.push(new be(t.x,t.y))}));let a=qs.isClockWise(r),s=!a&&!n.bReversed||a&&n.bReversed;return Hu.generateSectionPlanesByPoints(r,s)}resize(e,t){super.resize(e,t),t>0&&(this.css2dRenderer&&(this.css2dRenderer.setSize(e,t),this.css2dRenderer.domElement.style.width="0",this.css2dRenderer.domElement.style.height="0"),this.overlayRender&&this.overlayRender.setSize(e,t)),this.enableRender()}getRaycaster(){return this.raycaster}getRaycastableObjects(){var e;if(this.raycastableObjects)return this.raycastableObjects;let t=Date.now(),n=[];for(let i of this.loadedModels){let t=null==(e=i.dxfData)?void 0:e.threejsObject,r=t&&t.children.find((e=>e.name===this.activeLayoutName));r&&r.traverse((e=>{(e.visible||e.userData.isSnapObject)&&Hn.isLeafObject(e)&&n.push(e)}))}return this.groundPlane&&n.push(this.groundPlane),this.raycastableObjects=n,se.debug(`[Viewer] getRaycastableObjects() finds ${n.length} objects`),se.debug(`[Viewer] getRaycastableObjects() costs ${(Date.now()-t)/1e3} s`),n}getViewportByPoint(e){if(0===this.activeLayoutName.length||this.activeLayoutName===gn.MODEL_LAYOUT_NAME)return;let t=this.getLayoutByName(this.activeLayoutName);if(!t)return;let n=t=>e.xt.max.x||e.yt.max.y,i=this.getFilteredViewports(t);for(let r=0,a=i.length;r{e.object&&e.object.geometry&&o.push(e.object)})),e.transparent.forEach((e=>{e.object&&e.object.geometry&&o.push(e.object)})))}cve.multiplyMatrices(this.camera.projectionMatrix,this.camera.matrixWorldInverse),uve.setFromProjectionMatrix(cve);for(let e of this.loadedModels){let t=null==(r=e.dxfData)?void 0:r.threejsObject,n=t&&t.children.find((e=>e.name===this.activeLayoutName));if(n){let e=n.children.find((e=>e.name===gn.SNAP_GROUP_NAME));null==e||e.traverse((e=>{if(Hn.isLeafObject(e)){if(ky.makeEmpty(),ky.expandByObject(e),!uve.intersectsBox(ky))return;o.push(e)}}))}}this.groundPlane&&o.push(this.groundPlane),se.debug("[Viewer] getRaycastableObjectsByMouse() from modelSpace"),this.lastFrame=(null==(a=this.renderer)?void 0:a.info.render.frame)||0,this.raycastableObjects=o}else{let e=new WeakSet,t=this.getLayoutByName(this.activeLayoutName);if(t){let n=t.directAssociatedLeafObjectSet;n&&n.forEach((t=>{t.visible&&!e.has(t)&&(o.push(t),e.add(t))}))}let n=this.getViewportByPoint(this.raycaster.ray.origin);n&&n.associatedLeafObjectSet?(null==(s=n.associatedLeafObjectSet)||s.forEach((t=>{!e.has(t)&&(t.visible||t.userData.isSnapObject)&&(o.push(t),e.add(t))})),se.debug("[Viewer] getRaycastableObjectsByMouse() from inside of viewport:",n.viewportId)):se.debug("[Viewer] getRaycastableObjectsByMouse() from out of viewport"),this.groundPlane&&o.push(this.groundPlane)}return se.debug(`[Viewer] getRaycastableObjectsByMouse() costs ${(Date.now()-h)/1e3} s`),o}getIntersections(e){let t=this.getRaycastableObjectsByMouse(e);return this.raycaster&&this.raycaster.intersectObjects(t,!0)||[]}handleMouseClick(e){var t,n;if(null!=(t=this.measurePlugin)&&t.isActive()||null!=(n=this.markupManager)&&n.isMarkupActive()||(this.selectDrawableByEvent(e),this.selectedObject)||!this.enableSelection)return;this.raycaster&&this.raycaster.layers.set(12);let i=this.getIntersections(e);if(i.length>0){let e=e=>Mt.vectorToString(e);se.debug(`[Viewer] Clicked at: ${e(i[0].point)}`)}let r=i.find((e=>e.object.visible)),a=r&&r.object||void 0;this.selectedObject&&this.clearSelection(),a&&this.selectedObject&&this.selectedObject.id===a.id&&(a=void 0),a?this.selectObject(a):this.clearSelection()}selectDrawableByEvent(e){var t,n;this.clearSelection();let i=this.getHitResult(e);if(!i)return;let r=null==(t=this.overlayRender)?void 0:t.getDrawablesByPosition(i,this.raycaster);r&&r.length>0&&(r[0].selected=!0,this.selectedObject=r[0],null==(n=this.overlayRender)||n.render())}selectObject(e,t=!1){if(!this.enableSelection)return;let n=e=>{if(e.children.length>0&&e.children.forEach((e=>n(e))),e instanceof xt||e instanceof hr||e instanceof ii){let n=es.clonedHighlightMaterials(e,{depthTest:t});n&&(e.userData.originalMaterial=e.material,e.material=n)}},i=e=>{if(e.children.length>0&&e.children.forEach((e=>i(e))),(e instanceof xt||e instanceof hr||e instanceof ii)&&e.userData.originalMaterial){let t=e.material;e.material=e.userData.originalMaterial,delete e.userData.originalMaterial,Array.isArray(t)?t.forEach((e=>e.dispose())):t instanceof yr&&t.dispose()}},r=!1;this.selectedObject&&(i(this.selectedObject),this.selectedObject=void 0,r=!0),e&&(n(e),this.selectedObject=e,e.userData.dxfEntity?se.info("[Viewer] Selected entity:",e.userData.dxfEntity):se.info("[Viewer] Selected object:",e),r=!0),r&&this.enableRender()}clearSelection(){var e;this.selectedObject&&this.selectedObject instanceof Bi?(this.selectedObject.selected=!1,null==(e=this.overlayRender)||e.render()):this.selectObject(),this.selectedObject=void 0}flyToObjects(e){if(!e||0===e.length||!this.camera)return;let t=new Ot;e.forEach((e=>{let n=ks.getBoundingBox(e);n.isEmpty()||t.union(n)})),this.zoomToBBox(t)}flyToObject(e){this.flyToObjects([e])}flyToSelectedObject(){if(!this.selectedObject)return;let e=this.selectedObject;(e instanceof Pi&&e.userData.clonedMesh||e instanceof xt&&Ar.isMergedMesh(e)&&e.userData.clonedMesh)&&(e=e.userData.clonedMesh),this.flyToObject(e)}flyToRandomObject(){var e;let t=this.scene,n=[];for(let c of this.loadedModels){let t=null==(e=c.dxfData)?void 0:e.threejsObject;t&&n.push(t.id)}let i=n.length;if(i<=0)return;let r=n[Math.floor(Math.random()*i)],a=t.getObjectById(r);if(!a)return;let s=this.getActiveLayoutName();if(!a.children.find((e=>e.name===s)))return;let o=[];if(t.traverseVisible((e=>{(e instanceof xt||e instanceof hr)&&!["SKYBOX","GROUND_GRID","GROUND_GRASS","BIM_VIEWER_BOX_HELPER"].includes(e.name)&&o.push(e.id)})),o.length<1)return;let l=Math.floor(Math.random()*o.length),h=t.getObjectById(o[l]);h&&(se.info(`[Viewer] Flying to random object: ${h.name}, type: ${h.type}`),this.selectObject(h,void 0),this.flyToObject(h))}flyTo(e,t,n,i){let r=this.camera,a=this.controls;if(!r||!a)return;if(n&&(n=this.checkAndGetLimitedCameraZoom(n)),e.equals(t))return void se.error("[Viewer] Camera position and lookAt cannot be the same!");if(!Mt.isVectorValid(e)||!Mt.isVectorValid(t))return void se.error("[Viewer] Invalid position or lookAt!",e,t);let s=e.distanceTo(t);sr.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*r.far),se.warn("[Viewer] Camera could be too far to see the object!"));let o=(e,t,n)=>{n&&Number.isFinite(n)&&a.zoomTo(n),a.setLookAt(e.x,e.y,e.z,t.x,t.y,t.z),this.updateHidableObjectsVisibility(),this.enableRender()};if(!1===i)return this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),void o(e,t,n);let l=r.position.clone(),h=a.getTarget(new O),c=r.zoom,u=300,d=Date.now();this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=setInterval((()=>{let i=Date.now()-d;i>u&&(i=u);let r,a=(e,t,n)=>{let i=e.x+(t.x-e.x)*n,r=e.y+(t.y-e.y)*n,a=e.z+(t.z-e.z)*n;return new O(i,r,a)},s=a(l,e,i/u),p=a(h,t,i/u);n&&(r=c+(n-c)*i/u),o(s,p,r),i>=u&&(clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=void 0)}),10)}goTo(e,t,n){let i=this.camera,r=this.controls;if(!i||!r)return;let a=new O(e.x,e.y,i.position.z),s=r.getTarget(new O),o=new O(e.x,e.y,s.z);this.flyTo(a,o,t,n)}goToHomeView(){let e=this.getActiveLayoutInfo();e.homeViewExtent?this.zoomToBBox(e.homeViewExtent):se.error(`[Viewer] Failed to find extent for ${this.activeLayoutName}`)}zoomToBBox(e){let t=this.camera;if(!t)return;let n=e.max.x-e.min.x,i=e.max.y-e.min.y,r=t.right-t.left,a=t.top-t.bottom,s=Math.min(r/n,a/i);s/=1.1;let o=new Ot(new O(e.min.x,e.min.y,0),new O(e.max.x,e.max.y,0)),l=new O;o.getCenter(l),l.z=0;let h=l.clone().setZ(Math.max(t.position.z,this.CAMERA_Z_POSITION));h.equals(l)||this.flyTo(h,l,s,!1)}zoomToExtent(){let e=this.getActiveLayoutInfo();e.extent?this.zoomToBBox(e.extent):(console.error("[Viewer] Failed to find extent of current layout! Will go to home view."),this.goToHomeView())}zoomToCompareChange(e){if(this.changes){let t=this.changes[e];if(!t)return;let n=t.box;n&&this.zoomToBBox(n.clone().expandByScalar(1.2))}}getCompareChanges(){return this.changes}setBackgroundColor(e,t,n){!this.scene||!this.renderer||(hve.setRGB(e,t,n,this.renderer.outputColorSpace),(!this.scene.background||!(this.scene.background instanceof ct))&&(this.scene.background=new ct(e,t,n)),this.scene.background.copy(hve),this.enableRender())}getLayoutInfo(e){return this.layoutInfos[e]||(this.layoutInfos[e]={}),this.layoutInfos[e]}updateGroundPlane(){if(!this.scene)return;let e=this.getActiveLayoutInfo();if(!e.homeViewExtent)return;let t=e.homeViewExtent.clone();Mt.expandBoxByScale(t,3);let n=t.min,i=t.max,r=i.x-n.x+i.y-n.y+i.z-n.z;Mt.expandBoxByMinSize(t,r);let a=[],s=(e,t,n)=>{a.push(new O(e,t,n))},o=t.getSize(new O),l=t.getCenter(new O);if(s(-o.x/2,-o.y/2,0),s(o.x/2,-o.y/2,0),s(o.x/2,o.y/2,0),s(-o.x/2,o.y/2,0),this.groundPlane)this.groundPlane.position.set(l.x,l.y,-o.z),this.groundPlane.geometry.setFromPoints(a),this.groundPlane.geometry.computeBoundingSphere(),this.groundPlane.geometry.computeBoundingBox();else{let e=new Dt;e.setFromPoints(a),e.setIndex([0,3,2,0,2,1]);let t=new on({color:"#888",transparent:!0,opacity:0,side:Sr});this.groundPlane=new xt(e,t),this.groundPlane.visible=!0,this.groundPlane.frustumCulled=!1,this.groundPlane.position.set(l.x,l.y,-o.z),this.groundPlane.scale.set(1e5,1e5,1),this.groundPlane.name="groundPlane",this.groundPlane.renderOrder=-1e3,this.groundPlane.layers.enableAll(),Hn.disableLayerChannels(this.groundPlane,[12]),this.scene.add(this.groundPlane)}this.groundPlane.updateMatrixWorld()}computeBoundingBox(){var e;let t=new Ot;for(let n of this.loadedModels){let i=null==(e=n.dxfData)?void 0:e.threejsObject;for(let e=0;i&&e{if(!this.isCompareMode()||!e.material)return!1;let t;return t=e.material instanceof ln?e.material.uniforms.u_color.value:e.material.color,t.equals(new ct(hs.ENTITY_COLOR_ADDED))||t.equals(new ct(hs.ENTITY_COLOR_REMOVED))},o=1;e.traverse((e=>{if(this.isCompareMode()&&s(e)||e.userData.isSnapObject||!Hn.isLeafObject(e))return;let t=e.geometry;t.boundingBox||t.computeBoundingBox();let n=t.boundingBox.clone();if(!n||!Mt.isBoxValid(n))return;n.applyMatrix4(e.matrixWorld),n.getSize(B4);let i=Math.max(B4.x,B4.y),a=o/i;a<1/0?r.push({visibleMinZoom:a,object:e}):e instanceof ii?r.push({visibleMinZoom:o,object:e}):se.warn("[Viewer] The size of bbox is 0 ! ",e)})),o=this.getVisiblePixelSize(r.length);let l=0;r.forEach((e=>{let t=e.visibleMinZoom*o;e.visibleMinZoom=t,e.object.userData.visibleMinZoom=t,t>a&&(e.object.visible=!1,l++)})),r.sort(((e,t)=>e.visibleMinZoom-t.visibleMinZoom)),se.debug(`[Viewer] setLayoutHidableObjectArray cost: ${(Date.now()-n)/1e3}s, ${l} objects changed to hidden`)}statObjects(e){let t=this.sortedHidableObjects[this.activeLayoutName],n=t.length,i={},r=0;t.forEach((t=>{let n=t.object;if(n.geometry&&n.material){r++;let n=(t=>{let n=0,i=t;for(;i&&(n++,i!==e);)i=i.parent;return n})(t.object);i[n]||(i[n]=0),i[n]++}}));let a=0;e.traverse((e=>{let t=e;t.geometry&&t.material&&a++})),se.info(`[Viewer] hidableObjects count:${n}, real count:${r}, layout count: ${a}, level:`,i),se.info("[Viewer] scene:",this.scene)}updateHidableObjectsVisibility(){let e=this.camera;if(!e)return;let t=Date.now();this.controls.update(0);let n=e.zoom;if(Math.abs(n-this.lastCameraZoom)<1e-5||(this.updateRaycasterThreshold(),this.updateCameraZoomUniform(n),this.raycastableObjects=void 0,!this.sortedHidableObjects[this.activeLayoutName]))return;let i=this.sortedHidableObjects[this.activeLayoutName];if(0===i.length)return;let r=n>this.lastCameraZoom,a=Math.min(n,this.lastCameraZoom),s=Math.max(n,this.lastCameraZoom),o=[],l=0;for(let h=0;hs)break;i[h].object.visible=r,r&&o.push(i[h].object),l++}this.lastCameraZoom=n,se.debug(`[Viewer] updateHidableObjectsVisibility cost: ${(Date.now()-t)/1e3}s, ${l}(out of ${i.length}) objects changed to ${r?"visible":"hidden"}`)}updateRaycasterThreshold(){if(!this.camera||!this.raycaster)return;let e=3*this.getPixelSizeInWorldCoord(),t=this.raycaster.params;t.Line?t.Line.threshold=e:t.Line={threshold:e},t.Points?t.Points.threshold=e:t.Points={threshold:e}}updateCameraZoomUniform(e){gn.cameraZoomUniform.value=e}},LP=class{constructor(e){this.jobCount=0,this.viewer=new Qf(e);let t=document.getElementById(e.containerId);this.container=(null==t?void 0:t.parentElement)||document.body,this.loadingProgressBar=new Gf(this.container),this.loader=new gn(this.loadingManager,{ignorePaperSpace:!0}),this.initSpinner()}initSpinner(){let e=document.createElement("div");e.classList.add("gemini-spinner"),e.appendChild(document.createElement("span")),e.appendChild(document.createElement("span")),e.appendChild(document.createElement("span")),e.appendChild(document.createElement("span")),this.container.appendChild(e),this.spinner=e,this.setSpinnerVisibility(this.jobCount>0)}setFont(e){return ft(this,null,(function*(){let t=Date.now();this.fontManager||(this.fontManager=new ud),yield this.fontManager.loadFonts(e),se.info(`[DxfCompareHelper] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}compare(e,t,n,i){return ft(this,null,(function*(){var r,a,s,o,l;let{src:h,modelId:c}=e,{src:u}=t;this.viewer.masterModelId=c||h;let d=Date.now();if(this.increaseJobCount(),!this.fontManager)return Promise.reject("[DxfCompareHelper] Should set font first!");this.loader.setFont(this.fontManager),yield this.fontManager.getFontFromIndexeddb();let p=h+u,f=eg.t("ProgressBar.Comparing"),m=e=>{var t;null==(t=this.loadingProgressBar)||t.updateProgress(p,f,e),i&&i(new ProgressEvent("CompareProgress",{loaded:e,total:100}))},g=(e,t,n)=>{var r;let a=100*e.loaded/e.total;a=a*(n-t)/100+t,null==(r=this.loadingProgressBar)||r.updateProgress(p,f,a),i&&i(new ProgressEvent("CompareProgress",{loaded:a,total:100}))};Mt.printMemory("Before comparing"),null==(r=this.loadingProgressBar)||r.addProgressItem(p),m(0);let v=Date.now(),y=yield this.loader.parse(h,(e=>g(e,0,15))),x=yield this.loader.parse(u,(e=>g(e,15,30))),[b,_]=yield Promise.allSettled([y,x]);if("rejected"===b.status)return Promise.reject(`[DxfCompareHelper] Failed to parse ${h}`);if("rejected"===_.status)return Promise.reject(`[DxfCompareHelper] Failed to parse ${u}`);if(se.info(`[DxfCompareHelper] loadFiles in ${(Date.now()-v)/1e3}s`),gn.abortJobs)return Promise.reject("[DxfCompareHelper] compare loadFile aborted");let w=b.value,S=_.value;v=Date.now();let M=yield new hs(w,S,n).compare((e=>g(e,30,60)));if(se.info(`[DxfCompareHelper] Compared in ${(Date.now()-v)/1e3}s`),se.debug("[DxfCompareHelper] Compared results:",M),gn.abortJobs)return Promise.reject("[DxfCompareHelper] compare change aborted");Mt.printMemory("After getting the comparison results"),v=Date.now(),yield this.loader.loadEntitiesForCompare(w,S,M,!0,(e=>g(e,60,95))),Mt.printMemory("After Creating threejs objects based on comparison result"),null==(a=this.fontManager)||a.releaseFontData(),this.changes=M,se.info(`[DxfCompareHelper] Creates threejs objects based on comparison result in ${(Date.now()-v)/1e3}s`);let T=w,E=S;if(this.decreaseJobCount(),Object.keys(M).length||se.info("[DxfCompareHelper] No change found"),0===(null==(s=T.threejsObject)?void 0:s.children.length)&&0===(null==(o=E.threejsObject)?void 0:o.children.length)){let e=`[DxfCompareHelper] Nothing was loaded from ${h} and ${u}`;return se.warn(e),Promise.reject(e)}let A=T.threejsObject,C=E.threejsObject;return A.name=h,C.name=u,v=Date.now(),this.viewer.addModel({modelId:e.modelId||e.src,dxfData:T}),Mt.printMemory("After adding first loaded Model to scene"),m(95),this.viewer.addModel({modelId:t.modelId||t.src,dxfData:E}),Mt.printMemory("After adding second loaded Model to scene"),se.info(`[DxfCompareHelper] Added compared objects to scene in ${(Date.now()-v)/1e3}s`),se.info(`[DxfCompareHelper] The comparison between ${h}' and '${u}' is completed in ${(Date.now()-d)/1e3}s !`),m(100),null==(l=this.loadingProgressBar)||l.delayRemoveProgressItem(p),Promise.resolve()}))}getChanges(){return this.changes}zoomToChange(e){if(this.changes){let t=this.changes[e];if(!t)return;let n=t.box;n&&this.viewer.zoomToBBox(n.clone().expandByScalar(1.2))}}setSpinnerVisibility(e){this.spinner&&(e?this.spinner.classList.remove("hidden"):this.spinner.classList.add("hidden"))}increaseJobCount(){this.setSpinnerVisibility(++this.jobCount>0)}decreaseJobCount(){this.setSpinnerVisibility(--this.jobCount>0)}},dve=class extends LP{constructor(e,t){super(e),this.syncCamera=!1,this.syncCameraControls=(e,t,n)=>{let i=new O,r=new O,a=new O;e.getPosition(r),e.getTarget(a),e.getFocalOffset(i),t.setLookAt(r.x,r.y,r.z,a.x,a.y,a.z),t.zoomTo(n),t.dispatchEvent({type:"control"})},this.viewer2=new Qf(t),this.initSyncCameraEvent()}initSyncCameraEvent(){let e=this.viewer.controls,t=this.viewer2.controls,n=!1;e.addEventListener("control",(()=>{n=!1})),e.addEventListener("update",(()=>{!this.syncCamera||n||this.syncCameraControls(e,t,this.viewer.camera.zoom)})),t.addEventListener("control",(()=>{n=!0})),t.addEventListener("update",(()=>{!this.syncCamera||!n||this.syncCameraControls(t,e,this.viewer2.camera.zoom)}))}enableSyncCamera(e){if(this.syncCamera=e,e){let e=this.viewer.controls,t=this.viewer2.controls;this.syncCameraControls(e,t,this.viewer.camera.zoom)}}compare(e,t,n,i){return ft(this,null,(function*(){var r,a,s,o,l;let{src:h,modelId:c}=e,{src:u,modelId:d}=t;this.viewer.masterModelId=c||h,this.viewer2.masterModelId=d||u;let p=Date.now();if(this.increaseJobCount(),!this.fontManager)return Promise.reject("[DxfCompareHelper] Should set font first!");this.loader.setFont(this.fontManager),yield this.fontManager.getFontFromIndexeddb();let f=h+u,m=eg.t("ProgressBar.Comparing"),g=e=>{var t;null==(t=this.loadingProgressBar)||t.updateProgress(f,m,e),i&&i(new ProgressEvent("CompareProgress",{loaded:e,total:100}))},v=(e,t,n)=>{var r;let a=100*e.loaded/e.total;a=a*(n-t)/100+t,null==(r=this.loadingProgressBar)||r.updateProgress(f,m,a),i&&i(new ProgressEvent("CompareProgress",{loaded:a,total:100}))};Mt.printMemory("Before comparing"),null==(r=this.loadingProgressBar)||r.addProgressItem(f),g(0);let y=Date.now(),x=yield this.loader.parse(h,(e=>v(e,0,15))),b=yield this.loader.parse(u,(e=>v(e,15,30))),[_,w]=yield Promise.allSettled([x,b]);if("rejected"===_.status)return Promise.reject(`[DxfCompareHelper] Failed to parse ${h}`);if("rejected"===w.status)return Promise.reject(`[DxfCompareHelper] Failed to parse ${u}`);if(se.info(`[DxfCompareHelper] loadFiles in ${(Date.now()-y)/1e3}s`),gn.abortJobs)return Promise.reject("[DxfCompareHelper] compare loadFile aborted");let S=_.value,M=w.value;y=Date.now();let T=yield new hs(S,M,n).compare((e=>v(e,30,60)));if(se.info(`[DxfCompareHelper] Compared in ${(Date.now()-y)/1e3}s`),se.debug("Compared results:",T),gn.abortJobs)return Promise.reject("[DxfCompareHelper] compare change aborted");Mt.printMemory("After getting the comparison results"),y=Date.now(),yield this.loader.loadEntitiesForCompare(S,M,T,!1,(e=>v(e,60,95))),Mt.printMemory("After Creating threejs objects based on comparison result"),null==(a=this.fontManager)||a.releaseFontData(),this.changes=T,se.info(`[DxfCompareHelper] Creates threejs objects based on comparison result in ${(Date.now()-y)/1e3}s`);let E=S,A=M;if(this.decreaseJobCount(),Object.keys(T).length||se.info("[DxfCompareHelper] No change found"),0===(null==(s=E.threejsObject)?void 0:s.children.length)&&0===(null==(o=A.threejsObject)?void 0:o.children.length)){let e=`[DxfCompareHelper] Nothing was loaded from ${h} and ${u}`;return se.warn(e),Promise.reject(e)}let C=E.threejsObject,P=A.threejsObject;return C.name=h,P.name=u,y=Date.now(),this.viewer.addModel({modelId:e.modelId||e.src,dxfData:E}),Mt.printMemory("After adding first loaded Model to scene"),g(95),this.viewer2.addModel({modelId:t.modelId||t.src,dxfData:A}),Mt.printMemory("After adding second loaded Model to scene"),se.info(`[DxfCompareHelper] Added compared objects to scene in ${(Date.now()-y)/1e3}s`),se.info(`[DxfCompareHelper] The comparison between ${h}' and '${u}' is completed in ${(Date.now()-p)/1e3}s !`),g(100),null==(l=this.loadingProgressBar)||l.delayRemoveProgressItem(f),Promise.resolve()}))}zoomToChange(e){if(this.changes){let t=this.changes[e];if(!t)return;let n=t.box;n&&(this.viewer.zoomToBBox(n.clone().expandByScalar(1.2)),this.viewer2.zoomToBBox(n.clone().expandByScalar(1.2)))}}},sg=ji(fve(),1),dd=class{constructor(e,t){this.current=e,this.next=t,this.inNormal=this.inwardsNormal(),this.outNormal=this.outwardsNormal()}outwardsNormal(){let e=this.inwardsNormal();return[-e[0],-e[1]]}inwardsNormal(){let e=this.next[0]-this.current[0],t=this.next[1]-this.current[1],n=Math.sqrt(e*e+t*t);if(0===n)throw new Error("Vertices overlap");return[-t/n,e/n]}offset(e,t){return dd.offsetEdge(this.current,this.next,e,t)}inverseOffset(e,t){return dd.offsetEdge(this.next,this.current,e,t)}inverse(){return new dd(this.next,this.current)}static offsetEdge(e,t,n,i){return new dd([e[0]+n,e[1]+i],[t[0]+n,t[1]+i])}},x_=Array.isArray,pve=(e,t)=>e[0]===t[0]&&e[1]===t[1],V4=e=>Array.isArray(e)&&e.length,gve=(e,t=0,n=!1)=>{let i,r;if(V4(e)&&"number"==typeof e[0][0]){let t=0,a=e;for(i=0,r=a.length;i0||n&&t<0)&&a.reverse()}else for(i=0,r=e.length;i0);if(0===t&&V4(e)&&V4(e[0])&&"number"==typeof e[0][0][0]){let t=e[0].slice(0,1)[0];e[0].pop(),e[0].push([t[0],t[1]])}return e},mve=class{constructor(e,t=5){if(this.distance=0,this.arcSegments=t,!x_(e))throw new Error("Offset requires at least one coodinate to work with");this.edges=[],x_(e)&&"number"==typeof e[0]?this.vertices=e:(this.vertices=gve(e),this.processContour(this.vertices,this.edges))}processContour(e,t){let n,i;if(x_(e[0])&&"number"==typeof e[0][0])for(i=e.length,pve(e[0],e[i-1])&&(i-=1),n=0;nh?l-h:l+o-h,u=(s?-c:o-c)/a;e.push(i);for(let d=1;d0?this.margin(this.distance):this.padding(-this.distance)}offsetSegment(e,t,n,i){let r=[n.offset(n.inNormal[0]*i,n.inNormal[1]*i),n.inverseOffset(n.outNormal[0]*i,n.outNormal[1]*i)],a=[];for(let s=0,o=2;s0&&e.push(n)}e.length>0&&(t=1===e.length?e[0]:(0,sg.union)(e[0],...e.slice(1)))}else t=1===this.vertices.length?this.offsetPoint(e):this.offsetContour(this.vertices,this.edges);return t}offsetContour(e,t){let n=[],i=0,r=0;if(x_(e[0])&&"number"==typeof e[0][0]){for(i=0,r=e.length-1;i0&&(n=1===n.length?[n[0]]:(0,sg.union)(n[0],n.slice(1)))}else{let a=[];for(i=0,r=t.length;i0&&a.push(n)}a.length>0&&(n=1===a.length?a[0]:(0,sg.union)(a[0],...a.slice(1)))}return n}offsetPoint(e){this.setDistance(e);let t=2*this.arcSegments,n=[],i=this.vertices,r=this.distance,a=0;t%2==0&&t++;for(let s=0;se.get(t)}isFull(){return this.itemSet.size>=this.maxSize}add(e,t){let n=this.itemSet;if(n.has(e)||this.isFull())return!1;let i=this.usedSet,r=this.itemList,a=this.callbacks;return r.push(e),i.add(e),n.set(e,Date.now()),a.set(e,t),!0}remove(e){let t=this.usedSet,n=this.itemSet,i=this.itemList,r=this.callbacks;if(n.has(e)){r.get(e)(e);let a=i.indexOf(e);return i.splice(a,1),t.delete(e),n.delete(e),r.delete(e),!0}return!1}markUsed(e){let t=this.itemSet,n=this.usedSet;t.has(e)&&!n.has(e)&&(t.set(e,Date.now()),n.add(e))}markAllUnused(){this.usedSet.clear()}unloadUnusedContent(){let e=this.unloadPercent,t=this.minSize,n=this.itemList,i=this.itemSet,r=this.usedSet,a=this.callbacks,s=n.length-r.size,o=n.length-t,l=this.unloadPriorityCallback||this.defaultPriorityCallback;if(o>0&&s>0){n.sort(((e,t)=>{let n=r.has(e),i=r.has(t);return n&&i?0:n||i?n?1:-1:l(t)-l(e)}));let h=Math.min(o,s),c=Math.max(t*e,h*e),u=Math.min(c,s);u=Math.ceil(u);let d=n.splice(0,u);for(let e=0,t=d.length;e{this.scheduled=!1,this.unloadUnusedContent(),e&&this.markAllUnused()})))}},b_=class{constructor(){this.maxJobs=6,this.items=[],this.callbacks=new Map,this.currJobs=0,this.scheduled=!1,this.autoUpdate=!0,this.priorityCallback=()=>{throw new Error("PriorityQueue: PriorityCallback function not defined.")},this.schedulingCallback=e=>{requestAnimationFrame(e)},this._runjobs=()=>{this.tryRunJobs(),this.scheduled=!1}}sort(){let e=this.priorityCallback;this.items.sort(e)}add(e,t){return new Promise(((n,i)=>{let r=this.items,a=this.callbacks;r.push(e),a.set(e,((...e)=>t(...e).then(n).catch(i))),this.autoUpdate&&this.scheduleJobRun()}))}remove(e){let t=this.items,n=this.callbacks,i=t.indexOf(e);-1!==i&&(t.splice(i,1),n.delete(e))}tryRunJobs(){this.sort();let e=this.items,t=this.callbacks,n=this.maxJobs,i=this.currJobs;for(;n>i&&e.length>0;){i++;let n=e.pop(),r=t.get(n);t.delete(n),r(n).then((()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()})).catch((()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()}))}this.currJobs=i}scheduleJobRun(){this.scheduled||(this.schedulingCallback(this._runjobs),this.scheduled=!0)}},Avt=.0033528106647474805,vve=-(6378137*Avt-6378137);function q4(e){return 3===e||4===e}function ag(e,t){return e.__lastFrameVisited===t&&e.__used}function yve(e,t){e.__lastFrameVisited!==t&&(e.__lastFrameVisited=t,e.__used=!1,e.__inFrustum=!1,e.__isLeaf=!1,e.__visible=!1,e.__active=!1,e.__error=1/0,e.__distanceFromCamera=1/0,e.__childrenWereVisible=!1,e.__allChildrenLoaded=!1)}function xve(e,t,n){if(yve(e,t),e.__used=!0,n.markUsed(e),e.__contentEmpty){let i=e.children;for(let e=0,r=i.length;e0&&e.__depth+1>=a))return!0;let h=!1,c=e.children;for(let u=0,d=c.length;ue.__depth!==t.__depth?e.__depth>t.__depth?-1:1:e.__inFrustum!==t.__inFrustum?e.__inFrustum?1:-1:e.__used!==t.__used?e.__used?1:-1:e.__error!==t.__error?e.__error>t.__error?1:-1:e.__distanceFromCamera!==t.__distanceFromCamera?e.__distanceFromCamera>t.__distanceFromCamera?-1:1:0,Cvt=e=>1/(e.__depthFromRenderedParent+1),FP=class{get rootTileSet(){let e=this.tileSets[this.rootURL];return!e||e instanceof Promise?null:e}get root(){let e=this.rootTileSet;return e?e.root:null}constructor(e){this.tileSets={},this.rootURL=e,this.fetchOptions={},this.preprocessURL=null;let t=new DP;t.unloadPriorityCallback=Cvt;let n=new b_;n.maxJobs=4,n.priorityCallback=_ve;let i=new b_;i.maxJobs=1,i.priorityCallback=_ve,this.lruCache=t,this.downloadQueue=n,this.parseQueue=i,this.stats={parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0},this.frameCount=0,this.errorTarget=6,this.errorThreshold=1/0,this.loadSiblings=!0,this.displayActiveTiles=!1,this.maxDepth=1/0,this.stopAtEmptyTiles=!0}traverse(e,t){let n=this.tileSets[this.rootURL];!n||!n.root||kP(n.root,e,t)}update(){let e=this.stats,t=this.lruCache,n=this.tileSets,i=n[this.rootURL];if(!(this.rootURL in n))return void this.loadRootTileSet(this.rootURL);if(!i||!i.root)return;let r=i.root;e.inFrustum=0,e.used=0,e.active=0,e.visible=0,this.frameCount++,W4(r,this),j4(r,this),X4(r,this),Y4(r,this),t.scheduleUnload()}parseTile(e,t,n){return null}disposeTile(e){}preprocessNode(e,t,n){if(e.content&&(!("uri"in e.content)&&"url"in e.content&&(e.content.uri=e.content.url,delete e.content.url),e.content.uri&&(e.content.uri=new URL(e.content.uri,n+"/").toString()),e.content.boundingVolume&&!("box"in e.content.boundingVolume||"sphere"in e.content.boundingVolume||"region"in e.content.boundingVolume)&&delete e.content.boundingVolume),e.parent=t,e.children=e.children||[],e.content&&e.content.uri){let t=z4(e.content.uri),n=Boolean(t&&"json"===t.toLowerCase());e.__externalTileSet=n,e.__contentEmpty=n}else e.__externalTileSet=!1,e.__contentEmpty=!0;e.__distanceFromCamera=1/0,e.__error=1/0,e.__inFrustum=!1,e.__isLeaf=!1,e.__usedLastFrame=!1,e.__used=!1,e.__wasSetVisible=!1,e.__visible=!1,e.__childrenWereVisible=!1,e.__allChildrenLoaded=!1,e.__wasSetActive=!1,e.__active=!1,e.__loadingState=0,e.__loadIndex=0,e.__loadAbort=null,e.__depthFromRenderedParent=-1,null===t?(e.__depth=0,e.refine=e.refine||"REPLACE"):(e.__depth=t.__depth+1,e.refine=e.refine||t.refine)}setTileActive(e,t){}setTileVisible(e,t){}calculateError(e){return 0}tileInView(e){return!0}resetFailedTiles(){let e=this.stats;0!==e.failed&&(this.traverse((e=>{4===e.__loadingState&&(e.__loadingState=0)})),e.failed=0)}fetchTileSet(e,t,n=null){return fetch(e,t).then((t=>{if(t.ok)return t.json();throw new Error(`TilesRenderer: Failed to load tileset "${e}" with status ${t.status} : ${t.statusText}`)})).then((t=>{let i=t.asset.version;console.assert("1.0"===i||"0.0"===i,'asset.version is expected to be a string of "1.0" or "0.0"');let r=e.replace(/\/[^\/]*\/?$/,"");return r=new URL(r,window.location.href).toString(),kP(t.root,((e,t)=>this.preprocessNode(e,t,r)),null,n,n?n.__depth:0),t}))}loadRootTileSet(e){let t=this.tileSets;if(e in t)return t[e]instanceof Error?Promise.reject(t[e]):Promise.resolve(t[e]);{let n=this.fetchTileSet(this.preprocessURL?this.preprocessURL(e):e,this.fetchOptions).then((n=>{t[e]=n}));return n.catch((n=>{console.error(n),t[e]=n})),t[e]=n,n}}requestTileContents(e){if(0!==e.__loadingState)return;let t=this.stats,n=this.lruCache,i=this.downloadQueue,r=this.parseQueue,a=e.__externalTileSet;n.add(e,(e=>{1===e.__loadingState?(e.__loadAbort.abort(),e.__loadAbort=null):a?e.children.length=0:this.disposeTile(e),1===e.__loadingState?t.downloading--:2===e.__loadingState&&t.parsing--,e.__loadingState=0,e.__loadIndex++,r.remove(e),i.remove(e)})),e.__loadIndex++;let s=e.__loadIndex,o=new AbortController,l=o.signal;t.downloading++,e.__loadAbort=o,e.__loadingState=1;let h=a=>{e.__loadIndex===s&&("AbortError"!==a.name?(r.remove(e),i.remove(e),2===e.__loadingState?t.parsing--:1===e.__loadingState&&t.downloading--,t.failed++,console.error(`TilesRenderer : Failed to load tile at url "${e.content.uri}".`),console.error(a),e.__loadingState=4):n.remove(e))};a?i.add(e,(e=>{if(e.__loadIndex!==s)return Promise.resolve();let t=this.preprocessURL?this.preprocessURL(e.content.uri):e.content.uri;return this.fetchTileSet(t,Object.assign({signal:l},this.fetchOptions),e)})).then((n=>{e.__loadIndex===s&&(t.downloading--,e.__loadAbort=null,e.__loadingState=3,e.children.push(n.root))})).catch(h):i.add(e,(e=>{if(e.__loadIndex!==s)return Promise.resolve();let t=this.preprocessURL?this.preprocessURL(e.content.uri):e.content.uri;return fetch(t,Object.assign({signal:l},this.fetchOptions))})).then((t=>{if(e.__loadIndex===s){if(t.ok)return t.arrayBuffer();throw new Error(`Failed to load model with error code ${t.status}`)}})).then((n=>{if(e.__loadIndex===s)return t.downloading--,t.parsing++,e.__loadAbort=null,e.__loadingState=2,r.add(e,(e=>{if(e.__loadIndex!==s)return Promise.resolve();let t=z4(e.content.uri);return this.parseTile(n,e,t)}))})).then((()=>{e.__loadIndex===s&&(t.parsing--,e.__loadingState=3,e.__wasSetVisible&&this.setTileVisible(e,!0),e.__wasSetActive&&this.setTileActive(e,!0))})).catch(h)}dispose(){let e=this.lruCache;this.traverse((t=>{e.remove(t)})),this.stats={parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0},this.frameCount=0}};function NP(e){return(new TextDecoder).decode(e)}var fd=class{constructor(e,t,n,i){this.buffer=e,this.binOffset=t+n,this.binLength=i;let r=null;if(0!==n){let i=new Uint8Array(e,t,n);r=JSON.parse(NP(i))}else r={};this.header=r}getKeys(){return Object.keys(this.header)}getData(e,t,n=null,i=null){let r=this.header;if(!(e in r))return null;let a=r[e];if(a instanceof Object){if(Array.isArray(a))return a;{let r,{buffer:s,binOffset:o,binLength:l}=this,h=a.byteOffset||0,c=a.type||i,u=a.componentType||n;if("type"in a&&i&&a.type!==i)throw new Error("FeatureTable: Specified type does not match expected type.");switch(c){case"SCALAR":r=1;break;case"VEC2":r=2;break;case"VEC3":r=3;break;case"VEC4":r=4;break;default:throw new Error(`FeatureTable : Feature type not provided for "${e}".`)}let d,p=o+h,f=t*r;switch(u){case"BYTE":d=new Int8Array(s,p,f);break;case"UNSIGNED_BYTE":d=new Uint8Array(s,p,f);break;case"SHORT":d=new Int16Array(s,p,f);break;case"UNSIGNED_SHORT":d=new Uint16Array(s,p,f);break;case"INT":d=new Int32Array(s,p,f);break;case"UNSIGNED_INT":d=new Uint32Array(s,p,f);break;case"FLOAT":d=new Float32Array(s,p,f);break;case"DOUBLE":d=new Float64Array(s,p,f);break;default:throw new Error(`FeatureTable : Feature component type not provided for "${e}".`)}if(p+f*d.BYTES_PER_ELEMENT>o+l)throw new Error("FeatureTable: Feature data read outside binary body length.");return d}}return a}getBuffer(e,t){let{buffer:n,binOffset:i}=this;return n.slice(i+e,i+e+t)}},ep=class extends fd{constructor(e,t,n,i,r){super(e,n,i,r),this.batchSize=t}getData(e,t=null,n=null){return super.getData(e,this.batchSize,t,n)}},Zl=class{constructor(){this.fetchOptions={},this.workingPath=""}load(e){return fetch(e,this.fetchOptions).then((t=>{if(!t.ok)throw new Error(`Failed to load file "${e}" with status ${t.status} : ${t.statusText}`);return t.arrayBuffer()})).then((t=>(""===this.workingPath&&(this.workingPath=this.workingPathForURL(e)),this.parse(t))))}resolveExternalURL(e){return/^[^\\/]/.test(e)?this.workingPath+"/"+e:e}workingPathForURL(e){let t=e.split(/[\\/]/g);return t.pop(),t.join("/")+"/"}parse(e){throw new Error("LoaderBase: Parse not implemented.")}};function Gc(e){let t;if(t=e instanceof DataView?e:new DataView(e),"{"===String.fromCharCode(t.getUint8(0)))return null;let n="";for(let i=0;i<4;i++)n+=String.fromCharCode(t.getUint8(i));return n}var BP=class extends Zl{parse(e){let t=new DataView(e),n=Gc(t);console.assert("b3dm"===n);let i=t.getUint32(4,!0);console.assert(1===i);let r=t.getUint32(8,!0);console.assert(r===e.byteLength);let a=t.getUint32(12,!0),s=t.getUint32(16,!0),o=t.getUint32(20,!0),l=t.getUint32(24,!0),h=e.slice(28,28+a+s),c=new fd(h,0,a,s),u=28+a+s,d=e.slice(u,u+o+l),p=new ep(d,c.getData("BATCH_LENGTH"),0,o,l),f=u+o+l;return{version:i,featureTable:c,batchTable:p,glbBytes:new Uint8Array(e,f,r-f)}}},Fy=class extends BP{constructor(e=go){super(),this.manager=e,this.adjustmentTransform=new et}parse(e){let t=super.parse(e),n=t.glbBytes.slice().buffer;return new Promise(((e,i)=>{let r=this.manager,a=this.fetchOptions,s=r.getHandler("path.gltf")||new th(r);"include"===a.credentials&&"cors"===a.mode&&s.setCrossOrigin("use-credentials"),"credentials"in a&&s.setWithCredentials("include"===a.credentials),a.headers&&s.setRequestHeader(a.headers);let o=this.workingPath;!/[\\/]$/.test(o)&&o.length&&(o+="/");let l=this.adjustmentTransform;s.parse(n,o,(n=>{let{batchTable:i,featureTable:r}=t,{scene:a}=n,s=r.getData("RTC_CENTER");s&&(a.position.x+=s[0],a.position.y+=s[1],a.position.z+=s[2]),n.scene.updateMatrix(),n.scene.matrix.multiply(l),n.scene.matrix.decompose(n.scene.position,n.scene.quaternion,n.scene.scale),n.batchTable=i,n.featureTable=r,a.batchTable=i,a.featureTable=r,e(n)}),i)}))}},UP=class extends Zl{parse(e){let t=new DataView(e),n=Gc(t);console.assert("pnts"===n);let i=t.getUint32(4,!0);console.assert(1===i);let r=t.getUint32(8,!0);console.assert(r===e.byteLength);let a=t.getUint32(12,!0),s=t.getUint32(16,!0),o=t.getUint32(20,!0),l=t.getUint32(24,!0),h=e.slice(28,28+a+s),c=new fd(h,0,a,s),u=28+a+s,d=e.slice(u,u+o+l),p=new ep(d,c.getData("BATCH_LENGTH")||c.getData("POINTS_LENGTH"),0,o,l);return Promise.resolve({version:i,featureTable:c,batchTable:p})}},Tve={RGB:"color",POSITION:"position"},Ny=class extends UP{constructor(e=go){super(),this.manager=e}parse(e){return super.parse(e).then((e=>ft(this,null,(function*(){let t,{featureTable:n}=e,i=new xi,r=n.header.extensions;if(r&&r["3DTILES_draco_point_compression"]){let{byteOffset:e,byteLength:a,properties:s}=r["3DTILES_draco_point_compression"],o=this.manager.getHandler("draco.drc");if(null==o)throw new Error("PNTSLoader: dracoLoader not available.");let l={};for(let t in s)t in Tve&&t in s&&(l[Tve[t]]=s[t]);let h={attributeIDs:l,attributeTypes:{position:"Float32Array",color:"Uint8Array"},useUniqueIDs:!0},c=n.getBuffer(e,a);t=yield o.decodeGeometry(c,h),t.attributes.color&&(i.vertexColors=!0)}else{let e=n.getData("POINTS_LENGTH"),r=n.getData("POSITION",e,"FLOAT","VEC3"),a=n.getData("RGB",e,"UNSIGNED_BYTE","VEC3");t=new Dt,t.setAttribute("position",new mn(r,3,!1)),null!==a&&(t.setAttribute("color",new mn(a,3,!0)),i.vertexColors=!0)}["QUANTIZED_VOLUME_OFFSET","QUANTIZED_VOLUME_SCALE","CONSTANT_RGBA","BATCH_LENGTH","POSITION_QUANTIZED","RGBA","RGB565","NORMAL","NORMAL_OCT16P"].forEach((e=>{e in n.header&&console.warn(`PNTSLoader: Unsupported FeatureTable feature "${e}" detected.`)}));let a=new ii(t,i);e.scene=a,e.scene.featureTable=n;let s=n.getData("RTC_CENTER");return s&&(e.scene.position.x+=s[0],e.scene.position.y+=s[1],e.scene.position.z+=s[2]),e}))))}},HP=class extends Zl{parse(e){let t=new DataView(e),n=Gc(t);console.assert("i3dm"===n);let i=t.getUint32(4,!0);console.assert(1===i);let r=t.getUint32(8,!0);console.assert(r===e.byteLength);let a=t.getUint32(12,!0),s=t.getUint32(16,!0),o=t.getUint32(20,!0),l=t.getUint32(24,!0),h=t.getUint32(28,!0),c=e.slice(32,32+a+s),u=new fd(c,0,a,s),d=32+a+s,p=e.slice(d,d+o+l),f=new ep(p,u.getData("INSTANCES_LENGTH"),0,o,l),m=d+o+l,g=new Uint8Array(e,m,r-m),v=null,y=null;if(h)v=g,y=Promise.resolve();else{let e=this.resolveExternalURL(NP(g));y=fetch(e,this.fetchOptions).then((t=>{if(!t.ok)throw new Error(`I3DMLoaderBase : Failed to load file "${e}" with status ${t.status} : ${t.statusText}`);return t.arrayBuffer()})).then((e=>{v=new Uint8Array(e)}))}return y.then((()=>({version:i,featureTable:u,batchTable:f,glbBytes:v})))}},wve=new O,K4=new O,J4=new O,Sve=new O,Q4=new dr,VP=new O,zP=new et,By=class extends HP{constructor(e=go){super(),this.manager=e,this.adjustmentTransform=new et}resolveExternalURL(e){return this.manager.resolveURL(super.resolveExternalURL(e))}parse(e){return super.parse(e).then((e=>{let{featureTable:t,batchTable:n}=e,i=e.glbBytes.slice().buffer;return new Promise(((e,r)=>{let a=this.fetchOptions,s=this.manager,o=s.getHandler("path.gltf")||new th(s);"include"===a.credentials&&"cors"===a.mode&&o.setCrossOrigin("use-credentials"),"credentials"in a&&o.setWithCredentials("include"===a.credentials),a.headers&&o.setRequestHeader(a.headers);let l=this.workingPath;/[\\/]$/.test(l)||(l+="/");let h=this.adjustmentTransform;o.parse(i,l,(i=>{let r=t.getData("INSTANCES_LENGTH"),a=t.getData("POSITION",r,"FLOAT","VEC3"),s=t.getData("NORMAL_UP",r,"FLOAT","VEC3"),o=t.getData("NORMAL_RIGHT",r,"FLOAT","VEC3"),l=t.getData("SCALE_NON_UNIFORM",r,"FLOAT","VEC3"),c=t.getData("SCALE",r,"FLOAT","SCALAR");["RTC_CENTER","QUANTIZED_VOLUME_OFFSET","QUANTIZED_VOLUME_SCALE","EAST_NORTH_UP","POSITION_QUANTIZED","NORMAL_UP_OCT32P","NORMAL_RIGHT_OCT32P"].forEach((e=>{e in t.header&&console.warn(`I3DMLoader: Unsupported FeatureTable feature "${e}" detected.`)}));let u=new Map,d=[];i.scene.traverse((e=>{if(e.isMesh){let{geometry:t,material:n}=e,i=new Pi(t,n,r);i.position.copy(e.position),i.rotation.copy(e.rotation),i.scale.copy(e.scale),d.push(i),u.set(e,i)}}));let p=new O;for(let e=0;e{let n=t.parent;n&&(n.remove(t),n.add(e),e.updateMatrixWorld(),e.position.copy(p).applyMatrix4(e.matrixWorld))}));for(let e=0;e{let t=new er;return e.forEach((e=>{t.add(e.scene)})),{tiles:e,scene:t}}))}},WP=class{constructor(){this.name="CESIUM_RTC"}afterRoot(e){if(e.parser.json.extensions&&e.parser.json.extensions.CESIUM_RTC){let{center:t}=e.parser.json.extensions.CESIUM_RTC;t&&(e.scene.position.x+=t[0],e.scene.position.y+=t[1],e.scene.position.z+=t[2])}}},jP=class extends Zl{constructor(e=go){super(),this.manager=e}parse(e){return new Promise(((t,n)=>{let i=this.manager,r=this.fetchOptions,a=i.getHandler("path.gltf")||i.getHandler("path.glb");a||(a=new th(i),a.register((()=>new WP)),"include"===r.credentials&&"cors"===r.mode&&a.setCrossOrigin("use-credentials"),"credentials"in r&&a.setWithCredentials("include"===r.credentials),r.headers&&a.setRequestHeader(r.headers));let s=a.resourcePath||a.path||this.workingPath;!/[\\/]$/.test(s)&&s.length&&(s+="/"),a.parse(e,s,(e=>{t(e)}),n)}))}},XP=new et,YP=class extends er{constructor(e){super(),this.name="TilesRenderer.TilesGroup",this.tilesRenderer=e}raycast(e,t){this.tilesRenderer.optimizeRaycast&&this.tilesRenderer.raycast(e,t)}updateMatrixWorld(e){if(this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldNeedsUpdate||e){null===this.parent?XP.copy(this.matrix):XP.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1;let e=XP.elements,t=this.matrixWorld.elements,n=!1;for(let i=0;i<16;i++){let r=e[i],a=t[i];if(Math.abs(r-a)>Number.EPSILON){n=!0;break}}if(n){this.matrixWorld.copy(XP);let e=this.children;for(let t=0,n=e.length;t=t&&s<=n&&l>=i&&l<=r){let t=Ivt(e);u.push(t),this.getCartographicToPosition(s,l,o,t)}}}return u}getBoundingBox(e,t){Ave();let{latStart:n,latEnd:i,lonStart:r,lonEnd:a}=this;if(i-n{Object.getPrototypeOf(e).raycast.call(e,t,n)}))}function rV(e,t,n,i){if(n.has(e)){if(nV(e.cached.scene,i,Kl),Kl.length>0){Kl.length>1&&Kl.sort(tV);let e=Kl[0];return Kl.length=0,e}return null}let r=[],a=e.children;for(let l=0,h=a.length;l1e-6&&console.warn("ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when raycasting.");let n={distance:1/0,tile:null};r.push(n),h.containsPoint(lg.origin)?n.distance=0:n.distance=Cve.distanceToSquared(lg.origin)*t*t,n.tile=e}}}r.sort(tV);let s=1/0,o=null;for(let l=0,h=r.length;ls)break;{let r=e.tile,a=r.cached.scene,l=null;if(n.has(r)?(nV(a,i,Kl),Kl.length>0&&(Kl.length>1&&Kl.sort(tV),l=Kl[0])):l=rV(r,t,n,i),l){let e=l.distance*l.distance;e{e.frustumCulled=e[Lve]&&t}))}var w_=class extends FP{get autoDisableRendererCulling(){return this._autoDisableRendererCulling}set autoDisableRendererCulling(e){this._autoDisableRendererCulling!==e&&(super._autoDisableRendererCulling=e,this.forEachLoadedModel((t=>{Ive(t,!e)})))}constructor(...e){super(...e),this.group=new YP(this),this.cameras=[],this.cameraMap=new Map,this.cameraInfo=[],this.activeTiles=new Set,this.visibleTiles=new Set,this._autoDisableRendererCulling=!0,this.optimizeRaycast=!0,this.onLoadTileSet=null,this.onLoadModel=null,this.onDisposeModel=null,this.onTileVisibilityChange=null;let t=new Lu;t.setURLModifier((e=>this.preprocessURL?this.preprocessURL(e):e)),this.manager=t;let n=this;this._overridenRaycast=function(e,t){n.optimizeRaycast||Object.getPrototypeOf(this).raycast.call(this,e,t)}}getBounds(e){if(!this.root)return!1;let t=this.root.cached,n=t.box,i=t.boxTransform;return!!n&&(e.copy(n),e.applyMatrix4(i),!0)}getOrientedBounds(e,t){if(!this.root)return!1;let n=this.root.cached,i=n.box,r=n.boxTransform;return!!i&&(e.copy(i),t.copy(r),!0)}getBoundingSphere(e){if(!this.root)return!1;let t=this.root.cached.sphere;return!!t&&(e.copy(t),!0)}forEachLoadedModel(e){this.traverse((t=>{let n=t.cached.scene;n&&e(n,t)}))}raycast(e,t){if(this.root)if(e.firstHitOnly){let n=rV(this.root,this.group,this.activeTiles,e);n&&t.push(n)}else iV(this.root,this.group,this.activeTiles,e,t)}hasCamera(e){return this.cameraMap.has(e)}setCamera(e){let t=this.cameras,n=this.cameraMap;return!n.has(e)&&(n.set(e,new be),t.push(e),!0)}setResolution(e,t,n){let i=this.cameraMap;return!!i.has(e)&&(t instanceof be?i.get(e).copy(t):i.get(e).set(t,n),!0)}setResolutionFromRenderer(e,t){let n=this.cameraMap;if(!n.has(e))return!1;let i=n.get(e);return t.getSize(i),i.multiplyScalar(t.getPixelRatio()),!0}deleteCamera(e){let t=this.cameras,n=this.cameraMap;if(n.has(e)){let i=t.indexOf(e);return t.splice(i,1),n.delete(e),!0}return!1}fetchTileSet(e,...t){let n=super.fetchTileSet(e,...t);return n.then((t=>{this.onLoadTileSet&&Promise.resolve().then((()=>{this.onLoadTileSet(t,e)}))})),n}update(){let e=this.group,t=this.cameras,n=this.cameraMap,i=this.cameraInfo;if(0===t.length)return void console.warn("TilesRenderer: no cameras defined. Cannot update 3d tiles.");for(;i.length>t.length;)i.pop();for(;i.length1e-6&&console.warn("ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when calculating screen space error.");for(let a=0,s=i.length;ae.scene));break}case"pnts":{let t=new Ny(s);t.workingPath=r,t.fetchOptions=a,l=t.parse(e).then((e=>e.scene));break}case"i3dm":{let t=new By(s);t.workingPath=r,t.fetchOptions=a,t.adjustmentTransform.copy(qc),l=t.parse(e).then((e=>e.scene));break}case"cmpt":{let t=new qP(s);t.workingPath=r,t.fetchOptions=a,t.adjustmentTransform.copy(qc),l=t.parse(e).then((e=>e.scene));break}case"gltf":case"glb":let t=new jP(s);t.workingPath=r,t.fetchOptions=a,l=t.parse(e).then((e=>e.scene));break;default:console.warn(`TilesRenderer: Content type "${d}" not supported.`),l=Promise.resolve(null)}return l.then((e=>{if(t._loadIndex!==o)return;e.updateMatrix(),("glb"===d||"gltf"===d)&&e.matrix.multiply(qc),e.matrix.premultiply(u),e.matrix.decompose(e.position,e.quaternion,e.scale),e.traverse((e=>{e[Lve]=e.frustumCulled})),Ive(e,!this.autoDisableRendererCulling),c.scene=e,e.traverse((e=>{e.raycast=this._overridenRaycast}));let n=[],i=[],r=[];e.traverse((e=>{if(e.geometry&&i.push(e.geometry),e.material){let t=e.material;n.push(e.material);for(let e in t){let n=t[e];n&&n.isTexture&&r.push(n)}}})),c.materials=n,c.geometry=i,c.textures=r,this.onLoadModel&&this.onLoadModel(e,t)}))}disposeTile(e){let t=e.cached;if(t.scene){let n=t.materials,i=t.geometry,r=t.textures,a=t.scene.parent;for(let e=0,t=i.length;e25&&(t=25);let n=.5*(t-1),i=new Array(t),r=0;for(let a=0;a0){e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();let t=e.autoClear;e.autoClear=!1,r&&e.state.buffers.stencil.setTest(!1),e.setClearColor(16777215,1),this.changeVisibilityOfSelectedObjects(!1);let i=this.renderScene.background;if(this.renderScene.background=null,this.renderScene.overrideMaterial=this.depthMaterial,e.setRenderTarget(this.renderTargetDepthBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.changeVisibilityOfSelectedObjects(!0),this._visibilityCache.clear(),this.updateTextureMatrix(),this.changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this.prepareMaskMaterial,this.prepareMaskMaterial.uniforms.cameraNearFar.value.set(this.renderCamera.near,this.renderCamera.far),this.prepareMaskMaterial.uniforms.depthTexture.value=this.renderTargetDepthBuffer.texture,this.prepareMaskMaterial.uniforms.textureMatrix.value=this.textureMatrix,e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),e.render(this.renderScene,this.renderCamera),this.renderScene.overrideMaterial=null,this.changeVisibilityOfNonSelectedObjects(!0),this._visibilityCache.clear(),this.renderScene.background=i,this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){let e=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(e),this.tempPulseColor2.multiplyScalar(e)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value.set(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=jc.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=jc.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=jc.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=jc.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,r&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=t}this.renderToScreen&&(this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=n.texture,e.setRenderTarget(null),this.fsQuad.render(e))}getPrepareMaskMaterial(){return new ln({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new be(.5,.5)},textureMatrix:{value:null}},vertexShader:"#include \n\t\t\t\t#include \n\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tuniform mat4 textureMatrix;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t\tvPosition = mvPosition;\n\n\t\t\t\t\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t\t\t\t\t#ifdef USE_INSTANCING\n\n\t\t\t\t\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t\t\t\t\t#endif\n\t\t\t\t\t\n\t\t\t\t\tworldPosition = modelMatrix * worldPosition;\n\n\t\t\t\t\tprojTexCoord = textureMatrix * worldPosition;\n\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\tvarying vec4 vPosition;\n\t\t\t\tvarying vec4 projTexCoord;\n\t\t\t\tuniform sampler2D depthTexture;\n\t\t\t\tuniform vec2 cameraNearFar;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tfloat depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\n\t\t\t\t\tfloat viewZ = - DEPTH_TO_VIEW_Z( depth, cameraNearFar.x, cameraNearFar.y );\n\t\t\t\t\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\n\t\t\t\t\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\n\n\t\t\t\t}"})}getEdgeDetectionMaterial(){return new ln({uniforms:{maskTexture:{value:null},texSize:{value:new be(.5,.5)},visibleEdgeColor:{value:new O(1,1,1)},hiddenEdgeColor:{value:new O(1,1,1)}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec3 visibleEdgeColor;\n\t\t\t\tuniform vec3 hiddenEdgeColor;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\n\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\n\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\n\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\n\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\n\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\n\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\n\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\n\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\n\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\n\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\n\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\n\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\n\t\t\t\t}"})}getSeperableBlurMaterial(e){return new ln({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new be(.5,.5)},direction:{value:new be(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float kernelRadius;\n\n\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\n\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\n\t\t\t\t\tfloat sigma = kernelRadius/2.0;\n\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, sigma);\n\t\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\n\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\n\t\t\t\t\tvec2 uvOffset = delta;\n\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = kernelRadius * float(i) / float(MAX_RADIUS);\n\t\t\t\t\t\tfloat w = gaussianPdf(x, sigma);\n\t\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\n\t\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\n\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\n\t\t\t\t\t\tweightSum += (2.0 * w);\n\t\t\t\t\t\tuvOffset += delta;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = diffuseSum/weightSum;\n\t\t\t\t}"})}getOverlayMaterial(){return new ln({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\n\t\t\t\tuniform sampler2D maskTexture;\n\t\t\t\tuniform sampler2D edgeTexture1;\n\t\t\t\tuniform sampler2D edgeTexture2;\n\t\t\t\tuniform sampler2D patternTexture;\n\t\t\t\tuniform float edgeStrength;\n\t\t\t\tuniform float edgeGlow;\n\t\t\t\tuniform bool usePatternTexture;\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\n\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\n\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\n\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\n\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\n\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\n\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\n\t\t\t\t\tif(usePatternTexture)\n\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\n\t\t\t\t\tgl_FragColor = finalColor;\n\t\t\t\t}",blending:_c,depthTest:!1,depthWrite:!1,transparent:!0})}};jc.BlurDirectionX=new be(1,0),jc.BlurDirectionY=new be(0,1);var r2=class extends bs{constructor(e,t,n,i,r){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=i,this.clearAlpha=void 0!==r?r:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new ct}render(e,t,n){let i,r,a=e.autoClear;e.autoClear=!1,void 0!==this.overrideMaterial&&(r=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor&&(e.getClearColor(this._oldClearColor),i=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor&&e.setClearColor(this._oldClearColor,i),void 0!==this.overrideMaterial&&(this.scene.overrideMaterial=r),e.autoClear=a}},A_={defines:{NUM_SAMPLES:7,NUM_RINGS:4,NORMAL_TEXTURE:0,DIFFUSE_TEXTURE:0,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},tDiffuse:{value:null},tNormal:{value:null},size:{value:new be(512,512)},cameraNear:{value:1},cameraFar:{value:100},cameraProjectionMatrix:{value:new et},cameraInverseProjectionMatrix:{value:new et},scale:{value:1},intensity:{value:.1},bias:{value:.5},minResolution:{value:0},kernelRadius:{value:100},randomSeed:{value:0}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\t#include \n\n\t\tvarying vec2 vUv;\n\n\t\t#if DIFFUSE_TEXTURE == 1\n\t\tuniform sampler2D tDiffuse;\n\t\t#endif\n\n\t\tuniform sampler2D tDepth;\n\n\t\t#if NORMAL_TEXTURE == 1\n\t\tuniform sampler2D tNormal;\n\t\t#endif\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\n\t\tuniform float scale;\n\t\tuniform float intensity;\n\t\tuniform float bias;\n\t\tuniform float kernelRadius;\n\t\tuniform float minResolution;\n\t\tuniform vec2 size;\n\t\tuniform float randomSeed;\n\n\t\t// RGBA depth\n\n\t\t#include \n\n\t\tvec4 getDefaultColor( const in vec2 screenPosition ) {\n\t\t\t#if DIFFUSE_TEXTURE == 1\n\t\t\treturn texture2D( tDiffuse, vUv );\n\t\t\t#else\n\t\t\treturn vec4( 1.0 );\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\n\t\tvec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n\t\t\tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );\n\t\t\tclipPosition *= clipW; // unprojection.\n\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;\n\t\t}\n\n\t\tvec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {\n\t\t\t#if NORMAL_TEXTURE == 1\n\t\t\treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );\n\t\t\t#else\n\t\t\treturn normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );\n\t\t\t#endif\n\t\t}\n\n\t\tfloat scaleDividedByCameraFar;\n\t\tfloat minResolutionMultipliedByCameraFar;\n\n\t\tfloat getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {\n\t\t\tvec3 viewDelta = sampleViewPosition - centerViewPosition;\n\t\t\tfloat viewDistance = length( viewDelta );\n\t\t\tfloat scaledScreenDistance = scaleDividedByCameraFar * viewDistance;\n\n\t\t\treturn max(0.0, (dot(centerViewNormal, viewDelta) - minResolutionMultipliedByCameraFar) / scaledScreenDistance - bias) / (1.0 + pow2( scaledScreenDistance ) );\n\t\t}\n\n\t\t// moving costly divides into consts\n\t\tconst float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );\n\t\tconst float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );\n\n\t\tfloat getAmbientOcclusion( const in vec3 centerViewPosition ) {\n\t\t\t// precompute some variables require in getOcclusion.\n\t\t\tscaleDividedByCameraFar = scale / cameraFar;\n\t\t\tminResolutionMultipliedByCameraFar = minResolution * cameraFar;\n\t\t\tvec3 centerViewNormal = getViewNormal( centerViewPosition, vUv );\n\n\t\t\t// jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/\n\t\t\tfloat angle = rand( vUv + randomSeed ) * PI2;\n\t\t\tvec2 radius = vec2( kernelRadius * INV_NUM_SAMPLES ) / size;\n\t\t\tvec2 radiusStep = radius;\n\n\t\t\tfloat occlusionSum = 0.0;\n\t\t\tfloat weightSum = 0.0;\n\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i ++ ) {\n\t\t\t\tvec2 sampleUv = vUv + vec2( cos( angle ), sin( angle ) ) * radius;\n\t\t\t\tradius += radiusStep;\n\t\t\t\tangle += ANGLE_STEP;\n\n\t\t\t\tfloat sampleDepth = getDepth( sampleUv );\n\t\t\t\tif( sampleDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tfloat sampleViewZ = getViewZ( sampleDepth );\n\t\t\t\tvec3 sampleViewPosition = getViewPosition( sampleUv, sampleDepth, sampleViewZ );\n\t\t\t\tocclusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );\n\t\t\t\tweightSum += 1.0;\n\t\t\t}\n\n\t\t\tif( weightSum == 0.0 ) discard;\n\n\t\t\treturn occlusionSum * ( intensity / weightSum );\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat centerDepth = getDepth( vUv );\n\t\t\tif( centerDepth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\tfloat centerViewZ = getViewZ( centerDepth );\n\t\t\tvec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );\n\n\t\t\tfloat ambientOcclusion = getAmbientOcclusion( viewPosition );\n\n\t\t\tgl_FragColor = getDefaultColor( vUv );\n\t\t\tgl_FragColor.xyz *= 1.0 - ambientOcclusion;\n\t\t}"},yd={defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{value:null},size:{value:new be(512,512)},sampleUvOffsets:{value:[new be(0,0)]},sampleWeights:{value:[1]},tDepth:{value:null},cameraNear:{value:10},cameraFar:{value:1e3},depthCutoff:{value:10}},vertexShader:"\n\n\t\t#include \n\n\t\tuniform vec2 size;\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec2 vInvSize;\n\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tvInvSize = 1.0 / size;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t}",fragmentShader:"\n\n\t\t#include \n\t\t#include \n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tDepth;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform float depthCutoff;\n\n\t\tuniform vec2 sampleUvOffsets[ KERNEL_RADIUS + 1 ];\n\t\tuniform float sampleWeights[ KERNEL_RADIUS + 1 ];\n\n\t\tvarying vec2 vUv;\n\t\tvarying vec2 vInvSize;\n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\t\t\t#if DEPTH_PACKING == 1\n\t\t\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );\n\t\t\t#else\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\t\t\t#endif\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#else\n\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\t\t\t#endif\n\t\t}\n\n\t\tvoid main() {\n\t\t\tfloat depth = getDepth( vUv );\n\t\t\tif( depth >= ( 1.0 - EPSILON ) ) {\n\t\t\t\tdiscard;\n\t\t\t}\n\n\t\t\tfloat centerViewZ = -getViewZ( depth );\n\t\t\tbool rBreak = false, lBreak = false;\n\n\t\t\tfloat weightSum = sampleWeights[0];\n\t\t\tvec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;\n\n\t\t\tfor( int i = 1; i <= KERNEL_RADIUS; i ++ ) {\n\n\t\t\t\tfloat sampleWeight = sampleWeights[i];\n\t\t\t\tvec2 sampleUvOffset = sampleUvOffsets[i] * vInvSize;\n\n\t\t\t\tvec2 sampleUv = vUv + sampleUvOffset;\n\t\t\t\tfloat viewZ = -getViewZ( getDepth( sampleUv ) );\n\n\t\t\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) rBreak = true;\n\n\t\t\t\tif( ! rBreak ) {\n\t\t\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;\n\t\t\t\t\tweightSum += sampleWeight;\n\t\t\t\t}\n\n\t\t\t\tsampleUv = vUv - sampleUvOffset;\n\t\t\t\tviewZ = -getViewZ( getDepth( sampleUv ) );\n\n\t\t\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) lBreak = true;\n\n\t\t\t\tif( ! lBreak ) {\n\t\t\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;\n\t\t\t\t\tweightSum += sampleWeight;\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tgl_FragColor = diffuseSum / weightSum;\n\t\t}"},C_={createSampleWeights:function(e,t){let n=[];for(let i=0;i<=e;i++)n.push(Fvt(i,t));return n},createSampleOffsets:function(e,t){let n=[];for(let i=0;i<=e;i++)n.push(t.clone().multiplyScalar(i));return n},configure:function(e,t,n,i){e.defines.KERNEL_RADIUS=t,e.uniforms.sampleUvOffsets.value=C_.createSampleOffsets(t,i),e.uniforms.sampleWeights.value=C_.createSampleWeights(t,n),e.needsUpdate=!0}};function Fvt(e,t){return Math.exp(-e*e/(t*t*2))/(Math.sqrt(2*Math.PI)*t)}var i2={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform float opacity;\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tvarying vec2 vUv;\n\n\t\t#include \n\n\t\tvoid main() {\n\n\t\t\tfloat depth = 1.0 - unpackRGBAToDepth( texture2D( tDiffuse, vUv ) );\n\t\t\tgl_FragColor = vec4( vec3( depth ), opacity );\n\n\t\t}"},P_=class extends bs{constructor(e,t,n=!1,i=!1,r=new be(256,256)){let a;super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.supportsDepthTextureExtension=n,this.supportsNormalTexture=i,this.originalClearColor=new ct,this._oldClearColor=new ct,this.oldClearAlpha=1,this.params={output:0,saoBias:.5,saoIntensity:.18,saoScale:1,saoKernelRadius:100,saoMinResolution:0,saoBlur:!0,saoBlurRadius:8,saoBlurStdDev:4,saoBlurDepthCutoff:.01},this.resolution=new be(r.x,r.y),this.saoRenderTarget=new sr(this.resolution.x,this.resolution.y,{type:Rr}),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone(),this.beautyRenderTarget=this.saoRenderTarget.clone(),this.normalRenderTarget=new sr(this.resolution.x,this.resolution.y,{minFilter:Jr,magFilter:Jr,type:Rr}),this.depthRenderTarget=this.normalRenderTarget.clone(),this.supportsDepthTextureExtension&&(a=new cf,a.type=Sv,this.beautyRenderTarget.depthTexture=a,this.beautyRenderTarget.depthBuffer=!0),this.depthMaterial=new Tc,this.depthMaterial.depthPacking=Rv,this.depthMaterial.blending=Qr,this.normalMaterial=new df,this.normalMaterial.blending=Qr,this.saoMaterial=new ln({defines:Object.assign({},A_.defines),fragmentShader:A_.fragmentShader,vertexShader:A_.vertexShader,uniforms:Ti.clone(A_.uniforms)}),this.saoMaterial.extensions.derivatives=!0,this.saoMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.saoMaterial.defines.NORMAL_TEXTURE=this.supportsNormalTexture?1:0,this.saoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.saoMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?a:this.depthRenderTarget.texture,this.saoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.saoMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.blending=Qr,this.vBlurMaterial=new ln({uniforms:Ti.clone(yd.uniforms),defines:Object.assign({},yd.defines),vertexShader:yd.vertexShader,fragmentShader:yd.fragmentShader}),this.vBlurMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.vBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.vBlurMaterial.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.vBlurMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?a:this.depthRenderTarget.texture,this.vBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.vBlurMaterial.blending=Qr,this.hBlurMaterial=new ln({uniforms:Ti.clone(yd.uniforms),defines:Object.assign({},yd.defines),vertexShader:yd.vertexShader,fragmentShader:yd.fragmentShader}),this.hBlurMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.hBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.hBlurMaterial.uniforms.tDiffuse.value=this.blurIntermediateRenderTarget.texture,this.hBlurMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?a:this.depthRenderTarget.texture,this.hBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.hBlurMaterial.blending=Qr,this.materialCopy=new ln({uniforms:Ti.clone(Sa.uniforms),vertexShader:Sa.vertexShader,fragmentShader:Sa.fragmentShader,blending:Qr}),this.materialCopy.transparent=!0,this.materialCopy.depthTest=!1,this.materialCopy.depthWrite=!1,this.materialCopy.blending=Mm,this.materialCopy.blendSrc=Tv,this.materialCopy.blendDst=pf,this.materialCopy.blendEquation=qo,this.materialCopy.blendSrcAlpha=_v,this.materialCopy.blendDstAlpha=pf,this.materialCopy.blendEquationAlpha=qo,this.depthCopy=new ln({uniforms:Ti.clone(i2.uniforms),vertexShader:i2.vertexShader,fragmentShader:i2.fragmentShader,blending:Qr}),this.fsQuad=new wa(null)}render(e,t,n){if(this.renderToScreen&&(this.materialCopy.blending=Qr,this.materialCopy.uniforms.tDiffuse.value=n.texture,this.materialCopy.needsUpdate=!0,this.renderPass(e,this.materialCopy,null)),1===this.params.output)return;e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();let i=e.autoClear;e.autoClear=!1,e.setRenderTarget(this.depthRenderTarget),e.clear(),this.saoMaterial.uniforms.bias.value=this.params.saoBias,this.saoMaterial.uniforms.intensity.value=this.params.saoIntensity,this.saoMaterial.uniforms.scale.value=this.params.saoScale,this.saoMaterial.uniforms.kernelRadius.value=this.params.saoKernelRadius,this.saoMaterial.uniforms.minResolution.value=this.params.saoMinResolution,this.saoMaterial.uniforms.cameraNear.value=this.camera.near,this.saoMaterial.uniforms.cameraFar.value=this.camera.far;let r=this.params.saoBlurDepthCutoff*(this.camera.far-this.camera.near);this.vBlurMaterial.uniforms.depthCutoff.value=r,this.hBlurMaterial.uniforms.depthCutoff.value=r,this.vBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.vBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.hBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.hBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.params.saoBlurRadius=Math.floor(this.params.saoBlurRadius),(this.prevStdDev!==this.params.saoBlurStdDev||this.prevNumSamples!==this.params.saoBlurRadius)&&(C_.configure(this.vBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new be(0,1)),C_.configure(this.hBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new be(1,0)),this.prevStdDev=this.params.saoBlurStdDev,this.prevNumSamples=this.params.saoBlurRadius),e.setClearColor(0),e.setRenderTarget(this.beautyRenderTarget),e.clear(),e.render(this.scene,this.camera),this.supportsDepthTextureExtension||this.renderOverride(e,this.depthMaterial,this.depthRenderTarget,0,1),this.supportsNormalTexture&&this.renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this.renderPass(e,this.saoMaterial,this.saoRenderTarget,16777215,1),this.params.saoBlur&&(this.renderPass(e,this.vBlurMaterial,this.blurIntermediateRenderTarget,16777215,1),this.renderPass(e,this.hBlurMaterial,this.saoRenderTarget,16777215,1));let a=this.materialCopy;3===this.params.output?this.supportsDepthTextureExtension?(this.materialCopy.uniforms.tDiffuse.value=this.beautyRenderTarget.depthTexture,this.materialCopy.needsUpdate=!0):(this.depthCopy.uniforms.tDiffuse.value=this.depthRenderTarget.texture,this.depthCopy.needsUpdate=!0,a=this.depthCopy):4===this.params.output?(this.materialCopy.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.materialCopy.needsUpdate=!0):(this.materialCopy.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.materialCopy.needsUpdate=!0),0===this.params.output?a.blending=Mm:a.blending=Qr,this.renderPass(e,a,this.renderToScreen?null:n),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=i}renderPass(e,t,n,i,r){e.getClearColor(this.originalClearColor);let a=e.getClearAlpha(),s=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,null!=i&&(e.setClearColor(i),e.setClearAlpha(r||0),e.clear()),this.fsQuad.material=t,this.fsQuad.render(e),e.autoClear=s,e.setClearColor(this.originalClearColor),e.setClearAlpha(a)}renderOverride(e,t,n,i,r){e.getClearColor(this.originalClearColor);let a=e.getClearAlpha(),s=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i=t.clearColor||i,r=t.clearAlpha||r,null!=i&&(e.setClearColor(i),e.setClearAlpha(r||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=s,e.setClearColor(this.originalClearColor),e.setClearAlpha(a)}setSize(e,t){this.beautyRenderTarget.setSize(e,t),this.saoRenderTarget.setSize(e,t),this.blurIntermediateRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.depthRenderTarget.setSize(e,t),this.saoMaterial.uniforms.size.value.set(e,t),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.needsUpdate=!0,this.vBlurMaterial.uniforms.size.value.set(e,t),this.vBlurMaterial.needsUpdate=!0,this.hBlurMaterial.uniforms.size.value.set(e,t),this.hBlurMaterial.needsUpdate=!0}dispose(){this.saoRenderTarget.dispose(),this.blurIntermediateRenderTarget.dispose(),this.beautyRenderTarget.dispose(),this.normalRenderTarget.dispose(),this.depthRenderTarget.dispose(),this.depthMaterial.dispose(),this.normalMaterial.dispose(),this.saoMaterial.dispose(),this.vBlurMaterial.dispose(),this.hBlurMaterial.dispose(),this.materialCopy.dispose(),this.depthCopy.dispose(),this.fsQuad.dispose()}};P_.OUTPUT={Beauty:1,Default:0,SAO:2,Depth:3,Normal:4};var s2=class extends bs{constructor(e,t,n,i){super(),this.scene=e,this.camera=t,this.sampleLevel=4,this.unbiased=!0,this.clearColor=void 0!==n?n:0,this.clearAlpha=void 0!==i?i:0,this._oldClearColor=new ct;let r=Sa;this.copyUniforms=Ti.clone(r.uniforms),this.copyMaterial=new ln({uniforms:this.copyUniforms,vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,premultipliedAlpha:!0,blending:_c}),this.fsQuad=new wa(this.copyMaterial)}dispose(){this.sampleRenderTarget&&(this.sampleRenderTarget.dispose(),this.sampleRenderTarget=null),this.copyMaterial.dispose(),this.fsQuad.dispose()}setSize(e,t){this.sampleRenderTarget&&this.sampleRenderTarget.setSize(e,t)}render(e,t,n){this.sampleRenderTarget||(this.sampleRenderTarget=new sr(n.width,n.height,{type:Rr}),this.sampleRenderTarget.texture.name="SSAARenderPass.sample");let i=Nvt[Math.max(0,Math.min(this.sampleLevel,5))],r=e.autoClear;e.autoClear=!1,e.getClearColor(this._oldClearColor);let a=e.getClearAlpha(),s=1/i.length;this.copyUniforms.tDiffuse.value=this.sampleRenderTarget.texture;let o={fullWidth:n.width,fullHeight:n.height,offsetX:0,offsetY:0,width:n.width,height:n.height},l=Object.assign({},this.camera.view);l.enabled&&Object.assign(o,l);for(let h=0;hp?(a=1,s=0):(a=0,s=1);let f=d-a+c,m=p-s+c,g=d-1+2*c,v=p-1+2*c,y=255&l,x=255&h,b=this.perm[y+this.perm[x]]%12,_=this.perm[y+a+this.perm[x+s]]%12,w=this.perm[y+1+this.perm[x+1]]%12,S=.5-d*d-p*p;S<0?n=0:(S*=S,n=S*S*this.dot(this.grad3[b],d,p));let M=.5-f*f-m*m;M<0?i=0:(M*=M,i=M*M*this.dot(this.grad3[_],f,m));let T=.5-g*g-v*v;return T<0?r=0:(T*=T,r=T*T*this.dot(this.grad3[w],g,v)),70*(n+i+r)}noise3d(e,t,n){let i,r,a,s,o,l,h,c,u,d,p=.3333333333333333*(e+t+n),f=Math.floor(e+p),m=Math.floor(t+p),g=Math.floor(n+p),v=1/6,y=(f+m+g)*v,x=e-(f-y),b=t-(m-y),_=n-(g-y);x>=b?b>=_?(o=1,l=0,h=0,c=1,u=1,d=0):x>=_?(o=1,l=0,h=0,c=1,u=0,d=1):(o=0,l=0,h=1,c=1,u=0,d=1):b<_?(o=0,l=0,h=1,c=0,u=1,d=1):x<_?(o=0,l=1,h=0,c=0,u=1,d=1):(o=0,l=1,h=0,c=1,u=1,d=0);let w=x-o+v,S=b-l+v,M=_-h+v,T=x-c+2*v,E=b-u+2*v,A=_-d+2*v,C=x-1+.5,P=b-1+.5,R=_-1+.5,O=255&f,L=255&m,I=255&g,D=this.perm[O+this.perm[L+this.perm[I]]]%12,k=this.perm[O+o+this.perm[L+l+this.perm[I+h]]]%12,N=this.perm[O+c+this.perm[L+u+this.perm[I+d]]]%12,F=this.perm[O+1+this.perm[L+1+this.perm[I+1]]]%12,U=.6-x*x-b*b-_*_;U<0?i=0:(U*=U,i=U*U*this.dot3(this.grad3[D],x,b,_));let B=.6-w*w-S*S-M*M;B<0?r=0:(B*=B,r=B*B*this.dot3(this.grad3[k],w,S,M));let z=.6-T*T-E*E-A*A;z<0?a=0:(z*=z,a=z*z*this.dot3(this.grad3[N],T,E,A));let H=.6-C*C-P*P-R*R;return H<0?s=0:(H*=H,s=H*H*this.dot3(this.grad3[F],C,P,R)),32*(i+r+a+s)}noise4d(e,t,n,i){let r,a,s,o,l,h=this.grad4,c=this.simplex,u=this.perm,d=(Math.sqrt(5)-1)/4,p=(5-Math.sqrt(5))/20,f=(e+t+n+i)*d,m=Math.floor(e+f),g=Math.floor(t+f),v=Math.floor(n+f),y=Math.floor(i+f),x=(m+g+v+y)*p,b=e-(m-x),_=t-(g-x),w=n-(v-x),S=i-(y-x),M=(b>_?32:0)+(b>w?16:0)+(_>w?8:0)+(b>S?4:0)+(_>S?2:0)+(w>S?1:0),T=c[M][0]>=3?1:0,E=c[M][1]>=3?1:0,A=c[M][2]>=3?1:0,C=c[M][3]>=3?1:0,P=c[M][0]>=2?1:0,R=c[M][1]>=2?1:0,O=c[M][2]>=2?1:0,L=c[M][3]>=2?1:0,I=c[M][0]>=1?1:0,D=c[M][1]>=1?1:0,k=c[M][2]>=1?1:0,N=c[M][3]>=1?1:0,F=b-T+p,U=_-E+p,B=w-A+p,z=S-C+p,H=b-P+2*p,V=_-R+2*p,j=w-O+2*p,G=S-L+2*p,W=b-I+3*p,X=_-D+3*p,Y=w-k+3*p,q=S-N+3*p,J=b-1+4*p,Z=_-1+4*p,K=w-1+4*p,$=S-1+4*p,Q=255&m,ee=255&g,te=255&v,ne=255&y,ie=u[Q+u[ee+u[te+u[ne]]]]%32,re=u[Q+T+u[ee+E+u[te+A+u[ne+C]]]]%32,ae=u[Q+P+u[ee+R+u[te+O+u[ne+L]]]]%32,se=u[Q+I+u[ee+D+u[te+k+u[ne+N]]]]%32,oe=u[Q+1+u[ee+1+u[te+1+u[ne+1]]]]%32,le=.6-b*b-_*_-w*w-S*S;le<0?r=0:(le*=le,r=le*le*this.dot4(h[ie],b,_,w,S));let he=.6-F*F-U*U-B*B-z*z;he<0?a=0:(he*=he,a=he*he*this.dot4(h[re],F,U,B,z));let ce=.6-H*H-V*V-j*j-G*G;ce<0?s=0:(ce*=ce,s=ce*ce*this.dot4(h[ae],H,V,j,G));let ue=.6-W*W-X*X-Y*Y-q*q;ue<0?o=0:(ue*=ue,o=ue*ue*this.dot4(h[se],W,X,Y,q));let de=.6-J*J-Z*Z-K*K-$*$;return de<0?l=0:(de*=de,l=de*de*this.dot4(h[oe],J,Z,K,$)),27*(r+a+s+o+l)}},I_={defines:{PERSPECTIVE_CAMERA:1,KERNEL_SIZE:32},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},kernel:{value:null},cameraNear:{value:null},cameraFar:{value:null},resolution:{value:new be},cameraProjectionMatrix:{value:new et},cameraInverseProjectionMatrix:{value:new et},kernelRadius:{value:8},minDistance:{value:.005},maxDistance:{value:.05}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tuniform sampler2D tDiffuse;\n\t\tuniform sampler2D tNormal;\n\t\tuniform sampler2D tDepth;\n\t\tuniform sampler2D tNoise;\n\n\t\tuniform vec3 kernel[ KERNEL_SIZE ];\n\n\t\tuniform vec2 resolution;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\t\tuniform mat4 cameraProjectionMatrix;\n\t\tuniform mat4 cameraInverseProjectionMatrix;\n\n\t\tuniform float kernelRadius;\n\t\tuniform float minDistance; // avoid artifacts caused by neighbour fragments with minimal depth difference\n\t\tuniform float maxDistance; // avoid the influence of fragments which are too far away\n\n\t\tvarying vec2 vUv;\n\n\t\t#include \n\n\t\tfloat getDepth( const in vec2 screenPosition ) {\n\n\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\n\t\t}\n\n\t\tfloat getLinearDepth( const in vec2 screenPosition ) {\n\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\n\t\t\t\tfloat fragCoordZ = texture2D( tDepth, screenPosition ).x;\n\t\t\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n\t\t\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\n\t\t\t#else\n\n\t\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\n\t\t\t#endif\n\n\t\t}\n\n\t\tfloat getViewZ( const in float depth ) {\n\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\n\t\t\t\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );\n\n\t\t\t#else\n\n\t\t\t\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );\n\n\t\t\t#endif\n\n\t\t}\n\n\t\tvec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {\n\n\t\t\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];\n\n\t\t\tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );\n\n\t\t\tclipPosition *= clipW; // unprojection.\n\n\t\t\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;\n\n\t\t}\n\n\t\tvec3 getViewNormal( const in vec2 screenPosition ) {\n\n\t\t\treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat depth = getDepth( vUv );\n\t\t\tfloat viewZ = getViewZ( depth );\n\n\t\t\tvec3 viewPosition = getViewPosition( vUv, depth, viewZ );\n\t\t\tvec3 viewNormal = getViewNormal( vUv );\n\n\t\t\tvec2 noiseScale = vec2( resolution.x / 4.0, resolution.y / 4.0 );\n\t\t\tvec3 random = vec3( texture2D( tNoise, vUv * noiseScale ).r );\n\n\t\t\t// compute matrix used to reorient a kernel vector\n\n\t\t\tvec3 tangent = normalize( random - viewNormal * dot( random, viewNormal ) );\n\t\t\tvec3 bitangent = cross( viewNormal, tangent );\n\t\t\tmat3 kernelMatrix = mat3( tangent, bitangent, viewNormal );\n\n\t\t float occlusion = 0.0;\n\n\t\t for ( int i = 0; i < KERNEL_SIZE; i ++ ) {\n\n\t\t\t\tvec3 sampleVector = kernelMatrix * kernel[ i ]; // reorient sample vector in view space\n\t\t\t\tvec3 samplePoint = viewPosition + ( sampleVector * kernelRadius ); // calculate sample point\n\n\t\t\t\tvec4 samplePointNDC = cameraProjectionMatrix * vec4( samplePoint, 1.0 ); // project point and calculate NDC\n\t\t\t\tsamplePointNDC /= samplePointNDC.w;\n\n\t\t\t\tvec2 samplePointUv = samplePointNDC.xy * 0.5 + 0.5; // compute uv coordinates\n\n\t\t\t\tfloat realDepth = getLinearDepth( samplePointUv ); // get linear depth from depth texture\n\t\t\t\tfloat sampleDepth = viewZToOrthographicDepth( samplePoint.z, cameraNear, cameraFar ); // compute linear depth of the sample view Z value\n\t\t\t\tfloat delta = sampleDepth - realDepth;\n\n\t\t\t\tif ( delta > minDistance && delta < maxDistance ) { // if fragment is before sample point, increase occlusion\n\n\t\t\t\t\tocclusion += 1.0;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tocclusion = clamp( occlusion / float( KERNEL_SIZE ), 0.0, 1.0 );\n\n\t\t\tgl_FragColor = vec4( vec3( 1.0 - occlusion ), 1.0 );\n\n\t\t}"},L_={defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:"varying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"uniform sampler2D tDepth;\n\n\t\tuniform float cameraNear;\n\t\tuniform float cameraFar;\n\n\t\tvarying vec2 vUv;\n\n\t\t#include \n\n\t\tfloat getLinearDepth( const in vec2 screenPosition ) {\n\n\t\t\t#if PERSPECTIVE_CAMERA == 1\n\n\t\t\t\tfloat fragCoordZ = texture2D( tDepth, screenPosition ).x;\n\t\t\t\tfloat viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );\n\t\t\t\treturn viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );\n\n\t\t\t#else\n\n\t\t\t\treturn texture2D( tDepth, screenPosition ).x;\n\n\t\t\t#endif\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tfloat depth = getLinearDepth( vUv );\n\t\t\tgl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );\n\n\t\t}"},D_={uniforms:{tDiffuse:{value:null},resolution:{value:new be}},vertexShader:"varying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"uniform sampler2D tDiffuse;\n\n\t\tuniform vec2 resolution;\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvec2 texelSize = ( 1.0 / resolution );\n\t\t\tfloat result = 0.0;\n\n\t\t\tfor ( int i = - 2; i <= 2; i ++ ) {\n\n\t\t\t\tfor ( int j = - 2; j <= 2; j ++ ) {\n\n\t\t\t\t\tvec2 offset = ( vec2( float( i ), float( j ) ) ) * texelSize;\n\t\t\t\t\tresult += texture2D( tDiffuse, vUv + offset ).r;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tgl_FragColor = vec4( vec3( result / ( 5.0 * 5.0 ) ), 1.0 );\n\n\t\t}"},Jl=class extends bs{constructor(e,t,n,i){super(),this.width=void 0!==n?n:512,this.height=void 0!==i?i:512,this.clear=!0,this.camera=t,this.scene=e,this.kernelRadius=8,this.kernelSize=32,this.kernel=[],this.noiseTexture=null,this.output=0,this.minDistance=.005,this.maxDistance=.1,this._visibilityCache=new Map,this.generateSampleKernel(),this.generateRandomKernelRotations();let r=new cf;r.format=Wh,r.type=bu,this.beautyRenderTarget=new sr(this.width,this.height,{type:Rr}),this.normalRenderTarget=new sr(this.width,this.height,{minFilter:Jr,magFilter:Jr,type:Rr,depthTexture:r}),this.ssaoRenderTarget=new sr(this.width,this.height,{type:Rr}),this.blurRenderTarget=this.ssaoRenderTarget.clone(),this.ssaoMaterial=new ln({defines:Object.assign({},I_.defines),uniforms:Ti.clone(I_.uniforms),vertexShader:I_.vertexShader,fragmentShader:I_.fragmentShader,blending:Qr}),this.ssaoMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.ssaoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.ssaoMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture,this.ssaoMaterial.uniforms.tNoise.value=this.noiseTexture,this.ssaoMaterial.uniforms.kernel.value=this.kernel,this.ssaoMaterial.uniforms.cameraNear.value=this.camera.near,this.ssaoMaterial.uniforms.cameraFar.value=this.camera.far,this.ssaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.ssaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssaoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.normalMaterial=new df,this.normalMaterial.blending=Qr,this.blurMaterial=new ln({defines:Object.assign({},D_.defines),uniforms:Ti.clone(D_.uniforms),vertexShader:D_.vertexShader,fragmentShader:D_.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new ln({defines:Object.assign({},L_.defines),uniforms:Ti.clone(L_.uniforms),vertexShader:L_.vertexShader,fragmentShader:L_.fragmentShader,blending:Qr}),this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture,this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new ln({uniforms:Ti.clone(Sa.uniforms),vertexShader:Sa.vertexShader,fragmentShader:Sa.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:Tv,blendDst:pf,blendEquation:qo,blendSrcAlpha:_v,blendDstAlpha:pf,blendEquationAlpha:qo}),this.fsQuad=new wa(null),this.originalClearColor=new ct}dispose(){this.beautyRenderTarget.dispose(),this.normalRenderTarget.dispose(),this.ssaoRenderTarget.dispose(),this.blurRenderTarget.dispose(),this.normalMaterial.dispose(),this.blurMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this.fsQuad.dispose()}render(e,t){switch(!1===e.capabilities.isWebGL2&&(this.noiseTexture.format=YR),e.setRenderTarget(this.beautyRenderTarget),e.clear(),e.render(this.scene,this.camera),this.overrideVisibility(),this.renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this.restoreVisibility(),this.ssaoMaterial.uniforms.kernelRadius.value=this.kernelRadius,this.ssaoMaterial.uniforms.minDistance.value=this.minDistance,this.ssaoMaterial.uniforms.maxDistance.value=this.maxDistance,this.renderPass(e,this.ssaoMaterial,this.ssaoRenderTarget),this.renderPass(e,this.blurMaterial,this.blurRenderTarget),this.output){case Jl.OUTPUT.SSAO:this.copyMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.copyMaterial.blending=Qr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Jl.OUTPUT.Blur:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=Qr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Jl.OUTPUT.Beauty:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=Qr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Jl.OUTPUT.Depth:this.renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case Jl.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=Qr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Jl.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.copyMaterial.blending=Qr,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=Mm,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;default:console.warn("THREE.SSAOPass: Unknown output type.")}}renderPass(e,t,n,i,r){e.getClearColor(this.originalClearColor);let a=e.getClearAlpha(),s=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,null!=i&&(e.setClearColor(i),e.setClearAlpha(r||0),e.clear()),this.fsQuad.material=t,this.fsQuad.render(e),e.autoClear=s,e.setClearColor(this.originalClearColor),e.setClearAlpha(a)}renderOverride(e,t,n,i,r){e.getClearColor(this.originalClearColor);let a=e.getClearAlpha(),s=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i=t.clearColor||i,r=t.clearAlpha||r,null!=i&&(e.setClearColor(i),e.setClearAlpha(r||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=s,e.setClearColor(this.originalClearColor),e.setClearAlpha(a)}setSize(e,t){this.width=e,this.height=t,this.beautyRenderTarget.setSize(e,t),this.ssaoRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.blurRenderTarget.setSize(e,t),this.ssaoMaterial.uniforms.resolution.value.set(e,t),this.ssaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssaoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.blurMaterial.uniforms.resolution.value.set(e,t)}generateSampleKernel(){let e=this.kernelSize,t=this.kernel;for(let n=0;n\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 invSize;\n\t\t\t\tuniform vec2 direction;\n\t\t\t\tuniform float gaussianCoefficients[KERNEL_RADIUS];\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tfloat weightSum = gaussianCoefficients[0];\n\t\t\t\t\tvec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;\n\t\t\t\t\tfor( int i = 1; i < KERNEL_RADIUS; i ++ ) {\n\t\t\t\t\t\tfloat x = float(i);\n\t\t\t\t\t\tfloat w = gaussianCoefficients[i];\n\t\t\t\t\t\tvec2 uvOffset = direction * invSize * x;\n\t\t\t\t\t\tvec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;\n\t\t\t\t\t\tvec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;\n\t\t\t\t\t\tdiffuseSum += (sample1 + sample2) * w;\n\t\t\t\t\t\tweightSum += 2.0 * w;\n\t\t\t\t\t}\n\t\t\t\t\tgl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n\t\t\t\t}"})}getCompositeMaterial(e){return new ln({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\n\t\t\t\tuniform sampler2D blurTexture1;\n\t\t\t\tuniform sampler2D blurTexture2;\n\t\t\t\tuniform sampler2D blurTexture3;\n\t\t\t\tuniform sampler2D blurTexture4;\n\t\t\t\tuniform sampler2D blurTexture5;\n\t\t\t\tuniform float bloomStrength;\n\t\t\t\tuniform float bloomRadius;\n\t\t\t\tuniform float bloomFactors[NUM_MIPS];\n\t\t\t\tuniform vec3 bloomTintColors[NUM_MIPS];\n\n\t\t\t\tfloat lerpBloomFactor(const in float factor) {\n\t\t\t\t\tfloat mirrorFactor = 1.2 - factor;\n\t\t\t\t\treturn mix(factor, mirrorFactor, bloomRadius);\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\t\t\t\t\tgl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +\n\t\t\t\t\t\tlerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );\n\t\t\t\t}"})}};xd.BlurDirectionX=new be(1,0),xd.BlurDirectionY=new be(0,1);var kve={uniforms:{tDiffuse:{value:null},resolution:{value:new be(1/1024,1/512)}},vertexShader:"\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}",fragmentShader:"\n\tprecision highp float;\n\n\tuniform sampler2D tDiffuse;\n\n\tuniform vec2 resolution;\n\n\tvarying vec2 vUv;\n\n\t// FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com)\n\n\t//----------------------------------------------------------------------------------\n\t// File: es3-keplerFXAAassetsshaders/FXAA_DefaultES.frag\n\t// SDK Version: v3.00\n\t// Email: gameworks@nvidia.com\n\t// Site: http://developer.nvidia.com/\n\t//\n\t// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.\n\t//\n\t// Redistribution and use in source and binary forms, with or without\n\t// modification, are permitted provided that the following conditions\n\t// are met:\n\t// * Redistributions of source code must retain the above copyright\n\t// notice, this list of conditions and the following disclaimer.\n\t// * Redistributions in binary form must reproduce the above copyright\n\t// notice, this list of conditions and the following disclaimer in the\n\t// documentation and/or other materials provided with the distribution.\n\t// * Neither the name of NVIDIA CORPORATION nor the names of its\n\t// contributors may be used to endorse or promote products derived\n\t// from this software without specific prior written permission.\n\t//\n\t// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY\n\t// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\t// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n\t// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n\t// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n\t// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n\t// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n\t// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n\t// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\t// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\t// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\t//\n\t//----------------------------------------------------------------------------------\n\n\t#ifndef FXAA_DISCARD\n\t\t\t//\n\t\t\t// Only valid for PC OpenGL currently.\n\t\t\t// Probably will not work when FXAA_GREEN_AS_LUMA = 1.\n\t\t\t//\n\t\t\t// 1 = Use discard on pixels which don't need AA.\n\t\t\t// For APIs which enable concurrent TEX+ROP from same surface.\n\t\t\t// 0 = Return unchanged color on pixels which don't need AA.\n\t\t\t//\n\t\t\t#define FXAA_DISCARD 0\n\t#endif\n\n\t/*--------------------------------------------------------------------------*/\n\t#define FxaaTexTop(t, p) texture2D(t, p, -100.0)\n\t#define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), -100.0)\n\t/*--------------------------------------------------------------------------*/\n\n\t#define NUM_SAMPLES 5\n\n\t// assumes colors have premultipliedAlpha, so that the calculated color contrast is scaled by alpha\n\tfloat contrast( vec4 a, vec4 b ) {\n\t\t\tvec4 diff = abs( a - b );\n\t\t\treturn max( max( max( diff.r, diff.g ), diff.b ), diff.a );\n\t}\n\n\t/*============================================================================\n\n\t\t\t\t\t\t\t\t\tFXAA3 QUALITY - PC\n\n\t============================================================================*/\n\n\t/*--------------------------------------------------------------------------*/\n\tvec4 FxaaPixelShader(\n\t\t\tvec2 posM,\n\t\t\tsampler2D tex,\n\t\t\tvec2 fxaaQualityRcpFrame,\n\t\t\tfloat fxaaQualityEdgeThreshold,\n\t\t\tfloat fxaaQualityinvEdgeThreshold\n\t) {\n\t\t\tvec4 rgbaM = FxaaTexTop(tex, posM);\n\t\t\tvec4 rgbaS = FxaaTexOff(tex, posM, vec2( 0.0, 1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaE = FxaaTexOff(tex, posM, vec2( 1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaN = FxaaTexOff(tex, posM, vec2( 0.0,-1.0), fxaaQualityRcpFrame.xy);\n\t\t\tvec4 rgbaW = FxaaTexOff(tex, posM, vec2(-1.0, 0.0), fxaaQualityRcpFrame.xy);\n\t\t\t// . S .\n\t\t\t// W M E\n\t\t\t// . N .\n\n\t\t\tbool earlyExit = max( max( max(\n\t\t\t\t\tcontrast( rgbaM, rgbaN ),\n\t\t\t\t\tcontrast( rgbaM, rgbaS ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaE ) ),\n\t\t\t\t\tcontrast( rgbaM, rgbaW ) )\n\t\t\t\t\t< fxaaQualityEdgeThreshold;\n\t\t\t// . 0 .\n\t\t\t// 0 0 0\n\t\t\t// . 0 .\n\n\t\t\t#if (FXAA_DISCARD == 1)\n\t\t\t\t\tif(earlyExit) FxaaDiscard;\n\t\t\t#else\n\t\t\t\t\tif(earlyExit) return rgbaM;\n\t\t\t#endif\n\n\t\t\tfloat contrastN = contrast( rgbaM, rgbaN );\n\t\t\tfloat contrastS = contrast( rgbaM, rgbaS );\n\t\t\tfloat contrastE = contrast( rgbaM, rgbaE );\n\t\t\tfloat contrastW = contrast( rgbaM, rgbaW );\n\n\t\t\tfloat relativeVContrast = ( contrastN + contrastS ) - ( contrastE + contrastW );\n\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\tbool horzSpan = relativeVContrast > 0.;\n\t\t\t// . 1 .\n\t\t\t// 0 0 0\n\t\t\t// . 1 .\n\n\t\t\t// 45 deg edge detection and corners of objects, aka V/H contrast is too similar\n\t\t\tif( abs( relativeVContrast ) < .3 ) {\n\t\t\t\t\t// locate the edge\n\t\t\t\t\tvec2 dirToEdge;\n\t\t\t\t\tdirToEdge.x = contrastE > contrastW ? 1. : -1.;\n\t\t\t\t\tdirToEdge.y = contrastS > contrastN ? 1. : -1.;\n\t\t\t\t\t// . 2 . . 1 .\n\t\t\t\t\t// 1 0 2 ~= 0 0 1\n\t\t\t\t\t// . 1 . . 0 .\n\n\t\t\t\t\t// tap 2 pixels and see which ones are \"outside\" the edge, to\n\t\t\t\t\t// determine if the edge is vertical or horizontal\n\n\t\t\t\t\tvec4 rgbaAlongH = FxaaTexOff(tex, posM, vec2( dirToEdge.x, -dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\t\tfloat matchAlongH = contrast( rgbaM, rgbaAlongH );\n\t\t\t\t\t// . 1 .\n\t\t\t\t\t// 0 0 1\n\t\t\t\t\t// . 0 H\n\n\t\t\t\t\tvec4 rgbaAlongV = FxaaTexOff(tex, posM, vec2( -dirToEdge.x, dirToEdge.y ), fxaaQualityRcpFrame.xy);\n\t\t\t\t\tfloat matchAlongV = contrast( rgbaM, rgbaAlongV );\n\t\t\t\t\t// V 1 .\n\t\t\t\t\t// 0 0 1\n\t\t\t\t\t// . 0 .\n\n\t\t\t\t\trelativeVContrast = matchAlongV - matchAlongH;\n\t\t\t\t\trelativeVContrast *= fxaaQualityinvEdgeThreshold;\n\n\t\t\t\t\tif( abs( relativeVContrast ) < .3 ) { // 45 deg edge\n\t\t\t\t\t\t\t// 1 1 .\n\t\t\t\t\t\t\t// 0 0 1\n\t\t\t\t\t\t\t// . 0 1\n\n\t\t\t\t\t\t\t// do a simple blur\n\t\t\t\t\t\t\treturn mix(\n\t\t\t\t\t\t\t\t\trgbaM,\n\t\t\t\t\t\t\t\t\t(rgbaN + rgbaS + rgbaE + rgbaW) * .25,\n\t\t\t\t\t\t\t\t\t.4\n\t\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\thorzSpan = relativeVContrast > 0.;\n\t\t\t}\n\n\t\t\tif(!horzSpan) rgbaN = rgbaW;\n\t\t\tif(!horzSpan) rgbaS = rgbaE;\n\t\t\t// . 0 . 1\n\t\t\t// 1 0 1 -> 0\n\t\t\t// . 0 . 1\n\n\t\t\tbool pairN = contrast( rgbaM, rgbaN ) > contrast( rgbaM, rgbaS );\n\t\t\tif(!pairN) rgbaN = rgbaS;\n\n\t\t\tvec2 offNP;\n\t\t\toffNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\n\t\t\toffNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\n\n\t\t\tbool doneN = false;\n\t\t\tbool doneP = false;\n\n\t\t\tfloat nDist = 0.;\n\t\t\tfloat pDist = 0.;\n\n\t\t\tvec2 posN = posM;\n\t\t\tvec2 posP = posM;\n\n\t\t\tint iterationsUsed = 0;\n\t\t\tint iterationsUsedN = 0;\n\t\t\tint iterationsUsedP = 0;\n\t\t\tfor( int i = 0; i < NUM_SAMPLES; i++ ) {\n\t\t\t\t\titerationsUsed = i;\n\n\t\t\t\t\tfloat increment = float(i + 1);\n\n\t\t\t\t\tif(!doneN) {\n\t\t\t\t\t\t\tnDist += increment;\n\t\t\t\t\t\t\tposN = posM + offNP * nDist;\n\t\t\t\t\t\t\tvec4 rgbaEndN = FxaaTexTop(tex, posN.xy);\n\t\t\t\t\t\t\tdoneN = contrast( rgbaEndN, rgbaM ) > contrast( rgbaEndN, rgbaN );\n\t\t\t\t\t\t\titerationsUsedN = i;\n\t\t\t\t\t}\n\n\t\t\t\t\tif(!doneP) {\n\t\t\t\t\t\t\tpDist += increment;\n\t\t\t\t\t\t\tposP = posM - offNP * pDist;\n\t\t\t\t\t\t\tvec4 rgbaEndP = FxaaTexTop(tex, posP.xy);\n\t\t\t\t\t\t\tdoneP = contrast( rgbaEndP, rgbaM ) > contrast( rgbaEndP, rgbaN );\n\t\t\t\t\t\t\titerationsUsedP = i;\n\t\t\t\t\t}\n\n\t\t\t\t\tif(doneN || doneP) break;\n\t\t\t}\n\n\n\t\t\tif ( !doneP && !doneN ) return rgbaM; // failed to find end of edge\n\n\t\t\tfloat dist = min(\n\t\t\t\t\tdoneN ? float( iterationsUsedN ) / float( NUM_SAMPLES - 1 ) : 1.,\n\t\t\t\t\tdoneP ? float( iterationsUsedP ) / float( NUM_SAMPLES - 1 ) : 1.\n\t\t\t);\n\n\t\t\t// hacky way of reduces blurriness of mostly diagonal edges\n\t\t\t// but reduces AA quality\n\t\t\tdist = pow(dist, .5);\n\n\t\t\tdist = 1. - dist;\n\n\t\t\treturn mix(\n\t\t\t\t\trgbaM,\n\t\t\t\t\trgbaN,\n\t\t\t\t\tdist * .5\n\t\t\t);\n\t}\n\n\tvoid main() {\n\t\t\tconst float edgeDetectionQuality = .2;\n\t\t\tconst float invEdgeDetectionQuality = 1. / edgeDetectionQuality;\n\n\t\t\tgl_FragColor = FxaaPixelShader(\n\t\t\t\t\tvUv,\n\t\t\t\t\ttDiffuse,\n\t\t\t\t\tresolution,\n\t\t\t\t\tedgeDetectionQuality, // [0,1] contrast needed, otherwise early discard\n\t\t\t\t\tinvEdgeDetectionQuality\n\t\t\t);\n\n\t}\n\t"},o2=class{constructor(){this.vertexShader="\n varying vec2 vUv;\n void main( void ) {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);\n }",this.fragmentShader="\n uniform vec3 keyColor;\n uniform float similarity;\n uniform float smoothness;\n varying vec2 vUv;\n uniform sampler2D map;\n void main() {\n vec4 videoColor = texture2D(map, vUv);\n\n float Y1 = 0.299 * keyColor.r + 0.587 * keyColor.g + 0.114 * keyColor.b;\n float Cr1 = keyColor.r - Y1;\n float Cb1 = keyColor.b - Y1;\n \n float Y2 = 0.299 * videoColor.r + 0.587 * videoColor.g + 0.114 * videoColor.b;\n float Cr2 = videoColor.r - Y2; \n float Cb2 = videoColor.b - Y2; \n \n float blend = smoothstep(similarity, similarity + smoothness, distance(vec2(Cr2, Cb2), vec2(Cr1, Cb1)));\n gl_FragColor = vec4(videoColor.rgb, videoColor.a * blend); \n }";let e=document.createElement("video");this.webcam=e,navigator.mediaDevices.getUserMedia({video:{width:600,height:400}}).then((t=>{e.srcObject=t,e.onloadedmetadata=()=>{e.setAttribute("autoplay","true"),e.setAttribute("playsinline","true"),e.play()}})).catch((function(e){alert(e.name+": "+e.message)})),this.webcamCanvas=document.createElement("canvas");let t=this.webcamCanvas.getContext("2d");this.canvasCtx=t,t.fillStyle="#000000",t.fillRect(0,0,this.webcamCanvas.width,this.webcamCanvas.height);let n=new qr(this.webcamCanvas);this.webcamTexture=n,n.minFilter=Ir,n.magFilter=Ir,this.shaderMaterial=new ln({transparent:!0,uniforms:{map:{value:n},keyColor:{value:[0,1,0]},similarity:{value:.3},smoothness:{value:0}},vertexShader:this.vertexShader,fragmentShader:this.fragmentShader})}getShaderMaterial(){return this.shaderMaterial}createWebCamPlane(e=5,t=4){let n=new ui(e,t);return new xt(n,this.shaderMaterial)}animate(){this.webcam.readyState===this.webcam.HAVE_ENOUGH_DATA&&(this.canvasCtx.drawImage(this.webcam,0,0,this.webcamCanvas.width,this.webcamCanvas.height),this.webcamTexture.needsUpdate=!0)}},Za=new O(1,0,0),np=new O(0,1,0),rp=new O(0,0,1),Fve=new O(0,1,0),O_=new et,qy=2,Xc=class extends er{constructor(e=Za){super(),this.redMaterial=new on({color:16711680,depthTest:!1}),this.greenMaterial=new on({color:65280,depthTest:!1}),this.blueMaterial=new on({color:255,depthTest:!1}),this.highlightMaterial=new on({color:16776960,depthTest:!1}),this.pickableMaterial=new on({color:9807270,depthTest:!1}),this.initIgnoreClipMaterial(),this.initOrUpdateByAxis(e)}initIgnoreClipMaterial(){[this.redMaterial,this.greenMaterial,this.blueMaterial,this.highlightMaterial,this.pickableMaterial].forEach((e=>{e.onBeforeCompile=function(e,t){e.fragmentShader=e.fragmentShader.replace("#include ","").replace("#include ",""),e.vertexShader=e.vertexShader.replace("#include ","").replace("#include ","")}}))}setDirection(e){let t=new dr;t.setFromUnitVectors(Za,e),this.applyQuaternion(t)}initOrUpdateByAxis(e){this.clear(),[{actionType:"TranslateX",direction:Za,material:this.redMaterial},{actionType:"TranslateY",direction:np,material:this.greenMaterial},{actionType:"TranslateZ",direction:rp,material:this.blueMaterial}].forEach((t=>{let{actionType:n,direction:i,material:r}=t,a=this.createTranslateGizmo(n,i,qy,0===i.angleTo(e)?r:this.pickableMaterial);this.add(a)})),[{actionType:"RotateX",direction:Za,material:this.redMaterial,degree:90},{actionType:"RotateY",direction:np,material:this.greenMaterial,degree:90},{actionType:"RotateZ",direction:rp,material:this.blueMaterial,degree:90}].forEach((t=>{let{actionType:n,direction:i,material:r,degree:a}=t;if(0!==i.angleTo(e)){let e=this.createRotateGizmo(n,i,qy,r,a);this.add(e)}})),this.createSphere(1,this.pickableMaterial),this.createSphere(1,this.pickableMaterial,new O(12*qy,0,0)),this.createSphere(1,this.pickableMaterial,new O(0,12*qy,0)),this.createSphere(1,this.pickableMaterial,new O(0,0,12*qy))}createTranslateGizmo(e,t,n,i){let r=t.angleTo(Fve),a=Fve.clone().cross(t);O_.makeRotationAxis(a,r);let s=new wc(n/5,n/5,20*n),o=10*n;s.translate(0,o,0),s.applyMatrix4(O_);let l=new wc(0,n,3*n),h=2*o;l.translate(0,h,0),l.applyMatrix4(O_);let c=Ni([l,s]),u=new xt(c,i);return u.layers.enable(12),u.userData.actionType=e,i===this.pickableMaterial&&u.layers.disable(12),u}createRotateGizmo(e,t,n,i,r){let a=new O(0,0,1),s=t.clone().cross(a),o=t.angleTo(a);O_.makeRotationAxis(s,o);let l=new uf(12*n,n/5,24,36,An.degToRad(r));l.applyMatrix4(O_);let h=new xt(l,i);return h.layers.enable(12),h.userData.actionType=e,h}createSphere(e,t,n=new O){let i=new za(e,32,16),r=new xt(i,t);r.position.copy(n),r.layers.disable(12),this.add(r)}setActiveAxis(e){this.initOrUpdateByAxis(e)}createHoverRotateObjectByAxis(e){let t=Za;switch(e){case"RotateX":t=Za;break;case"RotateY":t=np;break;case"RotateZ":t=rp}return this.createRotateGizmo("",t,qy,this.highlightMaterial,360)}setActive(e,t){var n;let i=t.userData.actionType;["RotateX","RotateY","RotateZ"].includes(i)?e?(this.hoverObject=this.createHoverRotateObjectByAxis(i),this.add(this.hoverObject),t.visible=!1):(null==(n=this.hoverObject)||n.removeFromParent(),t.visible=!0,this.hoverObject=void 0):e?(this.originalMaterial=t.material,t.material=this.highlightMaterial):this.originalMaterial&&(t.material=this.originalMaterial)}adjustSize(e){let t=new O;this.getWorldPosition(t);let n=e.position,i=1;e instanceof Ur?i=(e.top-e.bottom)/e.zoom:e instanceof ur&&(i=t.distanceTo(n)*Math.min(1.9*Math.tan(Math.PI*e.fov/360)/e.zoom,7)),this.scale.set(1,1,1).multiplyScalar(i/180)}},ip=class{constructor(e,t){if(this.raycaster=new ia,this.sectionBox=new Ot,this.mouseDown=!1,this.lastWorldPos=new O,this.mouseMoved=!1,this.dragStarted=!1,this.refrencePlane=new Gr,this.active=!1,this.showSectionPlane=!1,this.mousedown=e=>{if(0===e.button){if(Dn.isMobile){let t=this.getIntersections(e);t?(this.inputManager.setCursor("grab"),this.selectedObject=t.object,this.activateSelectedObject(!0),this.enableDefaultControl(!1),this.viewer.enableRender()):this.enableDefaultControl(!0)}this.camera&&this.selectedObject&&(this.inputManager.setCursor("grabbing"),this.mouseDown=!0)}},this.mousemove=e=>{if(this.dragStarted)this.updateRaycasterByMouse(e),this.inputManager.setCursor("grabbing"),this.onDragMove(e);else{this.activateSelectedObject(!1);let t=this.getIntersections(e);t?(this.inputManager.setCursor("grab"),this.selectedObject=t.object,this.activateSelectedObject(!0),this.mouseDown&&(this.dragStarted||(this.dragStarted=!0,this.enableDefaultControl(!1),this.onDragStart(e)))):(this.inputManager.setCursor("default"),this.selectedObject=void 0)}this.viewer.enableRender()},this.mouseup=e=>{0===e.button&&(this.activateSelectedObject(!1),this.mouseDown&&this.dragStarted&&(this.inputManager.setCursor("grab"),this.onDragEnd(e),this.dragStarted=!1,this.enableDefaultControl(!0)),this.mouseDown=!1,this.selectedObject=void 0)},this.keydown=e=>{"Escape"===e.code&&this.deactivate()},!(e.camera&&e.renderer&&e.controls&&e.scene))throw new Error("Invalid bimViewer!");this.viewer=e,this.inputManager=t,this.scene=e.scene,this.renderer=e.renderer,this.raycaster.layers.set(12)}get canvas(){var e;return null==(e=this.viewer.renderer)?void 0:e.domElement}get isActive(){return!!this.active}get camera(){return this.viewer.camera}get controls(){return this.viewer.controls}setGlobalClippingEnabled(e){if(!this.clipPlanes)return;let t=e?this.clipPlanes:[];this.renderer.localClippingEnabled=e,this.renderer.clippingPlanes=t}setObjectClippingEnabled(e){var t,n;if(!this.clipPlanes||null==(t=this.clippingObjetIds)||!t.length)return;this.renderer.localClippingEnabled=e;let i=e?this.clipPlanes:[];null==(n=this.clippingObjetIds)||n.forEach((e=>{let t=this.scene.getObjectById(e);t&&t.traverse((e=>{e.material&&(Array.isArray(e.material)?e.material.forEach((e=>{e.clippingPlanes=i,e.clipIntersection=!1})):e.material&&(e.material.clippingPlanes=i,e.material.clipIntersection=!1))}))}))}clearClippingObjectIds(){this.setObjectClippingEnabled(!1),this.clippingObjetIds=[]}setClippingEnabled(e){var t;null!=(t=this.clippingObjetIds)&&t.length?(this.setGlobalClippingEnabled(!1),this.setObjectClippingEnabled(e)):this.setGlobalClippingEnabled(e)}activate(){if(this.inputManager.addEventListener("pointerdown",this.mousedown),this.inputManager.addEventListener("pointermove",this.mousemove),this.inputManager.addEventListener("pointerup",this.mouseup),this.inputManager.addEventListener("keydown",this.keydown),this.sectionBox.isEmpty()){let e=this.viewer.getBBox();e&&this.sectionBox.copy(e)}this.active=!0}deactivate(){var e;this.inputManager.removeEventListener("pointerdown",this.mousedown),this.inputManager.removeEventListener("pointermove",this.mousemove),this.inputManager.removeEventListener("pointerup",this.mouseup),this.inputManager.removeEventListener("keydown",this.keydown),null==(e=this.selectedObject)||e.removeFromParent(),this.selectedObject=void 0,this.dragStarted=!1,this.active=!1,this.inputManager.setCursor("default"),this.enableDefaultControl(!0)}enableDefaultControl(e){this.controls.enableRotate=e,this.controls.azimuthRotateSpeed=Number(e),this.controls.polarRotateSpeed=Number(e)}getIntersections(e){if(!this.raycaster)return;this.updateRaycasterByMouse(e);let t=this.raycaster.intersectObjects(this.getIntersectObjects())||[];return t.find((e=>e.object&&e.object.parent instanceof Xc))||t[0]}updateRaycasterByMouse(e){if(!this.raycaster)return;let t=new be(e.x,e.y),n=cn.screenPoint2NdcPoint(t,this.camera,this.canvas);this.raycaster.setFromCamera(n,this.camera)}destroy(){this.deactivate()}},Bve=new Ot,Uve=new dr,l2=class extends xt{constructor(e,t){super(),this.vertices=[],this.layers.enable(12),this.actionType=e,this.geometry=new Dt,this.vertices=t,this.geometry.setFromPoints(t),this.geometry.setIndex([0,1,2,0,2,3]),this.material=new on({depthTest:!1,color:l2.normalPlaneColor,transparent:!0,opacity:.01,side:Sr}),this.createIgnoreClipMaterials(this.material),this.geometry.computeVertexNormals(),this.edge=this.createEdge(t),this.add(this.edge)}createIgnoreClipMaterials(e){e.onBeforeCompile=function(e,t){e.fragmentShader=e.fragmentShader.replace("#include ","").replace("#include ",""),e.vertexShader=e.vertexShader.replace("#include ","").replace("#include ","")}}createEdge(e){let t=new Dt;t.setFromPoints(e),t.setIndex([0,1,1,2,2,3,3,0]);let n=new Gn({color:l2.normalLineColor});return this.createIgnoreClipMaterials(n),new hr(t,n)}update(e){this.geometry.setFromPoints(e),this.geometry.computeBoundingSphere(),this.geometry.computeVertexNormals(),this.edge.geometry.setFromPoints(e),this.vertices=e}rotatePlane(e,t){let n=this.getPlaneCenter();Uve.setFromAxisAngle(e,t),this.vertices=this.vertices.map((e=>e.sub(n).applyQuaternion(Uve).add(n))),this.update(this.vertices)}setDirection(e){let t=new dr;t.setFromUnitVectors(Za,e);let n=this.getPlaneCenter();this.vertices=this.vertices.map((e=>e.sub(n).applyQuaternion(t).add(n))),this.update(this.vertices)}getPlaneNormal(){let[e,t,n]=this.vertices,i=new O;return Zr.getNormal(e,t,n,i),i}setActive(e){this.material.opacity=e?.1:.01}getPlaneCenter(){Bve.setFromPoints(this.vertices);let e=new O;return Bve.getCenter(e),e}},Li=l2;Li.normalPlaneColor=new ct(0,.855,.718),Li.activePlaneColor=new ct(1,1,0),Li.normalLineColor=16777215;var Hve=(e=>(e.X="X",e.Y="Y",e.Z="Z",e))(Hve||{}),c2=class extends ip{constructor(e,t){super(e,t),this.activeAxis="X",this.center=new O,this.axisInfoMap={X:{normal:new O(1,0,0)},Y:{normal:new O(0,1,0)},Z:{normal:new O(0,0,1)}},this.viewer.addEventListener("AfterRender",(()=>{var e;this.isActive&&(null==(e=this.gizmo)||e.adjustSize(this.camera))}))}activate(){super.activate(),this.sectionBox&&this.sectionBox.getCenter(this.center),this.setActiveAxis("X")}deactivate(){var e,t;super.deactivate(),null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.planeMesh=void 0,this.gizmo=void 0}resetSection(){var e,t;null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.setClippingEnabled(!1),this.planeMesh=void 0,this.gizmo=void 0,this.setActiveAxis("X")}setActiveAxis(e){this.activeAxis=e,this.initOrUpdateGizmo(),this.initOrUpdateSectionPlane(),this.initOrUpdateClipPlane(),this.setClippingEnabled(!0),this.viewer.enableRender()}setSectionVisible(e){this.gizmo&&this.planeMesh&&(this.gizmo.visible=e,this.planeMesh.visible=e),this.showSectionPlane=e,this.viewer.enableRender()}initOrUpdateClipPlane(){switch(this.activeAxis){case"X":this.clipPlane=new Gr(new O(-1,0,0),this.center.x);break;case"Y":this.clipPlane=new Gr(new O(0,-1,0),this.center.y);break;case"Z":this.clipPlane=new Gr(new O(0,0,-1),this.center.z)}this.clipPlane&&(this.clipPlanes=[this.clipPlane])}initOrUpdateSectionPlane(){var e;let t=new O;this.sectionBox.getSize(t);let n=t.length(),i=this.center,r=(new Ot).setFromCenterAndSize(i,new O(n,n,n)),{min:a,max:s}=r;switch(null==(e=this.planeMesh)||e.removeFromParent(),this.activeAxis){case"X":this.planeMesh=new Li("X",[new O(i.x,s.y,a.z),new O(i.x,s.y,s.z),new O(i.x,a.y,s.z),new O(i.x,a.y,a.z)]);break;case"Y":this.planeMesh=new Li("Y",[new O(s.x,i.y,a.z),new O(a.x,i.y,a.z),new O(a.x,i.y,s.z),new O(s.x,i.y,s.z)]);break;case"Z":this.planeMesh=new Li("Z",[new O(s.x,s.y,i.z),new O(a.x,s.y,i.z),new O(a.x,a.y,i.z),new O(s.x,a.y,i.z)])}this.planeMesh&&this.scene.add(this.planeMesh),this.viewer.enableRender()}initOrUpdateGizmo(){var e,t;null==(e=this.gizmo)||e.removeFromParent();let n=this.axisInfoMap[this.activeAxis].normal;this.gizmo=new Xc,this.gizmo.setDirection(n),this.sectionBox.getCenter(this.gizmo.position),null==(t=this.scene)||t.add(this.gizmo)}onDragStart(e){var t;if(this.selectedObject instanceof Li)return;se.info("[AxisPlaneSection] onDragStart:",e);let n=new O;this.sectionBox.getCenter(n),this.refrencePlane.setFromNormalAndCoplanarPoint(this.camera.getWorldDirection(this.refrencePlane.normal),n),null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,this.lastWorldPos)}onDragMove(e){var t,n,i;if(!this.lastWorldPos||!this.selectedObject||!this.clipPlane||!this.planeMesh||!this.gizmo||this.selectedObject&&this.selectedObject instanceof Li)return;let r=new O;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,r);let a=this.selectedObject.userData.actionType,s=(new O).subVectors(this.lastWorldPos,this.center).normalize(),o=(new O).subVectors(r,this.center).normalize(),l=(new O).subVectors(r,this.lastWorldPos).projectOnVector(Za.clone().applyQuaternion(this.gizmo.quaternion)),h=s.angleTo(o),c=(new O).crossVectors(s,o),u=new O;this.sectionBox.getSize(u);let d,p=Math.max(u.x,u.y,u.z);switch(a){case"TranslateX":case"TranslateY":case"TranslateZ":d=(new O).addVectors(this.gizmo.position,l),this.sectionBox.clone().setFromCenterAndSize(this.center,new O(p,p,p)).containsPoint(d)&&(null==(n=this.gizmo)||n.position.add(l),null==(i=this.planeMesh)||i.position.add(l));break;case"RotateX":{let e=Za.clone().applyQuaternion(this.gizmo.quaternion);c.dot(e)<0&&(h=-h),this.gizmo.rotateX(h),this.planeMesh.rotatePlane(e,h)}break;case"RotateY":{let e=np.clone().applyQuaternion(this.gizmo.quaternion);c.dot(e)<0&&(h=-h),this.gizmo.rotateY(h),this.planeMesh.rotatePlane(e,h)}break;case"RotateZ":{let e=rp.clone().applyQuaternion(this.gizmo.quaternion);c.dot(e)<0&&(h=-h),this.gizmo.rotateZ(h),this.planeMesh.rotatePlane(e,h)}}this.clipPlane.setFromNormalAndCoplanarPoint(this.planeMesh.getPlaneNormal().negate(),this.gizmo.position),this.lastWorldPos=r}onDragEnd(e){this.selectedObject instanceof Li||se.info("[AxisPlaneSection] onDragEnd:",e)}getIntersectObjects(){return this.planeMesh&&this.gizmo?[this.planeMesh,this.gizmo]:[]}activateSelectedObject(e){this.selectedObject&&(this.selectedObject instanceof Li?this.selectedObject.setActive(e):this.selectedObject.parent instanceof Xc&&this.selectedObject.parent.setActive(e,this.selectedObject))}},Bvt=new O(1,0,0),Uvt=new O(0,1,0),Hvt=new O(0,0,1),u2=class extends ip{constructor(e,t){super(e,t),this.sectionRange={}}activate(){super.activate();let e=this.viewer.getBBox();if(e){let{min:t,max:n}=e;this.sectionRange={x:[t.x,n.x],y:[t.y,n.y],z:[t.z,n.z]}}this.initOrUpdateClipPlane(),this.initOrUpdateVertices(),this.initOrUpdateSectionPlane(),this.setClippingEnabled(!0)}deactivate(){super.deactivate(),this.planesMesh&&this.scene.remove(...this.planesMesh),this.planesMesh=void 0}initOrUpdateVertices(){if(!this.sectionBox)return;let{min:e,max:t}=this.sectionBox;this.vertices=[new O(t.x,t.y,t.z),new O(e.x,t.y,t.z),new O(e.x,e.y,t.z),new O(t.x,e.y,t.z),new O(t.x,t.y,e.z),new O(e.x,t.y,e.z),new O(e.x,e.y,e.z),new O(t.x,e.y,e.z)]}initOrUpdateClipPlane(){let{min:e,max:t}=this.sectionBox;this.clipPlanes?(this.clipPlanes[0].constant=t.x,this.clipPlanes[1].constant=-e.x,this.clipPlanes[2].constant=t.y,this.clipPlanes[3].constant=-e.y,this.clipPlanes[4].constant=t.z,this.clipPlanes[5].constant=-e.z):this.clipPlanes=[new Gr(new O(-1,0,0),t.x),new Gr(new O(1,0,0),-e.x),new Gr(new O(0,-1,0),t.y),new Gr(new O(0,1,0),-e.y),new Gr(new O(0,0,-1),t.z),new Gr(new O(0,0,1),-e.z)]}initOrUpdateSectionPlane(){let e=this.vertices;if(e){if(this.planesMesh)this.planesMesh[0].update([e[4],e[0],e[3],e[7]]),this.planesMesh[1].update([e[1],e[5],e[6],e[2]]),this.planesMesh[2].update([e[4],e[5],e[1],e[0]]),this.planesMesh[3].update([e[6],e[7],e[3],e[2]]),this.planesMesh[4].update([e[0],e[1],e[2],e[3]]),this.planesMesh[5].update([e[5],e[4],e[7],e[6]]);else{let t=[new Li("Right",[e[4],e[0],e[3],e[7]]),new Li("Left",[e[1],e[5],e[6],e[2]]),new Li("Top",[e[4],e[5],e[1],e[0]]),new Li("Bottom",[e[6],e[7],e[3],e[2]]),new Li("Front",[e[0],e[1],e[2],e[3]]),new Li("Back",[e[5],e[4],e[7],e[6]])];this.planesMesh=t,this.scene.add(...t)}this.viewer.enableRender()}}activateSelectedObject(e){var t;null==(t=this.selectedObject)||t.setActive(e)}onDragStart(e){var t;this.selectedObject&&(se.info("[ObjectsBoxSection] onDragStart:",e),this.refrencePlane.setFromNormalAndCoplanarPoint(this.camera.getWorldDirection(this.refrencePlane.normal),this.selectedObject.getPlaneCenter()),null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,this.lastWorldPos))}onDragMove(e){var t;if(!this.lastWorldPos||!this.selectedObject)return;let n=new O;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,n);let i=this.selectedObject.actionType;switch(i){case"Top":case"Bottom":this.dragTranslateSectionPlane(Uvt,this.lastWorldPos,n,i);break;case"Left":case"Right":this.dragTranslateSectionPlane(Bvt,this.lastWorldPos,n,i);break;case"Front":case"Back":this.dragTranslateSectionPlane(Hvt,this.lastWorldPos,n,i)}this.lastWorldPos=n}onDragEnd(e){se.info("[ObjectsBoxSection] onDragEnd:",e)}dragTranslateSectionPlane(e,t,n,i){let r,{min:a,max:s}=this.sectionBox,o=n.clone().sub(t).projectOnVector(e);switch(i){case"Top":r=s.y+o.y,this.isInRange(r,this.sectionRange.y)&&(s.y=r);break;case"Bottom":r=a.y+o.y,this.isInRange(r,this.sectionRange.y)&&(a.y=r);break;case"Left":r=a.x+o.x,this.isInRange(r,this.sectionRange.x)&&(a.x=r);break;case"Right":r=s.x+o.x,this.isInRange(r,this.sectionRange.x)&&(s.x=r);break;case"Front":r=s.z+o.z,this.isInRange(r,this.sectionRange.z)&&(s.z=r);break;case"Back":r=a.z+o.z,this.isInRange(r,this.sectionRange.z)&&(a.z=r)}this.initOrUpdateVertices(),this.initOrUpdateSectionPlane(),this.initOrUpdateClipPlane(),this.viewer.enableRender()}isInRange(e,t){return e>t[0]&&et.visible=e)),this.showSectionPlane=e,this.viewer.enableRender()}},h2=class extends ip{constructor(e,t){super(e,t),this.mousedown=e=>{var t;if(0===e.button){if(!this.faceInfo){let n=this.pickFace(e);if(n&&n.face){let e=n.face.normal,i=new Ln;e.applyNormalMatrix(i.getNormalMatrix(n.object.matrixWorld)),this.faceInfo={position:n.point,normal:e.normalize()},this.setSection(),null==(t=this.tooltip)||t.hide()}return}if(Dn.isMobile){let t=this.getIntersections(e);t&&(this.inputManager.setCursor("grab"),this.selectedObject=t.object,this.activateSelectedObject(!0),this.enableDefaultControl(!1),this.viewer.enableRender())}this.camera&&this.selectedObject&&(this.mouseDown=!0)}},this.mousemove=e=>{var t,n,i;if(this.faceInfo){if(this.dragStarted)this.updateRaycasterByMouse(e),this.onDragMove(e);else{this.activateSelectedObject(!1);let t=this.getIntersections(e);t?(this.selectedObject=t.object,this.activateSelectedObject(!0),this.mouseDown&&(null==(i=this.selectedObject)?void 0:i.parent)instanceof Xc&&(this.dragStarted||(this.dragStarted=!0,this.enableDefaultControl(!1),this.onDragStart(e)))):this.selectedObject=void 0}this.viewer.enableRender()}else this.pickFace(e)?null==(t=this.tooltip)||t.show():null==(n=this.tooltip)||n.hide()},this.center=new O,this.viewer.addEventListener("AfterRender",(()=>{var e;this.isActive&&(null==(e=this.gizmo)||e.adjustSize(this.camera))}))}activate(){super.activate(),this.sectionBox.getCenter(this.center),this.tooltip=new Yl("pick-section-plane",eh("Tooltip.section"),{parentNode:this.viewer.widgetContainer,followPointer:!0})}deactivate(){var e,t,n;super.deactivate(),null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.planeMesh=void 0,this.gizmo=void 0,this.faceInfo=void 0,null==(n=this.tooltip)||n.destroy(),this.tooltip=void 0}setSection(){this.initOrUpdateGizmo(),this.initOrUpdateSectionPlane(),this.initOrUpdateClipPlane(),this.setClippingEnabled(!0),this.viewer.enableRender()}resetSection(){var e,t,n;null==(e=this.planeMesh)||e.removeFromParent(),null==(t=this.gizmo)||t.removeFromParent(),this.setClippingEnabled(!1),this.planeMesh=void 0,this.gizmo=void 0,this.faceInfo=void 0,null==(n=this.tooltip)||n.show(),this.viewer.enableRender()}setSectionVisible(e){this.gizmo&&this.planeMesh&&(this.gizmo.visible=e,this.planeMesh.visible=e),this.showSectionPlane=e,this.viewer.enableRender()}initOrUpdateClipPlane(){if(!this.faceInfo)return;let{normal:e,position:t}=this.faceInfo;this.clipPlane=(new Gr).setFromNormalAndCoplanarPoint(e.clone().negate(),t),this.clipPlane&&(this.clipPlanes=[this.clipPlane])}initOrUpdateSectionPlane(){var e;if(!this.faceInfo)return;let{normal:t,position:n}=this.faceInfo,i=new O;this.sectionBox.getSize(i);let r=i.length(),a=n,s=(new Ot).setFromCenterAndSize(a,new O(r,r,r)),{min:o,max:l}=s;null==(e=this.planeMesh)||e.removeFromParent(),this.planeMesh=new Li("Plane",[new O(a.x,l.y,o.z),new O(a.x,l.y,l.z),new O(a.x,o.y,l.z),new O(a.x,o.y,o.z)]),this.planeMesh.setDirection(t),this.planeMesh&&this.scene.add(this.planeMesh),this.viewer.enableRender()}initOrUpdateGizmo(){var e,t;if(!this.faceInfo)return;null==(e=this.gizmo)||e.removeFromParent();let{normal:n,position:i}=this.faceInfo;this.gizmo=new Xc,this.gizmo.setDirection(n),this.gizmo.position.copy(i),null==(t=this.scene)||t.add(this.gizmo)}onDragStart(e){var t;if(!this.faceInfo||this.selectedObject instanceof Li)return;se.info("[PickPlaneSection] onDragStart:",e);let{position:n}=this.faceInfo;this.refrencePlane.setFromNormalAndCoplanarPoint(this.camera.getWorldDirection(this.refrencePlane.normal),n),null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,this.lastWorldPos)}onDragMove(e){var t,n,i;if(!this.lastWorldPos||!this.selectedObject||!this.clipPlane||!this.planeMesh||!this.gizmo||!this.faceInfo||this.selectedObject&&this.selectedObject instanceof Li)return;let r=new O;null==(t=this.raycaster)||t.ray.intersectPlane(this.refrencePlane,r);let a=this.selectedObject.userData.actionType,{position:s}=this.faceInfo,o=(new O).subVectors(this.lastWorldPos,s).normalize(),l=(new O).subVectors(r,s).normalize(),h=(new O).subVectors(r,this.lastWorldPos).projectOnVector(Za.clone().applyQuaternion(this.gizmo.quaternion)),c=o.angleTo(l),u=(new O).crossVectors(o,l),d=new O;this.sectionBox.getSize(d);let p,f=Math.max(d.x,d.y,d.z);switch(a){case"TranslateX":case"TranslateY":case"TranslateZ":p=(new O).addVectors(this.gizmo.position,h),this.sectionBox.clone().setFromCenterAndSize(this.center,new O(f,f,f)).containsPoint(p)&&(null==(n=this.gizmo)||n.position.add(h),null==(i=this.planeMesh)||i.position.add(h));break;case"RotateX":{let e=Za.clone().applyQuaternion(this.gizmo.quaternion);u.dot(e)<0&&(c=-c),this.gizmo.rotateX(c),this.planeMesh.rotatePlane(e,c)}break;case"RotateY":{let e=np.clone().applyQuaternion(this.gizmo.quaternion);u.dot(e)<0&&(c=-c),this.gizmo.rotateY(c),this.planeMesh.rotatePlane(e,c)}break;case"RotateZ":{let e=rp.clone().applyQuaternion(this.gizmo.quaternion);u.dot(e)<0&&(c=-c),this.gizmo.rotateZ(c),this.planeMesh.rotatePlane(e,c)}}this.clipPlane.setFromNormalAndCoplanarPoint(this.planeMesh.getPlaneNormal().negate(),this.gizmo.position),this.lastWorldPos=r}onDragEnd(e){this.selectedObject instanceof Li||se.info("[PickPlaneSection] onDragEnd:",e)}getIntersectObjects(){return this.planeMesh&&this.gizmo?[this.planeMesh,this.gizmo]:[]}activateSelectedObject(e){this.selectedObject&&(this.selectedObject instanceof Li?this.selectedObject.setActive(e):this.selectedObject.parent instanceof Xc&&this.selectedObject.parent.setActive(e,this.selectedObject))}pickFace(e){if(!this.raycaster)return;let t=new be(e.x,e.y),n=cn.screenPoint2NdcPoint(t,this.camera,this.canvas);this.raycaster.setFromCamera(n,this.camera);let i=[];return this.viewer.loadedModels.forEach((e=>{let t=e.object;t&&t.visible&&i.push(t)})),(this.raycaster.intersectObjects(this.viewer.getRaycastableObjectsByMouse(e))||[]).find((e=>{let t=e.object;return t.visible&&t instanceof xt}))}},d2=class extends fr{constructor(e){super(e,{id:"SectionPlugin"}),this.sections={},this.viewer=e;let t=e.getInputManager();t&&(this.sections.ObjectsBoxSection=new u2(e,t),this.sections.AxisPlaneSection=new c2(e,t),this.sections.PickPlaneSection=new h2(e,t))}get raycaster(){return this.viewer.getRaycaster()}activate(e){this.activeSectionType&&this.deactivate(),this.activeSectionType=e,this.sections[e].activate()}deactivate(){let e=this.activeSectionType;e&&this.sections[e].deactivate(),this.activeSectionType=void 0}resetSection(){}isActive(){let e=this.activeSectionType;return e?this.sections[e].isActive:!!this.getActiveSectionType()}getActiveSectionType(){return this.activeSectionType}getActiveSection(){if(this.activeSectionType)return this.sections[this.activeSectionType]}setClippingObjectIds(e){for(let t in this.sections)this.setClippingObjectIdsForType(t,e)}setClippingObjectIdsForType(e,t){this.sections[e].clearClippingObjectIds(),null!=t&&t.length&&(this.sections[e].clippingObjetIds=t,this.sections[e].setClippingEnabled(!0))}destroy(){super.destroy(),this.deactivate(),this.activeSectionType=void 0}},Vve=new O,zve=new vr,Gve=class extends Zf{constructor(e,t){var n;super(e),this.name="BimViewer",this.timer=Date.now(),this.enableSelection=!0,this.selectedObject=void 0,this.loadedModels=[],this.composerRenderEnabled=!0,this.composerEnabled=!1,this.savedMaterialsForOpacity=[],this.raf=new qf,this.clock=new mo,this.renderEnabled=!0,this.enableModelLevelFrustumCulling=!0,this.isFrustumInsectChecking=!1,this.settings=Gv,this.twoDModelCount=0,this.enableFastOperation=!0,this.edgesVisible=!0,this.distanceCullingFactor=150,this.operationTimeoutMs=500,this.bbox=new Ot,this.onResize=()=>{this.viewerContainer&&this.viewerContainer.parentElement&&this.resize(this.viewerContainer.parentElement.clientWidth,this.viewerContainer.parentElement.clientHeight)},this.onKeyDown=e=>{let t=this.camera,n=this.controls;if(!t||!n)return;let i=this.settings.keyboard.sensitivity||3,r=n.getPosition(new O),a=n.getTarget(new O),s=a.clone();if("ArrowLeft"===e.code||"ArrowRight"===e.code){let t=Math.PI*i/180;"ArrowLeft"===e.code&&(t=-t),s.x=(a.x-r.x)*Math.cos(t)-(a.z-r.z)*Math.sin(t)+r.x,s.z=(a.z-r.z)*Math.cos(t)+(a.x-r.x)*Math.sin(t)+r.z,n.setLookAt(r.x,r.y,r.z,s.x,s.y,s.z,!0)}else if("ArrowUp"===e.code||"ArrowDown"===e.code){let t=Math.PI*i/180,o=new O(a.x-r.x,a.y-r.y,a.z-r.z).length(),l=a.y-r.y;"ArrowDown"===e.code&&(t=-t);let h=Math.asin(l/o)+t;if(h<-Math.PI/2||h>Math.PI/2)return;let c=Math.sin(h)*o;s.y=a.y+(c-l),n.setLookAt(r.x,r.y,r.z,s.x,s.y,s.z,!0)}else if("KeyW"===e.code){let e=.01*i,s=r.distanceTo(a);if(s<10*t.near){let e=n.getTarget(new O).lerp(r,-t.near/s);n.setTarget(e.x,e.y,e.z)}r.lerp(a,e),n.setLookAt(r.x,r.y,r.z,a.x,a.y,a.z)}else if("KeyS"===e.code){let e=.01*i;r.lerp(a,-e),n.setLookAt(r.x,r.y,r.z,a.x,a.y,a.z,!1)}else"KeyF"===e.code?this.flyToSelectedObject():"KeyY"===e.code?this.flyTo(r,a.clone().setY(r.y)):"KeyR"===e.code&&this.flyToRandomObject();this.enableRender()},this.enableRender=(e=1e3)=>{this.renderEnabled=!0,this.raf&&(this.timeoutSymbol&&this.raf.clearTimeout(this.timeoutSymbol),this.timeoutSymbol=this.raf.setTimeout((()=>{this.renderEnabled=!1,this.composerRenderEnabled=!0}),e))},this.applyOptionsAndAddToScene=(e,t,n,i)=>ft(this,null,(function*(){let r=Mt.getUpdateProgressFunc(i),a=Mt.getUpdateSubProgressFunc(70,90,i);r(0),se.info(`[Viewer] '${e}' is loaded in ${(Date.now()-this.timer)/1e3}s, adding to scene...`),this.timer=Date.now();let s,o=n.src&&n.src.toLowerCase();if(o&&o.endsWith("dxf")&&this.twoDModelCount++,n.matrix&&16===n.matrix.length){let e=new et;e.elements=n.matrix,t.applyMatrix4(e)}if(t.matrixAutoUpdate=!1,t.updateMatrix(),t.traverse((e=>{e.matrixAutoUpdate&&(e.matrixAutoUpdate=!1,e.updateMatrix())})),n.merge&&this.merge(t),r(50),n.merge){let e=Date.now();Yf.createMeshBvhAsync([t],{saveOriginalIndex:!0}),se.info(`[Viewer] Creates mesh bvh cost ${(Date.now()-e)/1e3}s`)}r(60),t.traverse((e=>{e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0,e.userData.surfaceArea=this.calculateMeshSurfaceArea(e)),e.geometry&&e.layers.enableAll(),e instanceof Ws&&(e.visible=!1)})),r(70),n.edges&&(s=yield Hn.createOutlines(t,void 0,a)),r(90);let l={modelId:this.getUniqueModelId(n.modelId||n.src),object:t,edges:s};this.addModel(l),r(100)})),this.onAnchorPointerDown=e=>{var t,n;null==(t=this.controls)||!t.enableRotate||!this.renderer||null!=(n=this.sectionPlugin)&&n.isActive()||this.setOrbitPoint(e)},this.onAnchorPointerUp=()=>{this.anchor&&(this.anchor.className="anchor"),!this.viewerContainer||!this.camera||this.controls},this.onOperation=()=>{let e=this.renderer;if(!this.enableFastOperation||!e)return;let t=e=>{let t=this.renderer;void 0!==t.distanceCullingFactor&&(t.distanceCullingFactor=e)},n=e=>{this.loadedModels.forEach((t=>{t.edges&&t.edges.forEach((t=>t.visible=e))})),this.edgesVisible=e},i=e=>{let t=this.directionalLight;t&&(t.castShadow=e)};t(this.distanceCullingFactor),this.edgesVisible&&n(!1),i(!1),this.operationTimeout&&clearTimeout(this.operationTimeout),this.operationTimeout=setTimeout((()=>{this.operationTimeout=void 0,i(!0),n(!0),t(0),this.enableRender()}),this.operationTimeoutMs)},this.viewerCfg=Tr(Tr({},fde),e),se.info("[Viewer]","viewerCfg:",this.viewerCfg),this.settings=Gv,this.cameraCfg=t,this.cameraCfg&&this.cameraCfg.near&&(this.settings.camera.near=this.cameraCfg.near),this.cameraCfg&&this.cameraCfg.far&&(this.settings.camera.far=this.cameraCfg.far),this.increaseJobCount(),this.init(),this.animate(),this.renderer&&(null==(n=this.viewerContainer)||n.append(this.renderer.domElement)),this.decreaseJobCount(),se.info(`[Viewer] Initialized in ${(Date.now()-this.timer)/1e3}s`)}init(){let e=this.viewerCfg;this.initThree(),Dn.isBrowser&&!e.context&&this.initDom(),this.initEvents(),this.initControls()}initThree(){this.initScene(),this.initRenderer(),this.initCamera(),this.initLights()}initDom(){let e=this.viewerCfg;this.initSpinner(),this.initCSS2DRenderer(),this.initOthers(),!0===e.enableAxisGizmo&&se.warn("[Viewer] enableAxisGizmo is deprecated, use AxisGizmoPlugin instead!"),!0===e.enableStats&&se.warn("[Viewer] enableStats is deprecated, use StatsPlugin instead!"),e.enableToolbar&&se.warn("[Viewer] enableToolbar is deprecated, use ToolbarPlugin instead!"),e.enableBottomBar&&se.warn("[Viewer] enableBottomBar is deprecated, use BottomBarPlugin instead!"),e.enableNavCube&&se.warn("[Viewer] enableNavCube is deprecated, use NavCubePlugin instead!"),e.enableProgressBar&&(this.loadingProgressBar=this.initLoadingProgressBar()),e.enableContextMenu&&se.warn("[Viewer] enableContextMenu is deprecated, use ContextMenuPlugin instead!"),null!=e.enableSelection&&(this.enableSelection=e.enableSelection)}initScene(){this.scene=new _i,this.scene.matrixAutoUpdate=!1}initRenderer(){this.renderer=new Ms({antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),this.renderer.outputColorSpace=tn,this.renderer.toneMappingExposure=1,this.renderer.useLegacyLights=!1,this.renderer.setClearColor(11119017,1),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=Ev,this.renderer.shadowMap.autoUpdate=!1,Mt.printGpuInfo(this.renderer.getContext()),this.pmremGenerator=new Yh(this.renderer),this.pmremGenerator.compileEquirectangularShader(),this.enableOverlayRenderer&&(this.overlayRender=new Un(this)),this.setEnvironmentFromDataArray()}initCSS2DRenderer(){var e;let t=new Nu;t.setSize(this.width,this.height),t.domElement.style.height="0",t.domElement.style.width="0",t.domElement.style.position="absolute",t.domElement.style.top="0",t.domElement.style.left="0",t.domElement.style.overflow="visible",t.domElement.classList.add("css2d-renderer"),null==(e=this.viewerContainer)||e.appendChild(t.domElement),this.css2dRenderer=t}initCamera(){this.scene&&(this.perspectiveCamera=new ur(45,this.width/this.height,this.settings.camera.near,this.settings.camera.far),this.perspectiveCamera.position.set(0,100,0),this.scene.add(this.perspectiveCamera),this.camera=this.perspectiveCamera)}initControls(e=!1){if(!this.renderer)return;Dn.printDeviceInfo();let t,n=e?this.orthoCamera:this.perspectiveCamera;n&&this.inputManager&&((!this.perspectiveCameraControls||!this.orthoCameraConrols)&&(t=new ba(n,this.inputManager),t.dollySpeed=.3,t.dollyToCursor=!0,t.infinityDolly=!0,t.enabled=!0,t.keyTruckSpeed=10,t.restThreshold=0,t.smoothTime=.05,t.keys={left:"KeyD",up:"KeyE",right:"KeyA",bottom:"KeyQ"},t.listenToKeyEvents(),t.update(0)),t&&(e?(this.orthoCameraConrols=t,t.minZoom=3):(this.perspectiveCameraControls=t,this.bbox&&(t.minDistance=.1,t.maxDistance=10*this.bbox.getSize(new O).length())),this.controls=t,this.enableFastOperation&&t.addEventListener("control",this.onOperation)))}initRotateToCursor(){this.anchor=this.createAnchor()}initLights(){if(!this.scene)return;let e=16777215,t=new js(e,1.5);t.name="sun",t.castShadow=!0,t.position.set(-2,2,4),t.shadow.autoUpdate=!1,t.shadow.mapSize.width=1024,t.shadow.mapSize.height=1024,this.directionalLight=t,this.scene.add(t),this.scene.add(t.target),this.directionalLightHelper=new kb(this.directionalLight),this.directionalLightHelper.visible=!1,this.scene.add(this.directionalLightHelper),this.shadowCameraHelper=new Fb(this.directionalLight.shadow.camera),this.shadowCameraHelper.visible=!1,this.scene.add(this.shadowCameraHelper),this.ambientLight=new Pl(e),this.hemisphereLight=new Du(e,14540253,.2),this.hemisphereLight.position.set(0,300,0),this.scene.add(this.ambientLight),this.scene.add(this.hemisphereLight)}initEvents(){if(!this.renderer||!this.viewerContainer)return;let e=new Jo(this.viewerContainer);this.inputManager=e;let t=!1,n=!1,i=0,r=0,a=0,s=e=>-1!==r&&-1!==a&&Math.abs(e.x-r)<5&&Math.abs(e.y-a)<5;e.addEventListener("pointerdown",(e=>{n=!1,t=!0,0===e.button&&this.onAnchorPointerDown(e)})),e.addEventListener("pointermove",(e=>{t&&(n=!s(e))})),e.addEventListener("pointerup",(e=>{if(t=!1,n)return n=!1,void this.onAnchorPointerUp();if(0===e.button)if((e=>{let t=e.timestamp-i;return!!(0===e.button&&t<300&&s(e))})(e)){let t=this.getClickedObject(e);t?this.flyToObject(t):this.viewFitAll(),i=0,r=-1,a=-1}else i=e.timestamp,r=e.x,a=e.y,this.handleMouseClick(e);else e.button;this.onAnchorPointerUp()})),e.addEventListener("keydown",(e=>{this.onKeyDown(e)})),this.initRotateToCursor(),this.raycaster=new ia}initOthers(){!this.scene||!this.renderer||!this.camera||(this.renderer.domElement.style.outlineWidth="0")}initLoadingProgressBar(){return new Gf(this.widgetContainer)}sycnCameraAndControls(e){let t=e?this.orthoCamera:this.perspectiveCamera,n=e?this.perspectiveCameraControls:this.orthoCameraConrols,i=e?this.orthoCameraConrols:this.perspectiveCameraControls,r=new O;n.getPosition(r),i.setPosition(r.x,r.y,r.z);let a=n.getTarget(new O);if(i.setTarget(a.x,a.y,a.z),e){let e=t;e.zoom=10,e.updateProjectionMatrix()}}setToOrthographicCamera(e=!1){var t;if(!this.scene||!this.controls)return;let n=this.perspectiveCamera,i=this.perspectiveCameraControls,r=this.orthoCamera,a=this.orthoCameraConrols;e?(r||(r=new Ur(-this.width/2,this.width/2,this.height/2,-this.height/2,this.settings.camera.near,this.settings.camera.far),r.position.set(0,100,0),r.zoom=10,r.updateProjectionMatrix(),this.scene.add(r),this.orthoCamera=r,this.frustumSize=this.width),a||(this.initControls(!0),a=this.orthoCameraConrols),this.camera=r,this.controls=a):(this.camera=n,this.controls=i),this.sycnCameraAndControls(e),this.resize(this.width,this.height),null==(t=this.composer)||t.passes.forEach((e=>{e.camera&&(e.camera=this.camera)})),this.dispatchEvent("CameraChanged")}animate(){var e,t,n;if(this.minFrameInterval>0&&Date.now()-this.lastFrameExecuteTime!!e.tilesRenderer));0!==e.length&&(this.camera.updateMatrixWorld(),e.forEach((e=>{e.tilesRenderer.update()})))}frustumCullingByModelBBox(){if(!this.enableModelLevelFrustumCulling)return;let e=this.camera,t=this.scene;if(!e||!t)return;e.updateMatrixWorld();let n=new et;n.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse);let i=new ya;i.setFromProjectionMatrix(n);let r=(e,t)=>{if(e&&t&&(void 0===e.userData._visible&&(e.userData._visible=!0,Object.defineProperties(e,{visible:{set:t=>{e.userData._visible=t,this.isFrustumInsectChecking||(e.userData.userConfigVisibility=!0)},get:()=>e.userData._visible}})),void 0===e.userData.userConfigVisibility)){let n=i.intersectsBox(t);e.visible!==n&&(e.visible=n,se.debug(`[Viewer] frustumCullingByModelBBox() set model (id ${e.id})'s visible to:`,n))}};this.isFrustumInsectChecking=!0,this.loadedModels.forEach((e=>{if(e.tilesRenderer){let t=e.tilesRenderer.group;r(t,e.bbox)}else r(e.object,e.bbox)})),this.isFrustumInsectChecking=!1}destroy(){var e,t,n,i;null==(e=this.inputManager)||e.removeEventListener();let r=this.webcamPlane;this.scene&&r&&(this.scene.remove(r),r.geometry.dispose(),r.material.dispose(),this.webcamPlane=void 0),this.webcam=void 0,this.composer=void 0,this.renderPass=void 0,this.effectFxaaPass=void 0,this.saoPass=void 0,this.ssaoPass=void 0,this.outlinePass=void 0,this.ambientLight=void 0,this.directionalLight=void 0,this.hemisphereLight=void 0,this.directionalLightHelper&&(this.directionalLightHelper.dispose(),this.directionalLightHelper=void 0),this.controls&&(this.disposeRotateToCursor(),this.controls.dispose(),this.controls=void 0),this.perspectiveCameraControls&&(this.perspectiveCameraControls.dispose(),this.perspectiveCameraControls=void 0),this.shadowCameraHelper&&(this.shadowCameraHelper.dispose(),this.shadowCameraHelper=void 0),this.css2dRenderer&&(null==(t=this.viewerContainer)||t.removeChild(this.css2dRenderer.domElement),this.css2dRenderer=void 0),this.raycaster=void 0,this.selectedObject=void 0,this.savedMaterialsForOpacity=void 0,this.section=void 0,this.sectionType=void 0,this.loadedModels.forEach((e=>{e.tilesRenderer&&e.tilesRenderer.dispose()})),this.loadedModels=[],this.perspectiveCamera=void 0,this.perspectiveCameraControls=void 0,this.raf&&(this.timeoutSymbol&&this.raf.clearTimeout(this.timeoutSymbol),this.raf=void 0),null==(n=this.fontManager)||n.destroy(),this.fontManager=void 0,this.pmremGenerator&&(this.pmremGenerator.dispose(),this.pmremGenerator=void 0),null==(i=this.zoomToRectHelper)||i.destroy(),this.zoomToRectHelper=void 0,super.destroy()}loadLocalModel(e,t,n,i){return ft(this,null,(function*(){var r,a;this.timer=Date.now(),this.increaseJobCount();let s=t.modelId||t.src,o=this.translate("ProgressBar.Loading"),l=e=>{var t;null==(t=this.loadingProgressBar)||t.updateProgress(s,o,e),i&&i(new ProgressEvent("LoadProgress",{loaded:e,total:100}))},h=!1,c=(e,t,n)=>{var r;let a=100*e.loaded/e.total;a=a*(n-t)/100+t,a>n&&(h||(se.warn("[Progress] Invalid ProgressEvent:",e),h=!0),a=n),null==(r=this.loadingProgressBar)||r.updateProgress(s,o,a),i&&i(new ProgressEvent("LoadProgress",{loaded:a,total:100}))},u=e=>c(e,0,50),d=e=>c(e,50,99);null==(r=this.loadingProgressBar)||r.addProgressItem(s),l(0);try{let i=new $a(n);this.fontManager&&i.setFont(this.fontManager);let r=yield i.loadLocalModel(e,t.src,u);if(r)return yield this.applyOptionsAndAddToScene(e,r,t,d),Promise.resolve()}catch(e){let i=`Error loading ${t.src}`;return se.error(i,e),Promise.reject(i)}finally{this.decreaseJobCount(),l(100),null==(a=this.loadingProgressBar)||a.delayRemoveProgressItem(s)}return Promise.reject()}))}loadModel(e,t){return ft(this,null,(function*(){var n,i;this.timer=Date.now(),this.increaseJobCount();let r=e.modelId||e.src,a=this.translate("ProgressBar.Loading"),s=e=>{var n;null==(n=this.loadingProgressBar)||n.updateProgress(r,a,e),t&&t(new ProgressEvent("LoadProgress",{loaded:e,total:100}))},o=!1,l=(e,n,i)=>{var s;let l=100*e.loaded/e.total;l=l*(i-n)/100+n,l>i&&(o||(se.warn("[Progress] Invalid ProgressEvent:",e),o=!0),l=i),null==(s=this.loadingProgressBar)||s.updateProgress(r,a,l),t&&t(new ProgressEvent("LoadProgress",{loaded:l,total:100}))},h=e=>l(e,0,50),c=e=>l(e,50,99);null==(n=this.loadingProgressBar)||n.addProgressItem(r),s(0);try{let t=new $a;this.fontManager&&t.setFont(this.fontManager);let n=yield t.loadModel(e.src,e.fileFormat,h);if(n)return yield this.applyOptionsAndAddToScene(e.src,n,e,c),Promise.resolve()}catch(t){let i=`Error loading ${e.src}`;return se.error(i,t),Promise.reject(i)}finally{this.decreaseJobCount(),s(100),null==(i=this.loadingProgressBar)||i.delayRemoveProgressItem(r)}return Promise.reject()}))}load3dTiles(e){return ft(this,null,(function*(){var t;this.timer=Date.now(),this.increaseJobCount();let n=new w_(e.src),i=new Ot,r=yield new Promise(((t,r)=>{n.onLoadTileSet=()=>{n.getBounds(i)||(n.getBoundingSphere(zve)?zve.getBoundingBox(i):(se.warn(`[Viewer] Can't get the correct bounding box of 3dTiles '${e.src}'!`),r())),se.debug(i),n.onLoadTileSet=null;let a=n.group;se.debug(a),t(a)},n.onLoadModel=e=>{e.traverse((e=>{e.matrixAutoUpdate&&(e.matrixAutoUpdate=!1,e.updateMatrix()),e.isMesh&&(e.castShadow=!0,e.receiveShadow=!0),e.geometry&&e.layers.enableAll()})),e.updateWorldMatrix(!1,!0),this.updateDirectionalLightShadow(),this.enableRender()},n.setCamera(this.camera),n.setResolutionFromRenderer(this.camera,this.renderer),n.update()}));if(r){let a=Date.now(),s={modelId:this.getUniqueModelId(e.modelId||e.src),object:r,bbox:i,tilesRenderer:n};if(this.loadedModels.push(s),e.matrix&&16===e.matrix.length){let t=new et;t.elements=e.matrix,r.applyMatrix4(t)}return r.matrixAutoUpdate=!1,r.updateMatrix(),r.updateMatrixWorld(!0),null==(t=this.scene)||t.add(r),i.applyMatrix4(r.matrix),this.computeBoundingBox(),this.tryAdjustDirectionalLight(),1===this.loadedModels.length&&(this.tryAdjustCameraNearAndFar(),this.goToHomeView()),se.info(`[Viewer] Added 3dTiles '${e.src}' to scene in ${(Date.now()-a)/1e3}s`),this.enableRender(),this.decreaseJobCount(),this.dispatchEvent("ModelLoaded"),Promise.resolve()}return this.decreaseJobCount(),this.dispatchEvent("ModelLoaded"),Promise.reject()}))}setFont(e){return ft(this,null,(function*(){let t=Date.now();this.fontManager||(this.fontManager=new ud),yield this.fontManager.loadFonts(e),se.info(`[Viewer] Font file(s) load time in ${(Date.now()-t)/1e3}s`)}))}setDracoDecoderPath(e){$a.setDracoDecoderPath(e)}addModel(e){if(!this.scene||!this.renderer)return;this.increaseJobCount();let t=(new Ot).setFromObject(e.object);e.bbox||(e.bbox=t),this.scene.add(e.object),this.loadedModels.push(e),this.computeBoundingBox(),this.tryAdjustDirectionalLight(),1===this.loadedModels.length&&(this.tryAdjustCameraNearAndFar(),this.goToHomeView()),se.info(`[Viewer] Added '${e.modelId}' to scene in ${(Date.now()-this.timer)/1e3}s`),this.renderer.shadowMap.needsUpdate=!0,this.enableRender(),this.dispatchEvent("ModelLoaded",{modelId:e.modelId,bbox:t}),this.decreaseJobCount()}calculateMeshSurfaceArea(e){let t=new Zr,n=[0,0,0],i=e.geometry,r=i.getAttribute("position"),a=i.getIndex(),s=a?a.count:r.count,o=0;for(let l=0;le.object.id)).forEach((s=>{if(e){this.savedMaterialsForOpacity&&this.savedMaterialsForOpacity.length>0&&Hn.revertObjectOpacityById(r,s,this.savedMaterialsForOpacity);let e=Hn.setObjectOpacityById(r,s,t,n,i);a.push(...e)}else this.savedMaterialsForOpacity&&Hn.revertObjectOpacityById(r,s,this.savedMaterialsForOpacity)})),this.savedMaterialsForOpacity=e?a:[],this.enableRender()}hasTransparentObject(){return!!(this.savedMaterialsForOpacity&&this.savedMaterialsForOpacity.length>0)}showVertexNormals(e,t=.1){var n,i,r;e?(this.vertexNormalsHelpers||(this.vertexNormalsHelpers=new er),null==(n=this.scene)||n.traverseVisible((e=>{var n;if(e instanceof xt&&!["SKYBOX","GROUND_GRID","GROUND_GRASS","BIM_VIEWER_BOX_HELPER"].includes(e.name)){if(!e.geometry.attributes.normal)return;let i=new QP(e,t,16711680);null==(n=this.vertexNormalsHelpers)||n.add(i)}})),null==(i=this.scene)||i.add(this.vertexNormalsHelpers)):this.vertexNormalsHelpers&&(null==(r=this.scene)||r.remove(this.vertexNormalsHelpers),this.vertexNormalsHelpers=void 0)}resize(e,t){super.resize(e,t),t>0&&(this.composer&&this.composer.setSize(e,t),this.effectFxaaPass&&this.effectFxaaPass.uniforms.resolution.value.set(1/e,1/t),this.css2dRenderer&&(this.css2dRenderer.setSize(e,t),this.css2dRenderer.domElement.style.height="0",this.css2dRenderer.domElement.style.width="0")),this.enableRender()}getRaycaster(){return this.raycaster}getRaycastableObjectsByMouse(e){let t=[];if(!(this.raycaster&&this.camera&&this.scene&&e&&this.viewerContainer))return t;let n=new be(e.x,e.y),i=cn.screenPoint2NdcPoint(n,this.camera,this.viewerContainer);return this.camera.updateMatrixWorld(),this.raycaster.setFromCamera(i,this.camera),t=this.getRaycastableObjects(),t}getRaycastableObjects(){let e=[];return this.loadedModels.forEach((t=>{let n=t.object;n&&n.visible&&e.push(n)})),e}getIntersections(e){let t=this.getRaycastableObjectsByMouse(e),n=this.raycaster&&this.raycaster.intersectObjects(t,!0)||[];return this.renderer&&this.renderer.clippingPlanes.length>0&&(n=n.filter((e=>{var t;return null==(t=this.renderer)?void 0:t.clippingPlanes.every((function(t){return t.distanceToPoint(e.point)>0}))}))),n}getAllIntersections(e){if(!(this.raycaster&&this.camera&&this.scene&&this.viewerContainer))return[];let t=new be(null==e?void 0:e.x,null==e?void 0:e.y),n=cn.screenPoint2NdcPoint(t,this.camera,this.viewerContainer);this.raycaster.setFromCamera(n,this.camera);let i=this.scene.children,r=this.raycaster.intersectObjects(i,!0)||[];return this.renderer&&this.renderer.clippingPlanes.length>0&&(r=r.filter((e=>{var t;return null==(t=this.renderer)?void 0:t.clippingPlanes.every((function(t){return t.distanceToPoint(e.point)>0}))}))),r}getClickedObject(e){if(!this.raycaster)return;let t=Date.now();this.raycaster.layers.set(12);let n=this.getIntersections(e);se.debug(`[Viewer] getIntersections costs ${(Date.now()-t)/1e3}s`);let i=n.find((e=>{let t=e.object;return t.visible&&t instanceof xt}));return null==i?void 0:i.object}handleMouseClick(e){var t,n,i;if(null!=(t=this.measurePlugin)&&t.isActive()||null!=(n=this.sectionPlugin)&&n.isActive()||!this.raycaster)return;let r=Date.now();this.raycaster.layers.set(12);let a=this.getIntersections(e);se.debug(`[Viewer] getIntersections costs ${(Date.now()-r)/1e3}s`);let s,o,l=a.find((e=>{let t=e.object;return t.visible&&t instanceof xt})),h=l&&l.object||void 0;if(h)if(h instanceof Pi)s=l.instanceId,this.selectedObject&&this.selectedObject.id===h.id&&this.selectedObject.userData.instanceId===s&&(h=void 0);else if(Ar.isMergedMesh(h)){let e=l&&l.faceIndex||-1;e>=0?(o=Ar.getBatchIdByFaceIndex(h,e),this.selectedObject&&this.selectedObject.id===h.id&&this.selectedObject.userData.batchId===o&&(h=void 0)):h=void 0}else this.selectedObject&&this.selectedObject.id===h.id&&(h=void 0);if(a.length>0&&a[0].point){let e=null==(i=this.overlayRender)?void 0:i.getDrawablesByPosition(a[0].point,this.raycaster);e&&e.length>0?h=e[0]:this.enableSelection||(h=void 0)}this.selectedObject&&this.clearSelection(),h?this.selectObject(h,s,o):this.clearSelection()}selectObject(e,t,n,i=void 0){if(e instanceof Bi)return this.selectedObject=e,this.selectedObject.selected=!0,void this.enableRender();if(this.selectedObject){let t=this.selectedObject.userData;if(null!=t.instanceId&&t.originalMatrix&&t.clonedMesh){this.scene&&this.scene.remove(t.clonedMesh);let n=this.selectedObject;if(n.setMatrixAt(t.instanceId,t.originalMatrix),n.instanceMatrix.needsUpdate=!0,n.updateMatrix(),delete t.instanceId,delete t.originalMatrix,e===t.clonedMesh)return t.clonedMesh.geometry.dispose(),delete t.clonedMesh,this.selectedObject=void 0,void(this.outlinePass&&(this.outlinePass.selectedObjects=[]));t.clonedMesh.geometry.dispose(),delete t.clonedMesh}else if(null!=t.batchId&&t.clonedMesh){if(this.scene&&this.scene.remove(t.clonedMesh),delete t.batchId,e===t.clonedMesh)return t.clonedMesh.geometry.dispose(),delete t.clonedMesh,this.selectedObject=void 0,void(this.outlinePass&&(this.outlinePass.selectedObjects=[]));t.clonedMesh.geometry.dispose(),delete t.clonedMesh}else if(t.originalMaterial){if(this.selectedObject.material){let e=this.selectedObject.material;Array.isArray(e)?e.forEach((e=>e.dispose())):e instanceof yr&&e.dispose()}this.selectedObject.material=t.originalMaterial,delete t.originalMaterial}this.selectedObject=void 0,this.outlinePass&&(this.outlinePass.selectedObjects=[])}if(this.scene&&e){if(e instanceof Pi&&null!=t){let n=e,r=new et,a=new et;a.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),n.getMatrixAt(t,r),this.selectedObject=e,this.outlinePass&&(this.outlinePass.selectedObjects=[e]);let s=es.clonedHighlightMaterials(e,{depthTest:i});if(s){let i=new xt(n.geometry.clone(),s);i.applyMatrix4(e.matrixWorld.multiply(r)),i.matrixWorldNeedsUpdate=!0,i.name="Cloned mesh for highlighting",i.layers.enableAll();let o=r.clone();o.multiplyMatrices(r,a),n.setMatrixAt(t,o),n.instanceMatrix.needsUpdate=!0,n.updateMatrix(),this.selectedObject.userData.instanceId=t,this.selectedObject.userData.originalMatrix=r,this.selectedObject.userData.clonedMesh=i,this.scene.add(i)}}else if(Ar.isMergedMesh(e)&&null!=n){let t=Ar.getBatchByBatchId(e,n),r=`[Viewer] Clicked on merged mesh(id: ${e.id}).`;r+=` batchId: ${n}, object name before merge: ${null==t?void 0:t.name}`,null!=t&&t.userData&&(r+=`, userData before merge: ${JSON.stringify(t.userData)}`),se.info(r);let a=es.clonedHighlightMaterials(e,{depthTest:i}),s=Ar.cloneGeometryForBatch(e,t);if(a&&s){let t=new xt(s,a);t.applyMatrix4(e.matrixWorld),t.matrixWorldNeedsUpdate=!0,t.name="Cloned mesh for highlighting",t.layers.enableAll(),this.selectedObject=e,this.selectedObject.userData.batchId=n,this.selectedObject.userData.clonedMesh=t,this.scene.add(t)}}else{let t=es.clonedHighlightMaterials(e,{depthTest:i});t&&(this.selectedObject=e,this.selectedObject.userData.originalMaterial=this.selectedObject.material,this.selectedObject.material=t,this.outlinePass&&(this.outlinePass.selectedObjects=[e]))}this.enableRender()}else this.enableRender()}clearSelection(){this.selectedObject&&this.selectedObject instanceof Bi?this.selectedObject.selected=!1:this.selectObject(),this.selectedObject=void 0}getBBox(){return this.bbox}enableModelEdges(e,t){return ft(this,null,(function*(){let n=Mt.getUpdateProgressFunc(t);n(0),this.increaseJobCount();let i=this.loadedModels.length;for(let r=0;rt.visible=e))}this.decreaseJobCount(),n(100),this.enableRender()}))}flyToObjects(e){if(!e||0===e.length||!this.camera)return;let t=new Ot;e.forEach((e=>{let n=ks.getBoundingBox(e);t.union(n)}));let n=new vr;t.getBoundingSphere(n),this.controls.fitToSphere(n,!0)}flyToObject(e){this.flyToObjects([e])}flyToSelectedObject(){if(!this.selectedObject)return;let e=this.selectedObject;(e instanceof Pi&&e.userData.clonedMesh||Ar.isMergedMesh(e)&&e.userData.clonedMesh)&&(e=e.userData.clonedMesh),this.flyToObject(e)}flyToRandomObject(){var e,t,n;let i=this.loadedModels.map((e=>e.object.id)),r=i.length;if(r<=0)return;let a=i[Math.floor(Math.random()*r)];if(!(null==(e=this.scene)?void 0:e.getObjectById(a)))return;let s=[];if(null==(t=this.scene)||t.traverseVisible((e=>{(e instanceof xt||e instanceof hr)&&!["SKYBOX","GROUND_GRID","GROUND_GRASS","BIM_VIEWER_BOX_HELPER"].includes(e.name)&&s.push(e.id)})),s.length<1)return;let o=Math.floor(Math.random()*s.length),l=null==(n=this.scene)?void 0:n.getObjectById(s[o]);l&&(se.info(`[Viewer] Flying to random object: ${l.name}, type: ${l.type}`),this.selectObject(l,void 0,void 0,!1),this.flyToObject(l))}flyTo(e,t){let n=this.camera,i=this.controls;if(!n||!i)return;if(e.equals(t))return void se.error("[Viewer] camera position and lookAt cannot be the same!");if(!Mt.isVectorValid(e)||!Mt.isVectorValid(t))return void se.error("[Viewer] invalid position or lookAt!");let r=e.distanceTo(t);rn.far&&(e=e.clone().sub(t).normalize().multiplyScalar(.9*n.far),se.warn("[Viewer] camera could be too far to see the object!")),i.setLookAt(e.x,e.y,e.z,t.x,t.y,t.z,!0),i.setFocalOffset(0,0,0,!0)}viewFitAll(){if(!this.scene||!this.camera||!this.controls)return;let e=ks.getVisibleObjectBoundingBox(this.scene),t=new vr;e.getBoundingSphere(t),this.controls.fitToSphere(t,!0)}goToHomeView(){if(!this.scene)return;let e=this.camera,t=this.cameraCfg,n=t&&Mt.arrayToVector3(t.eye),i=t&&Mt.arrayToVector3(t.look);if(n&&i){let e=this.controls;e.setLookAt(n.x,n.y,n.z,i.x,i.y,i.z,!0),e.setFocalOffset(0,0,0,!0)}else{let t=new O,n=new O,i=new O(-1,-.5,-1);this.bbox.getCenter(n),t.subVectors(n,i);let r=new vr;this.bbox.getBoundingSphere(r);let a=this.controls;if(a.setLookAt(t.x,t.y,t.z,n.x,n.y,n.z,!0),a.fitToSphere(r,!0),a.getPosition(t),(!this.cameraCfg||this.cameraCfg&&(!this.cameraCfg.eye||!this.cameraCfg.look))&&(this.cameraCfg={eye:t.toArray(),look:n.toArray()}),e instanceof Ur){let t=this.bbox,n=t.max.x-t.min.x,i=t.max.z-t.min.z,r=e.right-e.left,a=e.top-e.bottom;e.zoom=Math.max(r,a)/Math.max(n,i),e.zoom/=2,e.updateProjectionMatrix()}t.equals(n)||this.flyTo(t,n)}}zoomToBBox(e){if(!this.controls)return;let t=new vr;e.getBoundingSphere(t),this.controls.fitToSphere(t,!0)}tryAdjustCameraNearAndFar(){let e=this.camera;if(!this.scene||!e)return;let t=this.bbox,n=e.near,i=e.far,r=t.max.x-t.min.x,a=t.max.y-t.min.y,s=t.max.z-t.min.z,o=Math.max(r,a,s),l=o/5,h=5*o;if(n>l||iMt.numberToString(e);se.info(`[Viewer] BBox's longest side is: ${t(o)}`),n>l&&(se.warn(`[Viewer] camera.near(${t(n)}) shouldn't bigger than ${t(l)}, will change it!`),e.near=l),i"SectionPlugin"===e.id))}activateSection(e="ObjectsBoxSection"){var t,n;!this.inputManager||null!=(t=this.sectionPlugin)&&t.isActive()?this.sectionPlugin||se.warn("[Viewer] SectionPlugin doesn't seem to be installed!"):(this.sectionType=e,this.clearSelection(),null==(n=this.sectionPlugin)||n.activate(e),this.enableRender())}deactivateSection(){var e;null==(e=this.sectionPlugin)||e.deactivate(),this.enableRender()}getActiveSection(){var e;return null==(e=this.sectionPlugin)?void 0:e.getActiveSection()}get measurePlugin(){return this.plugins.find((e=>"MeasurementPlugin"===e.id))}getMeasurements(){let e=this.measurePlugin;return e?e.getData():[]}activateMeasurement(e){let t=this.measurePlugin;t?(t.activate(e),this.clearSelection()):se.warn("[Viewer] MeasurementPlugin doesn't seem to be installed!")}deactivateMeasurement(){var e;null==(e=this.measurePlugin)||e.deactivate()}setMeasurementVisibility(e,t){let n=this.measurePlugin;return!!n&&n.setVisibilityById(e,t)}clearMeasurements(){var e;null==(e=this.measurePlugin)||e.clear()}zoomToRect(){this.zoomToRectHelper||(this.zoomToRectHelper=new Dy(this)),this.zoomToRectHelper.activate()}deactivateZoomRect(){var e;null==(e=this.zoomToRectHelper)||e.deactivate()}enableWebCam(){this.scene&&(this.webcam||(this.webcam=new o2),this.webcamPlane||(this.webcamPlane=this.webcam.createWebCamPlane(),this.webcamPlane.position.set(10,2,0)),this.scene.add(this.webcamPlane))}disableWebCam(){this.scene&&this.webcamPlane&&(this.webcamPlane.geometry.dispose(),this.webcamPlane.material.dispose(),this.scene.remove(this.webcamPlane))}setEnvironment(e){Cc.createEnvTexture(this.pmremGenerator,e).then((e=>{this.scene&&(this.scene.environment&&this.scene.environment.dispose(),this.scene.environment=e,this.enableRender())}))}setEnvironmentFromDataArray(e){Cc.createEnvTextureFromDataArray(this.pmremGenerator,e).then((e=>{this.scene&&(this.scene.environment=e,this.enableRender())}))}takeObjectsScreenshot(e){return ft(this,null,(function*(){return new Promise(((t,n)=>{var i;this.renderer||n("renderer is undefined"),null==(i=this.scene)||i.traverse((t=>{t instanceof xt&&((0,f2.includes)(e,(0,f2.get)(t.userData,"UniqueId"))?t.visible=!0:t.visible=!1)})),this.enableRender(),setTimeout((()=>{var e;t(null==(e=this.renderer)?void 0:e.domElement.toDataURL("image/png"))}),1e3)}))}))}setObjectColor(e,t){this.clearSelection();let n={};e.traverse((e=>{let t=e.material;t&&(Array.isArray(t)?t.forEach((e=>{n[e.id]=e})):n[t.id]=t)}));for(let i in n)es.setMaterialColor(n[i],new ct(t));this.enableRender()}updateRaycasterThreshold(){let e=this.camera;if(!e||!this.raycaster)return;let t=12/e.zoom,n=this.raycaster.params;n.Line?n.Line.threshold=t:n.Line={threshold:t},n.Points?n.Points.threshold=t:n.Points={threshold:t}}merge(e){this.increaseJobCount();try{let t=[];e.traverse((e=>{e.geometry&&e.material&&t.push(e)})),Ar.deepMerge(t,e)}finally{this.decreaseJobCount()}}updateProjectSettings(e){this.settings=e;let t=(e,t)=>{e&&t&&(e.near=t.near,e.far=t.far,e.updateProjectionMatrix())};t(this.perspectiveCamera,this.settings.camera),t(this.orthoCamera,this.settings.camera),this.enableRender(10)}computeBoundingBox(){let e=new Ot;return this.loadedModels.forEach((t=>{t.bbox&&!t.bbox.isEmpty()&&e.union(t.bbox)})),this.bbox=e,this.controls&&(this.controls.minDistance=.1,this.controls.maxDistance=10*this.bbox.getSize(new O).length()),e}setDistanceCullingFactor(e){this.distanceCullingFactor=e}getDistanceCullingFactor(){return this.distanceCullingFactor}getCameraPositionAndDirection(){let e=this.camera;if(!e)return;let t=e.position,n=new O;return e.getWorldDirection(n),{position:{x:t.x,y:t.y,z:t.z},direction:{x:n.x,y:n.y,z:n.z}}}},p2=ji(Fl(),1),Vvt=(e=>(e[e.Browser=0]="Browser",e[e.Browserless=1]="Browserless",e[e.Headless=2]="Headless",e))(Vvt||{}),qve=class{constructor(e,t,n){if(this.scene=this.initScene(),this.selectedObject=void 0,this.loadedModels=[],this.clock=new mo,this.viewerMode=0,this.raycaster=new ia,this.savedMaterialsForOpacity=[],this.jobCount=0,this.bbox=new Ot,this.outlineMaterial=new Gn({color:1118481}),this.outlineRoot=new er,this.transparentObjectIds=[],this.applyOptionsAndAddToScene=(e,t,n,i)=>ft(this,null,(function*(){if(se.info(`[Viewer] '${e}' is loaded, adding to scene...`),n.matrix&&16===n.matrix.length){let e=new et;e.elements=n.matrix,t.applyMatrix4(e)}let r;t.traverse((e=>{e.geometry&&e.layers.enableAll(),e instanceof Ws&&(e.visible=!1)})),n.edges&&(r=yield Hn.createOutlines(t,void 0,i));let a=n.modelId||n.src,s=e=>!!this.loadedModels.find((t=>t.modelId===e));if(s(a)){let e=1;for(;s(`${a}_${e}`);)e++;a=`${a}_${e}`,se.warn(`[Viewer] Model '${a}' is loaded more than once!`)}let o={modelId:a,object:t,edges:r};this.addModel(o)})),this.getMeshes=e=>{let t=[];return e instanceof xt?t.push(e):e.traverseVisible((e=>{e instanceof xt&&t.push(e)})),t},this.containerOrCanvas=e,t&&(this.viewerMode=t),this.glContext=n,1===this.viewerMode&&(e instanceof HTMLDivElement||!n))throw new Error("[Viewer] Parameters don't match Browserless viewerMode !");this.increaseJobCount(),this.init(),this.decreaseJobCount(),se.info("[Viewer] Initialized"),this.animate()}init(){this.initRenderer(),this.initCamera(),this.initControls(),this.initLights(),this.initPointerEvents(),this.scene.add(this.outlineRoot)}initScene(){let e=new _i;return e.background=new ct(7112861),e.matrixAutoUpdate=!0,e}isBrowserlessMode(){return 1===this.viewerMode}isBrowserMode(){return 0===this.viewerMode}initRenderer(){let e={antialias:!0,preserveDrawingBuffer:!0},t=this.isBrowserlessMode();t&&Object.assign(e,{canvas:this.containerOrCanvas,context:this.glContext});let n=new Ms(e);if(t){let e=this.containerOrCanvas.width,t=this.containerOrCanvas.height;se.info(`[Viewer] Render target size: ${e} x ${t}`),this.renderTarget=new sr(e,t,{minFilter:Ir,magFilter:Jr,format:ea,type:Ec}),n.setRenderTarget(this.renderTarget)}else{let e=this.containerOrCanvas.clientWidth,t=this.containerOrCanvas.clientHeight;this.containerOrCanvas.append(n.domElement),n.setPixelRatio(window.devicePixelRatio),n.setSize(e,t)}n.outputColorSpace=tn,n.toneMappingExposure=1,n.useLegacyLights=!1,n.setClearColor(11119017,1),n.shadowMap.enabled=!0,n.shadowMap.type=Ev,this.renderer=n,t||(this.pmremGenerator=new Yh(n),this.pmremGenerator.compileEquirectangularShader(),this.setEnvironmentFromDataArray())}initCamera(){if(!this.scene)return;let e=this.containerOrCanvas.clientWidth||this.containerOrCanvas.width||0,t=this.containerOrCanvas.clientHeight||this.containerOrCanvas.height||0,n=1;e&&t&&(n=e/t),this.camera=new ur(68,n,.05,1e4),this.camera.position.set(10,10,10),this.camera.lookAt(0,0,0),this.scene.add(this.camera)}initControls(){if(!this.renderer)return;let e=this.camera;if(!e)return;let t=new ba(e,this.renderer.domElement);t.smoothTime=.05,t.enabled=!0,t.keyTruckSpeed=10,t.keys={left:"KeyD",up:"KeyE",right:"KeyA",bottom:"KeyQ"},t.update(0),this.controls=t,t.addEventListener("update",(()=>{!this.isBrowserMode()&&this.renderer&&this.renderer.render(this.scene,e)}))}initLights(){if(!this.scene)return;let e=16777215,t=new js(e,.3);t.position.set(-2,2,4);let n=new Pl(3158064),i=new Du(e,14540253,3);i.position.set(0,300,0),this.scene.add(t),this.scene.add(n),this.scene.add(i)}initPointerEvents(){if(!this.renderer||!this.camera||!this.controls)return;let e=!1,t=!1,n=-1,i=-1;this.renderer.domElement.addEventListener("pointerdown",(t=>{n=t.x,i=t.y,e=!1})),this.renderer.domElement.addEventListener("pointermove",(t=>{n>=0&&i>=0&&(Math.abs(t.x-n)>5||Math.abs(t.y-i)>5)&&(e=!0)})),this.renderer.domElement.addEventListener("pointerup",(()=>{t&&setTimeout((()=>{t=!1}),200),n=-1,i=-1})),this.renderer.domElement.addEventListener("dblclick",(n=>{t=!0,e||(this.handleMouseClick(n),this.flyToSelectedObject())}))}animate(){var e;this.isBrowserMode()&&requestAnimationFrame(this.animate.bind(this));let t=this.clock.getDelta();this.controls&&this.controls.update(t),this.scene&&this.camera&&(null==(e=this.renderer)||e.render(this.scene,this.camera))}destroy(){this.camera=void 0,this.scene&&this.scene.clear(),this.requestAnimationFrameHandle&&(cancelAnimationFrame(this.requestAnimationFrameHandle),this.requestAnimationFrameHandle=void 0),this.renderer&&(this.containerOrCanvas.removeChild(this.renderer.domElement),this.renderer.clear(),this.renderer.dispose(),this.renderer=void 0),this.controls&&(this.controls.dispose(),this.controls=void 0),this.renderTarget&&(this.renderTarget.dispose(),this.renderTarget=void 0),this.raycaster=void 0,this.selectedObject=void 0,this.savedMaterialsForOpacity=void 0,this.loadedModels=[]}loadLocalModel(e,t,n){return ft(this,null,(function*(){let i=yield(new $a).loadLocalModel(e,t.src,n);return i?(yield this.applyOptionsAndAddToScene(e,i,t),Promise.resolve()):Promise.reject()}))}loadModel(e,t){return ft(this,null,(function*(){this.increaseJobCount();let n=yield(new $a).loadModel(e.src,e.fileFormat,t);return n?(yield this.applyOptionsAndAddToScene(e.src,n,e),Promise.resolve()):Promise.reject()}))}parseGltf(e,t,n,i){this.increaseJobCount(),(new $a).parseGltf(e,t.src,(e=>{this.applyOptionsAndAddToScene(t.src,e,t),n&&n(e)}),(e=>{i&&i(e)}))}addModel(e){if(!this.scene||!this.renderer)return;this.increaseJobCount();let t=(new Ot).setFromObject(e.object);e.bbox||(e.bbox=t),this.scene.add(e.object),this.loadedModels.push(e),this.computeBoundingBox(),1===this.loadedModels.length&&(this.tryAdjustCameraNearAndFar(),this.goToHomeView()),this.renderer.shadowMap.needsUpdate=!0,se.info(`[Viewer] Added '${e.modelId}' to scene`),this.decreaseJobCount()}addOrRemoveObjectOpacity(e=!0,t=.3,n,i){if(this.savedMaterialsForOpacity||(this.savedMaterialsForOpacity=[]),!this.scene)return;let r=this.scene,a=[];this.loadedModels.forEach((s=>{if(e){this.savedMaterialsForOpacity&&this.savedMaterialsForOpacity.length>0&&Hn.revertObjectOpacityById(r,s.object.id,this.savedMaterialsForOpacity);let e=Hn.setObjectOpacityById(r,s.object.id,t,n,i);a.push(...e)}else this.savedMaterialsForOpacity&&Hn.revertObjectOpacityById(r,s.object.id,this.savedMaterialsForOpacity)})),this.savedMaterialsForOpacity=e?a:[]}hasTransparentObject(){return!!(this.savedMaterialsForOpacity&&this.savedMaterialsForOpacity.length>0)}getIntersections(e){if(!this.raycaster||!this.camera||!this.scene)return[];let t=new be;e&&(t=cn.getScreenPointByEvent(e,this.containerOrCanvas));let n=cn.screenPoint2NdcPoint(t,this.camera,this.containerOrCanvas);this.raycaster.setFromCamera(n,this.camera);let i=[];return this.loadedModels.forEach((e=>{let t=e.object;t&&t.visible&&i.push(t)})),this.raycaster.intersectObjects(i,!0)||[]}handleMouseClick(e){this.raycaster&&this.raycaster.layers.set(12);let t=this.getIntersections(e).find((e=>{let t=e.object;return t.visible&&t instanceof xt})),n=t&&t.object||void 0;n&&this.selectedObject&&this.selectedObject.id===n.id&&(n=void 0),n?this.selectObject(n):this.clearSelection()}selectObject(e){if(this.selectedObject){let e=this.selectedObject.userData;if(e.originalMaterial){if(this.selectedObject.material){let e=this.selectedObject.material;Array.isArray(e)?e.forEach((e=>e.dispose())):e instanceof yr&&e.dispose()}this.selectedObject.material=e.originalMaterial,delete e.originalMaterial}this.selectedObject=void 0}if(!this.scene||!e)return;let t=es.clonedHighlightMaterials(e);t&&(this.selectedObject=e,this.selectedObject.userData.originalMaterial=this.selectedObject.material,this.selectedObject.material=t)}clearSelection(){this.selectObject()}flyToObjects(e){if(!e||0===e.length||!this.camera)return;let t=new Ot;e.forEach((e=>{let n=ks.getBoundingBox(e);t.union(n)}));let n=new vr;t.getBoundingSphere(n),this.controls.fitToSphere(n,!0)}flyToObject(e){this.flyToObjects([e])}flyToSelectedObject(){this.selectedObject&&this.flyToObject(this.selectedObject)}flyTo(e,t,n){var i;let r=this.camera,a=this.controls;if(!r||!a)return;let s=e=Array.isArray(e)?new O(e[0],e[1],e[2]):e,o=t=Array.isArray(t)?new O(t[0],t[1],t[2]):t;se.info("[Viewer] flyTo: ",Mt.vectorToString(s)),a.setPosition(s.x,s.y,s.z),a.setTarget(o.x,o.y,o.z),this.isBrowserMode()||null==(i=this.renderer)||i.render(this.scene,r),n&&n()}goToHomeView(){let e=new vr;this.bbox.getBoundingSphere(e),this.controls.fitToSphere(e,!0)}setEnvironmentFromDataArray(e){Cc.createEnvTextureFromDataArray(this.pmremGenerator,e).then((e=>{this.scene.environment=e,this.isBrowserMode()||this.animate()}))}tryAdjustCameraNearAndFar(){let e=this.camera;if(!this.scene||!e)return;let t=this.bbox,n=e.near,i=e.far,r=t.max.x-t.min.x,a=t.max.y-t.min.y,s=t.max.z-t.min.z,o=Math.max(r,a,s),l=o/5,h=5*o;if(n>l||iMt.numberToString(e);se.info(`[Viewer] BBox's longest side is: ${t(o)}`),n>l&&(se.warn(`[Viewer] camera.near(${t(n)}) shouldn't bigger than ${t(l)}, will change it!`),e.near=l),i0?void 0:this.transparentObjectIds,n=this.transparentObjectIds.length>0?this.transparentObjectIds:void 0,i=new on({color:16777215,transparent:!0,opacity:.1});this.loadedModels.forEach((e=>{Hn.applyMaterialToObjectById(this.scene,e.object.id,i,n,t)})),this.outlineRoot.clear();let r=[];if(e.forEach((e=>{let t=e.modelId,n=this.loadedModels.find((e=>e.modelId===t)),i=null==n?void 0:n.object;i||(se.warn(`[Viewer] The ModelId of ${t} has no corresponding model.`),i=this.scene),i.traverse((t=>{if((0,p2.includes)(e.id,(0,p2.get)(t.userData,"UniqueId"))){let e=this.getMeshes(t);r=r.concat(e)}}))})),r.length>0){r.forEach((e=>{let t=Hn.createOutline(e.geometry,this.outlineMaterial);t.applyMatrix4(e.matrixWorld),this.outlineRoot.add(t),t.updateWorldMatrix(!0,!1)}));let e=r.map((e=>e.id));this.loadedModels.forEach((t=>{Hn.revertAppliedMaterialToObjectById(this.scene,t.object.id,e)})),this.transparentObjectIds=e,this.flyToObjects(r)}else se.warn(`[Viewer] No object found with uniqueIds: ${e.map((e=>e.id))}`);this.isBrowserMode()||this.animate()}increaseJobCount(){++this.jobCount}decreaseJobCount(){--this.jobCount}computeBoundingBox(){let e=new Ot;return this.loadedModels.forEach((t=>{t.bbox&&!t.bbox.isEmpty()&&e.union(t.bbox)})),this.bbox=e,e}getContext(){var e;return null==(e=this.renderer)?void 0:e.getContext()}getCameraDirection(){var e;let t=new O;return null==(e=this.camera)||e.getWorldDirection(t),{x:t.x,y:t.y,z:t.z}}setFov(e){this.camera&&(this.camera.fov=e,this.camera.updateProjectionMatrix())}},Wve=new O,zvt=new dr,jve=new O,cg=class extends an{constructor(e=document.createElement("div")){super(),this.isCSS3DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.addEventListener("removed",(function(){this.traverse((function(e){e.element instanceof Element&&null!==e.element.parentNode&&e.element.parentNode.removeChild(e.element)}))}))}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this}},ih=new et,Gvt=new et,m2=class{constructor(e={}){let t,n,i,r,a=this,s={camera:{fov:0,style:""},objects:new WeakMap},o=void 0!==e.element?e.element:document.createElement("div");o.style.overflow="hidden",this.domElement=o;let l=document.createElement("div");l.style.transformOrigin="0 0",l.style.pointerEvents="none",o.appendChild(l);let h=document.createElement("div");function c(e){return Math.abs(e)<1e-10?0:e}function u(e){let t=e.elements;return"matrix3d("+c(t[0])+","+c(-t[1])+","+c(t[2])+","+c(t[3])+","+c(t[4])+","+c(-t[5])+","+c(t[6])+","+c(t[7])+","+c(t[8])+","+c(-t[9])+","+c(t[10])+","+c(t[11])+","+c(t[12])+","+c(-t[13])+","+c(t[14])+","+c(t[15])+")"}function d(e){let t=e.elements;return"translate(-50%,-50%)matrix3d("+c(t[0])+","+c(t[1])+","+c(t[2])+","+c(t[3])+","+c(-t[4])+","+c(-t[5])+","+c(-t[6])+","+c(-t[7])+","+c(t[8])+","+c(t[9])+","+c(t[10])+","+c(t[11])+","+c(t[12])+","+c(t[13])+","+c(t[14])+","+c(t[15])+")"}function p(e,t,n,i){if(e.isCSS3DObject){let i=!0===e.visible&&!0===e.layers.test(n.layers);if(e.element.style.display=!0===i?"":"none",!0===i){let i;e.onBeforeRender(a,t,n),e.isCSS3DSprite?(ih.copy(n.matrixWorldInverse),ih.transpose(),0!==e.rotation2D&&ih.multiply(Gvt.makeRotationZ(e.rotation2D)),e.matrixWorld.decompose(Wve,zvt,jve),ih.setPosition(Wve),ih.scale(jve),ih.elements[3]=0,ih.elements[7]=0,ih.elements[11]=0,ih.elements[15]=1,i=d(ih)):i=d(e.matrixWorld);let r=e.element,o=s.objects.get(e);if(void 0===o||o.style!==i){r.style.transform=i;let t={style:i};s.objects.set(e,t)}r.parentNode!==h&&h.appendChild(r),e.onAfterRender(a,t,n)}}for(let r=0,a=e.children.length;r0))return void(this.visible=!0);t.forEach((e=>e.opacity=0));let n=1/(e/10);this.visible=!0,this.clearFading(),this.renderOrder+=1,this.fadingInInterval=setInterval((()=>{let e=1,i=this.getMaterials();this.materialEquals(t,i)||(t=i),t.length>0&&(e=Math.min(t[0].opacity+n,1),t.forEach((t=>t.opacity=e))),e>=1&&this.clearFading()}),10)}materialEquals(e,t){return Xve.default.isEqualWith(e,t,((e,t)=>{if(!Array.isArray(e)||!Array.isArray(t))return e.id===t.id}))}fadeOut(e=1e3){let t=this.getMaterials(),n=1/(e/10),i=1/(e/10);this.clearFading(),this.scale.set(2,2,2),this.fadingOutInterval=setInterval((()=>{let e=this.scale.x+i;this.scale.set(e,e,e);let r=0;t.length>0&&(r=Math.max(t[0].opacity-n,0),t.forEach((e=>e.opacity=r))),(r<=0||e>=3)&&this.clearFading()}),10)}clearFading(){let e=this.getMaterials();this.fadingInInterval&&(clearInterval(this.fadingInInterval),this.fadingInInterval=void 0,this.visible=!0,e.forEach((e=>e.opacity=1)),this.renderOrder-=1),this.fadingOutInterval&&(clearInterval(this.fadingOutInterval),this.fadingOutInterval=void 0,this.visible=!1,e.forEach((e=>e.opacity=1)),this.scale.set(1,1,1))}getMaterials(){let e=this.thumbnailMesh;e||(e=this.mesh);let t=[];return Array.isArray(e.material)?t.push(...e.material):e.material&&t.push(e.material),t}create(){}createThumbnailMesh(e){return ft(this,null,(function*(){if(!this.thumbnailImages||6!=this.thumbnailImages.length)return;this.thumbnailMesh=new xt(new va(e,e,e)),this.thumbnailMesh.geometry.scale(1,1,-1);let t=(yield this.loadTexturesAsync(this.thumbnailImages)).map((e=>new on({map:e,side:pi,transparent:!0})));this.thumbnailMesh&&(this.thumbnailMesh.material=t,this.add(this.thumbnailMesh))}))}loadTextures(e){return e.map((e=>{let t=this.textureLoader.load(e);return t.colorSpace=tn,t}))}loadTexturesAsync(e){return ft(this,null,(function*(){let t=e.map((e=>this.textureLoader.loadAsync(e))),n=yield Promise.all(t);return n.forEach((e=>e.colorSpace=tn)),n}))}destroyMesh(e){var t;this.remove(e),e.clear(),e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach((e=>{var t;null==(t=e.map)||t.dispose(),e.dispose()})):(null==(t=e.material.map)||t.dispose(),e.material.dispose())}destroy(){this.clearFading(),this.images=[],this.mesh&&(this.mesh instanceof xt?this.destroyMesh(this.mesh):this.mesh.traverse((e=>{e instanceof xt&&this.destroyMesh(e)})),this.mesh=void 0)}},g2=class extends sp{constructor(e,t,n=200){if(super(e,t,n),6!==e.length)throw new Error(`[VRCube] Wrong number of images! Expected 6, got ${e.length}`)}create(){return ft(this,null,(function*(){yield this.createThumbnailMesh(this.size),this.thumbnailMesh?this.updateMesh():yield this.createMesh()}))}updateMesh(){let e=this.thumbnailMesh,t=this.thumbnailImages.length;this.images.forEach(((n,i)=>ft(this,null,(function*(){let r=yield this.loadTexturesAsync([n]);e.material[i].map=r[0],t--,0===t&&(this.thumbnailImages=void 0)})))),this.destroyMesh(this.mesh),this.mesh=void 0}createMesh(){return ft(this,null,(function*(){let e=this.mesh;e.geometry=new va(this.size,this.size,this.size),e.geometry.scale(1,1,-1);let t=(yield this.loadTexturesAsync(this.images)).map((e=>new on({map:e,side:pi,transparent:!0})));e.material=t,this.add(e),this.thumbnailMesh&&(this.destroyMesh(this.thumbnailMesh),this.thumbnailMesh=void 0,this.thumbnailImages=void 0)}))}},v2=class extends sp{constructor(e,t,n=200){if(super(e,t,n),24!==e.length)throw new Error(`[VRCube24Faces] Wrong number of images! Expected 24, got ${e.length}`);this.ratio=1,this.subPlaneWidth0=this.size*(this.ratio/(this.ratio+1)),this.subPlaneWidth1=this.size-this.subPlaneWidth0}create(){return ft(this,null,(function*(){yield this.createThumbnailMesh(this.size+.1),this.thumbnailMesh?this.createMesh():yield this.createMesh()}))}createMesh(){return ft(this,null,(function*(){var e;this.mesh=new er,this.mesh.scale.set(1,1,-1);let t=(yield this.loadTexturesAsync(this.images)).map((e=>new on({map:e,side:Ki,transparent:!0})));if(24!==t.length)throw new Error(`[VRCube24Faces] Wrong number of materials! Expected 24, got ${t.length}`);let n=this.createPlaneOfAFace(t.slice(0,4));n.rotateOnAxis(new O(0,1,0),-Math.PI/2),n.position.set(this.size/2,0,0);let i=this.createPlaneOfAFace(t.slice(4,8));i.rotateOnAxis(new O(0,1,0),Math.PI/2),i.position.set(-this.size/2,0,0);let r=this.createPlaneOfAFace(t.slice(8,12));r.rotateOnAxis(new O(1,0,0),-Math.PI/2),r.rotateOnAxis(new O(0,0,1),Math.PI),r.rotateOnAxis(new O(1,0,0),Math.PI),r.position.set(0,this.size/2,0);let a=this.createPlaneOfAFace(t.slice(12,16));a.rotateOnAxis(new O(1,0,0),Math.PI/2),a.rotateOnAxis(new O(0,0,1),Math.PI),a.rotateOnAxis(new O(1,0,0),Math.PI),a.position.set(0,-this.size/2,0);let s=this.createPlaneOfAFace(t.slice(16,20));s.rotateOnAxis(new O(0,1,0),Math.PI),s.position.set(0,0,this.size/2),this.createPlaneOfAFace(t.slice(20,24)).position.set(0,0,-this.size/2),this.add(this.mesh),this.thumbnailMesh&&(this.destroyMesh(this.thumbnailMesh),this.remove(this.thumbnailMesh),null==(e=this.thumbnailMesh)||e.clear(),this.thumbnailMesh=void 0)}))}createPlaneOfAFace(e){var t;let n=new er,i=new ui(this.subPlaneWidth0,this.subPlaneWidth0),r=new ui(this.subPlaneWidth1,this.subPlaneWidth0),a=new ui(this.subPlaneWidth0,this.subPlaneWidth1),s=new ui(this.subPlaneWidth1,this.subPlaneWidth1),o=new xt(i,e[0]),l=new xt(r,e[1]),h=new xt(a,e[2]),c=new xt(s,e[3]);return o.position.set(this.subPlaneWidth1/2,this.subPlaneWidth1/2,0),l.position.set(-this.subPlaneWidth0/2,this.subPlaneWidth1/2,0),h.position.set(this.subPlaneWidth1/2,-this.subPlaneWidth0/2,0),c.position.set(-this.subPlaneWidth0/2,-this.subPlaneWidth0/2,0),o.geometry.scale(-1,1,1),l.geometry.scale(-1,1,1),h.geometry.scale(-1,1,1),c.geometry.scale(-1,1,1),n.add(o,l,h,c),null==(t=this.mesh)||t.add(n),n}},y2=class extends sp{constructor(e,t,n=100){if(super(e,t,n),1!==e.length)throw new Error(`[VRSphere] Wrong number of images! Expected 1, got ${e.length}`)}create(){return ft(this,null,(function*(){yield this.createThumbnailMesh(this.size+.1),this.thumbnailMesh?this.createMesh():yield this.createMesh()}))}createMesh(){return ft(this,null,(function*(){var e;let t=this.mesh;t.geometry=new za(this.size,100,100),t.geometry.scale(-1,1,1);let n=(yield this.loadTexturesAsync(this.images)).map((e=>new on({map:e,side:pi,transparent:!0})));t.material=n[0],this.add(t),this.thumbnailMesh&&(this.destroyMesh(this.thumbnailMesh),this.remove(this.thumbnailMesh),null==(e=this.thumbnailMesh)||e.clear(),this.thumbnailMesh=void 0)}))}},Yve=class extends Zf{constructor(e,t){super(e),this.name="VRViewer",this.timer=Date.now(),this.loadedModels=[],this.minFov=50,this.maxFov=95,this.raycaster=new ia,this.autoRotate=!0,this.events=[],this.isMousePressing=!1,this.settings=Gv,this.viewpoints=[],this.activeViewpointId="",this.activePanoramaId="",this.viewpointAssetsMap=new Map,this.loadingPanos=[],this.onResize=()=>{this.viewerContainer&&this.viewerContainer.parentElement&&this.resize(this.viewerContainer.parentElement.clientWidth,this.viewerContainer.parentElement.clientHeight)},this.onMouseWheel=e=>{let t=e.deltaY<0?-5:5;this.updateFov(t)},this.applyOptionsAndAddToScene=(e,t,n,i)=>ft(this,null,(function*(){let r,a=Mt.getUpdateProgressFunc(i),s=Mt.getUpdateSubProgressFunc(70,90,i);if(a(0),se.info(`[Viewer] '${e}' is loaded in ${(Date.now()-this.timer)/1e3}s, adding to scene...`),this.timer=Date.now(),n.matrix&&16===n.matrix.length){let e=new et;e.elements=n.matrix,t.applyMatrix4(e)}if(t.matrixAutoUpdate=!1,t.updateMatrix(),t.traverse((e=>{e.matrixAutoUpdate&&(e.matrixAutoUpdate=!1,e.updateMatrix())})),n.merge&&this.merge(t),a(50),n.merge){let e=Date.now();Yf.createMeshBvhAsync([t],{saveOriginalIndex:!0}),se.info(`[Viewer] Creates mesh bvh cost ${(Date.now()-e)/1e3}s`)}a(60),t.traverse((e=>{e.geometry&&e.layers.enableAll(),e instanceof Ws&&(e.visible=!1)})),a(70),n.edges&&(r=yield Hn.createOutlines(t,void 0,s)),a(90);let o={modelId:this.getUniqueModelId(n.modelId||n.src),object:t,edges:r};this.addModel(o),a(100)})),this.viewerCfg=e,this.cameraCfg=t||{eye:[0,0,0],look:[0,0,0]},this.settings=Gv,this.cameraCfg.near&&(this.settings.camera.near=this.cameraCfg.near),this.cameraCfg.far&&(this.settings.camera.far=this.cameraCfg.far),this.setSpinnerVisibility(++this.jobCount>0),this.init(),this.animate(),this.setSpinnerVisibility(--this.jobCount>0)}init(){this.initSpinner(),this.initScene(),this.initRenderer(),this.initCamera(),this.initControls(),this.initLights(),this.initInputManager(),this.initEvents(),this.initOthers()}initScene(){let e=new _i;e.background=new ct(16777215),e.matrixAutoUpdate=!0,this.scene=e}initRenderer(){var e,t;this.renderer=new Ms({antialias:!0,preserveDrawingBuffer:!1}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),this.renderer.useLegacyLights=!1,this.css2dRenderer=new Nu,this.css2dRenderer.setSize(this.width,this.height),this.css2dRenderer.domElement.style.height="0",this.css2dRenderer.domElement.style.width="0",null==(e=this.viewerContainer)||e.appendChild(this.renderer.domElement),null==(t=this.viewerContainer)||t.appendChild(this.css2dRenderer.domElement)}initCamera(){this.scene&&(this.camera=new ur(75,this.width/this.height,this.settings.camera.near,this.settings.camera.far),this.scene.add(this.camera))}initControls(){if(!this.renderer||!this.camera)return;let e=this.camera,t=this.viewerCfg,n=new JA(e,this.renderer.domElement,!0);n.enabled=!0,n.autoRotate=this.autoRotate,n.autoRotateSpeed=t.autoRotateSpeed||-2,n.enablePan=!1,n.enableZoom=!1,n.enableRotate=!0,n.rotateSpeed=.3,n.minPolarAngle=.05*Math.PI,n.maxPolarAngle=.95*Math.PI,n.listenToKeyEvents(document.body),n.update(),this.controls=n,this.controlsHelper=new nP(e,n),this.controls.controlsHelper=this.controlsHelper,this.autoRotate&&this.controlsHelper.delayAutoRotate(),this.controlsHelper.automaticallyAdjustCameraPosition=!1,this.controls.addEventListener("end",(()=>{this.handleDragEnd&&this.handleDragEnd()}));let i=new O(0,0,0),r=new O(10,0,0);this.setCameraPositionAndDirection(i,r)}onKeyDown(e){return t=>{var n,i;let r=e.camera,a=e.controls;!r||!a||(("ArrowLeft"===t.code||"ArrowRight"===t.code||"ArrowUp"===t.code||"ArrowDown"===t.code)&&(null==(n=this.controlsHelper)||n.startToRotate(t)),null==(i=this.controlsHelper)||i.delayAutoRotate())}}initLights(){if(!this.scene)return;let e=new js(16777215,.3);e.position.set(-2,2,4),this.scene.add(e);let t=new Du(16777215,14540253,2);t.position.set(0,300,0),this.scene.add(t)}initInputManager(){this.viewerContainer&&(this.inputManager=new Jo(this.viewerContainer))}initEvents(){let e=this.renderer,t=this.camera;if(!e||!t)return;let n=!1,i=-1,r=-1;this.addEvent("keydown",this.onKeyDown(this)),this.addEvent("wheel",this.onMouseWheel),this.addEvent("pointerdown",(t=>{var a,s;i=t.x,r=t.y,n=!1,this.isMousePressing=!0,this.autoRotate&&(null==(a=this.controlsHelper)||a.delayAutoRotate()),t.button===jR.LEFT&&(null==(s=t.originalEvent)?void 0:s.target)instanceof HTMLCanvasElement&&(e.domElement.style.cursor="move")})),this.addEvent("pointermove",(e=>{i>=0&&r>=0&&(Math.abs(e.x-i)>5||Math.abs(e.y-r)>5)&&(n=!0)})),this.addEvent("pointerup",(i=>{var r,a,s;this.isMousePressing=!1,this.autoRotate&&(null==(r=this.controlsHelper)||r.delayAutoRotate()),e.domElement.style.cursor="auto";let o=i.button;if(!n&&o===jR.LEFT)if(null!=(a=i.originalEvent)&&a.target&&i.originalEvent.target instanceof HTMLDivElement){let e=Tf.tryFindObjectId(i.originalEvent.target);if(e){let t=null==(s=this.scene)?void 0:s.getObjectById(e);if(t){let e=t.userData.hotpoint;e&&(se.info("[Viewer] Clicked on hotpoint: ",e.hotpointId||e),this.onHotpointClicked&&this.onHotpointClicked(e))}}}else{let e=this.getIntersection(i);if(e){let n=e=>Mt.vectorToString(e),i=e.point,r=i.clone().sub(t.position).normalize();se.info(`[Viewer] Clicked at: ${n(i)},\n Camera position: ${n(t.position)},\n Target direction: ${n(r)}`)}}}))}initOthers(){!this.controls||!this.renderer||!this.camera||(this.renderer.domElement.style.outlineWidth="0")}animate(){var e,t,n;if(this.requestAnimationFrameHandle=requestAnimationFrame(this.animate.bind(this)),this.minFrameInterval>0){let e=Date.now()-this.lastFrameExecuteTime;if(e0&&!this.isMousePressing&&(t.autoRotateRemainingTime-=e,t.autoRotateRemainingTime<=0&&this.controls&&t.startAutoRotate())}}if(this.viewerContainer&&this.viewerContainer){let{width:e,height:t}=this.viewerContainer.getBoundingClientRect();(this.width!==e||this.height!==t)&&this.resize(e,t)}this.controls&&this.controls.update(),this.scene&&this.camera&&(this.dispatchEvent("BeforeRender"),null==(e=this.renderer)||e.render(this.scene,this.camera),null==(t=this.css2dRenderer)||t.render(this.scene,this.camera),null==(n=this.css3dRenderer)||n.render(this.scene,this.camera),this.dispatchEvent("AfterRender")),this.dispatchEvent("OnAnimate")}clearAllCachedPanoramas(){this.handleCameraUpdateInterval(),this.loadingPanos.forEach((e=>{e.creationPromise&&(e.creationPromise.cancel(),e.creationPromise=void 0)})),this.viewpointAssetsMap.forEach((e=>{var t;let n=e.panoramas;for(let i=n.length-1;i>=0;--i){let e=n[i];e.box.destroy(),null==(t=this.scene)||t.remove(e.box)}})),this.loadingPanos=[],this.viewpointAssetsMap.clear(),this.activePanoramaId="",this.activePanoramaId=""}destroy(){var e;this.events.forEach((e=>{var t;return null==(t=this.inputManager)?void 0:t.removeEventListener(e.type,e.func)})),this.events=[],this.clearAllCachedPanoramas(),this.css2dRenderer&&(null==(e=this.viewerContainer)||e.removeChild(this.css2dRenderer.domElement)),super.destroy()}updateFov(e){var t;let n=this.camera;if(!n)return;let i=this.minFov,r=this.maxFov,a=e=>{let t=n.fov+e;t=Math.min(t,r),t=Math.max(t,i),n.fov!==t&&(n.fov=t,n.updateProjectionMatrix())},s=e/20;for(let o=0;o<20;++o)setTimeout((()=>a(s)),5*o);this.autoRotate&&(null==(t=this.controlsHelper)||t.delayAutoRotate())}setMinAndMaxFov(e,t){let n=this.controls;n&&(this.minFov=e,this.maxFov=t,n.minFov=e,n.maxFov=t)}resize(e,t){super.resize(e,t),t>0&&(this.css2dRenderer&&(this.css2dRenderer.setSize(e,t),this.css2dRenderer.domElement.style.height="0",this.css2dRenderer.domElement.style.width="0"),this.css3dRenderer&&this.css3dRenderer.setSize(e,t))}enableAutoRotate(e){this.controls&&(this.autoRotate=e,this.controls.autoRotate=e)}setAutoRotateSpeed(e=1){this.controls&&(this.controls.autoRotateSpeed=e)}setCameraFov(e=75){let t=this.camera;t&&(t.fov=e,t.updateProjectionMatrix())}addEvent(e,t){var n;null==(n=this.inputManager)||n.addEventListener(e,t),this.events.push({type:e,func:t})}setCameraPositionAndDirection(e,t,n){let i,r,a=this.camera,s=this.controls;if(!a||!s)return;i=t?Array.isArray(t)?new O(t[0],t[1],t[2]):new O(t.x,t.y,t.z):s.target.clone().sub(a.position),i.normalize(),r=Array.isArray(e)?new O(e[0],e[1],e[2]):new O(e.x,e.y,e.z);let o=r.clone().addScaledVector(i,.01);this.fianlCameraPosition=r,this.finalCameraTarget=o;let l=(e,t)=>{a.position.set(e.x,e.y,e.z),s.target.set(t.x,t.y,t.z),s.update()};if(!1===n)return this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),void l(r,o);let h=a.position.clone(),c=s.target.clone(),u=500,d=Date.now();this.cameraUpdateInterval&&clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=setInterval((()=>{let e=Date.now()-d;e>u&&(e=u);let t=(e,t,n)=>{let i=e.x+(t.x-e.x)*n,r=e.y+(t.y-e.y)*n,a=e.z+(t.z-e.z)*n;return new O(i,r,a)},n=t(h,r,e/u),i=t(c,o,e/u);l(n,i),e>=u&&(clearInterval(this.cameraUpdateInterval),this.cameraUpdateInterval=void 0)}),10)}getCameraPositionAndDirection(){let e=this.camera;if(!e)return;let t=e.position,n=new O;return e.getWorldDirection(n),{position:{x:t.x,y:t.y,z:t.z},direction:{x:n.x,y:n.y,z:n.z}}}getCameraFov(){let e=this.camera;if(e)return e.fov}setViewpoints(e){this.handleCameraUpdateInterval(),this.viewpointAssetsMap.size>0&&(this.viewpointAssetsMap.forEach((e=>{let t=e.panoramas,n=e.css2dObjects;t.forEach((e=>{var t;e.box.destroy(),null==(t=this.scene)||t.remove(e.box)})),n.forEach((e=>{var t;null==(t=this.scene)||t.remove(e)}))})),this.viewpointAssetsMap.clear()),this.loadingPanos.forEach((e=>{e.creationPromise&&(e.creationPromise.cancel(),e.creationPromise=void 0)})),this.loadingPanos=[],this.activeViewpointId="",this.activePanoramaId="",this.viewpoints=e}loadModel(e,t){return ft(this,null,(function*(){var n,i;this.timer=Date.now(),this.increaseJobCount();let r=e.modelId||e.src,a=this.translate("ProgressBar.Loading"),s=e=>{var n;null==(n=this.loadingProgressBar)||n.updateProgress(r,a,e),t&&t(new ProgressEvent("LoadProgress",{loaded:e,total:100}))},o=(e,n,i)=>{var s;let o=100*e.loaded/e.total;o=o*(i-n)/100+n,null==(s=this.loadingProgressBar)||s.updateProgress(r,a,o),t&&t(new ProgressEvent("LoadProgress",{loaded:o,total:100}))},l=e=>o(e,0,50),h=e=>o(e,50,99);null==(n=this.loadingProgressBar)||n.addProgressItem(r),s(0);try{let t=yield(new $a).loadModel(e.src,e.fileFormat,l);if(t)return yield this.applyOptionsAndAddToScene(e.src,t,e,h),Promise.resolve()}catch(t){let i=`Error loading ${e.src}`;return se.error(i,t),Promise.reject(i)}finally{this.decreaseJobCount(),s(100),null==(i=this.loadingProgressBar)||i.delayRemoveProgressItem(r)}return Promise.reject()}))}setModelVisibility(e,t){let n=this.loadedModels.find((t=>t.modelId===e)),i=n&&n.object;if(!i)throw new Error(`Failed to find model by modelId '${e}'!`);i.visible=t,this.enableRender()}addModel(e){if(!this.scene||!this.renderer)return;this.increaseJobCount();let t=(new Ot).setFromObject(e.object);e.bbox||(e.bbox=t),this.scene.add(e.object),this.loadedModels.push(e),se.info(`[Viewer] Added '${e.modelId}' to scene in ${(Date.now()-this.timer)/1e3}s`),this.renderer.shadowMap.needsUpdate=!0,this.enableRender(),this.dispatchEvent("ModelLoaded",{modelId:e.modelId,bbox:t}),this.decreaseJobCount()}addPanorama(e,t){let n=this.viewpoints.find((t=>t.id===e));if(!n)throw new Error(`[Viewer] Failed to find viewpoint by id '${e}'`);n.panoramas||(n.panoramas=[]),n.panoramas.push(t)}findPanorama(e,t){let n=this.viewpoints.find((t=>t.id===e));if(n&&n.panoramas)return n.panoramas.find((e=>e.id===t))}setHotpointsVisibility(e,t="",n=[]){if(!this.viewpoints)return;let i=t=>{var i;let r=this.viewpointAssetsMap.get(t.id),a=(null==r?void 0:r.css2dObjects)||[];null==(i=t.hotpoints)||i.forEach((i=>{if(n&&n.length>0){if(-1===n.findIndex((e=>e===i.hotpointId)))return;if(i.visible=e,this.activeViewpointId===t.id){let t=a.find((e=>e.userData.hotpoint.hotpointId===i.hotpointId));t&&(t.visible=e)}}else i.visible=e,this.activeViewpointId===t.id&&a.forEach((t=>t.visible=e))}))};if(t){let e=this.viewpoints.find((e=>e.id===t));e&&i(e)}else this.viewpoints.forEach((e=>i(e)))}addHotpoints(e){if(!this.activeViewpointId||!e)return;let t=this.viewpoints.find((e=>e.id===this.activeViewpointId)),n=this.viewpointAssetsMap.get(this.activeViewpointId);!t||!n||(t.hotpoints||(t.hotpoints=[]),e.forEach((e=>{var i,r;if(-1!==(null==(i=t.hotpoints)?void 0:i.findIndex((t=>t.hotpointId===e.hotpointId))))return void se.warn(`[Viewer] Duplicated hotpointId: ${e.hotpointId}`);let a=t.position||[0,0,0],s=e.anchorPosition,o=Tf.createHotpoint(e.html),l=new O(s[0],s[1],s[2]),h=new O(a[0],a[1],a[2]);this.relocateAnchorIfTooCloseToCamera(o,l,h),o.visible=!1!==e.visible,o.userData.hotpoint=e,n.css2dObjects.push(o),null==(r=this.scene)||r.add(o),t.hotpoints.push(e)})))}removeHotpoints(e){if(!this.activeViewpointId||!e)return;let t=this.viewpoints.find((e=>e.id===this.activeViewpointId)),n=this.viewpointAssetsMap.get(this.activeViewpointId);!t||!n||e.forEach((e=>{var i,r;if(t.hotpoints)for(let n=t.hotpoints.length-1;n>=0;--n)e===t.hotpoints[n].hotpointId&&t.hotpoints.splice(n,1);for(let t=n.css2dObjects.length-1;t>=0;--t){let a=n.css2dObjects[t];e===(null==(i=a.userData.hotpoint)?void 0:i.hotpointId)&&(n.css2dObjects.splice(t,1),null==(r=this.scene)||r.remove(a))}}))}activeViewpointById(e,t,n,i){this.activatePanoramaById(e,"",!0,t,n,i)}activatePanoramaById(e,t,n=!0,i,r,a){if(e===this.activeViewpointId&&t===this.activePanoramaId)return;let s=this.viewpoints.find((t=>t.id===e));s&&this.activatePanorama(s,t,n,i,r,a)}removeCachedPanoramas(e={}){this.viewpointAssetsMap.forEach(((t,n)=>{var i;let r=t.panoramas;for(let a=r.length-1;a>=0;--a){let t=r[a];if(n===this.activeViewpointId&&t.id===this.activePanoramaId||e[n]&&e[n].includes(t.id))return;t.box.destroy(),null==(i=this.scene)||i.remove(t.box),r.splice(a,1)}}))}unlimitControlsAndShowAssets(e=!1){if(this.controls){let e=this.controls;e.enablePan=!0,e.enableZoom=!0}this.viewpointAssetsMap.forEach((t=>{t.panoramas.forEach((e=>{e.box.visible=!0})),e&&t.css2dObjects.forEach((e=>{e.visible=!0}))}))}relocateAnchorIfTooCloseToCamera(e,t,n){let i=this.camera;if(!i)return se.error("[Viewer] Camera is not initialized"),void e.position.set(t.x,t.y,t.z);let r,a=Math.abs(t.distanceTo(n));if(a{let i=e.panoramas.find((e=>e.id===t)),r=null==i?void 0:i.box;r&&(n?this.fadeIn(r):this.fadeOut(r))},c=(e,t)=>{e.css2dObjects.forEach((e=>{t?!1!==e.userData.hotpoint.visible&&(e.visible=t):e.visible=t}))},u=()=>{var t;let r=new O(0,0,0),a=new O(1,0,0),s=null==(t=this.getCameraPositionAndDirection())?void 0:t.direction;s&&a.set(s.x,s.y,s.z);let o=e.position;if(o&&3===o.length&&r.set(o[0],o[1],o[2]),n){let t=e.initialDirection;t&&3===t.length&&a.set(t[0],t[1],t[2])}this.setCameraPositionAndDirection(r,a,i)};!t&&(null==(s=e.panoramas)?void 0:s.length)>0&&(t=e.panoramas[0].id||""),this.handleCameraUpdateInterval();let d=this.viewpointAssetsMap.get(this.activeViewpointId),p=this.viewpointAssetsMap.get(e.id);if(this.activeViewpointId&&d&&(this.activeViewpointId!==e.id&&c(d,!1),h(d,this.activePanoramaId,!1)),p&&p.panoramas.find((e=>e.id===t)))return h(p,t,!0),this.activeViewpointId!==e.id&&c(p,!0),this.activeViewpointId!==e.id&&u(),this.activeViewpointId=e.id,this.activePanoramaId=t,void(r&&r(e));this.activeViewpointId=e.id,this.activePanoramaId=t;try{if(this.loadingPanos.some((n=>n.viewpointId===e.id&&n.panoramaId===t)))return void se.warn(`[Viewer] Panorama with viewpointId=${e.id} and panoramaId=${t} is being created`);let n=new _A(this.createBoxByImageOrImages(e,t));this.loadingPanos.push({viewpointId:e.id,panoramaId:t,creationPromise:n});let i=yield n.promise;this.loadingPanos=this.loadingPanos.filter((n=>n.viewpointId!==e.id||n.panoramaId!==t));let a=e.position;a&&3===a.length&&i.position.set(a[0],a[1],a[2]),this.activeViewpointId===e.id&&this.activePanoramaId===t?(this.fadeIn(i),null==(o=this.scene)||o.add(i),u()):(i.visible=!1,null==(l=this.scene)||l.add(i));let s={id:t,box:i},h=this.viewpointAssetsMap.get(e.id);if(h)h.panoramas.push(s),c(h,!0);else{let n=[];e.hotpoints&&e.hotpoints.forEach((r=>{let a=r.anchorPosition,s=Tf.createHotpoint(r.html);s.visible=!1!==r.visible,s.userData.hotpoint=r;let o=new O(a[0],a[1],a[2]);this.relocateAnchorIfTooCloseToCamera(s,o,i.position),(this.activeViewpointId!==e.id||this.activePanoramaId!==t)&&(s.visible=!1),n.push(s)}));let r={panoramas:[s],css2dObjects:n};this.viewpointAssetsMap.set(e.id,r),n.forEach((e=>{var t;return null==(t=this.scene)?void 0:t.add(e)}))}r&&r(e)}catch(e){"cancel"!==e.type&&a&&a(e)}}))}createBoxByImageOrImages(e,t){var n;let i=e.imageOrImages,r=e.thumbnailImages;if((null==(n=e.panoramas)?void 0:n.length)>0){let n=this.findPanorama(e.id,t);n||(n=e.panoramas[0],se.warn(`[Viewer] Failed to find panorama by id '${t}', will use the first one`)),i=n.images,r=n.thumbnails}if(!i)throw new Error("[Viewer] Invalid images!");if(Array.isArray(i)||(i=[i]),1===i.length)return this.createBoxByImage(i,r);if(6===i.length)return this.createBoxBy6Images(i,r);if(24===i.length)return this.createBoxBy24Images(i,r);throw new Error(`[Viewer] Wrong number of images! Expected 1/6/24, got ${i.length}`)}createBoxByImage(e,t){return ft(this,null,(function*(){let n=new y2(e,t);return yield n.create(),n}))}createBoxBy6Images(e,t){return ft(this,null,(function*(){if(6!==e.length)throw new Error(`[VRCube] Wrong number of images! Expected 6, got ${e.length}`);let n=new g2(e,t);return yield n.create(),n}))}createBoxBy24Images(e,t){return ft(this,null,(function*(){if(24!==e.length)throw new Error(`[VRCube] Wrong number of images! Expected 24, got ${e.length}`);let n=new v2(e,t);return yield n.create(),n}))}getIntersection(e){if(!this.camera||!this.scene)return;let t=this.viewpointAssetsMap.get(this.activeViewpointId);if(!t)return;let n=t.panoramas.find((e=>e.id===this.activePanoramaId));if(!n)return;let i=n.box,r=this.viewerContainer,a=new be;e&&(a=cn.getScreenPointByEvent(e,r));let s=cn.screenPoint2NdcPoint(a,this.camera,r);this.raycaster.setFromCamera(s,this.camera);let o=[i],l=this.raycaster.intersectObjects(o,!0)||[];return l.length>0?l.find((e=>{let t=e.object;return t.visible&&t instanceof xt})):void 0}fadeIn(e,t=500){e.fadeIn(t)}fadeOut(e,t=1e3){e.fadeOut(t)}handleCameraUpdateInterval(){if(this.cameraUpdateInterval){clearInterval(this.cameraUpdateInterval);let e=this.fianlCameraPosition,t=this.finalCameraTarget;if(e&&t&&this.controls&&this.camera){this.camera.position.set(e.x,e.y,e.z);let n=this.controls;n.target.set(t.x,t.y,t.z),n.update()}this.cameraUpdateInterval=void 0}this.fianlCameraPosition=void 0,this.finalCameraTarget=void 0}getHitResult(e){let t={location:null};if(!this.camera)return t;let n=this.getIntersection(e);return t.location=n?{x:n.point.x,y:n.point.y,z:n.point.z}:null,t}lookToPosition(e){var t;if(!this.camera)return;this.handleCameraUpdateInterval();let n=new O(e[0],e[1],e[2]).clone().sub(this.camera.position);null==(t=this.controlsHelper)||t.lookTo(n)}merge(e){this.increaseJobCount();try{let t=[];e.traverse((e=>{e.geometry&&e.material&&t.push(e)})),Ar.deepMerge(t,e)}finally{this.decreaseJobCount()}}},x2=class extends an{constructor(e=!0,t=!1){super(),this.name="COORDINATE_AXES",this.AXIS_LENGTH=1,this.AXIS_COLOR_X=16711680,this.AXIS_COLOR_Y=65280,this.AXIS_COLOR_Z=255;let n=new O(0,0,0),i=new O(1,0,0),r=new O(0,1,0),a=new Mc(i,n,this.AXIS_LENGTH,this.AXIS_COLOR_X,0,0),s=new Mc(r,n,this.AXIS_LENGTH,this.AXIS_COLOR_Y,0,0);if(this.add(a,s),!t){let e=new O(0,0,1),t=new Mc(e,n,this.AXIS_LENGTH,this.AXIS_COLOR_Z,0,0);this.add(t)}e&&this.addTexts(t)}addTexts(e=!1){let t=this.createText("X","#ff0000"),n=this.createText("Y","#00ff00");if(t.position.set(this.AXIS_LENGTH+.1,0,0),n.position.set(.1,this.AXIS_LENGTH,.1),this.add(t,n),!e){let e=this.createText("Z","#0000ff");e.position.set(0,0,this.AXIS_LENGTH+.1),this.add(e)}}createText(e,t,n=14){let i=document.createElement("div");i.innerHTML=e;let r=i.style;return r.color=t,r.width=`${n}px`,r.height=`${n}px`,r.textAlign="center",r.top="0px",r.left="0px",new zv(i)}},$ve=class extends fr{constructor(e,t){super(e,{id:"AxisGizmoPlugin"}),this.ignoreZAxis=!1,this.cfg=t||{},this.ignoreZAxis=!(null==t||!t.ignoreZAxis),this.hostCamera=e.camera,this.init()}init(){this.initRenderer(),this.initScene(),this.animate(),this.viewer.addEventListener("CameraChanged",(()=>{this.hostCamera=this.viewer.camera}))}initRenderer(){var e;let t,n=100,i=100;if(this.cfg.containerId&&(t=document.getElementById(this.cfg.containerId),t&&(n=t.clientWidth,i=t.clientHeight)),!t){let n="axisGizmo";t=document.createElement("div"),t.id=n,null==(e=this.viewer.widgetContainer)||e.appendChild(t)}this.renderer=new Ms({antialias:!0,alpha:!0}),this.renderer.setSize(n,i),t.appendChild(this.renderer.domElement),this.css2dRenderer=new Nu,this.css2dRenderer.setSize(n,i),this.css2dRenderer.domElement.style.height="0",this.css2dRenderer.domElement.style.width="0",t.appendChild(this.css2dRenderer.domElement)}initScene(){this.scene=new _i,this.camera=new Ur(-1,1,1,-1,.1,100),this.scene.add(this.camera),this.coordinateAxes=new x2(!0,this.ignoreZAxis),this.scene.add(this.coordinateAxes)}setHostCamera(e){this.hostCamera=e}render(){var e;!this.scene||!this.camera||(this.renderer&&(this.update(),this.renderer.render(this.scene,this.camera)),null==(e=this.css2dRenderer)||e.render(this.scene,this.camera))}animate(){requestAnimationFrame(this.animate.bind(this)),this.render()}update(){if(!this.hostCamera)return;let e=this.hostCamera;if(e){let t=new O;e.getWorldDirection(t);let n=e.up;this.updateCameraDirection(t,n)}}updateCameraDirection(e,t){if(!this.camera||!e)return;e.normalize();let n=.3;this.camera.position.set(2*-e.x+n,2*-e.y+n,2*-e.z+n),this.camera.lookAt(n,n,n),this.camera.up=t}destroy(){var e,t;super.destroy(),this.scene&&this.camera&&this.coordinateAxes&&(this.scene.clear(),this.scene=void 0,this.css2dRenderer&&(null==(e=this.container)||e.removeChild(this.css2dRenderer.domElement),this.css2dRenderer=void 0),this.renderer&&(null==(t=this.container)||t.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer=void 0),this.hostCamera=void 0,this.camera=void 0,this.coordinateAxes=void 0)}},cV=ji(Fl(),1),qvt="bottomBar",Wvt={"gemini-viewer-threejs-statistics":{icon:{default:"icon-info",active:"icon-info-filled",iconFont:"gemini-viewer-icon"},mutexIds:["gemini-viewer-threejs-cameraInfo","gemini-viewer-threejs-tips"],onActive:e=>{let t=document.createElement("span");if(!e.viewer.scene)return void(t.textContent="Failed!");t.textContent="Comupting...";let n={components:{},points:0,faces:0,materials:{},lights:{}},i=["SKYBOX","GROUND_GRID","GROUND_GRASS","BIM_VIEWER_BOX_HELPER"];e.viewer.scene.traverse((e=>{(e instanceof xt||e instanceof hr||e instanceof ii)&&!i.includes(e.name)?((e,t)=>{if(t.components[e.type]?t.components[e.type]++:t.components[e.type]=1,e.geometry){let n=e.geometry;if(e instanceof xt)if(n.index&&n.index.count){let i=Math.round(n.index.count/3);e instanceof Pi&&(i*=e.count),t.faces+=i}else if(n.groups.length>0)for(let e=0;e{t.materials[e]?t.materials[e]++:t.materials[e]=1},i=e.material;i instanceof yr?n(i.id):Array.isArray(i)&&i.forEach((e=>n(e.id)))})(e,n):e instanceof Ws&&(n.lights[e.type]?n.lights[e.type]++:n.lights[e.type]=1)}));let r=(e,n)=>{t.innerHTML+=`

${e}:${n}

`};t.innerHTML="";let a=` (${(e=>{var t;let n=null==(t=e.renderer)?void 0:t.domElement;return null==n?void 0:n.dataset.engine})(e.viewer)})`;r("Version",`${$E}${a}`),r("Components",JSON.stringify(n.components)),r("Points",n.points),r("Faces",n.faces),r("Materials",Object.keys(n.materials).length),r("Lights",JSON.stringify(n.lights)),"DxfViewer"===e.viewer.name&&r("Entities",e.viewer.getEntitiesCount()),e.tooltip.setContent(t),e.tooltip.show()},onDeactive:e=>{e.tooltip.hide()},onUpdate:e=>{let t=e.viewer.renderer,n=document.createElement("span"),i=(e,t)=>{n.innerHTML+=`

${e}:${t}

`};n.innerHTML="

-- Renderer Info --

";let r=null==t?void 0:t.info;i("Drawcalls",JSON.stringify(null==r?void 0:r.render.calls)),i("Points",JSON.stringify(null==r?void 0:r.render.points)),i("Lines",JSON.stringify(null==r?void 0:r.render.lines)),i("Triangles",JSON.stringify(null==r?void 0:r.render.triangles)),i("Geometries",JSON.stringify(null==r?void 0:r.memory.geometries)),i("Textures",JSON.stringify(null==r?void 0:r.memory.textures)),e.tooltip.updateChildContent(n)}},"gemini-viewer-threejs-cameraInfo":{icon:{default:"icon-view",active:"icon-view-filled",iconFont:"gemini-viewer-icon"},mutexIds:["gemini-viewer-threejs-statistics","gemini-viewer-threejs-tips"],onActive:e=>{let t=()=>{if(!e.viewer||!e.viewer.camera||!e.viewer.controls)return;let n=e.viewer.camera,i=e.viewer.controls,r=e=>Mt.numberToString(e),a=e=>Mt.vectorToString(e),s=n.position,o=i instanceof ba?i.getTarget(new O):i.target;if(s){let t=document.createElement("span");t.innerHTML=`\n

Camera position:${a(s)}

\n

Camera target:${a(o)}

`,n instanceof Ur&&(t.innerHTML+=`\n

top: ${r(n.top)}, bottom: ${r(n.bottom)}, left: ${r(n.left)}, right: ${r(n.right)}

\n

zoom: ${r(n.zoom)}

`),e.tooltip.setContent(t)}e.active||window.removeEventListener("mouseup",t)};if(t(),window.addEventListener("mouseup",t),"BimViewer"===e.viewer.name){let n=e.viewer.controls;null==n||n.addEventListener("update",t)}else e.viewer.controls.addEventListener("change",t);e.tooltip.show()},onDeactive:e=>{e.tooltip.hide()}},"gemini-viewer-threejs-tips":{icon:{default:"icon-more",iconFont:"gemini-viewer-icon"},mutexIds:["gemini-viewer-threejs-cameraInfo","gemini-viewer-threejs-cameraInfo"],onActive:e=>{let t=document.createElement("span");"BimViewer"===e.viewer.name?t.innerHTML="\n

W: Move forward

\n

A: Move backward

\n

S: Move left

\n

D: Move right

\n

Q: Rise up

\n

E: Lower down

\n

\u2191: Rotate up

\n

\u2193: Rotate down

\n

\u2190: Rotate to left

\n

\u2192: Rotate to right

\n ":"DxfViewer"===e.viewer.name?t.innerHTML="\n

\u2191: Move up

\n

\u2193: Move down

\n

\u2190: Move to left

\n

\u2192: Move to right

\n ":"VRViewer"===e.viewer.name?t.innerHTML="\n

\u2191: Rotate up

\n

\u2193: Rotate down

\n

\u2190: Rotate to left

\n

\u2192: Rotate to right

\n ":t.innerHTML="\n

Nothing to show

\n ",e.tooltip.setContent(t),e.tooltip.show()},onDeactive:e=>{e.tooltip.hide()}}},Zve=class extends fr{constructor(e){super(e,{id:"BottomBarPlugin"}),this.itemList=new Map,this.init()}update(){this.itemList.forEach((e=>{e.update()}))}init(){var e;let t=document.createElement("div");t.id=qvt,t.classList.add("bottom-bar"),(0,cV.forEach)(Wvt,((e,n)=>{let i=this.createItem(this.viewer,n,e);t.appendChild(i.element)})),this.element=t,null==(e=this.viewer.widgetContainer)||e.appendChild(this.element),this.viewer.addEventListener("AfterRender",(()=>{this.update()}))}createItem(e,t,n){let i=new lV(e,this,t,n);return this.itemList.set(t,i),i}},lV=class{constructor(e,t,n,i){this.viewer=e,this.bottomBar=t,this.menuId=n,this.cfg=i,this.eventBus=Ay(),this.active=!1,this.itemconfig=i,this.element=this.createButton(this.menuId,i),this.tooltip=new Yl(n+"-tooltip",null,{parentNode:e.widgetContainer}),this.eventBus.on("activeChange",(e=>{e?(this.element.classList.add("active"),(0,cV.forEach)(i.mutexIds,(e=>{var t;let n=null==(t=this.bottomBar)?void 0:t.itemList.get(e);n&&n.active&&n.setActive(!1)})),i.onActive&&i.onActive(this)):(this.element.classList.remove("active"),i.onDeactive&&i.onDeactive(this)),this.element instanceof HTMLElement&&SA(this.element.classList,i.icon,this.active)}))}createButton(e,t){let n=document.createElement("i");n.id=e;let{default:i="icon-new",iconFont:r=qv}=t.icon;return n.classList.add("icon"),n.classList.add(r),n.classList.add(i),n.onclick=()=>{this.active=!this.active,t.onClick&&t.onClick(this),this.eventBus.emit("activeChange",this.active)},n}setActive(e){this.active=e,this.eventBus.emit("activeChange",this.active)}update(){this.active&&this.itemconfig.onUpdate&&this.itemconfig.onUpdate(this)}},ug=ji(Fl(),1),k_=ji(Fl(),1),fs=ji(Fl(),1),b2=(e=>(e[e.ClickEvent=1]="ClickEvent",e[e.Popup=2]="Popup",e[e.SubMenu=3]="SubMenu",e[e.Switch=4]="Switch",e))(b2||{}),E2=(e=>(e.HomeView="HomeView",e.OrthoMode="OrthoMode",e.Measure="Measure",e.MeasureDistance="MeasureDistance",e.MeasureArea="MeasureArea",e.MeasureAngle="MeasureAngle",e.MeasureCoordinate="MeasureCoordinate",e.MeasureClear="MeasureClear",e.MarkupVisibility="MarkupVisibility",e.Markup="Markup",e.MarkupArrow="Arrow",e.MarkupRect="Rect",e.MarkupCloudRect="CloudRect",e.MarkupPolyLine="PolyLine",e.MarkupCloudLine="CloudLine",e.MarkupEllipse="Ellipse",e.MarkupCircle="Circle",e.MarkupDot="Dot",e.MarkupText="Text",e.MarkupX="X",e.MarkupStrokeStyle="StrokeStyle",e.MarkupLineWidth="LineWidth",e.MarkupLineWidth2="LineWidth2",e.MarkupLineWidth5="LineWidth5",e.MarkupLineWidth10="LineWidth10",e.MarkupFontSize="FontSize",e.MarkupFontSize14="FontSize14",e.MarkupFontSize18="FontSize18",e.MarkupFontSize24="FontSize24",e.MarkupClear="MarkupClear",e.MarkupQuit="MarkupQuit",e.Section="Section",e.SectionBox="SectionBox",e.SectionPlane="SectionPlane",e.SectionAxis="SectionAxis",e.BimTree="BimTree",e.Viewpoint="Viewpoint",e.Annotation="Annotation",e.Property="Property",e.Settings="Settings",e.Compared="Compared",e.QuitCompare="QuitCompare",e.Fullscreen="FullScreen",e.SceneClear="SceneClear",e.Layers="Layers",e.ZoomToRectangle="ZoomToRectangle",e.Screenshot="GetScreenshot",e))(E2||{}),_2=[["HomeView","OrthoMode","FullScreen","ZoomToRectangle","GetScreenshot"],["Measure","Markup","MarkupVisibility","Section"],["BimTree","Viewpoint","Annotation","Property","Compared","QuitCompare","Layers"],["Settings"]],ap=class{constructor(e,t,n=[]){this.visible=!0,this.menuList=new Map,this.keydown=e=>{var t,n;if(this.visible&&"Escape"===e.code){if(null!=(t=this.viewer.measurePlugin)&&t.isMeasuring()||null!=(n=this.viewer.getMarkupManager())&&n.isMarkupActive())return;this.clearActive()}},this.viewer=e,this.menuCfg=t,this.groupCfg=n,this.init(),window.addEventListener("keydown",this.keydown,!1)}init(){var e;let t=document.createElement("div");t.classList.add("toolbar");let n=this.menuCfg;this.groupCfg.forEach(((e,i)=>{let r=document.createElement("div");r.classList.add("toolbar-group");let a=document.createElement("div");a.classList.add("toolbar-group-division"),e.forEach((e=>{let t=(0,fs.get)(n,e);if(t&&!1!==t.visible){let n=this.createToolbarMenu(this.viewer,e,t);r.appendChild(n.element)}})),r.hasChildNodes()&&(i&&t.appendChild(a),t.appendChild(r))})),this.element=t,null==(e=this.viewer.widgetContainer)||e.appendChild(t),t.oncontextmenu=e=>{e.preventDefault()}}clearActive(){if(this.activateMenuId){let e=this.menuList.get(this.activateMenuId);null==e||e.setActive(!1),this.activateMenuId=void 0}}setActive(e,t){let n=this.menuList.get(e);null==n||n.setActive(t),this.activateMenuId=t?e:void 0}createToolbarMenu(e,t,n,i){let r=new uV(e,this,t,n,i);if(this.menuList.set(t,r),n.children){let t=document.createElement("div");t.classList.add("toolbar-sub-menu");let i=document.createElement("div");i.classList.add("toolbar-sub-menu-list"),t.appendChild(i),(0,fs.forIn)(n.children,((t,n)=>{if(t&&!1!==t.visible){let a=this.createToolbarMenu(e,n,t,r);i.appendChild(a.element)}})),r.element.appendChild(t)}return r}updateMenu(e,t){(0,fs.assign)(this.menuCfg[e],t),this.refresh()}updateMenus(e){(0,fs.forEach)(e,(({menuId:e,config:t})=>{(0,fs.assign)(this.menuCfg[e],t)})),this.refresh()}addMenu(e,t,n){if((0,fs.keys)(this.menuCfg).includes(e))se.error("[Toolbar]",e,"exists.");else{if((0,fs.assign)(this.menuCfg,{[e]:t}),n){let[t,i]=n;if(t>this.groupCfg.length-1)this.groupCfg=(0,fs.concat)(this.groupCfg,[[e]]);else{let n=this.groupCfg[t];this.groupCfg[t]=i>n.length-1?(0,fs.concat)(n,e):(0,fs.concat)((0,fs.take)(n,i),e,(0,fs.takeRight)(n,n.length-i))}}else this.groupCfg=(0,fs.concat)(this.groupCfg,[[e]]);this.refresh()}}refresh(){this.element&&this.element.remove(),this.element=void 0,this.menuList.clear(),this.init()}show(){this.element&&(this.element.style.display=""),this.visible=!0}hide(){this.element&&(this.element.style.display="none"),this.visible=!1}destroy(){this.element&&this.element.remove(),this.element=void 0,this.menuList.clear(),window.removeEventListener("keydown",this.keydown,!1)}},uV=class{constructor(e,t,n,i,r){this.eventBus=Ay(),this.toolbar=t,this.menuId=n,this.active=i.defaultActive||!1,this.element=i.customElement&&i.customElement(e,this.menuId,i)||this.createButton(e,this.menuId,i),this.eventBus.on("activeChange",(t=>{t?(this.element.classList.add("active"),(0,fs.forEach)(i.mutexIds,(e=>{var t;let n=null==(t=this.toolbar)?void 0:t.menuList.get(e);n&&n.active&&n.setActive(!1)})),i.onActive&&i.onActive(e)):(this.element.classList.remove("active"),i.onDeactive&&i.onDeactive(e)),this.element.firstChild instanceof HTMLElement&&SA(this.element.firstChild.classList,i.icon,this.active),r&&r.setActive(t)})),Dn.isMobile?(this.element.ontouchstart=t=>{switch(this.element.classList.toggle("toolbar-parent-menu-active"),this.element.classList.toggle("toolbar-menu-active"),t.stopPropagation(),i.type){case 1:i.onClick&&i.onClick(e,this.toolbar,t);break;case 4:i.onClick&&i.onClick(e,this.toolbar,t),this.active=!this.active,this.toolbar.activateMenuId=this.menuId,this.eventBus.emit("activeChange",this.active)}},this.element.addEventListener("touchend",(()=>{r&&r.element.classList.remove("toolbar-parent-menu-active")}))):(this.element.onclick=t=>{switch(t.stopPropagation(),i.type){case 1:i.onClick&&i.onClick(e,this.toolbar,t);break;case 4:i.onClick&&i.onClick(e,this.toolbar,t),this.active=!this.active,this.toolbar.activateMenuId=this.menuId,this.eventBus.emit("activeChange",this.active)}r&&r.element.classList.remove("toolbar-parent-menu-active")},this.element.addEventListener("mouseover",(()=>{this.element.classList.toggle("toolbar-parent-menu-active"),this.element.classList.add("toolbar-menu-active")})),this.element.addEventListener("mouseout",(()=>{this.element.classList.contains("toolbar-parent-menu-active")&&this.element.classList.remove("toolbar-parent-menu-active"),this.element.classList.remove("toolbar-menu-active")})))}createButton(e,t,n){let i=document.createElement("div");i.id=t,i.classList.add("toolbar-menu"),n.defaultActive&&i.classList.add("active"),n.children&&i.classList.add("toolbar-parent-menu");let{default:r="icon-new",iconFont:a=qv}=n.icon;return i.innerHTML=`
`,i.title=eh(n.menuName),i.innerHTML+=`${i.title}`,i}setActive(e){this.active=e,e?this.element.classList.add("toolbar-menu-active"):this.element.classList.remove("toolbar-menu-active"),this.eventBus.emit("activeChange",this.active)}},Kve={Arrow:{menuName:"Toolbar.markupArrow",icon:{default:"icon-arrow"},type:4,onActive:e=>{e.activateMarkup("ArrowMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","CloudLine","Ellipse","Circle","Dot","Text","X"]},Rect:{defaultActive:!1,menuName:"Toolbar.markupRect",icon:{default:"icon-rectangle"},type:4,onActive:e=>{e.activateMarkup("RectMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Arrow","CloudRect","PolyLine","CloudLine","Ellipse","Circle","Dot","Text","X"]},CloudRect:{defaultActive:!0,menuName:"Toolbar.markupCloudRect",icon:{default:"icon-cloud"},type:4,onActive:e=>{e.activateMarkup("CloudRectWithTextMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","Arrow","PolyLine","CloudLine","Ellipse","Circle","Dot","Text","X"]},PolyLine:{menuName:"Toolbar.markupPolyLine",icon:{default:"icon-polyline"},type:4,onActive:e=>{e.activateMarkup("PolylineMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","Arrow","CloudRect","CloudLine","Ellipse","Circle","Dot","Text","X"]},CloudLine:{menuName:"Toolbar.markupCloudLine",icon:{default:"icon-cloud-segment"},type:4,onActive:e=>{e.activateMarkup("CloudLineMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","Arrow","Ellipse","Circle","Dot","Text","X"]},Ellipse:{menuName:"Toolbar.markupEllipse",icon:{default:"icon-oval"},type:4,onActive:e=>{e.activateMarkup("EllipseMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","CloudLine","Arrow","Circle","Dot","Text","X"]},Circle:{menuName:"Toolbar.markupCircle",icon:{default:"icon-round"},type:4,onActive:e=>{e.activateMarkup("CircleMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","CloudLine","Ellipse","Arrow","Dot","Text","X"]},Dot:{menuName:"Toolbar.markupDot",icon:{default:"icon-round"},type:4,onActive:e=>{e.activateMarkup("DotMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","CloudLine","Ellipse","Arrow","Circle","Text","X"]},X:{menuName:"Toolbar.markupX",icon:{default:"icon-cross"},type:4,onActive:e=>{e.activateMarkup("XMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","CloudLine","Ellipse","Circle","Dot","Arrow","Text"]},Text:{menuName:"Toolbar.markupText",icon:{default:"icon-text"},type:4,onActive:e=>{e.activateMarkup("TextMarkup")},onDeactive(e){e.deactivateMarkup()},mutexIds:["Rect","CloudRect","PolyLine","CloudLine","Ellipse","Circle","Dot","Arrow","X"]},StrokeStyle:{menuName:"Toolbar.markupStroke",icon:{default:"icon-color-red"},type:1,onClick:(e,t,n)=>{let i=n.target.parentElement,r=null==i?void 0:i.firstElementChild,a=document.createElement("input");a.setAttribute("type","color"),a.value=Cn.rgba2Color(e.getMarkupLineColor()),a.click(),a.oninput=t=>{let n=t.target.value;e.setMarkupLineColor(...Cn.color2rgba(n)),r.style.color=n}}},LineWidth:{menuName:"Toolbar.markupLineWidth",icon:{default:"icon-line"},customElement(e,t,n){let i=document.createElement("div");return i.id=t,i.classList.add("toolbar-menu"),n.children&&i.classList.add("toolbar-parent-menu"),i.title=eh(n.menuName),i.innerHTML+=`${i.title}`,i},type:3,children:{LineWidth2:{defaultActive:!0,icon:{default:"icon-line-2"},onClick:e=>{e.setMarkupLineWidth(2)},type:4,menuName:"Toolbar.markupLineWidth2",mutexIds:["LineWidth5","LineWidth10"]},LineWidth5:{icon:{default:"icon-line-3"},onClick:e=>{e.setMarkupLineWidth(3)},type:4,menuName:"Toolbar.markupLineWidth5",mutexIds:["LineWidth2","LineWidth10"]},LineWidth10:{icon:{default:"icon-line-4"},onClick:e=>{e.setMarkupLineWidth(4)},type:4,menuName:"Toolbar.markupLineWidth10",mutexIds:["LineWidth2","LineWidth5"]}}},FontSize:{menuName:"Toolbar.markupFontSize",icon:{default:"icon-font"},customElement(e,t,n){let i=document.createElement("div");return i.id=t,i.classList.add("toolbar-menu"),n.children&&i.classList.add("toolbar-parent-menu"),i.title=eh(n.menuName),i.innerHTML+=`${i.title}`,i},type:3,children:{FontSize14:{icon:{default:"icon-font14"},onClick:e=>{e.setMarkupFontSize(14)},type:4,menuName:"",mutexIds:["FontSize18","FontSize24"]},FontSize18:{defaultActive:!0,icon:{default:"icon-font18"},onClick:e=>{e.setMarkupFontSize(18)},type:4,menuName:"",mutexIds:["FontSize14","FontSize24"]},FontSize24:{icon:{default:"icon-font24"},onClick:e=>{e.setMarkupFontSize(24)},type:4,menuName:"",mutexIds:["FontSize14","FontSize18"]}}},MarkupClear:{icon:{default:"icon-eraser"},onClick:e=>{se.info("[Toolbar]","Clear Markup",e),e.clearMarkups()},type:1,menuName:"Toolbar.clearMarkup"},MarkupQuit:{icon:{default:""},customElement(e,t,n){let i=document.createElement("div");return i.id=t,i.classList.add("toolbar-menu"),n.children&&i.classList.add("toolbar-parent-menu"),i.title=eh(n.menuName),i.innerHTML+=`${i.title}`,i},onClick:e=>{var t;null==(t=e.getMarkupManager())||t.deactivate(),e.dispatchEvent("MarkupDeactivated")},type:1,menuName:"Toolbar.quitMarkup"}},Jve=[["Arrow","Rect","CloudRect","PolyLine","Ellipse","Circle","Text","StrokeStyle","FontSize","MarkupClear","MarkupQuit"]],T2=class extends ap{constructor(e,t,n=[]){super(e,t,n),this.keydown=()=>{}}},Wy=class{constructor(e,t,n=document.body){this.container=n,this.isFollowing=!1,this.diffX=0,this.diffY=0,this.start=e=>{this.isFollowing=!0,this.diffX=e.clientX-this.element.offsetLeft,this.diffY=e.clientY-this.element.offsetTop},this.stop=()=>{this.isFollowing=!1},this.follow=e=>{if(!this.isFollowing)return;let t=e.clientX-this.diffX,n=e.clientY-this.diffY;this.element.style.left=t+"px",this.element.style.top=n+"px"},this.element=document.createElement("div"),this.element.id=e,this.element.classList.add("pop-panel");let i=document.createElement("div");i.classList.add("pop-panel-header"),i.append(t),this.element.appendChild(i),this.header=i;let r=document.createElement("div");r.classList.add("pop-panel-body"),this.element.appendChild(r),this.body=r,i.addEventListener(wH,this.start),i.addEventListener(TH,this.stop),document.body.addEventListener(wf,this.follow),this.container.appendChild(this.element)}destroy(){document.body.removeEventListener(wf,this.follow),this.element.removeEventListener(wH,this.start),this.element.removeEventListener(TH,this.stop),this.element.remove()}},w2=class extends Wy{constructor(e){super("axis-section-pop-panel","\u8f74\u5411\u5256\u5207",e.widgetContainer),this.axis="x",this.isVisible=!0,this.keydown=e=>{"Escape"===e.code&&this.destroy()},this.section=e.getActiveSection(),this.createGroupSelectLayout(),this.addGroupSelectItems(),this.createActiveSelectLayout(),this.addActiveItems(),window.addEventListener("keydown",this.keydown)}destroy(){super.destroy(),window.removeEventListener("keydown",this.keydown)}createGroupSelectLayout(){let e=document.createElement("div");e.classList.add("pop-panel-group-select"),this.body.appendChild(e),this.groupSelectNode=e}addGroupSelectItems(){let e=(e,t,n=!1)=>{let i=document.createElement("div");return i.classList.add("pop-panel-item"),i.setAttribute("itemName",e),i.append(t),n&&i.classList.add("active"),this.groupSelectNode&&this.groupSelectNode.appendChild(i),i},t=(e,t)=>a=>{a.stopPropagation(),this.activeItem!==e&&(n.classList.remove("active"),i.classList.remove("active"),r.classList.remove("active"),this.activeItem=e,t.classList.add("active"),this.section.setActiveAxis(e))},n=e("X","X",!0);n.onclick=t("X",n);let i=e("Y","Y");i.onclick=t("Y",i);let r=e("Z","Z");r.onclick=t("Z",r)}createActiveSelectLayout(){let e=document.createElement("div");e.classList.add("pop-panel-active-select"),this.body.appendChild(e),this.activeSelectNode=e}addActiveItems(){let e=(e,t)=>{let n=document.createElement("i");n.classList.add(qv),n.classList.add(t),e.innerHTML="",e.appendChild(n)},t=((t,n,i="")=>{let r=document.createElement("div");return r.classList.add("pop-panel-item"),n&&r.setAttribute("title",n),r.setAttribute("itemName",t),r.setAttribute("isActive","false"),e(r,i),r})("visible","\u9690\u85cf\u5256\u5207\u9762","icon-hidesectionplane");t.onclick=()=>{this.isVisible=!this.isVisible,this.isVisible?(e(t,"icon-hidesectionplane"),t.setAttribute("title","\u9690\u85cf\u5256\u5207\u9762")):(e(t,"icon-showsectionplane"),t.setAttribute("title","\u663e\u793a\u5256\u5207\u9762")),this.section.setSectionVisible(this.isVisible)}}},S2=class extends Wy{constructor(e){super("pick-section-pop-panel","\u62fe\u53d6\u9762\u5256\u5207",e.widgetContainer),this.isVisible=!0,this.enabled=!0,this.keydown=e=>{"Escape"===e.code&&this.destroy()},this.section=e.getActiveSection(),this.createActiveSelectLayout(),this.addActiveItems(),window.addEventListener("keydown",this.keydown)}destroy(){super.destroy(),window.removeEventListener("keydown",this.keydown)}createActiveSelectLayout(){let e=document.createElement("div");e.classList.add("pop-panel-active-select"),this.body.appendChild(e),this.activeSelectNode=e}addActiveItems(){let e=(e,t)=>{let n=document.createElement("i");n.classList.add("gemini-viewer-icon"),n.classList.add(t),e.innerHTML="",e.appendChild(n)},t=(t,n,i="")=>{let r=document.createElement("div");return r.classList.add("pop-panel-item"),n&&r.setAttribute("title",n),r.setAttribute("itemName",t),r.setAttribute("isActive","false"),e(r,i),r},n=t("visible","\u9690\u85cf\u5256\u5207\u9762","icon-hidesectionplane");n.onclick=()=>{this.enabled&&(this.isVisible=!this.isVisible,this.isVisible?(e(n,"icon-hidesectionplane"),n.setAttribute("title","\u9690\u85cf\u5256\u5207\u9762")):(e(n,"icon-showsectionplane"),n.setAttribute("title","\u663e\u793a\u5256\u5207\u9762")),this.section.setSectionVisible(this.isVisible))},this.activeSelectNode&&this.activeSelectNode.appendChild(n),this.visibleNode=n;let i=t("reset","\u91cd\u7f6e","icon-reset");i.onclick=t=>{t.stopPropagation(),this.enabled&&(this.isVisible=!0,e(n,"icon-hidesectionplane"),n.setAttribute("title","\u9690\u85cf\u5256\u5207\u9762"),this.section.resetSection())},this.activeSelectNode&&this.activeSelectNode.appendChild(i),this.resetNode=i}enable(){this.enabled=!0,this.visibleNode&&this.visibleNode.classList.remove("disable")}disable(){this.enabled=!1,this.visibleNode&&this.visibleNode.classList.add("disable")}},Ma,Qve={HomeView:{icon:{default:"icon-home",active:"icon-home-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.homeView",type:1,onClick:e=>{e.goToHomeView()}},OrthoMode:{icon:{default:"icon-orthomode",active:"icon-orthomode-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.orthoView",type:4,onActive:e=>{se.info("[Toolbar]","Enter OrthoMode"),e.setToOrthographicCamera(!0)},onDeactive:e=>{se.info("[Toolbar]","Exit OrthoMode"),e.setToOrthographicCamera(!1)}},Measure:{icon:{default:"icon-measure",active:"icon-measure-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.measurement",type:3,children:{MeasureDistance:{icon:{default:"icon-measure-distance"},menuName:"Toolbar.distanceMeasurement",onActive:e=>{let t=e;t.deactivateSection(),t.activateMeasurement("Distance")},onDeactive:e=>{e.deactivateMeasurement()},type:4,mutexIds:["MeasureArea","MeasureAngle","MeasureCoordinate"]},MeasureArea:{icon:{default:"icon-measure-area-color"},onActive:e=>{let t=e;t.deactivateSection(),t.activateMeasurement("Area")},onDeactive:e=>{e.deactivateMeasurement()},type:4,menuName:"Toolbar.areaMeasurement",mutexIds:["MeasureDistance","MeasureAngle","MeasureCoordinate"]},MeasureAngle:{menuName:"Toolbar.angleMeasurement",icon:{default:"icon-angle-measure"},type:4,onActive:e=>{let t=e;t.deactivateSection(),t.activateMeasurement("Angle")},onDeactive:e=>{e.deactivateMeasurement()},mutexIds:["MeasureDistance","MeasureArea","MeasureCoordinate"]},MeasureCoordinate:{menuName:"Toolbar.coordinateMeasurement",icon:{default:"icon-distancemeasure",iconFont:"gemini-viewer-icon"},type:4,onActive:e=>{let t=e;t.deactivateSection(),t.activateMeasurement("Coordinate")},onDeactive:e=>{e.deactivateMeasurement()},mutexIds:["MeasureDistance","MeasureArea","MeasureAngle"]},MeasureClear:{icon:{default:"icon-clear",active:"icon-clear-filled",iconFont:"gemini-viewer-icon"},onClick:e=>{let t=e;se.debug("[Toolbar]","Clearing Measure",e),t.clearMeasurements()},type:1,menuName:"Toolbar.clearMeasurement"}},mutexIds:["Section","SectionAxis","SectionBox","SectionPlane"]},Section:{icon:{default:"icon-section",active:"icon-section-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.section",type:3,children:{SectionAxis:{icon:{default:"icon-sectionplane",active:"icon-sectionplane-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.axisSection",type:4,onActive:e=>{let t=e;t.deactivateMeasurement(),t.getMeasurements().forEach((e=>t.setMeasurementVisibility(e.id,!1))),null==Ma||Ma.destroy(),t.activateSection("AxisPlaneSection"),Ma=new w2(t)},onDeactive:e=>{let t=e;t.getMeasurements().forEach((e=>t.setMeasurementVisibility(e.id,!0))),t.deactivateSection(),null==Ma||Ma.destroy(),Ma=void 0},mutexIds:["SectionBox","SectionPlane"]},SectionPlane:{icon:{default:"icon-choosesectionplane",active:"icon-choosesectionplane-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.pickSectionPlane",type:4,onActive:e=>{let t=e;t.deactivateMeasurement(),t.getMeasurements().forEach((e=>t.setMeasurementVisibility(e.id,!1))),null==Ma||Ma.destroy(),t.activateSection("PickPlaneSection"),Ma=new S2(t)},onDeactive:e=>{let t=e;t.getMeasurements().forEach((e=>t.setMeasurementVisibility(e.id,!0))),t.deactivateSection(),null==Ma||Ma.destroy(),Ma=void 0},mutexIds:["SectionAxis","SectionBox"]},SectionBox:{icon:{default:"icon-sectionbox",active:"icon-sectionbox-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.sectionBox",type:4,onActive:e=>{let t=e;t.deactivateMeasurement(),t.getMeasurements().forEach((e=>t.setMeasurementVisibility(e.id,!1))),t.activateSection()},onDeactive:e=>{let t=e;t.getMeasurements().forEach((e=>t.setMeasurementVisibility(e.id,!0))),t.deactivateSection()},mutexIds:["SectionAxis","SectionPlane"]}},mutexIds:["Measure","MeasureDistance","MeasureArea","MeasureAngle","MeasureCoordinate"]},BimTree:{icon:{default:"icon-bimtree",active:"icon-bimtree-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.bimTree",type:4,onActive:()=>{se.info("[Toolbar]","Activate Bim Tree")},onDeactive:()=>{se.info("[Toolbar]","Deactivate Bim Tree")},visible:!1},Viewpoint:{icon:{default:"icon-viewpoint",active:"icon-viewpoint-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.viewpoint",type:4,onActive:()=>{se.info("[Toolbar]","Activate Viewpoint")},onDeactive:()=>{se.info("[Toolbar]","Deactivate Viewpoint")},visible:!1},Annotation:{icon:{default:"icon-annotation",active:"icon-annotation-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.annotation",type:4,onActive:()=>{se.info("[Toolbar]","Activate Annotation")},onDeactive:()=>{se.info("[Toolbar]","Deactivate Annotation")},visible:!1},Property:{icon:{default:"icon-property",active:"icon-property-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.property",type:4,onActive:()=>{se.info("[Toolbar]","Activate Property")},onDeactive:()=>{se.info("[Toolbar]","Deactivate Property")},visible:!1},Settings:{icon:{default:"icon-settings",active:"icon-settings-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.settings",type:4,onActive:()=>{se.info("[Toolbar]","Activate Settings")},onDeactive:()=>{se.info("[Toolbar]","Deactivate Settings")},visible:!1},FullScreen:{icon:{default:"icon-fullscreen",active:"icon-fullscreen-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.fullscreen",type:4,onClick:(e,t)=>{var n;let i=()=>{let e=null==t?void 0:t.menuList.get("FullScreen");e&&e.setActive(Mt.isFullScreen())};Mt.isFullScreen()?(Mt.exitFullscreen(),window.removeEventListener("resize",i)):Mt.fullScreen(null==(n=e.viewerContainer)?void 0:n.parentElement),window.addEventListener("resize",i)}}},eye={HomeView:{icon:{default:"icon-zhushitu",active:"icon-zhushitu"},menuName:"Toolbar.homeView",type:1,onClick:e=>{e.goToHomeView()}},ZoomToRectangle:{icon:{default:"icon-kuangxuanfangda",active:"icon-kuangxuanfangda"},menuName:"Toolbar.zoomToRectangle",type:4,onClick:(e,t)=>{let n=e;n.removeEventListener("BoxSelectDeactivated"),n.addEventListener("BoxSelectDeactivated",(()=>{null==t||t.setActive("ZoomToRectangle",!1)})),n.zoomToRect()},mutexIds:["GetScreenshot"]},GetScreenshot:{icon:{default:"icon-frame-clipping",active:"icon-frame-clipping"},menuName:"Toolbar.screenshot",type:4,onClick:(e,t)=>{let n=e;n.removeEventListener("BoxSelectDeactivated"),n.addEventListener("BoxSelectDeactivated",(()=>{null==t||t.setActive("GetScreenshot",!1)})),n.getScreenshot().then((e=>{if(se.info("[Toolbar] getScreenshot() returns:",null==e?void 0:e.base64Image),null==e||!e.base64Image)throw"[Toolbar] Image data is empty!";let t=document.createElement("a");t.href=null==e?void 0:e.base64Image,t.download="",t.click()})).catch((e=>{se.error("[Toolbar] Failed to get screenshot, reason:",e),null==t||t.setActive("GetScreenshot",!1)}))},mutexIds:["ZoomToRectangle"]},Measure:{icon:{default:"icon-celiang1",active:"icon-celiang1"},menuName:"Toolbar.measurement",type:3,children:{MeasureDistance:{icon:{default:"icon-measure-distance"},menuName:"Toolbar.distanceMeasurement",onActive:e=>{e.activateMeasurement("Distance")},onDeactive:e=>{e.deactivateMeasurement()},type:4,mutexIds:["MeasureArea","MeasureAngle","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureArea:{icon:{default:"icon-measure-area-color"},onActive:e=>{e.activateMeasurement("Area")},onDeactive:e=>{e.deactivateMeasurement()},type:4,menuName:"Toolbar.areaMeasurement",mutexIds:["MeasureDistance","MeasureAngle","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureAngle:{menuName:"Toolbar.angleMeasurement",icon:{default:"icon-angle-measure"},type:4,onActive:e=>{e.activateMeasurement("Angle")},onDeactive:e=>{e.deactivateMeasurement()},mutexIds:["MeasureDistance","MeasureArea","MeasureCoordinate","ZoomToRectangle","GetScreenshot"]},MeasureCoordinate:{menuName:"Toolbar.coordinateMeasurement",icon:{default:"icon-distancemeasure",iconFont:"gemini-viewer-icon"},type:4,onActive:e=>{e.activateMeasurement("Coordinate")},onDeactive:e=>{e.deactivateMeasurement()},visible:!1,mutexIds:["MeasureDistance","MeasureArea","MeasureAngle","ZoomToRectangle","GetScreenshot"]},MeasureClear:{icon:{default:"icon-clear",active:"icon-clear-filled",iconFont:"gemini-viewer-icon"},onClick:e=>{let t=e;se.debug("[Toolbar]","Clearing Measure",e),t.clearMeasurements()},type:1,menuName:"Toolbar.clearMeasurement"}}},Markup:{icon:{default:"icon-annotation"},menuName:"Toolbar.markup",type:1,onClick:(e,t)=>{let n=e;null==t||t.updateMenu("Measure",{defaultActive:!1}),null==t||t.setActive("ZoomToRectangle",!1),n.getMarkups().forEach((e=>n.setMarkupVisibility(e.id,!0))),null==t||t.setActive("MarkupVisibility",!1),n.activateMarkup("CloudRectWithTextMarkup"),e.dispatchEvent("MarkupActivated")}},MarkupVisibility:{icon:{default:"icon-annotation-show",active:"icon-annotation-hide"},menuName:"Toolbar.markupVisibility",type:4,onActive:e=>{let t=e;t.getMarkups().forEach((e=>t.setMarkupVisibility(e.id,!1)))},onDeactive:e=>{let t=e;t.getMarkups().forEach((e=>t.setMarkupVisibility(e.id,!0)))},visible:!0},Settings:{icon:{default:"icon-settings",active:"icon-settings-filled",iconFont:"gemini-viewer-icon"},menuName:"Toolbar.settings",type:4,onActive:()=>{se.info("[Toolbar]","Activate Settings")},onDeactive:()=>{se.info("[Toolbar]","Deactivate Settings")},visible:!0},Compared:{icon:{default:"icon-compared"},menuName:"Toolbar.compared",type:4,onActive:()=>{se.info("[Toolbar]","Activate Compare")},onDeactive:()=>{se.info("[Toolbar]","Deactivate Compare")},visible:!1},QuitCompare:{icon:{default:"icon-compared"},menuName:"Toolbar.quitCompare",type:4,onActive:()=>{se.info("[Toolbar]","Activate Compare")},onDeactive:()=>{se.info("[Toolbar]","Deactivate Compare")},visible:!1},Layers:{icon:{default:"icon-tucengkongzhi",active:"icon-tucengkongzhi"},menuName:"Toolbar.layers",type:4,onClick:()=>{}},FullScreen:{icon:{default:"icon-quanping",active:"icon-quanping"},menuName:"Toolbar.fullscreen",type:4,onClick:(e,t)=>{var n;let i=()=>{let e=null==t?void 0:t.menuList.get("FullScreen");e&&e.setActive(Mt.isFullScreen())};Mt.isFullScreen()?(Mt.exitFullscreen(),window.removeEventListener("resize",i)):Mt.fullScreen(null==(n=e.viewerContainer)?void 0:n.parentElement),window.addEventListener("resize",i)}}},tye=class extends fr{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||"DxfViewerToolbarPlugin"}),this.onMarkupActivated=()=>{if(!this.markupToolbar){let e=(0,k_.merge)(this.cfg.markupMenuCfg||[],Kve),t=(0,k_.merge)(this.cfg.markupGroupCfg||[],Jve);this.markupToolbar=new T2(this.viewer,e,t),this.markupToolbar.hide()}this.toolbar.hide(),this.markupToolbar.show()},this.onMarkupDeactivated=()=>{var e;null==(e=this.markupToolbar)||e.hide(),this.toolbar.show()},this.cfg=t||{};let n=(0,k_.merge)({},eye,this.cfg.menuConfig),i=(0,k_.merge)(this.cfg.groupConfig||[],_2);this.toolbar=new ap(e,n,i),this.viewer.addEventListener("MarkupActivated",this.onMarkupActivated),this.viewer.addEventListener("MarkupDeactivated",this.onMarkupDeactivated)}setActive(e,t){this.toolbar.setActive(e,t)}destroy(){super.destroy()}},rye=ji(Fl(),1),nye=class extends fr{constructor(e,t){super(e,{id:(null==t?void 0:t.id)||"BimViewerToolbarPlugin"}),this.cfg=t||{};let n=(0,rye.merge)({},Qve,this.cfg.menuConfig),i=this.cfg.groupConfig||_2;this.toolbar=new ap(e,n,i)}setActive(e,t){this.toolbar.setActive(e,t)}destroy(){super.destroy()}},Mo=e=>({viewer:t})=>t.translate(`ContextMenu.${e}`),sye=e=>{var t;let n=0;return null==(t=e.scene)||t.traverseVisible((e=>{e instanceof xt&&n++})),n>0},jvt=e=>{var t,n;let i=0;return null==(t=e.scene)||t.traverse((e=>{e instanceof xt&&i++})),null==(n=e.scene)||n.traverseVisible((e=>{e instanceof xt&&i--})),i>0},hV=e=>e.hasTransparentObject(),M2=e=>Hn.isObjectSelectable(e),iye=(e,t,n,i)=>{let r=e.selectedObject;return!(!r||!t||r.id!==t.id)&&(null!=n&&r.isInstancedMesh?n===r.userData.instanceId:null==i||!Ar.isMergedMesh(r)||i===r.userData.batchId)},Xvt={getTitle:Mo("viewFitEntity"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{e.flyToObject(t)}},Yvt={getTitle:Mo("viewFitAll"),getEnabled:({viewer:e})=>sye(e),doAction:({viewer:e})=>e.viewFitAll()},$vt={getTitle:Mo("hideEntity"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{let n=e;M2(t)&&(n.clearSelection(),t.visible=!1,n.enableRender())}},Zvt={getTitle:Mo("hideOthers"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{var n;let i=e;i.clearSelection(),null==(n=i.scene)||n.traverse((e=>{e instanceof xt&&M2(e)&&(e.visible=!1)})),t.visible=!0,i.enableRender()}},Kvt={getTitle:Mo("hideAll"),getEnabled:({viewer:e})=>sye(e),doAction:({viewer:e})=>{var t;let n=e;n.clearSelection(),null==(t=n.scene)||t.traverse((e=>{e instanceof xt&&M2(e)&&(e.visible=!1)})),n.enableRender()}},Jvt={getTitle:Mo("showAll"),getEnabled:({viewer:e})=>jvt(e),doAction:({viewer:e})=>{var t;let n=e;null==(t=n.scene)||t.traverse((e=>{e instanceof xt&&M2(e)&&(e.visible=!0)})),n.enableRender()}},Qvt={getTitle:({hit:e,viewer:t,instanceId:n,batchId:i})=>iye(t,e,n,i)?Mo("deselect")({viewer:t}):Mo("select")({viewer:t}),getShown:({hit:e,viewer:t})=>t.enableSelection&&e,doAction:({hit:e,viewer:t,instanceId:n,batchId:i})=>{let r=t;Hn.isObjectSelectable(e)?iye(r,e,n,i)?r.clearSelection():r.selectObject(e,e.instanceId,i):se.debug(`[ContextMenu] object(type: ${e.type}, name: ${e.name}) not selectable!`)}},eyt={getTitle:Mo("selectNone"),getShown:({viewer:e})=>e.enableSelection,getEnabled:({viewer:e})=>e.selectedObject,doAction:({viewer:e})=>e.clearSelection()},tyt={getTitle:Mo("xRayAll"),getShown:({viewer:e})=>!hV(e),doAction:({viewer:e})=>{let t=e;t.clearSelection(),t.addOrRemoveObjectOpacity(!0),t.enableRender()}},nyt={getTitle:Mo("xRayNone"),getEnabled:({viewer:e})=>hV(e),doAction:({viewer:e})=>{let t=e;t.clearSelection(),hV(t)&&(t.addOrRemoveObjectOpacity(!1),t.enableRender())}},ryt={getTitle:Mo("xRayEntity"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{let n=e;n.clearSelection(),n.addOrRemoveObjectOpacity(!0,void 0,[t.id],void 0)}},iyt={getTitle:Mo("xRayOthers"),getShown:({hit:e})=>e,doAction:({viewer:e,hit:t})=>{let n=e;n.clearSelection(),n.addOrRemoveObjectOpacity(!0,.1,void 0,[t.id]),n.enableRender()}},syt={getTitle:({viewer:e})=>{let t=e,n="";switch(t.sectionType){case"PickPlaneSection":n="*showSectionPlane";break;case"AxisPlaneSection":n="showAxisSection";break;case"ObjectsBoxSection":n="*showSectionBox"}return t.translate(`ContextMenu.${n}`)},getShown:({viewer:e,section:t})=>{let n=e;return("PickPlaneSection"===n.sectionType||"AxisPlaneSection"===n.sectionType)&&!!t&&!t.showSectionPlane},doAction:({viewer:e,section:t})=>{let n=e;("PickPlaneSection"===n.sectionType||"AxisPlaneSection"===n.sectionType)&&(null==t||t.setSectionVisible(!0))}},ayt={getTitle:({viewer:e})=>{let t=e,n="";switch(t.sectionType){case"PickPlaneSection":n="hideSectionPlane";break;case"AxisPlaneSection":n="hideAxisSection";break;case"ObjectsBoxSection":n="hideSectionBox"}return t.translate(`ContextMenu.${n}`)},getShown:e=>aye(e),doAction:({viewer:e,section:t})=>{let n=e;("PickPlaneSection"===n.sectionType||"AxisPlaneSection"===n.sectionType)&&(null==t||t.setSectionVisible(!1))}},oyt={getTitle:Mo("undoSection"),getShown:e=>aye(e),doAction:({viewer:e,toolbar:t})=>{let n=e;if("PickPlaneSection"===n.sectionType){let e=null==t?void 0:t.menuList.get("SectionPlane");null==e||e.setActive(!1)}else if("AxisPlaneSection"===n.sectionType){let e=null==t?void 0:t.menuList.get("SectionAxis");null==e||e.setActive(!1)}else if("ObjectsBoxSection"===n.sectionType){let e=null==t?void 0:t.menuList.get("SectionBox");null==e||e.setActive(!1)}}},aye=({viewer:e,hit:t,section:n})=>{let i=e;return("PickPlaneSection"===i.sectionType||"AxisPlaneSection"===i.sectionType)&&!!n&&n.showSectionPlane&&(null==t?void 0:t.name)===SH},oye=[[syt],[ayt,oyt],[Xvt,Yvt],[$vt,Zvt,Kvt,Jvt],[ryt,iyt,tyt,nyt],[Qvt,eyt]],lye=class extends fr{constructor(e){super(e,{id:"ContextMenuPlugin"}),this.itemList=[],this.handleClick=()=>{this.hide()},this.container=e.widgetContainer||document.body,this.context={viewer:e},this.element=this.createMenuUI(oye||[]),window.oncontextmenu=e=>e.preventDefault(),this.hide(),this.initEvents()}initEvents(){let e=this.viewer.getInputManager();if(!e)return;let t=!1,n=!1,i=0,r=0;e.addEventListener("pointerdown",(()=>{n=!1,t=!0,this.hide()})),e.addEventListener("pointermove",(e=>{t&&!n&&(n=!(e=>-1!==i&&-1!==r&&Math.abs(e.x-i)<5&&Math.abs(e.y-r)<5)(e))})),e.addEventListener("pointerup",(e=>{if(t=!1,n)return n=!1,void this.hide();i=e.x,r=e.y,2===e.button?this.showContextMenu(e):this.hide()})),document.addEventListener("click",this.handleClick)}showContextMenu(e){let t=this.context,n=this.viewer;if(n.selectedObject){let e=n.selectedObject.userData.instanceId,i=n.selectedObject.userData.batchId;this.context=Ri(Tr({},t),{hit:n.selectedObject,instanceId:e,batchId:i})}else{let i=n.getRaycaster();i&&i.layers.set(10);let r=n.getAllIntersections(e);se.debug("[Viewer] showContextMenu intersections = ",r);let a,s=(0,ug.find)(r,(e=>{let t=e.object;return t instanceof xt&&t.visible})),o=null==s?void 0:s.instanceId,l=null==s?void 0:s.faceIndex;l&&(a=Ar.getBatchIdByFaceIndex(null==s?void 0:s.object,l)),this.context=Ri(Tr({},t),{hit:null==s?void 0:s.object,instanceId:o,batchId:a})}let{x:i,y:r}=e;this.show(i,r)}isEnabled(e){return e.getEnabled?e.getEnabled(this.context):void 0===e.enabled||e.enabled}isShown(e){return e.getShown?e.getShown(this.context):void 0===e.shown||e.shown}getTitle(e){return e.title||e.getTitle&&e.getTitle(this.context)||""}createMenuUI(e){let t=document.createElement("div");t.id=this.id,t.classList.add("context-menu");let n=this.createMenuGroup(e);return t.append(...n),this.container.appendChild(t),t}createMenuGroup(e){return(0,ug.map)(e,(e=>{let t=document.createElement("ul");return(0,ug.forEach)(e,(e=>{let n=this.createMenuItem(e);t.append(n)})),t}))}createMenuItem(e){let t=document.createElement("li");return t.innerHTML=this.getTitle(e),t.onclick=()=>e.doAction&&e.doAction(this.context),this.isEnabled(e)?t.classList.remove("disabled"):t.classList.add("disabled"),this.isShown(e)?t.removeAttribute("hidden"):t.setAttribute("hidden",""),this.itemList.push([e,t]),t}updateMenuItems(){(0,ug.forEach)(this.itemList,(([e,t])=>{this.isEnabled(e)?t.classList.remove("disabled"):t.classList.add("disabled"),this.isShown(e)?t.removeAttribute("hidden"):t.setAttribute("hidden",""),t.innerHTML=this.getTitle(e)}))}showMenuElement(e,t){let n=this.element.offsetHeight,i=this.element.offsetWidth;t+n>window.innerHeight&&(t=window.innerHeight-n-5),e+i>window.innerWidth&&(e=window.innerWidth-i-5),this.element.style.left=e+"px",this.element.style.top=t+"px"}show(e,t){this.updateMenuItems(),this.element.removeAttribute("hidden"),this.showMenuElement(e,t)}hide(){this.element.setAttribute("hidden","")}destroy(){document.removeEventListener("click",this.handleClick),this.container.removeChild(this.element)}};function lyt(e){if(e&&"undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}function Yy(e,t){var n=e.__state.conversionName.toString(),i=Math.round(e.r),r=Math.round(e.g),a=Math.round(e.b),s=e.a,o=Math.round(e.h),l=e.s.toFixed(1),h=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var c=e.hex.toString(16);c.length<6;)c="0"+c;return"#"+c}return"CSS_RGB"===n?"rgb("+i+","+r+","+a+")":"CSS_RGBA"===n?"rgba("+i+","+r+","+a+","+s+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+i+","+r+","+a+"]":"RGBA_ARRAY"===n?"["+i+","+r+","+a+","+s+"]":"RGB_OBJ"===n?"{r:"+i+",g:"+r+",b:"+a+"}":"RGBA_OBJ"===n?"{r:"+i+",g:"+r+",b:"+a+",a:"+s+"}":"HSV_OBJ"===n?"{h:"+o+",s:"+l+",v:"+h+"}":"HSVA_OBJ"===n?"{h:"+o+",s:"+l+",v:"+h+",a:"+s+"}":"unknown format"}var cye=Array.prototype.forEach,F_=Array.prototype.slice,Ht={BREAK:{},extend:function(e){return this.each(F_.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(t[n])||(e[n]=t[n])}.bind(this))}),this),e},defaults:function(e){return this.each(F_.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(e[n])&&(e[n]=t[n])}.bind(this))}),this),e},compose:function(){var e=F_.call(arguments);return function(){for(var t=F_.call(arguments),n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e)if(cye&&e.forEach&&e.forEach===cye)e.forEach(t,n);else if(e.length===e.length+0){var i,r=void 0;for(r=0,i=e.length;r1?Ht.toArray(arguments):arguments[0];return Ht.each(cyt,(function(t){if(t.litmus(e))return Ht.each(t.conversions,(function(t,n){if(N_=t.read(e),!1===R2&&!1!==N_)return R2=N_,N_.conversionName=n,N_.conversion=t,Ht.BREAK})),Ht.BREAK})),R2},uye=void 0,C2={hsv_to_rgb:function(e,t,n){var i=Math.floor(e/60)%6,r=e/60-Math.floor(e/60),a=n*(1-t),s=n*(1-r*t),o=n*(1-(1-r)*t),l=[[n,o,a],[s,n,a],[a,n,o],[a,s,n],[o,a,n],[n,a,s]][i];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var i=Math.min(e,t,n),r=Math.max(e,t,n),a=r-i,s=void 0;return 0===r?{h:NaN,s:0,v:0}:(s=e===r?(t-n)/a:t===r?2+(n-e)/a:4+(e-t)/a,(s/=6)<0&&(s+=1),{h:360*s,s:a/r,v:r/255})},rgb_to_hex:function(e,t,n){var i=this.hex_with_component(0,2,e);return i=this.hex_with_component(i,1,t),this.hex_with_component(i,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(uye=8*t)|e&~(255<-1?t.length-t.indexOf(".")-1:0}var _ye=function(e){function t(e,n,i){Yc(this,t);var r=cp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=i||{};return r.__min=a.min,r.__max=a.max,r.__step=a.step,Ht.isUndefined(r.__step)?0===r.initialValue?r.__impliedStep=1:r.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(r.initialValue))/Math.LN10))/10:r.__impliedStep=r.__step,r.__precision=hye(r.__impliedStep),r}return lp(t,hg),$c(t,[{key:"setValue",value:function(e){var n=e;return void 0!==this.__min&&nthis.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!=0&&(n=Math.round(n/this.__step)*this.__step),op(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=hye(e),this}}]),t}();function myt(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}var P2=function(e){function t(e,n,i){Yc(this,t);var r=cp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,i));r.__truncationSuspended=!1;var a=r,s=void 0;function o(){a.__onFinishChange&&a.__onFinishChange.call(a,a.getValue())}function l(e){var t=s-e.clientY;a.setValue(a.getValue()+t*a.__impliedStep),s=e.clientY}function h(){bt.unbind(window,"mousemove",l),bt.unbind(window,"mouseup",h),o()}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),bt.bind(r.__input,"change",(function(){var e=parseFloat(a.__input.value);Ht.isNaN(e)||a.setValue(e)})),bt.bind(r.__input,"blur",(function(){o()})),bt.bind(r.__input,"mousedown",(function(e){bt.bind(window,"mousemove",l),bt.bind(window,"mouseup",h),s=e.clientY})),bt.bind(r.__input,"keydown",(function(e){13===e.keyCode&&(a.__truncationSuspended=!0,this.blur(),a.__truncationSuspended=!1,o())})),r.updateDisplay(),r.domElement.appendChild(r.__input),r}return lp(t,_ye),$c(t,[{key:"updateDisplay",value:function(){return this.__input.value=this.__truncationSuspended?this.getValue():myt(this.getValue(),this.__precision),op(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}();function dye(e,t,n,i,r){return i+(e-t)/(n-t)*(r-i)}var pV=function(e){function t(e,n,i,r,a){Yc(this,t);var s=cp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,{min:i,max:r,step:a})),o=s;function l(e){e.preventDefault();var t=o.__background.getBoundingClientRect();return o.setValue(dye(e.clientX,t.left,t.right,o.__min,o.__max)),!1}function h(){bt.unbind(window,"mousemove",l),bt.unbind(window,"mouseup",h),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}function c(e){var t=e.touches[0].clientX,n=o.__background.getBoundingClientRect();o.setValue(dye(t,n.left,n.right,o.__min,o.__max))}function u(){bt.unbind(window,"touchmove",c),bt.unbind(window,"touchend",u),o.__onFinishChange&&o.__onFinishChange.call(o,o.getValue())}return s.__background=document.createElement("div"),s.__foreground=document.createElement("div"),bt.bind(s.__background,"mousedown",(function(e){document.activeElement.blur(),bt.bind(window,"mousemove",l),bt.bind(window,"mouseup",h),l(e)})),bt.bind(s.__background,"touchstart",(function(e){1===e.touches.length&&(bt.bind(window,"touchmove",c),bt.bind(window,"touchend",u),c(e))})),bt.addClass(s.__background,"slider"),bt.addClass(s.__foreground,"slider-fg"),s.updateDisplay(),s.__background.appendChild(s.__foreground),s.domElement.appendChild(s.__background),s}return lp(t,_ye),$c(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",op(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(),Tye=function(e){function t(e,n,i){Yc(this,t);var r=cp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),a=r;return r.__button=document.createElement("div"),r.__button.innerHTML=void 0===i?"Fire":i,bt.bind(r.__button,"click",(function(e){return e.preventDefault(),a.fire(),!1})),bt.addClass(r.__button,"button"),r.domElement.appendChild(r.__button),r}return lp(t,hg),$c(t,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),t}(),mV=function(e){function t(e,n){Yc(this,t);var i=cp(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));i.__color=new $s(i.getValue()),i.__temp=new $s(0);var r=i;i.domElement=document.createElement("div"),bt.makeSelectable(i.domElement,!1),i.__selector=document.createElement("div"),i.__selector.className="selector",i.__saturation_field=document.createElement("div"),i.__saturation_field.className="saturation-field",i.__field_knob=document.createElement("div"),i.__field_knob.className="field-knob",i.__field_knob_border="2px solid ",i.__hue_knob=document.createElement("div"),i.__hue_knob.className="hue-knob",i.__hue_field=document.createElement("div"),i.__hue_field.className="hue-field",i.__input=document.createElement("input"),i.__input.type="text",i.__input_textShadow="0 1px 1px ",bt.bind(i.__input,"keydown",(function(e){13===e.keyCode&&c.call(this)})),bt.bind(i.__input,"blur",c),bt.bind(i.__selector,"mousedown",(function(){bt.addClass(this,"drag").bind(window,"mouseup",(function(){bt.removeClass(r.__selector,"drag")}))})),bt.bind(i.__selector,"touchstart",(function(){bt.addClass(this,"drag").bind(window,"touchend",(function(){bt.removeClass(r.__selector,"drag")}))}));var a=document.createElement("div");function s(e){d(e),bt.bind(window,"mousemove",d),bt.bind(window,"touchmove",d),bt.bind(window,"mouseup",l),bt.bind(window,"touchend",l)}function o(e){p(e),bt.bind(window,"mousemove",p),bt.bind(window,"touchmove",p),bt.bind(window,"mouseup",h),bt.bind(window,"touchend",h)}function l(){bt.unbind(window,"mousemove",d),bt.unbind(window,"touchmove",d),bt.unbind(window,"mouseup",l),bt.unbind(window,"touchend",l),u()}function h(){bt.unbind(window,"mousemove",p),bt.unbind(window,"touchmove",p),bt.unbind(window,"mouseup",h),bt.unbind(window,"touchend",h),u()}function c(){var e=fV(this.value);!1!==e?(r.__color.__state=e,r.setValue(r.__color.toOriginal())):this.value=r.__color.toString()}function u(){r.__onFinishChange&&r.__onFinishChange.call(r,r.__color.toOriginal())}function d(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,i=n.clientX,a=n.clientY,s=(i-t.left)/(t.right-t.left),o=1-(a-t.top)/(t.bottom-t.top);return o>1?o=1:o<0&&(o=0),s>1?s=1:s<0&&(s=0),r.__color.v=o,r.__color.s=s,r.setValue(r.__color.toOriginal()),!1}function p(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),r.__color.h=360*n,r.setValue(r.__color.toOriginal()),!1}return Ht.extend(i.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),Ht.extend(i.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:i.__field_knob_border+(i.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),Ht.extend(i.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),Ht.extend(i.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),Ht.extend(a.style,{width:"100%",height:"100%",background:"none"}),fye(a,"top","rgba(0,0,0,0)","#000"),Ht.extend(i.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),vyt(i.__hue_field),Ht.extend(i.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:i.__input_textShadow+"rgba(0,0,0,0.7)"}),bt.bind(i.__saturation_field,"mousedown",s),bt.bind(i.__saturation_field,"touchstart",s),bt.bind(i.__field_knob,"mousedown",s),bt.bind(i.__field_knob,"touchstart",s),bt.bind(i.__hue_field,"mousedown",o),bt.bind(i.__hue_field,"touchstart",o),i.__saturation_field.appendChild(a),i.__selector.appendChild(i.__field_knob),i.__selector.appendChild(i.__saturation_field),i.__selector.appendChild(i.__hue_field),i.__hue_field.appendChild(i.__hue_knob),i.domElement.appendChild(i.__input),i.domElement.appendChild(i.__selector),i.updateDisplay(),i}return lp(t,hg),$c(t,[{key:"updateDisplay",value:function(){var e=fV(this.getValue());if(!1!==e){var t=!1;Ht.each($s.COMPONENTS,(function(n){if(!Ht.isUndefined(e[n])&&!Ht.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}}),this),t&&Ht.extend(this.__color.__state,e)}Ht.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,i=255-n;Ht.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,fye(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),Ht.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+i+","+i+","+i+",.7)"})}}]),t}(),gyt=["-moz-","-o-","-webkit-","-ms-",""];function fye(e,t,n,i){e.style.background="",Ht.each(gyt,(function(r){e.style.cssText+="background: "+r+"linear-gradient("+t+", "+n+" 0%, "+i+" 100%); "}))}function vyt(e){e.style.background="",e.style.cssText+="background: -moz-linear-gradient(top, #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",e.style.cssText+="background: -webkit-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: -o-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: -ms-linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: linear-gradient(top, #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"}var yyt={load:function(e,t){var n=t||document,i=n.createElement("link");i.type="text/css",i.rel="stylesheet",i.href=e,n.getElementsByTagName("head")[0].appendChild(i)},inject:function(e,t){var n=t||document,i=document.createElement("style");i.type="text/css",i.innerHTML=e;var r=n.getElementsByTagName("head")[0];try{r.appendChild(i)}catch(e){}}},xyt='
\n\n Here\'s the new load parameter for your GUI\'s constructor:\n\n \n\n
\n\n Automatically save\n values to localStorage on exit.\n\n
The values saved to localStorage will\n override those passed to dat.GUI\'s constructor. This makes it\n easier to work incrementally, but localStorage is fragile,\n and your friends may not see the same values you do.\n\n
\n\n
\n\n
',byt=function(e,t){var n=e[t];return Ht.isArray(arguments[2])||Ht.isObject(arguments[2])?new fyt(e,t,arguments[2]):Ht.isNumber(n)?Ht.isNumber(arguments[2])&&Ht.isNumber(arguments[3])?Ht.isNumber(arguments[4])?new pV(e,t,arguments[2],arguments[3],arguments[4]):new pV(e,t,arguments[2],arguments[3]):Ht.isNumber(arguments[4])?new P2(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new P2(e,t,{min:arguments[2],max:arguments[3]}):Ht.isString(n)?new pyt(e,t):Ht.isFunction(n)?new Tye(e,t,""):Ht.isBoolean(n)?new Eye(e,t):null};function Eyt(e){setTimeout(e,1e3/60)}var _yt=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||Eyt,Tyt=function(){function e(){Yc(this,e),this.backgroundElement=document.createElement("div"),Ht.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),bt.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),Ht.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;bt.bind(this.backgroundElement,"click",(function(){t.hide()}))}return $c(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),Ht.defer((function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"}))}},{key:"hide",value:function(){var e=this,t=function t(){e.domElement.style.display="none",e.backgroundElement.style.display="none",bt.unbind(e.domElement,"webkitTransitionEnd",t),bt.unbind(e.domElement,"transitionend",t),bt.unbind(e.domElement,"oTransitionEnd",t)};bt.bind(this.domElement,"webkitTransitionEnd",t),bt.bind(this.domElement,"transitionend",t),bt.bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-bt.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-bt.getHeight(this.domElement)/2+"px"}}]),e}(),wyt=lyt(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .cr.function .property-name{width:100%}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n");yyt.inject(wyt);var pye="dg",mye=72,gye=20,V_="Default",B_=function(){try{return!!window.localStorage}catch(e){return!1}}(),U_=void 0,vye=!0,jy=void 0,dV=!1,wye=[],Di=function e(t){var n=this,i=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),bt.addClass(this.domElement,pye),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],i=Ht.defaults(i,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),i=Ht.defaults(i,{resizable:i.autoPlace,hideable:i.autoPlace}),Ht.isUndefined(i.load)?i.load={preset:V_}:i.preset&&(i.load.preset=i.preset),Ht.isUndefined(i.parent)&&i.hideable&&wye.push(this),i.resizable=Ht.isUndefined(i.parent)&&i.resizable,i.autoPlace&&Ht.isUndefined(i.scrollable)&&(i.scrollable=!0);var r,a=B_&&"true"===localStorage.getItem(Xy(this,"isLocal")),s=void 0,o=void 0;if(Object.defineProperties(this,{parent:{get:function(){return i.parent}},scrollable:{get:function(){return i.scrollable}},autoPlace:{get:function(){return i.autoPlace}},closeOnTop:{get:function(){return i.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:i.load.preset},set:function(e){n.parent?n.getRoot().preset=e:i.load.preset=e,Ayt(this),n.revert()}},width:{get:function(){return i.width},set:function(e){i.width=e,yV(n,e)}},name:{get:function(){return i.name},set:function(e){i.name=e,o&&(o.innerHTML=i.name)}},closed:{get:function(){return i.closed},set:function(t){i.closed=t,i.closed?bt.addClass(n.__ul,e.CLASS_CLOSED):bt.removeClass(n.__ul,e.CLASS_CLOSED),this.onResize(),n.__closeButton&&(n.__closeButton.innerHTML=t?e.TEXT_OPEN:e.TEXT_CLOSED)}},load:{get:function(){return i.load}},useLocalStorage:{get:function(){return a},set:function(e){B_&&(a=e,e?bt.bind(window,"unload",s):bt.unbind(window,"unload",s),localStorage.setItem(Xy(n,"isLocal"),e))}}}),Ht.isUndefined(i.parent)){if(this.closed=i.closed||!1,bt.addClass(this.domElement,e.CLASS_MAIN),bt.makeSelectable(this.domElement,!1),B_&&a){n.useLocalStorage=!0;var l=localStorage.getItem(Xy(this,"gui"));l&&(i.load=JSON.parse(l))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=e.TEXT_CLOSED,bt.addClass(this.__closeButton,e.CLASS_CLOSE_BUTTON),i.closeOnTop?(bt.addClass(this.__closeButton,e.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(bt.addClass(this.__closeButton,e.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),bt.bind(this.__closeButton,"click",(function(){n.closed=!n.closed}))}else{void 0===i.closed&&(i.closed=!0);var h=document.createTextNode(i.name);bt.addClass(h,"controller-name"),o=EV(n,h),bt.addClass(this.__ul,e.CLASS_CLOSED),bt.addClass(o,"title"),bt.bind(o,"click",(function(e){return e.preventDefault(),n.closed=!n.closed,!1})),i.closed||(this.closed=!1)}i.autoPlace&&(Ht.isUndefined(i.parent)&&(vye&&(jy=document.createElement("div"),bt.addClass(jy,pye),bt.addClass(jy,e.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(jy),vye=!1),jy.appendChild(this.domElement),bt.addClass(this.domElement,e.CLASS_AUTO_PLACE)),this.parent||yV(n,i.width)),this.__resizeHandler=function(){n.onResizeDebounced()},bt.bind(window,"resize",this.__resizeHandler),bt.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),bt.bind(this.__ul,"transitionend",this.__resizeHandler),bt.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),i.resizable&&Ryt(this),s=function(){B_&&"true"===localStorage.getItem(Xy(n,"isLocal"))&&localStorage.setItem(Xy(n,"gui"),JSON.stringify(n.getSaveObject()))},this.saveToLocalStorageIfPossible=s,i.parent||((r=n.getRoot()).width+=1,Ht.defer((function(){r.width-=1})))};function EV(e,t,n){var i=document.createElement("li");return t&&i.appendChild(t),n?e.__ul.insertBefore(i,n):e.__ul.appendChild(i),e.onResize(),i}function yye(e){bt.unbind(window,"resize",e.__resizeHandler),e.saveToLocalStorageIfPossible&&bt.unbind(window,"unload",e.saveToLocalStorageIfPossible)}function gV(e,t){var n=e.__preset_select[e.__preset_select.selectedIndex];n.innerHTML=t?n.value+"*":n.value}function Syt(e,t,n){if(n.__li=t,n.__gui=e,Ht.extend(n,{options:function(t){if(arguments.length>1){var i=n.__li.nextElementSibling;return n.remove(),H_(e,n.object,n.property,{before:i,factoryArgs:[Ht.toArray(arguments)]})}if(Ht.isArray(t)||Ht.isObject(t)){var r=n.__li.nextElementSibling;return n.remove(),H_(e,n.object,n.property,{before:r,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof pV){var i=new P2(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});Ht.each(["updateDisplay","onChange","onFinishChange","step","min","max"],(function(e){var t=n[e],r=i[e];n[e]=i[e]=function(){var e=Array.prototype.slice.call(arguments);return r.apply(i,e),t.apply(n,e)}})),bt.addClass(t,"has-slider"),n.domElement.insertBefore(i.domElement,n.domElement.firstElementChild)}else if(n instanceof P2){var r=function(t){if(Ht.isNumber(n.__min)&&Ht.isNumber(n.__max)){var i=n.__li.firstElementChild.firstElementChild.innerHTML,r=n.__gui.__listening.indexOf(n)>-1;n.remove();var a=H_(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return a.name(i),r&&a.listen(),a}return t};n.min=Ht.compose(r,n.min),n.max=Ht.compose(r,n.max)}else n instanceof Eye?(bt.bind(t,"click",(function(){bt.fakeEvent(n.__checkbox,"click")})),bt.bind(n.__checkbox,"click",(function(e){e.stopPropagation()}))):n instanceof Tye?(bt.bind(t,"click",(function(){bt.fakeEvent(n.__button,"click")})),bt.bind(t,"mouseover",(function(){bt.addClass(n.__button,"hover")})),bt.bind(t,"mouseout",(function(){bt.removeClass(n.__button,"hover")}))):n instanceof mV&&(bt.addClass(t,"color"),n.updateDisplay=Ht.compose((function(e){return t.style.borderLeftColor=n.__color.toString(),e}),n.updateDisplay),n.updateDisplay());n.setValue=Ht.compose((function(t){return e.getRoot().__preset_select&&n.isModified()&&gV(e.getRoot(),!0),t}),n.setValue)}function Sye(e,t){var n=e.getRoot(),i=n.__rememberedObjects.indexOf(t.object);if(-1!==i){var r=n.__rememberedObjectIndecesToControllers[i];if(void 0===r&&(r={},n.__rememberedObjectIndecesToControllers[i]=r),r[t.property]=t,n.load&&n.load.remembered){var a=n.load.remembered,s=void 0;if(a[e.preset])s=a[e.preset];else{if(!a[V_])return;s=a[V_]}if(s[i]&&void 0!==s[i][t.property]){var o=s[i][t.property];t.initialValue=o,t.setValue(o)}}}}function H_(e,t,n,i){if(void 0===t[n])throw new Error('Object "'+t+'" has no property "'+n+'"');var r=void 0;if(i.color)r=new mV(t,n);else{var a=[t,n].concat(i.factoryArgs);r=byt.apply(e,a)}i.before instanceof hg&&(i.before=i.before.__li),Sye(e,r),bt.addClass(r.domElement,"c");var s=document.createElement("span");bt.addClass(s,"property-name"),s.innerHTML=r.property;var o=document.createElement("div");o.appendChild(s),o.appendChild(r.domElement);var l=EV(e,o,i.before);return bt.addClass(l,Di.CLASS_CONTROLLER_ROW),r instanceof mV?bt.addClass(l,"color"):bt.addClass(l,uyt(r.getValue())),Syt(e,l,r),e.__controllers.push(r),r}function Xy(e,t){return document.location.href+"."+t}function vV(e,t,n){var i=document.createElement("option");i.innerHTML=t,i.value=t,e.__preset_select.appendChild(i),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function xye(e,t){t.style.display=e.useLocalStorage?"block":"none"}function Myt(e){var t=e.__save_row=document.createElement("li");bt.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),bt.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML=" ",bt.addClass(n,"button gears");var i=document.createElement("span");i.innerHTML="Save",bt.addClass(i,"button"),bt.addClass(i,"save");var r=document.createElement("span");r.innerHTML="New",bt.addClass(r,"button"),bt.addClass(r,"save-as");var a=document.createElement("span");a.innerHTML="Revert",bt.addClass(a,"button"),bt.addClass(a,"revert");var s=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?Ht.each(e.load.remembered,(function(t,n){vV(e,n,n===e.preset)})):vV(e,V_,!1),bt.bind(s,"change",(function(){for(var t=0;t0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=A2(this)),e.folders={},Ht.each(this.__folders,(function(t,n){e.folders[n]=t.getSaveObject()})),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=A2(this),gV(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[V_]=A2(this,!0)),this.load.remembered[e]=A2(this),this.preset=e,vV(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){Ht.each(this.__controllers,(function(t){this.getRoot().load.remembered?Sye(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())}),this),Ht.each(this.__folders,(function(e){e.revert(e)})),e||gV(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&Mye(this.__listening)},updateDisplay:function(){Ht.each(this.__controllers,(function(e){e.updateDisplay()})),Ht.each(this.__folders,(function(e){e.updateDisplay()}))}});var Rye=Di,Aye=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],bd=(()=>{if("undefined"==typeof document)return!1;let e=Aye[0],t={};for(let n of Aye)if((null==n?void 0:n[1])in document){for(let[i,r]of n.entries())t[e[i]]=r;return t}return!1})(),Cye={change:bd.fullscreenchange,error:bd.fullscreenerror},rl={request:(e=document.documentElement,t)=>new Promise(((n,i)=>{let r=()=>{rl.off("change",r),n()};rl.on("change",r);let a=e[bd.requestFullscreen](t);a instanceof Promise&&a.then(r).catch(i)})),exit:()=>new Promise(((e,t)=>{if(!rl.isFullscreen)return void e();let n=()=>{rl.off("change",n),e()};rl.on("change",n);let i=document[bd.exitFullscreen]();i instanceof Promise&&i.then(n).catch(t)})),toggle:(e,t)=>rl.isFullscreen?rl.exit():rl.request(e,t),onchange(e){rl.on("change",e)},onerror(e){rl.on("error",e)},on(e,t){let n=Cye[e];n&&document.addEventListener(n,t,!1)},off(e,t){let n=Cye[e];n&&document.removeEventListener(n,t,!1)},raw:bd};Object.defineProperties(rl,{isFullscreen:{get:()=>Boolean(document[bd.fullscreenElement])},element:{enumerable:!0,get:()=>{var e;return null!=(e=document[bd.fullscreenElement])?e:void 0}},isEnabled:{enumerable:!0,get:()=>Boolean(document[bd.fullscreenEnabled])}}),bd||(rl={isEnabled:!1});var I2=rl,L2=new O,D2=class{constructor(e,t,n=void 0){this.scale=1,this.explodeUp=!1,this.scene=e,this.objectId=t,t||se.debug(`[EXP] Invalid objectId: ${t}`),n?this.explodeCenter=n:(this.explodeCenter=new O,this.getObjectCenter(this.explodeCenter));let i=this.scene.getObjectById(this.objectId);null==i||i.updateWorldMatrix(!0,!0)}explode(e){if(this.scale=e,!this.objectId||!this.explodeCenter||!this.scale)return void se.debug(`[EXP] Invalid objectId: ${this.objectId}, or position: ${this.explodeCenter}, or this.power: ${this.scale}`);let t=this.scene.getObjectById(this.objectId);t&&t.children?(se.debug(`[EXP] Exploding object '${t.name}'(id: ${t.id}) at: ${Mt.vectorToString(this.explodeCenter)}`),this.explodeObject(t)):se.debug("[EXP] No children to explode!")}explodeObject(e){e.geometry?this.explodeLeafObject(e):e.children.length>0?e.children.forEach((e=>this.explodeObject(e))):this.explodeLeafObject(e)}explodeLeafObject(e){var t;let n=e;if(!n.geometry)return;n.userData.originalMatrixWorld||(n.userData.originalMatrixWorld=n.matrixWorld);let i=n.userData.originalMatrixWorld;n.userData.originalCenter||(n.geometry.boundingBox||n.geometry.computeBoundingBox(),L2.set(0,0,0),null==(t=n.geometry.boundingBox)||t.getCenter(L2),L2.applyMatrix4(n.matrixWorld),n.userData.originalCenter=L2.clone());let r=n.userData.originalCenter.clone();r.sub(this.explodeCenter),r.multiplyScalar(this.scale-1),this.explodeUp&&(r.setX(0),r.setZ(0));let a=new et;a.setPosition(r),a.multiply(i),n.matrixWorld=a,n.children.length>0&&n.children.forEach((e=>e.updateMatrix()))}unexplode(){let e=this.scene.getObjectById(this.objectId);e&&e.children?(se.debug(`[EXP] Unexploding '${e.name}'(id: ${e.id}) at: ${Mt.vectorToString(this.explodeCenter)}`),this.unexplodeObject(e)):se.debug("[EXP] No children to explode!")}unexplodeObject(e){e.geometry?this.unexplodeLeafObject(e):e.children.length>0?e.children.forEach((e=>this.unexplodeObject(e))):this.unexplodeLeafObject(e)}unexplodeLeafObject(e){let t=e.userData.originalMatrixWorld;t&&(e.matrixWorld=t,e.children.length>0&&e.children.forEach((e=>e.updateMatrix())))}setExplodeUp(e){this.explodeUp=e}getObjectCenter(e){let t=new Ot;if(!this.objectId)return void se.debug(`[EXP] Invalid objectId: ${this.objectId}`);let n=this.scene.getObjectById(this.objectId);n&&n.children?(n.traverse((e=>{t.expandByObject(e)})),t.getCenter(e)):se.debug("[EXP] No children to explode!")}},O2=class extends fr{constructor(e,t){super(e,{id:"ExplodePlugin"}),this.exploders=[],this.onModelLoaded=()=>{this.init()},this.viewer=e,this.cfg=t||{},this.viewer.addEventListener("ModelLoaded",this.onModelLoaded)}get scene(){return this.viewer.scene}init(){this.viewer.loadedModels.forEach((e=>{if(this.hasExploderForModel(e.object.id))return;let t=new O;if(this.cfg.explodeCenter){let e=this.cfg.explodeCenter;t.set(e.x,e.y,e.z)}else!this.cfg.explodeCenter&&e.bbox&&e.bbox.getCenter(t);let n=new D2(this.scene,e.object.id,t);n.setExplodeUp(!!this.cfg.explodeUp),this.exploders.push(n)}))}explode(e){0===this.exploders.length&&this.init();for(let t of this.exploders)t.explode(e),this.viewer.enableRender()}unexplode(){for(let e of this.exploders)e.unexplode(),this.viewer.enableRender()}hasExploderForModel(e){return!!this.exploders.find((t=>t.objectId===e))}destroy(){super.destroy(),this.viewer.removeEventListener("ModelLoaded",this.onModelLoaded),this.unexplode()}},k2=class extends fr{constructor(e,t){super(e,{id:"GroundGrassPlugin"}),this.NAME="GROUND_GRASS",this.DEFAULT_SIZE=1e3,this.DEFAULT_REPEAT=20,this.onModelLoaded=()=>{!1!==this.cfg.visible&&(this.init(),this.viewer.enableRender())},this.cfg=t||{},!1!==this.cfg.visible&&this.init(),this.viewer.addEventListener("ModelLoaded",this.onModelLoaded)}init(){var e;this.groundGrass&&(null==(e=this.viewer.scene)||e.remove(this.groundGrass),this.groundGrass=void 0);let t=this.cfg.texture||"images/terrain/grass.jpg",n=this.cfg.width||this.DEFAULT_SIZE,i=this.cfg.height||this.DEFAULT_SIZE,r=this.cfg.repeatX||this.DEFAULT_REPEAT,a=this.cfg.repeatY||this.DEFAULT_REPEAT,s=new O,o=this.viewer.getBBox();o&&o.getCenter(s),ft(this,null,(function*(){var e;this.groundGrass=yield this.createGrassGround(t,n,i,r,a),null==(e=this.viewer.scene)||e.add(this.groundGrass),this.viewer.enableRender()}))}setVisible(e){e&&!this.groundGrass&&this.init(),this.groundGrass&&(this.groundGrass.visible=e),this.viewer.enableRender()}createGrassGround(e,t,n,i,r){return ft(this,null,(function*(){return new Promise((a=>{(new Rs).load(e,(e=>{e.wrapS=e.wrapT=Ci,e.repeat.set(i,r),e.anisotropy=16,e.encoding=Eu;let s=new Pu({map:e});s.side=pi;let o=new xt(new ui(t,n),s);return o.rotation.x=-Math.PI/2,o.position.y=0,o.receiveShadow=!0,o.name=this.NAME,o.layers.enableAll(),o.layers.disable(12),o.matrixAutoUpdate=!1,o.updateMatrix(),a(o)}))}))}))}destroy(){super.destroy(),this.groundGrass&&(this.groundGrass.removeFromParent(),this.groundGrass.geometry.dispose(),this.groundGrass.clear(),this.groundGrass=void 0),this.viewer.removeEventListener("ModelLoaded",this.onModelLoaded)}},F2=class extends fr{constructor(e,t){super(e,{id:"GroundGridPlugin"}),this.NAME="GROUND_GRID",this.DEFAULT_SIZE=1e3,this.DEFAULT_DIVISIONS=100,this.DEFAULT_MAT_PARAMS={color:12829635,transparent:!0,opacity:.5,wireframeLinewidth:.5},this.onModelLoaded=()=>{!1!==this.cfg.visible&&(this.init(),this.viewer.enableRender())},this.cfg=t||{},!1!==this.cfg.visible&&this.init(),this.viewer.addEventListener("ModelLoaded",this.onModelLoaded)}init(){var e,t;this.gridHelper&&(null==(e=this.viewer.scene)||e.remove(this.gridHelper),this.gridHelper=void 0);let n=this.cfg.size,i=this.cfg.divisions,r=new O,a=this.viewer.getBBox();a&&a.getCenter(r),this.gridHelper=this.createGroundGrid(n,i,r),null==(t=this.viewer.scene)||t.add(this.gridHelper),this.viewer.enableRender()}setVisible(e){e&&!this.gridHelper&&this.init(),this.gridHelper&&(this.gridHelper.visible=e),this.viewer.enableRender()}createGroundGrid(e,t,n){e=e||this.DEFAULT_SIZE,t=t||this.DEFAULT_DIVISIONS;let i=new Ob(e,t);n?i.position.set(n.x,n.y,n.z):i.position.y=0;let r=i.material;return Array.isArray(r)||(r.opacity=this.DEFAULT_MAT_PARAMS.opacity,r.transparent=this.DEFAULT_MAT_PARAMS.transparent),i.name=this.NAME,i.layers.enableAll(),i.layers.disable(12),i.matrixAutoUpdate=!1,i.updateMatrix(),i}destroy(){super.destroy(),this.gridHelper&&(this.gridHelper.removeFromParent(),this.gridHelper.geometry.dispose(),this.gridHelper.clear(),this.gridHelper=void 0),this.viewer.removeEventListener("ModelLoaded",this.onModelLoaded)}},N2=class extends fr{constructor(e,t){super(e,{id:"ScreenshotPlugin"}),this.cfg=t||{},this.cfg.type=this.cfg.type||"image/png",this.cfg.quality=this.cfg.quality||.8}getScreenshot(){var e;let t=null==(e=this.viewer.renderer)?void 0:e.domElement;if(t)return t.toDataURL(this.cfg.type,this.cfg.quality)}getScreenshotAsync(){return ft(this,arguments,(function*(e="BoxSelection"){var t;this.cancel();let n,i="image/png",r=this.viewer,a=null==(t=r.renderer)?void 0:t.domElement;if(!a||!r.viewerContainer||!r.camera)return;if("PickMarkup"===e?(this.pickMarkupHelper||(this.pickMarkupHelper=new SP(r)),n=yield this.pickMarkupHelper.pick()):"BoxSelection"===e&&(this.boxSelectHelper||(this.boxSelectHelper=new $f(r)),n=yield this.boxSelectHelper.select()),"Default"!==e&&!n)return;let s=yield Mt.canvasToImage(a),o=document.createElement("canvas");o.width=a.width,o.height=a.height;let l=window.devicePixelRatio,h=o.getContext("2d");if(h.drawImage(s,0,0,s.width/l,s.height/l),r.overlayRender){let e=yield r.overlayRender.getImage((e=>e instanceof Dr||e instanceof wi));h.drawImage(e,0,0,e.width/l,e.height/l)}let c=Mt.renderingContextToImage(h,n,i,.8);return r instanceof Qf?{base64Image:c,viewExtent:r.getCurrentViewExtent(),imageType:i}:{base64Image:c,imageType:i}}))}isActive(){var e,t;return(null==(e=this.boxSelectHelper)?void 0:e.isActive)||(null==(t=this.pickMarkupHelper)?void 0:t.isActive)}cancel(){var e,t;null!=(e=this.boxSelectHelper)&&e.isActive&&this.boxSelectHelper.deactivate(),null!=(t=this.pickMarkupHelper)&&t.isActive&&this.pickMarkupHelper.deactivate()}},up=class{constructor(e="uploadModelFile"){this.input=document.createElement("input"),this.input.id=e,this.input.type="file",this.input.multiple=!0,this.input.accept=this.formats().map((e=>"."+e)).join(","),this.input.style.display="none",this.input.onchange=e=>{let t=e.target.files;!t||t.length<=0?se.error("[Uploader] No files to be uploaded!"):this.uploadFiles(t)}}formats(){return se.warn("[Uploader]: Should call derived class instead!"),[]}uploadFiles(e){se.warn(`[Uploader]: Should call derived class instead! files: ${e}`)}openFileBrowserToUpload(){this.input.click()}},B2=class extends up{constructor(e,t){super(t),this.defaultModelConfig={src:"",merge:!1},this.viewer=e}formats(){return["gltf","glb","dxf","obj","stl","fbx","ifc","dae","*"]}uploadFiles(e){let t=e.length;if(0===t)return;if(this.checkAllFilesWithTheSameFormat(e)){for(let n=0;n{r&&(n=URL.createObjectURL(r),o.push(n),a.src=r.name)};if(r){l();let e=ra.extractUrlBase(n);i=new Lu,i.setURLModifier((t=>{let n=decodeURI(t).replace(e,"").replace(/^(\.?\/)/,"");if(s.has(n)){let e=s.get(n),t=URL.createObjectURL(e);return o.push(t),t}return t}))}else r=e[0],l();this.viewer.loadLocalModel(n,a,i,(e=>{let t=Math.floor(100*e.loaded/e.total);se.info(`[Uploader] Loading ${null==r?void 0:r.name}, ${t}%`)})).then((()=>{se.info(`[Uploader] Loaded ${null==r?void 0:r.name}`),o.forEach(URL.revokeObjectURL)}))}checkAllFilesWithTheSameFormat(e){let t=e=>{let t=e.lastIndexOf(".");return e.substring(t+1).toLowerCase()},n=e.length,i=t(e[0].name);for(let r=0;r{let n=Math.floor(100*t.loaded/t.total);se.info(`[Uploader] Loading ${null==e?void 0:e.name}, ${n}%`)}))}};function Pye(e,t,n,i,r,a,s){let o=e.addFolder(t);o.add(n,"x",r,a,s).onChange(i),o.add(n,"y",r,a,s).onChange(i),o.add(n,"z",r,a,s).onChange(i)}var Iye=class extends fr{constructor(e){super(e,{id:"BimViewerDatGuiPlugin"}),this.controls={showGroundGrid:!1,showGroundGrass:!1,skyMode:["None","Black Background","White Background","Gradient ramp","Cloudy"],environments:["None","Default (City Streat 64x32)","Venice Sunset","Footprint Court (HDR Labs)","City Street"],homeView:()=>console.log("[DGH] Go to home view"),views:["Top","Bottom","Front","Back","Left","Right"],OrthographicCamera:!1,viewpoints:!1,annotations:!1,takeSnapshot:()=>console.log("[DGH] Taking snapshot..."),fullScreen:()=>console.log("[DGH] Full screen..."),webcam:!1,uploadFile:()=>console.log("[DGH] Upload file..."),showBimTree:!1,showPropertyPanel:!1,transparentMode:!1,showVertexNormals:!1,explode:1,sectionMode:["No section","Box section","Pick plane section","Axis plane section"],alVisible:!0,alColor:"#cccccc",alIntensity:1,dlColor:"#dddddd",showDlHelper:!1,hlVisible:!0,hlIntensity:1,hlColor:[255,255,255,.6],hlGroundColor:[200,255,200,.6],fogEnabled:!1,fogColor:14540253,fogNearDistance:1,fogFarDistance:1e3,composerEnabled:!1,renderPassEnabled:!1,fxaaEnabled:!1,saoEnabled:!1,ssaoEnabled:!1,outlineEnabled:!1,ssaaEnabled:!1,bloomEnabled:!1,unrealBloomEnabled:!1,enableFastOperation:!1,distanceCullingFactor:100},this.viewer=e,this.init()}init(){if(!this.viewer||!this.viewer.renderer||!this.viewer.scene)throw new Error("Need to initialize renderer, scene first!");let e=this.viewer,t=this.viewer.scene,n=this.controls;this.gui=new Rye({name:"controls",autoPlace:!0,width:300,closed:!0}),this.gui.domElement.style.opacity="0.6";let i=this.gui.addFolder("Common settings");i.add(n,"showGroundGrid").name("Show ground grid").onChange((t=>{let n=e.findPlugin("GroundGridPlugin");n?n.setVisible(t):n=new F2(e)})),i.add(n,"showGroundGrass").name("Show ground grass").onChange((t=>{let n=e.findPlugin("GroundGrassPlugin");n?n.setVisible(t):n=new k2(e)})),i.add(n,"environments",n.environments).name("Environments").onChange((n=>{let i="";if("Default (City Streat 64x32)"===n){if(e.pmremGenerator)return Cc.createEnvTextureFromDataArray(e.pmremGenerator).then((e=>{t.environment=e})),void e.enableRender()}else"Venice Sunset"===n?i="venice_sunset_1k.hdr":"Footprint Court (HDR Labs)"===n?i="footprint_court_2k.hdr":"City Street"===n&&(i="city_street_256.hdr");""===i?t.environment=null:(i=`${window.location.origin}/images/envmap/${i}`,Cc.createEnvTexture(e.pmremGenerator,i).then((e=>{t.environment=e}))),e.enableRender()})),i.add(n,"homeView").name("Go to home view").onChange((()=>{e.goToHomeView()})),i.add(n,"views",n.views).name("Views").onChange((n=>{var i;let r=new O,a=new O,s=ks.getVisibleObjectBoundingBox(t),o=aE.getCameraDirectionByView(n);aE.getCameraPositionByBboxAndDirection(s,r,a,null==(i=e.camera)?void 0:i.projectionMatrix,o),e.flyTo(r,a)})),i.add(n,"OrthographicCamera").name("Orth Camera").onChange((t=>{e.setToOrthographicCamera(t)})),i.add(n,"takeSnapshot").name("Take snapshot").onChange((()=>{let t=e.findPlugin("ScreenshotPlugin");t||(t=new N2(e));let n=t.getScreenshot(),i=document.createElement("a");i.href=n,i.download="",i.click()})),i.add(n,"fullScreen").name("Full screen").onChange((()=>{I2&&I2.isEnabled&&I2.request(),e.enableRender()})),i.add(n,"uploadFile").name("Upload file").onChange((()=>{new B2(e).openFileBrowserToUpload()}));let r=this.gui.addFolder("Model operations");r.add(n,"transparentMode",n.transparentMode).name("Transparent mode").onChange((t=>{e.addOrRemoveObjectOpacity(t),e.enableRender()})),r.add(n,"showVertexNormals",n.showVertexNormals).name("Show Vertex Normals").onChange((t=>{e.showVertexNormals(t),e.enableRender()})),r.add(n,"explode",1,5).name("Explode tool").onChange((t=>{let n=e.findPlugin("ExplodePlugin");n||(n=new O2(e)),n.explode(t)})),r.add(n,"sectionMode",n.sectionMode).name("Section mode").onChange((t=>{let n=e.findPlugin("SectionPlugin");n||(n=new d2(e)),"No section"===t?n.deactivate():"Box section"===t?n.activate("ObjectsBoxSection"):"Pick plane section"===t?n.activate("PickPlaneSection"):"Axis plane section"===t&&n.activate("AxisPlaneSection"),e.enableRender()}));let a=this.viewer.ambientLight,s=this.gui.addFolder("Ambient light");s.add(n,"alVisible",n.alVisible).name("visible").onChange((t=>{a&&(a.visible=t),e.enableRender()})),s.addColor(n,"alColor").name("color").onChange((t=>{a&&(a.color=new ct(t)),e.enableRender()})),s.add(n,"alIntensity",0,5).name("intensity").onChange((t=>{a&&(a.intensity=t),e.enableRender()}));let o=this.viewer.directionalLight;if(o){let t=this.gui.addFolder("Directional light");t.add(o,"visible").name("visible").onChange((t=>{o&&(o.visible=t),e.enableRender()})),t.addColor(n,"dlColor").name("color").onChange((t=>{o&&(o.color=new ct(t)),e.enableRender()})),t.add(o,"intensity",0,5).name("intensity").onChange((t=>{o&&(o.intensity=t),e.enableRender()})),t.add(o,"castShadow").name("castShadow").onChange((t=>{o&&(o.castShadow=t),e.enableRender()})),t.add(n,"showDlHelper").name("showDlHelper").onChange((t=>{e.showDirectionalLightHelper(t),e.enableRender()}));let i=()=>{e.updateDirectionalLight(),e.enableRender()};Pye(t,"position",o.position,i),Pye(t,"target",o.target.position,i);let r=t.addFolder("shadow");r.add(o.shadow.camera,"near").name("near").onChange(i),r.add(o.shadow.camera,"far").name("far").onChange(i),r.add(o.shadow.camera,"zoom").name("zoom").onChange(i)}let l=this.viewer.hemisphereLight,h=this.gui.addFolder("Hemisphere Light");h.add(n,"hlVisible",n.hlVisible).name("visible").onChange((t=>{l&&(l.visible=t),e.enableRender()})),h.add(n,"hlIntensity",0,5).name("intensity").onChange((t=>{l&&(l.intensity=t),e.enableRender()})),h.addColor(n,"hlColor").name("color").onChange((t=>{l&&(l.color=new ct(t)),e.enableRender()})),h.addColor(n,"hlGroundColor").name("groundColor").onChange((t=>{l&&(l.groundColor=new ct(t)),e.enableRender()}));let c=this.gui.addFolder("Fog");c.add(n,"fogEnabled",n.fogEnabled).name("Enabled").onChange((i=>{t.fog=i?new wu(n.fogColor,n.fogNearDistance,n.fogFarDistance):null,e.enableRender()})),c.add(n,"fogNearDistance",0,100).name("Near").onChange((i=>{n.fogEnabled&&t&&(t.fog=new wu(n.fogColor,i,n.fogFarDistance)),e.enableRender()})),c.add(n,"fogFarDistance",100,2e3).name("Far").onChange((i=>{n.fogEnabled&&t&&(t.fog=new wu(n.fogColor,n.fogNearDistance,i)),e.enableRender()}));let u=this.gui.addFolder("Composer");u.add(n,"composerEnabled",n.composerEnabled).name("Composer Enabled").onChange((t=>{e.enableComposer(t)})),u.add(n,"renderPassEnabled",n.renderPassEnabled).name("RenderPass Enabled").onChange((t=>{e.enableRenderPass(t)})),u.add(n,"fxaaEnabled",n.fxaaEnabled).name("Effect FXAA Enabled").onChange((t=>{e.enableFxaaPass(t)})),u.add(n,"saoEnabled",n.saoEnabled).name("SAO Enabled").onChange((t=>{e.enableSaoPass(t)})),u.add(n,"ssaoEnabled",n.ssaoEnabled).name("SSAO Enabled").onChange((t=>{e.enableSsaoPass(t)})),u.add(n,"outlineEnabled",n.outlineEnabled).name("OutlinePass Enabled").onChange((t=>{e.enableOutlinePass(t)})),u.add(n,"ssaaEnabled",n.ssaaEnabled).name("SSAA Enabled").onChange((t=>{e.enableSsaaPass(t)})),u.add(n,"bloomEnabled",n.bloomEnabled).name("Bloom Enabled").onChange((t=>{e.enableBloomPass(t)})),u.add(n,"unrealBloomEnabled",n.unrealBloomEnabled).name("Unreal Bloom Enabled").onChange((t=>{e.enableUnrealBloomPass(t)}));let d=this.gui.addFolder("Performance");d.add(n,"enableFastOperation",n.enableFastOperation).name("Enable Fast Operation").onChange((t=>{e.enableFastOperation=t,e.enableRender()})).setValue(e.enableFastOperation),d.add(n,"distanceCullingFactor",10,1e3).name("Distance Culling Factor").onChange((t=>{e.setDistanceCullingFactor(t),e.enableRender()})).setValue(e.getDistanceCullingFactor())}open(){this.gui&&this.gui.open()}close(){this.gui&&this.gui.close()}destroy(){super.destroy(),this.gui&&this.gui.destroy(),this.gui=void 0}},Lye=class extends fr{constructor(e,t){super(e,{id:"LayerManagerPlugin"}),this.mouseDownPositionX=-1,this.mouseDownPositionY=-1,this.onPointerDown=e=>{let t=e.target;null!=t&&t.classList.contains("draggable")&&0===e.button&&(this.mouseDownPositionX=e.x,this.mouseDownPositionY=e.y,document.addEventListener("pointermove",this.onPointerMove),document.addEventListener("pointerup",this.onPointerUp))},this.onPointerMove=e=>{let t=this.layerMgrRoot,n=this.viewer.viewerContainer;if(!t||!n)return;let i=n.clientLeft+n.clientWidth,r=n.clientTop+n.clientHeight,a=e.x-this.mouseDownPositionX,s=e.y-this.mouseDownPositionY,o=t.offsetLeft+a,l=t.offsetTop+s;o<0&&(o=0),o>0&&o+t.clientWidth>i&&a>0&&(o=t.offsetLeft),l<0&&(l=0),l>0&&l+t.clientHeight>r&&s>0&&(l=t.offsetTop),t.style.left=`${o}px`,t.style.top=`${l}px`,this.mouseDownPositionX=e.x,this.mouseDownPositionY=e.y},this.onPointerUp=()=>{document.removeEventListener("pointermove",this.onPointerMove),document.removeEventListener("pointerup",this.onPointerUp)},this.cfg=t||{},!1!==this.cfg.visible&&this.init()}init(){let e=this.viewer;this.cfg.containerId&&(this.container=document.getElementById(this.cfg.containerId)),this.container||(this.container=e.widgetContainer),this.dxfLayersArray=e.getLayers(),this.buildPage(),this.addContent(),this.addEventHandlers()}setVisible(e){e&&!this.container&&this.init();let t=this.layerMgrRoot;"none"!==t.style.display!==e&&(e?(this.updatePage(),t.style.display=""):t.style.display="none",this.dispatchEvent("Visibilitychange",e))}show(){this.setVisible(!0)}hide(){this.setVisible(!1)}destroy(){var e,t,n;super.destroy(),null==(e=this.closeBtn)||e.removeEventListener("click",this.closePanel),null==(t=this.checkboxes)||t.forEach((e=>{e.removeEventListener("change",(()=>{this.checkboxHandler(e)}))})),null==(n=this.layerMgrRoot)||n.remove()}buildPage(){var e;this.layerMgrRoot=document.createElement("div"),this.layerMgrRoot.classList.add("layer-manager");let t=document.createElement("div");t.classList.add("header","draggable"),this.headerText=document.createElement("span"),this.headerText.innerHTML="Layers",this.headerText.classList.add("draggable"),this.closeBtn=document.createElement("span"),this.closeBtn.classList.add("close"),this.closeBtn.innerHTML="X",t.appendChild(this.headerText),t.appendChild(this.closeBtn),this.layerMgrRoot.appendChild(t),this.layerList=document.createElement("div"),this.layerList.classList.add("layer-list"),this.layerMgrRoot.appendChild(this.layerList),null==(e=this.container)||e.appendChild(this.layerMgrRoot),this.updateHeaderText()}addContent(){var e;let t='\n
\n \n Color\n   Layer name\n
\n ';if(this.dxfLayersArray){let e=this.dxfLayersArray.length>1;for(let n=0;n{let n=/[a-zA-Z0-9]/,i=e.toString(),r=t.toString();return n.test(i[0])||n.test(r[0])?i>r?1:i{e.addEventListener("change",(()=>{this.checkboxHandler(e)}))}))}generateListItem(e,t,n){return`\n
\n \n
\n ${e}\n
\n `}closePanel(){this.hide()}addEventHandlers(){var e,t;null==(e=this.closeBtn)||e.addEventListener("click",this.closePanel.bind(this)),null==(t=this.layerMgrRoot)||t.addEventListener("pointerdown",this.onPointerDown)}checkboxHandler(e){var t;if(!this.dxfLayersArray||!this.checkboxes)return;let n=this.viewer;if("toggleAllLayers"===e.id){for(let t=0;t{n.setLayerVisibility(t,e.checked,i)}))}return void(null==(t=this.checkboxes)||t.forEach((t=>t.checked=e.checked)))}let i="",r=e.value,a=r.indexOf(">");-1!==a&&(i=r.slice(1,a),r=r.slice(a+2)),i||(i=this.dxfLayersArray[0].modelId),n.setLayerVisibility(r,e.checked,i)}updatePage(){if(!this.dxfLayersArray)return;let e=this.viewer.getLayers();e.length!==this.dxfLayersArray.length&&(this.dxfLayersArray=e,this.addContent(),this.updateHeaderText())}updateHeaderText(){if(!this.dxfLayersArray||!this.headerText)return;let e=0;for(let t=0;t{this.initMaterial(),this.initRenderTarget(),this.createGroundShadowByBBox(e,t)},this.onShadowRender=()=>{var e,t,n,i,r;this.shouldUpdateShadow()&&(this.render(),null==(e=this.shadowCamera)||e.removeFromParent(),this.shadowCamera=void 0,null==(t=this.blurPlane)||t.removeFromParent(),this.blurPlane=void 0,null==(n=this.depthMaterial)||n.dispose(),this.depthMaterial=void 0,null==(i=this.horizontalBlurMaterial)||i.dispose(),this.horizontalBlurMaterial=void 0,null==(r=this.verticalBlurMaterial)||r.dispose(),this.verticalBlurMaterial=void 0)},this.cfg=t,this.viewer.addEventListener("ModelLoaded",this.onModelLoaded),this.viewer.addEventListener("BeforeRender",this.onShadowRender)}get scene(){return this.viewer.scene}get renderer(){return this.viewer.renderer}shouldUpdateShadow(){let e=!1,t=this.viewer.loadedModels.length;return this.modelCount!==t&&(this.modelCount=t,e=!0),e}initMaterial(){this.depthMaterial=new Tc,this.depthMaterial.userData.darkness={value:this.cfg.darkness},this.depthMaterial.onBeforeCompile=e=>{var t;e.uniforms.darkness=null==(t=this.depthMaterial)?void 0:t.userData.darkness,e.fragmentShader=`\n uniform float darkness;\n ${e.fragmentShader.replace("gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );","gl_FragColor = vec4( vec3( 0.0 ), ( 1.0 - fragCoordZ ) * darkness );")}\n `},this.depthMaterial.depthTest=!1,this.depthMaterial.depthWrite=!1,this.horizontalBlurMaterial=new ln(Dye),this.horizontalBlurMaterial.depthTest=!1,this.verticalBlurMaterial=new ln(Oye),this.verticalBlurMaterial.depthTest=!1}initRenderTarget(){this.renderTarget=new sr(128,128),this.renderTarget.texture.generateMipmaps=!1,this.renderTargetBlur=new sr(128,128),this.renderTargetBlur.texture.generateMipmaps=!1}createGroundShadowByBBox(e,t){var n,i,r;this.shadowGroup=new er,this.shadowGroup.name=`${e}-ground-shadow`,Hn.disableLayerChannels(this.shadowGroup,[12,11]),null==(n=this.scene)||n.add(this.shadowGroup);let{min:a,max:s}=t,o=new O;t.getSize(o),o.multiplyScalar(2);let l=new O;t.getCenter(l);let h=new ui(o.x,o.z).rotateX(Math.PI/2),c=new on({map:null==(i=this.renderTarget)?void 0:i.texture,transparent:!0,depthWrite:!1}),u=new xt(h,c);u.renderOrder=1,u.position.set(l.x,a.y,l.z),u.scale.y=-1,null==(r=this.shadowGroup)||r.add(u),this.shadowCamera=new Ur(-o.x/2,o.x/2,o.z/2,-o.z/2,-o.y/2,o.y),this.shadowCamera.position.set(l.x,a.y,l.z),this.shadowCamera.lookAt(l.x,s.y,l.z),this.shadowGroup.add(this.shadowCamera),this.blurPlane=new xt(h),this.blurPlane.position.set(l.x,a.y,l.z),this.blurPlane.visible=!1,this.shadowGroup.add(this.blurPlane)}blurShadow(e){this.renderer&&this.blurPlane&&this.renderTarget&&this.renderTargetBlur&&this.shadowCamera&&this.horizontalBlurMaterial&&this.verticalBlurMaterial&&(this.blurPlane.visible=!0,this.blurPlane.material=this.horizontalBlurMaterial,this.horizontalBlurMaterial.uniforms.tDiffuse.value=this.renderTarget.texture,this.horizontalBlurMaterial.uniforms.h.value=1*e/256,this.renderer.setRenderTarget(this.renderTargetBlur),this.renderer.render(this.blurPlane,this.shadowCamera),this.blurPlane.material=this.verticalBlurMaterial,this.verticalBlurMaterial.uniforms.tDiffuse.value=this.renderTargetBlur.texture,this.verticalBlurMaterial.uniforms.v.value=1*e/256,this.renderer.setRenderTarget(this.renderTarget),this.renderer.render(this.blurPlane,this.shadowCamera),this.blurPlane.visible=!1)}render(){if(!(this.renderer&&this.scene&&this.renderTarget&&this.shadowCamera&&this.depthMaterial))return;let e=this.scene.background;this.scene.background=null,this.scene.overrideMaterial=this.depthMaterial;let t=this.renderer.getClearAlpha();this.renderer.setClearAlpha(0),this.renderer.setRenderTarget(this.renderTarget),this.renderer.render(this.scene,this.shadowCamera),this.scene.overrideMaterial=null,this.blurShadow(this.cfg.blur),this.blurShadow(.4*this.cfg.blur),this.renderer.setRenderTarget(null),this.renderer.setClearAlpha(t),this.scene.background=e}destroy(){var e,t,n,i,r,a,s;super.destroy(),this.viewer.removeEventListener("ModelLoaded",this.onModelLoaded),this.viewer.removeEventListener("BeforeRender",this.onShadowRender),null==(e=this.shadowCamera)||e.removeFromParent(),this.shadowCamera=void 0,null==(t=this.blurPlane)||t.removeFromParent(),this.blurPlane=void 0,null==(n=this.depthMaterial)||n.dispose(),this.depthMaterial=void 0,null==(i=this.horizontalBlurMaterial)||i.dispose(),this.horizontalBlurMaterial=void 0,null==(r=this.verticalBlurMaterial)||r.dispose(),this.verticalBlurMaterial=void 0,null==(a=this.renderTarget)||a.dispose(),this.renderTarget=void 0,null==(s=this.renderTargetBlur)||s.dispose(),this.renderTargetBlur=void 0}},Fye=class extends fr{constructor(e){super(e,{id:"HotpointPlugin"}),this.onAfterRender=()=>{var e;let t=this.viewer.scene,n=this.viewer.camera;!t||!n||!this.hotpointRoot||0===this.hotpointRoot.children.length||null==(e=this.css2dRenderer)||e.render(t,n)},this.css2dRenderer=this.viewer.css2dRenderer,this.viewer.addEventListener("AfterRender",this.onAfterRender)}add(e){var t;if(this.has(e.hotpointId))return void se.warn(`[Hotpoint] Hotpoint with id '${e.hotpointId}' already exist!`);let n=e.anchorPosition,i=Tf.createHotpoint(e.html);i.position.set(n[0]||0,n[1]||0,n[2]||0),i.visible=!1!==e.visible,i.userData.hotpoint=e,this.hotpointRoot||(this.hotpointRoot=new er,this.hotpointRoot.matrixAutoUpdate=!1,this.hotpointRoot.matrixWorldAutoUpdate=!1,this.hotpointRoot.name="HotpointRoot",null==(t=this.viewer.scene)||t.add(this.hotpointRoot)),this.hotpointRoot.add(i),i.updateWorldMatrix(!1,!1),this.viewer.enableRender()}remove(e){var t,n;let i=(null==(t=this.hotpointRoot)?void 0:t.children)||[];for(let r=0;r{var n;return(null==(n=t.userData.hotpoint)?void 0:n.hotpointId)===e}))}},Ns=ji(Nye(),1),ai=ji(v1e(),1),YV={Fill:"Fill",Stroke:"Stroke",Shading:"Shading"},ec={Fill:0,Stroke:1,FillStroke:2,Invisible:3,FillAddToPath:4,StrokeAddToPath:5,FillStrokeAddToPath:6,AddToPath:7,FillStrokeMask:3,AddToPathFlag:4},y1e=16,x1e=100,$V=[1,0,0,1,0,0],ZV=[.001,0,0,.001,0,0],Pyt=["butt","round","square"],Iyt=["miter","round","bevel"],Lyt={},b1e={},E1e=new ct,Y2=new et,_1e=0,Dyt=.01,KV=class extends Er{constructor(e){if(super(),this.contentVisible=!0,this.markedContentStack=[],this.stateStack=[],this.current=new $2(1,1),this.tempSMask=null,this.pendingEOFill=!1,this.activeLayoutName="Model",this.defaultLayerId="0",this.currentLayerId="0",this.layers={0:{name:"0",id:"0",index:"0",visible:!0}},this.loadedEntityCount=0,this.viewportScale=1,this.baseTransform=new et,this.currentTransform=new et,this.transformStack=[],this.clipType=Ns.PolyFillType.pftNonZero,this.paths=[],this.pointsMaterials={},this.lineBasicMaterials={},this.meshBasicMaterials={},this.lineWithWidthCount=0,void 0===ai)throw"[PdfLoader] need load pdf.js first";"3.8.162"!==ai.version&&se.warn("[PdfLoader] The pdf.js version we are using now is 3.8.162,if not maybe wrong."),this.fontManager=e.font,ai.GlobalWorkerOptions.workerSrc=e.pdfWorker}load(e,t,n,i){this.loadAsync(e,n).then((e=>{t(e)})).catch((e=>{i(e)}))}loadAsync(e,t){return ft(this,null,(function*(){var n,i,r;let a=Mt.getUpdateProgressFunc(t),s=Mt.getUpdateSubProgressFunc(0,10,t),o=Mt.getUpdateSubProgressFunc(30,90,t);a(0);let{src:l}=e;this.modelCfg=e;let h=e.modelId||l,c=Date.now(),u=ai.getDocument(l);u.onProgress=s;let d=yield u.promise;this.pdf=d,se.info(`[PdfLoader] Pdf document loaded in ${(Date.now()-c)/1e3}s`),c=Date.now(),se.log(d),this.pdfDocumentGroup=new er,this.pdfDocumentGroup.name=`PdfDocument-${h}`,this.optionalContentConfig=yield d.getOptionalContentConfig(),d.numPages>1&&se.info("[PdfLoader] Only the first page can be render others will be ignore.");let p=yield d.getPage(1);a(20),se.info(`[PdfLoader] Pdf page loaded in ${(Date.now()-c)/1e3}s`),c=Date.now(),se.log(p),this.pdfPage=p,this.pdfPageGroup=new er,this.pdfPageGroup.name=KV.MODEL_LAYOUT_NAME,this.pdfDocumentGroup.add(this.pdfPageGroup),this.commonObjs=d._transport.commonObjs,this.objs=p.objs,yield null==(n=this.fontManager)?void 0:n.getFontFromIndexeddb(),se.log("[PdfLoader] Font loaded.");let f=p.view,m=8192/Math.max(f[2]-f[0],f[3]-f[1]),g=Math.min(300/72,m),v=p.getViewport({scale:g});return this.beginDrawing(v),this.current=new $2(v.width,v.height),yield this.buildLayers(p),a(30),yield this.getOperatorList(o),null!=(i=this.fontManager)&&i.missingFonts&&se.warn("[PdfLoader] Missing fonts and reference count:",null==(r=this.fontManager)?void 0:r.missingFonts,", used other fonts instead."),this.lineWithWidthCount>0&&se.warn(`[PdfLoader] Found ${this.lineWithWidthCount} line(s) with width, line width is not supported and was ignored.`),a(100),se.info(`[PdfLoader] Loaded '${e.src}' in ${(Date.now()-c)/1e3}s, adding to scene...`),{modelId:h,pdfData:{threejsObject:this.pdfDocumentGroup,layers:this.layers||[],layersAndThreejsObjects:this.layersAndThreejsObjects,loadedEntityCount:this.loadedEntityCount}}}))}getOperatorList(e){return ft(this,null,(function*(){let t=this.pdfPage;if(!t)return;let n,i=ai.AnnotationMode.ENABLE,r=t._transport.getRenderingIntent("display",i,null,!0),a=t._intentStates.get(r.cacheKey);return a||(a=Object.create(null),t._intentStates.set(r.cacheKey,a)),a.opListReadCapability||(n=Object.create(null),n.operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(n))},a.opListReadCapability=new ai.PromiseCapability,(a.renderTasks||(a.renderTasks=new Set)).add(n),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null}),yield this._pumpOperatorList(r,e)}))}_pumpOperatorList(e,t){return ft(this,null,(function*(){var n,i;let r=this.pdfPage;if(!r)return;let{renderingIntent:a,cacheKey:s,annotationStorageSerializable:o}=e,{map:l,transfers:h}=o,c=r._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:r._pageIndex,intent:a,cacheKey:s,annotationStorage:l},h).getReader(),u=r._intentStates.get(s);for(u.streamReader=c;;)try{let{value:e,done:a}=yield c.read();if(a)return void(u.streamReader=null);if(r._transport.destroyed)return;let s=e;yield this.executeOperatorList(s,t),null==(n=this.pdfPageGroup)||n.updateMatrixWorld(!0),null!=(i=this.modelCfg)&&i.merge&&this.mergePdfObjects(),s.lastChunk&&this.endDrawing()}catch(e){if(u.streamReader=null,r._transport.destroyed)return;if(u.operatorList){u.operatorList.lastChunk=!0;for(let e of u.renderTasks)e.operatorListChanged();this.tryCleanup()}if(u.displayReadyCapability)u.displayReadyCapability.reject(e);else{if(!u.opListReadCapability)throw e;u.opListReadCapability.reject(e)}}}))}tryCleanup(){let e=this.pdfPage;e&&e._intentStates.clear()}mergePdfObjects(){for(let e in this.layersAndThreejsObjects){let t=this.layersAndThreejsObjects[e];if(t.length<=1)continue;let n=Ar.deepMerge(t,this.pdfPageGroup,!1,!1,!1),i=n.added,r=n.removed;r.forEach((e=>{var t,n;null==(t=this.pdfPageGroup)||t.remove(e);let i=e;i.geometry.dispose(),i.material.dispose(),null==(n=i.material.map)||n.dispose()})),i.forEach((e=>{var t;null==(t=this.pdfPageGroup)||t.add(e)}));let a=t.filter((e=>!r.includes(e)));a.push(...i),this.layersAndThreejsObjects[e]=a}}getPointsMaterial(e,t=1){return this.pointsMaterials[`${e}-${t}`]||(this.pointsMaterials[`${e}-${t}`]=new xi({color:e,transparent:!0,opacity:t})),this.pointsMaterials[`${e}-${t}`]}getLineBasicMaterial(e,t=1){return this.lineBasicMaterials[`${e}-${t}`]||(this.lineBasicMaterials[`${e}-${t}`]=new Gn({color:e,transparent:!0,opacity:t})),this.lineBasicMaterials[`${e}-${t}`]}getMeshBasicMaterial(e,t=1){return this.meshBasicMaterials[`${e}-${t}`]||(this.meshBasicMaterials[`${e}-${t}`]=new on({color:e,transparent:!0,opacity:t,side:Sr})),this.meshBasicMaterials[`${e}-${t}`]}getTransformByMatrix4(e){return[e.elements[0],e.elements[1],e.elements[4],e.elements[5],e.elements[12],e.elements[13]]}getObject(e,t=null){return"string"==typeof e?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):t}beginDrawing(e){var t,n,i;se.log("beginDrawing",e),this.viewportScale=e.scale;let[r,a,s,o,l,h]=e.transform;this.baseTransform.set(r,s,0,l,a,o,0,h,0,0,1,0,0,0,0,1),this.currentTransform.copy(this.baseTransform),null==(t=this.pdfDocumentGroup)||t.applyMatrix4(this.baseTransform),null==(n=this.pdfDocumentGroup)||n.rotateZ(An.degToRad(-e.rotation));let{width:c,height:u}=e,d=(new Dt).setFromPoints([new O(0,0,0),new O(c,0,0),new O(c,u,0),new O(0,0,0),new O(c,u,0),new O(0,u,0)]),p=new on({color:16777215}),f=new xt(d,p);f.renderOrder=-999,null==(i=this.pdfDocumentGroup)||i.add(f)}endDrawing(){var e;null==(e=this.pdfPageGroup)||e.updateMatrixWorld(!0),this.tryCleanup(),this.releaseData()}releaseData(){var e;null==(e=this.fontManager)||e.releaseFontData(),this.operatorList=void 0,this.optionalContentConfig=void 0,this.commonObjs=void 0,this.objs=void 0,this.pdfPage=void 0,this.pdf=void 0}buildLayers(e){return ft(this,null,(function*(){if(!this.pdf)return;let t=yield e.getOperatorList(),n=t.fnArray,i=t.argsArray,r={},a=1;for(let e=0;n&&e1&&this.lineWithWidthCount++}setLineCap(e){se.log("setLineCap",Pyt[e]),this.current.lineCap=e}setLineJoin(e){se.log("setLineJoin",Iyt[e]),this.current.lineJoin=e}setMiterLimit(e){se.log("setMiterLimit",e),this.current.miterLimit=e}setDash(e,t){se.log("setDash",e,t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(let[t,n]of e)switch(t){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n[0],n[1]);break;case"CA":this.current.strokeAlpha=n;break;case"ca":this.current.fillAlpha=n;break;case"BM":case"TR":break;case"SMask":this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null}}save(){se.log("[PdfLoader] ================save");let e=this.current;this.transformStack.push(this.currentTransform.clone()),this.stateStack.push(e),this.current=e.clone()}restore(){se.log("[PdfLoader] ================restore"),0!==this.stateStack.length&&(this.current=this.stateStack.pop()),0!==this.transformStack.length&&this.currentTransform.copy(this.transformStack.pop()),this.pendingClip=null,this.paths=[]}transform(e,t,n,i,r,a){let s=Y2.set(e,n,0,r,t,i,0,a,0,0,1,0,0,0,0,1);this.currentTransform.multiply(s)}moveTo(){}lineTo(){}curveTo(){}curveTo2(){}curveTo3(){}closePath(){this.currentPath&&this.currentPath.curves.length>0&&(this.currentPath.closePath(),this.paths.push(this.currentPath.clone()),this.currentPath=void 0)}rectangle(){}stroke(e=!0){if(this.contentVisible){let e=this.current.strokeColor,t=this.current.strokeAlpha,n=[],i=[];for(let r=0;r0){let i=Ni(n),r=new ii(i,this.getPointsMaterial(e,t));this.addObjectToModel(r)}if(i.length>0){let n=Ni(i),r=new hr(n,this.getLineBasicMaterial(e,t));this.addObjectToModel(r)}}e&&this.consumePath(this.current.getClippedPathBoundingBox())}closeStroke(){this.closePath(),this.stroke()}fill(e=!0){if(0===this.paths.length)return;this.current.patternFill&&se.warn("[PdfLoader] fill pattern not supported now.");let t=this.current.getClippedPathBoundingBox();if(this.contentVisible&&null!==t){let e,t=[];if(this.clipPaths){let e=new Ns.PolyTree,n=new Ns.Clipper,i=this.paths.map((e=>e.getPoints().map((e=>({X:e.x,Y:e.y}))))),r=this.clipPaths.map((e=>e.getPoints().map((e=>({X:e.x,Y:e.y}))))),a=100;Ns.JS.ScaleUpPaths(i,a),Ns.JS.ScaleUpPaths(r,a),n.AddPaths(i,Ns.PolyType.ptSubject,!0),n.AddPaths(r,Ns.PolyType.ptClip,!0),n.Execute(Ns.ClipType.ctIntersection,e,this.pendingEOFill?Ns.PolyFillType.pftEvenOdd:Ns.PolyFillType.pftNonZero,this.clipType);let s=Ns.JS.PolyTreeToExPolygons(e);for(let o=0;onew be(e.X/a,e.Y/a)))),n.length>0&&n.forEach((e=>{let t=new Ss;t.setFromPoints(e.map((e=>new be(e.X/a,e.Y/a)))),i.holes.push(t)})),t.push(i)}this.clipPaths=void 0}e=t.length>0?new Al(t):Ni(this.paths.map((e=>new Al(e)))),e.applyMatrix4(this.currentTransform);let n=this.current.fillColor,i=this.current.fillAlpha,r=new xt(e,this.getMeshBasicMaterial(n,i));this.addObjectToModel(r),this.pendingEOFill=!1}e&&this.consumePath(t)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Lyt}eoClip(){this.pendingClip=b1e}beginText(){this.current.textMatrix=$V,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){this.currentPath=new Ss}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,t){var n;let i=this.commonObjs.get(e),r=this.current;if(!i)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=i.fontMatrix||ZV,(0===r.fontMatrix[0]||0===r.fontMatrix[3])&&se.warn("Invalid font matrix for font "+e),t<0?(t=-t,r.fontDirection=-1):r.fontDirection=1,this.current.font=i,this.current.fontSize=t,i.isType3Font)return;let a=i.loadedName||"sans-serif",s=(null==(n=i.systemFontInfo)?void 0:n.css)||`"${a}", ${i.fallbackName}`,o="normal";i.black?o="900":i.bold&&(o="bold");let l=i.italic?"italic":"normal",h=t;tx1e&&(h=x1e),this.current.fontSizeScale=t/h,this.current.browserFontSize=h,se.log(`[PdfLoader] font: ${l} ${o} ${h}px ${s}`),se.log(`[PdfLoader] current font is: ${i.name}`)}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(){}setTextMatrix(e,t,n,i,r,a){this.current.textMatrix=[e,t,n,i,r,a],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(e,t,n){var i,r,a,s;se.log("paintChar",e,t,n);let o,l,h=this.current,c=h.font,u=h.textRenderingMode,d=h.fontSize/h.fontSizeScale,p=u&ec.FillStrokeMask,f=!!(u&ec.AddToPathFlag),m=h.patternFill&&!c.missingFile;return(c.disableFontFace||f||m)&&(o=c.getPathGenerator(this.commonObjs,e)),c.disableFontFace||m?se.log("paintChar path:",o,d,p):((p===ec.Fill||p===ec.FillStroke)&&(l=null==(r=this.fontManager)?void 0:r.getCharShape(e,null==(i=this.current.font)?void 0:i.name,.8*this.current.browserFontSize)),(p===ec.Stroke||p===ec.FillStroke)&&(l=null==(s=this.fontManager)?void 0:s.getCharShape(e,null==(a=this.current.font)?void 0:a.name,.8*this.current.browserFontSize))),l}showText(e){var t,n;let i=this.current,r=i.font;if(r.isType3Font)return this.showType3Text(e);let a=i.fontSize;if(0===a)return;let s=i.fontSizeScale,o=i.charSpacing,l=i.wordSpacing,h=i.fontDirection,c=i.textHScale*h,u=e.length,d=r.vertical,p=d?1:-1,f=r.defaultVMetrics,m=a*i.fontMatrix[0],g=i.textRenderingMode===ec.Fill&&!r.disableFontFace&&!i.patternFill,[v,y,x,b,_,w]=i.textMatrix,S=this.currentTransform.clone();S.multiply(Y2.set(v,x,0,_,y,b,0,w,0,0,1,0,0,0,0,1)),S.multiply(Y2.makeTranslation(i.x,i.y+i.textRise,0)),h>0?S.scale(new O(c,1,1)):S.scale(new O(c,-1,1));let M=i.lineWidth,T=i.textMatrixScale;0===T||0===M?(i.textRenderingMode&ec.FillStrokeMask)===ec.Stroke||ec.FillStroke:M/=T,1!==s&&(S.scale(new O(s,s,1)),M/=s);let E,A=0,C=[];for(E=0;E0){let e,t=C[0]instanceof ta,n=Ni(C);e=t?new xt(n,this.getMeshBasicMaterial(this.current.fillColor)):new Wr(n,this.getLineBasicMaterial(this.current.fillColor)),e&&(this.addObjectToModel(e),e.layers.disable(11))}d?i.y-=A:i.x+=A*c}showType3Text(e){}setCharWidth(e,t){}setCharWidthAndBounds(e,t,n,i,r,a){}setStrokeColor(){}setStrokeColorN(){}setFillColorN(){this.current.patternFill=!0}setStrokeRGBColor(e,t,n){se.log("setStrokeRGBColor",[e,t,n]),this.current.strokeColor=E1e.setRGB(e/255,t/255,n/255).convertSRGBToLinear().getHex()}setFillRGBColor(e,t,n){se.log("setFillRGBColor",[e,t,n]),this.current.fillColor=E1e.setRGB(e/255,t/255,n/255).convertSRGBToLinear().getHex(),this.current.patternFill=!1}shadingFill(){}beginInlineImage(){}beginImageData(){}markPoint(e){}markPointProps(e,t){}beginMarkedContent(e){se.log("beginMarkedContent",e),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t){if("OC"===e){this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(t)});let e=this.optionalContentConfig.getGroup(null==t?void 0:t.id);this.currentLayerId=(null==e?void 0:e.name)||this.defaultLayerId,se.log("current layer:",null==e?void 0:e.name)}else this.markedContentStack.push({visible:!0});this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(e){let t=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip,this.pendingClip&&(t||(this.pendingClip===b1e?this.clipType=Ns.PolyFillType.pftEvenOdd:this.clipType=Ns.PolyFillType.pftNonZero,this.clipPaths=this.paths.slice()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),this.paths=[],this.currentPath=void 0}paintFormXObjectBegin(e,t){se.log("paintFormXObjectBegin",e,t)}paintFormXObjectEnd(){}beginGroup(){}endGroup(){}beginAnnotation(){}endAnnotation(){}paintImageMaskXObject(){}paintImageMaskXObjectGroup(){}paintImageXObject(e){if(!this.contentVisible)return;let t=this.getObject(e);t?this.paintInlineImageXObject(t):se.warn("Dependent image isn't ready yet")}paintInlineImageXObject(e){if(!this.contentVisible)return;se.log("paintInlineImageXObject",e),this.save();let{bitmap:t,width:n,height:i}=e;this.currentTransform.multiply(Y2.makeScale(1/n,-1/i,1));let r=new Eb(t),a=new on({map:r,transparent:!0}),s=new ui(n,i),o=new xt(s,a);o.translateX(n/2),o.translateY(-i/2),o.applyMatrix4(this.currentTransform),this.addObjectToModel(o),this.restore()}paintInlineImageXObjectGroup(){}paintImageXObjectRepeat(){}paintImageMaskXObjectRepeat(){}paintSolidColorImageMask(){}_scaleImage(e,t){let n=e.width,i=e.height,r=Math.max(Math.hypot(t.elements[0],t.elements[4]),1),a=Math.max(Math.hypot(t.elements[1],t.elements[5]),1),s=n,o=i,l=s,h=o;for(;r>2&&s>1||a>2&&o>1;)r>2&&s>1&&(l=s>=16384?Math.floor(s/2)-1||1:Math.ceil(s/2),r/=s/l),a>2&&o>1&&(h=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o)/2,a/=o/h),s=l,o=h;return{paintWidth:s,paintHeight:o}}constructPath(e,t,n){let i,r,a=this.current,s=a.x,o=a.y,l=[this.currentTransform.elements[0],this.currentTransform.elements[1],this.currentTransform.elements[4],this.currentTransform.elements[5],this.currentTransform.elements[12],this.currentTransform.elements[13]],h=0===l[0]&&0===l[3]||0===l[1]&&0===l[2],c=h?n.slice(0):null;for(let u=0,d=0,p=e.length;u=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}},ah=KV;ah.MODEL_LAYOUT_NAME="Model";for(let t in ai.OPS)void 0!==ah.prototype[t]&&(ah.prototype[ai.OPS[t]]=ah.prototype[t]);var $2=class{constructor(e,t){this.textMatrix=$V,this.fontMatrix=ZV,this.textRenderingMode=ec.Fill,this.fillColor=0,this.strokeColor=0,this.activeSMask=null,this.lineCap=0,this.lineJoin=0,this.miterLimit=0,this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.browserFontSize=1,this.textMatrix=$V,this.textMatrixScale=1,this.fontMatrix=ZV,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=ec.Fill,this.textRise=0,this.fillColor=0,this.strokeColor=0,this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.ctxMatrix=new Ln,this.clipBox=[0,0,e,t],this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}clone(){return Object.create(this)}setCurrentPoint(e,t){this.x=e,this.y=t}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}updatePathMinMax(e,t,n){[t,n]=ai.Util.applyTransform([t,n],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,n)}getPathBoundingBox(e=YV.Fill,t=null){let n=[this.minX,this.minY,this.maxX,this.maxY];if(e===YV.Stroke){if(!t)throw new Error("Stroke bounding box must include transform.");let e=ai.Util.singularValueDecompose2dScale(t),i=e[0]*this.lineWidth/2,r=e[1]*this.lineWidth/2;n[0]-=i,n[1]-=r,n[2]+=i,n[3]+=r}return n}updateRectMinMax(e,t){let n=ai.Util.applyTransform(t,e),i=ai.Util.applyTransform(t.slice(2),e);this.minX=Math.min(this.minX,n[0],i[0]),this.minY=Math.min(this.minY,n[1],i[1]),this.maxX=Math.max(this.maxX,n[0],i[0]),this.maxY=Math.max(this.maxY,n[1],i[1])}updateScalingPathMinMax(e,t){ai.Util.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.maxX=Math.max(this.maxX,t[1]),this.minY=Math.min(this.minY,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,n,i,r,a,s,o,l,h){let c=ai.Util.bezierBoundingBox(t,n,i,r,a,s,o,l);if(h)return h[0]=Math.min(h[0],c[0],c[2]),h[1]=Math.max(h[1],c[0],c[2]),h[2]=Math.min(h[2],c[1],c[3]),void(h[3]=Math.max(h[3],c[1],c[3]));this.updateRectMinMax(e,c)}updateClipFromPath(){let e=ai.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}getClippedPathBoundingBox(e=YV.Fill,t=null){return ai.Util.intersect(this.clipBox,this.getPathBoundingBox(e,t))||[]}},T1e=class extends fr{constructor(e,t){super(e,{id:"PdfLoaderPlugin"}),this.cfg=t||{}}loadAsync(e,t){return ft(this,null,(function*(){let n=this.viewer;n.increaseJobCount();let i=this.cfg.font,r=this.cfg.pdfWorker,a=yield new ah({font:i,pdfWorker:r}).loadAsync(e,t);return n.decreaseJobCount(),a}))}},w1e=class extends up{constructor(e,t){super(t),this.pdfWorker="",this.defaultModelConfig={src:"",merge:!0},this.viewer=e}setPdfWorker(e){this.pdfWorker=e}formats(){return["dxf","pdf"]}uploadFiles(e){for(let t=0;t{let n=Math.floor(100*t.loaded/t.total);se.info(`[Uploader] Loading ${null==e?void 0:e.name}, ${n}%`)}))}))}uploadSinglePdf(e){return ft(this,null,(function*(){let t=t=>{let n=Math.floor(100*t.loaded/t.total);se.info(`[Uploader] Loading ${null==e?void 0:e.name}, ${n}%`)};try{let n=this.viewer;n.increaseJobCount();let i={font:n.fontManager,pdfWorker:this.pdfWorker},r={merge:!0,src:URL.createObjectURL(e),modelId:e.name};new ah(i).loadAsync(r,t).then((e=>{this.viewer.addModel(e),this.onSuccess&&this.onSuccess({}),n.decreaseJobCount(),se.info(`[Uploader] Loaded model '${r.src}'`)}))}catch(e){se.info(e)}}))}},S1e=class extends up{constructor(e,t){super(t),this.viewer=e}formats(){return["png","jpg","jpeg"]}uploadFiles(e){let t={panoramas:[],id:"viewpoint_1",name:"",position:[0,1,0],initialDirection:[0,0,1]};if(1===e.length){let n=[];n.push(URL.createObjectURL(e[0])),t.panoramas.push({id:"panorama_1",images:n}),this.viewer.setViewpoints([t]),this.viewer.activatePanoramaById(t.id,t.panoramas[0].id)}else if(6===e.length){let n=t=>{let n="";for(let i=0;i({position:new O(e,t,n),rotation:new Xn(i,r,a)}),Oyt={Front:Ri(Tr({},Zs([0,0,1],[0,0,0])),{label:"NavCube.front"}),Right:Ri(Tr({},Zs([1,0,0],[0,mi,0])),{label:"NavCube.right"}),Back:Ri(Tr({},Zs([0,0,-1],[0,Math.PI,0])),{label:"NavCube.back"}),Left:Ri(Tr({},Zs([-1,0,0],[0,-mi,0])),{label:"NavCube.left"}),Top:Ri(Tr({},Zs([0,1,0],[-mi,0,0])),{label:"NavCube.top"}),Bottom:Ri(Tr({},Zs([0,-1,0],[mi,0,0])),{label:"NavCube.bottom"})},kyt=[Zs([0,1,1],[-Vr,0,-mi]),Zs([0,1,-1],[-3*Vr,0,-mi]),Zs([0,-1,1],[Vr,0,-mi]),Zs([0,-1,-1],[3*Vr,0,-mi]),Zs([1,1,0],[-mi,Vr,0]),Zs([1,-1,0],[-mi,3*Vr,0]),Zs([-1,1,0],[-mi,-Vr,0]),Zs([-1,-1,0],[-mi,-3*Vr,0]),Zs([1,0,1],[0,Vr,0]),Zs([1,0,-1],[0,3*Vr,0]),Zs([-1,0,1],[0,-Vr,0]),Zs([-1,0,-1],[0,-3*Vr,0])],Fyt=[{position:new O(1,1,1),rotation:[new Xn(-mi,mi,-Vr),new Xn(-mi,0,Vr),new Xn(0,0,3*Vr)]},{position:new O(1,1,-1),rotation:[new Xn(0,mi,3*Vr),new Xn(-mi,0,3*Vr),new Xn(0,Math.PI,-3*Vr)]},{position:new O(-1,1,-1),rotation:[new Xn(Math.PI,-mi,Vr),new Xn(-mi,0,-3*Vr),new Xn(0,Math.PI,3*Vr)]},{position:new O(-1,1,1),rotation:[new Xn(0,-mi,3*Vr),new Xn(-mi,0,-Vr),new Xn(0,0,-3*Vr)]},{position:new O(1,-1,1),rotation:[new Xn(0,mi,-Vr),new Xn(-mi,Math.PI,-Vr),new Xn(0,0,Vr)]},{position:new O(1,-1,-1),rotation:[new Xn(-mi,mi,3*Vr),new Xn(mi,0,Vr),new Xn(0,Math.PI,-Vr)]},{position:new O(-1,-1,1),rotation:[new Xn(0,-mi,Vr),new Xn(mi,0,-3*Vr),new Xn(0,0,-Vr)]},{position:new O(-1,-1,-1),rotation:[new Xn(0,-mi,-Vr),new Xn(mi,0,-Vr),new Xn(0,Math.PI,Vr)]}],Z2=class extends an{constructor(e={}){super(),this.NAVCUBE_SIZE=100,this.clickHandler=e.onClick,(0,fg.forEach)(Oyt,(e=>{this.createPlane(e)})),(0,fg.forEach)(kyt,(e=>{this.createEdge(e)})),(0,fg.forEach)(Fyt,((e,t)=>{this.createCorner(e,t)}))}createPlane(e){let t=e.position.clone().multiplyScalar(this.NAVCUBE_SIZE/2),{rotation:n,label:i}=e,r=document.createElement("div");r.style.width=this.NAVCUBE_SIZE+"px",r.style.height=this.NAVCUBE_SIZE+"px",r.classList.add("navcube-plane"),r.classList.add("outer");let a=document.createElement("div");a.style.width=this.NAVCUBE_SIZE-4+"px",a.style.height=this.NAVCUBE_SIZE-4+"px",a.innerHTML=eh(i),a.classList.add("navcube-plane"),a.classList.add("inner"),r.appendChild(a);let s=new cg(r);s.position.copy(t),s.rotation.copy(n),this.add(s),r.addEventListener("click",(()=>{this.clickHandler&&this.clickHandler(t.clone().normalize(),n)}))}createEdge(e){let t=e.position.clone().multiplyScalar(this.NAVCUBE_SIZE/2),n=document.createElement("div");n.style.width="4px",n.style.height=this.NAVCUBE_SIZE-40+"px",n.style.background=M1e,n.classList.add("navcube-edge");let i=new cg(n);i.position.copy(t),i.rotation.copy(e.rotation),this.add(i),n.addEventListener("click",(()=>{this.clickHandler&&this.clickHandler(t.clone().normalize(),e.rotation)}))}createCorner(e,t){let n=n=>{n.addEventListener("click",(()=>{this.clickHandler&&this.clickHandler(e.position.clone().normalize(),new Xn)})),n.addEventListener("mouseenter",(()=>{let e=document.getElementsByClassName("group-"+t);(0,fg.forEach)(e,(e=>{e instanceof HTMLElement&&e.classList.add("highlight")}))})),n.addEventListener("mouseleave",(()=>{let e=document.getElementsByClassName("group-"+t);(0,fg.forEach)(e,(e=>{e instanceof HTMLElement&&e.classList.remove("highlight")}))}))},i=e.position.clone().multiplyScalar(this.NAVCUBE_SIZE/2+.5),r=document.createElement("div");r.style.borderTop=14*Math.sqrt(3)+"px solid #efefef",r.style.borderLeft="14px solid transparent",r.style.borderRight="14px solid transparent",r.classList.add("navcube-corner"),r.classList.add("group-"+t);let a=new cg(r);a.position.copy(i).lerp(e.position,.14);let s=Math.atan2(i.z,i.x);a.rotateY(i.z*i.x<0?Math.PI+s:s);let o=(new Xn).setFromVector3(i.clone().normalize());a.rotateX(-o.y),i.y<0&&a.rotateZ(Math.PI),this.add(a);let l=(t,r,a)=>{let s=document.createElement("div");s.style.borderTop=`13px solid ${M1e}`,s.style.borderLeft="13px solid transparent",s.style.borderRight="13px solid transparent",s.classList.add("navcube-corner-plane"),s.classList.add("group-"+r);let o=new cg(s),l=e.position.clone();l.setComponent(a,0),o.position.copy(i).sub(l),o.rotateX(t.x),o.rotateY(t.y),o.rotateZ(t.z),this.add(o),n(s)};(0,fg.forEach)(e.rotation,((e,n)=>{l(e,t,n)})),n(r)}},R1e=class extends fr{constructor(e,t){super(e,{id:"NavCubePlugin"}),this.cfg=t||{},this.init()}init(){this.initRenderer(),this.initScene(),this.animate()}initRenderer(){var e;let t,n=135,i=135;if(this.cfg.containerId&&(t=document.getElementById(this.cfg.containerId),t&&(n=t.clientWidth,i=t.clientHeight)),!t){let n="navCube";t=document.createElement("div"),t.id=n,null==(e=this.viewer.widgetContainer)||e.appendChild(t)}this.renderer=new m2,this.renderer.setSize(n,i),this.renderer.domElement.classList.add("css3d-navcube"),t.appendChild(this.renderer.domElement)}initScene(){this.scene=new _i;let e=window.innerWidth/window.innerHeight;this.camera=new Ur(200*e/-2,200*e/2,100,-100,1,1e3),this.camera.position.set(-200,200,200),this.scene.add(this.camera),this.navCube=new Z2({onClick:e=>{let t=this.viewer.controls;if(!(this.camera&&e&&this.viewer.camera&&t))return;let n=t instanceof ba?t.getTarget(new O):t.target,i=this.viewer.camera.position.distanceTo(n);this.viewer.flyTo(n.clone().add(e.clone().multiplyScalar(i)),n)}}),this.scene.add(this.navCube)}render(){this.renderer&&this.scene&&this.camera&&(this.update(),this.renderer.render(this.scene,this.camera))}animate(){requestAnimationFrame(this.animate.bind(this)),this.render()}update(){if(!this.viewer||!this.viewer.camera)return;let e=this.viewer.camera;if(e){let t=new O;e.getWorldDirection(t);let n=e.up;this.updateCameraDirection(t,n)}}updateCameraDirection(e,t){this.camera&&e&&(e.normalize(),this.camera.position.set(20*-e.x+0,20*-e.y+0,20*-e.z+0),this.camera.lookAt(0,0,0),this.camera.up=t)}destroy(){super.destroy(),this.scene&&this.camera&&this.navCube&&(this.scene.clear(),this.camera=void 0,this.navCube=void 0,this.scene=void 0)}},X_=function(){var e=0,t=document.createElement("div");function n(e){return t.appendChild(e.dom),e}function i(n){for(var i=0;i=a+1e3&&(o.update(1e3*s/(e-a),100),a=e,s=0,h)){var t=performance.memory;h.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){r=this.end()},domElement:t,setMode:i}};X_.Panel=function(e,t,n){var i=1/0,r=0,a=Math.round,s=a(window.devicePixelRatio||1),o=80*s,l=48*s,h=3*s,c=2*s,u=3*s,d=15*s,p=74*s,f=30*s,m=document.createElement("canvas");m.width=o,m.height=l,m.style.cssText="width:80px;height:48px";var g=m.getContext("2d");return g.font="bold "+9*s+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=n,g.fillRect(0,0,o,l),g.fillStyle=t,g.fillText(e,h,c),g.fillRect(u,d,p,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(u,d,p,f),{dom:m,update:function(l,v){i=Math.min(i,l),r=Math.max(r,l),g.fillStyle=n,g.globalAlpha=1,g.fillRect(0,0,o,d),g.fillStyle=t,g.fillText(a(l)+" "+e+" ("+a(i)+"-"+a(r)+")",h,c),g.drawImage(m,u+s,d,p-s,f,u,d,p-s,f),g.fillRect(u+p-s,d,s,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(u+p-s,d,s,a((1-l/v)*f))}}};var A1e=X_,C1e=class extends fr{constructor(e){super(e,{id:"StatsPlugin"}),this.init()}init(){var e;let t=new A1e;t.setMode(0);let n=document.createElement("div");n.classList.add("statsOutput"),n.appendChild(t.domElement),null==(e=this.viewer.widgetContainer)||e.append(n),this.stats=t,this.viewer.addEventListener("OnAnimate",(()=>{var e;null==(e=this.stats)||e.update()}))}show(){var e;null==(e=this.stats)||e.showPanel(0)}hide(){var e;null==(e=this.stats)||e.showPanel(-1)}destroy(){super.destroy(),this.stats=void 0}},Y_=class extends xt{constructor(e,t,n,i=4e3,r=32,a=15,s=new O,o=new O(0,.7,.5)){super();let l={topColor:{value:e},skylineColor:{value:t},bottomColor:{value:n},offset:{value:400},exponent:{value:.9},skyCenter:{value:s||new O},sunDirection:{value:o.normalize()}};this.geometry=new za(i,r,a),this.material=new ln({uniforms:l,vertexShader:Y_.vertexShader,fragmentShader:Y_.fragmentShader,side:Ki}),this.name=Y_.NAME,this.matrixAutoUpdate=!1,this.layers.disable(12)}},il=Y_;il.NAME="SKYBOX",il.MIN_SKY_RADIUS=4e3,il.MAX_SKY_RADIUS=2e4,il.vertexShader="\n varying vec3 vWorldPosition;\n void main() {\n vec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n vWorldPosition = worldPosition.xyz;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",il.fragmentShader="\n uniform vec3 topColor;\n uniform vec3 skylineColor;\n uniform vec3 bottomColor;\n uniform float offset;\n uniform float exponent;\n uniform vec3 skyCenter;\n uniform vec3 sunDirection;\n varying vec3 vWorldPosition;\n // Used to find the position to draw the sun. Sun size is bigger when this value is smaller\n const float sunDirectionDotThreshold = 0.98;\n\n void main() {\n vec3 position = vec3(vWorldPosition.x - skyCenter.x, vWorldPosition.y - skyCenter.y, vWorldPosition.z - skyCenter.z);\n vec3 normalizedPosition = normalize( position + offset );\n float h = normalizedPosition.y;\n vec3 color;\n if (h > 0.0) {\n color = mix( skylineColor, topColor, pow( h, exponent ) );\n\n // draw the sun\n float dotResult = dot(sunDirection, normalizedPosition);\n if (dotResult > sunDirectionDotThreshold) {\n const float sunSize = 1.0 - sunDirectionDotThreshold; // maximum sun size\n const vec3 sunColor = vec3(1.0, 1.0, 1.0);\n color = mix(color, sunColor, pow((dotResult + sunSize - 1.0) / sunSize, 3.0));\n }\n } else {\n color = mix( skylineColor, bottomColor, pow( -h, exponent ) );\n }\n gl_FragColor = vec4(color , 1.0);\n }";var P1e=class extends fr{constructor(e,t){super(e,{id:"SkyboxPlugin"}),null!=t&&t.color?this.setSkyboxByColor(t.color):this.setSkyboxByGradientColors(),e.addEventListener("ModelLoaded",(()=>{let t=e.getBBox(),n=this.viewer.cameraCfg;if(t){if(t=t.clone(),n&&n.eye&&n.look){let e=n&&Mt.arrayToVector3(n.eye),i=n&&Mt.arrayToVector3(n.look),r=new Ot;r.setFromPoints([e,i]),t.union(r)}this.updateGradientColorSkybox(t)}}))}setSkyboxByColor(e=[.92,.95,.96]){let t=this.viewer;!t||!t.scene||(this.gradientColorSkybox&&(this.gradientColorSkybox.visible=!1),t.scene.background=this.rgb2Color(e),t.enableRender())}setSkyboxByGradientColors(e=[.52,.71,.96],t=[1,1,1],n=[.6,.6,.6]){var i;this.gradientColorSkybox&&(this.gradientColorSkybox.removeFromParent(),this.gradientColorSkybox=void 0);let r=this.rgb2Color(e),a=this.rgb2Color(t),s=this.rgb2Color(n);this.gradientColorSkybox=new il(r,a,s),null==(i=this.viewer.scene)||i.add(this.gradientColorSkybox),this.viewer.enableRender()}setSkyboxByCubeTexture(e){let t=this.viewer;if(!t||!t.scene)return;this.gradientColorSkybox&&(this.gradientColorSkybox.visible=!1);let n=new Pb;t.scene.background=n.load(e),t.enableRender()}updateGradientColorSkybox(e){if(!this.gradientColorSkybox)return;let t=2*(e.max.x-e.min.x+(e.max.y-e.min.y)+(e.max.z-e.min.z));til.MAX_SKY_RADIUS&&(t=il.MAX_SKY_RADIUS),this.gradientColorSkybox.geometry=new za(t,32,15),this.viewer.enableRender()}destroy(){var e;super.destroy(),null==(e=this.gradientColorSkybox)||e.removeFromParent(),this.gradientColorSkybox=void 0,this.viewer.scene&&(this.viewer.scene.background=null)}rgb2Color(e){let t=e[0]||0,n=e[1]||0,i=e[2]||0,r=new ct;return r.setRGB(t,n,i),r}};function Nyt(e,t,n,i,r){let a=document.createElement("span");return a.style.font="1px serif",a.style.fontFamily=e,a.style.fontSize=`${t}px`,a.style.fontStyle=n,a.style.fontVariant=i,a.style.fontWeight=r,a.style.font}var Byt=Object.freeze({text:"",color:"#fff",alignment:"center",backgroundColor:0,fontFamily:"sans-serif",fontSize:16,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",lineGap:1/4,padding:.5,strokeColor:"#000",strokeWidth:0}),K2=class extends qr{constructor(e,t=document.createElement("canvas")){super(t),this.canvas=t,this.isTextTexture=!0,this.needsRedraw=!0,this.contentOffset=0,this.lineOffset=0,this.width=0,this.height=0,this.pixelRatio=Math.max(window.devicePixelRatio||1),this.computeOptimalPixelRatio=()=>{let e=new O,t=new be,n=new O,i=new O,r=new be;return(a,s,o)=>{var l,h;if(r.set(this.width,this.height),r.x&&r.y){a.getWorldPosition(n),o.getWorldPosition(e);let c=n.distanceTo(e);if(o.isPerspectiveCamera&&(c*=2*Math.tan(An.degToRad(o.fov)/2)),(o.isPerspectiveCamera||o.isOrthographicCamera)&&(c/=o.zoom),c){a.getWorldScale(i);let e=null!=(h=null==(l=s.capabilities)?void 0:l.maxTextureSize)?h:1/0;return s.getDrawingBufferSize(t),Math.min(Math.max(i.x/c*(t.x/r.x),i.y/c*(t.y/r.y)),e/r.x,e/r.y)}}return 0}},this.cfg=Tr(Tr({},Byt),e)}get lines(){let{text:e}=this.cfg;return e?e.split("\n"):[]}get font(){let{fontFamily:e,fontSize:t,fontStyle:n,fontVariant:i,fontWeight:r}=this.cfg;return Nyt(e,t,n,i,r)}getContentWidth(){let{font:e,lines:t}=this,n=document.createElement("canvas").getContext("2d");return n.font=e,Math.max(...t.map((e=>n.measureText(e).width)))}initDraw(){let{lineGap:e,padding:t,strokeWidth:n}=this.cfg;t*=this.cfg.fontSize,e*=this.cfg.fontSize,n*=this.cfg.fontSize;let i=this.lines.length,r=this.cfg.fontSize+e,a=t+n/2,s=(i?this.getContentWidth():0)+2*a,o=(i?this.cfg.fontSize+r*(i-1):0)+2*a;this.width=s,this.height=o,this.contentOffset=a,this.lineOffset=r}getDrawPosition(e){let t=this.contentOffset+this.cfg.fontSize/2;switch(e){case"left":return{x:this.contentOffset,y:t};case"right":return{x:this.width-this.contentOffset,y:t}}return{x:this.width/2,y:t}}draw(){let e=this.canvas.getContext("2d"),{alignment:t,backgroundColor:n,color:i,strokeColor:r,strokeWidth:a}=this.cfg;e.fillStyle="#"+n.toString(16),e.fillRect(0,0,e.canvas.width,e.canvas.height),Object.assign(e,{fillStyle:i,font:this.font,lineWidth:a,miterLimit:1,strokeStyle:r,textAlign:t,textBaseline:"middle"});let{x:s,y:o}=this.getDrawPosition(t),l=o;this.lines.forEach((t=>{e.fillText(t,s,l),a&&e.strokeText(t,s,l),l+=this.lineOffset}))}getDrawingBufferWidth(){return An.ceilPowerOfTwo(this.width*this.pixelRatio)}getDrawingBufferHeight(){return An.ceilPowerOfTwo(this.height*this.pixelRatio)}redrew(){if(this.needsRedraw){this.initDraw();let e=this.canvas,t=e.getContext("2d");t.clearRect(0,0,e.width,e.height),e.width=this.getDrawingBufferWidth(),e.height=this.getDrawingBufferHeight(),e.width&&e.height?(t.save(),t.scale(e.width/this.width,e.height/this.height),this.draw(),t.restore()):e.width=e.height=1,this.needsRedraw=!1,this.needsUpdate=!0}}setPixelRatio(e){if(this.pixelRatio!==e){let t=this.getDrawingBufferWidth(),n=this.getDrawingBufferHeight();this.pixelRatio=e;let i=this.getDrawingBufferWidth(),r=this.getDrawingBufferHeight();(i!==t||r!==n)&&(this.needsRedraw=!0)}}setOptimalPixelRatio(e,t,n){let i=this.computeOptimalPixelRatio();this.setPixelRatio(i(e,t,n))}updateConfig(e){this.cfg=Tr(Tr({},this.cfg),e),this.needsRedraw=!0}};function JV(e,t,n){let i=new ct(e),r=new ct(t);return i.lerp(r,n).getHex()}var Or=(e=>(e[e.Rotate0=0]="Rotate0",e[e.Rotate90=Math.PI/2]="Rotate90",e[e.Rotate180=Math.PI]="Rotate180",e[e.Rotate270=1.5*Math.PI]="Rotate270",e))(Or||{}),oh=new O(1,0,0),Ra=new O(0,1,0),Cs=new O(0,0,1),I1e={right:{text:"\u53f3",name:"RightFace",position:new O(50,0,0),rotation:{axis:Ra,rad:Or.Rotate90}},left:{text:"\u5de6",name:"LeftFace",position:new O(-50,0,0),rotation:{axis:Ra,rad:Or.Rotate270}},top:{text:"\u4e0a",name:"TopFace",position:new O(0,50,0),rotation:{axis:oh,rad:Or.Rotate270}},bottom:{text:"\u4e0b",name:"BottomFace",position:new O(0,-50,0),rotation:{axis:oh,rad:Or.Rotate90}},front:{text:"\u524d",name:"FrontFace",position:new O(0,0,50),rotation:{axis:Ra,rad:0}},back:{text:"\u540e",name:"BackFace",position:new O(0,0,-50),rotation:{axis:Ra,rad:Or.Rotate180}}},J2=class extends an{constructor(e){super(),this.name="ViewCube",this.AXIS_LENGTH=130,this.AXIS_COLOR_X=16711680,this.AXIS_COLOR_Y=65280,this.AXIS_COLOR_Z=255,this.FACE_BACKGROUND_COLOR=16777215,this.FACE_HOVER_BACKGROUND_COLOR=8618481,this.EDGE_COLOUR=13290452,this.EDGE_OPACITY=.1,this.EDGE_SIZE=new be(70,12),this.CORNER_WIDTH=12,this.CORNER_COLOR=13290452,this.CORNER_OPACITY=1,this.faces=[],this.dirty=!1,this.showAxes=(null==e?void 0:e.showAxes)||!1,this.lineColor=(null==e?void 0:e.lineColor)||9343125,this.init()}init(){this.showAxes&&this.add(this.createAxes()),this.add(this.createViewCubeFaces()),this.add(this.createViewCubeEdges()),this.add(this.createViewCubeCorners())}createAxes(){let e=new an,t=new O(-50,-50,-50),n=new O(1,0,0),i=new O(0,1,0),r=new O(0,0,1),a=this.AXIS_LENGTH/15,s=this.AXIS_LENGTH/20,o=new Mc(n,t,this.AXIS_LENGTH,this.AXIS_COLOR_X,a,s),l=new Mc(i,t,this.AXIS_LENGTH,this.AXIS_COLOR_Y,a,s),h=new Mc(r,t,this.AXIS_LENGTH,this.AXIS_COLOR_Z,a,s);return e.add(o,l,h),e}createViewCubeFaces(){let e=new an,t=[],n=new on({color:this.FACE_BACKGROUND_COLOR,opacity:0,transparent:!0});Object.keys(I1e).forEach((e=>{let i=I1e[e],r=new K2({text:i.text,fontSize:100,color:"#cccccc",backgroundColor:this.FACE_BACKGROUND_COLOR,padding:.8,fontWeight:"bold"});r.redrew();let a=new on({map:r,opacity:1,transparent:!0});t.push(a);let s=this.createViewCubeFace(i.name,n,i.position,i.rotation);s.layers.enableAll(),s.userData={textTexture:r,tick:0,translateTick:0},this.faces.push(s)})),e.add(...this.faces);let i=new va(76,76,76),r=new xt(i,t);this.innerViewCubeMesh=r,e.add(r);let a=new Cu(new va(100,100,100)),s=new on({color:this.lineColor}),o=new Wr(a,s);return e.add(o),e.position.set(0,0,0),e}createViewCubeFace(e,t,n,i){let r=new ui(76,76),a=new xt(r,t);return a.name=e,a.rotateOnAxis(i.axis,i.rad),a.position.copy(n),a}createViewCubeEdges(){let e=new an,t=this.createEdge("TopFrontEdge",new O(0,51,51),[{axis:Cs,rad:Or.Rotate180}]),n=this.createEdge("TopRightEdge",new O(51,51,0),[{axis:oh,rad:Or.Rotate180},{axis:Ra,rad:Or.Rotate90},{axis:Cs,rad:0}]),i=this.createEdge("TopBackEdge",new O(0,51,-51),[{axis:Cs,rad:Or.Rotate180},{axis:Ra,rad:Or.Rotate180}]),r=this.createEdge("TopLeftEdge",new O(-51,51,0),[{axis:oh,rad:Or.Rotate90},{axis:Ra,rad:Or.Rotate180},{axis:Cs,rad:Or.Rotate90}]),a=this.createEdge("BottomFrontEdge",new O(0,-51,51),[{axis:Cs,rad:0}]),s=this.createEdge("BottomRightEdge",new O(51,-51,0),[{axis:oh,rad:Or.Rotate90},{axis:Ra,rad:0},{axis:Cs,rad:Or.Rotate90}]),o=this.createEdge("BottomBackEdge",new O(0,-51,-51),[{axis:Cs,rad:0},{axis:Ra,rad:Or.Rotate180}]),l=this.createEdge("BottomLeftEdge",new O(-51,-51,0),[{axis:oh,rad:Or.Rotate90},{axis:Ra,rad:Or.Rotate270},{axis:Cs,rad:Or.Rotate90}]),h=this.createEdge("FrontRightEdge",new O(51,0,51),[{axis:Cs,rad:Or.Rotate90}]),c=this.createEdge("BackRightEdge",new O(51,0,-51),[{axis:Cs,rad:Or.Rotate90},{axis:Ra,rad:Or.Rotate180}]),u=this.createEdge("BackLeftEdge",new O(-51,0,-51),[{axis:Cs,rad:Or.Rotate270},{axis:Ra,rad:Or.Rotate180}]),d=this.createEdge("FrontLeftEdge",new O(-51,0,51),[{axis:Cs,rad:Or.Rotate270}]);return e.add(t),e.add(n),e.add(i),e.add(r),e.add(a),e.add(s),e.add(o),e.add(l),e.add(h),e.add(c),e.add(u),e.add(d),e}createEdge(e,t,n){let i=new an,r=new ui(this.EDGE_SIZE.x,this.EDGE_SIZE.y),a=new on({color:this.EDGE_COLOUR,opacity:this.EDGE_OPACITY,transparent:!0}),s={tick:0},o=new xt(r,a);o.name=e,o.userData=s,o.position.setY(this.EDGE_SIZE.y/2),o.layers.enableAll();let l=new xt(r,a);return l.name=e,l.userData=s,l.position.setZ(-this.EDGE_SIZE.y/2),l.rotateOnAxis(new O(1,0,0),Math.PI/2),l.layers.enableAll(),i.add(o),i.add(l),i.position.copy(t),n.forEach((e=>{i.rotateOnAxis(e.axis,e.rad)})),i}createViewCubeCorners(){let e=new an,t=this.createCorner("TopFrontLeftCorner",new O(-51,51,51),[{axis:Cs,rad:Or.Rotate270}]),n=this.createCorner("TopFrontRightCorner",new O(51,51,51),[{axis:Cs,rad:Or.Rotate180}]),i=this.createCorner("TopBackRightCorner",new O(51,51,-51),[{axis:oh,rad:Or.Rotate90},{axis:Ra,rad:Or.Rotate180},{axis:Cs,rad:0}]),r=this.createCorner("TopBackLeftCorner",new O(-51,51,-51),[{axis:oh,rad:Or.Rotate90},{axis:Ra,rad:Or.Rotate180},{axis:Cs,rad:Or.Rotate90}]),a=this.createCorner("BottomFrontLeftCorner",new O(-51,-51,51),[{axis:Cs,rad:0}]),s=this.createCorner("BottomFrontRightCorner",new O(51,-51,51),[{axis:Cs,rad:Or.Rotate90}]),o=this.createCorner("BottomBackRightCorner",new O(51,-51,-51),[{axis:oh,rad:0},{axis:Ra,rad:Or.Rotate180},{axis:Cs,rad:0}]),l=this.createCorner("BottomBackLeftCorner",new O(-51,-51,-51),[{axis:oh,rad:0},{axis:Ra,rad:Or.Rotate180},{axis:Cs,rad:Or.Rotate90}]);return e.add(t),e.add(n),e.add(i),e.add(r),e.add(a),e.add(s),e.add(o),e.add(l),e}createCorner(e,t,n){let i=new an,r=new ui(this.CORNER_WIDTH,this.CORNER_WIDTH),a=new on({color:this.CORNER_COLOR,opacity:this.CORNER_OPACITY,transparent:!0}),s={tick:0},o=new xt(r,a);o.name=e,o.userData=s,o.position.set(this.CORNER_WIDTH/2,this.CORNER_WIDTH/2,0),o.layers.enableAll();let l=new xt(r,a);l.name=e,l.userData=s,l.position.set(this.CORNER_WIDTH/2,0,-this.CORNER_WIDTH/2),l.rotateOnAxis(new O(1,0,0),Math.PI/2),l.layers.enableAll();let h=new xt(r,a);return h.name=e,h.userData=s,h.position.set(0,this.CORNER_WIDTH/2,-this.CORNER_WIDTH/2),h.rotateOnAxis(new O(0,1,0),-Math.PI/2),h.layers.enableAll(),i.add(o),i.add(l),i.add(h),i.position.copy(t),n.forEach((e=>{i.rotateOnAxis(e.axis,e.rad)})),i}getBbox(){let e=new Ot;return e.setFromObject(this),e}getDirectionByViewCubeName(e){let t;switch(e){case"TopFace":t=new O(0,1,0);break;case"BottomFace":t=new O(0,-1,0);break;case"FrontFace":t=new O(0,0,1);break;case"BackFace":t=new O(0,0,-1);break;case"LeftFace":t=new O(-1,0,0);break;case"RightFace":t=new O(1,0,0);break;case"TopFrontEdge":t=new O(0,1,1);break;case"TopRightEdge":t=new O(1,1,0);break;case"TopBackEdge":t=new O(0,1,-1);break;case"TopLeftEdge":t=new O(-1,1,0);break;case"BottomFrontEdge":t=new O(0,-1,1);break;case"BottomRightEdge":t=new O(1,-1,0);break;case"BottomBackEdge":t=new O(0,-1,-1);break;case"BottomLeftEdge":t=new O(-1,-1,0);break;case"FrontLeftEdge":t=new O(-1,0,1);break;case"FrontRightEdge":t=new O(1,0,1);break;case"BackRightEdge":t=new O(1,0,-1);break;case"BackLeftEdge":t=new O(-1,0,-1);break;case"TopFrontLeftCorner":t=new O(-1,1,1);break;case"TopFrontRightCorner":t=new O(1,1,1);break;case"TopBackRightCorner":t=new O(1,1,-1);break;case"TopBackLeftCorner":t=new O(-1,1,-1);break;case"BottomFrontLeftCorner":t=new O(-1,-1,1);break;case"BottomFrontRightCorner":t=new O(1,-1,1);break;case"BottomBackRightCorner":t=new O(1,-1,-1);break;case"BottomBackLeftCorner":t=new O(-1,-1,-1)}return t}update(){this.traverse((e=>{e instanceof xt&&this.updateViewCube(e)}))}updateViewCube(e){if(this.updateMeshTick(e),e.name.indexOf("Face")>-1){let t=e.userData.textTexture;if(t){let n=JV(this.FACE_BACKGROUND_COLOR,this.FACE_HOVER_BACKGROUND_COLOR,e.userData.tick);t.updateConfig({backgroundColor:n}),e.userData.tick>0&&t.redrew()}if(this.innerViewCubeMesh){this.updateMeshTick(e,"translateTick",2);let t=e.position.clone().normalize(),n=Math.max(2*e.userData.translateTick-2,0);t.multiplyScalar(7*n),n>0&&this.innerViewCubeMesh.position.copy(t)}}else if(e.name.indexOf("Edge")>-1){let t=e.material,n=JV(this.EDGE_COLOUR,this.FACE_HOVER_BACKGROUND_COLOR,e.userData.tick);t.color.set(n),t.opacity=e.userData.tick}else if(e.name.indexOf("Corner")>-1){let t=e.material,n=JV(this.CORNER_COLOR,this.FACE_HOVER_BACKGROUND_COLOR,e.userData.tick);t.color.set(n);let i=1+.3*e.userData.tick;e.parent&&e.parent.scale.set(i,i,i)}}updateMeshTick(e,t="tick",n=1){void 0!==e.userData[t]&&(e.name===this.activateMeshName&&e.userData[t]0&&(e.userData[t]-=.05),e.userData[t]>0&&e.userData[t]{var t,n;let i=this.getNdcPointByEvent(e);if(!i)return;null==(t=e.originalEvent)||t.stopPropagation();let r=this.getIntersects(i);if(this.lastCoords=i,!r||0===r.length)return;let a=r[0].object.name,s=null==(n=this.viewCube)?void 0:n.getDirectionByViewCubeName(a);s&&this.updateViewerCamera(s)},this.onPointerMove=e=>{var t;let n=this.getNdcPointByEvent(e);n&&(null==(t=e.originalEvent)||t.stopPropagation(),this.updateActivateMeshName(n),this.lastCoords=n)},this.onPointerleave=e=>{var t,n;null==(t=e.originalEvent)||t.stopPropagation(),this.lastCoords=void 0,null!=(n=this.viewCube)&&n.activateMeshName&&(this.viewCube.activateMeshName=void 0)},this.onClick=e=>{var t;null==(t=e.originalEvent)||t.stopPropagation()},this.updateCameraAndMeshName=()=>{var e;if(null==(e=this.viewer)||!e.camera)return;let t=this.viewer.camera,n=new O;t.getWorldDirection(n);let i=t.up;this.updateCameraDirection(n,i),this.renderEnabled=!0,this.lastCoords&&this.updateActivateMeshName(this.lastCoords)},this.cfg=t||{},this.init(),this.animate()}init(){Dn.isBrowser&&!this.cfg.context&&this.initDom(),this.initInputManager(),this.initScene(),this.initRenderer(),this.initCamera(),this.initLights(),this.initViewCube(),this.initEvents()}initDom(){var e;let t=document.getElementById(this.cfg.containerId);if(!t){se.error("[ViewCube] containerId:",this.cfg.containerId,"is not found in dom tree! will append to gemini-widget-container");let n="viewCube";t=document.createElement("div"),t.id=n,null==(e=this.viewer.widgetContainer)||e.appendChild(t),this.cfg.containerId=n}this.width=t.clientWidth,this.height=t.clientHeight,this.container=t}initInputManager(){this.container&&(this.inputManager=new Jo(this.container))}initScene(){let e=new _i;e.matrixAutoUpdate=!1,this.scene=e}initCamera(){if(!this.scene)return;let e=new Ur(-this.width/2,this.width/2,this.height/2,-this.height/2,.1,1e5);e.position.set(300,300,300),e.lookAt(0,0,0),e.zoom=10,e.updateProjectionMatrix(),this.scene.add(e),this.camera=e}initRenderer(){var e;this.renderer=new Ms({antialias:!0,preserveDrawingBuffer:!0}),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(this.width,this.height),this.renderer.setClearColor(11119017,0),null==(e=this.container)||e.appendChild(this.renderer.domElement)}initLights(){if(!this.scene)return;let e=new js(16777215,1.5);e.name="sun",this.directionalLight=e,this.scene.add(e),this.scene.add(e.target)}initViewCube(){if(!this.scene)return;let e=new J2(this.cfg);this.viewCube=e,this.scene.add(e),this.zoomToBbox(e.getBbox())}initEvents(){var e,t,n,i;null==(e=this.inputManager)||e.addEventListener("pointerdown",this.onPointerDown),null==(t=this.inputManager)||t.addEventListener("pointermove",this.onPointerMove),null==(n=this.inputManager)||n.addEventListener("pointerleave",this.onPointerleave),null==(i=this.inputManager)||i.addEventListener("click",this.onClick),this.viewer.addEventListener("AfterRender",this.updateCameraAndMeshName)}updateViewerCamera(e){var t,n;if(null==(t=this.viewer)||!t.camera||null==(n=this.viewer)||!n.controls)return;e.normalize();let i=this.viewer.controls instanceof ba?this.viewer.getBBox().getCenter(new O):this.viewer.controls.target,r=this.viewer.camera.position.distanceTo(i);this.viewer.flyTo(i.clone().add(e.clone().multiplyScalar(r)),i)}updateActivateMeshName(e){if(!this.viewCube)return;let t=this.getIntersects(e);if(this.viewCube.activateMeshName&&(this.viewCube.activateMeshName=void 0),!t||0===t.length)return;let n=t[0].object;this.viewCube.activateMeshName=n.name}getNdcPointByEvent(e){if(!this.container||!this.camera)return;let t=cn.getScreenPointByEvent(e,this.container);return cn.screenPoint2NdcPoint(t,this.camera,this.container)}getIntersects(e){return this.scene&&this.camera&&this.viewCube?(this.camera.updateMatrixWorld(),this.raycaster.layers.set(12),this.raycaster.setFromCamera(e,this.camera),this.raycaster&&this.raycaster.intersectObjects(this.viewCube.children,!0)||[]):void 0}updateCameraDirection(e,t){this.camera&&e&&(e.normalize(),this.camera.position.set(200*-e.x+0,200*-e.y+0,200*-e.z+0),this.camera.lookAt(0,0,0),this.camera.up=t,this.camera.updateMatrixWorld())}animate(){var e,t;this.requestAnimationFrameHandle=requestAnimationFrame(this.animate.bind(this)),this.scene&&this.camera&&this.viewCube&&(this.renderEnabled||this.viewCube.dirty)&&(null==(e=this.renderer)||e.render(this.scene,this.camera),this.renderEnabled=!1,this.viewCube.dirty=!1),null==(t=this.viewCube)||t.update()}zoomToBbox(e){if(!this.camera)return;let t=this.camera.right-this.camera.left,n=this.camera.top-this.camera.bottom,i=new O;e.getSize(i);let r=Math.sqrt(Math.pow(i.x,2)+Math.pow(i.y,2)+Math.pow(i.z,2)),a=Math.min(t/r,n/r);this.camera.position.set(i.x/2,i.y/2,i.z/2),this.camera.zoom=a,this.camera.updateProjectionMatrix()}destroy(){var e,t,n,i,r,a,s;super.destroy(),this.requestAnimationFrameHandle&&(cancelAnimationFrame(this.requestAnimationFrameHandle),this.requestAnimationFrameHandle=void 0),this.renderer&&(this.renderer.domElement.remove(),this.renderer.clear(),this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer=void 0),null==(e=this.container)||e.remove(),this.container=void 0,null==(t=this.scene)||t.clear(),this.scene=void 0,null==(n=this.directionalLight)||n.dispose(),this.directionalLight=void 0,null==(i=this.inputManager)||i.removeEventListener("pointerdown",this.onPointerDown),null==(r=this.inputManager)||r.removeEventListener("pointermove",this.onPointerMove),null==(a=this.inputManager)||a.removeEventListener("pointerleave",this.onPointerleave),null==(s=this.inputManager)||s.removeEventListener("click",this.onClick),this.viewer.removeEventListener("AfterRender",this.updateCameraAndMeshName)}},Q2=class extends Bi{constructor(e,t){super(e),this.needsFrustumCulled=!1,this.image=t.image,this.min=t.min,this.max=t.max,this.radius=t.radius}getClassType(){return"OverviewMapDrawable"}getImageScreenSize(e,t,n){let i=this.transToScreenCoord(e,n),r=this.transToScreenCoord(t,n);return{width:Math.floor(Math.abs(i.x-r.x)),height:Math.floor(Math.abs(i.y-r.y))}}draw(e,t){let n=this.getImageScreenSize(this.max,this.min,t),i=new O;i.addVectors(this.max,this.min).multiplyScalar(.5);let r=this.transToScreenCoord(i,t),a=this.transToScreenCoord(t.position,t);e.save(),e.beginPath(),this.radius&&(e.arc(a.x,a.y,this.radius/this.tolerance,0,2*Math.PI,!0),e.clip()),e.drawImage(this.image,r.x-this.width/2,r.y-this.height/2,this.width,this.height),e.closePath(),e.restore(),this.width=n.width,this.height=n.height}drawSelect(){}getBounds(){let e=new O(-1,-3,-1),t=new O(1,-3,1);return new Ot(e,t)}isPointInPath(){return!1}getBBox(){return new Ot(this.min,this.max)}},$_=class extends Bi{constructor(e,t){super(e),this.hover=!1,this.needsFrustumCulled=!1,this.image=t.image,this.hoverImage=t.hoverImage,this.translate=t.translate,this.scale=t.scale||1,this.position=t.position instanceof O?t.position:new O(t.position.x,t.position.y,t.position.z),this.direction=t.direction?t.direction instanceof O?t.direction:new O(t.direction.x,t.direction.y,t.direction.z):void 0,this.radius=t.radius,this.displayRadius=t.displayRadius||1/0,this.rotation=t.rotation,this.enabledHover=!!t.enabledHover}direction2Rotation(e){return new be(e.x,e.z).angle()+Math.PI}getRotation(){let e=this.direction?this.direction2Rotation(this.direction):0,t=this.rotation?this.rotation:0;return t+=e,t}drawImage(e,t,n){let i=new be(1,1);this.translate&&i.set(this.translate.x,this.translate.y);let r=t.width*this.scale,a=t.height*this.scale,s=this.getRotation();s?(e.translate(n.x,n.y),e.rotate(s),e.drawImage(t,i.x*r,i.y*a,r,a),e.translate(-n.x,-n.y)):e.drawImage(t,n.x+i.x*r,n.y+i.y*a,r,a),this.width=r*this.tolerance,this.height=a*this.tolerance}draw(e,t){let n=this.position.clone(),i=!1;if(this.radius){let e=new be(n.x,n.z),r=new be(t.position.x,t.position.z),a=e.distanceTo(r);a>this.radius&&a0)}getBBox(){let e=this.position,t=new be(e.x,e.z),n=new Ot,i=new be(1,1);this.translate&&i.set(this.translate.x,this.translate.y);let r=[],a=i.x*this.width,s=i.y*this.height,o=(t,n)=>r.push(new be(e.x+t,e.z+n));o(a,s),o(a,s+this.height),o(a+this.width,s+this.height),o(a+this.width,s);let l=r.map((n=>{let i=this.getRotation();return i&&n.rotateAround(t,i),new O(n.x,e.y,n.y)}));return n.setFromPoints(l),n}},D1e=class extends Bi{constructor(e,t){super(e),this.needsFrustumCulled=!1,this.positions=t.positions,this.lineWidth=t.lineWidth||1,this.lineColor=t.lineColor||[0,0,0,1]}draw(e,t){let n=this.positions.map((e=>{let n=new O(e.x,e.y,e.z);return this.transToScreenCoord(n,t)}));e.save(),e.beginPath(),e.lineWidth=this.lineWidth,e.strokeStyle=Cn.rgba2Color(this.lineColor),n.forEach(((t,n)=>{0===n?e.moveTo(t.x,t.y):e.lineTo(t.x,t.y)})),e.stroke(),e.restore()}getBounds(){let e=new O(-1,-2,-1),t=new O(1,-2,1);return new Ot(e,t)}drawSelect(){}getClassType(){return"LineDrawable"}isPointInPath(){return!1}getBBox(){let e=this.positions.map((e=>new O(e.x,e.y,e.z)));return(new Ot).setFromPoints(e)}},O1e=class extends Bi{constructor(e,t){super(e),this.needsFrustumCulled=!1,this.text=t.text,this.position=t.position,this.offset=t.offset||{x:0,y:0},this.textStyle=t.textStyle||{},this.radius=t.radius,this.displayRadius=t.displayRadius||1/0,this.size=t.size||{width:0,height:0}}getFont(){let e=this.textStyle,t="";return t+=(e.fontSize?e.fontSize:12)+"px ",t+=e.fontWeight?e.fontWeight+" ":"",t+=e.fontFamily?e.fontFamily:"Arial",t}drawRoundRect(e,t,n,i,r,a,s){let o=this.textStyle,l=Math.min(o.borderRadius||0,i/2,r/2);e.save(),o.backgroundColor&&(e.fillStyle=o.backgroundColor),o.borderColor&&(e.strokeStyle=o.borderColor),o.borderWidth&&(e.lineWidth=o.borderWidth),this.radius&&s&&(e.beginPath(),e.arc(a.x,a.y,this.radius/this.tolerance,0,2*Math.PI,!0),e.clip(),e.closePath()),e.beginPath(),e.moveTo(t+l,n),e.arcTo(t+i,n,t+i,n+r,l),e.arcTo(t+i,n+r,t,n+r,l),e.arcTo(t,n+r,t,n,l),e.arcTo(t,n,t+i,n,l),o.borderWidth&&e.stroke(),o.backgroundColor&&e.fill(),e.closePath(),e.restore()}draw(e,t){let n=this.textStyle,i=new O(this.position.x,this.position.y,this.position.z),r=!1;if(this.radius){let e=new be(i.x,i.z),n=new be(t.position.x,t.position.z),a=e.distanceTo(n);a>this.radius&&a(e.ZoomChanged="ZoomChanged",e.SyncCamera="SyncCamera",e.CameraChanged="CameraChanged",e))(Gyt||{}),U1e=class extends us{constructor(e){var t,n,i;super(),this.CAMERA_Z_POSITION=100,this.width=0,this.height=0,this.frustumSize=this.width,this.renderEnabled=!1,this.drawableList=new Ko("overviewMap"),this.clock=new mo,this.raf=new qf,this.raycaster=new ia,this.translateStart=new be,this.rotateStart=new be,this.markerRotateState=!1,this.markerTranslateState=!1,this.isMarkerRotating=!1,this.isMarkerTranslating=!1,this.isUpdateWhenPawnMove=!0,this.allMarkersBBox=new Ot,this.tolerance=5,this.enableLookToAllMarkers=!1,this.handlePointerDown=e=>{let t=this.cameraDrawable,n=this.cameraDirDrawable;if(!(t&&n&&this.viewerContainer&&this.camera&&this.controls))return;let i=this.getDrawableByEvent(e),r=cn.getScreenPointByEvent(e,this.viewerContainer),a=this.lockCameraInViewCenter?this.camera.position:cn.worldPosition2ScreenPoint(t.position,this.camera,this.viewerContainer);i&&i===n&&(this.isMarkerRotating=!0,this.rotateStart.set(r.x-a.x,r.y-a.y),this.controls.enabled=!1),i&&i===t&&(this.isMarkerTranslating=!0,this.translateStart.set(r.x,r.y),this.controls.enabled=!1)},this.onCameraMove=e=>{var t,n;let i=this.cameraDrawable,r=this.cameraDirDrawable;if(!(i&&r&&this.camera&&this.viewerContainer))return;let a=cn.getScreenPointByEvent(e,this.viewerContainer),s=this.lockCameraInViewCenter?this.camera.position:cn.worldPosition2ScreenPoint(i.position,this.camera,this.viewerContainer);if(this.isMarkerRotating){let e=new be(a.x-s.x,a.y-s.y),n=(new be).subVectors(e,this.rotateStart);if(Math.abs(n.x)>this.tolerance||Math.abs(n.y)>this.tolerance){let n=e.angle()-this.rotateStart.angle();n=(n+2*Math.PI)%(2*Math.PI),null==(t=r.direction)||t.applyAxisAngle(this.camera.up,-n),this.rotateStart.copy(e)}}if(this.isMarkerTranslating){let e=new be(a.x,a.y),t=(new be).subVectors(e,this.translateStart);if(Math.abs(t.x)>this.tolerance||Math.abs(t.y)>this.tolerance){let t=cn.screenPoint2worldPosition(this.translateStart,this.camera,this.viewerContainer),r=cn.screenPoint2worldPosition(e,this.camera,this.viewerContainer),a=(new O).subVectors(r,t);a.setY(0),this.lockCameraInViewCenter?null==(n=this.controls)||n.truck(a.x,a.z):i.position.add(a),this.translateStart.copy(e)}}if(this.isMarkerRotating||this.isMarkerTranslating){let e=this.lockCameraInViewCenter?this.camera.position.clone():i.position.clone(),t=r.direction.clone(),n=this.transformMatrix.clone().invert();e.applyMatrix4(n),t.applyMatrix4(n),this.syncCamera(e,t)}},this.handlePointerUp=()=>{this.isMarkerTranslating=!1,this.isMarkerRotating=!1,this.markerRotateState=!1,this.markerTranslateState=!1,this.controls.enabled=!0},this.handlePointerLeave=()=>{this.markerRotateState=this.isMarkerRotating,this.markerTranslateState=this.isMarkerTranslating,this.isMarkerTranslating=!1,this.isMarkerRotating=!1,this.controls.enabled=!0},this.handlePointerEnter=e=>{1&e.buttons?(this.isMarkerTranslating=this.markerTranslateState,this.isMarkerRotating=this.markerRotateState,this.controls.enabled=!1):(this.markerRotateState=!1,this.markerTranslateState=!1)},this.handleDblClick=e=>{var t;let n=this.cameraDrawable,i=this.cameraDirDrawable;if(this.animationId&&window.cancelAnimationFrame(this.animationId),!(n&&i&&this.camera&&this.viewerContainer))return;let r=cn.getScreenPointByEvent(e,this.viewerContainer),a=cn.screenPoint2worldPosition(r,this.camera,this.viewerContainer);this.lockCameraInViewCenter?(a.setY(this.camera.position.y),null==(t=this.controls)||t.setLookAt(a.x,a.y,a.z,a.x,0,a.z)):(a.setY(n.position.y),n.position.copy(a));let s=i.direction.clone(),o=this.transformMatrix.clone().invert();a.applyMatrix4(o),s.applyMatrix4(o),this.syncCamera(a,s)},this.handlePointerMove=e=>{this.onCameraHover(e),this.onCameraMove(e),this.enableRender()},this.enableRender=(e=1e3)=>{this.renderEnabled=!0,this.raf&&(this.timeoutSymbol&&this.raf.clearTimeout(this.timeoutSymbol),this.timeoutSymbol=this.raf.setTimeout((()=>{this.renderEnabled=!1}),e))},this.isPointInBoundary=e=>{var t;if(null==(t=this.boundaries)||!t.size)return;let n,i=new be(e.x,e.y);return this.boundaries.forEach((e=>{e.polygon.length<3||Qt.isPointInPolygon(i,e.polygon)&&(n={id:e.id,name:e.name})})),n},this.animate=()=>{var e,t,n;this.requestAnimationFrameHandle=requestAnimationFrame(this.animate);let i=this.clock.getDelta(),r=null==(e=this.controls)?void 0:e.update(i);if(this.scene&&this.camera){if(this.viewerContainer&&this.viewerContainer){let{width:e,height:t}=this.viewerContainer.getBoundingClientRect();(this.width!==e||this.height!==t)&&(r=!0,this.resize(e,t))}if(this.renderEnabled||r){if(null==(t=this.renderer)||t.render(this.scene,this.camera),!Dn.isBrowser){let e=null==(n=this.renderer)?void 0:n.getContext();e&&e.endFrameEXP&&(e.flush(),e.endFrameEXP())}this.enableLookToAllMarkers&&this.lookToAllMarkers(),this.dispatchEvent("AfterRender")}}},this.cfg=e||{},this.transformMatrix=new et,this.transformMatrix.elements=this.cfg.transformMatrix||[0,0,-1,0,1,0,0,0,0,1,0,0,0,0,0,1],this.enabled=null==(t=this.cfg.enabled)||t,this.lockCameraInViewCenter=!!this.cfg.lockCameraInViewCenter,this.radius=this.cfg.radius,this.size=this.cfg.size,this.minZoomFactor=null!=(n=this.cfg.minZoomFactor)?n:.3,this.maxZoomFactor=null!=(i=this.cfg.maxZoomFactor)?i:5,this.init(),this.animate(),this.enableRender()}get cameraDrawable(){return this.getMarker("cameraDrawable")}get cameraDirDrawable(){return this.getMarker("cameraDirDrawable")}get overviewMapDrawable(){return this.getMarker("overviewMap")}init(){Dn.isBrowser&&!this.cfg.context&&this.initDom(),this.initScene(),this.initRenderer(),this.initCamera(),this.initInputManager(),this.initEvents(),this.initControls()}initDom(){let e=document.getElementById(this.cfg.containerId);if(!e){se.error("[ViewCube] containerId:",this.cfg.containerId,"is not found in dom tree! will append to document.body.");let t="overview-map";e=document.createElement("div"),e.id=t,document.body.appendChild(e),this.cfg.containerId=t}this.width=e.clientWidth,this.height=e.clientHeight,this.viewerContainer=e}initInputManager(){this.viewerContainer&&(this.inputManager=new Jo(this.viewerContainer))}initScene(){let e=new _i;e.background=null,e.matrixAutoUpdate=!1,e.matrixWorldAutoUpdate=!1,this.scene=e}initCamera(){if(!this.scene)return;let e=new Ur(-this.width/2,this.width/2,this.height/2,-this.height/2,.1,1e5);e.position.set(0,0,this.CAMERA_Z_POSITION),e.zoom=10,e.updateProjectionMatrix(),this.scene.add(e),this.camera=e,this.frustumSize=this.width}initRenderer(){var e;let{context:t}=this.cfg,n={context:t,antialias:!0,preserveDrawingBuffer:!0,alpha:!1,stencil:!1};!Dn.isBrowser&&t&&Object.assign(n,{context:t,canvas:Dn.creatReactNativeCanvas(t)}),t&&(this.width=t.drawingBufferWidth,this.height=t.drawingBufferHeight),this.renderer=new Ms(n),this.renderer.setClearColor(11119017,1),this.renderer.setClearAlpha(0),Dn.isBrowser&&(!t&&this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.domElement.classList.add("webgl-renderer"),null==(e=this.viewerContainer)||e.appendChild(this.renderer.domElement)),this.renderer.setSize(this.width,this.height),this.overlayRender=new Un(this),this.overlayRender.addDrawableList(this.drawableList)}initControls(){let e=this.camera;if(!this.inputManager||!e)return;let t=new ba(e,this.inputManager);t.enableRotate=!1,t.enabled=this.enabled,t.keyTruckSpeed=10,t.dollyToCursor=!0,t.dollySpeed=.1,t.truckSpeed=1,t.mouseButtons={left:yt.TRUCK,middle:yt.TRUCK,wheel:yt.ZOOM,right:yt.TRUCK},t.touches={one:yt.TOUCH_TRUCK,two:yt.TOUCH_ZOOM_TRUCK,three:yt.NONE},t.update(0),this.controls=t,t.addEventListener("control",this.onControlsChange()),t.addEventListener("update",this.onControlsUpdate())}onControlsChange(){return()=>{this.enableRender()}}onControlsUpdate(){return()=>{if(!this.camera||!this.cameraZoom||!this.initialZoom)return;let e=this.camera.zoom;Zt.areNumbersEqual(e,this.cameraZoom)||(this.cameraZoom=e,this.dispatchEvent("ZoomChanged",(e/this.initialZoom).toFixed(2)))}}initEvents(){var e,t,n,i,r,a;!this.enabled||this.lockCameraInViewCenter||(null==(e=this.inputManager)||e.addEventListener("pointermove",this.handlePointerMove),null==(t=this.inputManager)||t.addEventListener("pointerdown",this.handlePointerDown),null==(n=this.inputManager)||n.addEventListener("pointerup",this.handlePointerUp),null==(i=this.inputManager)||i.addEventListener("dblclick",this.handleDblClick),null==(r=this.inputManager)||r.addEventListener("pointerleave",this.handlePointerLeave),null==(a=this.inputManager)||a.addEventListener("pointerenter",this.handlePointerEnter))}getDrawableByEvent(e){var t;if(!this.camera||!this.groundPlane||!this.viewerContainer)return;let n=this.raycaster;if(!n)return;let i=cn.getScreenPointByEvent(e,this.viewerContainer),r=cn.screenPoint2NdcPoint(i,this.camera,this.viewerContainer);n.setFromCamera(r,this.camera);let a=n.intersectObject(this.groundPlane);if(0===a.length||!a[0].point)return;let s=null==(t=this.overlayRender)?void 0:t.getDrawablesByPosition(a[0].point,n);return s&&s.length>0?s[0]:void 0}onCameraHover(e){let t=this.cameraDrawable,n=this.cameraDirDrawable;if(!t||!n)return;t.hover=!1,n.hover=!1;let i=this.getDrawableByEvent(e);i&&i===n&&(n.hover=!0),i&&i===t&&(t.hover=!0),this.enableRender()}syncCamera(e,t){this.timeout&&clearTimeout(this.timeout),this.isUpdateWhenPawnMove=!1,this.dispatchEvent("SyncCamera",{location:e,direction:t}),this.dispatchEvent("CameraChanged",e.applyMatrix4(this.transformMatrix)),this.timeout=setTimeout((()=>{this.timeout&&clearTimeout(this.timeout),this.isUpdateWhenPawnMove=!0}),500)}updateZoomFromRadius(){if(!this.camera||!this.radius||!this.controls)return;let e=this.controls;e.minZoom=0,e.maxZoom=1/0,e.update(0);let t=this.getContainerRadius(),n=this.camera.zoom*Number((t/this.radius).toFixed(2));this.controls.zoomTo(n)}getContainerRadius(){if(!this.viewerContainer)return;let e=this.viewerContainer,{width:t,height:n}=e.getBoundingClientRect();return this.size&&(t=this.size.width,n=this.size.height),this.screenDistance2WorldDistance(Math.min(t,n)/2)}screenDistance2WorldDistance(e){let t=this.camera,n=this.viewerContainer,i=cn.screenPoint2worldPosition(new be(e,0),t,n),r=cn.screenPoint2worldPosition(new be(0,0),t,n);return Math.abs(new be(i.x,i.z).distanceTo(new be(r.x,r.z)))}initGroundPlane(e){var t;Mt.expandBoxByScale(e,3);let n=e.min,i=e.max,r=i.x-n.x+i.y-n.y+i.z-n.z;Mt.expandBoxByMinSize(e,r);let a=[],s=(e,t,n)=>{a.push(new O(e,t,n))},o=e.getSize(new O),l=e.getCenter(new O);if(s(-o.x/2,0,-o.z/2),s(o.x/2,0,-o.z/2),s(o.x/2,0,o.z/2),s(-o.x/2,0,o.z/2),this.groundPlane)this.groundPlane.geometry.setFromPoints(a),this.groundPlane.geometry.computeBoundingSphere(),this.groundPlane.geometry.computeBoundingBox(),this.groundPlane.geometry.computeVertexNormals();else{let e=new Dt;e.setFromPoints(a),e.setIndex([0,3,2,0,2,1]),e.computeVertexNormals();let n=new on({color:"#888",transparent:!0,opacity:0,side:Sr});this.groundPlane=new xt(e,n),this.groundPlane.frustumCulled=!1,this.groundPlane.position.copy(l),this.groundPlane.scale.set(1e5,1e5,1),this.groundPlane.name="groundPlane",this.groundPlane.userData.selectable=!1,this.groundPlane.renderOrder=-1e3,this.groundPlane.layers.enableAll(),Hn.disableLayerChannels(this.groundPlane,[12]),null==(t=this.scene)||t.add(this.groundPlane)}this.groundPlane.updateMatrixWorld()}initMaxAndMinZoom(){if(!this.controls)return;this.controls.update(0);let e=this.camera.zoom;this.controls.minZoom=e*this.minZoomFactor,this.controls.maxZoom=e*this.maxZoomFactor,this.initialZoom=e,this.cameraZoom=e}getImageElementFromUrl(e){let t=new Image;return t.src=e,new Promise(((e,n)=>{t.onload=()=>{e(t)},t.onerror=e=>{n(e)}}))}updateOverviewMap(e){return ft(this,null,(function*(){let t=new O,n=new O;t.set(e.min.x,e.min.y,e.min.z),n.set(e.max.x,e.max.y,e.max.z),t.applyMatrix4(this.transformMatrix),n.applyMatrix4(this.transformMatrix);let i=yield this.getImageElementFromUrl(e.image),r=new O(Math.min(t.x,n.x),0,Math.min(t.z,n.z)),a=new O(Math.max(t.x,n.x),0,Math.max(t.z,n.z)),s=new Ot(r,a);this.initGroundPlane(s.clone());let o=this.overviewMapDrawable;o?(o.image=i,o.radius=this.radius,o.max.copy(n),o.min.copy(t)):(this.zoomToBBox(s),this.updateZoomFromRadius(),this.initMaxAndMinZoom(),this.addMarker(new Q2("overviewMap",{image:i,min:t,max:n,radius:this.radius}))),this.imgBBox=s,this.enableRender()}))}createCameraMarkers(e,t){return ft(this,null,(function*(){var n,i;if(!this.camera||!this.viewerContainer)return;let r=this.cameraDrawable,a=this.cameraDirDrawable;if(r)r.position.copy(e),null==(n=r.direction)||n.copy(t);else{let n=yield this.getImageElementFromUrl(F1e),i=yield this.getImageElementFromUrl(B1e);this.addMarker(new $_("cameraDirDrawable",{image:n,hoverImage:i,translate:new be(-1,-.5),scale:.25,position:e,direction:t,enabledHover:this.enabled}))}if(a)a.position.copy(e),null==(i=a.direction)||i.copy(t);else{let n=yield this.getImageElementFromUrl(k1e),i=yield this.getImageElementFromUrl(N1e);this.addMarker(new $_("cameraDrawable",{image:n,hoverImage:i,translate:new be(-.5,-.5),scale:.25,position:e,direction:t,enabledHover:this.enabled}))}this.enableRender()}))}initCameraMarkers(e,t){return ft(this,null,(function*(){var n;let i=new O(e.x,e.y,e.z),r=new O(t.x,t.y,t.z);if(i.applyMatrix4(this.transformMatrix),r.applyMatrix4(this.transformMatrix),this.lockCameraInViewCenter){let e=this.camera;yield this.createCameraMarkers(e.position,r),i.setY(e.position.y),null==(n=this.controls)||n.setLookAt(i.x,i.y,i.z,i.x,0,i.z)}else yield this.createCameraMarkers(i,r)}))}updateOverviewMapCameraAnimation(){var e,t;let n=this.animationParam;if(!n)return void(this.animationId&&cancelAnimationFrame(this.animationId));let{startTime:i,positionStart:r,positionEnd:a,directionStart:s,directionEnd:o}=n,l=Math.min(1,(Date.now()-i)/500),h=r.lerp(a,l),c=s.lerp(o,l),u=this.cameraDrawable,d=this.cameraDirDrawable;if(null==(e=null==d?void 0:d.direction)||e.copy(c),this.lockCameraInViewCenter?null==(t=this.controls)||t.setLookAt(h.x,h.y,h.z,h.x,0,h.z):(null==u||u.position.copy(h),null==d||d.position.copy(h)),this.enableRender(),1===l)return this.animationParam=void 0,void(this.animationId&&cancelAnimationFrame(this.animationId));this.animationId=requestAnimationFrame(this.updateOverviewMapCameraAnimation.bind(this))}updateOverviewMapCamera(e,t){let n=this.cameraDrawable,i=this.cameraDirDrawable;if(!(this.camera&&this.viewerContainer&&n&&i&&this.isUpdateWhenPawnMove))return;this.animationId&&cancelAnimationFrame(this.animationId);let r,a=new O(e.x,e.y,e.z),s=new O(t.x,t.y,t.z);a.applyMatrix4(this.transformMatrix),s.applyMatrix4(this.transformMatrix),this.lockCameraInViewCenter?(r=this.camera.position.clone(),a.setY(r.y)):r=n.position.clone();let o=Date.now(),l=i.direction.clone();this.animationParam={startTime:o,positionStart:r,positionEnd:a,directionStart:l,directionEnd:s},this.updateOverviewMapCameraAnimation(),this.dispatchEvent("CameraChanged",a)}zoomToBBox(e){if(!this.scene||!this.camera||!this.controls)return;let t=this.camera,n=e.max.x-e.min.x,i=e.max.z-e.min.z,r=t.right-t.left,a=t.top-t.bottom,s=Math.min(r/n,a/i);this.controls.zoomTo(s);let o=new O;e.getCenter(o);let l=o.clone().setY(e.max.y+2);l.equals(o)||this.controls.setLookAt(l.x,l.y,l.z,o.x,o.y,o.z)}addMarker(e){this.drawableList.addDrawable(e),this.enableRender()}getMarker(e){return this.drawableList.getDrawableById(e)}removeMarker(e){this.drawableList.removeDrawable(e),this.enableRender()}dollyIn(e=.2){let t=this.camera;if(!t||!this.controls||!this.initialZoom)return;let n=t.zoom,i=Math.min(n+e*this.initialZoom,this.controls.maxZoom);this.controls.zoomTo(i)}dollyOut(e=.2){let t=this.camera;if(!t||!this.controls||!this.initialZoom)return;let n=t.zoom,i=Math.max(n-e*this.initialZoom,this.controls.minZoom);this.controls.zoomTo(i)}goToHomeView(){this.imgBBox&&this.zoomToBBox(this.imgBBox)}setRadius(e){this.radius=e;let t=this.overviewMapDrawable;t&&(t.radius=e),this.updateZoomFromRadius()}registerBoundaries(e){this.boundaries||(this.boundaries=new Map),e.forEach((e=>{var t;let n=e.points.map((e=>new be(e.x,e.y)));null==(t=this.boundaries)||t.set(e.id,{id:e.id,name:e.name,polygon:n})}))}screenShot(){return ft(this,null,(function*(){var e;try{let t=yield null==(e=this.overlayRender)?void 0:e.getImage((()=>!0));return null==t?void 0:t.src}catch(e){return void se.error(e)}}))}getViewConfig(){return this.cfg}getPixelSizeInWorldCoord(){let e=this.camera,{clientWidth:t,clientHeight:n}=this.viewerContainer;return Math.max(e.right-e.left,e.top-e.bottom)/e.zoom/Math.max(t,n)}lookToAllMarkers(){var e,t;let n=new Ot;this.drawableList.getDrawables().forEach((e=>{if("overviewMap"===e.id||"cameraDrawable"===e.id||"cameraDirDrawable"===e.id||!this.camera||!this.viewerContainer)return;let t=e;n.union(t.getBBox())})),n.min.setY(0),n.max.setY(0);let i=n.min.distanceTo(n.max);n.expandByVector(new O(.01*i,0,.01*i)),Zt.areVector3sEqual(null==(e=this.allMarkersBBox)?void 0:e.min,n.min)&&Zt.areVector3sEqual(null==(t=this.allMarkersBBox)?void 0:t.max,n.max)?this.enableLookToAllMarkers=!1:(this.allMarkersBBox=n,this.zoomToBBox(n))}resize(e,t){let n=this.camera;if(n&&t>0){let i=e/t;n.left=-this.frustumSize/2,n.right=this.frustumSize/2,n.top=this.frustumSize/i/2,n.bottom=-this.frustumSize/i/2,n.updateProjectionMatrix(),this.renderer&&this.renderer.setSize(e,t,!0),this.overlayRender&&this.overlayRender.setSize(e,t)}this.width=e,this.height=t,this.enableRender()}destroy(){var e,t,n;this.raycaster=void 0,null==(e=this.inputManager)||e.removeEventListener(),this.animationId&&(cancelAnimationFrame(this.animationId),this.animationId=void 0),this.timeout&&(clearTimeout(this.timeout),this.timeout=void 0),this.drawableList.clear(),null==(t=this.viewerContainer)||t.remove(),this.viewerContainer=void 0,null==(n=this.scene)||n.clear(),this.scene=void 0,this.requestAnimationFrameHandle&&(cancelAnimationFrame(this.requestAnimationFrameHandle),this.requestAnimationFrameHandle=void 0),this.renderer&&(this.renderer.domElement.remove(),this.renderer.clear(),this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer=void 0),this.overlayRender&&(this.overlayRender.destroy(),this.overlayRender=void 0),this.camera=void 0,this.controls&&(this.controls.dispose(),this.controls=void 0),this.groundPlane&&(this.groundPlane.geometry.dispose(),this.groundPlane.clear(),this.groundPlane=void 0),this.removeEventListener()}};export{MA as ANGLE_THRESHOLD_FOR_EDGE,eDt as AXIS_SECTION_PLANE_CONTROL_ID,QLt as AXIS_SECTION_PLANE_ID,n6 as AnnotationTable,h5 as ArrowMarkup,$ve as AxisGizmoPlugin,c2 as AxisPlaneSection,Hve as AxisType,sy as BYBLOCK,iy as BYLAYER,LP as BaseDxfCompareHelper,Dr as BaseMeasureDrawable,nh as BaseMeasurement,ip as BaseSection,Wu as BaseTable,sp as BaseVRMesh,Zf as BaseViewer,Gve as BimViewer,Iye as BimViewerDatGuiPlugin,nye as BimViewerToolbarPlugin,Cf as BinaryReader,ng as BitView,Zve as BottomBarPlugin,$f as BoxSelectHelper,Tf as CSS2DObjectUtils,ba as CameraControlsEx,_A as CancelablePromise,Un as CanvasRender,d5 as CircleMarkup,Pc as CloudLineMarkup,f5 as CloudRectMarkup,Cn as ColorUtils,Mt as CommonUtils,Gm as CompareDrawable,lye as ContextMenuPlugin,nP as ControlsHelper,cn as CoordinateConversionUtils,Qve as DEFAULT_BIMVIEWER_TOOLBAR_CONFIG,fde as DEFAULT_BIM_VIEWER_CONFIG,eye as DEFAULT_DXFVIEWER_TOOLBAR_CONFIG,Kve as DEFAULT_MARKUP_TOOLBAR_CONFIG,Dn as DeviceUtils,p5 as DotMarkup,Bi as Drawable,Ko as DrawableList,B5 as DxfChangeType,hs as DxfCompare,dve as DxfCompareHelper,u0e as DxfCompareMarkupManager,gy as DxfDataTable,gn as DxfLoader,Xm as DxfParser,Zfe as DxfRenderOrder,Lc as DxfUtils,Qf as DxfViewer,tye as DxfViewerToolbarPlugin,JLt as ENTER_KEY,KLt as ESC_KEY,RA as EdgeUtils,m5 as EllipseMarkup,us as Event,O2 as ExplodePlugin,Lm as ExportUtils,sd as FontDataTable,ud as FontManager,LA as FpsUtils,_de as GROUND_PLANE_RENDER_ORDER,_2 as GROUP_CONFIG,xP as GenerateMeshBvhWorker,Qt as GeometryUtils,k2 as GroundGrassPlugin,F2 as GroundGridPlugin,kye as GroundShadowPlugin,Fye as HotpointPlugin,qv as ICON_FONT_CLASS,$_ as ImageDrawable,ns as IndexedDbManager,Jo as InputManager,I0e as InstantiateHelper,$Lt as KEYDOWN_EVENT,ZLt as KEYUP_EVENT,vht as Keys,Lye as LayerManagerPlugin,g5 as LeaderLineMarkup,hr as Line,D1e as LineDrawable,TC as LinePatternShaders,$a as LoadingHelper,w1e as LocalDxfUploader,S1e as LocalImageUploader,B2 as LocalModelUploader,Jve as MARKUP_GROUP_CONFIG,wH as MOUSEDOWN_EVENT,wf as MOUSEMOVE_EVENT,TH as MOUSEUP_EVENT,dE as MarkupManager,T2 as MarkupToolbar,Wa as MarkupType,es as MaterialUtils,Zt as MathUtils,lve as MeasurementPlugin,$l as MeasurementType,b2 as MenuTypeEnums,Ar as MergeUtils,xt as Mesh,Yf as MeshBvhHelper,RP as MobileTouchHelperDrawable,R1e as NavCubePlugin,qm as NestCompareTypes,wP as OSnapHelper,Lfe as OSnapMarkerType,k4 as OSnapType,sve as ObjectPixelSizeHelper,Hn as ObjectUtils,u2 as ObjectsBoxSection,mve as Offset,Q2 as OverviewMapDrawable,U1e as OverviewMapPlugin,Gyt as OverviewMapPluginEvent,ah as PdfLoader,T1e as PdfLoaderPlugin,SP as PickMarkupHelper,h2 as PickPlaneSection,fr as Plugin,ii as Points,Fm as PolygonUtils,v5 as PolylineMarkup,Gf as ProgressBar,qf as RafHelper,y5 as RectMarkup,rDt as SECTION_BOX_ID,nDt as SECTION_PLANE_CONTROL_ID,tDt as SECTION_PLANE_ID,SH as SECTION_PLANE_NAME,ive as SHP,yP as SHPLoader,gP as SHPParser,AOt as SNAP_ICON_SIZE,ght as STATE,sde as SVGObject,Ife as SVGObjectUtils,ade as SVGRenderer,ks as SceneUtils,MH as ScreenshotMode,N2 as ScreenshotPlugin,d2 as SectionPlugin,Wv as SectionType,Hu as SectionUtils,$n as ShaderChunk,vP as ShpThree,qve as SimplifiedBimViewer,Pfe as SimplifyUtils,P1e as SkyboxPlugin,As as SnapDrawable,C1e as StatsPlugin,O1e as TextDrawable,Ol as TextMarkup,Cc as TextureUtils,ap as Toolbar,uV as ToolbarMenu,E2 as ToolbarMenuId,t6 as Units,JA as VRControls,g2 as VRCube,v2 as VRCube24Faces,y2 as VRSphere,Yve as VRViewer,L1e as ViewCubePlugin,aE as Viewer3DUtils,Ii as ViewerEvent,Vvt as ViewerMode,Ly as ViewerName,r6 as ViewpointTable,u5 as Views,o2 as WebCam,x5 as XMarkup,Dy as ZoomToRectHelper,e6 as bspline,pme as checkIsNewVersion,Jde as cn,oye as contextMenuItems,ume as createHatchPatternShaderMaterial,_dt as decodeDxfTextCharacterCodes,wdt as decodeDxfTextMbcsCharacterCodes,Tdt as decodeDxfTextUnicodeCodePoints,Kde as en,FOt as getLengthValueByUnit,sE as getUnitStr,Rdt as getVersionFromLocalStorage,Uu as layerForHitableObjects,ei as layerForSelectableObjects,vs as layerForSnapableObjects,se as log,si as matrixAutoUpdate,wC as parseDxfMTextContent,SC as parseDxfTextContent,J5 as round10,YLt as sceneAutoUpdate,SA as setIcon,gde as setLogLevel,Adt as setVersionToLocalStorage,Bu as showPrecisionValue,Dfe as unitConversionByMeter,uht as unitLabel,dme as unitScaleConversion,hme as unitScaleToMeter}; \ No newline at end of file diff --git a/demo/libs/types/core/Configs.d.ts b/demo/libs/types/core/Configs.d.ts index 2dacee2..32d615e 100644 --- a/demo/libs/types/core/Configs.d.ts +++ b/demo/libs/types/core/Configs.d.ts @@ -347,3 +347,21 @@ export interface ScreenshotConfig { quality: number; includeOverlay: boolean; } +/** + * Icon class. + * Used by toolbar and bottom bar icons, etc. + */ +export interface IconClass { + /** + * The default icon. + */ + default: string; + /** + * The icon when item is actived. + */ + active?: string; + /** + * The icon font class name. + */ + iconFont?: string; +} diff --git a/demo/libs/types/core/patches/shaders/shaderChunk/outine_bc_vertex.glsl.d.ts b/demo/libs/types/core/patches/shaders/shaderChunk/outine_bc_vertex.glsl.d.ts index 6a7247d..685b009 100644 --- a/demo/libs/types/core/patches/shaders/shaderChunk/outine_bc_vertex.glsl.d.ts +++ b/demo/libs/types/core/patches/shaders/shaderChunk/outine_bc_vertex.glsl.d.ts @@ -1,2 +1,2 @@ -declare const _default: "\n #if defined(USE_BC_OUTLINE)\n vBarycentric = barycentric;\n #endif\n"; +declare const _default: "\n #if defined(USE_BC_OUTLINE)\n // Restore barycentric coordinates\n int barycentricX = int(barycentric) & 0x1;\n int barycentricY = int(barycentric) & 0x2;\n int barycentricZ = int(barycentric) & 0x4;\n vBarycentric = vec3(float(barycentricX), float(barycentricY), float(barycentricZ));\n #endif\n"; export default _default; diff --git a/demo/libs/types/core/patches/shaders/shaderChunk/outline_bc_pars_vertex.glsl.d.ts b/demo/libs/types/core/patches/shaders/shaderChunk/outline_bc_pars_vertex.glsl.d.ts index 64547e1..b557760 100644 --- a/demo/libs/types/core/patches/shaders/shaderChunk/outline_bc_pars_vertex.glsl.d.ts +++ b/demo/libs/types/core/patches/shaders/shaderChunk/outline_bc_pars_vertex.glsl.d.ts @@ -1,2 +1,2 @@ -declare const _default: "\n #ifdef USE_BC_OUTLINE \n attribute vec3 barycentric;\n varying vec3 vBarycentric;\n #endif\n"; +declare const _default: "\n #ifdef USE_BC_OUTLINE \n attribute float barycentric;\n varying vec3 vBarycentric;\n #endif\n"; export default _default; diff --git a/demo/libs/types/core/utils/CommonUtils.d.ts b/demo/libs/types/core/utils/CommonUtils.d.ts index 9e181f5..ed9c9ec 100644 --- a/demo/libs/types/core/utils/CommonUtils.d.ts +++ b/demo/libs/types/core/utils/CommonUtils.d.ts @@ -1,4 +1,5 @@ import * as THREE from "three"; +import { IconClass } from "../Configs"; /** * @internal */ @@ -122,11 +123,3 @@ export declare class CommonUtils { * @internal */ export declare const setIcon: (classList: DOMTokenList, iconClass: IconClass, active: boolean) => void; -/** - * @internal - */ -export interface IconClass { - default: string; - active?: string; - iconFont?: string; -} diff --git a/demo/libs/types/core/viewers/DxfViewer.d.ts b/demo/libs/types/core/viewers/DxfViewer.d.ts index 6a20efd..38e2014 100644 --- a/demo/libs/types/core/viewers/DxfViewer.d.ts +++ b/demo/libs/types/core/viewers/DxfViewer.d.ts @@ -310,7 +310,7 @@ export declare class DxfViewer extends BaseViewer { * const viewer = new DxfViewer(viewerCfg); * await viewer.loadModelAsync(modelCfg, (event) => { * const progress = (event.loaded * 100) / event.total; - * console.log(`${event.type}: ${progress}%`); + * console.log(`Loading progress: ${progress}%`); * }); * console.log("Loaded"); * ``` diff --git a/demo/libs/types/export.doc.d.ts b/demo/libs/types/export.doc.d.ts index 6a05117..e7083fb 100644 --- a/demo/libs/types/export.doc.d.ts +++ b/demo/libs/types/export.doc.d.ts @@ -1,9 +1,9 @@ -export { SectionType, Vector2, Vector3, Box2, DrawableData, ScreenshotMode } from "./core"; +export { SectionType, Vector2, Vector3, Box2, DrawableData, InputManager, Model3d, ScreenshotMode } from "./core"; export { BaseDxfCompareHelper, DxfCompareHelper } from "./core/compare"; export { BaseViewerConfig, BimViewerConfig, CameraConfig, DxfCompareConfig, DxfModelConfig, DxfViewerConfig, Hotpoint, ModelConfig, Panorama, VRViewerConfig, VRViewpoint, } from "./core/Configs"; -export { BaseViewer, BimViewer, DxfViewer, VRViewer, ScreenshotResult, SimplifiedBimViewer, ViewerEvent, DxfLayers, MarkupData, Plugin, PluginConfig, } from "./core/viewers"; +export { BaseViewer, BimViewer, DxfLayers, DxfViewer, MarkupData, Model2d, Plugin, PluginConfig, ScreenshotResult, SimplifiedBimViewer, ViewerEvent, VRViewer, } from "./core/viewers"; export { DxfDetailChanges, DxfChangeType, DxfChange, DxfLayer } from "./core/dxf"; export { ILayer } from "./core/dxf-parser"; export { MarkupType } from "./core/markup"; export { ProgressBar } from "./components/progress-bar"; -export { AxisGizmoPlugin, AxisGizmoPluginConfig, BaseMeasureDrawable, BaseSection, BimViewerToolbarPlugin, BimViewerToolbarPluginConfig, ContextMenuPlugin, DxfViewerToolbarPlugin, DxfViewerToolbarPluginConfig, ExplodePlugin, GroundShadowPlugin, GroundShadowConfig, HotpointPlugin, LocalDxfUploader, LocalModelUploader, LocalImageUploader, MeasurementData, MeasurementPlugin, MeasurementType, NavCubePlugin, NavCubePluginConfig, SectionPlugin, SkyboxPlugin, SkyboxPluginConfig, ToolbarMenuId, ViewCubePlugin, ViewCubePluginConfig, } from "./plugins"; +export { AxisGizmoPlugin, AxisGizmoPluginConfig, BaseMeasureDrawable, BaseSection, BimViewerToolbarPlugin, BimViewerToolbarPluginConfig, ContextMenuPlugin, DxfViewerToolbarPlugin, DxfViewerToolbarPluginConfig, ExplodePlugin, GroundShadowPlugin, GroundShadowConfig, HotpointPlugin, LocalDxfUploader, LocalModelUploader, LocalImageUploader, MeasurementData, MeasurementPlugin, MeasurementType, NavCubePlugin, NavCubePluginConfig, SectionPlugin, SkyboxPlugin, SkyboxPluginConfig, Toolbar, ToolbarConfig, ToolbarMenuConfig, ToolbarMenu, ToolbarMenuId, ViewCubePlugin, ViewCubePluginConfig, } from "./plugins"; diff --git a/demo/libs/types/plugins/bottom-bar/BottomBarPlugin.d.ts b/demo/libs/types/plugins/bottom-bar/BottomBarPlugin.d.ts index b77b345..0e6a25c 100644 --- a/demo/libs/types/plugins/bottom-bar/BottomBarPlugin.d.ts +++ b/demo/libs/types/plugins/bottom-bar/BottomBarPlugin.d.ts @@ -1,5 +1,5 @@ import { Tooltip } from "../../components/tool-tip"; -import { IconClass } from "../../core/utils"; +import { IconClass } from "../../core"; import { BaseViewer } from "../../core/viewers/BaseViewer"; import { Plugin } from "../../core/viewers/Plugin"; declare enum BottomBarItemId { diff --git a/demo/libs/types/plugins/local-model-uploader/LocalDxfUploader.d.ts b/demo/libs/types/plugins/local-model-uploader/LocalDxfUploader.d.ts index 4bfe786..4e18ed4 100644 --- a/demo/libs/types/plugins/local-model-uploader/LocalDxfUploader.d.ts +++ b/demo/libs/types/plugins/local-model-uploader/LocalDxfUploader.d.ts @@ -5,9 +5,11 @@ import type { DxfViewer, ModelConfig } from "../../core"; */ export declare class LocalDxfUploader extends IUploader { private viewer; + private pdfWorker; onSuccess?: (event: any) => void; readonly defaultModelConfig: ModelConfig; constructor(viewer: DxfViewer, elementId?: string); + setPdfWorker(pdfWorker: string): void; protected formats(): string[]; protected uploadFiles(files: FileList): void; /** diff --git a/demo/libs/types/plugins/overview-map/ImageDrawable.d.ts b/demo/libs/types/plugins/overview-map/ImageDrawable.d.ts index 3e3dd51..db33201 100644 --- a/demo/libs/types/plugins/overview-map/ImageDrawable.d.ts +++ b/demo/libs/types/plugins/overview-map/ImageDrawable.d.ts @@ -5,6 +5,7 @@ export interface ImageDrawableConfig { image: HTMLImageElement; position: Vector3 | THREE.Vector3; radius?: number; + displayRadius?: number; enabledHover?: boolean; direction?: Vector3 | THREE.Vector3; rotation?: number; @@ -18,6 +19,7 @@ export declare class ImageDrawable extends Drawable { hover: boolean; needsFrustumCulled: boolean; position: THREE.Vector3; + displayRadius: number; radius?: number; direction?: THREE.Vector3; rotation?: number; diff --git a/demo/libs/types/plugins/overview-map/TextDrawable.d.ts b/demo/libs/types/plugins/overview-map/TextDrawable.d.ts index e232b21..6f81d53 100644 --- a/demo/libs/types/plugins/overview-map/TextDrawable.d.ts +++ b/demo/libs/types/plugins/overview-map/TextDrawable.d.ts @@ -17,19 +17,29 @@ export interface TextDrawableConfig { text: string; position: Vector3; radius?: number; + displayRadius?: number; offset?: Vector2; textStyle?: TextStyle; + size?: { + width: number; + height: number; + }; } export declare class TextDrawable extends Drawable { text: string; position: Vector3; offset: Vector2; + size: { + width: number; + height: number; + }; textStyle: TextStyle; + displayRadius: number; radius?: number; needsFrustumCulled: boolean; constructor(id: string, cfg: TextDrawableConfig); private getFont; - drawRoundRect(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number): void; + drawRoundRect(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, cameraPosition: THREE.Vector2, bClippable: boolean): void; draw(ctx: CanvasRenderingContext2D, camera: THREE.Camera): void; getBounds(): THREE.Box3; drawSelect(): void; diff --git a/demo/libs/types/plugins/toolbars/BimViewerToolbarPlugin.d.ts b/demo/libs/types/plugins/toolbars/BimViewerToolbarPlugin.d.ts index ae3b796..27a7912 100644 --- a/demo/libs/types/plugins/toolbars/BimViewerToolbarPlugin.d.ts +++ b/demo/libs/types/plugins/toolbars/BimViewerToolbarPlugin.d.ts @@ -13,7 +13,7 @@ export interface BimViewerToolbarPluginConfig extends PluginConfig { */ export declare class BimViewerToolbarPlugin extends Plugin { protected cfg: BimViewerToolbarPluginConfig; - toolbar: Toolbar; + protected toolbar: Toolbar; constructor(viewer: BaseViewer, cfg?: BimViewerToolbarPluginConfig); /** * Sets a menu item to be active or inactive. diff --git a/demo/libs/types/plugins/toolbars/DxfViewerToolbarPlugin.d.ts b/demo/libs/types/plugins/toolbars/DxfViewerToolbarPlugin.d.ts index bb32868..5e2f596 100644 --- a/demo/libs/types/plugins/toolbars/DxfViewerToolbarPlugin.d.ts +++ b/demo/libs/types/plugins/toolbars/DxfViewerToolbarPlugin.d.ts @@ -15,8 +15,8 @@ export interface DxfViewerToolbarPluginConfig extends PluginConfig { */ export declare class DxfViewerToolbarPlugin extends Plugin { protected cfg: DxfViewerToolbarPluginConfig; - toolbar: Toolbar; - markupToolbar?: Toolbar; + protected toolbar: Toolbar; + protected markupToolbar?: Toolbar; constructor(viewer: BaseViewer, cfg?: DxfViewerToolbarPluginConfig); /** * Sets a menu item to be active or inactive. diff --git a/demo/libs/types/plugins/toolbars/Toolbar.constants.d.ts b/demo/libs/types/plugins/toolbars/Toolbar.constants.d.ts index 0d07b41..1a6d111 100644 --- a/demo/libs/types/plugins/toolbars/Toolbar.constants.d.ts +++ b/demo/libs/types/plugins/toolbars/Toolbar.constants.d.ts @@ -1,5 +1,5 @@ import type { Toolbar } from "./Toolbar"; -import type { IconClass } from "../../core/utils"; +import { IconClass } from "../../core"; import type { BaseViewer } from "../../core/viewers"; /** * @type @@ -7,7 +7,6 @@ import type { BaseViewer } from "../../core/viewers"; * 2:show popup * 3:show submenu * 4:turn on/off - * @internal */ export declare enum MenuTypeEnums { ClickEvent = 1, @@ -17,7 +16,6 @@ export declare enum MenuTypeEnums { } /** * Buildin toolbar ids - * @internal */ export declare enum ToolbarMenuId { HomeView = "HomeView", @@ -69,8 +67,8 @@ export declare enum ToolbarMenuId { Screenshot = "GetScreenshot" } /** - * ToolbarConfig - * @internal + * Toolbar menu config. + * Used to define menu item name, icon, child items, etc. */ export interface ToolbarMenuConfig { menuName?: string; @@ -86,7 +84,8 @@ export interface ToolbarMenuConfig { onClick?: (viewer: BaseViewer, toolbar: Toolbar, event: MouseEvent | TouchEvent) => void; } /** - * @internal + * Toolbar config. + * The key is ToolbarMenuId, and the value is a ToolbarMenuConfig. */ export declare type ToolbarConfig = { [key in ToolbarMenuId]?: ToolbarMenuConfig; diff --git a/demo/libs/types/plugins/toolbars/Toolbar.d.ts b/demo/libs/types/plugins/toolbars/Toolbar.d.ts index 507c107..5fa052a 100644 --- a/demo/libs/types/plugins/toolbars/Toolbar.d.ts +++ b/demo/libs/types/plugins/toolbars/Toolbar.d.ts @@ -37,7 +37,6 @@ import { type BaseViewer } from "../../core/viewers"; * toolbar.toolbarGroupConfig = toolbarGroupConfig; * toolbar.refresh(); * ``` - * @internal */ export declare class Toolbar { protected viewer: BaseViewer; diff --git a/index.html b/index.html index 863aca4..125b913 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -React App
\ No newline at end of file +React App
\ No newline at end of file diff --git a/static/js/main.abd1e4ad.js b/static/js/main.abd1e4ad.js new file mode 100644 index 0000000..46f623a --- /dev/null +++ b/static/js/main.abd1e4ad.js @@ -0,0 +1,2 @@ +!function(){var e={694:function(e,t){var n;!function(){"use strict";var r={}.hasOwnProperty;function i(){for(var e=[],t=0;ti?0:i+t),(n=n>i?i:n)<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var o=Array(i);++r=i?e:r(e,t,n)}},322:function(e,t,n){var r=n(737),i=n(302),o=n(580),a=n(518);e.exports=function(e){return function(t){t=a(t);var n=i(t)?o(t):void 0,s=n?n[0]:t.charAt(0),l=n?r(n,1).join(""):t.slice(1);return s[e]()+l}}},810:function(e,t,n){var r=n(95),i=n(857),o=n(660),a=RegExp("['\u2019]","g");e.exports=function(e){return function(t){return r(o(i(t).replace(a,"")),e,"")}}},868:function(e,t,n){var r=n(632)({"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss","\u0100":"A","\u0102":"A","\u0104":"A","\u0101":"a","\u0103":"a","\u0105":"a","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u010e":"D","\u0110":"D","\u010f":"d","\u0111":"d","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g","\u0124":"H","\u0126":"H","\u0125":"h","\u0127":"h","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u0131":"i","\u0134":"J","\u0135":"j","\u0136":"K","\u0137":"k","\u0138":"k","\u0139":"L","\u013b":"L","\u013d":"L","\u013f":"L","\u0141":"L","\u013a":"l","\u013c":"l","\u013e":"l","\u0140":"l","\u0142":"l","\u0143":"N","\u0145":"N","\u0147":"N","\u014a":"N","\u0144":"n","\u0146":"n","\u0148":"n","\u014b":"n","\u014c":"O","\u014e":"O","\u0150":"O","\u014d":"o","\u014f":"o","\u0151":"o","\u0154":"R","\u0156":"R","\u0158":"R","\u0155":"r","\u0157":"r","\u0159":"r","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0162":"T","\u0164":"T","\u0166":"T","\u0163":"t","\u0165":"t","\u0167":"t","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u017a":"z","\u017c":"z","\u017e":"z","\u0132":"IJ","\u0133":"ij","\u0152":"Oe","\u0153":"oe","\u0149":"'n","\u017f":"s"});e.exports=r},32:function(e,t,n){var r="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;e.exports=r},587:function(e,t,n){var r=n(197),i=Object.prototype,o=i.hasOwnProperty,a=i.toString,s=r?r.toStringTag:void 0;e.exports=function(e){var t=o.call(e,s),n=e[s];try{e[s]=void 0;var r=!0}catch(l){}var i=a.call(e);return r&&(t?e[s]=n:delete e[s]),i}},302:function(e){var t=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");e.exports=function(e){return t.test(e)}},137:function(e){var t=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;e.exports=function(e){return t.test(e)}},581:function(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},9:function(e,t,n){var r=n(32),i="object"==typeof self&&self&&self.Object===Object&&self,o=r||i||Function("return this")();e.exports=o},580:function(e,t,n){var r=n(622),i=n(302),o=n(110);e.exports=function(e){return i(e)?o(e):r(e)}},110:function(e){var t="\\ud800-\\udfff",n="["+t+"]",r="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",i="\\ud83c[\\udffb-\\udfff]",o="[^"+t+"]",a="(?:\\ud83c[\\udde6-\\uddff]){2}",s="[\\ud800-\\udbff][\\udc00-\\udfff]",l="(?:"+r+"|"+i+")"+"?",u="[\\ufe0e\\ufe0f]?",c=u+l+("(?:\\u200d(?:"+[o,a,s].join("|")+")"+u+l+")*"),f="(?:"+[o+r+"?",r,a,s,n].join("|")+")",h=RegExp(i+"(?="+i+")|"+f+c,"g");e.exports=function(e){return e.match(h)||[]}},29:function(e){var t="\\ud800-\\udfff",n="\\u2700-\\u27bf",r="a-z\\xdf-\\xf6\\xf8-\\xff",i="A-Z\\xc0-\\xd6\\xd8-\\xde",o="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",a="["+o+"]",s="\\d+",l="["+n+"]",u="["+r+"]",c="[^"+t+o+s+n+r+i+"]",f="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",d="["+i+"]",p="(?:"+u+"|"+c+")",v="(?:"+d+"|"+c+")",m="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",g="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",y="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?",O="[\\ufe0e\\ufe0f]?",b=O+y+("(?:\\u200d(?:"+["[^"+t+"]",f,h].join("|")+")"+O+y+")*"),w="(?:"+[l,f,h].join("|")+")"+b,k=RegExp([d+"?"+u+"+"+m+"(?="+[a,d,"$"].join("|")+")",v+"+"+g+"(?="+[a,d+p,"$"].join("|")+")",d+"?"+p+"+"+m,d+"+"+g,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",s,w].join("|"),"g");e.exports=function(e){return e.match(k)||[]}},567:function(e,t,n){var r=n(131),i=n(810)((function(e,t,n){return t=t.toLowerCase(),e+(n?r(t):t)}));e.exports=i},131:function(e,t,n){var r=n(518),i=n(85);e.exports=function(e){return i(r(e).toLowerCase())}},857:function(e,t,n){var r=n(868),i=n(518),o=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,a=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]","g");e.exports=function(e){return(e=i(e))&&e.replace(o,r).replace(a,"")}},629:function(e){var t=Array.isArray;e.exports=t},141:function(e){e.exports=function(e){return null!=e&&"object"==typeof e}},152:function(e,t,n){var r=n(66),i=n(141);e.exports=function(e){return"symbol"==typeof e||i(e)&&"[object Symbol]"==r(e)}},518:function(e,t,n){var r=n(446);e.exports=function(e){return null==e?"":r(e)}},85:function(e,t,n){var r=n(322)("toUpperCase");e.exports=r},660:function(e,t,n){var r=n(240),i=n(137),o=n(518),a=n(29);e.exports=function(e,t,n){return e=o(e),void 0===(t=n?void 0:t)?i(e)?a(e):r(e):e.match(t)||[]}},463:function(e,t,n){"use strict";var r=n(791),i=n(296);function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n
attribute.\n *\n * @param to - The destination URL\n */\n createHref(to: To): string;\n\n /**\n * Returns a URL for the given `to` value\n *\n * @param to - The destination URL\n */\n createURL(to: To): URL;\n\n /**\n * Encode a location the same way window.history would do (no-op for memory\n * history) so we ensure our PUSH/REPLACE navigations for data routers\n * behave the same as POP\n *\n * @param to Unencoded path\n */\n encodeLocation(to: To): Path;\n\n /**\n * Pushes a new location onto the history stack, increasing its length by one.\n * If there were any entries in the stack after the current one, they are\n * lost.\n *\n * @param to - The new URL\n * @param state - Data to associate with the new location\n */\n push(to: To, state?: any): void;\n\n /**\n * Replaces the current location in the history stack with a new one. The\n * location that was replaced will no longer be available.\n *\n * @param to - The new URL\n * @param state - Data to associate with the new location\n */\n replace(to: To, state?: any): void;\n\n /**\n * Navigates `n` entries backward/forward in the history stack relative to the\n * current index. For example, a \"back\" navigation would use go(-1).\n *\n * @param delta - The delta in the stack index\n */\n go(delta: number): void;\n\n /**\n * Sets up a listener that will be called whenever the current location\n * changes.\n *\n * @param listener - A function that will be called when the location changes\n * @returns unlisten - A function that may be used to stop listening\n */\n listen(listener: Listener): () => void;\n}\n\ntype HistoryState = {\n usr: any;\n key?: string;\n idx: number;\n};\n\nconst PopStateEventType = \"popstate\";\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region Memory History\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * A user-supplied object that describes a location. Used when providing\n * entries to `createMemoryHistory` via its `initialEntries` option.\n */\nexport type InitialEntry = string | Partial;\n\nexport type MemoryHistoryOptions = {\n initialEntries?: InitialEntry[];\n initialIndex?: number;\n v5Compat?: boolean;\n};\n\n/**\n * A memory history stores locations in memory. This is useful in stateful\n * environments where there is no web browser, such as node tests or React\n * Native.\n */\nexport interface MemoryHistory extends History {\n /**\n * The current index in the history stack.\n */\n readonly index: number;\n}\n\n/**\n * Memory history stores the current location in memory. It is designed for use\n * in stateful non-browser environments like tests and React Native.\n */\nexport function createMemoryHistory(\n options: MemoryHistoryOptions = {}\n): MemoryHistory {\n let { initialEntries = [\"/\"], initialIndex, v5Compat = false } = options;\n let entries: Location[]; // Declare so we can access from createMemoryLocation\n entries = initialEntries.map((entry, index) =>\n createMemoryLocation(\n entry,\n typeof entry === \"string\" ? null : entry.state,\n index === 0 ? \"default\" : undefined\n )\n );\n let index = clampIndex(\n initialIndex == null ? entries.length - 1 : initialIndex\n );\n let action = Action.Pop;\n let listener: Listener | null = null;\n\n function clampIndex(n: number): number {\n return Math.min(Math.max(n, 0), entries.length - 1);\n }\n function getCurrentLocation(): Location {\n return entries[index];\n }\n function createMemoryLocation(\n to: To,\n state: any = null,\n key?: string\n ): Location {\n let location = createLocation(\n entries ? getCurrentLocation().pathname : \"/\",\n to,\n state,\n key\n );\n warning(\n location.pathname.charAt(0) === \"/\",\n `relative pathnames are not supported in memory history: ${JSON.stringify(\n to\n )}`\n );\n return location;\n }\n\n function createHref(to: To) {\n return typeof to === \"string\" ? to : createPath(to);\n }\n\n let history: MemoryHistory = {\n get index() {\n return index;\n },\n get action() {\n return action;\n },\n get location() {\n return getCurrentLocation();\n },\n createHref,\n createURL(to) {\n return new URL(createHref(to), \"http://localhost\");\n },\n encodeLocation(to: To) {\n let path = typeof to === \"string\" ? parsePath(to) : to;\n return {\n pathname: path.pathname || \"\",\n search: path.search || \"\",\n hash: path.hash || \"\",\n };\n },\n push(to, state) {\n action = Action.Push;\n let nextLocation = createMemoryLocation(to, state);\n index += 1;\n entries.splice(index, entries.length, nextLocation);\n if (v5Compat && listener) {\n listener({ action, location: nextLocation, delta: 1 });\n }\n },\n replace(to, state) {\n action = Action.Replace;\n let nextLocation = createMemoryLocation(to, state);\n entries[index] = nextLocation;\n if (v5Compat && listener) {\n listener({ action, location: nextLocation, delta: 0 });\n }\n },\n go(delta) {\n action = Action.Pop;\n let nextIndex = clampIndex(index + delta);\n let nextLocation = entries[nextIndex];\n index = nextIndex;\n if (listener) {\n listener({ action, location: nextLocation, delta });\n }\n },\n listen(fn: Listener) {\n listener = fn;\n return () => {\n listener = null;\n };\n },\n };\n\n return history;\n}\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region Browser History\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * A browser history stores the current location in regular URLs in a web\n * browser environment. This is the standard for most web apps and provides the\n * cleanest URLs the browser's address bar.\n *\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#browserhistory\n */\nexport interface BrowserHistory extends UrlHistory {}\n\nexport type BrowserHistoryOptions = UrlHistoryOptions;\n\n/**\n * Browser history stores the location in regular URLs. This is the standard for\n * most web apps, but it requires some configuration on the server to ensure you\n * serve the same app at multiple URLs.\n *\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory\n */\nexport function createBrowserHistory(\n options: BrowserHistoryOptions = {}\n): BrowserHistory {\n function createBrowserLocation(\n window: Window,\n globalHistory: Window[\"history\"]\n ) {\n let { pathname, search, hash } = window.location;\n return createLocation(\n \"\",\n { pathname, search, hash },\n // state defaults to `null` because `window.history.state` does\n (globalHistory.state && globalHistory.state.usr) || null,\n (globalHistory.state && globalHistory.state.key) || \"default\"\n );\n }\n\n function createBrowserHref(window: Window, to: To) {\n return typeof to === \"string\" ? to : createPath(to);\n }\n\n return getUrlBasedHistory(\n createBrowserLocation,\n createBrowserHref,\n null,\n options\n );\n}\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region Hash History\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * A hash history stores the current location in the fragment identifier portion\n * of the URL in a web browser environment.\n *\n * This is ideal for apps that do not control the server for some reason\n * (because the fragment identifier is never sent to the server), including some\n * shared hosting environments that do not provide fine-grained controls over\n * which pages are served at which URLs.\n *\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#hashhistory\n */\nexport interface HashHistory extends UrlHistory {}\n\nexport type HashHistoryOptions = UrlHistoryOptions;\n\n/**\n * Hash history stores the location in window.location.hash. This makes it ideal\n * for situations where you don't want to send the location to the server for\n * some reason, either because you do cannot configure it or the URL space is\n * reserved for something else.\n *\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createhashhistory\n */\nexport function createHashHistory(\n options: HashHistoryOptions = {}\n): HashHistory {\n function createHashLocation(\n window: Window,\n globalHistory: Window[\"history\"]\n ) {\n let {\n pathname = \"/\",\n search = \"\",\n hash = \"\",\n } = parsePath(window.location.hash.substr(1));\n\n // Hash URL should always have a leading / just like window.location.pathname\n // does, so if an app ends up at a route like /#something then we add a\n // leading slash so all of our path-matching behaves the same as if it would\n // in a browser router. This is particularly important when there exists a\n // root splat route () since that matches internally against\n // \"/*\" and we'd expect /#something to 404 in a hash router app.\n if (!pathname.startsWith(\"/\") && !pathname.startsWith(\".\")) {\n pathname = \"/\" + pathname;\n }\n\n return createLocation(\n \"\",\n { pathname, search, hash },\n // state defaults to `null` because `window.history.state` does\n (globalHistory.state && globalHistory.state.usr) || null,\n (globalHistory.state && globalHistory.state.key) || \"default\"\n );\n }\n\n function createHashHref(window: Window, to: To) {\n let base = window.document.querySelector(\"base\");\n let href = \"\";\n\n if (base && base.getAttribute(\"href\")) {\n let url = window.location.href;\n let hashIndex = url.indexOf(\"#\");\n href = hashIndex === -1 ? url : url.slice(0, hashIndex);\n }\n\n return href + \"#\" + (typeof to === \"string\" ? to : createPath(to));\n }\n\n function validateHashLocation(location: Location, to: To) {\n warning(\n location.pathname.charAt(0) === \"/\",\n `relative pathnames are not supported in hash history.push(${JSON.stringify(\n to\n )})`\n );\n }\n\n return getUrlBasedHistory(\n createHashLocation,\n createHashHref,\n validateHashLocation,\n options\n );\n}\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region UTILS\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n */\nexport function invariant(value: boolean, message?: string): asserts value;\nexport function invariant(\n value: T | null | undefined,\n message?: string\n): asserts value is T;\nexport function invariant(value: any, message?: string) {\n if (value === false || value === null || typeof value === \"undefined\") {\n throw new Error(message);\n }\n}\n\nexport function warning(cond: any, message: string) {\n if (!cond) {\n // eslint-disable-next-line no-console\n if (typeof console !== \"undefined\") console.warn(message);\n\n try {\n // Welcome to debugging history!\n //\n // This error is thrown as a convenience so you can more easily\n // find the source for a warning that appears in the console by\n // enabling \"pause on exceptions\" in your JavaScript debugger.\n throw new Error(message);\n // eslint-disable-next-line no-empty\n } catch (e) {}\n }\n}\n\nfunction createKey() {\n return Math.random().toString(36).substr(2, 8);\n}\n\n/**\n * For browser-based histories, we combine the state and key into an object\n */\nfunction getHistoryState(location: Location, index: number): HistoryState {\n return {\n usr: location.state,\n key: location.key,\n idx: index,\n };\n}\n\n/**\n * Creates a Location object with a unique key from the given Path\n */\nexport function createLocation(\n current: string | Location,\n to: To,\n state: any = null,\n key?: string\n): Readonly {\n let location: Readonly = {\n pathname: typeof current === \"string\" ? current : current.pathname,\n search: \"\",\n hash: \"\",\n ...(typeof to === \"string\" ? parsePath(to) : to),\n state,\n // TODO: This could be cleaned up. push/replace should probably just take\n // full Locations now and avoid the need to run through this flow at all\n // But that's a pretty big refactor to the current test suite so going to\n // keep as is for the time being and just let any incoming keys take precedence\n key: (to && (to as Location).key) || key || createKey(),\n };\n return location;\n}\n\n/**\n * Creates a string URL path from the given pathname, search, and hash components.\n */\nexport function createPath({\n pathname = \"/\",\n search = \"\",\n hash = \"\",\n}: Partial) {\n if (search && search !== \"?\")\n pathname += search.charAt(0) === \"?\" ? search : \"?\" + search;\n if (hash && hash !== \"#\")\n pathname += hash.charAt(0) === \"#\" ? hash : \"#\" + hash;\n return pathname;\n}\n\n/**\n * Parses a string URL path into its separate pathname, search, and hash components.\n */\nexport function parsePath(path: string): Partial {\n let parsedPath: Partial = {};\n\n if (path) {\n let hashIndex = path.indexOf(\"#\");\n if (hashIndex >= 0) {\n parsedPath.hash = path.substr(hashIndex);\n path = path.substr(0, hashIndex);\n }\n\n let searchIndex = path.indexOf(\"?\");\n if (searchIndex >= 0) {\n parsedPath.search = path.substr(searchIndex);\n path = path.substr(0, searchIndex);\n }\n\n if (path) {\n parsedPath.pathname = path;\n }\n }\n\n return parsedPath;\n}\n\nexport interface UrlHistory extends History {}\n\nexport type UrlHistoryOptions = {\n window?: Window;\n v5Compat?: boolean;\n};\n\nfunction getUrlBasedHistory(\n getLocation: (window: Window, globalHistory: Window[\"history\"]) => Location,\n createHref: (window: Window, to: To) => string,\n validateLocation: ((location: Location, to: To) => void) | null,\n options: UrlHistoryOptions = {}\n): UrlHistory {\n let { window = document.defaultView!, v5Compat = false } = options;\n let globalHistory = window.history;\n let action = Action.Pop;\n let listener: Listener | null = null;\n\n let index = getIndex()!;\n // Index should only be null when we initialize. If not, it's because the\n // user called history.pushState or history.replaceState directly, in which\n // case we should log a warning as it will result in bugs.\n if (index == null) {\n index = 0;\n globalHistory.replaceState({ ...globalHistory.state, idx: index }, \"\");\n }\n\n function getIndex(): number {\n let state = globalHistory.state || { idx: null };\n return state.idx;\n }\n\n function handlePop() {\n action = Action.Pop;\n let nextIndex = getIndex();\n let delta = nextIndex == null ? null : nextIndex - index;\n index = nextIndex;\n if (listener) {\n listener({ action, location: history.location, delta });\n }\n }\n\n function push(to: To, state?: any) {\n action = Action.Push;\n let location = createLocation(history.location, to, state);\n if (validateLocation) validateLocation(location, to);\n\n index = getIndex() + 1;\n let historyState = getHistoryState(location, index);\n let url = history.createHref(location);\n\n // try...catch because iOS limits us to 100 pushState calls :/\n try {\n globalHistory.pushState(historyState, \"\", url);\n } catch (error) {\n // If the exception is because `state` can't be serialized, let that throw\n // outwards just like a replace call would so the dev knows the cause\n // https://html.spec.whatwg.org/multipage/nav-history-apis.html#shared-history-push/replace-state-steps\n // https://html.spec.whatwg.org/multipage/structured-data.html#structuredserializeinternal\n if (error instanceof DOMException && error.name === \"DataCloneError\") {\n throw error;\n }\n // They are going to lose state here, but there is no real\n // way to warn them about it since the page will refresh...\n window.location.assign(url);\n }\n\n if (v5Compat && listener) {\n listener({ action, location: history.location, delta: 1 });\n }\n }\n\n function replace(to: To, state?: any) {\n action = Action.Replace;\n let location = createLocation(history.location, to, state);\n if (validateLocation) validateLocation(location, to);\n\n index = getIndex();\n let historyState = getHistoryState(location, index);\n let url = history.createHref(location);\n globalHistory.replaceState(historyState, \"\", url);\n\n if (v5Compat && listener) {\n listener({ action, location: history.location, delta: 0 });\n }\n }\n\n function createURL(to: To): URL {\n // window.location.origin is \"null\" (the literal string value) in Firefox\n // under certain conditions, notably when serving from a local HTML file\n // See https://bugzilla.mozilla.org/show_bug.cgi?id=878297\n let base =\n window.location.origin !== \"null\"\n ? window.location.origin\n : window.location.href;\n\n let href = typeof to === \"string\" ? to : createPath(to);\n invariant(\n base,\n `No window.location.(origin|href) available to create URL for href: ${href}`\n );\n return new URL(href, base);\n }\n\n let history: History = {\n get action() {\n return action;\n },\n get location() {\n return getLocation(window, globalHistory);\n },\n listen(fn: Listener) {\n if (listener) {\n throw new Error(\"A history only accepts one active listener\");\n }\n window.addEventListener(PopStateEventType, handlePop);\n listener = fn;\n\n return () => {\n window.removeEventListener(PopStateEventType, handlePop);\n listener = null;\n };\n },\n createHref(to) {\n return createHref(window, to);\n },\n createURL,\n encodeLocation(to) {\n // Encode a Location the same way window.location would\n let url = createURL(to);\n return {\n pathname: url.pathname,\n search: url.search,\n hash: url.hash,\n };\n },\n push,\n replace,\n go(n) {\n return globalHistory.go(n);\n },\n };\n\n return history;\n}\n\n//#endregion\n","export default function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}","export default function _arrayLikeToArray(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n return arr2;\n}","import arrayLikeToArray from \"./arrayLikeToArray.js\";\nexport default function _unsupportedIterableToArray(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return arrayLikeToArray(o, minLen);\n var n = Object.prototype.toString.call(o).slice(8, -1);\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(o);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);\n}","export default function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}","import arrayWithHoles from \"./arrayWithHoles.js\";\nimport iterableToArrayLimit from \"./iterableToArrayLimit.js\";\nimport unsupportedIterableToArray from \"./unsupportedIterableToArray.js\";\nimport nonIterableRest from \"./nonIterableRest.js\";\nexport default function _slicedToArray(arr, i) {\n return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();\n}","export default function _iterableToArrayLimit(r, l) {\n var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"];\n if (null != t) {\n var e,\n n,\n i,\n u,\n a = [],\n f = !0,\n o = !1;\n try {\n if (i = (t = t.call(r)).next, 0 === l) {\n if (Object(t) !== t) return;\n f = !1;\n } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);\n } catch (r) {\n o = !0, n = r;\n } finally {\n try {\n if (!f && null != t[\"return\"] && (u = t[\"return\"](), Object(u) !== u)) return;\n } finally {\n if (o) throw n;\n }\n }\n return a;\n }\n}","export default function _iterableToArray(iter) {\n if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter);\n}","import arrayWithoutHoles from \"./arrayWithoutHoles.js\";\nimport iterableToArray from \"./iterableToArray.js\";\nimport unsupportedIterableToArray from \"./unsupportedIterableToArray.js\";\nimport nonIterableSpread from \"./nonIterableSpread.js\";\nexport default function _toConsumableArray(arr) {\n return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();\n}","import arrayLikeToArray from \"./arrayLikeToArray.js\";\nexport default function _arrayWithoutHoles(arr) {\n if (Array.isArray(arr)) return arrayLikeToArray(arr);\n}","export default function _nonIterableSpread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}","export default function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}","export default function _typeof(o) {\n \"@babel/helpers - typeof\";\n\n return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) {\n return typeof o;\n } : function (o) {\n return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o;\n }, _typeof(o);\n}","import _typeof from \"./typeof.js\";\nimport toPrimitive from \"./toPrimitive.js\";\nexport default function _toPropertyKey(arg) {\n var key = toPrimitive(arg, \"string\");\n return _typeof(key) === \"symbol\" ? key : String(key);\n}","import _typeof from \"./typeof.js\";\nexport default function _toPrimitive(input, hint) {\n if (_typeof(input) !== \"object\" || input === null) return input;\n var prim = input[Symbol.toPrimitive];\n if (prim !== undefined) {\n var res = prim.call(input, hint || \"default\");\n if (_typeof(res) !== \"object\") return res;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (hint === \"string\" ? String : Number)(input);\n}","import toPropertyKey from \"./toPropertyKey.js\";\nfunction _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor);\n }\n}\nexport default function _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n Object.defineProperty(Constructor, \"prototype\", {\n writable: false\n });\n return Constructor;\n}","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n writable: true,\n configurable: true\n }\n });\n Object.defineProperty(subClass, \"prototype\", {\n writable: false\n });\n if (superClass) setPrototypeOf(subClass, superClass);\n}","export default function _getPrototypeOf(o) {\n _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {\n return o.__proto__ || Object.getPrototypeOf(o);\n };\n return _getPrototypeOf(o);\n}","export default function _isNativeReflectConstruct() {\n if (typeof Reflect === \"undefined\" || !Reflect.construct) return false;\n if (Reflect.construct.sham) return false;\n if (typeof Proxy === \"function\") return true;\n try {\n Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));\n return true;\n } catch (e) {\n return false;\n }\n}","export default function _assertThisInitialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n return self;\n}","import getPrototypeOf from \"./getPrototypeOf.js\";\nimport isNativeReflectConstruct from \"./isNativeReflectConstruct.js\";\nimport possibleConstructorReturn from \"./possibleConstructorReturn.js\";\nexport default function _createSuper(Derived) {\n var hasNativeReflectConstruct = isNativeReflectConstruct();\n return function _createSuperInternal() {\n var Super = getPrototypeOf(Derived),\n result;\n if (hasNativeReflectConstruct) {\n var NewTarget = getPrototypeOf(this).constructor;\n result = Reflect.construct(Super, arguments, NewTarget);\n } else {\n result = Super.apply(this, arguments);\n }\n return possibleConstructorReturn(this, result);\n };\n}","import _typeof from \"./typeof.js\";\nimport assertThisInitialized from \"./assertThisInitialized.js\";\nexport default function _possibleConstructorReturn(self, call) {\n if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) {\n return call;\n } else if (call !== void 0) {\n throw new TypeError(\"Derived constructors may only return object or undefined\");\n }\n return assertThisInitialized(self);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nimport isNativeReflectConstruct from \"./isNativeReflectConstruct.js\";\nexport default function _construct(Parent, args, Class) {\n if (isNativeReflectConstruct()) {\n _construct = Reflect.construct.bind();\n } else {\n _construct = function _construct(Parent, args, Class) {\n var a = [null];\n a.push.apply(a, args);\n var Constructor = Function.bind.apply(Parent, a);\n var instance = new Constructor();\n if (Class) setPrototypeOf(instance, Class.prototype);\n return instance;\n };\n }\n return _construct.apply(null, arguments);\n}","import getPrototypeOf from \"./getPrototypeOf.js\";\nimport setPrototypeOf from \"./setPrototypeOf.js\";\nimport isNativeFunction from \"./isNativeFunction.js\";\nimport construct from \"./construct.js\";\nexport default function _wrapNativeSuper(Class) {\n var _cache = typeof Map === \"function\" ? new Map() : undefined;\n _wrapNativeSuper = function _wrapNativeSuper(Class) {\n if (Class === null || !isNativeFunction(Class)) return Class;\n if (typeof Class !== \"function\") {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n if (typeof _cache !== \"undefined\") {\n if (_cache.has(Class)) return _cache.get(Class);\n _cache.set(Class, Wrapper);\n }\n function Wrapper() {\n return construct(Class, arguments, getPrototypeOf(this).constructor);\n }\n Wrapper.prototype = Object.create(Class.prototype, {\n constructor: {\n value: Wrapper,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n return setPrototypeOf(Wrapper, Class);\n };\n return _wrapNativeSuper(Class);\n}","export default function _isNativeFunction(fn) {\n return Function.toString.call(fn).indexOf(\"[native code]\") !== -1;\n}","import arrayWithHoles from \"./arrayWithHoles.js\";\nimport iterableToArray from \"./iterableToArray.js\";\nimport unsupportedIterableToArray from \"./unsupportedIterableToArray.js\";\nimport nonIterableRest from \"./nonIterableRest.js\";\nexport default function _toArray(arr) {\n return arrayWithHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableRest();\n}","import unsupportedIterableToArray from \"./unsupportedIterableToArray.js\";\nexport default function _createForOfIteratorHelper(o, allowArrayLike) {\n var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"];\n if (!it) {\n if (Array.isArray(o) || (it = unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") {\n if (it) o = it;\n var i = 0;\n var F = function F() {};\n return {\n s: F,\n n: function n() {\n if (i >= o.length) return {\n done: true\n };\n return {\n done: false,\n value: o[i++]\n };\n },\n e: function e(_e) {\n throw _e;\n },\n f: F\n };\n }\n throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n }\n var normalCompletion = true,\n didErr = false,\n err;\n return {\n s: function s() {\n it = it.call(o);\n },\n n: function n() {\n var step = it.next();\n normalCompletion = step.done;\n return step;\n },\n e: function e(_e2) {\n didErr = true;\n err = _e2;\n },\n f: function f() {\n try {\n if (!normalCompletion && it[\"return\"] != null) it[\"return\"]();\n } finally {\n if (didErr) throw err;\n }\n }\n };\n}","import type { Location, Path, To } from \"./history\";\nimport { warning, invariant, parsePath } from \"./history\";\n\n/**\n * Map of routeId -> data returned from a loader/action/error\n */\nexport interface RouteData {\n [routeId: string]: any;\n}\n\nexport enum ResultType {\n data = \"data\",\n deferred = \"deferred\",\n redirect = \"redirect\",\n error = \"error\",\n}\n\n/**\n * Successful result from a loader or action\n */\nexport interface SuccessResult {\n type: ResultType.data;\n data: any;\n statusCode?: number;\n headers?: Headers;\n}\n\n/**\n * Successful defer() result from a loader or action\n */\nexport interface DeferredResult {\n type: ResultType.deferred;\n deferredData: DeferredData;\n statusCode?: number;\n headers?: Headers;\n}\n\n/**\n * Redirect result from a loader or action\n */\nexport interface RedirectResult {\n type: ResultType.redirect;\n status: number;\n location: string;\n revalidate: boolean;\n reloadDocument?: boolean;\n}\n\n/**\n * Unsuccessful result from a loader or action\n */\nexport interface ErrorResult {\n type: ResultType.error;\n error: any;\n headers?: Headers;\n}\n\n/**\n * Result from a loader or action - potentially successful or unsuccessful\n */\nexport type DataResult =\n | SuccessResult\n | DeferredResult\n | RedirectResult\n | ErrorResult;\n\ntype LowerCaseFormMethod = \"get\" | \"post\" | \"put\" | \"patch\" | \"delete\";\ntype UpperCaseFormMethod = Uppercase;\n\n/**\n * Users can specify either lowercase or uppercase form methods on
,\n * useSubmit(), , etc.\n */\nexport type HTMLFormMethod = LowerCaseFormMethod | UpperCaseFormMethod;\n\n/**\n * Active navigation/fetcher form methods are exposed in lowercase on the\n * RouterState\n */\nexport type FormMethod = LowerCaseFormMethod;\nexport type MutationFormMethod = Exclude;\n\n/**\n * In v7, active navigation/fetcher form methods are exposed in uppercase on the\n * RouterState. This is to align with the normalization done via fetch().\n */\nexport type V7_FormMethod = UpperCaseFormMethod;\nexport type V7_MutationFormMethod = Exclude;\n\nexport type FormEncType =\n | \"application/x-www-form-urlencoded\"\n | \"multipart/form-data\"\n | \"application/json\"\n | \"text/plain\";\n\n// Thanks https://github.com/sindresorhus/type-fest!\ntype JsonObject = { [Key in string]: JsonValue } & {\n [Key in string]?: JsonValue | undefined;\n};\ntype JsonArray = JsonValue[] | readonly JsonValue[];\ntype JsonPrimitive = string | number | boolean | null;\ntype JsonValue = JsonPrimitive | JsonObject | JsonArray;\n\n/**\n * @private\n * Internal interface to pass around for action submissions, not intended for\n * external consumption\n */\nexport type Submission =\n | {\n formMethod: FormMethod | V7_FormMethod;\n formAction: string;\n formEncType: FormEncType;\n formData: FormData;\n json: undefined;\n text: undefined;\n }\n | {\n formMethod: FormMethod | V7_FormMethod;\n formAction: string;\n formEncType: FormEncType;\n formData: undefined;\n json: JsonValue;\n text: undefined;\n }\n | {\n formMethod: FormMethod | V7_FormMethod;\n formAction: string;\n formEncType: FormEncType;\n formData: undefined;\n json: undefined;\n text: string;\n };\n\n/**\n * @private\n * Arguments passed to route loader/action functions. Same for now but we keep\n * this as a private implementation detail in case they diverge in the future.\n */\ninterface DataFunctionArgs {\n request: Request;\n params: Params;\n context?: any;\n}\n\n/**\n * Arguments passed to loader functions\n */\nexport interface LoaderFunctionArgs extends DataFunctionArgs {}\n\n/**\n * Arguments passed to action functions\n */\nexport interface ActionFunctionArgs extends DataFunctionArgs {}\n\n/**\n * Loaders and actions can return anything except `undefined` (`null` is a\n * valid return value if there is no data to return). Responses are preferred\n * and will ease any future migration to Remix\n */\ntype DataFunctionValue = Response | NonNullable | null;\n\n/**\n * Route loader function signature\n */\nexport interface LoaderFunction {\n (args: LoaderFunctionArgs): Promise | DataFunctionValue;\n}\n\n/**\n * Route action function signature\n */\nexport interface ActionFunction {\n (args: ActionFunctionArgs): Promise | DataFunctionValue;\n}\n\n/**\n * Route shouldRevalidate function signature. This runs after any submission\n * (navigation or fetcher), so we flatten the navigation/fetcher submission\n * onto the arguments. It shouldn't matter whether it came from a navigation\n * or a fetcher, what really matters is the URLs and the formData since loaders\n * have to re-run based on the data models that were potentially mutated.\n */\nexport interface ShouldRevalidateFunction {\n (args: {\n currentUrl: URL;\n currentParams: AgnosticDataRouteMatch[\"params\"];\n nextUrl: URL;\n nextParams: AgnosticDataRouteMatch[\"params\"];\n formMethod?: Submission[\"formMethod\"];\n formAction?: Submission[\"formAction\"];\n formEncType?: Submission[\"formEncType\"];\n text?: Submission[\"text\"];\n formData?: Submission[\"formData\"];\n json?: Submission[\"json\"];\n actionResult?: DataResult;\n defaultShouldRevalidate: boolean;\n }): boolean;\n}\n\n/**\n * Function provided by the framework-aware layers to set `hasErrorBoundary`\n * from the framework-aware `errorElement` prop\n *\n * @deprecated Use `mapRouteProperties` instead\n */\nexport interface DetectErrorBoundaryFunction {\n (route: AgnosticRouteObject): boolean;\n}\n\n/**\n * Function provided by the framework-aware layers to set any framework-specific\n * properties from framework-agnostic properties\n */\nexport interface MapRoutePropertiesFunction {\n (route: AgnosticRouteObject): {\n hasErrorBoundary: boolean;\n } & Record;\n}\n\n/**\n * Keys we cannot change from within a lazy() function. We spread all other keys\n * onto the route. Either they're meaningful to the router, or they'll get\n * ignored.\n */\nexport type ImmutableRouteKey =\n | \"lazy\"\n | \"caseSensitive\"\n | \"path\"\n | \"id\"\n | \"index\"\n | \"children\";\n\nexport const immutableRouteKeys = new Set([\n \"lazy\",\n \"caseSensitive\",\n \"path\",\n \"id\",\n \"index\",\n \"children\",\n]);\n\ntype RequireOne = Exclude<\n {\n [K in keyof T]: K extends Key ? Omit & Required> : never;\n }[keyof T],\n undefined\n>;\n\n/**\n * lazy() function to load a route definition, which can add non-matching\n * related properties to a route\n */\nexport interface LazyRouteFunction {\n (): Promise>>;\n}\n\n/**\n * Base RouteObject with common props shared by all types of routes\n */\ntype AgnosticBaseRouteObject = {\n caseSensitive?: boolean;\n path?: string;\n id?: string;\n loader?: LoaderFunction;\n action?: ActionFunction;\n hasErrorBoundary?: boolean;\n shouldRevalidate?: ShouldRevalidateFunction;\n handle?: any;\n lazy?: LazyRouteFunction;\n};\n\n/**\n * Index routes must not have children\n */\nexport type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {\n children?: undefined;\n index: true;\n};\n\n/**\n * Non-index routes may have children, but cannot have index\n */\nexport type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {\n children?: AgnosticRouteObject[];\n index?: false;\n};\n\n/**\n * A route object represents a logical route, with (optionally) its child\n * routes organized in a tree-like structure.\n */\nexport type AgnosticRouteObject =\n | AgnosticIndexRouteObject\n | AgnosticNonIndexRouteObject;\n\nexport type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {\n id: string;\n};\n\nexport type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {\n children?: AgnosticDataRouteObject[];\n id: string;\n};\n\n/**\n * A data route object, which is just a RouteObject with a required unique ID\n */\nexport type AgnosticDataRouteObject =\n | AgnosticDataIndexRouteObject\n | AgnosticDataNonIndexRouteObject;\n\nexport type RouteManifest = Record;\n\n// Recursive helper for finding path parameters in the absence of wildcards\ntype _PathParam =\n // split path into individual path segments\n Path extends `${infer L}/${infer R}`\n ? _PathParam | _PathParam\n : // find params after `:`\n Path extends `:${infer Param}`\n ? Param extends `${infer Optional}?`\n ? Optional\n : Param\n : // otherwise, there aren't any params present\n never;\n\n/**\n * Examples:\n * \"/a/b/*\" -> \"*\"\n * \":a\" -> \"a\"\n * \"/a/:b\" -> \"b\"\n * \"/a/blahblahblah:b\" -> \"b\"\n * \"/:a/:b\" -> \"a\" | \"b\"\n * \"/:a/b/:c/*\" -> \"a\" | \"c\" | \"*\"\n */\ntype PathParam =\n // check if path is just a wildcard\n Path extends \"*\" | \"/*\"\n ? \"*\"\n : // look for wildcard at the end of the path\n Path extends `${infer Rest}/*`\n ? \"*\" | _PathParam\n : // look for params in the absence of wildcards\n _PathParam;\n\n// Attempt to parse the given string segment. If it fails, then just return the\n// plain string type as a default fallback. Otherwise return the union of the\n// parsed string literals that were referenced as dynamic segments in the route.\nexport type ParamParseKey =\n // if could not find path params, fallback to `string`\n [PathParam] extends [never] ? string : PathParam;\n\n/**\n * The parameters that were parsed from the URL path.\n */\nexport type Params = {\n readonly [key in Key]: string | undefined;\n};\n\n/**\n * A RouteMatch contains info about how a route matched a URL.\n */\nexport interface AgnosticRouteMatch<\n ParamKey extends string = string,\n RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject\n> {\n /**\n * The names and values of dynamic parameters in the URL.\n */\n params: Params;\n /**\n * The portion of the URL pathname that was matched.\n */\n pathname: string;\n /**\n * The portion of the URL pathname that was matched before child routes.\n */\n pathnameBase: string;\n /**\n * The route object that was used to match.\n */\n route: RouteObjectType;\n}\n\nexport interface AgnosticDataRouteMatch\n extends AgnosticRouteMatch {}\n\nfunction isIndexRoute(\n route: AgnosticRouteObject\n): route is AgnosticIndexRouteObject {\n return route.index === true;\n}\n\n// Walk the route tree generating unique IDs where necessary so we are working\n// solely with AgnosticDataRouteObject's within the Router\nexport function convertRoutesToDataRoutes(\n routes: AgnosticRouteObject[],\n mapRouteProperties: MapRoutePropertiesFunction,\n parentPath: number[] = [],\n manifest: RouteManifest = {}\n): AgnosticDataRouteObject[] {\n return routes.map((route, index) => {\n let treePath = [...parentPath, index];\n let id = typeof route.id === \"string\" ? route.id : treePath.join(\"-\");\n invariant(\n route.index !== true || !route.children,\n `Cannot specify children on an index route`\n );\n invariant(\n !manifest[id],\n `Found a route id collision on id \"${id}\". Route ` +\n \"id's must be globally unique within Data Router usages\"\n );\n\n if (isIndexRoute(route)) {\n let indexRoute: AgnosticDataIndexRouteObject = {\n ...route,\n ...mapRouteProperties(route),\n id,\n };\n manifest[id] = indexRoute;\n return indexRoute;\n } else {\n let pathOrLayoutRoute: AgnosticDataNonIndexRouteObject = {\n ...route,\n ...mapRouteProperties(route),\n id,\n children: undefined,\n };\n manifest[id] = pathOrLayoutRoute;\n\n if (route.children) {\n pathOrLayoutRoute.children = convertRoutesToDataRoutes(\n route.children,\n mapRouteProperties,\n treePath,\n manifest\n );\n }\n\n return pathOrLayoutRoute;\n }\n });\n}\n\n/**\n * Matches the given routes to a location and returns the match data.\n *\n * @see https://reactrouter.com/utils/match-routes\n */\nexport function matchRoutes<\n RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject\n>(\n routes: RouteObjectType[],\n locationArg: Partial | string,\n basename = \"/\"\n): AgnosticRouteMatch[] | null {\n let location =\n typeof locationArg === \"string\" ? parsePath(locationArg) : locationArg;\n\n let pathname = stripBasename(location.pathname || \"/\", basename);\n\n if (pathname == null) {\n return null;\n }\n\n let branches = flattenRoutes(routes);\n rankRouteBranches(branches);\n\n let matches = null;\n for (let i = 0; matches == null && i < branches.length; ++i) {\n matches = matchRouteBranch(\n branches[i],\n // Incoming pathnames are generally encoded from either window.location\n // or from router.navigate, but we want to match against the unencoded\n // paths in the route definitions. Memory router locations won't be\n // encoded here but there also shouldn't be anything to decode so this\n // should be a safe operation. This avoids needing matchRoutes to be\n // history-aware.\n safelyDecodeURI(pathname)\n );\n }\n\n return matches;\n}\n\ninterface RouteMeta<\n RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject\n> {\n relativePath: string;\n caseSensitive: boolean;\n childrenIndex: number;\n route: RouteObjectType;\n}\n\ninterface RouteBranch<\n RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject\n> {\n path: string;\n score: number;\n routesMeta: RouteMeta[];\n}\n\nfunction flattenRoutes<\n RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject\n>(\n routes: RouteObjectType[],\n branches: RouteBranch[] = [],\n parentsMeta: RouteMeta[] = [],\n parentPath = \"\"\n): RouteBranch[] {\n let flattenRoute = (\n route: RouteObjectType,\n index: number,\n relativePath?: string\n ) => {\n let meta: RouteMeta = {\n relativePath:\n relativePath === undefined ? route.path || \"\" : relativePath,\n caseSensitive: route.caseSensitive === true,\n childrenIndex: index,\n route,\n };\n\n if (meta.relativePath.startsWith(\"/\")) {\n invariant(\n meta.relativePath.startsWith(parentPath),\n `Absolute route path \"${meta.relativePath}\" nested under path ` +\n `\"${parentPath}\" is not valid. An absolute child route path ` +\n `must start with the combined path of all its parent routes.`\n );\n\n meta.relativePath = meta.relativePath.slice(parentPath.length);\n }\n\n let path = joinPaths([parentPath, meta.relativePath]);\n let routesMeta = parentsMeta.concat(meta);\n\n // Add the children before adding this route to the array so we traverse the\n // route tree depth-first and child routes appear before their parents in\n // the \"flattened\" version.\n if (route.children && route.children.length > 0) {\n invariant(\n // Our types know better, but runtime JS may not!\n // @ts-expect-error\n route.index !== true,\n `Index routes must not have child routes. Please remove ` +\n `all child routes from route path \"${path}\".`\n );\n\n flattenRoutes(route.children, branches, routesMeta, path);\n }\n\n // Routes without a path shouldn't ever match by themselves unless they are\n // index routes, so don't add them to the list of possible branches.\n if (route.path == null && !route.index) {\n return;\n }\n\n branches.push({\n path,\n score: computeScore(path, route.index),\n routesMeta,\n });\n };\n routes.forEach((route, index) => {\n // coarse-grain check for optional params\n if (route.path === \"\" || !route.path?.includes(\"?\")) {\n flattenRoute(route, index);\n } else {\n for (let exploded of explodeOptionalSegments(route.path)) {\n flattenRoute(route, index, exploded);\n }\n }\n });\n\n return branches;\n}\n\n/**\n * Computes all combinations of optional path segments for a given path,\n * excluding combinations that are ambiguous and of lower priority.\n *\n * For example, `/one/:two?/three/:four?/:five?` explodes to:\n * - `/one/three`\n * - `/one/:two/three`\n * - `/one/three/:four`\n * - `/one/three/:five`\n * - `/one/:two/three/:four`\n * - `/one/:two/three/:five`\n * - `/one/three/:four/:five`\n * - `/one/:two/three/:four/:five`\n */\nfunction explodeOptionalSegments(path: string): string[] {\n let segments = path.split(\"/\");\n if (segments.length === 0) return [];\n\n let [first, ...rest] = segments;\n\n // Optional path segments are denoted by a trailing `?`\n let isOptional = first.endsWith(\"?\");\n // Compute the corresponding required segment: `foo?` -> `foo`\n let required = first.replace(/\\?$/, \"\");\n\n if (rest.length === 0) {\n // Intepret empty string as omitting an optional segment\n // `[\"one\", \"\", \"three\"]` corresponds to omitting `:two` from `/one/:two?/three` -> `/one/three`\n return isOptional ? [required, \"\"] : [required];\n }\n\n let restExploded = explodeOptionalSegments(rest.join(\"/\"));\n\n let result: string[] = [];\n\n // All child paths with the prefix. Do this for all children before the\n // optional version for all children so we get consistent ordering where the\n // parent optional aspect is preferred as required. Otherwise, we can get\n // child sections interspersed where deeper optional segments are higher than\n // parent optional segments, where for example, /:two would explodes _earlier_\n // then /:one. By always including the parent as required _for all children_\n // first, we avoid this issue\n result.push(\n ...restExploded.map((subpath) =>\n subpath === \"\" ? required : [required, subpath].join(\"/\")\n )\n );\n\n // Then if this is an optional value, add all child versions without\n if (isOptional) {\n result.push(...restExploded);\n }\n\n // for absolute paths, ensure `/` instead of empty segment\n return result.map((exploded) =>\n path.startsWith(\"/\") && exploded === \"\" ? \"/\" : exploded\n );\n}\n\nfunction rankRouteBranches(branches: RouteBranch[]): void {\n branches.sort((a, b) =>\n a.score !== b.score\n ? b.score - a.score // Higher score first\n : compareIndexes(\n a.routesMeta.map((meta) => meta.childrenIndex),\n b.routesMeta.map((meta) => meta.childrenIndex)\n )\n );\n}\n\nconst paramRe = /^:\\w+$/;\nconst dynamicSegmentValue = 3;\nconst indexRouteValue = 2;\nconst emptySegmentValue = 1;\nconst staticSegmentValue = 10;\nconst splatPenalty = -2;\nconst isSplat = (s: string) => s === \"*\";\n\nfunction computeScore(path: string, index: boolean | undefined): number {\n let segments = path.split(\"/\");\n let initialScore = segments.length;\n if (segments.some(isSplat)) {\n initialScore += splatPenalty;\n }\n\n if (index) {\n initialScore += indexRouteValue;\n }\n\n return segments\n .filter((s) => !isSplat(s))\n .reduce(\n (score, segment) =>\n score +\n (paramRe.test(segment)\n ? dynamicSegmentValue\n : segment === \"\"\n ? emptySegmentValue\n : staticSegmentValue),\n initialScore\n );\n}\n\nfunction compareIndexes(a: number[], b: number[]): number {\n let siblings =\n a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]);\n\n return siblings\n ? // If two routes are siblings, we should try to match the earlier sibling\n // first. This allows people to have fine-grained control over the matching\n // behavior by simply putting routes with identical paths in the order they\n // want them tried.\n a[a.length - 1] - b[b.length - 1]\n : // Otherwise, it doesn't really make sense to rank non-siblings by index,\n // so they sort equally.\n 0;\n}\n\nfunction matchRouteBranch<\n ParamKey extends string = string,\n RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject\n>(\n branch: RouteBranch,\n pathname: string\n): AgnosticRouteMatch[] | null {\n let { routesMeta } = branch;\n\n let matchedParams = {};\n let matchedPathname = \"/\";\n let matches: AgnosticRouteMatch[] = [];\n for (let i = 0; i < routesMeta.length; ++i) {\n let meta = routesMeta[i];\n let end = i === routesMeta.length - 1;\n let remainingPathname =\n matchedPathname === \"/\"\n ? pathname\n : pathname.slice(matchedPathname.length) || \"/\";\n let match = matchPath(\n { path: meta.relativePath, caseSensitive: meta.caseSensitive, end },\n remainingPathname\n );\n\n if (!match) return null;\n\n Object.assign(matchedParams, match.params);\n\n let route = meta.route;\n\n matches.push({\n // TODO: Can this as be avoided?\n params: matchedParams as Params,\n pathname: joinPaths([matchedPathname, match.pathname]),\n pathnameBase: normalizePathname(\n joinPaths([matchedPathname, match.pathnameBase])\n ),\n route,\n });\n\n if (match.pathnameBase !== \"/\") {\n matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);\n }\n }\n\n return matches;\n}\n\n/**\n * Returns a path with params interpolated.\n *\n * @see https://reactrouter.com/utils/generate-path\n */\nexport function generatePath(\n originalPath: Path,\n params: {\n [key in PathParam]: string | null;\n } = {} as any\n): string {\n let path: string = originalPath;\n if (path.endsWith(\"*\") && path !== \"*\" && !path.endsWith(\"/*\")) {\n warning(\n false,\n `Route path \"${path}\" will be treated as if it were ` +\n `\"${path.replace(/\\*$/, \"/*\")}\" because the \\`*\\` character must ` +\n `always follow a \\`/\\` in the pattern. To get rid of this warning, ` +\n `please change the route path to \"${path.replace(/\\*$/, \"/*\")}\".`\n );\n path = path.replace(/\\*$/, \"/*\") as Path;\n }\n\n // ensure `/` is added at the beginning if the path is absolute\n const prefix = path.startsWith(\"/\") ? \"/\" : \"\";\n\n const stringify = (p: any) =>\n p == null ? \"\" : typeof p === \"string\" ? p : String(p);\n\n const segments = path\n .split(/\\/+/)\n .map((segment, index, array) => {\n const isLastSegment = index === array.length - 1;\n\n // only apply the splat if it's the last segment\n if (isLastSegment && segment === \"*\") {\n const star = \"*\" as PathParam;\n // Apply the splat\n return stringify(params[star]);\n }\n\n const keyMatch = segment.match(/^:(\\w+)(\\??)$/);\n if (keyMatch) {\n const [, key, optional] = keyMatch;\n let param = params[key as PathParam];\n invariant(optional === \"?\" || param != null, `Missing \":${key}\" param`);\n return stringify(param);\n }\n\n // Remove any optional markers from optional static segments\n return segment.replace(/\\?$/g, \"\");\n })\n // Remove empty segments\n .filter((segment) => !!segment);\n\n return prefix + segments.join(\"/\");\n}\n\n/**\n * A PathPattern is used to match on some portion of a URL pathname.\n */\nexport interface PathPattern {\n /**\n * A string to match against a URL pathname. May contain `:id`-style segments\n * to indicate placeholders for dynamic parameters. May also end with `/*` to\n * indicate matching the rest of the URL pathname.\n */\n path: Path;\n /**\n * Should be `true` if the static portions of the `path` should be matched in\n * the same case.\n */\n caseSensitive?: boolean;\n /**\n * Should be `true` if this pattern should match the entire URL pathname.\n */\n end?: boolean;\n}\n\n/**\n * A PathMatch contains info about how a PathPattern matched on a URL pathname.\n */\nexport interface PathMatch {\n /**\n * The names and values of dynamic parameters in the URL.\n */\n params: Params;\n /**\n * The portion of the URL pathname that was matched.\n */\n pathname: string;\n /**\n * The portion of the URL pathname that was matched before child routes.\n */\n pathnameBase: string;\n /**\n * The pattern that was used to match.\n */\n pattern: PathPattern;\n}\n\ntype Mutable = {\n -readonly [P in keyof T]: T[P];\n};\n\n/**\n * Performs pattern matching on a URL pathname and returns information about\n * the match.\n *\n * @see https://reactrouter.com/utils/match-path\n */\nexport function matchPath<\n ParamKey extends ParamParseKey,\n Path extends string\n>(\n pattern: PathPattern | Path,\n pathname: string\n): PathMatch | null {\n if (typeof pattern === \"string\") {\n pattern = { path: pattern, caseSensitive: false, end: true };\n }\n\n let [matcher, paramNames] = compilePath(\n pattern.path,\n pattern.caseSensitive,\n pattern.end\n );\n\n let match = pathname.match(matcher);\n if (!match) return null;\n\n let matchedPathname = match[0];\n let pathnameBase = matchedPathname.replace(/(.)\\/+$/, \"$1\");\n let captureGroups = match.slice(1);\n let params: Params = paramNames.reduce>(\n (memo, paramName, index) => {\n // We need to compute the pathnameBase here using the raw splat value\n // instead of using params[\"*\"] later because it will be decoded then\n if (paramName === \"*\") {\n let splatValue = captureGroups[index] || \"\";\n pathnameBase = matchedPathname\n .slice(0, matchedPathname.length - splatValue.length)\n .replace(/(.)\\/+$/, \"$1\");\n }\n\n memo[paramName] = safelyDecodeURIComponent(\n captureGroups[index] || \"\",\n paramName\n );\n return memo;\n },\n {}\n );\n\n return {\n params,\n pathname: matchedPathname,\n pathnameBase,\n pattern,\n };\n}\n\nfunction compilePath(\n path: string,\n caseSensitive = false,\n end = true\n): [RegExp, string[]] {\n warning(\n path === \"*\" || !path.endsWith(\"*\") || path.endsWith(\"/*\"),\n `Route path \"${path}\" will be treated as if it were ` +\n `\"${path.replace(/\\*$/, \"/*\")}\" because the \\`*\\` character must ` +\n `always follow a \\`/\\` in the pattern. To get rid of this warning, ` +\n `please change the route path to \"${path.replace(/\\*$/, \"/*\")}\".`\n );\n\n let paramNames: string[] = [];\n let regexpSource =\n \"^\" +\n path\n .replace(/\\/*\\*?$/, \"\") // Ignore trailing / and /*, we'll handle it below\n .replace(/^\\/*/, \"/\") // Make sure it has a leading /\n .replace(/[\\\\.*+^$?{}|()[\\]]/g, \"\\\\$&\") // Escape special regex chars\n .replace(/\\/:(\\w+)/g, (_: string, paramName: string) => {\n paramNames.push(paramName);\n return \"/([^\\\\/]+)\";\n });\n\n if (path.endsWith(\"*\")) {\n paramNames.push(\"*\");\n regexpSource +=\n path === \"*\" || path === \"/*\"\n ? \"(.*)$\" // Already matched the initial /, just match the rest\n : \"(?:\\\\/(.+)|\\\\/*)$\"; // Don't include the / in params[\"*\"]\n } else if (end) {\n // When matching to the end, ignore trailing slashes\n regexpSource += \"\\\\/*$\";\n } else if (path !== \"\" && path !== \"/\") {\n // If our path is non-empty and contains anything beyond an initial slash,\n // then we have _some_ form of path in our regex so we should expect to\n // match only if we find the end of this path segment. Look for an optional\n // non-captured trailing slash (to match a portion of the URL) or the end\n // of the path (if we've matched to the end). We used to do this with a\n // word boundary but that gives false positives on routes like\n // /user-preferences since `-` counts as a word boundary.\n regexpSource += \"(?:(?=\\\\/|$))\";\n } else {\n // Nothing to match for \"\" or \"/\"\n }\n\n let matcher = new RegExp(regexpSource, caseSensitive ? undefined : \"i\");\n\n return [matcher, paramNames];\n}\n\nfunction safelyDecodeURI(value: string) {\n try {\n return decodeURI(value);\n } catch (error) {\n warning(\n false,\n `The URL path \"${value}\" could not be decoded because it is is a ` +\n `malformed URL segment. This is probably due to a bad percent ` +\n `encoding (${error}).`\n );\n\n return value;\n }\n}\n\nfunction safelyDecodeURIComponent(value: string, paramName: string) {\n try {\n return decodeURIComponent(value);\n } catch (error) {\n warning(\n false,\n `The value for the URL param \"${paramName}\" will not be decoded because` +\n ` the string \"${value}\" is a malformed URL segment. This is probably` +\n ` due to a bad percent encoding (${error}).`\n );\n\n return value;\n }\n}\n\n/**\n * @private\n */\nexport function stripBasename(\n pathname: string,\n basename: string\n): string | null {\n if (basename === \"/\") return pathname;\n\n if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {\n return null;\n }\n\n // We want to leave trailing slash behavior in the user's control, so if they\n // specify a basename with a trailing slash, we should support it\n let startIndex = basename.endsWith(\"/\")\n ? basename.length - 1\n : basename.length;\n let nextChar = pathname.charAt(startIndex);\n if (nextChar && nextChar !== \"/\") {\n // pathname does not start with basename/\n return null;\n }\n\n return pathname.slice(startIndex) || \"/\";\n}\n\n/**\n * Returns a resolved path object relative to the given pathname.\n *\n * @see https://reactrouter.com/utils/resolve-path\n */\nexport function resolvePath(to: To, fromPathname = \"/\"): Path {\n let {\n pathname: toPathname,\n search = \"\",\n hash = \"\",\n } = typeof to === \"string\" ? parsePath(to) : to;\n\n let pathname = toPathname\n ? toPathname.startsWith(\"/\")\n ? toPathname\n : resolvePathname(toPathname, fromPathname)\n : fromPathname;\n\n return {\n pathname,\n search: normalizeSearch(search),\n hash: normalizeHash(hash),\n };\n}\n\nfunction resolvePathname(relativePath: string, fromPathname: string): string {\n let segments = fromPathname.replace(/\\/+$/, \"\").split(\"/\");\n let relativeSegments = relativePath.split(\"/\");\n\n relativeSegments.forEach((segment) => {\n if (segment === \"..\") {\n // Keep the root \"\" segment so the pathname starts at /\n if (segments.length > 1) segments.pop();\n } else if (segment !== \".\") {\n segments.push(segment);\n }\n });\n\n return segments.length > 1 ? segments.join(\"/\") : \"/\";\n}\n\nfunction getInvalidPathError(\n char: string,\n field: string,\n dest: string,\n path: Partial\n) {\n return (\n `Cannot include a '${char}' character in a manually specified ` +\n `\\`to.${field}\\` field [${JSON.stringify(\n path\n )}]. Please separate it out to the ` +\n `\\`to.${dest}\\` field. Alternatively you may provide the full path as ` +\n `a string in and the router will parse it for you.`\n );\n}\n\n/**\n * @private\n *\n * When processing relative navigation we want to ignore ancestor routes that\n * do not contribute to the path, such that index/pathless layout routes don't\n * interfere.\n *\n * For example, when moving a route element into an index route and/or a\n * pathless layout route, relative link behavior contained within should stay\n * the same. Both of the following examples should link back to the root:\n *\n * \n * \n * \n *\n * \n * \n * }> // <-- Does not contribute\n * // <-- Does not contribute\n * \n * \n */\nexport function getPathContributingMatches<\n T extends AgnosticRouteMatch = AgnosticRouteMatch\n>(matches: T[]) {\n return matches.filter(\n (match, index) =>\n index === 0 || (match.route.path && match.route.path.length > 0)\n );\n}\n\n/**\n * @private\n */\nexport function resolveTo(\n toArg: To,\n routePathnames: string[],\n locationPathname: string,\n isPathRelative = false\n): Path {\n let to: Partial;\n if (typeof toArg === \"string\") {\n to = parsePath(toArg);\n } else {\n to = { ...toArg };\n\n invariant(\n !to.pathname || !to.pathname.includes(\"?\"),\n getInvalidPathError(\"?\", \"pathname\", \"search\", to)\n );\n invariant(\n !to.pathname || !to.pathname.includes(\"#\"),\n getInvalidPathError(\"#\", \"pathname\", \"hash\", to)\n );\n invariant(\n !to.search || !to.search.includes(\"#\"),\n getInvalidPathError(\"#\", \"search\", \"hash\", to)\n );\n }\n\n let isEmptyPath = toArg === \"\" || to.pathname === \"\";\n let toPathname = isEmptyPath ? \"/\" : to.pathname;\n\n let from: string;\n\n // Routing is relative to the current pathname if explicitly requested.\n //\n // If a pathname is explicitly provided in `to`, it should be relative to the\n // route context. This is explained in `Note on `` values` in our\n // migration guide from v5 as a means of disambiguation between `to` values\n // that begin with `/` and those that do not. However, this is problematic for\n // `to` values that do not provide a pathname. `to` can simply be a search or\n // hash string, in which case we should assume that the navigation is relative\n // to the current location's pathname and *not* the route pathname.\n if (isPathRelative || toPathname == null) {\n from = locationPathname;\n } else {\n let routePathnameIndex = routePathnames.length - 1;\n\n if (toPathname.startsWith(\"..\")) {\n let toSegments = toPathname.split(\"/\");\n\n // Each leading .. segment means \"go up one route\" instead of \"go up one\n // URL segment\". This is a key difference from how works and a\n // major reason we call this a \"to\" value instead of a \"href\".\n while (toSegments[0] === \"..\") {\n toSegments.shift();\n routePathnameIndex -= 1;\n }\n\n to.pathname = toSegments.join(\"/\");\n }\n\n // If there are more \"..\" segments than parent routes, resolve relative to\n // the root / URL.\n from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : \"/\";\n }\n\n let path = resolvePath(to, from);\n\n // Ensure the pathname has a trailing slash if the original \"to\" had one\n let hasExplicitTrailingSlash =\n toPathname && toPathname !== \"/\" && toPathname.endsWith(\"/\");\n // Or if this was a link to the current path which has a trailing slash\n let hasCurrentTrailingSlash =\n (isEmptyPath || toPathname === \".\") && locationPathname.endsWith(\"/\");\n if (\n !path.pathname.endsWith(\"/\") &&\n (hasExplicitTrailingSlash || hasCurrentTrailingSlash)\n ) {\n path.pathname += \"/\";\n }\n\n return path;\n}\n\n/**\n * @private\n */\nexport function getToPathname(to: To): string | undefined {\n // Empty strings should be treated the same as / paths\n return to === \"\" || (to as Path).pathname === \"\"\n ? \"/\"\n : typeof to === \"string\"\n ? parsePath(to).pathname\n : to.pathname;\n}\n\n/**\n * @private\n */\nexport const joinPaths = (paths: string[]): string =>\n paths.join(\"/\").replace(/\\/\\/+/g, \"/\");\n\n/**\n * @private\n */\nexport const normalizePathname = (pathname: string): string =>\n pathname.replace(/\\/+$/, \"\").replace(/^\\/*/, \"/\");\n\n/**\n * @private\n */\nexport const normalizeSearch = (search: string): string =>\n !search || search === \"?\"\n ? \"\"\n : search.startsWith(\"?\")\n ? search\n : \"?\" + search;\n\n/**\n * @private\n */\nexport const normalizeHash = (hash: string): string =>\n !hash || hash === \"#\" ? \"\" : hash.startsWith(\"#\") ? hash : \"#\" + hash;\n\nexport type JsonFunction = (\n data: Data,\n init?: number | ResponseInit\n) => Response;\n\n/**\n * This is a shortcut for creating `application/json` responses. Converts `data`\n * to JSON and sets the `Content-Type` header.\n */\nexport const json: JsonFunction = (data, init = {}) => {\n let responseInit = typeof init === \"number\" ? { status: init } : init;\n\n let headers = new Headers(responseInit.headers);\n if (!headers.has(\"Content-Type\")) {\n headers.set(\"Content-Type\", \"application/json; charset=utf-8\");\n }\n\n return new Response(JSON.stringify(data), {\n ...responseInit,\n headers,\n });\n};\n\nexport interface TrackedPromise extends Promise {\n _tracked?: boolean;\n _data?: any;\n _error?: any;\n}\n\nexport class AbortedDeferredError extends Error {}\n\nexport class DeferredData {\n private pendingKeysSet: Set = new Set();\n private controller: AbortController;\n private abortPromise: Promise;\n private unlistenAbortSignal: () => void;\n private subscribers: Set<(aborted: boolean, settledKey?: string) => void> =\n new Set();\n data: Record;\n init?: ResponseInit;\n deferredKeys: string[] = [];\n\n constructor(data: Record, responseInit?: ResponseInit) {\n invariant(\n data && typeof data === \"object\" && !Array.isArray(data),\n \"defer() only accepts plain objects\"\n );\n\n // Set up an AbortController + Promise we can race against to exit early\n // cancellation\n let reject: (e: AbortedDeferredError) => void;\n this.abortPromise = new Promise((_, r) => (reject = r));\n this.controller = new AbortController();\n let onAbort = () =>\n reject(new AbortedDeferredError(\"Deferred data aborted\"));\n this.unlistenAbortSignal = () =>\n this.controller.signal.removeEventListener(\"abort\", onAbort);\n this.controller.signal.addEventListener(\"abort\", onAbort);\n\n this.data = Object.entries(data).reduce(\n (acc, [key, value]) =>\n Object.assign(acc, {\n [key]: this.trackPromise(key, value),\n }),\n {}\n );\n\n if (this.done) {\n // All incoming values were resolved\n this.unlistenAbortSignal();\n }\n\n this.init = responseInit;\n }\n\n private trackPromise(\n key: string,\n value: Promise | unknown\n ): TrackedPromise | unknown {\n if (!(value instanceof Promise)) {\n return value;\n }\n\n this.deferredKeys.push(key);\n this.pendingKeysSet.add(key);\n\n // We store a little wrapper promise that will be extended with\n // _data/_error props upon resolve/reject\n let promise: TrackedPromise = Promise.race([value, this.abortPromise]).then(\n (data) => this.onSettle(promise, key, undefined, data as unknown),\n (error) => this.onSettle(promise, key, error as unknown)\n );\n\n // Register rejection listeners to avoid uncaught promise rejections on\n // errors or aborted deferred values\n promise.catch(() => {});\n\n Object.defineProperty(promise, \"_tracked\", { get: () => true });\n return promise;\n }\n\n private onSettle(\n promise: TrackedPromise,\n key: string,\n error: unknown,\n data?: unknown\n ): unknown {\n if (\n this.controller.signal.aborted &&\n error instanceof AbortedDeferredError\n ) {\n this.unlistenAbortSignal();\n Object.defineProperty(promise, \"_error\", { get: () => error });\n return Promise.reject(error);\n }\n\n this.pendingKeysSet.delete(key);\n\n if (this.done) {\n // Nothing left to abort!\n this.unlistenAbortSignal();\n }\n\n // If the promise was resolved/rejected with undefined, we'll throw an error as you\n // should always resolve with a value or null\n if (error === undefined && data === undefined) {\n let undefinedError = new Error(\n `Deferred data for key \"${key}\" resolved/rejected with \\`undefined\\`, ` +\n `you must resolve/reject with a value or \\`null\\`.`\n );\n Object.defineProperty(promise, \"_error\", { get: () => undefinedError });\n this.emit(false, key);\n return Promise.reject(undefinedError);\n }\n\n if (data === undefined) {\n Object.defineProperty(promise, \"_error\", { get: () => error });\n this.emit(false, key);\n return Promise.reject(error);\n }\n\n Object.defineProperty(promise, \"_data\", { get: () => data });\n this.emit(false, key);\n return data;\n }\n\n private emit(aborted: boolean, settledKey?: string) {\n this.subscribers.forEach((subscriber) => subscriber(aborted, settledKey));\n }\n\n subscribe(fn: (aborted: boolean, settledKey?: string) => void) {\n this.subscribers.add(fn);\n return () => this.subscribers.delete(fn);\n }\n\n cancel() {\n this.controller.abort();\n this.pendingKeysSet.forEach((v, k) => this.pendingKeysSet.delete(k));\n this.emit(true);\n }\n\n async resolveData(signal: AbortSignal) {\n let aborted = false;\n if (!this.done) {\n let onAbort = () => this.cancel();\n signal.addEventListener(\"abort\", onAbort);\n aborted = await new Promise((resolve) => {\n this.subscribe((aborted) => {\n signal.removeEventListener(\"abort\", onAbort);\n if (aborted || this.done) {\n resolve(aborted);\n }\n });\n });\n }\n return aborted;\n }\n\n get done() {\n return this.pendingKeysSet.size === 0;\n }\n\n get unwrappedData() {\n invariant(\n this.data !== null && this.done,\n \"Can only unwrap data on initialized and settled deferreds\"\n );\n\n return Object.entries(this.data).reduce(\n (acc, [key, value]) =>\n Object.assign(acc, {\n [key]: unwrapTrackedPromise(value),\n }),\n {}\n );\n }\n\n get pendingKeys() {\n return Array.from(this.pendingKeysSet);\n }\n}\n\nfunction isTrackedPromise(value: any): value is TrackedPromise {\n return (\n value instanceof Promise && (value as TrackedPromise)._tracked === true\n );\n}\n\nfunction unwrapTrackedPromise(value: any) {\n if (!isTrackedPromise(value)) {\n return value;\n }\n\n if (value._error) {\n throw value._error;\n }\n return value._data;\n}\n\nexport type DeferFunction = (\n data: Record,\n init?: number | ResponseInit\n) => DeferredData;\n\nexport const defer: DeferFunction = (data, init = {}) => {\n let responseInit = typeof init === \"number\" ? { status: init } : init;\n\n return new DeferredData(data, responseInit);\n};\n\nexport type RedirectFunction = (\n url: string,\n init?: number | ResponseInit\n) => Response;\n\n/**\n * A redirect response. Sets the status code and the `Location` header.\n * Defaults to \"302 Found\".\n */\nexport const redirect: RedirectFunction = (url, init = 302) => {\n let responseInit = init;\n if (typeof responseInit === \"number\") {\n responseInit = { status: responseInit };\n } else if (typeof responseInit.status === \"undefined\") {\n responseInit.status = 302;\n }\n\n let headers = new Headers(responseInit.headers);\n headers.set(\"Location\", url);\n\n return new Response(null, {\n ...responseInit,\n headers,\n });\n};\n\n/**\n * A redirect response that will force a document reload to the new location.\n * Sets the status code and the `Location` header.\n * Defaults to \"302 Found\".\n */\nexport const redirectDocument: RedirectFunction = (url, init) => {\n let response = redirect(url, init);\n response.headers.set(\"X-Remix-Reload-Document\", \"true\");\n return response;\n};\n\n/**\n * @private\n * Utility class we use to hold auto-unwrapped 4xx/5xx Response bodies\n */\nexport class ErrorResponse {\n status: number;\n statusText: string;\n data: any;\n error?: Error;\n internal: boolean;\n\n constructor(\n status: number,\n statusText: string | undefined,\n data: any,\n internal = false\n ) {\n this.status = status;\n this.statusText = statusText || \"\";\n this.internal = internal;\n if (data instanceof Error) {\n this.data = data.toString();\n this.error = data;\n } else {\n this.data = data;\n }\n }\n}\n\n/**\n * Check if the given error is an ErrorResponse generated from a 4xx/5xx\n * Response thrown from an action/loader\n */\nexport function isRouteErrorResponse(error: any): error is ErrorResponse {\n return (\n error != null &&\n typeof error.status === \"number\" &&\n typeof error.statusText === \"string\" &&\n typeof error.internal === \"boolean\" &&\n \"data\" in error\n );\n}\n","import type { History, Location, Path, To } from \"./history\";\nimport {\n Action as HistoryAction,\n createLocation,\n createPath,\n invariant,\n parsePath,\n warning,\n} from \"./history\";\nimport type {\n DataResult,\n DeferredData,\n AgnosticDataRouteMatch,\n AgnosticDataRouteObject,\n DeferredResult,\n ErrorResult,\n FormEncType,\n FormMethod,\n DetectErrorBoundaryFunction,\n RedirectResult,\n RouteData,\n AgnosticRouteObject,\n Submission,\n SuccessResult,\n AgnosticRouteMatch,\n ShouldRevalidateFunction,\n RouteManifest,\n ImmutableRouteKey,\n ActionFunction,\n LoaderFunction,\n V7_MutationFormMethod,\n V7_FormMethod,\n HTMLFormMethod,\n MutationFormMethod,\n MapRoutePropertiesFunction,\n} from \"./utils\";\nimport {\n ErrorResponse,\n ResultType,\n convertRoutesToDataRoutes,\n getPathContributingMatches,\n immutableRouteKeys,\n isRouteErrorResponse,\n joinPaths,\n matchRoutes,\n resolveTo,\n stripBasename,\n} from \"./utils\";\n\n////////////////////////////////////////////////////////////////////////////////\n//#region Types and Constants\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * A Router instance manages all navigation and data loading/mutations\n */\nexport interface Router {\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Return the basename for the router\n */\n get basename(): RouterInit[\"basename\"];\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Return the current state of the router\n */\n get state(): RouterState;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Return the routes for this router instance\n */\n get routes(): AgnosticDataRouteObject[];\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Initialize the router, including adding history listeners and kicking off\n * initial data fetches. Returns a function to cleanup listeners and abort\n * any in-progress loads\n */\n initialize(): Router;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Subscribe to router.state updates\n *\n * @param fn function to call with the new state\n */\n subscribe(fn: RouterSubscriber): () => void;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Enable scroll restoration behavior in the router\n *\n * @param savedScrollPositions Object that will manage positions, in case\n * it's being restored from sessionStorage\n * @param getScrollPosition Function to get the active Y scroll position\n * @param getKey Function to get the key to use for restoration\n */\n enableScrollRestoration(\n savedScrollPositions: Record,\n getScrollPosition: GetScrollPositionFunction,\n getKey?: GetScrollRestorationKeyFunction\n ): () => void;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Navigate forward/backward in the history stack\n * @param to Delta to move in the history stack\n */\n navigate(to: number): Promise;\n\n /**\n * Navigate to the given path\n * @param to Path to navigate to\n * @param opts Navigation options (method, submission, etc.)\n */\n navigate(to: To | null, opts?: RouterNavigateOptions): Promise;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Trigger a fetcher load/submission\n *\n * @param key Fetcher key\n * @param routeId Route that owns the fetcher\n * @param href href to fetch\n * @param opts Fetcher options, (method, submission, etc.)\n */\n fetch(\n key: string,\n routeId: string,\n href: string | null,\n opts?: RouterFetchOptions\n ): void;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Trigger a revalidation of all current route loaders and fetcher loads\n */\n revalidate(): void;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Utility function to create an href for the given location\n * @param location\n */\n createHref(location: Location | URL): string;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Utility function to URL encode a destination path according to the internal\n * history implementation\n * @param to\n */\n encodeLocation(to: To): Path;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Get/create a fetcher for the given key\n * @param key\n */\n getFetcher(key?: string): Fetcher;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Delete the fetcher for a given key\n * @param key\n */\n deleteFetcher(key?: string): void;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Cleanup listeners and abort any in-progress loads\n */\n dispose(): void;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Get a navigation blocker\n * @param key The identifier for the blocker\n * @param fn The blocker function implementation\n */\n getBlocker(key: string, fn: BlockerFunction): Blocker;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Delete a navigation blocker\n * @param key The identifier for the blocker\n */\n deleteBlocker(key: string): void;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * HMR needs to pass in-flight route updates to React Router\n * TODO: Replace this with granular route update APIs (addRoute, updateRoute, deleteRoute)\n */\n _internalSetRoutes(routes: AgnosticRouteObject[]): void;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Internal fetch AbortControllers accessed by unit tests\n */\n _internalFetchControllers: Map;\n\n /**\n * @internal\n * PRIVATE - DO NOT USE\n *\n * Internal pending DeferredData instances accessed by unit tests\n */\n _internalActiveDeferreds: Map;\n}\n\n/**\n * State maintained internally by the router. During a navigation, all states\n * reflect the the \"old\" location unless otherwise noted.\n */\nexport interface RouterState {\n /**\n * The action of the most recent navigation\n */\n historyAction: HistoryAction;\n\n /**\n * The current location reflected by the router\n */\n location: Location;\n\n /**\n * The current set of route matches\n */\n matches: AgnosticDataRouteMatch[];\n\n /**\n * Tracks whether we've completed our initial data load\n */\n initialized: boolean;\n\n /**\n * Current scroll position we should start at for a new view\n * - number -> scroll position to restore to\n * - false -> do not restore scroll at all (used during submissions)\n * - null -> don't have a saved position, scroll to hash or top of page\n */\n restoreScrollPosition: number | false | null;\n\n /**\n * Indicate whether this navigation should skip resetting the scroll position\n * if we are unable to restore the scroll position\n */\n preventScrollReset: boolean;\n\n /**\n * Tracks the state of the current navigation\n */\n navigation: Navigation;\n\n /**\n * Tracks any in-progress revalidations\n */\n revalidation: RevalidationState;\n\n /**\n * Data from the loaders for the current matches\n */\n loaderData: RouteData;\n\n /**\n * Data from the action for the current matches\n */\n actionData: RouteData | null;\n\n /**\n * Errors caught from loaders for the current matches\n */\n errors: RouteData | null;\n\n /**\n * Map of current fetchers\n */\n fetchers: Map;\n\n /**\n * Map of current blockers\n */\n blockers: Map;\n}\n\n/**\n * Data that can be passed into hydrate a Router from SSR\n */\nexport type HydrationState = Partial<\n Pick\n>;\n\n/**\n * Future flags to toggle new feature behavior\n */\nexport interface FutureConfig {\n v7_normalizeFormMethod: boolean;\n v7_prependBasename: boolean;\n}\n\n/**\n * Initialization options for createRouter\n */\nexport interface RouterInit {\n routes: AgnosticRouteObject[];\n history: History;\n basename?: string;\n /**\n * @deprecated Use `mapRouteProperties` instead\n */\n detectErrorBoundary?: DetectErrorBoundaryFunction;\n mapRouteProperties?: MapRoutePropertiesFunction;\n future?: Partial;\n hydrationData?: HydrationState;\n window?: Window;\n}\n\n/**\n * State returned from a server-side query() call\n */\nexport interface StaticHandlerContext {\n basename: Router[\"basename\"];\n location: RouterState[\"location\"];\n matches: RouterState[\"matches\"];\n loaderData: RouterState[\"loaderData\"];\n actionData: RouterState[\"actionData\"];\n errors: RouterState[\"errors\"];\n statusCode: number;\n loaderHeaders: Record;\n actionHeaders: Record;\n activeDeferreds: Record | null;\n _deepestRenderedBoundaryId?: string | null;\n}\n\n/**\n * A StaticHandler instance manages a singular SSR navigation/fetch event\n */\nexport interface StaticHandler {\n dataRoutes: AgnosticDataRouteObject[];\n query(\n request: Request,\n opts?: { requestContext?: unknown }\n ): Promise;\n queryRoute(\n request: Request,\n opts?: { routeId?: string; requestContext?: unknown }\n ): Promise;\n}\n\n/**\n * Subscriber function signature for changes to router state\n */\nexport interface RouterSubscriber {\n (state: RouterState): void;\n}\n\ninterface UseMatchesMatch {\n id: string;\n pathname: string;\n params: AgnosticRouteMatch[\"params\"];\n data: unknown;\n handle: unknown;\n}\n\n/**\n * Function signature for determining the key to be used in scroll restoration\n * for a given location\n */\nexport interface GetScrollRestorationKeyFunction {\n (location: Location, matches: UseMatchesMatch[]): string | null;\n}\n\n/**\n * Function signature for determining the current scroll position\n */\nexport interface GetScrollPositionFunction {\n (): number;\n}\n\nexport type RelativeRoutingType = \"route\" | \"path\";\n\n// Allowed for any navigation or fetch\ntype BaseNavigateOrFetchOptions = {\n preventScrollReset?: boolean;\n relative?: RelativeRoutingType;\n};\n\n// Only allowed for navigations\ntype BaseNavigateOptions = BaseNavigateOrFetchOptions & {\n replace?: boolean;\n state?: any;\n fromRouteId?: string;\n};\n\n// Only allowed for submission navigations\ntype BaseSubmissionOptions = {\n formMethod?: HTMLFormMethod;\n formEncType?: FormEncType;\n} & (\n | { formData: FormData; body?: undefined }\n | { formData?: undefined; body: any }\n);\n\n/**\n * Options for a navigate() call for a normal (non-submission) navigation\n */\ntype LinkNavigateOptions = BaseNavigateOptions;\n\n/**\n * Options for a navigate() call for a submission navigation\n */\ntype SubmissionNavigateOptions = BaseNavigateOptions & BaseSubmissionOptions;\n\n/**\n * Options to pass to navigate() for a navigation\n */\nexport type RouterNavigateOptions =\n | LinkNavigateOptions\n | SubmissionNavigateOptions;\n\n/**\n * Options for a fetch() load\n */\ntype LoadFetchOptions = BaseNavigateOrFetchOptions;\n\n/**\n * Options for a fetch() submission\n */\ntype SubmitFetchOptions = BaseNavigateOrFetchOptions & BaseSubmissionOptions;\n\n/**\n * Options to pass to fetch()\n */\nexport type RouterFetchOptions = LoadFetchOptions | SubmitFetchOptions;\n\n/**\n * Potential states for state.navigation\n */\nexport type NavigationStates = {\n Idle: {\n state: \"idle\";\n location: undefined;\n formMethod: undefined;\n formAction: undefined;\n formEncType: undefined;\n formData: undefined;\n json: undefined;\n text: undefined;\n };\n Loading: {\n state: \"loading\";\n location: Location;\n formMethod: Submission[\"formMethod\"] | undefined;\n formAction: Submission[\"formAction\"] | undefined;\n formEncType: Submission[\"formEncType\"] | undefined;\n formData: Submission[\"formData\"] | undefined;\n json: Submission[\"json\"] | undefined;\n text: Submission[\"text\"] | undefined;\n };\n Submitting: {\n state: \"submitting\";\n location: Location;\n formMethod: Submission[\"formMethod\"];\n formAction: Submission[\"formAction\"];\n formEncType: Submission[\"formEncType\"];\n formData: Submission[\"formData\"];\n json: Submission[\"json\"];\n text: Submission[\"text\"];\n };\n};\n\nexport type Navigation = NavigationStates[keyof NavigationStates];\n\nexport type RevalidationState = \"idle\" | \"loading\";\n\n/**\n * Potential states for fetchers\n */\ntype FetcherStates = {\n Idle: {\n state: \"idle\";\n formMethod: undefined;\n formAction: undefined;\n formEncType: undefined;\n text: undefined;\n formData: undefined;\n json: undefined;\n data: TData | undefined;\n \" _hasFetcherDoneAnything \"?: boolean;\n };\n Loading: {\n state: \"loading\";\n formMethod: Submission[\"formMethod\"] | undefined;\n formAction: Submission[\"formAction\"] | undefined;\n formEncType: Submission[\"formEncType\"] | undefined;\n text: Submission[\"text\"] | undefined;\n formData: Submission[\"formData\"] | undefined;\n json: Submission[\"json\"] | undefined;\n data: TData | undefined;\n \" _hasFetcherDoneAnything \"?: boolean;\n };\n Submitting: {\n state: \"submitting\";\n formMethod: Submission[\"formMethod\"];\n formAction: Submission[\"formAction\"];\n formEncType: Submission[\"formEncType\"];\n text: Submission[\"text\"];\n formData: Submission[\"formData\"];\n json: Submission[\"json\"];\n data: TData | undefined;\n \" _hasFetcherDoneAnything \"?: boolean;\n };\n};\n\nexport type Fetcher =\n FetcherStates[keyof FetcherStates];\n\ninterface BlockerBlocked {\n state: \"blocked\";\n reset(): void;\n proceed(): void;\n location: Location;\n}\n\ninterface BlockerUnblocked {\n state: \"unblocked\";\n reset: undefined;\n proceed: undefined;\n location: undefined;\n}\n\ninterface BlockerProceeding {\n state: \"proceeding\";\n reset: undefined;\n proceed: undefined;\n location: Location;\n}\n\nexport type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;\n\nexport type BlockerFunction = (args: {\n currentLocation: Location;\n nextLocation: Location;\n historyAction: HistoryAction;\n}) => boolean;\n\ninterface ShortCircuitable {\n /**\n * startNavigation does not need to complete the navigation because we\n * redirected or got interrupted\n */\n shortCircuited?: boolean;\n}\n\ninterface HandleActionResult extends ShortCircuitable {\n /**\n * Error thrown from the current action, keyed by the route containing the\n * error boundary to render the error. To be committed to the state after\n * loaders have completed\n */\n pendingActionError?: RouteData;\n /**\n * Data returned from the current action, keyed by the route owning the action.\n * To be committed to the state after loaders have completed\n */\n pendingActionData?: RouteData;\n}\n\ninterface HandleLoadersResult extends ShortCircuitable {\n /**\n * loaderData returned from the current set of loaders\n */\n loaderData?: RouterState[\"loaderData\"];\n /**\n * errors thrown from the current set of loaders\n */\n errors?: RouterState[\"errors\"];\n}\n\n/**\n * Cached info for active fetcher.load() instances so they can participate\n * in revalidation\n */\ninterface FetchLoadMatch {\n routeId: string;\n path: string;\n}\n\n/**\n * Identified fetcher.load() calls that need to be revalidated\n */\ninterface RevalidatingFetcher extends FetchLoadMatch {\n key: string;\n match: AgnosticDataRouteMatch | null;\n matches: AgnosticDataRouteMatch[] | null;\n controller: AbortController | null;\n}\n\n/**\n * Wrapper object to allow us to throw any response out from callLoaderOrAction\n * for queryRouter while preserving whether or not it was thrown or returned\n * from the loader/action\n */\ninterface QueryRouteResponse {\n type: ResultType.data | ResultType.error;\n response: Response;\n}\n\nconst validMutationMethodsArr: MutationFormMethod[] = [\n \"post\",\n \"put\",\n \"patch\",\n \"delete\",\n];\nconst validMutationMethods = new Set(\n validMutationMethodsArr\n);\n\nconst validRequestMethodsArr: FormMethod[] = [\n \"get\",\n ...validMutationMethodsArr,\n];\nconst validRequestMethods = new Set(validRequestMethodsArr);\n\nconst redirectStatusCodes = new Set([301, 302, 303, 307, 308]);\nconst redirectPreserveMethodStatusCodes = new Set([307, 308]);\n\nexport const IDLE_NAVIGATION: NavigationStates[\"Idle\"] = {\n state: \"idle\",\n location: undefined,\n formMethod: undefined,\n formAction: undefined,\n formEncType: undefined,\n formData: undefined,\n json: undefined,\n text: undefined,\n};\n\nexport const IDLE_FETCHER: FetcherStates[\"Idle\"] = {\n state: \"idle\",\n data: undefined,\n formMethod: undefined,\n formAction: undefined,\n formEncType: undefined,\n formData: undefined,\n json: undefined,\n text: undefined,\n};\n\nexport const IDLE_BLOCKER: BlockerUnblocked = {\n state: \"unblocked\",\n proceed: undefined,\n reset: undefined,\n location: undefined,\n};\n\nconst ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\\/\\/)/i;\n\nconst defaultMapRouteProperties: MapRoutePropertiesFunction = (route) => ({\n hasErrorBoundary: Boolean(route.hasErrorBoundary),\n});\n\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region createRouter\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * Create a router and listen to history POP navigations\n */\nexport function createRouter(init: RouterInit): Router {\n const routerWindow = init.window\n ? init.window\n : typeof window !== \"undefined\"\n ? window\n : undefined;\n const isBrowser =\n typeof routerWindow !== \"undefined\" &&\n typeof routerWindow.document !== \"undefined\" &&\n typeof routerWindow.document.createElement !== \"undefined\";\n const isServer = !isBrowser;\n\n invariant(\n init.routes.length > 0,\n \"You must provide a non-empty routes array to createRouter\"\n );\n\n let mapRouteProperties: MapRoutePropertiesFunction;\n if (init.mapRouteProperties) {\n mapRouteProperties = init.mapRouteProperties;\n } else if (init.detectErrorBoundary) {\n // If they are still using the deprecated version, wrap it with the new API\n let detectErrorBoundary = init.detectErrorBoundary;\n mapRouteProperties = (route) => ({\n hasErrorBoundary: detectErrorBoundary(route),\n });\n } else {\n mapRouteProperties = defaultMapRouteProperties;\n }\n\n // Routes keyed by ID\n let manifest: RouteManifest = {};\n // Routes in tree format for matching\n let dataRoutes = convertRoutesToDataRoutes(\n init.routes,\n mapRouteProperties,\n undefined,\n manifest\n );\n let inFlightDataRoutes: AgnosticDataRouteObject[] | undefined;\n let basename = init.basename || \"/\";\n // Config driven behavior flags\n let future: FutureConfig = {\n v7_normalizeFormMethod: false,\n v7_prependBasename: false,\n ...init.future,\n };\n // Cleanup function for history\n let unlistenHistory: (() => void) | null = null;\n // Externally-provided functions to call on all state changes\n let subscribers = new Set();\n // Externally-provided object to hold scroll restoration locations during routing\n let savedScrollPositions: Record | null = null;\n // Externally-provided function to get scroll restoration keys\n let getScrollRestorationKey: GetScrollRestorationKeyFunction | null = null;\n // Externally-provided function to get current scroll position\n let getScrollPosition: GetScrollPositionFunction | null = null;\n // One-time flag to control the initial hydration scroll restoration. Because\n // we don't get the saved positions from until _after_\n // the initial render, we need to manually trigger a separate updateState to\n // send along the restoreScrollPosition\n // Set to true if we have `hydrationData` since we assume we were SSR'd and that\n // SSR did the initial scroll restoration.\n let initialScrollRestored = init.hydrationData != null;\n\n let initialMatches = matchRoutes(dataRoutes, init.history.location, basename);\n let initialErrors: RouteData | null = null;\n\n if (initialMatches == null) {\n // If we do not match a user-provided-route, fall back to the root\n // to allow the error boundary to take over\n let error = getInternalRouterError(404, {\n pathname: init.history.location.pathname,\n });\n let { matches, route } = getShortCircuitMatches(dataRoutes);\n initialMatches = matches;\n initialErrors = { [route.id]: error };\n }\n\n let initialized =\n // All initialMatches need to be loaded before we're ready. If we have lazy\n // functions around still then we'll need to run them in initialize()\n !initialMatches.some((m) => m.route.lazy) &&\n // And we have to either have no loaders or have been provided hydrationData\n (!initialMatches.some((m) => m.route.loader) || init.hydrationData != null);\n\n let router: Router;\n let state: RouterState = {\n historyAction: init.history.action,\n location: init.history.location,\n matches: initialMatches,\n initialized,\n navigation: IDLE_NAVIGATION,\n // Don't restore on initial updateState() if we were SSR'd\n restoreScrollPosition: init.hydrationData != null ? false : null,\n preventScrollReset: false,\n revalidation: \"idle\",\n loaderData: (init.hydrationData && init.hydrationData.loaderData) || {},\n actionData: (init.hydrationData && init.hydrationData.actionData) || null,\n errors: (init.hydrationData && init.hydrationData.errors) || initialErrors,\n fetchers: new Map(),\n blockers: new Map(),\n };\n\n // -- Stateful internal variables to manage navigations --\n // Current navigation in progress (to be committed in completeNavigation)\n let pendingAction: HistoryAction = HistoryAction.Pop;\n\n // Should the current navigation prevent the scroll reset if scroll cannot\n // be restored?\n let pendingPreventScrollReset = false;\n\n // AbortController for the active navigation\n let pendingNavigationController: AbortController | null;\n\n // We use this to avoid touching history in completeNavigation if a\n // revalidation is entirely uninterrupted\n let isUninterruptedRevalidation = false;\n\n // Use this internal flag to force revalidation of all loaders:\n // - submissions (completed or interrupted)\n // - useRevalidator()\n // - X-Remix-Revalidate (from redirect)\n let isRevalidationRequired = false;\n\n // Use this internal array to capture routes that require revalidation due\n // to a cancelled deferred on action submission\n let cancelledDeferredRoutes: string[] = [];\n\n // Use this internal array to capture fetcher loads that were cancelled by an\n // action navigation and require revalidation\n let cancelledFetcherLoads: string[] = [];\n\n // AbortControllers for any in-flight fetchers\n let fetchControllers = new Map();\n\n // Track loads based on the order in which they started\n let incrementingLoadId = 0;\n\n // Track the outstanding pending navigation data load to be compared against\n // the globally incrementing load when a fetcher load lands after a completed\n // navigation\n let pendingNavigationLoadId = -1;\n\n // Fetchers that triggered data reloads as a result of their actions\n let fetchReloadIds = new Map();\n\n // Fetchers that triggered redirect navigations\n let fetchRedirectIds = new Set();\n\n // Most recent href/match for fetcher.load calls for fetchers\n let fetchLoadMatches = new Map();\n\n // Store DeferredData instances for active route matches. When a\n // route loader returns defer() we stick one in here. Then, when a nested\n // promise resolves we update loaderData. If a new navigation starts we\n // cancel active deferreds for eliminated routes.\n let activeDeferreds = new Map();\n\n // Store blocker functions in a separate Map outside of router state since\n // we don't need to update UI state if they change\n let blockerFunctions = new Map();\n\n // Flag to ignore the next history update, so we can revert the URL change on\n // a POP navigation that was blocked by the user without touching router state\n let ignoreNextHistoryUpdate = false;\n\n // Initialize the router, all side effects should be kicked off from here.\n // Implemented as a Fluent API for ease of:\n // let router = createRouter(init).initialize();\n function initialize() {\n // If history informs us of a POP navigation, start the navigation but do not update\n // state. We'll update our own state once the navigation completes\n unlistenHistory = init.history.listen(\n ({ action: historyAction, location, delta }) => {\n // Ignore this event if it was just us resetting the URL from a\n // blocked POP navigation\n if (ignoreNextHistoryUpdate) {\n ignoreNextHistoryUpdate = false;\n return;\n }\n\n warning(\n blockerFunctions.size === 0 || delta != null,\n \"You are trying to use a blocker on a POP navigation to a location \" +\n \"that was not created by @remix-run/router. This will fail silently in \" +\n \"production. This can happen if you are navigating outside the router \" +\n \"via `window.history.pushState`/`window.location.hash` instead of using \" +\n \"router navigation APIs. This can also happen if you are using \" +\n \"createHashRouter and the user manually changes the URL.\"\n );\n\n let blockerKey = shouldBlockNavigation({\n currentLocation: state.location,\n nextLocation: location,\n historyAction,\n });\n\n if (blockerKey && delta != null) {\n // Restore the URL to match the current UI, but don't update router state\n ignoreNextHistoryUpdate = true;\n init.history.go(delta * -1);\n\n // Put the blocker into a blocked state\n updateBlocker(blockerKey, {\n state: \"blocked\",\n location,\n proceed() {\n updateBlocker(blockerKey!, {\n state: \"proceeding\",\n proceed: undefined,\n reset: undefined,\n location,\n });\n // Re-do the same POP navigation we just blocked\n init.history.go(delta);\n },\n reset() {\n let blockers = new Map(state.blockers);\n blockers.set(blockerKey!, IDLE_BLOCKER);\n updateState({ blockers });\n },\n });\n return;\n }\n\n return startNavigation(historyAction, location);\n }\n );\n\n // Kick off initial data load if needed. Use Pop to avoid modifying history\n // Note we don't do any handling of lazy here. For SPA's it'll get handled\n // in the normal navigation flow. For SSR it's expected that lazy modules are\n // resolved prior to router creation since we can't go into a fallbackElement\n // UI for SSR'd apps\n if (!state.initialized) {\n startNavigation(HistoryAction.Pop, state.location);\n }\n\n return router;\n }\n\n // Clean up a router and it's side effects\n function dispose() {\n if (unlistenHistory) {\n unlistenHistory();\n }\n subscribers.clear();\n pendingNavigationController && pendingNavigationController.abort();\n state.fetchers.forEach((_, key) => deleteFetcher(key));\n state.blockers.forEach((_, key) => deleteBlocker(key));\n }\n\n // Subscribe to state updates for the router\n function subscribe(fn: RouterSubscriber) {\n subscribers.add(fn);\n return () => subscribers.delete(fn);\n }\n\n // Update our state and notify the calling context of the change\n function updateState(newState: Partial): void {\n state = {\n ...state,\n ...newState,\n };\n subscribers.forEach((subscriber) => subscriber(state));\n }\n\n // Complete a navigation returning the state.navigation back to the IDLE_NAVIGATION\n // and setting state.[historyAction/location/matches] to the new route.\n // - Location is a required param\n // - Navigation will always be set to IDLE_NAVIGATION\n // - Can pass any other state in newState\n function completeNavigation(\n location: Location,\n newState: Partial>\n ): void {\n // Deduce if we're in a loading/actionReload state:\n // - We have committed actionData in the store\n // - The current navigation was a mutation submission\n // - We're past the submitting state and into the loading state\n // - The location being loaded is not the result of a redirect\n let isActionReload =\n state.actionData != null &&\n state.navigation.formMethod != null &&\n isMutationMethod(state.navigation.formMethod) &&\n state.navigation.state === \"loading\" &&\n location.state?._isRedirect !== true;\n\n let actionData: RouteData | null;\n if (newState.actionData) {\n if (Object.keys(newState.actionData).length > 0) {\n actionData = newState.actionData;\n } else {\n // Empty actionData -> clear prior actionData due to an action error\n actionData = null;\n }\n } else if (isActionReload) {\n // Keep the current data if we're wrapping up the action reload\n actionData = state.actionData;\n } else {\n // Clear actionData on any other completed navigations\n actionData = null;\n }\n\n // Always preserve any existing loaderData from re-used routes\n let loaderData = newState.loaderData\n ? mergeLoaderData(\n state.loaderData,\n newState.loaderData,\n newState.matches || [],\n newState.errors\n )\n : state.loaderData;\n\n // On a successful navigation we can assume we got through all blockers\n // so we can start fresh\n let blockers = state.blockers;\n if (blockers.size > 0) {\n blockers = new Map(blockers);\n blockers.forEach((_, k) => blockers.set(k, IDLE_BLOCKER));\n }\n\n // Always respect the user flag. Otherwise don't reset on mutation\n // submission navigations unless they redirect\n let preventScrollReset =\n pendingPreventScrollReset === true ||\n (state.navigation.formMethod != null &&\n isMutationMethod(state.navigation.formMethod) &&\n location.state?._isRedirect !== true);\n\n if (inFlightDataRoutes) {\n dataRoutes = inFlightDataRoutes;\n inFlightDataRoutes = undefined;\n }\n\n if (isUninterruptedRevalidation) {\n // If this was an uninterrupted revalidation then do not touch history\n } else if (pendingAction === HistoryAction.Pop) {\n // Do nothing for POP - URL has already been updated\n } else if (pendingAction === HistoryAction.Push) {\n init.history.push(location, location.state);\n } else if (pendingAction === HistoryAction.Replace) {\n init.history.replace(location, location.state);\n }\n\n updateState({\n ...newState, // matches, errors, fetchers go through as-is\n actionData,\n loaderData,\n historyAction: pendingAction,\n location,\n initialized: true,\n navigation: IDLE_NAVIGATION,\n revalidation: \"idle\",\n restoreScrollPosition: getSavedScrollPosition(\n location,\n newState.matches || state.matches\n ),\n preventScrollReset,\n blockers,\n });\n\n // Reset stateful navigation vars\n pendingAction = HistoryAction.Pop;\n pendingPreventScrollReset = false;\n isUninterruptedRevalidation = false;\n isRevalidationRequired = false;\n cancelledDeferredRoutes = [];\n cancelledFetcherLoads = [];\n }\n\n // Trigger a navigation event, which can either be a numerical POP or a PUSH\n // replace with an optional submission\n async function navigate(\n to: number | To | null,\n opts?: RouterNavigateOptions\n ): Promise {\n if (typeof to === \"number\") {\n init.history.go(to);\n return;\n }\n\n let normalizedPath = normalizeTo(\n state.location,\n state.matches,\n basename,\n future.v7_prependBasename,\n to,\n opts?.fromRouteId,\n opts?.relative\n );\n let { path, submission, error } = normalizeNavigateOptions(\n future.v7_normalizeFormMethod,\n false,\n normalizedPath,\n opts\n );\n\n let currentLocation = state.location;\n let nextLocation = createLocation(state.location, path, opts && opts.state);\n\n // When using navigate as a PUSH/REPLACE we aren't reading an already-encoded\n // URL from window.location, so we need to encode it here so the behavior\n // remains the same as POP and non-data-router usages. new URL() does all\n // the same encoding we'd get from a history.pushState/window.location read\n // without having to touch history\n nextLocation = {\n ...nextLocation,\n ...init.history.encodeLocation(nextLocation),\n };\n\n let userReplace = opts && opts.replace != null ? opts.replace : undefined;\n\n let historyAction = HistoryAction.Push;\n\n if (userReplace === true) {\n historyAction = HistoryAction.Replace;\n } else if (userReplace === false) {\n // no-op\n } else if (\n submission != null &&\n isMutationMethod(submission.formMethod) &&\n submission.formAction === state.location.pathname + state.location.search\n ) {\n // By default on submissions to the current location we REPLACE so that\n // users don't have to double-click the back button to get to the prior\n // location. If the user redirects to a different location from the\n // action/loader this will be ignored and the redirect will be a PUSH\n historyAction = HistoryAction.Replace;\n }\n\n let preventScrollReset =\n opts && \"preventScrollReset\" in opts\n ? opts.preventScrollReset === true\n : undefined;\n\n let blockerKey = shouldBlockNavigation({\n currentLocation,\n nextLocation,\n historyAction,\n });\n\n if (blockerKey) {\n // Put the blocker into a blocked state\n updateBlocker(blockerKey, {\n state: \"blocked\",\n location: nextLocation,\n proceed() {\n updateBlocker(blockerKey!, {\n state: \"proceeding\",\n proceed: undefined,\n reset: undefined,\n location: nextLocation,\n });\n // Send the same navigation through\n navigate(to, opts);\n },\n reset() {\n let blockers = new Map(state.blockers);\n blockers.set(blockerKey!, IDLE_BLOCKER);\n updateState({ blockers });\n },\n });\n return;\n }\n\n return await startNavigation(historyAction, nextLocation, {\n submission,\n // Send through the formData serialization error if we have one so we can\n // render at the right error boundary after we match routes\n pendingError: error,\n preventScrollReset,\n replace: opts && opts.replace,\n });\n }\n\n // Revalidate all current loaders. If a navigation is in progress or if this\n // is interrupted by a navigation, allow this to \"succeed\" by calling all\n // loaders during the next loader round\n function revalidate() {\n interruptActiveLoads();\n updateState({ revalidation: \"loading\" });\n\n // If we're currently submitting an action, we don't need to start a new\n // navigation, we'll just let the follow up loader execution call all loaders\n if (state.navigation.state === \"submitting\") {\n return;\n }\n\n // If we're currently in an idle state, start a new navigation for the current\n // action/location and mark it as uninterrupted, which will skip the history\n // update in completeNavigation\n if (state.navigation.state === \"idle\") {\n startNavigation(state.historyAction, state.location, {\n startUninterruptedRevalidation: true,\n });\n return;\n }\n\n // Otherwise, if we're currently in a loading state, just start a new\n // navigation to the navigation.location but do not trigger an uninterrupted\n // revalidation so that history correctly updates once the navigation completes\n startNavigation(\n pendingAction || state.historyAction,\n state.navigation.location,\n { overrideNavigation: state.navigation }\n );\n }\n\n // Start a navigation to the given action/location. Can optionally provide a\n // overrideNavigation which will override the normalLoad in the case of a redirect\n // navigation\n async function startNavigation(\n historyAction: HistoryAction,\n location: Location,\n opts?: {\n submission?: Submission;\n fetcherSubmission?: Submission;\n overrideNavigation?: Navigation;\n pendingError?: ErrorResponse;\n startUninterruptedRevalidation?: boolean;\n preventScrollReset?: boolean;\n replace?: boolean;\n }\n ): Promise {\n // Abort any in-progress navigations and start a new one. Unset any ongoing\n // uninterrupted revalidations unless told otherwise, since we want this\n // new navigation to update history normally\n pendingNavigationController && pendingNavigationController.abort();\n pendingNavigationController = null;\n pendingAction = historyAction;\n isUninterruptedRevalidation =\n (opts && opts.startUninterruptedRevalidation) === true;\n\n // Save the current scroll position every time we start a new navigation,\n // and track whether we should reset scroll on completion\n saveScrollPosition(state.location, state.matches);\n pendingPreventScrollReset = (opts && opts.preventScrollReset) === true;\n\n let routesToUse = inFlightDataRoutes || dataRoutes;\n let loadingNavigation = opts && opts.overrideNavigation;\n let matches = matchRoutes(routesToUse, location, basename);\n\n // Short circuit with a 404 on the root error boundary if we match nothing\n if (!matches) {\n let error = getInternalRouterError(404, { pathname: location.pathname });\n let { matches: notFoundMatches, route } =\n getShortCircuitMatches(routesToUse);\n // Cancel all pending deferred on 404s since we don't keep any routes\n cancelActiveDeferreds();\n completeNavigation(location, {\n matches: notFoundMatches,\n loaderData: {},\n errors: {\n [route.id]: error,\n },\n });\n return;\n }\n\n // Short circuit if it's only a hash change and not a revalidation or\n // mutation submission.\n //\n // Ignore on initial page loads because since the initial load will always\n // be \"same hash\". For example, on /page#hash and submit a \n // which will default to a navigation to /page\n if (\n state.initialized &&\n !isRevalidationRequired &&\n isHashChangeOnly(state.location, location) &&\n !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))\n ) {\n completeNavigation(location, { matches });\n return;\n }\n\n // Create a controller/Request for this navigation\n pendingNavigationController = new AbortController();\n let request = createClientSideRequest(\n init.history,\n location,\n pendingNavigationController.signal,\n opts && opts.submission\n );\n let pendingActionData: RouteData | undefined;\n let pendingError: RouteData | undefined;\n\n if (opts && opts.pendingError) {\n // If we have a pendingError, it means the user attempted a GET submission\n // with binary FormData so assign here and skip to handleLoaders. That\n // way we handle calling loaders above the boundary etc. It's not really\n // different from an actionError in that sense.\n pendingError = {\n [findNearestBoundary(matches).route.id]: opts.pendingError,\n };\n } else if (\n opts &&\n opts.submission &&\n isMutationMethod(opts.submission.formMethod)\n ) {\n // Call action if we received an action submission\n let actionOutput = await handleAction(\n request,\n location,\n opts.submission,\n matches,\n { replace: opts.replace }\n );\n\n if (actionOutput.shortCircuited) {\n return;\n }\n\n pendingActionData = actionOutput.pendingActionData;\n pendingError = actionOutput.pendingActionError;\n loadingNavigation = getLoadingNavigation(location, opts.submission);\n\n // Create a GET request for the loaders\n request = new Request(request.url, { signal: request.signal });\n }\n\n // Call loaders\n let { shortCircuited, loaderData, errors } = await handleLoaders(\n request,\n location,\n matches,\n loadingNavigation,\n opts && opts.submission,\n opts && opts.fetcherSubmission,\n opts && opts.replace,\n pendingActionData,\n pendingError\n );\n\n if (shortCircuited) {\n return;\n }\n\n // Clean up now that the action/loaders have completed. Don't clean up if\n // we short circuited because pendingNavigationController will have already\n // been assigned to a new controller for the next navigation\n pendingNavigationController = null;\n\n completeNavigation(location, {\n matches,\n ...(pendingActionData ? { actionData: pendingActionData } : {}),\n loaderData,\n errors,\n });\n }\n\n // Call the action matched by the leaf route for this navigation and handle\n // redirects/errors\n async function handleAction(\n request: Request,\n location: Location,\n submission: Submission,\n matches: AgnosticDataRouteMatch[],\n opts: { replace?: boolean } = {}\n ): Promise {\n interruptActiveLoads();\n\n // Put us in a submitting state\n let navigation = getSubmittingNavigation(location, submission);\n updateState({ navigation });\n\n // Call our action and get the result\n let result: DataResult;\n let actionMatch = getTargetMatch(matches, location);\n\n if (!actionMatch.route.action && !actionMatch.route.lazy) {\n result = {\n type: ResultType.error,\n error: getInternalRouterError(405, {\n method: request.method,\n pathname: location.pathname,\n routeId: actionMatch.route.id,\n }),\n };\n } else {\n result = await callLoaderOrAction(\n \"action\",\n request,\n actionMatch,\n matches,\n manifest,\n mapRouteProperties,\n basename\n );\n\n if (request.signal.aborted) {\n return { shortCircuited: true };\n }\n }\n\n if (isRedirectResult(result)) {\n let replace: boolean;\n if (opts && opts.replace != null) {\n replace = opts.replace;\n } else {\n // If the user didn't explicity indicate replace behavior, replace if\n // we redirected to the exact same location we're currently at to avoid\n // double back-buttons\n replace =\n result.location === state.location.pathname + state.location.search;\n }\n await startRedirectNavigation(state, result, { submission, replace });\n return { shortCircuited: true };\n }\n\n if (isErrorResult(result)) {\n // Store off the pending error - we use it to determine which loaders\n // to call and will commit it when we complete the navigation\n let boundaryMatch = findNearestBoundary(matches, actionMatch.route.id);\n\n // By default, all submissions are REPLACE navigations, but if the\n // action threw an error that'll be rendered in an errorElement, we fall\n // back to PUSH so that the user can use the back button to get back to\n // the pre-submission form location to try again\n if ((opts && opts.replace) !== true) {\n pendingAction = HistoryAction.Push;\n }\n\n return {\n // Send back an empty object we can use to clear out any prior actionData\n pendingActionData: {},\n pendingActionError: { [boundaryMatch.route.id]: result.error },\n };\n }\n\n if (isDeferredResult(result)) {\n throw getInternalRouterError(400, { type: \"defer-action\" });\n }\n\n return {\n pendingActionData: { [actionMatch.route.id]: result.data },\n };\n }\n\n // Call all applicable loaders for the given matches, handling redirects,\n // errors, etc.\n async function handleLoaders(\n request: Request,\n location: Location,\n matches: AgnosticDataRouteMatch[],\n overrideNavigation?: Navigation,\n submission?: Submission,\n fetcherSubmission?: Submission,\n replace?: boolean,\n pendingActionData?: RouteData,\n pendingError?: RouteData\n ): Promise {\n // Figure out the right navigation we want to use for data loading\n let loadingNavigation =\n overrideNavigation || getLoadingNavigation(location, submission);\n\n // If this was a redirect from an action we don't have a \"submission\" but\n // we have it on the loading navigation so use that if available\n let activeSubmission =\n submission ||\n fetcherSubmission ||\n getSubmissionFromNavigation(loadingNavigation);\n\n let routesToUse = inFlightDataRoutes || dataRoutes;\n let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(\n init.history,\n state,\n matches,\n activeSubmission,\n location,\n isRevalidationRequired,\n cancelledDeferredRoutes,\n cancelledFetcherLoads,\n fetchLoadMatches,\n fetchRedirectIds,\n routesToUse,\n basename,\n pendingActionData,\n pendingError\n );\n\n // Cancel pending deferreds for no-longer-matched routes or routes we're\n // about to reload. Note that if this is an action reload we would have\n // already cancelled all pending deferreds so this would be a no-op\n cancelActiveDeferreds(\n (routeId) =>\n !(matches && matches.some((m) => m.route.id === routeId)) ||\n (matchesToLoad && matchesToLoad.some((m) => m.route.id === routeId))\n );\n\n pendingNavigationLoadId = ++incrementingLoadId;\n\n // Short circuit if we have no loaders to run\n if (matchesToLoad.length === 0 && revalidatingFetchers.length === 0) {\n let updatedFetchers = markFetchRedirectsDone();\n completeNavigation(location, {\n matches,\n loaderData: {},\n // Commit pending error if we're short circuiting\n errors: pendingError || null,\n ...(pendingActionData ? { actionData: pendingActionData } : {}),\n ...(updatedFetchers ? { fetchers: new Map(state.fetchers) } : {}),\n });\n return { shortCircuited: true };\n }\n\n // If this is an uninterrupted revalidation, we remain in our current idle\n // state. If not, we need to switch to our loading state and load data,\n // preserving any new action data or existing action data (in the case of\n // a revalidation interrupting an actionReload)\n if (!isUninterruptedRevalidation) {\n revalidatingFetchers.forEach((rf) => {\n let fetcher = state.fetchers.get(rf.key);\n let revalidatingFetcher = getLoadingFetcher(\n undefined,\n fetcher ? fetcher.data : undefined\n );\n state.fetchers.set(rf.key, revalidatingFetcher);\n });\n let actionData = pendingActionData || state.actionData;\n updateState({\n navigation: loadingNavigation,\n ...(actionData\n ? Object.keys(actionData).length === 0\n ? { actionData: null }\n : { actionData }\n : {}),\n ...(revalidatingFetchers.length > 0\n ? { fetchers: new Map(state.fetchers) }\n : {}),\n });\n }\n\n revalidatingFetchers.forEach((rf) => {\n if (fetchControllers.has(rf.key)) {\n abortFetcher(rf.key);\n }\n if (rf.controller) {\n // Fetchers use an independent AbortController so that aborting a fetcher\n // (via deleteFetcher) does not abort the triggering navigation that\n // triggered the revalidation\n fetchControllers.set(rf.key, rf.controller);\n }\n });\n\n // Proxy navigation abort through to revalidation fetchers\n let abortPendingFetchRevalidations = () =>\n revalidatingFetchers.forEach((f) => abortFetcher(f.key));\n if (pendingNavigationController) {\n pendingNavigationController.signal.addEventListener(\n \"abort\",\n abortPendingFetchRevalidations\n );\n }\n\n let { results, loaderResults, fetcherResults } =\n await callLoadersAndMaybeResolveData(\n state.matches,\n matches,\n matchesToLoad,\n revalidatingFetchers,\n request\n );\n\n if (request.signal.aborted) {\n return { shortCircuited: true };\n }\n\n // Clean up _after_ loaders have completed. Don't clean up if we short\n // circuited because fetchControllers would have been aborted and\n // reassigned to new controllers for the next navigation\n if (pendingNavigationController) {\n pendingNavigationController.signal.removeEventListener(\n \"abort\",\n abortPendingFetchRevalidations\n );\n }\n revalidatingFetchers.forEach((rf) => fetchControllers.delete(rf.key));\n\n // If any loaders returned a redirect Response, start a new REPLACE navigation\n let redirect = findRedirect(results);\n if (redirect) {\n if (redirect.idx >= matchesToLoad.length) {\n // If this redirect came from a fetcher make sure we mark it in\n // fetchRedirectIds so it doesn't get revalidated on the next set of\n // loader executions\n let fetcherKey =\n revalidatingFetchers[redirect.idx - matchesToLoad.length].key;\n fetchRedirectIds.add(fetcherKey);\n }\n await startRedirectNavigation(state, redirect.result, { replace });\n return { shortCircuited: true };\n }\n\n // Process and commit output from loaders\n let { loaderData, errors } = processLoaderData(\n state,\n matches,\n matchesToLoad,\n loaderResults,\n pendingError,\n revalidatingFetchers,\n fetcherResults,\n activeDeferreds\n );\n\n // Wire up subscribers to update loaderData as promises settle\n activeDeferreds.forEach((deferredData, routeId) => {\n deferredData.subscribe((aborted) => {\n // Note: No need to updateState here since the TrackedPromise on\n // loaderData is stable across resolve/reject\n // Remove this instance if we were aborted or if promises have settled\n if (aborted || deferredData.done) {\n activeDeferreds.delete(routeId);\n }\n });\n });\n\n let updatedFetchers = markFetchRedirectsDone();\n let didAbortFetchLoads = abortStaleFetchLoads(pendingNavigationLoadId);\n let shouldUpdateFetchers =\n updatedFetchers || didAbortFetchLoads || revalidatingFetchers.length > 0;\n\n return {\n loaderData,\n errors,\n ...(shouldUpdateFetchers ? { fetchers: new Map(state.fetchers) } : {}),\n };\n }\n\n function getFetcher(key: string): Fetcher {\n return state.fetchers.get(key) || IDLE_FETCHER;\n }\n\n // Trigger a fetcher load/submit for the given fetcher key\n function fetch(\n key: string,\n routeId: string,\n href: string | null,\n opts?: RouterFetchOptions\n ) {\n if (isServer) {\n throw new Error(\n \"router.fetch() was called during the server render, but it shouldn't be. \" +\n \"You are likely calling a useFetcher() method in the body of your component. \" +\n \"Try moving it to a useEffect or a callback.\"\n );\n }\n\n if (fetchControllers.has(key)) abortFetcher(key);\n\n let routesToUse = inFlightDataRoutes || dataRoutes;\n let normalizedPath = normalizeTo(\n state.location,\n state.matches,\n basename,\n future.v7_prependBasename,\n href,\n routeId,\n opts?.relative\n );\n let matches = matchRoutes(routesToUse, normalizedPath, basename);\n\n if (!matches) {\n setFetcherError(\n key,\n routeId,\n getInternalRouterError(404, { pathname: normalizedPath })\n );\n return;\n }\n\n let { path, submission, error } = normalizeNavigateOptions(\n future.v7_normalizeFormMethod,\n true,\n normalizedPath,\n opts\n );\n\n if (error) {\n setFetcherError(key, routeId, error);\n return;\n }\n\n let match = getTargetMatch(matches, path);\n\n pendingPreventScrollReset = (opts && opts.preventScrollReset) === true;\n\n if (submission && isMutationMethod(submission.formMethod)) {\n handleFetcherAction(key, routeId, path, match, matches, submission);\n return;\n }\n\n // Store off the match so we can call it's shouldRevalidate on subsequent\n // revalidations\n fetchLoadMatches.set(key, { routeId, path });\n handleFetcherLoader(key, routeId, path, match, matches, submission);\n }\n\n // Call the action for the matched fetcher.submit(), and then handle redirects,\n // errors, and revalidation\n async function handleFetcherAction(\n key: string,\n routeId: string,\n path: string,\n match: AgnosticDataRouteMatch,\n requestMatches: AgnosticDataRouteMatch[],\n submission: Submission\n ) {\n interruptActiveLoads();\n fetchLoadMatches.delete(key);\n\n if (!match.route.action && !match.route.lazy) {\n let error = getInternalRouterError(405, {\n method: submission.formMethod,\n pathname: path,\n routeId: routeId,\n });\n setFetcherError(key, routeId, error);\n return;\n }\n\n // Put this fetcher into it's submitting state\n let existingFetcher = state.fetchers.get(key);\n let fetcher = getSubmittingFetcher(submission, existingFetcher);\n state.fetchers.set(key, fetcher);\n updateState({ fetchers: new Map(state.fetchers) });\n\n // Call the action for the fetcher\n let abortController = new AbortController();\n let fetchRequest = createClientSideRequest(\n init.history,\n path,\n abortController.signal,\n submission\n );\n fetchControllers.set(key, abortController);\n\n let originatingLoadId = incrementingLoadId;\n let actionResult = await callLoaderOrAction(\n \"action\",\n fetchRequest,\n match,\n requestMatches,\n manifest,\n mapRouteProperties,\n basename\n );\n\n if (fetchRequest.signal.aborted) {\n // We can delete this so long as we weren't aborted by ou our own fetcher\n // re-submit which would have put _new_ controller is in fetchControllers\n if (fetchControllers.get(key) === abortController) {\n fetchControllers.delete(key);\n }\n return;\n }\n\n if (isRedirectResult(actionResult)) {\n fetchControllers.delete(key);\n if (pendingNavigationLoadId > originatingLoadId) {\n // A new navigation was kicked off after our action started, so that\n // should take precedence over this redirect navigation. We already\n // set isRevalidationRequired so all loaders for the new route should\n // fire unless opted out via shouldRevalidate\n let doneFetcher = getDoneFetcher(undefined);\n state.fetchers.set(key, doneFetcher);\n updateState({ fetchers: new Map(state.fetchers) });\n return;\n } else {\n fetchRedirectIds.add(key);\n let loadingFetcher = getLoadingFetcher(submission);\n state.fetchers.set(key, loadingFetcher);\n updateState({ fetchers: new Map(state.fetchers) });\n\n return startRedirectNavigation(state, actionResult, {\n submission,\n isFetchActionRedirect: true,\n });\n }\n }\n\n // Process any non-redirect errors thrown\n if (isErrorResult(actionResult)) {\n setFetcherError(key, routeId, actionResult.error);\n return;\n }\n\n if (isDeferredResult(actionResult)) {\n throw getInternalRouterError(400, { type: \"defer-action\" });\n }\n\n // Start the data load for current matches, or the next location if we're\n // in the middle of a navigation\n let nextLocation = state.navigation.location || state.location;\n let revalidationRequest = createClientSideRequest(\n init.history,\n nextLocation,\n abortController.signal\n );\n let routesToUse = inFlightDataRoutes || dataRoutes;\n let matches =\n state.navigation.state !== \"idle\"\n ? matchRoutes(routesToUse, state.navigation.location, basename)\n : state.matches;\n\n invariant(matches, \"Didn't find any matches after fetcher action\");\n\n let loadId = ++incrementingLoadId;\n fetchReloadIds.set(key, loadId);\n\n let loadFetcher = getLoadingFetcher(submission, actionResult.data);\n state.fetchers.set(key, loadFetcher);\n\n let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(\n init.history,\n state,\n matches,\n submission,\n nextLocation,\n isRevalidationRequired,\n cancelledDeferredRoutes,\n cancelledFetcherLoads,\n fetchLoadMatches,\n fetchRedirectIds,\n routesToUse,\n basename,\n { [match.route.id]: actionResult.data },\n undefined // No need to send through errors since we short circuit above\n );\n\n // Put all revalidating fetchers into the loading state, except for the\n // current fetcher which we want to keep in it's current loading state which\n // contains it's action submission info + action data\n revalidatingFetchers\n .filter((rf) => rf.key !== key)\n .forEach((rf) => {\n let staleKey = rf.key;\n let existingFetcher = state.fetchers.get(staleKey);\n let revalidatingFetcher = getLoadingFetcher(\n undefined,\n existingFetcher ? existingFetcher.data : undefined\n );\n state.fetchers.set(staleKey, revalidatingFetcher);\n if (fetchControllers.has(staleKey)) {\n abortFetcher(staleKey);\n }\n if (rf.controller) {\n fetchControllers.set(staleKey, rf.controller);\n }\n });\n\n updateState({ fetchers: new Map(state.fetchers) });\n\n let abortPendingFetchRevalidations = () =>\n revalidatingFetchers.forEach((rf) => abortFetcher(rf.key));\n\n abortController.signal.addEventListener(\n \"abort\",\n abortPendingFetchRevalidations\n );\n\n let { results, loaderResults, fetcherResults } =\n await callLoadersAndMaybeResolveData(\n state.matches,\n matches,\n matchesToLoad,\n revalidatingFetchers,\n revalidationRequest\n );\n\n if (abortController.signal.aborted) {\n return;\n }\n\n abortController.signal.removeEventListener(\n \"abort\",\n abortPendingFetchRevalidations\n );\n\n fetchReloadIds.delete(key);\n fetchControllers.delete(key);\n revalidatingFetchers.forEach((r) => fetchControllers.delete(r.key));\n\n let redirect = findRedirect(results);\n if (redirect) {\n if (redirect.idx >= matchesToLoad.length) {\n // If this redirect came from a fetcher make sure we mark it in\n // fetchRedirectIds so it doesn't get revalidated on the next set of\n // loader executions\n let fetcherKey =\n revalidatingFetchers[redirect.idx - matchesToLoad.length].key;\n fetchRedirectIds.add(fetcherKey);\n }\n return startRedirectNavigation(state, redirect.result);\n }\n\n // Process and commit output from loaders\n let { loaderData, errors } = processLoaderData(\n state,\n state.matches,\n matchesToLoad,\n loaderResults,\n undefined,\n revalidatingFetchers,\n fetcherResults,\n activeDeferreds\n );\n\n // Since we let revalidations complete even if the submitting fetcher was\n // deleted, only put it back to idle if it hasn't been deleted\n if (state.fetchers.has(key)) {\n let doneFetcher = getDoneFetcher(actionResult.data);\n state.fetchers.set(key, doneFetcher);\n }\n\n let didAbortFetchLoads = abortStaleFetchLoads(loadId);\n\n // If we are currently in a navigation loading state and this fetcher is\n // more recent than the navigation, we want the newer data so abort the\n // navigation and complete it with the fetcher data\n if (\n state.navigation.state === \"loading\" &&\n loadId > pendingNavigationLoadId\n ) {\n invariant(pendingAction, \"Expected pending action\");\n pendingNavigationController && pendingNavigationController.abort();\n\n completeNavigation(state.navigation.location, {\n matches,\n loaderData,\n errors,\n fetchers: new Map(state.fetchers),\n });\n } else {\n // otherwise just update with the fetcher data, preserving any existing\n // loaderData for loaders that did not need to reload. We have to\n // manually merge here since we aren't going through completeNavigation\n updateState({\n errors,\n loaderData: mergeLoaderData(\n state.loaderData,\n loaderData,\n matches,\n errors\n ),\n ...(didAbortFetchLoads || revalidatingFetchers.length > 0\n ? { fetchers: new Map(state.fetchers) }\n : {}),\n });\n isRevalidationRequired = false;\n }\n }\n\n // Call the matched loader for fetcher.load(), handling redirects, errors, etc.\n async function handleFetcherLoader(\n key: string,\n routeId: string,\n path: string,\n match: AgnosticDataRouteMatch,\n matches: AgnosticDataRouteMatch[],\n submission?: Submission\n ) {\n let existingFetcher = state.fetchers.get(key);\n // Put this fetcher into it's loading state\n let loadingFetcher = getLoadingFetcher(\n submission,\n existingFetcher ? existingFetcher.data : undefined\n );\n state.fetchers.set(key, loadingFetcher);\n updateState({ fetchers: new Map(state.fetchers) });\n\n // Call the loader for this fetcher route match\n let abortController = new AbortController();\n let fetchRequest = createClientSideRequest(\n init.history,\n path,\n abortController.signal\n );\n fetchControllers.set(key, abortController);\n\n let originatingLoadId = incrementingLoadId;\n let result: DataResult = await callLoaderOrAction(\n \"loader\",\n fetchRequest,\n match,\n matches,\n manifest,\n mapRouteProperties,\n basename\n );\n\n // Deferred isn't supported for fetcher loads, await everything and treat it\n // as a normal load. resolveDeferredData will return undefined if this\n // fetcher gets aborted, so we just leave result untouched and short circuit\n // below if that happens\n if (isDeferredResult(result)) {\n result =\n (await resolveDeferredData(result, fetchRequest.signal, true)) ||\n result;\n }\n\n // We can delete this so long as we weren't aborted by our our own fetcher\n // re-load which would have put _new_ controller is in fetchControllers\n if (fetchControllers.get(key) === abortController) {\n fetchControllers.delete(key);\n }\n\n if (fetchRequest.signal.aborted) {\n return;\n }\n\n // If the loader threw a redirect Response, start a new REPLACE navigation\n if (isRedirectResult(result)) {\n if (pendingNavigationLoadId > originatingLoadId) {\n // A new navigation was kicked off after our loader started, so that\n // should take precedence over this redirect navigation\n let doneFetcher = getDoneFetcher(undefined);\n state.fetchers.set(key, doneFetcher);\n updateState({ fetchers: new Map(state.fetchers) });\n return;\n } else {\n fetchRedirectIds.add(key);\n await startRedirectNavigation(state, result);\n return;\n }\n }\n\n // Process any non-redirect errors thrown\n if (isErrorResult(result)) {\n let boundaryMatch = findNearestBoundary(state.matches, routeId);\n state.fetchers.delete(key);\n // TODO: In remix, this would reset to IDLE_NAVIGATION if it was a catch -\n // do we need to behave any differently with our non-redirect errors?\n // What if it was a non-redirect Response?\n updateState({\n fetchers: new Map(state.fetchers),\n errors: {\n [boundaryMatch.route.id]: result.error,\n },\n });\n return;\n }\n\n invariant(!isDeferredResult(result), \"Unhandled fetcher deferred data\");\n\n // Put the fetcher back into an idle state\n let doneFetcher = getDoneFetcher(result.data);\n state.fetchers.set(key, doneFetcher);\n updateState({ fetchers: new Map(state.fetchers) });\n }\n\n /**\n * Utility function to handle redirects returned from an action or loader.\n * Normally, a redirect \"replaces\" the navigation that triggered it. So, for\n * example:\n *\n * - user is on /a\n * - user clicks a link to /b\n * - loader for /b redirects to /c\n *\n * In a non-JS app the browser would track the in-flight navigation to /b and\n * then replace it with /c when it encountered the redirect response. In\n * the end it would only ever update the URL bar with /c.\n *\n * In client-side routing using pushState/replaceState, we aim to emulate\n * this behavior and we also do not update history until the end of the\n * navigation (including processed redirects). This means that we never\n * actually touch history until we've processed redirects, so we just use\n * the history action from the original navigation (PUSH or REPLACE).\n */\n async function startRedirectNavigation(\n state: RouterState,\n redirect: RedirectResult,\n {\n submission,\n replace,\n isFetchActionRedirect,\n }: {\n submission?: Submission;\n replace?: boolean;\n isFetchActionRedirect?: boolean;\n } = {}\n ) {\n if (redirect.revalidate) {\n isRevalidationRequired = true;\n }\n\n let redirectLocation = createLocation(\n state.location,\n redirect.location,\n // TODO: This can be removed once we get rid of useTransition in Remix v2\n {\n _isRedirect: true,\n ...(isFetchActionRedirect ? { _isFetchActionRedirect: true } : {}),\n }\n );\n invariant(\n redirectLocation,\n \"Expected a location on the redirect navigation\"\n );\n\n if (isBrowser) {\n let isDocumentReload = false;\n\n if (redirect.reloadDocument) {\n // Hard reload if the response contained X-Remix-Reload-Document\n isDocumentReload = true;\n } else if (ABSOLUTE_URL_REGEX.test(redirect.location)) {\n const url = init.history.createURL(redirect.location);\n isDocumentReload =\n // Hard reload if it's an absolute URL to a new origin\n url.origin !== routerWindow.location.origin ||\n // Hard reload if it's an absolute URL that does not match our basename\n stripBasename(url.pathname, basename) == null;\n }\n\n if (isDocumentReload) {\n if (replace) {\n routerWindow.location.replace(redirect.location);\n } else {\n routerWindow.location.assign(redirect.location);\n }\n return;\n }\n }\n\n // There's no need to abort on redirects, since we don't detect the\n // redirect until the action/loaders have settled\n pendingNavigationController = null;\n\n let redirectHistoryAction =\n replace === true ? HistoryAction.Replace : HistoryAction.Push;\n\n // Use the incoming submission if provided, fallback on the active one in\n // state.navigation\n let activeSubmission =\n submission || getSubmissionFromNavigation(state.navigation);\n\n // If this was a 307/308 submission we want to preserve the HTTP method and\n // re-submit the GET/POST/PUT/PATCH/DELETE as a submission navigation to the\n // redirected location\n if (\n redirectPreserveMethodStatusCodes.has(redirect.status) &&\n activeSubmission &&\n isMutationMethod(activeSubmission.formMethod)\n ) {\n await startNavigation(redirectHistoryAction, redirectLocation, {\n submission: {\n ...activeSubmission,\n formAction: redirect.location,\n },\n // Preserve this flag across redirects\n preventScrollReset: pendingPreventScrollReset,\n });\n } else if (isFetchActionRedirect) {\n // For a fetch action redirect, we kick off a new loading navigation\n // without the fetcher submission, but we send it along for shouldRevalidate\n await startNavigation(redirectHistoryAction, redirectLocation, {\n overrideNavigation: getLoadingNavigation(redirectLocation),\n fetcherSubmission: activeSubmission,\n // Preserve this flag across redirects\n preventScrollReset: pendingPreventScrollReset,\n });\n } else {\n // If we have a submission, we will preserve it through the redirect navigation\n let overrideNavigation = getLoadingNavigation(\n redirectLocation,\n activeSubmission\n );\n await startNavigation(redirectHistoryAction, redirectLocation, {\n overrideNavigation,\n // Preserve this flag across redirects\n preventScrollReset: pendingPreventScrollReset,\n });\n }\n }\n\n async function callLoadersAndMaybeResolveData(\n currentMatches: AgnosticDataRouteMatch[],\n matches: AgnosticDataRouteMatch[],\n matchesToLoad: AgnosticDataRouteMatch[],\n fetchersToLoad: RevalidatingFetcher[],\n request: Request\n ) {\n // Call all navigation loaders and revalidating fetcher loaders in parallel,\n // then slice off the results into separate arrays so we can handle them\n // accordingly\n let results = await Promise.all([\n ...matchesToLoad.map((match) =>\n callLoaderOrAction(\n \"loader\",\n request,\n match,\n matches,\n manifest,\n mapRouteProperties,\n basename\n )\n ),\n ...fetchersToLoad.map((f) => {\n if (f.matches && f.match && f.controller) {\n return callLoaderOrAction(\n \"loader\",\n createClientSideRequest(init.history, f.path, f.controller.signal),\n f.match,\n f.matches,\n manifest,\n mapRouteProperties,\n basename\n );\n } else {\n let error: ErrorResult = {\n type: ResultType.error,\n error: getInternalRouterError(404, { pathname: f.path }),\n };\n return error;\n }\n }),\n ]);\n let loaderResults = results.slice(0, matchesToLoad.length);\n let fetcherResults = results.slice(matchesToLoad.length);\n\n await Promise.all([\n resolveDeferredResults(\n currentMatches,\n matchesToLoad,\n loaderResults,\n loaderResults.map(() => request.signal),\n false,\n state.loaderData\n ),\n resolveDeferredResults(\n currentMatches,\n fetchersToLoad.map((f) => f.match),\n fetcherResults,\n fetchersToLoad.map((f) => (f.controller ? f.controller.signal : null)),\n true\n ),\n ]);\n\n return { results, loaderResults, fetcherResults };\n }\n\n function interruptActiveLoads() {\n // Every interruption triggers a revalidation\n isRevalidationRequired = true;\n\n // Cancel pending route-level deferreds and mark cancelled routes for\n // revalidation\n cancelledDeferredRoutes.push(...cancelActiveDeferreds());\n\n // Abort in-flight fetcher loads\n fetchLoadMatches.forEach((_, key) => {\n if (fetchControllers.has(key)) {\n cancelledFetcherLoads.push(key);\n abortFetcher(key);\n }\n });\n }\n\n function setFetcherError(key: string, routeId: string, error: any) {\n let boundaryMatch = findNearestBoundary(state.matches, routeId);\n deleteFetcher(key);\n updateState({\n errors: {\n [boundaryMatch.route.id]: error,\n },\n fetchers: new Map(state.fetchers),\n });\n }\n\n function deleteFetcher(key: string): void {\n let fetcher = state.fetchers.get(key);\n // Don't abort the controller if this is a deletion of a fetcher.submit()\n // in it's loading phase since - we don't want to abort the corresponding\n // revalidation and want them to complete and land\n if (\n fetchControllers.has(key) &&\n !(fetcher && fetcher.state === \"loading\" && fetchReloadIds.has(key))\n ) {\n abortFetcher(key);\n }\n fetchLoadMatches.delete(key);\n fetchReloadIds.delete(key);\n fetchRedirectIds.delete(key);\n state.fetchers.delete(key);\n }\n\n function abortFetcher(key: string) {\n let controller = fetchControllers.get(key);\n invariant(controller, `Expected fetch controller: ${key}`);\n controller.abort();\n fetchControllers.delete(key);\n }\n\n function markFetchersDone(keys: string[]) {\n for (let key of keys) {\n let fetcher = getFetcher(key);\n let doneFetcher = getDoneFetcher(fetcher.data);\n state.fetchers.set(key, doneFetcher);\n }\n }\n\n function markFetchRedirectsDone(): boolean {\n let doneKeys = [];\n let updatedFetchers = false;\n for (let key of fetchRedirectIds) {\n let fetcher = state.fetchers.get(key);\n invariant(fetcher, `Expected fetcher: ${key}`);\n if (fetcher.state === \"loading\") {\n fetchRedirectIds.delete(key);\n doneKeys.push(key);\n updatedFetchers = true;\n }\n }\n markFetchersDone(doneKeys);\n return updatedFetchers;\n }\n\n function abortStaleFetchLoads(landedId: number): boolean {\n let yeetedKeys = [];\n for (let [key, id] of fetchReloadIds) {\n if (id < landedId) {\n let fetcher = state.fetchers.get(key);\n invariant(fetcher, `Expected fetcher: ${key}`);\n if (fetcher.state === \"loading\") {\n abortFetcher(key);\n fetchReloadIds.delete(key);\n yeetedKeys.push(key);\n }\n }\n }\n markFetchersDone(yeetedKeys);\n return yeetedKeys.length > 0;\n }\n\n function getBlocker(key: string, fn: BlockerFunction) {\n let blocker: Blocker = state.blockers.get(key) || IDLE_BLOCKER;\n\n if (blockerFunctions.get(key) !== fn) {\n blockerFunctions.set(key, fn);\n }\n\n return blocker;\n }\n\n function deleteBlocker(key: string) {\n state.blockers.delete(key);\n blockerFunctions.delete(key);\n }\n\n // Utility function to update blockers, ensuring valid state transitions\n function updateBlocker(key: string, newBlocker: Blocker) {\n let blocker = state.blockers.get(key) || IDLE_BLOCKER;\n\n // Poor mans state machine :)\n // https://mermaid.live/edit#pako:eNqVkc9OwzAMxl8l8nnjAYrEtDIOHEBIgwvKJTReGy3_lDpIqO27k6awMG0XcrLlnz87nwdonESogKXXBuE79rq75XZO3-yHds0RJVuv70YrPlUrCEe2HfrORS3rubqZfuhtpg5C9wk5tZ4VKcRUq88q9Z8RS0-48cE1iHJkL0ugbHuFLus9L6spZy8nX9MP2CNdomVaposqu3fGayT8T8-jJQwhepo_UtpgBQaDEUom04dZhAN1aJBDlUKJBxE1ceB2Smj0Mln-IBW5AFU2dwUiktt_2Qaq2dBfaKdEup85UV7Yd-dKjlnkabl2Pvr0DTkTreM\n invariant(\n (blocker.state === \"unblocked\" && newBlocker.state === \"blocked\") ||\n (blocker.state === \"blocked\" && newBlocker.state === \"blocked\") ||\n (blocker.state === \"blocked\" && newBlocker.state === \"proceeding\") ||\n (blocker.state === \"blocked\" && newBlocker.state === \"unblocked\") ||\n (blocker.state === \"proceeding\" && newBlocker.state === \"unblocked\"),\n `Invalid blocker state transition: ${blocker.state} -> ${newBlocker.state}`\n );\n\n let blockers = new Map(state.blockers);\n blockers.set(key, newBlocker);\n updateState({ blockers });\n }\n\n function shouldBlockNavigation({\n currentLocation,\n nextLocation,\n historyAction,\n }: {\n currentLocation: Location;\n nextLocation: Location;\n historyAction: HistoryAction;\n }): string | undefined {\n if (blockerFunctions.size === 0) {\n return;\n }\n\n // We ony support a single active blocker at the moment since we don't have\n // any compelling use cases for multi-blocker yet\n if (blockerFunctions.size > 1) {\n warning(false, \"A router only supports one blocker at a time\");\n }\n\n let entries = Array.from(blockerFunctions.entries());\n let [blockerKey, blockerFunction] = entries[entries.length - 1];\n let blocker = state.blockers.get(blockerKey);\n\n if (blocker && blocker.state === \"proceeding\") {\n // If the blocker is currently proceeding, we don't need to re-check\n // it and can let this navigation continue\n return;\n }\n\n // At this point, we know we're unblocked/blocked so we need to check the\n // user-provided blocker function\n if (blockerFunction({ currentLocation, nextLocation, historyAction })) {\n return blockerKey;\n }\n }\n\n function cancelActiveDeferreds(\n predicate?: (routeId: string) => boolean\n ): string[] {\n let cancelledRouteIds: string[] = [];\n activeDeferreds.forEach((dfd, routeId) => {\n if (!predicate || predicate(routeId)) {\n // Cancel the deferred - but do not remove from activeDeferreds here -\n // we rely on the subscribers to do that so our tests can assert proper\n // cleanup via _internalActiveDeferreds\n dfd.cancel();\n cancelledRouteIds.push(routeId);\n activeDeferreds.delete(routeId);\n }\n });\n return cancelledRouteIds;\n }\n\n // Opt in to capturing and reporting scroll positions during navigations,\n // used by the component\n function enableScrollRestoration(\n positions: Record,\n getPosition: GetScrollPositionFunction,\n getKey?: GetScrollRestorationKeyFunction\n ) {\n savedScrollPositions = positions;\n getScrollPosition = getPosition;\n getScrollRestorationKey = getKey || null;\n\n // Perform initial hydration scroll restoration, since we miss the boat on\n // the initial updateState() because we've not yet rendered \n // and therefore have no savedScrollPositions available\n if (!initialScrollRestored && state.navigation === IDLE_NAVIGATION) {\n initialScrollRestored = true;\n let y = getSavedScrollPosition(state.location, state.matches);\n if (y != null) {\n updateState({ restoreScrollPosition: y });\n }\n }\n\n return () => {\n savedScrollPositions = null;\n getScrollPosition = null;\n getScrollRestorationKey = null;\n };\n }\n\n function getScrollKey(location: Location, matches: AgnosticDataRouteMatch[]) {\n if (getScrollRestorationKey) {\n let key = getScrollRestorationKey(\n location,\n matches.map((m) => createUseMatchesMatch(m, state.loaderData))\n );\n return key || location.key;\n }\n return location.key;\n }\n\n function saveScrollPosition(\n location: Location,\n matches: AgnosticDataRouteMatch[]\n ): void {\n if (savedScrollPositions && getScrollPosition) {\n let key = getScrollKey(location, matches);\n savedScrollPositions[key] = getScrollPosition();\n }\n }\n\n function getSavedScrollPosition(\n location: Location,\n matches: AgnosticDataRouteMatch[]\n ): number | null {\n if (savedScrollPositions) {\n let key = getScrollKey(location, matches);\n let y = savedScrollPositions[key];\n if (typeof y === \"number\") {\n return y;\n }\n }\n return null;\n }\n\n function _internalSetRoutes(newRoutes: AgnosticDataRouteObject[]) {\n manifest = {};\n inFlightDataRoutes = convertRoutesToDataRoutes(\n newRoutes,\n mapRouteProperties,\n undefined,\n manifest\n );\n }\n\n router = {\n get basename() {\n return basename;\n },\n get state() {\n return state;\n },\n get routes() {\n return dataRoutes;\n },\n initialize,\n subscribe,\n enableScrollRestoration,\n navigate,\n fetch,\n revalidate,\n // Passthrough to history-aware createHref used by useHref so we get proper\n // hash-aware URLs in DOM paths\n createHref: (to: To) => init.history.createHref(to),\n encodeLocation: (to: To) => init.history.encodeLocation(to),\n getFetcher,\n deleteFetcher,\n dispose,\n getBlocker,\n deleteBlocker,\n _internalFetchControllers: fetchControllers,\n _internalActiveDeferreds: activeDeferreds,\n // TODO: Remove setRoutes, it's temporary to avoid dealing with\n // updating the tree while validating the update algorithm.\n _internalSetRoutes,\n };\n\n return router;\n}\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region createStaticHandler\n////////////////////////////////////////////////////////////////////////////////\n\nexport const UNSAFE_DEFERRED_SYMBOL = Symbol(\"deferred\");\n\nexport interface CreateStaticHandlerOptions {\n basename?: string;\n /**\n * @deprecated Use `mapRouteProperties` instead\n */\n detectErrorBoundary?: DetectErrorBoundaryFunction;\n mapRouteProperties?: MapRoutePropertiesFunction;\n}\n\nexport function createStaticHandler(\n routes: AgnosticRouteObject[],\n opts?: CreateStaticHandlerOptions\n): StaticHandler {\n invariant(\n routes.length > 0,\n \"You must provide a non-empty routes array to createStaticHandler\"\n );\n\n let manifest: RouteManifest = {};\n let basename = (opts ? opts.basename : null) || \"/\";\n let mapRouteProperties: MapRoutePropertiesFunction;\n if (opts?.mapRouteProperties) {\n mapRouteProperties = opts.mapRouteProperties;\n } else if (opts?.detectErrorBoundary) {\n // If they are still using the deprecated version, wrap it with the new API\n let detectErrorBoundary = opts.detectErrorBoundary;\n mapRouteProperties = (route) => ({\n hasErrorBoundary: detectErrorBoundary(route),\n });\n } else {\n mapRouteProperties = defaultMapRouteProperties;\n }\n\n let dataRoutes = convertRoutesToDataRoutes(\n routes,\n mapRouteProperties,\n undefined,\n manifest\n );\n\n /**\n * The query() method is intended for document requests, in which we want to\n * call an optional action and potentially multiple loaders for all nested\n * routes. It returns a StaticHandlerContext object, which is very similar\n * to the router state (location, loaderData, actionData, errors, etc.) and\n * also adds SSR-specific information such as the statusCode and headers\n * from action/loaders Responses.\n *\n * It _should_ never throw and should report all errors through the\n * returned context.errors object, properly associating errors to their error\n * boundary. Additionally, it tracks _deepestRenderedBoundaryId which can be\n * used to emulate React error boundaries during SSr by performing a second\n * pass only down to the boundaryId.\n *\n * The one exception where we do not return a StaticHandlerContext is when a\n * redirect response is returned or thrown from any action/loader. We\n * propagate that out and return the raw Response so the HTTP server can\n * return it directly.\n */\n async function query(\n request: Request,\n { requestContext }: { requestContext?: unknown } = {}\n ): Promise {\n let url = new URL(request.url);\n let method = request.method;\n let location = createLocation(\"\", createPath(url), null, \"default\");\n let matches = matchRoutes(dataRoutes, location, basename);\n\n // SSR supports HEAD requests while SPA doesn't\n if (!isValidMethod(method) && method !== \"HEAD\") {\n let error = getInternalRouterError(405, { method });\n let { matches: methodNotAllowedMatches, route } =\n getShortCircuitMatches(dataRoutes);\n return {\n basename,\n location,\n matches: methodNotAllowedMatches,\n loaderData: {},\n actionData: null,\n errors: {\n [route.id]: error,\n },\n statusCode: error.status,\n loaderHeaders: {},\n actionHeaders: {},\n activeDeferreds: null,\n };\n } else if (!matches) {\n let error = getInternalRouterError(404, { pathname: location.pathname });\n let { matches: notFoundMatches, route } =\n getShortCircuitMatches(dataRoutes);\n return {\n basename,\n location,\n matches: notFoundMatches,\n loaderData: {},\n actionData: null,\n errors: {\n [route.id]: error,\n },\n statusCode: error.status,\n loaderHeaders: {},\n actionHeaders: {},\n activeDeferreds: null,\n };\n }\n\n let result = await queryImpl(request, location, matches, requestContext);\n if (isResponse(result)) {\n return result;\n }\n\n // When returning StaticHandlerContext, we patch back in the location here\n // since we need it for React Context. But this helps keep our submit and\n // loadRouteData operating on a Request instead of a Location\n return { location, basename, ...result };\n }\n\n /**\n * The queryRoute() method is intended for targeted route requests, either\n * for fetch ?_data requests or resource route requests. In this case, we\n * are only ever calling a single action or loader, and we are returning the\n * returned value directly. In most cases, this will be a Response returned\n * from the action/loader, but it may be a primitive or other value as well -\n * and in such cases the calling context should handle that accordingly.\n *\n * We do respect the throw/return differentiation, so if an action/loader\n * throws, then this method will throw the value. This is important so we\n * can do proper boundary identification in Remix where a thrown Response\n * must go to the Catch Boundary but a returned Response is happy-path.\n *\n * One thing to note is that any Router-initiated Errors that make sense\n * to associate with a status code will be thrown as an ErrorResponse\n * instance which include the raw Error, such that the calling context can\n * serialize the error as they see fit while including the proper response\n * code. Examples here are 404 and 405 errors that occur prior to reaching\n * any user-defined loaders.\n */\n async function queryRoute(\n request: Request,\n {\n routeId,\n requestContext,\n }: { requestContext?: unknown; routeId?: string } = {}\n ): Promise {\n let url = new URL(request.url);\n let method = request.method;\n let location = createLocation(\"\", createPath(url), null, \"default\");\n let matches = matchRoutes(dataRoutes, location, basename);\n\n // SSR supports HEAD requests while SPA doesn't\n if (!isValidMethod(method) && method !== \"HEAD\" && method !== \"OPTIONS\") {\n throw getInternalRouterError(405, { method });\n } else if (!matches) {\n throw getInternalRouterError(404, { pathname: location.pathname });\n }\n\n let match = routeId\n ? matches.find((m) => m.route.id === routeId)\n : getTargetMatch(matches, location);\n\n if (routeId && !match) {\n throw getInternalRouterError(403, {\n pathname: location.pathname,\n routeId,\n });\n } else if (!match) {\n // This should never hit I don't think?\n throw getInternalRouterError(404, { pathname: location.pathname });\n }\n\n let result = await queryImpl(\n request,\n location,\n matches,\n requestContext,\n match\n );\n if (isResponse(result)) {\n return result;\n }\n\n let error = result.errors ? Object.values(result.errors)[0] : undefined;\n if (error !== undefined) {\n // If we got back result.errors, that means the loader/action threw\n // _something_ that wasn't a Response, but it's not guaranteed/required\n // to be an `instanceof Error` either, so we have to use throw here to\n // preserve the \"error\" state outside of queryImpl.\n throw error;\n }\n\n // Pick off the right state value to return\n if (result.actionData) {\n return Object.values(result.actionData)[0];\n }\n\n if (result.loaderData) {\n let data = Object.values(result.loaderData)[0];\n if (result.activeDeferreds?.[match.route.id]) {\n data[UNSAFE_DEFERRED_SYMBOL] = result.activeDeferreds[match.route.id];\n }\n return data;\n }\n\n return undefined;\n }\n\n async function queryImpl(\n request: Request,\n location: Location,\n matches: AgnosticDataRouteMatch[],\n requestContext: unknown,\n routeMatch?: AgnosticDataRouteMatch\n ): Promise | Response> {\n invariant(\n request.signal,\n \"query()/queryRoute() requests must contain an AbortController signal\"\n );\n\n try {\n if (isMutationMethod(request.method.toLowerCase())) {\n let result = await submit(\n request,\n matches,\n routeMatch || getTargetMatch(matches, location),\n requestContext,\n routeMatch != null\n );\n return result;\n }\n\n let result = await loadRouteData(\n request,\n matches,\n requestContext,\n routeMatch\n );\n return isResponse(result)\n ? result\n : {\n ...result,\n actionData: null,\n actionHeaders: {},\n };\n } catch (e) {\n // If the user threw/returned a Response in callLoaderOrAction, we throw\n // it to bail out and then return or throw here based on whether the user\n // returned or threw\n if (isQueryRouteResponse(e)) {\n if (e.type === ResultType.error) {\n throw e.response;\n }\n return e.response;\n }\n // Redirects are always returned since they don't propagate to catch\n // boundaries\n if (isRedirectResponse(e)) {\n return e;\n }\n throw e;\n }\n }\n\n async function submit(\n request: Request,\n matches: AgnosticDataRouteMatch[],\n actionMatch: AgnosticDataRouteMatch,\n requestContext: unknown,\n isRouteRequest: boolean\n ): Promise | Response> {\n let result: DataResult;\n\n if (!actionMatch.route.action && !actionMatch.route.lazy) {\n let error = getInternalRouterError(405, {\n method: request.method,\n pathname: new URL(request.url).pathname,\n routeId: actionMatch.route.id,\n });\n if (isRouteRequest) {\n throw error;\n }\n result = {\n type: ResultType.error,\n error,\n };\n } else {\n result = await callLoaderOrAction(\n \"action\",\n request,\n actionMatch,\n matches,\n manifest,\n mapRouteProperties,\n basename,\n { isStaticRequest: true, isRouteRequest, requestContext }\n );\n\n if (request.signal.aborted) {\n let method = isRouteRequest ? \"queryRoute\" : \"query\";\n throw new Error(`${method}() call aborted`);\n }\n }\n\n if (isRedirectResult(result)) {\n // Uhhhh - this should never happen, we should always throw these from\n // callLoaderOrAction, but the type narrowing here keeps TS happy and we\n // can get back on the \"throw all redirect responses\" train here should\n // this ever happen :/\n throw new Response(null, {\n status: result.status,\n headers: {\n Location: result.location,\n },\n });\n }\n\n if (isDeferredResult(result)) {\n let error = getInternalRouterError(400, { type: \"defer-action\" });\n if (isRouteRequest) {\n throw error;\n }\n result = {\n type: ResultType.error,\n error,\n };\n }\n\n if (isRouteRequest) {\n // Note: This should only be non-Response values if we get here, since\n // isRouteRequest should throw any Response received in callLoaderOrAction\n if (isErrorResult(result)) {\n throw result.error;\n }\n\n return {\n matches: [actionMatch],\n loaderData: {},\n actionData: { [actionMatch.route.id]: result.data },\n errors: null,\n // Note: statusCode + headers are unused here since queryRoute will\n // return the raw Response or value\n statusCode: 200,\n loaderHeaders: {},\n actionHeaders: {},\n activeDeferreds: null,\n };\n }\n\n if (isErrorResult(result)) {\n // Store off the pending error - we use it to determine which loaders\n // to call and will commit it when we complete the navigation\n let boundaryMatch = findNearestBoundary(matches, actionMatch.route.id);\n let context = await loadRouteData(\n request,\n matches,\n requestContext,\n undefined,\n {\n [boundaryMatch.route.id]: result.error,\n }\n );\n\n // action status codes take precedence over loader status codes\n return {\n ...context,\n statusCode: isRouteErrorResponse(result.error)\n ? result.error.status\n : 500,\n actionData: null,\n actionHeaders: {\n ...(result.headers ? { [actionMatch.route.id]: result.headers } : {}),\n },\n };\n }\n\n // Create a GET request for the loaders\n let loaderRequest = new Request(request.url, {\n headers: request.headers,\n redirect: request.redirect,\n signal: request.signal,\n });\n let context = await loadRouteData(loaderRequest, matches, requestContext);\n\n return {\n ...context,\n // action status codes take precedence over loader status codes\n ...(result.statusCode ? { statusCode: result.statusCode } : {}),\n actionData: {\n [actionMatch.route.id]: result.data,\n },\n actionHeaders: {\n ...(result.headers ? { [actionMatch.route.id]: result.headers } : {}),\n },\n };\n }\n\n async function loadRouteData(\n request: Request,\n matches: AgnosticDataRouteMatch[],\n requestContext: unknown,\n routeMatch?: AgnosticDataRouteMatch,\n pendingActionError?: RouteData\n ): Promise<\n | Omit<\n StaticHandlerContext,\n \"location\" | \"basename\" | \"actionData\" | \"actionHeaders\"\n >\n | Response\n > {\n let isRouteRequest = routeMatch != null;\n\n // Short circuit if we have no loaders to run (queryRoute())\n if (\n isRouteRequest &&\n !routeMatch?.route.loader &&\n !routeMatch?.route.lazy\n ) {\n throw getInternalRouterError(400, {\n method: request.method,\n pathname: new URL(request.url).pathname,\n routeId: routeMatch?.route.id,\n });\n }\n\n let requestMatches = routeMatch\n ? [routeMatch]\n : getLoaderMatchesUntilBoundary(\n matches,\n Object.keys(pendingActionError || {})[0]\n );\n let matchesToLoad = requestMatches.filter(\n (m) => m.route.loader || m.route.lazy\n );\n\n // Short circuit if we have no loaders to run (query())\n if (matchesToLoad.length === 0) {\n return {\n matches,\n // Add a null for all matched routes for proper revalidation on the client\n loaderData: matches.reduce(\n (acc, m) => Object.assign(acc, { [m.route.id]: null }),\n {}\n ),\n errors: pendingActionError || null,\n statusCode: 200,\n loaderHeaders: {},\n activeDeferreds: null,\n };\n }\n\n let results = await Promise.all([\n ...matchesToLoad.map((match) =>\n callLoaderOrAction(\n \"loader\",\n request,\n match,\n matches,\n manifest,\n mapRouteProperties,\n basename,\n { isStaticRequest: true, isRouteRequest, requestContext }\n )\n ),\n ]);\n\n if (request.signal.aborted) {\n let method = isRouteRequest ? \"queryRoute\" : \"query\";\n throw new Error(`${method}() call aborted`);\n }\n\n // Process and commit output from loaders\n let activeDeferreds = new Map();\n let context = processRouteLoaderData(\n matches,\n matchesToLoad,\n results,\n pendingActionError,\n activeDeferreds\n );\n\n // Add a null for any non-loader matches for proper revalidation on the client\n let executedLoaders = new Set(\n matchesToLoad.map((match) => match.route.id)\n );\n matches.forEach((match) => {\n if (!executedLoaders.has(match.route.id)) {\n context.loaderData[match.route.id] = null;\n }\n });\n\n return {\n ...context,\n matches,\n activeDeferreds:\n activeDeferreds.size > 0\n ? Object.fromEntries(activeDeferreds.entries())\n : null,\n };\n }\n\n return {\n dataRoutes,\n query,\n queryRoute,\n };\n}\n\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region Helpers\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * Given an existing StaticHandlerContext and an error thrown at render time,\n * provide an updated StaticHandlerContext suitable for a second SSR render\n */\nexport function getStaticContextFromError(\n routes: AgnosticDataRouteObject[],\n context: StaticHandlerContext,\n error: any\n) {\n let newContext: StaticHandlerContext = {\n ...context,\n statusCode: 500,\n errors: {\n [context._deepestRenderedBoundaryId || routes[0].id]: error,\n },\n };\n return newContext;\n}\n\nfunction isSubmissionNavigation(\n opts: RouterNavigateOptions\n): opts is SubmissionNavigateOptions {\n return (\n opts != null &&\n ((\"formData\" in opts && opts.formData != null) ||\n (\"body\" in opts && opts.body !== undefined))\n );\n}\n\nfunction normalizeTo(\n location: Path,\n matches: AgnosticDataRouteMatch[],\n basename: string,\n prependBasename: boolean,\n to: To | null,\n fromRouteId?: string,\n relative?: RelativeRoutingType\n) {\n let contextualMatches: AgnosticDataRouteMatch[];\n let activeRouteMatch: AgnosticDataRouteMatch | undefined;\n if (fromRouteId != null && relative !== \"path\") {\n // Grab matches up to the calling route so our route-relative logic is\n // relative to the correct source route. When using relative:path,\n // fromRouteId is ignored since that is always relative to the current\n // location path\n contextualMatches = [];\n for (let match of matches) {\n contextualMatches.push(match);\n if (match.route.id === fromRouteId) {\n activeRouteMatch = match;\n break;\n }\n }\n } else {\n contextualMatches = matches;\n activeRouteMatch = matches[matches.length - 1];\n }\n\n // Resolve the relative path\n let path = resolveTo(\n to ? to : \".\",\n getPathContributingMatches(contextualMatches).map((m) => m.pathnameBase),\n stripBasename(location.pathname, basename) || location.pathname,\n relative === \"path\"\n );\n\n // When `to` is not specified we inherit search/hash from the current\n // location, unlike when to=\".\" and we just inherit the path.\n // See https://github.com/remix-run/remix/issues/927\n if (to == null) {\n path.search = location.search;\n path.hash = location.hash;\n }\n\n // Add an ?index param for matched index routes if we don't already have one\n if (\n (to == null || to === \"\" || to === \".\") &&\n activeRouteMatch &&\n activeRouteMatch.route.index &&\n !hasNakedIndexQuery(path.search)\n ) {\n path.search = path.search\n ? path.search.replace(/^\\?/, \"?index&\")\n : \"?index\";\n }\n\n // If we're operating within a basename, prepend it to the pathname. If\n // this is a root navigation, then just use the raw basename which allows\n // the basename to have full control over the presence of a trailing slash\n // on root actions\n if (prependBasename && basename !== \"/\") {\n path.pathname =\n path.pathname === \"/\" ? basename : joinPaths([basename, path.pathname]);\n }\n\n return createPath(path);\n}\n\n// Normalize navigation options by converting formMethod=GET formData objects to\n// URLSearchParams so they behave identically to links with query params\nfunction normalizeNavigateOptions(\n normalizeFormMethod: boolean,\n isFetcher: boolean,\n path: string,\n opts?: RouterNavigateOptions\n): {\n path: string;\n submission?: Submission;\n error?: ErrorResponse;\n} {\n // Return location verbatim on non-submission navigations\n if (!opts || !isSubmissionNavigation(opts)) {\n return { path };\n }\n\n if (opts.formMethod && !isValidMethod(opts.formMethod)) {\n return {\n path,\n error: getInternalRouterError(405, { method: opts.formMethod }),\n };\n }\n\n let getInvalidBodyError = () => ({\n path,\n error: getInternalRouterError(400, { type: \"invalid-body\" }),\n });\n\n // Create a Submission on non-GET navigations\n let rawFormMethod = opts.formMethod || \"get\";\n let formMethod = normalizeFormMethod\n ? (rawFormMethod.toUpperCase() as V7_FormMethod)\n : (rawFormMethod.toLowerCase() as FormMethod);\n let formAction = stripHashFromPath(path);\n\n if (opts.body !== undefined) {\n if (opts.formEncType === \"text/plain\") {\n // text only support POST/PUT/PATCH/DELETE submissions\n if (!isMutationMethod(formMethod)) {\n return getInvalidBodyError();\n }\n\n let text =\n typeof opts.body === \"string\"\n ? opts.body\n : opts.body instanceof FormData ||\n opts.body instanceof URLSearchParams\n ? // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#plain-text-form-data\n Array.from(opts.body.entries()).reduce(\n (acc, [name, value]) => `${acc}${name}=${value}\\n`,\n \"\"\n )\n : String(opts.body);\n\n return {\n path,\n submission: {\n formMethod,\n formAction,\n formEncType: opts.formEncType,\n formData: undefined,\n json: undefined,\n text,\n },\n };\n } else if (opts.formEncType === \"application/json\") {\n // json only supports POST/PUT/PATCH/DELETE submissions\n if (!isMutationMethod(formMethod)) {\n return getInvalidBodyError();\n }\n\n try {\n let json =\n typeof opts.body === \"string\" ? JSON.parse(opts.body) : opts.body;\n\n return {\n path,\n submission: {\n formMethod,\n formAction,\n formEncType: opts.formEncType,\n formData: undefined,\n json,\n text: undefined,\n },\n };\n } catch (e) {\n return getInvalidBodyError();\n }\n }\n }\n\n invariant(\n typeof FormData === \"function\",\n \"FormData is not available in this environment\"\n );\n\n let searchParams: URLSearchParams;\n let formData: FormData;\n\n if (opts.formData) {\n searchParams = convertFormDataToSearchParams(opts.formData);\n formData = opts.formData;\n } else if (opts.body instanceof FormData) {\n searchParams = convertFormDataToSearchParams(opts.body);\n formData = opts.body;\n } else if (opts.body instanceof URLSearchParams) {\n searchParams = opts.body;\n formData = convertSearchParamsToFormData(searchParams);\n } else if (opts.body == null) {\n searchParams = new URLSearchParams();\n formData = new FormData();\n } else {\n try {\n searchParams = new URLSearchParams(opts.body);\n formData = convertSearchParamsToFormData(searchParams);\n } catch (e) {\n return getInvalidBodyError();\n }\n }\n\n let submission: Submission = {\n formMethod,\n formAction,\n formEncType:\n (opts && opts.formEncType) || \"application/x-www-form-urlencoded\",\n formData,\n json: undefined,\n text: undefined,\n };\n\n if (isMutationMethod(submission.formMethod)) {\n return { path, submission };\n }\n\n // Flatten submission onto URLSearchParams for GET submissions\n let parsedPath = parsePath(path);\n // On GET navigation submissions we can drop the ?index param from the\n // resulting location since all loaders will run. But fetcher GET submissions\n // only run a single loader so we need to preserve any incoming ?index params\n if (isFetcher && parsedPath.search && hasNakedIndexQuery(parsedPath.search)) {\n searchParams.append(\"index\", \"\");\n }\n parsedPath.search = `?${searchParams}`;\n\n return { path: createPath(parsedPath), submission };\n}\n\n// Filter out all routes below any caught error as they aren't going to\n// render so we don't need to load them\nfunction getLoaderMatchesUntilBoundary(\n matches: AgnosticDataRouteMatch[],\n boundaryId?: string\n) {\n let boundaryMatches = matches;\n if (boundaryId) {\n let index = matches.findIndex((m) => m.route.id === boundaryId);\n if (index >= 0) {\n boundaryMatches = matches.slice(0, index);\n }\n }\n return boundaryMatches;\n}\n\nfunction getMatchesToLoad(\n history: History,\n state: RouterState,\n matches: AgnosticDataRouteMatch[],\n submission: Submission | undefined,\n location: Location,\n isRevalidationRequired: boolean,\n cancelledDeferredRoutes: string[],\n cancelledFetcherLoads: string[],\n fetchLoadMatches: Map,\n fetchRedirectIds: Set,\n routesToUse: AgnosticDataRouteObject[],\n basename: string | undefined,\n pendingActionData?: RouteData,\n pendingError?: RouteData\n): [AgnosticDataRouteMatch[], RevalidatingFetcher[]] {\n let actionResult = pendingError\n ? Object.values(pendingError)[0]\n : pendingActionData\n ? Object.values(pendingActionData)[0]\n : undefined;\n\n let currentUrl = history.createURL(state.location);\n let nextUrl = history.createURL(location);\n\n // Pick navigation matches that are net-new or qualify for revalidation\n let boundaryId = pendingError ? Object.keys(pendingError)[0] : undefined;\n let boundaryMatches = getLoaderMatchesUntilBoundary(matches, boundaryId);\n\n let navigationMatches = boundaryMatches.filter((match, index) => {\n if (match.route.lazy) {\n // We haven't loaded this route yet so we don't know if it's got a loader!\n return true;\n }\n if (match.route.loader == null) {\n return false;\n }\n\n // Always call the loader on new route instances and pending defer cancellations\n if (\n isNewLoader(state.loaderData, state.matches[index], match) ||\n cancelledDeferredRoutes.some((id) => id === match.route.id)\n ) {\n return true;\n }\n\n // This is the default implementation for when we revalidate. If the route\n // provides it's own implementation, then we give them full control but\n // provide this value so they can leverage it if needed after they check\n // their own specific use cases\n let currentRouteMatch = state.matches[index];\n let nextRouteMatch = match;\n\n return shouldRevalidateLoader(match, {\n currentUrl,\n currentParams: currentRouteMatch.params,\n nextUrl,\n nextParams: nextRouteMatch.params,\n ...submission,\n actionResult,\n defaultShouldRevalidate:\n // Forced revalidation due to submission, useRevalidator, or X-Remix-Revalidate\n isRevalidationRequired ||\n // Clicked the same link, resubmitted a GET form\n currentUrl.pathname + currentUrl.search ===\n nextUrl.pathname + nextUrl.search ||\n // Search params affect all loaders\n currentUrl.search !== nextUrl.search ||\n isNewRouteInstance(currentRouteMatch, nextRouteMatch),\n });\n });\n\n // Pick fetcher.loads that need to be revalidated\n let revalidatingFetchers: RevalidatingFetcher[] = [];\n fetchLoadMatches.forEach((f, key) => {\n // Don't revalidate if fetcher won't be present in the subsequent render\n if (!matches.some((m) => m.route.id === f.routeId)) {\n return;\n }\n\n let fetcherMatches = matchRoutes(routesToUse, f.path, basename);\n\n // If the fetcher path no longer matches, push it in with null matches so\n // we can trigger a 404 in callLoadersAndMaybeResolveData. Note this is\n // currently only a use-case for Remix HMR where the route tree can change\n // at runtime and remove a route previously loaded via a fetcher\n if (!fetcherMatches) {\n revalidatingFetchers.push({\n key,\n routeId: f.routeId,\n path: f.path,\n matches: null,\n match: null,\n controller: null,\n });\n return;\n }\n\n // Revalidating fetchers are decoupled from the route matches since they\n // load from a static href. They revalidate based on explicit revalidation\n // (submission, useRevalidator, or X-Remix-Revalidate)\n let fetcher = state.fetchers.get(key);\n let fetcherMatch = getTargetMatch(fetcherMatches, f.path);\n\n let shouldRevalidate = false;\n if (fetchRedirectIds.has(key)) {\n // Never trigger a revalidation of an actively redirecting fetcher\n shouldRevalidate = false;\n } else if (cancelledFetcherLoads.includes(key)) {\n // Always revalidate if the fetcher was cancelled\n shouldRevalidate = true;\n } else if (\n fetcher &&\n fetcher.state !== \"idle\" &&\n fetcher.data === undefined\n ) {\n // If the fetcher hasn't ever completed loading yet, then this isn't a\n // revalidation, it would just be a brand new load if an explicit\n // revalidation is required\n shouldRevalidate = isRevalidationRequired;\n } else {\n // Otherwise fall back on any user-defined shouldRevalidate, defaulting\n // to explicit revalidations only\n shouldRevalidate = shouldRevalidateLoader(fetcherMatch, {\n currentUrl,\n currentParams: state.matches[state.matches.length - 1].params,\n nextUrl,\n nextParams: matches[matches.length - 1].params,\n ...submission,\n actionResult,\n defaultShouldRevalidate: isRevalidationRequired,\n });\n }\n\n if (shouldRevalidate) {\n revalidatingFetchers.push({\n key,\n routeId: f.routeId,\n path: f.path,\n matches: fetcherMatches,\n match: fetcherMatch,\n controller: new AbortController(),\n });\n }\n });\n\n return [navigationMatches, revalidatingFetchers];\n}\n\nfunction isNewLoader(\n currentLoaderData: RouteData,\n currentMatch: AgnosticDataRouteMatch,\n match: AgnosticDataRouteMatch\n) {\n let isNew =\n // [a] -> [a, b]\n !currentMatch ||\n // [a, b] -> [a, c]\n match.route.id !== currentMatch.route.id;\n\n // Handle the case that we don't have data for a re-used route, potentially\n // from a prior error or from a cancelled pending deferred\n let isMissingData = currentLoaderData[match.route.id] === undefined;\n\n // Always load if this is a net-new route or we don't yet have data\n return isNew || isMissingData;\n}\n\nfunction isNewRouteInstance(\n currentMatch: AgnosticDataRouteMatch,\n match: AgnosticDataRouteMatch\n) {\n let currentPath = currentMatch.route.path;\n return (\n // param change for this match, /users/123 -> /users/456\n currentMatch.pathname !== match.pathname ||\n // splat param changed, which is not present in match.path\n // e.g. /files/images/avatar.jpg -> files/finances.xls\n (currentPath != null &&\n currentPath.endsWith(\"*\") &&\n currentMatch.params[\"*\"] !== match.params[\"*\"])\n );\n}\n\nfunction shouldRevalidateLoader(\n loaderMatch: AgnosticDataRouteMatch,\n arg: Parameters[0]\n) {\n if (loaderMatch.route.shouldRevalidate) {\n let routeChoice = loaderMatch.route.shouldRevalidate(arg);\n if (typeof routeChoice === \"boolean\") {\n return routeChoice;\n }\n }\n\n return arg.defaultShouldRevalidate;\n}\n\n/**\n * Execute route.lazy() methods to lazily load route modules (loader, action,\n * shouldRevalidate) and update the routeManifest in place which shares objects\n * with dataRoutes so those get updated as well.\n */\nasync function loadLazyRouteModule(\n route: AgnosticDataRouteObject,\n mapRouteProperties: MapRoutePropertiesFunction,\n manifest: RouteManifest\n) {\n if (!route.lazy) {\n return;\n }\n\n let lazyRoute = await route.lazy();\n\n // If the lazy route function was executed and removed by another parallel\n // call then we can return - first lazy() to finish wins because the return\n // value of lazy is expected to be static\n if (!route.lazy) {\n return;\n }\n\n let routeToUpdate = manifest[route.id];\n invariant(routeToUpdate, \"No route found in manifest\");\n\n // Update the route in place. This should be safe because there's no way\n // we could yet be sitting on this route as we can't get there without\n // resolving lazy() first.\n //\n // This is different than the HMR \"update\" use-case where we may actively be\n // on the route being updated. The main concern boils down to \"does this\n // mutation affect any ongoing navigations or any current state.matches\n // values?\". If not, it should be safe to update in place.\n let routeUpdates: Record = {};\n for (let lazyRouteProperty in lazyRoute) {\n let staticRouteValue =\n routeToUpdate[lazyRouteProperty as keyof typeof routeToUpdate];\n\n let isPropertyStaticallyDefined =\n staticRouteValue !== undefined &&\n // This property isn't static since it should always be updated based\n // on the route updates\n lazyRouteProperty !== \"hasErrorBoundary\";\n\n warning(\n !isPropertyStaticallyDefined,\n `Route \"${routeToUpdate.id}\" has a static property \"${lazyRouteProperty}\" ` +\n `defined but its lazy function is also returning a value for this property. ` +\n `The lazy route property \"${lazyRouteProperty}\" will be ignored.`\n );\n\n if (\n !isPropertyStaticallyDefined &&\n !immutableRouteKeys.has(lazyRouteProperty as ImmutableRouteKey)\n ) {\n routeUpdates[lazyRouteProperty] =\n lazyRoute[lazyRouteProperty as keyof typeof lazyRoute];\n }\n }\n\n // Mutate the route with the provided updates. Do this first so we pass\n // the updated version to mapRouteProperties\n Object.assign(routeToUpdate, routeUpdates);\n\n // Mutate the `hasErrorBoundary` property on the route based on the route\n // updates and remove the `lazy` function so we don't resolve the lazy\n // route again.\n Object.assign(routeToUpdate, {\n // To keep things framework agnostic, we use the provided\n // `mapRouteProperties` (or wrapped `detectErrorBoundary`) function to\n // set the framework-aware properties (`element`/`hasErrorBoundary`) since\n // the logic will differ between frameworks.\n ...mapRouteProperties(routeToUpdate),\n lazy: undefined,\n });\n}\n\nasync function callLoaderOrAction(\n type: \"loader\" | \"action\",\n request: Request,\n match: AgnosticDataRouteMatch,\n matches: AgnosticDataRouteMatch[],\n manifest: RouteManifest,\n mapRouteProperties: MapRoutePropertiesFunction,\n basename: string,\n opts: {\n isStaticRequest?: boolean;\n isRouteRequest?: boolean;\n requestContext?: unknown;\n } = {}\n): Promise {\n let resultType;\n let result;\n let onReject: (() => void) | undefined;\n\n let runHandler = (handler: ActionFunction | LoaderFunction) => {\n // Setup a promise we can race against so that abort signals short circuit\n let reject: () => void;\n let abortPromise = new Promise((_, r) => (reject = r));\n onReject = () => reject();\n request.signal.addEventListener(\"abort\", onReject);\n return Promise.race([\n handler({\n request,\n params: match.params,\n context: opts.requestContext,\n }),\n abortPromise,\n ]);\n };\n\n try {\n let handler = match.route[type];\n\n if (match.route.lazy) {\n if (handler) {\n // Run statically defined handler in parallel with lazy()\n let values = await Promise.all([\n runHandler(handler),\n loadLazyRouteModule(match.route, mapRouteProperties, manifest),\n ]);\n result = values[0];\n } else {\n // Load lazy route module, then run any returned handler\n await loadLazyRouteModule(match.route, mapRouteProperties, manifest);\n\n handler = match.route[type];\n if (handler) {\n // Handler still run even if we got interrupted to maintain consistency\n // with un-abortable behavior of handler execution on non-lazy or\n // previously-lazy-loaded routes\n result = await runHandler(handler);\n } else if (type === \"action\") {\n let url = new URL(request.url);\n let pathname = url.pathname + url.search;\n throw getInternalRouterError(405, {\n method: request.method,\n pathname,\n routeId: match.route.id,\n });\n } else {\n // lazy() route has no loader to run. Short circuit here so we don't\n // hit the invariant below that errors on returning undefined.\n return { type: ResultType.data, data: undefined };\n }\n }\n } else if (!handler) {\n let url = new URL(request.url);\n let pathname = url.pathname + url.search;\n throw getInternalRouterError(404, {\n pathname,\n });\n } else {\n result = await runHandler(handler);\n }\n\n invariant(\n result !== undefined,\n `You defined ${type === \"action\" ? \"an action\" : \"a loader\"} for route ` +\n `\"${match.route.id}\" but didn't return anything from your \\`${type}\\` ` +\n `function. Please return a value or \\`null\\`.`\n );\n } catch (e) {\n resultType = ResultType.error;\n result = e;\n } finally {\n if (onReject) {\n request.signal.removeEventListener(\"abort\", onReject);\n }\n }\n\n if (isResponse(result)) {\n let status = result.status;\n\n // Process redirects\n if (redirectStatusCodes.has(status)) {\n let location = result.headers.get(\"Location\");\n invariant(\n location,\n \"Redirects returned/thrown from loaders/actions must have a Location header\"\n );\n\n // Support relative routing in internal redirects\n if (!ABSOLUTE_URL_REGEX.test(location)) {\n location = normalizeTo(\n new URL(request.url),\n matches.slice(0, matches.indexOf(match) + 1),\n basename,\n true,\n location\n );\n } else if (!opts.isStaticRequest) {\n // Strip off the protocol+origin for same-origin + same-basename absolute\n // redirects. If this is a static request, we can let it go back to the\n // browser as-is\n let currentUrl = new URL(request.url);\n let url = location.startsWith(\"//\")\n ? new URL(currentUrl.protocol + location)\n : new URL(location);\n let isSameBasename = stripBasename(url.pathname, basename) != null;\n if (url.origin === currentUrl.origin && isSameBasename) {\n location = url.pathname + url.search + url.hash;\n }\n }\n\n // Don't process redirects in the router during static requests requests.\n // Instead, throw the Response and let the server handle it with an HTTP\n // redirect. We also update the Location header in place in this flow so\n // basename and relative routing is taken into account\n if (opts.isStaticRequest) {\n result.headers.set(\"Location\", location);\n throw result;\n }\n\n return {\n type: ResultType.redirect,\n status,\n location,\n revalidate: result.headers.get(\"X-Remix-Revalidate\") !== null,\n reloadDocument: result.headers.get(\"X-Remix-Reload-Document\") !== null,\n };\n }\n\n // For SSR single-route requests, we want to hand Responses back directly\n // without unwrapping. We do this with the QueryRouteResponse wrapper\n // interface so we can know whether it was returned or thrown\n if (opts.isRouteRequest) {\n let queryRouteResponse: QueryRouteResponse = {\n type:\n resultType === ResultType.error ? ResultType.error : ResultType.data,\n response: result,\n };\n throw queryRouteResponse;\n }\n\n let data: any;\n let contentType = result.headers.get(\"Content-Type\");\n // Check between word boundaries instead of startsWith() due to the last\n // paragraph of https://httpwg.org/specs/rfc9110.html#field.content-type\n if (contentType && /\\bapplication\\/json\\b/.test(contentType)) {\n data = await result.json();\n } else {\n data = await result.text();\n }\n\n if (resultType === ResultType.error) {\n return {\n type: resultType,\n error: new ErrorResponse(status, result.statusText, data),\n headers: result.headers,\n };\n }\n\n return {\n type: ResultType.data,\n data,\n statusCode: result.status,\n headers: result.headers,\n };\n }\n\n if (resultType === ResultType.error) {\n return { type: resultType, error: result };\n }\n\n if (isDeferredData(result)) {\n return {\n type: ResultType.deferred,\n deferredData: result,\n statusCode: result.init?.status,\n headers: result.init?.headers && new Headers(result.init.headers),\n };\n }\n\n return { type: ResultType.data, data: result };\n}\n\n// Utility method for creating the Request instances for loaders/actions during\n// client-side navigations and fetches. During SSR we will always have a\n// Request instance from the static handler (query/queryRoute)\nfunction createClientSideRequest(\n history: History,\n location: string | Location,\n signal: AbortSignal,\n submission?: Submission\n): Request {\n let url = history.createURL(stripHashFromPath(location)).toString();\n let init: RequestInit = { signal };\n\n if (submission && isMutationMethod(submission.formMethod)) {\n let { formMethod, formEncType } = submission;\n // Didn't think we needed this but it turns out unlike other methods, patch\n // won't be properly normalized to uppercase and results in a 405 error.\n // See: https://fetch.spec.whatwg.org/#concept-method\n init.method = formMethod.toUpperCase();\n\n if (formEncType === \"application/json\") {\n init.headers = new Headers({ \"Content-Type\": formEncType });\n init.body = JSON.stringify(submission.json);\n } else if (formEncType === \"text/plain\") {\n // Content-Type is inferred (https://fetch.spec.whatwg.org/#dom-request)\n init.body = submission.text;\n } else if (\n formEncType === \"application/x-www-form-urlencoded\" &&\n submission.formData\n ) {\n // Content-Type is inferred (https://fetch.spec.whatwg.org/#dom-request)\n init.body = convertFormDataToSearchParams(submission.formData);\n } else {\n // Content-Type is inferred (https://fetch.spec.whatwg.org/#dom-request)\n init.body = submission.formData;\n }\n }\n\n return new Request(url, init);\n}\n\nfunction convertFormDataToSearchParams(formData: FormData): URLSearchParams {\n let searchParams = new URLSearchParams();\n\n for (let [key, value] of formData.entries()) {\n // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#converting-an-entry-list-to-a-list-of-name-value-pairs\n searchParams.append(key, typeof value === \"string\" ? value : value.name);\n }\n\n return searchParams;\n}\n\nfunction convertSearchParamsToFormData(\n searchParams: URLSearchParams\n): FormData {\n let formData = new FormData();\n for (let [key, value] of searchParams.entries()) {\n formData.append(key, value);\n }\n return formData;\n}\n\nfunction processRouteLoaderData(\n matches: AgnosticDataRouteMatch[],\n matchesToLoad: AgnosticDataRouteMatch[],\n results: DataResult[],\n pendingError: RouteData | undefined,\n activeDeferreds: Map\n): {\n loaderData: RouterState[\"loaderData\"];\n errors: RouterState[\"errors\"] | null;\n statusCode: number;\n loaderHeaders: Record;\n} {\n // Fill in loaderData/errors from our loaders\n let loaderData: RouterState[\"loaderData\"] = {};\n let errors: RouterState[\"errors\"] | null = null;\n let statusCode: number | undefined;\n let foundError = false;\n let loaderHeaders: Record = {};\n\n // Process loader results into state.loaderData/state.errors\n results.forEach((result, index) => {\n let id = matchesToLoad[index].route.id;\n invariant(\n !isRedirectResult(result),\n \"Cannot handle redirect results in processLoaderData\"\n );\n if (isErrorResult(result)) {\n // Look upwards from the matched route for the closest ancestor\n // error boundary, defaulting to the root match\n let boundaryMatch = findNearestBoundary(matches, id);\n let error = result.error;\n // If we have a pending action error, we report it at the highest-route\n // that throws a loader error, and then clear it out to indicate that\n // it was consumed\n if (pendingError) {\n error = Object.values(pendingError)[0];\n pendingError = undefined;\n }\n\n errors = errors || {};\n\n // Prefer higher error values if lower errors bubble to the same boundary\n if (errors[boundaryMatch.route.id] == null) {\n errors[boundaryMatch.route.id] = error;\n }\n\n // Clear our any prior loaderData for the throwing route\n loaderData[id] = undefined;\n\n // Once we find our first (highest) error, we set the status code and\n // prevent deeper status codes from overriding\n if (!foundError) {\n foundError = true;\n statusCode = isRouteErrorResponse(result.error)\n ? result.error.status\n : 500;\n }\n if (result.headers) {\n loaderHeaders[id] = result.headers;\n }\n } else {\n if (isDeferredResult(result)) {\n activeDeferreds.set(id, result.deferredData);\n loaderData[id] = result.deferredData.data;\n } else {\n loaderData[id] = result.data;\n }\n\n // Error status codes always override success status codes, but if all\n // loaders are successful we take the deepest status code.\n if (\n result.statusCode != null &&\n result.statusCode !== 200 &&\n !foundError\n ) {\n statusCode = result.statusCode;\n }\n if (result.headers) {\n loaderHeaders[id] = result.headers;\n }\n }\n });\n\n // If we didn't consume the pending action error (i.e., all loaders\n // resolved), then consume it here. Also clear out any loaderData for the\n // throwing route\n if (pendingError) {\n errors = pendingError;\n loaderData[Object.keys(pendingError)[0]] = undefined;\n }\n\n return {\n loaderData,\n errors,\n statusCode: statusCode || 200,\n loaderHeaders,\n };\n}\n\nfunction processLoaderData(\n state: RouterState,\n matches: AgnosticDataRouteMatch[],\n matchesToLoad: AgnosticDataRouteMatch[],\n results: DataResult[],\n pendingError: RouteData | undefined,\n revalidatingFetchers: RevalidatingFetcher[],\n fetcherResults: DataResult[],\n activeDeferreds: Map\n): {\n loaderData: RouterState[\"loaderData\"];\n errors?: RouterState[\"errors\"];\n} {\n let { loaderData, errors } = processRouteLoaderData(\n matches,\n matchesToLoad,\n results,\n pendingError,\n activeDeferreds\n );\n\n // Process results from our revalidating fetchers\n for (let index = 0; index < revalidatingFetchers.length; index++) {\n let { key, match, controller } = revalidatingFetchers[index];\n invariant(\n fetcherResults !== undefined && fetcherResults[index] !== undefined,\n \"Did not find corresponding fetcher result\"\n );\n let result = fetcherResults[index];\n\n // Process fetcher non-redirect errors\n if (controller && controller.signal.aborted) {\n // Nothing to do for aborted fetchers\n continue;\n } else if (isErrorResult(result)) {\n let boundaryMatch = findNearestBoundary(state.matches, match?.route.id);\n if (!(errors && errors[boundaryMatch.route.id])) {\n errors = {\n ...errors,\n [boundaryMatch.route.id]: result.error,\n };\n }\n state.fetchers.delete(key);\n } else if (isRedirectResult(result)) {\n // Should never get here, redirects should get processed above, but we\n // keep this to type narrow to a success result in the else\n invariant(false, \"Unhandled fetcher revalidation redirect\");\n } else if (isDeferredResult(result)) {\n // Should never get here, deferred data should be awaited for fetchers\n // in resolveDeferredResults\n invariant(false, \"Unhandled fetcher deferred data\");\n } else {\n let doneFetcher = getDoneFetcher(result.data);\n state.fetchers.set(key, doneFetcher);\n }\n }\n\n return { loaderData, errors };\n}\n\nfunction mergeLoaderData(\n loaderData: RouteData,\n newLoaderData: RouteData,\n matches: AgnosticDataRouteMatch[],\n errors: RouteData | null | undefined\n): RouteData {\n let mergedLoaderData = { ...newLoaderData };\n for (let match of matches) {\n let id = match.route.id;\n if (newLoaderData.hasOwnProperty(id)) {\n if (newLoaderData[id] !== undefined) {\n mergedLoaderData[id] = newLoaderData[id];\n } else {\n // No-op - this is so we ignore existing data if we have a key in the\n // incoming object with an undefined value, which is how we unset a prior\n // loaderData if we encounter a loader error\n }\n } else if (loaderData[id] !== undefined && match.route.loader) {\n // Preserve existing keys not included in newLoaderData and where a loader\n // wasn't removed by HMR\n mergedLoaderData[id] = loaderData[id];\n }\n\n if (errors && errors.hasOwnProperty(id)) {\n // Don't keep any loader data below the boundary\n break;\n }\n }\n return mergedLoaderData;\n}\n\n// Find the nearest error boundary, looking upwards from the leaf route (or the\n// route specified by routeId) for the closest ancestor error boundary,\n// defaulting to the root match\nfunction findNearestBoundary(\n matches: AgnosticDataRouteMatch[],\n routeId?: string\n): AgnosticDataRouteMatch {\n let eligibleMatches = routeId\n ? matches.slice(0, matches.findIndex((m) => m.route.id === routeId) + 1)\n : [...matches];\n return (\n eligibleMatches.reverse().find((m) => m.route.hasErrorBoundary === true) ||\n matches[0]\n );\n}\n\nfunction getShortCircuitMatches(routes: AgnosticDataRouteObject[]): {\n matches: AgnosticDataRouteMatch[];\n route: AgnosticDataRouteObject;\n} {\n // Prefer a root layout route if present, otherwise shim in a route object\n let route = routes.find((r) => r.index || !r.path || r.path === \"/\") || {\n id: `__shim-error-route__`,\n };\n\n return {\n matches: [\n {\n params: {},\n pathname: \"\",\n pathnameBase: \"\",\n route,\n },\n ],\n route,\n };\n}\n\nfunction getInternalRouterError(\n status: number,\n {\n pathname,\n routeId,\n method,\n type,\n }: {\n pathname?: string;\n routeId?: string;\n method?: string;\n type?: \"defer-action\" | \"invalid-body\";\n } = {}\n) {\n let statusText = \"Unknown Server Error\";\n let errorMessage = \"Unknown @remix-run/router error\";\n\n if (status === 400) {\n statusText = \"Bad Request\";\n if (method && pathname && routeId) {\n errorMessage =\n `You made a ${method} request to \"${pathname}\" but ` +\n `did not provide a \\`loader\\` for route \"${routeId}\", ` +\n `so there is no way to handle the request.`;\n } else if (type === \"defer-action\") {\n errorMessage = \"defer() is not supported in actions\";\n } else if (type === \"invalid-body\") {\n errorMessage = \"Unable to encode submission body\";\n }\n } else if (status === 403) {\n statusText = \"Forbidden\";\n errorMessage = `Route \"${routeId}\" does not match URL \"${pathname}\"`;\n } else if (status === 404) {\n statusText = \"Not Found\";\n errorMessage = `No route matches URL \"${pathname}\"`;\n } else if (status === 405) {\n statusText = \"Method Not Allowed\";\n if (method && pathname && routeId) {\n errorMessage =\n `You made a ${method.toUpperCase()} request to \"${pathname}\" but ` +\n `did not provide an \\`action\\` for route \"${routeId}\", ` +\n `so there is no way to handle the request.`;\n } else if (method) {\n errorMessage = `Invalid request method \"${method.toUpperCase()}\"`;\n }\n }\n\n return new ErrorResponse(\n status || 500,\n statusText,\n new Error(errorMessage),\n true\n );\n}\n\n// Find any returned redirect errors, starting from the lowest match\nfunction findRedirect(\n results: DataResult[]\n): { result: RedirectResult; idx: number } | undefined {\n for (let i = results.length - 1; i >= 0; i--) {\n let result = results[i];\n if (isRedirectResult(result)) {\n return { result, idx: i };\n }\n }\n}\n\nfunction stripHashFromPath(path: To) {\n let parsedPath = typeof path === \"string\" ? parsePath(path) : path;\n return createPath({ ...parsedPath, hash: \"\" });\n}\n\nfunction isHashChangeOnly(a: Location, b: Location): boolean {\n if (a.pathname !== b.pathname || a.search !== b.search) {\n return false;\n }\n\n if (a.hash === \"\") {\n // /page -> /page#hash\n return b.hash !== \"\";\n } else if (a.hash === b.hash) {\n // /page#hash -> /page#hash\n return true;\n } else if (b.hash !== \"\") {\n // /page#hash -> /page#other\n return true;\n }\n\n // If the hash is removed the browser will re-perform a request to the server\n // /page#hash -> /page\n return false;\n}\n\nfunction isDeferredResult(result: DataResult): result is DeferredResult {\n return result.type === ResultType.deferred;\n}\n\nfunction isErrorResult(result: DataResult): result is ErrorResult {\n return result.type === ResultType.error;\n}\n\nfunction isRedirectResult(result?: DataResult): result is RedirectResult {\n return (result && result.type) === ResultType.redirect;\n}\n\nexport function isDeferredData(value: any): value is DeferredData {\n let deferred: DeferredData = value;\n return (\n deferred &&\n typeof deferred === \"object\" &&\n typeof deferred.data === \"object\" &&\n typeof deferred.subscribe === \"function\" &&\n typeof deferred.cancel === \"function\" &&\n typeof deferred.resolveData === \"function\"\n );\n}\n\nfunction isResponse(value: any): value is Response {\n return (\n value != null &&\n typeof value.status === \"number\" &&\n typeof value.statusText === \"string\" &&\n typeof value.headers === \"object\" &&\n typeof value.body !== \"undefined\"\n );\n}\n\nfunction isRedirectResponse(result: any): result is Response {\n if (!isResponse(result)) {\n return false;\n }\n\n let status = result.status;\n let location = result.headers.get(\"Location\");\n return status >= 300 && status <= 399 && location != null;\n}\n\nfunction isQueryRouteResponse(obj: any): obj is QueryRouteResponse {\n return (\n obj &&\n isResponse(obj.response) &&\n (obj.type === ResultType.data || obj.type === ResultType.error)\n );\n}\n\nfunction isValidMethod(method: string): method is FormMethod | V7_FormMethod {\n return validRequestMethods.has(method.toLowerCase() as FormMethod);\n}\n\nfunction isMutationMethod(\n method: string\n): method is MutationFormMethod | V7_MutationFormMethod {\n return validMutationMethods.has(method.toLowerCase() as MutationFormMethod);\n}\n\nasync function resolveDeferredResults(\n currentMatches: AgnosticDataRouteMatch[],\n matchesToLoad: (AgnosticDataRouteMatch | null)[],\n results: DataResult[],\n signals: (AbortSignal | null)[],\n isFetcher: boolean,\n currentLoaderData?: RouteData\n) {\n for (let index = 0; index < results.length; index++) {\n let result = results[index];\n let match = matchesToLoad[index];\n // If we don't have a match, then we can have a deferred result to do\n // anything with. This is for revalidating fetchers where the route was\n // removed during HMR\n if (!match) {\n continue;\n }\n\n let currentMatch = currentMatches.find(\n (m) => m.route.id === match!.route.id\n );\n let isRevalidatingLoader =\n currentMatch != null &&\n !isNewRouteInstance(currentMatch, match) &&\n (currentLoaderData && currentLoaderData[match.route.id]) !== undefined;\n\n if (isDeferredResult(result) && (isFetcher || isRevalidatingLoader)) {\n // Note: we do not have to touch activeDeferreds here since we race them\n // against the signal in resolveDeferredData and they'll get aborted\n // there if needed\n let signal = signals[index];\n invariant(\n signal,\n \"Expected an AbortSignal for revalidating fetcher deferred result\"\n );\n await resolveDeferredData(result, signal, isFetcher).then((result) => {\n if (result) {\n results[index] = result || results[index];\n }\n });\n }\n }\n}\n\nasync function resolveDeferredData(\n result: DeferredResult,\n signal: AbortSignal,\n unwrap = false\n): Promise {\n let aborted = await result.deferredData.resolveData(signal);\n if (aborted) {\n return;\n }\n\n if (unwrap) {\n try {\n return {\n type: ResultType.data,\n data: result.deferredData.unwrappedData,\n };\n } catch (e) {\n // Handle any TrackedPromise._error values encountered while unwrapping\n return {\n type: ResultType.error,\n error: e,\n };\n }\n }\n\n return {\n type: ResultType.data,\n data: result.deferredData.data,\n };\n}\n\nfunction hasNakedIndexQuery(search: string): boolean {\n return new URLSearchParams(search).getAll(\"index\").some((v) => v === \"\");\n}\n\n// Note: This should match the format exported by useMatches, so if you change\n// this please also change that :) Eventually we'll DRY this up\nfunction createUseMatchesMatch(\n match: AgnosticDataRouteMatch,\n loaderData: RouteData\n): UseMatchesMatch {\n let { route, pathname, params } = match;\n return {\n id: route.id,\n pathname,\n params,\n data: loaderData[route.id] as unknown,\n handle: route.handle as unknown,\n };\n}\n\nfunction getTargetMatch(\n matches: AgnosticDataRouteMatch[],\n location: Location | string\n) {\n let search =\n typeof location === \"string\" ? parsePath(location).search : location.search;\n if (\n matches[matches.length - 1].route.index &&\n hasNakedIndexQuery(search || \"\")\n ) {\n // Return the leaf index route when index is present\n return matches[matches.length - 1];\n }\n // Otherwise grab the deepest \"path contributing\" match (ignoring index and\n // pathless layout routes)\n let pathMatches = getPathContributingMatches(matches);\n return pathMatches[pathMatches.length - 1];\n}\n\nfunction getSubmissionFromNavigation(\n navigation: Navigation\n): Submission | undefined {\n let { formMethod, formAction, formEncType, text, formData, json } =\n navigation;\n if (!formMethod || !formAction || !formEncType) {\n return;\n }\n\n if (text != null) {\n return {\n formMethod,\n formAction,\n formEncType,\n formData: undefined,\n json: undefined,\n text,\n };\n } else if (formData != null) {\n return {\n formMethod,\n formAction,\n formEncType,\n formData,\n json: undefined,\n text: undefined,\n };\n } else if (json !== undefined) {\n return {\n formMethod,\n formAction,\n formEncType,\n formData: undefined,\n json,\n text: undefined,\n };\n }\n}\n\nfunction getLoadingNavigation(\n location: Location,\n submission?: Submission\n): NavigationStates[\"Loading\"] {\n if (submission) {\n let navigation: NavigationStates[\"Loading\"] = {\n state: \"loading\",\n location,\n formMethod: submission.formMethod,\n formAction: submission.formAction,\n formEncType: submission.formEncType,\n formData: submission.formData,\n json: submission.json,\n text: submission.text,\n };\n return navigation;\n } else {\n let navigation: NavigationStates[\"Loading\"] = {\n state: \"loading\",\n location,\n formMethod: undefined,\n formAction: undefined,\n formEncType: undefined,\n formData: undefined,\n json: undefined,\n text: undefined,\n };\n return navigation;\n }\n}\n\nfunction getSubmittingNavigation(\n location: Location,\n submission: Submission\n): NavigationStates[\"Submitting\"] {\n let navigation: NavigationStates[\"Submitting\"] = {\n state: \"submitting\",\n location,\n formMethod: submission.formMethod,\n formAction: submission.formAction,\n formEncType: submission.formEncType,\n formData: submission.formData,\n json: submission.json,\n text: submission.text,\n };\n return navigation;\n}\n\nfunction getLoadingFetcher(\n submission?: Submission,\n data?: Fetcher[\"data\"]\n): FetcherStates[\"Loading\"] {\n if (submission) {\n let fetcher: FetcherStates[\"Loading\"] = {\n state: \"loading\",\n formMethod: submission.formMethod,\n formAction: submission.formAction,\n formEncType: submission.formEncType,\n formData: submission.formData,\n json: submission.json,\n text: submission.text,\n data,\n \" _hasFetcherDoneAnything \": true,\n };\n return fetcher;\n } else {\n let fetcher: FetcherStates[\"Loading\"] = {\n state: \"loading\",\n formMethod: undefined,\n formAction: undefined,\n formEncType: undefined,\n formData: undefined,\n json: undefined,\n text: undefined,\n data,\n \" _hasFetcherDoneAnything \": true,\n };\n return fetcher;\n }\n}\n\nfunction getSubmittingFetcher(\n submission: Submission,\n existingFetcher?: Fetcher\n): FetcherStates[\"Submitting\"] {\n let fetcher: FetcherStates[\"Submitting\"] = {\n state: \"submitting\",\n formMethod: submission.formMethod,\n formAction: submission.formAction,\n formEncType: submission.formEncType,\n formData: submission.formData,\n json: submission.json,\n text: submission.text,\n data: existingFetcher ? existingFetcher.data : undefined,\n \" _hasFetcherDoneAnything \": true,\n };\n return fetcher;\n}\n\nfunction getDoneFetcher(data: Fetcher[\"data\"]): FetcherStates[\"Idle\"] {\n let fetcher: FetcherStates[\"Idle\"] = {\n state: \"idle\",\n formMethod: undefined,\n formAction: undefined,\n formEncType: undefined,\n formData: undefined,\n json: undefined,\n text: undefined,\n data,\n \" _hasFetcherDoneAnything \": true,\n };\n return fetcher;\n}\n//#endregion\n","import * as React from \"react\";\nimport type {\n AgnosticRouteMatch,\n AgnosticIndexRouteObject,\n AgnosticNonIndexRouteObject,\n History,\n Location,\n RelativeRoutingType,\n Router,\n StaticHandlerContext,\n To,\n TrackedPromise,\n LazyRouteFunction,\n} from \"@remix-run/router\";\nimport type { Action as NavigationType } from \"@remix-run/router\";\n\n// Create react-specific types from the agnostic types in @remix-run/router to\n// export from react-router\nexport interface IndexRouteObject {\n caseSensitive?: AgnosticIndexRouteObject[\"caseSensitive\"];\n path?: AgnosticIndexRouteObject[\"path\"];\n id?: AgnosticIndexRouteObject[\"id\"];\n loader?: AgnosticIndexRouteObject[\"loader\"];\n action?: AgnosticIndexRouteObject[\"action\"];\n hasErrorBoundary?: AgnosticIndexRouteObject[\"hasErrorBoundary\"];\n shouldRevalidate?: AgnosticIndexRouteObject[\"shouldRevalidate\"];\n handle?: AgnosticIndexRouteObject[\"handle\"];\n index: true;\n children?: undefined;\n element?: React.ReactNode | null;\n errorElement?: React.ReactNode | null;\n Component?: React.ComponentType | null;\n ErrorBoundary?: React.ComponentType | null;\n lazy?: LazyRouteFunction;\n}\n\nexport interface NonIndexRouteObject {\n caseSensitive?: AgnosticNonIndexRouteObject[\"caseSensitive\"];\n path?: AgnosticNonIndexRouteObject[\"path\"];\n id?: AgnosticNonIndexRouteObject[\"id\"];\n loader?: AgnosticNonIndexRouteObject[\"loader\"];\n action?: AgnosticNonIndexRouteObject[\"action\"];\n hasErrorBoundary?: AgnosticNonIndexRouteObject[\"hasErrorBoundary\"];\n shouldRevalidate?: AgnosticNonIndexRouteObject[\"shouldRevalidate\"];\n handle?: AgnosticNonIndexRouteObject[\"handle\"];\n index?: false;\n children?: RouteObject[];\n element?: React.ReactNode | null;\n errorElement?: React.ReactNode | null;\n Component?: React.ComponentType | null;\n ErrorBoundary?: React.ComponentType | null;\n lazy?: LazyRouteFunction;\n}\n\nexport type RouteObject = IndexRouteObject | NonIndexRouteObject;\n\nexport type DataRouteObject = RouteObject & {\n children?: DataRouteObject[];\n id: string;\n};\n\nexport interface RouteMatch<\n ParamKey extends string = string,\n RouteObjectType extends RouteObject = RouteObject\n> extends AgnosticRouteMatch {}\n\nexport interface DataRouteMatch extends RouteMatch {}\n\nexport interface DataRouterContextObject extends NavigationContextObject {\n router: Router;\n staticContext?: StaticHandlerContext;\n}\n\nexport const DataRouterContext =\n React.createContext(null);\nif (__DEV__) {\n DataRouterContext.displayName = \"DataRouter\";\n}\n\nexport const DataRouterStateContext = React.createContext<\n Router[\"state\"] | null\n>(null);\nif (__DEV__) {\n DataRouterStateContext.displayName = \"DataRouterState\";\n}\n\nexport const AwaitContext = React.createContext(null);\nif (__DEV__) {\n AwaitContext.displayName = \"Await\";\n}\n\nexport interface NavigateOptions {\n replace?: boolean;\n state?: any;\n preventScrollReset?: boolean;\n relative?: RelativeRoutingType;\n}\n\n/**\n * A Navigator is a \"location changer\"; it's how you get to different locations.\n *\n * Every history instance conforms to the Navigator interface, but the\n * distinction is useful primarily when it comes to the low-level API\n * where both the location and a navigator must be provided separately in order\n * to avoid \"tearing\" that may occur in a suspense-enabled app if the action\n * and/or location were to be read directly from the history instance.\n */\nexport interface Navigator {\n createHref: History[\"createHref\"];\n // Optional for backwards-compat with Router/HistoryRouter usage (edge case)\n encodeLocation?: History[\"encodeLocation\"];\n go: History[\"go\"];\n push(to: To, state?: any, opts?: NavigateOptions): void;\n replace(to: To, state?: any, opts?: NavigateOptions): void;\n}\n\ninterface NavigationContextObject {\n basename: string;\n navigator: Navigator;\n static: boolean;\n}\n\nexport const NavigationContext = React.createContext(\n null!\n);\n\nif (__DEV__) {\n NavigationContext.displayName = \"Navigation\";\n}\n\ninterface LocationContextObject {\n location: Location;\n navigationType: NavigationType;\n}\n\nexport const LocationContext = React.createContext(\n null!\n);\n\nif (__DEV__) {\n LocationContext.displayName = \"Location\";\n}\n\nexport interface RouteContextObject {\n outlet: React.ReactElement | null;\n matches: RouteMatch[];\n isDataRoute: boolean;\n}\n\nexport const RouteContext = React.createContext({\n outlet: null,\n matches: [],\n isDataRoute: false,\n});\n\nif (__DEV__) {\n RouteContext.displayName = \"Route\";\n}\n\nexport const RouteErrorContext = React.createContext(null);\n\nif (__DEV__) {\n RouteErrorContext.displayName = \"RouteError\";\n}\n","import * as React from \"react\";\nimport type {\n Blocker,\n BlockerFunction,\n Location,\n ParamParseKey,\n Params,\n Path,\n PathMatch,\n PathPattern,\n RelativeRoutingType,\n Router as RemixRouter,\n RevalidationState,\n To,\n} from \"@remix-run/router\";\nimport {\n Action as NavigationType,\n UNSAFE_invariant as invariant,\n isRouteErrorResponse,\n joinPaths,\n matchPath,\n matchRoutes,\n parsePath,\n resolveTo,\n stripBasename,\n IDLE_BLOCKER,\n UNSAFE_getPathContributingMatches as getPathContributingMatches,\n UNSAFE_warning as warning,\n} from \"@remix-run/router\";\n\nimport type {\n NavigateOptions,\n RouteContextObject,\n RouteMatch,\n RouteObject,\n DataRouteMatch,\n} from \"./context\";\nimport {\n DataRouterContext,\n DataRouterStateContext,\n LocationContext,\n NavigationContext,\n RouteContext,\n RouteErrorContext,\n AwaitContext,\n} from \"./context\";\n\n/**\n * Returns the full href for the given \"to\" value. This is useful for building\n * custom links that are also accessible and preserve right-click behavior.\n *\n * @see https://reactrouter.com/hooks/use-href\n */\nexport function useHref(\n to: To,\n { relative }: { relative?: RelativeRoutingType } = {}\n): string {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useHref() may be used only in the context of a component.`\n );\n\n let { basename, navigator } = React.useContext(NavigationContext);\n let { hash, pathname, search } = useResolvedPath(to, { relative });\n\n let joinedPathname = pathname;\n\n // If we're operating within a basename, prepend it to the pathname prior\n // to creating the href. If this is a root navigation, then just use the raw\n // basename which allows the basename to have full control over the presence\n // of a trailing slash on root links\n if (basename !== \"/\") {\n joinedPathname =\n pathname === \"/\" ? basename : joinPaths([basename, pathname]);\n }\n\n return navigator.createHref({ pathname: joinedPathname, search, hash });\n}\n\n/**\n * Returns true if this component is a descendant of a .\n *\n * @see https://reactrouter.com/hooks/use-in-router-context\n */\nexport function useInRouterContext(): boolean {\n return React.useContext(LocationContext) != null;\n}\n\n/**\n * Returns the current location object, which represents the current URL in web\n * browsers.\n *\n * Note: If you're using this it may mean you're doing some of your own\n * \"routing\" in your app, and we'd like to know what your use case is. We may\n * be able to provide something higher-level to better suit your needs.\n *\n * @see https://reactrouter.com/hooks/use-location\n */\nexport function useLocation(): Location {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useLocation() may be used only in the context of a component.`\n );\n\n return React.useContext(LocationContext).location;\n}\n\n/**\n * Returns the current navigation action which describes how the router came to\n * the current location, either by a pop, push, or replace on the history stack.\n *\n * @see https://reactrouter.com/hooks/use-navigation-type\n */\nexport function useNavigationType(): NavigationType {\n return React.useContext(LocationContext).navigationType;\n}\n\n/**\n * Returns a PathMatch object if the given pattern matches the current URL.\n * This is useful for components that need to know \"active\" state, e.g.\n * .\n *\n * @see https://reactrouter.com/hooks/use-match\n */\nexport function useMatch<\n ParamKey extends ParamParseKey,\n Path extends string\n>(pattern: PathPattern | Path): PathMatch | null {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useMatch() may be used only in the context of a component.`\n );\n\n let { pathname } = useLocation();\n return React.useMemo(\n () => matchPath(pattern, pathname),\n [pathname, pattern]\n );\n}\n\n/**\n * The interface for the navigate() function returned from useNavigate().\n */\nexport interface NavigateFunction {\n (to: To, options?: NavigateOptions): void;\n (delta: number): void;\n}\n\nconst navigateEffectWarning =\n `You should call navigate() in a React.useEffect(), not when ` +\n `your component is first rendered.`;\n\n// Mute warnings for calls to useNavigate in SSR environments\nfunction useIsomorphicLayoutEffect(\n cb: Parameters[0]\n) {\n let isStatic = React.useContext(NavigationContext).static;\n if (!isStatic) {\n // We should be able to get rid of this once react 18.3 is released\n // See: https://github.com/facebook/react/pull/26395\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useLayoutEffect(cb);\n }\n}\n\n/**\n * Returns an imperative method for changing the location. Used by s, but\n * may also be used by other elements to change the location.\n *\n * @see https://reactrouter.com/hooks/use-navigate\n */\nexport function useNavigate(): NavigateFunction {\n let { isDataRoute } = React.useContext(RouteContext);\n // Conditional usage is OK here because the usage of a data router is static\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return isDataRoute ? useNavigateStable() : useNavigateUnstable();\n}\n\nfunction useNavigateUnstable(): NavigateFunction {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useNavigate() may be used only in the context of a component.`\n );\n\n let dataRouterContext = React.useContext(DataRouterContext);\n let { basename, navigator } = React.useContext(NavigationContext);\n let { matches } = React.useContext(RouteContext);\n let { pathname: locationPathname } = useLocation();\n\n let routePathnamesJson = JSON.stringify(\n getPathContributingMatches(matches).map((match) => match.pathnameBase)\n );\n\n let activeRef = React.useRef(false);\n useIsomorphicLayoutEffect(() => {\n activeRef.current = true;\n });\n\n let navigate: NavigateFunction = React.useCallback(\n (to: To | number, options: NavigateOptions = {}) => {\n warning(activeRef.current, navigateEffectWarning);\n\n // Short circuit here since if this happens on first render the navigate\n // is useless because we haven't wired up our history listener yet\n if (!activeRef.current) return;\n\n if (typeof to === \"number\") {\n navigator.go(to);\n return;\n }\n\n let path = resolveTo(\n to,\n JSON.parse(routePathnamesJson),\n locationPathname,\n options.relative === \"path\"\n );\n\n // If we're operating within a basename, prepend it to the pathname prior\n // to handing off to history (but only if we're not in a data router,\n // otherwise it'll prepend the basename inside of the router).\n // If this is a root navigation, then we navigate to the raw basename\n // which allows the basename to have full control over the presence of a\n // trailing slash on root links\n if (dataRouterContext == null && basename !== \"/\") {\n path.pathname =\n path.pathname === \"/\"\n ? basename\n : joinPaths([basename, path.pathname]);\n }\n\n (!!options.replace ? navigator.replace : navigator.push)(\n path,\n options.state,\n options\n );\n },\n [\n basename,\n navigator,\n routePathnamesJson,\n locationPathname,\n dataRouterContext,\n ]\n );\n\n return navigate;\n}\n\nconst OutletContext = React.createContext(null);\n\n/**\n * Returns the context (if provided) for the child route at this level of the route\n * hierarchy.\n * @see https://reactrouter.com/hooks/use-outlet-context\n */\nexport function useOutletContext(): Context {\n return React.useContext(OutletContext) as Context;\n}\n\n/**\n * Returns the element for the child route at this level of the route\n * hierarchy. Used internally by to render child routes.\n *\n * @see https://reactrouter.com/hooks/use-outlet\n */\nexport function useOutlet(context?: unknown): React.ReactElement | null {\n let outlet = React.useContext(RouteContext).outlet;\n if (outlet) {\n return (\n {outlet}\n );\n }\n return outlet;\n}\n\n/**\n * Returns an object of key/value pairs of the dynamic params from the current\n * URL that were matched by the route path.\n *\n * @see https://reactrouter.com/hooks/use-params\n */\nexport function useParams<\n ParamsOrKey extends string | Record = string\n>(): Readonly<\n [ParamsOrKey] extends [string] ? Params : Partial\n> {\n let { matches } = React.useContext(RouteContext);\n let routeMatch = matches[matches.length - 1];\n return routeMatch ? (routeMatch.params as any) : {};\n}\n\n/**\n * Resolves the pathname of the given `to` value against the current location.\n *\n * @see https://reactrouter.com/hooks/use-resolved-path\n */\nexport function useResolvedPath(\n to: To,\n { relative }: { relative?: RelativeRoutingType } = {}\n): Path {\n let { matches } = React.useContext(RouteContext);\n let { pathname: locationPathname } = useLocation();\n\n let routePathnamesJson = JSON.stringify(\n getPathContributingMatches(matches).map((match) => match.pathnameBase)\n );\n\n return React.useMemo(\n () =>\n resolveTo(\n to,\n JSON.parse(routePathnamesJson),\n locationPathname,\n relative === \"path\"\n ),\n [to, routePathnamesJson, locationPathname, relative]\n );\n}\n\n/**\n * Returns the element of the route that matched the current location, prepared\n * with the correct context to render the remainder of the route tree. Route\n * elements in the tree must render an to render their child route's\n * element.\n *\n * @see https://reactrouter.com/hooks/use-routes\n */\nexport function useRoutes(\n routes: RouteObject[],\n locationArg?: Partial | string\n): React.ReactElement | null {\n return useRoutesImpl(routes, locationArg);\n}\n\n// Internal implementation with accept optional param for RouterProvider usage\nexport function useRoutesImpl(\n routes: RouteObject[],\n locationArg?: Partial | string,\n dataRouterState?: RemixRouter[\"state\"]\n): React.ReactElement | null {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useRoutes() may be used only in the context of a component.`\n );\n\n let { navigator } = React.useContext(NavigationContext);\n let { matches: parentMatches } = React.useContext(RouteContext);\n let routeMatch = parentMatches[parentMatches.length - 1];\n let parentParams = routeMatch ? routeMatch.params : {};\n let parentPathname = routeMatch ? routeMatch.pathname : \"/\";\n let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : \"/\";\n let parentRoute = routeMatch && routeMatch.route;\n\n if (__DEV__) {\n // You won't get a warning about 2 different under a \n // without a trailing *, but this is a best-effort warning anyway since we\n // cannot even give the warning unless they land at the parent route.\n //\n // Example:\n //\n // \n // {/* This route path MUST end with /* because otherwise\n // it will never match /blog/post/123 */}\n // } />\n // } />\n // \n //\n // function Blog() {\n // return (\n // \n // } />\n // \n // );\n // }\n let parentPath = (parentRoute && parentRoute.path) || \"\";\n warningOnce(\n parentPathname,\n !parentRoute || parentPath.endsWith(\"*\"),\n `You rendered descendant (or called \\`useRoutes()\\`) at ` +\n `\"${parentPathname}\" (under ) but the ` +\n `parent route path has no trailing \"*\". This means if you navigate ` +\n `deeper, the parent won't match anymore and therefore the child ` +\n `routes will never render.\\n\\n` +\n `Please change the parent to .`\n );\n }\n\n let locationFromContext = useLocation();\n\n let location;\n if (locationArg) {\n let parsedLocationArg =\n typeof locationArg === \"string\" ? parsePath(locationArg) : locationArg;\n\n invariant(\n parentPathnameBase === \"/\" ||\n parsedLocationArg.pathname?.startsWith(parentPathnameBase),\n `When overriding the location using \\`\\` or \\`useRoutes(routes, location)\\`, ` +\n `the location pathname must begin with the portion of the URL pathname that was ` +\n `matched by all parent routes. The current pathname base is \"${parentPathnameBase}\" ` +\n `but pathname \"${parsedLocationArg.pathname}\" was given in the \\`location\\` prop.`\n );\n\n location = parsedLocationArg;\n } else {\n location = locationFromContext;\n }\n\n let pathname = location.pathname || \"/\";\n let remainingPathname =\n parentPathnameBase === \"/\"\n ? pathname\n : pathname.slice(parentPathnameBase.length) || \"/\";\n\n let matches = matchRoutes(routes, { pathname: remainingPathname });\n\n if (__DEV__) {\n warning(\n parentRoute || matches != null,\n `No routes matched location \"${location.pathname}${location.search}${location.hash}\" `\n );\n\n warning(\n matches == null ||\n matches[matches.length - 1].route.element !== undefined ||\n matches[matches.length - 1].route.Component !== undefined,\n `Matched leaf route at location \"${location.pathname}${location.search}${location.hash}\" ` +\n `does not have an element or Component. This means it will render an with a ` +\n `null value by default resulting in an \"empty\" page.`\n );\n }\n\n let renderedMatches = _renderMatches(\n matches &&\n matches.map((match) =>\n Object.assign({}, match, {\n params: Object.assign({}, parentParams, match.params),\n pathname: joinPaths([\n parentPathnameBase,\n // Re-encode pathnames that were decoded inside matchRoutes\n navigator.encodeLocation\n ? navigator.encodeLocation(match.pathname).pathname\n : match.pathname,\n ]),\n pathnameBase:\n match.pathnameBase === \"/\"\n ? parentPathnameBase\n : joinPaths([\n parentPathnameBase,\n // Re-encode pathnames that were decoded inside matchRoutes\n navigator.encodeLocation\n ? navigator.encodeLocation(match.pathnameBase).pathname\n : match.pathnameBase,\n ]),\n })\n ),\n parentMatches,\n dataRouterState\n );\n\n // When a user passes in a `locationArg`, the associated routes need to\n // be wrapped in a new `LocationContext.Provider` in order for `useLocation`\n // to use the scoped location instead of the global location.\n if (locationArg && renderedMatches) {\n return (\n \n {renderedMatches}\n \n );\n }\n\n return renderedMatches;\n}\n\nfunction DefaultErrorComponent() {\n let error = useRouteError();\n let message = isRouteErrorResponse(error)\n ? `${error.status} ${error.statusText}`\n : error instanceof Error\n ? error.message\n : JSON.stringify(error);\n let stack = error instanceof Error ? error.stack : null;\n let lightgrey = \"rgba(200,200,200, 0.5)\";\n let preStyles = { padding: \"0.5rem\", backgroundColor: lightgrey };\n let codeStyles = { padding: \"2px 4px\", backgroundColor: lightgrey };\n\n let devInfo = null;\n if (__DEV__) {\n console.error(\n \"Error handled by React Router default ErrorBoundary:\",\n error\n );\n\n devInfo = (\n <>\n

💿 Hey developer 👋

\n

\n You can provide a way better UX than this when your app throws errors\n by providing your own ErrorBoundary or{\" \"}\n errorElement prop on your route.\n

\n \n );\n }\n\n return (\n <>\n

Unexpected Application Error!

\n

{message}

\n {stack ?
{stack}
: null}\n {devInfo}\n \n );\n}\n\nconst defaultErrorElement = ;\n\ntype RenderErrorBoundaryProps = React.PropsWithChildren<{\n location: Location;\n revalidation: RevalidationState;\n error: any;\n component: React.ReactNode;\n routeContext: RouteContextObject;\n}>;\n\ntype RenderErrorBoundaryState = {\n location: Location;\n revalidation: RevalidationState;\n error: any;\n};\n\nexport class RenderErrorBoundary extends React.Component<\n RenderErrorBoundaryProps,\n RenderErrorBoundaryState\n> {\n constructor(props: RenderErrorBoundaryProps) {\n super(props);\n this.state = {\n location: props.location,\n revalidation: props.revalidation,\n error: props.error,\n };\n }\n\n static getDerivedStateFromError(error: any) {\n return { error: error };\n }\n\n static getDerivedStateFromProps(\n props: RenderErrorBoundaryProps,\n state: RenderErrorBoundaryState\n ) {\n // When we get into an error state, the user will likely click \"back\" to the\n // previous page that didn't have an error. Because this wraps the entire\n // application, that will have no effect--the error page continues to display.\n // This gives us a mechanism to recover from the error when the location changes.\n //\n // Whether we're in an error state or not, we update the location in state\n // so that when we are in an error state, it gets reset when a new location\n // comes in and the user recovers from the error.\n if (\n state.location !== props.location ||\n (state.revalidation !== \"idle\" && props.revalidation === \"idle\")\n ) {\n return {\n error: props.error,\n location: props.location,\n revalidation: props.revalidation,\n };\n }\n\n // If we're not changing locations, preserve the location but still surface\n // any new errors that may come through. We retain the existing error, we do\n // this because the error provided from the app state may be cleared without\n // the location changing.\n return {\n error: props.error || state.error,\n location: state.location,\n revalidation: props.revalidation || state.revalidation,\n };\n }\n\n componentDidCatch(error: any, errorInfo: any) {\n console.error(\n \"React Router caught the following error during render\",\n error,\n errorInfo\n );\n }\n\n render() {\n return this.state.error ? (\n \n \n \n ) : (\n this.props.children\n );\n }\n}\n\ninterface RenderedRouteProps {\n routeContext: RouteContextObject;\n match: RouteMatch;\n children: React.ReactNode | null;\n}\n\nfunction RenderedRoute({ routeContext, match, children }: RenderedRouteProps) {\n let dataRouterContext = React.useContext(DataRouterContext);\n\n // Track how deep we got in our render pass to emulate SSR componentDidCatch\n // in a DataStaticRouter\n if (\n dataRouterContext &&\n dataRouterContext.static &&\n dataRouterContext.staticContext &&\n (match.route.errorElement || match.route.ErrorBoundary)\n ) {\n dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;\n }\n\n return (\n \n {children}\n \n );\n}\n\nexport function _renderMatches(\n matches: RouteMatch[] | null,\n parentMatches: RouteMatch[] = [],\n dataRouterState: RemixRouter[\"state\"] | null = null\n): React.ReactElement | null {\n if (matches == null) {\n if (dataRouterState?.errors) {\n // Don't bail if we have data router errors so we can render them in the\n // boundary. Use the pre-matched (or shimmed) matches\n matches = dataRouterState.matches as DataRouteMatch[];\n } else {\n return null;\n }\n }\n\n let renderedMatches = matches;\n\n // If we have data errors, trim matches to the highest error boundary\n let errors = dataRouterState?.errors;\n if (errors != null) {\n let errorIndex = renderedMatches.findIndex(\n (m) => m.route.id && errors?.[m.route.id]\n );\n invariant(\n errorIndex >= 0,\n `Could not find a matching route for errors on route IDs: ${Object.keys(\n errors\n ).join(\",\")}`\n );\n renderedMatches = renderedMatches.slice(\n 0,\n Math.min(renderedMatches.length, errorIndex + 1)\n );\n }\n\n return renderedMatches.reduceRight((outlet, match, index) => {\n let error = match.route.id ? errors?.[match.route.id] : null;\n // Only data routers handle errors\n let errorElement: React.ReactNode | null = null;\n if (dataRouterState) {\n errorElement = match.route.errorElement || defaultErrorElement;\n }\n let matches = parentMatches.concat(renderedMatches.slice(0, index + 1));\n let getChildren = () => {\n let children: React.ReactNode;\n if (error) {\n children = errorElement;\n } else if (match.route.Component) {\n // Note: This is a de-optimized path since React won't re-use the\n // ReactElement since it's identity changes with each new\n // React.createElement call. We keep this so folks can use\n // `` in `` but generally `Component`\n // usage is only advised in `RouterProvider` when we can convert it to\n // `element` ahead of time.\n children = ;\n } else if (match.route.element) {\n children = match.route.element;\n } else {\n children = outlet;\n }\n return (\n \n );\n };\n // Only wrap in an error boundary within data router usages when we have an\n // ErrorBoundary/errorElement on this route. Otherwise let it bubble up to\n // an ancestor ErrorBoundary/errorElement\n return dataRouterState &&\n (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? (\n \n ) : (\n getChildren()\n );\n }, null as React.ReactElement | null);\n}\n\nenum DataRouterHook {\n UseBlocker = \"useBlocker\",\n UseRevalidator = \"useRevalidator\",\n UseNavigateStable = \"useNavigate\",\n}\n\nenum DataRouterStateHook {\n UseBlocker = \"useBlocker\",\n UseLoaderData = \"useLoaderData\",\n UseActionData = \"useActionData\",\n UseRouteError = \"useRouteError\",\n UseNavigation = \"useNavigation\",\n UseRouteLoaderData = \"useRouteLoaderData\",\n UseMatches = \"useMatches\",\n UseRevalidator = \"useRevalidator\",\n UseNavigateStable = \"useNavigate\",\n UseRouteId = \"useRouteId\",\n}\n\nfunction getDataRouterConsoleError(\n hookName: DataRouterHook | DataRouterStateHook\n) {\n return `${hookName} must be used within a data router. See https://reactrouter.com/routers/picking-a-router.`;\n}\n\nfunction useDataRouterContext(hookName: DataRouterHook) {\n let ctx = React.useContext(DataRouterContext);\n invariant(ctx, getDataRouterConsoleError(hookName));\n return ctx;\n}\n\nfunction useDataRouterState(hookName: DataRouterStateHook) {\n let state = React.useContext(DataRouterStateContext);\n invariant(state, getDataRouterConsoleError(hookName));\n return state;\n}\n\nfunction useRouteContext(hookName: DataRouterStateHook) {\n let route = React.useContext(RouteContext);\n invariant(route, getDataRouterConsoleError(hookName));\n return route;\n}\n\n// Internal version with hookName-aware debugging\nfunction useCurrentRouteId(hookName: DataRouterStateHook) {\n let route = useRouteContext(hookName);\n let thisRoute = route.matches[route.matches.length - 1];\n invariant(\n thisRoute.route.id,\n `${hookName} can only be used on routes that contain a unique \"id\"`\n );\n return thisRoute.route.id;\n}\n\n/**\n * Returns the ID for the nearest contextual route\n */\nexport function useRouteId() {\n return useCurrentRouteId(DataRouterStateHook.UseRouteId);\n}\n\n/**\n * Returns the current navigation, defaulting to an \"idle\" navigation when\n * no navigation is in progress\n */\nexport function useNavigation() {\n let state = useDataRouterState(DataRouterStateHook.UseNavigation);\n return state.navigation;\n}\n\n/**\n * Returns a revalidate function for manually triggering revalidation, as well\n * as the current state of any manual revalidations\n */\nexport function useRevalidator() {\n let dataRouterContext = useDataRouterContext(DataRouterHook.UseRevalidator);\n let state = useDataRouterState(DataRouterStateHook.UseRevalidator);\n return React.useMemo(\n () => ({\n revalidate: dataRouterContext.router.revalidate,\n state: state.revalidation,\n }),\n [dataRouterContext.router.revalidate, state.revalidation]\n );\n}\n\n/**\n * Returns the active route matches, useful for accessing loaderData for\n * parent/child routes or the route \"handle\" property\n */\nexport function useMatches() {\n let { matches, loaderData } = useDataRouterState(\n DataRouterStateHook.UseMatches\n );\n return React.useMemo(\n () =>\n matches.map((match) => {\n let { pathname, params } = match;\n // Note: This structure matches that created by createUseMatchesMatch\n // in the @remix-run/router , so if you change this please also change\n // that :) Eventually we'll DRY this up\n return {\n id: match.route.id,\n pathname,\n params,\n data: loaderData[match.route.id] as unknown,\n handle: match.route.handle as unknown,\n };\n }),\n [matches, loaderData]\n );\n}\n\n/**\n * Returns the loader data for the nearest ancestor Route loader\n */\nexport function useLoaderData(): unknown {\n let state = useDataRouterState(DataRouterStateHook.UseLoaderData);\n let routeId = useCurrentRouteId(DataRouterStateHook.UseLoaderData);\n\n if (state.errors && state.errors[routeId] != null) {\n console.error(\n `You cannot \\`useLoaderData\\` in an errorElement (routeId: ${routeId})`\n );\n return undefined;\n }\n return state.loaderData[routeId];\n}\n\n/**\n * Returns the loaderData for the given routeId\n */\nexport function useRouteLoaderData(routeId: string): unknown {\n let state = useDataRouterState(DataRouterStateHook.UseRouteLoaderData);\n return state.loaderData[routeId];\n}\n\n/**\n * Returns the action data for the nearest ancestor Route action\n */\nexport function useActionData(): unknown {\n let state = useDataRouterState(DataRouterStateHook.UseActionData);\n\n let route = React.useContext(RouteContext);\n invariant(route, `useActionData must be used inside a RouteContext`);\n\n return Object.values(state?.actionData || {})[0];\n}\n\n/**\n * Returns the nearest ancestor Route error, which could be a loader/action\n * error or a render error. This is intended to be called from your\n * ErrorBoundary/errorElement to display a proper error message.\n */\nexport function useRouteError(): unknown {\n let error = React.useContext(RouteErrorContext);\n let state = useDataRouterState(DataRouterStateHook.UseRouteError);\n let routeId = useCurrentRouteId(DataRouterStateHook.UseRouteError);\n\n // If this was a render error, we put it in a RouteError context inside\n // of RenderErrorBoundary\n if (error) {\n return error;\n }\n\n // Otherwise look for errors from our data router state\n return state.errors?.[routeId];\n}\n\n/**\n * Returns the happy-path data from the nearest ancestor value\n */\nexport function useAsyncValue(): unknown {\n let value = React.useContext(AwaitContext);\n return value?._data;\n}\n\n/**\n * Returns the error from the nearest ancestor value\n */\nexport function useAsyncError(): unknown {\n let value = React.useContext(AwaitContext);\n return value?._error;\n}\n\nlet blockerId = 0;\n\n/**\n * Allow the application to block navigations within the SPA and present the\n * user a confirmation dialog to confirm the navigation. Mostly used to avoid\n * using half-filled form data. This does not handle hard-reloads or\n * cross-origin navigations.\n */\nexport function useBlocker(shouldBlock: boolean | BlockerFunction): Blocker {\n let { router, basename } = useDataRouterContext(DataRouterHook.UseBlocker);\n let state = useDataRouterState(DataRouterStateHook.UseBlocker);\n\n let [blockerKey, setBlockerKey] = React.useState(\"\");\n let blockerFunction = React.useCallback(\n (arg) => {\n if (typeof shouldBlock !== \"function\") {\n return !!shouldBlock;\n }\n if (basename === \"/\") {\n return shouldBlock(arg);\n }\n\n // If they provided us a function and we've got an active basename, strip\n // it from the locations we expose to the user to match the behavior of\n // useLocation\n let { currentLocation, nextLocation, historyAction } = arg;\n return shouldBlock({\n currentLocation: {\n ...currentLocation,\n pathname:\n stripBasename(currentLocation.pathname, basename) ||\n currentLocation.pathname,\n },\n nextLocation: {\n ...nextLocation,\n pathname:\n stripBasename(nextLocation.pathname, basename) ||\n nextLocation.pathname,\n },\n historyAction,\n });\n },\n [basename, shouldBlock]\n );\n\n // This effect is in charge of blocker key assignment and deletion (which is\n // tightly coupled to the key)\n React.useEffect(() => {\n let key = String(++blockerId);\n setBlockerKey(key);\n return () => router.deleteBlocker(key);\n }, [router]);\n\n // This effect handles assigning the blockerFunction. This is to handle\n // unstable blocker function identities, and happens only after the prior\n // effect so we don't get an orphaned blockerFunction in the router with a\n // key of \"\". Until then we just have the IDLE_BLOCKER.\n React.useEffect(() => {\n if (blockerKey !== \"\") {\n router.getBlocker(blockerKey, blockerFunction);\n }\n }, [router, blockerKey, blockerFunction]);\n\n // Prefer the blocker from `state` not `router.state` since DataRouterContext\n // is memoized so this ensures we update on blocker state updates\n return blockerKey && state.blockers.has(blockerKey)\n ? state.blockers.get(blockerKey)!\n : IDLE_BLOCKER;\n}\n\n/**\n * Stable version of useNavigate that is used when we are in the context of\n * a RouterProvider.\n */\nfunction useNavigateStable(): NavigateFunction {\n let { router } = useDataRouterContext(DataRouterHook.UseNavigateStable);\n let id = useCurrentRouteId(DataRouterStateHook.UseNavigateStable);\n\n let activeRef = React.useRef(false);\n useIsomorphicLayoutEffect(() => {\n activeRef.current = true;\n });\n\n let navigate: NavigateFunction = React.useCallback(\n (to: To | number, options: NavigateOptions = {}) => {\n warning(activeRef.current, navigateEffectWarning);\n\n // Short circuit here since if this happens on first render the navigate\n // is useless because we haven't wired up our router subscriber yet\n if (!activeRef.current) return;\n\n if (typeof to === \"number\") {\n router.navigate(to);\n } else {\n router.navigate(to, { fromRouteId: id, ...options });\n }\n },\n [router, id]\n );\n\n return navigate;\n}\n\nconst alreadyWarned: Record = {};\n\nfunction warningOnce(key: string, cond: boolean, message: string) {\n if (!cond && !alreadyWarned[key]) {\n alreadyWarned[key] = true;\n warning(false, message);\n }\n}\n","import * as React from \"react\";\nimport type {\n TrackedPromise,\n InitialEntry,\n Location,\n MemoryHistory,\n Router as RemixRouter,\n To,\n LazyRouteFunction,\n RelativeRoutingType,\n RouterState,\n} from \"@remix-run/router\";\nimport {\n Action as NavigationType,\n AbortedDeferredError,\n createMemoryHistory,\n UNSAFE_invariant as invariant,\n parsePath,\n resolveTo,\n stripBasename,\n UNSAFE_warning as warning,\n UNSAFE_getPathContributingMatches as getPathContributingMatches,\n} from \"@remix-run/router\";\n\nimport type {\n DataRouteObject,\n IndexRouteObject,\n RouteMatch,\n RouteObject,\n Navigator,\n NonIndexRouteObject,\n} from \"./context\";\nimport {\n LocationContext,\n NavigationContext,\n DataRouterContext,\n DataRouterStateContext,\n AwaitContext,\n RouteContext,\n} from \"./context\";\nimport {\n useAsyncValue,\n useInRouterContext,\n useNavigate,\n useOutlet,\n useRoutes,\n _renderMatches,\n useRoutesImpl,\n useLocation,\n} from \"./hooks\";\n\nexport interface FutureConfig {\n v7_startTransition: boolean;\n}\n\nexport interface RouterProviderProps {\n fallbackElement?: React.ReactNode;\n router: RemixRouter;\n future?: FutureConfig;\n}\n\n/**\n Webpack + React 17 fails to compile on any of the following because webpack\n complains that `startTransition` doesn't exist in `React`:\n * import { startTransition } from \"react\"\n * import * as React from from \"react\";\n \"startTransition\" in React ? React.startTransition(() => setState()) : setState()\n * import * as React from from \"react\";\n \"startTransition\" in React ? React[\"startTransition\"](() => setState()) : setState()\n\n Moving it to a constant such as the following solves the Webpack/React 17 issue:\n * import * as React from from \"react\";\n const START_TRANSITION = \"startTransition\";\n START_TRANSITION in React ? React[START_TRANSITION](() => setState()) : setState()\n\n However, that introduces webpack/terser minification issues in production builds\n in React 18 where minification/obfuscation ends up removing the call of\n React.startTransition entirely from the first half of the ternary. Grabbing\n this exported reference once up front resolves that issue.\n\n See https://github.com/remix-run/react-router/issues/10579\n*/\nconst START_TRANSITION = \"startTransition\";\nconst startTransitionImpl = React[START_TRANSITION];\n\n/**\n * Given a Remix Router instance, render the appropriate UI\n */\nexport function RouterProvider({\n fallbackElement,\n router,\n future,\n}: RouterProviderProps): React.ReactElement {\n // Need to use a layout effect here so we are subscribed early enough to\n // pick up on any render-driven redirects/navigations (useEffect/)\n let [state, setStateImpl] = React.useState(router.state);\n let { v7_startTransition } = future || {};\n let setState = React.useCallback(\n (newState: RouterState) => {\n v7_startTransition && startTransitionImpl\n ? startTransitionImpl(() => setStateImpl(newState))\n : setStateImpl(newState);\n },\n [setStateImpl, v7_startTransition]\n );\n React.useLayoutEffect(() => router.subscribe(setState), [router, setState]);\n\n let navigator = React.useMemo((): Navigator => {\n return {\n createHref: router.createHref,\n encodeLocation: router.encodeLocation,\n go: (n) => router.navigate(n),\n push: (to, state, opts) =>\n router.navigate(to, {\n state,\n preventScrollReset: opts?.preventScrollReset,\n }),\n replace: (to, state, opts) =>\n router.navigate(to, {\n replace: true,\n state,\n preventScrollReset: opts?.preventScrollReset,\n }),\n };\n }, [router]);\n\n let basename = router.basename || \"/\";\n\n let dataRouterContext = React.useMemo(\n () => ({\n router,\n navigator,\n static: false,\n basename,\n }),\n [router, navigator, basename]\n );\n\n // The fragment and {null} here are important! We need them to keep React 18's\n // useId happy when we are server-rendering since we may have a