From c037b43f4a66d9059aeb8adcb4d0e640f374ef06 Mon Sep 17 00:00:00 2001 From: jmj Date: Mon, 30 Nov 2026 07:37:34 +0800 Subject: [PATCH] Initial commit: PulseWall hub, Android app, and protocol docs - hub: FastAPI backend (MCP server, ADB LAN controller, bridge, storage) - hub/web: Vue 3 admin console (device manager, screen mirror, chat workbench) - android: Kotlin shell app with WebView stage, OTA, telemetry, keep-alive - protocol: architecture, MCP schema, and WebSocket protocol specs --- .gitignore | 28 + README.md | 37 + ai-speaker-cert.pem | 20 + android/app/build.gradle.kts | 60 + android/app/src/main/AndroidManifest.xml | 61 + .../app/src/main/assets/pulsewall/host.html | 502 +++ .../main/assets/pulsewall/libs/anime.min.js | 8 + .../main/assets/pulsewall/libs/dayjs.min.js | 1 + .../pulsewall/libs/echarts.custom.min.js | 48 + .../assets/pulsewall/libs/hls.light.min.js | 2 + .../main/assets/pulsewall/libs/konva.min.js | 12 + .../assets/pulsewall/libs/lodash-lite.min.js | 14 + .../main/assets/pulsewall/libs/manifest.json | 128 + .../src/main/assets/pulsewall/libs/plyr.css | 1 + .../main/assets/pulsewall/libs/plyr.min.js | 2 + .../assets/pulsewall/libs/pw-icons.min.js | 32 + .../main/assets/pulsewall/libs/rough.min.js | 1 + .../pulsewall/libs/tailwind-lite.min.css | 31 + .../main/assets/pulsewall/libs/three.min.js | 3833 +++++++++++++++++ .../main/assets/pulsewall/libs/zustand.min.js | 1 + .../assets/pulsewall/pulsewall-tokens.css | 156 + .../main/assets/pulsewall/pw-lib-loader.js | 78 + .../assets/pulsewall/pw-stage-bootstrap.js | 366 ++ .../src/main/assets/pulsewall/sandbox.html | 164 + .../main/assets/pulsewall/vue.global.prod.js | 9 + .../java/com/pulsewall/app/MainActivity.kt | 965 +++++ .../app/alert/NativeAlertController.kt | 416 ++ .../java/com/pulsewall/app/config/AppPrefs.kt | 107 + .../app/network/HubDiscoveryClient.kt | 87 + .../app/network/HubWebSocketClient.kt | 148 + .../com/pulsewall/app/ota/AppUpdateManager.kt | 253 ++ .../app/sentinel/OpenAiRepairSentinel.kt | 136 + .../com/pulsewall/app/service/BootReceiver.kt | 23 + .../app/service/PulseWallKeepAliveService.kt | 28 + .../app/telemetry/DeviceTelemetryCollector.kt | 398 ++ android/app/src/main/res/values/styles.xml | 10 + android/app/src/main/res/xml/file_paths.xml | 4 + android/build.gradle.kts | 4 + android/build_apk.sh | 45 + android/gradle.properties | 4 + android/keystore/pulsewall-dev.jks | Bin 0 -> 2734 bytes android/settings.gradle.kts | 18 + android/vendor-builder/build_vendors.mjs | 281 ++ android/vendor-builder/package-lock.json | 620 +++ android/vendor-builder/package.json | 19 + hub/app/__init__.py | 1 + hub/app/adb_lan/controller.py | 1057 +++++ hub/app/adb_lan/fmp4_muxer.py | 330 ++ hub/app/admin/chat_agent.py | 327 ++ hub/app/admin/ui.py | 649 +++ hub/app/bridge/discovery.py | 66 + hub/app/bridge/manager.py | 277 ++ hub/app/main.py | 656 +++ hub/app/mcp/server.py | 276 ++ hub/app/models.py | 113 + hub/app/runner.py | 64 + hub/app/storage/db.py | 987 +++++ hub/pyproject.toml | 32 + hub/run_hub.sh | 9 + hub/tests/test_hub.py | 601 +++ hub/web/index.html | 12 + hub/web/package-lock.json | 1288 ++++++ hub/web/package.json | 20 + hub/web/src/App.vue | 243 ++ hub/web/src/api.js | 93 + hub/web/src/components/ChatWorkbench.vue | 759 ++++ hub/web/src/components/DeviceManager.vue | 611 +++ .../src/components/DeviceMetricsCharts.vue | 440 ++ hub/web/src/components/DeviceScreenMirror.vue | 825 ++++ hub/web/src/components/GlobalSettings.vue | 235 + hub/web/src/components/PromptManager.vue | 334 ++ hub/web/src/main.js | 5 + hub/web/src/styles/theme.css | 276 ++ hub/web/vite.config.js | 24 + protocol/architecture.md | 54 + protocol/mcp-schema.md | 75 + protocol/ws-protocol.md | 198 + 77 files changed, 20098 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 ai-speaker-cert.pem create mode 100644 android/app/build.gradle.kts create mode 100644 android/app/src/main/AndroidManifest.xml create mode 100644 android/app/src/main/assets/pulsewall/host.html create mode 100644 android/app/src/main/assets/pulsewall/libs/anime.min.js create mode 100644 android/app/src/main/assets/pulsewall/libs/dayjs.min.js create mode 100644 android/app/src/main/assets/pulsewall/libs/echarts.custom.min.js create mode 100644 android/app/src/main/assets/pulsewall/libs/hls.light.min.js create mode 100644 android/app/src/main/assets/pulsewall/libs/konva.min.js create mode 100644 android/app/src/main/assets/pulsewall/libs/lodash-lite.min.js create mode 100644 android/app/src/main/assets/pulsewall/libs/manifest.json create mode 100644 android/app/src/main/assets/pulsewall/libs/plyr.css create mode 100644 android/app/src/main/assets/pulsewall/libs/plyr.min.js create mode 100644 android/app/src/main/assets/pulsewall/libs/pw-icons.min.js create mode 100644 android/app/src/main/assets/pulsewall/libs/rough.min.js create mode 100644 android/app/src/main/assets/pulsewall/libs/tailwind-lite.min.css create mode 100644 android/app/src/main/assets/pulsewall/libs/three.min.js create mode 100644 android/app/src/main/assets/pulsewall/libs/zustand.min.js create mode 100644 android/app/src/main/assets/pulsewall/pulsewall-tokens.css create mode 100644 android/app/src/main/assets/pulsewall/pw-lib-loader.js create mode 100644 android/app/src/main/assets/pulsewall/pw-stage-bootstrap.js create mode 100644 android/app/src/main/assets/pulsewall/sandbox.html create mode 100644 android/app/src/main/assets/pulsewall/vue.global.prod.js create mode 100644 android/app/src/main/java/com/pulsewall/app/MainActivity.kt create mode 100644 android/app/src/main/java/com/pulsewall/app/alert/NativeAlertController.kt create mode 100644 android/app/src/main/java/com/pulsewall/app/config/AppPrefs.kt create mode 100644 android/app/src/main/java/com/pulsewall/app/network/HubDiscoveryClient.kt create mode 100644 android/app/src/main/java/com/pulsewall/app/network/HubWebSocketClient.kt create mode 100644 android/app/src/main/java/com/pulsewall/app/ota/AppUpdateManager.kt create mode 100644 android/app/src/main/java/com/pulsewall/app/sentinel/OpenAiRepairSentinel.kt create mode 100644 android/app/src/main/java/com/pulsewall/app/service/BootReceiver.kt create mode 100644 android/app/src/main/java/com/pulsewall/app/service/PulseWallKeepAliveService.kt create mode 100644 android/app/src/main/java/com/pulsewall/app/telemetry/DeviceTelemetryCollector.kt create mode 100644 android/app/src/main/res/values/styles.xml create mode 100644 android/app/src/main/res/xml/file_paths.xml create mode 100644 android/build.gradle.kts create mode 100755 android/build_apk.sh create mode 100644 android/gradle.properties create mode 100644 android/keystore/pulsewall-dev.jks create mode 100644 android/settings.gradle.kts create mode 100644 android/vendor-builder/build_vendors.mjs create mode 100644 android/vendor-builder/package-lock.json create mode 100644 android/vendor-builder/package.json create mode 100644 hub/app/__init__.py create mode 100644 hub/app/adb_lan/controller.py create mode 100644 hub/app/adb_lan/fmp4_muxer.py create mode 100644 hub/app/admin/chat_agent.py create mode 100644 hub/app/admin/ui.py create mode 100644 hub/app/bridge/discovery.py create mode 100644 hub/app/bridge/manager.py create mode 100644 hub/app/main.py create mode 100644 hub/app/mcp/server.py create mode 100644 hub/app/models.py create mode 100644 hub/app/runner.py create mode 100644 hub/app/storage/db.py create mode 100644 hub/pyproject.toml create mode 100755 hub/run_hub.sh create mode 100644 hub/tests/test_hub.py create mode 100644 hub/web/index.html create mode 100644 hub/web/package-lock.json create mode 100644 hub/web/package.json create mode 100644 hub/web/src/App.vue create mode 100644 hub/web/src/api.js create mode 100644 hub/web/src/components/ChatWorkbench.vue create mode 100644 hub/web/src/components/DeviceManager.vue create mode 100644 hub/web/src/components/DeviceMetricsCharts.vue create mode 100644 hub/web/src/components/DeviceScreenMirror.vue create mode 100644 hub/web/src/components/GlobalSettings.vue create mode 100644 hub/web/src/components/PromptManager.vue create mode 100644 hub/web/src/main.js create mode 100644 hub/web/src/styles/theme.css create mode 100644 hub/web/vite.config.js create mode 100644 protocol/architecture.md create mode 100644 protocol/mcp-schema.md create mode 100644 protocol/ws-protocol.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6aa09d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +# Local headless Android toolchain & caches +.toolchain/ +.gradle/ + +# Python +__pycache__/ +*.py[cod] +.venv/ +*.db +*.sqlite3 +.env + +# Android / Gradle +android/.gradle/ +android/local.properties +android/build/ +android/app/build/ +android/.idea/ +*.iml +hub/releases/*.apk +hub/releases/latest.json +hub/web/node_modules/ +hub/app/admin/dist/ +android/vendor-builder/node_modules/ + +# OS / Editors +.DS_Store +*.swp diff --git a/README.md b/README.md new file mode 100644 index 0000000..09e68d3 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# PulseWall + +AI-driven Android 11 live information wall, real-time device status monitor, and bidirectional MCP interactive terminal. + +## Repository Layout + +- `protocol/` — Canonical architecture, MCP schema, and WebSocket protocol specs: + - `protocol/architecture.md` + - `protocol/mcp-schema.md` + - `protocol/ws-protocol.md` +- `hub/` — Python Central Bridge (`FastAPI` + official `MCP` Streamable HTTP + `WebSocket` device gateway + `SQLite` + Web Admin Panel + LAN-only ADB Debug controller) +- `android/` — Android 11 (`minSdk = 30`) native Kotlin client with layered `basic`/`root` telemetry, offline Vue 3 + PulseWall CSS framework, offscreen pre-render validation sandbox, runtime console watchdog, OpenAI-compatible on-device Repair Sentinel, and unbreakable native alert/alarm layer. + +## Quick Start + +### 1. Start the Python Hub +```bash +cd /data/working/PulseWall/hub +./run_hub.sh +``` +- **Web Admin Panel**: `http://:8765/admin` +- **Generic MCP Endpoint (Streamable HTTP)**: `http://:8765/mcp/` +- **Upstream Plugin Event Stream (SSE)**: `http://:8765/api/events/stream` +- **Android WebSocket Gateway**: `ws://:8765/ws/device/{device_id}` +- **LAN-Only Developer Debug / ADB API**: `POST http://:8765/api/lan-debug/{device_id}/action` + +### 2. Build the Android 11 APK +```bash +/data/working/PulseWall/android/build_apk.sh +``` +Output APK: +`android/app/build/outputs/apk/debug/app-debug.apk` + +### 3. First-Time Pairing +1. Install `app-debug.apk` onto your Android 11 device. +2. Tap the top-right floating status pill (`⚙`) to set your Hub WebSocket URL (`ws://:8765`) and device name. +3. Open `http://:8765/admin` to verify live device telemetry & DisplayProfile, configure your OpenAI-compatible end-side Repair AI model (pushed live to the device), and test feed/alarm/dynamic canvas rendering. diff --git a/ai-speaker-cert.pem b/ai-speaker-cert.pem new file mode 100644 index 0000000..baa11d2 --- /dev/null +++ b/ai-speaker-cert.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDPTCCAiWgAwIBAgIUVnWe0FCUWnM1H7/i/rts/H4h0b0wDQYJKoZIhvcNAQEL +BQAwFTETMBEGA1UEAwwKYWktc3BlYWtlcjAeFw0yNjExMjkxNDQ2NDdaFw0zNjEx +MjYxNDQ2NDdaMBUxEzARBgNVBAMMCmFpLXNwZWFrZXIwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQDB7s/3sZ9KLSF8jJCGwDm+IPZq2/x+FUdxqXyffEbK +n/1SVYNL2zKCM0BDXSBOrk9WQtBT+3ROijQ6BsG4eNtx2kMNSxscGQFwEBDxisAv +J+g1c3Euyij9DHdFrGaCxtGJbmxcT9N37r4VEnlEUZvKE5AcfS3ANuDn/3/WY/Vb +I/r61V0cpj2xQr3/ChRKw3w8M7tQrTvJArhbC1Mb3yBa57WMxdglcqeLrqLeSxpk +YHSX8Wrf4ZsBxU5d/UPv8TD5pyui9+kzzaUQxGVuByWdTc5/MspuDI1cGk3Qbeul +p3lxwFLQwvWsU7lsn2siWrypT4Q6GbbOlMlMzxyQY45HAgMBAAGjgYQwgYEwHQYD +VR0OBBYEFC0y9aSS6hLZCKZWr2AtpX+I1ZY2MB8GA1UdIwQYMBaAFC0y9aSS6hLZ +CKZWr2AtpX+I1ZY2MA8GA1UdEwEB/wQFMAMBAf8wLgYDVR0RBCcwJYcEwKgBb4cE +CioAAYcEfwAAAYIGZ2VtaW5pgglsb2NhbGhvc3QwDQYJKoZIhvcNAQELBQADggEB +AJ8Xk0fiaq0O8no0JCNEzZl5izEpy4SnWhuaEa009lxKe4924y0ORhPAeCC6ybmf +ZJLOhFgPoXxSsQwZ1wb/N8FCWboYtW1XFbtW+OsxDT7rGdmDOAAXgjmG4i3wMWLt +59LPGoEj2gOOvmNIkkga8txC5EM/OK/inURypXRSK0b2vNcCiqG4w9SSb99gDM7P +poHZHP3p2T1peqKWwuAe52bV+6Vo3Y1YO3udMyhCxcpsxbA+G2bLA8uNlvTOqcLO +SuiCsRptEYSCpd91WngXZThVL4Yly40D1DxoMRsEV/UiiYQO/A7IinbyyX7FGUCh +ZR2KSyVwb5Tjuqj5Ps/NarQ= +-----END CERTIFICATE----- diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts new file mode 100644 index 0000000..25a6aae --- /dev/null +++ b/android/app/build.gradle.kts @@ -0,0 +1,60 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +val pwVersionCode = (project.findProperty("pwVersionCode") as String?)?.toIntOrNull() ?: 1 +val pwVersionName = (project.findProperty("pwVersionName") as String?) ?: "0.1.0" + +android { + namespace = "com.pulsewall.app" + compileSdk = 34 + + defaultConfig { + applicationId = "com.pulsewall.app" + minSdk = 30 + targetSdk = 30 + versionCode = pwVersionCode + versionName = pwVersionName + } + + buildFeatures { + buildConfig = true + } + + signingConfigs { + create("pulsewallFixed") { + storeFile = file("../keystore/pulsewall-dev.jks") + storePassword = "pulsewall123" + keyAlias = "pulsewall" + keyPassword = "pulsewall123" + } + } + + buildTypes { + debug { + signingConfig = signingConfigs.getByName("pulsewallFixed") + } + release { + isMinifyEnabled = false + signingConfig = signingConfigs.getByName("pulsewallFixed") + } + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + kotlinOptions { + jvmTarget = "17" + } +} + +dependencies { + implementation("androidx.core:core-ktx:1.13.1") + implementation("androidx.appcompat:appcompat:1.7.0") + implementation("androidx.webkit:webkit:1.11.0") + implementation("com.squareup.okhttp3:okhttp:4.12.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1") +} diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..87428fd --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/assets/pulsewall/host.html b/android/app/src/main/assets/pulsewall/host.html new file mode 100644 index 0000000..14c8cf4 --- /dev/null +++ b/android/app/src/main/assets/pulsewall/host.html @@ -0,0 +1,502 @@ + + + + + + PulseWall Host + + + + + + + + + + +
+
+
+
+
+
+ 等待连接中心桥... + --:--:-- +
+

PulseWall 信息墙

+
正在尝试连接中心桥...
+
+ + + +
+
+ +
+ 🎮 遥控器操作指南:上下左右 移动焦点/滚屏 · OK/确定 点击选中项 · 菜单键(MENU) 随时打开设置 +
+ +
+
+
屏幕规格
+
--
+
+
+
电量 / 温度
+
--
+
+
+ +
+
+ 实时信息流 + 0 条 +
+
+
暂无动态,等待 AI 通过 MCP 推送...
+
+
+
+
+
+
+ + +
+ + + + diff --git a/android/app/src/main/assets/pulsewall/libs/anime.min.js b/android/app/src/main/assets/pulsewall/libs/anime.min.js new file mode 100644 index 0000000..ed9da8a --- /dev/null +++ b/android/app/src/main/assets/pulsewall/libs/anime.min.js @@ -0,0 +1,8 @@ +/* + * anime.js v3.2.2 + * (c) 2023 Julian Garnier + * Released under the MIT license + * animejs.com + */ + +!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):n.anime=e()}(this,function(){"use strict";var i={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0},M={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},j=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],l={CSS:{},springs:{}};function C(n,e,t){return Math.min(Math.max(n,e),t)}function u(n,e){return-1=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()1)return t(u[0])}else{var a=e.name;D[a]=e,i=a}return!r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return b},m.isValid=function(){return!(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t){var Oh=Object.defineProperty;var QT=Object.getOwnPropertyDescriptor;var JT=Object.getOwnPropertyNames;var $T=Object.prototype.hasOwnProperty;var Ae=(r,t)=>{for(var e in t)Oh(r,e,{get:t[e],enumerable:!0})},tC=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of JT(t))!$T.call(r,a)&&a!==e&&Oh(r,a,{get:()=>t[a],enumerable:!(i=QT(t,a))||i.enumerable});return r};var eC=r=>tC(Oh({},"__esModule",{value:!0}),r);var tN={};Ae(tN,{default:()=>$2,dispose:()=>J2,getInstanceByDom:()=>Q2,graphic:()=>K2,init:()=>X2,registerTheme:()=>j2,use:()=>q2});var Dd={};Ae(Dd,{Axis:()=>_o,ChartView:()=>Pt,ComponentModel:()=>ct,ComponentView:()=>At,List:()=>hr,Model:()=>wt,PRIORITY:()=>Vv,SeriesModel:()=>kt,color:()=>ql,connect:()=>aP,dataTool:()=>fP,dependencies:()=>FL,disConnect:()=>nP,disconnect:()=>US,dispose:()=>Wv,env:()=>tt,extendChartView:()=>DI,extendComponentModel:()=>wI,extendComponentView:()=>TI,extendSeriesModel:()=>CI,format:()=>wd,getCoordinateSystemDimensions:()=>sP,getInstanceByDom:()=>qs,getInstanceById:()=>oP,getMap:()=>uP,graphic:()=>sl,helper:()=>dd,init:()=>Hv,innerDrawElementOnCanvas:()=>ho,matrix:()=>jr,number:()=>Sd,parseGeoJSON:()=>Xf,parseGeoJson:()=>Xf,registerAction:()=>Fr,registerCoordinateSystem:()=>Xv,registerLayout:()=>qv,registerLoading:()=>Rf,registerLocale:()=>Bu,registerMap:()=>jv,registerPostInit:()=>Yv,registerPostUpdate:()=>Zv,registerPreprocessor:()=>Pf,registerProcessor:()=>If,registerTheme:()=>Ks,registerTransform:()=>Qv,registerUpdateLifecycle:()=>js,registerVisual:()=>vi,setCanvasCreator:()=>lP,setPlatformAPI:()=>Dl,throttle:()=>Ja,time:()=>bd,use:()=>zt,util:()=>Td,vector:()=>Be,version:()=>VL,zrUtil:()=>$,zrender:()=>nu});var Nh=function(r,t){return Nh=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(e[a]=i[a])},Nh(r,t)};function P(r,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Nh(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var nu={};Ae(nu,{dispose:()=>ND,disposeAll:()=>kD,getElementSSRData:()=>UD,getInstance:()=>zD,init:()=>au,registerPainter:()=>Lc,registerSSRDataGetter:()=>Pc,version:()=>BD});var rC=(function(){function r(){this.firefox=!1,this.ie=!1,this.edge=!1,this.newEdge=!1,this.weChat=!1}return r})(),iC=(function(){function r(){this.browser=new rC,this.node=!1,this.wxa=!1,this.worker=!1,this.svgSupported=!1,this.touchEventsSupported=!1,this.pointerEventsSupported=!1,this.domSupported=!1,this.transformSupported=!1,this.transform3dSupported=!1,this.hasGlobalWindow=typeof window<"u"}return r})(),gi=new iC;typeof wx=="object"&&typeof wx.getSystemInfoSync=="function"?(gi.wxa=!0,gi.touchEventsSupported=!0):typeof document>"u"&&typeof self<"u"?gi.worker=!0:!gi.hasGlobalWindow||"Deno"in window?(gi.node=!0,gi.svgSupported=!0):aC(navigator.userAgent,gi);function aC(r,t){var e=t.browser,i=r.match(/Firefox\/([\d.]+)/),a=r.match(/MSIE\s([\d.]+)/)||r.match(/Trident\/.+?rv:(([\d.]+))/),n=r.match(/Edge?\/([\d.]+)/),o=/micromessenger/i.test(r);i&&(e.firefox=!0,e.version=i[1]),a&&(e.ie=!0,e.version=a[1]),n&&(e.edge=!0,e.version=n[1],e.newEdge=+n[1].split(".")[0]>18),o&&(e.weChat=!0),t.svgSupported=typeof SVGRect<"u",t.touchEventsSupported="ontouchstart"in window&&!e.ie&&!e.edge,t.pointerEventsSupported="onpointerdown"in window&&(e.edge||e.ie&&+e.version>=11),t.domSupported=typeof document<"u";var s=document.documentElement.style;t.transform3dSupported=(e.ie&&"transition"in s||e.edge||"WebKitCSSMatrix"in window&&"m11"in new WebKitCSSMatrix||"MozPerspective"in s)&&!("OTransition"in s),t.transformSupported=t.transform3dSupported||e.ie&&+e.version>=9}var tt=gi;var $={};Ae($,{HashMap:()=>ig,RADIAN_TO_DEGREE:()=>El,assert:()=>te,bind:()=>X,clone:()=>K,concatArray:()=>Gh,createCanvas:()=>mC,createHashMap:()=>Y,createObject:()=>Zr,curry:()=>lt,defaults:()=>q,disableUserSelect:()=>No,each:()=>T,eqNaN:()=>ea,extend:()=>N,filter:()=>Tt,find:()=>Bh,guid:()=>Po,hasOwn:()=>qt,indexOf:()=>at,inherits:()=>Io,isArray:()=>k,isArrayLike:()=>Ot,isBuiltInObject:()=>kh,isDom:()=>$i,isFunction:()=>G,isGradientObject:()=>Yr,isImagePatternObject:()=>Vh,isNumber:()=>et,isObject:()=>H,isPrimitive:()=>gn,isRegExp:()=>Fh,isString:()=>B,isStringSafe:()=>_n,isTypedArray:()=>Nt,keys:()=>pt,logError:()=>ta,map:()=>U,merge:()=>it,mergeAll:()=>dC,mixin:()=>Ut,noop:()=>Bt,normalizeCssArray:()=>Oo,reduce:()=>ce,retrieve:()=>Dr,retrieve2:()=>Q,retrieve3:()=>Mr,setAsPrimitive:()=>yi,slice:()=>Ro,trim:()=>ee});var Cl=12,nC="sans-serif",dr=Cl+"px "+nC,oC=20,sC=100,lC="007LLmW'55;N0500LLLLLLLLLL00NNNLzWW\\\\WQb\\0FWLg\\bWb\\WQ\\WrWWQ000CL5LLFLL0LL**F*gLLLL5F0LF\\FFF5.5N";function uC(r){var t={};if(typeof JSON>"u")return t;for(var e=0;e=0)s=o*e.length;else for(var l=0;lLl,applyTransform:()=>Gt,clone:()=>Hh,copy:()=>xC,create:()=>Xr,dist:()=>xn,distSquare:()=>_i,distance:()=>Uo,distanceSquare:()=>ag,div:()=>DC,dot:()=>MC,len:()=>Wh,lenSquare:()=>Yh,length:()=>wC,lengthSquare:()=>TC,lerp:()=>Bo,max:()=>Qe,min:()=>je,mul:()=>CC,negate:()=>AC,normalize:()=>ra,scale:()=>zo,scaleAndAdd:()=>bC,set:()=>SC,sub:()=>ko});function Xr(r,t){return r==null&&(r=0),t==null&&(t=0),[r,t]}function xC(r,t){return r[0]=t[0],r[1]=t[1],r}function Hh(r){return[r[0],r[1]]}function SC(r,t,e){return r[0]=t,r[1]=e,r}function Ll(r,t,e){return r[0]=t[0]+e[0],r[1]=t[1]+e[1],r}function bC(r,t,e,i){return r[0]=t[0]+e[0]*i,r[1]=t[1]+e[1]*i,r}function ko(r,t,e){return r[0]=t[0]-e[0],r[1]=t[1]-e[1],r}function Wh(r){return Math.sqrt(Yh(r))}var wC=Wh;function Yh(r){return r[0]*r[0]+r[1]*r[1]}var TC=Yh;function CC(r,t,e){return r[0]=t[0]*e[0],r[1]=t[1]*e[1],r}function DC(r,t,e){return r[0]=t[0]/e[0],r[1]=t[1]/e[1],r}function MC(r,t){return r[0]*t[0]+r[1]*t[1]}function zo(r,t,e){return r[0]=t[0]*e,r[1]=t[1]*e,r}function ra(r,t){var e=Wh(t);return e===0?(r[0]=0,r[1]=0):(r[0]=t[0]/e,r[1]=t[1]/e),r}function Uo(r,t){return Math.sqrt((r[0]-t[0])*(r[0]-t[0])+(r[1]-t[1])*(r[1]-t[1]))}var xn=Uo;function ag(r,t){return(r[0]-t[0])*(r[0]-t[0])+(r[1]-t[1])*(r[1]-t[1])}var _i=ag;function AC(r,t){return r[0]=-t[0],r[1]=-t[1],r}function Bo(r,t,e,i){return r[0]=t[0]+i*(e[0]-t[0]),r[1]=t[1]+i*(e[1]-t[1]),r}function Gt(r,t,e){var i=t[0],a=t[1];return r[0]=e[0]*i+e[2]*a+e[4],r[1]=e[1]*i+e[3]*a+e[5],r}function je(r,t,e){return r[0]=Math.min(t[0],e[0]),r[1]=Math.min(t[1],e[1]),r}function Qe(r,t,e){return r[0]=Math.max(t[0],e[0]),r[1]=Math.max(t[1],e[1]),r}var Sn=(function(){function r(t,e){this.target=t,this.topTarget=e&&e.topTarget}return r})(),EC=(function(){function r(t){this.handler=t,t.on("mousedown",this._dragStart,this),t.on("mousemove",this._drag,this),t.on("mouseup",this._dragEnd,this)}return r.prototype._dragStart=function(t){for(var e=t.target;e&&!e.draggable;)e=e.parent||e.__hostTarget;e&&(this._draggingTarget=e,e.dragging=!0,this._x=t.offsetX,this._y=t.offsetY,this.handler.dispatchToElement(new Sn(e,t),"dragstart",t.event))},r.prototype._drag=function(t){var e=this._draggingTarget;if(e){var i=t.offsetX,a=t.offsetY,n=i-this._x,o=a-this._y;this._x=i,this._y=a,e.drift(n,o,t),this.handler.dispatchToElement(new Sn(e,t),"drag",t.event);var s=this.handler.findHover(i,a,e).target,l=this._dropTarget;this._dropTarget=s,e!==s&&(l&&s!==l&&this.handler.dispatchToElement(new Sn(l,t),"dragleave",t.event),s&&s!==l&&this.handler.dispatchToElement(new Sn(s,t),"dragenter",t.event))}},r.prototype._dragEnd=function(t){var e=this._draggingTarget;e&&(e.dragging=!1),this.handler.dispatchToElement(new Sn(e,t),"dragend",t.event),this._dropTarget&&this.handler.dispatchToElement(new Sn(this._dropTarget,t),"drop",t.event),this._draggingTarget=null,this._dropTarget=null},r})(),ng=EC;var LC=(function(){function r(t){t&&(this._$eventProcessor=t)}return r.prototype.on=function(t,e,i,a){this._$handlers||(this._$handlers={});var n=this._$handlers;if(typeof e=="function"&&(a=i,i=e,e=null),!i||!t)return this;var o=this._$eventProcessor;e!=null&&o&&o.normalizeQuery&&(e=o.normalizeQuery(e)),n[t]||(n[t]=[]);for(var s=0;s>1)%2;s.cssText=["position: absolute","visibility: hidden","padding: 0","margin: 0","border-width: 0","user-select: none","width:0","height:0",i[l]+":0",a[u]+":0",i[1-l]+":auto",a[1-u]+":auto",""].join("!important;"),r.appendChild(o),e.push(o)}return e}function RC(r,t,e){for(var i=e?"invTrans":"trans",a=t[i],n=t.srcCoords,o=[],s=[],l=!0,u=0;u<4;u++){var f=r[u].getBoundingClientRect(),h=2*u,p=f.left,c=f.top;o.push(p,c),l=l&&n&&p===n[h]&&c===n[h+1],s.push(r[u].offsetLeft,r[u].offsetTop)}return l&&a?a:(t.srcCoords=o,t[i]=e?Xh(s,o):Xh(o,s))}function Kh(r){return r.nodeName.toUpperCase()==="CANVAS"}var OC=/([&<>"'])/g,NC={"&":"&","<":"<",">":">",'"':""","'":"'"};function jt(r){return r==null?"":(r+"").replace(OC,function(t,e){return NC[e]})}var kC=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,jh=[],zC=tt.browser.firefox&&+tt.browser.version.split(".")[0]<39;function Il(r,t,e,i){return e=e||{},i?lg(r,t,e):zC&&t.layerX!=null&&t.layerX!==t.offsetX?(e.zrX=t.layerX,e.zrY=t.layerY):t.offsetX!=null?(e.zrX=t.offsetX,e.zrY=t.offsetY):lg(r,t,e),e}function lg(r,t,e){if(tt.domSupported&&r.getBoundingClientRect){var i=t.clientX,a=t.clientY;if(Kh(r)){var n=r.getBoundingClientRect();e.zrX=i-n.left,e.zrY=a-n.top;return}else if(Pl(jh,r,i,a)){e.zrX=jh[0],e.zrY=jh[1];return}}e.zrX=e.zrY=0}function Rl(r){return r||window.event}function Ee(r,t,e){if(t=Rl(t),t.zrX!=null)return t;var i=t.type,a=i&&i.indexOf("touch")>=0;if(a){var o=i!=="touchend"?t.targetTouches[0]:t.changedTouches[0];o&&Il(r,o,t,e)}else{Il(r,t,t,e);var n=UC(t);t.zrDelta=n?n/120:-(t.detail||0)/3}var s=t.button;return t.which==null&&s!==void 0&&kC.test(t.type)&&(t.which=s&1?1:s&2?3:s&4?2:0),t}function UC(r){var t=r.wheelDelta;if(t)return t;var e=r.deltaX,i=r.deltaY;if(e==null||i==null)return t;var a=Math.abs(i!==0?i:e),n=i>0?-1:i<0?1:e>0?-1:1;return 3*a*n}function ug(r,t,e,i){r.addEventListener(t,e,i)}function fg(r,t,e,i){r.removeEventListener(t,e,i)}var Ar=function(r){r.preventDefault(),r.stopPropagation(),r.cancelBubble=!0};function Qh(r){return r.which===2||r.which===3}var cg=(function(){function r(){this._track=[]}return r.prototype.recognize=function(t,e,i){return this._doTrack(t,e,i),this._recognize(t)},r.prototype.clear=function(){return this._track.length=0,this},r.prototype._doTrack=function(t,e,i){var a=t.touches;if(a){for(var n={points:[],touches:[],target:e,event:t},o=0,s=a.length;o1&&i&&i.length>1){var n=hg(i)/hg(a);!isFinite(n)&&(n=1),t.pinchScale=n;var o=BC(i);return t.pinchX=o[0],t.pinchY=o[1],{type:"pinch",target:r[0].target,event:t}}}}};var jr={};Ae(jr,{clone:()=>VC,copy:()=>Ol,create:()=>mr,identity:()=>qr,invert:()=>Kr,mul:()=>Je,rotate:()=>ia,scale:()=>$h,translate:()=>bn});function mr(){return[1,0,0,1,0,0]}function qr(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=1,r[4]=0,r[5]=0,r}function Ol(r,t){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r}function Je(r,t,e){var i=t[0]*e[0]+t[2]*e[1],a=t[1]*e[0]+t[3]*e[1],n=t[0]*e[2]+t[2]*e[3],o=t[1]*e[2]+t[3]*e[3],s=t[0]*e[4]+t[2]*e[5]+t[4],l=t[1]*e[4]+t[3]*e[5]+t[5];return r[0]=i,r[1]=a,r[2]=n,r[3]=o,r[4]=s,r[5]=l,r}function bn(r,t,e){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4]+e[0],r[5]=t[5]+e[1],r}function ia(r,t,e,i){i===void 0&&(i=[0,0]);var a=t[0],n=t[2],o=t[4],s=t[1],l=t[3],u=t[5],f=Math.sin(e),h=Math.cos(e);return r[0]=a*h+s*f,r[1]=-a*f+s*h,r[2]=n*h+l*f,r[3]=-n*f+h*l,r[4]=h*(o-i[0])+f*(u-i[1])+i[0],r[5]=h*(u-i[1])-f*(o-i[0])+i[1],r}function $h(r,t,e){var i=e[0],a=e[1];return r[0]=t[0]*i,r[1]=t[1]*a,r[2]=t[2]*i,r[3]=t[3]*a,r[4]=t[4]*i,r[5]=t[5]*a,r}function Kr(r,t){var e=t[0],i=t[2],a=t[4],n=t[1],o=t[3],s=t[5],l=e*o-n*i;return l?(l=1/l,r[0]=o*l,r[1]=-n*l,r[2]=-i*l,r[3]=e*l,r[4]=(i*s-o*a)*l,r[5]=(n*a-e*s)*l,r):null}function VC(r){var t=mr();return Ol(t,r),t}var FC=(function(){function r(t,e){this.x=t||0,this.y=e||0}return r.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this},r.prototype.clone=function(){return new r(this.x,this.y)},r.prototype.set=function(t,e){return this.x=t,this.y=e,this},r.prototype.equal=function(t){return t.x===this.x&&t.y===this.y},r.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},r.prototype.scale=function(t){this.x*=t,this.y*=t},r.prototype.scaleAndAdd=function(t,e){this.x+=t.x*e,this.y+=t.y*e},r.prototype.sub=function(t){return this.x-=t.x,this.y-=t.y,this},r.prototype.dot=function(t){return this.x*t.x+this.y*t.y},r.prototype.len=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},r.prototype.lenSquare=function(){return this.x*this.x+this.y*this.y},r.prototype.normalize=function(){var t=this.len();return this.x/=t,this.y/=t,this},r.prototype.distance=function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},r.prototype.distanceSquare=function(t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i},r.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},r.prototype.transform=function(t){if(t){var e=this.x,i=this.y;return this.x=t[0]*e+t[2]*i+t[4],this.y=t[1]*e+t[3]*i+t[5],this}},r.prototype.toArray=function(t){return t[0]=this.x,t[1]=this.y,t},r.prototype.fromArray=function(t){this.x=t[0],this.y=t[1]},r.set=function(t,e,i){t.x=e,t.y=i},r.copy=function(t,e){t.x=e.x,t.y=e.y},r.len=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)},r.lenSquare=function(t){return t.x*t.x+t.y*t.y},r.dot=function(t,e){return t.x*e.x+t.y*e.y},r.add=function(t,e,i){t.x=e.x+i.x,t.y=e.y+i.y},r.sub=function(t,e,i){t.x=e.x-i.x,t.y=e.y-i.y},r.scale=function(t,e,i){t.x=e.x*i,t.y=e.y*i},r.scaleAndAdd=function(t,e,i,a){t.x=e.x+i.x*a,t.y=e.y+i.y*a},r.lerp=function(t,e,i,a){var n=1-a;t.x=n*e.x+a*i.x,t.y=n*e.y+a*i.y},r})(),st=FC;var Nl=Math.min,kl=Math.max,aa=new st,na=new st,oa=new st,sa=new st,Fo=new st,Go=new st,GC=(function(){function r(t,e,i,a){i<0&&(t=t+i,i=-i),a<0&&(e=e+a,a=-a),this.x=t,this.y=e,this.width=i,this.height=a}return r.prototype.union=function(t){var e=Nl(t.x,this.x),i=Nl(t.y,this.y);isFinite(this.x)&&isFinite(this.width)?this.width=kl(t.x+t.width,this.x+this.width)-e:this.width=t.width,isFinite(this.y)&&isFinite(this.height)?this.height=kl(t.y+t.height,this.y+this.height)-i:this.height=t.height,this.x=e,this.y=i},r.prototype.applyTransform=function(t){r.applyTransform(this,this,t)},r.prototype.calculateTransform=function(t){var e=this,i=t.width/e.width,a=t.height/e.height,n=mr();return bn(n,n,[-e.x,-e.y]),$h(n,n,[i,a]),bn(n,n,[t.x,t.y]),n},r.prototype.intersect=function(t,e){if(!t)return!1;t instanceof r||(t=r.create(t));var i=this,a=i.x,n=i.x+i.width,o=i.y,s=i.y+i.height,l=t.x,u=t.x+t.width,f=t.y,h=t.y+t.height,p=!(nv&&(v=_,mv&&(v=x,g=i.x&&t<=i.x+i.width&&e>=i.y&&e<=i.y+i.height},r.prototype.clone=function(){return new r(this.x,this.y,this.width,this.height)},r.prototype.copy=function(t){r.copy(this,t)},r.prototype.plain=function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},r.prototype.isFinite=function(){return isFinite(this.x)&&isFinite(this.y)&&isFinite(this.width)&&isFinite(this.height)},r.prototype.isZero=function(){return this.width===0||this.height===0},r.create=function(t){return new r(t.x,t.y,t.width,t.height)},r.copy=function(t,e){t.x=e.x,t.y=e.y,t.width=e.width,t.height=e.height},r.applyTransform=function(t,e,i){if(!i){t!==e&&r.copy(t,e);return}if(i[1]<1e-5&&i[1]>-1e-5&&i[2]<1e-5&&i[2]>-1e-5){var a=i[0],n=i[3],o=i[4],s=i[5];t.x=e.x*a+o,t.y=e.y*n+s,t.width=e.width*a,t.height=e.height*n,t.width<0&&(t.x+=t.width,t.width=-t.width),t.height<0&&(t.y+=t.height,t.height=-t.height);return}aa.x=oa.x=e.x,aa.y=sa.y=e.y,na.x=sa.x=e.x+e.width,na.y=oa.y=e.y+e.height,aa.transform(i),sa.transform(i),na.transform(i),oa.transform(i),t.x=Nl(aa.x,na.x,oa.x,sa.x),t.y=Nl(aa.y,na.y,oa.y,sa.y);var l=kl(aa.x,na.x,oa.x,sa.x),u=kl(aa.y,na.y,oa.y,sa.y);t.width=l-t.x,t.height=u-t.y},r})(),nt=GC;var vg="silent";function HC(r,t,e){return{type:r,event:e,target:t.target,topTarget:t.topTarget,cancelBubble:!1,offsetX:e.zrX,offsetY:e.zrY,gestureEvent:e.gestureEvent,pinchX:e.pinchX,pinchY:e.pinchY,pinchScale:e.pinchScale,wheelDelta:e.zrDelta,zrByTouch:e.zrByTouch,which:e.which,stop:WC}}function WC(){Ar(this.event)}var YC=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.handler=null,e}return t.prototype.dispose=function(){},t.prototype.setCursor=function(){},t})(Kt),Ho=(function(){function r(t,e){this.x=t,this.y=e}return r})(),ZC=["click","dblclick","mousewheel","mouseout","mouseup","mousedown","mousemove","contextmenu"],tc=new nt(0,0,0,0),dg=(function(r){P(t,r);function t(e,i,a,n,o){var s=r.call(this)||this;return s._hovered=new Ho(0,0),s.storage=e,s.painter=i,s.painterRoot=n,s._pointerSize=o,a=a||new YC,s.proxy=null,s.setHandlerProxy(a),s._draggingMgr=new ng(s),s}return t.prototype.setHandlerProxy=function(e){this.proxy&&this.proxy.dispose(),e&&(T(ZC,function(i){e.on&&e.on(i,this[i],this)},this),e.handler=this),this.proxy=e},t.prototype.mousemove=function(e){var i=e.zrX,a=e.zrY,n=mg(this,i,a),o=this._hovered,s=o.target;s&&!s.__zr&&(o=this.findHover(o.x,o.y),s=o.target);var l=this._hovered=n?new Ho(i,a):this.findHover(i,a),u=l.target,f=this.proxy;f.setCursor&&f.setCursor(u?u.cursor:"default"),s&&u!==s&&this.dispatchToElement(o,"mouseout",e),this.dispatchToElement(l,"mousemove",e),u&&u!==s&&this.dispatchToElement(l,"mouseover",e)},t.prototype.mouseout=function(e){var i=e.zrEventControl;i!=="only_globalout"&&this.dispatchToElement(this._hovered,"mouseout",e),i!=="no_globalout"&&this.trigger("globalout",{type:"globalout",event:e})},t.prototype.resize=function(){this._hovered=new Ho(0,0)},t.prototype.dispatch=function(e,i){var a=this[e];a&&a.call(this,i)},t.prototype.dispose=function(){this.proxy.dispose(),this.storage=null,this.proxy=null,this.painter=null},t.prototype.setCursorStyle=function(e){var i=this.proxy;i.setCursor&&i.setCursor(e)},t.prototype.dispatchToElement=function(e,i,a){e=e||{};var n=e.target;if(!(n&&n.silent)){for(var o="on"+i,s=HC(i,e,a);n&&(n[o]&&(s.cancelBubble=!!n[o].call(n,s)),n.trigger(i,s),n=n.__hostTarget?n.__hostTarget:n.parent,!s.cancelBubble););s.cancelBubble||(this.trigger(i,s),this.painter&&this.painter.eachOtherLayer&&this.painter.eachOtherLayer(function(l){typeof l[o]=="function"&&l[o].call(l,s),l.trigger&&l.trigger(i,s)}))}},t.prototype.findHover=function(e,i,a){var n=this.storage.getDisplayList(),o=new Ho(e,i);if(pg(n,o,e,i,a),this._pointerSize&&!o.target){for(var s=[],l=this._pointerSize,u=l/2,f=new nt(e-u,i-u,l,l),h=n.length-1;h>=0;h--){var p=n[h];p!==a&&!p.ignore&&!p.ignoreCoarsePointer&&(!p.parent||!p.parent.ignoreCoarsePointer)&&(tc.copy(p.getBoundingRect()),p.transform&&tc.applyTransform(p.transform),tc.intersect(f)&&s.push(p))}if(s.length)for(var c=4,v=Math.PI/12,m=Math.PI*2,d=0;d4)return;this._downPoint=null}this.dispatchToElement(n,r,t)}});function XC(r,t,e){if(r[r.rectHover?"rectContain":"contain"](t,e)){for(var i=r,a=void 0,n=!1;i;){if(i.ignoreClip&&(n=!0),!n){var o=i.getClipPath();if(o&&!o.contain(t,e))return!1}i.silent&&(a=!0);var s=i.__hostTarget;i=s||i.parent}return a?vg:!0}return!1}function pg(r,t,e,i,a){for(var n=r.length-1;n>=0;n--){var o=r[n],s=void 0;if(o!==a&&!o.ignore&&(s=XC(o,e,i))&&(!t.topTarget&&(t.topTarget=o),s!==vg)){t.target=o;break}}}function mg(r,t,e){var i=r.painter;return t<0||t>i.getWidth()||e<0||e>i.getHeight()}var gg=dg;var xg=32,Wo=7;function qC(r){for(var t=0;r>=xg;)t|=r&1,r>>=1;return r+t}function yg(r,t,e,i){var a=t+1;if(a===e)return 1;if(i(r[a++],r[t])<0){for(;a=0;)a++;return a-t}function KC(r,t,e){for(e--;t>>1,a(n,r[l])<0?s=l:o=l+1;var u=i-o;switch(u){case 3:r[o+3]=r[o+2];case 2:r[o+2]=r[o+1];case 1:r[o+1]=r[o];break;default:for(;u>0;)r[o+u]=r[o+u-1],u--}r[o]=n}}function ec(r,t,e,i,a,n){var o=0,s=0,l=1;if(n(r,t[e+a])>0){for(s=i-a;l0;)o=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s),o+=a,l+=a}else{for(s=a+1;ls&&(l=s);var u=o;o=a-l,l=a-u}for(o++;o>>1);n(r,t[e+f])>0?o=f+1:l=f}return l}function rc(r,t,e,i,a,n){var o=0,s=0,l=1;if(n(r,t[e+a])<0){for(s=a+1;ls&&(l=s);var u=o;o=a-l,l=a-u}else{for(s=i-a;l=0;)o=l,l=(l<<1)+1,l<=0&&(l=s);l>s&&(l=s),o+=a,l+=a}for(o++;o>>1);n(r,t[e+f])<0?l=f:o=f+1}return l}function jC(r,t){var e=Wo,i,a,n=0,o=[];i=[],a=[];function s(c,v){i[n]=c,a[n]=v,n+=1}function l(){for(;n>1;){var c=n-2;if(c>=1&&a[c-1]<=a[c]+a[c+1]||c>=2&&a[c-2]<=a[c]+a[c-1])a[c-1]a[c+1])break;f(c)}}function u(){for(;n>1;){var c=n-2;c>0&&a[c-1]=Wo||w>=Wo);if(C)break;S<0&&(S=0),S+=2}if(e=S,e<1&&(e=1),v===1){for(g=0;g=0;g--)r[b+g]=r[S+g];r[x]=o[_];return}for(var w=e;;){var C=0,M=0,A=!1;do if(t(o[_],r[y])<0){if(r[x--]=r[y--],C++,M=0,--v===0){A=!0;break}}else if(r[x--]=o[_--],M++,C=0,--d===1){A=!0;break}while((C|M)=0;g--)r[b+g]=r[S+g];if(v===0){A=!0;break}}if(r[x--]=o[_--],--d===1){A=!0;break}if(M=d-ec(r[y],o,0,d,d-1,t),M!==0){for(x-=M,_-=M,d-=M,b=x+1,S=_+1,g=0;g=Wo||M>=Wo);if(A)break;w<0&&(w=0),w+=2}if(e=w,e<1&&(e=1),d===1){for(x-=v,y-=v,b=x+1,S=y+1,g=v-1;g>=0;g--)r[b+g]=r[S+g];r[x]=o[_]}else{if(d===0)throw new Error;for(S=x-(d-1),g=0;gs&&(l=s),_g(r,e,e+l,e+n,t),n=l}o.pushRun(e,n),o.mergeRuns(),a-=n,e+=n}while(a!==0);o.forceMergeRuns()}}var Zt=1,ua=2,xi=4;var Sg=!1;function ic(){Sg||(Sg=!0,console.warn("z / z2 / zlevel of displayable is invalid, which may cause unexpected errors"))}function bg(r,t){return r.zlevel===t.zlevel?r.z===t.z?r.z2-t.z2:r.z-t.z:r.zlevel-t.zlevel}var QC=(function(){function r(){this._roots=[],this._displayList=[],this._displayListLen=0,this.displayableSortFunc=bg}return r.prototype.traverse=function(t,e){for(var i=0;i0&&(f.__clipPaths=[]),isNaN(f.z)&&(ic(),f.z=0),isNaN(f.z2)&&(ic(),f.z2=0),isNaN(f.zlevel)&&(ic(),f.zlevel=0),this._displayList[this._displayListLen++]=f}var h=t.getDecalElement&&t.getDecalElement();h&&this._updateAndAddDisplayable(h,e,i);var p=t.getTextGuideLine();p&&this._updateAndAddDisplayable(p,e,i);var c=t.getTextContent();c&&this._updateAndAddDisplayable(c,e,i)}},r.prototype.addRoot=function(t){t.__zr&&t.__zr.storage===this||this._roots.push(t)},r.prototype.delRoot=function(t){if(t instanceof Array){for(var e=0,i=t.length;e=0&&this._roots.splice(a,1)},r.prototype.delAllRoots=function(){this._roots=[],this._displayList=[],this._displayListLen=0},r.prototype.getRoots=function(){return this._roots},r.prototype.dispose=function(){this._displayList=null,this._roots=null},r})(),wg=QC;var Tg;Tg=tt.hasGlobalWindow&&(window.requestAnimationFrame&&window.requestAnimationFrame.bind(window)||window.msRequestAnimationFrame&&window.msRequestAnimationFrame.bind(window)||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame)||function(r){return setTimeout(r,16)};var Yo=Tg;var zl={linear:function(r){return r},quadraticIn:function(r){return r*r},quadraticOut:function(r){return r*(2-r)},quadraticInOut:function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)},cubicIn:function(r){return r*r*r},cubicOut:function(r){return--r*r*r+1},cubicInOut:function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)},quarticIn:function(r){return r*r*r*r},quarticOut:function(r){return 1- --r*r*r*r},quarticInOut:function(r){return(r*=2)<1?.5*r*r*r*r:-.5*((r-=2)*r*r*r-2)},quinticIn:function(r){return r*r*r*r*r},quinticOut:function(r){return--r*r*r*r*r+1},quinticInOut:function(r){return(r*=2)<1?.5*r*r*r*r*r:.5*((r-=2)*r*r*r*r+2)},sinusoidalIn:function(r){return 1-Math.cos(r*Math.PI/2)},sinusoidalOut:function(r){return Math.sin(r*Math.PI/2)},sinusoidalInOut:function(r){return .5*(1-Math.cos(Math.PI*r))},exponentialIn:function(r){return r===0?0:Math.pow(1024,r-1)},exponentialOut:function(r){return r===1?1:1-Math.pow(2,-10*r)},exponentialInOut:function(r){return r===0?0:r===1?1:(r*=2)<1?.5*Math.pow(1024,r-1):.5*(-Math.pow(2,-10*(r-1))+2)},circularIn:function(r){return 1-Math.sqrt(1-r*r)},circularOut:function(r){return Math.sqrt(1- --r*r)},circularInOut:function(r){return(r*=2)<1?-.5*(Math.sqrt(1-r*r)-1):.5*(Math.sqrt(1-(r-=2)*r)+1)},elasticIn:function(r){var t,e=.1,i=.4;return r===0?0:r===1?1:(!e||e<1?(e=1,t=i/4):t=i*Math.asin(1/e)/(2*Math.PI),-(e*Math.pow(2,10*(r-=1))*Math.sin((r-t)*(2*Math.PI)/i)))},elasticOut:function(r){var t,e=.1,i=.4;return r===0?0:r===1?1:(!e||e<1?(e=1,t=i/4):t=i*Math.asin(1/e)/(2*Math.PI),e*Math.pow(2,-10*r)*Math.sin((r-t)*(2*Math.PI)/i)+1)},elasticInOut:function(r){var t,e=.1,i=.4;return r===0?0:r===1?1:(!e||e<1?(e=1,t=i/4):t=i*Math.asin(1/e)/(2*Math.PI),(r*=2)<1?-.5*(e*Math.pow(2,10*(r-=1))*Math.sin((r-t)*(2*Math.PI)/i)):e*Math.pow(2,-10*(r-=1))*Math.sin((r-t)*(2*Math.PI)/i)*.5+1)},backIn:function(r){var t=1.70158;return r*r*((t+1)*r-t)},backOut:function(r){var t=1.70158;return--r*r*((t+1)*r+t)+1},backInOut:function(r){var t=2.5949095;return(r*=2)<1?.5*(r*r*((t+1)*r-t)):.5*((r-=2)*r*((t+1)*r+t)+2)},bounceIn:function(r){return 1-zl.bounceOut(1-r)},bounceOut:function(r){return r<.36363636363636365?7.5625*r*r:r<.7272727272727273?7.5625*(r-=.5454545454545454)*r+.75:r<.9090909090909091?7.5625*(r-=.8181818181818182)*r+.9375:7.5625*(r-=.9545454545454546)*r+.984375},bounceInOut:function(r){return r<.5?zl.bounceIn(r*2)*.5:zl.bounceOut(r*2-1)*.5+.5}},Ul=zl;var Bl=Math.pow,bi=Math.sqrt,Fl=1e-8,Dg=1e-4,Cg=bi(3),Vl=1/3,Er=Xr(),$e=Xr(),wn=Xr();function Si(r){return r>-Fl&&rFl||r<-Fl}function Rt(r,t,e,i,a){var n=1-a;return n*n*(n*r+3*a*t)+a*a*(a*i+3*n*e)}function ac(r,t,e,i,a){var n=1-a;return 3*(((t-r)*n+2*(e-t)*a)*n+(i-e)*a*a)}function fa(r,t,e,i,a,n){var o=i+3*(t-e)-r,s=3*(e-t*2+r),l=3*(t-r),u=r-a,f=s*s-3*o*l,h=s*l-9*o*u,p=l*l-3*s*u,c=0;if(Si(f)&&Si(h))if(Si(s))n[0]=0;else{var v=-l/s;v>=0&&v<=1&&(n[c++]=v)}else{var m=h*h-4*f*p;if(Si(m)){var d=h/f,v=-s/o+d,g=-d/2;v>=0&&v<=1&&(n[c++]=v),g>=0&&g<=1&&(n[c++]=g)}else if(m>0){var y=bi(m),_=f*s+1.5*o*(-h+y),x=f*s+1.5*o*(-h-y);_<0?_=-Bl(-_,Vl):_=Bl(_,Vl),x<0?x=-Bl(-x,Vl):x=Bl(x,Vl);var v=(-s-(_+x))/(3*o);v>=0&&v<=1&&(n[c++]=v)}else{var S=(2*f*s-3*o*h)/(2*bi(f*f*f)),b=Math.acos(S)/3,w=bi(f),C=Math.cos(b),v=(-s-2*w*C)/(3*o),g=(-s+w*(C+Cg*Math.sin(b)))/(3*o),M=(-s+w*(C-Cg*Math.sin(b)))/(3*o);v>=0&&v<=1&&(n[c++]=v),g>=0&&g<=1&&(n[c++]=g),M>=0&&M<=1&&(n[c++]=M)}}return c}function Gl(r,t,e,i,a){var n=6*e-12*t+6*r,o=9*t+3*i-3*r-9*e,s=3*t-3*r,l=0;if(Si(o)){if(Mg(n)){var u=-s/n;u>=0&&u<=1&&(a[l++]=u)}}else{var f=n*n-4*o*s;if(Si(f))a[0]=-n/(2*o);else if(f>0){var h=bi(f),u=(-n+h)/(2*o),p=(-n-h)/(2*o);u>=0&&u<=1&&(a[l++]=u),p>=0&&p<=1&&(a[l++]=p)}}return l}function Tn(r,t,e,i,a,n){var o=(t-r)*a+r,s=(e-t)*a+t,l=(i-e)*a+e,u=(s-o)*a+o,f=(l-s)*a+s,h=(f-u)*a+u;n[0]=r,n[1]=o,n[2]=u,n[3]=h,n[4]=h,n[5]=f,n[6]=l,n[7]=i}function Ag(r,t,e,i,a,n,o,s,l,u,f){var h,p=.005,c=1/0,v,m,d,g;Er[0]=l,Er[1]=u;for(var y=0;y<1;y+=.05)$e[0]=Rt(r,e,a,o,y),$e[1]=Rt(t,i,n,s,y),d=_i(Er,$e),d=0&&d=0&&u<=1&&(a[l++]=u)}}else{var f=o*o-4*n*s;if(Si(f)){var u=-o/(2*n);u>=0&&u<=1&&(a[l++]=u)}else if(f>0){var h=bi(f),u=(-o+h)/(2*n),p=(-o-h)/(2*n);u>=0&&u<=1&&(a[l++]=u),p>=0&&p<=1&&(a[l++]=p)}}return l}function Hl(r,t,e){var i=r+e-2*t;return i===0?.5:(r-t)/i}function Cn(r,t,e,i,a){var n=(t-r)*i+r,o=(e-t)*i+t,s=(o-n)*i+n;a[0]=r,a[1]=n,a[2]=s,a[3]=s,a[4]=o,a[5]=e}function Pg(r,t,e,i,a,n,o,s,l){var u,f=.005,h=1/0;Er[0]=o,Er[1]=s;for(var p=0;p<1;p+=.05){$e[0]=Qt(r,e,a,p),$e[1]=Qt(t,i,n,p);var c=_i(Er,$e);c=0&&c=1?1:fa(0,i,n,1,l,s)&&Rt(0,a,o,1,s[0])}}}var $C=(function(){function r(t){this._inited=!1,this._startTime=0,this._pausedTime=0,this._paused=!1,this._life=t.life||1e3,this._delay=t.delay||0,this.loop=t.loop||!1,this.onframe=t.onframe||Bt,this.ondestroy=t.ondestroy||Bt,this.onrestart=t.onrestart||Bt,t.easing&&this.setEasing(t.easing)}return r.prototype.step=function(t,e){if(this._inited||(this._startTime=t+this._delay,this._inited=!0),this._paused){this._pausedTime+=e;return}var i=this._life,a=t-this._startTime-this._pausedTime,n=a/i;n<0&&(n=0),n=Math.min(n,1);var o=this.easingFunc,s=o?o(n):n;if(this.onframe(s),n===1)if(this.loop){var l=a%i;this._startTime=t-l,this._pausedTime=0,this.onrestart()}else return!0;return!1},r.prototype.pause=function(){this._paused=!0},r.prototype.resume=function(){this._paused=!1},r.prototype.setEasing=function(t){this.easing=t,this.easingFunc=G(t)?t:Ul[t]||Wl(t)},r})(),Rg=$C;var ql={};Ae(ql,{fastLerp:()=>Ug,fastMapToColor:()=>nD,lerp:()=>Zl,lift:()=>hc,liftColor:()=>Xl,lum:()=>ca,mapToColor:()=>oD,modifyAlpha:()=>lD,modifyHSL:()=>sD,parse:()=>pe,random:()=>uD,stringify:()=>Lr,toHex:()=>aD});var Og=(function(){function r(t){this.value=t}return r})();var tD=(function(){function r(){this._len=0}return r.prototype.insert=function(t){var e=new Og(t);return this.insertEntry(e),e},r.prototype.insertEntry=function(t){this.head?(this.tail.next=t,t.prev=this.tail,t.next=null,this.tail=t):this.head=this.tail=t,this._len++},r.prototype.remove=function(t){var e=t.prev,i=t.next;e?e.next=i:this.head=i,i?i.prev=e:this.tail=e,t.next=t.prev=null,this._len--},r.prototype.len=function(){return this._len},r.prototype.clear=function(){this.head=this.tail=null,this._len=0},r})();var eD=(function(){function r(t){this._list=new tD,this._maxSize=10,this._map={},this._maxSize=t}return r.prototype.put=function(t,e){var i=this._list,a=this._map,n=null;if(a[t]==null){var o=i.len(),s=this._lastRemovedEntry;if(o>=this._maxSize&&o>0){var l=i.head;i.remove(l),delete a[l.key],n=l.value,this._lastRemovedEntry=l}s?s.value=e:s=new Og(e),s.key=t,i.insertEntry(s),a[t]=s}return n},r.prototype.get=function(t){var e=this._map[t],i=this._list;if(e!=null)return e!==i.tail&&(i.remove(e),i.insertEntry(e)),e.value},r.prototype.clear=function(){this._list.clear(),this._map={}},r.prototype.len=function(){return this._list.len()},r})(),Qr=eD;var Ng={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function gr(r){return r=Math.round(r),r<0?0:r>255?255:r}function rD(r){return r=Math.round(r),r<0?0:r>360?360:r}function Zo(r){return r<0?0:r>1?1:r}function sc(r){var t=r;return t.length&&t.charAt(t.length-1)==="%"?gr(parseFloat(t)/100*255):gr(parseInt(t,10))}function ha(r){var t=r;return t.length&&t.charAt(t.length-1)==="%"?Zo(parseFloat(t)/100):Zo(parseFloat(t))}function lc(r,t,e){return e<0?e+=1:e>1&&(e-=1),e*6<1?r+(t-r)*e*6:e*2<1?t:e*3<2?r+(t-r)*(2/3-e)*6:r}function wi(r,t,e){return r+(t-r)*e}function tr(r,t,e,i,a){return r[0]=t,r[1]=e,r[2]=i,r[3]=a,r}function uc(r,t){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r}var zg=new Qr(20),Yl=null;function Dn(r,t){Yl&&uc(Yl,t),Yl=zg.put(r,Yl||t.slice())}function pe(r,t){if(r){t=t||[];var e=zg.get(r);if(e)return uc(t,e);r=r+"";var i=r.replace(/ /g,"").toLowerCase();if(i in Ng)return uc(t,Ng[i]),Dn(r,t),t;var a=i.length;if(i.charAt(0)==="#"){if(a===4||a===5){var n=parseInt(i.slice(1,4),16);if(!(n>=0&&n<=4095)){tr(t,0,0,0,1);return}return tr(t,(n&3840)>>4|(n&3840)>>8,n&240|(n&240)>>4,n&15|(n&15)<<4,a===5?parseInt(i.slice(4),16)/15:1),Dn(r,t),t}else if(a===7||a===9){var n=parseInt(i.slice(1,7),16);if(!(n>=0&&n<=16777215)){tr(t,0,0,0,1);return}return tr(t,(n&16711680)>>16,(n&65280)>>8,n&255,a===9?parseInt(i.slice(7),16)/255:1),Dn(r,t),t}return}var o=i.indexOf("("),s=i.indexOf(")");if(o!==-1&&s+1===a){var l=i.substr(0,o),u=i.substr(o+1,s-(o+1)).split(","),f=1;switch(l){case"rgba":if(u.length!==4)return u.length===3?tr(t,+u[0],+u[1],+u[2],1):tr(t,0,0,0,1);f=ha(u.pop());case"rgb":if(u.length>=3)return tr(t,sc(u[0]),sc(u[1]),sc(u[2]),u.length===3?f:ha(u[3])),Dn(r,t),t;tr(t,0,0,0,1);return;case"hsla":if(u.length!==4){tr(t,0,0,0,1);return}return u[3]=ha(u[3]),fc(u,t),Dn(r,t),t;case"hsl":if(u.length!==3){tr(t,0,0,0,1);return}return fc(u,t),Dn(r,t),t;default:return}}tr(t,0,0,0,1)}}function fc(r,t){var e=(parseFloat(r[0])%360+360)%360/360,i=ha(r[1]),a=ha(r[2]),n=a<=.5?a*(i+1):a+i-a*i,o=a*2-n;return t=t||[],tr(t,gr(lc(o,n,e+1/3)*255),gr(lc(o,n,e)*255),gr(lc(o,n,e-1/3)*255),1),r.length===4&&(t[3]=r[3]),t}function iD(r){if(r){var t=r[0]/255,e=r[1]/255,i=r[2]/255,a=Math.min(t,e,i),n=Math.max(t,e,i),o=n-a,s=(n+a)/2,l,u;if(o===0)l=0,u=0;else{s<.5?u=o/(n+a):u=o/(2-n-a);var f=((n-t)/6+o/2)/o,h=((n-e)/6+o/2)/o,p=((n-i)/6+o/2)/o;t===n?l=p-h:e===n?l=1/3+f-p:i===n&&(l=2/3+h-f),l<0&&(l+=1),l>1&&(l-=1)}var c=[l*360,u,s];return r[3]!=null&&c.push(r[3]),c}}function hc(r,t){var e=pe(r);if(e){for(var i=0;i<3;i++)t<0?e[i]=e[i]*(1-t)|0:e[i]=(255-e[i])*t+e[i]|0,e[i]>255?e[i]=255:e[i]<0&&(e[i]=0);return Lr(e,e.length===4?"rgba":"rgb")}}function aD(r){var t=pe(r);if(t)return((1<<24)+(t[0]<<16)+(t[1]<<8)+ +t[2]).toString(16).slice(1)}function Ug(r,t,e){if(!(!(t&&t.length)||!(r>=0&&r<=1))){e=e||[];var i=r*(t.length-1),a=Math.floor(i),n=Math.ceil(i),o=t[a],s=t[n],l=i-a;return e[0]=gr(wi(o[0],s[0],l)),e[1]=gr(wi(o[1],s[1],l)),e[2]=gr(wi(o[2],s[2],l)),e[3]=Zo(wi(o[3],s[3],l)),e}}var nD=Ug;function Zl(r,t,e){if(!(!(t&&t.length)||!(r>=0&&r<=1))){var i=r*(t.length-1),a=Math.floor(i),n=Math.ceil(i),o=pe(t[a]),s=pe(t[n]),l=i-a,u=Lr([gr(wi(o[0],s[0],l)),gr(wi(o[1],s[1],l)),gr(wi(o[2],s[2],l)),Zo(wi(o[3],s[3],l))],"rgba");return e?{color:u,leftIndex:a,rightIndex:n,value:i}:u}}var oD=Zl;function sD(r,t,e,i){var a=pe(r);if(r)return a=iD(a),t!=null&&(a[0]=rD(t)),e!=null&&(a[1]=ha(e)),i!=null&&(a[2]=ha(i)),Lr(fc(a),"rgba")}function lD(r,t){var e=pe(r);if(e&&t!=null)return e[3]=Zo(t),Lr(e,"rgba")}function Lr(r,t){if(!(!r||!r.length)){var e=r[0]+","+r[1]+","+r[2];return(t==="rgba"||t==="hsva"||t==="hsla")&&(e+=","+r[3]),t+"("+e+")"}}function ca(r,t){var e=pe(r);return e?(.299*e[0]+.587*e[1]+.114*e[2])*e[3]/255+(1-e[3])*t:0}function uD(){return Lr([Math.round(Math.random()*255),Math.round(Math.random()*255),Math.round(Math.random()*255)],"rgb")}var kg=new Qr(100);function Xl(r){if(B(r)){var t=kg.get(r);return t||(t=hc(r,-.1),kg.put(r,t)),t}else if(Yr(r)){var e=N({},r);return e.colorStops=U(r.colorStops,function(i){return{offset:i.offset,color:hc(i.color,-.1)}}),e}return r}function Bg(r){return r.type==="linear"}function Vg(r){return r.type==="radial"}var ZN=(function(){return tt.hasGlobalWindow&&G(window.btoa)?function(r){return window.btoa(unescape(encodeURIComponent(r)))}:typeof Buffer<"u"?function(r){return Buffer.from(r).toString("base64")}:function(r){return null}})();var pc=Array.prototype.slice;function Jr(r,t,e){return(t-r)*e+r}function cc(r,t,e,i){for(var a=t.length,n=0;ni?t:r,n=Math.min(e,i),o=a[n-1]||{color:[0,0,0,0],offset:0},s=n;so;if(s)i.length=o;else for(var l=n;l=1},r.prototype.getAdditiveTrack=function(){return this._additiveTrack},r.prototype.addKeyframe=function(t,e,i){this._needsSort=!0;var a=this.keyframes,n=a.length,o=!1,s=Gg,l=e;if(Ot(e)){var u=pD(e);s=u,(u===1&&!et(e[0])||u===2&&!et(e[0][0]))&&(o=!0)}else if(et(e)&&!ea(e))s=jl;else if(B(e))if(!isNaN(+e))s=jl;else{var f=pe(e);f&&(l=f,s=qo)}else if(Yr(e)){var h=N({},l);h.colorStops=U(e.colorStops,function(c){return{offset:c.offset,color:pe(c.color)}}),Bg(e)?s=vc:Vg(e)&&(s=dc),l=h}n===0?this.valType=s:(s!==this.valType||s===Gg)&&(o=!0),this.discrete=this.discrete||o;var p={time:t,value:l,rawValue:e,percent:0};return i&&(p.easing=i,p.easingFunc=G(i)?i:Ul[i]||Wl(i)),a.push(p),p},r.prototype.prepare=function(t,e){var i=this.keyframes;this._needsSort&&i.sort(function(m,d){return m.time-d.time});for(var a=this.valType,n=i.length,o=i[n-1],s=this.discrete,l=Ql(a),u=Hg(a),f=0;f=0&&!(o[f].percent<=e);f--);f=p(f,s-2)}else{for(f=h;fe);f++);f=p(f-1,s-2)}v=o[f+1],c=o[f]}if(c&&v){this._lastFr=f,this._lastFrP=e;var d=v.percent-c.percent,g=d===0?1:p((e-c.percent)/d,1);v.easingFunc&&(g=v.easingFunc(g));var y=i?this._additiveValue:u?Xo:t[l];if((Ql(n)||u)&&!y&&(y=this._additiveValue=[]),this.discrete)t[l]=g<1?c.rawValue:v.rawValue;else if(Ql(n))n===$l?cc(y,c[a],v[a],g):fD(y,c[a],v[a],g);else if(Hg(n)){var _=c[a],x=v[a],S=n===vc;t[l]={type:S?"linear":"radial",x:Jr(_.x,x.x,g),y:Jr(_.y,x.y,g),colorStops:U(_.colorStops,function(w,C){var M=x.colorStops[C];return{offset:Jr(w.offset,M.offset,g),color:Jl(cc([],w.color,M.color,g))}}),global:x.global},S?(t[l].x2=Jr(_.x2,x.x2,g),t[l].y2=Jr(_.y2,x.y2,g)):t[l].r=Jr(_.r,x.r,g)}else if(u)cc(y,c[a],v[a],g),i||(t[l]=Jl(y));else{var b=Jr(c[a],v[a],g);i?this._additiveValue=b:t[l]=b}i&&this._addToTarget(t)}}},r.prototype._addToTarget=function(t){var e=this.valType,i=this.propName,a=this._additiveValue;e===jl?t[i]=t[i]+a:e===qo?(pe(t[i],Xo),Kl(Xo,Xo,a,1),t[i]=Jl(Xo)):e===$l?Kl(t[i],t[i],a,1):e===Wg&&Fg(t[i],t[i],a,1)},r})(),dD=(function(){function r(t,e,i,a){if(this._tracks={},this._trackKeys=[],this._maxTime=0,this._started=0,this._clip=null,this._target=t,this._loop=e,e&&a){ta("Can' use additive animation on looped animation.");return}this._additiveAnimators=a,this._allowDiscrete=i}return r.prototype.getMaxTime=function(){return this._maxTime},r.prototype.getDelay=function(){return this._delay},r.prototype.getLoop=function(){return this._loop},r.prototype.getTarget=function(){return this._target},r.prototype.changeTarget=function(t){this._target=t},r.prototype.when=function(t,e,i){return this.whenWithKeys(t,e,pt(e),i)},r.prototype.whenWithKeys=function(t,e,i,a){for(var n=this._tracks,o=0;o0&&l.addKeyframe(0,Ko(u),a),this._trackKeys.push(s)}l.addKeyframe(t,Ko(e[s]),a)}return this._maxTime=Math.max(this._maxTime,t),this},r.prototype.pause=function(){this._clip.pause(),this._paused=!0},r.prototype.resume=function(){this._clip.resume(),this._paused=!1},r.prototype.isPaused=function(){return!!this._paused},r.prototype.duration=function(t){return this._maxTime=t,this._force=!0,this},r.prototype._doneCallback=function(){this._setTracksFinished(),this._clip=null;var t=this._doneCbs;if(t)for(var e=t.length,i=0;i0)){this._started=1;for(var e=this,i=[],a=this._maxTime||0,n=0;n1){var s=o.pop();n.addKeyframe(s.time,t[a]),n.prepare(this._maxTime,n.getAdditiveTrack())}}}},r})(),jo=dD;function pa(){return new Date().getTime()}var mD=(function(r){P(t,r);function t(e){var i=r.call(this)||this;return i._running=!1,i._time=0,i._pausedTime=0,i._pauseStart=0,i._paused=!1,e=e||{},i.stage=e.stage||{},i}return t.prototype.addClip=function(e){e.animation&&this.removeClip(e),this._head?(this._tail.next=e,e.prev=this._tail,e.next=null,this._tail=e):this._head=this._tail=e,e.animation=this},t.prototype.addAnimator=function(e){e.animation=this;var i=e.getClip();i&&this.addClip(i)},t.prototype.removeClip=function(e){if(e.animation){var i=e.prev,a=e.next;i?i.next=a:this._head=a,a?a.prev=i:this._tail=i,e.next=e.prev=e.animation=null}},t.prototype.removeAnimator=function(e){var i=e.getClip();i&&this.removeClip(i),e.animation=null},t.prototype.update=function(e){for(var i=pa()-this._pausedTime,a=i-this._time,n=this._head;n;){var o=n.next,s=n.step(i,a);s&&(n.ondestroy(),this.removeClip(n)),n=o}this._time=i,e||(this.trigger("frame",a),this.stage.update&&this.stage.update())},t.prototype._startLoop=function(){var e=this;this._running=!0;function i(){e._running&&(Yo(i),!e._paused&&e.update())}Yo(i)},t.prototype.start=function(){this._running||(this._time=pa(),this._pausedTime=0,this._startLoop())},t.prototype.stop=function(){this._running=!1},t.prototype.pause=function(){this._paused||(this._pauseStart=pa(),this._paused=!0)},t.prototype.resume=function(){this._paused&&(this._pausedTime+=pa()-this._pauseStart,this._paused=!1)},t.prototype.clear=function(){for(var e=this._head;e;){var i=e.next;e.prev=e.next=e.animation=null,e=i}this._head=this._tail=null},t.prototype.isFinished=function(){return this._head==null},t.prototype.animate=function(e,i){i=i||{},this.start();var a=new jo(e,i.loop);return this.addAnimator(a),a},t})(Kt),Yg=mD;var gD=300,mc=tt.domSupported,gc=(function(){var r=["click","dblclick","mousewheel","wheel","mouseout","mouseup","mousedown","mousemove","contextmenu"],t=["touchstart","touchend","touchmove"],e={pointerdown:1,pointerup:1,pointermove:1,pointerout:1},i=U(r,function(a){var n=a.replace("mouse","pointer");return e.hasOwnProperty(n)?n:a});return{mouse:r,touch:t,pointer:i}})(),Zg={mouse:["mousemove","mouseup"],pointer:["pointermove","pointerup"]},Xg=!1;function xc(r){var t=r.pointerType;return t==="pen"||t==="touch"}function yD(r){r.touching=!0,r.touchTimer!=null&&(clearTimeout(r.touchTimer),r.touchTimer=null),r.touchTimer=setTimeout(function(){r.touching=!1,r.touchTimer=null},700)}function yc(r){r&&(r.zrByTouch=!0)}function _D(r,t){return Ee(r.dom,new xD(r,t),!0)}function Kg(r,t){for(var e=t,i=!1;e&&e.nodeType!==9&&!(i=e.domBelongToZr||e!==t&&e===r.painterRoot);)e=e.parentNode;return i}var xD=(function(){function r(t,e){this.stopPropagation=Bt,this.stopImmediatePropagation=Bt,this.preventDefault=Bt,this.type=e.type,this.target=this.currentTarget=t.dom,this.pointerType=e.pointerType,this.clientX=e.clientX,this.clientY=e.clientY}return r})(),yr={mousedown:function(r){r=Ee(this.dom,r),this.__mayPointerCapture=[r.zrX,r.zrY],this.trigger("mousedown",r)},mousemove:function(r){r=Ee(this.dom,r);var t=this.__mayPointerCapture;t&&(r.zrX!==t[0]||r.zrY!==t[1])&&this.__togglePointerCapture(!0),this.trigger("mousemove",r)},mouseup:function(r){r=Ee(this.dom,r),this.__togglePointerCapture(!1),this.trigger("mouseup",r)},mouseout:function(r){r=Ee(this.dom,r);var t=r.toElement||r.relatedTarget;Kg(this,t)||(this.__pointerCapturing&&(r.zrEventControl="no_globalout"),this.trigger("mouseout",r))},wheel:function(r){Xg=!0,r=Ee(this.dom,r),this.trigger("mousewheel",r)},mousewheel:function(r){Xg||(r=Ee(this.dom,r),this.trigger("mousewheel",r))},touchstart:function(r){r=Ee(this.dom,r),yc(r),this.__lastTouchMoment=new Date,this.handler.processGesture(r,"start"),yr.mousemove.call(this,r),yr.mousedown.call(this,r)},touchmove:function(r){r=Ee(this.dom,r),yc(r),this.handler.processGesture(r,"change"),yr.mousemove.call(this,r)},touchend:function(r){r=Ee(this.dom,r),yc(r),this.handler.processGesture(r,"end"),yr.mouseup.call(this,r),+new Date-+this.__lastTouchMomentty||r<-ty}var ma=[],Mn=[],bc=mr(),wc=Math.abs,TD=(function(){function r(){}return r.prototype.getLocalTransform=function(t){return r.getLocalTransform(this,t)},r.prototype.setPosition=function(t){this.x=t[0],this.y=t[1]},r.prototype.setScale=function(t){this.scaleX=t[0],this.scaleY=t[1]},r.prototype.setSkew=function(t){this.skewX=t[0],this.skewY=t[1]},r.prototype.setOrigin=function(t){this.originX=t[0],this.originY=t[1]},r.prototype.needLocalTransform=function(){return da(this.rotation)||da(this.x)||da(this.y)||da(this.scaleX-1)||da(this.scaleY-1)||da(this.skewX)||da(this.skewY)},r.prototype.updateTransform=function(){var t=this.parent&&this.parent.transform,e=this.needLocalTransform(),i=this.transform;if(!(e||t)){i&&($g(i),this.invTransform=null);return}i=i||mr(),e?this.getLocalTransform(i):$g(i),t&&(e?Je(i,t,i):Ol(i,t)),this.transform=i,this._resolveGlobalScaleRatio(i)},r.prototype._resolveGlobalScaleRatio=function(t){var e=this.globalScaleRatio;if(e!=null&&e!==1){this.getGlobalScale(ma);var i=ma[0]<0?-1:1,a=ma[1]<0?-1:1,n=((ma[0]-i)*e+i)/ma[0]||0,o=((ma[1]-a)*e+a)/ma[1]||0;t[0]*=n,t[1]*=n,t[2]*=o,t[3]*=o}this.invTransform=this.invTransform||mr(),Kr(this.invTransform,t)},r.prototype.getComputedTransform=function(){for(var t=this,e=[];t;)e.push(t),t=t.parent;for(;t=e.pop();)t.updateTransform();return this.transform},r.prototype.setLocalTransform=function(t){if(t){var e=t[0]*t[0]+t[1]*t[1],i=t[2]*t[2]+t[3]*t[3],a=Math.atan2(t[1],t[0]),n=Math.PI/2+a-Math.atan2(t[3],t[2]);i=Math.sqrt(i)*Math.cos(n),e=Math.sqrt(e),this.skewX=n,this.skewY=0,this.rotation=-a,this.x=+t[4],this.y=+t[5],this.scaleX=e,this.scaleY=i,this.originX=0,this.originY=0}},r.prototype.decomposeTransform=function(){if(this.transform){var t=this.parent,e=this.transform;t&&t.transform&&(t.invTransform=t.invTransform||mr(),Je(Mn,t.invTransform,e),e=Mn);var i=this.originX,a=this.originY;(i||a)&&(bc[4]=i,bc[5]=a,Je(Mn,e,bc),Mn[4]-=i,Mn[5]-=a,e=Mn),this.setLocalTransform(e)}},r.prototype.getGlobalScale=function(t){var e=this.transform;return t=t||[],e?(t[0]=Math.sqrt(e[0]*e[0]+e[1]*e[1]),t[1]=Math.sqrt(e[2]*e[2]+e[3]*e[3]),e[0]<0&&(t[0]=-t[0]),e[3]<0&&(t[1]=-t[1]),t):(t[0]=1,t[1]=1,t)},r.prototype.transformCoordToLocal=function(t,e){var i=[t,e],a=this.invTransform;return a&&Gt(i,i,a),i},r.prototype.transformCoordToGlobal=function(t,e){var i=[t,e],a=this.transform;return a&&Gt(i,i,a),i},r.prototype.getLineScale=function(){var t=this.transform;return t&&wc(t[0]-1)>1e-10&&wc(t[3]-1)>1e-10?Math.sqrt(wc(t[0]*t[3]-t[2]*t[1])):1},r.prototype.copyTransform=function(t){CD(this,t)},r.getLocalTransform=function(t,e){e=e||[];var i=t.originX||0,a=t.originY||0,n=t.scaleX,o=t.scaleY,s=t.anchorX,l=t.anchorY,u=t.rotation||0,f=t.x,h=t.y,p=t.skewX?Math.tan(t.skewX):0,c=t.skewY?Math.tan(-t.skewY):0;if(i||a||s||l){var v=i+s,m=a+l;e[4]=-v*n-p*m*o,e[5]=-m*o-c*v*n}else e[4]=e[5]=0;return e[0]=n,e[3]=o,e[1]=c*n,e[2]=p*o,u&&ia(e,e,u),e[4]+=i+f,e[5]+=a+h,e},r.initDefaultProps=(function(){var t=r.prototype;t.scaleX=t.scaleY=t.globalScaleRatio=1,t.x=t.y=t.originX=t.originY=t.skewX=t.skewY=t.rotation=t.anchorX=t.anchorY=0})(),r})(),ga=["x","y","originX","originY","anchorX","anchorY","rotation","scaleX","scaleY","skewX","skewY"];function CD(r,t){for(var e=0;e=0?parseFloat(r)/100*t:parseFloat(r):r}function _a(r,t,e){var i=t.position||"inside",a=t.distance!=null?t.distance:5,n=e.height,o=e.width,s=n/2,l=e.x,u=e.y,f="left",h="top";if(i instanceof Array)l+=er(i[0],e.width),u+=er(i[1],e.height),f=null,h=null;else switch(i){case"left":l-=a,u+=s,f="right",h="middle";break;case"right":l+=a+o,u+=s,h="middle";break;case"top":l+=o/2,u-=a,f="center",h="bottom";break;case"bottom":l+=o/2,u+=n+a,f="center";break;case"inside":l+=o/2,u+=s,f="center",h="middle";break;case"insideLeft":l+=a,u+=s,h="middle";break;case"insideRight":l+=o-a,u+=s,f="right",h="middle";break;case"insideTop":l+=o/2,u+=a,f="center";break;case"insideBottom":l+=o/2,u+=n-a,f="center",h="bottom";break;case"insideTopLeft":l+=a,u+=a;break;case"insideTopRight":l+=o-a,u+=a,f="right";break;case"insideBottomLeft":l+=a,u+=n-a,h="bottom";break;case"insideBottomRight":l+=o-a,u+=n-a,f="right",h="bottom";break}return r=r||{},r.x=l,r.y=u,r.align=f,r.verticalAlign=h,r}var Tc="__zr_normal__",Cc=ga.concat(["ignore"]),DD=ce(ga,function(r,t){return r[t]=!0,r},{ignore:!1}),Ln={},MD=new nt(0,0,0,0),Ac=(function(){function r(t){this.id=Po(),this.animators=[],this.currentStates=[],this.states={},this._init(t)}return r.prototype._init=function(t){this.attr(t)},r.prototype.drift=function(t,e,i){switch(this.draggable){case"horizontal":e=0;break;case"vertical":t=0;break}var a=this.transform;a||(a=this.transform=[1,0,0,1,0,0]),a[4]+=t,a[5]+=e,this.decomposeTransform(),this.markRedraw()},r.prototype.beforeUpdate=function(){},r.prototype.afterUpdate=function(){},r.prototype.update=function(){this.updateTransform(),this.__dirty&&this.updateInnerText()},r.prototype.updateInnerText=function(t){var e=this._textContent;if(e&&(!e.ignore||t)){this.textConfig||(this.textConfig={});var i=this.textConfig,a=i.local,n=e.innerTransformable,o=void 0,s=void 0,l=!1;n.parent=a?this:null;var u=!1;if(n.copyTransform(e),i.position!=null){var f=MD;i.layoutRect?f.copy(i.layoutRect):f.copy(this.getBoundingRect()),a||f.applyTransform(this.transform),this.calculateTextPosition?this.calculateTextPosition(Ln,i,f):_a(Ln,i,f),n.x=Ln.x,n.y=Ln.y,o=Ln.align,s=Ln.verticalAlign;var h=i.origin;if(h&&i.rotation!=null){var p=void 0,c=void 0;h==="center"?(p=f.width*.5,c=f.height*.5):(p=er(h[0],f.width),c=er(h[1],f.height)),u=!0,n.originX=-n.x+p+(a?0:f.x),n.originY=-n.y+c+(a?0:f.y)}}i.rotation!=null&&(n.rotation=i.rotation);var v=i.offset;v&&(n.x+=v[0],n.y+=v[1],u||(n.originX=-v[0],n.originY=-v[1]));var m=i.inside==null?typeof i.position=="string"&&i.position.indexOf("inside")>=0:i.inside,d=this._innerTextDefaultStyle||(this._innerTextDefaultStyle={}),g=void 0,y=void 0,_=void 0;m&&this.canBeInsideText()?(g=i.insideFill,y=i.insideStroke,(g==null||g==="auto")&&(g=this.getInsideTextFill()),(y==null||y==="auto")&&(y=this.getInsideTextStroke(g),_=!0)):(g=i.outsideFill,y=i.outsideStroke,(g==null||g==="auto")&&(g=this.getOutsideFill()),(y==null||y==="auto")&&(y=this.getOutsideStroke(g),_=!0)),g=g||"#000",(g!==d.fill||y!==d.stroke||_!==d.autoStroke||o!==d.align||s!==d.verticalAlign)&&(l=!0,d.fill=g,d.stroke=y,d.autoStroke=_,d.align=o,d.verticalAlign=s,e.setDefaultTextStyle(d)),e.__dirty|=Zt,l&&e.dirtyStyle(!0)}},r.prototype.canBeInsideText=function(){return!0},r.prototype.getInsideTextFill=function(){return"#fff"},r.prototype.getInsideTextStroke=function(t){return"#000"},r.prototype.getOutsideFill=function(){return this.__zr&&this.__zr.isDarkMode()?$o:Jo},r.prototype.getOutsideStroke=function(t){var e=this.__zr&&this.__zr.getBackgroundColor(),i=typeof e=="string"&&pe(e);i||(i=[255,255,255,1]);for(var a=i[3],n=this.__zr.isDarkMode(),o=0;o<3;o++)i[o]=i[o]*a+(n?0:255)*(1-a);return i[3]=1,Lr(i,"rgba")},r.prototype.traverse=function(t,e){},r.prototype.attrKV=function(t,e){t==="textConfig"?this.setTextConfig(e):t==="textContent"?this.setTextContent(e):t==="clipPath"?this.setClipPath(e):t==="extra"?(this.extra=this.extra||{},N(this.extra,e)):this[t]=e},r.prototype.hide=function(){this.ignore=!0,this.markRedraw()},r.prototype.show=function(){this.ignore=!1,this.markRedraw()},r.prototype.attr=function(t,e){if(typeof t=="string")this.attrKV(t,e);else if(H(t))for(var i=t,a=pt(i),n=0;n0},r.prototype.getState=function(t){return this.states[t]},r.prototype.ensureState=function(t){var e=this.states;return e[t]||(e[t]={}),e[t]},r.prototype.clearStates=function(t){this.useState(Tc,!1,t)},r.prototype.useState=function(t,e,i,a){var n=t===Tc,o=this.hasState();if(!(!o&&n)){var s=this.currentStates,l=this.stateTransition;if(!(at(s,t)>=0&&(e||s.length===1))){var u;if(this.stateProxy&&!n&&(u=this.stateProxy(t)),u||(u=this.states&&this.states[t]),!u&&!n){ta("State "+t+" not exists.");return}n||this.saveCurrentToNormalState(u);var f=!!(u&&u.hoverLayer||a);f&&this._toggleHoverLayerFlag(!0),this._applyStateObj(t,u,this._normalState,e,!i&&!this.__inHover&&l&&l.duration>0,l);var h=this._textContent,p=this._textGuide;return h&&h.useState(t,e,i,f),p&&p.useState(t,e,i,f),n?(this.currentStates=[],this._normalState={}):e?this.currentStates.push(t):this.currentStates=[t],this._updateAnimationTargets(),this.markRedraw(),!f&&this.__inHover&&(this._toggleHoverLayerFlag(!1),this.__dirty&=~Zt),u}}},r.prototype.useStates=function(t,e,i){if(!t.length)this.clearStates();else{var a=[],n=this.currentStates,o=t.length,s=o===n.length;if(s){for(var l=0;l0,v);var m=this._textContent,d=this._textGuide;m&&m.useStates(t,e,p),d&&d.useStates(t,e,p),this._updateAnimationTargets(),this.currentStates=t.slice(),this.markRedraw(),!p&&this.__inHover&&(this._toggleHoverLayerFlag(!1),this.__dirty&=~Zt)}},r.prototype.isSilent=function(){for(var t=this.silent,e=this.parent;!t&&e;){if(e.silent){t=!0;break}e=e.parent}return t},r.prototype._updateAnimationTargets=function(){for(var t=0;t=0){var i=this.currentStates.slice();i.splice(e,1),this.useStates(i)}},r.prototype.replaceState=function(t,e,i){var a=this.currentStates.slice(),n=at(a,t),o=at(a,e)>=0;n>=0?o?a.splice(n,1):a[n]=e:i&&!o&&a.push(e),this.useStates(a)},r.prototype.toggleState=function(t,e){e?this.useState(t,!0):this.removeState(t)},r.prototype._mergeStates=function(t){for(var e={},i,a=0;a=0&&n.splice(o,1)}),this.animators.push(t),i&&i.animation.addAnimator(t),i&&i.wakeUp()},r.prototype.updateDuringAnimation=function(t){this.markRedraw()},r.prototype.stopAnimation=function(t,e){for(var i=this.animators,a=i.length,n=[],o=0;o0&&e.during&&n[0].during(function(v,m){e.during(m)});for(var p=0;p0||a.force&&!o.length){var C=void 0,M=void 0,A=void 0;if(s){M={},p&&(C={});for(var x=0;x<_;x++){var g=m[x];M[g]=e[g],p?C[g]=i[g]:e[g]=i[g]}}else if(p){A={};for(var x=0;x<_;x++){var g=m[x];A[g]=Ko(e[g]),ED(e,i,g)}}var S=new jo(e,!1,!1,h?Tt(v,function(E){return E.targetName===t}):null);S.targetName=t,a.scope&&(S.scope=a.scope),p&&C&&S.whenWithKeys(0,C,m),A&&S.whenWithKeys(0,A,m),S.whenWithKeys(u??500,s?M:i,m).delay(f||0),r.addAnimator(S,t),o.push(S)}}var ru=Ac;var ny=(function(r){P(t,r);function t(e){var i=r.call(this)||this;return i.isGroup=!0,i._children=[],i.attr(e),i}return t.prototype.childrenRef=function(){return this._children},t.prototype.children=function(){return this._children.slice()},t.prototype.childAt=function(e){return this._children[e]},t.prototype.childOfName=function(e){for(var i=this._children,a=0;a=0&&(a.splice(n,0,e),this._doAdd(e))}return this},t.prototype.replace=function(e,i){var a=at(this._children,e);return a>=0&&this.replaceAt(i,a),this},t.prototype.replaceAt=function(e,i){var a=this._children,n=a[i];if(e&&e!==this&&e.parent!==this&&e!==n){a[i]=e,n.parent=null;var o=this.__zr;o&&n.removeSelfFromZr(o),this._doAdd(e)}return this},t.prototype._doAdd=function(e){e.parent&&e.parent.remove(e),e.parent=this;var i=this.__zr;i&&i!==e.__zr&&e.addSelfToZr(i),i&&i.refresh()},t.prototype.remove=function(e){var i=this.__zr,a=this._children,n=at(a,e);return n<0?this:(a.splice(n,1),e.parent=null,i&&e.removeSelfFromZr(i),i&&i.refresh(),this)},t.prototype.removeAll=function(){for(var e=this._children,i=this.__zr,a=0;a0&&(this._stillFrameAccum++,this._stillFrameAccum>this._sleepAfterStill&&this.animation.stop())},r.prototype.setSleepAfterStill=function(t){this._sleepAfterStill=t},r.prototype.wakeUp=function(){this._disposed||(this.animation.start(),this._stillFrameAccum=0)},r.prototype.refreshHover=function(){this._needsRefreshHover=!0},r.prototype.refreshHoverImmediately=function(){this._disposed||(this._needsRefreshHover=!1,this.painter.refreshHover&&this.painter.getType()==="canvas"&&this.painter.refreshHover())},r.prototype.resize=function(t){this._disposed||(t=t||{},this.painter.resize(t.width,t.height),this.handler.resize())},r.prototype.clearAnimation=function(){this._disposed||this.animation.clear()},r.prototype.getWidth=function(){if(!this._disposed)return this.painter.getWidth()},r.prototype.getHeight=function(){if(!this._disposed)return this.painter.getHeight()},r.prototype.setCursorStyle=function(t){this._disposed||this.handler.setCursorStyle(t)},r.prototype.findHover=function(t,e){if(!this._disposed)return this.handler.findHover(t,e)},r.prototype.on=function(t,e,i){return this._disposed||this.handler.on(t,e,i),this},r.prototype.off=function(t,e){this._disposed||this.handler.off(t,e)},r.prototype.trigger=function(t,e){this._disposed||this.handler.trigger(t,e)},r.prototype.clear=function(){if(!this._disposed){for(var t=this.storage.getRoots(),e=0;e0){if(r<=a)return o;if(r>=n)return s}else{if(r>=a)return o;if(r<=n)return s}else{if(r===a)return o;if(r===n)return s}return(r-a)/l*u+o}function j(r,t){switch(r){case"center":case"middle":r="50%";break;case"left":case"top":r="0%";break;case"right":case"bottom":r="100%";break}return B(r)?VD(r).match(/%$/)?parseFloat(r)/100*t:parseFloat(r):r==null?NaN:+r}function bt(r,t,e){return t==null&&(t=10),t=Math.min(Math.max(0,t),sy),r=(+r).toFixed(t),e?r:+r}function $r(r){return r.sort(function(t,e){return t-e}),r}function ue(r){if(r=+r,isNaN(r))return 0;if(r>1e-14){for(var t=1,e=0;e<15;e++,t*=10)if(Math.round(r*t)/t===r)return e}return Ic(r)}function Ic(r){var t=r.toString().toLowerCase(),e=t.indexOf("e"),i=e>0?+t.slice(e+1):0,a=e>0?e:t.length,n=t.indexOf("."),o=n<0?0:a-1-n;return Math.max(0,o-i)}function Pn(r,t){var e=Math.log,i=Math.LN10,a=Math.floor(e(r[1]-r[0])/i),n=Math.round(e(Math.abs(t[1]-t[0]))/i),o=Math.min(Math.max(-a+n,0),20);return isFinite(o)?o:20}function ly(r,t,e){if(!r[t])return 0;var i=Rc(r,e);return i[t]||0}function Rc(r,t){var e=ce(r,function(c,v){return c+(isNaN(v)?0:v)},0);if(e===0)return[];for(var i=Math.pow(10,t),a=U(r,function(c){return(isNaN(c)?0:c)/e*i*100}),n=i*100,o=U(a,function(c){return Math.floor(c)}),s=ce(o,function(c,v){return c+v},0),l=U(a,function(c,v){return c-o[v]});su&&(u=l[h],f=h);++o[f],l[f]=0,++s}return U(o,function(c){return c/i})}function uy(r,t){var e=Math.max(ue(r),ue(t)),i=r+t;return e>sy?i:bt(i,e)}var fy=9007199254740991;function es(r){var t=Math.PI*2;return(r%t+t)%t}function Sa(r){return r>-oy&&r=10&&t++,t}function Rn(r,t){var e=In(r),i=Math.pow(10,e),a=r/i,n;return t?a<1.5?n=1:a<2.5?n=2:a<4?n=3:a<7?n=5:n=10:a<1?n=1:a<2?n=2:a<3?n=3:a<5?n=5:n=10,r=n*i,e>=-20?+r.toFixed(e<0?-e:0):r}function hy(r,t){var e=(r.length-1)*t+1,i=Math.floor(e),a=+r[i-1],n=e-i;return n?a+n*(r[i]-a):a}function cy(r){r.sort(function(l,u){return s(l,u,0)?-1:1});for(var t=-1/0,e=1,i=0;i=0||n&&at(n,l)<0)){var u=i.getShallow(l,t);u!=null&&(o[r[s][0]]=u)}}return o}}var iM=[["fill","color"],["shadowBlur"],["shadowOffsetX"],["shadowOffsetY"],["opacity"],["shadowColor"]],aM=Pr(iM),Dy=(function(){function r(){}return r.prototype.getAreaStyle=function(t,e){return aM(this,t,e)},r})();var Uc=new Qr(50);function Ay(r){if(typeof r=="string"){var t=Uc.get(r);return t&&t.image}else return r}function Bc(r,t,e,i,a){if(r)if(typeof r=="string"){if(t&&t.__zrImageSrc===r||!e)return t;var n=Uc.get(r),o={hostEl:e,cb:i,cbPayload:a};return n?(t=n.image,!zn(t)&&n.pending.push(o)):(t=be.loadImage(r,My,My),t.__zrImageSrc=r,Uc.put(r,t.__cachedImgObj={image:t,pending:[o]})),t}else return r;else return t}function My(){var r=this.__cachedImgObj;this.onload=this.onerror=this.__cachedImgObj=null;for(var t=0;t=o;l++)s-=o;var u=Le(e,t);return u>s&&(e="",u=0),s=r-u,a.ellipsis=e,a.ellipsisWidth=u,a.contentWidth=s,a.containerWidth=r,a}function Iy(r,t,e){var i=e.containerWidth,a=e.font,n=e.contentWidth;if(!i){r.textLine="",r.isTruncated=!1;return}var o=Le(t,a);if(o<=i){r.textLine=t,r.isTruncated=!1;return}for(var s=0;;s++){if(o<=n||s>=e.maxIterations){t+=e.ellipsis;break}var l=s===0?oM(t,n,e.ascCharWidth,e.cnCharWidth):o>0?Math.floor(t.length*n/o):0;t=t.substr(0,l),o=Le(t,a)}t===""&&(t=e.placeholder),r.textLine=t,r.isTruncated=!0}function oM(r,t,e,i){for(var a=0,n=0,o=r.length;nv&&u){var m=Math.floor(v/s);f=f||p.length>m,p=p.slice(0,m)}if(r&&n&&h!=null)for(var d=Py(h,a,t.ellipsis,{minChar:t.truncateMinChar,placeholder:t.placeholder}),g={},y=0;ys&&Fc(e,r.substring(s,u),t,o),Fc(e,l[2],t,o,l[1]),s=Vc.lastIndex}sa){var L=e.lines.length;b>0?(_.tokens=_.tokens.slice(0,b),g(_,S,x),e.lines=e.lines.slice(0,y+1)):e.lines=e.lines.slice(0,y),e.isTruncated=e.isTruncated||e.lines.length0&&v+i.accumWidth>i.width&&(f=t.split(` +`),u=!0),i.accumWidth=v}else{var m=Ny(t,l,i.width,i.breakAll,i.accumWidth);i.accumWidth=m.accumWidth+c,h=m.linesWidths,f=m.lines}}else f=t.split(` +`);for(var d=0;d=32&&t<=591||t>=880&&t<=4351||t>=4608&&t<=5119||t>=7680&&t<=8303}var fM=ce(",&?/;] ".split(""),function(r,t){return r[t]=!0,r},{});function hM(r){return uM(r)?!!fM[r]:!0}function Ny(r,t,e,i,a){for(var n=[],o=[],s="",l="",u=0,f=0,h=0;he:a+f+c>e){f?(s||l)&&(v?(s||(s=l,l="",u=0,f=u),n.push(s),o.push(f-u),l+=p,u+=c,s="",f=u):(l&&(s+=l,l="",u=0),n.push(s),o.push(f),s=p,f=c)):v?(n.push(l),o.push(u),l=p,u=c):(n.push(p),o.push(c));continue}f+=c,v?(l+=p,u+=c):(l&&(s+=l,l="",u=0),s+=p)}return!n.length&&!s&&(s=r,l="",u=0),l&&(s+=l),s&&(n.push(s),o.push(f)),n.length===1&&(f+=a),{accumWidth:f,lines:n,linesWidths:o}}var Yc="__zr_style_"+Math.round(Math.random()*10),Ir={shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,shadowColor:"#000",opacity:1,blend:"source-over"},Ta={style:{shadowBlur:!0,shadowOffsetX:!0,shadowOffsetY:!0,shadowColor:!0,opacity:!0}};Ir[Yc]=!0;var ky=["z","z2","invisible"],cM=["invisible"],pM=(function(r){P(t,r);function t(e){return r.call(this,e)||this}return t.prototype._init=function(e){for(var i=pt(e),a=0;a1e-4){s[0]=r-e,s[1]=t-i,l[0]=r+e,l[1]=t+i;return}if(hu[0]=Xc(a)*e+r,hu[1]=Zc(a)*i+t,cu[0]=Xc(n)*e+r,cu[1]=Zc(n)*i+t,u(s,hu,cu),f(l,hu,cu),a=a%Ca,a<0&&(a=a+Ca),n=n%Ca,n<0&&(n=n+Ca),a>n&&!o?n+=Ca:aa&&(pu[0]=Xc(c)*e+r,pu[1]=Zc(c)*i+t,u(s,pu,s),f(l,pu,l))}var Dt={M:1,L:2,C:3,Q:4,A:5,Z:6,R:7},Da=[],Ma=[],Or=[],Mi=[],Nr=[],kr=[],Kc=Math.min,jc=Math.max,Aa=Math.cos,Ea=Math.sin,ri=Math.abs,$c=Math.PI,Ai=$c*2,Qc=typeof Float32Array<"u",ns=[];function Jc(r){var t=Math.round(r/$c*1e8)/1e8;return t%2*$c}function os(r,t){var e=Jc(r[0]);e<0&&(e+=Ai);var i=e-r[0],a=r[1];a+=i,!t&&a-e>=Ai?a=e+Ai:t&&e-a>=Ai?a=e-Ai:!t&&e>a?a=e+(Ai-Jc(e-a)):t&&e0&&(this._ux=ri(i/va/t)||0,this._uy=ri(i/va/e)||0)},r.prototype.setDPR=function(t){this.dpr=t},r.prototype.setContext=function(t){this._ctx=t},r.prototype.getContext=function(){return this._ctx},r.prototype.beginPath=function(){return this._ctx&&this._ctx.beginPath(),this.reset(),this},r.prototype.reset=function(){this._saveData&&(this._len=0),this._pathSegLen&&(this._pathSegLen=null,this._pathLen=0),this._version++},r.prototype.moveTo=function(t,e){return this._drawPendingPt(),this.addData(Dt.M,t,e),this._ctx&&this._ctx.moveTo(t,e),this._x0=t,this._y0=e,this._xi=t,this._yi=e,this},r.prototype.lineTo=function(t,e){var i=ri(t-this._xi),a=ri(e-this._yi),n=i>this._ux||a>this._uy;if(this.addData(Dt.L,t,e),this._ctx&&n&&this._ctx.lineTo(t,e),n)this._xi=t,this._yi=e,this._pendingPtDist=0;else{var o=i*i+a*a;o>this._pendingPtDist&&(this._pendingPtX=t,this._pendingPtY=e,this._pendingPtDist=o)}return this},r.prototype.bezierCurveTo=function(t,e,i,a,n,o){return this._drawPendingPt(),this.addData(Dt.C,t,e,i,a,n,o),this._ctx&&this._ctx.bezierCurveTo(t,e,i,a,n,o),this._xi=n,this._yi=o,this},r.prototype.quadraticCurveTo=function(t,e,i,a){return this._drawPendingPt(),this.addData(Dt.Q,t,e,i,a),this._ctx&&this._ctx.quadraticCurveTo(t,e,i,a),this._xi=i,this._yi=a,this},r.prototype.arc=function(t,e,i,a,n,o){this._drawPendingPt(),ns[0]=a,ns[1]=n,os(ns,o),a=ns[0],n=ns[1];var s=n-a;return this.addData(Dt.A,t,e,i,i,a,s,0,o?0:1),this._ctx&&this._ctx.arc(t,e,i,a,n,o),this._xi=Aa(n)*i+t,this._yi=Ea(n)*i+e,this},r.prototype.arcTo=function(t,e,i,a,n){return this._drawPendingPt(),this._ctx&&this._ctx.arcTo(t,e,i,a,n),this},r.prototype.rect=function(t,e,i,a){return this._drawPendingPt(),this._ctx&&this._ctx.rect(t,e,i,a),this.addData(Dt.R,t,e,i,a),this},r.prototype.closePath=function(){this._drawPendingPt(),this.addData(Dt.Z);var t=this._ctx,e=this._x0,i=this._y0;return t&&t.closePath(),this._xi=e,this._yi=i,this},r.prototype.fill=function(t){t&&t.fill(),this.toStatic()},r.prototype.stroke=function(t){t&&t.stroke(),this.toStatic()},r.prototype.len=function(){return this._len},r.prototype.setData=function(t){var e=t.length;!(this.data&&this.data.length===e)&&Qc&&(this.data=new Float32Array(e));for(var i=0;if.length&&(this._expandData(),f=this.data);for(var h=0;h0&&(this._ctx&&this._ctx.lineTo(this._pendingPtX,this._pendingPtY),this._pendingPtDist=0)},r.prototype._expandData=function(){if(!(this.data instanceof Array)){for(var t=[],e=0;e11&&(this.data=new Float32Array(t)))}},r.prototype.getBoundingRect=function(){Or[0]=Or[1]=Nr[0]=Nr[1]=Number.MAX_VALUE,Mi[0]=Mi[1]=kr[0]=kr[1]=-Number.MAX_VALUE;var t=this.data,e=0,i=0,a=0,n=0,o;for(o=0;oi||ri(_)>a||p===e-1)&&(m=Math.sqrt(y*y+_*_),n=d,o=g);break}case Dt.C:{var x=t[p++],S=t[p++],d=t[p++],g=t[p++],b=t[p++],w=t[p++];m=Eg(n,o,x,S,d,g,b,w,10),n=b,o=w;break}case Dt.Q:{var x=t[p++],S=t[p++],d=t[p++],g=t[p++];m=Ig(n,o,x,S,d,g,10),n=d,o=g;break}case Dt.A:var C=t[p++],M=t[p++],A=t[p++],D=t[p++],E=t[p++],L=t[p++],I=L+E;p+=1,v&&(s=Aa(E)*A+C,l=Ea(E)*D+M),m=jc(A,D)*Kc(Ai,Math.abs(L)),n=Aa(I)*A+C,o=Ea(I)*D+M;break;case Dt.R:{s=n=t[p++],l=o=t[p++];var R=t[p++],O=t[p++];m=R*2+O*2;break}case Dt.Z:{var y=s-n,_=l-o;m=Math.sqrt(y*y+_*_),n=s,o=l;break}}m>=0&&(u[h++]=m,f+=m)}return this._pathLen=f,f},r.prototype.rebuildPath=function(t,e){var i=this.data,a=this._ux,n=this._uy,o=this._len,s,l,u,f,h,p,c=e<1,v,m,d=0,g=0,y,_=0,x,S;if(!(c&&(this._pathSegLen||this._calculateLength(),v=this._pathSegLen,m=this._pathLen,y=e*m,!y)))t:for(var b=0;b0&&(t.lineTo(x,S),_=0),w){case Dt.M:s=u=i[b++],l=f=i[b++],t.moveTo(u,f);break;case Dt.L:{h=i[b++],p=i[b++];var M=ri(h-u),A=ri(p-f);if(M>a||A>n){if(c){var D=v[g++];if(d+D>y){var E=(y-d)/D;t.lineTo(u*(1-E)+h*E,f*(1-E)+p*E);break t}d+=D}t.lineTo(h,p),u=h,f=p,_=0}else{var L=M*M+A*A;L>_&&(x=h,S=p,_=L)}break}case Dt.C:{var I=i[b++],R=i[b++],O=i[b++],V=i[b++],z=i[b++],F=i[b++];if(c){var D=v[g++];if(d+D>y){var E=(y-d)/D;Tn(u,I,O,z,E,Da),Tn(f,R,V,F,E,Ma),t.bezierCurveTo(Da[1],Ma[1],Da[2],Ma[2],Da[3],Ma[3]);break t}d+=D}t.bezierCurveTo(I,R,O,V,z,F),u=z,f=F;break}case Dt.Q:{var I=i[b++],R=i[b++],O=i[b++],V=i[b++];if(c){var D=v[g++];if(d+D>y){var E=(y-d)/D;Cn(u,I,O,E,Da),Cn(f,R,V,E,Ma),t.quadraticCurveTo(Da[1],Ma[1],Da[2],Ma[2]);break t}d+=D}t.quadraticCurveTo(I,R,O,V),u=O,f=V;break}case Dt.A:var W=i[b++],Z=i[b++],J=i[b++],vt=i[b++],gt=i[b++],St=i[b++],se=i[b++],Ke=!i[b++],Ue=J>vt?J:vt,le=ri(J-vt)>.001,Ft=gt+St,ht=!1;if(c){var D=v[g++];d+D>y&&(Ft=gt+St*(y-d)/D,ht=!0),d+=D}if(le&&t.ellipse?t.ellipse(W,Z,J,vt,se,gt,Ft,Ke):t.arc(W,Z,Ue,gt,Ft,Ke),ht)break t;C&&(s=Aa(gt)*J+W,l=Ea(gt)*vt+Z),u=Aa(Ft)*J+W,f=Ea(Ft)*vt+Z;break;case Dt.R:s=u=i[b],l=f=i[b+1],h=i[b++],p=i[b++];var _t=i[b++],Cr=i[b++];if(c){var D=v[g++];if(d+D>y){var $t=y-d;t.moveTo(h,p),t.lineTo(h+Kc($t,_t),p),$t-=_t,$t>0&&t.lineTo(h+_t,p+Kc($t,Cr)),$t-=Cr,$t>0&&t.lineTo(h+jc(_t-$t,0),p+Cr),$t-=_t,$t>0&&t.lineTo(h,p+jc(Cr-$t,0));break t}d+=D}t.rect(h,p,_t,Cr);break;case Dt.Z:if(c){var D=v[g++];if(d+D>y){var E=(y-d)/D;t.lineTo(u*(1-E)+s*E,f*(1-E)+l*E);break t}d+=D}t.closePath(),u=s,f=l}}},r.prototype.clone=function(){var t=new r,e=this.data;return t.data=e.slice?e.slice():Array.prototype.slice.call(e),t._len=this._len,t},r.CMD=Dt,r.initDefaultProps=(function(){var t=r.prototype;t._saveData=!0,t._ux=0,t._uy=0,t._pendingPtDist=0,t._version=0})(),r})(),we=dM;function La(r,t,e,i,a,n,o){if(a===0)return!1;var s=a,l=0,u=r;if(o>t+s&&o>i+s||or+s&&n>e+s||nt+h&&f>i+h&&f>n+h&&f>s+h||fr+h&&u>e+h&&u>a+h&&u>o+h||ut+u&&l>i+u&&l>n+u||lr+u&&s>e+u&&s>a+u||se||f+ua&&(a+=ls);var p=Math.atan2(l,s);return p<0&&(p+=ls),p>=i&&p<=a||p+ls>=i&&p+ls<=a}function or(r,t,e,i,a,n){if(n>t&&n>i||na?s:0}var Ei=we.CMD,Pa=Math.PI*2,xM=1e-4;function SM(r,t){return Math.abs(r-t)t&&u>i&&u>n&&u>s||u1&&bM(),c=Rt(t,i,n,s,sr[0]),p>1&&(v=Rt(t,i,n,s,sr[1]))),p===2?dt&&s>i&&s>n||s=0&&u<=1){for(var f=0,h=Qt(t,i,n,u),p=0;pe||s<-e)return 0;var l=Math.sqrt(e*e-s*s);Te[0]=-l,Te[1]=l;var u=Math.abs(i-a);if(u<1e-4)return 0;if(u>=Pa-1e-4){i=0,a=Pa;var f=n?1:-1;return o>=Te[0]+r&&o<=Te[1]+r?f:0}if(i>a){var h=i;i=a,a=h}i<0&&(i+=Pa,a+=Pa);for(var p=0,c=0;c<2;c++){var v=Te[c];if(v+r>o){var m=Math.atan2(s,v),f=n?1:-1;m<0&&(m=Pa+m),(m>=i&&m<=a||m+Pa>=i&&m+Pa<=a)&&(m>Math.PI/2&&m1&&(e||(s+=or(l,u,f,h,i,a))),d&&(l=n[v],u=n[v+1],f=l,h=u),m){case Ei.M:f=n[v++],h=n[v++],l=f,u=h;break;case Ei.L:if(e){if(La(l,u,n[v],n[v+1],t,i,a))return!0}else s+=or(l,u,n[v],n[v+1],i,a)||0;l=n[v++],u=n[v++];break;case Ei.C:if(e){if(Gy(l,u,n[v++],n[v++],n[v++],n[v++],n[v],n[v+1],t,i,a))return!0}else s+=wM(l,u,n[v++],n[v++],n[v++],n[v++],n[v],n[v+1],i,a)||0;l=n[v++],u=n[v++];break;case Ei.Q:if(e){if(Hy(l,u,n[v++],n[v++],n[v],n[v+1],t,i,a))return!0}else s+=TM(l,u,n[v++],n[v++],n[v],n[v+1],i,a)||0;l=n[v++],u=n[v++];break;case Ei.A:var g=n[v++],y=n[v++],_=n[v++],x=n[v++],S=n[v++],b=n[v++];v+=1;var w=!!(1-n[v++]);p=Math.cos(S)*_+g,c=Math.sin(S)*x+y,d?(f=p,h=c):s+=or(l,u,p,c,i,a);var C=(i-g)*x/_+g;if(e){if(Yy(g,y,x,S,S+b,w,t,C,a))return!0}else s+=CM(g,y,x,S,S+b,w,C,a);l=Math.cos(S+b)*_+g,u=Math.sin(S+b)*x+y;break;case Ei.R:f=l=n[v++],h=u=n[v++];var M=n[v++],A=n[v++];if(p=f+M,c=h+A,e){if(La(f,h,p,h,t,i,a)||La(p,h,p,c,t,i,a)||La(p,c,f,c,t,i,a)||La(f,c,f,h,t,i,a))return!0}else s+=or(p,h,p,c,i,a),s+=or(f,c,f,h,i,a);break;case Ei.Z:if(e){if(La(l,u,f,h,t,i,a))return!0}else s+=or(l,u,f,h,i,a);l=f,u=h;break}}return!e&&!SM(u,h)&&(s+=or(l,u,f,h,i,a)||0),s!==0}function Xy(r,t,e){return Zy(r,0,!1,t,e)}function qy(r,t,e,i){return Zy(r,t,!0,e,i)}var ep=q({fill:"#000",stroke:null,strokePercent:1,fillOpacity:1,strokeOpacity:1,lineDashOffset:0,lineWidth:1,lineCap:"butt",miterLimit:10,strokeNoScale:!1,strokeFirst:!1},Ir),MM={style:q({fill:!0,stroke:!0,strokePercent:!0,fillOpacity:!0,strokeOpacity:!0,lineDashOffset:!0,lineWidth:!0,miterLimit:!0},Ta.style)},tp=ga.concat(["invisible","culling","z","z2","zlevel","parent"]),AM=(function(r){P(t,r);function t(e){return r.call(this,e)||this}return t.prototype.update=function(){var e=this;r.prototype.update.call(this);var i=this.style;if(i.decal){var a=this._decalEl=this._decalEl||new t;a.buildPath===t.prototype.buildPath&&(a.buildPath=function(l){e.buildPath(l,e.shape)}),a.silent=!0;var n=a.style;for(var o in i)n[o]!==i[o]&&(n[o]=i[o]);n.fill=i.fill?i.decal:null,n.decal=null,n.shadowColor=null,i.strokeFirst&&(n.stroke=null);for(var s=0;s.5?Jo:i>.2?Jg:$o}else if(e)return $o}return Jo},t.prototype.getInsideTextStroke=function(e){var i=this.style.fill;if(B(i)){var a=this.__zr,n=!!(a&&a.isDarkMode()),o=ca(e,0)0))},t.prototype.hasFill=function(){var e=this.style,i=e.fill;return i!=null&&i!=="none"},t.prototype.getBoundingRect=function(){var e=this._rect,i=this.style,a=!e;if(a){var n=!1;this.path||(n=!0,this.createPathProxy());var o=this.path;(n||this.__dirty&xi)&&(o.beginPath(),this.buildPath(o,this.shape,!1),this.pathUpdated()),e=o.getBoundingRect()}if(this._rect=e,this.hasStroke()&&this.path&&this.path.len()>0){var s=this._rectStroke||(this._rectStroke=e.clone());if(this.__dirty||a){s.copy(e);var l=i.strokeNoScale?this.getLineScale():1,u=i.lineWidth;if(!this.hasFill()){var f=this.strokeContainThreshold;u=Math.max(u,f??4)}l>1e-10&&(s.width+=u/l,s.height+=u/l,s.x-=u/l/2,s.y-=u/l/2)}return s}return e},t.prototype.contain=function(e,i){var a=this.transformCoordToLocal(e,i),n=this.getBoundingRect(),o=this.style;if(e=a[0],i=a[1],n.contain(e,i)){var s=this.path;if(this.hasStroke()){var l=o.lineWidth,u=o.strokeNoScale?this.getLineScale():1;if(u>1e-10&&(this.hasFill()||(l=Math.max(l,this.strokeContainThreshold)),qy(s,l/u,e,i)))return!0}if(this.hasFill())return Xy(s,e,i)}return!1},t.prototype.dirtyShape=function(){this.__dirty|=xi,this._rect&&(this._rect=null),this._decalEl&&this._decalEl.dirtyShape(),this.markRedraw()},t.prototype.dirty=function(){this.dirtyStyle(),this.dirtyShape()},t.prototype.animateShape=function(e){return this.animate("shape",e)},t.prototype.updateDuringAnimation=function(e){e==="style"?this.dirtyStyle():e==="shape"?this.dirtyShape():this.markRedraw()},t.prototype.attrKV=function(e,i){e==="shape"?this.setShape(i):r.prototype.attrKV.call(this,e,i)},t.prototype.setShape=function(e,i){var a=this.shape;return a||(a=this.shape={}),typeof e=="string"?a[e]=i:N(a,e),this.dirtyShape(),this},t.prototype.shapeChanged=function(){return!!(this.__dirty&xi)},t.prototype.createStyle=function(e){return Zr(ep,e)},t.prototype._innerSaveToNormal=function(e){r.prototype._innerSaveToNormal.call(this,e);var i=this._normalState;e.shape&&!i.shape&&(i.shape=N({},this.shape))},t.prototype._applyStateObj=function(e,i,a,n,o,s){r.prototype._applyStateObj.call(this,e,i,a,n,o,s);var l=!(i&&n),u;if(i&&i.shape?o?n?u=i.shape:(u=N({},a.shape),N(u,i.shape)):(u=N({},n?this.shape:a.shape),N(u,i.shape)):l&&(u=a.shape),u)if(o){this.shape=N({},this.shape);for(var f={},h=pt(u),p=0;p0},t.prototype.hasFill=function(){var e=this.style,i=e.fill;return i!=null&&i!=="none"},t.prototype.createStyle=function(e){return Zr(EM,e)},t.prototype.setBoundingRect=function(e){this._rect=e},t.prototype.getBoundingRect=function(){var e=this.style;if(!this._rect){var i=e.text;i!=null?i+="":i="";var a=An(i,e.font,e.textAlign,e.textBaseline);if(a.x+=e.x||0,a.y+=e.y||0,this.hasStroke()){var n=e.lineWidth;a.x-=n/2,a.y-=n/2,a.width+=n,a.height+=n}this._rect=a}return this._rect},t.initDefaultProps=(function(){var e=t.prototype;e.dirtyRectTolerance=10})(),t})(Rr);Ky.prototype.type="tspan";var us=Ky;var LM=q({x:0,y:0},Ir),PM={style:q({x:!0,y:!0,width:!0,height:!0,sx:!0,sy:!0,sWidth:!0,sHeight:!0},Ta.style)};function IM(r){return!!(r&&typeof r!="string"&&r.width&&r.height)}var jy=(function(r){P(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.createStyle=function(e){return Zr(LM,e)},t.prototype._getSize=function(e){var i=this.style,a=i[e];if(a!=null)return a;var n=IM(i.image)?i.image:this.__image;if(!n)return 0;var o=e==="width"?"height":"width",s=i[o];return s==null?n[e]:n[e]/n[o]*s},t.prototype.getWidth=function(){return this._getSize("width")},t.prototype.getHeight=function(){return this._getSize("height")},t.prototype.getAnimationStyleProps=function(){return PM},t.prototype.getBoundingRect=function(){var e=this.style;return this._rect||(this._rect=new nt(e.x||0,e.y||0,this.getWidth(),this.getHeight())),this._rect},t})(Rr);jy.prototype.type="image";var ie=jy;function Qy(r,t){var e=t.x,i=t.y,a=t.width,n=t.height,o=t.r,s,l,u,f;a<0&&(e=e+a,a=-a),n<0&&(i=i+n,n=-n),typeof o=="number"?s=l=u=f=o:o instanceof Array?o.length===1?s=l=u=f=o[0]:o.length===2?(s=u=o[0],l=f=o[1]):o.length===3?(s=o[0],l=f=o[1],u=o[2]):(s=o[0],l=o[1],u=o[2],f=o[3]):s=l=u=f=0;var h;s+l>a&&(h=s+l,s*=a/h,l*=a/h),u+f>a&&(h=u+f,u*=a/h,f*=a/h),l+u>n&&(h=l+u,l*=n/h,u*=n/h),s+f>n&&(h=s+f,s*=n/h,f*=n/h),r.moveTo(e+s,i),r.lineTo(e+a-l,i),l!==0&&r.arc(e+a-l,i+l,l,-Math.PI/2,0),r.lineTo(e+a,i+n-u),u!==0&&r.arc(e+a-u,i+n-u,u,0,Math.PI/2),r.lineTo(e+f,i+n),f!==0&&r.arc(e+f,i+n-f,f,Math.PI/2,Math.PI),r.lineTo(e,i+s),s!==0&&r.arc(e+s,i+s,s,Math.PI,Math.PI*1.5)}var Un=Math.round;function vu(r,t,e){if(t){var i=t.x1,a=t.x2,n=t.y1,o=t.y2;r.x1=i,r.x2=a,r.y1=n,r.y2=o;var s=e&&e.lineWidth;return s&&(Un(i*2)===Un(a*2)&&(r.x1=r.x2=Li(i,s,!0)),Un(n*2)===Un(o*2)&&(r.y1=r.y2=Li(n,s,!0))),r}}function du(r,t,e){if(t){var i=t.x,a=t.y,n=t.width,o=t.height;r.x=i,r.y=a,r.width=n,r.height=o;var s=e&&e.lineWidth;return s&&(r.x=Li(i,s,!0),r.y=Li(a,s,!0),r.width=Math.max(Li(i+n,s,!1)-r.x,n===0?0:1),r.height=Math.max(Li(a+o,s,!1)-r.y,o===0?0:1)),r}}function Li(r,t,e){if(!t)return r;var i=Un(r*2);return(i+Un(t))%2===0?i/2:(i+(e?1:-1))/2}var NM=(function(){function r(){this.x=0,this.y=0,this.width=0,this.height=0}return r})();var kM={},Jy=(function(r){P(t,r);function t(e){return r.call(this,e)||this}return t.prototype.getDefaultShape=function(){return new NM},t.prototype.buildPath=function(e,i){var a,n,o,s;if(this.subPixelOptimize){var l=du(kM,i,this.style);a=l.x,n=l.y,o=l.width,s=l.height,l.r=i.r,i=l}else a=i.x,n=i.y,o=i.width,s=i.height;i.r?Qy(e,i):e.rect(a,n,o,s)},t.prototype.isZeroArea=function(){return!this.shape.width||!this.shape.height},t})(rt);Jy.prototype.type="rect";var mt=Jy;var $y={fill:"#000"},t0=2,zM={style:q({fill:!0,stroke:!0,fillOpacity:!0,strokeOpacity:!0,lineWidth:!0,fontSize:!0,lineHeight:!0,width:!0,height:!0,textShadowColor:!0,textShadowBlur:!0,textShadowOffsetX:!0,textShadowOffsetY:!0,backgroundColor:!0,padding:!0,borderColor:!0,borderWidth:!0,borderRadius:!0},Ta.style)},l0=(function(r){P(t,r);function t(e){var i=r.call(this)||this;return i.type="text",i._children=[],i._defaultStyle=$y,i.attr(e),i}return t.prototype.childrenRef=function(){return this._children},t.prototype.update=function(){r.prototype.update.call(this),this.styleChanged()&&this._updateSubTexts();for(var e=0;e0,E=e.width!=null&&(e.overflow==="truncate"||e.overflow==="break"||e.overflow==="breakAll"),L=o.calculatedLineHeight,I=0;I=0&&(I=b[L],I.align==="right");)this._placeToken(I,e,C,g,E,"right",_),M-=I.width,E-=I.width,L--;for(D+=(n-(D-d)-(y-E)-M)/2;A<=L;)I=b[A],this._placeToken(I,e,C,g,D+I.width/2,"center",_),D+=I.width,A++;g+=C}},t.prototype._placeToken=function(e,i,a,n,o,s,l){var u=i.rich[e.styleName]||{};u.text=e.text;var f=e.verticalAlign,h=n+a/2;f==="top"?h=n+e.height/2:f==="bottom"&&(h=n+a-e.height/2);var p=!e.isLineHolder&&rp(u);p&&this._renderBackground(u,i,s==="right"?o-e.width:s==="center"?o-e.width/2:o,h-e.height/2,e.width,e.height);var c=!!u.backgroundColor,v=e.textPadding;v&&(o=o0(o,s,v),h-=e.height/2-v[0]-e.innerHeight/2);var m=this._getOrCreateChild(us),d=m.createStyle();m.useStyle(d);var g=this._defaultStyle,y=!1,_=0,x=n0("fill"in u?u.fill:"fill"in i?i.fill:(y=!0,g.fill)),S=a0("stroke"in u?u.stroke:"stroke"in i?i.stroke:!c&&!l&&(!g.autoStroke||y)?(_=t0,g.stroke):null),b=u.textShadowBlur>0||i.textShadowBlur>0;d.text=e.text,d.x=o,d.y=h,b&&(d.shadowBlur=u.textShadowBlur||i.textShadowBlur||0,d.shadowColor=u.textShadowColor||i.textShadowColor||"transparent",d.shadowOffsetX=u.textShadowOffsetX||i.textShadowOffsetX||0,d.shadowOffsetY=u.textShadowOffsetY||i.textShadowOffsetY||0),d.textAlign=s,d.textBaseline="middle",d.font=e.font||dr,d.opacity=Mr(u.opacity,i.opacity,1),r0(d,u),S&&(d.lineWidth=Mr(u.lineWidth,i.lineWidth,_),d.lineDash=Q(u.lineDash,i.lineDash),d.lineDashOffset=i.lineDashOffset||0,d.stroke=S),x&&(d.fill=x);var w=e.contentWidth,C=e.contentHeight;m.setBoundingRect(new nt(En(d.x,w,d.textAlign),ya(d.y,C,d.textBaseline),w,C))},t.prototype._renderBackground=function(e,i,a,n,o,s){var l=e.backgroundColor,u=e.borderWidth,f=e.borderColor,h=l&&l.image,p=l&&!h,c=e.borderRadius,v=this,m,d;if(p||e.lineHeight||u&&f){m=this._getOrCreateChild(mt),m.useStyle(m.createStyle()),m.style.fill=null;var g=m.shape;g.x=a,g.y=n,g.width=o,g.height=s,g.r=c,m.dirtyShape()}if(p){var y=m.style;y.fill=l||null,y.fillOpacity=Q(e.fillOpacity,1)}else if(h){d=this._getOrCreateChild(ie),d.onload=function(){v.dirtyStyle()};var _=d.style;_.image=l.image,_.x=a,_.y=n,_.width=o,_.height=s}if(u&&f){var y=m.style;y.lineWidth=u,y.stroke=f,y.strokeOpacity=Q(e.strokeOpacity,1),y.lineDash=e.borderDash,y.lineDashOffset=e.borderDashOffset||0,m.strokeContainThreshold=0,m.hasFill()&&m.hasStroke()&&(y.strokeFirst=!0,y.lineWidth*=2)}var x=(m||d).style;x.shadowBlur=e.shadowBlur||0,x.shadowColor=e.shadowColor||"transparent",x.shadowOffsetX=e.shadowOffsetX||0,x.shadowOffsetY=e.shadowOffsetY||0,x.opacity=Mr(e.opacity,i.opacity,1)},t.makeFont=function(e){var i="";return FM(e)&&(i=[e.fontStyle,e.fontWeight,VM(e.fontSize),e.fontFamily||"sans-serif"].join(" ")),i&&ee(i)||e.textFont||e.font},t})(Rr),UM={left:!0,right:1,center:1},BM={top:1,bottom:1,middle:1},e0=["fontStyle","fontWeight","fontSize","fontFamily"];function VM(r){return typeof r=="string"&&(r.indexOf("px")!==-1||r.indexOf("rem")!==-1||r.indexOf("em")!==-1)?r:isNaN(+r)?Cl+"px":r+"px"}function r0(r,t){for(var e=0;e=0,n=!1;if(r instanceof rt){var o=d0(r),s=a&&o.selectFill||o.normalFill,l=a&&o.selectStroke||o.normalStroke;if(Bn(s)||Bn(l)){i=i||{};var u=i.style||{};u.fill==="inherit"?(n=!0,i=N({},i),u=N({},u),u.fill=s):!Bn(u.fill)&&Bn(s)?(n=!0,i=N({},i),u=N({},u),u.fill=Xl(s)):!Bn(u.stroke)&&Bn(l)&&(n||(i=N({},i),u=N({},u)),u.stroke=Xl(l)),i.style=u}}if(i&&i.z2==null){n||(i=N({},i));var f=r.z2EmphasisLift;i.z2=r.z2+(f??HM)}return i}function KM(r,t,e){if(e&&e.z2==null){e=N({},e);var i=r.z2SelectLift;e.z2=r.z2+(i??WM)}return e}function jM(r,t,e){var i=at(r.currentStates,t)>=0,a=r.style.opacity,n=i?null:XM(r,["opacity"],t,{opacity:1});e=e||{};var o=e.style||{};return o.opacity==null&&(e=N({},e),o=N({opacity:i?a:n.opacity*.1},o),e.style=o),e}function ip(r,t){var e=this.states[r];if(this.style){if(r==="emphasis")return qM(this,r,t,e);if(r==="blur")return jM(this,r,e);if(r==="select")return KM(this,r,e)}return e}function QM(r){r.stateProxy=ip;var t=r.getTextContent(),e=r.getTextGuideLine();t&&(t.stateProxy=ip),e&&(e.stateProxy=ip)}function c0(r,t){!_0(r,t)&&!r.__highByOuter&&ii(r,m0)}function p0(r,t){!_0(r,t)&&!r.__highByOuter&&ii(r,g0)}function ai(r,t){r.__highByOuter|=1<<(t||0),ii(r,m0)}function ni(r,t){!(r.__highByOuter&=~(1<<(t||0)))&&ii(r,g0)}function yu(r){ii(r,sp)}function ds(r){ii(r,y0)}function up(r){ii(r,YM)}function fp(r){ii(r,ZM)}function _0(r,t){return r.__highDownSilentOnTouch&&t.zrByTouch}function hp(r){var t=r.getModel(),e=[],i=[];t.eachComponent(function(a,n){var o=np(n),s=a==="series",l=s?r.getViewOfSeriesModel(n):r.getViewOfComponentModel(n);!s&&i.push(l),o.isBlured&&(l.group.traverse(function(u){y0(u)}),s&&e.push(n)),o.isBlured=!1}),T(i,function(a){a&&a.toggleBlurSeries&&a.toggleBlurSeries(e,!1,t)})}function ap(r,t,e,i){var a=i.getModel();e=e||"coordinateSystem";function n(u,f){for(var h=0;h0){var l={dataIndex:s,seriesIndex:e.seriesIndex};o!=null&&(l.dataType=o),t.push(l)}})}),t}function Ii(r,t,e){C0(r,!0),ii(r,QM),$M(r,t,e)}function JM(r){C0(r,!1)}function ve(r,t,e,i){i?JM(r):Ii(r,t,e)}function $M(r,t,e){var i=ot(r);t!=null?(i.focus=t,i.blurScope=e):i.focus&&(i.focus=null)}var v0=["emphasis","blur","select"],tA={itemStyle:"getItemStyle",lineStyle:"getLineStyle",areaStyle:"getAreaStyle"};function Fe(r,t,e,i){e=e||"itemStyle";for(var a=0;aNa,BezierCurve:()=>Oa,BoundingRect:()=>nt,Circle:()=>oi,CompoundPath:()=>Cu,Ellipse:()=>ys,Group:()=>ut,Image:()=>ie,IncrementalDisplayable:()=>Lu,Line:()=>ne,LinearGradient:()=>Yn,OrientedBoundingRect:()=>Zn,Path:()=>rt,Point:()=>st,Polygon:()=>xr,Polyline:()=>Ce,RadialGradient:()=>Mu,Rect:()=>mt,Ring:()=>Ra,Sector:()=>me,Text:()=>yt,applyTransform:()=>Fa,clipPointsByRect:()=>Mp,clipRectByRect:()=>Ap,createIcon:()=>Ga,extendPath:()=>wp,extendShape:()=>bp,getShapeClass:()=>Tp,getTransform:()=>bs,groupTransition:()=>Dp,initProps:()=>Mt,isElementRemoved:()=>Ua,lineLineIntersect:()=>r_,linePolygonIntersect:()=>OA,makeImage:()=>Ss,makePath:()=>qn,mergePath:()=>Kn,registerShape:()=>Ge,removeElement:()=>Xn,removeElementWithFadeOut:()=>Ba,resizePath:()=>Ru,setTooltipConfig:()=>jn,subPixelOptimize:()=>IA,subPixelOptimizeLine:()=>Va,subPixelOptimizeRect:()=>PA,transformDirection:()=>Cp,traverseElements:()=>li,updateProps:()=>xt});var Hn=we.CMD,eA=[[],[],[]],A0=Math.sqrt,rA=Math.atan2;function vp(r,t){if(t){var e=r.data,i=r.len(),a,n,o,s,l,u,f=Hn.M,h=Hn.C,p=Hn.L,c=Hn.R,v=Hn.A,m=Hn.Q;for(o=0,s=0;o1&&(o*=dp(v),s*=dp(v));var m=(a===n?-1:1)*dp((o*o*(s*s)-o*o*(c*c)-s*s*(p*p))/(o*o*(c*c)+s*s*(p*p)))||0,d=m*o*c/s,g=m*-s*p/o,y=(r+e)/2+bu(h)*d-Su(h)*g,_=(t+i)/2+Su(h)*d+bu(h)*g,x=L0([1,0],[(p-d)/o,(c-g)/s]),S=[(p-d)/o,(c-g)/s],b=[(-1*p-d)/o,(-1*c-g)/s],w=L0(S,b);if(mp(S,b)<=-1&&(w=gs),mp(S,b)>=1&&(w=0),w<0){var C=Math.round(w/gs*1e6)/1e6;w=gs*2+C%2*gs}f.addData(u,y,_,o,s,x,w,h,n)}var iA=/([mlvhzcqtsa])([^mlvhzcqtsa]*)/ig,aA=/-?([0-9]*\.)?[0-9]+([eE]-?[0-9]+)?/g;function nA(r){var t=new we;if(!r)return t;var e=0,i=0,a=e,n=i,o,s=we.CMD,l=r.match(iA);if(!l)return t;for(var u=0;uI*I+R*R&&(C=A,M=D),{cx:C,cy:M,x0:-f,y0:-h,x1:C*(a/S-1),y1:M*(a/S-1)}}function hA(r){var t;if(k(r)){var e=r.length;if(!e)return r;e===1?t=[r[0],r[0],0,0]:e===2?t=[r[0],r[0],r[1],r[1]]:e===3?t=r.concat(r[2]):t=r}else t=[r,r,r,r];return t}function G0(r,t){var e,i=_s(t.r,0),a=_s(t.r0||0,0),n=i>0,o=a>0;if(!(!n&&!o)){if(n||(i=a,a=0),a>i){var s=i;i=a,a=s}var l=t.startAngle,u=t.endAngle;if(!(isNaN(l)||isNaN(u))){var f=t.cx,h=t.cy,p=!!t.clockwise,c=V0(u-l),v=c>gp&&c%gp;if(v>_r&&(c=v),!(i>_r))r.moveTo(f,h);else if(c>gp-_r)r.moveTo(f+i*Wn(l),h+i*Ia(l)),r.arc(f,h,i,l,u,!p),a>_r&&(r.moveTo(f+a*Wn(u),h+a*Ia(u)),r.arc(f,h,a,u,l,p));else{var m=void 0,d=void 0,g=void 0,y=void 0,_=void 0,x=void 0,S=void 0,b=void 0,w=void 0,C=void 0,M=void 0,A=void 0,D=void 0,E=void 0,L=void 0,I=void 0,R=i*Wn(l),O=i*Ia(l),V=a*Wn(u),z=a*Ia(u),F=c>_r;if(F){var W=t.cornerRadius;W&&(e=hA(W),m=e[0],d=e[1],g=e[2],y=e[3]);var Z=V0(i-a)/2;if(_=zr(Z,g),x=zr(Z,y),S=zr(Z,m),b=zr(Z,d),M=w=_s(_,x),A=C=_s(S,b),(w>_r||C>_r)&&(D=i*Wn(u),E=i*Ia(u),L=a*Wn(l),I=a*Ia(l),c_r){var le=zr(g,M),Ft=zr(y,M),ht=wu(L,I,R,O,i,le,p),_t=wu(D,E,V,z,i,Ft,p);r.moveTo(f+ht.cx+ht.x0,h+ht.cy+ht.y0),M0&&r.arc(f+ht.cx,h+ht.cy,le,de(ht.y0,ht.x0),de(ht.y1,ht.x1),!p),r.arc(f,h,i,de(ht.cy+ht.y1,ht.cx+ht.x1),de(_t.cy+_t.y1,_t.cx+_t.x1),!p),Ft>0&&r.arc(f+_t.cx,h+_t.cy,Ft,de(_t.y1,_t.x1),de(_t.y0,_t.x0),!p))}else r.moveTo(f+R,h+O),r.arc(f,h,i,l,u,!p);if(!(a>_r)||!F)r.lineTo(f+V,h+z);else if(A>_r){var le=zr(m,A),Ft=zr(d,A),ht=wu(V,z,D,E,a,-Ft,p),_t=wu(R,O,L,I,a,-le,p);r.lineTo(f+ht.cx+ht.x0,h+ht.cy+ht.y0),A0&&r.arc(f+ht.cx,h+ht.cy,Ft,de(ht.y0,ht.x0),de(ht.y1,ht.x1),!p),r.arc(f,h,a,de(ht.cy+ht.y1,ht.cx+ht.x1),de(_t.cy+_t.y1,_t.cx+_t.x1),p),le>0&&r.arc(f+_t.cx,h+_t.cy,le,de(_t.y1,_t.x1),de(_t.y0,_t.x0),!p))}else r.lineTo(f+V,h+z),r.arc(f,h,a,u,l,p)}r.closePath()}}}var pA=(function(){function r(){this.cx=0,this.cy=0,this.r0=0,this.r=0,this.startAngle=0,this.endAngle=Math.PI*2,this.clockwise=!0,this.cornerRadius=0}return r})();var H0=(function(r){P(t,r);function t(e){return r.call(this,e)||this}return t.prototype.getDefaultShape=function(){return new pA},t.prototype.buildPath=function(e,i){G0(e,i)},t.prototype.isZeroArea=function(){return this.shape.startAngle===this.shape.endAngle||this.shape.r===this.shape.r0},t})(rt);H0.prototype.type="sector";var me=H0;var vA=(function(){function r(){this.cx=0,this.cy=0,this.r=0,this.r0=0}return r})();var W0=(function(r){P(t,r);function t(e){return r.call(this,e)||this}return t.prototype.getDefaultShape=function(){return new vA},t.prototype.buildPath=function(e,i){var a=i.cx,n=i.cy,o=Math.PI*2;e.moveTo(a+i.r,n),e.arc(a,n,i.r,0,o,!1),e.moveTo(a+i.r0,n),e.arc(a,n,i.r0,0,o,!0)},t})(rt);W0.prototype.type="ring";var Ra=W0;function yp(r,t,e,i){var a=[],n=[],o=[],s=[],l,u,f,h;if(i){f=[1/0,1/0],h=[-1/0,-1/0];for(var p=0,c=r.length;p=2){if(i){var n=yp(a,i,e,t.smoothConstraint);r.moveTo(a[0][0],a[0][1]);for(var o=a.length,s=0;s<(e?o:o-1);s++){var l=n[s*2],u=n[s*2+1],f=a[(s+1)%o];r.bezierCurveTo(l[0],l[1],u[0],u[1],f[0],f[1])}}else{r.moveTo(a[0][0],a[0][1]);for(var s=1,h=a.length;sza[1]){if(s=!1,n)return s;var f=Math.abs(za[0]-ka[1]),h=Math.abs(ka[0]-za[1]);Math.min(f,h)>a.len()&&(f0){var h=f.duration,p=f.delay,c=f.easing,v={duration:h,delay:p||0,easing:c,done:n,force:!!n||!!o,setToFinal:!u,scope:r,during:o};s?t.animateFrom(e,v):t.animateTo(e,v)}else t.stopAnimation(),!s&&t.attr(e),o&&o(1),n&&n()}function xt(r,t,e,i,a,n){_p("update",r,t,e,i,a,n)}function Mt(r,t,e,i,a,n){_p("enter",r,t,e,i,a,n)}function Ua(r){if(!r.__zr)return!0;for(var t=0;tMath.abs(n[1])?n[0]>0?"right":"left":n[1]>0?"bottom":"top"}function $0(r){return!r.isGroup}function RA(r){return r.shape!=null}function Dp(r,t,e){if(!r||!t)return;function i(o){var s={};return o.traverse(function(l){$0(l)&&l.anid&&(s[l.anid]=l)}),s}function a(o){var s={x:o.x,y:o.y,rotation:o.rotation};return RA(o)&&(s.shape=N({},o.shape)),s}var n=i(r);t.traverse(function(o){if($0(o)&&o.anid){var s=n[o.anid];if(s){var l=a(o);o.attr(a(s)),xt(o,l,e,ot(o).dataIndex)}}})}function Mp(r,t){return U(r,function(e){var i=e[0];i=Pu(i,t.x),i=Iu(i,t.x+t.width);var a=e[1];return a=Pu(a,t.y),a=Iu(a,t.y+t.height),[i,a]})}function Ap(r,t){var e=Pu(r.x,t.x),i=Iu(r.x+r.width,t.x+t.width),a=Pu(r.y,t.y),n=Iu(r.y+r.height,t.y+t.height);if(i>=e&&n>=a)return{x:e,y:a,width:i-e,height:n-a}}function Ga(r,t,e){var i=N({rectHover:!0},t),a=i.style={strokeNoScale:!0};if(e=e||{x:-1,y:-1,width:2,height:2},r)return r.indexOf("image://")===0?(a.image=r.slice(8),q(a,e),new ie(i)):qn(r.replace("path://",""),i,e,"center")}function OA(r,t,e,i,a){for(var n=0,o=a[a.length-1];n1)return!1;var d=xp(c,v,f,h)/p;return!(d<0||d>1)}function xp(r,t,e,i){return r*i-e*t}function NA(r){return r<=1e-6&&r>=-1e-6}function jn(r){var t=r.itemTooltipOption,e=r.componentModel,i=r.itemName,a=B(t)?{formatter:t}:t,n=e.mainType,o=e.componentIndex,s={componentType:n,name:i,$vars:["name"]};s[n+"Index"]=o;var l=r.formatterParamsExtra;l&&T(pt(l),function(f){qt(s,f)||(s[f]=l[f],s.$vars.push(f))});var u=ot(r.el);u.componentMainType=n,u.componentIndex=o,u.tooltipConfig={name:i,option:q({content:i,encodeHTMLContent:!0,formatterParams:s},a)}}function t_(r,t){var e;r.isGroup&&(e=t(r)),e||r.traverse(t)}function li(r,t){if(r)if(k(r))for(var e=0;e=0&&s.push(l)}),s}}function Oi(r,t){return it(it({},r,!0),t,!0)}var m_={time:{month:["January","February","March","April","May","June","July","August","September","October","November","December"],monthAbbr:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayOfWeek:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayOfWeekAbbr:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},legend:{selector:{all:"All",inverse:"Inv"}},toolbox:{brush:{title:{rect:"Box Select",polygon:"Lasso Select",lineX:"Horizontally Select",lineY:"Vertically Select",keep:"Keep Selections",clear:"Clear Selections"}},dataView:{title:"Data View",lang:["Data View","Close","Refresh"]},dataZoom:{title:{zoom:"Zoom",back:"Zoom Reset"}},magicType:{title:{line:"Switch to Line Chart",bar:"Switch to Bar Chart",stack:"Stack",tiled:"Tile"}},restore:{title:"Restore"},saveAsImage:{title:"Save as Image",lang:["Right Click to Save Image"]}},series:{typeNames:{pie:"Pie chart",bar:"Bar chart",line:"Line chart",scatter:"Scatter plot",effectScatter:"Ripple scatter plot",radar:"Radar chart",tree:"Tree",treemap:"Treemap",boxplot:"Boxplot",candlestick:"Candlestick",k:"K line chart",heatmap:"Heat map",map:"Map",parallel:"Parallel coordinate map",lines:"Line graph",graph:"Relationship graph",sankey:"Sankey diagram",funnel:"Funnel chart",gauge:"Gauge",pictorialBar:"Pictorial bar",themeRiver:"Theme River Map",sunburst:"Sunburst",custom:"Custom chart",chart:"Chart"}},aria:{general:{withTitle:'This is a chart about "{title}"',withoutTitle:"This is a chart"},series:{single:{prefix:"",withName:" with type {seriesType} named {seriesName}.",withoutName:" with type {seriesType}."},multiple:{prefix:". It consists of {seriesCount} series count.",withName:" The {seriesId} series is a {seriesType} representing {seriesName}.",withoutName:" The {seriesId} series is a {seriesType}.",separator:{middle:"",end:""}}},data:{allData:"The data is as follows: ",partialData:"The first {displayCnt} items are: ",withName:"the data for {name} is {value}",withoutName:"{value}",separator:{middle:", ",end:". "}}}};var g_={time:{month:["\u4E00\u6708","\u4E8C\u6708","\u4E09\u6708","\u56DB\u6708","\u4E94\u6708","\u516D\u6708","\u4E03\u6708","\u516B\u6708","\u4E5D\u6708","\u5341\u6708","\u5341\u4E00\u6708","\u5341\u4E8C\u6708"],monthAbbr:["1\u6708","2\u6708","3\u6708","4\u6708","5\u6708","6\u6708","7\u6708","8\u6708","9\u6708","10\u6708","11\u6708","12\u6708"],dayOfWeek:["\u661F\u671F\u65E5","\u661F\u671F\u4E00","\u661F\u671F\u4E8C","\u661F\u671F\u4E09","\u661F\u671F\u56DB","\u661F\u671F\u4E94","\u661F\u671F\u516D"],dayOfWeekAbbr:["\u65E5","\u4E00","\u4E8C","\u4E09","\u56DB","\u4E94","\u516D"]},legend:{selector:{all:"\u5168\u9009",inverse:"\u53CD\u9009"}},toolbox:{brush:{title:{rect:"\u77E9\u5F62\u9009\u62E9",polygon:"\u5708\u9009",lineX:"\u6A2A\u5411\u9009\u62E9",lineY:"\u7EB5\u5411\u9009\u62E9",keep:"\u4FDD\u6301\u9009\u62E9",clear:"\u6E05\u9664\u9009\u62E9"}},dataView:{title:"\u6570\u636E\u89C6\u56FE",lang:["\u6570\u636E\u89C6\u56FE","\u5173\u95ED","\u5237\u65B0"]},dataZoom:{title:{zoom:"\u533A\u57DF\u7F29\u653E",back:"\u533A\u57DF\u7F29\u653E\u8FD8\u539F"}},magicType:{title:{line:"\u5207\u6362\u4E3A\u6298\u7EBF\u56FE",bar:"\u5207\u6362\u4E3A\u67F1\u72B6\u56FE",stack:"\u5207\u6362\u4E3A\u5806\u53E0",tiled:"\u5207\u6362\u4E3A\u5E73\u94FA"}},restore:{title:"\u8FD8\u539F"},saveAsImage:{title:"\u4FDD\u5B58\u4E3A\u56FE\u7247",lang:["\u53F3\u952E\u53E6\u5B58\u4E3A\u56FE\u7247"]}},series:{typeNames:{pie:"\u997C\u56FE",bar:"\u67F1\u72B6\u56FE",line:"\u6298\u7EBF\u56FE",scatter:"\u6563\u70B9\u56FE",effectScatter:"\u6D9F\u6F2A\u6563\u70B9\u56FE",radar:"\u96F7\u8FBE\u56FE",tree:"\u6811\u56FE",treemap:"\u77E9\u5F62\u6811\u56FE",boxplot:"\u7BB1\u578B\u56FE",candlestick:"K\u7EBF\u56FE",k:"K\u7EBF\u56FE",heatmap:"\u70ED\u529B\u56FE",map:"\u5730\u56FE",parallel:"\u5E73\u884C\u5750\u6807\u56FE",lines:"\u7EBF\u56FE",graph:"\u5173\u7CFB\u56FE",sankey:"\u6851\u57FA\u56FE",funnel:"\u6F0F\u6597\u56FE",gauge:"\u4EEA\u8868\u76D8\u56FE",pictorialBar:"\u8C61\u5F62\u67F1\u56FE",themeRiver:"\u4E3B\u9898\u6CB3\u6D41\u56FE",sunburst:"\u65ED\u65E5\u56FE",custom:"\u81EA\u5B9A\u4E49\u56FE\u8868",chart:"\u56FE\u8868"}},aria:{general:{withTitle:"\u8FD9\u662F\u4E00\u4E2A\u5173\u4E8E\u201C{title}\u201D\u7684\u56FE\u8868\u3002",withoutTitle:"\u8FD9\u662F\u4E00\u4E2A\u56FE\u8868\uFF0C"},series:{single:{prefix:"",withName:"\u56FE\u8868\u7C7B\u578B\u662F{seriesType}\uFF0C\u8868\u793A{seriesName}\u3002",withoutName:"\u56FE\u8868\u7C7B\u578B\u662F{seriesType}\u3002"},multiple:{prefix:"\u5B83\u7531{seriesCount}\u4E2A\u56FE\u8868\u7CFB\u5217\u7EC4\u6210\u3002",withName:"\u7B2C{seriesId}\u4E2A\u7CFB\u5217\u662F\u4E00\u4E2A\u8868\u793A{seriesName}\u7684{seriesType}\uFF0C",withoutName:"\u7B2C{seriesId}\u4E2A\u7CFB\u5217\u662F\u4E00\u4E2A{seriesType}\uFF0C",separator:{middle:"\uFF1B",end:"\u3002"}}},data:{allData:"\u5176\u6570\u636E\u662F\u2014\u2014",partialData:"\u5176\u4E2D\uFF0C\u524D{displayCnt}\u9879\u662F\u2014\u2014",withName:"{name}\u7684\u6570\u636E\u662F{value}",withoutName:"{value}",separator:{middle:"\uFF0C",end:""}}}};var zu="ZH",Np="EN",Qn=Np,ku={},kp={},Uu=tt.domSupported?(function(){var r=(document.documentElement.lang||navigator.language||navigator.browserLanguage||Qn).toUpperCase();return r.indexOf(zu)>-1?zu:Qn})():Qn;function Bu(r,t){r=r.toUpperCase(),kp[r]=new wt(t),ku[r]=t}function y_(r){if(B(r)){var t=ku[r.toUpperCase()]||{};return r===zu||r===Np?K(t):it(K(t),K(ku[Qn]),!1)}else return it(K(r),K(ku[Qn]),!1)}function __(r){return kp[r]}function x_(){return kp[Qn]}Bu(Np,m_);Bu(zu,g_);var Fu=1e3,Gu=Fu*60,$n=Gu*60,He=$n*24,Up=He*365,ws={year:"{yyyy}",month:"{MMM}",day:"{d}",hour:"{HH}:{mm}",minute:"{HH}:{mm}",second:"{HH}:{mm}:{ss}",millisecond:"{HH}:{mm}:{ss} {SSS}",none:"{yyyy}-{MM}-{dd} {HH}:{mm}:{ss} {SSS}"},Vu="{yyyy}-{MM}-{dd}",Bp={year:"{yyyy}",month:"{yyyy}-{MM}",day:Vu,hour:Vu+" "+ws.hour,minute:Vu+" "+ws.minute,second:Vu+" "+ws.second,millisecond:ws.none},zp=["year","month","day","hour","minute","second","millisecond"],Vp=["year","half-year","quarter","month","week","half-week","day","half-day","quarter-day","hour","minute","second","millisecond"];function ye(r,t){return r+="","0000".substr(0,t-r.length)+r}function Za(r){switch(r){case"half-year":case"quarter":return"month";case"week":case"half-week":return"day";case"half-day":case"quarter-day":return"hour";default:return r}}function S_(r){return r===Za(r)}function b_(r){switch(r){case"year":case"month":return"day";case"millisecond":return"millisecond";default:return"second"}}function ui(r,t,e,i){var a=re(r),n=a[Hu(e)](),o=a[Ya(e)]()+1,s=Math.floor((o-1)/3)+1,l=a[Ts(e)](),u=a["get"+(e?"UTC":"")+"Day"](),f=a[Jn(e)](),h=(f-1)%12+1,p=a[Cs(e)](),c=a[Ds(e)](),v=a[Ms(e)](),m=f>=12?"pm":"am",d=m.toUpperCase(),g=i instanceof wt?i:__(i||Uu)||x_(),y=g.getModel("time"),_=y.get("month"),x=y.get("monthAbbr"),S=y.get("dayOfWeek"),b=y.get("dayOfWeekAbbr");return(t||"").replace(/{a}/g,m+"").replace(/{A}/g,d+"").replace(/{yyyy}/g,n+"").replace(/{yy}/g,ye(n%100+"",2)).replace(/{Q}/g,s+"").replace(/{MMMM}/g,_[o-1]).replace(/{MMM}/g,x[o-1]).replace(/{MM}/g,ye(o,2)).replace(/{M}/g,o+"").replace(/{dd}/g,ye(l,2)).replace(/{d}/g,l+"").replace(/{eeee}/g,S[u]).replace(/{ee}/g,b[u]).replace(/{e}/g,u+"").replace(/{HH}/g,ye(f,2)).replace(/{H}/g,f+"").replace(/{hh}/g,ye(h+"",2)).replace(/{h}/g,h+"").replace(/{mm}/g,ye(p,2)).replace(/{m}/g,p+"").replace(/{ss}/g,ye(c,2)).replace(/{s}/g,c+"").replace(/{SSS}/g,ye(v,3)).replace(/{S}/g,v+"")}function w_(r,t,e,i,a){var n=null;if(B(e))n=e;else if(G(e))n=e(r.value,t,{level:r.level});else{var o=N({},ws);if(r.level>0)for(var s=0;s=0;--s)if(l[u]){n=l[u];break}n=n||o.none}if(k(n)){var h=r.level==null?0:r.level>=0?r.level:n.length+r.level;h=Math.min(h,n.length-1),n=n[h]}}return ui(new Date(r.value),n,a,i)}function T_(r,t){var e=re(r),i=e[Ya(t)]()+1,a=e[Ts(t)](),n=e[Jn(t)](),o=e[Cs(t)](),s=e[Ds(t)](),l=e[Ms(t)](),u=l===0,f=u&&s===0,h=f&&o===0,p=h&&n===0,c=p&&a===1,v=c&&i===1;return v?"year":c?"month":p?"day":h?"hour":f?"minute":u?"second":"millisecond"}function Fp(r,t,e){var i=et(r)?re(r):r;switch(t=t||T_(r,e),t){case"year":return i[Hu(e)]();case"half-year":return i[Ya(e)]()>=6?1:0;case"quarter":return Math.floor((i[Ya(e)]()+1)/4);case"month":return i[Ya(e)]();case"day":return i[Ts(e)]();case"half-day":return i[Jn(e)]()/24;case"hour":return i[Jn(e)]();case"minute":return i[Cs(e)]();case"second":return i[Ds(e)]();case"millisecond":return i[Ms(e)]()}}function Hu(r){return r?"getUTCFullYear":"getFullYear"}function Ya(r){return r?"getUTCMonth":"getMonth"}function Ts(r){return r?"getUTCDate":"getDate"}function Jn(r){return r?"getUTCHours":"getHours"}function Cs(r){return r?"getUTCMinutes":"getMinutes"}function Ds(r){return r?"getUTCSeconds":"getSeconds"}function Ms(r){return r?"getUTCMilliseconds":"getMilliseconds"}function C_(r){return r?"setUTCFullYear":"setFullYear"}function Gp(r){return r?"setUTCMonth":"setMonth"}function Hp(r){return r?"setUTCDate":"setDate"}function Wp(r){return r?"setUTCHours":"setHours"}function Yp(r){return r?"setUTCMinutes":"setMinutes"}function Zp(r){return r?"setUTCSeconds":"setSeconds"}function Xp(r){return r?"setUTCMilliseconds":"setMilliseconds"}function qp(r,t,e,i,a,n,o,s){var l=new yt({style:{text:r,font:t,align:e,verticalAlign:i,padding:a,rich:n,overflow:o?"truncate":null,lineHeight:s}});return l.getBoundingRect()}function As(r){if(!rs(r))return B(r)?r:"-";var t=(r+"").split(".");return t[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,"$1,")+(t.length>1?"."+t[1]:"")}function to(r,t){return r=(r||"").toLowerCase().replace(/-(.)/g,function(e,i){return i.toUpperCase()}),t&&r&&(r=r.charAt(0).toUpperCase()+r.slice(1)),r}var Ur=Oo;function Wu(r,t,e){var i="{yyyy}-{MM}-{dd} {HH}:{mm}:{ss}";function a(f){return f&&ee(f)?f:"-"}function n(f){return!!(f!=null&&!isNaN(f)&&isFinite(f))}var o=t==="time",s=r instanceof Date;if(o||s){var l=o?re(r):r;if(isNaN(+l)){if(s)return"-"}else return ui(l,i,e)}if(t==="ordinal")return _n(r)?a(r):et(r)&&n(r)?r+"":"-";var u=rr(r);return n(u)?As(u):_n(r)?a(r):typeof r=="boolean"?r+"":"-"}var D_=["a","b","c","d","e","f","g"],Kp=function(r,t){return"{"+r+(t??"")+"}"};function eo(r,t,e){k(t)||(t=[t]);var i=t.length;if(!i)return"";for(var a=t[0].$vars||[],n=0;n':'';var o=e.markerId||"markerX";return{renderMode:n,content:"{"+o+"|} ",style:a==="subItem"?{width:4,height:4,borderRadius:2,backgroundColor:i}:{width:10,height:10,borderRadius:5,backgroundColor:i}}}function M_(r,t,e){(r==="week"||r==="month"||r==="quarter"||r==="half-year"||r==="year")&&(r=`MM-dd +yyyy`);var i=re(t),a=e?"getUTC":"get",n=i[a+"FullYear"](),o=i[a+"Month"]()+1,s=i[a+"Date"](),l=i[a+"Hours"](),u=i[a+"Minutes"](),f=i[a+"Seconds"](),h=i[a+"Milliseconds"]();return r=r.replace("MM",ye(o,2)).replace("M",o).replace("yyyy",n).replace("yy",ye(n%100+"",2)).replace("dd",ye(s,2)).replace("d",s).replace("hh",ye(l,2)).replace("h",l).replace("mm",ye(u,2)).replace("m",u).replace("ss",ye(f,2)).replace("s",f).replace("SSS",ye(h,3)),r}function A_(r){return r&&r.charAt(0).toUpperCase()+r.substr(1)}function Sr(r,t){return t=t||"transparent",B(r)?r:H(r)&&r.colorStops&&(r.colorStops[0]||{}).color||t}function jp(r,t){if(t==="_blank"||t==="blank"){var e=window.open();e.opener=null,e.location.href=r}else window.open(r,t)}var qu=T,HA=["left","right","top","bottom","width","height"],Xu=[["width","left","right"],["height","top","bottom"]];function Qp(r,t,e,i,a){var n=0,o=0;i==null&&(i=1/0),a==null&&(a=1/0);var s=0;t.eachChild(function(l,u){var f=l.getBoundingRect(),h=t.childAt(u+1),p=h&&h.getBoundingRect(),c,v;if(r==="horizontal"){var m=f.width+(p?-p.x+f.x:0);c=n+m,c>i||l.newline?(n=0,c=m,o+=s+e,s=f.height):s=Math.max(s,f.height)}else{var d=f.height+(p?-p.y+f.y:0);v=o+d,v>a||l.newline?(n+=s+e,o=0,v=d,s=f.width):s=Math.max(s,f.width)}l.newline||(l.x=n,l.y=o,l.markRedraw(),r==="horizontal"?n=c+e:o=v+e)})}var Xa=Qp,TV=lt(Qp,"vertical"),CV=lt(Qp,"horizontal");function De(r,t,e){e=Ur(e||0);var i=t.width,a=t.height,n=j(r.left,i),o=j(r.top,a),s=j(r.right,i),l=j(r.bottom,a),u=j(r.width,i),f=j(r.height,a),h=e[2]+e[0],p=e[1]+e[3],c=r.aspect;switch(isNaN(u)&&(u=i-s-p-n),isNaN(f)&&(f=a-l-h-o),c!=null&&(isNaN(u)&&isNaN(f)&&(c>i/a?u=i*.8:f=a*.8),isNaN(u)&&(u=c*f),isNaN(f)&&(f=u/c)),isNaN(n)&&(n=i-s-u-p),isNaN(o)&&(o=a-l-f-h),r.left||r.right){case"center":n=i/2-u/2-e[3];break;case"right":n=i-u-p;break}switch(r.top||r.bottom){case"middle":case"center":o=a/2-f/2-e[0];break;case"bottom":o=a-f-h;break}n=n||0,o=o||0,isNaN(u)&&(u=i-p-n-(s||0)),isNaN(f)&&(f=a-h-o-(l||0));var v=new nt(n+e[3],o+e[0],u,f);return v.margin=e,v}function Ni(r){var t=r.layoutMode||r.constructor.layoutMode;return H(t)?t:t?{type:t}:null}function Br(r,t,e){var i=e&&e.ignoreSize;!k(i)&&(i=[i,i]);var a=o(Xu[0],0),n=o(Xu[1],1);u(Xu[0],r,a),u(Xu[1],r,n);function o(f,h){var p={},c=0,v={},m=0,d=2;if(qu(f,function(_){v[_]=r[_]}),qu(f,function(_){s(t,_)&&(p[_]=v[_]=t[_]),l(p,_)&&c++,l(v,_)&&m++}),i[h])return l(t,f[1])?v[f[2]]=null:l(t,f[2])&&(v[f[1]]=null),v;if(m===d||!c)return v;if(c>=d)return p;for(var g=0;g=0;l--)s=it(s,a[l],!0);i.defaultOption=s}return i.defaultOption},t.prototype.getReferringComponents=function(e,i){var a=e+"Index",n=e+"Id";return Ti(this.ecModel,e,{index:this.get(a,!0),id:this.get(n,!0)},i)},t.prototype.getBoxLayoutParams=function(){var e=this;return{left:e.get("left"),top:e.get("top"),right:e.get("right"),bottom:e.get("bottom"),width:e.get("width"),height:e.get("height")}},t.prototype.getZLevelKey=function(){return""},t.prototype.setZLevel=function(e){this.option.zlevel=e},t.protoInitialize=(function(){var e=t.prototype;e.type="component",e.id="",e.name="",e.mainType="",e.subType="",e.componentIndex=0})(),t})(wt);fu(ro,wt);Di(ro);v_(ro);d_(ro,ZA);function ZA(r){var t=[];return T(ro.getClassesByMainType(r),function(e){t=t.concat(e.dependencies||e.prototype.dependencies||[])}),t=U(t,function(e){return Pe(e).main}),r!=="dataset"&&at(t,"dataset")<=0&&t.unshift("dataset"),t}var ct=ro;var E_="";typeof navigator<"u"&&(E_=navigator.platform||"");var io="rgba(0, 0, 0, 0.2)",L_={darkMode:"auto",colorBy:"series",color:["#5470c6","#91cc75","#fac858","#ee6666","#73c0de","#3ba272","#fc8452","#9a60b4","#ea7ccc"],gradientColor:["#f6efa6","#d88273","#bf444c"],aria:{decal:{decals:[{color:io,dashArrayX:[1,0],dashArrayY:[2,5],symbolSize:1,rotation:Math.PI/6},{color:io,symbol:"circle",dashArrayX:[[8,8],[0,8,8,0]],dashArrayY:[6,0],symbolSize:.8},{color:io,dashArrayX:[1,0],dashArrayY:[4,3],rotation:-Math.PI/4},{color:io,dashArrayX:[[6,6],[0,6,6,0]],dashArrayY:[6,0]},{color:io,dashArrayX:[[1,0],[1,6]],dashArrayY:[1,0,6,0],rotation:Math.PI/4},{color:io,symbol:"triangle",dashArrayX:[[9,9],[0,9,9,0]],dashArrayY:[7,2],symbolSize:.75}]}},textStyle:{fontFamily:E_.match(/^Win/)?"Microsoft YaHei":"sans-serif",fontSize:12,fontStyle:"normal",fontWeight:"normal"},blendMode:null,stateAnimation:{duration:300,easing:"cubicOut"},animation:"auto",animationDuration:1e3,animationDurationUpdate:500,animationEasing:"cubicInOut",animationEasingUpdate:"cubicInOut",animationThreshold:2e3,progressiveThreshold:3e3,progressive:400,hoverLayerThreshold:3e3,useUTC:!1};var Ku=Y(["tooltip","label","itemName","itemId","itemGroupId","itemChildGroupId","seriesName"]),oe="original",Xt="arrayRows",fe="objectRows",We="keyedColumns",Ye="typedArray",Jp="unknown",Oe="column",fi="row";var Jt={Must:1,Might:2,Not:3},P_=ft();function I_(r){P_(r).datasetMap=Y()}function R_(r,t,e){var i={},a=ju(t);if(!a||!r)return i;var n=[],o=[],s=t.ecModel,l=P_(s).datasetMap,u=a.uid+"_"+e.seriesLayoutBy,f,h;r=r.slice(),T(r,function(m,d){var g=H(m)?m:r[d]={name:m};g.type==="ordinal"&&f==null&&(f=d,h=v(g)),i[g.name]=[]});var p=l.get(u)||l.set(u,{categoryWayDim:h,valueWayDim:0});T(r,function(m,d){var g=m.name,y=v(m);if(f==null){var _=p.valueWayDim;c(i[g],_,y),c(o,_,y),p.valueWayDim+=y}else if(f===d)c(i[g],0,y),c(n,0,y);else{var _=p.categoryWayDim;c(i[g],_,y),c(o,_,y),p.categoryWayDim+=y}});function c(m,d,g){for(var y=0;yt)return r[i];return r[e-1]}function KA(r,t,e,i,a,n,o){n=n||r;var s=t(n),l=s.paletteIdx||0,u=s.paletteNameMap=s.paletteNameMap||{};if(u.hasOwnProperty(a))return u[a];var f=o==null||!i?e:qA(i,o);if(f=f||e,!(!f||!f.length)){var h=f[l];return a&&(u[a]=h),s.paletteIdx=(l+1)%f.length,h}}function jA(r,t){t(r).paletteIdx=0,t(r).paletteNameMap={}}var Ju,Ps,B_,V_="\0_ec_inner",QA=1;var W_=(function(r){P(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.init=function(e,i,a,n,o,s){n=n||{},this.option=null,this._theme=new wt(n),this._locale=new wt(o),this._optionManager=s},t.prototype.setOption=function(e,i,a){var n=H_(i);this._optionManager.setOption(e,a,n),this._resetOption(null,n)},t.prototype.resetOption=function(e,i){return this._resetOption(e,H_(i))},t.prototype._resetOption=function(e,i){var a=!1,n=this._optionManager;if(!e||e==="recreate"){var o=n.mountOption(e==="recreate");!this.option||e==="recreate"?B_(this,o):(this.restoreData(),this._mergeOption(o,i)),a=!0}if((e==="timeline"||e==="media")&&this.restoreData(),!e||e==="recreate"||e==="timeline"){var s=n.getTimelineOption(this);s&&(a=!0,this._mergeOption(s,i))}if(!e||e==="recreate"||e==="media"){var l=n.getMediaOption(this);l.length&&T(l,function(u){a=!0,this._mergeOption(u,i)},this)}return a},t.prototype.mergeOption=function(e){this._mergeOption(e,null)},t.prototype._mergeOption=function(e,i){var a=this.option,n=this._componentsMap,o=this._componentsCount,s=[],l=Y(),u=i&&i.replaceMergeMainTypeMap;I_(this),T(e,function(h,p){h!=null&&(ct.hasClass(p)?p&&(s.push(p),l.set(p,!0)):a[p]=a[p]==null?K(h):it(a[p],h,!0))}),u&&u.each(function(h,p){ct.hasClass(p)&&!l.get(p)&&(s.push(p),l.set(p,!0))}),ct.topologicalTravel(s,ct.getAllClassMainTypes(),f,this);function f(h){var p=z_(this,h,Lt(e[h])),c=n.get(h),v=c?u&&u.get(h)?"replaceMerge":"normalMerge":"replaceAll",m=gy(c,p,v);_y(m,h,ct),a[h]=null,n.set(h,null),o.set(h,0);var d=[],g=[],y=0,_,x;T(m,function(S,b){var w=S.existing,C=S.newOption;if(!C)w&&(w.mergeOption({},this),w.optionUpdated({},!1));else{var M=h==="series",A=ct.getClass(h,S.keyInfo.subType,!M);if(!A){if(0)var D,E;return}if(h==="tooltip"){if(_)return;_=!0}if(w&&w.constructor===A)w.name=S.keyInfo.name,w.mergeOption(C,this),w.optionUpdated(C,!1);else{var L=N({componentIndex:b},S.keyInfo);w=new A(C,this,this,L),N(w,L),S.brandNew&&(w.__requireNewView=!0),w.init(C,this,this),w.optionUpdated(null,!0)}}w?(d.push(w.option),g.push(w),y++):(d.push(void 0),g.push(void 0))},this),a[h]=d,n.set(h,g),o.set(h,y),h==="series"&&Ju(this)}this._seriesIndices||Ju(this)},t.prototype.getOption=function(){var e=K(this.option);return T(e,function(i,a){if(ct.hasClass(a)){for(var n=Lt(i),o=n.length,s=!1,l=o-1;l>=0;l--)n[l]&&!On(n[l])?s=!0:(n[l]=null,!s&&o--);n.length=o,e[a]=n}}),delete e[V_],e},t.prototype.getTheme=function(){return this._theme},t.prototype.getLocaleModel=function(){return this._locale},t.prototype.setUpdatePayload=function(e){this._payload=e},t.prototype.getUpdatePayload=function(){return this._payload},t.prototype.getComponent=function(e,i){var a=this._componentsMap.get(e);if(a){var n=a[i||0];if(n)return n;if(i==null){for(var o=0;o=t:e==="max"?r<=t:r===t}function lE(r,t){return r.join(",")===t.join(",")}var Y_=aE;var br=T,Rs=H,Z_=["areaStyle","lineStyle","nodeStyle","linkStyle","chordStyle","label","labelLine"];function tv(r){var t=r&&r.itemStyle;if(t)for(var e=0,i=Z_.length;e=0;d--){var g=r[d];if(s||(v=g.data.rawIndexOf(g.stackedByDimension,c)),v>=0){var y=g.data.getByRawIndex(g.stackResultDimension,v);if(l==="all"||l==="positive"&&y>0||l==="negative"&&y<0||l==="samesign"&&p>=0&&y>0||l==="samesign"&&p<=0&&y<0){p=uy(p,y),m=y;break}}}return i[0]=p,i[1]=m,i})})}var rf=(function(){function r(t){this.data=t.data||(t.sourceFormat===We?{}:[]),this.sourceFormat=t.sourceFormat||Jp,this.seriesLayoutBy=t.seriesLayoutBy||Oe,this.startIndex=t.startIndex||0,this.dimensionsDetectedCount=t.dimensionsDetectedCount,this.metaRawOption=t.metaRawOption;var e=this.dimensionsDefine=t.dimensionsDefine;if(e)for(var i=0;im&&(m=_)}c[0]=v,c[1]=m}},a=function(){return this._data?this._data.length/this._dimSize:0};ex=(t={},t[Xt+"_"+Oe]={pure:!0,appendData:n},t[Xt+"_"+fi]={pure:!0,appendData:function(){throw new Error('Do not support appendData when set seriesLayoutBy: "row".')}},t[fe]={pure:!0,appendData:n},t[We]={pure:!0,appendData:function(o){var s=this._data;T(o,function(l,u){for(var f=s[u]||(s[u]=[]),h=0;h<(l||[]).length;h++)f.push(l[h])})}},t[oe]={appendData:n},t[Ye]={persistent:!1,pure:!0,appendData:function(o){this._data=o},clean:function(){this._offset+=this.count(),this._data=null}},t);function n(o){for(var s=0;s=0&&(m=o.interpolatedValue[d])}return m!=null?m+"":""})}},r.prototype.getRawValue=function(t,e){return ci(this.getData(e),t)},r.prototype.formatTooltip=function(t,e,i){},r})();function fv(r){var t,e;return H(r)?r.type&&(e=r):t=r,{text:t,frag:e}}function ki(r){return new bE(r)}var bE=(function(){function r(t){t=t||{},this._reset=t.reset,this._plan=t.plan,this._count=t.count,this._onDirty=t.onDirty,this._dirty=!0}return r.prototype.perform=function(t){var e=this._upstream,i=t&&t.skip;if(this._dirty&&e){var a=this.context;a.data=a.outputData=e.context.outputData}this.__pipeline&&(this.__pipeline.currentTask=this);var n;this._plan&&!i&&(n=this._plan(this.context));var o=f(this._modBy),s=this._modDataCount||0,l=f(t&&t.modBy),u=t&&t.modDataCount||0;(o!==l||s!==u)&&(n="reset");function f(y){return!(y>=1)&&(y=1),y}var h;(this._dirty||n==="reset")&&(this._dirty=!1,h=this._doReset(i)),this._modBy=l,this._modDataCount=u;var p=t&&t.step;if(e?this._dueEnd=e._outputDueEnd:this._dueEnd=this._count?this._count(this.context):1/0,this._progress){var c=this._dueIndex,v=Math.min(p!=null?this._dueIndex+p:1/0,this._dueEnd);if(!i&&(h||c1&&i>0?s:o}};return n;function o(){return t=r?null:lt},gte:function(r,t){return r>=t}},TE=(function(){function r(t,e){if(!et(e)){var i="";dt(i)}this._opFn=ox[t],this._rvalFloat=rr(e)}return r.prototype.evaluate=function(t){return et(t)?this._opFn(t,this._rvalFloat):this._opFn(rr(t),this._rvalFloat)},r})(),sf=(function(){function r(t,e){var i=t==="desc";this._resultLT=i?1:-1,e==null&&(e=i?"min":"max"),this._incomparable=e==="min"?-1/0:1/0}return r.prototype.evaluate=function(t,e){var i=et(t)?t:rr(t),a=et(e)?e:rr(e),n=isNaN(i),o=isNaN(a);if(n&&(i=this._incomparable),o&&(a=this._incomparable),n&&o){var s=B(t),l=B(e);s&&(i=l?t:0),l&&(a=s?e:0)}return ia?-this._resultLT:0},r})();var CE=(function(){function r(t,e){this._rval=e,this._isEQ=t,this._rvalTypeof=typeof e,this._rvalFloat=rr(e)}return r.prototype.evaluate=function(t){var e=t===this._rval;if(!e){var i=typeof t;i!==this._rvalTypeof&&(i==="number"||this._rvalTypeof==="number")&&(e=rr(t)===this._rvalFloat)}return this._isEQ?e:!e},r})();function sx(r,t){return r==="eq"||r==="ne"?new CE(r==="eq",t):qt(ox,r)?new TE(r,t):null}var DE=(function(){function r(){}return r.prototype.getRawData=function(){throw new Error("not supported")},r.prototype.getRawDataItem=function(t){throw new Error("not supported")},r.prototype.cloneRawData=function(){},r.prototype.getDimensionInfo=function(t){},r.prototype.cloneAllDimensionInfo=function(){},r.prototype.count=function(){},r.prototype.retrieveValue=function(t,e){},r.prototype.retrieveValueFromItem=function(t,e){},r.prototype.convertValue=function(t,e){return pi(t,e)},r})();function ME(r,t){var e=new DE,i=r.data,a=e.sourceFormat=r.sourceFormat,n=r.startIndex,o="";r.seriesLayoutBy!==Oe&&dt(o);var s=[],l={},u=r.dimensionsDefine;if(u)T(u,function(m,d){var g=m.name,y={index:d,name:g,displayName:m.displayName};if(s.push(y),g!=null){var _="";qt(l,g)&&dt(_),l[g]=y}});else for(var f=0;f65535?RE:OE}function lo(){return[1/0,-1/0]}function NE(r){var t=r.constructor;return t===Array?r.slice():new t(r)}function cx(r,t,e,i,a){var n=px[e||"float"];if(a){var o=r[t],s=o&&o.length;if(s!==i){for(var l=new n(i),u=0;ud[1]&&(d[1]=m)}return this._rawCount=this._count=l,{start:s,end:l}},r.prototype._initDataFromProvider=function(t,e,i){for(var a=this._provider,n=this._chunks,o=this._dimensions,s=o.length,l=this._rawExtent,u=U(o,function(y){return y.property}),f=0;fg[1]&&(g[1]=d)}}!a.persistent&&a.clean&&a.clean(),this._rawCount=this._count=e,this._extent=[]},r.prototype.count=function(){return this._count},r.prototype.get=function(t,e){if(!(e>=0&&e=0&&e=this._rawCount||t<0)return-1;if(!this._indices)return t;var e=this._indices,i=e[t];if(i!=null&&it)n=o-1;else return o}return-1},r.prototype.indicesOfNearest=function(t,e,i){var a=this._chunks,n=a[t],o=[];if(!n)return o;i==null&&(i=1/0);for(var s=1/0,l=-1,u=0,f=0,h=this.count();f=0&&l<0)&&(s=v,l=c,u=0),c===l&&(o[u++]=f))}return o.length=u,o},r.prototype.getIndices=function(){var t,e=this._indices;if(e){var i=e.constructor,a=this._count;if(i===Array){t=new i(a);for(var n=0;n=h&&y<=p||isNaN(y))&&(l[u++]=m),m++}v=!0}else if(n===2){for(var d=c[a[0]],_=c[a[1]],x=t[a[1]][0],S=t[a[1]][1],g=0;g=h&&y<=p||isNaN(y))&&(b>=x&&b<=S||isNaN(b))&&(l[u++]=m),m++}v=!0}}if(!v)if(n===1)for(var g=0;g=h&&y<=p||isNaN(y))&&(l[u++]=w)}else for(var g=0;gt[A][1])&&(C=!1)}C&&(l[u++]=e.getRawIndex(g))}return ug[1]&&(g[1]=d)}}}},r.prototype.lttbDownSample=function(t,e){var i=this.clone([t],!0),a=i._chunks,n=a[t],o=this.count(),s=0,l=Math.floor(1/e),u=this.getRawIndex(0),f,h,p,c=new(so(this._rawCount))(Math.min((Math.ceil(o/l)+2)*2,o));c[s++]=u;for(var v=1;vf&&(f=h,p=x)}D>0&&Ds&&(m=s-f);for(var d=0;dv&&(v=y,c=f+d)}var _=this.getRawIndex(h),x=this.getRawIndex(c);hf-v&&(l=f-v,s.length=l);for(var m=0;mh[1]&&(h[1]=g),p[c++]=y}return n._count=c,n._indices=p,n._updateGetRawIdx(),n},r.prototype.each=function(t,e){if(this._count)for(var i=t.length,a=this._chunks,n=0,o=this.count();nl&&(l=h)}return o=[s,l],this._extent[t]=o,o},r.prototype.getRawDataItem=function(t){var e=this.getRawIndex(t);if(this._provider.persistent)return this._provider.getItem(e);for(var i=[],a=this._chunks,n=0;n=0?this._indices[t]:-1},r.prototype._updateGetRawIdx=function(){this.getRawIndex=this._indices?this._getRawIdx:this._getRawIdxIdentity},r.internalField=(function(){function t(e,i,a,n){return pi(e[n],this._dimensions[n])}cv={arrayRows:t,objectRows:function(e,i,a,n){return pi(e[i],this._dimensions[n])},keyedColumns:t,original:function(e,i,a,n){var o=e&&(e.value==null?e:e.value);return pi(o instanceof Array?o[n]:o,this._dimensions[n])},typedArray:function(e,i,a,n){return e[n]}}})(),r})(),zs=kE;var ff=(function(){function r(t){this._sourceList=[],this._storeList=[],this._upstreamSignList=[],this._versionSignBase=0,this._dirty=!0,this._sourceHost=t}return r.prototype.dirty=function(){this._setLocalSource([],[]),this._storeList=[],this._dirty=!0},r.prototype._setLocalSource=function(t,e){this._sourceList=t,this._upstreamSignList=e,this._versionSignBase++,this._versionSignBase>9e10&&(this._versionSignBase=0)},r.prototype._getVersionSign=function(){return this._sourceHost.uid+"_"+this._versionSignBase},r.prototype.prepareSource=function(){this._isDirty()&&(this._createSource(),this._dirty=!1)},r.prototype._createSource=function(){this._setLocalSource([],[]);var t=this._sourceHost,e=this._getUpstreamSourceManagers(),i=!!e.length,a,n;if(uf(t)){var o=t,s=void 0,l=void 0,u=void 0;if(i){var f=e[0];f.prepareSource(),u=f.getSource(),s=u.data,l=u.sourceFormat,n=[f._getVersionSign()]}else s=o.get("data",!0),l=Nt(s)?Ye:oe,n=[];var h=this._getSourceMetaRawOption()||{},p=u&&u.metaRawOption||{},c=Q(h.seriesLayoutBy,p.seriesLayoutBy)||null,v=Q(h.sourceHeader,p.sourceHeader),m=Q(h.dimensions,p.dimensions),d=c!==p.seriesLayoutBy||!!v!=!!p.sourceHeader||m;a=d?[Ns(s,{seriesLayoutBy:c,sourceHeader:v,dimensions:m},l)]:[]}else{var g=t;if(i){var y=this._applyTransform(e);a=y.sourceList,n=y.upstreamSignList}else{var _=g.get("source",!0);a=[Ns(_,this._getSourceMetaRawOption(),null)],n=[]}}this._setLocalSource(a,n)},r.prototype._applyTransform=function(t){var e=this._sourceHost,i=e.get("transform",!0),a=e.get("fromTransformResult",!0);if(a!=null){var n="";t.length!==1&&vx(n)}var o,s=[],l=[];return T(t,function(u){u.prepareSource();var f=u.getSource(a||0),h="";a!=null&&!f&&vx(h),s.push(f),l.push(u._getVersionSign())}),i?o=fx(i,s,{datasetIndex:e.componentIndex}):a!=null&&(o=[tx(s[0])]),{sourceList:o,upstreamSignList:l}},r.prototype._isDirty=function(){if(this._dirty)return!0;for(var t=this._getUpstreamSourceManagers(),e=0;e1||e>0&&!r.noHeader;return T(r.blocks,function(a){var n=yx(a);n>=t&&(t=n+ +(i&&(!n||dv(a)&&!a.noHeader)))}),t}return 0}function VE(r,t,e,i){var a=t.noHeader,n=GE(yx(t)),o=[],s=t.blocks||[];te(!s||k(s)),s=s||[];var l=r.orderMode;if(t.sortBlocks&&l){s=s.slice();var u={valueAsc:"asc",valueDesc:"desc"};if(qt(u,l)){var f=new sf(u[l],null);s.sort(function(m,d){return f.evaluate(m.sortParam,d.sortParam)})}else l==="seriesDesc"&&s.reverse()}T(s,function(m,d){var g=t.valueFormatter,y=gx(m)(g?N(N({},r),{valueFormatter:g}):r,m,d>0?n.html:0,i);y!=null&&o.push(y)});var h=r.renderMode==="richText"?o.join(n.richText):mv(i,o.join(""),a?e:n.html);if(a)return h;var p=Wu(t.header,"ordinal",r.useUTC),c=mx(i,r.renderMode).nameStyle,v=dx(i);return r.renderMode==="richText"?_x(r,p,c)+n.richText+h:mv(i,'
'+jt(p)+"
"+h,e)}function FE(r,t,e,i){var a=r.renderMode,n=t.noName,o=t.noValue,s=!t.markerType,l=t.name,u=r.useUTC,f=t.valueFormatter||r.valueFormatter||function(x){return x=k(x)?x:[x],U(x,function(S,b){return Wu(S,k(c)?c[b]:c,u)})};if(!(n&&o)){var h=s?"":r.markupStyleCreator.makeTooltipMarker(t.markerType,t.markerColor||"#333",a),p=n?"":Wu(l,"ordinal",u),c=t.valueType,v=o?[]:f(t.value,t.dataIndex),m=!s||!n,d=!s&&n,g=mx(i,a),y=g.nameStyle,_=g.valueStyle;return a==="richText"?(s?"":h)+(n?"":_x(r,p,y))+(o?"":YE(r,v,m,d,_)):mv(i,(s?"":h)+(n?"":HE(p,!s,y))+(o?"":WE(v,m,d,_)),e)}}function gv(r,t,e,i,a,n){if(r){var o=gx(r),s={useUTC:a,renderMode:e,orderMode:i,markupStyleCreator:t,valueFormatter:r.valueFormatter};return o(s,r,0,n)}}function GE(r){return{html:UE[r],richText:BE[r]}}function mv(r,t,e){var i='
',a="margin: "+e+"px 0 0",n=dx(r);return'
'+t+i+"
"}function HE(r,t,e){var i=t?"margin-left:2px":"";return''+jt(r)+""}function WE(r,t,e,i){var a=e?"10px":"20px",n=t?"float:right;margin-left:"+a:"";return r=k(r)?r:[r],''+U(r,function(o){return jt(o)}).join("  ")+""}function _x(r,t,e){return r.markupStyleCreator.wrapRichTextStyle(t,e)}function YE(r,t,e,i,a){var n=[a],o=i?10:20;return e&&n.push({padding:[0,0,0,o],align:"right"}),r.markupStyleCreator.wrapRichTextStyle(k(t)?t.join(" "):t,n)}function hf(r,t){var e=r.getData().getItemVisual(t,"style"),i=e[r.visualDrawType];return Sr(i)}function cf(r,t){var e=r.get("padding");return e??(t==="richText"?[8,10]:10)}var pf=(function(){function r(){this.richTextStyles={},this._nextStyleNameId=su()}return r.prototype._generateStyleName=function(){return"__EC_aUTo_"+this._nextStyleNameId++},r.prototype.makeTooltipMarker=function(t,e,i){var a=i==="richText"?this._generateStyleName():null,n=Yu({color:e,type:t,renderMode:i,markerId:a});return B(n)?n:(this.richTextStyles[a]=n.style,n.content)},r.prototype.wrapRichTextStyle=function(t,e){var i={};k(e)?T(e,function(n){return N(i,n)}):N(i,e);var a=this._generateStyleName();return this.richTextStyles[a]=i,"{"+a+"|"+t+"}"},r})();function xx(r){var t=r.series,e=r.dataIndex,i=r.multipleSeries,a=t.getData(),n=a.mapDimensionsAll("defaultedTooltip"),o=n.length,s=t.getRawValue(e),l=k(s),u=hf(t,e),f,h,p,c;if(o>1||l&&!o){var v=ZE(s,t,e,n,u);f=v.inlineValues,h=v.inlineValueTypes,p=v.blocks,c=v.inlineValues[0]}else if(o){var m=a.getDimensionInfo(n[0]);c=f=ci(a,e,n[0]),h=m.type}else c=f=l?s[0]:s;var d=Nn(t),g=d&&t.name||"",y=a.getName(e),_=i?g:y;return Ze("section",{header:g,noHeader:i||!d,sortParam:c,blocks:[Ze("nameValue",{markerType:"item",markerColor:u,name:_,noName:!ee(_),value:f,valueType:h,dataIndex:e})].concat(p||[])})}function ZE(r,t,e,i,a){var n=t.getData(),o=ce(r,function(h,p,c){var v=n.getDimensionInfo(c);return h=h||v&&v.tooltip!==!1&&v.displayName!=null},!1),s=[],l=[],u=[];i.length?T(i,function(h){f(ci(n,e,h),h)}):T(r,f);function f(h,p){var c=n.getDimensionInfo(p);!c||c.otherDims.tooltip===!1||(o?u.push(Ze("nameValue",{markerType:"subItem",markerColor:a,name:c.displayName,value:h,valueType:c.type})):(s.push(h),l.push(c.type)))}return{inlineValues:s,inlineValueTypes:l,blocks:u}}var zi=ft();function vf(r,t){return r.getName(t)||r.getId(t)}var XE="__universalTransitionEnabled",df=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e._selectedDataIndicesMap={},e}return t.prototype.init=function(e,i,a){this.seriesIndex=this.componentIndex,this.dataTask=ki({count:KE,reset:jE}),this.dataTask.context={model:this},this.mergeDefaultAndTheme(e,a);var n=zi(this).sourceManager=new ff(this);n.prepareSource();var o=this.getInitialData(e,a);bx(o,this),this.dataTask.context.data=o,zi(this).dataBeforeProcessed=o,Sx(this),this._initSelectedMapFromData(o)},t.prototype.mergeDefaultAndTheme=function(e,i){var a=Ni(this),n=a?Vr(e):{},o=this.subType;ct.hasClass(o)&&(o+="Series"),it(e,i.getTheme().get(this.subType)),it(e,this.getDefaultOption()),ba(e,"label",["show"]),this.fillDataTextStyle(e.data),a&&Br(e,n,a)},t.prototype.mergeOption=function(e,i){e=it(this.option,e,!0),this.fillDataTextStyle(e.data);var a=Ni(this);a&&Br(this.option,e,a);var n=zi(this).sourceManager;n.dirty(),n.prepareSource();var o=this.getInitialData(e,i);bx(o,this),this.dataTask.dirty(),this.dataTask.context.data=o,zi(this).dataBeforeProcessed=o,Sx(this),this._initSelectedMapFromData(o)},t.prototype.fillDataTextStyle=function(e){if(e&&!Nt(e))for(var i=["show"],a=0;athis.getShallow("animationThreshold")&&(i=!1),!!i},t.prototype.restoreData=function(){this.dataTask.dirty()},t.prototype.getColorFromPalette=function(e,i,a){var n=this.ecModel,o=Ls.prototype.getColorFromPalette.call(this,e,i,a);return o||(o=n.getColorFromPalette(e,i,a)),o},t.prototype.coordDimToDataDim=function(e){return this.getRawData().mapDimensionsAll(e)},t.prototype.getProgressive=function(){return this.get("progressive")},t.prototype.getProgressiveThreshold=function(){return this.get("progressiveThreshold")},t.prototype.select=function(e,i){this._innerSelect(this.getData(i),e)},t.prototype.unselect=function(e,i){var a=this.option.selectedMap;if(a){var n=this.option.selectedMode,o=this.getData(i);if(n==="series"||a==="all"){this.option.selectedMap={},this._selectedDataIndicesMap={};return}for(var s=0;s=0&&a.push(o)}return a},t.prototype.isSelected=function(e,i){var a=this.option.selectedMap;if(!a)return!1;var n=this.getData(i);return(a==="all"||a[vf(n,e)])&&!n.getItemModel(e).get(["select","disabled"])},t.prototype.isUniversalTransitionEnabled=function(){if(this[XE])return!0;var e=this.option.universalTransition;return e?e===!0?!0:e&&e.enabled:!1},t.prototype._innerSelect=function(e,i){var a,n,o=this.option,s=o.selectedMode,l=i.length;if(!(!s||!l)){if(s==="series")o.selectedMap="all";else if(s==="multiple"){H(o.selectedMap)||(o.selectedMap={});for(var u=o.selectedMap,f=0;f0&&this._innerSelect(e,i)}},t.registerClass=function(e){return ct.registerClass(e)},t.protoInitialize=(function(){var e=t.prototype;e.type="series.__base__",e.seriesIndex=0,e.ignoreStyleOnData=!1,e.hasSymbolVisual=!1,e.defaultSymbol="circle",e.visualStyleAccessPath="itemStyle",e.visualDrawType="fill"})(),t})(ct);Ut(df,ks);Ut(df,Ls);fu(df,ct);function Sx(r){var t=r.name;Nn(r)||(r.name=qE(r)||t)}function qE(r){var t=r.getRawData(),e=t.mapDimensionsAll("seriesName"),i=[];return T(e,function(a){var n=t.getDimensionInfo(a);n.displayName&&i.push(n.displayName)}),i.join(" ")}function KE(r){return r.model.getRawData().count()}function jE(r){var t=r.model;return t.setData(t.getRawData().cloneShallow()),QE}function QE(r,t){t.outputData&&r.end>t.outputData.count()&&t.model.getRawData().cloneShallow(t.outputData)}function bx(r,t){T(Gh(r.CHANGABLE_METHODS,r.DOWNSAMPLE_METHODS),function(e){r.wrapMethod(e,lt(JE,t))})}function JE(r,t){var e=yv(r);return e&&e.setOutputEnd((t||this).count()),t}function yv(r){var t=(r.ecModel||{}).scheduler,e=t&&t.getPipeline(r.uid);if(e){var i=e.currentTask;if(i){var a=i.agentStubMap;a&&(i=a.get(r.uid))}return i}}var kt=df;var _v=(function(){function r(){this.group=new ut,this.uid=Ri("viewComponent")}return r.prototype.init=function(t,e){},r.prototype.render=function(t,e,i,a){},r.prototype.dispose=function(t,e){},r.prototype.updateView=function(t,e,i,a){},r.prototype.updateLayout=function(t,e,i,a){},r.prototype.updateVisual=function(t,e,i,a){},r.prototype.toggleBlurSeries=function(t,e,i){},r.prototype.eachRendered=function(t){var e=this.group;e&&e.traverse(t)},r})();kn(_v);Di(_v);var At=_v;function Qa(){var r=ft();return function(t){var e=r(t),i=t.pipelineContext,a=!!e.large,n=!!e.progressiveRender,o=e.large=!!(i&&i.large),s=e.progressiveRender=!!(i&&i.progressiveRender);return(a!==o||n!==s)&&"reset"}}var Dx=ft(),$E=Qa(),xv=(function(){function r(){this.group=new ut,this.uid=Ri("viewChart"),this.renderTask=ki({plan:tL,reset:eL}),this.renderTask.context={view:this}}return r.prototype.init=function(t,e){},r.prototype.render=function(t,e,i,a){},r.prototype.highlight=function(t,e,i,a){var n=t.getData(a&&a.dataType);n&&Cx(n,a,"emphasis")},r.prototype.downplay=function(t,e,i,a){var n=t.getData(a&&a.dataType);n&&Cx(n,a,"normal")},r.prototype.remove=function(t,e){this.group.removeAll()},r.prototype.dispose=function(t,e){},r.prototype.updateView=function(t,e,i,a){this.render(t,e,i,a)},r.prototype.updateLayout=function(t,e,i,a){this.render(t,e,i,a)},r.prototype.updateVisual=function(t,e,i,a){this.render(t,e,i,a)},r.prototype.eachRendered=function(t){li(this.group,t)},r.markUpdateMethod=function(t,e){Dx(t).updateMethod=e},r.protoInitialize=(function(){var t=r.prototype;t.type="chart"})(),r})();function Tx(r,t,e){r&&ms(r)&&(t==="emphasis"?ai:ni)(r,e)}function Cx(r,t,e){var i=ir(r,t),a=t&&t.highlightKey!=null?D0(t.highlightKey):null;i!=null?T(Lt(i),function(n){Tx(r.getItemGraphicEl(n),e,a)}):r.eachItemGraphicEl(function(n){Tx(n,e,a)})}kn(xv,["dispose"]);Di(xv);function tL(r){return $E(r.model)}function eL(r){var t=r.model,e=r.ecModel,i=r.api,a=r.payload,n=t.pipelineContext.progressiveRender,o=r.view,s=a&&Dx(a).updateMethod,l=n?"incrementalPrepareRender":s&&o[s]?s:"render";return l!=="render"&&o[l](t,e,i,a),rL[l]}var rL={incrementalPrepareRender:{progress:function(r,t){t.view.incrementalRender(r,t.model,t.ecModel,t.api,t.payload)}},render:{forceFirstProgress:!0,progress:function(r,t){t.view.render(t.model,t.ecModel,t.api,t.payload)}}},Pt=xv;var mf="\0__throttleOriginMethod",Mx="\0__throttleRate",Ax="\0__throttleType";function Ja(r,t,e){var i,a=0,n=0,o=null,s,l,u,f;t=t||0;function h(){n=new Date().getTime(),o=null,r.apply(l,u||[])}var p=function(){for(var c=[],v=0;v=0?h():o=setTimeout(h,-s),a=i};return p.clear=function(){o&&(clearTimeout(o),o=null)},p.debounceNextCall=function(c){f=c},p}function Ui(r,t,e,i){var a=r[t];if(a){var n=a[mf]||a,o=a[Ax],s=a[Mx];if(s!==e||o!==i){if(e==null||!i)return r[t]=n;a=r[t]=Ja(n,e,i==="debounce"),a[mf]=n,a[Ax]=i,a[Mx]=e}return a}}function $a(r,t){var e=r[t];e&&e[mf]&&(e.clear&&e.clear(),r[t]=e[mf])}var Ex=ft(),Lx={itemStyle:Pr(Rp,!0),lineStyle:Pr(Ip,!0)},iL={lineStyle:"stroke",itemStyle:"fill"};function Px(r,t){var e=r.visualStyleMapper||Lx[t];return e||(console.warn("Unknown style type '"+t+"'."),Lx.itemStyle)}function Ix(r,t){var e=r.visualDrawType||iL[t];return e||(console.warn("Unknown style type '"+t+"'."),"fill")}var Rx={createOnAllSeries:!0,performRawSeries:!0,reset:function(r,t){var e=r.getData(),i=r.visualStyleAccessPath||"itemStyle",a=r.getModel(i),n=Px(r,i),o=n(a),s=a.getShallow("decal");s&&(e.setVisual("decal",s),s.dirty=!0);var l=Ix(r,i),u=o[l],f=G(u)?u:null,h=o.fill==="auto"||o.stroke==="auto";if(!o[l]||f||h){var p=r.getColorFromPalette(r.name,null,t.getSeriesCount());o[l]||(o[l]=p,e.setVisual("colorFromPalette",!0)),o.fill=o.fill==="auto"||G(o.fill)?p:o.fill,o.stroke=o.stroke==="auto"||G(o.stroke)?p:o.stroke}if(e.setVisual("style",o),e.setVisual("drawType",l),!t.isSeriesFiltered(r)&&f)return e.setVisual("colorFromPalette",!1),{dataEach:function(c,v){var m=r.getDataParams(v),d=N({},o);d[l]=f(m),c.setItemVisual(v,"style",d)}}}},Us=new wt,Ox={createOnAllSeries:!0,performRawSeries:!0,reset:function(r,t){if(!(r.ignoreStyleOnData||t.isSeriesFiltered(r))){var e=r.getData(),i=r.visualStyleAccessPath||"itemStyle",a=Px(r,i),n=e.getVisual("drawType");return{dataEach:e.hasItemOption?function(o,s){var l=o.getRawDataItem(s);if(l&&l[i]){Us.option=l[i];var u=a(Us),f=o.ensureUniqueItemVisual(s,"style");N(f,u),Us.option.decal&&(o.setItemVisual(s,"decal",Us.option.decal),Us.option.decal.dirty=!0),n in u&&o.setItemVisual(s,"colorFromPalette",!1)}}:null}}}},Nx={performRawSeries:!0,overallReset:function(r){var t=Y();r.eachSeries(function(e){var i=e.getColorBy();if(!e.isColorBySeries()){var a=e.type+"-"+i,n=t.get(a);n||(n={},t.set(a,n)),Ex(e).scope=n}}),r.eachSeries(function(e){if(!(e.isColorBySeries()||r.isSeriesFiltered(e))){var i=e.getRawData(),a={},n=e.getData(),o=Ex(e).scope,s=e.visualStyleAccessPath||"itemStyle",l=Ix(e,s);n.each(function(u){var f=n.getRawIndex(u);a[f]=u}),i.each(function(u){var f=a[u],h=n.getItemVisual(f,"colorFromPalette");if(h){var p=n.ensureUniqueItemVisual(f,"style"),c=i.getName(u)||u+"",v=i.count();p[l]=e.getColorFromPalette(c,o,v)}})}})}};var gf=Math.PI;function bv(r,t){t=t||{},q(t,{text:"loading",textColor:"#000",fontSize:12,fontWeight:"normal",fontStyle:"normal",fontFamily:"sans-serif",maskColor:"rgba(255, 255, 255, 0.8)",showSpinner:!0,color:"#5470c6",spinnerRadius:10,lineWidth:5,zlevel:0});var e=new ut,i=new mt({style:{fill:t.maskColor},zlevel:t.zlevel,z:1e4});e.add(i);var a=new yt({style:{text:t.text,fill:t.textColor,fontSize:t.fontSize,fontWeight:t.fontWeight,fontStyle:t.fontStyle,fontFamily:t.fontFamily},zlevel:t.zlevel,z:10001}),n=new mt({style:{fill:"none"},textContent:a,textConfig:{position:"right",distance:10},zlevel:t.zlevel,z:10001});e.add(n);var o;return t.showSpinner&&(o=new Na({shape:{startAngle:-gf/2,endAngle:-gf/2+.1,r:t.spinnerRadius},style:{stroke:t.color,lineCap:"round",lineWidth:t.lineWidth},zlevel:t.zlevel,z:10001}),o.animateShape(!0).when(1e3,{endAngle:gf*3/2}).start("circularInOut"),o.animateShape(!0).when(1e3,{startAngle:gf*3/2}).delay(300).start("circularInOut"),e.add(o)),e.resize=function(){var s=a.getBoundingRect().width,l=t.showSpinner?t.spinnerRadius:0,u=(r.getWidth()-l*2-(t.showSpinner&&s?10:0)-s)/2-(t.showSpinner&&s?0:5+s/2)+(t.showSpinner?0:s/2)+(s?0:l),f=r.getHeight()/2;t.showSpinner&&o.setShape({cx:u,cy:f}),n.setShape({x:u-l,y:f-l,width:l*2,height:l*2}),i.setShape({x:0,y:0,width:r.getWidth(),height:r.getHeight()})},e.resize(),e}var aL=(function(){function r(t,e,i,a){this._stageTaskMap=Y(),this.ecInstance=t,this.api=e,i=this._dataProcessorHandlers=i.slice(),a=this._visualHandlers=a.slice(),this._allHandlers=i.concat(a)}return r.prototype.restoreData=function(t,e){t.restoreData(e),this._stageTaskMap.each(function(i){var a=i.overallTask;a&&a.dirty()})},r.prototype.getPerformArgs=function(t,e){if(t.__pipeline){var i=this._pipelineMap.get(t.__pipeline.id),a=i.context,n=!e&&i.progressiveEnabled&&(!a||a.progressiveRender)&&t.__idxInPipeline>i.blockIndex,o=n?i.step:null,s=a&&a.modDataCount,l=s!=null?Math.ceil(s/o):null;return{step:o,modBy:l,modDataCount:s}}},r.prototype.getPipeline=function(t){return this._pipelineMap.get(t)},r.prototype.updateStreamModes=function(t,e){var i=this._pipelineMap.get(t.uid),a=t.getData(),n=a.count(),o=i.progressiveEnabled&&e.incrementalPrepareRender&&n>=i.threshold,s=t.get("large")&&n>=t.get("largeThreshold"),l=t.get("progressiveChunkMode")==="mod"?n:null;t.pipelineContext=i.context={progressiveRender:o,modDataCount:l,large:s}},r.prototype.restorePipelines=function(t){var e=this,i=e._pipelineMap=Y();t.eachSeries(function(a){var n=a.getProgressive(),o=a.uid;i.set(o,{id:o,head:null,tail:null,threshold:a.getProgressiveThreshold(),progressiveEnabled:n&&!(a.preventIncremental&&a.preventIncremental()),blockIndex:-1,step:Math.round(n||700),count:0}),e._pipe(a,a.dataTask)})},r.prototype.prepareStageTasks=function(){var t=this._stageTaskMap,e=this.api.getModel(),i=this.api;T(this._allHandlers,function(a){var n=t.get(a.uid)||t.set(a.uid,{}),o="";te(!(a.reset&&a.overallReset),o),a.reset&&this._createSeriesStageTask(a,n,e,i),a.overallReset&&this._createOverallStageTask(a,n,e,i)},this)},r.prototype.prepareView=function(t,e,i,a){var n=t.renderTask,o=n.context;o.model=e,o.ecModel=i,o.api=a,n.__block=!t.incrementalPrepareRender,this._pipe(e,n)},r.prototype.performDataProcessorTasks=function(t,e){this._performStageTasks(this._dataProcessorHandlers,t,e,{block:!0})},r.prototype.performVisualTasks=function(t,e,i){this._performStageTasks(this._visualHandlers,t,e,i)},r.prototype._performStageTasks=function(t,e,i,a){a=a||{};var n=!1,o=this;T(t,function(l,u){if(!(a.visualType&&a.visualType!==l.visualType)){var f=o._stageTaskMap.get(l.uid),h=f.seriesTaskMap,p=f.overallTask;if(p){var c,v=p.agentStubMap;v.each(function(d){s(a,d)&&(d.dirty(),c=!0)}),c&&p.dirty(),o.updatePayload(p,i);var m=o.getPerformArgs(p,a.block);v.each(function(d){d.perform(m)}),p.perform(m)&&(n=!0)}else h&&h.each(function(d,g){s(a,d)&&d.dirty();var y=o.getPerformArgs(d,a.block);y.skip=!l.performRawSeries&&e.isSeriesFiltered(d.context.model),o.updatePayload(d,i),d.perform(y)&&(n=!0)})}});function s(l,u){return l.setDirty&&(!l.dirtyMap||l.dirtyMap.get(u.__pipeline.id))}this.unfinished=n||this.unfinished},r.prototype.performSeriesTasks=function(t){var e;t.eachSeries(function(i){e=i.dataTask.perform()||e}),this.unfinished=e||this.unfinished},r.prototype.plan=function(){this._pipelineMap.each(function(t){var e=t.tail;do{if(e.__block){t.blockIndex=e.__idxInPipeline;break}e=e.getUpstream()}while(e)})},r.prototype.updatePayload=function(t,e){e!=="remain"&&(t.context.payload=e)},r.prototype._createSeriesStageTask=function(t,e,i,a){var n=this,o=e.seriesTaskMap,s=e.seriesTaskMap=Y(),l=t.seriesType,u=t.getTargetSeries;t.createOnAllSeries?i.eachRawSeries(f):l?i.eachRawSeriesByType(l,f):u&&u(i,a).each(f);function f(h){var p=h.uid,c=s.set(p,o&&o.get(p)||ki({plan:uL,reset:fL,count:cL}));c.context={model:h,ecModel:i,api:a,useClearVisual:t.isVisual&&!t.isLayout,plan:t.plan,reset:t.reset,scheduler:n},n._pipe(h,c)}},r.prototype._createOverallStageTask=function(t,e,i,a){var n=this,o=e.overallTask=e.overallTask||ki({reset:nL});o.context={ecModel:i,api:a,overallReset:t.overallReset,scheduler:n};var s=o.agentStubMap,l=o.agentStubMap=Y(),u=t.seriesType,f=t.getTargetSeries,h=!0,p=!1,c="";te(!t.createOnAllSeries,c),u?i.eachRawSeriesByType(u,v):f?f(i,a).each(v):(h=!1,T(i.getSeries(),v));function v(m){var d=m.uid,g=l.set(d,s&&s.get(d)||(p=!0,ki({reset:oL,onDirty:lL})));g.context={model:m,overallProgress:h},g.agent=o,g.__block=h,n._pipe(m,g)}p&&o.dirty()},r.prototype._pipe=function(t,e){var i=t.uid,a=this._pipelineMap.get(i);!a.head&&(a.head=e),a.tail&&a.tail.pipe(e),a.tail=e,e.__idxInPipeline=a.count++,e.__pipeline=a},r.wrapStageHandler=function(t,e){return G(t)&&(t={overallReset:t,seriesType:pL(t)}),t.uid=Ri("stageHandler"),e&&(t.visualType=e),t},r})();function nL(r){r.overallReset(r.ecModel,r.api,r.payload)}function oL(r){return r.overallProgress&&sL}function sL(){this.agent.dirty(),this.getDownstream().dirty()}function lL(){this.agent&&this.agent.dirty()}function uL(r){return r.plan?r.plan(r.model,r.ecModel,r.api,r.payload):null}function fL(r){r.useClearVisual&&r.data.clearAllVisual();var t=r.resetDefines=Lt(r.reset(r.model,r.ecModel,r.api,r.payload));return t.length>1?U(t,function(e,i){return kx(i)}):hL}var hL=kx(0);function kx(r){return function(t,e){var i=e.data,a=e.resetDefines[r];if(a&&a.dataEach)for(var n=t.start;n0&&c===u.length-p.length){var v=u.slice(0,c);v!=="data"&&(e.mainType=v,e[p.toLowerCase()]=l,f=!0)}}s.hasOwnProperty(u)&&(i[u]=l,f=!0),f||(a[u]=l)})}return{cptQuery:e,dataQuery:i,otherQuery:a}},r.prototype.filter=function(t,e){var i=this.eventInfo;if(!i)return!0;var a=i.targetEl,n=i.packedEvent,o=i.model,s=i.view;if(!o||!s)return!0;var l=e.cptQuery,u=e.dataQuery;return f(l,o,"mainType")&&f(l,o,"subType")&&f(l,o,"index","componentIndex")&&f(l,o,"name")&&f(l,o,"id")&&f(u,n,"name")&&f(u,n,"dataIndex")&&f(u,n,"dataType")&&(!s.filterForExposedEvent||s.filterForExposedEvent(t,e.otherQuery,a,n));function f(h,p,c,v){return h[c]==null||p[v||c]===h[c]}},r.prototype.afterTrigger=function(){this.eventInfo=null},r})();var Tv=["symbol","symbolSize","symbolRotate","symbolOffset"],Zx=Tv.concat(["symbolKeepAspect"]),Xx={createOnAllSeries:!0,performRawSeries:!0,reset:function(r,t){var e=r.getData();if(r.legendIcon&&e.setVisual("legendIcon",r.legendIcon),!r.hasSymbolVisual)return;for(var i={},a={},n=!1,o=0;o=0&&an(l)?l:.5;var u=r.createRadialGradient(o,s,0,o,s,l);return u}function Fs(r,t,e){for(var i=t.type==="radial"?DL(r,t,e):CL(r,t,e),a=t.colorStops,n=0;n0)?null:r==="dashed"?[4*t,2*t]:r==="dotted"?[t]:et(r)?[r]:k(r)?r:null}function Cv(r){var t=r.style,e=t.lineDash&&t.lineWidth>0&&ML(t.lineDash,t.lineWidth),i=t.lineDashOffset;if(e){var a=t.strokeNoScale&&r.getLineScale?r.getLineScale():1;a&&a!==1&&(e=U(e,function(n){return n/a}),i/=a)}return[e,i]}var AL=new we(!0);function Sf(r){var t=r.stroke;return!(t==null||t==="none"||!(r.lineWidth>0))}function eS(r){return typeof r=="string"&&r!=="none"}function bf(r){var t=r.fill;return t!=null&&t!=="none"}function rS(r,t){if(t.fillOpacity!=null&&t.fillOpacity!==1){var e=r.globalAlpha;r.globalAlpha=t.fillOpacity*t.opacity,r.fill(),r.globalAlpha=e}else r.fill()}function iS(r,t){if(t.strokeOpacity!=null&&t.strokeOpacity!==1){var e=r.globalAlpha;r.globalAlpha=t.strokeOpacity*t.opacity,r.stroke(),r.globalAlpha=e}else r.stroke()}function wf(r,t,e){var i=Bc(t.image,t.__image,e);if(zn(i)){var a=r.createPattern(i,t.repeat||"repeat");if(typeof DOMMatrix=="function"&&a&&a.setTransform){var n=new DOMMatrix;n.translateSelf(t.x||0,t.y||0),n.rotateSelf(0,0,(t.rotation||0)*El),n.scaleSelf(t.scaleX||1,t.scaleY||1),a.setTransform(n)}return a}}function EL(r,t,e,i){var a,n=Sf(e),o=bf(e),s=e.strokePercent,l=s<1,u=!t.path;(!t.silent||l)&&u&&t.createPathProxy();var f=t.path||AL,h=t.__dirty;if(!i){var p=e.fill,c=e.stroke,v=o&&!!p.colorStops,m=n&&!!c.colorStops,d=o&&!!p.image,g=n&&!!c.image,y=void 0,_=void 0,x=void 0,S=void 0,b=void 0;(v||m)&&(b=t.getBoundingRect()),v&&(y=h?Fs(r,p,b):t.__canvasFillGradient,t.__canvasFillGradient=y),m&&(_=h?Fs(r,c,b):t.__canvasStrokeGradient,t.__canvasStrokeGradient=_),d&&(x=h||!t.__canvasFillPattern?wf(r,p,t):t.__canvasFillPattern,t.__canvasFillPattern=x),g&&(S=h||!t.__canvasStrokePattern?wf(r,c,t):t.__canvasStrokePattern,t.__canvasStrokePattern=x),v?r.fillStyle=y:d&&(x?r.fillStyle=x:o=!1),m?r.strokeStyle=_:g&&(S?r.strokeStyle=S:n=!1)}var w=t.getGlobalScale();f.setScale(w[0],w[1],t.segmentIgnoreThreshold);var C,M;r.setLineDash&&e.lineDash&&(a=Cv(t),C=a[0],M=a[1]);var A=!0;(u||h&xi)&&(f.setDPR(r.dpr),l?f.setContext(null):(f.setContext(r),A=!1),f.reset(),t.buildPath(f,t.shape,i),f.toStatic(),t.pathUpdated()),A&&f.rebuildPath(r,l?s:1),C&&(r.setLineDash(C),r.lineDashOffset=M),i||(e.strokeFirst?(n&&iS(r,e),o&&rS(r,e)):(o&&rS(r,e),n&&iS(r,e))),C&&r.setLineDash([])}function LL(r,t,e){var i=t.__image=Bc(e.image,t.__image,t,t.onload);if(!(!i||!zn(i))){var a=e.x||0,n=e.y||0,o=t.getWidth(),s=t.getHeight(),l=i.width/i.height;if(o==null&&s!=null?o=s*l:s==null&&o!=null?s=o/l:o==null&&s==null&&(o=i.width,s=i.height),e.sWidth&&e.sHeight){var u=e.sx||0,f=e.sy||0;r.drawImage(i,u,f,e.sWidth,e.sHeight,a,n,o,s)}else if(e.sx&&e.sy){var u=e.sx,f=e.sy,h=o-u,p=s-f;r.drawImage(i,u,f,h,p,a,n,o,s)}else r.drawImage(i,a,n,o,s)}}function PL(r,t,e){var i,a=e.text;if(a!=null&&(a+=""),a){r.font=e.font||dr,r.textAlign=e.textAlign,r.textBaseline=e.textBaseline;var n=void 0,o=void 0;r.setLineDash&&e.lineDash&&(i=Cv(t),n=i[0],o=i[1]),n&&(r.setLineDash(n),r.lineDashOffset=o),e.strokeFirst?(Sf(e)&&r.strokeText(a,e.x,e.y),bf(e)&&r.fillText(a,e.x,e.y)):(bf(e)&&r.fillText(a,e.x,e.y),Sf(e)&&r.strokeText(a,e.x,e.y)),n&&r.setLineDash([])}}var aS=["shadowBlur","shadowOffsetX","shadowOffsetY"],nS=[["lineCap","butt"],["lineJoin","miter"],["miterLimit",10]];function hS(r,t,e,i,a){var n=!1;if(!i&&(e=e||{},t===e))return!1;if(i||t.opacity!==e.opacity){Ne(r,a),n=!0;var o=Math.max(Math.min(t.opacity,1),0);r.globalAlpha=isNaN(o)?Ir.opacity:o}(i||t.blend!==e.blend)&&(n||(Ne(r,a),n=!0),r.globalCompositeOperation=t.blend||Ir.blend);for(var s=0;s0&&e.unfinished);e.unfinished||this._zr.flush()}}},t.prototype.getDom=function(){return this._dom},t.prototype.getId=function(){return this.id},t.prototype.getZr=function(){return this._zr},t.prototype.isSSR=function(){return this._ssr},t.prototype.setOption=function(e,i,a){if(!this[Se]){if(this._disposed){this.id;return}var n,o,s;if(H(i)&&(a=i.lazyUpdate,n=i.silent,o=i.replaceMerge,s=i.transition,i=i.notMerge),this[Se]=!0,!this._model||i){var l=new Y_(this._api),u=this._theme,f=this._model=new $u;f.scheduler=this._scheduler,f.ssr=this._ssr,f.init(null,null,null,u,this._locale,l)}this._model.setOption(e,{replaceMerge:o},zv);var h={seriesTransition:s,optionChanged:!0};if(a)this[ke]={silent:n,updateParams:h},this[Se]=!1,this.getZr().wakeUp();else{try{co(this),Vi.update.call(this,null,h)}catch(p){throw this[ke]=null,this[Se]=!1,p}this._ssr||this._zr.flush(),this[ke]=null,this[Se]=!1,Ys.call(this,n),Zs.call(this,n)}}},t.prototype.setTheme=function(){},t.prototype.getModel=function(){return this._model},t.prototype.getOption=function(){return this._model&&this._model.getOption()},t.prototype.getWidth=function(){return this._zr.getWidth()},t.prototype.getHeight=function(){return this._zr.getHeight()},t.prototype.getDevicePixelRatio=function(){return this._zr.painter.dpr||tt.hasGlobalWindow&&window.devicePixelRatio||1},t.prototype.getRenderedCanvas=function(e){return this.renderToCanvas(e)},t.prototype.renderToCanvas=function(e){e=e||{};var i=this._zr.painter;return i.getRenderedCanvas({backgroundColor:e.backgroundColor||this._model.get("backgroundColor"),pixelRatio:e.pixelRatio||this.getDevicePixelRatio()})},t.prototype.renderToSVGString=function(e){e=e||{};var i=this._zr.painter;return i.renderToString({useViewBox:e.useViewBox})},t.prototype.getSvgDataURL=function(){if(tt.svgSupported){var e=this._zr,i=e.storage.getDisplayList();return T(i,function(a){a.stopAnimation(null,!0)}),e.painter.toDataURL()}},t.prototype.getDataURL=function(e){if(this._disposed){this.id;return}e=e||{};var i=e.excludeComponents,a=this._model,n=[],o=this;T(i,function(l){a.eachComponent({mainType:l},function(u){var f=o._componentsMap[u.__viewId];f.group.ignore||(n.push(f),f.group.ignore=!0)})});var s=this._zr.painter.getType()==="svg"?this.getSvgDataURL():this.renderToCanvas(e).toDataURL("image/"+(e&&e.type||"png"));return T(n,function(l){l.group.ignore=!1}),s},t.prototype.getConnectedDataURL=function(e){if(this._disposed){this.id;return}var i=e.type==="svg",a=this.group,n=Math.min,o=Math.max,s=1/0;if(Ef[a]){var l=s,u=s,f=-s,h=-s,p=[],c=e&&e.pixelRatio||this.getDevicePixelRatio();T(nn,function(_,x){if(_.group===a){var S=i?_.getZr().painter.getSvgDom().innerHTML:_.renderToCanvas(K(e)),b=_.getDom().getBoundingClientRect();l=n(b.left,l),u=n(b.top,u),f=o(b.right,f),h=o(b.bottom,h),p.push({dom:S,left:b.left,top:b.top})}}),l*=c,u*=c,f*=c,h*=c;var v=f-l,m=h-u,d=be.createCanvas(),g=au(d,{renderer:i?"svg":"canvas"});if(g.resize({width:v,height:m}),i){var y="";return T(p,function(_){var x=_.left-l,S=_.top-u;y+=''+_.dom+""}),g.painter.getSvgRoot().innerHTML=y,e.connectedBackgroundColor&&g.painter.setBackgroundColor(e.connectedBackgroundColor),g.refreshImmediately(),g.painter.toDataURL()}else return e.connectedBackgroundColor&&g.add(new mt({shape:{x:0,y:0,width:v,height:m},style:{fill:e.connectedBackgroundColor}})),T(p,function(_){var x=new ie({style:{x:_.left*c-l,y:_.top*c-u,image:_.dom}});g.add(x)}),g.refreshImmediately(),d.toDataURL("image/"+(e&&e.type||"png"))}else return this.getDataURL(e)},t.prototype.convertToPixel=function(e,i){return Iv(this,"convertToPixel",e,i)},t.prototype.convertFromPixel=function(e,i){return Iv(this,"convertFromPixel",e,i)},t.prototype.containPixel=function(e,i){if(this._disposed){this.id;return}var a=this._model,n,o=lu(a,e);return T(o,function(s,l){l.indexOf("Models")>=0&&T(s,function(u){var f=u.coordinateSystem;if(f&&f.containPoint)n=n||!!f.containPoint(i);else if(l==="seriesModels"){var h=this._chartsMap[u.__viewId];h&&h.containPoint&&(n=n||h.containPoint(i,u))}},this)},this),!!n},t.prototype.getVisual=function(e,i){var a=this._model,n=lu(a,e,{defaultMainType:"series"}),o=n.seriesModel,s=o.getData(),l=n.hasOwnProperty("dataIndexInside")?n.dataIndexInside:n.hasOwnProperty("dataIndex")?s.indexOfRawIndex(n.dataIndex):null;return l!=null?Kx(s,l,i):uo(s,i)},t.prototype.getViewOfComponentModel=function(e){return this._componentsMap[e.__viewId]},t.prototype.getViewOfSeriesModel=function(e){return this._chartsMap[e.__viewId]},t.prototype._initEvents=function(){var e=this;T(eP,function(i){var a=function(n){var o=e.getModel(),s=n.target,l,u=i==="globalout";if(u?l={}:s&&tn(s,function(v){var m=ot(v);if(m&&m.dataIndex!=null){var d=m.dataModel||o.getSeriesByIndex(m.seriesIndex);return l=d&&d.getDataParams(m.dataIndex,m.dataType,s)||{},!0}else if(m.eventData)return l=N({},m.eventData),!0},!0),l){var f=l.componentType,h=l.componentIndex;(f==="markLine"||f==="markPoint"||f==="markArea")&&(f="series",h=l.seriesIndex);var p=f&&h!=null&&o.getComponent(f,h),c=p&&e[p.mainType==="series"?"_chartsMap":"_componentsMap"][p.__viewId];l.event=n,l.type=i,e._$eventProcessor.eventInfo={targetEl:s,packedEvent:l,model:p,view:c},e.trigger(i,l)}};a.zrEventfulCallAtLast=!0,e._zr.on(i,a,e)}),T(Xs,function(i,a){e._messageCenter.on(a,function(n){this.trigger(a,n)},e)}),T(["selectchanged"],function(i){e._messageCenter.on(i,function(a){this.trigger(i,a)},e)}),Qx(this._messageCenter,this,this._api)},t.prototype.isDisposed=function(){return this._disposed},t.prototype.clear=function(){if(this._disposed){this.id;return}this.setOption({series:[]},!0)},t.prototype.dispose=function(){if(this._disposed){this.id;return}this._disposed=!0;var e=this.getDom();e&&kc(this.getDom(),Gv,"");var i=this,a=i._api,n=i._model;T(i._componentsViews,function(o){o.dispose(n,a)}),T(i._chartsViews,function(o){o.dispose(n,a)}),i._zr.dispose(),i._dom=i._model=i._chartsMap=i._componentsMap=i._chartsViews=i._componentsViews=i._scheduler=i._api=i._zr=i._throttledZrFlush=i._theme=i._coordSysMgr=i._messageCenter=null,delete nn[i.id]},t.prototype.resize=function(e){if(!this[Se]){if(this._disposed){this.id;return}this._zr.resize(e);var i=this._model;if(this._loadingFX&&this._loadingFX.resize(),!!i){var a=i.resetOption("media"),n=e&&e.silent;this[ke]&&(n==null&&(n=this[ke].silent),a=!0,this[ke]=null),this[Se]=!0;try{a&&co(this),Vi.update.call(this,{type:"resize",animation:N({duration:0},e&&e.animation)})}catch(o){throw this[Se]=!1,o}this[Se]=!1,Ys.call(this,n),Zs.call(this,n)}}},t.prototype.showLoading=function(e,i){if(this._disposed){this.id;return}if(H(e)&&(i=e,e=""),e=e||"default",this.hideLoading(),!!Uv[e]){var a=Uv[e](this._api,i),n=this._zr;this._loadingFX=a,n.add(a)}},t.prototype.hideLoading=function(){if(this._disposed){this.id;return}this._loadingFX&&this._zr.remove(this._loadingFX),this._loadingFX=null},t.prototype.makeActionFromEvent=function(e){var i=N({},e);return i.type=Xs[e.type],i},t.prototype.dispatchAction=function(e,i){if(this._disposed){this.id;return}if(H(i)||(i={silent:!!i}),!!Mf[e.type]&&this._model){if(this[Se]){this._pendingActions.push(e);return}var a=i.silent;Ov.call(this,e,a);var n=i.flush;n?this._zr.flush():n!==!1&&tt.browser.weChat&&this._throttledZrFlush(),Ys.call(this,a),Zs.call(this,a)}},t.prototype.updateLabelLayout=function(){ur.trigger("series:layoutlabels",this._model,this._api,{updatedSeries:[]})},t.prototype.appendData=function(e){if(this._disposed){this.id;return}var i=e.seriesIndex,a=this.getModel(),n=a.getSeriesByIndex(i);n.appendData(e),this._scheduler.unfinished=!0,this.getZr().wakeUp()},t.internalField=(function(){co=function(h){var p=h._scheduler;p.restorePipelines(h._model),p.prepareStageTasks(),Pv(h,!0),Pv(h,!1),p.plan()},Pv=function(h,p){for(var c=h._model,v=h._scheduler,m=p?h._componentsViews:h._chartsViews,d=p?h._componentsMap:h._chartsMap,g=h._zr,y=h._api,_=0;_p.get("hoverLayerThreshold")&&!tt.node&&!tt.worker&&p.eachSeries(function(d){if(!d.preventUsingHoverLayer){var g=h._chartsMap[d.__viewId];g.__alive&&g.eachRendered(function(y){y.states.emphasis&&(y.states.emphasis.hoverLayer=!0)})}})}function o(h,p){var c=h.get("blendMode")||null;p.eachRendered(function(v){v.isGroup||(v.style.blend=c)})}function s(h,p){if(!h.preventAutoZ){var c=h.get("z")||0,v=h.get("zlevel")||0;p.eachRendered(function(m){return l(m,c,v,-1/0),!0})}}function l(h,p,c,v){var m=h.getTextContent(),d=h.getTextGuideLine(),g=h.isGroup;if(g)for(var y=h.childrenRef(),_=0;_0?{duration:m,delay:c.get("delay"),easing:c.get("easing")}:null;p.eachRendered(function(g){if(g.states&&g.states.emphasis){if(Ua(g))return;if(g instanceof rt&&M0(g),g.__dirty){var y=g.prevStates;y&&g.useStates(y)}if(v){g.stateTransition=d;var _=g.getTextContent(),x=g.getTextGuideLine();_&&(_.stateTransition=d),x&&(x.stateTransition=d)}g.__dirty&&a(g)}})}CS=function(h){return new((function(p){P(c,p);function c(){return p!==null&&p.apply(this,arguments)||this}return c.prototype.getCoordinateSystems=function(){return h._coordSysMgr.getCoordinateSystems()},c.prototype.getComponentByElement=function(v){for(;v;){var m=v.__ecComponentInfo;if(m!=null)return h._model.getComponent(m.mainType,m.index);v=v.parent}},c.prototype.enterEmphasis=function(v,m){ai(v,m),fr(h)},c.prototype.leaveEmphasis=function(v,m){ni(v,m),fr(h)},c.prototype.enterBlur=function(v){yu(v),fr(h)},c.prototype.leaveBlur=function(v){ds(v),fr(h)},c.prototype.enterSelect=function(v){up(v),fr(h)},c.prototype.leaveSelect=function(v){fp(v),fr(h)},c.prototype.getModel=function(){return h.getModel()},c.prototype.getViewOfComponentModel=function(v){return h.getViewOfComponentModel(v)},c.prototype.getViewOfSeriesModel=function(v){return h.getViewOfSeriesModel(v)},c})(tf))(h)},kS=function(h){function p(c,v){for(var m=0;m=0)){MS.push(e);var n=wv.wrapStageHandler(e,a);n.__prio=t,n.__raw=e,r.push(n)}}function Rf(r,t){Uv[r]=t}function lP(r){Dl({createCanvas:r})}function jv(r,t,e){var i=Av("registerMap");i&&i(r,t,e)}function uP(r){var t=Av("getMap");return t&&t(r)}var Qv=ux;vi(Bv,Rx);vi(Lf,Ox);vi(Lf,Nx);vi(Bv,Xx);vi(Lf,qx);vi(LS,Mv);Pf(ef);If(WL,iv);Rf("default",bv);Fr({type:Pi,event:Pi,update:Pi},Bt);Fr({type:ps,event:ps,update:ps},Bt);Fr({type:Fn,event:Fn,update:Fn},Bt);Fr({type:vs,event:vs,update:vs},Bt);Fr({type:Gn,event:Gn,update:Gn},Bt);Ks("light",Vx);Ks("dark",Wx);var fP={};function Qs(r){return r==null?0:r.length||1}function BS(r){return r}var cP=(function(){function r(t,e,i,a,n,o){this._old=t,this._new=e,this._oldKeyGetter=i||BS,this._newKeyGetter=a||BS,this.context=n,this._diffModeMultiple=o==="multiple"}return r.prototype.add=function(t){return this._add=t,this},r.prototype.update=function(t){return this._update=t,this},r.prototype.updateManyToOne=function(t){return this._updateManyToOne=t,this},r.prototype.updateOneToMany=function(t){return this._updateOneToMany=t,this},r.prototype.updateManyToMany=function(t){return this._updateManyToMany=t,this},r.prototype.remove=function(t){return this._remove=t,this},r.prototype.execute=function(){this[this._diffModeMultiple?"_executeMultiple":"_executeOneToOne"]()},r.prototype._executeOneToOne=function(){var t=this._old,e=this._new,i={},a=new Array(t.length),n=new Array(e.length);this._initIndexMap(t,null,a,"_oldKeyGetter"),this._initIndexMap(e,i,n,"_newKeyGetter");for(var o=0;o1){var f=l.shift();l.length===1&&(i[s]=l[0]),this._update&&this._update(f,o)}else u===1?(i[s]=null,this._update&&this._update(l,o)):this._remove&&this._remove(o)}this._performRestAdd(n,i)},r.prototype._executeMultiple=function(){var t=this._old,e=this._new,i={},a={},n=[],o=[];this._initIndexMap(t,i,n,"_oldKeyGetter"),this._initIndexMap(e,a,o,"_newKeyGetter");for(var s=0;s1&&p===1)this._updateManyToOne&&this._updateManyToOne(f,u),a[l]=null;else if(h===1&&p>1)this._updateOneToMany&&this._updateOneToMany(f,u),a[l]=null;else if(h===1&&p===1)this._update&&this._update(f,u),a[l]=null;else if(h>1&&p>1)this._updateManyToMany&&this._updateManyToMany(f,u),a[l]=null;else if(h>1)for(var c=0;c1)for(var s=0;s30}var Js=H,Fi=U,yP=typeof Int32Array>"u"?Array:Int32Array,_P="e\0\0",HS=-1,xP=["hasItemOption","_nameList","_idList","_invertedIndicesMap","_dimSummary","userOutput","_rawData","_dimValueGetter","_nameDimIdx","_idDimIdx","_nameRepeatCount"],SP=["_approximateExtent"],WS,Nf,$s,tl,id,el,ad,bP=(function(){function r(t,e){this.type="list",this._dimOmitted=!1,this._nameList=[],this._idList=[],this._visual={},this._layout={},this._itemVisuals=[],this._itemLayouts=[],this._graphicEls=[],this._approximateExtent={},this._calculationInfo={},this.hasItemOption=!1,this.TRANSFERABLE_METHODS=["cloneShallow","downSample","minmaxDownSample","lttbDownSample","map"],this.CHANGABLE_METHODS=["filterSelf","selectRange"],this.DOWNSAMPLE_METHODS=["downSample","minmaxDownSample","lttbDownSample"];var i,a=!1;Of(t)?(i=t.dimensions,this._dimOmitted=t.isDimensionOmitted(),this._schema=t):(a=!0,i=t),i=i||["x","y"];for(var n={},o=[],s={},l=!1,u={},f=0;f=e)){var i=this._store,a=i.getProvider();this._updateOrdinalMeta();var n=this._nameList,o=this._idList,s=a.getSource().sourceFormat,l=s===oe;if(l&&!a.pure)for(var u=[],f=t;f0},r.prototype.ensureUniqueItemVisual=function(t,e){var i=this._itemVisuals,a=i[t];a||(a=i[t]={});var n=a[e];return n==null&&(n=this.getVisual(e),k(n)?n=n.slice():Js(n)&&(n=N({},n)),a[e]=n),n},r.prototype.setItemVisual=function(t,e,i){var a=this._itemVisuals[t]||{};this._itemVisuals[t]=a,Js(e)?N(a,e):a[e]=i},r.prototype.clearAllVisual=function(){this._visual={},this._itemVisuals=[]},r.prototype.setLayout=function(t,e){Js(t)?N(this._layout,t):this._layout[t]=e},r.prototype.getLayout=function(t){return this._layout[t]},r.prototype.getItemLayout=function(t){return this._itemLayouts[t]},r.prototype.setItemLayout=function(t,e,i){this._itemLayouts[t]=i?N(this._itemLayouts[t]||{},e):e},r.prototype.clearItemLayouts=function(){this._itemLayouts.length=0},r.prototype.setItemGraphicEl=function(t,e){var i=this.hostModel&&this.hostModel.seriesIndex;fs(i,this.dataType,t,e),this._graphicEls[t]=e},r.prototype.getItemGraphicEl=function(t){return this._graphicEls[t]},r.prototype.eachItemGraphicEl=function(t,e){T(this._graphicEls,function(i,a){i&&t&&t.call(e,i,a)})},r.prototype.cloneShallow=function(t){return t||(t=new r(this._schema?this._schema:Fi(this.dimensions,this._getDimInfo,this),this.hostModel)),id(t,this),t._store=this._store,t},r.prototype.wrapMethod=function(t,e){var i=this[t];G(i)&&(this.__wrappedMethods=this.__wrappedMethods||[],this.__wrappedMethods.push(t),this[t]=function(){var a=i.apply(this,arguments);return e.apply(this,[a].concat(Ro(arguments)))})},r.internalField=(function(){WS=function(t){var e=t._invertedIndicesMap;T(e,function(i,a){var n=t._dimInfos[a],o=n.ordinalMeta,s=t._store;if(o){i=e[a]=new yP(o.categories.length);for(var l=0;l1&&(l+="__ec__"+f),a[e]=l}}})(),r})(),hr=bP;var dd={};Ae(dd,{createDimensions:()=>YS,createList:()=>nI,createScale:()=>sI,createSymbol:()=>It,createTextStyle:()=>uI,dataStack:()=>oI,enableHoverEmphasis:()=>Ii,getECData:()=>ot,getLayoutRect:()=>De,mixinAxisModelCommonMethods:()=>lI});function YS(r,t){return vo(r,t).dimensions}function vo(r,t){no(r)||(r=oo(r)),t=t||{};var e=t.coordDimensions||[],i=t.dimensionsDefine||r.dimensionsDefine||[],a=Y(),n=[],o=TP(r,e,i,t.dimensionsCount),s=t.canOmitUnusedDimensions&&rd(o),l=i===r.dimensionsDefine,u=l?ed(r):td(i),f=t.encodeDefine;!f&&t.encodeDefaulter&&(f=t.encodeDefaulter(r,o));for(var h=Y(f),p=new pv(o),c=0;c0&&(i.name=a+(n-1)),n++,t.set(a,n)}}function TP(r,t,e,i){var a=Math.max(r.dimensionsDetectedCount||1,t.length,e.length,i||0);return T(t,function(n){var o;H(n)&&(o=n.dimsDef)&&(a=Math.max(a,o.length))}),a}function CP(r,t,e){if(e||t.hasKey(r)){for(var i=0;t.hasKey(r+i);)i++;r+=i}return t.set(r,!0),r}var DP=(function(){function r(t){this.coordSysDims=[],this.axisMap=Y(),this.categoryAxisMap=Y(),this.coordSysName=t}return r})();function ZS(r){var t=r.get("coordinateSystem"),e=new DP(t),i=MP[t];if(i)return i(r,e,e.axisMap,e.categoryAxisMap),e}var MP={cartesian2d:function(r,t,e,i){var a=r.getReferringComponents("xAxis",Ht).models[0],n=r.getReferringComponents("yAxis",Ht).models[0];t.coordSysDims=["x","y"],e.set("x",a),e.set("y",n),mo(a)&&(i.set("x",a),t.firstCategoryDimIndex=0),mo(n)&&(i.set("y",n),t.firstCategoryDimIndex==null&&(t.firstCategoryDimIndex=1))},singleAxis:function(r,t,e,i){var a=r.getReferringComponents("singleAxis",Ht).models[0];t.coordSysDims=["single"],e.set("single",a),mo(a)&&(i.set("single",a),t.firstCategoryDimIndex=0)},polar:function(r,t,e,i){var a=r.getReferringComponents("polar",Ht).models[0],n=a.findAxisModel("radiusAxis"),o=a.findAxisModel("angleAxis");t.coordSysDims=["radius","angle"],e.set("radius",n),e.set("angle",o),mo(n)&&(i.set("radius",n),t.firstCategoryDimIndex=0),mo(o)&&(i.set("angle",o),t.firstCategoryDimIndex==null&&(t.firstCategoryDimIndex=1))},geo:function(r,t,e,i){t.coordSysDims=["lng","lat"]},parallel:function(r,t,e,i){var a=r.ecModel,n=a.getComponent("parallel",r.get("parallelIndex")),o=t.coordSysDims=n.dimensions.slice();T(n.parallelAxisIndex,function(s,l){var u=a.getComponent("parallelAxis",s),f=o[l];e.set(f,u),mo(u)&&(i.set(f,u),t.firstCategoryDimIndex==null&&(t.firstCategoryDimIndex=l))})}};function mo(r){return r.get("type")==="category"}function kf(r,t,e){e=e||{};var i=e.byIndex,a=e.stackedCoordDimension,n,o,s;AP(t)?n=t:(o=t.schema,n=o.dimensions,s=t.store);var l=!!(r&&r.get("stack")),u,f,h,p;if(T(n,function(y,_){B(y)&&(n[_]=y={name:y}),l&&!y.isExtraCoord&&(!i&&!u&&y.ordinalMeta&&(u=y),!f&&y.type!=="ordinal"&&y.type!=="time"&&(!a||a===y.coordDim)&&(f=y))}),f&&!i&&!u&&(i=!0),f){h="__\0ecstackresult_"+r.id,p="__\0ecstackedover_"+r.id,u&&(u.createInvertedIndices=!0);var c=f.coordDim,v=f.type,m=0;T(n,function(y){y.coordDim===c&&m++});var d={name:h,coordDim:c,coordDimIndex:m,type:v,isExtraCoord:!0,isCalculationCoord:!0,storeDimIndex:n.length},g={name:p,coordDim:p,coordDimIndex:m+1,type:v,isExtraCoord:!0,isCalculationCoord:!0,storeDimIndex:n.length+1};o?(s&&(d.storeDimIndex=s.ensureCalculationDimension(p,v),g.storeDimIndex=s.ensureCalculationDimension(h,v)),o.appendCalculationDimension(d),o.appendCalculationDimension(g)):(n.push(d),n.push(g))}return{stackedDimension:f&&f.name,stackedByDimension:u&&u.name,isStackedByIndex:i,stackedOverDimension:p,stackResultDimension:h}}function AP(r){return!Of(r.schema)}function Xe(r,t){return!!t&&t===r.getCalculationInfo("stackedDimension")}function go(r,t){return Xe(r,t)?r.getCalculationInfo("stackResultDimension"):t}function EP(r,t){var e=r.get("coordinateSystem"),i=ao.get(e),a;return t&&t.coordSysDims&&(a=U(t.coordSysDims,function(n){var o={name:n},s=t.axisMap.get(n);if(s){var l=s.get("type");o.type=GS(l)}return o})),a||(a=i&&(i.getDimensionsInfo?i.getDimensionsInfo():i.dimensions.slice())||["x","y"]),a}function LP(r,t,e){var i,a;return e&&T(r,function(n,o){var s=n.coordDim,l=e.categoryAxisMap.get(s);l&&(i==null&&(i=o),n.ordinalMeta=l.getOrdinalMeta(),t&&(n.createInvertedIndices=!0)),n.otherDims.itemName!=null&&(a=!0)}),!a&&i!=null&&(r[i].otherDims.itemName=0),i}function PP(r,t,e){e=e||{};var i=t.getSourceManager(),a,n=!1;r?(n=!0,a=oo(r)):(a=i.getSource(),n=a.sourceFormat===oe);var o=ZS(t),s=EP(t,o),l=e.useEncodeDefaulter,u=G(l)?l:l?lt(R_,s,t):null,f={coordDimensions:s,generateCoord:e.generateCoord,encodeDefine:t.getEncode(),encodeDefaulter:u,canOmitUnusedDimensions:!n},h=vo(a,f),p=LP(h.dimensions,e.createInvertedIndices,o),c=n?null:i.getSharedDataStore(h),v=kf(t,{schema:h,store:c}),m=new hr(h,t);m.setCalculationInfo(v);var d=p!=null&&IP(a)?function(g,y,_,x){return x===p?_:this.defaultDimValueGetter(g,y,_,x)}:null;return m.hasItemOption=!1,m.initData(n?a:c,null,d),m}function IP(r){if(r.sourceFormat===oe){var t=RP(r.data||[]);return!k(ei(t))}}function RP(r){for(var t=0;te[1]&&(e[1]=t[1])},r.prototype.unionExtentFromData=function(t,e){this.unionExtent(t.getApproximateExtent(e))},r.prototype.getExtent=function(){return this._extent.slice()},r.prototype.setExtent=function(t,e){var i=this._extent;isNaN(t)||(i[0]=t),isNaN(e)||(i[1]=e)},r.prototype.isInExtentRange=function(t){return this._extent[0]<=t&&this._extent[1]>=t},r.prototype.isBlank=function(){return this._isBlank},r.prototype.setBlank=function(t){this._isBlank=t},r})();Di(XS);var ze=XS;var OP=0,NP=(function(){function r(t){this.categories=t.categories||[],this._needCollect=t.needCollect,this._deduplication=t.deduplication,this.uid=++OP}return r.createByAxisModel=function(t){var e=t.option,i=e.data,a=i&&U(i,kP);return new r({categories:a,needCollect:!a,deduplication:e.dedplication!==!1})},r.prototype.getOrdinal=function(t){return this._getOrCreateMap().get(t)},r.prototype.parseAndCollect=function(t){var e,i=this._needCollect;if(!B(t)&&!i)return t;if(i&&!this._deduplication)return e=this.categories.length,this.categories[e]=t,e;var a=this._getOrCreateMap();return e=a.get(t),e==null&&(i?(e=this.categories.length,this.categories[e]=t,a.set(t,e)):e=NaN),e},r.prototype._getOrCreateMap=function(){return this._map||(this._map=Y(this.categories))},r})();function kP(r){return H(r)&&r.value!=null?r.value:r+""}var rl=NP;function il(r){return r.type==="interval"||r.type==="log"}function KS(r,t,e,i){var a={},n=r[1]-r[0],o=a.interval=Rn(n/t,!0);e!=null&&oi&&(o=a.interval=i);var s=a.intervalPrecision=nd(o),l=a.niceTickExtent=[bt(Math.ceil(r[0]/o)*o,s),bt(Math.floor(r[1]/o)*o,s)];return zP(l,r),a}function zf(r){var t=Math.pow(10,In(r)),e=r/t;return e?e===2?e=3:e===3?e=5:e*=2:e=1,bt(e*t)}function nd(r){return ue(r)+2}function qS(r,t,e){r[t]=Math.max(Math.min(r[t],e[1]),e[0])}function zP(r,t){!isFinite(r[0])&&(r[0]=t[0]),!isFinite(r[1])&&(r[1]=t[1]),qS(r,0,t),qS(r,1,t),r[0]>r[1]&&(r[0]=r[1])}function Gi(r,t){return r>=t[0]&&r<=t[1]}function Hi(r,t){return t[1]===t[0]?.5:(r-t[0])/(t[1]-t[0])}function Wi(r,t){return r*(t[1]-t[0])+t[0]}var jS=(function(r){P(t,r);function t(e){var i=r.call(this,e)||this;i.type="ordinal";var a=i.getSetting("ordinalMeta");return a||(a=new rl({})),k(a)&&(a=new rl({categories:U(a,function(n){return H(n)?n.value:n})})),i._ordinalMeta=a,i._extent=i.getSetting("extent")||[0,a.categories.length-1],i}return t.prototype.parse=function(e){return e==null?NaN:B(e)?this._ordinalMeta.getOrdinal(e):Math.round(e)},t.prototype.contain=function(e){return e=this.parse(e),Gi(e,this._extent)&&this._ordinalMeta.categories[e]!=null},t.prototype.normalize=function(e){return e=this._getTickNumber(this.parse(e)),Hi(e,this._extent)},t.prototype.scale=function(e){return e=Math.round(Wi(e,this._extent)),this.getRawOrdinalNumber(e)},t.prototype.getTicks=function(){for(var e=[],i=this._extent,a=i[0];a<=i[1];)e.push({value:a}),a++;return e},t.prototype.getMinorTicks=function(e){},t.prototype.setSortInfo=function(e){if(e==null){this._ordinalNumbersByTick=this._ticksByOrdinalNumber=null;return}for(var i=e.ordinalNumbers,a=this._ordinalNumbersByTick=[],n=this._ticksByOrdinalNumber=[],o=0,s=this._ordinalMeta.categories.length,l=Math.min(s,i.length);o=0&&e=0&&e=e},t.prototype.getOrdinalMeta=function(){return this._ordinalMeta},t.prototype.calcNiceTicks=function(){},t.prototype.calcNiceExtent=function(){},t.type="ordinal",t})(ze);ze.registerClass(jS);var od=jS;var on=bt,QS=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type="interval",e._interval=0,e._intervalPrecision=2,e}return t.prototype.parse=function(e){return e},t.prototype.contain=function(e){return Gi(e,this._extent)},t.prototype.normalize=function(e){return Hi(e,this._extent)},t.prototype.scale=function(e){return Wi(e,this._extent)},t.prototype.setExtent=function(e,i){var a=this._extent;isNaN(e)||(a[0]=parseFloat(e)),isNaN(i)||(a[1]=parseFloat(i))},t.prototype.unionExtent=function(e){var i=this._extent;e[0]i[1]&&(i[1]=e[1]),this.setExtent(i[0],i[1])},t.prototype.getInterval=function(){return this._interval},t.prototype.setInterval=function(e){this._interval=e,this._niceExtent=this._extent.slice(),this._intervalPrecision=nd(e)},t.prototype.getTicks=function(e){var i=this._interval,a=this._extent,n=this._niceExtent,o=this._intervalPrecision,s=[];if(!i)return s;var l=1e4;a[0]l)return[];var f=s.length?s[s.length-1].value:n[1];return a[1]>f&&(e?s.push({value:on(f+i,o)}):s.push({value:a[1]})),s},t.prototype.getMinorTicks=function(e){for(var i=this.getTicks(!0),a=[],n=this.getExtent(),o=1;on[0]&&c0&&(n=n===null?s:Math.min(n,s))}e[i]=n}}return e}function fd(r){var t=VP(r),e=[];return T(r,function(i){var a=i.coordinateSystem,n=a.getBaseAxis(),o=n.getExtent(),s;if(n.type==="category")s=n.getBandWidth();else if(n.type==="value"||n.type==="time"){var l=n.dim+"_"+n.index,u=t[l],f=Math.abs(o[1]-o[0]),h=n.scale.getExtent(),p=Math.abs(h[1]-h[0]);s=u?f/p*u:f}else{var c=i.getData();s=Math.abs(o[1]-o[0])/c.count()}var v=j(i.get("barWidth"),s),m=j(i.get("barMaxWidth"),s),d=j(i.get("barMinWidth")||(ib(i)?.5:1),s),g=i.get("barGap"),y=i.get("barCategoryGap");e.push({bandWidth:s,barWidth:v,barMaxWidth:m,barMinWidth:d,barGap:g,barCategoryGap:y,axisKey:ld(n),stackId:sd(i)})}),FP(e)}function FP(r){var t={};T(r,function(i,a){var n=i.axisKey,o=i.bandWidth,s=t[n]||{bandWidth:o,remainedWidth:o,autoWidthCount:0,categoryGap:null,gap:"20%",stacks:{}},l=s.stacks;t[n]=s;var u=i.stackId;l[u]||s.autoWidthCount++,l[u]=l[u]||{width:0,maxWidth:0};var f=i.barWidth;f&&!l[u].width&&(l[u].width=f,f=Math.min(s.remainedWidth,f),s.remainedWidth-=f);var h=i.barMaxWidth;h&&(l[u].maxWidth=h);var p=i.barMinWidth;p&&(l[u].minWidth=p);var c=i.barGap;c!=null&&(s.gap=c);var v=i.barCategoryGap;v!=null&&(s.categoryGap=v)});var e={};return T(t,function(i,a){e[a]={};var n=i.stacks,o=i.bandWidth,s=i.categoryGap;if(s==null){var l=pt(n).length;s=Math.max(35-l*4,15)+"%"}var u=j(s,o),f=j(i.gap,1),h=i.remainedWidth,p=i.autoWidthCount,c=(h-u)/(p+(p-1)*f);c=Math.max(c,0),T(n,function(g){var y=g.maxWidth,_=g.minWidth;if(g.width){var x=g.width;y&&(x=Math.min(x,y)),_&&(x=Math.max(x,_)),g.width=x,h-=x+f*x,p--}else{var x=c;y&&yx&&(x=_),x!==c&&(g.width=x,h-=x+f*x,p--)}}),c=(h-u)/(p+(p-1)*f),c=Math.max(c,0);var v=0,m;T(n,function(g,y){g.width||(g.width=c),m=g,v+=g.width*(1+f)}),m&&(v-=m.width*f);var d=-v/2;T(n,function(g,y){e[a][y]=e[a][y]||{bandWidth:o,offset:d,width:g.width},d+=g.width*(1+f)})}),e}function $S(r,t,e){if(r&&t){var i=r[ld(t)];return i!=null&&e!=null?i[sd(e)]:i}}function tb(r,t){var e=ud(r,t),i=fd(e);T(e,function(a){var n=a.getData(),o=a.coordinateSystem,s=o.getBaseAxis(),l=sd(a),u=i[ld(s)][l],f=u.offset,h=u.width;n.setLayout({bandWidth:u.bandWidth,offset:f,size:h})})}function eb(r){return{seriesType:r,plan:Qa(),reset:function(t){if(rb(t)){var e=t.getData(),i=t.coordinateSystem,a=i.getBaseAxis(),n=i.getOtherAxis(a),o=e.getDimensionIndex(e.mapDimension(n.dim)),s=e.getDimensionIndex(e.mapDimension(a.dim)),l=t.get("showBackground",!0),u=e.mapDimension(n.dim),f=e.getCalculationInfo("stackResultDimension"),h=Xe(e,u)&&!!e.getCalculationInfo("stackedOnSeries"),p=n.isHorizontal(),c=GP(a,n),v=ib(t),m=t.get("barMinHeight")||0,d=f&&e.getDimensionIndex(f),g=e.getLayout("size"),y=e.getLayout("offset");return{progress:function(_,x){for(var S=_.count,b=v&&qe(S*3),w=v&&l&&qe(S*3),C=v&&qe(S),M=i.master.getRect(),A=p?M.width:M.height,D,E=x.getStore(),L=0;(D=_.next())!=null;){var I=E.get(h?d:o,D),R=E.get(s,D),O=c,V=void 0;h&&(V=+I-E.get(o,D));var z=void 0,F=void 0,W=void 0,Z=void 0;if(p){var J=i.dataToPoint([I,R]);if(h){var vt=i.dataToPoint([V,R]);O=vt[0]}z=O,F=J[1]+y,W=J[0]-O,Z=g,Math.abs(W)0?e:1:e))}var HP=function(r,t,e,i){for(;e>>1;r[a][1]a&&(this._approxInterval=a);var s=Bf.length,l=Math.min(HP(Bf,this._approxInterval,0,s),s-1);this._interval=Bf[l][1],this._minLevelUnit=Bf[Math.max(l-1,0)][0]},t.prototype.parse=function(e){return et(e)?e:+re(e)},t.prototype.contain=function(e){return Gi(this.parse(e),this._extent)},t.prototype.normalize=function(e){return Hi(this.parse(e),this._extent)},t.prototype.scale=function(e){return Wi(e,this._extent)},t.type="time",t})(cr),Bf=[["second",Fu],["minute",Gu],["hour",$n],["quarter-day",$n*6],["half-day",$n*12],["day",He*1.2],["half-week",He*3.5],["week",He*7],["month",He*31],["quarter",He*95],["half-year",Up/2],["year",Up]];function WP(r,t,e,i){var a=re(t),n=re(e),o=function(v){return Fp(a,v,i)===Fp(n,v,i)},s=function(){return o("year")},l=function(){return s()&&o("month")},u=function(){return l()&&o("day")},f=function(){return u()&&o("hour")},h=function(){return f()&&o("minute")},p=function(){return h()&&o("second")},c=function(){return p()&&o("millisecond")};switch(r){case"year":return s();case"month":return l();case"day":return u();case"hour":return f();case"minute":return h();case"second":return p();case"millisecond":return c()}}function YP(r,t){return r/=He,r>16?16:r>7.5?7:r>3.5?4:r>1.5?2:1}function ZP(r){var t=30*He;return r/=t,r>6?6:r>3?3:r>2?2:1}function XP(r){return r/=$n,r>12?12:r>6?6:r>3.5?4:r>2?2:1}function ab(r,t){return r/=t?Gu:Fu,r>30?30:r>20?20:r>15?15:r>10?10:r>5?5:r>2?2:1}function qP(r){return Rn(r,!0)}function KP(r,t,e){var i=new Date(r);switch(Za(t)){case"year":case"month":i[Gp(e)](0);case"day":i[Hp(e)](1);case"hour":i[Wp(e)](0);case"minute":i[Yp(e)](0);case"second":i[Zp(e)](0),i[Xp(e)](0)}return i.getTime()}function jP(r,t,e,i){var a=1e4,n=Vp,o=0;function s(A,D,E,L,I,R,O){for(var V=new Date(D),z=D,F=V[L]();z1&&R===0&&E.unshift({value:E[0].value-z})}}for(var R=0;R=i[0]&&y<=i[1]&&h++)}var _=(i[1]-i[0])/t;if(h>_*1.5&&p>_/1.5||(u.push(d),h>_||r===n[c]))break}f=[]}}}for(var x=Tt(U(u,function(A){return Tt(A,function(D){return D.value>=i[0]&&D.value<=i[1]&&!D.notAdd})}),function(A){return A.length>0}),S=[],b=x.length-1,c=0;c0;)n*=10;var s=[bt($P(i[0]/n)*n),bt(JP(i[1]/n)*n)];this._interval=n,this._niceExtent=s}},t.prototype.calcNiceExtent=function(e){al.calcNiceExtent.call(this,e),this._fixMin=e.fixMin,this._fixMax=e.fixMax},t.prototype.parse=function(e){return e},t.prototype.contain=function(e){return e=wr(e)/wr(this.base),Gi(e,this._extent)},t.prototype.normalize=function(e){return e=wr(e)/wr(this.base),Hi(e,this._extent)},t.prototype.scale=function(e){return e=Wi(e,this._extent),Vf(this.base,e)},t.type="log",t})(ze),lb=hd.prototype;lb.getMinorTicks=al.getMinorTicks;lb.getLabel=al.getLabel;function Ff(r,t){return QP(r,ue(t))}ze.registerClass(hd);var ub=hd;var tI=(function(){function r(t,e,i){this._prepareParams(t,e,i)}return r.prototype._prepareParams=function(t,e,i){i[1]0&&l>0&&!u&&(s=0),s<0&&l<0&&!f&&(l=0));var p=this._determinedMin,c=this._determinedMax;return p!=null&&(s=p,u=!0),c!=null&&(l=c,f=!0),{min:s,max:l,minFixed:u,maxFixed:f,isBlank:h}},r.prototype.modifyDataMinMax=function(t,e){this[rI[t]]=e},r.prototype.setDeterminedMinMax=function(t,e){var i=eI[t];this[i]=e},r.prototype.freeze=function(){this.frozen=!0},r})();var eI={min:"_determinedMin",max:"_determinedMax"},rI={min:"_dataMin",max:"_dataMax"};function Hf(r,t,e){var i=r.rawExtentInfo;return i||(i=new tI(r,t,e),r.rawExtentInfo=i,i)}function Gf(r,t){return t==null?null:ea(t)?NaN:r.parse(t)}function cd(r,t){var e=r.type,i=Hf(r,t,r.getExtent()).calculate();r.setBlank(i.isBlank);var a=i.min,n=i.max,o=t.ecModel;if(o&&e==="time"){var s=ud("bar",o),l=!1;if(T(s,function(h){l=l||h.getBaseAxis()===t.axis}),l){var u=fd(s),f=iI(a,n,t,u);a=f.min,n=f.max}}return{extent:[a,n],fixMin:i.minFixed,fixMax:i.maxFixed}}function iI(r,t,e,i){var a=e.axis.getExtent(),n=Math.abs(a[1]-a[0]),o=$S(i,e.axis);if(o===void 0)return{min:r,max:t};var s=1/0;T(o,function(c){s=Math.min(c.offset,s)});var l=-1/0;T(o,function(c){l=Math.max(c.offset+c.width,l)}),s=Math.abs(s),l=Math.abs(l);var u=s+l,f=t-r,h=1-(s+l)/n,p=f/h-f;return t+=p*(l/u),r-=p*(s/u),{min:r,max:t}}function nl(r,t){var e=t,i=cd(r,e),a=i.extent,n=e.get("splitNumber");r instanceof ub&&(r.base=e.get("logBase"));var o=r.type,s=e.get("interval"),l=o==="interval"||o==="time";r.setExtent(a[0],a[1]),r.calcNiceExtent({splitNumber:n,fixMin:i.fixMin,fixMax:i.fixMax,minInterval:l?e.get("minInterval"):null,maxInterval:l?e.get("maxInterval"):null}),s!=null&&r.setInterval&&r.setInterval(s)}function Wf(r,t){if(t=t||r.get("type"),t)switch(t){case"category":return new od({ordinalMeta:r.getOrdinalMeta?r.getOrdinalMeta():r.getCategories(),extent:[1/0,-1/0]});case"time":return new ob({locale:r.ecModel.getLocaleModel(),useUTC:r.ecModel.get("useUTC")});default:return new(ze.getClass(t)||cr)}}function fb(r){var t=r.scale.getExtent(),e=t[0],i=t[1];return!(e>0&&i>0||e<0&&i<0)}function sn(r){var t=r.getLabelModel().get("formatter"),e=r.type==="category"?r.scale.getExtent()[0]:null;return r.scale.type==="time"?(function(i){return function(a,n){return r.scale.getFormattedLabel(a,n,i)}})(t):B(t)?(function(i){return function(a){var n=r.scale.getLabel(a),o=i.replace("{value}",n??"");return o}})(t):G(t)?(function(i){return function(a,n){return e!=null&&(n=a.value-e),i(ol(r,a),n,a.level!=null?{level:a.level}:null)}})(t):function(i){return r.scale.getLabel(i)}}function ol(r,t){return r.type==="category"?r.scale.getLabel(t):t.value}function hb(r){var t=r.model,e=r.scale;if(!(!t.get(["axisLabel","show"])||e.isBlank())){var i,a,n=e.getExtent();e instanceof od?a=e.count():(i=e.getTicks(),a=i.length);var o=r.getLabelModel(),s=sn(r),l,u=1;a>40&&(u=Math.ceil(a/40));for(var f=0;fr[1]&&(r[1]=a[1])})}var yo=(function(){function r(){}return r.prototype.getNeedCrossZero=function(){var t=this.option;return!t.scale},r.prototype.getCoordSysModel=function(){},r})();function nI(r){return Gr(null,r)}var oI={isDimensionStacked:Xe,enableDataStack:kf,getStackedDimension:go};function sI(r,t){var e=t;t instanceof wt||(e=new wt(t));var i=Wf(e);return i.setExtent(r[0],r[1]),nl(i,e),i}function lI(r){Ut(r,yo)}function uI(r,t){return t=t||{},Wt(r,null,null,t.state!=="normal")}var pb=[],fI={registerPreprocessor:Pf,registerProcessor:If,registerPostInit:Yv,registerPostUpdate:Zv,registerUpdateLifecycle:js,registerAction:Fr,registerCoordinateSystem:Xv,registerLayout:qv,registerVisual:vi,registerTransform:Qv,registerLoading:Rf,registerMap:jv,registerImpl:_S,PRIORITY:Vv,ComponentModel:ct,ComponentView:At,SeriesModel:kt,ChartView:Pt,registerComponentModel:function(r){ct.registerClass(r)},registerComponentView:function(r){At.registerClass(r)},registerSeriesModel:function(r){kt.registerClass(r)},registerChartView:function(r){Pt.registerClass(r)},registerSubTypeDefaulter:function(r,t){ct.registerSubTypeDefaulter(r,t)},registerPainter:function(r,t){Lc(r,t)}};function zt(r){if(k(r)){T(r,function(t){zt(t)});return}at(pb,r)>=0||(pb.push(r),G(r)&&(r={install:r}),r.install(fI))}var hI=1e-8;function vb(r,t){return Math.abs(r-t)a&&(i=o,a=l)}if(i)return vI(i.exterior);var u=this.getBoundingRect();return[u.x+u.width/2,u.y+u.height/2]},t.prototype.getBoundingRect=function(e){var i=this._rect;if(i&&!e)return i;var a=[1/0,1/0],n=[-1/0,-1/0],o=this.geometries;return T(o,function(s){s.type==="polygon"?db(s.exterior,a,n,e):T(s.points,function(l){db(l,a,n,e)})}),isFinite(a[0])&&isFinite(a[1])&&isFinite(n[0])&&isFinite(n[1])||(a[0]=a[1]=n[0]=n[1]=0),i=new nt(a[0],a[1],n[0]-a[0],n[1]-a[1]),e||(this._rect=i),i},t.prototype.contain=function(e){var i=this.getBoundingRect(),a=this.geometries;if(!i.contain(e[0],e[1]))return!1;t:for(var n=0,o=a.length;n>1^-(s&1),l=l>>1^-(l&1),s+=a,l+=n,a=s,n=l,i.push([s/e,l/e])}return i}function Xf(r,t){return r=dI(r),U(Tt(r.features,function(e){return e.geometry&&e.properties&&e.geometry.coordinates.length>0}),function(e){var i=e.properties,a=e.geometry,n=[];switch(a.type){case"Polygon":var o=a.coordinates;n.push(new yd(o[0],o.slice(1)));break;case"MultiPolygon":T(a.coordinates,function(l){l[0]&&n.push(new yd(l[0],l.slice(1)))});break;case"LineString":n.push(new _d([a.coordinates]));break;case"MultiLineString":n.push(new _d(a.coordinates))}var s=new gb(i[t||"name"],n,i.cp);return s.properties=i,s})}var Sd={};Ae(Sd,{MAX_SAFE_INTEGER:()=>fy,asc:()=>$r,getPercentWithPrecision:()=>ly,getPixelPrecision:()=>Pn,getPrecision:()=>ue,getPrecisionSafe:()=>Ic,isNumeric:()=>rs,isRadianAroundZero:()=>Sa,linearMap:()=>Ct,nice:()=>Rn,numericToNumber:()=>rr,parseDate:()=>re,quantile:()=>hy,quantity:()=>ou,quantityExponent:()=>In,reformIntervals:()=>cy,remRadian:()=>es,round:()=>bt});var bd={};Ae(bd,{format:()=>ui,parse:()=>re});var sl={};Ae(sl,{Arc:()=>Na,BezierCurve:()=>Oa,BoundingRect:()=>nt,Circle:()=>oi,CompoundPath:()=>Cu,Ellipse:()=>ys,Group:()=>ut,Image:()=>ie,IncrementalDisplayable:()=>Lu,Line:()=>ne,LinearGradient:()=>Yn,Polygon:()=>xr,Polyline:()=>Ce,RadialGradient:()=>Mu,Rect:()=>mt,Ring:()=>Ra,Sector:()=>me,Text:()=>yt,clipPointsByRect:()=>Mp,clipRectByRect:()=>Ap,createIcon:()=>Ga,extendPath:()=>wp,extendShape:()=>bp,getShapeClass:()=>Tp,getTransform:()=>bs,initProps:()=>Mt,makeImage:()=>Ss,makePath:()=>qn,mergePath:()=>Kn,registerShape:()=>Ge,resizePath:()=>Ru,updateProps:()=>xt});var wd={};Ae(wd,{addCommas:()=>As,capitalFirst:()=>A_,encodeHTML:()=>jt,formatTime:()=>M_,formatTpl:()=>eo,getTextRect:()=>qp,getTooltipMarker:()=>Yu,normalizeCssArray:()=>Ur,toCamelCase:()=>to,truncateText:()=>Gc});var Td={};Ae(Td,{bind:()=>X,clone:()=>K,curry:()=>lt,defaults:()=>q,each:()=>T,extend:()=>N,filter:()=>Tt,indexOf:()=>at,inherits:()=>Io,isArray:()=>k,isFunction:()=>G,isObject:()=>H,isString:()=>B,map:()=>U,merge:()=>it,reduce:()=>ce});var ll=ft();function _b(r,t){var e=U(t,function(i){return r.scale.parse(i)});return r.type==="time"&&e.length>0&&(e.sort(),e.unshift(e[0]),e.push(e[e.length-1])),e}function xb(r){var t=r.getLabelModel().get("customValues");if(t){var e=sn(r),i=r.scale.getExtent(),a=_b(r,t),n=Tt(a,function(o){return o>=i[0]&&o<=i[1]});return{labels:U(n,function(o){var s={value:o};return{formattedLabel:e(s),rawLabel:r.scale.getLabel(s),tickValue:o}})}}return r.type==="category"?mI(r):yI(r)}function Sb(r,t){var e=r.getTickModel().get("customValues");if(e){var i=r.scale.getExtent(),a=_b(r,e);return{ticks:Tt(a,function(n){return n>=i[0]&&n<=i[1]})}}return r.type==="category"?gI(r,t):{ticks:U(r.scale.getTicks(),function(n){return n.value})}}function mI(r){var t=r.getLabelModel(),e=bb(r,t);return!t.get("show")||r.scale.isBlank()?{labels:[],labelCategoryInterval:e.labelCategoryInterval}:e}function bb(r,t){var e=wb(r,"labels"),i=Yf(t),a=Tb(e,i);if(a)return a;var n,o;return G(i)?n=Ab(r,i):(o=i==="auto"?_I(r):i,n=Mb(r,o)),Cb(e,i,{labels:n,labelCategoryInterval:o})}function gI(r,t){var e=wb(r,"ticks"),i=Yf(t),a=Tb(e,i);if(a)return a;var n,o;if((!t.get("show")||r.scale.isBlank())&&(n=[]),G(i))n=Ab(r,i,!0);else if(i==="auto"){var s=bb(r,r.getLabelModel());o=s.labelCategoryInterval,n=U(s.labels,function(l){return l.tickValue})}else o=i,n=Mb(r,o,!0);return Cb(e,i,{ticks:n,tickCategoryInterval:o})}function yI(r){var t=r.scale.getTicks(),e=sn(r);return{labels:U(t,function(i,a){return{level:i.level,formattedLabel:e(i,a),rawLabel:r.scale.getLabel(i),tickValue:i.value}})}}function wb(r,t){return ll(r)[t]||(ll(r)[t]=[])}function Tb(r,t){for(var e=0;e40&&(s=Math.max(1,Math.floor(o/40)));for(var l=n[0],u=r.dataToCoord(l+1)-r.dataToCoord(l),f=Math.abs(u*Math.cos(i)),h=Math.abs(u*Math.sin(i)),p=0,c=0;l<=n[1];l+=s){var v=0,m=0,d=An(e({value:l}),t.font,"center","top");v=d.width*1.3,m=d.height*1.3,p=Math.max(p,v,7),c=Math.max(c,m,7)}var g=p/f,y=c/h;isNaN(g)&&(g=1/0),isNaN(y)&&(y=1/0);var _=Math.max(0,Math.floor(Math.min(g,y))),x=ll(r.model),S=r.getExtent(),b=x.lastAutoInterval,w=x.lastTickCount;return b!=null&&w!=null&&Math.abs(b-_)<=1&&Math.abs(w-o)<=1&&b>_&&x.axisExtent0===S[0]&&x.axisExtent1===S[1]?_=b:(x.lastTickCount=o,x.lastAutoInterval=_,x.axisExtent0=S[0],x.axisExtent1=S[1]),_}function xI(r){var t=r.getLabelModel();return{axisRotate:r.getRotate?r.getRotate():r.isHorizontal&&!r.isHorizontal()?90:0,labelRotate:t.get("rotate")||0,font:t.getFont()}}function Mb(r,t,e){var i=sn(r),a=r.scale,n=a.getExtent(),o=r.getLabelModel(),s=[],l=Math.max((t||0)+1,1),u=n[0],f=a.count();u!==0&&l>1&&f/l>2&&(u=Math.round(Math.ceil(u/l)*l));var h=Zf(r),p=o.get("showMinLabel")||h,c=o.get("showMaxLabel")||h;p&&u!==n[0]&&m(n[0]);for(var v=u;v<=n[1];v+=l)m(v);c&&v-l!==n[1]&&m(n[1]);function m(d){var g={value:d};s.push(e?d:{formattedLabel:i(g),rawLabel:a.getLabel(g),tickValue:d})}return s}function Ab(r,t,e){var i=r.scale,a=sn(r),n=[];return T(i.getTicks(),function(o){var s=i.getLabel(o),l=o.value;t(o.value,s)&&n.push(e?l:{formattedLabel:a(o),rawLabel:s,tickValue:l})}),n}var Eb=[0,1],SI=(function(){function r(t,e,i){this.onBand=!1,this.inverse=!1,this.dim=t,this.scale=e,this._extent=i||[0,0]}return r.prototype.contain=function(t){var e=this._extent,i=Math.min(e[0],e[1]),a=Math.max(e[0],e[1]);return t>=i&&t<=a},r.prototype.containData=function(t){return this.scale.contain(t)},r.prototype.getExtent=function(){return this._extent.slice()},r.prototype.getPixelPrecision=function(t){return Pn(t||this.scale.getExtent(),this._extent)},r.prototype.setExtent=function(t,e){var i=this._extent;i[0]=t,i[1]=e},r.prototype.dataToCoord=function(t,e){var i=this._extent,a=this.scale;return t=a.normalize(t),this.onBand&&a.type==="ordinal"&&(i=i.slice(),Lb(i,a.count())),Ct(t,Eb,i,e)},r.prototype.coordToData=function(t,e){var i=this._extent,a=this.scale;this.onBand&&a.type==="ordinal"&&(i=i.slice(),Lb(i,a.count()));var n=Ct(t,i,Eb,e);return this.scale.scale(n)},r.prototype.pointToData=function(t,e){},r.prototype.getTicksCoords=function(t){t=t||{};var e=t.tickModel||this.getTickModel(),i=Sb(this,e),a=i.ticks,n=U(a,function(s){return{coord:this.dataToCoord(this.scale.type==="ordinal"?this.scale.getRawOrdinalNumber(s):s),tickValue:s}},this),o=e.get("alignWithLabel");return bI(this,n,o,t.clamp),n},r.prototype.getMinorTicksCoords=function(){if(this.scale.type==="ordinal")return[];var t=this.model.getModel("minorTick"),e=t.get("splitNumber");e>0&&e<100||(e=5);var i=this.scale.getMinorTicks(e),a=U(i,function(n){return U(n,function(o){return{coord:this.dataToCoord(o),tickValue:o}},this)},this);return a},r.prototype.getViewLabels=function(){return xb(this).labels},r.prototype.getLabelModel=function(){return this.model.getModel("axisLabel")},r.prototype.getTickModel=function(){return this.model.getModel("axisTick")},r.prototype.getBandWidth=function(){var t=this._extent,e=this.scale.getExtent(),i=e[1]-e[0]+(this.onBand?1:0);i===0&&(i=1);var a=Math.abs(t[1]-t[0]);return Math.abs(a)/i},r.prototype.calculateCategoryInterval=function(){return Db(this)},r})();function Lb(r,t){var e=r[1]-r[0],i=t,a=e/i/2;r[0]+=a,r[1]-=a}function bI(r,t,e,i){var a=t.length;if(!r.onBand||e||!a)return;var n=r.getExtent(),o,s;if(a===1)t[0].coord=n[0],o=t[1]={coord:n[1],tickValue:t[0].tickValue};else{var l=t[a-1].tickValue-t[0].tickValue,u=(t[a-1].coord-t[0].coord)/l;T(t,function(c){c.coord-=u/2});var f=r.scale.getExtent();s=1+f[1]-t[a-1].tickValue,o={coord:t[a-1].coord+u*s,tickValue:f[1]+1},t.push(o)}var h=n[0]>n[1];p(t[0].coord,n[0])&&(i?t[0].coord=n[0]:t.shift()),i&&p(n[0],t[0].coord)&&t.unshift({coord:n[0]}),p(n[1],o.coord)&&(i?o.coord=n[1]:t.pop()),i&&p(o.coord,n[1])&&t.push({coord:n[1]});function p(c,v){return c=bt(c),v=bt(v),h?c>v:c0){t=t/180*Math.PI,Yi.fromArray(r[0]),Vt.fromArray(r[1]),he.fromArray(r[2]),st.sub(Zi,Yi,Vt),st.sub(Hr,he,Vt);var e=Zi.len(),i=Hr.len();if(!(e<.001||i<.001)){Zi.scale(1/e),Hr.scale(1/i);var a=Zi.dot(Hr),n=Math.cos(t);if(n1&&st.copy(Me,he),Me.toArray(r[1])}}}}function Rb(r,t,e){if(e<=180&&e>0){e=e/180*Math.PI,Yi.fromArray(r[0]),Vt.fromArray(r[1]),he.fromArray(r[2]),st.sub(Zi,Vt,Yi),st.sub(Hr,he,Vt);var i=Zi.len(),a=Hr.len();if(!(i<.001||a<.001)){Zi.scale(1/i),Hr.scale(1/a);var n=Zi.dot(t),o=Math.cos(e);if(n=l)st.copy(Me,he);else{Me.scaleAndAdd(Hr,s/Math.tan(Math.PI/2-f));var h=he.x!==Vt.x?(Me.x-Vt.x)/(he.x-Vt.x):(Me.y-Vt.y)/(he.y-Vt.y);if(isNaN(h))return;h<0?st.copy(Me,Vt):h>1&&st.copy(Me,he)}Me.toArray(r[1])}}}}function Cd(r,t,e,i){var a=e==="normal",n=a?r:r.ensureState(e);n.ignore=t;var o=i.get("smooth");o&&o===!0&&(o=.3),n.shape=n.shape||{},o>0&&(n.shape.smooth=o);var s=i.getModel("lineStyle").getLineStyle();a?r.useStyle(s):n.style=s}function MI(r,t){var e=t.smooth,i=t.points;if(i)if(r.moveTo(i[0][0],i[0][1]),e>0&&i.length>=3){var a=xn(i[0],i[1]),n=xn(i[1],i[2]);if(!a||!n){r.lineTo(i[1][0],i[1][1]),r.lineTo(i[2][0],i[2][1]);return}var o=Math.min(a,n)*e,s=Bo([],i[1],i[0],o/a),l=Bo([],i[1],i[2],o/n),u=Bo([],s,l,.5);r.bezierCurveTo(s[0],s[1],s[0],s[1],u[0],u[1]),r.bezierCurveTo(l[0],l[1],l[0],l[1],i[2][0],i[2][1])}else for(var f=1;f0&&n&&b(-h/o,0,o);var d=r[0],g=r[o-1],y,_;x(),y<0&&w(-y,.8),_<0&&w(_,.8),x(),S(y,_,1),S(_,y,-1),x(),y<0&&C(-y),_<0&&C(_);function x(){y=d.rect[t]-i,_=a-g.rect[t]-g.rect[e]}function S(M,A,D){if(M<0){var E=Math.min(A,-M);if(E>0){b(E*D,0,o);var L=E+M;L<0&&w(-L*D,1)}else w(-M*D,1)}}function b(M,A,D){M!==0&&(u=!0);for(var E=A;E0)for(var L=0;L0;L--){var V=D[L-1]*O;b(-V,L,o)}}}function C(M){var A=M<0?-1:1;M=Math.abs(M);for(var D=Math.ceil(M/(o-1)),E=0;E0?b(D,0,E+1):b(-D,o-E-1,o),M-=D,M<=0)return}return u}function zb(r,t,e,i){return AI(r,"y","height",t,e,i)}function Ub(r){var t=[];r.sort(function(m,d){return d.priority-m.priority});var e=new nt(0,0,0,0);function i(m){if(!m.ignore){var d=m.ensureState("emphasis");d.ignore==null&&(d.ignore=!1)}m.ignore=!0}for(var a=0;a-1&&(u.style.stroke=u.style.fill,u.style.fill="#fff",u.style.lineWidth=2),i},t.type="series.line",t.dependencies=["grid","polar"],t.defaultOption={z:3,coordinateSystem:"cartesian2d",legendHoverLink:!0,clip:!0,label:{position:"top"},endLabel:{show:!1,valueAnimation:!0,distance:8},lineStyle:{width:2,type:"solid"},emphasis:{scale:!0},step:!1,smooth:!1,smoothMonotone:null,symbol:"emptyCircle",symbolSize:4,symbolRotate:null,showSymbol:!0,showAllSymbol:"auto",connectNulls:!1,sampling:"none",animationEasing:"linear",progressive:0,hoverLayerThreshold:1/0,universalTransition:{divideShape:"clone"},triggerLineEvent:!1},t})(kt),Bb=EI;function xo(r,t){var e=r.mapDimensionsAll("defaultedLabel"),i=e.length;if(i===1){var a=ci(r,t,e[0]);return a!=null?a+"":null}else if(i){for(var n=[],o=0;o=0&&i.push(t[n])}return i.join(" ")}var LI=(function(r){P(t,r);function t(e,i,a,n){var o=r.call(this)||this;return o.updateData(e,i,a,n),o}return t.prototype._createSymbol=function(e,i,a,n,o){this.removeAll();var s=It(e,-1,-1,2,2,null,o);s.attr({z2:100,culling:!0,scaleX:n[0]/2,scaleY:n[1]/2}),s.drift=PI,this._symbolType=e,this.add(s)},t.prototype.stopSymbolAnimation=function(e){this.childAt(0).stopAnimation(null,e)},t.prototype.getSymbolType=function(){return this._symbolType},t.prototype.getSymbolPath=function(){return this.childAt(0)},t.prototype.highlight=function(){ai(this.childAt(0))},t.prototype.downplay=function(){ni(this.childAt(0))},t.prototype.setZ=function(e,i){var a=this.childAt(0);a.zlevel=e,a.z=i},t.prototype.setDraggable=function(e,i){var a=this.childAt(0);a.draggable=e,a.cursor=!i&&e?"move":a.cursor},t.prototype.updateData=function(e,i,a,n){this.silent=!1;var o=e.getItemVisual(i,"symbol")||"circle",s=e.hostModel,l=t.getSymbolSize(e,i),u=o!==this._symbolType,f=n&&n.disableAnimation;if(u){var h=e.getItemVisual(i,"symbolKeepAspect");this._createSymbol(o,e,i,l,h)}else{var p=this.childAt(0);p.silent=!1;var c={scaleX:l[0]/2,scaleY:l[1]/2};f?p.attr(c):xt(p,c,s,i),si(p)}if(this._updateCommon(e,i,l,a,n),u){var p=this.childAt(0);if(!f){var c={scaleX:this._sizeX,scaleY:this._sizeY,style:{opacity:p.style.opacity}};p.scaleX=p.scaleY=0,p.style.opacity=0,Mt(p,c,s,i)}}f&&this.childAt(0).stopAnimation("leave")},t.prototype._updateCommon=function(e,i,a,n,o){var s=this.childAt(0),l=e.hostModel,u,f,h,p,c,v,m,d,g;if(n&&(u=n.emphasisItemStyle,f=n.blurItemStyle,h=n.selectItemStyle,p=n.focus,c=n.blurScope,m=n.labelStatesModels,d=n.hoverScale,g=n.cursorStyle,v=n.emphasisDisabled),!n||e.hasItemOption){var y=n&&n.itemModel?n.itemModel:e.getItemModel(i),_=y.getModel("emphasis");u=_.getModel("itemStyle").getItemStyle(),h=y.getModel(["select","itemStyle"]).getItemStyle(),f=y.getModel(["blur","itemStyle"]).getItemStyle(),p=_.get("focus"),c=_.get("blurScope"),v=_.get("disabled"),m=ge(y),d=_.getShallow("scale"),g=y.getShallow("cursor")}var x=e.getItemVisual(i,"symbolRotate");s.attr("rotation",(x||0)*Math.PI/180||0);var S=rn(e.getItemVisual(i,"symbolOffset"),a);S&&(s.x=S[0],s.y=S[1]),g&&s.attr("cursor",g);var b=e.getItemVisual(i,"style"),w=b.fill;if(s instanceof ie){var C=s.style;s.useStyle(N({image:C.image,x:C.x,y:C.y,width:C.width,height:C.height},b))}else s.__isEmptyBrush?s.useStyle(N({},b)):s.useStyle(b),s.style.decal=null,s.setColor(w,o&&o.symbolInnerColor),s.style.strokeNoScale=!0;var M=e.getItemVisual(i,"liftZ"),A=this._z2;M!=null?A==null&&(this._z2=s.z2,s.z2+=M):A!=null&&(s.z2=A,this._z2=null);var D=o&&o.useNameLabel;Re(s,m,{labelFetcher:l,labelDataIndex:i,defaultText:E,inheritColor:w,defaultOpacity:b.opacity});function E(R){return D?e.getName(R):xo(e,R)}this._sizeX=a[0]/2,this._sizeY=a[1]/2;var L=s.ensureState("emphasis");L.style=u,s.ensureState("select").style=h,s.ensureState("blur").style=f;var I=d==null||d===!0?Math.max(1.1,3/this._sizeY):isFinite(d)&&d>0?+d:1;L.scaleX=this._sizeX*I,L.scaleY=this._sizeY*I,this.setSymbolScale(1),ve(this,p,c,v)},t.prototype.setSymbolScale=function(e){this.scaleX=this.scaleY=e},t.prototype.fadeOut=function(e,i,a){var n=this.childAt(0),o=ot(this).dataIndex,s=a&&a.animation;if(this.silent=n.silent=!0,a&&a.fadeLabel){var l=n.getTextContent();l&&Xn(l,{style:{opacity:0}},i,{dataIndex:o,removeOpt:s,cb:function(){n.removeTextContent()}})}else n.removeTextContent();Xn(n,{style:{opacity:0},scaleX:0,scaleY:0},i,{dataIndex:o,cb:e,removeOpt:s})},t.getSymbolSize=function(e,i){return en(e.getItemVisual(i,"symbolSize"))},t})(ut);function PI(r,t){this.parent.drift(r,t)}var ul=LI;function Md(r,t,e,i){return t&&!isNaN(t[0])&&!isNaN(t[1])&&!(i.isIgnore&&i.isIgnore(e))&&!(i.clipShape&&!i.clipShape.contain(t[0],t[1]))&&r.getItemVisual(e,"symbol")!=="none"}function Vb(r){return r!=null&&!H(r)&&(r={isIgnore:r}),r||{}}function Fb(r){var t=r.hostModel,e=t.getModel("emphasis");return{emphasisItemStyle:e.getModel("itemStyle").getItemStyle(),blurItemStyle:t.getModel(["blur","itemStyle"]).getItemStyle(),selectItemStyle:t.getModel(["select","itemStyle"]).getItemStyle(),focus:e.get("focus"),blurScope:e.get("blurScope"),emphasisDisabled:e.get("disabled"),hoverScale:e.get("scale"),labelStatesModels:ge(t),cursorStyle:t.get("cursor")}}var II=(function(){function r(t){this.group=new ut,this._SymbolCtor=t||ul}return r.prototype.updateData=function(t,e){this._progressiveEls=null,e=Vb(e);var i=this.group,a=t.hostModel,n=this._data,o=this._SymbolCtor,s=e.disableAnimation,l=Fb(t),u={disableAnimation:s},f=e.getSymbolPoint||function(h){return t.getItemLayout(h)};n||i.removeAll(),t.diff(n).add(function(h){var p=f(h);if(Md(t,p,h,e)){var c=new o(t,h,l,u);c.setPosition(p),t.setItemGraphicEl(h,c),i.add(c)}}).update(function(h,p){var c=n.getItemGraphicEl(p),v=f(h);if(!Md(t,v,h,e)){i.remove(c);return}var m=t.getItemVisual(h,"symbol")||"circle",d=c&&c.getSymbolType&&c.getSymbolType();if(!c||d&&d!==m)i.remove(c),c=new o(t,h,l,u),c.setPosition(v);else{c.updateData(t,h,l,u);var g={x:v[0],y:v[1]};s?c.attr(g):xt(c,g,a)}i.add(c),t.setItemGraphicEl(h,c)}).remove(function(h){var p=n.getItemGraphicEl(h);p&&p.fadeOut(function(){i.remove(p)},a)}).execute(),this._getSymbolPoint=f,this._data=t},r.prototype.updateLayout=function(){var t=this,e=this._data;e&&e.eachItemGraphicEl(function(i,a){var n=t._getSymbolPoint(a);i.setPosition(n),i.markRedraw()})},r.prototype.incrementalPrepareUpdate=function(t){this._seriesScope=Fb(t),this._data=null,this.group.removeAll()},r.prototype.incrementalUpdate=function(t,e,i){this._progressiveEls=[],i=Vb(i);function a(l){l.isGroup||(l.incremental=!0,l.ensureState("emphasis").hoverLayer=!0)}for(var n=t.start;n0?e=i[0]:i[1]<0&&(e=i[1]),e}function Qf(r,t,e,i){var a=NaN;r.stacked&&(a=e.get(e.getCalculationInfo("stackedOverDimension"),i)),isNaN(a)&&(a=r.valueStart);var n=r.baseDataOffset,o=[];return o[n]=e.get(r.baseDim,i),o[1-n]=a,t.dataToPoint(o)}function OI(r,t){var e=[];return t.diff(r).add(function(i){e.push({cmd:"+",idx:i})}).update(function(i,a){e.push({cmd:"=",idx:a,idx1:i})}).remove(function(i){e.push({cmd:"-",idx:i})}).execute(),e}function Ad(r,t,e,i,a,n,o,s){for(var l=OI(r,t),u=[],f=[],h=[],p=[],c=[],v=[],m=[],d=jf(a,t,o),g=r.getLayout("points")||[],y=t.getLayout("points")||[],_=0;_=a||m<0)break;if(ln(g,y)){if(l){m+=n;continue}break}if(m===e)r[n>0?"moveTo":"lineTo"](g,y),h=g,p=y;else{var _=g-u,x=y-f;if(_*_+x*x<.5){m+=n;continue}if(o>0){for(var S=m+n,b=t[S*2],w=t[S*2+1];b===g&&w===y&&d=i||ln(b,w))c=g,v=y;else{A=b-u,D=w-f;var I=g-u,R=b-g,O=y-f,V=w-y,z=void 0,F=void 0;if(s==="x"){z=Math.abs(I),F=Math.abs(R);var W=A>0?1:-1;c=g-W*z*o,v=y,E=g+W*F*o,L=y}else if(s==="y"){z=Math.abs(O),F=Math.abs(V);var Z=D>0?1:-1;c=g,v=y-Z*z*o,E=g,L=y+Z*F*o}else z=Math.sqrt(I*I+O*O),F=Math.sqrt(R*R+V*V),M=F/(F+z),c=g-A*o*(1-M),v=y-D*o*(1-M),E=g+A*o*M,L=y+D*o*M,E=Xi(E,qi(b,g)),L=Xi(L,qi(w,y)),E=qi(E,Xi(b,g)),L=qi(L,Xi(w,y)),A=E-g,D=L-y,c=g-A*z/F,v=y-D*z/F,c=Xi(c,qi(u,g)),v=Xi(v,qi(f,y)),c=qi(c,Xi(u,g)),v=qi(v,Xi(f,y)),A=g-c,D=y-v,E=g+A*F/z,L=y+D*F/z}r.bezierCurveTo(h,p,c,v,g,y),h=E,p=L}else r.lineTo(g,y)}u=g,f=y,m+=n}return d}var Gb=(function(){function r(){this.smooth=0,this.smoothConstraint=!0}return r})(),Hb=(function(r){P(t,r);function t(e){var i=r.call(this,e)||this;return i.type="ec-polyline",i}return t.prototype.getDefaultStyle=function(){return{stroke:"#000",fill:null}},t.prototype.getDefaultShape=function(){return new Gb},t.prototype.buildPath=function(e,i){var a=i.points,n=0,o=a.length/2;if(i.connectNulls){for(;o>0&&ln(a[o*2-2],a[o*2-1]);o--);for(;n=0){var x=u?(v-l)*_+l:(c-s)*_+s;return u?[e,x]:[x,e]}s=c,l=v;break;case o.C:c=n[h++],v=n[h++],m=n[h++],d=n[h++],g=n[h++],y=n[h++];var S=u?fa(s,c,m,g,e,f):fa(l,v,d,y,e,f);if(S>0)for(var b=0;b=0){var x=u?Rt(l,v,d,y,w):Rt(s,c,m,g,w);return u?[e,x]:[x,e]}}s=g,l=y;break}}},t})(rt);var NI=(function(r){P(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t})(Gb),Wb=(function(r){P(t,r);function t(e){var i=r.call(this,e)||this;return i.type="ec-polygon",i}return t.prototype.getDefaultShape=function(){return new NI},t.prototype.buildPath=function(e,i){var a=i.points,n=i.stackedOnPoints,o=0,s=a.length/2,l=i.smoothMonotone;if(i.connectNulls){for(;s>0&&ln(a[s*2-2],a[s*2-1]);s--);for(;ot){n?e.push(o(n,l,t)):a&&e.push(o(a,l,0),o(a,l,t));break}else a&&(e.push(o(a,l,0)),a=null),e.push(l),n=l}return e}function UI(r,t,e){var i=r.getVisual("visualMeta");if(!(!i||!i.length||!r.count())&&t.type==="cartesian2d"){for(var a,n,o=i.length-1;o>=0;o--){var s=r.getDimensionInfo(i[o].dimension);if(a=s&&s.coordDim,a==="x"||a==="y"){n=i[o];break}}if(n){var l=t.getAxis(a),u=U(n.stops,function(_){return{coord:l.toGlobalCoord(l.dataToCoord(_.value)),color:_.color}}),f=u.length,h=n.outerColors.slice();f&&u[0].coord>u[f-1].coord&&(u.reverse(),h.reverse());var p=zI(u,a==="x"?e.getWidth():e.getHeight()),c=p.length;if(!c&&f)return u[0].coord<0?h[1]?h[1]:u[f-1].color:h[0]?h[0]:u[0].color;var v=10,m=p[0].coord-v,d=p[c-1].coord+v,g=d-m;if(g<.001)return"transparent";T(p,function(_){_.offset=(_.coord-m)/g}),p.push({offset:c?p[c-1].offset:.5,color:h[1]||"transparent"}),p.unshift({offset:c?p[0].offset:.5,color:h[0]||"transparent"});var y=new Yn(0,0,0,0,p,!0);return y[a]=m,y[a+"2"]=d,y}}}function BI(r,t,e){var i=r.get("showAllSymbol"),a=i==="auto";if(!(i&&!a)){var n=e.getAxesByScale("ordinal")[0];if(n&&!(a&&VI(n,t))){var o=t.mapDimension(n.dim),s={};return T(n.getViewLabels(),function(l){var u=n.scale.getRawOrdinalNumber(l.tickValue);s[u]=1}),function(l){return!s.hasOwnProperty(t.get(o,l))}}}}function VI(r,t){var e=r.getExtent(),i=Math.abs(e[1]-e[0])/r.scale.count();isNaN(i)&&(i=0);for(var a=t.count(),n=Math.max(1,Math.round(a/5)),o=0;oi)return!1;return!0}function FI(r,t){return isNaN(r)||isNaN(t)}function GI(r){for(var t=r.length/2;t>0&&FI(r[t*2-2],r[t*2-1]);t--);return t-1}function jb(r,t){return[r[t*2],r[t*2+1]]}function HI(r,t,e){for(var i=r.length/2,a=e==="x"?0:1,n,o,s=0,l=-1,u=0;u=t||n>=t&&o<=t){l=u;break}s=u,n=o}return{range:[s,l],t:(t-n)/(o-n)}}function Qb(r){if(r.get(["endLabel","show"]))return!0;for(var t=0;t0&&e.get(["emphasis","lineStyle","width"])==="bolder"){var F=v.getState("emphasis").style;F.lineWidth=+v.style.lineWidth+1}ot(v).seriesIndex=e.seriesIndex,ve(v,O,V,z);var W=Kb(e.get("smooth")),Z=e.get("smoothMonotone");if(v.setShape({smooth:W,smoothMonotone:Z,connectNulls:w}),m){var J=s.getCalculationInfo("stackedOnSeries"),vt=0;m.useStyle(q(u.getAreaStyle(),{fill:E,opacity:.7,lineJoin:"bevel",decal:s.getVisual("style").decal})),J&&(vt=Kb(J.get("smooth"))),m.setShape({smooth:W,stackedOnSmooth:vt,smoothMonotone:Z,connectNulls:w}),Fe(m,e,"areaStyle"),ot(m).seriesIndex=e.seriesIndex,ve(m,O,V,z)}var gt=this._changePolyState;s.eachItemGraphicEl(function(St){St&&(St.onHoverStateChange=gt)}),this._polyline.onHoverStateChange=gt,this._data=s,this._coordSys=n,this._stackedOnPoints=S,this._points=f,this._step=A,this._valueOrigin=_,e.get("triggerLineEvent")&&(this.packEventData(e,v),m&&this.packEventData(e,m))},t.prototype.packEventData=function(e,i){ot(i).eventData={componentType:"series",componentSubType:"line",componentIndex:e.componentIndex,seriesIndex:e.seriesIndex,seriesName:e.name,seriesType:"line"}},t.prototype.highlight=function(e,i,a,n){var o=e.getData(),s=ir(o,n);if(this._changePolyState("emphasis"),!(s instanceof Array)&&s!=null&&s>=0){var l=o.getLayout("points"),u=o.getItemGraphicEl(s);if(!u){var f=l[s*2],h=l[s*2+1];if(isNaN(f)||isNaN(h)||this._clipShapeForSymbol&&!this._clipShapeForSymbol.contain(f,h))return;var p=e.get("zlevel")||0,c=e.get("z")||0;u=new ul(o,s),u.x=f,u.y=h,u.setZ(p,c);var v=u.getSymbolPath().getTextContent();v&&(v.zlevel=p,v.z=c,v.z2=this._polyline.z2+1),u.__temp=!0,o.setItemGraphicEl(s,u),u.stopSymbolAnimation(!0),this.group.add(u)}u.highlight()}else Pt.prototype.highlight.call(this,e,i,a,n)},t.prototype.downplay=function(e,i,a,n){var o=e.getData(),s=ir(o,n);if(this._changePolyState("normal"),s!=null&&s>=0){var l=o.getItemGraphicEl(s);l&&(l.__temp?(o.setItemGraphicEl(s,null),this.group.remove(l)):l.downplay())}else Pt.prototype.downplay.call(this,e,i,a,n)},t.prototype._changePolyState=function(e){var i=this._polygon;lp(this._polyline,e),i&&lp(i,e)},t.prototype._newPolyline=function(e){var i=this._polyline;return i&&this._lineGroup.remove(i),i=new Hb({shape:{points:e},segmentIgnoreThreshold:2,z2:10}),this._lineGroup.add(i),this._polyline=i,i},t.prototype._newPolygon=function(e,i){var a=this._polygon;return a&&this._lineGroup.remove(a),a=new Wb({shape:{points:e,stackedOnPoints:i},segmentIgnoreThreshold:2}),this._lineGroup.add(a),this._polygon=a,a},t.prototype._initSymbolLabelAnimation=function(e,i,a){var n,o,s=i.getBaseAxis(),l=s.inverse;i.type==="cartesian2d"?(n=s.isHorizontal(),o=!1):i.type==="polar"&&(n=s.dim==="angle",o=!0);var u=e.hostModel,f=u.get("animationDuration");G(f)&&(f=f(null));var h=u.get("animationDelay")||0,p=G(h)?h(null):h;e.eachItemGraphicEl(function(c,v){var m=c;if(m){var d=[c.x,c.y],g=void 0,y=void 0,_=void 0;if(a)if(o){var x=a,S=i.pointToCoord(d);n?(g=x.startAngle,y=x.endAngle,_=-S[1]/180*Math.PI):(g=x.r0,y=x.r,_=S[0])}else{var b=a;n?(g=b.x,y=b.x+b.width,_=c.x):(g=b.y+b.height,y=b.y,_=c.y)}var w=y===g?0:(_-g)/(y-g);l&&(w=1-w);var C=G(h)?h(v):f*w+p,M=m.getSymbolPath(),A=M.getTextContent();m.attr({scaleX:0,scaleY:0}),m.animateTo({scaleX:1,scaleY:1},{duration:200,setToFinal:!0,delay:C}),A&&A.animateFrom({style:{opacity:0}},{duration:300,delay:C}),M.disableLabelAnimation=!0}})},t.prototype._initOrUpdateEndLabel=function(e,i,a){var n=e.getModel("endLabel");if(Qb(e)){var o=e.getData(),s=this._polyline,l=o.getLayout("points");if(!l){s.removeTextContent(),this._endLabel=null;return}var u=this._endLabel;u||(u=this._endLabel=new yt({z2:200}),u.ignoreClip=!0,s.setTextContent(this._endLabel),s.disableLabelAnimation=!0);var f=GI(l);f>=0&&(Re(s,ge(e,"endLabel"),{inheritColor:a,labelFetcher:e,labelDataIndex:f,defaultText:function(h,p,c){return c!=null?Kf(o,c):xo(o,h)},enableTextSetter:!0},WI(n,i)),s.textConfig.position=null)}else this._endLabel&&(this._polyline.removeTextContent(),this._endLabel=null)},t.prototype._endLabelOnDuring=function(e,i,a,n,o,s,l){var u=this._endLabel,f=this._polyline;if(u){e<1&&n.originalX==null&&(n.originalX=u.x,n.originalY=u.y);var h=a.getLayout("points"),p=a.hostModel,c=p.get("connectNulls"),v=s.get("precision"),m=s.get("distance")||0,d=l.getBaseAxis(),g=d.isHorizontal(),y=d.inverse,_=i.shape,x=y?g?_.x:_.y+_.height:g?_.x+_.width:_.y,S=(g?m:0)*(y?-1:1),b=(g?0:-m)*(y?-1:1),w=g?"x":"y",C=HI(h,x,w),M=C.range,A=M[1]-M[0],D=void 0;if(A>=1){if(A>1&&!c){var E=jb(h,M[0]);u.attr({x:E[0]+S,y:E[1]+b}),o&&(D=p.getRawValue(M[0]))}else{var E=f.getPointOn(x,w);E&&u.attr({x:E[0]+S,y:E[1]+b});var L=p.getRawValue(M[0]),I=p.getRawValue(M[1]);o&&(D=uu(a,v,L,I,C.t))}n.lastFrameIndex=M[0]}else{var R=e===1||n.lastFrameIndex>0?M[0]:0,E=jb(h,R);o&&(D=p.getRawValue(R)),u.attr({x:E[0]+S,y:E[1]+b})}if(o){var O=Ha(u);typeof O.setLabelText=="function"&&O.setLabelText(D)}}},t.prototype._doUpdateAnimation=function(e,i,a,n,o,s,l){var u=this._polyline,f=this._polygon,h=e.hostModel,p=Ad(this._data,e,this._stackedOnPoints,i,this._coordSys,a,this._valueOrigin,s),c=p.current,v=p.stackedOnCurrent,m=p.next,d=p.stackedOnNext;if(o&&(v=Ki(p.stackedOnCurrent,p.current,a,o,l),c=Ki(p.current,null,a,o,l),d=Ki(p.stackedOnNext,p.next,a,o,l),m=Ki(p.next,null,a,o,l)),qb(c,m)>3e3||f&&qb(v,d)>3e3){u.stopAnimation(),u.setShape({points:m}),f&&(f.stopAnimation(),f.setShape({points:m,stackedOnPoints:d}));return}u.shape.__points=p.current,u.shape.points=c;var g={shape:{points:m}};p.current!==c&&(g.shape.__points=p.next),u.stopAnimation(),xt(u,g,h),f&&(f.setShape({points:c,stackedOnPoints:v}),f.stopAnimation(),xt(f,{shape:{stackedOnPoints:d}},h),u.shape.points!==f.shape.points&&(f.shape.points=u.shape.points));for(var y=[],_=p.status,x=0;x<_.length;x++){var S=_[x].cmd;if(S==="="){var b=e.getItemGraphicEl(_[x].idx1);b&&y.push({el:b,ptIdx:x})}}u.animators&&u.animators.length&&u.animators[0].during(function(){f&&f.dirtyShape();for(var w=u.shape.__points,C=0;Ct&&(t=r[e]);return isFinite(t)?t:NaN},min:function(r){for(var t=1/0,e=0;e10&&o.type==="cartesian2d"&&n){var l=o.getBaseAxis(),u=o.getOtherAxis(l),f=l.getExtent(),h=i.getDevicePixelRatio(),p=Math.abs(f[1]-f[0])*(h||1),c=Math.round(s/p);if(isFinite(c)&&c>1){n==="lttb"?t.setData(a.lttbDownSample(a.mapDimension(u.dim),1/c)):n==="minmax"&&t.setData(a.minmaxDownSample(a.mapDimension(u.dim),1/c));var v=void 0;B(n)?v=ZI[n]:G(n)&&(v=n),v&&t.setData(a.downSample(a.mapDimension(u.dim),1/c,v,XI))}}}}}function Rd(r){r.registerChartView(Jb),r.registerSeriesModel(Bb),r.registerLayout(fn("line",!0)),r.registerVisual({seriesType:"line",reset:function(t){var e=t.getData(),i=t.getModel("lineStyle").getLineStyle();i&&!i.stroke&&(i.stroke=e.getVisual("style").fill),e.setVisual("legendLineStyle",i)}}),r.registerProcessor(r.PRIORITY.PROCESSOR.STATISTIC,fl("line"))}var $b=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.getInitialData=function(e,i){return Gr(null,this,{useEncodeDefaulter:!0})},t.prototype.getMarkerPosition=function(e,i,a){var n=this.coordinateSystem;if(n&&n.clampData){var o=n.clampData(e),s=n.dataToPoint(o);if(a)T(n.getAxes(),function(p,c){if(p.type==="category"&&i!=null){var v=p.getTicksCoords(),m=p.getTickModel().get("alignWithLabel"),d=o[c],g=i[c]==="x1"||i[c]==="y1";if(g&&!m&&(d+=1),v.length<2)return;if(v.length===2){s[c]=p.toGlobalCoord(p.getExtent()[g?1:0]);return}for(var y=void 0,_=void 0,x=1,S=0;Sd){_=(b+y)/2;break}S===1&&(x=w-v[0].tickValue)}_==null&&(y?y&&(_=v[v.length-1].coord):_=v[0].coord),s[c]=p.toGlobalCoord(_)}});else{var l=this.getData(),u=l.getLayout("offset"),f=l.getLayout("size"),h=n.getBaseAxis().isHorizontal()?0:1;s[h]+=u+f/2}return s}return[NaN,NaN]},t.type="series.__base_bar__",t.defaultOption={z:2,coordinateSystem:"cartesian2d",legendHoverLink:!0,barMinHeight:0,barMinAngle:0,large:!1,largeThreshold:400,progressive:3e3,progressiveChunkMode:"mod"},t})(kt);kt.registerClass($b);var Od=$b;var qI=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.getInitialData=function(){return Gr(null,this,{useEncodeDefaulter:!0,createInvertedIndices:!!this.get("realtimeSort",!0)||null})},t.prototype.getProgressive=function(){return this.get("large")?this.get("progressive"):!1},t.prototype.getProgressiveThreshold=function(){var e=this.get("progressiveThreshold"),i=this.get("largeThreshold");return i>e&&(e=i),e},t.prototype.brushSelector=function(e,i,a){return a.rect(i.getItemLayout(e))},t.type="series.bar",t.dependencies=["grid","polar"],t.defaultOption=Oi(Od.defaultOption,{clip:!0,roundCap:!1,showBackground:!1,backgroundStyle:{color:"rgba(180, 180, 180, 0.2)",borderColor:null,borderWidth:0,borderType:"solid",borderRadius:0,shadowBlur:0,shadowColor:null,shadowOffsetX:0,shadowOffsetY:0,opacity:1},select:{itemStyle:{borderColor:"#212121"}},realtimeSort:!1}),t})(Od),tw=qI;var KI=(function(){function r(){this.cx=0,this.cy=0,this.r0=0,this.r=0,this.startAngle=0,this.endAngle=Math.PI*2,this.clockwise=!0}return r})(),jI=(function(r){P(t,r);function t(e){var i=r.call(this,e)||this;return i.type="sausage",i}return t.prototype.getDefaultShape=function(){return new KI},t.prototype.buildPath=function(e,i){var a=i.cx,n=i.cy,o=Math.max(i.r0||0,0),s=Math.max(i.r,0),l=(s-o)*.5,u=o+l,f=i.startAngle,h=i.endAngle,p=i.clockwise,c=Math.PI*2,v=p?h-fMath.PI/2&&fs)return!0;s=h}return!1},t.prototype._isOrderDifferentInView=function(e,i){for(var a=i.scale,n=a.getExtent(),o=Math.max(0,n[0]),s=Math.min(n[1],a.getOrdinalMeta().categories.length-1);o<=s;++o)if(e.ordinalNumbers[o]!==a.getRawOrdinalNumber(o))return!0},t.prototype._updateSortWithinSameData=function(e,i,a,n){if(this._isOrderChangedWithinSameData(e,i,a)){var o=this._dataSort(e,a,i);this._isOrderDifferentInView(o,a)&&(this._removeOnRenderedListener(n),n.dispatchAction({type:"changeAxisOrder",componentType:a.dim+"Axis",axisId:a.index,sortInfo:o}))}},t.prototype._dispatchInitSort=function(e,i,a){var n=i.baseAxis,o=this._dataSort(e,n,function(s){return e.get(e.mapDimension(i.otherAxis.dim),s)});a.dispatchAction({type:"changeAxisOrder",componentType:n.dim+"Axis",isInitSort:!0,axisId:n.index,sortInfo:o})},t.prototype.remove=function(e,i){this._clear(this._model),this._removeOnRenderedListener(i)},t.prototype.dispose=function(e,i){this._removeOnRenderedListener(i)},t.prototype._removeOnRenderedListener=function(e){this._onRendered&&(e.getZr().off("rendered",this._onRendered),this._onRendered=null)},t.prototype._clear=function(e){var i=this.group,a=this._data;e&&e.isAnimationEnabled()&&a&&!this._isLargeDraw?(this._removeBackground(),this._backgroundEls=[],a.eachItemGraphicEl(function(n){Ba(n,e,ot(n).dataIndex)})):i.removeAll(),this._data=null,this._isFirstFrame=!0},t.prototype._removeBackground=function(){this.group.remove(this._backgroundGroup),this._backgroundGroup=null},t.type="bar",t})(Pt),iw={cartesian2d:function(r,t){var e=t.width<0?-1:1,i=t.height<0?-1:1;e<0&&(t.x+=t.width,t.width=-t.width),i<0&&(t.y+=t.height,t.height=-t.height);var a=r.x+r.width,n=r.y+r.height,o=Nd(t.x,r.x),s=kd(t.x+t.width,a),l=Nd(t.y,r.y),u=kd(t.y+t.height,n),f=sa?s:o,t.y=h&&l>n?u:l,t.width=f?0:s-o,t.height=h?0:u-l,e<0&&(t.x+=t.width,t.width=-t.width),i<0&&(t.y+=t.height,t.height=-t.height),f||h},polar:function(r,t){var e=t.r0<=t.r?1:-1;if(e<0){var i=t.r;t.r=t.r0,t.r0=i}var a=kd(t.r,r.r),n=Nd(t.r0,r.r0);t.r=a,t.r0=n;var o=a-n<0;if(e<0){var i=t.r;t.r=t.r0,t.r0=i}return o}},aw={cartesian2d:function(r,t,e,i,a,n,o,s,l){var u=new mt({shape:N({},i),z2:1});if(u.__dataIndex=e,u.name="item",n){var f=u.shape,h=a?"height":"width";f[h]=0}return u},polar:function(r,t,e,i,a,n,o,s,l){var u=!a&&l?bo:me,f=new u({shape:i,z2:1});f.name="item";var h=cw(a);if(f.calculateTextPosition=ew(h,{isRoundCap:u===bo}),n){var p=f.shape,c=a?"r":"endAngle",v={};p[c]=a?i.r0:i.startAngle,v[c]=i[c],(s?xt:Mt)(f,{shape:v},n)}return f}};function $I(r,t){var e=r.get("realtimeSort",!0),i=t.getBaseAxis();if(e&&i.type==="category"&&t.type==="cartesian2d")return{baseAxis:i,otherAxis:t.getOtherAxis(i)}}function nw(r,t,e,i,a,n,o,s){var l,u;n?(u={x:i.x,width:i.width},l={y:i.y,height:i.height}):(u={y:i.y,height:i.height},l={x:i.x,width:i.width}),s||(o?xt:Mt)(e,{shape:l},t,a,null);var f=t?r.baseAxis.model:null;(o?xt:Mt)(e,{shape:u},f,a)}function ow(r,t){for(var e=0;e0?1:-1,o=i.height>0?1:-1;return{x:i.x+n*a/2,y:i.y+o*a/2,width:i.width-n*a,height:i.height-o*a}},polar:function(r,t,e){var i=r.getItemLayout(t);return{cx:i.cx,cy:i.cy,r0:i.r0,r:i.r,startAngle:i.startAngle,endAngle:i.endAngle,clockwise:i.clockwise}}};function rR(r){return r.startAngle!=null&&r.endAngle!=null&&r.startAngle===r.endAngle}function cw(r){return(function(t){var e=t?"Arc":"Angle";return function(i){switch(i){case"start":case"insideStart":case"end":case"insideEnd":return i+e;default:return i}}})(r)}function lw(r,t,e,i,a,n,o,s){var l=t.getItemVisual(e,"style");if(s){if(!n.get("roundCap")){var f=r.shape,h=hn(i.getModel("itemStyle"),f,!0);N(f,h),r.setShape(f)}}else{var u=i.get(["itemStyle","borderRadius"])||0;r.setShape("r",u)}r.useStyle(l);var p=i.getShallow("cursor");p&&r.attr("cursor",p);var c=s?o?a.r>=a.r0?"endArc":"startArc":a.endAngle>=a.startAngle?"endAngle":"startAngle":o?a.height>=0?"bottom":"top":a.width>=0?"right":"left",v=ge(i);Re(r,v,{labelFetcher:n,labelDataIndex:e,defaultText:xo(n.getData(),e),inheritColor:l.fill,defaultOpacity:l.opacity,defaultOutsidePosition:c});var m=r.getTextContent();if(s&&m){var d=i.get(["label","position"]);r.textConfig.inside=d==="middle"?!0:null,rw(r,d==="outside"?c:d,cw(o),i.get(["label","rotate"]))}Nu(m,v,n.getRawValue(e),function(y){return Kf(t,y)});var g=i.getModel(["emphasis"]);ve(r,g.get("focus"),g.get("blurScope"),g.get("disabled")),Fe(r,i),rR(a)&&(r.style.fill="none",r.style.stroke="none",T(r.states,function(y){y.style&&(y.style.fill=y.style.stroke="none")}))}function iR(r,t){var e=r.get(["itemStyle","borderColor"]);if(!e||e==="none")return 0;var i=r.get(["itemStyle","borderWidth"])||0,a=isNaN(t.width)?Number.MAX_VALUE:Math.abs(t.width),n=isNaN(t.height)?Number.MAX_VALUE:Math.abs(t.height);return Math.min(i,a,n)}var aR=(function(){function r(){}return r})(),uw=(function(r){P(t,r);function t(e){var i=r.call(this,e)||this;return i.type="largeBar",i}return t.prototype.getDefaultShape=function(){return new aR},t.prototype.buildPath=function(e,i){for(var a=i.points,n=this.baseDimIdx,o=1-this.baseDimIdx,s=[],l=[],u=this.barWidth,f=0;f=0?e:null},30,!1);function nR(r,t,e){for(var i=r.baseDimIdx,a=1-i,n=r.shape.points,o=r.largeDataIndices,s=[],l=[],u=r.barWidth,f=0,h=n.length/3;f=s[0]&&t<=s[0]+l[0]&&e>=s[1]&&e<=s[1]+l[1])return o[f]}return-1}function pw(r,t,e){if(un(e,"cartesian2d")){var i=t,a=e.getArea();return{x:r?i.x:a.x,y:r?a.y:i.y,width:r?i.width:a.width,height:r?a.height:i.height}}else{var a=e.getArea(),n=t;return{cx:a.cx,cy:a.cy,r0:r?a.r0:n.r0,r:r?a.r:n.r,startAngle:r?n.startAngle:0,endAngle:r?n.endAngle:Math.PI*2}}}function oR(r,t,e){var i=r.type==="polar"?me:mt;return new i({shape:pw(t,e,r),silent:!0,z2:0})}var vw=JI;function zd(r){r.registerChartView(vw),r.registerSeriesModel(tw),r.registerLayout(r.PRIORITY.VISUAL.LAYOUT,lt(tb,"bar")),r.registerLayout(r.PRIORITY.VISUAL.PROGRESSIVE_LAYOUT,eb("bar")),r.registerProcessor(r.PRIORITY.PROCESSOR.STATISTIC,fl("bar")),r.registerAction({type:"changeAxisOrder",event:"changeAxisOrder",update:"update"},function(t,e){var i=t.componentType||"series";e.eachComponent({mainType:i,query:t},function(a){t.sortInfo&&a.axis.setCategorySortInfo(t.sortInfo)})})}var dw=Math.PI*2,eh=Math.PI/180;function mw(r,t){return De(r.getBoxLayoutParams(),{width:t.getWidth(),height:t.getHeight()})}function Ud(r,t){var e=mw(r,t),i=r.get("center"),a=r.get("radius");k(a)||(a=[0,a]);var n=j(e.width,t.getWidth()),o=j(e.height,t.getHeight()),s=Math.min(n,o),l=j(a[0],s/2),u=j(a[1],s/2),f,h,p=r.coordinateSystem;if(p){var c=p.dataToPoint(i);f=c[0]||0,h=c[1]||0}else k(i)||(i=[i,i]),f=j(i[0],n)+e.x,h=j(i[1],o)+e.y;return{cx:f,cy:h,r0:l,r:u}}function Bd(r,t,e){t.eachSeriesByType(r,function(i){var a=i.getData(),n=a.mapDimension("value"),o=mw(i,e),s=Ud(i,e),l=s.cx,u=s.cy,f=s.r,h=s.r0,p=-i.get("startAngle")*eh,c=i.get("endAngle"),v=i.get("padAngle")*eh;c=c==="auto"?p-dw:-c*eh;var m=i.get("minAngle")*eh,d=m+v,g=0;a.each(n,function(V){!isNaN(V)&&g++});var y=a.getSum(n),_=Math.PI/(y||g)*2,x=i.get("clockwise"),S=i.get("roseType"),b=i.get("stillShowZeroSum"),w=a.getDataExtent(n);w[0]=0;var C=x?1:-1,M=[p,c],A=C*v/2;os(M,!x),p=M[0],c=M[1];var D=Vd(i);D.startAngle=p,D.endAngle=c,D.clockwise=x;var E=Math.abs(c-p),L=E,I=0,R=p;if(a.setLayout({viewRect:o,r:f}),a.each(n,function(V,z){var F;if(isNaN(V)){a.setItemLayout(z,{angle:NaN,startAngle:NaN,endAngle:NaN,clockwise:x,cx:l,cy:u,r0:h,r:S?NaN:f});return}S!=="area"?F=y===0&&b?_:V*_:F=E/g,FF?(Z=R+C*F/2,J=Z):(Z=R+A,J=W-A),a.setItemLayout(z,{angle:F,startAngle:Z,endAngle:J,clockwise:x,cx:l,cy:u,r0:h,r:S?Ct(V,w,[h,f]):f}),R=W}),Le?g:d,S=Math.abs(_.label.y-e);if(S>=x.maxY){var b=_.label.x-t-_.len2*a,w=i+_.len,C=Math.abs(b)r.unconstrainedWidth?null:c:null;i.setStyle("width",v)}var m=i.getBoundingRect();n.width=m.width;var d=(i.style.margin||0)+2.1;n.height=m.height+d,n.y-=(n.height-h)/2}}}function Fd(r){return r.position==="center"}function Gd(r){var t=r.getData(),e=[],i,a,n=!1,o=(r.get("minShowLabelAngle")||0)*sR,s=t.getLayout("viewRect"),l=t.getLayout("r"),u=s.width,f=s.x,h=s.y,p=s.height;function c(b){b.ignore=!0}function v(b){if(!b.ignore)return!0;for(var w in b.states)if(b.states[w].ignore===!1)return!0;return!1}t.each(function(b){var w=t.getItemGraphicEl(b),C=w.shape,M=w.getTextContent(),A=w.getTextGuideLine(),D=t.getItemModel(b),E=D.getModel("label"),L=E.get("position")||D.get(["emphasis","label","position"]),I=E.get("distanceToLabelLine"),R=E.get("alignTo"),O=j(E.get("edgeDistance"),u),V=E.get("bleedMargin"),z=D.getModel("labelLine"),F=z.get("length");F=j(F,u);var W=z.get("length2");if(W=j(W,u),Math.abs(C.endAngle-C.startAngle)0?"right":"left":J>0?"left":"right"}var mi=Math.PI,Wr=0,Eo=E.get("rotate");if(et(Eo))Wr=Eo*(mi/180);else if(L==="center")Wr=0;else if(Eo==="radial"||Eo===!0){var KT=J<0?-Z+mi:-Z;Wr=KT}else if(Eo==="tangential"&&L!=="outside"&&L!=="outer"){var mn=Math.atan2(J,vt);mn<0&&(mn=mi*2+mn);var jT=vt>0;jT&&(mn=mi+mn),Wr=mn-mi}if(n=!!Wr,M.x=gt,M.y=St,M.rotation=Wr,M.setStyle({verticalAlign:"middle"}),Ue){M.setStyle({align:Ke});var Rh=M.states.select;Rh&&(Rh.x+=M.x,Rh.y+=M.y)}else{var Lo=M.getBoundingRect().clone();Lo.applyTransform(M.getComputedTransform());var Qm=(M.style.margin||0)+2.1;Lo.y-=Qm/2,Lo.height+=Qm,e.push({label:M,labelLine:A,position:L,len:F,len2:W,minTurnAngle:z.get("minTurnAngle"),maxSurfaceAngle:z.get("maxSurfaceAngle"),surfaceNormal:new st(J,vt),linePoints:se,textAlign:Ke,labelDistance:I,labelAlignTo:R,edgeDistance:O,bleedMargin:V,rect:Lo,unconstrainedWidth:Lo.width,labelStyleWidth:M.style.width})}w.setTextConfig({inside:Ue})}}),!n&&r.get("avoidLabelOverlap")&&lR(e,i,a,l,u,p,f,h);for(var m=0;m0){for(var f=o.getItemLayout(0),h=1;isNaN(f&&f.startAngle)&&h=n.r0}},t.type="pie",t})(Pt),_w=fR;function cn(r,t,e){t=k(t)&&{coordDimensions:t}||N({encodeDefine:r.getEncode()},t);var i=r.getSource(),a=vo(i,t).dimensions,n=new hr(a,r);return n.initData(i,e),n}var hR=(function(){function r(t,e){this._getDataWithEncodedVisual=t,this._getRawData=e}return r.prototype.getAllNames=function(){var t=this._getRawData();return t.mapArray(t.getName)},r.prototype.containName=function(t){var e=this._getRawData();return e.indexOfName(t)>=0},r.prototype.indexOfName=function(t){var e=this._getDataWithEncodedVisual();return e.indexOfName(t)},r.prototype.getItemVisual=function(t,e){var i=this._getDataWithEncodedVisual();return i.getItemVisual(t,e)},r})(),rh=hR;var cR=ft(),pR=(function(r){P(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.init=function(e){r.prototype.init.apply(this,arguments),this.legendVisualProvider=new rh(X(this.getData,this),X(this.getRawData,this)),this._defaultLabelLine(e)},t.prototype.mergeOption=function(){r.prototype.mergeOption.apply(this,arguments)},t.prototype.getInitialData=function(){return cn(this,{coordDimensions:["value"],encodeDefaulter:lt(O_,this)})},t.prototype.getDataParams=function(e){var i=this.getData(),a=cR(i),n=a.seats;if(!n){var o=[];i.each(i.mapDimension("value"),function(l){o.push(l)}),n=a.seats=Rc(o,i.hostModel.get("percentPrecision"))}var s=r.prototype.getDataParams.call(this,e);return s.percent=n[e]||0,s.$vars.push("percent"),s},t.prototype._defaultLabelLine=function(e){ba(e,"labelLine",["show"]);var i=e.labelLine,a=e.emphasis.labelLine;i.show=i.show&&e.label.show,a.show=a.show&&e.emphasis.label.show},t.type="series.pie",t.defaultOption={z:2,legendHoverLink:!0,colorBy:"data",center:["50%","50%"],radius:[0,"75%"],clockwise:!0,startAngle:90,endAngle:"auto",padAngle:0,minAngle:0,minShowLabelAngle:0,selectedOffset:10,percentPrecision:2,stillShowZeroSum:!0,left:0,top:0,right:0,bottom:0,width:null,height:null,label:{rotate:0,show:!0,overflow:"truncate",position:"outer",alignTo:"none",edgeDistance:"25%",bleedMargin:10,distanceToLabelLine:5},labelLine:{show:!0,length:15,length2:15,smooth:!1,minTurnAngle:90,maxSurfaceAngle:90,lineStyle:{width:1,type:"solid"}},itemStyle:{borderWidth:1,borderJoin:"round"},showEmptyCircle:!0,emptyCircleStyle:{color:"lightgray",opacity:1},labelLayout:{hideOverlap:!0},emphasis:{scale:!0,scaleSize:5},avoidLabelOverlap:!0,animationType:"expansion",animationDuration:1e3,animationTypeUpdate:"transition",animationEasingUpdate:"cubicInOut",animationDurationUpdate:500,animationEasing:"cubicInOut"},t})(kt),xw=pR;function Hd(r){return{seriesType:r,reset:function(t,e){var i=t.getData();i.filterSelf(function(a){var n=i.mapDimension("value"),o=i.get(n,a);return!(et(o)&&!isNaN(o)&&o<0)})}}}function Wd(r){r.registerChartView(_w),r.registerSeriesModel(xw),jx("pie",r.registerAction),r.registerLayout(lt(Bd,"pie")),r.registerProcessor(hl("pie")),r.registerProcessor(Hd("pie"))}var vR=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e.hasSymbolVisual=!0,e}return t.prototype.getInitialData=function(e,i){return Gr(null,this,{useEncodeDefaulter:!0})},t.prototype.getProgressive=function(){var e=this.option.progressive;return e??(this.option.large?5e3:this.get("progressive"))},t.prototype.getProgressiveThreshold=function(){var e=this.option.progressiveThreshold;return e??(this.option.large?1e4:this.get("progressiveThreshold"))},t.prototype.brushSelector=function(e,i,a){return a.point(i.getItemLayout(e))},t.prototype.getZLevelKey=function(){return this.getData().count()>this.getProgressiveThreshold()?this.id:""},t.type="series.scatter",t.dependencies=["grid","polar","geo","singleAxis","calendar"],t.defaultOption={coordinateSystem:"cartesian2d",z:2,legendHoverLink:!0,symbolSize:10,large:!1,largeThreshold:2e3,itemStyle:{opacity:.8},emphasis:{scale:!0},clip:!0,select:{itemStyle:{borderColor:"#212121"}},universalTransition:{divideShape:"clone"}},t})(kt),Sw=vR;var bw=4,dR=(function(){function r(){}return r})(),mR=(function(r){P(t,r);function t(e){var i=r.call(this,e)||this;return i._off=0,i.hoverDataIdx=-1,i}return t.prototype.getDefaultShape=function(){return new dR},t.prototype.reset=function(){this.notClear=!1,this._off=0},t.prototype.buildPath=function(e,i){var a=i.points,n=i.size,o=this.symbolProxy,s=o.shape,l=e.getContext?e.getContext():e,u=l&&n[0]=0;u--){var f=u*2,h=n[f]-s/2,p=n[f+1]-l/2;if(e>=h&&i>=p&&e<=h+s&&i<=p+l)return u}return-1},t.prototype.contain=function(e,i){var a=this.transformCoordToLocal(e,i),n=this.getBoundingRect();if(e=a[0],i=a[1],n.contain(e,i)){var o=this.hoverDataIdx=this.findDataIndex(e,i);return o>=0}return this.hoverDataIdx=-1,!1},t.prototype.getBoundingRect=function(){var e=this._rect;if(!e){for(var i=this.shape,a=i.points,n=i.size,o=n[0],s=n[1],l=1/0,u=1/0,f=-1/0,h=-1/0,p=0;p=0&&(u.dataIndex=h+(t.startIndex||0))})},r.prototype.remove=function(){this._clear()},r.prototype._clear=function(){this._newAdded=[],this.group.removeAll()},r})(),ww=gR;var yR=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.render=function(e,i,a){var n=e.getData(),o=this._updateSymbolDraw(n,e);o.updateData(n,{clipShape:this._getClipShape(e)}),this._finished=!0},t.prototype.incrementalPrepareRender=function(e,i,a){var n=e.getData(),o=this._updateSymbolDraw(n,e);o.incrementalPrepareUpdate(n),this._finished=!1},t.prototype.incrementalRender=function(e,i,a){this._symbolDraw.incrementalUpdate(e,i.getData(),{clipShape:this._getClipShape(i)}),this._finished=e.end===i.getData().count()},t.prototype.updateTransform=function(e,i,a){var n=e.getData();if(this.group.dirty(),!this._finished||n.count()>1e4)return{update:!0};var o=fn("").reset(e,i,a);o.progress&&o.progress({start:0,end:n.count(),count:n.count()},n),this._symbolDraw.updateLayout(n)},t.prototype.eachRendered=function(e){this._symbolDraw&&this._symbolDraw.eachRendered(e)},t.prototype._getClipShape=function(e){if(e.get("clip",!0)){var i=e.coordinateSystem;return i&&i.getArea&&i.getArea(.1)}},t.prototype._updateSymbolDraw=function(e,i){var a=this._symbolDraw,n=i.pipelineContext,o=n.large;return(!a||o!==this._isLargeDraw)&&(a&&a.remove(),a=this._symbolDraw=o?new ww:new So,this._isLargeDraw=o,this.group.removeAll()),this.group.add(a.group),a},t.prototype.remove=function(e,i){this._symbolDraw&&this._symbolDraw.remove(!0),this._symbolDraw=null},t.prototype.dispose=function(){},t.type="scatter",t})(Pt),Tw=yR;var _R=(function(r){P(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.type="grid",t.dependencies=["xAxis","yAxis"],t.layoutMode="box",t.defaultOption={show:!1,z:0,left:"10%",top:60,right:"10%",bottom:70,containLabel:!1,backgroundColor:"rgba(0,0,0,0)",borderWidth:1,borderColor:"#ccc"},t})(ct),Cw=_R;var ih=(function(r){P(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.getCoordSysModel=function(){return this.getReferringComponents("grid",Ht).models[0]},t.type="cartesian2dAxis",t})(ct);Ut(ih,yo);var Dw={show:!0,z:0,inverse:!1,name:"",nameLocation:"end",nameRotate:null,nameTruncate:{maxWidth:null,ellipsis:"...",placeholder:"."},nameTextStyle:{},nameGap:15,silent:!1,triggerEvent:!1,tooltip:{show:!1},axisPointer:{},axisLine:{show:!0,onZero:!0,onZeroAxisIndex:null,lineStyle:{color:"#6E7079",width:1,type:"solid"},symbol:["none","none"],symbolSize:[10,15]},axisTick:{show:!0,inside:!1,length:5,lineStyle:{width:1}},axisLabel:{show:!0,inside:!1,rotate:0,showMinLabel:null,showMaxLabel:null,margin:8,fontSize:12},splitLine:{show:!0,showMinLine:!0,showMaxLine:!0,lineStyle:{color:["#E0E6F1"],width:1,type:"solid"}},splitArea:{show:!1,areaStyle:{color:["rgba(250,250,250,0.2)","rgba(210,219,238,0.2)"]}}},xR=it({boundaryGap:!0,deduplication:null,splitLine:{show:!1},axisTick:{alignWithLabel:!1,interval:"auto"},axisLabel:{interval:"auto"}},Dw),Yd=it({boundaryGap:[0,0],axisLine:{show:"auto"},axisTick:{show:"auto"},splitNumber:5,minorTick:{show:!1,splitNumber:5,length:3,lineStyle:{}},minorSplitLine:{show:!1,lineStyle:{color:"#F4F7FD",width:1}}},Dw),SR=it({splitNumber:6,axisLabel:{showMinLabel:!1,showMaxLabel:!1,rich:{primary:{fontWeight:"bold"}}},splitLine:{show:!1}},Yd),bR=q({logBase:10},Yd),ah={category:xR,value:Yd,time:SR,log:bR};var Mw={value:1,category:1,time:1,log:1};function nh(r,t,e,i){T(Mw,function(a,n){var o=it(it({},ah[n],!0),i,!0),s=(function(l){P(u,l);function u(){var f=l!==null&&l.apply(this,arguments)||this;return f.type=t+"Axis."+n,f}return u.prototype.mergeDefaultAndTheme=function(f,h){var p=Ni(this),c=p?Vr(f):{},v=h.getTheme();it(f,v.get(n+"Axis")),it(f,this.getDefaultOption()),f.type=Aw(f),p&&Br(f,c,p)},u.prototype.optionUpdated=function(){var f=this.option;f.type==="category"&&(this.__ordinalMeta=rl.createByAxisModel(this))},u.prototype.getCategories=function(f){var h=this.option;if(h.type==="category")return f?h.data:this.__ordinalMeta.categories},u.prototype.getOrdinalMeta=function(){return this.__ordinalMeta},u.type=t+"Axis."+n,u.defaultOption=o,u})(e);r.registerComponentModel(s)}),r.registerSubTypeDefaulter(t+"Axis",Aw)}function Aw(r){return r.type||(r.data?"category":"value")}var wR=(function(){function r(t){this.type="cartesian",this._dimList=[],this._axes={},this.name=t||""}return r.prototype.getAxis=function(t){return this._axes[t]},r.prototype.getAxes=function(){return U(this._dimList,function(t){return this._axes[t]},this)},r.prototype.getAxesByScale=function(t){return t=t.toLowerCase(),Tt(this.getAxes(),function(e){return e.scale.type===t})},r.prototype.addAxis=function(t){var e=t.dim;this._axes[e]=t,this._dimList.push(e)},r})(),Ew=wR;var oh=["x","y"];function Lw(r){return r.type==="interval"||r.type==="time"}var TR=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type="cartesian2d",e.dimensions=oh,e}return t.prototype.calcAffineTransform=function(){this._transform=this._invTransform=null;var e=this.getAxis("x").scale,i=this.getAxis("y").scale;if(!(!Lw(e)||!Lw(i))){var a=e.getExtent(),n=i.getExtent(),o=this.dataToPoint([a[0],n[0]]),s=this.dataToPoint([a[1],n[1]]),l=a[1]-a[0],u=n[1]-n[0];if(!(!l||!u)){var f=(s[0]-o[0])/l,h=(s[1]-o[1])/u,p=o[0]-a[0]*f,c=o[1]-n[0]*h,v=this._transform=[f,0,0,h,p,c];this._invTransform=Kr([],v)}}},t.prototype.getBaseAxis=function(){return this.getAxesByScale("ordinal")[0]||this.getAxesByScale("time")[0]||this.getAxis("x")},t.prototype.containPoint=function(e){var i=this.getAxis("x"),a=this.getAxis("y");return i.contain(i.toLocalCoord(e[0]))&&a.contain(a.toLocalCoord(e[1]))},t.prototype.containData=function(e){return this.getAxis("x").containData(e[0])&&this.getAxis("y").containData(e[1])},t.prototype.containZone=function(e,i){var a=this.dataToPoint(e),n=this.dataToPoint(i),o=this.getArea(),s=new nt(a[0],a[1],n[0]-a[0],n[1]-a[1]);return o.intersect(s)},t.prototype.dataToPoint=function(e,i,a){a=a||[];var n=e[0],o=e[1];if(this._transform&&n!=null&&isFinite(n)&&o!=null&&isFinite(o))return Gt(a,e,this._transform);var s=this.getAxis("x"),l=this.getAxis("y");return a[0]=s.toGlobalCoord(s.dataToCoord(n,i)),a[1]=l.toGlobalCoord(l.dataToCoord(o,i)),a},t.prototype.clampData=function(e,i){var a=this.getAxis("x").scale,n=this.getAxis("y").scale,o=a.getExtent(),s=n.getExtent(),l=a.parse(e[0]),u=n.parse(e[1]);return i=i||[],i[0]=Math.min(Math.max(Math.min(o[0],o[1]),l),Math.max(o[0],o[1])),i[1]=Math.min(Math.max(Math.min(s[0],s[1]),u),Math.max(s[0],s[1])),i},t.prototype.pointToData=function(e,i){var a=[];if(this._invTransform)return Gt(a,e,this._invTransform);var n=this.getAxis("x"),o=this.getAxis("y");return a[0]=n.coordToData(n.toLocalCoord(e[0]),i),a[1]=o.coordToData(o.toLocalCoord(e[1]),i),a},t.prototype.getOtherAxis=function(e){return this.getAxis(e.dim==="x"?"y":"x")},t.prototype.getArea=function(e){e=e||0;var i=this.getAxis("x").getGlobalExtent(),a=this.getAxis("y").getGlobalExtent(),n=Math.min(i[0],i[1])-e,o=Math.min(a[0],a[1])-e,s=Math.max(i[0],i[1])-n+e,l=Math.max(a[0],a[1])-o+e;return new nt(n,o,s,l)},t})(Ew),Pw=TR;var CR=(function(r){P(t,r);function t(e,i,a,n,o){var s=r.call(this,e,i,a)||this;return s.index=0,s.type=n||"value",s.position=o||"bottom",s}return t.prototype.isHorizontal=function(){var e=this.position;return e==="top"||e==="bottom"},t.prototype.getGlobalExtent=function(e){var i=this.getExtent();return i[0]=this.toGlobalCoord(i[0]),i[1]=this.toGlobalCoord(i[1]),e&&i[0]>i[1]&&i.reverse(),i},t.prototype.pointToData=function(e,i){return this.coordToData(this.toLocalCoord(e[this.dim==="x"?0:1]),i)},t.prototype.setCategorySortInfo=function(e){if(this.type!=="category")return!1;this.model.option.categorySortInfo=e,this.scale.setSortInfo(e)},t})(_o),Iw=CR;function cl(r,t,e){e=e||{};var i=r.coordinateSystem,a=t.axis,n={},o=a.getAxesOnZeroOf()[0],s=a.position,l=o?"onZero":s,u=a.dim,f=i.getRect(),h=[f.x,f.x+f.width,f.y,f.y+f.height],p={left:0,right:1,top:0,bottom:1,onZero:2},c=t.get("offset")||0,v=u==="x"?[h[2]-c,h[3]+c]:[h[0]-c,h[1]+c];if(o){var m=o.toGlobalCoord(o.dataToCoord(0));v[p.onZero]=Math.max(Math.min(m,v[1]),v[0])}n.position=[u==="y"?v[p[l]]:h[0],u==="x"?v[p[l]]:h[3]],n.rotation=Math.PI/2*(u==="x"?0:1);var d={top:-1,bottom:1,left:-1,right:1};n.labelDirection=n.tickDirection=n.nameDirection=d[s],n.labelOffset=o?v[p[s]]-v[p.onZero]:0,t.get(["axisTick","inside"])&&(n.tickDirection=-n.tickDirection),Dr(e.labelInside,t.get(["axisLabel","inside"]))&&(n.labelDirection=-n.labelDirection);var g=t.get(["axisLabel","rotate"]);return n.labelRotate=l==="top"?-g:g,n.z2=1,n}function Zd(r){return r.get("coordinateSystem")==="cartesian2d"}function Xd(r){var t={xAxisModel:null,yAxisModel:null};return T(t,function(e,i){var a=i.replace(/Model$/,""),n=r.getReferringComponents(a,Ht).models[0];t[i]=n}),t}var qd=Math.log;function sh(r,t,e){var i=cr.prototype,a=i.getTicks.call(e),n=i.getTicks.call(e,!0),o=a.length-1,s=i.getInterval.call(e),l=cd(r,t),u=l.extent,f=l.fixMin,h=l.fixMax;if(r.type==="log"){var p=qd(r.base);u=[qd(u[0])/p,qd(u[1])/p]}r.setExtent(u[0],u[1]),r.calcNiceExtent({splitNumber:o,fixMin:f,fixMax:h});var c=i.getExtent.call(r);f&&(u[0]=c[0]),h&&(u[1]=c[1]);var v=i.getInterval.call(r),m=u[0],d=u[1];if(f&&h)v=(d-m)/o;else if(f)for(d=u[0]+v*o;du[0]&&isFinite(m)&&isFinite(u[0]);)v=zf(v),m=u[1]-v*o;else{var g=r.getTicks().length-1;g>o&&(v=zf(v));var y=v*o;d=Math.ceil(u[1]/v)*v,m=bt(d-y),m<0&&u[0]>=0?(m=0,d=bt(y)):d>0&&u[1]<=0&&(d=0,m=-bt(y))}var _=(a[0].value-n[0].value)/s,x=(a[o].value-n[o].value)/s;if(i.setExtent.call(r,m+v*_,d+v*x),i.setInterval.call(r,v),(_||x)&&i.setNiceExtent.call(r,m+v,d-v),0)var S}var DR=(function(){function r(t,e,i){this.type="grid",this._coordsMap={},this._coordsList=[],this._axesMap={},this._axesList=[],this.axisPointerEnabled=!0,this.dimensions=oh,this._initCartesian(t,e,i),this.model=t}return r.prototype.getRect=function(){return this._rect},r.prototype.update=function(t,e){var i=this._axesMap;this._updateScale(t,this.model);function a(o){var s,l=pt(o),u=l.length;if(u){for(var f=[],h=u-1;h>=0;h--){var p=+l[h],c=o[p],v=c.model,m=c.scale;il(m)&&v.get("alignTicks")&&v.get("interval")==null?f.push(c):(nl(m,v),il(m)&&(s=c))}f.length&&(s||(s=f.pop(),nl(s.scale,s.model)),T(f,function(d){sh(d.scale,d.model,s.scale)}))}}a(i.x),a(i.y);var n={};T(i.x,function(o){Ow(i,"y",o,n)}),T(i.y,function(o){Ow(i,"x",o,n)}),this.resize(this.model,e)},r.prototype.resize=function(t,e,i){var a=t.getBoxLayoutParams(),n=!i&&t.get("containLabel"),o=De(a,{width:e.getWidth(),height:e.getHeight()});this._rect=o;var s=this._axesList;l(),n&&(T(s,function(u){if(!u.model.get(["axisLabel","inside"])){var f=hb(u);if(f){var h=u.isHorizontal()?"height":"width",p=u.model.get(["axisLabel","margin"]);o[h]-=f[h]+p,u.position==="top"?o.y+=f.height+p:u.position==="left"&&(o.x+=f.width+p)}}}),l()),T(this._coordsList,function(u){u.calcAffineTransform()});function l(){T(s,function(u){var f=u.isHorizontal(),h=f?[0,o.width]:[0,o.height],p=u.inverse?1:0;u.setExtent(h[p],h[1-p]),MR(u,f?o.x:o.y)})}},r.prototype.getAxis=function(t,e){var i=this._axesMap[t];if(i!=null)return i[e||0]},r.prototype.getAxes=function(){return this._axesList.slice()},r.prototype.getCartesian=function(t,e){if(t!=null&&e!=null){var i="x"+t+"y"+e;return this._coordsMap[i]}H(t)&&(e=t.yAxisIndex,t=t.xAxisIndex);for(var a=0,n=this._coordsList;a0?"top":"bottom",n="center"):Sa(a-ji)?(o=i>0?"bottom":"top",n="center"):(o="middle",a>0&&a0?"right":"left":n=i>0?"left":"right"),{rotation:a,textAlign:n,textVerticalAlign:o}},r.makeAxisEventDataBase=function(t){var e={componentType:t.mainType,componentIndex:t.componentIndex};return e[t.mainType+"Index"]=t.componentIndex,e},r.isLabelSilent=function(t){var e=t.get("tooltip");return t.get("silent")||!(t.get("triggerEvent")||e&&e.show)},r})(),zw={axisLine:function(r,t,e,i){var a=t.get(["axisLine","show"]);if(a==="auto"&&r.handleAutoShown&&(a=r.handleAutoShown("axisLine")),!!a){var n=t.axis.getExtent(),o=i.transform,s=[n[0],0],l=[n[1],0],u=s[0]>l[0];o&&(Gt(s,s,o),Gt(l,l,o));var f=N({lineCap:"round"},t.getModel(["axisLine","lineStyle"]).getLineStyle()),h=new ne({shape:{x1:s[0],y1:s[1],x2:l[0],y2:l[1]},style:f,strokeContainThreshold:r.strokeContainThreshold||5,silent:!0,z2:1});Va(h.shape,h.style.lineWidth),h.anid="line",e.add(h);var p=t.get(["axisLine","symbol"]);if(p!=null){var c=t.get(["axisLine","symbolSize"]);B(p)&&(p=[p,p]),(B(c)||et(c))&&(c=[c,c]);var v=rn(t.get(["axisLine","symbolOffset"])||0,c),m=c[0],d=c[1];T([{rotate:r.rotation+Math.PI/2,offset:v[0],r:0},{rotate:r.rotation-Math.PI/2,offset:v[1],r:Math.sqrt((s[0]-l[0])*(s[0]-l[0])+(s[1]-l[1])*(s[1]-l[1]))}],function(g,y){if(p[y]!=="none"&&p[y]!=null){var _=It(p[y],-m/2,-d/2,m,d,f.stroke,!0),x=g.r+g.offset,S=u?l:s;_.attr({rotation:g.rotate,x:S[0]+x*Math.cos(r.rotation),y:S[1]-x*Math.sin(r.rotation),silent:!0,z2:11}),e.add(_)}})}}},axisTickLabel:function(r,t,e,i){var a=LR(e,i,t,r),n=IR(e,i,t,r);if(ER(t,n,a),PR(e,i,t,r.tickDirection),t.get(["axisLabel","hideOverlap"])){var o=kb(U(n,function(s){return{label:s,priority:s.z2,defaultAttr:{ignore:s.ignore}}}));Ub(o)}},axisName:function(r,t,e,i){var a=Dr(r.axisName,t.get("name"));if(a){var n=t.get("nameLocation"),o=r.nameDirection,s=t.getModel("nameTextStyle"),l=t.get("nameGap")||0,u=t.axis.getExtent(),f=u[0]>u[1]?-1:1,h=[n==="start"?u[0]-f*l:n==="end"?u[1]+f*l:(u[0]+u[1])/2,Bw(n)?r.labelOffset+o*l:0],p,c=t.get("nameRotate");c!=null&&(c=c*ji/180);var v;Bw(n)?p=pn.innerTextLayout(r.rotation,c??r.rotation,o):(p=AR(r.rotation,n,c||0,u),v=r.axisNameAvailableWidth,v!=null&&(v=Math.abs(v/Math.sin(p.rotation)),!isFinite(v)&&(v=null)));var m=s.getFont(),d=t.get("nameTruncate",!0)||{},g=d.ellipsis,y=Dr(r.nameTruncateMaxWidth,d.maxWidth,v),_=new yt({x:h[0],y:h[1],rotation:p.rotation,silent:pn.isLabelSilent(t),style:Wt(s,{text:a,font:m,overflow:"truncate",width:y,ellipsis:g,fill:s.getTextColor()||t.get(["axisLine","lineStyle","color"]),align:s.get("align")||p.textAlign,verticalAlign:s.get("verticalAlign")||p.textVerticalAlign}),z2:1});if(jn({el:_,componentModel:t,itemName:a}),_.__fullText=a,_.anid="name",t.get("triggerEvent")){var x=pn.makeAxisEventDataBase(t);x.targetType="axisName",x.name=a,ot(_).eventData=x}i.add(_),_.updateTransform(),e.add(_),_.decomposeTransform()}}};function AR(r,t,e,i){var a=es(e-r),n,o,s=i[0]>i[1],l=t==="start"&&!s||t!=="start"&&s;return Sa(a-ji/2)?(o=l?"bottom":"top",n="center"):Sa(a-ji*1.5)?(o=l?"top":"bottom",n="center"):(o="middle",aji/2?n=l?"left":"right":n=l?"right":"left"),{rotation:a,textAlign:n,textVerticalAlign:o}}function ER(r,t,e){if(!Zf(r.axis)){var i=r.get(["axisLabel","showMinLabel"]),a=r.get(["axisLabel","showMaxLabel"]);t=t||[],e=e||[];var n=t[0],o=t[1],s=t[t.length-1],l=t[t.length-2],u=e[0],f=e[1],h=e[e.length-1],p=e[e.length-2];i===!1?(pr(n),pr(u)):Uw(n,o)&&(i?(pr(o),pr(f)):(pr(n),pr(u))),a===!1?(pr(s),pr(h)):Uw(l,s)&&(a?(pr(l),pr(p)):(pr(s),pr(h)))}}function pr(r){r&&(r.ignore=!0)}function Uw(r,t){var e=r&&r.getBoundingRect().clone(),i=t&&t.getBoundingRect().clone();if(!(!e||!i)){var a=qr([]);return ia(a,a,-r.rotation),e.applyTransform(Je([],a,r.getLocalTransform())),i.applyTransform(Je([],a,t.getLocalTransform())),e.intersect(i)}}function Bw(r){return r==="middle"||r==="center"}function Vw(r,t,e,i,a){for(var n=[],o=[],s=[],l=0;l=0||r===t}function Gw(r){var t=lh(r);if(t){var e=t.axisPointerModel,i=t.axis.scale,a=e.option,n=e.get("status"),o=e.get("value");o!=null&&(o=i.parse(o));var s=Qd(e);n==null&&(a.status=s?"show":"hide");var l=i.getExtent().slice();l[0]>l[1]&&l.reverse(),(o==null||o>l[1])&&(o=l[1]),o0&&!v.min?v.min=0:v.min!=null&&v.min<0&&!v.max&&(v.max=0);var m=l;v.color!=null&&(m=q({color:v.color},l));var d=it(K(v),{boundaryGap:e,splitNumber:i,scale:a,axisLine:n,axisTick:o,axisLabel:s,name:v.text,showName:u,nameLocation:"end",nameGap:h,nameTextStyle:m,triggerEvent:p},!1);if(B(f)){var g=d.name;d.name=f.replace("{value}",g??"")}else G(f)&&(d.name=f(d.name,d));var y=new wt(d,null,this.ecModel);return Ut(y,yo.prototype),y.mainType="radar",y.componentIndex=this.componentIndex,y},this);this._indicatorModels=c},t.prototype.getIndicatorModels=function(){return this._indicatorModels},t.type="radar",t.defaultOption={z:0,center:["50%","50%"],radius:"75%",startAngle:90,axisName:{show:!0},boundaryGap:[0,0],splitNumber:5,axisNameGap:15,scale:!1,shape:"polygon",axisLine:it({lineStyle:{color:"#bbb"}},pl.axisLine),axisLabel:hh(pl.axisLabel,!1),axisTick:hh(pl.axisTick,!1),splitLine:hh(pl.splitLine,!0),splitArea:hh(pl.splitArea,!0),indicator:[]},t})(ct),t1=WR;var YR=["axisLine","axisTickLabel","axisName"],ZR=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.render=function(e,i,a){var n=this.group;n.removeAll(),this._buildAxes(e),this._buildSplitLineAndArea(e)},t.prototype._buildAxes=function(e){var i=e.coordinateSystem,a=i.getIndicatorAxes(),n=U(a,function(o){var s=o.model.get("showName")?o.name:"",l=new wo(o.model,{axisName:s,position:[i.cx,i.cy],rotation:o.angle,labelDirection:-1,tickDirection:-1,nameDirection:1});return l});T(n,function(o){T(YR,o.add,o),this.group.add(o.getGroup())},this)},t.prototype._buildSplitLineAndArea=function(e){var i=e.coordinateSystem,a=i.getIndicatorAxes();if(!a.length)return;var n=e.get("shape"),o=e.getModel("splitLine"),s=e.getModel("splitArea"),l=o.getModel("lineStyle"),u=s.getModel("areaStyle"),f=o.get("show"),h=s.get("show"),p=l.get("color"),c=u.get("color"),v=k(p)?p:[p],m=k(c)?c:[c],d=[],g=[];function y(R,O,V){var z=V%O.length;return R[z]=R[z]||[],z}if(n==="circle")for(var _=a[0].getTicksCoords(),x=i.cx,S=i.cy,b=0;b<_.length;b++){if(f){var w=y(d,v,b);d[w].push(new oi({shape:{cx:x,cy:S,r:_[b].coord}}))}if(h&&b<_.length-1){var w=y(g,m,b);g[w].push(new Ra({shape:{cx:x,cy:S,r0:_[b].coord,r:_[b+1].coord}}))}}else for(var C,M=U(a,function(R,O){var V=R.getTicksCoords();return C=C==null?V.length-1:Math.min(V.length-1,C),U(V,function(z){return i.coordToPoint(z.coord,O)})}),A=[],b=0;b<=C;b++){for(var D=[],E=0;E3?1.4:o>1?1.2:1.1,f=n>0?u:1/u;om(this,"zoom","zoomOnMouseWheel",e,{scale:f,originX:s,originY:l,isAvailableBehavior:null})}if(a){var h=Math.abs(n),p=(n>0?1:-1)*(h>3?.4:h>1?.15:.05);om(this,"scrollMove","moveOnMouseWheel",e,{scrollDelta:p,originX:s,originY:l,isAvailableBehavior:null})}}},t.prototype._pinchHandler=function(e){if(!nm(this._zr,"globalPan")){var i=e.pinchScale>1?1.1:1/1.1;om(this,"zoom",null,e,{scale:i,originX:e.pinchX,originY:e.pinchY,isAvailableBehavior:null})}},t})(Kt);function om(r,t,e,i,a){r.pointerChecker&&r.pointerChecker(i,a.originX,a.originY)&&(Ar(i.event),o1(r,t,e,i,a))}function o1(r,t,e,i,a){a.isAvailableBehavior=X(ch,null,e,i),r.trigger(t,a)}function ch(r,t,e){var i=e[r];return!r||i&&(!B(i)||t.event[i+"Key"])}var s1=QR;var l1=ne.prototype,sm=Oa.prototype,u1=(function(){function r(){this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.percent=1}return r})(),e7=(function(r){P(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t})(u1);function lm(r){return isNaN(+r.cpx1)||isNaN(+r.cpy1)}var JR=(function(r){P(t,r);function t(e){var i=r.call(this,e)||this;return i.type="ec-line",i}return t.prototype.getDefaultStyle=function(){return{stroke:"#000",fill:null}},t.prototype.getDefaultShape=function(){return new u1},t.prototype.buildPath=function(e,i){lm(i)?l1.buildPath.call(this,e,i):sm.buildPath.call(this,e,i)},t.prototype.pointAt=function(e){return lm(this.shape)?l1.pointAt.call(this,e):sm.pointAt.call(this,e)},t.prototype.tangentAt=function(e){var i=this.shape,a=lm(i)?[i.x2-i.x1,i.y2-i.y1]:sm.tangentAt.call(this,e);return ra(a,a)},t})(rt),f1=JR;var um=["fromSymbol","toSymbol"];function h1(r){return"_"+r+"Type"}function c1(r,t,e){var i=t.getItemVisual(e,r);if(!i||i==="none")return i;var a=t.getItemVisual(e,r+"Size"),n=t.getItemVisual(e,r+"Rotate"),o=t.getItemVisual(e,r+"Offset"),s=t.getItemVisual(e,r+"KeepAspect"),l=en(a),u=rn(o||0,l);return i+l+u+(n||"")+(s||"")}function p1(r,t,e){var i=t.getItemVisual(e,r);if(!(!i||i==="none")){var a=t.getItemVisual(e,r+"Size"),n=t.getItemVisual(e,r+"Rotate"),o=t.getItemVisual(e,r+"Offset"),s=t.getItemVisual(e,r+"KeepAspect"),l=en(a),u=rn(o||0,l),f=It(i,-l[0]/2+u[0],-l[1]/2+u[1],l[0],l[1],null,s);return f.__specifiedRotation=n==null||isNaN(n)?void 0:+n*Math.PI/180||0,f.name=r,f}}function $R(r){var t=new f1({name:"line",subPixelOptimize:!0});return fm(t.shape,r),t}function fm(r,t){r.x1=t[0][0],r.y1=t[0][1],r.x2=t[1][0],r.y2=t[1][1],r.percent=1;var e=t[2];e?(r.cpx1=e[0],r.cpy1=e[1]):(r.cpx1=NaN,r.cpy1=NaN)}var tO=(function(r){P(t,r);function t(e,i,a){var n=r.call(this)||this;return n._createLine(e,i,a),n}return t.prototype._createLine=function(e,i,a){var n=e.hostModel,o=e.getItemLayout(i),s=$R(o);s.shape.percent=0,Mt(s,{shape:{percent:1}},n,i),this.add(s),T(um,function(l){var u=p1(l,e,i);this.add(u),this[h1(l)]=c1(l,e,i)},this),this._updateCommonStl(e,i,a)},t.prototype.updateData=function(e,i,a){var n=e.hostModel,o=this.childOfName("line"),s=e.getItemLayout(i),l={shape:{}};fm(l.shape,s),xt(o,l,n,i),T(um,function(u){var f=c1(u,e,i),h=h1(u);if(this[h]!==f){this.remove(this.childOfName(u));var p=p1(u,e,i);this.add(p)}this[h]=f},this),this._updateCommonStl(e,i,a)},t.prototype.getLinePath=function(){return this.childAt(0)},t.prototype._updateCommonStl=function(e,i,a){var n=e.hostModel,o=this.childOfName("line"),s=a&&a.emphasisLineStyle,l=a&&a.blurLineStyle,u=a&&a.selectLineStyle,f=a&&a.labelStatesModels,h=a&&a.emphasisDisabled,p=a&&a.focus,c=a&&a.blurScope;if(!a||e.hasItemOption){var v=e.getItemModel(i),m=v.getModel("emphasis");s=m.getModel("lineStyle").getLineStyle(),l=v.getModel(["blur","lineStyle"]).getLineStyle(),u=v.getModel(["select","lineStyle"]).getLineStyle(),h=m.get("disabled"),p=m.get("focus"),c=m.get("blurScope"),f=ge(v)}var d=e.getItemVisual(i,"style"),g=d.stroke;o.useStyle(d),o.style.fill=null,o.style.strokeNoScale=!0,o.ensureState("emphasis").style=s,o.ensureState("blur").style=l,o.ensureState("select").style=u,T(um,function(b){var w=this.childOfName(b);if(w){w.setColor(g),w.style.opacity=d.opacity;for(var C=0;C0&&(S[0]=-S[0],S[1]=-S[1]);var w=x[0]<0?-1:1;if(n.__position!=="start"&&n.__position!=="end"){var C=-Math.atan2(x[1],x[0]);h[0].8?"left":p[0]<-.8?"right":"center",m=p[1]>.8?"top":p[1]<-.8?"bottom":"middle";break;case"start":n.x=-p[0]*g+f[0],n.y=-p[1]*y+f[1],v=p[0]>.8?"right":p[0]<-.8?"left":"center",m=p[1]>.8?"bottom":p[1]<-.8?"top":"middle";break;case"insideStartTop":case"insideStart":case"insideStartBottom":n.x=g*w+f[0],n.y=f[1]+M,v=x[0]<0?"right":"left",n.originX=-g*w,n.originY=-M;break;case"insideMiddleTop":case"insideMiddle":case"insideMiddleBottom":case"middle":n.x=b[0],n.y=b[1]+M,v="center",n.originY=-M;break;case"insideEndTop":case"insideEnd":case"insideEndBottom":n.x=-g*w+h[0],n.y=h[1]+M,v=x[0]>=0?"right":"left",n.originX=g*w,n.originY=-M;break}n.scaleX=n.scaleY=o,n.setStyle({verticalAlign:n.__verticalAlign||m,align:n.__align||v})}},t})(ut),v1=tO;var eO=(function(){function r(t){this.group=new ut,this._LineCtor=t||v1}return r.prototype.updateData=function(t){var e=this;this._progressiveEls=null;var i=this,a=i.group,n=i._lineData;i._lineData=t,n||a.removeAll();var o=d1(t);t.diff(n).add(function(s){e._doAdd(t,s,o)}).update(function(s,l){e._doUpdate(n,t,l,s,o)}).remove(function(s){a.remove(n.getItemGraphicEl(s))}).execute()},r.prototype.updateLayout=function(){var t=this._lineData;t&&t.eachItemGraphicEl(function(e,i){e.updateLayout(t,i)},this)},r.prototype.incrementalPrepareUpdate=function(t){this._seriesScope=d1(t),this._lineData=null,this.group.removeAll()},r.prototype.incrementalUpdate=function(t,e){this._progressiveEls=[];function i(s){!s.isGroup&&!rO(s)&&(s.incremental=!0,s.ensureState("emphasis").hoverLayer=!0)}for(var a=t.start;a0}function d1(r){var t=r.hostModel,e=t.getModel("emphasis");return{lineStyle:t.getModel("lineStyle").getLineStyle(),emphasisLineStyle:e.getModel(["lineStyle"]).getLineStyle(),blurLineStyle:t.getModel(["blur","lineStyle"]).getLineStyle(),selectLineStyle:t.getModel(["select","lineStyle"]).getLineStyle(),emphasisDisabled:e.get("disabled"),blurScope:e.get("blurScope"),focus:e.get("focus"),labelStatesModels:ge(t)}}function m1(r){return isNaN(r[0])||isNaN(r[1])}function hm(r){return r&&!m1(r[0])&&!m1(r[1])}var g1=eO;var iO=(function(){function r(){this.angle=0,this.width=10,this.r=10,this.x=0,this.y=0}return r})(),aO=(function(r){P(t,r);function t(e){var i=r.call(this,e)||this;return i.type="pointer",i}return t.prototype.getDefaultShape=function(){return new iO},t.prototype.buildPath=function(e,i){var a=Math.cos,n=Math.sin,o=i.r,s=i.width,l=i.angle,u=i.x-a(l)*s*(s>=o/3?1:2),f=i.y-n(l)*s*(s>=o/3?1:2);l=i.angle-Math.PI/2,e.moveTo(u,f),e.lineTo(i.x+a(l)*s,i.y+n(l)*s),e.lineTo(i.x+a(i.angle)*o,i.y+n(i.angle)*o),e.lineTo(i.x-a(l)*s,i.y-n(l)*s),e.lineTo(u,f)},t})(rt),y1=aO;function nO(r,t){var e=r.get("center"),i=t.getWidth(),a=t.getHeight(),n=Math.min(i,a),o=j(e[0],t.getWidth()),s=j(e[1],t.getHeight()),l=j(r.get("radius"),n/2);return{cx:o,cy:s,r:l}}function ph(r,t){var e=r==null?"":r+"";return t&&(B(t)?e=t.replace("{value}",e):G(t)&&(e=t(r))),e}var oO=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.render=function(e,i,a){this.group.removeAll();var n=e.get(["axisLine","lineStyle","color"]),o=nO(e,a);this._renderMain(e,i,a,n,o),this._data=e.getData()},t.prototype.dispose=function(){},t.prototype._renderMain=function(e,i,a,n,o){var s=this.group,l=e.get("clockwise"),u=-e.get("startAngle")/180*Math.PI,f=-e.get("endAngle")/180*Math.PI,h=e.getModel("axisLine"),p=h.get("roundCap"),c=p?bo:me,v=h.get("show"),m=h.getModel("lineStyle"),d=m.get("width"),g=[u,f];os(g,!l),u=g[0],f=g[1];for(var y=f-u,_=u,x=[],S=0;v&&S=M&&(A===0?0:n[A-1][0])Math.PI/2&&(gt+=Math.PI)):vt==="tangential"?gt=-C-Math.PI/2:et(vt)&&(gt=vt*Math.PI/180),gt===0?h.add(new yt({style:Wt(_,{text:F,x:Z,y:J,verticalAlign:R<-.8?"top":R>.8?"bottom":"middle",align:I<-.4?"left":I>.4?"right":"center"},{inheritColor:W}),silent:!0})):h.add(new yt({style:Wt(_,{text:F,x:Z,y:J,verticalAlign:"middle",align:"center"},{inheritColor:W}),silent:!0,originX:Z,originY:J,rotation:gt}))}if(y.get("show")&&O!==x){var V=y.get("distance");V=V?V+f:f;for(var St=0;St<=S;St++){I=Math.cos(C),R=Math.sin(C);var se=new ne({shape:{x1:I*(v-V)+p,y1:R*(v-V)+c,x2:I*(v-w-V)+p,y2:R*(v-w-V)+c},silent:!0,style:E});E.stroke==="auto"&&se.setStyle({stroke:n((O+St/S)/x)}),h.add(se),C+=A}C-=A}else C+=M}},t.prototype._renderPointer=function(e,i,a,n,o,s,l,u,f){var h=this.group,p=this._data,c=this._progressEls,v=[],m=e.get(["pointer","show"]),d=e.getModel("progress"),g=d.get("show"),y=e.getData(),_=y.mapDimension("value"),x=+e.get("min"),S=+e.get("max"),b=[x,S],w=[s,l];function C(A,D){var E=y.getItemModel(A),L=E.getModel("pointer"),I=j(L.get("width"),o.r),R=j(L.get("length"),o.r),O=e.get(["pointer","icon"]),V=L.get("offsetCenter"),z=j(V[0],o.r),F=j(V[1],o.r),W=L.get("keepAspect"),Z;return O?Z=It(O,z-I/2,F-R,I,R,null,W):Z=new y1({shape:{angle:-Math.PI/2,width:I,r:R,x:z,y:F}}),Z.rotation=-(D+Math.PI/2),Z.x=o.cx,Z.y=o.cy,Z}function M(A,D){var E=d.get("roundCap"),L=E?bo:me,I=d.get("overlap"),R=I?d.get("width"):f/y.count(),O=I?o.r-R:o.r-(A+1)*R,V=I?o.r:o.r-A*R,z=new L({shape:{startAngle:s,endAngle:D,cx:o.cx,cy:o.cy,clockwise:u,r0:O,r:V}});return I&&(z.z2=Ct(y.get(_,A),[x,S],[100,0],!0)),z}(g||m)&&(y.diff(p).add(function(A){var D=y.get(_,A);if(m){var E=C(A,s);Mt(E,{rotation:-((isNaN(+D)?w[0]:Ct(D,b,w,!0))+Math.PI/2)},e),h.add(E),y.setItemGraphicEl(A,E)}if(g){var L=M(A,s),I=d.get("clip");Mt(L,{shape:{endAngle:Ct(D,b,w,I)}},e),h.add(L),fs(e.seriesIndex,y.dataType,A,L),v[A]=L}}).update(function(A,D){var E=y.get(_,A);if(m){var L=p.getItemGraphicEl(D),I=L?L.rotation:s,R=C(A,I);R.rotation=I,xt(R,{rotation:-((isNaN(+E)?w[0]:Ct(E,b,w,!0))+Math.PI/2)},e),h.add(R),y.setItemGraphicEl(A,R)}if(g){var O=c[D],V=O?O.shape.endAngle:s,z=M(A,V),F=d.get("clip");xt(z,{shape:{endAngle:Ct(E,b,w,F)}},e),h.add(z),fs(e.seriesIndex,y.dataType,A,z),v[A]=z}}).execute(),y.each(function(A){var D=y.getItemModel(A),E=D.getModel("emphasis"),L=E.get("focus"),I=E.get("blurScope"),R=E.get("disabled");if(m){var O=y.getItemGraphicEl(A),V=y.getItemVisual(A,"style"),z=V.fill;if(O instanceof ie){var F=O.style;O.useStyle(N({image:F.image,x:F.x,y:F.y,width:F.width,height:F.height},V))}else O.useStyle(V),O.type!=="pointer"&&O.setColor(z);O.setStyle(D.getModel(["pointer","itemStyle"]).getItemStyle()),O.style.fill==="auto"&&O.setStyle("fill",n(Ct(y.get(_,A),b,[0,1],!0))),O.z2EmphasisLift=0,Fe(O,D),ve(O,L,I,R)}if(g){var W=v[A];W.useStyle(y.getItemVisual(A,"style")),W.setStyle(D.getModel(["progress","itemStyle"]).getItemStyle()),W.z2EmphasisLift=0,Fe(W,D),ve(W,L,I,R)}}),this._progressEls=v)},t.prototype._renderAnchor=function(e,i){var a=e.getModel("anchor"),n=a.get("show");if(n){var o=a.get("size"),s=a.get("icon"),l=a.get("offsetCenter"),u=a.get("keepAspect"),f=It(s,i.cx-o/2+j(l[0],i.r),i.cy-o/2+j(l[1],i.r),o,o,null,u);f.z2=a.get("showAbove")?1:0,f.setStyle(a.getModel("itemStyle").getItemStyle()),this.group.add(f)}},t.prototype._renderTitleAndDetail=function(e,i,a,n,o){var s=this,l=e.getData(),u=l.mapDimension("value"),f=+e.get("min"),h=+e.get("max"),p=new ut,c=[],v=[],m=e.isAnimationEnabled(),d=e.get(["pointer","showAbove"]);l.diff(this._data).add(function(g){c[g]=new yt({silent:!0}),v[g]=new yt({silent:!0})}).update(function(g,y){c[g]=s._titleEls[y],v[g]=s._detailEls[y]}).execute(),l.each(function(g){var y=l.getItemModel(g),_=l.get(u,g),x=new ut,S=n(Ct(_,[f,h],[0,1],!0)),b=y.getModel("title");if(b.get("show")){var w=b.get("offsetCenter"),C=o.cx+j(w[0],o.r),M=o.cy+j(w[1],o.r),A=c[g];A.attr({z2:d?0:2,style:Wt(b,{x:C,y:M,text:l.getName(g),align:"center",verticalAlign:"middle"},{inheritColor:S})}),x.add(A)}var D=y.getModel("detail");if(D.get("show")){var E=D.get("offsetCenter"),L=o.cx+j(E[0],o.r),I=o.cy+j(E[1],o.r),R=j(D.get("width"),o.r),O=j(D.get("height"),o.r),V=e.get(["progress","show"])?l.getItemVisual(g,"style").fill:S,A=v[g],z=D.get("formatter");A.attr({z2:d?0:2,style:Wt(D,{x:L,y:I,text:ph(_,z),width:isNaN(R)?null:R,height:isNaN(O)?null:O,align:"center",verticalAlign:"middle"},{inheritColor:V})}),Nu(A,{normal:D},_,function(W){return ph(W,z)}),m&&f_(A,g,l,e,{getFormattedLabel:function(W,Z,J,vt,gt,St){return ph(St?St.interpolatedValue:_,z)}}),x.add(A)}p.add(x)}),this.group.add(p),this._titleEls=c,this._detailEls=v},t.type="gauge",t})(Pt),_1=oO;var sO=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e.visualStyleAccessPath="itemStyle",e}return t.prototype.getInitialData=function(e,i){return cn(this,["value"])},t.type="series.gauge",t.defaultOption={z:2,colorBy:"data",center:["50%","50%"],legendHoverLink:!0,radius:"75%",startAngle:225,endAngle:-45,clockwise:!0,min:0,max:100,splitNumber:10,axisLine:{show:!0,roundCap:!1,lineStyle:{color:[[1,"#E6EBF8"]],width:10}},progress:{show:!1,overlap:!0,width:10,roundCap:!1,clip:!0},splitLine:{show:!0,length:10,distance:10,lineStyle:{color:"#63677A",width:3,type:"solid"}},axisTick:{show:!0,splitNumber:5,length:6,distance:10,lineStyle:{color:"#63677A",width:1,type:"solid"}},axisLabel:{show:!0,distance:15,color:"#464646",fontSize:12,rotate:0},pointer:{icon:null,offsetCenter:[0,0],show:!0,showAbove:!0,length:"60%",width:6,keepAspect:!1},anchor:{show:!1,showAbove:!1,size:6,icon:"circle",offsetCenter:[0,0],keepAspect:!1,itemStyle:{color:"#fff",borderWidth:0,borderColor:"#5470c6"}},title:{show:!0,offsetCenter:[0,"20%"],color:"#464646",fontSize:16,valueAnimation:!1},detail:{show:!0,backgroundColor:"rgba(0,0,0,0)",borderWidth:0,borderColor:"#ccc",width:100,height:null,padding:[5,10],offsetCenter:[0,"40%"],color:"#464646",fontSize:30,fontWeight:"bold",lineHeight:30,valueAnimation:!1}},t})(kt),x1=sO;function cm(r){r.registerChartView(_1),r.registerSeriesModel(x1)}function Qi(r,t,e,i,a,n){r=r||0;var o=e[1]-e[0];if(a!=null&&(a=Co(a,[0,o])),n!=null&&(n=Math.max(n,a??0)),i==="all"){var s=Math.abs(t[1]-t[0]);s=Co(s,[0,o]),a=n=Co(s,[a,n]),i=0}t[0]=Co(t[0],e),t[1]=Co(t[1],e);var l=pm(t,i);t[i]+=r;var u=a||0,f=e.slice();l.sign<0?f[0]+=u:f[1]-=u,t[i]=Co(t[i],f);var h;return h=pm(t,i),a!=null&&(h.sign!==l.sign||h.spann&&(t[1-i]=t[i]+h.sign*n),t}function pm(r,t){var e=r[t]-r[1-t];return{span:Math.abs(e),sign:e>0?-1:e<0?1:t?-1:1}}function Co(r,t){return Math.min(t[1]!=null?t[1]:1/0,Math.max(t[0]!=null?t[0]:-1/0,r))}var vn=ft(),S1=K,vm=X,lO=(function(){function r(){this._dragging=!1,this.animationThreshold=15}return r.prototype.render=function(t,e,i,a){var n=e.get("value"),o=e.get("status");if(this._axisModel=t,this._axisPointerModel=e,this._api=i,!(!a&&this._lastValue===n&&this._lastStatus===o)){this._lastValue=n,this._lastStatus=o;var s=this._group,l=this._handle;if(!o||o==="hide"){s&&s.hide(),l&&l.hide();return}s&&s.show(),l&&l.show();var u={};this.makeElOption(u,n,t,e,i);var f=u.graphicKey;f!==this._lastGraphicKey&&this.clear(i),this._lastGraphicKey=f;var h=this._moveAnimation=this.determineAnimation(t,e);if(!s)s=this._group=new ut,this.createPointerEl(s,u,t,e),this.createLabelEl(s,u,t,e),i.getZr().add(s);else{var p=lt(b1,e,h);this.updatePointerEl(s,u,p),this.updateLabelEl(s,u,p,e)}T1(s,e,!0),this._renderHandle(n)}},r.prototype.remove=function(t){this.clear(t)},r.prototype.dispose=function(t){this.clear(t)},r.prototype.determineAnimation=function(t,e){var i=e.get("animation"),a=t.axis,n=a.type==="category",o=e.get("snap");if(!o&&!n)return!1;if(i==="auto"||i==null){var s=this.animationThreshold;if(n&&a.getBandWidth()>s)return!0;if(o){var l=lh(t).seriesDataCount,u=a.getExtent();return Math.abs(u[0]-u[1])/l>s}return!1}return i===!0},r.prototype.makeElOption=function(t,e,i,a,n){},r.prototype.createPointerEl=function(t,e,i,a){var n=e.pointer;if(n){var o=vn(t).pointerEl=new Et[n.type](S1(e.pointer));t.add(o)}},r.prototype.createLabelEl=function(t,e,i,a){if(e.label){var n=vn(t).labelEl=new yt(S1(e.label));t.add(n),w1(n,a)}},r.prototype.updatePointerEl=function(t,e,i){var a=vn(t).pointerEl;a&&e.pointer&&(a.setStyle(e.pointer.style),i(a,{shape:e.pointer.shape}))},r.prototype.updateLabelEl=function(t,e,i,a){var n=vn(t).labelEl;n&&(n.setStyle(e.label.style),i(n,{x:e.label.x,y:e.label.y}),w1(n,a))},r.prototype._renderHandle=function(t){if(!(this._dragging||!this.updateHandleTransform)){var e=this._axisPointerModel,i=this._api.getZr(),a=this._handle,n=e.getModel("handle"),o=e.get("status");if(!n.get("show")||!o||o==="hide"){a&&i.remove(a),this._handle=null;return}var s;this._handle||(s=!0,a=this._handle=Ga(n.get("icon"),{cursor:"move",draggable:!0,onmousemove:function(u){Ar(u.event)},onmousedown:vm(this._onHandleDragMove,this,0,0),drift:vm(this._onHandleDragMove,this),ondragend:vm(this._onHandleDragEnd,this)}),i.add(a)),T1(a,e,!1),a.setStyle(n.getItemStyle(null,["color","borderColor","borderWidth","opacity","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY"]));var l=n.get("size");k(l)||(l=[l,l]),a.scaleX=l[0]/2,a.scaleY=l[1]/2,Ui(this,"_doDispatchAxisPointer",n.get("throttle")||0,"fixRate"),this._moveHandleToValue(t,s)}},r.prototype._moveHandleToValue=function(t,e){b1(this._axisPointerModel,!e&&this._moveAnimation,this._handle,dm(this.getHandleTransform(t,this._axisModel,this._axisPointerModel)))},r.prototype._onHandleDragMove=function(t,e){var i=this._handle;if(i){this._dragging=!0;var a=this.updateHandleTransform(dm(i),[t,e],this._axisModel,this._axisPointerModel);this._payloadInfo=a,i.stopAnimation(),i.attr(dm(a)),vn(i).lastProp=null,this._doDispatchAxisPointer()}},r.prototype._doDispatchAxisPointer=function(){var t=this._handle;if(t){var e=this._payloadInfo,i=this._axisModel;this._api.dispatchAction({type:"updateAxisPointer",x:e.cursorPoint[0],y:e.cursorPoint[1],tooltipOption:e.tooltipOption,axesInfo:[{axisDim:i.axis.dim,axisIndex:i.componentIndex}]})}},r.prototype._onHandleDragEnd=function(){this._dragging=!1;var t=this._handle;if(t){var e=this._axisPointerModel.get("value");this._moveHandleToValue(e),this._api.dispatchAction({type:"hideTip"})}},r.prototype.clear=function(t){this._lastValue=null,this._lastStatus=null;var e=t.getZr(),i=this._group,a=this._handle;e&&i&&(this._lastGraphicKey=null,i&&e.remove(i),a&&e.remove(a),this._group=null,this._handle=null,this._payloadInfo=null),$a(this,"_doDispatchAxisPointer")},r.prototype.doClear=function(){},r.prototype.buildLabel=function(t,e,i){return i=i||0,{x:t[i],y:t[1-i],width:e[i],height:e[1-i]}},r})();function b1(r,t,e,i){C1(vn(e).lastProp,i)||(vn(e).lastProp=i,t?xt(e,i,r):(e.stopAnimation(),e.attr(i)))}function C1(r,t){if(H(r)&&H(t)){var e=!0;return T(t,function(i,a){e=e&&C1(r[a],i)}),!!e}else return r===t}function w1(r,t){r[t.get(["label","show"])?"show":"hide"]()}function dm(r){return{x:r.x||0,y:r.y||0,rotation:r.rotation||0}}function T1(r,t,e){var i=t.get("z"),a=t.get("zlevel");r&&r.traverse(function(n){n.type!=="group"&&(i!=null&&(n.z=i),a!=null&&(n.zlevel=a),n.silent=e)})}var D1=lO;function M1(r){var t=r.get("type"),e=r.getModel(t+"Style"),i;return t==="line"?(i=e.getLineStyle(),i.fill=null):t==="shadow"&&(i=e.getAreaStyle(),i.stroke=null),i}function uO(r,t,e,i,a){var n=e.get("value"),o=mm(n,t.axis,t.ecModel,e.get("seriesDataIndices"),{precision:e.get(["label","precision"]),formatter:e.get(["label","formatter"])}),s=e.getModel("label"),l=Ur(s.get("padding")||0),u=s.getFont(),f=An(o,u),h=a.position,p=f.width+l[1]+l[3],c=f.height+l[0]+l[2],v=a.align;v==="right"&&(h[0]-=p),v==="center"&&(h[0]-=p/2);var m=a.verticalAlign;m==="bottom"&&(h[1]-=c),m==="middle"&&(h[1]-=c/2),fO(h,p,c,i);var d=s.get("backgroundColor");(!d||d==="auto")&&(d=t.get(["axisLine","lineStyle","color"])),r.label={x:h[0],y:h[1],style:Wt(s,{text:o,font:u,fill:s.getTextColor(),padding:l,backgroundColor:d}),z2:10}}function fO(r,t,e,i){var a=i.getWidth(),n=i.getHeight();r[0]=Math.min(r[0]+t,a)-t,r[1]=Math.min(r[1]+e,n)-e,r[0]=Math.max(r[0],0),r[1]=Math.max(r[1],0)}function mm(r,t,e,i,a){r=t.scale.parse(r);var n=t.scale.getLabel({value:r},{precision:a.precision}),o=a.formatter;if(o){var s={value:ol(t,{value:r}),axisDimension:t.dim,axisIndex:t.index,seriesData:[]};T(i,function(l){var u=e.getSeriesByIndex(l.seriesIndex),f=l.dataIndexInside,h=u&&u.getDataParams(f);h&&s.seriesData.push(h)}),B(o)?n=o.replace("{value}",n):G(o)&&(n=o(s))}return n}function gm(r,t,e){var i=mr();return ia(i,i,e.rotation),bn(i,i,e.position),Fa([r.dataToCoord(t),(e.labelOffset||0)+(e.labelDirection||1)*(e.labelMargin||0)],i)}function A1(r,t,e,i,a,n){var o=wo.innerTextLayout(e.rotation,0,e.labelDirection);e.labelMargin=a.get(["label","margin"]),uO(t,i,a,n,{position:gm(i.axis,r,e),align:o.textAlign,verticalAlign:o.textVerticalAlign})}function E1(r,t,e){return e=e||0,{x1:r[e],y1:r[1-e],x2:t[e],y2:t[1-e]}}function L1(r,t,e){return e=e||0,{x:r[e],y:r[1-e],width:t[e],height:t[1-e]}}var hO=(function(r){P(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}return t.prototype.makeElOption=function(e,i,a,n,o){var s=a.axis,l=s.grid,u=n.get("type"),f=I1(l,s).getOtherAxis(s).getGlobalExtent(),h=s.toGlobalCoord(s.dataToCoord(i,!0));if(u&&u!=="none"){var p=M1(n),c=cO[u](s,h,f);c.style=p,e.graphicKey=c.type,e.pointer=c}var v=cl(l.model,a);A1(i,e,v,a,n,o)},t.prototype.getHandleTransform=function(e,i,a){var n=cl(i.axis.grid.model,i,{labelInside:!1});n.labelMargin=a.get(["handle","margin"]);var o=gm(i.axis,e,n);return{x:o[0],y:o[1],rotation:n.rotation+(n.labelDirection<0?Math.PI:0)}},t.prototype.updateHandleTransform=function(e,i,a,n){var o=a.axis,s=o.grid,l=o.getGlobalExtent(!0),u=I1(s,o).getOtherAxis(o).getGlobalExtent(),f=o.dim==="x"?0:1,h=[e.x,e.y];h[f]+=i[f],h[f]=Math.min(l[1],h[f]),h[f]=Math.max(l[0],h[f]);var p=(u[1]+u[0])/2,c=[p,p];c[f]=h[f];var v=[{verticalAlign:"middle"},{align:"center"}];return{x:h[0],y:h[1],rotation:e.rotation,cursorPoint:c,tooltipOption:v[f]}},t})(D1);function I1(r,t){var e={};return e[t.dim+"AxisIndex"]=t.index,r.getCartesian(e)}var cO={line:function(r,t,e){var i=E1([t,e[0]],[t,e[1]],R1(r));return{type:"Line",subPixelOptimize:!0,shape:i}},shadow:function(r,t,e){var i=Math.max(1,r.getBandWidth()),a=e[1]-e[0];return{type:"Rect",shape:L1([t-i/2,e[0]],[i,a],R1(r))}}};function R1(r){return r.dim==="x"?0:1}var O1=hO;var pO=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.type="axisPointer",t.defaultOption={show:"auto",z:50,type:"line",snap:!1,triggerTooltip:!0,triggerEmphasis:!0,value:null,status:null,link:[],animation:null,animationDurationUpdate:200,lineStyle:{color:"#B9BEC9",width:1,type:"dashed"},shadowStyle:{color:"rgba(210,219,238,0.2)"},label:{show:!0,formatter:null,precision:"auto",margin:3,color:"#fff",padding:[5,7,5,7],backgroundColor:"auto",borderColor:null,borderWidth:0,borderRadius:3},handle:{show:!1,icon:"M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4h1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7v-1.2h6.6z M13.3,22H6.7v-1.2h6.6z M13.3,19.6H6.7v-1.2h6.6z",size:45,margin:50,color:"#333",shadowBlur:3,shadowColor:"#aaa",shadowOffsetX:0,shadowOffsetY:2,throttle:40}},t})(ct),N1=pO;var di=ft(),vO=T;function vh(r,t,e){if(!tt.node){var i=t.getZr();di(i).records||(di(i).records={}),dO(i,t);var a=di(i).records[r]||(di(i).records[r]={});a.handler=e}}function dO(r,t){if(di(r).initialized)return;di(r).initialized=!0,e("click",lt(k1,"click")),e("mousemove",lt(k1,"mousemove")),e("globalout",gO);function e(i,a){r.on(i,function(n){var o=yO(t);vO(di(r).records,function(s){s&&a(s,n,o.dispatchAction)}),mO(o.pendings,t)})}}function mO(r,t){var e=r.showTip.length,i=r.hideTip.length,a;e?a=r.showTip[e-1]:i&&(a=r.hideTip[i-1]),a&&(a.dispatchAction=null,t.dispatchAction(a))}function gO(r,t,e){r.handler("leave",null,e)}function k1(r,t,e,i){t.handler(r,e,i)}function yO(r){var t={showTip:[],hideTip:[]},e=function(i){var a=t[i.type];a?a.push(i):(i.dispatchAction=e,r.dispatchAction(i))};return{dispatchAction:e,pendings:t}}function vl(r,t){if(!tt.node){var e=t.getZr(),i=(di(e).records||{})[r];i&&(di(e).records[r]=null)}}var _O=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.render=function(e,i,a){var n=i.getComponent("tooltip"),o=e.get("triggerOn")||n&&n.get("triggerOn")||"mousemove|click";vh("axisPointer",a,function(s,l,u){o!=="none"&&(s==="leave"||o.indexOf(s)>=0)&&u({type:"updateAxisPointer",currTrigger:s,x:l&&l.offsetX,y:l&&l.offsetY})})},t.prototype.remove=function(e,i){vl("axisPointer",i)},t.prototype.dispose=function(e,i){vl("axisPointer",i)},t.type="axisPointer",t})(At),U1=_O;function dl(r,t){var e=[],i=r.seriesIndex,a;if(i==null||!(a=t.getSeriesByIndex(i)))return{point:[]};var n=a.getData(),o=ir(n,r);if(o==null||o<0||k(o))return{point:[]};var s=n.getItemGraphicEl(o),l=a.coordinateSystem;if(a.getTooltipPosition)e=a.getTooltipPosition(o)||[];else if(l&&l.dataToPoint)if(r.isStacked){var u=l.getBaseAxis(),f=l.getOtherAxis(u),h=f.dim,p=u.dim,c=h==="x"||h==="radius"?1:0,v=n.mapDimension(p),m=[];m[c]=n.get(v,o),m[1-c]=n.get(n.getCalculationInfo("stackResultDimension"),o),e=l.dataToPoint(m)||[]}else e=l.dataToPoint(n.getValues(U(l.dimensions,function(g){return n.mapDimension(g)}),o))||[];else if(s){var d=s.getBoundingRect().clone();d.applyTransform(s.transform),e=[d.x+d.width/2,d.y+d.height/2]}return{point:e,el:s}}var B1=ft();function ym(r,t,e){var i=r.currTrigger,a=[r.x,r.y],n=r,o=r.dispatchAction||X(e.dispatchAction,e),s=t.getComponent("axisPointer").coordSysAxesInfo;if(s){dh(a)&&(a=dl({seriesIndex:n.seriesIndex,dataIndex:n.dataIndex},t).point);var l=dh(a),u=n.axesInfo,f=s.axesInfo,h=i==="leave"||dh(a),p={},c={},v={list:[],map:{}},m={showPointer:lt(SO,c),showTooltip:lt(bO,v)};T(s.coordSysMap,function(g,y){var _=l||g.containPoint(a);T(s.coordSysAxesInfo[y],function(x,S){var b=x.axis,w=DO(u,x);if(!h&&_&&(!u||w)){var C=w&&w.value;C==null&&!l&&(C=b.pointToData(a)),C!=null&&V1(x,C,m,!1,p)}})});var d={};return T(f,function(g,y){var _=g.linkGroup;_&&!c[y]&&T(_.axesInfo,function(x,S){var b=c[S];if(x!==g&&b){var w=b.value;_.mapper&&(w=g.axis.scale.parse(_.mapper(w,F1(x),F1(g)))),d[g.key]=w}})}),T(d,function(g,y){V1(f[y],g,m,!0,p)}),wO(c,f,p),TO(v,a,r,o),CO(f,o,e),p}}function V1(r,t,e,i,a){var n=r.axis;if(!(n.scale.isBlank()||!n.containData(t))){if(!r.involveSeries){e.showPointer(r,t);return}var o=xO(t,r),s=o.payloadBatch,l=o.snapToValue;s[0]&&a.seriesIndex==null&&N(a,s[0]),!i&&r.snap&&n.containData(l)&&l!=null&&(t=l),e.showPointer(r,t,s),e.showTooltip(r,o,l)}}function xO(r,t){var e=t.axis,i=e.dim,a=r,n=[],o=Number.MAX_VALUE,s=-1;return T(t.seriesModels,function(l,u){var f=l.getData().mapDimensionsAll(i),h,p;if(l.getAxisTooltipData){var c=l.getAxisTooltipData(f,r,e);p=c.dataIndices,h=c.nestestValue}else{if(p=l.getData().indicesOfNearest(f[0],r,e.type==="category"?.5:null),!p.length)return;h=l.getData().get(f[0],p[0])}if(!(h==null||!isFinite(h))){var v=r-h,m=Math.abs(v);m<=o&&((m=0&&s<0)&&(o=m,s=v,a=h,n.length=0),T(p,function(d){n.push({seriesIndex:l.seriesIndex,dataIndexInside:d,dataIndex:l.getData().getRawIndex(d)})}))}}),{payloadBatch:n,snapToValue:a}}function SO(r,t,e,i){r[t.key]={value:e,payloadBatch:i}}function bO(r,t,e,i){var a=e.payloadBatch,n=t.axis,o=n.model,s=t.axisPointerModel;if(!(!t.triggerTooltip||!a.length)){var l=t.coordSys.model,u=To(l),f=r.map[u];f||(f=r.map[u]={coordSysId:l.id,coordSysIndex:l.componentIndex,coordSysType:l.type,coordSysMainType:l.mainType,dataByAxis:[]},r.list.push(f)),f.dataByAxis.push({axisDim:n.dim,axisIndex:o.componentIndex,axisType:o.type,axisId:o.id,value:i,valueLabelOpt:{precision:s.get(["label","precision"]),formatter:s.get(["label","formatter"])},seriesDataIndices:a.slice()})}}function wO(r,t,e){var i=e.axesInfo=[];T(t,function(a,n){var o=a.axisPointerModel.option,s=r[n];s?(!a.useHandle&&(o.status="show"),o.value=s.value,o.seriesDataIndices=(s.payloadBatch||[]).slice()):!a.useHandle&&(o.status="hide"),o.status==="show"&&i.push({axisDim:a.axis.dim,axisIndex:a.axis.model.componentIndex,value:o.value})})}function TO(r,t,e,i){if(dh(t)||!r.list.length){i({type:"hideTip"});return}var a=((r.list[0].dataByAxis[0]||{}).seriesDataIndices||[])[0]||{};i({type:"showTip",escapeConnect:!0,x:t[0],y:t[1],tooltipOption:e.tooltipOption,position:e.position,dataIndexInside:a.dataIndexInside,dataIndex:a.dataIndex,seriesIndex:a.seriesIndex,dataByCoordSys:r.list})}function CO(r,t,e){var i=e.getZr(),a="axisPointerLastHighlights",n=B1(i)[a]||{},o=B1(i)[a]={};T(r,function(u,f){var h=u.axisPointerModel.option;h.status==="show"&&u.triggerEmphasis&&T(h.seriesDataIndices,function(p){var c=p.seriesIndex+" | "+p.dataIndex;o[c]=p})});var s=[],l=[];T(n,function(u,f){!o[f]&&l.push(u)}),T(o,function(u,f){!n[f]&&s.push(u)}),l.length&&e.dispatchAction({type:"downplay",escapeConnect:!0,notBlur:!0,batch:l}),s.length&&e.dispatchAction({type:"highlight",escapeConnect:!0,notBlur:!0,batch:s})}function DO(r,t){for(var e=0;e<(r||[]).length;e++){var i=r[e];if(t.axis.dim===i.axisDim&&t.axis.model.componentIndex===i.axisIndex)return i}}function F1(r){var t=r.axis.model,e={},i=e.axisDim=r.axis.dim;return e.axisIndex=e[i+"AxisIndex"]=t.componentIndex,e.axisName=e[i+"AxisName"]=t.name,e.axisId=e[i+"AxisId"]=t.id,e}function dh(r){return!r||r[0]==null||isNaN(r[0])||r[1]==null||isNaN(r[1])}function mh(r){uh.registerAxisPointerClass("CartesianAxisPointer",O1),r.registerComponentModel(N1),r.registerComponentView(U1),r.registerPreprocessor(function(t){if(t){(!t.axisPointer||t.axisPointer.length===0)&&(t.axisPointer={});var e=t.axisPointer.link;e&&!k(e)&&(t.axisPointer.link=[e])}}),r.registerProcessor(r.PRIORITY.PROCESSOR.STATISTIC,function(t,e){t.getComponent("axisPointer").coordSysAxesInfo=Fw(t,e)}),r.registerAction({type:"updateAxisPointer",event:"updateAxisPointer",update:":updateAxisPointer"},ym)}function _m(r){zt(fh),zt(mh)}var xm=["x","y","radius","angle","single"],MO=["cartesian2d","polar","singleAxis"];function G1(r){var t=r.get("coordinateSystem");return at(MO,t)>=0}function vr(r){return r+"Axis"}function H1(r,t){var e=Y(),i=[],a=Y();r.eachComponent({mainType:"dataZoom",query:t},function(f){a.get(f.uid)||s(f)});var n;do n=!1,r.eachComponent("dataZoom",o);while(n);function o(f){!a.get(f.uid)&&l(f)&&(s(f),n=!0)}function s(f){a.set(f.uid,!0),i.push(f),u(f)}function l(f){var h=!1;return f.eachTargetAxis(function(p,c){var v=e.get(p);v&&v[c]&&(h=!0)}),h}function u(f){f.eachTargetAxis(function(h,p){(e.get(h)||e.set(h,[]))[p]=!0})}return i}function gh(r){var t=r.ecModel,e={infoList:[],infoMap:Y()};return r.eachTargetAxis(function(i,a){var n=t.getComponent(vr(i),a);if(n){var o=n.getCoordSysModel();if(o){var s=o.uid,l=e.infoMap.get(s);l||(l={model:o,axisModels:[]},e.infoList.push(l),e.infoMap.set(s,l)),l.axisModels.push(n)}}}),e}var Sm=(function(){function r(){this.indexList=[],this.indexMap=[]}return r.prototype.add=function(t){this.indexMap[t]||(this.indexList.push(t),this.indexMap[t]=!0)},r})(),AO=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e._autoThrottle=!0,e._noTarget=!0,e._rangePropMode=["percent","percent"],e}return t.prototype.init=function(e,i,a){var n=W1(e);this.settledOption=n,this.mergeDefaultAndTheme(e,a),this._doInit(n)},t.prototype.mergeOption=function(e){var i=W1(e);it(this.option,e,!0),it(this.settledOption,i,!0),this._doInit(i)},t.prototype._doInit=function(e){var i=this.option;this._setDefaultThrottle(e),this._updateRangeUse(e);var a=this.settledOption;T([["start","startValue"],["end","endValue"]],function(n,o){this._rangePropMode[o]==="value"&&(i[n[0]]=a[n[0]]=null)},this),this._resetTarget()},t.prototype._resetTarget=function(){var e=this.get("orient",!0),i=this._targetAxisInfoMap=Y(),a=this._fillSpecifiedTargetAxis(i);a?this._orient=e||this._makeAutoOrientByTargetAxis():(this._orient=e||"horizontal",this._fillAutoTargetAxisByOrient(i,this._orient)),this._noTarget=!0,i.each(function(n){n.indexList.length&&(this._noTarget=!1)},this)},t.prototype._fillSpecifiedTargetAxis=function(e){var i=!1;return T(xm,function(a){var n=this.getReferringComponents(vr(a),xy);if(n.specified){i=!0;var o=new Sm;T(n.models,function(s){o.add(s.componentIndex)}),e.set(a,o)}},this),i},t.prototype._fillAutoTargetAxisByOrient=function(e,i){var a=this.ecModel,n=!0;if(n){var o=i==="vertical"?"y":"x",s=a.findComponents({mainType:o+"Axis"});l(s,o)}if(n){var s=a.findComponents({mainType:"singleAxis",filter:function(f){return f.get("orient",!0)===i}});l(s,"single")}function l(u,f){var h=u[0];if(h){var p=new Sm;if(p.add(h.componentIndex),e.set(f,p),n=!1,f==="x"||f==="y"){var c=h.getReferringComponents("grid",Ht).models[0];c&&T(u,function(v){h.componentIndex!==v.componentIndex&&c===v.getReferringComponents("grid",Ht).models[0]&&p.add(v.componentIndex)})}}}n&&T(xm,function(u){if(n){var f=a.findComponents({mainType:vr(u),filter:function(p){return p.get("type",!0)==="category"}});if(f[0]){var h=new Sm;h.add(f[0].componentIndex),e.set(u,h),n=!1}}},this)},t.prototype._makeAutoOrientByTargetAxis=function(){var e;return this.eachTargetAxis(function(i){!e&&(e=i)},this),e==="y"?"vertical":"horizontal"},t.prototype._setDefaultThrottle=function(e){if(e.hasOwnProperty("throttle")&&(this._autoThrottle=!1),this._autoThrottle){var i=this.ecModel.option;this.option.throttle=i.animation&&i.animationDurationUpdate>0?100:20}},t.prototype._updateRangeUse=function(e){var i=this._rangePropMode,a=this.get("rangeMode");T([["start","startValue"],["end","endValue"]],function(n,o){var s=e[n[0]]!=null,l=e[n[1]]!=null;s&&!l?i[o]="percent":!s&&l?i[o]="value":a?i[o]=a[o]:s&&(i[o]="percent")})},t.prototype.noTarget=function(){return this._noTarget},t.prototype.getFirstTargetAxisModel=function(){var e;return this.eachTargetAxis(function(i,a){e==null&&(e=this.ecModel.getComponent(vr(i),a))},this),e},t.prototype.eachTargetAxis=function(e,i){this._targetAxisInfoMap.each(function(a,n){T(a.indexList,function(o){e.call(i,n,o)})})},t.prototype.getAxisProxy=function(e,i){var a=this.getAxisModel(e,i);if(a)return a.__dzAxisProxy},t.prototype.getAxisModel=function(e,i){var a=this._targetAxisInfoMap.get(e);if(a&&a.indexMap[i])return this.ecModel.getComponent(vr(e),i)},t.prototype.setRawRange=function(e){var i=this.option,a=this.settledOption;T([["start","startValue"],["end","endValue"]],function(n){(e[n[0]]!=null||e[n[1]]!=null)&&(i[n[0]]=a[n[0]]=e[n[0]],i[n[1]]=a[n[1]]=e[n[1]])},this),this._updateRangeUse(e)},t.prototype.setCalculatedRange=function(e){var i=this.option;T(["start","startValue","end","endValue"],function(a){i[a]=e[a]})},t.prototype.getPercentRange=function(){var e=this.findRepresentativeAxisProxy();if(e)return e.getDataPercentWindow()},t.prototype.getValueRange=function(e,i){if(e==null&&i==null){var a=this.findRepresentativeAxisProxy();if(a)return a.getDataValueWindow()}else return this.getAxisProxy(e,i).getDataValueWindow()},t.prototype.findRepresentativeAxisProxy=function(e){if(e)return e.__dzAxisProxy;for(var i,a=this._targetAxisInfoMap.keys(),n=0;no[1];if(_&&!x&&!S)return!0;_&&(d=!0),x&&(v=!0),S&&(m=!0)}return d&&v&&m})}else Mo(f,function(c){if(n==="empty")l.setData(u=u.map(c,function(m){return s(m)?m:NaN}));else{var v={};v[c]=o,u.selectRange(v)}});Mo(f,function(c){u.setApproximateExtent(o,c)})}});function s(l){return l>=o[0]&&l<=o[1]}},r.prototype._updateMinMaxSpan=function(){var t=this._minMaxSpan={},e=this._dataZoomModel,i=this._dataExtent;Mo(["min","max"],function(a){var n=e.get(a+"Span"),o=e.get(a+"ValueSpan");o!=null&&(o=this.getAxisModel().axis.scale.parse(o)),o!=null?n=Ct(i[0]+o,i,[0,100],!0):n!=null&&(o=Ct(n,[0,100],i,!0)-i[0]),t[a+"Span"]=n,t[a+"ValueSpan"]=o},this)},r.prototype._setAxisModel=function(){var t=this.getAxisModel(),e=this._percentWindow,i=this._valueWindow;if(e){var a=Pn(i,[0,500]);a=Math.min(a,20);var n=t.axis.scale.rawExtentInfo;e[0]!==0&&n.setDeterminedMinMax("min",+i[0].toFixed(a)),e[1]!==100&&n.setDeterminedMinMax("max",+i[1].toFixed(a)),n.freeze()}},r})();function PO(r,t,e){var i=[1/0,-1/0];Mo(e,function(o){cb(i,o.getData(),t)});var a=r.getAxisModel(),n=Hf(a.axis.scale,a,i).calculate();return[n.min,n.max]}var Z1=LO;var IO={getTargetSeries:function(r){function t(a){r.eachComponent("dataZoom",function(n){n.eachTargetAxis(function(o,s){var l=r.getComponent(vr(o),s);a(o,s,l,n)})})}t(function(a,n,o,s){o.__dzAxisProxy=null});var e=[];t(function(a,n,o,s){o.__dzAxisProxy||(o.__dzAxisProxy=new Z1(a,n,s,r),e.push(o.__dzAxisProxy))});var i=Y();return T(e,function(a){T(a.getTargetSeriesModels(),function(n){i.set(n.uid,n)})}),i},overallReset:function(r,t){r.eachComponent("dataZoom",function(e){e.eachTargetAxis(function(i,a){e.getAxisProxy(i,a).reset(e)}),e.eachTargetAxis(function(i,a){e.getAxisProxy(i,a).filterData(e,t)})}),r.eachComponent("dataZoom",function(e){var i=e.findRepresentativeAxisProxy();if(i){var a=i.getDataPercentWindow(),n=i.getDataValueWindow();e.setCalculatedRange({start:a[0],end:a[1],startValue:n[0],endValue:n[1]})}})}},X1=IO;function bm(r){r.registerAction("dataZoom",function(t,e){var i=H1(e,t);T(i,function(a){a.setRawRange({start:t.start,end:t.end,startValue:t.startValue,endValue:t.endValue})})})}var q1=!1;function ml(r){q1||(q1=!0,r.registerProcessor(r.PRIORITY.PROCESSOR.FILTER,X1),bm(r),r.registerSubTypeDefaulter("dataZoom",function(){return"slider"}))}function K1(r,t){var e=Ur(t.get("padding")),i=t.getItemStyle(["color","opacity"]);return i.fill=t.get("backgroundColor"),r=new mt({shape:{x:r.x-e[3],y:r.y-e[0],width:r.width+e[1]+e[3],height:r.height+e[0]+e[2],r:t.get("borderRadius")},style:i,silent:!0,z2:-1}),r}var RO=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.type="tooltip",t.dependencies=["axisPointer"],t.defaultOption={z:60,show:!0,showContent:!0,trigger:"item",triggerOn:"mousemove|click",alwaysShowContent:!1,displayMode:"single",renderMode:"auto",confine:null,showDelay:0,hideDelay:100,transitionDuration:.4,enterable:!1,backgroundColor:"#fff",shadowBlur:10,shadowColor:"rgba(0, 0, 0, .2)",shadowOffsetX:1,shadowOffsetY:2,borderRadius:4,borderWidth:1,padding:null,extraCssText:"",axisPointer:{type:"line",axis:"auto",animation:"auto",animationDurationUpdate:200,animationEasingUpdate:"exponentialOut",crossStyle:{color:"#999",width:1,type:"dashed",textStyle:{}}},textStyle:{color:"#666",fontSize:14}},t})(ct),j1=RO;function _h(r){var t=r.get("confine");return t!=null?!!t:r.get("renderMode")==="richText"}function Q1(r){if(tt.domSupported){for(var t=document.documentElement.style,e=0,i=r.length;e-1?(s+="top:50%",l+="translateY(-50%) rotate("+(u=n==="left"?-225:-45)+"deg)"):(s+="left:50%",l+="translateX(-50%) rotate("+(u=n==="top"?225:45)+"deg)");var f=u*Math.PI/180,h=o+a,p=h*Math.abs(Math.cos(f))+h*Math.abs(Math.sin(f)),c=Math.round(((p-Math.SQRT2*a)/2+Math.SQRT2*a-(p-h)/2)*100)/100;s+=";"+n+":-"+c+"px";var v=t+" solid "+a+"px;",m=["position:absolute;width:"+o+"px;height:"+o+"px;z-index:-1;",s+";"+l+";","border-bottom:"+v,"border-right:"+v,"background-color:"+i+";"];return'
'}function UO(r,t){var e="cubic-bezier(0.23,1,0.32,1)",i=" "+r/2+"s "+e,a="opacity"+i+",visibility"+i;return t||(i=" "+r+"s "+e,a+=tt.transformSupported?","+Cm+i:",left"+i+",top"+i),OO+":"+a}function tT(r,t,e){var i=r.toFixed(0)+"px",a=t.toFixed(0)+"px";if(!tt.transformSupported)return e?"top:"+a+";left:"+i+";":[["top",a],["left",i]];var n=tt.transform3dSupported,o="translate"+(n?"3d":"")+"("+i+","+a+(n?",0":"")+")";return e?"top:0;left:0;"+Cm+":"+o+";":[["top",0],["left",0],[wm,o]]}function BO(r){var t=[],e=r.get("fontSize"),i=r.getTextColor();i&&t.push("color:"+i),t.push("font:"+r.getFont());var a=Q(r.get("lineHeight"),Math.round(e*3/2));e&&t.push("line-height:"+a+"px");var n=r.get("textShadowColor"),o=r.get("textShadowBlur")||0,s=r.get("textShadowOffsetX")||0,l=r.get("textShadowOffsetY")||0;return n&&o&&t.push("text-shadow:"+s+"px "+l+"px "+o+"px "+n),T(["decoration","align"],function(u){var f=r.get(u);f&&t.push("text-"+u+":"+f)}),t.join(";")}function VO(r,t,e){var i=[],a=r.get("transitionDuration"),n=r.get("backgroundColor"),o=r.get("shadowBlur"),s=r.get("shadowColor"),l=r.get("shadowOffsetX"),u=r.get("shadowOffsetY"),f=r.getModel("textStyle"),h=cf(r,"html"),p=l+"px "+u+"px "+o+"px "+s;return i.push("box-shadow:"+p),t&&a&&i.push(UO(a,e)),n&&i.push("background-color:"+n),T(["width","color","radius"],function(c){var v="border-"+c,m=to(v),d=r.get(m);d!=null&&i.push(v+":"+d+(c==="color"?"":"px"))}),i.push(BO(f)),h!=null&&i.push("padding:"+Ur(h).join("px ")+"px"),i.join(";")+";"}function eT(r,t,e,i,a){var n=t&&t.painter;if(e){var o=n&&n.getViewportRoot();o&&sg(r,o,e,i,a)}else{r[0]=i,r[1]=a;var s=n&&n.getViewportRootOffset();s&&(r[0]+=s.offsetLeft,r[1]+=s.offsetTop)}r[2]=r[0]/t.getWidth(),r[3]=r[1]/t.getHeight()}var FO=(function(){function r(t,e){if(this._show=!1,this._styleCoord=[0,0,0,0],this._enterable=!0,this._alwaysShowContent=!1,this._firstShow=!0,this._longHide=!0,tt.wxa)return null;var i=document.createElement("div");i.domBelongToZr=!0,this.el=i;var a=this._zr=t.getZr(),n=e.appendTo,o=n&&(B(n)?document.querySelector(n):$i(n)?n:G(n)&&n(t.getDom()));eT(this._styleCoord,a,o,t.getWidth()/2,t.getHeight()/2),(o||t.getDom()).appendChild(i),this._api=t,this._container=o;var s=this;i.onmouseenter=function(){s._enterable&&(clearTimeout(s._hideTimeout),s._show=!0),s._inContent=!0},i.onmousemove=function(l){if(l=l||window.event,!s._enterable){var u=a.handler,f=a.painter.getViewportRoot();Ee(f,l,!0),u.dispatch("mousemove",l)}},i.onmouseleave=function(){s._inContent=!1,s._enterable&&s._show&&s.hideLater(s._hideDelay)}}return r.prototype.update=function(t){if(!this._container){var e=this._api.getDom(),i=$1(e,"position"),a=e.style;a.position!=="absolute"&&i!=="absolute"&&(a.position="relative")}var n=t.get("alwaysShowContent");n&&this._moveIfResized(),this._alwaysShowContent=n,this.el.className=t.get("className")||""},r.prototype.show=function(t,e){clearTimeout(this._hideTimeout),clearTimeout(this._longHideTimeout);var i=this.el,a=i.style,n=this._styleCoord;i.innerHTML?a.cssText=NO+VO(t,!this._firstShow,this._longHide)+tT(n[0],n[1],!0)+("border-color:"+Sr(e)+";")+(t.get("extraCssText")||"")+(";pointer-events:"+(this._enterable?"auto":"none")):a.display="none",this._show=!0,this._firstShow=!1,this._longHide=!1},r.prototype.setContent=function(t,e,i,a,n){var o=this.el;if(t==null){o.innerHTML="";return}var s="";if(B(n)&&i.get("trigger")==="item"&&!_h(i)&&(s=zO(i,a,n)),B(t))o.innerHTML=t+s;else if(t){o.innerHTML="",k(t)||(t=[t]);for(var l=0;l=0?this._tryShow(n,o):a==="leave"&&this._hide(o))},this))},t.prototype._keepShow=function(){var e=this._tooltipModel,i=this._ecModel,a=this._api,n=e.get("triggerOn");if(this._lastX!=null&&this._lastY!=null&&n!=="none"&&n!=="click"){var o=this;clearTimeout(this._refreshUpdateTimeout),this._refreshUpdateTimeout=setTimeout(function(){!a.isDisposed()&&o.manuallyShowTip(e,i,a,{x:o._lastX,y:o._lastY,dataByCoordSys:o._lastDataByCoordSys})})}},t.prototype.manuallyShowTip=function(e,i,a,n){if(!(n.from===this.uid||tt.node||!a.getDom())){var o=oT(n,a);this._ticket="";var s=n.dataByCoordSys,l=qO(n,i,a);if(l){var u=l.el.getBoundingRect().clone();u.applyTransform(l.el.transform),this._tryShow({offsetX:u.x+u.width/2,offsetY:u.y+u.height/2,target:l.el,position:n.position,positionDefault:"bottom"},o)}else if(n.tooltip&&n.x!=null&&n.y!=null){var f=HO;f.x=n.x,f.y=n.y,f.update(),ot(f).tooltipConfig={name:null,option:n.tooltip},this._tryShow({offsetX:n.x,offsetY:n.y,target:f},o)}else if(s)this._tryShow({offsetX:n.x,offsetY:n.y,position:n.position,dataByCoordSys:s,tooltipOption:n.tooltipOption},o);else if(n.seriesIndex!=null){if(this._manuallyAxisShowTip(e,i,a,n))return;var h=dl(n,i),p=h.point[0],c=h.point[1];p!=null&&c!=null&&this._tryShow({offsetX:p,offsetY:c,target:h.el,position:n.position,positionDefault:"bottom"},o)}else n.x!=null&&n.y!=null&&(a.dispatchAction({type:"updateAxisPointer",x:n.x,y:n.y}),this._tryShow({offsetX:n.x,offsetY:n.y,position:n.position,target:a.getZr().findHover(n.x,n.y).target},o))}},t.prototype.manuallyHideTip=function(e,i,a,n){var o=this._tooltipContent;this._tooltipModel&&o.hideLater(this._tooltipModel.get("hideDelay")),this._lastX=this._lastY=this._lastDataByCoordSys=null,n.from!==this.uid&&this._hide(oT(n,a))},t.prototype._manuallyAxisShowTip=function(e,i,a,n){var o=n.seriesIndex,s=n.dataIndex,l=i.getComponent("axisPointer").coordSysAxesInfo;if(!(o==null||s==null||l==null)){var u=i.getSeriesByIndex(o);if(u){var f=u.getData(),h=gl([f.getItemModel(s),u,(u.coordinateSystem||{}).model],this._tooltipModel);if(h.get("trigger")==="axis")return a.dispatchAction({type:"updateAxisPointer",seriesIndex:o,dataIndex:s,position:n.position}),!0}}},t.prototype._tryShow=function(e,i){var a=e.target,n=this._tooltipModel;if(n){this._lastX=e.offsetX,this._lastY=e.offsetY;var o=e.dataByCoordSys;if(o&&o.length)this._showAxisTooltip(o,e);else if(a){var s=ot(a);if(s.ssrType==="legend")return;this._lastDataByCoordSys=null;var l,u;tn(a,function(f){if(ot(f).dataIndex!=null)return l=f,!0;if(ot(f).tooltipConfig!=null)return u=f,!0},!0),l?this._showSeriesItemTooltip(e,l,i):u?this._showComponentItemTooltip(e,u,i):this._hide(i)}else this._lastDataByCoordSys=null,this._hide(i)}},t.prototype._showOrMove=function(e,i){var a=e.get("showDelay");i=X(i,this),clearTimeout(this._showTimout),a>0?this._showTimout=setTimeout(i,a):i()},t.prototype._showAxisTooltip=function(e,i){var a=this._ecModel,n=this._tooltipModel,o=[i.offsetX,i.offsetY],s=gl([i.tooltipOption],n),l=this._renderMode,u=[],f=Ze("section",{blocks:[],noHeader:!0}),h=[],p=new pf;T(e,function(y){T(y.dataByAxis,function(_){var x=a.getComponent(_.axisDim+"Axis",_.axisIndex),S=_.value;if(!(!x||S==null)){var b=mm(S,x.axis,a,_.seriesDataIndices,_.valueLabelOpt),w=Ze("section",{header:b,noHeader:!ee(b),sortBlocks:!0,blocks:[]});f.blocks.push(w),T(_.seriesDataIndices,function(C){var M=a.getSeriesByIndex(C.seriesIndex),A=C.dataIndexInside,D=M.getDataParams(A);if(!(D.dataIndex<0)){D.axisDim=_.axisDim,D.axisIndex=_.axisIndex,D.axisType=_.axisType,D.axisId=_.axisId,D.axisValue=ol(x.axis,{value:S}),D.axisValueLabel=b,D.marker=p.makeTooltipMarker("item",Sr(D.color),l);var E=fv(M.formatTooltip(A,!0,null)),L=E.frag;if(L){var I=gl([M],n).get("valueFormatter");w.blocks.push(I?N({valueFormatter:I},L):L)}E.text&&h.push(E.text),u.push(D)}})}})}),f.blocks.reverse(),h.reverse();var c=i.position,v=s.get("order"),m=gv(f,p,l,v,a.get("useUTC"),s.get("textStyle"));m&&h.unshift(m);var d=l==="richText"?` + +`:"
",g=h.join(d);this._showOrMove(s,function(){this._updateContentNotChangedOnAxis(e,u)?this._updatePosition(s,c,o[0],o[1],this._tooltipContent,u):this._showTooltipContent(s,g,u,Math.random()+"",o[0],o[1],c,null,p)})},t.prototype._showSeriesItemTooltip=function(e,i,a){var n=this._ecModel,o=ot(i),s=o.seriesIndex,l=n.getSeriesByIndex(s),u=o.dataModel||l,f=o.dataIndex,h=o.dataType,p=u.getData(h),c=this._renderMode,v=e.positionDefault,m=gl([p.getItemModel(f),u,l&&(l.coordinateSystem||{}).model],this._tooltipModel,v?{position:v}:null),d=m.get("trigger");if(!(d!=null&&d!=="item")){var g=u.getDataParams(f,h),y=new pf;g.marker=y.makeTooltipMarker("item",Sr(g.color),c);var _=fv(u.formatTooltip(f,!1,h)),x=m.get("order"),S=m.get("valueFormatter"),b=_.frag,w=b?gv(S?N({valueFormatter:S},b):b,y,c,x,n.get("useUTC"),m.get("textStyle")):_.text,C="item_"+u.name+"_"+f;this._showOrMove(m,function(){this._showTooltipContent(m,w,g,C,e.offsetX,e.offsetY,e.position,e.target,y)}),a({type:"showTip",dataIndexInside:f,dataIndex:p.getRawIndex(f),seriesIndex:s,from:this.uid})}},t.prototype._showComponentItemTooltip=function(e,i,a){var n=this._renderMode==="html",o=ot(i),s=o.tooltipConfig,l=s.option||{},u=l.encodeHTMLContent;if(B(l)){var f=l;l={content:f,formatter:f},u=!0}u&&n&&l.content&&(l=K(l),l.content=jt(l.content));var h=[l],p=this._ecModel.getComponent(o.componentMainType,o.componentIndex);p&&h.push(p),h.push({formatter:l.content});var c=e.positionDefault,v=gl(h,this._tooltipModel,c?{position:c}:null),m=v.get("content"),d=Math.random()+"",g=new pf;this._showOrMove(v,function(){var y=K(v.get("formatterParams")||{});this._showTooltipContent(v,m,y,d,e.offsetX,e.offsetY,e.position,i,g)}),a({type:"showTip",from:this.uid})},t.prototype._showTooltipContent=function(e,i,a,n,o,s,l,u,f){if(this._ticket="",!(!e.get("showContent")||!e.get("show"))){var h=this._tooltipContent;h.setEnterable(e.get("enterable"));var p=e.get("formatter");l=l||e.get("position");var c=i,v=this._getNearestPoint([o,s],a,e.get("trigger"),e.get("borderColor")),m=v.color;if(p)if(B(p)){var d=e.ecModel.get("useUTC"),g=k(a)?a[0]:a,y=g&&g.axisType&&g.axisType.indexOf("time")>=0;c=p,y&&(c=ui(g.axisValue,c,d)),c=eo(c,a,!0)}else if(G(p)){var _=X(function(x,S){x===this._ticket&&(h.setContent(S,f,e,m,l),this._updatePosition(e,l,o,s,h,a,u))},this);this._ticket=n,c=p(a,n,_)}else c=p;h.setContent(c,f,e,m,l),h.show(e,m),this._updatePosition(e,l,o,s,h,a,u)}},t.prototype._getNearestPoint=function(e,i,a,n){if(a==="axis"||k(i))return{color:n||(this._renderMode==="html"?"#fff":"none")};if(!k(i))return{color:n||i.color||i.borderColor}},t.prototype._updatePosition=function(e,i,a,n,o,s,l){var u=this._api.getWidth(),f=this._api.getHeight();i=i||e.get("position");var h=o.getSize(),p=e.get("align"),c=e.get("verticalAlign"),v=l&&l.getBoundingRect().clone();if(l&&v.applyTransform(l.transform),G(i)&&(i=i([a,n],s,o.el,v,{viewSize:[u,f],contentSize:h.slice()})),k(i))a=j(i[0],u),n=j(i[1],f);else if(H(i)){var m=i;m.width=h[0],m.height=h[1];var d=De(m,{width:u,height:f});a=d.x,n=d.y,p=null,c=null}else if(B(i)&&l){var g=XO(i,v,h,e.get("borderWidth"));a=g[0],n=g[1]}else{var g=YO(a,n,o,u,f,p?null:20,c?null:20);a=g[0],n=g[1]}if(p&&(a-=sT(p)?h[0]/2:p==="right"?h[0]:0),c&&(n-=sT(c)?h[1]/2:c==="bottom"?h[1]:0),_h(e)){var g=ZO(a,n,o,u,f);a=g[0],n=g[1]}o.moveTo(a,n)},t.prototype._updateContentNotChangedOnAxis=function(e,i){var a=this._lastDataByCoordSys,n=this._cbParamsList,o=!!a&&a.length===e.length;return o&&T(a,function(s,l){var u=s.dataByAxis||[],f=e[l]||{},h=f.dataByAxis||[];o=o&&u.length===h.length,o&&T(u,function(p,c){var v=h[c]||{},m=p.seriesDataIndices||[],d=v.seriesDataIndices||[];o=o&&p.value===v.value&&p.axisType===v.axisType&&p.axisId===v.axisId&&m.length===d.length,o&&T(m,function(g,y){var _=d[y];o=o&&g.seriesIndex===_.seriesIndex&&g.dataIndex===_.dataIndex}),n&&T(p.seriesDataIndices,function(g){var y=g.seriesIndex,_=i[y],x=n[y];_&&x&&x.data!==_.data&&(o=!1)})})}),this._lastDataByCoordSys=e,this._cbParamsList=i,!!o},t.prototype._hide=function(e){this._lastDataByCoordSys=null,e({type:"hideTip",from:this.uid})},t.prototype.dispose=function(e,i){tt.node||!i.getDom()||($a(this,"_updatePosition"),this._tooltipContent.dispose(),vl("itemTooltip",i))},t.type="tooltip",t})(At);function gl(r,t,e){var i=t.ecModel,a;e?(a=new wt(e,i,i),a=new wt(t.option,a,i)):a=t;for(var n=r.length-1;n>=0;n--){var o=r[n];o&&(o instanceof wt&&(o=o.get("tooltip",!0)),B(o)&&(o={formatter:o}),o&&(a=new wt(o,a,i)))}return a}function oT(r,t){return r.dispatchAction||X(t.dispatchAction,t)}function YO(r,t,e,i,a,n,o){var s=e.getSize(),l=s[0],u=s[1];return n!=null&&(r+l+n+2>i?r-=l+n:r+=n),o!=null&&(t+u+o>a?t-=u+o:t+=o),[r,t]}function ZO(r,t,e,i,a){var n=e.getSize(),o=n[0],s=n[1];return r=Math.min(r+o,i)-o,t=Math.min(t+s,a)-s,r=Math.max(r,0),t=Math.max(t,0),[r,t]}function XO(r,t,e,i){var a=e[0],n=e[1],o=Math.ceil(Math.SQRT2*i)+8,s=0,l=0,u=t.width,f=t.height;switch(r){case"inside":s=t.x+u/2-a/2,l=t.y+f/2-n/2;break;case"top":s=t.x+u/2-a/2,l=t.y-n-o;break;case"bottom":s=t.x+u/2-a/2,l=t.y+f+o;break;case"left":s=t.x-a-o,l=t.y+f/2-n/2;break;case"right":s=t.x+u+o,l=t.y+f/2-n/2}return[s,l]}function sT(r){return r==="center"||r==="middle"}function qO(r,t,e){var i=as(r).queryOptionMap,a=i.keys()[0];if(!(!a||a==="series")){var n=Ti(t,a,i.get(a),{useDefault:!1,enableAll:!1,enableNone:!1}),o=n.models[0];if(o){var s=e.getViewOfComponentModel(o),l;if(s.group.traverse(function(u){var f=ot(u).tooltipConfig;if(f&&f.name===r.name)return l=u,!0}),l)return{componentMainType:a,componentIndex:o.componentIndex,el:l}}}}var lT=WO;function Dm(r){zt(mh),r.registerComponentModel(j1),r.registerComponentView(lT),r.registerAction({type:"showTip",event:"showTip",update:"tooltip:manuallyShowTip"},Bt),r.registerAction({type:"hideTip",event:"hideTip",update:"tooltip:manuallyHideTip"},Bt)}var KO=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e.layoutMode={type:"box",ignoreSize:!0},e}return t.type="title",t.defaultOption={z:6,show:!0,text:"",target:"blank",subtext:"",subtarget:"blank",left:0,top:0,backgroundColor:"rgba(0,0,0,0)",borderColor:"#ccc",borderWidth:0,padding:5,itemGap:10,textStyle:{fontSize:18,fontWeight:"bold",color:"#464646"},subtextStyle:{fontSize:12,color:"#6E7079"}},t})(ct),jO=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.render=function(e,i,a){if(this.group.removeAll(),!!e.get("show")){var n=this.group,o=e.getModel("textStyle"),s=e.getModel("subtextStyle"),l=e.get("textAlign"),u=Q(e.get("textBaseline"),e.get("textVerticalAlign")),f=new yt({style:Wt(o,{text:e.get("text"),fill:o.getTextColor()},{disableBox:!0}),z2:10}),h=f.getBoundingRect(),p=e.get("subtext"),c=new yt({style:Wt(s,{text:p,fill:s.getTextColor(),y:h.height+e.get("itemGap"),verticalAlign:"top"},{disableBox:!0}),z2:10}),v=e.get("link"),m=e.get("sublink"),d=e.get("triggerEvent",!0);f.silent=!v&&!d,c.silent=!m&&!d,v&&f.on("click",function(){jp(v,"_"+e.get("target"))}),m&&c.on("click",function(){jp(m,"_"+e.get("subtarget"))}),ot(f).eventData=ot(c).eventData=d?{componentType:"title",componentIndex:e.componentIndex}:null,n.add(f),p&&n.add(c);var g=n.getBoundingRect(),y=e.getBoxLayoutParams();y.width=g.width,y.height=g.height;var _=De(y,{width:a.getWidth(),height:a.getHeight()},e.get("padding"));l||(l=e.get("left")||e.get("right"),l==="middle"&&(l="center"),l==="right"?_.x+=_.width:l==="center"&&(_.x+=_.width/2)),u||(u=e.get("top")||e.get("bottom"),u==="center"&&(u="middle"),u==="bottom"?_.y+=_.height:u==="middle"&&(_.y+=_.height/2),u=u||"top"),n.x=_.x,n.y=_.y,n.markRedraw();var x={align:l,verticalAlign:u};f.setStyle(x),c.setStyle(x),g=n.getBoundingRect();var S=_.margin,b=e.getItemStyle(["color","opacity"]);b.fill=e.get("backgroundColor");var w=new mt({shape:{x:g.x-S[3],y:g.y-S[0],width:g.width+S[1]+S[3],height:g.height+S[0]+S[2],r:e.get("borderRadius")},style:b,subPixelOptimize:!0,silent:!0});n.add(w)}},t.type="title",t})(At);function Mm(r){r.registerComponentModel(KO),r.registerComponentView(jO)}function yl(r,t){if(!r)return!1;for(var e=k(r)?r:[r],i=0;i=0&&(o[n]=+o[n].toFixed(p)),[o,h]}var Am={min:lt(bh,"min"),max:lt(bh,"max"),average:lt(bh,"average"),median:lt(bh,"median")};function _l(r,t){if(t){var e=r.getData(),i=r.coordinateSystem,a=i&&i.dimensions;if(!$O(t)&&!k(t.coord)&&k(a)){var n=Em(t,e,i,r);if(t=K(t),t.type&&Am[t.type]&&n.baseAxis&&n.valueAxis){var o=at(a,n.baseAxis.dim),s=at(a,n.valueAxis.dim),l=Am[t.type](e,n.baseDataDim,n.valueDataDim,o,s);t.coord=l[0],t.value=l[1]}else t.coord=[t.xAxis!=null?t.xAxis:t.radiusAxis,t.yAxis!=null?t.yAxis:t.angleAxis]}if(t.coord==null||!k(a))t.coord=[];else for(var u=t.coord,f=0;f<2;f++)Am[u[f]]&&(u[f]=Th(e,e.mapDimension(a[f]),u[f]));return t}}function Em(r,t,e,i){var a={};return r.valueIndex!=null||r.valueDim!=null?(a.valueDataDim=r.valueIndex!=null?t.getDimension(r.valueIndex):r.valueDim,a.valueAxis=e.getAxis(t2(i,a.valueDataDim)),a.baseAxis=e.getOtherAxis(a.valueAxis),a.baseDataDim=t.mapDimension(a.baseAxis.dim)):(a.baseAxis=i.getBaseAxis(),a.valueAxis=e.getOtherAxis(a.baseAxis),a.baseDataDim=t.mapDimension(a.baseAxis.dim),a.valueDataDim=t.mapDimension(a.valueAxis.dim)),a}function t2(r,t){var e=r.getData().getDimensionInfo(t);return e&&e.coordDim}function xl(r,t){return r&&r.containData&&t.coord&&!JO(t)?r.containData(t.coord):!0}function wh(r,t){return r?function(e,i,a,n){var o=n<2?e.coord&&e.coord[n]:e.value;return pi(o,t[n])}:function(e,i,a,n){return pi(e.value,t[n])}}function Th(r,t,e){if(e==="average"){var i=0,a=0;return r.each(t,function(n,o){isNaN(n)||(i+=n,a++)}),i/a}else return e==="median"?r.getMedian(t):r.getDataExtent(t)[e==="max"?1:0]}var Lm=ft(),e2=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.init=function(){this.markerGroupMap=Y()},t.prototype.render=function(e,i,a){var n=this,o=this.markerGroupMap;o.each(function(s){Lm(s).keep=!1}),i.eachSeries(function(s){var l=Tr.getMarkerModelFromSeries(s,n.type);l&&n.renderSeries(s,l,i,a)}),o.each(function(s){!Lm(s).keep&&n.group.remove(s.group)})},t.prototype.markKeep=function(e){Lm(e).keep=!0},t.prototype.toggleBlurSeries=function(e,i){var a=this;T(e,function(n){var o=Tr.getMarkerModelFromSeries(n,a.type);if(o){var s=o.getData();s.eachItemGraphicEl(function(l){l&&(i?yu(l):ds(l))})}})},t.type="marker",t})(At),Ch=e2;function cT(r,t,e){var i=t.coordinateSystem;r.each(function(a){var n=r.getItemModel(a),o,s=j(n.get("x"),e.getWidth()),l=j(n.get("y"),e.getHeight());if(!isNaN(s)&&!isNaN(l))o=[s,l];else if(t.getMarkerPosition)o=t.getMarkerPosition(r.getValues(r.dimensions,a));else if(i){var u=r.get(i.dimensions[0],a),f=r.get(i.dimensions[1],a);o=i.dataToPoint([u,f])}isNaN(s)||(o[0]=s),isNaN(l)||(o[1]=l),r.setItemLayout(a,o)})}var r2=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.updateTransform=function(e,i,a){i.eachSeries(function(n){var o=Tr.getMarkerModelFromSeries(n,"markPoint");o&&(cT(o.getData(),n,a),this.markerGroupMap.get(n.id).updateLayout())},this)},t.prototype.renderSeries=function(e,i,a,n){var o=e.coordinateSystem,s=e.id,l=e.getData(),u=this.markerGroupMap,f=u.get(s)||u.set(s,new So),h=i2(o,e,i);i.setData(h),cT(i.getData(),e,n),h.each(function(p){var c=h.getItemModel(p),v=c.getShallow("symbol"),m=c.getShallow("symbolSize"),d=c.getShallow("symbolRotate"),g=c.getShallow("symbolOffset"),y=c.getShallow("symbolKeepAspect");if(G(v)||G(m)||G(d)||G(g)){var _=i.getRawValue(p),x=i.getDataParams(p);G(v)&&(v=v(_,x)),G(m)&&(m=m(_,x)),G(d)&&(d=d(_,x)),G(g)&&(g=g(_,x))}var S=c.getModel("itemStyle").getItemStyle(),b=uo(l,"color");S.fill||(S.fill=b),h.setItemVisual(p,{symbol:v,symbolSize:m,symbolRotate:d,symbolOffset:g,symbolKeepAspect:y,style:S})}),f.updateData(h),this.group.add(f.group),h.eachItemGraphicEl(function(p){p.traverse(function(c){ot(c).dataModel=i})}),this.markKeep(f),f.group.silent=i.get("silent")||e.get("silent")},t.type="markPoint",t})(Ch);function i2(r,t,e){var i;r?i=U(r&&r.dimensions,function(s){var l=t.getData().getDimensionInfo(t.getData().mapDimension(s))||{};return N(N({},l),{name:s,ordinalMeta:null})}):i=[{name:"value",type:"float"}];var a=new hr(i,e),n=U(e.get("data"),lt(_l,t));r&&(n=Tt(n,lt(xl,r)));var o=wh(!!r,i);return a.initData(n,null,o),a}var pT=r2;function Pm(r){r.registerComponentModel(fT),r.registerComponentView(pT),r.registerPreprocessor(function(t){yl(t.series,"markPoint")&&(t.markPoint=t.markPoint||{})})}var a2=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.createMarkerModelFromSeries=function(e,i,a){return new t(e,i,a)},t.type="markLine",t.defaultOption={z:5,symbol:["circle","arrow"],symbolSize:[8,16],symbolOffset:0,precision:2,tooltip:{trigger:"item"},label:{show:!0,position:"end",distance:5},lineStyle:{type:"dashed"},emphasis:{label:{show:!0},lineStyle:{width:3}},animationEasing:"linear"},t})(Tr),vT=a2;var Dh=ft(),n2=function(r,t,e,i){var a=r.getData(),n;if(k(i))n=i;else{var o=i.type;if(o==="min"||o==="max"||o==="average"||o==="median"||i.xAxis!=null||i.yAxis!=null){var s=void 0,l=void 0;if(i.yAxis!=null||i.xAxis!=null)s=t.getAxis(i.yAxis!=null?"y":"x"),l=Dr(i.yAxis,i.xAxis);else{var u=Em(i,a,t,r);s=u.valueAxis;var f=go(a,u.valueDataDim);l=Th(a,f,o)}var h=s.dim==="x"?0:1,p=1-h,c=K(i),v={coord:[]};c.type=null,c.coord=[],c.coord[p]=-1/0,v.coord[p]=1/0;var m=e.get("precision");m>=0&&et(l)&&(l=+l.toFixed(Math.min(m,20))),c.coord[h]=v.coord[h]=l,n=[c,v,{type:o,valueIndex:i.valueIndex,value:l}]}else n=[]}var d=[_l(r,n[0]),_l(r,n[1]),N({},n[2])];return d[2].type=d[2].type||null,it(d[2],d[0]),it(d[2],d[1]),d};function Mh(r){return!isNaN(r)&&!isFinite(r)}function dT(r,t,e,i){var a=1-r,n=i.dimensions[r];return Mh(t[a])&&Mh(e[a])&&t[r]===e[r]&&i.getAxis(n).containData(t[r])}function o2(r,t){if(r.type==="cartesian2d"){var e=t[0].coord,i=t[1].coord;if(e&&i&&(dT(1,e,i,r)||dT(0,e,i,r)))return!0}return xl(r,t[0])&&xl(r,t[1])}function Im(r,t,e,i,a){var n=i.coordinateSystem,o=r.getItemModel(t),s,l=j(o.get("x"),a.getWidth()),u=j(o.get("y"),a.getHeight());if(!isNaN(l)&&!isNaN(u))s=[l,u];else{if(i.getMarkerPosition)s=i.getMarkerPosition(r.getValues(r.dimensions,t));else{var f=n.dimensions,h=r.get(f[0],t),p=r.get(f[1],t);s=n.dataToPoint([h,p])}if(un(n,"cartesian2d")){var c=n.getAxis("x"),v=n.getAxis("y"),f=n.dimensions;Mh(r.get(f[0],t))?s[0]=c.toGlobalCoord(c.getExtent()[e?0:1]):Mh(r.get(f[1],t))&&(s[1]=v.toGlobalCoord(v.getExtent()[e?0:1]))}isNaN(l)||(s[0]=l),isNaN(u)||(s[1]=u)}r.setItemLayout(t,s)}var s2=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.prototype.updateTransform=function(e,i,a){i.eachSeries(function(n){var o=Tr.getMarkerModelFromSeries(n,"markLine");if(o){var s=o.getData(),l=Dh(o).from,u=Dh(o).to;l.each(function(f){Im(l,f,!0,n,a),Im(u,f,!1,n,a)}),s.each(function(f){s.setItemLayout(f,[l.getItemLayout(f),u.getItemLayout(f)])}),this.markerGroupMap.get(n.id).updateLayout()}},this)},t.prototype.renderSeries=function(e,i,a,n){var o=e.coordinateSystem,s=e.id,l=e.getData(),u=this.markerGroupMap,f=u.get(s)||u.set(s,new g1);this.group.add(f.group);var h=l2(o,e,i),p=h.from,c=h.to,v=h.line;Dh(i).from=p,Dh(i).to=c,i.setData(v);var m=i.get("symbol"),d=i.get("symbolSize"),g=i.get("symbolRotate"),y=i.get("symbolOffset");k(m)||(m=[m,m]),k(d)||(d=[d,d]),k(g)||(g=[g,g]),k(y)||(y=[y,y]),h.from.each(function(x){_(p,x,!0),_(c,x,!1)}),v.each(function(x){var S=v.getItemModel(x).getModel("lineStyle").getLineStyle();v.setItemLayout(x,[p.getItemLayout(x),c.getItemLayout(x)]),S.stroke==null&&(S.stroke=p.getItemVisual(x,"style").fill),v.setItemVisual(x,{fromSymbolKeepAspect:p.getItemVisual(x,"symbolKeepAspect"),fromSymbolOffset:p.getItemVisual(x,"symbolOffset"),fromSymbolRotate:p.getItemVisual(x,"symbolRotate"),fromSymbolSize:p.getItemVisual(x,"symbolSize"),fromSymbol:p.getItemVisual(x,"symbol"),toSymbolKeepAspect:c.getItemVisual(x,"symbolKeepAspect"),toSymbolOffset:c.getItemVisual(x,"symbolOffset"),toSymbolRotate:c.getItemVisual(x,"symbolRotate"),toSymbolSize:c.getItemVisual(x,"symbolSize"),toSymbol:c.getItemVisual(x,"symbol"),style:S})}),f.updateData(v),h.line.eachItemGraphicEl(function(x){ot(x).dataModel=i,x.traverse(function(S){ot(S).dataModel=i})});function _(x,S,b){var w=x.getItemModel(S);Im(x,S,b,e,n);var C=w.getModel("itemStyle").getItemStyle();C.fill==null&&(C.fill=uo(l,"color")),x.setItemVisual(S,{symbolKeepAspect:w.get("symbolKeepAspect"),symbolOffset:Q(w.get("symbolOffset",!0),y[b?0:1]),symbolRotate:Q(w.get("symbolRotate",!0),g[b?0:1]),symbolSize:Q(w.get("symbolSize"),d[b?0:1]),symbol:Q(w.get("symbol",!0),m[b?0:1]),style:C})}this.markKeep(f),f.group.silent=i.get("silent")||e.get("silent")},t.type="markLine",t})(Ch);function l2(r,t,e){var i;r?i=U(r&&r.dimensions,function(u){var f=t.getData().getDimensionInfo(t.getData().mapDimension(u))||{};return N(N({},f),{name:u,ordinalMeta:null})}):i=[{name:"value",type:"float"}];var a=new hr(i,e),n=new hr(i,e),o=new hr([],e),s=U(e.get("data"),lt(n2,t,r,e));r&&(s=Tt(s,lt(o2,r)));var l=wh(!!r,i);return a.initData(U(s,function(u){return u[0]}),null,l),n.initData(U(s,function(u){return u[1]}),null,l),o.initData(U(s,function(u){return u[2]})),o.hasItemOption=!0,{from:a,to:n,line:o}}var mT=s2;function Rm(r){r.registerComponentModel(vT),r.registerComponentView(mT),r.registerPreprocessor(function(t){yl(t.series,"markLine")&&(t.markLine=t.markLine||{})})}var u2=function(r,t){if(t==="all")return{type:"all",title:r.getLocaleModel().get(["legend","selector","all"])};if(t==="inverse")return{type:"inverse",title:r.getLocaleModel().get(["legend","selector","inverse"])}},f2=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e.layoutMode={type:"box",ignoreSize:!0},e}return t.prototype.init=function(e,i,a){this.mergeDefaultAndTheme(e,a),e.selected=e.selected||{},this._updateSelector(e)},t.prototype.mergeOption=function(e,i){r.prototype.mergeOption.call(this,e,i),this._updateSelector(e)},t.prototype._updateSelector=function(e){var i=e.selector,a=this.ecModel;i===!0&&(i=e.selector=["all","inverse"]),k(i)&&T(i,function(n,o){B(n)&&(n={type:n}),i[o]=it(n,u2(a,n.type))})},t.prototype.optionUpdated=function(){this._updateData(this.ecModel);var e=this._data;if(e[0]&&this.get("selectedMode")==="single"){for(var i=!1,a=0;a=0},t.prototype.getOrient=function(){return this.get("orient")==="vertical"?{index:1,name:"vertical"}:{index:0,name:"horizontal"}},t.type="legend.plain",t.dependencies=["series"],t.defaultOption={z:4,show:!0,orient:"horizontal",left:"center",top:0,align:"auto",backgroundColor:"rgba(0,0,0,0)",borderColor:"#ccc",borderRadius:0,borderWidth:0,padding:5,itemGap:10,itemWidth:25,itemHeight:14,symbolRotate:"inherit",symbolKeepAspect:!0,inactiveColor:"#ccc",inactiveBorderColor:"#ccc",inactiveBorderWidth:"auto",itemStyle:{color:"inherit",opacity:"inherit",borderColor:"inherit",borderWidth:"auto",borderCap:"inherit",borderJoin:"inherit",borderDashOffset:"inherit",borderMiterLimit:"inherit"},lineStyle:{width:"auto",color:"inherit",inactiveColor:"#ccc",inactiveWidth:2,opacity:"inherit",type:"inherit",cap:"inherit",join:"inherit",dashOffset:"inherit",miterLimit:"inherit"},textStyle:{color:"#333"},selectedMode:!0,selector:!1,selectorLabel:{show:!0,borderRadius:10,padding:[3,5,3,5],fontSize:12,fontFamily:"sans-serif",color:"#666",borderWidth:1,borderColor:"#666"},emphasis:{selectorLabel:{show:!0,color:"#eee",backgroundColor:"#666"}},selectorPosition:"auto",selectorItemGap:7,selectorButtonGap:10,tooltip:{show:!1}},t})(ct),Sl=f2;var Ao=lt,Om=T,Ah=ut,h2=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e.newlineDisabled=!1,e}return t.prototype.init=function(){this.group.add(this._contentGroup=new Ah),this.group.add(this._selectorGroup=new Ah),this._isFirstRender=!0},t.prototype.getContentGroup=function(){return this._contentGroup},t.prototype.getSelectorGroup=function(){return this._selectorGroup},t.prototype.render=function(e,i,a){var n=this._isFirstRender;if(this._isFirstRender=!1,this.resetInner(),!!e.get("show",!0)){var o=e.get("align"),s=e.get("orient");(!o||o==="auto")&&(o=e.get("left")==="right"&&s==="vertical"?"right":"left");var l=e.get("selector",!0),u=e.get("selectorPosition",!0);l&&(!u||u==="auto")&&(u=s==="horizontal"?"end":"start"),this.renderInner(o,e,i,a,l,s,u);var f=e.getBoxLayoutParams(),h={width:a.getWidth(),height:a.getHeight()},p=e.get("padding"),c=De(f,h,p),v=this.layoutInner(e,o,c,n,l,u),m=De(q({width:v.width,height:v.height},f),h,p);this.group.x=m.x-v.x,this.group.y=m.y-v.y,this.group.markRedraw(),this.group.add(this._backgroundEl=K1(v,e))}},t.prototype.resetInner=function(){this.getContentGroup().removeAll(),this._backgroundEl&&this.group.remove(this._backgroundEl),this.getSelectorGroup().removeAll()},t.prototype.renderInner=function(e,i,a,n,o,s,l){var u=this.getContentGroup(),f=Y(),h=i.get("selectedMode"),p=[];a.eachRawSeries(function(c){!c.get("legendHoverLink")&&p.push(c.id)}),Om(i.getData(),function(c,v){var m=c.get("name");if(!this.newlineDisabled&&(m===""||m===` +`)){var d=new Ah;d.newline=!0,u.add(d);return}var g=a.getSeriesByName(m)[0];if(!f.get(m))if(g){var y=g.getData(),_=y.getVisual("legendLineStyle")||{},x=y.getVisual("legendIcon"),S=y.getVisual("style"),b=this._createItem(g,m,v,c,i,e,_,S,x,h,n);b.on("click",Ao(gT,m,null,n,p)).on("mouseover",Ao(Nm,g.name,null,n,p)).on("mouseout",Ao(km,g.name,null,n,p)),a.ssr&&b.eachChild(function(w){var C=ot(w);C.seriesIndex=g.seriesIndex,C.dataIndex=v,C.ssrType="legend"}),f.set(m,!0)}else a.eachRawSeries(function(w){if(!f.get(m)&&w.legendVisualProvider){var C=w.legendVisualProvider;if(!C.containName(m))return;var M=C.indexOfName(m),A=C.getItemVisual(M,"style"),D=C.getItemVisual(M,"legendIcon"),E=pe(A.fill);E&&E[3]===0&&(E[3]=.2,A=N(N({},A),{fill:Lr(E,"rgba")}));var L=this._createItem(w,m,v,c,i,e,{},A,D,h,n);L.on("click",Ao(gT,null,m,n,p)).on("mouseover",Ao(Nm,null,m,n,p)).on("mouseout",Ao(km,null,m,n,p)),a.ssr&&L.eachChild(function(I){var R=ot(I);R.seriesIndex=w.seriesIndex,R.dataIndex=v,R.ssrType="legend"}),f.set(m,!0)}},this)},this),o&&this._createSelector(o,i,n,s,l)},t.prototype._createSelector=function(e,i,a,n,o){var s=this.getSelectorGroup();Om(e,function(u){var f=u.type,h=new yt({style:{x:0,y:0,align:"center",verticalAlign:"middle"},onclick:function(){a.dispatchAction({type:f==="all"?"legendAllSelect":"legendInverseSelect",legendId:i.id})}});s.add(h);var p=i.getModel("selectorLabel"),c=i.getModel(["emphasis","selectorLabel"]);Re(h,{normal:p,emphasis:c},{defaultText:u.title}),Ii(h)})},t.prototype._createItem=function(e,i,a,n,o,s,l,u,f,h,p){var c=e.visualDrawType,v=o.get("itemWidth"),m=o.get("itemHeight"),d=o.isSelected(i),g=n.get("symbolRotate"),y=n.get("symbolKeepAspect"),_=n.get("icon");f=_||f||"roundRect";var x=c2(f,n,l,u,c,d,p),S=new Ah,b=n.getModel("textStyle");if(G(e.getLegendIcon)&&(!_||_==="inherit"))S.add(e.getLegendIcon({itemWidth:v,itemHeight:m,icon:f,iconRotate:g,itemStyle:x.itemStyle,lineStyle:x.lineStyle,symbolKeepAspect:y}));else{var w=_==="inherit"&&e.getData().getVisual("symbol")?g==="inherit"?e.getData().getVisual("symbolRotate"):g:0;S.add(p2({itemWidth:v,itemHeight:m,icon:f,iconRotate:w,itemStyle:x.itemStyle,lineStyle:x.lineStyle,symbolKeepAspect:y}))}var C=s==="left"?v+5:-5,M=s,A=o.get("formatter"),D=i;B(A)&&A?D=A.replace("{name}",i??""):G(A)&&(D=A(i));var E=d?b.getTextColor():n.get("inactiveColor");S.add(new yt({style:Wt(b,{text:D,x:C,y:m/2,fill:E,align:M,verticalAlign:"middle"},{inheritColor:E})}));var L=new mt({shape:S.getBoundingRect(),style:{fill:"transparent"}}),I=n.getModel("tooltip");return I.get("show")&&jn({el:L,componentModel:o,itemName:i,itemTooltipOption:I.option}),S.add(L),S.eachChild(function(R){R.silent=!0}),L.silent=!h,this.getContentGroup().add(S),Ii(S),S.__legendDataIndex=a,S},t.prototype.layoutInner=function(e,i,a,n,o,s){var l=this.getContentGroup(),u=this.getSelectorGroup();Xa(e.get("orient"),l,e.get("itemGap"),a.width,a.height);var f=l.getBoundingRect(),h=[-f.x,-f.y];if(u.markRedraw(),l.markRedraw(),o){Xa("horizontal",u,e.get("selectorItemGap",!0));var p=u.getBoundingRect(),c=[-p.x,-p.y],v=e.get("selectorButtonGap",!0),m=e.getOrient().index,d=m===0?"width":"height",g=m===0?"height":"width",y=m===0?"y":"x";s==="end"?c[m]+=f[d]+v:h[m]+=p[d]+v,c[1-m]+=f[g]/2-p[g]/2,u.x=c[0],u.y=c[1],l.x=h[0],l.y=h[1];var _={x:0,y:0};return _[d]=f[d]+v+p[d],_[g]=Math.max(f[g],p[g]),_[y]=Math.min(0,p[y]+c[1-m]),_}else return l.x=h[0],l.y=h[1],this.group.getBoundingRect()},t.prototype.remove=function(){this.getContentGroup().removeAll(),this._isFirstRender=!0},t.type="legend.plain",t})(At);function c2(r,t,e,i,a,n,o){function s(d,g){d.lineWidth==="auto"&&(d.lineWidth=g.lineWidth>0?2:0),Om(d,function(y,_){d[_]==="inherit"&&(d[_]=g[_])})}var l=t.getModel("itemStyle"),u=l.getItemStyle(),f=r.lastIndexOf("empty",0)===0?"fill":"stroke",h=l.getShallow("decal");u.decal=!h||h==="inherit"?i.decal:Ws(h,o),u.fill==="inherit"&&(u.fill=i[a]),u.stroke==="inherit"&&(u.stroke=i[f]),u.opacity==="inherit"&&(u.opacity=(a==="fill"?i:e).opacity),s(u,i);var p=t.getModel("lineStyle"),c=p.getLineStyle();if(s(c,e),u.fill==="auto"&&(u.fill=i.fill),u.stroke==="auto"&&(u.stroke=i.fill),c.stroke==="auto"&&(c.stroke=i.fill),!n){var v=t.get("inactiveBorderWidth"),m=u[f];u.lineWidth=v==="auto"?i.lineWidth>0&&m?2:0:u.lineWidth,u.fill=t.get("inactiveColor"),u.stroke=t.get("inactiveBorderColor"),c.stroke=p.get("inactiveColor"),c.lineWidth=p.get("inactiveWidth")}return{itemStyle:u,lineStyle:c}}function p2(r){var t=r.icon||"roundRect",e=It(t,0,0,r.itemWidth,r.itemHeight,r.itemStyle.fill,r.symbolKeepAspect);return e.setStyle(r.itemStyle),e.rotation=(r.iconRotate||0)*Math.PI/180,e.setOrigin([r.itemWidth/2,r.itemHeight/2]),t.indexOf("empty")>-1&&(e.style.stroke=e.style.fill,e.style.fill="#fff",e.style.lineWidth=2),e}function gT(r,t,e,i){km(r,t,e,i),e.dispatchAction({type:"legendToggleSelect",name:r??t}),Nm(r,t,e,i)}function yT(r){for(var t=r.getZr().storage.getDisplayList(),e,i=0,a=t.length;ia[o],d=[-c.x,-c.y];i||(d[n]=f[u]);var g=[0,0],y=[-v.x,-v.y],_=Q(e.get("pageButtonGap",!0),e.get("itemGap",!0));if(m){var x=e.get("pageButtonPosition",!0);x==="end"?y[n]+=a[o]-v[o]:g[n]+=v[o]+_}y[1-n]+=c[s]/2-v[s]/2,f.setPosition(d),h.setPosition(g),p.setPosition(y);var S={x:0,y:0};if(S[o]=m?a[o]:c[o],S[s]=Math.max(c[s],v[s]),S[l]=Math.min(0,v[l]+y[1-n]),h.__rectSize=a[o],m){var b={x:0,y:0};b[o]=Math.max(a[o]-v[o]-_,0),b[s]=S[s],h.setClipPath(new mt({shape:b})),h.__rectSize=b[o]}else p.eachChild(function(C){C.attr({invisible:!0,silent:!0})});var w=this._getPageInfo(e);return w.pageIndex!=null&&xt(f,{x:w.contentPosition[0],y:w.contentPosition[1]},m?e:null),this._updatePageInfoView(e,w),S},t.prototype._pageGo=function(e,i,a){var n=this._getPageInfo(i)[e];n!=null&&a.dispatchAction({type:"legendScroll",scrollDataIndex:n,legendId:i.id})},t.prototype._updatePageInfoView=function(e,i){var a=this._controllerGroup;T(["pagePrev","pageNext"],function(f){var h=f+"DataIndex",p=i[h]!=null,c=a.childOfName(f);c&&(c.setStyle("fill",p?e.get("pageIconColor",!0):e.get("pageIconInactiveColor",!0)),c.cursor=p?"pointer":"default")});var n=a.childOfName("pageText"),o=e.get("pageFormatter"),s=i.pageIndex,l=s!=null?s+1:0,u=i.pageCount;n&&o&&n.setStyle("text",B(o)?o.replace("{current}",l==null?"":l+"").replace("{total}",u==null?"":u+""):o({current:l,total:u}))},t.prototype._getPageInfo=function(e){var i=e.get("scrollDataIndex",!0),a=this.getContentGroup(),n=this._containerGroup.__rectSize,o=e.getOrient().index,s=Um[o],l=Bm[o],u=this._findTargetItemIndex(i),f=a.children(),h=f[u],p=f.length,c=p?1:0,v={contentPosition:[a.x,a.y],pageCount:c,pageIndex:c-1,pagePrevDataIndex:null,pageNextDataIndex:null};if(!h)return v;var m=x(h);v.contentPosition[o]=-m.s;for(var d=u+1,g=m,y=m,_=null;d<=p;++d)_=x(f[d]),(!_&&y.e>g.s+n||_&&!S(_,g.s))&&(y.i>g.i?g=y:g=_,g&&(v.pageNextDataIndex==null&&(v.pageNextDataIndex=g.i),++v.pageCount)),y=_;for(var d=u-1,g=m,y=m,_=null;d>=-1;--d)_=x(f[d]),(!_||!S(y,_.s))&&g.i=w&&b.s<=w+n}},t.prototype._findTargetItemIndex=function(e){if(!this._showController)return 0;var i,a=this.getContentGroup(),n;return a.eachChild(function(o,s){var l=o.__legendDataIndex;n==null&&l!=null&&(n=s),l===e&&(i=s)}),i??n},t.type="legend.scroll",t})(Eh),TT=d2;function Vm(r){r.registerAction("legendScroll","legendscroll",function(t,e){var i=t.scrollDataIndex;i!=null&&e.eachComponent({mainType:"legend",subType:"scroll",query:t},function(a){a.setScrollDataIndex(i)})})}function CT(r){zt(Lh),r.registerComponentModel(bT),r.registerComponentView(TT),Vm(r)}function Fm(r){zt(Lh),zt(CT)}var m2=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.type="dataZoom.inside",t.defaultOption=Oi(Do.defaultOption,{disabled:!1,zoomLock:!1,zoomOnMouseWheel:!0,moveOnMouseMove:!0,moveOnMouseWheel:!1,preventDefaultMouseMove:!0}),t})(Do),DT=m2;var Gm=ft();function MT(r,t,e){Gm(r).coordSysRecordMap.each(function(i){var a=i.dataZoomInfoMap.get(t.uid);a&&(a.getRange=e)})}function AT(r,t){for(var e=Gm(r).coordSysRecordMap,i=e.keys(),a=0;ai[e+t]&&(t=s),a=a&&o.get("preventDefaultMouseMove",!0)}),{controlType:t,opt:{zoomOnMouseWheel:!0,moveOnMouseMove:!0,moveOnMouseWheel:!0,preventDefaultMouseMove:!!a}}}function LT(r){r.registerProcessor(r.PRIORITY.PROCESSOR.FILTER,function(t,e){var i=Gm(e),a=i.coordSysRecordMap||(i.coordSysRecordMap=Y());a.each(function(n){n.dataZoomInfoMap=null}),t.eachComponent({mainType:"dataZoom",subType:"inside"},function(n){var o=gh(n);T(o.infoList,function(s){var l=s.model.uid,u=a.get(l)||a.set(l,g2(e,s.model)),f=u.dataZoomInfoMap||(u.dataZoomInfoMap=Y());f.set(n.uid,{dzReferCoordSysInfo:s,model:n,getRange:null})})}),a.each(function(n){var o=n.controller,s,l=n.dataZoomInfoMap;if(l){var u=l.keys()[0];u!=null&&(s=l.get(u))}if(!s){ET(a,n);return}var f=x2(l);o.enable(f.controlType,f.opt),o.setPointerChecker(n.containsPoint),Ui(n,"dispatchAction",s.model.get("throttle",!0),"fixRate")})})}var b2=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type="dataZoom.inside",e}return t.prototype.render=function(e,i,a){if(r.prototype.render.apply(this,arguments),e.noTarget()){this._clear();return}this.range=e.getPercentRange(),MT(a,e,{pan:X(Hm.pan,this),zoom:X(Hm.zoom,this),scrollMove:X(Hm.scrollMove,this)})},t.prototype.dispose=function(){this._clear(),r.prototype.dispose.apply(this,arguments)},t.prototype._clear=function(){AT(this.api,this.dataZoomModel),this.range=null},t.type="dataZoom.inside",t})(yh),Hm={zoom:function(r,t,e,i){var a=this.range,n=a.slice(),o=r.axisModels[0];if(o){var s=Wm[t](null,[i.originX,i.originY],o,e,r),l=(s.signal>0?s.pixelStart+s.pixelLength-s.pixel:s.pixel-s.pixelStart)/s.pixelLength*(n[1]-n[0])+n[0],u=Math.max(1/i.scale,0);n[0]=(n[0]-l)*u+l,n[1]=(n[1]-l)*u+l;var f=this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();if(Qi(0,n,[0,100],0,f.minSpan,f.maxSpan),this.range=n,a[0]!==n[0]||a[1]!==n[1])return n}},pan:PT(function(r,t,e,i,a,n){var o=Wm[i]([n.oldX,n.oldY],[n.newX,n.newY],t,a,e);return o.signal*(r[1]-r[0])*o.pixel/o.pixelLength}),scrollMove:PT(function(r,t,e,i,a,n){var o=Wm[i]([0,0],[n.scrollDelta,n.scrollDelta],t,a,e);return o.signal*(r[1]-r[0])*n.scrollDelta})};function PT(r){return function(t,e,i,a){var n=this.range,o=n.slice(),s=t.axisModels[0];if(s){var l=r(o,s,t,e,i,a);if(Qi(l,o,[0,100],"all"),this.range=o,n[0]!==o[0]||n[1]!==o[1])return o}}}var Wm={grid:function(r,t,e,i,a){var n=e.axis,o={},s=a.model.coordinateSystem.getRect();return r=r||[0,0],n.dim==="x"?(o.pixel=t[0]-r[0],o.pixelLength=s.width,o.pixelStart=s.x,o.signal=n.inverse?1:-1):(o.pixel=t[1]-r[1],o.pixelLength=s.height,o.pixelStart=s.y,o.signal=n.inverse?-1:1),o},polar:function(r,t,e,i,a){var n=e.axis,o={},s=a.model.coordinateSystem,l=s.getRadiusAxis().getExtent(),u=s.getAngleAxis().getExtent();return r=r?s.pointToCoord(r):[0,0],t=s.pointToCoord(t),e.mainType==="radiusAxis"?(o.pixel=t[0]-r[0],o.pixelLength=l[1]-l[0],o.pixelStart=l[0],o.signal=n.inverse?1:-1):(o.pixel=t[1]-r[1],o.pixelLength=u[1]-u[0],o.pixelStart=u[0],o.signal=n.inverse?-1:1),o},singleAxis:function(r,t,e,i,a){var n=e.axis,o=a.model.coordinateSystem.getRect(),s={};return r=r||[0,0],n.orient==="horizontal"?(s.pixel=t[0]-r[0],s.pixelLength=o.width,s.pixelStart=o.x,s.signal=n.inverse?1:-1):(s.pixel=t[1]-r[1],s.pixelLength=o.height,s.pixelStart=o.y,s.signal=n.inverse?-1:1),s}},IT=b2;function RT(r){ml(r),r.registerComponentModel(DT),r.registerComponentView(IT),LT(r)}var w2=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e}return t.type="dataZoom.slider",t.layoutMode="box",t.defaultOption=Oi(Do.defaultOption,{show:!0,right:"ph",top:"ph",width:"ph",height:"ph",left:null,bottom:null,borderColor:"#d2dbee",borderRadius:3,backgroundColor:"rgba(47,69,84,0)",dataBackground:{lineStyle:{color:"#d2dbee",width:.5},areaStyle:{color:"#d2dbee",opacity:.2}},selectedDataBackground:{lineStyle:{color:"#8fb0f7",width:.5},areaStyle:{color:"#8fb0f7",opacity:.2}},fillerColor:"rgba(135,175,274,0.2)",handleIcon:"path://M-9.35,34.56V42m0-40V9.5m-2,0h4a2,2,0,0,1,2,2v21a2,2,0,0,1-2,2h-4a2,2,0,0,1-2-2v-21A2,2,0,0,1-11.35,9.5Z",handleSize:"100%",handleStyle:{color:"#fff",borderColor:"#ACB8D1"},moveHandleSize:7,moveHandleIcon:"path://M-320.9-50L-320.9-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-348-41-339-50-320.9-50z M-212.3-50L-212.3-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-239.4-41-230.4-50-212.3-50z M-103.7-50L-103.7-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-130.9-41-121.8-50-103.7-50z",moveHandleStyle:{color:"#D2DBEE",opacity:.7},showDetail:!0,showDataShadow:"auto",realtime:!0,zoomLock:!1,textStyle:{color:"#6E7079"},brushSelect:!0,brushStyle:{color:"rgba(135,175,274,0.15)"},emphasis:{handleLabel:{show:!0},handleStyle:{borderColor:"#8FB0F7"},moveHandleStyle:{color:"#8FB0F7"}}}),t})(Do),OT=w2;var wl=mt,NT=7,T2=1,Ym=30,C2=7,Tl="horizontal",kT="vertical",D2=5,M2=["line","bar","candlestick","scatter"],A2={easing:"cubicOut",duration:100,delay:0},E2=(function(r){P(t,r);function t(){var e=r!==null&&r.apply(this,arguments)||this;return e.type=t.type,e._displayables={},e}return t.prototype.init=function(e,i){this.api=i,this._onBrush=X(this._onBrush,this),this._onBrushEnd=X(this._onBrushEnd,this)},t.prototype.render=function(e,i,a,n){if(r.prototype.render.apply(this,arguments),Ui(this,"_dispatchZoomAction",e.get("throttle"),"fixRate"),this._orient=e.getOrient(),e.get("show")===!1){this.group.removeAll();return}if(e.noTarget()){this._clear(),this.group.removeAll();return}(!n||n.type!=="dataZoom"||n.from!==this.uid)&&this._buildView(),this._updateView()},t.prototype.dispose=function(){this._clear(),r.prototype.dispose.apply(this,arguments)},t.prototype._clear=function(){$a(this,"_dispatchZoomAction");var e=this.api.getZr();e.off("mousemove",this._onBrush),e.off("mouseup",this._onBrushEnd)},t.prototype._buildView=function(){var e=this.group;e.removeAll(),this._brushing=!1,this._displayables.brushRect=null,this._resetLocation(),this._resetInterval();var i=this._displayables.sliderGroup=new ut;this._renderBackground(),this._renderHandle(),this._renderDataShadow(),e.add(i),this._positionGroup()},t.prototype._resetLocation=function(){var e=this.dataZoomModel,i=this.api,a=e.get("brushSelect"),n=a?C2:0,o=this._findCoordRect(),s={width:i.getWidth(),height:i.getHeight()},l=this._orient===Tl?{right:s.width-o.x-o.width,top:s.height-Ym-NT-n,width:o.width,height:Ym}:{right:NT,top:o.y,width:Ym,height:o.height},u=Vr(e.option);T(["right","top","width","height"],function(h){u[h]==="ph"&&(u[h]=l[h])});var f=De(u,s);this._location={x:f.x,y:f.y},this._size=[f.width,f.height],this._orient===kT&&this._size.reverse()},t.prototype._positionGroup=function(){var e=this.group,i=this._location,a=this._orient,n=this.dataZoomModel.getFirstTargetAxisModel(),o=n&&n.get("inverse"),s=this._displayables.sliderGroup,l=(this._dataShadowInfo||{}).otherAxisInverse;s.attr(a===Tl&&!o?{scaleY:l?1:-1,scaleX:1}:a===Tl&&o?{scaleY:l?1:-1,scaleX:-1}:a===kT&&!o?{scaleY:l?-1:1,scaleX:1,rotation:Math.PI/2}:{scaleY:l?-1:1,scaleX:-1,rotation:Math.PI/2});var u=e.getBoundingRect([s]);e.x=i.x-u.x,e.y=i.y-u.y,e.markRedraw()},t.prototype._getViewExtent=function(){return[0,this._size[0]]},t.prototype._renderBackground=function(){var e=this.dataZoomModel,i=this._size,a=this._displayables.sliderGroup,n=e.get("brushSelect");a.add(new wl({silent:!0,shape:{x:0,y:0,width:i[0],height:i[1]},style:{fill:e.get("backgroundColor")},z2:-40}));var o=new wl({shape:{x:0,y:0,width:i[0],height:i[1]},style:{fill:"transparent"},z2:0,onclick:X(this._onClickPanel,this)}),s=this.api.getZr();n?(o.on("mousedown",this._onBrushStart,this),o.cursor="crosshair",s.on("mousemove",this._onBrush),s.on("mouseup",this._onBrushEnd)):(s.off("mousemove",this._onBrush),s.off("mouseup",this._onBrushEnd)),a.add(o)},t.prototype._renderDataShadow=function(){var e=this._dataShadowInfo=this._prepareDataShadowInfo();if(this._displayables.dataShadowSegs=[],!e)return;var i=this._size,a=this._shadowSize||[],n=e.series,o=n.getRawData(),s=n.getShadowDim&&n.getShadowDim(),l=s&&o.getDimensionInfo(s)?n.getShadowDim():e.otherDim;if(l==null)return;var u=this._shadowPolygonPts,f=this._shadowPolylinePts;if(o!==this._shadowData||l!==this._shadowDim||i[0]!==a[0]||i[1]!==a[1]){var h=o.getDataExtent(l),p=(h[1]-h[0])*.3;h=[h[0]-p,h[1]+p];var c=[0,i[1]],v=[0,i[0]],m=[[i[0],0],[0,0]],d=[],g=v[1]/(o.count()-1),y=0,_=Math.round(o.count()/i[0]),x;o.each([l],function(M,A){if(_>0&&A%_){y+=g;return}var D=M==null||isNaN(M)||M==="",E=D?0:Ct(M,h,c,!0);D&&!x&&A?(m.push([m[m.length-1][0],0]),d.push([d[d.length-1][0],0])):!D&&x&&(m.push([y,0]),d.push([y,0])),m.push([y,E]),d.push([y,E]),y+=g,x=D}),u=this._shadowPolygonPts=m,f=this._shadowPolylinePts=d}this._shadowData=o,this._shadowDim=l,this._shadowSize=[i[0],i[1]];var S=this.dataZoomModel;function b(M){var A=S.getModel(M?"selectedDataBackground":"dataBackground"),D=new ut,E=new xr({shape:{points:u},segmentIgnoreThreshold:1,style:A.getModel("areaStyle").getAreaStyle(),silent:!0,z2:-20}),L=new Ce({shape:{points:f},segmentIgnoreThreshold:1,style:A.getModel("lineStyle").getLineStyle(),silent:!0,z2:-19});return D.add(E),D.add(L),D}for(var w=0;w<3;w++){var C=b(w===1);this._displayables.sliderGroup.add(C),this._displayables.dataShadowSegs.push(C)}},t.prototype._prepareDataShadowInfo=function(){var e=this.dataZoomModel,i=e.get("showDataShadow");if(i!==!1){var a,n=this.ecModel;return e.eachTargetAxis(function(o,s){var l=e.getAxisProxy(o,s).getTargetSeriesModels();T(l,function(u){if(!a&&!(i!==!0&&at(M2,u.get("type"))<0)){var f=n.getComponent(vr(o),s).axis,h=L2(o),p,c=u.coordinateSystem;h!=null&&c.getOtherAxis&&(p=c.getOtherAxis(f).inverse),h=u.getData().mapDimension(h),a={thisAxis:f,series:u,thisDim:o,otherDim:h,otherAxisInverse:p}}},this)},this),a}},t.prototype._renderHandle=function(){var e=this.group,i=this._displayables,a=i.handles=[null,null],n=i.handleLabels=[null,null],o=this._displayables.sliderGroup,s=this._size,l=this.dataZoomModel,u=this.api,f=l.get("borderRadius")||0,h=l.get("brushSelect"),p=i.filler=new wl({silent:h,style:{fill:l.get("fillerColor")},textConfig:{position:"inside"}});o.add(p),o.add(new wl({silent:!0,subPixelOptimize:!0,shape:{x:0,y:0,width:s[0],height:s[1],r:f},style:{stroke:l.get("dataBackgroundColor")||l.get("borderColor"),lineWidth:T2,fill:"rgba(0,0,0,0)"}})),T([0,1],function(_){var x=l.get("handleIcon");!Vs[x]&&x.indexOf("path://")<0&&x.indexOf("image://")<0&&(x="path://"+x);var S=It(x,-1,0,2,2,null,!0);S.attr({cursor:zT(this._orient),draggable:!0,drift:X(this._onDragMove,this,_),ondragend:X(this._onDragEnd,this),onmouseover:X(this._showDataInfo,this,!0),onmouseout:X(this._showDataInfo,this,!1),z2:5});var b=S.getBoundingRect(),w=l.get("handleSize");this._handleHeight=j(w,this._size[1]),this._handleWidth=b.width/b.height*this._handleHeight,S.setStyle(l.getModel("handleStyle").getItemStyle()),S.style.strokeNoScale=!0,S.rectHover=!0,S.ensureState("emphasis").style=l.getModel(["emphasis","handleStyle"]).getItemStyle(),Ii(S);var C=l.get("handleColor");C!=null&&(S.style.fill=C),o.add(a[_]=S);var M=l.getModel("textStyle"),A=l.get("handleLabel")||{},D=A.show||!1;e.add(n[_]=new yt({silent:!0,invisible:!D,style:Wt(M,{x:0,y:0,text:"",verticalAlign:"middle",align:"center",fill:M.getTextColor(),font:M.getFont()}),z2:10}))},this);var c=p;if(h){var v=j(l.get("moveHandleSize"),s[1]),m=i.moveHandle=new mt({style:l.getModel("moveHandleStyle").getItemStyle(),silent:!0,shape:{r:[0,0,2,2],y:s[1]-.5,height:v}}),d=v*.8,g=i.moveHandleIcon=It(l.get("moveHandleIcon"),-d/2,-d/2,d,d,"#fff",!0);g.silent=!0,g.y=s[1]+v/2-.5,m.ensureState("emphasis").style=l.getModel(["emphasis","moveHandleStyle"]).getItemStyle();var y=Math.min(s[1]/2,Math.max(v,10));c=i.moveZone=new mt({invisible:!0,shape:{y:s[1]-y,height:v+y}}),c.on("mouseover",function(){u.enterEmphasis(m)}).on("mouseout",function(){u.leaveEmphasis(m)}),o.add(m),o.add(g),o.add(c)}c.attr({draggable:!0,cursor:zT(this._orient),drift:X(this._onDragMove,this,"all"),ondragstart:X(this._showDataInfo,this,!0),ondragend:X(this._onDragEnd,this),onmouseover:X(this._showDataInfo,this,!0),onmouseout:X(this._showDataInfo,this,!1)})},t.prototype._resetInterval=function(){var e=this._range=this.dataZoomModel.getPercentRange(),i=this._getViewExtent();this._handleEnds=[Ct(e[0],[0,100],i,!0),Ct(e[1],[0,100],i,!0)]},t.prototype._updateInterval=function(e,i){var a=this.dataZoomModel,n=this._handleEnds,o=this._getViewExtent(),s=a.findRepresentativeAxisProxy().getMinMaxSpan(),l=[0,100];Qi(i,n,o,a.get("zoomLock")?"all":e,s.minSpan!=null?Ct(s.minSpan,l,o,!0):null,s.maxSpan!=null?Ct(s.maxSpan,l,o,!0):null);var u=this._range,f=this._range=$r([Ct(n[0],o,l,!0),Ct(n[1],o,l,!0)]);return!u||u[0]!==f[0]||u[1]!==f[1]},t.prototype._updateView=function(e){var i=this._displayables,a=this._handleEnds,n=$r(a.slice()),o=this._size;T([0,1],function(c){var v=i.handles[c],m=this._handleHeight;v.attr({scaleX:m/2,scaleY:m/2,x:a[c]+(c?-1:1),y:o[1]/2-m/2})},this),i.filler.setShape({x:n[0],y:0,width:n[1]-n[0],height:o[1]});var s={x:n[0],width:n[1]-n[0]};i.moveHandle&&(i.moveHandle.setShape(s),i.moveZone.setShape(s),i.moveZone.getBoundingRect(),i.moveHandleIcon&&i.moveHandleIcon.attr("x",s.x+s.width/2));for(var l=i.dataShadowSegs,u=[0,n[0],n[1],o[0]],f=0;fi[0]||a[1]<0||a[1]>i[1])){var n=this._handleEnds,o=(n[0]+n[1])/2,s=this._updateInterval("all",a[0]-o);this._updateView(),s&&this._dispatchZoomAction(!1)}},t.prototype._onBrushStart=function(e){var i=e.offsetX,a=e.offsetY;this._brushStart=new st(i,a),this._brushing=!0,this._brushStartTime=+new Date},t.prototype._onBrushEnd=function(e){if(this._brushing){var i=this._displayables.brushRect;if(this._brushing=!1,!!i){i.attr("ignore",!0);var a=i.shape,n=+new Date;if(!(n-this._brushStartTime<200&&Math.abs(a.width)<5)){var o=this._getViewExtent(),s=[0,100];this._range=$r([Ct(a.x,o,s,!0),Ct(a.x+a.width,o,s,!0)]),this._handleEnds=[a.x,a.x+a.width],this._updateView(),this._dispatchZoomAction(!1)}}}},t.prototype._onBrush=function(e){this._brushing&&(Ar(e.event),this._updateBrushRect(e.offsetX,e.offsetY))},t.prototype._updateBrushRect=function(e,i){var a=this._displayables,n=this.dataZoomModel,o=a.brushRect;o||(o=a.brushRect=new wl({silent:!0,style:n.getModel("brushStyle").getItemStyle()}),a.sliderGroup.add(o)),o.attr("ignore",!1);var s=this._brushStart,l=this._displayables.sliderGroup,u=l.transformCoordToLocal(e,i),f=l.transformCoordToLocal(s.x,s.y),h=this._size;u[0]=Math.max(Math.min(h[0],u[0]),0),o.setShape({x:f[0],y:0,width:u[0]-f[0],height:h[1]})},t.prototype._dispatchZoomAction=function(e){var i=this._range;this.api.dispatchAction({type:"dataZoom",from:this.uid,dataZoomId:this.dataZoomModel.id,animation:e?A2:null,start:i[0],end:i[1]})},t.prototype._findCoordRect=function(){var e,i=gh(this.dataZoomModel).infoList;if(!e&&i.length){var a=i[0].model.coordinateSystem;e=a.getRect&&a.getRect()}if(!e){var n=this.api.getWidth(),o=this.api.getHeight();e={x:n*.2,y:o*.2,width:n*.6,height:o*.6}}return e},t.type="dataZoom.slider",t})(yh);function L2(r){var t={x:"y",y:"x",radius:"angle",angle:"radius"};return t[r]}function zT(r){return r==="vertical"?"ns-resize":"ew-resize"}var UT=E2;function BT(r){r.registerComponentModel(OT),r.registerComponentView(UT),ml(r)}function Zm(r){zt(RT),zt(BT)}var VT={value:"eq","<":"lt","<=":"lte",">":"gt",">=":"gte","=":"eq","!=":"ne","<>":"ne"},P2=(function(){function r(t){var e=this._condVal=B(t)?new RegExp(t):Fh(t)?t:null;if(e==null){var i="";dt(i)}}return r.prototype.evaluate=function(t){var e=typeof t;return B(e)?this._condVal.test(t):et(e)?this._condVal.test(t+""):!1},r})(),I2=(function(){function r(){}return r.prototype.evaluate=function(){return this.value},r})(),R2=(function(){function r(){}return r.prototype.evaluate=function(){for(var t=this.children,e=0;e=s)}}for(var h=this.__startIndex;h15)break}}I.prevElClipPaths&&g.restore()};if(y)if(y.length===0)C=d.__endIndex;else for(var A=c.dpr,D=0;D0&&t>a[0]){for(l=0;lt);l++);s=i[a[l]]}if(a.splice(l+1,0,t),i[t]=e,!e.virtual)if(s){var u=s.dom;u.nextSibling?o.insertBefore(e.dom,u.nextSibling):o.appendChild(e.dom)}else o.firstChild?o.insertBefore(e.dom,o.firstChild):o.appendChild(e.dom);e.painter||(e.painter=this)}},r.prototype.eachLayer=function(t,e){for(var i=this._zlevelList,a=0;a0?Ih:0),this._needsManuallyCompositing),f.__builtin__||ta("ZLevel "+u+" has been used by unkown layer "+f.id),f!==n&&(f.__used=!0,f.__startIndex!==l&&(f.__dirty=!0),f.__startIndex=l,f.incremental?f.__drawIndex=-1:f.__drawIndex=l,e(l),n=f),a.__dirty&Zt&&!a.__inHover&&(f.__dirty=!0,f.incremental&&f.__drawIndex<0&&(f.__drawIndex=l))}e(l),this.eachBuiltinLayer(function(h,p){!h.__used&&h.getElementCount()>0&&(h.__dirty=!0,h.__startIndex=h.__endIndex=h.__drawIndex=0),h.__dirty&&h.__drawIndex<0&&(h.__drawIndex=h.__startIndex)})},r.prototype.clear=function(){return this.eachBuiltinLayer(this._clearLayer),this},r.prototype._clearLayer=function(t){t.clear()},r.prototype.setBackgroundColor=function(t){this._backgroundColor=t,T(this._layers,function(e){e.setUnpainted()})},r.prototype.configLayer=function(t,e){if(e){var i=this._layerConfig;i[t]?it(i[t],e,!0):i[t]=e;for(var a=0;ae.length)&&(t=e.length);for(var r=0,i=Array(t);r=e.length?{done:!0}:{done:!1,value:e[a++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e,t,r){return(t=g(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(){return o=Object.assign?Object.assign.bind():function(e){for(var t=1;t1||1===i&&null!=(t=this.levelkeys[r[0]])&&t.encrypted)return!0}return!1}},{key:"programDateTime",get:function(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime},set:function(e){_(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}},{key:"ref",get:function(){return G(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}}])}(U),Y=function(e){function t(t,r,i,a,n){var s;(s=e.call(this,i)||this).fragOffset=0,s.duration=0,s.independent=!1,s.relurl=void 0,s.fragment=void 0,s.index=void 0,s.gap=!1,s.duration=t.decimalFloatingPoint("DURATION"),s.gap=t.bool("GAP"),s.independent=t.bool("INDEPENDENT"),s.relurl=t.enumeratedString("URI"),s.fragment=r,s.index=a;var o=t.enumeratedString("BYTERANGE");return o&&s.setByteRange(o,n),n&&(s.fragOffset=n.fragOffset+n.duration),s}return u(t,e),a(t,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo||this.fragment.type===N.SUBTITLE&&this.stats.loading.end>0)}}])}(U);function W(e,t){var r=Object.getPrototypeOf(e);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i||W(r,t)}}function j(e){switch(e.details){case w.FRAG_LOAD_TIMEOUT:case w.KEY_LOAD_TIMEOUT:case w.LEVEL_LOAD_TIMEOUT:case w.MANIFEST_LOAD_TIMEOUT:case w.AUDIO_TRACK_LOAD_TIMEOUT:case w.SUBTITLE_TRACK_LOAD_TIMEOUT:case w.ASSET_LIST_LOAD_TIMEOUT:return!0}return!1}function q(e){return e.details.startsWith("key")}function X(e){return q(e)&&!!e.frag&&!e.frag.decryptdata}function z(e,t){var r=j(t);return e.default[(r?"timeout":"error")+"Retry"]}function Q(e,t){var r="linear"===e.backoff?1:Math.pow(2,t);return Math.min(r*e.retryDelayMs,e.maxRetryDelayMs)}function $(e){return f(f({},e),{errorRetry:null,timeoutRetry:null})}function Z(e,t,r,i){if(!e)return!1;var a=null==i?void 0:i.code,n=t499)}(a)||!!r);return e.shouldRetry?e.shouldRetry(e,t,r,i,n):n}function J(e){return 0===e&&!1===navigator.onLine}function ee(e,t){return t>0&&e.loadError>0&&0!==e.loadErrorTime&&self.performance.now()-e.loadErrorTime>t}var te=function(){function e(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}var t=e.prototype;return t.sample=function(e,t){var r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e},t.getTotalWeight=function(){return this.totalWeight_},t.getEstimate=function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_},e}(),re=function(){function e(e,t,r,i){void 0===i&&(i=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new te(e),this.fast_=new te(t),this.defaultTTFB_=i,this.ttfb_=new te(e)}var t=e.prototype;return t.update=function(e,t){var r=this.slow_,i=this.fast_,a=this.ttfb_;r.halfLife!==e&&(this.slow_=new te(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new te(t,i.getEstimate(),i.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new te(e,a.getEstimate(),a.getTotalWeight()))},t.sample=function(e,t){if(!(t<=0)){var r=Math.min(this.minDelayMs_,t/1e5),i=8*t,a=Math.max(e,r)/1e3,n=i/a;this.fast_.sample(a,n),this.slow_.sample(a,n)}},t.sampleTTFB=function(e){var t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))},t.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},t.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},t.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},t.destroy=function(){},a(e,[{key:"defaultEstimate",get:function(){return this.defaultEstimate_}}])}(),ie=function(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var r="["+e+"]:";this.trace=ae,this.debug=t.debug.bind(null,r),this.log=t.log.bind(null,r),this.warn=t.warn.bind(null,r),this.info=t.info.bind(null,r),this.error=t.error.bind(null,r)},ae=function(){},ne={trace:ae,debug:ae,log:ae,warn:ae,info:ae,error:ae};function se(){return o({},ne)}function oe(e,t,r){return t[e]?t[e].bind(t):function(e,t){var r=self.console[e];return r?r.bind(self.console,(t?"["+t+"] ":"")+"["+e+"] >"):ae}(e,r)}var le=se();function ue(e,t,r){var i=se();if("object"==typeof console&&!0===e||"object"==typeof e){var a=["debug","log","info","warn","error"];a.forEach((function(t){i[t]=oe(t,e,r)}));try{i.log('Debug logs enabled for "'+t+'" in hls.js version 1.7.4')}catch(e){return se()}a.forEach((function(t){le[t]=oe(t,e)}))}else o(le,i);return i}var de,he,fe=le,ce=he?de:(he=1,de=void 0),ge=S(ce);function ve(e){if(void 0===e&&(e=!0),"undefined"!=typeof self)return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function me(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function pe(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3]}function ye(e,t){return me(e,t)&&pe(e,t+6)+10<=e.length-t}function Ee(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function Te(e,t){for(var r=t,i=0;me(e,t);)i+=10,i+=pe(e,t+6),Ee(e,t+10)&&(i+=10),t+=i;if(i>0)return e.subarray(r,r+i)}function Se(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=1/0),function(e,t,r,i){var a,n=m(a=e)?a:a.buffer,s=1;"BYTES_PER_ELEMENT"in i&&(s=i.BYTES_PER_ELEMENT);var o,l=(o=e)&&m(o.buffer)&&void 0!==o.byteLength&&void 0!==o.byteOffset?e.byteOffset:0,u=(l+e.byteLength)/s,d=(l+t)/s,h=Math.floor(Math.max(0,Math.min(d,u)));return new i(n,h,Math.floor(Math.min(h+Math.max(r,0),u))-h)}(e,t,r,Uint8Array)}function Le(e,t){void 0===t&&(t=!1);var r=t?e.indexOf(0):e.length,i=function(e,t){var r;void 0===t&&(t={}),r=m(e)?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength);var i=0,a=t.encoding;if(!a){var n=r.getUint8(0),s=r.getUint8(1);239==n&&187==s&&191==r.getUint8(2)?(a=T,i=3):254==n&&255==s?(a=y,i=2):255==n&&254==s?(a=E,i=2):a=T}if("undefined"!=typeof TextDecoder)return new TextDecoder(a).decode(r);for(var o,l=r.byteLength,u=a!==y,d="";i=194&&o<=223)if(i+1=128&&h<=191?(o=(31&o)<<6|63&h,i+=2):i++}else i++;else if(o>=224&&o<=239)if(i+2<=l-1){var f=r.getUint8(i+1),c=r.getUint8(i+2);f>=128&&f<=191&&c>=128&&c<=191?(o=(15&o)<<12|(63&f)<<6|63&c,i+=3):i++}else i++;else if(o>=240&&o<=244)if(i+3<=l-1){var g=r.getUint8(i+1),v=r.getUint8(i+2),S=r.getUint8(i+3);g>=128&&g<=191&&v>=128&&v<=191&&S>=128&&S<=191?(o=(7&o)<<18|(63&g)<<12|(63&v)<<6|63&S,i+=4):i++}else i++;else i++;break;case y:case p:case E:o=r.getUint16(i,u),i+=2}d+=String.fromCodePoint(o)}return d}(new DataView(e.buffer,e.byteOffset,r),{encoding:T});return t?i:i.replace(/\0/g,"")}function Re(e){var t={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(!(e.size<2))if(3===e.data[0]){var r=e.data.subarray(1).indexOf(0);if(-1!==r){var i=Le(Se(e.data,1,r)),a=e.data[2+r],n=e.data.subarray(3+r).indexOf(0);if(-1!==n){var s,o,l=Le(Se(e.data,3+r,n));return s="--\x3e"===i?Le(Se(e.data,4+r+n)):m(o=e.data.subarray(4+r+n))?o:0==o.byteOffset&&o.byteLength==o.buffer.byteLength?o.buffer:new Uint8Array(o).buffer,t.mimeType=i,t.pictureType=a,t.description=l,t.data=s,t}}}else console.log("Ignore frame with unrecognized character encoding")}function Ae(e){return"PRIV"===e.type?function(e){if(!(e.size<2)){var t=Le(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}}(e):"W"===e.type[0]?function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=Le(e.data.subarray(t),!0);t+=r.length+1;var i=Le(e.data.subarray(t));return{key:e.type,info:r,data:i}}var a=Le(e.data);return{key:e.type,info:"",data:a}}(e):"APIC"===e.type?Re(e):function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=e.data,i=Le(r.subarray(t),!0);t+=i.length+1;var a=Le(r.subarray(t));return{key:e.type,info:i,data:a}}var n=Le(e.data.subarray(1));return{key:e.type,info:"",data:n}}}(e)}function be(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=pe(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}var ke=10,De=10;function Ie(e){for(var t=0,r=[];me(e,t);){var i=pe(e,t+6);e[t+5]>>6&1&&(t+=ke);for(var a=(t+=ke)+i;t+De>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function We(e,t){var r=[];return t.length?(je(e,t,0,0,e.byteLength,r),r):r}function je(e,t,r,i,a,n){var s=t[r];if(4===(null==s?void 0:s.length))for(var o=s.charCodeAt(0),l=s.charCodeAt(1),u=s.charCodeAt(2),d=s.charCodeAt(3),h=t.length-1,f=i;f1?f+g:a;if(c&&e[f+4]===o&&e[f+5]===l&&e[f+6]===u&&e[f+7]===d){var m=Math.min(v,a);r===h?n.push(e.subarray(f+8,m)):je(e,t,r+1,f+8,m,n)}f=v}}function qe(e){var t=[],r=e[0],i=8,a=Ge(e,i);i+=4;var n=0,s=0;0===r?(n=Ge(e,i),s=Ge(e,i+4),i+=8):(n=Ve(e,i),s=Ve(e,i+8),i+=16),i+=2;var o=e.length+s,l=Ue(e,i);i+=2;for(var u=0;u>>31)return fe.warn("SIDX has hierarchical references (not supported)"),null;var c=Ge(e,d);d+=4,t.push({referenceSize:f,subsegmentDuration:c,info:{duration:c/a,start:o,end:o+f-1}}),o+=f,i=d+=4}return{earliestPresentationTime:n,timescale:a,version:r,referencesCount:l,references:t}}function Xe(e){for(var t=[],r=We(e,["moov","trak"]),i=0;i3&&(n+="."+Ze(u[1])+Ze(u[2])+Ze(u[3]),t=Qe("avc1"===l?"dva1":"dvav",i));break;case"mp4a":var d=We(r,[a])[0],h=We(d.subarray(28),["esds"])[0];if(h&&h.length>7){var f=4;if(3!==h[f++])break;f=$e(h,f),f+=2;var c=h[f++];if(128&c&&(f+=2),64&c&&(f+=h[f++]),4!==h[f++])break;f=$e(h,f);var g=h[f++];if(64!==g)break;if(n+="."+Ze(g),f+=12,5!==h[f++])break;f=$e(h,f);var v=h[f++],m=(248&v)>>3;31===m&&(m+=1+((7&v)<<3)+((224&h[f])>>5)),n+="."+m}break;case"hvc1":case"hev1":var p=We(i,["hvcC"])[0];if(p&&p.length>12){var y=p[1],E=["","A","B","C"][y>>6],T=31&y,S=Ge(p,2),L=(32&y)>>5?"H":"L",R=p[12],A=p.subarray(6,12);n+="."+E+T,n+="."+function(e){for(var t=0,r=0;r<32;r++)t|=(e>>r&1)<<31-r;return t>>>0}(S).toString(16).toUpperCase(),n+="."+L+R;for(var b="",k=A.length;k--;){var D=A[k];(D||b)&&(b="."+D.toString(16).toUpperCase()+b)}n+=b}t=Qe("hev1"==l?"dvhe":"dvh1",i);break;case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":n=Qe(n,i)||n;break;case"vp09":var I=We(i,["vpcC"])[0];if(I&&I.length>6){var _=I[4],C=I[5],P=I[6]>>4&15;n+="."+Je(_)+"."+Je(C)+"."+Je(P)}break;case"av01":var x=We(i,["av1C"])[0];if(x&&x.length>2){var w=x[1]>>>5,O=31&x[1],M=x[2]>>>7?"H":"M",F=(64&x[2])>>6,N=(32&x[2])>>5,B=2===w&&F?N?12:10:F?10:8,U=(16&x[2])>>4,G=(8&x[2])>>3,V=(4&x[2])>>2,H=3&x[2];n+="."+w+"."+Je(O)+M+"."+Je(B)+"."+U+"."+G+V+H+"."+Je(1)+"."+Je(1)+"."+Je(1)+".0",t=Qe("dav1",i)}}return{codec:n,encrypted:s,supplemental:t}}function Qe(e,t){var r=We(t,["dvvC"]),i=r.length?r[0]:We(t,["dvcC"])[0];if(i){var a=i[2]>>1&127,n=i[2]<<5&32|i[3]>>3&31;return e+"."+Je(a)+"."+Je(n)}}function $e(e,t){for(var r=t+5;128&e[t++]&&t0;n||(a=We(i,["encv"])),a.forEach((function(e){We(n?e.subarray(28):e.subarray(78),["sinf"]).forEach((function(e){var r=function(e){var t=We(e,["schm"])[0];if(t){var r=Oe(t.subarray(4,8));if("cbcs"===r||"cenc"===r){var i=We(e,["schi","tenc"])[0];if(i)return i}}}(e);r&&t(r,n)}))}))}}))}function tt(e){return"undefined"==typeof TextDecoder?Le(e):(Me||(Me=new TextDecoder("utf-8"))).decode(e).replace(/\0/g,"")}function rt(e,t,r,i,a){for(var n={},s=!1,o=function(e){for(var t=e.byteLength,r=[],i=0;i1?i+n:t;if(a&&109===e[i+4]&&111===e[i+5]&&111===e[i+6]&&102===e[i+7])for(var o=Math.min(s,t),l=i+8;l1?l+d:o;if(u&&116===e[l+4]&&114===e[l+5]&&97===e[l+6]&&102===e[l+7]){for(var f=Math.min(h,o),c=void 0,g=void 0,v=[],m=l+8;m1?m+y:f;if(p&&116===e[m+4]){var T=Math.min(E,f);102===e[m+5]&&104===e[m+6]&&100===e[m+7]?g||(g=e.subarray(m+8,T)):102===e[m+5]&&100===e[m+6]&&116===e[m+7]?c||(c=e.subarray(m+8,T)):114===e[m+5]&&117===e[m+6]&&110===e[m+7]&&v.push(e.subarray(m+8,T))}m=E}r.push({moofOffset:e.byteOffset+i,tfdt:c,tfhd:g,truns:v})}l=h}i=s}return r}(e),l=e.byteLength,u=0;up.ptsMax)&&(p.ptsMax=ee+x)}C+=x,P+=x}!P&&R&&(P+=R*M)}else{for(var te,re,ie=C,ae=j,ne=W,se=-1,oe=0,le=0,ue=null!=(te=null==a?void 0:a.timeOffset)?te:0,de=R/(null!=(re=null==a?void 0:a.timescale)?re:1),he=!0===(null==a?void 0:a.isHEVCFlavor),fe=he?2:1,ce=0;ce0){var pe=j;do{var ye=0===e[pe]?e[pe+1]<<16|e[pe+2]<<8|e[pe+3]:Ge(e,pe),Ee=e[pe+=4],Te=he?Ee>>1&63:31&Ee;(he?39===Te||40===Te:6===Te)&&st(e.subarray(pe,pe+ye),fe,ue,a.samples),pe+=ye}while(pel);Re++)le=Re+1,Le+=8;if(T&&(a.timeOffset=ue),-1!==se&&oe<=l&&void 0===p.keyFrameIndex&&(p.keyFrameIndex=se,p.keyFrameStart=ie+se*R),le){(!_(p.ptsMin)||iep.ptsMax)&&(p.ptsMax=Ae)}var be=R*M;C=ie+be,P+=be}}p.duration+=P,p.duration&&(s=!0)}}if(!s){for(var ke=1/0,De=0,Ie=We(e,["sidx"]),_e=0;_e>1&63;return 39===r||40===r}return 6==(31&t)}function st(e,t,r,i){var a=ot(e),n=0;n+=t;for(var s=0,o=0,l=0;n=a.length)break;s+=l=a[n++]}while(255===l);o=0;do{if(n>=a.length)break;o+=l=a[n++]}while(255===l);var u=a.length-n,d=n;if(ou){fe.error("Malformed SEI payload. "+o+" is too small, only "+u+" bytes left to parse.");break}if(4===s){if(181===a[d++]){var h=Ue(a,d);if(d+=2,49===h){var f=Ge(a,d);if(d+=4,1195456820===f){var c=a[d++];if(3===c){var g=a[d++],v=64&g,m=v?2+3*(31&g):0,p=new Uint8Array(m);if(v){p[0]=g;for(var y=1;y16){for(var E=[],T=0;T<16;T++){var S=a[d++].toString(16);E.push(1==S.length?"0"+S:S),3!==T&&5!==T&&7!==T&&9!==T||E.push("-")}for(var L=o-16,R=new Uint8Array(L),A=0;A4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(bt(e,"audio")||bt(e,"video")))return e;if(t){var r=t.split(",");if(r.length>1){if(e)for(var i=r.length;i--;)if(r[i].substring(0,4)===e.substring(0,4))return r[i];return r[0]}}return t||e}function bt(e,t){return vt(e,t)&&pt(e,t)}function kt(e){var t=ve(e)||{isTypeSupported:function(){return!1}};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:!1}}function Dt(e,t,r){var i=encodeURIComponent(t),a=i+"="+encodeURIComponent(r),n=!1,s=[];e.search.substring(1).split("&").forEach((function(e){e===i||e.startsWith(i+"=")?n||(s.push(a),n=!0):e&&s.push(e)})),n||s.push(a),e.search=s.join("&")}var It=["NONE","TYPE-0","TYPE-1",null],_t=["SDR","PQ","HLG"],Ct="",Pt="YES",xt="v2";function wt(e){var t=e.canSkipUntil,r=e.canSkipDateRanges,i=e.age;return t&&i-1&&v!==g,p=!!e||m;if(p||!l.paused&&l.playbackRate&&l.readyState){var y=s.mainForwardBufferInfo;if(p||null!==y){var E=r.bwEstimator.getEstimateTTFB(),T=Math.abs(l.playbackRate);if(!(f<=Math.max(E,h/(2*T)*1e3))){var S=y?y.len/T:0,L=d.loading.first?d.loading.first-d.loading.start:-1,R=d.loaded&&L>-1,A=r.getBwEstimate(),b=s.levels,k=b[g],D=Math.max(d.loaded,Math.round(h*(a.bitrate||k.averageBitrate)/8)),I=R?f-L:f;I<1&&R&&(I=Math.min(f,8*d.loaded/A));var C=R?1e3*d.loaded/I:0,P=E/1e3,x=C?(D-d.loaded)/C:8*D/A+P;if(!(x<=S)){var w,M=C?8*C:A,F=!0===(null==(t=(null==e?void 0:e.details)||s.latestLevelDetails)?void 0:t.live),N=s.config.abrBandWidthUpFactor,B=Number.POSITIVE_INFINITY;for(w=g-1;w>c;w--){var U=b[w].maxBitrate,G=!b[w].details||F;if((B=r.getTimeToLoadFrag(P,M,h*U,G))=x||B>10*h)){R?r.bwEstimator.sample(f-Math.min(E,L),d.loaded):r.bwEstimator.sampleTTFB(f);var V=b[w].maxBitrate;r.getBwEstimate()*N>V&&(r.firstAutoFloor=Math.min(w,s.firstLevel),r.resetEstimator(V));var H=r.findBestLevel(V,c,w,0,S,1,1);H>-1&&(w=H),r.warn("Fragment "+a.sn+(n?" part "+n.index:"")+" of level "+g+" is loading too slowly;\n Fragment duration: "+a.duration.toFixed(3)+"\n Time to underbuffer: "+S.toFixed(3)+" s\n Estimated load time for current fragment: "+x.toFixed(3)+" s\n Estimated load time for down switch fragment: "+B.toFixed(3)+" s\n TTFB estimate: "+(0|L)+" ms\n Current BW estimate: "+(_(A)?0|A:"Unknown")+" bps\n New BW estimate: "+(0|r.getBwEstimate())+" bps\n Switching to level "+w+" @ "+(0|V)+" bps"),s.nextLoadLevel=s.nextAutoLevel=w,r.clearTimer();var K=function(){r.clearTimer();var e=r.hls;if(r.fragCurrent===a&&e.loadLevel===w&&w>0){var t=r.getStarvationDelay();if(r.warn("Aborting inflight request "+(w>0?"and switching down":"")+"\n Fragment duration: "+a.duration.toFixed(3)+" s\n Time to underbuffer: "+t.toFixed(3)+" s"),a.abortRequests(),r.fragCurrent=r.partCurrent=null,w>c){var i=r.findBestLevel(e.levels[c].bitrate,c,w,0,t,1,1);-1===i&&(i=c),e.nextLoadLevel=e.nextAutoLevel=i,r.firstAutoFloor=Math.min(i,e.firstLevel),r.resetEstimator(e.levels[i].bitrate)}}};m||x>2*B?K():r.timer=self.setInterval(K,1e3*B),s.trigger(O.FRAG_LOAD_EMERGENCY_ABORTED,{frag:a,part:n,stats:d})}}}}}}}}},r.hls=t,r.bwEstimator=r.initEstimator(),r.registerListeners(),r}u(t,e);var r=t.prototype;return r.resetEstimator=function(e){this.hls&&(e&&(this.log("setting initial bwe to "+e),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator())},r.initEstimator=function(){var e=this.hls.config;return new re(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)},r.registerListeners=function(){var e=this.hls;e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.FRAG_LOADING,this.onFragLoading,this),e.on(O.FRAG_LOADED,this.onFragLoaded,this),e.on(O.FRAG_BUFFERED,this.onFragBuffered,this),e.on(O.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(O.LEVEL_LOADED,this.onLevelLoaded,this),e.on(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(O.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(O.ERROR,this.onError,this)},r.unregisterListeners=function(){var e=this.hls;e&&(e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.FRAG_LOADING,this.onFragLoading,this),e.off(O.FRAG_LOADED,this.onFragLoaded,this),e.off(O.FRAG_BUFFERED,this.onFragBuffered,this),e.off(O.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(O.LEVEL_LOADED,this.onLevelLoaded,this),e.off(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(O.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(O.ERROR,this.onError,this))},r.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.audioTracksByGroup=this.codecTiers=this.fragCurrent=this.partCurrent=null},r.onManifestLoading=function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.firstAutoFloor=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},r.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},r.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},r.onFragLoading=function(e,t){var r,i=t.frag;this.ignoreFragment(i)||(i.bitrateTest||(this.fragCurrent=i,this.partCurrent=null!=(r=t.part)?r:null),this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100))},r.onLevelSwitching=function(e,t){this.clearTimer()},r.onError=function(e,t){if(!t.fatal)switch(t.details){case w.BUFFER_ADD_CODEC_ERROR:case w.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case w.FRAG_LOAD_TIMEOUT:var r=t.frag,i=this.fragCurrent,a=this.partCurrent;if(r&&H(r,i)){var n=performance.now(),s=a?a.stats:r.stats,o=n-s.loading.start,l=s.loading.first?s.loading.first-s.loading.start:-1;if(s.loaded&&l>-1){var u=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(o-Math.min(u,l),s.loaded)}else this.bwEstimator.sampleTTFB(o)}}},r.getTimeToLoadFrag=function(e,t,r,i){return e+r/t+(i?e+this.lastLevelLoadSec:0)},r.onLevelLoaded=function(e,t){var r=this.hls.config,i=t.stats.loading,a=i.end-i.first;_(a)&&(this.lastLevelLoadSec=a/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)},r.onFragLoaded=function(e,t){var r,i=t.frag,a=t.part,n=a?a.stats:i.stats;if(i.type===N.MAIN&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(i)){if(this.clearTimer(),i.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,null!=(r=this.hls)&&r.config.abrMaxWithRealBitrate){var s=a?a.duration:i.duration,o=this.hls.levels[i.level],l=(o.loaded?o.loaded.bytes:0)+n.loaded,u=(o.loaded?o.loaded.duration:0)+s;o.loaded={bytes:l,duration:u},o.realBitrate=Math.round(8*l/u)}if(i.bitrateTest){var d={stats:n,frag:i,part:a,id:i.type};this.onFragBuffered(O.FRAG_BUFFERED,d),i.bitrateTest=!1}else this.lastLoadedFragLevel=i.level}},r.onFragBuffered=function(e,t){var r=t.frag,i=t.part,a=null!=i&&i.stats.loaded?i.stats:r.stats;if(!a.aborted&&!this.ignoreFragment(r)){var n=((r.bitrate||0)>=1e5?a.parsing.end:a.loading.end)-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(n,a.loaded),a.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=n/1e3:(this.bitrateTestDelay=0,this.firstAutoFloor>-1&&this.bwEstimator.canEstimate()&&(this.firstAutoFloor=-1))}},r.ignoreFragment=function(e){return e.type!==N.MAIN||"initSegment"===e.sn},r.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},r.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},r.getNextABRAutoLevel=function(){var e=this.fragCurrent,t=this.partCurrent,r=this.hls;if(!r)return-1;if(r.levels.length<=1)return r.loadLevel;var i=r.maxAutoLevel,a=r.config,n=r.minAutoLevel,s=t?t.duration:e?e.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay(),u=a.abrBandWidthFactor,d=a.abrBandWidthUpFactor;if(l){var h=this.findBestLevel(o,n,i,l,0,u,d);if(h>=0)return this.rebufferNotice=-1,h}var f=s?Math.min(s,a.maxStarvationDelay):a.maxStarvationDelay;if(!l){var c=this.bitrateTestDelay;c&&(f=(s?Math.min(s,a.maxLoadingDelay):a.maxLoadingDelay)-c,this.info("bitrate test took "+Math.round(1e3*c)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*f)+" ms"),u=d=1)}var g=this.findBestLevel(o,n,i,l,f,u,d);if(this.rebufferNotice!==g&&(this.rebufferNotice=g,this.info((l?"rebuffering expected":"buffer is empty")+", optimal quality level "+g)),g>-1)return g;var v=r.levels[n],m=r.loadLevelObj;return m&&(null==v?void 0:v.bitrate)0),f=Math.min(f,t.minHeight),c=Math.min(c,t.minFramerate),g=Math.min(g,t.minBitrate),T.filter((function(e){return t.videoRanges[e]>0})).length>0&&(h=!0)},L=n.length;L--;)S();f=_(f)?f:0,c=_(c)?c:0;var R=Math.max(1080,f),A=Math.max(30,c);g=_(g)?g:r,r=Math.max(g,r),h||(t=void 0);var b=n.length>1;return{codecSet:n.reduce((function(t,i){var a=e[i];if(i===t)return t;if(p=h?T.filter((function(e){return a.videoRanges[e]>0})):[],b){if(a.minBitrate>r)return Ut(i,"min bitrate of "+a.minBitrate+" > current estimate of "+r),t;if(!a.hasDefaultAudio)return Ut(i,"no renditions with default or auto-select sound found"),t;if(o&&i.indexOf(o.substring(0,4))%5!=0)return Ut(i,'audio codec preference "'+o+'" not found'),t;if(s&&!u){if(!a.channels[s])return Ut(i,"no renditions with "+s+" channel sound found (channels options: "+Object.keys(a.channels)+")"),t}else if((!o||u)&&d&&0===a.channels[2])return Ut(i,"no renditions with stereo sound found"),t;if(a.minHeight>R)return Ut(i,"min resolution of "+a.minHeight+" > maximum of "+R),t;if(a.minFramerate>A)return Ut(i,"min framerate of "+a.minFramerate+" > maximum of "+A),t;if(!p.some((function(e){return a.videoRanges[e]>0})))return Ut(i,"no variants with VIDEO-RANGE of "+Bt(p)+" found"),t;if(l&&i.indexOf(l.substring(0,4))%5!=0)return Ut(i,'video codec preference "'+l+'" not found'),t;if(a.maxScore=Tt(t)||a.fragmentError>e[t].fragmentError)?t:(v=a.minIndex,m=a.maxScore,i)}),void 0),videoRanges:p,preferHDR:E,minFramerate:c,minBitrate:g,minIndex:v}}(I,R,e,b,k),P=C.codecSet,x=C.videoRanges,w=C.minFramerate,O=C.minBitrate,M=C.minIndex,F=C.preferHDR;D=M,E=P,R=F?x[x.length-1]:x[0],A=w,e=Math.max(e,O),this.log("picked start tier "+Bt(C))}else E=null==T?void 0:T.codecSet,R=null==T?void 0:T.videoRange;for(var N,B=h?h.duration:d?d.duration:0,U=this.bwEstimator.getEstimateTTFB()/1e3,G=[],V=function(){var t,l=g[H],d=H>c;if(!l)return 0;if((E&&l.codecSet!==E||R&&l.videoRange!==R||d&&A>l.frameRate||!d&&A>0&&A=2*B&&0===a?l.averageBitrate:l.maxBitrate,k=o.getTimeToLoadFrag(U,v,b*T,!p||p.live);if(v>=b&&(H===u||0===l.loadError&&0===l.fragmentError||ee(l,y.errorPenaltyExpireMs))&&(k<=U||!_(k)||S&&!o.bitrateTestDelay||k"+H+" adjustedbw("+Math.round(v)+")-bitrate="+Math.round(v-b)+" ttfb:"+U.toFixed(1)+" avgDuration:"+T.toFixed(1)+" maxFetchDuration:"+f.toFixed(1)+" fetchDuration:"+k.toFixed(1)+" firstSelection:"+L+" codecSet:"+l.codecSet+" videoRange:"+l.videoRange+" hls.loadLevel:"+m)),L&&(o.firstSelection=H),{v:H}}},H=r;H>=t;H--)if(0!==(N=V())&&N)return N.v;return-1},r.deriveNextAutoLevel=function(e){if(!this.hls)return-1;var t=this.hls,r=t.maxAutoLevel,i=t.minAutoLevel;return Math.min(Math.max(e,i),r)},a(t,[{key:"firstAutoLevel",get:function(){var e=this.hls;if(!e)return 0;var t=e.maxAutoLevel,r=e.minAutoLevel,i=this.getBwEstimate(),a=this.getStarvationDelay(),n=e.config.maxStarvationDelay,s=this.findBestLevel(i,r,t,a/2,n,1,1);if(s>-1)return s;var o=e.firstLevel,l=-1===this.firstAutoFloor?1/0:this.firstAutoFloor,u=Math.min(Math.max(o,r),t,l);return this.warn("Could not find best starting auto level. Defaulting to first in playlist "+o+" clamped to "+u),u}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){if(!this.hls)return-1;var e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&r&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;var i=t&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var a=this.hls.levels;if(a.length>Math.max(e,i)&&a[e].loadError<=a[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i},set:function(e){var t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}}])}(ie),Kt=function(){function e(e){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=e}var t=e.prototype;return t.destroy=function(){this.tracks=this.queues=null},t.append=function(e,t,r){if(null!==this.queues&&null!==this.tracks){var i=this.queues[t];i.push(e),1!==i.length||r||this.executeNext(t)}},t.appendBlocker=function(e){var t=this;return new Promise((function(r){var i={label:"async-blocker",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.append(i,e)}))},t.prependBlocker=function(e){var t=this;return new Promise((function(r){if(t.queues){var i={label:"async-blocker-prepend",execute:r,onStart:function(){},onComplete:function(){},onError:function(){}};t.queues[e].unshift(i)}}))},t.removeBlockers=function(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach((function(e){var t,r=null==(t=e[0])?void 0:t.label;"async-blocker"===r||"async-blocker-prepend"===r?(e[0].execute(),e.splice(0,1)):"block-audio"===r&&e.splice(0,1)}))},t.insertNext=function(e,t){var r;null!==this.queues&&(r=this.queues[t]).splice.apply(r,[1,0].concat(e))},t.unblockAudio=function(){var e;null!==this.queues&&"block-audio"===(null==(e=this.current("audio"))?void 0:e.label)&&this.shiftAndExecuteNext("audio")},t.audioBlocking=function(){return null!==this.queues&&this.queues.audio.some((function(e){return"block-audio"===e.label}))},t.executeNext=function(e){if(null!==this.queues&&null!==this.tracks){var t=this.queues[e];if(t.length){var r=t[0];try{r.execute()}catch(t){var i;if(r.onError(t),null===this.queues||null===this.tracks)return;var a=null==(i=this.tracks[e])?void 0:i.buffer;null!=a&&a.updating||this.shiftAndExecuteNext(e)}}}},t.shiftAndExecuteNext=function(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))},t.current=function(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null},t.toString=function(){var e=this.queues,t=this.tracks;return null===e||null===t?"":"\n"+this.list("video")+"\n"+this.list("audio")+"\n"+this.list("audiovideo")+"}"},t.list=function(e){var t,r;return null!=(t=this.queues)&&t[e]||null!=(r=this.tracks)&&r[e]?e+": ("+this.listSbInfo(e)+") "+this.listOps(e):""},t.listSbInfo=function(e){var t,r=null==(t=this.tracks)?void 0:t[e],i=null==r?void 0:r.buffer;return i?"SourceBuffer"+(i.updating?" updating":"")+(r.ended?" ended":"")+(r.ending?" ending":""):"none"},t.listOps=function(e){var t;return(null==(t=this.queues)?void 0:t[e].map((function(e){return e.label})).join(", "))||""},e}(),Yt=function(e,t){for(var r=0,i=e.length-1,a=null,n=null;r<=i;){var s=t(n=e[a=(r+i)/2|0]);if(s>0)r=a+1;else{if(!(s<0))return n;i=a-1}}return null};function Wt(e,t,r,i,a){void 0===r&&(r=0),void 0===i&&(i=0),void 0===a&&(a=.005);var n=null;if(e){n=t[1+e.sn-t[0].sn]||null;var s=e.endDTS-r;s>0&&s<15e-7&&(r+=15e-7),n&&e.level!==n.level&&n.end<=e.end&&(n=t[2+e.sn-t[0].sn]||null)}else 0===r&&0===t[0].start&&(n=t[0]);if(n&&((!e||e.level===n.level)&&0===jt(r,i,n)||function(e,t,r){if(0===(null==t?void 0:t.start)&&t.level0){var i=t.tagList.reduce((function(e,t){return"INF"===t[0]&&(e+=parseFloat(t[1])),e}),r);return e.start<=i}return!1}(n,e,Math.min(a,i))))return n;var o=Yt(t,jt.bind(null,r,i));return!o||o===e&&n?n:o}function jt(e,t,r){if(void 0===e&&(e=0),void 0===t&&(t=0),r.start<=e&&r.start+r.duration>e)return 0;var i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function qt(e,t,r){var i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}var Xt=0,zt=2,Qt=3,$t=5,Zt=0,Jt=1,er=2,tr=4,rr=8,ir=16,ar=function(e){function t(t){var r;return(r=e.call(this,"error-controller",t.logger)||this).hls=void 0,r.playlistError=0,r.hls=t,r.registerListeners(),r}u(t,e);var r=t.prototype;return r.registerListeners=function(){var e=this.hls;e.on(O.ERROR,this.onError,this),e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.LEVEL_UPDATED,this.onLevelUpdated,this)},r.unregisterListeners=function(){var e=this.hls;e&&(e.off(O.ERROR,this.onError,this),e.off(O.ERROR,this.onErrorOut,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.LEVEL_UPDATED,this.onLevelUpdated,this))},r.destroy=function(){this.unregisterListeners(),this.hls=null},r.startLoad=function(e){},r.stopLoad=function(){this.playlistError=0},r.getVariantLevelIndex=function(e){return(null==e?void 0:e.type)===N.MAIN?e.level:this.getVariantIndex()},r.getVariantIndex=function(){var e,t=this.hls,r=t.currentLevel;return null!=(e=t.loadLevelObj)&&e.details||-1===r?t.loadLevel:r},r.variantHasKey=function(e,t){if(e){var r;if(null!=(r=e.details)&&r.hasKey(t))return!0;var i=e.audioGroups;if(i)return this.hls.allAudioTracks.filter((function(e){return i.indexOf(e.groupId)>=0})).some((function(e){var r;return null==(r=e.details)?void 0:r.hasKey(t)}))}return!1},r.onManifestLoading=function(){this.playlistError=0},r.onLevelUpdated=function(){this.playlistError=0},r.onError=function(e,t){var r;if(!t.fatal){var i=this.hls,a=t.context;switch(t.details){case w.FRAG_LOAD_ERROR:case w.FRAG_LOAD_TIMEOUT:case w.KEY_LOAD_ERROR:case w.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case w.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction=or());case w.FRAG_GAP:case w.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=zt);case w.PLAYLIST_UNCHANGED_ERROR:case w.LEVEL_EMPTY_ERROR:case w.LEVEL_PARSING_ERROR:var n,s=t.parent===N.MAIN?t.level:i.loadLevel;return void(t.details===w.LEVEL_EMPTY_ERROR&&null!=(n=t.context)&&null!=(n=n.levelDetails)&&n.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,s)));case w.LEVEL_LOAD_ERROR:case w.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case w.AUDIO_TRACK_LOAD_ERROR:case w.AUDIO_TRACK_LOAD_TIMEOUT:case w.SUBTITLE_LOAD_ERROR:case w.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var o=i.loadLevelObj;if(o&&(a.type===F.AUDIO_TRACK&&o.hasAudioGroup(a.groupId)||a.type===F.SUBTITLE_TRACK&&o.hasSubtitleGroup(a.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,i.loadLevel),t.errorAction.action=zt,void(t.errorAction.flags=Jt)}return;case w.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(t.errorAction={action:zt,flags:er});case w.KEY_SYSTEM_SESSION_UPDATE_FAILED:case w.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case w.KEY_SYSTEM_NO_SESSION:return void(t.errorAction={action:zt,flags:tr});case w.BUFFER_ADD_CODEC_ERROR:case w.REMUX_ALLOC_ERROR:case w.BUFFER_APPEND_ERROR:return void(t.errorAction||(t.errorAction=this.getLevelSwitchAction(t,t.level)));case w.MEDIA_SOURCE_REQUIRES_RESET:return t.errorAction||(t.errorAction=this.getLevelSwitchAction(t,t.level)),void(t.errorAction.flags|=ir|rr);case w.INTERNAL_EXCEPTION:case w.BUFFER_APPENDING_ERROR:case w.BUFFER_APPEND_NO_PROGRESS:case w.BUFFER_FULL_ERROR:case w.LEVEL_SWITCH_ERROR:case w.BUFFER_STALLED_ERROR:case w.BUFFER_SEEK_OVER_HOLE:case w.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=or())}t.type===x.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=or())}},r.getPlaylistRetryOrSwitchAction=function(e,t){var r=z(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(Z(r,i,j(e),e.response))return{action:$t,flags:Zt,retryConfig:r,retryCount:i};var a=this.getLevelSwitchAction(e,t);return r&&(a.retryConfig=r,a.retryCount=i),a},r.getFragRetryOrSwitchAction=function(e){var t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],a=t.config,n=a.fragLoadPolicy,s=a.keyLoadPolicy,o=z(q(e)?s:n,e),l=t.levels.reduce((function(e,t){return e+t.fragmentError}),0);if(i&&(e.details!==w.FRAG_GAP&&i.fragmentError++,!X(e)&&Z(o,l,j(e),e.response)))return{action:$t,flags:Zt,retryConfig:o,retryCount:l};var u=this.getLevelSwitchAction(e,r);return o&&(u.retryConfig=o,u.retryCount=l),u},r.getLevelSwitchAction=function(e,t){var r=this.hls;null==t&&(t=r.loadLevel);var i=this.hls.levels[t];if(i){var a,n,s=e.details;i.loadError++,i.loadErrorTime=self.performance.now(),s===w.BUFFER_APPEND_ERROR&&i.fragmentError++;var o=-1,l=r.levels,u=r.loadLevel,d=r.minAutoLevel,h=r.maxAutoLevel;r.autoLevelEnabled||r.config.preserveManualLevelOnError||(r.loadLevel=-1);for(var f,c=null==(a=e.frag)?void 0:a.type,g=(c===N.AUDIO&&s===w.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&nr(e))&&l.some((function(e){var t=e.audioCodec;return i.audioCodec!==t})),v="video"===e.sourceBufferName&&nr(e)&&l.some((function(e){var t=e.codecSet,r=e.audioCodec;return i.codecSet!==t&&i.audioCodec===r})),m=null!=(n=e.context)?n:{},p=m.type,y=m.groupId,E=function(){var t=(T+u)%l.length;if(t!==u&&t>=d&&t<=h&&(0===l[t].loadError||ee(l[t],r.config.errorPenaltyExpireMs))){var a,n,f=l[t];if(s===w.FRAG_GAP&&c===N.MAIN&&e.frag){var m=l[t].details;if(m){var E=Wt(e.frag,m.fragments,e.frag.start);if(null!=E&&E.gap)return 0}}else{if(p===F.AUDIO_TRACK&&f.hasAudioGroup(y)||p===F.SUBTITLE_TRACK&&f.hasSubtitleGroup(y))return 0;if(c===N.AUDIO&&null!=(a=i.audioGroups)&&a.some((function(e){return f.hasAudioGroup(e)}))||c===N.SUBTITLE&&null!=(n=i.subtitleGroups)&&n.some((function(e){return f.hasSubtitleGroup(e)}))||g&&i.audioCodec===f.audioCodec||v&&i.codecSet===f.codecSet||!g&&i.audioCodec!==f.audioCodec)return 0}return o=t,1}},T=l.length;T--&&(0===(f=E())||1!==f););if(o>-1&&r.loadLevel!==o)return e.levelRetry=!0,this.playlistError=0,{action:zt,flags:Zt,nextAutoLevel:o}}return{action:zt,flags:Jt}},r.onErrorOut=function(e,t){var r,i;switch(null==(r=t.errorAction)?void 0:r.action){case Xt:break;case zt:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===w.FRAG_GAP||t.details===w.PLAYLIST_UNCHANGED_ERROR||sr(t)||(t.fatal=!0)}((null==(i=t.errorAction)?void 0:i.flags)||0)&ir&&this.hls.recoverMediaError(),t.fatal&&this.hls.stopLoad()},r.sendAlternateToPenaltyBox=function(e){var t=this.hls,r=e.errorAction;if(r){var i=r.nextAutoLevel;if(r.flags===Zt)this.switchLevel(e,i);else if(r.flags&rr)for(var a=this.hls.levels,n=a.length;n--;)"SDR"!==a[n].videoRange?(a[n].fragmentError++,a[n].loadError++):void 0===i&&(i=n);else if(r.flags&er){var s=this.getVariantLevelIndex(e.frag),o=t.levels[s],l=null==o?void 0:o.attrs["HDCP-LEVEL"];r.hdcpLevel=l;var u="NONE"===l;l&&!u?(t.maxHdcpLevel=It[It.indexOf(l)-1],r.resolved=!0,this.warn('Restricting playback to HDCP-LEVEL of "'+t.maxHdcpLevel+'" or lower')):(u&&this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE"),r.flags|=tr)}if(r.flags&tr){var d=e.decryptdata;if(d){for(var h=this.hls.levels,f=h.length,c=f;c--;){var g,v;this.variantHasKey(h[c],d)&&(this.log("Banned key found in level "+c+" ("+h[c].bitrate+'bps) or audio group "'+(null==(g=h[c].audioGroups)?void 0:g.join(","))+'" ('+(null==(v=e.frag)?void 0:v.type)+" fragment) "+xe(d.keyId||[])),h[c].fragmentError++,h[c].loadError++,this.log("Removing level "+c+" with key error ("+e.error+")"),this.hls.removeLevel(c))}var m=e.frag;if(this.hls.levels.lengthe.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=0:this.misses=e.misses+1},t.hasKey=function(e){return this.encryptedFragments.some((function(t){var r=t.decryptdata;return r||(t.setKeyFormat(e.keyFormat),r=t.decryptdata),!!r&&e.matches(r)}))},a(e,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&_(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}},{key:"fragmentStart",get:function(){return this.fragments.length?this.fragments[0].start:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"maxPartIndex",get:function(){var e=this.partList;if(e){var t=this.lastPartIndex;if(-1!==t){for(var r=e.length;r--;)if(e[r].index>t)return e[r].index;return t}}return 0}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}},{key:"expired",get:function(){if(this.live&&void 0!==this.advancedDateTime&&this.misses<3){var e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}},{key:"partsExpired",get:function(){return!!(this.live&&this.partTarget&&void 0!==this.advancedDateTime&&this.misses<3)&&this.age>1.5*(this.partHoldBack||3*this.partTarget)}}])}(),ur={length:0,start:function(){return 0},end:function(){return 0}},dr=function(){function e(){}return e.isBuffered=function(t,r){if(t)for(var i=e.getBuffered(t),a=i.length;a--;)if(r>=i.start(a)&&r<=i.end(a))return!0;return!1},e.bufferedRanges=function(t){if(t){var r=e.getBuffered(t);return e.timeRangesToArray(r)}return[]},e.timeRangesToArray=function(e){for(var t=[],r=0;r1&&e.sort((function(e,t){return e.start-t.start||t.end-e.end}));var i=-1,a=[];if(r)for(var n=0;n=e[n].start&&t<=e[n].end&&(i=n);var s=a.length;if(s){var o=a[s-1].end;e[n].start-oo&&(a[s-1].end=e[n].end):a.push(e[n])}else a.push(e[n])}else a=e;for(var l,u=0,d=t,h=t,f=0;f=c&&t<=g&&(i=f),t+r>=c&&t "+t+") - detaching media"),void i.hls.detachMedia()}var r=i.media.error,a=i,n=a.appendError,s=a.appendErrors,l=!1;!n&&r&&(l=Math.max(++s.audio,++s.video,++s.audiovideo)>=i.hls.config.appendErrorMaxRetry);var u=new Error("MediaSource closed while media attached"+Sr(l,r));i.warn(u),i.hls.trigger(O.ERROR,o({fatal:l},n,{type:x.MEDIA_ERROR,details:w.MEDIA_SOURCE_REQUIRES_RESET,error:u}))}},i._onMediaSourceEnded=function(){i.log("Media source ended")},i._onMediaEmptied=function(){var e=i,t=e.mediaSrc,r=e._objectUrl;t!==r&&i.error("Media element src was set while attaching MediaSource ("+r+" > "+t+")")},i._onMediaError=function(){var e,t,r=i.media;r&&i.log("Media error (code: "+(null==(e=r.error)?void 0:e.code)+"): "+(null==(t=r.error)?void 0:t.message))},i.hls=t,i.fragmentTracker=r,i.appendSource=(a=ve(t.config.preferManagedMediaSource),"undefined"!=typeof self&&a===self.ManagedMediaSource),i.initTracks(),i.registerListeners(),i}u(t,e);var r=t.prototype;return r.hasSourceTypes=function(){return Object.keys(this.tracks).length>0},r.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null,this._onMediaEmptied=this._onMediaError=null},r.registerListeners=function(){var e=this.hls;e.on(O.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.MANIFEST_PARSED,this.onManifestParsed,this),e.on(O.BUFFER_RESET,this.onBufferReset,this),e.on(O.BUFFER_APPENDING,this.onBufferAppending,this),e.on(O.BUFFER_CODECS,this.onBufferCodecs,this),e.on(O.BUFFER_EOS,this.onBufferEos,this),e.on(O.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(O.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(O.FRAG_PARSED,this.onFragParsed,this),e.on(O.FRAG_CHANGED,this.onFragChanged,this),e.on(O.ERROR,this.onError,this)},r.unregisterListeners=function(){var e=this.hls;e.off(O.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.MANIFEST_PARSED,this.onManifestParsed,this),e.off(O.BUFFER_RESET,this.onBufferReset,this),e.off(O.BUFFER_APPENDING,this.onBufferAppending,this),e.off(O.BUFFER_CODECS,this.onBufferCodecs,this),e.off(O.BUFFER_EOS,this.onBufferEos,this),e.off(O.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(O.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(O.FRAG_PARSED,this.onFragParsed,this),e.off(O.FRAG_CHANGED,this.onFragChanged,this),e.off(O.ERROR,this.onError,this)},r.transferMedia=function(){var e=this,t=this.media,r=this.mediaSource;if(!t)return null;var i={};if(this.operationQueue){var a=this.isUpdating();a||this.operationQueue.removeBlockers();var n=this.isQueued();(a||n)&&this.warn("Transfering MediaSource with"+(n?" operations in queue":"")+(a?" updating SourceBuffer(s)":"")+" "+this.operationQueue),this.operationQueue.destroy()}var s=this.transferData;return s&&!this.sourceBufferCount&&s.mediaSource===r?o(i,s.tracks):this.sourceBuffers.forEach((function(t){var r=t[0];r&&(i[r]=o({},e.tracks[r]),e.removeBuffer(r)),t[0]=t[1]=null})),{media:t,mediaSource:r,tracks:i}},r.initTracks=function(){this.resetAppendProgress(),this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.lastMpegAudioChunk=null,this.lastVideoAppendEnd=0},r.onManifestLoading=function(){this.bufferCodecEventsTotal=0,this.details=null,this.resetAppendErrors(),this.resetAppendProgress()},r.onManifestParsed=function(e,t){var r,i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsTotal=i,this.log(i+" bufferCodec event(s) expected."),null!=(r=this.transferData)&&r.mediaSource&&this.sourceBufferCount&&i&&this.bufferCreated()},r.onMediaAttaching=function(e,t){var r=this,i=this.media=t.media;this.transferData=this.overrides=void 0;var a=ve(this.appendSource);if(a){var n=!!t.mediaSource;(n||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);var s=this.mediaSource=t.mediaSource||new a;if(this.assignMediaSource(s),n)this._objectUrl=i.src,this.attachTransferred();else{var o,l=this._objectUrl=self.URL.createObjectURL(s),u=this.hls.config,d=u.emeEnabled&&i.mediaKeys?null==(o=u.emeController)?void 0:o.CDMCleanupPromise:null;d?d.then((function(){r.hls&&r.setSource(i,s,l)})).catch((function(){})):this.setSource(i,s,l)}hr(i,"emptied",this._onMediaEmptied),hr(i,"error",this._onMediaError),this.appendSource&&hr(i,"seeking",this._onStartStreaming)}},r.setSource=function(e,t,r){if(this.appendSource)try{e.removeAttribute("src");var i=self.ManagedMediaSource;e.disableRemotePlayback=e.disableRemotePlayback||i&&t instanceof i,Er(e),function(e,t){var r=self.document.createElement("source");r.type="video/mp4",r.src=t,e.appendChild(r)}(e,r),e.load()}catch(t){e.src=r}else e.src=r},r.assignMediaSource=function(e){var t,r;this.log(((null==(t=this.transferData)?void 0:t.mediaSource)===e?"transferred":"created")+" media source: "+(null==(r=e.constructor)?void 0:r.name)),hr(e,"sourceopen",this._onMediaSourceOpen),hr(e,"sourceended",this._onMediaSourceEnded),hr(e,"sourceclose",this._onMediaSourceClose),this.appendSource&&(hr(e,"startstreaming",this._onStartStreaming),hr(e,"endstreaming",this._onEndStreaming))},r.attachTransferred=function(){var e=this,t=this.media,r=this.transferData;if(r&&t){var i=this.tracks,a=r.tracks,n=a?Object.keys(a):null,s=n?n.length:0,o=function(){Promise.resolve().then((function(){e.media&&e.mediaSourceOpenOrEnded&&e._onMediaSourceOpen()}))};if(a&&n&&s){if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log("attachTransferred: (bufferCodecEventsTotal "+this.bufferCodecEventsTotal+")\nrequired tracks: "+Bt(i,(function(e,t){return"initSegment"===e?void 0:t}))+";\ntransfer tracks: "+Bt(a,(function(e,t){return"initSegment"===e?void 0:t}))+"}"),!function(e,t){var r=Object.keys(e),i=Object.keys(t),a=r.length,n=i.length;return!a||!n||a===n&&!r.some((function(e){return-1===i.indexOf(e)}))}(a,i)){r.mediaSource=null,r.tracks=void 0;var l=t.currentTime,u=this.details,d=Math.max(l,(null==u?void 0:u.fragments[0].start)||0);return d-l>1?void this.log("attachTransferred: waiting for playback to reach new tracks start time "+l+" -> "+d):(this.warn('attachTransferred: resetting MediaSource for incompatible tracks ("'+Object.keys(a)+'"->"'+Object.keys(i)+'") start time: '+d+" currentTime: "+l),this.onMediaDetaching(O.MEDIA_DETACHING,{}),this.onMediaAttaching(O.MEDIA_ATTACHING,r),void(t.currentTime=d))}this.transferData=void 0,n.forEach((function(t){var r=t,i=a[r];if(i){var n=i.buffer;if(n){var s=e.fragmentTracker,o=i.id;if(s.hasFragments(o)||s.hasParts(o)){var l=dr.getBuffered(n);s.detectEvictedFragments(r,l,o,null,null,!0)}var u=Tr(r),d=[r,n];e.sourceBuffers[u]=d,n.updating&&e.operationQueue&&e.operationQueue.prependBlocker(r),e.trackSourceBuffer(r,i)}}})),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}},r.onMediaDetaching=function(e,t){var r=this,i=!!t.transferMedia;this.transferData=this.overrides=void 0;var a=this.media,n=this.mediaSource,s=this._objectUrl;if(n){if(this.log("media source "+(i?"transferring":"detaching")),i)this.sourceBuffers.forEach((function(e){var t=e[0];t&&r.removeBuffer(t)})),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){var o="open"===n.readyState;try{for(var l=n.sourceBuffers,u=l.length;u--;)o&&l[u].abort(),n.removeSourceBuffer(l[u]);o&&n.endOfStream()}catch(e){this.warn("onMediaDetaching: "+e.message+" while calling endOfStream")}}this.sourceBufferCount&&this.onBufferReset()}fr(n,"sourceopen",this._onMediaSourceOpen),fr(n,"sourceended",this._onMediaSourceEnded),fr(n,"sourceclose",this._onMediaSourceClose),this.appendSource&&(fr(n,"startstreaming",this._onStartStreaming),fr(n,"endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}a&&(fr(a,"emptied",this._onMediaEmptied),fr(a,"error",this._onMediaError),fr(a,"seeking",this._onStartStreaming),i||(s&&self.URL.revokeObjectURL(s),this.mediaSrc!==s||this.isMediaSourceReplaced(s)?this.warn("media|source.src was changed by a third party - skip cleanup"):(a.removeAttribute("src"),this.appendSource&&Er(a),a.load())),this.media=null)},r.onBufferReset=function(){var e=this;this.sourceBuffers.forEach((function(t){var r=t[0];r&&e.resetBuffer(r)})),this.initTracks()},r.resetBuffer=function(e){var t,r=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),r)try{var i;null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(r)}catch(t){this.warn("onBufferReset "+e,t)}delete this.tracks[e]},r.removeBuffer=function(e){this.removeBufferListeners(e),this.sourceBuffers[Tr(e)]=[null,null];var t=this.tracks[e];t&&(this.clearBufferAppendTimeoutId(t),t.buffer=void 0)},r.resetQueue=function(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new Kt(this.tracks)},r.onBufferCodecs=function(e,t){var r,i=this,a=this.tracks,n=Object.keys(t);this.log('BUFFER_CODECS: "'+n+'" (current SB count '+this.sourceBufferCount+")");var s="audiovideo"in t&&(a.audio||a.video)||a.audiovideo&&("audio"in t||"video"in t),o=!s&&this.sourceBufferCount&&this.media&&n.some((function(e){return!a[e]}));s||o?this.warn('Unsupported transition between "'+Object.keys(a)+'" and "'+n+'" SourceBuffers'):(n.forEach((function(e){var r,n,s=t[e],o=s.id,l=s.codec,u=s.levelCodec,d=s.container,h=s.metadata,f=s.supplemental,c=a[e],g=null==(r=i.transferData)||null==(r=r.tracks)?void 0:r[e],v=null!=g&&g.buffer?g:c,m=(null==v?void 0:v.pendingCodec)||(null==v?void 0:v.codec),p=null==v?void 0:v.levelCodec;c||(c=a[e]={buffer:void 0,listeners:[],codec:l,supplemental:f,container:d,levelCodec:u,metadata:h,id:o});var y=At(m,p),E=null==y?void 0:y.replace(gr,"$1"),T=At(l,u),S=null==(n=T)?void 0:n.replace(gr,"$1");T&&y&&E!==S&&("audio"===e.slice(0,5)&&(T=Rt(T,i.appendSource)),i.log("switching codec "+m+" to "+T),T!==(c.pendingCodec||c.codec)&&(c.pendingCodec=T),c.container=d,i.appendChangeType(e,d,T))})),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&"main"===(null==(r=t.audio)?void 0:r.id)&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks()))},r.appendChangeType=function(e,t,r){var i=this,a=t+";codecs="+r,n={label:"change-type="+a,execute:function(){var n=i.tracks[e];if(n){var s=n.buffer;null!=s&&s.changeType&&(i.log("changing "+e+" sourceBuffer type to "+a),s.changeType(a),n.codec=r,n.container=t)}i.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(t){i.warn("Failed to change "+e+" SourceBuffer type",t)}};this.append(n,e,this.isPending(this.tracks[e]))},r.blockAudio=function(e){var t,r=this,i=e.start,a=i+.05*e.duration;if(!0!==(null==(t=this.fragmentTracker.getAppendedFrag(i,N.MAIN))?void 0:t.gap)){var n={label:"block-audio",execute:function(){var e,t;(r.lastVideoAppendEnd>a||dr.isBuffered(null==(e=r.tracks.video)?void 0:e.buffer,a)||!0===(null==(t=r.fragmentTracker.getAppendedFrag(a,N.MAIN))?void 0:t.gap))&&r.unblockAudio()},onStart:function(){},onComplete:function(){},onError:function(e){r.warn("Error executing block-audio operation",e)}};this.append(n,"audio",!0)}},r.unblockAudio=function(){this.operationQueue&&this.operationQueue.unblockAudio()},r.onBufferAppending=function(e,t){var r=this,i=this.tracks,a=t.data,n=t.type,s=t.parent,o=t.frag,l=t.part,u=t.chunkMeta,d=t.offset,h=u.buffering[n],f=G(o)&&!l&&!o.gap&&!u.partial&&!u.iframe,c=null,g=!1,v=o.sn,m=o.cc,p=self.performance.now();h.start=p;var y=o.stats.buffering,E=l?l.stats.buffering:null;0===y.start&&(y.start=p),0===(null==E?void 0:E.start)&&(E.start=p);var T=i.audio,S=!1;"audio"===n&&"audio/mpeg"===(null==T?void 0:T.container)&&(S=!this.lastMpegAudioChunk||1===u.id||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);var L=i.video,R=null==L?void 0:L.buffer;if(R&&"initSegment"!==v&&void 0!==d){var A=null==T?void 0:T.buffer,b=l||o;if("audio"===n&&"main"!==s&&!L.ending&&!L.ended&&A&&dr.getBuffered(A).length){var k=b.start+.05*b.duration,D=dr.getBuffered(R),I=this.currentOp("video");D.length||I?!dr.isBuffered(R,k)&&this.lastVideoAppendEndb.duration?this.unblockAudio():this.isAudioBlocked()&&this.executeNext("audio")}}var M=(l||o).start,F={label:"append-"+n,execute:function(){var e;h.executeStart=self.performance.now();var t=null==(e=r.tracks[n])?void 0:e.buffer;t&&(f&&(c=dr.timeRangesToArray(dr.getBuffered(t)),g=Ar(Rr(c,o),o)),S?r.updateTimestampOffset(t,M,.1,n,v,m):void 0!==d&&_(d)&&r.updateTimestampOffset(t,d,1e-6,n,v,m)),r.appendExecutor(a,n)},onStart:function(){},onComplete:function(){r.clearBufferAppendTimeoutId(r.tracks[n]);var e=self.performance.now();h.executeEnd=h.end=e,0===y.first&&(y.first=e),0===(null==E?void 0:E.first)&&(E.first=e);var t={};if(r.sourceBuffers.forEach((function(e){var r=e[0],i=e[1];r&&(t[r]=dr.getBuffered(i))})),f){var i=r.getFragmentAppendProgress(o),a=t[n];if(a&&c){var d=Rr(dr.timeRangesToArray(a),o);i.progressed||(i.progressed=d-Rr(c,o)>.001);var v=g&&Ar(d,o);i.fullyBuffered[n]=(void 0===i.fullyBuffered[n]||i.fullyBuffered[n])&&v}}r.hls.trigger(O.BUFFER_APPENDED,{type:n,frag:o,part:l,chunkMeta:u,parent:s,timeRanges:t})},onError:function(e){var t;r.clearBufferAppendTimeoutId(r.tracks[n]);var i=e.code===DOMException.QUOTA_EXCEEDED_ERR||"QuotaExceededError"==e.name||"quota"in e;if(i&&!r._quotaEvictionPending[n]){var d=r.getBackBufferEvictionTarget(n,a.byteLength,o.type);if(d>0){r._quotaEvictionPending[n]=!0,r.log('QuotaExceededError on "'+n+'" append sn: '+v+" - evicting back buffer to "+d.toFixed(3)+"s and retrying");var h=r.getFlushOp(n,0,d),c=r.getClearEvictionPendingOp(n);return void r.insertNext([h,F,c],n)}r.warn('QuotaExceededError on "'+n+'" sn: '+v+" - no back buffer available to evict")}f&&(r.getFragmentAppendProgress(o).errored=!0);var g={type:x.MEDIA_ERROR,parent:s,details:w.BUFFER_APPEND_ERROR,sourceBufferName:n,frag:o,part:l,chunkMeta:u,error:e,err:e,fatal:!1},m=null==(t=r.media)?void 0:t.error;if(e.name!==vr||0!==r.sourceBufferCount||r.media&&0!==r.pendingTrackCount){var p;i&&(g.details=w.BUFFER_FULL_ERROR);var y=++r.appendErrors[n],E=r.hls.config.appendErrorMaxRetry;r.warn("Failed "+y+"/"+(E+1)+' times to append segment in "'+n+'" sourceBuffer with error: '+e.message),y>=E&&(g.fatal=!i);var T=null==(p=r.mediaSource)?void 0:p.readyState;"ended"!==T&&"closed"!==T&&!m||r.isMediaSourceReplaced()||(r.warn('MediaSource readyState "'+T+'" during SourceBuffer'+Sr(g.fatal,m)),g.details=w.MEDIA_SOURCE_REQUIRES_RESET)}else g.errorAction=or(!0);r.appendError=g,r.hls.trigger(O.ERROR,g),i&&r.hls&&r.trimBuffers(o.start,1)}};this.log('queuing "'+n+'" append sn: '+v+(l?" p: "+l.index:"")+" of "+s+" playlist "+o.level+" cc: "+m+" offset: "+d+" bytes: "+a.byteLength),this.append(F,n,this.isPending(this.tracks[n]))},r.getClearEvictionPendingOp=function(e){var t=this;return{label:"clear",execute:function(){t._quotaEvictionPending[e]=!1,t.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(){}}},r.getFlushOp=function(e,t,r){var i=this;return this.log('queuing "'+e+'" remove '+t+"-"+r),{label:"remove",execute:function(){i.removeExecutor(e,t,r)},onStart:function(){},onComplete:function(){var a,n=null==(a=i.tracks[e])?void 0:a.buffer;i.log("Remove request "+t+"-"+r+" from "+e+" Source Buffer complete > buffer: "+(n?cr(dr.getBuffered(n)):"(detached)")),i.hls.trigger(O.BUFFER_FLUSHED,{type:e,start:t,end:r})},onError:function(a){i.warn("Failed to remove "+t+"-"+r+' from "'+e+'" SourceBuffer',a),i.hls.trigger(O.BUFFER_FLUSHED,{type:e,start:0,end:0,error:a})}}},r.onBufferFlushing=function(e,t){var r=this,i=t.type,a=t.startOffset,n=t.endOffset;i&&"audio"!==i||this.unblockAudio(),i?this.append(this.getFlushOp(i,a,n),i):this.sourceBuffers.forEach((function(e){var t=e[0];t&&r.append(r.getFlushOp(t,a,n),t)}))},r.onFragParsed=function(e,t){var r=this,i=t.frag,a=t.part,n=t.chunkMeta,s=[],o=a?a.elementaryStreams:i.elementaryStreams;o[B.AUDIOVIDEO]?s.push("audiovideo"):(o[B.AUDIO]&&s.push("audio"),o[B.VIDEO]&&s.push("video")),0===s.length&&this.log("Fragments must have at least one ElementaryStreamType set. "+i.type+" "+i.level+" "+(a?"part: "+a.index+" of ":"")+"sn: "+i.sn),this.blockBuffers((function(){var e=self.performance.now();i.stats.buffering.end=e,a&&(a.stats.buffering.end=e);var t=a?a.stats:i.stats;r.checkAppendProgress(i,a,n,s),r.hls&&(r.hls.trigger(O.FRAG_BUFFERED,{frag:i,part:a,stats:t,id:i.type,chunkMeta:n}),!a&&i.gap&&t.retry&&r.log("Nothing buffered for "+i.type+" level: "+i.level+" sn: "+i.sn+" retries "+t.retry))}),s).catch((function(e){r.warn("Fragment buffered callback "+e.message),r.stepOperationQueue(r.sourceBufferTypes)}))},r.onFragChanged=function(e,t){var r,i,a=this,n=null==(r=this.hls)?void 0:r.config;if(n){var s=n.backBufferLength,o=n.frontBufferFlushThreshold;this.trimBuffers(o,s,t.frag,t.previousFrag);var l=t.frag.elementaryStreams,u=this.appendErrors,d=null==(i=this.appendError)?void 0:i.sourceBufferName;Object.keys(l).forEach((function(e){l[e]&&(u[e]=0,e===d&&(a.appendError=void 0),"audio"===e||"video"===e?(u.audiovideo=0,"audiovideo"===d&&(a.appendError=void 0)):(u.audio=0,u.video=0,"audiovideo"!==d&&(a.appendError=void 0)))}))}},r.onBufferEos=function(e,t){var r,i=this;this.sourceBuffers.forEach((function(e){var r=e[0];if(r){var a=i.tracks[r];t.type&&t.type!==r||(a.ending=!0,a.ended||(a.ended=!0,i.log(r+" buffer reached EOS")))}}));var a=!1!==(null==(r=this.overrides)?void 0:r.endOfStream);this.allTracksEnding?(this.unblockAudio(),a?(this.log("Queueing EOS"),this.blockUntilOpen((function(){if(i.tracksEnded(),i.allTracksEnding){var e=i.mediaSource;"open"===(null==e?void 0:e.readyState)?(i.log("Calling mediaSource.endOfStream()"),e.endOfStream(),i.hls.trigger(O.BUFFERED_TO_END,void 0)):e&&i.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+e.readyState)}else i.log("EOS cancelled")}))):(this.tracksEnded(),this.hls.trigger(O.BUFFERED_TO_END,void 0))):"video"===t.type&&this.unblockAudio()},r.tracksEnded=function(){var e=this;this.sourceBuffers.forEach((function(t){var r=t[0];if(null!==r){var i=e.tracks[r];i&&(i.ending=!1)}}))},r.onLevelUpdated=function(e,t){var r=t.details;r.fragments.length&&(this.details=r,this.updateDuration())},r.updateDuration=function(){var e=this;this.blockUntilOpen((function(){var t=e.getDurationAndRange();t&&e.updateMediaSource(t)}))},r.onError=function(e,t){if(t.details===w.BUFFER_APPEND_ERROR&&t.frag){var r,i=null==(r=t.errorAction)?void 0:r.nextAutoLevel;_(i)&&i!==t.frag.level&&this.resetAppendErrors()}},r.getBackBufferEvictionTarget=function(e,t,r){var i=this.media;return i?this.fragmentTracker.getBackBufferEvictionEnd(i.currentTime,r,t):0},r.getFragmentAppendProgress=function(e){var t,r=Lr(e),i=this.fragmentAppendProgress[r];return(null==(t=i)?void 0:t.stats)!==e.stats&&(i={stats:e.stats,progressed:!1,errored:!1,fullyBuffered:Object.create(null)},this.fragmentAppendProgress[r]=i),i},r.checkAppendProgress=function(e,t,r,i){if(!(t||!G(e)||e.gap||r.iframe||r.partial)){var a=Lr(e),n=this.fragmentAppendProgress[a];delete this.fragmentAppendProgress[a];var s=e.stats.buffering;if(!s.start||s.first){var o=(null==n?void 0:n.stats)===e.stats?n:void 0;if(null==o||!o.errored){var l=i.length>0&&i.every((function(e){return!0===(null==o?void 0:o.fullyBuffered[e])}));if(null!=o&&o.progressed||l)delete this.appendsWithoutProgress[a];else if(o||0!==i.length){var u=(this.appendsWithoutProgress[a]||0)+1,d=this.hls;u>=d.config.appendErrorMaxRetry?delete this.appendsWithoutProgress[a]:this.appendsWithoutProgress[a]=u,this.warn("Fragment "+e.sn+" of "+e.type+" playlist "+e.level+" appended "+u+" time"+(u>1?"s":"")+" without buffered range growth"),d.trigger(O.ERROR,{type:x.MEDIA_ERROR,details:w.BUFFER_APPEND_NO_PROGRESS,fatal:!1,frag:e,chunkMeta:r,parent:e.type,appendsWithoutProgress:u,error:new Error("Fragment append did not increase buffered coverage ("+u+")")})}}}}},r.resetAppendProgress=function(){this.fragmentAppendProgress=Object.create(null),this.appendsWithoutProgress=Object.create(null)},r.resetAppendErrors=function(){this.appendErrors={audio:0,video:0,audiovideo:0},this.appendError=void 0},r.trimBuffers=function(e,t,r,i){var a=this.hls,n=this.details,s=this.media;if(s&&null!==n&&this.sourceBufferCount){var o=a.config,l=s.currentTime,u=n.levelTargetDuration;t=n.live&&null!==o.liveBackBufferLength?o.liveBackBufferLength:t;var d=-1/0;if(_(t)&&t>=0){var h=Math.max(t,u);d=Math.floor(l/u)*u-h}if(r){var f=this.getLoopBackBufferFlushEnd(r,null!=i?i:null);f>0&&(d=Math.max(d,f))}if(d>0&&this.flushBackBuffer(l,u,d),_(e)&&e>0){var c=Math.max(o.maxBufferLength,e),g=Math.max(c,u),v=Math.floor(l/u)*u+g;this.flushFrontBuffer(l,u,v)}}},r.getLoopBackBufferFlushEnd=function(e,t){var r,i=this.media;if(!1===(null==(r=this.hls)?void 0:r.config.loopBackBufferFlush)||null==i||!i.loop||!t||e.level<=t.level)return 0;var a=e.elementaryStreams,n=a.video,s=a.audiovideo;if(null!=n&&n.partial||null!=s&&s.partial)return 0;var o=this.getEarliestElementaryStreamStart(e)-.25;return o<=0?0:(this.log("Flushing lower quality back buffer for loop: level "+e.level+", range [0-"+o.toFixed(3)+"]"),o)},r.getEarliestElementaryStreamStart=function(e){var t=e.elementaryStreams,r=t.audio,i=t.video,a=t.audiovideo,n=e.start;return a?n=Math.min(n,a.startDTS):(r&&(n=Math.min(n,r.startDTS)),i&&(n=Math.min(n,i.startDTS))),n},r.flushBackBuffer=function(e,t,r){var i=this;this.sourceBuffers.forEach((function(e){var t=e[0],a=e[1];if(a){var n=dr.getBuffered(a);if(n.length>0&&r>n.start(0)){var s,o,l;i.hls.trigger(O.BACK_BUFFER_REACHED,{bufferEnd:r});var u=i.tracks[t];if(null!=(s=i.details)&&s.live)i.hls.trigger(O.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(null!=u&&u.ended&&(null==(o=i.media)||!o.loop||!1===(null==(l=i.hls)?void 0:l.config.loopBackBufferFlush)))return void i.log("Cannot flush "+t+" back buffer while SourceBuffer is in ended state");i.hls.trigger(O.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:t})}}}))},r.flushFrontBuffer=function(e,t,r){var i=this;this.sourceBuffers.forEach((function(t){var a=t[0],n=t[1];if(n){var s=dr.getBuffered(n),o=s.length;if(o<2)return;var l=s.start(o-1),u=s.end(o-1);if(r>l||e>=l&&e<=u)return;i.hls.trigger(O.BUFFER_FLUSHING,{startOffset:l,endOffset:1/0,type:a})}}))},r.getDurationAndRange=function(){var e,t=this.details,r=this.mediaSource;if(!t||!this.media||"open"!==(null==r?void 0:r.readyState))return null;var i=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&r.setLiveSeekableRange){var a=Math.max(0,t.fragmentStart);return{duration:1/0,start:a,end:Math.max(a,i)}}return{duration:1/0}}var n=null==(e=this.overrides)?void 0:e.duration;if(n)return _(n)?{duration:n}:null;var s=this.media.duration;return i>(_(r.duration)?r.duration:0)&&i>s||!_(s)?{duration:i}:null},r.updateMediaSource=function(e){var t=e.duration,r=e.start,i=e.end,a=this.mediaSource;a&&this.media&&"open"===a.readyState&&(a.duration!==t&&(_(t)&&this.log("Updating MediaSource duration to "+t.toFixed(3)),a.duration=t),void 0!==r&&void 0!==i&&(this.log("MediaSource duration is set to "+a.duration+". Setting seekable range to "+r+"-"+i+"."),a.setLiveSeekableRange(r,i)))},r.checkPendingTracks=function(){var e=this.bufferCodecEventsTotal,t=this.pendingTrackCount,r=this.tracks;if(this.log("checkPendingTracks (pending: "+t+" codec events expected: "+e+") "+Bt(r)),this.tracksReady){var i,a=null==(i=this.transferData)?void 0:i.tracks;a&&Object.keys(a).length?this.attachTransferred():this.createSourceBuffers()}},r.bufferCreated=function(){var e=this;if(this.sourceBufferCount){var t={};this.sourceBuffers.forEach((function(r){var i=r[0],a=r[1];if(i){var n=e.tracks[i];t[i]={buffer:a,container:n.container,codec:n.codec,supplemental:n.supplemental,levelCodec:n.levelCodec,id:n.id,metadata:n.metadata}}})),this.hls.trigger(O.BUFFER_CREATED,{tracks:t}),this.log("SourceBuffers created. Running queue: "+this.operationQueue),this.sourceBuffers.forEach((function(t){var r=t[0];e.executeNext(r)}))}else{var r=new Error("could not create source buffer for media codec(s)");this.hls.trigger(O.ERROR,{type:x.MEDIA_ERROR,details:w.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:r,reason:r.message})}},r.createSourceBuffers=function(){var e=this.tracks,t=this.sourceBuffers,r=this.mediaSource;if(!r)throw new Error("createSourceBuffers called when mediaSource was null");for(var i in e){var a=i,n=e[a];if(this.isPending(n)){var s=this.getTrackCodec(n,a),o=n.container+";codecs="+s;n.codec=s,this.log("creating sourceBuffer("+o+")"+(this.currentOp(a)?" Queued":"")+" "+Bt(n));try{var l=r.addSourceBuffer(o),u=Tr(a),d=[a,l];t[u]=d,n.buffer=l}catch(e){var h;return this.error("error while trying to add sourceBuffer: "+e.message),this.shiftAndExecuteNext(a),null==(h=this.operationQueue)||h.removeBlockers(),delete this.tracks[a],void this.hls.trigger(O.ERROR,{type:x.MEDIA_ERROR,details:w.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:a,mimeType:o,parent:n.id})}this.trackSourceBuffer(a,n)}}this.bufferCreated()},r.clearBufferAppendTimeoutId=function(e){e&&(self.clearTimeout(e.bufferAppendTimeoutId),e.bufferAppendTimeoutId=void 0)},r.getTrackCodec=function(e,t){var r=e.supplemental,i=e.codec;r&&("video"===t||"audiovideo"===t)&&mt(r,"video")&&(i=function(e,t){var r=[];if(e)for(var i=e.split(","),a=0;a=r&&(this.log("Updating "+i+" SourceBuffer timestampOffset to "+t+" (sn: "+a+" cc: "+n+")"),e.timestampOffset=t)},r.removeExecutor=function(e,t,r){var i=this.media,a=this.mediaSource,n=this.tracks[e],s=null==n?void 0:n.buffer;if(!i||!a||!s)throw new Error("Attempting to remove from the "+e+" SourceBuffer, but it does not exist");var o,l=_(i.duration)?i.duration:1/0,u=_(a.duration)?a.duration:1/0,d=Math.max(0,t);if(d>=u)return null==(o=this.currentOp(e))||o.onComplete(),void this.shiftAndExecuteNext(e);var h=Math.min(r,l,u);if(!(h>d)||n.ending&&!n.ended)throw new Error("Cannot remove "+(h<=d?"invalid range ("+d+" >= "+h+") ":"")+"from the "+e+" SourceBuffer"+(n.ending?" while track ending":""));n.ended=!1,this.log("Removing ["+d+","+h+"] from the "+e+" SourceBuffer"),s.remove(d,h)},r.appendExecutor=function(e,t){var r=this,i=this.tracks[t],a=null==i?void 0:i.buffer;if(!a)throw new pr("Attempting to append to the "+t+" SourceBuffer, but it does not exist");if(i.ending=!1,i.ended=!1,this.hls.config.appendTimeout!==1/0){var n=this.calculateAppendTimeoutTime(a);i.bufferAppendTimeoutId=self.setTimeout((function(){return r.appendTimeoutHandler(t,a,n)}),n)}a.appendBuffer(e)},r.appendTimeoutHandler=function(e,t,r){this.log("Received timeout after "+r+"ms for append on "+e+" source buffer. Aborting and triggering error.");try{t.abort()}catch(t){this.log("Failed to abort append on "+e+" source buffer after timeout.")}var i=this.currentOp(e);i&&i.onError(new Error(e+"-append-timeout"))},r.calculateAppendTimeoutTime=function(e){var t=10;this.details&&(t=this.details.levelTargetDuration);var r=2*t*1e3;if(null===this.media)return r;var i=dr.bufferInfo(e,this.media.currentTime,0);return i.len?(r=Math.max(1e3*i.len,r),Math.max(this.hls.config.appendTimeout,r)):r},r.blockUntilOpen=function(e){var t=this;if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch((function(e){t.warn("SourceBuffer blocked callback "+e),t.stepOperationQueue(t.sourceBufferTypes)}));else try{e()}catch(e){this.warn("Callback run without blocking "+this.operationQueue+" "+e)}},r.isUpdating=function(){return this.sourceBuffers.some((function(e){var t=e[0],r=e[1];return t&&r.updating}))},r.isQueued=function(){var e=this;return this.sourceBuffers.some((function(t){var r=t[0];return r&&!!e.currentOp(r)}))},r.isPending=function(e){return!!e&&!e.buffer},r.isAudioBlocked=function(){var e;return"block-audio"===(null==(e=this.currentOp("audio"))?void 0:e.label)},r.isAudioBlocking=function(){return!!this.operationQueue&&this.operationQueue.audioBlocking()},r.blockBuffers=function(e,t){var r=this;if(void 0===t&&(t=this.sourceBufferTypes),!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);var i=this.operationQueue,a=2===t.length&&this.isAudioBlocking()?[this.appendBlocker("video")]:t.map((function(e){return r.appendBlocker(e)}));return Promise.all(a).then((function(t){i===r.operationQueue&&(e(),r.stepOperationQueue(r.sourceBufferTypes))}))},r.stepOperationQueue=function(e){var t=this;e.forEach((function(e){var r,i=null==(r=t.tracks[e])?void 0:r.buffer;!i||i.updating||"audio"===e&&t.isAudioBlocked()||t.shiftAndExecuteNext(e)}))},r.append=function(e,t,r){this.operationQueue&&this.operationQueue.append(e,t,r)},r.insertNext=function(e,t){this.operationQueue&&this.operationQueue.insertNext(e,t)},r.appendBlocker=function(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)},r.currentOp=function(e){return this.operationQueue?this.operationQueue.current(e):null},r.executeNext=function(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)},r.shiftAndExecuteNext=function(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)},r.addBufferListener=function(e,t,r){var i=this.tracks[e];if(i){var a=i.buffer;if(a){var n=r.bind(this,e);i.listeners.push({event:t,listener:n}),hr(a,t,n)}}},r.removeBufferListeners=function(e){var t=this.tracks[e];if(t){var r=t.buffer;r&&(t.listeners.forEach((function(e){fr(r,e.event,e.listener)})),t.listeners.length=0)}},a(t,[{key:"mediaSourceOpenOrEnded",get:function(){var e,t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}},{key:"sourceBufferTracks",get:function(){var e=this;return Object.keys(this.tracks).reduce((function(t,r){var i=e.tracks[r];return t[r]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},t}),{})}},{key:"bufferedToEnd",get:function(){var e=this;return this.sourceBufferCount>0&&!this.sourceBuffers.some((function(t){var r=t[0];if(r){var i=e.tracks[r];if(i)return!i.ended||i.ending}return!1}))}},{key:"allTracksEnding",get:function(){var e=this;return this.sourceBufferCount>0&&!this.sourceBuffers.some((function(t){var r,i=t[0];return i&&!(null!=(r=e.tracks[i])&&r.ended)}))}},{key:"tracksReady",get:function(){var e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"mediaSrc",get:function(){var e,t=this.media;if(t)return(t.src?t:(null==(e=t.querySelector)?void 0:e.call(t,"source"))||t).src}},{key:"pendingTrackCount",get:function(){var e=this;return Object.keys(this.tracks).reduce((function(t,r){return t+(e.isPending(e.tracks[r])?1:0)}),0)}},{key:"sourceBufferCount",get:function(){return this.sourceBuffers.reduce((function(e,t){return e+(t[0]?1:0)}),0)}},{key:"sourceBufferTypes",get:function(){return this.sourceBuffers.map((function(e){return e[0]})).filter((function(e){return!!e}))}}])}(ie);function Er(e){var t=e.querySelectorAll("source");[].slice.call(t).forEach((function(t){e.removeChild(t)}))}function Tr(e){return"audio"===e?1:0}function Sr(e,t){return(e?"":" - triggering recovery")+(t?" with HTMLMediaElement Error: "+t.message:"")}function Lr(e){return e.type+"_"+e.sn+"_"+e.level}function Rr(e,t){for(var r=t.start,i=t.end,a=0,n=0;n=i)break;var o=Math.max(r,s.start),l=Math.min(i,s.end);l>o&&(a+=l-o)}return a}function Ar(e,t){return t.duration-e<=.05}var br=function(){function e(e){this.hls=null,this.autoLevelCapping=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.observer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.media=null,this.restrictedLevels=[],this.clientRect=null,this.registerListeners()}var t=e.prototype;return t.setStreamController=function(e){this.streamController=e},t.destroy=function(){this.hls&&this.unregisterListener(),(this.timer||this.observer)&&this.stopCapping(),this.media=this.clientRect=this.hls=null,this.streamController=void 0},t.registerListeners=function(){var e=this.hls;e&&(e.on(O.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(O.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(O.MANIFEST_PARSED,this.onManifestParsed,this),e.on(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(O.BUFFER_CODECS,this.onBufferCodecs,this),e.on(O.MEDIA_DETACHING,this.onMediaDetaching,this))},t.unregisterListener=function(){var e=this.hls;e&&(e.off(O.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(O.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(O.MANIFEST_PARSED,this.onManifestParsed,this),e.off(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(O.BUFFER_CODECS,this.onBufferCodecs,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this))},t.onFpsDropLevelCapping=function(e,t){if(this.hls){var r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}},t.onMediaAttaching=function(e,t){var r=t.media;this.clientRect=null,this.hls&&(r instanceof HTMLVideoElement?(this.media=r,this.hls.config.capLevelToPlayerSize&&this.observe()):this.media=null,(this.timer||this.observer)&&this.hls.levels.length>1&&this.detectPlayerSize())},t.onManifestParsed=function(e,t){this.restrictedLevels=[],t.video&&this.startCapping(),this.onLevelsUpdated()},t.onLevelsUpdated=function(){if(this.hls)if((this.timer||this.observer)&&(_(this.autoLevelCapping)||this.clientRect))this.detectPlayerSize();else if(void 0===this.observer&&void 0===this.timer){var e=this.hls.levels;e.length>1&&e.some((function(e){return!!e.videoCodec}))&&this.startCapping()}},t.onBufferCodecs=function(e,t){t.video&&this.startCapping()},t.onMediaDetaching=function(){this.stopCapping(),this.media=null},t.detectPlayerSize=function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0||!this.hls)return void(this.clientRect=null);var e=this.hls.levels;if(e.length>1){var t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&t.logger.log("Setting autoLevelCapping to "+r+": "+e[r].height+"p@"+e[r].bitrate+" for media "+this.mediaWidth+"x"+this.mediaHeight),t.autoLevelCapping=r,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}else 1===e.length&&this.stopCapping()}},t.getMaxLevel=function(t){var r=this;if(!this.hls)return-1;var i=this.hls.levels;if(!i.length)return-1;var a=i.filter((function(e,i){return r.isLevelAllowed(e)&&i<=t}));return this.observer||(this.clientRect=null),e.getMaxLevelByMediaSize(a,this.mediaWidth,this.mediaHeight)},t.observe=function(){var e=this,t=self.ResizeObserver;t&&(this.observer=new t((function(t){var r,i=null==(r=t[0])?void 0:r.contentRect;i&&(e.clientRect=i,e.detectPlayerSize())}))),this.observer&&this.media&&this.observer.observe(this.media)},t.startCapping=function(){var e;this.timer||this.observer||null==(e=this.hls)||!e.config.capLevelToPlayerSize||(self.clearInterval(this.timer),this.timer=void 0,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.observe(),this.observer||(this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3)),this.detectPlayerSize())},t.stopCapping=function(){this.restrictedLevels=[],this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0),this.observer&&(this.observer.disconnect(),this.observer=void 0)},t.getDimensions=function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t},t.isLevelAllowed=function(e){return!this.restrictedLevels.some((function(t){return e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height}))},e.getMaxLevelByMediaSize=function(e,t,r){if(null==e||!e.length)return-1;for(var i,a,n=e.length-1,s=Math.max(t,r),o=0;o=s||l.height>=s)&&(i=l,!(a=e[o+1])||i.width!==a.width||i.height!==a.height)){n=o;break}}return n},a(e,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls)return e;var t=this.hls.config,r=t.ignoreDevicePixelRatio,i=t.maxDevicePixelRatio;if(!r)try{e=self.devicePixelRatio}catch(e){}return Math.min(e,i)}}])}(),kr=/^(\d+)x(\d+)$/,Dr=/(.+?)=(".*?"|.*?)(?:,|$)/g,Ir=function(){function e(t,r){"string"==typeof t&&(t=e.parseAttrList(t,r)),o(this,t)}var t=e.prototype;return t.decimalInteger=function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t},t.hexadecimalInteger=function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var r=new Uint8Array(t.length/2),i=0;iNumber.MAX_SAFE_INTEGER?1/0:t},t.decimalFloatingPoint=function(e){return parseFloat(this[e])},t.optionalFloat=function(e,t){var r=this[e];return r?parseFloat(r):t},t.enumeratedString=function(e){return this[e]},t.enumeratedStringList=function(e,t){var r=this[e];return(r?r.split(/[ ,]+/):[]).reduce((function(e,t){return e[t.toLowerCase()]=!0,e}),t)},t.bool=function(e){return"YES"===this[e]},t.decimalResolution=function(e){var t=kr.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}},e.parseAttrList=function(e,t){var r,i={};for(Dr.lastIndex=0;null!==(r=Dr.exec(e));){var a=r[1].trim(),n=r[2],s=0===n.indexOf('"')&&n.lastIndexOf('"')===n.length-1,o=!1;if(s)n=n.slice(1,-1);else switch(a){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":o=!0}if(t&&(s||o));else if(!o&&!s)switch(a){case"CLOSED-CAPTIONS":if("NONE"===n)break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":fe.warn(e+": attribute "+a+" is missing quotes")}i[a]=n}return i},a(e,[{key:"clientAttrs",get:function(){return Object.keys(this).filter((function(e){return"X-"===e.substring(0,2)}))}}])}();function _r(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}var Cr=function(){return a((function(e,t,r){var i;if(void 0===r&&(r=0),this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==t?void 0:t.tagAnchor)||null,this.tagOrder=null!=(i=null==t?void 0:t.tagOrder)?i:r,t){var a=t.attr;for(var n in a)if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==a[n]){fe.warn('DATERANGE tag attribute: "'+n+'" does not match for tags with ID: "'+e.ID+'"'),this._badValueForSameId=n;break}e=o(new Ir({}),a,e)}if(this.attr=e,t?(this._startDate=t._startDate,this._cue=t._cue,this._endDate=t._endDate,this._dateAtEnd=t._dateAtEnd):this._startDate=new Date(e["START-DATE"]),"END-DATE"in e){var s=(null==t?void 0:t.endDate)||new Date(e["END-DATE"]);_(s.getTime())&&(this._endDate=s)}}),[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"cue",get:function(){var e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}},{key:"startTime",get:function(){var e=this.tagAnchor;return null===e||null===e.programDateTime?(fe.warn('Expected tagAnchor Fragment with PDT set for DateRange "'+this.id+'": '+e),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){var e=this._endDate||this._dateAtEnd;if(e)return e;var t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(_(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isInterstitial",get:function(){return"com.apple.hls.interstitial"===this.class}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&_(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}},{key:"invalidReason",get:function(){return this.id?this._badValueForSameId?"Date range "+this._badValueForSameId+" mismatch":_(this.startDate.getTime())?!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr?this.isValid?null:"Unknown (check DURATION(|END|NEXT), CLASS, and CUE)":"Interstitial Date range missing X-ASSET-(LIST|URI)":"Date range invalid start date":"Missing ID"}}])}();function Pr(e,t){return e.length===t.length&&!e.some((function(e,r){return e!==t[r]}))}function xr(e,t){return!e&&!t||!(!e||!t)&&Pr(e,t)}var wr=0,Or=1;function Mr(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function Fr(e){switch(e){case"AES-128":case"AES-256":return wr;case"AES-256-CTR":return Or;default:throw new Error("invalid full segment method "+e)}}var Nr={},Br=function(){function e(e,t,r,i,a,n){void 0===i&&(i=[1]),void 0===a&&(a=null),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.scheme=void 0,this.method=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=i,this.iv=a,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&!Mr(e),null!=n&&n.startsWith("0x")&&(this.keyId=new Uint8Array(we(n)))}e.clearKeyUriToKeyIdMap=function(){Nr={}},e.setKeyIdForUri=function(e,t){Nr[e]=t},e.addKeyIdForUri=function(e){var t=Object.keys(Nr).length%Number.MAX_SAFE_INTEGER,r=new Uint8Array(16);return new DataView(r.buffer,12,4).setUint32(0,t),Nr[e]=r,r};var t=e.prototype;return t.matches=function(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&Pr(e.keyFormatVersions,this.keyFormatVersions)&&xr(e.iv,this.iv)&&xr(e.keyId,this.keyId)},t.isSupported=function(){if(this.method){if(Mr(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method}return!1},t.getDecryptData=function(t,r){if(!this.encrypted||!this.uri)return null;if(Mr(this.method)){var i=this.iv;return i||("number"!=typeof t&&(fe.warn('missing IV for initialization segment with method="'+this.method+'" - compliance issue'),t=0),i=function(e){for(var t=new Uint8Array(16),r=12;r<16;r++)t[r]=e>>8*(15-r)&255;return t}(t)),new e(this.method,this.uri,"identity",this.keyFormatVersions,i)}return this},e}(),Ur=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(I-FRAME-STREAM-INF|SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)(?:[\r\n]+|$)/g,Gr=/#EXT-X-MEDIA:(.*)/g,Vr=/^#EXT(?:INF|-X-TARGETDURATION):/m,Hr=new RegExp([/#EXTINF:\s*(\d+(?:\.\d*)?|\.\d+)?(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),Kr=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS|I-FRAMES-ONLY)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),Yr=function(){function e(){}return e.findGroup=function(e,t){for(var r=0;r0&&n.length0&&h.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=h.optionalFloat("PART-HOLD-BACK",0),c.holdBack=h.optionalFloat("HOLD-BACK",0);break;case"PART-INF":c.partTarget&&ti(c,O,l);var $=new Ir(M);c.partTarget=$.decimalFloatingPoint("PART-TARGET");break;case"PART":var Z=c.partList;Z||(Z=c.partList=[]);var J=y>0?Z[Z.length-1]:void 0,ee=y++,te=new Ir(M,c),re=new Y(te,R,f,ee,J);Z.push(re),R.duration+=re.duration;break;case"PRELOAD-HINT":var ie=new Ir(M,c);c.preloadHint=ie;break;case"RENDITION-REPORT":var ae=new Ir(M,c);c.renditionReports=c.renditionReports||[],c.renditionReports.push(ae);break;default:fe.warn("line parsed but not handled: "+l)}}}L&&!L.relurl?(g.pop(),E-=L.duration,c.partList&&(c.fragmentHint=L)):c.partList&&(Zr(R,L,v),R.cc=T,c.fragmentHint=R,d&&ei(R,d,c)),c.targetduration||(c.playlistParsingError=new Error("Missing Target Duration"));var ne=g.length,se=g[0],oe=g[ne-1];if((E+=c.skippedSegments*c.targetduration)>0&&ne&&oe){c.averagetargetduration=E/ne;var le=oe.sn;c.endSN="initSegment"!==le?le:0,c.live||(oe.endList=!0),A>0&&(function(e,t,r){if(r||(r=e[t]),r)for(var i=t;i--;){var a=e[i];if(!a)return;a.programDateTime=r.programDateTime-1e3*a.duration,r=a}}(g,A,A>ne-1?R:null),se&&v.unshift(se))}return c.fragmentHint&&(E+=c.fragmentHint.duration),c.totalduration=E,v.length&&c.dateRangeTagCount&&se&&jr(v,c),c.endCC=T,c},e}();function Wr(e,t,r,i,a,n){var s;if(void 0===t)return null;var o=t,l={attrs:e,bitrate:e.decimalInteger("BANDWIDTH")||e.decimalInteger("AVERAGE-BANDWIDTH"),name:e.NAME,url:Yr.resolve(o,r)},u=e.decimalResolution("RESOLUTION");u&&(l.width=u.width,l.height=u.height),Qr(e.CODECS,l);var d=e["SUPPLEMENTAL-CODECS"];return d&&(l.supplemental={},Qr(d,l.supplemental)),null!=(s=l.unknownCodecs)&&s.length||a.push(l),n&&(l.iframes=!0),l}function jr(e,t){var r=e.length;if(!r){if(!t.hasProgramDateTime)return;var i=t.fragments[t.fragments.length-1];e.push(i),r++}for(var a=e[r-1],n=t.live?1/0:t.totalduration,s=Object.keys(t.dateRanges),o=s.length;o--;){var l=t.dateRanges[s[o]],u=l.startDate.getTime();l.tagAnchor=a.ref;for(var d=r;d--;){var h;if((null==(h=e[d])?void 0:h.sn)=o||0===i)&&t<=o+1e3*(((null==(s=r[i+1])?void 0:s.start)||a)-n.start)){var l=n.sn-e.startSN,u=e.fragments;if(l>=0&&lr.length)for(var d=r[i+1]||u[u.length-1],h=Math.min(d.sn-e.startSN,u.length-1);h>l;h--){var f=u[h].programDateTime;if(t>=f&&te.sn?(a=r-e.start,i=e):(a=e.start-r,i=t),i.duration!==a&&i.setDuration(a)}else t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration):t.setStart(Math.max(e.start-t.duration,0))}function ai(e,t,r,i,a,n,s,o){i-r<=0&&(o.warn("Fragment should have a positive duration",t),i=r+t.duration,n=a+t.duration);var l=r,u=i,d=t.startPTS,h=t.endPTS;if(_(d)){var f=Math.abs(d-r);e&&f>e.totalduration?o.warn("media timestamps and playlist times differ by "+f+"s for level "+t.level+" "+e.url):_(t.deltaPTS)?t.deltaPTS=Math.max(f,t.deltaPTS):t.deltaPTS=f,l=Math.max(r,d),r=Math.min(r,d),a=void 0!==t.startDTS?Math.min(a,t.startDTS):a,u=Math.min(i,h),i=Math.max(i,h),n=void 0!==t.endDTS?Math.max(n,t.endDTS):n}var c=r-t.start;return 0!==t.start&&t.setStart(r),t.setDuration(i-t.start),t.startPTS=r,t.maxStartPTS=l,t.startDTS=a,t.endPTS=i,t.minEndPTS=u,t.endDTS=n,ni(e,t,c)}function ni(e,t,r){var i,a,n=t.sn;if(!e||n((null==(i=e.fragmentHint)?void 0:i.sn)||e.endSN))return 0;var s=n-e.startSN,o=e.fragments;for(o[s]=t,a=s;a>0;a--)ii(o[a],o[a-1]);for(a=s;a=0;s--){var l=n[s].initSegment;if(l){a=l;break}}e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,r){for(var i,a=t.skippedSegments,n=Math.max(e.startSN,t.startSN)-t.startSN,s=(e.fragmentHint?1:0)+(a?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,o=t.startSN-e.startSN,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=null!=(i=e.fragmentHint)&&i.duration?e.fragments.concat(e.fragmentHint):e.fragments,d=n;d<=s;d++){var h=u[o+d],f=l[d];if(a&&!f&&h&&(f=t.fragments[d]=h),h&&f){r(h,f,d,l);var c=h.relurl,g=f.relurl;if(c&&gi(c,g))return void(t.playlistParsingError=oi("media sequence mismatch "+f.sn+":",e,t,0,f));if(h.cc!==f.cc)return void(t.playlistParsingError=oi("discontinuity sequence mismatch ("+h.cc+"!="+f.cc+")",e,t,0,f))}}}(e,t,(function(e,r,n,s){if(r.cc!==e.cc&&(e.cc>r.cc||t.skippedSegments)){for(var o=e.cc-r.cc,l=n;le.endSN&&u[0].cc=0,o=0;if(s&&at){var a=1e3*i[i.length-1].duration;a>0&&a0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}},r.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},r.clearTimeout=function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},r.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},r.removeLevel=function(e){var t=this.levels;t&&(this.levels=t.filter((function(t){return t!==e})))},r.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},r.onManifestLoaded=function(e,t){var r=t.contentSteering;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())},r.onManifestParsed=function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks},r.onError=function(e,t){var r=t.errorAction;if((null==r?void 0:r.action)===zt&&r.flags&Jt){var i=this.levels,a=this._pathwayPriority,n=this.pathwayId;if(t.context){var s=t.context,o=s.groupId,l=s.pathwayId,u=s.type;o&&i?n=this.getPathwayForGroupId(o,u,n):l&&(n=l)}n in this.penalizedPathways||(this.penalizedPathways[n]=performance.now()),!a&&i&&(a=this.pathways()),a&&a.length>1&&(this.updatePathwayPriority(a),r.resolved=this.pathwayId!==n,r.resolved||t.details===w.BUFFER_APPEND_ERROR&&!t.fatal||this.warn("Could not resolve "+t.details+' ("'+t.error.message+'") with content-steering for Pathway: '+n+" levels: "+(i?i.length:i)+" priorities: "+Bt(a)+" penalized: "+Bt(this.penalizedPathways)))}},r.filterParsedLevels=function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){var r=e[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length&&this.log("Found "+t.length+"/"+e.length+' levels in Pathway "'+this.pathwayId+'"'),t},r.getLevelsForPathway=function(e){return null===this.levels?[]:this.levels.filter((function(t){return e===t.pathwayId}))},r.updatePathwayPriority=function(e){var t;this._pathwayPriority=e;var r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach((function(e){i-r[e]>3e5&&delete r[e]}));for(var a=0;a0){this.log('Setting Pathway to "'+n+'"'),this.pathwayId=n,ci(t),this.hls.trigger(O.LEVELS_UPDATED,{levels:t});var l=this.hls.levels[s];o&&l&&this.levels&&(l.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&l.bitrate!==o.bitrate&&this.log("Unstable Pathways change from bitrate "+o.bitrate+" to "+l.bitrate),this.hls.nextLoadLevel=s);break}}}},r.getPathwayForGroupId=function(e,t,r){for(var i=this.getLevelsForPathway(r).concat(this.levels||[]),a=0;a0&&n>l.config.fpsDroppedMonitoringThreshold*s){var u=l.currentLevel;l.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=u)&&(u-=1,l.trigger(O.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel}),l.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}},t.checkFPSInterval=function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)},e}(),Ti="NOT_LOADED",Si="APPENDING",Li="PARTIAL",Ri="OK",Ai=function(){function e(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}var t=e.prototype;return t._registerListeners=function(){var e=this.hls;e&&(e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.BUFFER_APPENDED,this.onBufferAppended,this),e.on(O.FRAG_BUFFERED,this.onFragBuffered,this),e.on(O.FRAG_LOADED,this.onFragLoaded,this))},t._unregisterListeners=function(){var e=this.hls;e&&(e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.BUFFER_APPENDED,this.onBufferAppended,this),e.off(O.FRAG_BUFFERED,this.onFragBuffered,this),e.off(O.FRAG_LOADED,this.onFragLoaded,this))},t.destroy=function(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},t.getAppendedFrag=function(e,t){var r=this.activePartLists[t];if(r)for(var i=r.length;i--;){var a=r[i];if(!a)break;if(a.start<=e&&e<=a.end&&a.loaded)return a}return this.getBufferedFrag(e,t)},t.getBufferedFrag=function(e,t){return this.getFragAtPos(e,t,!0)},t.getFragAtPos=function(e,t,r){for(var i=this.fragments,a=Object.keys(i),n=a.length;n--;){var s=i[a[n]];if((null==s?void 0:s.body.type)===t&&(!r||s.buffered)){var o=s.body;if(o.start<=e&&e<=o.end)return o}}return null},t.detectEvictedFragments=function(e,t,r,i,a,n){var s=this;this.timeRanges&&(this.timeRanges[e]=t);var o=(null==a?void 0:a.fragment.sn)||-1;Object.keys(this.fragments).forEach((function(a){var l=s.fragments[a];if(l&&s.hls){var u=l.body;if(!(o>=u.sn))if(l.buffered||l.loaded&&!n){var d=l.range[e];if(d)if(0!==d.time.length){if(d.time.some((function(e){var r=!s.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&s.removeFragment(u),r})),i&&i!==u&&ct()){var h=i.endPTS,f=u.startPTS;if(h&&f&&l.range.video){var c=f-h;c<0&&c>-.1&&(s.removeFragment(u),s.hls.trigger(O.BUFFER_FLUSHING,{startOffset:h+.004,endOffset:1/0,type:"video"}))}}}else s.removeFragment(u)}else u.type===r&&s.removeFragment(u)}}))},t.detectPartialFragments=function(e){var t=this,r=this.timeRanges,i=e.frag,a=e.part,n=e.id;if(r&&G(i)){var s=ki(i),o=this.fragments[s];if(!(!o||o.buffered&&i.gap)){var l=!i.relurl;Object.keys(r).forEach((function(e){var s=i.elementaryStreams[e];if(s){var u=r[e],d=l||!0===s.partial;o.range[e]=t.getBufferedTimes(i,a,d,u),t.detectEvictedFragments(e,u,n,i,a)}})),o.loaded=null;var u=Object.keys(o.range);if(u.length){if(this.bufferedEnd(o,i),bi(o)||this.removeParts(i.sn-1,i.type),!a){var d=Math.min(.004,i.duration);u.some((function(e){var r,a=null==(r=o.range[e])?void 0:r.time,n=0===a.length||1===a.length&&a[0].endPTS-a[0].startPTS=e})))},t.fragBuffered=function(e,t){var r=ki(e),i=this.fragments[r];return!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,this.bufferedEnd(i,e)),i},t.getBufferedTimes=function(e,t,r,i){for(var a={time:[],partial:r},n=e.start,s=e.end,o=e.minEndPTS||s,l=e.maxStartPTS||n,u=0;u=d&&o<=h){a.time.push({startPTS:Math.max(n,i.start(u)),endPTS:Math.min(s,i.end(u))});break}if(nd){var f=Math.max(n,i.start(u)),c=Math.min(s,i.end(u));c>f&&(a.partial=!0,a.time.push({startPTS:f,endPTS:c}))}else if(s<=d)break}return a},t.getPartialFragment=function(e){var t,r,i,a=null,n=0,s=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach((function(l){var u=o[l];u&&bi(u)&&(r=u.body.start-s,i=u.body.end+s,e>=r&&e<=i&&(t=Math.min(e-r,i-e),n<=t&&(a=u.body,n=t)))})),a},t.isEndListAppended=function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||bi(t))},t.getState=function(e){var t=ki(e),r=this.fragments[t];return r?r.buffered?bi(r)?Li:Ri:Si:Ti},t.isTimeBuffered=function(e,t,r){for(var i,a,n=0;n=i&&t<=a)return!0;if(t<=i)return!1}return!1},t.onManifestLoading=function(){this.removeAllFragments()},t.onFragLoaded=function(e,t){if(G(t.frag)&&!t.frag.bitrateTest){var r=t.frag,i=t.part?null:t,a=ki(r);this.fragments[a]={body:r,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}},t.onBufferAppended=function(e,t){var r=t.frag,i=t.part,a=t.timeRanges;if(G(r)){var n=r.type;if(i){var s=this.activePartLists[n];s||(this.activePartLists[n]=s=[]),s.push(i)}this.timeRanges=a}},t.onFragBuffered=function(e,t){this.detectPartialFragments(t)},t.hasFragment=function(e){var t=ki(e);return!!this.fragments[t]},t.hasFragments=function(e){var t=this.fragments,r=Object.keys(t);if(!e)return r.length>0;for(var i=r.length;i--;){var a=t[r[i]];if((null==a?void 0:a.body.type)===e)return!0}return!1},t.hasParts=function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)},t.getBackBufferEvictionEnd=function(e,t,r){for(var i=this.fragments,a=0,n=0,s=Object.keys(i),o=0;o=r))return n}}return n>0?n:0},t.removeFragmentsInRange=function(e,t,r,i,a){var n=this;i&&!this.hasGaps||Object.keys(this.fragments).forEach((function(s){var o=n.fragments[s];if(o){var l=o.body;l.type!==r||i&&!l.gap||l.starte&&(o.buffered||a)&&n.removeFragment(l)}}))},t.removeFragment=function(e){var t=ki(e);e.clearElementaryStreamInfo();var r=this.activePartLists[e.type];if(r){var i=e.sn;this.activePartLists[e.type]=Di(r,(function(e){return e.fragment.sn!==i}))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]},t.gapFragments=function(){var e=this;return this.hasGaps?Object.keys(this.fragments).map((function(t){var r;return null==(r=e.fragments[t])?void 0:r.body})).filter((function(e){return!(null==e||!e.gap)})):[]},t.removeAllFragments=function(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;var t=null==(e=this.hls)||null==(e=e.latestLevelDetails)?void 0:e.partList;t&&t.forEach((function(e){return e.clearElementaryStreamInfo()}))},e}();function bi(e){var t,r,i,a;return e.buffered&&!!(e.body.gap||null!=(t=e.range.video)&&t.partial||null!=(r=e.range.audio)&&r.partial||null!=(i=e.range.audiovideo)&&i.partial||null!=(a=e.range.subs)&&a.partial)}function ki(e){return e.type+"_"+e.level+"_"+e.sn}function Di(e,t){return e.filter((function(e){var r=t(e);return r||e.clearElementaryStreamInfo(),r}))}var Ii=function(){function e(e,t,r){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=r}return e.prototype.decrypt=function(e,t){switch(this.aesMode){case wr:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case Or:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error("[AESCrypto] invalid aes mode "+this.aesMode)}},e}(),_i=function(){function e(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var t=e.prototype;return t.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),i=0;i<4;i++)r[i]=t.getUint32(4*i);return r},t.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,i=r[0],a=r[1],n=r[2],s=r[3],o=this.invSubMix,l=o[0],u=o[1],d=o[2],h=o[3],f=new Uint32Array(256),c=0,g=0,v=0;for(v=0;v<256;v++)f[v]=v<128?v<<1:v<<1^283;for(v=0;v<256;v++){var m=g^g<<1^g<<2^g<<3^g<<4;m=m>>>8^255&m^99,e[c]=m,t[m]=c;var p=f[c],y=f[p],E=f[y],T=257*f[m]^16843008*m;i[c]=T<<24|T>>>8,a[c]=T<<16|T>>>16,n[c]=T<<8|T>>>24,s[c]=T,T=16843009*E^65537*y^257*p^16843008*c,l[m]=T<<24|T>>>8,u[m]=T<<16|T>>>16,d[m]=T<<8|T>>>24,h[m]=T,c?(c=p^f[f[f[E^p]]],g^=f[f[g]]):c=g=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,i=0;i=r.length?r:r.slice(s.start,s.end):(a=(i=r).byteLength,(n=a&&new DataView(i.buffer).getUint8(a-1))?i.slice(0,a-n):i)},t.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},t.decrypt=function(e,t,r,i,a){var n=this;return this.decryptRange=a,this.useSoftware||a?new Promise((function(a,s){var o=ArrayBuffer.isView(e)?e:new Uint8Array(e);n.softwareDecrypt(o,t,r,i);var l=n.flush();l?a(l.buffer):s(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,r,i)},t.softwareDecrypt=function(e,t,r,i){var a=this.currentIV,n=this.currentResult,s=this.remainderData;if(i!==wr||16!==t.byteLength)return fe.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),s&&(e=it(s,e),this.remainderData=null);var o=this.getValidChunk(e);if(!o.length)return null;a&&(r=a);var l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new _i),l.expandKey(t);var u=n;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=o.slice(-16).buffer,u||null},t.webCryptoDecrypt=function(e,t,r,i){var a=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r,i));this.key=t,this.fastAesKey=new Ci(this.subtle,t,i)}return this.fastAesKey.expandKey().then((function(t){return a.subtle?(a.logOnce("WebCrypto AES decrypt"),new Ii(a.subtle,new Uint8Array(r),i).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))})).catch((function(n){return fe.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+n.name+": "+n.message),a.onWebCryptoError(e,t,r,i)}))},t.onWebCryptoError=function(e,t,r,i){var a=this.enableSoftwareAES;if(a){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r,i);var n=this.flush();if(n)return n.buffer}throw new Error("WebCrypto"+(a?" and softwareDecrypt":"")+": failed to decrypt data")},t.getValidChunk=function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=e.slice(0,r),this.remainderData=e.slice(r)),t},t.logOnce=function(e){this.logEnabled&&(fe.log("[decrypter]: "+e),this.logEnabled=!1)},e}(),xi=Math.pow(2,17),wi=function(){function e(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}var t=e.prototype;return t.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},t.abort=function(){this.loader&&this.loader.abort()},t.load=function(e,t,r,i){var a=this,n=e.url;if(!n)return Promise.reject(new Ni({type:x.NETWORK_ERROR,details:w.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(n?"part list":"url")),networkDetails:null}));this.abort();var s=this.config,o=s.fLoader,l=s.loader;return new Promise((function(u,d){if(a.loader&&a.loader.destroy(),e.gap){if(e.tagList.some((function(e){return"GAP"===e[0]})))return void d(Fi(e));e.gap=!1}var h=a.loader=o?new o(s):new l(s),c=Oi(e,null,t);e.loader=h;var g=$(s.fragLoadPolicy.default),v={loadPolicy:g,timeout:g.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:xi};h.stats.retry=e.stats.retry,e.stats=h.stats;var m={onSuccess:function(t,r,i,n){a.resetLoader(e,h);var s=t.data;i.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),u({frag:e,part:null,payload:s,networkDetails:n})},onError:function(t,r,i,s){a.resetLoader(e,h),d(new Ni({type:x.NETWORK_ERROR,details:w.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:f({url:n,data:void 0},t),error:new Error("HTTP Error "+t.code+" "+t.text),networkDetails:i,stats:s}))},onAbort:function(t,r,i){a.resetLoader(e,h),d(new Ni({type:x.NETWORK_ERROR,details:w.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:i,stats:t}))},onTimeout:function(t,r,i){a.resetLoader(e,h),d(new Ni({type:x.NETWORK_ERROR,details:w.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error("Timeout after "+v.timeout+"ms"),networkDetails:i,stats:t}))}};if(r){var p=a.gateProgress(r,i);m.onProgress=function(t,r,i,a){return p({frag:e,part:null,payload:i,networkDetails:a})}}h.load(c,v,m)}))},t.gateProgress=function(e,t){var r=e;if(t){var i=[],a=!1;t.then((function(){a=!0,i.forEach((function(t){return e(t)})),i.length=0})).catch((function(){})),r=function(t){a?e(t):i.push(t)}}return r},t.loadPart=function(e,t,r){var i=this;this.abort();var a=this.config,n=a.fLoader,s=a.loader;return new Promise((function(o,l){if(i.loader&&i.loader.destroy(),e.gap||t.gap)l(Fi(e,t));else{var u=i.loader=n?new n(a):new s(a),d=Oi(e,t);e.loader=u;var h=$(a.fragLoadPolicy.default),c={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:xi};t.stats=u.stats,u.load(d,c,{onSuccess:function(a,n,s,l){i.resetLoader(e,u),i.updateStatsFromPart(e,t);var d={frag:e,part:t,payload:a.data,networkDetails:l};r(d),o(d)},onError:function(r,a,n,s){i.resetLoader(e,u),l(new Ni({type:x.NETWORK_ERROR,details:w.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:f({url:d.url,data:void 0},r),error:new Error("HTTP Error "+r.code+" "+r.text),networkDetails:n,stats:s}))},onAbort:function(r,a,n){e.stats.aborted=t.stats.aborted,i.resetLoader(e,u),l(new Ni({type:x.NETWORK_ERROR,details:w.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:n,stats:r}))},onTimeout:function(r,a,n){i.resetLoader(e,u),l(new Ni({type:x.NETWORK_ERROR,details:w.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error("Timeout after "+c.timeout+"ms"),networkDetails:n,stats:r}))}})}}))},t.updateStatsFromPart=function(e,t){var r=e.stats,i=t.stats,a=i.total;if(r.loaded+=i.loaded,a){var n=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/a),n),o=(n-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var l=r.loading,u=i.loading;l.start?l.first+=u.first-u.start:(l.start=u.start,l.first=u.first),l.end=u.end},t.resetLoader=function(e,t){e.loader=null,e.url=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()},e}();function Oi(e,t,r){void 0===t&&(t=null);var i=t||e,a={type:F.MEDIA_FRAGMENT,frag:e,part:t,responseType:"arraybuffer",url:i.url,headers:{},rangeStart:0,rangeEnd:0},n=Mi(e,t,r);return n.resetIV&&(a.resetIV=!0),n.byteRange&&(a.rangeStart=n.byteRange.start,a.rangeEnd=n.byteRange.end),a}function Mi(e,t,r){void 0===t&&(t=null);var i,a,n={},s=t||e,o=s.byteRangeStartOffset,l=s.byteRangeEndOffset;if(_(o)&&_(l))if("initSegment"!==e.sn&&!r||"AES-128"!==(a=null==(i=e.decryptdata)?void 0:i.method)&&"AES-256"!==a)n.byteRange={start:o,end:l};else{var u=16*Math.floor(o/16),d=16*Math.ceil(l/16);n.decryptRange={start:o-u,end:l-u},u>=16&&(n.resetIV=!0,u-=16),n.byteRange={start:u,end:d}}return n}function Fi(e,t){var r=new Error("GAP "+(e.gap?"tag":"attribute")+" found"),i={type:x.MEDIA_ERROR,details:w.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new Ni(i)}var Ni=function(e){function t(t){var r;return(r=e.call(this,t.error.message)||this).data=void 0,r.data=t,r}return u(t,e),t}(v(Error)),Bi=function(e){function t(t,r){var i;return(i=e.call(this,t,r)||this)._boundTick=void 0,i._tickTimer=null,i._tickInterval=null,i._tickCallCount=0,i._boundTick=i.tick.bind(i),i}u(t,e);var r=t.prototype;return r.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},r.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},r.onHandlerDestroyed=function(){},r.hasInterval=function(){return!!this._tickInterval},r.hasNextTick=function(){return!!this._tickTimer},r.setInterval=function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)},r.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},r.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},r.tick=function(){this._tickCallCount++,1===this._tickCallCount?(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0):(this.log("possible exception thrown in task-loop ("+this.constructor.name+".doTick)"),this._tickCallCount=0)},r.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},r.doTick=function(){},t}(ie),Ui=function(e,t,r,i,a,n,s,o,l){void 0===i&&(i=0),void 0===a&&(a=-1),void 0===n&&(n=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.iframe=void 0,this.duration=void 0,this.decryptRange=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=e,this.sn=t,this.id=r,this.size=i,this.part=a,this.partial=n,this.duration=s||0,this.decryptRange=l,this.iframe=o||!1};function Gi(e,t){for(var r=0,i=e.length;re.startCC)}(t,e)){var i=Math.min(t.endCC,e.endCC),a=Gi(t.fragments,i),n=Gi(e.fragments,i);if(a&&n){var s=a.start-n.start;r.log("Aligning playlists using dicontinuity sequence "+i+" (diff: "+s+")"),Hi(s,e)}}}(t,e,r),t.alignedSliding||function(e,t,r){if(e.hasProgramDateTime&&t.hasProgramDateTime){var i,a,n=e.fragments,s=t.fragments;if(n.length&&s.length){var o=Math.min(t.endCC,e.endCC);t.startCCMath.max(60,e.totalduration))r.log("Cannot align playlists using PDT without overlap ("+Math.abs(d)+" > "+e.totalduration+")");else{var h=d-(a.start-i.start);r.log("Aligning playlists using PDT (diff: "+h+")"),Hi(h,e)}}}}}(t,e,r),t.alignedSliding||t.skippedSegments||li(e,t,!1,r))}var Yi={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_LEVEL:"WAITING_LEVEL"},Wi=function(e){function t(t,r,i,a,n){var s;return(s=e.call(this,a,t.logger)||this).hls=void 0,s.fragPrevious=null,s.fragCurrent=null,s.fragPlaying=null,s.fragmentTracker=void 0,s.transmuxer=null,s._state=Yi.STOPPED,s.playlistType=void 0,s.media=null,s.mediaBuffer=null,s.config=void 0,s.bitrateTest=!1,s.lastCurrentTime=0,s.nextLoadPosition=0,s.startPosition=-1,s.startTimeOffset=null,s.retryDate=0,s.levels=null,s.fragmentLoader=void 0,s.initFragmentLoader=void 0,s.keyLoader=void 0,s.levelLastLoaded=null,s.startFragRequested=!1,s.decrypter=void 0,s.initPTS=[],s.buffering=!0,s.loadingParts=!1,s.loopSn=void 0,s.onMediaSeeking=function(){var e,t=s,r=t.config,i=t.fragCurrent,a=t.media,n=t.mediaBuffer,o=t.state,l=a?a.currentTime:0,u=dr.bufferInfo(n||a,l,r.maxBufferHole),d=u.len;if(s.log("Media seeking to "+l+", state: "+o+", "+(d?"in":"out of")+" buffer"),s.state===Yi.ENDED)s.resetLoadingState();else if(i){var h=r.maxFragLookUpTolerance,f=i.start-h,c=i.start+i.duration+h;if(!d||cu.end){var g=lc;(g||v)&&(!i.loader||!v&&s.isFragmentNearlyDownloaded(i)?s.fragPrevious=null:(s.log("Cancelling fragment load for seek (sn: "+i.sn+") - "+(g?"backward":"forward")+" seek"),i.abortRequests(),s.resetLoadingState()))}}if(a&&(null!=(e=s.hls)&&e.hasEnoughToStart&&!d&&l!==s.startPosition&&s.fragmentTracker.removeFragmentsInRange(l,1/0,s.playlistType,!0),l>s.lastCurrentTime&&(s.lastCurrentTime=l),!s.loadingParts)){var m=Math.max(u.end,l),p=s.shouldLoadParts(s.getLevelDetails(),m);p&&(s.log("LL-Part loading ON after seeking to "+l+" with buffer @"+m),s.loadingParts=p)}var y=!dr.isBuffered(a,l);s.hls.hasEnoughToStart&&!y||(s.log("Setting "+(y?"startPosition":"nextLoadPosition")+" to "+l+" for seek without enough to start"),s.nextLoadPosition=l,y?s.startPosition=l:s.lastCurrentTime=l),d<1&&s.state===Yi.IDLE&&s.tickImmediate()},s.onMediaEnded=function(){s.log("setting startPosition to 0 because media ended"),s.startPosition=s.nextLoadPosition=s.lastCurrentTime=0},s.playlistType=n,s.hls=t,s.fragmentLoader=new wi(t.config),s.initFragmentLoader=new wi(t.config),s.keyLoader=i,s.fragmentTracker=r,s.config=t.config,s.decrypter=new Pi(t.config),s}u(t,e);var r=t.prototype;return r.registerListeners=function(){var e=this.hls;e.on(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(O.ERROR,this.onError,this)},r.unregisterListeners=function(){var e=this.hls;e.off(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(O.ERROR,this.onError,this)},r.doTick=function(){},r.onTickEnd=function(){var e=this.media;null!=e&&e.readyState&&!1===e.seeking&&(this.lastCurrentTime=e.currentTime)},r.startLoad=function(e){},r.stopLoad=function(){if(this.state!==Yi.STOPPED){this.fragmentLoader.abort(),this.initFragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Yi.STOPPED}},r.pauseBuffering=function(){this.buffering=!1},r.resumeBuffering=function(){this.buffering=!0},r._streamEnded=function(e,t){if(t.live||!this.media)return!1;var r=e.end||0,i=this.config.timelineOffset||0;if(r<=i)return!1;var a=e.buffered;this.config.maxBufferHole&&a&&a.length>1&&(e=dr.bufferedInfo(a,e.start,0));var n=e.nextStart;if(n&&n>i&&n0&&null!=n&&n.key&&n.iv&&Mr(n.method)){var s=self.performance.now(),o=Mi(i,null,t.iframesOnly).decryptRange;return t.decrypter.decrypt(new Uint8Array(a),n.key.buffer,n.iv.buffer,Fr(n.method),o).catch((function(e){throw r.trigger(O.ERROR,{type:x.MEDIA_ERROR,details:w.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),t.fragmentLoader.abort(),e})).then((function(a){var n=self.performance.now();return r.trigger(O.FRAG_DECRYPTED,{frag:i,part:null,payload:a,stats:{tstart:s,tdecrypt:n}}),e.payload=a,t.completeInitSegmentLoad(e)}))}return t.completeInitSegmentLoad(e)}))},r.completeInitSegmentLoad=function(e){var t=e.frag.stats;e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now()},r.loadInitSegmentIfNeeded=function(e){var t,r=this,i=e.initSegment;if(!this.bitrateTest&&G(e)&&i&&!i.data)return(!i.encrypted||null!=(t=i.decryptdata)&&t.key?this._loadInitSegment(i):this.keyLoader.load(i).then((function(){return r._loadInitSegment(i)}))).catch((function(t){if(r.state===Yi.STOPPED||r.state===Yi.ERROR)throw t;throw"data"in t&&(r.fragmentLoader.abort(),r.handleFragLoadError(t,e)),r.resetFragmentLoading(e),t}))},r.unhandledEncryptionError=function(e,t){var r,i,a=e.tracks;if(a&&!t.encrypted&&(null!=(r=a.audio)&&r.encrypted||null!=(i=a.video)&&i.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){var n=this.media,s=new Error("EME not supported (light build)");return this.warn(s.message),!(!n||n.mediaKeys)&&(this.hls.trigger(O.ERROR,{type:x.KEY_SYSTEM_ERROR,details:w.KEY_SYSTEM_NO_KEYS,fatal:!0,error:s,frag:t}),this.resetTransmuxer(),!0)}return!1},r.fragContextChanged=function(e){var t=this.fragCurrent;return!e||!H(e,t)},r.fragBufferedComplete=function(e,t){var r=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+this.fragInfo(e,!1,t)+" > buffer:"+(r?cr(dr.getBuffered(r)):"(detached)")+")"),G(e)){var i;if(e.type!==N.SUBTITLE){var a=e.elementaryStreams;if(!Object.keys(a).some((function(e){return!!a[e]})))return void(this.state=Yi.IDLE)}var n=null==(i=this.levels)?void 0:i[e.level];null!=n&&n.fragmentError&&(t||this.fragmentTracker.getState(e)!==Li)&&(this.log("Resetting level fragment error count of "+n.fragmentError+" on frag buffered"),n.fragmentError=0,e.stats.retry=0)}this.state=Yi.IDLE},r._handleFragmentLoadComplete=function(e){var t=this.transmuxer;if(t){var r=e.frag,i=e.part,a=e.partsLoaded,n=!a||0===a.length||a.some((function(e){return!e})),s=Mi(r,i).decryptRange,o=new Ui(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!n,r.duration,this.iframesOnly,s);this.log("load complete "+r.type+" sn: "+r.sn+(i?" part: "+i.index:"")+" of "+this.fragInfo(r,!1,i)),t.flush(o)}},r._handleFragmentLoadProgress=function(e){},r.loadKeyFor=function(e,t,r){var i,a=this,n=null;return!e.encrypted||null!=(i=e.decryptdata)&&i.key?e.encrypted||(n=this.keyLoader.loadClear(e,t.encryptedFragments,this.startFragRequested))&&this.log("[eme] blocking frag sn: "+e.sn+" load until media-keys acquired"):(this.log("Loading key for "+e.sn+" of ["+t.startSN+"-"+t.endSN+"], "+this.playlistLabel()+" "+e.level),this.state=Yi.KEY_LOADING,n=this.keyLoader.load(e,r).then((function(e){if(!a.fragContextChanged(e.frag))return a.hls.trigger(O.KEY_LOADED,e),a.state===Yi.KEY_LOADING&&(a.state=Yi.IDLE),e})),this.hls.trigger(O.KEY_LOADING,{frag:e})),n},r._doFragLoad=function(e,t,r,i){var a=this;void 0===r&&(r=null),this.fragCurrent=e;var n=t.details;if(!this.levels||!n)throw new Error("frag load aborted, missing level"+(n?"":" detail")+"s");var s,o=this.fragPrevious;if(!V(e,o)){var l=this.shouldLoadParts(t.details,e.end);l!==this.loadingParts&&(this.log("LL-Part loading "+(l?"ON":"OFF")+" loading sn "+(null==o?void 0:o.sn)+"->"+e.sn),this.loadingParts=l)}if(r=Math.max(e.start,r||0),this.loadingParts){var u=n.partList;if(u&&i){r>n.fragmentEnd&&n.fragmentHint&&(e=n.fragmentHint);var d=this.getNextPart(u,e,r);if(d>-1){var h=u[d];if(!V(e=this.fragCurrent=h.fragment,o)&&!this.shouldLoadParts(t.details,e.end))return this.log("LL-Part loading OFF @"+this.playhead+" next part: "+this.fragInfo(e,!1,h)),this.loadingParts=!1,Promise.resolve(null);if(!this.filterReplacedPrimary(h,t.details))return Promise.resolve(null);var f,c=this.loadKeyFor(e,n);if(this.fragContextChanged(e))return Promise.resolve(null);this.log("Loading "+e.type+" sn: "+e.sn+" part: "+h.index+" ("+d+"/"+(u.length-1)+") of "+this.fragInfo(e,!1,h)+" cc: "+e.cc+" ["+n.startSN+"-"+n.endSN+"], target: "+r+(h.byteRange.length?" range:"+h.byteRange.join("-"):"")),this.nextLoadPosition=h.start+h.duration,this.state=Yi.FRAG_LOADING;var g=this.loadInitSegmentIfNeeded(e);if(c||g){var v=!!c;f=Promise.all([c,g]).then((function(r){var n=r[0];return!v||n&&!a.fragContextChanged(n.frag)?a.doFragPartsLoad(e,h,t,i):null})).catch((function(t){return a.handleFragLoadError(t,e)}))}else f=this.doFragPartsLoad(e,h,t,i).catch((function(t){return a.handleFragLoadError(t,e)}));return this.hls.trigger(O.FRAG_LOADING,{frag:e,part:h,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}if(!e.url||this.loadedEndOfParts(u,r))return Promise.resolve(null)}}if(this.loadingParts)this.log("LL-Part loading OFF after next part miss @"+r+" Check buffer at sn: "+e.sn+" loaded parts: "+(null==(s=n.partList)?void 0:s.filter((function(e){return e.loaded})).map((function(e){return"["+e.start+"-"+e.end+"]"})))),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);if(!this.filterReplacedPrimary(e,t.details))return Promise.resolve(null);var m,p=this.loadInitSegmentIfNeeded(e),y=this.loadKeyFor(e,n,p);if(this.fragContextChanged(e))return this.log("Context changed in KEY_LOADING sn: "+e.sn+" "+e.relurl+" > "+(null==(m=this.fragCurrent)?void 0:m.relurl)),null==p||p.catch((function(){return null})),null==y||y.catch((function(){return null})),Promise.resolve(null);this.log("Loading "+e.type+" sn: "+e.sn+" of "+this.fragInfo(e,!1)+" cc: "+e.cc+" ["+n.startSN+"-"+n.endSN+"], target: "+r+(e.byteRange.length?" range:"+e.byteRange.join("-"):"")),_(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=Yi.FRAG_LOADING;var E,T=this.config.progressive&&e.type!==N.SUBTITLE;return E=T&&y?y.then((function(t){return!t||a.fragContextChanged(t.frag)?null:a.fragmentLoader.load(e,a.iframesOnly,i,p)})).catch((function(t){return a.handleFragLoadError(t,e)})):Promise.all([this.fragmentLoader.load(e,this.iframesOnly,T?i:void 0,T?p:void 0),y,p]).then((function(e){var t=e[0];return!T&&i&&i(t),t})).catch((function(t){return a.handleFragLoadError(t,e)})),this.hls.trigger(O.FRAG_LOADING,{frag:e,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):Promise.all([E,p]).then((function(e){return e[0]}))},r.doFragPartsLoad=function(e,t,r,i){var a=this;return new Promise((function(n,s){var o,l=[],u=null==(o=r.details)?void 0:o.partList,d=function(t){a.fragmentLoader.loadPart(e,t,i).then((function(i){l[t.index]=i;var s=i.part;a.hls.trigger(O.FRAG_LOADED,i);var o=hi(r.details,e.sn,t.index+1)||fi(u,e.sn,t.index+1);if(!o)return n({frag:e,part:s,partsLoaded:l});d(o)})).catch(s)};d(t)}))},r.handleFragLoadError=function(e,t){if("data"in e){var r=e.data;r.details===w.INTERNAL_ABORTED?this.handleFragLoadAborted(t,r.part):r.type!==x.KEY_SYSTEM_ERROR||r.fatal||(t.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t)),r.frag!==t?(r.frag&&this.warn(r.details+" error cascading from "+this.fragInfo(r.frag,!1,r.part)+" to "+this.fragInfo(t,!1)),this.hls.trigger(O.ERROR,f(f({},r),{},{frag:t}))):this.hls.trigger(O.ERROR,r)}else this.hls.trigger(O.ERROR,{type:x.OTHER_ERROR,details:w.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null},r._handleTransmuxerFlush=function(e){var t=this.getCurrentContext(e);if(t&&this.state===Yi.PARSING){var r=t.frag,i=t.part,a=t.level,n=self.performance.now();r.stats.parsing.end=n,i&&(i.stats.parsing.end=n);var s=this.getLevelDetails(),o=s&&r.sn>s.endSN||this.shouldLoadParts(s,r.end);o!==this.loadingParts&&(this.log("LL-Part loading "+(o?"ON":"OFF")+" after parsing segment ending @"+r.end),this.loadingParts=o),this.updateLevelTiming(r,i,a,e)}else this.fragCurrent||this.state===Yi.STOPPED||this.state===Yi.ERROR||(this.state=Yi.IDLE)},r.shouldLoadParts=function(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList&&!this.iframesOnly){var r,i=e.partList[0];if(t>=i.end+((null==(r=e.fragmentHint)?void 0:r.duration)||0)&&this.playhead>i.start-i.fragment.duration)return!0}}return!1},r.getCurrentContext=function(e){var t=this.levels,r=this.fragCurrent,i=e.level,a=e.sn,n=e.part;if(null==t||!t[i])return this.warn("Levels object was unset while buffering fragment "+a+" of "+this.playlistLabel()+" "+i+". The current chunk will not be buffered."),null;var s=t[i],o=s.details,l=n>-1?hi(o,a,n):null,u=l?l.fragment:di(o,a,r);return u?(r&&r!==u&&(u.stats=r.stats),{frag:u,part:l,level:s}):null},r.bufferFragmentData=function(e,t,r,i,a){if(this.state===Yi.PARSING){G(t)&&!this.fragContextChanged(t)&&(this.fragPrevious=t);var n=e.data1,s=e.data2,o=n;if(s&&(o=it(n,s)),o.length){var l=this.initPTS[t.cc],u=l?-l.baseTime/l.timescale:void 0,d={type:e.type,frag:t,part:r,chunkMeta:i,offset:u,parent:t.type,data:o};if(this.hls.trigger(O.BUFFER_APPENDING,d),e.dropped&&e.independent&&!r){if(a)return;this.flushBufferGap(t)}}}},r.flushBufferGap=function(e){var t=this.media;if(t)if(dr.isBuffered(t,t.currentTime)){var r=t.currentTime,i=dr.bufferInfo(t,r,0),a=e.duration,n=Math.min(2*this.config.maxFragLookUpTolerance,.25*a),s=Math.max(Math.min(e.start-n,i.end-n),r+n);e.start-s>n&&this.flushMainBuffer(s,e.start)}else this.flushMainBuffer(0,e.start)},r.getFwdBufferInfo=function(e,t){var r,i=this.playhead,a=this.lastCurrentTime>i||null!=(r=this.media)&&r.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,i,t,a)},r.getFwdBufferInfoAtPos=function(e,t,r,i){var a=dr.bufferInfo(e,t,i);if(0===a.len&&void 0!==a.nextStart){var n=this.fragmentTracker.getBufferedFrag(t,r);if(n&&(a.nextStart<=n.end||n.gap)){var s=Math.max(Math.min(a.nextStart,n.end)-t,i);return dr.bufferInfo(e,t,s)}}return a},r.getMaxBufferLength=function(e){var t,r=this.config;return t=e?Math.max(8*r.maxBufferSize/e,r.maxBufferLength):r.maxBufferLength,Math.min(t,r.maxMaxBufferLength)},r.exceedsMaxBuffer=function(e,t,r){var i=e.nextStart;if(i&&r.start>i){var a=e.buffered;if(a){for(var n=e.len,s=e.bufferedIndex,o=a.length-1;o>s;o--)a[o].start=t}}return!1},r.reduceMaxBufferLength=function(e,t){var r=this.config,i=Math.max(Math.min(e-t,r.maxBufferLength),t/2),a=Math.max(e-3*t,r.maxMaxBufferLength/2,i);return a>=i&&(r.maxMaxBufferLength=a,this.warn("Reduce max buffer length to "+a+"s"),!0)},r.getAppendedFrag=function(e){var t=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,this.playlistType):null;return t&&"fragment"in t?t.fragment:t},r.getNextFragment=function(e,t){var r=t.fragments,i=r.length;if(!i)return null;var a=this.config,n=t.fragmentStart,s=a.lowLatencyMode&&!!t.partList,o=null;if(t.live){var l=a.initialLiveManifestSize;if(i=n?(d=c,h=c===f?"config":"next load start"):g?(d=g,h="live edge"):(d=e,h="buffer pos"),d1)return!0}return!1},r.getNextFragmentLoopLoading=function(e,t,r,i,a){var n=null;if(e.gap&&(n=this.getNextFragment(this.nextLoadPosition,t))&&!n.gap&&r.nextStart){var s=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i,0);if(null!==s&&r.len+s.len>=a){var o=n.sn;return this.loopSn!==o&&(this.log('buffer full after gaps in "'+i+'" playlist starting at sn: '+o),this.loopSn=o),null}}return this.loopSn=void 0,n},r.filterReplacedPrimary=function(e,t){return e?(this.config,e):e},r.getNextPart=function(e,t,r){for(var i=-1,a=!1,n=!0,s=0,o=e.length;s-1&&r "+d.fragment.sn+")"),i},r.loadedEndOfParts=function(e,t){for(var r,i=e.length;i--;){if(!(r=e[i]).loaded)return!1;if(t>r.start)return!0}return!1},r.getInitialLiveFragment=function(e){var t=e.fragments,r=this.fragPrevious,i=null;if(r){if(e.hasProgramDateTime&&(i=function(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!_(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;for(var i=0;i=e.startSN&&a<=e.endSN){var n=t[a-e.startSN];r.cc===n.cc&&(i=n,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}i||(i=function(e,t,r){if(e&&e.startCC<=t&&e.endCC>=t){var i,a=e.fragments,n=e.fragmentHint;return n&&(a=a.concat(n)),Yt(a,(function(e){return e.cct?-1:(i=e,e.end<=r?1:e.start>r?-1:0)})),i||null}return null}(e,r.cc,r.end),i&&this.log("Live playlist, switching playlist, load frag with same CC: "+i.sn))}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i},r.getFragmentAtPosition=function(e,t,r){var i,a,n=this.config,s=this.fragPrevious,o=r.fragments,l=r.endSN,u=r.fragmentHint,d=n.maxFragLookUpTolerance,h=r.partList,f=!!(this.loadingParts&&null!=h&&h.length&&u);if(f&&!this.bitrateTest&&h[h.length-1].fragment.sn===u.sn&&(o=o.concat(u),l=u.sn),s&&this.fragmentTracker.getState(s)===Ti&&(s=null),i=et-d||null!=(a=this.media)&&a.paused||this.loadingParts||!this.startFragRequested?0:d):o[o.length-1]){var c=i.sn,g=c-r.startSN,v=this.fragmentTracker.getState(i);if((v===Ri||v===Li&&i.gap)&&(s=i),V(i,s)&&(!f||h[0].fragment.sn>c||!r.live||!h.some((function(e){return e.fragment.sn===c&&!e.loaded&&!e.gap})))){var m=o[g+1];i=i.sn"+e.startSN+" fragments: "+i),o}return a},r.waitForCdnTuneIn=function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)},r.setStartPosition=function(e,t){var r=this.startPosition;r=0&&(r=this.nextLoadPosition),r},r.handleFragLoadAborted=function(e,t){this.transmuxer&&e.type===this.playlistType&&G(e)&&e.stats.aborted&&(this.log("Fragment "+e.sn+(t?" part "+t.index:"")+" of "+this.playlistLabel()+" "+e.level+" was aborted"),this.resetFragmentLoading(e))},r.resetFragmentLoading=function(e){this.state!==Yi.STOPPED&&(this.fragCurrent&&(this.fragContextChanged(e)||this.state===Yi.FRAG_LOADING_WAITING_RETRY)||(this.state=Yi.IDLE))},r.onFragmentOrKeyLoadError=function(e,t){if(t.chunkMeta&&!t.frag){var r=this.getCurrentContext(t.chunkMeta);r&&(t.frag=r.frag)}var i=t.frag,a=t.part;if(i&&this.levels&&i.type===e)if(this.fragContextChanged(i)){var n;this.warn("Frag load error must match current frag to retry "+i.relurl+" > "+(null==(n=this.fragCurrent)?void 0:n.relurl))}else{var s=t.details===w.FRAG_GAP;s&&this.fragmentTracker.addAsGap(i);var o=t.errorAction;if(o){var l=o.action,u=o.flags,d=o.retryCount,h=void 0===d?0:d,f=o.retryConfig,c=!!f,g=c&&l===$t,v=c&&!o.resolved&&u&Jt,m=this.hls.latestLevelDetails,p=null==m?void 0:m.live;if(!g&&v&&G(i)&&p&&i.sn=t||r&&!J(0))&&(r&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=Yi.IDLE)},r.reduceLengthAndFlushBuffer=function(e){if(this.state===Yi.PARSING||this.state===Yi.PARSED){var t=e.frag,r=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,r),a=i&&i.len>.5;a&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);var n=!a;return n?this.warn("Buffer full error while media.currentTime ("+this.playhead+") is not buffered, flush "+r+" buffer"):i.nextStart&&t&&i.nextStart>t.start&&this.flushMainBuffer(i.nextStart,Number.POSITIVE_INFINITY,r===N.AUDIO?r:void 0),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),n}return!1},r.resetFragmentErrors=function(e){e===N.AUDIO&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==Yi.STOPPED&&(this.state=Yi.IDLE)},r.afterBufferFlushed=function(e,t){if(e){var r=dr.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,r,this.playlistType),this.state===Yi.ENDED&&this.resetLoadingState()}},r.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==Yi.STOPPED&&(this.state=Yi.IDLE)},r.resetStartWhenNotLoaded=function(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var e=this.getLevelDetails();null!=e&&e.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(e,e.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},r.resetWhenMissingContext=function(e){this.log("Loading context changed while buffering sn "+e.sn+" of "+this.playlistLabel()+" "+(-1===e.level?"":e.level)+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()},r.removeUnbufferedFrags=function(e){void 0===e&&(e=0),this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)},r.updateLevelTiming=function(e,t,r,i){var a=this,n=r.details;if(n){if(this.log("update level timing "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+this.fragInfo(e,!1,t)),!Object.keys(e.elementaryStreams).reduce((function(s,o){var l=e.elementaryStreams[o];if(l){var u=l.endPTS-l.startPTS;if(u<=0)return a.warn("Could not parse fragment "+e.sn+" "+o+" duration reliably ("+u+")"),s||!1;var d=0;return i.partial?t&&0===i.part&&(d=t.start-l.startPTS,e.startPTS=e.maxStartPTS=l.startPTS,e.startDTS=l.startDTS,0!==e.start&&e.setStart(l.startPTS),ni(n,e,d)):d=ai(n,e,l.startPTS,l.endPTS,l.startDTS,l.endDTS,a.iframesOnly,a),a.hls.trigger(O.LEVEL_PTS_UPDATED,{details:n,level:r,drift:d,type:o,frag:e,part:t,start:l.startPTS,end:l.endPTS}),!0}return s}),!1)){var s,o,l,u,d=null===(null==(s=this.transmuxer)?void 0:s.error),h=null!=(null==(o=this.transmuxer)?void 0:o.error),f=(null!=(l=null==(u=this.levels)?void 0:u.length)?l:0)>1;if((0===r.fragmentError||d&&(r.fragmentError<2||e.endList)||h&&f)&&this.treatAsGap(e,r),d){var c=new Error("Found no media in "+this.playlistLabel()+" "+e.level+" "+(t?"part: "+t.index+" of ":"")+"sn: "+e.sn+" at playlist time: "+e.start+". Resetting transmuxer to fallback to playlist timing");if(this.warn(c.message),this.hls.trigger(O.ERROR,{type:x.MEDIA_ERROR,details:w.FRAG_PARSING_ERROR,fatal:!1,error:c,frag:e,reason:"Found no media in msn "+e.sn+" of "+this.playlistLabel()+' "'+r.url+'"'}),!this.hls)return;this.resetTransmuxer()}}this.state=Yi.PARSED,this.log("Parsed "+e.type+" sn: "+e.sn+(t?" part: "+t.index:"")+" of "+this.fragInfo(e,!1,t)),this.hls.trigger(O.FRAG_PARSED,{frag:e,part:t,chunkMeta:i})}else this.warn("level.details undefined")},r.playlistLabel=function(){return this.playlistType+" playlist"},r.fragInfo=function(e,t,r){var i,a;return void 0===t&&(t=!0),e.type+" playlist "+e.level+" ("+(r?"part":"frag")+":["+(null!=(i=t&&!r?e.startPTS:(r||e).start)?i:NaN)+"-"+(null!=(a=t&&!r?e.endPTS:(r||e).end)?a:NaN)+"]"+(r&&"main"===e.type?"INDEPENDENT="+(r.independent?"YES":"NO"):"")+")"},r.treatAsGap=function(e,t){t&&t.fragmentError++,this.fragmentTracker.addAsGap(e)},r.resetTransmuxer=function(){var e;null==(e=this.transmuxer)||e.reset()},r.isFragmentNearlyDownloaded=function(e){var t,r=null==(t=e.loader)?void 0:t.stats;if(!r)return!1;if(r.total<=0)return!1;var i=r.loading.first>0,a=8*(r.total-r.loaded)/(this.hls.bandwidthEstimate||this.hls.config.abrEwmaDefaultEstimate);return i&&a<=.15},r.recoverWorkerError=function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())},r.calculateOptimalSwitchPoint=function(e,t){var r=0,i=this.hls,a=this.media,n=this.config,s=this.levels,o=this.playlistType,l=this.getLevelDetails();if(a&&!a.paused&&s){var u,d=o===N.AUDIO?ce.estimatedAudioBitrate(e.audioCodec,128e3):e.maxBitrate,h=1+i.ttfbEstimate/1e3,f=i.bandwidthEstimate*n.abrBandWidthUpFactor;r=h+d*(l&&(this.loadingParts?l.partTarget:l.averagetargetduration)||(null==(u=this.fragCurrent)?void 0:u.duration)||6)/f,e.details||(r+=h)}var c=this.playhead;return{fetchdelay:r,okToFlushForwardBuffer:!(null!=l&&l.live)||t.end-c>1.5*r}},r.scheduleTrackSwitch=function(e,t,r){var i=this.media,a=this.playlistType;if(i&&e){var n=r?this.getBufferedFrag(this.playhead+t):null;if(n){var s=this.followingBufferedFrag(n);if(s){var o;this.abortCurrentFrag();var l=s.maxStartPTS?s.maxStartPTS:s.start,u=s.duration,d=Math.max(n.end,l+Math.min(Math.max(u-this.config.maxFragLookUpTolerance,u*(this.couldBacktrack?.5:.125)),u*(this.couldBacktrack?.75:.25)));if(((null==(o=this.getLevelDetails())?void 0:o.fragmentStart)||0)>d)return;var h=a===N.MAIN?null:"audio";this.flushMainBuffer(d,Number.POSITIVE_INFINITY,h),this.cleanupBackBuffer()}}}},r.cleanupBackBuffer=function(){var e=this.media,t=this.playlistType;if(e){var r=this.getAppendedFrag(this.playhead);if(r&&r.start>1){var i=t===N.AUDIO;this.flushMainBuffer(0,r.start-(i?0:1),i?"audio":null)}}},r.getBufferedFrag=function(e){return this.fragmentTracker.getBufferedFrag(e,this.playlistType)},r.followingBufferedFrag=function(e){return e?this.getBufferedFrag(e.end+.5):null},r.abortCurrentFrag=function(){var e,t=this.fragCurrent;switch(this.fragCurrent=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case Yi.KEY_LOADING:case Yi.FRAG_LOADING:case Yi.FRAG_LOADING_WAITING_RETRY:case Yi.PARSING:case Yi.PARSED:this.state=Yi.IDLE}this.nextLoadPosition=null!=(e=this.hls)&&e.hasEnoughToStart?this.playhead:this.lastCurrentTime},r.checkFragPlaying=function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var r=e.currentTime;if(dr.isBuffered(e,r)?t=this.getAppendedFrag(r):dr.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t&&(this.backtrackFragment=void 0,!V(t,this.fragPlaying)))return this.fragPlaying=t,!0}return!1},r.getBufferOutput=function(){return null},r.nextLevelSwitch=function(){var e=this.levels,t=this.media,r=this.hls,i=this.config,a=this.playlistType;if(null!=t&&t.readyState&&e&&r&&i){var n=this.getBufferOutput(),s=this.getFwdBufferInfo(n,a);if(!s)return;var o=e[a===N.AUDIO?r.nextAudioTrack:r.nextLoadLevel],l=this.calculateOptimalSwitchPoint(o,s),u=l.fetchdelay,d=l.okToFlushForwardBuffer;this.scheduleTrackSwitch(s,u,d)}this.tickImmediate()},a(t,[{key:"startPositionValue",get:function(){var e=this.nextLoadPosition,t=this.startPosition;if(-1===t&&e){var r=this.getLevelDetails();return null!=r&&r.live?(this.hls.liveSyncPosition||r.fragmentStart)+this.timelineOffset:e}return t}},{key:"bufferingEnabled",get:function(){return this.buffering}},{key:"backtrackFragment",get:function(){},set:function(e){}},{key:"couldBacktrack",get:function(){return!1},set:function(e){}},{key:"inFlightFrag",get:function(){return{frag:this.fragCurrent,state:this.state}}},{key:"timelineOffset",get:function(){var e,t=this.config.timelineOffset;return t?(null==(e=this.getLevelDetails())?void 0:e.appliedTimelineOffset)||t:0}},{key:"primaryPrefetch",get:function(){return this.config,!1}},{key:"playhead",get:function(){var e;if(null!=(e=this.hls)&&e.hasEnoughToStart){var t,r=null==(t=this.media)?void 0:t.currentTime;return _(r)?r:this.lastCurrentTime}return this.getLoadPosition()}},{key:"iframesOnly",get:function(){var e;if(this.playlistType!==N.MAIN)return!1;var t=this.getLevelDetails();return t?t.iframesOnly:null==(e=this.levelLastLoaded)?void 0:e.iframes}},{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}}])}(Bi),ji=function(e){function t(t,r){var i;return(i=e.call(this,"gap-controller",t.logger)||this).hls=void 0,i.fragmentTracker=void 0,i.media=null,i.mediaSource=void 0,i.nudgeRetry=0,i.skipRetry=0,i.stallReported=!1,i.stalled=null,i.moved=!1,i.seeking=!1,i.buffered={},i.lastCurrentTime=void 0,i.ended=0,i.waiting=0,i.onMediaPlaying=function(){i.ended=0,i.waiting=0},i.onMediaWaiting=function(){var e;null!=(e=i.media)&&e.seeking||(i.waiting=self.performance.now(),i.tick())},i.onMediaEnded=function(){var e;i.hls&&(i.ended=(null==(e=i.media)?void 0:e.currentTime)||1,i.hls.trigger(O.MEDIA_ENDED,{stalled:!1}))},i.hls=t,i.fragmentTracker=r,i.lastCurrentTime=i.getCurrentTime(),i.registerListeners(),i}u(t,e);var r=t.prototype;return r.registerListeners=function(){var e=this.hls;e&&(e.on(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(O.BUFFER_APPENDED,this.onBufferAppended,this))},r.unregisterListeners=function(){var e=this.hls;e&&(e.off(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.BUFFER_APPENDED,this.onBufferAppended,this))},r.destroy=function(){e.prototype.destroy.call(this),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0},r.onMediaAttached=function(e,t){this.setInterval(100),this.mediaSource=t.mediaSource;var r=this.media=t.media;hr(r,"playing",this.onMediaPlaying),hr(r,"waiting",this.onMediaWaiting),hr(r,"ended",this.onMediaEnded)},r.onMediaDetaching=function(e,t){this.clearInterval();var r=this.media;r&&(fr(r,"playing",this.onMediaPlaying),fr(r,"waiting",this.onMediaWaiting),fr(r,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0},r.onBufferAppended=function(e,t){this.buffered=t.timeRanges},r.getCurrentTime=function(){var e,t=(null==(e=this.hls)?void 0:e.config.timelineOffset)||0;return this.media?Math.max(this.media.currentTime,t):t},r.tick=function(){var e;if(null!=(e=this.media)&&e.readyState&&this.hasBuffered){var t=this.getCurrentTime();this.media.currentTimet&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(l||o)o&&this.stallResolved(e);else{if(u)return this.skipRetry=this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&n.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(O.MEDIA_ENDED,{stalled:!1})));if(dr.getBuffered(n).length){var d=dr.bufferInfo(n,e,0),h=this.fragmentTracker;h&&this.hls&&Qi(0,e,h,this.hls);var f=d.nextStart||0;if(s&&h&&this.hls){var c=qi(this.hls.inFlightFragments,e),g=d.len>2,v=!f||c||f-e>2&&!h.getPartialFragment(e);if(g||v)return;this.moved=!1}var m=null==(i=this.hls)?void 0:i.latestLevelDetails;if(!this.moved&&null!==this.stalled&&h){if(!(d.len>0||f))return;var p=Math.max(f,d.start||0)-e,y=null!=m&&m.live?2*m.targetduration:2,E=zi(e,h);if(p>0&&(p<=y||E))return void(n.paused||this._trySkipBufferHole(E))}var T=a.detectStallWithCurrentTimeMs,S=self.performance.now(),L=this.waiting,R=this.stalled;if(null===R){if(!(L>0&&S-L=T||L&&this.moved)&&this.hls){var b;if("ended"===(null==(b=this.mediaSource)?void 0:b.readyState)&&(null==m||!m.live)&&Math.abs(e-((null==m?void 0:m.edge)||0))<1){if(this.ended)return;return this.ended=e||1,void this.hls.trigger(O.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(d),!this.media||!this.hls)return;if(n.currentTime!==e){var k=e;return e=n.currentTime,this.moved=!0,void this.log("currentTime changed "+k+" > "+e)}}var D=dr.bufferInfo(n,e,a.maxBufferHole);this._tryFixBufferStall(D,A,e)}else this.skipRetry=this.nudgeRetry=0}}}},r.stallResolved=function(e){var t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){var r=self.performance.now()-t;this.log("playback not stuck anymore @"+e+", after "+Math.round(r)+"ms"),this.stallReported=!1,this.waiting=0,this.hls.trigger(O.STALL_RESOLVED,{})}},r.nudgeOnVideoHole=function(e,t){var r,i=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&null!=(r=this.buffered.audio)&&r.length&&i&&i.length>1&&e>i.end(0)){var a=dr.bufferedInfo(dr.timeRangesToArray(this.buffered.audio),e,0);if(a.len>1&&t>=a.start){var n=dr.timeRangesToArray(i),s=dr.bufferedInfo(n,t,0).bufferedIndex;if(s>-1&&ss)&&u-l<1&&e-l<2){var d=new Error("nudging playhead to flush pipeline after video hole. currentTime: "+e+" hole: "+l+" -> "+u+" buffered index: "+o);this.warn(d.message),this.media.currentTime+=1e-6;var h=zi(e,this.fragmentTracker);h&&"fragment"in h?h=h.fragment:h||(h=void 0);var f=dr.bufferInfo(this.media,e,0);this.hls.trigger(O.ERROR,{type:x.MEDIA_ERROR,details:w.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:d,reason:d.message,frag:h,buffer:f.len,bufferInfo:f})}}}}},r._tryFixBufferStall=function(e,t,r){var i,a,n=this.fragmentTracker,s=this.media,o=null==(i=this.hls)?void 0:i.config;if(s&&n&&o){var l=null==(a=this.hls)?void 0:a.latestLevelDetails,u=zi(r,n);if((u||null!=l&&l.live&&r1&&e.len>o.maxBufferHole||e.nextStart&&(e.nextStart-r1e3*o.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}},r.adjacentTraversal=function(e,t){var r=this.fragmentTracker,i=e.nextStart;if(r&&i){var a=r.getFragAtPos(t,N.MAIN),n=r.getFragAtPos(i,N.MAIN);if(a&&n)return n.sn-a.sn<2}return!1},r._reportStall=function(e){var t=this.hls,r=this.media,i=this.stallReported,a=this.stalled;if(!i&&null!==a&&r&&t){this.stallReported=!0;var n=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+Bt(e)+")");this.warn(n.message),t.trigger(O.ERROR,{type:x.MEDIA_ERROR,details:w.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len,bufferInfo:e,stalled:{start:a}})}},r._trySkipBufferHole=function(e){var t=this.fragmentTracker,r=this.media,i=this.hls,a=null==i?void 0:i.config;if(!r||!t||!a)return 0;var n=r.currentTime,s=dr.bufferInfo(r,n,0);Qi(0,n,t,i);var o=n0&&s.len<1&&r.readyState<3,d=o-n;if(d>0&&(l||u)){if(d>a.maxBufferHole){var h=!1;if(0===n){var f=t.getAppendedFrag(0,N.MAIN);f&&o0)){g=!0;break}v+=p}if(g)return 0}}var y=a.nudgeMaxRetry,E=a.skipBufferHolePadding,T=++this.skipRetry>y,S=Math.max(o,n)+E;if(T||(this.warn("skipping hole, adjusting currentTime from "+n+" to "+S),this.moved=!0,r.currentTime=S),null==e||!e.gap||T){var L=new Error(T?"Playhead still not moving after seeking over buffer hole from "+n+" to "+S+" after "+a.nudgeMaxRetry+" attempts.":"fragment loaded with buffer holes, seeking from "+n+" to "+S),R={type:x.MEDIA_ERROR,details:w.BUFFER_SEEK_OVER_HOLE,fatal:T,error:L,reason:L.message,buffer:s.len,bufferInfo:s};e&&("fragment"in e?R.part=e:R.frag=e),i.trigger(O.ERROR,R)}return S}}return 0},r._tryNudgeBuffer=function(e){var t=this.hls,r=this.media,i=this.nudgeRetry,a=null==t?void 0:t.config;if(!r||!a)return 0;var n=r.currentTime;if(this.nudgeRetry++,i0}}])}(Bi);function qi(e,t){var r=Xi(e.main);if(r&&r.start<=t)return r;var i=Xi(e.audio);return i&&i.start<=t?i:null}function Xi(e){if(!e)return null;switch(e.state){case Yi.IDLE:case Yi.STOPPED:case Yi.ENDED:case Yi.ERROR:return null}return e.frag}function zi(e,t){return t.getAppendedFrag(e,N.MAIN)||t.getPartialFragment(e)}function Qi(e,t,r,i){i.latestLevelDetails,zi(t,r),i.config}var $i=function(e){return e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3",e.misbklv="urn:misb:KLV:bin:1910.1",e}({});function Zi(e,t,r,i){var a=e.mode;if("disabled"===a&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var n=function(e,t,r){var i=[],a=function(e,t){if(t<=e[0].startTime)return 0;var r=e.length-1;if(t>e[r].endTime)return-1;for(var i,a=0,n=r;a<=n;)if(te[i].startTime&&a-1)for(var n=a,s=e.length;n=t&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}(e.cues,t,r),s=0;sta&&(h=ta),h-d<=0&&(h=d+.25);for(var f=0;f.01&&this.updateDateRangeCues(t.details)},t.updateDateRangeCues=function(e,t){var r=this;if(this.hls&&this.media){var i=this.hls.config;i.assetPlayerId,i.timelineOffset;var a=i.enableDateRangeMetadataCues;if(i.interstitialsController,a){var n=Ji();if(e.hasProgramDateTime){var s,o=this.id3Track,l=e.dateRanges,u=Object.keys(l),d=this.dateRangeCuesAppended;if(o&&t)if(null!=(s=o.track.cues)&&s.length)for(var h=Object.keys(d).filter((function(e){return-1===u.indexOf(e)})),f=function(){var e,t=h[c],i=null==(e=d[t])?void 0:e.cues;delete d[t],i&&Object.keys(i).forEach((function(e){var t=i[e];if(t){t.removeEventListener("enter",r.onEventCueEnter);try{o.track.removeCue(t)}catch(e){}}}))},c=h.length;c--;)f();else d=this.dateRangeCuesAppended={};var g=e.fragments[e.fragments.length-1];if(0!==u.length&&_(null==g?void 0:g.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var v=function(){var e=u[m],t=l[e],i=t.startTime,a=d[e],s=(null==a?void 0:a.cues)||{},o=(null==a?void 0:a.durationKnown)||!1,h=ta,f=t.duration;if(t.endDate&&null!==f)h=i+f,o=!0;else if(t.endOnNext&&!o){var c=u.reduce((function(e,r){if(r!==t.id){var i=l[r];if(i.class===t.class&&i.startDate>t.startDate&&(!e||t.startDate.01&&(E.startTime=i,E.endTime=h):E.endTime=h;else if(n){var T=t.attr[y];_r(y)&&(T=we(T));var S=ea(n,i,h,{key:y,data:T},$i.dateRange);S&&(S.id=e,r.id3Track.track.addCue(S),s[y]=S)}}}d[e]={cues:s,dateRange:t,durationKnown:o}},m=0;m.05&&t.forwardBufferLength>1){var u=Math.min(2,Math.max(1,s)),d=Math.round(2/(1+Math.exp(-.75*l-t.edgeStalled))*20)/20,h=Math.min(u,Math.max(1,d));t.changeMediaPlaybackRate(e,h)}else 1!==e.playbackRate&&0!==e.playbackRate&&t.changeMediaPlaybackRate(e,1)}}}}},this.hls=e,this.registerListeners()}var t=e.prototype;return t.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null},t.registerListeners=function(){var e=this.hls;e&&(e.on(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(O.ERROR,this.onError,this),e.on(O.INTERSTITIAL_ASSET_STARTED,this.onAssetStarted,this))},t.unregisterListeners=function(){var e=this.hls;e&&(e.off(O.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(O.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(O.ERROR,this.onError,this),e.off(O.INTERSTITIAL_ASSET_STARTED,this.onAssetStarted,this))},t.onMediaAttached=function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)},t.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)},t.onManifestLoading=function(){this._latency=null,this.stallCount=0},t.onLevelUpdated=function(e,t){var r=t.details;r.advanced&&this.onTimeupdate(),!r.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)},t.onAssetStarted=function(e,t){var r,i=this.hls,a=this.media||t.event.appendInPlace&&(null==i||null==(r=i.interstitialsManager)?void 0:r.playerQueue.reduce((function(e,t){return e||t.media}),null));i&&a&&a.playbackRate>1&&a.playbackRate<=i.config.maxLiveSyncPlaybackRate&&this.changeMediaPlaybackRate(a,1)},t.onError=function(e,t){var r;t.details===w.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&null!=(r=this.levelDetails)&&r.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))},t.changeMediaPlaybackRate=function(e,t){var r,i;e.playbackRate!==t&&(null==(r=this.hls)||r.logger.debug("[latency-controller]: latency="+this.latency.toFixed(3)+", targetLatency="+(null==(i=this.targetLatency)?void 0:i.toFixed(3))+", forwardBufferLength="+this.forwardBufferLength.toFixed(3)+": adjusting playback rate from "+e.playbackRate+" to "+t),e.playbackRate=t)},t.estimateLiveEdge=function(){var e=this.levelDetails;return null===e?null:e.edge+e.age},t.computeLatency=function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime},a(e,[{key:"levelDetails",get:function(){var e;return(null==(e=this.hls)?void 0:e.latestLevelDetails)||null}},{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e,t=null==(e=this.hls)?void 0:e.config;if(!t)return 0;if(void 0!==t.liveMaxLatencyDuration)return t.liveMaxLatencyDuration;var r=this.levelDetails;return r?t.liveMaxLatencyDurationCount*r.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e||!this.hls)return null;var t=this.hls.config,r=e.holdBack,i=e.partHoldBack,a=e.targetduration,n=t.liveSyncDuration,s=t.liveSyncDurationCount,o=t.lowLatencyMode,l=this.hls.userConfig,u=o&&i||r;(this._targetLatencyUpdated||l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==n?n:s*a);var d=a;return u+Math.min(this.stallCount*t.liveSyncOnStallIncrease,d)},set:function(e){this.hls&&(this.stallCount=0,this.hls.config.liveSyncDuration=e,this._targetLatencyUpdated=!0)}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t||!this.hls)return null;var r=this.levelDetails;if(null===r)return null;var i=r.edge,a=e-t-this.edgeStalled,n=i-r.totalduration,s=i-(this.hls.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(n,a),s)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e||!this.hls)return 0;var t=3*(this.hls.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}}])}();function aa(e,t){return 255===e[t]&&240==(246&e[t+1])}function na(e,t){return 1&e[t+1]?7:9}function sa(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function oa(e,t){return t+1=e.length)return!1;var i=sa(e,t);if(i<=r)return!1;var a=t+i;return a===e.length||oa(e,a)}return!1}function ua(e,t,r,i,a){if(!e.samplerate){var n=function(e,t,r,i){var a=t[r+2],n=a>>2&15;if(!(n>12)){var s,o=1+(a>>6&3),l=t[r+3]>>6&3|(1&a)<<2,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][n],d=n;5!==o&&29!==o||(d-=3);var h=(14&d)>>1,f=(1&d)<<7|l<<3,c=0;if(1===o&&n>=6){var g=n-3;s=[(c=5)<<3|h,f|(14&g)>>1,(1&g)<<7|8,0]}else s=[o<<3|h,f];var v="mp4a.40."+(c||o);return fe.log("manifest codec:"+i+", parsed codec:"+v+", channels:"+l+", rate:"+u+" (ADTS object type:"+o+" sampling index:"+n+" esds config:["+s.join(",")+"])"),{config:s,samplerate:u,channelCount:l,codec:v,parsedCodec:v,manifestCodec:i}}var m=new Error("invalid ADTS sampling index:"+n);e.emit(O.ERROR,O.ERROR,{type:x.MEDIA_ERROR,details:w.FRAG_PARSING_ERROR,fatal:!0,error:m,reason:m.message})}(t,r,i,a);if(!n)return;o(e,n)}}function da(e){return 9216e4/e}function ha(e,t,r,i,a){var n,s=i+a*da(e.samplerate),o=function(e,t){var r=na(e,t);if(t+r<=e.length){var i=sa(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}(t,r);if(o){var l=o.frameLength,u=o.headerLength,d=u+l,h=Math.max(0,r+d-t.length);h?(n=new Uint8Array(d-u)).set(t.subarray(r+u,t.length),0):n=t.subarray(r+u,r+d);var f={unit:n,pts:s};return h||e.samples.push(f),{sample:f,length:d,missing:h}}var c=t.length-r;return(n=new Uint8Array(c)).set(t.subarray(r,t.length),0),{sample:{unit:n,pts:s},length:c,missing:-1}}function fa(e,t){return void 0===e&&(e=""),void 0===t&&(t=9e4),{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}var ca=function(){function e(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var t=e.prototype;return t.resetInitSegment=function(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},t.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},t.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},t.canParse=function(e,t){return!1},t.appendFrame=function(e,t,r){},t.demux=function(e,t){this.cachedData&&(e=it(this.cachedData,e),this.cachedData=null);var r,i=Te(e,0),a=i?i.length:0,n=this._audioTrack,s=this._id3Track,o=i?Pe(i):void 0,l=e.length;for((null===this.basePTS||0===this.frameIndex&&_(o))&&(this.basePTS=ga(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:$i.audioId3,duration:Number.POSITIVE_INFINITY});at.length)){var n=Ta(t,r);if(n&&r+n.frameLength<=t.length){var s=i+a*(9e4*n.samplesPerFrame/n.sampleRate),o={unit:t.subarray(r,r+n.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(o),{sample:o,length:n.frameLength,missing:0}}}}function Ta(e,t){var r=e[t+1]>>3&3,i=e[t+1]>>1&3,a=e[t+2]>>4&15,n=e[t+2]>>2&3;if(1!==r&&0!==a&&15!==a&&3!==n){var s=e[t+2]>>1&1,o=e[t+3]>>6,l=1e3*va[14*(3===r?3-i:3===i?3:4)+a-1],u=ma[3*(3===r?0:2===r?1:2)+n],d=3===o?1:2,h=pa[r][i],f=ya[i],c=8*h*f,g=Math.floor(h*l/u+s)*f,v=ct();return!!v&&v<=87&&2===i&&l>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:u,channelCount:d,frameLength:g,samplesPerFrame:c}}}function Sa(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function La(e,t){return t+1=e.length)return void r();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,r),this.decrypter.isSync())))return}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),i=0,a=32;a=e.length)return void i();for(var a=e[t].units;!(r>=a.length);r++){var n=a[r];if(!(n.data.length<=48||1!==n.type&&5!==n.type||(this.decryptAvcSample(e,t,r,i,n),this.decrypter.isSync())))return}}},e}(),ba=function(e){function t(t,r){var i;return(i=e.call(this)||this).observer=void 0,i.config=void 0,i.sampleAes=null,i.observer=t,i.config=r,i}u(t,e);var r=t.prototype;return r.resetInitSegment=function(t,r,i,a){e.prototype.resetInitSegment.call(this,t,r,i,a),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:a,inputTimeScale:9e4,dropped:0}},t.probe=function(e,t){if(!e)return!1;var r=Te(e,0),i=(null==r?void 0:r.length)||0;if(Ra(e,i))return!1;for(var a=e.length;i0;){s[0]=e[t];var o=Math.min(i,8),l=8-o;n[0]=4278190080>>>24+l<>l,r=r?r<8&&Ge(e,i+4)===Ne[t])return!0;i=a>1?i+a:r}return!1}(e,"moof")},t.demux=function(e,t,r){this.timeOffset=t;var i=e,a=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=it(this.remainderData,e));var s=function(e){var t={valid:null,remainder:null},r=We(e,["moof"]);if(r.length<2)return t.remainder=e,t;var i=r[r.length-1];return t.valid=e.slice(0,i.byteOffset-8),t.remainder=e.slice(i.byteOffset-8),t}(i);this.remainderData=s.remainder,a.samples=s.valid||new Uint8Array}else a.samples=i;var o=this.extractID3Track(a,t),l=this.parseFragment(a,n,t,r);return{videoTrack:a,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack,initData:this.initData,sampleData:l}},t.flush=function(e,t){var r=this.timeOffset,i=this.videoTrack,a=this.txtTrack;i.samples=this.remainderData||new Uint8Array,this.remainderData=null;var n=this.extractID3Track(i,this.timeOffset),s=this.parseFragment(i,a,r,t);return{videoTrack:i,audioTrack:fa(),id3Track:n,textTrack:fa(),initData:this.initData,sampleData:s}},t.parseFragment=function(e,t,r,i){var a=this.initData;if(a&&i){var n=function(e,t,r,i,a){var n=[];return{samples:n,sampleData:{includeSampleDetails:a,tracks:rt(t.samples,r,i,0,{isHEVCFlavor:at(t.codec),samples:n,timeOffset:e,timescale:t.timescale,trackId:t.id})}}}(r,e,a,this.logger,!1),s=n.samples,o=n.sampleData;return t.samples=s,o}t.samples=function(e,t){var r=[],i=t.samples,a=t.timescale,n=t.id,s=!1;return We(i,["moof"]).map((function(o){var l=o.byteOffset-8;We(o,["traf"]).map((function(o){var u=We(o,["tfdt"]).map((function(e){var t=e[0],r=Ge(e,4);return 1===t&&(r*=Math.pow(2,32),r+=Ge(e,8)),r/a}))[0];return void 0!==u&&(e=u),We(o,["tfhd"]).map((function(u){var d=Ge(u,4),h=16777215&Ge(u,0),f=0!=(1&h),c=0,g=0!=(2&h),v=0!=(8&h),m=0,p=0!=(16&h),y=0,E=0!=(32&h),T=!f&&0!=(131072&h),S=8;d===n&&(f?(c=Ge(u,S),S+=4,c*=Math.pow(2,32),c+=Ge(u,S),S+=4):T&&(c=l),g&&(S+=4),v&&(m=Ge(u,S),S+=4),p&&(y=Ge(u,S),S+=4),E&&(S+=4),"video"===t.type&&(s=at(t.codec)),We(o,["trun"]).map((function(n){var o=n[0],l=16777215&Ge(n,0),u=0!=(1&l),d=0,h=0!=(4&l),f=0!=(256&l),g=0,v=0!=(512&l),p=0,E=0!=(1024&l),T=0!=(2048&l),S=0,L=Ge(n,4),R=8;u&&(d=Ge(n,R),R+=4),h&&(R+=4);for(var A=c+d,b=0;b0&&0===t[f-1];)f--;var c=h-f+(0===f?n:0);if(!(c<2)){var g=Math.min(c,3),v=Math.min(h-f,g),m=g-v;if(f=h-v,u>=0)s.push({data:t.subarray(u,f),type:d});else{var p=this.getLastNalUnit(e.samples);p&&(f>0?p.data=it(p.data,t.subarray(0,f)):m>0&&(p.data=p.data.subarray(0,p.data.byteLength-m)),p.state=0)}if(!(l0&&0===t[y-1];)y--;o=i-y+(0===y?n:0)}if(u>=0)s.push({data:t.subarray(u),type:d,state:o});else if(0===s.length&&-1!==o){var E=this.getLastNalUnit(e.samples);E&&(E.data=it(E.data,t),E.state=o)}return e.naluState=o,s},e}(),Pa=function(){function e(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}var t=e.prototype;return t.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,i=new Uint8Array(4),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");i.set(e.subarray(r,r+a)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a},t.skipBits=function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&fe.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?r<>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},e}(),xa=function(e){function t(){return e.apply(this,arguments)||this}u(t,e);var r=t.prototype;return r.parsePES=function(e,t,r,i,a){var n,s=this,o=a.iframe,l=this.parseNALu(e,r.data,i),u=this.VideoSample,d=!1;r.data=null,u&&l.length&&!e.audFound&&(this.pushAccessUnit(u,e),u=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),l.forEach((function(i){var a,l;switch(i.type){case 1:if(o)break;var h=!1;n=!0;var f,c=i.data;if(d&&c.length>4){var g=s.readSliceType(c);2!==g&&4!==g&&7!==g&&9!==g||(h=!0)}h&&null!=(f=u)&&f.frame&&!u.key&&(s.pushAccessUnit(u,e),u=s.VideoSample=null),u||(u=s.VideoSample=s.createVideoSample(!0,r.pts,r.dts)),u.frame=!0,u.key=h;break;case 5:n=!0,null!=(a=u)&&a.frame&&!u.key&&(s.pushAccessUnit(u,e),u=s.VideoSample=null),u||(u=s.VideoSample=s.createVideoSample(!0,r.pts,r.dts)),u.key=!0,u.frame=!0;break;case 6:if(o)break;n=!0,st(i.data,1,r.pts,t.samples);break;case 7:var v,m;n=!0,d=!0;var p=i.data,y=s.readSPS(p);if(!e.sps||e.width!==y.width||e.height!==y.height||(null==(v=e.pixelRatio)?void 0:v[0])!==y.pixelRatio[0]||(null==(m=e.pixelRatio)?void 0:m[1])!==y.pixelRatio[1]){e.width=y.width,e.height=y.height,e.pixelRatio=y.pixelRatio,e.sps=[p];for(var E=p.subarray(1,4),T="avc1.",S=0;S<3;S++){var L=E[S].toString(16);L.length<2&&(L="0"+L),T+=L}e.codec=T}break;case 8:n=!0,e.pps=[i.data];break;case 9:n=!0,e.audFound=!0,null!=(l=u)&&l.frame&&(s.pushAccessUnit(u,e),u=null),u||(u=s.VideoSample=s.createVideoSample(!1,r.pts,r.dts));break;case 12:n=!0;break;default:n=!1}u&&n&&u.units.push(i)})),i&&u&&(this.pushAccessUnit(u,e),this.VideoSample=null)},r.getNALuType=function(e,t){return 31&e[t]},r.readSliceType=function(e){var t=new Pa(e);return t.readUByte(),t.readUEG(),t.readUEG()},r.skipScalingList=function(e,t){for(var r=8,i=8,a=0;a0&&r.warn("MPEG2-TS detected but first sync word found @ offset "+i),-1!==i},e.syncOffset=function(e){for(var t=e.length,r=Math.min(940,t-wa)+1,i=0;i1&&(0===n&&s>2||o+wa>r))return n}i++}return-1},e.createTrack=function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:Be[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}};var t=e.prototype;return t.resetInitSegment=function(t,r,i,a,n,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._videoTrack.duration=a,this.videoIntegrityChecker="skip"===this.config.handleMpegTsVideoIntegrityErrors?new Ha(this.logger):null,this._audioTrack=e.createTrack("audio",a),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i,t&&this.demux(t,0,s,"SAMPLE-AES"===(null==n?void 0:n.method))},t.resetTimeStamp=function(){},t.resetContiguity=function(){var e=this._audioTrack,t=this._videoTrack,r=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.videoParser=null,this.aacOverFlow=null,this.remainderData=null},t.demux=function(t,r,i,a,n){var s;void 0===a&&(a=!1),void 0===n&&(n=!1),a||(this.sampleAes=null);var o=this._videoTrack,l=this.videoIntegrityChecker,u=this._audioTrack,d=this._id3Track,h=this._txtTrack,f=i.iframe,c=o.pid,g=o.pesData,v=u.pid,m=d.pid,p=this._klvPid,y=u.pesData,E=d.pesData,T=null,S=null,L=this.pmtParsed,R=this._pmtId,A=t.length;if(this.remainderData&&(A=(t=it(this.remainderData,t)).length,this.remainderData=null),A>4>1){if((C=D+5+t[D+4])===D+wa)continue}else C=D+4;switch(_){case c:I&&(!g||null!=l&&l.isCorrupted||!(s=Ga(g,this.logger))||(this.readyVideoParser(o.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(o,h,s,!1,i)),g={data:[],size:0},null==l||l.reset(c)),null==l||l.handlePacket(t.subarray(D)),g&&(g.data.push(t.subarray(C,D+wa)),g.size+=D+wa-C);break;case v:if(f)break;if(I){if(y&&(s=Ga(y,this.logger)))switch(u.segmentCodec){case"aac":this.parseAACPES(u,s,i);break;case"mp3":this.parseMPEGPES(u,s)}y={data:[],size:0}}y&&(y.data.push(t.subarray(C,D+wa)),y.size+=D+wa-C);break;case m:if(f)break;I&&(E&&(s=Ga(E,this.logger))&&this.parseID3PES(d,s),E={data:[],size:0}),E&&(E.data.push(t.subarray(C,D+wa)),E.size+=D+wa-C);break;case p:if(f)break;I&&(T&&(s=Ga(T,this.logger))&&this.parseKlvPES(d,s),T={data:[],size:0}),T&&(T.data.push(t.subarray(C,D+wa)),T.size+=D+wa-C);break;case 0:I&&(C+=t[C]+1),R=this._pmtId=Fa(t,C);break;case R:I&&(C+=t[C]+1);var P=Na(t,C,this.typeSupported,a,this.observer,this.logger,this.config,i);(c=P.videoPid)>0&&(o.pid=c,o.segmentCodec=P.segmentVideoCodec),(v=P.audioPid)>0&&(u.pid=v,u.segmentCodec=P.segmentAudioCodec),(m=P.id3Pid)>0&&(d.pid=m),(p=P.klvPid)>0&&(this._klvPid=p),null===S||L||(this.logger.warn("MPEG-TS PMT found at "+D+" after unknown PID '"+S+"'. Backtracking to sync byte @"+b+" to parse all TS packets."),S=null,D=b-188),L=this.pmtParsed=!0;break;case 17:case 8191:break;default:S=_}}else k++;k>0&&Ba(this.observer,new Error("Found "+k+" TS packet/s that do not start with 0x47"),i,void 0,this.logger),o.pesData=g,u.pesData=y,d.pesData=E;var x={audioTrack:u,videoTrack:o,id3Track:d,textTrack:h};return n&&this.extractRemainingSamples(x,i),x},t.flush=function(e,t){var r,i=this.remainderData;return this.remainderData=null,r=i?this.demux(i,0,t,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(r,t),this.sampleAes?this.decrypt(r,this.sampleAes):r},t.extractRemainingSamples=function(e,t){var r,i=e.audioTrack,a=e.videoTrack,n=e.id3Track,s=e.textTrack,o=a.pesData,l=i.pesData,u=n.pesData,d=this.videoIntegrityChecker;if(!o||null!=d&&d.isCorrupted||!(r=Ga(o,this.logger))?a.pesData=o:(this.readyVideoParser(a.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(a,s,r,!0,t),a.pesData=null)),l&&(r=Ga(l,this.logger))){switch(i.segmentCodec){case"aac":this.parseAACPES(i,r,t);break;case"mp3":this.parseMPEGPES(i,r)}i.pesData=null}else null!=l&&l.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),i.pesData=l;u&&(r=Ga(u,this.logger))?(this.parseID3PES(n,r),n.pesData=null):n.pesData=u},t.demuxSampleAes=function(e,t,r,i){var a=this.demux(e,r,i,!0,!this.config.progressive),n=this.sampleAes=new Aa(this.observer,this.config,t);return this.decrypt(a,n)},t.readyVideoParser=function(e){null===this.videoParser&&"avc"===e&&(this.videoParser=new xa)},t.decrypt=function(e,t){return new Promise((function(r){var i=e.audioTrack,a=e.videoTrack;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,(function(){a.samples?t.decryptAvcSamples(a.samples,0,0,(function(){r(e)})):r(e)})):a.samples&&t.decryptAvcSamples(a.samples,0,0,(function(){r(e)}))}))},t.destroy=function(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0,this.videoIntegrityChecker=null},t.parseAACPES=function(e,t,r){var i,a,n,s=0,o=this.aacOverFlow,l=t.data;if(o){this.aacOverFlow=null;var u=o.missing,d=o.sample.unit.byteLength;if(-1===u)l=it(o.sample.unit,l);else{var h=d-u;o.sample.unit.set(l.subarray(0,u),h),e.samples.push(o.sample),s=o.missing}}for(i=s,a=l.length;ia.length)break;var o=n;if((n+=16)>=a.length)break;var l=a[n];n+=1;var u=0;if(128&l){var d=127&l;if(0===d||d>4||n+d>a.length){this.logger.warn("[tsdemuxer]: Invalid KLV length encoding");break}for(var h=0;ha.length){this.logger.warn("[tsdemuxer]: KLV value extends beyond PES payload");break}var f=n+u,c=a.subarray(o,f),g={data:c,len:c.byteLength,pts:i,dts:null!=(s=t.dts)?s:i,type:$i.misbklv,duration:Number.POSITIVE_INFINITY};e.samples.push(g),n=f}}else this.logger.warn("[tsdemuxer]: KLV PES unknown PTS and DTS")},e}();function Ma(e,t){return((31&e[t+1])<<8)+e[t+2]}function Fa(e,t){return(31&e[t+10])<<8|e[t+11]}function Na(e,t,r,i,a,n,s,o){var l={audioPid:-1,videoPid:-1,id3Pid:-1,klvPid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},u=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t0)for(var f=t+5,c=h;c>2;){switch(e[f]){case 106:-1===l.audioPid&&n.warn("AC-3 in M2TS support not included in build");break;case 5:-1===l.klvPid&&s.enableEmsgKLVMetadata&&(l.klvPid=d,n.log("KLV metadata PID found: "+d))}var g=e[f+1]+2;f+=g,c-=g}break;case 194:case 135:return Ba(a,new Error("Unsupported EC-3 in M2TS found"),o,void 0,n),l;case 36:return Ba(a,new Error("Unsupported HEVC in M2TS found"),o,void 0,n),l}t+=h+5}return l}function Ba(e,t,r,i,a){a.warn("parsing error: "+t.message),e.emit(O.ERROR,O.ERROR,{type:x.MEDIA_ERROR,details:w.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,chunkMeta:r,error:t,reason:t.message})}function Ua(e,t){t.log(e+" with AES-128-CBC encryption found in unencrypted stream")}function Ga(e,t){var r,i,a,n,s,o=0,l=e.data;if(!e||0===e.size)return null;for(;l[0].length<19&&l.length>1;)l[0]=it(l[0],l[1]),l.splice(1,1);if(1===((r=l[0])[0]<<16)+(r[1]<<8)+r[2]){if((i=(r[4]<<8)+r[5])&&i>e.size-6)return null;var u=r[7];192&u&&(n=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&u?n-(s=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2)>54e5&&(t.warn(Math.round((n-s)/9e4)+"s delta between PTS and DTS, align them"),n=s):s=n);var d=(a=r[8])+9;if(e.size<=d)return null;e.size-=d;for(var h=new Uint8Array(e.size),f=0,c=l.length;fg){d-=g;continue}r=r.subarray(d),g-=d,d=0}h.set(r,o),o+=g}return i&&(i-=a+3),{data:h,pts:n,dts:s,len:i}}return null}var Va,Ha=function(){function e(e){this.logger=void 0,this.pid=0,this.lastContinuityCounter=-1,this.integrityState="ok",this.logger=e}var t=e.prototype;return t.reset=function(e){this.pid=e,this.lastContinuityCounter=-1,this.integrityState="ok"},t.handlePacket=function(e){if(!(e.byteLength<4)){var t=Ma(e,0);if(t===this.pid){var r=(48&e[3])>>4;if(0!==r){var i=15&e[3],a=this.lastContinuityCounter;this.lastContinuityCounter=i;var n=0!=(1&r);if(!(0!=(2&r)&&0!=e[4]&&0!=(128&e[5])||a<0)){var s=n?a+1&15:a;return i!==s?(this.logger.warn("MPEG-TS Continuity Counter check failed for PID='"+t+"', CC="+i+", Expected-CC="+s+" Last-CC="+a),void(this.integrityState="cc-failed")):0!=(128&e[1])?(this.logger.warn("MPEG-TS Packet had TEI flag set for PID='"+t+"'"),void(this.integrityState="tei-bit")):void 0}}}else this.logger.debug("Packet PID mismatch, expected "+this.pid+" got "+t)}},a(e,[{key:"isCorrupted",get:function(){return"ok"!==this.integrityState}}])}(),Ka=function(){function e(){}return e.getSilentFrame=function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}},e}(),Ya={video:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),audio:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])},Wa=new Uint8Array([0,0,0,0,0,0,0,0]),ja=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),qa=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),Xa=new Uint8Array([0,0,0,0,0,0,0,0]),za=new Uint8Array([0,0,0,0,0,0,0,1]),Qa=new Uint8Array([105,115,111,109]),$a=new Uint8Array([97,118,99,49]),Za=new Uint8Array([0,0,0,1]),Ja=function(){function e(){}return e.box=function(e){for(var t=8,r=arguments.length,i=new Array(r>1?r-1:0),a=1;a>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))},e.mdia=function(t){return e.box(Ne.mdia,e.mdhd(t.timescale||0,t.duration||0),e.hdlr(t.type),e.minf(t))},e.mfhd=function(t){return e.box(Ne.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))},e.minf=function(t){return"audio"===t.type?e.box(Ne.minf,e.box(Ne.smhd,Xa),e.DINF,e.stbl(t)):e.box(Ne.minf,e.box(Ne.vmhd,qa),e.DINF,e.stbl(t))},e.moof=function(t,r,i){return e.box(Ne.moof,e.mfhd(t),e.traf(i,r))},e.moov=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trak(t[r]);return e.box.apply(null,[Ne.moov,e.mvhd(t[0].timescale||0,t[0].duration||0)].concat(i).concat(e.mvex(t)))},e.mvex=function(t){for(var r=t.length,i=[];r--;)i[r]=e.trex(t[r]);return e.box.apply(null,[Ne.mvex].concat(i))},e.mvhd=function(t,r){r*=t;var i=Math.floor(r/(Fe+1)),a=Math.floor(r%(Fe+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24,i>>16&255,i>>8&255,255&i,a>>24,a>>16&255,a>>8&255,255&a,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return e.box(Ne.mvhd,n)},e.sdtp=function(t){var r,i,a=t.samples||[],n=new Uint8Array(4+a.length);for(r=0;r>>8&255),n.push(255&a),n=n.concat(Array.prototype.slice.call(i));for(r=0;r>>8&255),s.push(255&a),s=s.concat(Array.prototype.slice.call(i));var o=e.box(Ne.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|t.sps.length].concat(n).concat([t.pps.length]).concat(s))),l=t.width,u=t.height,d=t.pixelRatio[0],h=t.pixelRatio[1];return e.box(Ne.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,e.box(Ne.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(Ne.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))},e.esds=function(e){var t=e.config,r=t.length;return new Uint8Array([0,0,0,0,3,23+r,0,1,0,4,15+r,64,21,0,0,0,0,0,0,0,0,0,0,0,5,r].concat(t,[6,1,2]))},e.audioStsd=function(e){var t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,255&t,0,0])},e.mp4a=function(t){return e.box(Ne.mp4a,e.audioStsd(t),e.box(Ne.esds,e.esds(t)))},e.mp3=function(t){return e.box(Ne[".mp3"],e.audioStsd(t))},e.ac3=function(t){return e.box(Ne["ac-3"],e.audioStsd(t),e.box(Ne.dac3,t.config))},e.stsd=function(t){var r=t.segmentCodec;if("audio"===t.type){if("aac"===r)return e.box(Ne.stsd,za,e.mp4a(t));if("mp3"===r&&"mp3"===t.codec)return e.box(Ne.stsd,za,e.mp3(t))}else{if(!t.pps||!t.sps)throw new Error("video track missing pps or sps");if("avc"===r)return e.box(Ne.stsd,za,e.avc1(t))}throw new Error("unsupported "+t.type+" segment codec ("+r+"/"+t.codec+")")},e.tkhd=function(t){var r=t.id,i=(t.duration||0)*(t.timescale||0),a=t.width||0,n=t.height||0,s=Math.floor(i/(Fe+1)),o=Math.floor(i%(Fe+1));return e.box(Ne.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,a>>8&255,255&a,0,0,n>>8&255,255&n,0,0]))},e.traf=function(t,r){var i=e.sdtp(t),a=t.id,n=Math.floor(r/(Fe+1)),s=Math.floor(r%(Fe+1));return e.box(Ne.traf,e.box(Ne.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(Ne.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,s>>24,s>>16&255,s>>8&255,255&s])),e.trun(t,i.length+16+20+8+16+8+8),i)},e.trak=function(t){return t.duration=t.duration||4294967295,e.box(Ne.trak,e.tkhd(t),e.mdia(t))},e.trex=function(t){var r=t.id;return e.box(Ne.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},e.trun=function(t,r){var i,a,n,s,o,l,u=t.samples||[],d=u.length,h=12+16*d,f=new Uint8Array(h);for(r+=8+h,f.set(["video"===t.type?1:0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i>>24&255,n>>>16&255,n>>>8&255,255&n,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);return e.box(Ne.trun,f)},e.initSegment=function(t){var r=e.moov(t);return it(e.FTYP,r)},e.hvc1=function(e){return new Uint8Array},e}();function en(e,t){return function(e,t,r,i){var a=e*t*r;return Math.round(a)}(e,1e3,1/9e4)}function tn(e){var t=e.baseTime,r=e.timescale;return t/r+" ("+t+"/"+r+") trackId: "+e.trackId}Va=Ja,Ja.FTYP=Va.box(Ne.ftyp,Qa,Za,Qa,$a),Ja.DINF=Va.box(Ne.dinf,Va.box(Ne.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])));var rn=8589934592;function an(e,t,r,i){return{duration:t,size:r,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1,paddingValue:0}}}var nn=function(e){function t(t,r,i,a){var n;return(n=e.call(this,"mp4-remuxer",a)||this).observer=void 0,n.config=void 0,n.typeSupported=void 0,n.ISGenerated=!1,n._initPTS=null,n._initDTS=null,n.nextVideoTs=null,n.nextAudioTs=null,n.videoSampleDuration=null,n.isAudioContiguous=!1,n.isVideoContiguous=!1,n.videoTrackConfig=void 0,n.observer=t,n.config=r,n.typeSupported=i,n.ISGenerated=!1,n}u(t,e);var r=t.prototype;return r.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},r.resetTimeStamp=function(e){var t=this._initPTS;t&&e&&e.trackId===t.trackId&&e.baseTime===t.baseTime&&e.timescale===t.timescale||this.log("Reset initPTS: "+(t?tn(t):t)+" > "+(e?tn(e):e)),this._initPTS=this._initDTS=e},r.resetNextTimestamp=function(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},r.resetInitSegment=function(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},r.getVideoStartPts=function(e){var t=!1,r=e[0].pts,i=e.reduce((function(e,i){var a=i.pts,n=a-e;return n<-4294967296&&(t=!0,n=(a=sn(a,r))-e),n>0?e:a}),r);return t&&this.debug("PTS rollover detected"),i},r.remux=function(e,t,r,i,a,n,s,o,l){var u,d,h,f,c,g,v=a,m=a,p=!l.iframe&&e.pid>-1,y=t.pid>-1,E=t.samples.length,T=e.samples.length>0,S=s&&E>0||E>1;if((!p||T)&&(!y||S)||this.ISGenerated||s){if(this.ISGenerated){var L,R,A,b,k=this.videoTrackConfig;(k&&(t.width!==k.width||t.height!==k.height||(null==(L=t.pixelRatio)?void 0:L[0])!==(null==(R=k.pixelRatio)?void 0:R[0])||(null==(A=t.pixelRatio)?void 0:A[1])!==(null==(b=k.pixelRatio)?void 0:b[1]))||!k&&S||null===this.nextAudioTs&&T)&&this.resetInitSegment()}this.ISGenerated||(h=this.generateIS(e,t,a,n));var D,I=this.isVideoContiguous,_=-1;if(S&&(_=function(e){for(var t=0;t0){this.warn("Dropped "+_+" out of "+E+" video samples due to a missing keyframe");var C=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(_),t.dropped+=_,D=m+=(t.samples[0].pts-C)/t.inputTimeScale}else-1===_&&(this.warn("No keyframe found out of "+E+" video samples"),g=!1);if(this.ISGenerated){if(T&&S&&a){var P=this.getVideoStartPts(t.samples),x=(sn(e.samples[0].pts,P)-P)/t.inputTimeScale;v+=Math.max(0,x),m+=Math.max(0,-x)}if(T){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),h=this.generateIS(e,t,a,n)),d=this.remuxAudio(e,v,this.isAudioContiguous,n,y||S||o===N.AUDIO?m:void 0,l),S){var w=d?d.endPTS-d.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),h=this.generateIS(e,t,a,n)),u=this.remuxVideo(t,m,I,w,l)}}else S&&(u=this.remuxVideo(t,m,I,0,l));u&&(u.firstKeyFrame=_,u.independent=-1!==_,u.firstKeyFramePTS=D)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(c=on(r,a,this._initPTS,this._initDTS)),i.samples.length&&(f=ln(i,a,this._initPTS))),{audio:d,video:u,initSegment:h,independent:g,text:f,id3:c}},r.computeInitPts=function(e,t,r,i){var a=Math.round(r*t),n=sn(e,a);if(n0?R-1:R].dts&&(E=!0)}E&&u.sort((function(e,t){var r=e.dts-t.dts,i=e.pts-t.pts;return r||i})),n=u[0].dts;var b=(s=u[u.length-1].dts)-n,k=b?Math.round(b/(h-1)):m||e.inputTimeScale/30;if(r){var D=n-L,I=D>k,_=D<-1;if((I||_)&&(I?this.warn((e.segmentCodec||"").toUpperCase()+": "+en(D)+" ms ("+D+"dts) hole between fragments detected at "+t.toFixed(3)):this.warn((e.segmentCodec||"").toUpperCase()+": "+en(-D)+" ms ("+D+"dts) overlapping between fragments detected at "+t.toFixed(3)),!_||L>=u[0].pts||ct())){n=L;var C=u[0].pts-D;if(I)u[0].dts=n,u[0].pts=C;else for(var P=!0,M=0;MC&&P);M++){var F=u[M].pts;if(u[M].dts-=D,u[M].pts-=D,M0?te.dts-u[ee-1].dts:k;if(ue=ee>0?te.pts-u[ee-1].pts:k,de.stretchShortVideoTrack&&null!==this.nextAudioTs){var fe=Math.floor(de.maxBufferHole*l),ce=(i?p+i*l:this.nextAudioTs+c)-te.pts;ce>fe?((m=ce-he)<0?m=he:z=!0,this.log("It is approximately "+ce/90+" ms to the next segment; using duration "+m/90+" ms for the last video frame.")):m=he}else m=he}var ge=Math.round(te.pts-te.dts);if(Q=Math.min(Q,m),Z=Math.max(Z,m),$=Math.min($,ue),J=Math.max(J,ue),!r&&0===ee&&ge>m){var ve=Math.round(ge/k)*k;ve-ge==1&&(this.log("pad first CTS "+ge+" -> "+ve+" of sn: "+a.sn),ge=ve)}d.push(an(te.key,m,ie,ge))}if(d.length){var me=ct();if(me){if(me<70){var pe=d[0].flags;pe.dependsOn=2,pe.isNonSync=0}}else if(function(){if(void 0===dt){var e=ht.match(/Safari\/(\d+)/i);dt=e?parseInt(e[1]):0}return dt}()&&J-$0&&(i&&Math.abs(E-(p+y))<9e3||Math.abs(sn(v[0].pts,E)-(p+y))<20*d),v.forEach((function(e){e.pts=sn(e.pts,E)})),!r||p<0){var T=v.length;if(v=v.filter((function(e){return e.pts>=0})),T!==v.length&&this.warn("Removed "+(v.length-T)+" of "+T+" samples (initPTS "+y+" / "+s+")"),!v.length)return;p=0===a?0:i&&!g?Math.max(0,E-y):v[0].pts-y}if("aac"===e.segmentCodec)for(var S=this.config.maxAudioFramesDrift,L=0,R=p+y;L=S*d&&D<1e4&&g){var I=Math.round(k/d);for(R=b-I*d;R0))return;N+=m;try{P=new Uint8Array(N)}catch(e){return void this.observer.emit(O.ERROR,O.ERROR,{type:x.MUX_ERROR,details:w.REMUX_ALLOC_ERROR,fatal:!1,chunkMeta:n,error:e,bytes:N,reason:"fail allocating audio mdat "+N})}f||(Ye(P,0,N),Ye(P,4,Ne.mdat))}P&&P.set(H,m);var Y=H.byteLength;m+=Y,c.push(an(!0,u,Y,0)),F=K}var W=c.length;if(W){var j=c[c.length-1];p=F-y,this.nextAudioTs=p+l*j.duration;var q=f?new Uint8Array(0):Ja.moof(e.sequenceNumber++,M/l,o({},e,{samples:c}));e.samples=[];var X=(M-y)/s,z=this.nextAudioTs/s,Q={data1:q,data2:P,startPTS:X,endPTS:z,startDTS:X,endDTS:z,type:"audio",hasAudio:!0,hasVideo:!1,nb:W};return this.isAudioContiguous=!0,Q}},t}(ie);function sn(e,t){var r;if(null===t)return e;for(r=t4294967296;)e+=r;return e}function on(e,t,r,i){var a=e.samples.length;if(a){for(var n=e.inputTimeScale,s=0;ssinf>>tenc' box: "+xe(i)+" -> "+xe(r)),e.set(r,8))}))}}(e,t);else{var l=s||o;null!=l&&l.encrypted&&this.warn('Init segment with encrypted track with has no key ("'+l.codec+'")!')}s&&(i=fn(s,B.AUDIO,this)),o&&(a=fn(o,B.VIDEO,this));var u={};s&&o?u.audiovideo={container:"video/mp4",codec:i+","+a,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:s?u.audio={container:"audio/mp4",codec:i,encrypted:s.encrypted,initSegment:e,id:"audio"}:o?u.video={container:"video/mp4",codec:a,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=u},r.remux=function(e,t,r,i,a,n,s,o,l,u,d){var h,f,c=this.initPTS,g=this.lastEndTime,v={audio:void 0,video:void 0,text:void 0,id3:r,initSegment:void 0};_(g)||(g=this.lastEndTime=a||0);var m=t.samples;if(!m.length)return v;var p=this.pendingInitSegment;p&&(this.pendingInitSegment=void 0,this.generateInitSegment(p,this.decryptdata,u));var y={initPTS:void 0,timescale:void 0,trackId:void 0},E=this.initData;if(null!=(h=E)&&h.length||(this.generateInitSegment(m),E=this.initData),null==(f=E)||!f.length)return this.warn("Failed to generate initSegment."),v;this.emitInitSegment&&(y.tracks=this.initTracks,v.initSegment=y,this.emitInitSegment=!1);var T=d?d.tracks:function(e,t,r,i,a){return rt(e,t,i)}(m,E,0,this),S=E.audio?T[E.audio.id]:null,L=E.video?T[E.video.id]:null,R=!!E.audio,A=!!E.video,b="";R&&(b+="audio"),A&&(b+="video");var k,D,I=hn(L,1/0),C=hn(S,1/0),P=hn(L,0,!0),x=hn(S,0,!0);L&&S&&E.audio&&(C>P||I>x)&&this.warn("audio and video track sample timestamps do not overlap. v: "+I+"-"+P+" a: "+C+"-"+x+"}",L,S);var w=!!S&&(!L||!c&&C1)&&(n||!c)&&(function(e,t,r,i){if(null===e)return!0;var a=Math.max(i,1),n=t-e.baseTime/e.timescale;return Math.abs(n-r)>=a}(c,k,a,D)||F!==c.timescale)){var U=!1,G=w?"audio":"video";if(c){var V=0!==a?k/a:1+k/1;U=k>=0&&Math.abs(1-V)<.001,this.log(G+" timestamps in track "+B+" at playlist time: "+(n?"":"~")+a+" maps to "+k+" with initPTS: "+c.baseTime/c.timescale+" ("+(N/F-c.baseTime/c.timescale)+"s diff) ("+b+") drift estimate: "+V+" "+(U?"(ignoring drift)":"remapping timestamps (initPTS)"))}U||(this.log("Found initPTS in "+G+" track "+B+" at playlist time: "+a+" offset: "+(k-a)+" ("+N+"/"+F+")"),c=null,y.initPTS=N,y.timescale=F,y.trackId=B)}c?(y.initPTS=c.baseTime,y.timescale=c.timescale,y.trackId=c.trackId):(y.timescale&&void 0!==y.trackId&&void 0!==y.initPTS||(this.warn("Could not set initPTS"),y.initPTS=k,y.timescale=1,y.trackId=-1),this.initPTS=c={baseTime:y.initPTS,timescale:y.timescale,trackId:y.trackId});var H=k-c.baseTime/c.timescale,K=H+D,Y=A&&void 0!==(null==O?void 0:O.ptsMin)?O.ptsMin/O.timescale-c.baseTime/c.timescale:H,W=A&&null!=O&&O.ptsMax?O.ptsMax/O.timescale-c.baseTime/c.timescale:K;D>0?this.lastEndTime=K:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var j={data1:M,data2:void 0,startPTS:Y,startDTS:H,endPTS:W,endDTS:K,type:b,hasAudio:R,hasVideo:A,nb:1,dropped:0,encrypted:!!E.audio&&E.audio.encrypted||!!E.video&&E.video.encrypted};v.audio=R&&!A?j:void 0,v.video=A?j:void 0;var q=this.isVideoContiguous,X=null==L?void 0:L.sampleCount;if(X){var z=L.keyFrameIndex,Q=-1!==z;j.nb=X,j.dropped=0===z||q?0:Q?z:X,j.independent=Q,j.firstKeyFrame=z,Q&&L.keyFrameStart&&(j.firstKeyFramePTS=(L.keyFrameStart-c.baseTime)/c.timescale),q||(v.independent=Q),this.isVideoContiguous||(this.isVideoContiguous=Q),j.dropped&&this.warn("fmp4 does not start with IDR: firstIDR "+z+"/"+X+" dropped: "+j.dropped+" start: "+(j.firstKeyFramePTS||"NA"))}return v.initSegment=y,v.id3=on(r,a,c,c),i.samples.length&&(v.text=ln(i,a,c)),v},t}(ie);function hn(e,t,r){return void 0===r&&(r=!1),void 0!==(null==e?void 0:e.start)?(e.start+(r?e.duration:0))/e.timescale:t}function fn(e,t,r){var i=e.codec;return i&&i.length>4?i:t===B.AUDIO?"ec-3"===i||"ac-3"===i||"alac"===i?i:"fLaC"===i||"Opus"===i?Rt(i,!1):(r.warn('Unhandled audio codec "'+i+'" in mp4 MAP'),i||"mp4a"):"mjpg"===i?i:(r.warn('Unhandled video codec "'+i+'" in mp4 MAP'),i||"avc1")}try{un=self.performance.now.bind(self.performance)}catch(e){un=Date.now}var cn=[{demux:Ia,remux:dn},{demux:Oa,remux:nn},{demux:ba,remux:nn},{demux:ka,remux:nn}],gn=function(){function e(e,t,r,i,a,n){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=r,this.id=a,this.logger=n}var t=e.prototype;return t.configure=function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()},t.push=function(e,t,r,i){var a=this;if(!this.observer)return vn(r);var n=r.transmuxing;n.executeStart=un();var s=new Uint8Array(e),o=this.currentTransmuxState,l=this.transmuxConfig;i&&(this.currentTransmuxState=i);var u=i||o,d=u.contiguous,h=u.discontinuity,f=u.trackSwitch,c=u.accurateTimeOffset,g=u.timeOffset,v=u.initSegmentChange,m=l.audioCodec,p=l.videoCodec,y=l.defaultInitPts,E=l.duration,T=l.initSegmentData,S=function(e,t){var r=null;return e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(r=t),r}(s,t);if(S&&Mr(S.method)){var L=this.getDecrypter(),R=Fr(S.method);return this.asyncResult=!0,this.decryptionPromise=L.decrypt(s,S.key.buffer,S.iv.buffer,R,r.decryptRange).then((function(e){var t=a.push(e,null,r);return a.decryptionPromise=null,t})),this.decryptionPromise}var A=this.needsProbing(h,f);if(A){var b=r.iframe&&T&&Oa.probe(T,this.logger)?T:s,k=this.configureTransmuxer(b);if(k)return this.logger.warn("[transmuxer] "+k.message),this.observer.emit(O.ERROR,O.ERROR,{type:x.MEDIA_ERROR,details:w.FRAG_PARSING_ERROR,fatal:!1,error:k,reason:k.message}),n.executeEnd=un(),vn(r)}(h||f||v||A)&&this.resetInitSegment(T,m,p,E,t,r),(h||v||A)&&this.resetInitialTimestamp(y),d||this.resetContiguity();var D=this.transmux(s,S,g,c,r);this.asyncResult=mn(D);var I=this.currentTransmuxState;return I.contiguous=!0,I.discontinuity=!1,I.trackSwitch=!1,n.executeEnd=un(),D},t.flush=function(e){var t=this,r=e.transmuxing;r.executeStart=un();var i=this.decrypter,a=this.currentTransmuxState,n=this.decryptionPromise;if(n)return this.asyncResult=!0,n.then((function(){return t.flush(e)}));var s=[],o=a.timeOffset;if(i){var l=i.flush();l&&s.push(this.push(l.buffer,null,e))}var u=this.demuxer,d=this.remuxer;if(!u||!d){r.executeEnd=un();var h=[vn(e)];return this.asyncResult?Promise.resolve(h):h}var f=u.flush(o,e);return mn(f)?(this.asyncResult=!0,f.then((function(r){return t.flushRemux(s,r,e),s}))):(this.flushRemux(s,f,e),this.asyncResult?Promise.resolve(s):s)},t.flushRemux=function(e,t,r){if(this.remuxer){var i=t.audioTrack,a=t.videoTrack,n=t.id3Track,s=t.textTrack,o=this.currentTransmuxState,l=o.accurateTimeOffset,u=o.timeOffset;this.logger.log("[transmuxer.ts]: Flushed "+this.id+" sn: "+r.sn+(r.part>-1?" part: "+r.part:"")+" of "+this.id+" playlist "+r.level);var d=this.remuxer.remux(i,a,n,s,u,l,!0,this.id,r,t.initData,t.sampleData);e.push({remuxResult:d,chunkMeta:r}),r.transmuxing.executeEnd=un()}},t.resetInitialTimestamp=function(e){var t=this.demuxer,r=this.remuxer;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))},t.resetContiguity=function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())},t.resetInitSegment=function(e,t,r,i,a,n){var s=this.demuxer,o=this.remuxer;s&&o&&(s.resetInitSegment(e,t,r,i,a,n),o.resetInitSegment(e,t,r,a))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0),this.observer&&this.observer.removeAllListeners(),this.decryptionPromise=null,this.decrypter=this.observer=void 0,this.logger=this.config=this.probe=void 0},t.transmux=function(e,t,r,i,a){return"SAMPLE-AES"===(null==t?void 0:t.method)?this.transmuxSampleAes(e,t,r,i,a):this.transmuxUnencrypted(e,r,i,a)},t.transmuxUnencrypted=function(e,t,r,i){var a=this.demuxer,n=this.remuxer;if(!a||!n)return vn(i);var s=a.demux(e,t,i,!1,!this.config.progressive),o=s.audioTrack,l=s.videoTrack,u=s.id3Track,d=s.textTrack;return{remuxResult:n.remux(o,l,u,d,t,r,!1,this.id,i,s.initData,s.sampleData),chunkMeta:i}},t.transmuxSampleAes=function(e,t,r,i,a){var n=this;return this.demuxer?this.demuxer.demuxSampleAes(e,t,r,a).then((function(e){return{remuxResult:n.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,n.id,a,e.initData,e.sampleData),chunkMeta:a}})):Promise.reject(new Error("no demuxer"))},t.configureTransmuxer=function(e){var t=this.config,r=this.observer,i=this.typeSupported;if(r){var a;try{for(var n=0,s=cn.length;n1&&l.id===(null==p?void 0:p.stats.chunkCount),R=!E&&(1===T||0===T&&(1===S||L&&S<=0)),A=self.performance.now();(E||T||0===a.stats.parsing.start)&&(a.stats.parsing.start=A),!n||!S&&R||(n.stats.parsing.start=A);var b=!(p&&(null==(d=a.initSegment)?void 0:d.url)===(null==(h=p.initSegment)?void 0:h.url)),k=new yn(y,R,o,E,v,b);if(!R||y||b){this.hls.logger.log("[transmuxer-interface]: Starting new transmux session for "+a.type+" sn: "+l.sn+(l.part>-1?" part: "+l.part:"")+" "+this.id+" playlist: "+l.level+" id: "+l.id+"\n discontinuity: "+y+"\n trackSwitch: "+E+"\n contiguous: "+R+"\n accurateTimeOffset: "+o+"\n timeOffset: "+v+"\n initSegmentChange: "+b);var D=new pn(r,i,t,s,u);this.configureTransmuxer(D)}if(this.frag=a,this.part=n,this.workerContext)this.workerContext.worker.postMessage({instanceNo:c,cmd:"demux",data:e,decryptdata:m,chunkMeta:l,state:k},e instanceof ArrayBuffer?[e]:[]);else if(g){var I=g.push(e,m,l,k);mn(I)?I.then((function(e){f.handleTransmuxComplete(e)})).catch((function(e){f.transmuxerError(e,l,"transmuxer-interface push error")})):this.handleTransmuxComplete(I)}},r.flush=function(e){var t=this;e.transmuxing.start=self.performance.now();var r=this.instanceNo,i=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:r,cmd:"flush",chunkMeta:e});else if(i){var a=i.flush(e);mn(a)?a.then((function(r){t.handleFlushResult(r,e)})).catch((function(r){t.transmuxerError(r,e,"transmuxer-interface flush error")})):this.handleFlushResult(a,e)}},r.transmuxerError=function(e,t,r){this.hls&&(this.error=e,this.hls.trigger(O.ERROR,{type:x.MEDIA_ERROR,details:w.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:r}))},r.handleFlushResult=function(e,t){var r=this;e.forEach((function(e){r.handleTransmuxComplete(e)})),this.onFlush(t)},r.configureTransmuxer=function(e){var t=this.instanceNo,r=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):r&&r.configure(e)},r.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},t}();function In(){return self.SourceBuffer||self.WebKitSourceBuffer}function _n(){if(!ve())return!1;var e=In();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}var Cn=0,Pn=1,xn=2,wn=function(e){function t(t,r,i){var a;return(a=e.call(this,t,r,i,"stream-controller",N.MAIN)||this).audioCodecSwap=!1,a.level=-1,a._forceStartLoad=!1,a._hasEnoughToStart=!1,a.altAudio=Cn,a.audioOnly=!1,a._couldBacktrack=!1,a._backtrackFragment=void 0,a.audioCodecSwitch=!1,a.videoBuffer=null,a.onMediaPlaying=function(){a.tick()},a.onMediaSeeked=function(){var e=a.media,t=e?e.currentTime:null;if(null!==t&&_(t)&&(a.log("Media seeked to "+t),a.getBufferedFrag(t))){var r=a.getFwdBufferInfoAtPos(e,t,N.MAIN,0);r&&0!==r.len?a.tick():a.log("Main buffer empty at "+t+' on "seeked" event: '+(r?r.len:r))}},a.registerListeners(),a}u(t,e);var r=t.prototype;return r.registerListeners=function(){e.prototype.registerListeners.call(this);var t=this.hls;t.on(O.MANIFEST_PARSED,this.onManifestParsed,this),t.on(O.LEVEL_LOADING,this.onLevelLoading,this),t.on(O.LEVEL_LOADED,this.onLevelLoaded,this),t.on(O.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(O.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(O.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(O.BUFFER_CREATED,this.onBufferCreated,this),t.on(O.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(O.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(O.FRAG_BUFFERED,this.onFragBuffered,this)},r.unregisterListeners=function(){e.prototype.unregisterListeners.call(this);var t=this.hls;t.off(O.MANIFEST_PARSED,this.onManifestParsed,this),t.off(O.LEVEL_LOADED,this.onLevelLoaded,this),t.off(O.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(O.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(O.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(O.BUFFER_CREATED,this.onBufferCreated,this),t.off(O.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(O.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(O.FRAG_BUFFERED,this.onFragBuffered,this)},r.onHandlerDestroying=function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),e.prototype.onHandlerDestroying.call(this)},r.startLoad=function(e,t){if(this.levels){var r=this.lastCurrentTime,i=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var a=i.startLevel;-1===a&&(i.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=i.firstAutoLevel),i.nextLoadLevel=a,this.level=i.loadLevel,this._hasEnoughToStart=!!t}r>0&&-1===e&&!t&&this.initPTS.length&&(this.log("Override startPosition with lastCurrentTime @"+r),e=r),this.state=Yi.IDLE,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,t||this.fragmentTracker.hasFragments(this.playlistType)||(this._hasEnoughToStart=this.startFragRequested=!1),this.tick()}else this._forceStartLoad=!0,this.state=Yi.STOPPED},r.stopLoad=function(){this._forceStartLoad=!1,e.prototype.stopLoad.call(this)},r.doTick=function(){switch(this.state){case Yi.WAITING_LEVEL:var e=this.levels,t=this.level,r=null==e?void 0:e[t],i=null==r?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r&&!this.waitForLive(r))){if(this.waitForCdnTuneIn(i))break;this.state=Yi.IDLE;break}if(this.hls.nextLoadLevel!==this.level){this.state=Yi.IDLE;break}break;case Yi.FRAG_LOADING_WAITING_RETRY:this.checkRetryDate()}this.state===Yi.IDLE&&this.doTickIdle(),this.onTickEnd()},r.onTickEnd=function(){e.prototype.onTickEnd.call(this),this.checkFragmentChanged()},r.doTickIdle=function(){var e=this.hls,t=this.levelLastLoaded,r=this.levels,i=this.media;if(null!==t&&(i||this.primaryPrefetch||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var a=this.buffering?e.nextLoadLevel:e.loadLevel;if(null!=r&&r[a]){var n=r[a],s=this.getMainFwdBufferInfo();if(null!==s){var o=this.getLevelDetails();if(o&&this._streamEnded(s,o)&&this.altAudio!==Pn){var l={type:this.targetBufferType()};return this.hls.trigger(O.BUFFER_EOS,l),void(this.state=Yi.ENDED)}if(this.buffering){e.loadLevel!==a&&-1===e.manualLevel&&this.log("Adapting to level "+a+" from level "+this.level),this.level=e.nextLoadLevel=a;var u=n.details;if(!u||this.state===Yi.WAITING_LEVEL||this.waitForLive(n))return this.level=a,this.state=Yi.WAITING_LEVEL,void(this.startFragRequested=!1);var d=s.len,h=this.getMaxBufferLength(n.maxBitrate);if(!(d>=h)){this.backtrackFragment&&this.backtrackFragment.start>s.end&&(this.backtrackFragment=void 0);var f=this.backtrackFragment?this.backtrackFragment.start:s.end,c=this.getNextFragment(f,u);if(this.couldBacktrack&&!this.fragPrevious&&c&&G(c)&&this.fragmentTracker.getState(c)!==Ri){var g,v=(null!=(g=this.backtrackFragment)?g:c).sn-u.startSN,m=u.fragments[v-1];m&&c.cc===m.cc&&(c=m,this.fragmentTracker.removeFragment(m))}else this.backtrackFragment&&s.len&&(this.backtrackFragment=void 0);if(c&&this.isLoopLoading(c,f)){if(!c.gap){var p=this.audioOnly&&!this.altAudio?B.AUDIO:B.VIDEO,y=(p===B.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;y&&this.afterBufferFlushed(y,p)}c=this.getNextFragmentLoopLoading(c,u,s,N.MAIN,h)}c&&(this.exceedsMaxBuffer(s,h,c)||this.loadFragment(c,n,f))}}}}}},r.loadFragment=function(t,r,i){var a=this.fragmentTracker.getState(t);a===Ti||a===Li?this.bitrateTest?(this.log("Fragment "+t.sn+" of level "+t.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(t,r)):e.prototype.loadFragment.call(this,t,r,i):this.clearTrackerIfNeeded(t)},r.immediateLevelSwitch=function(){var t;this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY),this.altAudio!==Cn&&((null==(t=this.getLevelDetails())?void 0:t.fragmentStart)||0)>this.lastCurrentTime&&e.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")},r.getBufferOutput=function(){return this.mediaBuffer&&this.altAudio===xn?this.mediaBuffer:this.media},r.checkFragmentChanged=function(){var e=this.fragPlaying;if(!this.checkFragPlaying())return!1;var t=this.fragPlaying;if(t){var r=t.level;this.hls.trigger(O.FRAG_CHANGED,{frag:t,previousFrag:e}),(null==e?void 0:e.level)!==r&&this.hls.trigger(O.LEVEL_SWITCHED,{level:r})}return!0},r.abortCurrentFrag=function(){this.backtrackFragment=void 0,e.prototype.abortCurrentFrag.call(this)},r.flushMainBuffer=function(t,r){e.prototype.flushMainBuffer.call(this,t,r,this.targetBufferType())},r.targetBufferType=function(){return this.altAudio!==xn||this.audioOnly?null:"video"},r.onMediaAttached=function(t,r){e.prototype.onMediaAttached.call(this,t,r);var i=r.media;hr(i,"playing",this.onMediaPlaying),hr(i,"seeked",this.onMediaSeeked)},r.onMediaDetaching=function(t,r){var i=this.media;i&&(fr(i,"playing",this.onMediaPlaying),fr(i,"seeked",this.onMediaSeeked)),this.videoBuffer=null,e.prototype.onMediaDetaching.call(this,t,r),r.transferMedia||(this._hasEnoughToStart=!1)},r.onManifestLoading=function(){e.prototype.onManifestLoading.call(this),this.log("Trigger BUFFER_RESET"),this.hls.trigger(O.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.backtrackFragment=void 0,this.altAudio=Cn,this.audioOnly=!1},r.onManifestParsed=function(e,t){for(var r,i,a=!1,n=!1,s=0;s=o.startCC)return!0;delete i.initPTS[t]})),this.tick()}else this.warn("Levels were reset while loading level "+s)},r.synchronizeToLiveEdge=function(e){var t=this.config,r=this.media;if(r){var i=this.hls.liveSyncPosition,a=this.playhead,n=e.fragmentStart,s=e.edge,o=a>=n-t.maxFragLookUpTolerance&&a<=s;if(null!==i&&r.duration>i&&(a=this.config.appendErrorMaxRetry&&(this.warn("Marking fragment "+t.frag.sn+" of level "+t.frag.level+" as a gap after "+t.appendsWithoutProgress+" appends without buffered range growth, to prevent loop loading"),this.fragmentTracker.addAsGap(t.frag));break;case w.MEDIA_SOURCE_REQUIRES_RESET:this.onSourceBufferError(N.MAIN,t);break;case w.BUFFER_ADD_CODEC_ERROR:case w.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case w.BUFFER_FULL_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case w.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}},r.onFragLoadEmergencyAborted=function(){this.state=Yi.IDLE,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()},r.onBufferFlushed=function(e,t){var r=t.type;if(r!==B.AUDIO||!this.altAudio){var i=(r===B.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,r),this.tick())}},r.onLevelsUpdated=function(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels},r.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},r.seekToStartPos=function(){var e=this.media;if(e){var t=e.currentTime,r=this.startPosition;if(r>=0&&t0&&(oL.cc;if(!1!==i.independent){var b=u.startPTS,k=u.endPTS,D=u.startDTS,I=u.endDTS;if(o)o.elementaryStreams[u.type]={startPTS:b,endPTS:k,startDTS:D,endDTS:I};else if(u.firstKeyFrame&&u.independent&&1===a.id&&!A&&(this.couldBacktrack=!0),u.dropped&&u.independent){var C=this.getMainFwdBufferInfo(),P=(C?C.end:this.getLoadPosition())+this.config.maxBufferHole,x=u.firstKeyFramePTS?u.firstKeyFramePTS:b;if(!R&&P2&&(s.gap=!0);s.setElementaryStreamInfo(u.type,b,k,D,I),this.backtrackFragment&&(this.backtrackFragment=s),this.bufferFragmentData(u,s,o,a,R||A)}else{if(!R&&!A)return void this.backtrack(s);s.gap=!0}}if(g){var w=g.startPTS,M=g.endPTS,F=g.startDTS,N=g.endDTS;o&&(o.elementaryStreams[B.AUDIO]={startPTS:w,endPTS:M,startDTS:F,endDTS:N}),s.setElementaryStreamInfo(B.AUDIO,w,M,F,N),this.bufferFragmentData(g,s,o,a)}if(c&&null!=h&&h.samples.length){var U={id:t,frag:s,details:c,samples:h.samples};r.trigger(O.FRAG_PARSING_METADATA,U)}if(c&&d){var G={id:t,frag:s,details:c,samples:d.samples};r.trigger(O.FRAG_PARSING_USERDATA,G)}}}else this.resetWhenMissingContext(a)},r.logMuxedErr=function(e){this.warn((G(e)?"Media":"Init")+" segment with muxed audiovideo where only video expected: "+e.url)},r._bufferInitSegment=function(e,t,r,i){var a=this;if(this.state===Yi.PARSING){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(r));var n=t.audio,s=t.video,o=t.audiovideo;if(n){var l=e.audioCodec,u=At(n.codec,l);if("mp4a"===u&&(u="mp4a.40.5"),this.audioCodecSwitch){u&&(u=-1!==u.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var d=n.metadata;d&&"channelCount"in d&&1!==(d.channelCount||1)&&!function(){if(void 0===ut){var e=ht.match(/Firefox\/(\d+)/i);ut=e?parseInt(e[1]):0}return ut}()&&(u="mp4a.40.5")}u&&-1!==u.indexOf("mp4a.40.5")&&/Android/.test(ht)&&"audio/mpeg"!==n.container&&(u="mp4a.40.2",this.log("Android: force audio codec to "+u)),l&&l!==u&&this.log('Swapping manifest audio codec "'+l+'" for "'+u+'"'),n.levelCodec=u,n.id=N.MAIN,this.log("Init audio buffer, container:"+n.container+", codecs[selected/level/parsed]=["+(u||"")+"/"+(l||"")+"/"+n.codec+"]"),delete t.audiovideo}if(s){s.levelCodec=e.videoCodec,s.id=N.MAIN;var h=s.codec;if(4===(null==h?void 0:h.length))switch(h){case"hvc1":case"hev1":s.codec="hvc1.1.6.L120.90";break;case"av01":s.codec="av01.0.04M.08";break;case"avc1":s.codec="avc1.42e01e"}this.log("Init video buffer, container:"+s.container+", codecs[level/parsed]=["+(e.videoCodec||"")+"/"+h+"]"+(s.codec!==h?" parsed-corrected="+s.codec:"")+(s.supplemental?" supplemental="+s.supplemental:"")),delete t.audiovideo}o&&(this.iframesOnly&&this.logMuxedErr(r),this.log("Init audiovideo buffer, container:"+o.container+", codecs[level/parsed]=["+e.codecs+"/"+o.codec+"]"),delete t.video,delete t.audio);var f=Object.keys(t);if(f.length){if(this.hls.trigger(O.BUFFER_CODECS,t),!this.hls)return;f.forEach((function(e){var n=t[e].initSegment;null!=n&&n.byteLength&&a.hls.trigger(O.BUFFER_APPENDING,{type:e,data:n,frag:r,part:null,chunkMeta:i,parent:r.type})}))}this.tickImmediate()}},r.getMainFwdBufferInfo=function(){var e=this.getBufferOutput();return this.getFwdBufferInfo(e,N.MAIN)},r.backtrack=function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=Yi.IDLE},a(t,[{key:"backtrackFragment",get:function(){return this._backtrackFragment},set:function(e){this._backtrackFragment=e}},{key:"couldBacktrack",get:function(){return this._couldBacktrack},set:function(e){this._couldBacktrack=e}},{key:"hasEnoughToStart",get:function(){return this._hasEnoughToStart}},{key:"maxBufferLength",get:function(){var e=this.levels,t=this.level,r=null==e?void 0:e[t];return r?this.getMaxBufferLength(r.maxBitrate):this.config.maxBufferLength}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e;if(this.fragPlaying)return this.fragPlaying;var t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;return _(t)?this.getAppendedFrag(t):null}},{key:"currentProgramDateTime",get:function(){var e,t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(_(t)){var r=this.getLevelDetails(),i=this.currentFrag||(r?Wt(null,r.fragments,t):null);if(i){var a=i.programDateTime;if(null!==a){var n=a+1e3*(t-i.start);return new Date(n)}}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])}(Wi),On=function(){function e(){this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=0,this.config=null,this.callbacks=null,this.context=null,this.stats=new M}var t=e.prototype;return t.destroy=function(){this.callbacks=this.context=this.config=null,this.abortInternal(),this.stats=null},t.load=function(e,t,r){var i=this.stats;if(i.loading.start)throw new Error("Loader can only be used once.");i.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()},t.abort=function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.getNetworkDetails())},t.loadtimeout=function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(Z(e,this.stats.retry,!0))this.retry(e);else{var t;fe.warn("timeout while loading "+(null==(t=this.context)?void 0:t.url));var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.getNetworkDetails()))}}},t.retry=function(e){var t=this,r=this.context,i=this.stats;this.retryDelay=Q(e,i.retry),i.retry++,fe.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+(null==r?void 0:r.url)+", retrying "+i.retry+"/"+e.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.resetInternalLoader(),self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout((function(){return t.loadInternal()}),this.retryDelay)},e}(),Mn=function(){function e(){this.chunks=[],this.dataLength=0}var t=e.prototype;return t.push=function(e){this.chunks.push(e),this.dataLength+=e.length},t.flush=function(){var e,t=this.chunks,r=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var r=new Uint8Array(t),i=0,a=0;a=i&&a(t,r,n.flush().buffer,e)):a(t,r,l.buffer,e),o()})).catch((function(){return Promise.reject()}))};return o()},t}(On);function Bn(e,t){return new self.Request(e.url,t)}var Un=function(e){function t(t,r,i){var a;return(a=e.call(this,t)||this).code=void 0,a.details=void 0,a.code=r,a.details=i,a}return u(t,e),t}(v(Error)),Gn=/^age:\s*[\d.]+\s*$/im,Vn=function(e){function t(t){var r;return(r=e.call(this)||this).xhrSetup=void 0,r.loader=null,r.xhrSetup=t.xhrSetup||null,r}u(t,e);var r=t.prototype;return r.destroy=function(){e.prototype.destroy.call(this),this.loader=null,this.xhrSetup=null},r.abortInternal=function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))},r.getNetworkDetails=function(){return this.loader},r.resetInternalLoader=function(){this.loader=null},r.loadInternal=function(){var e=this,t=this.config,r=this.context;if(t&&r){var i=this.loader=new self.XMLHttpRequest,a=this.stats;a.loading.first=0,a.loaded=0,a.aborted=!1;var n=this.xhrSetup;n?Promise.resolve().then((function(){if(e.loader===i&&!e.stats.aborted)return n.call(e,i,r.url,r)})).catch((function(t){if(e.loader===i&&!e.stats.aborted)return i.open("GET",r.url,!0),n.call(e,i,r.url,r)})).then((function(){e.loader!==i||e.stats.aborted||e.openAndSendXhr(i,r,t)})).catch((function(t){var n;null==(n=e.callbacks)||n.onError({code:i.status,text:t.message},r,i,a)})):this.openAndSendXhr(i,r,t)}},r.openAndSendXhr=function(e,t,r){e.readyState||e.open("GET",t.url,!0);var i=t.headers,a=r.loadPolicy,n=a.maxTimeToFirstByteMs,s=a.maxLoadTimeMs;if(i)for(var o in i)e.setRequestHeader(o,i[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=n&&_(n)?n:s,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()},r.readystatechange=function(){var e=this.context,t=this.loader,r=this.stats;if(e&&t){var i=t.readyState,a=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var n=t.status,s="text"===t.responseType?t.responseText:null;if(n>=200&&n<300){var o=null!=s?s:t.response;if(null!=o){var l,u;r.loading.end=Math.max(self.performance.now(),r.loading.first);var d="arraybuffer"===t.responseType?o.byteLength:o.length;r.loaded=r.total=d,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first);var h=null==(l=this.callbacks)?void 0:l.onProgress;h&&h(r,e,o,t);var f={url:t.responseURL,data:o,code:n};return e.rangeEnd&&d!==e.rangeEnd-e.rangeStart&&fe.warn("Payload length "+d+" does not match requested Range: bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),void(null==(u=this.callbacks)||u.onSuccess(f,r,e,t))}}var c,g=a.loadPolicy.errorRetry;Z(g,r.retry,!1,{url:e.url,data:void 0,code:n})?this.retry(g):(fe.error(n+" while loading "+e.url),null==(c=this.callbacks)||c.onError({code:n,text:t.statusText},e,t,r))}}},r.loadprogress=function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)},r.getCacheAge=function(){var e=null;if(this.loader&&Gn.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e},r.getResponseHeader=function(e){return this.loader&&new RegExp("^"+e+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null},t}(On),Hn={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},Kn=f(f({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,loopBackBufferFlush:void 0,startOnSegmentBoundary:!1,nextAudioTrackBufferFlushForwardOffset:.25,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,skipBufferHolePadding:.1,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveMaxUnchangedPlaylistRefresh:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,appendTimeout:1/0,ignorePlaylistParsingErrors:!1,loader:Vn,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,handleMpegTsVideoIntegrityErrors:"process",abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,abrSwitchInterval:0,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:null,requireKeySystemAccessOnStart:!1,reuseKeySessions:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,emsgKLVSchemaUri:void 0,enableInterstitialPlayback:!1,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,iframeCacheLimit:2097152,useMediaCapabilities:!1,preserveManualLevelOnError:!1,errorPenaltyExpireMs:0,certLoadPolicy:{default:Hn},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:Hn},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,streamController:wn,abrController:Ht,bufferController:yr,capLevelController:br,errorController:ar,fpsController:Ei,id3TrackController:ra,gapController:ji,latencyController:ia},{cueHandler:ge,enableWebVTT:!1,enableIMSC1:!1,enableCEA708Captions:!1,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:void 0,subtitleTrackController:void 0,timelineController:void 0,audioStreamController:void 0,audioTrackController:void 0,emeController:void 0,cmcdController:void 0,contentSteeringController:mi,iframeController:void 0,interstitialsController:void 0});function Yn(e,t,r){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');if(void 0!==t.liveMaxUnchangedPlaylistRefresh){var i=t.liveMaxUnchangedPlaylistRefresh,a=(n=i,s=2,o=1/0,Math.max(s,Math.min(n,o)));a!==i&&r.warn('hls.js config: "liveMaxUnchangedPlaylistRefresh" clamped from '+i+" to "+a+"."),t.liveMaxUnchangedPlaylistRefresh=a}var n,s,o,l=Wn(e),u=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((function(e){var i=("level"===e?"playlist":e)+"LoadPolicy",a=void 0===t[i],n=[];u.forEach((function(r){var s=e+"Loading"+r,o=t[s];if(void 0!==o&&a){n.push(s);var u=l[i].default;switch(t[i]={default:u},r){case"TimeOut":u.maxLoadTimeMs=o,u.maxTimeToFirstByteMs=o;break;case"MaxRetry":u.errorRetry.maxNumRetry=o,u.timeoutRetry.maxNumRetry=o;break;case"RetryDelay":u.errorRetry.retryDelayMs=o,u.timeoutRetry.retryDelayMs=o;break;case"MaxRetryTimeout":u.errorRetry.maxRetryDelayMs=o,u.timeoutRetry.maxRetryDelayMs=o}}})),n.length&&r.warn('hls.js config: "'+n.join('", "')+'" setting(s) are deprecated, use "'+i+'": '+Bt(t[i]))})),f(f({},l),t)}function Wn(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(Wn):Object.keys(e).reduce((function(t,r){return t[r]=Wn(e[r]),t}),{}):e}function jn(e,t){var r=e.loader;r!==Nn&&r!==Vn?(t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=Nn,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}var qn=function(e){function t(t,r){var i;return(i=e.call(this,r,t.logger)||this).hls=void 0,i.canLoad=!1,i.timer=-1,i.loadingSync=!1,i.hls=t,i}u(t,e);var r=t.prototype;return r.destroy=function(){this.clearTimer(),this.hls=null},r.clearTimer=function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)},r.startLoad=function(){this.canLoad=!0,this.loadPlaylist()},r.stopLoad=function(){this.canLoad=!1,this.clearTimer()},r.switchParams=function(e,t,r){var i=null==t?void 0:t.renditionReports;if(i){for(var a=-1,n=0;n=0&&h>t.partTarget&&(d+=1)}var f=r&&wt(r);return new Ot(u,d>=0?d:void 0,f)}}},r.loadPlaylist=function(e){this.clearTimer()},r.loadingPlaylist=function(e,t){this.clearTimer()},r.shouldLoadPlaylist=function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)},r.getUrlWithDirectives=function(e,t){if(t)try{return t.addDirectives(e)}catch(e){this.warn("Could not construct new URL with HLS Delivery Directives: "+e)}return e},r.playlistLoaded=function(e,t,r){var i=t.details,a=t.stats,n=i.fragments,s=self.performance.now(),o=a.loading.first?Math.max(0,Math.floor(s-a.loading.first)):0;i.advancedDateTime=Date.now()-o;var l=this.hls.config.timelineOffset;if(l!==i.appliedTimelineOffset){var u=Math.max(l||0,0);i.appliedTimelineOffset=u,n.forEach((function(e){null==e||e.setStart(e.playlistOffset+u)}))}if(i.live||null!=r&&r.live){var d,h="levelInfo"in t?t.levelInfo:t.track;i.reloaded(r);var f=null==(d=n[n.length-1])?void 0:d.type;if(i.misses>=this.hls.config.liveMaxUnchangedPlaylistRefresh){var c=new Error(f+" playlist "+h.id+" hit max allowed unchanged reloads.");this.warn(c);var g=t.networkDetails,v=t.context;return void this.hls.trigger(O.ERROR,{type:x.NETWORK_ERROR,details:w.PLAYLIST_UNCHANGED_ERROR,fatal:!1,url:i.url,error:c,reason:c.message,level:t.level,parent:f,context:v,networkDetails:g,stats:a})}if(r){si(r,i,this);var m=i.playlistParsingError;if(m){this.warn(m);var p=this.hls;if(!p.config.ignorePlaylistParsingErrors){var y=t.networkDetails;return void p.trigger(O.ERROR,{type:x.NETWORK_ERROR,details:w.LEVEL_PARSING_ERROR,fatal:!1,url:i.url,error:m,reason:m.message,level:t.level,parent:f,networkDetails:y,stats:a})}i.playlistParsingError=null}}-1===i.requestScheduled&&(i.requestScheduled=a.loading.start);var E=this.hls.mainForwardBufferInfo,T=E?E.end-E.len:0,S=ui(i,1e3*(i.edge-T));i.requestScheduled+S0){if(M>3*i.targetduration)this.log("Playlist last advanced "+P.toFixed(2)+"s ago. Omitting segment and part directives."),A=void 0,b=void 0;else if(null!=r&&r.tuneInGoal&&M-i.partTarget>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+F+" with playlist age: "+i.age),F=0;else{var N=Math.floor(F/i.targetduration);A+=N,void 0!==b&&(b+=Math.round(F%i.targetduration/i.partTarget)),this.log("CDN Tune-in age: "+i.ageHeader+"s last advanced "+P.toFixed(2)+"s goal: "+F+" skip sn "+N+" to part "+b)}i.tuneInGoal=F}if(L=this.getDeliveryDirectives(i,t.deliveryDirectives,A,b),k||!C)return i.requestScheduled=s,void this.loadingPlaylist(h,L)}else(i.canBlockReload||i.canSkipUntil)&&(L=this.getDeliveryDirectives(i,t.deliveryDirectives,A,b));L&&void 0!==A&&i.canBlockReload&&(i.requestScheduled=a.loading.first+Math.max(S-2*o,S/2)),this.scheduleLoading(h,L,i)}else this.clearTimer()},r.scheduleLoading=function(e,t,r){var i=this,a=r||e.details;if(a){var n=self.performance.now(),s=a.requestScheduled;if(n>=s&&!this.loadingSync)return this.loadingSync=!0,this.loadingPlaylist(e,t),void(this.loadingSync=!1);var o=Math.max(s-n,0);this.log("reload live playlist "+(e.name||e.bitrate+"bps")+" in "+Math.round(o)+" ms"),this.clearTimer(),this.timer=self.setTimeout((function(){return i.loadingPlaylist(e,t)}),o)}else this.loadingPlaylist(e,t)},r.getDeliveryDirectives=function(e,t,r,i){var a=wt(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,i=t.part,a=Ct),new Ot(r,i,a)},r.checkRetry=function(e){var t=this,r=e.details,i=j(e),a=e.errorAction,n=a||{},s=n.action,o=n.retryCount,l=void 0===o?0:o,u=n.retryConfig,d=!!a&&!!u&&(s===$t||!a.resolved&&s===zt);if(d){var h;if(l>=u.maxNumRetry)return!1;if(i&&null!=(h=e.context)&&h.deliveryDirectives)this.warn("Retrying playlist loading "+(l+1)+"/"+u.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var f,c=J(null==(f=e.response)?void 0:f.code);if(this.clearTimer(),c)this.log("Waiting for connection (offline)"),e.reason="offline",this.timer=self.setTimeout((function(){return t.checkOfflineStatus()}),1e3);else{var g=Q(u,l);this.warn("Retrying playlist loading "+(l+1)+"/"+u.maxNumRetry+' after "'+r+'" in '+g+"ms"),this.timer=self.setTimeout((function(){return t.loadPlaylist()}),g)}}e.levelRetry=!0,a.resolved=!0}return d},r.checkOfflineStatus=function(){var e=this;this.clearTimer(),J(0)?this.timer=self.setTimeout((function(){return e.checkOfflineStatus()}),1e3):(this.log("Connection restored (online)"),this.loadPlaylist())},t}(ie),Xn=function(e){function t(t,r){var i;return(i=e.call(this,t,"level-controller")||this)._levels=[],i._firstLevel=-1,i._maxAutoLevel=-1,i._startLevel=void 0,i.currentLevel=null,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.steering=void 0,i.lastABRSwitchTime=-1,i._iframeVariants=[],i.onParsedComplete=void 0,i.steering=r,i._registerListeners(),i}u(t,e);var r=t.prototype;return r._registerListeners=function(){var e=this.hls;e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(O.LEVEL_LOADED,this.onLevelLoaded,this),e.on(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(O.FRAG_BUFFERED,this.onFragBuffered,this),e.on(O.ERROR,this.onError,this)},r._unregisterListeners=function(){var e=this.hls;e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(O.LEVEL_LOADED,this.onLevelLoaded,this),e.off(O.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(O.FRAG_BUFFERED,this.onFragBuffered,this),e.off(O.ERROR,this.onError,this)},r.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),e.prototype.destroy.call(this)},r.stopLoad=function(){this._levels.forEach((function(e){e.loadError=0,e.fragmentError=0})),e.prototype.stopLoad.call(this)},r.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1,this._iframeVariants=[]},r.onManifestLoading=function(e,t){this.resetLevels()},r.onManifestLoaded=function(e,t){var r=this,i=this.hls.config.preferManagedMediaSource,a=[],n={},s={},o=!1,l=!1,u=!1,d=!1;t.levels.forEach((function(e){var t=e.attrs,h=$n(e,i),f=e.audioCodec,c=e.videoCodec,g=e.imageCodec,v=e.width,m=e.height;if(h){o||(o=!(!v||!m)),l||(l=!!c),u||(u=!!f),d||(d=!!g);var p=t.CODECS,y=t["FRAME-RATE"],E=t["HDCP-LEVEL"],T=t["PATHWAY-ID"],S=t.RESOLUTION,L=t["VIDEO-RANGE"],R=(T||".")+"-"+e.bitrate+"-"+S+"-"+y+"-"+p+"-"+L+"-"+E;if(n[R])if(n[R].uri===e.url||e.attrs["PATHWAY-ID"])e.iframes||(n[R].addGroupId("audio",t.AUDIO),n[R].addGroupId("text",t.SUBTITLES));else{var A=s[R]+=1;e.attrs["PATHWAY-ID"]=new Array(A+1).join(".");var b=r.createLevel(e);n[R]=b,a.push(b)}else{var k=r.createLevel(e);n[R]=k,s[R]=1,a.push(k)}}else r.log('Some or all CODECS not supported "'+t.CODECS+'"')})),this.filterAndSortMediaOptions(a,t,o,l,u,d)},r.createLevel=function(e){var t=new Mt(e),r=e.supplemental;if(null!=r&&r.videoCodec&&!Qn(r.videoCodec,this.hls.config.preferManagedMediaSource)){var i=new Error('SUPPLEMENTAL-CODECS not supported "'+r.videoCodec+'"');this.log(i.message),t.supportedResult=ce.getUnsupportedResult(i,[])}return t},r.filterAndSortMediaOptions=function(e,t,r,i,a,n){var s,o=this,l=[],u=[],d=e,h=(null==(s=t.stats)?void 0:s.parsing)||{},f=this.hls.config.preferManagedMediaSource;if((r||i)&&a&&(d=d.filter((function(e){var t,r=e.videoCodec,i=e.videoRange,a=e.width,n=e.height;return(!!r||!(!a||!n))&&!!(t=i)&&_t.indexOf(t)>-1}))),i&&n&&(d=d.filter((function(e){return!e.imageCodec}))),0===d.length)return Promise.resolve().then((function(){if(o.hls){var e="no level with compatible codecs found in manifest",r=e;t.levels.length&&(r="one or more CODECS in variant not supported: "+Bt(t.levels.map((function(e){return e.attrs.CODECS})).filter((function(e,t,r){return r.indexOf(e)===t}))),o.warn(r),e+=" ("+r+")");var i=new Error(e);o.hls.trigger(O.ERROR,{type:x.MEDIA_ERROR,details:w.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:i,reason:r})}})),void(h.end=performance.now());t.audioTracks&&Zn(l=t.audioTracks.filter((function(e){return!e.audioCodec||zn(e.audioCodec,f)}))),t.subtitles&&Zn(u=t.subtitles);var c=d.slice(0);d.sort((function(e,t){if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return _t.indexOf(e.videoRange)-_t.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){var i=Et(e.videoCodec),a=Et(t.videoCodec);if(i!==a)return a-i}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var n=Tt(e.codecSet),s=Tt(t.codecSet);if(n!==s)return s-n}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0}));var g=c[0];if(this.steering&&(d=this.steering.filterParsedLevels(d)).length!==c.length)for(var v=0;vE&&E===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=T)}break}var S=t.iframeVariants.filter((function(e){return $n(e,f)}));this._iframeVariants=S;var L=a&&!i,R=this.hls.config,A=!(!R.audioStreamController||!R.audioTrackController),b={levels:d,audioTracks:l,subtitleTracks:u,iframeVariants:S,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:a,video:i,altAudio:A&&!L&&l.some((function(e){return!!e.url}))};h.end=performance.now(),this.hls.trigger(O.MANIFEST_PARSED,b)},r.onError=function(e,t){!t.fatal&&t.context&&t.context.type===F.LEVEL&&t.context.level===this.level&&this.checkRetry(t)},r.onFragBuffered=function(e,t){var r=t.frag;if(r.type===N.MAIN){var i=r.elementaryStreams;if(!Object.keys(i).some((function(e){return!!i[e]})))return;var a=this._levels[r.level];null!=a&&a.loadError&&(this.log("Resetting level error count of "+a.loadError+" on frag buffered"),a.loadError=0)}},r.onLevelLoaded=function(e,t){var r,i,a=t.level,n=t.details,s=t.levelInfo;if(!s)return this.warn("Invalid level index "+a),void(null!=(i=t.deliveryDirectives)&&i.skip&&(n.deltaUpdateFailed=!0));if(s===this.currentLevel||t.withoutMultiVariant){0===s.fragmentError&&(s.loadError=0);var o=s.details;o===t.details&&o.advanced&&(o=void 0),this.playlistLoaded(a,t,o)}else null!=(r=t.deliveryDirectives)&&r.skip&&(n.deltaUpdateFailed=!0)},r.loadPlaylist=function(t){e.prototype.loadPlaylist.call(this),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,t)},r.loadingPlaylist=function(t,r){e.prototype.loadingPlaylist.call(this,t,r);var i=this.getUrlWithDirectives(t.uri,r),a=this.currentLevelIndex,n=t.attrs["PATHWAY-ID"],s=t.details,o=null==s?void 0:s.age;this.log("Loading level index "+a+(void 0!==(null==r?void 0:r.msn)?" at sn "+r.msn+" part "+r.part:"")+(n?" Pathway "+n:"")+(o&&s.live?" age "+o.toFixed(1)+(s.type&&" "+s.type||""):"")+" "+i),this.hls.trigger(O.LEVEL_LOADING,{url:i,level:a,levelInfo:t,pathwayId:t.attrs["PATHWAY-ID"],id:0,deliveryDirectives:r||null})},r.removeLevel=function(e){var t,r=this;if(1!==this._levels.length){var i=this._levels.filter((function(t,i){return i!==e||(r.steering&&r.steering.removeLevel(t),t===r.currentLevel&&(r.currentLevel=null,r.currentLevelIndex=-1,t.details&&t.details.fragments.forEach((function(e){return e.level=-1}))),!1)}));ci(i),this._levels=i,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);var a=i.length-1;this._firstLevel=Math.min(this._firstLevel,a),this._startLevel&&(this._startLevel=Math.min(this._startLevel,a)),this.hls.trigger(O.LEVELS_UPDATED,{levels:i})}},r.onLevelsUpdated=function(e,t){var r=t.levels;this._levels=r},r.checkMaxAutoUpdated=function(){var e=this.hls,t=e.autoLevelCapping,r=e.maxAutoLevel,i=e.maxHdcpLevel;this._maxAutoLevel!==r&&(this._maxAutoLevel=r,this.hls.trigger(O.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:r,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))},a(t,[{key:"iframeVariants",get:function(){return 0===this._iframeVariants.length?null:this._iframeVariants}},{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"loadLevelObj",get:function(){return this.currentLevel}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;if(0!==t.length){if(e<0||e>=t.length){var r=new Error("invalid level idx"),i=e<0;if(this.hls.trigger(O.ERROR,{type:x.OTHER_ERROR,details:w.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:r,reason:r.message}),i)return;e=Math.min(e,t.length-1)}var a=this.currentLevelIndex,n=this.currentLevel,s=n?n.attrs["PATHWAY-ID"]:void 0,o=t[e],l=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=o,a!==e||!n||s!==l){this.log("Switching to level "+e+" ("+(o.height?o.height+"p ":"")+(o.videoRange?o.videoRange+" ":"")+(o.codecSet?o.codecSet+" ":"")+"@"+o.bitrate+")"+(l?" with Pathway "+l:"")+" from level "+a+(s?" with Pathway "+s:""));var u={level:e,attrs:o.attrs,details:o.details,bitrate:o.bitrate,averageBitrate:o.averageBitrate,maxBitrate:o.maxBitrate,realBitrate:o.realBitrate,width:o.width,height:o.height,codecSet:o.codecSet,audioCodec:o.audioCodec,videoCodec:o.videoCodec,audioGroups:o.audioGroups,subtitleGroups:o.subtitleGroups,loaded:o.loaded,loadError:o.loadError,fragmentError:o.fragmentError,name:o.name,id:o.id,uri:o.uri,url:o.url,urlId:0,audioGroupIds:o.audioGroupIds,textGroupIds:o.textGroupIds};this.hls.trigger(O.LEVEL_SWITCHING,u);var d=o.details;if(!d||d.live){var h=this.switchParams(o.uri,null==n?void 0:n.details,d);this.loadPlaylist(h)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"pathways",get:function(){return this.steering?this.steering.pathways():[]}},{key:"pathwayPriority",get:function(){return this.steering?this.steering.pathwayPriority:null},set:function(e){if(this.steering){var t=this.steering.pathways(),r=e.filter((function(e){return-1!==t.indexOf(e)}));if(e.length<1)return void this.warn("pathwayPriority "+e+" should contain at least one pathway from list: "+t);this.steering.pathwayPriority=r}}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){var t=this.currentLevelIndex;if(-1===this.manualLevelIndex&&e!==t&&-1!==e){var r=this.hls.config.abrSwitchInterval;if(r>0){var i=performance.now(),a=i-this.lastABRSwitchTime,n=1e3*r;if(this.lastABRSwitchTime>-1&&a "+e+" ("+Math.round(a)+"ms < "+n+"ms / "+r+"s)");this.lastABRSwitchTime=i,this.log("Allowing ABR level switch: "+t+" -> "+e+" ("+Math.round(a)+"ms >= "+n+"ms / "+r+"s)")}}this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}}])}(qn);function zn(e,t){return mt(e,"audio",t)}function Qn(e,t){return mt(e,"video",t)}function $n(e,t){var r=e.audioCodec,i=e.videoCodec;r&&(e.audioCodec=r=Rt(r,t)||void 0),i&&(i=e.videoCodec=function(e){for(var t=e.split(","),r=0;r2&&"avc1"===i[0]&&(t[r]="avc1."+parseInt(i[1]).toString(16)+("000"+parseInt(i[2]).toString(16)).slice(-4))}return t.join(",")}(i));var a=e.unknownCodecs;return!((null==a?void 0:a.length)||r&&!zn(r,t)||i&&!Qn(i,t))}function Zn(e){var t={};e.forEach((function(e){var r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++}))}var Jn=function(e){function t(t,r){var i;return(i=e.call(this,"key-loader",r)||this).config=void 0,i.keyLoaderInfo={},i.emeController=null,i.config=t,i}u(t,e);var r=t.prototype;return r.abort=function(e){for(var t in this.keyLoaderInfo){var r=this.keyLoaderInfo[t].loader;if(r){var i;if(e&&e!==(null==(i=r.context)?void 0:i.frag.type))return;r.abort()}}},r.destroy=function(){for(var e in this.keyLoaderInfo){var t=this.keyLoaderInfo[e].loader;t&&t.destroy()}this.emeController=null,this.keyLoaderInfo={}},r.loadClear=function(e,t,r){return this.emeController?this.emeController.loadClear(e,t,r):null},r.load=function(e,t){var r=this;return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then((function(i){return r.loadInternal(e,t,i)})):this.loadInternal(e,t)},r.loadInternal=function(e,t,r){var i=this,a=e.decryptdata;if(!a){var n=new Error(r?"Expected frag.decryptdata to be defined after setting format "+r:"Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: "+(this.emeController&&this.config.emeEnabled)+")");return Promise.reject(es(e,w.KEY_LOAD_ERROR,n))}var s=e;switch(a.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===a.keyFormat?this.loadKeyHTTP(s):t?t.then((function(){return i.loadKeyEME(s)})):this.loadKeyEME(s);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(s);default:return Promise.reject(es(e,w.KEY_LOAD_ERROR,new Error('Key supplied with unsupported METHOD: "'+a.method+'"')))}},r.loadKeyEME=function(e){if(this.emeController&&this.config.emeEnabled){var t;if(!e.decryptdata.keyId&&null!=(t=e.initSegment)&&t.data){var r=function(e){var t=[];return et(e,(function(e){return t.push(e.subarray(8,24))})),t}(e.initSegment.data);if(r.length){var i=r[0],a=e.decryptdata.uri;if(i.some((function(e){return 0!==e})))this.log("Using keyId found in init segment "+xe(i)+" keyUri: "+a),Br.setKeyIdForUri(a,i);else{var n=Br.addKeyIdForUri(a);this.log("Patching empty keyId with "+xe(n)+" keyUri: "+a),i=n}e.decryptdata.keyId=i}}return this.emeController.loadKey(e).then((function(){return{frag:e,keyInfo:{decryptdata:e.decryptdata}}}))}return Promise.reject(es(e,w.KEY_LOAD_ERROR,new Error("emeEnabled with controller: "+(this.emeController&&this.config.emeEnabled)+")")))},r.loadKeyHTTP=function(e){var t=this,r=e.decryptdata,i=r.uri;if(!i)return Promise.reject(es(e,w.KEY_LOAD_ERROR,new Error('Invalid key URI: "'+i+'"')));var a=this.keyLoaderInfo[i];if(a){if(a.decryptdata.key)return r.key=a.decryptdata.key,a.keyLoadPromise=null,Promise.resolve({frag:e,keyInfo:a});if(a.keyLoadPromise)return a.keyLoadPromise.then((function(t){return r.key=a.decryptdata.key,f(f({},t),{},{frag:e})}))}this.log("Loading"+(r.keyId?" keyId: "+xe(r.keyId):"")+" URI: "+r.uri+" from "+e.type+" "+e.level);var n=this.config,s=new(0,n.loader)(n);e.keyLoader=s;var o=this.keyLoaderInfo[i]={decryptdata:r,keyLoadPromise:null,loader:s};return o.keyLoadPromise=new Promise((function(r,a){var l={type:F.KEY,keyInfo:o,frag:e,responseType:"arraybuffer",url:i},u=n.keyLoadPolicy.default,d={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},h={onSuccess:function(e,i,n,s){var o=n.frag,l=n.keyInfo,u=n.url;if(!o.decryptdata||l!==t.keyLoaderInfo[u])return t.resetLoader(n),a(es(o,w.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),s));l.decryptdata.key=o.decryptdata.key=new Uint8Array(e.data),o.keyLoader=l.loader=l.keyLoadPromise=null,r({frag:o,keyInfo:l})},onError:function(r,n,s,o){t.resetLoader(n),a(es(e,w.KEY_LOAD_ERROR,new Error("HTTP Error "+r.code+" loading key "+r.text),s,f({url:i,data:void 0},r)))},onTimeout:function(r,i,n){t.resetLoader(i),a(es(e,w.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),n))},onAbort:function(r,i,n){t.resetLoader(i),a(es(e,w.INTERNAL_ABORTED,new Error("key loading aborted"),n))}};s.load(l,d,h)}))},r.resetLoader=function(e){var t=e.frag,r=e.keyInfo,i=e.url,a=r.loader;t.keyLoader===a&&(t.keyLoader=r.loader=r.keyLoadPromise=null),delete this.keyLoaderInfo[i],a&&a.destroy()},t}(ie);function es(e,t,r,i,a){return void 0===t&&(t=w.KEY_LOAD_ERROR),new Ni({type:x.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:r,networkDetails:i||null})}function ts(e){switch(e.type){case F.AUDIO_TRACK:return N.AUDIO;case F.SUBTITLE_TRACK:return N.SUBTITLE;default:return N.MAIN}}function rs(e,t){var r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}var is=function(){function e(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=e,this.registerListeners()}var t=e.prototype;return t.startLoad=function(e){},t.stopLoad=function(){this.destroyInternalLoaders()},t.registerListeners=function(){var e=this.hls;e.on(O.MANIFEST_LOADING,this.onManifestLoading,this),e.on(O.LEVEL_LOADING,this.onLevelLoading,this),e.on(O.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(O.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(O.LEVELS_UPDATED,this.onLevelsUpdated,this)},t.unregisterListeners=function(){var e=this.hls;e.off(O.MANIFEST_LOADING,this.onManifestLoading,this),e.off(O.LEVEL_LOADING,this.onLevelLoading,this),e.off(O.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(O.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(O.LEVELS_UPDATED,this.onLevelsUpdated,this)},t.createInternalLoader=function(e){var t=this.hls.config,r=t.pLoader,i=t.loader,a=new(r||i)(t);return this.loaders[e.type]=a,a},t.getInternalLoader=function(e){return this.loaders[e.type]},t.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},t.destroyInternalLoaders=function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}},t.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},t.onManifestLoading=function(e,t){var r=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:F.MANIFEST,url:r,deliveryDirectives:null,levelOrTrack:null})},t.onLevelLoading=function(e,t){var r=t.id,i=t.level,a=t.pathwayId,n=t.url,s=t.deliveryDirectives,o=t.levelInfo;this.load({id:r,level:i,pathwayId:a,responseType:"text",type:F.LEVEL,url:n,deliveryDirectives:s,levelOrTrack:o})},t.onAudioTrackLoading=function(e,t){var r=t.id,i=t.groupId,a=t.url,n=t.deliveryDirectives,s=t.track;this.load({id:r,groupId:i,level:null,responseType:"text",type:F.AUDIO_TRACK,url:a,deliveryDirectives:n,levelOrTrack:s})},t.onSubtitleTrackLoading=function(e,t){var r=t.id,i=t.groupId,a=t.url,n=t.deliveryDirectives,s=t.track;this.load({id:r,groupId:i,level:null,responseType:"text",type:F.SUBTITLE_TRACK,url:a,deliveryDirectives:n,levelOrTrack:s})},t.onLevelsUpdated=function(e,t){var r=this.loaders[F.LEVEL];if(r){var i=r.context;i&&!t.levels.some((function(e){return e===i.levelOrTrack}))&&(r.abort(),delete this.loaders[F.LEVEL])}},t.load=function(e){var t,r,i,a=this,n=this.hls.config,s=this.getInternalLoader(e);if(s){var l=this.hls.logger,u=s.context;if((null==u?void 0:u.levelOrTrack)===e.levelOrTrack&&(u.url===e.url||u.deliveryDirectives&&!e.deliveryDirectives))return void(u.url===e.url?l.log("[playlist-loader]: ignore "+e.url+" ongoing request"):l.log("[playlist-loader]: ignore "+e.url+" in favor of "+u.url));l.log("[playlist-loader]: aborting previous loader for type: "+e.type),s.abort()}if(r=e.type===F.MANIFEST?n.manifestLoadPolicy.default:o({},n.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),_(null==(t=e.deliveryDirectives)?void 0:t.part)&&(e.type===F.LEVEL&&null!==e.level?i=this.hls.levels[e.level].details:e.type===F.AUDIO_TRACK&&null!==e.id?i=this.hls.audioTracks[e.id].details:e.type===F.SUBTITLE_TRACK&&null!==e.id&&(i=this.hls.subtitleTracks[e.id].details),i)){var d=i.partTarget,h=i.targetduration;if(d&&h){var f=1e3*Math.max(3*d,.8*h);r=o({},r,{maxTimeToFirstByteMs:Math.min(f,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(f,r.maxTimeToFirstByteMs)})}}var c=r.errorRetry||r.timeoutRetry||{},g={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:c.maxNumRetry||0,retryDelay:c.retryDelayMs||0,maxRetryDelay:c.maxRetryDelayMs||0},v={onSuccess:function(e,t,r,i){var n=a.getInternalLoader(r);a.resetInternalLoader(r.type);var s=e.data;t.parsing.start=performance.now(),Yr.isMediaPlaylist(s)||r.type!==F.MANIFEST?a.handleTrackOrLevelPlaylist(e,t,r,i||null,n):a.handleMasterPlaylist(e,t,r,i)},onError:function(e,t,r,i){a.handleNetworkError(t,r,!1,e,i)},onTimeout:function(e,t,r){a.handleNetworkError(t,r,!0,void 0,e)}};s.load(e,g,v)},t.checkAutostartLoad=function(){if(this.hls){var e=this.hls,t=e.config,r=t.autoStartLoad,i=t.startPosition,a=e.forceStartLoad;(r||a)&&(this.hls.logger.log((r?"auto":"force")+" startLoad with configured startPosition "+i),this.hls.startLoad(i))}},t.handleMasterPlaylist=function(e,t,r,i){var a=this,n=this.hls,s=e.data,o=rs(e,r),l=Yr.parseMasterPlaylist(s,o);if(l.playlistParsingError)return t.parsing.end=performance.now(),void this.handleManifestParsingError(e,r,l.playlistParsingError,i,t);var u=l.contentSteering,d=l.levels,h=l.iframeVariants,f=l.sessionData,c=l.sessionKeys,g=l.startTimeOffset,v=l.variableList;this.variableList=v,d.forEach((function(e){var t=e.unknownCodecs;if(t)for(var r=a.hls.config.preferManagedMediaSource,i=e.audioCodec,n=e.videoCodec,s=t.length;s--;){var o=t[s];mt(o,"audio",r)?(e.audioCodec=i=i?i+","+o:o,gt.audio[i.substring(0,4)]=2,t.splice(s,1)):mt(o,"video",r)&&(e.videoCodec=n=n?n+","+o:o,gt.video[n.substring(0,4)]=2,t.splice(s,1))}}));var m=Yr.parseMasterPlaylistMedia(s,o,l),p=m.AUDIO,y=void 0===p?[]:p,E=m.SUBTITLES,T=m["CLOSED-CAPTIONS"];y.length&&(y.some((function(e){return!e.url}))||!d[0].audioCodec||d[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),y.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Ir({}),bitrate:0,url:""}))),n.trigger(O.MANIFEST_LOADED,{levels:d,audioTracks:y,subtitles:E,iframeVariants:h,captions:T,contentSteering:u,url:o,stats:t,networkDetails:i,sessionData:f,sessionKeys:c,startTimeOffset:g,variableList:v})},t.handleTrackOrLevelPlaylist=function(e,t,r,i,a){var n=this.hls,s=r.id,o=r.level,l=r.type,u=rs(e,r),d=_(o)?o:_(s)?s:0,h=ts(r),f=Yr.parseLevelPlaylist(e.data,u,d,h,0,this.variableList);if(l===F.MANIFEST){var c={attrs:new Ir({}),bitrate:0,details:f,name:"",url:u};f.requestScheduled=t.loading.start+ui(f,0),n.trigger(O.MANIFEST_LOADED,{levels:[c],audioTracks:[],iframeVariants:[],url:u,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=f,this.handlePlaylistLoaded(f,e,t,r,i,a)},t.handleManifestParsingError=function(e,t,r,i,a){this.hls.trigger(O.ERROR,{type:x.NETWORK_ERROR,details:w.MANIFEST_PARSING_ERROR,fatal:t.type===F.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:a})},t.handleNetworkError=function(e,t,r,i,a){void 0===r&&(r=!1);var n="A network "+(r?"timeout":"error"+(i?" (status "+i.code+")":""))+" occurred while loading "+e.type;e.type===F.LEVEL?n+=": "+e.level+" id: "+e.id:e.type!==F.AUDIO_TRACK&&e.type!==F.SUBTITLE_TRACK||(n+=" id: "+e.id+' group-id: "'+e.groupId+'"');var s=new Error(n);this.hls.logger.warn("[playlist-loader]: "+n);var o=w.UNKNOWN,l=!1,u=this.getInternalLoader(e);switch(e.type){case F.MANIFEST:o=r?w.MANIFEST_LOAD_TIMEOUT:w.MANIFEST_LOAD_ERROR,l=!0;break;case F.LEVEL:o=r?w.LEVEL_LOAD_TIMEOUT:w.LEVEL_LOAD_ERROR,l=!1;break;case F.AUDIO_TRACK:o=r?w.AUDIO_TRACK_LOAD_TIMEOUT:w.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case F.SUBTITLE_TRACK:o=r?w.SUBTITLE_TRACK_LOAD_TIMEOUT:w.SUBTITLE_LOAD_ERROR,l=!1}u&&this.resetInternalLoader(e.type);var d={type:x.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:u,context:e,error:s,networkDetails:t,stats:a};if(i){var h=e.url;t&&"url"in t&&(h=t.url),d.response=f({url:h,data:void 0},i)}this.hls.trigger(O.ERROR,d)},t.handlePlaylistLoaded=function(e,t,r,i,a,n){var s=this.hls,o=i.type,l=i.level,u=i.levelOrTrack,d=i.id,h=i.groupId,f=i.deliveryDirectives,c=rs(t,i),g=ts(i),v="number"==typeof i.level&&g===N.MAIN?l:void 0,m=e.playlistParsingError;if(m){if(this.hls.logger.warn(m+" "+e.url),!s.config.ignorePlaylistParsingErrors)return void s.trigger(O.ERROR,{type:x.NETWORK_ERROR,details:w.LEVEL_PARSING_ERROR,fatal:!1,url:c,error:m,reason:m.message,response:t,context:i,level:v,parent:g,networkDetails:a,stats:r});e.playlistParsingError=null}if(e.fragments.length)switch(e.live&&n&&(n.getCacheAge&&(e.ageHeader=n.getCacheAge()||0),n.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case F.MANIFEST:case F.LEVEL:if(v)if(u){if(u!==s.levels[v]){var p=s.levels.indexOf(u);p>-1&&(v=p)}}else v=0;s.trigger(O.LEVEL_LOADED,{details:e,levelInfo:u||s.levels[0],level:v||0,id:d||0,stats:r,networkDetails:a,deliveryDirectives:f,withoutMultiVariant:o===F.MANIFEST,context:i});break;case F.AUDIO_TRACK:s.trigger(O.AUDIO_TRACK_LOADED,{details:e,track:u,id:d||0,groupId:h||"",stats:r,networkDetails:a,deliveryDirectives:f,context:i});break;case F.SUBTITLE_TRACK:s.trigger(O.SUBTITLE_TRACK_LOADED,{details:e,track:u,id:d||0,groupId:h||"",stats:r,networkDetails:a,deliveryDirectives:f,context:i})}else{var y=e.playlistParsingError=new Error("No Segments found in Playlist");s.trigger(O.ERROR,{type:x.NETWORK_ERROR,details:w.LEVEL_EMPTY_ERROR,fatal:!1,url:c,error:y,reason:y.message,response:t,context:i,level:v,parent:g,networkDetails:a,stats:r})}},e}(),as=function(){function e(t){void 0===t&&(t={}),this.config=void 0,this.userConfig=void 0,this.logger=void 0,this._url=null,this.streamController=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new k,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.iframeController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;var r=this.logger=ue(t.debug||!1,"Hls instance",t.loggerId||t.assetPlayerId),i=this.config=Yn(e.DefaultConfig,t,r);this.userConfig=t,i.progressive&&jn(i,r);var a=i.streamController,n=i.abrController,s=i.bufferController,o=i.capLevelController,l=i.errorController,u=i.fpsController,d=i.id3TrackController,h=i.iframeController,f=i.gapController,c=new l(this),g=this.abrController=new n(this),v=new Ai(this),m=i.interstitialsController,p=m?this.interstitialsController=new m(this,e):null,y=s?this.bufferController=new s(this,v):null,E=o?this.capLevelController=new o(this):null,T=u?new u(this):null,S=i.cmcdController,L=S?this.cmcdController=new S(this):null,R=new is(this),A=i.contentSteeringController,b=A?new A(this):null,D=this.levelController=new Xn(this,b),I=d?new d(this):void 0,_=new Jn(this.config,this.logger),C=this.streamController=new a(this,v,_),P=this.gapController=f?new f(this,v):void 0;E&&E.setStreamController(C);var x=[R,D,C];p&&x.splice(1,0,p),b&&x.splice(1,0,b),this.networkControllers=x;var w=[g];y&&w.push(y),P&&w.push(P),E&&w.push(E),T&&(T.setStreamController(C),w.push(T)),I&&w.push(I),w.push(v),this.audioTrackController=this.createController(i.audioTrackController,x);var M=i.audioStreamController;M&&x.push(this.audioStreamController=new M(this,v,_)),this.subtitleTrackController=this.createController(i.subtitleTrackController,x);var F=i.subtitleStreamController;F&&x.push(this.subtititleStreamController=new F(this,v,_)),this.createController(i.timelineController,w),_.emeController=this.emeController=this.createController(i.emeController,w),L&&w.push(L),this.latencyController=this.createController(i.latencyController,w),this.coreComponents=w,this.iframeController=h?new h(this,e):void 0,x.push(c);var N=c.onErrorOut;"function"==typeof N&&this.on(O.ERROR,N,c),this.on(O.MANIFEST_LOADED,R.onManifestLoaded,R)}e.isMSESupported=function(){return _n()},e.isSupported=function(){return function(){if(!_n())return!1;var e=ve();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some((function(t){return e.isTypeSupported(yt(t,"video"))}))||["mp4a.40.2","fLaC"].some((function(t){return e.isTypeSupported(yt(t,"audio"))})))}()},e.getMediaSource=function(){return ve()};var t=e.prototype;return t.createController=function(e,t){if(e){var r=new e(this);return t&&t.push(r),r}return null},t.on=function(e,t,r){void 0===r&&(r=this),this._emitter.on(e,t,r)},t.once=function(e,t,r){void 0===r&&(r=this),this._emitter.once(e,t,r)},t.removeAllListeners=function(e){this._emitter.removeAllListeners(e)},t.off=function(e,t,r,i){void 0===r&&(r=this),this._emitter.off(e,t,r,i)},t.listeners=function(e){return this._emitter.listeners(e)},t.emit=function(e,t,r){return this._emitter.emit(e,t,r)},t.trigger=function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;var r=e===O.ERROR;this.trigger(O.ERROR,{type:x.OTHER_ERROR,details:w.INTERNAL_EXCEPTION,fatal:r,event:e,error:t}),this.triggeringException=!1}}return!1},t.listenerCount=function(e){return this._emitter.listenerCount(e)},t.destroy=function(){this.logger.log("destroy"),this.trigger(O.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach((function(e){return e.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(e){return e.destroy()})),this.coreComponents.length=0,this.iframeController=void 0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null},t.attachMedia=function(e){if(!e||"media"in e&&!e.media){var t=new Error("attachMedia failed: invalid argument ("+e+")");this.trigger(O.ERROR,{type:x.OTHER_ERROR,details:w.ATTACH_MEDIA_ERROR,fatal:!0,error:t})}else{this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());var r="media"in e,i=r?e.media:e,a=r?e:{media:i};this._media=i,this.trigger(O.MEDIA_ATTACHING,a)}},t.detachMedia=function(){this.logger.log("detachMedia");var e={};this.trigger(O.MEDIA_DETACHING,e),this._media=null,this.trigger(O.MEDIA_DETACHED,e)},t.transferMedia=function(){var e;this._media=null;var t=(null==(e=this.bufferController)?void 0:e.transferMedia())||null,r={transferMedia:t};return this.trigger(O.MEDIA_DETACHING,r),this.trigger(O.MEDIA_DETACHED,r),t},t.loadSource=function(e){var t;this.stopLoad();var r=this.media,i=this._url,a=this._url=I.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log("loadSource:"+a),r&&i&&(i!==a||null!=(t=this.bufferController)&&t.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(r)),this.trigger(O.MANIFEST_LOADING,{url:e})},t.startLoad=function(e,t){void 0===e&&(e=-1),this.logger.log("startLoad("+e+(t?", ":"")+")"),this.started=!0,this.resumeBuffering();for(var r=0;r-1?this.abrController.forcedAutoLevel:e},set:function(e){this.logger.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=this.capLevelController,r=!!e;t&&r!==this.config.capLevelToPlayerSize&&(r?t.startCapping():(t.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=r)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(this.logger.log("set autoLevelCapping:"+e),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"abrEwmaDefaultEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.defaultEstimate:NaN}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){(function(e){return It.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var r=e.length,i=0;i=t)return i;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(e=-1===r&&null!=t&&t.length?t.length-1:r,i)for(var a=e;a--;){var n=t[a].attrs["HDCP-LEVEL"];if(n&&n<=i)return a}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioForwardBufferInfo",get:function(){var e;return(null==(e=this.audioStreamController)?void 0:e.getFwdBufferInfo())||null}},{key:"maxBufferLength",get:function(){return this.streamController.maxBufferLength}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"nextAudioTrack",get:function(){var e,t;return null!=(e=null==(t=this.audioStreamController)?void 0:t.nextAudioTrack)?e:-1},set:function(e){var t=this.audioTrackController;t&&(t.nextAudioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{key:"liveSyncPosition",get:function(){var e,t;return null!=(e=null==(t=this.latencyController)?void 0:t.liveSyncPosition)?e:null}},{key:"latency",get:function(){var e;return(null==(e=this.latencyController)?void 0:e.latency)||0}},{key:"maxLatency",get:function(){var e;return(null==(e=this.latencyController)?void 0:e.maxLatency)||0}},{key:"targetLatency",get:function(){var e;return(null==(e=this.latencyController)?void 0:e.targetLatency)||null},set:function(e){this.latencyController&&(this.latencyController.targetLatency=e)}},{key:"drift",get:function(){var e;return(null==(e=this.latencyController)?void 0:e.drift)||null}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}},{key:"pathways",get:function(){return this.levelController.pathways}},{key:"pathwayPriority",get:function(){return this.levelController.pathwayPriority},set:function(e){this.levelController.pathwayPriority=e}},{key:"bufferedToEnd",get:function(){var e;return!(null==(e=this.bufferController)||!e.bufferedToEnd)}},{key:"interstitialsManager",get:function(){return null}},{key:"iframeVariants",get:function(){var e=this.levelController.iframeVariants;return e||[]}}],[{key:"version",get:function(){return An}},{key:"Events",get:function(){return O}},{key:"MetadataSchema",get:function(){return $i}},{key:"ErrorTypes",get:function(){return x}},{key:"ErrorDetails",get:function(){return w}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:Kn},set:function(t){e.defaultConfig=t}}])}();return as.defaultConfig=void 0,as},"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(r="undefined"!=typeof globalThis?globalThis:r||self).Hls=i()}(!1); +//# sourceMappingURL=hls.light.min.js.map diff --git a/android/app/src/main/assets/pulsewall/libs/konva.min.js b/android/app/src/main/assets/pulsewall/libs/konva.min.js new file mode 100644 index 0000000..3265945 --- /dev/null +++ b/android/app/src/main/assets/pulsewall/libs/konva.min.js @@ -0,0 +1,12 @@ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Konva=e()}(this,(function(){"use strict"; +/* + * Konva JavaScript Framework v9.3.22 + * http://konvajs.org/ + * Licensed under the MIT + * Date: Tue Jul 08 2025 + * + * Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS) + * Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva) + * + * @license + */const t=Math.PI/180;const e="undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},i={_global:e,version:"9.3.22",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(t){}.toString()),dblClickWindow:400,getAngle:e=>i.angleDeg?e*t:e,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_fixTextRendering:!1,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>i.DD.isDragging,isTransforming(){var t;return null===(t=i.Transformer)||void 0===t?void 0:t.isTransforming()},isDragReady:()=>!!i.DD.node,releaseCanvasOnDestroy:!0,document:e.document,_injectGlobal(t){e.Konva=t}},n=t=>{i[t.prototype.getClassName()]=t};i._injectGlobal(i);class s{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new s(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const e=this.m;return{x:e[0]*t.x+e[2]*t.y+e[4],y:e[1]*t.x+e[3]*t.y+e[5]}}translate(t,e){return this.m[4]+=this.m[0]*t+this.m[2]*e,this.m[5]+=this.m[1]*t+this.m[3]*e,this}scale(t,e){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=e,this.m[3]*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),n=this.m[0]*e+this.m[2]*i,s=this.m[1]*e+this.m[3]*i,r=this.m[0]*-i+this.m[2]*e,a=this.m[1]*-i+this.m[3]*e;return this.m[0]=n,this.m[1]=s,this.m[2]=r,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,e){const i=this.m[0]+this.m[2]*e,n=this.m[1]+this.m[3]*e,s=this.m[2]+this.m[0]*t,r=this.m[3]+this.m[1]*t;return this.m[0]=i,this.m[1]=n,this.m[2]=s,this.m[3]=r,this}multiply(t){const e=this.m[0]*t.m[0]+this.m[2]*t.m[1],i=this.m[1]*t.m[0]+this.m[3]*t.m[1],n=this.m[0]*t.m[2]+this.m[2]*t.m[3],s=this.m[1]*t.m[2]+this.m[3]*t.m[3],r=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=s,this.m[4]=r,this.m[5]=a,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),e=this.m[3]*t,i=-this.m[1]*t,n=-this.m[2]*t,s=this.m[0]*t,r=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=e,this.m[1]=i,this.m[2]=n,this.m[3]=s,this.m[4]=r,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const t=this.m[0],e=this.m[1],i=this.m[2],n=this.m[3],s=t*n-e*i,r={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=t||0!=e){const a=Math.sqrt(t*t+e*e);r.rotation=e>0?Math.acos(t/a):-Math.acos(t/a),r.scaleX=a,r.scaleY=s/a,r.skewX=(t*i+e*n)/s,r.skewY=0}else if(0!=i||0!=n){const a=Math.sqrt(i*i+n*n);r.rotation=Math.PI/2-(n>0?Math.acos(-i/a):-Math.acos(i/a)),r.scaleX=s/a,r.scaleY=a,r.skewX=0,r.skewY=(t*i+e*n)/s}return r.rotation=g._getRotation(r.rotation),r}}const r=Math.PI/180,a=180/Math.PI,o="Konva error: ",h={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},l=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;let d=[];const c="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(t){setTimeout(t,60)},g={_isElement:t=>!(!t||1!=t.nodeType),_isFunction:t=>!!(t&&t.constructor&&t.call&&t.apply),_isPlainObject:t=>!!t&&t.constructor===Object,_isArray:t=>"[object Array]"===Object.prototype.toString.call(t),_isNumber:t=>"[object Number]"===Object.prototype.toString.call(t)&&!isNaN(t)&&isFinite(t),_isString:t=>"[object String]"===Object.prototype.toString.call(t),_isBoolean:t=>"[object Boolean]"===Object.prototype.toString.call(t),isObject:t=>t instanceof Object,isValidSelector(t){if("string"!=typeof t)return!1;const e=t[0];return"#"===e||"."===e||e===e.toUpperCase()},_sign:t=>0===t||t>0?1:-1,requestAnimFrame(t){d.push(t),1===d.length&&c((function(){const t=d;d=[],t.forEach((function(t){t()}))}))},createCanvasElement(){const t=document.createElement("canvas");try{t.style=t.style||{}}catch(t){}return t},createImageElement:()=>document.createElement("img"),_isInDocument(t){for(;t=t.parentNode;)if(t==document)return!0;return!1},_urlToImage(t,e){const i=g.createImageElement();i.onload=function(){e(i)},i.src=t},_rgbToHex:(t,e,i)=>((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1),_hexToRgb(t){t=t.replace("#","");const e=parseInt(t,16);return{r:e>>16&255,g:e>>8&255,b:255&e}},getRandomColor(){let t=(16777215*Math.random()|0).toString(16);for(;t.length<6;)t="0"+t;return"#"+t},getRGB(t){let e;return t in h?(e=h[t],{r:e[0],g:e[1],b:e[2]}):"#"===t[0]?this._hexToRgb(t.substring(1)):"rgb("===t.substr(0,4)?(e=l.exec(t.replace(/ /g,"")),{r:parseInt(e[1],10),g:parseInt(e[2],10),b:parseInt(e[3],10)}):{r:0,g:0,b:0}},colorToRGBA:t=>(t=t||"black",g._namedColorToRBA(t)||g._hex3ColorToRGBA(t)||g._hex4ColorToRGBA(t)||g._hex6ColorToRGBA(t)||g._hex8ColorToRGBA(t)||g._rgbColorToRGBA(t)||g._rgbaColorToRGBA(t)||g._hslColorToRGBA(t)),_namedColorToRBA(t){const e=h[t.toLowerCase()];return e?{r:e[0],g:e[1],b:e[2],a:1}:null},_rgbColorToRGBA(t){if(0===t.indexOf("rgb(")){const e=(t=t.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:e[0],g:e[1],b:e[2],a:1}}},_rgbaColorToRGBA(t){if(0===t.indexOf("rgba(")){const e=(t=t.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map(((t,e)=>"%"===t.slice(-1)?3===e?parseInt(t)/100:parseInt(t)/100*255:Number(t)));return{r:e[0],g:e[1],b:e[2],a:e[3]}}},_hex8ColorToRGBA(t){if("#"===t[0]&&9===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:parseInt(t.slice(7,9),16)/255}},_hex6ColorToRGBA(t){if("#"===t[0]&&7===t.length)return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16),a:1}},_hex4ColorToRGBA(t){if("#"===t[0]&&5===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:parseInt(t[4]+t[4],16)/255}},_hex3ColorToRGBA(t){if("#"===t[0]&&4===t.length)return{r:parseInt(t[1]+t[1],16),g:parseInt(t[2]+t[2],16),b:parseInt(t[3]+t[3],16),a:1}},_hslColorToRGBA(t){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(t)){const[e,...i]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),n=Number(i[0])/360,s=Number(i[1])/100,r=Number(i[2])/100;let a,o,h;if(0===s)return h=255*r,{r:Math.round(h),g:Math.round(h),b:Math.round(h),a:1};a=r<.5?r*(1+s):r+s-r*s;const l=2*r-a,d=[0,0,0];for(let t=0;t<3;t++)o=n+1/3*-(t-1),o<0&&o++,o>1&&o--,h=6*o<1?l+6*(a-l)*o:2*o<1?a:3*o<2?l+(a-l)*(2/3-o)*6:l,d[t]=255*h;return{r:Math.round(d[0]),g:Math.round(d[1]),b:Math.round(d[2]),a:1}}},haveIntersection:(t,e)=>!(e.x>t.x+t.width||e.x+e.widtht.y+t.height||e.y+e.heightt.slice(0),degToRad:t=>t*r,radToDeg:t=>t*a,_degToRad:t=>(g.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),g.degToRad(t)),_radToDeg:t=>(g.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),g.radToDeg(t)),_getRotation:t=>i.angleDeg?g.radToDeg(t):t,_capitalize:t=>t.charAt(0).toUpperCase()+t.slice(1),throw(t){throw new Error(o+t)},error(t){console.error(o+t)},warn(t){i.showWarnings&&console.warn("Konva warning: "+t)},each(t,e){for(const i in t)e(i,t[i])},_inRange:(t,e,i)=>e<=t&&t1?(a=i,o=n,h=(i-s)*(i-s)+(n-r)*(n-r)):(a=t+d*(i-t),o=e+d*(n-e),h=(a-s)*(a-s)+(o-r)*(o-r))}return[a,o,h]},_getProjectionToLine(t,e,i){const n=g.cloneObject(t);let s=Number.MAX_VALUE;return e.forEach((function(r,a){if(!i&&a===e.length-1)return;const o=e[(a+1)%e.length],h=g._getProjectionToSegment(r.x,r.y,o.x,o.y,t.x,t.y),l=h[0],d=h[1],c=h[2];ce.length){const i=e;e=t,t=i}for(let e=0;et.touches?t.changedTouches[0].identifier:t.pointerId||999,releaseCanvas(...t){i.releaseCanvasOnDestroy&&t.forEach((t=>{t.width=0,t.height=0}))},drawRoundedRectPath(t,e,i,n){let s=0,r=0,a=0,o=0;"number"==typeof n?s=r=a=o=Math.min(n,e/2,i/2):(s=Math.min(n[0]||0,e/2,i/2),r=Math.min(n[1]||0,e/2,i/2),o=Math.min(n[2]||0,e/2,i/2),a=Math.min(n[3]||0,e/2,i/2)),t.moveTo(s,0),t.lineTo(e-r,0),t.arc(e-r,r,r,3*Math.PI/2,0,!1),t.lineTo(e,i-o),t.arc(e-o,i-o,o,0,Math.PI/2,!1),t.lineTo(a,i),t.arc(a,i-a,a,Math.PI/2,Math.PI,!1),t.lineTo(0,s),t.arc(s,s,s,Math.PI,3*Math.PI/2,!1)}};const u=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];class f{constructor(t){this.canvas=t,i.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(t){t.fillEnabled()&&this._fill(t)}_fill(t){}strokeShape(t){t.hasStroke()&&this._stroke(t)}_stroke(t){}fillStrokeShape(t){t.attrs.fillAfterStrokeEnabled?(this.strokeShape(t),this.fillShape(t)):(this.fillShape(t),this.strokeShape(t))}getTrace(t,e){let i,n,s,r,a=this.traceArr,o=a.length,h="";for(i=0;i"number"==typeof t?Math.floor(t):t))),h+="("+r.join(",")+")")):(h+=n.property,t||(h+="="+n.val)),h+=";";return h}clearTrace(){this.traceArr=[]}_trace(t){let e,i=this.traceArr;i.push(t),e=i.length,e>=100&&i.shift()}reset(){const t=this.getCanvas().getPixelRatio();this.setTransform(1*t,0,0,1*t,0,0)}getCanvas(){return this.canvas}clear(t){const e=this.getCanvas();t?this.clearRect(t.x||0,t.y||0,t.width||0,t.height||0):this.clearRect(0,0,e.getWidth()/e.pixelRatio,e.getHeight()/e.pixelRatio)}_applyLineCap(t){const e=t.attrs.lineCap;e&&this.setAttr("lineCap",e)}_applyOpacity(t){const e=t.getAbsoluteOpacity();1!==e&&this.setAttr("globalAlpha",e)}_applyLineJoin(t){const e=t.attrs.lineJoin;e&&this.setAttr("lineJoin",e)}setAttr(t,e){this._context[t]=e}arc(t,e,i,n,s,r){this._context.arc(t,e,i,n,s,r)}arcTo(t,e,i,n,s){this._context.arcTo(t,e,i,n,s)}beginPath(){this._context.beginPath()}bezierCurveTo(t,e,i,n,s,r){this._context.bezierCurveTo(t,e,i,n,s,r)}clearRect(t,e,i,n){this._context.clearRect(t,e,i,n)}clip(...t){this._context.clip.apply(this._context,t)}closePath(){this._context.closePath()}createImageData(t,e){const i=arguments;return 2===i.length?this._context.createImageData(t,e):1===i.length?this._context.createImageData(t):void 0}createLinearGradient(t,e,i,n){return this._context.createLinearGradient(t,e,i,n)}createPattern(t,e){return this._context.createPattern(t,e)}createRadialGradient(t,e,i,n,s,r){return this._context.createRadialGradient(t,e,i,n,s,r)}drawImage(t,e,i,n,s,r,a,o,h){const l=arguments,d=this._context;3===l.length?d.drawImage(t,e,i):5===l.length?d.drawImage(t,e,i,n,s):9===l.length&&d.drawImage(t,e,i,n,s,r,a,o,h)}ellipse(t,e,i,n,s,r,a,o){this._context.ellipse(t,e,i,n,s,r,a,o)}isPointInPath(t,e,i,n){return i?this._context.isPointInPath(i,t,e,n):this._context.isPointInPath(t,e,n)}fill(...t){this._context.fill.apply(this._context,t)}fillRect(t,e,i,n){this._context.fillRect(t,e,i,n)}strokeRect(t,e,i,n){this._context.strokeRect(t,e,i,n)}fillText(t,e,i,n){n?this._context.fillText(t,e,i,n):this._context.fillText(t,e,i)}measureText(t){return this._context.measureText(t)}getImageData(t,e,i,n){return this._context.getImageData(t,e,i,n)}lineTo(t,e){this._context.lineTo(t,e)}moveTo(t,e){this._context.moveTo(t,e)}rect(t,e,i,n){this._context.rect(t,e,i,n)}roundRect(t,e,i,n,s){this._context.roundRect(t,e,i,n,s)}putImageData(t,e,i){this._context.putImageData(t,e,i)}quadraticCurveTo(t,e,i,n){this._context.quadraticCurveTo(t,e,i,n)}restore(){this._context.restore()}rotate(t){this._context.rotate(t)}save(){this._context.save()}scale(t,e){this._context.scale(t,e)}setLineDash(t){this._context.setLineDash?this._context.setLineDash(t):"mozDash"in this._context?this._context.mozDash=t:"webkitLineDash"in this._context&&(this._context.webkitLineDash=t)}getLineDash(){return this._context.getLineDash()}setTransform(t,e,i,n,s,r){this._context.setTransform(t,e,i,n,s,r)}stroke(t){t?this._context.stroke(t):this._context.stroke()}strokeText(t,e,i,n){this._context.strokeText(t,e,i,n)}transform(t,e,i,n,s,r){this._context.transform(t,e,i,n,s,r)}translate(t,e){this._context.translate(t,e)}_enableTrace(){let t,e,i=this,n=u.length,s=this.setAttr;const r=function(t){let n,s=i[t];i[t]=function(){return e=function(t){const e=[],i=t.length,n=g;for(let s=0;s{"dragging"===e.dragStatus&&(t=!0)})),t},justDragged:!1,get node(){let t;return b._dragElements.forEach((e=>{t=e.node})),t},_dragElements:new Map,_drag(t){const e=[];b._dragElements.forEach(((i,n)=>{const{node:s}=i,r=s.getStage();r.setPointersPositions(t),void 0===i.pointerId&&(i.pointerId=g._getFirstPointerId(t));const a=r._changedPointerPositions.find((t=>t.id===i.pointerId));if(a){if("dragging"!==i.dragStatus){const e=s.dragDistance();if(Math.max(Math.abs(a.x-i.startPointerPos.x),Math.abs(a.y-i.startPointerPos.y)){e.fire("dragmove",{type:"dragmove",target:e,evt:t},!0)}))},_endDragBefore(t){const e=[];b._dragElements.forEach((n=>{const{node:s}=n,r=s.getStage();t&&r.setPointersPositions(t);if(!r._changedPointerPositions.find((t=>t.id===n.pointerId)))return;"dragging"!==n.dragStatus&&"stopped"!==n.dragStatus||(b.justDragged=!0,i._mouseListenClick=!1,i._touchListenClick=!1,i._pointerListenClick=!1,n.dragStatus="stopped");const a=n.node.getLayer()||n.node instanceof i.Stage&&n.node;a&&-1===e.indexOf(a)&&e.push(a)})),e.forEach((t=>{t.draw()}))},_endDragAfter(t){b._dragElements.forEach(((e,i)=>{"stopped"===e.dragStatus&&e.node.fire("dragend",{type:"dragend",target:e.node,evt:t},!0),"dragging"!==e.dragStatus&&b._dragElements.delete(i)}))}};function S(t){return g._isString(t)?'"'+t+'"':"[object Number]"===Object.prototype.toString.call(t)||g._isBoolean(t)?t:Object.prototype.toString.call(t)}function w(t){return t>255?255:t<0?0:Math.round(t)}function C(){if(i.isUnminified)return function(t,e){return g._isNumber(t)||g.warn(S(t)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),t}}function P(t){if(i.isUnminified)return function(e,i){let n=g._isNumber(e),s=g._isArray(e)&&e.length==t;return n||s||g.warn(S(e)+' is a not valid value for "'+i+'" attribute. The value should be a number or Array('+t+")"),e}}function k(){if(i.isUnminified)return function(t,e){return g._isNumber(t)||"auto"===t||g.warn(S(t)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),t}}function A(){if(i.isUnminified)return function(t,e){return g._isString(t)||g.warn(S(t)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),t}}function T(){if(i.isUnminified)return function(t,e){const i=g._isString(t),n="[object CanvasGradient]"===Object.prototype.toString.call(t)||t&&t.addColorStop;return i||n||g.warn(S(t)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),t}}function M(){if(i.isUnminified)return function(t,e){return!0===t||!1===t||g.warn(S(t)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),t}}i.isBrowser&&(window.addEventListener("mouseup",b._endDragBefore,!0),window.addEventListener("touchend",b._endDragBefore,!0),window.addEventListener("touchcancel",b._endDragBefore,!0),window.addEventListener("mousemove",b._drag),window.addEventListener("touchmove",b._drag),window.addEventListener("mouseup",b._endDragAfter,!1),window.addEventListener("touchend",b._endDragAfter,!1),window.addEventListener("touchcancel",b._endDragAfter,!1));const G="get",R="set",E={addGetterSetter(t,e,i,n,s){E.addGetter(t,e,i),E.addSetter(t,e,n,s),E.addOverloadedGetterSetter(t,e)},addGetter(t,e,i){const n=G+g._capitalize(e);t.prototype[n]=t.prototype[n]||function(){const t=this.attrs[e];return void 0===t?i:t}},addSetter(t,e,i,n){const s=R+g._capitalize(e);t.prototype[s]||E.overWriteSetter(t,e,i,n)},overWriteSetter(t,e,i,n){const s=R+g._capitalize(e);t.prototype[s]=function(t){return i&&null!=t&&(t=i.call(this,t,e)),this._setAttr(e,t),n&&n.call(this),this}},addComponentsGetterSetter(t,e,n,s,r){const a=n.length,o=g._capitalize,h=G+o(e),l=R+o(e);t.prototype[h]=function(){const t={};for(let i=0;i{this._setAttr(e+o(t),void 0)})),this._fireChangeEvent(e,i,t),r&&r.call(this),this},E.addOverloadedGetterSetter(t,e)},addOverloadedGetterSetter(t,e){const i=g._capitalize(e),n=R+i,s=G+i;t.prototype[e]=function(){return arguments.length?(this[n](arguments[0]),this):this[s]()}},addDeprecatedGetterSetter(t,e,i,n){g.error("Adding deprecated "+e);const s=G+g._capitalize(e),r=e+" property is deprecated and will be removed soon. Look at Konva change log for more information.";t.prototype[s]=function(){g.error(r);const t=this.attrs[e];return void 0===t?i:t},E.addSetter(t,e,n,(function(){g.error(r)})),E.addOverloadedGetterSetter(t,e)},backCompat(t,e){g.each(e,(function(e,i){const n=t.prototype[i],s=G+g._capitalize(e),r=R+g._capitalize(e);function a(){n.apply(this,arguments),g.error('"'+e+'" method is deprecated and will be removed soon. Use ""'+i+'" instead.')}t.prototype[e]=a,t.prototype[s]=a,t.prototype[r]=a}))},afterSetFilter(){this._filterUpToDate=!1}},D="absoluteOpacity",L="allEventListeners",O="absoluteTransform",I="absoluteScale",F="canvas",B="listening",N="Shape",H=" ",z="stage",W="transform",Y="visible",X=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(H);let j=1;class q{constructor(t){this._id=j++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){t!==W&&t!==O||!this._cache.get(t)?t?this._cache.delete(t):this._cache.clear():this._cache.get(t).dirty=!0}_getCache(t,e){let i=this._cache.get(t);return(void 0===i||(t===W||t===O)&&!0===i.dirty)&&(i=e.call(this),this._cache.set(t,i)),i}_calculate(t,e,i){if(!this._attachedDepsListeners.get(t)){const i=e.map((t=>t+"Change.konva")).join(H);this.on(i,(()=>{this._clearCache(t)})),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,i)}_getCanvasCache(){return this._cache.get(F)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===O&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(F)){const{scene:t,filter:e,hit:i,buffer:n}=this._cache.get(F);g.releaseCanvas(t,e,i,n),this._cache.delete(F)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){const e=t||{};let i={};void 0!==e.x&&void 0!==e.y&&void 0!==e.width&&void 0!==e.height||(i=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let n=Math.ceil(e.width||i.width),s=Math.ceil(e.height||i.height),r=e.pixelRatio,a=void 0===e.x?Math.floor(i.x):e.x,o=void 0===e.y?Math.floor(i.y):e.y,h=e.offset||0,l=e.drawBorder||!1,d=e.hitCanvasPixelRatio||1;if(!n||!s)return void g.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");n+=2*h+(Math.abs(Math.round(i.x)-a)>.5?1:0),s+=2*h+(Math.abs(Math.round(i.y)-o)>.5?1:0),a-=h,o-=h;const c=new v({pixelRatio:r,width:n,height:s}),u=new v({pixelRatio:r,width:0,height:0,willReadFrequently:!0}),f=new x({pixelRatio:d,width:n,height:s}),p=c.getContext(),m=f.getContext(),_=new v({width:c.width/c.pixelRatio+Math.abs(a),height:c.height/c.pixelRatio+Math.abs(o),pixelRatio:c.pixelRatio}),y=_.getContext();return f.isCache=!0,c.isCache=!0,this._cache.delete(F),this._filterUpToDate=!1,!1===e.imageSmoothingEnabled&&(c.getContext()._context.imageSmoothingEnabled=!1,u.getContext()._context.imageSmoothingEnabled=!1),p.save(),m.save(),y.save(),p.translate(-a,-o),m.translate(-a,-o),y.translate(-a,-o),_.x=a,_.y=o,this._isUnderCache=!0,this._clearSelfAndDescendantCache(D),this._clearSelfAndDescendantCache(I),this.drawScene(c,this,_),this.drawHit(f,this),this._isUnderCache=!1,p.restore(),m.restore(),l&&(p.save(),p.beginPath(),p.rect(0,0,n,s),p.closePath(),p.setAttr("strokeStyle","red"),p.setAttr("lineWidth",5),p.stroke(),p.restore()),this._cache.set(F,{scene:c,filter:u,hit:f,buffer:_,x:a,y:o}),this._requestDraw(),this}isCached(){return this._cache.has(F)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,e){const i=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let n=1/0,s=1/0,r=-1/0,a=-1/0;const o=this.getAbsoluteTransform(e);return i.forEach((function(t){const e=o.point(t);void 0===n&&(n=r=e.x,s=a=e.y),n=Math.min(n,e.x),s=Math.min(s,e.y),r=Math.max(r,e.x),a=Math.max(a,e.y)})),{x:n,y:s,width:r-n,height:a-s}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const e=this._getCanvasCache();t.translate(e.x,e.y);const i=this._getCachedSceneCanvas(),n=i.pixelRatio;t.drawImage(i._canvas,0,0,i.width/n,i.height/n),t.restore()}_drawCachedHitCanvas(t){const e=this._getCanvasCache(),i=e.hit;t.save(),t.translate(e.x,e.y),t.drawImage(i._canvas,0,0,i.width/i.pixelRatio,i.height/i.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t,e,i,n,s=this.filters(),r=this._getCanvasCache(),a=r.scene,o=r.filter,h=o.getContext();if(s){if(!this._filterUpToDate){const r=a.pixelRatio;o.setSize(a.width/a.pixelRatio,a.height/a.pixelRatio);try{for(t=s.length,h.clear(),h.drawImage(a._canvas,0,0,a.getWidth()/r,a.getHeight()/r),e=h.getImageData(0,0,o.getWidth(),o.getHeight()),i=0;i{let e,i;if(!t)return this;for(e in t)"children"!==e&&(i="set"+g._capitalize(e),g._isFunction(this[i])?this[i](t[e]):this._setAttr(e,t[e]))})),this}isListening(){return this._getCache(B,this._isListening)}_isListening(t){if(!this.listening())return!1;const e=this.getParent();return!e||e===t||this===t||e._isListening(t)}isVisible(){return this._getCache(Y,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const e=this.getParent();return!e||e===t||this===t||e._isVisible(t)}shouldDrawHit(t,e=!1){if(t)return this._isVisible(t)&&this._isListening(t);const n=this.getLayer();let s=!1;b._dragElements.forEach((t=>{"dragging"===t.dragStatus&&("Stage"===t.node.nodeType||t.node.getLayer()===n)&&(s=!0)}));const r=!e&&!i.hitOnDragEnabled&&(s||i.isTransforming());return this.isListening()&&this.isVisible()&&!r}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t,e,i,n,s=this.getDepth(),r=this,a=0;const o=this.getStage();return"Stage"!==r.nodeType&&o&&function o(h){for(t=[],e=h.length,i=0;i0&&t[0].getDepth()<=s&&o(t)}(o.getChildren()),a}getDepth(){let t=0,e=this.parent;for(;e;)t++,e=e.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(W),this._clearSelfAndDescendantCache(O)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges((()=>{this.x(t.x),this.y(t.y)})),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const e=t.getPointerPosition();if(!e)return null;const i=this.getAbsoluteTransform().copy();return i.invert(),i.point(e)}getAbsolutePosition(t){let e=!1,i=this.parent;for(;i;){if(i.isCached()){e=!0;break}i=i.parent}e&&!t&&(t=!0);const n=this.getAbsoluteTransform(t).getMatrix(),r=new s,a=this.offset();return r.m=n.slice(),r.translate(a.x,a.y),r.getTranslation()}setAbsolutePosition(t){const{x:e,y:i,...n}=this._clearTransform();this.attrs.x=e,this.attrs.y=i,this._clearCache(W);const s=this._getAbsoluteTransform().copy();return s.invert(),s.translate(t.x,t.y),t={x:this.attrs.x+s.getTranslation().x,y:this.attrs.y+s.getTranslation().y},this._setTransform(n),this.setPosition({x:t.x,y:t.y}),this._clearCache(W),this._clearSelfAndDescendantCache(O),this}_setTransform(t){let e;for(e in t)this.attrs[e]=t[e]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let e=t.x,i=t.y,n=this.x(),s=this.y();return void 0!==e&&(n+=e),void 0!==i&&(s+=i),this.setPosition({x:n,y:s}),this}_eachAncestorReverse(t,e){let i,n,s=[],r=this.getParent();if(!e||e._id!==this._id){for(s.unshift(this);r&&(!e||r._id!==e._id);)s.unshift(r),r=r.parent;for(i=s.length,n=0;n0&&(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return g.warn("Node has no parent. moveToBottom function is ignored."),!1;const t=this.index;return t>0&&(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(t){if(!this.parent)return g.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&g.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const e=this.index;return this.parent.children.splice(e,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(D,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const e=this.getParent();return e&&!e._isUnderCache&&(t*=e.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let t,e,i,n,s,r=this.getAttrs();const a={attrs:{},className:this.getClassName()};for(t in r)e=r[t],s=g.isObject(e)&&!g._isPlainObject(e)&&!g._isArray(e),s||(i="function"==typeof this[t]&&this[t],delete r[t],n=i?i.call(this):null,r[t]=e,n!==e&&(a.attrs[t]=e));return g._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,e,i){const n=[];e&&this._isMatch(t)&&n.push(this);let s=this.parent;for(;s;){if(s===i)return n;s._isMatch(t)&&n.push(s),s=s.parent}return n}isAncestorOf(t){return!1}findAncestor(t,e,i){return this.findAncestors(t,e,i)[0]}_isMatch(t){if(!t)return!1;if("function"==typeof t)return t(this);let e,i,n=t.replace(/ /g,"").split(","),s=n.length;for(e=0;e{try{const i=null==t?void 0:t.callback;i&&delete t.callback,g._urlToImage(this.toDataURL(t),(function(t){e(t),null==i||i(t)}))}catch(t){i(t)}}))}toBlob(t){return new Promise(((e,i)=>{try{const i=null==t?void 0:t.callback;i&&delete t.callback,this.toCanvas(t).toBlob((t=>{e(t),null==i||i(t)}),null==t?void 0:t.mimeType,null==t?void 0:t.quality)}catch(t){i(t)}}))}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():i.dragDistance}_off(t,e,i){let n,s,r,a=this.eventListeners[t];for(n=0;n=0))return;if(this.isDragging())return;let e=!1;b._dragElements.forEach((t=>{this.isAncestorOf(t.node)&&(e=!0)})),e||this._createDragElement(t)}))}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();if(!this.getStage())return;const t=b._dragElements.get(this._id),e=t&&"dragging"===t.dragStatus,i=t&&"ready"===t.dragStatus;e?this.stopDrag():i&&b._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const e=this.getStage();if(!e)return!1;const i={x:-t.x,y:-t.y,width:e.width()+2*t.x,height:e.height()+2*t.y};return g.haveIntersection(i,this.getClientRect())}static create(t,e){return g._isString(t)&&(t=JSON.parse(t)),this._createNode(t,e)}static _createNode(t,e){let n,s,r,a=q.prototype.getClassName.call(t),o=t.children;e&&(t.attrs.container=e),i[a]||(g.warn('Can not find a node with class name "'+a+'". Fallback to "Shape".'),a="Shape");if(n=new(0,i[a])(t.attrs),o)for(s=o.length,r=0;r0}removeChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.remove()})),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach((t=>{t.parent=null,t.index=0,t.destroy()})),this.children=[],this._requestDraw(),this}add(...t){if(0===t.length)return this;if(t.length>1){for(let e=0;e0?e[0]:void 0}_generalFind(t,e){const i=[];return this._descendants((n=>{const s=n._isMatch(t);return s&&i.push(n),!(!s||!e)})),i}_descendants(t){let e=!1;const i=this.getChildren();for(const n of i){if(e=t(n),e)return!0;if(n.hasChildren()&&(e=n._descendants(t),e))return!0}return!1}toObject(){const t=q.prototype.toObject.call(this);return t.children=[],this.getChildren().forEach((e=>{t.children.push(e.toObject())})),t}isAncestorOf(t){let e=t.getParent();for(;e;){if(e._id===this._id)return!0;e=e.getParent()}return!1}clone(t){const e=q.prototype.clone.call(this,t);return this.getChildren().forEach((function(t){e.add(t.clone())})),e}getAllIntersections(t){const e=[];return this.find("Shape").forEach((i=>{i.isVisible()&&i.intersects(t)&&e.push(i)})),e}_clearSelfAndDescendantCache(t){var e;super._clearSelfAndDescendantCache(t),this.isCached()||null===(e=this.children)||void 0===e||e.forEach((function(e){e._clearSelfAndDescendantCache(t)}))}_setChildrenIndices(){var t;null===(t=this.children)||void 0===t||t.forEach((function(t,e){t.index=e})),this._requestDraw()}drawScene(t,e,i){const n=this.getLayer(),s=t||n&&n.getCanvas(),r=s&&s.getContext(),a=this._getCanvasCache(),o=a&&a.scene,h=s&&s.isCache;if(!this.isVisible()&&!h)return this;if(o){r.save();const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(r),r.restore()}else this._drawChildren("drawScene",s,e,i);return this}drawHit(t,e){if(!this.shouldDrawHit(e))return this;const i=this.getLayer(),n=t||i&&i.hitCanvas,s=n&&n.getContext(),r=this._getCanvasCache();if(r&&r.hit){s.save();const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(s),s.restore()}else this._drawChildren("drawHit",n,e);return this}_drawChildren(t,e,i,n){var s;const r=e&&e.getContext(),a=this.clipWidth(),o=this.clipHeight(),h=this.clipFunc(),l="number"==typeof a&&"number"==typeof o||h,d=i===this;if(l){r.save();const t=this.getAbsoluteTransform(i);let e,n=t.getMatrix();if(r.transform(n[0],n[1],n[2],n[3],n[4],n[5]),r.beginPath(),h)e=h.call(this,r,this);else{const t=this.clipX(),e=this.clipY();r.rect(t||0,e||0,a,o)}r.clip.apply(r,e),n=t.copy().invert().getMatrix(),r.transform(n[0],n[1],n[2],n[3],n[4],n[5])}const c=!d&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===t;c&&(r.save(),r._applyGlobalCompositeOperation(this)),null===(s=this.children)||void 0===s||s.forEach((function(s){s[t](e,i,n)})),c&&r.restore(),l&&r.restore()}getClientRect(t={}){var e;const i=t.skipTransform,n=t.relativeTo;let s,r,a,o,h={x:1/0,y:1/0,width:0,height:0};const l=this;null===(e=this.children)||void 0===e||e.forEach((function(e){if(!e.visible())return;const i=e.getClientRect({relativeTo:l,skipShadow:t.skipShadow,skipStroke:t.skipStroke});0===i.width&&0===i.height||(void 0===s?(s=i.x,r=i.y,a=i.x+i.width,o=i.y+i.height):(s=Math.min(s,i.x),r=Math.min(r,i.y),a=Math.max(a,i.x+i.width),o=Math.max(o,i.y+i.height)))}));const d=this.find("Shape");let c=!1;for(let t=0;tt.indexOf("pointer")>=0?"pointer":t.indexOf("touch")>=0?"touch":"mouse",Pt=t=>{const e=Ct(t);return"pointer"===e?i.pointerEventsEnabled&&wt.pointer:"touch"===e?wt.touch:"mouse"===e?wt.mouse:void 0};function kt(t={}){return(t.clipFunc||t.clipWidth||t.clipHeight)&&g.warn("Stage does not support clipping. Please use clip for Layers or Groups."),t}const At=[];class Tt extends V{constructor(t){super(kt(t)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),At.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(()=>{kt(this.attrs)})),this._checkVisibility()}_validateAdd(t){const e="Layer"===t.getType(),i="FastLayer"===t.getType();e||i||g.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const t=this.visible()?"":"none";this.content.style.display=t}setContainer(t){if("string"==typeof t){let e;if("."===t.charAt(0)){const e=t.slice(1);t=document.getElementsByClassName(e)[0]}else e="#"!==t.charAt(0)?t:t.slice(1),t=document.getElementById(e);if(!t)throw"Can not find container in document with id "+e}return this._setAttr("container",t),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),t.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const t=this.children,e=t.length;for(let i=0;i-1&&At.splice(e,1),g.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const t=this._pointerPositions[0]||this._changedPointerPositions[0];return t?{x:t.x,y:t.y}:(g.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(t){return this._pointerPositions.find((e=>e.id===t))}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(t){(t=t||{}).x=t.x||0,t.y=t.y||0,t.width=t.width||this.width(),t.height=t.height||this.height();const e=new v({width:t.width,height:t.height,pixelRatio:t.pixelRatio||1}),i=e.getContext()._context,n=this.children;return(t.x||t.y)&&i.translate(-1*t.x,-1*t.y),n.forEach((function(e){if(!e.isVisible())return;const n=e._toKonvaCanvas(t);i.drawImage(n._canvas,t.x,t.y,n.getWidth()/n.getPixelRatio(),n.getHeight()/n.getPixelRatio())})),e}getIntersection(t){if(!t)return null;const e=this.children;for(let i=e.length-1;i>=0;i--){const n=e[i].getIntersection(t);if(n)return n}return null}_resizeDOM(){const t=this.width(),e=this.height();this.content&&(this.content.style.width=t+"px",this.content.style.height=e+"px"),this.bufferCanvas.setSize(t,e),this.bufferHitCanvas.setSize(t,e),this.children.forEach((i=>{i.setSize({width:t,height:e}),i.draw()}))}add(t,...e){if(arguments.length>1){for(let t=0;t5&&g.warn("The stage has "+n+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),t.setSize({width:this.width(),height:this.height()}),t.draw(),i.isBrowser&&this.content.appendChild(t.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(t){return Z(t,this)}setPointerCapture(t){tt(t,this)}releaseCapture(t){et(t)}getLayers(){return this.children}_bindContentEvents(){i.isBrowser&&St.forEach((([t,e])=>{this.content.addEventListener(t,(t=>{this[e](t)}),{passive:!1})}))}_pointerenter(t){this.setPointersPositions(t);const e=Pt(t.type);e&&this._fire(e.pointerenter,{evt:t,target:this,currentTarget:this})}_pointerover(t){this.setPointersPositions(t);const e=Pt(t.type);e&&this._fire(e.pointerover,{evt:t,target:this,currentTarget:this})}_getTargetShape(t){let e=this[t+"targetShape"];return e&&!e.getStage()&&(e=null),e}_pointerleave(t){const e=Pt(t.type),n=Ct(t.type);if(!e)return;this.setPointersPositions(t);const s=this._getTargetShape(n),r=!(i.isDragging()||i.isTransforming())||i.hitOnDragEnabled;s&&r?(s._fireAndBubble(e.pointerout,{evt:t}),s._fireAndBubble(e.pointerleave,{evt:t}),this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this[n+"targetShape"]=null):r&&(this._fire(e.pointerleave,{evt:t,target:this,currentTarget:this}),this._fire(e.pointerout,{evt:t,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(t){const e=Pt(t.type),n=Ct(t.type);if(!e)return;this.setPointersPositions(t);let s=!1;this._changedPointerPositions.forEach((r=>{const a=this.getIntersection(r);if(b.justDragged=!1,i["_"+n+"ListenClick"]=!0,!a||!a.isListening())return void(this[n+"ClickStartShape"]=void 0);i.capturePointerEventsEnabled&&a.setPointerCapture(r.id),this[n+"ClickStartShape"]=a,a._fireAndBubble(e.pointerdown,{evt:t,pointerId:r.id}),s=!0;const o=t.type.indexOf("touch")>=0;a.preventDefault()&&t.cancelable&&o&&t.preventDefault()})),s||this._fire(e.pointerdown,{evt:t,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(t){const e=Pt(t.type),n=Ct(t.type);if(!e)return;i.isDragging()&&b.node.preventDefault()&&t.cancelable&&t.preventDefault(),this.setPointersPositions(t);if(!(!(i.isDragging()||i.isTransforming())||i.hitOnDragEnabled))return;const s={};let r=!1;const a=this._getTargetShape(n);this._changedPointerPositions.forEach((i=>{const o=J(i.id)||this.getIntersection(i),h=i.id,l={evt:t,pointerId:h},d=a!==o;if(d&&a&&(a._fireAndBubble(e.pointerout,{...l},o),a._fireAndBubble(e.pointerleave,{...l},o)),o){if(s[o._id])return;s[o._id]=!0}o&&o.isListening()?(r=!0,d&&(o._fireAndBubble(e.pointerover,{...l},a),o._fireAndBubble(e.pointerenter,{...l},a),this[n+"targetShape"]=o),o._fireAndBubble(e.pointermove,{...l})):a&&(this._fire(e.pointerover,{evt:t,target:this,currentTarget:this,pointerId:h}),this[n+"targetShape"]=null)})),r||this._fire(e.pointermove,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(t){const e=Pt(t.type),n=Ct(t.type);if(!e)return;this.setPointersPositions(t);const s=this[n+"ClickStartShape"],r=this[n+"ClickEndShape"],a={};let o=!1;this._changedPointerPositions.forEach((h=>{const l=J(h.id)||this.getIntersection(h);if(l){if(l.releaseCapture(h.id),a[l._id])return;a[l._id]=!0}const d=h.id,c={evt:t,pointerId:d};let g=!1;i["_"+n+"InDblClickWindow"]?(g=!0,clearTimeout(this[n+"DblTimeout"])):b.justDragged||(i["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout((function(){i["_"+n+"InDblClickWindow"]=!1}),i.dblClickWindow),l&&l.isListening()?(o=!0,this[n+"ClickEndShape"]=l,l._fireAndBubble(e.pointerup,{...c}),i["_"+n+"ListenClick"]&&s&&s===l&&(l._fireAndBubble(e.pointerclick,{...c}),g&&r&&r===l&&l._fireAndBubble(e.pointerdblclick,{...c}))):(this[n+"ClickEndShape"]=null,i["_"+n+"ListenClick"]&&this._fire(e.pointerclick,{evt:t,target:this,currentTarget:this,pointerId:d}),g&&this._fire(e.pointerdblclick,{evt:t,target:this,currentTarget:this,pointerId:d}))})),o||this._fire(e.pointerup,{evt:t,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),i["_"+n+"ListenClick"]=!1,t.cancelable&&"touch"!==n&&"pointer"!==n&&t.preventDefault()}_contextmenu(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(mt,{evt:t}):this._fire(mt,{evt:t,target:this,currentTarget:this})}_wheel(t){this.setPointersPositions(t);const e=this.getIntersection(this.getPointerPosition());e&&e.isListening()?e._fireAndBubble(bt,{evt:t}):this._fire(bt,{evt:t,target:this,currentTarget:this})}_pointercancel(t){this.setPointersPositions(t);const e=J(t.pointerId)||this.getIntersection(this.getPointerPosition());e&&e._fireAndBubble(dt,$(t)),et(t.pointerId)}_lostpointercapture(t){et(t.pointerId)}setPointersPositions(t){const e=this._getContentPosition();let i=null,n=null;void 0!==(t=t||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(t.touches,(t=>{this._pointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})})),Array.prototype.forEach.call(t.changedTouches||t.touches,(t=>{this._changedPointerPositions.push({id:t.identifier,x:(t.clientX-e.left)/e.scaleX,y:(t.clientY-e.top)/e.scaleY})}))):(i=(t.clientX-e.left)/e.scaleX,n=(t.clientY-e.top)/e.scaleY,this.pointerPos={x:i,y:n},this._pointerPositions=[{x:i,y:n,id:g._getFirstPointerId(t)}],this._changedPointerPositions=[{x:i,y:n,id:g._getFirstPointerId(t)}])}_setPointerPosition(t){g.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(t)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const t=this.content.getBoundingClientRect();return{top:t.top,left:t.left,scaleX:t.width/this.content.clientWidth||1,scaleY:t.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new v({width:this.width(),height:this.height()}),this.bufferHitCanvas=new x({pixelRatio:1,width:this.width(),height:this.height()}),!i.isBrowser)return;const t=this.container();if(!t)throw"Stage has no container. A container is required.";t.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),t.appendChild(this.content),this._resizeDOM()}cache(){return g.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach((function(t){t.batchDraw()})),this}}Tt.prototype.nodeType="Stage",n(Tt),E.addGetterSetter(Tt,"container"),i.isBrowser&&document.addEventListener("visibilitychange",(()=>{At.forEach((t=>{t.batchDraw()}))}));const Mt="hasShadow",Gt="shadowRGBA",Rt="patternImage",Et="linearGradient",Dt="radialGradient";let Lt;function Ot(){return Lt||(Lt=g.createCanvasElement().getContext("2d"),Lt)}const It={};class Ft extends q{constructor(t){let e;for(super(t);e=g.getRandomColor(),!e||e in It;);this.colorKey=e,It[e]=this}getContext(){return g.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return g.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(Mt,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(Rt,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const t=Ot().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(t&&t.setTransform){const e=new s;e.translate(this.fillPatternX(),this.fillPatternY()),e.rotate(i.getAngle(this.fillPatternRotation())),e.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),e.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const n=e.getMatrix(),r="undefined"==typeof DOMMatrix?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);t.setTransform(r)}return t}}_getLinearGradient(){return this._getCache(Et,this.__getLinearGradient)}__getLinearGradient(){const t=this.fillLinearGradientColorStops();if(t){const e=Ot(),i=this.fillLinearGradientStartPoint(),n=this.fillLinearGradientEndPoint(),s=e.createLinearGradient(i.x,i.y,n.x,n.y);for(let e=0;ethis.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],(()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops())))}hasHitStroke(){const t=this.hitStrokeWidth();return"auto"===t?this.hasStroke():this.strokeEnabled()&&!!t}intersects(t){const e=this.getStage();if(!e)return!1;const i=e.bufferHitCanvas;i.getContext().clear(),this.drawHit(i,void 0,!0);return i.context.getImageData(Math.round(t.x),Math.round(t.y),1,1).data[3]>0}destroy(){return q.prototype.destroy.call(this),delete It[this.colorKey],delete this.colorKey,this}_useBufferCanvas(t){var e;if(!(null===(e=this.attrs.perfectDrawEnabled)||void 0===e||e))return!1;const i=t||this.hasFill(),n=this.hasStroke(),s=1!==this.getAbsoluteOpacity();if(i&&n&&s)return!0;const r=this.hasShadow(),a=this.shadowForStrokeEnabled();return!!(i&&n&&r&&a)}setStrokeHitEnabled(t){g.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),t?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){const t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}getClientRect(t={}){let e=!1,i=this.getParent();for(;i;){if(i.isCached()){e=!0;break}i=i.getParent()}const n=t.skipTransform,s=t.relativeTo||e&&this.getStage()||void 0,r=this.getSelfRect(),a=!t.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=r.width+a,h=r.height+a,l=!t.skipShadow&&this.hasShadow(),d=l?this.shadowOffsetX():0,c=l?this.shadowOffsetY():0,g=o+Math.abs(d),u=h+Math.abs(c),f=l&&this.shadowBlur()||0,p={width:g+2*f,height:u+2*f,x:-(a/2+f)+Math.min(d,0)+r.x,y:-(a/2+f)+Math.min(c,0)+r.y};return n?p:this._transformedRect(p,s)}drawScene(t,e,i){const n=this.getLayer(),s=(t||n.getCanvas()).getContext(),r=this._getCanvasCache(),a=this.getSceneFunc(),o=this.hasShadow();let h;const l=e===this;if(!this.isVisible()&&!l)return this;if(r){s.save();const t=this.getAbsoluteTransform(e).getMatrix();return s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedSceneCanvas(s),s.restore(),this}if(!a)return this;if(s.save(),this._useBufferCanvas()){h=this.getStage();const t=i||h.bufferCanvas,n=t.getContext();n.clear(),n.save(),n._applyLineJoin(this);const r=this.getAbsoluteTransform(e).getMatrix();n.transform(r[0],r[1],r[2],r[3],r[4],r[5]),a.call(this,n,this),n.restore();const l=t.pixelRatio;o&&s._applyShadow(this),s._applyOpacity(this),s._applyGlobalCompositeOperation(this),s.drawImage(t._canvas,t.x||0,t.y||0,t.width/l,t.height/l)}else{if(s._applyLineJoin(this),!l){const t=this.getAbsoluteTransform(e).getMatrix();s.transform(t[0],t[1],t[2],t[3],t[4],t[5]),s._applyOpacity(this),s._applyGlobalCompositeOperation(this)}o&&s._applyShadow(this),a.call(this,s,this)}return s.restore(),this}drawHit(t,e,i=!1){if(!this.shouldDrawHit(e,i))return this;const n=this.getLayer(),s=t||n.hitCanvas,r=s&&s.getContext(),a=this.hitFunc()||this.sceneFunc(),o=this._getCanvasCache(),h=o&&o.hit;if(this.colorKey||g.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),h){r.save();const t=this.getAbsoluteTransform(e).getMatrix();return r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),this._drawCachedHitCanvas(r),r.restore(),this}if(!a)return this;r.save(),r._applyLineJoin(this);if(!(this===e)){const t=this.getAbsoluteTransform(e).getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5])}return a.call(this,r,this),r.restore(),this}drawHitFromCache(t=0){const e=this._getCanvasCache(),i=this._getCachedSceneCanvas(),n=e.hit,s=n.getContext(),r=n.getWidth(),a=n.getHeight();s.clear(),s.drawImage(i._canvas,0,0,r,a);try{const e=s.getImageData(0,0,r,a),i=e.data,n=i.length,o=g._hexToRgb(this.colorKey);for(let e=0;et?(i[e]=o.r,i[e+1]=o.g,i[e+2]=o.b,i[e+3]=255):i[e+3]=0}s.putImageData(e,0,0)}catch(t){g.error("Unable to draw hit graph from cached scene canvas. "+t.message)}return this}hasPointerCapture(t){return Z(t,this)}setPointerCapture(t){tt(t,this)}releaseCapture(t){et(t)}}Ft.prototype._fillFunc=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},Ft.prototype._strokeFunc=function(t){t.stroke()},Ft.prototype._fillFuncHit=function(t){const e=this.attrs.fillRule;e?t.fill(e):t.fill()},Ft.prototype._strokeFuncHit=function(t){t.stroke()},Ft.prototype._centroid=!1,Ft.prototype.nodeType="Shape",n(Ft),Ft.prototype.eventListeners={},Ft.prototype.on.call(Ft.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(Mt)})),Ft.prototype.on.call(Ft.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(Gt)})),Ft.prototype.on.call(Ft.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",(function(){this._clearCache(Rt)})),Ft.prototype.on.call(Ft.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",(function(){this._clearCache(Et)})),Ft.prototype.on.call(Ft.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",(function(){this._clearCache(Dt)})),E.addGetterSetter(Ft,"stroke",void 0,T()),E.addGetterSetter(Ft,"strokeWidth",2,C()),E.addGetterSetter(Ft,"fillAfterStrokeEnabled",!1),E.addGetterSetter(Ft,"hitStrokeWidth","auto",k()),E.addGetterSetter(Ft,"strokeHitEnabled",!0,M()),E.addGetterSetter(Ft,"perfectDrawEnabled",!0,M()),E.addGetterSetter(Ft,"shadowForStrokeEnabled",!0,M()),E.addGetterSetter(Ft,"lineJoin"),E.addGetterSetter(Ft,"lineCap"),E.addGetterSetter(Ft,"sceneFunc"),E.addGetterSetter(Ft,"hitFunc"),E.addGetterSetter(Ft,"dash"),E.addGetterSetter(Ft,"dashOffset",0,C()),E.addGetterSetter(Ft,"shadowColor",void 0,A()),E.addGetterSetter(Ft,"shadowBlur",0,C()),E.addGetterSetter(Ft,"shadowOpacity",1,C()),E.addComponentsGetterSetter(Ft,"shadowOffset",["x","y"]),E.addGetterSetter(Ft,"shadowOffsetX",0,C()),E.addGetterSetter(Ft,"shadowOffsetY",0,C()),E.addGetterSetter(Ft,"fillPatternImage"),E.addGetterSetter(Ft,"fill",void 0,T()),E.addGetterSetter(Ft,"fillPatternX",0,C()),E.addGetterSetter(Ft,"fillPatternY",0,C()),E.addGetterSetter(Ft,"fillLinearGradientColorStops"),E.addGetterSetter(Ft,"strokeLinearGradientColorStops"),E.addGetterSetter(Ft,"fillRadialGradientStartRadius",0),E.addGetterSetter(Ft,"fillRadialGradientEndRadius",0),E.addGetterSetter(Ft,"fillRadialGradientColorStops"),E.addGetterSetter(Ft,"fillPatternRepeat","repeat"),E.addGetterSetter(Ft,"fillEnabled",!0),E.addGetterSetter(Ft,"strokeEnabled",!0),E.addGetterSetter(Ft,"shadowEnabled",!0),E.addGetterSetter(Ft,"dashEnabled",!0),E.addGetterSetter(Ft,"strokeScaleEnabled",!0),E.addGetterSetter(Ft,"fillPriority","color"),E.addComponentsGetterSetter(Ft,"fillPatternOffset",["x","y"]),E.addGetterSetter(Ft,"fillPatternOffsetX",0,C()),E.addGetterSetter(Ft,"fillPatternOffsetY",0,C()),E.addComponentsGetterSetter(Ft,"fillPatternScale",["x","y"]),E.addGetterSetter(Ft,"fillPatternScaleX",1,C()),E.addGetterSetter(Ft,"fillPatternScaleY",1,C()),E.addComponentsGetterSetter(Ft,"fillLinearGradientStartPoint",["x","y"]),E.addComponentsGetterSetter(Ft,"strokeLinearGradientStartPoint",["x","y"]),E.addGetterSetter(Ft,"fillLinearGradientStartPointX",0),E.addGetterSetter(Ft,"strokeLinearGradientStartPointX",0),E.addGetterSetter(Ft,"fillLinearGradientStartPointY",0),E.addGetterSetter(Ft,"strokeLinearGradientStartPointY",0),E.addComponentsGetterSetter(Ft,"fillLinearGradientEndPoint",["x","y"]),E.addComponentsGetterSetter(Ft,"strokeLinearGradientEndPoint",["x","y"]),E.addGetterSetter(Ft,"fillLinearGradientEndPointX",0),E.addGetterSetter(Ft,"strokeLinearGradientEndPointX",0),E.addGetterSetter(Ft,"fillLinearGradientEndPointY",0),E.addGetterSetter(Ft,"strokeLinearGradientEndPointY",0),E.addComponentsGetterSetter(Ft,"fillRadialGradientStartPoint",["x","y"]),E.addGetterSetter(Ft,"fillRadialGradientStartPointX",0),E.addGetterSetter(Ft,"fillRadialGradientStartPointY",0),E.addComponentsGetterSetter(Ft,"fillRadialGradientEndPoint",["x","y"]),E.addGetterSetter(Ft,"fillRadialGradientEndPointX",0),E.addGetterSetter(Ft,"fillRadialGradientEndPointY",0),E.addGetterSetter(Ft,"fillPatternRotation",0),E.addGetterSetter(Ft,"fillRule",void 0,A()),E.backCompat(Ft,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});const Bt=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],Nt=Bt.length;class Ht extends V{constructor(t){super(t),this.canvas=new v,this.hitCanvas=new x({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(t){return this.getContext().clear(t),this.getHitCanvas().getContext().clear(t),this}setZIndex(t){super.setZIndex(t);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),t{this.draw(),this._waitingForDraw=!1}))),this}getIntersection(t){if(!this.isListening()||!this.isVisible())return null;let e=1,i=!1;for(;;){for(let n=0;n0?{antialiased:!0}:{}}drawScene(t,e,i){const n=this.getLayer(),s=t||n&&n.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&s.getContext().clear(),V.prototype.drawScene.call(this,s,e,i),this._fire("draw",{node:this}),this}drawHit(t,e){const i=this.getLayer(),n=t||i&&i.hitCanvas;return i&&i.clearBeforeDraw()&&i.getHitCanvas().getContext().clear(),V.prototype.drawHit.call(this,n,e),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(t){g.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(t)}getHitGraphEnabled(t){return g.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const t=this.parent;!!this.hitCanvas._canvas.parentNode?t.content.removeChild(this.hitCanvas._canvas):t.content.appendChild(this.hitCanvas._canvas)}destroy(){return g.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}Ht.prototype.nodeType="Layer",n(Ht),E.addGetterSetter(Ht,"imageSmoothingEnabled",!0),E.addGetterSetter(Ht,"clearBeforeDraw",!0),E.addGetterSetter(Ht,"hitGraphEnabled",!0,M());class zt extends Ht{constructor(t){super(t),this.listening(!1),g.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}zt.prototype.nodeType="FastLayer",n(zt);class Wt extends V{_validateAdd(t){const e=t.getType();"Group"!==e&&"Shape"!==e&&g.throw("You may only add groups and shapes to groups.")}}Wt.prototype.nodeType="Group",n(Wt);const Yt=e.performance&&e.performance.now?function(){return e.performance.now()}:function(){return(new Date).getTime()};class Xt{constructor(t,e){this.id=Xt.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Yt(),frameRate:0},this.func=t,this.setLayers(e)}setLayers(t){let e=[];return t&&(e=Array.isArray(t)?t:[t]),this.layers=e,this}getLayers(){return this.layers}addLayer(t){const e=this.layers,i=e.length;for(let n=0;nthis.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():t<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=t,this.update())}getTime(){return this._time}setPosition(t){this.prevPos=this._pos,this.propFunc(t),this._pos=t}getPosition(t){return void 0===t&&(t=this._time),this.func(t,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(t){this.pause(),this._time=t,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const t=this.getTimer()-this._startTime;2===this.state?this.setTime(t):3===this.state&&this.setTime(this.duration-t)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class Kt{constructor(t){const e=this,n=t.node,s=n._id,r=t.easing||Qt.Linear,a=!!t.yoyo;let o,h;o=void 0===t.duration?.3:0===t.duration?.001:t.duration,this.node=n,this._id=Ut++;const l=n.getLayer()||(n instanceof i.Stage?n.getLayers():null);for(h in l||g.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new Xt((function(){e.tween.onEnterFrame()}),l),this.tween=new Vt(h,(function(t){e._tweenFunc(t)}),r,0,1,1e3*o,a),this._addListeners(),Kt.attrs[s]||(Kt.attrs[s]={}),Kt.attrs[s][this._id]||(Kt.attrs[s][this._id]={}),Kt.tweens[s]||(Kt.tweens[s]={}),t)void 0===jt[h]&&this._addAttr(h,t[h]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,e){const i=this.node,n=i._id;let s,r,a,o,h;const l=Kt.tweens[n][t];l&&delete Kt.attrs[n][l][t];let d=i.getAttr(t);if(g._isArray(e))if(s=[],r=Math.max(e.length,d.length),"points"===t&&e.length!==d.length&&(e.length>d.length?(o=d,d=g._prepareArrayForTween(d,e,i.closed())):(a=e,e=g._prepareArrayForTween(e,d,i.closed()))),0===t.indexOf("fill"))for(let t=0;t{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,e=Kt.attrs[t._id][this._id];e.points&&e.points.trueEnd&&t.setAttr("points",e.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,e=Kt.attrs[t._id][this._id];e.points&&e.points.trueStart&&t.points(e.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(1e3*t),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,e=this._id,i=Kt.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const e in i)delete Kt.tweens[t][e];delete Kt.attrs[t][e],Kt.tweens[t]&&(0===Object.keys(Kt.tweens[t]).length&&delete Kt.tweens[t],0===Object.keys(Kt.attrs[t]).length&&delete Kt.attrs[t])}}Kt.attrs={},Kt.tweens={},q.prototype.to=function(t){const e=t.onFinish;t.node=this,t.onFinish=function(){this.destroy(),e&&e()};new Kt(t).play()};const Qt={BackEaseIn(t,e,i,n){const s=1.70158;return i*(t/=n)*t*((s+1)*t-s)+e},BackEaseOut(t,e,i,n){const s=1.70158;return i*((t=t/n-1)*t*((s+1)*t+s)+1)+e},BackEaseInOut(t,e,i,n){let s=1.70158;return(t/=n/2)<1?i/2*(t*t*((1+(s*=1.525))*t-s))+e:i/2*((t-=2)*t*((1+(s*=1.525))*t+s)+2)+e},ElasticEaseIn(t,e,i,n,s,r){let a=0;return 0===t?e:1==(t/=n)?e+i:(r||(r=.3*n),!s||s(t/=n)<1/2.75?i*(7.5625*t*t)+e:t<2/2.75?i*(7.5625*(t-=1.5/2.75)*t+.75)+e:t<2.5/2.75?i*(7.5625*(t-=2.25/2.75)*t+.9375)+e:i*(7.5625*(t-=2.625/2.75)*t+.984375)+e,BounceEaseIn:(t,e,i,n)=>i-Qt.BounceEaseOut(n-t,0,i,n)+e,BounceEaseInOut:(t,e,i,n)=>ti*(t/=n)*t+e,EaseOut:(t,e,i,n)=>-i*(t/=n)*(t-2)+e,EaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t+e:-i/2*(--t*(t-2)-1)+e,StrongEaseIn:(t,e,i,n)=>i*(t/=n)*t*t*t*t+e,StrongEaseOut:(t,e,i,n)=>i*((t=t/n-1)*t*t*t*t+1)+e,StrongEaseInOut:(t,e,i,n)=>(t/=n/2)<1?i/2*t*t*t*t*t+e:i/2*((t-=2)*t*t*t*t+2)+e,Linear:(t,e,i,n)=>i*t/n+e},Jt=g._assign(i,{Util:g,Transform:s,Node:q,Container:V,Stage:Tt,stages:At,Layer:Ht,FastLayer:zt,Group:Wt,DD:b,Shape:Ft,shapes:It,Animation:Xt,Tween:Kt,Easings:Qt,Context:f,Canvas:y});class $t extends Ft{_sceneFunc(t){const e=i.getAngle(this.angle()),n=this.clockwise();t.beginPath(),t.arc(0,0,this.outerRadius(),0,e,n),t.arc(0,0,this.innerRadius(),e,0,!n),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}getSelfRect(){const t=this.innerRadius(),e=this.outerRadius(),n=this.clockwise(),s=i.getAngle(n?360-this.angle():this.angle()),r=Math.cos(Math.min(s,Math.PI)),a=Math.sin(Math.min(Math.max(Math.PI,s),3*Math.PI/2)),o=Math.sin(Math.min(s,Math.PI/2)),h=r*(r>0?t:e),l=a*(a>0?t:e),d=o*(o>0?e:t);return{x:h,y:n?-1*d:l,width:1*e-h,height:d-l}}}function Zt(t,e,i,n,s,r,a){const o=Math.sqrt(Math.pow(i-t,2)+Math.pow(n-e,2)),h=Math.sqrt(Math.pow(s-i,2)+Math.pow(r-n,2)),l=a*o/(o+h),d=a*h/(o+h);return[i-l*(s-t),n-l*(r-e),i+d*(s-t),n+d*(r-e)]}function te(t,e){const i=t.length,n=[];for(let s=2;s4){const n=this.getTensionPoints(),r=n.length;for(a=s?0:4,s||t.quadraticCurveTo(n[0],n[1],n[2],n[3]);a{let n,s;const r=i/2;n=0;for(let i=0;i<20;i++)s=r*ie[20][i]+r,n+=ne[20][i]*oe(t,e,s);return r*n},ae=(t,e,i)=>{void 0===i&&(i=1);const n=t[0]-2*t[1]+t[2],s=e[0]-2*e[1]+e[2],r=2*t[1]-2*t[0],a=2*e[1]-2*e[0],o=4*(n*n+s*s),h=4*(n*r+s*a),l=r*r+a*a;if(0===o)return i*Math.sqrt(Math.pow(t[2]-t[0],2)+Math.pow(e[2]-e[0],2));const d=h/(2*o),c=i+d,g=l/o-d*d,u=c*c+g>0?Math.sqrt(c*c+g):0,f=d*d+g>0?Math.sqrt(d*d+g):0,p=d+Math.sqrt(d*d+g)!==0?g*Math.log(Math.abs((c+u)/(d+f))):0;return Math.sqrt(o)/2*(c*u-d*f+p)};function oe(t,e,i){const n=he(1,i,t),s=he(1,i,e),r=n*n+s*s;return Math.sqrt(r)}const he=(t,e,i)=>{const n=i.length-1;let s,r;if(0===n)return 0;if(0===t){r=0;for(let t=0;t<=n;t++)r+=se[n][t]*Math.pow(1-e,n-t)*Math.pow(e,t)*i[t];return r}s=new Array(n);for(let t=0;t{let n=1,s=t/e,r=(t-i(s))/e,a=0;for(;n>.001;){const o=i(s+r),h=Math.abs(t-o)/e;if(h500)break}return s};class de extends Ft{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",(function(){this._readDataAttribute()}))}_readDataAttribute(){this.dataArray=de.parsePathData(this.data()),this.pathLength=de.getPathLength(this.dataArray)}_sceneFunc(t){const e=this.dataArray;t.beginPath();let i=!1;for(let n=0;na?s:a,g=s>a?1:s/a,u=s>a?a/s:1;t.translate(e,n),t.rotate(l),t.scale(g,u),t.arc(0,0,c,o,o+h,1-d),t.scale(1/g,1/u),t.rotate(-l),t.translate(-e,-n);break;case"z":i=!0,t.closePath()}}i||this.hasFill()?t.fillStrokeShape(this):t.strokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach((function(e){if("A"===e.command){const i=e.points[4],n=e.points[5],s=e.points[4]+n;let r=Math.PI/180;if(Math.abs(i-s)s;n-=r){const i=de.getPointOnEllipticalArc(e.points[0],e.points[1],e.points[2],e.points[3],n,0);t.push(i.x,i.y)}else for(let n=i+r;ne[n].pathLength;)t-=e[n].pathLength,++n;if(n===s)return i=e[n-1].points.slice(-2),{x:i[0],y:i[1]};if(t<.01){return"M"===e[n].command?(i=e[n].points.slice(0,2),{x:i[0],y:i[1]}):{x:e[n].start.x,y:e[n].start.y}}const r=e[n],a=r.points;switch(r.command){case"L":return de.getPointOnLine(t,r.start.x,r.start.y,a[0],a[1]);case"C":return de.getPointOnCubicBezier(le(t,de.getPathLength(e),(t=>re([r.start.x,a[0],a[2],a[4]],[r.start.y,a[1],a[3],a[5]],t))),r.start.x,r.start.y,a[0],a[1],a[2],a[3],a[4],a[5]);case"Q":return de.getPointOnQuadraticBezier(le(t,de.getPathLength(e),(t=>ae([r.start.x,a[0],a[2]],[r.start.y,a[1],a[3]],t))),r.start.x,r.start.y,a[0],a[1],a[2],a[3]);case"A":const i=a[0],n=a[1],s=a[2],o=a[3],h=a[5],l=a[6];let d=a[4];return d+=h*t/r.pathLength,de.getPointOnEllipticalArc(i,n,s,o,d,l)}return null}static getPointOnLine(t,e,i,n,s,r,a){r=null!=r?r:e,a=null!=a?a:i;const o=this.getLineLength(e,i,n,s);if(o<1e-10)return{x:e,y:i};if(n===e)return{x:r,y:a+(s>i?t:-t)};const h=(s-i)/(n-e),l=Math.sqrt(t*t/(1+h*h))*(n0&&!isNaN(d[0]);){let t="",e=[];const n=a,r=o;let h,l,c,g,u,f,p,m,_,y;switch(i){case"l":a+=d.shift(),o+=d.shift(),t="L",e.push(a,o);break;case"L":a=d.shift(),o=d.shift(),e.push(a,o);break;case"m":const n=d.shift(),r=d.shift();if(a+=n,o+=r,t="M",s.length>2&&"z"===s[s.length-1].command)for(let t=s.length-2;t>=0;t--)if("M"===s[t].command){a=s[t].points[0]+n,o=s[t].points[1]+r;break}e.push(a,o),i="l";break;case"M":a=d.shift(),o=d.shift(),t="M",e.push(a,o),i="L";break;case"h":a+=d.shift(),t="L",e.push(a,o);break;case"H":a=d.shift(),t="L",e.push(a,o);break;case"v":o+=d.shift(),t="L",e.push(a,o);break;case"V":o=d.shift(),t="L",e.push(a,o);break;case"C":e.push(d.shift(),d.shift(),d.shift(),d.shift()),a=d.shift(),o=d.shift(),e.push(a,o);break;case"c":e.push(a+d.shift(),o+d.shift(),a+d.shift(),o+d.shift()),a+=d.shift(),o+=d.shift(),t="C",e.push(a,o);break;case"S":l=a,c=o,h=s[s.length-1],"C"===h.command&&(l=a+(a-h.points[2]),c=o+(o-h.points[3])),e.push(l,c,d.shift(),d.shift()),a=d.shift(),o=d.shift(),t="C",e.push(a,o);break;case"s":l=a,c=o,h=s[s.length-1],"C"===h.command&&(l=a+(a-h.points[2]),c=o+(o-h.points[3])),e.push(l,c,a+d.shift(),o+d.shift()),a+=d.shift(),o+=d.shift(),t="C",e.push(a,o);break;case"Q":e.push(d.shift(),d.shift()),a=d.shift(),o=d.shift(),e.push(a,o);break;case"q":e.push(a+d.shift(),o+d.shift()),a+=d.shift(),o+=d.shift(),t="Q",e.push(a,o);break;case"T":l=a,c=o,h=s[s.length-1],"Q"===h.command&&(l=a+(a-h.points[0]),c=o+(o-h.points[1])),a=d.shift(),o=d.shift(),t="Q",e.push(l,c,a,o);break;case"t":l=a,c=o,h=s[s.length-1],"Q"===h.command&&(l=a+(a-h.points[0]),c=o+(o-h.points[1])),a+=d.shift(),o+=d.shift(),t="Q",e.push(l,c,a,o);break;case"A":g=d.shift(),u=d.shift(),f=d.shift(),p=d.shift(),m=d.shift(),_=a,y=o,a=d.shift(),o=d.shift(),t="A",e=this.convertEndpointToCenterParameterization(_,y,a,o,p,m,g,u,f);break;case"a":g=d.shift(),u=d.shift(),f=d.shift(),p=d.shift(),m=d.shift(),_=a,y=o,a+=d.shift(),o+=d.shift(),t="A",e=this.convertEndpointToCenterParameterization(_,y,a,o,p,m,g,u,f)}s.push({command:t||i,points:e,start:{x:n,y:r},pathLength:this.calcLength(n,r,t||i,e)})}"z"!==i&&"Z"!==i||s.push({command:"z",points:[],start:void 0,pathLength:0})}return s}static calcLength(t,e,i,n){let s,r,a,o;const h=de;switch(i){case"L":return h.getLineLength(t,e,n[0],n[1]);case"C":return re([t,n[0],n[2],n[4]],[e,n[1],n[3],n[5]],1);case"Q":return ae([t,n[0],n[2]],[e,n[1],n[3]],1);case"A":s=0;const i=n[4],l=n[5],d=n[4]+l;let c=Math.PI/180;if(Math.abs(i-d)d;o-=c)a=h.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],o,0),s+=h.getLineLength(r.x,r.y,a.x,a.y),r=a;else for(o=i+c;o1&&(a*=Math.sqrt(g),o*=Math.sqrt(g));let u=Math.sqrt((a*a*(o*o)-a*a*(c*c)-o*o*(d*d))/(a*a*(c*c)+o*o*(d*d)));s===r&&(u*=-1),isNaN(u)&&(u=0);const f=u*a*c/o,p=u*-o*d/a,m=(t+i)/2+Math.cos(l)*f-Math.sin(l)*p,_=(e+n)/2+Math.sin(l)*f+Math.cos(l)*p,y=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])},v=function(t,e){return(t[0]*e[0]+t[1]*e[1])/(y(t)*y(e))},x=function(t,e){return(t[0]*e[1]=1&&(C=0),0===r&&C>0&&(C-=2*Math.PI),1===r&&C<0&&(C+=2*Math.PI),[m,_,a,o,b,C,l,r]}}de.prototype.className="Path",de.prototype._attrsAffectingSize=["data"],n(de),E.addGetterSetter(de,"data");class ce extends ee{_sceneFunc(t){super._sceneFunc(t);const e=2*Math.PI,i=this.points();let n=i;const s=0!==this.tension()&&i.length>4;s&&(n=this.getTensionPoints());const r=this.pointerLength(),a=i.length;let o,h;if(s){const t=[n[n.length-4],n[n.length-3],n[n.length-2],n[n.length-1],i[a-2],i[a-1]],e=de.calcLength(n[n.length-4],n[n.length-3],"C",t),s=de.getPointOnQuadraticBezier(Math.min(1,1-r/e),t[0],t[1],t[2],t[3],t[4],t[5]);o=i[a-2]-s.x,h=i[a-1]-s.y}else o=i[a-2]-i[a-4],h=i[a-1]-i[a-3];const l=(Math.atan2(h,o)+e)%e,d=this.pointerWidth();this.pointerAtEnding()&&(t.save(),t.beginPath(),t.translate(i[a-2],i[a-1]),t.rotate(l),t.moveTo(0,0),t.lineTo(-r,d/2),t.lineTo(-r,-d/2),t.closePath(),t.restore(),this.__fillStroke(t)),this.pointerAtBeginning()&&(t.save(),t.beginPath(),t.translate(i[0],i[1]),s?(o=(n[0]+n[2])/2-i[0],h=(n[1]+n[3])/2-i[1]):(o=i[2]-i[0],h=i[3]-i[1]),t.rotate((Math.atan2(-h,-o)+e)%e),t.moveTo(0,0),t.lineTo(-r,d/2),t.lineTo(-r,-d/2),t.closePath(),t.restore(),this.__fillStroke(t))}__fillStroke(t){const e=this.dashEnabled();e&&(this.attrs.dashEnabled=!1,t.setLineDash([])),t.fillStrokeShape(this),e&&(this.attrs.dashEnabled=!0)}getSelfRect(){const t=super.getSelfRect(),e=this.pointerWidth()/2;return{x:t.x,y:t.y-e,width:t.width,height:t.height+2*e}}}ce.prototype.className="Arrow",n(ce),E.addGetterSetter(ce,"pointerLength",10,C()),E.addGetterSetter(ce,"pointerWidth",10,C()),E.addGetterSetter(ce,"pointerAtBeginning",!1),E.addGetterSetter(ce,"pointerAtEnding",!0);class ge extends Ft{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius()!==t/2&&this.radius(t/2)}setHeight(t){this.radius()!==t/2&&this.radius(t/2)}}ge.prototype._centroid=!0,ge.prototype.className="Circle",ge.prototype._attrsAffectingSize=["radius"],n(ge),E.addGetterSetter(ge,"radius",0,C());class ue extends Ft{_sceneFunc(t){const e=this.radiusX(),i=this.radiusY();t.beginPath(),t.save(),e!==i&&t.scale(1,i/e),t.arc(0,0,e,0,2*Math.PI,!1),t.restore(),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(t){this.radiusX(t/2)}setHeight(t){this.radiusY(t/2)}}ue.prototype.className="Ellipse",ue.prototype._centroid=!0,ue.prototype._attrsAffectingSize=["radiusX","radiusY"],n(ue),E.addComponentsGetterSetter(ue,"radius",["x","y"]),E.addGetterSetter(ue,"radiusX",0,C()),E.addGetterSetter(ue,"radiusY",0,C());class fe extends Ft{constructor(t){super(t),this._loadListener=()=>{this._requestDraw()},this.on("imageChange.konva",(t=>{this._removeImageLoad(t.oldVal),this._setImageLoad()})),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&4===t.readyState||t&&t.addEventListener&&t.addEventListener("load",this._loadListener)}_removeImageLoad(t){t&&t.removeEventListener&&t.removeEventListener("load",this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){const t=!!this.cornerRadius(),e=this.hasShadow();return!(!t||!e)||super._useBufferCanvas(!0)}_sceneFunc(t){const e=this.getWidth(),i=this.getHeight(),n=this.cornerRadius(),s=this.attrs.image;let r;if(s){const t=this.attrs.cropWidth,n=this.attrs.cropHeight;r=t&&n?[s,this.cropX(),this.cropY(),t,n,0,0,e,i]:[s,0,0,e,i]}(this.hasFill()||this.hasStroke()||n)&&(t.beginPath(),n?g.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)),s&&(n&&t.clip(),t.drawImage.apply(t,r))}_hitFunc(t){const e=this.width(),i=this.height(),n=this.cornerRadius();t.beginPath(),n?g.drawRoundedRectPath(t,e,i,n):t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,e;return null!==(t=this.attrs.width)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.width}getHeight(){var t,e;return null!==(t=this.attrs.height)&&void 0!==t?t:null===(e=this.image())||void 0===e?void 0:e.height}static fromURL(t,e,i=null){const n=g.createImageElement();n.onload=function(){const t=new fe({image:n});e(t)},n.onerror=i,n.crossOrigin="Anonymous",n.src=t}}fe.prototype.className="Image",n(fe),E.addGetterSetter(fe,"cornerRadius",0,P(4)),E.addGetterSetter(fe,"image"),E.addComponentsGetterSetter(fe,"crop",["x","y","width","height"]),E.addGetterSetter(fe,"cropX",0,C()),E.addGetterSetter(fe,"cropY",0,C()),E.addGetterSetter(fe,"cropWidth",0,C()),E.addGetterSetter(fe,"cropHeight",0,C());const pe=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],me="up",_e="right",ye="down",ve="left",xe=pe.length;class be extends Wt{constructor(t){super(t),this.on("add.konva",(function(t){this._addListeners(t.child),this._sync()}))}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(t){let e,i=this;const n=function(){i._sync()};for(e=0;e{e=Math.min(e,t.x),i=Math.max(i,t.x),n=Math.min(n,t.y),s=Math.max(s,t.y)})),{x:e,y:n,width:i-e,height:s-n}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}Ce.prototype.className="RegularPolygon",Ce.prototype._centroid=!0,Ce.prototype._attrsAffectingSize=["radius"],n(Ce),E.addGetterSetter(Ce,"radius",0,C()),E.addGetterSetter(Ce,"sides",0,C());const Pe=2*Math.PI;class ke extends Ft{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.innerRadius(),0,Pe,!1),t.moveTo(this.outerRadius(),0),t.arc(0,0,this.outerRadius(),Pe,0,!0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(t){this.outerRadius(t/2)}setHeight(t){this.outerRadius(t/2)}}ke.prototype.className="Ring",ke.prototype._centroid=!0,ke.prototype._attrsAffectingSize=["innerRadius","outerRadius"],n(ke),E.addGetterSetter(ke,"innerRadius",0,C()),E.addGetterSetter(ke,"outerRadius",0,C());class Ae extends Ft{constructor(t){super(t),this._updated=!0,this.anim=new Xt((()=>{const t=this._updated;return this._updated=!1,t})),this.on("animationChange.konva",(function(){this.frameIndex(0)})),this.on("frameIndexChange.konva",(function(){this._updated=!0})),this.on("frameRateChange.konva",(function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())}))}_sceneFunc(t){const e=this.animation(),i=this.frameIndex(),n=4*i,s=this.animations()[e],r=this.frameOffsets(),a=s[n+0],o=s[n+1],h=s[n+2],l=s[n+3],d=this.image();if((this.hasFill()||this.hasStroke())&&(t.beginPath(),t.rect(0,0,h,l),t.closePath(),t.fillStrokeShape(this)),d)if(r){const n=r[e],s=2*i;t.drawImage(d,a,o,h,l,n[s+0],n[s+1],h,l)}else t.drawImage(d,a,o,h,l,0,0,h,l)}_hitFunc(t){const e=this.animation(),i=this.frameIndex(),n=4*i,s=this.animations()[e],r=this.frameOffsets(),a=s[n+2],o=s[n+3];if(t.beginPath(),r){const n=r[e],s=2*i;t.rect(n[s+0],n[s+1],a,o)}else t.rect(0,0,a,o);t.closePath(),t.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const t=this;this.interval=setInterval((function(){t._updateIndex()}),1e3/this.frameRate())}start(){if(this.isRunning())return;const t=this.getLayer();this.anim.setLayers(t),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const t=this.frameIndex(),e=this.animation();t{if(/\p{Emoji}/u.test(e)){const s=n[i+1];s&&/\p{Emoji_Modifier}|\u200D/u.test(s)?(t.push(e+s),n[i+1]=""):t.push(e)}else/\p{Regional_Indicator}{2}/u.test(e+(n[i+1]||""))?t.push(e+n[i+1]):i>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(e)?t[t.length-1]+=e:e&&t.push(e);return t}),[])}Te.prototype.className="Star",Te.prototype._centroid=!0,Te.prototype._attrsAffectingSize=["innerRadius","outerRadius"],n(Te),E.addGetterSetter(Te,"numPoints",5,C()),E.addGetterSetter(Te,"innerRadius",0,C()),E.addGetterSetter(Te,"outerRadius",0,C());const Ge="auto",Re="inherit",Ee="justify",De="left",Le="middle",Oe="normal",Ie=" ",Fe="none",Be=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],Ne=Be.length;let He;function ze(){return He||(He=g.createCanvasElement().getContext("2d"),He)}class We extends Ft{constructor(t){super(function(t){return(t=t||{}).fillLinearGradientColorStops||t.fillRadialGradientColorStops||t.fillPatternImage||(t.fill=t.fill||"black"),t}(t)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t1&&(y+=o)}}_hitFunc(t){const e=this.getWidth(),i=this.getHeight();t.beginPath(),t.rect(0,0,e,i),t.closePath(),t.fillStrokeShape(this)}setText(t){const e=g._isString(t)?t:null==t?"":t+"";return this._setAttr("text",e),this}getWidth(){return this.attrs.width===Ge||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===Ge||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return g.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(t){var e,i,n,s,r,a,o,h,l,d,c;let g,u=ze(),f=this.fontSize();u.save(),u.font=this._getContextFont(),g=u.measureText(t),u.restore();const p=f/100;return{actualBoundingBoxAscent:null!==(e=g.actualBoundingBoxAscent)&&void 0!==e?e:71.58203125*p,actualBoundingBoxDescent:null!==(i=g.actualBoundingBoxDescent)&&void 0!==i?i:0,actualBoundingBoxLeft:null!==(n=g.actualBoundingBoxLeft)&&void 0!==n?n:-7.421875*p,actualBoundingBoxRight:null!==(s=g.actualBoundingBoxRight)&&void 0!==s?s:75.732421875*p,alphabeticBaseline:null!==(r=g.alphabeticBaseline)&&void 0!==r?r:0,emHeightAscent:null!==(a=g.emHeightAscent)&&void 0!==a?a:100*p,emHeightDescent:null!==(o=g.emHeightDescent)&&void 0!==o?o:-20*p,fontBoundingBoxAscent:null!==(h=g.fontBoundingBoxAscent)&&void 0!==h?h:91*p,fontBoundingBoxDescent:null!==(l=g.fontBoundingBoxDescent)&&void 0!==l?l:21*p,hangingBaseline:null!==(d=g.hangingBaseline)&&void 0!==d?d:72.80000305175781*p,ideographicBaseline:null!==(c=g.ideographicBaseline)&&void 0!==c?c:-21*p,width:g.width,height:f}}_getContextFont(){return this.fontStyle()+Ie+this.fontVariant()+Ie+(this.fontSize()+"px ")+this.fontFamily().split(",").map((t=>{const e=(t=t.trim()).indexOf(" ")>=0,i=t.indexOf('"')>=0||t.indexOf("'")>=0;return e&&!i&&(t=`"${t}"`),t})).join(", ")}_addTextLine(t){this.align()===Ee&&(t=t.trim());const e=this._getTextWidth(t);return this.textArr.push({text:t,width:e,lastInParagraph:!1})}_getTextWidth(t){const e=this.letterSpacing(),i=t.length;return ze().measureText(t).width+e*i}_setTextData(){let t=this.text().split("\n"),e=+this.fontSize(),i=0,n=this.lineHeight()*e,s=this.attrs.width,r=this.attrs.height,a=s!==Ge&&void 0!==s,o=r!==Ge&&void 0!==r,h=this.padding(),l=s-2*h,d=r-2*h,c=0,g=this.wrap(),u="char"!==g&&g!==Fe,f=this.ellipsis();this.textArr=[],ze().font=this._getContextFont();const p=f?this._getTextWidth("…"):0;for(let e=0,s=t.length;el)for(;r.length>0;){let t=0,e=Me(r).length,s="",a=0;for(;t>>1,h=Me(r).slice(0,i+1).join(""),g=this._getTextWidth(h);(f&&o&&c+n>d?g+p:g)<=l?(t=i+1,s=h,a=g):e=i}if(!s)break;if(u){const e=Me(r),i=Me(s),n=e[i.length];let o;if((n===Ie||"-"===n)&&a<=l)o=i.length;else{const t=i.lastIndexOf(Ie),e=i.lastIndexOf("-");o=Math.max(t,e)+1}o>0&&(t=o,s=e.slice(0,t).join(""),a=this._getTextWidth(s))}s=s.trimRight(),this._addTextLine(s),i=Math.max(i,a),c+=n;if(this._shouldHandleEllipsis(c)){this._tryToAddEllipsisToLastLine();break}if(r=Me(r).slice(t).join("").trimLeft(),r.length>0&&(h=this._getTextWidth(r),h<=l)){this._addTextLine(r),c+=n,i=Math.max(i,h);break}}else this._addTextLine(r),c+=n,i=Math.max(i,h),this._shouldHandleEllipsis(c)&&ed)break}this.textHeight=e,this.textWidth=i}_shouldHandleEllipsis(t){const e=+this.fontSize(),i=this.lineHeight()*e,n=this.attrs.height,s=n!==Ge&&void 0!==n,r=n-2*this.padding();return!(this.wrap()!==Fe)||s&&t+i>r}_tryToAddEllipsisToLastLine(){const t=this.attrs.width,e=t!==Ge&&void 0!==t,i=t-2*this.padding(),n=this.ellipsis(),s=this.textArr[this.textArr.length-1];if(s&&n){if(e){this._getTextWidth(s.text+"…")this.pathLength?null:de.getPointAtLengthOfDataArray(t,this.dataArray)}_readDataAttribute(){this.dataArray=de.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(t){t.setAttr("font",this._getContextFont()),t.setAttr("textBaseline",this.textBaseline()),t.setAttr("textAlign","left"),t.save();const e=this.textDecoration(),i=this.fill(),n=this.fontSize(),s=this.glyphInfo;"underline"===e&&t.beginPath();for(let i=0;i=1){const i=e[0].p0;t.moveTo(i.x,i.y)}for(let i=0;it+`.${Ue}`)).join(" "),Ke="nodesRect",Qe=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],Je={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},$e="ontouchstart"in i._global;const Ze=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function ti(t,e,i){const n=i.x+(t.x-i.x)*Math.cos(e)-(t.y-i.y)*Math.sin(e),s=i.y+(t.x-i.x)*Math.sin(e)+(t.y-i.y)*Math.cos(e);return{...t,rotation:t.rotation+e,x:n,y:s}}function ei(t,e){const i=function(t){return{x:t.x+t.width/2*Math.cos(t.rotation)+t.height/2*Math.sin(-t.rotation),y:t.y+t.height/2*Math.cos(t.rotation)+t.width/2*Math.sin(t.rotation)}}(t);return ti(t,e,i)}let ii=0;class ni extends Wt{constructor(t){super(t),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(Ve,this.update),this.getNode()&&this.update()}attachTo(t){return this.setNode(t),this}setNode(t){return g.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([t])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return Ue+this._id}setNodes(t=[]){this._nodes&&this._nodes.length&&this.detach();const e=t.filter((t=>!t.isAncestorOf(this)||(g.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1)));this._nodes=t=e,1===t.length&&this.useSingleNodeRotation()?this.rotation(t[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach((t=>{const e=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()};if(t._attrsAffectingSize.length){const i=t._attrsAffectingSize.map((t=>t+"Change."+this._getEventNamespace())).join(" ");t.on(i,e)}t.on(Qe.map((t=>t+`.${this._getEventNamespace()}`)).join(" "),e),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,e),this._proxyDrag(t)})),this._resetTransformCache();return!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(t){let e;t.on(`dragstart.${this._getEventNamespace()}`,(i=>{e=t.getAbsolutePosition(),this.isDragging()||t===this.findOne(".back")||this.startDrag(i,!1)})),t.on(`dragmove.${this._getEventNamespace()}`,(i=>{if(!e)return;const n=t.getAbsolutePosition(),s=n.x-e.x,r=n.y-e.y;this.nodes().forEach((e=>{if(e===t)return;if(e.isDragging())return;const n=e.getAbsolutePosition();e.setAbsolutePosition({x:n.x+s,y:n.y+r}),e.startDrag(i)})),e=null}))}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach((t=>{t.off("."+this._getEventNamespace())})),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(Ke),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(Ke,this.__getNodeRect)}__getNodeShape(t,e=this.rotation(),n){const s=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=t.getAbsoluteScale(n),a=t.getAbsolutePosition(n),o=s.x*r.x-t.offsetX()*r.x,h=s.y*r.y-t.offsetY()*r.y,l=(i.getAngle(t.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return ti({x:a.x+o*Math.cos(l)+h*Math.sin(-l),y:a.y+h*Math.cos(l)+o*Math.sin(l),width:s.width*r.x,height:s.height*r.y,rotation:l},-i.getAngle(e),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const t=[];this.nodes().map((e=>{const i=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),n=[{x:i.x,y:i.y},{x:i.x+i.width,y:i.y},{x:i.x+i.width,y:i.y+i.height},{x:i.x,y:i.y+i.height}],s=e.getAbsoluteTransform();n.forEach((function(e){const i=s.point(e);t.push(i)}))}));const e=new s;e.rotate(-i.getAngle(this.rotation()));let n=1/0,r=1/0,a=-1/0,o=-1/0;t.forEach((function(t){const i=e.point(t);void 0===n&&(n=a=i.x,r=o=i.y),n=Math.min(n,i.x),r=Math.min(r,i.y),a=Math.max(a,i.x),o=Math.max(o,i.y)})),e.invert();const h=e.point({x:n,y:r});return{x:h.x,y:h.y,width:a-n,height:o-r,rotation:i.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),Ze.forEach((t=>{this._createAnchor(t)})),this._createAnchor("rotater")}_createAnchor(t){const e=new we({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:t+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:$e?10:"auto"}),n=this;e.on("mousedown touchstart",(function(t){n._handleMouseDown(t)})),e.on("dragstart",(t=>{e.stopDrag(),t.cancelBubble=!0})),e.on("dragend",(t=>{t.cancelBubble=!0})),e.on("mouseenter",(()=>{const n=i.getAngle(this.rotation()),s=this.rotateAnchorCursor(),r=function(t,e,i){if("rotater"===t)return i;e+=g.degToRad(Je[t]||0);const n=(g.radToDeg(e)%360+360)%360;return g._inRange(n,337.5,360)||g._inRange(n,0,22.5)?"ns-resize":g._inRange(n,22.5,67.5)?"nesw-resize":g._inRange(n,67.5,112.5)?"ew-resize":g._inRange(n,112.5,157.5)?"nwse-resize":g._inRange(n,157.5,202.5)?"ns-resize":g._inRange(n,202.5,247.5)?"nesw-resize":g._inRange(n,247.5,292.5)?"ew-resize":g._inRange(n,292.5,337.5)?"nwse-resize":(g.error("Transformer has unknown angle for cursor detection: "+n),"pointer")}(t,n,s);e.getStage().content&&(e.getStage().content.style.cursor=r),this._cursorChange=!0})),e.on("mouseout",(()=>{e.getStage().content&&(e.getStage().content.style.cursor=""),this._cursorChange=!1})),this.add(e)}_createBack(){const t=new Ft({name:"back",width:0,height:0,draggable:!0,sceneFunc(t,e){const i=e.getParent(),n=i.padding();t.beginPath(),t.rect(-n,-n,e.width()+2*n,e.height()+2*n),t.moveTo(e.width()/2,-n),i.rotateEnabled()&&i.rotateLineVisible()&&t.lineTo(e.width()/2,-i.rotateAnchorOffset()*g._sign(e.height())-n),t.fillStrokeShape(e)},hitFunc:(t,e)=>{if(!this.shouldOverdrawWholeArea())return;const i=this.padding();t.beginPath(),t.rect(-i,-i,e.width()+2*i,e.height()+2*i),t.fillStrokeShape(e)}});this.add(t),this._proxyDrag(t),t.on("dragstart",(t=>{t.cancelBubble=!0})),t.on("dragmove",(t=>{t.cancelBubble=!0})),t.on("dragend",(t=>{t.cancelBubble=!0})),this.on("dragmove",(t=>{this.update()}))}_handleMouseDown(t){if(this._transforming)return;this._movingAnchorName=t.target.name().split(" ")[0];const e=this._getNodeRect(),i=e.width,n=e.height,s=Math.sqrt(Math.pow(i,2)+Math.pow(n,2));this.sin=Math.abs(n/s),this.cos=Math.abs(i/s),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const r=t.target.getAbsolutePosition(),a=t.target.getStage().getPointerPosition();this._anchorDragOffset={x:a.x-r.x,y:a.y-r.y},ii++,this._fire("transformstart",{evt:t.evt,target:this.getNode()}),this._nodes.forEach((e=>{e._fire("transformstart",{evt:t.evt,target:e})}))}_handleMouseMove(t){let e,n,s;const r=this.findOne("."+this._movingAnchorName),a=r.getStage();a.setPointersPositions(t);const o=a.getPointerPosition();let h={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y};const l=r.getAbsolutePosition();this.anchorDragBoundFunc()&&(h=this.anchorDragBoundFunc()(l,h,t)),r.setAbsolutePosition(h);const d=r.getAbsolutePosition();if(l.x===d.x&&l.y===d.y)return;if("rotater"===this._movingAnchorName){const s=this._getNodeRect();e=r.x()-s.width/2,n=-r.y()+s.height/2;let a=Math.atan2(-n,e)+Math.PI/2;s.height<0&&(a-=Math.PI);const o=i.getAngle(this.rotation())+a,h=i.getAngle(this.rotationSnapTolerance()),l=function(t,e,n){let s=e;for(let r=0;rt.x?-1:1,a=this.findOne(".top-left").y()>t.y?-1:1;e=s*this.cos*i,n=s*this.sin*a,this.findOne(".top-left").x(t.x-e),this.findOne(".top-left").y(t.y-n)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(r.y());else if("top-right"===this._movingAnchorName){if(g){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};s=Math.sqrt(Math.pow(r.x()-t.x,2)+Math.pow(t.y-r.y(),2));const i=this.findOne(".top-right").x()t.y?-1:1;e=s*this.cos*i,n=s*this.sin*a,this.findOne(".top-right").x(t.x+e),this.findOne(".top-right").y(t.y-n)}var f=r.position();this.findOne(".top-left").y(f.y),this.findOne(".bottom-right").x(f.x)}else if("middle-left"===this._movingAnchorName)this.findOne(".top-left").x(r.x());else if("middle-right"===this._movingAnchorName)this.findOne(".bottom-right").x(r.x());else if("bottom-left"===this._movingAnchorName){if(g){const t=u?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};s=Math.sqrt(Math.pow(t.x-r.x(),2)+Math.pow(r.y()-t.y,2));const i=t.x{var i;e._fire("transformend",{evt:t,target:e}),null===(i=e.getLayer())||void 0===i||i.batchDraw()})),this._movingAnchorName=null}}_fitNodesInto(t,e){const n=this._getNodeRect();if(g._inRange(t.width,2*-this.padding()-1,1))return void this.update();if(g._inRange(t.height,2*-this.padding()-1,1))return void this.update();const r=new s;if(r.rotate(i.getAngle(this.rotation())),this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("left")>=0){const e=r.point({x:2*-this.padding(),y:0});t.x+=e.x,t.y+=e.y,t.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y}else if(this._movingAnchorName&&t.width<0&&this._movingAnchorName.indexOf("right")>=0){const e=r.point({x:2*this.padding(),y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.width+=2*this.padding()}if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("top")>=0){const e=r.point({x:0,y:2*-this.padding()});t.x+=e.x,t.y+=e.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}else if(this._movingAnchorName&&t.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const e=r.point({x:0,y:2*this.padding()});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=e.x,this._anchorDragOffset.y-=e.y,t.height+=2*this.padding()}if(this.boundBoxFunc()){const e=this.boundBoxFunc()(n,t);e?t=e:g.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const a=1e7,o=new s;o.translate(n.x,n.y),o.rotate(n.rotation),o.scale(n.width/a,n.height/a);const h=new s,l=t.width/a,d=t.height/a;!1===this.flipEnabled()?(h.translate(t.x,t.y),h.rotate(t.rotation),h.translate(t.width<0?t.width:0,t.height<0?t.height:0),h.scale(Math.abs(l),Math.abs(d))):(h.translate(t.x,t.y),h.rotate(t.rotation),h.scale(l,d));const c=h.multiply(o.invert());this._nodes.forEach((t=>{var e;const i=t.getParent().getAbsoluteTransform(),n=t.getTransform().copy();n.translate(t.offsetX(),t.offsetY());const r=new s;r.multiply(i.copy().invert()).multiply(c).multiply(i).multiply(n);const a=r.decompose();t.setAttrs(a),null===(e=t.getLayer())||void 0===e||e.batchDraw()})),this.rotation(g._getRotation(t.rotation)),this._nodes.forEach((t=>{this._fire("transform",{evt:e,target:t}),t._fire("transform",{evt:e,target:t})})),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(t,e){this.findOne(t).setAttrs(e)}update(){var t;const e=this._getNodeRect();this.rotation(g._getRotation(e.rotation));const i=e.width,n=e.height,s=this.enabledAnchors(),r=this.resizeEnabled(),a=this.padding(),o=this.anchorSize(),h=this.find("._anchor");h.forEach((t=>{t.setAttrs({width:o,height:o,offsetX:o/2,offsetY:o/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})})),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:o/2+a,offsetY:o/2+a,visible:r&&s.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:i/2,y:0,offsetY:o/2+a,visible:r&&s.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:i,y:0,offsetX:o/2-a,offsetY:o/2+a,visible:r&&s.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:n/2,offsetX:o/2+a,visible:r&&s.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:i,y:n/2,offsetX:o/2-a,visible:r&&s.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:n,offsetX:o/2+a,offsetY:o/2-a,visible:r&&s.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:i/2,y:n,offsetY:o/2-a,visible:r&&s.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:i,y:n,offsetX:o/2-a,offsetY:o/2-a,visible:r&&s.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:i/2,y:-this.rotateAnchorOffset()*g._sign(n)-a,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:i,height:n,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const l=this.anchorStyleFunc();l&&h.forEach((t=>{l(t)})),null===(t=this.getLayer())||void 0===t||t.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const t=this.findOne("."+this._movingAnchorName);t&&t.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),Wt.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return q.prototype.toObject.call(this)}clone(t){return q.prototype.clone.call(this,t)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}ni.isTransforming=()=>ii>0,ni.prototype.className="Transformer",n(ni),E.addGetterSetter(ni,"enabledAnchors",Ze,(function(t){return t instanceof Array||g.warn("enabledAnchors value should be an array"),t instanceof Array&&t.forEach((function(t){-1===Ze.indexOf(t)&&g.warn("Unknown anchor name: "+t+". Available names are: "+Ze.join(", "))})),t||[]})),E.addGetterSetter(ni,"flipEnabled",!0,M()),E.addGetterSetter(ni,"resizeEnabled",!0),E.addGetterSetter(ni,"anchorSize",10,C()),E.addGetterSetter(ni,"rotateEnabled",!0),E.addGetterSetter(ni,"rotateLineVisible",!0),E.addGetterSetter(ni,"rotationSnaps",[]),E.addGetterSetter(ni,"rotateAnchorOffset",50,C()),E.addGetterSetter(ni,"rotateAnchorCursor","crosshair"),E.addGetterSetter(ni,"rotationSnapTolerance",5,C()),E.addGetterSetter(ni,"borderEnabled",!0),E.addGetterSetter(ni,"anchorStroke","rgb(0, 161, 255)"),E.addGetterSetter(ni,"anchorStrokeWidth",1,C()),E.addGetterSetter(ni,"anchorFill","white"),E.addGetterSetter(ni,"anchorCornerRadius",0,C()),E.addGetterSetter(ni,"borderStroke","rgb(0, 161, 255)"),E.addGetterSetter(ni,"borderStrokeWidth",1,C()),E.addGetterSetter(ni,"borderDash"),E.addGetterSetter(ni,"keepRatio",!0),E.addGetterSetter(ni,"shiftBehavior","default"),E.addGetterSetter(ni,"centeredScaling",!1),E.addGetterSetter(ni,"ignoreStroke",!1),E.addGetterSetter(ni,"padding",0,C()),E.addGetterSetter(ni,"nodes"),E.addGetterSetter(ni,"node"),E.addGetterSetter(ni,"boundBoxFunc"),E.addGetterSetter(ni,"anchorDragBoundFunc"),E.addGetterSetter(ni,"anchorStyleFunc"),E.addGetterSetter(ni,"shouldOverdrawWholeArea",!1),E.addGetterSetter(ni,"useSingleNodeRotation",!0),E.backCompat(ni,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});class si extends Ft{_sceneFunc(t){t.beginPath(),t.arc(0,0,this.radius(),0,i.getAngle(this.angle()),this.clockwise()),t.lineTo(0,0),t.closePath(),t.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(t){this.radius(t/2)}setHeight(t){this.radius(t/2)}}function ri(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}si.prototype.className="Wedge",si.prototype._centroid=!0,si.prototype._attrsAffectingSize=["radius"],n(si),E.addGetterSetter(si,"radius",0,C()),E.addGetterSetter(si,"angle",0,C()),E.addGetterSetter(si,"clockwise",!1),E.backCompat(si,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});const ai=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],oi=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];E.addGetterSetter(q,"blurRadius",0,C(),E.afterSetFilter);E.addGetterSetter(q,"brightness",0,C(),E.afterSetFilter);E.addGetterSetter(q,"contrast",0,C(),E.afterSetFilter);function hi(t,e,i,n,s){const r=i-e,a=s-n;if(0===r)return n+a/2;if(0===a)return n;let o=(t-e)/r;return o=a*o+n,o}E.addGetterSetter(q,"embossStrength",.5,C(),E.afterSetFilter),E.addGetterSetter(q,"embossWhiteLevel",.5,C(),E.afterSetFilter),E.addGetterSetter(q,"embossDirection","top-left",void 0,E.afterSetFilter),E.addGetterSetter(q,"embossBlend",!1,void 0,E.afterSetFilter);E.addGetterSetter(q,"enhance",0,C(),E.afterSetFilter);E.addGetterSetter(q,"hue",0,C(),E.afterSetFilter),E.addGetterSetter(q,"saturation",0,C(),E.afterSetFilter),E.addGetterSetter(q,"luminance",0,C(),E.afterSetFilter);E.addGetterSetter(q,"hue",0,C(),E.afterSetFilter),E.addGetterSetter(q,"saturation",0,C(),E.afterSetFilter),E.addGetterSetter(q,"value",0,C(),E.afterSetFilter);function li(t,e,i){let n=4*(i*t.width+e);const s=[];return s.push(t.data[n++],t.data[n++],t.data[n++],t.data[n++]),s}function di(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}E.addGetterSetter(q,"kaleidoscopePower",2,C(),E.afterSetFilter),E.addGetterSetter(q,"kaleidoscopeAngle",0,C(),E.afterSetFilter);E.addGetterSetter(q,"threshold",0,C(),E.afterSetFilter);E.addGetterSetter(q,"noise",.2,C(),E.afterSetFilter);E.addGetterSetter(q,"pixelSize",8,C(),E.afterSetFilter);E.addGetterSetter(q,"levels",.5,C(),E.afterSetFilter);E.addGetterSetter(q,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),E.addGetterSetter(q,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),E.addGetterSetter(q,"blue",0,w,E.afterSetFilter);E.addGetterSetter(q,"red",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),E.addGetterSetter(q,"green",0,(function(t){return this._filterUpToDate=!1,t>255?255:t<0?0:Math.round(t)})),E.addGetterSetter(q,"blue",0,w,E.afterSetFilter),E.addGetterSetter(q,"alpha",1,(function(t){return this._filterUpToDate=!1,t>1?1:t<0?0:t}));E.addGetterSetter(q,"threshold",.5,C(),E.afterSetFilter);return Jt.Util._assign(Jt,{Arc:$t,Arrow:ce,Circle:ge,Ellipse:ue,Image:fe,Label:be,Tag:Se,Line:ee,Path:de,Rect:we,RegularPolygon:Ce,Ring:ke,Sprite:Ae,Star:Te,Text:We,TextPath:qe,Transformer:ni,Wedge:si,Filters:{Blur:function(t){const e=Math.round(this.blurRadius());e>0&&function(t,e){const i=t.data,n=t.width,s=t.height;let r,a,o,h,l,d,c,g,u,f,p,m,_,y,v,x,b,S,w,C;const P=e+e+1,k=n-1,A=s-1,T=e+1,M=T*(T+1)/2,G=new ri,R=ai[e],E=oi[e];let D=null,L=G,O=null,I=null;for(let t=1;t>E,0!==w?(w=255/w,i[a]=(h*R>>E)*w,i[a+1]=(l*R>>E)*w,i[a+2]=(d*R>>E)*w):i[a]=i[a+1]=i[a+2]=0,h-=g,l-=u,d-=f,c-=p,g-=O.r,u-=O.g,f-=O.b,p-=O.a,r=o+((r=t+e+1)>E,w>0?(w=255/w,i[r]=(h*R>>E)*w,i[r+1]=(l*R>>E)*w,i[r+2]=(d*R>>E)*w):i[r]=i[r+1]=i[r+2]=0,h-=g,l-=u,d-=f,c-=p,g-=O.r,u-=O.g,f-=O.b,p-=O.a,r=t+((r=e+T)255?255:s,r=r<0?0:r>255?255:r,a=a<0?0:a>255?255:a,i[t]=s,i[t+1]=r,i[t+2]=a},Emboss:function(t){const e=10*this.embossStrength(),i=255*this.embossWhiteLevel(),n=this.embossDirection(),s=this.embossBlend(),r=t.data,a=t.width,o=t.height,h=4*a;let l=0,d=0,c=o;switch(n){case"top-left":l=-1,d=-1;break;case"top":l=-1,d=0;break;case"top-right":l=-1,d=1;break;case"right":l=0,d=1;break;case"bottom-right":l=1,d=1;break;case"bottom":l=1,d=0;break;case"bottom-left":l=1,d=-1;break;case"left":l=0,d=-1;break;default:g.error("Unknown emboss direction: "+n)}do{const t=(c-1)*h;let n=l;c+n<1&&(n=0),c+n>o&&(n=0);const g=(c-1+n)*a*4;let u=a;do{const n=t+4*(u-1);let o=d;u+o<1&&(o=0),u+o>a&&(o=0);const h=g+4*(u-1+o),l=r[n]-r[h],c=r[n+1]-r[h+1],f=r[n+2]-r[h+2];let p=l;const m=p>0?p:-p;if((c>0?c:-c)>m&&(p=c),(f>0?f:-f)>m&&(p=f),p*=e,s){const t=r[n]+p,e=r[n+1]+p,i=r[n+2]+p;r[n]=t>255?255:t<0?0:t,r[n+1]=e>255?255:e<0?0:e,r[n+2]=i>255?255:i<0?0:i}else{let t=i-p;t<0?t=0:t>255&&(t=255),r[n]=r[n+1]=r[n+2]=t}}while(--u)}while(--c)},Enhance:function(t){const e=t.data,i=e.length;let n,s,r,a=e[0],o=a,h=e[1],l=h,d=e[2],c=d;const g=this.enhance();if(0===g)return;for(let t=0;to&&(o=n),s=e[t+1],sl&&(l=s),r=e[t+2],rc&&(c=r);let u,f,p,m,_,y;if(o===a&&(o=255,a=0),l===h&&(l=255,h=0),c===d&&(c=255,d=0),g>0)u=o+g*(255-o),f=a-g*(a-0),p=l+g*(255-l),m=h-g*(h-0),_=c+g*(255-c),y=d-g*(d-0);else{const t=.5*(o+a);u=o+g*(o-t),f=a+g*(a-t);const e=.5*(l+h);p=l+g*(l-e),m=h+g*(h-e);const i=.5*(c+d);_=c+g*(c-i),y=d+g*(d-i)}for(let t=0;tl?g:l;const u=a,f=r,p=360/f*Math.PI/180;for(let t=0;te&&(b=x,S=0,w=-1),s=0;sl?g:l;const u=a,f=r;let p,m;for(d=0;d=0&&c=0&&g=0&&c=0&&g=1020?255:0}return a}(e,t.width,t.height),e=function(t,e,i){const n=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],s=Math.round(Math.sqrt(n.length)),r=Math.floor(s/2),a=[];for(let o=0;o=0&&c=0&&g=i))for(let e=g;e=n)continue;const s=4*(i*e+t);r+=a[s+0],o+=a[s+1],h+=a[s+2],l+=a[s+3],f+=1}r/=f,o/=f,h/=f,l/=f;for(let t=d;t=i))for(let e=g;e=n)continue;const s=4*(i*e+t);a[s+0]=r,a[s+1]=o,a[s+2]=h,a[s+3]=l}}},Posterize:function(t){const e=Math.round(254*this.levels())+1,i=t.data,n=i.length,s=255/e;for(let t=0;t127&&(n=255-n),s>127&&(s=255-s),a>127&&(a=255-a),e[i]=n,e[i+1]=s,e[i+2]=a}while(--r)}while(--s)},Threshold:function(t){const e=255*this.threshold(),i=t.data,n=i.length;for(let t=0;t{var St=Object.defineProperty;var Wa=Object.getOwnPropertyDescriptor;var Ka=Object.getOwnPropertyNames;var qa=Object.prototype.hasOwnProperty;var Ha=(r,t)=>{for(var e in t)St(r,e,{get:t[e],enumerable:!0})},$a=(r,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ka(t))!qa.call(r,a)&&a!==e&&St(r,a,{get:()=>t[a],enumerable:!(o=Wa(t,a))||o.enumerable});return r};var za=r=>$a(St({},"__esModule",{value:!0}),r);var Ll={};Ha(Ll,{chunk:()=>Et,clamp:()=>Mt,cloneDeep:()=>jt,debounce:()=>Lr,get:()=>Mr,groupBy:()=>Bt,keyBy:()=>Ft,meanBy:()=>Rt,merge:()=>Nt,omit:()=>Dt,orderBy:()=>Gt,pick:()=>Ut,range:()=>Wt,round:()=>Kt,set:()=>qt,sortBy:()=>Ht,sumBy:()=>$t,throttle:()=>zt,uniq:()=>Yt,uniqBy:()=>Xt});var Ya=typeof global=="object"&&global&&global.Object===Object&&global,Nr=Ya;var Xa=typeof self=="object"&&self&&self.Object===Object&&self,Za=Nr||Xa||Function("return this")(),h=Za;var Ja=h.Symbol,_=Ja;var Jt=Object.prototype,Qa=Jt.hasOwnProperty,Va=Jt.toString,Pr=_?_.toStringTag:void 0;function ka(r){var t=Qa.call(r,Pr),e=r[Pr];try{r[Pr]=void 0;var o=!0}catch{}var a=Va.call(r);return o&&(t?r[Pr]=e:delete r[Pr]),a}var Qt=ka;var rf=Object.prototype,tf=rf.toString;function ef(r){return tf.call(r)}var Vt=ef;var of="[object Null]",af="[object Undefined]",kt=_?_.toStringTag:void 0;function ff(r){return r==null?r===void 0?af:of:kt&&kt in Object(r)?Qt(r):Vt(r)}var w=ff;function nf(r){return r!=null&&typeof r=="object"}var O=nf;var pf="[object Symbol]";function mf(r){return typeof r=="symbol"||O(r)&&w(r)==pf}var j=mf;function uf(r,t){for(var e=-1,o=r==null?0:r.length,a=Array(o);++e0){if(++t>=Vf)return arguments[0]}else t=0;return r.apply(void 0,arguments)}}var ge=tn;function en(r){return function(){return r}}var he=en;var on=(function(){try{var r=I(Object,"defineProperty");return r({},"",{}),r}catch{}})(),sr=on;var an=sr?function(r,t){return sr(r,"toString",{configurable:!0,enumerable:!1,value:he(t),writable:!0})}:V,ye=an;var fn=ge(ye),Kr=fn;function nn(r,t){for(var e=-1,o=r==null?0:r.length;++e-1}var _e=ln;var dn=9007199254740991,cn=/^(?:0|[1-9]\d*)$/;function xn(r,t){var e=typeof r;return t=t??dn,!!t&&(e=="number"||e!="symbol"&&cn.test(r))&&r>-1&&r%1==0&&r-1&&r%1==0&&r<=_n}var dr=Sn;function In(r){return r!=null&&dr(r.length)&&!ur(r)}var E=In;function wn(r,t,e){if(!c(e))return!1;var o=typeof t;return(o=="number"?E(e)&&k(t,e.length):o=="string"&&t in e)?R(e[t],r):!1}var q=wn;function Pn(r){return Hr(function(t,e){var o=-1,a=e.length,f=a>1?e[a-1]:void 0,n=a>2?e[2]:void 0;for(f=r.length>3&&typeof f=="function"?(a--,f):void 0,n&&q(e[0],e[1],n)&&(f=a<3?void 0:f,a=1),t=Object(t);++o-1}var Xe=Qi;function Vi(r,t){var e=this.__data__,o=tr(e,r);return o<0?(++this.size,e.push([r,t])):e[o][1]=t,this}var Ze=Vi;function yr(r){var t=-1,e=r==null?0:r.length;for(this.clear();++t0&&e(i)?t>1?io(i,t-1,e,o,a):vr(a,i):o||(a[a.length]=i)}return a}var Yr=io;function Ap(r){var t=r==null?0:r.length;return t?Yr(r,1):[]}var po=Ap;function Tp(r){return Kr(qr(r,void 0,po),r+"")}var Xr=Tp;var Op=zr(Object.getPrototypeOf,Object),Ar=Op;var _p="[object Object]",Sp=Function.prototype,Ip=Object.prototype,mo=Sp.toString,wp=Ip.hasOwnProperty,Pp=mo.call(Object);function Cp(r){if(!O(r)||w(r)!=_p)return!1;var t=Ar(r);if(t===null)return!0;var e=wp.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&mo.call(e)==Pp}var Zr=Cp;function Ep(r,t,e){var o=-1,a=r.length;t<0&&(t=-t>a?0:a+t),e=e>a?a:e,e<0&&(e+=a),a=t>e?0:e-t>>>0,t>>>=0;for(var f=Array(a);++o=t?r:t)),r}var so=Np;function Dp(r,t,e){return e===void 0&&(e=t,t=void 0),e!==void 0&&(e=L(e),e=e===e?e:0),t!==void 0&&(t=L(t),t=t===t?t:0),so(L(r),t,e)}var Mt=Dp;function Gp(){this.__data__=new er,this.size=0}var lo=Gp;function Up(r){var t=this.__data__,e=t.delete(r);return this.size=t.size,e}var co=Up;function Wp(r){return this.__data__.get(r)}var xo=Wp;function Kp(r){return this.__data__.has(r)}var go=Kp;var qp=200;function Hp(r,t){var e=this.__data__;if(e instanceof er){var o=e.__data__;if(!or||o.lengthi))return!1;var m=f.get(r),u=f.get(t);if(m&&u)return m==t&&u==r;var s=-1,l=!0,y=e&Bu?new mt:void 0;for(f.set(r,t),f.set(t,r);++s=t||J<0||s&&wr>=f}function v(){var T=vt();if(b(T))return B(T);i=setTimeout(v,S(T))}function B(T){return i=void 0,l&&o?y(T):(o=a=void 0,n)}function Rr(){i!==void 0&&clearTimeout(i),m=0,o=p=a=i=void 0}function pr(){return i===void 0?n:B(vt())}function Z(){var T=vt(),J=b(T);if(o=arguments,a=this,p=T,J){if(i===void 0)return A(p);if(s)return clearTimeout(i),i=setTimeout(v,t),y(p)}return i===void 0&&(i=setTimeout(v,t)),n}return Z.cancel=Rr,Z.flush=pr,Z}var Lr=Bs;function Fs(r,t,e){(e!==void 0&&!R(r[t],e)||e===void 0&&!(t in r))&&F(r,t,e)}var Br=Fs;function Rs(r){return O(r)&&E(r)}var Aa=Rs;function Ns(r,t){if(!(t==="constructor"&&typeof r[t]=="function")&&t!="__proto__")return r[t]}var Fr=Ns;function Ds(r){return C(r,D(r))}var Ta=Ds;function Gs(r,t,e,o,a,f,n){var i=Fr(r,e),p=Fr(t,e),m=n.get(p);if(m){Br(r,e,m);return}var u=f?f(i,p,e+"",r,t,n):void 0,s=u===void 0;if(s){var l=d(p),y=!l&&$(p),A=!l&&!y&&xr(p);u=p,l||y||A?d(i)?u=i:Aa(i)?u=Wr(i):y?(s=!1,u=Qr(p,!0)):A?(s=!1,u=at(p,!0)):u=[]:Zr(p)||H(p)?(u=i,H(i)?u=Ta(i):(!c(i)||ur(i))&&(u=ft(p))):s=!1}s&&(n.set(p,u),a(u,p,o,f,n),n.delete(p)),Br(r,e,u)}var Oa=Gs;function _a(r,t,e,o,a){r!==t&&ht(t,function(f,n){if(a||(a=new U),c(f))Oa(r,t,n,e,_a,o,a);else{var i=o?o(Fr(r,n),f,n+"",r,t,a):void 0;i===void 0&&(i=f),Br(r,n,i)}},D)}var Sa=_a;function Us(r,t,e){for(var o=-1,a=r==null?0:r.length;++o1),f}),C(r,tt(r),e),o&&(e=it(e,ol|al|fl,ja));for(var a=t.length;a--;)Ma(e,t[a]);return e}),Dt=nl;function il(r,t,e,o){if(!c(r))return r;t=M(t,r);for(var a=-1,f=t.length,n=f-1,i=r;i!=null&&++at||f&&n&&p&&!i&&!m||o&&n&&p||!e&&p||!a)return 1;if(!o&&!f&&!m&&r=i)return p;var m=e[o];return p*(m=="desc"?-1:1)}}return r.index-t.index}var Ra=sl;function ll(r,t,e){t.length?t=Q(t,function(f){return d(f)?function(n){return G(n,f.length===1?f[0]:f)}:f}):t=[V];var o=-1;t=Q(t,rr(W));var a=Pa(r,function(f,n,i){var p=Q(t,function(m){return m(f)});return{criteria:p,index:++o,value:f}});return Ba(a,function(f,n){return Ra(f,n,e)})}var Ot=ll;function dl(r,t,e,o){return r==null?[]:(d(t)||(t=t==null?[]:[t]),e=o?void 0:e,d(e)||(e=e==null?[]:[e]),Ot(r,t,e))}var Gt=dl;function cl(r,t){return La(r,t,function(e,o){return gt(r,o)})}var Na=cl;var xl=Xr(function(r,t){return r==null?{}:Na(r,t)}),Ut=xl;var gl=Math.ceil,hl=Math.max;function yl(r,t,e,o){for(var a=-1,f=hl(gl((t-r)/(e||1)),0),n=Array(f);f--;)n[o?f:++a]=r,r+=e;return n}var Da=yl;function bl(r){return function(t,e,o){return o&&typeof o!="number"&&q(t,e,o)&&(e=o=void 0),t=mr(t),e===void 0?(e=t,t=0):e=mr(e),o=o===void 0?t1&&q(r,t[0],t[1])?t=[]:e>2&&q(t[0],t[1],t[2])&&(t=[t[0]]),Ot(r,Yr(t,1),[])}),Ht=Ol;function _l(r,t){return r&&r.length?At(r,W(t,2)):0}var $t=_l;var Sl="Expected a function";function Il(r,t,e){var o=!0,a=!0;if(typeof r!="function")throw new TypeError(Sl);return c(e)&&(o="leading"in e?!!e.leading:o,a="trailing"in e?!!e.trailing:a),Lr(r,t,{leading:o,maxWait:t,trailing:a})}var zt=Il;var wl=1/0,Pl=fr&&1/Ir(new fr([,-0]))[1]==wl?function(r){return new fr(r)}:xe,Ua=Pl;var Cl=200;function El(r,t,e){var o=-1,a=_e,f=r.length,n=!0,i=[],p=i;if(e)n=!1,a=Ia;else if(f>=Cl){var m=t?null:Ua(r);if(m)return Ir(m);n=!1,a=ut,p=new mt}else p=t?[]:i;r:for(;++o + * Build: `lodash modularize exports="es" --repo lodash/lodash#4.18.1 -o ./` + * Copyright OpenJS Foundation and other contributors + * Released under MIT license + * Based on Underscore.js 1.8.3 + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + *) +*/ diff --git a/android/app/src/main/assets/pulsewall/libs/manifest.json b/android/app/src/main/assets/pulsewall/libs/manifest.json new file mode 100644 index 0000000..3f66989 --- /dev/null +++ b/android/app/src/main/assets/pulsewall/libs/manifest.json @@ -0,0 +1,128 @@ +{ + "plyr": { + "global": "Plyr", + "category": "media-player", + "js": { + "file": "plyr.min.js", + "raw_kb": 111.3, + "gzip_kb": 32.5 + }, + "css": { + "file": "plyr.css", + "raw_kb": 31.8, + "gzip_kb": 5 + }, + "note": "首选轻量无依赖播放器 UI,配合 hls 播放 m3u8 直播/点播" + }, + "hls": { + "global": "Hls", + "category": "streaming", + "js": { + "file": "hls.light.min.js", + "raw_kb": 379.8, + "gzip_kb": 117.3 + }, + "note": "HLS (m3u8) 离线精简版流媒体引擎" + }, + "echarts": { + "global": "echarts", + "category": "charts", + "heavy": true, + "js": { + "file": "echarts.custom.min.js", + "raw_kb": 610.5, + "gzip_kb": 203.1 + }, + "note": "按需裁剪版 ECharts(含折线/柱状/饼图/仪表盘/雷达/散点 + CanvasRenderer),仅在需要复杂图表时按需加载" + }, + "konva": { + "global": "Konva", + "category": "canvas-2d", + "js": { + "file": "konva.min.js", + "raw_kb": 171.2, + "gzip_kb": 50 + }, + "note": "2D 交互画布引擎,适合矢量对象编排与实时动效看板" + }, + "three": { + "global": "THREE", + "category": "canvas-3d", + "heavy": true, + "js": { + "file": "three.min.js", + "raw_kb": 669, + "gzip_kb": 170.9 + }, + "note": "Three.js 3D 渲染库,体积较大,机顶盒/低端 GPU 慎用,仅明确需要 3D 时加载" + }, + "rough": { + "global": "rough", + "category": "sketch", + "js": { + "file": "rough.min.js", + "raw_kb": 27.3, + "gzip_kb": 9.2 + }, + "note": "手绘风格 Canvas/SVG 绘制库(超轻量 <9KB)" + }, + "tailwind": { + "category": "css", + "css": { + "file": "tailwind-lite.min.css", + "raw_kb": 4.7, + "gzip_kb": 1.6 + }, + "note": "离线预编译 Tailwind 实用工具类 CSS(零 JS 运行时开销,Android 11 WebView 兼容)" + }, + "dayjs": { + "global": "dayjs", + "category": "datetime", + "js": { + "file": "dayjs.min.js", + "raw_kb": 7, + "gzip_kb": 3 + }, + "note": "超轻量日期时间格式化与计算库(~2KB)" + }, + "lodash": { + "global": "_", + "category": "utils", + "js": { + "file": "lodash-lite.min.js", + "raw_kb": 32.2, + "gzip_kb": 12.1 + }, + "note": "按需 Tree-Shaking 的 lodash-es 常用工具函数集(window._)" + }, + "zustand": { + "global": "Zustand", + "category": "state", + "js": { + "file": "zustand.min.js", + "raw_kb": 0.8, + "gzip_kb": 0.5 + }, + "note": "极简跨组件状态共享库(window.Zustand.createStore,~1KB)" + }, + "anime": { + "global": "anime", + "category": "animation", + "js": { + "file": "anime.min.js", + "raw_kb": 17, + "gzip_kb": 6.9 + }, + "note": "轻量动效库(仅在 CSS 动画不够用时按需引入)" + }, + "icons": { + "global": "PwIcons", + "category": "icons", + "js": { + "file": "pw-icons.min.js", + "raw_kb": 2.3, + "gzip_kb": 1.2 + }, + "note": "超轻量离线 SVG 图标运行时(<2KB,支持 PwIcons.svg(\"cpu\", 20) 或 data-pw-icon 属性)" + } +} \ No newline at end of file diff --git a/android/app/src/main/assets/pulsewall/libs/plyr.css b/android/app/src/main/assets/pulsewall/libs/plyr.css new file mode 100644 index 0000000..6924c2c --- /dev/null +++ b/android/app/src/main/assets/pulsewall/libs/plyr.css @@ -0,0 +1 @@ +@charset "UTF-8";@keyframes plyr-progress{to{background-position:25px 0;background-position:var(--plyr-progress-loading-size,25px) 0}}@keyframes plyr-popup{0%{opacity:.5;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes plyr-fade-in{0%{opacity:0}to{opacity:1}}.plyr{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;align-items:center;direction:ltr;display:flex;flex-direction:column;font-family:inherit;font-family:var(--plyr-font-family,inherit);font-variant-numeric:tabular-nums;font-weight:400;font-weight:var(--plyr-font-weight-regular,400);line-height:1.7;line-height:var(--plyr-line-height,1.7);max-width:100%;min-width:200px;position:relative;text-shadow:none;transition:box-shadow .3s ease;z-index:0}.plyr audio,.plyr iframe,.plyr video{display:block;height:100%;width:100%}.plyr button{font:inherit;line-height:inherit;width:auto}.plyr:focus{outline:0}.plyr--full-ui{box-sizing:border-box}.plyr--full-ui *,.plyr--full-ui :after,.plyr--full-ui :before{box-sizing:inherit}.plyr--full-ui a,.plyr--full-ui button,.plyr--full-ui input,.plyr--full-ui label{touch-action:manipulation}.plyr__badge{background:#4a5464;background:var(--plyr-badge-background,#4a5464);border-radius:2px;border-radius:var(--plyr-badge-border-radius,2px);color:#fff;color:var(--plyr-badge-text-color,#fff);font-size:9px;font-size:var(--plyr-font-size-badge,9px);line-height:1;padding:3px 4px}.plyr--full-ui ::-webkit-media-text-track-container{display:none}.plyr__captions{animation:plyr-fade-in .3s ease;bottom:0;display:none;font-size:13px;font-size:var(--plyr-font-size-small,13px);left:0;padding:10px;padding:var(--plyr-control-spacing,10px);position:absolute;text-align:center;transition:transform .4s ease-in-out;width:100%}.plyr__captions span:empty{display:none}@media (min-width:480px){.plyr__captions{font-size:15px;font-size:var(--plyr-font-size-base,15px);padding:20px;padding:calc(2 * var(--plyr-control-spacing, 10px))}}@media (min-width:768px){.plyr__captions{font-size:18px;font-size:var(--plyr-font-size-large,18px)}}.plyr--captions-active .plyr__captions{display:block}.plyr:not(.plyr--hide-controls) .plyr__controls:not(:empty)~.plyr__captions{transform:translateY(calc(-40px));transform:translateY(calc(-4 * var(--plyr-control-spacing, 10px)))}.plyr__caption{background:#000c;background:var(--plyr-captions-background,#000c);border-radius:4px;-webkit-box-decoration-break:clone;box-decoration-break:clone;color:#fff;color:var(--plyr-captions-text-color,#fff);line-height:185%;padding:.2em .5em;white-space:pre-wrap}.plyr__caption div{display:inline}.plyr__control{background:#0000;border:0;border-radius:4px;border-radius:var(--plyr-control-radius,4px);color:inherit;cursor:pointer;flex-shrink:0;overflow:visible;padding:7px;padding:calc(.7 * var(--plyr-control-spacing, 10px));position:relative;transition:all .1s ease-in-out}.plyr__control svg{display:block;fill:currentColor;height:18px;height:var(--plyr-control-icon-size,18px);pointer-events:none;width:18px;width:var(--plyr-control-icon-size,18px)}.plyr__control:focus{outline:0}.plyr__control:focus-visible{outline:2px dashed #00b2ff;outline:2px dashed var(--plyr-focus-visible-color,var(--plyr-color-main,var(--plyr-color-main,#00b2ff)));outline-offset:2px}a.plyr__control{text-decoration:none}.plyr__control.plyr__control--pressed .icon--not-pressed,.plyr__control.plyr__control--pressed .label--not-pressed,.plyr__control:not(.plyr__control--pressed) .icon--pressed,.plyr__control:not(.plyr__control--pressed) .label--pressed,a.plyr__control:after,a.plyr__control:before{display:none}.plyr--full-ui ::-webkit-media-controls{display:none}.plyr__controls{align-items:center;display:flex;justify-content:flex-end;text-align:center}.plyr__controls .plyr__progress__container{flex:1;min-width:0}.plyr__controls .plyr__controls__item{margin-left:2.5px;margin-left:calc(.25 * var(--plyr-control-spacing, 10px))}.plyr__controls .plyr__controls__item:first-child{margin-left:0;margin-right:auto}.plyr__controls .plyr__controls__item.plyr__progress__container{padding-left:2.5px;padding-left:calc(.25 * var(--plyr-control-spacing, 10px))}.plyr__controls .plyr__controls__item.plyr__time{padding:0 5px;padding:0 calc(.5 * var(--plyr-control-spacing, 10px))}.plyr__controls .plyr__controls__item.plyr__progress__container:first-child,.plyr__controls .plyr__controls__item.plyr__time+.plyr__time,.plyr__controls .plyr__controls__item.plyr__time:first-child{padding-left:0}.plyr [data-plyr=airplay],.plyr [data-plyr=captions],.plyr [data-plyr=fullscreen],.plyr [data-plyr=pip],.plyr__controls:empty{display:none}.plyr--airplay-supported [data-plyr=airplay],.plyr--captions-enabled [data-plyr=captions],.plyr--fullscreen-enabled [data-plyr=fullscreen],.plyr--pip-supported [data-plyr=pip]{display:inline-block}.plyr__menu{display:flex;position:relative}.plyr__menu .plyr__control svg{transition:transform .3s ease}.plyr__menu .plyr__control[aria-expanded=true] svg{transform:rotate(90deg)}.plyr__menu .plyr__control[aria-expanded=true] .plyr__tooltip{display:none}.plyr__menu__container{animation:plyr-popup .2s ease;background:#ffffffe6;background:var(--plyr-menu-background,#ffffffe6);border-radius:8px;border-radius:var(--plyr-menu-radius,8px);bottom:100%;box-shadow:0 1px 2px #00000026;box-shadow:var(--plyr-menu-shadow,0 1px 2px #00000026);color:#4a5464;color:var(--plyr-menu-color,#4a5464);font-size:15px;font-size:var(--plyr-font-size-base,15px);margin-bottom:10px;position:absolute;right:-3px;text-align:left;white-space:nowrap;z-index:3}.plyr__menu__container>div{overflow:hidden;transition:height .35s cubic-bezier(.4,0,.2,1),width .35s cubic-bezier(.4,0,.2,1)}.plyr__menu__container:after{border:4px solid #0000;border:var(--plyr-menu-arrow-size,4px) solid #0000;border-top-color:#ffffffe6;border-top-color:var(--plyr-menu-background,#ffffffe6);content:"";height:0;position:absolute;right:14px;right:calc(.5 * var(--plyr-control-icon-size, 18px) + .7 * var(--plyr-control-spacing, 10px) - .5 * var(--plyr-menu-arrow-size, 4px));top:100%;width:0}.plyr__menu__container [role=menu]{padding:7px;padding:calc(.7 * var(--plyr-control-spacing, 10px))}.plyr__menu__container [role=menuitem],.plyr__menu__container [role=menuitemradio]{margin-top:2px}.plyr__menu__container [role=menuitem]:first-child,.plyr__menu__container [role=menuitemradio]:first-child{margin-top:0}.plyr__menu__container .plyr__control{align-items:center;color:#4a5464;color:var(--plyr-menu-color,#4a5464);display:flex;font-size:13px;font-size:var(--plyr-font-size-menu,var(--plyr-font-size-small,13px));padding:4.66667px 10.5px;padding:calc(.46667 * var(--plyr-control-spacing, 10px)) calc(1.05 * var(--plyr-control-spacing, 10px));-webkit-user-select:none;user-select:none;width:100%}.plyr__menu__container .plyr__control>span{align-items:inherit;display:flex;width:100%}.plyr__menu__container .plyr__control:after{border:4px solid #0000;border:var(--plyr-menu-item-arrow-size,4px) solid #0000;content:"";position:absolute;top:50%;transform:translateY(-50%)}.plyr__menu__container .plyr__control--forward{padding-right:28px;padding-right:calc(2.8 * var(--plyr-control-spacing, 10px))}.plyr__menu__container .plyr__control--forward:after{border-left-color:#728197;border-left-color:var(--plyr-menu-arrow-color,#728197);right:6.5px;right:calc(1.05 * var(--plyr-control-spacing, 10px) - var(--plyr-menu-item-arrow-size, 4px))}.plyr__menu__container .plyr__control--forward:focus-visible:after,.plyr__menu__container .plyr__control--forward:hover:after{border-left-color:initial}.plyr__menu__container .plyr__control--back{font-weight:400;font-weight:var(--plyr-font-weight-regular,400);margin:7px;margin:calc(.7 * var(--plyr-control-spacing, 10px));margin-bottom:3.5px;margin-bottom:calc(.35 * var(--plyr-control-spacing, 10px));padding-left:28px;padding-left:calc(2.8 * var(--plyr-control-spacing, 10px));position:relative;width:calc(100% - 14px);width:calc(100% - 1.4 * var(--plyr-control-spacing, 10px))}.plyr__menu__container .plyr__control--back:after{border-right-color:#728197;border-right-color:var(--plyr-menu-arrow-color,#728197);left:6.5px;left:calc(1.05 * var(--plyr-control-spacing, 10px) - var(--plyr-menu-item-arrow-size, 4px))}.plyr__menu__container .plyr__control--back:before{background:#dcdfe5;background:var(--plyr-menu-back-border-color,#dcdfe5);box-shadow:0 1px 0 #fff;box-shadow:0 1px 0 var(--plyr-menu-back-border-shadow-color,#fff);content:"";height:1px;left:0;margin-top:3.5px;margin-top:calc(.35 * var(--plyr-control-spacing, 10px));overflow:hidden;position:absolute;right:0;top:100%}.plyr__menu__container .plyr__control--back:focus-visible:after,.plyr__menu__container .plyr__control--back:hover:after{border-right-color:initial}.plyr__menu__container .plyr__control[role=menuitemradio]{padding-left:7px;padding-left:calc(.7 * var(--plyr-control-spacing, 10px))}.plyr__menu__container .plyr__control[role=menuitemradio]:after,.plyr__menu__container .plyr__control[role=menuitemradio]:before{border-radius:100%}.plyr__menu__container .plyr__control[role=menuitemradio]:before{background:#0000001a;content:"";display:block;flex-shrink:0;height:16px;margin-right:10px;margin-right:var(--plyr-control-spacing,10px);transition:all .3s ease;width:16px}.plyr__menu__container .plyr__control[role=menuitemradio]:after{background:#fff;border:0;height:6px;left:12px;opacity:0;top:50%;transform:translateY(-50%) scale(0);transition:transform .3s ease,opacity .3s ease;width:6px}.plyr__menu__container .plyr__control[role=menuitemradio][aria-checked=true]:before{background:#00b2ff;background:var(--plyr-control-toggle-checked-background,var(--plyr-color-main,var(--plyr-color-main,#00b2ff)))}.plyr__menu__container .plyr__control[role=menuitemradio][aria-checked=true]:after{opacity:1;transform:translateY(-50%) scale(1)}.plyr__menu__container .plyr__control[role=menuitemradio]:focus-visible:before,.plyr__menu__container .plyr__control[role=menuitemradio]:hover:before{background:#23282f1a}.plyr__menu__container .plyr__menu__value{align-items:center;display:flex;margin-left:auto;margin-right:calc(-5px);margin-right:calc(-1 * (-2px + .7 * var(--plyr-control-spacing, 10px)));overflow:hidden;padding-left:24.5px;padding-left:calc(2.45 * var(--plyr-control-spacing, 10px));pointer-events:none}.plyr--full-ui input[type=range]{appearance:none;background:#0000;border:0;border-radius:26px;border-radius:calc(2 * var(--plyr-range-thumb-height, 13px));color:#00b2ff;color:var(--plyr-range-fill-background,var(--plyr-color-main,var(--plyr-color-main,#00b2ff)));display:block;height:19px;height:calc(2 * var(--plyr-range-thumb-active-shadow-width, 3px) + var(--plyr-range-thumb-height, 13px));margin:0;min-width:0;padding:0;transition:box-shadow .3s ease;width:100%}.plyr--full-ui input[type=range]::-webkit-slider-runnable-track{background:#0000;border:0;border-radius:2.5px;border-radius:calc(.5 * var(--plyr-range-track-height, 5px));height:5px;height:var(--plyr-range-track-height,5px);-webkit-transition:box-shadow .3s ease;transition:box-shadow .3s ease;-webkit-user-select:none;user-select:none;background-image:linear-gradient(90deg,currentColor 0,#0000);background-image:linear-gradient(to right,currentColor var(--value,0),#0000 var(--value,0))}.plyr--full-ui input[type=range]::-webkit-slider-thumb{background:#fff;background:var(--plyr-range-thumb-background,#fff);border:0;border-radius:100%;box-shadow:0 1px 1px #23282f26,0 0 0 1px #23282f33;box-shadow:var(--plyr-range-thumb-shadow,0 1px 1px #23282f26,0 0 0 1px #23282f33);height:13px;height:var(--plyr-range-thumb-height,13px);position:relative;-webkit-transition:all .2s ease;transition:all .2s ease;width:13px;width:var(--plyr-range-thumb-height,13px);appearance:none;margin-top:calc(-4px);margin-top:calc(-.5 * (var(--plyr-range-thumb-height, 13px) - var(--plyr-range-track-height, 5px)))}.plyr--full-ui input[type=range]::-moz-range-track{background:#0000;border:0;border-radius:2.5px;border-radius:calc(.5 * var(--plyr-range-track-height, 5px));height:5px;height:var(--plyr-range-track-height,5px);-moz-transition:box-shadow .3s ease;transition:box-shadow .3s ease;user-select:none}.plyr--full-ui input[type=range]::-moz-range-thumb{background:#fff;background:var(--plyr-range-thumb-background,#fff);border:0;border-radius:100%;box-shadow:0 1px 1px #23282f26,0 0 0 1px #23282f33;box-shadow:var(--plyr-range-thumb-shadow,0 1px 1px #23282f26,0 0 0 1px #23282f33);height:13px;height:var(--plyr-range-thumb-height,13px);position:relative;-moz-transition:all .2s ease;transition:all .2s ease;width:13px;width:var(--plyr-range-thumb-height,13px)}.plyr--full-ui input[type=range]::-moz-range-progress{background:currentColor;border-radius:2.5px;border-radius:calc(.5 * var(--plyr-range-track-height, 5px));height:5px;height:var(--plyr-range-track-height,5px)}.plyr--full-ui input[type=range]::-ms-track{color:#0000}.plyr--full-ui input[type=range]::-ms-fill-upper,.plyr--full-ui input[type=range]::-ms-track{background:#0000;border:0;border-radius:2.5px;border-radius:calc(.5 * var(--plyr-range-track-height, 5px));height:5px;height:var(--plyr-range-track-height,5px);-ms-transition:box-shadow .3s ease;transition:box-shadow .3s ease;user-select:none}.plyr--full-ui input[type=range]::-ms-fill-lower{background:#0000;border:0;border-radius:2.5px;border-radius:calc(.5 * var(--plyr-range-track-height, 5px));height:5px;height:var(--plyr-range-track-height,5px);-ms-transition:box-shadow .3s ease;transition:box-shadow .3s ease;user-select:none;background:currentColor}.plyr--full-ui input[type=range]::-ms-thumb{background:#fff;background:var(--plyr-range-thumb-background,#fff);border:0;border-radius:100%;box-shadow:0 1px 1px #23282f26,0 0 0 1px #23282f33;box-shadow:var(--plyr-range-thumb-shadow,0 1px 1px #23282f26,0 0 0 1px #23282f33);height:13px;height:var(--plyr-range-thumb-height,13px);position:relative;-ms-transition:all .2s ease;transition:all .2s ease;width:13px;width:var(--plyr-range-thumb-height,13px);margin-top:0}.plyr--full-ui input[type=range]::-ms-tooltip{display:none}.plyr--full-ui input[type=range]::-moz-focus-outer{border:0}.plyr--full-ui input[type=range]:focus{outline:0}.plyr--full-ui input[type=range]:focus-visible::-webkit-slider-runnable-track{outline:2px dashed #00b2ff;outline:2px dashed var(--plyr-focus-visible-color,var(--plyr-color-main,var(--plyr-color-main,#00b2ff)));outline-offset:2px}.plyr--full-ui input[type=range]:focus-visible::-moz-range-track{outline:2px dashed #00b2ff;outline:2px dashed var(--plyr-focus-visible-color,var(--plyr-color-main,var(--plyr-color-main,#00b2ff)));outline-offset:2px}.plyr--full-ui input[type=range]:focus-visible::-ms-track{outline:2px dashed #00b2ff;outline:2px dashed var(--plyr-focus-visible-color,var(--plyr-color-main,var(--plyr-color-main,#00b2ff)));outline-offset:2px}.plyr__poster{background-color:#000;background-color:var(--plyr-video-background,var(--plyr-video-background,#000));background-position:50% 50%;background-repeat:no-repeat;background-size:contain;height:100%;left:0;opacity:0;position:absolute;top:0;transition:opacity .2s ease;width:100%;z-index:1}.plyr--stopped.plyr__poster-enabled .plyr__poster{opacity:1}.plyr--youtube.plyr--paused.plyr__poster-enabled:not(.plyr--stopped) .plyr__poster{display:none}.plyr__time{font-size:13px;font-size:var(--plyr-font-size-time,var(--plyr-font-size-small,13px))}.plyr__time+.plyr__time:before{content:"⁄";margin-right:10px;margin-right:var(--plyr-control-spacing,10px)}@media (max-width:767px){.plyr__time+.plyr__time{display:none}}.plyr__tooltip{background:#fff;background:var(--plyr-tooltip-background,#fff);border-radius:5px;border-radius:var(--plyr-tooltip-radius,5px);bottom:100%;box-shadow:0 1px 2px #00000026;box-shadow:var(--plyr-tooltip-shadow,0 1px 2px #00000026);color:#4a5464;color:var(--plyr-tooltip-color,#4a5464);font-size:13px;font-size:var(--plyr-font-size-small,13px);font-weight:400;font-weight:var(--plyr-font-weight-regular,400);left:50%;line-height:1.3;margin-bottom:10px;margin-bottom:var(--plyr-control-spacing,10px);opacity:0;padding:5px 7.5px;padding:calc(.5 * var(--plyr-control-spacing, 10px)) calc(.75 * var(--plyr-control-spacing, 10px));pointer-events:none;position:absolute;transform:translate(-50%,10px) scale(.8);transform-origin:50% 100%;transition:transform .2s ease .1s,opacity .2s ease .1s;white-space:nowrap;z-index:2}.plyr__tooltip:before{border-left:4px solid #0000;border-left:var(--plyr-tooltip-arrow-size,4px) solid #0000;border-right:4px solid #0000;border-right:var(--plyr-tooltip-arrow-size,4px) solid #0000;border-top:4px solid #fff;border-top:var(--plyr-tooltip-arrow-size,4px) solid var(--plyr-tooltip-background,#fff);bottom:calc(-4px);bottom:calc(-1 * var(--plyr-tooltip-arrow-size, 4px));content:"";height:0;left:50%;position:absolute;transform:translateX(-50%);width:0;z-index:2}.plyr .plyr__control:focus-visible .plyr__tooltip,.plyr .plyr__control:hover .plyr__tooltip,.plyr__tooltip--visible{opacity:1;transform:translate(-50%) scale(1)}.plyr .plyr__control:hover .plyr__tooltip{z-index:3}.plyr__controls>.plyr__control:first-child .plyr__tooltip,.plyr__controls>.plyr__control:first-child+.plyr__control .plyr__tooltip{left:0;transform:translateY(10px) scale(.8);transform-origin:0 100%}.plyr__controls>.plyr__control:first-child .plyr__tooltip:before,.plyr__controls>.plyr__control:first-child+.plyr__control .plyr__tooltip:before{left:16px;left:calc(.5 * var(--plyr-control-icon-size, 18px) + .7 * var(--plyr-control-spacing, 10px))}.plyr__controls>.plyr__control:last-child .plyr__tooltip{left:auto;right:0;transform:translateY(10px) scale(.8);transform-origin:100% 100%}.plyr__controls>.plyr__control:last-child .plyr__tooltip:before{left:auto;right:16px;right:calc(.5 * var(--plyr-control-icon-size, 18px) + .7 * var(--plyr-control-spacing, 10px));transform:translateX(50%)}.plyr__controls>.plyr__control:first-child .plyr__tooltip--visible,.plyr__controls>.plyr__control:first-child+.plyr__control .plyr__tooltip--visible,.plyr__controls>.plyr__control:first-child+.plyr__control:focus-visible .plyr__tooltip,.plyr__controls>.plyr__control:first-child+.plyr__control:hover .plyr__tooltip,.plyr__controls>.plyr__control:first-child:focus-visible .plyr__tooltip,.plyr__controls>.plyr__control:first-child:hover .plyr__tooltip,.plyr__controls>.plyr__control:last-child .plyr__tooltip--visible,.plyr__controls>.plyr__control:last-child:focus-visible .plyr__tooltip,.plyr__controls>.plyr__control:last-child:hover .plyr__tooltip{transform:translate(0) scale(1)}.plyr__progress{left:6.5px;left:calc(.5 * var(--plyr-range-thumb-height, 13px));margin-right:13px;margin-right:var(--plyr-range-thumb-height,13px);position:relative}.plyr__progress input[type=range],.plyr__progress__buffer{margin-left:calc(-6.5px);margin-left:calc(-.5 * var(--plyr-range-thumb-height, 13px));margin-right:calc(-6.5px);margin-right:calc(-.5 * var(--plyr-range-thumb-height, 13px));width:calc(100% + 13px);width:calc(100% + var(--plyr-range-thumb-height, 13px))}.plyr__progress input[type=range]{position:relative;z-index:2}.plyr__progress .plyr__tooltip{left:0;max-width:120px;overflow-wrap:break-word}.plyr__progress__buffer{-webkit-appearance:none;background:#0000;border:0;border-radius:100px;height:5px;height:var(--plyr-range-track-height,5px);left:0;margin-top:calc(-2.5px);margin-top:calc(-.5 * var(--plyr-range-track-height, 5px));padding:0;position:absolute;top:50%}.plyr__progress__buffer::-webkit-progress-bar{background:#0000}.plyr__progress__buffer::-webkit-progress-value{background:currentColor;border-radius:100px;min-width:5px;min-width:var(--plyr-range-track-height,5px);-webkit-transition:width .2s ease;transition:width .2s ease}.plyr__progress__buffer::-moz-progress-bar{background:currentColor;border-radius:100px;min-width:5px;min-width:var(--plyr-range-track-height,5px);-moz-transition:width .2s ease;transition:width .2s ease}.plyr__progress__buffer::-ms-fill{border-radius:100px;-ms-transition:width .2s ease;transition:width .2s ease}.plyr--loading .plyr__progress__buffer{animation:plyr-progress 1s linear infinite;background-image:linear-gradient(-45deg,#23282f99 25%,#0000 0,#0000 50%,#23282f99 0,#23282f99 75%,#0000 0,#0000);background-image:linear-gradient(-45deg,var(--plyr-progress-loading-background,#23282f99) 25%,#0000 25%,#0000 50%,var(--plyr-progress-loading-background,#23282f99) 50%,var(--plyr-progress-loading-background,#23282f99) 75%,#0000 75%,#0000);background-repeat:repeat-x;background-size:25px 25px;background-size:var(--plyr-progress-loading-size,25px) var(--plyr-progress-loading-size,25px);color:#0000}.plyr--video.plyr--loading .plyr__progress__buffer{background-color:#ffffff40;background-color:var(--plyr-video-progress-buffered-background,#ffffff40)}.plyr--audio.plyr--loading .plyr__progress__buffer{background-color:#c1c8d199;background-color:var(--plyr-audio-progress-buffered-background,#c1c8d199)}.plyr__progress__marker{background-color:#fff;background-color:var(--plyr-progress-marker-background,#fff);border-radius:1px;height:5px;height:var(--plyr-range-track-height,5px);position:absolute;top:50%;transform:translate(-50%,-50%);width:3px;width:var(--plyr-progress-marker-width,3px);z-index:3}.plyr__volume{align-items:center;display:flex;position:relative}.plyr__volume input[type=range]{margin-left:5px;margin-left:calc(.5 * var(--plyr-control-spacing, 10px));margin-right:5px;margin-right:calc(.5 * var(--plyr-control-spacing, 10px));max-width:90px;min-width:60px;position:relative;z-index:2}.plyr--audio{display:block}.plyr--audio .plyr__controls{background:#fff;background:var(--plyr-audio-controls-background,#fff);border-radius:inherit;color:#4a5464;color:var(--plyr-audio-control-color,#4a5464);padding:10px;padding:var(--plyr-control-spacing,10px)}.plyr--audio .plyr__control:focus-visible,.plyr--audio .plyr__control:hover,.plyr--audio .plyr__control[aria-expanded=true]{background:#00b2ff;background:var(--plyr-audio-control-background-hover,var(--plyr-color-main,var(--plyr-color-main,#00b2ff)));color:#fff;color:var(--plyr-audio-control-color-hover,#fff)}.plyr--full-ui.plyr--audio input[type=range]::-webkit-slider-runnable-track{background-color:#c1c8d199;background-color:var(--plyr-audio-range-track-background,var(--plyr-audio-progress-buffered-background,#c1c8d199))}.plyr--full-ui.plyr--audio input[type=range]::-moz-range-track{background-color:#c1c8d199;background-color:var(--plyr-audio-range-track-background,var(--plyr-audio-progress-buffered-background,#c1c8d199))}.plyr--full-ui.plyr--audio input[type=range]::-ms-track{background-color:#c1c8d199;background-color:var(--plyr-audio-range-track-background,var(--plyr-audio-progress-buffered-background,#c1c8d199))}.plyr--full-ui.plyr--audio input[type=range]:active::-webkit-slider-thumb{box-shadow:0 1px 1px #23282f26,0 0 0 1px #23282f33,0 0 0 3px #23282f1a;box-shadow:var(--plyr-range-thumb-shadow,0 1px 1px #23282f26,0 0 0 1px #23282f33),0 0 0 var(--plyr-range-thumb-active-shadow-width,3px) var(--plyr-audio-range-thumb-active-shadow-color,#23282f1a)}.plyr--full-ui.plyr--audio input[type=range]:active::-moz-range-thumb{box-shadow:0 1px 1px #23282f26,0 0 0 1px #23282f33,0 0 0 3px #23282f1a;box-shadow:var(--plyr-range-thumb-shadow,0 1px 1px #23282f26,0 0 0 1px #23282f33),0 0 0 var(--plyr-range-thumb-active-shadow-width,3px) var(--plyr-audio-range-thumb-active-shadow-color,#23282f1a)}.plyr--full-ui.plyr--audio input[type=range]:active::-ms-thumb{box-shadow:0 1px 1px #23282f26,0 0 0 1px #23282f33,0 0 0 3px #23282f1a;box-shadow:var(--plyr-range-thumb-shadow,0 1px 1px #23282f26,0 0 0 1px #23282f33),0 0 0 var(--plyr-range-thumb-active-shadow-width,3px) var(--plyr-audio-range-thumb-active-shadow-color,#23282f1a)}.plyr--audio .plyr__progress__buffer{color:#c1c8d199;color:var(--plyr-audio-progress-buffered-background,#c1c8d199)}.plyr--video{overflow:hidden}.plyr--video.plyr--menu-open{overflow:visible}.plyr__video-wrapper{background:#000;background:var(--plyr-video-background,var(--plyr-video-background,#000));border-radius:inherit;height:100%;margin:auto;overflow:hidden;position:relative;width:100%}@supports not (aspect-ratio:16/9){.plyr__video-embed,.plyr__video-wrapper--fixed-ratio{height:0;padding-bottom:56.25%;position:relative}}.plyr__video-embed,.plyr__video-wrapper--fixed-ratio{aspect-ratio:16/9}.plyr__video-embed iframe,.plyr__video-wrapper--fixed-ratio video{border:0;height:100%;left:0;position:absolute;top:0;width:100%}.plyr--full-ui .plyr__video-embed>.plyr__video-embed__container{padding-bottom:240%;position:relative;transform:translateY(-38.28125%)}.plyr--video .plyr__controls{background:linear-gradient(#0000,#000000bf);background:var(--plyr-video-controls-background,linear-gradient(#0000,#000000bf));border-bottom-left-radius:inherit;border-bottom-right-radius:inherit;bottom:0;color:#fff;color:var(--plyr-video-control-color,#fff);left:0;padding:5px;padding:calc(.5 * var(--plyr-control-spacing, 10px));padding-top:20px;padding-top:calc(2 * var(--plyr-control-spacing, 10px));position:absolute;right:0;transition:opacity .4s ease-in-out,transform .4s ease-in-out;z-index:3}@media (min-width:480px){.plyr--video .plyr__controls{padding:10px;padding:var(--plyr-control-spacing,10px);padding-top:35px;padding-top:calc(3.5 * var(--plyr-control-spacing, 10px))}}.plyr--video.plyr--hide-controls .plyr__controls{opacity:0;pointer-events:none;transform:translateY(100%)}.plyr--video .plyr__control:focus-visible,.plyr--video .plyr__control:hover,.plyr--video .plyr__control[aria-expanded=true]{background:#00b2ff;background:var(--plyr-video-control-background-hover,var(--plyr-color-main,var(--plyr-color-main,#00b2ff)));color:#fff;color:var(--plyr-video-control-color-hover,#fff)}.plyr__control--overlaid{background:#00b2ff;background:var(--plyr-video-control-background-hover,var(--plyr-color-main,var(--plyr-color-main,#00b2ff)));border:0;border-radius:100%;color:#fff;color:var(--plyr-video-control-color,#fff);display:none;left:50%;opacity:.9;padding:15px;padding:calc(1.5 * var(--plyr-control-spacing, 10px));position:absolute;top:50%;transform:translate(-50%,-50%);transition:.3s;z-index:2}.plyr__control--overlaid svg{left:2px;position:relative}.plyr__control--overlaid:focus,.plyr__control--overlaid:hover{opacity:1}.plyr--playing .plyr__control--overlaid{opacity:0;visibility:hidden}.plyr--full-ui.plyr--video .plyr__control--overlaid{display:block}.plyr--full-ui.plyr--video input[type=range]::-webkit-slider-runnable-track{background-color:#ffffff40;background-color:var(--plyr-video-range-track-background,var(--plyr-video-progress-buffered-background,#ffffff40))}.plyr--full-ui.plyr--video input[type=range]::-moz-range-track{background-color:#ffffff40;background-color:var(--plyr-video-range-track-background,var(--plyr-video-progress-buffered-background,#ffffff40))}.plyr--full-ui.plyr--video input[type=range]::-ms-track{background-color:#ffffff40;background-color:var(--plyr-video-range-track-background,var(--plyr-video-progress-buffered-background,#ffffff40))}.plyr--full-ui.plyr--video input[type=range]:active::-webkit-slider-thumb{box-shadow:0 1px 1px #23282f26,0 0 0 1px #23282f33,0 0 0 3px #ffffff80;box-shadow:var(--plyr-range-thumb-shadow,0 1px 1px #23282f26,0 0 0 1px #23282f33),0 0 0 var(--plyr-range-thumb-active-shadow-width,3px) var(--plyr-audio-range-thumb-active-shadow-color,#ffffff80)}.plyr--full-ui.plyr--video input[type=range]:active::-moz-range-thumb{box-shadow:0 1px 1px #23282f26,0 0 0 1px #23282f33,0 0 0 3px #ffffff80;box-shadow:var(--plyr-range-thumb-shadow,0 1px 1px #23282f26,0 0 0 1px #23282f33),0 0 0 var(--plyr-range-thumb-active-shadow-width,3px) var(--plyr-audio-range-thumb-active-shadow-color,#ffffff80)}.plyr--full-ui.plyr--video input[type=range]:active::-ms-thumb{box-shadow:0 1px 1px #23282f26,0 0 0 1px #23282f33,0 0 0 3px #ffffff80;box-shadow:var(--plyr-range-thumb-shadow,0 1px 1px #23282f26,0 0 0 1px #23282f33),0 0 0 var(--plyr-range-thumb-active-shadow-width,3px) var(--plyr-audio-range-thumb-active-shadow-color,#ffffff80)}.plyr--video .plyr__progress__buffer{color:#ffffff40;color:var(--plyr-video-progress-buffered-background,#ffffff40)}.plyr:fullscreen{background:#000;border-radius:0!important;height:100%;margin:0;width:100%}.plyr:fullscreen video{height:100%}.plyr:fullscreen .plyr__control .icon--exit-fullscreen{display:block}.plyr:fullscreen .plyr__control .icon--exit-fullscreen+svg{display:none}.plyr:fullscreen.plyr--hide-controls{cursor:none}@media (min-width:1024px){.plyr:fullscreen .plyr__captions{font-size:21px;font-size:var(--plyr-font-size-xlarge,21px)}}.plyr--fullscreen-fallback{background:#000;border-radius:0!important;height:100%;margin:0;width:100%}.plyr--fullscreen-fallback video{height:100%}.plyr--fullscreen-fallback .plyr__control .icon--exit-fullscreen{display:block}.plyr--fullscreen-fallback .plyr__control .icon--exit-fullscreen+svg{display:none}.plyr--fullscreen-fallback.plyr--hide-controls{cursor:none}@media (min-width:1024px){.plyr--fullscreen-fallback .plyr__captions{font-size:21px;font-size:var(--plyr-font-size-xlarge,21px)}}.plyr--fullscreen-fallback{position:fixed;inset:0;z-index:10000000}.plyr__ads{border-radius:inherit;cursor:pointer;inset:0;overflow:hidden;position:absolute;z-index:-1}.plyr__ads>div,.plyr__ads>div iframe{height:100%;position:absolute;width:100%}.plyr__ads:after{background:#23282f;border-radius:2px;bottom:10px;bottom:var(--plyr-control-spacing,10px);color:#fff;content:attr(data-badge-text);font-size:11px;padding:2px 6px;pointer-events:none;position:absolute;right:10px;right:var(--plyr-control-spacing,10px);z-index:3}.plyr__ads:empty:after{display:none}.plyr__cues{background:currentColor;display:block;height:5px;height:var(--plyr-range-track-height,5px);left:0;opacity:.8;position:absolute;top:50%;transform:translateY(-50%);width:3px;z-index:3}.plyr__preview-thumb{background-color:#fff;background-color:var(--plyr-tooltip-background,#fff);border-radius:8px;border-radius:var(--plyr-menu-radius,8px);bottom:100%;box-shadow:0 1px 2px #00000026;box-shadow:var(--plyr-tooltip-shadow,0 1px 2px #00000026);margin-bottom:10px;margin-bottom:var(--plyr-control-spacing,10px);opacity:0;padding:3px;pointer-events:none;position:absolute;transform:translateY(10px) scale(.8);transform-origin:50% 100%;transition:transform .2s ease .1s,opacity .2s ease .1s;z-index:2}.plyr__preview-thumb--is-shown{opacity:1;transform:translate(0) scale(1)}.plyr__preview-thumb:before{border-left:4px solid #0000;border-left:var(--plyr-tooltip-arrow-size,4px) solid #0000;border-right:4px solid #0000;border-right:var(--plyr-tooltip-arrow-size,4px) solid #0000;border-top:4px solid #fff;border-top:var(--plyr-tooltip-arrow-size,4px) solid var(--plyr-tooltip-background,#fff);bottom:calc(-4px);bottom:calc(-1 * var(--plyr-tooltip-arrow-size, 4px));content:"";height:0;left:calc(50% + var(--preview-arrow-offset));position:absolute;transform:translateX(-50%);width:0;z-index:2}.plyr__preview-thumb__image-container{background:#c1c8d1;border-radius:7px;border-radius:calc(-1px + var(--plyr-menu-radius, 8px));overflow:hidden;position:relative;z-index:0}.plyr__preview-thumb__image-container img,.plyr__preview-thumb__image-container:after{height:100%;left:0;position:absolute;top:0;width:100%}.plyr__preview-thumb__image-container:after{border-radius:inherit;box-shadow:inset 0 0 0 1px #00000026;content:"";pointer-events:none}.plyr__preview-thumb__image-container img{max-height:none;max-width:none}.plyr__preview-thumb__time-container{background:linear-gradient(#0000,#000000bf);background:var(--plyr-video-controls-background,linear-gradient(#0000,#000000bf));border-bottom-left-radius:7px;border-bottom-left-radius:calc(-1px + var(--plyr-menu-radius, 8px));border-bottom-right-radius:7px;border-bottom-right-radius:calc(-1px + var(--plyr-menu-radius, 8px));bottom:0;left:0;line-height:1.1;padding:20px 6px 6px;position:absolute;right:0;z-index:3}.plyr__preview-thumb__time-container span{color:#fff;font-size:13px;font-size:var(--plyr-font-size-time,var(--plyr-font-size-small,13px))}.plyr__preview-scrubbing{filter:blur(1px);height:100%;inset:0;margin:auto;opacity:0;overflow:hidden;pointer-events:none;position:absolute;transition:opacity .3s ease;width:100%;z-index:1}.plyr__preview-scrubbing--is-shown{opacity:1}.plyr__preview-scrubbing img{height:100%;left:0;max-height:none;max-width:none;object-fit:contain;position:absolute;top:0;width:100%}.plyr--no-transition{transition:none!important}.plyr__sr-only{clip:rect(1px,1px,1px,1px);overflow:hidden;border:0!important;height:1px!important;padding:0!important;position:absolute!important;width:1px!important}.plyr [hidden]{display:none!important} \ No newline at end of file diff --git a/android/app/src/main/assets/pulsewall/libs/plyr.min.js b/android/app/src/main/assets/pulsewall/libs/plyr.min.js new file mode 100644 index 0000000..cc157e8 --- /dev/null +++ b/android/app/src/main/assets/pulsewall/libs/plyr.min.js @@ -0,0 +1,2 @@ +"object"==typeof navigator&&function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):(e="undefined"!=typeof globalThis?globalThis:e||self).Plyr=t()}(this,function(){var e=Object.create,t=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,n=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,l=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),r=(l,r,o)=>(o=null!=l?e(n(l)):{},((e,n,l,r)=>{if(n&&"object"==typeof n||"function"==typeof n)for(var o,c=s(n),u=0,h=c.length;un[e]).bind(null,o),enumerable:!(r=i(n,o))||r.enumerable});return e})(!r&&l&&l.__esModule&&a.call(l,"default")?o:t(o,"default",{value:l,enumerable:!0}),l)),o=l((e,t)=>{var i,s;i=e,s=function(){"use strict";function e(e,t){for(var i=0;i(i=100/o.width*(n.clientX-o.left))?i=0:100i?i-=(100-2*i)*c:50t){var i=function(e){var t="".concat(e).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return t?Math.max(0,(t[1]?t[1].length:0)-(t[2]?+t[2]:0)):0}(t);return parseFloat(e.toFixed(i))}return Math.round(e/t)*t}(i/100*(l-a),r)}},{key:"set",value:function(e){t.enabled&&p(e)&&!e.target.disabled&&(e.preventDefault(),e.target.value=this.get(e),function(e,t){if(e&&t){var i=new Event(t,{bubbles:!0});e.dispatchEvent(i)}}(e.target,"touchend"===e.type?"change":"input"))}}])&&e(i.prototype,a),l&&e(i,l),t;var i,a,l}()},"object"==typeof e&&void 0!==t?t.exports=s():"function"==typeof define&&define.amd?define("RangeTouch",s):(i=i||self).RangeTouch=s()}),c=r(o(),1),u=e=>null!=e?e.constructor:null,h=(e,t)=>Boolean(e&&t&&e instanceof t),d=e=>null==e,m=e=>u(e)===Object,p=e=>u(e)===String,g=e=>"function"==typeof e,f=e=>Array.isArray(e),y=e=>h(e,NodeList);function b(e){return d(e)||(p(e)||f(e)||y(e))&&!e.length||m(e)&&!Object.keys(e).length}var v={nullOrUndefined:d,object:m,number:e=>u(e)===Number&&!Number.isNaN(e),string:p,boolean:e=>u(e)===Boolean,function:g,array:f,weakMap:e=>h(e,WeakMap),nodeList:y,element:function(e){return null!==e&&"object"==typeof e&&1===e.nodeType&&"object"==typeof e.style&&"object"==typeof e.ownerDocument},textNode:e=>u(e)===Text,event:e=>h(e,Event),keyboardEvent:e=>h(e,KeyboardEvent),cue:e=>h(e,window.TextTrackCue)||h(e,window.VTTCue),track:e=>h(e,TextTrack)||!d(e)&&p(e.kind),promise:e=>h(e,Promise)&&g(e.then),url:function(e){if(h(e,window.URL))return!0;if(!p(e))return!1;let t=e;e.startsWith("http://")&&e.startsWith("https://")||(t=`http://${e}`);try{return!b(new URL(t).hostname)}catch{return!1}},empty:b},w=(()=>{const e=document.createElement("span"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},i=Object.keys(t).find(t=>void 0!==e.style[t]);return!!v.string(i)&&t[i]})();function k(e,t){setTimeout(()=>{try{e.hidden=!0,e.offsetHeight,e.hidden=!1}catch{}},t)}function T(e,t){return t.split(".").reduce((e,t)=>e&&e[t],e)}function C(e={},...t){if(!t.length)return e;const i=t.shift();return v.object(i)?(Object.keys(i).forEach(t=>{v.object(i[t])?(Object.keys(e).includes(t)||Object.assign(e,{[t]:{}}),C(e[t],i[t])):Object.assign(e,{[t]:i[t]})}),C(e,...t)):e}function A(e,t){const i=e.length?e:[e];Array.from(i).reverse().forEach((e,i)=>{const s=i>0?t.cloneNode(!0):t,n=e.parentNode,a=e.nextSibling;s.appendChild(e),a?n.insertBefore(s,a):n.appendChild(s)})}function S(e,t){v.element(e)&&!v.empty(t)&&Object.entries(t).filter(([,e])=>!v.nullOrUndefined(e)).forEach(([t,i])=>e.setAttribute(t,i))}function E(e,t,i){const s=document.createElement(e);return v.object(t)&&S(s,t),v.string(i)&&(s.textContent=i),s}function P(e,t,i,s){v.element(t)&&t.appendChild(E(e,i,s))}function M(e){v.nodeList(e)||v.array(e)?Array.from(e).forEach(M):v.element(e)&&v.element(e.parentNode)&&e.parentNode.removeChild(e)}function N(e){if(!v.element(e))return;let{length:t}=e.childNodes;for(;t>0;)e.removeChild(e.lastChild),t-=1}function x(e,t){return v.element(t)&&v.element(t.parentNode)&&v.element(e)?(t.parentNode.replaceChild(e,t),e):null}function L(e,t){if(!v.string(e)||v.empty(e))return{};const i={},s=C({},t);return e.split(",").forEach(e=>{const t=e.trim(),n=t.replace(".",""),a=t.replace(/[[\]]/g,"").split("="),[l]=a,r=a.length>1?a[1].replace(/["']/g,""):"";switch(t.charAt(0)){case".":v.string(s.class)?i.class=`${s.class} ${n}`:i.class=n;break;case"#":i.id=t.replace("#","");break;case"[":i[l]=r}}),C(s,i)}function I(e,t){if(!v.element(e))return;let i=t;v.boolean(i)||(i=!e.hidden),e.hidden=i}function $(e,t,i){if(v.nodeList(e))return Array.from(e).map(e=>$(e,t,i));if(v.element(e)){let s="toggle";return void 0!==i&&(s=i?"add":"remove"),e.classList[s](t),e.classList.contains(t)}return!1}function O(e,t){return v.element(e)&&e.classList.contains(t)}function _(e,t){const{prototype:i}=Element;return(i.matches||i.webkitMatchesSelector||i.mozMatchesSelector||i.msMatchesSelector||function(){return Array.from(document.querySelectorAll(t)).includes(this)}).call(e,t)}function j(e){return this.elements.container.querySelectorAll(e)}function q(e){return this.elements.container.querySelector(e)}function D(e=null,t=!1){v.element(e)&&e.focus({preventScroll:!0,focusVisible:t})}var H={"audio/ogg":"vorbis","audio/wav":"1","video/webm":"vp8, vorbis","video/mp4":"avc1.42E01E, mp4a.40.2","video/ogg":"theora"},R={audio:"canPlayType"in document.createElement("audio"),video:"canPlayType"in document.createElement("video"),check(e,t){const i=R[e]||"html5"!==t;return{api:i,ui:i&&R.rangeInput}},pip:document.pictureInPictureEnabled&&!E("video").disablePictureInPicture,airplay:v.function(window.WebKitPlaybackTargetAvailabilityEvent),playsinline:"playsInline"in document.createElement("video"),mime(e){if(v.empty(e))return!1;const[t]=e.split("/");let i=e;if(!this.isHTML5||t!==this.type)return!1;Object.keys(H).includes(i)&&(i+=`; codecs="${H[e]}"`);try{return Boolean(i&&this.media.canPlayType(i).replace(/no/,""))}catch{return!1}},textTracks:"textTracks"in document.createElement("video"),rangeInput:(()=>{const e=document.createElement("input");return e.type="range","range"===e.type})(),touch:"ontouchstart"in document.documentElement,transitions:!1!==w,reducedMotion:"matchMedia"in window&&window.matchMedia("(prefers-reduced-motion)").matches},V=(()=>{let e=!1;try{const t=Object.defineProperty({},"passive",{get:()=>(e=!0,null)});window.addEventListener("test",null,t),window.removeEventListener("test",null,t)}catch{}return e})();function F(e,t,i,s=!1,n=!0,a=!1){if(!e||!("addEventListener"in e)||v.empty(t)||!v.function(i))return;const l=t.split(" ");let r=a;V&&(r={passive:n,capture:a}),l.forEach(t=>{this&&this.eventListeners&&s&&this.eventListeners.push({element:e,type:t,callback:i,options:r}),e[s?"addEventListener":"removeEventListener"](t,i,r)})}function U(e,t="",i,s=!0,n=!1){F.call(this,e,t,i,!0,s,n)}function B(e,t="",i,s=!0,n=!1){F.call(this,e,t,i,!1,s,n)}function W(e,t="",i,s=!0,n=!1){const a=(...l)=>{B(e,t,a,s,n),i.apply(this,l)};F.call(this,e,t,a,!0,s,n)}function z(e,t="",i=!1,s={}){if(!v.element(e)||v.empty(t))return;const n=new CustomEvent(t,{bubbles:i,detail:{...s,plyr:this}});e.dispatchEvent(n)}function K(){this&&this.eventListeners&&(this.eventListeners.forEach(e=>{const{element:t,type:i,callback:s,options:n}=e;t.removeEventListener(i,s,n)}),this.eventListeners=[])}function Y(){return new Promise(e=>this.ready?setTimeout(e,0):U.call(this,this.elements.container,"ready",e)).then(()=>{})}function X(e){v.promise(e)&&e.then(null,()=>{})}function Q(e){return v.array(e)?e.filter((t,i)=>e.indexOf(t)===i):e}function J(e,t){return v.array(e)&&e.length?e.reduce((e,i)=>Math.abs(i-t)({...e,[t/i]:[t,i]}),{});function ee(e){return!!(v.array(e)||v.string(e)&&e.includes(":"))&&(v.array(e)?e:e.split(":")).map(Number).every(v.number)}function te(e){if(!v.array(e)||!e.every(v.number))return null;const[t,i]=e,s=(e,t)=>0===t?e:s(t,e%t),n=s(t,i);return[t/n,i/n]}function ie(e){const t=e=>ee(e)?e.split(":").map(Number):null;let i=t(e);if(null===i&&(i=t(this.config.ratio)),null===i&&!v.empty(this.embed)&&v.array(this.embed.ratio)&&({ratio:i}=this.embed),null===i&&this.isHTML5){const{videoWidth:e,videoHeight:t}=this.media;i=[e,t]}return te(i)}function se(e){if(!this.isVideo)return{};const{wrapper:t}=this.elements,i=ie.call(this,e);if(!v.array(i))return{};const[s,n]=te(i),a=100/s*n;if(G(`aspect-ratio: ${s}/${n}`)?t.style.aspectRatio=`${s}/${n}`:t.style.paddingBottom=`${a}%`,this.isVimeo&&!this.config.vimeo.premium&&this.supported.ui){const e=100/this.media.offsetWidth*Number.parseInt(window.getComputedStyle(this.media).paddingBottom,10),i=(e-a)/(e/50);this.fullscreen.active?t.style.paddingBottom=null:this.media.style.transform=`translateY(-${i}%)`}else this.isHTML5&&t.classList.add(this.config.classNames.videoFixedRatio);return{padding:a,ratio:i}}function ne(e,t,i=.05){const s=e/t,n=J(Object.keys(Z),s);return Math.abs(n-s)<=i?Z[n]:[e,t]}var ae={getSources(){return this.isHTML5?Array.from(this.media.querySelectorAll("source")).filter(e=>{const t=e.getAttribute("type");return!!v.empty(t)||R.mime.call(this,t)}):[]},getQualityOptions(){return this.config.quality.forced?this.config.quality.options:ae.getSources.call(this).map(e=>Number(e.getAttribute("size"))).filter(Boolean)},setup(){if(!this.isHTML5)return;const e=this;e.options.speed=e.config.speed.options,v.empty(this.config.ratio)||se.call(e),Object.defineProperty(e.media,"quality",{get(){const t=ae.getSources.call(e).find(t=>t.getAttribute("src")===e.source);return t&&Number(t.getAttribute("size"))},set(t){if(e.quality!==t){if(e.config.quality.forced&&v.function(e.config.quality.onChange))e.config.quality.onChange(t);else{const i=ae.getSources.call(e).find(e=>Number(e.getAttribute("size"))===t);if(!i)return;const{currentTime:s,paused:n,preload:a,readyState:l,playbackRate:r}=e.media;e.media.src=i.getAttribute("src"),("none"!==a||l)&&(e.once("loadedmetadata",()=>{e.speed=r,e.currentTime=s,n||X(e.play())}),e.media.load())}z.call(e,e.media,"qualitychange",!1,{quality:t})}}})},cancelRequests(){this.isHTML5&&(M(ae.getSources.call(this)),this.media.setAttribute("src",this.config.blankVideo),this.media.load(),this.debug.log("Cancelled network requests"))}},le={isIE:Boolean(window.document.documentMode),isEdge:/Edge/.test(navigator.userAgent),isWebKit:"WebkitAppearance"in document.documentElement.style&&!/Edge/.test(navigator.userAgent),isIPhone:/iPhone|iPod/i.test(navigator.userAgent)&&navigator.maxTouchPoints>1,isIPadOS:"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1,isIos:/iPad|iPhone|iPod/i.test(navigator.userAgent)&&navigator.maxTouchPoints>1};function re(e,...t){return v.empty(e)?e:e.toString().replace(/\{(\d+)\}/g,(e,i)=>t[i].toString())}function oe(e="",t="",i=""){return e.replace(new RegExp(t.toString().replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1"),"g"),i.toString())}function ce(e=""){return e.toString().replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())}function ue(e=""){let t=e.toString();return t=function(e=""){let t=e.toString();return t=oe(t,"-"," "),t=oe(t,"_"," "),t=ce(t),oe(t," ","")}(t),t.charAt(0).toLowerCase()+t.slice(1)}function he(e){const t=document.createElement("div");return t.appendChild(e),t.innerHTML}var de={pip:"PIP",airplay:"AirPlay",html5:"HTML5",vimeo:"Vimeo",youtube:"YouTube"},me={get(e="",t={}){if(v.empty(e)||v.empty(t))return"";let i=T(t.i18n,e);if(v.empty(i))return Object.keys(de).includes(e)?de[e]:"";const s={"{seektime}":t.seekTime,"{title}":t.title};return Object.entries(s).forEach(([e,t])=>{i=oe(i,e,t)}),i}};function pe(e){return pe="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},pe(e)}function ge(e){var t=function(e,t){if("object"!=pe(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var s=i.call(e,t||"default");if("object"!=pe(s))return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==pe(t)?t:t+""}function fe(e,t,i){return(t=ge(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var ye=class e{constructor(t){fe(this,"get",t=>{if(!e.supported||!this.enabled)return null;const i=window.localStorage.getItem(this.key);if(v.empty(i))return null;const s=JSON.parse(i);return v.string(t)&&t.length?s[t]:s}),fe(this,"set",t=>{if(!e.supported||!this.enabled)return;if(!v.object(t))return;let i=this.get();v.empty(i)&&(i={}),C(i,t);try{window.localStorage.setItem(this.key,JSON.stringify(i))}catch{}}),this.enabled=t.config.storage.enabled,this.key=t.config.storage.key}static get supported(){try{if(!("localStorage"in window))return!1;const e="___test";return window.localStorage.setItem(e,e),window.localStorage.removeItem(e),!0}catch{return!1}}};function be(e,t="text",i=!1){return new Promise((s,n)=>{try{const n=new XMLHttpRequest;if(!("withCredentials"in n))return;i&&(n.withCredentials=!0),n.addEventListener("load",()=>{if("text"===t)try{s(JSON.parse(n.responseText))}catch{s(n.responseText)}else s(n.response)}),n.addEventListener("error",()=>{throw new Error(n.status)}),n.open("GET",e,!0),n.responseType=t,n.send()}catch(a){n(a)}})}function ve(e,t){if(!v.string(e))return;const i="cache",s=v.string(t);let n=!1;const a=()=>null!==document.getElementById(t),l=(e,t)=>{e.innerHTML=t,s&&a()||document.body.insertAdjacentElement("afterbegin",e)};if(!s||!a()){const a=ye.supported,r=document.createElement("div");if(r.setAttribute("hidden",""),s&&r.setAttribute("id",t),a){const e=window.localStorage.getItem(`${i}-${t}`);n=null!==e,n&&l(r,JSON.parse(e).content)}be(e).then(e=>{if(!v.empty(e)){if(a)try{window.localStorage.setItem(`${i}-${t}`,JSON.stringify({content:e}))}catch{}l(r,e)}}).catch(()=>{})}}var we=e=>Math.trunc(e/60/60%60,10);function ke(e=0,t=!1,i=!1){if(!v.number(e))return ke(void 0,t,i);const s=e=>`0${e}`.slice(-2);let n=we(e);const a=(l=e,Math.trunc(l/60%60,10));var l;const r=(e=>Math.trunc(e%60,10))(e);return n=t||n>0?`${n}:`:"",`${i&&e>0?"-":""}${n}${s(a)}:${s(r)}`}var Te={getIconUrl(){const e=new URL(this.config.iconUrl,window.location),t=window.location.host?window.location.host:window.top.location.host,i=e.host!==t||le.isIE&&!window.svg4everybody;return{url:this.config.iconUrl,cors:i}},findElements(){try{return this.elements.controls=q.call(this,this.config.selectors.controls.wrapper),this.elements.buttons={play:j.call(this,this.config.selectors.buttons.play),pause:q.call(this,this.config.selectors.buttons.pause),restart:q.call(this,this.config.selectors.buttons.restart),rewind:q.call(this,this.config.selectors.buttons.rewind),fastForward:q.call(this,this.config.selectors.buttons.fastForward),mute:q.call(this,this.config.selectors.buttons.mute),pip:q.call(this,this.config.selectors.buttons.pip),airplay:q.call(this,this.config.selectors.buttons.airplay),settings:q.call(this,this.config.selectors.buttons.settings),captions:q.call(this,this.config.selectors.buttons.captions),fullscreen:q.call(this,this.config.selectors.buttons.fullscreen)},this.elements.progress=q.call(this,this.config.selectors.progress),this.elements.inputs={seek:q.call(this,this.config.selectors.inputs.seek),volume:q.call(this,this.config.selectors.inputs.volume)},this.elements.display={buffer:q.call(this,this.config.selectors.display.buffer),currentTime:q.call(this,this.config.selectors.display.currentTime),duration:q.call(this,this.config.selectors.display.duration)},v.element(this.elements.progress)&&(this.elements.display.seekTooltip=this.elements.progress.querySelector(`.${this.config.classNames.tooltip}`)),!0}catch(e){return this.debug.warn("It looks like there is a problem with your custom controls HTML",e),this.toggleNativeControls(!0),!1}},createIcon(e,t){const i="http://www.w3.org/2000/svg",s=Te.getIconUrl.call(this),n=`${s.cors?"":s.url}#${this.config.iconPrefix}`,a=document.createElementNS(i,"svg");S(a,C(t,{"aria-hidden":"true",focusable:"false"}));const l=document.createElementNS(i,"use"),r=`${n}-${e}`;return"href"in l&&l.setAttributeNS("http://www.w3.org/1999/xlink","href",r),l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r),a.appendChild(l),a},createLabel(e,t={}){const i=me.get(e,this.config);return E("span",{...t,class:[t.class,this.config.classNames.hidden].filter(Boolean).join(" ")},i)},createBadge(e){if(v.empty(e))return null;const t=E("span",{class:this.config.classNames.menu.value});return t.appendChild(E("span",{class:this.config.classNames.menu.badge},e)),t},createButton(e,t){const i=C({},t);let s=ue(e);const n={element:"button",toggle:!1,label:null,icon:null,labelPressed:null,iconPressed:null};switch(["element","icon","label"].forEach(e=>{Object.keys(i).includes(e)&&(n[e]=i[e],delete i[e])}),"button"!==n.element||Object.keys(i).includes("type")||(i.type="button"),Object.keys(i).includes("class")?i.class.split(" ").includes(this.config.classNames.control)||C(i,{class:`${i.class} ${this.config.classNames.control}`}):i.class=this.config.classNames.control,e){case"play":n.toggle=!0,n.label="play",n.labelPressed="pause",n.icon="play",n.iconPressed="pause";break;case"mute":n.toggle=!0,n.label="mute",n.labelPressed="unmute",n.icon="volume",n.iconPressed="muted";break;case"captions":n.toggle=!0,n.label="enableCaptions",n.labelPressed="disableCaptions",n.icon="captions-off",n.iconPressed="captions-on";break;case"fullscreen":n.toggle=!0,n.label="enterFullscreen",n.labelPressed="exitFullscreen",n.icon="enter-fullscreen",n.iconPressed="exit-fullscreen";break;case"play-large":i.class+=` ${this.config.classNames.control}--overlaid`,s="play",n.label="play",n.icon="play";break;default:v.empty(n.label)&&(n.label=s),v.empty(n.icon)&&(n.icon=e)}const a=E(n.element);return n.toggle?(a.appendChild(Te.createIcon.call(this,n.iconPressed,{class:"icon--pressed"})),a.appendChild(Te.createIcon.call(this,n.icon,{class:"icon--not-pressed"})),a.appendChild(Te.createLabel.call(this,n.labelPressed,{class:"label--pressed"})),a.appendChild(Te.createLabel.call(this,n.label,{class:"label--not-pressed"}))):(a.appendChild(Te.createIcon.call(this,n.icon)),a.appendChild(Te.createLabel.call(this,n.label))),C(i,L(this.config.selectors.buttons[s],i)),S(a,i),"play"===s?(v.array(this.elements.buttons[s])||(this.elements.buttons[s]=[]),this.elements.buttons[s].push(a)):this.elements.buttons[s]=a,a},createRange(e,t){const i=E("input",C(L(this.config.selectors.inputs[e]),{type:"range",min:0,max:100,step:.01,value:0,autocomplete:"off",role:"slider","aria-label":me.get(e,this.config),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":0},t));return this.elements.inputs[e]=i,Te.updateRangeFill.call(this,i),c.default.setup(i),i},createProgress(e,t){const i=E("progress",C(L(this.config.selectors.display[e]),{min:0,max:100,value:0,role:"progressbar","aria-hidden":!0},t));if("volume"!==e){i.appendChild(E("span",null,"0"));const t={played:"played",buffer:"buffered"}[e];i.textContent=`% ${(t?me.get(t,this.config):"").toLowerCase()}`}return this.elements.display[e]=i,i},createTime(e,t){const i=L(this.config.selectors.display[e],t),s=E("div",C(i,{class:`${i.class?i.class:""} ${this.config.classNames.display.time} `.trim(),"aria-label":me.get(e,this.config),role:"timer"}),"00:00");return this.elements.display[e]=s,s},bindMenuItemShortcuts(e,t){U.call(this,e,"keydown keyup",i=>{if(![" ","ArrowUp","ArrowDown","ArrowRight"].includes(i.key))return;if(i.preventDefault(),i.stopPropagation(),"keydown"===i.type)return;const s=_(e,'[role="menuitemradio"]');if(!s&&[" ","ArrowRight"].includes(i.key))Te.showMenuPanel.call(this,t,!0);else{let t;" "!==i.key&&("ArrowDown"===i.key||s&&"ArrowRight"===i.key?(t=e.nextElementSibling,v.element(t)||(t=e.parentNode.firstElementChild)):(t=e.previousElementSibling,v.element(t)||(t=e.parentNode.lastElementChild)),D.call(this,t,!0))}},!1),U.call(this,e,"keyup",e=>{"Return"===e.key&&Te.focusFirstMenuItem.call(this,null,!0)})},createMenuItem({value:e,list:t,type:i,title:s,badge:n=null,checked:a=!1}){const l=L(this.config.selectors.inputs[i]),r=E("button",C(l,{type:"button",role:"menuitemradio",class:`${this.config.classNames.control} ${l.class?l.class:""}`.trim(),"aria-checked":a,value:e})),o=E("span");o.innerHTML=s,v.element(n)&&o.appendChild(n),r.appendChild(o),Object.defineProperty(r,"checked",{enumerable:!0,get:()=>"true"===r.getAttribute("aria-checked"),set(e){e&&Array.from(r.parentNode.children).filter(e=>_(e,'[role="menuitemradio"]')).forEach(e=>e.setAttribute("aria-checked","false")),r.setAttribute("aria-checked",e?"true":"false")}}),this.listeners.bind(r,"click keyup",t=>{if(!v.keyboardEvent(t)||" "===t.key){switch(t.preventDefault(),t.stopPropagation(),r.checked=!0,i){case"language":this.currentTrack=Number(e);break;case"quality":this.quality=e;break;case"speed":this.speed=Number.parseFloat(e)}Te.showMenuPanel.call(this,"home",v.keyboardEvent(t))}},i,!1),Te.bindMenuItemShortcuts.call(this,r,i),t.appendChild(r)},formatTime(e=0,t=!1){if(!v.number(e))return e;return ke(e,we(this.duration)>0,t)},updateTimeDisplay(e=null,t=0,i=!1){v.element(e)&&v.number(t)&&(e.textContent=Te.formatTime(t,i))},updateVolume(){this.supported.ui&&(v.element(this.elements.inputs.volume)&&Te.setRange.call(this,this.elements.inputs.volume,this.muted?0:this.volume),v.element(this.elements.buttons.mute)&&(this.elements.buttons.mute.pressed=this.muted||0===this.volume))},setRange(e,t=0){v.element(e)&&(e.value=t,Te.updateRangeFill.call(this,e))},updateProgress(e){if(!this.supported.ui||!v.event(e))return;let t=0;const i=(e,t)=>{const i=v.number(t)?t:0,s=v.element(e)?e:this.elements.display.buffer;if(v.element(s)){s.value=i;const e=s.getElementsByTagName("span")[0];v.element(e)&&(e.childNodes[0].nodeValue=i)}};if(e)switch(e.type){case"timeupdate":case"seeking":case"seeked":s=this.currentTime,n=this.duration,t=0===s||0===n||Number.isNaN(s)||Number.isNaN(n)?0:(s/n*100).toFixed(2),"timeupdate"===e.type&&Te.setRange.call(this,this.elements.inputs.seek,t);break;case"playing":case"progress":i(this.elements.display.buffer,100*this.buffered)}var s,n},updateRangeFill(e){const t=v.event(e)?e.target:e;if(v.element(t)&&"range"===t.getAttribute("type")){if(_(t,this.config.selectors.inputs.seek)){t.setAttribute("aria-valuenow",this.currentTime);const e=Te.formatTime(this.currentTime),i=Te.formatTime(this.duration),s=me.get("seekLabel",this.config);t.setAttribute("aria-valuetext",s.replace("{currentTime}",e).replace("{duration}",i))}else if(_(t,this.config.selectors.inputs.volume)){const e=100*t.value;t.setAttribute("aria-valuenow",e),t.setAttribute("aria-valuetext",`${e.toFixed(1)}%`)}else t.setAttribute("aria-valuenow",t.value);(le.isWebKit||le.isIPadOS)&&t.style.setProperty("--value",t.value/t.max*100+"%")}},updateSeekTooltip(e){var t;if(!this.config.tooltips.seek||!v.element(this.elements.inputs.seek)||!v.element(this.elements.display.seekTooltip)||0===this.duration)return;const i=this.elements.display.seekTooltip,s=`${this.config.classNames.tooltip}--visible`,n=e=>$(i,s,e);if(this.touch)return void n(!1);let a=0;const l=this.elements.progress.getBoundingClientRect();if(v.event(e)){const t=e.pageX-e.clientX;a=100/l.width*(e.pageX-l.left-t)}else{if(!O(i,s))return;a=Number.parseFloat(i.style.left,10)}a<0?a=0:a>100&&(a=100);const r=this.duration/100*a;i.textContent=Te.formatTime(r);const o=null===(t=this.config.markers)||void 0===t||null===(t=t.points)||void 0===t?void 0:t.find(({time:e})=>e===Math.round(r));o&&i.insertAdjacentHTML("afterbegin",`${o.label}
`),i.style.left=`${a}%`,v.event(e)&&["mouseenter","mouseleave"].includes(e.type)&&n("mouseenter"===e.type)},timeUpdate(e){const t=!v.element(this.elements.display.duration)&&this.config.invertTime;Te.updateTimeDisplay.call(this,this.elements.display.currentTime,t?this.duration-this.currentTime:this.currentTime,t),e&&"timeupdate"===e.type&&this.media.seeking||Te.updateProgress.call(this,e)},durationUpdate(){if(!this.supported.ui||!this.config.invertTime&&this.currentTime)return;if(this.duration>=2**32)return I(this.elements.display.currentTime,!0),void I(this.elements.progress,!0);v.element(this.elements.inputs.seek)&&this.elements.inputs.seek.setAttribute("aria-valuemax",this.duration);const e=v.element(this.elements.display.duration);!e&&this.config.displayDuration&&this.paused&&Te.updateTimeDisplay.call(this,this.elements.display.currentTime,this.duration),e&&Te.updateTimeDisplay.call(this,this.elements.display.duration,this.duration),this.config.markers.enabled&&Te.setMarkers.call(this),Te.updateSeekTooltip.call(this)},toggleMenuButton(e,t){I(this.elements.settings.buttons[e],!t)},updateSetting(e,t,i){const s=this.elements.settings.panels[e];let n=null,a=t;if("captions"===e)n=this.currentTrack;else{if(n=v.empty(i)?this[e]:i,v.empty(n)&&(n=this.config[e].default),!v.empty(this.options[e])&&!this.options[e].includes(n))return void this.debug.warn(`Unsupported value of '${n}' for ${e}`);if(!this.config[e].options.includes(n))return void this.debug.warn(`Disabled value of '${n}' for ${e}`)}if(v.element(a)||(a=s&&s.querySelector('[role="menu"]')),!v.element(a))return;this.elements.settings.buttons[e].querySelector(`.${this.config.classNames.menu.value}`).innerHTML=Te.getLabel.call(this,e,n);const l=a&&a.querySelector(`[value="${n}"]`);v.element(l)&&(l.checked=!0)},getLabel(e,t){switch(e){case"speed":return 1===t?me.get("normal",this.config):`${t}×`;case"quality":if(v.number(t)){const e=me.get(`qualityLabel.${t}`,this.config);return e.length?e:`${t}p`}return ce(t);case"captions":return Se.getLabel.call(this);default:return null}},setQualityMenu(e){if(!v.element(this.elements.settings.panels.quality))return;const t="quality",i=this.elements.settings.panels.quality.querySelector('[role="menu"]');v.array(e)&&(this.options.quality=Q(e).filter(e=>this.config.quality.options.includes(e)));const s=!v.empty(this.options.quality)&&this.options.quality.length>1;if(Te.toggleMenuButton.call(this,t,s),N(i),Te.checkMenu.call(this),!s)return;const n=e=>{const t=me.get(`qualityBadge.${e}`,this.config);return t.length?Te.createBadge.call(this,t):null};this.options.quality.sort((e,t)=>{const i=this.config.quality.options;return i.indexOf(e)>i.indexOf(t)?1:-1}).forEach(e=>{Te.createMenuItem.call(this,{value:e,list:i,type:t,title:Te.getLabel.call(this,"quality",e),badge:n(e)})}),Te.updateSetting.call(this,t,i)},setCaptionsMenu(){if(!v.element(this.elements.settings.panels.captions))return;const e="captions",t=this.elements.settings.panels.captions.querySelector('[role="menu"]'),i=Se.getTracks.call(this),s=Boolean(i.length);if(Te.toggleMenuButton.call(this,e,s),N(t),Te.checkMenu.call(this),!s)return;const n=i.map((e,i)=>({value:i,checked:this.captions.toggled&&this.currentTrack===i,title:Se.getLabel.call(this,e),badge:e.language&&Te.createBadge.call(this,e.language.toUpperCase()),list:t,type:"language"}));n.unshift({value:-1,checked:!this.captions.toggled,title:me.get("disabled",this.config),list:t,type:"language"}),n.forEach(Te.createMenuItem.bind(this)),Te.updateSetting.call(this,e,t)},setSpeedMenu(){if(!v.element(this.elements.settings.panels.speed))return;const e="speed",t=this.elements.settings.panels.speed.querySelector('[role="menu"]');this.options.speed=this.options.speed.filter(e=>e>=this.minimumSpeed&&e<=this.maximumSpeed);const i=!v.empty(this.options.speed)&&this.options.speed.length>1;Te.toggleMenuButton.call(this,e,i),N(t),Te.checkMenu.call(this),i&&(this.options.speed.forEach(i=>{Te.createMenuItem.call(this,{value:i,list:t,type:e,title:Te.getLabel.call(this,"speed",i)})}),Te.updateSetting.call(this,e,t))},checkMenu(){const{buttons:e}=this.elements.settings,t=!v.empty(e)&&Object.values(e).some(e=>!e.hidden);I(this.elements.settings.menu,!t)},focusFirstMenuItem(e,t=!1){if(this.elements.settings.popup.hidden)return;let i=e;v.element(i)||(i=Object.values(this.elements.settings.panels).find(e=>!e.hidden));const s=i.querySelector('[role^="menuitem"]');D.call(this,s,t)},toggleMenu(e){const{popup:t}=this.elements.settings,i=this.elements.buttons.settings;if(!v.element(t)||!v.element(i))return;const{hidden:s}=t;let n=s;if(v.boolean(e))n=e;else if(v.keyboardEvent(e)&&"Escape"===e.key)n=!1;else if(v.event(e)){const s=v.function(e.composedPath)?e.composedPath()[0]:e.target,a=t.contains(s);if(a||!a&&e.target!==i&&n)return}i.setAttribute("aria-expanded",n),I(t,!n),$(this.elements.container,this.config.classNames.menu.open,n),n&&v.keyboardEvent(e)?Te.focusFirstMenuItem.call(this,null,!0):n||s||D.call(this,i,v.keyboardEvent(e))},getMenuSize(e){const t=e.cloneNode(!0);t.style.position="absolute",t.style.opacity=0,t.removeAttribute("hidden"),e.parentNode.appendChild(t);const i=t.scrollWidth,s=t.scrollHeight;return M(t),{width:i,height:s}},showMenuPanel(e="",t=!1){const i=this.elements.container.querySelector(`#plyr-settings-${this.id}-${e}`);if(!v.element(i))return;const s=i.parentNode,n=Array.from(s.children).find(e=>!e.hidden);if(R.transitions&&!R.reducedMotion){s.style.width=`${n.scrollWidth}px`,s.style.height=`${n.scrollHeight}px`;const e=Te.getMenuSize.call(this,i),t=e=>{e.target===s&&["width","height"].includes(e.propertyName)&&(s.style.width="",s.style.height="",B.call(this,s,w,t))};U.call(this,s,w,t),s.style.width=`${e.width}px`,s.style.height=`${e.height}px`}I(n,!0),I(i,!1),Te.focusFirstMenuItem.call(this,i,t)},setDownloadUrl(){const e=this.elements.buttons.download;v.element(e)&&e.setAttribute("href",this.download)},create(e){const{bindMenuItemShortcuts:t,createButton:i,createProgress:s,createRange:n,createTime:a,setQualityMenu:l,setSpeedMenu:r,showMenuPanel:o}=Te;this.elements.controls=null,v.array(this.config.controls)&&this.config.controls.includes("play-large")&&this.elements.container.appendChild(i.call(this,"play-large"));const c=E("div",L(this.config.selectors.controls.wrapper));this.elements.controls=c;const u={class:"plyr__controls__item"};return Q(v.array(this.config.controls)?this.config.controls:[]).forEach(l=>{if("restart"===l&&c.appendChild(i.call(this,"restart",u)),"rewind"===l&&c.appendChild(i.call(this,"rewind",u)),"play"===l&&c.appendChild(i.call(this,"play",u)),"fast-forward"===l&&c.appendChild(i.call(this,"fast-forward",u)),"progress"===l){const t=E("div",{class:`${u.class} plyr__progress__container`}),i=E("div",L(this.config.selectors.progress));if(i.appendChild(n.call(this,"seek",{id:`plyr-seek-${e.id}`})),i.appendChild(s.call(this,"buffer")),this.config.tooltips.seek){const e=E("span",{class:this.config.classNames.tooltip},"00:00");i.appendChild(e),this.elements.display.seekTooltip=e}this.elements.progress=i,t.appendChild(this.elements.progress),c.appendChild(t)}if("current-time"===l&&c.appendChild(a.call(this,"currentTime",u)),"duration"===l&&c.appendChild(a.call(this,"duration",u)),"mute"===l||"volume"===l){let{volume:t}=this.elements;if(v.element(t)&&c.contains(t)||(t=E("div",C({},u,{class:`${u.class} plyr__volume`.trim()})),this.elements.volume=t,c.appendChild(t)),"mute"===l&&t.appendChild(i.call(this,"mute")),"volume"===l&&!le.isIos&&!le.isIPadOS){const i={max:1,step:.05,value:this.config.volume};t.appendChild(n.call(this,"volume",C(i,{id:`plyr-volume-${e.id}`})))}}if("captions"===l&&c.appendChild(i.call(this,"captions",u)),"settings"===l&&!v.empty(this.config.settings)){const s=E("div",C({},u,{class:`${u.class} plyr__menu`.trim(),hidden:""}));s.appendChild(i.call(this,"settings",{"aria-haspopup":!0,"aria-controls":`plyr-settings-${e.id}`,"aria-expanded":!1}));const n=E("div",{class:"plyr__menu__container",id:`plyr-settings-${e.id}`,hidden:""}),a=E("div"),l=E("div",{id:`plyr-settings-${e.id}-home`}),r=E("div",{role:"menu"});l.appendChild(r),a.appendChild(l),this.elements.settings.panels.home=l,this.config.settings.forEach(i=>{const s=E("button",C(L(this.config.selectors.buttons.settings),{type:"button",class:`${this.config.classNames.control} ${this.config.classNames.control}--forward`,role:"menuitem","aria-haspopup":!0,hidden:""}));t.call(this,s,i),U.call(this,s,"click",()=>{o.call(this,i,!1)});const n=E("span",null,me.get(i,this.config)),l=E("span",{class:this.config.classNames.menu.value});l.innerHTML=e[i],n.appendChild(l),s.appendChild(n),r.appendChild(s);const c=E("div",{id:`plyr-settings-${e.id}-${i}`,hidden:""}),u=E("button",{type:"button",class:`${this.config.classNames.control} ${this.config.classNames.control}--back`});u.appendChild(E("span",{"aria-hidden":!0},me.get(i,this.config))),u.appendChild(E("span",{class:this.config.classNames.hidden},me.get("menuBack",this.config))),U.call(this,c,"keydown",e=>{"ArrowLeft"===e.key&&(e.preventDefault(),e.stopPropagation(),o.call(this,"home",!0))},!1),U.call(this,u,"click",()=>{o.call(this,"home",!1)}),c.appendChild(u),c.appendChild(E("div",{role:"menu"})),a.appendChild(c),this.elements.settings.buttons[i]=s,this.elements.settings.panels[i]=c}),n.appendChild(a),s.appendChild(n),c.appendChild(s),this.elements.settings.popup=n,this.elements.settings.menu=s}if("pip"===l&&R.pip&&c.appendChild(i.call(this,"pip",u)),"airplay"===l&&R.airplay&&c.appendChild(i.call(this,"airplay",u)),"download"===l){const e=C({},u,{element:"a",href:this.download,target:"_blank"});this.isHTML5&&(e.download="");const{download:t}=this.config.urls;!v.url(t)&&this.isEmbed&&C(e,{icon:`logo-${this.provider}`,label:this.provider}),c.appendChild(i.call(this,"download",e))}"fullscreen"===l&&c.appendChild(i.call(this,"fullscreen",u))}),this.isHTML5&&l.call(this,ae.getQualityOptions.call(this)),r.call(this),c},inject(){if(this.config.loadSprite){const e=Te.getIconUrl.call(this);e.cors&&ve(e.url,"sprite-plyr")}this.id=Math.floor(1e4*Math.random());let e=null;this.elements.controls=null;const t={id:this.id,seektime:this.config.seekTime,title:this.config.title};let i=!0;v.function(this.config.controls)&&(this.config.controls=this.config.controls.call(this,t)),this.config.controls||(this.config.controls=[]),v.element(this.config.controls)||v.string(this.config.controls)?e=this.config.controls:(e=Te.create.call(this,{id:this.id,seektime:this.config.seekTime,speed:this.speed,quality:this.quality,captions:Se.getLabel.call(this)}),i=!1);let s;i&&v.string(this.config.controls)&&(e=(e=>{let i=e;return Object.entries(t).forEach(([e,t])=>{i=oe(i,`{${e}}`,t)}),i})(e)),v.string(this.config.selectors.controls.container)&&(s=document.querySelector(this.config.selectors.controls.container)),v.element(s)||(s=this.elements.container);if(s[v.element(e)?"insertAdjacentElement":"insertAdjacentHTML"]("afterbegin",e),v.element(this.elements.controls)||Te.findElements.call(this),!v.empty(this.elements.buttons)){const e=e=>{const t=this.config.classNames.controlPressed;e.setAttribute("aria-pressed","false"),Object.defineProperty(e,"pressed",{configurable:!0,enumerable:!0,get:()=>O(e,t),set(i=!1){$(e,t,i),e.setAttribute("aria-pressed",i?"true":"false")}})};Object.values(this.elements.buttons).filter(Boolean).forEach(t=>{v.array(t)||v.nodeList(t)?Array.from(t).filter(Boolean).forEach(e):e(t)})}if(le.isEdge&&k(s),this.config.tooltips.controls){const{classNames:e,selectors:t}=this.config,i=`${t.controls.wrapper} ${t.labels} .${e.hidden}`,s=j.call(this,i);Array.from(s).forEach(e=>{$(e,this.config.classNames.hidden,!1),$(e,this.config.classNames.tooltip,!0)})}},setMediaMetadata(){try{"mediaSession"in navigator&&(navigator.mediaSession.metadata=new window.MediaMetadata({title:this.config.mediaMetadata.title,artist:this.config.mediaMetadata.artist,album:this.config.mediaMetadata.album,artwork:this.config.mediaMetadata.artwork}))}catch{}},setMarkers(){var e;if(!this.duration||this.elements.markers)return;const t=null===(e=this.config.markers)||void 0===e||null===(e=e.points)||void 0===e?void 0:e.filter(({time:e})=>e>0&&e$(n,a,e);t.forEach(e=>{const t=E("span",{class:this.config.classNames.marker},""),i=e.time/this.duration*100+"%";n&&(t.addEventListener("mouseenter",()=>{e.label||(n.style.left=i,n.innerHTML=e.label,l(!0))}),t.addEventListener("mouseleave",()=>{l(!1)})),t.addEventListener("click",()=>{this.currentTime=e.time}),t.style.left=i,s.appendChild(t)}),i.appendChild(s),this.config.tooltips.seek||(n=E("span",{class:this.config.classNames.tooltip},""),i.appendChild(n)),this.elements.markers={points:s,tip:n},this.elements.progress.appendChild(i)}};function Ce(e,t=!0){let i=e;if(t){const e=document.createElement("a");e.href=i,i=e.href}try{return new URL(i)}catch{return null}}function Ae(e){const t=new URLSearchParams;return v.object(e)&&Object.entries(e).forEach(([e,i])=>{t.set(e,i)}),t}var Se={setup(){if(!this.supported.ui)return;if(!this.isVideo||this.isYouTube||this.isHTML5&&!R.textTracks)return void(v.array(this.config.controls)&&this.config.controls.includes("settings")&&this.config.settings.includes("captions")&&Te.setCaptionsMenu.call(this));var e,t;if(v.element(this.elements.captions)||(this.elements.captions=E("div",L(this.config.selectors.captions)),this.elements.captions.setAttribute("dir","auto"),e=this.elements.captions,t=this.elements.wrapper,v.element(e)&&v.element(t)&&t.parentNode.insertBefore(e,t.nextSibling)),le.isIE&&window.URL){const e=this.media.querySelectorAll("track");Array.from(e).forEach(e=>{const t=e.getAttribute("src"),i=Ce(t);null!==i&&i.hostname!==window.location.href.hostname&&["http:","https:"].includes(i.protocol)&&be(t,"blob").then(t=>{e.setAttribute("src",window.URL.createObjectURL(t))}).catch(()=>{M(e)})})}const i=Q((navigator.languages||[navigator.language||navigator.userLanguage||"en"]).map(e=>e.split("-")[0]));let s=(this.storage.get("language")||this.captions.language||this.config.captions.language||"auto").toLowerCase();"auto"===s&&([s]=i);let n=this.storage.get("captions")||this.captions.active;if(v.boolean(n)||({active:n}=this.config.captions),Object.assign(this.captions,{toggled:!1,active:n,language:s,languages:i}),this.isHTML5){const e=this.config.captions.update?"addtrack removetrack":"removetrack";U.call(this,this.media.textTracks,e,Se.update.bind(this))}setTimeout(Se.update.bind(this),0)},update(){const e=Se.getTracks.call(this,!0),{active:t,language:i,meta:s,currentTrackNode:n}=this.captions,a=Boolean(e.find(e=>(e.language||"").toLowerCase()===i));this.isHTML5&&this.isVideo&&e.filter(e=>!s.get(e)).forEach(e=>{this.debug.log("Track added",e),s.set(e,{default:"showing"===e.mode}),"showing"===e.mode&&(e.mode="hidden"),U.call(this,e,"cuechange",()=>Se.updateCues.call(this))}),(a&&this.language!==i||!e.includes(n))&&(Se.setLanguage.call(this,i),Se.toggle.call(this,t&&a)),this.elements&&$(this.elements.container,this.config.classNames.captions.enabled,!v.empty(e)),v.array(this.config.controls)&&this.config.controls.includes("settings")&&this.config.settings.includes("captions")&&Te.setCaptionsMenu.call(this)},toggle(e,t=!0){if(!this.supported.ui)return;const{toggled:i}=this.captions,s=this.config.classNames.captions.active,n=v.nullOrUndefined(e)?!i:e;if(n!==i){if(t||(this.captions.active=n,this.storage.set({captions:n})),!this.language&&n&&!t){const e=Se.getTracks.call(this),t=Se.findTrack.call(this,[this.captions.language,...this.captions.languages],!0);return this.captions.language=t.language,void Se.set.call(this,e.indexOf(t))}this.elements.buttons.captions&&(this.elements.buttons.captions.pressed=n),$(this.elements.container,s,n),this.captions.toggled=n,Te.updateSetting.call(this,"captions"),z.call(this,this.media,n?"captionsenabled":"captionsdisabled")}setTimeout(()=>{n&&this.captions.toggled&&(this.captions.currentTrackNode.mode="hidden")})},set(e,t=!0){const i=Se.getTracks.call(this);if(-1!==e)if(v.number(e))if(e in i){if(this.captions.currentTrack!==e){this.captions.currentTrack=e;const s=i[e],{language:n}=s||{};this.captions.currentTrackNode=s,Te.updateSetting.call(this,"captions"),t||(this.captions.language=n,this.storage.set({language:n})),this.isVimeo&&this.embed.enableTextTrack(n,null,!1),z.call(this,this.media,"languagechange")}Se.toggle.call(this,!0,t),this.isHTML5&&this.isVideo&&Se.updateCues.call(this)}else this.debug.warn("Track not found",e);else this.debug.warn("Invalid caption argument",e);else Se.toggle.call(this,!1,t)},setLanguage(e,t=!0){if(!v.string(e))return void this.debug.warn("Invalid language argument",e);const i=e.toLowerCase();this.captions.language=i;const s=Se.getTracks.call(this);let n=s[this.captions.currentTrack];n&&(n.language||"").toLowerCase()!==i&&(n=void 0),n||(n=Se.findTrack.call(this,[i])),Se.set.call(this,s.indexOf(n),t)},getTracks(e=!1){return Array.from((this.media||{}).textTracks||[]).filter(t=>!this.isHTML5||e||this.captions.meta.has(t)).filter(e=>["captions","subtitles"].includes(e.kind))},findTrack(e,t=!1){const i=Se.getTracks.call(this),s=e=>Number((this.captions.meta.get(e)||{}).default),n=Array.from(i).sort((e,t)=>s(t)-s(e));let a;return e.every(e=>(a=n.find(t=>(t.language||"").toLowerCase()===(e||"").toLowerCase()),!a)),a||(t?n[0]:void 0)},getCurrentTrack(){return Se.getTracks.call(this)[this.currentTrack]},getLabel(e){let t=e;return!v.track(t)&&R.textTracks&&this.captions.toggled&&(t=Se.getCurrentTrack.call(this)),v.track(t)?v.empty(t.label)?v.empty(t.language)?me.get("enabled",this.config):e.language.toUpperCase():t.label:me.get("disabled",this.config)},updateCues(e){if(!this.supported.ui)return;if(!v.element(this.elements.captions))return void this.debug.warn("No captions element to render to");if(!v.nullOrUndefined(e)&&!Array.isArray(e))return void this.debug.warn("updateCues: Invalid input",e);let t=e;if(!t){const e=Se.getCurrentTrack.call(this);t=Array.from((e||{}).activeCues||[]).map(e=>e.getCueAsHTML()).map(he)}const i=t.map(e=>e.trim()).join("\n");if(i!==this.elements.captions.innerHTML){N(this.elements.captions);const e=E("span",L(this.config.selectors.caption));e.innerHTML=i,this.elements.captions.appendChild(e),z.call(this,this.media,"cuechange")}}},Ee={enabled:!0,title:"",debug:!1,autoplay:!1,autopause:!0,playsinline:!0,seekTime:10,volume:1,muted:!1,duration:null,displayDuration:!0,invertTime:!0,toggleInvert:!0,ratio:null,clickToPlay:!0,hideControls:!0,resetOnEnd:!1,disableContextMenu:!0,loadSprite:!0,iconPrefix:"plyr",iconUrl:"https://cdn.plyr.io/3.8.5/plyr.svg",blankVideo:"https://cdn.plyr.io/static/blank.mp4",quality:{default:576,options:[4320,2880,2160,1440,1080,720,576,480,360,240],forced:!1,onChange:null},loop:{active:!1},speed:{selected:1,options:[.5,.75,1,1.25,1.5,1.75,2,4]},keyboard:{focused:!0,global:!1},tooltips:{controls:!1,seek:!0},captions:{active:!1,language:"auto",update:!1},fullscreen:{enabled:!0,fallback:!0,iosNative:!1},storage:{enabled:!0,key:"plyr"},controls:["play-large","play","progress","current-time","mute","volume","captions","settings","pip","airplay","fullscreen"],settings:["captions","quality","speed"],i18n:{restart:"Restart",rewind:"Rewind {seektime}s",play:"Play",pause:"Pause",fastForward:"Forward {seektime}s",seek:"Seek",seekLabel:"{currentTime} of {duration}",played:"Played",buffered:"Buffered",currentTime:"Current time",duration:"Duration",volume:"Volume",mute:"Mute",unmute:"Unmute",enableCaptions:"Enable captions",disableCaptions:"Disable captions",download:"Download",enterFullscreen:"Enter fullscreen",exitFullscreen:"Exit fullscreen",frameTitle:"Player for {title}",captions:"Captions",settings:"Settings",pip:"PIP",menuBack:"Go back to previous menu",speed:"Speed",normal:"Normal",quality:"Quality",loop:"Loop",start:"Start",end:"End",all:"All",reset:"Reset",disabled:"Disabled",enabled:"Enabled",advertisement:"Ad",qualityBadge:{2160:"4K",1440:"HD",1080:"HD",720:"HD",576:"SD",480:"SD"}},urls:{download:null,vimeo:{sdk:"https://player.vimeo.com/api/player.js",iframe:"https://player.vimeo.com/video/{0}?{1}",api:"https://vimeo.com/api/oembed.json?url={0}"},youtube:{sdk:"https://www.youtube.com/iframe_api",api:"https://noembed.com/embed?url=https://www.youtube.com/watch?v={0}"},googleIMA:{sdk:"https://imasdk.googleapis.com/js/sdkloader/ima3.js"}},listeners:{seek:null,play:null,pause:null,restart:null,rewind:null,fastForward:null,mute:null,volume:null,captions:null,download:null,fullscreen:null,pip:null,airplay:null,speed:null,quality:null,loop:null,language:null},events:["ended","progress","stalled","playing","waiting","canplay","canplaythrough","loadstart","loadeddata","loadedmetadata","timeupdate","volumechange","play","pause","error","seeking","seeked","emptied","ratechange","cuechange","download","enterfullscreen","exitfullscreen","captionsenabled","captionsdisabled","languagechange","controlshidden","controlsshown","ready","statechange","qualitychange","adsloaded","adscontentpause","adscontentresume","adstarted","adsmidpoint","adscomplete","adsallcomplete","adsimpression","adsclick"],selectors:{editable:"input, textarea, select, [contenteditable]",container:".plyr",controls:{container:null,wrapper:".plyr__controls"},labels:"[data-plyr]",buttons:{play:'[data-plyr="play"]',pause:'[data-plyr="pause"]',restart:'[data-plyr="restart"]',rewind:'[data-plyr="rewind"]',fastForward:'[data-plyr="fast-forward"]',mute:'[data-plyr="mute"]',captions:'[data-plyr="captions"]',download:'[data-plyr="download"]',fullscreen:'[data-plyr="fullscreen"]',pip:'[data-plyr="pip"]',airplay:'[data-plyr="airplay"]',settings:'[data-plyr="settings"]',loop:'[data-plyr="loop"]'},inputs:{seek:'[data-plyr="seek"]',volume:'[data-plyr="volume"]',speed:'[data-plyr="speed"]',language:'[data-plyr="language"]',quality:'[data-plyr="quality"]'},display:{currentTime:".plyr__time--current",duration:".plyr__time--duration",buffer:".plyr__progress__buffer",loop:".plyr__progress__loop",volume:".plyr__volume--display"},progress:".plyr__progress",captions:".plyr__captions",caption:".plyr__caption"},classNames:{type:"plyr--{0}",provider:"plyr--{0}",video:"plyr__video-wrapper",embed:"plyr__video-embed",videoFixedRatio:"plyr__video-wrapper--fixed-ratio",embedContainer:"plyr__video-embed__container",poster:"plyr__poster",posterEnabled:"plyr__poster-enabled",ads:"plyr__ads",control:"plyr__control",controlPressed:"plyr__control--pressed",playing:"plyr--playing",paused:"plyr--paused",stopped:"plyr--stopped",loading:"plyr--loading",hover:"plyr--hover",tooltip:"plyr__tooltip",cues:"plyr__cues",marker:"plyr__progress__marker",hidden:"plyr__sr-only",hideControls:"plyr--hide-controls",isTouch:"plyr--is-touch",uiSupported:"plyr--full-ui",noTransition:"plyr--no-transition",display:{time:"plyr__time"},menu:{value:"plyr__menu__value",badge:"plyr__badge",open:"plyr--menu-open"},captions:{enabled:"plyr--captions-enabled",active:"plyr--captions-active"},fullscreen:{enabled:"plyr--fullscreen-enabled",fallback:"plyr--fullscreen-fallback"},pip:{supported:"plyr--pip-supported",active:"plyr--pip-active"},airplay:{supported:"plyr--airplay-supported",active:"plyr--airplay-active"},previewThumbnails:{thumbContainer:"plyr__preview-thumb",thumbContainerShown:"plyr__preview-thumb--is-shown",imageContainer:"plyr__preview-thumb__image-container",timeContainer:"plyr__preview-thumb__time-container",scrubbingContainer:"plyr__preview-scrubbing",scrubbingContainerShown:"plyr__preview-scrubbing--is-shown"}},attributes:{embed:{provider:"data-plyr-provider",id:"data-plyr-embed-id",hash:"data-plyr-embed-hash"}},ads:{enabled:!1,publisherId:"",tagUrl:""},previewThumbnails:{enabled:!1,src:"",withCredentials:!1},vimeo:{byline:!1,portrait:!1,title:!1,speed:!0,transparent:!1,customControls:!0,referrerPolicy:null,premium:!1},youtube:{rel:0,showinfo:0,iv_load_policy:3,modestbranding:1,customControls:!0,noCookie:!1},mediaMetadata:{title:"",artist:"",album:"",artwork:[]},markers:{enabled:!1,points:[]}},Pe="picture-in-picture",Me="inline",Ne={html5:"html5",youtube:"youtube",vimeo:"vimeo"},xe="audio",Le="video";function Ie(){}var $e=class{constructor(e=!1){this.enabled=window.console&&e,this.enabled&&this.log("Debugging enabled")}get log(){return this.enabled?Function.prototype.bind.call(console.log,console):Ie}get warn(){return this.enabled?Function.prototype.bind.call(console.warn,console):Ie}get error(){return this.enabled?Function.prototype.bind.call(console.error,console):Ie}},Oe=class e{constructor(t){fe(this,"onChange",()=>{if(!this.supported)return;const e=this.player.elements.buttons.fullscreen;v.element(e)&&(e.pressed=this.active);const t=this.target===this.player.media?this.target:this.player.elements.container;z.call(this.player,t,this.active?"enterfullscreen":"exitfullscreen",!0)}),fe(this,"toggleFallback",(e=!1)=>{var t,i;e?this.scrollPosition={x:null!==(t=window.scrollX)&&void 0!==t?t:0,y:null!==(i=window.scrollY)&&void 0!==i?i:0}:window.scrollTo(this.scrollPosition.x,this.scrollPosition.y);if(document.body.style.overflow=e?"hidden":"",$(this.target,this.player.config.classNames.fullscreen.fallback,e),le.isIos){let t=document.head.querySelector('meta[name="viewport"]');const i="viewport-fit=cover";t||(t=document.createElement("meta"),t.setAttribute("name","viewport"));const s=v.string(t.content)&&t.content.includes(i);e?(this.cleanupViewport=!s,s||(t.content+=`,${i}`)):this.cleanupViewport&&(t.content=t.content.split(",").filter(e=>e.trim()!==i).join(","))}this.onChange()}),fe(this,"trapFocus",e=>{if(le.isIos||le.isIPadOS||!this.active||"Tab"!==e.key)return;const t=document.activeElement,i=j.call(this.player,"a[href], button:not(:disabled), input:not(:disabled), [tabindex]"),[s]=i,n=i[i.length-1];t!==n||e.shiftKey?t===s&&e.shiftKey&&(n.focus(),e.preventDefault()):(s.focus(),e.preventDefault())}),fe(this,"update",()=>{if(this.supported){let t;t=this.forceFallback?"Fallback (forced)":e.nativeSupported?"Native":"Fallback",this.player.debug.log(`${t} fullscreen enabled`)}else this.player.debug.log("Fullscreen not supported and fallback disabled");$(this.player.elements.container,this.player.config.classNames.fullscreen.enabled,this.supported)}),fe(this,"enter",()=>{this.supported&&(le.isIos&&this.player.config.fullscreen.iosNative?this.player.isVimeo?this.player.embed.requestFullscreen():this.target.webkitEnterFullscreen():!e.nativeSupported||this.forceFallback?this.toggleFallback(!0):this.prefix?v.empty(this.prefix)||this.target[`${this.prefix}Request${this.property}`]():this.target.requestFullscreen({navigationUI:"hide"}))}),fe(this,"exit",()=>{if(this.supported)if(le.isIos&&this.player.config.fullscreen.iosNative)this.player.isVimeo?this.player.embed.exitFullscreen():this.target.webkitEnterFullscreen(),X(this.player.play());else if(!e.nativeSupported||this.forceFallback)this.toggleFallback(!1);else if(this.prefix){if(!v.empty(this.prefix)){const e="moz"===this.prefix?"Cancel":"Exit";document[`${this.prefix}${e}${this.property}`]()}}else(document.cancelFullScreen||document.exitFullscreen).call(document)}),fe(this,"toggle",()=>{this.active?this.exit():this.enter()}),this.player=t,this.prefix=e.prefix,this.property=e.property,this.scrollPosition={x:0,y:0},this.forceFallback="force"===t.config.fullscreen.fallback,this.player.elements.fullscreen=t.config.fullscreen.container&&function(e,t){const{prototype:i}=Element;return(i.closest||function(){let e=this;do{if(_.matches(e,t))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType);return null}).call(e,t)}(this.player.elements.container,t.config.fullscreen.container),U.call(this.player,document,"ms"===this.prefix?"MSFullscreenChange":`${this.prefix}fullscreenchange`,()=>{this.onChange()}),U.call(this.player,this.player.elements.container,"dblclick",e=>{v.element(this.player.elements.controls)&&this.player.elements.controls.contains(e.target)||this.player.listeners.proxy(e,this.toggle,"fullscreen")}),U.call(this,this.player.elements.container,"keydown",e=>this.trapFocus(e)),this.update()}static get nativeSupported(){return!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)}get useNative(){return e.nativeSupported&&!this.forceFallback}static get prefix(){if(v.function(document.exitFullscreen))return"";let e="";return["webkit","moz","ms"].some(t=>!(!v.function(document[`${t}ExitFullscreen`])&&!v.function(document[`${t}CancelFullScreen`]))&&(e=t,!0)),e}static get property(){return"moz"===this.prefix?"FullScreen":"Fullscreen"}get supported(){return[this.player.config.fullscreen.enabled,this.player.isVideo,e.nativeSupported||this.player.config.fullscreen.fallback,!this.player.isYouTube||e.nativeSupported||!le.isIos||this.player.config.playsinline&&!this.player.config.fullscreen.iosNative].every(Boolean)}get active(){if(!this.supported)return!1;if(!e.nativeSupported||this.forceFallback)return O(this.target,this.player.config.classNames.fullscreen.fallback);const t=this.prefix?this.target.getRootNode()[`${this.prefix}${this.property}Element`]:this.target.getRootNode().fullscreenElement;return t&&t.shadowRoot?t===this.target.getRootNode().host:t===this.target}get target(){var e;return le.isIos&&this.player.config.fullscreen.iosNative?this.player.media:null!==(e=this.player.elements.fullscreen)&&void 0!==e?e:this.player.elements.container}};function _e(e,t=1){return new Promise((i,s)=>{const n=new Image,a=()=>{delete n.onload,delete n.onerror,(n.naturalWidth>=t?i:s)(n)};Object.assign(n,{onload:a,onerror:a,src:e})})}var je={addStyleHook(){$(this.elements.container,this.config.selectors.container.replace(".",""),!0),$(this.elements.container,this.config.classNames.uiSupported,this.supported.ui)},toggleNativeControls(e=!1){e&&this.isHTML5?this.media.setAttribute("controls",""):this.media.removeAttribute("controls")},build(){if(this.listeners.media(),!this.supported.ui)return this.debug.warn(`Basic support only for ${this.provider} ${this.type}`),void je.toggleNativeControls.call(this,!0);v.element(this.elements.controls)||(Te.inject.call(this),this.listeners.controls()),je.toggleNativeControls.call(this),this.isHTML5&&Se.setup.call(this),this.volume=null,this.muted=null,this.loop=null,this.quality=null,this.speed=null,Te.updateVolume.call(this),Te.timeUpdate.call(this),Te.durationUpdate.call(this),je.checkPlaying.call(this),$(this.elements.container,this.config.classNames.pip.supported,R.pip&&this.isHTML5&&this.isVideo),$(this.elements.container,this.config.classNames.airplay.supported,R.airplay&&this.isHTML5),$(this.elements.container,this.config.classNames.isTouch,this.touch),this.ready=!0,setTimeout(()=>{z.call(this,this.media,"ready")},0),je.setTitle.call(this),this.poster&&je.setPoster.call(this,this.poster,!1).catch(()=>{}),this.config.duration&&Te.durationUpdate.call(this),this.config.mediaMetadata&&Te.setMediaMetadata.call(this)},setTitle(){let e=me.get("play",this.config);if(v.string(this.config.title)&&!v.empty(this.config.title)&&(e+=`, ${this.config.title}`),Array.from(this.elements.buttons.play||[]).forEach(t=>{t.setAttribute("aria-label",e)}),this.isEmbed){const e=q.call(this,"iframe");if(!v.element(e))return;const t=v.empty(this.config.title)?"video":this.config.title,i=me.get("frameTitle",this.config);e.setAttribute("title",i.replace("{title}",t))}},togglePoster(e){$(this.elements.container,this.config.classNames.posterEnabled,e)},setPoster(e,t=!0){return t&&this.poster?Promise.reject(new Error("Poster already set")):(this.media.setAttribute("data-poster",e),this.elements.poster.removeAttribute("hidden"),Y.call(this).then(()=>_e(e)).catch(t=>{throw e===this.poster&&je.togglePoster.call(this,!1),t}).then(()=>{if(e!==this.poster)throw new Error("setPoster cancelled by later call to setPoster")}).then(()=>(Object.assign(this.elements.poster.style,{backgroundImage:`url('${e}')`,backgroundSize:""}),je.togglePoster.call(this,!0),e)))},checkPlaying(e){$(this.elements.container,this.config.classNames.playing,this.playing),$(this.elements.container,this.config.classNames.paused,this.paused),$(this.elements.container,this.config.classNames.stopped,this.stopped),Array.from(this.elements.buttons.play||[]).forEach(e=>{Object.assign(e,{pressed:this.playing}),e.setAttribute("aria-label",me.get(this.playing?"pause":"play",this.config))}),v.event(e)&&"timeupdate"===e.type||je.toggleControls.call(this)},checkLoading(e){this.loading=["stalled","waiting"].includes(e.type),clearTimeout(this.timers.loading),this.timers.loading=setTimeout(()=>{$(this.elements.container,this.config.classNames.loading,this.loading),je.toggleControls.call(this)},this.loading?250:0)},toggleControls(e){const{controls:t}=this.elements;if(t&&this.config.hideControls){const i=this.touch&&this.lastSeekTime+2e3>Date.now();this.toggleControls(Boolean(e||this.loading||this.paused||t.pressed||t.hover||i))}},migrateStyles(){Object.values({...this.media.style}).filter(e=>!v.empty(e)&&v.string(e)&&e.startsWith("--plyr")).forEach(e=>{this.elements.container.style.setProperty(e,this.media.style.getPropertyValue(e)),this.media.style.removeProperty(e)}),v.empty(this.media.style)&&this.media.removeAttribute("style")}};function qe(e){const t=!(e.muted||0===e.volume);t||0!==e.volume||(e.volume=e.lastVolume>0?e.lastVolume:Ee.volume),e.muted=t}var De=class{constructor(e){fe(this,"firstTouch",()=>{const{player:e}=this,{elements:t}=e;e.touch=!0,$(t.container,e.config.classNames.isTouch,!0)}),fe(this,"global",(e=!0)=>{const{player:t}=this;t.config.keyboard.global&&F.call(t,window,"keydown keyup",this.handleKey,e,!1),F.call(t,document.body,"click",this.toggleMenu,e),W.call(t,document.body,"touchstart",this.firstTouch)}),fe(this,"container",()=>{const{player:e}=this,{config:t,elements:i,timers:s}=e;!t.keyboard.global&&t.keyboard.focused&&U.call(e,i.container,"keydown keyup",this.handleKey,!1),U.call(e,i.container,"mousemove mouseleave touchstart touchmove enterfullscreen exitfullscreen",t=>{const{controls:n}=i;n&&"enterfullscreen"===t.type&&(n.pressed=!1,n.hover=!1);let a=0;["touchstart","touchmove","mousemove"].includes(t.type)&&(je.toggleControls.call(e,!0),a=e.touch?3e3:2e3),clearTimeout(s.controls),s.controls=setTimeout(()=>je.toggleControls.call(e,!1),a)});const n=()=>{if(!e.isVimeo||e.config.vimeo.premium)return;const t=i.wrapper,{active:s}=e.fullscreen,[n,a]=ie.call(e),l=G(`aspect-ratio: ${n} / ${a}`);if(!s)return void(l?(t.style.width=null,t.style.height=null):(t.style.maxWidth=null,t.style.margin=null));const[r,o]=[Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),Math.max(document.documentElement.clientHeight||0,window.innerHeight||0)],c=r/o>n/a;l?(t.style.width=c?"auto":"100%",t.style.height=c?"100%":"auto"):(t.style.maxWidth=c?o/a*n+"px":null,t.style.margin=c?"0 auto":null)},a=()=>{clearTimeout(s.resized),s.resized=setTimeout(n,50)};U.call(e,i.container,"enterfullscreen exitfullscreen",t=>{const{target:s}=e.fullscreen;s===i.container&&(!e.isEmbed&&v.empty(e.config.ratio)||(n(),("enterfullscreen"===t.type?U:B).call(e,window,"resize",a)))})}),fe(this,"media",()=>{const{player:e}=this,{elements:t}=e;if(U.call(e,e.media,"timeupdate seeking seeked",t=>Te.timeUpdate.call(e,t)),U.call(e,e.media,"durationchange loadeddata loadedmetadata",t=>Te.durationUpdate.call(e,t)),U.call(e,e.media,"ended",()=>{e.isHTML5&&e.isVideo&&e.config.resetOnEnd&&(e.restart(),e.pause())}),U.call(e,e.media,"progress playing seeking seeked",t=>Te.updateProgress.call(e,t)),U.call(e,e.media,"volumechange",t=>Te.updateVolume.call(e,t)),U.call(e,e.media,"playing play pause ended emptied timeupdate",t=>je.checkPlaying.call(e,t)),U.call(e,e.media,"waiting canplay seeked playing",t=>je.checkLoading.call(e,t)),e.supported.ui&&e.config.clickToPlay&&!e.isAudio){const i=q.call(e,`.${e.config.classNames.video}`);if(!v.element(i))return;U.call(e,t.container,"click",s=>{([t.container,i].includes(s.target)||i.contains(s.target))&&(e.touch&&e.config.hideControls||(e.ended?(this.proxy(s,e.restart,"restart"),this.proxy(s,()=>{X(e.play())},"play")):this.proxy(s,()=>{X(e.togglePlay())},"play")))})}e.supported.ui&&e.config.disableContextMenu&&U.call(e,t.wrapper,"contextmenu",e=>{e.preventDefault()},!1),U.call(e,e.media,"volumechange",()=>{e.storage.set({volume:e.volume,muted:e.muted})}),U.call(e,e.media,"ratechange",()=>{Te.updateSetting.call(e,"speed"),e.storage.set({speed:e.speed})}),U.call(e,e.media,"qualitychange",t=>{Te.updateSetting.call(e,"quality",null,t.detail.quality)}),U.call(e,e.media,"ready qualitychange",()=>{Te.setDownloadUrl.call(e)});const i=e.config.events.concat(["keyup","keydown"]).join(" ");U.call(e,e.media,i,i=>{let{detail:s={}}=i;"error"===i.type&&(s=e.media.error),z.call(e,t.container,i.type,!0,s)})}),fe(this,"proxy",(e,t,i)=>{const{player:s}=this,n=s.config.listeners[i];let a=!0;v.function(n)&&(a=n.call(s,e)),!1!==a&&v.function(t)&&t.call(s,e)}),fe(this,"bind",(e,t,i,s,n=!0)=>{const{player:a}=this,l=a.config.listeners[s],r=v.function(l);U.call(a,e,t,e=>this.proxy(e,i,s),n&&!r)}),fe(this,"controls",()=>{const{player:e}=this,{elements:t}=e,i=le.isIE?"change":"input";if(t.buttons.play&&Array.from(t.buttons.play).forEach(t=>{this.bind(t,"click",()=>{X(e.togglePlay())},"play")}),this.bind(t.buttons.restart,"click",e.restart,"restart"),this.bind(t.buttons.rewind,"click",()=>{e.lastSeekTime=Date.now(),e.rewind()},"rewind"),this.bind(t.buttons.fastForward,"click",()=>{e.lastSeekTime=Date.now(),e.forward()},"fastForward"),this.bind(t.buttons.mute,"click",()=>{qe(e)},"mute"),this.bind(t.buttons.captions,"click",()=>e.toggleCaptions()),this.bind(t.buttons.download,"click",()=>{z.call(e,e.media,"download")},"download"),this.bind(t.buttons.fullscreen,"click",()=>{e.fullscreen.toggle()},"fullscreen"),this.bind(t.buttons.pip,"click",()=>{e.pip="toggle"},"pip"),this.bind(t.buttons.airplay,"click",e.airplay,"airplay"),this.bind(t.buttons.settings,"click",t=>{t.stopPropagation(),t.preventDefault(),Te.toggleMenu.call(e,t)},null,!1),this.bind(t.buttons.settings,"keyup",t=>{[" ","Enter"].includes(t.key)&&("Enter"!==t.key?(t.preventDefault(),t.stopPropagation(),Te.toggleMenu.call(e,t)):Te.focusFirstMenuItem.call(e,null,!0))},null,!1),this.bind(t.settings.menu,"keydown",t=>{"Escape"===t.key&&Te.toggleMenu.call(e,t)}),this.bind(t.inputs.seek,"mousedown mousemove",e=>{const i=t.progress.getBoundingClientRect(),s=e.pageX-e.clientX,n=100/i.width*(e.pageX-i.left-s);e.currentTarget.setAttribute("seek-value",n)}),this.bind(t.inputs.seek,"mousedown mouseup keydown keyup touchstart touchend",t=>{const i=t.currentTarget,s="play-on-seeked";if(v.keyboardEvent(t)&&!["ArrowLeft","ArrowRight"].includes(t.key))return;e.lastSeekTime=Date.now();const n=i.hasAttribute(s),a=["mouseup","touchend","keyup"].includes(t.type);n&&a?(i.removeAttribute(s),X(e.play())):!a&&e.playing&&(i.setAttribute(s,""),e.pause())}),le.isIos){const t=j.call(e,'input[type="range"]');Array.from(t).forEach(e=>this.bind(e,i,e=>k(e.target)))}this.bind(t.inputs.seek,i,t=>{const i=t.currentTarget;let s=i.getAttribute("seek-value");v.empty(s)&&(s=i.value),i.removeAttribute("seek-value"),e.currentTime=s/i.max*e.duration},"seek"),this.bind(t.progress,"mouseenter mouseleave mousemove",t=>Te.updateSeekTooltip.call(e,t)),this.bind(t.progress,"mousemove touchmove",t=>{const{previewThumbnails:i}=e;i&&i.loaded&&i.startMove(t)}),this.bind(t.progress,"mouseleave touchend click",()=>{const{previewThumbnails:t}=e;t&&t.loaded&&t.endMove(!1,!0)}),this.bind(t.progress,"mousedown touchstart",t=>{const{previewThumbnails:i}=e;i&&i.loaded&&i.startScrubbing(t)}),this.bind(t.progress,"mouseup touchend",t=>{const{previewThumbnails:i}=e;i&&i.loaded&&i.endScrubbing(t)}),le.isWebKit&&Array.from(j.call(e,'input[type="range"]')).forEach(t=>{this.bind(t,"input",t=>Te.updateRangeFill.call(e,t.target))}),e.config.toggleInvert&&!v.element(t.display.duration)&&this.bind(t.display.currentTime,"click",()=>{0!==e.currentTime&&(e.config.invertTime=!e.config.invertTime,Te.timeUpdate.call(e))}),this.bind(t.inputs.volume,i,t=>{e.volume=t.target.value},"volume"),"change"!==i&&this.bind(t.inputs.volume,"change",t=>{const i=Number(t.target.value);i>0&&(e.lastVolume=i)}),this.bind(t.controls,"mouseenter mouseleave",i=>{t.controls.hover=!e.touch&&"mouseenter"===i.type}),t.fullscreen&&Array.from(t.fullscreen.children).filter(e=>!e.contains(t.container)).forEach(i=>{this.bind(i,"mouseenter mouseleave",i=>{t.controls&&(t.controls.hover=!e.touch&&"mouseenter"===i.type)})}),this.bind(t.controls,"mousedown mouseup touchstart touchend touchcancel",e=>{t.controls.pressed=["mousedown","touchstart"].includes(e.type)}),this.bind(t.controls,"focusin",()=>{const{config:i,timers:s}=e;$(t.controls,i.classNames.noTransition,!0),je.toggleControls.call(e,!0),setTimeout(()=>{$(t.controls,i.classNames.noTransition,!1)},0);const n=this.touch?3e3:4e3;clearTimeout(s.controls),s.controls=setTimeout(()=>je.toggleControls.call(e,!1),n)}),this.bind(t.inputs.volume,"wheel",t=>{const i=t.webkitDirectionInvertedFromDevice,[s,n]=[t.deltaX,-t.deltaY].map(e=>i?-e:e),a=Math.sign(Math.abs(s)>Math.abs(n)?s:n);e.increaseVolume(a/50);const{volume:l}=e.media;(1===a&&l<1||-1===a&&l>0)&&t.preventDefault()},"volume",!1)}),this.player=e,this.lastKey=null,this.focusTimer=null,this.lastKeyDown=null,this.handleKey=this.handleKey.bind(this),this.toggleMenu=this.toggleMenu.bind(this),this.firstTouch=this.firstTouch.bind(this)}handleKey(e){const{player:t}=this,{elements:i}=t,{key:s,type:n,altKey:a,ctrlKey:l,metaKey:r,shiftKey:o}=e,c="keydown"===n,u=c&&s===this.lastKey;if(a||l||r||o)return;if(!s)return;if(c){const n=document.activeElement;if(v.element(n)){const{editable:s}=t.config.selectors,{seek:a}=i.inputs;if(n!==a&&_(n,s))return;if(" "===e.key&&_(n,'button, [role^="menuitem"]'))return}switch([" ","ArrowLeft","ArrowUp","ArrowRight","ArrowDown","0","1","2","3","4","5","6","7","8","9","c","f","k","l","m"].includes(s)&&(e.preventDefault(),e.stopPropagation()),s){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":u||(h=Number.parseInt(s,10),t.currentTime=t.duration/10*h);break;case" ":case"k":u||X(t.togglePlay());break;case"ArrowUp":t.increaseVolume(.1);break;case"ArrowDown":t.decreaseVolume(.1);break;case"m":u||qe(t);break;case"ArrowRight":t.forward();break;case"ArrowLeft":t.rewind();break;case"f":t.fullscreen.toggle();break;case"c":u||t.toggleCaptions();break;case"l":t.loop=!t.loop}"Escape"===s&&!t.fullscreen.usingNative&&t.fullscreen.active&&t.fullscreen.toggle(),this.lastKey=s}else this.lastKey=null;var h}toggleMenu(e){Te.toggleMenu.call(this.player,e)}},He=r(l((e,t)=>{var i,s;i=e,s=function(){var e=function(){},t={},i={},s={};function n(e,t){if(e){var n=s[e];if(i[e]=t,n)for(;n.length;)n[0](e,t),n.splice(0,1)}}function a(t,i){t.call&&(t={success:t}),i.length?(t.error||e)(i):(t.success||e)(t)}function l(t,i,s,n){var a,r,o,c=document,u=s.async,h=(s.numRetries||0)+1,d=s.before||e,m=t.replace(/[\?|#].*$/,""),p=t.replace(/^(css|img|module|nomodule)!/,"");if(n=n||0,/(^css!|\.css$)/.test(m))(o=c.createElement("link")).rel="stylesheet",o.href=p,(a="hideFocus"in o)&&o.relList&&(a=0,o.rel="preload",o.as="style");else if(/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(m))(o=c.createElement("img")).src=p;else if((o=c.createElement("script")).src=p,o.async=void 0===u||u,r="noModule"in o,/^module!/.test(m)){if(!r)return i(t,"l");o.type="module"}else if(/^nomodule!/.test(m)&&r)return i(t,"l");o.onload=o.onerror=o.onbeforeload=function(e){var r=e.type[0];if(a)try{o.sheet.cssText.length||(r="e")}catch(c){18!=c.code&&(r="e")}if("e"==r){if((n+=1){(0,He.default)(e,{success:t,error:i})})}function Ve(e){e&&!this.embed.hasPlayed&&(this.embed.hasPlayed=!0),this.media.paused===e&&(this.media.paused=!e,z.call(this,this.media,e?"play":"pause"))}var Fe={setup(){const e=this;$(e.elements.wrapper,e.config.classNames.embed,!0),e.options.speed=e.config.speed.options,se.call(e),v.object(window.Vimeo)?Fe.ready.call(e):Re(e.config.urls.vimeo.sdk).then(()=>{Fe.ready.call(e)}).catch(t=>{e.debug.warn("Vimeo SDK (player.js) failed to load",t)})},ready(){const e=this,t=e.config.vimeo,{premium:i,referrerPolicy:s,...n}=t;let a=e.media.getAttribute("src"),l="";v.empty(a)?(a=e.media.getAttribute(e.config.attributes.embed.id),l=e.media.getAttribute(e.config.attributes.embed.hash)):l=function(e){const t=e.match(/^.*(vimeo.com\/|video\/)(\d+)(\?.*h=|\/)+([\d,a-f]+)/);return t&&5===t.length?t[4]:null}(a);const r=l?{h:l}:{};i&&Object.assign(n,{controls:!1,sidedock:!1});const o=Ae({loop:e.config.loop.active,autoplay:e.autoplay,muted:e.muted,gesture:"media",playsinline:e.config.playsinline,...r,...n}),c=function(e){if(v.empty(e))return null;if(v.number(Number(e)))return e;const t=e.match(/^.*(vimeo.com\/|video\/)(\d+).*/);return t?t[2]:e}(a),u=E("iframe"),h=re(e.config.urls.vimeo.iframe,c,o);if(u.setAttribute("src",h),u.setAttribute("allowfullscreen",""),u.setAttribute("allow",["autoplay","fullscreen","picture-in-picture","encrypted-media","accelerometer","gyroscope"].join("; ")),v.empty(s)||u.setAttribute("referrerPolicy",s),i||!t.customControls)u.setAttribute("data-poster",e.poster),e.media=x(u,e.media);else{const t=E("div",{class:e.config.classNames.embedContainer,"data-poster":e.poster});t.appendChild(u),e.media=x(t,e.media)}t.customControls||be(re(e.config.urls.vimeo.api,h)).then(t=>{!v.empty(t)&&t.thumbnail_url&&je.setPoster.call(e,t.thumbnail_url).catch(()=>{})}),e.embed=new window.Vimeo.Player(u,{autopause:e.config.autopause,muted:e.muted}),e.media.paused=!0,e.media.currentTime=0,e.supported.ui&&e.embed.disableTextTrack(),e.media.play=()=>(Ve.call(e,!0),e.embed.play()),e.media.pause=()=>(Ve.call(e,!1),e.embed.pause()),e.media.stop=()=>{e.pause(),e.currentTime=0};let{currentTime:d}=e.media;Object.defineProperty(e.media,"currentTime",{get:()=>d,set(t){const{embed:i,media:s,paused:n,volume:a}=e,l=n&&!i.hasPlayed;s.seeking=!0,z.call(e,s,"seeking"),Promise.resolve(l&&i.setVolume(0)).then(()=>i.setCurrentTime(t)).then(()=>l&&i.pause()).then(()=>l&&i.setVolume(a)).catch(()=>{})}});let m=e.config.speed.selected;Object.defineProperty(e.media,"playbackRate",{get:()=>m,set(t){e.embed.setPlaybackRate(t).then(()=>{m=t,z.call(e,e.media,"ratechange")}).catch(()=>{e.options.speed=[1]})}});let{volume:p}=e.config;Object.defineProperty(e.media,"volume",{get:()=>p,set(t){e.embed.setVolume(t).then(()=>{p=t,z.call(e,e.media,"volumechange")})}});let{muted:g}=e.config;Object.defineProperty(e.media,"muted",{get:()=>g,set(t){const i=!!v.boolean(t)&&t;e.embed.setMuted(!!i||e.config.muted).then(()=>{g=i,z.call(e,e.media,"volumechange")})}});let f,{loop:y}=e.config;Object.defineProperty(e.media,"loop",{get:()=>y,set(t){const i=v.boolean(t)?t:e.config.loop.active;e.embed.setLoop(i).then(()=>{y=i})}}),e.embed.getVideoUrl().then(t=>{f=t,Te.setDownloadUrl.call(e)}).catch(e=>{this.debug.warn(e)}),Object.defineProperty(e.media,"currentSrc",{get:()=>f}),Object.defineProperty(e.media,"ended",{get:()=>e.currentTime===e.duration}),Promise.all([e.embed.getVideoWidth(),e.embed.getVideoHeight()]).then(t=>{const[i,s]=t;e.embed.ratio=ne(i,s),se.call(this)}),e.embed.setAutopause(e.config.autopause).then(t=>{e.config.autopause=t}),e.embed.getVideoTitle().then(t=>{e.config.title=t,je.setTitle.call(this)}),e.embed.getCurrentTime().then(t=>{d=t,z.call(e,e.media,"timeupdate")}),e.embed.getDuration().then(t=>{e.media.duration=t,z.call(e,e.media,"durationchange")}),e.embed.getTextTracks().then(t=>{e.media.textTracks=t,Se.setup.call(e)}),e.embed.on("cuechange",({cues:t=[]})=>{const i=t.map(e=>function(e){const t=document.createDocumentFragment(),i=document.createElement("div");return t.appendChild(i),i.innerHTML=e,t.firstChild.textContent}(e.text));Se.updateCues.call(e,i)}),e.embed.on("loaded",()=>{e.embed.getPaused().then(t=>{Ve.call(e,!t),t||z.call(e,e.media,"playing")}),v.element(e.embed.element)&&e.supported.ui&&e.embed.element.setAttribute("tabindex",-1)}),e.embed.on("bufferstart",()=>{z.call(e,e.media,"waiting")}),e.embed.on("bufferend",()=>{z.call(e,e.media,"playing")}),e.embed.on("play",()=>{Ve.call(e,!0),z.call(e,e.media,"playing")}),e.embed.on("pause",()=>{Ve.call(e,!1)}),e.embed.on("timeupdate",t=>{e.media.seeking=!1,d=t.seconds,z.call(e,e.media,"timeupdate")}),e.embed.on("progress",t=>{e.media.buffered=t.percent,z.call(e,e.media,"progress"),1===Number.parseInt(t.percent,10)&&z.call(e,e.media,"canplaythrough"),e.embed.getDuration().then(t=>{t!==e.media.duration&&(e.media.duration=t,z.call(e,e.media,"durationchange"))})}),e.embed.on("seeked",()=>{e.media.seeking=!1,z.call(e,e.media,"seeked")}),e.embed.on("ended",()=>{e.media.paused=!0,z.call(e,e.media,"ended")}),e.embed.on("error",t=>{e.media.error=t,z.call(e,e.media,"error")}),t.customControls&&setTimeout(()=>je.build.call(e),0)}};function Ue(e){e&&!this.embed.hasPlayed&&(this.embed.hasPlayed=!0),this.media.paused===e&&(this.media.paused=!e,z.call(this,this.media,e?"play":"pause"))}function Be(e){return e.noCookie?"https://www.youtube-nocookie.com":"http:"===window.location.protocol?"http://www.youtube.com":void 0}var We={setup(){if($(this.elements.wrapper,this.config.classNames.embed,!0),v.object(window.YT)&&v.function(window.YT.Player))We.ready.call(this);else{const e=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{v.function(e)&&e(),We.ready.call(this)},Re(this.config.urls.youtube.sdk).catch(e=>{this.debug.warn("YouTube API failed to load",e)})}},getTitle(e){be(re(this.config.urls.youtube.api,e)).then(e=>{if(v.object(e)){const{title:t,height:i,width:s}=e;this.config.title=t,je.setTitle.call(this),this.embed.ratio=ne(s,i)}se.call(this)}).catch(()=>{se.call(this)})},ready(){const e=this,t=e.config.youtube,i=e.media&&e.media.getAttribute("id");if(!v.empty(i)&&i.startsWith("youtube-"))return;let s=e.media.getAttribute("src");v.empty(s)&&(s=e.media.getAttribute(this.config.attributes.embed.id));const n=function(e){if(v.empty(e))return null;const t=e.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/);return t&&t[2]?t[2]:e}(s);const a=E("div",{id:`${e.provider}-${Math.floor(1e4*Math.random())}`,"data-poster":t.customControls?e.poster:void 0});if(e.media=x(a,e.media),t.customControls){const t=e=>`https://i.ytimg.com/vi/${n}/${e}default.jpg`;_e(t("maxres"),121).catch(()=>_e(t("sd"),121)).catch(()=>_e(t("hq"))).then(t=>je.setPoster.call(e,t.src)).then(t=>{t.includes("maxres")||(e.elements.poster.style.backgroundSize="cover")}).catch(()=>{})}e.embed=new window.YT.Player(e.media,{videoId:n,host:Be(t),playerVars:C({},{autoplay:e.config.autoplay?1:0,hl:e.config.hl,controls:e.supported.ui&&t.customControls?0:1,disablekb:1,playsinline:e.config.playsinline&&!e.config.fullscreen.iosNative?1:0,cc_load_policy:e.captions.active?1:0,cc_lang_pref:e.config.captions.language,widget_referrer:window?window.location.href:null},t),events:{onError(t){if(!e.media.error){const i=t.data,s={2:"The request contains an invalid parameter value. For example, this error occurs if you specify a video ID that does not have 11 characters, or if the video ID contains invalid characters, such as exclamation points or asterisks.",5:"The requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred.",100:"The video requested was not found. This error occurs when a video has been removed (for any reason) or has been marked as private.",101:"The owner of the requested video does not allow it to be played in embedded players.",150:"The owner of the requested video does not allow it to be played in embedded players."}[i]||"An unknown error occurred";e.media.error={code:i,message:s},z.call(e,e.media,"error")}},onPlaybackRateChange(t){const i=t.target;e.media.playbackRate=i.getPlaybackRate(),z.call(e,e.media,"ratechange")},onReady(i){if(v.function(e.media.play))return;const s=i.target;We.getTitle.call(e,n),e.media.play=()=>{Ue.call(e,!0),s.playVideo()},e.media.pause=()=>{Ue.call(e,!1),s.pauseVideo()},e.media.stop=()=>{s.stopVideo()},e.media.duration=s.getDuration(),e.media.paused=!0,e.media.currentTime=0,Object.defineProperty(e.media,"currentTime",{get:()=>Number(s.getCurrentTime()),set(t){e.paused&&!e.embed.hasPlayed&&e.embed.mute(),e.media.seeking=!0,z.call(e,e.media,"seeking"),s.seekTo(t)}}),Object.defineProperty(e.media,"playbackRate",{get:()=>s.getPlaybackRate(),set(e){s.setPlaybackRate(e)}});let{volume:a}=e.config;Object.defineProperty(e.media,"volume",{get:()=>a,set(t){a=t,s.setVolume(100*a),z.call(e,e.media,"volumechange")}});let{muted:l}=e.config;Object.defineProperty(e.media,"muted",{get:()=>l,set(t){const i=v.boolean(t)?t:l;l=i,s[i?"mute":"unMute"](),s.setVolume(100*a),z.call(e,e.media,"volumechange")}}),Object.defineProperty(e.media,"currentSrc",{get:()=>s.getVideoUrl()}),Object.defineProperty(e.media,"ended",{get:()=>e.currentTime===e.duration});const r=s.getAvailablePlaybackRates();e.options.speed=r.filter(t=>e.config.speed.options.includes(t)),e.supported.ui&&t.customControls&&e.media.setAttribute("tabindex",-1),z.call(e,e.media,"timeupdate"),z.call(e,e.media,"durationchange"),clearInterval(e.timers.buffering),e.timers.buffering=setInterval(()=>{e.media.buffered=s.getVideoLoadedFraction(),(null===e.media.lastBuffered||e.media.lastBufferedje.build.call(e),50)},onStateChange(i){const s=i.target;switch(clearInterval(e.timers.playing),e.media.seeking&&[1,2].includes(i.data)&&(e.media.seeking=!1,z.call(e,e.media,"seeked")),i.data){case-1:z.call(e,e.media,"timeupdate"),e.media.buffered=s.getVideoLoadedFraction(),z.call(e,e.media,"progress");break;case 0:Ue.call(e,!1),e.media.loop?(s.stopVideo(),s.playVideo()):z.call(e,e.media,"ended");break;case 1:t.customControls&&!e.config.autoplay&&e.media.paused&&!e.embed.hasPlayed?e.media.pause():(Ue.call(e,!0),z.call(e,e.media,"playing"),e.timers.playing=setInterval(()=>{z.call(e,e.media,"timeupdate")},50),e.media.duration!==s.getDuration()&&(e.media.duration=s.getDuration(),z.call(e,e.media,"durationchange")));break;case 2:e.muted||e.embed.unMute(),Ue.call(e,!1);break;case 3:z.call(e,e.media,"waiting")}z.call(e,e.elements.container,"statechange",!1,{code:i.data})}}})}},ze={setup(){this.media?($(this.elements.container,this.config.classNames.type.replace("{0}",this.type),!0),$(this.elements.container,this.config.classNames.provider.replace("{0}",this.provider),!0),this.isEmbed&&$(this.elements.container,this.config.classNames.type.replace("{0}","video"),!0),this.isVideo&&(this.elements.wrapper=E("div",{class:this.config.classNames.video}),A(this.media,this.elements.wrapper),this.elements.poster=E("div",{class:this.config.classNames.poster}),this.elements.wrapper.appendChild(this.elements.poster)),this.isHTML5?ae.setup.call(this):this.isYouTube?We.setup.call(this):this.isVimeo&&Fe.setup.call(this)):this.debug.warn("No media element found!")}};var Ke=class{constructor(e){fe(this,"load",()=>{this.enabled&&(v.object(window.google)&&v.object(window.google.ima)?this.ready():Re(this.player.config.urls.googleIMA.sdk).then(()=>{this.ready()}).catch(()=>{this.trigger("error",new Error("Google IMA SDK failed to load"))}))}),fe(this,"ready",()=>{var e;this.enabled||((e=this).manager&&e.manager.destroy(),e.elements.displayContainer&&e.elements.displayContainer.destroy(),e.elements.container.remove()),this.startSafetyTimer(12e3,"ready()"),this.managerPromise.then(()=>{this.clearSafetyTimer("onAdsManagerLoaded()")}),this.listeners(),this.setupIMA()}),fe(this,"setupIMA",()=>{this.elements.container=E("div",{class:this.player.config.classNames.ads}),this.player.elements.container.appendChild(this.elements.container),google.ima.settings.setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.ENABLED),google.ima.settings.setLocale(this.player.config.ads.language),google.ima.settings.setDisableCustomPlaybackForIOS10Plus(this.player.config.playsinline),this.elements.displayContainer=new google.ima.AdDisplayContainer(this.elements.container,this.player.media),this.loader=new google.ima.AdsLoader(this.elements.displayContainer),this.loader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,e=>this.onAdsManagerLoaded(e),!1),this.loader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,e=>this.onAdError(e),!1),this.requestAds()}),fe(this,"requestAds",()=>{const{container:e}=this.player.elements;try{const t=new google.ima.AdsRequest;t.adTagUrl=this.tagUrl,t.linearAdSlotWidth=e.offsetWidth,t.linearAdSlotHeight=e.offsetHeight,t.nonLinearAdSlotWidth=e.offsetWidth,t.nonLinearAdSlotHeight=e.offsetHeight,t.forceNonLinearFullSlot=!1,t.setAdWillPlayMuted(!this.player.muted),this.loader.requestAds(t)}catch(t){this.onAdError(t)}}),fe(this,"pollCountdown",(e=!1)=>{if(!e)return clearInterval(this.countdownTimer),void this.elements.container.removeAttribute("data-badge-text");this.countdownTimer=setInterval(()=>{const e=ke(Math.max(this.manager.getRemainingTime(),0)),t=`${me.get("advertisement",this.player.config)} - ${e}`;this.elements.container.setAttribute("data-badge-text",t)},100)}),fe(this,"onAdsManagerLoaded",e=>{if(!this.enabled)return;const t=new google.ima.AdsRenderingSettings;t.restoreCustomPlaybackStateOnAdBreakComplete=!0,t.enablePreloading=!0,this.manager=e.getAdsManager(this.player,t),this.cuePoints=this.manager.getCuePoints(),this.manager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,e=>this.onAdError(e)),Object.keys(google.ima.AdEvent.Type).forEach(e=>{this.manager.addEventListener(google.ima.AdEvent.Type[e],e=>this.onAdEvent(e))}),this.trigger("loaded")}),fe(this,"addCuePoints",()=>{v.empty(this.cuePoints)||this.cuePoints.forEach(e=>{if(0!==e&&-1!==e&&e{const{container:t}=this.player.elements,i=e.getAd(),s=e.getAdData();switch((e=>{z.call(this.player,this.player.media,`ads${e.replace(/_/g,"").toLowerCase()}`)})(e.type),e.type){case google.ima.AdEvent.Type.LOADED:this.trigger("loaded"),this.pollCountdown(!0),i.isLinear()||(i.width=t.offsetWidth,i.height=t.offsetHeight);break;case google.ima.AdEvent.Type.STARTED:this.manager.setVolume(this.player.volume);break;case google.ima.AdEvent.Type.ALL_ADS_COMPLETED:this.player.ended?this.loadAds():this.loader.contentComplete();break;case google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED:this.pauseContent();break;case google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED:this.pollCountdown(),this.resumeContent();break;case google.ima.AdEvent.Type.LOG:s.adError&&this.player.debug.warn(`Non-fatal ad error: ${s.adError.getMessage()}`)}}),fe(this,"onAdError",e=>{this.cancel(),this.player.debug.warn("Ads error",e)}),fe(this,"listeners",()=>{const{container:e}=this.player.elements;let t;this.player.on("canplay",()=>{this.addCuePoints()}),this.player.on("ended",()=>{this.loader.contentComplete()}),this.player.on("timeupdate",()=>{t=this.player.currentTime}),this.player.on("seeked",()=>{const e=this.player.currentTime;v.empty(this.cuePoints)||this.cuePoints.forEach((i,s)=>{t{this.manager&&this.manager.resize(e.offsetWidth,e.offsetHeight,google.ima.ViewMode.NORMAL)})}),fe(this,"play",()=>{const{container:e}=this.player.elements;this.managerPromise||this.resumeContent(),this.managerPromise.then(()=>{this.manager.setVolume(this.player.volume),this.elements.displayContainer.initialize();try{this.initialized||(this.manager.init(e.offsetWidth,e.offsetHeight,google.ima.ViewMode.NORMAL),this.manager.start()),this.initialized=!0}catch(t){this.onAdError(t)}}).catch(()=>{})}),fe(this,"resumeContent",()=>{this.elements.container.style.zIndex="",this.playing=!1,X(this.player.media.play())}),fe(this,"pauseContent",()=>{this.elements.container.style.zIndex=3,this.playing=!0,this.player.media.pause()}),fe(this,"cancel",()=>{this.initialized&&this.resumeContent(),this.trigger("error"),this.loadAds()}),fe(this,"loadAds",()=>{this.managerPromise.then(()=>{this.manager&&this.manager.destroy(),this.managerPromise=new Promise(e=>{this.on("loaded",e),this.player.debug.log(this.manager)}),this.initialized=!1,this.requestAds()}).catch(()=>{})}),fe(this,"trigger",(e,...t)=>{const i=this.events[e];v.array(i)&&i.forEach(e=>{v.function(e)&&e.apply(this,t)})}),fe(this,"on",(e,t)=>(v.array(this.events[e])||(this.events[e]=[]),this.events[e].push(t),this)),fe(this,"startSafetyTimer",(e,t)=>{this.player.debug.log(`Safety timer invoked from: ${t}`),this.safetyTimer=setTimeout(()=>{this.cancel(),this.clearSafetyTimer("startSafetyTimer()")},e)}),fe(this,"clearSafetyTimer",e=>{v.nullOrUndefined(this.safetyTimer)||(this.player.debug.log(`Safety timer cleared from: ${e}`),clearTimeout(this.safetyTimer),this.safetyTimer=null)}),this.player=e,this.config=e.config.ads,this.playing=!1,this.initialized=!1,this.elements={container:null,displayContainer:null},this.manager=null,this.loader=null,this.cuePoints=null,this.events={},this.safetyTimer=null,this.countdownTimer=null,this.managerPromise=new Promise((e,t)=>{this.on("loaded",e),this.on("error",t)}),this.load()}get enabled(){const{config:e}=this;return this.player.isHTML5&&this.player.isVideo&&e.enabled&&(!v.empty(e.publisherId)||v.url(e.tagUrl))}get tagUrl(){const{config:e}=this;if(v.url(e.tagUrl))return e.tagUrl;return`https://go.aniview.com/api/adserver6/vast/?${Ae({AV_PUBLISHERID:"58c25bb0073ef448b1087ad6",AV_CHANNELID:"5a0458dc28a06145e4519d21",AV_URL:window.location.hostname,cb:Date.now(),AV_WIDTH:640,AV_HEIGHT:480,AV_CDIM2:e.publisherId})}`}};function Ye(e=0,t=0,i=255){return Math.min(Math.max(e,t),i)}function Xe(e){const t=[];return e.split(/\r\n\r\n|\n\n|\r\r/).forEach(e=>{const i={};e.split(/\r\n|\n|\r/).forEach(e=>{if(v.number(i.startTime)){if(!v.empty(e.trim())&&v.empty(i.text)){const t=e.trim().split("#xywh=");[i.text]=t,t[1]&&([i.x,i.y,i.w,i.h]=t[1].split(","))}}else{const t=e.match(/(\d{2})?:?(\d{2}):(\d{2}).(\d{2,3})( ?--> ?)(\d{2})?:?(\d{2}):(\d{2}).(\d{2,3})/);t&&(i.startTime=60*Number(t[1]||0)*60+60*Number(t[2])+Number(t[3])+Number(`0.${t[4]}`),i.endTime=60*Number(t[6]||0)*60+60*Number(t[7])+Number(t[8])+Number(`0.${t[9]}`))}}),i.text&&t.push(i)}),t}function Qe(e,t){const i={};return e>t.width/t.height?(i.width=t.width,i.height=1/e*t.width):(i.height=t.height,i.width=e*t.height),i}var Je,Ge=class{constructor(e){fe(this,"load",()=>{this.player.elements.display.seekTooltip&&(this.player.elements.display.seekTooltip.hidden=this.enabled),this.enabled&&this.getThumbnails().then(()=>{this.enabled&&(this.render(),this.determineContainerAutoSizing(),this.listeners(),this.loaded=!0)})}),fe(this,"getThumbnails",()=>new Promise(e=>{const{src:t}=this.player.config.previewThumbnails;if(v.empty(t))throw new Error("Missing previewThumbnails.src config attribute");const i=()=>{this.thumbnails.sort((e,t)=>e.height-t.height),this.player.debug.log("Preview thumbnails",this.thumbnails),e()};if(v.function(t))t(e=>{this.thumbnails=e,i()});else{const e=(v.string(t)?[t]:t).map(e=>this.getThumbnail(e));Promise.all(e).then(i)}})),fe(this,"getThumbnail",e=>new Promise(t=>{be(e,void 0,this.player.config.previewThumbnails.withCredentials).then(i=>{const s={frames:Xe(i),height:null,urlPrefix:""};s.frames[0].text.startsWith("/")||s.frames[0].text.startsWith("http://")||s.frames[0].text.startsWith("https://")||(s.urlPrefix=e.substring(0,e.lastIndexOf("/")+1));const n=new Image;n.onload=()=>{s.height=n.naturalHeight,s.width=n.naturalWidth,this.thumbnails.push(s),t()},n.src=s.urlPrefix+s.frames[0].text})})),fe(this,"startMove",e=>{if(this.loaded&&v.event(e)&&["touchmove","mousemove"].includes(e.type)&&this.player.media.duration){if("touchmove"===e.type)this.seekTime=this.player.media.duration*(this.player.elements.inputs.seek.value/100);else{var t;const i=this.player.elements.progress.getBoundingClientRect(),s=100/i.width*(e.pageX-i.left);this.seekTime=this.player.media.duration*(s/100),this.seekTime<0&&(this.seekTime=0),this.seekTime>this.player.media.duration-1&&(this.seekTime=this.player.media.duration-1),this.mousePosX=e.pageX,this.elements.thumb.time.textContent=ke(this.seekTime);const n=null===(t=this.player.config.markers)||void 0===t||null===(t=t.points)||void 0===t?void 0:t.find(({time:e})=>e===Math.round(this.seekTime));n&&this.elements.thumb.time.insertAdjacentHTML("afterbegin",`${n.label}
`)}this.showImageAtCurrentTime()}}),fe(this,"endMove",()=>{this.toggleThumbContainer(!1,!0)}),fe(this,"startScrubbing",e=>{(v.nullOrUndefined(e.button)||!1===e.button||0===e.button)&&(this.mouseDown=!0,this.player.media.duration&&(this.toggleScrubbingContainer(!0),this.toggleThumbContainer(!1,!0),this.showImageAtCurrentTime()))}),fe(this,"endScrubbing",()=>{this.mouseDown=!1,Math.ceil(this.lastTime)===Math.ceil(this.player.media.currentTime)?this.toggleScrubbingContainer(!1):W.call(this.player,this.player.media,"timeupdate",()=>{this.mouseDown||this.toggleScrubbingContainer(!1)})}),fe(this,"listeners",()=>{this.player.on("play",()=>{this.toggleThumbContainer(!1,!0)}),this.player.on("seeked",()=>{this.toggleThumbContainer(!1)}),this.player.on("timeupdate",()=>{this.lastTime=this.player.media.currentTime})}),fe(this,"render",()=>{this.elements.thumb.container=E("div",{class:this.player.config.classNames.previewThumbnails.thumbContainer}),this.elements.thumb.imageContainer=E("div",{class:this.player.config.classNames.previewThumbnails.imageContainer}),this.elements.thumb.container.appendChild(this.elements.thumb.imageContainer);const e=E("div",{class:this.player.config.classNames.previewThumbnails.timeContainer});this.elements.thumb.time=E("span",{},"00:00"),e.appendChild(this.elements.thumb.time),this.elements.thumb.imageContainer.appendChild(e),v.element(this.player.elements.progress)&&this.player.elements.progress.appendChild(this.elements.thumb.container),this.elements.scrubbing.container=E("div",{class:this.player.config.classNames.previewThumbnails.scrubbingContainer}),this.player.elements.wrapper.appendChild(this.elements.scrubbing.container)}),fe(this,"destroy",()=>{this.elements.thumb.container&&this.elements.thumb.container.remove(),this.elements.scrubbing.container&&this.elements.scrubbing.container.remove()}),fe(this,"showImageAtCurrentTime",()=>{this.mouseDown?this.setScrubbingContainerSize():this.setThumbContainerSizeAndPos();const e=this.thumbnails[0].frames.findIndex(e=>this.seekTime>=e.startTime&&this.seekTime<=e.endTime),t=e>=0;let i=0;this.mouseDown||this.toggleThumbContainer(t),t&&(this.thumbnails.forEach((t,s)=>{this.loadedImages.includes(t.frames[e].text)&&(i=s)}),e!==this.showingThumb&&(this.showingThumb=e,this.loadImage(i)))}),fe(this,"loadImage",(e=0)=>{const t=this.showingThumb,i=this.thumbnails[e],{urlPrefix:s}=i,n=i.frames[t],a=i.frames[t].text,l=s+a;if(this.currentImageElement&&this.currentImageElement.dataset.filename===a)this.showImage(this.currentImageElement,n,e,t,a,!1),this.currentImageElement.dataset.index=t,this.removeOldImages(this.currentImageElement);else{this.loadingImage&&this.usingSprites&&(this.loadingImage.onload=null);const i=new Image;i.src=l,i.dataset.index=t,i.dataset.filename=a,this.showingThumbFilename=a,this.player.debug.log(`Loading image: ${l}`),i.onload=()=>this.showImage(i,n,e,t,a,!0),this.loadingImage=i,this.removeOldImages(i)}}),fe(this,"showImage",(e,t,i,s,n,a=!0)=>{this.player.debug.log(`Showing thumb: ${n}. num: ${s}. qual: ${i}. newimg: ${a}`),this.setImageSizeAndOffset(e,t),a&&(this.currentImageContainer.appendChild(e),this.currentImageElement=e,this.loadedImages.includes(n)||this.loadedImages.push(n)),this.preloadNearby(s,!0).then(this.preloadNearby(s,!1)).then(this.getHigherQuality(i,e,t,n))}),fe(this,"removeOldImages",e=>{Array.from(this.currentImageContainer.children).forEach(t=>{if("img"!==t.tagName.toLowerCase())return;const i=this.usingSprites?500:1e3;if(t.dataset.index!==e.dataset.index&&!t.dataset.deleting){t.dataset.deleting=!0;const{currentImageContainer:e}=this;setTimeout(()=>{e.removeChild(t),this.player.debug.log(`Removing thumb: ${t.dataset.filename}`)},i)}})}),fe(this,"preloadNearby",(e,t=!0)=>new Promise(i=>{setTimeout(()=>{const s=this.thumbnails[0].frames[e].text;if(this.showingThumbFilename===s){let n;n=t?this.thumbnails[0].frames.slice(e):this.thumbnails[0].frames.slice(0,e).reverse();let a=!1;n.forEach(e=>{const t=e.text;if(t!==s&&!this.loadedImages.includes(t)){a=!0,this.player.debug.log(`Preloading thumb filename: ${t}`);const{urlPrefix:e}=this.thumbnails[0],s=e+t,n=new Image;n.src=s,n.onload=()=>{this.player.debug.log(`Preloaded thumb filename: ${t}`),this.loadedImages.includes(t)||this.loadedImages.push(t),i()}}}),a||i()}},300)})),fe(this,"getHigherQuality",(e,t,i,s)=>{if(e{this.showingThumbFilename===s&&(this.player.debug.log(`Showing higher quality thumb for: ${s}`),this.loadImage(e+1))},300)}}),fe(this,"toggleThumbContainer",(e=!1,t=!1)=>{const i=this.player.config.classNames.previewThumbnails.thumbContainerShown;this.elements.thumb.container.classList.toggle(i,e),!e&&t&&(this.showingThumb=null,this.showingThumbFilename=null)}),fe(this,"toggleScrubbingContainer",(e=!1)=>{const t=this.player.config.classNames.previewThumbnails.scrubbingContainerShown;this.elements.scrubbing.container.classList.toggle(t,e),e||(this.showingThumb=null,this.showingThumbFilename=null)}),fe(this,"determineContainerAutoSizing",()=>{(this.elements.thumb.imageContainer.clientHeight>20||this.elements.thumb.imageContainer.clientWidth>20)&&(this.sizeSpecifiedInCSS=!0)}),fe(this,"setThumbContainerSizeAndPos",()=>{const{imageContainer:e}=this.elements.thumb;if(this.sizeSpecifiedInCSS){if(e.clientHeight>20&&e.clientWidth<20){const t=Math.floor(e.clientHeight*this.thumbAspectRatio);e.style.width=`${t}px`}else if(e.clientHeight<20&&e.clientWidth>20){const t=Math.floor(e.clientWidth/this.thumbAspectRatio);e.style.height=`${t}px`}}else{const t=Math.floor(this.thumbContainerHeight*this.thumbAspectRatio);e.style.height=`${this.thumbContainerHeight}px`,e.style.width=`${t}px`}this.setThumbContainerPos()}),fe(this,"setThumbContainerPos",()=>{const e=this.player.elements.progress.getBoundingClientRect(),t=this.player.elements.container.getBoundingClientRect(),{container:i}=this.elements.thumb,s=t.left-e.left+10,n=t.right-e.left-i.clientWidth-10,a=this.mousePosX-e.left-i.clientWidth/2,l=Ye(a,s,n);i.style.left=`${l}px`,i.style.setProperty("--preview-arrow-offset",a-l+"px")}),fe(this,"setScrubbingContainerSize",()=>{const{width:e,height:t}=Qe(this.thumbAspectRatio,{width:this.player.media.clientWidth,height:this.player.media.clientHeight});this.elements.scrubbing.container.style.width=`${e}px`,this.elements.scrubbing.container.style.height=`${t}px`}),fe(this,"setImageSizeAndOffset",(e,t)=>{if(!this.usingSprites)return;const i=this.thumbContainerHeight/t.h;e.style.height=e.naturalHeight*i+"px",e.style.width=e.naturalWidth*i+"px",e.style.left=`-${t.x*i}px`,e.style.top=`-${t.y*i}px`}),this.player=e,this.thumbnails=[],this.loaded=!1,this.lastMouseMoveTime=Date.now(),this.mouseDown=!1,this.loadedImages=[],this.elements={thumb:{},scrubbing:{}},this.load()}get enabled(){return this.player.isHTML5&&this.player.isVideo&&this.player.config.previewThumbnails.enabled}get currentImageContainer(){return this.mouseDown?this.elements.scrubbing.container:this.elements.thumb.imageContainer}get usingSprites(){return Object.keys(this.thumbnails[0].frames[0]).includes("w")}get thumbAspectRatio(){return this.usingSprites?this.thumbnails[0].frames[0].w/this.thumbnails[0].frames[0].h:this.thumbnails[0].width/this.thumbnails[0].height}get thumbContainerHeight(){if(this.mouseDown){const{height:e}=Qe(this.thumbAspectRatio,{width:this.player.media.clientWidth,height:this.player.media.clientHeight});return e}return this.sizeSpecifiedInCSS?this.elements.thumb.imageContainer.clientHeight:Math.floor(this.player.media.clientWidth/this.thumbAspectRatio/4)}get currentImageElement(){return this.mouseDown?this.currentScrubbingImageElement:this.currentThumbnailImageElement}set currentImageElement(e){this.mouseDown?this.currentScrubbingImageElement=e:this.currentThumbnailImageElement=e}},Ze={insertElements(e,t){v.string(t)?P(e,this.media,{src:t}):v.array(t)&&t.forEach(t=>{P(e,this.media,t)})},change(e){T(e,"sources.length")?(ae.cancelRequests.call(this),this.destroy(()=>{this.options.quality=[],M(this.media),this.media=null,v.element(this.elements.container)&&this.elements.container.removeAttribute("class");const{sources:t,type:i}=e,[{provider:s=Ne.html5,src:n}]=t,a="html5"===s?i:"div",l="html5"===s?{}:{src:n};Object.assign(this,{provider:s,type:i,supported:R.check(i,s,this.config.playsinline),media:E(a,l)}),this.elements.container.appendChild(this.media),v.boolean(e.autoplay)&&(this.config.autoplay=e.autoplay),this.isHTML5&&(this.config.crossorigin&&this.media.setAttribute("crossorigin",""),this.config.autoplay&&this.media.setAttribute("autoplay",""),v.empty(e.poster)||(this.poster=e.poster),this.config.loop.active&&this.media.setAttribute("loop",""),this.config.muted&&this.media.setAttribute("muted",""),this.config.playsinline&&this.media.setAttribute("playsinline","")),je.addStyleHook.call(this),this.isHTML5&&Ze.insertElements.call(this,"source",t),this.config.title=e.title,ze.setup.call(this),this.isHTML5&&Object.keys(e).includes("tracks")&&Ze.insertElements.call(this,"track",e.tracks),(this.isHTML5||this.isEmbed&&!this.supported.ui)&&je.build.call(this),this.isHTML5&&this.media.load(),v.empty(e.previewThumbnails)||(Object.assign(this.config.previewThumbnails,e.previewThumbnails),this.previewThumbnails&&this.previewThumbnails.loaded&&(this.previewThumbnails.destroy(),this.previewThumbnails=null),this.config.previewThumbnails.enabled&&(this.previewThumbnails=new Ge(this))),this.fullscreen.update()},!0)):this.debug.warn("Invalid source format")}},et=class e{constructor(t,i){if(fe(this,"play",()=>v.function(this.media.play)?(this.ads&&this.ads.enabled&&this.ads.managerPromise.then(()=>this.ads.play()).catch(()=>X(this.media.play())),this.media.play()):null),fe(this,"pause",()=>this.playing&&v.function(this.media.pause)?this.media.pause():null),fe(this,"togglePlay",e=>(v.boolean(e)?e:!this.playing)?this.play():this.pause()),fe(this,"stop",()=>{this.isHTML5?(this.pause(),this.restart()):v.function(this.media.stop)&&this.media.stop()}),fe(this,"restart",()=>{this.currentTime=0}),fe(this,"rewind",e=>{this.currentTime-=v.number(e)?e:this.config.seekTime}),fe(this,"forward",e=>{this.currentTime+=v.number(e)?e:this.config.seekTime}),fe(this,"increaseVolume",e=>{const t=this.media.muted?0:this.volume;this.volume=t+(v.number(e)?e:0)}),fe(this,"decreaseVolume",e=>{this.increaseVolume(-e)}),fe(this,"airplay",()=>{R.airplay&&this.media.webkitShowPlaybackTargetPicker()}),fe(this,"toggleControls",e=>{if(this.supported.ui&&!this.isAudio){const t=O(this.elements.container,this.config.classNames.hideControls),i=void 0===e?void 0:!e,s=$(this.elements.container,this.config.classNames.hideControls,i);if(s&&v.array(this.config.controls)&&this.config.controls.includes("settings")&&!v.empty(this.config.settings)&&Te.toggleMenu.call(this,!1),s!==t){const e=s?"controlshidden":"controlsshown";z.call(this,this.media,e)}return!s}return!1}),fe(this,"on",(e,t)=>{U.call(this,this.elements.container,e,t)}),fe(this,"once",(e,t)=>{W.call(this,this.elements.container,e,t)}),fe(this,"off",(e,t)=>{B(this.elements.container,e,t)}),fe(this,"destroy",(e,t=!1)=>{if(!this.ready)return;const i=()=>{document.body.style.overflow="",this.embed=null,t?(Object.keys(this.elements).length&&(M(this.elements.buttons.play),M(this.elements.captions),M(this.elements.controls),M(this.elements.wrapper),this.elements.buttons.play=null,this.elements.captions=null,this.elements.controls=null,this.elements.wrapper=null),v.function(e)&&e()):(K.call(this),ae.cancelRequests.call(this),x(this.elements.original,this.elements.container),z.call(this,this.elements.original,"destroyed",!0),v.function(e)&&e.call(this.elements.original),this.ready=!1,setTimeout(()=>{this.elements=null,this.media=null},200))};this.stop(),clearTimeout(this.timers.loading),clearTimeout(this.timers.controls),clearTimeout(this.timers.resized),this.isHTML5?(je.toggleNativeControls.call(this,!0),i()):this.isYouTube?(clearInterval(this.timers.buffering),clearInterval(this.timers.playing),null!==this.embed&&v.function(this.embed.destroy)&&this.embed.destroy(),i()):this.isVimeo&&(null!==this.embed&&this.embed.unload().then(i),setTimeout(i,200))}),fe(this,"supports",e=>R.mime.call(this,e)),this.timers={},this.ready=!1,this.loading=!1,this.failed=!1,this.touch=R.touch,this.media=t,v.string(this.media)&&(this.media=document.querySelectorAll(this.media)),(window.jQuery&&this.media instanceof jQuery||v.nodeList(this.media)||v.array(this.media))&&(this.media=this.media[0]),this.config=C({},Ee,e.defaults,i||{},(()=>{try{return JSON.parse(this.media.getAttribute("data-plyr-config"))}catch{return{}}})()),this.elements={container:null,fullscreen:null,captions:null,buttons:{},display:{},progress:{},inputs:{},settings:{popup:null,menu:null,panels:{},buttons:{}}},this.captions={active:null,currentTrack:-1,meta:new WeakMap},this.fullscreen={active:!1},this.options={speed:[],quality:[]},this.debug=new $e(this.config.debug),this.debug.log("Config",this.config),this.debug.log("Support",R),v.nullOrUndefined(this.media)||!v.element(this.media))return void this.debug.error("Setup failed: no suitable element passed");if(this.media.plyr)return void this.debug.warn("Target already setup");if(!this.config.enabled)return void this.debug.error("Setup failed: disabled by config");if(!R.check().api)return void this.debug.error("Setup failed: no support");const s=this.media.cloneNode(!0);s.autoplay=!1,this.elements.original=s;const n=this.media.tagName.toLowerCase();let a=null,l=null;switch(n){case"div":if(a=this.media.querySelector("iframe"),v.element(a)){if(l=Ce(a.getAttribute("src")),this.provider=function(e){return/^(?:https?:\/\/)?(?:www\.)?(?:youtube\.com|youtube-nocookie\.com|youtu\.?be)\/.+$/.test(e)?Ne.youtube:/^https?:\/\/player.vimeo.com\/video\/\d{0,9}(?=\b|\/)/.test(e)?Ne.vimeo:null}(l.toString()),this.elements.container=this.media,this.media=a,this.elements.container.className="",l.search.length){const e=["1","true"];e.includes(l.searchParams.get("autoplay"))&&(this.config.autoplay=!0),e.includes(l.searchParams.get("loop"))&&(this.config.loop.active=!0),this.isYouTube?(this.config.playsinline=e.includes(l.searchParams.get("playsinline")),this.config.youtube.hl=l.searchParams.get("hl")):this.config.playsinline=!0}}else this.provider=this.media.getAttribute(this.config.attributes.embed.provider),this.media.removeAttribute(this.config.attributes.embed.provider);if(v.empty(this.provider)||!Object.values(Ne).includes(this.provider))return void this.debug.error("Setup failed: Invalid provider");this.type=Le;break;case"video":case"audio":this.type=n,this.provider=Ne.html5,this.media.hasAttribute("crossorigin")&&(this.config.crossorigin=!0),this.media.hasAttribute("autoplay")&&(this.config.autoplay=!0),(this.media.hasAttribute("playsinline")||this.media.hasAttribute("webkit-playsinline"))&&(this.config.playsinline=!0),this.media.hasAttribute("muted")&&(this.config.muted=!0),this.media.hasAttribute("loop")&&(this.config.loop.active=!0);break;default:return void this.debug.error("Setup failed: unsupported type")}this.supported=R.check(this.type,this.provider),this.supported.api?(this.eventListeners=[],this.listeners=new De(this),this.storage=new ye(this),this.media.plyr=this,v.element(this.elements.container)||(this.elements.container=E("div"),A(this.media,this.elements.container)),je.migrateStyles.call(this),je.addStyleHook.call(this),ze.setup.call(this),this.config.debug&&U.call(this,this.elements.container,this.config.events.join(" "),e=>{this.debug.log(`event: ${e.type}`)}),this.fullscreen=new Oe(this),(this.isHTML5||this.isEmbed&&!this.supported.ui)&&je.build.call(this),this.listeners.container(),this.listeners.global(),this.config.ads.enabled&&(this.ads=new Ke(this)),this.isHTML5&&this.config.autoplay&&this.once("canplay",()=>X(this.play())),this.lastSeekTime=0,this.config.previewThumbnails.enabled&&(this.previewThumbnails=new Ge(this))):this.debug.error("Setup failed: no support")}get isHTML5(){return this.provider===Ne.html5}get isEmbed(){return this.isYouTube||this.isVimeo}get isYouTube(){return this.provider===Ne.youtube}get isVimeo(){return this.provider===Ne.vimeo}get isVideo(){return this.type===Le}get isAudio(){return this.type===xe}get playing(){return Boolean(this.ready&&!this.paused&&!this.ended)}get paused(){return Boolean(this.media.paused)}get stopped(){return Boolean(this.paused&&0===this.currentTime)}get ended(){return Boolean(this.media.ended)}set currentTime(e){if(!this.duration)return;const t=v.number(e)&&e>0;this.media.currentTime=t?Math.min(e,this.duration):0,this.debug.log(`Seeking to ${this.currentTime} seconds`)}get currentTime(){return Number(this.media.currentTime)}get buffered(){const{buffered:e}=this.media;return v.number(e)?e:e&&e.length&&this.duration>0?e.end(0)/this.duration:0}get seeking(){return Boolean(this.media.seeking)}get duration(){const e=Number.parseFloat(this.config.duration),t=(this.media||{}).duration,i=v.number(t)&&t!==1/0?t:0;return e||i}set volume(e){let t=e;v.string(t)&&(t=Number(t)),v.number(t)||(t=this.storage.get("volume")),v.number(t)||({volume:t}=this.config),t>1&&(t=1),t<0&&(t=0),t>0&&(!this.lastVolume||t>=this.config.volume)&&(this.lastVolume=t),this.config.volume=t,this.media.volume=t,!v.empty(e)&&this.muted&&t>0&&(this.muted=!1)}get volume(){return Number(this.media.volume)}set muted(e){let t=e;v.boolean(t)||(t=this.storage.get("muted")),v.boolean(t)||(t=this.config.muted),this.config.muted=t,this.media.muted=t}get muted(){return Boolean(this.media.muted)}get hasAudio(){return!this.isHTML5||(!!this.isAudio||(Boolean(this.media.mozHasAudio)||Boolean(this.media.webkitAudioDecodedByteCount)||Boolean(this.media.audioTracks&&this.media.audioTracks.length)))}set speed(e){let t=null;v.number(e)&&(t=e),v.number(t)||(t=this.storage.get("speed")),v.number(t)||(t=this.config.speed.selected);const{minimumSpeed:i,maximumSpeed:s}=this;t=Ye(t,i,s),this.config.speed.selected=t,setTimeout(()=>{this.media&&(this.media.playbackRate=t)},0)}get speed(){return Number(this.media.playbackRate)}get minimumSpeed(){return this.isYouTube?Math.min(...this.options.speed):this.isVimeo?.5:.0625}get maximumSpeed(){return this.isYouTube?Math.max(...this.options.speed):this.isVimeo?2:16}set quality(e){const t=this.config.quality,i=this.options.quality;if(!i.length)return;let s=[!v.empty(e)&&Number(e),this.storage.get("quality"),t.selected,t.default].find(v.number),n=!0;if(!i.includes(s)){const e=J(i,s);this.debug.warn(`Unsupported quality option: ${s}, using ${e} instead`),s=e,n=!1}t.selected=s,this.media.quality=s,n&&this.storage.set({quality:s})}get quality(){return this.media.quality}set loop(e){const t=v.boolean(e)?e:this.config.loop.active;this.config.loop.active=t,this.media.loop=t}get loop(){return Boolean(this.media.loop)}set source(e){Ze.change.call(this,e)}get source(){return this.media.currentSrc}get download(){const{download:e}=this.config.urls;return v.url(e)?e:this.source}set download(e){v.url(e)&&(this.config.urls.download=e,Te.setDownloadUrl.call(this))}set poster(e){this.isVideo?je.setPoster.call(this,e,!1).catch(()=>{}):this.debug.warn("Poster can only be set for video")}get poster(){return this.isVideo?this.media.getAttribute("poster")||this.media.getAttribute("data-poster"):null}get ratio(){if(!this.isVideo)return null;const e=te(ie.call(this));return v.array(e)?e.join(":"):e}set ratio(e){this.isVideo?v.string(e)&&ee(e)?(this.config.ratio=te(e),se.call(this)):this.debug.error(`Invalid aspect ratio specified (${e})`):this.debug.warn("Aspect ratio can only be set for video")}set autoplay(e){this.config.autoplay=v.boolean(e)?e:this.config.autoplay}get autoplay(){return Boolean(this.config.autoplay)}toggleCaptions(e){Se.toggle.call(this,e,!1)}set currentTrack(e){Se.set.call(this,e,!1),Se.setup.call(this)}get currentTrack(){const{toggled:e,currentTrack:t}=this.captions;return e?t:-1}set language(e){Se.setLanguage.call(this,e,!1)}get language(){return(Se.getCurrentTrack.call(this)||{}).language}set pip(e){if(!R.pip)return;const t=v.boolean(e)?e:!this.pip;v.function(this.media.webkitSetPresentationMode)&&this.media.webkitSetPresentationMode(t?Pe:Me),v.function(this.media.requestPictureInPicture)&&(!this.pip&&t?this.media.requestPictureInPicture():this.pip&&!t&&document.exitPictureInPicture())}get pip(){return R.pip?v.empty(this.media.webkitPresentationMode)?this.media===document.pictureInPictureElement:this.media.webkitPresentationMode===Pe:null}setPreviewThumbnails(e){this.previewThumbnails&&this.previewThumbnails.loaded&&(this.previewThumbnails.destroy(),this.previewThumbnails=null),Object.assign(this.config.previewThumbnails,e),this.config.previewThumbnails.enabled&&(this.previewThumbnails=new Ge(this))}static supported(e,t){return R.check(e,t)}static loadSprite(e,t){return ve(e,t)}static setup(t,i={}){let s=null;return v.string(t)?s=Array.from(document.querySelectorAll(t)):v.nodeList(t)?s=Array.from(t):v.array(t)&&(s=t.filter(v.element)),v.empty(s)?null:s.map(t=>new e(t,i))}};return et.defaults=(Je=Ee,JSON.parse(JSON.stringify(Je))),et}); +//# sourceMappingURL=plyr.min.js.map \ No newline at end of file diff --git a/android/app/src/main/assets/pulsewall/libs/pw-icons.min.js b/android/app/src/main/assets/pulsewall/libs/pw-icons.min.js new file mode 100644 index 0000000..ab99e34 --- /dev/null +++ b/android/app/src/main/assets/pulsewall/libs/pw-icons.min.js @@ -0,0 +1,32 @@ +(function(g){ +var P={ +cpu:"M9 2v2M15 2v2M9 20v2M15 20v2M2 9h2M2 15h2M20 9h2M20 15h2M6 6h12v12H6zM9 9h6v6H9z", +thermometer:"M14 14.76V3.5a2.5 2.5 0 0 0-5 0v11.26a4.5 4.5 0 1 0 5 0z", +battery:"M2 7h16v10H2zM22 11v2", +wifi:"M5 12.55a11 11 0 0 1 14.08 0M1.42 9a16 16 0 0 1 21.16 0M8.53 16.11a6 6 0 0 1 6.95 0M12 20h.01", +bell:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9M13.73 21a2 2 0 0 1-3.46 0", +alert:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0zM12 9v4M12 17h.01", +check:"M20 6L9 17l-5-5", +x:"M18 6L6 18M6 6l12 12", +play:"M5 3l14 9-14 9V3z", +pause:"M6 4h4v16H6zM14 4h4v16h-4z", +tv:"M2 7h20v13H2zM17 2l-5 5-5-5", +server:"M2 2h20v8H2zM2 14h20v8H2zM6 6h.01M6 18h.01", +activity:"M22 12h-4l-3 9L9 3l-3 9H2", +clock:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zM12 6v6l4 2", +settings:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4", +refresh:"M23 4v6h-6M1 20v-6h6M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15", +home:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z", +sun:"M12 17a5 5 0 1 0 0-10 5 5 0 0 0 0 10zM12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42", +cloud:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z", +database:"M12 2C6.5 2 2 3.8 2 6v12c0 2.2 4.5 4 10 4s10-1.8 10-4V6c0-2.2-4.5-4-10-4zM2 12c0 2.2 4.5 4 10 4s10-1.8 10-4", +terminal:"M4 17l6-6-6-6M12 19h8", +volume:"M11 5L6 9H2v6h4l5 4V5zM19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07", +zap:"M13 2L3 14h9l-1 8 10-12h-9l1-8z", +shield:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z", +chart:"M18 20V10M12 20V4M6 20v-6" +}; +function svg(n,s,c){var d=P[n]||P.activity;s=s||20;return '';} +function hydrate(root){(root||document).querySelectorAll("[data-pw-icon]").forEach(function(el){el.innerHTML=svg(el.getAttribute("data-pw-icon"),el.getAttribute("data-size")||20,el.getAttribute("data-color"));});} +g.PwIcons={names:Object.keys(P),svg:svg,hydrate:hydrate}; +})(window); \ No newline at end of file diff --git a/android/app/src/main/assets/pulsewall/libs/rough.min.js b/android/app/src/main/assets/pulsewall/libs/rough.min.js new file mode 100644 index 0000000..a82ab73 --- /dev/null +++ b/android/app/src/main/assets/pulsewall/libs/rough.min.js @@ -0,0 +1 @@ +var rough=(()=>{var tt=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var $t=Object.prototype.hasOwnProperty;var Rt=(a,t)=>{for(var s in t)tt(a,s,{get:t[s],enumerable:!0})},jt=(a,t,s,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Gt(t))!$t.call(a,n)&&n!==s&&tt(a,n,{get:()=>t[n],enumerable:!(e=Et(t,n))||e.enumerable});return a};var qt=a=>jt(tt({},"__esModule",{value:!0}),a);var te={};Rt(te,{canvas:()=>Ut,default:()=>Kt,generator:()=>Yt,svg:()=>Xt});function et(a,t,s){if(a&&a.length){let[e,n]=t,o=Math.PI/180*s,r=Math.cos(o),h=Math.sin(o);for(let i of a){let[l,c]=i;i[0]=(l-e)*r-(c-n)*h+e,i[1]=(l-e)*h+(c-n)*r+n}}}function Ft(a,t){return a[0]===t[0]&&a[1]===t[1]}function Vt(a,t,s,e=1){let n=s,o=Math.max(t,.1),r=a[0]&&a[0][0]&&typeof a[0][0]=="number"?[a]:a,h=[0,0];if(n)for(let l of r)et(l,h,n);let i=(function(l,c,d){let p=[];for(let M of l){let m=[...M];Ft(m[0],m[m.length-1])||m.push([m[0][0],m[0][1]]),m.length>2&&p.push(m)}let u=[];c=Math.max(c,.1);let f=[];for(let M of p)for(let m=0;mM.yminm.ymin?1:M.xm.x?1:M.ymax===m.ymax?0:(M.ymax-m.ymax)/Math.abs(M.ymax-m.ymax))),!f.length)return u;let g=[],k=f[0].ymin,b=0;for(;g.length||f.length;){if(f.length){let M=-1;for(let m=0;mk);m++)M=m;f.splice(0,M+1).forEach((m=>{g.push({s:k,edge:m})}))}if(g=g.filter((M=>!(M.edge.ymax<=k))),g.sort(((M,m)=>M.edge.x===m.edge.x?0:(M.edge.x-m.edge.x)/Math.abs(M.edge.x-m.edge.x))),(d!==1||b%c==0)&&g.length>1)for(let M=0;M=g.length)break;let P=g[M].edge,w=g[m].edge;u.push([[Math.round(P.x),k],[Math.round(w.x),k]])}k+=d,g.forEach((M=>{M.edge.x=M.edge.x+d*M.edge.islope})),b++}return u})(r,o,e);if(n){for(let l of r)et(l,h,-n);(function(l,c,d){let p=[];l.forEach((u=>p.push(...u))),et(p,c,d)})(i,h,-n)}return i}function F(a,t){var s;let e=t.hachureAngle+90,n=t.hachureGap;n<0&&(n=4*t.strokeWidth),n=Math.round(Math.max(n,.1));let o=1;return t.roughness>=1&&(((s=t.randomizer)===null||s===void 0?void 0:s.next())||Math.random())>.7&&(o=n),Vt(a,n,e,o||1)}var q=class{constructor(t){this.helper=t}fillPolygons(t,s){return this._fillPolygons(t,s)}_fillPolygons(t,s){let e=F(t,s);return{type:"fillSketch",ops:this.renderLines(e,s)}}renderLines(t,s){let e=[];for(let n of t)e.push(...this.helper.doubleLineOps(n[0][0],n[0][1],n[1][0],n[1][1],s));return e}};function Y(a){let t=a[0],s=a[1];return Math.sqrt(Math.pow(t[0]-s[0],2)+Math.pow(t[1]-s[1],2))}var ht=class extends q{fillPolygons(t,s){let e=s.hachureGap;e<0&&(e=4*s.strokeWidth),e=Math.max(e,.1);let n=F(t,Object.assign({},s,{hachureGap:e})),o=Math.PI/180*s.hachureAngle,r=[],h=.5*e*Math.cos(o),i=.5*e*Math.sin(o);for(let[l,c]of n)Y([l,c])&&r.push([[l[0]-h,l[1]+i],[...c]],[[l[0]+h,l[1]-i],[...c]]);return{type:"fillSketch",ops:this.renderLines(r,s)}}},rt=class extends q{fillPolygons(t,s){let e=this._fillPolygons(t,s),n=Object.assign({},s,{hachureAngle:s.hachureAngle+90}),o=this._fillPolygons(t,n);return e.ops=e.ops.concat(o.ops),e}},it=class{constructor(t){this.helper=t}fillPolygons(t,s){let e=F(t,s=Object.assign({},s,{hachureAngle:0}));return this.dotsOnLines(e,s)}dotsOnLines(t,s){let e=[],n=s.hachureGap;n<0&&(n=4*s.strokeWidth),n=Math.max(n,.1);let o=s.fillWeight;o<0&&(o=s.strokeWidth/2);let r=n/4;for(let h of t){let i=Y(h),l=i/n,c=Math.ceil(l)-1,d=i-c*n,p=(h[0][0]+h[1][0])/2-n/4,u=Math.min(h[0][1],h[1][1]);for(let f=0;f{let h=Y(r),i=Math.floor(h/(e+n)),l=(h+n-i*(e+n))/2,c=r[0],d=r[1];c[0]>d[0]&&(c=r[1],d=r[0]);let p=Math.atan((d[1]-c[1])/(d[0]-c[0]));for(let u=0;u{let r=Y(o),h=Math.round(r/(2*s)),i=o[0],l=o[1];i[0]>l[0]&&(i=o[1],l=o[0]);let c=Math.atan((l[1]-i[1])/(l[0]-i[0]));for(let d=0;dc%2?l+s:l+t));o.push({key:"C",data:i}),t=i[4],s=i[5];break}case"Q":o.push({key:"Q",data:[...h]}),t=h[2],s=h[3];break;case"q":{let i=h.map(((l,c)=>c%2?l+s:l+t));o.push({key:"Q",data:i}),t=i[2],s=i[3];break}case"A":o.push({key:"A",data:[...h]}),t=h[5],s=h[6];break;case"a":t+=h[5],s+=h[6],o.push({key:"A",data:[h[0],h[1],h[2],h[3],h[4],t,s]});break;case"H":o.push({key:"H",data:[...h]}),t=h[0];break;case"h":t+=h[0],o.push({key:"H",data:[t]});break;case"V":o.push({key:"V",data:[...h]}),s=h[0];break;case"v":s+=h[0],o.push({key:"V",data:[s]});break;case"S":o.push({key:"S",data:[...h]}),t=h[2],s=h[3];break;case"s":{let i=h.map(((l,c)=>c%2?l+s:l+t));o.push({key:"S",data:i}),t=i[2],s=i[3];break}case"T":o.push({key:"T",data:[...h]}),t=h[0],s=h[1];break;case"t":t+=h[0],s+=h[1],o.push({key:"T",data:[t,s]});break;case"Z":case"z":o.push({key:"Z",data:[]}),t=e,s=n}return o}function Dt(a){let t=[],s="",e=0,n=0,o=0,r=0,h=0,i=0;for(let{key:l,data:c}of a){switch(l){case"M":t.push({key:"M",data:[...c]}),[e,n]=c,[o,r]=c;break;case"C":t.push({key:"C",data:[...c]}),e=c[4],n=c[5],h=c[2],i=c[3];break;case"L":t.push({key:"L",data:[...c]}),[e,n]=c;break;case"H":e=c[0],t.push({key:"L",data:[e,n]});break;case"V":n=c[0],t.push({key:"L",data:[e,n]});break;case"S":{let d=0,p=0;s==="C"||s==="S"?(d=e+(e-h),p=n+(n-i)):(d=e,p=n),t.push({key:"C",data:[d,p,...c]}),h=c[0],i=c[1],e=c[2],n=c[3];break}case"T":{let[d,p]=c,u=0,f=0;s==="Q"||s==="T"?(u=e+(e-h),f=n+(n-i)):(u=e,f=n);let g=e+2*(u-e)/3,k=n+2*(f-n)/3,b=d+2*(u-d)/3,M=p+2*(f-p)/3;t.push({key:"C",data:[g,k,b,M,d,p]}),h=u,i=f,e=d,n=p;break}case"Q":{let[d,p,u,f]=c,g=e+2*(d-e)/3,k=n+2*(p-n)/3,b=u+2*(d-u)/3,M=f+2*(p-f)/3;t.push({key:"C",data:[g,k,b,M,u,f]}),h=d,i=p,e=u,n=f;break}case"A":{let d=Math.abs(c[0]),p=Math.abs(c[1]),u=c[2],f=c[3],g=c[4],k=c[5],b=c[6];d===0||p===0?(t.push({key:"C",data:[e,n,k,b,k,b]}),e=k,n=b):(e!==k||n!==b)&&(At(e,n,k,b,d,p,u,f,g).forEach((function(M){t.push({key:"C",data:M})})),e=k,n=b);break}case"Z":t.push({key:"Z",data:[]}),e=o,n=r}s=l}return t}function R(a,t,s){return[a*Math.cos(s)-t*Math.sin(s),a*Math.sin(s)+t*Math.cos(s)]}function At(a,t,s,e,n,o,r,h,i,l){let c=(d=r,Math.PI*d/180);var d;let p=[],u=0,f=0,g=0,k=0;if(l)[u,f,g,k]=l;else{[a,t]=R(a,t,-c),[s,e]=R(s,e,-c);let T=(a-s)/2,v=(t-e)/2,_=T*T/(n*n)+v*v/(o*o);_>1&&(_=Math.sqrt(_),n*=_,o*=_);let W=n*n,E=o*o,zt=W*E-W*v*v-E*T*T,Wt=W*v*v+E*T*T,yt=(h===i?-1:1)*Math.sqrt(Math.abs(zt/Wt));g=yt*n*v/o+(a+s)/2,k=yt*-o*T/n+(t+e)/2,u=Math.asin(parseFloat(((t-k)/o).toFixed(9))),f=Math.asin(parseFloat(((e-k)/o).toFixed(9))),af&&(u-=2*Math.PI),!i&&f>u&&(f-=2*Math.PI)}let b=f-u;if(Math.abs(b)>120*Math.PI/180){let T=f,v=s,_=e;f=i&&f>u?u+120*Math.PI/180*1:u+120*Math.PI/180*-1,p=At(s=g+n*Math.cos(f),e=k+o*Math.sin(f),v,_,n,o,r,0,i,[f,T,g,k])}b=f-u;let M=Math.cos(u),m=Math.sin(u),P=Math.cos(f),w=Math.sin(f),x=Math.tan(b/4),L=4/3*n*x,A=4/3*o*x,Z=[a,t],D=[a+L*m,t-A*M],C=[s+L*w,e-A*P],bt=[s,e];if(D[0]=2*Z[0]-D[0],D[1]=2*Z[1]-D[1],l)return[D,C,bt].concat(p);{p=[D,C,bt].concat(p);let T=[];for(let v=0;v2){let n=[];for(let o=0;o2*Math.PI&&(u=0,f=2*Math.PI);let g=2*Math.PI/i.curveStepCount,k=Math.min(g/2,(f-u)/2),b=Ot(k,l,c,d,p,u,f,1,i);if(!i.disableMultiStroke){let M=Ot(k,l,c,d,p,u,f,1.5,i);b.push(...M)}return r&&(h?b.push(...I(l,c,l+d*Math.cos(u),c+p*Math.sin(u),i),...I(l,c,l+d*Math.cos(f),c+p*Math.sin(f),i)):b.push({op:"lineTo",data:[l,c]},{op:"lineTo",data:[l+d*Math.cos(u),c+p*Math.sin(u)]})),{type:"path",ops:b}}function Pt(a,t){let s=Dt(Tt(kt(a))),e=[],n=[0,0],o=[0,0];for(let{key:r,data:h}of s)switch(r){case"M":o=[h[0],h[1]],n=[h[0],h[1]];break;case"L":e.push(...I(o[0],o[1],h[0],h[1],t)),o=[h[0],h[1]];break;case"C":{let[i,l,c,d,p,u]=h;e.push(...Nt(i,l,c,d,p,u,o,t)),o=[p,u];break}case"Z":e.push(...I(o[0],o[1],n[0],n[1],t)),o=[n[0],n[1]]}return{type:"path",ops:e}}function at(a,t){let s=[];for(let e of a)if(e.length){let n=t.maxRandomnessOffset||0,o=e.length;if(o>2){s.push({op:"move",data:[e[0][0]+y(n,t),e[0][1]+y(n,t)]});for(let r=1;r500?.4:-.0016668*i+1.233334;let c=n.maxRandomnessOffset||0;c*c*100>h&&(c=i/10);let d=c/2,p=.2+.2*Ct(n),u=n.bowing*n.maxRandomnessOffset*(e-t)/200,f=n.bowing*n.maxRandomnessOffset*(a-s)/200;u=y(u,n,l),f=y(f,n,l);let g=[],k=()=>y(d,n,l),b=()=>y(c,n,l),M=n.preserveVertices;return o&&(r?g.push({op:"move",data:[a+(M?0:k()),t+(M?0:k())]}):g.push({op:"move",data:[a+(M?0:y(c,n,l)),t+(M?0:y(c,n,l))]})),r?g.push({op:"bcurveTo",data:[u+a+(s-a)*p+k(),f+t+(e-t)*p+k(),u+a+2*(s-a)*p+k(),f+t+2*(e-t)*p+k(),s+(M?0:k()),e+(M?0:k())]}):g.push({op:"bcurveTo",data:[u+a+(s-a)*p+b(),f+t+(e-t)*p+b(),u+a+2*(s-a)*p+b(),f+t+2*(e-t)*p+b(),s+(M?0:b()),e+(M?0:b())]}),g}function H(a,t,s){if(!a.length)return[];let e=[];e.push([a[0][0]+y(t,s),a[0][1]+y(t,s)]),e.push([a[0][0]+y(t,s),a[0][1]+y(t,s)]);for(let n=1;n3){let o=[],r=1-s.curveTightness;n.push({op:"move",data:[a[1][0],a[1][1]]});for(let h=1;h+21&&n.push(h)):n.push(h),n.push(a[t+3])}else{let i=a[t+0],l=a[t+1],c=a[t+2],d=a[t+3],p=z(i,l,.5),u=z(l,c,.5),f=z(c,d,.5),g=z(p,u,.5),k=z(u,f,.5),b=z(g,k,.5);dt([i,p,g,b],0,s,n),dt([b,k,f,d],0,s,n)}var o,r;return n}function Jt(a,t){return X(a,0,a.length,t)}function X(a,t,s,e,n){let o=n||[],r=a[t],h=a[s-1],i=0,l=1;for(let c=t+1;ci&&(i=d,l=c)}return Math.sqrt(i)>e?(X(a,t,l+1,e,o),X(a,l,s,e,o)):(o.length||o.push(r),o.push(h)),o}function ot(a,t=.15,s){let e=[],n=(a.length-1)/3;for(let o=0;o0?X(e,0,e.length,s):e}var O="none",$=class{constructor(t){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:"#000",strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:"hachure",fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=t||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return Math.floor(Math.random()*2**31)}_o(t){return t?Object.assign({},this.defaultOptions,t):this.defaultOptions}_d(t,s,e){return{shape:t,sets:s||[],options:e||this.defaultOptions}}line(t,s,e,n,o){let r=this._o(o);return this._d("line",[_t(t,s,e,n,r)],r)}rectangle(t,s,e,n,o){let r=this._o(o),h=[],i=Ht(t,s,e,n,r);if(r.fill){let l=[[t,s],[t+e,s],[t+e,s+n],[t,s+n]];r.fillStyle==="solid"?h.push(at([l],r)):h.push(G([l],r))}return r.stroke!==O&&h.push(i),this._d("rectangle",h,r)}ellipse(t,s,e,n,o){let r=this._o(o),h=[],i=It(e,n,r),l=pt(t,s,r,i);if(r.fill)if(r.fillStyle==="solid"){let c=pt(t,s,r,i).opset;c.type="fillPath",h.push(c)}else h.push(G([l.estimatedPoints],r));return r.stroke!==O&&h.push(l.opset),this._d("ellipse",h,r)}circle(t,s,e,n){let o=this.ellipse(t,s,e,e,n);return o.shape="circle",o}linearPath(t,s){let e=this._o(s);return this._d("linearPath",[B(t,!1,e)],e)}arc(t,s,e,n,o,r,h=!1,i){let l=this._o(i),c=[],d=wt(t,s,e,n,o,r,h,!0,l);if(h&&l.fill)if(l.fillStyle==="solid"){let p=Object.assign({},l);p.disableMultiStroke=!0;let u=wt(t,s,e,n,o,r,!0,!1,p);u.type="fillPath",c.push(u)}else c.push((function(p,u,f,g,k,b,M){let m=p,P=u,w=Math.abs(f/2),x=Math.abs(g/2);w+=y(.01*w,M),x+=y(.01*x,M);let L=k,A=b;for(;L<0;)L+=2*Math.PI,A+=2*Math.PI;A-L>2*Math.PI&&(L=0,A=2*Math.PI);let Z=(A-L)/M.curveStepCount,D=[];for(let C=L;C<=A;C+=Z)D.push([m+w*Math.cos(C),P+x*Math.sin(C)]);return D.push([m+w*Math.cos(A),P+x*Math.sin(A)]),D.push([m,P]),G([D],M)})(t,s,e,n,o,r,l));return l.stroke!==O&&c.push(d),this._d("arc",c,l)}curve(t,s){let e=this._o(s),n=[],o=xt(t,e);if(e.fill&&e.fill!==O)if(e.fillStyle==="solid"){let r=xt(t,Object.assign(Object.assign({},e),{disableMultiStroke:!0,roughness:e.roughness?e.roughness+e.fillShapeRoughnessGain:0}));n.push({type:"fillPath",ops:this._mergedShape(r.ops)})}else{let r=[],h=t;if(h.length){let i=typeof h[0][0]=="number"?[h]:h;for(let l of i)l.length<3?r.push(...l):l.length===3?r.push(...ot(Lt([l[0],l[0],l[1],l[2]]),10,(1+e.roughness)/2)):r.push(...ot(Lt(l),10,(1+e.roughness)/2))}r.length&&n.push(G([r],e))}return e.stroke!==O&&n.push(o),this._d("curve",n,e)}polygon(t,s){let e=this._o(s),n=[],o=B(t,!0,e);return e.fill&&(e.fillStyle==="solid"?n.push(at([t],e)):n.push(G([t],e))),e.stroke!==O&&n.push(o),this._d("polygon",n,e)}path(t,s){let e=this._o(s),n=[];if(!t)return this._d("path",n,e);t=(t||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");let o=e.fill&&e.fill!=="transparent"&&e.fill!==O,r=e.stroke!==O,h=!!(e.simplification&&e.simplification<1),i=(function(c,d,p){let u=Dt(Tt(kt(c))),f=[],g=[],k=[0,0],b=[],M=()=>{b.length>=4&&g.push(...ot(b,d)),b=[]},m=()=>{M(),g.length&&(f.push(g),g=[])};for(let{key:w,data:x}of u)switch(w){case"M":m(),k=[x[0],x[1]],g.push(k);break;case"L":M(),g.push([x[0],x[1]]);break;case"C":if(!b.length){let L=g.length?g[g.length-1]:k;b.push([L[0],L[1]])}b.push([x[0],x[1]]),b.push([x[2],x[3]]),b.push([x[4],x[5]]);break;case"Z":M(),g.push([k[0],k[1]])}if(m(),!p)return f;let P=[];for(let w of f){let x=Jt(w,p);x.length&&P.push(x)}return P})(t,1,h?4-4*(e.simplification||1):(1+e.roughness)/2),l=Pt(t,e);if(o)if(e.fillStyle==="solid")if(i.length===1){let c=Pt(t,Object.assign(Object.assign({},e),{disableMultiStroke:!0,roughness:e.roughness?e.roughness+e.fillShapeRoughnessGain:0}));n.push({type:"fillPath",ops:this._mergedShape(c.ops)})}else n.push(at(i,e));else n.push(G(i,e));return r&&(h?i.forEach((c=>{n.push(B(c,!1,e))})):n.push(l)),this._d("path",n,e)}opsToPath(t,s){let e="";for(let n of t.ops){let o=typeof s=="number"&&s>=0?n.data.map((r=>+r.toFixed(s))):n.data;switch(n.op){case"move":e+=`M${o[0]} ${o[1]} `;break;case"bcurveTo":e+=`C${o[0]} ${o[1]}, ${o[2]} ${o[3]}, ${o[4]} ${o[5]} `;break;case"lineTo":e+=`L${o[0]} ${o[1]} `}}return e.trim()}toPaths(t){let s=t.sets||[],e=t.options||this.defaultOptions,n=[];for(let o of s){let r=null;switch(o.type){case"path":r={d:this.opsToPath(o),stroke:e.stroke,strokeWidth:e.strokeWidth,fill:O};break;case"fillPath":r={d:this.opsToPath(o),stroke:O,strokeWidth:0,fill:e.fill||O};break;case"fillSketch":r=this.fillSketch(o,e)}r&&n.push(r)}return n}fillSketch(t,s){let e=s.fillWeight;return e<0&&(e=s.strokeWidth/2),{d:this.opsToPath(t),stroke:s.fill||O,strokeWidth:e,fill:O}}_mergedShape(t){return t.filter(((s,e)=>e===0||s.op!=="move"))}},gt=class{constructor(t,s){this.canvas=t,this.ctx=this.canvas.getContext("2d"),this.gen=new $(s)}draw(t){let s=t.sets||[],e=t.options||this.getDefaultOptions(),n=this.ctx,o=t.options.fixedDecimalPlaceDigits;for(let r of s)switch(r.type){case"path":n.save(),n.strokeStyle=e.stroke==="none"?"transparent":e.stroke,n.lineWidth=e.strokeWidth,e.strokeLineDash&&n.setLineDash(e.strokeLineDash),e.strokeLineDashOffset&&(n.lineDashOffset=e.strokeLineDashOffset),this._drawToContext(n,r,o),n.restore();break;case"fillPath":{n.save(),n.fillStyle=e.fill||"";let h=t.shape==="curve"||t.shape==="polygon"||t.shape==="path"?"evenodd":"nonzero";this._drawToContext(n,r,o,h),n.restore();break}case"fillSketch":this.fillSketch(n,r,e)}}fillSketch(t,s,e){let n=e.fillWeight;n<0&&(n=e.strokeWidth/2),t.save(),e.fillLineDash&&t.setLineDash(e.fillLineDash),e.fillLineDashOffset&&(t.lineDashOffset=e.fillLineDashOffset),t.strokeStyle=e.fill||"",t.lineWidth=n,this._drawToContext(t,s,e.fixedDecimalPlaceDigits),t.restore()}_drawToContext(t,s,e,n="nonzero"){t.beginPath();for(let o of s.ops){let r=typeof e=="number"&&e>=0?o.data.map((h=>+h.toFixed(e))):o.data;switch(o.op){case"move":t.moveTo(r[0],r[1]);break;case"bcurveTo":t.bezierCurveTo(r[0],r[1],r[2],r[3],r[4],r[5]);break;case"lineTo":t.lineTo(r[0],r[1])}}s.type==="fillPath"?t.fill(n):t.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(t,s,e,n,o){let r=this.gen.line(t,s,e,n,o);return this.draw(r),r}rectangle(t,s,e,n,o){let r=this.gen.rectangle(t,s,e,n,o);return this.draw(r),r}ellipse(t,s,e,n,o){let r=this.gen.ellipse(t,s,e,n,o);return this.draw(r),r}circle(t,s,e,n){let o=this.gen.circle(t,s,e,n);return this.draw(o),o}linearPath(t,s){let e=this.gen.linearPath(t,s);return this.draw(e),e}polygon(t,s){let e=this.gen.polygon(t,s);return this.draw(e),e}arc(t,s,e,n,o,r,h=!1,i){let l=this.gen.arc(t,s,e,n,o,r,h,i);return this.draw(l),l}curve(t,s){let e=this.gen.curve(t,s);return this.draw(e),e}path(t,s){let e=this.gen.path(t,s);return this.draw(e),e}},N="http://www.w3.org/2000/svg",Mt=class{constructor(t,s){this.svg=t,this.gen=new $(s)}draw(t){let s=t.sets||[],e=t.options||this.getDefaultOptions(),n=this.svg.ownerDocument||window.document,o=n.createElementNS(N,"g"),r=t.options.fixedDecimalPlaceDigits;for(let h of s){let i=null;switch(h.type){case"path":i=n.createElementNS(N,"path"),i.setAttribute("d",this.opsToPath(h,r)),i.setAttribute("stroke",e.stroke),i.setAttribute("stroke-width",e.strokeWidth+""),i.setAttribute("fill","none"),e.strokeLineDash&&i.setAttribute("stroke-dasharray",e.strokeLineDash.join(" ").trim()),e.strokeLineDashOffset&&i.setAttribute("stroke-dashoffset",`${e.strokeLineDashOffset}`);break;case"fillPath":i=n.createElementNS(N,"path"),i.setAttribute("d",this.opsToPath(h,r)),i.setAttribute("stroke","none"),i.setAttribute("stroke-width","0"),i.setAttribute("fill",e.fill||""),t.shape!=="curve"&&t.shape!=="polygon"||i.setAttribute("fill-rule","evenodd");break;case"fillSketch":i=this.fillSketch(n,h,e)}i&&o.appendChild(i)}return o}fillSketch(t,s,e){let n=e.fillWeight;n<0&&(n=e.strokeWidth/2);let o=t.createElementNS(N,"path");return o.setAttribute("d",this.opsToPath(s,e.fixedDecimalPlaceDigits)),o.setAttribute("stroke",e.fill||""),o.setAttribute("stroke-width",n+""),o.setAttribute("fill","none"),e.fillLineDash&&o.setAttribute("stroke-dasharray",e.fillLineDash.join(" ").trim()),e.fillLineDashOffset&&o.setAttribute("stroke-dashoffset",`${e.fillLineDashOffset}`),o}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(t,s){return this.gen.opsToPath(t,s)}line(t,s,e,n,o){let r=this.gen.line(t,s,e,n,o);return this.draw(r)}rectangle(t,s,e,n,o){let r=this.gen.rectangle(t,s,e,n,o);return this.draw(r)}ellipse(t,s,e,n,o){let r=this.gen.ellipse(t,s,e,n,o);return this.draw(r)}circle(t,s,e,n){let o=this.gen.circle(t,s,e,n);return this.draw(o)}linearPath(t,s){let e=this.gen.linearPath(t,s);return this.draw(e)}polygon(t,s){let e=this.gen.polygon(t,s);return this.draw(e)}arc(t,s,e,n,o,r,h=!1,i){let l=this.gen.arc(t,s,e,n,o,r,h,i);return this.draw(l)}curve(t,s){let e=this.gen.curve(t,s);return this.draw(e)}path(t,s){let e=this.gen.path(t,s);return this.draw(e)}},V={canvas:(a,t)=>new gt(a,t),svg:(a,t)=>new Mt(a,t),generator:a=>new $(a),newSeed:()=>$.newSeed()};var Kt=V,Ut=V.canvas,Xt=V.svg,Yt=V.generator;return qt(te);})(); diff --git a/android/app/src/main/assets/pulsewall/libs/tailwind-lite.min.css b/android/app/src/main/assets/pulsewall/libs/tailwind-lite.min.css new file mode 100644 index 0000000..1710e3d --- /dev/null +++ b/android/app/src/main/assets/pulsewall/libs/tailwind-lite.min.css @@ -0,0 +1,31 @@ +/* PulseWall Prebuilt Tailwind-Compatible Utility Subset (Android 11 WebView safe, zero JS runtime) */ +.flex{display:flex}.inline-flex{display:inline-flex}.grid{display:grid}.block{display:block}.inline-block{display:inline-block}.hidden{display:none} +.flex-col{flex-direction:column}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0} +.items-center{align-items:center}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-stretch{align-items:stretch} +.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start} +.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))} +.col-span-2{grid-column:span 2/span 2}.col-span-full{grid-column:1/-1} +.gap-1{gap:4px}.gap-2{gap:8px}.gap-3{gap:12px}.gap-4{gap:16px}.gap-5{gap:20px}.gap-6{gap:24px} +.space-y-2>*+*{margin-top:8px}.space-y-3>*+*{margin-top:12px}.space-y-4>*+*{margin-top:16px} +.p-1{padding:4px}.p-2{padding:8px}.p-3{padding:12px}.p-4{padding:16px}.p-5{padding:20px}.p-6{padding:24px} +.px-2{padding-left:8px;padding-right:8px}.px-3{padding-left:12px;padding-right:12px}.px-4{padding-left:16px;padding-right:16px}.px-5{padding-left:20px;padding-right:20px} +.py-1{padding-top:4px;padding-bottom:4px}.py-2{padding-top:8px;padding-bottom:8px}.py-3{padding-top:12px;padding-bottom:12px}.py-4{padding-top:16px;padding-bottom:16px} +.m-0{margin:0}.mt-1{margin-top:4px}.mt-2{margin-top:8px}.mt-3{margin-top:12px}.mt-4{margin-top:16px}.mb-2{margin-bottom:8px}.mb-3{margin-bottom:12px}.mb-4{margin-bottom:16px}.mx-auto{margin-left:auto;margin-right:auto} +.w-full{width:100%}.h-full{height:100%}.min-h-screen{min-height:100vh}.max-w-full{max-width:100%}.aspect-video{aspect-ratio:16/9} +.relative{position:relative}.absolute{position:absolute}.inset-0{top:0;right:0;bottom:0;left:0}.overflow-hidden{overflow:hidden}.overflow-auto{overflow:auto} +.rounded{border-radius:6px}.rounded-lg{border-radius:10px}.rounded-xl{border-radius:14px}.rounded-2xl{border-radius:18px}.rounded-full{border-radius:9999px} +.border{border:1px solid rgba(148,163,184,0.22)}.border-slate-700{border-color:#334155}.border-slate-800{border-color:#1e293b}.border-cyan-500{border-color:#06b6d4}.border-teal-400{border-color:#2dd4bf}.border-amber-500{border-color:#f59e0b}.border-red-500{border-color:#ef4444} +.text-xs{font-size:12px;line-height:16px}.text-sm{font-size:14px;line-height:20px}.text-base{font-size:16px;line-height:24px}.text-lg{font-size:18px;line-height:26px}.text-xl{font-size:20px;line-height:28px}.text-2xl{font-size:24px;line-height:32px}.text-3xl{font-size:30px;line-height:36px}.text-4xl{font-size:36px;line-height:40px} +.font-medium{font-weight:500}.font-semibold{font-weight:600}.font-bold{font-weight:700}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace} +.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +.text-white{color:#fff}.text-slate-200{color:#e2e8f0}.text-slate-300{color:#cbd5e1}.text-slate-400{color:#94a3b8}.text-slate-500{color:#64748b} +.text-teal-400{color:#2dd4bf}.text-cyan-400{color:#22d3ee}.text-sky-400{color:#38bdf8}.text-emerald-400{color:#34d399}.text-amber-400{color:#fbbf24}.text-red-400{color:#f87171}.text-rose-400{color:#fb7185} +.bg-slate-950{background-color:#020617}.bg-slate-900{background-color:#0f172a}.bg-slate-800{background-color:#1e293b}.bg-slate-700{background-color:#334155} +.bg-teal-500{background-color:#14b8a6}.bg-cyan-500{background-color:#06b6d4}.bg-sky-500{background-color:#0ea5e9}.bg-emerald-500{background-color:#10b981}.bg-amber-500{background-color:#f59e0b}.bg-red-600{background-color:#dc2626} +.bg-slate-900\/80{background-color:rgba(15,23,42,0.8)}.bg-slate-800\/80{background-color:rgba(30,41,59,0.8)} +.shadow-lg{box-shadow:0 10px 24px rgba(0,0,0,0.35)}.opacity-60{opacity:0.6}.opacity-80{opacity:0.8} +.cursor-pointer{cursor:pointer}.transition{transition:all 0.15s ease} +@keyframes pw-pulse{0%,100%{opacity:1}50%{opacity:.45}}.animate-pulse{animation:pw-pulse 1.8s cubic-bezier(.4,0,.6,1) infinite} +@keyframes pw-spin{to{transform:rotate(360deg)}}.animate-spin{animation:pw-spin 1s linear infinite} +@media(min-width:640px){.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}} +@media(min-width:900px){.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}} \ No newline at end of file diff --git a/android/app/src/main/assets/pulsewall/libs/three.min.js b/android/app/src/main/assets/pulsewall/libs/three.min.js new file mode 100644 index 0000000..f206284 --- /dev/null +++ b/android/app/src/main/assets/pulsewall/libs/three.min.js @@ -0,0 +1,3833 @@ +var THREE=(()=>{var Xc=Object.defineProperty;var wp=Object.getOwnPropertyDescriptor;var Ap=Object.getOwnPropertyNames;var Cp=Object.prototype.hasOwnProperty;var Rp=(s,t)=>{for(var e in t)Xc(s,e,{get:t[e],enumerable:!0})},Ip=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ap(t))!Cp.call(s,i)&&i!==e&&Xc(s,i,{get:()=>t[i],enumerable:!(n=wp(t,i))||n.enumerable});return s};var Pp=s=>Ip(Xc({},"__esModule",{value:!0}),s);var Dy={};Rp(Dy,{ACESFilmicToneMapping:()=>kf,AddEquation:()=>ei,AddOperation:()=>Ff,AdditiveAnimationBlendMode:()=>_u,AdditiveBlending:()=>Ul,AgXToneMapping:()=>Hf,AlphaFormat:()=>uu,AlwaysCompare:()=>ip,AlwaysDepth:()=>Ga,AlwaysStencilFunc:()=>Bl,AmbientLight:()=>bc,AnimationAction:()=>Dc,AnimationClip:()=>Wi,AnimationLoader:()=>mh,AnimationMixer:()=>Lh,AnimationObjectGroup:()=>Ph,AnimationUtils:()=>gy,ArcCurve:()=>Vo,ArrayCamera:()=>Ao,ArrowHelper:()=>eu,AttachedBindMode:()=>Ol,Audio:()=>Pc,AudioAnalyser:()=>Rh,AudioContext:()=>Hr,AudioListener:()=>Ah,AudioLoader:()=>Th,AxesHelper:()=>nu,BackSide:()=>Be,BasicDepthPacking:()=>Zf,BasicShadowMap:()=>Np,BatchedMesh:()=>Fo,Bone:()=>br,BooleanKeyframeTrack:()=>Wn,Box2:()=>Hh,Box3:()=>we,Box3Helper:()=>jh,BoxGeometry:()=>Ui,BoxHelper:()=>Qh,BufferAttribute:()=>ne,BufferGeometry:()=>Wt,BufferGeometryLoader:()=>Rc,ByteType:()=>cu,Cache:()=>Fn,Camera:()=>bs,CameraHelper:()=>Kh,CanvasTexture:()=>hh,CapsuleGeometry:()=>Yo,CatmullRomCurve3:()=>Ho,CineonToneMapping:()=>zf,CircleGeometry:()=>Zo,ClampToEdgeWrapping:()=>en,Clock:()=>Ic,Color:()=>ut,ColorKeyframeTrack:()=>Br,ColorManagement:()=>Yt,CompressedArrayTexture:()=>ch,CompressedCubeTexture:()=>lh,CompressedTexture:()=>As,CompressedTextureLoader:()=>gh,ConeGeometry:()=>Jo,ConstantAlphaFactor:()=>Df,ConstantColorFactor:()=>Pf,Controls:()=>su,CubeCamera:()=>To,CubeReflectionMapping:()=>Hn,CubeRefractionMapping:()=>ii,CubeTexture:()=>Ni,CubeTextureLoader:()=>_h,CubeUVReflectionMapping:()=>Is,CubicBezierCurve:()=>Tr,CubicBezierCurve3:()=>Go,CubicInterpolant:()=>gc,CullFaceBack:()=>Dl,CullFaceFront:()=>mf,CullFaceFrontBack:()=>Up,CullFaceNone:()=>pf,Curve:()=>Ke,CurvePath:()=>qo,CustomBlending:()=>_f,CustomToneMapping:()=>Vf,CylinderGeometry:()=>Rs,Cylindrical:()=>kh,Data3DTexture:()=>mr,DataArrayTexture:()=>ys,DataTexture:()=>nn,DataTextureLoader:()=>xh,DataUtils:()=>Ym,DecrementStencilOp:()=>Jp,DecrementWrapStencilOp:()=>Kp,DefaultLoadingManager:()=>Mp,DepthFormat:()=>Ri,DepthStencilFormat:()=>Di,DepthTexture:()=>vr,DetachedBindMode:()=>Wf,DirectionalLight:()=>Sc,DirectionalLightHelper:()=>$h,DiscreteInterpolant:()=>_c,DodecahedronGeometry:()=>$o,DoubleSide:()=>gn,DstAlphaFactor:()=>wf,DstColorFactor:()=>Cf,DynamicCopyUsage:()=>dm,DynamicDrawUsage:()=>am,DynamicReadUsage:()=>lm,EdgesGeometry:()=>Ko,EllipseCurve:()=>Cs,EqualCompare:()=>jf,EqualDepth:()=>Xa,EqualStencilFunc:()=>em,EquirectangularReflectionMapping:()=>ar,EquirectangularRefractionMapping:()=>or,Euler:()=>Je,EventDispatcher:()=>sn,ExtrudeGeometry:()=>Qo,FileLoader:()=>dn,Float16BufferAttribute:()=>Yl,Float32BufferAttribute:()=>Mt,FloatType:()=>Ge,Fog:()=>Ro,FogExp2:()=>Co,FramebufferTexture:()=>oh,FrontSide:()=>Vn,Frustum:()=>Fi,GLBufferAttribute:()=>Fh,GLSL1:()=>pm,GLSL3:()=>zl,GreaterCompare:()=>tp,GreaterDepth:()=>Ya,GreaterEqualCompare:()=>np,GreaterEqualDepth:()=>qa,GreaterEqualStencilFunc:()=>rm,GreaterStencilFunc:()=>im,GridHelper:()=>Zh,Group:()=>ni,HalfFloatType:()=>Ps,HemisphereLight:()=>vc,HemisphereLightHelper:()=>Yh,IcosahedronGeometry:()=>jo,ImageBitmapLoader:()=>Eh,ImageLoader:()=>Xi,ImageUtils:()=>bo,IncrementStencilOp:()=>Zp,IncrementWrapStencilOp:()=>$p,InstancedBufferAttribute:()=>ri,InstancedBufferGeometry:()=>Cc,InstancedInterleavedBuffer:()=>Nh,InstancedMesh:()=>No,Int16BufferAttribute:()=>Xl,Int32BufferAttribute:()=>ql,Int8BufferAttribute:()=>Hl,IntType:()=>Nc,InterleavedBuffer:()=>ws,InterleavedBufferAttribute:()=>Oi,Interpolant:()=>ki,InterpolateDiscrete:()=>hr,InterpolateLinear:()=>So,InterpolateSmooth:()=>za,InvertStencilOp:()=>Qp,KeepStencilOp:()=>Si,KeyframeTrack:()=>Qe,LOD:()=>Lo,LatheGeometry:()=>Ir,Layers:()=>Ms,LessCompare:()=>Qf,LessDepth:()=>Wa,LessEqualCompare:()=>xu,LessEqualDepth:()=>Pi,LessEqualStencilFunc:()=>nm,LessStencilFunc:()=>tm,Light:()=>En,LightProbe:()=>wc,Line:()=>bn,Line3:()=>Gh,LineBasicMaterial:()=>Ae,LineCurve:()=>wr,LineCurve3:()=>Wo,LineDashedMaterial:()=>mc,LineLoop:()=>zo,LineSegments:()=>rn,LinearFilter:()=>ve,LinearInterpolant:()=>Or,LinearMipMapLinearFilter:()=>zp,LinearMipMapNearestFilter:()=>Bp,LinearMipmapLinearFilter:()=>xn,LinearMipmapNearestFilter:()=>$s,LinearSRGBColorSpace:()=>qi,LinearToneMapping:()=>Of,LinearTransfer:()=>Xr,Loader:()=>De,LoaderUtils:()=>Vr,LoadingManager:()=>zr,LoopOnce:()=>Xf,LoopPingPong:()=>Yf,LoopRepeat:()=>qf,LuminanceAlphaFormat:()=>pu,LuminanceFormat:()=>fu,MOUSE:()=>Lp,Material:()=>Ee,MaterialLoader:()=>Ac,MathUtils:()=>Pm,Matrix2:()=>Vh,Matrix3:()=>Bt,Matrix4:()=>Ut,MaxEquation:()=>Mf,Mesh:()=>pe,MeshBasicMaterial:()=>Sn,MeshDepthMaterial:()=>yr,MeshDistanceMaterial:()=>Mr,MeshLambertMaterial:()=>fc,MeshMatcapMaterial:()=>pc,MeshNormalMaterial:()=>dc,MeshPhongMaterial:()=>hc,MeshPhysicalMaterial:()=>lc,MeshStandardMaterial:()=>Fr,MeshToonMaterial:()=>uc,MinEquation:()=>yf,MirroredRepeatWrapping:()=>lr,MixOperation:()=>Nf,MultiplyBlending:()=>Fl,MultiplyOperation:()=>Gr,NearestFilter:()=>Te,NearestMipMapLinearFilter:()=>Op,NearestMipMapNearestFilter:()=>Fp,NearestMipmapLinearFilter:()=>ds,NearestMipmapNearestFilter:()=>ou,NeutralToneMapping:()=>Gf,NeverCompare:()=>Kf,NeverDepth:()=>Ha,NeverStencilFunc:()=>jp,NoBlending:()=>On,NoColorSpace:()=>Dn,NoToneMapping:()=>Bn,NormalAnimationBlendMode:()=>Vc,NormalBlending:()=>Ci,NotEqualCompare:()=>ep,NotEqualDepth:()=>Za,NotEqualStencilFunc:()=>sm,NumberKeyframeTrack:()=>Vi,Object3D:()=>Qt,ObjectLoader:()=>bh,ObjectSpaceNormalMap:()=>$f,OctahedronGeometry:()=>Ur,OneFactor:()=>bf,OneMinusConstantAlphaFactor:()=>Uf,OneMinusConstantColorFactor:()=>Lf,OneMinusDstAlphaFactor:()=>Af,OneMinusDstColorFactor:()=>Rf,OneMinusSrcAlphaFactor:()=>Va,OneMinusSrcColorFactor:()=>Tf,OrthographicCamera:()=>Ts,PCFShadowMap:()=>au,PCFSoftShadowMap:()=>gf,PMREMGenerator:()=>xr,Path:()=>Bi,PerspectiveCamera:()=>xe,Plane:()=>mn,PlaneGeometry:()=>Es,PlaneHelper:()=>tu,PointLight:()=>Mc,PointLightHelper:()=>qh,Points:()=>ko,PointsMaterial:()=>Er,PolarGridHelper:()=>Jh,PolyhedronGeometry:()=>ai,PositionalAudio:()=>Ch,PropertyBinding:()=>re,PropertyMixer:()=>Lc,QuadraticBezierCurve:()=>Ar,QuadraticBezierCurve3:()=>Cr,Quaternion:()=>Le,QuaternionKeyframeTrack:()=>Hi,QuaternionLinearInterpolant:()=>xc,RED_GREEN_RGTC2_Format:()=>yo,RED_RGTC1_Format:()=>gu,REVISION:()=>Ny,RGBADepthPacking:()=>Jf,RGBAFormat:()=>Oe,RGBAIntegerFormat:()=>kc,RGBA_ASTC_10x10_Format:()=>po,RGBA_ASTC_10x5_Format:()=>ho,RGBA_ASTC_10x6_Format:()=>uo,RGBA_ASTC_10x8_Format:()=>fo,RGBA_ASTC_12x10_Format:()=>mo,RGBA_ASTC_12x12_Format:()=>go,RGBA_ASTC_4x4_Format:()=>no,RGBA_ASTC_5x4_Format:()=>io,RGBA_ASTC_5x5_Format:()=>so,RGBA_ASTC_6x5_Format:()=>ro,RGBA_ASTC_6x6_Format:()=>ao,RGBA_ASTC_8x5_Format:()=>oo,RGBA_ASTC_8x6_Format:()=>co,RGBA_ASTC_8x8_Format:()=>lo,RGBA_BPTC_Format:()=>er,RGBA_ETC2_EAC_Format:()=>eo,RGBA_PVRTC_2BPPV1_Format:()=>Qa,RGBA_PVRTC_4BPPV1_Format:()=>Ka,RGBA_S3TC_DXT1_Format:()=>Qs,RGBA_S3TC_DXT3_Format:()=>js,RGBA_S3TC_DXT5_Format:()=>tr,RGBDepthPacking:()=>Wp,RGBFormat:()=>du,RGBIntegerFormat:()=>kp,RGB_BPTC_SIGNED_Format:()=>_o,RGB_BPTC_UNSIGNED_Format:()=>xo,RGB_ETC1_Format:()=>ja,RGB_ETC2_Format:()=>to,RGB_PVRTC_2BPPV1_Format:()=>$a,RGB_PVRTC_4BPPV1_Format:()=>Ja,RGB_S3TC_DXT1_Format:()=>Ks,RGDepthPacking:()=>Xp,RGFormat:()=>mu,RGIntegerFormat:()=>zc,RawShaderMaterial:()=>cc,Ray:()=>si,Raycaster:()=>Oh,RectAreaLight:()=>Ec,RedFormat:()=>Bc,RedIntegerFormat:()=>Wr,ReinhardToneMapping:()=>Bf,RenderTarget:()=>Eo,RepeatWrapping:()=>cr,ReplaceStencilOp:()=>Yp,ReverseSubtractEquation:()=>vf,RingGeometry:()=>tc,SIGNED_RED_GREEN_RGTC2_Format:()=>Mo,SIGNED_RED_RGTC1_Format:()=>vo,SRGBColorSpace:()=>He,SRGBTransfer:()=>se,Scene:()=>Io,ShaderChunk:()=>Gt,ShaderLib:()=>un,ShaderMaterial:()=>$e,ShadowMaterial:()=>oc,Shape:()=>kn,ShapeGeometry:()=>ec,ShapePath:()=>iu,ShapeUtils:()=>yn,ShortType:()=>lu,Skeleton:()=>Uo,SkeletonHelper:()=>Xh,SkinnedMesh:()=>Do,Source:()=>Nn,Sphere:()=>be,SphereGeometry:()=>Nr,Spherical:()=>zh,SphericalHarmonics3:()=>Tc,SplineCurve:()=>Rr,SpotLight:()=>yc,SpotLightHelper:()=>Wh,Sprite:()=>Po,SpriteMaterial:()=>Sr,SrcAlphaFactor:()=>ka,SrcAlphaSaturateFactor:()=>If,SrcColorFactor:()=>Ef,StaticCopyUsage:()=>um,StaticDrawUsage:()=>dr,StaticReadUsage:()=>cm,StereoCamera:()=>wh,StreamCopyUsage:()=>fm,StreamDrawUsage:()=>om,StreamReadUsage:()=>hm,StringKeyframeTrack:()=>Xn,SubtractEquation:()=>xf,SubtractiveBlending:()=>Nl,TOUCH:()=>Dp,TangentSpaceNormalMap:()=>oi,TetrahedronGeometry:()=>nc,Texture:()=>_e,TextureLoader:()=>vh,TextureUtils:()=>Tv,TorusGeometry:()=>ic,TorusKnotGeometry:()=>sc,Triangle:()=>_n,TriangleFanDrawMode:()=>Gp,TriangleStripDrawMode:()=>Hp,TrianglesDrawMode:()=>Vp,TubeGeometry:()=>rc,UVMapping:()=>Uc,Uint16BufferAttribute:()=>gr,Uint32BufferAttribute:()=>_r,Uint8BufferAttribute:()=>Gl,Uint8ClampedBufferAttribute:()=>Wl,Uniform:()=>Dh,UniformsGroup:()=>Uh,UniformsLib:()=>ct,UniformsUtils:()=>cp,UnsignedByteType:()=>Mn,UnsignedInt248Type:()=>Li,UnsignedInt5999Type:()=>hu,UnsignedIntType:()=>Gn,UnsignedShort4444Type:()=>Fc,UnsignedShort5551Type:()=>Oc,UnsignedShortType:()=>xs,VSMShadowMap:()=>pn,Vector2:()=>$,Vector3:()=>A,Vector4:()=>$t,VectorKeyframeTrack:()=>Gi,VideoTexture:()=>ah,WebGL3DRenderTarget:()=>Vl,WebGLArrayRenderTarget:()=>kl,WebGLCoordinateSystem:()=>vn,WebGLCubeRenderTarget:()=>wo,WebGLMultipleRenderTargets:()=>ru,WebGLRenderTarget:()=>Ze,WebGLRenderer:()=>ih,WebGLUtils:()=>pp,WebGPUCoordinateSystem:()=>fr,WireframeGeometry:()=>ac,WrapAroundEnding:()=>ur,ZeroCurvatureEnding:()=>Ti,ZeroFactor:()=>Sf,ZeroSlopeEnding:()=>wi,ZeroStencilOp:()=>qp,createCanvasElement:()=>rp});var Ny="170",Lp={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Dp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},pf=0,Dl=1,mf=2,Up=3,Np=0,au=1,gf=2,pn=3,Vn=0,Be=1,gn=2,On=0,Ci=1,Ul=2,Nl=3,Fl=4,_f=5,ei=100,xf=101,vf=102,yf=103,Mf=104,Sf=200,bf=201,Ef=202,Tf=203,ka=204,Va=205,wf=206,Af=207,Cf=208,Rf=209,If=210,Pf=211,Lf=212,Df=213,Uf=214,Ha=0,Ga=1,Wa=2,Pi=3,Xa=4,qa=5,Ya=6,Za=7,Gr=0,Nf=1,Ff=2,Bn=0,Of=1,Bf=2,zf=3,kf=4,Vf=5,Hf=6,Gf=7,Ol="attached",Wf="detached",Uc=300,Hn=301,ii=302,ar=303,or=304,Is=306,cr=1e3,en=1001,lr=1002,Te=1003,ou=1004,Fp=1004,ds=1005,Op=1005,ve=1006,$s=1007,Bp=1007,xn=1008,zp=1008,Mn=1009,cu=1010,lu=1011,xs=1012,Nc=1013,Gn=1014,Ge=1015,Ps=1016,Fc=1017,Oc=1018,Li=1020,hu=35902,uu=1021,du=1022,Oe=1023,fu=1024,pu=1025,Ri=1026,Di=1027,Bc=1028,Wr=1029,mu=1030,zc=1031,kp=1032,kc=1033,Ks=33776,Qs=33777,js=33778,tr=33779,Ja=35840,$a=35841,Ka=35842,Qa=35843,ja=36196,to=37492,eo=37496,no=37808,io=37809,so=37810,ro=37811,ao=37812,oo=37813,co=37814,lo=37815,ho=37816,uo=37817,fo=37818,po=37819,mo=37820,go=37821,er=36492,_o=36494,xo=36495,gu=36283,vo=36284,yo=36285,Mo=36286,Xf=2200,qf=2201,Yf=2202,hr=2300,So=2301,za=2302,Ti=2400,wi=2401,ur=2402,Vc=2500,_u=2501,Vp=0,Hp=1,Gp=2,Zf=3200,Jf=3201,Wp=3202,Xp=3203,oi=0,$f=1,Dn="",He="srgb",qi="srgb-linear",Xr="linear",se="srgb",qp=0,Si=7680,Yp=7681,Zp=7682,Jp=7683,$p=34055,Kp=34056,Qp=5386,jp=512,tm=513,em=514,nm=515,im=516,sm=517,rm=518,Bl=519,Kf=512,Qf=513,jf=514,xu=515,tp=516,ep=517,np=518,ip=519,dr=35044,am=35048,om=35040,cm=35045,lm=35049,hm=35041,um=35046,dm=35050,fm=35042,pm="100",zl="300 es",vn=2e3,fr=2001,sn=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 i=this._listeners[t];if(i!==void 0){let r=i.indexOf(e);r!==-1&&i.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 i=n.slice(0);for(let r=0,a=i.length;r>8&255]+Re[s>>16&255]+Re[s>>24&255]+"-"+Re[t&255]+Re[t>>8&255]+"-"+Re[t>>16&15|64]+Re[t>>24&255]+"-"+Re[e&63|128]+Re[e>>8&255]+"-"+Re[e>>16&255]+Re[e>>24&255]+Re[n&255]+Re[n>>8&255]+Re[n>>16&255]+Re[n>>24&255]).toLowerCase()}function fe(s,t,e){return Math.max(t,Math.min(e,s))}function vu(s,t){return(s%t+t)%t}function mm(s,t,e,n,i){return n+(s-t)*(i-n)/(e-t)}function gm(s,t,e){return s!==t?(e-s)/(t-s):0}function nr(s,t,e){return(1-e)*s+e*t}function _m(s,t,e,n){return nr(s,t,1-Math.exp(-e*n))}function xm(s,t=1){return t-Math.abs(vu(s,t*2)-t)}function vm(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*(3-2*s))}function ym(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*s*(s*(s*6-15)+10))}function Mm(s,t){return s+Math.floor(Math.random()*(t-s+1))}function Sm(s,t){return s+Math.random()*(t-s)}function bm(s){return s*(.5-Math.random())}function Em(s){s!==void 0&&(Du=s);let t=Du+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Tm(s){return s*Ii}function wm(s){return s*vs}function Am(s){return(s&s-1)===0&&s!==0}function Cm(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function Rm(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function Im(s,t,e,n,i){let r=Math.cos,a=Math.sin,o=r(e/2),c=a(e/2),l=r((t+n)/2),h=a((t+n)/2),u=r((t-n)/2),d=a((t-n)/2),f=r((n-t)/2),m=a((n-t)/2);switch(i){case"XYX":s.set(o*h,c*u,c*d,o*l);break;case"YZY":s.set(c*d,o*h,c*u,o*l);break;case"ZXZ":s.set(c*u,c*d,o*h,o*l);break;case"XZX":s.set(o*h,c*m,c*f,o*l);break;case"YXY":s.set(c*f,o*h,c*m,o*l);break;case"ZYZ":s.set(c*m,c*f,o*h,o*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Fe(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("Invalid component type.")}}function kt(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("Invalid component type.")}}var Pm={DEG2RAD:Ii,RAD2DEG:vs,generateUUID:Ye,clamp:fe,euclideanModulo:vu,mapLinear:mm,inverseLerp:gm,lerp:nr,damp:_m,pingpong:xm,smoothstep:vm,smootherstep:ym,randInt:Mm,randFloat:Sm,randFloatSpread:bm,seededRandom:Em,degToRad:Tm,radToDeg:wm,isPowerOfTwo:Am,ceilPowerOfTwo:Cm,floorPowerOfTwo:Rm,setQuaternionFromProperEuler:Im,normalize:kt,denormalize:Fe},$=class s{constructor(t=0,e=0){s.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,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[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=Math.trunc(this.x),this.y=Math.trunc(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(fe(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),i=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*i+t.x,this.y=r*i+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},Bt=class s{constructor(t,e,n,i,r,a,o,c,l){s.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,a,o,c,l)}set(t,e,n,i,r,a,o,c,l){let h=this.elements;return h[0]=t,h[1]=i,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,i=e.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],u=n[7],d=n[2],f=n[5],m=n[8],_=i[0],g=i[3],p=i[6],y=i[1],v=i[4],x=i[7],P=i[2],T=i[5],C=i[8];return r[0]=a*_+o*y+c*P,r[3]=a*g+o*v+c*T,r[6]=a*p+o*x+c*C,r[1]=l*_+h*y+u*P,r[4]=l*g+h*v+u*T,r[7]=l*p+h*x+u*C,r[2]=d*_+f*y+m*P,r[5]=d*g+f*v+m*T,r[8]=d*p+f*x+m*C,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],i=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+i*r*l-i*a*c}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=h*a-o*l,d=o*c-h*r,f=l*r-a*c,m=e*u+n*d+i*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);let _=1/m;return t[0]=u*_,t[1]=(i*l-h*n)*_,t[2]=(o*n-i*a)*_,t[3]=d*_,t[4]=(h*e-i*c)*_,t[5]=(i*r-o*e)*_,t[6]=f*_,t[7]=(n*c-l*e)*_,t[8]=(a*e-n*r)*_,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,i,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,-i*l,i*c,-i*(-l*a+c*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(qc.makeScale(t,e)),this}rotate(t){return this.premultiply(qc.makeRotation(-t)),this}translate(t,e){return this.premultiply(qc.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 i=0;i<9;i++)if(e[i]!==n[i])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)}},qc=new Bt;function sp(s){for(let t=s.length-1;t>=0;--t)if(s[t]>=65535)return!0;return!1}var Lm={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function fs(s,t){return new Lm[s](t)}function pr(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function rp(){let s=pr("canvas");return s.style.display="block",s}var Uu={};function Ys(s){s in Uu||(Uu[s]=!0,console.warn(s))}function Dm(s,t,e){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(t,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}function Um(s){let t=s.elements;t[2]=.5*t[2]+.5*t[3],t[6]=.5*t[6]+.5*t[7],t[10]=.5*t[10]+.5*t[11],t[14]=.5*t[14]+.5*t[15]}function Nm(s){let t=s.elements;t[11]===-1?(t[10]=-t[10]-1,t[14]=-t[14]):(t[10]=-t[10],t[14]=-t[14]+1)}var Yt={enabled:!0,workingColorSpace:qi,spaces:{},convert:function(s,t,e){return this.enabled===!1||t===e||!t||!e||(this.spaces[t].transfer===se&&(s.r=zn(s.r),s.g=zn(s.g),s.b=zn(s.b)),this.spaces[t].primaries!==this.spaces[e].primaries&&(s.applyMatrix3(this.spaces[t].toXYZ),s.applyMatrix3(this.spaces[e].fromXYZ)),this.spaces[e].transfer===se&&(s.r=gs(s.r),s.g=gs(s.g),s.b=gs(s.b))),s},fromWorkingColorSpace:function(s,t){return this.convert(s,this.workingColorSpace,t)},toWorkingColorSpace:function(s,t){return this.convert(s,t,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Dn?Xr:this.spaces[s].transfer},getLuminanceCoefficients:function(s,t=this.workingColorSpace){return s.fromArray(this.spaces[t].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,t,e){return s.copy(this.spaces[t].toXYZ).multiply(this.spaces[e].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace}};function zn(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function gs(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}var Nu=[.64,.33,.3,.6,.15,.06],Fu=[.2126,.7152,.0722],Ou=[.3127,.329],Bu=new Bt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),zu=new Bt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);Yt.define({[qi]:{primaries:Nu,whitePoint:Ou,transfer:Xr,toXYZ:Bu,fromXYZ:zu,luminanceCoefficients:Fu,workingColorSpaceConfig:{unpackColorSpace:He},outputColorSpaceConfig:{drawingBufferColorSpace:He}},[He]:{primaries:Nu,whitePoint:Ou,transfer:se,toXYZ:Bu,fromXYZ:zu,luminanceCoefficients:Fu,outputColorSpaceConfig:{drawingBufferColorSpace:He}}});var Zi,bo=class{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Zi===void 0&&(Zi=pr("canvas")),Zi.width=t.width,Zi.height=t.height;let n=Zi.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Zi}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<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){let e=pr("canvas");e.width=t.width,e.height=t.height;let n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);let i=n.getImageData(0,0,t.width,t.height),r=i.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 cr:t.x=t.x-Math.floor(t.x);break;case en:t.x=t.x<0?0:1;break;case lr: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 cr:t.y=t.y-Math.floor(t.y);break;case en:t.y=t.y<0?0:1;break;case lr: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)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}};_e.DEFAULT_IMAGE=null;_e.DEFAULT_MAPPING=Uc;_e.DEFAULT_ANISOTROPY=1;var $t=class s{constructor(t=0,e=0,n=0,i=1){s.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}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,i){return this.x=t,this.y=e,this.z=n,this.w=i,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,i=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*i+a[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,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,i,r,c=t.elements,l=c[0],h=c[4],u=c[8],d=c[1],f=c[5],m=c[9],_=c[2],g=c[6],p=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-_)<.01&&Math.abs(m-g)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+_)<.1&&Math.abs(m+g)<.1&&Math.abs(l+f+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;let v=(l+1)/2,x=(f+1)/2,P=(p+1)/2,T=(h+d)/4,C=(u+_)/4,R=(m+g)/4;return v>x&&v>P?v<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(v),i=T/n,r=C/n):x>P?x<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(x),n=T/i,r=R/i):P<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(P),n=C/r,i=R/r),this.set(n,i,r,e),this}let y=Math.sqrt((g-m)*(g-m)+(u-_)*(u-_)+(d-h)*(d-h));return Math.abs(y)<.001&&(y=1),this.x=(g-m)/y,this.y=(u-_)/y,this.z=(d-h)/y,this.w=Math.acos((l+f+p-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(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}},Eo=class extends sn{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new $t(0,0,t,e),this.scissorTest=!1,this.viewport=new $t(0,0,t,e);let i={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ve,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);let r=new _e(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);r.flipY=!1,r.generateMipmaps=n.generateMipmaps,r.internalFormat=n.internalFormat,this.textures=[];let a=n.count;for(let o=0;o=0?1:-1,v=1-p*p;if(v>Number.EPSILON){let P=Math.sqrt(v),T=Math.atan2(P,p*y);g=Math.sin(g*T)/P,o=Math.sin(o*T)/P}let x=o*y;if(c=c*g+d*x,l=l*g+f*x,h=h*g+m*x,u=u*g+_*x,g===1-o){let P=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=P,l*=P,h*=P,u*=P}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,r,a){let o=n[i],c=n[i+1],l=n[i+2],h=n[i+3],u=r[a],d=r[a+1],f=r[a+2],m=r[a+3];return t[e]=o*m+h*u+c*f-l*d,t[e+1]=c*m+h*d+l*u-o*f,t[e+2]=l*m+h*f+o*d-c*u,t[e+3]=h*m-o*u-c*d-l*f,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,i){return this._x=t,this._y=e,this._z=n,this._w=i,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=!0){let n=t._x,i=t._y,r=t._z,a=t._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(i/2),u=o(r/2),d=c(n/2),f=c(i/2),m=c(r/2);switch(a){case"XYZ":this._x=d*h*u+l*f*m,this._y=l*f*u-d*h*m,this._z=l*h*m+d*f*u,this._w=l*h*u-d*f*m;break;case"YXZ":this._x=d*h*u+l*f*m,this._y=l*f*u-d*h*m,this._z=l*h*m-d*f*u,this._w=l*h*u+d*f*m;break;case"ZXY":this._x=d*h*u-l*f*m,this._y=l*f*u+d*h*m,this._z=l*h*m+d*f*u,this._w=l*h*u-d*f*m;break;case"ZYX":this._x=d*h*u-l*f*m,this._y=l*f*u+d*h*m,this._z=l*h*m-d*f*u,this._w=l*h*u+d*f*m;break;case"YZX":this._x=d*h*u+l*f*m,this._y=l*f*u+d*h*m,this._z=l*h*m-d*f*u,this._w=l*h*u-d*f*m;break;case"XZY":this._x=d*h*u-l*f*m,this._y=l*f*u-d*h*m,this._z=l*h*m+d*f*u,this._w=l*h*u+d*f*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,n=e[0],i=e[4],r=e[8],a=e[1],o=e[5],c=e[9],l=e[2],h=e[6],u=e[10],d=n+o+u;if(d>0){let f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(r-l)*f,this._z=(a-i)*f}else if(n>o&&n>u){let f=2*Math.sqrt(1+n-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(r+l)/f}else if(o>u){let f=2*Math.sqrt(1+o-n-u);this._w=(r-l)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(c+h)/f}else{let f=2*Math.sqrt(1+u-n-o);this._w=(a-i)/f,this._x=(r+l)/f,this._y=(c+h)/f,this._z=.25*f}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(fe(this.dot(t),-1,1)))}rotateTowards(t,e){let n=this.angleTo(t);if(n===0)return this;let i=Math.min(1,e/n);return this.slerp(t,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(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,i=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+i*l-r*c,this._y=i*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-i*o,this._w=a*h-n*o-i*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,i=this._y,r=this._z,a=this._w,o=a*t._w+n*t._x+i*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=i,this._z=r,this;let c=1-o*o;if(c<=Number.EPSILON){let f=1-e;return this._w=f*a+e*this._w,this._x=f*n+e*this._x,this._y=f*i+e*this._y,this._z=f*r+e*this._z,this.normalize(),this}let l=Math.sqrt(c),h=Math.atan2(l,o),u=Math.sin((1-e)*h)/l,d=Math.sin(e*h)/l;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=i*u+this._y*d,this._z=r*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}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._onChangeCallback(),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}},A=class s{constructor(t=0,e=0,n=0){s.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(ku.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ku.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,n=this.y,i=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(t){let e=this.x,n=this.y,i=this.z,r=t.x,a=t.y,o=t.z,c=t.w,l=2*(a*i-o*n),h=2*(o*e-r*i),u=2*(r*n-a*e);return this.x=e+c*l+a*u-o*h,this.y=n+c*h+o*l-r*u,this.z=i+c*u+r*h-a*l,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,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(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,i=t.y,r=t.z,a=e.x,o=e.y,c=e.z;return this.x=i*c-r*o,this.y=r*a-n*c,this.z=n*o-i*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 Zc.copy(this).projectOnVector(t),this.sub(Zc)}reflect(t){return this.sub(Zc.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(fe(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}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 i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*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(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,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()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Zc=new A,ku=new Le,we=class{constructor(t=new A(1/0,1/0,1/0),e=new A(-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;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.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.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,cn),cn.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(Ns),Jr.subVectors(this.max,Ns),Ji.subVectors(t.a,Ns),$i.subVectors(t.b,Ns),Ki.subVectors(t.c,Ns),Zn.subVectors($i,Ji),Jn.subVectors(Ki,$i),li.subVectors(Ji,Ki);let e=[0,-Zn.z,Zn.y,0,-Jn.z,Jn.y,0,-li.z,li.y,Zn.z,0,-Zn.x,Jn.z,0,-Jn.x,li.z,0,-li.x,-Zn.y,Zn.x,0,-Jn.y,Jn.x,0,-li.y,li.x,0];return!Jc(e,Ji,$i,Ki,Jr)||(e=[1,0,0,0,1,0,0,0,1],!Jc(e,Ji,$i,Ki,Jr))?!1:($r.crossVectors(Zn,Jn),e=[$r.x,$r.y,$r.z],Jc(e,Ji,$i,Ki,Jr))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,cn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(cn).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:(An[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),An[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),An[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),An[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),An[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),An[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),An[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),An[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(An),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)}},An=[new A,new A,new A,new A,new A,new A,new A,new A],cn=new A,Zr=new we,Ji=new A,$i=new A,Ki=new A,Zn=new A,Jn=new A,li=new A,Ns=new A,Jr=new A,$r=new A,hi=new A;function Jc(s,t,e,n,i){for(let r=0,a=s.length-3;r<=a;r+=3){hi.fromArray(s,r);let o=i.x*Math.abs(hi.x)+i.y*Math.abs(hi.y)+i.z*Math.abs(hi.z),c=t.dot(hi),l=e.dot(hi),h=n.dot(hi);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}var Bm=new we,Fs=new A,$c=new A,be=class{constructor(t=new A,e=-1){this.isSphere=!0,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):Bm.setFromPoints(t).getCenter(n);let i=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;Fs.subVectors(t,this.center);let e=Fs.lengthSq();if(e>this.radius*this.radius){let n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(Fs,i/n),this.radius+=i}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):($c.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Fs.copy(t.center).add($c)),this.expandByPoint(Fs.copy(t.center).sub($c))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}},Cn=new A,Kc=new A,Kr=new A,$n=new A,Qc=new A,Qr=new A,jc=new A,si=class{constructor(t=new A,e=new A(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,Cn)),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=Cn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Cn.copy(this.origin).addScaledVector(this.direction,e),Cn.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){Kc.copy(t).add(e).multiplyScalar(.5),Kr.copy(e).sub(t).normalize(),$n.copy(this.origin).sub(Kc);let r=t.distanceTo(e)*.5,a=-this.direction.dot(Kr),o=$n.dot(this.direction),c=-$n.dot(Kr),l=$n.lengthSq(),h=Math.abs(1-a*a),u,d,f,m;if(h>0)if(u=a*c-o,d=a*o-c,m=r*h,u>=0)if(d>=-m)if(d<=m){let _=1/h;u*=_,d*=_,f=u*(u+a*d+2*o)+d*(a*u+d+2*c)+l}else d=r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d=-r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-m?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l):d<=m?(u=0,d=Math.min(Math.max(-r,-c),r),f=d*(d+2*c)+l):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(Kc).addScaledVector(Kr,d),f}intersectSphere(t,e){Cn.subVectors(t.center,this.origin);let n=Cn.dot(this.direction),i=Cn.dot(Cn)-n*n,r=t.radius*t.radius;if(i>r)return null;let a=Math.sqrt(r-i),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,i,r,a,o,c,l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(t.min.x-d.x)*l,i=(t.max.x-d.x)*l):(n=(t.max.x-d.x)*l,i=(t.min.x-d.x)*l),h>=0?(r=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(r=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a=0?(o=(t.min.z-d.z)*u,c=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,c=(t.min.z-d.z)*u),n>c||o>i)||((o>n||n!==n)&&(n=o),(c=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,Cn)!==null}intersectTriangle(t,e,n,i,r){Qc.subVectors(e,t),Qr.subVectors(n,t),jc.crossVectors(Qc,Qr);let a=this.direction.dot(jc),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;$n.subVectors(this.origin,t);let c=o*this.direction.dot(Qr.crossVectors($n,Qr));if(c<0)return null;let l=o*this.direction.dot(Qc.cross($n));if(l<0||c+l>a)return null;let h=-o*$n.dot(jc);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)}},Ut=class s{constructor(t,e,n,i,r,a,o,c,l,h,u,d,f,m,_,g){s.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,i,r,a,o,c,l,h,u,d,f,m,_,g)}set(t,e,n,i,r,a,o,c,l,h,u,d,f,m,_,g){let p=this.elements;return p[0]=t,p[4]=e,p[8]=n,p[12]=i,p[1]=r,p[5]=a,p[9]=o,p[13]=c,p[2]=l,p[6]=h,p[10]=u,p[14]=d,p[3]=f,p[7]=m,p[11]=_,p[15]=g,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 s().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,i=1/Qi.setFromMatrixColumn(t,0).length(),r=1/Qi.setFromMatrixColumn(t,1).length(),a=1/Qi.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,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,i=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(r),u=Math.sin(r);if(t.order==="XYZ"){let d=a*h,f=a*u,m=o*h,_=o*u;e[0]=c*h,e[4]=-c*u,e[8]=l,e[1]=f+m*l,e[5]=d-_*l,e[9]=-o*c,e[2]=_-d*l,e[6]=m+f*l,e[10]=a*c}else if(t.order==="YXZ"){let d=c*h,f=c*u,m=l*h,_=l*u;e[0]=d+_*o,e[4]=m*o-f,e[8]=a*l,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=f*o-m,e[6]=_+d*o,e[10]=a*c}else if(t.order==="ZXY"){let d=c*h,f=c*u,m=l*h,_=l*u;e[0]=d-_*o,e[4]=-a*u,e[8]=m+f*o,e[1]=f+m*o,e[5]=a*h,e[9]=_-d*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){let d=a*h,f=a*u,m=o*h,_=o*u;e[0]=c*h,e[4]=m*l-f,e[8]=d*l+_,e[1]=c*u,e[5]=_*l+d,e[9]=f*l-m,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){let d=a*c,f=a*l,m=o*c,_=o*l;e[0]=c*h,e[4]=_-d*u,e[8]=m*u+f,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=f*u+m,e[10]=d-_*u}else if(t.order==="XZY"){let d=a*c,f=a*l,m=o*c,_=o*l;e[0]=c*h,e[4]=-u,e[8]=l*h,e[1]=d*u+_,e[5]=a*h,e[9]=f*u-m,e[2]=m*u-f,e[6]=o*h,e[10]=_*u+d}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(zm,t,km)}lookAt(t,e,n){let i=this.elements;return Xe.subVectors(t,e),Xe.lengthSq()===0&&(Xe.z=1),Xe.normalize(),Kn.crossVectors(n,Xe),Kn.lengthSq()===0&&(Math.abs(n.z)===1?Xe.x+=1e-4:Xe.z+=1e-4,Xe.normalize(),Kn.crossVectors(n,Xe)),Kn.normalize(),jr.crossVectors(Xe,Kn),i[0]=Kn.x,i[4]=jr.x,i[8]=Xe.x,i[1]=Kn.y,i[5]=jr.y,i[9]=Xe.y,i[2]=Kn.z,i[6]=jr.z,i[10]=Xe.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let n=t.elements,i=e.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],u=n[5],d=n[9],f=n[13],m=n[2],_=n[6],g=n[10],p=n[14],y=n[3],v=n[7],x=n[11],P=n[15],T=i[0],C=i[4],R=i[8],b=i[12],M=i[1],L=i[5],k=i[9],O=i[13],V=i[2],Z=i[6],H=i[10],et=i[14],G=i[3],ot=i[7],mt=i[11],St=i[15];return r[0]=a*T+o*M+c*V+l*G,r[4]=a*C+o*L+c*Z+l*ot,r[8]=a*R+o*k+c*H+l*mt,r[12]=a*b+o*O+c*et+l*St,r[1]=h*T+u*M+d*V+f*G,r[5]=h*C+u*L+d*Z+f*ot,r[9]=h*R+u*k+d*H+f*mt,r[13]=h*b+u*O+d*et+f*St,r[2]=m*T+_*M+g*V+p*G,r[6]=m*C+_*L+g*Z+p*ot,r[10]=m*R+_*k+g*H+p*mt,r[14]=m*b+_*O+g*et+p*St,r[3]=y*T+v*M+x*V+P*G,r[7]=y*C+v*L+x*Z+P*ot,r[11]=y*R+v*k+x*H+P*mt,r[15]=y*b+v*O+x*et+P*St,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],i=t[8],r=t[12],a=t[1],o=t[5],c=t[9],l=t[13],h=t[2],u=t[6],d=t[10],f=t[14],m=t[3],_=t[7],g=t[11],p=t[15];return m*(+r*c*u-i*l*u-r*o*d+n*l*d+i*o*f-n*c*f)+_*(+e*c*f-e*l*d+r*a*d-i*a*f+i*l*h-r*c*h)+g*(+e*l*u-e*o*f-r*a*u+n*a*f+r*o*h-n*l*h)+p*(-i*o*h-e*c*u+e*o*d+i*a*u-n*a*d+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 i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){let t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=t[9],d=t[10],f=t[11],m=t[12],_=t[13],g=t[14],p=t[15],y=u*g*l-_*d*l+_*c*f-o*g*f-u*c*p+o*d*p,v=m*d*l-h*g*l-m*c*f+a*g*f+h*c*p-a*d*p,x=h*_*l-m*u*l+m*o*f-a*_*f-h*o*p+a*u*p,P=m*u*c-h*_*c-m*o*d+a*_*d+h*o*g-a*u*g,T=e*y+n*v+i*x+r*P;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let C=1/T;return t[0]=y*C,t[1]=(_*d*r-u*g*r-_*i*f+n*g*f+u*i*p-n*d*p)*C,t[2]=(o*g*r-_*c*r+_*i*l-n*g*l-o*i*p+n*c*p)*C,t[3]=(u*c*r-o*d*r-u*i*l+n*d*l+o*i*f-n*c*f)*C,t[4]=v*C,t[5]=(h*g*r-m*d*r+m*i*f-e*g*f-h*i*p+e*d*p)*C,t[6]=(m*c*r-a*g*r-m*i*l+e*g*l+a*i*p-e*c*p)*C,t[7]=(a*d*r-h*c*r+h*i*l-e*d*l-a*i*f+e*c*f)*C,t[8]=x*C,t[9]=(m*u*r-h*_*r-m*n*f+e*_*f+h*n*p-e*u*p)*C,t[10]=(a*_*r-m*o*r+m*n*l-e*_*l-a*n*p+e*o*p)*C,t[11]=(h*o*r-a*u*r-h*n*l+e*u*l+a*n*f-e*o*f)*C,t[12]=P*C,t[13]=(h*_*i-m*u*i+m*n*d-e*_*d-h*n*g+e*u*g)*C,t[14]=(m*o*i-a*_*i-m*n*c+e*_*c+a*n*g-e*o*g)*C,t[15]=(a*u*i-h*o*i+h*n*c-e*u*c-a*n*d+e*o*d)*C,this}scale(t){let e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,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],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}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),i=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-i*c,l*c+i*o,0,l*o+i*c,h*o+n,h*c-i*a,0,l*c-i*o,h*c+i*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,i,r,a){return this.set(1,n,r,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){let i=this.elements,r=e._x,a=e._y,o=e._z,c=e._w,l=r+r,h=a+a,u=o+o,d=r*l,f=r*h,m=r*u,_=a*h,g=a*u,p=o*u,y=c*l,v=c*h,x=c*u,P=n.x,T=n.y,C=n.z;return i[0]=(1-(_+p))*P,i[1]=(f+x)*P,i[2]=(m-v)*P,i[3]=0,i[4]=(f-x)*T,i[5]=(1-(d+p))*T,i[6]=(g+y)*T,i[7]=0,i[8]=(m+v)*C,i[9]=(g-y)*C,i[10]=(1-(d+_))*C,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){let i=this.elements,r=Qi.set(i[0],i[1],i[2]).length(),a=Qi.set(i[4],i[5],i[6]).length(),o=Qi.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],ln.copy(this);let l=1/r,h=1/a,u=1/o;return ln.elements[0]*=l,ln.elements[1]*=l,ln.elements[2]*=l,ln.elements[4]*=h,ln.elements[5]*=h,ln.elements[6]*=h,ln.elements[8]*=u,ln.elements[9]*=u,ln.elements[10]*=u,e.setFromRotationMatrix(ln),n.x=r,n.y=a,n.z=o,this}makePerspective(t,e,n,i,r,a,o=vn){let c=this.elements,l=2*r/(e-t),h=2*r/(n-i),u=(e+t)/(e-t),d=(n+i)/(n-i),f,m;if(o===vn)f=-(a+r)/(a-r),m=-2*a*r/(a-r);else if(o===fr)f=-a/(a-r),m=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=l,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=h,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,i,r,a,o=vn){let c=this.elements,l=1/(e-t),h=1/(n-i),u=1/(a-r),d=(e+t)*l,f=(n+i)*h,m,_;if(o===vn)m=(a+r)*u,_=-2*u;else if(o===fr)m=r*u,_=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-d,c[1]=0,c[5]=2*h,c[9]=0,c[13]=-f,c[2]=0,c[6]=0,c[10]=_,c[14]=-m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){let e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])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}},Qi=new A,ln=new Ut,zm=new A(0,0,0),km=new A(1,1,1),Kn=new A,jr=new A,Xe=new A,Vu=new Ut,Hu=new Le,Je=class s{constructor(t=0,e=0,n=0,i=s.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}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,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,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 i=t.elements,r=i[0],a=i[4],o=i[8],c=i[1],l=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(e){case"XYZ":this._y=Math.asin(fe(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-fe(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(fe(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-fe(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(fe(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-fe(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,f),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 Vu.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Vu,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Hu.setFromEuler(this),this.setFromQuaternion(Hu,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}};Je.DEFAULT_ORDER="XYZ";var Ms=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&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));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?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.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){i.children=[];for(let o=0;o0){i.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),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=i,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.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,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?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){hn.subVectors(i,e),In.subVectors(n,e),el.subVectors(t,e);let a=hn.dot(hn),o=hn.dot(In),c=hn.dot(el),l=In.dot(In),h=In.dot(el),u=a*l-o*o;if(u===0)return r.set(0,0,0),null;let d=1/u,f=(l*c-o*h)*d,m=(a*h-o*c)*d;return r.set(1-f-m,m,f)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,Pn)===null?!1:Pn.x>=0&&Pn.y>=0&&Pn.x+Pn.y<=1}static getInterpolation(t,e,n,i,r,a,o,c){return this.getBarycoord(t,e,n,i,Pn)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,Pn.x),c.addScaledVector(a,Pn.y),c.addScaledVector(o,Pn.z),c)}static getInterpolatedAttribute(t,e,n,i,r,a){return rl.setScalar(0),al.setScalar(0),ol.setScalar(0),rl.fromBufferAttribute(t,e),al.fromBufferAttribute(t,n),ol.fromBufferAttribute(t,i),a.setScalar(0),a.addScaledVector(rl,r.x),a.addScaledVector(al,r.y),a.addScaledVector(ol,r.z),a}static isFrontFacing(t,e,n,i){return hn.subVectors(n,e),In.subVectors(t,e),hn.cross(In).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),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 hn.subVectors(this.c,this.b),In.subVectors(this.a,this.b),hn.cross(In).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return s.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return s.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return s.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return s.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return s.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let n=this.a,i=this.b,r=this.c,a,o;es.subVectors(i,n),ns.subVectors(r,n),nl.subVectors(t,n);let c=es.dot(nl),l=ns.dot(nl);if(c<=0&&l<=0)return e.copy(n);il.subVectors(t,i);let h=es.dot(il),u=ns.dot(il);if(h>=0&&u<=h)return e.copy(i);let d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),e.copy(n).addScaledVector(es,a);sl.subVectors(t,r);let f=es.dot(sl),m=ns.dot(sl);if(m>=0&&f<=m)return e.copy(r);let _=f*l-c*m;if(_<=0&&l>=0&&m<=0)return o=l/(l-m),e.copy(n).addScaledVector(ns,o);let g=h*m-f*u;if(g<=0&&u-h>=0&&f-m>=0)return Zu.subVectors(r,i),o=(u-h)/(u-h+(f-m)),e.copy(i).addScaledVector(Zu,o);let p=1/(g+_+d);return a=_*p,o=d*p,e.copy(n).addScaledVector(es,a).addScaledVector(ns,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}},ap={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},Qn={h:0,s:0,l:0},ea={h:0,s:0,l:0};function cl(s,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?s+(t-s)*6*e:e<1/2?t:e<2/3?s+(t-s)*6*(2/3-e):s}var ut=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 i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=He){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Yt.toWorkingColorSpace(this,e),this}setRGB(t,e,n,i=Yt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Yt.toWorkingColorSpace(this,i),this}setHSL(t,e,n,i=Yt.workingColorSpace){if(t=vu(t,1),e=fe(e,0,1),n=fe(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=cl(a,r,t+1/3),this.g=cl(a,r,t),this.b=cl(a,r,t-1/3)}return Yt.toWorkingColorSpace(this,i),this}setStyle(t,e=He){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r,a=i[1],o=i[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(i=/^\#([A-Fa-f\d]+)$/.exec(t)){let r=i[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=He){let n=ap[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=zn(t.r),this.g=zn(t.g),this.b=zn(t.b),this}copyLinearToSRGB(t){return this.r=gs(t.r),this.g=gs(t.g),this.b=gs(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=He){return Yt.fromWorkingColorSpace(Ie.copy(this),t),Math.round(fe(Ie.r*255,0,255))*65536+Math.round(fe(Ie.g*255,0,255))*256+Math.round(fe(Ie.b*255,0,255))}getHexString(t=He){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Yt.workingColorSpace){Yt.fromWorkingColorSpace(Ie.copy(this),e);let n=Ie.r,i=Ie.g,r=Ie.b,a=Math.max(n,i,r),o=Math.min(n,i,r),c,l,h=(o+a)/2;if(o===a)c=0,l=0;else{let u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case n:c=(i-r)/u+(i0!=t>0&&this.version++,this._alphaTest=t}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 i=this[e];if(i===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.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!==void 0&&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.dispersion!==void 0&&(n.dispersion=this.dispersion),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.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),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!==Ci&&(n.blending=this.blending),this.side!==Vn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==ka&&(n.blendSrc=this.blendSrc),this.blendDst!==Va&&(n.blendDst=this.blendDst),this.blendEquation!==ei&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Pi&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Bl&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Si&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Si&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Si&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),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=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),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=!0),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 i(r){let a=[];for(let o in r){let c=r[o];delete c.metadata,a.push(c)}return a}if(e){let r=i(t.textures),a=i(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.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,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 i=e.length;n=new Array(i);for(let r=0;r!==i;++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++}onBuild(){console.warn("Material: onBuild() has been removed.")}},Sn=class extends Ee{static get type(){return"MeshBasicMaterial"}constructor(t){super(),this.isMeshBasicMaterial=!0,this.color=new ut(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Je,this.combine=Gr,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}},Un=qm();function qm(){let s=new ArrayBuffer(4),t=new Float32Array(s),e=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let c=0;c<256;++c){let l=c-127;l<-27?(n[c]=0,n[c|256]=32768,i[c]=24,i[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}let r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,r[c]=l|h}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:t,uint32View:e,baseTable:n,shiftTable:i,mantissaTable:r,exponentTable:a,offsetTable:o}}function Ve(s){Math.abs(s)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),s=fe(s,-65504,65504),Un.floatView[0]=s;let t=Un.uint32View[0],e=t>>23&511;return Un.baseTable[e]+((t&8388607)>>Un.shiftTable[e])}function Zs(s){let t=s>>10;return Un.uint32View[0]=Un.mantissaTable[Un.offsetTable[t]+(s&1023)]+Un.exponentTable[t],Un.floatView[0]}var Ym={toHalfFloat:Ve,fromHalfFloat:Zs},ge=new A,na=new $,ne=class{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=dr,this.updateRanges=[],this.gpuType=Ge,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;ie.count&&console.warn("THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new we);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new A(-1/0,-1/0,-1/0),new A(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,i=e.length;n0&&(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 i={},r=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u0&&(i[c]=h,r=!0)}r&&(t.data.morphAttributes=i,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 i=t.attributes;for(let l in i){let h=i[l];this.setAttribute(l,h.clone(e))}let r=t.morphAttributes;for(let l in r){let h=[],u=r[l];for(let d=0,f=u.length;d0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r(t.far-t.near)**2))&&(Ju.copy(r).invert(),ui.copy(t.ray).applyMatrix4(Ju),!(n.boundingBox!==null&&ui.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,ui)))}_computeIntersections(t,e,n){let i,r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,_=d.length;m<_;m++){let g=d[m],p=a[g.materialIndex],y=Math.max(g.start,f.start),v=Math.min(o.count,Math.min(g.start+g.count,f.start+f.count));for(let x=y,P=v;xe.far?null:{distance:l,point:ca.clone(),object:s}}function la(s,t,e,n,i,r,a,o,c,l){s.getVertexPosition(o,sa),s.getVertexPosition(c,ra),s.getVertexPosition(l,aa);let h=Jm(s,t,e,n,sa,ra,aa,Ku);if(h){let u=new A;_n.getBarycoord(Ku,sa,ra,aa,u),i&&(h.uv=_n.getInterpolatedAttribute(i,o,c,l,u,new $)),r&&(h.uv1=_n.getInterpolatedAttribute(r,o,c,l,u,new $)),a&&(h.normal=_n.getInterpolatedAttribute(a,o,c,l,u,new A),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));let d={a:o,b:c,c:l,normal:new A,materialIndex:0};_n.getNormal(sa,ra,aa,d.normal),h.face=d,h.barycoord=u}return h}var Ui=class s extends Wt{constructor(t=1,e=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};let o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);let c=[],l=[],h=[],u=[],d=0,f=0;m("z","y","x",-1,-1,n,e,t,a,r,0),m("z","y","x",1,-1,n,e,-t,a,r,1),m("x","z","y",1,1,t,n,e,i,a,2),m("x","z","y",1,-1,t,n,-e,i,a,3),m("x","y","z",1,-1,t,e,n,i,r,4),m("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(c),this.setAttribute("position",new Mt(l,3)),this.setAttribute("normal",new Mt(h,3)),this.setAttribute("uv",new Mt(u,2));function m(_,g,p,y,v,x,P,T,C,R,b){let M=x/C,L=P/R,k=x/2,O=P/2,V=T/2,Z=C+1,H=R+1,et=0,G=0,ot=new A;for(let mt=0;mt0?1:-1,h.push(ot.x,ot.y,ot.z),u.push(zt/C),u.push(1-mt/R),et+=1}}for(let mt=0;mt0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let n={};for(let i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}},bs=class extends Qt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ut,this.projectionMatrix=new Ut,this.projectionMatrixInverse=new Ut,this.coordinateSystem=vn}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){return super.getWorldDirection(t).negate()}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)}},jn=new A,Qu=new $,ju=new $,xe=class extends bs{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,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=vs*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(Ii*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return vs*2*Math.atan(Math.tan(Ii*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){jn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(jn.x,jn.y).multiplyScalar(-t/jn.z),jn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(jn.x,jn.y).multiplyScalar(-t/jn.z)}getViewSize(t,e){return this.getViewBounds(t,Qu,ju),e.subVectors(ju,Qu)}setViewOffset(t,e,n,i,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=i,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(Ii*.5*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i,a=this.view;if(this.view!==null&&this.view.enabled){let c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*i/c,e-=a.offsetY*n/l,i*=a.width/c,n*=a.height/l}let o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,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}},ss=-90,rs=1,To=class extends Qt{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let i=new xe(ss,rs,t,e);i.layers=this.layers,this.add(i);let r=new xe(ss,rs,t,e);r.layers=this.layers,this.add(r);let a=new xe(ss,rs,t,e);a.layers=this.layers,this.add(a);let o=new xe(ss,rs,t,e);o.layers=this.layers,this.add(o);let c=new xe(ss,rs,t,e);c.layers=this.layers,this.add(c);let l=new xe(ss,rs,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let t=this.coordinateSystem,e=this.children.concat(),[n,i,r,a,o,c]=e;for(let l of e)this.remove(l);if(t===vn)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),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===fr)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),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{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());let[r,a,o,c,l,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),m=t.xr.enabled;t.xr.enabled=!1;let _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,i),t.render(e,r),t.setRenderTarget(n,1,i),t.render(e,a),t.setRenderTarget(n,2,i),t.render(e,o),t.setRenderTarget(n,3,i),t.render(e,c),t.setRenderTarget(n,4,i),t.render(e,l),n.texture.generateMipmaps=_,t.setRenderTarget(n,5,i),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=m,n.texture.needsPMREMUpdate=!0}},Ni=class extends _e{constructor(t,e,n,i,r,a,o,c,l,h){t=t!==void 0?t:[],e=e!==void 0?e:Hn,super(t,e,n,i,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}},wo=class extends Ze{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;let n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new Ni(i,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:ve}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:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},i=new Ui(5,5,5),r=new $e({name:"CubemapFromEquirect",uniforms:Ss(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Be,blending:On});r.uniforms.tEquirect.value=e;let a=new pe(i,r),o=e.minFilter;return e.minFilter===xn&&(e.minFilter=ve),new To(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e,n,i){let r=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,i);t.setRenderTarget(r)}},ul=new A,jm=new A,tg=new Bt,mn=class{constructor(t=new A(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,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){let i=ul.subVectors(n,e).cross(jm.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,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(ul),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;let r=-(t.start.dot(this.normal)+this.constant)/i;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||tg.getNormalMatrix(t),i=this.coplanarPoint(ul).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.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)}},di=new be,ha=new A,Fi=class{constructor(t=new mn,e=new mn,n=new mn,i=new mn,r=new mn,a=new mn){this.planes=[t,e,n,i,r,a]}set(t,e,n,i,r,a){let o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(i),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=vn){let n=this.planes,i=t.elements,r=i[0],a=i[1],o=i[2],c=i[3],l=i[4],h=i[5],u=i[6],d=i[7],f=i[8],m=i[9],_=i[10],g=i[11],p=i[12],y=i[13],v=i[14],x=i[15];if(n[0].setComponents(c-r,d-l,g-f,x-p).normalize(),n[1].setComponents(c+r,d+l,g+f,x+p).normalize(),n[2].setComponents(c+a,d+h,g+m,x+y).normalize(),n[3].setComponents(c-a,d-h,g-m,x-y).normalize(),n[4].setComponents(c-o,d-u,g-_,x-v).normalize(),e===vn)n[5].setComponents(c+o,d+u,g+_,x+v).normalize();else if(e===fr)n[5].setComponents(o,u,_,v).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(),di.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{let e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),di.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(di)}intersectsSprite(t){return di.center.set(0,0,0),di.radius=.7071067811865476,di.applyMatrix4(t.matrixWorld),this.intersectsSphere(di)}intersectsSphere(t){let e=this.planes,n=t.center,i=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)0?t.max.x:t.min.x,ha.y=i.normal.y>0?t.max.y:t.min.y,ha.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(ha)<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 lp(){let s=null,t=!1,e=null,n=null;function i(r,a){e(r,a),n=s.requestAnimationFrame(i)}return{start:function(){t!==!0&&e!==null&&(n=s.requestAnimationFrame(i),t=!0)},stop:function(){s.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){s=r}}}function eg(s){let t=new WeakMap;function e(o,c){let l=o.array,h=o.usage,u=l.byteLength,d=s.createBuffer();s.bindBuffer(c,d),s.bufferData(c,l,h),o.onUploadCallback();let f;if(l instanceof Float32Array)f=s.FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?f=s.HALF_FLOAT:f=s.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=s.SHORT;else if(l instanceof Uint32Array)f=s.UNSIGNED_INT;else if(l instanceof Int32Array)f=s.INT;else if(l instanceof Int8Array)f=s.BYTE;else if(l instanceof Uint8Array)f=s.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,c,l){let h=c.array,u=c.updateRanges;if(s.bindBuffer(l,o),u.length===0)s.bufferSubData(l,0,h);else{u.sort((f,m)=>f.start-m.start);let d=0;for(let f=1;f 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,xg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,vg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,yg=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,Mg=`#if defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#elif defined( USE_COLOR ) + diffuseColor.rgb *= vColor; +#endif`,Sg=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) + varying vec3 vColor; +#endif`,bg=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec3 vColor; +#endif`,Eg=`#if defined( USE_COLOR_ALPHA ) + vColor = vec4( 1.0 ); +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + vColor = vec3( 1.0 ); +#endif +#ifdef USE_COLOR + vColor *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.xyz *= instanceColor.xyz; +#endif +#ifdef USE_BATCHING_COLOR + vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); + vColor.xyz *= batchingColor.xyz; +#endif`,Tg=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); +} +mat3 transposeMat3( const in mat3 m ) { + mat3 tmp; + tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); + tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); + tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); + return tmp; +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`,wg=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,Ag=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; + #ifdef FLIP_SIDED + transformedTangent = - transformedTangent; + #endif +#endif`,Cg=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,Rg=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,Ig=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,Pg=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,Lg="gl_FragColor = linearToOutputTexel( gl_FragColor );",Dg=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 sRGBTransferOETF( in vec4 value ) { + return 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 ); +}`,Ug=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); + #else + vec4 envColor = vec4( 0.0 ); + #endif + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif +#endif`,Ng=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform float flipEnvMap; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif + +#endif`,Fg=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,Og=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,Bg=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,zg=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,kg=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Vg=`#ifdef USE_FOG + #ifdef FOG_EXP2 + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + #else + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + #endif + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`,Hg=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,Gg=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`,Wg=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,Xg=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,qg=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Yg=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif`,Zg=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); + reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,Jg=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,$g=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Kg=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,Qg=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,jg=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; +#endif`,t_=`struct PhysicalMaterial { + vec3 diffuseColor; + float roughness; + vec3 specularColor; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float 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 ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + float v = 0.5 / ( gv + gl ); + return saturate(v); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColor; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; + float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; + float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); + return saturate( DG * RECIPROCAL_PI ); +} +vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); + const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); + vec4 r = roughness * c0 + c1; + float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; + vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; + return fab; +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + vec2 fab = DFGApprox( normal, viewDir, roughness ); + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void 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 ) { +#else +void 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 ) { +#endif + vec2 fab = DFGApprox( normal, viewDir, roughness ); + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + #endif + vec3 singleScattering = vec3( 0.0 ); + vec3 multiScattering = vec3( 0.0 ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); + #endif + vec3 totalScattering = singleScattering + multiScattering; + vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); + reflectedLight.indirectSpecular += radiance * singleScattering; + reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; + reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,e_=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,n_=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,i_=`#if defined( RE_IndirectDiffuse ) + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,s_=`#if defined( USE_LOGDEPTHBUF ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,r_=`#if defined( USE_LOGDEPTHBUF ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,a_=`#ifdef USE_LOGDEPTHBUF + varying float vFragDepth; + varying float vIsPerspective; +#endif`,o_=`#ifdef USE_LOGDEPTHBUF + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,c_=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,l_=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,h_=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,u_=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,d_=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,f_=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,p_=`#ifdef USE_INSTANCING_MORPH + float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; + } +#endif`,m_=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,g_=`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,__=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,x_=`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,v_=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,y_=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,M_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,S_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,b_=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,E_=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,T_=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,w_=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,A_=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,C_=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,R_=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,I_=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + return depth * ( near - far ) - near; +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + return ( near * far ) / ( ( far - near ) * depth - far ); +}`,P_=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,L_=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,D_=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,U_=`#ifdef DITHERING + vec3 dithering( vec3 color ) { + float grid_position = rand( gl_FragCoord.xy ); + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + return color + dither_shift_RGB; + } +#endif`,N_=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,F_=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,O_=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { + return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); + } + vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { + return unpackRGBATo2Half( texture2D( shadow, uv ) ); + } + float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ + float occlusion = 1.0; + vec2 distribution = texture2DDistribution( shadow, uv ); + float hard_shadow = step( compare , distribution.x ); + if (hard_shadow != 1.0 ) { + float distance = compare - distribution.x ; + float variance = max( 0.00000, distribution.y * distribution.y ); + float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); + } + return occlusion; + } + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + #if defined( SHADOWMAP_TYPE_PCF ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx0 = - texelSize.x * shadowRadius; + float dy0 = - texelSize.y * shadowRadius; + float dx1 = + texelSize.x * shadowRadius; + float dy1 = + texelSize.y * shadowRadius; + float dx2 = dx0 / 2.0; + float dy2 = dy0 / 2.0; + float dx3 = dx1 / 2.0; + float dy3 = dy1 / 2.0; + shadow = ( + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) + ) * ( 1.0 / 17.0 ); + #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx = texelSize.x; + float dy = texelSize.y; + vec2 uv = shadowCoord.xy; + vec2 f = fract( uv * shadowMapSize + 0.5 ); + uv -= f * texelSize; + shadow = ( + texture2DCompare( shadowMap, uv, shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), + f.x ), + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), + f.x ), + f.y ) + ) * ( 1.0 / 9.0 ); + #elif defined( SHADOWMAP_TYPE_VSM ) + shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); + #else + shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + vec2 cubeToUV( vec3 v, float texelSizeY ) { + vec3 absV = abs( v ); + float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); + absV *= scaleToCube; + v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); + vec2 planar = v.xy; + float almostATexel = 1.5 * texelSizeY; + float almostOne = 1.0 - almostATexel; + if ( absV.z >= almostOne ) { + if ( v.z > 0.0 ) + planar.x = 4.0 - v.x; + } else if ( absV.x >= almostOne ) { + float signX = sign( v.x ); + planar.x = v.z * signX + 2.0 * signX; + } else if ( absV.y >= almostOne ) { + float signY = sign( v.y ); + planar.x = v.x + 2.0 * signY + 2.0; + planar.y = v.z * signY - 2.0; + } + return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); + } + float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + + float lightToPositionLength = length( lightToPosition ); + if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { + float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); + #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) + vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; + shadow = ( + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) + ) * ( 1.0 / 9.0 ); + #else + shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } +#endif`,B_=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,z_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,k_=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,V_=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,H_=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,G_=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,W_=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,X_=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,q_=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,Y_=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,Z_=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,J_=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,$_=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + + #else + + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,K_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,Q_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,j_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,t0=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_BATCHING + worldPosition = batchingMatrix * worldPosition; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`,e0=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,n0=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,i0=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,s0=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float flipEnvMap; +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,r0=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,a0=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,o0=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,c0=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,l0=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,h0=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +#include +void main () { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = packDepthToRGBA( dist ); +}`,u0=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,d0=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,f0=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,p0=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,m0=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,g0=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,_0=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,x0=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,v0=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,y0=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,M0=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,S0=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,b0=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,E0=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,T0=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,w0=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); + outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,A0=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,C0=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,R0=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,I0=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,P0=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,L0=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include +}`,D0=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,U0=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,Gt={alphahash_fragment:ng,alphahash_pars_fragment:ig,alphamap_fragment:sg,alphamap_pars_fragment:rg,alphatest_fragment:ag,alphatest_pars_fragment:og,aomap_fragment:cg,aomap_pars_fragment:lg,batching_pars_vertex:hg,batching_vertex:ug,begin_vertex:dg,beginnormal_vertex:fg,bsdfs:pg,iridescence_fragment:mg,bumpmap_pars_fragment:gg,clipping_planes_fragment:_g,clipping_planes_pars_fragment:xg,clipping_planes_pars_vertex:vg,clipping_planes_vertex:yg,color_fragment:Mg,color_pars_fragment:Sg,color_pars_vertex:bg,color_vertex:Eg,common:Tg,cube_uv_reflection_fragment:wg,defaultnormal_vertex:Ag,displacementmap_pars_vertex:Cg,displacementmap_vertex:Rg,emissivemap_fragment:Ig,emissivemap_pars_fragment:Pg,colorspace_fragment:Lg,colorspace_pars_fragment:Dg,envmap_fragment:Ug,envmap_common_pars_fragment:Ng,envmap_pars_fragment:Fg,envmap_pars_vertex:Og,envmap_physical_pars_fragment:Zg,envmap_vertex:Bg,fog_vertex:zg,fog_pars_vertex:kg,fog_fragment:Vg,fog_pars_fragment:Hg,gradientmap_pars_fragment:Gg,lightmap_pars_fragment:Wg,lights_lambert_fragment:Xg,lights_lambert_pars_fragment:qg,lights_pars_begin:Yg,lights_toon_fragment:Jg,lights_toon_pars_fragment:$g,lights_phong_fragment:Kg,lights_phong_pars_fragment:Qg,lights_physical_fragment:jg,lights_physical_pars_fragment:t_,lights_fragment_begin:e_,lights_fragment_maps:n_,lights_fragment_end:i_,logdepthbuf_fragment:s_,logdepthbuf_pars_fragment:r_,logdepthbuf_pars_vertex:a_,logdepthbuf_vertex:o_,map_fragment:c_,map_pars_fragment:l_,map_particle_fragment:h_,map_particle_pars_fragment:u_,metalnessmap_fragment:d_,metalnessmap_pars_fragment:f_,morphinstance_vertex:p_,morphcolor_vertex:m_,morphnormal_vertex:g_,morphtarget_pars_vertex:__,morphtarget_vertex:x_,normal_fragment_begin:v_,normal_fragment_maps:y_,normal_pars_fragment:M_,normal_pars_vertex:S_,normal_vertex:b_,normalmap_pars_fragment:E_,clearcoat_normal_fragment_begin:T_,clearcoat_normal_fragment_maps:w_,clearcoat_pars_fragment:A_,iridescence_pars_fragment:C_,opaque_fragment:R_,packing:I_,premultiplied_alpha_fragment:P_,project_vertex:L_,dithering_fragment:D_,dithering_pars_fragment:U_,roughnessmap_fragment:N_,roughnessmap_pars_fragment:F_,shadowmap_pars_fragment:O_,shadowmap_pars_vertex:B_,shadowmap_vertex:z_,shadowmask_pars_fragment:k_,skinbase_vertex:V_,skinning_pars_vertex:H_,skinning_vertex:G_,skinnormal_vertex:W_,specularmap_fragment:X_,specularmap_pars_fragment:q_,tonemapping_fragment:Y_,tonemapping_pars_fragment:Z_,transmission_fragment:J_,transmission_pars_fragment:$_,uv_pars_fragment:K_,uv_pars_vertex:Q_,uv_vertex:j_,worldpos_vertex:t0,background_vert:e0,background_frag:n0,backgroundCube_vert:i0,backgroundCube_frag:s0,cube_vert:r0,cube_frag:a0,depth_vert:o0,depth_frag:c0,distanceRGBA_vert:l0,distanceRGBA_frag:h0,equirect_vert:u0,equirect_frag:d0,linedashed_vert:f0,linedashed_frag:p0,meshbasic_vert:m0,meshbasic_frag:g0,meshlambert_vert:_0,meshlambert_frag:x0,meshmatcap_vert:v0,meshmatcap_frag:y0,meshnormal_vert:M0,meshnormal_frag:S0,meshphong_vert:b0,meshphong_frag:E0,meshphysical_vert:T0,meshphysical_frag:w0,meshtoon_vert:A0,meshtoon_frag:C0,points_vert:R0,points_frag:I0,shadow_vert:P0,shadow_frag:L0,sprite_vert:D0,sprite_frag:U0},ct={common:{diffuse:{value:new ut(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Bt},alphaMap:{value:null},alphaMapTransform:{value:new Bt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Bt}},envmap:{envMap:{value:null},envMapRotation:{value:new Bt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Bt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Bt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Bt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Bt},normalScale:{value:new $(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Bt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Bt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Bt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Bt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ut(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,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 ut(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Bt},alphaTest:{value:0},uvTransform:{value:new Bt}},sprite:{diffuse:{value:new ut(16777215)},opacity:{value:1},center:{value:new $(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Bt},alphaMap:{value:null},alphaMapTransform:{value:new Bt},alphaTest:{value:0}}},un={basic:{uniforms:Ne([ct.common,ct.specularmap,ct.envmap,ct.aomap,ct.lightmap,ct.fog]),vertexShader:Gt.meshbasic_vert,fragmentShader:Gt.meshbasic_frag},lambert:{uniforms:Ne([ct.common,ct.specularmap,ct.envmap,ct.aomap,ct.lightmap,ct.emissivemap,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.fog,ct.lights,{emissive:{value:new ut(0)}}]),vertexShader:Gt.meshlambert_vert,fragmentShader:Gt.meshlambert_frag},phong:{uniforms:Ne([ct.common,ct.specularmap,ct.envmap,ct.aomap,ct.lightmap,ct.emissivemap,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.fog,ct.lights,{emissive:{value:new ut(0)},specular:{value:new ut(1118481)},shininess:{value:30}}]),vertexShader:Gt.meshphong_vert,fragmentShader:Gt.meshphong_frag},standard:{uniforms:Ne([ct.common,ct.envmap,ct.aomap,ct.lightmap,ct.emissivemap,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.roughnessmap,ct.metalnessmap,ct.fog,ct.lights,{emissive:{value:new ut(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Gt.meshphysical_vert,fragmentShader:Gt.meshphysical_frag},toon:{uniforms:Ne([ct.common,ct.aomap,ct.lightmap,ct.emissivemap,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.gradientmap,ct.fog,ct.lights,{emissive:{value:new ut(0)}}]),vertexShader:Gt.meshtoon_vert,fragmentShader:Gt.meshtoon_frag},matcap:{uniforms:Ne([ct.common,ct.bumpmap,ct.normalmap,ct.displacementmap,ct.fog,{matcap:{value:null}}]),vertexShader:Gt.meshmatcap_vert,fragmentShader:Gt.meshmatcap_frag},points:{uniforms:Ne([ct.points,ct.fog]),vertexShader:Gt.points_vert,fragmentShader:Gt.points_frag},dashed:{uniforms:Ne([ct.common,ct.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Gt.linedashed_vert,fragmentShader:Gt.linedashed_frag},depth:{uniforms:Ne([ct.common,ct.displacementmap]),vertexShader:Gt.depth_vert,fragmentShader:Gt.depth_frag},normal:{uniforms:Ne([ct.common,ct.bumpmap,ct.normalmap,ct.displacementmap,{opacity:{value:1}}]),vertexShader:Gt.meshnormal_vert,fragmentShader:Gt.meshnormal_frag},sprite:{uniforms:Ne([ct.sprite,ct.fog]),vertexShader:Gt.sprite_vert,fragmentShader:Gt.sprite_frag},background:{uniforms:{uvTransform:{value:new Bt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Gt.background_vert,fragmentShader:Gt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Bt}},vertexShader:Gt.backgroundCube_vert,fragmentShader:Gt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Gt.cube_vert,fragmentShader:Gt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Gt.equirect_vert,fragmentShader:Gt.equirect_frag},distanceRGBA:{uniforms:Ne([ct.common,ct.displacementmap,{referencePosition:{value:new A},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Gt.distanceRGBA_vert,fragmentShader:Gt.distanceRGBA_frag},shadow:{uniforms:Ne([ct.lights,ct.fog,{color:{value:new ut(0)},opacity:{value:1}}]),vertexShader:Gt.shadow_vert,fragmentShader:Gt.shadow_frag}};un.physical={uniforms:Ne([un.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Bt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Bt},clearcoatNormalScale:{value:new $(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Bt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Bt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Bt},sheen:{value:0},sheenColor:{value:new ut(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Bt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Bt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Bt},transmissionSamplerSize:{value:new $},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Bt},attenuationDistance:{value:0},attenuationColor:{value:new ut(0)},specularColor:{value:new ut(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Bt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Bt},anisotropyVector:{value:new $},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Bt}}]),vertexShader:Gt.meshphysical_vert,fragmentShader:Gt.meshphysical_frag};var ua={r:0,b:0,g:0},fi=new Je,N0=new Ut;function F0(s,t,e,n,i,r,a){let o=new ut(0),c=r===!0?0:1,l,h,u=null,d=0,f=null;function m(y){let v=y.isScene===!0?y.background:null;return v&&v.isTexture&&(v=(y.backgroundBlurriness>0?e:t).get(v)),v}function _(y){let v=!1,x=m(y);x===null?p(o,c):x&&x.isColor&&(p(x,1),v=!0);let P=s.xr.getEnvironmentBlendMode();P==="additive"?n.buffers.color.setClear(0,0,0,1,a):P==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(s.autoClear||v)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function g(y,v){let x=m(v);x&&(x.isCubeTexture||x.mapping===Is)?(h===void 0&&(h=new pe(new Ui(1,1,1),new $e({name:"BackgroundCubeMaterial",uniforms:Ss(un.backgroundCube.uniforms),vertexShader:un.backgroundCube.vertexShader,fragmentShader:un.backgroundCube.fragmentShader,side:Be,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(P,T,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),fi.copy(v.backgroundRotation),fi.x*=-1,fi.y*=-1,fi.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(fi.y*=-1,fi.z*=-1),h.material.uniforms.envMap.value=x,h.material.uniforms.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=v.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(N0.makeRotationFromEuler(fi)),h.material.toneMapped=Yt.getTransfer(x.colorSpace)!==se,(u!==x||d!==x.version||f!==s.toneMapping)&&(h.material.needsUpdate=!0,u=x,d=x.version,f=s.toneMapping),h.layers.enableAll(),y.unshift(h,h.geometry,h.material,0,0,null)):x&&x.isTexture&&(l===void 0&&(l=new pe(new Es(2,2),new $e({name:"BackgroundMaterial",uniforms:Ss(un.background.uniforms),vertexShader:un.background.vertexShader,fragmentShader:un.background.fragmentShader,side:Vn,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=x,l.material.uniforms.backgroundIntensity.value=v.backgroundIntensity,l.material.toneMapped=Yt.getTransfer(x.colorSpace)!==se,x.matrixAutoUpdate===!0&&x.updateMatrix(),l.material.uniforms.uvTransform.value.copy(x.matrix),(u!==x||d!==x.version||f!==s.toneMapping)&&(l.material.needsUpdate=!0,u=x,d=x.version,f=s.toneMapping),l.layers.enableAll(),y.unshift(l,l.geometry,l.material,0,0,null))}function p(y,v){y.getRGB(ua,op(s)),n.buffers.color.setClear(ua.r,ua.g,ua.b,v,a)}return{getClearColor:function(){return o},setClearColor:function(y,v=1){o.set(y),c=v,p(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(y){c=y,p(o,c)},render:_,addToRenderList:g}}function O0(s,t){let e=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=d(null),r=i,a=!1;function o(M,L,k,O,V){let Z=!1,H=u(O,k,L);r!==H&&(r=H,l(r.object)),Z=f(M,O,k,V),Z&&m(M,O,k,V),V!==null&&t.update(V,s.ELEMENT_ARRAY_BUFFER),(Z||a)&&(a=!1,x(M,L,k,O),V!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t.get(V).buffer))}function c(){return s.createVertexArray()}function l(M){return s.bindVertexArray(M)}function h(M){return s.deleteVertexArray(M)}function u(M,L,k){let O=k.wireframe===!0,V=n[M.id];V===void 0&&(V={},n[M.id]=V);let Z=V[L.id];Z===void 0&&(Z={},V[L.id]=Z);let H=Z[O];return H===void 0&&(H=d(c()),Z[O]=H),H}function d(M){let L=[],k=[],O=[];for(let V=0;V=0){let mt=V[G],St=Z[G];if(St===void 0&&(G==="instanceMatrix"&&M.instanceMatrix&&(St=M.instanceMatrix),G==="instanceColor"&&M.instanceColor&&(St=M.instanceColor)),mt===void 0||mt.attribute!==St||St&&mt.data!==St.data)return!0;H++}return r.attributesNum!==H||r.index!==O}function m(M,L,k,O){let V={},Z=L.attributes,H=0,et=k.getAttributes();for(let G in et)if(et[G].location>=0){let mt=Z[G];mt===void 0&&(G==="instanceMatrix"&&M.instanceMatrix&&(mt=M.instanceMatrix),G==="instanceColor"&&M.instanceColor&&(mt=M.instanceColor));let St={};St.attribute=mt,mt&&mt.data&&(St.data=mt.data),V[G]=St,H++}r.attributes=V,r.attributesNum=H,r.index=O}function _(){let M=r.newAttributes;for(let L=0,k=M.length;L=0){let ot=V[et];if(ot===void 0&&(et==="instanceMatrix"&&M.instanceMatrix&&(ot=M.instanceMatrix),et==="instanceColor"&&M.instanceColor&&(ot=M.instanceColor)),ot!==void 0){let mt=ot.normalized,St=ot.itemSize,zt=t.get(ot);if(zt===void 0)continue;let jt=zt.buffer,Y=zt.type,it=zt.bytesPerElement,bt=Y===s.INT||Y===s.UNSIGNED_INT||ot.gpuType===Nc;if(ot.isInterleavedBufferAttribute){let rt=ot.data,It=rt.stride,Ft=ot.offset;if(rt.isInstancedInterleavedBuffer){for(let Dt=0;Dt0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";C="mediump"}return C==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp",h=c(l);h!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);let u=e.logarithmicDepthBuffer===!0,d=e.reverseDepthBuffer===!0&&t.has("EXT_clip_control"),f=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),m=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=s.getParameter(s.MAX_TEXTURE_SIZE),g=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),p=s.getParameter(s.MAX_VERTEX_ATTRIBS),y=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),v=s.getParameter(s.MAX_VARYING_VECTORS),x=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),P=m>0,T=s.getParameter(s.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reverseDepthBuffer:d,maxTextures:f,maxVertexTextures:m,maxTextureSize:_,maxCubemapSize:g,maxAttributes:p,maxVertexUniforms:y,maxVaryings:v,maxFragmentUniforms:x,vertexTextures:P,maxSamples:T}}function k0(s){let t=this,e=null,n=0,i=!1,r=!1,a=new mn,o=new Bt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){let f=u.length!==0||d||n!==0||i;return i=d,n=u.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){let m=u.clippingPlanes,_=u.clipIntersection,g=u.clipShadows,p=s.get(u);if(!i||m===null||m.length===0||r&&!g)r?h(null):l();else{let y=r?0:n,v=y*4,x=p.clippingState||null;c.value=x,x=h(m,d,v,f);for(let P=0;P!==v;++P)x[P]=e[P];p.clippingState=x,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=y}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,m){let _=u!==null?u.length:0,g=null;if(_!==0){if(g=c.value,m!==!0||g===null){let p=f+_*4,y=d.matrixWorldInverse;o.getNormalMatrix(y),(g===null||g.length0){let l=new wo(c.height);return l.fromEquirectangularTexture(s,a),t.set(a,l),a.addEventListener("dispose",i),e(l.texture,a.mapping)}else return null}}return a}function i(a){let o=a.target;o.removeEventListener("dispose",i);let c=t.get(o);c!==void 0&&(t.delete(o),c.dispose())}function r(){t=new WeakMap}return{get:n,dispose:r}}var Ts=class extends bs{constructor(t=-1,e=1,n=1,i=-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=i,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,i,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=i,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,i=(this.top+this.bottom)/2,r=n-t,a=n+t,o=i+e,c=i-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}},ps=4,td=[.125,.215,.35,.446,.526,.582],Ei=20,dl=new Ts,ed=new ut,fl=null,pl=0,ml=0,gl=!1,bi=(1+Math.sqrt(5))/2,as=1/bi,nd=[new A(-bi,as,0),new A(bi,as,0),new A(-as,0,bi),new A(as,0,bi),new A(0,bi,-as),new A(0,bi,as),new A(-1,1,-1),new A(1,1,-1),new A(-1,1,1),new A(1,1,1)],xr=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,i=100){fl=this._renderer.getRenderTarget(),pl=this._renderer.getActiveCubeFace(),ml=this._renderer.getActiveMipmapLevel(),gl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);let r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(t,n,i,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=rd(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=sd(),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?v:0,v,v),h.setRenderTarget(i),_&&h.render(m,o),h.render(t,o)}m.geometry.dispose(),m.material.dispose(),h.toneMapping=d,h.autoClear=u,t.background=g}_textureToCubeUV(t,e){let n=this._renderer,i=t.mapping===Hn||t.mapping===ii;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=rd()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=sd());let r=i?this._cubemapMaterial:this._equirectMaterial,a=new pe(this._lodPlanes[0],r),o=r.uniforms;o.envMap.value=t;let c=this._cubeSize;da(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(a,dl)}_applyPMREM(t){let e=this._renderer,n=e.autoClear;e.autoClear=!1;let i=this._lodPlanes.length;for(let r=1;rEi&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${Ei}`);let p=[],y=0;for(let C=0;Cv-ps?i-v+ps:0),T=4*(this._cubeSize-x);da(e,P,T,3*x,2*x),c.setRenderTarget(e),c.render(u,dl)}};function H0(s){let t=[],e=[],n=[],i=s,r=s-ps+1+td.length;for(let a=0;as-ps?c=td[a-s+ps-1]:a===0&&(c=0),n.push(c);let l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,m=6,_=3,g=2,p=1,y=new Float32Array(_*m*f),v=new Float32Array(g*m*f),x=new Float32Array(p*m*f);for(let T=0;T2?0:-1,b=[C,R,0,C+2/3,R,0,C+2/3,R+1,0,C,R,0,C+2/3,R+1,0,C,R+1,0];y.set(b,_*m*T),v.set(d,g*m*T);let M=[T,T,T,T,T,T];x.set(M,p*m*T)}let P=new Wt;P.setAttribute("position",new ne(y,_)),P.setAttribute("uv",new ne(v,g)),P.setAttribute("faceIndex",new ne(x,p)),t.push(P),i>ps&&i--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function id(s,t,e){let n=new Ze(s,t,e);return n.texture.mapping=Is,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function da(s,t,e,n,i){s.viewport.set(t,e,n,i),s.scissor.set(t,e,n,i)}function G0(s,t,e){let n=new Float32Array(Ei),i=new A(0,1,0);return new $e({name:"SphericalGaussianBlur",defines:{n:Ei,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:yu(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:On,depthTest:!1,depthWrite:!1})}function sd(){return new $e({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:yu(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:On,depthTest:!1,depthWrite:!1})}function rd(){return new $e({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:yu(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:On,depthTest:!1,depthWrite:!1})}function yu(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}function W0(s){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){let c=o.mapping,l=c===ar||c===or,h=c===Hn||c===ii;if(l||h){let u=t.get(o),d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return e===null&&(e=new xr(s)),u=l?e.fromEquirectangular(o,u):e.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),u.texture;if(u!==void 0)return u.texture;{let f=o.image;return l&&f&&f.height>0||h&&f&&i(f)?(e===null&&(e=new xr(s)),u=l?e.fromEquirectangular(o):e.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),o.addEventListener("dispose",r),u.texture):null}}}return o}function i(o){let c=0,l=6;for(let h=0;ht.maxTextureSize&&(P=Math.ceil(x/t.maxTextureSize),x=t.maxTextureSize);let T=new Float32Array(x*P*4*u),C=new ys(T,x,P,u);C.type=Ge,C.needsUpdate=!0;let R=v*4;for(let M=0;M0)return s;let i=t*e,r=od[i];if(r===void 0&&(r=new Float32Array(i),od[i]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,s[a].toArray(r,o)}return r}function ye(s,t){if(s.length!==t.length)return!1;for(let e=0,n=s.length;e":" "} ${o}: ${e[a]}`)}return n.join(` +`)}var pd=new Bt;function Vx(s){Yt._getMatrix(pd,Yt.workingColorSpace,s);let t=`mat3( ${pd.elements.map(e=>e.toFixed(4))} )`;switch(Yt.getTransfer(s)){case Xr:return[t,"LinearTransferOETF"];case se:return[t,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",s),[t,"LinearTransferOETF"]}}function md(s,t,e){let n=s.getShaderParameter(t,s.COMPILE_STATUS),i=s.getShaderInfoLog(t).trim();if(n&&i==="")return"";let r=/ERROR: 0:(\d+)/.exec(i);if(r){let a=parseInt(r[1]);return e.toUpperCase()+` + +`+i+` + +`+kx(s.getShaderSource(t),a)}else return i}function Hx(s,t){let e=Vx(t);return[`vec4 ${s}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(` +`)}function Gx(s,t){let e;switch(t){case Of:e="Linear";break;case Bf:e="Reinhard";break;case zf:e="Cineon";break;case kf:e="ACESFilmic";break;case Hf:e="AgX";break;case Gf:e="Neutral";break;case Vf:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+s+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}var fa=new A;function Wx(){Yt.getLuminanceCoefficients(fa);let s=fa.x.toFixed(4),t=fa.y.toFixed(4),e=fa.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(` +`)}function Xx(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Js).join(` +`)}function qx(s){let t=[];for(let e in s){let n=s[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(` +`)}function Yx(s,t){let e={},n=s.getProgramParameter(t,s.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function Kl(s){return s.replace(Zx,$x)}var Jx=new Map;function $x(s,t){let e=Gt[t];if(e===void 0){let n=Jx.get(t);if(n!==void 0)e=Gt[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 Kl(e)}var Kx=/#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 xd(s){return s.replace(Kx,Qx)}function Qx(s,t,e,n){let i="";for(let r=parseInt(t);r0&&(g+=` +`),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m].filter(Js).join(` +`),p.length>0&&(p+=` +`)):(g=[vd(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",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.anisotropy?"#define USE_ANISOTROPY":"",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?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#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.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(Js).join(` +`),p=[vd(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",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 "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.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.dispersion?"#define USE_DISPERSION":"",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||e.batchingColor?"#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.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",e.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==Bn?"#define TONE_MAPPING":"",e.toneMapping!==Bn?Gt.tonemapping_pars_fragment:"",e.toneMapping!==Bn?Gx("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Gt.colorspace_pars_fragment,Hx("linearToOutputTexel",e.outputColorSpace),Wx(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",` +`].filter(Js).join(` +`)),a=Kl(a),a=gd(a,e),a=_d(a,e),o=Kl(o),o=gd(o,e),o=_d(o,e),a=xd(a),o=xd(o),e.isRawShaderMaterial!==!0&&(y=`#version 300 es +`,g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+g,p=["#define varying in",e.glslVersion===zl?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===zl?"":"#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(` +`)+` +`+p);let v=y+g+a,x=y+p+o,P=fd(i,i.VERTEX_SHADER,v),T=fd(i,i.FRAGMENT_SHADER,x);i.attachShader(_,P),i.attachShader(_,T),e.index0AttributeName!==void 0?i.bindAttribLocation(_,0,e.index0AttributeName):e.morphTargets===!0&&i.bindAttribLocation(_,0,"position"),i.linkProgram(_);function C(L){if(s.debug.checkShaderErrors){let k=i.getProgramInfoLog(_).trim(),O=i.getShaderInfoLog(P).trim(),V=i.getShaderInfoLog(T).trim(),Z=!0,H=!0;if(i.getProgramParameter(_,i.LINK_STATUS)===!1)if(Z=!1,typeof s.debug.onShaderError=="function")s.debug.onShaderError(i,_,P,T);else{let et=md(i,P,"vertex"),G=md(i,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(_,i.VALIDATE_STATUS)+` + +Material Name: `+L.name+` +Material Type: `+L.type+` + +Program Info Log: `+k+` +`+et+` +`+G)}else k!==""?console.warn("THREE.WebGLProgram: Program Info Log:",k):(O===""||V==="")&&(H=!1);H&&(L.diagnostics={runnable:Z,programLog:k,vertexShader:{log:O,prefix:g},fragmentShader:{log:V,prefix:p}})}i.deleteShader(P),i.deleteShader(T),R=new _s(i,_),b=Yx(i,_)}let R;this.getUniforms=function(){return R===void 0&&C(this),R};let b;this.getAttributes=function(){return b===void 0&&C(this),b};let M=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=i.getProgramParameter(_,Bx)),M},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=zx++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=P,this.fragmentShader=T,this}var rv=0,Ql=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){let e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),r=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return a.has(i)===!1&&(a.add(i),i.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 jl(t),e.set(t,n)),n}},jl=class{constructor(t){this.id=rv++,this.code=t,this.usedTimes=0}};function av(s,t,e,n,i,r,a){let o=new Ms,c=new Ql,l=new Set,h=[],u=i.logarithmicDepthBuffer,d=i.vertexTextures,f=i.precision,m={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 _(b){return l.add(b),b===0?"uv":`uv${b}`}function g(b,M,L,k,O){let V=k.fog,Z=O.geometry,H=b.isMeshStandardMaterial?k.environment:null,et=(b.isMeshStandardMaterial?e:t).get(b.envMap||H),G=et&&et.mapping===Is?et.image.height:null,ot=m[b.type];b.precision!==null&&(f=i.getMaxPrecision(b.precision),f!==b.precision&&console.warn("THREE.WebGLProgram.getParameters:",b.precision,"not supported, using",f,"instead."));let mt=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,St=mt!==void 0?mt.length:0,zt=0;Z.morphAttributes.position!==void 0&&(zt=1),Z.morphAttributes.normal!==void 0&&(zt=2),Z.morphAttributes.color!==void 0&&(zt=3);let jt,Y,it,bt;if(ot){let ie=un[ot];jt=ie.vertexShader,Y=ie.fragmentShader}else jt=b.vertexShader,Y=b.fragmentShader,c.update(b),it=c.getVertexShaderID(b),bt=c.getFragmentShaderID(b);let rt=s.getRenderTarget(),It=s.state.buffers.depth.getReversed(),Ft=O.isInstancedMesh===!0,Dt=O.isBatchedMesh===!0,Jt=!!b.map,K=!!b.matcap,nt=!!et,I=!!b.aoMap,Ct=!!b.lightMap,j=!!b.bumpMap,xt=!!b.normalMap,at=!!b.displacementMap,Pt=!!b.emissiveMap,gt=!!b.metalnessMap,w=!!b.roughnessMap,S=b.anisotropy>0,F=b.clearcoat>0,X=b.dispersion>0,Q=b.iridescence>0,q=b.sheen>0,Et=b.transmission>0,lt=S&&!!b.anisotropyMap,_t=F&&!!b.clearcoatMap,qt=F&&!!b.clearcoatNormalMap,tt=F&&!!b.clearcoatRoughnessMap,vt=Q&&!!b.iridescenceMap,Lt=Q&&!!b.iridescenceThicknessMap,Nt=q&&!!b.sheenColorMap,yt=q&&!!b.sheenRoughnessMap,Zt=!!b.specularMap,Xt=!!b.specularColorMap,ae=!!b.specularIntensityMap,D=Et&&!!b.transmissionMap,ht=Et&&!!b.thicknessMap,W=!!b.gradientMap,J=!!b.alphaMap,pt=b.alphaTest>0,dt=!!b.alphaHash,Vt=!!b.extensions,ue=Bn;b.toneMapped&&(rt===null||rt.isXRRenderTarget===!0)&&(ue=s.toneMapping);let Ce={shaderID:ot,shaderType:b.type,shaderName:b.name,vertexShader:jt,fragmentShader:Y,defines:b.defines,customVertexShaderID:it,customFragmentShaderID:bt,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:f,batching:Dt,batchingColor:Dt&&O._colorsTexture!==null,instancing:Ft,instancingColor:Ft&&O.instanceColor!==null,instancingMorph:Ft&&O.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:rt===null?s.outputColorSpace:rt.isXRRenderTarget===!0?rt.texture.colorSpace:qi,alphaToCoverage:!!b.alphaToCoverage,map:Jt,matcap:K,envMap:nt,envMapMode:nt&&et.mapping,envMapCubeUVHeight:G,aoMap:I,lightMap:Ct,bumpMap:j,normalMap:xt,displacementMap:d&&at,emissiveMap:Pt,normalMapObjectSpace:xt&&b.normalMapType===$f,normalMapTangentSpace:xt&&b.normalMapType===oi,metalnessMap:gt,roughnessMap:w,anisotropy:S,anisotropyMap:lt,clearcoat:F,clearcoatMap:_t,clearcoatNormalMap:qt,clearcoatRoughnessMap:tt,dispersion:X,iridescence:Q,iridescenceMap:vt,iridescenceThicknessMap:Lt,sheen:q,sheenColorMap:Nt,sheenRoughnessMap:yt,specularMap:Zt,specularColorMap:Xt,specularIntensityMap:ae,transmission:Et,transmissionMap:D,thicknessMap:ht,gradientMap:W,opaque:b.transparent===!1&&b.blending===Ci&&b.alphaToCoverage===!1,alphaMap:J,alphaTest:pt,alphaHash:dt,combine:b.combine,mapUv:Jt&&_(b.map.channel),aoMapUv:I&&_(b.aoMap.channel),lightMapUv:Ct&&_(b.lightMap.channel),bumpMapUv:j&&_(b.bumpMap.channel),normalMapUv:xt&&_(b.normalMap.channel),displacementMapUv:at&&_(b.displacementMap.channel),emissiveMapUv:Pt&&_(b.emissiveMap.channel),metalnessMapUv:gt&&_(b.metalnessMap.channel),roughnessMapUv:w&&_(b.roughnessMap.channel),anisotropyMapUv:lt&&_(b.anisotropyMap.channel),clearcoatMapUv:_t&&_(b.clearcoatMap.channel),clearcoatNormalMapUv:qt&&_(b.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:tt&&_(b.clearcoatRoughnessMap.channel),iridescenceMapUv:vt&&_(b.iridescenceMap.channel),iridescenceThicknessMapUv:Lt&&_(b.iridescenceThicknessMap.channel),sheenColorMapUv:Nt&&_(b.sheenColorMap.channel),sheenRoughnessMapUv:yt&&_(b.sheenRoughnessMap.channel),specularMapUv:Zt&&_(b.specularMap.channel),specularColorMapUv:Xt&&_(b.specularColorMap.channel),specularIntensityMapUv:ae&&_(b.specularIntensityMap.channel),transmissionMapUv:D&&_(b.transmissionMap.channel),thicknessMapUv:ht&&_(b.thicknessMap.channel),alphaMapUv:J&&_(b.alphaMap.channel),vertexTangents:!!Z.attributes.tangent&&(xt||S),vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!Z.attributes.color&&Z.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!Z.attributes.uv&&(Jt||J),fog:!!V,useFog:b.fog===!0,fogExp2:!!V&&V.isFogExp2,flatShading:b.flatShading===!0,sizeAttenuation:b.sizeAttenuation===!0,logarithmicDepthBuffer:u,reverseDepthBuffer:It,skinning:O.isSkinnedMesh===!0,morphTargets:Z.morphAttributes.position!==void 0,morphNormals:Z.morphAttributes.normal!==void 0,morphColors:Z.morphAttributes.color!==void 0,morphTargetsCount:St,morphTextureStride:zt,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:b.dithering,shadowMapEnabled:s.shadowMap.enabled&&L.length>0,shadowMapType:s.shadowMap.type,toneMapping:ue,decodeVideoTexture:Jt&&b.map.isVideoTexture===!0&&Yt.getTransfer(b.map.colorSpace)===se,decodeVideoTextureEmissive:Pt&&b.emissiveMap.isVideoTexture===!0&&Yt.getTransfer(b.emissiveMap.colorSpace)===se,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===gn,flipSided:b.side===Be,useDepthPacking:b.depthPacking>=0,depthPacking:b.depthPacking||0,index0AttributeName:b.index0AttributeName,extensionClipCullDistance:Vt&&b.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Vt&&b.extensions.multiDraw===!0||Dt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:b.customProgramCacheKey()};return Ce.vertexUv1s=l.has(1),Ce.vertexUv2s=l.has(2),Ce.vertexUv3s=l.has(3),l.clear(),Ce}function p(b){let M=[];if(b.shaderID?M.push(b.shaderID):(M.push(b.customVertexShaderID),M.push(b.customFragmentShaderID)),b.defines!==void 0)for(let L in b.defines)M.push(L),M.push(b.defines[L]);return b.isRawShaderMaterial===!1&&(y(M,b),v(M,b),M.push(s.outputColorSpace)),M.push(b.customProgramCacheKey),M.join()}function y(b,M){b.push(M.precision),b.push(M.outputColorSpace),b.push(M.envMapMode),b.push(M.envMapCubeUVHeight),b.push(M.mapUv),b.push(M.alphaMapUv),b.push(M.lightMapUv),b.push(M.aoMapUv),b.push(M.bumpMapUv),b.push(M.normalMapUv),b.push(M.displacementMapUv),b.push(M.emissiveMapUv),b.push(M.metalnessMapUv),b.push(M.roughnessMapUv),b.push(M.anisotropyMapUv),b.push(M.clearcoatMapUv),b.push(M.clearcoatNormalMapUv),b.push(M.clearcoatRoughnessMapUv),b.push(M.iridescenceMapUv),b.push(M.iridescenceThicknessMapUv),b.push(M.sheenColorMapUv),b.push(M.sheenRoughnessMapUv),b.push(M.specularMapUv),b.push(M.specularColorMapUv),b.push(M.specularIntensityMapUv),b.push(M.transmissionMapUv),b.push(M.thicknessMapUv),b.push(M.combine),b.push(M.fogExp2),b.push(M.sizeAttenuation),b.push(M.morphTargetsCount),b.push(M.morphAttributeCount),b.push(M.numDirLights),b.push(M.numPointLights),b.push(M.numSpotLights),b.push(M.numSpotLightMaps),b.push(M.numHemiLights),b.push(M.numRectAreaLights),b.push(M.numDirLightShadows),b.push(M.numPointLightShadows),b.push(M.numSpotLightShadows),b.push(M.numSpotLightShadowsWithMaps),b.push(M.numLightProbes),b.push(M.shadowMapType),b.push(M.toneMapping),b.push(M.numClippingPlanes),b.push(M.numClipIntersection),b.push(M.depthPacking)}function v(b,M){o.disableAll(),M.supportsVertexTextures&&o.enable(0),M.instancing&&o.enable(1),M.instancingColor&&o.enable(2),M.instancingMorph&&o.enable(3),M.matcap&&o.enable(4),M.envMap&&o.enable(5),M.normalMapObjectSpace&&o.enable(6),M.normalMapTangentSpace&&o.enable(7),M.clearcoat&&o.enable(8),M.iridescence&&o.enable(9),M.alphaTest&&o.enable(10),M.vertexColors&&o.enable(11),M.vertexAlphas&&o.enable(12),M.vertexUv1s&&o.enable(13),M.vertexUv2s&&o.enable(14),M.vertexUv3s&&o.enable(15),M.vertexTangents&&o.enable(16),M.anisotropy&&o.enable(17),M.alphaHash&&o.enable(18),M.batching&&o.enable(19),M.dispersion&&o.enable(20),M.batchingColor&&o.enable(21),b.push(o.mask),o.disableAll(),M.fog&&o.enable(0),M.useFog&&o.enable(1),M.flatShading&&o.enable(2),M.logarithmicDepthBuffer&&o.enable(3),M.reverseDepthBuffer&&o.enable(4),M.skinning&&o.enable(5),M.morphTargets&&o.enable(6),M.morphNormals&&o.enable(7),M.morphColors&&o.enable(8),M.premultipliedAlpha&&o.enable(9),M.shadowMapEnabled&&o.enable(10),M.doubleSided&&o.enable(11),M.flipSided&&o.enable(12),M.useDepthPacking&&o.enable(13),M.dithering&&o.enable(14),M.transmission&&o.enable(15),M.sheen&&o.enable(16),M.opaque&&o.enable(17),M.pointsUvs&&o.enable(18),M.decodeVideoTexture&&o.enable(19),M.decodeVideoTextureEmissive&&o.enable(20),M.alphaToCoverage&&o.enable(21),b.push(o.mask)}function x(b){let M=m[b.type],L;if(M){let k=un[M];L=cp.clone(k.uniforms)}else L=b.uniforms;return L}function P(b,M){let L;for(let k=0,O=h.length;k0?n.push(p):f.transparent===!0?i.push(p):e.push(p)}function c(u,d,f,m,_,g){let p=a(u,d,f,m,_,g);f.transmission>0?n.unshift(p):f.transparent===!0?i.unshift(p):e.unshift(p)}function l(u,d){e.length>1&&e.sort(u||cv),n.length>1&&n.sort(d||yd),i.length>1&&i.sort(d||yd)}function h(){for(let u=t,d=s.length;u=r.length?(a=new Md,r.push(a)):a=r[i],a}function e(){s=new WeakMap}return{get:t,dispose:e}}function hv(){let s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new A,color:new ut};break;case"SpotLight":e={position:new A,direction:new A,color:new ut,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new A,color:new ut,distance:0,decay:0};break;case"HemisphereLight":e={direction:new A,skyColor:new ut,groundColor:new ut};break;case"RectAreaLight":e={color:new ut,position:new A,halfWidth:new A,halfHeight:new A};break}return s[t.id]=e,e}}}function uv(){let s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new $,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[t.id]=e,e}}}var dv=0;function fv(s,t){return(t.castShadow?2:0)-(s.castShadow?2:0)+(t.map?1:0)-(s.map?1:0)}function pv(s){let t=new hv,e=uv(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-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,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new A);let i=new A,r=new Ut,a=new Ut;function o(l){let h=0,u=0,d=0;for(let b=0;b<9;b++)n.probe[b].set(0,0,0);let f=0,m=0,_=0,g=0,p=0,y=0,v=0,x=0,P=0,T=0,C=0;l.sort(fv);for(let b=0,M=l.length;b0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ct.LTC_FLOAT_1,n.rectAreaLTC2=ct.LTC_FLOAT_2):(n.rectAreaLTC1=ct.LTC_HALF_1,n.rectAreaLTC2=ct.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;let R=n.hash;(R.directionalLength!==f||R.pointLength!==m||R.spotLength!==_||R.rectAreaLength!==g||R.hemiLength!==p||R.numDirectionalShadows!==y||R.numPointShadows!==v||R.numSpotShadows!==x||R.numSpotMaps!==P||R.numLightProbes!==C)&&(n.directional.length=f,n.spot.length=_,n.rectArea.length=g,n.point.length=m,n.hemi.length=p,n.directionalShadow.length=y,n.directionalShadowMap.length=y,n.pointShadow.length=v,n.pointShadowMap.length=v,n.spotShadow.length=x,n.spotShadowMap.length=x,n.directionalShadowMatrix.length=y,n.pointShadowMatrix.length=v,n.spotLightMatrix.length=x+P-T,n.spotLightMap.length=P,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=C,R.directionalLength=f,R.pointLength=m,R.spotLength=_,R.rectAreaLength=g,R.hemiLength=p,R.numDirectionalShadows=y,R.numPointShadows=v,R.numSpotShadows=x,R.numSpotMaps=P,R.numLightProbes=C,n.version=dv++)}function c(l,h){let u=0,d=0,f=0,m=0,_=0,g=h.matrixWorldInverse;for(let p=0,y=l.length;p=a.length?(o=new Sd(s),a.push(o)):o=a[r],o}function n(){t=new WeakMap}return{get:e,dispose:n}}var yr=class extends Ee{static get type(){return"MeshDepthMaterial"}constructor(t){super(),this.isMeshDepthMaterial=!0,this.depthPacking=Zf,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}},Mr=class extends Ee{static get type(){return"MeshDistanceMaterial"}constructor(t){super(),this.isMeshDistanceMaterial=!0,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}},gv=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,_v=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +#include +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( squared_mean - mean * mean ); + gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); +}`;function xv(s,t,e){let n=new Fi,i=new $,r=new $,a=new $t,o=new yr({depthPacking:Jf}),c=new Mr,l={},h=e.maxTextureSize,u={[Vn]:Be,[Be]:Vn,[gn]:gn},d=new $e({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new $},radius:{value:4}},vertexShader:gv,fragmentShader:_v}),f=d.clone();f.defines.HORIZONTAL_PASS=1;let m=new Wt;m.setAttribute("position",new ne(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let _=new pe(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=au;let p=this.type;this.render=function(T,C,R){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||T.length===0)return;let b=s.getRenderTarget(),M=s.getActiveCubeFace(),L=s.getActiveMipmapLevel(),k=s.state;k.setBlending(On),k.buffers.color.setClear(1,1,1,1),k.buffers.depth.setTest(!0),k.setScissorTest(!1);let O=p!==pn&&this.type===pn,V=p===pn&&this.type!==pn;for(let Z=0,H=T.length;Zh||i.y>h)&&(i.x>h&&(r.x=Math.floor(h/ot.x),i.x=r.x*ot.x,G.mapSize.x=r.x),i.y>h&&(r.y=Math.floor(h/ot.y),i.y=r.y*ot.y,G.mapSize.y=r.y)),G.map===null||O===!0||V===!0){let St=this.type!==pn?{minFilter:Te,magFilter:Te}:{};G.map!==null&&G.map.dispose(),G.map=new Ze(i.x,i.y,St),G.map.texture.name=et.name+".shadowMap",G.camera.updateProjectionMatrix()}s.setRenderTarget(G.map),s.clear();let mt=G.getViewportCount();for(let St=0;St0||C.map&&C.alphaTest>0){let k=M.uuid,O=C.uuid,V=l[k];V===void 0&&(V={},l[k]=V);let Z=V[O];Z===void 0&&(Z=M.clone(),V[O]=Z,C.addEventListener("dispose",P)),M=Z}if(M.visible=C.visible,M.wireframe=C.wireframe,b===pn?M.side=C.shadowSide!==null?C.shadowSide:C.side:M.side=C.shadowSide!==null?C.shadowSide:u[C.side],M.alphaMap=C.alphaMap,M.alphaTest=C.alphaTest,M.map=C.map,M.clipShadows=C.clipShadows,M.clippingPlanes=C.clippingPlanes,M.clipIntersection=C.clipIntersection,M.displacementMap=C.displacementMap,M.displacementScale=C.displacementScale,M.displacementBias=C.displacementBias,M.wireframeLinewidth=C.wireframeLinewidth,M.linewidth=C.linewidth,R.isPointLight===!0&&M.isMeshDistanceMaterial===!0){let k=s.properties.get(M);k.light=R}return M}function x(T,C,R,b,M){if(T.visible===!1)return;if(T.layers.test(C.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&M===pn)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,T.matrixWorld);let O=t.update(T),V=T.material;if(Array.isArray(V)){let Z=O.groups;for(let H=0,et=Z.length;H=1):G.indexOf("OpenGL ES")!==-1&&(et=parseFloat(/^OpenGL ES (\d)/.exec(G)[1]),H=et>=2);let ot=null,mt={},St=s.getParameter(s.SCISSOR_BOX),zt=s.getParameter(s.VIEWPORT),jt=new $t().fromArray(St),Y=new $t().fromArray(zt);function it(D,ht,W,J){let pt=new Uint8Array(4),dt=s.createTexture();s.bindTexture(D,dt),s.texParameteri(D,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(D,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let Vt=0;Vtt?(s.repeat.x=1,s.repeat.y=e/t,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2):(s.repeat.x=t/e,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0),s}function Sv(s,t){let e=s.image&&s.image.width?s.image.width/s.image.height:1;return e>t?(s.repeat.x=t/e,s.repeat.y=1,s.offset.x=(1-s.repeat.x)/2,s.offset.y=0):(s.repeat.x=1,s.repeat.y=e/t,s.offset.x=0,s.offset.y=(1-s.repeat.y)/2),s}function bv(s){return s.repeat.x=1,s.repeat.y=1,s.offset.x=0,s.offset.y=0,s}function th(s,t,e,n){let i=Ev(n);switch(e){case uu:return s*t;case fu:return s*t;case pu:return s*t*2;case Bc:return s*t/i.components*i.byteLength;case Wr:return s*t/i.components*i.byteLength;case mu:return s*t*2/i.components*i.byteLength;case zc:return s*t*2/i.components*i.byteLength;case du:return s*t*3/i.components*i.byteLength;case Oe:return s*t*4/i.components*i.byteLength;case kc:return s*t*4/i.components*i.byteLength;case Ks:case Qs:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*8;case js:case tr:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case $a:case Qa:return Math.max(s,16)*Math.max(t,8)/4;case Ja:case Ka:return Math.max(s,8)*Math.max(t,8)/2;case ja:case to:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*8;case eo:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case no:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case io:return Math.floor((s+4)/5)*Math.floor((t+3)/4)*16;case so:return Math.floor((s+4)/5)*Math.floor((t+4)/5)*16;case ro:return Math.floor((s+5)/6)*Math.floor((t+4)/5)*16;case ao:return Math.floor((s+5)/6)*Math.floor((t+5)/6)*16;case oo:return Math.floor((s+7)/8)*Math.floor((t+4)/5)*16;case co:return Math.floor((s+7)/8)*Math.floor((t+5)/6)*16;case lo:return Math.floor((s+7)/8)*Math.floor((t+7)/8)*16;case ho:return Math.floor((s+9)/10)*Math.floor((t+4)/5)*16;case uo:return Math.floor((s+9)/10)*Math.floor((t+5)/6)*16;case fo:return Math.floor((s+9)/10)*Math.floor((t+7)/8)*16;case po:return Math.floor((s+9)/10)*Math.floor((t+9)/10)*16;case mo:return Math.floor((s+11)/12)*Math.floor((t+9)/10)*16;case go:return Math.floor((s+11)/12)*Math.floor((t+11)/12)*16;case er:case _o:case xo:return Math.ceil(s/4)*Math.ceil(t/4)*16;case gu:case vo:return Math.ceil(s/4)*Math.ceil(t/4)*8;case yo:case Mo:return Math.ceil(s/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function Ev(s){switch(s){case Mn:case cu:return{byteLength:1,components:1};case xs:case lu:case Ps:return{byteLength:2,components:1};case Fc:case Oc:return{byteLength:2,components:4};case Gn:case Nc:case Ge:return{byteLength:4,components:1};case hu:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${s}.`)}var Tv={contain:Mv,cover:Sv,fill:bv,getByteLength:th};function wv(s,t,e,n,i,r,a){let o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new $,h=new WeakMap,u,d=new WeakMap,f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(w,S){return f?new OffscreenCanvas(w,S):pr("canvas")}function _(w,S,F){let X=1,Q=gt(w);if((Q.width>F||Q.height>F)&&(X=F/Math.max(Q.width,Q.height)),X<1)if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&w instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&w instanceof ImageBitmap||typeof VideoFrame<"u"&&w instanceof VideoFrame){let q=Math.floor(X*Q.width),Et=Math.floor(X*Q.height);u===void 0&&(u=m(q,Et));let lt=S?m(q,Et):u;return lt.width=q,lt.height=Et,lt.getContext("2d").drawImage(w,0,0,q,Et),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Q.width+"x"+Q.height+") to ("+q+"x"+Et+")."),lt}else return"data"in w&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Q.width+"x"+Q.height+")."),w;return w}function g(w){return w.generateMipmaps}function p(w){s.generateMipmap(w)}function y(w){return w.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:w.isWebGL3DRenderTarget?s.TEXTURE_3D:w.isWebGLArrayRenderTarget||w.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function v(w,S,F,X,Q=!1){if(w!==null){if(s[w]!==void 0)return s[w];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let q=S;if(S===s.RED&&(F===s.FLOAT&&(q=s.R32F),F===s.HALF_FLOAT&&(q=s.R16F),F===s.UNSIGNED_BYTE&&(q=s.R8)),S===s.RED_INTEGER&&(F===s.UNSIGNED_BYTE&&(q=s.R8UI),F===s.UNSIGNED_SHORT&&(q=s.R16UI),F===s.UNSIGNED_INT&&(q=s.R32UI),F===s.BYTE&&(q=s.R8I),F===s.SHORT&&(q=s.R16I),F===s.INT&&(q=s.R32I)),S===s.RG&&(F===s.FLOAT&&(q=s.RG32F),F===s.HALF_FLOAT&&(q=s.RG16F),F===s.UNSIGNED_BYTE&&(q=s.RG8)),S===s.RG_INTEGER&&(F===s.UNSIGNED_BYTE&&(q=s.RG8UI),F===s.UNSIGNED_SHORT&&(q=s.RG16UI),F===s.UNSIGNED_INT&&(q=s.RG32UI),F===s.BYTE&&(q=s.RG8I),F===s.SHORT&&(q=s.RG16I),F===s.INT&&(q=s.RG32I)),S===s.RGB_INTEGER&&(F===s.UNSIGNED_BYTE&&(q=s.RGB8UI),F===s.UNSIGNED_SHORT&&(q=s.RGB16UI),F===s.UNSIGNED_INT&&(q=s.RGB32UI),F===s.BYTE&&(q=s.RGB8I),F===s.SHORT&&(q=s.RGB16I),F===s.INT&&(q=s.RGB32I)),S===s.RGBA_INTEGER&&(F===s.UNSIGNED_BYTE&&(q=s.RGBA8UI),F===s.UNSIGNED_SHORT&&(q=s.RGBA16UI),F===s.UNSIGNED_INT&&(q=s.RGBA32UI),F===s.BYTE&&(q=s.RGBA8I),F===s.SHORT&&(q=s.RGBA16I),F===s.INT&&(q=s.RGBA32I)),S===s.RGB&&F===s.UNSIGNED_INT_5_9_9_9_REV&&(q=s.RGB9_E5),S===s.RGBA){let Et=Q?Xr:Yt.getTransfer(X);F===s.FLOAT&&(q=s.RGBA32F),F===s.HALF_FLOAT&&(q=s.RGBA16F),F===s.UNSIGNED_BYTE&&(q=Et===se?s.SRGB8_ALPHA8:s.RGBA8),F===s.UNSIGNED_SHORT_4_4_4_4&&(q=s.RGBA4),F===s.UNSIGNED_SHORT_5_5_5_1&&(q=s.RGB5_A1)}return(q===s.R16F||q===s.R32F||q===s.RG16F||q===s.RG32F||q===s.RGBA16F||q===s.RGBA32F)&&t.get("EXT_color_buffer_float"),q}function x(w,S){let F;return w?S===null||S===Gn||S===Li?F=s.DEPTH24_STENCIL8:S===Ge?F=s.DEPTH32F_STENCIL8:S===xs&&(F=s.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):S===null||S===Gn||S===Li?F=s.DEPTH_COMPONENT24:S===Ge?F=s.DEPTH_COMPONENT32F:S===xs&&(F=s.DEPTH_COMPONENT16),F}function P(w,S){return g(w)===!0||w.isFramebufferTexture&&w.minFilter!==Te&&w.minFilter!==ve?Math.log2(Math.max(S.width,S.height))+1:w.mipmaps!==void 0&&w.mipmaps.length>0?w.mipmaps.length:w.isCompressedTexture&&Array.isArray(w.image)?S.mipmaps.length:1}function T(w){let S=w.target;S.removeEventListener("dispose",T),R(S),S.isVideoTexture&&h.delete(S)}function C(w){let S=w.target;S.removeEventListener("dispose",C),M(S)}function R(w){let S=n.get(w);if(S.__webglInit===void 0)return;let F=w.source,X=d.get(F);if(X){let Q=X[S.__cacheKey];Q.usedTimes--,Q.usedTimes===0&&b(w),Object.keys(X).length===0&&d.delete(F)}n.remove(w)}function b(w){let S=n.get(w);s.deleteTexture(S.__webglTexture);let F=w.source,X=d.get(F);delete X[S.__cacheKey],a.memory.textures--}function M(w){let S=n.get(w);if(w.depthTexture&&(w.depthTexture.dispose(),n.remove(w.depthTexture)),w.isWebGLCubeRenderTarget)for(let X=0;X<6;X++){if(Array.isArray(S.__webglFramebuffer[X]))for(let Q=0;Q=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+w+" texture units while this GPU supports only "+i.maxTextures),L+=1,w}function V(w){let S=[];return S.push(w.wrapS),S.push(w.wrapT),S.push(w.wrapR||0),S.push(w.magFilter),S.push(w.minFilter),S.push(w.anisotropy),S.push(w.internalFormat),S.push(w.format),S.push(w.type),S.push(w.generateMipmaps),S.push(w.premultiplyAlpha),S.push(w.flipY),S.push(w.unpackAlignment),S.push(w.colorSpace),S.join()}function Z(w,S){let F=n.get(w);if(w.isVideoTexture&&at(w),w.isRenderTargetTexture===!1&&w.version>0&&F.__version!==w.version){let X=w.image;if(X===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(X.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Y(F,w,S);return}}e.bindTexture(s.TEXTURE_2D,F.__webglTexture,s.TEXTURE0+S)}function H(w,S){let F=n.get(w);if(w.version>0&&F.__version!==w.version){Y(F,w,S);return}e.bindTexture(s.TEXTURE_2D_ARRAY,F.__webglTexture,s.TEXTURE0+S)}function et(w,S){let F=n.get(w);if(w.version>0&&F.__version!==w.version){Y(F,w,S);return}e.bindTexture(s.TEXTURE_3D,F.__webglTexture,s.TEXTURE0+S)}function G(w,S){let F=n.get(w);if(w.version>0&&F.__version!==w.version){it(F,w,S);return}e.bindTexture(s.TEXTURE_CUBE_MAP,F.__webglTexture,s.TEXTURE0+S)}let ot={[cr]:s.REPEAT,[en]:s.CLAMP_TO_EDGE,[lr]:s.MIRRORED_REPEAT},mt={[Te]:s.NEAREST,[ou]:s.NEAREST_MIPMAP_NEAREST,[ds]:s.NEAREST_MIPMAP_LINEAR,[ve]:s.LINEAR,[$s]:s.LINEAR_MIPMAP_NEAREST,[xn]:s.LINEAR_MIPMAP_LINEAR},St={[Kf]:s.NEVER,[ip]:s.ALWAYS,[Qf]:s.LESS,[xu]:s.LEQUAL,[jf]:s.EQUAL,[np]:s.GEQUAL,[tp]:s.GREATER,[ep]:s.NOTEQUAL};function zt(w,S){if(S.type===Ge&&t.has("OES_texture_float_linear")===!1&&(S.magFilter===ve||S.magFilter===$s||S.magFilter===ds||S.magFilter===xn||S.minFilter===ve||S.minFilter===$s||S.minFilter===ds||S.minFilter===xn)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(w,s.TEXTURE_WRAP_S,ot[S.wrapS]),s.texParameteri(w,s.TEXTURE_WRAP_T,ot[S.wrapT]),(w===s.TEXTURE_3D||w===s.TEXTURE_2D_ARRAY)&&s.texParameteri(w,s.TEXTURE_WRAP_R,ot[S.wrapR]),s.texParameteri(w,s.TEXTURE_MAG_FILTER,mt[S.magFilter]),s.texParameteri(w,s.TEXTURE_MIN_FILTER,mt[S.minFilter]),S.compareFunction&&(s.texParameteri(w,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(w,s.TEXTURE_COMPARE_FUNC,St[S.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===Te||S.minFilter!==ds&&S.minFilter!==xn||S.type===Ge&&t.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||n.get(S).__currentAnisotropy){let F=t.get("EXT_texture_filter_anisotropic");s.texParameterf(w,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,i.getMaxAnisotropy())),n.get(S).__currentAnisotropy=S.anisotropy}}}function jt(w,S){let F=!1;w.__webglInit===void 0&&(w.__webglInit=!0,S.addEventListener("dispose",T));let X=S.source,Q=d.get(X);Q===void 0&&(Q={},d.set(X,Q));let q=V(S);if(q!==w.__cacheKey){Q[q]===void 0&&(Q[q]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,F=!0),Q[q].usedTimes++;let Et=Q[w.__cacheKey];Et!==void 0&&(Q[w.__cacheKey].usedTimes--,Et.usedTimes===0&&b(S)),w.__cacheKey=q,w.__webglTexture=Q[q].texture}return F}function Y(w,S,F){let X=s.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(X=s.TEXTURE_2D_ARRAY),S.isData3DTexture&&(X=s.TEXTURE_3D);let Q=jt(w,S),q=S.source;e.bindTexture(X,w.__webglTexture,s.TEXTURE0+F);let Et=n.get(q);if(q.version!==Et.__version||Q===!0){e.activeTexture(s.TEXTURE0+F);let lt=Yt.getPrimaries(Yt.workingColorSpace),_t=S.colorSpace===Dn?null:Yt.getPrimaries(S.colorSpace),qt=S.colorSpace===Dn||lt===_t?s.NONE:s.BROWSER_DEFAULT_WEBGL;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,S.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,S.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,qt);let tt=_(S.image,!1,i.maxTextureSize);tt=Pt(S,tt);let vt=r.convert(S.format,S.colorSpace),Lt=r.convert(S.type),Nt=v(S.internalFormat,vt,Lt,S.colorSpace,S.isVideoTexture);zt(X,S);let yt,Zt=S.mipmaps,Xt=S.isVideoTexture!==!0,ae=Et.__version===void 0||Q===!0,D=q.dataReady,ht=P(S,tt);if(S.isDepthTexture)Nt=x(S.format===Di,S.type),ae&&(Xt?e.texStorage2D(s.TEXTURE_2D,1,Nt,tt.width,tt.height):e.texImage2D(s.TEXTURE_2D,0,Nt,tt.width,tt.height,0,vt,Lt,null));else if(S.isDataTexture)if(Zt.length>0){Xt&&ae&&e.texStorage2D(s.TEXTURE_2D,ht,Nt,Zt[0].width,Zt[0].height);for(let W=0,J=Zt.length;W0){let pt=th(yt.width,yt.height,S.format,S.type);for(let dt of S.layerUpdates){let Vt=yt.data.subarray(dt*pt/yt.data.BYTES_PER_ELEMENT,(dt+1)*pt/yt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,W,0,0,dt,yt.width,yt.height,1,vt,Vt)}S.clearLayerUpdates()}else e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,W,0,0,0,yt.width,yt.height,tt.depth,vt,yt.data)}else e.compressedTexImage3D(s.TEXTURE_2D_ARRAY,W,Nt,yt.width,yt.height,tt.depth,0,yt.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Xt?D&&e.texSubImage3D(s.TEXTURE_2D_ARRAY,W,0,0,0,yt.width,yt.height,tt.depth,vt,Lt,yt.data):e.texImage3D(s.TEXTURE_2D_ARRAY,W,Nt,yt.width,yt.height,tt.depth,0,vt,Lt,yt.data)}else{Xt&&ae&&e.texStorage2D(s.TEXTURE_2D,ht,Nt,Zt[0].width,Zt[0].height);for(let W=0,J=Zt.length;W0){let W=th(tt.width,tt.height,S.format,S.type);for(let J of S.layerUpdates){let pt=tt.data.subarray(J*W/tt.data.BYTES_PER_ELEMENT,(J+1)*W/tt.data.BYTES_PER_ELEMENT);e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,J,tt.width,tt.height,1,vt,Lt,pt)}S.clearLayerUpdates()}else e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,tt.width,tt.height,tt.depth,vt,Lt,tt.data)}else e.texImage3D(s.TEXTURE_2D_ARRAY,0,Nt,tt.width,tt.height,tt.depth,0,vt,Lt,tt.data);else if(S.isData3DTexture)Xt?(ae&&e.texStorage3D(s.TEXTURE_3D,ht,Nt,tt.width,tt.height,tt.depth),D&&e.texSubImage3D(s.TEXTURE_3D,0,0,0,0,tt.width,tt.height,tt.depth,vt,Lt,tt.data)):e.texImage3D(s.TEXTURE_3D,0,Nt,tt.width,tt.height,tt.depth,0,vt,Lt,tt.data);else if(S.isFramebufferTexture){if(ae)if(Xt)e.texStorage2D(s.TEXTURE_2D,ht,Nt,tt.width,tt.height);else{let W=tt.width,J=tt.height;for(let pt=0;pt>=1,J>>=1}}else if(Zt.length>0){if(Xt&&ae){let W=gt(Zt[0]);e.texStorage2D(s.TEXTURE_2D,ht,Nt,W.width,W.height)}for(let W=0,J=Zt.length;W0&&ht++;let J=gt(vt[0]);e.texStorage2D(s.TEXTURE_CUBE_MAP,ht,Zt,J.width,J.height)}for(let J=0;J<6;J++)if(tt){Xt?D&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,0,0,vt[J].width,vt[J].height,Nt,yt,vt[J].data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,Zt,vt[J].width,vt[J].height,0,Nt,yt,vt[J].data);for(let pt=0;pt>q),Lt=Math.max(1,S.height>>q);Q===s.TEXTURE_3D||Q===s.TEXTURE_2D_ARRAY?e.texImage3D(Q,q,_t,vt,Lt,S.depth,0,Et,lt,null):e.texImage2D(Q,q,_t,vt,Lt,0,Et,lt,null)}e.bindFramebuffer(s.FRAMEBUFFER,w),xt(S)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,X,Q,tt.__webglTexture,0,j(S)):(Q===s.TEXTURE_2D||Q>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&Q<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,X,Q,tt.__webglTexture,q),e.bindFramebuffer(s.FRAMEBUFFER,null)}function rt(w,S,F){if(s.bindRenderbuffer(s.RENDERBUFFER,w),S.depthBuffer){let X=S.depthTexture,Q=X&&X.isDepthTexture?X.type:null,q=x(S.stencilBuffer,Q),Et=S.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,lt=j(S);xt(S)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,lt,q,S.width,S.height):F?s.renderbufferStorageMultisample(s.RENDERBUFFER,lt,q,S.width,S.height):s.renderbufferStorage(s.RENDERBUFFER,q,S.width,S.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,Et,s.RENDERBUFFER,w)}else{let X=S.textures;for(let Q=0;Q{delete S.__boundDepthTexture,delete S.__depthDisposeCallback,X.removeEventListener("dispose",Q)};X.addEventListener("dispose",Q),S.__depthDisposeCallback=Q}S.__boundDepthTexture=X}if(w.depthTexture&&!S.__autoAllocateDepthBuffer){if(F)throw new Error("target.depthTexture not supported in Cube render targets");It(S.__webglFramebuffer,w)}else if(F){S.__webglDepthbuffer=[];for(let X=0;X<6;X++)if(e.bindFramebuffer(s.FRAMEBUFFER,S.__webglFramebuffer[X]),S.__webglDepthbuffer[X]===void 0)S.__webglDepthbuffer[X]=s.createRenderbuffer(),rt(S.__webglDepthbuffer[X],w,!1);else{let Q=w.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,q=S.__webglDepthbuffer[X];s.bindRenderbuffer(s.RENDERBUFFER,q),s.framebufferRenderbuffer(s.FRAMEBUFFER,Q,s.RENDERBUFFER,q)}}else if(e.bindFramebuffer(s.FRAMEBUFFER,S.__webglFramebuffer),S.__webglDepthbuffer===void 0)S.__webglDepthbuffer=s.createRenderbuffer(),rt(S.__webglDepthbuffer,w,!1);else{let X=w.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Q=S.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,Q),s.framebufferRenderbuffer(s.FRAMEBUFFER,X,s.RENDERBUFFER,Q)}e.bindFramebuffer(s.FRAMEBUFFER,null)}function Dt(w,S,F){let X=n.get(w);S!==void 0&&bt(X.__webglFramebuffer,w,w.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),F!==void 0&&Ft(w)}function Jt(w){let S=w.texture,F=n.get(w),X=n.get(S);w.addEventListener("dispose",C);let Q=w.textures,q=w.isWebGLCubeRenderTarget===!0,Et=Q.length>1;if(Et||(X.__webglTexture===void 0&&(X.__webglTexture=s.createTexture()),X.__version=S.version,a.memory.textures++),q){F.__webglFramebuffer=[];for(let lt=0;lt<6;lt++)if(S.mipmaps&&S.mipmaps.length>0){F.__webglFramebuffer[lt]=[];for(let _t=0;_t0){F.__webglFramebuffer=[];for(let lt=0;lt0&&xt(w)===!1){F.__webglMultisampledFramebuffer=s.createFramebuffer(),F.__webglColorRenderbuffer=[],e.bindFramebuffer(s.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let lt=0;lt0)for(let _t=0;_t0)for(let _t=0;_t0){if(xt(w)===!1){let S=w.textures,F=w.width,X=w.height,Q=s.COLOR_BUFFER_BIT,q=w.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,Et=n.get(w),lt=S.length>1;if(lt)for(let _t=0;_t0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function at(w){let S=a.render.frame;h.get(w)!==S&&(h.set(w,S),w.update())}function Pt(w,S){let F=w.colorSpace,X=w.format,Q=w.type;return w.isCompressedTexture===!0||w.isVideoTexture===!0||F!==qi&&F!==Dn&&(Yt.getTransfer(F)===se?(X!==Oe||Q!==Mn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",F)),S}function gt(w){return typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement?(l.width=w.naturalWidth||w.width,l.height=w.naturalHeight||w.height):typeof VideoFrame<"u"&&w instanceof VideoFrame?(l.width=w.displayWidth,l.height=w.displayHeight):(l.width=w.width,l.height=w.height),l}this.allocateTextureUnit=O,this.resetTextureUnits=k,this.setTexture2D=Z,this.setTexture2DArray=H,this.setTexture3D=et,this.setTextureCube=G,this.rebindTextures=Dt,this.setupRenderTarget=Jt,this.updateRenderTargetMipmap=K,this.updateMultisampleRenderTarget=Ct,this.setupDepthRenderbuffer=Ft,this.setupFrameBufferTexture=bt,this.useMultisampledRTT=xt}function pp(s,t){function e(n,i=Dn){let r,a=Yt.getTransfer(i);if(n===Mn)return s.UNSIGNED_BYTE;if(n===Fc)return s.UNSIGNED_SHORT_4_4_4_4;if(n===Oc)return s.UNSIGNED_SHORT_5_5_5_1;if(n===hu)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===cu)return s.BYTE;if(n===lu)return s.SHORT;if(n===xs)return s.UNSIGNED_SHORT;if(n===Nc)return s.INT;if(n===Gn)return s.UNSIGNED_INT;if(n===Ge)return s.FLOAT;if(n===Ps)return s.HALF_FLOAT;if(n===uu)return s.ALPHA;if(n===du)return s.RGB;if(n===Oe)return s.RGBA;if(n===fu)return s.LUMINANCE;if(n===pu)return s.LUMINANCE_ALPHA;if(n===Ri)return s.DEPTH_COMPONENT;if(n===Di)return s.DEPTH_STENCIL;if(n===Bc)return s.RED;if(n===Wr)return s.RED_INTEGER;if(n===mu)return s.RG;if(n===zc)return s.RG_INTEGER;if(n===kc)return s.RGBA_INTEGER;if(n===Ks||n===Qs||n===js||n===tr)if(a===se)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Ks)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Qs)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===js)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===tr)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Ks)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Qs)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===js)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===tr)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Ja||n===$a||n===Ka||n===Qa)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Ja)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===$a)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Ka)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Qa)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ja||n===to||n===eo)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===ja||n===to)return a===se?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===eo)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===no||n===io||n===so||n===ro||n===ao||n===oo||n===co||n===lo||n===ho||n===uo||n===fo||n===po||n===mo||n===go)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===no)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===io)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===so)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===ro)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ao)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===oo)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===co)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===lo)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ho)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===uo)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===fo)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===po)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===mo)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===go)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===er||n===_o||n===xo)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===er)return a===se?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===_o)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===xo)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===gu||n===vo||n===yo||n===Mo)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===er)return r.COMPRESSED_RED_RGTC1_EXT;if(n===vo)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===yo)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Mo)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Li?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:e}}var Ao=class extends xe{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},ni=class extends Qt{constructor(){super(),this.isGroup=!0,this.type="Group"}},Av={type:"move"},ir=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ni,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 ni,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new A,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new A),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ni,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new A,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new A),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 i=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 _ of t.hand.values()){let g=e.getJointPose(_,n),p=this._getHandJoint(l,_);g!==null&&(p.matrix.fromArray(g.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=g.radius),p.visible=g!==null}let h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,m=.005;l.inputState.pinching&&d>f+m?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&d<=f-m&&(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&&(i=e.getPose(t.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Av)))}return o!==null&&(o.visible=i!==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 ni;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}},Cv=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,Rv=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`,eh=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){let i=new _e,r=t.properties.get(i);r.__webglTexture=e.texture,(e.depthNear!=n.depthNear||e.depthFar!=n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(t){if(this.texture!==null&&this.mesh===null){let e=t.cameras[0].viewport,n=new $e({vertexShader:Cv,fragmentShader:Rv,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new pe(new Es(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},nh=class extends sn{constructor(t,e){super();let n=this,i=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,m=null,_=new eh,g=e.getContextAttributes(),p=null,y=null,v=[],x=[],P=new $,T=null,C=new xe;C.viewport=new $t;let R=new xe;R.viewport=new $t;let b=[C,R],M=new Ao,L=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let it=v[Y];return it===void 0&&(it=new ir,v[Y]=it),it.getTargetRaySpace()},this.getControllerGrip=function(Y){let it=v[Y];return it===void 0&&(it=new ir,v[Y]=it),it.getGripSpace()},this.getHand=function(Y){let it=v[Y];return it===void 0&&(it=new ir,v[Y]=it),it.getHandSpace()};function O(Y){let it=x.indexOf(Y.inputSource);if(it===-1)return;let bt=v[it];bt!==void 0&&(bt.update(Y.inputSource,Y.frame,l||a),bt.dispatchEvent({type:Y.type,data:Y.inputSource}))}function V(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",V),i.removeEventListener("inputsourceschange",Z);for(let Y=0;Y=0&&(x[rt]=null,v[rt].disconnect(bt))}for(let it=0;it=x.length){x.push(bt),rt=Ft;break}else if(x[Ft]===null){x[Ft]=bt,rt=Ft;break}if(rt===-1)break}let It=v[rt];It&&It.connect(bt)}}let H=new A,et=new A;function G(Y,it,bt){H.setFromMatrixPosition(it.matrixWorld),et.setFromMatrixPosition(bt.matrixWorld);let rt=H.distanceTo(et),It=it.projectionMatrix.elements,Ft=bt.projectionMatrix.elements,Dt=It[14]/(It[10]-1),Jt=It[14]/(It[10]+1),K=(It[9]+1)/It[5],nt=(It[9]-1)/It[5],I=(It[8]-1)/It[0],Ct=(Ft[8]+1)/Ft[0],j=Dt*I,xt=Dt*Ct,at=rt/(-I+Ct),Pt=at*-I;if(it.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Pt),Y.translateZ(at),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),It[10]===-1)Y.projectionMatrix.copy(it.projectionMatrix),Y.projectionMatrixInverse.copy(it.projectionMatrixInverse);else{let gt=Dt+at,w=Jt+at,S=j-Pt,F=xt+(rt-Pt),X=K*Jt/w*gt,Q=nt*Jt/w*gt;Y.projectionMatrix.makePerspective(S,F,X,Q,gt,w),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function ot(Y,it){it===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(it.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(i===null)return;let it=Y.near,bt=Y.far;_.texture!==null&&(_.depthNear>0&&(it=_.depthNear),_.depthFar>0&&(bt=_.depthFar)),M.near=R.near=C.near=it,M.far=R.far=C.far=bt,(L!==M.near||k!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),L=M.near,k=M.far),C.layers.mask=Y.layers.mask|2,R.layers.mask=Y.layers.mask|4,M.layers.mask=C.layers.mask|R.layers.mask;let rt=Y.parent,It=M.cameras;ot(M,rt);for(let Ft=0;Ft0&&(g.alphaTest.value=p.alphaTest);let y=t.get(p),v=y.envMap,x=y.envMapRotation;v&&(g.envMap.value=v,pi.copy(x),pi.x*=-1,pi.y*=-1,pi.z*=-1,v.isCubeTexture&&v.isRenderTargetTexture===!1&&(pi.y*=-1,pi.z*=-1),g.envMapRotation.value.setFromMatrix4(Iv.makeRotationFromEuler(pi)),g.flipEnvMap.value=v.isCubeTexture&&v.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=p.reflectivity,g.ior.value=p.ior,g.refractionRatio.value=p.refractionRatio),p.lightMap&&(g.lightMap.value=p.lightMap,g.lightMapIntensity.value=p.lightMapIntensity,e(p.lightMap,g.lightMapTransform)),p.aoMap&&(g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity,e(p.aoMap,g.aoMapTransform))}function a(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,p.map&&(g.map.value=p.map,e(p.map,g.mapTransform))}function o(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function c(g,p,y,v){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*y,g.scale.value=v*.5,p.map&&(g.map.value=p.map,e(p.map,g.uvTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,e(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function l(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.rotation.value=p.rotation,p.map&&(g.map.value=p.map,e(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,e(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function h(g,p){g.specular.value.copy(p.specular),g.shininess.value=Math.max(p.shininess,1e-4)}function u(g,p){p.gradientMap&&(g.gradientMap.value=p.gradientMap)}function d(g,p){g.metalness.value=p.metalness,p.metalnessMap&&(g.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,g.metalnessMapTransform)),g.roughness.value=p.roughness,p.roughnessMap&&(g.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,g.roughnessMapTransform)),p.envMap&&(g.envMapIntensity.value=p.envMapIntensity)}function f(g,p,y){g.ior.value=p.ior,p.sheen>0&&(g.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),g.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(g.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,g.sheenColorMapTransform)),p.sheenRoughnessMap&&(g.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,g.sheenRoughnessMapTransform))),p.clearcoat>0&&(g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(g.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,g.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(g.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Be&&g.clearcoatNormalScale.value.negate())),p.dispersion>0&&(g.dispersion.value=p.dispersion),p.iridescence>0&&(g.iridescence.value=p.iridescence,g.iridescenceIOR.value=p.iridescenceIOR,g.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(g.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,g.iridescenceMapTransform)),p.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),p.transmission>0&&(g.transmission.value=p.transmission,g.transmissionSamplerMap.value=y.texture,g.transmissionSamplerSize.value.set(y.width,y.height),p.transmissionMap&&(g.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,g.transmissionMapTransform)),g.thickness.value=p.thickness,p.thicknessMap&&(g.thicknessMap.value=p.thicknessMap,e(p.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=p.attenuationDistance,g.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(g.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(g.anisotropyMap.value=p.anisotropyMap,e(p.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=p.specularIntensity,g.specularColor.value.copy(p.specularColor),p.specularColorMap&&(g.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,g.specularColorMapTransform)),p.specularIntensityMap&&(g.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,p){p.matcap&&(g.matcap.value=p.matcap)}function _(g,p){let y=t.get(p).light;g.referencePosition.value.setFromMatrixPosition(y.matrixWorld),g.nearDistance.value=y.shadow.camera.near,g.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function Lv(s,t,e,n){let i={},r={},a=[],o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function c(y,v){let x=v.program;n.uniformBlockBinding(y,x)}function l(y,v){let x=i[y.id];x===void 0&&(m(y),x=h(y),i[y.id]=x,y.addEventListener("dispose",g));let P=v.program;n.updateUBOMapping(y,P);let T=t.render.frame;r[y.id]!==T&&(d(y),r[y.id]=T)}function h(y){let v=u();y.__bindingPointIndex=v;let x=s.createBuffer(),P=y.__size,T=y.usage;return s.bindBuffer(s.UNIFORM_BUFFER,x),s.bufferData(s.UNIFORM_BUFFER,P,T),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,v,x),x}function u(){for(let y=0;y0&&(x+=P-T),y.__size=x,y.__cache={},this}function _(y){let v={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(v.boundary=4,v.storage=4):y.isVector2?(v.boundary=8,v.storage=8):y.isVector3||y.isColor?(v.boundary=16,v.storage=12):y.isVector4?(v.boundary=16,v.storage=16):y.isMatrix3?(v.boundary=48,v.storage=48):y.isMatrix4?(v.boundary=64,v.storage=64):y.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",y),v}function g(y){let v=y.target;v.removeEventListener("dispose",g);let x=a.indexOf(v.__bindingPointIndex);a.splice(x,1),s.deleteBuffer(i[v.id]),delete i[v.id],delete r[v.id]}function p(){for(let y in i)s.deleteBuffer(i[y]);a=[],i={},r={}}return{bind:c,update:l,dispose:p}}var ih=class{constructor(t={}){let{canvas:e=rp(),context:n=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reverseDepthBuffer:d=!1}=t;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");f=n.getContextAttributes().alpha}else f=a;let m=new Uint32Array(4),_=new Int32Array(4),g=null,p=null,y=[],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=He,this.toneMapping=Bn,this.toneMappingExposure=1;let x=this,P=!1,T=0,C=0,R=null,b=-1,M=null,L=new $t,k=new $t,O=null,V=new ut(0),Z=0,H=e.width,et=e.height,G=1,ot=null,mt=null,St=new $t(0,0,H,et),zt=new $t(0,0,H,et),jt=!1,Y=new Fi,it=!1,bt=!1,rt=new Ut,It=new Ut,Ft=new A,Dt=new $t,Jt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},K=!1;function nt(){return R===null?G:1}let I=n;function Ct(E,U){return e.getContext(E,U)}try{let E={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine","three.js r170"),e.addEventListener("webglcontextlost",J,!1),e.addEventListener("webglcontextrestored",pt,!1),e.addEventListener("webglcontextcreationerror",dt,!1),I===null){let U="webgl2";if(I=Ct(U,E),I===null)throw Ct(U)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(E){throw console.error("THREE.WebGLRenderer: "+E.message),E}let j,xt,at,Pt,gt,w,S,F,X,Q,q,Et,lt,_t,qt,tt,vt,Lt,Nt,yt,Zt,Xt,ae,D;function ht(){j=new X0(I),j.init(),Xt=new pp(I,j),xt=new z0(I,j,t,Xt),at=new yv(I,j),xt.reverseDepthBuffer&&d&&at.buffers.depth.setReversed(!0),Pt=new Z0(I),gt=new ov,w=new wv(I,j,at,gt,xt,Xt,Pt),S=new V0(x),F=new W0(x),X=new eg(I),ae=new O0(I,X),Q=new q0(I,X,Pt,ae),q=new $0(I,Q,X,Pt),Nt=new J0(I,xt,w),tt=new k0(gt),Et=new av(x,S,F,j,xt,ae,tt),lt=new Pv(x,gt),_t=new lv,qt=new mv(j),Lt=new F0(x,S,F,at,q,f,c),vt=new xv(x,q,xt),D=new Lv(I,Pt,xt,at),yt=new B0(I,j,Pt),Zt=new Y0(I,j,Pt),Pt.programs=Et.programs,x.capabilities=xt,x.extensions=j,x.properties=gt,x.renderLists=_t,x.shadowMap=vt,x.state=at,x.info=Pt}ht();let W=new nh(x,I);this.xr=W,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){let E=j.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){let E=j.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return G},this.setPixelRatio=function(E){E!==void 0&&(G=E,this.setSize(H,et,!1))},this.getSize=function(E){return E.set(H,et)},this.setSize=function(E,U,B=!0){if(W.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}H=E,et=U,e.width=Math.floor(E*G),e.height=Math.floor(U*G),B===!0&&(e.style.width=E+"px",e.style.height=U+"px"),this.setViewport(0,0,E,U)},this.getDrawingBufferSize=function(E){return E.set(H*G,et*G).floor()},this.setDrawingBufferSize=function(E,U,B){H=E,et=U,G=B,e.width=Math.floor(E*B),e.height=Math.floor(U*B),this.setViewport(0,0,E,U)},this.getCurrentViewport=function(E){return E.copy(L)},this.getViewport=function(E){return E.copy(St)},this.setViewport=function(E,U,B,z){E.isVector4?St.set(E.x,E.y,E.z,E.w):St.set(E,U,B,z),at.viewport(L.copy(St).multiplyScalar(G).round())},this.getScissor=function(E){return E.copy(zt)},this.setScissor=function(E,U,B,z){E.isVector4?zt.set(E.x,E.y,E.z,E.w):zt.set(E,U,B,z),at.scissor(k.copy(zt).multiplyScalar(G).round())},this.getScissorTest=function(){return jt},this.setScissorTest=function(E){at.setScissorTest(jt=E)},this.setOpaqueSort=function(E){ot=E},this.setTransparentSort=function(E){mt=E},this.getClearColor=function(E){return E.copy(Lt.getClearColor())},this.setClearColor=function(){Lt.setClearColor.apply(Lt,arguments)},this.getClearAlpha=function(){return Lt.getClearAlpha()},this.setClearAlpha=function(){Lt.setClearAlpha.apply(Lt,arguments)},this.clear=function(E=!0,U=!0,B=!0){let z=0;if(E){let N=!1;if(R!==null){let st=R.texture.format;N=st===kc||st===zc||st===Wr}if(N){let st=R.texture.type,ft=st===Mn||st===Gn||st===xs||st===Li||st===Fc||st===Oc,Tt=Lt.getClearColor(),wt=Lt.getClearAlpha(),Ot=Tt.r,Ht=Tt.g,At=Tt.b;ft?(m[0]=Ot,m[1]=Ht,m[2]=At,m[3]=wt,I.clearBufferuiv(I.COLOR,0,m)):(_[0]=Ot,_[1]=Ht,_[2]=At,_[3]=wt,I.clearBufferiv(I.COLOR,0,_))}else z|=I.COLOR_BUFFER_BIT}U&&(z|=I.DEPTH_BUFFER_BIT),B&&(z|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),I.clear(z)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",J,!1),e.removeEventListener("webglcontextrestored",pt,!1),e.removeEventListener("webglcontextcreationerror",dt,!1),_t.dispose(),qt.dispose(),gt.dispose(),S.dispose(),F.dispose(),q.dispose(),ae.dispose(),D.dispose(),Et.dispose(),W.dispose(),W.removeEventListener("sessionstart",Tu),W.removeEventListener("sessionend",wu),ci.stop()};function J(E){E.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),P=!0}function pt(){console.log("THREE.WebGLRenderer: Context Restored."),P=!1;let E=Pt.autoReset,U=vt.enabled,B=vt.autoUpdate,z=vt.needsUpdate,N=vt.type;ht(),Pt.autoReset=E,vt.enabled=U,vt.autoUpdate=B,vt.needsUpdate=z,vt.type=N}function dt(E){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function Vt(E){let U=E.target;U.removeEventListener("dispose",Vt),ue(U)}function ue(E){Ce(E),gt.remove(E)}function Ce(E){let U=gt.get(E).programs;U!==void 0&&(U.forEach(function(B){Et.releaseProgram(B)}),E.isShaderMaterial&&Et.releaseShaderCache(E))}this.renderBufferDirect=function(E,U,B,z,N,st){U===null&&(U=Jt);let ft=N.isMesh&&N.matrixWorld.determinant()<0,Tt=bp(E,U,B,z,N);at.setMaterial(z,ft);let wt=B.index,Ot=1;if(z.wireframe===!0){if(wt=Q.getWireframeAttribute(B),wt===void 0)return;Ot=2}let Ht=B.drawRange,At=B.attributes.position,Kt=Ht.start*Ot,oe=(Ht.start+Ht.count)*Ot;st!==null&&(Kt=Math.max(Kt,st.start*Ot),oe=Math.min(oe,(st.start+st.count)*Ot)),wt!==null?(Kt=Math.max(Kt,0),oe=Math.min(oe,wt.count)):At!=null&&(Kt=Math.max(Kt,0),oe=Math.min(oe,At.count));let ce=oe-Kt;if(ce<0||ce===1/0)return;ae.setup(N,z,Tt,B,wt);let ze,te=yt;if(wt!==null&&(ze=X.get(wt),te=Zt,te.setIndex(ze)),N.isMesh)z.wireframe===!0?(at.setLineWidth(z.wireframeLinewidth*nt()),te.setMode(I.LINES)):te.setMode(I.TRIANGLES);else if(N.isLine){let Rt=z.linewidth;Rt===void 0&&(Rt=1),at.setLineWidth(Rt*nt()),N.isLineSegments?te.setMode(I.LINES):N.isLineLoop?te.setMode(I.LINE_LOOP):te.setMode(I.LINE_STRIP)}else N.isPoints?te.setMode(I.POINTS):N.isSprite&&te.setMode(I.TRIANGLES);if(N.isBatchedMesh)if(N._multiDrawInstances!==null)te.renderMultiDrawInstances(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount,N._multiDrawInstances);else if(j.get("WEBGL_multi_draw"))te.renderMultiDraw(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount);else{let Rt=N._multiDrawStarts,wn=N._multiDrawCounts,ee=N._multiDrawCount,on=wt?X.get(wt).bytesPerElement:1,Yi=gt.get(z).currentProgram.getUniforms();for(let We=0;We{function st(){if(z.forEach(function(ft){gt.get(ft).currentProgram.isReady()&&z.delete(ft)}),z.size===0){N(E);return}setTimeout(st,10)}j.get("KHR_parallel_shader_compile")!==null?st():setTimeout(st,10)})};let an=null;function Tn(E){an&&an(E)}function Tu(){ci.stop()}function wu(){ci.start()}let ci=new lp;ci.setAnimationLoop(Tn),typeof self<"u"&&ci.setContext(self),this.setAnimationLoop=function(E){an=E,W.setAnimationLoop(E),E===null?ci.stop():ci.start()},W.addEventListener("sessionstart",Tu),W.addEventListener("sessionend",wu),this.render=function(E,U){if(U!==void 0&&U.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(P===!0)return;if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),W.enabled===!0&&W.isPresenting===!0&&(W.cameraAutoUpdate===!0&&W.updateCamera(U),U=W.getCamera()),E.isScene===!0&&E.onBeforeRender(x,E,U,R),p=qt.get(E,v.length),p.init(U),v.push(p),It.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Y.setFromProjectionMatrix(It),bt=this.localClippingEnabled,it=tt.init(this.clippingPlanes,bt),g=_t.get(E,y.length),g.init(),y.push(g),W.enabled===!0&&W.isPresenting===!0){let st=x.xr.getDepthSensingMesh();st!==null&&Wc(st,U,-1/0,x.sortObjects)}Wc(E,U,0,x.sortObjects),g.finish(),x.sortObjects===!0&&g.sort(ot,mt),K=W.enabled===!1||W.isPresenting===!1||W.hasDepthSensing()===!1,K&&Lt.addToRenderList(g,E),this.info.render.frame++,it===!0&&tt.beginShadows();let B=p.state.shadowsArray;vt.render(B,E,U),it===!0&&tt.endShadows(),this.info.autoReset===!0&&this.info.reset();let z=g.opaque,N=g.transmissive;if(p.setupLights(),U.isArrayCamera){let st=U.cameras;if(N.length>0)for(let ft=0,Tt=st.length;ft0&&Cu(z,N,E,U),K&&Lt.render(E),Au(g,E,U);R!==null&&(w.updateMultisampleRenderTarget(R),w.updateRenderTargetMipmap(R)),E.isScene===!0&&E.onAfterRender(x,E,U),ae.resetDefaultState(),b=-1,M=null,v.pop(),v.length>0?(p=v[v.length-1],it===!0&&tt.setGlobalState(x.clippingPlanes,p.state.camera)):p=null,y.pop(),y.length>0?g=y[y.length-1]:g=null};function Wc(E,U,B,z){if(E.visible===!1)return;if(E.layers.test(U.layers)){if(E.isGroup)B=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(U);else if(E.isLight)p.pushLight(E),E.castShadow&&p.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||Y.intersectsSprite(E)){z&&Dt.setFromMatrixPosition(E.matrixWorld).applyMatrix4(It);let ft=q.update(E),Tt=E.material;Tt.visible&&g.push(E,ft,Tt,B,Dt.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||Y.intersectsObject(E))){let ft=q.update(E),Tt=E.material;if(z&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),Dt.copy(E.boundingSphere.center)):(ft.boundingSphere===null&&ft.computeBoundingSphere(),Dt.copy(ft.boundingSphere.center)),Dt.applyMatrix4(E.matrixWorld).applyMatrix4(It)),Array.isArray(Tt)){let wt=ft.groups;for(let Ot=0,Ht=wt.length;Ot0&&qr(N,U,B),st.length>0&&qr(st,U,B),ft.length>0&&qr(ft,U,B),at.buffers.depth.setTest(!0),at.buffers.depth.setMask(!0),at.buffers.color.setMask(!0),at.setPolygonOffset(!1)}function Cu(E,U,B,z){if((B.isScene===!0?B.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[z.id]===void 0&&(p.state.transmissionRenderTarget[z.id]=new Ze(1,1,{generateMipmaps:!0,type:j.has("EXT_color_buffer_half_float")||j.has("EXT_color_buffer_float")?Ps:Mn,minFilter:xn,samples:4,stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Yt.workingColorSpace}));let st=p.state.transmissionRenderTarget[z.id],ft=z.viewport||L;st.setSize(ft.z,ft.w);let Tt=x.getRenderTarget();x.setRenderTarget(st),x.getClearColor(V),Z=x.getClearAlpha(),Z<1&&x.setClearColor(16777215,.5),x.clear(),K&&Lt.render(B);let wt=x.toneMapping;x.toneMapping=Bn;let Ot=z.viewport;if(z.viewport!==void 0&&(z.viewport=void 0),p.setupLightsView(z),it===!0&&tt.setGlobalState(x.clippingPlanes,z),qr(E,B,z),w.updateMultisampleRenderTarget(st),w.updateRenderTargetMipmap(st),j.has("WEBGL_multisampled_render_to_texture")===!1){let Ht=!1;for(let At=0,Kt=U.length;At0),At=!!B.morphAttributes.position,Kt=!!B.morphAttributes.normal,oe=!!B.morphAttributes.color,ce=Bn;z.toneMapped&&(R===null||R.isXRRenderTarget===!0)&&(ce=x.toneMapping);let ze=B.morphAttributes.position||B.morphAttributes.normal||B.morphAttributes.color,te=ze!==void 0?ze.length:0,Rt=gt.get(z),wn=p.state.lights;if(it===!0&&(bt===!0||E!==M)){let je=E===M&&z.id===b;tt.setState(z,E,je)}let ee=!1;z.version===Rt.__version?(Rt.needsLights&&Rt.lightsStateVersion!==wn.state.version||Rt.outputColorSpace!==Tt||N.isBatchedMesh&&Rt.batching===!1||!N.isBatchedMesh&&Rt.batching===!0||N.isBatchedMesh&&Rt.batchingColor===!0&&N.colorTexture===null||N.isBatchedMesh&&Rt.batchingColor===!1&&N.colorTexture!==null||N.isInstancedMesh&&Rt.instancing===!1||!N.isInstancedMesh&&Rt.instancing===!0||N.isSkinnedMesh&&Rt.skinning===!1||!N.isSkinnedMesh&&Rt.skinning===!0||N.isInstancedMesh&&Rt.instancingColor===!0&&N.instanceColor===null||N.isInstancedMesh&&Rt.instancingColor===!1&&N.instanceColor!==null||N.isInstancedMesh&&Rt.instancingMorph===!0&&N.morphTexture===null||N.isInstancedMesh&&Rt.instancingMorph===!1&&N.morphTexture!==null||Rt.envMap!==wt||z.fog===!0&&Rt.fog!==st||Rt.numClippingPlanes!==void 0&&(Rt.numClippingPlanes!==tt.numPlanes||Rt.numIntersection!==tt.numIntersection)||Rt.vertexAlphas!==Ot||Rt.vertexTangents!==Ht||Rt.morphTargets!==At||Rt.morphNormals!==Kt||Rt.morphColors!==oe||Rt.toneMapping!==ce||Rt.morphTargetsCount!==te)&&(ee=!0):(ee=!0,Rt.__version=z.version);let on=Rt.currentProgram;ee===!0&&(on=Yr(z,U,N));let Yi=!1,We=!1,Ds=!1,le=on.getUniforms(),fn=Rt.uniforms;if(at.useProgram(on.program)&&(Yi=!0,We=!0,Ds=!0),z.id!==b&&(b=z.id,We=!0),Yi||M!==E){at.buffers.depth.getReversed()?(rt.copy(E.projectionMatrix),Um(rt),Nm(rt),le.setValue(I,"projectionMatrix",rt)):le.setValue(I,"projectionMatrix",E.projectionMatrix),le.setValue(I,"viewMatrix",E.matrixWorldInverse);let qn=le.map.cameraPosition;qn!==void 0&&qn.setValue(I,Ft.setFromMatrixPosition(E.matrixWorld)),xt.logarithmicDepthBuffer&&le.setValue(I,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&&le.setValue(I,"isOrthographic",E.isOrthographicCamera===!0),M!==E&&(M=E,We=!0,Ds=!0)}if(N.isSkinnedMesh){le.setOptional(I,N,"bindMatrix"),le.setOptional(I,N,"bindMatrixInverse");let je=N.skeleton;je&&(je.boneTexture===null&&je.computeBoneTexture(),le.setValue(I,"boneTexture",je.boneTexture,w))}N.isBatchedMesh&&(le.setOptional(I,N,"batchingTexture"),le.setValue(I,"batchingTexture",N._matricesTexture,w),le.setOptional(I,N,"batchingIdTexture"),le.setValue(I,"batchingIdTexture",N._indirectTexture,w),le.setOptional(I,N,"batchingColorTexture"),N._colorsTexture!==null&&le.setValue(I,"batchingColorTexture",N._colorsTexture,w));let Us=B.morphAttributes;if((Us.position!==void 0||Us.normal!==void 0||Us.color!==void 0)&&Nt.update(N,B,on),(We||Rt.receiveShadow!==N.receiveShadow)&&(Rt.receiveShadow=N.receiveShadow,le.setValue(I,"receiveShadow",N.receiveShadow)),z.isMeshGouraudMaterial&&z.envMap!==null&&(fn.envMap.value=wt,fn.flipEnvMap.value=wt.isCubeTexture&&wt.isRenderTargetTexture===!1?-1:1),z.isMeshStandardMaterial&&z.envMap===null&&U.environment!==null&&(fn.envMapIntensity.value=U.environmentIntensity),We&&(le.setValue(I,"toneMappingExposure",x.toneMappingExposure),Rt.needsLights&&Ep(fn,Ds),st&&z.fog===!0&<.refreshFogUniforms(fn,st),lt.refreshMaterialUniforms(fn,z,G,et,p.state.transmissionRenderTarget[E.id]),_s.upload(I,Iu(Rt),fn,w)),z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(_s.upload(I,Iu(Rt),fn,w),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&&le.setValue(I,"center",N.center),le.setValue(I,"modelViewMatrix",N.modelViewMatrix),le.setValue(I,"normalMatrix",N.normalMatrix),le.setValue(I,"modelMatrix",N.matrixWorld),z.isShaderMaterial||z.isRawShaderMaterial){let je=z.uniformsGroups;for(let qn=0,Yn=je.length;qn0&&w.useMultisampledRTT(E)===!1?N=gt.get(E).__webglMultisampledFramebuffer:Array.isArray(Ht)?N=Ht[B]:N=Ht,L.copy(E.viewport),k.copy(E.scissor),O=E.scissorTest}else L.copy(St).multiplyScalar(G).floor(),k.copy(zt).multiplyScalar(G).floor(),O=jt;if(at.bindFramebuffer(I.FRAMEBUFFER,N)&&z&&at.drawBuffers(E,N),at.viewport(L),at.scissor(k),at.setScissorTest(O),st){let wt=gt.get(E.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+U,wt.__webglTexture,B)}else if(ft){let wt=gt.get(E.texture),Ot=U||0;I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,wt.__webglTexture,B||0,Ot)}b=-1},this.readRenderTargetPixels=function(E,U,B,z,N,st,ft){if(!(E&&E.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Tt=gt.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&ft!==void 0&&(Tt=Tt[ft]),Tt){at.bindFramebuffer(I.FRAMEBUFFER,Tt);try{let wt=E.texture,Ot=wt.format,Ht=wt.type;if(!xt.textureFormatReadable(Ot)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!xt.textureTypeReadable(Ht)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=E.width-z&&B>=0&&B<=E.height-N&&I.readPixels(U,B,z,N,Xt.convert(Ot),Xt.convert(Ht),st)}finally{let wt=R!==null?gt.get(R).__webglFramebuffer:null;at.bindFramebuffer(I.FRAMEBUFFER,wt)}}},this.readRenderTargetPixelsAsync=async function(E,U,B,z,N,st,ft){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Tt=gt.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&ft!==void 0&&(Tt=Tt[ft]),Tt){let wt=E.texture,Ot=wt.format,Ht=wt.type;if(!xt.textureFormatReadable(Ot))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!xt.textureTypeReadable(Ht))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(U>=0&&U<=E.width-z&&B>=0&&B<=E.height-N){at.bindFramebuffer(I.FRAMEBUFFER,Tt);let At=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,At),I.bufferData(I.PIXEL_PACK_BUFFER,st.byteLength,I.STREAM_READ),I.readPixels(U,B,z,N,Xt.convert(Ot),Xt.convert(Ht),0);let Kt=R!==null?gt.get(R).__webglFramebuffer:null;at.bindFramebuffer(I.FRAMEBUFFER,Kt);let oe=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await Dm(I,oe,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,At),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,st),I.deleteBuffer(At),I.deleteSync(oe),st}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(E,U=null,B=0){E.isTexture!==!0&&(Ys("WebGLRenderer: copyFramebufferToTexture function signature has changed."),U=arguments[0]||null,E=arguments[1]);let z=Math.pow(2,-B),N=Math.floor(E.image.width*z),st=Math.floor(E.image.height*z),ft=U!==null?U.x:0,Tt=U!==null?U.y:0;w.setTexture2D(E,0),I.copyTexSubImage2D(I.TEXTURE_2D,B,0,0,ft,Tt,N,st),at.unbindTexture()},this.copyTextureToTexture=function(E,U,B=null,z=null,N=0){E.isTexture!==!0&&(Ys("WebGLRenderer: copyTextureToTexture function signature has changed."),z=arguments[0]||null,E=arguments[1],U=arguments[2],N=arguments[3]||0,B=null);let st,ft,Tt,wt,Ot,Ht,At,Kt,oe,ce=E.isCompressedTexture?E.mipmaps[N]:E.image;B!==null?(st=B.max.x-B.min.x,ft=B.max.y-B.min.y,Tt=B.isBox3?B.max.z-B.min.z:1,wt=B.min.x,Ot=B.min.y,Ht=B.isBox3?B.min.z:0):(st=ce.width,ft=ce.height,Tt=ce.depth||1,wt=0,Ot=0,Ht=0),z!==null?(At=z.x,Kt=z.y,oe=z.z):(At=0,Kt=0,oe=0);let ze=Xt.convert(U.format),te=Xt.convert(U.type),Rt;U.isData3DTexture?(w.setTexture3D(U,0),Rt=I.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?(w.setTexture2DArray(U,0),Rt=I.TEXTURE_2D_ARRAY):(w.setTexture2D(U,0),Rt=I.TEXTURE_2D),I.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,U.flipY),I.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),I.pixelStorei(I.UNPACK_ALIGNMENT,U.unpackAlignment);let wn=I.getParameter(I.UNPACK_ROW_LENGTH),ee=I.getParameter(I.UNPACK_IMAGE_HEIGHT),on=I.getParameter(I.UNPACK_SKIP_PIXELS),Yi=I.getParameter(I.UNPACK_SKIP_ROWS),We=I.getParameter(I.UNPACK_SKIP_IMAGES);I.pixelStorei(I.UNPACK_ROW_LENGTH,ce.width),I.pixelStorei(I.UNPACK_IMAGE_HEIGHT,ce.height),I.pixelStorei(I.UNPACK_SKIP_PIXELS,wt),I.pixelStorei(I.UNPACK_SKIP_ROWS,Ot),I.pixelStorei(I.UNPACK_SKIP_IMAGES,Ht);let Ds=E.isDataArrayTexture||E.isData3DTexture,le=U.isDataArrayTexture||U.isData3DTexture;if(E.isRenderTargetTexture||E.isDepthTexture){let fn=gt.get(E),Us=gt.get(U),je=gt.get(fn.__renderTarget),qn=gt.get(Us.__renderTarget);at.bindFramebuffer(I.READ_FRAMEBUFFER,je.__webglFramebuffer),at.bindFramebuffer(I.DRAW_FRAMEBUFFER,qn.__webglFramebuffer);for(let Yn=0;Yn0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}},ws=class{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=dr,this.updateRanges=[],this.version=0,this.uuid=Ye()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;it.far||e.push({distance:c,point:zs.clone(),uv:_n.getInterpolation(zs,pa,Vs,ma,bd,xl,Ed,new $),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}};function ga(s,t,e,n,i,r){hs.subVectors(s,e).addScalar(.5).multiply(n),i!==void 0?(ks.x=r*hs.x-i*hs.y,ks.y=i*hs.x+r*hs.y):ks.copy(hs),s.copy(t),s.x+=ks.x,s.y+=ks.y,s.applyMatrix4(mp)}var _a=new A,Td=new A,Lo=class extends Qt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);let e=t.levels;for(let n=0,i=e.length;n0){let n,i;for(n=1,i=e.length;n0){_a.setFromMatrixPosition(this.matrixWorld);let i=t.ray.origin.distanceTo(_a);this.getObjectForDistance(i).raycast(t,e)}}update(t){let e=this.levels;if(e.length>1){_a.setFromMatrixPosition(t.matrixWorld),Td.setFromMatrixPosition(this.matrixWorld);let n=_a.distanceTo(Td)/t.zoom;e[0].object.visible=!0;let i,r;for(i=1,r=e.length;i=a)e[i-1].object.visible=!1,e[i].object.visible=!0;else break}for(this._currentLevel=i-1;i=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});let o=r[this.index];a.push(o),this.index++,o.start=t,o.count=e,o.z=n,o.index=i}reset(){this.list.length=0,this.index=0}},ke=new Ut,Bv=new ut(1,1,1),Sl=new Fi,ya=new we,mi=new be,Ws=new A,Ud=new A,zv=new A,bl=new sh,Pe=new pe,Ma=[];function kv(s,t,e=0){let n=t.itemSize;if(s.isInterleavedBufferAttribute||s.array.constructor!==t.array.constructor){let i=s.count;for(let r=0;r65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new ne(r,1))}this._geometryInitialized=!0}}_validateGeometry(t){let e=this.geometry;if(!!t.getIndex()!=!!e.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(let n in e.attributes){if(!t.hasAttribute(n))throw new Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let i=t.getAttribute(n),r=e.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new we);let t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let n=0,i=e.length;n=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("BatchedMesh: Maximum item count reached.");let n={visible:!0,active:!0,geometryIndex:t},i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Ml),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=n):(i=this._instanceInfo.length,this._instanceInfo.push(n));let r=this._matricesTexture;ke.identity().toArray(r.image.data,i*16),r.needsUpdate=!0;let a=this._colorsTexture;return a&&(Bv.toArray(a.image.data,i*4),a.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(t,e=-1,n=-1){this._initializeGeometry(t),this._validateGeometry(t);let i={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},r=this._geometryInfo;i.vertexStart=this._nextVertexStart,i.reservedVertexCount=e===-1?t.getAttribute("position").count:e;let a=t.getIndex();if(a!==null&&(i.indexStart=this._nextIndexStart,i.reservedIndexCount=n===-1?a.count:n),i.indexStart!==-1&&i.indexStart+i.reservedIndexCount>this._maxIndexCount||i.vertexStart+i.reservedVertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");let c;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Ml),c=this._availableGeometryIds.shift(),r[c]=i):(c=this._geometryCount,this._geometryCount++,r.push(i)),this.setGeometryAt(c,t),this._nextIndexStart=i.indexStart+i.reservedIndexCount,this._nextVertexStart=i.vertexStart+i.reservedVertexCount,c}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);let n=this.geometry,i=n.getIndex()!==null,r=n.getIndex(),a=e.getIndex(),o=this._geometryInfo[t];if(i&&a.count>o.reservedIndexCount||e.attributes.position.count>o.reservedVertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");let c=o.vertexStart,l=o.reservedVertexCount;o.vertexCount=e.getAttribute("position").count;for(let h in n.attributes){let u=e.getAttribute(h),d=n.getAttribute(h);kv(u,d,c);let f=u.itemSize;for(let m=u.count,_=l;m<_;m++){let g=c+m;for(let p=0;p=e.length||e[t].active===!1)return this;let n=this._instanceInfo;for(let i=0,r=n.length;i=e.length||e[t].active===!1?this:(e[t].active=!1,this._availableInstanceIds.push(t),this._visibilityChanged=!0,this)}optimize(){let t=0,e=0,n=this._geometryInfo,i=n.map((a,o)=>o).sort((a,o)=>n[a].vertexStart-n[o].vertexStart),r=this.geometry;for(let a=0,o=n.length;a=this._geometryCount)return null;let n=this.geometry,i=this._geometryInfo[t];if(i.boundingBox===null){let r=new we,a=n.index,o=n.attributes.position;for(let c=i.start,l=i.start+i.count;c=this._geometryCount)return null;let n=this.geometry,i=this._geometryInfo[t];if(i.boundingSphere===null){let r=new be;this.getBoundingBoxAt(t,ya),ya.getCenter(r.center);let a=n.index,o=n.attributes.position,c=0;for(let l=i.start,h=i.start+i.count;l=n.length||n[t].active===!1?this:(e.toArray(r,t*16),i.needsUpdate=!0,this)}getMatrixAt(t,e){let n=this._instanceInfo,i=this._matricesTexture.image.data;return t>=n.length||n[t].active===!1?null:e.fromArray(i,t*16)}setColorAt(t,e){this._colorsTexture===null&&this._initColorsTexture();let n=this._colorsTexture,i=this._colorsTexture.image.data,r=this._instanceInfo;return t>=r.length||r[t].active===!1?this:(e.toArray(i,t*4),n.needsUpdate=!0,this)}getColorAt(t,e){let n=this._colorsTexture.image.data,i=this._instanceInfo;return t>=i.length||i[t].active===!1?null:e.fromArray(n,t*4)}setVisibleAt(t,e){let n=this._instanceInfo;return t>=n.length||n[t].active===!1||n[t].visible===e?this:(n[t].visible=e,this._visibilityChanged=!0,this)}getVisibleAt(t){let e=this._instanceInfo;return t>=e.length||e[t].active===!1?!1:e[t].visible}setGeometryIdAt(t,e){let n=this._instanceInfo,i=this._geometryInfo;return t>=n.length||n[t].active===!1||e>=i.length||i[e].active===!1?null:(n[t].geometryIndex=e,this)}getGeometryIdAt(t){let e=this._instanceInfo;return t>=e.length||e[t].active===!1?-1:e[t].geometryIndex}getGeometryRangeAt(t,e={}){if(t<0||t>=this._geometryCount)return null;let n=this._geometryInfo[t];return e.vertexStart=n.vertexStart,e.vertexCount=n.vertexCount,e.reservedVertexCount=n.reservedVertexCount,e.indexStart=n.indexStart,e.indexCount=n.indexCount,e.reservedIndexCount=n.reservedIndexCount,e.start=n.start,e.count=n.count,e}setInstanceCount(t){let e=this._availableInstanceIds,n=this._instanceInfo;for(e.sort(Ml);e[e.length-1]===n.length;)n.pop(),e.pop();if(to.active);if(Math.max(...n.map(o=>o.vertexStart+o.reservedVertexCount))>t)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(c=>c.indexStart+c.reservedIndexCount))>e)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`);let r=this.geometry;r.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Wt,this._initializeGeometry(r));let a=this.geometry;r.index&&gi(r.index.array,a.index.array);for(let o in r.attributes)gi(r.attributes[o].array,a.attributes[o].array)}raycast(t,e){let n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,a=this.geometry;Pe.material=this.material,Pe.geometry.index=a.index,Pe.geometry.attributes=a.attributes,Pe.geometry.boundingBox===null&&(Pe.geometry.boundingBox=new we),Pe.geometry.boundingSphere===null&&(Pe.geometry.boundingSphere=new be);for(let o=0,c=n.length;o({...e,boundingBox:e.boundingBox!==null?e.boundingBox.clone():null,boundingSphere:e.boundingSphere!==null?e.boundingSphere.clone():null})),this._instanceInfo=t._instanceInfo.map(e=>({...e})),this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(t,e,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let a=i.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,c=this._instanceInfo,l=this._multiDrawStarts,h=this._multiDrawCounts,u=this._geometryInfo,d=this.perObjectFrustumCulled,f=this._indirectTexture,m=f.image.data;d&&(ke.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),Sl.setFromProjectionMatrix(ke,t.coordinateSystem));let _=0;if(this.sortObjects){ke.copy(this.matrixWorld).invert(),Ws.setFromMatrixPosition(n.matrixWorld).applyMatrix4(ke),Ud.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(ke);for(let y=0,v=c.length;y0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;rn)return;El.applyMatrix4(s.matrixWorld);let c=t.ray.origin.distanceTo(El);if(!(ct.far))return{distance:c,point:Fd.clone().applyMatrix4(s.matrixWorld),index:i,face:null,faceIndex:null,barycoord:null,object:s}}var Od=new A,Bd=new A,rn=class extends bn{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(t.index===null){let e=t.attributes.position,n=[];for(let i=0,r=e.count;i0){let i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;ri.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}var ah=class extends _e{constructor(t,e,n,i,r,a,o,c,l){super(t,e,n,i,r,a,o,c,l),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:ve,this.magFilter=r!==void 0?r:ve,this.generateMipmaps=!1;let h=this;function u(){h.needsUpdate=!0,t.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},oh=class extends _e{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=Te,this.minFilter=Te,this.generateMipmaps=!1,this.needsUpdate=!0}},As=class extends _e{constructor(t,e,n,i,r,a,o,c,l,h,u,d){super(null,a,o,c,l,h,i,r,u,d),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}},ch=class extends As{constructor(t,e,n,i,r,a){super(t,e,n,r,a),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=en,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}},lh=class extends As{constructor(t,e,n){super(void 0,t[0].width,t[0].height,e,n,Hn),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}},hh=class extends _e{constructor(t,e,n,i,r,a,o,c,l){super(t,e,n,i,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Ke=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){let n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){let e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){let t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let e=[],n,i=this.getPoint(0),r=0;e.push(0);for(let a=1;a<=t;a++)n=this.getPoint(a/t),r+=n.distanceTo(i),e.push(r),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){let n=this.getLengths(),i=0,r=n.length,a;e?a=e:a=t*n[r-1];let o=0,c=r-1,l;for(;o<=c;)if(i=Math.floor(o+(c-o)/2),l=n[i]-a,l<0)o=i+1;else if(l>0)c=i-1;else{c=i;break}if(i=c,n[i]===a)return i/(r-1);let h=n[i],d=n[i+1]-h,f=(a-h)/d;return(i+f)/(r-1)}getTangent(t,e){let i=t-1e-4,r=t+1e-4;i<0&&(i=0),r>1&&(r=1);let a=this.getPoint(i),o=this.getPoint(r),c=e||(a.isVector2?new $:new A);return c.copy(o).sub(a).normalize(),c}getTangentAt(t,e){let n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){let n=new A,i=[],r=[],a=[],o=new A,c=new Ut;for(let f=0;f<=t;f++){let m=f/t;i[f]=this.getTangentAt(m,new A)}r[0]=new A,a[0]=new A;let l=Number.MAX_VALUE,h=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);h<=l&&(l=h,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),d<=l&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],o),a[0].crossVectors(i[0],r[0]);for(let f=1;f<=t;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(i[f-1],i[f]),o.length()>Number.EPSILON){o.normalize();let m=Math.acos(fe(i[f-1].dot(i[f]),-1,1));r[f].applyMatrix4(c.makeRotationAxis(o,m))}a[f].crossVectors(i[f],r[f])}if(e===!0){let f=Math.acos(fe(r[0].dot(r[t]),-1,1));f/=t,i[0].dot(o.crossVectors(r[0],r[t]))>0&&(f=-f);for(let m=1;m<=t;m++)r[m].applyMatrix4(c.makeRotationAxis(i[m],f*m)),a[m].crossVectors(i[m],r[m])}return{tangents:i,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}},Cs=class extends Ke{constructor(t=0,e=0,n=1,i=1,r=0,a=Math.PI*2,o=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=c}getPoint(t,e=new $){let n=e,i=Math.PI*2,r=this.aEndAngle-this.aStartAngle,a=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(o)/r)+1)*r:c===0&&o===r-1&&(o=r-2,c=1);let l,h;this.closed||o>0?l=i[(o-1)%r]:(wa.subVectors(i[0],i[1]).add(i[0]),l=wa);let u=i[o%r],d=i[(o+1)%r];if(this.closed||o+2i.length-2?i.length-1:a+1],u=i[a>i.length-3?i.length-1:a+2];return n.set(Vd(o,c.x,l.x,h.x,u.x),Vd(o,c.y,l.y,h.y,u.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e=n){let a=i[r]-n,o=this.curves[r],c=o.getLength(),l=c===0?0:1-a/c;return o.getPointAt(l,e)}r++}return null}getLength(){let t=this.getCurveLengths();return t[t.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 t=[],e=0;for(let n=0,i=this.curves.length;n1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e0){let u=l.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(l);let h=l.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}},Ir=class s extends Wt{constructor(t=[new $(0,-.5),new $(.5,0),new $(0,.5)],e=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=fe(i,0,Math.PI*2);let r=[],a=[],o=[],c=[],l=[],h=1/e,u=new A,d=new $,f=new A,m=new A,_=new A,g=0,p=0;for(let y=0;y<=t.length-1;y++)switch(y){case 0:g=t[y+1].x-t[y].x,p=t[y+1].y-t[y].y,f.x=p*1,f.y=-g,f.z=p*0,_.copy(f),f.normalize(),c.push(f.x,f.y,f.z);break;case t.length-1:c.push(_.x,_.y,_.z);break;default:g=t[y+1].x-t[y].x,p=t[y+1].y-t[y].y,f.x=p*1,f.y=-g,f.z=p*0,m.copy(f),f.x+=_.x,f.y+=_.y,f.z+=_.z,f.normalize(),c.push(f.x,f.y,f.z),_.copy(m)}for(let y=0;y<=e;y++){let v=n+y*h*i,x=Math.sin(v),P=Math.cos(v);for(let T=0;T<=t.length-1;T++){u.x=t[T].x*x,u.y=t[T].y,u.z=t[T].x*P,a.push(u.x,u.y,u.z),d.x=y/e,d.y=T/(t.length-1),o.push(d.x,d.y);let C=c[3*T+0]*x,R=c[3*T+1],b=c[3*T+0]*P;l.push(C,R,b)}}for(let y=0;y0&&v(!0),e>0&&v(!1)),this.setIndex(h),this.setAttribute("position",new Mt(u,3)),this.setAttribute("normal",new Mt(d,3)),this.setAttribute("uv",new Mt(f,2));function y(){let x=new A,P=new A,T=0,C=(e-t)/n;for(let R=0;R<=r;R++){let b=[],M=R/r,L=M*(e-t)+t;for(let k=0;k<=i;k++){let O=k/i,V=O*c+o,Z=Math.sin(V),H=Math.cos(V);P.x=L*Z,P.y=-M*n+g,P.z=L*H,u.push(P.x,P.y,P.z),x.set(Z,C,H).normalize(),d.push(x.x,x.y,x.z),f.push(O,1-M),b.push(m++)}_.push(b)}for(let R=0;R0||b!==0)&&(h.push(M,L,O),T+=3),(e>0||b!==r-1)&&(h.push(L,k,O),T+=3)}l.addGroup(p,T,0),p+=T}function v(x){let P=m,T=new $,C=new A,R=0,b=x===!0?t:e,M=x===!0?1:-1;for(let k=1;k<=i;k++)u.push(0,g*M,0),d.push(0,M,0),f.push(.5,.5),m++;let L=m;for(let k=0;k<=i;k++){let V=k/i*c+o,Z=Math.cos(V),H=Math.sin(V);C.x=b*H,C.y=g*M,C.z=b*Z,u.push(C.x,C.y,C.z),d.push(0,M,0),T.x=Z*.5+.5,T.y=H*.5*M+.5,f.push(T.x,T.y),m++}for(let k=0;k.9&&C<.1&&(v<.2&&(a[y+0]+=1),x<.2&&(a[y+2]+=1),P<.2&&(a[y+4]+=1))}}function d(y){r.push(y.x,y.y,y.z)}function f(y,v){let x=y*3;v.x=t[x+0],v.y=t[x+1],v.z=t[x+2]}function m(){let y=new A,v=new A,x=new A,P=new A,T=new $,C=new $,R=new $;for(let b=0,M=0;b80*e){o=l=s[0],c=h=s[1];for(let m=e;ml&&(l=u),d>h&&(h=d);f=Math.max(l-o,h-c),f=f!==0?32767/f:0}return Pr(r,a,e,o,c,f,0),a}};function gp(s,t,e,n,i){let r,a;if(i===hy(s,t,e,n)>0)for(r=t;r=t;r-=n)a=Hd(r,s[r],s[r+1],a);return a&&Gc(a,a.next)&&(Dr(a),a=a.next),a}function zi(s,t){if(!s)return s;t||(t=s);let e=s,n;do if(n=!1,!e.steiner&&(Gc(e,e.next)||he(e.prev,e,e.next)===0)){if(Dr(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Pr(s,t,e,n,i,r,a){if(!s)return;!a&&r&&sy(s,n,i,r);let o=s,c,l;for(;s.prev!==s.next;){if(c=s.prev,l=s.next,r?$v(s,n,i,r):Jv(s)){t.push(c.i/e|0),t.push(s.i/e|0),t.push(l.i/e|0),Dr(s),s=l.next,o=l.next;continue}if(s=l,s===o){a?a===1?(s=Kv(zi(s),t,e),Pr(s,t,e,n,i,r,2)):a===2&&Qv(s,t,e,n,i,r):Pr(zi(s),t,e,n,i,r,1);break}}}function Jv(s){let t=s.prev,e=s,n=s.next;if(he(t,e,n)>=0)return!1;let i=t.x,r=e.x,a=n.x,o=t.y,c=e.y,l=n.y,h=ir?i>a?i:a:r>a?r:a,f=o>c?o>l?o:l:c>l?c:l,m=n.next;for(;m!==t;){if(m.x>=h&&m.x<=d&&m.y>=u&&m.y<=f&&ms(i,o,r,c,a,l,m.x,m.y)&&he(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function $v(s,t,e,n){let i=s.prev,r=s,a=s.next;if(he(i,r,a)>=0)return!1;let o=i.x,c=r.x,l=a.x,h=i.y,u=r.y,d=a.y,f=oc?o>l?o:l:c>l?c:l,g=h>u?h>d?h:d:u>d?u:d,p=uh(f,m,t,e,n),y=uh(_,g,t,e,n),v=s.prevZ,x=s.nextZ;for(;v&&v.z>=p&&x&&x.z<=y;){if(v.x>=f&&v.x<=_&&v.y>=m&&v.y<=g&&v!==i&&v!==a&&ms(o,h,c,u,l,d,v.x,v.y)&&he(v.prev,v,v.next)>=0||(v=v.prevZ,x.x>=f&&x.x<=_&&x.y>=m&&x.y<=g&&x!==i&&x!==a&&ms(o,h,c,u,l,d,x.x,x.y)&&he(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;v&&v.z>=p;){if(v.x>=f&&v.x<=_&&v.y>=m&&v.y<=g&&v!==i&&v!==a&&ms(o,h,c,u,l,d,v.x,v.y)&&he(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=y;){if(x.x>=f&&x.x<=_&&x.y>=m&&x.y<=g&&x!==i&&x!==a&&ms(o,h,c,u,l,d,x.x,x.y)&&he(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Kv(s,t,e){let n=s;do{let i=n.prev,r=n.next.next;!Gc(i,r)&&_p(i,n,n.next,r)&&Lr(i,r)&&Lr(r,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(r.i/e|0),Dr(n),Dr(n.next),n=s=r),n=n.next}while(n!==s);return zi(n)}function Qv(s,t,e,n,i,r){let a=s;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&oy(a,o)){let c=xp(a,o);a=zi(a,a.next),c=zi(c,c.next),Pr(a,t,e,n,i,r,0),Pr(c,t,e,n,i,r,0);return}o=o.next}a=a.next}while(a!==s)}function jv(s,t,e,n){let i=[],r,a,o,c,l;for(r=0,a=t.length;r=e.next.y&&e.next.y!==e.y){let d=e.x+(a-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=r&&d>n&&(n=d,i=e.x=e.x&&e.x>=c&&r!==e.x&&ms(ai.x||e.x===i.x&&iy(i,e)))&&(i=e,h=u)),e=e.next;while(e!==o);return i}function iy(s,t){return he(s.prev,s,t.prev)<0&&he(t.next,s,s.next)<0}function sy(s,t,e,n){let i=s;do i.z===0&&(i.z=uh(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==s);i.prevZ.nextZ=null,i.prevZ=null,ry(i)}function ry(s){let t,e,n,i,r,a,o,c,l=1;do{for(e=s,s=null,r=null,a=0;e;){for(a++,n=e,o=0,t=0;t0||c>0&&n;)o!==0&&(c===0||!n||e.z<=n.z)?(i=e,e=e.nextZ,o--):(i=n,n=n.nextZ,c--),r?r.nextZ=i:s=i,i.prevZ=r,r=i;e=n}r.nextZ=null,l*=2}while(a>1);return s}function uh(s,t,e,n,i){return s=(s-e)*i|0,t=(t-n)*i|0,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,s|t<<1}function ay(s){let t=s,e=s;do(t.x=(s-a)*(r-o)&&(s-a)*(n-o)>=(e-a)*(t-o)&&(e-a)*(r-o)>=(i-a)*(n-o)}function oy(s,t){return s.next.i!==t.i&&s.prev.i!==t.i&&!cy(s,t)&&(Lr(s,t)&&Lr(t,s)&&ly(s,t)&&(he(s.prev,s,t.prev)||he(s,t.prev,t))||Gc(s,t)&&he(s.prev,s,s.next)>0&&he(t.prev,t,t.next)>0)}function he(s,t,e){return(t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y)}function Gc(s,t){return s.x===t.x&&s.y===t.y}function _p(s,t,e,n){let i=Pa(he(s,t,e)),r=Pa(he(s,t,n)),a=Pa(he(e,n,s)),o=Pa(he(e,n,t));return!!(i!==r&&a!==o||i===0&&Ia(s,e,t)||r===0&&Ia(s,n,t)||a===0&&Ia(e,s,n)||o===0&&Ia(e,t,n))}function Ia(s,t,e){return t.x<=Math.max(s.x,e.x)&&t.x>=Math.min(s.x,e.x)&&t.y<=Math.max(s.y,e.y)&&t.y>=Math.min(s.y,e.y)}function Pa(s){return s>0?1:s<0?-1:0}function cy(s,t){let e=s;do{if(e.i!==s.i&&e.next.i!==s.i&&e.i!==t.i&&e.next.i!==t.i&&_p(e,e.next,s,t))return!0;e=e.next}while(e!==s);return!1}function Lr(s,t){return he(s.prev,s,s.next)<0?he(s,t,s.next)>=0&&he(s,s.prev,t)>=0:he(s,t,s.prev)<0||he(s,s.next,t)<0}function ly(s,t){let e=s,n=!1,i=(s.x+t.x)/2,r=(s.y+t.y)/2;do e.y>r!=e.next.y>r&&e.next.y!==e.y&&i<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==s);return n}function xp(s,t){let e=new dh(s.i,s.x,s.y),n=new dh(t.i,t.x,t.y),i=s.next,r=t.prev;return s.next=t,t.prev=s,e.next=i,i.prev=e,n.next=e,e.prev=n,r.next=n,n.prev=r,n}function Hd(s,t,e,n){let i=new dh(s,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Dr(s){s.next.prev=s.prev,s.prev.next=s.next,s.prevZ&&(s.prevZ.nextZ=s.nextZ),s.nextZ&&(s.nextZ.prevZ=s.prevZ)}function dh(s,t,e){this.i=s,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function hy(s,t,e,n){let i=0;for(let r=t,a=e-n;r2&&s[t-1].equals(s[0])&&s.pop()}function Wd(s,t){for(let e=0;eNumber.EPSILON){let X=Math.sqrt(S),Q=Math.sqrt(gt*gt+w*w),q=nt.x-Pt/X,Et=nt.y+at/X,lt=I.x-w/Q,_t=I.y+gt/Q,qt=((lt-q)*w-(_t-Et)*gt)/(at*w-Pt*gt);Ct=q+at*qt-K.x,j=Et+Pt*qt-K.y;let tt=Ct*Ct+j*j;if(tt<=2)return new $(Ct,j);xt=Math.sqrt(tt/2)}else{let X=!1;at>Number.EPSILON?gt>Number.EPSILON&&(X=!0):at<-Number.EPSILON?gt<-Number.EPSILON&&(X=!0):Math.sign(Pt)===Math.sign(w)&&(X=!0),X?(Ct=-Pt,j=at,xt=Math.sqrt(S)):(Ct=at,j=Pt,xt=Math.sqrt(S/2))}return new $(Ct/xt,j/xt)}let ot=[];for(let K=0,nt=V.length,I=nt-1,Ct=K+1;K=0;K--){let nt=K/g,I=f*Math.cos(nt*Math.PI/2),Ct=m*Math.sin(nt*Math.PI/2)+_;for(let j=0,xt=V.length;j=0;){let Ct=I,j=I-1;j<0&&(j=K.length-1);for(let xt=0,at=h+g*2;xt0)&&f.push(v,x,T),(p!==n-1||c0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}},hc=class extends Ee{static get type(){return"MeshPhongMaterial"}constructor(t){super(),this.isMeshPhongMaterial=!0,this.color=new ut(16777215),this.specular=new ut(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ut(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=oi,this.normalScale=new $(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Je,this.combine=Gr,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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}},uc=class extends Ee{static get type(){return"MeshToonMaterial"}constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.color=new ut(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ut(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=oi,this.normalScale=new $(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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}},dc=class extends Ee{static get type(){return"MeshNormalMaterial"}constructor(t){super(),this.isMeshNormalMaterial=!0,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=oi,this.normalScale=new $(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}},fc=class extends Ee{static get type(){return"MeshLambertMaterial"}constructor(t){super(),this.isMeshLambertMaterial=!0,this.color=new ut(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ut(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=oi,this.normalScale=new $(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Je,this.combine=Gr,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(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}},pc=class extends Ee{static get type(){return"MeshMatcapMaterial"}constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.color=new ut(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=oi,this.normalScale=new $(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}},mc=class extends Ae{static get type(){return"LineDashedMaterial"}constructor(t){super(),this.isLineDashedMaterial=!0,this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}};function Ai(s,t,e){return!s||!e&&s.constructor===t?s:typeof t.BYTES_PER_ELEMENT=="number"?new t(s):Array.prototype.slice.call(s)}function vp(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function yp(s){function t(i,r){return s[i]-s[r]}let e=s.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort(t),n}function fh(s,t,e){let n=s.length,i=new s.constructor(n);for(let r=0,a=0;a!==n;++r){let o=e[r]*t;for(let c=0;c!==t;++c)i[a++]=s[o+c]}return i}function Su(s,t,e,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(t.push(r.time),e.push.apply(e,a)),r=s[i++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(t.push(r.time),a.toArray(e,e.length)),r=s[i++];while(r!==void 0);else do a=r[n],a!==void 0&&(t.push(r.time),e.push(a)),r=s[i++];while(r!==void 0)}function py(s,t,e,n,i=30){let r=s.clone();r.name=t;let a=[];for(let c=0;c=n)){u.push(l.times[f]);for(let _=0;_r.tracks[c].times[0]&&(o=r.tracks[c].times[0]);for(let c=0;c=o.times[m]){let p=m*u+h,y=p+u-h;_=o.values.slice(p,y)}else{let p=o.createInterpolant(),y=h,v=u-h;p.evaluate(r),_=p.resultBuffer.slice(y,v)}c==="quaternion"&&new Le().fromArray(_).normalize().conjugate().toArray(_);let g=l.times.length;for(let p=0;p=r)){let o=e[1];t=r)break e}a=n,n=0;break n}break t}for(;n>>1;te;)--a;if(++a,r!==0||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);let o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(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,i=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(i!==void 0&&vp(i))for(let o=0,c=i.length;o!==c;++o){let l=i[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=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===za,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=t.slice(0,a),this.values=e.slice(0,a*n)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}};Qe.prototype.TimeBufferType=Float32Array;Qe.prototype.ValueBufferType=Float32Array;Qe.prototype.DefaultInterpolation=So;var Wn=class extends Qe{constructor(t,e,n){super(t,e,n)}};Wn.prototype.ValueTypeName="bool";Wn.prototype.ValueBufferType=Array;Wn.prototype.DefaultInterpolation=hr;Wn.prototype.InterpolantFactoryMethodLinear=void 0;Wn.prototype.InterpolantFactoryMethodSmooth=void 0;var Br=class extends Qe{};Br.prototype.ValueTypeName="color";var Vi=class extends Qe{};Vi.prototype.ValueTypeName="number";var xc=class extends ki{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){let r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-e)/(i-e),l=t*o;for(let h=l+o;l!==h;l+=4)Le.slerpFlat(r,0,a,l-o,a,l,c);return r}},Hi=class extends Qe{InterpolantFactoryMethodLinear(t){return new xc(this.times,this.values,this.getValueSize(),t)}};Hi.prototype.ValueTypeName="quaternion";Hi.prototype.InterpolantFactoryMethodSmooth=void 0;var Xn=class extends Qe{constructor(t,e,n){super(t,e,n)}};Xn.prototype.ValueTypeName="string";Xn.prototype.ValueBufferType=Array;Xn.prototype.DefaultInterpolation=hr;Xn.prototype.InterpolantFactoryMethodLinear=void 0;Xn.prototype.InterpolantFactoryMethodSmooth=void 0;var Gi=class extends Qe{};Gi.prototype.ValueTypeName="vector";var Wi=class{constructor(t="",e=-1,n=[],i=Vc){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=Ye(),this.duration<0&&this.resetDuration()}static parse(t){let e=[],n=t.tracks,i=1/(t.fps||1);for(let a=0,o=n.length;a!==o;++a)e.push(xy(n[a]).scale(i));let r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){let e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let r=0,a=n.length;r!==a;++r)e.push(Qe.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(t,e,n,i){let r=e.length,a=[];for(let o=0;o1){let u=h[1],d=i[u];d||(i[u]=d=[]),d.push(l)}}let a=[];for(let o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],e,n));return a}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(u,d,f,m,_){if(f.length!==0){let g=[],p=[];Su(f,g,p,m),g.length!==0&&_.push(new u(d,g,p))}},i=[],r=t.name||"default",a=t.fps||30,o=t.blendMode,c=t.length||-1,l=t.hierarchy||[];for(let u=0;u{e&&e(r),this.manager.itemEnd(t)},0),r;if(Ln[t]!==void 0){Ln[t].push({onLoad:e,onProgress:n,onError:i});return}Ln[t]=[],Ln[t].push({onLoad:e,onProgress:n,onError:i});let a=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,c=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let h=Ln[t],u=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=d?parseInt(d):0,m=f!==0,_=0,g=new ReadableStream({start(p){y();function y(){u.read().then(({done:v,value:x})=>{if(v)p.close();else{_+=x.byteLength;let P=new ProgressEvent("progress",{lengthComputable:m,loaded:_,total:f});for(let T=0,C=h.length;T{p.error(v)})}}});return new Response(g)}else throw new ph(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return l.json();default:if(o===void 0)return l.text();{let u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return l.arrayBuffer().then(m=>f.decode(m))}}}).then(l=>{Fn.add(t,l);let h=Ln[t];delete Ln[t];for(let u=0,d=h.length;u{let h=Ln[t];if(h===void 0)throw this.manager.itemError(t),l;delete Ln[t];for(let u=0,d=h.length;u{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}},mh=class extends De{constructor(t){super(t)}load(t,e,n,i){let r=this,a=new dn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(o){try{e(r.parse(JSON.parse(o)))}catch(c){i?i(c):console.error(c),r.manager.itemError(t)}},n,i)}parse(t){let e=[];for(let n=0;n0:i.vertexColors=t.vertexColors),t.uniforms!==void 0)for(let r in t.uniforms){let a=t.uniforms[r];switch(i.uniforms[r]={},a.type){case"t":i.uniforms[r].value=n(a.value);break;case"c":i.uniforms[r].value=new ut().setHex(a.value);break;case"v2":i.uniforms[r].value=new $().fromArray(a.value);break;case"v3":i.uniforms[r].value=new A().fromArray(a.value);break;case"v4":i.uniforms[r].value=new $t().fromArray(a.value);break;case"m3":i.uniforms[r].value=new Bt().fromArray(a.value);break;case"m4":i.uniforms[r].value=new Ut().fromArray(a.value);break;default:i.uniforms[r].value=a.value}}if(t.defines!==void 0&&(i.defines=t.defines),t.vertexShader!==void 0&&(i.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(i.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(i.glslVersion=t.glslVersion),t.extensions!==void 0)for(let r in t.extensions)i.extensions[r]=t.extensions[r];if(t.lights!==void 0&&(i.lights=t.lights),t.clipping!==void 0&&(i.clipping=t.clipping),t.size!==void 0&&(i.size=t.size),t.sizeAttenuation!==void 0&&(i.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(i.map=n(t.map)),t.matcap!==void 0&&(i.matcap=n(t.matcap)),t.alphaMap!==void 0&&(i.alphaMap=n(t.alphaMap)),t.bumpMap!==void 0&&(i.bumpMap=n(t.bumpMap)),t.bumpScale!==void 0&&(i.bumpScale=t.bumpScale),t.normalMap!==void 0&&(i.normalMap=n(t.normalMap)),t.normalMapType!==void 0&&(i.normalMapType=t.normalMapType),t.normalScale!==void 0){let r=t.normalScale;Array.isArray(r)===!1&&(r=[r,r]),i.normalScale=new $().fromArray(r)}return t.displacementMap!==void 0&&(i.displacementMap=n(t.displacementMap)),t.displacementScale!==void 0&&(i.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(i.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(i.roughnessMap=n(t.roughnessMap)),t.metalnessMap!==void 0&&(i.metalnessMap=n(t.metalnessMap)),t.emissiveMap!==void 0&&(i.emissiveMap=n(t.emissiveMap)),t.emissiveIntensity!==void 0&&(i.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(i.specularMap=n(t.specularMap)),t.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(t.specularIntensityMap)),t.specularColorMap!==void 0&&(i.specularColorMap=n(t.specularColorMap)),t.envMap!==void 0&&(i.envMap=n(t.envMap)),t.envMapRotation!==void 0&&i.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(i.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(i.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(i.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(i.lightMap=n(t.lightMap)),t.lightMapIntensity!==void 0&&(i.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(i.aoMap=n(t.aoMap)),t.aoMapIntensity!==void 0&&(i.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(i.gradientMap=n(t.gradientMap)),t.clearcoatMap!==void 0&&(i.clearcoatMap=n(t.clearcoatMap)),t.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),t.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),t.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new $().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(i.iridescenceMap=n(t.iridescenceMap)),t.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),t.transmissionMap!==void 0&&(i.transmissionMap=n(t.transmissionMap)),t.thicknessMap!==void 0&&(i.thicknessMap=n(t.thicknessMap)),t.anisotropyMap!==void 0&&(i.anisotropyMap=n(t.anisotropyMap)),t.sheenColorMap!==void 0&&(i.sheenColorMap=n(t.sheenColorMap)),t.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return s.createMaterialFromType(t)}static createMaterialFromType(t){let e={ShadowMaterial:oc,SpriteMaterial:Sr,RawShaderMaterial:cc,ShaderMaterial:$e,PointsMaterial:Er,MeshPhysicalMaterial:lc,MeshStandardMaterial:Fr,MeshPhongMaterial:hc,MeshToonMaterial:uc,MeshNormalMaterial:dc,MeshLambertMaterial:fc,MeshDepthMaterial:yr,MeshDistanceMaterial:Mr,MeshBasicMaterial:Sn,MeshMatcapMaterial:pc,LineDashedMaterial:mc,LineBasicMaterial:Ae,Material:Ee};return new e[t]}},Vr=class{static decodeText(t){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(t);let e="";for(let n=0,i=t.length;n0){let c=new zr(e);r=new Xi(c),r.setCrossOrigin(this.crossOrigin);for(let l=0,h=t.length;l0){i=new Xi(this.manager),i.setCrossOrigin(this.crossOrigin);for(let a=0,o=t.length;a{let g=new we;g.min.fromArray(_.boxMin),g.max.fromArray(_.boxMax);let p=new be;return p.radius=_.sphereRadius,p.center.fromArray(_.sphereCenter),{boxInitialized:_.boxInitialized,box:g,sphereInitialized:_.sphereInitialized,sphere:p}}),a._maxInstanceCount=t.maxInstanceCount,a._maxVertexCount=t.maxVertexCount,a._maxIndexCount=t.maxIndexCount,a._geometryInitialized=t.geometryInitialized,a._geometryCount=t.geometryCount,a._matricesTexture=l(t.matricesTexture.uuid),t.colorsTexture!==void 0&&(a._colorsTexture=l(t.colorsTexture.uuid));break;case"LOD":a=new Lo;break;case"Line":a=new bn(o(t.geometry),c(t.material));break;case"LineLoop":a=new zo(o(t.geometry),c(t.material));break;case"LineSegments":a=new rn(o(t.geometry),c(t.material));break;case"PointCloud":case"Points":a=new ko(o(t.geometry),c(t.material));break;case"Sprite":a=new Po(c(t.material));break;case"Group":a=new ni;break;case"Bone":a=new br;break;default:a=new Qt}if(a.uuid=t.uuid,t.name!==void 0&&(a.name=t.name),t.matrix!==void 0?(a.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=t.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(t.position!==void 0&&a.position.fromArray(t.position),t.rotation!==void 0&&a.rotation.fromArray(t.rotation),t.quaternion!==void 0&&a.quaternion.fromArray(t.quaternion),t.scale!==void 0&&a.scale.fromArray(t.scale)),t.up!==void 0&&a.up.fromArray(t.up),t.castShadow!==void 0&&(a.castShadow=t.castShadow),t.receiveShadow!==void 0&&(a.receiveShadow=t.receiveShadow),t.shadow&&(t.shadow.intensity!==void 0&&(a.shadow.intensity=t.shadow.intensity),t.shadow.bias!==void 0&&(a.shadow.bias=t.shadow.bias),t.shadow.normalBias!==void 0&&(a.shadow.normalBias=t.shadow.normalBias),t.shadow.radius!==void 0&&(a.shadow.radius=t.shadow.radius),t.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(t.shadow.mapSize),t.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(t.shadow.camera))),t.visible!==void 0&&(a.visible=t.visible),t.frustumCulled!==void 0&&(a.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(a.renderOrder=t.renderOrder),t.userData!==void 0&&(a.userData=t.userData),t.layers!==void 0&&(a.layers.mask=t.layers),t.children!==void 0){let d=t.children;for(let f=0;f"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);let r=this,a=Fn.get(t);if(a!==void 0){if(r.manager.itemStart(t),a.then){a.then(l=>{e&&e(l),r.manager.itemEnd(t)}).catch(l=>{i&&i(l)});return}return setTimeout(function(){e&&e(a),r.manager.itemEnd(t)},0),a}let o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;let c=fetch(t,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){return Fn.add(t,l),e&&e(l),r.manager.itemEnd(t),l}).catch(function(l){i&&i(l),Fn.remove(t),r.manager.itemError(t),r.manager.itemEnd(t)});Fn.add(t,c),r.manager.itemStart(t)}},La,Hr=class{static getContext(){return La===void 0&&(La=new(window.AudioContext||window.webkitAudioContext)),La}static setContext(t){La=t}},Th=class extends De{constructor(t){super(t)}load(t,e,n,i){let r=this,a=new dn(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(c){try{let l=c.slice(0);Hr.getContext().decodeAudioData(l,function(u){e(u)}).catch(o)}catch(l){o(l)}},n,i);function o(c){i?i(c):console.error(c),r.manager.itemError(t)}}},Qd=new Ut,jd=new Ut,_i=new Ut,wh=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new xe,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new xe,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){let e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,_i.copy(t.projectionMatrix);let i=e.eyeSep/2,r=i*e.near/e.focus,a=e.near*Math.tan(Ii*e.fov*.5)/e.zoom,o,c;jd.elements[12]=-i,Qd.elements[12]=i,o=-a*e.aspect+r,c=a*e.aspect+r,_i.elements[0]=2*e.near/(c-o),_i.elements[8]=(c+o)/(c-o),this.cameraL.projectionMatrix.copy(_i),o=-a*e.aspect-r,c=a*e.aspect-r,_i.elements[0]=2*e.near/(c-o),_i.elements[8]=(c+o)/(c-o),this.cameraR.projectionMatrix.copy(_i)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(jd),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(Qd)}},Ic=class{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=tf(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=tf();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}};function tf(){return performance.now()}var xi=new A,ef=new Le,yy=new A,vi=new A,Ah=class extends Qt{constructor(){super(),this.type="AudioListener",this.context=Hr.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Ic}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);let e=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(xi,ef,yy),vi.set(0,0,-1).applyQuaternion(ef),e.positionX){let i=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(xi.x,i),e.positionY.linearRampToValueAtTime(xi.y,i),e.positionZ.linearRampToValueAtTime(xi.z,i),e.forwardX.linearRampToValueAtTime(vi.x,i),e.forwardY.linearRampToValueAtTime(vi.y,i),e.forwardZ.linearRampToValueAtTime(vi.z,i),e.upX.linearRampToValueAtTime(n.x,i),e.upY.linearRampToValueAtTime(n.y,i),e.upZ.linearRampToValueAtTime(n.z,i)}else e.setPosition(xi.x,xi.y,xi.z),e.setOrientation(vi.x,vi.y,vi.z,n.x,n.y,n.z)}},Pc=class extends Qt{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+t;let e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(t=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let c=e,l=e+e;c!==l;++c)if(n[c]!==n[c+e]){o.setValue(n,i);break}}saveOriginalState(){let t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let r=n,a=i;r!==a;++r)e[r]=e[i+r%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n=.5)for(let a=0;a!==r;++a)t[e+a]=t[n+a]}_slerp(t,e,n,i){Le.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,r){let a=this._workIndex*r;Le.multiplyQuaternionsFlat(t,a,t,e,t,n),Le.slerpFlat(t,e,t,e,t,a,i)}_lerp(t,e,n,i,r){let a=1-i;for(let o=0;o!==r;++o){let c=e+o;t[c]=t[c]*a+t[n+o]*i}}_lerpAdditive(t,e,n,i,r){for(let a=0;a!==r;++a){let o=e+a;t[o]=t[o]+t[n+a]*i}}},bu="\\[\\]\\.:\\/",Sy=new RegExp("["+bu+"]","g"),Eu="[^"+bu+"]",by="[^"+bu.replace("\\.","")+"]",Ey=/((?:WC+[\/:])*)/.source.replace("WC",Eu),Ty=/(WCOD+)?/.source.replace("WCOD",by),wy=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Eu),Ay=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Eu),Cy=new RegExp("^"+Ey+Ty+wy+Ay+"$"),Ry=["material","materials","bones","map"],Ih=class{constructor(t,e,n){let i=n||re.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();let n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){let n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}},re=class s{constructor(t,e,n){this.path=e,this.parsedPath=n||s.parseTrackName(e),this.node=s.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new s.Composite(t,e,n):new s(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(Sy,"")}static parseTrackName(t){let e=Cy.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){let r=n.nodeName.substring(i+1);Ry.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){let n=function(r){for(let a=0;a=r){let u=r++,d=t[u];e[d.uuid]=h,t[h]=d,e[l]=u,t[u]=c;for(let f=0,m=i;f!==m;++f){let _=n[f],g=_[u],p=_[h];_[h]=g,_[u]=p}}}this.nCachedObjects_=r}uncache(){let t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length,r=this.nCachedObjects_,a=t.length;for(let o=0,c=arguments.length;o!==c;++o){let l=arguments[o],h=l.uuid,u=e[h];if(u!==void 0)if(delete e[h],u0&&(e[f.uuid]=u),t[u]=f,t.pop();for(let m=0,_=i;m!==_;++m){let g=n[m];g[u]=g[d],g.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){let n=this._bindingsIndicesByPath,i=n[t],r=this._bindings;if(i!==void 0)return r[i];let a=this._paths,o=this._parsedPaths,c=this._objects,l=c.length,h=this.nCachedObjects_,u=new Array(l);i=r.length,n[t]=i,a.push(t),o.push(e),r.push(u);for(let d=h,f=c.length;d!==f;++d){let m=c[d];u[d]=new re(m,t,e)}return u}unsubscribe_(t){let e=this._bindingsIndicesByPath,n=e[t];if(n!==void 0){let i=this._paths,r=this._parsedPaths,a=this._bindings,o=a.length-1,c=a[o],l=t[o];e[l]=n,a[n]=c,a.pop(),r[n]=r[o],r.pop(),i[n]=i[o],i.pop()}}},Dc=class{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;let r=e.tracks,a=r.length,o=new Array(a),c={endingStart:Ti,endingEnd:Ti};for(let l=0;l!==a;++l){let h=r[l].createInterpolant(null);o[l]=h,h.settings=c}this._interpolantSettings=c,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=qf,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&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){let i=this._clip.duration,r=t._clip.duration,a=r/i,o=i/r;t.warp(1,a,e),this.warp(o,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){let t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){let i=this._mixer,r=i.time,a=this.timeScale,o=this._timeScaleInterpolant;o===null&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);let c=o.parameterPositions,l=o.sampleValues;return c[0]=r,c[1]=r+n,l[0]=t/a,l[1]=e/a,this}stopWarping(){let t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled){this._updateWeight(t);return}let r=this._startTime;if(r!==null){let c=(t-r)*n;c<0||n===0?e=0:(this._startTime=null,e=n*c)}e*=this._updateTimeScale(t);let a=this._updateTime(e),o=this._updateWeight(t);if(o>0){let c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case _u:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(a),l[h].accumulateAdditive(o);break;case Vc:default:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(a),l[h].accumulate(i,o)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let n=this._weightInterpolant;if(n!==null){let i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,n=this.loop,i=this.time+t,r=this._loopCount,a=n===Yf;if(t===0)return r===-1?i:a&&(r&1)===1?e-i:i;if(n===Xf){r===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else if(i<0)i=0;else{this.time=i;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(r===-1&&(t>=0?(r=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),i>=e||i<0){let o=Math.floor(i/e);i-=e*o,r+=Math.abs(o);let c=this.repetitions-r;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(c===1){let l=t<0;this._setEndings(l,!l,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=i;if(a&&(r&1)===1)return e-i}return i}_setEndings(t,e,n){let i=this._interpolantSettings;n?(i.endingStart=wi,i.endingEnd=wi):(t?i.endingStart=this.zeroSlopeAtStart?wi:Ti:i.endingStart=ur,e?i.endingEnd=this.zeroSlopeAtEnd?wi:Ti:i.endingEnd=ur)}_scheduleFading(t,e,n){let i=this._mixer,r=i.time,a=this._weightInterpolant;a===null&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);let o=a.parameterPositions,c=a.sampleValues;return o[0]=r,c[0]=e,o[1]=r+t,c[1]=n,this}},Iy=new Float32Array(1),Lh=class extends sn{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let n=t._localRoot||this._root,i=t._clip.tracks,r=i.length,a=t._propertyBindings,o=t._interpolants,c=n.uuid,l=this._bindingsByRootAndName,h=l[c];h===void 0&&(h={},l[c]=h);for(let u=0;u!==r;++u){let d=i[u],f=d.name,m=h[f];if(m!==void 0)++m.referenceCount,a[u]=m;else{if(m=a[u],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,c,f));continue}let _=e&&e._propertyBindings[u].binding.parsedPath;m=new Lc(re.create(n,f,_),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,c,f),a[u]=m}o[u].resultBuffer=m.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){let n=(t._localRoot||this._root).uuid,i=t._clip.uuid,r=this._actionsByClip[i];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,i,n)}let e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){let r=e[n];r.useCount++===0&&(this._lendBinding(r),r.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){let r=e[n];--r.useCount===0&&(r.restoreOriginalState(),this._takeBackBinding(r))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return e!==null&&e=0;--n)t[n].stop();return this}update(t){t*=this.timeScale;let e=this._actions,n=this._nActiveActions,i=this.time+=t,r=Math.sign(t),a=this._accuIndex^=1;for(let l=0;l!==n;++l)e[l]._update(i,t,r,a);let o=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)o[l].apply(a);return this}setTime(t){this.time=0;for(let e=0;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}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}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))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,af).distanceTo(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}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)}},of=new A,Da=new A,Gh=class{constructor(t=new A,e=new A){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){of.subVectors(t,this.start),Da.subVectors(this.end,this.start);let n=Da.dot(Da),r=Da.dot(of)/n;return e&&(r=fe(r,0,1)),r}closestPointToPoint(t,e,n){let i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},cf=new A,Wh=class extends Qt{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";let n=new Wt,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,o=1,c=32;a1)for(let u=0;u.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{ff.set(t.z,0,-t.x).normalize();let e=Math.acos(t.y);this.quaternion.setFromAxisAngle(ff,e)}}setLength(t,e=t*.2,n=e*.2){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},nu=class extends rn{constructor(t=1){let e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Wt;i.setAttribute("position",new Mt(e,3)),i.setAttribute("color",new Mt(n,3));let r=new Ae({vertexColors:!0,toneMapped:!1});super(i,r),this.type="AxesHelper"}setColors(t,e,n){let i=new ut,r=this.geometry.attributes.color.array;return i.set(t),i.toArray(r,0),i.toArray(r,3),i.set(e),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()}},iu=class{constructor(){this.type="ShapePath",this.color=new ut,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Bi,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,r,a){return this.currentPath.bezierCurveTo(t,e,n,i,r,a),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(p){let y=[];for(let v=0,x=p.length;vNumber.EPSILON){if(M<0&&(C=y[T],b=-b,R=y[P],M=-M),p.yR.y)continue;if(p.y===C.y){if(p.x===C.x)return!0}else{let L=M*(p.x-C.x)-b*(p.y-C.y);if(L===0)return!0;if(L<0)continue;x=!x}}else{if(p.y!==C.y)continue;if(R.x<=p.x&&p.x<=C.x||C.x<=p.x&&p.x<=R.x)return!0}}return x}let i=yn.isClockWise,r=this.subPaths;if(r.length===0)return[];let a,o,c,l=[];if(r.length===1)return o=r[0],c=new kn,c.curves=o.curves,l.push(c),l;let h=!i(r[0].getPoints());h=t?!h:h;let u=[],d=[],f=[],m=0,_;d[m]=void 0,f[m]=[];for(let p=0,y=r.length;p1){let p=!1,y=0;for(let v=0,x=d.length;v0&&p===!1&&(f=u)}let g;for(let p=0,y=d.length;p{var r=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var x=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},I=(e,t,n,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of d(t))!j.call(e,o)&&o!==n&&r(e,o,{get:()=>t[o],enumerable:!(c=p(t,o))||c.enumerable});return e};var m=e=>I(r({},"__esModule",{value:!0}),e);var y={};x(y,{createStore:()=>b});var u=e=>{let t,n=new Set,c=(s,S)=>{let i=typeof s=="function"?s(t):s;if(!Object.is(i,t)){let f=t;t=S??(typeof i!="object"||i===null)?i:Object.assign({},t,i),n.forEach(g=>g(t,f))}},o=()=>t,a={setState:c,getState:o,getInitialState:()=>l,subscribe:s=>(n.add(s),()=>n.delete(s))},l=t=e(c,o,a);return a},b=(e=>e?u(e):u);return m(y);})(); diff --git a/android/app/src/main/assets/pulsewall/pulsewall-tokens.css b/android/app/src/main/assets/pulsewall/pulsewall-tokens.css new file mode 100644 index 0000000..501c7d6 --- /dev/null +++ b/android/app/src/main/assets/pulsewall/pulsewall-tokens.css @@ -0,0 +1,156 @@ +:root { + --pw-bg: #0a0f1d; + --pw-surface: #121a2e; + --pw-surface-2: #18233d; + --pw-border: rgba(148, 163, 184, 0.18); + --pw-text: #eef4ff; + --pw-muted: #93a4c3; + --pw-accent: #38bdf8; + --pw-ok: #22c55e; + --pw-warn: #f59e0b; + --pw-danger: #ef4444; + --safe-top: 28px; + --safe-bottom: 16px; +} + +* { + box-sizing: border-box; + -webkit-tap-highlight-color: transparent; +} + +html, body { + margin: 0; + padding: 0; + width: 100%; + min-height: 100%; + background: var(--pw-bg); + color: var(--pw-text); + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans CJK SC", sans-serif; + overflow-x: hidden; + word-wrap: break-word; +} + +#pw-shell { + padding: calc(var(--safe-top) + 46px) 14px calc(var(--safe-bottom) + 18px) 14px; + max-width: 100%; + min-height: 100vh; +} + +#pw-shell.pw-fullscreen-mode { + padding: 0 !important; + margin: 0 !important; + width: 100%; + max-width: 100%; + min-height: 100vh; +} + +#pw-shell.pw-fullscreen-mode #pw-canvas, +#pw-shell.pw-fullscreen-mode #pw-sandbox-root { + width: 100%; + min-height: 100vh; +} + +.pw-stack { display: flex; flex-direction: column; gap: 12px; } +.pw-row { display: flex; flex-direction: row; align-items: center; gap: 10px; flex-wrap: wrap; } +.pw-between { justify-content: space-between; } + +.pw-grid-2 { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 12px; +} +.pw-grid-auto { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); + gap: 12px; +} +@media (max-width: 360px) { + .pw-grid-2 { grid-template-columns: 1fr; } +} + +.pw-card { + background: linear-gradient(160deg, rgba(24, 35, 61, 0.92), rgba(16, 24, 43, 0.96)); + border: 1px solid var(--pw-border); + border-radius: 16px; + padding: 14px 16px; + max-width: 100%; +} +.pw-hero { + border-color: rgba(56, 189, 248, 0.35); + background: linear-gradient(145deg, rgba(16, 36, 66, 0.95), rgba(14, 21, 38, 0.96)); +} + +.pw-muted { color: var(--pw-muted); font-size: 13px; } +.pw-metric { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: 0.3px; } +.pw-ok-text { color: var(--pw-ok); } +.pw-warn-text { color: var(--pw-warn); } +.pw-danger-text { color: var(--pw-danger); } + +.pw-pill { + display: inline-flex; + align-items: center; + padding: 3px 10px; + border-radius: 999px; + font-size: 11px; + font-weight: 700; + letter-spacing: 0.4px; + background: rgba(56, 189, 248, 0.16); + color: var(--pw-accent); +} +.pw-pill.pw-ok { background: rgba(34, 197, 94, 0.18); color: var(--pw-ok); } +.pw-pill.pw-warn { background: rgba(245, 158, 11, 0.18); color: var(--pw-warn); } +.pw-pill.pw-danger { background: rgba(239, 68, 68, 0.22); color: #fca5a5; } + +.pw-btn { + display: inline-flex; + align-items: center; + justify-content: center; + padding: 10px 14px; + border-radius: 12px; + border: 1px solid transparent; + font-size: 14px; + font-weight: 600; + cursor: pointer; +} +.pw-btn-primary { background: var(--pw-accent); color: #041220; } +.pw-btn-danger { background: var(--pw-danger); color: #ffffff; } +.pw-btn-secondary { background: var(--pw-surface-2); color: var(--pw-text); border-color: var(--pw-border); } + +.pw-code { + background: #070b15; + border: 1px solid var(--pw-border); + border-radius: 10px; + padding: 10px; + font-family: ui-monospace, SFMono-Regular, Menlo, monospace; + font-size: 12px; + color: #cbd5e1; + white-space: pre-wrap; + overflow-x: auto; +} + +.pw-feed-item { + border-left: 3px solid var(--pw-accent); + padding: 10px 12px; + background: rgba(18, 26, 46, 0.85); + border-radius: 0 12px 12px 0; + margin-bottom: 10px; +} +.pw-feed-item.level-warning { border-left-color: var(--pw-warn); } +.pw-feed-item.level-error, .pw-feed-item.level-critical { border-left-color: var(--pw-danger); } + +/* IR Remote / TV D-Pad visible focus indicator */ +.pw-tv-focus { + outline: 3px solid #facc15 !important; + outline-offset: 2px; + box-shadow: 0 0 0 5px rgba(250, 204, 21, 0.35), 0 8px 24px rgba(0, 0, 0, 0.45) !important; + transform: scale(1.02); + transition: transform 0.12s ease, box-shadow 0.12s ease; +} +.pw-tv-hint { + font-size: 12px; + color: #cbd5e1; + background: rgba(15, 23, 42, 0.72); + border: 1px solid rgba(56, 189, 248, 0.22); + border-radius: 10px; + padding: 8px 12px; +} diff --git a/android/app/src/main/assets/pulsewall/pw-lib-loader.js b/android/app/src/main/assets/pulsewall/pw-lib-loader.js new file mode 100644 index 0000000..f52da58 --- /dev/null +++ b/android/app/src/main/assets/pulsewall/pw-lib-loader.js @@ -0,0 +1,78 @@ +(function (g) { + var CATALOG = { + plyr: { js: "./libs/plyr.min.js", css: "./libs/plyr.css", global: "Plyr" }, + hls: { js: "./libs/hls.light.min.js", global: "Hls" }, + echarts: { js: "./libs/echarts.custom.min.js", global: "echarts" }, + konva: { js: "./libs/konva.min.js", global: "Konva" }, + three: { js: "./libs/three.min.js", global: "THREE" }, + rough: { js: "./libs/rough.min.js", global: "rough" }, + tailwind: { css: "./libs/tailwind-lite.min.css" }, + dayjs: { js: "./libs/dayjs.min.js", global: "dayjs" }, + lodash: { js: "./libs/lodash-lite.min.js", global: "_" }, + zustand: { js: "./libs/zustand.min.js", global: "Zustand" }, + anime: { js: "./libs/anime.min.js", global: "anime" }, + icons: { js: "./libs/pw-icons.min.js", global: "PwIcons" } + }; + + var loadedPromises = {}; + + function loadCss(href) { + return new Promise(function (resolve) { + if (document.querySelector('link[data-pw-lib-css="' + href + '"]')) { + resolve(); + return; + } + var link = document.createElement("link"); + link.rel = "stylesheet"; + link.href = href; + link.setAttribute("data-pw-lib-css", href); + link.onload = function () { resolve(); }; + link.onerror = function () { resolve(); }; + document.head.appendChild(link); + }); + } + + function loadJs(src) { + return new Promise(function (resolve, reject) { + if (document.querySelector('script[data-pw-lib-js="' + src + '"]')) { + resolve(); + return; + } + var s = document.createElement("script"); + s.src = src; + s.async = false; + s.setAttribute("data-pw-lib-js", src); + s.onload = function () { resolve(); }; + s.onerror = function () { reject(new Error("Failed to load local lib: " + src)); }; + document.head.appendChild(s); + }); + } + + function loadOne(name) { + var key = String(name || "").toLowerCase().trim(); + var entry = CATALOG[key]; + if (!entry) { + return Promise.reject(new Error("Unknown local PulseWall lib: " + name)); + } + if (loadedPromises[key]) return loadedPromises[key]; + var tasks = []; + if (entry.css) tasks.push(loadCss(entry.css)); + if (entry.js) tasks.push(loadJs(entry.js)); + loadedPromises[key] = Promise.all(tasks).then(function () { + return entry.global ? g[entry.global] : true; + }); + return loadedPromises[key]; + } + + function loadLib(names) { + if (Array.isArray(names)) { + return Promise.all(names.map(loadOne)); + } + return loadOne(names); + } + + g.__pwLibLoader = { + catalog: CATALOG, + loadLib: loadLib + }; +})(window); diff --git a/android/app/src/main/assets/pulsewall/pw-stage-bootstrap.js b/android/app/src/main/assets/pulsewall/pw-stage-bootstrap.js new file mode 100644 index 0000000..95c8128 --- /dev/null +++ b/android/app/src/main/assets/pulsewall/pw-stage-bootstrap.js @@ -0,0 +1,366 @@ +(function (g) { + if (g.__pwStageBootstrapped) return; + g.__pwStageBootstrapped = true; + + var frozen = false; + var disposed = false; + var origSetInterval = g.setInterval.bind(g); + var origClearInterval = g.clearInterval.bind(g); + var origSetTimeout = g.setTimeout.bind(g); + var origClearTimeout = g.clearTimeout.bind(g); + var origRAF = g.requestAnimationFrame ? g.requestAnimationFrame.bind(g) : null; + var origCAF = g.cancelAnimationFrame ? g.cancelAnimationFrame.bind(g) : null; + + var intervals = new Set(); + var timeouts = new Set(); + var rafIds = new Set(); + var heldRafCallbacks = []; + var sockets = new Set(); + var eventSources = new Set(); + var observers = new Set(); + + g.setInterval = function (fn, delay) { + if (disposed) return 0; + var args = Array.prototype.slice.call(arguments, 2); + var wrapped = function () { + if (disposed || frozen) return; + if (typeof fn === "function") fn.apply(g, args); + else origSetTimeout(fn, 0); + }; + var id = origSetInterval(wrapped, delay); + intervals.add(id); + return id; + }; + + g.clearInterval = function (id) { + intervals.delete(id); + return origClearInterval(id); + }; + + g.setTimeout = function (fn, delay) { + if (disposed) return 0; + var args = Array.prototype.slice.call(arguments, 2); + var id = 0; + var wrapped = function () { + timeouts.delete(id); + if (disposed) return; + if (typeof fn === "function") fn.apply(g, args); + else origSetTimeout(fn, 0); + }; + id = origSetTimeout(wrapped, delay); + timeouts.add(id); + return id; + }; + + g.clearTimeout = function (id) { + timeouts.delete(id); + return origClearTimeout(id); + }; + + if (origRAF) { + g.requestAnimationFrame = function (cb) { + if (disposed) return 0; + if (frozen) { + heldRafCallbacks.push(cb); + return 0; + } + var id = 0; + id = origRAF(function (ts) { + rafIds.delete(id); + if (disposed) return; + if (frozen) { + heldRafCallbacks.push(cb); + return; + } + cb(ts); + }); + rafIds.add(id); + return id; + }; + } + + if (origCAF) { + g.cancelAnimationFrame = function (id) { + rafIds.delete(id); + return origCAF(id); + }; + } + + if (typeof g.WebSocket === "function") { + var NativeWS = g.WebSocket; + g.WebSocket = function (url, protocols) { + var ws = protocols !== undefined ? new NativeWS(url, protocols) : new NativeWS(url); + sockets.add(ws); + ws.addEventListener("close", function () { sockets.delete(ws); }); + return ws; + }; + g.WebSocket.prototype = NativeWS.prototype; + g.WebSocket.CONNECTING = NativeWS.CONNECTING; + g.WebSocket.OPEN = NativeWS.OPEN; + g.WebSocket.CLOSING = NativeWS.CLOSING; + g.WebSocket.CLOSED = NativeWS.CLOSED; + } + + if (typeof g.EventSource === "function") { + var NativeES = g.EventSource; + g.EventSource = function (url, cfg) { + var es = cfg !== undefined ? new NativeES(url, cfg) : new NativeES(url); + eventSources.add(es); + return es; + }; + g.EventSource.prototype = NativeES.prototype; + } + + if (typeof g.MutationObserver === "function") { + var NativeMO = g.MutationObserver; + g.MutationObserver = function (cb) { + var mo = new NativeMO(cb); + observers.add(mo); + return mo; + }; + g.MutationObserver.prototype = NativeMO.prototype; + } + + if (typeof g.ResizeObserver === "function") { + var NativeRO = g.ResizeObserver; + g.ResizeObserver = function (cb) { + var ro = new NativeRO(cb); + observers.add(ro); + return ro; + }; + g.ResizeObserver.prototype = NativeRO.prototype; + } + + function ensureFreezeStyle() { + if (document.getElementById("__pw_freeze_style")) return; + var st = document.createElement("style"); + st.id = "__pw_freeze_style"; + st.textContent = + "html.__pw-frozen *, html.__pw-frozen *::before, html.__pw-frozen *::after { " + + "animation-play-state: paused !important; transition: none !important; }"; + (document.head || document.documentElement).appendChild(st); + } + + g.__pwSetFrozen = function (shouldFreeze) { + var next = !!shouldFreeze; + if (next === frozen || disposed) return; + frozen = next; + ensureFreezeStyle(); + if (frozen) { + document.documentElement.classList.add("__pw-frozen"); + document.querySelectorAll("video, audio").forEach(function (m) { + try { + if (!m.paused) { + m.dataset.pwWasPlaying = "1"; + m.pause(); + } + } catch (_) {} + }); + } else { + document.documentElement.classList.remove("__pw-frozen"); + document.querySelectorAll("video, audio").forEach(function (m) { + try { + if (m.dataset.pwWasPlaying === "1") { + delete m.dataset.pwWasPlaying; + m.play().catch(function () {}); + } + } catch (_) {} + }); + var toResume = heldRafCallbacks.splice(0, heldRafCallbacks.length); + toResume.forEach(function (cb) { + try { g.requestAnimationFrame(cb); } catch (_) {} + }); + } + }; + + g.__pwPageDispose = function () { + if (disposed) return; + disposed = true; + frozen = true; + heldRafCallbacks.length = 0; + + intervals.forEach(function (id) { try { origClearInterval(id); } catch (_) {} }); + intervals.clear(); + timeouts.forEach(function (id) { try { origClearTimeout(id); } catch (_) {} }); + timeouts.clear(); + if (origCAF) { + rafIds.forEach(function (id) { try { origCAF(id); } catch (_) {} }); + } + rafIds.clear(); + + sockets.forEach(function (ws) { try { ws.close(); } catch (_) {} }); + sockets.clear(); + eventSources.forEach(function (es) { try { es.close(); } catch (_) {} }); + eventSources.clear(); + observers.forEach(function (ob) { try { ob.disconnect(); } catch (_) {} }); + observers.clear(); + + try { + if (g.echarts && typeof g.echarts.getInstanceByDom === "function") { + document.querySelectorAll("div, canvas").forEach(function (el) { + try { + var inst = g.echarts.getInstanceByDom(el); + if (inst && typeof inst.dispose === "function") inst.dispose(); + } catch (_) {} + }); + } + } catch (_) {} + + try { + document.querySelectorAll("video, audio").forEach(function (m) { + try { m.pause(); m.removeAttribute("src"); m.load(); } catch (_) {} + }); + } catch (_) {} + + try { + document.querySelectorAll("canvas").forEach(function (c) { + try { + var gl = c.getContext("webgl2") || c.getContext("webgl") || c.getContext("experimental-webgl"); + if (gl) { + var ext = gl.getExtension("WEBGL_lose_context"); + if (ext) ext.loseContext(); + } + } catch (_) {} + try { c.width = 0; c.height = 0; } catch (_) {} + }); + } catch (_) {} + }; + + // Wire error watchdog back to parent host/sandbox + function reportErr(source, msg, stack) { + if (disposed) return; + try { + if (g.parent && g.parent !== g && typeof g.parent.__pwOnStageError === "function") { + g.parent.__pwOnStageError(String(source || "runtime"), String(msg || "Unknown error"), String(stack || "")); + } + } catch (_) {} + } + + g.onerror = function (msg, url, line, col, err) { + reportErr("window.onerror", msg + " (" + line + ":" + col + ")", err && err.stack ? err.stack : ""); + return false; + }; + g.addEventListener("unhandledrejection", function (ev) { + var r = ev && ev.reason; + reportErr("unhandledrejection", r && r.message ? r.message : String(r), r && r.stack ? r.stack : ""); + }); + var origConsoleError = console.error; + console.error = function () { + try { + var parts = Array.prototype.slice.call(arguments).map(function (a) { + if (a instanceof Error) return a.message + "\n" + (a.stack || ""); + if (typeof a === "object") { try { return JSON.stringify(a); } catch (_) { return String(a); } } + return String(a); + }); + reportErr("console.error", parts.join(" "), ""); + } catch (_) {} + return origConsoleError.apply(console, arguments); + }; + + // Wire window.PulseWall API inside the isolated iframe + var parentPW = (g.parent && g.parent !== g && g.parent.PulseWall) ? g.parent.PulseWall : null; + g.__PW_DATA__ = (g.parent && g.parent !== g && g.parent.__PW_DATA__) ? g.parent.__PW_DATA__ : {}; + g.PulseWall = { + loadLib: function (names) { + return g.__pwLibLoader ? g.__pwLibLoader.loadLib(names) : Promise.reject(new Error("LibLoader unavailable")); + }, + libs: g.__pwLibLoader ? Object.keys(g.__pwLibLoader.catalog) : [], + sendAction: function (presetId, label, customText) { + if (parentPW && parentPW.sendAction) parentPW.sendAction(presetId, label, customText); + }, + openSettings: function () { + if (parentPW && parentPW.openSettings) parentPW.openSettings(); + }, + discoverHub: function () { + if (parentPW && parentPW.discoverHub) parentPW.discoverHub(); + }, + checkUpdate: function () { + if (parentPW && parentPW.checkUpdate) parentPW.checkUpdate(); + }, + getDeviceProfile: function () { + return parentPW && parentPW.getDeviceProfile ? parentPW.getDeviceProfile() : {}; + }, + getTelemetry: function () { + return parentPW && parentPW.getTelemetry ? parentPW.getTelemetry() : {}; + }, + getDataContext: function () { + return g.__PW_DATA__ || {}; + } + }; + + // Spatial D-Pad navigation inside the isolated iframe + var currentFocusEl = null; + function getFocusables() { + var nodes = document.querySelectorAll("button, a[href], input, select, textarea, [tabindex], [role='button'], [onclick], .pw-btn"); + return Array.prototype.slice.call(nodes).filter(function (el) { + if (el.disabled) return false; + var rect = el.getBoundingClientRect(); + return rect.width > 4 && rect.height > 4 && g.getComputedStyle(el).visibility !== "hidden"; + }); + } + function clearTvFocus() { + if (currentFocusEl) { + currentFocusEl.classList.remove("pw-tv-focus"); + currentFocusEl = null; + } + } + function setTvFocus(el) { + if (!el) return; + if (currentFocusEl && currentFocusEl !== el) currentFocusEl.classList.remove("pw-tv-focus"); + currentFocusEl = el; + el.classList.add("pw-tv-focus"); + try { el.focus({ preventScroll: true }); } catch (_) {} + try { el.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" }); } catch (_) {} + } + function findNextFocusable(dir) { + var list = getFocusables(); + if (!list.length) return null; + if (!currentFocusEl || list.indexOf(currentFocusEl) === -1) return list[0]; + var cur = currentFocusEl.getBoundingClientRect(); + var cx = cur.left + cur.width / 2; + var cy = cur.top + cur.height / 2; + var best = null; + var bestScore = Infinity; + for (var i = 0; i < list.length; i++) { + var el = list[i]; + if (el === currentFocusEl) continue; + var r = el.getBoundingClientRect(); + var dx = r.left + r.width / 2 - cx; + var dy = r.top + r.height / 2 - cy; + var valid = false, primary = 0, secondary = 0; + if (dir === "right" && dx > 6) { valid = true; primary = dx; secondary = Math.abs(dy); } + else if (dir === "left" && dx < -6) { valid = true; primary = -dx; secondary = Math.abs(dy); } + else if (dir === "down" && dy > 6) { valid = true; primary = dy; secondary = Math.abs(dx); } + else if (dir === "up" && dy < -6) { valid = true; primary = -dy; secondary = Math.abs(dx); } + if (valid) { + var score = primary + secondary * 2.2; + if (score < bestScore) { bestScore = score; best = el; } + } + } + return best; + } + + g.__pwClearTvFocus = clearTvFocus; + g.__pwFocusFirst = function () { + var list = getFocusables(); + if (list.length) setTvFocus(list[0]); + }; + g.__pwRemoteKey = function (dir) { + if (dir === "ok") { + if (!currentFocusEl || !document.body.contains(currentFocusEl)) g.__pwFocusFirst(); + if (currentFocusEl) currentFocusEl.click(); + return true; + } + var next = findNextFocusable(dir); + if (next) { setTvFocus(next); return true; } + if (dir === "down") { g.scrollBy({ top: 240, behavior: "smooth" }); return true; } + if (dir === "up") { g.scrollBy({ top: -240, behavior: "smooth" }); return true; } + return false; + }; + + document.addEventListener("DOMContentLoaded", function () { + try { + if (g.PwIcons && g.PwIcons.hydrate) g.PwIcons.hydrate(document.body); + } catch (_) {} + }); +})(window); diff --git a/android/app/src/main/assets/pulsewall/sandbox.html b/android/app/src/main/assets/pulsewall/sandbox.html new file mode 100644 index 0000000..7ef462a --- /dev/null +++ b/android/app/src/main/assets/pulsewall/sandbox.html @@ -0,0 +1,164 @@ + + + + + + PulseWall Validation Sandbox + + + +
+ + + diff --git a/android/app/src/main/assets/pulsewall/vue.global.prod.js b/android/app/src/main/assets/pulsewall/vue.global.prod.js new file mode 100644 index 0000000..b2cd5c3 --- /dev/null +++ b/android/app/src/main/assets/pulsewall/vue.global.prod.js @@ -0,0 +1,9 @@ +/** +* vue v3.5.13 +* (c) 2018-present Yuxi (Evan) You and Vue contributors +* @license MIT +**/var Vue=function(e){"use strict";var t,n;let r,i,l,s,o,a,c,u,d,p,f,h,m;function g(e){let t=Object.create(null);for(let n of e.split(","))t[n]=1;return e=>e in t}let y={},b=[],_=()=>{},S=()=>!1,x=e=>111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&(e.charCodeAt(2)>122||97>e.charCodeAt(2)),C=e=>e.startsWith("onUpdate:"),k=Object.assign,T=(e,t)=>{let n=e.indexOf(t);n>-1&&e.splice(n,1)},N=Object.prototype.hasOwnProperty,w=(e,t)=>N.call(e,t),A=Array.isArray,E=e=>"[object Map]"===V(e),I=e=>"[object Set]"===V(e),R=e=>"[object Date]"===V(e),O=e=>"[object RegExp]"===V(e),P=e=>"function"==typeof e,M=e=>"string"==typeof e,L=e=>"symbol"==typeof e,$=e=>null!==e&&"object"==typeof e,D=e=>($(e)||P(e))&&P(e.then)&&P(e.catch),F=Object.prototype.toString,V=e=>F.call(e),B=e=>V(e).slice(8,-1),U=e=>"[object Object]"===V(e),j=e=>M(e)&&"NaN"!==e&&"-"!==e[0]&&""+parseInt(e,10)===e,H=g(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),q=g("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"),W=e=>{let t=Object.create(null);return n=>t[n]||(t[n]=e(n))},K=/-(\w)/g,z=W(e=>e.replace(K,(e,t)=>t?t.toUpperCase():"")),J=/\B([A-Z])/g,G=W(e=>e.replace(J,"-$1").toLowerCase()),X=W(e=>e.charAt(0).toUpperCase()+e.slice(1)),Q=W(e=>e?`on${X(e)}`:""),Z=(e,t)=>!Object.is(e,t),Y=(e,...t)=>{for(let n=0;n{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},et=e=>{let t=parseFloat(e);return isNaN(t)?e:t},en=e=>{let t=M(e)?Number(e):NaN;return isNaN(t)?e:t},er=()=>r||(r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}),ei=g("Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol");function el(e){if(A(e)){let t={};for(let n=0;n{if(e){let n=e.split(eo);n.length>1&&(t[n[0].trim()]=n[1].trim())}}),t}function eu(e){let t="";if(M(e))t=e;else if(A(e))for(let n=0;neg(e,t))}let ev=e=>!!(e&&!0===e.__v_isRef),eb=e=>M(e)?e:null==e?"":A(e)||$(e)&&(e.toString===F||!P(e.toString))?ev(e)?eb(e.value):JSON.stringify(e,e_,2):String(e),e_=(e,t)=>ev(t)?e_(e,t.value):E(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((e,[t,n],r)=>(e[eS(t,r)+" =>"]=n,e),{})}:I(t)?{[`Set(${t.size})`]:[...t.values()].map(e=>eS(e))}:L(t)?eS(t):!$(t)||A(t)||U(t)?t:String(t),eS=(e,t="")=>{var n;return L(e)?`Symbol(${null!=(n=e.description)?n:t})`:e};class ex{constructor(e=!1){this.detached=e,this._active=!0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.parent=i,!e&&i&&(this.index=(i.scopes||(i.scopes=[])).push(this)-1)}get active(){return this._active}pause(){if(this._active){let e,t;if(this._isPaused=!0,this.scopes)for(e=0,t=this.scopes.length;e0)){if(o){let e=o;for(o=void 0;e;){let t=e.next;e.next=void 0,e.flags&=-9,e=t}}for(;s;){let t=s;for(s=void 0;t;){let n=t.next;if(t.next=void 0,t.flags&=-9,1&t.flags)try{t.trigger()}catch(t){e||(e=t)}t=n}}if(e)throw e}}function eA(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function eE(e){let t;let n=e.depsTail,r=n;for(;r;){let e=r.prevDep;-1===r.version?(r===n&&(n=e),eO(r),function(e){let{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}(r)):t=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=e}e.deps=t,e.depsTail=n}function eI(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(eR(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function eR(e){if(4&e.flags&&!(16&e.flags)||(e.flags&=-17,e.globalVersion===eF))return;e.globalVersion=eF;let t=e.dep;if(e.flags|=2,t.version>0&&!e.isSSR&&e.deps&&!eI(e)){e.flags&=-3;return}let n=l,r=eP;l=e,eP=!0;try{eA(e);let n=e.fn(e._value);(0===t.version||Z(n,e._value))&&(e._value=n,t.version++)}catch(e){throw t.version++,e}finally{l=n,eP=r,eE(e),e.flags&=-3}}function eO(e,t=!1){let{dep:n,prevSub:r,nextSub:i}=e;if(r&&(r.nextSub=i,e.prevSub=void 0),i&&(i.prevSub=r,e.nextSub=void 0),n.subs===e&&(n.subs=r,!r&&n.computed)){n.computed.flags&=-5;for(let e=n.computed.deps;e;e=e.nextDep)eO(e,!0)}t||--n.sc||!n.map||n.map.delete(n.key)}let eP=!0,eM=[];function eL(){eM.push(eP),eP=!1}function e$(){let e=eM.pop();eP=void 0===e||e}function eD(e){let{cleanup:t}=e;if(e.cleanup=void 0,t){let e=l;l=void 0;try{t()}finally{l=e}}}let eF=0;class eV{constructor(e,t){this.sub=e,this.dep=t,this.version=t.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class eB{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0}track(e){if(!l||!eP||l===this.computed)return;let t=this.activeLink;if(void 0===t||t.sub!==l)t=this.activeLink=new eV(l,this),l.deps?(t.prevDep=l.depsTail,l.depsTail.nextDep=t,l.depsTail=t):l.deps=l.depsTail=t,function e(t){if(t.dep.sc++,4&t.sub.flags){let n=t.dep.computed;if(n&&!t.dep.subs){n.flags|=20;for(let t=n.deps;t;t=t.nextDep)e(t)}let r=t.dep.subs;r!==t&&(t.prevSub=r,r&&(r.nextSub=t)),t.dep.subs=t}}(t);else if(-1===t.version&&(t.version=this.version,t.nextDep)){let e=t.nextDep;e.prevDep=t.prevDep,t.prevDep&&(t.prevDep.nextDep=e),t.prevDep=l.depsTail,t.nextDep=void 0,l.depsTail.nextDep=t,l.depsTail=t,l.deps===t&&(l.deps=e)}return t}trigger(e){this.version++,eF++,this.notify(e)}notify(e){eT++;try{for(let e=this.subs;e;e=e.prevSub)e.sub.notify()&&e.sub.dep.notify()}finally{ew()}}}let eU=new WeakMap,ej=Symbol(""),eH=Symbol(""),eq=Symbol("");function eW(e,t,n){if(eP&&l){let t=eU.get(e);t||eU.set(e,t=new Map);let r=t.get(n);r||(t.set(n,r=new eB),r.map=t,r.key=n),r.track()}}function eK(e,t,n,r,i,l){let s=eU.get(e);if(!s){eF++;return}let o=e=>{e&&e.trigger()};if(eT++,"clear"===t)s.forEach(o);else{let i=A(e),l=i&&j(n);if(i&&"length"===n){let e=Number(r);s.forEach((t,n)=>{("length"===n||n===eq||!L(n)&&n>=e)&&o(t)})}else switch((void 0!==n||s.has(void 0))&&o(s.get(n)),l&&o(s.get(eq)),t){case"add":i?l&&o(s.get("length")):(o(s.get(ej)),E(e)&&o(s.get(eH)));break;case"delete":!i&&(o(s.get(ej)),E(e)&&o(s.get(eH)));break;case"set":E(e)&&o(s.get(ej))}}ew()}function ez(e){let t=tx(e);return t===e?t:(eW(t,"iterate",eq),t_(e)?t:t.map(tk))}function eJ(e){return eW(e=tx(e),"iterate",eq),e}let eG={__proto__:null,[Symbol.iterator](){return eX(this,Symbol.iterator,tk)},concat(...e){return ez(this).concat(...e.map(e=>A(e)?ez(e):e))},entries(){return eX(this,"entries",e=>(e[1]=tk(e[1]),e))},every(e,t){return eZ(this,"every",e,t,void 0,arguments)},filter(e,t){return eZ(this,"filter",e,t,e=>e.map(tk),arguments)},find(e,t){return eZ(this,"find",e,t,tk,arguments)},findIndex(e,t){return eZ(this,"findIndex",e,t,void 0,arguments)},findLast(e,t){return eZ(this,"findLast",e,t,tk,arguments)},findLastIndex(e,t){return eZ(this,"findLastIndex",e,t,void 0,arguments)},forEach(e,t){return eZ(this,"forEach",e,t,void 0,arguments)},includes(...e){return e0(this,"includes",e)},indexOf(...e){return e0(this,"indexOf",e)},join(e){return ez(this).join(e)},lastIndexOf(...e){return e0(this,"lastIndexOf",e)},map(e,t){return eZ(this,"map",e,t,void 0,arguments)},pop(){return e1(this,"pop")},push(...e){return e1(this,"push",e)},reduce(e,...t){return eY(this,"reduce",e,t)},reduceRight(e,...t){return eY(this,"reduceRight",e,t)},shift(){return e1(this,"shift")},some(e,t){return eZ(this,"some",e,t,void 0,arguments)},splice(...e){return e1(this,"splice",e)},toReversed(){return ez(this).toReversed()},toSorted(e){return ez(this).toSorted(e)},toSpliced(...e){return ez(this).toSpliced(...e)},unshift(...e){return e1(this,"unshift",e)},values(){return eX(this,"values",tk)}};function eX(e,t,n){let r=eJ(e),i=r[t]();return r===e||t_(e)||(i._next=i.next,i.next=()=>{let e=i._next();return e.value&&(e.value=n(e.value)),e}),i}let eQ=Array.prototype;function eZ(e,t,n,r,i,l){let s=eJ(e),o=s!==e&&!t_(e),a=s[t];if(a!==eQ[t]){let t=a.apply(e,l);return o?tk(t):t}let c=n;s!==e&&(o?c=function(t,r){return n.call(this,tk(t),r,e)}:n.length>2&&(c=function(t,r){return n.call(this,t,r,e)}));let u=a.call(s,c,r);return o&&i?i(u):u}function eY(e,t,n,r){let i=eJ(e),l=n;return i!==e&&(t_(e)?n.length>3&&(l=function(t,r,i){return n.call(this,t,r,i,e)}):l=function(t,r,i){return n.call(this,t,tk(r),i,e)}),i[t](l,...r)}function e0(e,t,n){let r=tx(e);eW(r,"iterate",eq);let i=r[t](...n);return(-1===i||!1===i)&&tS(n[0])?(n[0]=tx(n[0]),r[t](...n)):i}function e1(e,t,n=[]){eL(),eT++;let r=tx(e)[t].apply(e,n);return ew(),e$(),r}let e2=g("__proto__,__v_isRef,__isVue"),e3=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>"arguments"!==e&&"caller"!==e).map(e=>Symbol[e]).filter(L));function e6(e){L(e)||(e=String(e));let t=tx(this);return eW(t,"has",e),t.hasOwnProperty(e)}class e4{constructor(e=!1,t=!1){this._isReadonly=e,this._isShallow=t}get(e,t,n){if("__v_skip"===t)return e.__v_skip;let r=this._isReadonly,i=this._isShallow;if("__v_isReactive"===t)return!r;if("__v_isReadonly"===t)return r;if("__v_isShallow"===t)return i;if("__v_raw"===t)return n===(r?i?tf:tp:i?td:tu).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(n)?e:void 0;let l=A(e);if(!r){let e;if(l&&(e=eG[t]))return e;if("hasOwnProperty"===t)return e6}let s=Reflect.get(e,t,tN(e)?e:n);return(L(t)?e3.has(t):e2(t))?s:(r||eW(e,"get",t),i)?s:tN(s)?l&&j(t)?s:s.value:$(s)?r?tg(s):th(s):s}}class e8 extends e4{constructor(e=!1){super(!1,e)}set(e,t,n,r){let i=e[t];if(!this._isShallow){let t=tb(i);if(t_(n)||tb(n)||(i=tx(i),n=tx(n)),!A(e)&&tN(i)&&!tN(n))return!t&&(i.value=n,!0)}let l=A(e)&&j(t)?Number(t)e,tr=e=>Reflect.getPrototypeOf(e);function ti(e){return function(...t){return"delete"!==e&&("clear"===e?void 0:this)}}function tl(e,t){let n=function(e,t){let n={get(n){let r=this.__v_raw,i=tx(r),l=tx(n);e||(Z(n,l)&&eW(i,"get",n),eW(i,"get",l));let{has:s}=tr(i),o=t?tn:e?tT:tk;return s.call(i,n)?o(r.get(n)):s.call(i,l)?o(r.get(l)):void(r!==i&&r.get(n))},get size(){let t=this.__v_raw;return e||eW(tx(t),"iterate",ej),Reflect.get(t,"size",t)},has(t){let n=this.__v_raw,r=tx(n),i=tx(t);return e||(Z(t,i)&&eW(r,"has",t),eW(r,"has",i)),t===i?n.has(t):n.has(t)||n.has(i)},forEach(n,r){let i=this,l=i.__v_raw,s=tx(l),o=t?tn:e?tT:tk;return e||eW(s,"iterate",ej),l.forEach((e,t)=>n.call(r,o(e),o(t),i))}};return k(n,e?{add:ti("add"),set:ti("set"),delete:ti("delete"),clear:ti("clear")}:{add(e){t||t_(e)||tb(e)||(e=tx(e));let n=tx(this);return tr(n).has.call(n,e)||(n.add(e),eK(n,"add",e,e)),this},set(e,n){t||t_(n)||tb(n)||(n=tx(n));let r=tx(this),{has:i,get:l}=tr(r),s=i.call(r,e);s||(e=tx(e),s=i.call(r,e));let o=l.call(r,e);return r.set(e,n),s?Z(n,o)&&eK(r,"set",e,n):eK(r,"add",e,n),this},delete(e){let t=tx(this),{has:n,get:r}=tr(t),i=n.call(t,e);i||(e=tx(e),i=n.call(t,e)),r&&r.call(t,e);let l=t.delete(e);return i&&eK(t,"delete",e,void 0),l},clear(){let e=tx(this),t=0!==e.size,n=e.clear();return t&&eK(e,"clear",void 0,void 0),n}}),["keys","values","entries",Symbol.iterator].forEach(r=>{n[r]=function(...n){let i=this.__v_raw,l=tx(i),s=E(l),o="entries"===r||r===Symbol.iterator&&s,a=i[r](...n),c=t?tn:e?tT:tk;return e||eW(l,"iterate","keys"===r&&s?eH:ej),{next(){let{value:e,done:t}=a.next();return t?{value:e,done:t}:{value:o?[c(e[0]),c(e[1])]:c(e),done:t}},[Symbol.iterator](){return this}}}}),n}(e,t);return(t,r,i)=>"__v_isReactive"===r?!e:"__v_isReadonly"===r?e:"__v_raw"===r?t:Reflect.get(w(n,r)&&r in t?n:t,r,i)}let ts={get:tl(!1,!1)},to={get:tl(!1,!0)},ta={get:tl(!0,!1)},tc={get:tl(!0,!0)},tu=new WeakMap,td=new WeakMap,tp=new WeakMap,tf=new WeakMap;function th(e){return tb(e)?e:ty(e,!1,e9,ts,tu)}function tm(e){return ty(e,!1,te,to,td)}function tg(e){return ty(e,!0,e7,ta,tp)}function ty(e,t,n,r,i){if(!$(e)||e.__v_raw&&!(t&&e.__v_isReactive))return e;let l=i.get(e);if(l)return l;let s=e.__v_skip||!Object.isExtensible(e)?0:function(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(B(e));if(0===s)return e;let o=new Proxy(e,2===s?r:n);return i.set(e,o),o}function tv(e){return tb(e)?tv(e.__v_raw):!!(e&&e.__v_isReactive)}function tb(e){return!!(e&&e.__v_isReadonly)}function t_(e){return!!(e&&e.__v_isShallow)}function tS(e){return!!e&&!!e.__v_raw}function tx(e){let t=e&&e.__v_raw;return t?tx(t):e}function tC(e){return!w(e,"__v_skip")&&Object.isExtensible(e)&&ee(e,"__v_skip",!0),e}let tk=e=>$(e)?th(e):e,tT=e=>$(e)?tg(e):e;function tN(e){return!!e&&!0===e.__v_isRef}function tw(e){return tE(e,!1)}function tA(e){return tE(e,!0)}function tE(e,t){return tN(e)?e:new tI(e,t)}class tI{constructor(e,t){this.dep=new eB,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=t?e:tx(e),this._value=t?e:tk(e),this.__v_isShallow=t}get value(){return this.dep.track(),this._value}set value(e){let t=this._rawValue,n=this.__v_isShallow||t_(e)||tb(e);Z(e=n?e:tx(e),t)&&(this._rawValue=e,this._value=n?e:tk(e),this.dep.trigger())}}function tR(e){return tN(e)?e.value:e}let tO={get:(e,t,n)=>"__v_raw"===t?e:tR(Reflect.get(e,t,n)),set:(e,t,n,r)=>{let i=e[t];return tN(i)&&!tN(n)?(i.value=n,!0):Reflect.set(e,t,n,r)}};function tP(e){return tv(e)?e:new Proxy(e,tO)}class tM{constructor(e){this.__v_isRef=!0,this._value=void 0;let t=this.dep=new eB,{get:n,set:r}=e(t.track.bind(t),t.trigger.bind(t));this._get=n,this._set=r}get value(){return this._value=this._get()}set value(e){this._set(e)}}function tL(e){return new tM(e)}class t${constructor(e,t,n){this._object=e,this._key=t,this._defaultValue=n,this.__v_isRef=!0,this._value=void 0}get value(){let e=this._object[this._key];return this._value=void 0===e?this._defaultValue:e}set value(e){this._object[this._key]=e}get dep(){return function(e,t){let n=eU.get(e);return n&&n.get(t)}(tx(this._object),this._key)}}class tD{constructor(e){this._getter=e,this.__v_isRef=!0,this.__v_isReadonly=!0,this._value=void 0}get value(){return this._value=this._getter()}}function tF(e,t,n){let r=e[t];return tN(r)?r:new t$(e,t,n)}class tV{constructor(e,t,n){this.fn=e,this.setter=t,this._value=void 0,this.dep=new eB(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=eF-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!t,this.isSSR=n}notify(){if(this.flags|=16,!(8&this.flags)&&l!==this)return eN(this,!0),!0}get value(){let e=this.dep.track();return eR(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}}let tB={},tU=new WeakMap;function tj(e,t=!1,n=h){if(n){let t=tU.get(n);t||tU.set(n,t=[]),t.push(e)}}function tH(e,t=1/0,n){if(t<=0||!$(e)||e.__v_skip||(n=n||new Set).has(e))return e;if(n.add(e),t--,tN(e))tH(e.value,t,n);else if(A(e))for(let r=0;r{tH(e,t,n)});else if(U(e)){for(let r in e)tH(e[r],t,n);for(let r of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,r)&&tH(e[r],t,n)}return e}function tq(e,t,n,r){try{return r?e(...r):e()}catch(e){tK(e,t,n)}}function tW(e,t,n,r){if(P(e)){let i=tq(e,t,n,r);return i&&D(i)&&i.catch(e=>{tK(e,t,n)}),i}if(A(e)){let i=[];for(let l=0;l=t8(n)?tz.push(e):tz.splice(function(e){let t=tJ+1,n=tz.length;for(;t>>1,i=tz[r],l=t8(i);lt8(e)-t8(t));if(tG.length=0,tX){tX.push(...e);return}for(tQ=0,tX=e;tQnull==e.id?2&e.flags?-1:1/0:e.id,t5=null,t9=null;function t7(e){let t=t5;return t5=e,t9=e&&e.type.__scopeId||null,t}function ne(e,t=t5,n){if(!t||e._n)return e;let r=(...n)=>{let i;r._d&&im(-1);let l=t7(t);try{i=e(...n)}finally{t7(l),r._d&&im(1)}return i};return r._n=!0,r._c=!0,r._d=!0,r}function nt(e,t,n,r){let i=e.dirs,l=t&&t.dirs;for(let s=0;se.__isTeleport,ni=e=>e&&(e.disabled||""===e.disabled),nl=e=>e&&(e.defer||""===e.defer),ns=e=>"undefined"!=typeof SVGElement&&e instanceof SVGElement,no=e=>"function"==typeof MathMLElement&&e instanceof MathMLElement,na=(e,t)=>{let n=e&&e.to;return M(n)?t?t(n):null:n},nc={name:"Teleport",__isTeleport:!0,process(e,t,n,r,i,l,s,o,a,c){let{mc:u,pc:d,pbc:p,o:{insert:f,querySelector:h,createText:m,createComment:g}}=c,y=ni(t.props),{shapeFlag:b,children:_,dynamicChildren:S}=t;if(null==e){let e=t.el=m(""),c=t.anchor=m("");f(e,n,r),f(c,n,r);let d=(e,t)=>{16&b&&(i&&i.isCE&&(i.ce._teleportTarget=e),u(_,e,t,i,l,s,o,a))},p=()=>{let e=t.target=na(t.props,h),n=np(e,t,m,f);e&&("svg"!==s&&ns(e)?s="svg":"mathml"!==s&&no(e)&&(s="mathml"),y||(d(e,n),nd(t,!1)))};y&&(d(n,c),nd(t,!0)),nl(t.props)?rB(()=>{p(),t.el.__isMounted=!0},l):p()}else{if(nl(t.props)&&!e.el.__isMounted){rB(()=>{nc.process(e,t,n,r,i,l,s,o,a,c),delete e.el.__isMounted},l);return}t.el=e.el,t.targetStart=e.targetStart;let u=t.anchor=e.anchor,f=t.target=e.target,m=t.targetAnchor=e.targetAnchor,g=ni(e.props),b=g?n:f;if("svg"===s||ns(f)?s="svg":("mathml"===s||no(f))&&(s="mathml"),S?(p(e.dynamicChildren,S,b,i,l,s,o),rK(e,t,!0)):a||d(e,t,b,g?u:m,i,l,s,o,!1),y)g?t.props&&e.props&&t.props.to!==e.props.to&&(t.props.to=e.props.to):nu(t,n,u,c,1);else if((t.props&&t.props.to)!==(e.props&&e.props.to)){let e=t.target=na(t.props,h);e&&nu(t,e,null,c,0)}else g&&nu(t,f,m,c,1);nd(t,y)}},remove(e,t,n,{um:r,o:{remove:i}},l){let{shapeFlag:s,children:o,anchor:a,targetStart:c,targetAnchor:u,target:d,props:p}=e;if(d&&(i(c),i(u)),l&&i(a),16&s){let e=l||!ni(p);for(let i=0;i{e.isMounted=!0}),n3(()=>{e.isUnmounting=!0}),e}let ng=[Function,Array],ny={mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:ng,onEnter:ng,onAfterEnter:ng,onEnterCancelled:ng,onBeforeLeave:ng,onLeave:ng,onAfterLeave:ng,onLeaveCancelled:ng,onBeforeAppear:ng,onAppear:ng,onAfterAppear:ng,onAppearCancelled:ng},nv=e=>{let t=e.subTree;return t.component?nv(t.component):t};function nb(e){let t=e[0];if(e.length>1){for(let n of e)if(n.type!==io){t=n;break}}return t}let n_={name:"BaseTransition",props:ny,setup(e,{slots:t}){let n=iL(),r=nm();return()=>{let i=t.default&&nN(t.default(),!0);if(!i||!i.length)return;let l=nb(i),s=tx(e),{mode:o}=s;if(r.isLeaving)return nC(l);let a=nk(l);if(!a)return nC(l);let c=nx(a,s,r,n,e=>c=e);a.type!==io&&nT(a,c);let u=n.subTree&&nk(n.subTree);if(u&&u.type!==io&&!ib(a,u)&&nv(n).type!==io){let e=nx(u,s,r,n);if(nT(u,e),"out-in"===o&&a.type!==io)return r.isLeaving=!0,e.afterLeave=()=>{r.isLeaving=!1,8&n.job.flags||n.update(),delete e.afterLeave,u=void 0},nC(l);"in-out"===o&&a.type!==io?e.delayLeave=(e,t,n)=>{nS(r,u)[String(u.key)]=u,e[nf]=()=>{t(),e[nf]=void 0,delete c.delayedLeave,u=void 0},c.delayedLeave=()=>{n(),delete c.delayedLeave,u=void 0}}:u=void 0}else u&&(u=void 0);return l}}};function nS(e,t){let{leavingVNodes:n}=e,r=n.get(t.type);return r||(r=Object.create(null),n.set(t.type,r)),r}function nx(e,t,n,r,i){let{appear:l,mode:s,persisted:o=!1,onBeforeEnter:a,onEnter:c,onAfterEnter:u,onEnterCancelled:d,onBeforeLeave:p,onLeave:f,onAfterLeave:h,onLeaveCancelled:m,onBeforeAppear:g,onAppear:y,onAfterAppear:b,onAppearCancelled:_}=t,S=String(e.key),x=nS(n,e),C=(e,t)=>{e&&tW(e,r,9,t)},k=(e,t)=>{let n=t[1];C(e,t),A(e)?e.every(e=>e.length<=1)&&n():e.length<=1&&n()},T={mode:s,persisted:o,beforeEnter(t){let r=a;if(!n.isMounted){if(!l)return;r=g||a}t[nf]&&t[nf](!0);let i=x[S];i&&ib(e,i)&&i.el[nf]&&i.el[nf](),C(r,[t])},enter(e){let t=c,r=u,i=d;if(!n.isMounted){if(!l)return;t=y||c,r=b||u,i=_||d}let s=!1,o=e[nh]=t=>{s||(s=!0,t?C(i,[e]):C(r,[e]),T.delayedLeave&&T.delayedLeave(),e[nh]=void 0)};t?k(t,[e,o]):o()},leave(t,r){let i=String(e.key);if(t[nh]&&t[nh](!0),n.isUnmounting)return r();C(p,[t]);let l=!1,s=t[nf]=n=>{l||(l=!0,r(),n?C(m,[t]):C(h,[t]),t[nf]=void 0,x[i]!==e||delete x[i])};x[i]=e,f?k(f,[t,s]):s()},clone(e){let l=nx(e,t,n,r,i);return i&&i(l),l}};return T}function nC(e){if(nq(e))return(e=iT(e)).children=null,e}function nk(e){if(!nq(e))return nr(e.type)&&e.children?nb(e.children):e;let{shapeFlag:t,children:n}=e;if(n){if(16&t)return n[0];if(32&t&&P(n.default))return n.default()}}function nT(e,t){6&e.shapeFlag&&e.component?(e.transition=t,nT(e.component.subTree,t)):128&e.shapeFlag?(e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback)):e.transition=t}function nN(e,t=!1,n){let r=[],i=0;for(let l=0;l1)for(let e=0;enE(e,t&&(A(t)?t[l]:t),n,r,i));return}if(nj(r)&&!i){512&r.shapeFlag&&r.type.__asyncResolved&&r.component.subTree.component&&nE(e,t,n,r.component.subTree);return}let l=4&r.shapeFlag?iW(r.component):r.el,s=i?null:l,{i:o,r:a}=e,c=t&&t.r,u=o.refs===y?o.refs={}:o.refs,d=o.setupState,p=tx(d),f=d===y?()=>!1:e=>w(p,e);if(null!=c&&c!==a&&(M(c)?(u[c]=null,f(c)&&(d[c]=null)):tN(c)&&(c.value=null)),P(a))tq(a,o,12,[s,u]);else{let t=M(a),r=tN(a);if(t||r){let o=()=>{if(e.f){let n=t?f(a)?d[a]:u[a]:a.value;i?A(n)&&T(n,l):A(n)?n.includes(l)||n.push(l):t?(u[a]=[l],f(a)&&(d[a]=u[a])):(a.value=[l],e.k&&(u[e.k]=a.value))}else t?(u[a]=s,f(a)&&(d[a]=s)):r&&(a.value=s,e.k&&(u[e.k]=s))};s?(o.id=-1,rB(o,n)):o()}}}let nI=!1,nR=()=>{nI||(console.error("Hydration completed but contains mismatches."),nI=!0)},nO=e=>e.namespaceURI.includes("svg")&&"foreignObject"!==e.tagName,nP=e=>e.namespaceURI.includes("MathML"),nM=e=>{if(1===e.nodeType){if(nO(e))return"svg";if(nP(e))return"mathml"}},nL=e=>8===e.nodeType;function n$(e){let{mt:t,p:n,o:{patchProp:r,createText:i,nextSibling:l,parentNode:s,remove:o,insert:a,createComment:c}}=e,u=(n,r,o,c,b,_=!1)=>{_=_||!!r.dynamicChildren;let S=nL(n)&&"["===n.data,x=()=>h(n,r,o,c,b,S),{type:C,ref:k,shapeFlag:T,patchFlag:N}=r,w=n.nodeType;r.el=n,-2===N&&(_=!1,r.dynamicChildren=null);let A=null;switch(C){case is:3!==w?""===r.children?(a(r.el=i(""),s(n),n),A=n):A=x():(n.data!==r.children&&(nR(),n.data=r.children),A=l(n));break;case io:y(n)?(A=l(n),g(r.el=n.content.firstChild,n,o)):A=8!==w||S?x():l(n);break;case ia:if(S&&(w=(n=l(n)).nodeType),1===w||3===w){A=n;let e=!r.children.length;for(let t=0;t{s=s||!!t.dynamicChildren;let{type:a,props:c,patchFlag:u,shapeFlag:d,dirs:f,transition:h}=t,m="input"===a||"option"===a;if(m||-1!==u){let a;f&&nt(t,null,n,"created");let b=!1;if(y(e)){b=rW(null,h)&&n&&n.vnode.props&&n.vnode.props.appear;let r=e.content.firstChild;b&&h.beforeEnter(r),g(r,e,n),t.el=e=r}if(16&d&&!(c&&(c.innerHTML||c.textContent))){let r=p(e.firstChild,t,e,n,i,l,s);for(;r;){nV(e,1)||nR();let t=r;r=r.nextSibling,o(t)}}else if(8&d){let n=t.children;"\n"===n[0]&&("PRE"===e.tagName||"TEXTAREA"===e.tagName)&&(n=n.slice(1)),e.textContent!==n&&(nV(e,0)||nR(),e.textContent=t.children)}if(c){if(m||!s||48&u){let t=e.tagName.includes("-");for(let i in c)(m&&(i.endsWith("value")||"indeterminate"===i)||x(i)&&!H(i)||"."===i[0]||t)&&r(e,i,null,c[i],void 0,n)}else if(c.onClick)r(e,"onClick",null,c.onClick,void 0,n);else if(4&u&&tv(c.style))for(let e in c.style)c.style[e]}(a=c&&c.onVnodeBeforeMount)&&iR(a,n,t),f&&nt(t,null,n,"beforeMount"),((a=c&&c.onVnodeMounted)||f||b)&&ir(()=>{a&&iR(a,n,t),b&&h.enter(e),f&&nt(t,null,n,"mounted")},i)}return e.nextSibling},p=(e,t,r,s,o,c,d)=>{d=d||!!t.dynamicChildren;let p=t.children,f=p.length;for(let t=0;t{let{slotScopeIds:u}=t;u&&(i=i?i.concat(u):u);let d=s(e),f=p(l(e),t,d,n,r,i,o);return f&&nL(f)&&"]"===f.data?l(t.anchor=f):(nR(),a(t.anchor=c("]"),d,f),f)},h=(e,t,r,i,a,c)=>{if(nV(e.parentElement,1)||nR(),t.el=null,c){let t=m(e);for(;;){let n=l(e);if(n&&n!==t)o(n);else break}}let u=l(e),d=s(e);return o(e),n(null,t,d,u,r,i,nM(d),a),r&&(r.vnode.el=t.el,r8(r,t.el)),u},m=(e,t="[",n="]")=>{let r=0;for(;e;)if((e=l(e))&&nL(e)&&(e.data===t&&r++,e.data===n)){if(0===r)return l(e);r--}return e},g=(e,t,n)=>{let r=t.parentNode;r&&r.replaceChild(e,t);let i=n;for(;i;)i.vnode.el===t&&(i.vnode.el=i.subTree.el=e),i=i.parent},y=e=>1===e.nodeType&&"TEMPLATE"===e.tagName;return[(e,t)=>{if(!t.hasChildNodes()){n(null,e,t),t4(),t._vnode=e;return}u(t.firstChild,e,null,null,null),t4(),t._vnode=e},u]}let nD="data-allow-mismatch",nF={0:"text",1:"children",2:"class",3:"style",4:"attribute"};function nV(e,t){if(0===t||1===t)for(;e&&!e.hasAttribute(nD);)e=e.parentElement;let n=e&&e.getAttribute(nD);if(null==n)return!1;if(""===n)return!0;{let e=n.split(",");return!!(0===t&&e.includes("children"))||n.split(",").includes(nF[t])}}let nB=er().requestIdleCallback||(e=>setTimeout(e,1)),nU=er().cancelIdleCallback||(e=>clearTimeout(e)),nj=e=>!!e.type.__asyncLoader;function nH(e,t){let{ref:n,props:r,children:i,ce:l}=t.vnode,s=iC(e,r,i);return s.ref=n,s.ce=l,delete t.vnode.ce,s}let nq=e=>e.type.__isKeepAlive;function nW(e,t){return A(e)?e.some(e=>nW(e,t)):M(e)?e.split(",").includes(t):!!O(e)&&(e.lastIndex=0,e.test(t))}function nK(e,t){nJ(e,"a",t)}function nz(e,t){nJ(e,"da",t)}function nJ(e,t,n=iM){let r=e.__wdc||(e.__wdc=()=>{let t=n;for(;t;){if(t.isDeactivated)return;t=t.parent}return e()});if(nQ(t,r,n),n){let e=n.parent;for(;e&&e.parent;)nq(e.parent.vnode)&&function(e,t,n,r){let i=nQ(t,e,r,!0);n6(()=>{T(r[t],i)},n)}(r,t,n,e),e=e.parent}}function nG(e){e.shapeFlag&=-257,e.shapeFlag&=-513}function nX(e){return 128&e.shapeFlag?e.ssContent:e}function nQ(e,t,n=iM,r=!1){if(n){let i=n[e]||(n[e]=[]),l=t.__weh||(t.__weh=(...r)=>{eL();let i=i$(n),l=tW(t,n,e,r);return i(),e$(),l});return r?i.unshift(l):i.push(l),l}}let nZ=e=>(t,n=iM)=>{iV&&"sp"!==e||nQ(e,(...e)=>t(...e),n)},nY=nZ("bm"),n0=nZ("m"),n1=nZ("bu"),n2=nZ("u"),n3=nZ("bum"),n6=nZ("um"),n4=nZ("sp"),n8=nZ("rtg"),n5=nZ("rtc");function n9(e,t=iM){nQ("ec",e,t)}let n7="components",re=Symbol.for("v-ndc");function rt(e,t,n=!0,r=!1){let i=t5||iM;if(i){let n=i.type;if(e===n7){let e=iK(n,!1);if(e&&(e===t||e===z(t)||e===X(z(t))))return n}let l=rn(i[e]||n[e],t)||rn(i.appContext[e],t);return!l&&r?n:l}}function rn(e,t){return e&&(e[t]||e[z(t)]||e[X(z(t))])}let rr=e=>e?iF(e)?iW(e):rr(e.parent):null,ri=k(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>e.props,$attrs:e=>e.attrs,$slots:e=>e.slots,$refs:e=>e.refs,$parent:e=>rr(e.parent),$root:e=>rr(e.root),$host:e=>e.ce,$emit:e=>e.emit,$options:e=>rp(e),$forceUpdate:e=>e.f||(e.f=()=>{t1(e.update)}),$nextTick:e=>e.n||(e.n=t0.bind(e.proxy)),$watch:e=>rQ.bind(e)}),rl=(e,t)=>e!==y&&!e.__isScriptSetup&&w(e,t),rs={get({_:e},t){let n,r,i;if("__v_skip"===t)return!0;let{ctx:l,setupState:s,data:o,props:a,accessCache:c,type:u,appContext:d}=e;if("$"!==t[0]){let r=c[t];if(void 0!==r)switch(r){case 1:return s[t];case 2:return o[t];case 4:return l[t];case 3:return a[t]}else{if(rl(s,t))return c[t]=1,s[t];if(o!==y&&w(o,t))return c[t]=2,o[t];if((n=e.propsOptions[0])&&w(n,t))return c[t]=3,a[t];if(l!==y&&w(l,t))return c[t]=4,l[t];ru&&(c[t]=0)}}let p=ri[t];return p?("$attrs"===t&&eW(e.attrs,"get",""),p(e)):(r=u.__cssModules)&&(r=r[t])?r:l!==y&&w(l,t)?(c[t]=4,l[t]):w(i=d.config.globalProperties,t)?i[t]:void 0},set({_:e},t,n){let{data:r,setupState:i,ctx:l}=e;return rl(i,t)?(i[t]=n,!0):r!==y&&w(r,t)?(r[t]=n,!0):!w(e.props,t)&&!("$"===t[0]&&t.slice(1)in e)&&(l[t]=n,!0)},has({_:{data:e,setupState:t,accessCache:n,ctx:r,appContext:i,propsOptions:l}},s){let o;return!!n[s]||e!==y&&w(e,s)||rl(t,s)||(o=l[0])&&w(o,s)||w(r,s)||w(ri,s)||w(i.config.globalProperties,s)},defineProperty(e,t,n){return null!=n.get?e._.accessCache[t]=0:w(n,"value")&&this.set(e,t,n.value,null),Reflect.defineProperty(e,t,n)}},ro=k({},rs,{get(e,t){if(t!==Symbol.unscopables)return rs.get(e,t,e)},has:(e,t)=>"_"!==t[0]&&!ei(t)});function ra(){let e=iL();return e.setupContext||(e.setupContext=iq(e))}function rc(e){return A(e)?e.reduce((e,t)=>(e[t]=null,e),{}):e}let ru=!0;function rd(e,t,n){tW(A(e)?e.map(e=>e.bind(t.proxy)):e.bind(t.proxy),t,n)}function rp(e){let t;let n=e.type,{mixins:r,extends:i}=n,{mixins:l,optionsCache:s,config:{optionMergeStrategies:o}}=e.appContext,a=s.get(n);return a?t=a:l.length||r||i?(t={},l.length&&l.forEach(e=>rf(t,e,o,!0)),rf(t,n,o)):t=n,$(n)&&s.set(n,t),t}function rf(e,t,n,r=!1){let{mixins:i,extends:l}=t;for(let s in l&&rf(e,l,n,!0),i&&i.forEach(t=>rf(e,t,n,!0)),t)if(r&&"expose"===s);else{let r=rh[s]||n&&n[s];e[s]=r?r(e[s],t[s]):t[s]}return e}let rh={data:rm,props:rb,emits:rb,methods:rv,computed:rv,beforeCreate:ry,created:ry,beforeMount:ry,mounted:ry,beforeUpdate:ry,updated:ry,beforeDestroy:ry,beforeUnmount:ry,destroyed:ry,unmounted:ry,activated:ry,deactivated:ry,errorCaptured:ry,serverPrefetch:ry,components:rv,directives:rv,watch:function(e,t){if(!e)return t;if(!t)return e;let n=k(Object.create(null),e);for(let r in t)n[r]=ry(e[r],t[r]);return n},provide:rm,inject:function(e,t){return rv(rg(e),rg(t))}};function rm(e,t){return t?e?function(){return k(P(e)?e.call(this,this):e,P(t)?t.call(this,this):t)}:t:e}function rg(e){if(A(e)){let t={};for(let n=0;n1)return n&&P(t)?t.call(r&&r.proxy):t}}let rT={},rN=()=>Object.create(rT),rw=e=>Object.getPrototypeOf(e)===rT;function rA(e,t,n,r){let i;let[l,s]=e.propsOptions,o=!1;if(t)for(let a in t){let c;if(H(a))continue;let u=t[a];l&&w(l,c=z(a))?s&&s.includes(c)?(i||(i={}))[c]=u:n[c]=u:r1(e.emitsOptions,a)||a in r&&u===r[a]||(r[a]=u,o=!0)}if(s){let t=tx(n),r=i||y;for(let i=0;i"_"===e[0]||"$stable"===e,rP=e=>A(e)?e.map(iw):[iw(e)],rM=(e,t,n)=>{if(t._n)return t;let r=ne((...e)=>rP(t(...e)),n);return r._c=!1,r},rL=(e,t,n)=>{let r=e._ctx;for(let n in e){if(rO(n))continue;let i=e[n];if(P(i))t[n]=rM(n,i,r);else if(null!=i){let e=rP(i);t[n]=()=>e}}},r$=(e,t)=>{let n=rP(t);e.slots.default=()=>n},rD=(e,t,n)=>{for(let r in t)(n||"_"!==r)&&(e[r]=t[r])},rF=(e,t,n)=>{let r=e.slots=rN();if(32&e.vnode.shapeFlag){let e=t._;e?(rD(r,t,n),n&&ee(r,"_",e,!0)):rL(t,r)}else t&&r$(e,t)},rV=(e,t,n)=>{let{vnode:r,slots:i}=e,l=!0,s=y;if(32&r.shapeFlag){let e=t._;e?n&&1===e?l=!1:rD(i,t,n):(l=!t.$stable,rL(t,i)),s=t}else t&&(r$(e,t),s={default:1});if(l)for(let e in i)rO(e)||null!=s[e]||delete i[e]},rB=ir;function rU(e){return rj(e,n$)}function rj(e,t){var n;let r,i;er().__VUE__=!0;let{insert:l,remove:s,patchProp:o,createElement:a,createText:u,createComment:d,setText:p,setElementText:f,parentNode:h,nextSibling:m,setScopeId:g=_,insertStaticContent:S}=e,x=(e,t,n,r=null,i=null,l=null,s,o=null,a=!!t.dynamicChildren)=>{if(e===t)return;e&&!ib(e,t)&&(r=eo(e),et(e,i,l,!0),e=null),-2===t.patchFlag&&(a=!1,t.dynamicChildren=null);let{type:c,ref:u,shapeFlag:d}=t;switch(c){case is:C(e,t,n,r);break;case io:T(e,t,n,r);break;case ia:null==e&&N(t,n,r,s);break;case il:U(e,t,n,r,i,l,s,o,a);break;default:1&d?R(e,t,n,r,i,l,s,o,a):6&d?j(e,t,n,r,i,l,s,o,a):64&d?c.process(e,t,n,r,i,l,s,o,a,eu):128&d&&c.process(e,t,n,r,i,l,s,o,a,eu)}null!=u&&i&&nE(u,e&&e.ref,l,t||e,!t)},C=(e,t,n,r)=>{if(null==e)l(t.el=u(t.children),n,r);else{let n=t.el=e.el;t.children!==e.children&&p(n,t.children)}},T=(e,t,n,r)=>{null==e?l(t.el=d(t.children||""),n,r):t.el=e.el},N=(e,t,n,r)=>{[e.el,e.anchor]=S(e.children,t,n,r,e.el,e.anchor)},E=({el:e,anchor:t},n,r)=>{let i;for(;e&&e!==t;)i=m(e),l(e,n,r),e=i;l(t,n,r)},I=({el:e,anchor:t})=>{let n;for(;e&&e!==t;)n=m(e),s(e),e=n;s(t)},R=(e,t,n,r,i,l,s,o,a)=>{"svg"===t.type?s="svg":"math"===t.type&&(s="mathml"),null==e?O(t,n,r,i,l,s,o,a):F(e,t,i,l,s,o,a)},O=(e,t,n,r,i,s,c,u)=>{let d,p;let{props:h,shapeFlag:m,transition:g,dirs:y}=e;if(d=e.el=a(e.type,s,h&&h.is,h),8&m?f(d,e.children):16&m&&L(e.children,d,null,r,i,rH(e,s),c,u),y&&nt(e,null,r,"created"),M(d,e,e.scopeId,c,r),h){for(let e in h)"value"===e||H(e)||o(d,e,null,h[e],s,r);"value"in h&&o(d,"value",null,h.value,s),(p=h.onVnodeBeforeMount)&&iR(p,r,e)}y&&nt(e,null,r,"beforeMount");let b=rW(i,g);b&&g.beforeEnter(d),l(d,t,n),((p=h&&h.onVnodeMounted)||b||y)&&rB(()=>{p&&iR(p,r,e),b&&g.enter(d),y&&nt(e,null,r,"mounted")},i)},M=(e,t,n,r,i)=>{if(n&&g(e,n),r)for(let t=0;t{for(let c=a;c{let a;let c=t.el=e.el,{patchFlag:u,dynamicChildren:d,dirs:p}=t;u|=16&e.patchFlag;let h=e.props||y,m=t.props||y;if(n&&rq(n,!1),(a=m.onVnodeBeforeUpdate)&&iR(a,n,t,e),p&&nt(t,e,n,"beforeUpdate"),n&&rq(n,!0),(h.innerHTML&&null==m.innerHTML||h.textContent&&null==m.textContent)&&f(c,""),d?V(e.dynamicChildren,d,c,n,r,rH(t,i),l):s||X(e,t,c,null,n,r,rH(t,i),l,!1),u>0){if(16&u)B(c,h,m,n,i);else if(2&u&&h.class!==m.class&&o(c,"class",null,m.class,i),4&u&&o(c,"style",h.style,m.style,i),8&u){let e=t.dynamicProps;for(let t=0;t{a&&iR(a,n,t,e),p&&nt(t,e,n,"updated")},r)},V=(e,t,n,r,i,l,s)=>{for(let o=0;o{if(t!==n){if(t!==y)for(let l in t)H(l)||l in n||o(e,l,t[l],null,i,r);for(let l in n){if(H(l))continue;let s=n[l],a=t[l];s!==a&&"value"!==l&&o(e,l,a,s,i,r)}"value"in n&&o(e,"value",t.value,n.value,i)}},U=(e,t,n,r,i,s,o,a,c)=>{let d=t.el=e?e.el:u(""),p=t.anchor=e?e.anchor:u(""),{patchFlag:f,dynamicChildren:h,slotScopeIds:m}=t;m&&(a=a?a.concat(m):m),null==e?(l(d,n,r),l(p,n,r),L(t.children||[],n,p,i,s,o,a,c)):f>0&&64&f&&h&&e.dynamicChildren?(V(e.dynamicChildren,h,n,i,s,o,a),(null!=t.key||i&&t===i.subTree)&&rK(e,t,!0)):X(e,t,n,p,i,s,o,a,c)},j=(e,t,n,r,i,l,s,o,a)=>{t.slotScopeIds=o,null==e?512&t.shapeFlag?i.ctx.activate(t,n,r,s,a):q(t,n,r,i,l,s,a):W(e,t,a)},q=(e,t,n,r,i,l,s)=>{let o=e.component=function(e,t,n){let r=e.type,i=(t?t.appContext:e.appContext)||iO,l={uid:iP++,vnode:e,type:r,parent:t,appContext:i,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new ex(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:t?t.provides:Object.create(i.provides),ids:t?t.ids:["",0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:function e(t,n,r=!1){let i=r?rI:n.propsCache,l=i.get(t);if(l)return l;let s=t.props,o={},a=[],c=!1;if(!P(t)){let i=t=>{c=!0;let[r,i]=e(t,n,!0);k(o,r),i&&a.push(...i)};!r&&n.mixins.length&&n.mixins.forEach(i),t.extends&&i(t.extends),t.mixins&&t.mixins.forEach(i)}if(!s&&!c)return $(t)&&i.set(t,b),b;if(A(s))for(let e=0;e{let r=e(t,n,!0);r&&(a=!0,k(o,r))};!r&&n.mixins.length&&n.mixins.forEach(i),t.extends&&i(t.extends),t.mixins&&t.mixins.forEach(i)}return s||a?(A(s)?s.forEach(e=>o[e]=null):k(o,s),$(t)&&i.set(t,o),o):($(t)&&i.set(t,null),null)}(r,i),emit:null,emitted:null,propsDefaults:y,inheritAttrs:r.inheritAttrs,ctx:y,data:y,props:y,attrs:y,slots:y,refs:y,setupState:y,setupContext:null,suspense:n,suspenseId:n?n.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return l.ctx={_:l},l.root=t?t.root:l,l.emit=r0.bind(null,l),e.ce&&e.ce(l),l}(e,r,i);nq(e)&&(o.ctx.renderer=eu),function(e,t=!1,n=!1){t&&c(t);let{props:r,children:i}=e.vnode,l=iF(e);(function(e,t,n,r=!1){let i={},l=rN();for(let n in e.propsDefaults=Object.create(null),rA(e,t,i,l),e.propsOptions[0])n in i||(i[n]=void 0);n?e.props=r?i:tm(i):e.type.props?e.props=i:e.props=l,e.attrs=l})(e,r,l,t),rF(e,i,n),l&&function(e,t){let n=e.type;e.accessCache=Object.create(null),e.proxy=new Proxy(e.ctx,rs);let{setup:r}=n;if(r){eL();let n=e.setupContext=r.length>1?iq(e):null,i=i$(e),l=tq(r,e,0,[e.props,n]),s=D(l);if(e$(),i(),(s||e.sp)&&!nj(e)&&nA(e),s){if(l.then(iD,iD),t)return l.then(n=>{iB(e,n,t)}).catch(t=>{tK(t,e,0)});e.asyncDep=l}else iB(e,l,t)}else ij(e,t)}(e,t),t&&c(!1)}(o,!1,s),o.asyncDep?(i&&i.registerDep(o,K,s),e.el||T(null,o.subTree=iC(io),t,n)):K(o,e,t,n,i,l,s)},W=(e,t,n)=>{let r=t.component=e.component;if(function(e,t,n){let{props:r,children:i,component:l}=e,{props:s,children:o,patchFlag:a}=t,c=l.emitsOptions;if(t.dirs||t.transition)return!0;if(!n||!(a>=0))return(!!i||!!o)&&(!o||!o.$stable)||r!==s&&(r?!s||r4(r,s,c):!!s);if(1024&a)return!0;if(16&a)return r?r4(r,s,c):!!s;if(8&a){let e=t.dynamicProps;for(let t=0;t{let a=()=>{if(e.isMounted){let t,{next:n,bu:r,u:i,parent:c,vnode:u}=e;{let t=function e(t){let n=t.subTree.component;if(n)return n.asyncDep&&!n.asyncResolved?n:e(n)}(e);if(t){n&&(n.el=u.el,J(e,n,o)),t.asyncDep.then(()=>{e.isUnmounted||a()});return}}let d=n;rq(e,!1),n?(n.el=u.el,J(e,n,o)):n=u,r&&Y(r),(t=n.props&&n.props.onVnodeBeforeUpdate)&&iR(t,c,n,u),rq(e,!0);let p=r2(e),f=e.subTree;e.subTree=p,x(f,p,h(f.el),eo(f),e,l,s),n.el=p.el,null===d&&r8(e,p.el),i&&rB(i,l),(t=n.props&&n.props.onVnodeUpdated)&&rB(()=>iR(t,c,n,u),l)}else{let o;let{el:a,props:c}=t,{bm:u,m:d,parent:p,root:f,type:h}=e,m=nj(t);if(rq(e,!1),u&&Y(u),!m&&(o=c&&c.onVnodeBeforeMount)&&iR(o,p,t),rq(e,!0),a&&i){let t=()=>{e.subTree=r2(e),i(a,e.subTree,e,l,null)};m&&h.__asyncHydrate?h.__asyncHydrate(a,e,t):t()}else{f.ce&&f.ce._injectChildStyle(h);let i=e.subTree=r2(e);x(null,i,n,r,e,l,s),t.el=i.el}if(d&&rB(d,l),!m&&(o=c&&c.onVnodeMounted)){let e=t;rB(()=>iR(o,p,e),l)}(256&t.shapeFlag||p&&nj(p.vnode)&&256&p.vnode.shapeFlag)&&e.a&&rB(e.a,l),e.isMounted=!0,t=n=r=null}};e.scope.on();let c=e.effect=new ek(a);e.scope.off();let u=e.update=c.run.bind(c),d=e.job=c.runIfDirty.bind(c);d.i=e,d.id=e.uid,c.scheduler=()=>t1(d),rq(e,!0),u()},J=(e,t,n)=>{t.component=e;let r=e.vnode.props;e.vnode=t,e.next=null,function(e,t,n,r){let{props:i,attrs:l,vnode:{patchFlag:s}}=e,o=tx(i),[a]=e.propsOptions,c=!1;if((r||s>0)&&!(16&s)){if(8&s){let n=e.vnode.dynamicProps;for(let r=0;r{let c=e&&e.children,u=e?e.shapeFlag:0,d=t.children,{patchFlag:p,shapeFlag:h}=t;if(p>0){if(128&p){Z(c,d,n,r,i,l,s,o,a);return}if(256&p){Q(c,d,n,r,i,l,s,o,a);return}}8&h?(16&u&&es(c,i,l),d!==c&&f(n,d)):16&u?16&h?Z(c,d,n,r,i,l,s,o,a):es(c,i,l,!0):(8&u&&f(n,""),16&h&&L(d,n,r,i,l,s,o,a))},Q=(e,t,n,r,i,l,s,o,a)=>{let c;e=e||b,t=t||b;let u=e.length,d=t.length,p=Math.min(u,d);for(c=0;cd?es(e,i,l,!0,!1,p):L(t,n,r,i,l,s,o,a,p)},Z=(e,t,n,r,i,l,s,o,a)=>{let c=0,u=t.length,d=e.length-1,p=u-1;for(;c<=d&&c<=p;){let r=e[c],u=t[c]=a?iA(t[c]):iw(t[c]);if(ib(r,u))x(r,u,n,null,i,l,s,o,a);else break;c++}for(;c<=d&&c<=p;){let r=e[d],c=t[p]=a?iA(t[p]):iw(t[p]);if(ib(r,c))x(r,c,n,null,i,l,s,o,a);else break;d--,p--}if(c>d){if(c<=p){let e=p+1,d=ep)for(;c<=d;)et(e[c],i,l,!0),c++;else{let f;let h=c,m=c,g=new Map;for(c=m;c<=p;c++){let e=t[c]=a?iA(t[c]):iw(t[c]);null!=e.key&&g.set(e.key,c)}let y=0,_=p-m+1,S=!1,C=0,k=Array(_);for(c=0;c<_;c++)k[c]=0;for(c=h;c<=d;c++){let r;let u=e[c];if(y>=_){et(u,i,l,!0);continue}if(null!=u.key)r=g.get(u.key);else for(f=m;f<=p;f++)if(0===k[f-m]&&ib(u,t[f])){r=f;break}void 0===r?et(u,i,l,!0):(k[r-m]=c+1,r>=C?C=r:S=!0,x(u,t[r],n,null,i,l,s,o,a),y++)}let T=S?function(e){let t,n,r,i,l;let s=e.slice(),o=[0],a=e.length;for(t=0;t>1]]0&&(s[t]=o[r-1]),o[r]=t)}}for(r=o.length,i=o[r-1];r-- >0;)o[r]=i,i=s[i];return o}(k):b;for(f=T.length-1,c=_-1;c>=0;c--){let e=m+c,d=t[e],p=e+1{let{el:s,type:o,transition:a,children:c,shapeFlag:u}=e;if(6&u){ee(e.component.subTree,t,n,r);return}if(128&u){e.suspense.move(t,n,r);return}if(64&u){o.move(e,t,n,eu);return}if(o===il){l(s,t,n);for(let e=0;ea.enter(s),i);else{let{leave:e,delayLeave:r,afterLeave:i}=a,o=()=>l(s,t,n),c=()=>{e(s,()=>{o(),i&&i()})};r?r(s,o,c):c()}}else l(s,t,n)},et=(e,t,n,r=!1,i=!1)=>{let l;let{type:s,props:o,ref:a,children:c,dynamicChildren:u,shapeFlag:d,patchFlag:p,dirs:f,cacheIndex:h}=e;if(-2===p&&(i=!1),null!=a&&nE(a,null,n,e,!0),null!=h&&(t.renderCache[h]=void 0),256&d){t.ctx.deactivate(e);return}let m=1&d&&f,g=!nj(e);if(g&&(l=o&&o.onVnodeBeforeUnmount)&&iR(l,t,e),6&d)el(e.component,n,r);else{if(128&d){e.suspense.unmount(n,r);return}m&&nt(e,null,t,"beforeUnmount"),64&d?e.type.remove(e,t,n,eu,r):u&&!u.hasOnce&&(s!==il||p>0&&64&p)?es(u,t,n,!1,!0):(s===il&&384&p||!i&&16&d)&&es(c,t,n),r&&en(e)}(g&&(l=o&&o.onVnodeUnmounted)||m)&&rB(()=>{l&&iR(l,t,e),m&&nt(e,null,t,"unmounted")},n)},en=e=>{let{type:t,el:n,anchor:r,transition:i}=e;if(t===il){ei(n,r);return}if(t===ia){I(e);return}let l=()=>{s(n),i&&!i.persisted&&i.afterLeave&&i.afterLeave()};if(1&e.shapeFlag&&i&&!i.persisted){let{leave:t,delayLeave:r}=i,s=()=>t(n,l);r?r(e.el,l,s):s()}else l()},ei=(e,t)=>{let n;for(;e!==t;)n=m(e),s(e),e=n;s(t)},el=(e,t,n)=>{let{bum:r,scope:i,job:l,subTree:s,um:o,m:a,a:c}=e;rz(a),rz(c),r&&Y(r),i.stop(),l&&(l.flags|=8,et(s,e,t,n)),o&&rB(o,t),rB(()=>{e.isUnmounted=!0},t),t&&t.pendingBranch&&!t.isUnmounted&&e.asyncDep&&!e.asyncResolved&&e.suspenseId===t.pendingId&&(t.deps--,0===t.deps&&t.resolve())},es=(e,t,n,r=!1,i=!1,l=0)=>{for(let s=l;s{if(6&e.shapeFlag)return eo(e.component.subTree);if(128&e.shapeFlag)return e.suspense.next();let t=m(e.anchor||e.el),n=t&&t[nn];return n?m(n):t},ea=!1,ec=(e,t,n)=>{null==e?t._vnode&&et(t._vnode,null,null,!0):x(t._vnode||null,e,t,null,null,null,n),t._vnode=e,ea||(ea=!0,t6(),t4(),ea=!1)},eu={p:x,um:et,m:ee,r:en,mt:q,mc:L,pc:X,pbc:V,n:eo,o:e};return t&&([r,i]=t(eu)),{render:ec,hydrate:r,createApp:(n=r,function(e,t=null){P(e)||(e=k({},e)),null==t||$(t)||(t=null);let r=r_(),i=new WeakSet,l=[],s=!1,o=r.app={_uid:rS++,_component:e,_props:t,_container:null,_context:r,_instance:null,version:iX,get config(){return r.config},set config(v){},use:(e,...t)=>(i.has(e)||(e&&P(e.install)?(i.add(e),e.install(o,...t)):P(e)&&(i.add(e),e(o,...t))),o),mixin:e=>(r.mixins.includes(e)||r.mixins.push(e),o),component:(e,t)=>t?(r.components[e]=t,o):r.components[e],directive:(e,t)=>t?(r.directives[e]=t,o):r.directives[e],mount(i,l,a){if(!s){let c=o._ceVNode||iC(e,t);return c.appContext=r,!0===a?a="svg":!1===a&&(a=void 0),l&&n?n(c,i):ec(c,i,a),s=!0,o._container=i,i.__vue_app__=o,iW(c.component)}},onUnmount(e){l.push(e)},unmount(){s&&(tW(l,o._instance,16),ec(null,o._container),delete o._container.__vue_app__)},provide:(e,t)=>(r.provides[e]=t,o),runWithContext(e){let t=rx;rx=o;try{return e()}finally{rx=t}}};return o})}}function rH({type:e,props:t},n){return"svg"===n&&"foreignObject"===e||"mathml"===n&&"annotation-xml"===e&&t&&t.encoding&&t.encoding.includes("html")?void 0:n}function rq({effect:e,job:t},n){n?(e.flags|=32,t.flags|=4):(e.flags&=-33,t.flags&=-5)}function rW(e,t){return(!e||e&&!e.pendingBranch)&&t&&!t.persisted}function rK(e,t,n=!1){let r=e.children,i=t.children;if(A(r)&&A(i))for(let e=0;etW(e,c,t,n);let u=!1;return"post"===s?a.scheduler=e=>{rB(e,c&&c.suspense)}:"sync"!==s&&(u=!0,a.scheduler=(e,t)=>{t?e():t1(e)}),a.augmentJob=e=>{t&&(e.flags|=4),u&&(e.flags|=2,c&&(e.id=c.uid,e.i=c))},function(e,t,n=y){let r,l,s,o;let{immediate:a,deep:c,once:u,scheduler:d,augmentJob:p,call:f}=n,m=e=>c?e:t_(e)||!1===c||0===c?tH(e,1):tH(e),g=!1,b=!1;if(tN(e)?(l=()=>e.value,g=t_(e)):tv(e)?(l=()=>m(e),g=!0):A(e)?(b=!0,g=e.some(e=>tv(e)||t_(e)),l=()=>e.map(e=>tN(e)?e.value:tv(e)?m(e):P(e)?f?f(e,2):e():void 0)):l=P(e)?t?f?()=>f(e,2):e:()=>{if(s){eL();try{s()}finally{e$()}}let t=h;h=r;try{return f?f(e,3,[o]):e(o)}finally{h=t}}:_,t&&c){let e=l,t=!0===c?1/0:c;l=()=>tH(e(),t)}let S=i,x=()=>{r.stop(),S&&S.active&&T(S.effects,r)};if(u&&t){let e=t;t=(...t)=>{e(...t),x()}}let C=b?Array(e.length).fill(tB):tB,k=e=>{if(1&r.flags&&(r.dirty||e)){if(t){let e=r.run();if(c||g||(b?e.some((e,t)=>Z(e,C[t])):Z(e,C))){s&&s();let n=h;h=r;try{let n=[e,C===tB?void 0:b&&C[0]===tB?[]:C,o];f?f(t,3,n):t(...n),C=e}finally{h=n}}}else r.run()}};return p&&p(k),(r=new ek(l)).scheduler=d?()=>d(k,!1):k,o=e=>tj(e,!1,r),s=r.onStop=()=>{let e=tU.get(r);if(e){if(f)f(e,4);else for(let t of e)t();tU.delete(r)}},t?a?k(!0):C=r.run():d?d(k.bind(null,!0),!0):r.run(),x.pause=r.pause.bind(r),x.resume=r.resume.bind(r),x.stop=x,x}(e,t,a)}function rQ(e,t,n){let r;let i=this.proxy,l=M(e)?e.includes(".")?rZ(i,e):()=>i[e]:e.bind(i,i);P(t)?r=t:(r=t.handler,n=t);let s=i$(this),o=rX(l,r.bind(i),n);return s(),o}function rZ(e,t){let n=t.split(".");return()=>{let t=e;for(let e=0;e"modelValue"===t||"model-value"===t?e.modelModifiers:e[`${t}Modifiers`]||e[`${z(t)}Modifiers`]||e[`${G(t)}Modifiers`];function r0(e,t,...n){let r;if(e.isUnmounted)return;let i=e.vnode.props||y,l=n,s=t.startsWith("update:"),o=s&&rY(i,t.slice(7));o&&(o.trim&&(l=n.map(e=>M(e)?e.trim():e)),o.number&&(l=n.map(et)));let a=i[r=Q(t)]||i[r=Q(z(t))];!a&&s&&(a=i[r=Q(G(t))]),a&&tW(a,e,6,l);let c=i[r+"Once"];if(c){if(e.emitted){if(e.emitted[r])return}else e.emitted={};e.emitted[r]=!0,tW(c,e,6,l)}}function r1(e,t){return!!(e&&x(t))&&(w(e,(t=t.slice(2).replace(/Once$/,""))[0].toLowerCase()+t.slice(1))||w(e,G(t))||w(e,t))}function r2(e){let t,n;let{type:r,vnode:i,proxy:l,withProxy:s,propsOptions:[o],slots:a,attrs:c,emit:u,render:d,renderCache:p,props:f,data:h,setupState:m,ctx:g,inheritAttrs:y}=e,b=t7(e);try{if(4&i.shapeFlag){let e=s||l;t=iw(d.call(e,e,p,f,m,h,g)),n=c}else t=iw(r.length>1?r(f,{attrs:c,slots:a,emit:u}):r(f,null)),n=r.props?c:r3(c)}catch(n){ic.length=0,tK(n,e,1),t=iC(io)}let _=t;if(n&&!1!==y){let e=Object.keys(n),{shapeFlag:t}=_;e.length&&7&t&&(o&&e.some(C)&&(n=r6(n,o)),_=iT(_,n,!1,!0))}return i.dirs&&((_=iT(_,null,!1,!0)).dirs=_.dirs?_.dirs.concat(i.dirs):i.dirs),i.transition&&nT(_,i.transition),t=_,t7(b),t}let r3=e=>{let t;for(let n in e)("class"===n||"style"===n||x(n))&&((t||(t={}))[n]=e[n]);return t},r6=(e,t)=>{let n={};for(let r in e)C(r)&&r.slice(9)in t||(n[r]=e[r]);return n};function r4(e,t,n){let r=Object.keys(t);if(r.length!==Object.keys(e).length)return!0;for(let i=0;ie.__isSuspense,r9=0;function r7(e,t){let n=e.props&&e.props[t];P(n)&&n()}function ie(e,t,n,r,i,l,s,o,a,c,u=!1){let d;let{p:p,m:f,um:h,n:m,o:{parentNode:g,remove:y}}=c,b=function(e){let t=e.props&&e.props.suspensible;return null!=t&&!1!==t}(e);b&&t&&t.pendingBranch&&(d=t.pendingId,t.deps++);let _=e.props?en(e.props.timeout):void 0,S=l,x={vnode:e,parent:t,parentComponent:n,namespace:s,container:r,hiddenContainer:i,deps:0,pendingId:r9++,timeout:"number"==typeof _?_:-1,activeBranch:null,pendingBranch:null,isInFallback:!u,isHydrating:u,isUnmounted:!1,effects:[],resolve(e=!1,n=!1){let{vnode:r,activeBranch:i,pendingBranch:s,pendingId:o,effects:a,parentComponent:c,container:u}=x,p=!1;x.isHydrating?x.isHydrating=!1:e||((p=i&&s.transition&&"out-in"===s.transition.mode)&&(i.transition.afterLeave=()=>{o===x.pendingId&&(f(s,u,l===S?m(i):l,0),t3(a))}),i&&(g(i.el)===u&&(l=m(i)),h(i,c,x,!0)),p||f(s,u,l,0)),ii(x,s),x.pendingBranch=null,x.isInFallback=!1;let y=x.parent,_=!1;for(;y;){if(y.pendingBranch){y.effects.push(...a),_=!0;break}y=y.parent}_||p||t3(a),x.effects=[],b&&t&&t.pendingBranch&&d===t.pendingId&&(t.deps--,0!==t.deps||n||t.resolve()),r7(r,"onResolve")},fallback(e){if(!x.pendingBranch)return;let{vnode:t,activeBranch:n,parentComponent:r,container:i,namespace:l}=x;r7(t,"onFallback");let s=m(n),c=()=>{x.isInFallback&&(p(null,e,i,s,r,null,l,o,a),ii(x,e))},u=e.transition&&"out-in"===e.transition.mode;u&&(n.transition.afterLeave=c),x.isInFallback=!0,h(n,r,null,!0),u||c()},move(e,t,n){x.activeBranch&&f(x.activeBranch,e,t,n),x.container=e},next:()=>x.activeBranch&&m(x.activeBranch),registerDep(e,t,n){let r=!!x.pendingBranch;r&&x.deps++;let i=e.vnode.el;e.asyncDep.catch(t=>{tK(t,e,0)}).then(l=>{if(e.isUnmounted||x.isUnmounted||x.pendingId!==e.suspenseId)return;e.asyncResolved=!0;let{vnode:o}=e;iB(e,l,!1),i&&(o.el=i);let a=!i&&e.subTree.el;t(e,o,g(i||e.subTree.el),i?null:m(e.subTree),x,s,n),a&&y(a),r8(e,o.el),r&&0==--x.deps&&x.resolve()})},unmount(e,t){x.isUnmounted=!0,x.activeBranch&&h(x.activeBranch,n,e,t),x.pendingBranch&&h(x.pendingBranch,n,e,t)}};return x}function it(e){let t;if(P(e)){let n=ih&&e._c;n&&(e._d=!1,id()),e=e(),n&&(e._d=!0,t=iu,ip())}return A(e)&&(e=function(e,t=!0){let n;for(let t=0;tt!==e)),e}function ir(e,t){t&&t.pendingBranch?A(e)?t.effects.push(...e):t.effects.push(e):t3(e)}function ii(e,t){e.activeBranch=t;let{vnode:n,parentComponent:r}=e,i=t.el;for(;!i&&t.component;)i=(t=t.component.subTree).el;n.el=i,r&&r.subTree===n&&(r.vnode.el=i,r8(r,i))}let il=Symbol.for("v-fgt"),is=Symbol.for("v-txt"),io=Symbol.for("v-cmt"),ia=Symbol.for("v-stc"),ic=[],iu=null;function id(e=!1){ic.push(iu=e?null:[])}function ip(){ic.pop(),iu=ic[ic.length-1]||null}let ih=1;function im(e,t=!1){ih+=e,e<0&&iu&&t&&(iu.hasOnce=!0)}function ig(e){return e.dynamicChildren=ih>0?iu||b:null,ip(),ih>0&&iu&&iu.push(e),e}function iy(e,t,n,r,i){return ig(iC(e,t,n,r,i,!0))}function iv(e){return!!e&&!0===e.__v_isVNode}function ib(e,t){return e.type===t.type&&e.key===t.key}let i_=({key:e})=>null!=e?e:null,iS=({ref:e,ref_key:t,ref_for:n})=>("number"==typeof e&&(e=""+e),null!=e?M(e)||tN(e)||P(e)?{i:t5,r:e,k:t,f:!!n}:e:null);function ix(e,t=null,n=null,r=0,i=null,l=e===il?0:1,s=!1,o=!1){let a={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&i_(t),ref:t&&iS(t),scopeId:t9,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:l,patchFlag:r,dynamicProps:i,dynamicChildren:null,appContext:null,ctx:t5};return o?(iE(a,n),128&l&&e.normalize(a)):n&&(a.shapeFlag|=M(n)?8:16),ih>0&&!s&&iu&&(a.patchFlag>0||6&l)&&32!==a.patchFlag&&iu.push(a),a}let iC=function(e,t=null,n=null,r=0,i=null,l=!1){var s;if(e&&e!==re||(e=io),iv(e)){let r=iT(e,t,!0);return n&&iE(r,n),ih>0&&!l&&iu&&(6&r.shapeFlag?iu[iu.indexOf(e)]=r:iu.push(r)),r.patchFlag=-2,r}if(P(s=e)&&"__vccOpts"in s&&(e=e.__vccOpts),t){let{class:e,style:n}=t=ik(t);e&&!M(e)&&(t.class=eu(e)),$(n)&&(tS(n)&&!A(n)&&(n=k({},n)),t.style=el(n))}let o=M(e)?1:r5(e)?128:nr(e)?64:$(e)?4:P(e)?2:0;return ix(e,t,n,r,i,o,l,!0)};function ik(e){return e?tS(e)||rw(e)?k({},e):e:null}function iT(e,t,n=!1,r=!1){let{props:i,ref:l,patchFlag:s,children:o,transition:a}=e,c=t?iI(i||{},t):i,u={__v_isVNode:!0,__v_skip:!0,type:e.type,props:c,key:c&&i_(c),ref:t&&t.ref?n&&l?A(l)?l.concat(iS(t)):[l,iS(t)]:iS(t):l,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:o,target:e.target,targetStart:e.targetStart,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==il?-1===s?16:16|s:s,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:a,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&iT(e.ssContent),ssFallback:e.ssFallback&&iT(e.ssFallback),el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce};return a&&r&&nT(u,a.clone(u)),u}function iN(e=" ",t=0){return iC(is,null,e,t)}function iw(e){return null==e||"boolean"==typeof e?iC(io):A(e)?iC(il,null,e.slice()):iv(e)?iA(e):iC(is,null,String(e))}function iA(e){return null===e.el&&-1!==e.patchFlag||e.memo?e:iT(e)}function iE(e,t){let n=0,{shapeFlag:r}=e;if(null==t)t=null;else if(A(t))n=16;else if("object"==typeof t){if(65&r){let n=t.default;n&&(n._c&&(n._d=!1),iE(e,n()),n._c&&(n._d=!0));return}{n=32;let r=t._;r||rw(t)?3===r&&t5&&(1===t5.slots._?t._=1:(t._=2,e.patchFlag|=1024)):t._ctx=t5}}else P(t)?(t={default:t,_ctx:t5},n=32):(t=String(t),64&r?(n=16,t=[iN(t)]):n=8);e.children=t,e.shapeFlag|=n}function iI(...e){let t={};for(let n=0;niM||t5;a=e=>{iM=e},c=e=>{iV=e};let i$=e=>{let t=iM;return a(e),e.scope.on(),()=>{e.scope.off(),a(t)}},iD=()=>{iM&&iM.scope.off(),a(null)};function iF(e){return 4&e.vnode.shapeFlag}let iV=!1;function iB(e,t,n){P(t)?e.render=t:$(t)&&(e.setupState=tP(t)),ij(e,n)}function iU(e){u=e,d=e=>{e.render._rc&&(e.withProxy=new Proxy(e.ctx,ro))}}function ij(e,t,n){let r=e.type;if(!e.render){if(!t&&u&&!r.render){let t=r.template||rp(e).template;if(t){let{isCustomElement:n,compilerOptions:i}=e.appContext.config,{delimiters:l,compilerOptions:s}=r,o=k(k({isCustomElement:n,delimiters:l},i),s);r.render=u(t,o)}}e.render=r.render||_,d&&d(e)}{let t=i$(e);eL();try{!function(e){let t=rp(e),n=e.proxy,r=e.ctx;ru=!1,t.beforeCreate&&rd(t.beforeCreate,e,"bc");let{data:i,computed:l,methods:s,watch:o,provide:a,inject:c,created:u,beforeMount:d,mounted:p,beforeUpdate:f,updated:h,activated:m,deactivated:g,beforeDestroy:y,beforeUnmount:b,destroyed:S,unmounted:x,render:C,renderTracked:k,renderTriggered:T,errorCaptured:N,serverPrefetch:w,expose:E,inheritAttrs:I,components:R,directives:O,filters:L}=t;if(c&&function(e,t,n=_){for(let n in A(e)&&(e=rg(e)),e){let r;let i=e[n];tN(r=$(i)?"default"in i?rk(i.from||n,i.default,!0):rk(i.from||n):rk(i))?Object.defineProperty(t,n,{enumerable:!0,configurable:!0,get:()=>r.value,set:e=>r.value=e}):t[n]=r}}(c,r,null),s)for(let e in s){let t=s[e];P(t)&&(r[e]=t.bind(n))}if(i){let t=i.call(n,n);$(t)&&(e.data=th(t))}if(ru=!0,l)for(let e in l){let t=l[e],i=P(t)?t.bind(n,n):P(t.get)?t.get.bind(n,n):_,s=iz({get:i,set:!P(t)&&P(t.set)?t.set.bind(n):_});Object.defineProperty(r,e,{enumerable:!0,configurable:!0,get:()=>s.value,set:e=>s.value=e})}if(o)for(let e in o)!function e(t,n,r,i){let l=i.includes(".")?rZ(r,i):()=>r[i];if(M(t)){let e=n[t];P(e)&&rX(l,e,void 0)}else if(P(t)){var s;s=t.bind(r),rX(l,s,void 0)}else if($(t)){if(A(t))t.forEach(t=>e(t,n,r,i));else{let e=P(t.handler)?t.handler.bind(r):n[t.handler];P(e)&&rX(l,e,t)}}}(o[e],r,n,e);if(a){let e=P(a)?a.call(n):a;Reflect.ownKeys(e).forEach(t=>{rC(t,e[t])})}function D(e,t){A(t)?t.forEach(t=>e(t.bind(n))):t&&e(t.bind(n))}if(u&&rd(u,e,"c"),D(nY,d),D(n0,p),D(n1,f),D(n2,h),D(nK,m),D(nz,g),D(n9,N),D(n5,k),D(n8,T),D(n3,b),D(n6,x),D(n4,w),A(E)){if(E.length){let t=e.exposed||(e.exposed={});E.forEach(e=>{Object.defineProperty(t,e,{get:()=>n[e],set:t=>n[e]=t})})}else e.exposed||(e.exposed={})}C&&e.render===_&&(e.render=C),null!=I&&(e.inheritAttrs=I),R&&(e.components=R),O&&(e.directives=O)}(e)}finally{e$(),t()}}}let iH={get:(e,t)=>(eW(e,"get",""),e[t])};function iq(e){return{attrs:new Proxy(e.attrs,iH),slots:e.slots,emit:e.emit,expose:t=>{e.exposed=t||{}}}}function iW(e){return e.exposed?e.exposeProxy||(e.exposeProxy=new Proxy(tP(tC(e.exposed)),{get:(t,n)=>n in t?t[n]:n in ri?ri[n](e):void 0,has:(e,t)=>t in e||t in ri})):e.proxy}function iK(e,t=!0){return P(e)?e.displayName||e.name:e.name||t&&e.__name}let iz=(e,t)=>(function(e,t,n=!1){let r,i;return P(e)?r=e:(r=e.get,i=e.set),new tV(r,i,n)})(e,0,iV);function iJ(e,t,n){let r=arguments.length;return 2!==r?(r>3?n=Array.prototype.slice.call(arguments,2):3===r&&iv(n)&&(n=[n]),iC(e,t,n)):!$(t)||A(t)?iC(e,null,t):iv(t)?iC(e,null,[t]):iC(e,t)}function iG(e,t){let n=e.memo;if(n.length!=t.length)return!1;for(let e=0;e0&&iu&&iu.push(e),!0}let iX="3.5.13",iQ="undefined"!=typeof window&&window.trustedTypes;if(iQ)try{m=iQ.createPolicy("vue",{createHTML:e=>e})}catch(e){}let iZ=m?e=>m.createHTML(e):e=>e,iY="undefined"!=typeof document?document:null,i0=iY&&iY.createElement("template"),i1="transition",i2="animation",i3=Symbol("_vtc"),i6={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},i4=k({},ny,i6),i8=((t=(e,{slots:t})=>iJ(n_,i7(e),t)).displayName="Transition",t.props=i4,t),i5=(e,t=[])=>{A(e)?e.forEach(e=>e(...t)):e&&e(...t)},i9=e=>!!e&&(A(e)?e.some(e=>e.length>1):e.length>1);function i7(e){let t={};for(let n in e)n in i6||(t[n]=e[n]);if(!1===e.css)return t;let{name:n="v",type:r,duration:i,enterFromClass:l=`${n}-enter-from`,enterActiveClass:s=`${n}-enter-active`,enterToClass:o=`${n}-enter-to`,appearFromClass:a=l,appearActiveClass:c=s,appearToClass:u=o,leaveFromClass:d=`${n}-leave-from`,leaveActiveClass:p=`${n}-leave-active`,leaveToClass:f=`${n}-leave-to`}=e,h=function(e){if(null==e)return null;if($(e))return[en(e.enter),en(e.leave)];{let t=en(e);return[t,t]}}(i),m=h&&h[0],g=h&&h[1],{onBeforeEnter:y,onEnter:b,onEnterCancelled:_,onLeave:S,onLeaveCancelled:x,onBeforeAppear:C=y,onAppear:T=b,onAppearCancelled:N=_}=t,w=(e,t,n,r)=>{e._enterCancelled=r,lt(e,t?u:o),lt(e,t?c:s),n&&n()},A=(e,t)=>{e._isLeaving=!1,lt(e,d),lt(e,f),lt(e,p),t&&t()},E=e=>(t,n)=>{let i=e?T:b,s=()=>w(t,e,n);i5(i,[t,s]),ln(()=>{lt(t,e?a:l),le(t,e?u:o),i9(i)||li(t,r,m,s)})};return k(t,{onBeforeEnter(e){i5(y,[e]),le(e,l),le(e,s)},onBeforeAppear(e){i5(C,[e]),le(e,a),le(e,c)},onEnter:E(!1),onAppear:E(!0),onLeave(e,t){e._isLeaving=!0;let n=()=>A(e,t);le(e,d),e._enterCancelled?(le(e,p),la()):(la(),le(e,p)),ln(()=>{e._isLeaving&&(lt(e,d),le(e,f),i9(S)||li(e,r,g,n))}),i5(S,[e,n])},onEnterCancelled(e){w(e,!1,void 0,!0),i5(_,[e])},onAppearCancelled(e){w(e,!0,void 0,!0),i5(N,[e])},onLeaveCancelled(e){A(e),i5(x,[e])}})}function le(e,t){t.split(/\s+/).forEach(t=>t&&e.classList.add(t)),(e[i3]||(e[i3]=new Set)).add(t)}function lt(e,t){t.split(/\s+/).forEach(t=>t&&e.classList.remove(t));let n=e[i3];n&&(n.delete(t),n.size||(e[i3]=void 0))}function ln(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}let lr=0;function li(e,t,n,r){let i=e._endId=++lr,l=()=>{i===e._endId&&r()};if(null!=n)return setTimeout(l,n);let{type:s,timeout:o,propCount:a}=ll(e,t);if(!s)return r();let c=s+"end",u=0,d=()=>{e.removeEventListener(c,p),l()},p=t=>{t.target===e&&++u>=a&&d()};setTimeout(()=>{u(n[e]||"").split(", "),i=r(`${i1}Delay`),l=r(`${i1}Duration`),s=ls(i,l),o=r(`${i2}Delay`),a=r(`${i2}Duration`),c=ls(o,a),u=null,d=0,p=0;t===i1?s>0&&(u=i1,d=s,p=l.length):t===i2?c>0&&(u=i2,d=c,p=a.length):p=(u=(d=Math.max(s,c))>0?s>c?i1:i2:null)?u===i1?l.length:a.length:0;let f=u===i1&&/\b(transform|all)(,|$)/.test(r(`${i1}Property`).toString());return{type:u,timeout:d,propCount:p,hasTransform:f}}function ls(e,t){for(;e.lengthlo(t)+lo(e[n])))}function lo(e){return"auto"===e?0:1e3*Number(e.slice(0,-1).replace(",","."))}function la(){return document.body.offsetHeight}let lc=Symbol("_vod"),lu=Symbol("_vsh");function ld(e,t){e.style.display=t?e[lc]:"none",e[lu]=!t}let lp=Symbol("");function lf(e,t){if(1===e.nodeType){let n=e.style,r="";for(let e in t)n.setProperty(`--${e}`,t[e]),r+=`--${e}: ${t[e]};`;n[lp]=r}}let lh=/(^|;)\s*display\s*:/,lm=/\s*!important$/;function lg(e,t,n){if(A(n))n.forEach(n=>lg(e,t,n));else if(null==n&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{let r=function(e,t){let n=lv[t];if(n)return n;let r=z(t);if("filter"!==r&&r in e)return lv[t]=r;r=X(r);for(let n=0;nlT||(lN.then(()=>lT=0),lT=Date.now()),lA=e=>111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)>96&&123>e.charCodeAt(2),lE={};function lI(e,t,n){let r=nw(e,t);U(r)&&k(r,t);class i extends lO{constructor(e){super(r,e,n)}}return i.def=r,i}let lR="undefined"!=typeof HTMLElement?HTMLElement:class{};class lO extends lR{constructor(e,t={},n=l9){super(),this._def=e,this._props=t,this._createApp=n,this._isVueCE=!0,this._instance=null,this._app=null,this._nonce=this._def.nonce,this._connected=!1,this._resolved=!1,this._numberProps=null,this._styleChildren=new WeakSet,this._ob=null,this.shadowRoot&&n!==l9?this._root=this.shadowRoot:!1!==e.shadowRoot?(this.attachShadow({mode:"open"}),this._root=this.shadowRoot):this._root=this,this._def.__asyncLoader||this._resolveProps(this._def)}connectedCallback(){if(!this.isConnected)return;this.shadowRoot||this._parseSlots(),this._connected=!0;let e=this;for(;e=e&&(e.parentNode||e.host);)if(e instanceof lO){this._parent=e;break}this._instance||(this._resolved?(this._setParent(),this._update()):e&&e._pendingResolve?this._pendingResolve=e._pendingResolve.then(()=>{this._pendingResolve=void 0,this._resolveDef()}):this._resolveDef())}_setParent(e=this._parent){e&&(this._instance.parent=e._instance,this._instance.provides=e._instance.provides)}disconnectedCallback(){this._connected=!1,t0(()=>{this._connected||(this._ob&&(this._ob.disconnect(),this._ob=null),this._app&&this._app.unmount(),this._instance&&(this._instance.ce=void 0),this._app=this._instance=null)})}_resolveDef(){if(this._pendingResolve)return;for(let e=0;e{for(let t of e)this._setAttr(t.attributeName)}),this._ob.observe(this,{attributes:!0});let e=(e,t=!1)=>{let n;this._resolved=!0,this._pendingResolve=void 0;let{props:r,styles:i}=e;if(r&&!A(r))for(let e in r){let t=r[e];(t===Number||t&&t.type===Number)&&(e in this._props&&(this._props[e]=en(this._props[e])),(n||(n=Object.create(null)))[z(e)]=!0)}this._numberProps=n,t&&this._resolveProps(e),this.shadowRoot&&this._applyStyles(i),this._mount(e)},t=this._def.__asyncLoader;t?this._pendingResolve=t().then(t=>e(this._def=t,!0)):e(this._def)}_mount(e){this._app=this._createApp(e),e.configureApp&&e.configureApp(this._app),this._app._ceVNode=this._createVNode(),this._app.mount(this._root);let t=this._instance&&this._instance.exposed;if(t)for(let e in t)w(this,e)||Object.defineProperty(this,e,{get:()=>tR(t[e])})}_resolveProps(e){let{props:t}=e,n=A(t)?t:Object.keys(t||{});for(let e of Object.keys(this))"_"!==e[0]&&n.includes(e)&&this._setProp(e,this[e]);for(let e of n.map(z))Object.defineProperty(this,e,{get(){return this._getProp(e)},set(t){this._setProp(e,t,!0,!0)}})}_setAttr(e){if(e.startsWith("data-v-"))return;let t=this.hasAttribute(e),n=t?this.getAttribute(e):lE,r=z(e);t&&this._numberProps&&this._numberProps[r]&&(n=en(n)),this._setProp(r,n,!1,!0)}_getProp(e){return this._props[e]}_setProp(e,t,n=!0,r=!1){if(t!==this._props[e]&&(t===lE?delete this._props[e]:(this._props[e]=t,"key"===e&&this._app&&(this._app._ceVNode.key=t)),r&&this._instance&&this._update(),n)){let n=this._ob;n&&n.disconnect(),!0===t?this.setAttribute(G(e),""):"string"==typeof t||"number"==typeof t?this.setAttribute(G(e),t+""):t||this.removeAttribute(G(e)),n&&n.observe(this,{attributes:!0})}}_update(){l5(this._createVNode(),this._root)}_createVNode(){let e={};this.shadowRoot||(e.onVnodeMounted=e.onVnodeUpdated=this._renderSlots.bind(this));let t=iC(this._def,k(e,this._props));return this._instance||(t.ce=e=>{this._instance=e,e.ce=this,e.isCE=!0;let t=(e,t)=>{this.dispatchEvent(new CustomEvent(e,U(t[0])?k({detail:t},t[0]):{detail:t}))};e.emit=(e,...n)=>{t(e,n),G(e)!==e&&t(G(e),n)},this._setParent()}),t}_applyStyles(e,t){if(!e)return;if(t){if(t===this._def||this._styleChildren.has(t))return;this._styleChildren.add(t)}let n=this._nonce;for(let t=e.length-1;t>=0;t--){let r=document.createElement("style");n&&r.setAttribute("nonce",n),r.textContent=e[t],this.shadowRoot.prepend(r)}}_parseSlots(){let e;let t=this._slots={};for(;e=this.firstChild;){let n=1===e.nodeType&&e.getAttribute("slot")||"default";(t[n]||(t[n]=[])).push(e),this.removeChild(e)}}_renderSlots(){let e=(this._teleportTarget||this).querySelectorAll("slot"),t=this._instance.type.__scopeId;for(let n=0;n{if(!n.length)return;let t=e.moveClass||`${e.name||"v"}-move`;if(!function(e,t,n){let r=e.cloneNode(),i=e[i3];i&&i.forEach(e=>{e.split(/\s+/).forEach(e=>e&&r.classList.remove(e))}),n.split(/\s+/).forEach(e=>e&&r.classList.add(e)),r.style.display="none";let l=1===t.nodeType?t:t.parentNode;l.appendChild(r);let{hasTransform:s}=ll(r);return l.removeChild(r),s}(n[0].el,i.vnode.el,t))return;n.forEach(lV),n.forEach(lB);let r=n.filter(lU);la(),r.forEach(e=>{let n=e.el,r=n.style;le(n,t),r.transform=r.webkitTransform=r.transitionDuration="";let i=n[l$]=e=>{(!e||e.target===n)&&(!e||/transform$/.test(e.propertyName))&&(n.removeEventListener("transitionend",i),n[l$]=null,lt(n,t))};n.addEventListener("transitionend",i)})}),()=>{let s=tx(e),o=i7(s),a=s.tag||il;if(n=[],r)for(let e=0;e{let t=e.props["onUpdate:modelValue"]||!1;return A(t)?e=>Y(t,e):t};function lH(e){e.target.composing=!0}function lq(e){let t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}let lW=Symbol("_assign"),lK={created(e,{modifiers:{lazy:t,trim:n,number:r}},i){e[lW]=lj(i);let l=r||i.props&&"number"===i.props.type;lx(e,t?"change":"input",t=>{if(t.target.composing)return;let r=e.value;n&&(r=r.trim()),l&&(r=et(r)),e[lW](r)}),n&&lx(e,"change",()=>{e.value=e.value.trim()}),t||(lx(e,"compositionstart",lH),lx(e,"compositionend",lq),lx(e,"change",lq))},mounted(e,{value:t}){e.value=null==t?"":t},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:i,number:l}},s){if(e[lW]=lj(s),e.composing)return;let o=(l||"number"===e.type)&&!/^0\d/.test(e.value)?et(e.value):e.value,a=null==t?"":t;o===a||document.activeElement===e&&"range"!==e.type&&(r&&t===n||i&&e.value.trim()===a)||(e.value=a)}},lz={deep:!0,created(e,t,n){e[lW]=lj(n),lx(e,"change",()=>{let t=e._modelValue,n=lZ(e),r=e.checked,i=e[lW];if(A(t)){let e=ey(t,n),l=-1!==e;if(r&&!l)i(t.concat(n));else if(!r&&l){let n=[...t];n.splice(e,1),i(n)}}else if(I(t)){let e=new Set(t);r?e.add(n):e.delete(n),i(e)}else i(lY(e,r))})},mounted:lJ,beforeUpdate(e,t,n){e[lW]=lj(n),lJ(e,t,n)}};function lJ(e,{value:t,oldValue:n},r){let i;if(e._modelValue=t,A(t))i=ey(t,r.props.value)>-1;else if(I(t))i=t.has(r.props.value);else{if(t===n)return;i=eg(t,lY(e,!0))}e.checked!==i&&(e.checked=i)}let lG={created(e,{value:t},n){e.checked=eg(t,n.props.value),e[lW]=lj(n),lx(e,"change",()=>{e[lW](lZ(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[lW]=lj(r),t!==n&&(e.checked=eg(t,r.props.value))}},lX={deep:!0,created(e,{value:t,modifiers:{number:n}},r){let i=I(t);lx(e,"change",()=>{let t=Array.prototype.filter.call(e.options,e=>e.selected).map(e=>n?et(lZ(e)):lZ(e));e[lW](e.multiple?i?new Set(t):t:t[0]),e._assigning=!0,t0(()=>{e._assigning=!1})}),e[lW]=lj(r)},mounted(e,{value:t}){lQ(e,t)},beforeUpdate(e,t,n){e[lW]=lj(n)},updated(e,{value:t}){e._assigning||lQ(e,t)}};function lQ(e,t){let n=e.multiple,r=A(t);if(!n||r||I(t)){for(let i=0,l=e.options.length;iString(e)===String(s)):l.selected=ey(t,s)>-1}else l.selected=t.has(s)}else if(eg(lZ(l),t)){e.selectedIndex!==i&&(e.selectedIndex=i);return}}n||-1===e.selectedIndex||(e.selectedIndex=-1)}}function lZ(e){return"_value"in e?e._value:e.value}function lY(e,t){let n=t?"_trueValue":"_falseValue";return n in e?e[n]:t}function l0(e,t,n,r,i){let l=function(e,t){switch(e){case"SELECT":return lX;case"TEXTAREA":return lK;default:switch(t){case"checkbox":return lz;case"radio":return lG;default:return lK}}}(e.tagName,n.props&&n.props.type)[i];l&&l(e,t,n,r)}let l1=["ctrl","shift","alt","meta"],l2={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&0!==e.button,middle:e=>"button"in e&&1!==e.button,right:e=>"button"in e&&2!==e.button,exact:(e,t)=>l1.some(n=>e[`${n}Key`]&&!t.includes(n))},l3={esc:"escape",space:" ",up:"arrow-up",left:"arrow-left",right:"arrow-right",down:"arrow-down",delete:"backspace"},l6=k({patchProp:(e,t,n,r,i,l)=>{let s="svg"===i;"class"===t?function(e,t,n){let r=e[i3];r&&(t=(t?[t,...r]:[...r]).join(" ")),null==t?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}(e,r,s):"style"===t?function(e,t,n){let r=e.style,i=M(n),l=!1;if(n&&!i){if(t){if(M(t))for(let e of t.split(";")){let t=e.slice(0,e.indexOf(":")).trim();null==n[t]&&lg(r,t,"")}else for(let e in t)null==n[e]&&lg(r,e,"")}for(let e in n)"display"===e&&(l=!0),lg(r,e,n[e])}else if(i){if(t!==n){let e=r[lp];e&&(n+=";"+e),r.cssText=n,l=lh.test(n)}}else t&&e.removeAttribute("style");lc in e&&(e[lc]=l?r.display:"",e[lu]&&(r.display="none"))}(e,n,r):x(t)?C(t)||function(e,t,n,r,i=null){let l=e[lC]||(e[lC]={}),s=l[t];if(r&&s)s.value=r;else{let[n,o]=function(e){let t;if(lk.test(e)){let n;for(t={};n=e.match(lk);)e=e.slice(0,e.length-n[0].length),t[n[0].toLowerCase()]=!0}return[":"===e[2]?e.slice(3):G(e.slice(2)),t]}(t);r?lx(e,n,l[t]=function(e,t){let n=e=>{if(e._vts){if(e._vts<=n.attached)return}else e._vts=Date.now();tW(function(e,t){if(!A(t))return t;{let n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(e=>t=>!t._stopped&&e&&e(t))}}(e,n.value),t,5,[e])};return n.value=e,n.attached=lw(),n}(r,i),o):s&&(!function(e,t,n,r){e.removeEventListener(t,n,r)}(e,n,s,o),l[t]=void 0)}}(e,t,0,r,l):("."===t[0]?(t=t.slice(1),0):"^"===t[0]?(t=t.slice(1),1):!function(e,t,n,r){if(r)return!!("innerHTML"===t||"textContent"===t||t in e&&lA(t)&&P(n));if("spellcheck"===t||"draggable"===t||"translate"===t||"form"===t||"list"===t&&"INPUT"===e.tagName||"type"===t&&"TEXTAREA"===e.tagName)return!1;if("width"===t||"height"===t){let t=e.tagName;if("IMG"===t||"VIDEO"===t||"CANVAS"===t||"SOURCE"===t)return!1}return!(lA(t)&&M(n))&&t in e}(e,t,r,s))?e._isVueCE&&(/[A-Z]/.test(t)||!M(r))?lS(e,z(t),r,l,t):("true-value"===t?e._trueValue=r:"false-value"===t&&(e._falseValue=r),l_(e,t,r,s)):(lS(e,t,r),e.tagName.includes("-")||"value"!==t&&"checked"!==t&&"selected"!==t||l_(e,t,r,s,l,"value"!==t))}},{insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{let t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,r)=>{let i="svg"===t?iY.createElementNS("http://www.w3.org/2000/svg",e):"mathml"===t?iY.createElementNS("http://www.w3.org/1998/Math/MathML",e):n?iY.createElement(e,{is:n}):iY.createElement(e);return"select"===e&&r&&null!=r.multiple&&i.setAttribute("multiple",r.multiple),i},createText:e=>iY.createTextNode(e),createComment:e=>iY.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>iY.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,r,i,l){let s=n?n.previousSibling:t.lastChild;if(i&&(i===l||i.nextSibling))for(;t.insertBefore(i.cloneNode(!0),n),i!==l&&(i=i.nextSibling););else{i0.innerHTML=iZ("svg"===r?`${e}`:"mathml"===r?`${e}`:e);let i=i0.content;if("svg"===r||"mathml"===r){let e=i.firstChild;for(;e.firstChild;)i.appendChild(e.firstChild);i.removeChild(e)}t.insertBefore(i,n)}return[s?s.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}}),l4=!1;function l8(){return p=l4?p:rU(l6),l4=!0,p}let l5=(...e)=>{(p||(p=rj(l6))).render(...e)},l9=(...e)=>{let t=(p||(p=rj(l6))).createApp(...e),{mount:n}=t;return t.mount=e=>{let r=st(e);if(!r)return;let i=t._component;P(i)||i.render||i.template||(i.template=r.innerHTML),1===r.nodeType&&(r.textContent="");let l=n(r,!1,se(r));return r instanceof Element&&(r.removeAttribute("v-cloak"),r.setAttribute("data-v-app","")),l},t},l7=(...e)=>{let t=l8().createApp(...e),{mount:n}=t;return t.mount=e=>{let t=st(e);if(t)return n(t,!0,se(t))},t};function se(e){return e instanceof SVGElement?"svg":"function"==typeof MathMLElement&&e instanceof MathMLElement?"mathml":void 0}function st(e){return M(e)?document.querySelector(e):e}let sn=Symbol(""),sr=Symbol(""),si=Symbol(""),sl=Symbol(""),ss=Symbol(""),so=Symbol(""),sa=Symbol(""),sc=Symbol(""),su=Symbol(""),sd=Symbol(""),sp=Symbol(""),sf=Symbol(""),sh=Symbol(""),sm=Symbol(""),sg=Symbol(""),sy=Symbol(""),sv=Symbol(""),sb=Symbol(""),s_=Symbol(""),sS=Symbol(""),sx=Symbol(""),sC=Symbol(""),sk=Symbol(""),sT=Symbol(""),sN=Symbol(""),sw=Symbol(""),sA=Symbol(""),sE=Symbol(""),sI=Symbol(""),sR=Symbol(""),sO=Symbol(""),sP=Symbol(""),sM=Symbol(""),sL=Symbol(""),s$=Symbol(""),sD=Symbol(""),sF=Symbol(""),sV=Symbol(""),sB=Symbol(""),sU={[sn]:"Fragment",[sr]:"Teleport",[si]:"Suspense",[sl]:"KeepAlive",[ss]:"BaseTransition",[so]:"openBlock",[sa]:"createBlock",[sc]:"createElementBlock",[su]:"createVNode",[sd]:"createElementVNode",[sp]:"createCommentVNode",[sf]:"createTextVNode",[sh]:"createStaticVNode",[sm]:"resolveComponent",[sg]:"resolveDynamicComponent",[sy]:"resolveDirective",[sv]:"resolveFilter",[sb]:"withDirectives",[s_]:"renderList",[sS]:"renderSlot",[sx]:"createSlots",[sC]:"toDisplayString",[sk]:"mergeProps",[sT]:"normalizeClass",[sN]:"normalizeStyle",[sw]:"normalizeProps",[sA]:"guardReactiveProps",[sE]:"toHandlers",[sI]:"camelize",[sR]:"capitalize",[sO]:"toHandlerKey",[sP]:"setBlockTracking",[sM]:"pushScopeId",[sL]:"popScopeId",[s$]:"withCtx",[sD]:"unref",[sF]:"isRef",[sV]:"withMemo",[sB]:"isMemoSame"},sj={start:{line:1,column:1,offset:0},end:{line:1,column:1,offset:0},source:""};function sH(e,t,n,r,i,l,s,o=!1,a=!1,c=!1,u=sj){return e&&(o?(e.helper(so),e.helper(e.inSSR||c?sa:sc)):e.helper(e.inSSR||c?su:sd),s&&e.helper(sb)),{type:13,tag:t,props:n,children:r,patchFlag:i,dynamicProps:l,directives:s,isBlock:o,disableTracking:a,isComponent:c,loc:u}}function sq(e,t=sj){return{type:17,loc:t,elements:e}}function sW(e,t=sj){return{type:15,loc:t,properties:e}}function sK(e,t){return{type:16,loc:sj,key:M(e)?sz(e,!0):e,value:t}}function sz(e,t=!1,n=sj,r=0){return{type:4,loc:n,content:e,isStatic:t,constType:t?3:r}}function sJ(e,t=sj){return{type:8,loc:t,children:e}}function sG(e,t=[],n=sj){return{type:14,loc:n,callee:e,arguments:t}}function sX(e,t,n=!1,r=!1,i=sj){return{type:18,params:e,returns:t,newline:n,isSlot:r,loc:i}}function sQ(e,t,n,r=!0){return{type:19,test:e,consequent:t,alternate:n,newline:r,loc:sj}}function sZ(e,{helper:t,removeHelper:n,inSSR:r}){if(!e.isBlock){var i,l;e.isBlock=!0,n((i=e.isComponent,r||i?su:sd)),t(so),t((l=e.isComponent,r||l?sa:sc))}}let sY=new Uint8Array([123,123]),s0=new Uint8Array([125,125]);function s1(e){return e>=97&&e<=122||e>=65&&e<=90}function s2(e){return 32===e||10===e||9===e||12===e||13===e}function s3(e){return 47===e||62===e||s2(e)}function s6(e){let t=new Uint8Array(e.length);for(let n=0;n4===e.type&&e.isStatic;function oe(e){switch(e){case"Teleport":case"teleport":return sr;case"Suspense":case"suspense":return si;case"KeepAlive":case"keep-alive":return sl;case"BaseTransition":case"base-transition":return ss}}let ot=/^\d|[^\$\w\xA0-\uFFFF]/,on=e=>!ot.test(e),or=/[A-Za-z_$\xA0-\uFFFF]/,oi=/[\.\?\w$\xA0-\uFFFF]/,ol=/\s+[.[]\s*|\s*[.[]\s+/g,os=e=>4===e.type?e.content:e.loc.source,oo=e=>{let t=os(e).trim().replace(ol,e=>e.trim()),n=0,r=[],i=0,l=0,s=null;for(let e=0;e|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/,oc=e=>oa.test(os(e));function ou(e,t,n=!1){for(let r=0;r4===e.key.type&&e.key.content===r)}return n}function o_(e,t){return`_${t}_${e.replace(/[^\w]/g,(t,n)=>"-"===t?"_":e.charCodeAt(n).toString())}`}let oS=/([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/,ox={parseMode:"base",ns:0,delimiters:["{{","}}"],getNamespace:()=>0,isVoidTag:S,isPreTag:S,isIgnoreNewlineTag:S,isCustomElement:S,onError:s8,onWarn:s5,comments:!1,prefixIdentifiers:!1},oC=ox,ok=null,oT="",oN=null,ow=null,oA="",oE=-1,oI=-1,oR=0,oO=!1,oP=null,oM=[],oL=new class{constructor(e,t){this.stack=e,this.cbs=t,this.state=1,this.buffer="",this.sectionStart=0,this.index=0,this.entityStart=0,this.baseState=1,this.inRCDATA=!1,this.inXML=!1,this.inVPre=!1,this.newlines=[],this.mode=0,this.delimiterOpen=sY,this.delimiterClose=s0,this.delimiterIndex=-1,this.currentSequence=void 0,this.sequenceIndex=0}get inSFCRoot(){return 2===this.mode&&0===this.stack.length}reset(){this.state=1,this.mode=0,this.buffer="",this.sectionStart=0,this.index=0,this.baseState=1,this.inRCDATA=!1,this.currentSequence=void 0,this.newlines.length=0,this.delimiterOpen=sY,this.delimiterClose=s0}getPos(e){let t=1,n=e+1;for(let r=this.newlines.length-1;r>=0;r--){let i=this.newlines[r];if(e>i){t=r+2,n=e-i;break}}return{column:n,line:t,offset:e}}peek(){return this.buffer.charCodeAt(this.index+1)}stateText(e){60===e?(this.index>this.sectionStart&&this.cbs.ontext(this.sectionStart,this.index),this.state=5,this.sectionStart=this.index):this.inVPre||e!==this.delimiterOpen[0]||(this.state=2,this.delimiterIndex=0,this.stateInterpolationOpen(e))}stateInterpolationOpen(e){if(e===this.delimiterOpen[this.delimiterIndex]){if(this.delimiterIndex===this.delimiterOpen.length-1){let e=this.index+1-this.delimiterOpen.length;e>this.sectionStart&&this.cbs.ontext(this.sectionStart,e),this.state=3,this.sectionStart=e}else this.delimiterIndex++}else this.inRCDATA?(this.state=32,this.stateInRCDATA(e)):(this.state=1,this.stateText(e))}stateInterpolation(e){e===this.delimiterClose[0]&&(this.state=4,this.delimiterIndex=0,this.stateInterpolationClose(e))}stateInterpolationClose(e){e===this.delimiterClose[this.delimiterIndex]?this.delimiterIndex===this.delimiterClose.length-1?(this.cbs.oninterpolation(this.sectionStart,this.index+1),this.inRCDATA?this.state=32:this.state=1,this.sectionStart=this.index+1):this.delimiterIndex++:(this.state=3,this.stateInterpolation(e))}stateSpecialStartSequence(e){let t=this.sequenceIndex===this.currentSequence.length;if(t?s3(e):(32|e)===this.currentSequence[this.sequenceIndex]){if(!t){this.sequenceIndex++;return}}else this.inRCDATA=!1;this.sequenceIndex=0,this.state=6,this.stateInTagName(e)}stateInRCDATA(e){if(this.sequenceIndex===this.currentSequence.length){if(62===e||s2(e)){let t=this.index-this.currentSequence.length;if(this.sectionStart=e||(28===this.state?this.currentSequence===s4.CdataEnd?this.cbs.oncdata(this.sectionStart,e):this.cbs.oncomment(this.sectionStart,e):6===this.state||11===this.state||18===this.state||17===this.state||12===this.state||13===this.state||14===this.state||15===this.state||16===this.state||20===this.state||19===this.state||21===this.state||9===this.state||this.cbs.ontext(this.sectionStart,e))}emitCodePoint(e,t){}}(oM,{onerr:oQ,ontext(e,t){oB(oF(e,t),e,t)},ontextentity(e,t,n){oB(e,t,n)},oninterpolation(e,t){if(oO)return oB(oF(e,t),e,t);let n=e+oL.delimiterOpen.length,r=t-oL.delimiterClose.length;for(;s2(oT.charCodeAt(n));)n++;for(;s2(oT.charCodeAt(r-1));)r--;let i=oF(n,r);i.includes("&")&&(i=oC.decodeEntities(i,!1)),oz({type:5,content:oX(i,!1,oJ(n,r)),loc:oJ(e,t)})},onopentagname(e,t){let n=oF(e,t);oN={type:1,tag:n,ns:oC.getNamespace(n,oM[0],oC.ns),tagType:0,props:[],children:[],loc:oJ(e-1,t),codegenNode:void 0}},onopentagend(e){oV(e)},onclosetag(e,t){let n=oF(e,t);if(!oC.isVoidTag(n)){let r=!1;for(let e=0;e0&&oM[0].loc.start.offset;for(let n=0;n<=e;n++)oU(oM.shift(),t,n(7===e.type?e.rawName:e.name)===t)},onattribend(e,t){oN&&ow&&(oG(ow.loc,t),0!==e&&(oA.includes("&")&&(oA=oC.decodeEntities(oA,!0)),6===ow.type?("class"===ow.name&&(oA=oK(oA).trim()),ow.value={type:2,content:oA,loc:1===e?oJ(oE,oI):oJ(oE-1,oI+1)},oL.inSFCRoot&&"template"===oN.tag&&"lang"===ow.name&&oA&&"html"!==oA&&oL.enterRCDATA(s6("{let i=t.start.offset+n,l=i+e.length;return oX(e,!1,oJ(i,l),0,r?1:0)},o={source:s(l.trim(),n.indexOf(l,i.length)),value:void 0,key:void 0,index:void 0,finalized:!1},a=i.trim().replace(oD,"").trim(),c=i.indexOf(a),u=a.match(o$);if(u){let e;a=a.replace(o$,"").trim();let t=u[1].trim();if(t&&(e=n.indexOf(t,c+a.length),o.key=s(t,e,!0)),u[2]){let r=u[2].trim();r&&(o.index=s(r,n.indexOf(r,o.key?e+t.length:c+a.length),!0))}}return a&&(o.value=s(a,c,!0)),o}(ow.exp)))),(7!==ow.type||"pre"!==ow.name)&&oN.props.push(ow)),oA="",oE=oI=-1},oncomment(e,t){oC.comments&&oz({type:3,content:oF(e,t),loc:oJ(e-4,t+3)})},onend(){let e=oT.length;for(let t=0;t64&&n<91||oe(e)||oC.isBuiltInComponent&&oC.isBuiltInComponent(e)||oC.isNativeTag&&!oC.isNativeTag(e))return!0;for(let e=0;e=0;)n--;return n}let oH=new Set(["if","else","else-if","for","slot"]),oq=/\r\n/g;function oW(e,t){let n="preserve"!==oC.whitespace,r=!1;for(let t=0;t1)for(let i=0;i{n--};for(;nt===e:t=>e.test(t);return(e,r)=>{if(1===e.type){let{props:i}=e;if(3===e.tagType&&i.some(oh))return;let l=[];for(let s=0;s`${sU[e]}: _${sU[e]}`;function o5(e,t,{helper:n,push:r,newline:i,isTS:l}){let s=n("component"===t?sm:sy);for(let n=0;n3;t.push("["),n&&t.indent(),o7(e,t,n),n&&t.deindent(),t.push("]")}function o7(e,t,n=!1,r=!0){let{push:i,newline:l}=t;for(let s=0;se||"null")}([s,o,a,n,u]),t),r(")"),p&&r(")"),d&&(r(", "),ae(d,t),r(")"))}(e,t);break;case 14:!function(e,t){let{push:n,helper:r,pure:i}=t,l=M(e.callee)?e.callee:r(e.callee);i&&n(o4),n(l+"(",-2,e),o7(e.arguments,t),n(")")}(e,t);break;case 15:!function(e,t){let{push:n,indent:r,deindent:i,newline:l}=t,{properties:s}=e;if(!s.length){n("{}",-2,e);return}let o=s.length>1;n(o?"{":"{ "),o&&r();for(let e=0;e "),(a||o)&&(n("{"),r()),s?(a&&n("return "),A(s)?o9(s,t):ae(s,t)):o&&ae(o,t),(a||o)&&(i(),n("}")),c&&n(")")}(e,t);break;case 19:!function(e,t){let{test:n,consequent:r,alternate:i,newline:l}=e,{push:s,indent:o,deindent:a,newline:c}=t;if(4===n.type){let e=!on(n.content);e&&s("("),at(n,t),e&&s(")")}else s("("),ae(n,t),s(")");l&&o(),t.indentLevel++,l||s(" "),s("? "),ae(r,t),t.indentLevel--,l&&c(),l||s(" "),s(": ");let u=19===i.type;!u&&t.indentLevel++,ae(i,t),!u&&t.indentLevel--,l&&a(!0)}(e,t);break;case 20:!function(e,t){let{push:n,helper:r,indent:i,deindent:l,newline:s}=t,{needPauseTracking:o,needArraySpread:a}=e;a&&n("[...("),n(`_cache[${e.index}] || (`),o&&(i(),n(`${r(sP)}(-1`),e.inVOnce&&n(", true"),n("),"),s(),n("(")),n(`_cache[${e.index}] = `),ae(e.value,t),o&&(n(`).cacheIndex = ${e.index},`),s(),n(`${r(sP)}(1),`),s(),n(`_cache[${e.index}]`),l()),n(")"),a&&n(")]")}(e,t);break;case 21:o7(e.body,t,!0,!1)}}function at(e,t){let{content:n,isStatic:r}=e;t.push(r?JSON.stringify(n):n,-3,e)}function an(e,t){for(let n=0;n(function(e,t,n,r){if("else"!==t.name&&(!t.exp||!t.exp.content.trim())){let r=t.exp?t.exp.loc:e.loc;n.onError(s9(28,t.loc)),t.exp=sz("true",!1,r)}if("if"===t.name){var i;let l=ai(e,t),s={type:9,loc:oJ((i=e.loc).start.offset,i.end.offset),branches:[l]};if(n.replaceNode(s),r)return r(s,l,!0)}else{let i=n.parent.children,l=i.indexOf(e);for(;l-- >=-1;){let s=i[l];if(s&&3===s.type||s&&2===s.type&&!s.content.trim().length){n.removeNode(s);continue}if(s&&9===s.type){"else-if"===t.name&&void 0===s.branches[s.branches.length-1].condition&&n.onError(s9(30,e.loc)),n.removeNode();let i=ai(e,t);s.branches.push(i);let l=r&&r(s,i,!1);o3(i,n),l&&l(),n.currentNode=null}else n.onError(s9(30,e.loc));break}}})(e,t,n,(e,t,r)=>{let i=n.parent.children,l=i.indexOf(e),s=0;for(;l-- >=0;){let e=i[l];e&&9===e.type&&(s+=e.branches.length)}return()=>{r?e.codegenNode=al(t,s,n):function(e){for(;;)if(19===e.type){if(19!==e.alternate.type)return e;e=e.alternate}else 20===e.type&&(e=e.value)}(e.codegenNode).alternate=al(t,s+e.branches.length-1,n)}}));function ai(e,t){let n=3===e.tagType;return{type:10,loc:e.loc,condition:"else"===t.name?void 0:t.exp,children:n&&!ou(e,"for")?e.children:[e],userKey:od(e,"key"),isTemplateIf:n}}function al(e,t,n){return e.condition?sQ(e.condition,as(e,t,n),sG(n.helper(sp),['""',"true"])):as(e,t,n)}function as(e,t,n){let{helper:r}=n,i=sK("key",sz(`${t}`,!1,sj,2)),{children:l}=e,s=l[0];if(1!==l.length||1!==s.type){if(1!==l.length||11!==s.type)return sH(n,r(sn),sW([i]),l,64,void 0,void 0,!0,!1,!1,e.loc);{let e=s.codegenNode;return ov(e,i,n),e}}{let e=s.codegenNode,t=14===e.type&&e.callee===sV?e.arguments[1].returns:e;return 13===t.type&&sZ(t,n),ov(t,i,n),e}}let ao=(e,t,n)=>{let{modifiers:r,loc:i}=e,l=e.arg,{exp:s}=e;if(s&&4===s.type&&!s.content.trim()&&(s=void 0),!s){if(4!==l.type||!l.isStatic)return n.onError(s9(52,l.loc)),{props:[sK(l,sz("",!0,i))]};aa(e),s=e.exp}return 4!==l.type?(l.children.unshift("("),l.children.push(') || ""')):l.isStatic||(l.content=`${l.content} || ""`),r.some(e=>"camel"===e.content)&&(4===l.type?l.isStatic?l.content=z(l.content):l.content=`${n.helperString(sI)}(${l.content})`:(l.children.unshift(`${n.helperString(sI)}(`),l.children.push(")"))),!n.inSSR&&(r.some(e=>"prop"===e.content)&&ac(l,"."),r.some(e=>"attr"===e.content)&&ac(l,"^")),{props:[sK(l,s)]}},aa=(e,t)=>{let n=e.arg,r=z(n.content);e.exp=sz(r,!1,n.loc)},ac=(e,t)=>{4===e.type?e.isStatic?e.content=t+e.content:e.content=`\`${t}\${${e.content}}\``:(e.children.unshift(`'${t}' + (`),e.children.push(")"))},au=o6("for",(e,t,n)=>{let{helper:r,removeHelper:i}=n;return function(e,t,n,r){if(!t.exp){n.onError(s9(31,t.loc));return}let i=t.forParseResult;if(!i){n.onError(s9(32,t.loc));return}ad(i);let{addIdentifiers:l,removeIdentifiers:s,scopes:o}=n,{source:a,value:c,key:u,index:d}=i,p={type:11,loc:t.loc,source:a,valueAlias:c,keyAlias:u,objectIndexAlias:d,parseResult:i,children:om(e)?e.children:[e]};n.replaceNode(p),o.vFor++;let f=r&&r(p);return()=>{o.vFor--,f&&f()}}(e,t,n,t=>{let l=sG(r(s_),[t.source]),s=om(e),o=ou(e,"memo"),a=od(e,"key",!1,!0);a&&7===a.type&&!a.exp&&aa(a);let c=a&&(6===a.type?a.value?sz(a.value.content,!0):void 0:a.exp),u=a&&c?sK("key",c):null,d=4===t.source.type&&t.source.constType>0,p=d?64:a?128:256;return t.codegenNode=sH(n,r(sn),void 0,l,p,void 0,void 0,!0,!d,!1,e.loc),()=>{let a;let{children:p}=t,f=1!==p.length||1!==p[0].type,h=og(e)?e:s&&1===e.children.length&&og(e.children[0])?e.children[0]:null;if(h)a=h.codegenNode,s&&u&&ov(a,u,n);else if(f)a=sH(n,r(sn),u?sW([u]):void 0,e.children,64,void 0,void 0,!0,void 0,!1);else{var m,g,y,b,_,S,x,C;a=p[0].codegenNode,s&&u&&ov(a,u,n),!d!==a.isBlock&&(a.isBlock?(i(so),i((m=n.inSSR,g=a.isComponent,m||g?sa:sc))):i((y=n.inSSR,b=a.isComponent,y||b?su:sd))),(a.isBlock=!d,a.isBlock)?(r(so),r((_=n.inSSR,S=a.isComponent,_||S?sa:sc))):r((x=n.inSSR,C=a.isComponent,x||C?su:sd))}if(o){let e=sX(ap(t.parseResult,[sz("_cached")]));e.body={type:21,body:[sJ(["const _memo = (",o.exp,")"]),sJ(["if (_cached",...c?[" && _cached.key === ",c]:[],` && ${n.helperString(sB)}(_cached, _memo)) return _cached`]),sJ(["const _item = ",a]),sz("_item.memo = _memo"),sz("return _item")],loc:sj},l.arguments.push(e,sz("_cache"),sz(String(n.cached.length))),n.cached.push(null)}else l.arguments.push(sX(ap(t.parseResult),a,!0))}})});function ad(e,t){e.finalized||(e.finalized=!0)}function ap({value:e,key:t,index:n},r=[]){return function(e){let t=e.length;for(;t--&&!e[t];);return e.slice(0,t+1).map((e,t)=>e||sz("_".repeat(t+1),!1))}([e,t,n,...r])}let af=sz("undefined",!1),ah=(e,t)=>{if(1===e.type&&(1===e.tagType||3===e.tagType)){let n=ou(e,"slot");if(n)return n.exp,t.scopes.vSlot++,()=>{t.scopes.vSlot--}}},am=(e,t,n,r)=>sX(e,n,!1,!0,n.length?n[0].loc:r);function ag(e,t,n){let r=[sK("name",e),sK("fn",t)];return null!=n&&r.push(sK("key",sz(String(n),!0))),sW(r)}let ay=new WeakMap,av=(e,t)=>function(){let n,r,i,l,s;if(!(1===(e=t.currentNode).type&&(0===e.tagType||1===e.tagType)))return;let{tag:o,props:a}=e,c=1===e.tagType,u=c?function(e,t,n=!1){let{tag:r}=e,i=aS(r),l=od(e,"is",!1,!0);if(l){if(i){let e;if(6===l.type?e=l.value&&sz(l.value.content,!0):(e=l.exp)||(e=sz("is",!1,l.arg.loc)),e)return sG(t.helper(sg),[e])}else 6===l.type&&l.value.content.startsWith("vue:")&&(r=l.value.content.slice(4))}let s=oe(r)||t.isBuiltInComponent(r);return s?(n||t.helper(s),s):(t.helper(sm),t.components.add(r),o_(r,"component"))}(e,t):`"${o}"`,d=$(u)&&u.callee===sg,p=0,f=d||u===sr||u===si||!c&&("svg"===o||"foreignObject"===o||"math"===o);if(a.length>0){let r=ab(e,t,void 0,c,d);n=r.props,p=r.patchFlag,l=r.dynamicPropNames;let i=r.directives;s=i&&i.length?sq(i.map(e=>(function(e,t){let n=[],r=ay.get(e);r?n.push(t.helperString(r)):(t.helper(sy),t.directives.add(e.name),n.push(o_(e.name,"directive")));let{loc:i}=e;if(e.exp&&n.push(e.exp),e.arg&&(e.exp||n.push("void 0"),n.push(e.arg)),Object.keys(e.modifiers).length){e.arg||(e.exp||n.push("void 0"),n.push("void 0"));let t=sz("true",!1,i);n.push(sW(e.modifiers.map(e=>sK(e,t)),i))}return sq(n,e.loc)})(e,t))):void 0,r.shouldUseBlock&&(f=!0)}if(e.children.length>0){if(u===sl&&(f=!0,p|=1024),c&&u!==sr&&u!==sl){let{slots:n,hasDynamicSlots:i}=function(e,t,n=am){t.helper(s$);let{children:r,loc:i}=e,l=[],s=[],o=t.scopes.vSlot>0||t.scopes.vFor>0,a=ou(e,"slot",!0);if(a){let{arg:e,exp:t}=a;e&&!s7(e)&&(o=!0),l.push(sK(e||sz("default",!0),n(t,void 0,r,i)))}let c=!1,u=!1,d=[],p=new Set,f=0;for(let e=0;esK("default",n(e,void 0,t,i));c?d.length&&d.some(e=>(function e(t){return 2!==t.type&&12!==t.type||(2===t.type?!!t.content.trim():e(t.content))})(e))&&(u?t.onError(s9(39,d[0].loc)):l.push(e(void 0,d))):l.push(e(void 0,r))}let h=o?2:!function e(t){for(let n=0;n0,h=!1,m=0,g=!1,y=!1,b=!1,_=!1,S=!1,C=!1,k=[],T=e=>{u.length&&(d.push(sW(a_(u),a)),u=[]),e&&d.push(e)},N=()=>{t.scopes.vFor>0&&u.push(sK(sz("ref_for",!0),sz("true")))},w=({key:e,value:n})=>{if(s7(e)){let l=e.content,s=x(l);s&&(!r||i)&&"onclick"!==l.toLowerCase()&&"onUpdate:modelValue"!==l&&!H(l)&&(_=!0),s&&H(l)&&(C=!0),s&&14===n.type&&(n=n.arguments[0]),20===n.type||(4===n.type||8===n.type)&&oY(n,t)>0||("ref"===l?g=!0:"class"===l?y=!0:"style"===l?b=!0:"key"===l||k.includes(l)||k.push(l),r&&("class"===l||"style"===l)&&!k.includes(l)&&k.push(l))}else S=!0};for(let i=0;i"prop"===e.content)&&(m|=32);let x=t.directiveTransforms[n];if(x){let{props:n,needRuntime:r}=x(s,e,t);l||n.forEach(w),_&&i&&!s7(i)?T(sW(n,a)):u.push(...n),r&&(p.push(s),L(r)&&ay.set(s,r))}else!q(n)&&(p.push(s),f&&(h=!0))}}if(d.length?(T(),s=d.length>1?sG(t.helper(sk),d,a):d[0]):u.length&&(s=sW(a_(u),a)),S?m|=16:(y&&!r&&(m|=2),b&&!r&&(m|=4),k.length&&(m|=8),_&&(m|=32)),!h&&(0===m||32===m)&&(g||C||p.length>0)&&(m|=512),!t.inSSR&&s)switch(s.type){case 15:let A=-1,E=-1,I=!1;for(let e=0;e{if(og(e)){let{children:n,loc:r}=e,{slotName:i,slotProps:l}=function(e,t){let n,r='"default"',i=[];for(let t=0;t0){let{props:r,directives:l}=ab(e,t,i,!1,!1);n=r,l.length&&t.onError(s9(36,l[0].loc))}return{slotName:r,slotProps:n}}(e,t),s=[t.prefixIdentifiers?"_ctx.$slots":"$slots",i,"{}","undefined","true"],o=2;l&&(s[2]=l,o=3),n.length&&(s[3]=sX([],n,!1,!1,r),o=4),t.scopeId&&!t.slotted&&(o=5),s.splice(o),e.codegenNode=sG(t.helper(sS),s,r)}},aC=(e,t,n,r)=>{let i;let{loc:l,modifiers:s,arg:o}=e;if(e.exp||s.length,4===o.type){if(o.isStatic){let e=o.content;e.startsWith("vue:")&&(e=`vnode-${e.slice(4)}`),i=sz(0!==t.tagType||e.startsWith("vnode")||!/[A-Z]/.test(e)?Q(z(e)):`on:${e}`,!0,o.loc)}else i=sJ([`${n.helperString(sO)}(`,o,")"])}else(i=o).children.unshift(`${n.helperString(sO)}(`),i.children.push(")");let a=e.exp;a&&!a.content.trim()&&(a=void 0);let c=n.cacheHandlers&&!a&&!n.inVOnce;if(a){let e=oo(a),t=!(e||oc(a)),n=a.content.includes(";");(t||c&&e)&&(a=sJ([`${t?"$event":"(...args)"} => ${n?"{":"("}`,a,n?"}":")"]))}let u={props:[sK(i,a||sz("() => {}",!1,l))]};return r&&(u=r(u)),c&&(u.props[0].value=n.cache(u.props[0].value)),u.props.forEach(e=>e.key.isHandlerKey=!0),u},ak=(e,t)=>{if(0===e.type||1===e.type||11===e.type||10===e.type)return()=>{let n;let r=e.children,i=!1;for(let e=0;e7===e.type&&!t.directiveTransforms[e.name]))))for(let e=0;e{if(1===e.type&&ou(e,"once",!0)&&!aT.has(e)&&!t.inVOnce&&!t.inSSR)return aT.add(e),t.inVOnce=!0,t.helper(sP),()=>{t.inVOnce=!1;let e=t.currentNode;e.codegenNode&&(e.codegenNode=t.cache(e.codegenNode,!0,!0))}},aw=(e,t,n)=>{let r;let{exp:i,arg:l}=e;if(!i)return n.onError(s9(41,e.loc)),aA();let s=i.loc.source.trim(),o=4===i.type?i.content:s,a=n.bindingMetadata[s];if("props"===a||"props-aliased"===a)return i.loc,aA();if(!o.trim()||!oo(i))return n.onError(s9(42,i.loc)),aA();let c=l||sz("modelValue",!0),u=l?s7(l)?`onUpdate:${z(l.content)}`:sJ(['"onUpdate:" + ',l]):"onUpdate:modelValue",d=n.isTS?"($event: any)":"$event";r=sJ([`${d} => ((`,i,") = $event)"]);let p=[sK(c,e.exp),sK(u,r)];if(e.modifiers.length&&1===t.tagType){let t=e.modifiers.map(e=>e.content).map(e=>(on(e)?e:JSON.stringify(e))+": true").join(", "),n=l?s7(l)?`${l.content}Modifiers`:sJ([l,' + "Modifiers"']):"modelModifiers";p.push(sK(n,sz(`{ ${t} }`,!1,e.loc,2)))}return aA(p)};function aA(e=[]){return{props:e}}let aE=new WeakSet,aI=(e,t)=>{if(1===e.type){let n=ou(e,"memo");if(!(!n||aE.has(e)))return aE.add(e),()=>{let r=e.codegenNode||t.currentNode.codegenNode;r&&13===r.type&&(1!==e.tagType&&sZ(r,t),e.codegenNode=sG(t.helper(sV),[n.exp,sX(void 0,r),"_cache",String(t.cached.length)]),t.cached.push(null))}}},aR=Symbol(""),aO=Symbol(""),aP=Symbol(""),aM=Symbol(""),aL=Symbol(""),a$=Symbol(""),aD=Symbol(""),aF=Symbol(""),aV=Symbol(""),aB=Symbol("");!function(e){Object.getOwnPropertySymbols(e).forEach(t=>{sU[t]=e[t]})}({[aR]:"vModelRadio",[aO]:"vModelCheckbox",[aP]:"vModelText",[aM]:"vModelSelect",[aL]:"vModelDynamic",[a$]:"withModifiers",[aD]:"withKeys",[aF]:"vShow",[aV]:"Transition",[aB]:"TransitionGroup"});let aU={parseMode:"html",isVoidTag:eh,isNativeTag:e=>ed(e)||ep(e)||ef(e),isPreTag:e=>"pre"===e,isIgnoreNewlineTag:e=>"pre"===e||"textarea"===e,decodeEntities:function(e,t=!1){return(f||(f=document.createElement("div")),t)?(f.innerHTML=`
`,f.children[0].getAttribute("foo")):(f.innerHTML=e,f.textContent)},isBuiltInComponent:e=>"Transition"===e||"transition"===e?aV:"TransitionGroup"===e||"transition-group"===e?aB:void 0,getNamespace(e,t,n){let r=t?t.ns:n;if(t&&2===r){if("annotation-xml"===t.tag){if("svg"===e)return 1;t.props.some(e=>6===e.type&&"encoding"===e.name&&null!=e.value&&("text/html"===e.value.content||"application/xhtml+xml"===e.value.content))&&(r=0)}else/^m(?:[ions]|text)$/.test(t.tag)&&"mglyph"!==e&&"malignmark"!==e&&(r=0)}else t&&1===r&&("foreignObject"===t.tag||"desc"===t.tag||"title"===t.tag)&&(r=0);if(0===r){if("svg"===e)return 1;if("math"===e)return 2}return r}},aj=(e,t)=>sz(JSON.stringify(ec(e)),!1,t,3),aH=g("passive,once,capture"),aq=g("stop,prevent,self,ctrl,shift,alt,meta,exact,middle"),aW=g("left,right"),aK=g("onkeyup,onkeydown,onkeypress"),az=(e,t,n,r)=>{let i=[],l=[],s=[];for(let n=0;ns7(e)&&"onclick"===e.content.toLowerCase()?sz(t,!0):4!==e.type?sJ(["(",e,`) === "onClick" ? "${t}" : (`,e,")"]):e,aG=(e,t)=>{1===e.type&&0===e.tagType&&("script"===e.tag||"style"===e.tag)&&t.removeNode()},aX=[e=>{1===e.type&&e.props.forEach((t,n)=>{6===t.type&&"style"===t.name&&t.value&&(e.props[n]={type:7,name:"bind",arg:sz("style",!0,t.loc),exp:aj(t.value.content,t.loc),modifiers:[],loc:t.loc})})}],aQ={cloak:()=>({props:[]}),html:(e,t,n)=>{let{exp:r,loc:i}=e;return r||n.onError(s9(53,i)),t.children.length&&(n.onError(s9(54,i)),t.children.length=0),{props:[sK(sz("innerHTML",!0,i),r||sz("",!0))]}},text:(e,t,n)=>{let{exp:r,loc:i}=e;return r||n.onError(s9(55,i)),t.children.length&&(n.onError(s9(56,i)),t.children.length=0),{props:[sK(sz("textContent",!0),r?oY(r,n)>0?r:sG(n.helperString(sC),[r],i):sz("",!0))]}},model:(e,t,n)=>{let r=aw(e,t,n);if(!r.props.length||1===t.tagType)return r;e.arg&&n.onError(s9(58,e.arg.loc));let{tag:i}=t,l=n.isCustomElement(i);if("input"===i||"textarea"===i||"select"===i||l){let s=aP,o=!1;if("input"===i||l){let r=od(t,"type");if(r){if(7===r.type)s=aL;else if(r.value)switch(r.value.content){case"radio":s=aR;break;case"checkbox":s=aO;break;case"file":o=!0,n.onError(s9(59,e.loc))}}else t.props.some(e=>7===e.type&&"bind"===e.name&&(!e.arg||4!==e.arg.type||!e.arg.isStatic))&&(s=aL)}else"select"===i&&(s=aM);o||(r.needRuntime=n.helper(s))}else n.onError(s9(57,e.loc));return r.props=r.props.filter(e=>!(4===e.key.type&&"modelValue"===e.key.content)),r},on:(e,t,n)=>aC(e,t,n,t=>{let{modifiers:r}=e;if(!r.length)return t;let{key:i,value:l}=t.props[0],{keyModifiers:s,nonKeyModifiers:o,eventOptionModifiers:a}=az(i,r,n,e.loc);if(o.includes("right")&&(i=aJ(i,"onContextmenu")),o.includes("middle")&&(i=aJ(i,"onMouseup")),o.length&&(l=sG(n.helper(a$),[l,JSON.stringify(o)])),s.length&&(!s7(i)||aK(i.content.toLowerCase()))&&(l=sG(n.helper(aD),[l,JSON.stringify(s)])),a.length){let e=a.map(X).join("");i=s7(i)?sz(`${i.content}${e}`,!0):sJ(["(",i,`) + "${e}"`])}return{props:[sK(i,l)]}}),show:(e,t,n)=>{let{exp:r,loc:i}=e;return!r&&n.onError(s9(61,i)),{props:[],needRuntime:n.helper(aF)}}},aZ=Object.create(null);function aY(e,t){if(!M(e)){if(!e.nodeType)return _;e=e.innerHTML}let n=e+JSON.stringify(t,(e,t)=>"function"==typeof t?t.toString():t),r=aZ[n];if(r)return r;if("#"===e[0]){let t=document.querySelector(e);e=t?t.innerHTML:""}let i=k({hoistStatic:!0,onError:void 0,onWarn:_},t);i.isCustomElement||"undefined"==typeof customElements||(i.isCustomElement=e=>!!customElements.get(e));let{code:l}=function(e,t={}){return function(e,t={}){let n=t.onError||s8,r="module"===t.mode;!0===t.prefixIdentifiers?n(s9(47)):r&&n(s9(48)),t.cacheHandlers&&n(s9(49)),t.scopeId&&!r&&n(s9(50));let i=k({},t,{prefixIdentifiers:!1}),l=M(e)?function(e,t){if(oL.reset(),oN=null,ow=null,oA="",oE=-1,oI=-1,oM.length=0,oT=e,oC=k({},ox),t){let e;for(e in t)null!=t[e]&&(oC[e]=t[e])}oL.mode="html"===oC.parseMode?1:"sfc"===oC.parseMode?2:0,oL.inXML=1===oC.ns||2===oC.ns;let n=t&&t.delimiters;n&&(oL.delimiterOpen=s6(n[0]),oL.delimiterClose=s6(n[1]));let r=ok=function(e,t=""){return{type:0,source:t,children:e,helpers:new Set,components:[],directives:[],hoists:[],imports:[],cached:[],temps:0,codegenNode:void 0,loc:sj}}([],e);return oL.parse(oT),r.loc=oJ(0,e.length),r.children=oW(r.children),ok=null,r}(e,i):e,[s,o]=[[aN,ar,aI,au,ax,av,ah,ak],{on:aC,bind:ao,model:aw}];return!function(e,t){let n=function(e,{filename:t="",prefixIdentifiers:n=!1,hoistStatic:r=!1,hmr:i=!1,cacheHandlers:l=!1,nodeTransforms:s=[],directiveTransforms:o={},transformHoist:a=null,isBuiltInComponent:c=_,isCustomElement:u=_,expressionPlugins:d=[],scopeId:p=null,slotted:f=!0,ssr:h=!1,inSSR:m=!1,ssrCssVars:g="",bindingMetadata:b=y,inline:S=!1,isTS:x=!1,onError:C=s8,onWarn:k=s5,compatConfig:T}){let N=t.replace(/\?.*$/,"").match(/([^/\\]+)\.\w+$/),w={filename:t,selfName:N&&X(z(N[1])),prefixIdentifiers:n,hoistStatic:r,hmr:i,cacheHandlers:l,nodeTransforms:s,directiveTransforms:o,transformHoist:a,isBuiltInComponent:c,isCustomElement:u,expressionPlugins:d,scopeId:p,slotted:f,ssr:h,inSSR:m,ssrCssVars:g,bindingMetadata:b,inline:S,isTS:x,onError:C,onWarn:k,compatConfig:T,root:e,helpers:new Map,components:new Set,directives:new Set,hoists:[],imports:[],cached:[],constantCache:new WeakMap,temps:0,identifiers:Object.create(null),scopes:{vFor:0,vSlot:0,vPre:0,vOnce:0},parent:null,grandParent:null,currentNode:e,childIndex:0,inVOnce:!1,helper(e){let t=w.helpers.get(e)||0;return w.helpers.set(e,t+1),e},removeHelper(e){let t=w.helpers.get(e);if(t){let n=t-1;n?w.helpers.set(e,n):w.helpers.delete(e)}},helperString:e=>`_${sU[w.helper(e)]}`,replaceNode(e){w.parent.children[w.childIndex]=w.currentNode=e},removeNode(e){let t=w.parent.children,n=e?t.indexOf(e):w.currentNode?w.childIndex:-1;e&&e!==w.currentNode?w.childIndex>n&&(w.childIndex--,w.onNodeRemoved()):(w.currentNode=null,w.onNodeRemoved()),w.parent.children.splice(n,1)},onNodeRemoved:_,addIdentifiers(e){},removeIdentifiers(e){},hoist(e){M(e)&&(e=sz(e)),w.hoists.push(e);let t=sz(`_hoisted_${w.hoists.length}`,!1,e.loc,2);return t.hoisted=e,t},cache(e,t=!1,n=!1){let r=function(e,t,n=!1,r=!1){return{type:20,index:e,value:t,needPauseTracking:n,inVOnce:r,needArraySpread:!1,loc:sj}}(w.cached.length,e,t,n);return w.cached.push(r),r}};return w}(e,t);o3(e,n),t.hoistStatic&&function e(t,n,r,i=!1,l=!1){let{children:s}=t,o=[];for(let n=0;n0){if(e>=2){a.codegenNode.patchFlag=-1,o.push(a);continue}}else{let e=a.codegenNode;if(13===e.type){let t=e.patchFlag;if((void 0===t||512===t||1===t)&&o1(a,r)>=2){let t=o2(a);t&&(e.props=r.hoist(t))}e.dynamicProps&&(e.dynamicProps=r.hoist(e.dynamicProps))}}}else if(12===a.type&&(i?0:oY(a,r))>=2){o.push(a);continue}if(1===a.type){let n=1===a.tagType;n&&r.scopes.vSlot++,e(a,t,r,!1,l),n&&r.scopes.vSlot--}else if(11===a.type)e(a,t,r,1===a.children.length,!0);else if(9===a.type)for(let n=0;ne.key===t||e.key.content===t);return n&&n.value}}o.length&&r.transformHoist&&r.transformHoist(s,r,t)}(e,void 0,n,oZ(e,e.children[0])),t.ssr||function(e,t){let{helper:n}=t,{children:r}=e;if(1===r.length){let n=r[0];if(oZ(e,n)&&n.codegenNode){let r=n.codegenNode;13===r.type&&sZ(r,t),e.codegenNode=r}else e.codegenNode=n}else r.length>1&&(e.codegenNode=sH(t,n(sn),void 0,e.children,64,void 0,void 0,!0,void 0,!1))}(e,n),e.helpers=new Set([...n.helpers.keys()]),e.components=[...n.components],e.directives=[...n.directives],e.imports=n.imports,e.hoists=n.hoists,e.temps=n.temps,e.cached=n.cached,e.transformed=!0}(l,k({},i,{nodeTransforms:[...s,...t.nodeTransforms||[]],directiveTransforms:k({},o,t.directiveTransforms||{})})),function(e,t={}){let n=function(e,{mode:t="function",prefixIdentifiers:n="module"===t,sourceMap:r=!1,filename:i="template.vue.html",scopeId:l=null,optimizeImports:s=!1,runtimeGlobalName:o="Vue",runtimeModuleName:a="vue",ssrRuntimeModuleName:c="vue/server-renderer",ssr:u=!1,isTS:d=!1,inSSR:p=!1}){let f={mode:t,prefixIdentifiers:n,sourceMap:r,filename:i,scopeId:l,optimizeImports:s,runtimeGlobalName:o,runtimeModuleName:a,ssrRuntimeModuleName:c,ssr:u,isTS:d,inSSR:p,source:e.source,code:"",column:1,line:1,offset:0,indentLevel:0,pure:!1,map:void 0,helper:e=>`_${sU[e]}`,push(e,t=-2,n){f.code+=e},indent(){h(++f.indentLevel)},deindent(e=!1){e?--f.indentLevel:h(--f.indentLevel)},newline(){h(f.indentLevel)}};function h(e){f.push("\n"+" ".repeat(e),0)}return f}(e,t);t.onContextCreated&&t.onContextCreated(n);let{mode:r,push:i,prefixIdentifiers:l,indent:s,deindent:o,newline:a,scopeId:c,ssr:u}=n,d=Array.from(e.helpers),p=d.length>0,f=!l&&"module"!==r;(function(e,t){let{ssr:n,prefixIdentifiers:r,push:i,newline:l,runtimeModuleName:s,runtimeGlobalName:o,ssrRuntimeModuleName:a}=t,c=Array.from(e.helpers);if(c.length>0&&(i(`const _Vue = ${o} +`,-1),e.hoists.length)){let e=[su,sd,sp,sf,sh].filter(e=>c.includes(e)).map(o8).join(", ");i(`const { ${e} } = _Vue +`,-1)}(function(e,t){if(!e.length)return;t.pure=!0;let{push:n,newline:r}=t;r();for(let i=0;i0)&&a()),e.directives.length&&(o5(e.directives,"directive",n),e.temps>0&&a()),e.temps>0){i("let ");for(let t=0;t0?", ":""}_temp${t}`)}return(e.components.length||e.directives.length||e.temps)&&(i(` +`,0),a()),u||i("return "),e.codegenNode?ae(e.codegenNode,n):i("null"),f&&(o(),i("}")),o(),i("}"),{ast:e,code:n.code,preamble:"",map:n.map?n.map.toJSON():void 0}}(l,i)}(e,k({},aU,t,{nodeTransforms:[aG,...aX,...t.nodeTransforms||[]],directiveTransforms:k({},aQ,t.directiveTransforms||{}),transformHoist:null}))}(e,i),s=Function(l)();return s._rc=!0,aZ[n]=s}return iU(aY),e.BaseTransition=n_,e.BaseTransitionPropsValidators=ny,e.Comment=io,e.DeprecationTypes=null,e.EffectScope=ex,e.ErrorCodes={SETUP_FUNCTION:0,0:"SETUP_FUNCTION",RENDER_FUNCTION:1,1:"RENDER_FUNCTION",NATIVE_EVENT_HANDLER:5,5:"NATIVE_EVENT_HANDLER",COMPONENT_EVENT_HANDLER:6,6:"COMPONENT_EVENT_HANDLER",VNODE_HOOK:7,7:"VNODE_HOOK",DIRECTIVE_HOOK:8,8:"DIRECTIVE_HOOK",TRANSITION_HOOK:9,9:"TRANSITION_HOOK",APP_ERROR_HANDLER:10,10:"APP_ERROR_HANDLER",APP_WARN_HANDLER:11,11:"APP_WARN_HANDLER",FUNCTION_REF:12,12:"FUNCTION_REF",ASYNC_COMPONENT_LOADER:13,13:"ASYNC_COMPONENT_LOADER",SCHEDULER:14,14:"SCHEDULER",COMPONENT_UPDATE:15,15:"COMPONENT_UPDATE",APP_UNMOUNT_CLEANUP:16,16:"APP_UNMOUNT_CLEANUP"},e.ErrorTypeStrings=null,e.Fragment=il,e.KeepAlive={name:"KeepAlive",__isKeepAlive:!0,props:{include:[String,RegExp,Array],exclude:[String,RegExp,Array],max:[String,Number]},setup(e,{slots:t}){let n=iL(),r=n.ctx,i=new Map,l=new Set,s=null,o=n.suspense,{renderer:{p:a,m:c,um:u,o:{createElement:d}}}=r,p=d("div");function f(e){nG(e),u(e,n,o,!0)}function h(e){i.forEach((t,n)=>{let r=iK(t.type);r&&!e(r)&&m(n)})}function m(e){let t=i.get(e);!t||s&&ib(t,s)?s&&nG(s):f(t),i.delete(e),l.delete(e)}r.activate=(e,t,n,r,i)=>{let l=e.component;c(e,t,n,0,o),a(l.vnode,e,t,n,l,o,r,e.slotScopeIds,i),rB(()=>{l.isDeactivated=!1,l.a&&Y(l.a);let t=e.props&&e.props.onVnodeMounted;t&&iR(t,l.parent,e)},o)},r.deactivate=e=>{let t=e.component;rz(t.m),rz(t.a),c(e,p,null,1,o),rB(()=>{t.da&&Y(t.da);let n=e.props&&e.props.onVnodeUnmounted;n&&iR(n,t.parent,e),t.isDeactivated=!0},o)},rX(()=>[e.include,e.exclude],([e,t])=>{e&&h(t=>nW(e,t)),t&&h(e=>!nW(t,e))},{flush:"post",deep:!0});let g=null,y=()=>{null!=g&&(r5(n.subTree.type)?rB(()=>{i.set(g,nX(n.subTree))},n.subTree.suspense):i.set(g,nX(n.subTree)))};return n0(y),n2(y),n3(()=>{i.forEach(e=>{let{subTree:t,suspense:r}=n,i=nX(t);if(e.type===i.type&&e.key===i.key){nG(i);let e=i.component.da;e&&rB(e,r);return}f(e)})}),()=>{if(g=null,!t.default)return s=null;let n=t.default(),r=n[0];if(n.length>1)return s=null,n;if(!iv(r)||!(4&r.shapeFlag)&&!(128&r.shapeFlag))return s=null,r;let o=nX(r);if(o.type===io)return s=null,o;let a=o.type,c=iK(nj(o)?o.type.__asyncResolved||{}:a),{include:u,exclude:d,max:p}=e;if(u&&(!c||!nW(u,c))||d&&c&&nW(d,c))return o.shapeFlag&=-257,s=o,r;let f=null==o.key?a:o.key,h=i.get(f);return o.el&&(o=iT(o),128&r.shapeFlag&&(r.ssContent=o)),g=f,h?(o.el=h.el,o.component=h.component,o.transition&&nT(o,o.transition),o.shapeFlag|=512,l.delete(f),l.add(f)):(l.add(f),p&&l.size>parseInt(p,10)&&m(l.values().next().value)),o.shapeFlag|=256,s=o,r5(r.type)?r:o}}},e.ReactiveEffect=ek,e.Static=ia,e.Suspense={name:"Suspense",__isSuspense:!0,process(e,t,n,r,i,l,s,o,a,c){if(null==e)(function(e,t,n,r,i,l,s,o,a){let{p:c,o:{createElement:u}}=a,d=u("div"),p=e.suspense=ie(e,i,r,t,d,n,l,s,o,a);c(null,p.pendingBranch=e.ssContent,d,null,r,p,l,s),p.deps>0?(r7(e,"onPending"),r7(e,"onFallback"),c(null,e.ssFallback,t,n,r,null,l,s),ii(p,e.ssFallback)):p.resolve(!1,!0)})(t,n,r,i,l,s,o,a,c);else{if(l&&l.deps>0&&!e.suspense.isInFallback){t.suspense=e.suspense,t.suspense.vnode=t,t.el=e.el;return}(function(e,t,n,r,i,l,s,o,{p:a,um:c,o:{createElement:u}}){let d=t.suspense=e.suspense;d.vnode=t,t.el=e.el;let p=t.ssContent,f=t.ssFallback,{activeBranch:h,pendingBranch:m,isInFallback:g,isHydrating:y}=d;if(m)d.pendingBranch=p,ib(p,m)?(a(m,p,d.hiddenContainer,null,i,d,l,s,o),d.deps<=0?d.resolve():g&&!y&&(a(h,f,n,r,i,null,l,s,o),ii(d,f))):(d.pendingId=r9++,y?(d.isHydrating=!1,d.activeBranch=m):c(m,i,d),d.deps=0,d.effects.length=0,d.hiddenContainer=u("div"),g?(a(null,p,d.hiddenContainer,null,i,d,l,s,o),d.deps<=0?d.resolve():(a(h,f,n,r,i,null,l,s,o),ii(d,f))):h&&ib(p,h)?(a(h,p,n,r,i,d,l,s,o),d.resolve(!0)):(a(null,p,d.hiddenContainer,null,i,d,l,s,o),d.deps<=0&&d.resolve()));else if(h&&ib(p,h))a(h,p,n,r,i,d,l,s,o),ii(d,p);else if(r7(t,"onPending"),d.pendingBranch=p,512&p.shapeFlag?d.pendingId=p.component.suspenseId:d.pendingId=r9++,a(null,p,d.hiddenContainer,null,i,d,l,s,o),d.deps<=0)d.resolve();else{let{timeout:e,pendingId:t}=d;e>0?setTimeout(()=>{d.pendingId===t&&d.fallback(f)},e):0===e&&d.fallback(f)}})(e,t,n,r,i,s,o,a,c)}},hydrate:function(e,t,n,r,i,l,s,o,a){let c=t.suspense=ie(t,r,n,e.parentNode,document.createElement("div"),null,i,l,s,o,!0),u=a(e,c.pendingBranch=t.ssContent,n,c,l,s);return 0===c.deps&&c.resolve(!1,!0),u},normalize:function(e){let{shapeFlag:t,children:n}=e,r=32&t;e.ssContent=it(r?n.default:n),e.ssFallback=r?it(n.fallback):iC(io)}},e.Teleport=nc,e.Text=is,e.TrackOpTypes={GET:"get",HAS:"has",ITERATE:"iterate"},e.Transition=i8,e.TransitionGroup=lF,e.TriggerOpTypes={SET:"set",ADD:"add",DELETE:"delete",CLEAR:"clear"},e.VueElement=lO,e.assertNumber=function(e,t){},e.callWithAsyncErrorHandling=tW,e.callWithErrorHandling=tq,e.camelize=z,e.capitalize=X,e.cloneVNode=iT,e.compatUtils=null,e.compile=aY,e.computed=iz,e.createApp=l9,e.createBlock=iy,e.createCommentVNode=function(e="",t=!1){return t?(id(),iy(io,null,e)):iC(io,null,e)},e.createElementBlock=function(e,t,n,r,i,l){return ig(ix(e,t,n,r,i,l,!0))},e.createElementVNode=ix,e.createHydrationRenderer=rU,e.createPropsRestProxy=function(e,t){let n={};for(let r in e)t.includes(r)||Object.defineProperty(n,r,{enumerable:!0,get:()=>e[r]});return n},e.createRenderer=function(e){return rj(e)},e.createSSRApp=l7,e.createSlots=function(e,t){for(let n=0;n{let t=r.fn(...e);return t&&(t.key=r.key),t}:r.fn)}return e},e.createStaticVNode=function(e,t){let n=iC(ia,null,e);return n.staticCount=t,n},e.createTextVNode=iN,e.createVNode=iC,e.customRef=tL,e.defineAsyncComponent=function(e){let t;P(e)&&(e={loader:e});let{loader:n,loadingComponent:r,errorComponent:i,delay:l=200,hydrate:s,timeout:o,suspensible:a=!0,onError:c}=e,u=null,d=0,p=()=>(d++,u=null,f()),f=()=>{let e;return u||(e=u=n().catch(e=>{if(e=e instanceof Error?e:Error(String(e)),c)return new Promise((t,n)=>{c(e,()=>t(p()),()=>n(e),d+1)});throw e}).then(n=>e!==u&&u?u:(n&&(n.__esModule||"Module"===n[Symbol.toStringTag])&&(n=n.default),t=n,n)))};return nw({name:"AsyncComponentWrapper",__asyncLoader:f,__asyncHydrate(e,n,r){let i=s?()=>{let t=s(r,t=>(function(e,t){if(nL(e)&&"["===e.data){let n=1,r=e.nextSibling;for(;r;){if(1===r.nodeType){if(!1===t(r))break}else if(nL(r)){if("]"===r.data){if(0==--n)break}else"["===r.data&&n++}r=r.nextSibling}}else t(e)})(e,t));t&&(n.bum||(n.bum=[])).push(t)}:r;t?i():f().then(()=>!n.isUnmounted&&i())},get __asyncResolved(){return t},setup(){let e=iM;if(nA(e),t)return()=>nH(t,e);let n=t=>{u=null,tK(t,e,13,!i)};if(a&&e.suspense)return f().then(t=>()=>nH(t,e)).catch(e=>(n(e),()=>i?iC(i,{error:e}):null));let s=tw(!1),c=tw(),d=tw(!!l);return l&&setTimeout(()=>{d.value=!1},l),null!=o&&setTimeout(()=>{if(!s.value&&!c.value){let e=Error(`Async component timed out after ${o}ms.`);n(e),c.value=e}},o),f().then(()=>{s.value=!0,e.parent&&nq(e.parent.vnode)&&e.parent.update()}).catch(e=>{n(e),c.value=e}),()=>s.value&&t?nH(t,e):c.value&&i?iC(i,{error:c.value}):r&&!d.value?iC(r):void 0}})},e.defineComponent=nw,e.defineCustomElement=lI,e.defineEmits=function(){return null},e.defineExpose=function(e){},e.defineModel=function(){},e.defineOptions=function(e){},e.defineProps=function(){return null},e.defineSSRCustomElement=(e,t)=>lI(e,t,l7),e.defineSlots=function(){return null},e.devtools=void 0,e.effect=function(e,t){e.effect instanceof ek&&(e=e.effect.fn);let n=new ek(e);t&&k(n,t);try{n.run()}catch(e){throw n.stop(),e}let r=n.run.bind(n);return r.effect=n,r},e.effectScope=function(e){return new ex(e)},e.getCurrentInstance=iL,e.getCurrentScope=function(){return i},e.getCurrentWatcher=function(){return h},e.getTransitionRawChildren=nN,e.guardReactiveProps=ik,e.h=iJ,e.handleError=tK,e.hasInjectionContext=function(){return!!(iM||t5||rx)},e.hydrate=(...e)=>{l8().hydrate(...e)},e.hydrateOnIdle=(e=1e4)=>t=>{let n=nB(t,{timeout:e});return()=>nU(n)},e.hydrateOnInteraction=(e=[])=>(t,n)=>{M(e)&&(e=[e]);let r=!1,i=e=>{r||(r=!0,l(),t(),e.target.dispatchEvent(new e.constructor(e.type,e)))},l=()=>{n(t=>{for(let n of e)t.removeEventListener(n,i)})};return n(t=>{for(let n of e)t.addEventListener(n,i,{once:!0})}),l},e.hydrateOnMediaQuery=e=>t=>{if(e){let n=matchMedia(e);if(!n.matches)return n.addEventListener("change",t,{once:!0}),()=>n.removeEventListener("change",t);t()}},e.hydrateOnVisible=e=>(t,n)=>{let r=new IntersectionObserver(e=>{for(let n of e)if(n.isIntersecting){r.disconnect(),t();break}},e);return n(e=>{if(e instanceof Element){if(function(e){let{top:t,left:n,bottom:r,right:i}=e.getBoundingClientRect(),{innerHeight:l,innerWidth:s}=window;return(t>0&&t0&&r0&&n0&&ir.disconnect()},e.initCustomFormatter=function(){},e.initDirectivesForSSR=_,e.inject=rk,e.isMemoSame=iG,e.isProxy=tS,e.isReactive=tv,e.isReadonly=tb,e.isRef=tN,e.isRuntimeOnly=()=>!u,e.isShallow=t_,e.isVNode=iv,e.markRaw=tC,e.mergeDefaults=function(e,t){let n=rc(e);for(let e in t){if(e.startsWith("__skip"))continue;let r=n[e];r?A(r)||P(r)?r=n[e]={type:r,default:t[e]}:r.default=t[e]:null===r&&(r=n[e]={default:t[e]}),r&&t[`__skip_${e}`]&&(r.skipFactory=!0)}return n},e.mergeModels=function(e,t){return e&&t?A(e)&&A(t)?e.concat(t):k({},rc(e),rc(t)):e||t},e.mergeProps=iI,e.nextTick=t0,e.normalizeClass=eu,e.normalizeProps=function(e){if(!e)return null;let{class:t,style:n}=e;return t&&!M(t)&&(e.class=eu(t)),n&&(e.style=el(n)),e},e.normalizeStyle=el,e.onActivated=nK,e.onBeforeMount=nY,e.onBeforeUnmount=n3,e.onBeforeUpdate=n1,e.onDeactivated=nz,e.onErrorCaptured=n9,e.onMounted=n0,e.onRenderTracked=n5,e.onRenderTriggered=n8,e.onScopeDispose=function(e,t=!1){i&&i.cleanups.push(e)},e.onServerPrefetch=n4,e.onUnmounted=n6,e.onUpdated=n2,e.onWatcherCleanup=tj,e.openBlock=id,e.popScopeId=function(){t9=null},e.provide=rC,e.proxyRefs=tP,e.pushScopeId=function(e){t9=e},e.queuePostFlushCb=t3,e.reactive=th,e.readonly=tg,e.ref=tw,e.registerRuntimeCompiler=iU,e.render=l5,e.renderList=function(e,t,n,r){let i;let l=n&&n[r],s=A(e);if(s||M(e)){let n=s&&tv(e),r=!1;n&&(r=!t_(e),e=eJ(e)),i=Array(e.length);for(let n=0,s=e.length;nt(e,n,void 0,l&&l[n]));else{let n=Object.keys(e);i=Array(n.length);for(let r=0,s=n.length;r!iv(t)||!!(t.type!==io&&(t.type!==il||e(t.children))))?t:null}(l(n)),o=n.key||s&&s.key,a=iy(il,{key:(o&&!L(o)?o:`_${t}`)+(!s&&r?"_fb":"")},s||(r?r():[]),s&&1===e._?64:-2);return!i&&a.scopeId&&(a.slotScopeIds=[a.scopeId+"-s"]),l&&l._c&&(l._d=!0),a},e.resolveComponent=function(e,t){return rt(n7,e,!0,t)||e},e.resolveDirective=function(e){return rt("directives",e)},e.resolveDynamicComponent=function(e){return M(e)?rt(n7,e,!1)||e:e||re},e.resolveFilter=null,e.resolveTransitionHooks=nx,e.setBlockTracking=im,e.setDevtoolsHook=_,e.setTransitionHooks=nT,e.shallowReactive=tm,e.shallowReadonly=function(e){return ty(e,!0,tt,tc,tf)},e.shallowRef=tA,e.ssrContextKey=rJ,e.ssrUtils=null,e.stop=function(e){e.effect.stop()},e.toDisplayString=eb,e.toHandlerKey=Q,e.toHandlers=function(e,t){let n={};for(let r in e)n[t&&/[A-Z]/.test(r)?`on:${r}`:Q(r)]=e[r];return n},e.toRaw=tx,e.toRef=function(e,t,n){return tN(e)?e:P(e)?new tD(e):$(e)&&arguments.length>1?tF(e,t,n):tw(e)},e.toRefs=function(e){let t=A(e)?Array(e.length):{};for(let n in e)t[n]=tF(e,n);return t},e.toValue=function(e){return P(e)?e():tR(e)},e.transformVNodeArgs=function(e){},e.triggerRef=function(e){e.dep&&e.dep.trigger()},e.unref=tR,e.useAttrs=function(){return ra().attrs},e.useCssModule=function(e="$style"){return y},e.useCssVars=function(e){let t=iL();if(!t)return;let n=t.ut=(n=e(t.proxy))=>{Array.from(document.querySelectorAll(`[data-v-owner="${t.uid}"]`)).forEach(e=>lf(e,n))},r=()=>{let r=e(t.proxy);t.ce?lf(t.ce,r):function e(t,n){if(128&t.shapeFlag){let r=t.suspense;t=r.activeBranch,r.pendingBranch&&!r.isHydrating&&r.effects.push(()=>{e(r.activeBranch,n)})}for(;t.component;)t=t.component.subTree;if(1&t.shapeFlag&&t.el)lf(t.el,n);else if(t.type===il)t.children.forEach(t=>e(t,n));else if(t.type===ia){let{el:e,anchor:r}=t;for(;e&&(lf(e,n),e!==r);)e=e.nextSibling}}(t.subTree,r),n(r)};n1(()=>{t3(r)}),n0(()=>{rX(r,_,{flush:"post"});let e=new MutationObserver(r);e.observe(t.subTree.el.parentNode,{childList:!0}),n6(()=>e.disconnect())})},e.useHost=lP,e.useId=function(){let e=iL();return e?(e.appContext.config.idPrefix||"v")+"-"+e.ids[0]+e.ids[1]++:""},e.useModel=function(e,t,n=y){let r=iL(),i=z(t),l=G(t),s=rY(e,i),o=tL((s,o)=>{let a,c;let u=y;return rG(()=>{let t=e[i];Z(a,t)&&(a=t,o())}),{get:()=>(s(),n.get?n.get(a):a),set(e){let s=n.set?n.set(e):e;if(!Z(s,a)&&!(u!==y&&Z(e,u)))return;let d=r.vnode.props;d&&(t in d||i in d||l in d)&&(`onUpdate:${t}`in d||`onUpdate:${i}`in d||`onUpdate:${l}`in d)||(a=e,o()),r.emit(`update:${t}`,s),Z(e,s)&&Z(e,u)&&!Z(s,c)&&o(),u=e,c=s}}});return o[Symbol.iterator]=()=>{let e=0;return{next:()=>e<2?{value:e++?s||y:o,done:!1}:{done:!0}}},o},e.useSSRContext=()=>{},e.useShadowRoot=function(){let e=lP();return e&&e.shadowRoot},e.useSlots=function(){return ra().slots},e.useTemplateRef=function(e){let t=iL(),n=tA(null);return t&&Object.defineProperty(t.refs===y?t.refs={}:t.refs,e,{enumerable:!0,get:()=>n.value,set:e=>n.value=e}),n},e.useTransitionState=nm,e.vModelCheckbox=lz,e.vModelDynamic={created(e,t,n){l0(e,t,n,null,"created")},mounted(e,t,n){l0(e,t,n,null,"mounted")},beforeUpdate(e,t,n,r){l0(e,t,n,r,"beforeUpdate")},updated(e,t,n,r){l0(e,t,n,r,"updated")}},e.vModelRadio=lG,e.vModelSelect=lX,e.vModelText=lK,e.vShow={beforeMount(e,{value:t},{transition:n}){e[lc]="none"===e.style.display?"":e.style.display,n&&t?n.beforeEnter(e):ld(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:r}){!t!=!n&&(r?t?(r.beforeEnter(e),ld(e,!0),r.enter(e)):r.leave(e,()=>{ld(e,!1)}):ld(e,t))},beforeUnmount(e,{value:t}){ld(e,t)}},e.version=iX,e.warn=_,e.watch=function(e,t,n){return rX(e,t,n)},e.watchEffect=function(e,t){return rX(e,null,t)},e.watchPostEffect=function(e,t){return rX(e,null,{flush:"post"})},e.watchSyncEffect=rG,e.withAsyncContext=function(e){let t=iL(),n=e();return iD(),D(n)&&(n=n.catch(e=>{throw i$(t),e})),[n,()=>i$(t)]},e.withCtx=ne,e.withDefaults=function(e,t){return null},e.withDirectives=function(e,t){if(null===t5)return e;let n=iW(t5),r=e.dirs||(e.dirs=[]);for(let e=0;e{let n=e._withKeys||(e._withKeys={}),r=t.join(".");return n[r]||(n[r]=n=>{if(!("key"in n))return;let r=G(n.key);if(t.some(e=>e===r||l3[e]===r))return e(n)})},e.withMemo=function(e,t,n,r){let i=n[r];if(i&&iG(i,e))return i;let l=t();return l.memo=e.slice(),l.cacheIndex=r,n[r]=l},e.withModifiers=(e,t)=>{let n=e._withMods||(e._withMods={}),r=t.join(".");return n[r]||(n[r]=(n,...r)=>{for(let e=0;ene,e}({}); diff --git a/android/app/src/main/java/com/pulsewall/app/MainActivity.kt b/android/app/src/main/java/com/pulsewall/app/MainActivity.kt new file mode 100644 index 0000000..8fd2bb2 --- /dev/null +++ b/android/app/src/main/java/com/pulsewall/app/MainActivity.kt @@ -0,0 +1,965 @@ +package com.pulsewall.app + +import android.annotation.SuppressLint +import android.app.AlertDialog +import android.content.Intent +import android.content.res.Configuration +import android.graphics.Color +import android.graphics.drawable.GradientDrawable +import android.graphics.drawable.StateListDrawable +import android.os.Bundle +import android.util.Base64 +import android.view.Gravity +import android.view.KeyEvent +import android.view.View +import android.view.ViewGroup +import android.view.WindowInsets +import android.view.WindowInsetsController +import android.view.WindowManager +import android.webkit.JavascriptInterface +import android.webkit.WebResourceRequest +import android.webkit.WebResourceResponse +import android.webkit.WebView +import android.webkit.WebViewClient +import android.widget.Button +import android.widget.EditText +import android.widget.FrameLayout +import android.widget.LinearLayout +import android.widget.ScrollView +import android.widget.TextView +import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity +import androidx.webkit.WebViewAssetLoader +import com.pulsewall.app.alert.NativeAlertController +import com.pulsewall.app.config.AppPrefs +import com.pulsewall.app.network.HubDiscoveryClient +import com.pulsewall.app.network.HubMessageListener +import com.pulsewall.app.network.HubWebSocketClient +import com.pulsewall.app.ota.AppUpdateManager +import com.pulsewall.app.sentinel.OpenAiRepairSentinel +import com.pulsewall.app.service.PulseWallKeepAliveService +import com.pulsewall.app.telemetry.DeviceTelemetryCollector +import kotlinx.coroutines.CompletableDeferred +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.cancel +import kotlinx.coroutines.launch +import kotlinx.coroutines.sync.Mutex +import kotlinx.coroutines.sync.withLock +import kotlinx.coroutines.withContext +import kotlinx.coroutines.withTimeoutOrNull +import org.json.JSONArray +import org.json.JSONObject +import java.util.concurrent.ConcurrentHashMap + +data class SandboxValidationOutcome( + val ok: Boolean, + val errors: List, + val overflowPx: Int +) + +data class ActiveRenderContext( + val taskId: String, + val snapshotId: String, + val mode: String, + val title: String, + var html: String, + var dataContext: JSONObject +) + +class MainActivity : AppCompatActivity(), HubMessageListener { + + private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main) + private lateinit var prefs: AppPrefs + private lateinit var telemetry: DeviceTelemetryCollector + private lateinit var alertController: NativeAlertController + private lateinit var wsClient: HubWebSocketClient + private lateinit var updateManager: AppUpdateManager + private val sentinel = OpenAiRepairSentinel() + + private lateinit var mainWebView: WebView + private lateinit var sandboxWebView: WebView + private lateinit var statusPill: TextView + + private var mainPageReady = false + private var sandboxPageReady = false + private var sandboxLoadWaiter: CompletableDeferred? = null + private val sandboxMutex = Mutex() + private var wsConnected = false + private var lastConnDetail = "正在连接中心桥..." + private var initialOtaChecked = false + private var autoDiscoveryTried = false + private var isShowingCustomCanvas = false + private var lastBackPressMs = 0L + + private val sandboxWaiters = ConcurrentHashMap>() + private val pendingClarificationTasks = ConcurrentHashMap() + private var activeRender: ActiveRenderContext? = null + private var lastRuntimeRepairAtMs = 0L + + @SuppressLint("SetJavaScriptEnabled") + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) + setShowWhenLocked(true) + setTurnScreenOn(true) + + prefs = AppPrefs(this) + telemetry = DeviceTelemetryCollector(this) + alertController = NativeAlertController(this) { alertId, interactionId, presetId, label, customText -> + sendInteractionReply(alertId, interactionId, presetId, label, customText) + } + updateManager = AppUpdateManager( + activity = this, + prefs = prefs, + scope = scope, + rootAvailableSupplier = { telemetry.isRootAvailable() } + ) + + val root = FrameLayout(this).apply { + setBackgroundColor(Color.parseColor("#0A0F1D")) + } + + val assetLoader = WebViewAssetLoader.Builder() + .addPathHandler("/assets/", WebViewAssetLoader.AssetsPathHandler(this)) + .build() + + // 1. Offscreen Validation Sandbox WebView (parked GONE + paused + about:blank when idle -> 0% CPU / 0MB GL) + sandboxWebView = WebView(this).apply { + alpha = 0f + visibility = View.GONE + isClickable = false + isFocusable = false + settings.javaScriptEnabled = true + settings.domStorageEnabled = true + addJavascriptInterface(SandboxJsBridge(), "SandboxBridge") + webViewClient = object : WebViewClient() { + override fun shouldInterceptRequest(view: WebView, request: WebResourceRequest): WebResourceResponse? { + return assetLoader.shouldInterceptRequest(request.url) + } + + override fun onPageFinished(view: WebView?, url: String?) { + if (url != null && url.contains("sandbox.html")) { + sandboxPageReady = true + sandboxLoadWaiter?.complete(true) + } else { + sandboxPageReady = false + } + } + } + loadUrl("about:blank") + onPause() + } + root.addView( + sandboxWebView, + FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) + ) + + // 2. Main WebView Canvas + mainWebView = WebView(this).apply { + setBackgroundColor(Color.parseColor("#0A0F1D")) + settings.javaScriptEnabled = true + settings.domStorageEnabled = true + addJavascriptInterface(MainJsBridge(), "AndroidBridge") + webViewClient = object : WebViewClient() { + override fun shouldInterceptRequest(view: WebView, request: WebResourceRequest): WebResourceResponse? { + return assetLoader.shouldInterceptRequest(request.url) + } + + override fun onPageFinished(view: WebView?, url: String?) { + mainPageReady = true + pushStatusToWebView() + if (prefs.lastHealthyHtml.isNotBlank()) { + mountHtmlOnMain( + ActiveRenderContext( + taskId = "restored", + snapshotId = prefs.lastHealthySnapshotId.ifBlank { "restored" }, + mode = "full", + title = "Restored", + html = prefs.lastHealthyHtml, + dataContext = JSONObject() + ) + ) + } + } + } + loadUrl("https://appassets.androidplatform.net/assets/pulsewall/host.html") + } + root.addView( + mainWebView, + FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) + ) + + // 3. Unbreakable Native Floating Status Pill (TV IR Remote Focusable + Touch Tap) + val pillFocused = GradientDrawable().apply { + setColor(Color.parseColor("#E61E3A5F")) + cornerRadius = dp(20).toFloat() + setStroke(dp(3), Color.parseColor("#FACC15")) + } + val pillNormal = GradientDrawable().apply { + setColor(Color.parseColor("#CC162038")) + cornerRadius = dp(20).toFloat() + setStroke(dp(1), Color.parseColor("#4438BDF8")) + } + val pillBg = StateListDrawable().apply { + addState(intArrayOf(android.R.attr.state_focused), pillFocused) + addState(intArrayOf(android.R.attr.state_pressed), pillFocused) + addState(intArrayOf(), pillNormal) + } + statusPill = TextView(this).apply { + text = "● 未连接 · ${prefs.deviceName} · ⚙ (MENU)" + isFocusable = true + isFocusableInTouchMode = true + setTextColor(Color.WHITE) + textSize = 13f + val hPad = dp(14) + val vPad = dp(8) + setPadding(hPad, vPad, hPad, vPad) + background = pillBg + setOnClickListener { showSettingsDialog() } + } + val pillLp = FrameLayout.LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT, + Gravity.TOP or Gravity.END + ).apply { + topMargin = dp(34) + marginEnd = dp(12) + } + root.addView(statusPill, pillLp) + setContentView(root) + applyImmersiveFullscreen() + + runCatching { + startForegroundService(Intent(this, PulseWallKeepAliveService::class.java)) + } + + wsClient = HubWebSocketClient( + prefs = prefs, + helloSupplier = { telemetry.collectHelloPayload(prefs.deviceId, prefs.deviceName) }, + telemetrySupplier = { telemetry.collectTelemetryPayload() }, + listener = this + ) + wsClient.start() + + // If still on default placeholder IP, proactively scan LAN UDP 8766 to auto-discover Hub + if (prefs.hubWsUrl == "ws://192.168.1.100:8765") { + runLanAutoDiscovery(silentIfNotFound = true) + } + } + + private fun applyImmersiveFullscreen() { + runCatching { + window.setDecorFitsSystemWindows(false) + window.insetsController?.let { ctrl -> + ctrl.hide(WindowInsets.Type.statusBars() or WindowInsets.Type.navigationBars()) + ctrl.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE + } + } + } + + override fun onWindowFocusChanged(hasFocus: Boolean) { + super.onWindowFocusChanged(hasFocus) + if (hasFocus) { + applyImmersiveFullscreen() + } + } + + override fun dispatchKeyEvent(event: KeyEvent): Boolean { + if (event.action == KeyEvent.ACTION_DOWN) { + when (event.keyCode) { + KeyEvent.KEYCODE_MENU, + KeyEvent.KEYCODE_SETTINGS, + KeyEvent.KEYCODE_INFO, + KeyEvent.KEYCODE_F1 -> { + showSettingsDialog() + return true + } + + KeyEvent.KEYCODE_BACK -> { + if (isShowingCustomCanvas) { + restoreHomeScreen(clearSavedSnapshot = true) + Toast.makeText(this, "已关闭动态页并返回默认首页", Toast.LENGTH_SHORT).show() + return true + } + val now = System.currentTimeMillis() + if (now - lastBackPressMs > 2000L) { + lastBackPressMs = now + Toast.makeText(this, "再按一次返回键退出 PulseWall", Toast.LENGTH_SHORT).show() + return true + } + } + + KeyEvent.KEYCODE_DPAD_UP, + KeyEvent.KEYCODE_DPAD_DOWN, + KeyEvent.KEYCODE_DPAD_LEFT, + KeyEvent.KEYCODE_DPAD_RIGHT, + KeyEvent.KEYCODE_DPAD_CENTER, + KeyEvent.KEYCODE_ENTER -> { + if (statusPill.visibility == View.VISIBLE && statusPill.hasFocus()) { + if (event.keyCode == KeyEvent.KEYCODE_DPAD_CENTER || event.keyCode == KeyEvent.KEYCODE_ENTER) { + showSettingsDialog() + return true + } + if (event.keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { + mainWebView.requestFocus() + mainWebView.evaluateJavascript("window.__pwFocusFirst && window.__pwFocusFirst();", null) + return true + } + } else if (mainPageReady) { + val dir = when (event.keyCode) { + KeyEvent.KEYCODE_DPAD_UP -> "up" + KeyEvent.KEYCODE_DPAD_DOWN -> "down" + KeyEvent.KEYCODE_DPAD_LEFT -> "left" + KeyEvent.KEYCODE_DPAD_RIGHT -> "right" + else -> "ok" + } + mainWebView.evaluateJavascript("window.__pwRemoteKey && window.__pwRemoteKey('$dir');", null) + return true + } + } + } + } + return super.dispatchKeyEvent(event) + } + + private fun runLanAutoDiscovery(silentIfNotFound: Boolean) { + if (!silentIfNotFound) { + Toast.makeText(this, "正在扫描局域网 PulseWall 中心桥 (UDP 8766)...", Toast.LENGTH_SHORT).show() + } + scope.launch { + val hubs = HubDiscoveryClient.discover(timeoutMs = 1800) + if (hubs.isNotEmpty()) { + val best = hubs.first() + prefs.hubWsUrl = best.wsUrl + lastConnDetail = "已自动发现中心桥: ${best.wsUrl},正在连接..." + pushStatusToWebView() + wsClient.reconnect() + Toast.makeText(this@MainActivity, "已自动发现中心桥: ${best.wsUrl}", Toast.LENGTH_LONG).show() + } else if (!silentIfNotFound) { + Toast.makeText( + this@MainActivity, + "未自动发现中心桥,请确认服务器已运行 ./hub/run_hub.sh 且放行 8765/8766 端口", + Toast.LENGTH_LONG + ).show() + } + } + } + + override fun onConfigurationChanged(newConfig: Configuration) { + super.onConfigurationChanged(newConfig) + pushStatusToWebView() + Thread { + val tele = telemetry.collectTelemetryPayload() + wsClient.sendFrame("device.telemetry", tele) + }.start() + } + + private fun updateStatusPillText() { + val dot = if (wsConnected) "🟢 已连接" else "🟠 未连接" + statusPill.text = "$dot · ${prefs.deviceName} · ⚙ (MENU)" + if (isShowingCustomCanvas) { + if (statusPill.hasFocus()) { + mainWebView.requestFocus() + } + statusPill.visibility = View.GONE + } else { + statusPill.visibility = View.VISIBLE + } + } + + override fun onConnectionChanged(connected: Boolean, detail: String) { + wsConnected = connected + if (detail.isNotBlank()) { + lastConnDetail = detail + } + runOnUiThread { + updateStatusPillText() + pushStatusToWebView() + if (connected && !initialOtaChecked) { + initialOtaChecked = true + updateManager.checkForUpdate(silentIfLatest = true) + } else if (!connected && !autoDiscoveryTried) { + autoDiscoveryTried = true + runLanAutoDiscovery(silentIfNotFound = true) + } + } + } + + override fun onHubFrame(type: String, payload: JSONObject) { + when (type) { + "config.push" -> { + prefs.applyHubConfigPush(payload) + wsClient.rescheduleTelemetry() + } + + "ota.available" -> { + updateManager.handleHubPush(payload) + } + + "feed.push" -> { + val sound = payload.optString("sound", "ding") + if (sound != "none") { + alertController.playSound(sound) + } + runOnUiThread { + val escaped = JSONObject.quote(payload.toString()) + mainWebView.evaluateJavascript("window.__pwPushFeed && window.__pwPushFeed($escaped);", null) + } + } + + "alert.trigger" -> { + alertController.showAlert(payload) + } + + "alert.dismiss" -> { + val aid = payload.optString("alert_id", "").ifBlank { null } + alertController.dismiss(aid) + } + + "render.apply" -> { + val ctx = ActiveRenderContext( + taskId = payload.optString("task_id", "task_${System.currentTimeMillis()}"), + snapshotId = payload.optString("snapshot_id", "snap_${System.currentTimeMillis()}"), + mode = payload.optString("mode", "full"), + title = payload.optString("title", ""), + html = payload.optString("html", ""), + dataContext = payload.optJSONObject("data_context") ?: JSONObject() + ) + scope.launch { runRenderPipeline(ctx, trigger = "initial_render", upstreamAnswers = null) } + } + + "render.rollback" -> { + val snapId = payload.optString("snapshot_id", "rollback") + val html = payload.optString("html", "") + if (snapId == "home" || html.isBlank()) { + restoreHomeScreen(clearSavedSnapshot = true) + } else { + val ctx = ActiveRenderContext("rollback", snapId, "full", "Rollback", html, JSONObject()) + mountHtmlOnMain(ctx) + prefs.lastHealthySnapshotId = snapId + prefs.lastHealthyHtml = html + } + } + + "render.home" -> { + restoreHomeScreen(clearSavedSnapshot = true) + } + + "clarification.answer" -> { + val taskId = payload.optString("task_id", "") + val pending = pendingClarificationTasks.remove(taskId) + val updatedHtml = payload.optString("updated_html", "").ifBlank { null } + val updatedData = payload.optJSONObject("updated_data") + val answers = payload.optJSONObject("answers") ?: JSONObject() + + if (pending != null) { + if (updatedData != null && updatedData.length() > 0) { + val keys = updatedData.keys() + while (keys.hasNext()) { + val k = keys.next() + pending.dataContext.put(k, updatedData.get(k)) + } + } + if (updatedHtml != null) { + pending.html = updatedHtml + scope.launch { runRenderPipeline(pending, trigger = "clarification_retry", upstreamAnswers = null) } + } else { + scope.launch { runRenderPipeline(pending, trigger = "clarification_retry", upstreamAnswers = answers) } + } + } + } + } + } + + private suspend fun runRenderPipeline( + ctx: ActiveRenderContext, + trigger: String, + upstreamAnswers: JSONObject? + ) { + val aiCfg = prefs.getRepairAiConfig() + val displayProfile = withContext(Dispatchers.Default) { telemetry.collectDisplayProfile() } + var candidateHtml = ctx.html + var attempts = 0 + var lastFixSummary = "" + var lastErrors: List = emptyList() + + // If upstream answered a clarification, let end-side Repair AI integrate the answer first + if (upstreamAnswers != null && aiCfg.enabled) { + val dec = sentinel.diagnoseAndRepair( + cfg = aiCfg, + currentHtml = candidateHtml, + errors = listOf("Apply upstream clarification answers and complete the template."), + displayProfile = displayProfile, + dataContext = ctx.dataContext, + upstreamAnswers = upstreamAnswers + ) + if (dec.action == "fix_locally" && !dec.fixedHtml.isNullOrBlank()) { + candidateHtml = dec.fixedHtml + lastFixSummary = dec.fixSummary + attempts++ + } + } + + val maxLoops = if (aiCfg.enabled) aiCfg.maxRetries + 1 else 1 + for (loopIdx in 0 until maxLoops) { + val check = validateInOffscreenSandbox(ctx.taskId, candidateHtml, ctx.dataContext, displayProfile) + if (check.ok) { + ctx.html = candidateHtml + activeRender = ctx + prefs.lastHealthySnapshotId = ctx.snapshotId + prefs.lastHealthyHtml = candidateHtml + mountHtmlOnMain(ctx) + + val status = if (attempts > 0) "rendered_after_local_fix" else "rendered" + sendRenderResult(ctx, trigger, status, attempts, candidateHtml, lastFixSummary, JSONArray(), emptyList()) + return + } + + lastErrors = check.errors + if (!aiCfg.enabled || loopIdx >= aiCfg.maxRetries) { + break + } + + val decision = sentinel.diagnoseAndRepair( + cfg = aiCfg, + currentHtml = candidateHtml, + errors = lastErrors, + displayProfile = displayProfile, + dataContext = ctx.dataContext + ) + + when (decision.action) { + "fix_locally" -> { + if (!decision.fixedHtml.isNullOrBlank()) { + candidateHtml = decision.fixedHtml + lastFixSummary = decision.fixSummary + attempts++ + } else { + break + } + } + + "ask_upstream" -> { + ctx.html = candidateHtml + pendingClarificationTasks[ctx.taskId] = ctx + sendRenderResult( + ctx = ctx, + trigger = trigger, + status = "needs_clarification", + attempts = attempts, + finalHtml = null, + fixSummary = decision.fixSummary, + questions = decision.clarificationQuestions, + errors = lastErrors + ) + return + } + + else -> { + lastErrors = lastErrors + listOf("RepairSentinel: ${decision.errorMessage}") + break + } + } + } + + // Fallback: keep/rollback last healthy snapshot + sendRenderResult(ctx, trigger, "failed_rolled_back", attempts, null, lastFixSummary, JSONArray(), lastErrors) + Toast.makeText(this, "页面校验未通过,已保持上一健康版本", Toast.LENGTH_SHORT).show() + } + + private suspend fun validateInOffscreenSandbox( + taskId: String, + html: String, + dataContext: JSONObject, + displayProfile: JSONObject + ): SandboxValidationOutcome { + if (html.isBlank()) { + return SandboxValidationOutcome(false, listOf("Empty HTML payload"), 0) + } + return sandboxMutex.withLock { + val deferred = CompletableDeferred() + sandboxWaiters[taskId] = deferred + try { + // Wake sandbox WebView ONLY for the brief validation window + val loadDeferred = CompletableDeferred() + withContext(Dispatchers.Main) { + sandboxPageReady = false + sandboxLoadWaiter = loadDeferred + sandboxWebView.visibility = View.INVISIBLE + sandboxWebView.onResume() + sandboxWebView.loadUrl("https://appassets.androidplatform.net/assets/pulsewall/sandbox.html") + } + val loaded = withTimeoutOrNull(2500L) { loadDeferred.await() } ?: false + if (!loaded) { + return@withLock SandboxValidationOutcome(true, emptyList(), 0) + } + + val payload = JSONObject().apply { + put("task_id", taskId) + put("html", html) + put("data_context", dataContext) + put("display_profile", displayProfile) + } + val b64 = Base64.encodeToString(payload.toString().toByteArray(Charsets.UTF_8), Base64.NO_WRAP) + withContext(Dispatchers.Main) { + sandboxWebView.evaluateJavascript("window.__pwValidateB64 && window.__pwValidateB64('$b64');", null) + } + + val res = withTimeoutOrNull(4000L) { deferred.await() } + res ?: SandboxValidationOutcome(false, listOf("Sandbox validation timed out (>4s)"), 0) + } finally { + sandboxWaiters.remove(taskId) + sandboxLoadWaiter = null + // CRITICAL: Always unload & freeze sandbox immediately after validation -> 0% background CPU/GL! + withContext(Dispatchers.Main) { + runCatching { + sandboxWebView.evaluateJavascript("window.__pwResetSandbox && window.__pwResetSandbox();", null) + sandboxWebView.loadUrl("about:blank") + sandboxWebView.onPause() + sandboxWebView.visibility = View.GONE + sandboxPageReady = false + } + } + } + } + } + + private fun mountHtmlOnMain(ctx: ActiveRenderContext) { + isShowingCustomCanvas = true + val payload = JSONObject().apply { + put("task_id", ctx.taskId) + put("snapshot_id", ctx.snapshotId) + put("mode", ctx.mode) + put("title", ctx.title) + put("html", ctx.html) + put("data_context", ctx.dataContext) + } + val b64 = Base64.encodeToString(payload.toString().toByteArray(Charsets.UTF_8), Base64.NO_WRAP) + runOnUiThread { + updateStatusPillText() + mainWebView.evaluateJavascript("window.__pwMountCanvas && window.__pwMountCanvas('$b64');", null) + } + } + + private fun restoreHomeScreen(clearSavedSnapshot: Boolean) { + isShowingCustomCanvas = false + activeRender = null + if (clearSavedSnapshot) { + prefs.lastHealthyHtml = "" + prefs.lastHealthySnapshotId = "" + } + runOnUiThread { + updateStatusPillText() + mainWebView.evaluateJavascript("window.__pwRestoreHome && window.__pwRestoreHome();", null) + pushStatusToWebView() + } + } + + private fun handleRuntimeConsoleError(snapshotId: String, taskId: String, source: String, message: String, stack: String) { + val report = JSONObject().apply { + put("snapshot_id", snapshotId) + put("task_id", taskId) + put("source", source) + put("message", message) + put("stack", stack.take(1000)) + put("repair_status", "observed") + } + wsClient.sendFrame("console.error_report", report) + + val aiCfg = prefs.getRepairAiConfig() + val cur = activeRender ?: return + val now = System.currentTimeMillis() + if (!aiCfg.enabled || now - lastRuntimeRepairAtMs < aiCfg.runtimeCooldownSec * 1000L) { + return + } + lastRuntimeRepairAtMs = now + scope.launch { + val profile = withContext(Dispatchers.Default) { telemetry.collectDisplayProfile() } + val dec = sentinel.diagnoseAndRepair( + cfg = aiCfg, + currentHtml = cur.html, + errors = listOf("Runtime $source: $message\n$stack"), + displayProfile = profile, + dataContext = cur.dataContext + ) + when (dec.action) { + "fix_locally" -> { + if (!dec.fixedHtml.isNullOrBlank()) { + cur.html = dec.fixedHtml + runRenderPipeline(cur, trigger = "runtime_watchdog", upstreamAnswers = null) + } + } + + "ask_upstream" -> { + pendingClarificationTasks[cur.taskId] = cur + sendRenderResult( + ctx = cur, + trigger = "runtime_watchdog", + status = "needs_clarification", + attempts = 1, + finalHtml = null, + fixSummary = dec.fixSummary, + questions = dec.clarificationQuestions, + errors = listOf("$source: $message") + ) + } + } + } + } + + private fun sendRenderResult( + ctx: ActiveRenderContext, + trigger: String, + status: String, + attempts: Int, + finalHtml: String?, + fixSummary: String, + questions: JSONArray, + errors: List + ) { + val payload = JSONObject().apply { + put("task_id", ctx.taskId) + put("snapshot_id", ctx.snapshotId) + put("trigger", trigger) + put("status", status) + put("attempts", attempts) + if (finalHtml != null) put("final_html", finalHtml) + put("local_fix_summary", fixSummary) + put("clarification_questions", questions) + put("errors", JSONArray(errors)) + } + wsClient.sendFrame("render.result", payload) + } + + private fun sendInteractionReply( + alertId: String, + interactionId: String, + presetId: String?, + label: String, + customText: String? + ) { + val payload = JSONObject().apply { + put("alert_id", alertId) + put("interaction_id", interactionId) + put("selected_preset_id", presetId) + put("selected_label", label) + put("custom_text", customText) + put("responded_at", System.currentTimeMillis()) + } + wsClient.sendFrame("interaction.reply", payload) + } + + private fun pushStatusToWebView() { + if (!mainPageReady) return + Thread { + val prof = telemetry.collectDisplayProfile() + val tele = telemetry.collectTelemetryPayload() + val safeTop = prof.optInt("safe_area_top_dp", 28) + val safeBot = prof.optInt("safe_area_bottom_dp", 16) + val pStr = JSONObject.quote(prof.toString()) + val tStr = JSONObject.quote(tele.toString()) + val dStr = JSONObject.quote(lastConnDetail) + runOnUiThread { + mainWebView.evaluateJavascript("window.__pwApplySafeArea && window.__pwApplySafeArea($safeTop,$safeBot);", null) + mainWebView.evaluateJavascript("window.__pwUpdateStatus && window.__pwUpdateStatus($wsConnected,$pStr,$tStr,$dStr);", null) + } + }.start() + } + + private fun showSettingsDialog() { + val container = LinearLayout(this).apply { + orientation = LinearLayout.VERTICAL + val p = dp(16) + setPadding(p, p, p, p) + } + + fun addField(label: String, initial: String): EditText { + container.addView(TextView(this).apply { text = label; textSize = 12f }) + val et = EditText(this).apply { setText(initial); isSingleLine = true } + container.addView(et) + return et + } + + val urlEt = addField("Python 中心桥 WebSocket 地址 (如 ws://192.168.x.x:8765)", prefs.hubWsUrl) + val discoverBtn = Button(this).apply { + text = "🔍 自动搜索局域网中心桥 (免输 IP)" + setOnClickListener { + scope.launch { + Toast.makeText(this@MainActivity, "正在搜索局域网中心桥...", Toast.LENGTH_SHORT).show() + val hubs = HubDiscoveryClient.discover(timeoutMs = 1800) + if (hubs.isNotEmpty()) { + urlEt.setText(hubs.first().wsUrl) + Toast.makeText(this@MainActivity, "已填入 ${hubs.first().wsUrl},请点【保存并重连】", Toast.LENGTH_LONG).show() + } else { + Toast.makeText(this@MainActivity, "未搜到中心桥,请确认已运行 ./hub/run_hub.sh", Toast.LENGTH_LONG).show() + } + } + } + } + container.addView(discoverBtn) + val idEt = addField("设备 ID (唯一标识)", prefs.deviceId) + val nameEt = addField("设备显示名称", prefs.deviceName) + val tokEt = addField("鉴权 Token (可选)", prefs.authToken) + + val aiCfg = prefs.getRepairAiConfig() + container.addView(TextView(this).apply { + text = "\n连接状态: $lastConnDetail\n版本: v${BuildConfig.VERSION_NAME} (build ${BuildConfig.VERSION_CODE}) · Root: ${if (telemetry.isRootAvailable()) "已启用" else "未检测到"}\n端侧修复 AI (由中心桥热下发): " + + if (aiCfg.enabled) "已启用 (${aiCfg.model})" else "未启用" + textSize = 12f + }) + + val checkUpdateBtn = Button(this).apply { + text = "🔄 检查 App 自更新 (OTA)" + setOnClickListener { + updateManager.checkForUpdate(silentIfLatest = false) + } + } + container.addView(checkUpdateBtn) + + val homeBtn = Button(this).apply { + text = "🏠 返回默认首页(关闭当前动态页)" + setOnClickListener { + restoreHomeScreen(clearSavedSnapshot = true) + Toast.makeText(this@MainActivity, "已恢复默认首页", Toast.LENGTH_SHORT).show() + } + } + container.addView(homeBtn) + + val testBtn = Button(this).apply { + text = "演练全屏红色警报" + setOnClickListener { + alertController.showAlert( + JSONObject() + .put("alert_id", "local_test") + .put("title", "本地紧急警报演练") + .put("message", "验证原生警报层、警报音、预设按钮与收起式输入框。") + .put("level", "critical") + .put("presentation", "fullscreen_alarm") + .put("sound", "siren") + .put("details_code", "RuntimeException: Demo stack trace line 42") + .put( + "interaction", + JSONObject() + .put("interaction_id", "local_int") + .put("allow_custom_input", true) + .put( + "presets", + JSONArray() + .put(JSONObject().put("id", "ack").put("label", "确认收到").put("style", "primary")) + .put(JSONObject().put("id", "fix").put("label", "通知 AI 处理").put("style", "danger")) + ) + ) + ) + } + } + container.addView(testBtn) + + val scrollWrapper = ScrollView(this).apply { addView(container) } + AlertDialog.Builder(this) + .setTitle("PulseWall 终端设置 (遥控器上下选择)") + .setView(scrollWrapper) + .setPositiveButton("保存并重连") { _, _ -> + prefs.hubWsUrl = urlEt.text.toString() + prefs.deviceId = idEt.text.toString() + prefs.deviceName = nameEt.text.toString() + prefs.authToken = tokEt.text.toString() + wsClient.reconnect() + Toast.makeText(this, "正在重连中心桥...", Toast.LENGTH_SHORT).show() + } + .setNegativeButton("取消", null) + .show() + } + + inner class MainJsBridge { + @JavascriptInterface + fun onWebAction(presetId: String, label: String, customText: String) { + sendInteractionReply( + alertId = "canvas", + interactionId = "canvas_${System.currentTimeMillis()}", + presetId = presetId, + label = label, + customText = customText.ifBlank { null } + ) + } + + @JavascriptInterface + fun onRuntimeError(snapshotId: String, taskId: String, source: String, message: String, stack: String) { + handleRuntimeConsoleError(snapshotId, taskId, source, message, stack) + } + + @JavascriptInterface + fun openSettings() { + runOnUiThread { showSettingsDialog() } + } + + @JavascriptInterface + fun discoverHub() { + runOnUiThread { runLanAutoDiscovery(silentIfNotFound = false) } + } + + @JavascriptInterface + fun checkUpdate() { + runOnUiThread { updateManager.checkForUpdate(silentIfLatest = false) } + } + + @JavascriptInterface + fun onFocusTopBar() { + runOnUiThread { + if (!isShowingCustomCanvas && statusPill.visibility == View.VISIBLE) { + statusPill.requestFocus() + } + } + } + } + + inner class SandboxJsBridge { + @JavascriptInterface + fun onValidationResult(taskId: String, ok: Boolean, errorsJson: String, overflowPx: Int) { + val errs = mutableListOf() + runCatching { + val arr = JSONArray(errorsJson) + for (i in 0 until arr.length()) errs.add(arr.optString(i)) + } + sandboxWaiters[taskId]?.complete(SandboxValidationOutcome(ok, errs, overflowPx)) + } + } + + private fun dp(v: Int): Int = (v * resources.displayMetrics.density).toInt() + + override fun onStart() { + super.onStart() + runCatching { + mainWebView.onResume() + if (mainPageReady) { + mainWebView.evaluateJavascript("window.__pwFreezeActiveLayer && window.__pwFreezeActiveLayer(false);", null) + } + } + } + + override fun onStop() { + super.onStop() + // Freeze WebView rendering/animations when Activity is hidden in background (WS keep-alive service stays active) + runCatching { + if (mainPageReady) { + mainWebView.evaluateJavascript("window.__pwFreezeActiveLayer && window.__pwFreezeActiveLayer(true);", null) + } + mainWebView.onPause() + } + } + + override fun onDestroy() { + super.onDestroy() + wsClient.stop() + telemetry.close() + alertController.destroy() + runCatching { + sandboxWebView.loadUrl("about:blank") + sandboxWebView.destroy() + mainWebView.loadUrl("about:blank") + mainWebView.destroy() + } + scope.cancel() + } +} diff --git a/android/app/src/main/java/com/pulsewall/app/alert/NativeAlertController.kt b/android/app/src/main/java/com/pulsewall/app/alert/NativeAlertController.kt new file mode 100644 index 0000000..43792ac --- /dev/null +++ b/android/app/src/main/java/com/pulsewall/app/alert/NativeAlertController.kt @@ -0,0 +1,416 @@ +package com.pulsewall.app.alert + +import android.app.Activity +import android.app.Dialog +import android.content.Context +import android.graphics.Color +import android.graphics.Typeface +import android.graphics.drawable.ColorDrawable +import android.graphics.drawable.GradientDrawable +import android.graphics.drawable.StateListDrawable +import android.media.AudioManager +import android.media.ToneGenerator +import android.os.Handler +import android.os.Looper +import android.os.PowerManager +import android.os.VibrationEffect +import android.os.Vibrator +import android.speech.tts.TextToSpeech +import android.view.Gravity +import android.view.View +import android.view.ViewGroup +import android.view.Window +import android.view.WindowManager +import android.widget.Button +import android.widget.EditText +import android.widget.LinearLayout +import android.widget.ScrollView +import android.widget.TextView +import android.widget.Toast +import org.json.JSONArray +import org.json.JSONObject +import java.util.Locale + +/** + * Native Unbreakable Alert Layer: + * Completely independent of WebView health. Handles ding/warning/siren sounds, + * TTS speech, vibration, wake-screen, fullscreen red emergency overlay, and + * Preset-First interactive dialogs (collapsible custom input at bottom). + */ +class NativeAlertController( + private val activity: Activity, + private val onInteractionReply: (alertId: String, interactionId: String, presetId: String?, label: String, customText: String?) -> Unit +) { + private val mainHandler = Handler(Looper.getMainLooper()) + private var activeDialog: Dialog? = null + private var activeAlertId: String? = null + private var sirenRunnable: Runnable? = null + private var flashRunnable: Runnable? = null + private var tts: TextToSpeech? = null + private var ttsReady = false + + init { + tts = TextToSpeech(activity.applicationContext) { status -> + if (status == TextToSpeech.SUCCESS) { + tts?.language = Locale.CHINA + ttsReady = true + } + } + } + + fun playSound(sound: String, ttsText: String? = null) { + stopSiren() + when (sound) { + "none" -> return + "ding" -> playTone(ToneGenerator.TONE_PROP_BEEP, 180) + "warning" -> playTone(ToneGenerator.TONE_PROP_BEEP2, 420) + "siren" -> startSirenLoop() + "tts" -> speakText(ttsText ?: "收到新提醒") + else -> playTone(ToneGenerator.TONE_PROP_BEEP, 180) + } + if (!ttsText.isNullOrBlank() && sound != "tts") { + mainHandler.postDelayed({ speakText(ttsText) }, 450) + } + } + + private fun playTone(tone: Int, durationMs: Int) { + try { + val tg = ToneGenerator(AudioManager.STREAM_ALARM, 90) + tg.startTone(tone, durationMs) + mainHandler.postDelayed({ runCatching { tg.release() } }, (durationMs + 120).toLong()) + } catch (_: Throwable) { + } + } + + private fun startSirenLoop() { + stopSiren() + var step = 0 + val r = object : Runnable { + override fun run() { + val tone = if (step % 2 == 0) ToneGenerator.TONE_CDMA_EMERGENCY_RINGBACK else ToneGenerator.TONE_SUP_ERROR + playTone(tone, 480) + step++ + if (step < 30) { + mainHandler.postDelayed(this, 650) + } + } + } + sirenRunnable = r + mainHandler.post(r) + } + + fun stopSiren() { + sirenRunnable?.let { mainHandler.removeCallbacks(it) } + sirenRunnable = null + flashRunnable?.let { mainHandler.removeCallbacks(it) } + flashRunnable = null + } + + private fun speakText(text: String) { + if (ttsReady) { + tts?.speak(text, TextToSpeech.QUEUE_FLUSH, null, "pw_tts_${System.currentTimeMillis()}") + } + } + + private fun triggerVibration(critical: Boolean) { + try { + @Suppress("DEPRECATION") + val vib = activity.getSystemService(Context.VIBRATOR_SERVICE) as? Vibrator ?: return + if (!vib.hasVibrator()) return + val pattern = if (critical) longArrayOf(0, 400, 180, 400, 180, 500) else longArrayOf(0, 140) + vib.vibrate(VibrationEffect.createWaveform(pattern, -1)) + } catch (_: Throwable) { + } + } + + private fun wakeScreen() { + try { + activity.setShowWhenLocked(true) + activity.setTurnScreenOn(true) + activity.window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) + val pm = activity.getSystemService(Context.POWER_SERVICE) as PowerManager + @Suppress("DEPRECATION") + val wl = pm.newWakeLock( + PowerManager.SCREEN_BRIGHT_WAKE_LOCK or PowerManager.ACQUIRE_CAUSES_WAKEUP, + "PulseWall:EmergencyWake" + ) + wl.acquire(15_000L) + } catch (_: Throwable) { + } + } + + fun showAlert(payload: JSONObject) { + mainHandler.post { + val alertId = payload.optString("alert_id", "alert_${System.currentTimeMillis()}") + val title = payload.optString("title", "PulseWall 提醒") + val message = payload.optString("message", "") + val level = payload.optString("level", "warning") + val presentation = payload.optString("presentation", "modal") + val sound = payload.optString("sound", "warning") + val vibrate = payload.optBoolean("vibrate", true) + val wake = payload.optBoolean("wake_screen", presentation == "fullscreen_alarm") + val ttsText = payload.optString("tts_text", "").ifBlank { null } + val detailsCode = payload.optString("details_code", "").ifBlank { null } + val interaction = payload.optJSONObject("interaction") + + // Synchronously clear any previous dialog/siren BEFORE starting new sound & new dialog! + dismissNowOnMain(null) + + if (wake) wakeScreen() + playSound(sound, ttsText) + if (vibrate) triggerVibration(presentation == "fullscreen_alarm" || level == "critical") + + if (presentation == "toast") { + Toast.makeText(activity, "$title: $message", Toast.LENGTH_LONG).show() + return@post + } + + activeAlertId = alertId + + val isFullscreen = presentation == "fullscreen_alarm" + val dialog = if (isFullscreen) { + Dialog(activity, android.R.style.Theme_Black_NoTitleBar_Fullscreen) + } else { + Dialog(activity) + } + dialog.requestWindowFeature(Window.FEATURE_NO_TITLE) + dialog.setCancelable(!isFullscreen) + dialog.setCanceledOnTouchOutside(!isFullscreen) + + val root = LinearLayout(activity).apply { + orientation = LinearLayout.VERTICAL + gravity = if (isFullscreen) Gravity.CENTER else Gravity.CENTER_HORIZONTAL + val pad = dp(20) + setPadding(pad, dp(28), pad, dp(24)) + setBackgroundColor(if (isFullscreen) Color.parseColor("#8B0000") else Color.parseColor("#111A2E")) + } + + if (isFullscreen) { + var toggle = false + val flash = object : Runnable { + override fun run() { + root.setBackgroundColor(if (toggle) Color.parseColor("#991B1B") else Color.parseColor("#450A0A")) + toggle = !toggle + mainHandler.postDelayed(this, 550) + } + } + flashRunnable = flash + mainHandler.post(flash) + } else { + root.background = GradientDrawable().apply { + setColor(Color.parseColor("#131C31")) + cornerRadius = dp(18).toFloat() + setStroke(dp(1), accentColorForLevel(level)) + } + } + + val badge = TextView(activity).apply { + text = if (isFullscreen) "🚨 紧急全屏警报 · ${level.uppercase()}" else "⚡ ${level.uppercase()}" + setTextColor(if (isFullscreen) Color.WHITE else accentColorForLevel(level)) + textSize = 13f + setTypeface(null, Typeface.BOLD) + } + root.addView(badge) + + val titleTv = TextView(activity).apply { + text = title + setTextColor(Color.WHITE) + textSize = if (isFullscreen) 26f else 20f + setTypeface(null, Typeface.BOLD) + setPadding(0, dp(8), 0, dp(8)) + } + root.addView(titleTv) + + val msgTv = TextView(activity).apply { + text = message + setTextColor(Color.parseColor("#E2E8F0")) + textSize = 15f + setPadding(0, 0, 0, dp(12)) + } + root.addView(msgTv) + + if (detailsCode != null) { + val codeTv = TextView(activity).apply { + text = detailsCode + setTextColor(Color.parseColor("#FDE68A")) + setBackgroundColor(Color.parseColor("#CC070B14")) + typeface = Typeface.MONOSPACE + textSize = 12f + val p = dp(10) + setPadding(p, p, p, p) + } + val scroll = ScrollView(activity).apply { + layoutParams = LinearLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + dp(130) + ).apply { bottomMargin = dp(14) } + addView(codeTv) + } + root.addView(scroll) + } + + // Preset-First Interaction Section + val interactionId = interaction?.optString("interaction_id", "int_$alertId") ?: "int_$alertId" + val presets: JSONArray = interaction?.optJSONArray("presets") ?: JSONArray().apply { + put(JSONObject().put("id", "ack").put("label", "确认收到").put("style", "primary")) + } + + var firstActionButton: Button? = null + for (i in 0 until presets.length()) { + val p = presets.optJSONObject(i) ?: continue + val pid = p.optString("id", "opt_$i") + val label = p.optString("label", "确认") + val style = p.optString("style", "primary") + val baseColor = when (style) { + "danger" -> Color.parseColor("#DC2626") + "secondary" -> Color.parseColor("#334155") + "success" -> Color.parseColor("#16A34A") + else -> Color.parseColor("#38BDF8") + } + val btn = Button(activity).apply { + text = label + isAllCaps = false + isFocusable = true + isFocusableInTouchMode = true + textSize = 16f + setTypeface(null, Typeface.BOLD) + setTextColor(if (style == "primary") Color.parseColor("#041220") else Color.WHITE) + background = buildFocusableButtonBg(baseColor) + layoutParams = LinearLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT + ).apply { topMargin = dp(10) } + setOnClickListener { + stopSiren() + dialog.dismiss() + onInteractionReply(alertId, interactionId, pid, label, null) + } + } + if (firstActionButton == null) firstActionButton = btn + root.addView(btn) + } + + // Collapsible Custom Free-Text Input at the very bottom (zero friction by default) + val allowCustom = interaction?.optBoolean("allow_custom_input", false) ?: false + if (allowCustom) { + val customContainer = LinearLayout(activity).apply { + orientation = LinearLayout.VERTICAL + visibility = View.GONE + setPadding(0, dp(10), 0, 0) + } + val edit = EditText(activity).apply { + hint = interaction?.optString("custom_input_placeholder", "输入自定义说明或指令...") + setHintTextColor(Color.parseColor("#94A3B8")) + setTextColor(Color.WHITE) + setBackgroundColor(Color.parseColor("#1E293B")) + val p = dp(10) + setPadding(p, p, p, p) + } + val sendBtn = Button(activity).apply { + text = "发送自定义指令" + isAllCaps = false + setTextColor(Color.WHITE) + setBackgroundColor(Color.parseColor("#0284C7")) + layoutParams = LinearLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT + ).apply { topMargin = dp(8) } + setOnClickListener { + val txt = edit.text.toString().trim() + if (txt.isNotEmpty()) { + stopSiren() + dialog.dismiss() + onInteractionReply(alertId, interactionId, "custom_input", "自定义输入", txt) + } + } + } + customContainer.addView(edit) + customContainer.addView(sendBtn) + + val toggleCustom = TextView(activity).apply { + text = "▾ 其他输入(手动打字)" + isFocusable = true + isFocusableInTouchMode = true + setTextColor(Color.parseColor("#CBD5E1")) + textSize = 13f + gravity = Gravity.CENTER + setPadding(dp(8), dp(12), dp(8), dp(8)) + background = buildFocusableButtonBg(Color.TRANSPARENT) + setOnClickListener { + customContainer.visibility = + if (customContainer.visibility == View.GONE) View.VISIBLE else View.GONE + } + } + root.addView(toggleCustom) + root.addView(customContainer) + } + + val outerScroll = ScrollView(activity).apply { + isFillViewport = isFullscreen + addView(root) + } + dialog.setContentView(outerScroll) + dialog.window?.apply { + setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) + if (isFullscreen) { + setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) + } else { + val w = (activity.resources.displayMetrics.widthPixels * 0.90).toInt() + setLayout(w, ViewGroup.LayoutParams.WRAP_CONTENT) + } + } + dialog.setOnDismissListener { stopSiren() } + activeDialog = dialog + dialog.show() + firstActionButton?.requestFocus() + } + } + + private fun dismissNowOnMain(alertId: String?) { + if (alertId == null || alertId == activeAlertId) { + stopSiren() + runCatching { activeDialog?.dismiss() } + activeDialog = null + activeAlertId = null + } + } + + fun dismiss(alertId: String?) { + if (Looper.myLooper() == Looper.getMainLooper()) { + dismissNowOnMain(alertId) + } else { + mainHandler.post { dismissNowOnMain(alertId) } + } + } + + fun destroy() { + stopSiren() + runCatching { activeDialog?.dismiss() } + runCatching { tts?.stop(); tts?.shutdown() } + } + + private fun accentColorForLevel(level: String): Int = when (level) { + "critical", "error" -> Color.parseColor("#EF4444") + "warning" -> Color.parseColor("#F59E0B") + else -> Color.parseColor("#38BDF8") + } + + private fun buildFocusableButtonBg(baseColor: Int): StateListDrawable { + val focused = GradientDrawable().apply { + cornerRadius = dp(12).toFloat() + setColor(baseColor) + setStroke(dp(3), Color.parseColor("#FACC15")) + } + val normal = GradientDrawable().apply { + cornerRadius = dp(12).toFloat() + setColor(baseColor) + } + return StateListDrawable().apply { + addState(intArrayOf(android.R.attr.state_focused), focused) + addState(intArrayOf(android.R.attr.state_pressed), focused) + addState(intArrayOf(), normal) + } + } + + private fun dp(v: Int): Int = (v * activity.resources.displayMetrics.density).toInt() +} diff --git a/android/app/src/main/java/com/pulsewall/app/config/AppPrefs.kt b/android/app/src/main/java/com/pulsewall/app/config/AppPrefs.kt new file mode 100644 index 0000000..59e98c5 --- /dev/null +++ b/android/app/src/main/java/com/pulsewall/app/config/AppPrefs.kt @@ -0,0 +1,107 @@ +package com.pulsewall.app.config + +import android.content.Context +import android.os.Build +import org.json.JSONObject +import java.util.UUID + +data class RepairAiConfig( + val enabled: Boolean = false, + val baseUrl: String = "https://api.openai.com/v1", + val apiKey: String = "", + val model: String = "gpt-4o-mini", + val timeoutSec: Int = 30, + val maxRetries: Int = 3, + val runtimeCooldownSec: Int = 30 +) + +class AppPrefs(context: Context) { + private val sp = context.getSharedPreferences("pulsewall_prefs", Context.MODE_PRIVATE) + + var hubWsUrl: String + get() = sp.getString("hub_ws_url", "ws://192.168.1.100:8765") ?: "ws://192.168.1.100:8765" + set(v) = sp.edit().putString("hub_ws_url", v.trim().trimEnd('/')).apply() + + var deviceId: String + get() { + var id = sp.getString("device_id", null) + if (id.isNullOrBlank()) { + val safeModel = (Build.MODEL ?: "android11") + .lowercase() + .replace(Regex("[^a-z0-9]+"), "-") + .trim('-') + .take(16) + id = "$safeModel-${UUID.randomUUID().toString().take(6)}" + sp.edit().putString("device_id", id).apply() + } + return id + } + set(v) = sp.edit().putString("device_id", v.trim()).apply() + + var deviceName: String + get() = sp.getString("device_name", "${Build.MANUFACTURER} ${Build.MODEL}") ?: "Android 11 Wall" + set(v) = sp.edit().putString("device_name", v.trim()).apply() + + var authToken: String + get() = sp.getString("auth_token", "") ?: "" + set(v) = sp.edit().putString("auth_token", v.trim()).apply() + + var telemetryIntervalSec: Int + get() = sp.getInt("telemetry_interval_sec", 3).coerceIn(1, 120) + set(v) = sp.edit().putInt("telemetry_interval_sec", v.coerceIn(1, 120)).apply() + + var lastHealthySnapshotId: String + get() = sp.getString("last_healthy_snapshot_id", "") ?: "" + set(v) = sp.edit().putString("last_healthy_snapshot_id", v).apply() + + var lastHealthyHtml: String + get() = sp.getString("last_healthy_html", "") ?: "" + set(v) = sp.edit().putString("last_healthy_html", v).apply() + + fun getRepairAiConfig(): RepairAiConfig { + return RepairAiConfig( + enabled = sp.getBoolean("ai_enabled", false), + baseUrl = sp.getString("ai_base_url", "https://api.openai.com/v1") ?: "https://api.openai.com/v1", + apiKey = sp.getString("ai_api_key", "") ?: "", + model = sp.getString("ai_model", "gpt-4o-mini") ?: "gpt-4o-mini", + timeoutSec = sp.getInt("ai_timeout_sec", 30).coerceIn(5, 120), + maxRetries = sp.getInt("ai_max_retries", 3).coerceIn(0, 5), + runtimeCooldownSec = sp.getInt("ai_runtime_cooldown_sec", 30).coerceIn(5, 300) + ) + } + + fun applyHubConfigPush(payload: JSONObject) { + val editor = sp.edit() + val ai = payload.optJSONObject("repair_ai") + if (ai != null) { + editor.putBoolean("ai_enabled", ai.optBoolean("enabled", false)) + editor.putString("ai_base_url", ai.optString("base_url", "https://api.openai.com/v1")) + editor.putString("ai_api_key", ai.optString("api_key", "")) + editor.putString("ai_model", ai.optString("model", "gpt-4o-mini")) + editor.putInt("ai_timeout_sec", ai.optInt("timeout_sec", 30)) + editor.putInt("ai_max_retries", ai.optInt("max_retries", 3)) + editor.putInt("ai_runtime_cooldown_sec", ai.optInt("runtime_cooldown_sec", 30)) + } + if (payload.has("telemetry_interval_sec")) { + editor.putInt("telemetry_interval_sec", payload.optInt("telemetry_interval_sec", 10)) + } + editor.apply() + } + + fun buildDeviceWsEndpoint(): String { + val base = hubWsUrl + val url = if (base.contains("/ws/device/")) base else "$base/ws/device/$deviceId" + return if (authToken.isNotBlank()) "$url?token=$authToken" else url + } + + fun buildHubHttpBaseUrl(): String { + val trimmed = hubWsUrl.trim().trimEnd('/') + val withoutWsPath = trimmed.substringBefore("/ws/device/") + return when { + withoutWsPath.startsWith("wss://", ignoreCase = true) -> "https://" + withoutWsPath.substring(6) + withoutWsPath.startsWith("ws://", ignoreCase = true) -> "http://" + withoutWsPath.substring(5) + withoutWsPath.startsWith("http://", ignoreCase = true) || withoutWsPath.startsWith("https://", ignoreCase = true) -> withoutWsPath + else -> "http://$withoutWsPath" + } + } +} diff --git a/android/app/src/main/java/com/pulsewall/app/network/HubDiscoveryClient.kt b/android/app/src/main/java/com/pulsewall/app/network/HubDiscoveryClient.kt new file mode 100644 index 0000000..af9cc16 --- /dev/null +++ b/android/app/src/main/java/com/pulsewall/app/network/HubDiscoveryClient.kt @@ -0,0 +1,87 @@ +package com.pulsewall.app.network + +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext +import org.json.JSONObject +import java.net.DatagramPacket +import java.net.DatagramSocket +import java.net.Inet4Address +import java.net.InetAddress +import java.net.NetworkInterface +import java.net.SocketTimeoutException + +data class DiscoveredHub( + val host: String, + val port: Int, + val hubName: String +) { + val wsUrl: String get() = "ws://$host:$port" +} + +/** + * Broadcasts a LAN UDP probe on port 8766 to auto-discover PulseWall Hub without typing IPs on a TV remote. + */ +object HubDiscoveryClient { + private const val DISCOVERY_PORT = 8766 + private val PROBE = "PULSEWALL_DISCOVER".toByteArray(Charsets.UTF_8) + + suspend fun discover(timeoutMs: Int = 1800): List = withContext(Dispatchers.IO) { + val found = linkedMapOf() + var socket: DatagramSocket? = null + try { + socket = DatagramSocket().apply { + broadcast = true + soTimeout = 400 + } + val targets = collectBroadcastAddresses() + for (addr in targets) { + runCatching { + val pkt = DatagramPacket(PROBE, PROBE.size, addr, DISCOVERY_PORT) + socket.send(pkt) + } + } + + val deadline = System.currentTimeMillis() + timeoutMs + val buf = ByteArray(2048) + while (System.currentTimeMillis() < deadline) { + try { + val rx = DatagramPacket(buf, buf.size) + socket.receive(rx) + val text = String(rx.data, 0, rx.length, Charsets.UTF_8) + val obj = JSONObject(text) + if (obj.optString("type") == "PULSEWALL_HUB_HERE") { + val host = rx.address.hostAddress ?: continue + val port = obj.optInt("port", 8765) + val name = obj.optString("hub_name", "PulseWall Hub") + found["$host:$port"] = DiscoveredHub(host, port, name) + } + } catch (_: SocketTimeoutException) { + // keep listening until deadline + } catch (_: Throwable) { + } + } + } catch (_: Throwable) { + } finally { + runCatching { socket?.close() } + } + found.values.toList() + } + + private fun collectBroadcastAddresses(): List { + val addrs = linkedSetOf() + runCatching { addrs.add(InetAddress.getByName("255.255.255.255")) } + runCatching { + val ifaces = NetworkInterface.getNetworkInterfaces() + while (ifaces.hasMoreElements()) { + val iface = ifaces.nextElement() + if (!iface.isUp || iface.isLoopback) continue + for (ia in iface.interfaceAddresses) { + if (ia.address is Inet4Address && ia.broadcast != null) { + addrs.add(ia.broadcast) + } + } + } + } + return addrs.toList() + } +} diff --git a/android/app/src/main/java/com/pulsewall/app/network/HubWebSocketClient.kt b/android/app/src/main/java/com/pulsewall/app/network/HubWebSocketClient.kt new file mode 100644 index 0000000..621db22 --- /dev/null +++ b/android/app/src/main/java/com/pulsewall/app/network/HubWebSocketClient.kt @@ -0,0 +1,148 @@ +package com.pulsewall.app.network + +import android.os.Handler +import android.os.Looper +import com.pulsewall.app.config.AppPrefs +import okhttp3.OkHttpClient +import okhttp3.Request +import okhttp3.Response +import okhttp3.WebSocket +import okhttp3.WebSocketListener +import org.json.JSONObject +import java.util.UUID +import java.util.concurrent.TimeUnit + +interface HubMessageListener { + fun onConnectionChanged(connected: Boolean, detail: String = "") + fun onHubFrame(type: String, payload: JSONObject) +} + +class HubWebSocketClient( + private val prefs: AppPrefs, + private val helloSupplier: () -> JSONObject, + private val telemetrySupplier: () -> JSONObject, + private val listener: HubMessageListener +) { + private val client = OkHttpClient.Builder() + .pingInterval(20, TimeUnit.SECONDS) + .readTimeout(0, TimeUnit.MILLISECONDS) + .build() + + private val handler = Handler(Looper.getMainLooper()) + private var webSocket: WebSocket? = null + private var closedByUser = false + private var connected = false + private var retryDelayMs = 2000L + + private val telemetryTick = object : Runnable { + override fun run() { + if (connected) { + Thread { + val data = runCatching { telemetrySupplier() }.getOrNull() + if (data != null) { + sendFrame("device.telemetry", data) + } + }.start() + } + handler.postDelayed(this, prefs.telemetryIntervalSec * 1000L) + } + } + + fun start() { + closedByUser = false + connectNow() + handler.removeCallbacks(telemetryTick) + handler.postDelayed(telemetryTick, prefs.telemetryIntervalSec * 1000L) + } + + fun rescheduleTelemetry() { + if (closedByUser) return + handler.removeCallbacks(telemetryTick) + handler.postDelayed(telemetryTick, prefs.telemetryIntervalSec * 1000L) + } + + fun reconnect() { + disconnectInternal() + retryDelayMs = 1500L + if (!closedByUser) connectNow() + } + + fun stop() { + closedByUser = true + handler.removeCallbacksAndMessages(null) + disconnectInternal() + } + + private fun disconnectInternal() { + connected = false + runCatching { webSocket?.close(1000, "Reconnect/Stop") } + webSocket = null + } + + private fun connectNow() { + if (closedByUser) return + val endpoint = prefs.buildDeviceWsEndpoint() + val req = try { + Request.Builder().url(endpoint).build() + } catch (e: Throwable) { + listener.onConnectionChanged(false, "地址格式错误: $endpoint (${e.message})") + scheduleReconnect() + return + } + + webSocket = client.newWebSocket(req, object : WebSocketListener() { + override fun onOpen(webSocket: WebSocket, response: Response) { + connected = true + retryDelayMs = 2000L + listener.onConnectionChanged(true, "已连接 $endpoint") + Thread { + val hello = runCatching { helloSupplier() }.getOrNull() + if (hello != null) sendFrame("device.hello", hello) + val tele = runCatching { telemetrySupplier() }.getOrNull() + if (tele != null) sendFrame("device.telemetry", tele) + }.start() + } + + override fun onMessage(webSocket: WebSocket, text: String) { + try { + val frame = JSONObject(text) + val type = frame.optString("type", "") + val payload = frame.optJSONObject("payload") ?: JSONObject() + listener.onHubFrame(type, payload) + } catch (_: Throwable) { + } + } + + override fun onClosed(webSocket: WebSocket, code: Int, reason: String) { + connected = false + listener.onConnectionChanged(false, "连接已断开 ($code $reason)") + scheduleReconnect() + } + + override fun onFailure(webSocket: WebSocket, t: Throwable, response: Response?) { + connected = false + val msg = t.message ?: t.javaClass.simpleName + listener.onConnectionChanged(false, "无法连接 ${prefs.hubWsUrl}: $msg") + scheduleReconnect() + } + }) + } + + private fun scheduleReconnect() { + if (closedByUser) return + val delay = retryDelayMs + retryDelayMs = (retryDelayMs * 2).coerceAtMost(20_000L) + handler.postDelayed({ connectNow() }, delay) + } + + fun sendFrame(type: String, payload: JSONObject): Boolean { + val ws = webSocket ?: return false + val envelope = JSONObject().apply { + put("type", type) + put("msg_id", UUID.randomUUID().toString()) + put("ts", System.currentTimeMillis()) + put("payload", payload) + } + return ws.send(envelope.toString()) + } +} diff --git a/android/app/src/main/java/com/pulsewall/app/ota/AppUpdateManager.kt b/android/app/src/main/java/com/pulsewall/app/ota/AppUpdateManager.kt new file mode 100644 index 0000000..efcdfef --- /dev/null +++ b/android/app/src/main/java/com/pulsewall/app/ota/AppUpdateManager.kt @@ -0,0 +1,253 @@ +package com.pulsewall.app.ota + +import android.app.Activity +import android.app.AlertDialog +import android.content.Intent +import android.widget.Toast +import androidx.core.content.FileProvider +import com.pulsewall.app.BuildConfig +import com.pulsewall.app.config.AppPrefs +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import okhttp3.OkHttpClient +import okhttp3.Request +import org.json.JSONObject +import java.io.File +import java.io.FileInputStream +import java.io.FileOutputStream +import java.security.MessageDigest +import java.util.concurrent.TimeUnit + +data class OtaReleaseInfo( + val versionCode: Int, + val versionName: String, + val sizeBytes: Long, + val sha256: String, + val changelog: String, + val downloadUrl: String +) + +/** + * Self-update (OTA) engine against Python Hub: + * - Auto-checks /api/ota/latest or responds to Hub `ota.available` WS push + * - Verifies SHA-256 before installation + * - Root devices: supports one-tap silent `pm install -r -S` + auto relaunch + * - Non-root devices: falls back to Android standard FileProvider package installer + */ +class AppUpdateManager( + private val activity: Activity, + private val prefs: AppPrefs, + private val scope: CoroutineScope, + private val rootAvailableSupplier: () -> Boolean +) { + private val httpClient = OkHttpClient.Builder() + .connectTimeout(15, TimeUnit.SECONDS) + .readTimeout(120, TimeUnit.SECONDS) + .build() + + @Volatile + private var checkingOrDownloading = false + + fun checkForUpdate(silentIfLatest: Boolean = false) { + if (checkingOrDownloading) return + checkingOrDownloading = true + scope.launch { + try { + val base = prefs.buildHubHttpBaseUrl() + val info = fetchLatestMeta(base) + if (info == null) { + if (!silentIfLatest) { + toast("中心桥暂未发布新版安装包") + } + return@launch + } + if (info.versionCode > BuildConfig.VERSION_CODE) { + promptUpdateDialog(info) + } else if (!silentIfLatest) { + toast("当前已是最新版本 v${BuildConfig.VERSION_NAME} (build ${BuildConfig.VERSION_CODE})") + } + } catch (t: Throwable) { + if (!silentIfLatest) { + toast("检测更新失败: ${t.message}") + } + } finally { + checkingOrDownloading = false + } + } + } + + fun handleHubPush(payload: JSONObject) { + val vCode = payload.optInt("version_code", 0) + if (vCode <= BuildConfig.VERSION_CODE) return + val base = prefs.buildHubHttpBaseUrl() + val dlPath = payload.optString("download_path", "/api/ota/download/pulsewall-latest.apk") + val dlUrl = if (dlPath.startsWith("http")) dlPath else "$base$dlPath" + val info = OtaReleaseInfo( + versionCode = vCode, + versionName = payload.optString("version_name", "unknown"), + sizeBytes = payload.optLong("size_bytes", 0L), + sha256 = payload.optString("sha256", ""), + changelog = payload.optString("changelog", "发现新版本"), + downloadUrl = dlUrl + ) + activity.runOnUiThread { promptUpdateDialog(info) } + } + + private suspend fun fetchLatestMeta(hubHttpBase: String): OtaReleaseInfo? = withContext(Dispatchers.IO) { + val req = Request.Builder().url("$hubHttpBase/api/ota/latest").get().build() + httpClient.newCall(req).execute().use { resp -> + if (!resp.isSuccessful) return@withContext null + val obj = JSONObject(resp.body?.string().orEmpty()) + if (!obj.optBoolean("available", false)) return@withContext null + val dlPath = obj.optString("download_path", "/api/ota/download/pulsewall-latest.apk") + OtaReleaseInfo( + versionCode = obj.optInt("version_code", 0), + versionName = obj.optString("version_name", "0.0.0"), + sizeBytes = obj.optLong("size_bytes", 0L), + sha256 = obj.optString("sha256", ""), + changelog = obj.optString("changelog", ""), + downloadUrl = "$hubHttpBase$dlPath" + ) + } + } + + private fun promptUpdateDialog(info: OtaReleaseInfo) { + val hasRoot = rootAvailableSupplier() + val mb = String.format("%.2f MB", info.sizeBytes / 1048576.0) + val msg = buildString { + appendLine("当前版本: v${BuildConfig.VERSION_NAME} (build ${BuildConfig.VERSION_CODE})") + appendLine("最新版本: v${info.versionName} (build ${info.versionCode}) · $mb") + if (info.changelog.isNotBlank()) { + appendLine() + appendLine("更新内容:") + append(info.changelog) + } + } + + val builder = AlertDialog.Builder(activity) + .setTitle("发现 PulseWall 新版本") + .setMessage(msg) + .setNegativeButton("稍后", null) + + if (hasRoot) { + builder.setPositiveButton("⚡ Root 静默更新并重启") { _, _ -> + downloadAndInstall(info, useRootSilent = true) + } + builder.setNeutralButton("常规安装") { _, _ -> + downloadAndInstall(info, useRootSilent = false) + } + } else { + builder.setPositiveButton("下载并安装") { _, _ -> + downloadAndInstall(info, useRootSilent = false) + } + } + builder.show() + } + + private fun downloadAndInstall(info: OtaReleaseInfo, useRootSilent: Boolean) { + if (checkingOrDownloading) return + checkingOrDownloading = true + toast("正在下载 v${info.versionName}...") + + scope.launch { + try { + val apkFile = downloadApk(info) + if (info.sha256.isNotBlank()) { + val actual = sha256Of(apkFile) + if (!actual.equals(info.sha256, ignoreCase = true)) { + apkFile.delete() + toast("校验失败:安装包 SHA-256 不匹配,已中止更新") + return@launch + } + } + + if (useRootSilent) { + toast("校验通过,正在 Root 静默安装并重启...") + val ok = installSilentlyWithRoot(apkFile) + if (!ok) { + toast("Root 静默安装失败,已自动切换常规安装界面") + launchStandardInstaller(apkFile) + } + } else { + launchStandardInstaller(apkFile) + } + } catch (t: Throwable) { + toast("更新失败: ${t.message}") + } finally { + checkingOrDownloading = false + } + } + } + + private suspend fun downloadApk(info: OtaReleaseInfo): File = withContext(Dispatchers.IO) { + val dir = File(activity.cacheDir, "ota").apply { mkdirs() } + val outFile = File(dir, "pulsewall-update.apk") + val req = Request.Builder().url(info.downloadUrl).get().build() + httpClient.newCall(req).execute().use { resp -> + if (!resp.isSuccessful) { + throw IllegalStateException("HTTP ${resp.code} downloading APK") + } + val body = resp.body ?: throw IllegalStateException("Empty APK response body") + body.byteStream().use { input -> + FileOutputStream(outFile).use { output -> + val buf = ByteArray(16384) + while (true) { + val n = input.read(buf) + if (n <= 0) break + output.write(buf, 0, n) + } + } + } + } + outFile + } + + private suspend fun sha256Of(file: File): String = withContext(Dispatchers.IO) { + val md = MessageDigest.getInstance("SHA-256") + FileInputStream(file).use { fis -> + val buf = ByteArray(16384) + while (true) { + val n = fis.read(buf) + if (n <= 0) break + md.update(buf, 0, n) + } + } + md.digest().joinToString("") { "%02x".format(it) } + } + + private suspend fun installSilentlyWithRoot(apkFile: File): Boolean = withContext(Dispatchers.IO) { + try { + val size = apkFile.length() + val safePath = apkFile.absolutePath.replace("'", "'\\''") + val cmd = "cat '$safePath' | pm install -r -S $size && am start -n ${BuildConfig.APPLICATION_ID}/.MainActivity" + val proc = ProcessBuilder("su", "-c", cmd).redirectErrorStream(true).start() + val finished = proc.waitFor(60, TimeUnit.SECONDS) + if (!finished) { + proc.destroyForcibly() + return@withContext false + } + val out = proc.inputStream.bufferedReader().readText() + proc.exitValue() == 0 && out.contains("Success", ignoreCase = true) + } catch (_: Throwable) { + false + } + } + + private fun launchStandardInstaller(apkFile: File) { + val uri = FileProvider.getUriForFile(activity, "${BuildConfig.APPLICATION_ID}.fileprovider", apkFile) + val intent = Intent(Intent.ACTION_VIEW).apply { + setDataAndType(uri, "application/vnd.android.package-archive") + addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) + addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + } + activity.startActivity(intent) + } + + private fun toast(msg: String) { + activity.runOnUiThread { + Toast.makeText(activity, msg, Toast.LENGTH_LONG).show() + } + } +} diff --git a/android/app/src/main/java/com/pulsewall/app/sentinel/OpenAiRepairSentinel.kt b/android/app/src/main/java/com/pulsewall/app/sentinel/OpenAiRepairSentinel.kt new file mode 100644 index 0000000..299c65b --- /dev/null +++ b/android/app/src/main/java/com/pulsewall/app/sentinel/OpenAiRepairSentinel.kt @@ -0,0 +1,136 @@ +package com.pulsewall.app.sentinel + +import com.pulsewall.app.config.RepairAiConfig +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.withContext +import okhttp3.MediaType.Companion.toMediaType +import okhttp3.OkHttpClient +import okhttp3.Request +import okhttp3.RequestBody.Companion.toRequestBody +import org.json.JSONArray +import org.json.JSONObject +import java.util.concurrent.TimeUnit + +data class RepairDecision( + val action: String, // "fix_locally" | "ask_upstream" | "error" + val fixedHtml: String? = null, + val fixSummary: String = "", + val clarificationQuestions: JSONArray = JSONArray(), + val errorMessage: String? = null +) + +/** + * End-Side OpenAI-Compatible Repair Sentinel. + * Fixes HTML/CSS/Vue/JS/viewport compatibility errors locally, or escalates missing/ambiguous + * business data questions back to the upstream AI via Hub. + */ +class OpenAiRepairSentinel { + + suspend fun diagnoseAndRepair( + cfg: RepairAiConfig, + currentHtml: String, + errors: List, + displayProfile: JSONObject, + dataContext: JSONObject, + upstreamAnswers: JSONObject? = null + ): RepairDecision = withContext(Dispatchers.IO) { + if (!cfg.enabled || cfg.apiKey.isBlank() || cfg.baseUrl.isBlank()) { + return@withContext RepairDecision( + action = "error", + errorMessage = "End-side Repair AI is disabled or missing API config from Hub." + ) + } + + val client = OkHttpClient.Builder() + .connectTimeout(cfg.timeoutSec.toLong(), TimeUnit.SECONDS) + .readTimeout(cfg.timeoutSec.toLong(), TimeUnit.SECONDS) + .writeTimeout(cfg.timeoutSec.toLong(), TimeUnit.SECONDS) + .build() + + val systemPrompt = """ +You are the PulseWall On-Device UI Repair Sentinel running on an Android 11 WebView. +Your job: +1. If the error is caused by HTML syntax, Vue/JS code bugs, CSS layout overflow, or Android 11 WebView compatibility: + Return JSON with action="fix_locally", the complete repaired HTML fragment in "fixed_html", and a brief "fix_summary". + IMPORTANT: Never fabricate unknown business/server metric data. Keep responsive styling compatible with viewport_css_w/h and WebView version. + Available built-in CSS classes: .pw-stack, .pw-row, .pw-between, .pw-grid-2, .pw-grid-auto, .pw-card, .pw-hero, .pw-muted, .pw-metric, .pw-pill, .pw-btn, .pw-btn-primary, .pw-btn-danger, .pw-btn-secondary, .pw-code, plus preloaded Tailwind-lite utilities. + Preloaded globals: `Vue` (Vue 3), `dayjs`, `PwIcons`. + Lazy offline local libs via `await window.PulseWall.loadLib(['plyr','hls','echarts','konva','three','rough','lodash','zustand','anime'])` -> globals: `Plyr`, `Hls`, `echarts`, `Konva`, `THREE`, `rough`, `_`, `Zustand`, `anime`. Never depend on blocked external CDNs when a local lib exists. + Bridge: `window.PulseWall.sendAction(id, label, customText)`. +2. If the error or missing rendering is caused by missing/ambiguous business data fields that only the upstream AI knows: + Return JSON with action="ask_upstream" and "clarification_questions": [{"field": "...", "question": "..."}]. + +Respond ONLY with valid JSON matching: +{ + "action": "fix_locally" | "ask_upstream", + "fixed_html": "", + "fix_summary": "short explanation", + "clarification_questions": [{"field": "...", "question": "..."}] +} + """.trimIndent() + + val userPayload = JSONObject().apply { + put("device_display_profile", displayProfile) + put("errors", JSONArray(errors)) + put("data_context", dataContext) + if (upstreamAnswers != null) { + put("upstream_clarification_answers", upstreamAnswers) + } + put("html_code", currentHtml) + } + + val reqBody = JSONObject().apply { + put("model", cfg.model) + put("temperature", 0.1) + put("messages", JSONArray().apply { + put(JSONObject().put("role", "system").put("content", systemPrompt)) + put(JSONObject().put("role", "user").put("content", userPayload.toString())) + }) + } + + val endpoint = cfg.baseUrl.trimEnd('/') + "/chat/completions" + val request = Request.Builder() + .url(endpoint) + .header("Authorization", "Bearer ${cfg.apiKey}") + .header("Content-Type", "application/json") + .post(reqBody.toString().toRequestBody("application/json; charset=utf-8".toMediaType())) + .build() + + try { + client.newCall(request).execute().use { resp -> + val raw = resp.body?.string().orEmpty() + if (!resp.isSuccessful) { + return@withContext RepairDecision( + action = "error", + errorMessage = "OpenAI API HTTP ${resp.code}: ${raw.take(240)}" + ) + } + val root = JSONObject(raw) + val content = root.getJSONArray("choices") + .getJSONObject(0) + .getJSONObject("message") + .getString("content") + .trim() + val jsonStr = extractJsonBlock(content) + val parsed = JSONObject(jsonStr) + val action = parsed.optString("action", "error") + RepairDecision( + action = action, + fixedHtml = if (parsed.isNull("fixed_html")) null else parsed.optString("fixed_html", ""), + fixSummary = parsed.optString("fix_summary", ""), + clarificationQuestions = parsed.optJSONArray("clarification_questions") ?: JSONArray() + ) + } + } catch (t: Throwable) { + RepairDecision(action = "error", errorMessage = t.message ?: t.javaClass.simpleName) + } + } + + private fun extractJsonBlock(text: String): String { + val fenced = Regex("```(?:json)?\\s*([\\s\\S]*?)```").find(text) + if (fenced != null) return fenced.groupValues[1].trim() + val first = text.indexOf('{') + val last = text.lastIndexOf('}') + return if (first >= 0 && last > first) text.substring(first, last + 1) else text + } +} diff --git a/android/app/src/main/java/com/pulsewall/app/service/BootReceiver.kt b/android/app/src/main/java/com/pulsewall/app/service/BootReceiver.kt new file mode 100644 index 0000000..17a86eb --- /dev/null +++ b/android/app/src/main/java/com/pulsewall/app/service/BootReceiver.kt @@ -0,0 +1,23 @@ +package com.pulsewall.app.service + +import android.content.BroadcastReceiver +import android.content.Context +import android.content.Intent +import com.pulsewall.app.MainActivity + +class BootReceiver : BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent?) { + val action = intent?.action ?: return + if (action == Intent.ACTION_BOOT_COMPLETED || action == Intent.ACTION_LOCKED_BOOT_COMPLETED) { + runCatching { + context.startForegroundService(Intent(context, PulseWallKeepAliveService::class.java)) + } + runCatching { + val launch = Intent(context, MainActivity::class.java).apply { + addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + } + context.startActivity(launch) + } + } + } +} diff --git a/android/app/src/main/java/com/pulsewall/app/service/PulseWallKeepAliveService.kt b/android/app/src/main/java/com/pulsewall/app/service/PulseWallKeepAliveService.kt new file mode 100644 index 0000000..f7b013a --- /dev/null +++ b/android/app/src/main/java/com/pulsewall/app/service/PulseWallKeepAliveService.kt @@ -0,0 +1,28 @@ +package com.pulsewall.app.service + +import android.app.Notification +import android.app.NotificationChannel +import android.app.NotificationManager +import android.app.Service +import android.content.Intent +import android.os.IBinder + +class PulseWallKeepAliveService : Service() { + override fun onCreate() { + super.onCreate() + val channelId = "pulsewall_keepalive" + val nm = getSystemService(NotificationManager::class.java) + val ch = NotificationChannel(channelId, "PulseWall 后台保活", NotificationManager.IMPORTANCE_LOW) + nm.createNotificationChannel(ch) + val notif = Notification.Builder(this, channelId) + .setContentTitle("PulseWall 运行中") + .setContentText("已与中心桥保持实时通信") + .setSmallIcon(android.R.drawable.stat_notify_sync) + .build() + startForeground(1001, notif) + } + + override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int = START_STICKY + + override fun onBind(intent: Intent?): IBinder? = null +} diff --git a/android/app/src/main/java/com/pulsewall/app/telemetry/DeviceTelemetryCollector.kt b/android/app/src/main/java/com/pulsewall/app/telemetry/DeviceTelemetryCollector.kt new file mode 100644 index 0000000..6806b23 --- /dev/null +++ b/android/app/src/main/java/com/pulsewall/app/telemetry/DeviceTelemetryCollector.kt @@ -0,0 +1,398 @@ +package com.pulsewall.app.telemetry + +import android.app.Activity +import android.app.ActivityManager +import android.app.UiModeManager +import android.content.Context +import android.content.Intent +import android.content.IntentFilter +import android.content.pm.PackageManager +import android.content.res.Configuration +import android.net.wifi.WifiManager +import android.os.BatteryManager +import android.os.Build +import android.os.Environment +import android.os.PowerManager +import android.os.Process as AndroidProcess +import android.os.StatFs +import android.view.WindowInsets +import androidx.webkit.WebViewCompat +import com.pulsewall.app.BuildConfig +import org.json.JSONArray +import org.json.JSONObject +import java.io.BufferedReader +import java.io.BufferedWriter +import java.io.File +import java.io.InputStreamReader +import java.io.OutputStreamWriter +import java.util.UUID +import kotlin.math.roundToInt + +/** + * Layered Android 11 (API 30) capability & telemetry collector. + * Keeps ONE persistent interactive `su` session so Magisk/SuperSU never spams + * "granted superuser rights" toasts on every 10-second telemetry tick. + */ +class DeviceTelemetryCollector(private val activity: Activity) { + + @Volatile + private var rootChecked = false + + @Volatile + private var hasRoot = false + + private val suLock = Any() + private var suProcess: Process? = null + private var suWriter: BufferedWriter? = null + private var suReader: BufferedReader? = null + private var rootKeepAliveApplied = false + private var prevCpuTotal = -1L + private var prevCpuIdle = -1L + + fun isRootAvailable(): Boolean { + if (!rootChecked) { + synchronized(suLock) { + if (!rootChecked) { + hasRoot = initPersistentSuSession() + rootChecked = true + } + } + } + return hasRoot + } + + fun detectCapabilities(): JSONArray { + val arr = JSONArray() + arr.put("basic") + if (isRootAvailable()) { + arr.put("root") + } + return arr + } + + private fun initPersistentSuSession(): Boolean { + val candidates = listOf( + "/system/bin/su", + "/system/xbin/su", + "/sbin/su", + "/su/bin/su", + "/data/adb/ksu/bin/su", + "/data/adb/magisk/magisk" + ) + if (candidates.none { File(it).exists() }) { + return false + } + return try { + val proc = ProcessBuilder("su").redirectErrorStream(true).start() + val writer = BufferedWriter(OutputStreamWriter(proc.outputStream)) + val reader = BufferedReader(InputStreamReader(proc.inputStream)) + suProcess = proc + suWriter = writer + suReader = reader + val out = execOnPersistentSuLocked("id") + if (out != null && out.contains("uid=0")) { + applyRootKeepAliveLocked() + true + } else { + closeSuLocked() + false + } + } catch (_: Throwable) { + closeSuLocked() + false + } + } + + private fun execOnPersistentSuLocked(cmd: String): String? { + val proc = suProcess ?: return null + val writer = suWriter ?: return null + val reader = suReader ?: return null + if (!proc.isAlive) { + closeSuLocked() + return null + } + return try { + val marker = "__PW_DONE_${UUID.randomUUID().toString().take(8)}__" + writer.write("$cmd\necho $marker\n") + writer.flush() + val sb = StringBuilder() + var lines = 0 + while (lines < 64) { + val line = reader.readLine() ?: break + if (line.trim() == marker) break + if (sb.isNotEmpty()) sb.append('\n') + sb.append(line) + lines++ + } + sb.toString().trim() + } catch (_: Throwable) { + closeSuLocked() + null + } + } + + private fun runRootCommand(cmd: String): String? { + if (!isRootAvailable()) return null + synchronized(suLock) { + return execOnPersistentSuLocked(cmd) + } + } + + private fun applyRootKeepAliveLocked() { + if (rootKeepAliveApplied) return + rootKeepAliveApplied = true + val pkg = BuildConfig.APPLICATION_ID + val pid = AndroidProcess.myPid() + // Whitelist from Doze, allow unrestricted background execution, and raise OOM protection + execOnPersistentSuLocked( + "dumpsys deviceidle whitelist +$pkg >/dev/null 2>&1; " + + "cmd appops set $pkg RUN_IN_BACKGROUND allow >/dev/null 2>&1; " + + "cmd appops set $pkg RUN_ANY_IN_BACKGROUND allow >/dev/null 2>&1; " + + "echo -900 > /proc/$pid/oom_score_adj 2>/dev/null; true" + ) + } + + private fun sampleCpuUsagePct(): Double? { + val line = runCatching { + val f = File("/proc/stat") + if (f.canRead()) f.bufferedReader().use { it.readLine() } else null + }.getOrNull() ?: if (hasRoot) runRootCommand("head -n 1 /proc/stat") else null + + if (line.isNullOrBlank() || !line.startsWith("cpu")) return null + val nums = line.trim().split(Regex("\\s+")).drop(1).mapNotNull { it.toLongOrNull() } + if (nums.size < 4) return null + val idle = nums[3] + (nums.getOrNull(4) ?: 0L) + val total = nums.sum() + + val result = if (prevCpuTotal > 0 && total > prevCpuTotal) { + val diffTotal = total - prevCpuTotal + val diffIdle = (idle - prevCpuIdle).coerceAtLeast(0L) + val pct = ((diffTotal - diffIdle).toDouble() / diffTotal.toDouble()) * 100.0 + (pct.coerceIn(0.0, 100.0) * 10.0).roundToInt() / 10.0 + } else { + null + } + prevCpuTotal = total + prevCpuIdle = idle + return result + } + + private fun sampleGpuUsagePct(): Double? { + val candidates = listOf( + "/sys/class/mpgpu/utilization", + "/sys/class/kgsl/kgsl-3d0/gpu_busy_percentage", + "/sys/class/misc/mali0/device/utilization" + ) + for (path in candidates) { + val raw = runCatching { + val f = File(path) + if (f.canRead()) f.readText().trim() else null + }.getOrNull() ?: if (hasRoot) runRootCommand("cat $path 2>/dev/null") else null + if (!raw.isNullOrBlank()) { + val num = Regex("[0-9]+(?:\\.[0-9]+)?").find(raw)?.value?.toDoubleOrNull() + if (num != null && num in 0.0..100.0) { + return (num * 10.0).roundToInt() / 10.0 + } + } + } + // Adreno gpubusy fallback: " " + val adreno = runCatching { + val f = File("/sys/class/kgsl/kgsl-3d0/gpubusy") + if (f.canRead()) f.readText().trim() else null + }.getOrNull() ?: if (hasRoot) runRootCommand("cat /sys/class/kgsl/kgsl-3d0/gpubusy 2>/dev/null") else null + if (!adreno.isNullOrBlank()) { + val parts = adreno.split(Regex("\\s+")).mapNotNull { it.toDoubleOrNull() } + if (parts.size >= 2 && parts[1] > 0) { + val pct = ((parts[0] / parts[1]) * 100.0).coerceIn(0.0, 100.0) + return (pct * 10.0).roundToInt() / 10.0 + } + } + return null + } + + private fun readStorageMb(): Pair? { + return runCatching { + val stat = StatFs(Environment.getDataDirectory().path) + val totalMb = stat.totalBytes / (1024L * 1024L) + val availMb = stat.availableBytes / (1024L * 1024L) + val usedMb = (totalMb - availMb).coerceAtLeast(0L) + usedMb to totalMb + }.getOrNull() + } + + private fun closeSuLocked() { + runCatching { suWriter?.write("exit\n"); suWriter?.flush() } + runCatching { suWriter?.close() } + runCatching { suReader?.close() } + runCatching { suProcess?.destroy() } + suWriter = null + suReader = null + suProcess = null + } + + fun close() { + synchronized(suLock) { + closeSuLocked() + } + } + + fun collectDisplayProfile(): JSONObject { + val dm = activity.resources.displayMetrics + val cfg = activity.resources.configuration + val wm = activity.windowManager + val bounds = wm.currentWindowMetrics.bounds + val insets = wm.currentWindowMetrics.windowInsets.getInsetsIgnoringVisibility( + WindowInsets.Type.systemBars() + ) + val density = dm.density.coerceAtLeast(1f) + val widthPx = bounds.width() + val heightPx = bounds.height() + val cssW = (widthPx / density).roundToInt() + val cssH = (heightPx / density).roundToInt() + val safeTopDp = (insets.top / density).roundToInt() + val safeBottomDp = (insets.bottom / density).roundToInt() + + val orientation = if (cfg.orientation == Configuration.ORIENTATION_LANDSCAPE) "landscape" else "portrait" + val uiModeMgr = activity.getSystemService(Context.UI_MODE_SERVICE) as? UiModeManager + val isTvMode = uiModeMgr?.currentModeType == Configuration.UI_MODE_TYPE_TELEVISION + val hasTouch = activity.packageManager.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN) + val deviceType = when { + isTvMode || !hasTouch -> "tv" + cfg.smallestScreenWidthDp >= 600 -> "tablet" + else -> "phone" + } + val webViewPkg = WebViewCompat.getCurrentWebViewPackage(activity) + val webViewVer = webViewPkg?.versionName ?: "unknown" + + return JSONObject().apply { + put("device_type", deviceType) + put("input_mode", if (deviceType == "tv") "remote" else "touch") + put("orientation", orientation) + put("width_px", widthPx) + put("height_px", heightPx) + put("viewport_css_w", cssW) + put("viewport_css_h", cssH) + put("dpr", density.toDouble()) + put("safe_area_top_dp", safeTopDp) + put("safe_area_bottom_dp", safeBottomDp) + put("font_scale", cfg.fontScale.toDouble()) + put("webview_version", webViewVer) + } + } + + fun collectHelloPayload(deviceId: String, deviceName: String): JSONObject { + return JSONObject().apply { + put("device_id", deviceId) + put("device_name", deviceName) + put("model", "${Build.MANUFACTURER} ${Build.MODEL}") + put("android_sdk", Build.VERSION.SDK_INT) + put("android_release", Build.VERSION.RELEASE ?: "11") + put("app_version", "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})") + put("capabilities", detectCapabilities()) + put("display_profile", collectDisplayProfile()) + } + } + + private fun readThermalZonesDirect(): JSONObject { + val thermalZones = JSONObject() + val dir = File("/sys/class/thermal") + val zones = dir.listFiles { f -> f.name.startsWith("thermal_zone") } ?: return thermalZones + var count = 0 + for (z in zones) { + if (count >= 8) break + val typeFile = File(z, "type") + val tempFile = File(z, "temp") + if (typeFile.canRead() && tempFile.canRead()) { + val t = runCatching { typeFile.readText().trim() }.getOrNull() + val num = runCatching { tempFile.readText().trim().toDoubleOrNull() }.getOrNull() + if (!t.isNullOrBlank() && num != null) { + val celsius = if (num > 1000.0) num / 1000.0 else if (num > 150.0) num / 10.0 else num + if (celsius in -10.0..130.0) { + thermalZones.put(t, (celsius * 10).roundToInt() / 10.0) + count++ + } + } + } + } + return thermalZones + } + + fun collectTelemetryPayload(): JSONObject { + val ctx = activity.applicationContext + val batIntent = ctx.registerReceiver(null, IntentFilter(Intent.ACTION_BATTERY_CHANGED)) + val level = batIntent?.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) ?: -1 + val scale = batIntent?.getIntExtra(BatteryManager.EXTRA_SCALE, 100) ?: 100 + val batteryPct = if (level >= 0 && scale > 0) (level * 100) / scale else null + val status = batIntent?.getIntExtra(BatteryManager.EXTRA_STATUS, -1) ?: -1 + val isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL + val tempTenth = batIntent?.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, Int.MIN_VALUE) ?: Int.MIN_VALUE + val batteryTempC = if (tempTenth != Int.MIN_VALUE) tempTenth / 10.0 else null + + val bm = ctx.getSystemService(Context.BATTERY_SERVICE) as? BatteryManager + val currentUa = bm?.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_NOW) + var currentMa = if (currentUa != null && currentUa != Int.MIN_VALUE) currentUa / 1000 else null + + val am = ctx.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager + val memInfo = ActivityManager.MemoryInfo() + am.getMemoryInfo(memInfo) + val totalMb = (memInfo.totalMem / (1024 * 1024)).toInt() + val usedMb = ((memInfo.totalMem - memInfo.availMem) / (1024 * 1024)).toInt() + + val pm = ctx.getSystemService(Context.POWER_SERVICE) as PowerManager + val screenOn = pm.isInteractive + + val wifiMgr = ctx.getSystemService(Context.WIFI_SERVICE) as? WifiManager + val rssi = try { + @Suppress("DEPRECATION") + wifiMgr?.connectionInfo?.rssi + } catch (_: Throwable) { + null + } + + // Try direct non-root read first; only use single persistent su session if needed + val thermalZones = readThermalZonesDirect() + if (thermalZones.length() == 0 && hasRoot) { + val thermalRaw = runRootCommand( + "for z in /sys/class/thermal/thermal_zone*; do " + + "t=$(cat \$z/type 2>/dev/null); v=$(cat \$z/temp 2>/dev/null); " + + "if [ -n \"\$t\" ] && [ -n \"\$v\" ]; then echo \"\$t=\$v\"; fi; done | head -n 8" + ) + thermalRaw?.lines()?.forEach { line -> + val idx = line.indexOf('=') + if (idx > 0) { + val key = line.substring(0, idx).trim() + val num = line.substring(idx + 1).trim().toDoubleOrNull() + if (num != null) { + val celsius = if (num > 1000.0) num / 1000.0 else if (num > 150.0) num / 10.0 else num + if (celsius in -10.0..130.0) { + thermalZones.put(key, (celsius * 10).roundToInt() / 10.0) + } + } + } + } + } + + val cpuPct = sampleCpuUsagePct() + val gpuPct = sampleGpuUsagePct() + val storage = readStorageMb() + + return JSONObject().apply { + if (batteryPct != null) put("battery_pct", batteryPct) + put("is_charging", isCharging) + if (batteryTempC != null) put("battery_temp_c", batteryTempC) + if (currentMa != null) put("battery_current_ma", currentMa) + if (cpuPct != null) put("cpu_usage_pct", cpuPct) + if (gpuPct != null) put("gpu_usage_pct", gpuPct) + put("mem_used_mb", usedMb) + put("mem_total_mb", totalMb) + if (storage != null) { + put("storage_used_mb", storage.first) + put("storage_total_mb", storage.second) + } + put("thermal_zones", thermalZones) + if (rssi != null && rssi > -127) put("wifi_rssi_dbm", rssi) + put("screen_on", screenOn) + put("display_profile", collectDisplayProfile()) + } + } +} diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..3a23d04 --- /dev/null +++ b/android/app/src/main/res/values/styles.xml @@ -0,0 +1,10 @@ + + + + diff --git a/android/app/src/main/res/xml/file_paths.xml b/android/app/src/main/res/xml/file_paths.xml new file mode 100644 index 0000000..844e43d --- /dev/null +++ b/android/app/src/main/res/xml/file_paths.xml @@ -0,0 +1,4 @@ + + + + diff --git a/android/build.gradle.kts b/android/build.gradle.kts new file mode 100644 index 0000000..017d909 --- /dev/null +++ b/android/build.gradle.kts @@ -0,0 +1,4 @@ +plugins { + id("com.android.application") version "8.5.2" apply false + id("org.jetbrains.kotlin.android") version "1.9.24" apply false +} diff --git a/android/build_apk.sh b/android/build_apk.sh new file mode 100755 index 0000000..476c9c6 --- /dev/null +++ b/android/build_apk.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +set -euo pipefail +ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)" +export HOME="$ROOT_DIR/.toolchain/home" +export JAVA_HOME="$ROOT_DIR/.toolchain/jdk17" +export ANDROID_HOME="$ROOT_DIR/.toolchain/android-sdk" +export ANDROID_SDK_ROOT="$ANDROID_HOME" +export ANDROID_USER_HOME="$HOME/.android" +export GRADLE_USER_HOME="$ROOT_DIR/.toolchain/gradle-home" +mkdir -p "$ANDROID_USER_HOME" +export PATH="$JAVA_HOME/bin:$ROOT_DIR/.toolchain/gradle/gradle-8.7/bin:$ANDROID_HOME/platform-tools:$PATH" + +VERSION_CODE="${PW_VERSION_CODE:-1}" +VERSION_NAME="${PW_VERSION_NAME:-0.1.0}" +CHANGELOG="${PW_CHANGELOG:-PulseWall 更新包 v${VERSION_NAME} (build ${VERSION_CODE})}" + +cd "$ROOT_DIR/android" +gradle assembleDebug --no-daemon -PpwVersionCode="$VERSION_CODE" -PpwVersionName="$VERSION_NAME" "$@" + +APK_SRC="$ROOT_DIR/android/app/build/outputs/apk/debug/app-debug.apk" +RELEASE_DIR="$ROOT_DIR/hub/releases" +mkdir -p "$RELEASE_DIR" +APK_DST="$RELEASE_DIR/pulsewall-latest.apk" +cp -f "$APK_SRC" "$APK_DST" + +python3 - "$APK_DST" "$RELEASE_DIR/latest.json" "$VERSION_CODE" "$VERSION_NAME" "$CHANGELOG" <<'PY' +import hashlib, json, os, sys, time +apk_path, meta_path, vcode, vname, changelog = sys.argv[1:] +h = hashlib.sha256() +with open(apk_path, "rb") as f: + for chunk in iter(lambda: f.read(65536), b""): + h.update(chunk) +meta = { + "version_code": int(vcode), + "version_name": vname, + "filename": os.path.basename(apk_path), + "size_bytes": os.path.getsize(apk_path), + "sha256": h.hexdigest(), + "changelog": changelog, + "updated_at_ms": int(time.time() * 1000), +} +with open(meta_path, "w", encoding="utf-8") as f: + json.dump(meta, f, ensure_ascii=False, indent=2) +print("Published OTA release:", json.dumps(meta, ensure_ascii=False)) +PY diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 0000000..8af9ad9 --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,4 @@ +org.gradle.jvmargs=-Xmx2560m -Dfile.encoding=UTF-8 +android.useAndroidX=true +android.nonTransitiveRClass=true +kotlin.code.style=official diff --git a/android/keystore/pulsewall-dev.jks b/android/keystore/pulsewall-dev.jks new file mode 100644 index 0000000000000000000000000000000000000000..8c6febf824ca1ac7c19da03a9514e29456bfb94f GIT binary patch literal 2734 zcma)8X*d*&7M>Y{tc4L`n6XZl%vi=Ywn&pKnL)^wHG6gyhLK&eWM4uVyT%eBOJyhP z*oEATeJN5m;kwVgPv5=2?)`C|bIyCt`~ExcbC5*FauARPNn|vpV-SzRM*Uy`(gO>K zjMu!?p#?J|Aq#sK;7{^p%X&l&d;2jv%SVF}{IPoOTEX3(-n9tns@MNkRp+M%f-djftk^G)!hY~A&v=^l%(l7D%}la^(~Xt)rPR{- zi+~x5mpv+a_2oO<@ZcZ}*L?`lJ$q4RZJ=oeoc1ATU4+!9k zmkjtE1M>n#HTs*;<1CJ4wh#{~gn;|VkF;P4K!@YJCehA5MrgwRReY+n+Aue@R&N#J z3H#s%42hqYNQr4urJrQK*?i1zqh=QBOrqi_$4B9o?uPHfe*Kty0B551(e1BftOZe~ z^^9pX`h=6qq!j#%<2fX+Ci-?N1P1ZASw$cyFQR=w3r$na8fw);4=YZsH)yLs%wbQ+ zf0v9Imj5~7AwZ3@%By)t6$8{6#*-%%w{uGZ5;R6HdPcOrexZ0xrf`jUFK%6^gQfNR zQv9p#<&YNjZsjSTCp&~ZgA6HV{LM)M$5%AWue%nb^E|B?>>9+&HtZN*p41m|d@pTw zgS$g{(rTVD4i(`}m0E7SoZ zlMqmAuIpHO$R-Ep!-imkBB6*r83XQunW~c}f^!J7f(G)O(O$v_yXXwRT<#K=*orD%byQETTl37)x$8W<=9q(w9c4J*mNmDBZsNG~VoT^@GKPx!VmN#b&`T9zk_^DB;&|ortC+p2gm0ODI z)%#QQUP?YT37wyW@v^oicg(f-5c13=gwa&9&rL|1k zF{hr65Fb#st!hy0M>a1y>R<`Lk@2~Sm1nG7q`C8#zB?A*3okuyR^cv9-PY|<;dD4h zv>c9!8%vB^{(P$~JVeZ?NrJ(3gMGxh=vj95jiYJZn077bTOya1a~?_LoJT=|4UzSQxpn9l{o1^-@qlZG_tQW zZa<^$Yh9`+9VGmZT{1vW5Po*ReSkl}9pDRa1Ox)^o>lJuxx$HpfZ2^*JRD&t1tobU z1zCA{Ikb`tk_Zm}qeD+uKm_}oL7pHW;4C@+H39xFvyQzImt=~hpQzL18Nm*rVt<(i zHT^$kU5m3V9U~PkpWMqTuRptxFe1&Kg}Tc~#(`S!6fPw#45(LRcIafSP1A!v4z3ys zVT11vSxXcai;%F^o0civ&UFf7rlQ+rYN(Ym+{@#==W?^@a&mBwAMRuOE$Bq{+6++J zvD)KdWrzBL?zOjaT_N6k&Y_uKobv)oTr~wgnt3j9?P6xrY5A&Vw-*wLio<#JQ!C_v z4I4p8WkM*A$(zaQx;eoSaZUidDNpmXfF1AYaiWD(ZS4i8oQ7u|XEPU!FIGZ#pTSdE zVtZ3bYZ~TldNjv8TPIh1S8^^UYf0vQ=n=Tuf6Q6Qi{-prQzOCYV19KQ)hd(VG6W&O z45RbQ8H@P}+i*n>`kLAt?DRJ($)==t%r1>I$&g%WhtEkvANk$wx1&n* zrogGug?7bq{opym(&M_i+-}}YdLd)=uoTfRW@hM&_NN2w*PQ}qU{VnmCH!94Dyik@ zo%h|I6L2eAm_Vgjf@SX*pZ8QBuUUm0@g|5+FT6>AJrTxmB|#gQ_u008UzC{{; zuQr>DGL`H0Yq|85?p;*qtEd8)Wj1vsaEyx(~a>sUXaSI*iy$ zDn;YW-LKKRYK-oJRv#e@?s!&kp@pf5bx?J)+uFWbb9ZgBT?wN#OJR780#-sFl7UYU z)*-WH!0Z(W^TGZwIszqfRNVKvzD?sdPZ3yd|KjqMUX*+*{margin-top:8px}.space-y-3>*+*{margin-top:12px}.space-y-4>*+*{margin-top:16px} +.p-1{padding:4px}.p-2{padding:8px}.p-3{padding:12px}.p-4{padding:16px}.p-5{padding:20px}.p-6{padding:24px} +.px-2{padding-left:8px;padding-right:8px}.px-3{padding-left:12px;padding-right:12px}.px-4{padding-left:16px;padding-right:16px}.px-5{padding-left:20px;padding-right:20px} +.py-1{padding-top:4px;padding-bottom:4px}.py-2{padding-top:8px;padding-bottom:8px}.py-3{padding-top:12px;padding-bottom:12px}.py-4{padding-top:16px;padding-bottom:16px} +.m-0{margin:0}.mt-1{margin-top:4px}.mt-2{margin-top:8px}.mt-3{margin-top:12px}.mt-4{margin-top:16px}.mb-2{margin-bottom:8px}.mb-3{margin-bottom:12px}.mb-4{margin-bottom:16px}.mx-auto{margin-left:auto;margin-right:auto} +.w-full{width:100%}.h-full{height:100%}.min-h-screen{min-height:100vh}.max-w-full{max-width:100%}.aspect-video{aspect-ratio:16/9} +.relative{position:relative}.absolute{position:absolute}.inset-0{top:0;right:0;bottom:0;left:0}.overflow-hidden{overflow:hidden}.overflow-auto{overflow:auto} +.rounded{border-radius:6px}.rounded-lg{border-radius:10px}.rounded-xl{border-radius:14px}.rounded-2xl{border-radius:18px}.rounded-full{border-radius:9999px} +.border{border:1px solid rgba(148,163,184,0.22)}.border-slate-700{border-color:#334155}.border-slate-800{border-color:#1e293b}.border-cyan-500{border-color:#06b6d4}.border-teal-400{border-color:#2dd4bf}.border-amber-500{border-color:#f59e0b}.border-red-500{border-color:#ef4444} +.text-xs{font-size:12px;line-height:16px}.text-sm{font-size:14px;line-height:20px}.text-base{font-size:16px;line-height:24px}.text-lg{font-size:18px;line-height:26px}.text-xl{font-size:20px;line-height:28px}.text-2xl{font-size:24px;line-height:32px}.text-3xl{font-size:30px;line-height:36px}.text-4xl{font-size:36px;line-height:40px} +.font-medium{font-weight:500}.font-semibold{font-weight:600}.font-bold{font-weight:700}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace} +.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +.text-white{color:#fff}.text-slate-200{color:#e2e8f0}.text-slate-300{color:#cbd5e1}.text-slate-400{color:#94a3b8}.text-slate-500{color:#64748b} +.text-teal-400{color:#2dd4bf}.text-cyan-400{color:#22d3ee}.text-sky-400{color:#38bdf8}.text-emerald-400{color:#34d399}.text-amber-400{color:#fbbf24}.text-red-400{color:#f87171}.text-rose-400{color:#fb7185} +.bg-slate-950{background-color:#020617}.bg-slate-900{background-color:#0f172a}.bg-slate-800{background-color:#1e293b}.bg-slate-700{background-color:#334155} +.bg-teal-500{background-color:#14b8a6}.bg-cyan-500{background-color:#06b6d4}.bg-sky-500{background-color:#0ea5e9}.bg-emerald-500{background-color:#10b981}.bg-amber-500{background-color:#f59e0b}.bg-red-600{background-color:#dc2626} +.bg-slate-900\\/80{background-color:rgba(15,23,42,0.8)}.bg-slate-800\\/80{background-color:rgba(30,41,59,0.8)} +.shadow-lg{box-shadow:0 10px 24px rgba(0,0,0,0.35)}.opacity-60{opacity:0.6}.opacity-80{opacity:0.8} +.cursor-pointer{cursor:pointer}.transition{transition:all 0.15s ease} +@keyframes pw-pulse{0%,100%{opacity:1}50%{opacity:.45}}.animate-pulse{animation:pw-pulse 1.8s cubic-bezier(.4,0,.6,1) infinite} +@keyframes pw-spin{to{transform:rotate(360deg)}}.animate-spin{animation:pw-spin 1s linear infinite} +@media(min-width:640px){.sm\\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}} +@media(min-width:900px){.md\\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}} +`.trim() + fs.writeFileSync(path.join(outDir, 'tailwind-lite.min.css'), css, 'utf8') + return reportSize('tailwind-lite.min.css') +} + +function generateUltraLightIcons() { + // <2KB gzip pure SVG/CSS icon runtime (EagleICON / OpenTiny-style ultra-light offline icons) + const js = `(function(g){ +var P={ +cpu:"M9 2v2M15 2v2M9 20v2M15 20v2M2 9h2M2 15h2M20 9h2M20 15h2M6 6h12v12H6zM9 9h6v6H9z", +thermometer:"M14 14.76V3.5a2.5 2.5 0 0 0-5 0v11.26a4.5 4.5 0 1 0 5 0z", +battery:"M2 7h16v10H2zM22 11v2", +wifi:"M5 12.55a11 11 0 0 1 14.08 0M1.42 9a16 16 0 0 1 21.16 0M8.53 16.11a6 6 0 0 1 6.95 0M12 20h.01", +bell:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9M13.73 21a2 2 0 0 1-3.46 0", +alert:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0zM12 9v4M12 17h.01", +check:"M20 6L9 17l-5-5", +x:"M18 6L6 18M6 6l12 12", +play:"M5 3l14 9-14 9V3z", +pause:"M6 4h4v16H6zM14 4h4v16h-4z", +tv:"M2 7h20v13H2zM17 2l-5 5-5-5", +server:"M2 2h20v8H2zM2 14h20v8H2zM6 6h.01M6 18h.01", +activity:"M22 12h-4l-3 9L9 3l-3 9H2", +clock:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20zM12 6v6l4 2", +settings:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4", +refresh:"M23 4v6h-6M1 20v-6h6M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15", +home:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z", +sun:"M12 17a5 5 0 1 0 0-10 5 5 0 0 0 0 10zM12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42", +cloud:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z", +database:"M12 2C6.5 2 2 3.8 2 6v12c0 2.2 4.5 4 10 4s10-1.8 10-4V6c0-2.2-4.5-4-10-4zM2 12c0 2.2 4.5 4 10 4s10-1.8 10-4", +terminal:"M4 17l6-6-6-6M12 19h8", +volume:"M11 5L6 9H2v6h4l5 4V5zM19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07", +zap:"M13 2L3 14h9l-1 8 10-12h-9l1-8z", +shield:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z", +chart:"M18 20V10M12 20V4M6 20v-6" +}; +function svg(n,s,c){var d=P[n]||P.activity;s=s||20;return '';} +function hydrate(root){(root||document).querySelectorAll("[data-pw-icon]").forEach(function(el){el.innerHTML=svg(el.getAttribute("data-pw-icon"),el.getAttribute("data-size")||20,el.getAttribute("data-color"));});} +g.PwIcons={names:Object.keys(P),svg:svg,hydrate:hydrate}; +})(window);` + fs.writeFileSync(path.join(outDir, 'pw-icons.min.js'), js, 'utf8') + return reportSize('pw-icons.min.js') +} + +async function main() { + const manifest = {} + + // 1. Plyr (Player UI, zero-dep) + manifest.plyr = { + global: 'Plyr', + category: 'media-player', + js: copyDist('plyr/dist/plyr.min.js', 'plyr.min.js'), + css: copyDist('plyr/dist/plyr.css', 'plyr.css'), + note: '首选轻量无依赖播放器 UI,配合 hls 播放 m3u8 直播/点播' + } + + // 2. hls.js light build + manifest.hls = { + global: 'Hls', + category: 'streaming', + js: copyDist('hls.js/dist/hls.light.min.js', 'hls.light.min.js'), + note: 'HLS (m3u8) 离线精简版流媒体引擎' + } + + // 3. ECharts (Tree-Shaken Dashboard Build!) + manifest.echarts = { + global: 'echarts', + category: 'charts', + heavy: true, + js: await bundleEntry( + ` + import * as echarts from 'echarts/core'; + import { LineChart, BarChart, PieChart, GaugeChart, RadarChart, ScatterChart } from 'echarts/charts'; + import { + TitleComponent, TooltipComponent, GridComponent, LegendComponent, + DatasetComponent, TransformComponent, DataZoomComponent, MarkLineComponent, MarkPointComponent + } from 'echarts/components'; + import { CanvasRenderer } from 'echarts/renderers'; + echarts.use([ + LineChart, BarChart, PieChart, GaugeChart, RadarChart, ScatterChart, + TitleComponent, TooltipComponent, GridComponent, LegendComponent, + DatasetComponent, TransformComponent, DataZoomComponent, MarkLineComponent, MarkPointComponent, + CanvasRenderer + ]); + export const init = echarts.init; + export const use = echarts.use; + export const graphic = echarts.graphic; + export const registerTheme = echarts.registerTheme; + export const getInstanceByDom = echarts.getInstanceByDom; + export const dispose = echarts.dispose; + export default echarts; + `, + 'echarts.custom.min.js', + 'echarts' + ), + note: '按需裁剪版 ECharts(含折线/柱状/饼图/仪表盘/雷达/散点 + CanvasRenderer),仅在需要复杂图表时按需加载' + } + + // 4. Konva.js (2D Interactive Canvas) + manifest.konva = { + global: 'Konva', + category: 'canvas-2d', + js: copyDist('konva/konva.min.js', 'konva.min.js'), + note: '2D 交互画布引擎,适合矢量对象编排与实时动效看板' + } + + // 5. Three.js (3D WebGL - heavy, use sparingly on low-end GPU) + manifest.three = { + global: 'THREE', + category: 'canvas-3d', + heavy: true, + js: await bundleEntry( + `export * from 'three';`, + 'three.min.js', + 'THREE' + ), + note: 'Three.js 3D 渲染库,体积较大,机顶盒/低端 GPU 慎用,仅明确需要 3D 时加载' + } + + // 6. Rough.js (Hand-drawn sketch style, <9KB) + manifest.rough = { + global: 'rough', + category: 'sketch', + js: await bundleEntry( + `import rough from 'roughjs/bundled/rough.esm.js'; export default rough; export const canvas = rough.canvas; export const svg = rough.svg; export const generator = rough.generator;`, + 'rough.min.js', + 'rough' + ), + note: '手绘风格 Canvas/SVG 绘制库(超轻量 <9KB)' + } + + // 7. Tailwind CSS prebuilt utility subset + manifest.tailwind = { + category: 'css', + css: generateTailwindLiteCss(), + note: '离线预编译 Tailwind 实用工具类 CSS(零 JS 运行时开销,Android 11 WebView 兼容)' + } + + // 8. Day.js (~2KB) + manifest.dayjs = { + global: 'dayjs', + category: 'datetime', + js: copyDist('dayjs/dayjs.min.js', 'dayjs.min.js'), + note: '超轻量日期时间格式化与计算库(~2KB)' + } + + // 9. lodash-es tree-shaken subset (~3-5KB) + manifest.lodash = { + global: '_', + category: 'utils', + js: await bundleEntry( + ` + export { + debounce, throttle, cloneDeep, merge, groupBy, sortBy, orderBy, + uniq, uniqBy, chunk, clamp, pick, omit, get, set, sumBy, meanBy, keyBy, round, range + } from 'lodash-es'; + `, + 'lodash-lite.min.js', + '_' + ), + note: '按需 Tree-Shaking 的 lodash-es 常用工具函数集(window._)' + } + + // 10. Zustand vanilla (~1KB) + manifest.zustand = { + global: 'Zustand', + category: 'state', + js: await bundleEntry( + `export { createStore } from 'zustand/vanilla';`, + 'zustand.min.js', + 'Zustand' + ), + note: '极简跨组件状态共享库(window.Zustand.createStore,~1KB)' + } + + // 11. Anime.js (~6KB) + manifest.anime = { + global: 'anime', + category: 'animation', + js: copyDist('animejs/lib/anime.min.js', 'anime.min.js'), + note: '轻量动效库(仅在 CSS 动画不够用时按需引入)' + } + + // 12. Ultra-light inline SVG icons (<2KB) + manifest.icons = { + global: 'PwIcons', + category: 'icons', + js: generateUltraLightIcons(), + note: '超轻量离线 SVG 图标运行时(<2KB,支持 PwIcons.svg("cpu", 20) 或 data-pw-icon 属性)' + } + + fs.writeFileSync(path.join(outDir, 'manifest.json'), JSON.stringify(manifest, null, 2), 'utf8') + console.log('\n=== Bundled Offline Android Assets Summary ===') + for (const [k, v] of Object.entries(manifest)) { + const jsInfo = v.js ? `JS ${v.js.raw_kb}KB (gz ${v.js.gzip_kb}KB)` : '' + const cssInfo = v.css ? `CSS ${v.css.raw_kb}KB (gz ${v.css.gzip_kb}KB)` : '' + console.log(`- ${k.padEnd(10)} [global: ${(v.global || '-').padEnd(8)}] ${[jsInfo, cssInfo].filter(Boolean).join(' + ')}`) + } +} + +main().catch((err) => { + console.error(err) + process.exit(1) +}) diff --git a/android/vendor-builder/package-lock.json b/android/vendor-builder/package-lock.json new file mode 100644 index 0000000..589913e --- /dev/null +++ b/android/vendor-builder/package-lock.json @@ -0,0 +1,620 @@ +{ + "name": "pulsewall-vendor-builder", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "pulsewall-vendor-builder", + "version": "1.0.0", + "dependencies": { + "animejs": "^3.2.2", + "dayjs": "^1.11.13", + "echarts": "^5.6.0", + "esbuild": "^0.25.0", + "hls.js": "^1.5.20", + "konva": "^9.3.18", + "lodash-es": "^4.17.21", + "plyr": "^3.7.8", + "roughjs": "^4.6.6", + "three": "^0.170.0", + "zustand": "^5.0.3" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz", + "integrity": "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.12.tgz", + "integrity": "sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.12.tgz", + "integrity": "sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.12.tgz", + "integrity": "sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.12.tgz", + "integrity": "sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.12.tgz", + "integrity": "sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.12.tgz", + "integrity": "sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.12.tgz", + "integrity": "sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.12.tgz", + "integrity": "sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.12.tgz", + "integrity": "sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.12.tgz", + "integrity": "sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.12.tgz", + "integrity": "sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==", + "cpu": [ + "loong64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.12.tgz", + "integrity": "sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==", + "cpu": [ + "mips64el" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.12.tgz", + "integrity": "sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.12.tgz", + "integrity": "sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==", + "cpu": [ + "riscv64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.12.tgz", + "integrity": "sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.12.tgz", + "integrity": "sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.12.tgz", + "integrity": "sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.12.tgz", + "integrity": "sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.12.tgz", + "integrity": "sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.12.tgz", + "integrity": "sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.12.tgz", + "integrity": "sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.12.tgz", + "integrity": "sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.12.tgz", + "integrity": "sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.12.tgz", + "integrity": "sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.12.tgz", + "integrity": "sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/animejs": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/animejs/-/animejs-3.2.2.tgz", + "integrity": "sha512-Ao95qWLpDPXXM+WrmwcKbl6uNlC5tjnowlaRYtuVDHHoygjtIPfDUoK9NthrlZsQSKjZXlmji2TrBUAVbiH0LQ==" + }, + "node_modules/custom-event-polyfill": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/custom-event-polyfill/-/custom-event-polyfill-1.0.7.tgz", + "integrity": "sha512-TDDkd5DkaZxZFM8p+1I3yAlvM3rSr1wbrOliG4yJiwinMZN8z/iGL7BTlDkrJcYTmgUSb4ywVCc3ZaUtOtC76w==" + }, + "node_modules/dayjs": { + "version": "1.11.23", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.23.tgz", + "integrity": "sha512-QDTCU0M0MxR3hQfnlDJfwekQiaanm1ubOD231u73WBckQ/fsamwRLiE2GBz6D3a/xF1NgfiDLJjXBa1hYOYTtQ==" + }, + "node_modules/echarts": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/echarts/-/echarts-5.6.0.tgz", + "integrity": "sha512-oTbVTsXfKuEhxftHqL5xprgLoc0k7uScAwtryCgWF6hPYFLRwOUHiFmHGCBKP5NPFNkDVopOieyUqYGH8Fa3kA==", + "dependencies": { + "tslib": "2.3.0", + "zrender": "5.6.1" + } + }, + "node_modules/esbuild": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.12.tgz", + "integrity": "sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==", + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.12", + "@esbuild/android-arm": "0.25.12", + "@esbuild/android-arm64": "0.25.12", + "@esbuild/android-x64": "0.25.12", + "@esbuild/darwin-arm64": "0.25.12", + "@esbuild/darwin-x64": "0.25.12", + "@esbuild/freebsd-arm64": "0.25.12", + "@esbuild/freebsd-x64": "0.25.12", + "@esbuild/linux-arm": "0.25.12", + "@esbuild/linux-arm64": "0.25.12", + "@esbuild/linux-ia32": "0.25.12", + "@esbuild/linux-loong64": "0.25.12", + "@esbuild/linux-mips64el": "0.25.12", + "@esbuild/linux-ppc64": "0.25.12", + "@esbuild/linux-riscv64": "0.25.12", + "@esbuild/linux-s390x": "0.25.12", + "@esbuild/linux-x64": "0.25.12", + "@esbuild/netbsd-arm64": "0.25.12", + "@esbuild/netbsd-x64": "0.25.12", + "@esbuild/openbsd-arm64": "0.25.12", + "@esbuild/openbsd-x64": "0.25.12", + "@esbuild/openharmony-arm64": "0.25.12", + "@esbuild/sunos-x64": "0.25.12", + "@esbuild/win32-arm64": "0.25.12", + "@esbuild/win32-ia32": "0.25.12", + "@esbuild/win32-x64": "0.25.12" + } + }, + "node_modules/hachure-fill": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/hachure-fill/-/hachure-fill-0.5.2.tgz", + "integrity": "sha512-3GKBOn+m2LX9iq+JC1064cSFprJY4jL1jCXTcpnfER5HYE2l/4EfWSGzkPa/ZDBmYI0ZOEj5VHV/eKnPGkHuOg==" + }, + "node_modules/hls.js": { + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.7.4.tgz", + "integrity": "sha512-3GlxGdPvT2YHvQYOt+yOzT/DEior/qJVNIylHA77kgeoBTdQQqi70GwefNEUmHQeNGyjC8U62+bruqW/Tpm+tg==" + }, + "node_modules/konva": { + "version": "9.3.22", + "resolved": "https://registry.npmjs.org/konva/-/konva-9.3.22.tgz", + "integrity": "sha512-yQI5d1bmELlD/fowuyfOp9ff+oamg26WOCkyqUyc+nczD/lhRa3EvD2MZOoc4c1293TAubW9n34fSQLgSeEgSw==", + "funding": [ + { + "type": "patreon", + "url": "https://www.patreon.com/lavrton" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/konva" + }, + { + "type": "github", + "url": "https://github.com/sponsors/lavrton" + } + ] + }, + "node_modules/loadjs": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/loadjs/-/loadjs-4.3.0.tgz", + "integrity": "sha512-vNX4ZZLJBeDEOBvdr2v/F+0aN5oMuPu7JTqrMwp+DtgK+AryOlpy6Xtm2/HpNr+azEa828oQjOtWsB6iDtSfSQ==" + }, + "node_modules/lodash-es": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.18.1.tgz", + "integrity": "sha512-J8xewKD/Gk22OZbhpOVSwcs60zhd95ESDwezOFuA3/099925PdHJ7OFHNTGtajL3AlZkykD32HykiMo+BIBI8A==" + }, + "node_modules/path-data-parser": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/path-data-parser/-/path-data-parser-0.1.0.tgz", + "integrity": "sha512-NOnmBpt5Y2RWbuv0LMzsayp3lVylAHLPUTut412ZA3l+C4uw4ZVkQbjShYCQ8TCpUMdPapr4YjUqLYD6v68j+w==" + }, + "node_modules/plyr": { + "version": "3.8.5", + "resolved": "https://registry.npmjs.org/plyr/-/plyr-3.8.5.tgz", + "integrity": "sha512-SqGU1s76fq4lI8ABYhi1uxwrcLGYqmyiMazFAUIOQKKwt6S7FfflEMljLaM3SV8HUUb1KdZ04FY/SNFRpPZHUw==", + "deprecated": "Plyr is deprecated and receives security updates only. Use Video.js 10 for new projects. Migration guide: https://videojs.org/docs/framework/html/guides/migrate-from-plyr", + "hasInstallScript": true, + "dependencies": { + "custom-event-polyfill": "^1.0.7", + "loadjs": "^4.3.0", + "rangetouch": "^2.0.1", + "url-polyfill": "^1.1.14" + }, + "engines": { + "node": "^22.18.0 || >=24.11.0" + } + }, + "node_modules/points-on-curve": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/points-on-curve/-/points-on-curve-0.2.0.tgz", + "integrity": "sha512-0mYKnYYe9ZcqMCWhUjItv/oHjvgEsfKvnUTg8sAtnHr3GVy7rGkXCb6d5cSyqrWqL4k81b9CPg3urd+T7aop3A==" + }, + "node_modules/points-on-path": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/points-on-path/-/points-on-path-0.2.1.tgz", + "integrity": "sha512-25ClnWWuw7JbWZcgqY/gJ4FQWadKxGWk+3kR/7kD0tCaDtPPMj7oHu2ToLaVhfpnHrZzYby2w6tUA0eOIuUg8g==", + "dependencies": { + "path-data-parser": "0.1.0", + "points-on-curve": "0.2.0" + } + }, + "node_modules/rangetouch": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/rangetouch/-/rangetouch-2.0.1.tgz", + "integrity": "sha512-sln+pNSc8NGaHoLzwNBssFSf/rSYkqeBXzX1AtJlkJiUaVSJSbRAWJk+4omsXkN+EJalzkZhWQ3th1m0FpR5xA==" + }, + "node_modules/roughjs": { + "version": "4.6.6", + "resolved": "https://registry.npmjs.org/roughjs/-/roughjs-4.6.6.tgz", + "integrity": "sha512-ZUz/69+SYpFN/g/lUlo2FXcIjRkSu3nDarreVdGGndHEBJ6cXPdKguS8JGxwj5HA5xIbVKSmLgr5b3AWxtRfvQ==", + "dependencies": { + "hachure-fill": "^0.5.2", + "path-data-parser": "^0.1.0", + "points-on-curve": "^0.2.0", + "points-on-path": "^0.2.1" + } + }, + "node_modules/three": { + "version": "0.170.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.170.0.tgz", + "integrity": "sha512-FQK+LEpYc0fBD+J8g6oSEyyNzjp+Q7Ks1C568WWaoMRLW+TkNNWmenWeGgJjV105Gd+p/2ql1ZcjYvNiPZBhuQ==" + }, + "node_modules/tslib": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", + "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==" + }, + "node_modules/url-polyfill": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/url-polyfill/-/url-polyfill-1.1.14.tgz", + "integrity": "sha512-p4f3TTAG6ADVF3mwbXw7hGw+QJyw5CnNGvYh5fCuQQZIiuKUswqcznyV3pGDP9j0TSmC4UvRKm8kl1QsX1diiQ==" + }, + "node_modules/zrender": { + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/zrender/-/zrender-5.6.1.tgz", + "integrity": "sha512-OFXkDJKcrlx5su2XbzJvj/34Q3m6PvyCZkVPHGYpcCJ52ek4U/ymZyfuV1nKE23AyBJ51E/6Yr0mhZ7xGTO4ag==", + "dependencies": { + "tslib": "2.3.0" + } + }, + "node_modules/zustand": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/zustand/-/zustand-5.1.0.tgz", + "integrity": "sha512-ciJZlP48M1PTQbVQq81CGVFxHTLpZNrFjKqwjtCU34AWuXTZT/jrF3p9+fI84Cf1eSCMLapxqBy/SNTfwOBuqA==", + "engines": { + "node": ">=12.20.0" + }, + "peerDependencies": { + "@types/react": ">=18.0.0", + "immer": ">=9.0.6", + "react": ">=18.0.0", + "use-sync-external-store": ">=1.2.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "immer": { + "optional": true + }, + "react": { + "optional": true + }, + "use-sync-external-store": { + "optional": true + } + } + } + } +} diff --git a/android/vendor-builder/package.json b/android/vendor-builder/package.json new file mode 100644 index 0000000..acf0937 --- /dev/null +++ b/android/vendor-builder/package.json @@ -0,0 +1,19 @@ +{ + "name": "pulsewall-vendor-builder", + "version": "1.0.0", + "private": true, + "type": "module", + "dependencies": { + "animejs": "^3.2.2", + "dayjs": "^1.11.13", + "echarts": "^5.6.0", + "esbuild": "^0.25.0", + "hls.js": "^1.5.20", + "konva": "^9.3.18", + "lodash-es": "^4.17.21", + "plyr": "^3.7.8", + "roughjs": "^4.6.6", + "three": "^0.170.0", + "zustand": "^5.0.3" + } +} diff --git a/hub/app/__init__.py b/hub/app/__init__.py new file mode 100644 index 0000000..e96b7b0 --- /dev/null +++ b/hub/app/__init__.py @@ -0,0 +1 @@ +"""PulseWall Hub package.""" diff --git a/hub/app/adb_lan/controller.py b/hub/app/adb_lan/controller.py new file mode 100644 index 0000000..7c4f887 --- /dev/null +++ b/hub/app/adb_lan/controller.py @@ -0,0 +1,1057 @@ +from __future__ import annotations + +import asyncio +import base64 +import io +import ipaddress +import os +import re +import shutil +import time +from collections.abc import AsyncIterator +from fractions import Fraction +from pathlib import Path +from typing import Any + +from fastapi import HTTPException, Request, WebSocket + +from app.adb_lan.fmp4_muxer import AnnexBAccessUnitFramer, ZeroLatencyFmp4Muxer +from app.storage.db import PulseWallDB + +_SAFE_PACKAGE_RE = re.compile(r"^[A-Za-z0-9_.-]+(/[A-Za-z0-9_.$]+)?$") +_REPO_ROOT = Path(__file__).resolve().parents[3] + + +def is_private_ip(host: str | None) -> bool: + if not host: + return False + cleaned = host.strip() + if cleaned in ("localhost", "testclient"): + return True + if cleaned.startswith("::ffff:"): + cleaned = cleaned[len("::ffff:") :] + try: + ip = ipaddress.ip_address(cleaned) + return ip.is_loopback or ip.is_private or ip.is_link_local + except ValueError: + return False + + +def assert_lan_only_request(request: Request) -> None: + """Hard security guard: LAN Developer Debug API MUST reject any non-LAN client or public proxy hop.""" + client_host = request.client.host if request.client else None + if not is_private_ip(client_host): + raise HTTPException( + status_code=403, + detail=f"LAN Developer Debug API is strictly restricted to private LAN clients (got {client_host}).", + ) + + for hdr in ("x-forwarded-for", "x-real-ip", "cf-connecting-ip"): + val = request.headers.get(hdr) + if val: + parts = [p.strip() for p in val.split(",") if p.strip()] + if any(not is_private_ip(p) for p in parts): + raise HTTPException( + status_code=403, + detail=f"LAN Developer Debug API rejected public forwarded header '{hdr}'.", + ) + + +def _norm_model(s: str) -> str: + return re.sub(r"[^a-z0-9]+", "", (s or "").lower()) + + +def _extract_h264_codec_str(data: bytes) -> str | None: + idx = 0 + n = len(data) + while idx < n - 4: + pos = data.find(b"\x00\x00\x01", idx) + if pos < 0: + return None + nal_start = pos + 3 + if nal_start + 3 < n and (data[nal_start] & 0x1F) == 7: + return f"avc1.{data[nal_start + 1]:02x}{data[nal_start + 2]:02x}{data[nal_start + 3]:02x}" + idx = nal_start + return None + + +def _packet_has_idr(data: bytes) -> bool: + idx = 0 + n = len(data) + while idx < n - 4: + pos = data.find(b"\x00\x00\x01", idx) + if pos < 0: + return False + nal_start = pos + 3 + if nal_start < n and (data[nal_start] & 0x1F) == 5: + return True + idx = nal_start + return False + + +class _ChunkSink(io.RawIOBase): + def __init__(self) -> None: + self._chunks: list[bytes] = [] + + def writable(self) -> bool: + return True + + def write(self, b: Any) -> int: + raw = bytes(b) + self._chunks.append(raw) + return len(raw) + + def drain(self) -> bytes: + if not self._chunks: + return b"" + out = b"".join(self._chunks) + self._chunks.clear() + return out + + +class _Fmp4StreamBroadcaster: + """Zero-transcode, ZERO-BUFFERING H.264 broadcaster (1 hardware encoder per device). + + Simultaneously fans out: + - Raw Annex-B H.264 Access Units (`format=h264`) for direct browser WebCodecs GPU decoding + - Zero-buffering fMP4 fragments (`format=fmp4`) for HTML5