From ab13e793b68fa06decc95b70a958c5d57846ba6f Mon Sep 17 00:00:00 2001 From: iOS Date: Sun, 10 Mar 2024 07:31:58 +0100 Subject: [PATCH] first March push --- .obsidian/plugins/cron/data.json | 2 +- .obsidian/plugins/media-extended/main.js | 48 +- .../plugins/media-extended/manifest.json | 4 +- .../obsidian-activity-history/data.json | 34 +- .../obsidian-book-search-plugin/main.js | 2 +- .../obsidian-book-search-plugin/manifest.json | 2 +- .obsidian/plugins/obsidian-commits/data.json | 276 +- .obsidian/plugins/obsidian-map-view/main.js | 70414 ++++++++++------ .../plugins/obsidian-map-view/manifest.json | 4 +- .../plugins/obsidian-map-view/styles.css | 89 + .../obsidian-reminder-plugin/data.json | 131 +- .../plugins/obsidian-tasks-plugin/main.js | 189 +- .../obsidian-tasks-plugin/manifest.json | 2 +- .../plugins/obsidian-tasks-plugin/styles.css | 106 +- .obsidian/plugins/quickadd/data.json | 45 +- .obsidian/plugins/quickadd/main.js | 553 +- .obsidian/plugins/quickadd/manifest.json | 2 +- .obsidian/plugins/templater-obsidian/main.js | 17 +- .../plugins/templater-obsidian/manifest.json | 2 +- .obsidian/workspace-mobile.json | 62 +- 00.01 Admin/Calendars/2024-03-03.md | 8 +- 00.01 Admin/Calendars/2024-03-04.md | 134 + 00.01 Admin/Calendars/2024-03-05.md | 139 + 00.01 Admin/Calendars/2024-03-06.md | 136 + 00.01 Admin/Calendars/2024-03-07.md | 136 + 00.01 Admin/Calendars/2024-03-08.md | 139 + 00.01 Admin/Calendars/2024-03-09.md | 136 + 00.01 Admin/Calendars/2024-03-10.md | 134 + .../2022-03-19 🏠 Arrivée Meggi-mo.md | 12 + .../2022-03-24 🎡 Départ de Meggi-mo.md | 11 + .../2022-03-31 🏠 Arrivée de Papa.md | 9 + .../Events/2022-04-04 🗼 Départ Papa.md | 9 + ...-04-10 🗳️ 1er tour Présidentielle.md | 11 + ... 2nd tour élections présidentielles.md | 8 + .../2022-04-27 📍 Arrivée à Lisbonne.md | 9 + .../2022-05-01 🏠 Départ de Lisbonne.md | 9 + ... Definite arrival of Meggi-mo to Züzü.md | 9 + .../Events/2022-10-14 📍 Weekend à GVA.md | 17 + .../2022-10-21 🗼 Weekend à Paris.md | 16 + ...9 💍 Fiançailles Marguerite & Arnold.md | 10 + .../Events/2022-12-26 🏠 Papa à Zürich.md | 12 + .../2022-12-30 🏠 Stef & Kyna in Zürich.md | 12 + .../Events/2023-01-23 🩺 Médecin.md | 13 + .../Events/2023-02-06 📍 Genève.md | 12 + .../Events/2023-02-09 🩺 Médecin.md | 13 + .../2023-02-11 💍 Mariage Eloi & Zélie.md | 91 + .../2023-02-19 🎞️ Tár @ Riff Raff.md | 13 + .../Events/2023-03-06 🩺 Médecin.md | 12 + ...023-03-11 🏠 Marg & Arnold à Zürich.md | 13 + ...8 🇨🇭 Molly & boyfriend in Zürich.md | 12 + .../Events/2023-04-14 🩺 Médecin.md | 13 + .../Events/2023-12-21 🏠 Arrivée Papa.md | 10 + .../Events/2023-12-27 🗼 Départ Papa.md | 10 + ...-03-05 ⚽️ Real Sociedad - PSG (1-2).md | 18 + .../2024-03-05 ⚽️ Real Sociedad - PSG.md | 11 - 00.02 Inbox/La Louisiane.md | 2 +- ...ed or Expelled, As Told by a Spycatcher.md | 159 + ...hree decades on, I discovered the truth.md | 198 + .../The (Many) Vintages of the Century.md | 100 + ...isters cashed in on a life of deception.md | 194 + ...icon Valley Problem, by Andrew Cockburn.md | 104 + .../Bookmarks - Mac applications.md | 3 +- 01.01 Life Orga/@Finances.md | 3 +- 01.02 Home/@Shopping list.md | 8 +- 01.02 Home/Household.md | 6 +- 01.07 Animals/@Sally.md | 3 +- 02.02 Paris/@@Paris.md | 3 +- .../Invisible Man.md | 4 +- {00.02 Inbox => 03.01 Reading list}/Yoga.md | 4 +- 05.02 Networks/Configuring UFW.md | 6 +- 05.02 Networks/Server Alias.md | 3 +- 05.02 Networks/Server Cloud.md | 3 +- 06.01 Finances/2024.ledger | 112 + 06.02 Investments/Crypto Tasks.md | 3 +- 74 files changed, 48661 insertions(+), 25598 deletions(-) create mode 100644 00.01 Admin/Calendars/2024-03-04.md create mode 100644 00.01 Admin/Calendars/2024-03-05.md create mode 100644 00.01 Admin/Calendars/2024-03-06.md create mode 100644 00.01 Admin/Calendars/2024-03-07.md create mode 100644 00.01 Admin/Calendars/2024-03-08.md create mode 100644 00.01 Admin/Calendars/2024-03-09.md create mode 100644 00.01 Admin/Calendars/2024-03-10.md create mode 100644 00.01 Admin/Calendars/Events/2022-03-19 🏠 Arrivée Meggi-mo.md create mode 100644 00.01 Admin/Calendars/Events/2022-03-24 🎡 Départ de Meggi-mo.md create mode 100644 00.01 Admin/Calendars/Events/2022-03-31 🏠 Arrivée de Papa.md create mode 100644 00.01 Admin/Calendars/Events/2022-04-04 🗼 Départ Papa.md create mode 100644 00.01 Admin/Calendars/Events/2022-04-10 🗳️ 1er tour Présidentielle.md create mode 100644 00.01 Admin/Calendars/Events/2022-04-24 🗳️ 2nd tour élections présidentielles.md create mode 100644 00.01 Admin/Calendars/Events/2022-04-27 📍 Arrivée à Lisbonne.md create mode 100644 00.01 Admin/Calendars/Events/2022-05-01 🏠 Départ de Lisbonne.md create mode 100644 00.01 Admin/Calendars/Events/2022-05-15 🏠 Definite arrival of Meggi-mo to Züzü.md create mode 100644 00.01 Admin/Calendars/Events/2022-10-14 📍 Weekend à GVA.md create mode 100644 00.01 Admin/Calendars/Events/2022-10-21 🗼 Weekend à Paris.md create mode 100644 00.01 Admin/Calendars/Events/2022-11-19 💍 Fiançailles Marguerite & Arnold.md create mode 100644 00.01 Admin/Calendars/Events/2022-12-26 🏠 Papa à Zürich.md create mode 100644 00.01 Admin/Calendars/Events/2022-12-30 🏠 Stef & Kyna in Zürich.md create mode 100644 00.01 Admin/Calendars/Events/2023-01-23 🩺 Médecin.md create mode 100644 00.01 Admin/Calendars/Events/2023-02-06 📍 Genève.md create mode 100644 00.01 Admin/Calendars/Events/2023-02-09 🩺 Médecin.md create mode 100644 00.01 Admin/Calendars/Events/2023-02-11 💍 Mariage Eloi & Zélie.md create mode 100644 00.01 Admin/Calendars/Events/2023-02-19 🎞️ Tár @ Riff Raff.md create mode 100644 00.01 Admin/Calendars/Events/2023-03-06 🩺 Médecin.md create mode 100644 00.01 Admin/Calendars/Events/2023-03-11 🏠 Marg & Arnold à Zürich.md create mode 100644 00.01 Admin/Calendars/Events/2023-03-18 🇨🇭 Molly & boyfriend in Zürich.md create mode 100644 00.01 Admin/Calendars/Events/2023-04-14 🩺 Médecin.md create mode 100644 00.01 Admin/Calendars/Events/2023-12-21 🏠 Arrivée Papa.md create mode 100644 00.01 Admin/Calendars/Events/2023-12-27 🗼 Départ Papa.md create mode 100644 00.01 Admin/Calendars/Events/2024-03-05 ⚽️ Real Sociedad - PSG (1-2).md delete mode 100644 00.01 Admin/Calendars/Events/2024-03-05 ⚽️ Real Sociedad - PSG.md create mode 100644 00.03 News/How Russian Spies Get Flipped or Expelled, As Told by a Spycatcher.md create mode 100644 00.03 News/I always believed my funny, kind father was killed by a murderous teenage gang. Three decades on, I discovered the truth.md create mode 100644 00.03 News/The (Many) Vintages of the Century.md create mode 100644 00.03 News/The Great Pretenders How two faux-Inuit sisters cashed in on a life of deception.md create mode 100644 00.03 News/The Pentagon’s Silicon Valley Problem, by Andrew Cockburn.md rename {00.02 Inbox => 03.01 Reading list}/Invisible Man.md (94%) rename {00.02 Inbox => 03.01 Reading list}/Yoga.md (95%) diff --git a/.obsidian/plugins/cron/data.json b/.obsidian/plugins/cron/data.json index 838c92fc..cfd6a3fe 100644 --- a/.obsidian/plugins/cron/data.json +++ b/.obsidian/plugins/cron/data.json @@ -19,7 +19,7 @@ "601d1cc7-a4f3-4f19-aa9f-3bddd7ab6b1d": { "locked": false, "lockedDeviceName": "iPhone", - "lastRun": "2024-03-03T09:00:01+01:00" + "lastRun": "2024-03-10T07:12:39+01:00" } } } \ No newline at end of file diff --git a/.obsidian/plugins/media-extended/main.js b/.obsidian/plugins/media-extended/main.js index df44c64b..9ba976c3 100644 --- a/.obsidian/plugins/media-extended/main.js +++ b/.obsidian/plugins/media-extended/main.js @@ -3,24 +3,24 @@ THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source visit the plugins github repository */ -"use strict";var wL=Object.create;var jo=Object.defineProperty;var bL=Object.getOwnPropertyDescriptor;var xL=Object.getOwnPropertyNames;var kL=Object.getPrototypeOf,EL=Object.prototype.hasOwnProperty;var TL=(t,e,n)=>e in t?jo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Ue=(t,e)=>()=>(t&&(e=t(t=0)),e);var dt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),xt=(t,e)=>{for(var n in e)jo(t,n,{get:e[n],enumerable:!0})},wx=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of xL(e))!EL.call(t,r)&&r!==n&&jo(t,r,{get:()=>e[r],enumerable:!(i=bL(e,r))||i.enumerable});return t};var $=(t,e,n)=>(n=t!=null?wL(kL(t)):{},wx(e||!t||!t.__esModule?jo(n,"default",{value:t,enumerable:!0}):n,t)),SL=t=>wx(jo({},"__esModule",{value:!0}),t);var w=(t,e,n)=>(TL(t,typeof e!="symbol"?e+"":e,n),n),ng=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var k=(t,e,n)=>(ng(t,e,"read from private field"),n?n.call(t):e.get(t)),O=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},we=(t,e,n,i)=>(ng(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n);var M=(t,e,n)=>(ng(t,e,"access private method"),n);var zx=dt(ie=>{"use strict";var Ho=Symbol.for("react.element"),NL=Symbol.for("react.portal"),DL=Symbol.for("react.fragment"),OL=Symbol.for("react.strict_mode"),VL=Symbol.for("react.profiler"),FL=Symbol.for("react.provider"),zL=Symbol.for("react.context"),UL=Symbol.for("react.forward_ref"),jL=Symbol.for("react.suspense"),qL=Symbol.for("react.memo"),HL=Symbol.for("react.lazy"),Mx=Symbol.iterator;function BL(t){return t===null||typeof t!="object"?null:(t=Mx&&t[Mx]||t["@@iterator"],typeof t=="function"?t:null)}var Ix={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Ax=Object.assign,Nx={};function Xs(t,e,n){this.props=t,this.context=e,this.refs=Nx,this.updater=n||Ix}Xs.prototype.isReactComponent={};Xs.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};Xs.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function Dx(){}Dx.prototype=Xs.prototype;function lg(t,e,n){this.props=t,this.context=e,this.refs=Nx,this.updater=n||Ix}var cg=lg.prototype=new Dx;cg.constructor=lg;Ax(cg,Xs.prototype);cg.isPureReactComponent=!0;var Rx=Array.isArray,Ox=Object.prototype.hasOwnProperty,ug={current:null},Vx={key:!0,ref:!0,__self:!0,__source:!0};function Fx(t,e,n){var i,r={},s=null,a=null;if(e!=null)for(i in e.ref!==void 0&&(a=e.ref),e.key!==void 0&&(s=""+e.key),e)Ox.call(e,i)&&!Vx.hasOwnProperty(i)&&(r[i]=e[i]);var o=arguments.length-2;if(o===1)r.children=n;else if(1{"use strict";Ux.exports=zx()});var Xx=dt(me=>{"use strict";function mg(t,e){var n=t.length;t.push(e);e:for(;0>>1,r=t[i];if(0>>1;ied(o,n))led(c,o)?(t[i]=c,t[l]=n,i=l):(t[i]=o,t[a]=n,i=a);else if(led(c,n))t[i]=c,t[l]=n,i=l;else break e}}return e}function ed(t,e){var n=t.sortIndex-e.sortIndex;return n!==0?n:t.id-e.id}typeof performance=="object"&&typeof performance.now=="function"?(jx=performance,me.unstable_now=function(){return jx.now()}):(pg=Date,qx=pg.now(),me.unstable_now=function(){return pg.now()-qx});var jx,pg,qx,oi=[],or=[],QL=1,gn=null,ht=3,id=!1,es=!1,Wo=!1,Wx=typeof setTimeout=="function"?setTimeout:null,Kx=typeof clearTimeout=="function"?clearTimeout:null,Hx=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function gg(t){for(var e=qn(or);e!==null;){if(e.callback===null)nd(or);else if(e.startTime<=t)nd(or),e.sortIndex=e.expirationTime,mg(oi,e);else break;e=qn(or)}}function vg(t){if(Wo=!1,gg(t),!es)if(qn(oi)!==null)es=!0,_g(yg);else{var e=qn(or);e!==null&&wg(vg,e.startTime-t)}}function yg(t,e){es=!1,Wo&&(Wo=!1,Kx(Ko),Ko=-1),id=!0;var n=ht;try{for(gg(e),gn=qn(oi);gn!==null&&(!(gn.expirationTime>e)||t&&!Qx());){var i=gn.callback;if(typeof i=="function"){gn.callback=null,ht=gn.priorityLevel;var r=i(gn.expirationTime<=e);e=me.unstable_now(),typeof r=="function"?gn.callback=r:gn===qn(oi)&&nd(oi),gg(e)}else nd(oi);gn=qn(oi)}if(gn!==null)var s=!0;else{var a=qn(or);a!==null&&wg(vg,a.startTime-e),s=!1}return s}finally{gn=null,ht=n,id=!1}}var rd=!1,td=null,Ko=-1,Gx=5,Yx=-1;function Qx(){return!(me.unstable_now()-Yxt||125i?(t.sortIndex=n,mg(or,t),qn(oi)===null&&t===qn(or)&&(Wo?(Kx(Ko),Ko=-1):Wo=!0,wg(vg,n-i))):(t.sortIndex=r,mg(oi,t),es||id||(es=!0,_g(yg))),t};me.unstable_shouldYield=Qx;me.unstable_wrapCallback=function(t){var e=ht;return function(){var n=ht;ht=e;try{return t.apply(this,arguments)}finally{ht=n}}}});var Jx=dt((uz,Zx)=>{"use strict";Zx.exports=Xx()});var sT=dt(sn=>{"use strict";var ak=z(),nn=Jx();function P(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),qg=Object.prototype.hasOwnProperty,XL=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,e0={},t0={};function ZL(t){return qg.call(t0,t)?!0:qg.call(e0,t)?!1:XL.test(t)?t0[t]=!0:(e0[t]=!0,!1)}function JL(t,e,n,i){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return i?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function eI(t,e,n,i){if(e===null||typeof e>"u"||JL(t,e,n,i))return!0;if(i)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Pt(t,e,n,i,r,s,a){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=i,this.attributeNamespace=r,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=a}var ot={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){ot[t]=new Pt(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];ot[e]=new Pt(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){ot[t]=new Pt(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){ot[t]=new Pt(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){ot[t]=new Pt(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){ot[t]=new Pt(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){ot[t]=new Pt(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){ot[t]=new Pt(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){ot[t]=new Pt(t,5,!1,t.toLowerCase(),null,!1,!1)});var Nv=/[\-:]([a-z])/g;function Dv(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Nv,Dv);ot[e]=new Pt(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Nv,Dv);ot[e]=new Pt(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Nv,Dv);ot[e]=new Pt(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){ot[t]=new Pt(t,1,!1,t.toLowerCase(),null,!1,!1)});ot.xlinkHref=new Pt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){ot[t]=new Pt(t,1,!1,t.toLowerCase(),null,!0,!0)});function Ov(t,e,n,i){var r=ot.hasOwnProperty(e)?ot[e]:null;(r!==null?r.type!==0:i||!(2e in t?qo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Ue=(t,e)=>()=>(t&&(e=t(t=0)),e);var dt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),xt=(t,e)=>{for(var n in e)qo(t,n,{get:e[n],enumerable:!0})},Tx=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of SL(e))!CL.call(t,r)&&r!==n&&qo(t,r,{get:()=>e[r],enumerable:!(i=TL(e,r))||i.enumerable});return t};var $=(t,e,n)=>(n=t!=null?EL(PL(t)):{},Tx(e||!t||!t.__esModule?qo(n,"default",{value:t,enumerable:!0}):n,t)),ML=t=>Tx(qo({},"__esModule",{value:!0}),t);var _=(t,e,n)=>($L(t,typeof e!="symbol"?e+"":e,n),n),og=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var k=(t,e,n)=>(og(t,e,"read from private field"),n?n.call(t):e.get(t)),O=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},we=(t,e,n,i)=>(og(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n);var M=(t,e,n)=>(og(t,e,"access private method"),n);var Wx=dt(ie=>{"use strict";var Ko=Symbol.for("react.element"),jL=Symbol.for("react.portal"),HL=Symbol.for("react.fragment"),qL=Symbol.for("react.strict_mode"),BL=Symbol.for("react.profiler"),WL=Symbol.for("react.provider"),KL=Symbol.for("react.context"),GL=Symbol.for("react.forward_ref"),YL=Symbol.for("react.suspense"),QL=Symbol.for("react.memo"),XL=Symbol.for("react.lazy"),Dx=Symbol.iterator;function ZL(t){return t===null||typeof t!="object"?null:(t=Dx&&t[Dx]||t["@@iterator"],typeof t=="function"?t:null)}var Fx={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},zx=Object.assign,Ux={};function Js(t,e,n){this.props=t,this.context=e,this.refs=Ux,this.updater=n||Fx}Js.prototype.isReactComponent={};Js.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};Js.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function jx(){}jx.prototype=Js.prototype;function hg(t,e,n){this.props=t,this.context=e,this.refs=Ux,this.updater=n||Fx}var fg=hg.prototype=new jx;fg.constructor=hg;zx(fg,Js.prototype);fg.isPureReactComponent=!0;var Ox=Array.isArray,Hx=Object.prototype.hasOwnProperty,mg={current:null},qx={key:!0,ref:!0,__self:!0,__source:!0};function Bx(t,e,n){var i,r={},s=null,a=null;if(e!=null)for(i in e.ref!==void 0&&(a=e.ref),e.key!==void 0&&(s=""+e.key),e)Hx.call(e,i)&&!qx.hasOwnProperty(i)&&(r[i]=e[i]);var o=arguments.length-2;if(o===1)r.children=n;else if(1{"use strict";Kx.exports=Wx()});var i0=dt(me=>{"use strict";function wg(t,e){var n=t.length;t.push(e);e:for(;0>>1,r=t[i];if(0>>1;iad(o,n))lad(c,o)?(t[i]=c,t[l]=n,i=l):(t[i]=o,t[a]=n,i=a);else if(lad(c,n))t[i]=c,t[l]=n,i=l;else break e}}return e}function ad(t,e){var n=t.sortIndex-e.sortIndex;return n!==0?n:t.id-e.id}typeof performance=="object"&&typeof performance.now=="function"?(Gx=performance,me.unstable_now=function(){return Gx.now()}):(vg=Date,Yx=vg.now(),me.unstable_now=function(){return vg.now()-Yx});var Gx,vg,Yx,ci=[],lr=[],iI=1,gn=null,ht=3,cd=!1,is=!1,Yo=!1,Zx=typeof setTimeout=="function"?setTimeout:null,Jx=typeof clearTimeout=="function"?clearTimeout:null,Qx=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function bg(t){for(var e=Hn(lr);e!==null;){if(e.callback===null)ld(lr);else if(e.startTime<=t)ld(lr),e.sortIndex=e.expirationTime,wg(ci,e);else break;e=Hn(lr)}}function xg(t){if(Yo=!1,bg(t),!is)if(Hn(ci)!==null)is=!0,Eg(kg);else{var e=Hn(lr);e!==null&&Tg(xg,e.startTime-t)}}function kg(t,e){is=!1,Yo&&(Yo=!1,Jx(Qo),Qo=-1),cd=!0;var n=ht;try{for(bg(e),gn=Hn(ci);gn!==null&&(!(gn.expirationTime>e)||t&&!n0());){var i=gn.callback;if(typeof i=="function"){gn.callback=null,ht=gn.priorityLevel;var r=i(gn.expirationTime<=e);e=me.unstable_now(),typeof r=="function"?gn.callback=r:gn===Hn(ci)&&ld(ci),bg(e)}else ld(ci);gn=Hn(ci)}if(gn!==null)var s=!0;else{var a=Hn(lr);a!==null&&Tg(xg,a.startTime-e),s=!1}return s}finally{gn=null,ht=n,cd=!1}}var ud=!1,od=null,Qo=-1,e0=5,t0=-1;function n0(){return!(me.unstable_now()-t0t||125i?(t.sortIndex=n,wg(lr,t),Hn(ci)===null&&t===Hn(lr)&&(Yo?(Jx(Qo),Qo=-1):Yo=!0,Tg(xg,n-i))):(t.sortIndex=r,wg(ci,t),is||cd||(is=!0,Eg(kg))),t};me.unstable_shouldYield=n0;me.unstable_wrapCallback=function(t){var e=ht;return function(){var n=ht;ht=e;try{return t.apply(this,arguments)}finally{ht=n}}}});var s0=dt((yz,r0)=>{"use strict";r0.exports=i0()});var dT=dt(sn=>{"use strict";var pk=z(),nn=s0();function P(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Gg=Object.prototype.hasOwnProperty,rI=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,a0={},o0={};function sI(t){return Gg.call(o0,t)?!0:Gg.call(a0,t)?!1:rI.test(t)?o0[t]=!0:(a0[t]=!0,!1)}function aI(t,e,n,i){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return i?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function oI(t,e,n,i){if(e===null||typeof e>"u"||aI(t,e,n,i))return!0;if(i)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Pt(t,e,n,i,r,s,a){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=i,this.attributeNamespace=r,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=a}var ot={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){ot[t]=new Pt(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];ot[e]=new Pt(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){ot[t]=new Pt(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){ot[t]=new Pt(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){ot[t]=new Pt(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){ot[t]=new Pt(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){ot[t]=new Pt(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){ot[t]=new Pt(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){ot[t]=new Pt(t,5,!1,t.toLowerCase(),null,!1,!1)});var zv=/[\-:]([a-z])/g;function Uv(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(zv,Uv);ot[e]=new Pt(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(zv,Uv);ot[e]=new Pt(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(zv,Uv);ot[e]=new Pt(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){ot[t]=new Pt(t,1,!1,t.toLowerCase(),null,!1,!1)});ot.xlinkHref=new Pt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){ot[t]=new Pt(t,1,!1,t.toLowerCase(),null,!0,!0)});function jv(t,e,n,i){var r=ot.hasOwnProperty(e)?ot[e]:null;(r!==null?r.type!==0:i||!(2o||r[a]!==s[o]){var l=` -`+r[a].replace(" at new "," at ");return t.displayName&&l.includes("")&&(l=l.replace("",t.displayName)),l}while(1<=a&&0<=o);break}}}finally{xg=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?nl(t):""}function tI(t){switch(t.tag){case 5:return nl(t.type);case 16:return nl("Lazy");case 13:return nl("Suspense");case 19:return nl("SuspenseList");case 0:case 2:case 15:return t=kg(t.type,!1),t;case 11:return t=kg(t.type.render,!1),t;case 1:return t=kg(t.type,!0),t;default:return""}}function Kg(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case ta:return"Fragment";case ea:return"Portal";case Hg:return"Profiler";case Vv:return"StrictMode";case Bg:return"Suspense";case Wg:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case ck:return(t.displayName||"Context")+".Consumer";case lk:return(t._context.displayName||"Context")+".Provider";case Fv:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case zv:return e=t.displayName||null,e!==null?e:Kg(t.type)||"Memo";case cr:e=t._payload,t=t._init;try{return Kg(t(e))}catch{}}return null}function nI(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Kg(e);case 8:return e===Vv?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function kr(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function dk(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function iI(t){var e=dk(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),i=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var r=n.get,s=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return r.call(this)},set:function(a){i=""+a,s.call(this,a)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return i},setValue:function(a){i=""+a},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function ad(t){t._valueTracker||(t._valueTracker=iI(t))}function pk(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),i="";return t&&(i=dk(t)?t.checked?"true":"false":t.value),t=i,t!==n?(e.setValue(t),!0):!1}function Ad(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Gg(t,e){var n=e.checked;return Le({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function i0(t,e){var n=e.defaultValue==null?"":e.defaultValue,i=e.checked!=null?e.checked:e.defaultChecked;n=kr(e.value!=null?e.value:n),t._wrapperState={initialChecked:i,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function hk(t,e){e=e.checked,e!=null&&Ov(t,"checked",e,!1)}function Yg(t,e){hk(t,e);var n=kr(e.value),i=e.type;if(n!=null)i==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(i==="submit"||i==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Qg(t,e.type,n):e.hasOwnProperty("defaultValue")&&Qg(t,e.type,kr(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function r0(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var i=e.type;if(!(i!=="submit"&&i!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Qg(t,e,n){(e!=="number"||Ad(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var il=Array.isArray;function pa(t,e,n,i){if(t=t.options,e){e={};for(var r=0;r"+e.valueOf().toString()+"",e=od.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function gl(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var al={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},rI=["Webkit","ms","Moz","O"];Object.keys(al).forEach(function(t){rI.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),al[e]=al[t]})});function vk(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||al.hasOwnProperty(t)&&al[t]?(""+e).trim():e+"px"}function yk(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var i=n.indexOf("--")===0,r=vk(n,e[n],i);n==="float"&&(n="cssFloat"),i?t.setProperty(n,r):t[n]=r}}var sI=Le({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Jg(t,e){if(e){if(sI[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(P(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(P(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(P(61))}if(e.style!=null&&typeof e.style!="object")throw Error(P(62))}}function ev(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var tv=null;function Uv(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var nv=null,ha=null,fa=null;function o0(t){if(t=Al(t)){if(typeof nv!="function")throw Error(P(280));var e=t.stateNode;e&&(e=lp(e),nv(t.stateNode,t.type,e))}}function _k(t){ha?fa?fa.push(t):fa=[t]:ha=t}function wk(){if(ha){var t=ha,e=fa;if(fa=ha=null,o0(t),e)for(t=0;t>>=0,t===0?32:31-(gI(t)/vI|0)|0}var ld=64,cd=4194304;function rl(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Vd(t,e){var n=t.pendingLanes;if(n===0)return 0;var i=0,r=t.suspendedLanes,s=t.pingedLanes,a=n&268435455;if(a!==0){var o=a&~r;o!==0?i=rl(o):(s&=a,s!==0&&(i=rl(s)))}else a=n&~r,a!==0?i=rl(a):s!==0&&(i=rl(s));if(i===0)return 0;if(e!==0&&e!==i&&!(e&r)&&(r=i&-i,s=e&-e,r>=s||r===16&&(s&4194240)!==0))return e;if(i&4&&(i|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=i;0n;n++)e.push(t);return e}function Ll(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Gn(e),t[e]=n}function bI(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var i=t.eventTimes;for(t=t.expirationTimes;0=ll),g0=" ",v0=!1;function zk(t,e){switch(t){case"keyup":return YI.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Uk(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var na=!1;function XI(t,e){switch(t){case"compositionend":return Uk(e);case"keypress":return e.which!==32?null:(v0=!0,g0);case"textInput":return t=e.data,t===g0&&v0?null:t;default:return null}}function ZI(t,e){if(na)return t==="compositionend"||!Yv&&zk(t,e)?(t=Vk(),Td=Wv=hr=null,na=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=i}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=w0(n)}}function Bk(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?Bk(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function Wk(){for(var t=window,e=Ad();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=Ad(t.document)}return e}function Qv(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function oA(t){var e=Wk(),n=t.focusedElem,i=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&Bk(n.ownerDocument.documentElement,n)){if(i!==null&&Qv(n)){if(e=i.start,t=i.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var r=n.textContent.length,s=Math.min(i.start,r);i=i.end===void 0?s:Math.min(i.end,r),!t.extend&&s>i&&(r=i,i=s,s=r),r=b0(n,s);var a=b0(n,i);r&&a&&(t.rangeCount!==1||t.anchorNode!==r.node||t.anchorOffset!==r.offset||t.focusNode!==a.node||t.focusOffset!==a.offset)&&(e=e.createRange(),e.setStart(r.node,r.offset),t.removeAllRanges(),s>i?(t.addRange(e),t.extend(a.node,a.offset)):(e.setEnd(a.node,a.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,ia=null,lv=null,ul=null,cv=!1;function x0(t,e,n){var i=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;cv||ia==null||ia!==Ad(i)||(i=ia,"selectionStart"in i&&Qv(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),ul&&xl(ul,i)||(ul=i,i=Ud(lv,"onSelect"),0aa||(t.current=mv[aa],mv[aa]=null,aa--)}function ge(t,e){aa++,mv[aa]=t.current,t.current=e}var Er={},vt=Sr(Er),zt=Sr(!1),ls=Er;function _a(t,e){var n=t.type.contextTypes;if(!n)return Er;var i=t.stateNode;if(i&&i.__reactInternalMemoizedUnmaskedChildContext===e)return i.__reactInternalMemoizedMaskedChildContext;var r={},s;for(s in n)r[s]=e[s];return i&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=r),r}function Ut(t){return t=t.childContextTypes,t!=null}function qd(){xe(zt),xe(vt)}function R0(t,e,n){if(vt.current!==Er)throw Error(P(168));ge(vt,e),ge(zt,n)}function tE(t,e,n){var i=t.stateNode;if(e=e.childContextTypes,typeof i.getChildContext!="function")return n;i=i.getChildContext();for(var r in i)if(!(r in e))throw Error(P(108,nI(t)||"Unknown",r));return Le({},n,i)}function Hd(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Er,ls=vt.current,ge(vt,t),ge(zt,zt.current),!0}function L0(t,e,n){var i=t.stateNode;if(!i)throw Error(P(169));n?(t=tE(t,e,ls),i.__reactInternalMemoizedMergedChildContext=t,xe(zt),xe(vt),ge(vt,t)):xe(zt),ge(zt,n)}var Li=null,cp=!1,Ag=!1;function nE(t){Li===null?Li=[t]:Li.push(t)}function vA(t){cp=!0,nE(t)}function Pr(){if(!Ag&&Li!==null){Ag=!0;var t=0,e=de;try{var n=Li;for(de=1;t>=a,r-=a,Ii=1<<32-Gn(e)+r|n<I?(K=R,R=null):K=R.sibling;var q=p(m,R,g[I],x);if(q===null){R===null&&(R=K);break}t&&R&&q.alternate===null&&e(m,R),f=s(q,f,I),L===null?T=q:L.sibling=q,L=q,R=K}if(I===g.length)return n(m,R),Ce&&ts(m,I),T;if(R===null){for(;II?(K=R,R=null):K=R.sibling;var _e=p(m,R,q.value,x);if(_e===null){R===null&&(R=K);break}t&&R&&_e.alternate===null&&e(m,R),f=s(_e,f,I),L===null?T=_e:L.sibling=_e,L=_e,R=K}if(q.done)return n(m,R),Ce&&ts(m,I),T;if(R===null){for(;!q.done;I++,q=g.next())q=d(m,q.value,x),q!==null&&(f=s(q,f,I),L===null?T=q:L.sibling=q,L=q);return Ce&&ts(m,I),T}for(R=i(m,R);!q.done;I++,q=g.next())q=h(R,m,I,q.value,x),q!==null&&(t&&q.alternate!==null&&R.delete(q.key===null?I:q.key),f=s(q,f,I),L===null?T=q:L.sibling=q,L=q);return t&&R.forEach(function(J){return e(m,J)}),Ce&&ts(m,I),T}function _(m,f,g,x){if(typeof g=="object"&&g!==null&&g.type===ta&&g.key===null&&(g=g.props.children),typeof g=="object"&&g!==null){switch(g.$$typeof){case sd:e:{for(var T=g.key,L=f;L!==null;){if(L.key===T){if(T=g.type,T===ta){if(L.tag===7){n(m,L.sibling),f=r(L,g.props.children),f.return=m,m=f;break e}}else if(L.elementType===T||typeof T=="object"&&T!==null&&T.$$typeof===cr&&F0(T)===L.type){n(m,L.sibling),f=r(L,g.props),f.ref=Zo(m,L,g),f.return=m,m=f;break e}n(m,L);break}else e(m,L);L=L.sibling}g.type===ta?(f=os(g.props.children,m.mode,x,g.key),f.return=m,m=f):(x=Id(g.type,g.key,g.props,null,m.mode,x),x.ref=Zo(m,f,g),x.return=m,m=x)}return a(m);case ea:e:{for(L=g.key;f!==null;){if(f.key===L)if(f.tag===4&&f.stateNode.containerInfo===g.containerInfo&&f.stateNode.implementation===g.implementation){n(m,f.sibling),f=r(f,g.children||[]),f.return=m,m=f;break e}else{n(m,f);break}else e(m,f);f=f.sibling}f=jg(g,m.mode,x),f.return=m,m=f}return a(m);case cr:return L=g._init,_(m,f,L(g._payload),x)}if(il(g))return y(m,f,g,x);if(Go(g))return v(m,f,g,x);wd(m,g)}return typeof g=="string"&&g!==""||typeof g=="number"?(g=""+g,f!==null&&f.tag===6?(n(m,f.sibling),f=r(f,g),f.return=m,m=f):(n(m,f),f=Ug(g,m.mode,x),f.return=m,m=f),a(m)):n(m,f)}return _}var ba=uE(!0),dE=uE(!1),Nl={},pi=Sr(Nl),Sl=Sr(Nl),Pl=Sr(Nl);function ss(t){if(t===Nl)throw Error(P(174));return t}function sy(t,e){switch(ge(Pl,e),ge(Sl,t),ge(pi,Nl),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:Zg(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=Zg(e,t)}xe(pi),ge(pi,e)}function xa(){xe(pi),xe(Sl),xe(Pl)}function pE(t){ss(Pl.current);var e=ss(pi.current),n=Zg(e,t.type);e!==n&&(ge(Sl,t),ge(pi,n))}function ay(t){Sl.current===t&&(xe(pi),xe(Sl))}var Me=Sr(0);function Qd(t){for(var e=t;e!==null;){if(e.tag===13){var n=e.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var Ng=[];function oy(){for(var t=0;tn?n:4,t(!0);var i=Dg.transition;Dg.transition={};try{t(!1),e()}finally{de=n,Dg.transition=i}}function CE(){return xn().memoizedState}function bA(t,e,n){var i=br(t);if(n={lane:i,action:n,hasEagerState:!1,eagerState:null,next:null},$E(t))ME(e,n);else if(n=aE(t,e,n,i),n!==null){var r=St();Yn(n,t,i,r),RE(n,e,i)}}function xA(t,e,n){var i=br(t),r={lane:i,action:n,hasEagerState:!1,eagerState:null,next:null};if($E(t))ME(e,r);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var a=e.lastRenderedState,o=s(a,n);if(r.hasEagerState=!0,r.eagerState=o,Qn(o,a)){var l=e.interleaved;l===null?(r.next=r,iy(e)):(r.next=l.next,l.next=r),e.interleaved=r;return}}catch{}finally{}n=aE(t,e,r,i),n!==null&&(r=St(),Yn(n,t,i,r),RE(n,e,i))}}function $E(t){var e=t.alternate;return t===Re||e!==null&&e===Re}function ME(t,e){dl=Xd=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function RE(t,e,n){if(n&4194240){var i=e.lanes;i&=t.pendingLanes,n|=i,e.lanes=n,qv(t,n)}}var Zd={readContext:bn,useCallback:ft,useContext:ft,useEffect:ft,useImperativeHandle:ft,useInsertionEffect:ft,useLayoutEffect:ft,useMemo:ft,useReducer:ft,useRef:ft,useState:ft,useDebugValue:ft,useDeferredValue:ft,useTransition:ft,useMutableSource:ft,useSyncExternalStore:ft,useId:ft,unstable_isNewReconciler:!1},kA={readContext:bn,useCallback:function(t,e){return ci().memoizedState=[t,e===void 0?null:e],t},useContext:bn,useEffect:U0,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,$d(4194308,4,kE.bind(null,e,t),n)},useLayoutEffect:function(t,e){return $d(4194308,4,t,e)},useInsertionEffect:function(t,e){return $d(4,2,t,e)},useMemo:function(t,e){var n=ci();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var i=ci();return e=n!==void 0?n(e):e,i.memoizedState=i.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},i.queue=t,t=t.dispatch=bA.bind(null,Re,t),[i.memoizedState,t]},useRef:function(t){var e=ci();return t={current:t},e.memoizedState=t},useState:z0,useDebugValue:py,useDeferredValue:function(t){return ci().memoizedState=t},useTransition:function(){var t=z0(!1),e=t[0];return t=wA.bind(null,t[1]),ci().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var i=Re,r=ci();if(Ce){if(n===void 0)throw Error(P(407));n=n()}else{if(n=e(),Je===null)throw Error(P(349));us&30||mE(i,e,n)}r.memoizedState=n;var s={value:n,getSnapshot:e};return r.queue=s,U0(vE.bind(null,i,s,t),[t]),i.flags|=2048,Ml(9,gE.bind(null,i,s,n,e),void 0,null),n},useId:function(){var t=ci(),e=Je.identifierPrefix;if(Ce){var n=Ai,i=Ii;n=(i&~(1<<32-Gn(i)-1)).toString(32)+n,e=":"+e+"R"+n,n=Cl++,0")&&(l=l.replace("",t.displayName)),l}while(1<=a&&0<=o);break}}}finally{Pg=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?sl(t):""}function lI(t){switch(t.tag){case 5:return sl(t.type);case 16:return sl("Lazy");case 13:return sl("Suspense");case 19:return sl("SuspenseList");case 0:case 2:case 15:return t=Cg(t.type,!1),t;case 11:return t=Cg(t.type.render,!1),t;case 1:return t=Cg(t.type,!0),t;default:return""}}function Zg(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case ia:return"Fragment";case na:return"Portal";case Yg:return"Profiler";case Hv:return"StrictMode";case Qg:return"Suspense";case Xg:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case mk:return(t.displayName||"Context")+".Consumer";case fk:return(t._context.displayName||"Context")+".Provider";case qv:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Bv:return e=t.displayName||null,e!==null?e:Zg(t.type)||"Memo";case ur:e=t._payload,t=t._init;try{return Zg(t(e))}catch{}}return null}function cI(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Zg(e);case 8:return e===Hv?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Er(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function vk(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function uI(t){var e=vk(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),i=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var r=n.get,s=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return r.call(this)},set:function(a){i=""+a,s.call(this,a)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return i},setValue:function(a){i=""+a},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function pd(t){t._valueTracker||(t._valueTracker=uI(t))}function yk(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),i="";return t&&(i=vk(t)?t.checked?"true":"false":t.value),t=i,t!==n?(e.setValue(t),!0):!1}function zd(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Jg(t,e){var n=e.checked;return Re({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function c0(t,e){var n=e.defaultValue==null?"":e.defaultValue,i=e.checked!=null?e.checked:e.defaultChecked;n=Er(e.value!=null?e.value:n),t._wrapperState={initialChecked:i,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function _k(t,e){e=e.checked,e!=null&&jv(t,"checked",e,!1)}function ev(t,e){_k(t,e);var n=Er(e.value),i=e.type;if(n!=null)i==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(i==="submit"||i==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?tv(t,e.type,n):e.hasOwnProperty("defaultValue")&&tv(t,e.type,Er(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function u0(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var i=e.type;if(!(i!=="submit"&&i!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function tv(t,e,n){(e!=="number"||zd(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var al=Array.isArray;function fa(t,e,n,i){if(t=t.options,e){e={};for(var r=0;r"+e.valueOf().toString()+"",e=hd.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function _l(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var cl={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},dI=["Webkit","ms","Moz","O"];Object.keys(cl).forEach(function(t){dI.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),cl[e]=cl[t]})});function kk(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||cl.hasOwnProperty(t)&&cl[t]?(""+e).trim():e+"px"}function Ek(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var i=n.indexOf("--")===0,r=kk(n,e[n],i);n==="float"&&(n="cssFloat"),i?t.setProperty(n,r):t[n]=r}}var pI=Re({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function rv(t,e){if(e){if(pI[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(P(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(P(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(P(61))}if(e.style!=null&&typeof e.style!="object")throw Error(P(62))}}function sv(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var av=null;function Wv(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var ov=null,ma=null,ga=null;function h0(t){if(t=Ol(t)){if(typeof ov!="function")throw Error(P(280));var e=t.stateNode;e&&(e=fp(e),ov(t.stateNode,t.type,e))}}function Tk(t){ma?ga?ga.push(t):ga=[t]:ma=t}function Sk(){if(ma){var t=ma,e=ga;if(ga=ma=null,h0(t),e)for(t=0;t>>=0,t===0?32:31-(kI(t)/EI|0)|0}var fd=64,md=4194304;function ol(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function qd(t,e){var n=t.pendingLanes;if(n===0)return 0;var i=0,r=t.suspendedLanes,s=t.pingedLanes,a=n&268435455;if(a!==0){var o=a&~r;o!==0?i=ol(o):(s&=a,s!==0&&(i=ol(s)))}else a=n&~r,a!==0?i=ol(a):s!==0&&(i=ol(s));if(i===0)return 0;if(e!==0&&e!==i&&!(e&r)&&(r=i&-i,s=e&-e,r>=s||r===16&&(s&4194240)!==0))return e;if(i&4&&(i|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=i;0n;n++)e.push(t);return e}function Nl(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Gn(e),t[e]=n}function CI(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var i=t.eventTimes;for(t=t.expirationTimes;0=dl),x0=" ",k0=!1;function Wk(t,e){switch(t){case"keyup":return nA.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Kk(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ra=!1;function rA(t,e){switch(t){case"compositionend":return Kk(e);case"keypress":return e.which!==32?null:(k0=!0,x0);case"textInput":return t=e.data,t===x0&&k0?null:t;default:return null}}function sA(t,e){if(ra)return t==="compositionend"||!ey&&Wk(t,e)?(t=qk(),Rd=Xv=fr=null,ra=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=i}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=S0(n)}}function Xk(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?Xk(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function Zk(){for(var t=window,e=zd();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=zd(t.document)}return e}function ty(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function fA(t){var e=Zk(),n=t.focusedElem,i=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&Xk(n.ownerDocument.documentElement,n)){if(i!==null&&ty(n)){if(e=i.start,t=i.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var r=n.textContent.length,s=Math.min(i.start,r);i=i.end===void 0?s:Math.min(i.end,r),!t.extend&&s>i&&(r=i,i=s,s=r),r=P0(n,s);var a=P0(n,i);r&&a&&(t.rangeCount!==1||t.anchorNode!==r.node||t.anchorOffset!==r.offset||t.focusNode!==a.node||t.focusOffset!==a.offset)&&(e=e.createRange(),e.setStart(r.node,r.offset),t.removeAllRanges(),s>i?(t.addRange(e),t.extend(a.node,a.offset)):(e.setEnd(a.node,a.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,sa=null,hv=null,hl=null,fv=!1;function C0(t,e,n){var i=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;fv||sa==null||sa!==zd(i)||(i=sa,"selectionStart"in i&&ty(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),hl&&Tl(hl,i)||(hl=i,i=Kd(hv,"onSelect"),0la||(t.current=wv[la],wv[la]=null,la--)}function ge(t,e){la++,wv[la]=t.current,t.current=e}var Tr={},vt=Pr(Tr),zt=Pr(!1),ds=Tr;function ba(t,e){var n=t.type.contextTypes;if(!n)return Tr;var i=t.stateNode;if(i&&i.__reactInternalMemoizedUnmaskedChildContext===e)return i.__reactInternalMemoizedMaskedChildContext;var r={},s;for(s in n)r[s]=e[s];return i&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=r),r}function Ut(t){return t=t.childContextTypes,t!=null}function Yd(){xe(zt),xe(vt)}function O0(t,e,n){if(vt.current!==Tr)throw Error(P(168));ge(vt,e),ge(zt,n)}function oE(t,e,n){var i=t.stateNode;if(e=e.childContextTypes,typeof i.getChildContext!="function")return n;i=i.getChildContext();for(var r in i)if(!(r in e))throw Error(P(108,cI(t)||"Unknown",r));return Re({},n,i)}function Qd(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Tr,ds=vt.current,ge(vt,t),ge(zt,zt.current),!0}function V0(t,e,n){var i=t.stateNode;if(!i)throw Error(P(169));n?(t=oE(t,e,ds),i.__reactInternalMemoizedMergedChildContext=t,xe(zt),xe(vt),ge(vt,t)):xe(zt),ge(zt,n)}var Ii=null,mp=!1,Fg=!1;function lE(t){Ii===null?Ii=[t]:Ii.push(t)}function EA(t){mp=!0,lE(t)}function Cr(){if(!Fg&&Ii!==null){Fg=!0;var t=0,e=de;try{var n=Ii;for(de=1;t>=a,r-=a,Ai=1<<32-Gn(e)+r|n<I?(K=R,R=null):K=R.sibling;var H=p(m,R,g[I],x);if(H===null){R===null&&(R=K);break}t&&R&&H.alternate===null&&e(m,R),f=s(H,f,I),L===null?T=H:L.sibling=H,L=H,R=K}if(I===g.length)return n(m,R),Pe&&rs(m,I),T;if(R===null){for(;II?(K=R,R=null):K=R.sibling;var _e=p(m,R,H.value,x);if(_e===null){R===null&&(R=K);break}t&&R&&_e.alternate===null&&e(m,R),f=s(_e,f,I),L===null?T=_e:L.sibling=_e,L=_e,R=K}if(H.done)return n(m,R),Pe&&rs(m,I),T;if(R===null){for(;!H.done;I++,H=g.next())H=d(m,H.value,x),H!==null&&(f=s(H,f,I),L===null?T=H:L.sibling=H,L=H);return Pe&&rs(m,I),T}for(R=i(m,R);!H.done;I++,H=g.next())H=h(R,m,I,H.value,x),H!==null&&(t&&H.alternate!==null&&R.delete(H.key===null?I:H.key),f=s(H,f,I),L===null?T=H:L.sibling=H,L=H);return t&&R.forEach(function(J){return e(m,J)}),Pe&&rs(m,I),T}function w(m,f,g,x){if(typeof g=="object"&&g!==null&&g.type===ia&&g.key===null&&(g=g.props.children),typeof g=="object"&&g!==null){switch(g.$$typeof){case dd:e:{for(var T=g.key,L=f;L!==null;){if(L.key===T){if(T=g.type,T===ia){if(L.tag===7){n(m,L.sibling),f=r(L,g.props.children),f.return=m,m=f;break e}}else if(L.elementType===T||typeof T=="object"&&T!==null&&T.$$typeof===ur&&B0(T)===L.type){n(m,L.sibling),f=r(L,g.props),f.ref=tl(m,L,g),f.return=m,m=f;break e}n(m,L);break}else e(m,L);L=L.sibling}g.type===ia?(f=us(g.props.children,m.mode,x,g.key),f.return=m,m=f):(x=Fd(g.type,g.key,g.props,null,m.mode,x),x.ref=tl(m,f,g),x.return=m,m=x)}return a(m);case na:e:{for(L=g.key;f!==null;){if(f.key===L)if(f.tag===4&&f.stateNode.containerInfo===g.containerInfo&&f.stateNode.implementation===g.implementation){n(m,f.sibling),f=r(f,g.children||[]),f.return=m,m=f;break e}else{n(m,f);break}else e(m,f);f=f.sibling}f=Kg(g,m.mode,x),f.return=m,m=f}return a(m);case ur:return L=g._init,w(m,f,L(g._payload),x)}if(al(g))return y(m,f,g,x);if(Xo(g))return v(m,f,g,x);Sd(m,g)}return typeof g=="string"&&g!==""||typeof g=="number"?(g=""+g,f!==null&&f.tag===6?(n(m,f.sibling),f=r(f,g),f.return=m,m=f):(n(m,f),f=Wg(g,m.mode,x),f.return=m,m=f),a(m)):n(m,f)}return w}var ka=gE(!0),vE=gE(!1),Vl={},fi=Pr(Vl),$l=Pr(Vl),Ml=Pr(Vl);function ls(t){if(t===Vl)throw Error(P(174));return t}function uy(t,e){switch(ge(Ml,e),ge($l,t),ge(fi,Vl),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:iv(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=iv(e,t)}xe(fi),ge(fi,e)}function Ea(){xe(fi),xe($l),xe(Ml)}function yE(t){ls(Ml.current);var e=ls(fi.current),n=iv(e,t.type);e!==n&&(ge($l,t),ge(fi,n))}function dy(t){$l.current===t&&(xe(fi),xe($l))}var $e=Pr(0);function np(t){for(var e=t;e!==null;){if(e.tag===13){var n=e.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var zg=[];function py(){for(var t=0;tn?n:4,t(!0);var i=Ug.transition;Ug.transition={};try{t(!1),e()}finally{de=n,Ug.transition=i}}function AE(){return xn().memoizedState}function CA(t,e,n){var i=xr(t);if(n={lane:i,action:n,hasEagerState:!1,eagerState:null,next:null},NE(t))DE(e,n);else if(n=pE(t,e,n,i),n!==null){var r=St();Yn(n,t,i,r),OE(n,e,i)}}function $A(t,e,n){var i=xr(t),r={lane:i,action:n,hasEagerState:!1,eagerState:null,next:null};if(NE(t))DE(e,r);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var a=e.lastRenderedState,o=s(a,n);if(r.hasEagerState=!0,r.eagerState=o,Qn(o,a)){var l=e.interleaved;l===null?(r.next=r,ly(e)):(r.next=l.next,l.next=r),e.interleaved=r;return}}catch{}finally{}n=pE(t,e,r,i),n!==null&&(r=St(),Yn(n,t,i,r),OE(n,e,i))}}function NE(t){var e=t.alternate;return t===Me||e!==null&&e===Me}function DE(t,e){fl=ip=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function OE(t,e,n){if(n&4194240){var i=e.lanes;i&=t.pendingLanes,n|=i,e.lanes=n,Gv(t,n)}}var rp={readContext:bn,useCallback:ft,useContext:ft,useEffect:ft,useImperativeHandle:ft,useInsertionEffect:ft,useLayoutEffect:ft,useMemo:ft,useReducer:ft,useRef:ft,useState:ft,useDebugValue:ft,useDeferredValue:ft,useTransition:ft,useMutableSource:ft,useSyncExternalStore:ft,useId:ft,unstable_isNewReconciler:!1},MA={readContext:bn,useCallback:function(t,e){return di().memoizedState=[t,e===void 0?null:e],t},useContext:bn,useEffect:K0,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,Nd(4194308,4,$E.bind(null,e,t),n)},useLayoutEffect:function(t,e){return Nd(4194308,4,t,e)},useInsertionEffect:function(t,e){return Nd(4,2,t,e)},useMemo:function(t,e){var n=di();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var i=di();return e=n!==void 0?n(e):e,i.memoizedState=i.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},i.queue=t,t=t.dispatch=CA.bind(null,Me,t),[i.memoizedState,t]},useRef:function(t){var e=di();return t={current:t},e.memoizedState=t},useState:W0,useDebugValue:vy,useDeferredValue:function(t){return di().memoizedState=t},useTransition:function(){var t=W0(!1),e=t[0];return t=PA.bind(null,t[1]),di().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var i=Me,r=di();if(Pe){if(n===void 0)throw Error(P(407));n=n()}else{if(n=e(),Je===null)throw Error(P(349));hs&30||bE(i,e,n)}r.memoizedState=n;var s={value:n,getSnapshot:e};return r.queue=s,K0(kE.bind(null,i,s,t),[t]),i.flags|=2048,Il(9,xE.bind(null,i,s,n,e),void 0,null),n},useId:function(){var t=di(),e=Je.identifierPrefix;if(Pe){var n=Ni,i=Ai;n=(i&~(1<<32-Gn(i)-1)).toString(32)+n,e=":"+e+"R"+n,n=Rl++,0<\/script>",t=t.removeChild(t.firstChild)):typeof i.is=="string"?t=a.createElement(n,{is:i.is}):(t=a.createElement(n),n==="select"&&(a=t,i.multiple?a.multiple=!0:i.size&&(a.size=i.size))):t=a.createElementNS(t,n),t[ui]=e,t[Tl]=i,zE(t,e,!1,!1),e.stateNode=t;e:{switch(a=ev(n,i),n){case"dialog":be("cancel",t),be("close",t),r=i;break;case"iframe":case"object":case"embed":be("load",t),r=i;break;case"video":case"audio":for(r=0;rEa&&(e.flags|=128,i=!0,Jo(s,!1),e.lanes=4194304)}else{if(!i)if(t=Qd(a),t!==null){if(e.flags|=128,i=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),Jo(s,!0),s.tail===null&&s.tailMode==="hidden"&&!a.alternate&&!Ce)return mt(e),null}else 2*Ve()-s.renderingStartTime>Ea&&n!==1073741824&&(e.flags|=128,i=!0,Jo(s,!1),e.lanes=4194304);s.isBackwards?(a.sibling=e.child,e.child=a):(n=s.last,n!==null?n.sibling=a:e.child=a,s.last=a)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Ve(),e.sibling=null,n=Me.current,ge(Me,i?n&1|2:n&1),e):(mt(e),null);case 22:case 23:return yy(),i=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==i&&(e.flags|=8192),i&&e.mode&1?Jt&1073741824&&(mt(e),e.subtreeFlags&6&&(e.flags|=8192)):mt(e),null;case 24:return null;case 25:return null}throw Error(P(156,e.tag))}function RA(t,e){switch(Zv(e),e.tag){case 1:return Ut(e.type)&&qd(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return xa(),xe(zt),xe(vt),oy(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return ay(e),null;case 13:if(xe(Me),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(P(340));wa()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return xe(Me),null;case 4:return xa(),null;case 10:return ny(e.type._context),null;case 22:case 23:return yy(),null;case 24:return null;default:return null}}var xd=!1,gt=!1,LA=typeof WeakSet=="function"?WeakSet:Set,A=null;function ua(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(i){Oe(t,e,i)}else n.current=null}function Pv(t,e,n){try{n()}catch(i){Oe(t,e,i)}}var Q0=!1;function IA(t,e){if(uv=Fd,t=Wk(),Qv(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var r=i.anchorOffset,s=i.focusNode;i=i.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var a=0,o=-1,l=-1,c=0,u=0,d=t,p=null;t:for(;;){for(var h;d!==n||r!==0&&d.nodeType!==3||(o=a+r),d!==s||i!==0&&d.nodeType!==3||(l=a+i),d.nodeType===3&&(a+=d.nodeValue.length),(h=d.firstChild)!==null;)p=d,d=h;for(;;){if(d===t)break t;if(p===n&&++c===r&&(o=a),p===s&&++u===i&&(l=a),(h=d.nextSibling)!==null)break;d=p,p=d.parentNode}d=h}n=o===-1||l===-1?null:{start:o,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(dv={focusedElem:t,selectionRange:n},Fd=!1,A=e;A!==null;)if(e=A,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,A=t;else for(;A!==null;){e=A;try{var y=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var v=y.memoizedProps,_=y.memoizedState,m=e.stateNode,f=m.getSnapshotBeforeUpdate(e.elementType===e.type?v:Bn(e.type,v),_);m.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var g=e.stateNode.containerInfo;g.nodeType===1?g.textContent="":g.nodeType===9&&g.documentElement&&g.removeChild(g.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(P(163))}}catch(x){Oe(e,e.return,x)}if(t=e.sibling,t!==null){t.return=e.return,A=t;break}A=e.return}return y=Q0,Q0=!1,y}function pl(t,e,n){var i=e.updateQueue;if(i=i!==null?i.lastEffect:null,i!==null){var r=i=i.next;do{if((r.tag&t)===t){var s=r.destroy;r.destroy=void 0,s!==void 0&&Pv(e,n,s)}r=r.next}while(r!==i)}}function pp(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var i=n.create;n.destroy=i()}n=n.next}while(n!==e)}}function Cv(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function qE(t){var e=t.alternate;e!==null&&(t.alternate=null,qE(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[ui],delete e[Tl],delete e[fv],delete e[mA],delete e[gA])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function HE(t){return t.tag===5||t.tag===3||t.tag===4}function X0(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||HE(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function $v(t,e,n){var i=t.tag;if(i===5||i===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=jd));else if(i!==4&&(t=t.child,t!==null))for($v(t,e,n),t=t.sibling;t!==null;)$v(t,e,n),t=t.sibling}function Mv(t,e,n){var i=t.tag;if(i===5||i===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(i!==4&&(t=t.child,t!==null))for(Mv(t,e,n),t=t.sibling;t!==null;)Mv(t,e,n),t=t.sibling}var st=null,Wn=!1;function lr(t,e,n){for(n=n.child;n!==null;)BE(t,e,n),n=n.sibling}function BE(t,e,n){if(di&&typeof di.onCommitFiberUnmount=="function")try{di.onCommitFiberUnmount(rp,n)}catch{}switch(n.tag){case 5:gt||ua(n,e);case 6:var i=st,r=Wn;st=null,lr(t,e,n),st=i,Wn=r,st!==null&&(Wn?(t=st,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):st.removeChild(n.stateNode));break;case 18:st!==null&&(Wn?(t=st,n=n.stateNode,t.nodeType===8?Ig(t.parentNode,n):t.nodeType===1&&Ig(t,n),wl(t)):Ig(st,n.stateNode));break;case 4:i=st,r=Wn,st=n.stateNode.containerInfo,Wn=!0,lr(t,e,n),st=i,Wn=r;break;case 0:case 11:case 14:case 15:if(!gt&&(i=n.updateQueue,i!==null&&(i=i.lastEffect,i!==null))){r=i=i.next;do{var s=r,a=s.destroy;s=s.tag,a!==void 0&&(s&2||s&4)&&Pv(n,e,a),r=r.next}while(r!==i)}lr(t,e,n);break;case 1:if(!gt&&(ua(n,e),i=n.stateNode,typeof i.componentWillUnmount=="function"))try{i.props=n.memoizedProps,i.state=n.memoizedState,i.componentWillUnmount()}catch(o){Oe(n,e,o)}lr(t,e,n);break;case 21:lr(t,e,n);break;case 22:n.mode&1?(gt=(i=gt)||n.memoizedState!==null,lr(t,e,n),gt=i):lr(t,e,n);break;default:lr(t,e,n)}}function Z0(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new LA),e.forEach(function(i){var r=jA.bind(null,t,i);n.has(i)||(n.add(i),i.then(r,r))})}}function Hn(t,e){var n=e.deletions;if(n!==null)for(var i=0;ir&&(r=a),i&=~s}if(i=r,i=Ve()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*NA(i/1960))-i,10t?16:t,fr===null)var i=!1;else{if(t=fr,fr=null,tp=0,se&6)throw Error(P(331));var r=se;for(se|=4,A=t.current;A!==null;){var s=A,a=s.child;if(A.flags&16){var o=s.deletions;if(o!==null){for(var l=0;lVe()-gy?as(t,0):my|=n),jt(t,e)}function JE(t,e){e===0&&(t.mode&1?(e=cd,cd<<=1,!(cd&130023424)&&(cd=4194304)):e=1);var n=St();t=Vi(t,e),t!==null&&(Ll(t,e,n),jt(t,n))}function UA(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),JE(t,n)}function jA(t,e){var n=0;switch(t.tag){case 13:var i=t.stateNode,r=t.memoizedState;r!==null&&(n=r.retryLane);break;case 19:i=t.stateNode;break;default:throw Error(P(314))}i!==null&&i.delete(e),JE(t,n)}var eT;eT=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||zt.current)Ft=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return Ft=!1,$A(t,e,n);Ft=!!(t.flags&131072)}else Ft=!1,Ce&&e.flags&1048576&&iE(e,Wd,e.index);switch(e.lanes=0,e.tag){case 2:var i=e.type;Md(t,e),t=e.pendingProps;var r=_a(e,vt.current);ga(e,n),r=cy(null,e,i,t,r,n);var s=uy();return e.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Ut(i)?(s=!0,Hd(e)):s=!1,e.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,ry(e),r.updater=up,e.stateNode=r,r._reactInternals=e,wv(e,i,t,n),e=kv(null,e,i,!0,s,n)):(e.tag=0,Ce&&s&&Xv(e),Tt(null,e,r,n),e=e.child),e;case 16:i=e.elementType;e:{switch(Md(t,e),t=e.pendingProps,r=i._init,i=r(i._payload),e.type=i,r=e.tag=HA(i),t=Bn(i,t),r){case 0:e=xv(null,e,i,t,n);break e;case 1:e=K0(null,e,i,t,n);break e;case 11:e=B0(null,e,i,t,n);break e;case 14:e=W0(null,e,i,Bn(i.type,t),n);break e}throw Error(P(306,i,""))}return e;case 0:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Bn(i,r),xv(t,e,i,r,n);case 1:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Bn(i,r),K0(t,e,i,r,n);case 3:e:{if(OE(e),t===null)throw Error(P(387));i=e.pendingProps,s=e.memoizedState,r=s.element,oE(t,e),Yd(e,i,null,n);var a=e.memoizedState;if(i=a.element,s.isDehydrated)if(s={element:i,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){r=ka(Error(P(423)),e),e=G0(t,e,i,n,r);break e}else if(i!==r){r=ka(Error(P(424)),e),e=G0(t,e,i,n,r);break e}else for(en=yr(e.stateNode.containerInfo.firstChild),tn=e,Ce=!0,Kn=null,n=dE(e,null,i,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(wa(),i===r){e=Fi(t,e,n);break e}Tt(t,e,i,n)}e=e.child}return e;case 5:return pE(e),t===null&&vv(e),i=e.type,r=e.pendingProps,s=t!==null?t.memoizedProps:null,a=r.children,pv(i,r)?a=null:s!==null&&pv(i,s)&&(e.flags|=32),DE(t,e),Tt(t,e,a,n),e.child;case 6:return t===null&&vv(e),null;case 13:return VE(t,e,n);case 4:return sy(e,e.stateNode.containerInfo),i=e.pendingProps,t===null?e.child=ba(e,null,i,n):Tt(t,e,i,n),e.child;case 11:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Bn(i,r),B0(t,e,i,r,n);case 7:return Tt(t,e,e.pendingProps,n),e.child;case 8:return Tt(t,e,e.pendingProps.children,n),e.child;case 12:return Tt(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(i=e.type._context,r=e.pendingProps,s=e.memoizedProps,a=r.value,ge(Kd,i._currentValue),i._currentValue=a,s!==null)if(Qn(s.value,a)){if(s.children===r.children&&!zt.current){e=Fi(t,e,n);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var o=s.dependencies;if(o!==null){a=s.child;for(var l=o.firstContext;l!==null;){if(l.context===i){if(s.tag===1){l=Ni(-1,n&-n),l.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var u=c.pending;u===null?l.next=l:(l.next=u.next,u.next=l),c.pending=l}}s.lanes|=n,l=s.alternate,l!==null&&(l.lanes|=n),yv(s.return,n,e),o.lanes|=n;break}l=l.next}}else if(s.tag===10)a=s.type===e.type?null:s.child;else if(s.tag===18){if(a=s.return,a===null)throw Error(P(341));a.lanes|=n,o=a.alternate,o!==null&&(o.lanes|=n),yv(a,n,e),a=s.sibling}else a=s.child;if(a!==null)a.return=s;else for(a=s;a!==null;){if(a===e){a=null;break}if(s=a.sibling,s!==null){s.return=a.return,a=s;break}a=a.return}s=a}Tt(t,e,r.children,n),e=e.child}return e;case 9:return r=e.type,i=e.pendingProps.children,ga(e,n),r=bn(r),i=i(r),e.flags|=1,Tt(t,e,i,n),e.child;case 14:return i=e.type,r=Bn(i,e.pendingProps),r=Bn(i.type,r),W0(t,e,i,r,n);case 15:return AE(t,e,e.type,e.pendingProps,n);case 17:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Bn(i,r),Md(t,e),e.tag=1,Ut(i)?(t=!0,Hd(e)):t=!1,ga(e,n),cE(e,i,r),wv(e,i,r,n),kv(null,e,i,!0,t,n);case 19:return FE(t,e,n);case 22:return NE(t,e,n)}throw Error(P(156,e.tag))};function tT(t,e){return Pk(t,e)}function qA(t,e,n,i){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function _n(t,e,n,i){return new qA(t,e,n,i)}function wy(t){return t=t.prototype,!(!t||!t.isReactComponent)}function HA(t){if(typeof t=="function")return wy(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Fv)return 11;if(t===zv)return 14}return 2}function xr(t,e){var n=t.alternate;return n===null?(n=_n(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function Id(t,e,n,i,r,s){var a=2;if(i=t,typeof t=="function")wy(t)&&(a=1);else if(typeof t=="string")a=5;else e:switch(t){case ta:return os(n.children,r,s,e);case Vv:a=8,r|=8;break;case Hg:return t=_n(12,n,e,r|2),t.elementType=Hg,t.lanes=s,t;case Bg:return t=_n(13,n,e,r),t.elementType=Bg,t.lanes=s,t;case Wg:return t=_n(19,n,e,r),t.elementType=Wg,t.lanes=s,t;case uk:return fp(n,r,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case lk:a=10;break e;case ck:a=9;break e;case Fv:a=11;break e;case zv:a=14;break e;case cr:a=16,i=null;break e}throw Error(P(130,t==null?t:typeof t,""))}return e=_n(a,n,e,r),e.elementType=t,e.type=i,e.lanes=s,e}function os(t,e,n,i){return t=_n(7,t,i,e),t.lanes=n,t}function fp(t,e,n,i){return t=_n(22,t,i,e),t.elementType=uk,t.lanes=n,t.stateNode={isHidden:!1},t}function Ug(t,e,n){return t=_n(6,t,null,e),t.lanes=n,t}function jg(t,e,n){return e=_n(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function BA(t,e,n,i,r){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Tg(0),this.expirationTimes=Tg(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Tg(0),this.identifierPrefix=i,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function by(t,e,n,i,r,s,a,o,l){return t=new BA(t,e,n,o,l),e===1?(e=1,s===!0&&(e|=8)):e=0,s=_n(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:i,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},ry(s),t}function WA(t,e,n){var i=3{"use strict";function aT(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(aT)}catch(t){console.error(t)}}aT(),oT.exports=sT()});var Ol=dt(Ty=>{"use strict";var lT=Dl();Ty.createRoot=lT.createRoot,Ty.hydrateRoot=lT.hydrateRoot;var hz});var pT=dt(dT=>{"use strict";var Pa=z();function XA(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var ZA=typeof Object.is=="function"?Object.is:XA,JA=Pa.useState,eN=Pa.useEffect,tN=Pa.useLayoutEffect,nN=Pa.useDebugValue;function iN(t,e){var n=e(),i=JA({inst:{value:n,getSnapshot:e}}),r=i[0].inst,s=i[1];return tN(function(){r.value=n,r.getSnapshot=e,Sy(r)&&s({inst:r})},[t,n,e]),eN(function(){return Sy(r)&&s({inst:r}),t(function(){Sy(r)&&s({inst:r})})},[t]),nN(n),n}function Sy(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!ZA(t,n)}catch{return!0}}function rN(t,e){return e()}var sN=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?rN:iN;dT.useSyncExternalStore=Pa.useSyncExternalStore!==void 0?Pa.useSyncExternalStore:sN});var fT=dt((vz,hT)=>{"use strict";hT.exports=pT()});var gT=dt(mT=>{"use strict";var wp=z(),aN=fT();function oN(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var lN=typeof Object.is=="function"?Object.is:oN,cN=aN.useSyncExternalStore,uN=wp.useRef,dN=wp.useEffect,pN=wp.useMemo,hN=wp.useDebugValue;mT.useSyncExternalStoreWithSelector=function(t,e,n,i,r){var s=uN(null);if(s.current===null){var a={hasValue:!1,value:null};s.current=a}else a=s.current;s=pN(function(){function l(h){if(!c){if(c=!0,u=h,h=i(h),r!==void 0&&a.hasValue){var y=a.value;if(r(y,h))return d=y}return d=h}if(y=d,lN(u,h))return y;var v=i(h);return r!==void 0&&r(y,v)?y:(u=h,d=v)}var c=!1,u,d,p=n===void 0?null:n;return[function(){return l(e())},p===null?void 0:function(){return l(p())}]},[e,n,i,r]);var o=cN(t,s[0],s[1]);return dN(function(){a.hasValue=!0,a.value=o},[o]),hN(o),o}});var yT=dt((_z,vT)=>{"use strict";vT.exports=gT()});function xN(){Cp=!0,queueMicrotask(DT)}function DT(){if(!Ca.length){Cp=!1;return}Ly=!0;for(let t=0;t=0;n--)By(e[n])}function OT(t){let e=$t();return Hl(e,t.length?t.bind(null,ql.bind(e)):t,null)}function C(t){return Hl(Ct,t,null)}function La(t){return Hl(null,t,null)}function Zn(){Ly||DT()}function jl(){return Ct}function et(t,e){try{return Hl(e,t,null)}catch(n){zy(e,n);return}}function Fy(t,e=Ct){return e?.$cx[t]}function EN(t,e,n=Ct){n&&(n.$cx={...n.$cx,[t]:e})}function TN(t){Ct&&(Ct.$eh=Ct.$eh?[t,...Ct.$eh]:[t])}function G(t){if(!t||!Ct)return t||bN;let e=Ct;return e.$d?Array.isArray(e.$d)?e.$d.push(t):e.$d=[e.$d,t]:e.$d=t,function(){e.$st!==Rp&&(t.call(null),Lp(e.$d)?e.$d=null:Array.isArray(e.$d)&&e.$d.splice(e.$d.indexOf(t),1))}}function ql(t=!0){if(this.$st===Rp)return;let e=t?this.$ps||this[on]:this,n=this.$ns,i=null;for(;n&&n[on]===this;)ql.call(n,!0),$T(n),i=n.$ns,n.$ns=null,n=i;t&&$T(this),n&&(n.$ps=t?this.$ps:this),e&&(e.$ns=n)}function $T(t){t.$st=Rp,t.$d&&VT(t),t.$s&&Sp(t,0),t.$ps&&(t.$ps.$ns=null),t[on]=null,t.$s=null,t.$o=null,t.$ps=null,t.$cx=Vy,t.$eh=null}function VT(t){try{if(Array.isArray(t.$d))for(let e=t.$d.length-1;e>=0;e--){let n=t.$d[e];n.call(n)}else t.$d.call(t.$d);t.$d=null}catch(e){zy(t,e)}}function Hl(t,e,n){let i=Ct,r=$a;Ct=t,$a=n;try{return e.call(t)}finally{Ct=i,$a=r}}function zy(t,e){if(!t||!t.$eh)throw e;let n=0,i=t.$eh.length,r=MT(e);for(n=0;n0){t.$s.length=an+En.length;for(let s=0;s=e)&&(t.$e&&t.$st===Ra&&(Ca.push(t),Cp||xN()),t.$st=e,t.$o))for(let n=0;nt();return e[on]=!0,e}function Wy(t){return qT(t)&&"set"in t}function Ht(...t){}function fi(t){return t===null}function Ie(t){return typeof t>"u"}function Ky(t){return fi(t)||Ie(t)}function Bl(t){return t?.constructor===Object}function Be(t){return typeof t=="number"&&!Number.isNaN(t)}function F(t){return typeof t=="string"}function Gy(t){return typeof t=="boolean"}function yt(t){return typeof t=="function"}function He(t){return Array.isArray(t)}function CN(t){return F(t)?new RegExp(t):t}function $N(t){return qt?!1:t===window}function MN(t,e){return typeof process<"u",Ht}function Ip(t){return!!t?.[WT]}function LN(t){return t.originEvent}function KT(t,e){if(Ip(t))return t.triggers.walk(e)}function Yy(t,e){return Ip(t)?t.triggers.findType(e):void 0}function GT(t,e){return!!Yy(t,e)}function YT(t,e){e&&t.triggers.add(e)}function S(t,e,n,i){return qt?Ht:(t.addEventListener(e,n,i),G(()=>t.removeEventListener(e,n,i)))}function Wl(t){return!!t?.type.startsWith("pointer")}function Ia(t){return!!t?.type.startsWith("touch")}function Qy(t){return/^(click|mouse)/.test(t?.type??"")}function ji(t){return!!t?.type.startsWith("key")}function IN(t){return ji(t)&&t.key==="Enter"}function AN(t){return ji(t)&&t.key==="Escape"}function Kl(t){return ji(t)&&(t.key==="Enter"||t.key===" ")}function Xy(t){return t instanceof Node}function NN(t){return Xy(t)&&t.nodeType===1}function DN(t){return Xy(t)&&t.nodeType===11}function ON(){return document.createDocumentFragment()}function VN(t){return qt?t:document.createComment(t)}function Z(t,e,n){if(t)if(!n&&n!==""&&n!==0)t.removeAttribute(e);else{let i=n===!0?"":n+"";t.getAttribute(e)!==i&&t.setAttribute(e,i)}else return}function lt(t,e,n){if(t)!n&&n!==0?t.style.removeProperty(e):t.style.setProperty(e,n+"");else return}function FN(t,e,n){t.classList[n?"add":"remove"](e)}function zN(t,e){let n=e?`slot[name="${e}"]`:"slot:not([name])",r=t.shadowRoot?.querySelector(n)?.assignedNodes({flatten:!0})??[];return Array.prototype.filter.call(r,s=>s.nodeType==1)}function UN(t){let e=t.firstChild,n=e.getAttribute("shadowroot");e.parentNode.attachShadow({mode:n}).appendChild(e.content),e.remove()}function jN(t){return yt(t)?t():t}function Iy(t){let e=t;for(;typeof e=="function";)e=e.call(this);return e}function mi(t){return{id:Symbol(),provide:t}}function Rt(t,e,n=jl()){let i=!Ie(e);EN(t.id,i?e:t.provide?.(),n)}function Ae(t){return Fy(t.id)}function Tn(t){return!Ie(Fy(t.id))}function qN(t){let e={};for(let n of Object.keys(t)){let i=t[n];e[n]=D(i,i)}return e}function Zy(t,e){return OT(()=>{zl.$$=new Mp(t,jl(),e);let n=new t;return zl.$$.e=n,zl.$$=null,n})}function ee(t,e,n){t[$y]||(t[$y]=new Set),t[$y].add(e)}function Ne(t,e,n){t[My]||(t[My]=new Set),t[My].add(e)}function gs(t){return Ae(t)}function Aa(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function HN(t){return Gl(t.replace(/([A-Z])/g," $1"))}function Np(t){return t.replace(/-./g,e=>e[1].toUpperCase())}function XT(t){return ZT(t).replace(/\s/g,"")}function ZT(t){return Gl(t.replace(/-./g,e=>" "+e[1].toUpperCase()))}function Gl(t){return t.charAt(0).toUpperCase()+t.slice(1)}function BN(t){return t.charAt(0).toLowerCase()+t.slice(1)}function KN(t){return t.replace(WN,"")}function Dp(t,...e){return ce.createElement(vs.Provider,{value:t},...e)}function Op(){return ce.useContext(vs).current}function Vp(t){let e=Op();return ce.useMemo(()=>Fy(t.id,e),[e])}function GN(){return eS}function YN(t,e){var n;return n=class extends eS{},n.F=t,n.T=e,n}function Jy(t,e){typeof t=="function"?t(e):t&&(t.current=e)}function re(...t){return e=>t.forEach(n=>Jy(n,e))}function QN(t,e){let n=ce.forwardRef((i,r)=>{let s=ce.useContext(vs),a=ce.useRef(null),o=ce.useRef();if(!o.current){let _=ZN(),m=AT(t,_,i,s.current);_.e=m,o.current=_,a.current=m.scope}function l(){let _=o.current,m=s.current;if(window.cancelAnimationFrame(_.ea),_.ea=-1,_.e.$$.o){let f=AT(t,_,i,m);_.e=f,_.Q=!1,_.da=!1,a.current=f.scope}return _.a&&IT(_,_.a),_.da||(Jy(r,_.e),_.da=!0),()=>Pp(_)}function c(_){let m=o.current;if(!m.da){m.a=_;return}window.cancelAnimationFrame(m.K),m.K=window.requestAnimationFrame(()=>{let f=o.current;f.K=-1,f.a!==_&&(Pp(f),_&&IT(f,_),f.a=_)})}ce.useEffect(()=>{let _=o.current;return window.cancelAnimationFrame(_.ea),_.ea=-1,function(){yt(i.children)&&(window.cancelAnimationFrame(_.K),_.K=-1,window.cancelAnimationFrame(_.E),_.E=-1,window.cancelAnimationFrame(_.ea),_.ea=window.requestAnimationFrame(()=>{_.ea=-1,Pp(_),_.e.$$.p(),_.e.$$[Ap]=null,_.J={},_._={},a.current=null}))}},[]),ce.useEffect(Zn);let u=o.current,{children:d,...p}=i,h={},y=u.aa,v=Object.keys(p);u.J={};for(let _ of[...y,...v])if(e.props.has(_))u.e.$props[_].set(v.includes(_)?p[_]:t.props?.[_]);else if(e.events?.has(_)||e.eventsRE?.test(_))u.J[_]=p[_];else if(e.domEvents?.has(_)||e.domEventsRE?.test(_)){let m=Aa(_.slice(2));u._[m]=p[_],v.includes(_)?u.a&&!u.ca?.has(m)&&(u.ca||(u.ca=new Set),u.ca.add(m),u.a.addEventListener(m,u.ba)):(u.a?.removeEventListener(m,u.ba),u.ca?.delete(m))}else h[_]=p[_];return u.aa=v,Dp(a,ce.createElement(XN,{effect:l}),yt(d)?d?.({...h,suppressHydrationWarning:!0,ref:c},u.e):d)});return n.displayName=t.name+"Bridge",n}function XN({effect:t}){return ce.useEffect(t,[]),null}function ZN(){let t={a:null,aa:[],J:{},_:{},K:-1,E:-1,ea:-1,Q:!1,da:!1,ca:null,ba(e){let n=Ie(e.detail)?[e]:[e.detail,e];t._[e.type]?.(...n)}};return t}function IT(t,e){if(!(t.a===e&&t.Q)){if(t.Q&&Pp(t),t._){t.ca||(t.ca=new Set);for(let n of Object.keys(t._))t.ca.has(n)||(e.addEventListener(n,t.ba),t.ca.add(n))}t.e.$$.x(e),t.E=window.requestAnimationFrame(()=>{t.e.$$.y(),t.E=-1}),t.Q=!0}}function Pp(t){if(t.Q&&(window.cancelAnimationFrame(t.E),t.E=-1,t.e.$$.s(),t.Q=!1,t.a&&t.ca)){for(let e of t.ca)t.a.removeEventListener(e,t.ba);t.ca.clear()}}function JN(t){let e=LT.get(t.type),n=Ie(t.detail)?[t]:[t.detail,t];e||LT.set(t.type,e=`on${XT(t.type)}`),this.J[e]?.(...n)}function AT(t,e,n,i){let r=Zy(t,{props:n,scope:i});return r.$$[Ap]=JN.bind(e),r.$$.w(),r}function tS(t,e=!1){let n=typeof t;if(n!=="string")return!e&&n==="function"?tS(t()):e&&n==="boolean"?t+"":t;let i=e?'"':"<",r=e?""":"<",s=t.indexOf(i),a=t.indexOf("&");if(s<0&&a<0)return t;let o=0,l="";for(;s>=0&&a>=0;)s=0)do o=0);else for(;a>=0;)o(a.destroy(),null)))}return n.displayName=t.name+"Bridge",n}function $r(t){return Vp(t)}function pe(t,e){let[,n]=ce.useState();return ce.useEffect(()=>HT(()=>{t(),n({})}),[e??t]),t()}function Na(t){return t?"true":"false"}function nS(t){let e=[];for(let n=0;n!e.includes(n)))}function qi(){let t,e;return{promise:new Promise((i,r)=>{t=i,e=r}),resolve:t,reject:e}}function p2(t,e,n){let i=new Promise((r,s)=>{let a=setTimeout(()=>{clearTimeout(a),s(n)},e)});return Promise.race([t,i])}function t_(t){return new Promise(e=>setTimeout(e,t))}function h2(t){return qt?Promise.resolve():new Promise(e=>{window.requestAnimationFrame(n=>{t?.(n),e()})})}function Mr(t){if(qt)return Ht;let e=-1,n;function i(...r){n=r,!(e>=0)&&(e=window.requestAnimationFrame(()=>{t.apply(this,n),e=-1,n=void 0}))}return i}function n_(t,e){return qt?Promise.resolve():new Promise(n=>{f2(i=>{t?.(i),n()},e)})}function i_(t){let[,e]=ce.useState(),n=ce.useRef(null);return n.current==null&&(n.current={state:{},$update:D({}),props:new Set}),ce.useEffect(()=>{let{state:i,$update:r,props:s}=n.current;return b(()=>{for(let a of s){let o=t[a]();i[a]=He(o)?[...o]:o}r(),e({})})},[t]),ce.useMemo(()=>{let{state:i,$update:r,props:s}=n.current,a=!1;return s.clear(),new Proxy(i,{get(o,l){if(!s.has(l)&&l in t){s.add(l);let c=t[l]();i[l]=He(c)?[...c]:c,a||(r.set({}),a=!0,queueMicrotask(()=>a=!1))}return i[l]},set(o,l,c){return l in t||(i[l]=c),!0}})},[t])}function X(t,e){return qt?o2(t,{props:new Set(Object.keys(t.props||{}))}):QN(t,{props:new Set(Object.keys(t.props||{})),events:new Set(e?.events),eventsRE:e?.eventsRegex,domEvents:e?.domEvents,domEventsRE:e?.domEventsRegex})}var ce,qt,on,Cp,Ly,Ct,$a,En,an,Ca,Vy,bN,Ra,NT,Ul,Rp,jy,ms,zT,qy,b,BT,RN,WT,j,$p,Ma,$y,My,Ap,QT,Ry,Mp,zl,Mt,H,Xn,WN,vs,JT,eS,LT,e2,t2,i2,r2,Ay,Ny,Dy,Oy,a2,f2,ys,Lt=Ue(()=>{"use strict";"use client";ce=$(z(),1),qt=typeof document>"u",on=Symbol(0),Cp=!1,Ly=!1,Ct=null,$a=null,En=null,an=0,Ca=[],Vy={},bN=()=>{},Ra=0,NT=1,Ul=2,Rp=3;jy=function(){this[on]=null,this.$ns=null,this.$ps=null,Ct&&Ct.append(this)},ms=jy.prototype;ms.$cx=Vy;ms.$eh=null;ms.$c=null;ms.$d=null;ms.append=function(t){if(t[on]=this,t.$ps=this,this.$ns)if(t.$ns){let e=t.$ns;for(;e.$ns;)e=e.$ns;e.$ns=this.$ns,this.$ns.$ps=e}else t.$ns=this.$ns,this.$ns.$ps=t;this.$ns=t,t.$cx=t.$cx===Vy?this.$cx:{...this.$cx,...t.$cx},this.$eh&&(t.$eh=t.$eh?[...t.$eh,...this.$eh]:this.$eh)};ms.dispose=function(){ql.call(this)};zT=function(e,n,i){jy.call(this),this.$st=n?Ul:Ra,this.$i=!1,this.$e=!1,this.$s=null,this.$o=null,this.$v=e,n&&(this.$c=n),i&&i.dirty&&(this.$ch=i.dirty)},qy=zT.prototype;Object.setPrototypeOf(qy,ms);qy.$ch=SN;qy.call=Uy;b=qt?MN:HT;RN=qt?class{}:Event,WT=Symbol("DOM_EVENT"),j=class extends RN{constructor(e,...n){super(e,n[0]),this[BT]=!0,this.triggers=new $p,this.detail=n[0]?.detail;let i=n[0]?.trigger;i&&this.triggers.add(i)}get trigger(){return this.triggers.source}get originEvent(){return this.triggers.origin}get isOriginTrusted(){return this.triggers.origin?.isTrusted??!1}};BT=WT;$p=class{constructor(){this.chain=[]}get source(){return this.chain[0]}get origin(){return this.chain[this.chain.length-1]}add(e){this.chain.push(e),Ip(e)&&this.chain.push(...e.triggers)}remove(e){return this.chain.splice(this.chain.indexOf(e),1)[0]}has(e){return this.chain.some(n=>n===e)}hasType(e){return!!this.findType(e)}findType(e){return this.chain.find(n=>n.type===e)}walk(e){for(let n of this.chain){let i=e(n);if(i)return[n,i]}}[Symbol.iterator](){return this.chain.values()}};Ma=class extends EventTarget{addEventListener(e,n,i){return super.addEventListener(e,n,i)}removeEventListener(e,n,i){return super.removeEventListener(e,n,i)}};$y=Symbol(0),My=Symbol(0),Ap=Symbol(0),Ry={},Mp=class{constructor(e,n,i){this[QT]=null,this.$el=D(null),this.a=null,this.d=null,this.f=null,this.g=null,this.e=null,this.o=!1,this.i=Ry,this.b=null,this.c=null,this.l=[],this.m=[],this.j=[],this.n=[],this.d=n,i?.scope&&i.scope.append(n);let r=e.state,s=e.props;if(r&&(this.h=r.create(),this.k=new Proxy(this.h,{get:(a,o)=>this.h[o]()}),Rt(r,this.h)),s&&(this.i=qN(s),i?.props))for(let a of Object.keys(i.props))this.i[a]?.set(i.props[a]);G(this.p.bind(this))}w(){et(()=>{for(let e of this.l)e()},this.d)}x(e){this.a||(this.a=e,this.$el.set(e),et(()=>{this.f=$t(),et(()=>{for(let n of this.m)n(this.a);this.q(),this.r()},this.f)},this.d),e.dispatchEvent(new Event("attached")))}s(){this.f?.dispose(),this.f=null,this.g=null,this.a=null,this.$el.set(null)}y(){!this.a||!this.f||!this.j.length||et(()=>{this.g=$t(),et(()=>{for(let e of this.j)e(this.a)},this.g)},this.f)}z(){this.g?.dispose(),this.g=null}p(){if(this.o)return;this.o=!0,et(()=>{for(let n of this.n)n(this.a)},this.d);let e=this.a;this.s(),this.d.dispose(),this.l.length=0,this.m.length=0,this.j.length=0,this.n.length=0,this.e=null,this.b=null,this.c=null,this.i=Ry,this.d=null,this.k=Ry,this.h=null,e&&delete e.$}t(e){e.onSetup&&this.l.push(e.onSetup.bind(e)),e.onAttach&&this.m.push(e.onAttach.bind(e)),e.onConnect&&this.j.push(e.onConnect.bind(e)),e.onDestroy&&this.n.push(e.onDestroy.bind(e))}q(){if(this.b)for(let e of Object.keys(this.b))qt?Z(this.a,e,Iy.call(this.e,this.b[e])):yt(this.b[e])?b(this.u.bind(this,e)):Z(this.a,e,this.b[e])}r(){if(this.c)for(let e of Object.keys(this.c))qt?lt(this.a,e,Iy.call(this.e,this.c[e])):yt(this.c[e])?b(this.v.bind(this,e)):lt(this.a,e,this.c[e])}u(e){Z(this.a,e,this.b[e].call(this.e))}v(e){lt(this.a,e,this.c[e].call(this.e))}};QT=Ap;zl={$$:null};Mt=class extends EventTarget{constructor(){super(),zl.$$&&this.attach(zl)}get el(){return this.$$.a}get $el(){return this.$$.$el()}get scope(){return this.$$.d}get attachScope(){return this.$$.f}get connectScope(){return this.$$.g}get $props(){return this.$$.i}get $state(){return this.$$.h}get state(){return this.$$.k}attach({$$:e}){return this.$$=e,e.t(this),this}addEventListener(e,n,i){this.listen(e,n,i)}removeEventListener(e,n,i){this.el?.removeEventListener(e,n,i)}setAttributes(e){this.$$.b||(this.$$.b={}),Object.assign(this.$$.b,e)}setStyles(e){this.$$.c||(this.$$.c={}),Object.assign(this.$$.c,e)}setCSSVars(e){this.setStyles(e)}createEvent(e,...n){return new j(e,n[0])}dispatch(e,...n){if(qt||!this.el)return!1;let i=e instanceof Event?e:new j(e,n[0]);return Object.defineProperty(i,"target",{get:()=>this.$$.e}),La(()=>(this.$$[Ap]?.(i),this.el.dispatchEvent(i)))}dispatchEvent(e){return this.dispatch(e)}listen(e,n,i){return qt||!this.el?Ht:S(this.el,e,n,i)}},H=class extends Mt{subscribe(e){return et(()=>b(()=>e(this.state)),this.$$.d)}destroy(){this.$$.p()}};Xn=class{constructor(e){this.id=Symbol(0),this.record=e,this.A=Object.getOwnPropertyDescriptors(e)}create(){let e={},n=new Proxy(e,{get:(i,r)=>e[r]()});for(let i of Object.keys(this.record)){let r=this.A[i].get;e[i]=r?hi(r.bind(n)):D(this.record[i])}return e}reset(e,n){for(let i of Object.keys(e))!this.A[i].get&&(!n||n(i))&&e[i].set(this.record[i])}};WN=/;\s*$/;vs=ce.createContext({current:null});vs.displayName="Scope";JT=class extends ce.Component{constructor(e,n){super(e),this.d={current:$t()},n&&n.append(this.d.current);let i=this.constructor;i.F&&Rt(i.F,i.T?.(),this.d.current)}render(){return Dp(this.d,this.props?.children)}};JT.contextType=vs;eS=JT;LT=new Map;e2=Symbol(0),t2=/\s+/;i2=/\s*:\s*/,r2=/\s*;\s*/;Ay=class{constructor(e){this.keepAlive=!1,this.forwardKeepAlive=!0,this.attributes=new Ny,this.style=new Dy,this.classList=new Oy,this.$=e}get $props(){return this.$.$$.i}get $state(){return this.$.$$.h}get state(){return this.$.state}setup(){let e=this.$.$$;et(()=>{this.hasAttribute("class")&&n2(this.classList.tokens,this.getAttribute("class")),this.hasAttribute("style")&&s2(this.style.tokens,this.getAttribute("style")),e.w(),e.x(this),this.classList.length>0&&this.setAttribute("class",this.classList.toString()),this.style.length>0&&this.setAttribute("style",this.style.toString()),this.keepAlive&&this.setAttribute("keep-alive","")},e.d)}getAttribute(e){return this.attributes.getAttribute(e)}setAttribute(e,n){this.attributes.setAttribute(e,n)}hasAttribute(e){return this.attributes.hasAttribute(e)}removeAttribute(e){return this.attributes.removeAttribute(e)}[e2](){}addEventListener(){}removeEventListener(){}dispatchEvent(){return!1}subscribe(){return Ht}destroy(){this.$.destroy()}},Ny=class{constructor(){this.Z=new Map}get length(){return this.Z.size}get tokens(){return this.Z}getAttribute(e){return this.Z.get(e)??null}hasAttribute(e){return this.Z.has(e)}setAttribute(e,n){this.Z.set(e,n+"")}removeAttribute(e){this.Z.delete(e)}toString(){if(this.Z.size===0)return"";let e="";for(let[n,i]of this.Z)e+=` ${n}="${tS(i,!0)}"`;return e}},Dy=class{constructor(){this.Z=new Map}get length(){return this.Z.size}get tokens(){return this.Z}getPropertyValue(e){return this.Z.get(e)??""}setProperty(e,n){this.Z.set(e,n??"")}removeProperty(e){let n=this.Z.get(e);return this.Z.delete(e),n??""}toString(){if(this.Z.size===0)return"";let e="";for(let[n,i]of this.Z)e+=`${n}: ${i};`;return e}},Oy=class{constructor(){this.Z=new Set}get length(){return this.Z.size}get tokens(){return this.Z}add(...e){for(let n of e)this.Z.add(n)}contains(e){return this.Z.has(e)}remove(e){this.Z.delete(e)}replace(e,n){return this.Z.has(e)?(this.Z.delete(e),this.Z.add(n),!0):!1}toggle(e,n){return n!==!0&&(this.Z.has(e)||n===!1)?(this.Z.delete(e),!1):(this.Z.add(e),!0)}toString(){return Array.from(this.Z).join(" ")}},a2={acceptcharset:"acceptCharset","accept-charset":"acceptCharset",accesskey:"accessKey",allowfullscreen:"allowFullScreen",autocapitalize:"autoCapitalize",autocomplete:"autoComplete",autocorrect:"autoCorrect",autofocus:"autoFocus",autoplay:"autoPlay",autosave:"autoSave",cellpadding:"cellPadding",cellspacing:"cellSpacing",charset:"charSet",class:"className",classid:"classID",classname:"className",colspan:"colSpan",contenteditable:"contentEditable",contextmenu:"contextMenu",controlslist:"controlsList",crossorigin:"crossOrigin",dangerouslysetinnerhtml:"dangerouslySetInnerHTML",datetime:"dateTime",defaultchecked:"defaultChecked",defaultvalue:"defaultValue",disablepictureinpicture:"disablePictureInPicture",disableremoteplayback:"disableRemotePlayback",enctype:"encType",enterkeyhint:"enterKeyHint",fetchpriority:"fetchPriority",for:"htmlFor",formmethod:"formMethod",formaction:"formAction",formenctype:"formEncType",formnovalidate:"formNoValidate",formtarget:"formTarget",frameborder:"frameBorder",hreflang:"hrefLang",htmlfor:"htmlFor",httpequiv:"httpEquiv","http-equiv":"httpEquiv",imagesizes:"imageSizes",imagesrcset:"imageSrcSet",innerhtml:"innerHTML",inputmode:"inputMode",itemid:"itemID",itemprop:"itemProp",itemref:"itemRef",itemscope:"itemScope",itemtype:"itemType",keyparams:"keyParams",keytype:"keyType",marginwidth:"marginWidth",marginheight:"marginHeight",maxlength:"maxLength",mediagroup:"mediaGroup",minlength:"minLength",nomodule:"noModule",novalidate:"noValidate",playsinline:"playsInline",radiogroup:"radioGroup",readonly:"readOnly",referrerpolicy:"referrerPolicy",rowspan:"rowSpan",spellcheck:"spellCheck",srcdoc:"srcDoc",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex",usemap:"useMap"};f2=qt?Ht:typeof window<"u"?"requestIdleCallback"in window?window.requestIdleCallback:t=>window.setTimeout(t,1):Ht;ys=Object.freeze({__proto__:null,Component:H,DOMEvent:j,EventTriggers:$p,EventsTarget:Ma,Instance:Mp,ReactScopeContext:vs,State:Xn,ViewController:Mt,WithScope:Dp,animationFrameThrottle:Mr,appendTriggerEvent:YT,ariaBool:Na,attachDeclarativeShadowDOM:UN,camelToKebabCase:Aa,camelToTitleCase:HN,composeRefs:re,computed:hi,createComment:VN,createComponent:Zy,createContext:mi,createDisposalBin:Yl,createFragment:ON,createReactComponent:X,createReactContextProvider:YN,createReactScopeProvider:GN,createRegex:CN,createScope:$t,deferredPromise:qi,effect:b,findTriggerEvent:Yy,flattenArray:nS,getOriginEvent:LN,getScope:jl,getSlottedChildren:zN,hasProvidedContext:Tn,hasTriggerEvent:GT,isArray:He,isBoolean:Gy,isDOMElement:NN,isDOMEvent:Ip,isDOMFragment:DN,isDOMNode:Xy,isFunction:yt,isKeyboardClick:Kl,isKeyboardEvent:ji,isMouseEvent:Qy,isNil:Ky,isNull:fi,isNumber:Be,isObject:Bl,isPointerEvent:Wl,isReadSignal:qT,isString:F,isTouchEvent:Ia,isUndefined:Ie,isWindow:$N,isWriteSignal:Wy,kebabToCamelCase:Np,kebabToPascalCase:XT,kebabToTitleCase:ZT,keysOf:Ql,listenEvent:S,lowercaseFirstLetter:BN,mergeProperties:u2,method:Ne,noop:Ht,omit:d2,onDispose:G,onError:TN,peek:C,pick:iS,prop:ee,provideContext:Rt,readonly:PN,root:OT,run:l2,runAll:c2,scoped:et,setAttribute:Z,setRef:Jy,setStyle:lt,signal:D,tick:Zn,timedPromise:p2,toggleClass:FN,trimTrailingSemicolon:KN,untrack:La,unwrap:jN,unwrapDeep:Iy,uppercaseFirstChar:Gl,useContext:Ae,useDisposalBin:e_,useReactContext:Vp,useReactScope:Op,useSignal:pe,useSignalRecord:i_,useState:gs,useStateContext:$r,waitAnimationFrame:h2,waitIdlePeriod:n_,waitTimeout:t_,walkTriggerEventChain:KT,wasEnterKeyPressed:IN,wasEscapeKeyPressed:AN})});var rS={};xt(rS,{SRTParser:()=>Fp,default:()=>v2});function v2(){return new Fp}var m2,g2,Fp,sS=Ue(()=>{"use strict";Xl();m2=/,/g,g2="-->",Fp=class extends Oa{parse(e,n){if(e==="")this.a&&(this.j.push(this.a),this.f.onCue?.(this.a),this.a=null),this.c=Da.None;else if(this.c===Da.Cue)this.a.text+=(this.a.text?` -`:"")+e;else if(e.includes(g2)){let i=this.o(e,n);i&&(this.a=new Hi(i[0],i[1],i[2].join(" ")),this.a.id=this.l,this.c=Da.Cue)}this.l=e}o(e,n){return super.o(e.replace(m2,"."),n)}}});var r_={};xt(r_,{ParseErrorBuilder:()=>y2});var y2,s_=Ue(()=>{"use strict";Xl();y2={p(){return new Bt({code:Sn.BadSignature,reason:"missing WEBVTT file header",line:1})},q(t,e){return new Bt({code:Sn.BadTimestamp,reason:`cue start timestamp \`${t}\` is invalid on line ${e}`,line:e})},r(t,e){return new Bt({code:Sn.BadTimestamp,reason:`cue end timestamp \`${t}\` is invalid on line ${e}`,line:e})},s(t,e,n){return new Bt({code:Sn.BadTimestamp,reason:`cue end timestamp \`${e}\` is greater than start \`${t}\` on line ${n}`,line:n})},w(t,e,n){return new Bt({code:Sn.BadSettingValue,reason:`invalid value for cue setting \`${t}\` on line ${n} (value: ${e})`,line:n})},v(t,e,n){return new Bt({code:Sn.UnknownSetting,reason:`unknown cue setting \`${t}\` on line ${n} (value: ${e})`,line:n})},u(t,e,n){return new Bt({code:Sn.BadSettingValue,reason:`invalid value for region setting \`${t}\` on line ${n} (value: ${e})`,line:n})},t(t,e,n){return new Bt({code:Sn.UnknownSetting,reason:`unknown region setting \`${t}\` on line ${n} (value: ${e})`,line:n})},T(t,e){return new Bt({code:Sn.BadFormat,reason:`format missing for \`${t}\` block on line ${e}`,line:e})}}});var dS={};xt(dS,{SSAParser:()=>jp,default:()=>_2});function o_(t){let e=parseInt(t.replace("&H",""),16);if(e>=0){let i=(e>>24&255^255)/255,r=e>>16&255,s=e>>8&255;return"rgba("+[e&255,s,r,i].join(",")+")"}return null}function l_(t,e,n){let i=Math.ceil(2*Math.PI*t),r="";for(let s=0;s{"use strict";Xl();zp=/^Format:[\s\t]*/,aS=/^Style:[\s\t]*/,oS=/^Dialogue:[\s\t]*/,Up=/[\s\t]*,[\s\t]*/,lS=/\{[^}]+\}/g,cS=/\\N/g,uS=/^\[(.*)[\s\t]?Styles\]$/,a_=/^\[(.*)[\s\t]?Events\]$/,jp=class{constructor(){w(this,"f");w(this,"O",0);w(this,"a",null);w(this,"j",[]);w(this,"k",[]);w(this,"N",null);w(this,"d");w(this,"P",{})}async init(e){this.f=e,e.errors&&(this.d=(await Promise.resolve().then(()=>(s_(),r_))).ParseErrorBuilder)}parse(e,n){if(this.O)switch(this.O){case 1:if(e==="")this.O=0;else if(aS.test(e))if(this.N){let i=e.replace(aS,"").split(Up);this.S(i)}else this.e(this.d?.T("Style",n));else zp.test(e)?this.N=e.replace(zp,"").split(Up):a_.test(e)&&(this.N=null,this.O=2);break;case 2:if(e==="")this.Q();else if(oS.test(e))if(this.Q(),this.N){let i=e.replace(oS,"").split(Up),r=this.U(i,n);r&&(this.a=r)}else this.e(this.d?.T("Dialogue",n));else this.a?this.a.text+=` -`+e.replace(lS,"").replace(cS,` -`):zp.test(e)?this.N=e.replace(zp,"").split(Up):uS.test(e)?(this.N=null,this.O=1):a_.test(e)&&(this.N=null)}else e===""||(uS.test(e)?(this.N=null,this.O=1):a_.test(e)&&(this.N=null,this.O=2))}done(){return{metadata:{},cues:this.j,regions:[],errors:this.k}}Q(){this.a&&(this.j.push(this.a),this.f.onCue?.(this.a),this.a=null)}S(e){let n="Default",i={},r,s="center",a="bottom",o,l=1.2,c,u,d=3,p=[];for(let h=0;h=4&&(a=f>=7?"top":"center"),f%3){case 1:s="start";break;case 2:s="center";break;case 3:s="end";break}}}if(i.R=a,i["--cue-white-space"]="normal",i["--cue-line-height"]="normal",i["--cue-text-align"]=s,a==="center"?(i["--cue-top"]="50%",p.push("translateY(-50%)")):i[`--cue-${a}`]=(o||0)+"px",d===1&&(i["--cue-padding-y"]="0"),(d===1||u)&&(i["--cue-bg-color"]=d===1?"none":u),d===3&&c&&(i["--cue-outline"]=`${r}px solid ${c}`),d===1&&typeof r=="number"){let h=u??"#000";i["--cue-text-shadow"]=[c&&l_(r*1.2,l*1.2,c),c?l_(r*(r/2),l*(r/2),h):l_(r,l,h)].filter(Boolean).join(", ")}p.length&&(i["--cue-transform"]=p.join(" ")),this.P[n]=i}U(e,n){let i=this.V(e),r=this.o(i.Start,i.End,n);if(!r)return;let s=new Hi(r[0],r[1],""),a={...this.P[i.Style]||{}},o=i.Name?``:"",l=a.R,c=i.MarginL&&parseFloat(i.MarginL),u=i.MarginR&&parseFloat(i.MarginR),d=i.MarginV&&parseFloat(i.MarginV);return c&&(a["--cue-width"]="auto",a["--cue-left"]=c+"px"),u&&(a["--cue-width"]="auto",a["--cue-right"]=u+"px"),d&&l!=="center"&&(a[`--cue-${l}`]=d+"px"),s.text=o+e.slice(this.N.length-1).join(", ").replace(lS,"").replace(cS,` -`),delete a.R,Object.keys(a).length&&(s.style=a),s}V(e){let n={};for(let i=0;ir)return[r,s];r===null&&this.e(this.d?.q(e,i)),s===null&&this.e(this.d?.r(n,i)),r!=null&&s!==null&&s>r&&this.e(this.d?.s(r,s,i))}e(e){if(e){if(this.k.push(e),this.f.strict)throw this.f.cancel(),e;this.f.onError?.(e)}}}});async function yS(t,e){let n=new ReadableStream({start(i){let r=t.split(vS);for(let s of r)i.enqueue(s);i.close()}});return Wp(n,e)}async function Wp(t,e){let n=e?.type??"vtt",i;if(typeof n=="string")switch(n){case"srt":i=(await Promise.resolve().then(()=>(sS(),rS))).default;break;case"ssa":case"ass":i=(await Promise.resolve().then(()=>(pS(),dS))).default;break;default:i=(await Promise.resolve().then(function(){return O2})).default}else i=n;let r,s=t.getReader(),a=i(),o=!!e?.strict||!!e?.errors;await a.init({strict:!1,...e,errors:o,type:n,cancel(){s.cancel(),r=a.done(!0)}});let l=1;for(;;){let{value:c,done:u}=await s.read();if(u){a.parse("",l),r=a.done(!1);break}a.parse(c,l),l++}return r}async function _S(t,e){let n=await t;if(!n.ok||!n.body)return{metadata:{},cues:[],regions:[],errors:[void 0]};let i=n.headers.get("content-type")||"",r=i.match(/text\/(.*?)(?:;|$)/)?.[1],s=i.match(/charset=(.*?)(?:;|$)/)?.[1];return p_(n.body,{type:r,encoding:s,...e})}async function p_(t,{encoding:e="utf-8",...n}={}){let i=t.pipeThrough(new u_(e));return Wp(i,n)}function x2(t){let e=parseInt(t,10);return Number.isNaN(e)?null:e}function Jl(t){let e=parseInt(t.replace(b2,""),10);return!Number.isNaN(e)&&e>=0&&e<=100?e:null}function fS(t){if(!t.includes(hS))return null;let[e,n]=t.split(hS).map(Jl);return e!==null&&n!==null?[e,n]:null}function k2(t){let e=parseFloat(t);return Number.isNaN(e)?null:e}function Bi(t){let e=t.match(N2);if(!e)return null;let n=e[1]?parseInt(e[1],10):0,i=parseInt(e[2],10),r=parseInt(e[3],10),s=e[4]?parseInt(e[4].padEnd(3,"0"),10):0,a=n*3600+i*60+r+s/1e3;return n<0||i<0||r<0||s<0||i>59||r>59?null:a}function D2(){return new Oa}function f_(t){let e="",n=1,i=[],r=[],s;for(let c=0;c":a(),n=1;break;default:!e&&V2.test(u)&&(n=6),e+=u;break}break;case 3:switch(u){case" ":case" ":case` -`:o(),s&&s.class?.trim(),n=4;break;case".":o();break;case">":o(),s&&s.class?.trim(),n=1;break;default:e+=u}break;case 4:u===">"?(e=e.replace(F2," "),s?.type==="v"?s.voice=c_(e):s?.type==="lang"&&(s.lang=c_(e)),e="",n=1):e+=u;break;case 5:u===">"&&(e="",s=r.pop(),n=1);break;case 6:if(u===">"){let d=Bi(e);d!==null&&d>=t.startTime&&d<=t.endTime&&(e="timestamp",a(),s.time=d),e="",n=1}else e+=u;break}}function a(){if(q2.has(e)){let c=s;s=H2(e),c?(r[r.length-1]!==c&&r.push(c),c.children.push(s)):i.push(s)}e="",n=1}function o(){if(s&&e){let c=e.replace("bg_","");j2.has(c)?s[e.startsWith("bg_")?"bgColor":"color"]=c:s.class=s.class?s.class+" "+e:e}e=""}function l(){if(!e)return;let c={type:"text",data:c_(e)};s?s.children.push(c):i.push(c),e=""}return n===1&&l(),i}function H2(t){return{tagName:wS[t],type:t,children:[]}}function c_(t){return t.replace(U2,e=>z2[e]||"'")}function It(t,e,n){t.style.setProperty(`--${e}`,n+"")}function Rr(t,e,n=!0){t.setAttribute(`data-${e}`,n===!0?"":n+"")}function qp(t,e){t.setAttribute("data-part",e)}function B2(t){return parseFloat(getComputedStyle(t).lineHeight)||0}function bS(t){if(h_)throw Error("[media-captions] called `createVTTCueTemplate` on the server - use `renderVTTCueString`");let e=document.createElement("template");return e.innerHTML=Kp(t),{cue:t,content:e.content}}function Kp(t,e=0){return Gp(f_(t),e)}function Gp(t,e=0){let n,i="";for(let r of t)if(r.type==="text")i+=r.data;else{let s=r.type==="timestamp";n={},n.class=r.class,n.title=r.type==="v"&&r.voice,n.lang=r.type==="lang"&&r.lang,n["data-part"]=r.type==="v"&&"voice",s&&(n["data-part"]="timed",n["data-time"]=r.time,n["data-future"]=r.time>e,n["data-past"]=r.timeo[1]).map(o=>`${o[0]}="${o[1]===!0?"":o[1]}"`).join(" ");i+=`<${r.tagName}${a?" "+a:""}>${Gp(r.children)}`}return i}function m_(t,e){if(!h_)for(let n of t.querySelectorAll('[data-part="timed"]')){let i=Number(n.getAttribute("data-time"));Number.isNaN(i)||(i>e?Rr(n,"future"):n.removeAttribute("data-future"),i=e.left&&t.top<=e.bottom&&t.bottom>=e.top}function G2(t,e){for(let n=0;n=0&&e.bottom<=t.height&&e.left>=0&&e.right<=t.width}function Y2(t,e,n){switch(n){case"+x":return e.left<0;case"-x":return e.right>t.width;case"+y":return e.top<0;case"-y":return e.bottom>t.height}}function Q2(t,e){let n=Math.max(0,Math.min(t.width,e.right)-Math.max(0,e.left)),i=Math.max(0,Math.min(t.height,e.bottom)-Math.max(0,e.top));return n*i/(t.height*t.width)}function v_(t,e){return{top:e.top/t.height,left:e.left/t.width,right:(t.width-e.right)/t.width,bottom:(t.height-e.bottom)/t.height}}function xS(t,e){return e.top=e.top*t.height,e.left=e.left*t.width,e.right=t.width-e.right*t.width,e.bottom=t.height-e.bottom*t.height,e}function ES(t,e,n,i){let r=v_(e,n);for(let s of kS)It(t,`${i}-${s}`,r[s]*100+"%")}function TS(t,e,n,i){let r=1,s,a={...e};for(let o=0;ol&&(s={...e},r=l),e={...a}}return s||a}function X2(t,e,n,i){let r=n.firstElementChild,s=eD(e),a,o=[];if(n[Lr]||(n[Lr]=Z2(t,n)),a=xS(t,{...n[Lr]}),n[ec])o=[n[ec]==="top"?"+y":"-y","+x","-x"];else if(e.snapToLines){let l;switch(e.vertical){case"":o=["+y","-y"],l="height";break;case"rl":o=["+x","-x"],l="width";break;case"lr":o=["-x","+x"],l="width";break}let c=B2(r),u=c*Math.round(s),d=t[l]+c,p=o[0];Math.abs(u)>d&&(u=u<0?-1:1,u*=Math.ceil(d/c)*c),s<0&&(u+=e.vertical===""?t.height:t.width,o=o.reverse()),Hp(a,p,u)}else{let l=e.vertical==="",c=l?"+y":"+x",u=l?a.height:a.width;Hp(a,c,(l?t.height:t.width)*s/100),Hp(a,c,e.lineAlign==="center"?u/2:e.lineAlign==="end"?u:0),o=l?["-y","+y","-x","+x"]:["-x","+x","-y","+y"]}return a=TS(t,a,i,o),ES(n,t,a,"cue"),a}function Z2(t,e){let n=g_(e),i=J2(e);if(e[ec]=!1,i.top&&(n.top=i.top,n.bottom=i.top+n.height,e[ec]="top"),i.bottom){let r=t.height-i.bottom;n.top=r-n.height,n.bottom=r,e[ec]="bottom"}return i.left&&(n.left=i.left),i.right&&(n.right=t.width-i.right),v_(t,n)}function J2(t){let e={};for(let n of kS)e[n]=parseFloat(t.style.getPropertyValue(`--cue-${n}`));return e}function eD(t){return t.line==="auto"?t.snapToLines?-1:100:t.line}function tD(t){if(t.position==="auto")switch(t.align){case"start":case"left":return 0;case"right":case"end":return 100;default:return 50}return t.position}function nD(t,e){if(t.positionAlign==="auto")switch(t.align){case"start":return e==="ltr"?"line-left":"line-right";case"end":return e==="ltr"?"line-right":"line-left";case"center":return"center";default:return`line-${t.align}`}return t.positionAlign}function rD(t,e,n,i){let r=Array.from(n.querySelectorAll('[data-part="cue-display"]')),s=0,a=Math.max(0,r.length-e.lines);for(let l=r.length-1;l>=a;l--)s+=r[l].offsetHeight;It(n,"region-height",s+"px"),n[Lr]||(n[Lr]=v_(t,g_(n)));let o={...n[Lr]};return o=xS(t,o),o.width=n.clientWidth,o.height=s,o.right=o.left+o.width,o.bottom=o.top+s,o=TS(t,o,i,iD),ES(n,t,o,"region"),o}var Sn,Bt,vS,u_,d_,tc,h_,w2,Hi,nc,hS,b2,E2,mS,T2,Va,S2,P2,C2,$2,Zl,M2,R2,L2,I2,A2,N2,Da,Oa,O2,V2,F2,wS,z2,U2,j2,q2,Lr,kS,ec,iD,Bp,Xl=Ue(()=>{"use strict";Sn={LoadFail:0,BadSignature:1,BadTimestamp:2,BadSettingValue:3,BadFormat:4,UnknownSetting:5},Bt=class extends Error{constructor(n){super(n.reason);w(this,"code");w(this,"line");this.code=n.code,this.line=n.line}},vS=/\r?\n|\r/gm,u_=class{constructor(e){w(this,"writable");w(this,"readable");let n=new d_(e);this.writable=new WritableStream({write(i){n.transform(i)},close(){n.close()}}),this.readable=new ReadableStream({start(i){n.onLine=r=>i.enqueue(r),n.onClose=()=>i.close()}})}},d_=class{constructor(e){w(this,"x","");w(this,"y");w(this,"onLine");w(this,"onClose");this.y=new TextDecoder(e)}transform(e){this.x+=this.y.decode(e,{stream:!0});let n=this.x.split(vS);this.x=n.pop()||"";for(let i=0;i"u",w2=h_?tc:window.VTTCue,Hi=class extends w2{constructor(){super(...arguments);w(this,"region",null);w(this,"vertical","");w(this,"snapToLines",!0);w(this,"line","auto");w(this,"lineAlign","start");w(this,"position","auto");w(this,"positionAlign","auto");w(this,"size",100);w(this,"align","center");w(this,"style")}},nc=class{constructor(){w(this,"id","");w(this,"width",100);w(this,"lines",3);w(this,"regionAnchorX",0);w(this,"regionAnchorY",100);w(this,"viewportAnchorX",0);w(this,"viewportAnchorY",100);w(this,"scroll","")}},hS=",",b2="%";E2="WEBVTT",mS=",",T2="%",Va=/[:=]/,S2=/^[\s\t]*(region|vertical|line|position|size|align)[:=]/,P2="NOTE",C2="REGION",$2=/^REGION:?[\s\t]+/,Zl=/[\s\t]+/,M2="-->",R2=/[\s\t]*-->[\s\t]+/,L2=/start|center|end|left|right/,I2=/start|center|end/,A2=/line-(?:left|right)|center|auto/,N2=/^(?:(\d{1,2}):)?(\d{2}):(\d{2})(?:\.(\d{1,3}))?$/,Da=(t=>(t[t.None=0]="None",t[t.Header=1]="Header",t[t.Cue=2]="Cue",t[t.Region=3]="Region",t[t.Note=4]="Note",t))(Da||{}),Oa=class{constructor(){w(this,"f");w(this,"c",0);w(this,"g",{});w(this,"h",{});w(this,"j",[]);w(this,"a",null);w(this,"b",null);w(this,"k",[]);w(this,"d");w(this,"l","")}async init(e){this.f=e,e.strict&&(this.c=1),e.errors&&(this.d=(await Promise.resolve().then(()=>(s_(),r_))).ParseErrorBuilder)}parse(e,n){if(e==="")this.a?(this.j.push(this.a),this.f.onCue?.(this.a),this.a=null):this.b?(this.h[this.b.id]=this.b,this.f.onRegion?.(this.b),this.b=null):this.c===1&&(this.i(e,n),this.f.onHeaderMetadata?.(this.g)),this.c=0;else if(this.c)switch(this.c){case 1:this.i(e,n);break;case 2:if(this.a){let i=this.a.text.length>0;!i&&S2.test(e)?this.m(e.split(Zl),n):this.a.text+=(i?` -`:"")+e}break;case 3:this.n(e.split(Zl),n);break}else if(e.startsWith(P2))this.c=4;else if(e.startsWith(C2))this.c=3,this.b=new nc,this.n(e.replace($2,"").split(Zl),n);else if(e.includes(M2)){let i=this.o(e,n);i&&(this.a=new Hi(i[0],i[1],""),this.a.id=this.l,this.m(i[2],n)),this.c=2}else n===1&&this.i(e,n);this.l=e}done(){return{metadata:this.g,cues:this.j,regions:Object.values(this.h),errors:this.k}}i(e,n){if(n>1){if(Va.test(e)){let[i,r]=e.split(Va);i&&(this.g[i]=(r||"").replace(Zl,""))}}else e.startsWith(E2)?this.c=1:this.e(this.d?.p())}o(e,n){let[i,r=""]=e.split(R2),[s,...a]=r.split(Zl),o=Bi(i),l=Bi(s);if(o!==null&&l!==null&&l>o)return[o,l,a];o===null&&this.e(this.d?.q(i,n)),l===null&&this.e(this.d?.r(s,n)),o!=null&&l!==null&&l>o&&this.e(this.d?.s(o,l,n))}n(e,n){let i;for(let r=0;r",""":'"',"'":"'"," ":"\xA0","‎":"\u200E","‏":"\u200F"},U2=/&(?:amp|lt|gt|quot|#(0+)?39|nbsp|lrm|rlm);/g,j2=new Set(["white","lime","cyan","red","yellow","magenta","blue","black"]),q2=new Set(Object.keys(wS));Lr=Symbol(0);kS=["top","left","right","bottom"];ec=Symbol(0);iD=["-y","+y","-x","+x"];Bp=class{constructor(e,n){w(this,"overlay");w(this,"z");w(this,"A",0);w(this,"C","ltr");w(this,"B",[]);w(this,"D",!1);w(this,"E");w(this,"h",new Map);w(this,"j",new Map);w(this,"K",W2(()=>{this.D=!1,this.G();for(let e of this.h.values())e[Lr]=null;for(let e of this.j.values())e&&(e[Lr]=null);this.H(!0)},50));this.overlay=e,this.dir=n?.dir??"ltr",e.setAttribute("translate","yes"),e.setAttribute("aria-live","off"),e.setAttribute("aria-atomic","true"),qp(e,"captions"),this.G(),this.E=new ResizeObserver(this.I.bind(this)),this.E.observe(e)}get dir(){return this.C}set dir(e){this.C=e,Rr(this.overlay,"dir",e)}get currentTime(){return this.A}set currentTime(e){this.A=e,this.update()}changeTrack({regions:e,cues:n}){this.reset(),this.J(e);for(let i of n)this.j.set(i,null);this.update()}addCue(e){this.j.set(e,null),this.update()}removeCue(e){this.j.delete(e),this.update()}update(e=!1){this.H(e)}reset(){this.j.clear(),this.h.clear(),this.B=[],this.overlay.textContent=""}destroy(){this.reset(),this.E.disconnect()}I(){this.D=!0,this.K()}G(){this.z=g_(this.overlay),It(this.overlay,"overlay-width",this.z.width+"px"),It(this.overlay,"overlay-height",this.z.height+"px")}H(e=!1){if(!this.j.size||this.D)return;let n,i=[...this.j.keys()].filter(s=>this.A>=s.startTime&&this.A<=s.endTime).sort((s,a)=>s.startTime!==a.startTime?s.startTime-a.startTime:s.endTime-a.endTime),r=i.map(s=>s.region);for(let s=0;sRr(o,"active")),e=!0),a.isConnected||((o||this.overlay).append(a),e=!0)}if(e){let s=[],a=new Set;for(let o=i.length-1;o>=0;o--){if(n=i[o],a.has(n.region||n))continue;let l=this.F(n),c=l?this.h.get(n.region.id):this.j.get(n);l?s.push(rD(this.z,n.region,c,s)):s.push(X2(this.z,n,c,s)),a.add(l?n.region:n)}}m_(this.overlay,this.A),this.B=i}J(e){if(e)for(let n of e){let i=this.M(n);this.h.set(n.id,i),this.overlay.append(i)}}M(e){let n=document.createElement("div");return qp(n,"region"),Rr(n,"id",e.id),Rr(n,"scroll",e.scroll),It(n,"region-width",e.width+"%"),It(n,"region-anchor-x",e.regionAnchorX),It(n,"region-anchor-y",e.regionAnchorY),It(n,"region-viewport-anchor-x",e.viewportAnchorX),It(n,"region-viewport-anchor-y",e.viewportAnchorY),It(n,"region-lines",e.lines),n}L(e){let n=document.createElement("div"),i=tD(e),r=nD(e,this.C);if(qp(n,"cue-display"),e.vertical!==""&&Rr(n,"vertical"),It(n,"cue-text-align",e.align),e.style)for(let a of Object.keys(e.style))n.style.setProperty(a,e.style[a]);if(this.F(e))It(n,"cue-offset",`${i-(r==="line-right"?100:r==="center"?50:0)}%`);else if(It(n,"cue-writing-mode",e.vertical===""?"horizontal-tb":e.vertical==="lr"?"vertical-lr":"vertical-rl"),!e.style?.["--cue-width"]){let a=i;r==="line-left"?a=100-i:r==="center"&&i<=50?a=i*2:r==="center"&&i>50&&(a=(100-i)*2);let o=e.sizeBp,ParseError:()=>Bt,ParseErrorCode:()=>Sn,TextCue:()=>tc,VTTCue:()=>Hi,VTTRegion:()=>nc,createVTTCueTemplate:()=>bS,parseByteStream:()=>p_,parseResponse:()=>_S,parseText:()=>yS,parseTextStream:()=>Wp,parseVTTTimestamp:()=>Bi,renderVTTCueString:()=>Kp,renderVTTTokensString:()=>Gp,tokenizeVTTCue:()=>f_,updateTimedVTTCueNodes:()=>m_});var rc=Ue(()=>{"use strict";Xl()});var gi,sc=Ue(()=>{"use strict";"use client";Lt();gi=class{constructor(e){this._callback=e}_start(){Ie(this._id)&&this._loop()}_stop(){Be(this._id)&&window.cancelAnimationFrame(this._id),this._id=void 0}_loop(){this._id=window.requestAnimationFrame(()=>{Ie(this._id)||(this._callback(),this._loop())})}}});var y_,__,Fa,w_=Ue(()=>{"use strict";"use client";Lt();Wt();sc();y_=class{constructor(e,n){this._provider=e,this._ctx=n,this._disposal=e_(),this._waiting=!1,this._attachedLoadStart=!1,this._attachedCanPlay=!1,this._timeRAF=new gi(this._onAnimationFrame.bind(this)),this._handlers=void 0,this._handleDevEvent=void 0,this._attachInitialListeners(),b(this._attachTimeUpdate.bind(this)),G(this._onDispose.bind(this))}get _media(){return this._provider.media}get _notify(){return this._ctx.delegate._notify}_onDispose(){this._attachedLoadStart=!1,this._attachedCanPlay=!1,this._timeRAF._stop(),this._disposal.empty()}_onAnimationFrame(){let e=this._media.currentTime;this._ctx.$state.realCurrentTime()!==e&&this._updateCurrentTime(e)}_attachInitialListeners(){this._attachEventListener("loadstart",this._onLoadStart),this._attachEventListener("abort",this._onAbort),this._attachEventListener("emptied",this._onEmptied),this._attachEventListener("error",this._onError),this._attachEventListener("volumechange",this._onVolumeChange)}_attachLoadStartListeners(){this._attachedLoadStart||(this._disposal.add(this._attachEventListener("loadeddata",this._onLoadedData),this._attachEventListener("loadedmetadata",this._onLoadedMetadata),this._attachEventListener("canplay",this._onCanPlay),this._attachEventListener("canplaythrough",this._onCanPlayThrough),this._attachEventListener("durationchange",this._onDurationChange),this._attachEventListener("play",this._onPlay),this._attachEventListener("progress",this._onProgress),this._attachEventListener("stalled",this._onStalled),this._attachEventListener("suspend",this._onSuspend)),this._attachedLoadStart=!0)}_attachCanPlayListeners(){this._attachedCanPlay||(this._disposal.add(this._attachEventListener("pause",this._onPause),this._attachEventListener("playing",this._onPlaying),this._attachEventListener("ratechange",this._onRateChange),this._attachEventListener("seeked",this._onSeeked),this._attachEventListener("seeking",this._onSeeking),this._attachEventListener("ended",this._onEnded),this._attachEventListener("waiting",this._onWaiting)),this._attachedCanPlay=!0)}_attachEventListener(e,n){return S(this._media,e,n.bind(this))}_onDevEvent(e){}_updateCurrentTime(e,n){let i={currentTime:Math.min(e,this._ctx.$state.seekableEnd()),played:this._media.played};this._notify("time-update",i,n)}_onLoadStart(e){if(this._media.networkState===3){this._onAbort(e);return}this._attachLoadStartListeners(),this._notify("load-start",void 0,e)}_onAbort(e){this._notify("abort",void 0,e)}_onEmptied(){this._notify("emptied",void 0,event)}_onLoadedData(e){this._notify("loaded-data",void 0,e)}_onLoadedMetadata(e){this._attachCanPlayListeners(),this._notify("loaded-metadata",void 0,e),b_&&_s(this._ctx.$state.source())&&this._ctx.delegate._ready(this._getCanPlayDetail(),e)}_getCanPlayDetail(){return{provider:C(this._ctx.$provider),duration:this._media.duration,buffered:this._media.buffered,seekable:this._media.seekable}}_onPlay(e){this._ctx.$state.canPlay&&this._notify("play",void 0,e)}_onPause(e){this._media.readyState===1&&!this._waiting||(this._waiting=!1,this._timeRAF._stop(),this._notify("pause",void 0,e))}_onCanPlay(e){this._ctx.delegate._ready(this._getCanPlayDetail(),e)}_onCanPlayThrough(e){this._ctx.$state.started()||this._notify("can-play-through",this._getCanPlayDetail(),e)}_onPlaying(e){this._waiting=!1,this._notify("playing",void 0,e),this._timeRAF._start()}_onStalled(e){this._notify("stalled",void 0,e),this._media.readyState<3&&(this._waiting=!0,this._notify("waiting",void 0,e))}_onWaiting(e){this._media.readyState<3&&(this._waiting=!0,this._notify("waiting",void 0,e))}_onEnded(e){this._timeRAF._stop(),this._updateCurrentTime(this._media.duration,e),this._notify("end",void 0,e),this._ctx.$state.loop()&&Ky(this._media.controls)&&(this._media.controls=!1)}_attachTimeUpdate(){this._ctx.$state.paused()&&S(this._media,"timeupdate",this._onTimeUpdate.bind(this))}_onTimeUpdate(e){this._updateCurrentTime(this._media.currentTime,e)}_onDurationChange(e){this._ctx.$state.ended()&&this._updateCurrentTime(this._media.duration,e),this._notify("duration-change",this._media.duration,e)}_onVolumeChange(e){let n={volume:this._media.volume,muted:this._media.muted};this._notify("volume-change",n,e)}_onSeeked(e){this._updateCurrentTime(this._media.currentTime,e),this._notify("seeked",this._media.currentTime,e),Math.trunc(this._media.currentTime)===Math.trunc(this._media.duration)&&Yp(this._media.duration)>Yp(this._media.currentTime)&&(this._updateCurrentTime(this._media.duration,e),this._media.ended||this._ctx.player.dispatch(new j("media-play-request",{trigger:e})))}_onSeeking(e){this._notify("seeking",this._media.currentTime,e)}_onProgress(e){let n={buffered:this._media.buffered,seekable:this._media.seekable};this._notify("progress",n,e)}_onSuspend(e){this._notify("suspend",void 0,e)}_onRateChange(e){this._notify("rate-change",this._media.playbackRate,e)}_onError(e){let n=this._media.error;if(!n)return;let i={message:n.message,code:n.code,mediaError:n};this._notify("error",i,e)}},__=class{constructor(e,n){this._provider=e,this._ctx=n,this._nativeTracks.onaddtrack=this._onAddNativeTrack.bind(this),this._nativeTracks.onremovetrack=this._onRemoveNativeTrack.bind(this),this._nativeTracks.onchange=this._onChangeNativeTrack.bind(this),S(this._ctx.audioTracks,"change",this._onChangeTrack.bind(this))}get _nativeTracks(){return this._provider.media.audioTracks}_onAddNativeTrack(e){let n=e.track;if(n.label==="")return;let i={id:n.id.toString(),label:n.label,language:n.language,kind:n.kind,selected:!1};this._ctx.audioTracks[Y._add](i,e),n.enabled&&(i.selected=!0)}_onRemoveNativeTrack(e){let n=this._ctx.audioTracks.getById(e.track.id);n&&this._ctx.audioTracks[Y._remove](n,e)}_onChangeNativeTrack(e){let n=this._getEnabledNativeTrack();if(!n)return;let i=this._ctx.audioTracks.getById(n.id);i&&this._ctx.audioTracks[Y._select](i,!0,e)}_getEnabledNativeTrack(){return Array.from(this._nativeTracks).find(e=>e.enabled)}_onChangeTrack(e){let{current:n}=e.detail;if(!n)return;let i=this._nativeTracks.getTrackById(n.id);if(i){let r=this._getEnabledNativeTrack();r&&(r.enabled=!1),i.enabled=!0}}},Fa=class{constructor(e,n){this._media=e,this._ctx=n,this.scope=$t(),this._currentSrc=null}setup(){new y_(this,this._ctx),"audioTracks"in this.media&&new __(this,this._ctx),G(()=>{this._media.setAttribute("src",""),this._media.load()})}get type(){return""}get media(){return this._media}get currentSrc(){return this._currentSrc}setPlaybackRate(e){this._media.playbackRate=e}async play(){return this._media.play()}async pause(){return this._media.pause()}setMuted(e){this._media.muted=e}setVolume(e){this._media.volume=e}setCurrentTime(e){this._media.currentTime=e}setPlaysInline(e){Z(this._media,"playsinline",e)}async loadSource({src:e,type:n},i){this._media.preload=i||"",x_(e)?this._media.srcObject=e:(this._media.srcObject=null,this._media.src=F(e)?this._appendMediaFragment(e):window.URL.createObjectURL(e)),this._media.load(),this._currentSrc={src:e,type:n}}_appendMediaFragment(e){let{clipStartTime:n,clipEndTime:i}=this._ctx.$state,r=n(),s=i();return r>0&&s>0?`${e}#t=${r},${s}`:r>0?`${e}#t=${r}`:s>0?`${e}#t=0,${s}`:e}}});var SS={};xt(SS,{AudioProvider:()=>k_});var Zz,k_,PS=Ue(()=>{"use strict";"use client";w_();Zz=$(z(),1),k_=class extends Fa{constructor(){super(...arguments),this.$$PROVIDER_TYPE="AUDIO"}get type(){return"audio"}setup(){super.setup(),this.type==="audio"&&this._ctx.delegate._notify("provider-setup",this)}get audio(){return this._media}}});var CS={};xt(CS,{VideoProvider:()=>ac});function sD(t,e){return Array.from(t.children).find(n=>n.track===e)}var nU,E_,T_,S_,P_,C_,$_,M_,ac,R_=Ue(()=>{"use strict";"use client";Lt();Wt();w_();nU=$(z(),1),E_=class{constructor(e,n){this._video=e,this._ctx=n,e.textTracks.onaddtrack=this._onAddTrack.bind(this),G(this._onDispose.bind(this))}_onAddTrack(e){let n=e.track;if(!n||sD(this._video,n))return;let i=new ln({id:n.id,kind:n.kind,label:n.label,language:n.language,type:"vtt"});i[W._native]={track:n},i[W._readyState]=2,i[W._nativeHLS]=!0;let r=0,s=a=>{if(n.cues)for(let o=r;o{this._media.delegate._notify("picture-in-picture-change",i,r)},S(this._video,"enterpictureinpicture",this._onEnter.bind(this)),S(this._video,"leavepictureinpicture",this._onExit.bind(this))}get active(){return document.pictureInPictureElement===this._video}get supported(){return Xp(this._video)}async enter(){return this._video.requestPictureInPicture()}exit(){return document.exitPictureInPicture()}_onEnter(e){this._onChange(!0,e)}_onExit(e){this._onChange(!1,e)}},S_=class{constructor(e,n){this._video=e,this._media=n,this._mode="inline",S(this._video,"webkitpresentationmodechanged",this._onModeChange.bind(this))}get _supported(){return Zp(this._video)}async _setPresentationMode(e){this._mode!==e&&this._video.webkitSetPresentationMode(e)}_onModeChange(e){let n=this._mode;this._mode=this._video.webkitPresentationMode,this._media.player?.dispatch(new j("video-presentation-change",{detail:this._mode,trigger:e})),["fullscreen","picture-in-picture"].forEach(i=>{(this._mode===i||n===i)&&this._media.delegate._notify(`${i}-change`,this._mode===i,e)})}},P_=class{constructor(e){this._presentation=e}get active(){return this._presentation._mode==="fullscreen"}get supported(){return this._presentation._supported}async enter(){this._presentation._setPresentationMode("fullscreen")}async exit(){this._presentation._setPresentationMode("inline")}},C_=class{constructor(e){this._presentation=e}get active(){return this._presentation._mode==="picture-in-picture"}get supported(){return this._presentation._supported}async enter(){this._presentation._setPresentationMode("picture-in-picture")}async exit(){this._presentation._setPresentationMode("inline")}},$_=class{constructor(e,n){this._video=e,this._ctx=n,this._supported=D(!1),this._setup()}get supported(){return this._supported()}_setup(){N||!this._video.remote||!this._canPrompt||(this._video.remote.watchAvailability(e=>{this._supported.set(e)}).catch(()=>{this._supported.set(!1)}),b(this._watchSupported.bind(this)))}_watchSupported(){if(!this._supported())return;let e=["connecting","connect","disconnect"],n=this._onStateChange.bind(this);n(),S(this._video,"playing",n);for(let i of e)S(this._video.remote,i,n)}async prompt(){if(!this.supported)throw Error("Not supported on this platform.");return this._video.remote.prompt()}_onStateChange(e){let n=this._video.remote.state;if(n===this._state)return;let i={type:this._type,state:n};this._ctx.delegate._notify("remote-playback-change",i,e),this._state=n}},M_=class extends $_{constructor(){super(...arguments),this._type="airplay"}get _canPrompt(){return"WebKitPlaybackTargetAvailabilityEvent"in window}},ac=class extends Fa{constructor(e,n){super(e,n),this.$$PROVIDER_TYPE="VIDEO",et(()=>{if(this.airPlay=new M_(e,n),Zp(e)){let i=new S_(e,n);this.fullscreen=new P_(i),this.pictureInPicture=new C_(i)}else Xp(e)&&(this.pictureInPicture=new T_(e,n))},this.scope)}get type(){return"video"}setup(){super.setup(),Qp(this.video)&&new E_(this.video,this._ctx),this._ctx.textRenderers._attachVideo(this.video),G(()=>{this._ctx.textRenderers._attachVideo(null)}),this.type==="video"&&this._ctx.delegate._notify("provider-setup",this)}get video(){return this._media}}});var $S={};xt($S,{HLSProvider:()=>Jp});async function oD(t,e={}){if(!Ie(t)){if(e.onLoadStart?.(),t.prototype&&t.prototype!==Function)return e.onLoaded?.(t),t;try{let n=(await t())?.default;if(n&&n.isSupported)e.onLoaded?.(n);else throw Error("");return n}catch(n){e.onLoadError?.(n)}}}async function lD(t,e={}){if(F(t)){e.onLoadStart?.();try{if(await th(t),!yt(window.Hls))throw Error("");let n=window.Hls;return e.onLoaded?.(n),n}catch(n){e.onLoadError?.(n)}}}var oU,aD,L_,I_,cD,Jp,MS=Ue(()=>{"use strict";"use client";Lt();Wt();R_();sc();oU=$(z(),1),aD=t=>Aa(t),L_=class{constructor(e,n){this._video=e,this._ctx=n,this._instance=null,this._stopLiveSync=null,this._config={},this._callbacks=new Set,this._retryLoadingTimer=-1}get instance(){return this._instance}setup(e){let{streamType:n}=this._ctx.$state,i=C(n).includes("live"),r=C(n).includes("ll-");this._instance=new e({lowLatencyMode:r,backBufferLength:r?4:i?8:void 0,renderTextTracksNatively:!1,...this._config});let s=this._dispatchHLSEvent.bind(this);for(let a of Object.values(e.Events))this._instance.on(a,s);this._instance.on(e.Events.ERROR,this._onError.bind(this));for(let a of this._callbacks)a(this._instance);this._ctx.player.dispatch("hls-instance",{detail:this._instance}),this._instance.attachMedia(this._video),this._instance.on(e.Events.FRAG_LOADING,this._onFragLoading.bind(this)),this._instance.on(e.Events.AUDIO_TRACK_SWITCHED,this._onAudioSwitch.bind(this)),this._instance.on(e.Events.LEVEL_SWITCHED,this._onLevelSwitched.bind(this)),this._instance.on(e.Events.LEVEL_LOADED,this._onLevelLoaded.bind(this)),this._instance.on(e.Events.NON_NATIVE_TEXT_TRACKS_FOUND,this._onTracksFound.bind(this)),this._instance.on(e.Events.CUES_PARSED,this._onCuesParsed.bind(this)),this._ctx.qualities[cn._enableAuto]=this._enableAutoQuality.bind(this),S(this._ctx.qualities,"change",this._onQualityChange.bind(this)),S(this._ctx.audioTracks,"change",this._onAudioChange.bind(this)),this._stopLiveSync=b(this._liveSync.bind(this))}_liveSync(){if(!this._ctx.$state.live())return;let e=new gi(this._liveSyncPosition.bind(this));return e._start(),e._stop.bind(e)}_liveSyncPosition(){this._ctx.$state.liveSyncPosition.set(this._instance?.liveSyncPosition??1/0)}_dispatchHLSEvent(e,n){this._ctx.player?.dispatch(new j(aD(e),{detail:n}))}_onTracksFound(e,n){let i=new j(e,{detail:n}),r=-1;for(let s=0;s{l.mode==="showing"?(this._instance.subtitleTrack=s,r=s):r===s&&(this._instance.subtitleTrack=-1,r=-1)},this._ctx.textTracks.add(l,i)}}_onCuesParsed(e,n){let i=this._ctx.textTracks.getById(`hls-${n.track}`);if(!i)return;let r=new j(e,{detail:n});for(let s of n.cues)s.positionAlign="auto",i.addCue(s,r)}_onAudioSwitch(e,n){let i=this._ctx.audioTracks[n.id];if(i){let r=new j(e,{detail:n});this._ctx.audioTracks[Y._select](i,!0,r)}}_onLevelSwitched(e,n){let i=this._ctx.qualities[n.level];if(i){let r=new j(e,{detail:n});this._ctx.qualities[Y._select](i,!0,r)}}_onLevelLoaded(e,n){if(this._ctx.$state.canPlay())return;let{type:i,live:r,totalduration:s,targetduration:a}=n.details,o=new j(e,{detail:n});this._ctx.delegate._notify("stream-type-change",r?i==="EVENT"&&Number.isFinite(s)&&a>=10?"live:dvr":"live":"on-demand",o),this._ctx.delegate._notify("duration-change",s,o);let l=this._instance.media;this._instance.currentLevel===-1&&this._ctx.qualities[cn._setAuto](!0,o);for(let c of this._instance.audioTracks){let u={id:c.id.toString(),label:c.name,language:c.lang||"",kind:"main"};this._ctx.audioTracks[Y._add](u,o)}for(let c of this._instance.levels){let u={id:c.id?.toString()??c.height+"p",width:c.width,height:c.height,codec:c.codecSet,bitrate:c.bitrate};this._ctx.qualities[Y._add](u,o)}l.dispatchEvent(new j("canplay",{trigger:o}))}_onError(e,n){if(n.fatal)switch(n.type){case"networkError":this._onNetworkError(n.error);break;case"mediaError":this._instance?.recoverMediaError();break;default:this._onFatalError(n.error);break}}_onFragLoading(){this._retryLoadingTimer>=0&&this._clearRetryTimer()}_onNetworkError(e){this._clearRetryTimer(),this._instance?.startLoad(),this._retryLoadingTimer=window.setTimeout(()=>{this._retryLoadingTimer=-1,this._onFatalError(e)},5e3)}_clearRetryTimer(){clearTimeout(this._retryLoadingTimer),this._retryLoadingTimer=-1}_onFatalError(e){this._instance?.destroy(),this._instance=null,this._ctx.delegate._notify("error",{message:e.message,code:1,error:e})}_enableAutoQuality(){this._instance&&(this._instance.currentLevel=-1)}_onQualityChange(){let{qualities:e}=this._ctx;!this._instance||e.auto||(this._instance[e.switch+"Level"]=e.selectedIndex,oc&&(this._video.currentTime=this._video.currentTime))}_onAudioChange(){let{audioTracks:e}=this._ctx;this._instance&&this._instance.audioTrack!==e.selectedIndex&&(this._instance.audioTrack=e.selectedIndex)}_loadSource(e){F(e.src)&&(this._clearRetryTimer(),this._instance?.loadSource(e.src))}_destroy(){this._clearRetryTimer(),this._ctx&&(this._ctx.qualities[cn._enableAuto]=void 0),this._instance?.destroy(),this._instance=null,this._stopLiveSync?.(),this._stopLiveSync=null}},I_=class{constructor(e,n,i){this._lib=e,this._ctx=n,this._callback=i,this._startLoading()}async _startLoading(){let e={onLoadStart:this._onLoadStart.bind(this),onLoaded:this._onLoaded.bind(this),onLoadError:this._onLoadError.bind(this)},n=await lD(this._lib,e);if(Ie(n)&&!F(this._lib)&&(n=await oD(this._lib,e)),!n)return null;if(!n.isSupported()){let i="[vidstack] `hls.js` is not supported in this environment";return this._ctx.player.dispatch(new j("hls-unsupported")),this._ctx.delegate._notify("error",{message:i,code:4}),null}return n}_onLoadStart(){this._ctx.player.dispatch(new j("hls-lib-load-start"))}_onLoaded(e){this._ctx.player.dispatch(new j("hls-lib-loaded",{detail:e})),this._callback(e)}_onLoadError(e){let n=vi(e);this._ctx.player.dispatch(new j("hls-lib-load-error",{detail:n})),this._ctx.delegate._notify("error",{message:n.message,code:4,error:n})}};cD="https://cdn.jsdelivr.net",Jp=class extends ac{constructor(){super(...arguments),this.$$PROVIDER_TYPE="HLS",this._ctor=null,this._controller=new L_(this.video,this._ctx),this._library=`${cD}/npm/hls.js@^1.5.0/dist/hls.min.js`}get ctor(){return this._ctor}get instance(){return this._controller.instance}get type(){return"hls"}get canLiveSync(){return!0}get config(){return this._controller._config}set config(e){this._controller._config=e}get library(){return this._library}set library(e){this._library=e}preconnect(){F(this._library)&&Jn(this._library)}setup(){super.setup(),new I_(this._library,this._ctx,e=>{this._ctor=e,this._controller.setup(e),this._ctx.delegate._notify("provider-setup",this);let n=C(this._ctx.$state.source);n&&this.loadSource(n)})}async loadSource(e,n){F(e.src)&&(this._media.preload=n||"",this._controller._loadSource(e),this._currentSrc=e)}onInstance(e){let n=this._controller.instance;return n&&e(n),this._controller._callbacks.add(e),()=>this._controller._callbacks.delete(e)}destroy(){this._controller._destroy()}};Jp.supported=eh()});function Ua(t,e=3e3){let n=qi();return setTimeout(()=>{let i=t();i&&n.reject(i)},e),n}var za,A_=Ue(()=>{"use strict";"use client";Lt();Wt();za=class{constructor(e){this._iframe=e,this._src=D(""),this.referrerPolicy=null,e.setAttribute("frameBorder","0"),e.setAttribute("aria-hidden","true"),e.setAttribute("allow","autoplay; fullscreen; encrypted-media; picture-in-picture; accelerometer; gyroscope"),this.referrerPolicy!==null&&e.setAttribute("referrerpolicy",this.referrerPolicy)}get iframe(){return this._iframe}setup(){S(window,"message",this._onWindowMessage.bind(this)),S(this._iframe,"load",this._onLoad.bind(this)),b(this._watchSrc.bind(this))}_watchSrc(){let e=this._src();if(!e.length){this._iframe.setAttribute("src","");return}let n=C(()=>this._buildParams());this._iframe.setAttribute("src",RS(e,n))}_postMessage(e,n){N||this._iframe.contentWindow?.postMessage(JSON.stringify(e),n??"*")}_onWindowMessage(e){let n=this._getOrigin();if((e.source===null||e.source===this._iframe?.contentWindow)&&(!F(n)||n===e.origin)){try{let r=JSON.parse(e.data);r&&this._onMessage(r,e);return}catch{}e.data&&this._onMessage(e.data,e)}}}});var LS={};xt(LS,{getVimeoVideoInfo:()=>O_,resolveVimeoVideoId:()=>D_});function D_(t){let e=t.match(uD);return{videoId:e?.[1],hash:e?.[2]}}async function O_(t,e){if(N_.has(t))return N_.get(t);if(nh.has(t))return nh.get(t);let n=`https://vimeo.com/api/oembed.json?url=https://player.vimeo.com/video/${t}`,i=window.fetch(n,{mode:"cors",signal:e.signal}).then(r=>r.json()).then(r=>{let s=/vimeocdn.com\/video\/(.*)?_/,a=r?.thumbnail_url?.match(s)?.[1],o=a?`https://i.vimeocdn.com/video/${a}_1920x1080.webp`:"",l={title:r?.title??"",duration:r?.duration??0,poster:o,pro:r.account_type!=="basic"};return N_.set(t,l),l}).finally(()=>nh.delete(t));return nh.set(t,i),i}var uD,N_,nh,V_=Ue(()=>{"use strict";"use client";uD=/(?:https:\/\/)?(?:player\.)?vimeo(?:\.com)?\/(?:video\/)?(\d+)(?:\?hash=(.*))?/,N_=new Map,nh=new Map});var IS={};xt(IS,{VimeoProvider:()=>F_});var gU,dD,F_,AS=Ue(()=>{"use strict";"use client";Lt();Wt();sc();A_();V_();gU=$(z(),1),dD=["bufferend","bufferstart","durationchange","ended","enterpictureinpicture","error","fullscreenchange","leavepictureinpicture","loaded","playProgress","loadProgress","pause","play","playbackratechange","qualitychange","seeked","seeking","timeupdate","volumechange","waiting"],F_=class extends za{constructor(e,n){super(e),this._ctx=n,this.$$PROVIDER_TYPE="VIMEO",this.scope=$t(),this._played=0,this._playedRange=new oe(0,0),this._seekableRange=new oe(0,0),this._playPromise=null,this._pausePromise=null,this._videoInfoPromise=null,this._videoId=D(""),this._pro=D(!1),this._hash=null,this._currentSrc=null,this._currentCue=null,this._timeRAF=new gi(this._onAnimationFrame.bind(this)),this._chaptersTrack=null,this.cookies=!1,this.title=!0,this.byline=!0,this.portrait=!0,this.color="00ADEF",this._skipTimeUpdates=!1}get _notify(){return this._ctx.delegate._notify}get type(){return"vimeo"}get currentSrc(){return this._currentSrc}get videoId(){return this._videoId()}get hash(){return this._hash}get isPro(){return this._pro()}preconnect(){Jn(this._getOrigin())}setup(){super.setup(),b(this._watchVideoId.bind(this)),b(this._watchVideoInfo.bind(this)),b(this._watchPro.bind(this)),this._notify("provider-setup",this)}destroy(){this._reset(),this._remote("destroy")}async play(){let{paused:e}=this._ctx.$state;return this._playPromise||(this._playPromise=Ua(()=>{if(this._playPromise=null,e())return"Timed out."}),this._remote("play")),this._playPromise.promise}async pause(){let{paused:e}=this._ctx.$state;return this._pausePromise||(this._pausePromise=Ua(()=>{if(this._pausePromise=null,!e())return"Timed out."}),this._remote("pause")),this._pausePromise.promise}setMuted(e){this._remote("setMuted",e)}setCurrentTime(e){this._remote("seekTo",e),this._notify("seeking",e)}setVolume(e){this._remote("setVolume",e),this._remote("setMuted",C(this._ctx.$state.muted))}setPlaybackRate(e){this._remote("setPlaybackRate",e)}async loadSource(e){if(!F(e.src)){this._currentSrc=null,this._hash=null,this._videoId.set("");return}let{videoId:n,hash:i}=D_(e.src);this._videoId.set(n??""),this._hash=i??null,this._currentSrc=e}_watchVideoId(){this._reset();let e=this._videoId();if(!e){this._src.set("");return}this._src.set(`${this._getOrigin()}/video/${e}`),this._notify("load-start")}_watchVideoInfo(){let e=this._videoId();if(!e)return;let n=qi(),i=new AbortController;return this._videoInfoPromise=n,O_(e,i).then(r=>{n.resolve(r)}).catch(r=>{n.reject(),this._notify("error",{message:`Failed to fetch vimeo video info for id \`${e}\`.`,code:1,error:vi(r)})}),()=>{n.reject(),i.abort()}}_watchPro(){let e=this._pro(),{$state:n,qualities:i}=this._ctx;if(n.canSetPlaybackRate.set(e),i[Y._setReadonly](!e),e)return S(i,"change",()=>{if(i.auto)return;let r=i.selected?.id;r&&this._remote("setQuality",r)})}_getOrigin(){return"https://player.vimeo.com"}_buildParams(){let{$iosControls:e}=this._ctx,{keyDisabled:n}=this._ctx.$props,{controls:i,playsInline:r}=this._ctx.$state,s=i()||e();return{title:this.title,byline:this.byline,color:this.color,portrait:this.portrait,controls:s,h:this.hash,keyboard:s&&!n(),transparent:!0,playsinline:r(),dnt:!this.cookies}}_onAnimationFrame(){this._remote("getCurrentTime")}_onTimeUpdate(e,n){if(this._skipTimeUpdates&&e===0)return;let{realCurrentTime:i,realDuration:r,paused:s,bufferedEnd:a}=this._ctx.$state;if(i()===e)return;let o=i(),l={currentTime:e,played:this._getPlayedRange(e)};this._notify("time-update",l,n),Math.abs(o-e)>1.5&&(this._notify("seeking",e,n),!s()&&a(){this._skipTimeUpdates=!1},500))}_getPlayedRange(e){return this._played>=e?this._playedRange:this._playedRange=new oe(0,this._played=e)}_onSeeked(e,n){this._notify("seeked",e,n)}_onReady(e){let n=this._videoId();this._videoInfoPromise?.promise.then(i=>{if(!i)return;let{title:r,poster:s,duration:a,pro:o}=i,{$iosControls:l}=this._ctx,{controls:c}=this._ctx.$state,u=c()||l();this._pro.set(o),this._seekableRange=new oe(0,a),this._notify("title-change",r,e),this._notify("poster-change",s,e),this._notify("duration-change",a,e);let d={buffered:new oe(0,0),seekable:this._seekableRange,duration:a};this._ctx.delegate._ready(d,e),u||this._remote("_hideOverlay"),this._remote("getQualities"),this._remote("getChapters")}).catch(i=>{n===this._videoId()&&this._notify("error",{message:"Failed to fetch oembed data",code:2,error:vi(i)})})}_onMethod(e,n,i){switch(e){case"getCurrentTime":this._onTimeUpdate(n,i);break;case"getBuffered":He(n)&&n.length&&this._onLoadProgress(n[n.length-1][1],i);break;case"setMuted":this._onVolumeChange(C(this._ctx.$state.volume),n,i);break;case"getChapters":this._onChaptersChange(n);break;case"getQualities":this._onQualitiesChange(n,i);break}}_attachListeners(){for(let e of dD)this._remote("addEventListener",e)}_onPause(e){this._timeRAF._stop(),this._notify("pause",void 0,e),this._pausePromise?.resolve(),this._pausePromise=null}_onPlay(e){this._timeRAF._start(),this._notify("play",void 0,e),this._playPromise?.resolve(),this._playPromise=null}_onPlayProgress(e){let{paused:n}=this._ctx.$state;n()||this._notify("playing",void 0,e)}_onLoadProgress(e,n){let i={buffered:new oe(0,e),seekable:this._seekableRange};this._notify("progress",i,n)}_onBufferStart(e){this._notify("waiting",void 0,e)}_onBufferEnd(e){let{paused:n}=this._ctx.$state;n()||this._notify("playing",void 0,e)}_onWaiting(e){let{paused:n}=this._ctx.$state;n()&&this._notify("play",void 0,e),this._notify("waiting",void 0,e)}_onVolumeChange(e,n,i){let r={volume:e,muted:n};this._notify("volume-change",r,i)}_onChaptersChange(e){if(this._removeChapters(),!e.length)return;let n=new ln({kind:"chapters",default:!0}),{realDuration:i}=this._ctx.$state;for(let r=0;ri.id==="auto")?()=>{this._remote("setQuality","auto")}:void 0;for(let i of e){if(i.id==="auto")continue;let r=+i.id.slice(0,-1);isNaN(r)||this._ctx.qualities[Y._add]({id:i.id,width:r*(16/9),height:r,codec:"avc1,h.264",bitrate:-1},n)}this._onQualityChange(e.find(i=>i.active),n)}_onQualityChange({id:e}={},n){if(!e)return;let i=e==="auto",r=this._ctx.qualities.toArray().find(s=>s.id===e);i?(this._ctx.qualities[cn._setAuto](i,n),this._ctx.qualities[Y._select](void 0,!0,n)):this._ctx.qualities[Y._select](r,!0,n)}_onEvent(e,n,i){switch(e){case"ready":this._attachListeners();break;case"loaded":this._onReady(i);break;case"play":this._onPlay(i);break;case"playProgress":this._onPlayProgress(i);break;case"pause":this._onPause(i);break;case"loadProgress":this._onLoadProgress(n.seconds,i);break;case"waiting":this._onWaiting(i);break;case"bufferstart":this._onBufferStart(i);break;case"bufferend":this._onBufferEnd(i);break;case"volumechange":this._onVolumeChange(n.volume,C(this._ctx.$state.muted),i);break;case"durationchange":this._seekableRange=new oe(0,n.duration),this._notify("duration-change",n.duration,i);break;case"playbackratechange":this._notify("rate-change",n.playbackRate,i);break;case"qualitychange":this._onQualityChange(n,i);break;case"fullscreenchange":this._notify("fullscreen-change",n.fullscreen,i);break;case"enterpictureinpicture":this._notify("picture-in-picture-change",!0,i);break;case"leavepictureinpicture":this._notify("picture-in-picture-change",!1,i);break;case"ended":this._notify("end",void 0,i);break;case"error":this._onError(n,i);break;case"seek":case"seeked":this._onSeeked(n.seconds,i);break}}_onError(e,n){if(e.method==="setPlaybackRate"&&this._pro.set(!1),e.method==="play"){this._playPromise?.reject(e.message);return}}_onMessage(e,n){e.event?this._onEvent(e.event,e.data,n):e.method&&this._onMethod(e.method,e.value,n)}_onLoad(){}_remote(e,n){return this._postMessage({method:e,value:n})}_reset(){this._timeRAF._stop(),this._played=0,this._playedRange=new oe(0,0),this._seekableRange=new oe(0,0),this._playPromise=null,this._pausePromise=null,this._videoInfoPromise=null,this._currentCue=null,this._pro.set(!1),this._removeChapters()}}});var NS={};xt(NS,{findYouTubePoster:()=>hD,resolveYouTubeVideoId:()=>U_});function U_(t){return t.match(pD)?.[1]}async function hD(t,e){if(z_.has(t))return z_.get(t);if(ih.has(t))return ih.get(t);let n=new Promise(async i=>{let r=["maxresdefault","sddefault","hqdefault"];for(let s of r)for(let a of[!0,!1]){let o=fD(t,s,a);if((await fetch(o,{mode:"no-cors",signal:e.signal})).status<400){z_.set(t,o),i(o);return}}}).catch(()=>"").finally(()=>ih.delete(t));return ih.set(t,n),n}function fD(t,e,n){return`https://i.ytimg.com/${n?"vi_webp":"vi"}/${t}/${e}.${n?"webp":"jpg"}`}var pD,z_,ih,j_=Ue(()=>{"use strict";"use client";pD=/(?:youtu\.be|youtube|youtube\.com|youtube-nocookie\.com)\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=|)((?:\w|-){11})/,z_=new Map,ih=new Map});var DS={};xt(DS,{YouTubeProvider:()=>q_});var bU,ws,q_,OS=Ue(()=>{"use strict";"use client";Lt();Wt();A_();j_();bU=$(z(),1),ws={_Unstarted:-1,_Ended:0,_Playing:1,_Paused:2,_Buffering:3,_Cued:5},q_=class extends za{constructor(e,n){super(e),this._ctx=n,this.$$PROVIDER_TYPE="YOUTUBE",this.scope=$t(),this._videoId=D(""),this._state=-1,this._seekingTimer=-1,this._pausedSeeking=!1,this._played=0,this._playedRange=new oe(0,0),this._currentSrc=null,this._playPromise=null,this._pausePromise=null,this.language="en",this.color="red",this.cookies=!1}get _notify(){return this._ctx.delegate._notify}get currentSrc(){return this._currentSrc}get type(){return"youtube"}get videoId(){return this._videoId()}preconnect(){Jn(this._getOrigin())}setup(){super.setup(),b(this._watchVideoId.bind(this)),this._notify("provider-setup",this)}async play(){let{paused:e}=this._ctx.$state;return this._playPromise||(this._playPromise=Ua(()=>{if(this._playPromise=null,e())return"Timed out."}),this._remote("playVideo")),this._playPromise.promise}async pause(){let{paused:e}=this._ctx.$state;return this._pausePromise||(this._pausePromise=Ua(()=>{this._pausePromise=null,e()}),this._remote("pauseVideo")),this._pausePromise.promise}setMuted(e){e?this._remote("mute"):this._remote("unMute")}setCurrentTime(e){this._pausedSeeking=this._ctx.$state.paused(),this._remote("seekTo",e),this._notify("seeking",e)}setVolume(e){this._remote("setVolume",e*100)}setPlaybackRate(e){this._remote("setPlaybackRate",e)}async loadSource(e){if(!F(e.src)){this._currentSrc=null,this._videoId.set("");return}let n=U_(e.src);this._videoId.set(n??""),this._currentSrc=e}_getOrigin(){return this.cookies?"https://www.youtube.com":"https://www.youtube-nocookie.com"}_watchVideoId(){this._reset();let e=this._videoId();if(!e){this._src.set("");return}this._src.set(`${this._getOrigin()}/embed/${e}`),this._notify("load-start")}_buildParams(){let{keyDisabled:e}=this._ctx.$props,{$iosControls:n}=this._ctx,{controls:i,muted:r,playsInline:s}=this._ctx.$state,a=i()||n();return{autoplay:0,cc_lang_pref:this.language,cc_load_policy:a?1:void 0,color:this.color,controls:a?1:0,disablekb:!a||e()?1:0,enablejsapi:1,fs:1,hl:this.language,iv_load_policy:a?1:3,mute:r()?1:0,playsinline:s()?1:0}}_remote(e,n){this._postMessage({event:"command",func:e,args:n?[n]:void 0})}_onLoad(){window.setTimeout(()=>this._postMessage({event:"listening"}),100)}_onReady(e){this._notify("loaded-metadata"),this._notify("loaded-data"),this._ctx.delegate._ready(void 0,e)}_onPause(e){this._pausePromise?.resolve(),this._pausePromise=null,this._notify("pause",void 0,e)}_onTimeUpdate(e,n){let{duration:i,realCurrentTime:r}=this._ctx.$state,s=this._state===ws._Ended,a=s?i():e,o={currentTime:a,played:this._getPlayedRange(a)};this._notify("time-update",o,n),!s&&Math.abs(a-r())>1&&this._notify("seeking",a,n)}_getPlayedRange(e){return this._played>=e?this._playedRange:this._playedRange=new oe(0,this._played=e)}_onProgress(e,n,i){let r={buffered:new oe(0,e),seekable:n};this._notify("progress",r,i);let{seeking:s,realCurrentTime:a}=this._ctx.$state;s()&&e>a()&&this._onSeeked(i)}_onSeeked(e){let{paused:n,realCurrentTime:i}=this._ctx.$state;window.clearTimeout(this._seekingTimer),this._seekingTimer=window.setTimeout(()=>{this._notify("seeked",i(),e),this._seekingTimer=-1},n()?100:0),this._pausedSeeking=!1}_onEnded(e){let{seeking:n}=this._ctx.$state;n()&&this._onSeeked(e),this._notify("end",void 0,e)}_onStateChange(e,n){let{started:i,paused:r,seeking:s}=this._ctx.$state,a=e===ws._Playing,o=e===ws._Buffering,l=(r()||this._playPromise)&&(o||a);if(o&&this._notify("waiting",void 0,n),s()&&a&&this._onSeeked(n),!i()&&l&&this._pausedSeeking){this._playPromise?.reject("invalid internal play operation"),this._playPromise=null,a&&(this.pause(),this._pausedSeeking=!1);return}switch(l&&(this._playPromise?.resolve(),this._playPromise=null,this._notify("play",void 0,n)),e){case ws._Cued:this._onReady(n);break;case ws._Playing:this._notify("playing",void 0,n);break;case ws._Paused:this._onPause(n);break;case ws._Ended:this._onEnded(n);break}this._state=e}_onMessage({info:e},n){if(!e)return;let{title:i,intrinsicDuration:r,playbackRate:s}=this._ctx.$state;if(Bl(e.videoData)&&e.videoData.title!==i()&&this._notify("title-change",e.videoData.title,n),Be(e.duration)&&e.duration!==r()){if(Be(e.videoLoadedFraction)){let a=e.progressState?.loaded??e.videoLoadedFraction*e.duration,o=new oe(0,e.duration);this._onProgress(a,o,n)}this._notify("duration-change",e.duration,n)}if(Be(e.playbackRate)&&e.playbackRate!==s()&&this._notify("rate-change",e.playbackRate,n),e.progressState){let{current:a,seekableStart:o,seekableEnd:l,loaded:c,duration:u}=e.progressState;this._onTimeUpdate(a,n),this._onProgress(c,new oe(o,l),n),u!==r()&&this._notify("duration-change",u,n)}if(Be(e.volume)&&Gy(e.muted)){let a={muted:e.muted,volume:e.volume/100};this._notify("volume-change",a,n)}Be(e.playerState)&&e.playerState!==this._state&&this._onStateChange(e.playerState,n)}_reset(){this._state=-1,this._seekingTimer=-1,this._played=0,this._playedRange=new oe(0,0),this._playPromise=null,this._pausePromise=null,this._pausedSeeking=!1}}});var FS={};xt(FS,{GoogleCastProvider:()=>K_});var SU,B_,H_,VS,W_,K_,zS=Ue(()=>{"use strict";"use client";Lt();Wt();sc();Y_();SU=$(z(),1),B_=class{constructor(e){this._info=new chrome.cast.media.MediaInfo(e.src,e.type)}build(){return this._info}_setStreamType(e){return e.includes("live")?this._info.streamType=chrome.cast.media.StreamType.LIVE:this._info.streamType=chrome.cast.media.StreamType.BUFFERED,this}_setTracks(e){return this._info.tracks=e.map(this._buildCastTrack),this}_setMetadata(e,n){return this._info.metadata=new chrome.cast.media.GenericMediaMetadata,this._info.metadata.title=e,this._info.metadata.images=[{url:n}],this}_buildCastTrack(e,n){let i=new chrome.cast.media.Track(n,chrome.cast.media.TrackType.TEXT);return i.name=e.label,i.trackContentId=e.src,i.trackContentType="text/vtt",i.language=e.language,i.subtype=e.kind.toUpperCase(),i}},H_=chrome.cast.media.TrackType.TEXT,VS=chrome.cast.media.TrackType.AUDIO,W_=class{constructor(e,n,i){this._cast=e,this._ctx=n,this._onNewLocalTracks=i}_setup(){let e=this._syncRemoteActiveIds.bind(this);S(this._ctx.audioTracks,"change",e),S(this._ctx.textTracks,"mode-change",e),b(this._syncLocalTracks.bind(this))}_getLocalTextTracks(){return this._ctx.$state.textTracks().filter(e=>e.src&&e.type==="vtt")}_getLocalAudioTracks(){return this._ctx.$state.audioTracks()}_getRemoteTracks(e){let n=this._cast.mediaInfo?.tracks??[];return e?n.filter(i=>i.type===e):n}_getRemoteActiveIds(){let e=[],n=this._getLocalAudioTracks().find(r=>r.selected),i=this._getLocalTextTracks().filter(r=>r.mode==="showing");if(n){let r=this._getRemoteTracks(VS),s=this._findRemoteTrack(r,n);s&&e.push(s.trackId)}if(i?.length){let r=this._getRemoteTracks(H_);if(r.length)for(let s of i){let a=this._findRemoteTrack(r,s);a&&e.push(a.trackId)}}return e}_syncLocalTracks(){let e=this._getLocalTextTracks();if(!this._cast.isMediaLoaded)return;let n=this._getRemoteTracks(H_);for(let i of e)if(!this._findRemoteTrack(n,i)){La(()=>this._onNewLocalTracks?.());break}}_syncRemoteTracks(e){if(!this._cast.isMediaLoaded)return;let n=this._getLocalAudioTracks(),i=this._getLocalTextTracks(),r=this._getRemoteTracks(VS),s=this._getRemoteTracks(H_);for(let a of r){if(this._findLocalTrack(n,a))continue;let l={id:a.trackId.toString(),label:a.name,language:a.language,kind:a.subtype??"main",selected:!1};this._ctx.audioTracks[Y._add](l,e)}for(let a of s){if(this._findLocalTrack(i,a))continue;let l={id:a.trackId.toString(),src:a.trackContentId,label:a.name,language:a.language,kind:a.subtype.toLowerCase()};this._ctx.textTracks.add(l,e)}}_syncRemoteActiveIds(e){if(!this._cast.isMediaLoaded)return;let n=this._getRemoteActiveIds(),i=new chrome.cast.media.EditTracksInfoRequest(n);this._editTracksInfo(i).catch(r=>{})}_editTracksInfo(e){let n=cc();return new Promise((i,r)=>n?.editTracksInfo(e,i,r))}_findLocalTrack(e,n){return e.find(i=>this._isMatch(i,n))}_findRemoteTrack(e,n){return e.find(i=>this._isMatch(n,i))}_isMatch(e,n){return n.name===e.label&&n.language===e.language&&n.subtype.toLowerCase()===e.kind.toLowerCase()}},K_=class{constructor(e,n){this._player=e,this._ctx=n,this.$$PROVIDER_TYPE="GOOGLE_CAST",this.scope=$t(),this._currentSrc=null,this._state="disconnected",this._currentTime=0,this._played=0,this._playedRange=new oe(0,0),this._seekableRange=new oe(0,0),this._timeRAF=new gi(this._onAnimationFrame.bind(this)),this._reloadInfo=null,this._isIdle=!1,this._tracks=new W_(this._player,this._ctx,this._onNewLocalTracks.bind(this))}get _notify(){return this._ctx.delegate._notify}get type(){return"google-cast"}get currentSrc(){return this._currentSrc}get player(){return this._player}get cast(){return bs()}get session(){return lc()}get media(){return cc()}get hasActiveSession(){return rh(this._currentSrc)}setup(){this._attachCastContextEventListeners(),this._attachCastPlayerEventListeners(),this._tracks._setup(),this._notify("provider-setup",this)}_attachCastContextEventListeners(){G_(cast.framework.CastContextEventType.CAST_STATE_CHANGED,this._onCastStateChange.bind(this))}_attachCastPlayerEventListeners(){let e=cast.framework.RemotePlayerEventType,n={[e.IS_CONNECTED_CHANGED]:this._onCastStateChange,[e.IS_MEDIA_LOADED_CHANGED]:this._onMediaLoadedChange,[e.CAN_CONTROL_VOLUME_CHANGED]:this._onCanControlVolumeChange,[e.CAN_SEEK_CHANGED]:this._onCanSeekChange,[e.DURATION_CHANGED]:this._onDurationChange,[e.IS_MUTED_CHANGED]:this._onVolumeChange,[e.VOLUME_LEVEL_CHANGED]:this._onVolumeChange,[e.IS_PAUSED_CHANGED]:this._onPausedChange,[e.LIVE_SEEKABLE_RANGE_CHANGED]:this._onProgress,[e.PLAYER_STATE_CHANGED]:this._onPlayerStateChange};this._playerEventHandlers=n;let i=this._onRemotePlayerEvent.bind(this);for(let r of Ql(n))this._player.controller.addEventListener(r,i);G(()=>{for(let r of Ql(n))this._player.controller.removeEventListener(r,i)})}async play(){if(!(!this._player.isPaused&&!this._isIdle)){if(this._isIdle){await this._reload(!1,0);return}this._player.controller?.playOrPause()}}async pause(){this._player.isPaused||this._player.controller?.playOrPause()}getMediaStatus(e){return new Promise((n,i)=>{this.media?.getStatus(e,n,i)})}setMuted(e){(e&&!this._player.isMuted||!e&&this._player.isMuted)&&this._player.controller?.muteOrUnmute()}setCurrentTime(e){this._player.currentTime=e,this._notify("seeking",e),this._player.controller?.seek()}setVolume(e){this._player.volumeLevel=e,this._player.controller?.setVolumeLevel()}async loadSource(e){if(this._reloadInfo?.src!==e&&(this._reloadInfo=null),rh(e)){this._resumeSession(),this._currentSrc=e;return}this._notify("load-start");let n=this._buildLoadRequest(e),i=await this.session.loadMedia(n);if(i){this._currentSrc=null,this._notify("error",Error(sh(i)));return}this._currentSrc=e}destroy(){this._reset(),this._endSession()}_reset(){this._reloadInfo||(this._played=0,this._playedRange=new oe(0,0),this._seekableRange=new oe(0,0)),this._timeRAF._stop(),this._currentTime=0,this._reloadInfo=null}_resumeSession(){let e=new j("resume-session",{detail:this.session});this._onMediaLoadedChange(e);let{muted:n,volume:i,remotePlaybackInfo:r}=this._ctx.$state,s=r();this.setCurrentTime(Math.max(this._player.currentTime,s?.savedState?.currentTime??0)),this.setMuted(n()),this.setVolume(i()),s?.savedState?.paused===!1&&this.play()}_endSession(){this.cast.endCurrentSession(!0);let{remotePlaybackLoader:e}=this._ctx.$state;e.set(null)}_disconnectFromReceiver(){this._ctx.$state.remotePlaybackInfo.set({savedState:{paused:this._player.isPaused,currentTime:this._player.currentTime}}),this._endSession()}_onAnimationFrame(){this._onCurrentTimeChange()}_onRemotePlayerEvent(e){this._playerEventHandlers[e.type].call(this,e)}_onCastStateChange(e){let n=this.cast.getCastState(),i=n===cast.framework.CastState.CONNECTED?"connected":n===cast.framework.CastState.CONNECTING?"connecting":"disconnected";if(this._state===i)return;let r={type:"google-cast",state:i},s=this._createEvent(e);this._state=i,this._notify("remote-playback-change",r,s),i==="disconnected"&&this._disconnectFromReceiver()}_onMediaLoadedChange(e){if(!!!this._player.isMediaLoaded)return;let i=C(this._ctx.$state.source);Promise.resolve().then(()=>{if(i!==C(this._ctx.$state.source)||!this._player.isMediaLoaded)return;this._reset();let r=this._player.duration;this._seekableRange=new oe(0,r);let s={provider:this,duration:r,buffered:this._playedRange,seekable:this._getSeekableRange()},a=this._createEvent(e);this._notify("loaded-metadata",void 0,a),this._notify("loaded-data",void 0,a),this._notify("can-play",s,a),this._onCanControlVolumeChange(),this._onCanSeekChange(e);let{volume:o,muted:l}=this._ctx.$state;this.setVolume(o()),this.setMuted(l()),this._timeRAF._start(),this._tracks._syncRemoteTracks(a),this._tracks._syncRemoteActiveIds(a)})}_onCanControlVolumeChange(){this._ctx.$state.canSetVolume.set(this._player.canControlVolume)}_onCanSeekChange(e){let n=this._createEvent(e);this._notify("stream-type-change",this._getStreamType(),n)}_getStreamType(){return this._player.mediaInfo?.streamType===chrome.cast.media.StreamType.LIVE?this._player.canSeek?"live:dvr":"live":"on-demand"}_onCurrentTimeChange(){if(this._reloadInfo)return;let e=this._player.currentTime;if(e===this._currentTime)return;let n=this._played,i=this._getPlayedRange(e),r={currentTime:e,played:i};this._notify("time-update",r),e>n&&this._onProgress(),this._ctx.$state.seeking()&&this._notify("seeked",e),this._currentTime=e}_getPlayedRange(e){return this._played>=e?this._playedRange:this._playedRange=new oe(0,this._played=e)}_onDurationChange(e){if(!this._player.isMediaLoaded||this._reloadInfo)return;let n=this._player.duration,i=this._createEvent(e);this._seekableRange=new oe(0,n),this._notify("duration-change",n,i)}_onVolumeChange(e){if(!this._player.isMediaLoaded)return;let n={muted:this._player.isMuted,volume:this._player.volumeLevel},i=this._createEvent(e);this._notify("volume-change",n,i)}_onPausedChange(e){let n=this._createEvent(e);this._player.isPaused?this._notify("pause",void 0,n):this._notify("play",void 0,n)}_onProgress(e){let n={seekable:this._getSeekableRange(),buffered:this._playedRange},i=e?this._createEvent(e):void 0;this._notify("progress",n,i)}_onPlayerStateChange(e){let n=this._player.playerState,i=chrome.cast.media.PlayerState;if(this._isIdle=n===i.IDLE,n===i.PAUSED)return;let r=this._createEvent(e);switch(n){case i.PLAYING:this._notify("playing",void 0,r);break;case i.BUFFERING:this._notify("waiting",void 0,r);break;case i.IDLE:this._timeRAF._stop(),this._notify("pause"),this._notify("end");break}}_getSeekableRange(){return this._player.liveSeekableRange?new oe(this._player.liveSeekableRange.start,this._player.liveSeekableRange.end):this._seekableRange}_createEvent(e){return e instanceof Event?e:new j(e.type,{detail:e})}_buildMediaInfo(e){let{streamType:n,title:i,poster:r}=this._ctx.$state;return new B_(e)._setMetadata(i(),r())._setStreamType(n())._setTracks(this._tracks._getLocalTextTracks()).build()}_buildLoadRequest(e){let n=this._buildMediaInfo(e),i=new chrome.cast.media.LoadRequest(n),r=this._ctx.$state.remotePlaybackInfo();return i.autoplay=(this._reloadInfo?.paused??r?.savedState?.paused)===!1,i.currentTime=this._reloadInfo?.time??r?.savedState?.currentTime??0,i}async _reload(e,n){let i=C(this._ctx.$state.source);this._reloadInfo={src:i,paused:e,time:n},await this.loadSource(i)}_onNewLocalTracks(){this._reload(this._player.isPaused,this._player.currentTime).catch(e=>{})}}});var jS={};xt(jS,{a:()=>bs,b:()=>lc,c:()=>sh,d:()=>_D,g:()=>cc,h:()=>rh,l:()=>G_});function mD(){return"https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"}function gD(){return!!window.cast?.framework}function vD(){return!!window.chrome?.cast?.isAvailable}function US(){return bs().getCastState()===cast.framework.CastState.CONNECTED}function bs(){return window.cast.framework.CastContext.getInstance()}function lc(){return bs().getCurrentSession()}function cc(){return lc()?.getSessionObj().media[0]}function rh(t){return cc()?.media.contentId===t?.src}function yD(){return{language:"en-US",autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,resumeSavedSession:!0,androidReceiverCompatible:!0}}function sh(t){return`Google Cast Error Code: ${t}`}function G_(t,e){return qS(bs(),t,e)}var Q_,_D,Y_=Ue(()=>{"use strict";"use client";Wt();Lt();Q_=class{constructor(){this.name="google-cast"}get cast(){return bs()}mediaType(){return"video"}canPlay(e){return oc&&!ah&&oh(e)}async prompt(e){let n;try{let i=await this._loadCastFramework(e);this._player||(this._player=new cast.framework.RemotePlayer,new cast.framework.RemotePlayerController(this._player)),n=e.player.createEvent("google-cast-prompt-open",{trigger:i}),e.player.dispatchEvent(n),this._notifyRemoteStateChange(e,"connecting",n),await this._showPrompt(C(e.$props.googleCast)),e.$state.remotePlaybackInfo.set({deviceName:lc()?.getCastDevice().friendlyName}),US()&&this._notifyRemoteStateChange(e,"connected",n)}catch(i){let r=vi(i);throw this._notifyRemoteStateChange(e,US()?"connected":"disconnected",new j("google-cast-prompt-error",{detail:r})),r}finally{e.player.dispatch("google-cast-prompt-close",{trigger:n})}}async load(e){if(N)throw Error("[vidstack] can not load google cast provider server-side");if(!this._player)throw Error("[vidstack] google cast player was not initialized");return new(await Promise.resolve().then(()=>(zS(),FS))).GoogleCastProvider(this._player,e)}async _loadCastFramework(e){if(gD())return;let n=e.player.createEvent("google-cast-load-start");e.player.dispatch(n),await th(mD()),await customElements.whenDefined("google-cast-launcher");let i=e.player.createEvent("google-cast-loaded",{trigger:n});if(e.player.dispatch(i),!vD())throw Error("Cast not available.");return i}async _showPrompt(e){this._setOptions(e);let n=await this.cast.requestSession();if(n)throw Error(sh(n))}_setOptions(e){this.cast?.setOptions({...yD(),...e})}_notifyRemoteStateChange(e,n,i){let r={type:"google-cast",state:n};e.delegate._notify("remote-playback-change",r,i)}},_D=Object.freeze({__proto__:null,GoogleCastLoader:Q_})});function hP(){return hh}function X_(t){if(xs.fullscreenElement===t)return!0;try{return t.matches(xs.fullscreenPseudoClass)}catch{return!1}}function GS(){if(!hh)throw Error("[vidstack] no fullscreen API")}function bw(){return fP()&&yt(screen.orientation.unlock)}function fP(){return!N&&!Ie(window.screen.orientation)&&!Ie(window.screen.orientation.lock)}function LD(t,e){return N?!1:(t||(t=document.createElement("audio")),t.canPlayType(e).length>0)}function ID(t,e){return N?!1:(t||(t=document.createElement("video")),t.canPlayType(e).length>0)}function Qp(t){return N?!1:(t||(t=document.createElement("video")),t.canPlayType("application/vnd.apple.mpegurl").length>0)}function Xp(t){return N?!1:!!document.pictureInPictureEnabled&&!t?.disablePictureInPicture}function Zp(t){return N?!1:yt(t?.webkitSupportsPresentationMode)&&yt(t?.webkitSetPresentationMode)}async function mP(){let t=document.createElement("video");return t.volume=.5,await t_(0),t.volume===.5}function AD(){return N?void 0:window?.ManagedMediaSource??window?.MediaSource??window?.WebKitMediaSource}function ND(){return N?void 0:window?.SourceBuffer??window?.WebKitSourceBuffer}function eh(){if(N)return!1;let t=AD();if(Ie(t))return!1;let e=t&&yt(t.isTypeSupported)&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),n=ND(),i=Ie(n)||!Ie(n.prototype)&&yt(n.prototype.appendBuffer)&&yt(n.prototype.remove);return!!e&&!!i}function tw(t){if(!t.length)return null;let e=t.start(0);for(let n=1;ne&&(e=i)}return e}function RS(t,e){let n=new URLSearchParams;for(let i of Object.keys(e))n.set(i,e[i]+"");return t+"?"+n.toString()}function Jn(t,e="preconnect"){if(N)return!1;let n=document.querySelector(`link[href="${t}"]`);if(!fi(n))return!0;let i=document.createElement("link");return i.rel=e,i.href=t,i.crossOrigin="true",document.head.append(i),!0}function th(t){if(lh[t])return lh[t].promise;let e=qi(),n=document.querySelector(`script[src="${t}"]`);if(!fi(n))return e.resolve(),e.promise;let i=document.createElement("script");return i.src=t,i.onload=()=>{e.resolve(),delete lh[t]},i.onerror=()=>{e.reject(),delete lh[t]},setTimeout(()=>document.head.append(i),0),e.promise}function mh(t){return t==="use-credentials"?"include":F(t)?"same-origin":void 0}function gh(t,e){return e>=t.startTime&&es.includes(o.kind)&&o.mode==="showing");if(a!==i){if(!a){n(null),i=null;return}a.readyState==2?n(a):(n(null),a.addEventListener("load",()=>n(a),{once:!0})),i=a}}return r(),S(t,"mode-change",r)}function We(t){return qD.test(t.kind)}function yP(t,e,n){let i=F(t)?JSON.parse(t):t,r=[],s=[];return i.regions&&n&&(r=i.regions.map(a=>Object.assign(new n,a))),(i.cues||He(i))&&(s=(He(i)?i:i.cues).filter(a=>Be(a.startTime)&&Be(a.endTime)).map(a=>Object.assign(new e(0,0,""),a))),{regions:r,cues:s}}function _P(t){Ls.reset(t,e=>HD.has(e)),Zn()}function le(){return Ae(tu)}function wP(t){return t.split("-")[0]}function BD(t){return t.split("-")[1]}function WD(t){return t==="x"?"y":"x"}function KD(t){return t==="y"?"height":"width"}function bP(t){return["top","bottom"].includes(wP(t))?"y":"x"}function GD(t){return WD(bP(t))}function xP(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}function JS(t,e,n){let{reference:i,floating:r}=t,s=bP(e),a=GD(e),o=KD(a),l=wP(e),c=s==="y",u=i.x+i.width/2-r.width/2,d=i.y+i.height/2-r.height/2,p=i[o]/2-r[o]/2,h;switch(l){case"top":h={x:u,y:i.y-r.height};break;case"bottom":h={x:u,y:i.y+i.height};break;case"right":h={x:i.x+i.width,y:d};break;case"left":h={x:i.x-r.width,y:d};break;default:h={x:i.x,y:i.y}}switch(BD(e)){case"start":h[a]-=p*(n&&c?-1:1);break;case"end":h[a]+=p*(n&&c?-1:1);break}return h}function Ar(t){return kP(t)?(t.nodeName||"").toLowerCase():"#document"}function dn(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Ji(t){var e;return(e=(kP(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function kP(t){return t instanceof Node||t instanceof dn(t).Node}function Gi(t){return t instanceof Element||t instanceof dn(t).Element}function yi(t){return t instanceof HTMLElement||t instanceof dn(t).HTMLElement}function eP(t){return typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof dn(t).ShadowRoot}function nu(t){let{overflow:e,overflowX:n,overflowY:i,display:r}=Cn(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+n)&&!["inline","contents"].includes(r)}function QD(t){return["table","td","th"].includes(Ar(t))}function kw(t){let e=Ew(),n=Cn(t);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(i=>(n.willChange||"").includes(i))||["paint","layout","strict","content"].some(i=>(n.contain||"").includes(i))}function EP(t){let e=Wa(t);for(;yi(e)&&!nf(e);){if(kw(e))return e;e=Wa(e)}return null}function Ew(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function nf(t){return["html","body","#document"].includes(Ar(t))}function Cn(t){return dn(t).getComputedStyle(t)}function rf(t){return Gi(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function Wa(t){if(Ar(t)==="html")return t;let e=t.assignedSlot||t.parentNode||eP(t)&&t.host||Ji(t);return eP(e)?e.host:e}function TP(t){let e=Wa(t);return nf(e)?t.ownerDocument?t.ownerDocument.body:t.body:yi(e)&&nu(e)?e:TP(e)}function hc(t,e,n){var i;e===void 0&&(e=[]),n===void 0&&(n=!0);let r=TP(t),s=r===((i=t.ownerDocument)==null?void 0:i.body),a=dn(r);return s?e.concat(a,a.visualViewport||[],nu(r)?r:[],a.frameElement&&n?hc(a.frameElement):[]):e.concat(r,hc(r,[],n))}function SP(t){let e=Cn(t),n=parseFloat(e.width)||0,i=parseFloat(e.height)||0,r=yi(t),s=r?t.offsetWidth:n,a=r?t.offsetHeight:i,o=vh(n)!==s||vh(i)!==a;return o&&(n=s,i=a),{width:n,height:i,$:o}}function Tw(t){return Gi(t)?t:t.contextElement}function qa(t){let e=Tw(t);if(!yi(e))return Ir(1);let n=e.getBoundingClientRect(),{width:i,height:r,$:s}=SP(e),a=(s?vh(n.width):n.width)/i,o=(s?vh(n.height):n.height)/r;return(!a||!Number.isFinite(a))&&(a=1),(!o||!Number.isFinite(o))&&(o=1),{x:a,y:o}}function PP(t){let e=dn(t);return!Ew()||!e.visualViewport?XD:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function ZD(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==dn(t)?!1:e}function ks(t,e,n,i){e===void 0&&(e=!1),n===void 0&&(n=!1);let r=t.getBoundingClientRect(),s=Tw(t),a=Ir(1);e&&(i?Gi(i)&&(a=qa(i)):a=qa(t));let o=ZD(s,n,i)?PP(s):Ir(0),l=(r.left+o.x)/a.x,c=(r.top+o.y)/a.y,u=r.width/a.x,d=r.height/a.y;if(s){let p=dn(s),h=i&&Gi(i)?dn(i):i,y=p.frameElement;for(;y&&i&&h!==p;){let v=qa(y),_=y.getBoundingClientRect(),m=Cn(y),f=_.left+(y.clientLeft+parseFloat(m.paddingLeft))*v.x,g=_.top+(y.clientTop+parseFloat(m.paddingTop))*v.y;l*=v.x,c*=v.y,u*=v.x,d*=v.y,l+=f,c+=g,y=dn(y).frameElement}}return xP({width:u,height:d,x:l,y:c})}function CP(t){let e=!1,n=0,i=0;function r(a){try{e=e||t.matches(a)}catch{}}JD.forEach(a=>{r(a)});let s=EP(t);if(e&&s){let a=s.getBoundingClientRect();n=a.x,i=a.y}return[e,n,i]}function eO(t){let{elements:e,rect:n,offsetParent:i,strategy:r}=t,s=Ji(i),[a]=e?CP(e.floating):[!1];if(i===s||a)return n;let o={scrollLeft:0,scrollTop:0},l=Ir(1),c=Ir(0),u=yi(i);if((u||!u&&r!=="fixed")&&((Ar(i)!=="body"||nu(s))&&(o=rf(i)),yi(i))){let d=ks(i);l=qa(i),c.x=d.x+i.clientLeft,c.y=d.y+i.clientTop}return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-o.scrollLeft*l.x+c.x,y:n.y*l.y-o.scrollTop*l.y+c.y}}function tO(t){return Array.from(t.getClientRects())}function $P(t){return ks(Ji(t)).left+rf(t).scrollLeft}function nO(t){let e=Ji(t),n=rf(t),i=t.ownerDocument.body,r=ja(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),s=ja(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight),a=-n.scrollLeft+$P(t),o=-n.scrollTop;return Cn(i).direction==="rtl"&&(a+=ja(e.clientWidth,i.clientWidth)-r),{width:r,height:s,x:a,y:o}}function iO(t,e){let n=dn(t),i=Ji(t),r=n.visualViewport,s=i.clientWidth,a=i.clientHeight,o=0,l=0;if(r){s=r.width,a=r.height;let c=Ew();(!c||c&&e==="fixed")&&(o=r.offsetLeft,l=r.offsetTop)}return{width:s,height:a,x:o,y:l}}function rO(t,e){let n=ks(t,!0,e==="fixed"),i=n.top+t.clientTop,r=n.left+t.clientLeft,s=yi(t)?qa(t):Ir(1),a=t.clientWidth*s.x,o=t.clientHeight*s.y,l=r*s.x,c=i*s.y;return{width:a,height:o,x:l,y:c}}function tP(t,e,n){let i;if(e==="viewport")i=iO(t,n);else if(e==="document")i=nO(Ji(t));else if(Gi(e))i=rO(e,n);else{let r=PP(t);i={...e,x:e.x-r.x,y:e.y-r.y}}return xP(i)}function MP(t,e){let n=Wa(t);return n===e||!Gi(n)||nf(n)?!1:Cn(n).position==="fixed"||MP(n,e)}function sO(t,e){let n=e.get(t);if(n)return n;let i=hc(t,[],!1).filter(o=>Gi(o)&&Ar(o)!=="body"),r=null,s=Cn(t).position==="fixed",a=s?Wa(t):t;for(;Gi(a)&&!nf(a);){let o=Cn(a),l=kw(a);!l&&o.position==="fixed"&&(r=null),(s?!l&&!r:!l&&o.position==="static"&&!!r&&["absolute","fixed"].includes(r.position)||nu(a)&&!l&&MP(t,a))?i=i.filter(u=>u!==a):r=o,a=Wa(a)}return e.set(t,i),i}function aO(t){let{element:e,boundary:n,rootBoundary:i,strategy:r}=t,a=[...n==="clippingAncestors"?sO(e,this._c):[].concat(n),i],o=a[0],l=a.reduce((c,u)=>{let d=tP(e,u,r);return c.top=ja(d.top,c.top),c.right=iw(d.right,c.right),c.bottom=iw(d.bottom,c.bottom),c.left=ja(d.left,c.left),c},tP(e,o,r));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function oO(t){let{width:e,height:n}=SP(t);return{width:e,height:n}}function lO(t,e,n,i){let r=yi(e),s=Ji(e),a=n==="fixed",o=ks(t,!0,a,e),l={scrollLeft:0,scrollTop:0},c=Ir(0);if(r||!r&&!a)if((Ar(e)!=="body"||nu(s))&&(l=rf(e)),r){let v=ks(e,!0,a,e);c.x=v.x+e.clientLeft,c.y=v.y+e.clientTop}else s&&(c.x=$P(s));let u=o.left+l.scrollLeft-c.x,d=o.top+l.scrollTop-c.y,[p,h,y]=CP(i);return p&&(u+=h,d+=y,r&&(u+=e.clientLeft,d+=e.clientTop)),{x:u,y:d,width:o.width,height:o.height}}function nP(t,e){return!yi(t)||Cn(t).position==="fixed"?null:e?e(t):t.offsetParent}function RP(t,e){let n=dn(t);if(!yi(t))return n;let i=nP(t,e);for(;i&&QD(i)&&Cn(i).position==="static";)i=nP(i,e);return i&&(Ar(i)==="html"||Ar(i)==="body"&&Cn(i).position==="static"&&!kw(i))?n:i||EP(t)||n}function uO(t){return Cn(t).direction==="rtl"}function pO(t,e){let n=null,i,r=Ji(t);function s(){var o;clearTimeout(i),(o=n)==null||o.disconnect(),n=null}function a(o,l){o===void 0&&(o=!1),l===void 0&&(l=1),s();let{left:c,top:u,width:d,height:p}=t.getBoundingClientRect();if(o||e(),!d||!p)return;let h=ch(u),y=ch(r.clientWidth-(c+d)),v=ch(r.clientHeight-(u+p)),_=ch(c),f={rootMargin:-h+"px "+-y+"px "+-v+"px "+-_+"px",threshold:ja(0,iw(1,l))||1},g=!0;function x(T){let L=T[0].intersectionRatio;if(L!==l){if(!g)return a();L?a(!1,L):i=setTimeout(()=>{a(!1,1e-7)},100)}g=!1}try{n=new IntersectionObserver(x,{...f,root:r.ownerDocument})}catch{n=new IntersectionObserver(x,f)}n.observe(t)}return a(!0),s}function hO(t,e,n,i){i===void 0&&(i={});let{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:o=typeof IntersectionObserver=="function",animationFrame:l=!1}=i,c=Tw(t),u=r||s?[...c?hc(c):[],...hc(e)]:[];u.forEach(m=>{r&&m.addEventListener("scroll",n,{passive:!0}),s&&m.addEventListener("resize",n)});let d=c&&o?pO(c,n):null,p=-1,h=null;a&&(h=new ResizeObserver(m=>{let[f]=m;f&&f.target===c&&h&&(h.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var g;(g=h)==null||g.observe(e)})),n()}),c&&!l&&h.observe(c),h.observe(e));let y,v=l?ks(t):null;l&&_();function _(){let m=ks(t);v&&(m.x!==v.x||m.y!==v.y||m.width!==v.width||m.height!==v.height)&&n(),v=m,y=requestAnimationFrame(_)}return n(),()=>{var m;u.forEach(f=>{r&&f.removeEventListener("scroll",n),s&&f.removeEventListener("resize",n)}),d?.(),(m=h)==null||m.disconnect(),h=null,l&&cancelAnimationFrame(y)}}function qS(t,e,n){if(t)return S(t,e,n)}function ve(t,e,n){t.hasAttribute(e)||t.setAttribute(e,n)}function Or(t,e){if(t.hasAttribute("aria-label")||t.hasAttribute("data-no-label"))return;function n(){Z(t,"aria-label",e())}N?n():b(n)}function LP(t,e,n){for(;e;){if(e===t)return!0;if(n?.(e))break;e=e.parentElement}return!1}function Nr(t,e){S(t,"pointerup",n=>{n.button===0&&e(n)}),S(t,"keydown",n=>{Kl(n)&&e(n)})}function Sw(t){return Ia(t)&&(t.touches.length>1||t.changedTouches.length>1)}function yh(t){if(N)return t();let e=jl(),n=window.requestAnimationFrame(()=>{et(t,e),n=-1});return()=>void window.cancelAnimationFrame(n)}function IP(t,e,n,{offsetVarName:i,xOffset:r,yOffset:s,...a}){if(!t)return;let o=n.replace(" ","-").replace("-center","");if(lt(t,"visibility",e?null:"hidden"),!e)return;let l=u=>n.includes("left")?`calc(-1 * ${u})`:u,c=u=>n.includes("top")?`calc(-1 * ${u})`:u;return hO(e,t,()=>{fO(e,t,{placement:o,...a}).then(({x:u,y:d})=>{Object.assign(t.style,{top:`calc(${d+"px"} + ${c(s?s+"px":`var(--${i}-y-offset, 0px)`)})`,left:`calc(${u+"px"} + ${l(r?r+"px":`var(--${i}-x-offset, 0px)`)})`})})})}function mO(t){return getComputedStyle(t).animationName!=="none"}function gO(t,e,n){var i=null,r=null,s=n&&n.leading,a=n&&n.trailing;s==null&&(s=!0),a==null&&(a=!s),s==!0&&(a=!1);var o=function(){i&&(clearTimeout(i),i=null)},l=function(){var u=r;o(),u&&u()},c=function(){var u=s&&!i,d=this,p=arguments;if(r=function(){return t.apply(d,p)},i||(i=setTimeout(function(){if(i=null,a)return r()},e)),u)return u=!1,r()};return c.cancel=o,c.flush=l,c}function vO(t,e,n){var i=null,r=null,s=function(){i&&(clearTimeout(i),r=null,i=null)},a=function(){var l=r;s(),l&&l()},o=function(){if(!e)return t.apply(this,arguments);var l=this,c=arguments,u=n&&!i;if(s(),r=function(){t.apply(l,c)},i=setTimeout(function(){if(i=null,!u){var d=r;return r=null,d()}},e),u)return r()};return o.cancel=s,o.flush=a,o}function to(t){return t?.$$PROVIDER_TYPE==="VIDEO"}function AP(t){return!N&&t instanceof HTMLAudioElement}function NP(t){return!N&&t instanceof HTMLVideoElement}function DP(t){return AP(t)||NP(t)}function xO(t){return t.replace(/Shift\+(\d)/g,(e,n)=>bO[n-1])}function Cw({src:t,type:e}){return F(t)?VP.test(t)||FP.has(e)||t.startsWith("blob:")&&e==="audio/object":e==="audio/object"}function $w(t){return F(t.src)?zP.test(t.src)||UP.has(t.type)||t.src.startsWith("blob:")&&t.type==="video/object"||_s(t)&&(N||Qp()):t.type==="video/object"}function _s({src:t,type:e}){return F(t)&&jP.test(t)||qP.has(e)}function oh(t){return F(t.src)&&(Cw(t)||$w(t)||_s(t))}function x_(t){return!N&&typeof window.MediaStream<"u"&&t instanceof window.MediaStream}function vi(t){return t instanceof Error?t:Error(JSON.stringify(t))}function Wi(t,e){if(!t)throw Error(e||"Assertion failed.")}function J_(t,e){if(!(t&&e))throw Error("[vidstack] media not ready")}function sP(t,e){if(!e?.supported)throw Error("[vidstack] no fullscreen support")}function At(t,e=2){return Number(t.toFixed(e))}function Yp(t){return String(t).split(".")[1]?.length??0}function Mw(t,e,n){return Math.max(t,Math.min(n,e))}function uh(t,e){Z(t,"data-focus",e),Z(t,"data-hocus",e)}function aP(t,e){Z(t,"data-hocus",e),Z(t,"data-hover",e)}function KP(t,e){return fetch(t,e).then(n=>n.text()).then(n=>{let i=MO(n);if(i)return KP(/^https?:/.test(i)?i:new URL(i,t).href,e);let r=/EXT-X-PLAYLIST-TYPE:\s*VOD/.test(n)?"on-demand":"live";return r==="live"&&RO(n)>=10&&(/#EXT-X-DVR-ENABLED:\s*true/.test(n)||n.includes("#EXT-X-DISCONTINUITY"))?"live:dvr":r})}function MO(t){let e=t.match(/#EXT-X-STREAM-INF:[^\n]+(\n[^\n]+)*/g);return e?e[0].split(` -`)[1].trim():null}function RO(t){let e=t.split(` -`);for(let n of e)if(n.startsWith("#EXT-X-TARGETDURATION")){let i=parseFloat(n.split(":")[1]);if(!isNaN(i))return i}return-1}function oP(t){return(He(t)?t:[!F(t)&&"src"in t?t:{src:t}]).map(({src:e,type:n,...i})=>({src:e,type:n??(F(e)?GP.get(e):null)??(!F(e)||e.startsWith("blob:")?"video/object":e.includes("youtube")?"video/youtube":e.includes("vimeo")?"video/vimeo":"?"),...i})).sort(e=>e.type==="?"?1:-1)}function lP(t,e){return t?.src===e?.src&&t?.type===e?.type}function FO(t){return t?"true":"false"}function Gt(t){return()=>FO(t())}function cP(t,e,n){let i=e-t,r=n-t;return i>0?r/i:0}function zO(t,e,n,i){return Mw(t,At(n,Yp(i)),e)}function UO(t,e,n,i){let r=Mw(0,n,1),s=e-t,a=s*r,o=a/i,l=i*o;return t+l}function ew(t,e){let n=String(t),i=n.length;if(i=3600?ew(s,2):s,c=ew(a,2);return r>0||i?`${o}:${l}:${c}`:`${l}:${c}`}function yc(t){let e=[],{hours:n,minutes:i,seconds:r}=YP(t);return n>0&&e.push(`${n} hour`),i>0&&e.push(`${i} min`),(r>0||e.length===0)&&e.push(`${r} sec`),e.join(" ")}function Rw(t,{clamp:e,offset:n,orientation:i}){let r=getComputedStyle(t),s=parseFloat(r.width),a=parseFloat(r.height),o={top:null,right:null,bottom:null,left:null};if(o[i==="horizontal"?"bottom":"left"]=`calc(100% + var(--media-slider-preview-offset, ${n}px))`,i==="horizontal"){let l=s/2;if(!e)o.left=`calc(var(--slider-pointer) - ${l}px)`;else{let c=`max(0px, calc(var(--slider-pointer) - ${l}px))`,u=`calc(100% - ${s}px)`;o.left=`min(${c}, ${u})`}}else{let l=a/2;if(!e)o.bottom=`calc(var(--slider-pointer) - ${l}px)`;else{let c=`max(${l}px, calc(var(--slider-pointer) - ${l}px))`,u=`calc(100% - ${a}px)`;o.bottom=`min(${c}, ${u})`}}Object.assign(t.style,o)}function b3(t){return ke.isValidElement(t)&&t.type===w3}function x3(t,e){let n={...e};for(let i in e){let r=t[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?n[i]=(...o)=>{s(...o),r(...o)}:r&&(n[i]=r):i==="style"?n[i]={...r,...s}:i==="className"&&(n[i]=[r,s].filter(Boolean).join(" "))}return{...t,...n}}function ZP(t){return t?.$$PROVIDER_TYPE==="REMOTION"}function ye(t,e){let n=$r(Ls);return pe((e?.current?.$state||n||E3)[t])}var ke,wD,bD,xD,kD,ED,TD,SD,PD,CD,$D,MD,Y,HS,pc,un,BS,WS,KS,Kt,Pn,xs,hh,fh,N,RD,ah,YS,oc,b_,gP,xw,oe,lh,DD,OD,VD,FD,zD,UD,jD,W,QS,XS,ZS,ln,qD,Ls,HD,tu,Ba,iw,ja,vh,ch,Ir,YD,XD,JD,cO,dO,fO,Yi,_h,iu,wh,rw,bh,Pw,xh,uc,kh,Eh,yO,_O,cn,Th,OP,iP,wO,rP,sw,bO,Sh,VP,FP,zP,UP,jP,qP,Ph,fc,HP,WP,Ch,$h,Z_,kO,EO,Mh,aw,ow,Rh,lw,cw,TO,uw,dw,SO,Lh,pn,PO,CO,Ee,he,$O,GP,hw,fw,LO,IO,AO,Ka,Ih,Ah,Nh,Ha,NO,Dh,Oh,mc,tt,DO,OO,VO,gc,Vh,Fh,zh,Uh,jh,qh,Hh,Bh,Wh,sf,uP,mw,vc,af,_i,Qi,Ki,dh,Kh,Ga,Gh,jO,qO,HO,Es,BO,WO,KO,Ya,_c,wc,Qa,GO,YO,of,Xi,ct,QO,dP,gw,XO,ZO,ru,JO,Zi,e3,t3,n3,Ts,Yh,Qh,dc,bc,vw,Dr,i3,r3,QP,Xa,s3,a3,o3,Za,l3,c3,Lw,Ss,u3,d3,Iw,Ps,p3,h3,Aw,Cs,f3,m3,Nw,$s,g3,v3,Dw,Ms,Xh,yw,Zh,xc,kc,y3,_3,_w,Rs,Jh,Ec,Tc,ef,Sc,Pc,Cc,$c,Mc,Rc,Lc,Ic,Ac,Nc,Dc,Oc,Vc,Fc,zc,Uc,jc,qc,Hc,Bc,Wc,Kc,Gc,Yc,Qc,Xc,Zc,Jc,tf,Ja,eu,XP,ww,w3,k3,U,pP,E3,Wt=Ue(()=>{"use strict";"use client";ke=$(z(),1);Lt();bD=Symbol(0);wD=bD;xD=Symbol(0),kD=Symbol(0),ED=Symbol(0),TD=Symbol(0),SD=Symbol(0),PD=Symbol(0),CD=Symbol(0),$D=Symbol(0),MD=Symbol(0),Y={_add:xD,_remove:kD,_reset:ED,_select:TD,_readonly:SD,_setReadonly:PD,_onReset:CD,_onRemove:$D,_onUserSelect:MD},pc=class extends Ma{constructor(){super(...arguments),this._items=[],this[HS]=!1}get length(){return this._items.length}get readonly(){return this[Y._readonly]}toArray(){return[...this._items]}[(HS=Y._readonly,Symbol.iterator)](){return this._items.values()}[Y._add](e,n){let i=this._items.length;""+i in this||Object.defineProperty(this,i,{get(){return this._items[i]}}),!this._items.includes(e)&&(this._items.push(e),this.dispatchEvent(new j("add",{detail:e,trigger:n})))}[Y._remove](e,n){let i=this._items.indexOf(e);i>=0&&(this[Y._onRemove]?.(e,n),this._items.splice(i,1),this.dispatchEvent(new j("remove",{detail:e,trigger:n})))}[Y._reset](e){for(let n of[...this._items])this[Y._remove](n,e);this._items=[],this[Y._setReadonly](!1,e),this[Y._onReset]?.()}[Y._setReadonly](e,n){this[Y._readonly]!==e&&(this[Y._readonly]=e,this.dispatchEvent(new j("readonly-change",{detail:e,trigger:n})))}},un={fullscreenEnabled:0,fullscreenElement:1,requestFullscreen:2,exitFullscreen:3,fullscreenchange:4,fullscreenerror:5,fullscreen:6},BS=["webkitFullscreenEnabled","webkitFullscreenElement","webkitRequestFullscreen","webkitExitFullscreen","webkitfullscreenchange","webkitfullscreenerror","-webkit-full-screen"],WS=["mozFullScreenEnabled","mozFullScreenElement","mozRequestFullScreen","mozCancelFullScreen","mozfullscreenchange","mozfullscreenerror","-moz-full-screen"],KS=["msFullscreenEnabled","msFullscreenElement","msRequestFullscreen","msExitFullscreen","MSFullscreenChange","MSFullscreenError","-ms-fullscreen"],Kt=typeof window<"u"&&typeof window.document<"u"?window.document:{},Pn="fullscreenEnabled"in Kt&&Object.keys(un)||BS[0]in Kt&&BS||WS[0]in Kt&&WS||KS[0]in Kt&&KS||[],xs={requestFullscreen:function(t){return t[Pn[un.requestFullscreen]]()},requestFullscreenFunction:function(t){return t[Pn[un.requestFullscreen]]},get exitFullscreen(){return Kt[Pn[un.exitFullscreen]].bind(Kt)},get fullscreenPseudoClass(){return":"+Pn[un.fullscreen]},addEventListener:function(t,e,n){return Kt.addEventListener(Pn[un[t]],e,n)},removeEventListener:function(t,e,n){return Kt.removeEventListener(Pn[un[t]],e,n)},get fullscreenEnabled(){return!!Kt[Pn[un.fullscreenEnabled]]},set fullscreenEnabled(t){},get fullscreenElement(){return Kt[Pn[un.fullscreenElement]]},set fullscreenElement(t){},get onfullscreenchange(){return Kt[("on"+Pn[un.fullscreenchange]).toLowerCase()]},set onfullscreenchange(t){return Kt[("on"+Pn[un.fullscreenchange]).toLowerCase()]=t},get onfullscreenerror(){return Kt[("on"+Pn[un.fullscreenerror]).toLowerCase()]},set onfullscreenerror(t){return Kt[("on"+Pn[un.fullscreenerror]).toLowerCase()]=t}},hh=xs.fullscreenEnabled,fh=class extends Mt{constructor(){super(...arguments),this._listening=!1,this._active=!1}get active(){return this._active}get supported(){return hh}onConnect(){S(xs,"fullscreenchange",this._onFullscreenChange.bind(this)),S(xs,"fullscreenerror",this._onFullscreenError.bind(this)),G(this._onDisconnect.bind(this))}async _onDisconnect(){hh&&await this.exit()}_onFullscreenChange(e){let n=X_(this.el);n!==this._active&&(n||(this._listening=!1),this._active=n,this.dispatch("fullscreen-change",{detail:n,trigger:e}))}_onFullscreenError(e){this._listening&&(this.dispatch("fullscreen-error",{detail:null,trigger:e}),this._listening=!1)}async enter(){try{return this._listening=!0,!this.el||X_(this.el)?void 0:(GS(),xs.requestFullscreen(this.el))}catch(e){throw this._listening=!1,e}}async exit(){if(!(!this.el||!X_(this.el)))return GS(),xs.exitFullscreen()}};N=typeof document>"u",RD=N?"":navigator?.userAgent.toLowerCase()||"",ah=!N&&/iphone|ipad|ipod|ios|crios|fxios/i.test(RD),YS=!N&&/(iphone|ipod)/gi.test(navigator?.platform||""),oc=!N&&!!window.chrome,b_=!N&&(!!window.safari||ah);gP=class vP extends Mt{constructor(){super(...arguments),this._type=D(this._getScreenOrientation()),this._locked=D(!1)}get type(){return this._type()}get locked(){return this._locked()}get portrait(){return this._type().startsWith("portrait")}get landscape(){return this._type().startsWith("landscape")}get supported(){return vP.supported}onConnect(){if(this.supported)S(screen.orientation,"change",this._onOrientationChange.bind(this));else{let e=window.matchMedia("(orientation: landscape)");e.onchange=this._onOrientationChange.bind(this),G(()=>e.onchange=null)}G(this._onDisconnect.bind(this))}async _onDisconnect(){this.supported&&this._locked()&&await this.unlock()}_onOrientationChange(e){this._type.set(this._getScreenOrientation()),this.dispatch("orientation-change",{detail:{orientation:C(this._type),lock:this._currentLock},trigger:e})}async lock(e){C(this._locked)||this._currentLock===e||(this._assertScreenOrientationAPI(),await screen.orientation.lock(e),this._locked.set(!0),this._currentLock=e)}async unlock(){C(this._locked)&&(this._assertScreenOrientationAPI(),this._currentLock=void 0,await screen.orientation.unlock(),this._locked.set(!1))}_assertScreenOrientationAPI(){if(!this.supported)throw Error("[vidstack] no orientation API")}_getScreenOrientation(){return N?"portrait-primary":this.supported?window.screen.orientation.type:window.innerWidth>=window.innerHeight?"landscape-primary":"portrait-primary"}};gP.supported=bw();xw=gP,oe=class{get length(){return this._ranges.length}constructor(e,n){He(e)?this._ranges=e:!Ie(e)&&!Ie(n)?this._ranges=[[e,n]]:this._ranges=[]}start(e){return this._ranges[e][0]??1/0}end(e){return this._ranges[e][1]??1/0}};lh={};DD=Symbol(0),OD=Symbol(0),VD=Symbol(0),FD=Symbol(0),zD=Symbol(0),UD=Symbol(0),jD=Symbol(0),W={_crossOrigin:DD,_readyState:OD,_updateActiveCues:VD,_canLoad:FD,_onModeChange:zD,_native:UD,_nativeHLS:jD};ln=class extends Ma{constructor(e){super(),this.id="",this.label="",this.language="",this.default=!1,this._canLoad=!1,this._currentTime=0,this._mode="disabled",this._metadata={},this._regions=[],this._cues=[],this._activeCues=[],this[QS]=0,this[XS]=null,this[ZS]=null;for(let n of Object.keys(e))this[n]=e[n];this.type||(this.type="vtt"),!N&&e.content?Promise.resolve().then(()=>(rc(),ic)).then(({parseText:n,VTTCue:i,VTTRegion:r})=>{!F(e.content)||e.type==="json"?(this._parseJSON(e.content,i,r),this.readyState!==3&&this._readyState()):n(e.content,{type:e.type}).then(({cues:s,regions:a})=>{this._cues=s,this._regions=a,this._readyState()})}):e.src||(this[W._readyState]=2)}static createId(e){return`id::${e.type}-${e.kind}-${e.src??e.label}`}get metadata(){return this._metadata}get regions(){return this._regions}get cues(){return this._cues}get activeCues(){return this._activeCues}get readyState(){return this[W._readyState]}get mode(){return this._mode}set mode(e){this.setMode(e)}addCue(e,n){let i=0,r=this._cues.length;for(i=0;i=0){let r=this._activeCues.includes(e);this._cues.splice(i,1),this[W._native]?.track.removeCue(e),this.dispatchEvent(new j("remove-cue",{detail:e,trigger:n})),r&&this[W._updateActiveCues](this._currentTime,n)}}setMode(e,n){this._mode!==e&&(this._mode=e,e==="disabled"?(this._activeCues=[],this._activeCuesChanged()):this.readyState===2?this[W._updateActiveCues](this._currentTime,n):this._load(),this.dispatchEvent(new j("mode-change",{detail:this,trigger:n})),this[W._onModeChange]?.())}[(QS=W._readyState,XS=W._onModeChange,ZS=W._native,W._updateActiveCues)](e,n){if(this._currentTime=e,this.mode==="disabled"||!this._cues.length)return;let i=[];for(let s=0,a=this._cues.length;s0)){this[W._readyState]=1,this.dispatchEvent(new j("load-start"));try{let{parseResponse:e,VTTCue:n,VTTRegion:i}=await Promise.resolve().then(()=>(rc(),ic)),r=this[W._crossOrigin]?.(),s=fetch(this.src,{headers:this.type==="json"?{"Content-Type":"application/json"}:void 0,credentials:mh(r)});if(this.type==="json")this._parseJSON(await(await s).text(),n,i);else{let{errors:a,metadata:o,regions:l,cues:c}=await e(s,{type:this.type,encoding:this.encoding});if(a[0]?.code===0)throw a[0];this._metadata=o,this._regions=l,this._cues=c}this._readyState()}catch(e){this._errorState(e)}}}_readyState(){if(this[W._readyState]=2,!this.src||this.type!=="vtt"){let n=this[W._native]?.track;if(n)for(let i of this._cues)n.addCue(i)}let e=new j("load");this[W._updateActiveCues](this._currentTime,e),this.dispatchEvent(e)}_errorState(e){this[W._readyState]=3,this.dispatchEvent(new j("error",{detail:e}))}_parseJSON(e,n,i){try{let{regions:r,cues:s}=yP(e,n,i);this._regions=r,this._cues=s}catch(r){this._errorState(r)}}_activeCuesChanged(e){this.dispatchEvent(new j("cue-change",{trigger:e}))}},qD=/captions|subtitles/;Ls=new Xn({artist:"",audioTrack:null,audioTracks:[],autoPlay:!1,autoPlayError:null,buffered:new oe,canLoad:!1,canLoadPoster:!1,canFullscreen:!1,canOrientScreen:bw(),canPictureInPicture:!1,canPlay:!1,clipStartTime:0,clipEndTime:0,controls:!1,controlsVisible:!1,crossOrigin:null,ended:!1,error:null,fullscreen:!1,loop:!1,logLevel:"silent",mediaType:"unknown",muted:!1,paused:!0,played:new oe,playing:!1,playsInline:!1,pictureInPicture:!1,preload:"metadata",playbackRate:1,qualities:[],quality:null,autoQuality:!1,canSetQuality:!0,canSetPlaybackRate:!0,canSetVolume:!1,seekable:new oe,seeking:!1,source:{src:"",type:""},sources:[],started:!1,textTracks:[],textTrack:null,get hasCaptions(){return this.textTracks.filter(We).length>0},volume:1,waiting:!1,realCurrentTime:0,get currentTime(){return this.clipStartTime>0?Math.max(0,Math.min(this.realCurrentTime-this.clipStartTime,this.duration)):this.realCurrentTime},providedDuration:-1,intrinsicDuration:0,get realDuration(){return this.providedDuration>0?this.providedDuration:this.intrinsicDuration},get duration(){return this.clipEndTime>0?this.clipEndTime-this.clipStartTime:Math.max(0,this.realDuration-this.clipStartTime)},get title(){return this.providedTitle||this.inferredTitle},get poster(){return this.providedPoster||this.inferredPoster},get viewType(){return this.providedViewType!=="unknown"?this.providedViewType:this.inferredViewType},get streamType(){return this.providedStreamType!=="unknown"?this.providedStreamType:this.inferredStreamType},get currentSrc(){return this.source},get bufferedStart(){let t=tw(this.buffered)??0;return Math.max(0,t-this.clipStartTime)},get bufferedEnd(){let t=nw(this.buffered)??0;return Math.min(this.duration,Math.max(0,t-this.clipStartTime))},get seekableStart(){let t=tw(this.seekable)??0;return Math.max(0,t-this.clipStartTime)},get seekableEnd(){let t=this.canPlay?nw(this.seekable)??1/0:0;return this.clipEndTime>0?Math.min(this.clipEndTime,Math.max(0,t-this.clipStartTime)):t},get seekableWindow(){return Math.max(0,this.seekableEnd-this.seekableStart)},canAirPlay:!1,canGoogleCast:!1,remotePlaybackState:"disconnected",remotePlaybackType:"none",remotePlaybackLoader:null,remotePlaybackInfo:null,get isAirPlayConnected(){return this.remotePlaybackType==="airplay"&&this.remotePlaybackState==="connected"},get isGoogleCastConnected(){return this.remotePlaybackType==="google-cast"&&this.remotePlaybackState==="connected"},pointer:"fine",orientation:"landscape",width:0,height:0,mediaWidth:0,mediaHeight:0,lastKeyboardAction:null,userBehindLiveEdge:!1,liveEdgeTolerance:10,minLiveDVRWindow:60,get canSeek(){return/unknown|on-demand|:dvr/.test(this.streamType)&&Number.isFinite(this.seekableWindow)&&(!this.live||/:dvr/.test(this.streamType)&&this.seekableWindow>=this.minLiveDVRWindow)},get live(){return this.streamType.includes("live")||!Number.isFinite(this.realDuration)},get liveEdgeStart(){return this.live&&Number.isFinite(this.seekableEnd)?Math.max(0,(this.liveSyncPosition??this.seekableEnd)-this.liveEdgeTolerance):0},get liveEdge(){return this.live&&(!this.canSeek||!this.userBehindLiveEdge&&this.currentTime>=this.liveEdgeStart)},get liveEdgeWindow(){return this.live&&Number.isFinite(this.seekableEnd)?this.seekableEnd-this.liveEdgeStart:0},autoPlaying:!1,providedTitle:"",inferredTitle:"",providedPoster:"",inferredPoster:"",inferredViewType:"unknown",providedViewType:"unknown",providedStreamType:"unknown",inferredStreamType:"unknown",liveSyncPosition:null}),HD=new Set(["audioTrack","audioTracks","autoPlayError","autoPlaying","autoQuality","buffered","canPlay","ended","error","inferredPoster","inferredStreamType","inferredTitle","intrinsicDuration","liveSyncPosition","paused","played","playing","qualities","quality","realCurrentTime","seekable","seeking","started","userBehindLiveEdge","waiting"]);tu=mi();Ba=class{constructor(e=void 0){this._logger=e,this._target=null,this._player=null,this._prevTrackIndex=-1}setTarget(e){this._target=e}getPlayer(e){return this._player?this._player:((e??this._target)?.dispatchEvent(new j("find-media-player",{detail:n=>void(this._player=n),bubbles:!0,composed:!0})),this._player)}setPlayer(e){this._player=e}startLoading(e){this._dispatchRequest("media-start-loading",e)}startLoadingPoster(e){this._dispatchRequest("media-poster-start-loading",e)}requestAirPlay(e){this._dispatchRequest("media-airplay-request",e)}requestGoogleCast(e){this._dispatchRequest("media-google-cast-request",e)}play(e){this._dispatchRequest("media-play-request",e)}pause(e){this._dispatchRequest("media-pause-request",e)}mute(e){this._dispatchRequest("media-mute-request",e)}unmute(e){this._dispatchRequest("media-unmute-request",e)}enterFullscreen(e,n){this._dispatchRequest("media-enter-fullscreen-request",n,e)}exitFullscreen(e,n){this._dispatchRequest("media-exit-fullscreen-request",n,e)}lockScreenOrientation(e,n){this._dispatchRequest("media-orientation-lock-request",n,e)}unlockScreenOrientation(e){this._dispatchRequest("media-orientation-unlock-request",e)}enterPictureInPicture(e){this._dispatchRequest("media-enter-pip-request",e)}exitPictureInPicture(e){this._dispatchRequest("media-exit-pip-request",e)}seeking(e,n){this._dispatchRequest("media-seeking-request",n,e)}seek(e,n){this._dispatchRequest("media-seek-request",n,e)}seekToLiveEdge(e){this._dispatchRequest("media-live-edge-request",e)}changeVolume(e,n){this._dispatchRequest("media-volume-change-request",n,Math.max(0,Math.min(1,e)))}changeAudioTrack(e,n){this._dispatchRequest("media-audio-track-change-request",n,e)}changeQuality(e,n){this._dispatchRequest("media-quality-change-request",n,e)}requestAutoQuality(e){this.changeQuality(-1,e)}changeTextTrackMode(e,n,i){this._dispatchRequest("media-text-track-change-request",i,{index:e,mode:n})}changePlaybackRate(e,n){this._dispatchRequest("media-rate-change-request",n,e)}resumeControls(e){this._dispatchRequest("media-resume-controls-request",e)}pauseControls(e){this._dispatchRequest("media-pause-controls-request",e)}togglePaused(e){let n=this.getPlayer(e?.target);n&&(n.state.paused?this.play(e):this.pause(e))}toggleControls(e){let n=this.getPlayer(e?.target);n&&(n.controls.showing?n.controls.hide(0,e):n.controls.show(0,e))}toggleMuted(e){let n=this.getPlayer(e?.target);n&&(n.state.muted?this.unmute(e):this.mute(e))}toggleFullscreen(e,n){let i=this.getPlayer(n?.target);i&&(i.state.fullscreen?this.exitFullscreen(e,n):this.enterFullscreen(e,n))}togglePictureInPicture(e){let n=this.getPlayer(e?.target);n&&(n.state.pictureInPicture?this.exitPictureInPicture(e):this.enterPictureInPicture(e))}disableCaptions(e){let n=this.getPlayer(e?.target);if(!n)return;let i=n.state.textTracks,r=n.state.textTrack;if(r){let s=i.indexOf(r);this.changeTextTrackMode(s,"disabled",e)}}toggleCaptions(e){let n=this.getPlayer(e?.target);if(!n)return;let i=n.state.textTracks,r=n.state.textTrack;if(r){let s=i.indexOf(r);this.changeTextTrackMode(s,"disabled",e),this._prevTrackIndex=s}else{let s=this._prevTrackIndex;(!i[s]||!We(i[s]))&&(s=-1),s===-1&&(s=i.findIndex(a=>We(a)&&a.default)),s===-1&&(s=i.findIndex(a=>We(a))),s>=0&&this.changeTextTrackMode(s,"showing",e),this._prevTrackIndex=-1}}_dispatchRequest(e,n,i){let r=new j(e,{bubbles:!0,composed:!0,cancelable:!0,detail:i,trigger:n}),s=n?.target||null;s&&s instanceof H&&(s=s.el),s=!s||s===document||s===window||s===document.body||this._player?.el&&s instanceof Node&&!this._player.el.contains(s)?this._target??this.getPlayer()?.el:s??this._target,this._player?e==="media-play-request"&&!this._player.state.canLoad?s?.dispatchEvent(r):this._player.canPlayQueue._enqueue(e,()=>s?.dispatchEvent(r)):s?.dispatchEvent(r)}_noPlayerWarning(e){}},iw=Math.min,ja=Math.max,vh=Math.round,ch=Math.floor,Ir=t=>({x:t,y:t});YD=async(t,e,n)=>{let{placement:i="bottom",strategy:r="absolute",middleware:s=[],platform:a}=n,o=s.filter(Boolean),l=await(a.isRTL==null?void 0:a.isRTL(e)),c=await a.getElementRects({reference:t,floating:e,strategy:r}),{x:u,y:d}=JS(c,i,l),p=i,h={},y=0;for(let v=0;v{let i=new Map,r={platform:dO,...n},s={...r.platform,_c:i};return YD(t,e,{...r,platform:s})};Yi=class extends Mt{},_h=class extends Yi{constructor(){super(...arguments),this._idleTimer=-2,this._pausedTracking=!1,this._hideOnMouseLeave=D(!1),this._isMouseOutside=D(!1),this._focusedItem=null,this.defaultDelay=2e3}get hideOnMouseLeave(){let{hideControlsOnMouseLeave:e}=this.$props;return this._hideOnMouseLeave()||e()}set hideOnMouseLeave(e){this._hideOnMouseLeave.set(e)}get showing(){return this.$state.controlsVisible()}show(e=0,n){this._clearIdleTimer(),this._pausedTracking||this._changeVisibility(!0,e,n)}hide(e=this.defaultDelay,n){this._clearIdleTimer(),this._pausedTracking||this._changeVisibility(!1,e,n)}pause(e){this._pausedTracking=!0,this._clearIdleTimer(),this._changeVisibility(!0,0,e)}resume(e){this._pausedTracking=!1,!this.$state.paused()&&this._changeVisibility(!1,this.defaultDelay,e)}onConnect(){b(this._watchMouse.bind(this)),b(this._watchPaused.bind(this));let e=this._onPlay.bind(this),n=this._onPause.bind(this);this.listen("can-play",i=>this.show(0,i)),this.listen("play",e),this.listen("pause",n),this.listen("auto-play-fail",n)}_watchMouse(){let{started:e,pointer:n,paused:i}=this.$state;if(!e()||n()!=="fine")return;let r=this.hideOnMouseLeave;(!r||!this._isMouseOutside())&&b(()=>{i()||this.listen("pointermove",this._onStopIdle.bind(this))}),r&&(this.listen("mouseenter",this._onMouseEnter.bind(this)),this.listen("mouseleave",this._onMouseLeave.bind(this)))}_watchPaused(){let{paused:e,started:n,autoPlayError:i}=this.$state;if(e()||i()&&!n())return;let r=this._onStopIdle.bind(this);b(()=>{let s=this.$state.pointer(),a=s==="coarse",o=[a?"touchend":"pointerup","keydown"];for(let l of o)this.listen(l,r,{passive:!1})})}_onPlay(e){this.show(0,e),this.hide(void 0,e)}_onPause(e){this.show(0,e)}_onMouseEnter(e){this._isMouseOutside.set(!1),this.show(0,e),this.hide(void 0,e)}_onMouseLeave(e){this._isMouseOutside.set(!0),this.hide(0,e)}_clearIdleTimer(){window.clearTimeout(this._idleTimer),this._idleTimer=-1}_onStopIdle(e){e.MEDIA_GESTURE||this._pausedTracking||Sw(e)||(ji(e)&&(e.key==="Escape"?(this.el?.focus(),this._focusedItem=null):this._focusedItem&&(e.preventDefault(),requestAnimationFrame(()=>{this._focusedItem?.focus(),this._focusedItem=null}))),this.show(0,e),this.hide(this.defaultDelay,e))}_changeVisibility(e,n,i){if(n===0){this._onChange(e,i);return}this._idleTimer=window.setTimeout(()=>{this.scope&&this._onChange(e&&!this._pausedTracking,i)},n)}_onChange(e,n){this.$state.controlsVisible()!==e&&(this.$state.controlsVisible.set(e),!e&&document.activeElement&&this.el?.contains(document.activeElement)&&(this._focusedItem=document.activeElement,requestAnimationFrame(()=>this.el?.focus())),this.dispatch("controls-change",{detail:e,trigger:n}))}},iu=gO;wh=class{constructor(){this.playerId="vds-player",this.mediaId=null,this._data={volume:null,muted:null,time:null,lang:null,captions:null,rate:null},this.saveTime=iu(()=>{if(N||!this.mediaId)return;let e=(this._data.time??0).toString();localStorage.setItem(this.mediaId,e)},1e3)}async getVolume(){return this._data.volume}async setVolume(e){this._data.volume=e,this.save()}async getMuted(){return this._data.muted}async setMuted(e){this._data.muted=e,this.save()}async getTime(){return this._data.time}async setTime(e){this._data.time=e,this.saveTime()}async getLang(){return this._data.lang}async setLang(e){this._data.lang=e,this.save()}async getCaptions(){return this._data.captions}async setCaptions(e){this._data.captions=e,this.save()}async getPlaybackRate(){return this._data.rate}async setPlaybackRate(e){this._data.rate=e,this.save()}onChange(e,n,i="vds-player"){let r=i?localStorage.getItem(i):null,s=n?localStorage.getItem(n):null;this.playerId=i,this.mediaId=n,this._data={volume:null,muted:null,lang:null,captions:null,...r?JSON.parse(r):{},time:s?+s:null}}save(){if(N||!this.playerId)return;let e=JSON.stringify({...this._data,time:void 0});localStorage.setItem(this.playerId,e)}},rw=class{constructor(){this.priority=0,this._display=!0,this._video=null,this._track=null,this._tracks=new Set}canRender(e,n){return!!n}attach(e){this._video=e,e&&(e.textTracks.onchange=this._onChange.bind(this))}addTrack(e){this._tracks.add(e),this._attachTrack(e)}removeTrack(e){e[W._native]?.remove?.(),e[W._native]=null,this._tracks.delete(e)}changeTrack(e){let n=e?.[W._native];n&&n.track.mode!=="showing"&&(n.track.mode="showing"),this._track=e}setDisplay(e){this._display=e,this._onChange()}detach(){this._video&&(this._video.textTracks.onchange=null);for(let e of this._tracks)this.removeTrack(e);this._tracks.clear(),this._video=null,this._track=null}_attachTrack(e){var i;if(!this._video)return;let n=e[i=W._native]??(e[i]=this._createTrackElement(e));n instanceof HTMLElement&&(this._video.append(n),n.track.mode=n.default?"showing":"hidden")}_createTrackElement(e){let n=document.createElement("track"),i=e.default||e.mode==="showing",r=e.src&&e.type==="vtt";if(n.id=e.id,r)n.src=e.src;else{let s=function(){URL.revokeObjectURL(this.src),this.removeEventListener("load",s),this.removeEventListener("error",s)},a=new Blob([`WEBVTT -`],{type:"text/vtt"});n.src=URL.createObjectURL(a),n.addEventListener("load",s),n.addEventListener("error",s)}return n.label=e.label,n.kind=e.kind,n.default=i,e.language&&(n.srclang=e.language),i&&!r&&this._copyCues(e,n.track),n}_copyCues(e,n){if(!(e.src&&e.type==="vtt"||n.cues?.length))for(let i of e.cues)n.addCue(i)}_onChange(e){for(let n of this._tracks){let i=n[W._native]?.track;if(!i)continue;if(!this._display){i.mode="disabled";continue}let r=i.mode==="showing";r&&this._copyCues(n,i),n.setMode(r?"showing":"disabled",e)}}},bh=class{constructor(e){this._media=e,this._video=null,this._renderers=[],this._nativeDisplay=!1,this._nativeRenderer=null,this._customRenderer=null;let n=e.textTracks;this._textTracks=n,b(this._watchControls.bind(this)),G(this._detach.bind(this)),S(n,"add",this._onAddTrack.bind(this)),S(n,"remove",this._onRemoveTrack.bind(this)),S(n,"mode-change",this._update.bind(this))}_watchControls(){let{$state:e,$iosControls:n}=this._media;this._nativeDisplay=e.controls()||n(),this._update()}add(e){this._renderers.push(e),this._update()}remove(e){e.detach(),this._renderers.splice(this._renderers.indexOf(e),1),this._update()}_attachVideo(e){requestAnimationFrame(()=>{if(this._video=e,e){this._nativeRenderer=new rw,this._nativeRenderer.attach(e);for(let n of this._textTracks)this._addNativeTrack(n)}this._update()})}_addNativeTrack(e){We(e)&&this._nativeRenderer?.addTrack(e)}_removeNativeTrack(e){We(e)&&this._nativeRenderer?.removeTrack(e)}_onAddTrack(e){this._addNativeTrack(e.detail)}_onRemoveTrack(e){this._removeNativeTrack(e.detail)}_update(){let e=this._textTracks.selected;if(this._video&&(this._nativeDisplay||e?.[W._nativeHLS])){this._customRenderer?.changeTrack(null),this._nativeRenderer?.setDisplay(!0),this._nativeRenderer?.changeTrack(e);return}if(this._nativeRenderer?.setDisplay(!1),this._nativeRenderer?.changeTrack(null),!e){this._customRenderer?.changeTrack(null);return}let n=this._renderers.sort((i,r)=>i.priority-r.priority).find(i=>i.canRender(e,this._video));this._customRenderer!==n&&(this._customRenderer?.detach(),n?.attach(this._video),this._customRenderer=n??null),n?.changeTrack(e)}_detach(){this._nativeRenderer?.detach(),this._nativeRenderer=null,this._customRenderer?.detach(),this._customRenderer=null}},Pw=vO;xh=class extends pc{constructor(){super(),this._canLoad=!1,this._defaults={},this._storage=null,this._preferredLang=null,this._selectCaptions=Pw(async()=>{if(!this._canLoad||this.selected||await this._storage?.getCaptions()===!1)return;!this._preferredLang&&this._storage&&(this._preferredLang=await this._storage.getLang());let e=this._preferredLang&&this._items.find(i=>We(i)&&i.language===this._preferredLang),n=this._defaults.captions;e?e.mode="showing":n&&n&&(n.mode="showing"),this._storage?.setLang?.(this._preferredLang??n?.language??null)},300),this._onTrackModeChangeBind=this._onTrackModeChange.bind(this)}get selected(){return this._items.find(n=>n.mode==="showing"&&We(n))??null}get preferredLang(){return this._preferredLang}set preferredLang(e){this._preferredLang=e}add(e,n){let i=e instanceof ln,r=i?e:new ln(e),s=e.kind==="captions"||e.kind==="subtitles"?"captions":e.kind;return this._defaults[s]&&e.default&&delete e.default,r.addEventListener("mode-change",this._onTrackModeChangeBind),this[Y._add](r,n),r[W._crossOrigin]=this[W._crossOrigin],this._canLoad&&r[W._canLoad](),e.default&&(this._defaults[s]=r,s!=="captions"?r.mode="showing":this._selectCaptions()),this}remove(e,n){if(this._items.includes(e))return e===this._defaults[e.kind]&&delete this._defaults[e.kind],e.mode="disabled",e[W._onModeChange]=null,e.removeEventListener("mode-change",this._onTrackModeChangeBind),this[Y._remove](e,n),this}clear(e){for(let n of[...this._items])this.remove(n,e);return this}getById(e){return this._items.find(n=>n.id===e)??null}getByKind(e){let n=Array.isArray(e)?e:[e];return this._items.filter(i=>n.includes(i.kind))}[W._canLoad](){if(!this._canLoad){for(let e of this._items)e[W._canLoad]();this._canLoad=!0,this._selectCaptions()}}_onTrackModeChange(e){let n=e.detail;if(this._storage&&We(n)&&(this._storage.setCaptions?.(n.mode==="showing"),this._storage?.setLang?.(this._preferredLang??n?.language??null)),n.mode==="showing"){let i=We(n)?["captions","subtitles"]:[n.kind];for(let r of this._items)r.mode==="showing"&&r!=n&&i.includes(r.kind)&&(r.mode="disabled")}this.dispatchEvent(new j("mode-change",{detail:e.detail,trigger:e}))}setStorage(e){this._storage=e}},uc=Symbol(0),kh=class extends pc{get selected(){return this._items.find(e=>e.selected)??null}get selectedIndex(){return this._items.findIndex(e=>e.selected)}[Y._onRemove](e,n){this[Y._select](e,!1,n)}[Y._add](e,n){e[uc]=!1,Object.defineProperty(e,"selected",{get(){return this[uc]},set:i=>{this.readonly||(this[Y._onUserSelect]?.(),this[Y._select](e,i))}}),super[Y._add](e,n)}[Y._select](e,n,i){if(n===e?.[uc])return;let r=this.selected;e&&(e[uc]=n),(n?r!==e:r===e)&&(r&&(r[uc]=!1),this.dispatchEvent(new j("change",{detail:{prev:r,current:this.selected},trigger:i})))}},Eh=class extends kh{getById(e){return e===""?null:this._items.find(n=>n.id===e)??null}},yO=Symbol(0),_O=Symbol(0),cn={_setAuto:yO,_enableAuto:_O},Th=class extends kh{constructor(){super(...arguments),this._auto=!1,this.switch="current"}get auto(){return this._auto||this.readonly}[Y._onUserSelect](){this[cn._setAuto](!1)}[Y._onReset](e){this[cn._setAuto](!1,e)}autoSelect(e){this.readonly||this._auto||!this[cn._enableAuto]||(this[cn._enableAuto]?.(),this[cn._setAuto](!0,e))}[cn._setAuto](e,n){this._auto!==e&&(this._auto=e,this.dispatchEvent(new j("auto-change",{detail:e,trigger:n})))}};OP={togglePaused:"k Space",toggleMuted:"m",toggleFullscreen:"f",togglePictureInPicture:"i",toggleCaptions:"c",seekBackward:"j J ArrowLeft",seekForward:"l L ArrowRight",volumeUp:"ArrowUp",volumeDown:"ArrowDown",speedUp:">",slowDown:"<"},iP=new Set(["Shift","Alt","Meta","Control"]),wO='button, [role="button"]',rP='input, textarea, select, [contenteditable], [role^="menuitem"], [role="timer"]',sw=class extends Yi{constructor(e){super(),this._media=e,this._timeSlider=null}onConnect(){b(this._onTargetChange.bind(this))}_onTargetChange(){let{keyDisabled:e,keyTarget:n}=this.$props;if(e())return;let i=n()==="player"?this.el:document,r=D(!1);i===this.el?(this.listen("focusin",()=>r.set(!0)),this.listen("focusout",s=>{this.el.contains(s.target)||r.set(!1)})):(C(r)||r.set(document.querySelector("[data-media-player]")===this.el),S(document,"focusin",s=>{let a=s.composedPath().find(o=>o instanceof Element&&o.localName==="media-player");a!==void 0&&r.set(this.el===a)})),b(()=>{r()&&(S(i,"keyup",this._onKeyUp.bind(this)),S(i,"keydown",this._onKeyDown.bind(this)),S(i,"keydown",this._onPreventVideoKeys.bind(this),{capture:!0}))})}_onKeyUp(e){let n=document.activeElement;if(!e.key||!this.$state.canSeek()||n?.matches(rP))return;let{method:i,value:r}=this._getMatchingMethod(e);if(!F(r)&&!He(r)){r?.callback(e);return}i?.startsWith("seek")&&(e.preventDefault(),e.stopPropagation(),this._timeSlider?(this._forwardTimeKeyboardEvent(e,i==="seekForward"),this._timeSlider=null):(this._media.remote.seek(this._seekTotal,e),this._seekTotal=void 0)),i?.startsWith("volume")&&this.el.querySelector("[data-media-volume-slider]")?.dispatchEvent(new KeyboardEvent("keyup",{key:i==="volumeUp"?"Up":"Down",shiftKey:e.shiftKey,trigger:e}))}_onKeyDown(e){if(!e.key||iP.has(e.key))return;let n=document.activeElement;if(n?.matches(rP)||Kl(e)&&n?.matches(wO))return;let{method:i,value:r}=this._getMatchingMethod(e);if(!F(r)&&!He(r)){r?.callback(e);return}if(!i&&!e.metaKey&&/[0-9]/.test(e.key)){e.preventDefault(),e.stopPropagation(),this._media.remote.seek(this.$state.duration()/10*Number(e.key),e);return}if(i){switch(e.preventDefault(),e.stopPropagation(),i){case"seekForward":case"seekBackward":this._seeking(e,i,i==="seekForward");break;case"volumeUp":case"volumeDown":let s=this.el.querySelector("[data-media-volume-slider]");if(s)s.dispatchEvent(new KeyboardEvent("keydown",{key:i==="volumeUp"?"Up":"Down",shiftKey:e.shiftKey,trigger:e}));else{let o=e.shiftKey?.1:.05;this._media.remote.changeVolume(this.$state.volume()+(i==="volumeUp"?+o:-o),e)}break;case"toggleFullscreen":this._media.remote.toggleFullscreen("prefer-media",e);break;case"speedUp":case"slowDown":let a=this.$state.playbackRate();this._media.remote.changePlaybackRate(Math.max(.25,Math.min(2,a+(i==="speedUp"?.25:-.25))),e);break;default:this._media.remote[i]?.(e)}this.$state.lastKeyboardAction.set({action:i,event:e})}}_onPreventVideoKeys(e){DP(e.target)&&this._getMatchingMethod(e).method&&e.preventDefault()}_getMatchingMethod(e){let n={...this.$props.keyShortcuts(),...this._media.ariaKeys},i=Object.keys(n).find(r=>{let s=n[r],a=He(s)?s.join(" "):F(s)?s:s?.keys;return(He(a)?a:a?.split(" "))?.some(o=>xO(o).replace(/Control/g,"Ctrl").split("+").every(l=>iP.has(l)?e[l.toLowerCase()+"Key"]:e.key===l.replace("Space"," ")))});return{method:i,value:i?n[i]:null}}_calcSeekAmount(e,n){let i=e.shiftKey?10:5;return this._seekTotal=Math.max(0,Math.min((this._seekTotal??this.$state.currentTime())+(n==="seekForward"?+i:-i),this.$state.duration()))}_forwardTimeKeyboardEvent(e,n){this._timeSlider?.dispatchEvent(new KeyboardEvent(e.type,{key:n?"Right":"Left",shiftKey:e.shiftKey,trigger:e}))}_seeking(e,n,i){this.$state.canSeek()&&(this._timeSlider||(this._timeSlider=this.el.querySelector("[data-media-time-slider]")),this._timeSlider?this._forwardTimeKeyboardEvent(e,i):this._media.remote.seeking(this._calcSeekAmount(e,n),e))}},bO=["!","@","#","$","%","^","&","*","(",")"];Sh=class extends Mt{constructor(e){super(),this._shortcut=e}onAttach(e){let{$props:n,ariaKeys:i}=le(),r=e.getAttribute("aria-keyshortcuts");if(r){i[this._shortcut]=r,N||G(()=>{delete i[this._shortcut]});return}let s=n.keyShortcuts()[this._shortcut];if(s){let a=He(s)?s.join(" "):F(s)?s:s?.keys;e.setAttribute("aria-keyshortcuts",He(a)?a.join(" "):a)}}},VP=/\.(m4a|m4b|mp4a|mpga|mp2|mp2a|mp3|m2a|m3a|wav|weba|aac|oga|spx)($|\?)/i,FP=new Set(["audio/mpeg","audio/ogg","audio/3gp","audio/mp4","audio/webm","audio/flac"]),zP=/\.(mp4|og[gv]|webm|mov|m4v)(#t=[,\d+]+)?($|\?)/i,UP=new Set(["video/mp4","video/webm","video/3gp","video/ogg","video/avi","video/mpeg"]),jP=/\.(m3u8)($|\?)/i,qP=new Set(["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"]);Ph=class{constructor(){this.name="audio"}canPlay(e){return Cw(e)?N||e.type==="?"||LD(this.target,e.type):!1}mediaType(){return"audio"}async load(e){if(N)throw Error("[vidstack] can not load audio provider server-side");return new(await Promise.resolve().then(()=>(PS(),SS))).AudioProvider(this.target,e)}},fc=class{constructor(){this.name="video"}canPlay(e){return $w(e)?N||e.type==="?"||ID(this.target,e.type):!1}mediaType(){return"video"}async load(e){if(N)throw Error("[vidstack] can not load video provider server-side");return new(await Promise.resolve().then(()=>(R_(),CS))).VideoProvider(this.target,e)}},HP=class BP extends fc{constructor(){super(...arguments),this.name="hls"}canPlay(e){return BP.supported&&_s(e)}async load(e){if(N)throw Error("[vidstack] can not load hls provider server-side");return new(await Promise.resolve().then(()=>(MS(),$S))).HLSProvider(this.target,e)}};HP.supported=eh();WP=HP,Ch=class{constructor(){this.name="vimeo"}preconnect(){let e=["https://i.vimeocdn.com","https://f.vimeocdn.com","https://fresnel.vimeocdn.com"];for(let n of e)Jn(n)}canPlay(e){return F(e.src)&&e.type==="video/vimeo"}mediaType(){return"video"}async load(e){if(N)throw Error("[vidstack] can not load vimeo provider server-side");return new(await Promise.resolve().then(()=>(AS(),IS))).VimeoProvider(this.target,e)}async loadPoster(e,n,i){let{resolveVimeoVideoId:r,getVimeoVideoInfo:s}=await Promise.resolve().then(()=>(V_(),LS));if(!F(e.src))return null;let{videoId:a}=r(e.src);return a?s(a,i).then(o=>o?o.poster:null):null}},$h=class{constructor(){this.name="youtube"}preconnect(){let e=["https://www.google.com","https://i.ytimg.com","https://googleads.g.doubleclick.net","https://static.doubleclick.net"];for(let n of e)Jn(n)}canPlay(e){return F(e.src)&&e.type==="video/youtube"}mediaType(){return"video"}async load(e){if(N)throw Error("[vidstack] can not load youtube provider server-side");return new(await Promise.resolve().then(()=>(OS(),DS))).YouTubeProvider(this.target,e)}async loadPoster(e,n,i){let{findYouTubePoster:r,resolveYouTubeVideoId:s}=await Promise.resolve().then(()=>(j_(),NS)),a=F(e.src)&&s(e.src);return a?r(a,i):null}},Z_=Symbol(0),kO=["autoPlay","canAirPlay","canFullscreen","canGoogleCast","canLoad","canLoadPoster","canPictureInPicture","canPlay","canSeek","ended","fullscreen","isAirPlayConnected","isGoogleCastConnected","live","liveEdge","loop","mediaType","muted","paused","pictureInPicture","playing","playsInline","remotePlaybackState","remotePlaybackType","seeking","started","streamType","viewType","waiting"],EO={artist:"",autoplay:!1,autoPlay:!1,clipStartTime:0,clipEndTime:0,controls:!1,currentTime:0,crossorigin:null,crossOrigin:null,duration:-1,fullscreenOrientation:"landscape",googleCast:{},load:"visible",posterLoad:"visible",logLevel:"silent",loop:!1,muted:!1,paused:!0,playsinline:!1,playsInline:!1,playbackRate:1,poster:"",preload:"metadata",preferNativeHLS:!1,src:"",title:"",controlsDelay:2e3,hideControlsOnMouseLeave:!1,viewType:"unknown",streamType:"unknown",volume:1,liveEdgeTolerance:10,minLiveDVRWindow:60,keyDisabled:!1,keyTarget:"player",keyShortcuts:OP,storage:null},Mh=class extends Yi{constructor(e,n){super(),this._type=e,this._callback=n}async onAttach(e){if(N)return;let n=this.$props[this._type]();if(n==="eager")requestAnimationFrame(this._callback);else if(n==="idle")n_(this._callback);else if(n==="visible"){let i,r=new IntersectionObserver(s=>{this.scope&&s[0].isIntersecting&&(i?.(),i=void 0,this._callback())});r.observe(e),i=G(()=>r.disconnect())}}},aw=class{constructor(e,n){this._handle=e,this._media=n,this._notify=(i,...r)=>{N||this._handle(new j(i,{detail:r?.[0],trigger:r?.[1]}))}}async _ready(e,n){if(!N)return La(async()=>{this._media;let{autoPlay:i,canPlay:r,started:s,duration:a,seekable:o,buffered:l,remotePlaybackInfo:c,playsInline:u}=this._media.$state;if(r())return;let d={duration:e?.duration??a(),seekable:e?.seekable??o(),buffered:e?.buffered??l(),provider:this._media.$provider()};this._notify("can-play",d,n),Zn();let p=this._media.$provider(),{storage:h}=this._media,{muted:y,volume:v,clipStartTime:_,playbackRate:m}=this._media.$props,f=c()?.savedState?.currentTime,g=c()?.savedState?.paused===!1,x=f??await h?.getTime()??_(),T=g||i();p&&(p.setVolume(await h?.getVolume()??v()),p.setMuted(await h?.getMuted()??y()),p.setPlaybackRate?.(await h?.getPlaybackRate()??m()),p.setPlaysInline?.(u()),x>0&&p.setCurrentTime(x)),r()&&T&&!s()&&await this._attemptAutoplay(n),c.set(null)})}async _attemptAutoplay(e){let{player:n,$state:{autoPlaying:i,muted:r}}=this._media;i.set(!0);let s=new j("auto-play-attempt",{trigger:e});try{await n.play(s)}catch{}}},ow=class{constructor(){this._queue=new Map}_enqueue(e,n){this._queue.set(e,n)}_serve(e){let n=this._peek(e);return this._queue.delete(e),n}_peek(e){return this._queue.get(e)}_delete(e){this._queue.delete(e)}_clear(){this._queue.clear()}},Rh=class{constructor(){this._serving=!1,this._pending=qi(),this._queue=new Map}get _size(){return this._queue.size}get _isServing(){return this._serving}async _waitForFlush(){this._serving||await this._pending.promise}_enqueue(e,n){if(this._serving){n();return}this._queue.delete(e),this._queue.set(e,n)}_serve(e){this._queue.get(e)?.(),this._queue.delete(e)}_start(){this._flush(),this._serving=!0,this._queue.size>0&&this._flush()}_stop(){this._serving=!1}_reset(){this._stop(),this._queue.clear(),this._release()}_flush(){for(let e of this._queue.keys())this._serve(e);this._release()}_release(){this._pending.resolve(),this._pending=qi()}};lw=class extends Yi{constructor(e,n,i){super(),this._stateMgr=e,this._request=n,this._media=i,this._providerQueue=new Rh,this._wasPIPActive=!1,this._$provider=i.$provider,this._controls=new _h,this._fullscreen=new fh,this._orientation=new xw}onAttach(){this.listen("fullscreen-change",this._onFullscreenChange.bind(this))}onConnect(){let e=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),n=this._handleRequest.bind(this);for(let i of e)i.startsWith("media-")&&this.listen(i,n);this._attachLoadPlayListener(),b(this._watchProvider.bind(this)),b(this._onControlsDelayChange.bind(this)),b(this._onAirPlaySupportChange.bind(this)),b(this._onGoogleCastSupportChange.bind(this)),b(this._onFullscreenSupportChange.bind(this)),b(this._onPiPSupportChange.bind(this))}onDestroy(){this._providerQueue._reset()}_attachLoadPlayListener(){let{load:e}=this.$props,{canLoad:n}=this.$state;if(e()!=="play"||n())return;let i=this.listen("media-play-request",r=>{this._handleLoadPlayStrategy(r),i()})}_watchProvider(){let e=this._$provider(),n=this.$state.canPlay();return e&&n&&this._providerQueue._start(),()=>{this._providerQueue._stop()}}_handleRequest(e){e.stopPropagation(),!e.defaultPrevented&&this[e.type]&&(C(this._$provider)?this[e.type](e):this._providerQueue._enqueue(e.type,()=>{C(this._$provider)&&this[e.type](e)}))}async _play(e){if(N)return;let{canPlay:n,paused:i,autoPlaying:r}=this.$state;if(!this._handleLoadPlayStrategy(e)&&!(!C(i)&&!this._request._looping)){e&&this._request._queue._enqueue("media-play-request",e);try{let s=C(this._$provider);return J_(s,C(n)),await s.play()}catch(s){let a=this.createEvent("play-fail",{detail:vi(s),trigger:e});throw a.autoPlay=r(),this._stateMgr._handle(a),s}}}_handleLoadPlayStrategy(e){let{load:n}=this.$props,{canLoad:i}=this.$state;if(n()==="play"&&!i()){let r=this.createEvent("media-start-loading",{trigger:e});return this.dispatchEvent(r),this._providerQueue._enqueue("media-play-request",async()=>{try{await this._play(r)}catch{}}),!0}return!1}async _pause(e){if(N)return;let{canPlay:n,paused:i}=this.$state;if(!C(i)){e&&this._request._queue._enqueue("media-pause-request",e);try{let r=C(this._$provider);return J_(r,C(n)),await r.pause()}catch(r){throw this._request._queue._delete("media-pause-request"),r}}}_seekToLiveEdge(e){if(N)return;let{canPlay:n,live:i,liveEdge:r,canSeek:s,liveSyncPosition:a,seekableEnd:o,userBehindLiveEdge:l}=this.$state;if(l.set(!1),C(()=>!i()||r()||!s()))return;let c=C(this._$provider);J_(c,C(n)),e&&this._request._queue._enqueue("media-seek-request",e);let u=o()-2;c.setCurrentTime(Math.min(u,a()??u))}async _enterFullscreen(e="prefer-media",n){if(N)return;let i=this._getFullscreenAdapter(e);if(sP(e,i),!i.active)return C(this.$state.pictureInPicture)&&(this._wasPIPActive=!0,await this._exitPictureInPicture(n)),n&&this._request._queue._enqueue("media-enter-fullscreen-request",n),i.enter()}async _exitFullscreen(e="prefer-media",n){if(N)return;let i=this._getFullscreenAdapter(e);if(sP(e,i),!!i.active){n&&this._request._queue._enqueue("media-exit-fullscreen-request",n);try{let r=await i.exit();return this._wasPIPActive&&C(this.$state.canPictureInPicture)&&await this._enterPictureInPicture(),r}finally{this._wasPIPActive=!1}}}_getFullscreenAdapter(e){let n=C(this._$provider);return e==="prefer-media"&&this._fullscreen.supported||e==="media"?this._fullscreen:n?.fullscreen}async _enterPictureInPicture(e){if(!N&&(this._throwIfPIPNotSupported(),!this.$state.pictureInPicture()))return e&&this._request._queue._enqueue("media-enter-pip-request",e),await this._$provider().pictureInPicture.enter()}async _exitPictureInPicture(e){if(!N&&(this._throwIfPIPNotSupported(),!!this.$state.pictureInPicture()))return e&&this._request._queue._enqueue("media-exit-pip-request",e),await this._$provider().pictureInPicture.exit()}_throwIfPIPNotSupported(){if(!this.$state.canPictureInPicture())throw Error("[vidstack] no pip support")}_onControlsDelayChange(){this._controls.defaultDelay=this.$props.controlsDelay()}_onAirPlaySupportChange(){let{canAirPlay:e}=this.$state,n=!!this._$provider()?.airPlay?.supported;e.set(n)}_onGoogleCastSupportChange(){let{canGoogleCast:e,source:n}=this.$state,i=oc&&!ah&&oh(n());e.set(i)}_onFullscreenSupportChange(){let{canFullscreen:e}=this.$state,n=this._fullscreen.supported||!!this._$provider()?.fullscreen?.supported;e.set(n)}_onPiPSupportChange(){let{canPictureInPicture:e}=this.$state,n=!!this._$provider()?.pictureInPicture?.supported;e.set(n)}async"media-airplay-request"(e){try{await this._requestAirPlay(e)}catch{}}async _requestAirPlay(e){try{let n=this._$provider()?.airPlay;if(!n?.supported)throw Error("No AirPlay adapter.");return e&&this._request._queue._enqueue("media-airplay-request",e),await n.prompt()}catch(n){throw this._request._queue._delete("media-airplay-request"),n}}async"media-google-cast-request"(e){try{await this._requestGoogleCast(e)}catch{}}async _requestGoogleCast(e){try{let{canGoogleCast:n}=this.$state;if(!C(n))throw new Error("Cast not available.");if(Jn("https://www.gstatic.com"),!this._googleCastLoader){let r=await Promise.resolve().then(()=>(Y_(),jS)).then(function(s){return s.d});this._googleCastLoader=new r.GoogleCastLoader}await this._googleCastLoader.prompt(this._media),e&&this._request._queue._enqueue("media-google-cast-request",e);let i=C(this.$state.remotePlaybackState)!=="disconnected";i&&this.$state.remotePlaybackInfo.set(r=>({...r,savedState:{paused:C(this.$state.paused),currentTime:C(this.$state.currentTime)}})),this.$state.remotePlaybackLoader.set(i?this._googleCastLoader:null)}catch(n){throw this._request._queue._delete("media-google-cast-request"),n}}"media-audio-track-change-request"(e){if(this._media.audioTracks.readonly)return;let n=e.detail,i=this._media.audioTracks[n];if(i){let r=e.type;this._request._queue._enqueue(r,e),i.selected=!0}}async"media-enter-fullscreen-request"(e){try{await this._enterFullscreen(e.detail,e)}catch(n){this._onFullscreenError(n,e)}}async"media-exit-fullscreen-request"(e){try{await this._exitFullscreen(e.detail,e)}catch(n){this._onFullscreenError(n,e)}}async _onFullscreenChange(e){let n=C(this.$props.fullscreenOrientation),i=e.detail;if(!(Ie(n)||!this._orientation.supported))if(i){if(this._orientation.locked)return;this.dispatch("media-orientation-lock-request",{detail:n,trigger:e})}else this._orientation.locked&&this.dispatch("media-orientation-unlock-request",{trigger:e})}_onFullscreenError(e,n){this._stateMgr._handle(this.createEvent("fullscreen-error",{detail:vi(e)}))}async"media-orientation-lock-request"(e){let n=e.type;try{this._request._queue._enqueue(n,e),await this._orientation.lock(e.detail)}catch{this._request._queue._delete(n)}}async"media-orientation-unlock-request"(e){let n=e.type;try{this._request._queue._enqueue(n,e),await this._orientation.unlock()}catch{this._request._queue._delete(n)}}async"media-enter-pip-request"(e){try{await this._enterPictureInPicture(e)}catch(n){this._onPictureInPictureError(n,e)}}async"media-exit-pip-request"(e){try{await this._exitPictureInPicture(e)}catch(n){this._onPictureInPictureError(n,e)}}_onPictureInPictureError(e,n){this._stateMgr._handle(this.createEvent("picture-in-picture-error",{detail:vi(e)}))}"media-live-edge-request"(e){let{live:n,liveEdge:i,canSeek:r}=this.$state;if(!(!n()||i()||!r())){this._request._queue._enqueue("media-seek-request",e);try{this._seekToLiveEdge()}catch{this._request._queue._delete("media-seek-request")}}}async"media-loop-request"(e){try{this._request._looping=!0,this._request._replaying=!0,await this._play(e)}catch{this._request._looping=!1}}async"media-pause-request"(e){if(!this.$state.paused())try{await this._pause(e)}catch{}}async"media-play-request"(e){if(this.$state.paused())try{await this._play(e)}catch{}}"media-rate-change-request"(e){let{playbackRate:n,canSetPlaybackRate:i}=this.$state;if(n()===e.detail||!i())return;let r=this._$provider();r?.setPlaybackRate&&(this._request._queue._enqueue("media-rate-change-request",e),r.setPlaybackRate(e.detail))}"media-quality-change-request"(e){if(this._media.qualities.readonly)return;this._request._queue._enqueue("media-quality-change-request",e);let n=e.detail;if(n<0)this._media.qualities.autoSelect(e);else{let i=this._media.qualities[n];i&&(i.selected=!0)}}"media-pause-controls-request"(e){let n=e.type;this._request._queue._enqueue(n,e),this._controls.pause(e)}"media-resume-controls-request"(e){let n=e.type;this._request._queue._enqueue(n,e),this._controls.resume(e)}"media-seek-request"(e){let{seekableStart:n,seekableEnd:i,ended:r,canSeek:s,live:a,userBehindLiveEdge:o,clipStartTime:l}=this.$state;r()&&(this._request._replaying=!0);let c=e.type;this._request._seeking=!1,this._request._queue._delete(c);let u=Math.min(Math.max(n()+.1,e.detail+l()),i()-.1);!Number.isFinite(u)||!s()||(this._request._queue._enqueue(c,e),this._$provider().setCurrentTime(u),a()&&e.isOriginTrusted&&Math.abs(i()-u)>=2&&o.set(!0))}"media-seeking-request"(e){let n=e.type;this._request._queue._enqueue(n,e),this.$state.seeking.set(!0),this._request._seeking=!0}"media-start-loading"(e){if(this.$state.canLoad())return;let n=e.type;this._request._queue._enqueue(n,e),this._stateMgr._handle(this.createEvent("can-load"))}"media-poster-start-loading"(e){if(this.$state.canLoadPoster())return;let n=e.type;this._request._queue._enqueue(n,e),this._stateMgr._handle(this.createEvent("can-load-poster"))}"media-text-track-change-request"(e){let{index:n,mode:i}=e.detail,r=this._media.textTracks[n];if(r){let s=e.type;this._request._queue._enqueue(s,e),r.setMode(i,e)}}"media-mute-request"(e){if(this.$state.muted())return;let n=e.type;this._request._queue._enqueue(n,e),this._$provider().setMuted(!0)}"media-unmute-request"(e){let{muted:n,volume:i}=this.$state;if(!n())return;let r=e.type;this._request._queue._enqueue(r,e),this._media.$provider().setMuted(!1),i()===0&&(this._request._queue._enqueue(r,e),this._$provider().setVolume(.25))}"media-volume-change-request"(e){let{muted:n,volume:i}=this.$state,r=e.detail;if(i()===r)return;let s=e.type;this._request._queue._enqueue(s,e),this._$provider().setVolume(r),r>0&&n()&&(this._request._queue._enqueue(s,e),this._$provider().setMuted(!1))}_logError(e,n,i){}};cw=class{constructor(){this._seeking=!1,this._looping=!1,this._replaying=!1,this._queue=new ow}},TO=new Set(["auto-play","auto-play-fail","can-load","sources-change","source-change","load-start","abort","error","loaded-metadata","loaded-data","can-play","play","play-fail","pause","playing","seeking","seeked","waiting"]),uw=class extends Yi{constructor(e,n){super(),this._request=e,this._media=n,this._trackedEvents=new Map,this._clipEnded=!1,this._firingWaiting=!1,this._isPlayingOnDisconnect=!1,this.seeking=iu(i=>{let{seeking:r,realCurrentTime:s,paused:a}=this.$state;r.set(!0),s.set(i.detail),this._satisfyRequest("media-seeking-request",i),a()&&(this._waitingTrigger=i,this._fireWaiting())},150,{leading:!0}),this._fireWaiting=Pw(()=>{if(!this._waitingTrigger)return;this._firingWaiting=!0;let{waiting:i,playing:r}=this.$state;i.set(!0),r.set(!1);let s=this.createEvent("waiting",{trigger:this._waitingTrigger});this._trackedEvents.set("waiting",s),this.dispatch(s),this._waitingTrigger=void 0,this._firingWaiting=!1},300)}onAttach(e){e.setAttribute("aria-busy","true"),this.listen("fullscreen-change",this["fullscreen-change"].bind(this)),this.listen("fullscreen-error",this["fullscreen-error"].bind(this)),this.listen("orientation-change",this["orientation-change"].bind(this))}onConnect(e){b(this._watchCanSetVolume.bind(this)),this._addTextTrackListeners(),this._addQualityListeners(),this._addAudioTrackListeners(),this._resumePlaybackOnConnect(),G(this._pausePlaybackOnDisconnect.bind(this))}_handle(e){if(!this.scope)return;let n=e.type;this[e.type]?.(e),N||(TO.has(n)&&this._trackedEvents.set(n,e),this.dispatch(e))}_resumePlaybackOnConnect(){this._isPlayingOnDisconnect&&(requestAnimationFrame(()=>{this.scope&&this._media.remote.play(new j("dom-connect"))}),this._isPlayingOnDisconnect=!1)}_pausePlaybackOnDisconnect(){this._isPlayingOnDisconnect||(this._isPlayingOnDisconnect=!this._media.$state.paused(),this._media.$provider()?.pause())}_resetTracking(){this._stopWaiting(),this._clipEnded=!1,this._request._replaying=!1,this._request._looping=!1,this._firingWaiting=!1,this._waitingTrigger=void 0,this._trackedEvents.clear()}_satisfyRequest(e,n){let i=this._request._queue._serve(e);i&&(n.request=i,n.triggers.add(i))}_addTextTrackListeners(){this._onTextTracksChange(),this._onTextTrackModeChange();let e=this._media.textTracks;S(e,"add",this._onTextTracksChange.bind(this)),S(e,"remove",this._onTextTracksChange.bind(this)),S(e,"mode-change",this._onTextTrackModeChange.bind(this))}_addQualityListeners(){let e=this._media.qualities;S(e,"add",this._onQualitiesChange.bind(this)),S(e,"remove",this._onQualitiesChange.bind(this)),S(e,"change",this._onQualityChange.bind(this)),S(e,"auto-change",this._onAutoQualityChange.bind(this)),S(e,"readonly-change",this._onCanSetQualityChange.bind(this))}_addAudioTrackListeners(){let e=this._media.audioTracks;S(e,"add",this._onAudioTracksChange.bind(this)),S(e,"remove",this._onAudioTracksChange.bind(this)),S(e,"change",this._onAudioTrackChange.bind(this))}_onTextTracksChange(e){let{textTracks:n}=this.$state;n.set(this._media.textTracks.toArray()),this.dispatch("text-tracks-change",{detail:n(),trigger:e})}_onTextTrackModeChange(e){e&&this._satisfyRequest("media-text-track-change-request",e);let n=this._media.textTracks.selected,{textTrack:i}=this.$state;i()!==n&&(i.set(n),this.dispatch("text-track-change",{detail:n,trigger:e}))}_onAudioTracksChange(e){let{audioTracks:n}=this.$state;n.set(this._media.audioTracks.toArray()),this.dispatch("audio-tracks-change",{detail:n(),trigger:e})}_onAudioTrackChange(e){let{audioTrack:n}=this.$state;n.set(this._media.audioTracks.selected),e&&this._satisfyRequest("media-audio-track-change-request",e),this.dispatch("audio-track-change",{detail:n(),trigger:e})}_onQualitiesChange(e){let{qualities:n}=this.$state;n.set(this._media.qualities.toArray()),this.dispatch("qualities-change",{detail:n(),trigger:e})}_onQualityChange(e){let{quality:n}=this.$state;n.set(this._media.qualities.selected),e&&this._satisfyRequest("media-quality-change-request",e),this.dispatch("quality-change",{detail:n(),trigger:e})}_onAutoQualityChange(){this.$state.autoQuality.set(this._media.qualities.auto)}_onCanSetQualityChange(){this.$state.canSetQuality.set(!this._media.qualities.readonly)}_watchCanSetVolume(){let{canSetVolume:e,isGoogleCastConnected:n}=this.$state;if(n()){e.set(!1);return}mP().then(e.set)}"provider-change"(e){let n=this._media.$provider(),i=e.detail;n?.type!==i?.type&&(n?.destroy?.(),n?.scope?.dispose(),this._media.$provider.set(e.detail),n&&e.detail===null&&this._resetMediaState(e))}"provider-loader-change"(e){}"auto-play"(e){this.$state.autoPlayError.set(null)}"auto-play-fail"(e){this.$state.autoPlayError.set(e.detail),this._resetTracking()}"can-load"(e){this.$state.canLoad.set(!0),this._trackedEvents.set("can-load",e),this._media.textTracks[W._canLoad](),this._satisfyRequest("media-start-loading",e)}"can-load-poster"(e){this.$state.canLoadPoster.set(!0),this._trackedEvents.set("can-load-poster",e),this._satisfyRequest("media-poster-start-loading",e)}"media-type-change"(e){let n=this._trackedEvents.get("source-change");n&&e.triggers.add(n);let i=this.$state.viewType();this.$state.mediaType.set(e.detail);let r=this.$state.providedViewType(),s=r==="unknown"?e.detail:r;i!==s&&(N?this.$state.inferredViewType.set(s):setTimeout(()=>{requestAnimationFrame(()=>{this.scope&&(this.$state.inferredViewType.set(e.detail),this.dispatch("view-type-change",{detail:s,trigger:e}))})},0))}"stream-type-change"(e){let n=this._trackedEvents.get("source-change");n&&e.triggers.add(n);let{streamType:i,inferredStreamType:r}=this.$state;r.set(e.detail),e.detail=i()}"rate-change"(e){let{storage:n}=this._media,{canPlay:i}=this.$state;this.$state.playbackRate.set(e.detail),this._satisfyRequest("media-rate-change-request",e),i()&&n?.setPlaybackRate?.(e.detail)}"remote-playback-change"(e){let{remotePlaybackState:n,remotePlaybackType:i}=this.$state,{type:r,state:s}=e.detail,a=s==="connected";i.set(r),n.set(s);let o=r==="airplay"?"media-airplay-request":"media-google-cast-request";if(a)this._satisfyRequest(o,e);else{let l=this._request._queue._peek(o);l&&(e.request=l,e.triggers.add(l))}}"sources-change"(e){this.$state.sources.set(e.detail)}"source-change"(e){let n=this._trackedEvents.get("sources-change");n&&e.triggers.add(n),this._resetMediaState(e),this._trackedEvents.set(e.type,e),this.$state.source.set(e.detail),this.el?.setAttribute("aria-busy","true")}_resetMediaState(e){this._media.audioTracks[Y._reset](e),this._media.qualities[Y._reset](e),this._resetTracking(),_P(this._media.$state)}abort(e){let n=this._trackedEvents.get("source-change");n&&e.triggers.add(n);let i=this._trackedEvents.get("can-load");i&&!e.triggers.hasType("can-load")&&e.triggers.add(i)}"load-start"(e){let n=this._trackedEvents.get("source-change");n&&e.triggers.add(n)}error(e){this.$state.error.set(e.detail);let n=this._trackedEvents.get("abort");n&&e.triggers.add(n)}"loaded-metadata"(e){let n=this._trackedEvents.get("load-start");n&&e.triggers.add(n)}"loaded-data"(e){let n=this._trackedEvents.get("load-start");n&&e.triggers.add(n)}"can-play"(e){let n=this._trackedEvents.get("loaded-metadata");n&&e.triggers.add(n),this._onCanPlayDetail(e.detail),this.el?.setAttribute("aria-busy","false")}"can-play-through"(e){this._onCanPlayDetail(e.detail);let n=this._trackedEvents.get("can-play");n&&e.triggers.add(n)}_onCanPlayDetail(e){let{seekable:n,seekableEnd:i,buffered:r,intrinsicDuration:s,canPlay:a}=this.$state;a.set(!0),r.set(e.buffered),n.set(e.seekable),s.set(i())}"duration-change"(e){let{live:n,intrinsicDuration:i}=this.$state,r=e.detail;n()||i.set(Number.isNaN(r)?0:r)}progress(e){let{buffered:n,seekable:i,live:r,intrinsicDuration:s,seekableEnd:a}=this.$state,o=e.detail;n.set(o.buffered),i.set(o.seekable),r()&&(s.set(a),this.dispatch("duration-change",{detail:a(),trigger:e}))}play(e){let{paused:n,autoPlayError:i,ended:r,autoPlaying:s,playsInline:a,pointer:o,muted:l,viewType:c}=this.$state;if(this._resetPlaybackIfNeeded(),!n()&&!this._request._looping){e.stopImmediatePropagation();return}e.autoPlay=s();let u=this._trackedEvents.get("waiting");u&&e.triggers.add(u),this._satisfyRequest("media-play-request",e),this._trackedEvents.set("play",e),n.set(!1),i.set(null),e.autoPlay&&(this._handle(this.createEvent("auto-play",{detail:{muted:l()},trigger:e})),s.set(!1)),(r()||this._request._replaying)&&(this._request._replaying=!1,r.set(!1),this._handle(this.createEvent("replay",{trigger:e}))),!a()&&c()==="video"&&o()==="coarse"&&this._media.remote.enterFullscreen("prefer-media",e),this._request._looping&&e.stopImmediatePropagation()}_resetPlaybackIfNeeded(e){if(!C(this._media.$provider))return;let{ended:i,seekableStart:r,clipStartTime:s,clipEndTime:a,realCurrentTime:o,duration:l}=this.$state,c=o()0&&o()>=a()||Math.abs(o()-l())<.1||i();return c&&this.dispatch("media-seek-request",{detail:(s()>0?0:r())+.1,trigger:e}),c}"play-fail"(e){let{muted:n,autoPlaying:i}=this.$state,r=this._trackedEvents.get("play");r&&e.triggers.add(r),this._satisfyRequest("media-play-request",e);let{paused:s,playing:a}=this.$state;s.set(!0),a.set(!1),this._resetTracking(),this._trackedEvents.set("play-fail",e),e.autoPlay&&(this._handle(this.createEvent("auto-play-fail",{detail:{muted:n(),error:e.detail},trigger:e})),i.set(!1))}playing(e){let n=this._trackedEvents.get("play"),i=this._trackedEvents.get("seeked");n?e.triggers.add(n):i&&e.triggers.add(i),setTimeout(()=>this._resetTracking(),0);let{paused:r,playing:s,live:a,liveSyncPosition:o,seekableEnd:l,started:c,currentTime:u,seeking:d,ended:p}=this.$state;if(r.set(!1),s.set(!0),d.set(!1),p.set(!1),this._request._looping){e.stopImmediatePropagation(),this._request._looping=!1;return}if(a()&&!c()&&u()===0){let h=o()??l()-2;Number.isFinite(h)&&this._media.$provider().setCurrentTime(h)}this.started(e)}started(e){let{started:n}=this.$state;n()||(n.set(!0),this._handle(this.createEvent("started",{trigger:e})))}pause(e){this.el?.isConnected||(this._isPlayingOnDisconnect=!0),this._satisfyRequest("media-pause-request",e);let n=this._trackedEvents.get("seeked");if(n&&e.triggers.add(n),this._clipEnded){e.stopImmediatePropagation(),this._handle(this.createEvent("end",{trigger:e})),this._clipEnded=!1;return}if(this._request._looping){e.stopImmediatePropagation();return}this._resetTracking();let{paused:i,playing:r}=this.$state;i.set(!0),r.set(!1)}"time-update"(e){if(this._request._looping){e.stopImmediatePropagation();return}let{realCurrentTime:n,played:i,waiting:r,clipEndTime:s,loop:a}=this.$state,o=s(),l=e.detail;n.set(l.currentTime),i.set(l.played),r.set(!1);for(let c of this._media.textTracks)c[W._updateActiveCues](l.currentTime,e);o>0&&l.currentTime>=o&&(a()&&(this._request._looping=!0),this._clipEnded=!0,this.dispatch("media-pause-request",{trigger:e})),this._saveTime()}_saveTime(){let{storage:e}=this._media,{canPlay:n,realCurrentTime:i}=this.$state;n()&&e?.setTime?.(i())}"volume-change"(e){let{storage:n}=this._media,{volume:i,muted:r,canPlay:s}=this.$state,a=e.detail;i.set(a.volume),r.set(a.muted||a.volume===0),this._satisfyRequest("media-volume-change-request",e),this._satisfyRequest(a.muted?"media-mute-request":"media-unmute-request",e),s()&&(n?.setVolume?.(i()),n?.setMuted?.(r()))}seeked(e){let{seeking:n,realCurrentTime:i,paused:r,duration:s,ended:a}=this.$state;if(this._request._seeking)n.set(!0),e.stopImmediatePropagation();else if(n()){let o=this._trackedEvents.get("waiting");o&&e.triggers.add(o);let l=this._trackedEvents.get("seeking");l&&!e.triggers.has(l)&&e.triggers.add(l),r()&&this._stopWaiting(),n.set(!1),e.detail!==s()&&a.set(!1),i.set(e.detail),this._satisfyRequest("media-seek-request",e);let c=e?.originEvent;c?.isTrusted&&!/seek/.test(c.type)&&this.started(e)}}waiting(e){this._firingWaiting||this._request._seeking||(e.stopImmediatePropagation(),this._waitingTrigger=e,this._fireWaiting())}end(e){let{loop:n}=this.$state;if(n()){setTimeout(()=>{requestAnimationFrame(()=>{this.dispatch("media-loop-request",{trigger:e})})},10);return}this._onEnded(e)}_onEnded(e){let{paused:n,seeking:i,ended:r,duration:s}=this.$state;n()||this.dispatch("pause",{trigger:e}),i()&&this.dispatch("seeked",{detail:s(),trigger:e}),r.set(!0),this._resetTracking(),this.dispatch("ended",{trigger:e})}_stopWaiting(){this._fireWaiting.cancel(),this.$state.waiting.set(!1)}"fullscreen-change"(e){let n=e.detail;this.$state.fullscreen.set(n),this._satisfyRequest(n?"media-enter-fullscreen-request":"media-exit-fullscreen-request",e)}"fullscreen-error"(e){this._satisfyRequest("media-enter-fullscreen-request",e),this._satisfyRequest("media-exit-fullscreen-request",e)}"orientation-change"(e){let n=e.detail.lock;this._satisfyRequest(n?"media-orientation-lock-request":"media-orientation-unlock-request",e)}"picture-in-picture-change"(e){let n=e.detail;this.$state.pictureInPicture.set(n),this._satisfyRequest(n?"media-enter-pip-request":"media-exit-pip-request",e)}"picture-in-picture-error"(e){this._satisfyRequest("media-enter-pip-request",e),this._satisfyRequest("media-exit-pip-request",e)}"title-change"(e){e.trigger&&(e.stopImmediatePropagation(),this.$state.inferredTitle.set(e.detail))}"poster-change"(e){e.trigger&&(e.stopImmediatePropagation(),this.$state.inferredPoster.set(e.detail))}},dw=class extends Yi{onSetup(){this._init(),!N&&(b(this._watchArtist.bind(this)),b(this._watchAutoplay.bind(this)),b(this._watchClipTimes.bind(this)),b(this._watchControls.bind(this)),b(this._watchCrossOrigin.bind(this)),b(this._watchDuration.bind(this)),b(this._watchLive.bind(this)),b(this._watchLiveEdge.bind(this)),b(this._watchLiveTolerance.bind(this)),b(this._watchLoop.bind(this)),b(this._watchPlaysInline.bind(this)),b(this._watchPoster.bind(this)),b(this._watchProvidedTypes.bind(this)),b(this._watchTitle.bind(this)))}_init(){let e={duration:"providedDuration",poster:"providedPoster",streamType:"providedStreamType",title:"providedTitle",viewType:"providedViewType"},n=new Set(["currentTime","paused","playbackRate","volume"]);for(let i of Object.keys(this.$props))n.has(i)||this.$state[e[i]??i]?.set(this.$props[i]());this.$state.muted.set(this.$props.muted()||this.$props.volume()===0)}_watchProvidedTypes(){let{viewType:e,streamType:n,title:i,poster:r}=this.$props;this.$state.providedPoster.set(r()),this.$state.providedStreamType.set(n()),this.$state.providedViewType.set(e()),this.$state.providedTitle.set(i())}_watchLogLevel(){}_watchArtist(){let{artist:e}=this.$props;this.$state.artist.set(e())}_watchTitle(){let{title:e}=this.$state;this.dispatch("title-change",{detail:e()})}_watchAutoplay(){let e=this.$props.autoPlay()||this.$props.autoplay();this.$state.autoPlay.set(e),this.dispatch("auto-play-change",{detail:e})}_watchLoop(){let e=this.$props.loop();this.$state.loop.set(e),this.dispatch("loop-change",{detail:e})}_watchControls(){let e=this.$props.controls();this.$state.controls.set(e)}_watchPoster(){let{poster:e}=this.$state;this.dispatch("poster-change",{detail:e()})}_watchCrossOrigin(){let e=this.$props.crossOrigin()??this.$props.crossorigin(),n=e===!0?"":e;this.$state.crossOrigin.set(n)}_watchDuration(){let{providedDuration:e}=this.$state;e.set(this.$props.duration())}_watchPlaysInline(){let e=this.$props.playsInline()||this.$props.playsinline();this.$state.playsInline.set(e),this.dispatch("plays-inline-change",{detail:e})}_watchClipTimes(){let{clipStartTime:e,clipEndTime:n}=this.$props;this.$state.clipStartTime.set(e()),this.$state.clipEndTime.set(n())}_watchLive(){this.dispatch("live-change",{detail:this.$state.live()})}_watchLiveTolerance(){this.$state.liveEdgeTolerance.set(this.$props.liveEdgeTolerance()),this.$state.minLiveDVRWindow.set(this.$props.minLiveDVRWindow())}_watchLiveEdge(){this.dispatch("live-edge-change",{detail:this.$state.liveEdge()})}},SO=class pw extends Yi{constructor(){super()}onConnect(){b(this._onMetadataChange.bind(this)),b(this._onPlaybackStateChange.bind(this));let e=this._handleAction.bind(this);for(let n of pw._actions)navigator.mediaSession.setActionHandler(n,e);G(this._onDisconnect.bind(this))}_onDisconnect(){for(let e of pw._actions)navigator.mediaSession.setActionHandler(e,null)}_onMetadataChange(){let{title:e,artist:n,poster:i}=this.$state;navigator.mediaSession.metadata=new MediaMetadata({title:e(),artist:n(),artwork:[{src:i()}]})}_onPlaybackStateChange(){let{canPlay:e,paused:n}=this.$state;navigator.mediaSession.playbackState=e()?n()?"paused":"playing":"none"}_handleAction(e){let n=new j("media-session-action",{detail:e});switch(e.action){case"play":this.dispatch("media-play-request",{trigger:n});break;case"pause":this.dispatch("media-pause-request",{trigger:n});break;case"seekto":case"seekforward":case"seekbackward":this.dispatch("media-seek-request",{detail:Be(e.seekTime)?e.seekTime:this.$state.currentTime()+(e.seekOffset??10),trigger:n});break}}};SO._actions=["play","pause","seekforward","seekbackward","seekto"];Lh=D(!1);N||(S(document,"pointerdown",()=>{Lh.set(!1)}),S(document,"keydown",t=>{t.metaKey||t.altKey||t.ctrlKey||Lh.set(!0)}));pn=class extends Mt{constructor(){super(...arguments),this._focused=D(!1)}onConnect(e){b(()=>{if(!Lh()){this._focused.set(!1),uh(e,!1),this.listen("pointerenter",this._onPointerEnter.bind(this)),this.listen("pointerleave",this._onPointerLeave.bind(this));return}let n=document.activeElement===e;this._focused.set(n),uh(e,n),this.listen("focus",this._onFocus.bind(this)),this.listen("blur",this._onBlur.bind(this))})}focused(){return this._focused()}_onFocus(){this._focused.set(!0),uh(this.el,!0)}_onBlur(){this._focused.set(!1),uh(this.el,!1)}_onPointerEnter(){aP(this.el,!0)}_onPointerLeave(){aP(this.el,!1)}};PO=Object.defineProperty,CO=Object.getOwnPropertyDescriptor,Ee=(t,e,n,i)=>{for(var r=i>1?void 0:i?CO(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&PO(e,n,r),r},he=class ph extends H{constructor(){super(),this.canPlayQueue=new Rh,this._skipTitleUpdate=!1,new dw;let e={player:this,qualities:new Th,audioTracks:new Eh,storage:null,$provider:D(null),$providerSetup:D(!1),$props:this.$props,$state:this.$state};e.remote=new Ba(void 0),e.remote.setPlayer(this),e.$iosControls=hi(this._isIOSControls.bind(this)),e.textTracks=new xh,e.textTracks[W._crossOrigin]=this.$state.crossOrigin,e.textRenderers=new bh(e),e.ariaKeys={},this._media=e,Rt(tu,e),this.orientation=new xw,new pn,new sw(e);let n=new cw;this._stateMgr=new uw(n,e),this._requestMgr=new lw(this._stateMgr,n,e),e.delegate=new aw(this._stateMgr._handle.bind(this._stateMgr),e),new Mh("load",this.startLoading.bind(this)),new Mh("posterLoad",this.startLoadingPoster.bind(this))}get _provider(){return this._media.$provider()}onSetup(){this._setupMediaAttributes(),b(this._watchCanPlay.bind(this)),b(this._watchMuted.bind(this)),b(this._watchPaused.bind(this)),b(this._watchVolume.bind(this)),b(this._watchCurrentTime.bind(this)),b(this._watchPlaysInline.bind(this)),b(this._watchPlaybackRate.bind(this))}onAttach(e){e.setAttribute("data-media-player",""),ve(e,"tabindex","0"),ve(e,"role","region"),b(this._watchStorage.bind(this)),N?this._watchTitle():b(this._watchTitle.bind(this)),N?this._watchOrientation():b(this._watchOrientation.bind(this)),S(e,"find-media-player",this._onFindPlayer.bind(this))}onConnect(e){YS&&Z(e,"data-iphone","");let n=window.matchMedia("(pointer: coarse)");this._onPointerChange(n),n.onchange=this._onPointerChange.bind(this);let i=new ResizeObserver(Mr(this._onResize.bind(this)));i.observe(e),b(this._onResize.bind(this)),this.dispatch("media-player-connect",{detail:this,bubbles:!0,composed:!0}),G(()=>{i.disconnect(),n.onchange=null})}onDestroy(){this._media.player=null,this.canPlayQueue._reset()}_watchTitle(){let e=this.$el,{title:n,live:i,viewType:r,providedTitle:s}=this.$state,a=i(),o=Gl(r()),l=o!=="Unknown"?`${a?"Live ":""}${o}`:a?"Live":"Media",c=n();Z(this.el,"aria-label",c?`${l} - ${c}`:l+" Player"),!N&&e?.hasAttribute("title")&&(this._skipTitleUpdate=!0,e?.removeAttribute("title"))}_watchOrientation(){let e=this.orientation.landscape?"landscape":"portrait";this.$state.orientation.set(e),Z(this.el,"data-orientation",e),this._onResize()}_watchCanPlay(){this.$state.canPlay()&&this._provider?this.canPlayQueue._start():this.canPlayQueue._stop()}_setupMediaAttributes(){if(ph[Z_]){this.setAttributes(ph[Z_]);return}let e={"data-load":function(){return this.$props.load()},"data-captions":function(){let i=this.$state.textTrack();return!!i&&We(i)},"data-ios-controls":function(){return this._media.$iosControls()},"data-controls":function(){return this.controls.showing},"data-buffering":function(){let{canLoad:i,canPlay:r,waiting:s}=this.$state;return i()&&(!r()||s())},"data-error":function(){let{error:i}=this.$state;return!!i()},"data-autoplay-error":function(){let{autoPlayError:i}=this.$state;return!!i()}},n={autoPlay:"autoplay",canAirPlay:"can-airplay",canPictureInPicture:"can-pip",pictureInPicture:"pip",playsInline:"playsinline",remotePlaybackState:"remote-state",remotePlaybackType:"remote-type",isAirPlayConnected:"airplay",isGoogleCastConnected:"google-cast"};for(let i of kO){let r="data-"+(n[i]??Aa(i));e[r]=function(){return this.$state[i]()}}delete e.title,ph[Z_]=e,this.setAttributes(e)}_onFindPlayer(e){e.detail(this)}_onResize(){if(N||!this.el)return;let e=this.el.clientWidth,n=this.el.clientHeight;this.$state.width.set(e),this.$state.height.set(n),lt(this.el,"--player-width",e+"px"),lt(this.el,"--player-height",n+"px")}_onPointerChange(e){if(N)return;let n=e.matches?"coarse":"fine";Z(this.el,"data-pointer",n),this.$state.pointer.set(n),this._onResize()}_isIOSControls(){let{playsInline:e,fullscreen:n}=this.$state;return YS&&!hP()&&this.$state.mediaType()==="video"&&(!e()||n())}get provider(){return this._provider}get controls(){return this._requestMgr._controls}get title(){return C(this.$state.providedTitle)}set title(e){if(this._skipTitleUpdate){this._skipTitleUpdate=!1;return}this.$state.providedTitle.set(e)}get qualities(){return this._media.qualities}get audioTracks(){return this._media.audioTracks}get textTracks(){return this._media.textTracks}get textRenderers(){return this._media.textRenderers}get paused(){return C(this.$state.paused)}set paused(e){this._queuePausedUpdate(e)}_watchPaused(){this._queuePausedUpdate(this.$props.paused())}_queuePausedUpdate(e){e?this.canPlayQueue._enqueue("paused",()=>this._requestMgr._pause()):this.canPlayQueue._enqueue("paused",()=>this._requestMgr._play())}get muted(){return C(this.$state.muted)}set muted(e){this.$props.muted.set(e)}_watchMuted(){this._queueMutedUpdate(this.$props.muted())}_queueMutedUpdate(e){this.canPlayQueue._enqueue("muted",()=>{this._provider&&this._provider.setMuted(e)})}get currentTime(){return C(this.$state.currentTime)}set currentTime(e){this._queueCurrentTimeUpdate(e)}_watchCurrentTime(){this._queueCurrentTimeUpdate(this.$props.currentTime())}_queueCurrentTimeUpdate(e){this.canPlayQueue._enqueue("currentTime",()=>{let{currentTime:n,clipStartTime:i,seekableStart:r,seekableEnd:s}=this.$state;e!==C(n)&&C(()=>{if(!this._provider)return;let a=Math.min(Math.max(r()+.1,e+i()),s()-.1);Number.isFinite(a)&&this._provider.setCurrentTime(a)})})}get volume(){return C(this.$state.volume)}set volume(e){this.$props.volume.set(e)}_watchVolume(){this._queueVolumeUpdate(this.$props.volume())}_queueVolumeUpdate(e){let n=Mw(0,e,1);this.canPlayQueue._enqueue("volume",()=>{this._provider&&this._provider.setVolume(n)})}get playbackRate(){return C(this.$state.playbackRate)}set playbackRate(e){this._queuePlaybackRateUpdate(e)}_watchPlaybackRate(){this._queuePlaybackRateUpdate(this.$props.playbackRate())}_queuePlaybackRateUpdate(e){this.canPlayQueue._enqueue("rate",()=>{this._provider&&this._provider.setPlaybackRate?.(e)})}_watchPlaysInline(){this._queuePlaysInlineUpdate(this.$props.playsInline())}_queuePlaysInlineUpdate(e){this.canPlayQueue._enqueue("playsinline",()=>{this._provider&&this._provider.setPlaysInline?.(e)})}_watchStorage(){let e=this.$props.storage(),n=F(e)?new wh:e;if(n?.onChange){let{source:i}=this.$state,r=F(e)?e:this.el?.id,s=hi(this._computeMediaId.bind(this));b(()=>n.onChange(i(),s(),r))}this._media.storage=n,this._media.textTracks.setStorage(n),G(()=>{n?.onDestroy?.(),this._media.storage=null,this._media.textTracks.setStorage(null)})}_computeMediaId(){let{clipStartTime:e,clipEndTime:n}=this.$props,{source:i}=this.$state,r=i();return r.src?`${r.src}:${e()}:${n()}`:null}async play(e){return this._requestMgr._play(e)}async pause(e){return this._requestMgr._pause(e)}async enterFullscreen(e,n){return this._requestMgr._enterFullscreen(e,n)}async exitFullscreen(e,n){return this._requestMgr._exitFullscreen(e,n)}enterPictureInPicture(e){return this._requestMgr._enterPictureInPicture(e)}exitPictureInPicture(e){return this._requestMgr._exitPictureInPicture(e)}seekToLiveEdge(e){this._requestMgr._seekToLiveEdge(e)}startLoading(e){this._media.delegate._notify("can-load",void 0,e)}startLoadingPoster(e){this._media.delegate._notify("can-load-poster",void 0,e)}requestAirPlay(e){return this._requestMgr._requestAirPlay(e)}requestGoogleCast(e){return this._requestMgr._requestGoogleCast(e)}destroy(){this._media.remote.setPlayer(null),this.dispatch("destroy")}};he.props=EO;he.state=Ls;Ee([ee],he.prototype,"canPlayQueue",2);Ee([ee],he.prototype,"provider",1);Ee([ee],he.prototype,"controls",1);Ee([ee],he.prototype,"orientation",2);Ee([ee],he.prototype,"title",1);Ee([ee],he.prototype,"qualities",1);Ee([ee],he.prototype,"audioTracks",1);Ee([ee],he.prototype,"textTracks",1);Ee([ee],he.prototype,"textRenderers",1);Ee([ee],he.prototype,"paused",1);Ee([ee],he.prototype,"muted",1);Ee([ee],he.prototype,"currentTime",1);Ee([ee],he.prototype,"volume",1);Ee([ee],he.prototype,"playbackRate",1);Ee([Ne],he.prototype,"play",1);Ee([Ne],he.prototype,"pause",1);Ee([Ne],he.prototype,"enterFullscreen",1);Ee([Ne],he.prototype,"exitFullscreen",1);Ee([Ne],he.prototype,"enterPictureInPicture",1);Ee([Ne],he.prototype,"exitPictureInPicture",1);Ee([Ne],he.prototype,"seekToLiveEdge",1);Ee([Ne],he.prototype,"startLoading",1);Ee([Ne],he.prototype,"startLoadingPoster",1);Ee([Ne],he.prototype,"requestAirPlay",1);Ee([Ne],he.prototype,"requestGoogleCast",1);$O=he;GP=new Map,hw=class{constructor(e,n,i,r=[]){this._domSources=e,this._media=n,this._loader=i,this._initialize=!1;let s=new WP,a=new fc,o=new Ph,l=new $h,c=new Ch,u=[l,c];this._loaders=hi(()=>{let p=n.$state.remotePlaybackLoader(),h=n.$props.preferNativeHLS()?[...r,a,o,s,...u]:[...r,s,a,o,...u];return p?[p,...h]:h});let{$state:d}=n;d.sources.set(oP(n.$props.src()));for(let p of d.sources()){let h=this._loaders().find(v=>v.canPlay(p));if(!h)continue;let y=h.mediaType(p);this._media.$state.source.set(p),this._media.$state.mediaType.set(y),this._media.$state.inferredViewType.set(y),this._loader.set(h),this._initialize=!0}}get _notify(){return this._media.delegate._notify}connect(){let e=this._loader();this._initialize&&(this._notifySourceChange(this._media.$state.source(),e),this._notifyLoaderChange(e),this._initialize=!1),b(this._onSourcesChange.bind(this)),b(this._onSourceChange.bind(this)),b(this._onSetup.bind(this)),b(this._onLoadSource.bind(this)),b(this._onLoadPoster.bind(this))}_onSourcesChange(){this._notify("sources-change",[...oP(this._media.$props.src()),...this._domSources()])}_onSourceChange(){let{$state:e}=this._media,n=e.sources(),i=C(e.source),r=this._findNewSource(i,n);if(n[0]?.src&&!r.src&&!r.type){let{crossOrigin:a}=e,o=mh(a()),l=new AbortController;return Promise.all(n.map(c=>F(c.src)&&c.type==="?"?fetch(c.src,{method:"HEAD",credentials:o,signal:l.signal}).then(u=>(c.type=u.headers.get("content-type")||"??",GP.set(c.src,c.type),c)).catch(()=>c):c)).then(c=>{l.signal.aborted||(this._findNewSource(C(e.source),c),Zn())}),()=>l.abort()}Zn()}_findNewSource(e,n){let i={src:"",type:""},r=null,s=this._loaders();for(let a of n){let o=s.find(l=>l.canPlay(a));if(o){i=a,r=o;break}}return lP(e,i)||this._notifySourceChange(i,r),r!==C(this._loader)&&this._notifyLoaderChange(r),i}_notifySourceChange(e,n){this._notify("source-change",e),this._notify("media-type-change",n?.mediaType(e)||"unknown")}_notifyLoaderChange(e){this._media.$providerSetup.set(!1),this._notify("provider-change",null),e&&C(()=>e.preconnect?.(this._media)),this._loader.set(e),this._notify("provider-loader-change",e)}_onSetup(){let e=this._media.$provider();if(!(!e||C(this._media.$providerSetup))){if(this._media.$state.canLoad()){et(()=>e.setup(),e.scope),this._media.$providerSetup.set(!0);return}C(()=>e.preconnect?.())}}_onLoadSource(){if(!this._media.$providerSetup())return;let e=this._media.$provider(),n=this._media.$state.source(),i=C(this._media.$state.crossOrigin);if(!lP(e?.currentSrc,n)){if(this._media.$state.canLoad()){let r=new AbortController;return _s(n)?eh()||KP(n.src,{credentials:mh(i),signal:r.signal}).then(s=>{this._notify("stream-type-change",s)}).catch(Ht):this._notify("stream-type-change","on-demand"),C(()=>{let s=C(this._media.$state.preload);return e?.loadSource(n,s).catch(a=>{})}),()=>r.abort()}try{F(n.src)&&Jn(new URL(n.src).origin)}catch{}}}_onLoadPoster(){let e=this._loader(),{source:n,canLoadPoster:i}=this._media.$state;if(!e||!e.loadPoster||!n()||!i())return;let r=new AbortController,s=new j("source-change",{detail:n});return e.loadPoster(n(),this._media,r).then(a=>{this._notify("poster-change",a||"",s)}).catch(()=>{this._notify("poster-change","",s)}),()=>{r.abort()}}};fw=class{constructor(e,n){this._domTracks=e,this._media=n,this._prevTracks=[],b(this._onTracksChange.bind(this))}_onTracksChange(){let e=this._domTracks();for(let n of this._prevTracks)if(!e.some(i=>i.id===n.id)){let i=n.id&&this._media.textTracks.getById(n.id);i&&this._media.textTracks.remove(i)}for(let n of e){let i=n.id||ln.createId(n);this._media.textTracks.getById(i)||(n.id=i,this._media.textTracks.add(n))}this._prevTracks=e}},LO=Object.defineProperty,IO=Object.getOwnPropertyDescriptor,AO=(t,e,n,i)=>{for(var r=i>1?void 0:i?IO(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&LO(e,n,r),r},Ka=class extends H{constructor(){super(...arguments),this._domSources=D([]),this._domTracks=D([]),this._loader=null,this._loadRafId=-1}onSetup(){this._media=le(),this._sources=new hw(this._domSources,this._media,this.$state.loader,this.$props.loaders())}onAttach(e){e.setAttribute("data-media-provider","")}onConnect(e){this._sources.connect(),new fw(this._domTracks,this._media);let n=new ResizeObserver(Mr(this._onResize.bind(this)));n.observe(e);let i=new MutationObserver(this._onMutation.bind(this));i.observe(e,{attributes:!0,childList:!0}),this._onResize(),this._onMutation(),G(()=>{n.disconnect(),i.disconnect()})}load(e){window.cancelAnimationFrame(this._loadRafId),this._loadRafId=requestAnimationFrame(()=>this._runLoader(e)),G(()=>{window.cancelAnimationFrame(this._loadRafId)})}_runLoader(e){if(!this.scope)return;let n=this.$state.loader(),{$provider:i}=this._media;this._loader===n&&n?.target===e&&C(i)||(this._destroyProvider(),this._loader=n,n&&(n.target=e||null),!(!n||!e)&&n.load(this._media).then(r=>{this.scope&&C(this.$state.loader)===n&&this._media.delegate._notify("provider-change",r)}))}onDestroy(){this._loader=null,this._destroyProvider()}_destroyProvider(){this._media.delegate._notify("provider-change",null)}_onResize(){if(!this.el)return;let e=this._media.player,n=this.el.offsetWidth,i=this.el.offsetHeight;e&&(e.$state.mediaWidth.set(n),e.$state.mediaHeight.set(i),e.el&&(lt(e.el,"--media-width",n+"px"),lt(e.el,"--media-height",i+"px")))}_onMutation(){let e=[],n=[],i=this.el.children;for(let r of i)r instanceof HTMLSourceElement?e.push({src:r.src,type:r.type}):r instanceof HTMLTrackElement&&n.push({id:r.id,src:r.src,kind:r.track.kind,language:r.srclang,label:r.label,default:r.default,type:r.getAttribute("data-type")});this._domSources.set(e),this._domTracks.set(n),Zn()}};Ka.props={loaders:[]};Ka.state=new Xn({loader:null});AO([Ne],Ka.prototype,"load",1);Ih=class extends H{onSetup(){this._media=le(),b(this._watchProps.bind(this))}onAttach(e){let{pictureInPicture:n,fullscreen:i}=this._media.$state;lt(e,"pointer-events","none"),ve(e,"role","group"),this.setAttributes({"data-visible":this._isShowing.bind(this),"data-fullscreen":i,"data-pip":n}),b(()=>{this.dispatch("change",{detail:this._isShowing()})}),b(this._hideControls.bind(this)),b(()=>{let r=i();for(let s of["top","right","bottom","left"])lt(e,`padding-${s}`,r&&`env(safe-area-inset-${s})`)})}_hideControls(){if(!this.el)return;let{$iosControls:e}=this._media,{controls:n}=this._media.$state,i=n()||e();Z(this.el,"aria-hidden",i?"true":null),lt(this.el,"display",i?"none":null)}_watchProps(){let{controls:e}=this._media.player,{hideDelay:n,hideOnMouseLeave:i}=this.$props;e.defaultDelay=n()===2e3?this._media.$props.controlsDelay():n(),e.hideOnMouseLeave=i()}_isShowing(){let{controlsVisible:e}=this._media.$state;return e()}};Ih.props={hideDelay:2e3,hideOnMouseLeave:!1};Ah=class extends H{onAttach(e){lt(e,"pointer-events","auto")}},Nh=class extends Mt{constructor(e){super(),this._delegate=e,this._showTimerId=-1,this._hideRafId=-1,this._stopAnimationEndListener=null,b(this._watchTrigger.bind(this))}onDestroy(){this._stopAnimationEndListener?.(),this._stopAnimationEndListener=null}_watchTrigger(){let e=this._delegate._trigger();if(!e){this.hide();return}let n=this.show.bind(this),i=this.hide.bind(this);this._delegate._listen(e,n,i)}show(e){this._cancelShowing(),window.cancelAnimationFrame(this._hideRafId),this._hideRafId=-1,this._stopAnimationEndListener?.(),this._stopAnimationEndListener=null,this._showTimerId=window.setTimeout(()=>{this._showTimerId=-1;let n=this._delegate._content();n&&n.style.removeProperty("display"),C(()=>this._delegate._onChange(!0,e))},this._delegate._showDelay?.()??0)}hide(e){this._cancelShowing(),C(()=>this._delegate._onChange(!1,e)),this._hideRafId=requestAnimationFrame(()=>{this._cancelShowing(),this._hideRafId=-1;let n=this._delegate._content();if(n){let i=()=>{n.style.display="none",this._stopAnimationEndListener=null};if(mO(n)){this._stopAnimationEndListener?.();let s=S(n,"animationend",i,{once:!0});this._stopAnimationEndListener=s}else i()}})}_cancelShowing(){window.clearTimeout(this._showTimerId),this._showTimerId=-1}},Ha=mi(),NO=0,Dh=class extends H{constructor(){super(),this._id=`media-tooltip-${++NO}`,this._trigger=D(null),this._content=D(null),new pn;let{showDelay:e}=this.$props;new Nh({_trigger:this._trigger,_content:this._content,_showDelay:e,_listen(n,i,r){S(n,"touchstart",s=>s.preventDefault(),{passive:!1}),b(()=>{Lh()&&S(n,"focus",i),S(n,"blur",r)}),S(n,"mouseenter",i),S(n,"mouseleave",r)},_onChange:this._onShowingChange.bind(this)})}onAttach(e){e.style.setProperty("display","contents")}onSetup(){Rt(Ha,{_trigger:this._trigger,_content:this._content,_attachTrigger:this._attachTrigger.bind(this),_detachTrigger:this._detachTrigger.bind(this),_attachContent:this._attachContent.bind(this),_detachContent:this._detachContent.bind(this)})}_attachTrigger(e){this._trigger.set(e);let n=e.getAttribute("data-media-tooltip");n&&this.el?.setAttribute(`data-media-${n}-tooltip`,""),Z(e,"data-describedby",this._id)}_detachTrigger(e){e.removeAttribute("data-describedby"),e.removeAttribute("aria-describedby"),this._trigger.set(null)}_attachContent(e){e.setAttribute("id",this._id),e.style.display="none",ve(e,"role","tooltip"),this._content.set(e)}_detachContent(e){e.removeAttribute("id"),e.removeAttribute("role"),this._content.set(null)}_onShowingChange(e){let n=this._trigger(),i=this._content();n&&Z(n,"aria-describedby",e?this._id:null);for(let r of[this.el,n,i])r&&Z(r,"data-visible",e)}};Dh.props={showDelay:700};Oh=class extends H{constructor(){super(),new pn}onConnect(e){G(yh(()=>{if(!this.connectScope)return;this._attach();let n=Ae(Ha);G(()=>{let i=this._getButton();i&&n._detachTrigger(i)})}))}_attach(){let e=this._getButton(),n=Ae(Ha);e&&n._attachTrigger(e)}_getButton(){let e=this.el.firstElementChild;return e?.localName==="button"||e?.getAttribute("role")==="button"?e:this.el}},mc=class extends H{constructor(){super(),new pn;let{placement:e}=this.$props;this.setAttributes({"data-placement":e})}onAttach(e){this._attach(e),Object.assign(e.style,{position:"absolute",top:0,left:0,width:"max-content"})}onConnect(e){this._attach(e);let n=Ae(Ha);G(()=>n._detachContent(e)),G(yh(()=>{this.connectScope&&b(this._watchPlacement.bind(this))}))}_attach(e){Ae(Ha)._attachContent(e)}_watchPlacement(){let{placement:e,offset:n,alignOffset:i}=this.$props;return IP(this.el,this._getTrigger(),e(),{offsetVarName:"media-tooltip",xOffset:i(),yOffset:n()})}_getTrigger(){return Ae(Ha)._trigger()}};mc.props={placement:"top center",offset:0,alignOffset:0};tt=class extends Mt{constructor(e){super(),this._delegate=e,new pn,e._keyShortcut&&new Sh(e._keyShortcut)}onSetup(){let{disabled:e}=this.$props;this.setAttributes({"data-pressed":this._delegate._isPressed,"aria-pressed":this._isARIAPressed.bind(this),"aria-disabled":()=>e()?"true":null})}onAttach(e){ve(e,"tabindex","0"),ve(e,"role","button"),ve(e,"type","button")}onConnect(e){Nr(e,this._onMaybePress.bind(this));for(let n of["click","touchstart"])this.listen(n,this._onInteraction.bind(this))}_isARIAPressed(){return Na(this._delegate._isPressed())}_onPressed(e){Wy(this._delegate._isPressed)&&this._delegate._isPressed.set(n=>!n)}_onMaybePress(e){if(this.$props.disabled()||this.el.hasAttribute("data-disabled")){e.preventDefault(),e.stopImmediatePropagation();return}e.preventDefault(),(this._delegate._onPress??this._onPressed).call(this,e)}_onInteraction(e){this.$props.disabled()&&(e.preventDefault(),e.stopImmediatePropagation())}};tt.props={disabled:!1};DO=Object.defineProperty,OO=Object.getOwnPropertyDescriptor,VO=(t,e,n,i)=>{for(var r=i>1?void 0:i?OO(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&DO(e,n,r),r},gc=class extends H{constructor(){super(),this._pressed=D(!1),new tt({_isPressed:this._pressed})}get pressed(){return this._pressed()}};gc.props={disabled:!1,defaultPressed:!1};VO([ee],gc.prototype,"pressed",1);Vh=class extends H{constructor(){super(),new tt({_isPressed:this._isPressed.bind(this),_onPress:this._onPress.bind(this)})}onSetup(){this._media=le();let{canAirPlay:e,isAirPlayConnected:n}=this._media.$state;this.setAttributes({"data-active":n,"data-supported":e,"data-state":this._getState.bind(this),"aria-hidden":Gt(()=>!e())})}onAttach(e){e.setAttribute("data-media-tooltip","airplay"),Or(e,this._getDefaultLabel.bind(this))}_onPress(e){this._media.remote.requestAirPlay(e)}_isPressed(){let{remotePlaybackType:e,remotePlaybackState:n}=this._media.$state;return e()==="airplay"&&n()!=="disconnected"}_getState(){let{remotePlaybackType:e,remotePlaybackState:n}=this._media.$state;return e()==="airplay"&&n()}_getDefaultLabel(){let{remotePlaybackState:e}=this._media.$state;return`AirPlay ${e()}`}};Vh.props=tt.props;Fh=class extends H{constructor(){super(),new tt({_isPressed:this._isPressed.bind(this),_onPress:this._onPress.bind(this)})}onSetup(){this._media=le();let{canGoogleCast:e,isGoogleCastConnected:n}=this._media.$state;this.setAttributes({"data-active":n,"data-supported":e,"data-state":this._getState.bind(this),"aria-hidden":Gt(()=>!e())})}onAttach(e){e.setAttribute("data-media-tooltip","google-cast"),Or(e,this._getDefaultLabel.bind(this))}_onPress(e){this._media.remote.requestGoogleCast(e)}_isPressed(){let{remotePlaybackType:e,remotePlaybackState:n}=this._media.$state;return e()==="google-cast"&&n()!=="disconnected"}_getState(){let{remotePlaybackType:e,remotePlaybackState:n}=this._media.$state;return e()==="google-cast"&&n()}_getDefaultLabel(){let{remotePlaybackState:e}=this._media.$state;return`Google Cast ${e()}`}};Fh.props=tt.props;zh=class extends H{constructor(){super(),new tt({_isPressed:this._isPressed.bind(this),_keyShortcut:"togglePaused",_onPress:this._onPress.bind(this)})}onSetup(){this._media=le();let{paused:e,ended:n}=this._media.$state;this.setAttributes({"data-paused":e,"data-ended":n})}onAttach(e){e.setAttribute("data-media-tooltip","play"),Or(e,this._getDefaultLabel.bind(this))}_onPress(e){let n=this._media.remote;this._isPressed()?n.pause(e):n.play(e)}_isPressed(){let{paused:e}=this._media.$state;return!e()}_getDefaultLabel(){let{paused:e}=this._media.$state;return e()?"Play":"Pause"}};zh.props=tt.props;Uh=class extends H{constructor(){super(),new tt({_isPressed:this._isPressed.bind(this),_keyShortcut:"toggleCaptions",_onPress:this._onPress.bind(this)})}onSetup(){this._media=le(),this.setAttributes({"data-active":this._isPressed.bind(this),"data-supported":()=>!this._isHidden(),"aria-hidden":Gt(this._isHidden.bind(this))})}onAttach(e){e.setAttribute("data-media-tooltip","caption"),Or(e,this._getDefaultLabel.bind(this))}_onPress(e){this._media.remote.toggleCaptions(e)}_isPressed(){let{textTrack:e}=this._media.$state,n=e();return!!n&&We(n)}_isHidden(){let{hasCaptions:e}=this._media.$state;return!e()}_getDefaultLabel(){let{textTrack:e}=this._media.$state;return e()?"Closed-Captions Off":"Closed-Captions On"}};Uh.props=tt.props;jh=class extends H{constructor(){super(),new tt({_isPressed:this._isPressed.bind(this),_keyShortcut:"toggleFullscreen",_onPress:this._onPress.bind(this)})}onSetup(){this._media=le();let{fullscreen:e}=this._media.$state,n=this._isSupported.bind(this);this.setAttributes({"data-active":e,"data-supported":n,"aria-hidden":Gt(()=>!n())})}onAttach(e){e.setAttribute("data-media-tooltip","fullscreen"),Or(e,this._getDefaultLabel.bind(this))}_onPress(e){let n=this._media.remote,i=this.$props.target();this._isPressed()?n.exitFullscreen(i,e):n.enterFullscreen(i,e)}_isPressed(){let{fullscreen:e}=this._media.$state;return e()}_isSupported(){let{canFullscreen:e}=this._media.$state;return e()}_getDefaultLabel(){let{fullscreen:e}=this._media.$state;return e()?"Exit Fullscreen":"Enter Fullscreen"}};jh.props={...tt.props,target:"prefer-media"};qh=class extends H{constructor(){super(),new tt({_isPressed:this._isPressed.bind(this),_keyShortcut:"toggleMuted",_onPress:this._onPress.bind(this)})}onSetup(){this._media=le(),this.setAttributes({"data-muted":this._isPressed.bind(this),"data-state":this._getState.bind(this)})}onAttach(e){e.setAttribute("data-media-mute-button",""),e.setAttribute("data-media-tooltip","mute"),Or(e,this._getDefaultLabel.bind(this))}_onPress(e){let n=this._media.remote;this._isPressed()?n.unmute(e):n.mute(e)}_isPressed(){let{muted:e,volume:n}=this._media.$state;return e()||n()===0}_getDefaultLabel(){return this._isPressed()?"Unmute":"Mute"}_getState(){let{muted:e,volume:n}=this._media.$state,i=n();if(e()||i===0)return"muted";if(i>=.5)return"high";if(i<.5)return"low"}};qh.props=tt.props;Hh=class extends H{constructor(){super(),new tt({_isPressed:this._isPressed.bind(this),_keyShortcut:"togglePictureInPicture",_onPress:this._onPress.bind(this)})}onSetup(){this._media=le();let{pictureInPicture:e}=this._media.$state,n=this._isSupported.bind(this);this.setAttributes({"data-active":e,"data-supported":n,"aria-hidden":Gt(()=>!n())})}onAttach(e){e.setAttribute("data-media-tooltip","pip"),Or(e,this._getDefaultLabel.bind(this))}_onPress(e){let n=this._media.remote;this._isPressed()?n.exitPictureInPicture(e):n.enterPictureInPicture(e)}_isPressed(){let{pictureInPicture:e}=this._media.$state;return e()}_isSupported(){let{canPictureInPicture:e}=this._media.$state;return e()}_getDefaultLabel(){let{pictureInPicture:e}=this._media.$state;return e()?"Exit Picture In Picture":"Enter Picture In Picture"}};Hh.props=tt.props;Bh=class extends H{constructor(){super(),new pn}onSetup(){this._media=le();let{seeking:e}=this._media.$state,{seconds:n}=this.$props,i=this._isSupported.bind(this);this.setAttributes({seconds:n,"data-seeking":e,"data-supported":i,"aria-hidden":Gt(()=>!i())})}onAttach(e){ve(e,"tabindex","0"),ve(e,"role","button"),ve(e,"type","button"),e.setAttribute("data-media-tooltip","seek"),Or(e,this._getDefaultLabel.bind(this))}onConnect(e){Nr(e,this._onPress.bind(this))}_isSupported(){let{canSeek:e}=this._media.$state;return e()}_getDefaultLabel(){let{seconds:e}=this.$props;return`Seek ${e()>0?"forward":"backward"} ${e()} seconds`}_onPress(e){let{seconds:n,disabled:i}=this.$props;if(i())return;let{currentTime:r}=this._media.$state,s=r()+n();this._media.remote.seek(s,e)}};Bh.props={disabled:!1,seconds:30};Wh=class extends H{constructor(){super(),new pn}onSetup(){this._media=le();let{disabled:e}=this.$props,{live:n,liveEdge:i}=this._media.$state,r=()=>!n();this.setAttributes({"data-edge":i,"data-hidden":r,"aria-disabled":Gt(()=>e()||i()),"aria-hidden":Gt(r)})}onAttach(e){ve(e,"tabindex","0"),ve(e,"role","button"),ve(e,"type","button"),e.setAttribute("data-media-tooltip","live")}onConnect(e){Nr(e,this._onPress.bind(this))}_onPress(e){let{disabled:n}=this.$props,{liveEdge:i}=this._media.$state;n()||i()||this._media.remote.seekToLiveEdge(e)}};Wh.props={disabled:!1};sf=new Xn({min:0,max:100,value:0,pointerValue:0,focused:!1,dragging:!1,pointing:!1,get active(){return this.dragging||this.focused||this.pointing},get fillRate(){return cP(this.min,this.max,this.value)},get fillPercent(){return this.fillRate*100},get pointerRate(){return cP(this.min,this.max,this.pointerValue)},get pointerPercent(){return this.pointerRate*100}});uP={Left:-1,ArrowLeft:-1,Up:1,ArrowUp:1,Right:1,ArrowRight:1,Down:-1,ArrowDown:-1},mw=class extends Mt{constructor(e,n){super(),this._delegate=e,this._media=n,this._provider=null,this._touch=null,this._touchStartValue=null,this._onDocumentPointerMove=iu(i=>{this._updatePointerValue(this._getPointerValue(i),i)},20,{leading:!0})}onConnect(){if(b(this._attachEventListeners.bind(this)),b(this._attachPointerListeners.bind(this)),this._delegate._swipeGesture){let e=this._media.player.el?.querySelector("media-provider,[data-media-provider]");e&&(this._provider=e,S(e,"touchstart",this._onTouchStart.bind(this),{passive:!0}),S(e,"touchmove",this._onTouchMove.bind(this),{passive:!1}))}}_onTouchStart(e){this._touch=e.touches[0]}_onTouchMove(e){if(fi(this._touch)||Sw(e))return;let n=e.touches[0],i=n.clientX-this._touch.clientX,r=n.clientY-this._touch.clientY,s=this.$state.dragging();!s&&Math.abs(r)>20||s||Math.abs(i)>20&&(this._touch=n,this._touchStartValue=this.$state.value(),this._onStartDragging(this._touchStartValue,e))}_attachEventListeners(){this._delegate._isDisabled()||(this.listen("focus",this._onFocus.bind(this)),this.listen("pointerenter",this._onPointerEnter.bind(this)),this.listen("pointermove",this._onPointerMove.bind(this)),this.listen("pointerleave",this._onPointerLeave.bind(this)),this.listen("pointerdown",this._onPointerDown.bind(this)),this.listen("keydown",this._onKeyDown.bind(this)),this.listen("keyup",this._onKeyUp.bind(this)))}_attachPointerListeners(){this._delegate._isDisabled()||!this.$state.dragging()||(S(document,"pointerup",this._onDocumentPointerUp.bind(this)),S(document,"pointermove",this._onDocumentPointerMove.bind(this)),b_&&S(document,"touchmove",this._onDocumentTouchMove.bind(this),{passive:!1}))}_onFocus(){this._updatePointerValue(this.$state.value())}_updateValue(e,n){let{value:i,min:r,max:s,dragging:a}=this.$state,o=Math.max(r(),Math.min(e,s()));i.set(o);let l=this.createEvent("value-change",{detail:o,trigger:n});if(this.dispatch(l),this._delegate._onValueChange?.(l),a()){let c=this.createEvent("drag-value-change",{detail:o,trigger:n});this.dispatch(c),this._delegate._onDragValueChange?.(c)}}_updatePointerValue(e,n){let{pointerValue:i,dragging:r}=this.$state;i.set(e),this.dispatch("pointer-value-change",{detail:e,trigger:n}),r()&&this._updateValue(e,n)}_getPointerValue(e){let n,i=this.el.getBoundingClientRect(),{min:r,max:s}=this.$state;if(this.$props.orientation()==="vertical"){let{bottom:a,height:o}=i;n=(a-e.clientY)/o}else if(this._touch&&Be(this._touchStartValue)){let{width:a}=this._provider.getBoundingClientRect(),o=(e.clientX-this._touch.clientX)/a,l=s()-r(),c=l*Math.abs(o);n=(o<0?this._touchStartValue-c:this._touchStartValue+c)/l}else{let{left:a,width:o}=i;n=(e.clientX-a)/o}return Math.max(r(),Math.min(s(),this._delegate._roundValue(UO(r(),s(),n,this._delegate._getStep()))))}_onPointerEnter(e){this.$state.pointing.set(!0)}_onPointerMove(e){let{dragging:n}=this.$state;n()||this._updatePointerValue(this._getPointerValue(e),e)}_onPointerLeave(e){this.$state.pointing.set(!1)}_onPointerDown(e){if(e.button!==0)return;let n=this._getPointerValue(e);this._onStartDragging(n,e),this._updatePointerValue(n,e)}_onStartDragging(e,n){let{dragging:i}=this.$state;if(i())return;i.set(!0),this._media.remote.pauseControls(n);let r=this.createEvent("drag-start",{detail:e,trigger:n});this.dispatch(r),this._delegate._onDragStart?.(r)}_onStopDragging(e,n){let{dragging:i}=this.$state;if(!i())return;i.set(!1),this._media.remote.resumeControls(n);let r=this.createEvent("drag-end",{detail:e,trigger:n});this.dispatch(r),this._delegate._onDragEnd?.(r),this._touch=null,this._touchStartValue=null}_onKeyDown(e){let{key:n}=e,{min:i,max:r}=this.$state,s;if(n==="Home"||n==="PageUp"?s=i():n==="End"||n==="PageDown"?s=r():!e.metaKey&&/[0-9]/.test(n)&&(s=(r()-i())/10*Number(n)),!Ie(s)){this._updatePointerValue(s,e),this._updateValue(s,e);return}let a=this._getKeyValue(e);if(Ie(a))return;let o=n===this._lastDownKey;!this.$state.dragging()&&o&&this._onStartDragging(a,e),this._updatePointerValue(a,e),o||this._updateValue(a,e),this._lastDownKey=n}_onKeyUp(e){this._lastDownKey="";let{dragging:n,value:i}=this.$state;if(!n())return;let r=this._getKeyValue(e)??i();this._updatePointerValue(r),this._onStopDragging(r,e)}_getKeyValue(e){let{key:n,shiftKey:i}=e;if(!Object.keys(uP).includes(n))return;e.preventDefault(),e.stopPropagation();let{shiftKeyMultiplier:s}=this.$props,{value:a,min:o,max:l}=this.$state,c=this._delegate._getStep(),u=this._delegate._getKeyStep(),d=i?u*s():u,p=Number(uP[n]),h=d*p,y=(a()+h)/c;return Math.max(o(),Math.min(l(),Number((c*y).toFixed(3))))}_onDocumentPointerUp(e){if(e.button!==0)return;let n=this._getPointerValue(e);this._updatePointerValue(n,e),this._onStopDragging(n,e)}_onDocumentTouchMove(e){e.preventDefault()}},vc=mi(()=>({})),af=mi(),_i=class extends Mt{constructor(e){super(),this._delegate=e,this._updateSliderVars=Mr((n,i)=>{this.el?.style.setProperty("--slider-fill",n+"%"),this.el?.style.setProperty("--slider-pointer",i+"%")})}onSetup(){this._media=le();let e=new pn;e.attach(this),this.$state.focused=e.focused.bind(e),Tn(vc)||Rt(vc,{default:"value"}),Rt(af,{_orientation:this.$props.orientation,_disabled:this._delegate._isDisabled,_preview:D(null)}),b(this._watchValue.bind(this)),b(this._watchDisabled.bind(this)),this._setupAttrs(),new mw(this._delegate,this._media).attach(this)}onAttach(e){ve(e,"role","slider"),ve(e,"tabindex","0"),ve(e,"autocomplete","off"),N?this._watchCSSVars():b(this._watchCSSVars.bind(this))}_watchValue(){let{dragging:e,value:n,min:i,max:r}=this.$state;C(e)||n.set(zO(i(),r(),n(),this._delegate._getStep()))}_watchDisabled(){if(!this._delegate._isDisabled())return;let{dragging:e,pointing:n}=this.$state;e.set(!1),n.set(!1)}_getARIADisabled(){return Na(this._delegate._isDisabled())}_setupAttrs(){let{orientation:e}=this.$props,{dragging:n,active:i,pointing:r}=this.$state;this.setAttributes({"data-dragging":n,"data-pointing":r,"data-active":i,"aria-disabled":this._getARIADisabled.bind(this),"aria-valuemin":this.$state.min,"aria-valuemax":this.$state.max,"aria-valuenow":this._delegate._getARIAValueNow,"aria-valuetext":this._delegate._getARIAValueText,"aria-orientation":e})}_watchCSSVars(){let{fillPercent:e,pointerPercent:n}=this.$state;this._updateSliderVars(At(e(),3),At(n(),3))}};_i.props={disabled:!1,step:1,keyStep:1,orientation:"horizontal",shiftKeyMultiplier:5};Qi=class extends H{constructor(){super(),new _i({_getStep:this.$props.step,_getKeyStep:this.$props.keyStep,_roundValue:Math.round,_isDisabled:this.$props.disabled,_getARIAValueNow:this._getARIAValueNow.bind(this),_getARIAValueText:this._getARIAValueText.bind(this)})}onSetup(){b(this._watchValue.bind(this)),b(this._watchMinMax.bind(this))}_getARIAValueNow(){let{value:e}=this.$state;return Math.round(e())}_getARIAValueText(){let{value:e,max:n}=this.$state;return At(e()/n()*100,2)+"%"}_watchValue(){let{value:e}=this.$props;this.$state.value.set(e())}_watchMinMax(){let{min:e,max:n}=this.$props;this.$state.min.set(e()),this.$state.max.set(n())}};Qi.props={..._i.props,min:0,max:100,value:0};Qi.state=sf;Ki=new Map,dh=new Map,Kh=class t{constructor(e,n,i){this.$src=e,this.$crossOrigin=n,this._media=i,this.$images=D([]),b(this._onLoadCues.bind(this))}static create(e,n){let i=le();return new t(e,n,i)}_onLoadCues(){let{canLoad:e}=this._media.$state;if(!e())return;let n=this.$src(),i=new AbortController;if(n){if(F(n)&&Ki.has(n)){let r=Ki.get(n);if(Ki.delete(n),Ki.set(n,r),Ki.size>30){let s=Ki.keys().next().value;Ki.delete(s)}this.$images.set(Ki.get(n))}else if(F(n)){let r=this.$crossOrigin(),s=n+"::"+r;if(!dh.has(s)){let a=new Promise(async(o,l)=>{try{let c=await fetch(n,{signal:i.signal,credentials:mh(r)});if(c.headers.get("content-type")==="application/json"){let d=await c.json();if(He(d))if(d[0]&&"text"in d)o(this._processVTTCues(d));else{for(let p=0;p(rc(),ic)).then(async({parseResponse:d})=>{try{let{cues:p}=await d(c);o(this._processVTTCues(p))}catch(p){l(p)}})}catch(c){l(c)}}).then(o=>(i.signal.aborted||Ki.set(s,o),o)).catch(o=>{i.signal.aborted||this._onError(n,o)}).finally(()=>{F(s)&&dh.delete(s)});dh.set(s,a)}dh.get(s)?.then(a=>{i.signal.aborted||this.$images.set(a||[])})}else if(He(n))try{this.$images.set(this._processImages(n))}catch(r){this._onError(n,r)}else try{this.$images.set(this._processStoryboard(n))}catch(r){this._onError(n,r)}return()=>{i.abort(),this.$images.set([])}}}_processImages(e){let n=this._resolveBaseUrl();return e.map((i,r)=>(Wi(i.url&&F(i.url),!1),Wi("startTime"in i&&Be(i.startTime),!1),{...i,url:F(i.url)?this._resolveURL(i.url,n):i.url}))}_processStoryboard(e){Wi(F(e.url),!1),Wi(He(e.tiles)&&e.tiles?.length,!1);let n=new URL(e.url),i=[],r="tile_width"in e?e.tile_width:e.tileWidth,s="tile_height"in e?e.tile_height:e.tileHeight;for(let a of e.tiles)i.push({url:n,startTime:"start"in a?a.start:a.startTime,width:r,height:s,coords:{x:a.x,y:a.y}});return i}_processVTTCues(e){for(let r=0;r{this._resetStyles(),n.set(!1),i.set(null)}}_onLoaded(){let{loading:e,error:n}=this.$state;e.set(!1),n.set(null)}_onError(e){let{loading:n,error:i}=this.$state;n.set(!1),i.set(e)}_isLoading(){let{loading:e,hidden:n}=this.$state;return!n()&&e()}_hasError(){let{error:e}=this.$state;return!fi(e())}_watchHidden(){let{hidden:e}=this.$state,{duration:n}=this._media.$state,i=this._loader.$images();e.set(this._hasError()||!Number.isFinite(n())||i.length===0)}_getTime(){return this.$props.time()}_onFindActiveThumbnail(){let e=this._getTime(),{src:n,activeThumbnail:i}=this.$state,r=this._loader.$images(),s=-1,a=null;for(let o=r.length-1;o>=0;o--){let l=r[o];if(e>=l.startTime&&(!l.endTime||e1?h:1;this._style(e,"--thumbnail-width",`${s*v}px`),this._style(e,"--thumbnail-height",`${a*v}px`),this._style(n,"width",`${n.naturalWidth*v}px`),this._style(n,"height",`${n.naturalHeight*v}px`),this._style(n,"transform",r.coords?`translate(-${r.coords.x*v}px, -${r.coords.y*v}px)`:""),this._style(n,"max-width","none")}_style(e,n,i){e.style.setProperty(n,i),this._styleResets.push(()=>e.style.removeProperty(n))}_resetStyles(){for(let e of this._styleResets)e();this._styleResets=[]}};Ga.props={src:null,time:0,crossOrigin:null};Ga.state=new Xn({src:"",img:null,thumbnails:[],activeThumbnail:null,crossOrigin:null,loading:!1,error:null,hidden:!1});Gh=class extends Ga{onAttach(e){this._slider=gs(Qi.state)}_getTime(){let{duration:e,clipStartTime:n}=this._media.$state;return n()+this._slider.pointerRate()*e()}},jO=Object.defineProperty,qO=Object.getOwnPropertyDescriptor,HO=(t,e,n,i)=>{for(var r=i>1?void 0:i?qO(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&jO(e,n,r),r},Es=class extends H{get video(){return this.$state.video()}onSetup(){this._media=le(),this._slider=gs(Qi.state),this._watchCrossOrigin(),this.setAttributes({"data-loading":this._isLoading.bind(this),"data-hidden":this.$state.hidden,"data-error":this._hasError.bind(this),"aria-hidden":Gt(this.$state.hidden)})}onAttach(e){b(this._watchVideo.bind(this)),b(this._watchSrc.bind(this)),b(this._watchCrossOrigin.bind(this)),b(this._watchHidden.bind(this)),b(this._onSrcChange.bind(this)),b(this._onUpdateTime.bind(this))}_watchVideo(){let e=this.$state.video();e&&(e.readyState>=2&&this._onCanPlay(),S(e,"canplay",this._onCanPlay.bind(this)),S(e,"error",this._onError.bind(this)))}_watchSrc(){let{src:e}=this.$state,{canLoad:n}=this._media.$state;e.set(n()?this.$props.src():null)}_watchCrossOrigin(){let{crossOrigin:e}=this.$props,{crossOrigin:n}=this.$state,{crossOrigin:i}=this._media.$state,r=e()!==null?e():i();n.set(r===!0?"anonymous":r)}_isLoading(){let{canPlay:e,hidden:n}=this.$state;return!e()&&!n()}_hasError(){let{error:e}=this.$state;return!fi(e)}_watchHidden(){let{src:e,hidden:n}=this.$state,{canLoad:i,duration:r}=this._media.$state;n.set(i()&&(!e()||this._hasError()||!Number.isFinite(r())))}_onSrcChange(){let{src:e,canPlay:n,error:i}=this.$state;e(),n.set(!1),i.set(null)}_onCanPlay(e){let{canPlay:n,error:i}=this.$state;n.set(!0),i.set(null),this.dispatch("can-play",{trigger:e})}_onError(e){let{canPlay:n,error:i}=this.$state;n.set(!1),i.set(e),this.dispatch("error",{trigger:e})}_onUpdateTime(){let{video:e,canPlay:n}=this.$state,{duration:i}=this._media.$state,{pointerRate:r}=this._slider,s=e();n()&&s&&Number.isFinite(i())&&Number.isFinite(r())&&(s.currentTime=r()*i())}};Es.props={src:null,crossOrigin:null};Es.state=new Xn({video:null,src:null,crossOrigin:null,canPlay:!1,error:null,hidden:!1});HO([ee],Es.prototype,"video",1);BO=Object.defineProperty,WO=Object.getOwnPropertyDescriptor,KO=(t,e,n,i)=>{for(var r=i>1?void 0:i?WO(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&BO(e,n,r),r},Ya=class extends H{onSetup(){this._slider=gs(Qi.state),this._format=Ae(vc),this._text=hi(this.getValueText.bind(this))}getValueText(){let{type:e,format:n,decimalPlaces:i,padHours:r,padMinutes:s,showHours:a}=this.$props,{value:o,pointerValue:l,min:c,max:u}=this._slider,d=n()??this._format.default,p=e()==="current"?o():l();if(d==="percent"){let h=u()-c(),y=p/h*100;return(this._format.percent??At)(y,i())+"\uFE6A"}else return d==="time"?(this._format.time??Vr)(p,r(),s(),a()):this._format.value?.(p)??p.toFixed(2)}};Ya.props={type:"pointer",format:null,showHours:!1,padHours:null,padMinutes:null,decimalPlaces:2};KO([Ne],Ya.prototype,"getValueText",1);_c=class extends H{constructor(){super(...arguments),this._updatePlacement=Mr(()=>{let{_disabled:e,_orientation:n}=this._slider;if(e())return;let i=this.el,{offset:r,noClamp:s}=this.$props;Rw(i,{clamp:!s(),offset:r(),orientation:n()})})}onSetup(){this._slider=Ae(af);let{active:e}=gs(Qi.state);this.setAttributes({"data-visible":e})}onAttach(e){Object.assign(e.style,{position:"absolute",top:0,left:0,width:"max-content"})}onConnect(e){let{_preview:n}=this._slider;n.set(e),G(()=>n.set(null)),b(this._updatePlacement.bind(this));let i=new ResizeObserver(this._updatePlacement.bind(this));i.observe(e),G(()=>i.disconnect())}};_c.props={offset:0,noClamp:!1};wc=class extends H{constructor(){super(...arguments),this._throttleVolumeChange=iu(this._onVolumeChange.bind(this),25)}onSetup(){this._media=le(),Rt(vc,{default:"percent"}),new _i({_getStep:this.$props.step,_getKeyStep:this.$props.keyStep,_isDisabled:this.$props.disabled,_roundValue:Math.round,_getARIAValueNow:this._getARIAValueNow.bind(this),_getARIAValueText:this._getARIAValueText.bind(this),_onDragValueChange:this._onDragValueChange.bind(this),_onValueChange:this._onValueChange.bind(this)}).attach(this),b(this._watchVolume.bind(this))}onAttach(e){e.setAttribute("data-media-volume-slider",""),ve(e,"aria-label","Volume");let{canSetVolume:n}=this._media.$state;this.setAttributes({"data-supported":n,"aria-hidden":Gt(()=>!n())})}_getARIAValueNow(){let{value:e}=this.$state;return Math.round(e())}_getARIAValueText(){let{value:e,max:n}=this.$state;return At(e()/n()*100,2)+"%"}_watchVolume(){let{muted:e,volume:n}=this._media.$state,i=e()?0:n()*100;this.$state.value.set(i),this.dispatch("value-change",{detail:i})}_onVolumeChange(e){if(!e.trigger)return;let n=At(e.detail/100,3);this._media.remote.changeVolume(n,e)}_onValueChange(e){this._throttleVolumeChange(e)}_onDragValueChange(e){this._throttleVolumeChange(e)}};wc.props={..._i.props,keyStep:5,shiftKeyMultiplier:2};wc.state=sf;Qa=class extends H{constructor(){super(),this._chapter=D(null),this._playingBeforeDragStart=!1,new _i({_swipeGesture:!0,_getStep:this._getStep.bind(this),_getKeyStep:this._getKeyStep.bind(this),_isDisabled:this._isDisabled.bind(this),_roundValue:this._roundValue,_getARIAValueNow:this._getARIAValueNow.bind(this),_getARIAValueText:this._getARIAValueText.bind(this),_onDragStart:this._onDragStart.bind(this),_onDragValueChange:this._onDragValueChange.bind(this),_onDragEnd:this._onDragEnd.bind(this),_onValueChange:this._onValueChange.bind(this)})}onSetup(){this._media=le(),Rt(vc,{default:"time",value:this._formatValue.bind(this),time:this._formatTime.bind(this)}),this.setAttributes({"data-chapters":this._hasChapters.bind(this)}),this.setStyles({"--slider-progress":this._calcBufferedPercent.bind(this)}),b(this._watchCurrentTime.bind(this)),b(this._watchSeekingThrottle.bind(this))}onAttach(e){e.setAttribute("data-media-time-slider",""),ve(e,"aria-label","Seek")}onConnect(e){b(this._watchPreviewing.bind(this)),eo(this._media.textTracks,"chapters",this._chapter.set)}_calcBufferedPercent(){let{bufferedEnd:e,duration:n}=this._media.$state;return At(Math.min(e()/Math.max(n(),1),1)*100,3)+"%"}_hasChapters(){let{duration:e}=this._media.$state;return this._chapter()?.cues.length&&Number.isFinite(e())&&e()>0}_watchSeekingThrottle(){this._dispatchSeeking=iu(this._seeking.bind(this),this.$props.seekingRequestThrottle())}_watchCurrentTime(){let{currentTime:e}=this._media.$state,{value:n,dragging:i}=this.$state,r=this._timeToPercent(e());C(i)||(n.set(r),this.dispatch("value-change",{detail:r}))}_watchPreviewing(){let e=this._media.player.el,{_preview:n}=Ae(af);e&&n()&&Z(e,"data-preview",this.$state.active())}_seeking(e,n){this._media.remote.seeking(e,n)}_seek(e,n,i){this._dispatchSeeking.cancel();let{live:r}=this._media.$state;if(r()&&n>=99){this._media.remote.seekToLiveEdge(i);return}this._media.remote.seek(e,i)}_onDragStart(e){let{pauseWhileDragging:n}=this.$props;if(n()){let{paused:i}=this._media.$state;this._playingBeforeDragStart=!i(),this._media.remote.pause(e)}}_onDragValueChange(e){this._dispatchSeeking(this._percentToTime(e.detail),e)}_onDragEnd(e){let n=e.detail;this._seek(this._percentToTime(n),n,e);let{pauseWhileDragging:i}=this.$props;i()&&this._playingBeforeDragStart&&(this._media.remote.play(e),this._playingBeforeDragStart=!1)}_onValueChange(e){let{dragging:n}=this.$state;n()||!e.trigger||this._onDragEnd(e)}_getStep(){let e=this.$props.step()/this._media.$state.duration()*100;return Number.isFinite(e)?e:1}_getKeyStep(){let e=this.$props.keyStep()/this._media.$state.duration()*100;return Number.isFinite(e)?e:1}_roundValue(e){return At(e,3)}_isDisabled(){let{canSeek:e}=this._media.$state;return this.$props.disabled()||!e()}_getARIAValueNow(){let{value:e}=this.$state;return Math.round(e())}_getARIAValueText(){let e=this._percentToTime(this.$state.value()),{duration:n}=this._media.$state;return Number.isFinite(e)?`${yc(e)} out of ${yc(n())}`:"live"}_percentToTime(e){let{duration:n}=this._media.$state;return At(e/100*n(),5)}_timeToPercent(e){let{liveEdge:n,duration:i}=this._media.$state,r=Math.max(0,Math.min(1,n()?1:Math.min(e,i())/i()));return Number.isNaN(r)?0:Number.isFinite(r)?r*100:100}_formatValue(e){let n=this._percentToTime(e),{live:i,duration:r}=this._media.$state;return Number.isFinite(n)?(i()?n-r():n).toFixed(0):"LIVE"}_formatTime(e,n,i,r){let s=this._percentToTime(e),{live:a,duration:o}=this._media.$state,l=a()?s-o():s;return Number.isFinite(s)?`${l<0?"-":""}${Vr(Math.abs(l),n,i,r)}`:"LIVE"}};Qa.props={..._i.props,step:.1,keyStep:5,shiftKeyMultiplier:2,pauseWhileDragging:!1,seekingRequestThrottle:100};Qa.state=sf;GO=Object.defineProperty,YO=Object.getOwnPropertyDescriptor,of=(t,e,n,i)=>{for(var r=i>1?void 0:i?YO(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&GO(e,n,r),r},Xi=class extends H{constructor(){super(...arguments),this._titleRef=null,this._refs=[],this._$track=D(null),this._$cues=D([]),this._activeIndex=D(-1),this._activePointerIndex=D(-1),this._bufferedIndex=0,this._updateBufferedPercent=Mr(e=>{let n,i=this._$cues(),{clipStartTime:r}=this._media.$state,s=r(),a=this._getEndTime(i);for(let o=this._bufferedIndex;o{let e=C(this._$track);!this.scope||!e||!e.cues.length||(this._$cues.set(this._fillGaps(e.cues)),this._activeIndex.set(0),this._bufferedIndex=0)},150,!0)}get cues(){return this._$cues()}get activeCue(){return this._$cues()[this._activeIndex()]||null}get activePointerCue(){return this._$cues()[this._activePointerIndex()]||null}onSetup(){this._media=le(),this._sliderState=gs(Qa.state)}onAttach(e){eo(this._media.textTracks,"chapters",this._setTrack.bind(this)),b(this._onTrackChange.bind(this))}onConnect(){G(()=>this._reset.bind(this))}onDestroy(){this._setTrack(null)}setRefs(e){if(this._refs=e,this._updateScope?.dispose(),this._refs.length===1){let n=this._refs[0];n.style.width="100%",n.style.setProperty("--chapter-fill","var(--slider-fill)"),n.style.setProperty("--chapter-progress","var(--slider-progress)")}else this._refs.length>0&&et(()=>this._watch(),this._updateScope=$t())}_setTrack(e){C(this._$track)!==e&&(this._reset(),this._$track.set(e))}_reset(){this._refs=[],this._$cues.set([]),this._activeIndex.set(-1),this._activePointerIndex.set(-1),this._bufferedIndex=0,this._updateScope?.dispose()}_watch(){this._refs.length&&(b(this._watchContainerWidths.bind(this)),b(this._watchFillPercent.bind(this)),b(this._watchPointerPercent.bind(this)),b(this._watchBufferedPercent.bind(this)))}_watchContainerWidths(){let e=this._$cues();if(!e.length)return;let n,{clipStartTime:i,clipEndTime:r}=this._media.$state,s=i(),a=r()||e[e.length-1].endTime,o=a-s,l=100;for(let c=0;cc?this._updateFillPercents(c,d,"100%"):d=0&&i<100)return l;return 0}_watchBufferedPercent(){this._updateBufferedPercent(this._bufferedPercent())}_calcMediaBufferedPercent(){let{bufferedEnd:e,duration:n}=this._media.$state;return At(Math.min(e()/Math.max(n(),1),1),3)*100}_getEndTime(e){let{clipEndTime:n}=this._media.$state,i=n();return i>0?i:e[e.length-1]?.endTime||0}_calcPercent(e,n,i,r){if(this._$cues().length===0)return 0;let a=r-i,o=Math.max(0,e.startTime-i),l=Math.min(r,e.endTime)-i,c=o/a,u=c*100,d=Math.min(1,c+(l-o)/a)*100;return Math.max(0,At(n>=d?100:(n-u)/(d-u)*100,3))}_fillGaps(e){let n=[],{clipStartTime:i,clipEndTime:r,duration:s}=this._media.$state,a=i(),o=r()||1/0;e=e.filter(u=>u.startTime<=o&&u.endTime>=a);let l=e[0];l&&l.startTime>a&&n.push(new window.VTTCue(a,l.startTime,""));for(let u=0;u0&&n.push(new window.VTTCue(d.endTime,d.endTime+h,""))}}let c=e[e.length-1];return c&&(n.push(c),s()>=0&&(o===0||o!==1/0&&c.endTime1&&n.push(new window.VTTCue(c.endTime,s(),""))),n}_onTrackChange(){if(!this.scope)return;let{disabled:e}=this.$props;if(e()){this._$cues.set([]),this._activeIndex.set(0),this._bufferedIndex=0;return}let n=this._$track();if(n){let i=this._onCuesChange.bind(this);i(),G(S(n,"add-cue",i)),G(S(n,"remove-cue",i)),b(this._watchMediaDuration.bind(this))}return this._titleRef=this._findChapterTitleRef(),this._titleRef&&b(this._onChapterTitleChange.bind(this)),()=>{this._titleRef&&(this._titleRef.textContent="",this._titleRef=null)}}_watchMediaDuration(){this._media.$state.duration(),this._onCuesChange()}_onChapterTitleChange(){let e=this.activePointerCue||this.activeCue;this._titleRef&&(this._titleRef.textContent=e?.text||"")}_findParentSlider(){let e=this.el;for(;e&&e.getAttribute("role")!=="slider";)e=e.parentElement;return e}_findChapterTitleRef(){let e=this._findParentSlider();return e?e.querySelector('[data-part="chapter-title"]'):null}};Xi.props={disabled:!1};of([ee],Xi.prototype,"cues",1);of([ee],Xi.prototype,"activeCue",1);of([ee],Xi.prototype,"activePointerCue",1);of([Ne],Xi.prototype,"setRefs",1);ct=mi(),QO=["a[href]","[tabindex]","input","select","button"].map(t=>`${t}:not([aria-hidden='true'])`).join(","),dP=new Set(["Escape","Tab","ArrowUp","ArrowDown","Home","PageUp","End","PageDown","Enter"," "]),gw=class{constructor(e){this._delegate=e,this._index=0,this._el=null,this._elements=[]}get _items(){return this._elements}_attachMenu(e){return S(e,"focus",this._onFocus.bind(this)),this._el=e,G(()=>{this._el=null}),this}_listen(){this._el&&(this._update(),S(this._el,"keyup",this._onKeyUp.bind(this)),S(this._el,"keydown",this._onKeyDown.bind(this)),G(()=>{this._index=0,this._elements=[]}))}_update(){this._index=0,this._elements=this._getFocusableElements()}_scroll(e=this._findActiveIndex()){let n=this._elements[e],i=this._delegate._getScrollContainer();n&&i&&requestAnimationFrame(()=>{i.scrollTop=n.offsetTop-i.offsetHeight/2+n.offsetHeight/2})}_focusAt(e){this._index=e,this._elements[e]?.focus(),this._scroll(e)}_findActiveIndex(){return this._elements.findIndex(e=>e.getAttribute("aria-checked")==="true")}_onFocus(){this._update(),setTimeout(()=>{let e=this._findActiveIndex();this._focusAt(e>=0?e:0)},100)}_onKeyUp(e){dP.has(e.key)&&(e.stopPropagation(),e.preventDefault())}_onKeyDown(e){if(dP.has(e.key))switch(e.stopPropagation(),e.preventDefault(),e.key){case"Escape":this._delegate._closeMenu(e);break;case"Tab":this._focusAt(this._nextIndex(e.shiftKey?-1:1));break;case"ArrowUp":this._focusAt(this._nextIndex(-1));break;case"ArrowDown":this._focusAt(this._nextIndex(1));break;case"Home":case"PageUp":this._focusAt(0);break;case"End":case"PageDown":this._focusAt(this._elements.length-1);break}}_nextIndex(e){let n=this._index;do n=(n+e+this._elements.length)%this._elements.length;while(this._elements[n]?.offsetParent===null);return n}_getFocusableElements(){if(!this._el)return[];let e=this._el.querySelectorAll(QO),n=[],i=r=>r.getAttribute("role")==="menu";for(let r of e)r instanceof HTMLElement&&r.offsetParent!==null&&LP(this._el,r,i)&&n.push(r);return n}},XO=Object.defineProperty,ZO=Object.getOwnPropertyDescriptor,ru=(t,e,n,i)=>{for(var r=i>1?void 0:i?ZO(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&XO(e,n,r),r},JO=0,Zi=class extends H{constructor(){super(),this._expanded=D(!1),this._disabled=D(!1),this._trigger=D(null),this._content=D(null),this._isTriggerDisabled=D(!1),this._submenus=new Set,this._menuObserver=null,this._removeSubmenuBind=this._removeSubmenu.bind(this),this._onSubmenuOpenBind=this._onSubmenuOpen.bind(this),this._onSubmenuCloseBind=this._onSubmenuClose.bind(this),this._onResize=Mr(()=>{let n=C(this._content);if(!n||N)return;let i=0,r=getComputedStyle(n),s=[...n.children];for(let a of["paddingTop","paddingBottom","borderTopWidth","borderBottomWidth"])i+=parseFloat(r[a])||0;for(let a of s)if(a instanceof HTMLElement&&a.style.display==="contents")s.push(...a.children);else if(a.nodeType===3)i+=parseFloat(getComputedStyle(a).fontSize);else if(a instanceof HTMLElement){let o=getComputedStyle(a);if(o.display==="none")continue;i+=a.offsetHeight+(parseFloat(o.marginTop)||0)+(parseFloat(o.marginBottom)||0)}requestAnimationFrame(()=>{lt(n,"--menu-height",i+"px")})});let{showDelay:e}=this.$props;this._popper=new Nh({_trigger:this._trigger,_content:this._content,_showDelay:e,_listen:(n,i,r)=>{Nr(n,a=>{this._expanded()?r(a):i(a)});let s=this._getCloseTarget();s&&Nr(s,a=>{a.stopPropagation(),r(a)})},_onChange:this._onExpandedChange.bind(this)})}get triggerElement(){return this._trigger()}get contentElement(){return this._content()}get isSubmenu(){return!!this._parentMenu}onSetup(){this._media=le();let e=++JO;this._menuId=`media-menu-${e}`,this._menuButtonId=`media-menu-button-${e}`,this._focus=new gw({_getScrollContainer:this._findScrollContainer.bind(this),_closeMenu:this.close.bind(this)}),Tn(ct)&&(this._parentMenu=Ae(ct)),this.setAttributes({"data-open":this._expanded,"data-submenu":this.isSubmenu,"data-disabled":this._isDisabled.bind(this)}),Rt(ct,{_button:this._trigger,_expanded:this._expanded,_hint:D(""),_disable:this._disable.bind(this),_attachMenuButton:this._attachMenuButton.bind(this),_attachMenuItems:this._attachMenuItems.bind(this),_attachObserver:this._attachObserver.bind(this),_disableMenuButton:this._disableMenuButton.bind(this),_addSubmenu:this._addSubmenu.bind(this)})}onAttach(e){e.style.setProperty("display","contents"),this._focus._attachMenu(e)}onConnect(e){b(this._watchExpanded.bind(this)),this.isSubmenu&&this._parentMenu?._addSubmenu(this)}onDestroy(){this._trigger.set(null),this._content.set(null),this._menuObserver=null}_watchExpanded(){let e=this._isExpanded();this.isSubmenu||this._onResize(),this._updateMenuItemsHidden(e),e&&(b(()=>{let{height:n}=this._media.$state,i=this._content();i&<(i,"--player-height",n()+"px")}),this._focus._listen(),this.listen("pointerup",this._onPointerUp.bind(this)),S(window,"pointerup",this._onWindowPointerUp.bind(this)))}_attachMenuButton(e){let n=e.el,i=this.isSubmenu,r=Gt(this._isDisabled.bind(this));ve(n,"tabindex",i?"-1":"0"),ve(n,"role",i?"menuitem":"button"),Z(n,"id",this._menuButtonId),Z(n,"aria-haspopup","menu"),Z(n,"aria-expanded","false"),Z(n,"data-submenu",this.isSubmenu),this.isSubmenu||this._stopClickPropagation(n);let s=()=>{Z(n,"data-open",this._expanded()),Z(n,"aria-disabled",r())};N?s():b(s),this._trigger.set(n),G(()=>{this._trigger.set(null)})}_attachMenuItems(e){let n=e.el;n.style.setProperty("display","none"),Z(n,"id",this._menuId),ve(n,"role","menu"),ve(n,"tabindex","-1"),Z(n,"data-submenu",this.isSubmenu),this._content.set(n),G(()=>this._content.set(null));let i=()=>Z(n,"data-open",this._expanded());if(N?i():b(i),this._focus._attachMenu(n),this._updateMenuItemsHidden(!1),!this.isSubmenu){let r=this._onResizeTransition.bind(this);e.listen("transitionstart",r),e.listen("transitionend",r),e.listen("vds-menu-resize",this._onResize)}}_attachObserver(e){this._menuObserver=e}_stopClickPropagation(e){S(e,"click",n=>n.stopPropagation()),S(e,"pointerup",n=>n.stopPropagation())}_updateMenuItemsHidden(e){let n=C(this._content);n&&Z(n,"aria-hidden",Na(!e))}_disableMenuButton(e){this._isTriggerDisabled.set(e)}_onExpandedChange(e,n){if(n?.stopPropagation(),this._expanded()===e)return;if(this._isDisabled()){e&&this._popper.hide(n);return}this.el?.dispatchEvent(new Event("vds-menu-resize",{bubbles:!0,composed:!0}));let i=this._trigger(),r=this._content();if(i&&(Z(i,"aria-controls",e&&this._menuId),Z(i,"aria-expanded",Na(e))),r&&Z(r,"aria-labelledby",e&&this._menuButtonId),this._expanded.set(e),this._toggleMediaControls(n),Zn(),ji(n)){e?r?.focus():i?.focus();for(let s of[this.el,r])s&&s.setAttribute("data-keyboard","")}else for(let s of[this.el,r])s&&s.removeAttribute("data-keyboard");this.dispatch(e?"open":"close",{trigger:n}),e?(!this.isSubmenu&&this._media.activeMenu!==this&&(this._media.activeMenu?.close(n),this._media.activeMenu=this),this._menuObserver?._onOpen?.(n)):(this.isSubmenu?setTimeout(()=>{for(let s of this._submenus)s.close(n)},300):this._media.activeMenu=null,this._menuObserver?._onClose?.(n)),e&&!ji(n)&&requestAnimationFrame(()=>{this._focus._update(),setTimeout(()=>{this._focus._scroll()},100)})}_isExpanded(){return!this._isDisabled()&&this._expanded()}_isDisabled(){return this._disabled()||this._isTriggerDisabled()}_disable(e){this._disabled.set(e)}_onPointerUp(e){e.stopPropagation()}_onWindowPointerUp(e){if(!(!(e.target instanceof Node)||this._content()?.contains(e.target))){if(this.isSubmenu)return setTimeout(this.close.bind(this,e),800);this.close(e)}}_getCloseTarget(){let e=this.el?.querySelector('[data-part="close-target"]');return this.el&&e&&LP(this.el,e,n=>n.getAttribute("role")==="menu")?e:null}_findScrollContainer(){if(this.isSubmenu){let e=this.el;for(;e&&e.tagName!=="media-menu"&&e.hasAttribute("data-submenu");)e=e.parentNode;return e}else return C(this._content)||null}_toggleMediaControls(e){this.isSubmenu||(this._expanded()?this._media.remote.pauseControls(e):this._media.remote.resumeControls(e))}_addSubmenu(e){this._submenus.add(e),S(e,"open",this._onSubmenuOpenBind),S(e,"close",this._onSubmenuCloseBind),G(this._removeSubmenuBind)}_removeSubmenu(e){this._submenus.delete(e)}_onSubmenuOpen(e){this.isSubmenu&&this.triggerElement?.setAttribute("aria-hidden","true");for(let n of this._submenus)if(n!==e.target)for(let i of[n.el,n.triggerElement])i?.setAttribute("aria-hidden","true")}_onSubmenuClose(){this.isSubmenu&&this.triggerElement?.setAttribute("aria-hidden","false");for(let e of this._submenus)for(let n of[e.el,e.triggerElement])n?.setAttribute("aria-hidden","false")}_onResizeTransition(e){let n=this._content();if(n&&e.propertyName==="height"){let i=e.type==="transitionstart";Z(n,"data-resizing",i)}}open(e){C(this._expanded)||(this._popper.show(e),Zn())}close(e){C(this._expanded)&&(this._popper.hide(e),Zn())}};Zi.props={showDelay:0};ru([ee],Zi.prototype,"triggerElement",1);ru([ee],Zi.prototype,"contentElement",1);ru([ee],Zi.prototype,"isSubmenu",1);ru([Ne],Zi.prototype,"open",1);ru([Ne],Zi.prototype,"close",1);e3=Object.defineProperty,t3=Object.getOwnPropertyDescriptor,n3=(t,e,n,i)=>{for(var r=i>1?void 0:i?t3(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&e3(e,n,r),r},Ts=class extends H{get expanded(){return this._menu?._expanded()??!1}constructor(){super(),new pn}onSetup(){this._menu=Ae(ct)}onAttach(e){this._menu._attachMenuButton(this),b(this._watchDisabled.bind(this)),ve(e,"type","button")}onConnect(e){let n=Array.from(e.querySelectorAll('[data-part="hint"]')).pop();n&&b(()=>{let i=this._menu._hint();i&&(n.textContent=i)}),Nr(e,i=>{this.dispatch("select",{trigger:i})})}_watchDisabled(){this._menu._disableMenuButton(this.$props.disabled())}};Ts.props={disabled:!1};n3([ee],Ts.prototype,"expanded",1);Yh=class extends Ts{},Qh=class extends H{constructor(){super(...arguments),this._target=null}onSetup(){this._media=le(),Rt(dc,{_attach:this._attachElement.bind(this)})}onAttach(e){e.style.setProperty("display","contents")}onConnect(e){}onDestroy(){this._target?.remove(),this._target=null}_attachElement(e){this._portal(!1),this._target=e,yh(()=>{yh(()=>{this.connectScope&&b(this._watchDisabled.bind(this))})})}_watchDisabled(){let{fullscreen:e}=this._media.$state,{disabled:n}=this.$props,i=n();this._portal(i==="fullscreen"?!e():!i)}_portal(e){if(!this._target)return;let n=this._getContainer(this.$props.container());if(!n)return;let i=this._target.parentElement===n;Z(this._target,"data-portal",e),e?i||(this._target.remove(),n.append(this._target)):i&&this._target.parentElement===n&&(this._target.remove(),this.el?.append(this._target))}_getContainer(e){return e instanceof HTMLElement?e:e?document.querySelector(e):document.body}};Qh.props={container:null,disabled:!1};dc=mi(),bc=class extends H{constructor(){super(),new pn;let{placement:e}=this.$props;this.setAttributes({"data-placement":e})}onAttach(e){if(this._menu=Ae(ct),this._menu._attachMenuItems(this),Tn(dc)){let n=Ae(dc);n&&(Rt(dc,null),n._attach(e),G(()=>n._attach(null)))}}onConnect(e){b(this._watchPlacement.bind(this))}_watchPlacement(){if(!this.el)return;let e=this.$props.placement();if(e){Object.assign(this.el.style,{position:"absolute",top:0,left:0,width:"max-content"});let{offset:n,alignOffset:i}=this.$props;return IP(this.el,this._getButton(),e,{offsetVarName:"media-menu",xOffset:i(),yOffset:n()})}else this.el.removeAttribute("style"),this.el.style.display="none"}_getButton(){return this._menu._button()}};bc.props={placement:null,offset:0,alignOffset:0};vw=mi(),Dr=class extends Mt{constructor(){super(...arguments),this._group=new Set,this._value=D(""),this._controller=null,this._onChangeBind=this._onChange.bind(this)}get _values(){return Array.from(this._group).map(e=>e._value())}get value(){return this._value()}set value(e){this._onChange(e)}onSetup(){Rt(vw,{add:this._addRadio.bind(this),remove:this._removeRadio.bind(this)})}onAttach(e){Tn(ct)||ve(e,"role","radiogroup"),this.setAttributes({value:this._value})}onDestroy(){this._group.clear()}_addRadio(e){this._group.has(e)||(this._group.add(e),e._onCheck=this._onChangeBind,e._check(e._value()===this._value()))}_removeRadio(e){e._onCheck=null,this._group.delete(e)}_onChange(e,n){let i=C(this._value);if(!e||e===i)return;let r=this._findRadio(i),s=this._findRadio(e);r?._check(!1,n),s?._check(!0,n),this._value.set(e),this._onValueChange?.(e,n)}_findRadio(e){for(let n of this._group)if(e===C(n._value))return n;return null}},i3=Object.defineProperty,r3=Object.getOwnPropertyDescriptor,QP=(t,e,n,i)=>{for(var r=i>1?void 0:i?r3(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&i3(e,n,r),r},Xa=class extends H{get values(){return this._controller._values}get value(){return this._controller.value}set value(e){this._controller.value=e}constructor(){super(),this._controller=new Dr,this._controller._onValueChange=this._onValueChange.bind(this)}onSetup(){N?this._watchValue():b(this._watchValue.bind(this))}_watchValue(){this._controller.value=this.$props.value()}_onValueChange(e,n){let i=this.createEvent("change",{detail:e,trigger:n});this.dispatch(i)}};Xa.props={value:""};QP([ee],Xa.prototype,"values",1);QP([ee],Xa.prototype,"value",1);s3=Object.defineProperty,a3=Object.getOwnPropertyDescriptor,o3=(t,e,n,i)=>{for(var r=i>1?void 0:i?a3(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&s3(e,n,r),r},Za=class extends H{constructor(){super(),this._checked=D(!1),this._controller={_value:this.$props.value,_check:this._check.bind(this),_onCheck:null},new pn}get checked(){return this._checked()}onSetup(){this.setAttributes({value:this.$props.value,"data-checked":this._checked,"aria-checked":Gt(this._checked)})}onAttach(e){let n=Tn(ct);ve(e,"tabindex",n?"-1":"0"),ve(e,"role",n?"menuitemradio":"radio"),b(this._watchValue.bind(this))}onConnect(e){this._addToGroup(),Nr(e,this._onPress.bind(this)),G(this._onDisconnect.bind(this))}_onDisconnect(){et(()=>{Ae(vw).remove(this._controller)},this.connectScope)}_addToGroup(){Ae(vw).add(this._controller)}_watchValue(){let{value:e}=this.$props,n=e();C(this._checked)&&this._controller._onCheck?.(n)}_onPress(e){C(this._checked)||(this._onChange(!0,e),this._onSelect(e),this._controller._onCheck?.(C(this.$props.value),e))}_check(e,n){C(this._checked)!==e&&this._onChange(e,n)}_onChange(e,n){this._checked.set(e),this.dispatch("change",{detail:e,trigger:n})}_onSelect(e){this.dispatch("select",{trigger:e})}};Za.props={value:""};o3([ee],Za.prototype,"checked",1);l3=Object.defineProperty,c3=Object.getOwnPropertyDescriptor,Lw=(t,e,n,i)=>{for(var r=i>1?void 0:i?c3(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&l3(e,n,r),r},Ss=class extends H{constructor(){super(),this._index=D(0),this._track=D(null),this._cues=D([]),this._controller=new Dr,this._controller._onValueChange=this._onValueChange.bind(this)}get value(){return this._controller.value}get disabled(){return!this._cues()?.length}onSetup(){this._media=le(),Tn(ct)&&(this._menu=Ae(ct));let{thumbnails:e}=this.$props;this.setAttributes({"data-thumbnails":()=>!!e()})}onAttach(e){this._menu?._attachObserver({_onOpen:this._onOpen.bind(this)})}getOptions(){let{clipStartTime:e,clipEndTime:n}=this._media.$state,i=e(),r=n()||1/0;return this._cues().map((s,a)=>({cue:s,value:a.toString(),label:s.text,startTime:Vr(Math.max(0,s.startTime-i),!1),duration:yc(Math.min(r,s.endTime)-Math.max(i,s.startTime))}))}_onOpen(){C(()=>this._watchCurrentTime())}onConnect(e){b(this._watchValue.bind(this)),b(this._watchCurrentTime.bind(this)),b(this._watchControllerDisabled.bind(this)),b(this._watchTrack.bind(this)),eo(this._media.textTracks,"chapters",this._track.set)}_watchTrack(){let e=this._track();if(!e)return;let n=this._onCuesChange.bind(this,e);return n(),S(e,"add-cue",n),S(e,"remove-cue",n),()=>{this._cues.set([])}}_onCuesChange(e){let{clipStartTime:n,clipEndTime:i}=this._media.$state,r=n(),s=i()||1/0;this._cues.set([...e.cues].filter(a=>a.startTime<=s&&a.endTime>=r))}_watchValue(){this._controller.value=this._getValue()}_watchCurrentTime(){if(!this._menu?._expanded())return;if(!this._track()){this._index.set(-1);return}let{realCurrentTime:n,clipStartTime:i,clipEndTime:r}=this._media.$state,s=i(),a=r()||1/0,o=n(),l=this._cues().findIndex(c=>gh(c,o));if(this._index.set(l),l>=0){let c=this._cues()[l],u=this.el.querySelector("[aria-checked='true']"),d=Math.max(s,c.startTime),p=Math.min(a,c.endTime)-d,h=Math.max(0,o-d)/p*100;u&<(u,"--progress",At(h,3)+"%")}}_watchControllerDisabled(){this._menu?._disable(this.disabled)}_getValue(){return this._index().toString()}_onValueChange(e,n){if(this.disabled||!n)return;let i=+e,r=this._cues(),{clipStartTime:s}=this._media.$state;Be(i)&&r?.[i]&&(this._index.set(i),this._media.remote.seek(r[i].startTime-s(),n),this.dispatch("change",{detail:r[i],trigger:n}))}};Ss.props={thumbnails:null};Lw([ee],Ss.prototype,"value",1);Lw([ee],Ss.prototype,"disabled",1);Lw([Ne],Ss.prototype,"getOptions",1);u3=Object.defineProperty,d3=Object.getOwnPropertyDescriptor,Iw=(t,e,n,i)=>{for(var r=i>1?void 0:i?d3(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&u3(e,n,r),r},Ps=class extends H{get value(){return this._controller.value}get disabled(){let{audioTracks:e}=this._media.$state;return e().length===0}constructor(){super(),this._controller=new Dr,this._controller._onValueChange=this._onValueChange.bind(this)}onSetup(){this._media=le(),Tn(ct)&&(this._menu=Ae(ct))}onConnect(e){b(this._watchValue.bind(this)),b(this._watchControllerDisabled.bind(this)),b(this._watchHintText.bind(this))}getOptions(){let{audioTracks:e}=this._media.$state;return e().map(n=>({track:n,label:n.label,value:n.label.toLowerCase()}))}_watchValue(){this._controller.value=this._getValue()}_watchHintText(){let{emptyLabel:e}=this.$props,{audioTrack:n}=this._media.$state,i=n();this._menu?._hint.set(i?.label??e())}_watchControllerDisabled(){this._menu?._disable(this.disabled)}_getValue(){let{audioTrack:e}=this._media.$state,n=e();return n?n.label.toLowerCase():""}_onValueChange(e,n){if(this.disabled)return;let i=this._media.audioTracks.toArray().findIndex(r=>r.label.toLowerCase()===e);if(i>=0){let r=this._media.audioTracks[i];this._media.remote.changeAudioTrack(i,n),this.dispatch("change",{detail:r,trigger:n})}}};Ps.props={emptyLabel:"Default"};Iw([ee],Ps.prototype,"value",1);Iw([ee],Ps.prototype,"disabled",1);Iw([Ne],Ps.prototype,"getOptions",1);p3=Object.defineProperty,h3=Object.getOwnPropertyDescriptor,Aw=(t,e,n,i)=>{for(var r=i>1?void 0:i?h3(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&p3(e,n,r),r},Cs=class extends H{get value(){return this._controller.value}get disabled(){let{hasCaptions:e}=this._media.$state;return!e()}constructor(){super(),this._controller=new Dr,this._controller._onValueChange=this._onValueChange.bind(this)}onSetup(){this._media=le(),Tn(ct)&&(this._menu=Ae(ct))}onConnect(e){super.onConnect?.(e),b(this._watchValue.bind(this)),b(this._watchControllerDisabled.bind(this)),b(this._watchHintText.bind(this))}getOptions(){let{offLabel:e}=this.$props,{textTracks:n}=this._media.$state;return[{value:"off",label:e},...n().filter(We).map(i=>({track:i,label:i.label,value:this._getTrackValue(i)}))]}_watchValue(){this._controller.value=this._getValue()}_watchHintText(){let{offLabel:e}=this.$props,{textTrack:n}=this._media.$state,i=n();this._menu?._hint.set(i&&We(i)&&i.mode==="showing"?i.label:e())}_watchControllerDisabled(){this._menu?._disable(this.disabled)}_getValue(){let{textTrack:e}=this._media.$state,n=e();return n&&We(n)&&n.mode==="showing"?this._getTrackValue(n):"off"}_onValueChange(e,n){if(this.disabled)return;if(e==="off"){let r=this._media.textTracks.selected;if(r){let s=this._media.textTracks.toArray().indexOf(r);this._media.remote.changeTextTrackMode(s,"disabled",n),this.dispatch("change",{detail:null,trigger:n})}return}let i=this._media.textTracks.toArray().findIndex(r=>this._getTrackValue(r)===e);if(i>=0){let r=this._media.textTracks[i];this._media.remote.changeTextTrackMode(i,"showing",n),this.dispatch("change",{detail:r,trigger:n})}}_getTrackValue(e){return e.id+":"+e.kind+"-"+e.label.toLowerCase()}};Cs.props={offLabel:"Off"};Aw([ee],Cs.prototype,"value",1);Aw([ee],Cs.prototype,"disabled",1);Aw([Ne],Cs.prototype,"getOptions",1);f3=Object.defineProperty,m3=Object.getOwnPropertyDescriptor,Nw=(t,e,n,i)=>{for(var r=i>1?void 0:i?m3(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&f3(e,n,r),r},$s=class extends H{get value(){return this._controller.value}get disabled(){let{rates:e}=this.$props,{canSetPlaybackRate:n}=this._media.$state;return!n()||e().length===0}constructor(){super(),this._controller=new Dr,this._controller._onValueChange=this._onValueChange.bind(this)}onSetup(){this._media=le(),Tn(ct)&&(this._menu=Ae(ct))}onConnect(e){b(this._watchValue.bind(this)),b(this._watchHintText.bind(this)),b(this._watchControllerDisabled.bind(this))}getOptions(){let{rates:e,normalLabel:n}=this.$props;return e().map(i=>({label:i===1?n:i+"\xD7",value:i.toString()}))}_watchValue(){this._controller.value=this._getValue()}_watchHintText(){let{normalLabel:e}=this.$props,{playbackRate:n}=this._media.$state,i=n();this._menu?._hint.set(i===1?e():i+"\xD7")}_watchControllerDisabled(){this._menu?._disable(this.disabled)}_getValue(){let{playbackRate:e}=this._media.$state;return e().toString()}_onValueChange(e,n){if(this.disabled)return;let i=+e;this._media.remote.changePlaybackRate(i,n),this.dispatch("change",{detail:i,trigger:n})}};$s.props={normalLabel:"Normal",rates:[.25,.5,.75,1,1.25,1.5,1.75,2]};Nw([ee],$s.prototype,"value",1);Nw([ee],$s.prototype,"disabled",1);Nw([Ne],$s.prototype,"getOptions",1);g3=Object.defineProperty,v3=Object.getOwnPropertyDescriptor,Dw=(t,e,n,i)=>{for(var r=i>1?void 0:i?v3(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&g3(e,n,r),r},Ms=class extends H{constructor(){super(),this._sortedQualities=hi(()=>{let{qualities:e}=this._media.$state;return[...e()].sort((n,i)=>i.height===n.height?i.bitrate-n.bitrate:i.height-n.height)}),this._controller=new Dr,this._controller._onValueChange=this._onValueChange.bind(this)}get value(){return this._controller.value}get disabled(){let{canSetQuality:e,qualities:n}=this._media.$state;return!e()||n().length===0}onSetup(){this._media=le(),Tn(ct)&&(this._menu=Ae(ct))}onConnect(e){b(this._watchValue.bind(this)),b(this._watchControllerDisabled.bind(this)),b(this._watchHintText.bind(this))}getOptions(){let{autoLabel:e,hideBitrate:n}=this.$props;return[{value:"auto",label:e},...this._sortedQualities().map(i=>{let r=i.bitrate>=0?`${At(i.bitrate/1e6,2)} Mbps`:null;return{quality:i,label:i.height+"p",value:this._getQualityId(i),bitrate:()=>n()?null:r}})]}_watchValue(){this._controller.value=this._getValue()}_watchHintText(){let{autoLabel:e}=this.$props,{autoQuality:n,quality:i}=this._media.$state,r=i()?i().height+"p":"";this._menu?._hint.set(n()?e()+(r?` (${r})`:""):r)}_watchControllerDisabled(){this._menu?._disable(this.disabled)}_onValueChange(e,n){if(this.disabled)return;if(e==="auto"){this._media.remote.changeQuality(-1,n),this.dispatch("change",{detail:"auto",trigger:n});return}let{qualities:i}=this._media.$state,r=C(i).findIndex(s=>this._getQualityId(s)===e);if(r>=0){let s=C(i)[r];this._media.remote.changeQuality(r,n),this.dispatch("change",{detail:s,trigger:n})}}_getValue(){let{quality:e,autoQuality:n}=this._media.$state;if(n())return"auto";let i=e();return i?this._getQualityId(i):"auto"}_getQualityId(e){return e.height+"_"+e.bitrate}};Ms.props={autoLabel:"Auto",hideBitrate:!1};Dw([ee],Ms.prototype,"value",1);Dw([ee],Ms.prototype,"disabled",1);Dw([Ne],Ms.prototype,"getOptions",1);Xh=class extends H{constructor(){super(...arguments),this._provider=null,this._presses=0,this._pressTimerId=-1}onSetup(){this._media=le();let{event:e,action:n}=this.$props;this.setAttributes({event:e,action:n})}onAttach(e){e.setAttribute("data-media-gesture",""),e.style.setProperty("pointer-events","none")}onConnect(e){this._provider=this._media.player.el?.querySelector("[data-media-provider]"),b(this._attachListener.bind(this))}_attachListener(){let e=this.$props.event(),n=this.$props.disabled();!this._provider||!e||n||(/^dbl/.test(e)&&(e=e.split(/^dbl/)[1]),(e==="pointerup"||e==="pointerdown")&&this._media.$state.pointer()==="coarse"&&(e=e==="pointerup"?"touchend":"touchstart"),S(this._provider,e,this._acceptEvent.bind(this),{passive:!1}))}_acceptEvent(e){if(this.$props.disabled()||Wl(e)&&(e.button!==0||this._media.activeMenu)||Ia(e)&&this._media.activeMenu||Sw(e)||!this._inBounds(e))return;if(e.MEDIA_GESTURE=!0,e.preventDefault(),!C(this.$props.event)?.startsWith("dbl"))this._presses===0&&setTimeout(()=>{this._presses===1&&this._handleEvent(e)},250);else if(this._presses===1){queueMicrotask(()=>this._handleEvent(e)),clearTimeout(this._pressTimerId),this._presses=0;return}this._presses===0&&(this._pressTimerId=window.setTimeout(()=>{this._presses=0},275)),this._presses++}_handleEvent(e){this.el.setAttribute("data-triggered",""),requestAnimationFrame(()=>{this._isTopLayer()&&this._performAction(C(this.$props.action),e),requestAnimationFrame(()=>{this.el.removeAttribute("data-triggered")})})}_inBounds(e){if(!this.el)return!1;if(Wl(e)||Qy(e)||Ia(e)){let n=Ia(e)?e.changedTouches[0]??e.touches[0]:void 0,i=n?.clientX??e.clientX,r=n?.clientY??e.clientY,s=this.el.getBoundingClientRect(),a=r>=s.top&&r<=s.bottom&&i>=s.left&&i<=s.right;return e.type.includes("leave")?!a:a}return!0}_isTopLayer(){let e=this._media.player.el.querySelectorAll("[data-media-gesture][data-triggered]");return Array.from(e).sort((n,i)=>+getComputedStyle(i).zIndex-+getComputedStyle(n).zIndex)[0]===this.el}_performAction(e,n){if(!e)return;let i=new j("will-trigger",{detail:e,cancelable:!0,trigger:n});if(this.dispatchEvent(i),i.defaultPrevented)return;let[r,s]=e.replace(/:([a-z])/,"-$1").split(":");e.includes(":fullscreen")?this._media.remote.toggleFullscreen("prefer-media",n):e.includes("seek:")?this._media.remote.seek(C(this._media.$state.currentTime)+(+s||0),n):this._media.remote[Np(r)](n),this.dispatch("trigger",{detail:e,trigger:n})}};Xh.props={disabled:!1,event:void 0,action:void 0};yw=class{constructor(e){this._renderer=e,this.priority=10,this._track=null,this._disposal=Yl()}attach(){}canRender(){return!0}detach(){this._disposal.empty(),this._renderer.reset(),this._track=null}changeTrack(e){!e||this._track===e||(this._disposal.empty(),e.readyState<2?(this._renderer.reset(),this._disposal.add(S(e,"load",()=>this._changeTrack(e),{once:!0}))):this._changeTrack(e),this._disposal.add(S(e,"add-cue",n=>{this._renderer.addCue(n.detail)}),S(e,"remove-cue",n=>{this._renderer.removeCue(n.detail)})),this._track=e)}_changeTrack(e){this._renderer.changeTrack({cues:[...e.cues],regions:[...e.regions]})}},Zh=class extends H{onSetup(){this._media=le(),this.setAttributes({"aria-hidden":Gt(this._isHidden.bind(this))})}onAttach(e){e.style.setProperty("pointer-events","none")}onConnect(e){if(this._renderer){b(this._watchViewType.bind(this));return}Promise.resolve().then(()=>(rc(),ic)).then(n=>{this.connectScope&&et(()=>{this._lib=n;let{CaptionsRenderer:i}=this._lib;this._renderer=new i(e),this._textRenderer=new yw(this._renderer),b(this._watchViewType.bind(this))},this.connectScope)})}onDestroy(){this._textRenderer&&(this._textRenderer.detach(),this._media.textRenderers.remove(this._textRenderer)),this._renderer?.destroy()}_isHidden(){let{textTrack:e,remotePlaybackState:n}=this._media.$state,i=e();return this._media.$iosControls()||n()==="connected"||!i||!We(i)}_watchViewType(){let{viewType:e}=this._media.$state;return e()==="audio"?this._setupAudioView():this._setupVideoView()}_setupAudioView(){return b(this._onTrackChange.bind(this)),()=>{this.el.textContent=""}}_onTrackChange(){if(this._isHidden())return;let{textTrack:e}=this._media.$state;this._onCueChange(),S(e(),"cue-change",this._onCueChange.bind(this)),b(this._onUpdateTimedNodes.bind(this))}_onCueChange(){this.el.textContent="";let{realCurrentTime:e,textTrack:n}=this._media.$state,i=C(e),r=C(n).activeCues,{renderVTTCueString:s}=this._lib;for(let a of r){let o=document.createElement("div");o.setAttribute("data-part","cue"),o.innerHTML=s(a,i),this.el.append(o)}}_onUpdateTimedNodes(){let{realCurrentTime:e}=this._media.$state,{updateTimedVTTCueNodes:n}=this._lib;n(this.el,e())}_setupVideoView(){return b(this._watchTextDirection.bind(this)),b(this._watchMediaTime.bind(this)),this._media.textRenderers.add(this._textRenderer),()=>{this.el.textContent="",this._textRenderer.detach(),this._media.textRenderers.remove(this._textRenderer)}}_watchTextDirection(){this._renderer.dir=this.$props.textDir()}_watchMediaTime(){if(this._isHidden())return;let{realCurrentTime:e}=this._media.$state;this._renderer.currentTime=e()}};Zh.props={textDir:"ltr"};xc=class extends H{onSetup(){this._media=le(),this._watchSrc(),this._watchAlt(),this._watchCrossOrigin(),this._watchHidden()}onAttach(e){e.style.setProperty("pointer-events","none"),b(this._watchImg.bind(this)),b(this._watchSrc.bind(this)),b(this._watchAlt.bind(this)),b(this._watchCrossOrigin.bind(this)),b(this._watchHidden.bind(this));let{started:n}=this._media.$state;this.setAttributes({"data-visible":()=>!n()&&!this.$state.hidden(),"data-loading":this._isLoading.bind(this),"data-error":this._hasError.bind(this),"data-hidden":this.$state.hidden})}onConnect(e){b(this._onPreconnect.bind(this)),b(this._onLoadStart.bind(this))}_hasError(){let{error:e}=this.$state;return!fi(e())}_onPreconnect(){let{canLoadPoster:e,poster:n}=this._media.$state;!e()&&n()&&Jn(n(),"preconnect")}_watchHidden(){let{src:e}=this.$props,{$iosControls:n}=this._media,{poster:i}=this._media.$state;this.el&&Z(this.el,"display",n()?"none":null),this.$state.hidden.set(this._hasError()||!(e()||i())||n())}_isLoading(){let{loading:e,hidden:n}=this.$state;return!n()&&e()}_watchImg(){let e=this.$state.img();e&&(S(e,"load",this._onLoad.bind(this)),S(e,"error",this._onError.bind(this)))}_watchSrc(){let{canLoadPoster:e,poster:n}=this._media.$state,i=this.$props.src(),r=i||n();i&&n()!==i&&this._media.$state.providedPoster.set(i),this.$state.src.set(e()&&r.length?r:null)}_watchAlt(){let{src:e}=this.$props,{alt:n}=this.$state,{poster:i}=this._media.$state;n.set(e()||i()?this.$props.alt():null)}_watchCrossOrigin(){let{crossOrigin:e}=this.$props,{crossOrigin:n}=this.$state,{crossOrigin:i,poster:r}=this._media.$state,s=e()!==null?e():i();n.set(/ytimg\.com|vimeo/.test(r()||"")?null:s===!0?"anonymous":s)}_onLoadStart(){let{loading:e,error:n}=this.$state,{canLoadPoster:i,poster:r}=this._media.$state;e.set(i()&&!!r()),n.set(null)}_onLoad(){let{loading:e,error:n}=this.$state;e.set(!1),n.set(null)}_onError(e){let{loading:n,error:i}=this.$state;n.set(!1),i.set(e)}};xc.props={src:null,alt:null,crossOrigin:null};xc.state=new Xn({img:null,src:null,alt:null,crossOrigin:null,loading:!0,error:null,hidden:!1});kc=class extends H{constructor(){super(...arguments),this._invert=D(null)}onSetup(){this._media=le(),this._watchTime();let{type:e}=this.$props;this.setAttributes({"data-type":e,"data-remainder":this._shouldInvert.bind(this)})}onAttach(e){e.hasAttribute("role")||b(this._watchRole.bind(this)),b(this._watchTime.bind(this))}onConnect(e){b(()=>{if(!this.$props.toggle()){this._invert.set(null);return}Nr(e,this._onToggle.bind(this))})}_watchTime(){let{type:e,padHours:n,padMinutes:i,showHours:r}=this.$props,s=this._getSeconds(e()),a=this._media.$state.duration(),o=this._shouldInvert();if(!Number.isFinite(s+a)){this.$state.timeText.set("LIVE");return}let l=o?Math.max(0,a-s):s,c=Vr(l,n(),i(),r());this.$state.timeText.set((o?"-":"")+c)}_watchRole(){if(!this.el)return;let{toggle:e}=this.$props;Z(this.el,"role",e()?"timer":null),Z(this.el,"tabindex",e()?0:null)}_getSeconds(e){let{bufferedEnd:n,duration:i,currentTime:r}=this._media.$state;switch(e){case"buffered":return n();case"duration":return i();default:return r()}}_shouldInvert(){return this.$props.remainder()&&this._invert()!==!1}_onToggle(e){if(e.preventDefault(),this._invert()===null){this._invert.set(!this.$props.remainder());return}this._invert.set(n=>!n)}};kc.props={type:"current",showHours:!1,padHours:null,padMinutes:null,remainder:!1,toggle:!1};kc.state=new Xn({timeText:""});y3=mi(),_3={clickToPlay:!0,clickToFullscreen:!0,controls:["play-large","play","progress","current-time","mute+volume","captions","settings","pip","airplay","fullscreen"],customIcons:!1,displayDuration:!1,download:null,markers:null,invertTime:!0,thumbnails:null,toggleTime:!0,translations:null,seekTime:10,speed:[.5,.75,1,1.25,1.5,1.75,2,4]},_w=class extends H{onSetup(){this._media=le(),Rt(y3,{...this.$props,previewTime:D(0)})}};_w.props=_3;Rs=class extends $O{},Jh=class extends Ka{},Ec=class extends Ih{},Tc=class extends Ah{},ef=class extends gc{},Sc=class extends Uh{},Pc=class extends jh{},Cc=class extends Wh{},$c=class extends qh{},Mc=class extends Hh{},Rc=class extends zh{},Lc=class extends Vh{},Ic=class extends Fh{},Ac=class extends Bh{},Nc=class extends Dh{},Dc=class extends Oh{},Oc=class extends mc{},Vc=class extends Qi{},Fc=class extends Qa{},zc=class extends wc{},Uc=class extends Gh{},jc=class extends Ya{},qc=class extends Es{},Hc=class extends _c{},Bc=class extends Xi{},Wc=class extends Zi{},Kc=class extends Ts{},Gc=class extends bc{},Yc=class extends Yh{},Qc=class extends Xa{},Xc=class extends Za{},Zc=class extends Zh{},Jc=class extends Xh{},tf=class extends xc{},Ja=class extends Ga{},eu=class extends kc{},XP=ke.forwardRef((t,e)=>{let{children:n,...i}=t,r=ke.Children.toArray(n),s=r.find(b3);if(s){let a=s.props.children,o=r.map(l=>l===s?ke.Children.count(a)>1?ke.Children.only(null):ke.isValidElement(a)?a.props.children:null:l);return ke.createElement(ww,{...i,ref:e},ke.isValidElement(a)?ke.cloneElement(a,void 0,o):null)}return ke.createElement(ww,{...i,ref:e},n)});XP.displayName="Slot";ww=ke.forwardRef((t,e)=>{let{children:n,...i}=t;return ke.isValidElement(n)?ke.cloneElement(n,{...x3(i,n.props),ref:e?re(e,n.ref):n.ref}):ke.Children.count(n)>1?ke.Children.only(null):null});ww.displayName="SlotClone";w3=({children:t})=>ke.createElement(ke.Fragment,null,t);k3=["button","div","span","img","video","audio"],U=k3.reduce((t,e)=>{let n=ke.forwardRef((i,r)=>{let{asChild:s,...a}=i;return ke.createElement(s?XP:e,{...a,ref:r})});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});pP=Rs.state.record,E3=Object.keys(pP).reduce((t,e)=>({...t,[e](){return pP[e]}}),{})});var m1={};xt(m1,{default:()=>$V});var $V,g1=Ue(()=>{"use strict";"use client";$V=' '});var _C=dt((V8,yC)=>{"use strict";var mF={aa:{name:"Afar",nativeName:"Afaraf"},ab:{name:"Abkhaz",nativeName:"\u0430\u04A7\u0441\u0443\u0430 \u0431\u044B\u0437\u0448\u04D9\u0430"},ae:{name:"Avestan",nativeName:"avesta"},af:{name:"Afrikaans",nativeName:"Afrikaans"},ak:{name:"Akan",nativeName:"Akan"},am:{name:"Amharic",nativeName:"\u12A0\u121B\u122D\u129B"},an:{name:"Aragonese",nativeName:"aragon\xE9s"},ar:{name:"Arabic",nativeName:"\u0627\u064E\u0644\u0652\u0639\u064E\u0631\u064E\u0628\u0650\u064A\u064E\u0651\u0629\u064F"},as:{name:"Assamese",nativeName:"\u0985\u09B8\u09AE\u09C0\u09AF\u09BC\u09BE"},av:{name:"Avaric",nativeName:"\u0430\u0432\u0430\u0440 \u043C\u0430\u0446\u04C0"},ay:{name:"Aymara",nativeName:"aymar aru"},az:{name:"Azerbaijani",nativeName:"az\u0259rbaycan dili"},ba:{name:"Bashkir",nativeName:"\u0431\u0430\u0448\u04A1\u043E\u0440\u0442 \u0442\u0435\u043B\u0435"},be:{name:"Belarusian",nativeName:"\u0431\u0435\u043B\u0430\u0440\u0443\u0441\u043A\u0430\u044F \u043C\u043E\u0432\u0430"},bg:{name:"Bulgarian",nativeName:"\u0431\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438 \u0435\u0437\u0438\u043A"},bi:{name:"Bislama",nativeName:"Bislama"},bm:{name:"Bambara",nativeName:"bamanankan"},bn:{name:"Bengali",nativeName:"\u09AC\u09BE\u0982\u09B2\u09BE"},bo:{name:"Tibetan",nativeName:"\u0F56\u0F7C\u0F51\u0F0B\u0F61\u0F72\u0F42"},br:{name:"Breton",nativeName:"brezhoneg"},bs:{name:"Bosnian",nativeName:"bosanski jezik"},ca:{name:"Catalan",nativeName:"Catal\xE0"},ce:{name:"Chechen",nativeName:"\u043D\u043E\u0445\u0447\u0438\u0439\u043D \u043C\u043E\u0442\u0442"},ch:{name:"Chamorro",nativeName:"Chamoru"},co:{name:"Corsican",nativeName:"corsu"},cr:{name:"Cree",nativeName:"\u14C0\u1426\u1403\u152D\u140D\u140F\u1423"},cs:{name:"Czech",nativeName:"\u010De\u0161tina"},cu:{name:"Old Church Slavonic",nativeName:"\u0469\u0437\u044B\u043A\u044A \u0441\u043B\u043E\u0432\u0463\u043D\u044C\u0441\u043A\u044A"},cv:{name:"Chuvash",nativeName:"\u0447\u04D1\u0432\u0430\u0448 \u0447\u04D7\u043B\u0445\u0438"},cy:{name:"Welsh",nativeName:"Cymraeg"},da:{name:"Danish",nativeName:"dansk"},de:{name:"German",nativeName:"Deutsch"},dv:{name:"Divehi",nativeName:"\u078B\u07A8\u0788\u07AC\u0780\u07A8"},dz:{name:"Dzongkha",nativeName:"\u0F62\u0FAB\u0F7C\u0F44\u0F0B\u0F41"},ee:{name:"Ewe",nativeName:"E\u028Begbe"},el:{name:"Greek",nativeName:"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"},en:{name:"English",nativeName:"English"},eo:{name:"Esperanto",nativeName:"Esperanto"},es:{name:"Spanish",nativeName:"Espa\xF1ol"},et:{name:"Estonian",nativeName:"eesti"},eu:{name:"Basque",nativeName:"euskara"},fa:{name:"Persian",nativeName:"\u0641\u0627\u0631\u0633\u06CC"},ff:{name:"Fula",nativeName:"Fulfulde"},fi:{name:"Finnish",nativeName:"suomi"},fj:{name:"Fijian",nativeName:"vosa Vakaviti"},fo:{name:"Faroese",nativeName:"f\xF8royskt"},fr:{name:"French",nativeName:"Fran\xE7ais"},fy:{name:"Western Frisian",nativeName:"Frysk"},ga:{name:"Irish",nativeName:"Gaeilge"},gd:{name:"Scottish Gaelic",nativeName:"G\xE0idhlig"},gl:{name:"Galician",nativeName:"galego"},gn:{name:"Guaran\xED",nativeName:"Ava\xF1e'\u1EBD"},gu:{name:"Gujarati",nativeName:"\u0A97\u0AC1\u0A9C\u0AB0\u0ABE\u0AA4\u0AC0"},gv:{name:"Manx",nativeName:"Gaelg"},ha:{name:"Hausa",nativeName:"\u0647\u064E\u0648\u064F\u0633\u064E"},he:{name:"Hebrew",nativeName:"\u05E2\u05D1\u05E8\u05D9\u05EA"},hi:{name:"Hindi",nativeName:"\u0939\u093F\u0928\u094D\u0926\u0940"},ho:{name:"Hiri Motu",nativeName:"Hiri Motu"},hr:{name:"Croatian",nativeName:"Hrvatski"},ht:{name:"Haitian",nativeName:"Krey\xF2l ayisyen"},hu:{name:"Hungarian",nativeName:"magyar"},hy:{name:"Armenian",nativeName:"\u0540\u0561\u0575\u0565\u0580\u0565\u0576"},hz:{name:"Herero",nativeName:"Otjiherero"},ia:{name:"Interlingua",nativeName:"Interlingua"},id:{name:"Indonesian",nativeName:"Bahasa Indonesia"},ie:{name:"Interlingue",nativeName:"Interlingue"},ig:{name:"Igbo",nativeName:"As\u1EE5s\u1EE5 Igbo"},ii:{name:"Nuosu",nativeName:"\uA188\uA320\uA4BF Nuosuhxop"},ik:{name:"Inupiaq",nativeName:"I\xF1upiaq"},io:{name:"Ido",nativeName:"Ido"},is:{name:"Icelandic",nativeName:"\xCDslenska"},it:{name:"Italian",nativeName:"Italiano"},iu:{name:"Inuktitut",nativeName:"\u1403\u14C4\u1483\u144E\u1450\u1466"},ja:{name:"Japanese",nativeName:"\u65E5\u672C\u8A9E"},jv:{name:"Javanese",nativeName:"basa Jawa"},ka:{name:"Georgian",nativeName:"\u10E5\u10D0\u10E0\u10D7\u10E3\u10DA\u10D8"},kg:{name:"Kongo",nativeName:"Kikongo"},ki:{name:"Kikuyu",nativeName:"G\u0129k\u0169y\u0169"},kj:{name:"Kwanyama",nativeName:"Kuanyama"},kk:{name:"Kazakh",nativeName:"\u049B\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"},kl:{name:"Kalaallisut",nativeName:"kalaallisut"},km:{name:"Khmer",nativeName:"\u1781\u17C1\u1798\u179A\u1797\u17B6\u179F\u17B6"},kn:{name:"Kannada",nativeName:"\u0C95\u0CA8\u0CCD\u0CA8\u0CA1"},ko:{name:"Korean",nativeName:"\uD55C\uAD6D\uC5B4"},kr:{name:"Kanuri",nativeName:"Kanuri"},ks:{name:"Kashmiri",nativeName:"\u0915\u0936\u094D\u092E\u0940\u0930\u0940"},ku:{name:"Kurdish",nativeName:"Kurd\xEE"},kv:{name:"Komi",nativeName:"\u043A\u043E\u043C\u0438 \u043A\u044B\u0432"},kw:{name:"Cornish",nativeName:"Kernewek"},ky:{name:"Kyrgyz",nativeName:"\u041A\u044B\u0440\u0433\u044B\u0437\u0447\u0430"},la:{name:"Latin",nativeName:"latine"},lb:{name:"Luxembourgish",nativeName:"L\xEBtzebuergesch"},lg:{name:"Ganda",nativeName:"Luganda"},li:{name:"Limburgish",nativeName:"Limburgs"},ln:{name:"Lingala",nativeName:"Ling\xE1la"},lo:{name:"Lao",nativeName:"\u0E9E\u0EB2\u0EAA\u0EB2\u0EA5\u0EB2\u0EA7"},lt:{name:"Lithuanian",nativeName:"lietuvi\u0173 kalba"},lu:{name:"Luba-Katanga",nativeName:"Kiluba"},lv:{name:"Latvian",nativeName:"latvie\u0161u valoda"},mg:{name:"Malagasy",nativeName:"fiteny malagasy"},mh:{name:"Marshallese",nativeName:"Kajin M\u0327aje\u013C"},mi:{name:"M\u0101ori",nativeName:"te reo M\u0101ori"},mk:{name:"Macedonian",nativeName:"\u043C\u0430\u043A\u0435\u0434\u043E\u043D\u0441\u043A\u0438 \u0458\u0430\u0437\u0438\u043A"},ml:{name:"Malayalam",nativeName:"\u0D2E\u0D32\u0D2F\u0D3E\u0D33\u0D02"},mn:{name:"Mongolian",nativeName:"\u041C\u043E\u043D\u0433\u043E\u043B \u0445\u044D\u043B"},mr:{name:"Marathi",nativeName:"\u092E\u0930\u093E\u0920\u0940"},ms:{name:"Malay",nativeName:"Bahasa Melayu"},mt:{name:"Maltese",nativeName:"Malti"},my:{name:"Burmese",nativeName:"\u1017\u1019\u102C\u1005\u102C"},na:{name:"Nauru",nativeName:"Dorerin Naoero"},nb:{name:"Norwegian Bokm\xE5l",nativeName:"Norsk bokm\xE5l"},nd:{name:"Northern Ndebele",nativeName:"isiNdebele"},ne:{name:"Nepali",nativeName:"\u0928\u0947\u092A\u093E\u0932\u0940"},ng:{name:"Ndonga",nativeName:"Owambo"},nl:{name:"Dutch",nativeName:"Nederlands"},nn:{name:"Norwegian Nynorsk",nativeName:"Norsk nynorsk"},no:{name:"Norwegian",nativeName:"Norsk"},nr:{name:"Southern Ndebele",nativeName:"isiNdebele"},nv:{name:"Navajo",nativeName:"Din\xE9 bizaad"},ny:{name:"Chichewa",nativeName:"chiChe\u0175a"},oc:{name:"Occitan",nativeName:"occitan"},oj:{name:"Ojibwe",nativeName:"\u140A\u14C2\u1511\u14C8\u142F\u14A7\u140E\u14D0"},om:{name:"Oromo",nativeName:"Afaan Oromoo"},or:{name:"Oriya",nativeName:"\u0B13\u0B21\u0B3C\u0B3F\u0B06"},os:{name:"Ossetian",nativeName:"\u0438\u0440\u043E\u043D \xE6\u0432\u0437\u0430\u0433"},pa:{name:"Panjabi",nativeName:"\u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40"},pi:{name:"P\u0101li",nativeName:"\u092A\u093E\u0934\u093F"},pl:{name:"Polish",nativeName:"Polski"},ps:{name:"Pashto",nativeName:"\u067E\u069A\u062A\u0648"},pt:{name:"Portuguese",nativeName:"Portugu\xEAs"},qu:{name:"Quechua",nativeName:"Runa Simi"},rm:{name:"Romansh",nativeName:"rumantsch grischun"},rn:{name:"Kirundi",nativeName:"Ikirundi"},ro:{name:"Romanian",nativeName:"Rom\xE2n\u0103"},ru:{name:"Russian",nativeName:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},rw:{name:"Kinyarwanda",nativeName:"Ikinyarwanda"},sa:{name:"Sanskrit",nativeName:"\u0938\u0902\u0938\u094D\u0915\u0943\u0924\u092E\u094D"},sc:{name:"Sardinian",nativeName:"sardu"},sd:{name:"Sindhi",nativeName:"\u0938\u093F\u0928\u094D\u0927\u0940"},se:{name:"Northern Sami",nativeName:"Davvis\xE1megiella"},sg:{name:"Sango",nativeName:"y\xE2ng\xE2 t\xEE s\xE4ng\xF6"},si:{name:"Sinhala",nativeName:"\u0DC3\u0DD2\u0D82\u0DC4\u0DBD"},sk:{name:"Slovak",nativeName:"sloven\u010Dina"},sl:{name:"Slovenian",nativeName:"sloven\u0161\u010Dina"},sm:{name:"Samoan",nativeName:"gagana fa'a Samoa"},sn:{name:"Shona",nativeName:"chiShona"},so:{name:"Somali",nativeName:"Soomaaliga"},sq:{name:"Albanian",nativeName:"Shqip"},sr:{name:"Serbian",nativeName:"\u0441\u0440\u043F\u0441\u043A\u0438 \u0458\u0435\u0437\u0438\u043A"},ss:{name:"Swati",nativeName:"SiSwati"},st:{name:"Southern Sotho",nativeName:"Sesotho"},su:{name:"Sundanese",nativeName:"Basa Sunda"},sv:{name:"Swedish",nativeName:"Svenska"},sw:{name:"Swahili",nativeName:"Kiswahili"},ta:{name:"Tamil",nativeName:"\u0BA4\u0BAE\u0BBF\u0BB4\u0BCD"},te:{name:"Telugu",nativeName:"\u0C24\u0C46\u0C32\u0C41\u0C17\u0C41"},tg:{name:"Tajik",nativeName:"\u0442\u043E\u04B7\u0438\u043A\u04E3"},th:{name:"Thai",nativeName:"\u0E44\u0E17\u0E22"},ti:{name:"Tigrinya",nativeName:"\u1275\u130D\u122D\u129B"},tk:{name:"Turkmen",nativeName:"T\xFCrkmen\xE7e"},tl:{name:"Tagalog",nativeName:"Wikang Tagalog"},tn:{name:"Tswana",nativeName:"Setswana"},to:{name:"Tonga",nativeName:"faka Tonga"},tr:{name:"Turkish",nativeName:"T\xFCrk\xE7e"},ts:{name:"Tsonga",nativeName:"Xitsonga"},tt:{name:"Tatar",nativeName:"\u0442\u0430\u0442\u0430\u0440 \u0442\u0435\u043B\u0435"},tw:{name:"Twi",nativeName:"Twi"},ty:{name:"Tahitian",nativeName:"Reo Tahiti"},ug:{name:"Uyghur",nativeName:"\u0626\u06C7\u064A\u063A\u06C7\u0631\u0686\u06D5\u200E"},uk:{name:"Ukrainian",nativeName:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"},ur:{name:"Urdu",nativeName:"\u0627\u0631\u062F\u0648"},uz:{name:"Uzbek",nativeName:"\u040E\u0437\u0431\u0435\u043A"},ve:{name:"Venda",nativeName:"Tshiven\u1E13a"},vi:{name:"Vietnamese",nativeName:"Ti\u1EBFng Vi\u1EC7t"},vo:{name:"Volap\xFCk",nativeName:"Volap\xFCk"},wa:{name:"Walloon",nativeName:"walon"},wo:{name:"Wolof",nativeName:"Wollof"},xh:{name:"Xhosa",nativeName:"isiXhosa"},yi:{name:"Yiddish",nativeName:"\u05D9\u05D9\u05B4\u05D3\u05D9\u05E9"},yo:{name:"Yoruba",nativeName:"Yor\xF9b\xE1"},za:{name:"Zhuang",nativeName:"Sa\u026F cue\u014B\u0185"},zh:{name:"Chinese",nativeName:"\u4E2D\u6587"},zu:{name:"Zulu",nativeName:"isiZulu"}};yC.exports=mF});var eb=dt((F8,EC)=>{"use strict";var pu=_C(),wC={},Mf={},bC=[],xC=[],kC=[];for(let t in pu){let{name:e,nativeName:n}=pu[t];wC[t]=Mf[e.toLowerCase()]=Mf[n.toLowerCase()]={code:t,name:e,nativeName:n},bC.push(t),xC.push(e),kC.push(n)}EC.exports=class $f{static getLanguages(e=[]){return e.map(n=>$f.validate(n)?Object.assign({},wC[n]):{code:n,name:"",nativeName:""})}static getName(e){return $f.validate(e)?pu[e].name:""}static getAllNames(){return xC.slice()}static getNativeName(e){return $f.validate(e)?pu[e].nativeName:""}static getAllNativeNames(){return kC.slice()}static getCode(e){return e=e.toLowerCase(),Mf.hasOwnProperty(e)?Mf[e].code:""}static getAllCodes(){return bC.slice()}static validate(e){return pu.hasOwnProperty(e)}}});var _$=dt(Qf=>{"use strict";var y5=z(),_5=Symbol.for("react.element"),w5=Symbol.for("react.fragment"),b5=Object.prototype.hasOwnProperty,x5=y5.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,k5={key:!0,ref:!0,__self:!0,__source:!0};function y$(t,e,n){var i,r={},s=null,a=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(a=e.ref);for(i in e)b5.call(e,i)&&!k5.hasOwnProperty(i)&&(r[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps,e)r[i]===void 0&&(r[i]=e[i]);return{$$typeof:_5,type:t,key:s,ref:a,props:r,_owner:x5.current}}Qf.Fragment=w5;Qf.jsx=y$;Qf.jsxs=y$});var ae=dt((jq,w$)=>{"use strict";w$.exports=_$()});var Rm=dt(Mm=>{"use strict";Object.defineProperty(Mm,"__esModule",{value:!0});function mR(t,e){if(e)return t;throw new Error("Unhandled discriminated union member: "+JSON.stringify(t))}Mm.assertNever=mR;Mm.default=mR});var E6={};xt(E6,{default:()=>eg});module.exports=SL(E6);var xx=require("obsidian");function ig(t,e){let n={};for(let i of e)i in t&&(n[i]=t[i]);return n}function Ku(t,e){let n={...t};for(let i of e)delete n[i];return n}var rg={bilibili:"https://www.bilibili.com",youtube:"https://www.youtube.com",vimeo:"https://www.vimeo.com",coursera:"https://www.coursera.org"},Gu={bilibili:"bilibili",youtube:"YouTube",generic:"Website",vimeo:"Vimeo",coursera:"Coursera"},bx=t=>Ku(t,["generic"]);var PL={bilibili:'',vimeo:'',coursera:'',youtube:null};Object.entries(PL).forEach(([t,e])=>{e&&(0,xx.addIcon)(t,e)});var tg=require("obsidian");function qo(t){return zn(t).href}function zn(t){let e=new URL(t);return e.hash="",e}function Un(t){try{return new URL(t)}catch{return null}}var je=require("obsidian");function Gs(t,e){let n="target"in t?t.target:t;if(!n.instanceOf?.(HTMLElement))return;let i=n.getBoundingClientRect();return e.setParentElement(n).showAtPosition({x:i.x,y:i.bottom,width:i.width,overlap:!0,left:!0},n.doc)}var kx="mx-port";var ai=t=>`persist:mx-player-${t}`;var Ex=require("obsidian");function sg(t){return require("@electron/remote").session.fromPartition(ai(t))}function Tx(){return Ex.Platform.isDesktopApp?require("fs/promises"):null}function Sx(t){return require("@electron/remote").webContents.fromId(t)}function Yu(){return require("@electron/remote").dialog}var Ys=class extends je.Modal{constructor(n){super(n);w(this,"navEl",this.contentEl.insertAdjacentElement("beforebegin",createDiv({cls:"mx-login-nav"})));w(this,"webview",createEl("webview",{attr:{partition:this.partition,allowpopups:""}}));w(this,"backButton",new je.ButtonComponent(this.navEl).setIcon("arrow-left").setTooltip("Back").setClass("mx-login-back").setDisabled(!0).onClick(()=>{try{this.webview.goBack()}catch(n){new je.Notice("Failed to go back, see console for details"),console.error("err go back",n)}}));w(this,"forwardButton",new je.ButtonComponent(this.navEl).setIcon("arrow-right").setTooltip("Forward").setClass("mx-login-forward").setDisabled(!0).onClick(()=>{try{this.webview.goForward()}catch(n){new je.Notice("Failed to go forward, see console for details"),console.error("err go forward",n)}}));w(this,"refreshButton",new je.ButtonComponent(this.navEl).setIcon("rotate-ccw").setTooltip("Refresh").setClass("mx-login-refresh").setDisabled(!0).onClick(()=>{try{this.webview.reload()}catch(n){new je.Notice("Failed to refresh, see console for details"),console.error("err refresh",n)}}));w(this,"addressBarForm",this.navEl.createEl("form"));w(this,"addressBar",new je.TextComponent(this.addressBarForm).then(n=>{n.inputEl.type="url",n.inputEl.placeholder="https://example.com",n.inputEl.classList.add("mx-login-address")}));w(this,"addressSubmit",new je.ButtonComponent(this.addressBarForm).setIcon("arrow-right-circle").then(n=>n.buttonEl.type="submit"));w(this,"moreOptionsButton",new je.ButtonComponent(this.navEl).setIcon("more-horizontal").setTooltip("More options").setClass("mx-login-more").onClick(n=>{let i=new je.Menu;this.onMoreOptions(i),Gs(n,i)}));w(this,"callbacks",[]);w(this,"handledWebcontents",new Set);this.containerEl.addClasses(["mx-login-modal"]),this.titleEl.style.display="none",this.buildWelcome()}get partition(){return ai(this.app.appId)}buildWelcome(){this.contentEl.empty(),this.contentEl.createEl("h1").setText("Login");let n=this.contentEl.createEl("main");n.createEl("p").setText("You can login to sites, change preferences and more, just as you would in a browser."),n.createEl("p").setText("To open a website, you can:");let i=n.createEl("ul");i.createEl("li").setText("Enter the site address in the address bar");let r=i.createEl("li");r.setText("Select from a list of "),new je.DropdownComponent(r).addOptions({...bx(Gu),".":"supported websites..."}).setValue(".").onChange(s=>{s in rg&&this.setUrl(rg[s])})}getSession(){return sg(this.app.appId)}onMoreOptions(n){n.addItem(i=>i.setTitle("Clear cache").setSection("clear").setIcon("trash").onClick(async()=>{if(window.confirm("Are you sure you want to clear the website cache? All login sessions and preferences will be lost."))try{await this.getSession().clearCache(),new je.Notice("Cache cleared")}catch(s){new je.Notice("Failed to clear cache, see console for details"),console.error("err clear cache",s)}}))}setUrl(n){this.initWebview(),this.webview.src=n,this.addressBar.setValue(n)}register(n){this.callbacks.push(n)}registerWebviewEvent(n,i){this.webview.addEventListener(n,i),this.register(()=>this.webview.removeEventListener(n,i))}onClose(){for(let n of this.callbacks)n();this.containerEl.empty()}initWebview(){this.webview.isConnected||(this.registerWebviewEvent("will-navigate",()=>{this.addressBar.setValue(this.webview.getURL())}),this.contentEl.empty(),this.contentEl.appendChild(this.webview),this.backButton.setDisabled(!1),this.forwardButton.setDisabled(!1),this.refreshButton.setDisabled(!1),this.registerWebviewEvent("dom-ready",()=>{if(this.handledWebcontents.has(this.webview.getWebContentsId()))return;let n=this.webview.getWebContentsId();this.handledWebcontents.add(n),Sx(n)?.setWindowOpenHandler(({url:r,disposition:s})=>((s==="new-window"||s==="foreground-tab"||s==="default")&&this.setUrl(r),{action:"deny"}))}))}onOpen(){this.addressBarForm.onsubmit=n=>{n.preventDefault();let i=this.addressBar.getValue();i&&this.setUrl(i)}}};function Px(){this.addCommand({id:"login",name:"Login website",callback:()=>{new Ys(this.app).open()}})}var DM=require("obsidian");var Iu=require("obsidian");var Qu=require("obsidian"),Qs=class t extends Qu.Modal{constructor(n,i,r){super(n);this.onSubmit=i;this.onExit=r;this.containerEl.addClass("mx-playback-prompt"),this.onSubmit=i}static run(){return new Promise(n=>{new t(app,r=>n(Number(r)),()=>n(null)).open()})}onOpen(){let{contentEl:n,titleEl:i}=this;i.setText("Playback Speed");let r=n.createEl("form",{},s=>{s.createEl("input",{type:"number",placeholder:"Enter a number between 0 and 10",attr:{min:.1,max:10,step:.1,width:100,required:!0,name:"playback-speed"}}),s.createEl("button",{attr:{type:"submit"},text:"Submit"})});r.oninvalid=s=>{s.preventDefault(),new Qu.Notice("Invalid playback rate")},r.onsubmit=s=>{s.preventDefault();let a=new FormData(r);this.onSubmit(a.get("playback-speed").toString()),this.close()}}onClose(){let{contentEl:n}=this;n.empty(),this.onExit()}};var ar=[.25,.5,.75,1,1.25,1.5,2,3,5,10];function Cx(t,e){let n=e.state.playbackRate,i=!ar.includes(n),r=t.setTitle(CL(n)).setIcon("gauge").setSection("mx-player").setSubmenu();ar.forEach(s=>r.addItem(a=>a.setTitle(`${s}x`).setChecked(s===n).onClick(()=>{e.playbackRate=s}))),r.addItem(s=>s.setTitle($L(n)).setChecked(i).onClick(async()=>{let a=await Qs.run();a&&(e.playbackRate=a)}))}function CL(t){let e=new DocumentFragment;return e.appendText("Speed "),e.createEl("code",{text:`(${t}x)`}),e}function $L(t){let e=new DocumentFragment;return e.appendText("Custom"),ar.includes(t)?e.appendText("..."):(e.appendText(" "),e.createEl("code",{text:`(${t}x)`})),e}var IM=require("obsidian");var ko=require("obsidian");var $x=require("obsidian");var kt={video:["mp4","webm","ogv","mov","mkv"],audio:["mp3","wav","m4a","3gp","flac","ogg","oga","opus"]};function Xt(t){t=t.replace(/^\./,"").toLowerCase();for(let e of Object.keys(kt))if(kt[e].includes(t))return e;return null}var nz=[...kt.video,...kt.audio];function $i(t){return t.file instanceof $x.TFile}var pt={video:"mx-url-video",audio:"mx-url-audio"},ML=new Set(Object.values(pt));function RL(t){return ML.has(t)}var Mi="mx-embed",Zt="mx-webpage",jn={video:"mx-file-video",audio:"mx-file-audio"},LL=new Set(Object.values(jn));function IL(t){return LL.has(t)}function AL(t){return RL(t)||Mi===t||Zt===t}function ag(t){return IL(t)||AL(t)}var mm=require("obsidian"),EM=$(Ol());var ti=$(z());var uT={},cT=t=>{let e,n=new Set,i=(u,d)=>{let p=typeof u=="function"?u(e):u;if(!Object.is(p,e)){let h=e;e=d??(typeof p!="object"||p===null)?p:Object.assign({},e,p),n.forEach(y=>y(e,h))}},r=()=>e,l={setState:i,getState:r,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(uT.env?uT.env.MODE:void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},c=e=t(i,r,l);return l},_p=t=>t?cT(t):cT;var bT=$(z(),1),xT=$(yT(),1),wT={},{useDebugValue:fN}=bT.default,{useSyncExternalStoreWithSelector:mN}=xT.default,_T=!1,gN=t=>t;function Py(t,e=gN,n){(wT.env?wT.env.MODE:void 0)!=="production"&&n&&!_T&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),_T=!0);let i=mN(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return fN(i),i}var Vl={main:/^(?[\w:.]*)(?:,(?[\w:.]+))?$/,npt_sec:/^\d+(?:\.\d+)?$/,npt_mmss:/^(?[0-5]\d):(?[0-5]\d(?:\.\d+)?)$/,npt_hhmmss:/^(?\d+):(?[0-5]\d):(?[0-5]\d(?:\.\d+)?)$/,npt_time:/^(?:npt:)?([\d.:]+)$/},kn=({start:t,end:e})=>t>=0&&e<0;function Cr(t){if(!t)return null;let n=new URLSearchParams(t.replace(/^#+/,"")).get("t");if(!n)return null;let i=n.match(Vl.main);if(!i)return null;let{start:r,end:s}=i.groups;return vN(r,s)}var vN=(t,e)=>{let n=t||null,i=e??null,r,s;if(n&&i)r=bp(n),s=i==="e"?1/0:bp(i);else if(n)r=bp(n),s=-1;else if(i)r=-1,s=bp(i);else throw console.error("Missing startTime and endTime",t,e),new Error("Missing startTime and endTime");return r===null||s===null?null:{start:r,end:s}};function bp(t){let e=t.match(Vl.npt_time);if(!e)return null;let n=e[1],i=n.match(Vl.npt_sec);if(i)return Number(i[0]);let r=n.match(Vl.npt_mmss);if(r){let{mm:a,ss:o}=r.groups;return Number(a)*60+Number(o)}let s=n.match(Vl.npt_hhmmss);if(s){let{hh:a,mm:o,ss:l}=s.groups;return Number(a)*60*60+Number(o)*60+Number(l)}return null}function xp(t){let e=new URLSearchParams(t.replace(/^#+/,"")),n=!e.has("noctrl")&&!e.has("controls")?void 0:e.has("controls");return{loop:e.has("loop")?!0:void 0,muted:e.has("mute")?!0:void 0,autoplay:e.has("play")?!0:void 0,controls:n,volume:yN(e.get("vol")),tempFragment:Cr(t)}}function yN(t){if(!t)return;let e=parseInt(t,10);if(!isNaN(e)&&e>=0&&e<=100)return e/100}var kT=()=>({emit(t,...e){for(let n=0,i=this.events[t]||[],r=i.length;n{this.events[t]=this.events[t]?.filter(i=>e!==i)}}});function kp(){let t=kT();return t.once=function(n,i){let r=this.on(n,(...s)=>{r(),i(...s)});return r},t}function ET(t){let e=t;return typeof e.id=="string"&&typeof e.invoke=="string"}function TT(t,...e){return{id:_N(),invoke:t,args:e}}function ST(t){return typeof t.id=="string"}function PT(t){return typeof t.send=="string"}function CT(t,e){return{send:t,payload:e}}function _N(){return Math.random().toString(36).substring(2,9)}var Ep=class extends Error{constructor(e){super(`no handler for ${e}`)}},Cy="mx-port-ready";var Tp=class{constructor(){w(this,"port",null);w(this,"actions",Object.create(null));w(this,"emitter",kp());w(this,"methods",new Proxy({},{get:(e,n)=>{if(typeof n=="symbol")throw new Error("Remote invoke does not support symbol property");return e[n]??(e[n]=(...i)=>this.invoke(n.toString(),i))}}))}load(e){this.port&&this.port.close(),this.port=e;let n=({data:i})=>{this.onMessage(i)};e.addEventListener("message",n),e.start(),e.postMessage(Cy)}unload(){this.port?.close(),this.emitter.events={}}onMessage(e){e===Cy?this.emitter.emit("ready"):ET(e)?this.response(e):ST(e)?this.emitter.emit("resp",e.id,e.payload,e.error):PT(e)&&this.emitter.emit(`send:${e.send}`,{type:e.send,payload:e.payload})}invoke(e,n,{transfer:i,timeout:r=1e3}={}){if(!this.port)throw new Error("port not loaded");let s=TT(e,...n);return this.port.postMessage(s,{transfer:i}),new Promise((a,o)=>{let l=-1,c=this.emitter.on("resp",(u,d,p)=>{if(u===s.id)if(c(),window.clearTimeout(l),p){let{message:h,stack:y}=p,v=new Error(h);v.stack=y,o(v)}else a(d)});r>0&&r<1/0&&(l=window.setTimeout(()=>{c(),console.error(`${e} timeout after ${r}ms`),o(new Ui(r))},r))})}handle(e,n){this.actions[e]=n}send(e,n,i){if(!this.port)throw new Error("port not loaded");let r=CT(e,n);this.port.postMessage(r,{transfer:i})}on(e,n){return this.emitter.on(`send:${e}`,n)}once(e,n){return this.emitter.once(`send:${e}`,n)}onReady(e,{once:n=!1}={}){return n?this.emitter.once("ready",e):this.emitter.on("ready",e)}async response({id:e,invoke:n,args:i=[]}){if(!this.port)throw new Error("port not loaded");let r={id:e,payload:null};try{let s=this.actions[n];if(!s)throw new Ep(n);let a=await s(...i);a===void 0?this.port.postMessage(r):(r.payload=await a.value,this.port.postMessage(r,{transfer:a.transfer}))}catch(s){console.error("port messaging error",s),s instanceof Error?r.error={message:s.message,stack:s.stack}:r.error={message:String(s)},this.port.postMessage(r)}}},Ui=class extends Error{constructor(e){super(`timeout after ${e}ms`)}};var wN=()=>{},Fl=wN;Lt();Lt();Wt();Wt();var V=$(z(),1);var E=$(z(),1);Lt();Wt();var e1=$(Dl(),1);function wi(){return Vp(tu)}var T3=X(Lc,{domEventsRegex:/^onMedia/}),t1=E.forwardRef(({children:t,...e},n)=>E.createElement(T3,{...e},i=>E.createElement(U.button,{...i,ref:re(i.ref,n)},t)));t1.displayName="AirPlayButton";var S3=X(Rc,{domEventsRegex:/^onMedia/}),lf=E.forwardRef(({children:t,...e},n)=>E.createElement(S3,{...e},i=>E.createElement(U.button,{...i,ref:re(i.ref,n)},t)));lf.displayName="PlayButton";var P3=X(Sc,{domEventsRegex:/^onMedia/}),Ow=E.forwardRef(({children:t,...e},n)=>E.createElement(P3,{...e},i=>E.createElement(U.button,{...i,ref:re(i.ref,n)},t)));Ow.displayName="CaptionButton";var C3=X(Pc,{domEventsRegex:/^onMedia/}),cf=E.forwardRef(({children:t,...e},n)=>E.createElement(C3,{...e},i=>E.createElement(U.button,{...i,ref:re(i.ref,n)},t)));cf.displayName="FullscreenButton";var $3=X($c,{domEventsRegex:/^onMedia/}),uf=E.forwardRef(({children:t,...e},n)=>E.createElement($3,{...e},i=>E.createElement(U.button,{...i,ref:re(i.ref,n)},t)));uf.displayName="MuteButton";var M3=X(Mc,{domEventsRegex:/^onMedia/}),Vw=E.forwardRef(({children:t,...e},n)=>E.createElement(M3,{...e},i=>E.createElement(U.button,{...i,ref:re(i.ref,n)},t)));Vw.displayName="PIPButton";var R3=X(Ac,{domEventsRegex:/^onMedia/}),su=E.forwardRef(({children:t,...e},n)=>E.createElement(R3,{...e},i=>E.createElement(U.button,{...i,ref:re(i.ref,n)},t)));su.displayName="SeekButton";var L3=X(Cc,{domEventsRegex:/^onMedia/}),n1=E.forwardRef(({children:t,...e},n)=>E.createElement(L3,{...e},i=>E.createElement(U.button,{...i,ref:re(i.ref,n)},t)));n1.displayName="LiveButton";var Fw=X(jc),I3=X(Vc,{events:["onDragStart","onDragEnd","onDragValueChange","onValueChange","onPointerValueChange"]}),A3=E.forwardRef(({children:t,...e},n)=>E.createElement(I3,{...e,ref:n},i=>E.createElement(U.div,{...i},t)));A3.displayName="Slider";var N3=E.forwardRef((t,e)=>E.createElement(U.div,{...t,ref:e}));N3.displayName="SliderThumb";var D3=E.forwardRef((t,e)=>E.createElement(U.div,{...t,ref:e}));D3.displayName="SliderTrack";var O3=E.forwardRef((t,e)=>E.createElement(U.div,{...t,ref:e}));O3.displayName="SliderTrackFill";var V3=X(Hc),F3=E.forwardRef(({children:t,...e},n)=>E.createElement(V3,{...e},i=>E.createElement(U.div,{...i,ref:re(i.ref,n)},t)));F3.displayName="SliderPreview";var z3=E.forwardRef(({children:t,...e},n)=>E.createElement(Fw,{...e},(i,r)=>{let s=pe(()=>r.getValueText(),r);return E.createElement(U.div,{...i,ref:n},s,t)}));z3.displayName="SliderValue";var U3=X(zc,{domEventsRegex:/^onMedia/}),j3=E.forwardRef(({children:t,...e},n)=>E.createElement(U3,{...e,ref:n},i=>E.createElement(U.div,{...i},t)));j3.displayName="VolumeSlider";var q3=E.forwardRef(({children:t,...e},n)=>E.createElement(Fw,{...e},(i,r)=>{let s=pe(()=>r.getValueText(),r);return E.createElement(U.div,{...i,ref:re(i.ref,n)},s,t)}));q3.displayName="SliderValue";function H3(t=0,e=0,n=""){return N?{startTime:t,endTime:e,text:n,addEventListener:Ht,removeEventListener:Ht,dispatchEvent:Ht}:new window.VTTCue(t,e,n)}var B3=X(Ja),i1=E.forwardRef(({children:t,...e},n)=>E.createElement(B3,{...e},i=>E.createElement(U.div,{...i,ref:re(i.ref,n)},t)));i1.displayName="Thumbnail";var r1=E.forwardRef(({children:t,...e},n)=>{let{src:i,img:r,crossOrigin:s}=$r(Ja.state),a=pe(i),o=pe(s);return E.createElement(U.img,{crossOrigin:o,...e,src:a,ref:re(r.set,n)},t)});r1.displayName="ThumbnailImg";var df=Object.freeze({__proto__:null,Img:r1,Root:i1}),pf=E.createContext({$chapters:D(null)});pf.displayName="TimeSliderContext";var W3=X(Fc,{domEventsRegex:/^onMedia/}),K3=E.forwardRef(({children:t,...e},n)=>{let i=E.useMemo(()=>D(null),[]);return E.createElement(pf.Provider,{value:{$chapters:i}},E.createElement(W3,{...e,ref:n},r=>E.createElement(U.div,{...r},t)))});K3.displayName="TimeSlider";var G3=X(Bc),Y3=E.forwardRef(({children:t,...e},n)=>E.createElement(G3,{...e},(i,r)=>E.createElement(U.div,{...i,ref:re(i.ref,n)},E.createElement(s1,{instance:r},t))));Y3.displayName="SliderChapters";function s1({instance:t,children:e}){let n=pe(()=>t.cues,t),i=E.useRef([]),r=E.useRef(),{$chapters:s}=E.useContext(pf);return r.current||(r.current=H3()),E.useEffect(()=>(s.set(t),()=>void s.set(null)),[t]),E.useEffect(()=>{t.setRefs(i.current)},[n]),e(n.length?n:[r.current],a=>{if(!a){i.current.length=0;return}i.current.push(a)})}s1.displayName="SliderChapterTracks";var Q3=E.forwardRef(({children:t,...e},n)=>{let{$chapters:i}=E.useContext(pf),[r,s]=E.useState();return E.useEffect(()=>b(()=>{let a=i(),o=a?.activePointerCue||a?.activeCue;s(o?.text||"")}),[]),E.createElement(U.div,{...e,ref:n},r,t)});Q3.displayName="SliderChapterTitle";var X3=E.forwardRef(({children:t,...e},n)=>E.createElement(Fw,{...e},(i,r)=>{let s=pe(()=>r.getValueText(),r);return E.createElement(U.div,{...i,ref:re(i.ref,n)},s,t)}));X3.displayName="SliderValue";var Z3=E.forwardRef((t,e)=>E.createElement(U.div,{...t,ref:e}));Z3.displayName="SliderProgress";var J3=X(Uc),eV=E.forwardRef(({children:t,...e},n)=>E.createElement(J3,{...e},i=>E.createElement(U.div,{...i,ref:re(i.ref,n)},t)));eV.displayName="SliderThumbnail";var tV=X(qc,{events:["onCanPlay","onError"]}),nV=E.forwardRef(({children:t,...e},n)=>E.createElement(tV,{...e},(i,r)=>E.createElement(a1,{...i,instance:r,ref:re(i.ref,n)},t)));nV.displayName="SliderVideo";var a1=E.forwardRef(({instance:t,children:e,...n},i)=>{let{canLoad:r}=$r(Ls),{src:s,video:a,crossOrigin:o}=t.$state,l=pe(s),c=pe(r),u=pe(o);return E.createElement(U.video,{style:{maxWidth:"unset"},...n,src:l||void 0,muted:!0,playsInline:!0,preload:c?"auto":"none",crossOrigin:u||void 0,ref:re(a.set,i)},e)});a1.displayName="SliderVideoProvider";var iV=X(Qc,{events:["onChange"]}),rV=E.forwardRef(({children:t,...e},n)=>E.createElement(iV,{...e,ref:n},i=>E.createElement(U.div,{...i},t)));rV.displayName="RadioGroup";var sV=X(Xc,{events:["onChange","onSelect"]}),aV=E.forwardRef(({children:t,...e},n)=>E.createElement(sV,{...e},i=>E.createElement(U.div,{...i,ref:re(i.ref,n)},t)));aV.displayName="RadioItem";var oV=typeof document>"u",lV=X(Wc,{events:["onOpen","onClose"],domEventsRegex:/^onMedia/}),cV=E.forwardRef(({children:t,...e},n)=>E.createElement(lV,{...e,ref:n},(i,r)=>E.createElement(U.div,{...i,style:{display:r.isSubmenu?void 0:"contents",...i.style}},t)));cV.displayName="Menu";var uV=X(Kc,{events:["onSelect"]}),dV=E.forwardRef(({children:t,...e},n)=>E.createElement(uV,{...e},i=>E.createElement(U.button,{...i,ref:re(i.ref,n)},t)));dV.displayName="MenuButton";var pV=E.forwardRef(({disabled:t=!1,children:e,...n},i)=>{let r=ye("fullscreen");return oV||!(t==="fullscreen"?!r:!t)?e:(0,e1.createPortal)(E.createElement(U.div,{...n,style:{display:"contents",...n.style},ref:i},e),document.body)});pV.displayName="MenuPortal";var hV=X(Gc),fV=E.forwardRef(({children:t,...e},n)=>E.createElement(hV,{...e},i=>E.createElement(U.div,{...i,ref:re(i.ref,n)},t)));fV.displayName="MenuItems";var mV=X(Yc),gV=E.forwardRef(({children:t,...e},n)=>E.createElement(mV,{...e},i=>E.createElement(U.div,{...i,ref:re(i.ref,n)},t)));gV.displayName="MenuItem";var vV=X(Jc,{events:["onWillTrigger","onTrigger"]}),$n=E.forwardRef(({children:t,...e},n)=>E.createElement(vV,{...e,ref:n},i=>E.createElement(U.div,{...i},t)));$n.displayName="Gesture";var yV=X(eu),au=E.forwardRef(({children:t,...e},n)=>E.createElement(yV,{...e},(i,r)=>E.createElement(o1,{...i,instance:r,ref:re(i.ref,n)},t)));au.displayName="Time";var o1=E.forwardRef(({instance:t,children:e,...n},i)=>{let{timeText:r}=t.$state,s=pe(r);return E.createElement(U.div,{...n,ref:i},s,e)});o1.displayName="TimeText";function bi(){return wi()?.player||null}function zw({off:t=!0}={}){let e=wi(),{textTracks:n,textTrack:i}=e.$state,r=pe(n);return pe(i),E.useMemo(()=>{let s=r.filter(We),a=s.map(o=>({track:o,label:o.label,value:JP(o),get selected(){return i()===o},select(l){let c=n().indexOf(o);c>=0&&e.remote.changeTextTrackMode(c,"showing",l)}}));return t&&a.unshift({track:null,label:F(t)?t:"Off",value:"off",get selected(){return!i()},select(o){e.remote.toggleCaptions(o)}}),Object.defineProperty(a,"disabled",{get(){return!s.length}}),Object.defineProperty(a,"selectedTrack",{get(){return i()}}),Object.defineProperty(a,"selectedValue",{get(){let o=i();return o?JP(o):"off"}}),a},[r])}function JP(t){return t.id+":"+t.kind+"-"+t.label.toLowerCase()}var hf=$(z(),1),Uw=hf.forwardRef((t,e)=>{let{width:n,height:i,size:r=null,paths:s,...a}=t;return hf.createElement("svg",{viewBox:"0 0 32 32",...a,width:n??r,height:i??r,fill:"none","aria-hidden":"true",focusable:"false",xmlns:"http://www.w3.org/2000/svg",ref:e,dangerouslySetInnerHTML:{__html:s}})});Uw.displayName="VidstackIcon";var te=$(z(),1);Lt();Wt();var _V=X(Ec),l1=te.forwardRef(({children:t,...e},n)=>te.createElement(_V,{...e},i=>te.createElement(U.div,{...i,ref:re(i.ref,n)},t)));l1.displayName="Controls";var wV=X(Tc),c1=te.forwardRef(({children:t,...e},n)=>te.createElement(wV,{...e},i=>te.createElement(U.div,{...i,ref:re(i.ref,n)},t)));c1.displayName="ControlsGroup";var er=Object.freeze({__proto__:null,Group:c1,Root:l1}),bV=X(Nc);function xV({children:t,...e}){return te.createElement(bV,{...e},t)}xV.displayName="Tooltip";var kV=X(Dc),EV=te.forwardRef(({children:t,...e},n)=>te.createElement(kV,{...e},i=>te.createElement(U.button,{...i,ref:re(i.ref,n)},t)));EV.displayName="TooltipTrigger";var TV=X(Oc),SV=te.forwardRef(({children:t,...e},n)=>te.createElement(TV,{...e},i=>te.createElement(U.div,{...i,ref:re(i.ref,n)},t)));SV.displayName="TooltipContent";var PV=X(Ic,{domEventsRegex:/^onMedia/}),u1=te.forwardRef(({children:t,...e},n)=>te.createElement(PV,{...e},i=>te.createElement(U.button,{...i,ref:re(i.ref,n)},t)));u1.displayName="GoogleCastButton";var d1=te.forwardRef(({children:t,...e},n)=>{let i=ye("title");return te.createElement(U.span,{...e,ref:n},i,t)});d1.displayName="Title";function p1(t){let[e,n]=te.useState([]);return te.useEffect(()=>{if(!t){n([]);return}function i(){n(t.activeCues)}return i(),S(t,"cue-change",i)},[t]),e}function h1(t){let e=wi(),[n,i]=te.useState(null);return te.useEffect(()=>eo(e.textTracks,t,i),[t]),n}function ff(){let t=h1("chapters");return p1(t)[0]?.text||""}var f1=te.forwardRef(({children:t,...e},n)=>{let i=ff();return te.createElement(U.span,{...e,ref:n},i,t)});f1.displayName="ChapterTitle";var CV=X(Zc),mf=te.forwardRef(({children:t,...e},n)=>te.createElement(CV,{...e,ref:n},i=>te.createElement(U.div,{...i},t)));mf.displayName="Captions";var VU=te.forwardRef(({size:t=96,children:e,...n},i)=>te.createElement("svg",{width:t,height:t,fill:"none",viewBox:"0 0 120 120","aria-hidden":"true","data-part":"root",...n,ref:i},e)),FU=te.forwardRef(({width:t=8,children:e,...n},i)=>te.createElement("circle",{cx:"60",cy:"60",r:"54",stroke:"currentColor",strokeWidth:t,"data-part":"track",...n,ref:i},e)),zU=te.forwardRef(({width:t=8,fillPercent:e=50,children:n,...i},r)=>te.createElement("circle",{cx:"60",cy:"60",r:"54",stroke:"currentColor",pathLength:"100",strokeWidth:t,strokeDasharray:100,strokeDashoffset:100-e,"data-part":"track-fill",...i,ref:r},n));var gf=$(z(),1);Wt();function vf(t){let e=wi(),n=gf.useRef();return n.current||(n.current=new Ba),gf.useEffect(()=>{let i=t&&"current"in t?t.current:t,r=i instanceof Rs,s=r?i:e?.player;n.current.setPlayer(s??null),n.current.setTarget(i??null)},[e,t&&"current"in t?t.current:t]),n.current}var _j=$(Dl(),1);var MV=["onAbort","onAudioTrackChange","onAudioTracksChange","onAutoPlay","onAutoPlayChange","onAutoPlayFail","onCanLoad","onCanPlay","onCanPlayThrough","onControlsChange","onDestroy","onDurationChange","onEmptied","onEnd","onEnded","onError","onFindMediaPlayer","onFullscreenChange","onFullscreenError","onLiveChange","onLiveEdgeChange","onLoadedData","onLoadedMetadata","onLoadStart","onLoopChange","onOrientationChange","onPause","onPictureInPictureChange","onPictureInPictureError","onPlay","onPlayFail","onPlaying","onPlaysInlineChange","onPosterChange","onProgress","onProviderChange","onProviderLoaderChange","onProviderSetup","onQualitiesChange","onQualityChange","onRateChange","onReplay","onSeeked","onSeeking","onSourceChange","onSourceChange","onStalled","onStarted","onStreamTypeChange","onSuspend","onTextTrackChange","onTextTracksChange","onTimeUpdate","onTitleChange","onVdsLog","onVideoPresentationChange","onVolumeChange","onWaiting"],RV=X(Rs,{events:MV,eventsRegex:/^onHls/,domEventsRegex:/^onMedia/}),jw=V.forwardRef(({aspectRatio:t,children:e,...n},i)=>V.createElement(RV,{...n,src:n.src,ref:i,style:{aspectRatio:t,...n.style}},r=>V.createElement(U.div,{...r},e)));jw.displayName="MediaPlayer";var LV=X(Jh),qw=V.forwardRef(({loaders:t=[],children:e,mediaProps:n,buildMediaEl:i,...r},s)=>{let a=V.useMemo(()=>t.map(o=>new o),t);return V.createElement(LV,{...r,loaders:a,ref:s},(o,l)=>V.createElement("div",{...o},V.createElement(v1,{...n,provider:l,buildMediaEl:i}),e))});qw.displayName="MediaProvider";function v1({provider:t,buildMediaEl:e,...n}){let{controls:i,crossOrigin:r,poster:s,remotePlaybackInfo:a}=$r(Ls),{loader:o}=t.$state,{$iosControls:l,$provider:c,$providerSetup:u}=wi(),d=pe(i),p=pe(l),h=d||p,y=pe(r),v=pe(s),_=pe(o),m=pe(c),f=pe(u),g=pe(a),x=_?.mediaType(),T=_?.name==="youtube",L=_?.name==="vimeo",R=T||L,I=_?.name==="remotion",K=_?.name==="google-cast",[q,_e]=V.useState("");return V.useEffect(()=>{!K||q||Promise.resolve().then(()=>(g1(),m1)).then(J=>{_e(J.default)})},[K]),K?V.createElement("div",{className:"vds-google-cast",ref:J=>{t.load(J)}},V.createElement(Uw,{paths:q}),g?.deviceName?V.createElement("span",{className:"vds-google-cast-info"},"Google Cast on"," ",V.createElement("span",{className:"vds-google-cast-device-name"},g.deviceName)):null):I?V.createElement("div",{"data-remotion-canvas":!0},V.createElement("div",{"data-remotion-container":!0,ref:J=>{t.load(J)}},ZP(m)&&f?V.createElement(m.render):null)):e?.(_,t)??(R?V.createElement(V.Fragment,null,V.createElement("iframe",{className:T?"vds-youtube":"vds-vimeo",suppressHydrationWarning:!0,tabIndex:h?void 0:-1,"aria-hidden":"true","data-no-controls":h?void 0:"",ref(J){t.load(J)}}),h?null:V.createElement("div",{className:"vds-blocker"})):x?V.createElement(x==="audio"?"audio":"video",{...n,controls:h?"true":null,crossOrigin:typeof y=="boolean"?"":y,poster:x==="video"&&h&&v?v:null,preload:"none","aria-hidden":"true",suppressHydrationWarning:!0,ref(J){t.load(J)}}):null)}v1.displayName="MediaOutlet";function IV(t){let e=wi(),n=V.useMemo(()=>new ln(t),Object.values(t));return V.useEffect(()=>(e.textTracks.add(n),()=>void e.textTracks.remove(n)),[n]),n}function Hw({lang:t,...e}){return IV({language:t,...e}),null}Hw.displayName="Track";var AV=X(ef),NV=V.forwardRef(({children:t,...e},n)=>V.createElement(AV,{...e},i=>V.createElement(U.button,{...i,ref:re(i.ref,n)},t)));NV.displayName="ToggleButton";var DV=X(tf),OV=V.forwardRef(({children:t,...e},n)=>V.createElement(DV,{...e},(i,r)=>V.createElement(y1,{...i,instance:r,ref:re(i.ref,n)},t)));OV.displayName="Poster";var y1=V.forwardRef(({instance:t,children:e,...n},i)=>{let{src:r,img:s,alt:a,crossOrigin:o}=t.$state,l=pe(r),c=pe(a),u=pe(o);return V.createElement(U.img,{...n,src:l||"",alt:c||void 0,crossOrigin:u||void 0,ref:re(s.set,i)},e)});y1.displayName="PosterImg";var VV=V.forwardRef(({children:t,...e},n)=>V.createElement(U.div,{translate:"yes","aria-live":"off","aria-atomic":"true",...e,ref:n},t));VV.displayName="Caption";var FV=V.forwardRef((t,e)=>{let n=ye("textTrack"),[i,r]=V.useState();return V.useEffect(()=>{if(!n)return;function s(){r(n?.activeCues[0])}return n.addEventListener("cue-change",s),()=>{n.removeEventListener("cue-change",s),r(void 0)}},[n]),V.createElement(U.span,{...t,"data-part":"cue",dangerouslySetInnerHTML:{__html:i?.text||""},ref:e})});FV.displayName="CaptionText";function _1(){let[t,e]=V.useState(null),n=wi();return V.useEffect(()=>{if(n)return b(()=>{e(n.$provider())})},[]),t}function w1({clamp:t=!1,offset:e=0,orientation:n="horizontal"}={}){let[i,r]=V.useState(null),[s,a]=V.useState(null),[o,l]=V.useState(0),[c,u]=V.useState(!1);return V.useEffect(()=>{if(!i)return;let d=D(!1);function p(h){i&&l(zV(i,h,n))}return b(()=>{if(!d()){S(i,"pointerenter",()=>{u(!0),s?.setAttribute("data-visible","")}),S(i,"pointerdown",h=>{d.set(!0),p(h)}),S(i,"pointerleave",()=>{u(!1),s?.removeAttribute("data-visible")}),S(i,"pointermove",h=>{p(h)});return}s?.setAttribute("data-dragging",""),S(document,"pointerup",h=>{d.set(!1),s?.removeAttribute("data-dragging"),p(h)}),S(document,"pointermove",h=>{p(h)}),S(document,"touchmove",h=>h.preventDefault(),{passive:!1})})},[i]),V.useEffect(()=>{s&&s.style.setProperty("--slider-pointer",o+"%")},[s,o]),V.useEffect(()=>{if(!s)return;let d=()=>{Rw(s,{offset:e,clamp:t,orientation:n})};d();let p=new ResizeObserver(d);return p.observe(s),()=>p.disconnect()},[s,t,e,n]),{previewRootRef:r,previewRef:a,previewValue:o,isPreviewVisible:c}}function zV(t,e,n){let i,r=t.getBoundingClientRect();if(n==="vertical"){let{bottom:s,height:a}=r;i=(s-e.clientY)/a}else{let{left:s,width:a}=r;i=(e.clientX-s)/a}return UV(Math.max(0,Math.min(100,100*i)))}function UV(t){return Number(t.toFixed(3))}var b1='"use strict";var X=()=>({emit(e,...t){for(let n=0,r=this.events[e]||[],i=r.length;n{this.events[e]=this.events[e]?.filter(n=>t!==n)}}});function Z(){let e=X();return e.once=function(n,r){let i=this.on(n,(...s)=>{i(),r(...s)});return i},e}function ee(e){let t=e;return typeof t.id=="string"&&typeof t.invoke=="string"}function te(e,...t){return{id:Ce(),invoke:e,args:t}}function ne(e){return typeof e.id=="string"}function re(e){return typeof e.send=="string"}function ie(e,t){return{send:e,payload:t}}function Ce(){return Math.random().toString(36).substring(2,9)}var k=class extends Error{constructor(t){super(`no handler for ${t}`)}},N="mx-port-ready";var R=class{port=null;load(t){this.port&&this.port.close(),this.port=t;let n=({data:r})=>{this.onMessage(r)};t.addEventListener("message",n),t.start(),t.postMessage(N)}unload(){this.port?.close(),this.emitter.events={}}actions=Object.create(null);emitter=Z();onMessage(t){t===N?this.emitter.emit("ready"):ee(t)?this.response(t):ne(t)?this.emitter.emit("resp",t.id,t.payload,t.error):re(t)&&this.emitter.emit(`send:${t.send}`,{type:t.send,payload:t.payload})}methods=new Proxy({},{get:(t,n)=>{if(typeof n=="symbol")throw new Error("Remote invoke does not support symbol property");return t[n]??=(...r)=>this.invoke(n.toString(),r)}});invoke(t,n,{transfer:r,timeout:i=1e3}={}){if(!this.port)throw new Error("port not loaded");let s=te(t,...n);return this.port.postMessage(s,{transfer:r}),new Promise((o,a)=>{let l=-1,u=this.emitter.on("resp",(c,p,y)=>{if(c===s.id)if(u(),window.clearTimeout(l),y){let{message:K,stack:z}=y,S=new Error(K);S.stack=z,a(S)}else o(p)});i>0&&i<1/0&&(l=window.setTimeout(()=>{u(),a(new M(i))},i))})}handle(t,n){this.actions[t]=n}send(t,n,r){if(!this.port)throw new Error("port not loaded");let i=ie(t,n);this.port.postMessage(i,{transfer:r})}on(t,n){return this.emitter.on(`send:${t}`,n)}once(t,n){return this.emitter.once(`send:${t}`,n)}onReady(t,{once:n=!1}={}){return n?this.emitter.once("ready",t):this.emitter.on("ready",t)}async response({id:t,invoke:n,args:r=[]}){if(!this.port)throw new Error("port not loaded");let i={id:t,payload:null};try{let s=this.actions[n];if(!s)throw new k(n);let o=await s(...r);o===void 0?this.port.postMessage(i):(i.payload=await o.value,this.port.postMessage(i,{transfer:o.transfer}))}catch(s){s instanceof Error?i.error={message:s.message,stack:s.stack}:i.error={message:String(s)},this.port.postMessage(i)}}},M=class extends Error{constructor(t){super(`timeout after ${t}ms`)}};var se="mx-port";async function q(){let e=await new Promise((n,r)=>{function i({data:o,ports:a}){o===se&&(n(a[0]),window.removeEventListener("message",i),window.clearTimeout(s))}window.addEventListener("message",i);let s=setTimeout(()=>{r("failed to get port: timeout "+5e3),window.removeEventListener("message",i)},5e3)}),t=new R;return t.load(e),t}var A=class{#e=[];#t=!1;async load(){if(!this.#t){this.#t=!0,await this.onload();for(let t of this.#n)await t.load()}}async onload(){}async unload(){if(!this.#t)return;this.#t=!1;let t;for(;t=this.#e.pop();)await t();let n;for(;n=this.#n.pop();)await n.unload();await this.onunload()}async onunload(){}register(t){this.#e.push(t)}registerInterval(t,n){let r=setInterval(t,n);this.register(()=>clearInterval(r))}registerDomEvent(t,n,r,i){t.addEventListener(n,r,i),this.register(()=>t.removeEventListener(n,r,i))}#n=[];async addChild(t){return this.#n.push(t),this.#t&&await t.load(),t}async removeChild(t){let n=this.#n.indexOf(t);return n!==-1&&(this.#n.splice(n,1),t.unload()),t}};function d(e){let t=[];for(let n=0;nn.send("enterpictureinpicture",void 0)),e.registerDomEvent(t,"leavepictureinpicture",()=>n.send("leavepictureinpicture",void 0)));function r(){n.send("abort",void 0)}function i(){n.send("emptied",void 0)}function s(){t.error&&n.send("error",{code:t.error.code,message:t.error.message})}function o(){n.send("volumechange",{muted:t.muted,volume:t.volume})}function a(){n.send("durationchange",{played:d(t.played),duration:t.duration})}function l(){n.send("progress",{buffered:d(t.buffered),seekable:d(t.seekable)})}function u(){n.send("stalled",{readyState:t.readyState})}function c(){n.send("suspend",void 0)}function p(){n.send("ratechange",{rate:t.playbackRate})}function y(){n.send("seeked",{current:t.currentTime,played:d(t.played),duration:t.duration,ended:t.ended})}function K(){n.send("seeking",{current:t.currentTime})}function z(){n.send("ended",{controls:t.controls,current:t.currentTime,played:d(t.played),duration:t.duration,ended:t.ended})}function S(){n.send("waiting",{readyState:t.readyState})}}var U=class{value;next;constructor(t){this.value=t}},T=class{#e;#t;#n;constructor(){this.clear()}enqueue(t){let n=new U(t);this.#e?(this.#t.next=n,this.#t=n):(this.#e=n,this.#t=n),this.#n++}dequeue(){let t=this.#e;if(t)return this.#e=this.#e.next,this.#n--,t.value}clear(){this.#e=void 0,this.#t=void 0,this.#n=0}get size(){return this.#n}*[Symbol.iterator](){let t=this.#e;for(;t;)yield t.value,t=t.next}};var le={bind(e,t,n){return e.bind(n)}};function F(e){if(!((Number.isInteger(e)||e===Number.POSITIVE_INFINITY)&&e>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let t=new T,n=0,r=()=>{n--,t.size>0&&t.dequeue()()},i=async(a,l,u)=>{n++;let c=(async()=>a(...u))();l(c);try{await c}catch{}r()},s=(a,l,u)=>{t.enqueue(le.bind(i.bind(void 0,a,l,u))),(async()=>(await Promise.resolve(),n0&&t.dequeue()()))()},o=(a,...l)=>new Promise(u=>{s(a,u,l)});return Object.defineProperties(o,{activeCount:{get:()=>n},pendingCount:{get:()=>t.size},clearQueue:{value(){t.clear()}}}),o}async function ue(e,t,n){let r=document.createElement("canvas"),{videoWidth:i,videoHeight:s}=e;Object.assign(r,{width:i,height:s});let o=r.getContext("2d",{alpha:!1});if(!o)throw new Error("Canvas context creation failed");o.drawImage(e,0,0,i,s);let a=await new Promise((u,c)=>{try{r.toBlob(p=>{p?u(p):c(new Error("Canvas to blob failed"))},t,n)}catch(p){c(p)}}),l=await a.arrayBuffer();return{time:e.currentTime,blob:{arrayBuffer:l,type:a.type}}}var de=["currentTime","playbackRate","volume","muted"],ce=["paused","played","networkState","duration","buffered","seekable","readyState","ended","autoplay","error"],me=["play","pause"],fe="mx-mounted";function x(e){return e[0].toUpperCase()+e.slice(1)}function V(e){return e instanceof TimeRanges?d(e):e}function pe(){let e=this.media,t=this.controller,n=this.stateRef;ce.forEach(i=>{t.handle(`get${x(i)}`,()=>({value:V(e[i])}))}),t.handle("pictureInPictureEnabled",()=>({value:document.pictureInPictureElement===e})),t.handle("requestPictureInPicture",()=>{e instanceof HTMLVideoElement&&e.requestPictureInPicture()}),t.handle("exitPictureInPicture",()=>{document.exitPictureInPicture()}),de.forEach(i=>{t.handle(`get${x(i)}`,()=>({value:V(e[i])})),i==="currentTime"?t.handle(`set${x(i)}`,s=>{n.prevSeek={value:e.currentTime,time:Date.now()},e[i]=s}):t.handle(`set${x(i)}`,s=>{e[i]=s})}),me.forEach(i=>{t.handle(i,async(...s)=>({value:await e[i](...s)}))}),t.handle("screenshot",async(i,s)=>{if(!(e instanceof HTMLVideoElement))throw new Error("Cannot take screenshot of non-video element");let o=await ue(e,i,s);return{value:o,transfer:[o.blob.arrayBuffer]}});let r=F(4);return t.handle("fetch",async(i,{gzip:s=!1,...o}={})=>{let a=await r(()=>window.fetch(i,o)),l=await a.blob(),u={type:l.type,respHeaders:Object.fromEntries(a.headers)};if(!s){let y=await l.arrayBuffer();return{value:{ab:y,gzip:!1,...u},transfer:[y]}}let c=l.stream(),p=await De(c.pipeThrough(new CompressionStream("gzip")));return{value:{ab:p,gzip:!0,...u},transfer:[p]}}),n}async function De(e){let t=e.getReader(),n=[];for(;;){let{done:s,value:o}=await t.read();if(s)break;n.push(o)}let r=n.reduce((s,o)=>s+o.byteLength,0),i=new Uint8Array(r);for(let s=0,o=0;s=0&&o(),t.readyState>=1&&a(),t.readyState>=2&&l(),t.readyState>=3&&u(),t.readyState>=4&&c(),e.registerDomEvent(t,"play",s),e.registerDomEvent(t,"pause",r),e.registerDomEvent(t,"playing",i),t.readyState>=3&&!t.paused?(s(),i()):r();function r(){n.send("pause",{readyState:t.readyState})}function i(){n.send("playing",void 0)}function s(){n.send("play",void 0)}function o(){n.send("loadstart",{networkState:t.networkState})}function a(){n.send("loadedmetadata",void 0)}function l(){n.send("loadeddata",void 0)}function u(){n.send("canplay",{buffered:d(t.buffered),seekable:d(t.seekable),duration:t.duration})}function c(){n.send("canplaythrough",{buffered:d(t.buffered),seekable:d(t.seekable),duration:t.duration})}}var g=Symbol(0),C=!1,he=!1,$=null,E=null,f=null,m=0,b=[],j={};var w=0,we=1,P=2,B=3;function Ie(){C=!0,queueMicrotask(Oe)}function Oe(){if(!b.length){C=!1;return}he=!0;for(let e=0;e=0;n--)J(t[n])}function G(e=!0){if(this.$st===B)return;let t=e?this.$ps||this[g]:this,n=this.$ns,r=null;for(;n&&n[g]===this;)G.call(n,!0),ye(n),r=n.$ns,n.$ns=null,n=r;e&&ye(this),n&&(n.$ps=e?this.$ps:this),t&&(t.$ns=n)}function ye(e){e.$st=B,e.$d&&Me(e),e.$s&&L(e,0),e.$ps&&(e.$ps.$ns=null),e[g]=null,e.$s=null,e.$o=null,e.$ps=null,e.$cx=j,e.$eh=null}function Me(e){try{if(Array.isArray(e.$d))for(let t=e.$d.length-1;t>=0;t--){let n=e.$d[t];n.call(n)}else e.$d.call(e.$d);e.$d=null}catch(t){Te(e,t)}}function _e(e,t,n){let r=$,i=E;$=e,E=n;try{return t.call(e)}finally{$=r,E=i}}function Te(e,t){if(!e||!e.$eh)throw t;let n=0,r=e.$eh.length,i=ve(t);for(n=0;n0){e.$s.length=m+f.length;for(let s=0;s=t)&&(e.$e&&e.$st===w&&(b.push(e),C||Ie()),e.$st=t,e.$o))for(let n=0;n"u"}function Q(e){return typeof e=="number"&&!Number.isNaN(e)}var Ee,Ve=Event,Se=Symbol("DOM_EVENT"),W=class extends Ve{constructor(t,...n){super(t,n[0]),this[Ee]=!0,this.triggers=new D,this.detail=n[0]?.detail;let r=n[0]?.trigger;r&&this.triggers.add(r)}static{Ee=Se}get trigger(){return this.triggers.source}get originEvent(){return this.triggers.origin}get isOriginTrusted(){return this.triggers.origin?.isTrusted??!1}},D=class{constructor(){this.chain=[]}get source(){return this.chain[0]}get origin(){return this.chain[this.chain.length-1]}add(t){this.chain.push(t),ke(t)&&this.chain.push(...t.triggers)}remove(t){return this.chain.splice(this.chain.indexOf(t),1)[0]}has(t){return this.chain.some(n=>n===t)}hasType(t){return!!this.findType(t)}findType(t){return this.chain.find(n=>n.type===t)}walk(t){for(let n of this.chain){let r=t(n);if(r)return[n,r]}}[Symbol.iterator](){return this.chain.values()}};function ke(e){return!!e?.[Se]}var dn=typeof window<"u"?"requestIdleCallback"in window?window.requestIdleCallback:e=>window.setTimeout(e,1):Pe;var O=class{constructor(t){this._callback=t}_id;_start(){I(this._id)&&this._loop()}_stop(){Q(this._id)&&window.cancelAnimationFrame(this._id),this._id=void 0}_loop(){this._id=window.requestAnimationFrame(()=>{I(this._id)||(this._callback(),this._loop())})}};function Re(e){let t=e.media,n=e.controller,r=new O(a);e.register(()=>r._stop());let i,s=t.currentTime;function o(){i!==t.paused&&(i=t.paused,t.paused?t.addEventListener("timeupdate",a):t.removeEventListener("timeupdate",a))}o(),t.addEventListener("ended",()=>{r._stop(),o()}),t.addEventListener("pause",()=>{r._stop(),o()}),t.addEventListener("playing",()=>{r._start(),o()});function a(){s!==t.currentTime&&(s=t.currentTime,n.send("timeupdate",{current:s,played:d(t.played)}))}}function H(e,t=document.body,n=1e4){return new Promise((r,i)=>{let s=t.querySelector(e);if(s){r(s);return}let o=new MutationObserver(()=>{let l=t.querySelector(e);l&&(o.disconnect(),r(l),window.clearTimeout(a))}),a=window.setTimeout(()=>{o.disconnect(),i(new Error(`timeout waiting for ${e}`))},n);o.observe(t,{childList:!0,subtree:!0})})}var We=[".dplayer",".video-js",".jwplayer","[data-player]"],h=class extends A{constructor(n){super();this.controller=n;this.register(()=>n.unload())}getStyle(){return Ge}#e=null;stateRef={prevSeek:null};findMedia(){return H("video, audio")}async load(){let n=this.getStyle();n&&this.injectStyle(n),await super.load();let r=this.media.controls===!0;r&&(this.media.controls=!1),this.register(this.controller.on("mx-toggle-controls",({payload:i})=>{document.body.classList.toggle("mx-show-controls",i)})),r&&this.register(this.controller.on("mx-toggle-controls",({payload:i})=>{this.media.controls=i})),this.register(this.controller.on("mx-toggle-webfs",({payload:i})=>{document.body.classList.toggle("mx-fs-enable",i)})),document.body.classList.add("mx-play-ready"),this.controller.send("mx-play-ready",void 0)}get media(){if(!this.#e)throw new Error("Get media before load");return this.#e}async onload(){this.#e=await this.findMedia(),await Promise.all([this.enterWebFullscreen(),this.hookMediaEl()])}enterWebFullscreen(){document.body.classList.add("mx-fs-enable");let n=this.media.closest(We.join(", "))??this.media;n.classList.add("mx-player"),this.assignParentClass(n),window.dispatchEvent(new Event("resize"))}assignParentClass(n){for(let r of je(n))r.classList.add("mx-parent"),getComputedStyle(r).position=="fixed"&&r.classList.add("mx-absolute")}injectStyle(n){let r=document.createElement("style");r.textContent=n,document.head.appendChild(r),this.register(()=>r.remove())}async untilMediaReady(n="canplay",r=5e3){if(this.media.readyState>=Be[n])return;let i=-1;await new Promise((s,o)=>{this.registerDomEvent(this.media,n,s,{once:!0}),i=window.setTimeout(()=>{o(new M(r))},r)}),window.clearTimeout(i)}async hookMediaEl(){ge(this),Re(this),ae(this),pe.call(this),this.controller.send(fe,void 0)}};function*je(e,t=!1){for(t&&(yield e);e.parentElement&&e.parentElement!==document.body;)e=e.parentElement,yield e}var Be={loadedmetadata:HTMLMediaElement.HAVE_METADATA,loadeddata:HTMLMediaElement.HAVE_CURRENT_DATA,canplay:HTMLMediaElement.HAVE_FUTURE_DATA,canplaythrough:HTMLMediaElement.HAVE_ENOUGH_DATA},Ge=`\nbody.mx-fs-enable .mx-player {\n position: fixed !important;\n top: 0 !important;\n left: 0 !important;\n width: 100vw !important;\n height: 100vh !important;\n max-width: none !important;\n max-height: none !important;\n min-width: 0 !important;\n min-height: 0 !important;\n margin: 0 !important;\n padding: 0 !important;\n z-index: 2147483647 !important; /* Ensure it\'s on top of other elements */\n background-color: #000 !important;\n transform: none !important;\n}\nbody.mx-fs-enable .mx-parent {\n overflow: visible !important;\n z-index: auto !important;\n transform: none !important;\n -webkit-transform-style: flat !important;\n transition: none !important;\n contain: none !important;\n}\nbody.mx-fs-enable .mx-absolute {\n position: absolute !important;\n}\nbody.mx-fs-enable {\n overflow: hidden !important;\n zoom: 100% !important;\n}\nbody.mx-fs-enable .mx-parent video {\n object-fit: contain !important;\n}\n`.trim();var Ye={waitForSelector:H,MediaPlugin:h},Ae=(e=>function(n){if(n in e)return e[n];throw new Error(`Module not found: ${n.toString()}`)})({"media-extended":Ye});async function Le(e,t){if(!e)return new h(t);let n=window.eval(`(function anonymous(require,module,exports){${e}\n})`),r={},i={exports:r};n(Ae,i,r),r=i.exports||r;let s=r.default||i.exports;if(!s)throw new Error("Failed to load plugin. No exports detected.");let o=new s(t);if(!(o instanceof h))throw new Error("Failed to load plugin. plugin not extends MediaPlugin");return o}var _;q().then(e=>{e.handle("loadPlugin",async t=>{_&&_.unload(),_=await Le(t,e),_.load()})});\n';var tr=Symbol(0),_f=!1,x1=!1,Is=null,io=null,Mn=null,hn=0,no=[],Ww={},qV=()=>{},ro=0,P1=1,ou=2,bf=3;function HV(){_f=!0,queueMicrotask(BV)}function BV(){if(!no.length){_f=!1;return}x1=!0;for(let t=0;t=0;n--)Yw(e[n])}function C1(t){if(!t||!Is)return t||qV;let e=Is;return e.$d?Array.isArray(e.$d)?e.$d.push(t):e.$d=[e.$d,t]:e.$d=t,function(){e.$st!==bf&&(t.call(null),L1(e.$d)?e.$d=null:Array.isArray(e.$d)&&e.$d.splice(e.$d.indexOf(t),1))}}function Kw(t=!0){if(this.$st===bf)return;let e=t?this.$ps||this[tr]:this,n=this.$ns,i=null;for(;n&&n[tr]===this;)Kw.call(n,!0),k1(n),i=n.$ns,n.$ns=null,n=i;t&&k1(this),n&&(n.$ps=t?this.$ps:this),e&&(e.$ns=n)}function k1(t){t.$st=bf,t.$d&&$1(t),t.$s&&yf(t,0),t.$ps&&(t.$ps.$ns=null),t[tr]=null,t.$s=null,t.$o=null,t.$ps=null,t.$cx=Ww,t.$eh=null}function $1(t){try{if(Array.isArray(t.$d))for(let e=t.$d.length-1;e>=0;e--){let n=t.$d[e];n.call(n)}else t.$d.call(t.$d);t.$d=null}catch(e){M1(t,e)}}function KV(t,e,n){let i=Is,r=io;Is=t,io=n;try{return e.call(t)}finally{Is=i,io=r}}function M1(t,e){if(!t||!t.$eh)throw e;let n=0,i=t.$eh.length,r=E1(e);for(n=0;n0){t.$s.length=hn+Mn.length;for(let s=0;s=e)&&(t.$e&&t.$st===ro&&(no.push(t),_f||HV()),t.$st=e,t.$o))for(let n=0;nn===e)}hasType(e){return!!this.findType(e)}findType(e){return this.chain.find(n=>n.type===e)}walk(e){for(let n of this.chain){let i=e(n);if(i)return[n,i]}}[Symbol.iterator](){return this.chain.values()}};function D1(t){return!!t?.[N1]}function eF(){let t=new Set;return{add(...e){for(let n of e)t.add(n)},empty(){for(let e of t)e();t.clear()}}}function O1(){let t=eF();return C1(t.empty),t}var c7=typeof window<"u"?"requestIdleCallback"in window?window.requestIdleCallback:t=>window.setTimeout(t,1):A1;var Ds=require("obsidian");var V1=`"use strict";var s=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var y=(r,e)=>{for(var t in e)s(r,t,{get:e[t],enumerable:!0})},b=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of p(e))!m.call(r,n)&&n!==t&&s(r,n,{get:()=>e[n],enumerable:!(i=d(e,n))||i.enumerable});return r};var f=r=>b(s({},"__esModule",{value:!0}),r);var k={};y(k,{default:()=>o});module.exports=f(k);var c=()=>require("media-extended");var{waitForSelector:l,MediaPlugin:h}=c(),w=\` +`+s.stack}return{value:t,source:e,stack:r,digest:null}}function qg(t,e,n){return{value:t,source:null,stack:n??null,digest:e??null}}function Sv(t,e){try{console.error(e.value)}catch(n){setTimeout(function(){throw n})}}var IA=typeof WeakMap=="function"?WeakMap:Map;function VE(t,e,n){n=Di(-1,n),n.tag=3,n.payload={element:null};var i=e.value;return n.callback=function(){ap||(ap=!0,Dv=i),Sv(t,e)},n}function FE(t,e,n){n=Di(-1,n),n.tag=3;var i=t.type.getDerivedStateFromError;if(typeof i=="function"){var r=e.value;n.payload=function(){return i(r)},n.callback=function(){Sv(t,e)}}var s=t.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){Sv(t,e),typeof i!="function"&&(br===null?br=new Set([this]):br.add(this));var a=e.stack;this.componentDidCatch(e.value,{componentStack:a!==null?a:""})}),n}function G0(t,e,n){var i=t.pingCache;if(i===null){i=t.pingCache=new IA;var r=new Set;i.set(e,r)}else r=i.get(e),r===void 0&&(r=new Set,i.set(e,r));r.has(n)||(r.add(n),t=KA.bind(null,t,e,n),e.then(t,t))}function Y0(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function Q0(t,e,n,i,r){return t.mode&1?(t.flags|=65536,t.lanes=r,t):(t===e?t.flags|=65536:(t.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(e=Di(-1,1),e.tag=2,wr(n,e,1))),n.lanes|=1),t)}var AA=Ui.ReactCurrentOwner,Ft=!1;function Tt(t,e,n,i){e.child=t===null?vE(e,null,n,i):ka(e,t.child,n,i)}function X0(t,e,n,i,r){n=n.render;var s=e.ref;return ya(e,r),i=fy(t,e,n,i,s,r),n=my(),t!==null&&!Ft?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~r,zi(t,e,r)):(Pe&&n&&ny(e),e.flags|=1,Tt(t,e,i,r),e.child)}function Z0(t,e,n,i,r){if(t===null){var s=n.type;return typeof s=="function"&&!Ty(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(e.tag=15,e.type=s,zE(t,e,s,i,r)):(t=Fd(n.type,null,i,e,e.mode,r),t.ref=e.ref,t.return=e,e.child=t)}if(s=t.child,!(t.lanes&r)){var a=s.memoizedProps;if(n=n.compare,n=n!==null?n:Tl,n(a,i)&&t.ref===e.ref)return zi(t,e,r)}return e.flags|=1,t=kr(s,i),t.ref=e.ref,t.return=e,e.child=t}function zE(t,e,n,i,r){if(t!==null){var s=t.memoizedProps;if(Tl(s,i)&&t.ref===e.ref)if(Ft=!1,e.pendingProps=i=s,(t.lanes&r)!==0)t.flags&131072&&(Ft=!0);else return e.lanes=t.lanes,zi(t,e,r)}return Pv(t,e,n,i,r)}function UE(t,e,n){var i=e.pendingProps,r=i.children,s=t!==null?t.memoizedState:null;if(i.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},ge(ha,Jt),Jt|=n;else{if(!(n&1073741824))return t=s!==null?s.baseLanes|n:n,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,ge(ha,Jt),Jt|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},i=s!==null?s.baseLanes:n,ge(ha,Jt),Jt|=i}else s!==null?(i=s.baseLanes|n,e.memoizedState=null):i=n,ge(ha,Jt),Jt|=i;return Tt(t,e,r,n),e.child}function jE(t,e){var n=e.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(e.flags|=512,e.flags|=2097152)}function Pv(t,e,n,i,r){var s=Ut(n)?ds:vt.current;return s=ba(e,s),ya(e,r),n=fy(t,e,n,i,s,r),i=my(),t!==null&&!Ft?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~r,zi(t,e,r)):(Pe&&i&&ny(e),e.flags|=1,Tt(t,e,n,r),e.child)}function J0(t,e,n,i,r){if(Ut(n)){var s=!0;Qd(e)}else s=!1;if(ya(e,r),e.stateNode===null)Dd(t,e),mE(e,n,i),Tv(e,n,i,r),i=!0;else if(t===null){var a=e.stateNode,o=e.memoizedProps;a.props=o;var l=a.context,c=n.contextType;typeof c=="object"&&c!==null?c=bn(c):(c=Ut(n)?ds:vt.current,c=ba(e,c));var u=n.getDerivedStateFromProps,d=typeof u=="function"||typeof a.getSnapshotBeforeUpdate=="function";d||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(o!==i||l!==c)&&q0(e,a,i,c),dr=!1;var p=e.memoizedState;a.state=p,tp(e,i,a,r),l=e.memoizedState,o!==i||p!==l||zt.current||dr?(typeof u=="function"&&(Ev(e,n,u,i),l=e.memoizedState),(o=dr||H0(e,n,o,i,p,l,c))?(d||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(e.flags|=4194308)):(typeof a.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=i,e.memoizedState=l),a.props=i,a.state=l,a.context=c,i=o):(typeof a.componentDidMount=="function"&&(e.flags|=4194308),i=!1)}else{a=e.stateNode,hE(t,e),o=e.memoizedProps,c=e.type===e.elementType?o:Bn(e.type,o),a.props=c,d=e.pendingProps,p=a.context,l=n.contextType,typeof l=="object"&&l!==null?l=bn(l):(l=Ut(n)?ds:vt.current,l=ba(e,l));var h=n.getDerivedStateFromProps;(u=typeof h=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(o!==d||p!==l)&&q0(e,a,i,l),dr=!1,p=e.memoizedState,a.state=p,tp(e,i,a,r);var y=e.memoizedState;o!==d||p!==y||zt.current||dr?(typeof h=="function"&&(Ev(e,n,h,i),y=e.memoizedState),(c=dr||H0(e,n,c,i,p,y,l)||!1)?(u||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(i,y,l),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(i,y,l)),typeof a.componentDidUpdate=="function"&&(e.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof a.componentDidUpdate!="function"||o===t.memoizedProps&&p===t.memoizedState||(e.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||o===t.memoizedProps&&p===t.memoizedState||(e.flags|=1024),e.memoizedProps=i,e.memoizedState=y),a.props=i,a.state=y,a.context=l,i=c):(typeof a.componentDidUpdate!="function"||o===t.memoizedProps&&p===t.memoizedState||(e.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||o===t.memoizedProps&&p===t.memoizedState||(e.flags|=1024),i=!1)}return Cv(t,e,n,i,s,r)}function Cv(t,e,n,i,r,s){jE(t,e);var a=(e.flags&128)!==0;if(!i&&!a)return r&&V0(e,n,!1),zi(t,e,s);i=e.stateNode,AA.current=e;var o=a&&typeof n.getDerivedStateFromError!="function"?null:i.render();return e.flags|=1,t!==null&&a?(e.child=ka(e,t.child,null,s),e.child=ka(e,null,o,s)):Tt(t,e,o,s),e.memoizedState=i.state,r&&V0(e,n,!0),e.child}function HE(t){var e=t.stateNode;e.pendingContext?O0(t,e.pendingContext,e.pendingContext!==e.context):e.context&&O0(t,e.context,!1),uy(t,e.containerInfo)}function ek(t,e,n,i,r){return xa(),ry(r),e.flags|=256,Tt(t,e,n,i),e.child}var $v={dehydrated:null,treeContext:null,retryLane:0};function Mv(t){return{baseLanes:t,cachePool:null,transitions:null}}function qE(t,e,n){var i=e.pendingProps,r=$e.current,s=!1,a=(e.flags&128)!==0,o;if((o=a)||(o=t!==null&&t.memoizedState===null?!1:(r&2)!==0),o?(s=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(r|=1),ge($e,r&1),t===null)return xv(e),t=e.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?(e.mode&1?t.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(a=i.children,t=i.fallback,s?(i=e.mode,s=e.child,a={mode:"hidden",children:a},!(i&1)&&s!==null?(s.childLanes=0,s.pendingProps=a):s=wp(a,i,0,null),t=us(t,i,n,null),s.return=e,t.return=e,s.sibling=t,e.child=s,e.child.memoizedState=Mv(n),e.memoizedState=$v,t):yy(e,a));if(r=t.memoizedState,r!==null&&(o=r.dehydrated,o!==null))return NA(t,e,a,i,o,r,n);if(s){s=i.fallback,a=e.mode,r=t.child,o=r.sibling;var l={mode:"hidden",children:i.children};return!(a&1)&&e.child!==r?(i=e.child,i.childLanes=0,i.pendingProps=l,e.deletions=null):(i=kr(r,l),i.subtreeFlags=r.subtreeFlags&14680064),o!==null?s=kr(o,s):(s=us(s,a,n,null),s.flags|=2),s.return=e,i.return=e,i.sibling=s,e.child=i,i=s,s=e.child,a=t.child.memoizedState,a=a===null?Mv(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},s.memoizedState=a,s.childLanes=t.childLanes&~n,e.memoizedState=$v,i}return s=t.child,t=s.sibling,i=kr(s,{mode:"visible",children:i.children}),!(e.mode&1)&&(i.lanes=n),i.return=e,i.sibling=null,t!==null&&(n=e.deletions,n===null?(e.deletions=[t],e.flags|=16):n.push(t)),e.child=i,e.memoizedState=null,i}function yy(t,e){return e=wp({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function Pd(t,e,n,i){return i!==null&&ry(i),ka(e,t.child,null,n),t=yy(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function NA(t,e,n,i,r,s,a){if(n)return e.flags&256?(e.flags&=-257,i=qg(Error(P(422))),Pd(t,e,a,i)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(s=i.fallback,r=e.mode,i=wp({mode:"visible",children:i.children},r,0,null),s=us(s,r,a,null),s.flags|=2,i.return=e,s.return=e,i.sibling=s,e.child=i,e.mode&1&&ka(e,t.child,null,a),e.child.memoizedState=Mv(a),e.memoizedState=$v,s);if(!(e.mode&1))return Pd(t,e,a,null);if(r.data==="$!"){if(i=r.nextSibling&&r.nextSibling.dataset,i)var o=i.dgst;return i=o,s=Error(P(419)),i=qg(s,i,void 0),Pd(t,e,a,i)}if(o=(a&t.childLanes)!==0,Ft||o){if(i=Je,i!==null){switch(a&-a){case 4:r=2;break;case 16:r=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:r=32;break;case 536870912:r=268435456;break;default:r=0}r=r&(i.suspendedLanes|a)?0:r,r!==0&&r!==s.retryLane&&(s.retryLane=r,Fi(t,r),Yn(i,t,r,-1))}return Ey(),i=qg(Error(P(421))),Pd(t,e,a,i)}return r.data==="$?"?(e.flags|=128,e.child=t.child,e=GA.bind(null,t),r._reactRetry=e,null):(t=s.treeContext,en=_r(r.nextSibling),tn=e,Pe=!0,Kn=null,t!==null&&(vn[yn++]=Ai,vn[yn++]=Ni,vn[yn++]=ps,Ai=t.id,Ni=t.overflow,ps=e),e=yy(e,i.children),e.flags|=4096,e)}function tk(t,e,n){t.lanes|=e;var i=t.alternate;i!==null&&(i.lanes|=e),kv(t.return,e,n)}function Bg(t,e,n,i,r){var s=t.memoizedState;s===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:i,tail:n,tailMode:r}:(s.isBackwards=e,s.rendering=null,s.renderingStartTime=0,s.last=i,s.tail=n,s.tailMode=r)}function BE(t,e,n){var i=e.pendingProps,r=i.revealOrder,s=i.tail;if(Tt(t,e,i.children,n),i=$e.current,i&2)i=i&1|2,e.flags|=128;else{if(t!==null&&t.flags&128)e:for(t=e.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&tk(t,n,e);else if(t.tag===19)tk(t,n,e);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}i&=1}if(ge($e,i),!(e.mode&1))e.memoizedState=null;else switch(r){case"forwards":for(n=e.child,r=null;n!==null;)t=n.alternate,t!==null&&np(t)===null&&(r=n),n=n.sibling;n=r,n===null?(r=e.child,e.child=null):(r=n.sibling,n.sibling=null),Bg(e,!1,r,n,s);break;case"backwards":for(n=null,r=e.child,e.child=null;r!==null;){if(t=r.alternate,t!==null&&np(t)===null){e.child=r;break}t=r.sibling,r.sibling=n,n=r,r=t}Bg(e,!0,n,null,s);break;case"together":Bg(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function Dd(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function zi(t,e,n){if(t!==null&&(e.dependencies=t.dependencies),fs|=e.lanes,!(n&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(P(153));if(e.child!==null){for(t=e.child,n=kr(t,t.pendingProps),e.child=n,n.return=e;t.sibling!==null;)t=t.sibling,n=n.sibling=kr(t,t.pendingProps),n.return=e;n.sibling=null}return e.child}function DA(t,e,n){switch(e.tag){case 3:HE(e),xa();break;case 5:yE(e);break;case 1:Ut(e.type)&&Qd(e);break;case 4:uy(e,e.stateNode.containerInfo);break;case 10:var i=e.type._context,r=e.memoizedProps.value;ge(Jd,i._currentValue),i._currentValue=r;break;case 13:if(i=e.memoizedState,i!==null)return i.dehydrated!==null?(ge($e,$e.current&1),e.flags|=128,null):n&e.child.childLanes?qE(t,e,n):(ge($e,$e.current&1),t=zi(t,e,n),t!==null?t.sibling:null);ge($e,$e.current&1);break;case 19:if(i=(n&e.childLanes)!==0,t.flags&128){if(i)return BE(t,e,n);e.flags|=128}if(r=e.memoizedState,r!==null&&(r.rendering=null,r.tail=null,r.lastEffect=null),ge($e,$e.current),i)break;return null;case 22:case 23:return e.lanes=0,UE(t,e,n)}return zi(t,e,n)}var WE,Rv,KE,GE;WE=function(t,e){for(var n=e.child;n!==null;){if(n.tag===5||n.tag===6)t.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Rv=function(){};KE=function(t,e,n,i){var r=t.memoizedProps;if(r!==i){t=e.stateNode,ls(fi.current);var s=null;switch(n){case"input":r=Jg(t,r),i=Jg(t,i),s=[];break;case"select":r=Re({},r,{value:void 0}),i=Re({},i,{value:void 0}),s=[];break;case"textarea":r=nv(t,r),i=nv(t,i),s=[];break;default:typeof r.onClick!="function"&&typeof i.onClick=="function"&&(t.onclick=Gd)}rv(n,i);var a;n=null;for(c in r)if(!i.hasOwnProperty(c)&&r.hasOwnProperty(c)&&r[c]!=null)if(c==="style"){var o=r[c];for(a in o)o.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(yl.hasOwnProperty(c)?s||(s=[]):(s=s||[]).push(c,null));for(c in i){var l=i[c];if(o=r?.[c],i.hasOwnProperty(c)&&l!==o&&(l!=null||o!=null))if(c==="style")if(o){for(a in o)!o.hasOwnProperty(a)||l&&l.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in l)l.hasOwnProperty(a)&&o[a]!==l[a]&&(n||(n={}),n[a]=l[a])}else n||(s||(s=[]),s.push(c,n)),n=l;else c==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,o=o?o.__html:void 0,l!=null&&o!==l&&(s=s||[]).push(c,l)):c==="children"?typeof l!="string"&&typeof l!="number"||(s=s||[]).push(c,""+l):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(yl.hasOwnProperty(c)?(l!=null&&c==="onScroll"&&be("scroll",t),s||o===l||(s=[])):(s=s||[]).push(c,l))}n&&(s=s||[]).push("style",n);var c=s;(e.updateQueue=c)&&(e.flags|=4)}};GE=function(t,e,n,i){n!==i&&(e.flags|=4)};function nl(t,e){if(!Pe)switch(t.tailMode){case"hidden":e=t.tail;for(var n=null;e!==null;)e.alternate!==null&&(n=e),e=e.sibling;n===null?t.tail=null:n.sibling=null;break;case"collapsed":n=t.tail;for(var i=null;n!==null;)n.alternate!==null&&(i=n),n=n.sibling;i===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:i.sibling=null}}function mt(t){var e=t.alternate!==null&&t.alternate.child===t.child,n=0,i=0;if(e)for(var r=t.child;r!==null;)n|=r.lanes|r.childLanes,i|=r.subtreeFlags&14680064,i|=r.flags&14680064,r.return=t,r=r.sibling;else for(r=t.child;r!==null;)n|=r.lanes|r.childLanes,i|=r.subtreeFlags,i|=r.flags,r.return=t,r=r.sibling;return t.subtreeFlags|=i,t.childLanes=n,e}function OA(t,e,n){var i=e.pendingProps;switch(iy(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return mt(e),null;case 1:return Ut(e.type)&&Yd(),mt(e),null;case 3:return i=e.stateNode,Ea(),xe(zt),xe(vt),py(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(t===null||t.child===null)&&(Td(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,Kn!==null&&(Fv(Kn),Kn=null))),Rv(t,e),mt(e),null;case 5:dy(e);var r=ls(Ml.current);if(n=e.type,t!==null&&e.stateNode!=null)KE(t,e,n,i,r),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!i){if(e.stateNode===null)throw Error(P(166));return mt(e),null}if(t=ls(fi.current),Td(e)){i=e.stateNode,n=e.type;var s=e.memoizedProps;switch(i[pi]=e,i[Cl]=s,t=(e.mode&1)!==0,n){case"dialog":be("cancel",i),be("close",i);break;case"iframe":case"object":case"embed":be("load",i);break;case"video":case"audio":for(r=0;r<\/script>",t=t.removeChild(t.firstChild)):typeof i.is=="string"?t=a.createElement(n,{is:i.is}):(t=a.createElement(n),n==="select"&&(a=t,i.multiple?a.multiple=!0:i.size&&(a.size=i.size))):t=a.createElementNS(t,n),t[pi]=e,t[Cl]=i,WE(t,e,!1,!1),e.stateNode=t;e:{switch(a=sv(n,i),n){case"dialog":be("cancel",t),be("close",t),r=i;break;case"iframe":case"object":case"embed":be("load",t),r=i;break;case"video":case"audio":for(r=0;rSa&&(e.flags|=128,i=!0,nl(s,!1),e.lanes=4194304)}else{if(!i)if(t=np(a),t!==null){if(e.flags|=128,i=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),nl(s,!0),s.tail===null&&s.tailMode==="hidden"&&!a.alternate&&!Pe)return mt(e),null}else 2*Oe()-s.renderingStartTime>Sa&&n!==1073741824&&(e.flags|=128,i=!0,nl(s,!1),e.lanes=4194304);s.isBackwards?(a.sibling=e.child,e.child=a):(n=s.last,n!==null?n.sibling=a:e.child=a,s.last=a)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Oe(),e.sibling=null,n=$e.current,ge($e,i?n&1|2:n&1),e):(mt(e),null);case 22:case 23:return ky(),i=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==i&&(e.flags|=8192),i&&e.mode&1?Jt&1073741824&&(mt(e),e.subtreeFlags&6&&(e.flags|=8192)):mt(e),null;case 24:return null;case 25:return null}throw Error(P(156,e.tag))}function VA(t,e){switch(iy(e),e.tag){case 1:return Ut(e.type)&&Yd(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Ea(),xe(zt),xe(vt),py(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return dy(e),null;case 13:if(xe($e),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(P(340));xa()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return xe($e),null;case 4:return Ea(),null;case 10:return oy(e.type._context),null;case 22:case 23:return ky(),null;case 24:return null;default:return null}}var Cd=!1,gt=!1,FA=typeof WeakSet=="function"?WeakSet:Set,A=null;function pa(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(i){De(t,e,i)}else n.current=null}function Lv(t,e,n){try{n()}catch(i){De(t,e,i)}}var nk=!1;function zA(t,e){if(mv=Bd,t=Zk(),ty(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var r=i.anchorOffset,s=i.focusNode;i=i.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var a=0,o=-1,l=-1,c=0,u=0,d=t,p=null;t:for(;;){for(var h;d!==n||r!==0&&d.nodeType!==3||(o=a+r),d!==s||i!==0&&d.nodeType!==3||(l=a+i),d.nodeType===3&&(a+=d.nodeValue.length),(h=d.firstChild)!==null;)p=d,d=h;for(;;){if(d===t)break t;if(p===n&&++c===r&&(o=a),p===s&&++u===i&&(l=a),(h=d.nextSibling)!==null)break;d=p,p=d.parentNode}d=h}n=o===-1||l===-1?null:{start:o,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(gv={focusedElem:t,selectionRange:n},Bd=!1,A=e;A!==null;)if(e=A,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,A=t;else for(;A!==null;){e=A;try{var y=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var v=y.memoizedProps,w=y.memoizedState,m=e.stateNode,f=m.getSnapshotBeforeUpdate(e.elementType===e.type?v:Bn(e.type,v),w);m.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var g=e.stateNode.containerInfo;g.nodeType===1?g.textContent="":g.nodeType===9&&g.documentElement&&g.removeChild(g.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(P(163))}}catch(x){De(e,e.return,x)}if(t=e.sibling,t!==null){t.return=e.return,A=t;break}A=e.return}return y=nk,nk=!1,y}function ml(t,e,n){var i=e.updateQueue;if(i=i!==null?i.lastEffect:null,i!==null){var r=i=i.next;do{if((r.tag&t)===t){var s=r.destroy;r.destroy=void 0,s!==void 0&&Lv(e,n,s)}r=r.next}while(r!==i)}}function yp(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var i=n.create;n.destroy=i()}n=n.next}while(n!==e)}}function Iv(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function YE(t){var e=t.alternate;e!==null&&(t.alternate=null,YE(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[pi],delete e[Cl],delete e[_v],delete e[xA],delete e[kA])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function QE(t){return t.tag===5||t.tag===3||t.tag===4}function ik(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||QE(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Av(t,e,n){var i=t.tag;if(i===5||i===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=Gd));else if(i!==4&&(t=t.child,t!==null))for(Av(t,e,n),t=t.sibling;t!==null;)Av(t,e,n),t=t.sibling}function Nv(t,e,n){var i=t.tag;if(i===5||i===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(i!==4&&(t=t.child,t!==null))for(Nv(t,e,n),t=t.sibling;t!==null;)Nv(t,e,n),t=t.sibling}var st=null,Wn=!1;function cr(t,e,n){for(n=n.child;n!==null;)XE(t,e,n),n=n.sibling}function XE(t,e,n){if(hi&&typeof hi.onCommitFiberUnmount=="function")try{hi.onCommitFiberUnmount(up,n)}catch{}switch(n.tag){case 5:gt||pa(n,e);case 6:var i=st,r=Wn;st=null,cr(t,e,n),st=i,Wn=r,st!==null&&(Wn?(t=st,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):st.removeChild(n.stateNode));break;case 18:st!==null&&(Wn?(t=st,n=n.stateNode,t.nodeType===8?Vg(t.parentNode,n):t.nodeType===1&&Vg(t,n),kl(t)):Vg(st,n.stateNode));break;case 4:i=st,r=Wn,st=n.stateNode.containerInfo,Wn=!0,cr(t,e,n),st=i,Wn=r;break;case 0:case 11:case 14:case 15:if(!gt&&(i=n.updateQueue,i!==null&&(i=i.lastEffect,i!==null))){r=i=i.next;do{var s=r,a=s.destroy;s=s.tag,a!==void 0&&(s&2||s&4)&&Lv(n,e,a),r=r.next}while(r!==i)}cr(t,e,n);break;case 1:if(!gt&&(pa(n,e),i=n.stateNode,typeof i.componentWillUnmount=="function"))try{i.props=n.memoizedProps,i.state=n.memoizedState,i.componentWillUnmount()}catch(o){De(n,e,o)}cr(t,e,n);break;case 21:cr(t,e,n);break;case 22:n.mode&1?(gt=(i=gt)||n.memoizedState!==null,cr(t,e,n),gt=i):cr(t,e,n);break;default:cr(t,e,n)}}function rk(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new FA),e.forEach(function(i){var r=YA.bind(null,t,i);n.has(i)||(n.add(i),i.then(r,r))})}}function qn(t,e){var n=e.deletions;if(n!==null)for(var i=0;ir&&(r=a),i&=~s}if(i=r,i=Oe()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*jA(i/1960))-i,10t?16:t,mr===null)var i=!1;else{if(t=mr,mr=null,op=0,se&6)throw Error(P(331));var r=se;for(se|=4,A=t.current;A!==null;){var s=A,a=s.child;if(A.flags&16){var o=s.deletions;if(o!==null){for(var l=0;lOe()-by?cs(t,0):wy|=n),jt(t,e)}function sT(t,e){e===0&&(t.mode&1?(e=md,md<<=1,!(md&130023424)&&(md=4194304)):e=1);var n=St();t=Fi(t,e),t!==null&&(Nl(t,e,n),jt(t,n))}function GA(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),sT(t,n)}function YA(t,e){var n=0;switch(t.tag){case 13:var i=t.stateNode,r=t.memoizedState;r!==null&&(n=r.retryLane);break;case 19:i=t.stateNode;break;default:throw Error(P(314))}i!==null&&i.delete(e),sT(t,n)}var aT;aT=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||zt.current)Ft=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return Ft=!1,DA(t,e,n);Ft=!!(t.flags&131072)}else Ft=!1,Pe&&e.flags&1048576&&cE(e,Zd,e.index);switch(e.lanes=0,e.tag){case 2:var i=e.type;Dd(t,e),t=e.pendingProps;var r=ba(e,vt.current);ya(e,n),r=fy(null,e,i,t,r,n);var s=my();return e.flags|=1,typeof r=="object"&&r!==null&&typeof r.render=="function"&&r.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Ut(i)?(s=!0,Qd(e)):s=!1,e.memoizedState=r.state!==null&&r.state!==void 0?r.state:null,cy(e),r.updater=gp,e.stateNode=r,r._reactInternals=e,Tv(e,i,t,n),e=Cv(null,e,i,!0,s,n)):(e.tag=0,Pe&&s&&ny(e),Tt(null,e,r,n),e=e.child),e;case 16:i=e.elementType;e:{switch(Dd(t,e),t=e.pendingProps,r=i._init,i=r(i._payload),e.type=i,r=e.tag=XA(i),t=Bn(i,t),r){case 0:e=Pv(null,e,i,t,n);break e;case 1:e=J0(null,e,i,t,n);break e;case 11:e=X0(null,e,i,t,n);break e;case 14:e=Z0(null,e,i,Bn(i.type,t),n);break e}throw Error(P(306,i,""))}return e;case 0:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Bn(i,r),Pv(t,e,i,r,n);case 1:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Bn(i,r),J0(t,e,i,r,n);case 3:e:{if(HE(e),t===null)throw Error(P(387));i=e.pendingProps,s=e.memoizedState,r=s.element,hE(t,e),tp(e,i,null,n);var a=e.memoizedState;if(i=a.element,s.isDehydrated)if(s={element:i,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){r=Ta(Error(P(423)),e),e=ek(t,e,i,n,r);break e}else if(i!==r){r=Ta(Error(P(424)),e),e=ek(t,e,i,n,r);break e}else for(en=_r(e.stateNode.containerInfo.firstChild),tn=e,Pe=!0,Kn=null,n=vE(e,null,i,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(xa(),i===r){e=zi(t,e,n);break e}Tt(t,e,i,n)}e=e.child}return e;case 5:return yE(e),t===null&&xv(e),i=e.type,r=e.pendingProps,s=t!==null?t.memoizedProps:null,a=r.children,vv(i,r)?a=null:s!==null&&vv(i,s)&&(e.flags|=32),jE(t,e),Tt(t,e,a,n),e.child;case 6:return t===null&&xv(e),null;case 13:return qE(t,e,n);case 4:return uy(e,e.stateNode.containerInfo),i=e.pendingProps,t===null?e.child=ka(e,null,i,n):Tt(t,e,i,n),e.child;case 11:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Bn(i,r),X0(t,e,i,r,n);case 7:return Tt(t,e,e.pendingProps,n),e.child;case 8:return Tt(t,e,e.pendingProps.children,n),e.child;case 12:return Tt(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(i=e.type._context,r=e.pendingProps,s=e.memoizedProps,a=r.value,ge(Jd,i._currentValue),i._currentValue=a,s!==null)if(Qn(s.value,a)){if(s.children===r.children&&!zt.current){e=zi(t,e,n);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var o=s.dependencies;if(o!==null){a=s.child;for(var l=o.firstContext;l!==null;){if(l.context===i){if(s.tag===1){l=Di(-1,n&-n),l.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var u=c.pending;u===null?l.next=l:(l.next=u.next,u.next=l),c.pending=l}}s.lanes|=n,l=s.alternate,l!==null&&(l.lanes|=n),kv(s.return,n,e),o.lanes|=n;break}l=l.next}}else if(s.tag===10)a=s.type===e.type?null:s.child;else if(s.tag===18){if(a=s.return,a===null)throw Error(P(341));a.lanes|=n,o=a.alternate,o!==null&&(o.lanes|=n),kv(a,n,e),a=s.sibling}else a=s.child;if(a!==null)a.return=s;else for(a=s;a!==null;){if(a===e){a=null;break}if(s=a.sibling,s!==null){s.return=a.return,a=s;break}a=a.return}s=a}Tt(t,e,r.children,n),e=e.child}return e;case 9:return r=e.type,i=e.pendingProps.children,ya(e,n),r=bn(r),i=i(r),e.flags|=1,Tt(t,e,i,n),e.child;case 14:return i=e.type,r=Bn(i,e.pendingProps),r=Bn(i.type,r),Z0(t,e,i,r,n);case 15:return zE(t,e,e.type,e.pendingProps,n);case 17:return i=e.type,r=e.pendingProps,r=e.elementType===i?r:Bn(i,r),Dd(t,e),e.tag=1,Ut(i)?(t=!0,Qd(e)):t=!1,ya(e,n),mE(e,i,r),Tv(e,i,r,n),Cv(null,e,i,!0,t,n);case 19:return BE(t,e,n);case 22:return UE(t,e,n)}throw Error(P(156,e.tag))};function oT(t,e){return Ik(t,e)}function QA(t,e,n,i){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function _n(t,e,n,i){return new QA(t,e,n,i)}function Ty(t){return t=t.prototype,!(!t||!t.isReactComponent)}function XA(t){if(typeof t=="function")return Ty(t)?1:0;if(t!=null){if(t=t.$$typeof,t===qv)return 11;if(t===Bv)return 14}return 2}function kr(t,e){var n=t.alternate;return n===null?(n=_n(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function Fd(t,e,n,i,r,s){var a=2;if(i=t,typeof t=="function")Ty(t)&&(a=1);else if(typeof t=="string")a=5;else e:switch(t){case ia:return us(n.children,r,s,e);case Hv:a=8,r|=8;break;case Yg:return t=_n(12,n,e,r|2),t.elementType=Yg,t.lanes=s,t;case Qg:return t=_n(13,n,e,r),t.elementType=Qg,t.lanes=s,t;case Xg:return t=_n(19,n,e,r),t.elementType=Xg,t.lanes=s,t;case gk:return wp(n,r,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case fk:a=10;break e;case mk:a=9;break e;case qv:a=11;break e;case Bv:a=14;break e;case ur:a=16,i=null;break e}throw Error(P(130,t==null?t:typeof t,""))}return e=_n(a,n,e,r),e.elementType=t,e.type=i,e.lanes=s,e}function us(t,e,n,i){return t=_n(7,t,i,e),t.lanes=n,t}function wp(t,e,n,i){return t=_n(22,t,i,e),t.elementType=gk,t.lanes=n,t.stateNode={isHidden:!1},t}function Wg(t,e,n){return t=_n(6,t,null,e),t.lanes=n,t}function Kg(t,e,n){return e=_n(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function ZA(t,e,n,i,r){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Mg(0),this.expirationTimes=Mg(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mg(0),this.identifierPrefix=i,this.onRecoverableError=r,this.mutableSourceEagerHydrationData=null}function Sy(t,e,n,i,r,s,a,o,l){return t=new ZA(t,e,n,o,l),e===1?(e=1,s===!0&&(e|=8)):e=0,s=_n(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:i,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},cy(s),t}function JA(t,e,n){var i=3{"use strict";function pT(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(pT)}catch(t){console.error(t)}}pT(),hT.exports=dT()});var zl=dt(My=>{"use strict";var fT=Fl();My.createRoot=fT.createRoot,My.hydrateRoot=fT.hydrateRoot;var bz});var yT=dt(vT=>{"use strict";var $a=z();function rN(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var sN=typeof Object.is=="function"?Object.is:rN,aN=$a.useState,oN=$a.useEffect,lN=$a.useLayoutEffect,cN=$a.useDebugValue;function uN(t,e){var n=e(),i=aN({inst:{value:n,getSnapshot:e}}),r=i[0].inst,s=i[1];return lN(function(){r.value=n,r.getSnapshot=e,Ry(r)&&s({inst:r})},[t,n,e]),oN(function(){return Ry(r)&&s({inst:r}),t(function(){Ry(r)&&s({inst:r})})},[t]),cN(n),n}function Ry(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!sN(t,n)}catch{return!0}}function dN(t,e){return e()}var pN=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?dN:uN;vT.useSyncExternalStore=$a.useSyncExternalStore!==void 0?$a.useSyncExternalStore:pN});var wT=dt((Tz,_T)=>{"use strict";_T.exports=yT()});var xT=dt(bT=>{"use strict";var Sp=z(),hN=wT();function fN(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var mN=typeof Object.is=="function"?Object.is:fN,gN=hN.useSyncExternalStore,vN=Sp.useRef,yN=Sp.useEffect,_N=Sp.useMemo,wN=Sp.useDebugValue;bT.useSyncExternalStoreWithSelector=function(t,e,n,i,r){var s=vN(null);if(s.current===null){var a={hasValue:!1,value:null};s.current=a}else a=s.current;s=_N(function(){function l(h){if(!c){if(c=!0,u=h,h=i(h),r!==void 0&&a.hasValue){var y=a.value;if(r(y,h))return d=y}return d=h}if(y=d,mN(u,h))return y;var v=i(h);return r!==void 0&&r(y,v)?y:(u=h,d=v)}var c=!1,u,d,p=n===void 0?null:n;return[function(){return l(e())},p===null?void 0:function(){return l(p())}]},[e,n,i,r]);var o=gN(t,s[0],s[1]);return yN(function(){a.hasValue=!0,a.value=o},[o]),wN(o),o}});var ET=dt((Pz,kT)=>{"use strict";kT.exports=xT()});function $N(){Ap=!0,queueMicrotask(jT)}function jT(){if(!Ma.length){Ap=!1;return}Oy=!0;for(let t=0;t=0;n--)Qy(e[n])}function HT(t){let e=$t();return Kl(e,t.length?t.bind(null,Wl.bind(e)):t,null)}function C(t){return Kl(Ct,t,null)}function Aa(t){return Kl(null,t,null)}function Zn(){Oy||jT()}function Bl(){return Ct}function et(t,e){try{return Kl(e,t,null)}catch(n){By(e,n);return}}function qy(t,e=Ct){return e?.$cx[t]}function RN(t,e,n=Ct){n&&(n.$cx={...n.$cx,[t]:e})}function LN(t){Ct&&(Ct.$eh=Ct.$eh?[t,...Ct.$eh]:[t])}function G(t){if(!t||!Ct)return t||CN;let e=Ct;return e.$d?Array.isArray(e.$d)?e.$d.push(t):e.$d=[e.$d,t]:e.$d=t,function(){e.$st!==Op&&(t.call(null),Vp(e.$d)?e.$d=null:Array.isArray(e.$d)&&e.$d.splice(e.$d.indexOf(t),1))}}function Wl(t=!0){if(this.$st===Op)return;let e=t?this.$ps||this[on]:this,n=this.$ns,i=null;for(;n&&n[on]===this;)Wl.call(n,!0),NT(n),i=n.$ns,n.$ns=null,n=i;t&&NT(this),n&&(n.$ps=t?this.$ps:this),e&&(e.$ns=n)}function NT(t){t.$st=Op,t.$d&&qT(t),t.$s&&Lp(t,0),t.$ps&&(t.$ps.$ns=null),t[on]=null,t.$s=null,t.$o=null,t.$ps=null,t.$cx=Hy,t.$eh=null}function qT(t){try{if(Array.isArray(t.$d))for(let e=t.$d.length-1;e>=0;e--){let n=t.$d[e];n.call(n)}else t.$d.call(t.$d);t.$d=null}catch(e){By(t,e)}}function Kl(t,e,n){let i=Ct,r=Ra;Ct=t,Ra=n;try{return e.call(t)}finally{Ct=i,Ra=r}}function By(t,e){if(!t||!t.$eh)throw e;let n=0,i=t.$eh.length,r=DT(e);for(n=0;n0){t.$s.length=an+En.length;for(let s=0;s=e)&&(t.$e&&t.$st===Ia&&(Ma.push(t),Ap||$N()),t.$st=e,t.$o))for(let n=0;nt();return e[on]=!0,e}function Xy(t){return YT(t)&&"set"in t}function qt(...t){}function gi(t){return t===null}function Le(t){return typeof t>"u"}function Zy(t){return gi(t)||Le(t)}function Gl(t){return t?.constructor===Object}function Be(t){return typeof t=="number"&&!Number.isNaN(t)}function F(t){return typeof t=="string"}function Jy(t){return typeof t=="boolean"}function yt(t){return typeof t=="function"}function qe(t){return Array.isArray(t)}function NN(t){return F(t)?new RegExp(t):t}function DN(t){return Ht?!1:t===window}function ON(t,e){return typeof process<"u",qt}function Fp(t){return!!t?.[ZT]}function FN(t){return t.originEvent}function JT(t,e){if(Fp(t))return t.triggers.walk(e)}function e_(t,e){return Fp(t)?t.triggers.findType(e):void 0}function eS(t,e){return!!e_(t,e)}function tS(t,e){e&&t.triggers.add(e)}function S(t,e,n,i){return Ht?qt:(t.addEventListener(e,n,i),G(()=>t.removeEventListener(e,n,i)))}function Yl(t){return!!t?.type.startsWith("pointer")}function Na(t){return!!t?.type.startsWith("touch")}function t_(t){return/^(click|mouse)/.test(t?.type??"")}function Hi(t){return!!t?.type.startsWith("key")}function zN(t){return Hi(t)&&t.key==="Enter"}function UN(t){return Hi(t)&&t.key==="Escape"}function Ql(t){return Hi(t)&&(t.key==="Enter"||t.key===" ")}function n_(t){return t instanceof Node}function jN(t){return n_(t)&&t.nodeType===1}function HN(t){return n_(t)&&t.nodeType===11}function qN(){return document.createDocumentFragment()}function BN(t){return Ht?t:document.createComment(t)}function Z(t,e,n){if(t)if(!n&&n!==""&&n!==0)t.removeAttribute(e);else{let i=n===!0?"":n+"";t.getAttribute(e)!==i&&t.setAttribute(e,i)}else return}function lt(t,e,n){if(t)!n&&n!==0?t.style.removeProperty(e):t.style.setProperty(e,n+"");else return}function WN(t,e,n){t.classList[n?"add":"remove"](e)}function KN(t,e){let n=e?`slot[name="${e}"]`:"slot:not([name])",r=t.shadowRoot?.querySelector(n)?.assignedNodes({flatten:!0})??[];return Array.prototype.filter.call(r,s=>s.nodeType==1)}function GN(t){let e=t.firstChild,n=e.getAttribute("shadowroot");e.parentNode.attachShadow({mode:n}).appendChild(e.content),e.remove()}function YN(t){return yt(t)?t():t}function Vy(t){let e=t;for(;typeof e=="function";)e=e.call(this);return e}function vi(t){return{id:Symbol(),provide:t}}function Rt(t,e,n=Bl()){let i=!Le(e);RN(t.id,i?e:t.provide?.(),n)}function Ie(t){return qy(t.id)}function Tn(t){return!Le(qy(t.id))}function QN(t){let e={};for(let n of Object.keys(t)){let i=t[n];e[n]=D(i,i)}return e}function i_(t,e){return HT(()=>{Hl.$$=new Dp(t,Bl(),e);let n=new t;return Hl.$$.e=n,Hl.$$=null,n})}function ee(t,e,n){t[Ay]||(t[Ay]=new Set),t[Ay].add(e)}function Ae(t,e,n){t[Ny]||(t[Ny]=new Set),t[Ny].add(e)}function _s(t){return Ie(t)}function Da(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function XN(t){return Xl(t.replace(/([A-Z])/g," $1"))}function Up(t){return t.replace(/-./g,e=>e[1].toUpperCase())}function iS(t){return rS(t).replace(/\s/g,"")}function rS(t){return Xl(t.replace(/-./g,e=>" "+e[1].toUpperCase()))}function Xl(t){return t.charAt(0).toUpperCase()+t.slice(1)}function ZN(t){return t.charAt(0).toLowerCase()+t.slice(1)}function eD(t){return t.replace(JN,"")}function jp(t,...e){return ce.createElement(ws.Provider,{value:t},...e)}function Hp(){return ce.useContext(ws).current}function qp(t){let e=Hp();return ce.useMemo(()=>qy(t.id,e),[e])}function tD(){return aS}function nD(t,e){var n;return n=class extends aS{},n.F=t,n.T=e,n}function r_(t,e){typeof t=="function"?t(e):t&&(t.current=e)}function re(...t){return e=>t.forEach(n=>r_(n,e))}function iD(t,e){let n=ce.forwardRef((i,r)=>{let s=ce.useContext(ws),a=ce.useRef(null),o=ce.useRef();if(!o.current){let w=sD(),m=zT(t,w,i,s.current);w.e=m,o.current=w,a.current=m.scope}function l(){let w=o.current,m=s.current;if(window.cancelAnimationFrame(w.ea),w.ea=-1,w.e.$$.o){let f=zT(t,w,i,m);w.e=f,w.Q=!1,w.da=!1,a.current=f.scope}return w.a&&FT(w,w.a),w.da||(r_(r,w.e),w.da=!0),()=>Ip(w)}function c(w){let m=o.current;if(!m.da){m.a=w;return}window.cancelAnimationFrame(m.K),m.K=window.requestAnimationFrame(()=>{let f=o.current;f.K=-1,f.a!==w&&(Ip(f),w&&FT(f,w),f.a=w)})}ce.useEffect(()=>{let w=o.current;return window.cancelAnimationFrame(w.ea),w.ea=-1,function(){yt(i.children)&&(window.cancelAnimationFrame(w.K),w.K=-1,window.cancelAnimationFrame(w.E),w.E=-1,window.cancelAnimationFrame(w.ea),w.ea=window.requestAnimationFrame(()=>{w.ea=-1,Ip(w),w.e.$$.p(),w.e.$$[zp]=null,w.J={},w._={},a.current=null}))}},[]),ce.useEffect(Zn);let u=o.current,{children:d,...p}=i,h={},y=u.aa,v=Object.keys(p);u.J={};for(let w of[...y,...v])if(e.props.has(w))u.e.$props[w].set(v.includes(w)?p[w]:t.props?.[w]);else if(e.events?.has(w)||e.eventsRE?.test(w))u.J[w]=p[w];else if(e.domEvents?.has(w)||e.domEventsRE?.test(w)){let m=Da(w.slice(2));u._[m]=p[w],v.includes(w)?u.a&&!u.ca?.has(m)&&(u.ca||(u.ca=new Set),u.ca.add(m),u.a.addEventListener(m,u.ba)):(u.a?.removeEventListener(m,u.ba),u.ca?.delete(m))}else h[w]=p[w];return u.aa=v,jp(a,ce.createElement(rD,{effect:l}),yt(d)?d?.({...h,suppressHydrationWarning:!0,ref:c},u.e):d)});return n.displayName=t.name+"Bridge",n}function rD({effect:t}){return ce.useEffect(t,[]),null}function sD(){let t={a:null,aa:[],J:{},_:{},K:-1,E:-1,ea:-1,Q:!1,da:!1,ca:null,ba(e){let n=Le(e.detail)?[e]:[e.detail,e];t._[e.type]?.(...n)}};return t}function FT(t,e){if(!(t.a===e&&t.Q)){if(t.Q&&Ip(t),t._){t.ca||(t.ca=new Set);for(let n of Object.keys(t._))t.ca.has(n)||(e.addEventListener(n,t.ba),t.ca.add(n))}t.e.$$.x(e),t.E=window.requestAnimationFrame(()=>{t.e.$$.y(),t.E=-1}),t.Q=!0}}function Ip(t){if(t.Q&&(window.cancelAnimationFrame(t.E),t.E=-1,t.e.$$.s(),t.Q=!1,t.a&&t.ca)){for(let e of t.ca)t.a.removeEventListener(e,t.ba);t.ca.clear()}}function aD(t){let e=VT.get(t.type),n=Le(t.detail)?[t]:[t.detail,t];e||VT.set(t.type,e=`on${iS(t.type)}`),this.J[e]?.(...n)}function zT(t,e,n,i){let r=i_(t,{props:n,scope:i});return r.$$[zp]=aD.bind(e),r.$$.w(),r}function oS(t,e=!1){let n=typeof t;if(n!=="string")return!e&&n==="function"?oS(t()):e&&n==="boolean"?t+"":t;let i=e?'"':"<",r=e?""":"<",s=t.indexOf(i),a=t.indexOf("&");if(s<0&&a<0)return t;let o=0,l="";for(;s>=0&&a>=0;)s=0)do o=0);else for(;a>=0;)o(a.destroy(),null)))}return n.displayName=t.name+"Bridge",n}function Mr(t){return qp(t)}function pe(t,e){let[,n]=ce.useState();return ce.useEffect(()=>QT(()=>{t(),n({})}),[e??t]),t()}function Oa(t){return t?"true":"false"}function lS(t){let e=[];for(let n=0;n!e.includes(n)))}function qi(){let t,e;return{promise:new Promise((i,r)=>{t=i,e=r}),resolve:t,reject:e}}function _D(t,e,n){let i=new Promise((r,s)=>{let a=setTimeout(()=>{clearTimeout(a),s(n)},e)});return Promise.race([t,i])}function a_(t){return new Promise(e=>setTimeout(e,t))}function wD(t){return Ht?Promise.resolve():new Promise(e=>{window.requestAnimationFrame(n=>{t?.(n),e()})})}function Rr(t){if(Ht)return qt;let e=-1,n;function i(...r){n=r,!(e>=0)&&(e=window.requestAnimationFrame(()=>{t.apply(this,n),e=-1,n=void 0}))}return i}function o_(t,e){return Ht?Promise.resolve():new Promise(n=>{bD(i=>{t?.(i),n()},e)})}function l_(t){let[,e]=ce.useState(),n=ce.useRef(null);return n.current==null&&(n.current={state:{},$update:D({}),props:new Set}),ce.useEffect(()=>{let{state:i,$update:r,props:s}=n.current;return b(()=>{for(let a of s){let o=t[a]();i[a]=qe(o)?[...o]:o}r(),e({})})},[t]),ce.useMemo(()=>{let{state:i,$update:r,props:s}=n.current,a=!1;return s.clear(),new Proxy(i,{get(o,l){if(!s.has(l)&&l in t){s.add(l);let c=t[l]();i[l]=qe(c)?[...c]:c,a||(r.set({}),a=!0,queueMicrotask(()=>a=!1))}return i[l]},set(o,l,c){return l in t||(i[l]=c),!0}})},[t])}function X(t,e){return Ht?fD(t,{props:new Set(Object.keys(t.props||{}))}):iD(t,{props:new Set(Object.keys(t.props||{})),events:new Set(e?.events),eventsRE:e?.eventsRegex,domEvents:e?.domEvents,domEventsRE:e?.domEventsRegex})}var ce,Ht,on,Ap,Oy,Ct,Ra,En,an,Ma,Hy,CN,Ia,UT,ql,Op,Ky,ys,WT,Gy,b,XT,VN,ZT,j,Np,La,Ay,Ny,zp,nS,Dy,Dp,Hl,Mt,q,Xn,JN,ws,sS,aS,VT,oD,lD,uD,dD,Fy,zy,Uy,jy,hD,bD,bs,Lt=Ue(()=>{"use strict";"use client";ce=$(z(),1),Ht=typeof document>"u",on=Symbol(0),Ap=!1,Oy=!1,Ct=null,Ra=null,En=null,an=0,Ma=[],Hy={},CN=()=>{},Ia=0,UT=1,ql=2,Op=3;Ky=function(){this[on]=null,this.$ns=null,this.$ps=null,Ct&&Ct.append(this)},ys=Ky.prototype;ys.$cx=Hy;ys.$eh=null;ys.$c=null;ys.$d=null;ys.append=function(t){if(t[on]=this,t.$ps=this,this.$ns)if(t.$ns){let e=t.$ns;for(;e.$ns;)e=e.$ns;e.$ns=this.$ns,this.$ns.$ps=e}else t.$ns=this.$ns,this.$ns.$ps=t;this.$ns=t,t.$cx=t.$cx===Hy?this.$cx:{...this.$cx,...t.$cx},this.$eh&&(t.$eh=t.$eh?[...t.$eh,...this.$eh]:this.$eh)};ys.dispose=function(){Wl.call(this)};WT=function(e,n,i){Ky.call(this),this.$st=n?ql:Ia,this.$i=!1,this.$e=!1,this.$s=null,this.$o=null,this.$v=e,n&&(this.$c=n),i&&i.dirty&&(this.$ch=i.dirty)},Gy=WT.prototype;Object.setPrototypeOf(Gy,ys);Gy.$ch=IN;Gy.call=Wy;b=Ht?ON:QT;VN=Ht?class{}:Event,ZT=Symbol("DOM_EVENT"),j=class extends VN{constructor(e,...n){super(e,n[0]),this[XT]=!0,this.triggers=new Np,this.detail=n[0]?.detail;let i=n[0]?.trigger;i&&this.triggers.add(i)}get trigger(){return this.triggers.source}get originEvent(){return this.triggers.origin}get isOriginTrusted(){return this.triggers.origin?.isTrusted??!1}};XT=ZT;Np=class{constructor(){this.chain=[]}get source(){return this.chain[0]}get origin(){return this.chain[this.chain.length-1]}add(e){this.chain.push(e),Fp(e)&&this.chain.push(...e.triggers)}remove(e){return this.chain.splice(this.chain.indexOf(e),1)[0]}has(e){return this.chain.some(n=>n===e)}hasType(e){return!!this.findType(e)}findType(e){return this.chain.find(n=>n.type===e)}walk(e){for(let n of this.chain){let i=e(n);if(i)return[n,i]}}[Symbol.iterator](){return this.chain.values()}};La=class extends EventTarget{addEventListener(e,n,i){return super.addEventListener(e,n,i)}removeEventListener(e,n,i){return super.removeEventListener(e,n,i)}};Ay=Symbol(0),Ny=Symbol(0),zp=Symbol(0),Dy={},Dp=class{constructor(e,n,i){this[nS]=null,this.$el=D(null),this.a=null,this.d=null,this.f=null,this.g=null,this.e=null,this.o=!1,this.i=Dy,this.b=null,this.c=null,this.l=[],this.m=[],this.j=[],this.n=[],this.d=n,i?.scope&&i.scope.append(n);let r=e.state,s=e.props;if(r&&(this.h=r.create(),this.k=new Proxy(this.h,{get:(a,o)=>this.h[o]()}),Rt(r,this.h)),s&&(this.i=QN(s),i?.props))for(let a of Object.keys(i.props))this.i[a]?.set(i.props[a]);G(this.p.bind(this))}w(){et(()=>{for(let e of this.l)e()},this.d)}x(e){this.a||(this.a=e,this.$el.set(e),et(()=>{this.f=$t(),et(()=>{for(let n of this.m)n(this.a);this.q(),this.r()},this.f)},this.d),e.dispatchEvent(new Event("attached")))}s(){this.f?.dispose(),this.f=null,this.g=null,this.a=null,this.$el.set(null)}y(){!this.a||!this.f||!this.j.length||et(()=>{this.g=$t(),et(()=>{for(let e of this.j)e(this.a)},this.g)},this.f)}z(){this.g?.dispose(),this.g=null}p(){if(this.o)return;this.o=!0,et(()=>{for(let n of this.n)n(this.a)},this.d);let e=this.a;this.s(),this.d.dispose(),this.l.length=0,this.m.length=0,this.j.length=0,this.n.length=0,this.e=null,this.b=null,this.c=null,this.i=Dy,this.d=null,this.k=Dy,this.h=null,e&&delete e.$}t(e){e.onSetup&&this.l.push(e.onSetup.bind(e)),e.onAttach&&this.m.push(e.onAttach.bind(e)),e.onConnect&&this.j.push(e.onConnect.bind(e)),e.onDestroy&&this.n.push(e.onDestroy.bind(e))}q(){if(this.b)for(let e of Object.keys(this.b))Ht?Z(this.a,e,Vy.call(this.e,this.b[e])):yt(this.b[e])?b(this.u.bind(this,e)):Z(this.a,e,this.b[e])}r(){if(this.c)for(let e of Object.keys(this.c))Ht?lt(this.a,e,Vy.call(this.e,this.c[e])):yt(this.c[e])?b(this.v.bind(this,e)):lt(this.a,e,this.c[e])}u(e){Z(this.a,e,this.b[e].call(this.e))}v(e){lt(this.a,e,this.c[e].call(this.e))}};nS=zp;Hl={$$:null};Mt=class extends EventTarget{constructor(){super(),Hl.$$&&this.attach(Hl)}get el(){return this.$$.a}get $el(){return this.$$.$el()}get scope(){return this.$$.d}get attachScope(){return this.$$.f}get connectScope(){return this.$$.g}get $props(){return this.$$.i}get $state(){return this.$$.h}get state(){return this.$$.k}attach({$$:e}){return this.$$=e,e.t(this),this}addEventListener(e,n,i){this.listen(e,n,i)}removeEventListener(e,n,i){this.el?.removeEventListener(e,n,i)}setAttributes(e){this.$$.b||(this.$$.b={}),Object.assign(this.$$.b,e)}setStyles(e){this.$$.c||(this.$$.c={}),Object.assign(this.$$.c,e)}setCSSVars(e){this.setStyles(e)}createEvent(e,...n){return new j(e,n[0])}dispatch(e,...n){if(Ht||!this.el)return!1;let i=e instanceof Event?e:new j(e,n[0]);return Object.defineProperty(i,"target",{get:()=>this.$$.e}),Aa(()=>(this.$$[zp]?.(i),this.el.dispatchEvent(i)))}dispatchEvent(e){return this.dispatch(e)}listen(e,n,i){return Ht||!this.el?qt:S(this.el,e,n,i)}},q=class extends Mt{subscribe(e){return et(()=>b(()=>e(this.state)),this.$$.d)}destroy(){this.$$.p()}};Xn=class{constructor(e){this.id=Symbol(0),this.record=e,this.A=Object.getOwnPropertyDescriptors(e)}create(){let e={},n=new Proxy(e,{get:(i,r)=>e[r]()});for(let i of Object.keys(this.record)){let r=this.A[i].get;e[i]=r?mi(r.bind(n)):D(this.record[i])}return e}reset(e,n){for(let i of Object.keys(e))!this.A[i].get&&(!n||n(i))&&e[i].set(this.record[i])}};JN=/;\s*$/;ws=ce.createContext({current:null});ws.displayName="Scope";sS=class extends ce.Component{constructor(e,n){super(e),this.d={current:$t()},n&&n.append(this.d.current);let i=this.constructor;i.F&&Rt(i.F,i.T?.(),this.d.current)}render(){return jp(this.d,this.props?.children)}};sS.contextType=ws;aS=sS;VT=new Map;oD=Symbol(0),lD=/\s+/;uD=/\s*:\s*/,dD=/\s*;\s*/;Fy=class{constructor(e){this.keepAlive=!1,this.forwardKeepAlive=!0,this.attributes=new zy,this.style=new Uy,this.classList=new jy,this.$=e}get $props(){return this.$.$$.i}get $state(){return this.$.$$.h}get state(){return this.$.state}setup(){let e=this.$.$$;et(()=>{this.hasAttribute("class")&&cD(this.classList.tokens,this.getAttribute("class")),this.hasAttribute("style")&&pD(this.style.tokens,this.getAttribute("style")),e.w(),e.x(this),this.classList.length>0&&this.setAttribute("class",this.classList.toString()),this.style.length>0&&this.setAttribute("style",this.style.toString()),this.keepAlive&&this.setAttribute("keep-alive","")},e.d)}getAttribute(e){return this.attributes.getAttribute(e)}setAttribute(e,n){this.attributes.setAttribute(e,n)}hasAttribute(e){return this.attributes.hasAttribute(e)}removeAttribute(e){return this.attributes.removeAttribute(e)}[oD](){}addEventListener(){}removeEventListener(){}dispatchEvent(){return!1}subscribe(){return qt}destroy(){this.$.destroy()}},zy=class{constructor(){this.Z=new Map}get length(){return this.Z.size}get tokens(){return this.Z}getAttribute(e){return this.Z.get(e)??null}hasAttribute(e){return this.Z.has(e)}setAttribute(e,n){this.Z.set(e,n+"")}removeAttribute(e){this.Z.delete(e)}toString(){if(this.Z.size===0)return"";let e="";for(let[n,i]of this.Z)e+=` ${n}="${oS(i,!0)}"`;return e}},Uy=class{constructor(){this.Z=new Map}get length(){return this.Z.size}get tokens(){return this.Z}getPropertyValue(e){return this.Z.get(e)??""}setProperty(e,n){this.Z.set(e,n??"")}removeProperty(e){let n=this.Z.get(e);return this.Z.delete(e),n??""}toString(){if(this.Z.size===0)return"";let e="";for(let[n,i]of this.Z)e+=`${n}: ${i};`;return e}},jy=class{constructor(){this.Z=new Set}get length(){return this.Z.size}get tokens(){return this.Z}add(...e){for(let n of e)this.Z.add(n)}contains(e){return this.Z.has(e)}remove(e){this.Z.delete(e)}replace(e,n){return this.Z.has(e)?(this.Z.delete(e),this.Z.add(n),!0):!1}toggle(e,n){return n!==!0&&(this.Z.has(e)||n===!1)?(this.Z.delete(e),!1):(this.Z.add(e),!0)}toString(){return Array.from(this.Z).join(" ")}},hD={acceptcharset:"acceptCharset","accept-charset":"acceptCharset",accesskey:"accessKey",allowfullscreen:"allowFullScreen",autocapitalize:"autoCapitalize",autocomplete:"autoComplete",autocorrect:"autoCorrect",autofocus:"autoFocus",autoplay:"autoPlay",autosave:"autoSave",cellpadding:"cellPadding",cellspacing:"cellSpacing",charset:"charSet",class:"className",classid:"classID",classname:"className",colspan:"colSpan",contenteditable:"contentEditable",contextmenu:"contextMenu",controlslist:"controlsList",crossorigin:"crossOrigin",dangerouslysetinnerhtml:"dangerouslySetInnerHTML",datetime:"dateTime",defaultchecked:"defaultChecked",defaultvalue:"defaultValue",disablepictureinpicture:"disablePictureInPicture",disableremoteplayback:"disableRemotePlayback",enctype:"encType",enterkeyhint:"enterKeyHint",fetchpriority:"fetchPriority",for:"htmlFor",formmethod:"formMethod",formaction:"formAction",formenctype:"formEncType",formnovalidate:"formNoValidate",formtarget:"formTarget",frameborder:"frameBorder",hreflang:"hrefLang",htmlfor:"htmlFor",httpequiv:"httpEquiv","http-equiv":"httpEquiv",imagesizes:"imageSizes",imagesrcset:"imageSrcSet",innerhtml:"innerHTML",inputmode:"inputMode",itemid:"itemID",itemprop:"itemProp",itemref:"itemRef",itemscope:"itemScope",itemtype:"itemType",keyparams:"keyParams",keytype:"keyType",marginwidth:"marginWidth",marginheight:"marginHeight",maxlength:"maxLength",mediagroup:"mediaGroup",minlength:"minLength",nomodule:"noModule",novalidate:"noValidate",playsinline:"playsInline",radiogroup:"radioGroup",readonly:"readOnly",referrerpolicy:"referrerPolicy",rowspan:"rowSpan",spellcheck:"spellCheck",srcdoc:"srcDoc",srclang:"srcLang",srcset:"srcSet",tabindex:"tabIndex",usemap:"useMap"};bD=Ht?qt:typeof window<"u"?"requestIdleCallback"in window?window.requestIdleCallback:t=>window.setTimeout(t,1):qt;bs=Object.freeze({__proto__:null,Component:q,DOMEvent:j,EventTriggers:Np,EventsTarget:La,Instance:Dp,ReactScopeContext:ws,State:Xn,ViewController:Mt,WithScope:jp,animationFrameThrottle:Rr,appendTriggerEvent:tS,ariaBool:Oa,attachDeclarativeShadowDOM:GN,camelToKebabCase:Da,camelToTitleCase:XN,composeRefs:re,computed:mi,createComment:BN,createComponent:i_,createContext:vi,createDisposalBin:Zl,createFragment:qN,createReactComponent:X,createReactContextProvider:nD,createReactScopeProvider:tD,createRegex:NN,createScope:$t,deferredPromise:qi,effect:b,findTriggerEvent:e_,flattenArray:lS,getOriginEvent:FN,getScope:Bl,getSlottedChildren:KN,hasProvidedContext:Tn,hasTriggerEvent:eS,isArray:qe,isBoolean:Jy,isDOMElement:jN,isDOMEvent:Fp,isDOMFragment:HN,isDOMNode:n_,isFunction:yt,isKeyboardClick:Ql,isKeyboardEvent:Hi,isMouseEvent:t_,isNil:Zy,isNull:gi,isNumber:Be,isObject:Gl,isPointerEvent:Yl,isReadSignal:YT,isString:F,isTouchEvent:Na,isUndefined:Le,isWindow:DN,isWriteSignal:Xy,kebabToCamelCase:Up,kebabToPascalCase:iS,kebabToTitleCase:rS,keysOf:Jl,listenEvent:S,lowercaseFirstLetter:ZN,mergeProperties:vD,method:Ae,noop:qt,omit:yD,onDispose:G,onError:LN,peek:C,pick:cS,prop:ee,provideContext:Rt,readonly:AN,root:HT,run:mD,runAll:gD,scoped:et,setAttribute:Z,setRef:r_,setStyle:lt,signal:D,tick:Zn,timedPromise:_D,toggleClass:WN,trimTrailingSemicolon:eD,untrack:Aa,unwrap:YN,unwrapDeep:Vy,uppercaseFirstChar:Xl,useContext:Ie,useDisposalBin:s_,useReactContext:qp,useReactScope:Hp,useSignal:pe,useSignalRecord:l_,useState:_s,useStateContext:Mr,waitAnimationFrame:wD,waitIdlePeriod:o_,waitTimeout:a_,walkTriggerEventChain:JT,wasEnterKeyPressed:zN,wasEscapeKeyPressed:UN})});var uS={};xt(uS,{SRTParser:()=>Bp,default:()=>ED});function ED(){return new Bp}var xD,kD,Bp,dS=Ue(()=>{"use strict";ec();xD=/,/g,kD="-->",Bp=class extends Fa{parse(e,n){if(e==="")this.a&&(this.j.push(this.a),this.f.onCue?.(this.a),this.a=null),this.c=Va.None;else if(this.c===Va.Cue)this.a.text+=(this.a.text?` +`:"")+e;else if(e.includes(kD)){let i=this.o(e,n);i&&(this.a=new Bi(i[0],i[1],i[2].join(" ")),this.a.id=this.l,this.c=Va.Cue)}this.l=e}o(e,n){return super.o(e.replace(xD,"."),n)}}});var c_={};xt(c_,{ParseErrorBuilder:()=>TD});var TD,u_=Ue(()=>{"use strict";ec();TD={p(){return new Bt({code:Sn.BadSignature,reason:"missing WEBVTT file header",line:1})},q(t,e){return new Bt({code:Sn.BadTimestamp,reason:`cue start timestamp \`${t}\` is invalid on line ${e}`,line:e})},r(t,e){return new Bt({code:Sn.BadTimestamp,reason:`cue end timestamp \`${t}\` is invalid on line ${e}`,line:e})},s(t,e,n){return new Bt({code:Sn.BadTimestamp,reason:`cue end timestamp \`${e}\` is greater than start \`${t}\` on line ${n}`,line:n})},w(t,e,n){return new Bt({code:Sn.BadSettingValue,reason:`invalid value for cue setting \`${t}\` on line ${n} (value: ${e})`,line:n})},v(t,e,n){return new Bt({code:Sn.UnknownSetting,reason:`unknown cue setting \`${t}\` on line ${n} (value: ${e})`,line:n})},u(t,e,n){return new Bt({code:Sn.BadSettingValue,reason:`invalid value for region setting \`${t}\` on line ${n} (value: ${e})`,line:n})},t(t,e,n){return new Bt({code:Sn.UnknownSetting,reason:`unknown region setting \`${t}\` on line ${n} (value: ${e})`,line:n})},T(t,e){return new Bt({code:Sn.BadFormat,reason:`format missing for \`${t}\` block on line ${e}`,line:e})}}});var vS={};xt(vS,{SSAParser:()=>Gp,default:()=>SD});function p_(t){let e=parseInt(t.replace("&H",""),16);if(e>=0){let i=(e>>24&255^255)/255,r=e>>16&255,s=e>>8&255;return"rgba("+[e&255,s,r,i].join(",")+")"}return null}function h_(t,e,n){let i=Math.ceil(2*Math.PI*t),r="";for(let s=0;s{"use strict";ec();Wp=/^Format:[\s\t]*/,pS=/^Style:[\s\t]*/,hS=/^Dialogue:[\s\t]*/,Kp=/[\s\t]*,[\s\t]*/,fS=/\{[^}]+\}/g,mS=/\\N/g,gS=/^\[(.*)[\s\t]?Styles\]$/,d_=/^\[(.*)[\s\t]?Events\]$/,Gp=class{constructor(){_(this,"f");_(this,"O",0);_(this,"a",null);_(this,"j",[]);_(this,"k",[]);_(this,"N",null);_(this,"d");_(this,"P",{})}async init(e){this.f=e,e.errors&&(this.d=(await Promise.resolve().then(()=>(u_(),c_))).ParseErrorBuilder)}parse(e,n){if(this.O)switch(this.O){case 1:if(e==="")this.O=0;else if(pS.test(e))if(this.N){let i=e.replace(pS,"").split(Kp);this.S(i)}else this.e(this.d?.T("Style",n));else Wp.test(e)?this.N=e.replace(Wp,"").split(Kp):d_.test(e)&&(this.N=null,this.O=2);break;case 2:if(e==="")this.Q();else if(hS.test(e))if(this.Q(),this.N){let i=e.replace(hS,"").split(Kp),r=this.U(i,n);r&&(this.a=r)}else this.e(this.d?.T("Dialogue",n));else this.a?this.a.text+=` +`+e.replace(fS,"").replace(mS,` +`):Wp.test(e)?this.N=e.replace(Wp,"").split(Kp):gS.test(e)?(this.N=null,this.O=1):d_.test(e)&&(this.N=null)}else e===""||(gS.test(e)?(this.N=null,this.O=1):d_.test(e)&&(this.N=null,this.O=2))}done(){return{metadata:{},cues:this.j,regions:[],errors:this.k}}Q(){this.a&&(this.j.push(this.a),this.f.onCue?.(this.a),this.a=null)}S(e){let n="Default",i={},r,s="center",a="bottom",o,l=1.2,c,u,d=3,p=[];for(let h=0;h=4&&(a=f>=7?"top":"center"),f%3){case 1:s="start";break;case 2:s="center";break;case 3:s="end";break}}}if(i.R=a,i["--cue-white-space"]="normal",i["--cue-line-height"]="normal",i["--cue-text-align"]=s,a==="center"?(i["--cue-top"]="50%",p.push("translateY(-50%)")):i[`--cue-${a}`]=(o||0)+"px",d===1&&(i["--cue-padding-y"]="0"),(d===1||u)&&(i["--cue-bg-color"]=d===1?"none":u),d===3&&c&&(i["--cue-outline"]=`${r}px solid ${c}`),d===1&&typeof r=="number"){let h=u??"#000";i["--cue-text-shadow"]=[c&&h_(r*1.2,l*1.2,c),c?h_(r*(r/2),l*(r/2),h):h_(r,l,h)].filter(Boolean).join(", ")}p.length&&(i["--cue-transform"]=p.join(" ")),this.P[n]=i}U(e,n){let i=this.V(e),r=this.o(i.Start,i.End,n);if(!r)return;let s=new Bi(r[0],r[1],""),a={...this.P[i.Style]||{}},o=i.Name?``:"",l=a.R,c=i.MarginL&&parseFloat(i.MarginL),u=i.MarginR&&parseFloat(i.MarginR),d=i.MarginV&&parseFloat(i.MarginV);return c&&(a["--cue-width"]="auto",a["--cue-left"]=c+"px"),u&&(a["--cue-width"]="auto",a["--cue-right"]=u+"px"),d&&l!=="center"&&(a[`--cue-${l}`]=d+"px"),s.text=o+e.slice(this.N.length-1).join(", ").replace(fS,"").replace(mS,` +`),delete a.R,Object.keys(a).length&&(s.style=a),s}V(e){let n={};for(let i=0;ir)return[r,s];r===null&&this.e(this.d?.q(e,i)),s===null&&this.e(this.d?.r(n,i)),r!=null&&s!==null&&s>r&&this.e(this.d?.s(r,s,i))}e(e){if(e){if(this.k.push(e),this.f.strict)throw this.f.cancel(),e;this.f.onError?.(e)}}}});async function ES(t,e){let n=new ReadableStream({start(i){let r=t.split(kS);for(let s of r)i.enqueue(s);i.close()}});return Zp(n,e)}async function Zp(t,e){let n=e?.type??"vtt",i;if(typeof n=="string")switch(n){case"srt":i=(await Promise.resolve().then(()=>(dS(),uS))).default;break;case"ssa":case"ass":i=(await Promise.resolve().then(()=>(yS(),vS))).default;break;default:i=(await Promise.resolve().then(function(){return qD})).default}else i=n;let r,s=t.getReader(),a=i(),o=!!e?.strict||!!e?.errors;await a.init({strict:!1,...e,errors:o,type:n,cancel(){s.cancel(),r=a.done(!0)}});let l=1;for(;;){let{value:c,done:u}=await s.read();if(u){a.parse("",l),r=a.done(!1);break}a.parse(c,l),l++}return r}async function TS(t,e){let n=await t;if(!n.ok||!n.body)return{metadata:{},cues:[],regions:[],errors:[void 0]};let i=n.headers.get("content-type")||"",r=i.match(/text\/(.*?)(?:;|$)/)?.[1],s=i.match(/charset=(.*?)(?:;|$)/)?.[1];return v_(n.body,{type:r,encoding:s,...e})}async function v_(t,{encoding:e="utf-8",...n}={}){let i=t.pipeThrough(new m_(e));return Zp(i,n)}function $D(t){let e=parseInt(t,10);return Number.isNaN(e)?null:e}function nc(t){let e=parseInt(t.replace(CD,""),10);return!Number.isNaN(e)&&e>=0&&e<=100?e:null}function wS(t){if(!t.includes(_S))return null;let[e,n]=t.split(_S).map(nc);return e!==null&&n!==null?[e,n]:null}function MD(t){let e=parseFloat(t);return Number.isNaN(e)?null:e}function Wi(t){let e=t.match(jD);if(!e)return null;let n=e[1]?parseInt(e[1],10):0,i=parseInt(e[2],10),r=parseInt(e[3],10),s=e[4]?parseInt(e[4].padEnd(3,"0"),10):0,a=n*3600+i*60+r+s/1e3;return n<0||i<0||r<0||s<0||i>59||r>59?null:a}function HD(){return new Fa}function __(t){let e="",n=1,i=[],r=[],s;for(let c=0;c":a(),n=1;break;default:!e&&BD.test(u)&&(n=6),e+=u;break}break;case 3:switch(u){case" ":case" ":case` +`:o(),s&&s.class?.trim(),n=4;break;case".":o();break;case">":o(),s&&s.class?.trim(),n=1;break;default:e+=u}break;case 4:u===">"?(e=e.replace(WD," "),s?.type==="v"?s.voice=f_(e):s?.type==="lang"&&(s.lang=f_(e)),e="",n=1):e+=u;break;case 5:u===">"&&(e="",s=r.pop(),n=1);break;case 6:if(u===">"){let d=Wi(e);d!==null&&d>=t.startTime&&d<=t.endTime&&(e="timestamp",a(),s.time=d),e="",n=1}else e+=u;break}}function a(){if(QD.has(e)){let c=s;s=XD(e),c?(r[r.length-1]!==c&&r.push(c),c.children.push(s)):i.push(s)}e="",n=1}function o(){if(s&&e){let c=e.replace("bg_","");YD.has(c)?s[e.startsWith("bg_")?"bgColor":"color"]=c:s.class=s.class?s.class+" "+e:e}e=""}function l(){if(!e)return;let c={type:"text",data:f_(e)};s?s.children.push(c):i.push(c),e=""}return n===1&&l(),i}function XD(t){return{tagName:SS[t],type:t,children:[]}}function f_(t){return t.replace(GD,e=>KD[e]||"'")}function It(t,e,n){t.style.setProperty(`--${e}`,n+"")}function Lr(t,e,n=!0){t.setAttribute(`data-${e}`,n===!0?"":n+"")}function Yp(t,e){t.setAttribute("data-part",e)}function ZD(t){return parseFloat(getComputedStyle(t).lineHeight)||0}function PS(t){if(y_)throw Error("[media-captions] called `createVTTCueTemplate` on the server - use `renderVTTCueString`");let e=document.createElement("template");return e.innerHTML=Jp(t),{cue:t,content:e.content}}function Jp(t,e=0){return eh(__(t),e)}function eh(t,e=0){let n,i="";for(let r of t)if(r.type==="text")i+=r.data;else{let s=r.type==="timestamp";n={},n.class=r.class,n.title=r.type==="v"&&r.voice,n.lang=r.type==="lang"&&r.lang,n["data-part"]=r.type==="v"&&"voice",s&&(n["data-part"]="timed",n["data-time"]=r.time,n["data-future"]=r.time>e,n["data-past"]=r.timeo[1]).map(o=>`${o[0]}="${o[1]===!0?"":o[1]}"`).join(" ");i+=`<${r.tagName}${a?" "+a:""}>${eh(r.children)}`}return i}function w_(t,e){if(!y_)for(let n of t.querySelectorAll('[data-part="timed"]')){let i=Number(n.getAttribute("data-time"));Number.isNaN(i)||(i>e?Lr(n,"future"):n.removeAttribute("data-future"),i=e.left&&t.top<=e.bottom&&t.bottom>=e.top}function t2(t,e){for(let n=0;n=0&&e.bottom<=t.height&&e.left>=0&&e.right<=t.width}function n2(t,e,n){switch(n){case"+x":return e.left<0;case"-x":return e.right>t.width;case"+y":return e.top<0;case"-y":return e.bottom>t.height}}function i2(t,e){let n=Math.max(0,Math.min(t.width,e.right)-Math.max(0,e.left)),i=Math.max(0,Math.min(t.height,e.bottom)-Math.max(0,e.top));return n*i/(t.height*t.width)}function x_(t,e){return{top:e.top/t.height,left:e.left/t.width,right:(t.width-e.right)/t.width,bottom:(t.height-e.bottom)/t.height}}function CS(t,e){return e.top=e.top*t.height,e.left=e.left*t.width,e.right=t.width-e.right*t.width,e.bottom=t.height-e.bottom*t.height,e}function MS(t,e,n,i){let r=x_(e,n);for(let s of $S)It(t,`${i}-${s}`,r[s]*100+"%")}function RS(t,e,n,i){let r=1,s,a={...e};for(let o=0;ol&&(s={...e},r=l),e={...a}}return s||a}function r2(t,e,n,i){let r=n.firstElementChild,s=o2(e),a,o=[];if(n[Ir]||(n[Ir]=s2(t,n)),a=CS(t,{...n[Ir]}),n[ic])o=[n[ic]==="top"?"+y":"-y","+x","-x"];else if(e.snapToLines){let l;switch(e.vertical){case"":o=["+y","-y"],l="height";break;case"rl":o=["+x","-x"],l="width";break;case"lr":o=["-x","+x"],l="width";break}let c=ZD(r),u=c*Math.round(s),d=t[l]+c,p=o[0];Math.abs(u)>d&&(u=u<0?-1:1,u*=Math.ceil(d/c)*c),s<0&&(u+=e.vertical===""?t.height:t.width,o=o.reverse()),Qp(a,p,u)}else{let l=e.vertical==="",c=l?"+y":"+x",u=l?a.height:a.width;Qp(a,c,(l?t.height:t.width)*s/100),Qp(a,c,e.lineAlign==="center"?u/2:e.lineAlign==="end"?u:0),o=l?["-y","+y","-x","+x"]:["-x","+x","-y","+y"]}return a=RS(t,a,i,o),MS(n,t,a,"cue"),a}function s2(t,e){let n=b_(e),i=a2(e);if(e[ic]=!1,i.top&&(n.top=i.top,n.bottom=i.top+n.height,e[ic]="top"),i.bottom){let r=t.height-i.bottom;n.top=r-n.height,n.bottom=r,e[ic]="bottom"}return i.left&&(n.left=i.left),i.right&&(n.right=t.width-i.right),x_(t,n)}function a2(t){let e={};for(let n of $S)e[n]=parseFloat(t.style.getPropertyValue(`--cue-${n}`));return e}function o2(t){return t.line==="auto"?t.snapToLines?-1:100:t.line}function l2(t){if(t.position==="auto")switch(t.align){case"start":case"left":return 0;case"right":case"end":return 100;default:return 50}return t.position}function c2(t,e){if(t.positionAlign==="auto")switch(t.align){case"start":return e==="ltr"?"line-left":"line-right";case"end":return e==="ltr"?"line-right":"line-left";case"center":return"center";default:return`line-${t.align}`}return t.positionAlign}function d2(t,e,n,i){let r=Array.from(n.querySelectorAll('[data-part="cue-display"]')),s=0,a=Math.max(0,r.length-e.lines);for(let l=r.length-1;l>=a;l--)s+=r[l].offsetHeight;It(n,"region-height",s+"px"),n[Ir]||(n[Ir]=x_(t,b_(n)));let o={...n[Ir]};return o=CS(t,o),o.width=n.clientWidth,o.height=s,o.right=o.left+o.width,o.bottom=o.top+s,o=RS(t,o,i,u2),MS(n,t,o,"region"),o}var Sn,Bt,kS,m_,g_,rc,y_,PD,Bi,sc,_S,CD,RD,bS,LD,za,ID,AD,ND,DD,tc,OD,VD,FD,zD,UD,jD,Va,Fa,qD,BD,WD,SS,KD,GD,YD,QD,Ir,$S,ic,u2,Xp,ec=Ue(()=>{"use strict";Sn={LoadFail:0,BadSignature:1,BadTimestamp:2,BadSettingValue:3,BadFormat:4,UnknownSetting:5},Bt=class extends Error{constructor(n){super(n.reason);_(this,"code");_(this,"line");this.code=n.code,this.line=n.line}},kS=/\r?\n|\r/gm,m_=class{constructor(e){_(this,"writable");_(this,"readable");let n=new g_(e);this.writable=new WritableStream({write(i){n.transform(i)},close(){n.close()}}),this.readable=new ReadableStream({start(i){n.onLine=r=>i.enqueue(r),n.onClose=()=>i.close()}})}},g_=class{constructor(e){_(this,"x","");_(this,"y");_(this,"onLine");_(this,"onClose");this.y=new TextDecoder(e)}transform(e){this.x+=this.y.decode(e,{stream:!0});let n=this.x.split(kS);this.x=n.pop()||"";for(let i=0;i"u",PD=y_?rc:window.VTTCue,Bi=class extends PD{constructor(){super(...arguments);_(this,"region",null);_(this,"vertical","");_(this,"snapToLines",!0);_(this,"line","auto");_(this,"lineAlign","start");_(this,"position","auto");_(this,"positionAlign","auto");_(this,"size",100);_(this,"align","center");_(this,"style")}},sc=class{constructor(){_(this,"id","");_(this,"width",100);_(this,"lines",3);_(this,"regionAnchorX",0);_(this,"regionAnchorY",100);_(this,"viewportAnchorX",0);_(this,"viewportAnchorY",100);_(this,"scroll","")}},_S=",",CD="%";RD="WEBVTT",bS=",",LD="%",za=/[:=]/,ID=/^[\s\t]*(region|vertical|line|position|size|align)[:=]/,AD="NOTE",ND="REGION",DD=/^REGION:?[\s\t]+/,tc=/[\s\t]+/,OD="-->",VD=/[\s\t]*-->[\s\t]+/,FD=/start|center|end|left|right/,zD=/start|center|end/,UD=/line-(?:left|right)|center|auto/,jD=/^(?:(\d{1,2}):)?(\d{2}):(\d{2})(?:\.(\d{1,3}))?$/,Va=(t=>(t[t.None=0]="None",t[t.Header=1]="Header",t[t.Cue=2]="Cue",t[t.Region=3]="Region",t[t.Note=4]="Note",t))(Va||{}),Fa=class{constructor(){_(this,"f");_(this,"c",0);_(this,"g",{});_(this,"h",{});_(this,"j",[]);_(this,"a",null);_(this,"b",null);_(this,"k",[]);_(this,"d");_(this,"l","")}async init(e){this.f=e,e.strict&&(this.c=1),e.errors&&(this.d=(await Promise.resolve().then(()=>(u_(),c_))).ParseErrorBuilder)}parse(e,n){if(e==="")this.a?(this.j.push(this.a),this.f.onCue?.(this.a),this.a=null):this.b?(this.h[this.b.id]=this.b,this.f.onRegion?.(this.b),this.b=null):this.c===1&&(this.i(e,n),this.f.onHeaderMetadata?.(this.g)),this.c=0;else if(this.c)switch(this.c){case 1:this.i(e,n);break;case 2:if(this.a){let i=this.a.text.length>0;!i&&ID.test(e)?this.m(e.split(tc),n):this.a.text+=(i?` +`:"")+e}break;case 3:this.n(e.split(tc),n);break}else if(e.startsWith(AD))this.c=4;else if(e.startsWith(ND))this.c=3,this.b=new sc,this.n(e.replace(DD,"").split(tc),n);else if(e.includes(OD)){let i=this.o(e,n);i&&(this.a=new Bi(i[0],i[1],""),this.a.id=this.l,this.m(i[2],n)),this.c=2}else n===1&&this.i(e,n);this.l=e}done(){return{metadata:this.g,cues:this.j,regions:Object.values(this.h),errors:this.k}}i(e,n){if(n>1){if(za.test(e)){let[i,r]=e.split(za);i&&(this.g[i]=(r||"").replace(tc,""))}}else e.startsWith(RD)?this.c=1:this.e(this.d?.p())}o(e,n){let[i,r=""]=e.split(VD),[s,...a]=r.split(tc),o=Wi(i),l=Wi(s);if(o!==null&&l!==null&&l>o)return[o,l,a];o===null&&this.e(this.d?.q(i,n)),l===null&&this.e(this.d?.r(s,n)),o!=null&&l!==null&&l>o&&this.e(this.d?.s(o,l,n))}n(e,n){let i;for(let r=0;r",""":'"',"'":"'"," ":"\xA0","‎":"\u200E","‏":"\u200F"},GD=/&(?:amp|lt|gt|quot|#(0+)?39|nbsp|lrm|rlm);/g,YD=new Set(["white","lime","cyan","red","yellow","magenta","blue","black"]),QD=new Set(Object.keys(SS));Ir=Symbol(0);$S=["top","left","right","bottom"];ic=Symbol(0);u2=["-y","+y","-x","+x"];Xp=class{constructor(e,n){_(this,"overlay");_(this,"z");_(this,"A",0);_(this,"C","ltr");_(this,"B",[]);_(this,"D",!1);_(this,"E");_(this,"h",new Map);_(this,"j",new Map);_(this,"K",JD(()=>{this.D=!1,this.G();for(let e of this.h.values())e[Ir]=null;for(let e of this.j.values())e&&(e[Ir]=null);this.H(!0)},50));this.overlay=e,this.dir=n?.dir??"ltr",e.setAttribute("translate","yes"),e.setAttribute("aria-live","off"),e.setAttribute("aria-atomic","true"),Yp(e,"captions"),this.G(),this.E=new ResizeObserver(this.I.bind(this)),this.E.observe(e)}get dir(){return this.C}set dir(e){this.C=e,Lr(this.overlay,"dir",e)}get currentTime(){return this.A}set currentTime(e){this.A=e,this.update()}changeTrack({regions:e,cues:n}){this.reset(),this.J(e);for(let i of n)this.j.set(i,null);this.update()}addCue(e){this.j.set(e,null),this.update()}removeCue(e){this.j.delete(e),this.update()}update(e=!1){this.H(e)}reset(){this.j.clear(),this.h.clear(),this.B=[],this.overlay.textContent=""}destroy(){this.reset(),this.E.disconnect()}I(){this.D=!0,this.K()}G(){this.z=b_(this.overlay),It(this.overlay,"overlay-width",this.z.width+"px"),It(this.overlay,"overlay-height",this.z.height+"px")}H(e=!1){if(!this.j.size||this.D)return;let n,i=[...this.j.keys()].filter(s=>this.A>=s.startTime&&this.A<=s.endTime).sort((s,a)=>s.startTime!==a.startTime?s.startTime-a.startTime:s.endTime-a.endTime),r=i.map(s=>s.region);for(let s=0;sLr(o,"active")),e=!0),a.isConnected||((o||this.overlay).append(a),e=!0)}if(e){let s=[],a=new Set;for(let o=i.length-1;o>=0;o--){if(n=i[o],a.has(n.region||n))continue;let l=this.F(n),c=l?this.h.get(n.region.id):this.j.get(n);l?s.push(d2(this.z,n.region,c,s)):s.push(r2(this.z,n,c,s)),a.add(l?n.region:n)}}w_(this.overlay,this.A),this.B=i}J(e){if(e)for(let n of e){let i=this.M(n);this.h.set(n.id,i),this.overlay.append(i)}}M(e){let n=document.createElement("div");return Yp(n,"region"),Lr(n,"id",e.id),Lr(n,"scroll",e.scroll),It(n,"region-width",e.width+"%"),It(n,"region-anchor-x",e.regionAnchorX),It(n,"region-anchor-y",e.regionAnchorY),It(n,"region-viewport-anchor-x",e.viewportAnchorX),It(n,"region-viewport-anchor-y",e.viewportAnchorY),It(n,"region-lines",e.lines),n}L(e){let n=document.createElement("div"),i=l2(e),r=c2(e,this.C);if(Yp(n,"cue-display"),e.vertical!==""&&Lr(n,"vertical"),It(n,"cue-text-align",e.align),e.style)for(let a of Object.keys(e.style))n.style.setProperty(a,e.style[a]);if(this.F(e))It(n,"cue-offset",`${i-(r==="line-right"?100:r==="center"?50:0)}%`);else if(It(n,"cue-writing-mode",e.vertical===""?"horizontal-tb":e.vertical==="lr"?"vertical-lr":"vertical-rl"),!e.style?.["--cue-width"]){let a=i;r==="line-left"?a=100-i:r==="center"&&i<=50?a=i*2:r==="center"&&i>50&&(a=(100-i)*2);let o=e.sizeXp,ParseError:()=>Bt,ParseErrorCode:()=>Sn,TextCue:()=>rc,VTTCue:()=>Bi,VTTRegion:()=>sc,createVTTCueTemplate:()=>PS,parseByteStream:()=>v_,parseResponse:()=>TS,parseText:()=>ES,parseTextStream:()=>Zp,parseVTTTimestamp:()=>Wi,renderVTTCueString:()=>Jp,renderVTTTokensString:()=>eh,tokenizeVTTCue:()=>__,updateTimedVTTCueNodes:()=>w_});var oc=Ue(()=>{"use strict";ec()});var yi,lc=Ue(()=>{"use strict";"use client";Lt();yi=class{constructor(e){this._callback=e}_start(){Le(this._id)&&this._loop()}_stop(){Be(this._id)&&window.cancelAnimationFrame(this._id),this._id=void 0}_loop(){this._id=window.requestAnimationFrame(()=>{Le(this._id)||(this._callback(),this._loop())})}}});var k_,E_,Ua,T_=Ue(()=>{"use strict";"use client";Lt();Wt();lc();k_=class{constructor(e,n){this._provider=e,this._ctx=n,this._disposal=s_(),this._waiting=!1,this._attachedLoadStart=!1,this._attachedCanPlay=!1,this._timeRAF=new yi(this._onAnimationFrame.bind(this)),this._handlers=void 0,this._handleDevEvent=void 0,this._attachInitialListeners(),b(this._attachTimeUpdate.bind(this)),G(this._onDispose.bind(this))}get _media(){return this._provider.media}get _notify(){return this._ctx.delegate._notify}_onDispose(){this._attachedLoadStart=!1,this._attachedCanPlay=!1,this._timeRAF._stop(),this._disposal.empty()}_onAnimationFrame(){let e=this._media.currentTime;this._ctx.$state.realCurrentTime()!==e&&this._updateCurrentTime(e)}_attachInitialListeners(){this._attachEventListener("loadstart",this._onLoadStart),this._attachEventListener("abort",this._onAbort),this._attachEventListener("emptied",this._onEmptied),this._attachEventListener("error",this._onError),this._attachEventListener("volumechange",this._onVolumeChange)}_attachLoadStartListeners(){this._attachedLoadStart||(this._disposal.add(this._attachEventListener("loadeddata",this._onLoadedData),this._attachEventListener("loadedmetadata",this._onLoadedMetadata),this._attachEventListener("canplay",this._onCanPlay),this._attachEventListener("canplaythrough",this._onCanPlayThrough),this._attachEventListener("durationchange",this._onDurationChange),this._attachEventListener("play",this._onPlay),this._attachEventListener("progress",this._onProgress),this._attachEventListener("stalled",this._onStalled),this._attachEventListener("suspend",this._onSuspend)),this._attachedLoadStart=!0)}_attachCanPlayListeners(){this._attachedCanPlay||(this._disposal.add(this._attachEventListener("pause",this._onPause),this._attachEventListener("playing",this._onPlaying),this._attachEventListener("ratechange",this._onRateChange),this._attachEventListener("seeked",this._onSeeked),this._attachEventListener("seeking",this._onSeeking),this._attachEventListener("ended",this._onEnded),this._attachEventListener("waiting",this._onWaiting)),this._attachedCanPlay=!0)}_attachEventListener(e,n){return S(this._media,e,n.bind(this))}_onDevEvent(e){}_updateCurrentTime(e,n){let i={currentTime:Math.min(e,this._ctx.$state.seekableEnd()),played:this._media.played};this._notify("time-update",i,n)}_onLoadStart(e){if(this._media.networkState===3){this._onAbort(e);return}this._attachLoadStartListeners(),this._notify("load-start",void 0,e)}_onAbort(e){this._notify("abort",void 0,e)}_onEmptied(){this._notify("emptied",void 0,event)}_onLoadedData(e){this._notify("loaded-data",void 0,e)}_onLoadedMetadata(e){this._attachCanPlayListeners(),this._notify("loaded-metadata",void 0,e),S_&&xs(this._ctx.$state.source())&&this._ctx.delegate._ready(this._getCanPlayDetail(),e)}_getCanPlayDetail(){return{provider:C(this._ctx.$provider),duration:this._media.duration,buffered:this._media.buffered,seekable:this._media.seekable}}_onPlay(e){this._ctx.$state.canPlay&&this._notify("play",void 0,e)}_onPause(e){this._media.readyState===1&&!this._waiting||(this._waiting=!1,this._timeRAF._stop(),this._notify("pause",void 0,e))}_onCanPlay(e){this._ctx.delegate._ready(this._getCanPlayDetail(),e)}_onCanPlayThrough(e){this._ctx.$state.started()||this._notify("can-play-through",this._getCanPlayDetail(),e)}_onPlaying(e){this._waiting=!1,this._notify("playing",void 0,e),this._timeRAF._start()}_onStalled(e){this._notify("stalled",void 0,e),this._media.readyState<3&&(this._waiting=!0,this._notify("waiting",void 0,e))}_onWaiting(e){this._media.readyState<3&&(this._waiting=!0,this._notify("waiting",void 0,e))}_onEnded(e){this._timeRAF._stop(),this._updateCurrentTime(this._media.duration,e),this._notify("end",void 0,e),this._ctx.$state.loop()&&Zy(this._media.controls)&&(this._media.controls=!1)}_attachTimeUpdate(){this._ctx.$state.paused()&&S(this._media,"timeupdate",this._onTimeUpdate.bind(this))}_onTimeUpdate(e){this._updateCurrentTime(this._media.currentTime,e)}_onDurationChange(e){this._ctx.$state.ended()&&this._updateCurrentTime(this._media.duration,e),this._notify("duration-change",this._media.duration,e)}_onVolumeChange(e){let n={volume:this._media.volume,muted:this._media.muted};this._notify("volume-change",n,e)}_onSeeked(e){this._updateCurrentTime(this._media.currentTime,e),this._notify("seeked",this._media.currentTime,e),Math.trunc(this._media.currentTime)===Math.trunc(this._media.duration)&&th(this._media.duration)>th(this._media.currentTime)&&(this._updateCurrentTime(this._media.duration,e),this._media.ended||this._ctx.player.dispatch(new j("media-play-request",{trigger:e})))}_onSeeking(e){this._notify("seeking",this._media.currentTime,e)}_onProgress(e){let n={buffered:this._media.buffered,seekable:this._media.seekable};this._notify("progress",n,e)}_onSuspend(e){this._notify("suspend",void 0,e)}_onRateChange(e){this._notify("rate-change",this._media.playbackRate,e)}_onError(e){let n=this._media.error;if(!n)return;let i={message:n.message,code:n.code,mediaError:n};this._notify("error",i,e)}},E_=class{constructor(e,n){this._provider=e,this._ctx=n,this._nativeTracks.onaddtrack=this._onAddNativeTrack.bind(this),this._nativeTracks.onremovetrack=this._onRemoveNativeTrack.bind(this),this._nativeTracks.onchange=this._onChangeNativeTrack.bind(this),S(this._ctx.audioTracks,"change",this._onChangeTrack.bind(this))}get _nativeTracks(){return this._provider.media.audioTracks}_onAddNativeTrack(e){let n=e.track;if(n.label==="")return;let i={id:n.id.toString(),label:n.label,language:n.language,kind:n.kind,selected:!1};this._ctx.audioTracks[Y._add](i,e),n.enabled&&(i.selected=!0)}_onRemoveNativeTrack(e){let n=this._ctx.audioTracks.getById(e.track.id);n&&this._ctx.audioTracks[Y._remove](n,e)}_onChangeNativeTrack(e){let n=this._getEnabledNativeTrack();if(!n)return;let i=this._ctx.audioTracks.getById(n.id);i&&this._ctx.audioTracks[Y._select](i,!0,e)}_getEnabledNativeTrack(){return Array.from(this._nativeTracks).find(e=>e.enabled)}_onChangeTrack(e){let{current:n}=e.detail;if(!n)return;let i=this._nativeTracks.getTrackById(n.id);if(i){let r=this._getEnabledNativeTrack();r&&(r.enabled=!1),i.enabled=!0}}},Ua=class{constructor(e,n){this._media=e,this._ctx=n,this.scope=$t(),this._currentSrc=null}setup(){new k_(this,this._ctx),"audioTracks"in this.media&&new E_(this,this._ctx),G(()=>{this._media.setAttribute("src",""),this._media.load()})}get type(){return""}get media(){return this._media}get currentSrc(){return this._currentSrc}setPlaybackRate(e){this._media.playbackRate=e}async play(){return this._media.play()}async pause(){return this._media.pause()}setMuted(e){this._media.muted=e}setVolume(e){this._media.volume=e}setCurrentTime(e){this._media.currentTime=e}setPlaysInline(e){Z(this._media,"playsinline",e)}async loadSource({src:e,type:n},i){this._media.preload=i||"",P_(e)?this._media.srcObject=e:(this._media.srcObject=null,this._media.src=F(e)?this._appendMediaFragment(e):window.URL.createObjectURL(e)),this._media.load(),this._currentSrc={src:e,type:n}}_appendMediaFragment(e){let{clipStartTime:n,clipEndTime:i}=this._ctx.$state,r=n(),s=i();return r>0&&s>0?`${e}#t=${r},${s}`:r>0?`${e}#t=${r}`:s>0?`${e}#t=0,${s}`:e}}});var LS={};xt(LS,{AudioProvider:()=>C_});var aU,C_,IS=Ue(()=>{"use strict";"use client";T_();aU=$(z(),1),C_=class extends Ua{constructor(){super(...arguments),this.$$PROVIDER_TYPE="AUDIO"}get type(){return"audio"}setup(){super.setup(),this.type==="audio"&&this._ctx.delegate._notify("provider-setup",this)}get audio(){return this._media}}});var AS={};xt(AS,{VideoProvider:()=>cc});function p2(t,e){return Array.from(t.children).find(n=>n.track===e)}var uU,$_,M_,R_,L_,I_,A_,N_,cc,D_=Ue(()=>{"use strict";"use client";Lt();Wt();T_();uU=$(z(),1),$_=class{constructor(e,n){this._video=e,this._ctx=n,e.textTracks.onaddtrack=this._onAddTrack.bind(this),G(this._onDispose.bind(this))}_onAddTrack(e){let n=e.track;if(!n||p2(this._video,n))return;let i=new ln({id:n.id,kind:n.kind,label:n.label,language:n.language,type:"vtt"});i[W._native]={track:n},i[W._readyState]=2,i[W._nativeHLS]=!0;let r=0,s=a=>{if(n.cues)for(let o=r;o{this._media.delegate._notify("picture-in-picture-change",i,r)},S(this._video,"enterpictureinpicture",this._onEnter.bind(this)),S(this._video,"leavepictureinpicture",this._onExit.bind(this))}get active(){return document.pictureInPictureElement===this._video}get supported(){return ih(this._video)}async enter(){return this._video.requestPictureInPicture()}exit(){return document.exitPictureInPicture()}_onEnter(e){this._onChange(!0,e)}_onExit(e){this._onChange(!1,e)}},R_=class{constructor(e,n){this._video=e,this._media=n,this._mode="inline",S(this._video,"webkitpresentationmodechanged",this._onModeChange.bind(this))}get _supported(){return rh(this._video)}async _setPresentationMode(e){this._mode!==e&&this._video.webkitSetPresentationMode(e)}_onModeChange(e){let n=this._mode;this._mode=this._video.webkitPresentationMode,this._media.player?.dispatch(new j("video-presentation-change",{detail:this._mode,trigger:e})),["fullscreen","picture-in-picture"].forEach(i=>{(this._mode===i||n===i)&&this._media.delegate._notify(`${i}-change`,this._mode===i,e)})}},L_=class{constructor(e){this._presentation=e}get active(){return this._presentation._mode==="fullscreen"}get supported(){return this._presentation._supported}async enter(){this._presentation._setPresentationMode("fullscreen")}async exit(){this._presentation._setPresentationMode("inline")}},I_=class{constructor(e){this._presentation=e}get active(){return this._presentation._mode==="picture-in-picture"}get supported(){return this._presentation._supported}async enter(){this._presentation._setPresentationMode("picture-in-picture")}async exit(){this._presentation._setPresentationMode("inline")}},A_=class{constructor(e,n){this._video=e,this._ctx=n,this._supported=D(!1),this._setup()}get supported(){return this._supported()}_setup(){N||!this._video.remote||!this._canPrompt||(this._video.remote.watchAvailability(e=>{this._supported.set(e)}).catch(()=>{this._supported.set(!1)}),b(this._watchSupported.bind(this)))}_watchSupported(){if(!this._supported())return;let e=["connecting","connect","disconnect"],n=this._onStateChange.bind(this);n(),S(this._video,"playing",n);for(let i of e)S(this._video.remote,i,n)}async prompt(){if(!this.supported)throw Error("Not supported on this platform.");return this._video.remote.prompt()}_onStateChange(e){let n=this._video.remote.state;if(n===this._state)return;let i={type:this._type,state:n};this._ctx.delegate._notify("remote-playback-change",i,e),this._state=n}},N_=class extends A_{constructor(){super(...arguments),this._type="airplay"}get _canPrompt(){return"WebKitPlaybackTargetAvailabilityEvent"in window}},cc=class extends Ua{constructor(e,n){super(e,n),this.$$PROVIDER_TYPE="VIDEO",et(()=>{if(this.airPlay=new N_(e,n),rh(e)){let i=new R_(e,n);this.fullscreen=new L_(i),this.pictureInPicture=new I_(i)}else ih(e)&&(this.pictureInPicture=new M_(e,n))},this.scope)}get type(){return"video"}setup(){super.setup(),nh(this.video)&&new $_(this.video,this._ctx),this._ctx.textRenderers._attachVideo(this.video),G(()=>{this._ctx.textRenderers._attachVideo(null)}),this.type==="video"&&this._ctx.delegate._notify("provider-setup",this)}get video(){return this._media}}});var NS={};xt(NS,{HLSProvider:()=>sh});async function f2(t,e={}){if(!Le(t)){if(e.onLoadStart?.(),t.prototype&&t.prototype!==Function)return e.onLoaded?.(t),t;try{let n=(await t())?.default;if(n&&n.isSupported)e.onLoaded?.(n);else throw Error("");return n}catch(n){e.onLoadError?.(n)}}}async function m2(t,e={}){if(F(t)){e.onLoadStart?.();try{if(await oh(t),!yt(window.Hls))throw Error("");let n=window.Hls;return e.onLoaded?.(n),n}catch(n){e.onLoadError?.(n)}}}var mU,h2,O_,V_,g2,sh,DS=Ue(()=>{"use strict";"use client";Lt();Wt();D_();lc();mU=$(z(),1),h2=t=>Da(t),O_=class{constructor(e,n){this._video=e,this._ctx=n,this._instance=null,this._stopLiveSync=null,this._config={},this._callbacks=new Set,this._retryLoadingTimer=-1}get instance(){return this._instance}setup(e){let{streamType:n}=this._ctx.$state,i=C(n).includes("live"),r=C(n).includes("ll-");this._instance=new e({lowLatencyMode:r,backBufferLength:r?4:i?8:void 0,renderTextTracksNatively:!1,...this._config});let s=this._dispatchHLSEvent.bind(this);for(let a of Object.values(e.Events))this._instance.on(a,s);this._instance.on(e.Events.ERROR,this._onError.bind(this));for(let a of this._callbacks)a(this._instance);this._ctx.player.dispatch("hls-instance",{detail:this._instance}),this._instance.attachMedia(this._video),this._instance.on(e.Events.FRAG_LOADING,this._onFragLoading.bind(this)),this._instance.on(e.Events.AUDIO_TRACK_SWITCHED,this._onAudioSwitch.bind(this)),this._instance.on(e.Events.LEVEL_SWITCHED,this._onLevelSwitched.bind(this)),this._instance.on(e.Events.LEVEL_LOADED,this._onLevelLoaded.bind(this)),this._instance.on(e.Events.NON_NATIVE_TEXT_TRACKS_FOUND,this._onTracksFound.bind(this)),this._instance.on(e.Events.CUES_PARSED,this._onCuesParsed.bind(this)),this._ctx.qualities[cn._enableAuto]=this._enableAutoQuality.bind(this),S(this._ctx.qualities,"change",this._onQualityChange.bind(this)),S(this._ctx.audioTracks,"change",this._onAudioChange.bind(this)),this._stopLiveSync=b(this._liveSync.bind(this))}_liveSync(){if(!this._ctx.$state.live())return;let e=new yi(this._liveSyncPosition.bind(this));return e._start(),e._stop.bind(e)}_liveSyncPosition(){this._ctx.$state.liveSyncPosition.set(this._instance?.liveSyncPosition??1/0)}_dispatchHLSEvent(e,n){this._ctx.player?.dispatch(new j(h2(e),{detail:n}))}_onTracksFound(e,n){let i=new j(e,{detail:n}),r=-1;for(let s=0;s{l.mode==="showing"?(this._instance.subtitleTrack=s,r=s):r===s&&(this._instance.subtitleTrack=-1,r=-1)},this._ctx.textTracks.add(l,i)}}_onCuesParsed(e,n){let i=this._ctx.textTracks.getById(`hls-${n.track}`);if(!i)return;let r=new j(e,{detail:n});for(let s of n.cues)s.positionAlign="auto",i.addCue(s,r)}_onAudioSwitch(e,n){let i=this._ctx.audioTracks[n.id];if(i){let r=new j(e,{detail:n});this._ctx.audioTracks[Y._select](i,!0,r)}}_onLevelSwitched(e,n){let i=this._ctx.qualities[n.level];if(i){let r=new j(e,{detail:n});this._ctx.qualities[Y._select](i,!0,r)}}_onLevelLoaded(e,n){if(this._ctx.$state.canPlay())return;let{type:i,live:r,totalduration:s,targetduration:a}=n.details,o=new j(e,{detail:n});this._ctx.delegate._notify("stream-type-change",r?i==="EVENT"&&Number.isFinite(s)&&a>=10?"live:dvr":"live":"on-demand",o),this._ctx.delegate._notify("duration-change",s,o);let l=this._instance.media;this._instance.currentLevel===-1&&this._ctx.qualities[cn._setAuto](!0,o);for(let c of this._instance.audioTracks){let u={id:c.id.toString(),label:c.name,language:c.lang||"",kind:"main"};this._ctx.audioTracks[Y._add](u,o)}for(let c of this._instance.levels){let u={id:c.id?.toString()??c.height+"p",width:c.width,height:c.height,codec:c.codecSet,bitrate:c.bitrate};this._ctx.qualities[Y._add](u,o)}l.dispatchEvent(new j("canplay",{trigger:o}))}_onError(e,n){if(n.fatal)switch(n.type){case"networkError":this._onNetworkError(n.error);break;case"mediaError":this._instance?.recoverMediaError();break;default:this._onFatalError(n.error);break}}_onFragLoading(){this._retryLoadingTimer>=0&&this._clearRetryTimer()}_onNetworkError(e){this._clearRetryTimer(),this._instance?.startLoad(),this._retryLoadingTimer=window.setTimeout(()=>{this._retryLoadingTimer=-1,this._onFatalError(e)},5e3)}_clearRetryTimer(){clearTimeout(this._retryLoadingTimer),this._retryLoadingTimer=-1}_onFatalError(e){this._instance?.destroy(),this._instance=null,this._ctx.delegate._notify("error",{message:e.message,code:1,error:e})}_enableAutoQuality(){this._instance&&(this._instance.currentLevel=-1)}_onQualityChange(){let{qualities:e}=this._ctx;!this._instance||e.auto||(this._instance[e.switch+"Level"]=e.selectedIndex,uc&&(this._video.currentTime=this._video.currentTime))}_onAudioChange(){let{audioTracks:e}=this._ctx;this._instance&&this._instance.audioTrack!==e.selectedIndex&&(this._instance.audioTrack=e.selectedIndex)}_loadSource(e){F(e.src)&&(this._clearRetryTimer(),this._instance?.loadSource(e.src))}_destroy(){this._clearRetryTimer(),this._ctx&&(this._ctx.qualities[cn._enableAuto]=void 0),this._instance?.destroy(),this._instance=null,this._stopLiveSync?.(),this._stopLiveSync=null}},V_=class{constructor(e,n,i){this._lib=e,this._ctx=n,this._callback=i,this._startLoading()}async _startLoading(){let e={onLoadStart:this._onLoadStart.bind(this),onLoaded:this._onLoaded.bind(this),onLoadError:this._onLoadError.bind(this)},n=await m2(this._lib,e);if(Le(n)&&!F(this._lib)&&(n=await f2(this._lib,e)),!n)return null;if(!n.isSupported()){let i="[vidstack] `hls.js` is not supported in this environment";return this._ctx.player.dispatch(new j("hls-unsupported")),this._ctx.delegate._notify("error",{message:i,code:4}),null}return n}_onLoadStart(){this._ctx.player.dispatch(new j("hls-lib-load-start"))}_onLoaded(e){this._ctx.player.dispatch(new j("hls-lib-loaded",{detail:e})),this._callback(e)}_onLoadError(e){let n=_i(e);this._ctx.player.dispatch(new j("hls-lib-load-error",{detail:n})),this._ctx.delegate._notify("error",{message:n.message,code:4,error:n})}};g2="https://cdn.jsdelivr.net",sh=class extends cc{constructor(){super(...arguments),this.$$PROVIDER_TYPE="HLS",this._ctor=null,this._controller=new O_(this.video,this._ctx),this._library=`${g2}/npm/hls.js@^1.5.0/dist/hls.min.js`}get ctor(){return this._ctor}get instance(){return this._controller.instance}get type(){return"hls"}get canLiveSync(){return!0}get config(){return this._controller._config}set config(e){this._controller._config=e}get library(){return this._library}set library(e){this._library=e}preconnect(){F(this._library)&&Jn(this._library)}setup(){super.setup(),new V_(this._library,this._ctx,e=>{this._ctor=e,this._controller.setup(e),this._ctx.delegate._notify("provider-setup",this);let n=C(this._ctx.$state.source);n&&this.loadSource(n)})}async loadSource(e,n){F(e.src)&&(this._media.preload=n||"",this._controller._loadSource(e),this._currentSrc=e)}onInstance(e){let n=this._controller.instance;return n&&e(n),this._controller._callbacks.add(e),()=>this._controller._callbacks.delete(e)}destroy(){this._controller._destroy()}};sh.supported=ah()});function Ha(t,e=3e3){let n=qi();return setTimeout(()=>{let i=t();i&&n.reject(i)},e),n}var ja,F_=Ue(()=>{"use strict";"use client";Lt();Wt();ja=class{constructor(e){this._iframe=e,this._src=D(""),this.referrerPolicy=null,e.setAttribute("frameBorder","0"),e.setAttribute("aria-hidden","true"),e.setAttribute("allow","autoplay; fullscreen; encrypted-media; picture-in-picture; accelerometer; gyroscope"),this.referrerPolicy!==null&&e.setAttribute("referrerpolicy",this.referrerPolicy)}get iframe(){return this._iframe}setup(){S(window,"message",this._onWindowMessage.bind(this)),S(this._iframe,"load",this._onLoad.bind(this)),b(this._watchSrc.bind(this))}_watchSrc(){let e=this._src();if(!e.length){this._iframe.setAttribute("src","");return}let n=C(()=>this._buildParams());this._iframe.setAttribute("src",OS(e,n))}_postMessage(e,n){N||this._iframe.contentWindow?.postMessage(JSON.stringify(e),n??"*")}_onWindowMessage(e){let n=this._getOrigin();if((e.source===null||e.source===this._iframe?.contentWindow)&&(!F(n)||n===e.origin)){try{let r=JSON.parse(e.data);r&&this._onMessage(r,e);return}catch{}e.data&&this._onMessage(e.data,e)}}}});var VS={};xt(VS,{getVimeoVideoInfo:()=>j_,resolveVimeoVideoId:()=>U_});function U_(t){let e=t.match(v2);return{videoId:e?.[1],hash:e?.[2]}}async function j_(t,e){if(z_.has(t))return z_.get(t);if(lh.has(t))return lh.get(t);let n=`https://vimeo.com/api/oembed.json?url=https://player.vimeo.com/video/${t}`,i=window.fetch(n,{mode:"cors",signal:e.signal}).then(r=>r.json()).then(r=>{let s=/vimeocdn.com\/video\/(.*)?_/,a=r?.thumbnail_url?.match(s)?.[1],o=a?`https://i.vimeocdn.com/video/${a}_1920x1080.webp`:"",l={title:r?.title??"",duration:r?.duration??0,poster:o,pro:r.account_type!=="basic"};return z_.set(t,l),l}).finally(()=>lh.delete(t));return lh.set(t,i),i}var v2,z_,lh,H_=Ue(()=>{"use strict";"use client";v2=/(?:https:\/\/)?(?:player\.)?vimeo(?:\.com)?\/(?:video\/)?(\d+)(?:\?hash=(.*))?/,z_=new Map,lh=new Map});var FS={};xt(FS,{VimeoProvider:()=>q_});var EU,y2,q_,zS=Ue(()=>{"use strict";"use client";Lt();Wt();lc();F_();H_();EU=$(z(),1),y2=["bufferend","bufferstart","durationchange","ended","enterpictureinpicture","error","fullscreenchange","leavepictureinpicture","loaded","playProgress","loadProgress","pause","play","playbackratechange","qualitychange","seeked","seeking","timeupdate","volumechange","waiting"],q_=class extends ja{constructor(e,n){super(e),this._ctx=n,this.$$PROVIDER_TYPE="VIMEO",this.scope=$t(),this._played=0,this._playedRange=new oe(0,0),this._seekableRange=new oe(0,0),this._playPromise=null,this._pausePromise=null,this._videoInfoPromise=null,this._videoId=D(""),this._pro=D(!1),this._hash=null,this._currentSrc=null,this._currentCue=null,this._timeRAF=new yi(this._onAnimationFrame.bind(this)),this._chaptersTrack=null,this.cookies=!1,this.title=!0,this.byline=!0,this.portrait=!0,this.color="00ADEF",this._skipTimeUpdates=!1}get _notify(){return this._ctx.delegate._notify}get type(){return"vimeo"}get currentSrc(){return this._currentSrc}get videoId(){return this._videoId()}get hash(){return this._hash}get isPro(){return this._pro()}preconnect(){Jn(this._getOrigin())}setup(){super.setup(),b(this._watchVideoId.bind(this)),b(this._watchVideoInfo.bind(this)),b(this._watchPro.bind(this)),this._notify("provider-setup",this)}destroy(){this._reset(),this._remote("destroy")}async play(){let{paused:e}=this._ctx.$state;return this._playPromise||(this._playPromise=Ha(()=>{if(this._playPromise=null,e())return"Timed out."}),this._remote("play")),this._playPromise.promise}async pause(){let{paused:e}=this._ctx.$state;return this._pausePromise||(this._pausePromise=Ha(()=>{if(this._pausePromise=null,!e())return"Timed out."}),this._remote("pause")),this._pausePromise.promise}setMuted(e){this._remote("setMuted",e)}setCurrentTime(e){this._remote("seekTo",e),this._notify("seeking",e)}setVolume(e){this._remote("setVolume",e),this._remote("setMuted",C(this._ctx.$state.muted))}setPlaybackRate(e){this._remote("setPlaybackRate",e)}async loadSource(e){if(!F(e.src)){this._currentSrc=null,this._hash=null,this._videoId.set("");return}let{videoId:n,hash:i}=U_(e.src);this._videoId.set(n??""),this._hash=i??null,this._currentSrc=e}_watchVideoId(){this._reset();let e=this._videoId();if(!e){this._src.set("");return}this._src.set(`${this._getOrigin()}/video/${e}`),this._notify("load-start")}_watchVideoInfo(){let e=this._videoId();if(!e)return;let n=qi(),i=new AbortController;return this._videoInfoPromise=n,j_(e,i).then(r=>{n.resolve(r)}).catch(r=>{n.reject(),this._notify("error",{message:`Failed to fetch vimeo video info for id \`${e}\`.`,code:1,error:_i(r)})}),()=>{n.reject(),i.abort()}}_watchPro(){let e=this._pro(),{$state:n,qualities:i}=this._ctx;if(n.canSetPlaybackRate.set(e),i[Y._setReadonly](!e),e)return S(i,"change",()=>{if(i.auto)return;let r=i.selected?.id;r&&this._remote("setQuality",r)})}_getOrigin(){return"https://player.vimeo.com"}_buildParams(){let{$iosControls:e}=this._ctx,{keyDisabled:n}=this._ctx.$props,{controls:i,playsInline:r}=this._ctx.$state,s=i()||e();return{title:this.title,byline:this.byline,color:this.color,portrait:this.portrait,controls:s,h:this.hash,keyboard:s&&!n(),transparent:!0,playsinline:r(),dnt:!this.cookies}}_onAnimationFrame(){this._remote("getCurrentTime")}_onTimeUpdate(e,n){if(this._skipTimeUpdates&&e===0)return;let{realCurrentTime:i,realDuration:r,paused:s,bufferedEnd:a}=this._ctx.$state;if(i()===e)return;let o=i(),l={currentTime:e,played:this._getPlayedRange(e)};this._notify("time-update",l,n),Math.abs(o-e)>1.5&&(this._notify("seeking",e,n),!s()&&a(){this._skipTimeUpdates=!1},500))}_getPlayedRange(e){return this._played>=e?this._playedRange:this._playedRange=new oe(0,this._played=e)}_onSeeked(e,n){this._notify("seeked",e,n)}_onReady(e){let n=this._videoId();this._videoInfoPromise?.promise.then(i=>{if(!i)return;let{title:r,poster:s,duration:a,pro:o}=i,{$iosControls:l}=this._ctx,{controls:c}=this._ctx.$state,u=c()||l();this._pro.set(o),this._seekableRange=new oe(0,a),this._notify("title-change",r,e),this._notify("poster-change",s,e),this._notify("duration-change",a,e);let d={buffered:new oe(0,0),seekable:this._seekableRange,duration:a};this._ctx.delegate._ready(d,e),u||this._remote("_hideOverlay"),this._remote("getQualities"),this._remote("getChapters")}).catch(i=>{n===this._videoId()&&this._notify("error",{message:"Failed to fetch oembed data",code:2,error:_i(i)})})}_onMethod(e,n,i){switch(e){case"getCurrentTime":this._onTimeUpdate(n,i);break;case"getBuffered":qe(n)&&n.length&&this._onLoadProgress(n[n.length-1][1],i);break;case"setMuted":this._onVolumeChange(C(this._ctx.$state.volume),n,i);break;case"getChapters":this._onChaptersChange(n);break;case"getQualities":this._onQualitiesChange(n,i);break}}_attachListeners(){for(let e of y2)this._remote("addEventListener",e)}_onPause(e){this._timeRAF._stop(),this._notify("pause",void 0,e),this._pausePromise?.resolve(),this._pausePromise=null}_onPlay(e){this._timeRAF._start(),this._notify("play",void 0,e),this._playPromise?.resolve(),this._playPromise=null}_onPlayProgress(e){let{paused:n}=this._ctx.$state;n()||this._notify("playing",void 0,e)}_onLoadProgress(e,n){let i={buffered:new oe(0,e),seekable:this._seekableRange};this._notify("progress",i,n)}_onBufferStart(e){this._notify("waiting",void 0,e)}_onBufferEnd(e){let{paused:n}=this._ctx.$state;n()||this._notify("playing",void 0,e)}_onWaiting(e){let{paused:n}=this._ctx.$state;n()&&this._notify("play",void 0,e),this._notify("waiting",void 0,e)}_onVolumeChange(e,n,i){let r={volume:e,muted:n};this._notify("volume-change",r,i)}_onChaptersChange(e){if(this._removeChapters(),!e.length)return;let n=new ln({kind:"chapters",default:!0}),{realDuration:i}=this._ctx.$state;for(let r=0;ri.id==="auto")?()=>{this._remote("setQuality","auto")}:void 0;for(let i of e){if(i.id==="auto")continue;let r=+i.id.slice(0,-1);isNaN(r)||this._ctx.qualities[Y._add]({id:i.id,width:r*(16/9),height:r,codec:"avc1,h.264",bitrate:-1},n)}this._onQualityChange(e.find(i=>i.active),n)}_onQualityChange({id:e}={},n){if(!e)return;let i=e==="auto",r=this._ctx.qualities.toArray().find(s=>s.id===e);i?(this._ctx.qualities[cn._setAuto](i,n),this._ctx.qualities[Y._select](void 0,!0,n)):this._ctx.qualities[Y._select](r,!0,n)}_onEvent(e,n,i){switch(e){case"ready":this._attachListeners();break;case"loaded":this._onReady(i);break;case"play":this._onPlay(i);break;case"playProgress":this._onPlayProgress(i);break;case"pause":this._onPause(i);break;case"loadProgress":this._onLoadProgress(n.seconds,i);break;case"waiting":this._onWaiting(i);break;case"bufferstart":this._onBufferStart(i);break;case"bufferend":this._onBufferEnd(i);break;case"volumechange":this._onVolumeChange(n.volume,C(this._ctx.$state.muted),i);break;case"durationchange":this._seekableRange=new oe(0,n.duration),this._notify("duration-change",n.duration,i);break;case"playbackratechange":this._notify("rate-change",n.playbackRate,i);break;case"qualitychange":this._onQualityChange(n,i);break;case"fullscreenchange":this._notify("fullscreen-change",n.fullscreen,i);break;case"enterpictureinpicture":this._notify("picture-in-picture-change",!0,i);break;case"leavepictureinpicture":this._notify("picture-in-picture-change",!1,i);break;case"ended":this._notify("end",void 0,i);break;case"error":this._onError(n,i);break;case"seek":case"seeked":this._onSeeked(n.seconds,i);break}}_onError(e,n){if(e.method==="setPlaybackRate"&&this._pro.set(!1),e.method==="play"){this._playPromise?.reject(e.message);return}}_onMessage(e,n){e.event?this._onEvent(e.event,e.data,n):e.method&&this._onMethod(e.method,e.value,n)}_onLoad(){}_remote(e,n){return this._postMessage({method:e,value:n})}_reset(){this._timeRAF._stop(),this._played=0,this._playedRange=new oe(0,0),this._seekableRange=new oe(0,0),this._playPromise=null,this._pausePromise=null,this._videoInfoPromise=null,this._currentCue=null,this._pro.set(!1),this._removeChapters()}}});var US={};xt(US,{findYouTubePoster:()=>w2,resolveYouTubeVideoId:()=>W_});function W_(t){return t.match(_2)?.[1]}async function w2(t,e){if(B_.has(t))return B_.get(t);if(ch.has(t))return ch.get(t);let n=new Promise(async i=>{let r=["maxresdefault","sddefault","hqdefault"];for(let s of r)for(let a of[!0,!1]){let o=b2(t,s,a);if((await fetch(o,{mode:"no-cors",signal:e.signal})).status<400){B_.set(t,o),i(o);return}}}).catch(()=>"").finally(()=>ch.delete(t));return ch.set(t,n),n}function b2(t,e,n){return`https://i.ytimg.com/${n?"vi_webp":"vi"}/${t}/${e}.${n?"webp":"jpg"}`}var _2,B_,ch,K_=Ue(()=>{"use strict";"use client";_2=/(?:youtu\.be|youtube|youtube\.com|youtube-nocookie\.com)\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=|)((?:\w|-){11})/,B_=new Map,ch=new Map});var jS={};xt(jS,{YouTubeProvider:()=>G_});var $U,ks,G_,HS=Ue(()=>{"use strict";"use client";Lt();Wt();F_();K_();$U=$(z(),1),ks={_Unstarted:-1,_Ended:0,_Playing:1,_Paused:2,_Buffering:3,_Cued:5},G_=class extends ja{constructor(e,n){super(e),this._ctx=n,this.$$PROVIDER_TYPE="YOUTUBE",this.scope=$t(),this._videoId=D(""),this._state=-1,this._seekingTimer=-1,this._pausedSeeking=!1,this._played=0,this._playedRange=new oe(0,0),this._currentSrc=null,this._playPromise=null,this._pausePromise=null,this.language="en",this.color="red",this.cookies=!1}get _notify(){return this._ctx.delegate._notify}get currentSrc(){return this._currentSrc}get type(){return"youtube"}get videoId(){return this._videoId()}preconnect(){Jn(this._getOrigin())}setup(){super.setup(),b(this._watchVideoId.bind(this)),this._notify("provider-setup",this)}async play(){let{paused:e}=this._ctx.$state;return this._playPromise||(this._playPromise=Ha(()=>{if(this._playPromise=null,e())return"Timed out."}),this._remote("playVideo")),this._playPromise.promise}async pause(){let{paused:e}=this._ctx.$state;return this._pausePromise||(this._pausePromise=Ha(()=>{this._pausePromise=null,e()}),this._remote("pauseVideo")),this._pausePromise.promise}setMuted(e){e?this._remote("mute"):this._remote("unMute")}setCurrentTime(e){this._pausedSeeking=this._ctx.$state.paused(),this._remote("seekTo",e),this._notify("seeking",e)}setVolume(e){this._remote("setVolume",e*100)}setPlaybackRate(e){this._remote("setPlaybackRate",e)}async loadSource(e){if(!F(e.src)){this._currentSrc=null,this._videoId.set("");return}let n=W_(e.src);this._videoId.set(n??""),this._currentSrc=e}_getOrigin(){return this.cookies?"https://www.youtube.com":"https://www.youtube-nocookie.com"}_watchVideoId(){this._reset();let e=this._videoId();if(!e){this._src.set("");return}this._src.set(`${this._getOrigin()}/embed/${e}`),this._notify("load-start")}_buildParams(){let{keyDisabled:e}=this._ctx.$props,{$iosControls:n}=this._ctx,{controls:i,muted:r,playsInline:s}=this._ctx.$state,a=i()||n();return{autoplay:0,cc_lang_pref:this.language,cc_load_policy:a?1:void 0,color:this.color,controls:a?1:0,disablekb:!a||e()?1:0,enablejsapi:1,fs:1,hl:this.language,iv_load_policy:a?1:3,mute:r()?1:0,playsinline:s()?1:0}}_remote(e,n){this._postMessage({event:"command",func:e,args:n?[n]:void 0})}_onLoad(){window.setTimeout(()=>this._postMessage({event:"listening"}),100)}_onReady(e){this._notify("loaded-metadata"),this._notify("loaded-data"),this._ctx.delegate._ready(void 0,e)}_onPause(e){this._pausePromise?.resolve(),this._pausePromise=null,this._notify("pause",void 0,e)}_onTimeUpdate(e,n){let{duration:i,realCurrentTime:r}=this._ctx.$state,s=this._state===ks._Ended,a=s?i():e,o={currentTime:a,played:this._getPlayedRange(a)};this._notify("time-update",o,n),!s&&Math.abs(a-r())>1&&this._notify("seeking",a,n)}_getPlayedRange(e){return this._played>=e?this._playedRange:this._playedRange=new oe(0,this._played=e)}_onProgress(e,n,i){let r={buffered:new oe(0,e),seekable:n};this._notify("progress",r,i);let{seeking:s,realCurrentTime:a}=this._ctx.$state;s()&&e>a()&&this._onSeeked(i)}_onSeeked(e){let{paused:n,realCurrentTime:i}=this._ctx.$state;window.clearTimeout(this._seekingTimer),this._seekingTimer=window.setTimeout(()=>{this._notify("seeked",i(),e),this._seekingTimer=-1},n()?100:0),this._pausedSeeking=!1}_onEnded(e){let{seeking:n}=this._ctx.$state;n()&&this._onSeeked(e),this._notify("end",void 0,e)}_onStateChange(e,n){let{started:i,paused:r,seeking:s}=this._ctx.$state,a=e===ks._Playing,o=e===ks._Buffering,l=(r()||this._playPromise)&&(o||a);if(o&&this._notify("waiting",void 0,n),s()&&a&&this._onSeeked(n),!i()&&l&&this._pausedSeeking){this._playPromise?.reject("invalid internal play operation"),this._playPromise=null,a&&(this.pause(),this._pausedSeeking=!1);return}switch(l&&(this._playPromise?.resolve(),this._playPromise=null,this._notify("play",void 0,n)),e){case ks._Cued:this._onReady(n);break;case ks._Playing:this._notify("playing",void 0,n);break;case ks._Paused:this._onPause(n);break;case ks._Ended:this._onEnded(n);break}this._state=e}_onMessage({info:e},n){if(!e)return;let{title:i,intrinsicDuration:r,playbackRate:s}=this._ctx.$state;if(Gl(e.videoData)&&e.videoData.title!==i()&&this._notify("title-change",e.videoData.title,n),Be(e.duration)&&e.duration!==r()){if(Be(e.videoLoadedFraction)){let a=e.progressState?.loaded??e.videoLoadedFraction*e.duration,o=new oe(0,e.duration);this._onProgress(a,o,n)}this._notify("duration-change",e.duration,n)}if(Be(e.playbackRate)&&e.playbackRate!==s()&&this._notify("rate-change",e.playbackRate,n),e.progressState){let{current:a,seekableStart:o,seekableEnd:l,loaded:c,duration:u}=e.progressState;this._onTimeUpdate(a,n),this._onProgress(c,new oe(o,l),n),u!==r()&&this._notify("duration-change",u,n)}if(Be(e.volume)&&Jy(e.muted)){let a={muted:e.muted,volume:e.volume/100};this._notify("volume-change",a,n)}Be(e.playerState)&&e.playerState!==this._state&&this._onStateChange(e.playerState,n)}_reset(){this._state=-1,this._seekingTimer=-1,this._played=0,this._playedRange=new oe(0,0),this._playPromise=null,this._pausePromise=null,this._pausedSeeking=!1}}});var BS={};xt(BS,{GoogleCastProvider:()=>Z_});var AU,Q_,Y_,qS,X_,Z_,WS=Ue(()=>{"use strict";"use client";Lt();Wt();lc();ew();AU=$(z(),1),Q_=class{constructor(e){this._info=new chrome.cast.media.MediaInfo(e.src,e.type)}build(){return this._info}_setStreamType(e){return e.includes("live")?this._info.streamType=chrome.cast.media.StreamType.LIVE:this._info.streamType=chrome.cast.media.StreamType.BUFFERED,this}_setTracks(e){return this._info.tracks=e.map(this._buildCastTrack),this}_setMetadata(e,n){return this._info.metadata=new chrome.cast.media.GenericMediaMetadata,this._info.metadata.title=e,this._info.metadata.images=[{url:n}],this}_buildCastTrack(e,n){let i=new chrome.cast.media.Track(n,chrome.cast.media.TrackType.TEXT);return i.name=e.label,i.trackContentId=e.src,i.trackContentType="text/vtt",i.language=e.language,i.subtype=e.kind.toUpperCase(),i}},Y_=chrome.cast.media.TrackType.TEXT,qS=chrome.cast.media.TrackType.AUDIO,X_=class{constructor(e,n,i){this._cast=e,this._ctx=n,this._onNewLocalTracks=i}_setup(){let e=this._syncRemoteActiveIds.bind(this);S(this._ctx.audioTracks,"change",e),S(this._ctx.textTracks,"mode-change",e),b(this._syncLocalTracks.bind(this))}_getLocalTextTracks(){return this._ctx.$state.textTracks().filter(e=>e.src&&e.type==="vtt")}_getLocalAudioTracks(){return this._ctx.$state.audioTracks()}_getRemoteTracks(e){let n=this._cast.mediaInfo?.tracks??[];return e?n.filter(i=>i.type===e):n}_getRemoteActiveIds(){let e=[],n=this._getLocalAudioTracks().find(r=>r.selected),i=this._getLocalTextTracks().filter(r=>r.mode==="showing");if(n){let r=this._getRemoteTracks(qS),s=this._findRemoteTrack(r,n);s&&e.push(s.trackId)}if(i?.length){let r=this._getRemoteTracks(Y_);if(r.length)for(let s of i){let a=this._findRemoteTrack(r,s);a&&e.push(a.trackId)}}return e}_syncLocalTracks(){let e=this._getLocalTextTracks();if(!this._cast.isMediaLoaded)return;let n=this._getRemoteTracks(Y_);for(let i of e)if(!this._findRemoteTrack(n,i)){Aa(()=>this._onNewLocalTracks?.());break}}_syncRemoteTracks(e){if(!this._cast.isMediaLoaded)return;let n=this._getLocalAudioTracks(),i=this._getLocalTextTracks(),r=this._getRemoteTracks(qS),s=this._getRemoteTracks(Y_);for(let a of r){if(this._findLocalTrack(n,a))continue;let l={id:a.trackId.toString(),label:a.name,language:a.language,kind:a.subtype??"main",selected:!1};this._ctx.audioTracks[Y._add](l,e)}for(let a of s){if(this._findLocalTrack(i,a))continue;let l={id:a.trackId.toString(),src:a.trackContentId,label:a.name,language:a.language,kind:a.subtype.toLowerCase()};this._ctx.textTracks.add(l,e)}}_syncRemoteActiveIds(e){if(!this._cast.isMediaLoaded)return;let n=this._getRemoteActiveIds(),i=new chrome.cast.media.EditTracksInfoRequest(n);this._editTracksInfo(i).catch(r=>{})}_editTracksInfo(e){let n=pc();return new Promise((i,r)=>n?.editTracksInfo(e,i,r))}_findLocalTrack(e,n){return e.find(i=>this._isMatch(i,n))}_findRemoteTrack(e,n){return e.find(i=>this._isMatch(n,i))}_isMatch(e,n){return n.name===e.label&&n.language===e.language&&n.subtype.toLowerCase()===e.kind.toLowerCase()}},Z_=class{constructor(e,n){this._player=e,this._ctx=n,this.$$PROVIDER_TYPE="GOOGLE_CAST",this.scope=$t(),this._currentSrc=null,this._state="disconnected",this._currentTime=0,this._played=0,this._playedRange=new oe(0,0),this._seekableRange=new oe(0,0),this._timeRAF=new yi(this._onAnimationFrame.bind(this)),this._reloadInfo=null,this._isIdle=!1,this._tracks=new X_(this._player,this._ctx,this._onNewLocalTracks.bind(this))}get _notify(){return this._ctx.delegate._notify}get type(){return"google-cast"}get currentSrc(){return this._currentSrc}get player(){return this._player}get cast(){return Es()}get session(){return dc()}get media(){return pc()}get hasActiveSession(){return uh(this._currentSrc)}setup(){this._attachCastContextEventListeners(),this._attachCastPlayerEventListeners(),this._tracks._setup(),this._notify("provider-setup",this)}_attachCastContextEventListeners(){J_(cast.framework.CastContextEventType.CAST_STATE_CHANGED,this._onCastStateChange.bind(this))}_attachCastPlayerEventListeners(){let e=cast.framework.RemotePlayerEventType,n={[e.IS_CONNECTED_CHANGED]:this._onCastStateChange,[e.IS_MEDIA_LOADED_CHANGED]:this._onMediaLoadedChange,[e.CAN_CONTROL_VOLUME_CHANGED]:this._onCanControlVolumeChange,[e.CAN_SEEK_CHANGED]:this._onCanSeekChange,[e.DURATION_CHANGED]:this._onDurationChange,[e.IS_MUTED_CHANGED]:this._onVolumeChange,[e.VOLUME_LEVEL_CHANGED]:this._onVolumeChange,[e.IS_PAUSED_CHANGED]:this._onPausedChange,[e.LIVE_SEEKABLE_RANGE_CHANGED]:this._onProgress,[e.PLAYER_STATE_CHANGED]:this._onPlayerStateChange};this._playerEventHandlers=n;let i=this._onRemotePlayerEvent.bind(this);for(let r of Jl(n))this._player.controller.addEventListener(r,i);G(()=>{for(let r of Jl(n))this._player.controller.removeEventListener(r,i)})}async play(){if(!(!this._player.isPaused&&!this._isIdle)){if(this._isIdle){await this._reload(!1,0);return}this._player.controller?.playOrPause()}}async pause(){this._player.isPaused||this._player.controller?.playOrPause()}getMediaStatus(e){return new Promise((n,i)=>{this.media?.getStatus(e,n,i)})}setMuted(e){(e&&!this._player.isMuted||!e&&this._player.isMuted)&&this._player.controller?.muteOrUnmute()}setCurrentTime(e){this._player.currentTime=e,this._notify("seeking",e),this._player.controller?.seek()}setVolume(e){this._player.volumeLevel=e,this._player.controller?.setVolumeLevel()}async loadSource(e){if(this._reloadInfo?.src!==e&&(this._reloadInfo=null),uh(e)){this._resumeSession(),this._currentSrc=e;return}this._notify("load-start");let n=this._buildLoadRequest(e),i=await this.session.loadMedia(n);if(i){this._currentSrc=null,this._notify("error",Error(dh(i)));return}this._currentSrc=e}destroy(){this._reset(),this._endSession()}_reset(){this._reloadInfo||(this._played=0,this._playedRange=new oe(0,0),this._seekableRange=new oe(0,0)),this._timeRAF._stop(),this._currentTime=0,this._reloadInfo=null}_resumeSession(){let e=new j("resume-session",{detail:this.session});this._onMediaLoadedChange(e);let{muted:n,volume:i,remotePlaybackInfo:r}=this._ctx.$state,s=r();this.setCurrentTime(Math.max(this._player.currentTime,s?.savedState?.currentTime??0)),this.setMuted(n()),this.setVolume(i()),s?.savedState?.paused===!1&&this.play()}_endSession(){this.cast.endCurrentSession(!0);let{remotePlaybackLoader:e}=this._ctx.$state;e.set(null)}_disconnectFromReceiver(){this._ctx.$state.remotePlaybackInfo.set({savedState:{paused:this._player.isPaused,currentTime:this._player.currentTime}}),this._endSession()}_onAnimationFrame(){this._onCurrentTimeChange()}_onRemotePlayerEvent(e){this._playerEventHandlers[e.type].call(this,e)}_onCastStateChange(e){let n=this.cast.getCastState(),i=n===cast.framework.CastState.CONNECTED?"connected":n===cast.framework.CastState.CONNECTING?"connecting":"disconnected";if(this._state===i)return;let r={type:"google-cast",state:i},s=this._createEvent(e);this._state=i,this._notify("remote-playback-change",r,s),i==="disconnected"&&this._disconnectFromReceiver()}_onMediaLoadedChange(e){if(!!!this._player.isMediaLoaded)return;let i=C(this._ctx.$state.source);Promise.resolve().then(()=>{if(i!==C(this._ctx.$state.source)||!this._player.isMediaLoaded)return;this._reset();let r=this._player.duration;this._seekableRange=new oe(0,r);let s={provider:this,duration:r,buffered:this._playedRange,seekable:this._getSeekableRange()},a=this._createEvent(e);this._notify("loaded-metadata",void 0,a),this._notify("loaded-data",void 0,a),this._notify("can-play",s,a),this._onCanControlVolumeChange(),this._onCanSeekChange(e);let{volume:o,muted:l}=this._ctx.$state;this.setVolume(o()),this.setMuted(l()),this._timeRAF._start(),this._tracks._syncRemoteTracks(a),this._tracks._syncRemoteActiveIds(a)})}_onCanControlVolumeChange(){this._ctx.$state.canSetVolume.set(this._player.canControlVolume)}_onCanSeekChange(e){let n=this._createEvent(e);this._notify("stream-type-change",this._getStreamType(),n)}_getStreamType(){return this._player.mediaInfo?.streamType===chrome.cast.media.StreamType.LIVE?this._player.canSeek?"live:dvr":"live":"on-demand"}_onCurrentTimeChange(){if(this._reloadInfo)return;let e=this._player.currentTime;if(e===this._currentTime)return;let n=this._played,i=this._getPlayedRange(e),r={currentTime:e,played:i};this._notify("time-update",r),e>n&&this._onProgress(),this._ctx.$state.seeking()&&this._notify("seeked",e),this._currentTime=e}_getPlayedRange(e){return this._played>=e?this._playedRange:this._playedRange=new oe(0,this._played=e)}_onDurationChange(e){if(!this._player.isMediaLoaded||this._reloadInfo)return;let n=this._player.duration,i=this._createEvent(e);this._seekableRange=new oe(0,n),this._notify("duration-change",n,i)}_onVolumeChange(e){if(!this._player.isMediaLoaded)return;let n={muted:this._player.isMuted,volume:this._player.volumeLevel},i=this._createEvent(e);this._notify("volume-change",n,i)}_onPausedChange(e){let n=this._createEvent(e);this._player.isPaused?this._notify("pause",void 0,n):this._notify("play",void 0,n)}_onProgress(e){let n={seekable:this._getSeekableRange(),buffered:this._playedRange},i=e?this._createEvent(e):void 0;this._notify("progress",n,i)}_onPlayerStateChange(e){let n=this._player.playerState,i=chrome.cast.media.PlayerState;if(this._isIdle=n===i.IDLE,n===i.PAUSED)return;let r=this._createEvent(e);switch(n){case i.PLAYING:this._notify("playing",void 0,r);break;case i.BUFFERING:this._notify("waiting",void 0,r);break;case i.IDLE:this._timeRAF._stop(),this._notify("pause"),this._notify("end");break}}_getSeekableRange(){return this._player.liveSeekableRange?new oe(this._player.liveSeekableRange.start,this._player.liveSeekableRange.end):this._seekableRange}_createEvent(e){return e instanceof Event?e:new j(e.type,{detail:e})}_buildMediaInfo(e){let{streamType:n,title:i,poster:r}=this._ctx.$state;return new Q_(e)._setMetadata(i(),r())._setStreamType(n())._setTracks(this._tracks._getLocalTextTracks()).build()}_buildLoadRequest(e){let n=this._buildMediaInfo(e),i=new chrome.cast.media.LoadRequest(n),r=this._ctx.$state.remotePlaybackInfo();return i.autoplay=(this._reloadInfo?.paused??r?.savedState?.paused)===!1,i.currentTime=this._reloadInfo?.time??r?.savedState?.currentTime??0,i}async _reload(e,n){let i=C(this._ctx.$state.source);this._reloadInfo={src:i,paused:e,time:n},await this.loadSource(i)}_onNewLocalTracks(){this._reload(this._player.isPaused,this._player.currentTime).catch(e=>{})}}});var GS={};xt(GS,{a:()=>Es,b:()=>dc,c:()=>dh,d:()=>S2,g:()=>pc,h:()=>uh,l:()=>J_});function x2(){return"https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"}function k2(){return!!window.cast?.framework}function E2(){return!!window.chrome?.cast?.isAvailable}function KS(){return Es().getCastState()===cast.framework.CastState.CONNECTED}function Es(){return window.cast.framework.CastContext.getInstance()}function dc(){return Es().getCurrentSession()}function pc(){return dc()?.getSessionObj().media[0]}function uh(t){return pc()?.media.contentId===t?.src}function T2(){return{language:"en-US",autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,resumeSavedSession:!0,androidReceiverCompatible:!0}}function dh(t){return`Google Cast Error Code: ${t}`}function J_(t,e){return YS(Es(),t,e)}var tw,S2,ew=Ue(()=>{"use strict";"use client";Wt();Lt();tw=class{constructor(){this.name="google-cast"}get cast(){return Es()}mediaType(){return"video"}canPlay(e){return uc&&!ph&&hh(e)}async prompt(e){let n;try{let i=await this._loadCastFramework(e);this._player||(this._player=new cast.framework.RemotePlayer,new cast.framework.RemotePlayerController(this._player)),n=e.player.createEvent("google-cast-prompt-open",{trigger:i}),e.player.dispatchEvent(n),this._notifyRemoteStateChange(e,"connecting",n),await this._showPrompt(C(e.$props.googleCast)),e.$state.remotePlaybackInfo.set({deviceName:dc()?.getCastDevice().friendlyName}),KS()&&this._notifyRemoteStateChange(e,"connected",n)}catch(i){let r=_i(i);throw this._notifyRemoteStateChange(e,KS()?"connected":"disconnected",new j("google-cast-prompt-error",{detail:r})),r}finally{e.player.dispatch("google-cast-prompt-close",{trigger:n})}}async load(e){if(N)throw Error("[vidstack] can not load google cast provider server-side");if(!this._player)throw Error("[vidstack] google cast player was not initialized");return new(await Promise.resolve().then(()=>(WS(),BS))).GoogleCastProvider(this._player,e)}async _loadCastFramework(e){if(k2())return;let n=e.player.createEvent("google-cast-load-start");e.player.dispatch(n),await oh(x2()),await customElements.whenDefined("google-cast-launcher");let i=e.player.createEvent("google-cast-loaded",{trigger:n});if(e.player.dispatch(i),!E2())throw Error("Cast not available.");return i}async _showPrompt(e){this._setOptions(e);let n=await this.cast.requestSession();if(n)throw Error(dh(n))}_setOptions(e){this.cast?.setOptions({...T2(),...e})}_notifyRemoteStateChange(e,n,i){let r={type:"google-cast",state:n};e.delegate._notify("remote-playback-change",r,i)}},S2=Object.freeze({__proto__:null,GoogleCastLoader:tw})});function _P(){return _h}function nw(t){if(Ts.fullscreenElement===t)return!0;try{return t.matches(Ts.fullscreenPseudoClass)}catch{return!1}}function eP(){if(!_h)throw Error("[vidstack] no fullscreen API")}function Sw(){return wP()&&yt(screen.orientation.unlock)}function wP(){return!N&&!Le(window.screen.orientation)&&!Le(window.screen.orientation.lock)}function F2(t,e){return N?!1:(t||(t=document.createElement("audio")),t.canPlayType(e).length>0)}function z2(t,e){return N?!1:(t||(t=document.createElement("video")),t.canPlayType(e).length>0)}function nh(t){return N?!1:(t||(t=document.createElement("video")),t.canPlayType("application/vnd.apple.mpegurl").length>0)}function ih(t){return N?!1:!!document.pictureInPictureEnabled&&!t?.disablePictureInPicture}function rh(t){return N?!1:yt(t?.webkitSupportsPresentationMode)&&yt(t?.webkitSetPresentationMode)}async function bP(){let t=document.createElement("video");return t.volume=.5,await a_(0),t.volume===.5}function U2(){return N?void 0:window?.ManagedMediaSource??window?.MediaSource??window?.WebKitMediaSource}function j2(){return N?void 0:window?.SourceBuffer??window?.WebKitSourceBuffer}function ah(){if(N)return!1;let t=U2();if(Le(t))return!1;let e=t&&yt(t.isTypeSupported)&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),n=j2(),i=Le(n)||!Le(n.prototype)&&yt(n.prototype.appendBuffer)&&yt(n.prototype.remove);return!!e&&!!i}function aw(t){if(!t.length)return null;let e=t.start(0);for(let n=1;ne&&(e=i)}return e}function OS(t,e){let n=new URLSearchParams;for(let i of Object.keys(e))n.set(i,e[i]+"");return t+"?"+n.toString()}function Jn(t,e="preconnect"){if(N)return!1;let n=document.querySelector(`link[href="${t}"]`);if(!gi(n))return!0;let i=document.createElement("link");return i.rel=e,i.href=t,i.crossOrigin="true",document.head.append(i),!0}function oh(t){if(fh[t])return fh[t].promise;let e=qi(),n=document.querySelector(`script[src="${t}"]`);if(!gi(n))return e.resolve(),e.promise;let i=document.createElement("script");return i.src=t,i.onload=()=>{e.resolve(),delete fh[t]},i.onerror=()=>{e.reject(),delete fh[t]},setTimeout(()=>document.head.append(i),0),e.promise}function bh(t){return t==="use-credentials"?"include":F(t)?"same-origin":void 0}function xh(t,e){return e>=t.startTime&&es.includes(o.kind)&&o.mode==="showing");if(a!==i){if(!a){n(null),i=null;return}a.readyState==2?n(a):(n(null),a.addEventListener("load",()=>n(a),{once:!0})),i=a}}return r(),S(t,"mode-change",r)}function We(t){return Q2.test(t.kind)}function EP(t,e,n){let i=F(t)?JSON.parse(t):t,r=[],s=[];return i.regions&&n&&(r=i.regions.map(a=>Object.assign(new n,a))),(i.cues||qe(i))&&(s=(qe(i)?i:i.cues).filter(a=>Be(a.startTime)&&Be(a.endTime)).map(a=>Object.assign(new e(0,0,""),a))),{regions:r,cues:s}}function TP(t){Ns.reset(t,e=>X2.has(e)),Zn()}function le(){return Ie(ru)}function SP(t){return t.split("-")[0]}function Z2(t){return t.split("-")[1]}function J2(t){return t==="x"?"y":"x"}function eO(t){return t==="y"?"height":"width"}function PP(t){return["top","bottom"].includes(SP(t))?"y":"x"}function tO(t){return J2(PP(t))}function CP(t){return{...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}function sP(t,e,n){let{reference:i,floating:r}=t,s=PP(e),a=tO(e),o=eO(a),l=SP(e),c=s==="y",u=i.x+i.width/2-r.width/2,d=i.y+i.height/2-r.height/2,p=i[o]/2-r[o]/2,h;switch(l){case"top":h={x:u,y:i.y-r.height};break;case"bottom":h={x:u,y:i.y+i.height};break;case"right":h={x:i.x+i.width,y:d};break;case"left":h={x:i.x-r.width,y:d};break;default:h={x:i.x,y:i.y}}switch(Z2(e)){case"start":h[a]-=p*(n&&c?-1:1);break;case"end":h[a]+=p*(n&&c?-1:1);break}return h}function Nr(t){return $P(t)?(t.nodeName||"").toLowerCase():"#document"}function dn(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function er(t){var e;return(e=($P(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function $P(t){return t instanceof Node||t instanceof dn(t).Node}function Yi(t){return t instanceof Element||t instanceof dn(t).Element}function wi(t){return t instanceof HTMLElement||t instanceof dn(t).HTMLElement}function aP(t){return typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof dn(t).ShadowRoot}function su(t){let{overflow:e,overflowX:n,overflowY:i,display:r}=Cn(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+n)&&!["inline","contents"].includes(r)}function iO(t){return["table","td","th"].includes(Nr(t))}function Cw(t){let e=$w(),n=Cn(t);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(i=>(n.willChange||"").includes(i))||["paint","layout","strict","content"].some(i=>(n.contain||"").includes(i))}function MP(t){let e=Ga(t);for(;wi(e)&&!cf(e);){if(Cw(e))return e;e=Ga(e)}return null}function $w(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function cf(t){return["html","body","#document"].includes(Nr(t))}function Cn(t){return dn(t).getComputedStyle(t)}function uf(t){return Yi(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function Ga(t){if(Nr(t)==="html")return t;let e=t.assignedSlot||t.parentNode||aP(t)&&t.host||er(t);return aP(e)?e.host:e}function RP(t){let e=Ga(t);return cf(e)?t.ownerDocument?t.ownerDocument.body:t.body:wi(e)&&su(e)?e:RP(e)}function gc(t,e,n){var i;e===void 0&&(e=[]),n===void 0&&(n=!0);let r=RP(t),s=r===((i=t.ownerDocument)==null?void 0:i.body),a=dn(r);return s?e.concat(a,a.visualViewport||[],su(r)?r:[],a.frameElement&&n?gc(a.frameElement):[]):e.concat(r,gc(r,[],n))}function LP(t){let e=Cn(t),n=parseFloat(e.width)||0,i=parseFloat(e.height)||0,r=wi(t),s=r?t.offsetWidth:n,a=r?t.offsetHeight:i,o=kh(n)!==s||kh(i)!==a;return o&&(n=s,i=a),{width:n,height:i,$:o}}function Mw(t){return Yi(t)?t:t.contextElement}function Ba(t){let e=Mw(t);if(!wi(e))return Ar(1);let n=e.getBoundingClientRect(),{width:i,height:r,$:s}=LP(e),a=(s?kh(n.width):n.width)/i,o=(s?kh(n.height):n.height)/r;return(!a||!Number.isFinite(a))&&(a=1),(!o||!Number.isFinite(o))&&(o=1),{x:a,y:o}}function IP(t){let e=dn(t);return!$w()||!e.visualViewport?rO:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function sO(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==dn(t)?!1:e}function Ss(t,e,n,i){e===void 0&&(e=!1),n===void 0&&(n=!1);let r=t.getBoundingClientRect(),s=Mw(t),a=Ar(1);e&&(i?Yi(i)&&(a=Ba(i)):a=Ba(t));let o=sO(s,n,i)?IP(s):Ar(0),l=(r.left+o.x)/a.x,c=(r.top+o.y)/a.y,u=r.width/a.x,d=r.height/a.y;if(s){let p=dn(s),h=i&&Yi(i)?dn(i):i,y=p.frameElement;for(;y&&i&&h!==p;){let v=Ba(y),w=y.getBoundingClientRect(),m=Cn(y),f=w.left+(y.clientLeft+parseFloat(m.paddingLeft))*v.x,g=w.top+(y.clientTop+parseFloat(m.paddingTop))*v.y;l*=v.x,c*=v.y,u*=v.x,d*=v.y,l+=f,c+=g,y=dn(y).frameElement}}return CP({width:u,height:d,x:l,y:c})}function AP(t){let e=!1,n=0,i=0;function r(a){try{e=e||t.matches(a)}catch{}}aO.forEach(a=>{r(a)});let s=MP(t);if(e&&s){let a=s.getBoundingClientRect();n=a.x,i=a.y}return[e,n,i]}function oO(t){let{elements:e,rect:n,offsetParent:i,strategy:r}=t,s=er(i),[a]=e?AP(e.floating):[!1];if(i===s||a)return n;let o={scrollLeft:0,scrollTop:0},l=Ar(1),c=Ar(0),u=wi(i);if((u||!u&&r!=="fixed")&&((Nr(i)!=="body"||su(s))&&(o=uf(i)),wi(i))){let d=Ss(i);l=Ba(i),c.x=d.x+i.clientLeft,c.y=d.y+i.clientTop}return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-o.scrollLeft*l.x+c.x,y:n.y*l.y-o.scrollTop*l.y+c.y}}function lO(t){return Array.from(t.getClientRects())}function NP(t){return Ss(er(t)).left+uf(t).scrollLeft}function cO(t){let e=er(t),n=uf(t),i=t.ownerDocument.body,r=qa(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),s=qa(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight),a=-n.scrollLeft+NP(t),o=-n.scrollTop;return Cn(i).direction==="rtl"&&(a+=qa(e.clientWidth,i.clientWidth)-r),{width:r,height:s,x:a,y:o}}function uO(t,e){let n=dn(t),i=er(t),r=n.visualViewport,s=i.clientWidth,a=i.clientHeight,o=0,l=0;if(r){s=r.width,a=r.height;let c=$w();(!c||c&&e==="fixed")&&(o=r.offsetLeft,l=r.offsetTop)}return{width:s,height:a,x:o,y:l}}function dO(t,e){let n=Ss(t,!0,e==="fixed"),i=n.top+t.clientTop,r=n.left+t.clientLeft,s=wi(t)?Ba(t):Ar(1),a=t.clientWidth*s.x,o=t.clientHeight*s.y,l=r*s.x,c=i*s.y;return{width:a,height:o,x:l,y:c}}function oP(t,e,n){let i;if(e==="viewport")i=uO(t,n);else if(e==="document")i=cO(er(t));else if(Yi(e))i=dO(e,n);else{let r=IP(t);i={...e,x:e.x-r.x,y:e.y-r.y}}return CP(i)}function DP(t,e){let n=Ga(t);return n===e||!Yi(n)||cf(n)?!1:Cn(n).position==="fixed"||DP(n,e)}function pO(t,e){let n=e.get(t);if(n)return n;let i=gc(t,[],!1).filter(o=>Yi(o)&&Nr(o)!=="body"),r=null,s=Cn(t).position==="fixed",a=s?Ga(t):t;for(;Yi(a)&&!cf(a);){let o=Cn(a),l=Cw(a);!l&&o.position==="fixed"&&(r=null),(s?!l&&!r:!l&&o.position==="static"&&!!r&&["absolute","fixed"].includes(r.position)||su(a)&&!l&&DP(t,a))?i=i.filter(u=>u!==a):r=o,a=Ga(a)}return e.set(t,i),i}function hO(t){let{element:e,boundary:n,rootBoundary:i,strategy:r}=t,a=[...n==="clippingAncestors"?pO(e,this._c):[].concat(n),i],o=a[0],l=a.reduce((c,u)=>{let d=oP(e,u,r);return c.top=qa(d.top,c.top),c.right=lw(d.right,c.right),c.bottom=lw(d.bottom,c.bottom),c.left=qa(d.left,c.left),c},oP(e,o,r));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function fO(t){let{width:e,height:n}=LP(t);return{width:e,height:n}}function mO(t,e,n,i){let r=wi(e),s=er(e),a=n==="fixed",o=Ss(t,!0,a,e),l={scrollLeft:0,scrollTop:0},c=Ar(0);if(r||!r&&!a)if((Nr(e)!=="body"||su(s))&&(l=uf(e)),r){let v=Ss(e,!0,a,e);c.x=v.x+e.clientLeft,c.y=v.y+e.clientTop}else s&&(c.x=NP(s));let u=o.left+l.scrollLeft-c.x,d=o.top+l.scrollTop-c.y,[p,h,y]=AP(i);return p&&(u+=h,d+=y,r&&(u+=e.clientLeft,d+=e.clientTop)),{x:u,y:d,width:o.width,height:o.height}}function lP(t,e){return!wi(t)||Cn(t).position==="fixed"?null:e?e(t):t.offsetParent}function OP(t,e){let n=dn(t);if(!wi(t))return n;let i=lP(t,e);for(;i&&iO(i)&&Cn(i).position==="static";)i=lP(i,e);return i&&(Nr(i)==="html"||Nr(i)==="body"&&Cn(i).position==="static"&&!Cw(i))?n:i||MP(t)||n}function vO(t){return Cn(t).direction==="rtl"}function _O(t,e){let n=null,i,r=er(t);function s(){var o;clearTimeout(i),(o=n)==null||o.disconnect(),n=null}function a(o,l){o===void 0&&(o=!1),l===void 0&&(l=1),s();let{left:c,top:u,width:d,height:p}=t.getBoundingClientRect();if(o||e(),!d||!p)return;let h=mh(u),y=mh(r.clientWidth-(c+d)),v=mh(r.clientHeight-(u+p)),w=mh(c),f={rootMargin:-h+"px "+-y+"px "+-v+"px "+-w+"px",threshold:qa(0,lw(1,l))||1},g=!0;function x(T){let L=T[0].intersectionRatio;if(L!==l){if(!g)return a();L?a(!1,L):i=setTimeout(()=>{a(!1,1e-7)},100)}g=!1}try{n=new IntersectionObserver(x,{...f,root:r.ownerDocument})}catch{n=new IntersectionObserver(x,f)}n.observe(t)}return a(!0),s}function wO(t,e,n,i){i===void 0&&(i={});let{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:o=typeof IntersectionObserver=="function",animationFrame:l=!1}=i,c=Mw(t),u=r||s?[...c?gc(c):[],...gc(e)]:[];u.forEach(m=>{r&&m.addEventListener("scroll",n,{passive:!0}),s&&m.addEventListener("resize",n)});let d=c&&o?_O(c,n):null,p=-1,h=null;a&&(h=new ResizeObserver(m=>{let[f]=m;f&&f.target===c&&h&&(h.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var g;(g=h)==null||g.observe(e)})),n()}),c&&!l&&h.observe(c),h.observe(e));let y,v=l?Ss(t):null;l&&w();function w(){let m=Ss(t);v&&(m.x!==v.x||m.y!==v.y||m.width!==v.width||m.height!==v.height)&&n(),v=m,y=requestAnimationFrame(w)}return n(),()=>{var m;u.forEach(f=>{r&&f.removeEventListener("scroll",n),s&&f.removeEventListener("resize",n)}),d?.(),(m=h)==null||m.disconnect(),h=null,l&&cancelAnimationFrame(y)}}function YS(t,e,n){if(t)return S(t,e,n)}function ve(t,e,n){t.hasAttribute(e)||t.setAttribute(e,n)}function Vr(t,e){if(t.hasAttribute("aria-label")||t.hasAttribute("data-no-label"))return;function n(){Z(t,"aria-label",e())}N?n():b(n)}function VP(t,e,n){for(;e;){if(e===t)return!0;if(n?.(e))break;e=e.parentElement}return!1}function Dr(t,e){S(t,"pointerup",n=>{n.button===0&&e(n)}),S(t,"keydown",n=>{Ql(n)&&e(n)})}function Rw(t){return Na(t)&&(t.touches.length>1||t.changedTouches.length>1)}function Eh(t){if(N)return t();let e=Bl(),n=window.requestAnimationFrame(()=>{et(t,e),n=-1});return()=>void window.cancelAnimationFrame(n)}function FP(t,e,n,{offsetVarName:i,xOffset:r,yOffset:s,...a}){if(!t)return;let o=n.replace(" ","-").replace("-center","");if(lt(t,"visibility",e?null:"hidden"),!e)return;let l=u=>n.includes("left")?`calc(-1 * ${u})`:u,c=u=>n.includes("top")?`calc(-1 * ${u})`:u;return wO(e,t,()=>{bO(e,t,{placement:o,...a}).then(({x:u,y:d})=>{Object.assign(t.style,{top:`calc(${d+"px"} + ${c(s?s+"px":`var(--${i}-y-offset, 0px)`)})`,left:`calc(${u+"px"} + ${l(r?r+"px":`var(--${i}-x-offset, 0px)`)})`})})})}function xO(t){return getComputedStyle(t).animationName!=="none"}function kO(t,e,n){var i=null,r=null,s=n&&n.leading,a=n&&n.trailing;s==null&&(s=!0),a==null&&(a=!s),s==!0&&(a=!1);var o=function(){i&&(clearTimeout(i),i=null)},l=function(){var u=r;o(),u&&u()},c=function(){var u=s&&!i,d=this,p=arguments;if(r=function(){return t.apply(d,p)},i||(i=setTimeout(function(){if(i=null,a)return r()},e)),u)return u=!1,r()};return c.cancel=o,c.flush=l,c}function EO(t,e,n){var i=null,r=null,s=function(){i&&(clearTimeout(i),r=null,i=null)},a=function(){var l=r;s(),l&&l()},o=function(){if(!e)return t.apply(this,arguments);var l=this,c=arguments,u=n&&!i;if(s(),r=function(){t.apply(l,c)},i=setTimeout(function(){if(i=null,!u){var d=r;return r=null,d()}},e),u)return r()};return o.cancel=s,o.flush=a,o}function io(t){return t?.$$PROVIDER_TYPE==="VIDEO"}function zP(t){return!N&&t instanceof HTMLAudioElement}function UP(t){return!N&&t instanceof HTMLVideoElement}function jP(t){return zP(t)||UP(t)}function $O(t){return t.replace(/Shift\+(\d)/g,(e,n)=>CO[n-1])}function Iw({src:t,type:e}){return F(t)?qP.test(t)||BP.has(e)||t.startsWith("blob:")&&e==="audio/object":e==="audio/object"}function Aw(t){return F(t.src)?WP.test(t.src)||KP.has(t.type)||t.src.startsWith("blob:")&&t.type==="video/object"||xs(t)&&(N||nh()):t.type==="video/object"}function xs({src:t,type:e}){return F(t)&&GP.test(t)||YP.has(e)}function hh(t){return F(t.src)&&(Iw(t)||Aw(t)||xs(t))}function P_(t){return!N&&typeof window.MediaStream<"u"&&t instanceof window.MediaStream}function _i(t){return t instanceof Error?t:Error(JSON.stringify(t))}function Ki(t,e){if(!t)throw Error(e||"Assertion failed.")}function rw(t,e){if(!(t&&e))throw Error("[vidstack] media not ready")}function dP(t,e){if(!e?.supported)throw Error("[vidstack] no fullscreen support")}function At(t,e=2){return Number(t.toFixed(e))}function th(t){return String(t).split(".")[1]?.length??0}function Nw(t,e,n){return Math.max(t,Math.min(n,e))}function gh(t,e){Z(t,"data-focus",e),Z(t,"data-hocus",e)}function pP(t,e){Z(t,"data-hocus",e),Z(t,"data-hover",e)}function JP(t,e){return fetch(t,e).then(n=>n.text()).then(n=>{let i=OO(n);if(i)return JP(/^https?:/.test(i)?i:new URL(i,t).href,e);let r=/EXT-X-PLAYLIST-TYPE:\s*VOD/.test(n)?"on-demand":"live";return r==="live"&&VO(n)>=10&&(/#EXT-X-DVR-ENABLED:\s*true/.test(n)||n.includes("#EXT-X-DISCONTINUITY"))?"live:dvr":r})}function OO(t){let e=t.match(/#EXT-X-STREAM-INF:[^\n]+(\n[^\n]+)*/g);return e?e[0].split(` +`)[1].trim():null}function VO(t){let e=t.split(` +`);for(let n of e)if(n.startsWith("#EXT-X-TARGETDURATION")){let i=parseFloat(n.split(":")[1]);if(!isNaN(i))return i}return-1}function hP(t){return(qe(t)?t:[!F(t)&&"src"in t?t:{src:t}]).map(({src:e,type:n,...i})=>({src:e,type:n??(F(e)?e1.get(e):null)??(!F(e)||e.startsWith("blob:")?"video/object":e.includes("youtube")?"video/youtube":e.includes("vimeo")?"video/vimeo":"?"),...i})).sort(e=>e.type==="?"?1:-1)}function fP(t,e){return t?.src===e?.src&&t?.type===e?.type}function WO(t){return t?"true":"false"}function Gt(t){return()=>WO(t())}function mP(t,e,n){let i=e-t,r=n-t;return i>0?r/i:0}function KO(t,e,n,i){return Nw(t,At(n,th(i)),e)}function GO(t,e,n,i){let r=Nw(0,n,1),s=e-t,a=s*r,o=a/i,l=i*o;return t+l}function sw(t,e){let n=String(t),i=n.length;if(i=3600?sw(s,2):s,c=sw(a,2);return r>0||i?`${o}:${l}:${c}`:`${l}:${c}`}function bc(t){let e=[],{hours:n,minutes:i,seconds:r}=t1(t);return n>0&&e.push(`${n} hour`),i>0&&e.push(`${i} min`),(r>0||e.length===0)&&e.push(`${r} sec`),e.join(" ")}function Dw(t,{clamp:e,offset:n,orientation:i}){let r=getComputedStyle(t),s=parseFloat(r.width),a=parseFloat(r.height),o={top:null,right:null,bottom:null,left:null};if(o[i==="horizontal"?"bottom":"left"]=`calc(100% + var(--media-slider-preview-offset, ${n}px))`,i==="horizontal"){let l=s/2;if(!e)o.left=`calc(var(--slider-pointer) - ${l}px)`;else{let c=`max(0px, calc(var(--slider-pointer) - ${l}px))`,u=`calc(100% - ${s}px)`;o.left=`min(${c}, ${u})`}}else{let l=a/2;if(!e)o.bottom=`calc(var(--slider-pointer) - ${l}px)`;else{let c=`max(${l}px, calc(var(--slider-pointer) - ${l}px))`,u=`calc(100% - ${a}px)`;o.bottom=`min(${c}, ${u})`}}Object.assign(t.style,o)}function C3(t){return ke.isValidElement(t)&&t.type===P3}function $3(t,e){let n={...e};for(let i in e){let r=t[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?n[i]=(...o)=>{s(...o),r(...o)}:r&&(n[i]=r):i==="style"?n[i]={...r,...s}:i==="className"&&(n[i]=[r,s].filter(Boolean).join(" "))}return{...t,...n}}function r1(t){return t?.$$PROVIDER_TYPE==="REMOTION"}function ye(t,e){let n=Mr(Ns);return pe((e?.current?.$state||n||R3)[t])}var ke,P2,C2,$2,M2,R2,L2,I2,A2,N2,D2,O2,Y,QS,mc,un,XS,ZS,JS,Kt,Pn,Ts,_h,wh,N,V2,ph,tP,uc,S_,xP,Pw,oe,fh,H2,q2,B2,W2,K2,G2,Y2,W,nP,iP,rP,ln,Q2,Ns,X2,ru,Ka,lw,qa,kh,mh,Ar,nO,rO,aO,gO,yO,bO,Qi,Th,au,Sh,cw,Ph,Lw,Ch,hc,$h,Mh,TO,SO,cn,Rh,HP,cP,PO,uP,uw,CO,Lh,qP,BP,WP,KP,GP,YP,Ih,vc,QP,ZP,Ah,Nh,iw,MO,RO,Dh,dw,pw,Oh,hw,fw,LO,mw,gw,IO,Vh,pn,AO,NO,Ee,he,DO,e1,yw,_w,FO,zO,UO,Ya,Fh,zh,Uh,Wa,jO,jh,Hh,yc,tt,HO,qO,BO,_c,qh,Bh,Wh,Kh,Gh,Yh,Qh,Xh,Zh,df,gP,ww,wc,pf,bi,Xi,Gi,vh,Jh,Qa,ef,YO,QO,XO,Ps,ZO,JO,e3,Xa,xc,kc,Za,t3,n3,hf,Zi,ct,i3,vP,bw,r3,s3,ou,a3,Ji,o3,l3,c3,Cs,tf,nf,fc,Ec,xw,Or,u3,d3,n1,Ja,p3,h3,f3,eo,m3,g3,Ow,$s,v3,y3,Vw,Ms,_3,w3,Fw,Rs,b3,x3,zw,Ls,k3,E3,Uw,Is,rf,kw,sf,Tc,Sc,T3,S3,Ew,As,af,Pc,Cc,of,$c,Mc,Rc,Lc,Ic,Ac,Nc,Dc,Oc,Vc,Fc,zc,Uc,jc,Hc,qc,Bc,Wc,Kc,Gc,Yc,Qc,Xc,Zc,Jc,eu,tu,nu,lf,to,iu,i1,Tw,P3,M3,U,yP,R3,Wt=Ue(()=>{"use strict";"use client";ke=$(z(),1);Lt();C2=Symbol(0);P2=C2;$2=Symbol(0),M2=Symbol(0),R2=Symbol(0),L2=Symbol(0),I2=Symbol(0),A2=Symbol(0),N2=Symbol(0),D2=Symbol(0),O2=Symbol(0),Y={_add:$2,_remove:M2,_reset:R2,_select:L2,_readonly:I2,_setReadonly:A2,_onReset:N2,_onRemove:D2,_onUserSelect:O2},mc=class extends La{constructor(){super(...arguments),this._items=[],this[QS]=!1}get length(){return this._items.length}get readonly(){return this[Y._readonly]}toArray(){return[...this._items]}[(QS=Y._readonly,Symbol.iterator)](){return this._items.values()}[Y._add](e,n){let i=this._items.length;""+i in this||Object.defineProperty(this,i,{get(){return this._items[i]}}),!this._items.includes(e)&&(this._items.push(e),this.dispatchEvent(new j("add",{detail:e,trigger:n})))}[Y._remove](e,n){let i=this._items.indexOf(e);i>=0&&(this[Y._onRemove]?.(e,n),this._items.splice(i,1),this.dispatchEvent(new j("remove",{detail:e,trigger:n})))}[Y._reset](e){for(let n of[...this._items])this[Y._remove](n,e);this._items=[],this[Y._setReadonly](!1,e),this[Y._onReset]?.()}[Y._setReadonly](e,n){this[Y._readonly]!==e&&(this[Y._readonly]=e,this.dispatchEvent(new j("readonly-change",{detail:e,trigger:n})))}},un={fullscreenEnabled:0,fullscreenElement:1,requestFullscreen:2,exitFullscreen:3,fullscreenchange:4,fullscreenerror:5,fullscreen:6},XS=["webkitFullscreenEnabled","webkitFullscreenElement","webkitRequestFullscreen","webkitExitFullscreen","webkitfullscreenchange","webkitfullscreenerror","-webkit-full-screen"],ZS=["mozFullScreenEnabled","mozFullScreenElement","mozRequestFullScreen","mozCancelFullScreen","mozfullscreenchange","mozfullscreenerror","-moz-full-screen"],JS=["msFullscreenEnabled","msFullscreenElement","msRequestFullscreen","msExitFullscreen","MSFullscreenChange","MSFullscreenError","-ms-fullscreen"],Kt=typeof window<"u"&&typeof window.document<"u"?window.document:{},Pn="fullscreenEnabled"in Kt&&Object.keys(un)||XS[0]in Kt&&XS||ZS[0]in Kt&&ZS||JS[0]in Kt&&JS||[],Ts={requestFullscreen:function(t){return t[Pn[un.requestFullscreen]]()},requestFullscreenFunction:function(t){return t[Pn[un.requestFullscreen]]},get exitFullscreen(){return Kt[Pn[un.exitFullscreen]].bind(Kt)},get fullscreenPseudoClass(){return":"+Pn[un.fullscreen]},addEventListener:function(t,e,n){return Kt.addEventListener(Pn[un[t]],e,n)},removeEventListener:function(t,e,n){return Kt.removeEventListener(Pn[un[t]],e,n)},get fullscreenEnabled(){return!!Kt[Pn[un.fullscreenEnabled]]},set fullscreenEnabled(t){},get fullscreenElement(){return Kt[Pn[un.fullscreenElement]]},set fullscreenElement(t){},get onfullscreenchange(){return Kt[("on"+Pn[un.fullscreenchange]).toLowerCase()]},set onfullscreenchange(t){return Kt[("on"+Pn[un.fullscreenchange]).toLowerCase()]=t},get onfullscreenerror(){return Kt[("on"+Pn[un.fullscreenerror]).toLowerCase()]},set onfullscreenerror(t){return Kt[("on"+Pn[un.fullscreenerror]).toLowerCase()]=t}},_h=Ts.fullscreenEnabled,wh=class extends Mt{constructor(){super(...arguments),this._listening=!1,this._active=!1}get active(){return this._active}get supported(){return _h}onConnect(){S(Ts,"fullscreenchange",this._onFullscreenChange.bind(this)),S(Ts,"fullscreenerror",this._onFullscreenError.bind(this)),G(this._onDisconnect.bind(this))}async _onDisconnect(){_h&&await this.exit()}_onFullscreenChange(e){let n=nw(this.el);n!==this._active&&(n||(this._listening=!1),this._active=n,this.dispatch("fullscreen-change",{detail:n,trigger:e}))}_onFullscreenError(e){this._listening&&(this.dispatch("fullscreen-error",{detail:null,trigger:e}),this._listening=!1)}async enter(){try{return this._listening=!0,!this.el||nw(this.el)?void 0:(eP(),Ts.requestFullscreen(this.el))}catch(e){throw this._listening=!1,e}}async exit(){if(!(!this.el||!nw(this.el)))return eP(),Ts.exitFullscreen()}};N=typeof document>"u",V2=N?"":navigator?.userAgent.toLowerCase()||"",ph=!N&&/iphone|ipad|ipod|ios|crios|fxios/i.test(V2),tP=!N&&/(iphone|ipod)/gi.test(navigator?.platform||""),uc=!N&&!!window.chrome,S_=!N&&(!!window.safari||ph);xP=class kP extends Mt{constructor(){super(...arguments),this._type=D(this._getScreenOrientation()),this._locked=D(!1)}get type(){return this._type()}get locked(){return this._locked()}get portrait(){return this._type().startsWith("portrait")}get landscape(){return this._type().startsWith("landscape")}get supported(){return kP.supported}onConnect(){if(this.supported)S(screen.orientation,"change",this._onOrientationChange.bind(this));else{let e=window.matchMedia("(orientation: landscape)");e.onchange=this._onOrientationChange.bind(this),G(()=>e.onchange=null)}G(this._onDisconnect.bind(this))}async _onDisconnect(){this.supported&&this._locked()&&await this.unlock()}_onOrientationChange(e){this._type.set(this._getScreenOrientation()),this.dispatch("orientation-change",{detail:{orientation:C(this._type),lock:this._currentLock},trigger:e})}async lock(e){C(this._locked)||this._currentLock===e||(this._assertScreenOrientationAPI(),await screen.orientation.lock(e),this._locked.set(!0),this._currentLock=e)}async unlock(){C(this._locked)&&(this._assertScreenOrientationAPI(),this._currentLock=void 0,await screen.orientation.unlock(),this._locked.set(!1))}_assertScreenOrientationAPI(){if(!this.supported)throw Error("[vidstack] no orientation API")}_getScreenOrientation(){return N?"portrait-primary":this.supported?window.screen.orientation.type:window.innerWidth>=window.innerHeight?"landscape-primary":"portrait-primary"}};xP.supported=Sw();Pw=xP,oe=class{get length(){return this._ranges.length}constructor(e,n){qe(e)?this._ranges=e:!Le(e)&&!Le(n)?this._ranges=[[e,n]]:this._ranges=[]}start(e){return this._ranges[e][0]??1/0}end(e){return this._ranges[e][1]??1/0}};fh={};H2=Symbol(0),q2=Symbol(0),B2=Symbol(0),W2=Symbol(0),K2=Symbol(0),G2=Symbol(0),Y2=Symbol(0),W={_crossOrigin:H2,_readyState:q2,_updateActiveCues:B2,_canLoad:W2,_onModeChange:K2,_native:G2,_nativeHLS:Y2};ln=class extends La{constructor(e){super(),this.id="",this.label="",this.language="",this.default=!1,this._canLoad=!1,this._currentTime=0,this._mode="disabled",this._metadata={},this._regions=[],this._cues=[],this._activeCues=[],this[nP]=0,this[iP]=null,this[rP]=null;for(let n of Object.keys(e))this[n]=e[n];this.type||(this.type="vtt"),!N&&e.content?Promise.resolve().then(()=>(oc(),ac)).then(({parseText:n,VTTCue:i,VTTRegion:r})=>{!F(e.content)||e.type==="json"?(this._parseJSON(e.content,i,r),this.readyState!==3&&this._readyState()):n(e.content,{type:e.type}).then(({cues:s,regions:a})=>{this._cues=s,this._regions=a,this._readyState()})}):e.src||(this[W._readyState]=2)}static createId(e){return`id::${e.type}-${e.kind}-${e.src??e.label}`}get metadata(){return this._metadata}get regions(){return this._regions}get cues(){return this._cues}get activeCues(){return this._activeCues}get readyState(){return this[W._readyState]}get mode(){return this._mode}set mode(e){this.setMode(e)}addCue(e,n){let i=0,r=this._cues.length;for(i=0;i=0){let r=this._activeCues.includes(e);this._cues.splice(i,1),this[W._native]?.track.removeCue(e),this.dispatchEvent(new j("remove-cue",{detail:e,trigger:n})),r&&this[W._updateActiveCues](this._currentTime,n)}}setMode(e,n){this._mode!==e&&(this._mode=e,e==="disabled"?(this._activeCues=[],this._activeCuesChanged()):this.readyState===2?this[W._updateActiveCues](this._currentTime,n):this._load(),this.dispatchEvent(new j("mode-change",{detail:this,trigger:n})),this[W._onModeChange]?.())}[(nP=W._readyState,iP=W._onModeChange,rP=W._native,W._updateActiveCues)](e,n){if(this._currentTime=e,this.mode==="disabled"||!this._cues.length)return;let i=[];for(let s=0,a=this._cues.length;s0)){this[W._readyState]=1,this.dispatchEvent(new j("load-start"));try{let{parseResponse:e,VTTCue:n,VTTRegion:i}=await Promise.resolve().then(()=>(oc(),ac)),r=this[W._crossOrigin]?.(),s=fetch(this.src,{headers:this.type==="json"?{"Content-Type":"application/json"}:void 0,credentials:bh(r)});if(this.type==="json")this._parseJSON(await(await s).text(),n,i);else{let{errors:a,metadata:o,regions:l,cues:c}=await e(s,{type:this.type,encoding:this.encoding});if(a[0]?.code===0)throw a[0];this._metadata=o,this._regions=l,this._cues=c}this._readyState()}catch(e){this._errorState(e)}}}_readyState(){if(this[W._readyState]=2,!this.src||this.type!=="vtt"){let n=this[W._native]?.track;if(n)for(let i of this._cues)n.addCue(i)}let e=new j("load");this[W._updateActiveCues](this._currentTime,e),this.dispatchEvent(e)}_errorState(e){this[W._readyState]=3,this.dispatchEvent(new j("error",{detail:e}))}_parseJSON(e,n,i){try{let{regions:r,cues:s}=EP(e,n,i);this._regions=r,this._cues=s}catch(r){this._errorState(r)}}_activeCuesChanged(e){this.dispatchEvent(new j("cue-change",{trigger:e}))}},Q2=/captions|subtitles/;Ns=new Xn({artist:"",audioTrack:null,audioTracks:[],autoPlay:!1,autoPlayError:null,buffered:new oe,canLoad:!1,canLoadPoster:!1,canFullscreen:!1,canOrientScreen:Sw(),canPictureInPicture:!1,canPlay:!1,clipStartTime:0,clipEndTime:0,controls:!1,controlsVisible:!1,crossOrigin:null,ended:!1,error:null,fullscreen:!1,loop:!1,logLevel:"silent",mediaType:"unknown",muted:!1,paused:!0,played:new oe,playing:!1,playsInline:!1,pictureInPicture:!1,preload:"metadata",playbackRate:1,qualities:[],quality:null,autoQuality:!1,canSetQuality:!0,canSetPlaybackRate:!0,canSetVolume:!1,seekable:new oe,seeking:!1,source:{src:"",type:""},sources:[],started:!1,textTracks:[],textTrack:null,get hasCaptions(){return this.textTracks.filter(We).length>0},volume:1,waiting:!1,realCurrentTime:0,get currentTime(){return this.clipStartTime>0?Math.max(0,Math.min(this.realCurrentTime-this.clipStartTime,this.duration)):this.realCurrentTime},providedDuration:-1,intrinsicDuration:0,get realDuration(){return this.providedDuration>0?this.providedDuration:this.intrinsicDuration},get duration(){return this.clipEndTime>0?this.clipEndTime-this.clipStartTime:Math.max(0,this.realDuration-this.clipStartTime)},get title(){return this.providedTitle||this.inferredTitle},get poster(){return this.providedPoster||this.inferredPoster},get viewType(){return this.providedViewType!=="unknown"?this.providedViewType:this.inferredViewType},get streamType(){return this.providedStreamType!=="unknown"?this.providedStreamType:this.inferredStreamType},get currentSrc(){return this.source},get bufferedStart(){let t=aw(this.buffered)??0;return Math.max(0,t-this.clipStartTime)},get bufferedEnd(){let t=ow(this.buffered)??0;return Math.min(this.duration,Math.max(0,t-this.clipStartTime))},get seekableStart(){let t=aw(this.seekable)??0;return Math.max(0,t-this.clipStartTime)},get seekableEnd(){let t=this.canPlay?ow(this.seekable)??1/0:0;return this.clipEndTime>0?Math.min(this.clipEndTime,Math.max(0,t-this.clipStartTime)):t},get seekableWindow(){return Math.max(0,this.seekableEnd-this.seekableStart)},canAirPlay:!1,canGoogleCast:!1,remotePlaybackState:"disconnected",remotePlaybackType:"none",remotePlaybackLoader:null,remotePlaybackInfo:null,get isAirPlayConnected(){return this.remotePlaybackType==="airplay"&&this.remotePlaybackState==="connected"},get isGoogleCastConnected(){return this.remotePlaybackType==="google-cast"&&this.remotePlaybackState==="connected"},pointer:"fine",orientation:"landscape",width:0,height:0,mediaWidth:0,mediaHeight:0,lastKeyboardAction:null,userBehindLiveEdge:!1,liveEdgeTolerance:10,minLiveDVRWindow:60,get canSeek(){return/unknown|on-demand|:dvr/.test(this.streamType)&&Number.isFinite(this.seekableWindow)&&(!this.live||/:dvr/.test(this.streamType)&&this.seekableWindow>=this.minLiveDVRWindow)},get live(){return this.streamType.includes("live")||!Number.isFinite(this.realDuration)},get liveEdgeStart(){return this.live&&Number.isFinite(this.seekableEnd)?Math.max(0,(this.liveSyncPosition??this.seekableEnd)-this.liveEdgeTolerance):0},get liveEdge(){return this.live&&(!this.canSeek||!this.userBehindLiveEdge&&this.currentTime>=this.liveEdgeStart)},get liveEdgeWindow(){return this.live&&Number.isFinite(this.seekableEnd)?this.seekableEnd-this.liveEdgeStart:0},autoPlaying:!1,providedTitle:"",inferredTitle:"",providedPoster:"",inferredPoster:"",inferredViewType:"unknown",providedViewType:"unknown",providedStreamType:"unknown",inferredStreamType:"unknown",liveSyncPosition:null}),X2=new Set(["audioTrack","audioTracks","autoPlayError","autoPlaying","autoQuality","buffered","canPlay","ended","error","inferredPoster","inferredStreamType","inferredTitle","intrinsicDuration","liveSyncPosition","paused","played","playing","qualities","quality","realCurrentTime","seekable","seeking","started","userBehindLiveEdge","waiting"]);ru=vi();Ka=class{constructor(e=void 0){this._logger=e,this._target=null,this._player=null,this._prevTrackIndex=-1}setTarget(e){this._target=e}getPlayer(e){return this._player?this._player:((e??this._target)?.dispatchEvent(new j("find-media-player",{detail:n=>void(this._player=n),bubbles:!0,composed:!0})),this._player)}setPlayer(e){this._player=e}startLoading(e){this._dispatchRequest("media-start-loading",e)}startLoadingPoster(e){this._dispatchRequest("media-poster-start-loading",e)}requestAirPlay(e){this._dispatchRequest("media-airplay-request",e)}requestGoogleCast(e){this._dispatchRequest("media-google-cast-request",e)}play(e){this._dispatchRequest("media-play-request",e)}pause(e){this._dispatchRequest("media-pause-request",e)}mute(e){this._dispatchRequest("media-mute-request",e)}unmute(e){this._dispatchRequest("media-unmute-request",e)}enterFullscreen(e,n){this._dispatchRequest("media-enter-fullscreen-request",n,e)}exitFullscreen(e,n){this._dispatchRequest("media-exit-fullscreen-request",n,e)}lockScreenOrientation(e,n){this._dispatchRequest("media-orientation-lock-request",n,e)}unlockScreenOrientation(e){this._dispatchRequest("media-orientation-unlock-request",e)}enterPictureInPicture(e){this._dispatchRequest("media-enter-pip-request",e)}exitPictureInPicture(e){this._dispatchRequest("media-exit-pip-request",e)}seeking(e,n){this._dispatchRequest("media-seeking-request",n,e)}seek(e,n){this._dispatchRequest("media-seek-request",n,e)}seekToLiveEdge(e){this._dispatchRequest("media-live-edge-request",e)}changeVolume(e,n){this._dispatchRequest("media-volume-change-request",n,Math.max(0,Math.min(1,e)))}changeAudioTrack(e,n){this._dispatchRequest("media-audio-track-change-request",n,e)}changeQuality(e,n){this._dispatchRequest("media-quality-change-request",n,e)}requestAutoQuality(e){this.changeQuality(-1,e)}changeTextTrackMode(e,n,i){this._dispatchRequest("media-text-track-change-request",i,{index:e,mode:n})}changePlaybackRate(e,n){this._dispatchRequest("media-rate-change-request",n,e)}resumeControls(e){this._dispatchRequest("media-resume-controls-request",e)}pauseControls(e){this._dispatchRequest("media-pause-controls-request",e)}togglePaused(e){let n=this.getPlayer(e?.target);n&&(n.state.paused?this.play(e):this.pause(e))}toggleControls(e){let n=this.getPlayer(e?.target);n&&(n.controls.showing?n.controls.hide(0,e):n.controls.show(0,e))}toggleMuted(e){let n=this.getPlayer(e?.target);n&&(n.state.muted?this.unmute(e):this.mute(e))}toggleFullscreen(e,n){let i=this.getPlayer(n?.target);i&&(i.state.fullscreen?this.exitFullscreen(e,n):this.enterFullscreen(e,n))}togglePictureInPicture(e){let n=this.getPlayer(e?.target);n&&(n.state.pictureInPicture?this.exitPictureInPicture(e):this.enterPictureInPicture(e))}disableCaptions(e){let n=this.getPlayer(e?.target);if(!n)return;let i=n.state.textTracks,r=n.state.textTrack;if(r){let s=i.indexOf(r);this.changeTextTrackMode(s,"disabled",e)}}toggleCaptions(e){let n=this.getPlayer(e?.target);if(!n)return;let i=n.state.textTracks,r=n.state.textTrack;if(r){let s=i.indexOf(r);this.changeTextTrackMode(s,"disabled",e),this._prevTrackIndex=s}else{let s=this._prevTrackIndex;(!i[s]||!We(i[s]))&&(s=-1),s===-1&&(s=i.findIndex(a=>We(a)&&a.default)),s===-1&&(s=i.findIndex(a=>We(a))),s>=0&&this.changeTextTrackMode(s,"showing",e),this._prevTrackIndex=-1}}_dispatchRequest(e,n,i){let r=new j(e,{bubbles:!0,composed:!0,cancelable:!0,detail:i,trigger:n}),s=n?.target||null;s&&s instanceof q&&(s=s.el),s=!s||s===document||s===window||s===document.body||this._player?.el&&s instanceof Node&&!this._player.el.contains(s)?this._target??this.getPlayer()?.el:s??this._target,this._player?e==="media-play-request"&&!this._player.state.canLoad?s?.dispatchEvent(r):this._player.canPlayQueue._enqueue(e,()=>s?.dispatchEvent(r)):s?.dispatchEvent(r)}_noPlayerWarning(e){}},lw=Math.min,qa=Math.max,kh=Math.round,mh=Math.floor,Ar=t=>({x:t,y:t});nO=async(t,e,n)=>{let{placement:i="bottom",strategy:r="absolute",middleware:s=[],platform:a}=n,o=s.filter(Boolean),l=await(a.isRTL==null?void 0:a.isRTL(e)),c=await a.getElementRects({reference:t,floating:e,strategy:r}),{x:u,y:d}=sP(c,i,l),p=i,h={},y=0;for(let v=0;v{let i=new Map,r={platform:yO,...n},s={...r.platform,_c:i};return nO(t,e,{...r,platform:s})};Qi=class extends Mt{},Th=class extends Qi{constructor(){super(...arguments),this._idleTimer=-2,this._pausedTracking=!1,this._hideOnMouseLeave=D(!1),this._isMouseOutside=D(!1),this._focusedItem=null,this.defaultDelay=2e3}get hideOnMouseLeave(){let{hideControlsOnMouseLeave:e}=this.$props;return this._hideOnMouseLeave()||e()}set hideOnMouseLeave(e){this._hideOnMouseLeave.set(e)}get showing(){return this.$state.controlsVisible()}show(e=0,n){this._clearIdleTimer(),this._pausedTracking||this._changeVisibility(!0,e,n)}hide(e=this.defaultDelay,n){this._clearIdleTimer(),this._pausedTracking||this._changeVisibility(!1,e,n)}pause(e){this._pausedTracking=!0,this._clearIdleTimer(),this._changeVisibility(!0,0,e)}resume(e){this._pausedTracking=!1,!this.$state.paused()&&this._changeVisibility(!1,this.defaultDelay,e)}onConnect(){b(this._watchMouse.bind(this)),b(this._watchPaused.bind(this));let e=this._onPlay.bind(this),n=this._onPause.bind(this);this.listen("can-play",i=>this.show(0,i)),this.listen("play",e),this.listen("pause",n),this.listen("auto-play-fail",n)}_watchMouse(){let{started:e,pointer:n,paused:i}=this.$state;if(!e()||n()!=="fine")return;let r=this.hideOnMouseLeave;(!r||!this._isMouseOutside())&&b(()=>{i()||this.listen("pointermove",this._onStopIdle.bind(this))}),r&&(this.listen("mouseenter",this._onMouseEnter.bind(this)),this.listen("mouseleave",this._onMouseLeave.bind(this)))}_watchPaused(){let{paused:e,started:n,autoPlayError:i}=this.$state;if(e()||i()&&!n())return;let r=this._onStopIdle.bind(this);b(()=>{let s=this.$state.pointer(),a=s==="coarse",o=[a?"touchend":"pointerup","keydown"];for(let l of o)this.listen(l,r,{passive:!1})})}_onPlay(e){this.show(0,e),this.hide(void 0,e)}_onPause(e){this.show(0,e)}_onMouseEnter(e){this._isMouseOutside.set(!1),this.show(0,e),this.hide(void 0,e)}_onMouseLeave(e){this._isMouseOutside.set(!0),this.hide(0,e)}_clearIdleTimer(){window.clearTimeout(this._idleTimer),this._idleTimer=-1}_onStopIdle(e){e.MEDIA_GESTURE||this._pausedTracking||Rw(e)||(Hi(e)&&(e.key==="Escape"?(this.el?.focus(),this._focusedItem=null):this._focusedItem&&(e.preventDefault(),requestAnimationFrame(()=>{this._focusedItem?.focus(),this._focusedItem=null}))),this.show(0,e),this.hide(this.defaultDelay,e))}_changeVisibility(e,n,i){if(n===0){this._onChange(e,i);return}this._idleTimer=window.setTimeout(()=>{this.scope&&this._onChange(e&&!this._pausedTracking,i)},n)}_onChange(e,n){this.$state.controlsVisible()!==e&&(this.$state.controlsVisible.set(e),!e&&document.activeElement&&this.el?.contains(document.activeElement)&&(this._focusedItem=document.activeElement,requestAnimationFrame(()=>this.el?.focus())),this.dispatch("controls-change",{detail:e,trigger:n}))}},au=kO;Sh=class{constructor(){this.playerId="vds-player",this.mediaId=null,this._data={volume:null,muted:null,time:null,lang:null,captions:null,rate:null},this.saveTime=au(()=>{if(N||!this.mediaId)return;let e=(this._data.time??0).toString();localStorage.setItem(this.mediaId,e)},1e3)}async getVolume(){return this._data.volume}async setVolume(e){this._data.volume=e,this.save()}async getMuted(){return this._data.muted}async setMuted(e){this._data.muted=e,this.save()}async getTime(){return this._data.time}async setTime(e){this._data.time=e,this.saveTime()}async getLang(){return this._data.lang}async setLang(e){this._data.lang=e,this.save()}async getCaptions(){return this._data.captions}async setCaptions(e){this._data.captions=e,this.save()}async getPlaybackRate(){return this._data.rate}async setPlaybackRate(e){this._data.rate=e,this.save()}onChange(e,n,i="vds-player"){let r=i?localStorage.getItem(i):null,s=n?localStorage.getItem(n):null;this.playerId=i,this.mediaId=n,this._data={volume:null,muted:null,lang:null,captions:null,...r?JSON.parse(r):{},time:s?+s:null}}save(){if(N||!this.playerId)return;let e=JSON.stringify({...this._data,time:void 0});localStorage.setItem(this.playerId,e)}},cw=class{constructor(){this.priority=0,this._display=!0,this._video=null,this._track=null,this._tracks=new Set}canRender(e,n){return!!n}attach(e){this._video=e,e&&(e.textTracks.onchange=this._onChange.bind(this))}addTrack(e){this._tracks.add(e),this._attachTrack(e)}removeTrack(e){e[W._native]?.remove?.(),e[W._native]=null,this._tracks.delete(e)}changeTrack(e){let n=e?.[W._native];n&&n.track.mode!=="showing"&&(n.track.mode="showing"),this._track=e}setDisplay(e){this._display=e,this._onChange()}detach(){this._video&&(this._video.textTracks.onchange=null);for(let e of this._tracks)this.removeTrack(e);this._tracks.clear(),this._video=null,this._track=null}_attachTrack(e){var i;if(!this._video)return;let n=e[i=W._native]??(e[i]=this._createTrackElement(e));n instanceof HTMLElement&&(this._video.append(n),n.track.mode=n.default?"showing":"hidden")}_createTrackElement(e){let n=document.createElement("track"),i=e.default||e.mode==="showing",r=e.src&&e.type==="vtt";if(n.id=e.id,r)n.src=e.src;else{let s=function(){URL.revokeObjectURL(this.src),this.removeEventListener("load",s),this.removeEventListener("error",s)},a=new Blob([`WEBVTT +`],{type:"text/vtt"});n.src=URL.createObjectURL(a),n.addEventListener("load",s),n.addEventListener("error",s)}return n.label=e.label,n.kind=e.kind,n.default=i,e.language&&(n.srclang=e.language),i&&!r&&this._copyCues(e,n.track),n}_copyCues(e,n){if(!(e.src&&e.type==="vtt"||n.cues?.length))for(let i of e.cues)n.addCue(i)}_onChange(e){for(let n of this._tracks){let i=n[W._native]?.track;if(!i)continue;if(!this._display){i.mode="disabled";continue}let r=i.mode==="showing";r&&this._copyCues(n,i),n.setMode(r?"showing":"disabled",e)}}},Ph=class{constructor(e){this._media=e,this._video=null,this._renderers=[],this._nativeDisplay=!1,this._nativeRenderer=null,this._customRenderer=null;let n=e.textTracks;this._textTracks=n,b(this._watchControls.bind(this)),G(this._detach.bind(this)),S(n,"add",this._onAddTrack.bind(this)),S(n,"remove",this._onRemoveTrack.bind(this)),S(n,"mode-change",this._update.bind(this))}_watchControls(){let{$state:e,$iosControls:n}=this._media;this._nativeDisplay=e.controls()||n(),this._update()}add(e){this._renderers.push(e),this._update()}remove(e){e.detach(),this._renderers.splice(this._renderers.indexOf(e),1),this._update()}_attachVideo(e){requestAnimationFrame(()=>{if(this._video=e,e){this._nativeRenderer=new cw,this._nativeRenderer.attach(e);for(let n of this._textTracks)this._addNativeTrack(n)}this._update()})}_addNativeTrack(e){We(e)&&this._nativeRenderer?.addTrack(e)}_removeNativeTrack(e){We(e)&&this._nativeRenderer?.removeTrack(e)}_onAddTrack(e){this._addNativeTrack(e.detail)}_onRemoveTrack(e){this._removeNativeTrack(e.detail)}_update(){let e=this._textTracks.selected;if(this._video&&(this._nativeDisplay||e?.[W._nativeHLS])){this._customRenderer?.changeTrack(null),this._nativeRenderer?.setDisplay(!0),this._nativeRenderer?.changeTrack(e);return}if(this._nativeRenderer?.setDisplay(!1),this._nativeRenderer?.changeTrack(null),!e){this._customRenderer?.changeTrack(null);return}let n=this._renderers.sort((i,r)=>i.priority-r.priority).find(i=>i.canRender(e,this._video));this._customRenderer!==n&&(this._customRenderer?.detach(),n?.attach(this._video),this._customRenderer=n??null),n?.changeTrack(e)}_detach(){this._nativeRenderer?.detach(),this._nativeRenderer=null,this._customRenderer?.detach(),this._customRenderer=null}},Lw=EO;Ch=class extends mc{constructor(){super(),this._canLoad=!1,this._defaults={},this._storage=null,this._preferredLang=null,this._selectCaptions=Lw(async()=>{if(!this._canLoad||this.selected||await this._storage?.getCaptions()===!1)return;!this._preferredLang&&this._storage&&(this._preferredLang=await this._storage.getLang());let e=this._preferredLang&&this._items.find(i=>We(i)&&i.language===this._preferredLang),n=this._defaults.captions;e?e.mode="showing":n&&n&&(n.mode="showing"),this._storage?.setLang?.(this._preferredLang??n?.language??null)},300),this._onTrackModeChangeBind=this._onTrackModeChange.bind(this)}get selected(){return this._items.find(n=>n.mode==="showing"&&We(n))??null}get preferredLang(){return this._preferredLang}set preferredLang(e){this._preferredLang=e}add(e,n){let i=e instanceof ln,r=i?e:new ln(e),s=e.kind==="captions"||e.kind==="subtitles"?"captions":e.kind;return this._defaults[s]&&e.default&&delete e.default,r.addEventListener("mode-change",this._onTrackModeChangeBind),this[Y._add](r,n),r[W._crossOrigin]=this[W._crossOrigin],this._canLoad&&r[W._canLoad](),e.default&&(this._defaults[s]=r,s!=="captions"?r.mode="showing":this._selectCaptions()),this}remove(e,n){if(this._items.includes(e))return e===this._defaults[e.kind]&&delete this._defaults[e.kind],e.mode="disabled",e[W._onModeChange]=null,e.removeEventListener("mode-change",this._onTrackModeChangeBind),this[Y._remove](e,n),this}clear(e){for(let n of[...this._items])this.remove(n,e);return this}getById(e){return this._items.find(n=>n.id===e)??null}getByKind(e){let n=Array.isArray(e)?e:[e];return this._items.filter(i=>n.includes(i.kind))}[W._canLoad](){if(!this._canLoad){for(let e of this._items)e[W._canLoad]();this._canLoad=!0,this._selectCaptions()}}_onTrackModeChange(e){let n=e.detail;if(this._storage&&We(n)&&(this._storage.setCaptions?.(n.mode==="showing"),this._storage?.setLang?.(this._preferredLang??n?.language??null)),n.mode==="showing"){let i=We(n)?["captions","subtitles"]:[n.kind];for(let r of this._items)r.mode==="showing"&&r!=n&&i.includes(r.kind)&&(r.mode="disabled")}this.dispatchEvent(new j("mode-change",{detail:e.detail,trigger:e}))}setStorage(e){this._storage=e}},hc=Symbol(0),$h=class extends mc{get selected(){return this._items.find(e=>e.selected)??null}get selectedIndex(){return this._items.findIndex(e=>e.selected)}[Y._onRemove](e,n){this[Y._select](e,!1,n)}[Y._add](e,n){e[hc]=!1,Object.defineProperty(e,"selected",{get(){return this[hc]},set:i=>{this.readonly||(this[Y._onUserSelect]?.(),this[Y._select](e,i))}}),super[Y._add](e,n)}[Y._select](e,n,i){if(n===e?.[hc])return;let r=this.selected;e&&(e[hc]=n),(n?r!==e:r===e)&&(r&&(r[hc]=!1),this.dispatchEvent(new j("change",{detail:{prev:r,current:this.selected},trigger:i})))}},Mh=class extends $h{getById(e){return e===""?null:this._items.find(n=>n.id===e)??null}},TO=Symbol(0),SO=Symbol(0),cn={_setAuto:TO,_enableAuto:SO},Rh=class extends $h{constructor(){super(...arguments),this._auto=!1,this.switch="current"}get auto(){return this._auto||this.readonly}[Y._onUserSelect](){this[cn._setAuto](!1)}[Y._onReset](e){this[cn._setAuto](!1,e)}autoSelect(e){this.readonly||this._auto||!this[cn._enableAuto]||(this[cn._enableAuto]?.(),this[cn._setAuto](!0,e))}[cn._setAuto](e,n){this._auto!==e&&(this._auto=e,this.dispatchEvent(new j("auto-change",{detail:e,trigger:n})))}};HP={togglePaused:"k Space",toggleMuted:"m",toggleFullscreen:"f",togglePictureInPicture:"i",toggleCaptions:"c",seekBackward:"j J ArrowLeft",seekForward:"l L ArrowRight",volumeUp:"ArrowUp",volumeDown:"ArrowDown",speedUp:">",slowDown:"<"},cP=new Set(["Shift","Alt","Meta","Control"]),PO='button, [role="button"]',uP='input, textarea, select, [contenteditable], [role^="menuitem"], [role="timer"]',uw=class extends Qi{constructor(e){super(),this._media=e,this._timeSlider=null}onConnect(){b(this._onTargetChange.bind(this))}_onTargetChange(){let{keyDisabled:e,keyTarget:n}=this.$props;if(e())return;let i=n()==="player"?this.el:document,r=D(!1);i===this.el?(this.listen("focusin",()=>r.set(!0)),this.listen("focusout",s=>{this.el.contains(s.target)||r.set(!1)})):(C(r)||r.set(document.querySelector("[data-media-player]")===this.el),S(document,"focusin",s=>{let a=s.composedPath().find(o=>o instanceof Element&&o.localName==="media-player");a!==void 0&&r.set(this.el===a)})),b(()=>{r()&&(S(i,"keyup",this._onKeyUp.bind(this)),S(i,"keydown",this._onKeyDown.bind(this)),S(i,"keydown",this._onPreventVideoKeys.bind(this),{capture:!0}))})}_onKeyUp(e){let n=document.activeElement;if(!e.key||!this.$state.canSeek()||n?.matches(uP))return;let{method:i,value:r}=this._getMatchingMethod(e);if(!F(r)&&!qe(r)){r?.callback(e);return}i?.startsWith("seek")&&(e.preventDefault(),e.stopPropagation(),this._timeSlider?(this._forwardTimeKeyboardEvent(e,i==="seekForward"),this._timeSlider=null):(this._media.remote.seek(this._seekTotal,e),this._seekTotal=void 0)),i?.startsWith("volume")&&this.el.querySelector("[data-media-volume-slider]")?.dispatchEvent(new KeyboardEvent("keyup",{key:i==="volumeUp"?"Up":"Down",shiftKey:e.shiftKey,trigger:e}))}_onKeyDown(e){if(!e.key||cP.has(e.key))return;let n=document.activeElement;if(n?.matches(uP)||Ql(e)&&n?.matches(PO))return;let{method:i,value:r}=this._getMatchingMethod(e);if(!F(r)&&!qe(r)){r?.callback(e);return}if(!i&&!e.metaKey&&/[0-9]/.test(e.key)){e.preventDefault(),e.stopPropagation(),this._media.remote.seek(this.$state.duration()/10*Number(e.key),e);return}if(i){switch(e.preventDefault(),e.stopPropagation(),i){case"seekForward":case"seekBackward":this._seeking(e,i,i==="seekForward");break;case"volumeUp":case"volumeDown":let s=this.el.querySelector("[data-media-volume-slider]");if(s)s.dispatchEvent(new KeyboardEvent("keydown",{key:i==="volumeUp"?"Up":"Down",shiftKey:e.shiftKey,trigger:e}));else{let o=e.shiftKey?.1:.05;this._media.remote.changeVolume(this.$state.volume()+(i==="volumeUp"?+o:-o),e)}break;case"toggleFullscreen":this._media.remote.toggleFullscreen("prefer-media",e);break;case"speedUp":case"slowDown":let a=this.$state.playbackRate();this._media.remote.changePlaybackRate(Math.max(.25,Math.min(2,a+(i==="speedUp"?.25:-.25))),e);break;default:this._media.remote[i]?.(e)}this.$state.lastKeyboardAction.set({action:i,event:e})}}_onPreventVideoKeys(e){jP(e.target)&&this._getMatchingMethod(e).method&&e.preventDefault()}_getMatchingMethod(e){let n={...this.$props.keyShortcuts(),...this._media.ariaKeys},i=Object.keys(n).find(r=>{let s=n[r],a=qe(s)?s.join(" "):F(s)?s:s?.keys;return(qe(a)?a:a?.split(" "))?.some(o=>$O(o).replace(/Control/g,"Ctrl").split("+").every(l=>cP.has(l)?e[l.toLowerCase()+"Key"]:e.key===l.replace("Space"," ")))});return{method:i,value:i?n[i]:null}}_calcSeekAmount(e,n){let i=e.shiftKey?10:5;return this._seekTotal=Math.max(0,Math.min((this._seekTotal??this.$state.currentTime())+(n==="seekForward"?+i:-i),this.$state.duration()))}_forwardTimeKeyboardEvent(e,n){this._timeSlider?.dispatchEvent(new KeyboardEvent(e.type,{key:n?"Right":"Left",shiftKey:e.shiftKey,trigger:e}))}_seeking(e,n,i){this.$state.canSeek()&&(this._timeSlider||(this._timeSlider=this.el.querySelector("[data-media-time-slider]")),this._timeSlider?this._forwardTimeKeyboardEvent(e,i):this._media.remote.seeking(this._calcSeekAmount(e,n),e))}},CO=["!","@","#","$","%","^","&","*","(",")"];Lh=class extends Mt{constructor(e){super(),this._shortcut=e}onAttach(e){let{$props:n,ariaKeys:i}=le(),r=e.getAttribute("aria-keyshortcuts");if(r){i[this._shortcut]=r,N||G(()=>{delete i[this._shortcut]});return}let s=n.keyShortcuts()[this._shortcut];if(s){let a=qe(s)?s.join(" "):F(s)?s:s?.keys;e.setAttribute("aria-keyshortcuts",qe(a)?a.join(" "):a)}}},qP=/\.(m4a|m4b|mp4a|mpga|mp2|mp2a|mp3|m2a|m3a|wav|weba|aac|oga|spx)($|\?)/i,BP=new Set(["audio/mpeg","audio/ogg","audio/3gp","audio/mp4","audio/webm","audio/flac"]),WP=/\.(mp4|og[gv]|webm|mov|m4v)(#t=[,\d+]+)?($|\?)/i,KP=new Set(["video/mp4","video/webm","video/3gp","video/ogg","video/avi","video/mpeg"]),GP=/\.(m3u8)($|\?)/i,YP=new Set(["application/vnd.apple.mpegurl","audio/mpegurl","audio/x-mpegurl","application/x-mpegurl","video/x-mpegurl","video/mpegurl","application/mpegurl"]);Ih=class{constructor(){this.name="audio"}canPlay(e){return Iw(e)?N||e.type==="?"||F2(this.target,e.type):!1}mediaType(){return"audio"}async load(e){if(N)throw Error("[vidstack] can not load audio provider server-side");return new(await Promise.resolve().then(()=>(IS(),LS))).AudioProvider(this.target,e)}},vc=class{constructor(){this.name="video"}canPlay(e){return Aw(e)?N||e.type==="?"||z2(this.target,e.type):!1}mediaType(){return"video"}async load(e){if(N)throw Error("[vidstack] can not load video provider server-side");return new(await Promise.resolve().then(()=>(D_(),AS))).VideoProvider(this.target,e)}},QP=class XP extends vc{constructor(){super(...arguments),this.name="hls"}canPlay(e){return XP.supported&&xs(e)}async load(e){if(N)throw Error("[vidstack] can not load hls provider server-side");return new(await Promise.resolve().then(()=>(DS(),NS))).HLSProvider(this.target,e)}};QP.supported=ah();ZP=QP,Ah=class{constructor(){this.name="vimeo"}preconnect(){let e=["https://i.vimeocdn.com","https://f.vimeocdn.com","https://fresnel.vimeocdn.com"];for(let n of e)Jn(n)}canPlay(e){return F(e.src)&&e.type==="video/vimeo"}mediaType(){return"video"}async load(e){if(N)throw Error("[vidstack] can not load vimeo provider server-side");return new(await Promise.resolve().then(()=>(zS(),FS))).VimeoProvider(this.target,e)}async loadPoster(e,n,i){let{resolveVimeoVideoId:r,getVimeoVideoInfo:s}=await Promise.resolve().then(()=>(H_(),VS));if(!F(e.src))return null;let{videoId:a}=r(e.src);return a?s(a,i).then(o=>o?o.poster:null):null}},Nh=class{constructor(){this.name="youtube"}preconnect(){let e=["https://www.google.com","https://i.ytimg.com","https://googleads.g.doubleclick.net","https://static.doubleclick.net"];for(let n of e)Jn(n)}canPlay(e){return F(e.src)&&e.type==="video/youtube"}mediaType(){return"video"}async load(e){if(N)throw Error("[vidstack] can not load youtube provider server-side");return new(await Promise.resolve().then(()=>(HS(),jS))).YouTubeProvider(this.target,e)}async loadPoster(e,n,i){let{findYouTubePoster:r,resolveYouTubeVideoId:s}=await Promise.resolve().then(()=>(K_(),US)),a=F(e.src)&&s(e.src);return a?r(a,i):null}},iw=Symbol(0),MO=["autoPlay","canAirPlay","canFullscreen","canGoogleCast","canLoad","canLoadPoster","canPictureInPicture","canPlay","canSeek","ended","fullscreen","isAirPlayConnected","isGoogleCastConnected","live","liveEdge","loop","mediaType","muted","paused","pictureInPicture","playing","playsInline","remotePlaybackState","remotePlaybackType","seeking","started","streamType","viewType","waiting"],RO={artist:"",autoplay:!1,autoPlay:!1,clipStartTime:0,clipEndTime:0,controls:!1,currentTime:0,crossorigin:null,crossOrigin:null,duration:-1,fullscreenOrientation:"landscape",googleCast:{},load:"visible",posterLoad:"visible",logLevel:"silent",loop:!1,muted:!1,paused:!0,playsinline:!1,playsInline:!1,playbackRate:1,poster:"",preload:"metadata",preferNativeHLS:!1,src:"",title:"",controlsDelay:2e3,hideControlsOnMouseLeave:!1,viewType:"unknown",streamType:"unknown",volume:1,liveEdgeTolerance:10,minLiveDVRWindow:60,keyDisabled:!1,keyTarget:"player",keyShortcuts:HP,storage:null},Dh=class extends Qi{constructor(e,n){super(),this._type=e,this._callback=n}async onAttach(e){if(N)return;let n=this.$props[this._type]();if(n==="eager")requestAnimationFrame(this._callback);else if(n==="idle")o_(this._callback);else if(n==="visible"){let i,r=new IntersectionObserver(s=>{this.scope&&s[0].isIntersecting&&(i?.(),i=void 0,this._callback())});r.observe(e),i=G(()=>r.disconnect())}}},dw=class{constructor(e,n){this._handle=e,this._media=n,this._notify=(i,...r)=>{N||this._handle(new j(i,{detail:r?.[0],trigger:r?.[1]}))}}async _ready(e,n){if(!N)return Aa(async()=>{this._media;let{autoPlay:i,canPlay:r,started:s,duration:a,seekable:o,buffered:l,remotePlaybackInfo:c,playsInline:u}=this._media.$state;if(r())return;let d={duration:e?.duration??a(),seekable:e?.seekable??o(),buffered:e?.buffered??l(),provider:this._media.$provider()};this._notify("can-play",d,n),Zn();let p=this._media.$provider(),{storage:h}=this._media,{muted:y,volume:v,clipStartTime:w,playbackRate:m}=this._media.$props,f=c()?.savedState?.currentTime,g=c()?.savedState?.paused===!1,x=f??await h?.getTime()??w(),T=g||i();p&&(p.setVolume(await h?.getVolume()??v()),p.setMuted(await h?.getMuted()??y()),p.setPlaybackRate?.(await h?.getPlaybackRate()??m()),p.setPlaysInline?.(u()),x>0&&p.setCurrentTime(x)),r()&&T&&!s()&&await this._attemptAutoplay(n),c.set(null)})}async _attemptAutoplay(e){let{player:n,$state:{autoPlaying:i,muted:r}}=this._media;i.set(!0);let s=new j("auto-play-attempt",{trigger:e});try{await n.play(s)}catch{}}},pw=class{constructor(){this._queue=new Map}_enqueue(e,n){this._queue.set(e,n)}_serve(e){let n=this._peek(e);return this._queue.delete(e),n}_peek(e){return this._queue.get(e)}_delete(e){this._queue.delete(e)}_clear(){this._queue.clear()}},Oh=class{constructor(){this._serving=!1,this._pending=qi(),this._queue=new Map}get _size(){return this._queue.size}get _isServing(){return this._serving}async _waitForFlush(){this._serving||await this._pending.promise}_enqueue(e,n){if(this._serving){n();return}this._queue.delete(e),this._queue.set(e,n)}_serve(e){this._queue.get(e)?.(),this._queue.delete(e)}_start(){this._flush(),this._serving=!0,this._queue.size>0&&this._flush()}_stop(){this._serving=!1}_reset(){this._stop(),this._queue.clear(),this._release()}_flush(){for(let e of this._queue.keys())this._serve(e);this._release()}_release(){this._pending.resolve(),this._pending=qi()}};hw=class extends Qi{constructor(e,n,i){super(),this._stateMgr=e,this._request=n,this._media=i,this._providerQueue=new Oh,this._wasPIPActive=!1,this._$provider=i.$provider,this._controls=new Th,this._fullscreen=new wh,this._orientation=new Pw}onAttach(){this.listen("fullscreen-change",this._onFullscreenChange.bind(this))}onConnect(){let e=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),n=this._handleRequest.bind(this);for(let i of e)i.startsWith("media-")&&this.listen(i,n);this._attachLoadPlayListener(),b(this._watchProvider.bind(this)),b(this._onControlsDelayChange.bind(this)),b(this._onAirPlaySupportChange.bind(this)),b(this._onGoogleCastSupportChange.bind(this)),b(this._onFullscreenSupportChange.bind(this)),b(this._onPiPSupportChange.bind(this))}onDestroy(){this._providerQueue._reset()}_attachLoadPlayListener(){let{load:e}=this.$props,{canLoad:n}=this.$state;if(e()!=="play"||n())return;let i=this.listen("media-play-request",r=>{this._handleLoadPlayStrategy(r),i()})}_watchProvider(){let e=this._$provider(),n=this.$state.canPlay();return e&&n&&this._providerQueue._start(),()=>{this._providerQueue._stop()}}_handleRequest(e){e.stopPropagation(),!e.defaultPrevented&&this[e.type]&&(C(this._$provider)?this[e.type](e):this._providerQueue._enqueue(e.type,()=>{C(this._$provider)&&this[e.type](e)}))}async _play(e){if(N)return;let{canPlay:n,paused:i,autoPlaying:r}=this.$state;if(!this._handleLoadPlayStrategy(e)&&!(!C(i)&&!this._request._looping)){e&&this._request._queue._enqueue("media-play-request",e);try{let s=C(this._$provider);return rw(s,C(n)),await s.play()}catch(s){let a=this.createEvent("play-fail",{detail:_i(s),trigger:e});throw a.autoPlay=r(),this._stateMgr._handle(a),s}}}_handleLoadPlayStrategy(e){let{load:n}=this.$props,{canLoad:i}=this.$state;if(n()==="play"&&!i()){let r=this.createEvent("media-start-loading",{trigger:e});return this.dispatchEvent(r),this._providerQueue._enqueue("media-play-request",async()=>{try{await this._play(r)}catch{}}),!0}return!1}async _pause(e){if(N)return;let{canPlay:n,paused:i}=this.$state;if(!C(i)){e&&this._request._queue._enqueue("media-pause-request",e);try{let r=C(this._$provider);return rw(r,C(n)),await r.pause()}catch(r){throw this._request._queue._delete("media-pause-request"),r}}}_seekToLiveEdge(e){if(N)return;let{canPlay:n,live:i,liveEdge:r,canSeek:s,liveSyncPosition:a,seekableEnd:o,userBehindLiveEdge:l}=this.$state;if(l.set(!1),C(()=>!i()||r()||!s()))return;let c=C(this._$provider);rw(c,C(n)),e&&this._request._queue._enqueue("media-seek-request",e);let u=o()-2;c.setCurrentTime(Math.min(u,a()??u))}async _enterFullscreen(e="prefer-media",n){if(N)return;let i=this._getFullscreenAdapter(e);if(dP(e,i),!i.active)return C(this.$state.pictureInPicture)&&(this._wasPIPActive=!0,await this._exitPictureInPicture(n)),n&&this._request._queue._enqueue("media-enter-fullscreen-request",n),i.enter()}async _exitFullscreen(e="prefer-media",n){if(N)return;let i=this._getFullscreenAdapter(e);if(dP(e,i),!!i.active){n&&this._request._queue._enqueue("media-exit-fullscreen-request",n);try{let r=await i.exit();return this._wasPIPActive&&C(this.$state.canPictureInPicture)&&await this._enterPictureInPicture(),r}finally{this._wasPIPActive=!1}}}_getFullscreenAdapter(e){let n=C(this._$provider);return e==="prefer-media"&&this._fullscreen.supported||e==="media"?this._fullscreen:n?.fullscreen}async _enterPictureInPicture(e){if(!N&&(this._throwIfPIPNotSupported(),!this.$state.pictureInPicture()))return e&&this._request._queue._enqueue("media-enter-pip-request",e),await this._$provider().pictureInPicture.enter()}async _exitPictureInPicture(e){if(!N&&(this._throwIfPIPNotSupported(),!!this.$state.pictureInPicture()))return e&&this._request._queue._enqueue("media-exit-pip-request",e),await this._$provider().pictureInPicture.exit()}_throwIfPIPNotSupported(){if(!this.$state.canPictureInPicture())throw Error("[vidstack] no pip support")}_onControlsDelayChange(){this._controls.defaultDelay=this.$props.controlsDelay()}_onAirPlaySupportChange(){let{canAirPlay:e}=this.$state,n=!!this._$provider()?.airPlay?.supported;e.set(n)}_onGoogleCastSupportChange(){let{canGoogleCast:e,source:n}=this.$state,i=uc&&!ph&&hh(n());e.set(i)}_onFullscreenSupportChange(){let{canFullscreen:e}=this.$state,n=this._fullscreen.supported||!!this._$provider()?.fullscreen?.supported;e.set(n)}_onPiPSupportChange(){let{canPictureInPicture:e}=this.$state,n=!!this._$provider()?.pictureInPicture?.supported;e.set(n)}async"media-airplay-request"(e){try{await this._requestAirPlay(e)}catch{}}async _requestAirPlay(e){try{let n=this._$provider()?.airPlay;if(!n?.supported)throw Error("No AirPlay adapter.");return e&&this._request._queue._enqueue("media-airplay-request",e),await n.prompt()}catch(n){throw this._request._queue._delete("media-airplay-request"),n}}async"media-google-cast-request"(e){try{await this._requestGoogleCast(e)}catch{}}async _requestGoogleCast(e){try{let{canGoogleCast:n}=this.$state;if(!C(n))throw new Error("Cast not available.");if(Jn("https://www.gstatic.com"),!this._googleCastLoader){let r=await Promise.resolve().then(()=>(ew(),GS)).then(function(s){return s.d});this._googleCastLoader=new r.GoogleCastLoader}await this._googleCastLoader.prompt(this._media),e&&this._request._queue._enqueue("media-google-cast-request",e);let i=C(this.$state.remotePlaybackState)!=="disconnected";i&&this.$state.remotePlaybackInfo.set(r=>({...r,savedState:{paused:C(this.$state.paused),currentTime:C(this.$state.currentTime)}})),this.$state.remotePlaybackLoader.set(i?this._googleCastLoader:null)}catch(n){throw this._request._queue._delete("media-google-cast-request"),n}}"media-audio-track-change-request"(e){if(this._media.audioTracks.readonly)return;let n=e.detail,i=this._media.audioTracks[n];if(i){let r=e.type;this._request._queue._enqueue(r,e),i.selected=!0}}async"media-enter-fullscreen-request"(e){try{await this._enterFullscreen(e.detail,e)}catch(n){this._onFullscreenError(n,e)}}async"media-exit-fullscreen-request"(e){try{await this._exitFullscreen(e.detail,e)}catch(n){this._onFullscreenError(n,e)}}async _onFullscreenChange(e){let n=C(this.$props.fullscreenOrientation),i=e.detail;if(!(Le(n)||!this._orientation.supported))if(i){if(this._orientation.locked)return;this.dispatch("media-orientation-lock-request",{detail:n,trigger:e})}else this._orientation.locked&&this.dispatch("media-orientation-unlock-request",{trigger:e})}_onFullscreenError(e,n){this._stateMgr._handle(this.createEvent("fullscreen-error",{detail:_i(e)}))}async"media-orientation-lock-request"(e){let n=e.type;try{this._request._queue._enqueue(n,e),await this._orientation.lock(e.detail)}catch{this._request._queue._delete(n)}}async"media-orientation-unlock-request"(e){let n=e.type;try{this._request._queue._enqueue(n,e),await this._orientation.unlock()}catch{this._request._queue._delete(n)}}async"media-enter-pip-request"(e){try{await this._enterPictureInPicture(e)}catch(n){this._onPictureInPictureError(n,e)}}async"media-exit-pip-request"(e){try{await this._exitPictureInPicture(e)}catch(n){this._onPictureInPictureError(n,e)}}_onPictureInPictureError(e,n){this._stateMgr._handle(this.createEvent("picture-in-picture-error",{detail:_i(e)}))}"media-live-edge-request"(e){let{live:n,liveEdge:i,canSeek:r}=this.$state;if(!(!n()||i()||!r())){this._request._queue._enqueue("media-seek-request",e);try{this._seekToLiveEdge()}catch{this._request._queue._delete("media-seek-request")}}}async"media-loop-request"(e){try{this._request._looping=!0,this._request._replaying=!0,await this._play(e)}catch{this._request._looping=!1}}async"media-pause-request"(e){if(!this.$state.paused())try{await this._pause(e)}catch{}}async"media-play-request"(e){if(this.$state.paused())try{await this._play(e)}catch{}}"media-rate-change-request"(e){let{playbackRate:n,canSetPlaybackRate:i}=this.$state;if(n()===e.detail||!i())return;let r=this._$provider();r?.setPlaybackRate&&(this._request._queue._enqueue("media-rate-change-request",e),r.setPlaybackRate(e.detail))}"media-quality-change-request"(e){if(this._media.qualities.readonly)return;this._request._queue._enqueue("media-quality-change-request",e);let n=e.detail;if(n<0)this._media.qualities.autoSelect(e);else{let i=this._media.qualities[n];i&&(i.selected=!0)}}"media-pause-controls-request"(e){let n=e.type;this._request._queue._enqueue(n,e),this._controls.pause(e)}"media-resume-controls-request"(e){let n=e.type;this._request._queue._enqueue(n,e),this._controls.resume(e)}"media-seek-request"(e){let{seekableStart:n,seekableEnd:i,ended:r,canSeek:s,live:a,userBehindLiveEdge:o,clipStartTime:l}=this.$state;r()&&(this._request._replaying=!0);let c=e.type;this._request._seeking=!1,this._request._queue._delete(c);let u=Math.min(Math.max(n()+.1,e.detail+l()),i()-.1);!Number.isFinite(u)||!s()||(this._request._queue._enqueue(c,e),this._$provider().setCurrentTime(u),a()&&e.isOriginTrusted&&Math.abs(i()-u)>=2&&o.set(!0))}"media-seeking-request"(e){let n=e.type;this._request._queue._enqueue(n,e),this.$state.seeking.set(!0),this._request._seeking=!0}"media-start-loading"(e){if(this.$state.canLoad())return;let n=e.type;this._request._queue._enqueue(n,e),this._stateMgr._handle(this.createEvent("can-load"))}"media-poster-start-loading"(e){if(this.$state.canLoadPoster())return;let n=e.type;this._request._queue._enqueue(n,e),this._stateMgr._handle(this.createEvent("can-load-poster"))}"media-text-track-change-request"(e){let{index:n,mode:i}=e.detail,r=this._media.textTracks[n];if(r){let s=e.type;this._request._queue._enqueue(s,e),r.setMode(i,e)}}"media-mute-request"(e){if(this.$state.muted())return;let n=e.type;this._request._queue._enqueue(n,e),this._$provider().setMuted(!0)}"media-unmute-request"(e){let{muted:n,volume:i}=this.$state;if(!n())return;let r=e.type;this._request._queue._enqueue(r,e),this._media.$provider().setMuted(!1),i()===0&&(this._request._queue._enqueue(r,e),this._$provider().setVolume(.25))}"media-volume-change-request"(e){let{muted:n,volume:i}=this.$state,r=e.detail;if(i()===r)return;let s=e.type;this._request._queue._enqueue(s,e),this._$provider().setVolume(r),r>0&&n()&&(this._request._queue._enqueue(s,e),this._$provider().setMuted(!1))}_logError(e,n,i){}};fw=class{constructor(){this._seeking=!1,this._looping=!1,this._replaying=!1,this._queue=new pw}},LO=new Set(["auto-play","auto-play-fail","can-load","sources-change","source-change","load-start","abort","error","loaded-metadata","loaded-data","can-play","play","play-fail","pause","playing","seeking","seeked","waiting"]),mw=class extends Qi{constructor(e,n){super(),this._request=e,this._media=n,this._trackedEvents=new Map,this._clipEnded=!1,this._firingWaiting=!1,this._isPlayingOnDisconnect=!1,this.seeking=au(i=>{let{seeking:r,realCurrentTime:s,paused:a}=this.$state;r.set(!0),s.set(i.detail),this._satisfyRequest("media-seeking-request",i),a()&&(this._waitingTrigger=i,this._fireWaiting())},150,{leading:!0}),this._fireWaiting=Lw(()=>{if(!this._waitingTrigger)return;this._firingWaiting=!0;let{waiting:i,playing:r}=this.$state;i.set(!0),r.set(!1);let s=this.createEvent("waiting",{trigger:this._waitingTrigger});this._trackedEvents.set("waiting",s),this.dispatch(s),this._waitingTrigger=void 0,this._firingWaiting=!1},300)}onAttach(e){e.setAttribute("aria-busy","true"),this.listen("fullscreen-change",this["fullscreen-change"].bind(this)),this.listen("fullscreen-error",this["fullscreen-error"].bind(this)),this.listen("orientation-change",this["orientation-change"].bind(this))}onConnect(e){b(this._watchCanSetVolume.bind(this)),this._addTextTrackListeners(),this._addQualityListeners(),this._addAudioTrackListeners(),this._resumePlaybackOnConnect(),G(this._pausePlaybackOnDisconnect.bind(this))}_handle(e){if(!this.scope)return;let n=e.type;this[e.type]?.(e),N||(LO.has(n)&&this._trackedEvents.set(n,e),this.dispatch(e))}_resumePlaybackOnConnect(){this._isPlayingOnDisconnect&&(requestAnimationFrame(()=>{this.scope&&this._media.remote.play(new j("dom-connect"))}),this._isPlayingOnDisconnect=!1)}_pausePlaybackOnDisconnect(){this._isPlayingOnDisconnect||(this._isPlayingOnDisconnect=!this._media.$state.paused(),this._media.$provider()?.pause())}_resetTracking(){this._stopWaiting(),this._clipEnded=!1,this._request._replaying=!1,this._request._looping=!1,this._firingWaiting=!1,this._waitingTrigger=void 0,this._trackedEvents.clear()}_satisfyRequest(e,n){let i=this._request._queue._serve(e);i&&(n.request=i,n.triggers.add(i))}_addTextTrackListeners(){this._onTextTracksChange(),this._onTextTrackModeChange();let e=this._media.textTracks;S(e,"add",this._onTextTracksChange.bind(this)),S(e,"remove",this._onTextTracksChange.bind(this)),S(e,"mode-change",this._onTextTrackModeChange.bind(this))}_addQualityListeners(){let e=this._media.qualities;S(e,"add",this._onQualitiesChange.bind(this)),S(e,"remove",this._onQualitiesChange.bind(this)),S(e,"change",this._onQualityChange.bind(this)),S(e,"auto-change",this._onAutoQualityChange.bind(this)),S(e,"readonly-change",this._onCanSetQualityChange.bind(this))}_addAudioTrackListeners(){let e=this._media.audioTracks;S(e,"add",this._onAudioTracksChange.bind(this)),S(e,"remove",this._onAudioTracksChange.bind(this)),S(e,"change",this._onAudioTrackChange.bind(this))}_onTextTracksChange(e){let{textTracks:n}=this.$state;n.set(this._media.textTracks.toArray()),this.dispatch("text-tracks-change",{detail:n(),trigger:e})}_onTextTrackModeChange(e){e&&this._satisfyRequest("media-text-track-change-request",e);let n=this._media.textTracks.selected,{textTrack:i}=this.$state;i()!==n&&(i.set(n),this.dispatch("text-track-change",{detail:n,trigger:e}))}_onAudioTracksChange(e){let{audioTracks:n}=this.$state;n.set(this._media.audioTracks.toArray()),this.dispatch("audio-tracks-change",{detail:n(),trigger:e})}_onAudioTrackChange(e){let{audioTrack:n}=this.$state;n.set(this._media.audioTracks.selected),e&&this._satisfyRequest("media-audio-track-change-request",e),this.dispatch("audio-track-change",{detail:n(),trigger:e})}_onQualitiesChange(e){let{qualities:n}=this.$state;n.set(this._media.qualities.toArray()),this.dispatch("qualities-change",{detail:n(),trigger:e})}_onQualityChange(e){let{quality:n}=this.$state;n.set(this._media.qualities.selected),e&&this._satisfyRequest("media-quality-change-request",e),this.dispatch("quality-change",{detail:n(),trigger:e})}_onAutoQualityChange(){this.$state.autoQuality.set(this._media.qualities.auto)}_onCanSetQualityChange(){this.$state.canSetQuality.set(!this._media.qualities.readonly)}_watchCanSetVolume(){let{canSetVolume:e,isGoogleCastConnected:n}=this.$state;if(n()){e.set(!1);return}bP().then(e.set)}"provider-change"(e){let n=this._media.$provider(),i=e.detail;n?.type!==i?.type&&(n?.destroy?.(),n?.scope?.dispose(),this._media.$provider.set(e.detail),n&&e.detail===null&&this._resetMediaState(e))}"provider-loader-change"(e){}"auto-play"(e){this.$state.autoPlayError.set(null)}"auto-play-fail"(e){this.$state.autoPlayError.set(e.detail),this._resetTracking()}"can-load"(e){this.$state.canLoad.set(!0),this._trackedEvents.set("can-load",e),this._media.textTracks[W._canLoad](),this._satisfyRequest("media-start-loading",e)}"can-load-poster"(e){this.$state.canLoadPoster.set(!0),this._trackedEvents.set("can-load-poster",e),this._satisfyRequest("media-poster-start-loading",e)}"media-type-change"(e){let n=this._trackedEvents.get("source-change");n&&e.triggers.add(n);let i=this.$state.viewType();this.$state.mediaType.set(e.detail);let r=this.$state.providedViewType(),s=r==="unknown"?e.detail:r;i!==s&&(N?this.$state.inferredViewType.set(s):setTimeout(()=>{requestAnimationFrame(()=>{this.scope&&(this.$state.inferredViewType.set(e.detail),this.dispatch("view-type-change",{detail:s,trigger:e}))})},0))}"stream-type-change"(e){let n=this._trackedEvents.get("source-change");n&&e.triggers.add(n);let{streamType:i,inferredStreamType:r}=this.$state;r.set(e.detail),e.detail=i()}"rate-change"(e){let{storage:n}=this._media,{canPlay:i}=this.$state;this.$state.playbackRate.set(e.detail),this._satisfyRequest("media-rate-change-request",e),i()&&n?.setPlaybackRate?.(e.detail)}"remote-playback-change"(e){let{remotePlaybackState:n,remotePlaybackType:i}=this.$state,{type:r,state:s}=e.detail,a=s==="connected";i.set(r),n.set(s);let o=r==="airplay"?"media-airplay-request":"media-google-cast-request";if(a)this._satisfyRequest(o,e);else{let l=this._request._queue._peek(o);l&&(e.request=l,e.triggers.add(l))}}"sources-change"(e){this.$state.sources.set(e.detail)}"source-change"(e){let n=this._trackedEvents.get("sources-change");n&&e.triggers.add(n),this._resetMediaState(e),this._trackedEvents.set(e.type,e),this.$state.source.set(e.detail),this.el?.setAttribute("aria-busy","true")}_resetMediaState(e){this._media.audioTracks[Y._reset](e),this._media.qualities[Y._reset](e),this._resetTracking(),TP(this._media.$state)}abort(e){let n=this._trackedEvents.get("source-change");n&&e.triggers.add(n);let i=this._trackedEvents.get("can-load");i&&!e.triggers.hasType("can-load")&&e.triggers.add(i)}"load-start"(e){let n=this._trackedEvents.get("source-change");n&&e.triggers.add(n)}error(e){this.$state.error.set(e.detail);let n=this._trackedEvents.get("abort");n&&e.triggers.add(n)}"loaded-metadata"(e){let n=this._trackedEvents.get("load-start");n&&e.triggers.add(n)}"loaded-data"(e){let n=this._trackedEvents.get("load-start");n&&e.triggers.add(n)}"can-play"(e){let n=this._trackedEvents.get("loaded-metadata");n&&e.triggers.add(n),this._onCanPlayDetail(e.detail),this.el?.setAttribute("aria-busy","false")}"can-play-through"(e){this._onCanPlayDetail(e.detail);let n=this._trackedEvents.get("can-play");n&&e.triggers.add(n)}_onCanPlayDetail(e){let{seekable:n,seekableEnd:i,buffered:r,intrinsicDuration:s,canPlay:a}=this.$state;a.set(!0),r.set(e.buffered),n.set(e.seekable),s.set(i())}"duration-change"(e){let{live:n,intrinsicDuration:i}=this.$state,r=e.detail;n()||i.set(Number.isNaN(r)?0:r)}progress(e){let{buffered:n,seekable:i,live:r,intrinsicDuration:s,seekableEnd:a}=this.$state,o=e.detail;n.set(o.buffered),i.set(o.seekable),r()&&(s.set(a),this.dispatch("duration-change",{detail:a(),trigger:e}))}play(e){let{paused:n,autoPlayError:i,ended:r,autoPlaying:s,playsInline:a,pointer:o,muted:l,viewType:c}=this.$state;if(this._resetPlaybackIfNeeded(),!n()&&!this._request._looping){e.stopImmediatePropagation();return}e.autoPlay=s();let u=this._trackedEvents.get("waiting");u&&e.triggers.add(u),this._satisfyRequest("media-play-request",e),this._trackedEvents.set("play",e),n.set(!1),i.set(null),e.autoPlay&&(this._handle(this.createEvent("auto-play",{detail:{muted:l()},trigger:e})),s.set(!1)),(r()||this._request._replaying)&&(this._request._replaying=!1,r.set(!1),this._handle(this.createEvent("replay",{trigger:e}))),!a()&&c()==="video"&&o()==="coarse"&&this._media.remote.enterFullscreen("prefer-media",e),this._request._looping&&e.stopImmediatePropagation()}_resetPlaybackIfNeeded(e){if(!C(this._media.$provider))return;let{ended:i,seekableStart:r,clipStartTime:s,clipEndTime:a,realCurrentTime:o,duration:l}=this.$state,c=o()0&&o()>=a()||Math.abs(o()-l())<.1||i();return c&&this.dispatch("media-seek-request",{detail:(s()>0?0:r())+.1,trigger:e}),c}"play-fail"(e){let{muted:n,autoPlaying:i}=this.$state,r=this._trackedEvents.get("play");r&&e.triggers.add(r),this._satisfyRequest("media-play-request",e);let{paused:s,playing:a}=this.$state;s.set(!0),a.set(!1),this._resetTracking(),this._trackedEvents.set("play-fail",e),e.autoPlay&&(this._handle(this.createEvent("auto-play-fail",{detail:{muted:n(),error:e.detail},trigger:e})),i.set(!1))}playing(e){let n=this._trackedEvents.get("play"),i=this._trackedEvents.get("seeked");n?e.triggers.add(n):i&&e.triggers.add(i),setTimeout(()=>this._resetTracking(),0);let{paused:r,playing:s,live:a,liveSyncPosition:o,seekableEnd:l,started:c,currentTime:u,seeking:d,ended:p}=this.$state;if(r.set(!1),s.set(!0),d.set(!1),p.set(!1),this._request._looping){e.stopImmediatePropagation(),this._request._looping=!1;return}if(a()&&!c()&&u()===0){let h=o()??l()-2;Number.isFinite(h)&&this._media.$provider().setCurrentTime(h)}this.started(e)}started(e){let{started:n}=this.$state;n()||(n.set(!0),this._handle(this.createEvent("started",{trigger:e})))}pause(e){this.el?.isConnected||(this._isPlayingOnDisconnect=!0),this._satisfyRequest("media-pause-request",e);let n=this._trackedEvents.get("seeked");if(n&&e.triggers.add(n),this._clipEnded){e.stopImmediatePropagation(),this._handle(this.createEvent("end",{trigger:e})),this._clipEnded=!1;return}if(this._request._looping){e.stopImmediatePropagation();return}this._resetTracking();let{paused:i,playing:r}=this.$state;i.set(!0),r.set(!1)}"time-update"(e){if(this._request._looping){e.stopImmediatePropagation();return}let{realCurrentTime:n,played:i,waiting:r,clipEndTime:s,loop:a}=this.$state,o=s(),l=e.detail;n.set(l.currentTime),i.set(l.played),r.set(!1);for(let c of this._media.textTracks)c[W._updateActiveCues](l.currentTime,e);o>0&&l.currentTime>=o&&(a()&&(this._request._looping=!0),this._clipEnded=!0,this.dispatch("media-pause-request",{trigger:e})),this._saveTime()}_saveTime(){let{storage:e}=this._media,{canPlay:n,realCurrentTime:i}=this.$state;n()&&e?.setTime?.(i())}"volume-change"(e){let{storage:n}=this._media,{volume:i,muted:r,canPlay:s}=this.$state,a=e.detail;i.set(a.volume),r.set(a.muted||a.volume===0),this._satisfyRequest("media-volume-change-request",e),this._satisfyRequest(a.muted?"media-mute-request":"media-unmute-request",e),s()&&(n?.setVolume?.(i()),n?.setMuted?.(r()))}seeked(e){let{seeking:n,realCurrentTime:i,paused:r,duration:s,ended:a}=this.$state;if(this._request._seeking)n.set(!0),e.stopImmediatePropagation();else if(n()){let o=this._trackedEvents.get("waiting");o&&e.triggers.add(o);let l=this._trackedEvents.get("seeking");l&&!e.triggers.has(l)&&e.triggers.add(l),r()&&this._stopWaiting(),n.set(!1),e.detail!==s()&&a.set(!1),i.set(e.detail),this._satisfyRequest("media-seek-request",e);let c=e?.originEvent;c?.isTrusted&&!/seek/.test(c.type)&&this.started(e)}}waiting(e){this._firingWaiting||this._request._seeking||(e.stopImmediatePropagation(),this._waitingTrigger=e,this._fireWaiting())}end(e){let{loop:n}=this.$state;if(n()){setTimeout(()=>{requestAnimationFrame(()=>{this.dispatch("media-loop-request",{trigger:e})})},10);return}this._onEnded(e)}_onEnded(e){let{paused:n,seeking:i,ended:r,duration:s}=this.$state;n()||this.dispatch("pause",{trigger:e}),i()&&this.dispatch("seeked",{detail:s(),trigger:e}),r.set(!0),this._resetTracking(),this.dispatch("ended",{trigger:e})}_stopWaiting(){this._fireWaiting.cancel(),this.$state.waiting.set(!1)}"fullscreen-change"(e){let n=e.detail;this.$state.fullscreen.set(n),this._satisfyRequest(n?"media-enter-fullscreen-request":"media-exit-fullscreen-request",e)}"fullscreen-error"(e){this._satisfyRequest("media-enter-fullscreen-request",e),this._satisfyRequest("media-exit-fullscreen-request",e)}"orientation-change"(e){let n=e.detail.lock;this._satisfyRequest(n?"media-orientation-lock-request":"media-orientation-unlock-request",e)}"picture-in-picture-change"(e){let n=e.detail;this.$state.pictureInPicture.set(n),this._satisfyRequest(n?"media-enter-pip-request":"media-exit-pip-request",e)}"picture-in-picture-error"(e){this._satisfyRequest("media-enter-pip-request",e),this._satisfyRequest("media-exit-pip-request",e)}"title-change"(e){e.trigger&&(e.stopImmediatePropagation(),this.$state.inferredTitle.set(e.detail))}"poster-change"(e){e.trigger&&(e.stopImmediatePropagation(),this.$state.inferredPoster.set(e.detail))}},gw=class extends Qi{onSetup(){this._init(),!N&&(b(this._watchArtist.bind(this)),b(this._watchAutoplay.bind(this)),b(this._watchClipTimes.bind(this)),b(this._watchControls.bind(this)),b(this._watchCrossOrigin.bind(this)),b(this._watchDuration.bind(this)),b(this._watchLive.bind(this)),b(this._watchLiveEdge.bind(this)),b(this._watchLiveTolerance.bind(this)),b(this._watchLoop.bind(this)),b(this._watchPlaysInline.bind(this)),b(this._watchPoster.bind(this)),b(this._watchProvidedTypes.bind(this)),b(this._watchTitle.bind(this)))}_init(){let e={duration:"providedDuration",poster:"providedPoster",streamType:"providedStreamType",title:"providedTitle",viewType:"providedViewType"},n=new Set(["currentTime","paused","playbackRate","volume"]);for(let i of Object.keys(this.$props))n.has(i)||this.$state[e[i]??i]?.set(this.$props[i]());this.$state.muted.set(this.$props.muted()||this.$props.volume()===0)}_watchProvidedTypes(){let{viewType:e,streamType:n,title:i,poster:r}=this.$props;this.$state.providedPoster.set(r()),this.$state.providedStreamType.set(n()),this.$state.providedViewType.set(e()),this.$state.providedTitle.set(i())}_watchLogLevel(){}_watchArtist(){let{artist:e}=this.$props;this.$state.artist.set(e())}_watchTitle(){let{title:e}=this.$state;this.dispatch("title-change",{detail:e()})}_watchAutoplay(){let e=this.$props.autoPlay()||this.$props.autoplay();this.$state.autoPlay.set(e),this.dispatch("auto-play-change",{detail:e})}_watchLoop(){let e=this.$props.loop();this.$state.loop.set(e),this.dispatch("loop-change",{detail:e})}_watchControls(){let e=this.$props.controls();this.$state.controls.set(e)}_watchPoster(){let{poster:e}=this.$state;this.dispatch("poster-change",{detail:e()})}_watchCrossOrigin(){let e=this.$props.crossOrigin()??this.$props.crossorigin(),n=e===!0?"":e;this.$state.crossOrigin.set(n)}_watchDuration(){let{providedDuration:e}=this.$state;e.set(this.$props.duration())}_watchPlaysInline(){let e=this.$props.playsInline()||this.$props.playsinline();this.$state.playsInline.set(e),this.dispatch("plays-inline-change",{detail:e})}_watchClipTimes(){let{clipStartTime:e,clipEndTime:n}=this.$props;this.$state.clipStartTime.set(e()),this.$state.clipEndTime.set(n())}_watchLive(){this.dispatch("live-change",{detail:this.$state.live()})}_watchLiveTolerance(){this.$state.liveEdgeTolerance.set(this.$props.liveEdgeTolerance()),this.$state.minLiveDVRWindow.set(this.$props.minLiveDVRWindow())}_watchLiveEdge(){this.dispatch("live-edge-change",{detail:this.$state.liveEdge()})}},IO=class vw extends Qi{constructor(){super()}onConnect(){b(this._onMetadataChange.bind(this)),b(this._onPlaybackStateChange.bind(this));let e=this._handleAction.bind(this);for(let n of vw._actions)navigator.mediaSession.setActionHandler(n,e);G(this._onDisconnect.bind(this))}_onDisconnect(){for(let e of vw._actions)navigator.mediaSession.setActionHandler(e,null)}_onMetadataChange(){let{title:e,artist:n,poster:i}=this.$state;navigator.mediaSession.metadata=new MediaMetadata({title:e(),artist:n(),artwork:[{src:i()}]})}_onPlaybackStateChange(){let{canPlay:e,paused:n}=this.$state;navigator.mediaSession.playbackState=e()?n()?"paused":"playing":"none"}_handleAction(e){let n=new j("media-session-action",{detail:e});switch(e.action){case"play":this.dispatch("media-play-request",{trigger:n});break;case"pause":this.dispatch("media-pause-request",{trigger:n});break;case"seekto":case"seekforward":case"seekbackward":this.dispatch("media-seek-request",{detail:Be(e.seekTime)?e.seekTime:this.$state.currentTime()+(e.seekOffset??10),trigger:n});break}}};IO._actions=["play","pause","seekforward","seekbackward","seekto"];Vh=D(!1);N||(S(document,"pointerdown",()=>{Vh.set(!1)}),S(document,"keydown",t=>{t.metaKey||t.altKey||t.ctrlKey||Vh.set(!0)}));pn=class extends Mt{constructor(){super(...arguments),this._focused=D(!1)}onConnect(e){b(()=>{if(!Vh()){this._focused.set(!1),gh(e,!1),this.listen("pointerenter",this._onPointerEnter.bind(this)),this.listen("pointerleave",this._onPointerLeave.bind(this));return}let n=document.activeElement===e;this._focused.set(n),gh(e,n),this.listen("focus",this._onFocus.bind(this)),this.listen("blur",this._onBlur.bind(this))})}focused(){return this._focused()}_onFocus(){this._focused.set(!0),gh(this.el,!0)}_onBlur(){this._focused.set(!1),gh(this.el,!1)}_onPointerEnter(){pP(this.el,!0)}_onPointerLeave(){pP(this.el,!1)}};AO=Object.defineProperty,NO=Object.getOwnPropertyDescriptor,Ee=(t,e,n,i)=>{for(var r=i>1?void 0:i?NO(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&AO(e,n,r),r},he=class yh extends q{constructor(){super(),this.canPlayQueue=new Oh,this._skipTitleUpdate=!1,new gw;let e={player:this,qualities:new Rh,audioTracks:new Mh,storage:null,$provider:D(null),$providerSetup:D(!1),$props:this.$props,$state:this.$state};e.remote=new Ka(void 0),e.remote.setPlayer(this),e.$iosControls=mi(this._isIOSControls.bind(this)),e.textTracks=new Ch,e.textTracks[W._crossOrigin]=this.$state.crossOrigin,e.textRenderers=new Ph(e),e.ariaKeys={},this._media=e,Rt(ru,e),this.orientation=new Pw,new pn,new uw(e);let n=new fw;this._stateMgr=new mw(n,e),this._requestMgr=new hw(this._stateMgr,n,e),e.delegate=new dw(this._stateMgr._handle.bind(this._stateMgr),e),new Dh("load",this.startLoading.bind(this)),new Dh("posterLoad",this.startLoadingPoster.bind(this))}get _provider(){return this._media.$provider()}onSetup(){this._setupMediaAttributes(),b(this._watchCanPlay.bind(this)),b(this._watchMuted.bind(this)),b(this._watchPaused.bind(this)),b(this._watchVolume.bind(this)),b(this._watchCurrentTime.bind(this)),b(this._watchPlaysInline.bind(this)),b(this._watchPlaybackRate.bind(this))}onAttach(e){e.setAttribute("data-media-player",""),ve(e,"tabindex","0"),ve(e,"role","region"),b(this._watchStorage.bind(this)),N?this._watchTitle():b(this._watchTitle.bind(this)),N?this._watchOrientation():b(this._watchOrientation.bind(this)),S(e,"find-media-player",this._onFindPlayer.bind(this))}onConnect(e){tP&&Z(e,"data-iphone","");let n=window.matchMedia("(pointer: coarse)");this._onPointerChange(n),n.onchange=this._onPointerChange.bind(this);let i=new ResizeObserver(Rr(this._onResize.bind(this)));i.observe(e),b(this._onResize.bind(this)),this.dispatch("media-player-connect",{detail:this,bubbles:!0,composed:!0}),G(()=>{i.disconnect(),n.onchange=null})}onDestroy(){this._media.player=null,this.canPlayQueue._reset()}_watchTitle(){let e=this.$el,{title:n,live:i,viewType:r,providedTitle:s}=this.$state,a=i(),o=Xl(r()),l=o!=="Unknown"?`${a?"Live ":""}${o}`:a?"Live":"Media",c=n();Z(this.el,"aria-label",c?`${l} - ${c}`:l+" Player"),!N&&e?.hasAttribute("title")&&(this._skipTitleUpdate=!0,e?.removeAttribute("title"))}_watchOrientation(){let e=this.orientation.landscape?"landscape":"portrait";this.$state.orientation.set(e),Z(this.el,"data-orientation",e),this._onResize()}_watchCanPlay(){this.$state.canPlay()&&this._provider?this.canPlayQueue._start():this.canPlayQueue._stop()}_setupMediaAttributes(){if(yh[iw]){this.setAttributes(yh[iw]);return}let e={"data-load":function(){return this.$props.load()},"data-captions":function(){let i=this.$state.textTrack();return!!i&&We(i)},"data-ios-controls":function(){return this._media.$iosControls()},"data-controls":function(){return this.controls.showing},"data-buffering":function(){let{canLoad:i,canPlay:r,waiting:s}=this.$state;return i()&&(!r()||s())},"data-error":function(){let{error:i}=this.$state;return!!i()},"data-autoplay-error":function(){let{autoPlayError:i}=this.$state;return!!i()}},n={autoPlay:"autoplay",canAirPlay:"can-airplay",canPictureInPicture:"can-pip",pictureInPicture:"pip",playsInline:"playsinline",remotePlaybackState:"remote-state",remotePlaybackType:"remote-type",isAirPlayConnected:"airplay",isGoogleCastConnected:"google-cast"};for(let i of MO){let r="data-"+(n[i]??Da(i));e[r]=function(){return this.$state[i]()}}delete e.title,yh[iw]=e,this.setAttributes(e)}_onFindPlayer(e){e.detail(this)}_onResize(){if(N||!this.el)return;let e=this.el.clientWidth,n=this.el.clientHeight;this.$state.width.set(e),this.$state.height.set(n),lt(this.el,"--player-width",e+"px"),lt(this.el,"--player-height",n+"px")}_onPointerChange(e){if(N)return;let n=e.matches?"coarse":"fine";Z(this.el,"data-pointer",n),this.$state.pointer.set(n),this._onResize()}_isIOSControls(){let{playsInline:e,fullscreen:n}=this.$state;return tP&&!_P()&&this.$state.mediaType()==="video"&&(!e()||n())}get provider(){return this._provider}get controls(){return this._requestMgr._controls}get title(){return C(this.$state.providedTitle)}set title(e){if(this._skipTitleUpdate){this._skipTitleUpdate=!1;return}this.$state.providedTitle.set(e)}get qualities(){return this._media.qualities}get audioTracks(){return this._media.audioTracks}get textTracks(){return this._media.textTracks}get textRenderers(){return this._media.textRenderers}get paused(){return C(this.$state.paused)}set paused(e){this._queuePausedUpdate(e)}_watchPaused(){this._queuePausedUpdate(this.$props.paused())}_queuePausedUpdate(e){e?this.canPlayQueue._enqueue("paused",()=>this._requestMgr._pause()):this.canPlayQueue._enqueue("paused",()=>this._requestMgr._play())}get muted(){return C(this.$state.muted)}set muted(e){this.$props.muted.set(e)}_watchMuted(){this._queueMutedUpdate(this.$props.muted())}_queueMutedUpdate(e){this.canPlayQueue._enqueue("muted",()=>{this._provider&&this._provider.setMuted(e)})}get currentTime(){return C(this.$state.currentTime)}set currentTime(e){this._queueCurrentTimeUpdate(e)}_watchCurrentTime(){this._queueCurrentTimeUpdate(this.$props.currentTime())}_queueCurrentTimeUpdate(e){this.canPlayQueue._enqueue("currentTime",()=>{let{currentTime:n,clipStartTime:i,seekableStart:r,seekableEnd:s}=this.$state;e!==C(n)&&C(()=>{if(!this._provider)return;let a=Math.min(Math.max(r()+.1,e+i()),s()-.1);Number.isFinite(a)&&this._provider.setCurrentTime(a)})})}get volume(){return C(this.$state.volume)}set volume(e){this.$props.volume.set(e)}_watchVolume(){this._queueVolumeUpdate(this.$props.volume())}_queueVolumeUpdate(e){let n=Nw(0,e,1);this.canPlayQueue._enqueue("volume",()=>{this._provider&&this._provider.setVolume(n)})}get playbackRate(){return C(this.$state.playbackRate)}set playbackRate(e){this._queuePlaybackRateUpdate(e)}_watchPlaybackRate(){this._queuePlaybackRateUpdate(this.$props.playbackRate())}_queuePlaybackRateUpdate(e){this.canPlayQueue._enqueue("rate",()=>{this._provider&&this._provider.setPlaybackRate?.(e)})}_watchPlaysInline(){this._queuePlaysInlineUpdate(this.$props.playsInline())}_queuePlaysInlineUpdate(e){this.canPlayQueue._enqueue("playsinline",()=>{this._provider&&this._provider.setPlaysInline?.(e)})}_watchStorage(){let e=this.$props.storage(),n=F(e)?new Sh:e;if(n?.onChange){let{source:i}=this.$state,r=F(e)?e:this.el?.id,s=mi(this._computeMediaId.bind(this));b(()=>n.onChange(i(),s(),r))}this._media.storage=n,this._media.textTracks.setStorage(n),G(()=>{n?.onDestroy?.(),this._media.storage=null,this._media.textTracks.setStorage(null)})}_computeMediaId(){let{clipStartTime:e,clipEndTime:n}=this.$props,{source:i}=this.$state,r=i();return r.src?`${r.src}:${e()}:${n()}`:null}async play(e){return this._requestMgr._play(e)}async pause(e){return this._requestMgr._pause(e)}async enterFullscreen(e,n){return this._requestMgr._enterFullscreen(e,n)}async exitFullscreen(e,n){return this._requestMgr._exitFullscreen(e,n)}enterPictureInPicture(e){return this._requestMgr._enterPictureInPicture(e)}exitPictureInPicture(e){return this._requestMgr._exitPictureInPicture(e)}seekToLiveEdge(e){this._requestMgr._seekToLiveEdge(e)}startLoading(e){this._media.delegate._notify("can-load",void 0,e)}startLoadingPoster(e){this._media.delegate._notify("can-load-poster",void 0,e)}requestAirPlay(e){return this._requestMgr._requestAirPlay(e)}requestGoogleCast(e){return this._requestMgr._requestGoogleCast(e)}destroy(){this._media.remote.setPlayer(null),this.dispatch("destroy")}};he.props=RO;he.state=Ns;Ee([ee],he.prototype,"canPlayQueue",2);Ee([ee],he.prototype,"provider",1);Ee([ee],he.prototype,"controls",1);Ee([ee],he.prototype,"orientation",2);Ee([ee],he.prototype,"title",1);Ee([ee],he.prototype,"qualities",1);Ee([ee],he.prototype,"audioTracks",1);Ee([ee],he.prototype,"textTracks",1);Ee([ee],he.prototype,"textRenderers",1);Ee([ee],he.prototype,"paused",1);Ee([ee],he.prototype,"muted",1);Ee([ee],he.prototype,"currentTime",1);Ee([ee],he.prototype,"volume",1);Ee([ee],he.prototype,"playbackRate",1);Ee([Ae],he.prototype,"play",1);Ee([Ae],he.prototype,"pause",1);Ee([Ae],he.prototype,"enterFullscreen",1);Ee([Ae],he.prototype,"exitFullscreen",1);Ee([Ae],he.prototype,"enterPictureInPicture",1);Ee([Ae],he.prototype,"exitPictureInPicture",1);Ee([Ae],he.prototype,"seekToLiveEdge",1);Ee([Ae],he.prototype,"startLoading",1);Ee([Ae],he.prototype,"startLoadingPoster",1);Ee([Ae],he.prototype,"requestAirPlay",1);Ee([Ae],he.prototype,"requestGoogleCast",1);DO=he;e1=new Map,yw=class{constructor(e,n,i,r=[]){this._domSources=e,this._media=n,this._loader=i,this._initialize=!1;let s=new ZP,a=new vc,o=new Ih,l=new Nh,c=new Ah,u=[l,c];this._loaders=mi(()=>{let p=n.$state.remotePlaybackLoader(),h=n.$props.preferNativeHLS()?[...r,a,o,s,...u]:[...r,s,a,o,...u];return p?[p,...h]:h});let{$state:d}=n;d.sources.set(hP(n.$props.src()));for(let p of d.sources()){let h=this._loaders().find(v=>v.canPlay(p));if(!h)continue;let y=h.mediaType(p);this._media.$state.source.set(p),this._media.$state.mediaType.set(y),this._media.$state.inferredViewType.set(y),this._loader.set(h),this._initialize=!0}}get _notify(){return this._media.delegate._notify}connect(){let e=this._loader();this._initialize&&(this._notifySourceChange(this._media.$state.source(),e),this._notifyLoaderChange(e),this._initialize=!1),b(this._onSourcesChange.bind(this)),b(this._onSourceChange.bind(this)),b(this._onSetup.bind(this)),b(this._onLoadSource.bind(this)),b(this._onLoadPoster.bind(this))}_onSourcesChange(){this._notify("sources-change",[...hP(this._media.$props.src()),...this._domSources()])}_onSourceChange(){let{$state:e}=this._media,n=e.sources(),i=C(e.source),r=this._findNewSource(i,n);if(n[0]?.src&&!r.src&&!r.type){let{crossOrigin:a}=e,o=bh(a()),l=new AbortController;return Promise.all(n.map(c=>F(c.src)&&c.type==="?"?fetch(c.src,{method:"HEAD",credentials:o,signal:l.signal}).then(u=>(c.type=u.headers.get("content-type")||"??",e1.set(c.src,c.type),c)).catch(()=>c):c)).then(c=>{l.signal.aborted||(this._findNewSource(C(e.source),c),Zn())}),()=>l.abort()}Zn()}_findNewSource(e,n){let i={src:"",type:""},r=null,s=this._loaders();for(let a of n){let o=s.find(l=>l.canPlay(a));if(o){i=a,r=o;break}}return fP(e,i)||this._notifySourceChange(i,r),r!==C(this._loader)&&this._notifyLoaderChange(r),i}_notifySourceChange(e,n){this._notify("source-change",e),this._notify("media-type-change",n?.mediaType(e)||"unknown")}_notifyLoaderChange(e){this._media.$providerSetup.set(!1),this._notify("provider-change",null),e&&C(()=>e.preconnect?.(this._media)),this._loader.set(e),this._notify("provider-loader-change",e)}_onSetup(){let e=this._media.$provider();if(!(!e||C(this._media.$providerSetup))){if(this._media.$state.canLoad()){et(()=>e.setup(),e.scope),this._media.$providerSetup.set(!0);return}C(()=>e.preconnect?.())}}_onLoadSource(){if(!this._media.$providerSetup())return;let e=this._media.$provider(),n=this._media.$state.source(),i=C(this._media.$state.crossOrigin);if(!fP(e?.currentSrc,n)){if(this._media.$state.canLoad()){let r=new AbortController;return xs(n)?ah()||JP(n.src,{credentials:bh(i),signal:r.signal}).then(s=>{this._notify("stream-type-change",s)}).catch(qt):this._notify("stream-type-change","on-demand"),C(()=>{let s=C(this._media.$state.preload);return e?.loadSource(n,s).catch(a=>{})}),()=>r.abort()}try{F(n.src)&&Jn(new URL(n.src).origin)}catch{}}}_onLoadPoster(){let e=this._loader(),{source:n,canLoadPoster:i}=this._media.$state;if(!e||!e.loadPoster||!n()||!i())return;let r=new AbortController,s=new j("source-change",{detail:n});return e.loadPoster(n(),this._media,r).then(a=>{this._notify("poster-change",a||"",s)}).catch(()=>{this._notify("poster-change","",s)}),()=>{r.abort()}}};_w=class{constructor(e,n){this._domTracks=e,this._media=n,this._prevTracks=[],b(this._onTracksChange.bind(this))}_onTracksChange(){let e=this._domTracks();for(let n of this._prevTracks)if(!e.some(i=>i.id===n.id)){let i=n.id&&this._media.textTracks.getById(n.id);i&&this._media.textTracks.remove(i)}for(let n of e){let i=n.id||ln.createId(n);this._media.textTracks.getById(i)||(n.id=i,this._media.textTracks.add(n))}this._prevTracks=e}},FO=Object.defineProperty,zO=Object.getOwnPropertyDescriptor,UO=(t,e,n,i)=>{for(var r=i>1?void 0:i?zO(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&FO(e,n,r),r},Ya=class extends q{constructor(){super(...arguments),this._domSources=D([]),this._domTracks=D([]),this._loader=null,this._loadRafId=-1}onSetup(){this._media=le(),this._sources=new yw(this._domSources,this._media,this.$state.loader,this.$props.loaders())}onAttach(e){e.setAttribute("data-media-provider","")}onConnect(e){this._sources.connect(),new _w(this._domTracks,this._media);let n=new ResizeObserver(Rr(this._onResize.bind(this)));n.observe(e);let i=new MutationObserver(this._onMutation.bind(this));i.observe(e,{attributes:!0,childList:!0}),this._onResize(),this._onMutation(),G(()=>{n.disconnect(),i.disconnect()})}load(e){window.cancelAnimationFrame(this._loadRafId),this._loadRafId=requestAnimationFrame(()=>this._runLoader(e)),G(()=>{window.cancelAnimationFrame(this._loadRafId)})}_runLoader(e){if(!this.scope)return;let n=this.$state.loader(),{$provider:i}=this._media;this._loader===n&&n?.target===e&&C(i)||(this._destroyProvider(),this._loader=n,n&&(n.target=e||null),!(!n||!e)&&n.load(this._media).then(r=>{this.scope&&C(this.$state.loader)===n&&this._media.delegate._notify("provider-change",r)}))}onDestroy(){this._loader=null,this._destroyProvider()}_destroyProvider(){this._media.delegate._notify("provider-change",null)}_onResize(){if(!this.el)return;let e=this._media.player,n=this.el.offsetWidth,i=this.el.offsetHeight;e&&(e.$state.mediaWidth.set(n),e.$state.mediaHeight.set(i),e.el&&(lt(e.el,"--media-width",n+"px"),lt(e.el,"--media-height",i+"px")))}_onMutation(){let e=[],n=[],i=this.el.children;for(let r of i)r instanceof HTMLSourceElement?e.push({src:r.src,type:r.type}):r instanceof HTMLTrackElement&&n.push({id:r.id,src:r.src,kind:r.track.kind,language:r.srclang,label:r.label,default:r.default,type:r.getAttribute("data-type")});this._domSources.set(e),this._domTracks.set(n),Zn()}};Ya.props={loaders:[]};Ya.state=new Xn({loader:null});UO([Ae],Ya.prototype,"load",1);Fh=class extends q{onSetup(){this._media=le(),b(this._watchProps.bind(this))}onAttach(e){let{pictureInPicture:n,fullscreen:i}=this._media.$state;lt(e,"pointer-events","none"),ve(e,"role","group"),this.setAttributes({"data-visible":this._isShowing.bind(this),"data-fullscreen":i,"data-pip":n}),b(()=>{this.dispatch("change",{detail:this._isShowing()})}),b(this._hideControls.bind(this)),b(()=>{let r=i();for(let s of["top","right","bottom","left"])lt(e,`padding-${s}`,r&&`env(safe-area-inset-${s})`)})}_hideControls(){if(!this.el)return;let{$iosControls:e}=this._media,{controls:n}=this._media.$state,i=n()||e();Z(this.el,"aria-hidden",i?"true":null),lt(this.el,"display",i?"none":null)}_watchProps(){let{controls:e}=this._media.player,{hideDelay:n,hideOnMouseLeave:i}=this.$props;e.defaultDelay=n()===2e3?this._media.$props.controlsDelay():n(),e.hideOnMouseLeave=i()}_isShowing(){let{controlsVisible:e}=this._media.$state;return e()}};Fh.props={hideDelay:2e3,hideOnMouseLeave:!1};zh=class extends q{onAttach(e){lt(e,"pointer-events","auto")}},Uh=class extends Mt{constructor(e){super(),this._delegate=e,this._showTimerId=-1,this._hideRafId=-1,this._stopAnimationEndListener=null,b(this._watchTrigger.bind(this))}onDestroy(){this._stopAnimationEndListener?.(),this._stopAnimationEndListener=null}_watchTrigger(){let e=this._delegate._trigger();if(!e){this.hide();return}let n=this.show.bind(this),i=this.hide.bind(this);this._delegate._listen(e,n,i)}show(e){this._cancelShowing(),window.cancelAnimationFrame(this._hideRafId),this._hideRafId=-1,this._stopAnimationEndListener?.(),this._stopAnimationEndListener=null,this._showTimerId=window.setTimeout(()=>{this._showTimerId=-1;let n=this._delegate._content();n&&n.style.removeProperty("display"),C(()=>this._delegate._onChange(!0,e))},this._delegate._showDelay?.()??0)}hide(e){this._cancelShowing(),C(()=>this._delegate._onChange(!1,e)),this._hideRafId=requestAnimationFrame(()=>{this._cancelShowing(),this._hideRafId=-1;let n=this._delegate._content();if(n){let i=()=>{n.style.display="none",this._stopAnimationEndListener=null};if(xO(n)){this._stopAnimationEndListener?.();let s=S(n,"animationend",i,{once:!0});this._stopAnimationEndListener=s}else i()}})}_cancelShowing(){window.clearTimeout(this._showTimerId),this._showTimerId=-1}},Wa=vi(),jO=0,jh=class extends q{constructor(){super(),this._id=`media-tooltip-${++jO}`,this._trigger=D(null),this._content=D(null),new pn;let{showDelay:e}=this.$props;new Uh({_trigger:this._trigger,_content:this._content,_showDelay:e,_listen(n,i,r){S(n,"touchstart",s=>s.preventDefault(),{passive:!1}),b(()=>{Vh()&&S(n,"focus",i),S(n,"blur",r)}),S(n,"mouseenter",i),S(n,"mouseleave",r)},_onChange:this._onShowingChange.bind(this)})}onAttach(e){e.style.setProperty("display","contents")}onSetup(){Rt(Wa,{_trigger:this._trigger,_content:this._content,_attachTrigger:this._attachTrigger.bind(this),_detachTrigger:this._detachTrigger.bind(this),_attachContent:this._attachContent.bind(this),_detachContent:this._detachContent.bind(this)})}_attachTrigger(e){this._trigger.set(e);let n=e.getAttribute("data-media-tooltip");n&&this.el?.setAttribute(`data-media-${n}-tooltip`,""),Z(e,"data-describedby",this._id)}_detachTrigger(e){e.removeAttribute("data-describedby"),e.removeAttribute("aria-describedby"),this._trigger.set(null)}_attachContent(e){e.setAttribute("id",this._id),e.style.display="none",ve(e,"role","tooltip"),this._content.set(e)}_detachContent(e){e.removeAttribute("id"),e.removeAttribute("role"),this._content.set(null)}_onShowingChange(e){let n=this._trigger(),i=this._content();n&&Z(n,"aria-describedby",e?this._id:null);for(let r of[this.el,n,i])r&&Z(r,"data-visible",e)}};jh.props={showDelay:700};Hh=class extends q{constructor(){super(),new pn}onConnect(e){G(Eh(()=>{if(!this.connectScope)return;this._attach();let n=Ie(Wa);G(()=>{let i=this._getButton();i&&n._detachTrigger(i)})}))}_attach(){let e=this._getButton(),n=Ie(Wa);e&&n._attachTrigger(e)}_getButton(){let e=this.el.firstElementChild;return e?.localName==="button"||e?.getAttribute("role")==="button"?e:this.el}},yc=class extends q{constructor(){super(),new pn;let{placement:e}=this.$props;this.setAttributes({"data-placement":e})}onAttach(e){this._attach(e),Object.assign(e.style,{position:"absolute",top:0,left:0,width:"max-content"})}onConnect(e){this._attach(e);let n=Ie(Wa);G(()=>n._detachContent(e)),G(Eh(()=>{this.connectScope&&b(this._watchPlacement.bind(this))}))}_attach(e){Ie(Wa)._attachContent(e)}_watchPlacement(){let{placement:e,offset:n,alignOffset:i}=this.$props;return FP(this.el,this._getTrigger(),e(),{offsetVarName:"media-tooltip",xOffset:i(),yOffset:n()})}_getTrigger(){return Ie(Wa)._trigger()}};yc.props={placement:"top center",offset:0,alignOffset:0};tt=class extends Mt{constructor(e){super(),this._delegate=e,new pn,e._keyShortcut&&new Lh(e._keyShortcut)}onSetup(){let{disabled:e}=this.$props;this.setAttributes({"data-pressed":this._delegate._isPressed,"aria-pressed":this._isARIAPressed.bind(this),"aria-disabled":()=>e()?"true":null})}onAttach(e){ve(e,"tabindex","0"),ve(e,"role","button"),ve(e,"type","button")}onConnect(e){Dr(e,this._onMaybePress.bind(this));for(let n of["click","touchstart"])this.listen(n,this._onInteraction.bind(this))}_isARIAPressed(){return Oa(this._delegate._isPressed())}_onPressed(e){Xy(this._delegate._isPressed)&&this._delegate._isPressed.set(n=>!n)}_onMaybePress(e){if(this.$props.disabled()||this.el.hasAttribute("data-disabled")){e.preventDefault(),e.stopImmediatePropagation();return}e.preventDefault(),(this._delegate._onPress??this._onPressed).call(this,e)}_onInteraction(e){this.$props.disabled()&&(e.preventDefault(),e.stopImmediatePropagation())}};tt.props={disabled:!1};HO=Object.defineProperty,qO=Object.getOwnPropertyDescriptor,BO=(t,e,n,i)=>{for(var r=i>1?void 0:i?qO(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&HO(e,n,r),r},_c=class extends q{constructor(){super(),this._pressed=D(!1),new tt({_isPressed:this._pressed})}get pressed(){return this._pressed()}};_c.props={disabled:!1,defaultPressed:!1};BO([ee],_c.prototype,"pressed",1);qh=class extends q{constructor(){super(),new tt({_isPressed:this._isPressed.bind(this),_onPress:this._onPress.bind(this)})}onSetup(){this._media=le();let{canAirPlay:e,isAirPlayConnected:n}=this._media.$state;this.setAttributes({"data-active":n,"data-supported":e,"data-state":this._getState.bind(this),"aria-hidden":Gt(()=>!e())})}onAttach(e){e.setAttribute("data-media-tooltip","airplay"),Vr(e,this._getDefaultLabel.bind(this))}_onPress(e){this._media.remote.requestAirPlay(e)}_isPressed(){let{remotePlaybackType:e,remotePlaybackState:n}=this._media.$state;return e()==="airplay"&&n()!=="disconnected"}_getState(){let{remotePlaybackType:e,remotePlaybackState:n}=this._media.$state;return e()==="airplay"&&n()}_getDefaultLabel(){let{remotePlaybackState:e}=this._media.$state;return`AirPlay ${e()}`}};qh.props=tt.props;Bh=class extends q{constructor(){super(),new tt({_isPressed:this._isPressed.bind(this),_onPress:this._onPress.bind(this)})}onSetup(){this._media=le();let{canGoogleCast:e,isGoogleCastConnected:n}=this._media.$state;this.setAttributes({"data-active":n,"data-supported":e,"data-state":this._getState.bind(this),"aria-hidden":Gt(()=>!e())})}onAttach(e){e.setAttribute("data-media-tooltip","google-cast"),Vr(e,this._getDefaultLabel.bind(this))}_onPress(e){this._media.remote.requestGoogleCast(e)}_isPressed(){let{remotePlaybackType:e,remotePlaybackState:n}=this._media.$state;return e()==="google-cast"&&n()!=="disconnected"}_getState(){let{remotePlaybackType:e,remotePlaybackState:n}=this._media.$state;return e()==="google-cast"&&n()}_getDefaultLabel(){let{remotePlaybackState:e}=this._media.$state;return`Google Cast ${e()}`}};Bh.props=tt.props;Wh=class extends q{constructor(){super(),new tt({_isPressed:this._isPressed.bind(this),_keyShortcut:"togglePaused",_onPress:this._onPress.bind(this)})}onSetup(){this._media=le();let{paused:e,ended:n}=this._media.$state;this.setAttributes({"data-paused":e,"data-ended":n})}onAttach(e){e.setAttribute("data-media-tooltip","play"),Vr(e,this._getDefaultLabel.bind(this))}_onPress(e){let n=this._media.remote;this._isPressed()?n.pause(e):n.play(e)}_isPressed(){let{paused:e}=this._media.$state;return!e()}_getDefaultLabel(){let{paused:e}=this._media.$state;return e()?"Play":"Pause"}};Wh.props=tt.props;Kh=class extends q{constructor(){super(),new tt({_isPressed:this._isPressed.bind(this),_keyShortcut:"toggleCaptions",_onPress:this._onPress.bind(this)})}onSetup(){this._media=le(),this.setAttributes({"data-active":this._isPressed.bind(this),"data-supported":()=>!this._isHidden(),"aria-hidden":Gt(this._isHidden.bind(this))})}onAttach(e){e.setAttribute("data-media-tooltip","caption"),Vr(e,this._getDefaultLabel.bind(this))}_onPress(e){this._media.remote.toggleCaptions(e)}_isPressed(){let{textTrack:e}=this._media.$state,n=e();return!!n&&We(n)}_isHidden(){let{hasCaptions:e}=this._media.$state;return!e()}_getDefaultLabel(){let{textTrack:e}=this._media.$state;return e()?"Closed-Captions Off":"Closed-Captions On"}};Kh.props=tt.props;Gh=class extends q{constructor(){super(),new tt({_isPressed:this._isPressed.bind(this),_keyShortcut:"toggleFullscreen",_onPress:this._onPress.bind(this)})}onSetup(){this._media=le();let{fullscreen:e}=this._media.$state,n=this._isSupported.bind(this);this.setAttributes({"data-active":e,"data-supported":n,"aria-hidden":Gt(()=>!n())})}onAttach(e){e.setAttribute("data-media-tooltip","fullscreen"),Vr(e,this._getDefaultLabel.bind(this))}_onPress(e){let n=this._media.remote,i=this.$props.target();this._isPressed()?n.exitFullscreen(i,e):n.enterFullscreen(i,e)}_isPressed(){let{fullscreen:e}=this._media.$state;return e()}_isSupported(){let{canFullscreen:e}=this._media.$state;return e()}_getDefaultLabel(){let{fullscreen:e}=this._media.$state;return e()?"Exit Fullscreen":"Enter Fullscreen"}};Gh.props={...tt.props,target:"prefer-media"};Yh=class extends q{constructor(){super(),new tt({_isPressed:this._isPressed.bind(this),_keyShortcut:"toggleMuted",_onPress:this._onPress.bind(this)})}onSetup(){this._media=le(),this.setAttributes({"data-muted":this._isPressed.bind(this),"data-state":this._getState.bind(this)})}onAttach(e){e.setAttribute("data-media-mute-button",""),e.setAttribute("data-media-tooltip","mute"),Vr(e,this._getDefaultLabel.bind(this))}_onPress(e){let n=this._media.remote;this._isPressed()?n.unmute(e):n.mute(e)}_isPressed(){let{muted:e,volume:n}=this._media.$state;return e()||n()===0}_getDefaultLabel(){return this._isPressed()?"Unmute":"Mute"}_getState(){let{muted:e,volume:n}=this._media.$state,i=n();if(e()||i===0)return"muted";if(i>=.5)return"high";if(i<.5)return"low"}};Yh.props=tt.props;Qh=class extends q{constructor(){super(),new tt({_isPressed:this._isPressed.bind(this),_keyShortcut:"togglePictureInPicture",_onPress:this._onPress.bind(this)})}onSetup(){this._media=le();let{pictureInPicture:e}=this._media.$state,n=this._isSupported.bind(this);this.setAttributes({"data-active":e,"data-supported":n,"aria-hidden":Gt(()=>!n())})}onAttach(e){e.setAttribute("data-media-tooltip","pip"),Vr(e,this._getDefaultLabel.bind(this))}_onPress(e){let n=this._media.remote;this._isPressed()?n.exitPictureInPicture(e):n.enterPictureInPicture(e)}_isPressed(){let{pictureInPicture:e}=this._media.$state;return e()}_isSupported(){let{canPictureInPicture:e}=this._media.$state;return e()}_getDefaultLabel(){let{pictureInPicture:e}=this._media.$state;return e()?"Exit Picture In Picture":"Enter Picture In Picture"}};Qh.props=tt.props;Xh=class extends q{constructor(){super(),new pn}onSetup(){this._media=le();let{seeking:e}=this._media.$state,{seconds:n}=this.$props,i=this._isSupported.bind(this);this.setAttributes({seconds:n,"data-seeking":e,"data-supported":i,"aria-hidden":Gt(()=>!i())})}onAttach(e){ve(e,"tabindex","0"),ve(e,"role","button"),ve(e,"type","button"),e.setAttribute("data-media-tooltip","seek"),Vr(e,this._getDefaultLabel.bind(this))}onConnect(e){Dr(e,this._onPress.bind(this))}_isSupported(){let{canSeek:e}=this._media.$state;return e()}_getDefaultLabel(){let{seconds:e}=this.$props;return`Seek ${e()>0?"forward":"backward"} ${e()} seconds`}_onPress(e){let{seconds:n,disabled:i}=this.$props;if(i())return;let{currentTime:r}=this._media.$state,s=r()+n();this._media.remote.seek(s,e)}};Xh.props={disabled:!1,seconds:30};Zh=class extends q{constructor(){super(),new pn}onSetup(){this._media=le();let{disabled:e}=this.$props,{live:n,liveEdge:i}=this._media.$state,r=()=>!n();this.setAttributes({"data-edge":i,"data-hidden":r,"aria-disabled":Gt(()=>e()||i()),"aria-hidden":Gt(r)})}onAttach(e){ve(e,"tabindex","0"),ve(e,"role","button"),ve(e,"type","button"),e.setAttribute("data-media-tooltip","live")}onConnect(e){Dr(e,this._onPress.bind(this))}_onPress(e){let{disabled:n}=this.$props,{liveEdge:i}=this._media.$state;n()||i()||this._media.remote.seekToLiveEdge(e)}};Zh.props={disabled:!1};df=new Xn({min:0,max:100,value:0,pointerValue:0,focused:!1,dragging:!1,pointing:!1,get active(){return this.dragging||this.focused||this.pointing},get fillRate(){return mP(this.min,this.max,this.value)},get fillPercent(){return this.fillRate*100},get pointerRate(){return mP(this.min,this.max,this.pointerValue)},get pointerPercent(){return this.pointerRate*100}});gP={Left:-1,ArrowLeft:-1,Up:1,ArrowUp:1,Right:1,ArrowRight:1,Down:-1,ArrowDown:-1},ww=class extends Mt{constructor(e,n){super(),this._delegate=e,this._media=n,this._provider=null,this._touch=null,this._touchStartValue=null,this._onDocumentPointerMove=au(i=>{this._updatePointerValue(this._getPointerValue(i),i)},20,{leading:!0})}onConnect(){if(b(this._attachEventListeners.bind(this)),b(this._attachPointerListeners.bind(this)),this._delegate._swipeGesture){let e=this._media.player.el?.querySelector("media-provider,[data-media-provider]");e&&(this._provider=e,S(e,"touchstart",this._onTouchStart.bind(this),{passive:!0}),S(e,"touchmove",this._onTouchMove.bind(this),{passive:!1}))}}_onTouchStart(e){this._touch=e.touches[0]}_onTouchMove(e){if(gi(this._touch)||Rw(e))return;let n=e.touches[0],i=n.clientX-this._touch.clientX,r=n.clientY-this._touch.clientY,s=this.$state.dragging();!s&&Math.abs(r)>20||s||Math.abs(i)>20&&(this._touch=n,this._touchStartValue=this.$state.value(),this._onStartDragging(this._touchStartValue,e))}_attachEventListeners(){this._delegate._isDisabled()||(this.listen("focus",this._onFocus.bind(this)),this.listen("pointerenter",this._onPointerEnter.bind(this)),this.listen("pointermove",this._onPointerMove.bind(this)),this.listen("pointerleave",this._onPointerLeave.bind(this)),this.listen("pointerdown",this._onPointerDown.bind(this)),this.listen("keydown",this._onKeyDown.bind(this)),this.listen("keyup",this._onKeyUp.bind(this)))}_attachPointerListeners(){this._delegate._isDisabled()||!this.$state.dragging()||(S(document,"pointerup",this._onDocumentPointerUp.bind(this)),S(document,"pointermove",this._onDocumentPointerMove.bind(this)),S_&&S(document,"touchmove",this._onDocumentTouchMove.bind(this),{passive:!1}))}_onFocus(){this._updatePointerValue(this.$state.value())}_updateValue(e,n){let{value:i,min:r,max:s,dragging:a}=this.$state,o=Math.max(r(),Math.min(e,s()));i.set(o);let l=this.createEvent("value-change",{detail:o,trigger:n});if(this.dispatch(l),this._delegate._onValueChange?.(l),a()){let c=this.createEvent("drag-value-change",{detail:o,trigger:n});this.dispatch(c),this._delegate._onDragValueChange?.(c)}}_updatePointerValue(e,n){let{pointerValue:i,dragging:r}=this.$state;i.set(e),this.dispatch("pointer-value-change",{detail:e,trigger:n}),r()&&this._updateValue(e,n)}_getPointerValue(e){let n,i=this.el.getBoundingClientRect(),{min:r,max:s}=this.$state;if(this.$props.orientation()==="vertical"){let{bottom:a,height:o}=i;n=(a-e.clientY)/o}else if(this._touch&&Be(this._touchStartValue)){let{width:a}=this._provider.getBoundingClientRect(),o=(e.clientX-this._touch.clientX)/a,l=s()-r(),c=l*Math.abs(o);n=(o<0?this._touchStartValue-c:this._touchStartValue+c)/l}else{let{left:a,width:o}=i;n=(e.clientX-a)/o}return Math.max(r(),Math.min(s(),this._delegate._roundValue(GO(r(),s(),n,this._delegate._getStep()))))}_onPointerEnter(e){this.$state.pointing.set(!0)}_onPointerMove(e){let{dragging:n}=this.$state;n()||this._updatePointerValue(this._getPointerValue(e),e)}_onPointerLeave(e){this.$state.pointing.set(!1)}_onPointerDown(e){if(e.button!==0)return;let n=this._getPointerValue(e);this._onStartDragging(n,e),this._updatePointerValue(n,e)}_onStartDragging(e,n){let{dragging:i}=this.$state;if(i())return;i.set(!0),this._media.remote.pauseControls(n);let r=this.createEvent("drag-start",{detail:e,trigger:n});this.dispatch(r),this._delegate._onDragStart?.(r)}_onStopDragging(e,n){let{dragging:i}=this.$state;if(!i())return;i.set(!1),this._media.remote.resumeControls(n);let r=this.createEvent("drag-end",{detail:e,trigger:n});this.dispatch(r),this._delegate._onDragEnd?.(r),this._touch=null,this._touchStartValue=null}_onKeyDown(e){let{key:n}=e,{min:i,max:r}=this.$state,s;if(n==="Home"||n==="PageUp"?s=i():n==="End"||n==="PageDown"?s=r():!e.metaKey&&/[0-9]/.test(n)&&(s=(r()-i())/10*Number(n)),!Le(s)){this._updatePointerValue(s,e),this._updateValue(s,e);return}let a=this._getKeyValue(e);if(Le(a))return;let o=n===this._lastDownKey;!this.$state.dragging()&&o&&this._onStartDragging(a,e),this._updatePointerValue(a,e),o||this._updateValue(a,e),this._lastDownKey=n}_onKeyUp(e){this._lastDownKey="";let{dragging:n,value:i}=this.$state;if(!n())return;let r=this._getKeyValue(e)??i();this._updatePointerValue(r),this._onStopDragging(r,e)}_getKeyValue(e){let{key:n,shiftKey:i}=e;if(!Object.keys(gP).includes(n))return;e.preventDefault(),e.stopPropagation();let{shiftKeyMultiplier:s}=this.$props,{value:a,min:o,max:l}=this.$state,c=this._delegate._getStep(),u=this._delegate._getKeyStep(),d=i?u*s():u,p=Number(gP[n]),h=d*p,y=(a()+h)/c;return Math.max(o(),Math.min(l(),Number((c*y).toFixed(3))))}_onDocumentPointerUp(e){if(e.button!==0)return;let n=this._getPointerValue(e);this._updatePointerValue(n,e),this._onStopDragging(n,e)}_onDocumentTouchMove(e){e.preventDefault()}},wc=vi(()=>({})),pf=vi(),bi=class extends Mt{constructor(e){super(),this._delegate=e,this._updateSliderVars=Rr((n,i)=>{this.el?.style.setProperty("--slider-fill",n+"%"),this.el?.style.setProperty("--slider-pointer",i+"%")})}onSetup(){this._media=le();let e=new pn;e.attach(this),this.$state.focused=e.focused.bind(e),Tn(wc)||Rt(wc,{default:"value"}),Rt(pf,{_orientation:this.$props.orientation,_disabled:this._delegate._isDisabled,_preview:D(null)}),b(this._watchValue.bind(this)),b(this._watchDisabled.bind(this)),this._setupAttrs(),new ww(this._delegate,this._media).attach(this)}onAttach(e){ve(e,"role","slider"),ve(e,"tabindex","0"),ve(e,"autocomplete","off"),N?this._watchCSSVars():b(this._watchCSSVars.bind(this))}_watchValue(){let{dragging:e,value:n,min:i,max:r}=this.$state;C(e)||n.set(KO(i(),r(),n(),this._delegate._getStep()))}_watchDisabled(){if(!this._delegate._isDisabled())return;let{dragging:e,pointing:n}=this.$state;e.set(!1),n.set(!1)}_getARIADisabled(){return Oa(this._delegate._isDisabled())}_setupAttrs(){let{orientation:e}=this.$props,{dragging:n,active:i,pointing:r}=this.$state;this.setAttributes({"data-dragging":n,"data-pointing":r,"data-active":i,"aria-disabled":this._getARIADisabled.bind(this),"aria-valuemin":this.$state.min,"aria-valuemax":this.$state.max,"aria-valuenow":this._delegate._getARIAValueNow,"aria-valuetext":this._delegate._getARIAValueText,"aria-orientation":e})}_watchCSSVars(){let{fillPercent:e,pointerPercent:n}=this.$state;this._updateSliderVars(At(e(),3),At(n(),3))}};bi.props={disabled:!1,step:1,keyStep:1,orientation:"horizontal",shiftKeyMultiplier:5};Xi=class extends q{constructor(){super(),new bi({_getStep:this.$props.step,_getKeyStep:this.$props.keyStep,_roundValue:Math.round,_isDisabled:this.$props.disabled,_getARIAValueNow:this._getARIAValueNow.bind(this),_getARIAValueText:this._getARIAValueText.bind(this)})}onSetup(){b(this._watchValue.bind(this)),b(this._watchMinMax.bind(this))}_getARIAValueNow(){let{value:e}=this.$state;return Math.round(e())}_getARIAValueText(){let{value:e,max:n}=this.$state;return At(e()/n()*100,2)+"%"}_watchValue(){let{value:e}=this.$props;this.$state.value.set(e())}_watchMinMax(){let{min:e,max:n}=this.$props;this.$state.min.set(e()),this.$state.max.set(n())}};Xi.props={...bi.props,min:0,max:100,value:0};Xi.state=df;Gi=new Map,vh=new Map,Jh=class t{constructor(e,n,i){this.$src=e,this.$crossOrigin=n,this._media=i,this.$images=D([]),b(this._onLoadCues.bind(this))}static create(e,n){let i=le();return new t(e,n,i)}_onLoadCues(){let{canLoad:e}=this._media.$state;if(!e())return;let n=this.$src(),i=new AbortController;if(n){if(F(n)&&Gi.has(n)){let r=Gi.get(n);if(Gi.delete(n),Gi.set(n,r),Gi.size>30){let s=Gi.keys().next().value;Gi.delete(s)}this.$images.set(Gi.get(n))}else if(F(n)){let r=this.$crossOrigin(),s=n+"::"+r;if(!vh.has(s)){let a=new Promise(async(o,l)=>{try{let c=await fetch(n,{signal:i.signal,credentials:bh(r)});if(c.headers.get("content-type")==="application/json"){let d=await c.json();if(qe(d))if(d[0]&&"text"in d)o(this._processVTTCues(d));else{for(let p=0;p(oc(),ac)).then(async({parseResponse:d})=>{try{let{cues:p}=await d(c);o(this._processVTTCues(p))}catch(p){l(p)}})}catch(c){l(c)}}).then(o=>(i.signal.aborted||Gi.set(s,o),o)).catch(o=>{i.signal.aborted||this._onError(n,o)}).finally(()=>{F(s)&&vh.delete(s)});vh.set(s,a)}vh.get(s)?.then(a=>{i.signal.aborted||this.$images.set(a||[])})}else if(qe(n))try{this.$images.set(this._processImages(n))}catch(r){this._onError(n,r)}else try{this.$images.set(this._processStoryboard(n))}catch(r){this._onError(n,r)}return()=>{i.abort(),this.$images.set([])}}}_processImages(e){let n=this._resolveBaseUrl();return e.map((i,r)=>(Ki(i.url&&F(i.url),!1),Ki("startTime"in i&&Be(i.startTime),!1),{...i,url:F(i.url)?this._resolveURL(i.url,n):i.url}))}_processStoryboard(e){Ki(F(e.url),!1),Ki(qe(e.tiles)&&e.tiles?.length,!1);let n=new URL(e.url),i=[],r="tile_width"in e?e.tile_width:e.tileWidth,s="tile_height"in e?e.tile_height:e.tileHeight;for(let a of e.tiles)i.push({url:n,startTime:"start"in a?a.start:a.startTime,width:r,height:s,coords:{x:a.x,y:a.y}});return i}_processVTTCues(e){for(let r=0;r{this._resetStyles(),n.set(!1),i.set(null)}}_onLoaded(){let{loading:e,error:n}=this.$state;e.set(!1),n.set(null)}_onError(e){let{loading:n,error:i}=this.$state;n.set(!1),i.set(e)}_isLoading(){let{loading:e,hidden:n}=this.$state;return!n()&&e()}_hasError(){let{error:e}=this.$state;return!gi(e())}_watchHidden(){let{hidden:e}=this.$state,{duration:n}=this._media.$state,i=this._loader.$images();e.set(this._hasError()||!Number.isFinite(n())||i.length===0)}_getTime(){return this.$props.time()}_onFindActiveThumbnail(){let e=this._getTime(),{src:n,activeThumbnail:i}=this.$state,r=this._loader.$images(),s=-1,a=null;for(let o=r.length-1;o>=0;o--){let l=r[o];if(e>=l.startTime&&(!l.endTime||e1?h:1;this._style(e,"--thumbnail-width",`${s*v}px`),this._style(e,"--thumbnail-height",`${a*v}px`),this._style(n,"width",`${n.naturalWidth*v}px`),this._style(n,"height",`${n.naturalHeight*v}px`),this._style(n,"transform",r.coords?`translate(-${r.coords.x*v}px, -${r.coords.y*v}px)`:""),this._style(n,"max-width","none")}_style(e,n,i){e.style.setProperty(n,i),this._styleResets.push(()=>e.style.removeProperty(n))}_resetStyles(){for(let e of this._styleResets)e();this._styleResets=[]}};Qa.props={src:null,time:0,crossOrigin:null};Qa.state=new Xn({src:"",img:null,thumbnails:[],activeThumbnail:null,crossOrigin:null,loading:!1,error:null,hidden:!1});ef=class extends Qa{onAttach(e){this._slider=_s(Xi.state)}_getTime(){let{duration:e,clipStartTime:n}=this._media.$state;return n()+this._slider.pointerRate()*e()}},YO=Object.defineProperty,QO=Object.getOwnPropertyDescriptor,XO=(t,e,n,i)=>{for(var r=i>1?void 0:i?QO(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&YO(e,n,r),r},Ps=class extends q{get video(){return this.$state.video()}onSetup(){this._media=le(),this._slider=_s(Xi.state),this._watchCrossOrigin(),this.setAttributes({"data-loading":this._isLoading.bind(this),"data-hidden":this.$state.hidden,"data-error":this._hasError.bind(this),"aria-hidden":Gt(this.$state.hidden)})}onAttach(e){b(this._watchVideo.bind(this)),b(this._watchSrc.bind(this)),b(this._watchCrossOrigin.bind(this)),b(this._watchHidden.bind(this)),b(this._onSrcChange.bind(this)),b(this._onUpdateTime.bind(this))}_watchVideo(){let e=this.$state.video();e&&(e.readyState>=2&&this._onCanPlay(),S(e,"canplay",this._onCanPlay.bind(this)),S(e,"error",this._onError.bind(this)))}_watchSrc(){let{src:e}=this.$state,{canLoad:n}=this._media.$state;e.set(n()?this.$props.src():null)}_watchCrossOrigin(){let{crossOrigin:e}=this.$props,{crossOrigin:n}=this.$state,{crossOrigin:i}=this._media.$state,r=e()!==null?e():i();n.set(r===!0?"anonymous":r)}_isLoading(){let{canPlay:e,hidden:n}=this.$state;return!e()&&!n()}_hasError(){let{error:e}=this.$state;return!gi(e)}_watchHidden(){let{src:e,hidden:n}=this.$state,{canLoad:i,duration:r}=this._media.$state;n.set(i()&&(!e()||this._hasError()||!Number.isFinite(r())))}_onSrcChange(){let{src:e,canPlay:n,error:i}=this.$state;e(),n.set(!1),i.set(null)}_onCanPlay(e){let{canPlay:n,error:i}=this.$state;n.set(!0),i.set(null),this.dispatch("can-play",{trigger:e})}_onError(e){let{canPlay:n,error:i}=this.$state;n.set(!1),i.set(e),this.dispatch("error",{trigger:e})}_onUpdateTime(){let{video:e,canPlay:n}=this.$state,{duration:i}=this._media.$state,{pointerRate:r}=this._slider,s=e();n()&&s&&Number.isFinite(i())&&Number.isFinite(r())&&(s.currentTime=r()*i())}};Ps.props={src:null,crossOrigin:null};Ps.state=new Xn({video:null,src:null,crossOrigin:null,canPlay:!1,error:null,hidden:!1});XO([ee],Ps.prototype,"video",1);ZO=Object.defineProperty,JO=Object.getOwnPropertyDescriptor,e3=(t,e,n,i)=>{for(var r=i>1?void 0:i?JO(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&ZO(e,n,r),r},Xa=class extends q{onSetup(){this._slider=_s(Xi.state),this._format=Ie(wc),this._text=mi(this.getValueText.bind(this))}getValueText(){let{type:e,format:n,decimalPlaces:i,padHours:r,padMinutes:s,showHours:a}=this.$props,{value:o,pointerValue:l,min:c,max:u}=this._slider,d=n()??this._format.default,p=e()==="current"?o():l();if(d==="percent"){let h=u()-c(),y=p/h*100;return(this._format.percent??At)(y,i())+"\uFE6A"}else return d==="time"?(this._format.time??Fr)(p,r(),s(),a()):this._format.value?.(p)??p.toFixed(2)}};Xa.props={type:"pointer",format:null,showHours:!1,padHours:null,padMinutes:null,decimalPlaces:2};e3([Ae],Xa.prototype,"getValueText",1);xc=class extends q{constructor(){super(...arguments),this._updatePlacement=Rr(()=>{let{_disabled:e,_orientation:n}=this._slider;if(e())return;let i=this.el,{offset:r,noClamp:s}=this.$props;Dw(i,{clamp:!s(),offset:r(),orientation:n()})})}onSetup(){this._slider=Ie(pf);let{active:e}=_s(Xi.state);this.setAttributes({"data-visible":e})}onAttach(e){Object.assign(e.style,{position:"absolute",top:0,left:0,width:"max-content"})}onConnect(e){let{_preview:n}=this._slider;n.set(e),G(()=>n.set(null)),b(this._updatePlacement.bind(this));let i=new ResizeObserver(this._updatePlacement.bind(this));i.observe(e),G(()=>i.disconnect())}};xc.props={offset:0,noClamp:!1};kc=class extends q{constructor(){super(...arguments),this._throttleVolumeChange=au(this._onVolumeChange.bind(this),25)}onSetup(){this._media=le(),Rt(wc,{default:"percent"}),new bi({_getStep:this.$props.step,_getKeyStep:this.$props.keyStep,_isDisabled:this.$props.disabled,_roundValue:Math.round,_getARIAValueNow:this._getARIAValueNow.bind(this),_getARIAValueText:this._getARIAValueText.bind(this),_onDragValueChange:this._onDragValueChange.bind(this),_onValueChange:this._onValueChange.bind(this)}).attach(this),b(this._watchVolume.bind(this))}onAttach(e){e.setAttribute("data-media-volume-slider",""),ve(e,"aria-label","Volume");let{canSetVolume:n}=this._media.$state;this.setAttributes({"data-supported":n,"aria-hidden":Gt(()=>!n())})}_getARIAValueNow(){let{value:e}=this.$state;return Math.round(e())}_getARIAValueText(){let{value:e,max:n}=this.$state;return At(e()/n()*100,2)+"%"}_watchVolume(){let{muted:e,volume:n}=this._media.$state,i=e()?0:n()*100;this.$state.value.set(i),this.dispatch("value-change",{detail:i})}_onVolumeChange(e){if(!e.trigger)return;let n=At(e.detail/100,3);this._media.remote.changeVolume(n,e)}_onValueChange(e){this._throttleVolumeChange(e)}_onDragValueChange(e){this._throttleVolumeChange(e)}};kc.props={...bi.props,keyStep:5,shiftKeyMultiplier:2};kc.state=df;Za=class extends q{constructor(){super(),this._chapter=D(null),this._playingBeforeDragStart=!1,new bi({_swipeGesture:!0,_getStep:this._getStep.bind(this),_getKeyStep:this._getKeyStep.bind(this),_isDisabled:this._isDisabled.bind(this),_roundValue:this._roundValue,_getARIAValueNow:this._getARIAValueNow.bind(this),_getARIAValueText:this._getARIAValueText.bind(this),_onDragStart:this._onDragStart.bind(this),_onDragValueChange:this._onDragValueChange.bind(this),_onDragEnd:this._onDragEnd.bind(this),_onValueChange:this._onValueChange.bind(this)})}onSetup(){this._media=le(),Rt(wc,{default:"time",value:this._formatValue.bind(this),time:this._formatTime.bind(this)}),this.setAttributes({"data-chapters":this._hasChapters.bind(this)}),this.setStyles({"--slider-progress":this._calcBufferedPercent.bind(this)}),b(this._watchCurrentTime.bind(this)),b(this._watchSeekingThrottle.bind(this))}onAttach(e){e.setAttribute("data-media-time-slider",""),ve(e,"aria-label","Seek")}onConnect(e){b(this._watchPreviewing.bind(this)),no(this._media.textTracks,"chapters",this._chapter.set)}_calcBufferedPercent(){let{bufferedEnd:e,duration:n}=this._media.$state;return At(Math.min(e()/Math.max(n(),1),1)*100,3)+"%"}_hasChapters(){let{duration:e}=this._media.$state;return this._chapter()?.cues.length&&Number.isFinite(e())&&e()>0}_watchSeekingThrottle(){this._dispatchSeeking=au(this._seeking.bind(this),this.$props.seekingRequestThrottle())}_watchCurrentTime(){let{currentTime:e}=this._media.$state,{value:n,dragging:i}=this.$state,r=this._timeToPercent(e());C(i)||(n.set(r),this.dispatch("value-change",{detail:r}))}_watchPreviewing(){let e=this._media.player.el,{_preview:n}=Ie(pf);e&&n()&&Z(e,"data-preview",this.$state.active())}_seeking(e,n){this._media.remote.seeking(e,n)}_seek(e,n,i){this._dispatchSeeking.cancel();let{live:r}=this._media.$state;if(r()&&n>=99){this._media.remote.seekToLiveEdge(i);return}this._media.remote.seek(e,i)}_onDragStart(e){let{pauseWhileDragging:n}=this.$props;if(n()){let{paused:i}=this._media.$state;this._playingBeforeDragStart=!i(),this._media.remote.pause(e)}}_onDragValueChange(e){this._dispatchSeeking(this._percentToTime(e.detail),e)}_onDragEnd(e){let n=e.detail;this._seek(this._percentToTime(n),n,e);let{pauseWhileDragging:i}=this.$props;i()&&this._playingBeforeDragStart&&(this._media.remote.play(e),this._playingBeforeDragStart=!1)}_onValueChange(e){let{dragging:n}=this.$state;n()||!e.trigger||this._onDragEnd(e)}_getStep(){let e=this.$props.step()/this._media.$state.duration()*100;return Number.isFinite(e)?e:1}_getKeyStep(){let e=this.$props.keyStep()/this._media.$state.duration()*100;return Number.isFinite(e)?e:1}_roundValue(e){return At(e,3)}_isDisabled(){let{canSeek:e}=this._media.$state;return this.$props.disabled()||!e()}_getARIAValueNow(){let{value:e}=this.$state;return Math.round(e())}_getARIAValueText(){let e=this._percentToTime(this.$state.value()),{duration:n}=this._media.$state;return Number.isFinite(e)?`${bc(e)} out of ${bc(n())}`:"live"}_percentToTime(e){let{duration:n}=this._media.$state;return At(e/100*n(),5)}_timeToPercent(e){let{liveEdge:n,duration:i}=this._media.$state,r=Math.max(0,Math.min(1,n()?1:Math.min(e,i())/i()));return Number.isNaN(r)?0:Number.isFinite(r)?r*100:100}_formatValue(e){let n=this._percentToTime(e),{live:i,duration:r}=this._media.$state;return Number.isFinite(n)?(i()?n-r():n).toFixed(0):"LIVE"}_formatTime(e,n,i,r){let s=this._percentToTime(e),{live:a,duration:o}=this._media.$state,l=a()?s-o():s;return Number.isFinite(s)?`${l<0?"-":""}${Fr(Math.abs(l),n,i,r)}`:"LIVE"}};Za.props={...bi.props,step:.1,keyStep:5,shiftKeyMultiplier:2,pauseWhileDragging:!1,seekingRequestThrottle:100};Za.state=df;t3=Object.defineProperty,n3=Object.getOwnPropertyDescriptor,hf=(t,e,n,i)=>{for(var r=i>1?void 0:i?n3(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&t3(e,n,r),r},Zi=class extends q{constructor(){super(...arguments),this._titleRef=null,this._refs=[],this._$track=D(null),this._$cues=D([]),this._activeIndex=D(-1),this._activePointerIndex=D(-1),this._bufferedIndex=0,this._updateBufferedPercent=Rr(e=>{let n,i=this._$cues(),{clipStartTime:r}=this._media.$state,s=r(),a=this._getEndTime(i);for(let o=this._bufferedIndex;o{let e=C(this._$track);!this.scope||!e||!e.cues.length||(this._$cues.set(this._fillGaps(e.cues)),this._activeIndex.set(0),this._bufferedIndex=0)},150,!0)}get cues(){return this._$cues()}get activeCue(){return this._$cues()[this._activeIndex()]||null}get activePointerCue(){return this._$cues()[this._activePointerIndex()]||null}onSetup(){this._media=le(),this._sliderState=_s(Za.state)}onAttach(e){no(this._media.textTracks,"chapters",this._setTrack.bind(this)),b(this._onTrackChange.bind(this))}onConnect(){G(()=>this._reset.bind(this))}onDestroy(){this._setTrack(null)}setRefs(e){if(this._refs=e,this._updateScope?.dispose(),this._refs.length===1){let n=this._refs[0];n.style.width="100%",n.style.setProperty("--chapter-fill","var(--slider-fill)"),n.style.setProperty("--chapter-progress","var(--slider-progress)")}else this._refs.length>0&&et(()=>this._watch(),this._updateScope=$t())}_setTrack(e){C(this._$track)!==e&&(this._reset(),this._$track.set(e))}_reset(){this._refs=[],this._$cues.set([]),this._activeIndex.set(-1),this._activePointerIndex.set(-1),this._bufferedIndex=0,this._updateScope?.dispose()}_watch(){this._refs.length&&(b(this._watchContainerWidths.bind(this)),b(this._watchFillPercent.bind(this)),b(this._watchPointerPercent.bind(this)),b(this._watchBufferedPercent.bind(this)))}_watchContainerWidths(){let e=this._$cues();if(!e.length)return;let n,{clipStartTime:i,clipEndTime:r}=this._media.$state,s=i(),a=r()||e[e.length-1].endTime,o=a-s,l=100;for(let c=0;cc?this._updateFillPercents(c,d,"100%"):d=0&&i<100)return l;return 0}_watchBufferedPercent(){this._updateBufferedPercent(this._bufferedPercent())}_calcMediaBufferedPercent(){let{bufferedEnd:e,duration:n}=this._media.$state;return At(Math.min(e()/Math.max(n(),1),1),3)*100}_getEndTime(e){let{clipEndTime:n}=this._media.$state,i=n();return i>0?i:e[e.length-1]?.endTime||0}_calcPercent(e,n,i,r){if(this._$cues().length===0)return 0;let a=r-i,o=Math.max(0,e.startTime-i),l=Math.min(r,e.endTime)-i,c=o/a,u=c*100,d=Math.min(1,c+(l-o)/a)*100;return Math.max(0,At(n>=d?100:(n-u)/(d-u)*100,3))}_fillGaps(e){let n=[],{clipStartTime:i,clipEndTime:r,duration:s}=this._media.$state,a=i(),o=r()||1/0;e=e.filter(u=>u.startTime<=o&&u.endTime>=a);let l=e[0];l&&l.startTime>a&&n.push(new window.VTTCue(a,l.startTime,""));for(let u=0;u0&&n.push(new window.VTTCue(d.endTime,d.endTime+h,""))}}let c=e[e.length-1];return c&&(n.push(c),s()>=0&&(o===0||o!==1/0&&c.endTime1&&n.push(new window.VTTCue(c.endTime,s(),""))),n}_onTrackChange(){if(!this.scope)return;let{disabled:e}=this.$props;if(e()){this._$cues.set([]),this._activeIndex.set(0),this._bufferedIndex=0;return}let n=this._$track();if(n){let i=this._onCuesChange.bind(this);i(),G(S(n,"add-cue",i)),G(S(n,"remove-cue",i)),b(this._watchMediaDuration.bind(this))}return this._titleRef=this._findChapterTitleRef(),this._titleRef&&b(this._onChapterTitleChange.bind(this)),()=>{this._titleRef&&(this._titleRef.textContent="",this._titleRef=null)}}_watchMediaDuration(){this._media.$state.duration(),this._onCuesChange()}_onChapterTitleChange(){let e=this.activePointerCue||this.activeCue;this._titleRef&&(this._titleRef.textContent=e?.text||"")}_findParentSlider(){let e=this.el;for(;e&&e.getAttribute("role")!=="slider";)e=e.parentElement;return e}_findChapterTitleRef(){let e=this._findParentSlider();return e?e.querySelector('[data-part="chapter-title"]'):null}};Zi.props={disabled:!1};hf([ee],Zi.prototype,"cues",1);hf([ee],Zi.prototype,"activeCue",1);hf([ee],Zi.prototype,"activePointerCue",1);hf([Ae],Zi.prototype,"setRefs",1);ct=vi(),i3=["a[href]","[tabindex]","input","select","button"].map(t=>`${t}:not([aria-hidden='true'])`).join(","),vP=new Set(["Escape","Tab","ArrowUp","ArrowDown","Home","PageUp","End","PageDown","Enter"," "]),bw=class{constructor(e){this._delegate=e,this._index=0,this._el=null,this._elements=[]}get _items(){return this._elements}_attachMenu(e){return S(e,"focus",this._onFocus.bind(this)),this._el=e,G(()=>{this._el=null}),this}_listen(){this._el&&(this._update(),S(this._el,"keyup",this._onKeyUp.bind(this)),S(this._el,"keydown",this._onKeyDown.bind(this)),G(()=>{this._index=0,this._elements=[]}))}_update(){this._index=0,this._elements=this._getFocusableElements()}_scroll(e=this._findActiveIndex()){let n=this._elements[e],i=this._delegate._getScrollContainer();n&&i&&requestAnimationFrame(()=>{i.scrollTop=n.offsetTop-i.offsetHeight/2+n.offsetHeight/2})}_focusAt(e){this._index=e,this._elements[e]?.focus(),this._scroll(e)}_findActiveIndex(){return this._elements.findIndex(e=>e.getAttribute("aria-checked")==="true")}_onFocus(){this._update(),setTimeout(()=>{let e=this._findActiveIndex();this._focusAt(e>=0?e:0)},100)}_onKeyUp(e){vP.has(e.key)&&(e.stopPropagation(),e.preventDefault())}_onKeyDown(e){if(vP.has(e.key))switch(e.stopPropagation(),e.preventDefault(),e.key){case"Escape":this._delegate._closeMenu(e);break;case"Tab":this._focusAt(this._nextIndex(e.shiftKey?-1:1));break;case"ArrowUp":this._focusAt(this._nextIndex(-1));break;case"ArrowDown":this._focusAt(this._nextIndex(1));break;case"Home":case"PageUp":this._focusAt(0);break;case"End":case"PageDown":this._focusAt(this._elements.length-1);break}}_nextIndex(e){let n=this._index;do n=(n+e+this._elements.length)%this._elements.length;while(this._elements[n]?.offsetParent===null);return n}_getFocusableElements(){if(!this._el)return[];let e=this._el.querySelectorAll(i3),n=[],i=r=>r.getAttribute("role")==="menu";for(let r of e)r instanceof HTMLElement&&r.offsetParent!==null&&VP(this._el,r,i)&&n.push(r);return n}},r3=Object.defineProperty,s3=Object.getOwnPropertyDescriptor,ou=(t,e,n,i)=>{for(var r=i>1?void 0:i?s3(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&r3(e,n,r),r},a3=0,Ji=class extends q{constructor(){super(),this._expanded=D(!1),this._disabled=D(!1),this._trigger=D(null),this._content=D(null),this._isTriggerDisabled=D(!1),this._submenus=new Set,this._menuObserver=null,this._removeSubmenuBind=this._removeSubmenu.bind(this),this._onSubmenuOpenBind=this._onSubmenuOpen.bind(this),this._onSubmenuCloseBind=this._onSubmenuClose.bind(this),this._onResize=Rr(()=>{let n=C(this._content);if(!n||N)return;let i=0,r=getComputedStyle(n),s=[...n.children];for(let a of["paddingTop","paddingBottom","borderTopWidth","borderBottomWidth"])i+=parseFloat(r[a])||0;for(let a of s)if(a instanceof HTMLElement&&a.style.display==="contents")s.push(...a.children);else if(a.nodeType===3)i+=parseFloat(getComputedStyle(a).fontSize);else if(a instanceof HTMLElement){let o=getComputedStyle(a);if(o.display==="none")continue;i+=a.offsetHeight+(parseFloat(o.marginTop)||0)+(parseFloat(o.marginBottom)||0)}requestAnimationFrame(()=>{lt(n,"--menu-height",i+"px")})});let{showDelay:e}=this.$props;this._popper=new Uh({_trigger:this._trigger,_content:this._content,_showDelay:e,_listen:(n,i,r)=>{Dr(n,a=>{this._expanded()?r(a):i(a)});let s=this._getCloseTarget();s&&Dr(s,a=>{a.stopPropagation(),r(a)})},_onChange:this._onExpandedChange.bind(this)})}get triggerElement(){return this._trigger()}get contentElement(){return this._content()}get isSubmenu(){return!!this._parentMenu}onSetup(){this._media=le();let e=++a3;this._menuId=`media-menu-${e}`,this._menuButtonId=`media-menu-button-${e}`,this._focus=new bw({_getScrollContainer:this._findScrollContainer.bind(this),_closeMenu:this.close.bind(this)}),Tn(ct)&&(this._parentMenu=Ie(ct)),this.setAttributes({"data-open":this._expanded,"data-submenu":this.isSubmenu,"data-disabled":this._isDisabled.bind(this)}),Rt(ct,{_button:this._trigger,_expanded:this._expanded,_hint:D(""),_disable:this._disable.bind(this),_attachMenuButton:this._attachMenuButton.bind(this),_attachMenuItems:this._attachMenuItems.bind(this),_attachObserver:this._attachObserver.bind(this),_disableMenuButton:this._disableMenuButton.bind(this),_addSubmenu:this._addSubmenu.bind(this)})}onAttach(e){e.style.setProperty("display","contents"),this._focus._attachMenu(e)}onConnect(e){b(this._watchExpanded.bind(this)),this.isSubmenu&&this._parentMenu?._addSubmenu(this)}onDestroy(){this._trigger.set(null),this._content.set(null),this._menuObserver=null}_watchExpanded(){let e=this._isExpanded();this.isSubmenu||this._onResize(),this._updateMenuItemsHidden(e),e&&(b(()=>{let{height:n}=this._media.$state,i=this._content();i&<(i,"--player-height",n()+"px")}),this._focus._listen(),this.listen("pointerup",this._onPointerUp.bind(this)),S(window,"pointerup",this._onWindowPointerUp.bind(this)))}_attachMenuButton(e){let n=e.el,i=this.isSubmenu,r=Gt(this._isDisabled.bind(this));ve(n,"tabindex",i?"-1":"0"),ve(n,"role",i?"menuitem":"button"),Z(n,"id",this._menuButtonId),Z(n,"aria-haspopup","menu"),Z(n,"aria-expanded","false"),Z(n,"data-submenu",this.isSubmenu),this.isSubmenu||this._stopClickPropagation(n);let s=()=>{Z(n,"data-open",this._expanded()),Z(n,"aria-disabled",r())};N?s():b(s),this._trigger.set(n),G(()=>{this._trigger.set(null)})}_attachMenuItems(e){let n=e.el;n.style.setProperty("display","none"),Z(n,"id",this._menuId),ve(n,"role","menu"),ve(n,"tabindex","-1"),Z(n,"data-submenu",this.isSubmenu),this._content.set(n),G(()=>this._content.set(null));let i=()=>Z(n,"data-open",this._expanded());if(N?i():b(i),this._focus._attachMenu(n),this._updateMenuItemsHidden(!1),!this.isSubmenu){let r=this._onResizeTransition.bind(this);e.listen("transitionstart",r),e.listen("transitionend",r),e.listen("vds-menu-resize",this._onResize)}}_attachObserver(e){this._menuObserver=e}_stopClickPropagation(e){S(e,"click",n=>n.stopPropagation()),S(e,"pointerup",n=>n.stopPropagation())}_updateMenuItemsHidden(e){let n=C(this._content);n&&Z(n,"aria-hidden",Oa(!e))}_disableMenuButton(e){this._isTriggerDisabled.set(e)}_onExpandedChange(e,n){if(n?.stopPropagation(),this._expanded()===e)return;if(this._isDisabled()){e&&this._popper.hide(n);return}this.el?.dispatchEvent(new Event("vds-menu-resize",{bubbles:!0,composed:!0}));let i=this._trigger(),r=this._content();if(i&&(Z(i,"aria-controls",e&&this._menuId),Z(i,"aria-expanded",Oa(e))),r&&Z(r,"aria-labelledby",e&&this._menuButtonId),this._expanded.set(e),this._toggleMediaControls(n),Zn(),Hi(n)){e?r?.focus():i?.focus();for(let s of[this.el,r])s&&s.setAttribute("data-keyboard","")}else for(let s of[this.el,r])s&&s.removeAttribute("data-keyboard");this.dispatch(e?"open":"close",{trigger:n}),e?(!this.isSubmenu&&this._media.activeMenu!==this&&(this._media.activeMenu?.close(n),this._media.activeMenu=this),this._menuObserver?._onOpen?.(n)):(this.isSubmenu?setTimeout(()=>{for(let s of this._submenus)s.close(n)},300):this._media.activeMenu=null,this._menuObserver?._onClose?.(n)),e&&!Hi(n)&&requestAnimationFrame(()=>{this._focus._update(),setTimeout(()=>{this._focus._scroll()},100)})}_isExpanded(){return!this._isDisabled()&&this._expanded()}_isDisabled(){return this._disabled()||this._isTriggerDisabled()}_disable(e){this._disabled.set(e)}_onPointerUp(e){e.stopPropagation()}_onWindowPointerUp(e){if(!(!(e.target instanceof Node)||this._content()?.contains(e.target))){if(this.isSubmenu)return setTimeout(this.close.bind(this,e),800);this.close(e)}}_getCloseTarget(){let e=this.el?.querySelector('[data-part="close-target"]');return this.el&&e&&VP(this.el,e,n=>n.getAttribute("role")==="menu")?e:null}_findScrollContainer(){if(this.isSubmenu){let e=this.el;for(;e&&e.tagName!=="media-menu"&&e.hasAttribute("data-submenu");)e=e.parentNode;return e}else return C(this._content)||null}_toggleMediaControls(e){this.isSubmenu||(this._expanded()?this._media.remote.pauseControls(e):this._media.remote.resumeControls(e))}_addSubmenu(e){this._submenus.add(e),S(e,"open",this._onSubmenuOpenBind),S(e,"close",this._onSubmenuCloseBind),G(this._removeSubmenuBind)}_removeSubmenu(e){this._submenus.delete(e)}_onSubmenuOpen(e){this.isSubmenu&&this.triggerElement?.setAttribute("aria-hidden","true");for(let n of this._submenus)if(n!==e.target)for(let i of[n.el,n.triggerElement])i?.setAttribute("aria-hidden","true")}_onSubmenuClose(){this.isSubmenu&&this.triggerElement?.setAttribute("aria-hidden","false");for(let e of this._submenus)for(let n of[e.el,e.triggerElement])n?.setAttribute("aria-hidden","false")}_onResizeTransition(e){let n=this._content();if(n&&e.propertyName==="height"){let i=e.type==="transitionstart";Z(n,"data-resizing",i)}}open(e){C(this._expanded)||(this._popper.show(e),Zn())}close(e){C(this._expanded)&&(this._popper.hide(e),Zn())}};Ji.props={showDelay:0};ou([ee],Ji.prototype,"triggerElement",1);ou([ee],Ji.prototype,"contentElement",1);ou([ee],Ji.prototype,"isSubmenu",1);ou([Ae],Ji.prototype,"open",1);ou([Ae],Ji.prototype,"close",1);o3=Object.defineProperty,l3=Object.getOwnPropertyDescriptor,c3=(t,e,n,i)=>{for(var r=i>1?void 0:i?l3(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&o3(e,n,r),r},Cs=class extends q{get expanded(){return this._menu?._expanded()??!1}constructor(){super(),new pn}onSetup(){this._menu=Ie(ct)}onAttach(e){this._menu._attachMenuButton(this),b(this._watchDisabled.bind(this)),ve(e,"type","button")}onConnect(e){let n=Array.from(e.querySelectorAll('[data-part="hint"]')).pop();n&&b(()=>{let i=this._menu._hint();i&&(n.textContent=i)}),Dr(e,i=>{this.dispatch("select",{trigger:i})})}_watchDisabled(){this._menu._disableMenuButton(this.$props.disabled())}};Cs.props={disabled:!1};c3([ee],Cs.prototype,"expanded",1);tf=class extends Cs{},nf=class extends q{constructor(){super(...arguments),this._target=null}onSetup(){this._media=le(),Rt(fc,{_attach:this._attachElement.bind(this)})}onAttach(e){e.style.setProperty("display","contents")}onConnect(e){}onDestroy(){this._target?.remove(),this._target=null}_attachElement(e){this._portal(!1),this._target=e,Eh(()=>{Eh(()=>{this.connectScope&&b(this._watchDisabled.bind(this))})})}_watchDisabled(){let{fullscreen:e}=this._media.$state,{disabled:n}=this.$props,i=n();this._portal(i==="fullscreen"?!e():!i)}_portal(e){if(!this._target)return;let n=this._getContainer(this.$props.container());if(!n)return;let i=this._target.parentElement===n;Z(this._target,"data-portal",e),e?i||(this._target.remove(),n.append(this._target)):i&&this._target.parentElement===n&&(this._target.remove(),this.el?.append(this._target))}_getContainer(e){return e instanceof HTMLElement?e:e?document.querySelector(e):document.body}};nf.props={container:null,disabled:!1};fc=vi(),Ec=class extends q{constructor(){super(),new pn;let{placement:e}=this.$props;this.setAttributes({"data-placement":e})}onAttach(e){if(this._menu=Ie(ct),this._menu._attachMenuItems(this),Tn(fc)){let n=Ie(fc);n&&(Rt(fc,null),n._attach(e),G(()=>n._attach(null)))}}onConnect(e){b(this._watchPlacement.bind(this))}_watchPlacement(){if(!this.el)return;let e=this.$props.placement();if(e){Object.assign(this.el.style,{position:"absolute",top:0,left:0,width:"max-content"});let{offset:n,alignOffset:i}=this.$props;return FP(this.el,this._getButton(),e,{offsetVarName:"media-menu",xOffset:i(),yOffset:n()})}else this.el.removeAttribute("style"),this.el.style.display="none"}_getButton(){return this._menu._button()}};Ec.props={placement:null,offset:0,alignOffset:0};xw=vi(),Or=class extends Mt{constructor(){super(...arguments),this._group=new Set,this._value=D(""),this._controller=null,this._onChangeBind=this._onChange.bind(this)}get _values(){return Array.from(this._group).map(e=>e._value())}get value(){return this._value()}set value(e){this._onChange(e)}onSetup(){Rt(xw,{add:this._addRadio.bind(this),remove:this._removeRadio.bind(this)})}onAttach(e){Tn(ct)||ve(e,"role","radiogroup"),this.setAttributes({value:this._value})}onDestroy(){this._group.clear()}_addRadio(e){this._group.has(e)||(this._group.add(e),e._onCheck=this._onChangeBind,e._check(e._value()===this._value()))}_removeRadio(e){e._onCheck=null,this._group.delete(e)}_onChange(e,n){let i=C(this._value);if(!e||e===i)return;let r=this._findRadio(i),s=this._findRadio(e);r?._check(!1,n),s?._check(!0,n),this._value.set(e),this._onValueChange?.(e,n)}_findRadio(e){for(let n of this._group)if(e===C(n._value))return n;return null}},u3=Object.defineProperty,d3=Object.getOwnPropertyDescriptor,n1=(t,e,n,i)=>{for(var r=i>1?void 0:i?d3(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&u3(e,n,r),r},Ja=class extends q{get values(){return this._controller._values}get value(){return this._controller.value}set value(e){this._controller.value=e}constructor(){super(),this._controller=new Or,this._controller._onValueChange=this._onValueChange.bind(this)}onSetup(){N?this._watchValue():b(this._watchValue.bind(this))}_watchValue(){this._controller.value=this.$props.value()}_onValueChange(e,n){let i=this.createEvent("change",{detail:e,trigger:n});this.dispatch(i)}};Ja.props={value:""};n1([ee],Ja.prototype,"values",1);n1([ee],Ja.prototype,"value",1);p3=Object.defineProperty,h3=Object.getOwnPropertyDescriptor,f3=(t,e,n,i)=>{for(var r=i>1?void 0:i?h3(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&p3(e,n,r),r},eo=class extends q{constructor(){super(),this._checked=D(!1),this._controller={_value:this.$props.value,_check:this._check.bind(this),_onCheck:null},new pn}get checked(){return this._checked()}onSetup(){this.setAttributes({value:this.$props.value,"data-checked":this._checked,"aria-checked":Gt(this._checked)})}onAttach(e){let n=Tn(ct);ve(e,"tabindex",n?"-1":"0"),ve(e,"role",n?"menuitemradio":"radio"),b(this._watchValue.bind(this))}onConnect(e){this._addToGroup(),Dr(e,this._onPress.bind(this)),G(this._onDisconnect.bind(this))}_onDisconnect(){et(()=>{Ie(xw).remove(this._controller)},this.connectScope)}_addToGroup(){Ie(xw).add(this._controller)}_watchValue(){let{value:e}=this.$props,n=e();C(this._checked)&&this._controller._onCheck?.(n)}_onPress(e){C(this._checked)||(this._onChange(!0,e),this._onSelect(e),this._controller._onCheck?.(C(this.$props.value),e))}_check(e,n){C(this._checked)!==e&&this._onChange(e,n)}_onChange(e,n){this._checked.set(e),this.dispatch("change",{detail:e,trigger:n})}_onSelect(e){this.dispatch("select",{trigger:e})}};eo.props={value:""};f3([ee],eo.prototype,"checked",1);m3=Object.defineProperty,g3=Object.getOwnPropertyDescriptor,Ow=(t,e,n,i)=>{for(var r=i>1?void 0:i?g3(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&m3(e,n,r),r},$s=class extends q{constructor(){super(),this._index=D(0),this._track=D(null),this._cues=D([]),this._controller=new Or,this._controller._onValueChange=this._onValueChange.bind(this)}get value(){return this._controller.value}get disabled(){return!this._cues()?.length}onSetup(){this._media=le(),Tn(ct)&&(this._menu=Ie(ct));let{thumbnails:e}=this.$props;this.setAttributes({"data-thumbnails":()=>!!e()})}onAttach(e){this._menu?._attachObserver({_onOpen:this._onOpen.bind(this)})}getOptions(){let{clipStartTime:e,clipEndTime:n}=this._media.$state,i=e(),r=n()||1/0;return this._cues().map((s,a)=>({cue:s,value:a.toString(),label:s.text,startTime:Fr(Math.max(0,s.startTime-i),!1),duration:bc(Math.min(r,s.endTime)-Math.max(i,s.startTime))}))}_onOpen(){C(()=>this._watchCurrentTime())}onConnect(e){b(this._watchValue.bind(this)),b(this._watchCurrentTime.bind(this)),b(this._watchControllerDisabled.bind(this)),b(this._watchTrack.bind(this)),no(this._media.textTracks,"chapters",this._track.set)}_watchTrack(){let e=this._track();if(!e)return;let n=this._onCuesChange.bind(this,e);return n(),S(e,"add-cue",n),S(e,"remove-cue",n),()=>{this._cues.set([])}}_onCuesChange(e){let{clipStartTime:n,clipEndTime:i}=this._media.$state,r=n(),s=i()||1/0;this._cues.set([...e.cues].filter(a=>a.startTime<=s&&a.endTime>=r))}_watchValue(){this._controller.value=this._getValue()}_watchCurrentTime(){if(!this._menu?._expanded())return;if(!this._track()){this._index.set(-1);return}let{realCurrentTime:n,clipStartTime:i,clipEndTime:r}=this._media.$state,s=i(),a=r()||1/0,o=n(),l=this._cues().findIndex(c=>xh(c,o));if(this._index.set(l),l>=0){let c=this._cues()[l],u=this.el.querySelector("[aria-checked='true']"),d=Math.max(s,c.startTime),p=Math.min(a,c.endTime)-d,h=Math.max(0,o-d)/p*100;u&<(u,"--progress",At(h,3)+"%")}}_watchControllerDisabled(){this._menu?._disable(this.disabled)}_getValue(){return this._index().toString()}_onValueChange(e,n){if(this.disabled||!n)return;let i=+e,r=this._cues(),{clipStartTime:s}=this._media.$state;Be(i)&&r?.[i]&&(this._index.set(i),this._media.remote.seek(r[i].startTime-s(),n),this.dispatch("change",{detail:r[i],trigger:n}))}};$s.props={thumbnails:null};Ow([ee],$s.prototype,"value",1);Ow([ee],$s.prototype,"disabled",1);Ow([Ae],$s.prototype,"getOptions",1);v3=Object.defineProperty,y3=Object.getOwnPropertyDescriptor,Vw=(t,e,n,i)=>{for(var r=i>1?void 0:i?y3(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&v3(e,n,r),r},Ms=class extends q{get value(){return this._controller.value}get disabled(){let{audioTracks:e}=this._media.$state;return e().length===0}constructor(){super(),this._controller=new Or,this._controller._onValueChange=this._onValueChange.bind(this)}onSetup(){this._media=le(),Tn(ct)&&(this._menu=Ie(ct))}onConnect(e){b(this._watchValue.bind(this)),b(this._watchControllerDisabled.bind(this)),b(this._watchHintText.bind(this))}getOptions(){let{audioTracks:e}=this._media.$state;return e().map(n=>({track:n,label:n.label,value:n.label.toLowerCase()}))}_watchValue(){this._controller.value=this._getValue()}_watchHintText(){let{emptyLabel:e}=this.$props,{audioTrack:n}=this._media.$state,i=n();this._menu?._hint.set(i?.label??e())}_watchControllerDisabled(){this._menu?._disable(this.disabled)}_getValue(){let{audioTrack:e}=this._media.$state,n=e();return n?n.label.toLowerCase():""}_onValueChange(e,n){if(this.disabled)return;let i=this._media.audioTracks.toArray().findIndex(r=>r.label.toLowerCase()===e);if(i>=0){let r=this._media.audioTracks[i];this._media.remote.changeAudioTrack(i,n),this.dispatch("change",{detail:r,trigger:n})}}};Ms.props={emptyLabel:"Default"};Vw([ee],Ms.prototype,"value",1);Vw([ee],Ms.prototype,"disabled",1);Vw([Ae],Ms.prototype,"getOptions",1);_3=Object.defineProperty,w3=Object.getOwnPropertyDescriptor,Fw=(t,e,n,i)=>{for(var r=i>1?void 0:i?w3(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&_3(e,n,r),r},Rs=class extends q{get value(){return this._controller.value}get disabled(){let{hasCaptions:e}=this._media.$state;return!e()}constructor(){super(),this._controller=new Or,this._controller._onValueChange=this._onValueChange.bind(this)}onSetup(){this._media=le(),Tn(ct)&&(this._menu=Ie(ct))}onConnect(e){super.onConnect?.(e),b(this._watchValue.bind(this)),b(this._watchControllerDisabled.bind(this)),b(this._watchHintText.bind(this))}getOptions(){let{offLabel:e}=this.$props,{textTracks:n}=this._media.$state;return[{value:"off",label:e},...n().filter(We).map(i=>({track:i,label:i.label,value:this._getTrackValue(i)}))]}_watchValue(){this._controller.value=this._getValue()}_watchHintText(){let{offLabel:e}=this.$props,{textTrack:n}=this._media.$state,i=n();this._menu?._hint.set(i&&We(i)&&i.mode==="showing"?i.label:e())}_watchControllerDisabled(){this._menu?._disable(this.disabled)}_getValue(){let{textTrack:e}=this._media.$state,n=e();return n&&We(n)&&n.mode==="showing"?this._getTrackValue(n):"off"}_onValueChange(e,n){if(this.disabled)return;if(e==="off"){let r=this._media.textTracks.selected;if(r){let s=this._media.textTracks.toArray().indexOf(r);this._media.remote.changeTextTrackMode(s,"disabled",n),this.dispatch("change",{detail:null,trigger:n})}return}let i=this._media.textTracks.toArray().findIndex(r=>this._getTrackValue(r)===e);if(i>=0){let r=this._media.textTracks[i];this._media.remote.changeTextTrackMode(i,"showing",n),this.dispatch("change",{detail:r,trigger:n})}}_getTrackValue(e){return e.id+":"+e.kind+"-"+e.label.toLowerCase()}};Rs.props={offLabel:"Off"};Fw([ee],Rs.prototype,"value",1);Fw([ee],Rs.prototype,"disabled",1);Fw([Ae],Rs.prototype,"getOptions",1);b3=Object.defineProperty,x3=Object.getOwnPropertyDescriptor,zw=(t,e,n,i)=>{for(var r=i>1?void 0:i?x3(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&b3(e,n,r),r},Ls=class extends q{get value(){return this._controller.value}get disabled(){let{rates:e}=this.$props,{canSetPlaybackRate:n}=this._media.$state;return!n()||e().length===0}constructor(){super(),this._controller=new Or,this._controller._onValueChange=this._onValueChange.bind(this)}onSetup(){this._media=le(),Tn(ct)&&(this._menu=Ie(ct))}onConnect(e){b(this._watchValue.bind(this)),b(this._watchHintText.bind(this)),b(this._watchControllerDisabled.bind(this))}getOptions(){let{rates:e,normalLabel:n}=this.$props;return e().map(i=>({label:i===1?n:i+"\xD7",value:i.toString()}))}_watchValue(){this._controller.value=this._getValue()}_watchHintText(){let{normalLabel:e}=this.$props,{playbackRate:n}=this._media.$state,i=n();this._menu?._hint.set(i===1?e():i+"\xD7")}_watchControllerDisabled(){this._menu?._disable(this.disabled)}_getValue(){let{playbackRate:e}=this._media.$state;return e().toString()}_onValueChange(e,n){if(this.disabled)return;let i=+e;this._media.remote.changePlaybackRate(i,n),this.dispatch("change",{detail:i,trigger:n})}};Ls.props={normalLabel:"Normal",rates:[.25,.5,.75,1,1.25,1.5,1.75,2]};zw([ee],Ls.prototype,"value",1);zw([ee],Ls.prototype,"disabled",1);zw([Ae],Ls.prototype,"getOptions",1);k3=Object.defineProperty,E3=Object.getOwnPropertyDescriptor,Uw=(t,e,n,i)=>{for(var r=i>1?void 0:i?E3(e,n):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&k3(e,n,r),r},Is=class extends q{constructor(){super(),this._sortedQualities=mi(()=>{let{qualities:e}=this._media.$state;return[...e()].sort((n,i)=>i.height===n.height?i.bitrate-n.bitrate:i.height-n.height)}),this._controller=new Or,this._controller._onValueChange=this._onValueChange.bind(this)}get value(){return this._controller.value}get disabled(){let{canSetQuality:e,qualities:n}=this._media.$state;return!e()||n().length===0}onSetup(){this._media=le(),Tn(ct)&&(this._menu=Ie(ct))}onConnect(e){b(this._watchValue.bind(this)),b(this._watchControllerDisabled.bind(this)),b(this._watchHintText.bind(this))}getOptions(){let{autoLabel:e,hideBitrate:n}=this.$props;return[{value:"auto",label:e},...this._sortedQualities().map(i=>{let r=i.bitrate>=0?`${At(i.bitrate/1e6,2)} Mbps`:null;return{quality:i,label:i.height+"p",value:this._getQualityId(i),bitrate:()=>n()?null:r}})]}_watchValue(){this._controller.value=this._getValue()}_watchHintText(){let{autoLabel:e}=this.$props,{autoQuality:n,quality:i}=this._media.$state,r=i()?i().height+"p":"";this._menu?._hint.set(n()?e()+(r?` (${r})`:""):r)}_watchControllerDisabled(){this._menu?._disable(this.disabled)}_onValueChange(e,n){if(this.disabled)return;if(e==="auto"){this._media.remote.changeQuality(-1,n),this.dispatch("change",{detail:"auto",trigger:n});return}let{qualities:i}=this._media.$state,r=C(i).findIndex(s=>this._getQualityId(s)===e);if(r>=0){let s=C(i)[r];this._media.remote.changeQuality(r,n),this.dispatch("change",{detail:s,trigger:n})}}_getValue(){let{quality:e,autoQuality:n}=this._media.$state;if(n())return"auto";let i=e();return i?this._getQualityId(i):"auto"}_getQualityId(e){return e.height+"_"+e.bitrate}};Is.props={autoLabel:"Auto",hideBitrate:!1};Uw([ee],Is.prototype,"value",1);Uw([ee],Is.prototype,"disabled",1);Uw([Ae],Is.prototype,"getOptions",1);rf=class extends q{constructor(){super(...arguments),this._provider=null,this._presses=0,this._pressTimerId=-1}onSetup(){this._media=le();let{event:e,action:n}=this.$props;this.setAttributes({event:e,action:n})}onAttach(e){e.setAttribute("data-media-gesture",""),e.style.setProperty("pointer-events","none")}onConnect(e){this._provider=this._media.player.el?.querySelector("[data-media-provider]"),b(this._attachListener.bind(this))}_attachListener(){let e=this.$props.event(),n=this.$props.disabled();!this._provider||!e||n||(/^dbl/.test(e)&&(e=e.split(/^dbl/)[1]),(e==="pointerup"||e==="pointerdown")&&this._media.$state.pointer()==="coarse"&&(e=e==="pointerup"?"touchend":"touchstart"),S(this._provider,e,this._acceptEvent.bind(this),{passive:!1}))}_acceptEvent(e){if(this.$props.disabled()||Yl(e)&&(e.button!==0||this._media.activeMenu)||Na(e)&&this._media.activeMenu||Rw(e)||!this._inBounds(e))return;if(e.MEDIA_GESTURE=!0,e.preventDefault(),!C(this.$props.event)?.startsWith("dbl"))this._presses===0&&setTimeout(()=>{this._presses===1&&this._handleEvent(e)},250);else if(this._presses===1){queueMicrotask(()=>this._handleEvent(e)),clearTimeout(this._pressTimerId),this._presses=0;return}this._presses===0&&(this._pressTimerId=window.setTimeout(()=>{this._presses=0},275)),this._presses++}_handleEvent(e){this.el.setAttribute("data-triggered",""),requestAnimationFrame(()=>{this._isTopLayer()&&this._performAction(C(this.$props.action),e),requestAnimationFrame(()=>{this.el.removeAttribute("data-triggered")})})}_inBounds(e){if(!this.el)return!1;if(Yl(e)||t_(e)||Na(e)){let n=Na(e)?e.changedTouches[0]??e.touches[0]:void 0,i=n?.clientX??e.clientX,r=n?.clientY??e.clientY,s=this.el.getBoundingClientRect(),a=r>=s.top&&r<=s.bottom&&i>=s.left&&i<=s.right;return e.type.includes("leave")?!a:a}return!0}_isTopLayer(){let e=this._media.player.el.querySelectorAll("[data-media-gesture][data-triggered]");return Array.from(e).sort((n,i)=>+getComputedStyle(i).zIndex-+getComputedStyle(n).zIndex)[0]===this.el}_performAction(e,n){if(!e)return;let i=new j("will-trigger",{detail:e,cancelable:!0,trigger:n});if(this.dispatchEvent(i),i.defaultPrevented)return;let[r,s]=e.replace(/:([a-z])/,"-$1").split(":");e.includes(":fullscreen")?this._media.remote.toggleFullscreen("prefer-media",n):e.includes("seek:")?this._media.remote.seek(C(this._media.$state.currentTime)+(+s||0),n):this._media.remote[Up(r)](n),this.dispatch("trigger",{detail:e,trigger:n})}};rf.props={disabled:!1,event:void 0,action:void 0};kw=class{constructor(e){this._renderer=e,this.priority=10,this._track=null,this._disposal=Zl()}attach(){}canRender(){return!0}detach(){this._disposal.empty(),this._renderer.reset(),this._track=null}changeTrack(e){!e||this._track===e||(this._disposal.empty(),e.readyState<2?(this._renderer.reset(),this._disposal.add(S(e,"load",()=>this._changeTrack(e),{once:!0}))):this._changeTrack(e),this._disposal.add(S(e,"add-cue",n=>{this._renderer.addCue(n.detail)}),S(e,"remove-cue",n=>{this._renderer.removeCue(n.detail)})),this._track=e)}_changeTrack(e){this._renderer.changeTrack({cues:[...e.cues],regions:[...e.regions]})}},sf=class extends q{onSetup(){this._media=le(),this.setAttributes({"aria-hidden":Gt(this._isHidden.bind(this))})}onAttach(e){e.style.setProperty("pointer-events","none")}onConnect(e){if(this._renderer){b(this._watchViewType.bind(this));return}Promise.resolve().then(()=>(oc(),ac)).then(n=>{this.connectScope&&et(()=>{this._lib=n;let{CaptionsRenderer:i}=this._lib;this._renderer=new i(e),this._textRenderer=new kw(this._renderer),b(this._watchViewType.bind(this))},this.connectScope)})}onDestroy(){this._textRenderer&&(this._textRenderer.detach(),this._media.textRenderers.remove(this._textRenderer)),this._renderer?.destroy()}_isHidden(){let{textTrack:e,remotePlaybackState:n}=this._media.$state,i=e();return this._media.$iosControls()||n()==="connected"||!i||!We(i)}_watchViewType(){let{viewType:e}=this._media.$state;return e()==="audio"?this._setupAudioView():this._setupVideoView()}_setupAudioView(){return b(this._onTrackChange.bind(this)),()=>{this.el.textContent=""}}_onTrackChange(){if(this._isHidden())return;let{textTrack:e}=this._media.$state;this._onCueChange(),S(e(),"cue-change",this._onCueChange.bind(this)),b(this._onUpdateTimedNodes.bind(this))}_onCueChange(){this.el.textContent="";let{realCurrentTime:e,textTrack:n}=this._media.$state,i=C(e),r=C(n).activeCues,{renderVTTCueString:s}=this._lib;for(let a of r){let o=document.createElement("div");o.setAttribute("data-part","cue"),o.innerHTML=s(a,i),this.el.append(o)}}_onUpdateTimedNodes(){let{realCurrentTime:e}=this._media.$state,{updateTimedVTTCueNodes:n}=this._lib;n(this.el,e())}_setupVideoView(){return b(this._watchTextDirection.bind(this)),b(this._watchMediaTime.bind(this)),this._media.textRenderers.add(this._textRenderer),()=>{this.el.textContent="",this._textRenderer.detach(),this._media.textRenderers.remove(this._textRenderer)}}_watchTextDirection(){this._renderer.dir=this.$props.textDir()}_watchMediaTime(){if(this._isHidden())return;let{realCurrentTime:e}=this._media.$state;this._renderer.currentTime=e()}};sf.props={textDir:"ltr"};Tc=class extends q{onSetup(){this._media=le(),this._watchSrc(),this._watchAlt(),this._watchCrossOrigin(),this._watchHidden()}onAttach(e){e.style.setProperty("pointer-events","none"),b(this._watchImg.bind(this)),b(this._watchSrc.bind(this)),b(this._watchAlt.bind(this)),b(this._watchCrossOrigin.bind(this)),b(this._watchHidden.bind(this));let{started:n}=this._media.$state;this.setAttributes({"data-visible":()=>!n()&&!this.$state.hidden(),"data-loading":this._isLoading.bind(this),"data-error":this._hasError.bind(this),"data-hidden":this.$state.hidden})}onConnect(e){b(this._onPreconnect.bind(this)),b(this._onLoadStart.bind(this))}_hasError(){let{error:e}=this.$state;return!gi(e())}_onPreconnect(){let{canLoadPoster:e,poster:n}=this._media.$state;!e()&&n()&&Jn(n(),"preconnect")}_watchHidden(){let{src:e}=this.$props,{$iosControls:n}=this._media,{poster:i}=this._media.$state;this.el&&Z(this.el,"display",n()?"none":null),this.$state.hidden.set(this._hasError()||!(e()||i())||n())}_isLoading(){let{loading:e,hidden:n}=this.$state;return!n()&&e()}_watchImg(){let e=this.$state.img();e&&(S(e,"load",this._onLoad.bind(this)),S(e,"error",this._onError.bind(this)))}_watchSrc(){let{canLoadPoster:e,poster:n}=this._media.$state,i=this.$props.src(),r=i||n();i&&n()!==i&&this._media.$state.providedPoster.set(i),this.$state.src.set(e()&&r.length?r:null)}_watchAlt(){let{src:e}=this.$props,{alt:n}=this.$state,{poster:i}=this._media.$state;n.set(e()||i()?this.$props.alt():null)}_watchCrossOrigin(){let{crossOrigin:e}=this.$props,{crossOrigin:n}=this.$state,{crossOrigin:i,poster:r}=this._media.$state,s=e()!==null?e():i();n.set(/ytimg\.com|vimeo/.test(r()||"")?null:s===!0?"anonymous":s)}_onLoadStart(){let{loading:e,error:n}=this.$state,{canLoadPoster:i,poster:r}=this._media.$state;e.set(i()&&!!r()),n.set(null)}_onLoad(){let{loading:e,error:n}=this.$state;e.set(!1),n.set(null)}_onError(e){let{loading:n,error:i}=this.$state;n.set(!1),i.set(e)}};Tc.props={src:null,alt:null,crossOrigin:null};Tc.state=new Xn({img:null,src:null,alt:null,crossOrigin:null,loading:!0,error:null,hidden:!1});Sc=class extends q{constructor(){super(...arguments),this._invert=D(null)}onSetup(){this._media=le(),this._watchTime();let{type:e}=this.$props;this.setAttributes({"data-type":e,"data-remainder":this._shouldInvert.bind(this)})}onAttach(e){e.hasAttribute("role")||b(this._watchRole.bind(this)),b(this._watchTime.bind(this))}onConnect(e){b(()=>{if(!this.$props.toggle()){this._invert.set(null);return}Dr(e,this._onToggle.bind(this))})}_watchTime(){let{type:e,padHours:n,padMinutes:i,showHours:r}=this.$props,s=this._getSeconds(e()),a=this._media.$state.duration(),o=this._shouldInvert();if(!Number.isFinite(s+a)){this.$state.timeText.set("LIVE");return}let l=o?Math.max(0,a-s):s,c=Fr(l,n(),i(),r());this.$state.timeText.set((o?"-":"")+c)}_watchRole(){if(!this.el)return;let{toggle:e}=this.$props;Z(this.el,"role",e()?"timer":null),Z(this.el,"tabindex",e()?0:null)}_getSeconds(e){let{bufferedEnd:n,duration:i,currentTime:r}=this._media.$state;switch(e){case"buffered":return n();case"duration":return i();default:return r()}}_shouldInvert(){return this.$props.remainder()&&this._invert()!==!1}_onToggle(e){if(e.preventDefault(),this._invert()===null){this._invert.set(!this.$props.remainder());return}this._invert.set(n=>!n)}};Sc.props={type:"current",showHours:!1,padHours:null,padMinutes:null,remainder:!1,toggle:!1};Sc.state=new Xn({timeText:""});T3=vi(),S3={clickToPlay:!0,clickToFullscreen:!0,controls:["play-large","play","progress","current-time","mute+volume","captions","settings","pip","airplay","fullscreen"],customIcons:!1,displayDuration:!1,download:null,markers:null,invertTime:!0,thumbnails:null,toggleTime:!0,translations:null,seekTime:10,speed:[.5,.75,1,1.25,1.5,1.75,2,4]},Ew=class extends q{onSetup(){this._media=le(),Rt(T3,{...this.$props,previewTime:D(0)})}};Ew.props=S3;As=class extends DO{},af=class extends Ya{},Pc=class extends Fh{},Cc=class extends zh{},of=class extends _c{},$c=class extends Kh{},Mc=class extends Gh{},Rc=class extends Zh{},Lc=class extends Yh{},Ic=class extends Qh{},Ac=class extends Wh{},Nc=class extends qh{},Dc=class extends Bh{},Oc=class extends Xh{},Vc=class extends jh{},Fc=class extends Hh{},zc=class extends yc{},Uc=class extends Xi{},jc=class extends Za{},Hc=class extends kc{},qc=class extends ef{},Bc=class extends Xa{},Wc=class extends Ps{},Kc=class extends xc{},Gc=class extends Zi{},Yc=class extends Ji{},Qc=class extends Cs{},Xc=class extends Ec{},Zc=class extends tf{},Jc=class extends Ja{},eu=class extends eo{},tu=class extends sf{},nu=class extends rf{},lf=class extends Tc{},to=class extends Qa{},iu=class extends Sc{},i1=ke.forwardRef((t,e)=>{let{children:n,...i}=t,r=ke.Children.toArray(n),s=r.find(C3);if(s){let a=s.props.children,o=r.map(l=>l===s?ke.Children.count(a)>1?ke.Children.only(null):ke.isValidElement(a)?a.props.children:null:l);return ke.createElement(Tw,{...i,ref:e},ke.isValidElement(a)?ke.cloneElement(a,void 0,o):null)}return ke.createElement(Tw,{...i,ref:e},n)});i1.displayName="Slot";Tw=ke.forwardRef((t,e)=>{let{children:n,...i}=t;return ke.isValidElement(n)?ke.cloneElement(n,{...$3(i,n.props),ref:e?re(e,n.ref):n.ref}):ke.Children.count(n)>1?ke.Children.only(null):null});Tw.displayName="SlotClone";P3=({children:t})=>ke.createElement(ke.Fragment,null,t);M3=["button","div","span","img","video","audio"],U=M3.reduce((t,e)=>{let n=ke.forwardRef((i,r)=>{let{asChild:s,...a}=i;return ke.createElement(s?i1:e,{...a,ref:r})});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});yP=As.state.record,R3=Object.keys(yP).reduce((t,e)=>({...t,[e](){return yP[e]}}),{})});var b1={};xt(b1,{default:()=>DV});var DV,x1=Ue(()=>{"use strict";"use client";DV=' '});var TC=dt((Y8,EC)=>{"use strict";var xF={aa:{name:"Afar",nativeName:"Afaraf"},ab:{name:"Abkhaz",nativeName:"\u0430\u04A7\u0441\u0443\u0430 \u0431\u044B\u0437\u0448\u04D9\u0430"},ae:{name:"Avestan",nativeName:"avesta"},af:{name:"Afrikaans",nativeName:"Afrikaans"},ak:{name:"Akan",nativeName:"Akan"},am:{name:"Amharic",nativeName:"\u12A0\u121B\u122D\u129B"},an:{name:"Aragonese",nativeName:"aragon\xE9s"},ar:{name:"Arabic",nativeName:"\u0627\u064E\u0644\u0652\u0639\u064E\u0631\u064E\u0628\u0650\u064A\u064E\u0651\u0629\u064F"},as:{name:"Assamese",nativeName:"\u0985\u09B8\u09AE\u09C0\u09AF\u09BC\u09BE"},av:{name:"Avaric",nativeName:"\u0430\u0432\u0430\u0440 \u043C\u0430\u0446\u04C0"},ay:{name:"Aymara",nativeName:"aymar aru"},az:{name:"Azerbaijani",nativeName:"az\u0259rbaycan dili"},ba:{name:"Bashkir",nativeName:"\u0431\u0430\u0448\u04A1\u043E\u0440\u0442 \u0442\u0435\u043B\u0435"},be:{name:"Belarusian",nativeName:"\u0431\u0435\u043B\u0430\u0440\u0443\u0441\u043A\u0430\u044F \u043C\u043E\u0432\u0430"},bg:{name:"Bulgarian",nativeName:"\u0431\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438 \u0435\u0437\u0438\u043A"},bi:{name:"Bislama",nativeName:"Bislama"},bm:{name:"Bambara",nativeName:"bamanankan"},bn:{name:"Bengali",nativeName:"\u09AC\u09BE\u0982\u09B2\u09BE"},bo:{name:"Tibetan",nativeName:"\u0F56\u0F7C\u0F51\u0F0B\u0F61\u0F72\u0F42"},br:{name:"Breton",nativeName:"brezhoneg"},bs:{name:"Bosnian",nativeName:"bosanski jezik"},ca:{name:"Catalan",nativeName:"Catal\xE0"},ce:{name:"Chechen",nativeName:"\u043D\u043E\u0445\u0447\u0438\u0439\u043D \u043C\u043E\u0442\u0442"},ch:{name:"Chamorro",nativeName:"Chamoru"},co:{name:"Corsican",nativeName:"corsu"},cr:{name:"Cree",nativeName:"\u14C0\u1426\u1403\u152D\u140D\u140F\u1423"},cs:{name:"Czech",nativeName:"\u010De\u0161tina"},cu:{name:"Old Church Slavonic",nativeName:"\u0469\u0437\u044B\u043A\u044A \u0441\u043B\u043E\u0432\u0463\u043D\u044C\u0441\u043A\u044A"},cv:{name:"Chuvash",nativeName:"\u0447\u04D1\u0432\u0430\u0448 \u0447\u04D7\u043B\u0445\u0438"},cy:{name:"Welsh",nativeName:"Cymraeg"},da:{name:"Danish",nativeName:"dansk"},de:{name:"German",nativeName:"Deutsch"},dv:{name:"Divehi",nativeName:"\u078B\u07A8\u0788\u07AC\u0780\u07A8"},dz:{name:"Dzongkha",nativeName:"\u0F62\u0FAB\u0F7C\u0F44\u0F0B\u0F41"},ee:{name:"Ewe",nativeName:"E\u028Begbe"},el:{name:"Greek",nativeName:"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"},en:{name:"English",nativeName:"English"},eo:{name:"Esperanto",nativeName:"Esperanto"},es:{name:"Spanish",nativeName:"Espa\xF1ol"},et:{name:"Estonian",nativeName:"eesti"},eu:{name:"Basque",nativeName:"euskara"},fa:{name:"Persian",nativeName:"\u0641\u0627\u0631\u0633\u06CC"},ff:{name:"Fula",nativeName:"Fulfulde"},fi:{name:"Finnish",nativeName:"suomi"},fj:{name:"Fijian",nativeName:"vosa Vakaviti"},fo:{name:"Faroese",nativeName:"f\xF8royskt"},fr:{name:"French",nativeName:"Fran\xE7ais"},fy:{name:"Western Frisian",nativeName:"Frysk"},ga:{name:"Irish",nativeName:"Gaeilge"},gd:{name:"Scottish Gaelic",nativeName:"G\xE0idhlig"},gl:{name:"Galician",nativeName:"galego"},gn:{name:"Guaran\xED",nativeName:"Ava\xF1e'\u1EBD"},gu:{name:"Gujarati",nativeName:"\u0A97\u0AC1\u0A9C\u0AB0\u0ABE\u0AA4\u0AC0"},gv:{name:"Manx",nativeName:"Gaelg"},ha:{name:"Hausa",nativeName:"\u0647\u064E\u0648\u064F\u0633\u064E"},he:{name:"Hebrew",nativeName:"\u05E2\u05D1\u05E8\u05D9\u05EA"},hi:{name:"Hindi",nativeName:"\u0939\u093F\u0928\u094D\u0926\u0940"},ho:{name:"Hiri Motu",nativeName:"Hiri Motu"},hr:{name:"Croatian",nativeName:"Hrvatski"},ht:{name:"Haitian",nativeName:"Krey\xF2l ayisyen"},hu:{name:"Hungarian",nativeName:"magyar"},hy:{name:"Armenian",nativeName:"\u0540\u0561\u0575\u0565\u0580\u0565\u0576"},hz:{name:"Herero",nativeName:"Otjiherero"},ia:{name:"Interlingua",nativeName:"Interlingua"},id:{name:"Indonesian",nativeName:"Bahasa Indonesia"},ie:{name:"Interlingue",nativeName:"Interlingue"},ig:{name:"Igbo",nativeName:"As\u1EE5s\u1EE5 Igbo"},ii:{name:"Nuosu",nativeName:"\uA188\uA320\uA4BF Nuosuhxop"},ik:{name:"Inupiaq",nativeName:"I\xF1upiaq"},io:{name:"Ido",nativeName:"Ido"},is:{name:"Icelandic",nativeName:"\xCDslenska"},it:{name:"Italian",nativeName:"Italiano"},iu:{name:"Inuktitut",nativeName:"\u1403\u14C4\u1483\u144E\u1450\u1466"},ja:{name:"Japanese",nativeName:"\u65E5\u672C\u8A9E"},jv:{name:"Javanese",nativeName:"basa Jawa"},ka:{name:"Georgian",nativeName:"\u10E5\u10D0\u10E0\u10D7\u10E3\u10DA\u10D8"},kg:{name:"Kongo",nativeName:"Kikongo"},ki:{name:"Kikuyu",nativeName:"G\u0129k\u0169y\u0169"},kj:{name:"Kwanyama",nativeName:"Kuanyama"},kk:{name:"Kazakh",nativeName:"\u049B\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"},kl:{name:"Kalaallisut",nativeName:"kalaallisut"},km:{name:"Khmer",nativeName:"\u1781\u17C1\u1798\u179A\u1797\u17B6\u179F\u17B6"},kn:{name:"Kannada",nativeName:"\u0C95\u0CA8\u0CCD\u0CA8\u0CA1"},ko:{name:"Korean",nativeName:"\uD55C\uAD6D\uC5B4"},kr:{name:"Kanuri",nativeName:"Kanuri"},ks:{name:"Kashmiri",nativeName:"\u0915\u0936\u094D\u092E\u0940\u0930\u0940"},ku:{name:"Kurdish",nativeName:"Kurd\xEE"},kv:{name:"Komi",nativeName:"\u043A\u043E\u043C\u0438 \u043A\u044B\u0432"},kw:{name:"Cornish",nativeName:"Kernewek"},ky:{name:"Kyrgyz",nativeName:"\u041A\u044B\u0440\u0433\u044B\u0437\u0447\u0430"},la:{name:"Latin",nativeName:"latine"},lb:{name:"Luxembourgish",nativeName:"L\xEBtzebuergesch"},lg:{name:"Ganda",nativeName:"Luganda"},li:{name:"Limburgish",nativeName:"Limburgs"},ln:{name:"Lingala",nativeName:"Ling\xE1la"},lo:{name:"Lao",nativeName:"\u0E9E\u0EB2\u0EAA\u0EB2\u0EA5\u0EB2\u0EA7"},lt:{name:"Lithuanian",nativeName:"lietuvi\u0173 kalba"},lu:{name:"Luba-Katanga",nativeName:"Kiluba"},lv:{name:"Latvian",nativeName:"latvie\u0161u valoda"},mg:{name:"Malagasy",nativeName:"fiteny malagasy"},mh:{name:"Marshallese",nativeName:"Kajin M\u0327aje\u013C"},mi:{name:"M\u0101ori",nativeName:"te reo M\u0101ori"},mk:{name:"Macedonian",nativeName:"\u043C\u0430\u043A\u0435\u0434\u043E\u043D\u0441\u043A\u0438 \u0458\u0430\u0437\u0438\u043A"},ml:{name:"Malayalam",nativeName:"\u0D2E\u0D32\u0D2F\u0D3E\u0D33\u0D02"},mn:{name:"Mongolian",nativeName:"\u041C\u043E\u043D\u0433\u043E\u043B \u0445\u044D\u043B"},mr:{name:"Marathi",nativeName:"\u092E\u0930\u093E\u0920\u0940"},ms:{name:"Malay",nativeName:"Bahasa Melayu"},mt:{name:"Maltese",nativeName:"Malti"},my:{name:"Burmese",nativeName:"\u1017\u1019\u102C\u1005\u102C"},na:{name:"Nauru",nativeName:"Dorerin Naoero"},nb:{name:"Norwegian Bokm\xE5l",nativeName:"Norsk bokm\xE5l"},nd:{name:"Northern Ndebele",nativeName:"isiNdebele"},ne:{name:"Nepali",nativeName:"\u0928\u0947\u092A\u093E\u0932\u0940"},ng:{name:"Ndonga",nativeName:"Owambo"},nl:{name:"Dutch",nativeName:"Nederlands"},nn:{name:"Norwegian Nynorsk",nativeName:"Norsk nynorsk"},no:{name:"Norwegian",nativeName:"Norsk"},nr:{name:"Southern Ndebele",nativeName:"isiNdebele"},nv:{name:"Navajo",nativeName:"Din\xE9 bizaad"},ny:{name:"Chichewa",nativeName:"chiChe\u0175a"},oc:{name:"Occitan",nativeName:"occitan"},oj:{name:"Ojibwe",nativeName:"\u140A\u14C2\u1511\u14C8\u142F\u14A7\u140E\u14D0"},om:{name:"Oromo",nativeName:"Afaan Oromoo"},or:{name:"Oriya",nativeName:"\u0B13\u0B21\u0B3C\u0B3F\u0B06"},os:{name:"Ossetian",nativeName:"\u0438\u0440\u043E\u043D \xE6\u0432\u0437\u0430\u0433"},pa:{name:"Panjabi",nativeName:"\u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40"},pi:{name:"P\u0101li",nativeName:"\u092A\u093E\u0934\u093F"},pl:{name:"Polish",nativeName:"Polski"},ps:{name:"Pashto",nativeName:"\u067E\u069A\u062A\u0648"},pt:{name:"Portuguese",nativeName:"Portugu\xEAs"},qu:{name:"Quechua",nativeName:"Runa Simi"},rm:{name:"Romansh",nativeName:"rumantsch grischun"},rn:{name:"Kirundi",nativeName:"Ikirundi"},ro:{name:"Romanian",nativeName:"Rom\xE2n\u0103"},ru:{name:"Russian",nativeName:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},rw:{name:"Kinyarwanda",nativeName:"Ikinyarwanda"},sa:{name:"Sanskrit",nativeName:"\u0938\u0902\u0938\u094D\u0915\u0943\u0924\u092E\u094D"},sc:{name:"Sardinian",nativeName:"sardu"},sd:{name:"Sindhi",nativeName:"\u0938\u093F\u0928\u094D\u0927\u0940"},se:{name:"Northern Sami",nativeName:"Davvis\xE1megiella"},sg:{name:"Sango",nativeName:"y\xE2ng\xE2 t\xEE s\xE4ng\xF6"},si:{name:"Sinhala",nativeName:"\u0DC3\u0DD2\u0D82\u0DC4\u0DBD"},sk:{name:"Slovak",nativeName:"sloven\u010Dina"},sl:{name:"Slovenian",nativeName:"sloven\u0161\u010Dina"},sm:{name:"Samoan",nativeName:"gagana fa'a Samoa"},sn:{name:"Shona",nativeName:"chiShona"},so:{name:"Somali",nativeName:"Soomaaliga"},sq:{name:"Albanian",nativeName:"Shqip"},sr:{name:"Serbian",nativeName:"\u0441\u0440\u043F\u0441\u043A\u0438 \u0458\u0435\u0437\u0438\u043A"},ss:{name:"Swati",nativeName:"SiSwati"},st:{name:"Southern Sotho",nativeName:"Sesotho"},su:{name:"Sundanese",nativeName:"Basa Sunda"},sv:{name:"Swedish",nativeName:"Svenska"},sw:{name:"Swahili",nativeName:"Kiswahili"},ta:{name:"Tamil",nativeName:"\u0BA4\u0BAE\u0BBF\u0BB4\u0BCD"},te:{name:"Telugu",nativeName:"\u0C24\u0C46\u0C32\u0C41\u0C17\u0C41"},tg:{name:"Tajik",nativeName:"\u0442\u043E\u04B7\u0438\u043A\u04E3"},th:{name:"Thai",nativeName:"\u0E44\u0E17\u0E22"},ti:{name:"Tigrinya",nativeName:"\u1275\u130D\u122D\u129B"},tk:{name:"Turkmen",nativeName:"T\xFCrkmen\xE7e"},tl:{name:"Tagalog",nativeName:"Wikang Tagalog"},tn:{name:"Tswana",nativeName:"Setswana"},to:{name:"Tonga",nativeName:"faka Tonga"},tr:{name:"Turkish",nativeName:"T\xFCrk\xE7e"},ts:{name:"Tsonga",nativeName:"Xitsonga"},tt:{name:"Tatar",nativeName:"\u0442\u0430\u0442\u0430\u0440 \u0442\u0435\u043B\u0435"},tw:{name:"Twi",nativeName:"Twi"},ty:{name:"Tahitian",nativeName:"Reo Tahiti"},ug:{name:"Uyghur",nativeName:"\u0626\u06C7\u064A\u063A\u06C7\u0631\u0686\u06D5\u200E"},uk:{name:"Ukrainian",nativeName:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"},ur:{name:"Urdu",nativeName:"\u0627\u0631\u062F\u0648"},uz:{name:"Uzbek",nativeName:"\u040E\u0437\u0431\u0435\u043A"},ve:{name:"Venda",nativeName:"Tshiven\u1E13a"},vi:{name:"Vietnamese",nativeName:"Ti\u1EBFng Vi\u1EC7t"},vo:{name:"Volap\xFCk",nativeName:"Volap\xFCk"},wa:{name:"Walloon",nativeName:"walon"},wo:{name:"Wolof",nativeName:"Wollof"},xh:{name:"Xhosa",nativeName:"isiXhosa"},yi:{name:"Yiddish",nativeName:"\u05D9\u05D9\u05B4\u05D3\u05D9\u05E9"},yo:{name:"Yoruba",nativeName:"Yor\xF9b\xE1"},za:{name:"Zhuang",nativeName:"Sa\u026F cue\u014B\u0185"},zh:{name:"Chinese",nativeName:"\u4E2D\u6587"},zu:{name:"Zulu",nativeName:"isiZulu"}};EC.exports=xF});var sb=dt((Q8,MC)=>{"use strict";var gu=TC(),SC={},Df={},PC=[],CC=[],$C=[];for(let t in gu){let{name:e,nativeName:n}=gu[t];SC[t]=Df[e.toLowerCase()]=Df[n.toLowerCase()]={code:t,name:e,nativeName:n},PC.push(t),CC.push(e),$C.push(n)}MC.exports=class Nf{static getLanguages(e=[]){return e.map(n=>Nf.validate(n)?Object.assign({},SC[n]):{code:n,name:"",nativeName:""})}static getName(e){return Nf.validate(e)?gu[e].name:""}static getAllNames(){return CC.slice()}static getNativeName(e){return Nf.validate(e)?gu[e].nativeName:""}static getAllNativeNames(){return $C.slice()}static getCode(e){return e=e.toLowerCase(),Df.hasOwnProperty(e)?Df[e].code:""}static getAllCodes(){return PC.slice()}static validate(e){return gu.hasOwnProperty(e)}}});var E$=dt(Jf=>{"use strict";var x5=z(),k5=Symbol.for("react.element"),E5=Symbol.for("react.fragment"),T5=Object.prototype.hasOwnProperty,S5=x5.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,P5={key:!0,ref:!0,__self:!0,__source:!0};function k$(t,e,n){var i,r={},s=null,a=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(a=e.ref);for(i in e)T5.call(e,i)&&!P5.hasOwnProperty(i)&&(r[i]=e[i]);if(t&&t.defaultProps)for(i in e=t.defaultProps,e)r[i]===void 0&&(r[i]=e[i]);return{$$typeof:k5,type:t,key:s,ref:a,props:r,_owner:S5.current}}Jf.Fragment=E5;Jf.jsx=k$;Jf.jsxs=k$});var ae=dt((XH,T$)=>{"use strict";T$.exports=E$()});var Dm=dt(Nm=>{"use strict";Object.defineProperty(Nm,"__esModule",{value:!0});function _R(t,e){if(e)return t;throw new Error("Unhandled discriminated union member: "+JSON.stringify(t))}Nm.assertNever=_R;Nm.default=_R});var $6={};xt($6,{default:()=>sg});module.exports=ML($6);var Px=require("obsidian");function lg(t,e){let n={};for(let i of e)i in t&&(n[i]=t[i]);return n}function Zu(t,e){let n={...t};for(let i of e)delete n[i];return n}var cg={bilibili:"https://www.bilibili.com",youtube:"https://www.youtube.com",vimeo:"https://www.vimeo.com",coursera:"https://www.coursera.org"},Ju={bilibili:"bilibili",youtube:"YouTube",generic:"Website",vimeo:"Vimeo",coursera:"Coursera"},Sx=t=>Zu(t,["generic"]);var RL={bilibili:'',vimeo:'',coursera:'',youtube:null};Object.entries(RL).forEach(([t,e])=>{e&&(0,Px.addIcon)(t,e)});var ag=require("obsidian");function Bo(t){return zn(t).href}function zn(t){let e=new URL(t);return e.hash="",e}function Un(t){try{return new URL(t)}catch{return null}}var je=require("obsidian");function Qs(t,e){let n="target"in t?t.target:t;if(!n.instanceOf?.(HTMLElement))return;let i=n.getBoundingClientRect();return e.setParentElement(n).showAtPosition({x:i.x,y:i.bottom,width:i.width,overlap:!0,left:!0},n.doc)}var Cx="mx-port";var oi=t=>`persist:mx-player-${t}`;var $x=require("obsidian");function ug(t){return require("@electron/remote").session.fromPartition(oi(t))}function Mx(){return $x.Platform.isDesktopApp?require("fs/promises"):null}function Rx(t){return require("@electron/remote").webContents.fromId(t)}function ed(){return require("@electron/remote").dialog}var Xs=class extends je.Modal{constructor(n){super(n);_(this,"navEl",this.contentEl.insertAdjacentElement("beforebegin",createDiv({cls:"mx-login-nav"})));_(this,"webview",createEl("webview",{attr:{partition:this.partition,allowpopups:""}}));_(this,"backButton",new je.ButtonComponent(this.navEl).setIcon("arrow-left").setTooltip("Back").setClass("mx-login-back").setDisabled(!0).onClick(()=>{try{this.webview.goBack()}catch(n){new je.Notice("Failed to go back, see console for details"),console.error("err go back",n)}}));_(this,"forwardButton",new je.ButtonComponent(this.navEl).setIcon("arrow-right").setTooltip("Forward").setClass("mx-login-forward").setDisabled(!0).onClick(()=>{try{this.webview.goForward()}catch(n){new je.Notice("Failed to go forward, see console for details"),console.error("err go forward",n)}}));_(this,"refreshButton",new je.ButtonComponent(this.navEl).setIcon("rotate-ccw").setTooltip("Refresh").setClass("mx-login-refresh").setDisabled(!0).onClick(()=>{try{this.webview.reload()}catch(n){new je.Notice("Failed to refresh, see console for details"),console.error("err refresh",n)}}));_(this,"addressBarForm",this.navEl.createEl("form"));_(this,"addressBar",new je.TextComponent(this.addressBarForm).then(n=>{n.inputEl.type="url",n.inputEl.placeholder="https://example.com",n.inputEl.classList.add("mx-login-address")}));_(this,"addressSubmit",new je.ButtonComponent(this.addressBarForm).setIcon("arrow-right-circle").then(n=>n.buttonEl.type="submit"));_(this,"moreOptionsButton",new je.ButtonComponent(this.navEl).setIcon("more-horizontal").setTooltip("More options").setClass("mx-login-more").onClick(n=>{let i=new je.Menu;this.onMoreOptions(i),Qs(n,i)}));_(this,"callbacks",[]);_(this,"handledWebcontents",new Set);this.containerEl.addClasses(["mx-login-modal"]),this.titleEl.style.display="none",this.buildWelcome()}get partition(){return oi(this.app.appId)}buildWelcome(){this.contentEl.empty(),this.contentEl.createEl("h1").setText("Login");let n=this.contentEl.createEl("main");n.createEl("p").setText("You can login to sites, change preferences and more, just as you would in a browser."),n.createEl("p").setText("To open a website, you can:");let i=n.createEl("ul");i.createEl("li").setText("Enter the site address in the address bar");let r=i.createEl("li");r.setText("Select from a list of "),new je.DropdownComponent(r).addOptions({...Sx(Ju),".":"supported websites..."}).setValue(".").onChange(s=>{s in cg&&this.setUrl(cg[s])})}getSession(){return ug(this.app.appId)}onMoreOptions(n){n.addItem(i=>i.setTitle("Clear cache").setSection("clear").setIcon("trash").onClick(async()=>{if(window.confirm("Are you sure you want to clear the website cache? All login sessions and preferences will be lost."))try{await this.getSession().clearCache(),new je.Notice("Cache cleared")}catch(s){new je.Notice("Failed to clear cache, see console for details"),console.error("err clear cache",s)}}))}setUrl(n){this.initWebview(),this.webview.src=n,this.addressBar.setValue(n)}register(n){this.callbacks.push(n)}registerWebviewEvent(n,i){this.webview.addEventListener(n,i),this.register(()=>this.webview.removeEventListener(n,i))}onClose(){for(let n of this.callbacks)n();this.containerEl.empty()}initWebview(){this.webview.isConnected||(this.registerWebviewEvent("will-navigate",()=>{this.addressBar.setValue(this.webview.getURL())}),this.contentEl.empty(),this.contentEl.appendChild(this.webview),this.backButton.setDisabled(!1),this.forwardButton.setDisabled(!1),this.refreshButton.setDisabled(!1),this.registerWebviewEvent("dom-ready",()=>{if(this.handledWebcontents.has(this.webview.getWebContentsId()))return;let n=this.webview.getWebContentsId();this.handledWebcontents.add(n),Rx(n)?.setWindowOpenHandler(({url:r,disposition:s})=>((s==="new-window"||s==="foreground-tab"||s==="default")&&this.setUrl(r),{action:"deny"}))}))}onOpen(){this.addressBarForm.onsubmit=n=>{n.preventDefault();let i=this.addressBar.getValue();i&&this.setUrl(i)}}};function Lx(){this.addCommand({id:"login",name:"Login website",callback:()=>{new Xs(this.app).open()}})}var zM=require("obsidian");var Vu=require("obsidian");var td=require("obsidian"),Zs=class t extends td.Modal{constructor(n,i,r){super(n);this.onSubmit=i;this.onExit=r;this.containerEl.addClass("mx-playback-prompt"),this.onSubmit=i}static run(){return new Promise(n=>{new t(app,r=>n(Number(r)),()=>n(null)).open()})}onOpen(){let{contentEl:n,titleEl:i}=this;i.setText("Playback Speed");let r=n.createEl("form",{},s=>{s.createEl("input",{type:"number",placeholder:"Enter a number between 0 and 10",attr:{min:.1,max:10,step:.1,width:100,required:!0,name:"playback-speed"}}),s.createEl("button",{attr:{type:"submit"},text:"Submit"})});r.oninvalid=s=>{s.preventDefault(),new td.Notice("Invalid playback rate")},r.onsubmit=s=>{s.preventDefault();let a=new FormData(r);this.onSubmit(a.get("playback-speed").toString()),this.close()}}onClose(){let{contentEl:n}=this;n.empty(),this.onExit()}};var li=[.25,.5,.75,1,1.25,1.5,2,3,5,10];function Ix(t,e){let n=e.state.playbackRate,i=!li.includes(n),r=t.setTitle(LL(n)).setIcon("gauge").setSection("mx-player").setSubmenu();li.forEach(s=>r.addItem(a=>a.setTitle(`${s}x`).setChecked(s===n).onClick(()=>{e.playbackRate=s}))),r.addItem(s=>s.setTitle(IL(n)).setChecked(i).onClick(async()=>{let a=await Zs.run();a&&(e.playbackRate=a)}))}function LL(t){let e=new DocumentFragment;return e.appendText("Speed "),e.createEl("code",{text:`(${t}x)`}),e}function IL(t){let e=new DocumentFragment;return e.appendText("Custom"),li.includes(t)?e.appendText("..."):(e.appendText(" "),e.createEl("code",{text:`(${t}x)`})),e}var OM=require("obsidian");function nd(){return/[<>:"/\\|?*\u0000-\u001F]/g}function Ax(){return/^(con|prn|aux|nul|com\d|lpt\d)$/i}var AL=100,NL=/^\.+(\\|\/)|^\.+$/,DL=/\.+$/;function Wo(t,e={}){let n=/[\u0000-\u001F\u0080-\u009F]/g,i=/([<>:"/\\|?*\u0000-\u001F]){2,}/g;if(typeof t!="string")throw new TypeError("Expected a string");let r=e.replacement===void 0?"!":e.replacement;if(nd().test(r)&&n.test(r))throw new Error("Replacement string cannot contain reserved filename characters");r.length>0&&(t=t.replace(i,"$1")),t=t.normalize("NFD"),t=t.replace(NL,r),t=t.replace(nd(),r),t=t.replace(n,r),t=t.replace(DL,""),r.length>0&&(!(t[0]===".")&&t[0]==="."&&(t=r+t),t[t.length-1]==="."&&(t+=r)),t=Ax().test(t)?t+r:t;let s=typeof e.maxLength=="number"?e.maxLength:AL;if(t.length>s){let a=t.lastIndexOf(".");if(a===-1)t=t.slice(0,s);else{let o=t.slice(0,a),l=t.slice(a);t=o.slice(0,Math.max(1,s-l.length))+l}}return t}var To=require("obsidian");var Nx=require("obsidian");var kt={video:["mp4","webm","ogv","mov","mkv"],audio:["mp3","wav","m4a","3gp","flac","ogg","oga","opus"]};function Xt(t){t=t.replace(/^\./,"").toLowerCase();for(let e of Object.keys(kt))if(kt[e].includes(t))return e;return null}var uz=[...kt.video,...kt.audio];function Mi(t){return t.file instanceof Nx.TFile}var pt={video:"mx-url-video",audio:"mx-url-audio"},OL=new Set(Object.values(pt));function VL(t){return OL.has(t)}var Ri="mx-embed",Zt="mx-webpage",jn={video:"mx-file-video",audio:"mx-file-audio"},FL=new Set(Object.values(jn));function zL(t){return FL.has(t)}function UL(t){return VL(t)||Ri===t||Zt===t}function dg(t){return zL(t)||UL(t)}var ym=require("obsidian"),$M=$(zl());var ni=$(z());var gT={},mT=t=>{let e,n=new Set,i=(u,d)=>{let p=typeof u=="function"?u(e):u;if(!Object.is(p,e)){let h=e;e=d??(typeof p!="object"||p===null)?p:Object.assign({},e,p),n.forEach(y=>y(e,h))}},r=()=>e,l={setState:i,getState:r,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(gT.env?gT.env.MODE:void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},c=e=t(i,r,l);return l},Tp=t=>t?mT(t):mT;var PT=$(z(),1),CT=$(ET(),1),ST={},{useDebugValue:bN}=PT.default,{useSyncExternalStoreWithSelector:xN}=CT.default,TT=!1,kN=t=>t;function Ly(t,e=kN,n){(ST.env?ST.env.MODE:void 0)!=="production"&&n&&!TT&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),TT=!0);let i=xN(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return bN(i),i}var Ul={main:/^(?[\w:.]*)(?:,(?[\w:.]+))?$/,npt_sec:/^\d+(?:\.\d+)?$/,npt_mmss:/^(?[0-5]\d):(?[0-5]\d(?:\.\d+)?)$/,npt_hhmmss:/^(?\d+):(?[0-5]\d):(?[0-5]\d(?:\.\d+)?)$/,npt_time:/^(?:npt:)?([\d.:]+)$/},kn=({start:t,end:e})=>t>=0&&e<0;function $r(t){if(!t)return null;let n=new URLSearchParams(t.replace(/^#+/,"")).get("t");if(!n)return null;let i=n.match(Ul.main);if(!i)return null;let{start:r,end:s}=i.groups;return EN(r,s)}var EN=(t,e)=>{let n=t||null,i=e??null,r,s;if(n&&i)r=Pp(n),s=i==="e"?1/0:Pp(i);else if(n)r=Pp(n),s=-1;else if(i)r=-1,s=Pp(i);else throw console.error("Missing startTime and endTime",t,e),new Error("Missing startTime and endTime");return r===null||s===null?null:{start:r,end:s}};function Pp(t){let e=t.match(Ul.npt_time);if(!e)return null;let n=e[1],i=n.match(Ul.npt_sec);if(i)return Number(i[0]);let r=n.match(Ul.npt_mmss);if(r){let{mm:a,ss:o}=r.groups;return Number(a)*60+Number(o)}let s=n.match(Ul.npt_hhmmss);if(s){let{hh:a,mm:o,ss:l}=s.groups;return Number(a)*60*60+Number(o)*60+Number(l)}return null}function Cp(t){let e=new URLSearchParams(t.replace(/^#+/,"")),n=!e.has("noctrl")&&!e.has("controls")?void 0:e.has("controls");return{loop:e.has("loop")?!0:void 0,muted:e.has("mute")?!0:void 0,autoplay:e.has("play")?!0:void 0,controls:n,volume:TN(e.get("vol")),tempFragment:$r(t)}}function TN(t){if(!t)return;let e=parseInt(t,10);if(!isNaN(e)&&e>=0&&e<=100)return e/100}var $T=()=>({emit(t,...e){for(let n=0,i=this.events[t]||[],r=i.length;n{this.events[t]=this.events[t]?.filter(i=>e!==i)}}});function $p(){let t=$T();return t.once=function(n,i){let r=this.on(n,(...s)=>{r(),i(...s)});return r},t}function MT(t){let e=t;return typeof e.id=="string"&&typeof e.invoke=="string"}function RT(t,...e){return{id:SN(),invoke:t,args:e}}function LT(t){return typeof t.id=="string"}function IT(t){return typeof t.send=="string"}function AT(t,e){return{send:t,payload:e}}function SN(){return Math.random().toString(36).substring(2,9)}var Mp=class extends Error{constructor(e){super(`no handler for ${e}`)}},Iy="mx-port-ready";var Rp=class{constructor(){_(this,"port",null);_(this,"actions",Object.create(null));_(this,"emitter",$p());_(this,"methods",new Proxy({},{get:(e,n)=>{if(typeof n=="symbol")throw new Error("Remote invoke does not support symbol property");return e[n]??(e[n]=(...i)=>this.invoke(n.toString(),i))}}))}load(e){this.port&&this.port.close(),this.port=e;let n=({data:i})=>{this.onMessage(i)};e.addEventListener("message",n),e.start(),e.postMessage(Iy)}unload(){this.port?.close(),this.emitter.events={}}onMessage(e){e===Iy?this.emitter.emit("ready"):MT(e)?this.response(e):LT(e)?this.emitter.emit("resp",e.id,e.payload,e.error):IT(e)&&this.emitter.emit(`send:${e.send}`,{type:e.send,payload:e.payload})}invoke(e,n,{transfer:i,timeout:r=1e3}={}){if(!this.port)throw new Error("port not loaded");let s=RT(e,...n);return this.port.postMessage(s,{transfer:i}),new Promise((a,o)=>{let l=-1,c=this.emitter.on("resp",(u,d,p)=>{if(u===s.id)if(c(),window.clearTimeout(l),p){let{message:h,stack:y}=p,v=new Error(h);v.stack=y,o(v)}else a(d)});r>0&&r<1/0&&(l=window.setTimeout(()=>{c(),console.error(`${e} timeout after ${r}ms`),o(new ji(r))},r))})}handle(e,n){this.actions[e]=n}send(e,n,i){if(!this.port)throw new Error("port not loaded");let r=AT(e,n);this.port.postMessage(r,{transfer:i})}on(e,n){return this.emitter.on(`send:${e}`,n)}once(e,n){return this.emitter.once(`send:${e}`,n)}onReady(e,{once:n=!1}={}){return n?this.emitter.once("ready",e):this.emitter.on("ready",e)}async response({id:e,invoke:n,args:i=[]}){if(!this.port)throw new Error("port not loaded");let r={id:e,payload:null};try{let s=this.actions[n];if(!s)throw new Mp(n);let a=await s(...i);a===void 0?this.port.postMessage(r):(r.payload=await a.value,this.port.postMessage(r,{transfer:a.transfer}))}catch(s){console.error("port messaging error",s),s instanceof Error?r.error={message:s.message,stack:s.stack}:r.error={message:String(s)},this.port.postMessage(r)}}},ji=class extends Error{constructor(e){super(`timeout after ${e}ms`)}};var PN=()=>{},jl=PN;Lt();Lt();Wt();Wt();var V=$(z(),1);var E=$(z(),1);Lt();Wt();var a1=$(Fl(),1);function xi(){return qp(ru)}var L3=X(Nc,{domEventsRegex:/^onMedia/}),o1=E.forwardRef(({children:t,...e},n)=>E.createElement(L3,{...e},i=>E.createElement(U.button,{...i,ref:re(i.ref,n)},t)));o1.displayName="AirPlayButton";var I3=X(Ac,{domEventsRegex:/^onMedia/}),ff=E.forwardRef(({children:t,...e},n)=>E.createElement(I3,{...e},i=>E.createElement(U.button,{...i,ref:re(i.ref,n)},t)));ff.displayName="PlayButton";var A3=X($c,{domEventsRegex:/^onMedia/}),jw=E.forwardRef(({children:t,...e},n)=>E.createElement(A3,{...e},i=>E.createElement(U.button,{...i,ref:re(i.ref,n)},t)));jw.displayName="CaptionButton";var N3=X(Mc,{domEventsRegex:/^onMedia/}),mf=E.forwardRef(({children:t,...e},n)=>E.createElement(N3,{...e},i=>E.createElement(U.button,{...i,ref:re(i.ref,n)},t)));mf.displayName="FullscreenButton";var D3=X(Lc,{domEventsRegex:/^onMedia/}),gf=E.forwardRef(({children:t,...e},n)=>E.createElement(D3,{...e},i=>E.createElement(U.button,{...i,ref:re(i.ref,n)},t)));gf.displayName="MuteButton";var O3=X(Ic,{domEventsRegex:/^onMedia/}),Hw=E.forwardRef(({children:t,...e},n)=>E.createElement(O3,{...e},i=>E.createElement(U.button,{...i,ref:re(i.ref,n)},t)));Hw.displayName="PIPButton";var V3=X(Oc,{domEventsRegex:/^onMedia/}),lu=E.forwardRef(({children:t,...e},n)=>E.createElement(V3,{...e},i=>E.createElement(U.button,{...i,ref:re(i.ref,n)},t)));lu.displayName="SeekButton";var F3=X(Rc,{domEventsRegex:/^onMedia/}),l1=E.forwardRef(({children:t,...e},n)=>E.createElement(F3,{...e},i=>E.createElement(U.button,{...i,ref:re(i.ref,n)},t)));l1.displayName="LiveButton";var qw=X(Bc),z3=X(Uc,{events:["onDragStart","onDragEnd","onDragValueChange","onValueChange","onPointerValueChange"]}),U3=E.forwardRef(({children:t,...e},n)=>E.createElement(z3,{...e,ref:n},i=>E.createElement(U.div,{...i},t)));U3.displayName="Slider";var j3=E.forwardRef((t,e)=>E.createElement(U.div,{...t,ref:e}));j3.displayName="SliderThumb";var H3=E.forwardRef((t,e)=>E.createElement(U.div,{...t,ref:e}));H3.displayName="SliderTrack";var q3=E.forwardRef((t,e)=>E.createElement(U.div,{...t,ref:e}));q3.displayName="SliderTrackFill";var B3=X(Kc),W3=E.forwardRef(({children:t,...e},n)=>E.createElement(B3,{...e},i=>E.createElement(U.div,{...i,ref:re(i.ref,n)},t)));W3.displayName="SliderPreview";var K3=E.forwardRef(({children:t,...e},n)=>E.createElement(qw,{...e},(i,r)=>{let s=pe(()=>r.getValueText(),r);return E.createElement(U.div,{...i,ref:n},s,t)}));K3.displayName="SliderValue";var G3=X(Hc,{domEventsRegex:/^onMedia/}),Y3=E.forwardRef(({children:t,...e},n)=>E.createElement(G3,{...e,ref:n},i=>E.createElement(U.div,{...i},t)));Y3.displayName="VolumeSlider";var Q3=E.forwardRef(({children:t,...e},n)=>E.createElement(qw,{...e},(i,r)=>{let s=pe(()=>r.getValueText(),r);return E.createElement(U.div,{...i,ref:re(i.ref,n)},s,t)}));Q3.displayName="SliderValue";function X3(t=0,e=0,n=""){return N?{startTime:t,endTime:e,text:n,addEventListener:qt,removeEventListener:qt,dispatchEvent:qt}:new window.VTTCue(t,e,n)}var Z3=X(to),c1=E.forwardRef(({children:t,...e},n)=>E.createElement(Z3,{...e},i=>E.createElement(U.div,{...i,ref:re(i.ref,n)},t)));c1.displayName="Thumbnail";var u1=E.forwardRef(({children:t,...e},n)=>{let{src:i,img:r,crossOrigin:s}=Mr(to.state),a=pe(i),o=pe(s);return E.createElement(U.img,{crossOrigin:o,...e,src:a,ref:re(r.set,n)},t)});u1.displayName="ThumbnailImg";var vf=Object.freeze({__proto__:null,Img:u1,Root:c1}),yf=E.createContext({$chapters:D(null)});yf.displayName="TimeSliderContext";var J3=X(jc,{domEventsRegex:/^onMedia/}),eV=E.forwardRef(({children:t,...e},n)=>{let i=E.useMemo(()=>D(null),[]);return E.createElement(yf.Provider,{value:{$chapters:i}},E.createElement(J3,{...e,ref:n},r=>E.createElement(U.div,{...r},t)))});eV.displayName="TimeSlider";var tV=X(Gc),nV=E.forwardRef(({children:t,...e},n)=>E.createElement(tV,{...e},(i,r)=>E.createElement(U.div,{...i,ref:re(i.ref,n)},E.createElement(d1,{instance:r},t))));nV.displayName="SliderChapters";function d1({instance:t,children:e}){let n=pe(()=>t.cues,t),i=E.useRef([]),r=E.useRef(),{$chapters:s}=E.useContext(yf);return r.current||(r.current=X3()),E.useEffect(()=>(s.set(t),()=>void s.set(null)),[t]),E.useEffect(()=>{t.setRefs(i.current)},[n]),e(n.length?n:[r.current],a=>{if(!a){i.current.length=0;return}i.current.push(a)})}d1.displayName="SliderChapterTracks";var iV=E.forwardRef(({children:t,...e},n)=>{let{$chapters:i}=E.useContext(yf),[r,s]=E.useState();return E.useEffect(()=>b(()=>{let a=i(),o=a?.activePointerCue||a?.activeCue;s(o?.text||"")}),[]),E.createElement(U.div,{...e,ref:n},r,t)});iV.displayName="SliderChapterTitle";var rV=E.forwardRef(({children:t,...e},n)=>E.createElement(qw,{...e},(i,r)=>{let s=pe(()=>r.getValueText(),r);return E.createElement(U.div,{...i,ref:re(i.ref,n)},s,t)}));rV.displayName="SliderValue";var sV=E.forwardRef((t,e)=>E.createElement(U.div,{...t,ref:e}));sV.displayName="SliderProgress";var aV=X(qc),oV=E.forwardRef(({children:t,...e},n)=>E.createElement(aV,{...e},i=>E.createElement(U.div,{...i,ref:re(i.ref,n)},t)));oV.displayName="SliderThumbnail";var lV=X(Wc,{events:["onCanPlay","onError"]}),cV=E.forwardRef(({children:t,...e},n)=>E.createElement(lV,{...e},(i,r)=>E.createElement(p1,{...i,instance:r,ref:re(i.ref,n)},t)));cV.displayName="SliderVideo";var p1=E.forwardRef(({instance:t,children:e,...n},i)=>{let{canLoad:r}=Mr(Ns),{src:s,video:a,crossOrigin:o}=t.$state,l=pe(s),c=pe(r),u=pe(o);return E.createElement(U.video,{style:{maxWidth:"unset"},...n,src:l||void 0,muted:!0,playsInline:!0,preload:c?"auto":"none",crossOrigin:u||void 0,ref:re(a.set,i)},e)});p1.displayName="SliderVideoProvider";var uV=X(Jc,{events:["onChange"]}),dV=E.forwardRef(({children:t,...e},n)=>E.createElement(uV,{...e,ref:n},i=>E.createElement(U.div,{...i},t)));dV.displayName="RadioGroup";var pV=X(eu,{events:["onChange","onSelect"]}),hV=E.forwardRef(({children:t,...e},n)=>E.createElement(pV,{...e},i=>E.createElement(U.div,{...i,ref:re(i.ref,n)},t)));hV.displayName="RadioItem";var fV=typeof document>"u",mV=X(Yc,{events:["onOpen","onClose"],domEventsRegex:/^onMedia/}),gV=E.forwardRef(({children:t,...e},n)=>E.createElement(mV,{...e,ref:n},(i,r)=>E.createElement(U.div,{...i,style:{display:r.isSubmenu?void 0:"contents",...i.style}},t)));gV.displayName="Menu";var vV=X(Qc,{events:["onSelect"]}),yV=E.forwardRef(({children:t,...e},n)=>E.createElement(vV,{...e},i=>E.createElement(U.button,{...i,ref:re(i.ref,n)},t)));yV.displayName="MenuButton";var _V=E.forwardRef(({disabled:t=!1,children:e,...n},i)=>{let r=ye("fullscreen");return fV||!(t==="fullscreen"?!r:!t)?e:(0,a1.createPortal)(E.createElement(U.div,{...n,style:{display:"contents",...n.style},ref:i},e),document.body)});_V.displayName="MenuPortal";var wV=X(Xc),bV=E.forwardRef(({children:t,...e},n)=>E.createElement(wV,{...e},i=>E.createElement(U.div,{...i,ref:re(i.ref,n)},t)));bV.displayName="MenuItems";var xV=X(Zc),kV=E.forwardRef(({children:t,...e},n)=>E.createElement(xV,{...e},i=>E.createElement(U.div,{...i,ref:re(i.ref,n)},t)));kV.displayName="MenuItem";var EV=X(nu,{events:["onWillTrigger","onTrigger"]}),$n=E.forwardRef(({children:t,...e},n)=>E.createElement(EV,{...e,ref:n},i=>E.createElement(U.div,{...i},t)));$n.displayName="Gesture";var TV=X(iu),cu=E.forwardRef(({children:t,...e},n)=>E.createElement(TV,{...e},(i,r)=>E.createElement(h1,{...i,instance:r,ref:re(i.ref,n)},t)));cu.displayName="Time";var h1=E.forwardRef(({instance:t,children:e,...n},i)=>{let{timeText:r}=t.$state,s=pe(r);return E.createElement(U.div,{...n,ref:i},s,e)});h1.displayName="TimeText";function ki(){return xi()?.player||null}function Bw({off:t=!0}={}){let e=xi(),{textTracks:n,textTrack:i}=e.$state,r=pe(n);return pe(i),E.useMemo(()=>{let s=r.filter(We),a=s.map(o=>({track:o,label:o.label,value:s1(o),get selected(){return i()===o},select(l){let c=n().indexOf(o);c>=0&&e.remote.changeTextTrackMode(c,"showing",l)}}));return t&&a.unshift({track:null,label:F(t)?t:"Off",value:"off",get selected(){return!i()},select(o){e.remote.toggleCaptions(o)}}),Object.defineProperty(a,"disabled",{get(){return!s.length}}),Object.defineProperty(a,"selectedTrack",{get(){return i()}}),Object.defineProperty(a,"selectedValue",{get(){let o=i();return o?s1(o):"off"}}),a},[r])}function s1(t){return t.id+":"+t.kind+"-"+t.label.toLowerCase()}var _f=$(z(),1),Ww=_f.forwardRef((t,e)=>{let{width:n,height:i,size:r=null,paths:s,...a}=t;return _f.createElement("svg",{viewBox:"0 0 32 32",...a,width:n??r,height:i??r,fill:"none","aria-hidden":"true",focusable:"false",xmlns:"http://www.w3.org/2000/svg",ref:e,dangerouslySetInnerHTML:{__html:s}})});Ww.displayName="VidstackIcon";var te=$(z(),1);Lt();Wt();var SV=X(Pc),f1=te.forwardRef(({children:t,...e},n)=>te.createElement(SV,{...e},i=>te.createElement(U.div,{...i,ref:re(i.ref,n)},t)));f1.displayName="Controls";var PV=X(Cc),m1=te.forwardRef(({children:t,...e},n)=>te.createElement(PV,{...e},i=>te.createElement(U.div,{...i,ref:re(i.ref,n)},t)));m1.displayName="ControlsGroup";var tr=Object.freeze({__proto__:null,Group:m1,Root:f1}),CV=X(Vc);function $V({children:t,...e}){return te.createElement(CV,{...e},t)}$V.displayName="Tooltip";var MV=X(Fc),RV=te.forwardRef(({children:t,...e},n)=>te.createElement(MV,{...e},i=>te.createElement(U.button,{...i,ref:re(i.ref,n)},t)));RV.displayName="TooltipTrigger";var LV=X(zc),IV=te.forwardRef(({children:t,...e},n)=>te.createElement(LV,{...e},i=>te.createElement(U.div,{...i,ref:re(i.ref,n)},t)));IV.displayName="TooltipContent";var AV=X(Dc,{domEventsRegex:/^onMedia/}),g1=te.forwardRef(({children:t,...e},n)=>te.createElement(AV,{...e},i=>te.createElement(U.button,{...i,ref:re(i.ref,n)},t)));g1.displayName="GoogleCastButton";var v1=te.forwardRef(({children:t,...e},n)=>{let i=ye("title");return te.createElement(U.span,{...e,ref:n},i,t)});v1.displayName="Title";function y1(t){let[e,n]=te.useState([]);return te.useEffect(()=>{if(!t){n([]);return}function i(){n(t.activeCues)}return i(),S(t,"cue-change",i)},[t]),e}function _1(t){let e=xi(),[n,i]=te.useState(null);return te.useEffect(()=>no(e.textTracks,t,i),[t]),n}function wf(){let t=_1("chapters");return y1(t)[0]?.text||""}var w1=te.forwardRef(({children:t,...e},n)=>{let i=wf();return te.createElement(U.span,{...e,ref:n},i,t)});w1.displayName="ChapterTitle";var NV=X(tu),bf=te.forwardRef(({children:t,...e},n)=>te.createElement(NV,{...e,ref:n},i=>te.createElement(U.div,{...i},t)));bf.displayName="Captions";var WU=te.forwardRef(({size:t=96,children:e,...n},i)=>te.createElement("svg",{width:t,height:t,fill:"none",viewBox:"0 0 120 120","aria-hidden":"true","data-part":"root",...n,ref:i},e)),KU=te.forwardRef(({width:t=8,children:e,...n},i)=>te.createElement("circle",{cx:"60",cy:"60",r:"54",stroke:"currentColor",strokeWidth:t,"data-part":"track",...n,ref:i},e)),GU=te.forwardRef(({width:t=8,fillPercent:e=50,children:n,...i},r)=>te.createElement("circle",{cx:"60",cy:"60",r:"54",stroke:"currentColor",pathLength:"100",strokeWidth:t,strokeDasharray:100,strokeDashoffset:100-e,"data-part":"track-fill",...i,ref:r},n));var xf=$(z(),1);Wt();function kf(t){let e=xi(),n=xf.useRef();return n.current||(n.current=new Ka),xf.useEffect(()=>{let i=t&&"current"in t?t.current:t,r=i instanceof As,s=r?i:e?.player;n.current.setPlayer(s??null),n.current.setTarget(i??null)},[e,t&&"current"in t?t.current:t]),n.current}var Pj=$(Fl(),1);var OV=["onAbort","onAudioTrackChange","onAudioTracksChange","onAutoPlay","onAutoPlayChange","onAutoPlayFail","onCanLoad","onCanPlay","onCanPlayThrough","onControlsChange","onDestroy","onDurationChange","onEmptied","onEnd","onEnded","onError","onFindMediaPlayer","onFullscreenChange","onFullscreenError","onLiveChange","onLiveEdgeChange","onLoadedData","onLoadedMetadata","onLoadStart","onLoopChange","onOrientationChange","onPause","onPictureInPictureChange","onPictureInPictureError","onPlay","onPlayFail","onPlaying","onPlaysInlineChange","onPosterChange","onProgress","onProviderChange","onProviderLoaderChange","onProviderSetup","onQualitiesChange","onQualityChange","onRateChange","onReplay","onSeeked","onSeeking","onSourceChange","onSourceChange","onStalled","onStarted","onStreamTypeChange","onSuspend","onTextTrackChange","onTextTracksChange","onTimeUpdate","onTitleChange","onVdsLog","onVideoPresentationChange","onVolumeChange","onWaiting"],VV=X(As,{events:OV,eventsRegex:/^onHls/,domEventsRegex:/^onMedia/}),Kw=V.forwardRef(({aspectRatio:t,children:e,...n},i)=>V.createElement(VV,{...n,src:n.src,ref:i,style:{aspectRatio:t,...n.style}},r=>V.createElement(U.div,{...r},e)));Kw.displayName="MediaPlayer";var FV=X(af),Gw=V.forwardRef(({loaders:t=[],children:e,mediaProps:n,buildMediaEl:i,...r},s)=>{let a=V.useMemo(()=>t.map(o=>new o),t);return V.createElement(FV,{...r,loaders:a,ref:s},(o,l)=>V.createElement("div",{...o},V.createElement(k1,{...n,provider:l,buildMediaEl:i}),e))});Gw.displayName="MediaProvider";function k1({provider:t,buildMediaEl:e,...n}){let{controls:i,crossOrigin:r,poster:s,remotePlaybackInfo:a}=Mr(Ns),{loader:o}=t.$state,{$iosControls:l,$provider:c,$providerSetup:u}=xi(),d=pe(i),p=pe(l),h=d||p,y=pe(r),v=pe(s),w=pe(o),m=pe(c),f=pe(u),g=pe(a),x=w?.mediaType(),T=w?.name==="youtube",L=w?.name==="vimeo",R=T||L,I=w?.name==="remotion",K=w?.name==="google-cast",[H,_e]=V.useState("");return V.useEffect(()=>{!K||H||Promise.resolve().then(()=>(x1(),b1)).then(J=>{_e(J.default)})},[K]),K?V.createElement("div",{className:"vds-google-cast",ref:J=>{t.load(J)}},V.createElement(Ww,{paths:H}),g?.deviceName?V.createElement("span",{className:"vds-google-cast-info"},"Google Cast on"," ",V.createElement("span",{className:"vds-google-cast-device-name"},g.deviceName)):null):I?V.createElement("div",{"data-remotion-canvas":!0},V.createElement("div",{"data-remotion-container":!0,ref:J=>{t.load(J)}},r1(m)&&f?V.createElement(m.render):null)):e?.(w,t)??(R?V.createElement(V.Fragment,null,V.createElement("iframe",{className:T?"vds-youtube":"vds-vimeo",suppressHydrationWarning:!0,tabIndex:h?void 0:-1,"aria-hidden":"true","data-no-controls":h?void 0:"",ref(J){t.load(J)}}),h?null:V.createElement("div",{className:"vds-blocker"})):x?V.createElement(x==="audio"?"audio":"video",{...n,controls:h?"true":null,crossOrigin:typeof y=="boolean"?"":y,poster:x==="video"&&h&&v?v:null,preload:"none","aria-hidden":"true",suppressHydrationWarning:!0,ref(J){t.load(J)}}):null)}k1.displayName="MediaOutlet";function zV(t){let e=xi(),n=V.useMemo(()=>new ln(t),Object.values(t));return V.useEffect(()=>(e.textTracks.add(n),()=>void e.textTracks.remove(n)),[n]),n}function Yw({lang:t,...e}){return zV({language:t,...e}),null}Yw.displayName="Track";var UV=X(of),jV=V.forwardRef(({children:t,...e},n)=>V.createElement(UV,{...e},i=>V.createElement(U.button,{...i,ref:re(i.ref,n)},t)));jV.displayName="ToggleButton";var HV=X(lf),qV=V.forwardRef(({children:t,...e},n)=>V.createElement(HV,{...e},(i,r)=>V.createElement(E1,{...i,instance:r,ref:re(i.ref,n)},t)));qV.displayName="Poster";var E1=V.forwardRef(({instance:t,children:e,...n},i)=>{let{src:r,img:s,alt:a,crossOrigin:o}=t.$state,l=pe(r),c=pe(a),u=pe(o);return V.createElement(U.img,{...n,src:l||"",alt:c||void 0,crossOrigin:u||void 0,ref:re(s.set,i)},e)});E1.displayName="PosterImg";var BV=V.forwardRef(({children:t,...e},n)=>V.createElement(U.div,{translate:"yes","aria-live":"off","aria-atomic":"true",...e,ref:n},t));BV.displayName="Caption";var WV=V.forwardRef((t,e)=>{let n=ye("textTrack"),[i,r]=V.useState();return V.useEffect(()=>{if(!n)return;function s(){r(n?.activeCues[0])}return n.addEventListener("cue-change",s),()=>{n.removeEventListener("cue-change",s),r(void 0)}},[n]),V.createElement(U.span,{...t,"data-part":"cue",dangerouslySetInnerHTML:{__html:i?.text||""},ref:e})});WV.displayName="CaptionText";function T1(){let[t,e]=V.useState(null),n=xi();return V.useEffect(()=>{if(n)return b(()=>{e(n.$provider())})},[]),t}function S1({clamp:t=!1,offset:e=0,orientation:n="horizontal"}={}){let[i,r]=V.useState(null),[s,a]=V.useState(null),[o,l]=V.useState(0),[c,u]=V.useState(!1);return V.useEffect(()=>{if(!i)return;let d=D(!1);function p(h){i&&l(KV(i,h,n))}return b(()=>{if(!d()){S(i,"pointerenter",()=>{u(!0),s?.setAttribute("data-visible","")}),S(i,"pointerdown",h=>{d.set(!0),p(h)}),S(i,"pointerleave",()=>{u(!1),s?.removeAttribute("data-visible")}),S(i,"pointermove",h=>{p(h)});return}s?.setAttribute("data-dragging",""),S(document,"pointerup",h=>{d.set(!1),s?.removeAttribute("data-dragging"),p(h)}),S(document,"pointermove",h=>{p(h)}),S(document,"touchmove",h=>h.preventDefault(),{passive:!1})})},[i]),V.useEffect(()=>{s&&s.style.setProperty("--slider-pointer",o+"%")},[s,o]),V.useEffect(()=>{if(!s)return;let d=()=>{Dw(s,{offset:e,clamp:t,orientation:n})};d();let p=new ResizeObserver(d);return p.observe(s),()=>p.disconnect()},[s,t,e,n]),{previewRootRef:r,previewRef:a,previewValue:o,isPreviewVisible:c}}function KV(t,e,n){let i,r=t.getBoundingClientRect();if(n==="vertical"){let{bottom:s,height:a}=r;i=(s-e.clientY)/a}else{let{left:s,width:a}=r;i=(e.clientX-s)/a}return GV(Math.max(0,Math.min(100,100*i)))}function GV(t){return Number(t.toFixed(3))}var P1='"use strict";var X=()=>({emit(e,...t){for(let n=0,r=this.events[e]||[],i=r.length;n{this.events[e]=this.events[e]?.filter(n=>t!==n)}}});function Z(){let e=X();return e.once=function(n,r){let i=this.on(n,(...s)=>{i(),r(...s)});return i},e}function ee(e){let t=e;return typeof t.id=="string"&&typeof t.invoke=="string"}function te(e,...t){return{id:Ce(),invoke:e,args:t}}function ne(e){return typeof e.id=="string"}function re(e){return typeof e.send=="string"}function ie(e,t){return{send:e,payload:t}}function Ce(){return Math.random().toString(36).substring(2,9)}var k=class extends Error{constructor(t){super(`no handler for ${t}`)}},N="mx-port-ready";var R=class{port=null;load(t){this.port&&this.port.close(),this.port=t;let n=({data:r})=>{this.onMessage(r)};t.addEventListener("message",n),t.start(),t.postMessage(N)}unload(){this.port?.close(),this.emitter.events={}}actions=Object.create(null);emitter=Z();onMessage(t){t===N?this.emitter.emit("ready"):ee(t)?this.response(t):ne(t)?this.emitter.emit("resp",t.id,t.payload,t.error):re(t)&&this.emitter.emit(`send:${t.send}`,{type:t.send,payload:t.payload})}methods=new Proxy({},{get:(t,n)=>{if(typeof n=="symbol")throw new Error("Remote invoke does not support symbol property");return t[n]??=(...r)=>this.invoke(n.toString(),r)}});invoke(t,n,{transfer:r,timeout:i=1e3}={}){if(!this.port)throw new Error("port not loaded");let s=te(t,...n);return this.port.postMessage(s,{transfer:r}),new Promise((o,a)=>{let l=-1,u=this.emitter.on("resp",(c,p,y)=>{if(c===s.id)if(u(),window.clearTimeout(l),y){let{message:K,stack:z}=y,S=new Error(K);S.stack=z,a(S)}else o(p)});i>0&&i<1/0&&(l=window.setTimeout(()=>{u(),a(new M(i))},i))})}handle(t,n){this.actions[t]=n}send(t,n,r){if(!this.port)throw new Error("port not loaded");let i=ie(t,n);this.port.postMessage(i,{transfer:r})}on(t,n){return this.emitter.on(`send:${t}`,n)}once(t,n){return this.emitter.once(`send:${t}`,n)}onReady(t,{once:n=!1}={}){return n?this.emitter.once("ready",t):this.emitter.on("ready",t)}async response({id:t,invoke:n,args:r=[]}){if(!this.port)throw new Error("port not loaded");let i={id:t,payload:null};try{let s=this.actions[n];if(!s)throw new k(n);let o=await s(...r);o===void 0?this.port.postMessage(i):(i.payload=await o.value,this.port.postMessage(i,{transfer:o.transfer}))}catch(s){s instanceof Error?i.error={message:s.message,stack:s.stack}:i.error={message:String(s)},this.port.postMessage(i)}}},M=class extends Error{constructor(t){super(`timeout after ${t}ms`)}};var se="mx-port";async function q(){let e=await new Promise((n,r)=>{function i({data:o,ports:a}){o===se&&(n(a[0]),window.removeEventListener("message",i),window.clearTimeout(s))}window.addEventListener("message",i);let s=setTimeout(()=>{r("failed to get port: timeout "+5e3),window.removeEventListener("message",i)},5e3)}),t=new R;return t.load(e),t}var A=class{#e=[];#t=!1;async load(){if(!this.#t){this.#t=!0,await this.onload();for(let t of this.#n)await t.load()}}async onload(){}async unload(){if(!this.#t)return;this.#t=!1;let t;for(;t=this.#e.pop();)await t();let n;for(;n=this.#n.pop();)await n.unload();await this.onunload()}async onunload(){}register(t){this.#e.push(t)}registerInterval(t,n){let r=setInterval(t,n);this.register(()=>clearInterval(r))}registerDomEvent(t,n,r,i){t.addEventListener(n,r,i),this.register(()=>t.removeEventListener(n,r,i))}#n=[];async addChild(t){return this.#n.push(t),this.#t&&await t.load(),t}async removeChild(t){let n=this.#n.indexOf(t);return n!==-1&&(this.#n.splice(n,1),t.unload()),t}};function d(e){let t=[];for(let n=0;nn.send("enterpictureinpicture",void 0)),e.registerDomEvent(t,"leavepictureinpicture",()=>n.send("leavepictureinpicture",void 0)));function r(){n.send("abort",void 0)}function i(){n.send("emptied",void 0)}function s(){t.error&&n.send("error",{code:t.error.code,message:t.error.message})}function o(){n.send("volumechange",{muted:t.muted,volume:t.volume})}function a(){n.send("durationchange",{played:d(t.played),duration:t.duration})}function l(){n.send("progress",{buffered:d(t.buffered),seekable:d(t.seekable)})}function u(){n.send("stalled",{readyState:t.readyState})}function c(){n.send("suspend",void 0)}function p(){n.send("ratechange",{rate:t.playbackRate})}function y(){n.send("seeked",{current:t.currentTime,played:d(t.played),duration:t.duration,ended:t.ended})}function K(){n.send("seeking",{current:t.currentTime})}function z(){n.send("ended",{controls:t.controls,current:t.currentTime,played:d(t.played),duration:t.duration,ended:t.ended})}function S(){n.send("waiting",{readyState:t.readyState})}}var U=class{value;next;constructor(t){this.value=t}},T=class{#e;#t;#n;constructor(){this.clear()}enqueue(t){let n=new U(t);this.#e?(this.#t.next=n,this.#t=n):(this.#e=n,this.#t=n),this.#n++}dequeue(){let t=this.#e;if(t)return this.#e=this.#e.next,this.#n--,t.value}clear(){this.#e=void 0,this.#t=void 0,this.#n=0}get size(){return this.#n}*[Symbol.iterator](){let t=this.#e;for(;t;)yield t.value,t=t.next}};var le={bind(e,t,n){return e.bind(n)}};function F(e){if(!((Number.isInteger(e)||e===Number.POSITIVE_INFINITY)&&e>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let t=new T,n=0,r=()=>{n--,t.size>0&&t.dequeue()()},i=async(a,l,u)=>{n++;let c=(async()=>a(...u))();l(c);try{await c}catch{}r()},s=(a,l,u)=>{t.enqueue(le.bind(i.bind(void 0,a,l,u))),(async()=>(await Promise.resolve(),n0&&t.dequeue()()))()},o=(a,...l)=>new Promise(u=>{s(a,u,l)});return Object.defineProperties(o,{activeCount:{get:()=>n},pendingCount:{get:()=>t.size},clearQueue:{value(){t.clear()}}}),o}async function ue(e,t,n){let r=document.createElement("canvas"),{videoWidth:i,videoHeight:s}=e;Object.assign(r,{width:i,height:s});let o=r.getContext("2d",{alpha:!1});if(!o)throw new Error("Canvas context creation failed");o.drawImage(e,0,0,i,s);let a=await new Promise((u,c)=>{try{r.toBlob(p=>{p?u(p):c(new Error("Canvas to blob failed"))},t,n)}catch(p){c(p)}}),l=await a.arrayBuffer();return{time:e.currentTime,blob:{arrayBuffer:l,type:a.type}}}var de=["currentTime","playbackRate","volume","muted"],ce=["paused","played","networkState","duration","buffered","seekable","readyState","ended","autoplay","error"],me=["play","pause"],fe="mx-mounted";function x(e){return e[0].toUpperCase()+e.slice(1)}function V(e){return e instanceof TimeRanges?d(e):e}function pe(){let e=this.media,t=this.controller,n=this.stateRef;ce.forEach(i=>{t.handle(`get${x(i)}`,()=>({value:V(e[i])}))}),t.handle("pictureInPictureEnabled",()=>({value:document.pictureInPictureElement===e})),t.handle("requestPictureInPicture",()=>{e instanceof HTMLVideoElement&&e.requestPictureInPicture()}),t.handle("exitPictureInPicture",()=>{document.exitPictureInPicture()}),de.forEach(i=>{t.handle(`get${x(i)}`,()=>({value:V(e[i])})),i==="currentTime"?t.handle(`set${x(i)}`,s=>{n.prevSeek={value:e.currentTime,time:Date.now()},e[i]=s}):t.handle(`set${x(i)}`,s=>{e[i]=s})}),me.forEach(i=>{t.handle(i,async(...s)=>({value:await e[i](...s)}))}),t.handle("screenshot",async(i,s)=>{if(!(e instanceof HTMLVideoElement))throw new Error("Cannot take screenshot of non-video element");let o=await ue(e,i,s);return{value:o,transfer:[o.blob.arrayBuffer]}});let r=F(4);return t.handle("fetch",async(i,{gzip:s=!1,...o}={})=>{let a=await r(()=>window.fetch(i,o)),l=await a.blob(),u={type:l.type,respHeaders:Object.fromEntries(a.headers)};if(!s){let y=await l.arrayBuffer();return{value:{ab:y,gzip:!1,...u},transfer:[y]}}let c=l.stream(),p=await De(c.pipeThrough(new CompressionStream("gzip")));return{value:{ab:p,gzip:!0,...u},transfer:[p]}}),n}async function De(e){let t=e.getReader(),n=[];for(;;){let{done:s,value:o}=await t.read();if(s)break;n.push(o)}let r=n.reduce((s,o)=>s+o.byteLength,0),i=new Uint8Array(r);for(let s=0,o=0;s=0&&o(),t.readyState>=1&&a(),t.readyState>=2&&l(),t.readyState>=3&&u(),t.readyState>=4&&c(),e.registerDomEvent(t,"play",s),e.registerDomEvent(t,"pause",r),e.registerDomEvent(t,"playing",i),t.readyState>=3&&!t.paused?(s(),i()):r();function r(){n.send("pause",{readyState:t.readyState})}function i(){n.send("playing",void 0)}function s(){n.send("play",void 0)}function o(){n.send("loadstart",{networkState:t.networkState})}function a(){n.send("loadedmetadata",void 0)}function l(){n.send("loadeddata",void 0)}function u(){n.send("canplay",{buffered:d(t.buffered),seekable:d(t.seekable),duration:t.duration})}function c(){n.send("canplaythrough",{buffered:d(t.buffered),seekable:d(t.seekable),duration:t.duration})}}var g=Symbol(0),C=!1,he=!1,$=null,E=null,f=null,m=0,b=[],j={};var w=0,we=1,P=2,B=3;function Ie(){C=!0,queueMicrotask(Oe)}function Oe(){if(!b.length){C=!1;return}he=!0;for(let e=0;e=0;n--)J(t[n])}function G(e=!0){if(this.$st===B)return;let t=e?this.$ps||this[g]:this,n=this.$ns,r=null;for(;n&&n[g]===this;)G.call(n,!0),ye(n),r=n.$ns,n.$ns=null,n=r;e&&ye(this),n&&(n.$ps=e?this.$ps:this),t&&(t.$ns=n)}function ye(e){e.$st=B,e.$d&&Me(e),e.$s&&L(e,0),e.$ps&&(e.$ps.$ns=null),e[g]=null,e.$s=null,e.$o=null,e.$ps=null,e.$cx=j,e.$eh=null}function Me(e){try{if(Array.isArray(e.$d))for(let t=e.$d.length-1;t>=0;t--){let n=e.$d[t];n.call(n)}else e.$d.call(e.$d);e.$d=null}catch(t){Te(e,t)}}function _e(e,t,n){let r=$,i=E;$=e,E=n;try{return t.call(e)}finally{$=r,E=i}}function Te(e,t){if(!e||!e.$eh)throw t;let n=0,r=e.$eh.length,i=ve(t);for(n=0;n0){e.$s.length=m+f.length;for(let s=0;s=t)&&(e.$e&&e.$st===w&&(b.push(e),C||Ie()),e.$st=t,e.$o))for(let n=0;n"u"}function Q(e){return typeof e=="number"&&!Number.isNaN(e)}var Ee,Ve=Event,Se=Symbol("DOM_EVENT"),W=class extends Ve{constructor(t,...n){super(t,n[0]),this[Ee]=!0,this.triggers=new D,this.detail=n[0]?.detail;let r=n[0]?.trigger;r&&this.triggers.add(r)}static{Ee=Se}get trigger(){return this.triggers.source}get originEvent(){return this.triggers.origin}get isOriginTrusted(){return this.triggers.origin?.isTrusted??!1}},D=class{constructor(){this.chain=[]}get source(){return this.chain[0]}get origin(){return this.chain[this.chain.length-1]}add(t){this.chain.push(t),ke(t)&&this.chain.push(...t.triggers)}remove(t){return this.chain.splice(this.chain.indexOf(t),1)[0]}has(t){return this.chain.some(n=>n===t)}hasType(t){return!!this.findType(t)}findType(t){return this.chain.find(n=>n.type===t)}walk(t){for(let n of this.chain){let r=t(n);if(r)return[n,r]}}[Symbol.iterator](){return this.chain.values()}};function ke(e){return!!e?.[Se]}var dn=typeof window<"u"?"requestIdleCallback"in window?window.requestIdleCallback:e=>window.setTimeout(e,1):Pe;var O=class{constructor(t){this._callback=t}_id;_start(){I(this._id)&&this._loop()}_stop(){Q(this._id)&&window.cancelAnimationFrame(this._id),this._id=void 0}_loop(){this._id=window.requestAnimationFrame(()=>{I(this._id)||(this._callback(),this._loop())})}};function Re(e){let t=e.media,n=e.controller,r=new O(a);e.register(()=>r._stop());let i,s=t.currentTime;function o(){i!==t.paused&&(i=t.paused,t.paused?t.addEventListener("timeupdate",a):t.removeEventListener("timeupdate",a))}o(),t.addEventListener("ended",()=>{r._stop(),o()}),t.addEventListener("pause",()=>{r._stop(),o()}),t.addEventListener("playing",()=>{r._start(),o()});function a(){s!==t.currentTime&&(s=t.currentTime,n.send("timeupdate",{current:s,played:d(t.played)}))}}function H(e,t=document.body,n=1e4){return new Promise((r,i)=>{let s=t.querySelector(e);if(s){r(s);return}let o=new MutationObserver(()=>{let l=t.querySelector(e);l&&(o.disconnect(),r(l),window.clearTimeout(a))}),a=window.setTimeout(()=>{o.disconnect(),i(new Error(`timeout waiting for ${e}`))},n);o.observe(t,{childList:!0,subtree:!0})})}var We=[".dplayer",".video-js",".jwplayer","[data-player]"],h=class extends A{constructor(n){super();this.controller=n;this.register(()=>n.unload())}getStyle(){return Ge}#e=null;stateRef={prevSeek:null};findMedia(){return H("video, audio")}async load(){let n=this.getStyle();n&&this.injectStyle(n),await super.load();let r=this.media.controls===!0;r&&(this.media.controls=!1),this.register(this.controller.on("mx-toggle-controls",({payload:i})=>{document.body.classList.toggle("mx-show-controls",i)})),r&&this.register(this.controller.on("mx-toggle-controls",({payload:i})=>{this.media.controls=i})),this.register(this.controller.on("mx-toggle-webfs",({payload:i})=>{document.body.classList.toggle("mx-fs-enable",i)})),document.body.classList.add("mx-play-ready"),this.controller.send("mx-play-ready",void 0)}get media(){if(!this.#e)throw new Error("Get media before load");return this.#e}async onload(){this.#e=await this.findMedia(),await Promise.all([this.enterWebFullscreen(),this.hookMediaEl()])}enterWebFullscreen(){document.body.classList.add("mx-fs-enable");let n=this.media.closest(We.join(", "))??this.media;n.classList.add("mx-player"),this.assignParentClass(n),window.dispatchEvent(new Event("resize"))}assignParentClass(n){for(let r of je(n))r.classList.add("mx-parent"),getComputedStyle(r).position=="fixed"&&r.classList.add("mx-absolute")}injectStyle(n){let r=document.createElement("style");r.textContent=n,document.head.appendChild(r),this.register(()=>r.remove())}async untilMediaReady(n="canplay",r=5e3){if(this.media.readyState>=Be[n])return;let i=-1;await new Promise((s,o)=>{this.registerDomEvent(this.media,n,s,{once:!0}),i=window.setTimeout(()=>{o(new M(r))},r)}),window.clearTimeout(i)}async hookMediaEl(){ge(this),Re(this),ae(this),pe.call(this),this.controller.send(fe,void 0)}};function*je(e,t=!1){for(t&&(yield e);e.parentElement&&e.parentElement!==document.body;)e=e.parentElement,yield e}var Be={loadedmetadata:HTMLMediaElement.HAVE_METADATA,loadeddata:HTMLMediaElement.HAVE_CURRENT_DATA,canplay:HTMLMediaElement.HAVE_FUTURE_DATA,canplaythrough:HTMLMediaElement.HAVE_ENOUGH_DATA},Ge=`\nbody.mx-fs-enable .mx-player {\n position: fixed !important;\n top: 0 !important;\n left: 0 !important;\n width: 100vw !important;\n height: 100vh !important;\n max-width: none !important;\n max-height: none !important;\n min-width: 0 !important;\n min-height: 0 !important;\n margin: 0 !important;\n padding: 0 !important;\n z-index: 2147483647 !important; /* Ensure it\'s on top of other elements */\n background-color: #000 !important;\n transform: none !important;\n}\nbody.mx-fs-enable .mx-parent {\n overflow: visible !important;\n z-index: auto !important;\n transform: none !important;\n -webkit-transform-style: flat !important;\n transition: none !important;\n contain: none !important;\n}\nbody.mx-fs-enable .mx-absolute {\n position: absolute !important;\n}\nbody.mx-fs-enable {\n overflow: hidden !important;\n zoom: 100% !important;\n}\nbody.mx-fs-enable .mx-parent video {\n object-fit: contain !important;\n}\n`.trim();var Ye={waitForSelector:H,MediaPlugin:h},Ae=(e=>function(n){if(n in e)return e[n];throw new Error(`Module not found: ${n.toString()}`)})({"media-extended":Ye});async function Le(e,t){if(!e)return new h(t);let n=window.eval(`(function anonymous(require,module,exports){${e}\n})`),r={},i={exports:r};n(Ae,i,r),r=i.exports||r;let s=r.default||i.exports;if(!s)throw new Error("Failed to load plugin. No exports detected.");let o=new s(t);if(!(o instanceof h))throw new Error("Failed to load plugin. plugin not extends MediaPlugin");return o}var _;q().then(e=>{e.handle("loadPlugin",async t=>{_&&_.unload(),_=await Le(t,e),_.load()})});\n';var nr=Symbol(0),Tf=!1,C1=!1,Ds=null,so=null,Mn=null,hn=0,ro=[],Xw={},QV=()=>{},ao=0,I1=1,uu=2,Pf=3;function XV(){Tf=!0,queueMicrotask(ZV)}function ZV(){if(!ro.length){Tf=!1;return}C1=!0;for(let t=0;t=0;n--)eb(e[n])}function A1(t){if(!t||!Ds)return t||QV;let e=Ds;return e.$d?Array.isArray(e.$d)?e.$d.push(t):e.$d=[e.$d,t]:e.$d=t,function(){e.$st!==Pf&&(t.call(null),V1(e.$d)?e.$d=null:Array.isArray(e.$d)&&e.$d.splice(e.$d.indexOf(t),1))}}function Zw(t=!0){if(this.$st===Pf)return;let e=t?this.$ps||this[nr]:this,n=this.$ns,i=null;for(;n&&n[nr]===this;)Zw.call(n,!0),$1(n),i=n.$ns,n.$ns=null,n=i;t&&$1(this),n&&(n.$ps=t?this.$ps:this),e&&(e.$ns=n)}function $1(t){t.$st=Pf,t.$d&&N1(t),t.$s&&Ef(t,0),t.$ps&&(t.$ps.$ns=null),t[nr]=null,t.$s=null,t.$o=null,t.$ps=null,t.$cx=Xw,t.$eh=null}function N1(t){try{if(Array.isArray(t.$d))for(let e=t.$d.length-1;e>=0;e--){let n=t.$d[e];n.call(n)}else t.$d.call(t.$d);t.$d=null}catch(e){D1(t,e)}}function eF(t,e,n){let i=Ds,r=so;Ds=t,so=n;try{return e.call(t)}finally{Ds=i,so=r}}function D1(t,e){if(!t||!t.$eh)throw e;let n=0,i=t.$eh.length,r=M1(e);for(n=0;n0){t.$s.length=hn+Mn.length;for(let s=0;s=e)&&(t.$e&&t.$st===ao&&(ro.push(t),Tf||XV()),t.$st=e,t.$o))for(let n=0;nn===e)}hasType(e){return!!this.findType(e)}findType(e){return this.chain.find(n=>n.type===e)}walk(e){for(let n of this.chain){let i=e(n);if(i)return[n,i]}}[Symbol.iterator](){return this.chain.values()}};function j1(t){return!!t?.[U1]}function oF(){let t=new Set;return{add(...e){for(let n of e)t.add(n)},empty(){for(let e of t)e();t.clear()}}}function H1(){let t=oF();return A1(t.empty),t}var v7=typeof window<"u"?"requestIdleCallback"in window?window.requestIdleCallback:t=>window.setTimeout(t,1):z1;var zr=require("obsidian");var q1=`"use strict";var s=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var y=(r,e)=>{for(var t in e)s(r,t,{get:e[t],enumerable:!0})},b=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of p(e))!m.call(r,n)&&n!==t&&s(r,n,{get:()=>e[n],enumerable:!(i=d(e,n))||i.enumerable});return r};var f=r=>b(s({},"__esModule",{value:!0}),r);var k={};y(k,{default:()=>o});module.exports=f(k);var c=()=>require("media-extended");var{waitForSelector:l,MediaPlugin:h}=c(),w=\` #bilibili-player .bpx-player-control-wrap { opacity: 0 !important; } @@ -28,13 +28,13 @@ Error generating stack: `+s.message+` opacity: 100 !important; } \`,o=class extends h{findMedia(){return l("#bilibili-player video")}getStyle(){return w}async onload(){this.controller.handle("bili_getManifest",()=>({value:window.player.getManifest()})),localStorage.setItem("recommend_auto_play","close"),localStorage.setItem("bpx_player_profile",JSON.stringify({media:{autoplay:!1}})),await super.onload(),this.revertAutoSeek(),Promise.all([this.toggleDanmaku(!1)]),await this.untilWebFullscreen()}get player(){return this.media.closest("#bilibili-player")}async toggleDanmaku(e){if(window.player){e===void 0&&(e=!window.player.danmaku.isOpen()),e?window.player.danmaku.open():window.player.danmaku.close();return}let t=await l(".bui-danmaku-switch",this.player);if(!t)return;let i=t.querySelector("input.bui-danmaku-switch-input");if(i){if(e===void 0){i.click();return}e!==this.isDanmakuOn(t)&&i.click()}}isDanmakuOn(e){return e.querySelector(".bui-danmaku-switch-off")?.offsetHeight===0}isWebFullscreen(){return this.player.classList.contains("mode-webscreen")}enterWebFullscreen(){this.isWebFullscreen()||l(".bpx-player-ctrl-web",this.player).then(e=>{e.click()})}revertAutoSeek(){let t=this.player.querySelector(".bpx-player-toast-auto");if(!t)return;let i=()=>{this.stateRef.prevSeek&&this.stateRef.prevSeek.time>Date.now()-5e3?this.media.currentTime=this.stateRef.prevSeek.value:this.media.currentTime=0},n=new MutationObserver(u=>{u.find(a=>a.type==="childList"&&a.addedNodes.length>0)?.addedNodes.forEach(a=>{a.textContent?.includes("\\u5DF2\\u4E3A\\u60A8\\u5B9A\\u4F4D\\u81F3")&&(a.style.opacity="0",i())})});n.observe(t,{childList:!0,subtree:!0}),this.register(()=>n.disconnect())}async untilWebFullscreen(){let e=this.player;this.isWebFullscreen()||await new Promise(t=>{let i=new MutationObserver(n=>{n.find(a=>a.type==="attributes"&&a.attributeName==="class"&&e?.classList.contains("mode-webscreen"))&&(i.disconnect(),t(void 0))});i.observe(e,{attributes:!0}),setTimeout(()=>{i.disconnect(),t(void 0)},6e3)})}}; -`;var F1=`"use strict";var a=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var u=(r,e)=>{for(var o in e)a(r,o,{get:e[o],enumerable:!0})},m=(r,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of p(e))!d.call(r,t)&&t!==o&&a(r,t,{get:()=>e[t],enumerable:!(s=l(e,t))||s.enumerable});return r};var c=r=>m(a({},"__esModule",{value:!0}),r);var b={};u(b,{default:()=>i});module.exports=c(b);var n=()=>require("media-extended");var y=\` +`;var B1=`"use strict";var a=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var u=(r,e)=>{for(var o in e)a(r,o,{get:e[o],enumerable:!0})},m=(r,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of p(e))!d.call(r,t)&&t!==o&&a(r,t,{get:()=>e[t],enumerable:!(s=l(e,t))||s.enumerable});return r};var c=r=>m(a({},"__esModule",{value:!0}),r);var b={};u(b,{default:()=>i});module.exports=c(b);var n=()=>require("media-extended");var y=\` body:not(.mx-show-controls) .vp-player-ui-overlays { opacity: 0 !important; } \`,{waitForSelector:x,MediaPlugin:M}=n(),i=class extends M{findMedia(){return x("#main [data-player] .vp-video video")}getStyle(){return super.getStyle()+\` \`+y}}; -`;var z1=`"use strict";var s=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var y=(o,t)=>{for(var e in t)s(o,e,{get:t[e],enumerable:!0})},h=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of p(t))!u.call(o,r)&&r!==e&&s(o,r,{get:()=>t[r],enumerable:!(n=m(t,r))||n.enumerable});return o};var b=o=>h(s({},"__esModule",{value:!0}),o);var M={};y(M,{default:()=>a});module.exports=b(M);var d=()=>require("media-extended");var g=\` +`;var W1=`"use strict";var s=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var y=(o,t)=>{for(var e in t)s(o,e,{get:t[e],enumerable:!0})},h=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of p(t))!u.call(o,r)&&r!==e&&s(o,r,{get:()=>t[r],enumerable:!(n=m(t,r))||n.enumerable});return o};var b=o=>h(s({},"__esModule",{value:!0}),o);var M={};y(M,{default:()=>a});module.exports=b(M);var d=()=>require("media-extended");var g=\` body:not(.mx-player-ready) #movie_player, ytd-watch-flexy[theater] #movie_player { position: fixed !important; @@ -103,22 +103,22 @@ ytm-companion-ad-renderer { } \`.trim(),{waitForSelector:i,MediaPlugin:w}=d(),a=class extends w{findMedia(){return i("ytd-app #movie_player video")}getStyle(){return g+\` \`+v}async onload(){await super.onload(),Promise.all([i(".video-ads.ytp-ad-module",this.app).then(t=>this.removePlayerAD(t)),this.disableAutoPlay()])}get app(){return this.media.closest("ytd-app")}get moviePlayer(){return this.media.closest("#movie_player")}async disableAutoPlay(){let e=await i('button.ytp-button[data-tooltip-target-id="ytp-autonav-toggle-button"]',this.app);if(!e)throw new Error("Autoplay button not found");let n=e.querySelector(".ytp-autonav-toggle-button");if(!n)throw new Error("Autoplay button label not found");let r=()=>n.getAttribute("aria-checked")==="true";r()&&(e.click(),await new Promise(c=>{let l=new MutationObserver(()=>{r()||(l.disconnect(),c())});l.observe(n,{attributes:!0})}))}removePlayerAD(t){let e=new MutationObserver(()=>this.skipAd());this.registerInterval(()=>this.skipAd(),500),e.observe(t,{childList:!0,subtree:!0})}skipAd(){let t=this.media,e=this.moviePlayer.querySelector(".ytp-ad-skip-button")||this.moviePlayer.querySelector(".ytp-ad-skip-button-modern"),n=this.moviePlayer.querySelector(".video-ads.ytp-ad-module .ytp-ad-player-overlay");if(t)if(e){if(window.location.href.indexOf("https://m.youtube.com/")===-1&&(t.muted=!0),t.currentTime>.5){t.currentTime=t.duration;return}e.click(),E.call(e)}else n&&(t.currentTime=t.duration)}enterWebFullscreen(){this.assignParentClass(this.moviePlayer),(async()=>{let t=await i("#movie_player .ytp-size-button"),e=()=>!!this.app.querySelector("ytd-watch-flexy[theater]");if(!e())do t.click(),await f(200);while(!e());window.dispatchEvent(new Event("resize"))})()}};function f(o){return new Promise(t=>setTimeout(t,o))}function E(){let o=new Touch({identifier:Date.now(),target:this,clientX:12,clientY:34,radiusX:56,radiusY:78,rotationAngle:0,force:1}),t=new TouchEvent("touchstart",{bubbles:!0,cancelable:!0,view:window,touches:[o],targetTouches:[o],changedTouches:[o]});this.dispatchEvent(t);let e=new TouchEvent("touchend",{bubbles:!0,cancelable:!0,view:window,touches:[],targetTouches:[],changedTouches:[o]});this.dispatchEvent(e)} -`;var U1={bilibili:V1,youtube:z1,vimeo:F1,coursera:void 0,generic:void 0};var j1={generic:t=>t,bilibili:t=>t.replaceAll(/[-_]哔哩哔哩.+$|[-_]bilibili.+$|-(?:番剧|电影|纪录片|国创|电视剧|综艺)-.+/g,""),youtube:t=>t.replace(/ - YouTube$/,""),vimeo:t=>t.replace(/ on Vimeo$/,""),coursera:t=>t.replace(/ \| Coursera$/,"")};var lC=require("url"),so=require("obsidian");var cu=require("obsidian");function xf(t){return t===0?"00:00:00":cu.moment.utc(cu.moment.duration({seconds:t}).as("milliseconds")).format("HH:mm:ss")}function B1(t){return t===0?"DT0S":cu.moment.duration(t,"seconds").toISOString()}var q1=(t,e=2)=>{let n,i;return Number.isInteger(t)?n=t.toString():[n,i]=t.toFixed(e).split("."),n.length===1&&(n="0"+n),i?n+"."+i:n};function kf(t){return t.replace(/t=[^&]+/,"")}function W1(t,e){let n=Qw(e);return`${t}&${n}`}function K1(t,e){let n=Number.isNaN(t)?-1:t,i=Number.isNaN(e)?-1:e;return{start:n,end:i}}function Qw(t){let{start:e,end:n}=t,i={get start(){return H1(e)},get end(){return H1(n)}};return kn(t)?`t=${i.start}`:e<0&&n>0?Number.isFinite(n)?`t=,${i.end}`:null:e>0&&n>0?`t=${i.start},${i.end}`:null}function H1(t){if(Number.isNaN(t)||t<0)throw new Error("durationInSecond must be positive");if(t===1/0)return"e";let e=cu.moment.duration(t,"seconds"),n=e.hours(),i=e.minutes(),r=e.seconds()+e.milliseconds()/1e3;if(n>0)return[n,...[i,r].map(s=>q1(s))].join(":");if(i>0)return[i,r].map(s=>q1(s)).join(":");if(r>0)return r.toFixed(2);throw new Error("durationInSecond must be positive")}var G1=require("obsidian"),rF=G1.Platform.isWin?require("path/win32"):require("path/posix"),xi=rF;function ki(t){let e=new URL(t.href),n=kf(e.hash);return e.hash===n?t:e}function Y1(t){return t.hostname==="b23.tv"?!1:t.hostname.endsWith(".bilibili.com")&&(t.pathname.startsWith("/video/")||t.pathname.startsWith("/bangumi/play/"))?t.pathname.split("/").filter(Boolean).slice(-1)[0]:null}var Q1=t=>Y1(t)===null?null:"bilibili",X1=t=>{let e=Y1(t);if(e===null)throw new Error("Invalid bilibili url");let n=Cr(t.hash),i=sF(t),r=zn(t);r.searchParams.forEach((a,o,l)=>{o==="p"&&a!=="1"||l.delete(o)}),r.searchParams.sort();let s=new URL(r);return!n&&i>0&&(n={start:i,end:-1}),n&&kn(n)&&s.searchParams.set("t",String(n.start)),{source:ki(s),cleaned:r,id:e||void 0}};function sF(t){let e=t.searchParams.get("t"),n=e?Number(e):NaN;return Number.isNaN(n)?NaN:n}var Z1=t=>t.hostname==="www.coursera.org"?"coursera":null,J1=t=>{let e=zn(t);e.search="";let n=new URL(t);return{cleaned:e,source:ki(n)}};var eC=require("obsidian");var tC=t=>({type:"generic",cleaned:zn(t),source:ki(t.protocol==="file:"?aF(t):t)});function aF(t){let e=new URL(eC.Platform.resourcePathPrefix+t.href.substring(8));return e.search=Date.now().toString(),e}var nC=t=>t.hostname!=="vimeo.com"||!t.pathname.substring(1).match(/^\d+$/)?null:"vimeo",iC=t=>{let e=t.pathname.substring(1);if(!e.match(/^\d+$/))throw new Error("Invalid vimeo url");let n=zn(t);n.search="";let i=new URL(t);return{cleaned:n,source:ki(i),id:e}};function sC(t){let e=t.pathname.split("/");if(t.hostname==="youtu.be"&&e.length===2)return e[1];if(t.hostname==="www.youtube.com"||t.hostname==="youtube.com"){if(e.length===2&&e[1]==="watch")return t.searchParams.get("v");let n=["shorts","embed","v"];if(e.length===3&&n.includes(e[1]))return e[2]}return null}var aC=t=>sC(t)?"youtube":null,oC=t=>{let e=Cr(t.hash),n=Xw(t.searchParams.get("t")),i=Xw(t.searchParams.get("start")),r=Xw(t.searchParams.get("end")),s=sC(t);if(!s)throw new Error("Invalid youtube url");let a=zn("https://www.youtube.com/watch");a.search=new URLSearchParams({v:s}).toString();let o=new URL(a);if(t.searchParams.has("list")&&o.searchParams.set("list",t.searchParams.get("list")),e||(i>0&&r>0?e=K1(i,r):i>0?e={start:i,end:1/0}:r>0?e={start:0,end:r}:n>0&&(e={start:n,end:-1})),e){let l=rC(e.start),c=rC(e.end);kn(e)||e.start>0&&e.end>0&&l===c?o.searchParams.set("t",l):(e.start>0&&o.searchParams.set("start",l),e.end>0&&o.searchParams.set("end",c))}return{source:ki(o),cleaned:a,id:s}};function rC(t){return t.toFixed(0)}function Xw(t){if(!t)return NaN;let e=Number(t);if(!Number.isNaN(e))return e;let n=/^(?:(?\d+)h)?(?:(?\d+)m)?(?:(?\d+)s)?$/,i=t.match(n);if(!i)return NaN;let{h:r,m:s,s:a}=i.groups,o=r?Number(r):0,l=s?Number(s):0,c=a?Number(a):0;return o*3600+l*60+c}var oF=new Set(["https:","http:","file:"]),Ns,uu=class uu extends URL{constructor(n,i){super(n);O(this,Ns,void 0);w(this,"type");w(this,"mxUrl");if(this.mxUrl=i?new URL(i):null,!oF.has(this.protocol))throw new Error("Unsupported protocol: "+this.protocol);this.type=lF.reduce((r,s)=>r??s(this),null)??"generic",we(this,Ns,cF[this.type](this))}static create(n,i){if(n instanceof uu)return n.clone();try{return new uu(n,i)}catch{return null}}get inferredType(){let n=this.pathname.split(".").pop();return n?Xt(n):null}get isFileUrl(){return this.protocol==="file:"}get filePath(){if(this.isFileUrl)try{return(0,lC.fileURLToPath)(this)}catch(n){return console.error("Failed to convert file url to path",n,this.href),null}return null}getVaultFile(n){if(!(n.adapter instanceof so.FileSystemAdapter))return!1;let i=this.filePath,r=n.adapter.getBasePath();if(!i)return!1;let s=xi.relative(r,i);if(!s||s.startsWith(".."))return!1;let a=(0,so.normalizePath)(s);return n.getAbstractFileByPath(a)}compare(n){return!!n&&this.jsonState.source===n.jsonState.source}get tempFrag(){return Cr(this.hash)}setTempFrag(n){let i=this.clone(),r=kf(this.hash);return n?i.hash=W1(r,n):i.hash=r,i}clone(){return new uu(this,this.mxUrl??void 0)}get source(){return k(this,Ns).source}get cleaned(){return k(this,Ns).cleaned}get id(){return k(this,Ns).id}get jsonState(){return{source:qo(this.mxUrl??this.cleaned)}}};Ns=new WeakMap;var _t=uu,lF=[Q1,aC,nC,Z1],cF={bilibili:X1,youtube:oC,vimeo:iC,coursera:J1,generic:tC};function cC(t,{getUrlMapping:e}){if(!t)return null;if(t.protocol!=="mx:")return _t.create(t);let[,,n]=t.pathname.split("/"),i=e(n);return i?_t.create(t.href.replace(`mx://${n}/`,i.replace(/\/*$/,"/")),t):null}function uC(t,e){if(Xt(t.extension)===null)throw new Error(`Unknown media type ${t.extension}`);let n=e.getResourcePath(t);return new _t("file:///"+n.substring(so.Platform.resourcePathPrefix.length))}function dC(t){return`webpage::${btoa(t)}`}function pC(t){return atob(t.replace(/^webpage::/,""))}function hC(t){return t.startsWith("webpage::")}function fC(t){return t.type==="TimeRanges"}var Ef=class{constructor(e){this.ranges=e}get length(){return this.ranges.length}start(e){return this.ranges[e][0]}end(e){return this.ranges[e][1]}};function ei(t){return fC(t)?new Ef(t.value):t}var{onDispose:Zw,peek:uF}=ys,Tf=class{constructor(e,n){this._provider=e;this._ctx=n;w(this,"_disposal",O1());w(this,"_waiting",!1);w(this,"_attachedLoadStart",!1);w(this,"_attachedCanPlay",!1);w(this,"_handlers");w(this,"_handleDevEvent");this._attachInitialListeners(),Zw(this._media.on("timeupdate",this._onTimeUpdate.bind(this))),Zw(this._onDispose.bind(this))}get _webview(){return this._provider.webview}get _media(){return this._provider.media}get _notify(){return this._ctx.delegate._notify}_onDispose(){this._attachedLoadStart=!1,this._attachedCanPlay=!1,this._disposal.empty()}_attachInitialListeners(){this._attachEventListener("loadstart",this._onLoadStart),this._attachEventListener("abort",this._onAbort),this._attachEventListener("emptied",this._onEmptied),this._attachEventListener("error",this._onError),this._attachEventListener("volumechange",this._onVolumeChange)}_attachLoadStartListeners(){this._attachedLoadStart||(this._disposal.add(this._attachEventListener("loadeddata",this._onLoadedData),this._attachEventListener("loadedmetadata",this._onLoadedMetadata),this._attachEventListener("canplay",this._onCanPlay),this._attachEventListener("canplaythrough",this._onCanPlayThrough),this._attachEventListener("durationchange",this._onDurationChange),this._attachEventListener("play",this._onPlay),this._attachEventListener("progress",this._onProgress),this._attachEventListener("stalled",this._onStalled),this._attachEventListener("suspend",this._onSuspend)),this._attachedLoadStart=!0)}_attachCanPlayListeners(){this._attachedCanPlay||(this._disposal.add(this._attachEventListener("pause",this._onPause),this._attachEventListener("playing",this._onPlaying),this._attachEventListener("ratechange",this._onRateChange),this._attachEventListener("seeked",this._onSeeked),this._attachEventListener("seeking",this._onSeeking),this._attachEventListener("ended",this._onEnded),this._attachEventListener("waiting",this._onWaiting)),this._attachedCanPlay=!0)}_attachEventListener(e,n){let i=n.bind(this),r=this._media.on(e,i);return Zw(r)}_onDevEvent(e){}_updateCurrentTime(e,n,i){let r={currentTime:Math.min(e,this._ctx.$state.seekableEnd()),played:n};this._notify("time-update",r,i&&new Event(i.type))}_onLoadStart(e){if(e.payload.networkState===3){this._onAbort(e);return}this._attachLoadStartListeners(),this._notify("load-start",void 0,new Event(e.type))}_onAbort(e){this._notify("abort",void 0,new Event(e.type))}_onEmptied({type:e}){this._notify("emptied",void 0,new Event(e))}_onLoadedData(e){this._notify("loaded-data",void 0,new Event(e.type))}_onLoadedMetadata(e){this._attachCanPlayListeners(),this._notify("loaded-metadata",void 0,new Event(e.type))}_getCanPlayDetail({duration:e,buffered:n,seekable:i}){return{provider:uF(this._ctx.$provider),duration:e,buffered:n,seekable:i}}_onPlay(e){this._ctx.$state.canPlay&&this._notify("play",void 0,new Event(e.type))}_onPause({type:e,payload:n}){n.readyState===1&&!this._waiting||(this._waiting=!1,this._notify("pause",void 0,new Event(e)))}_onCanPlay({type:e,payload:n}){let i=ei(n.buffered),r=ei(n.seekable);this._ctx.delegate._ready(this._getCanPlayDetail({duration:n.duration,buffered:i,seekable:r}),new Event(e))}_onCanPlayThrough({type:e,payload:n}){if(this._ctx.$state.started())return;let i=ei(n.buffered),r=ei(n.seekable);this._notify("can-play-through",this._getCanPlayDetail({duration:n.duration,buffered:i,seekable:r}),new Event(e))}_onPlaying({type:e}){this._waiting=!1,this._notify("playing",void 0,new Event(e))}_onStalled({type:e,payload:n}){this._notify("stalled",void 0,new Event(e)),n.readyState<3&&(this._waiting=!0,this._notify("waiting",void 0,new Event(e)))}_onWaiting({type:e,payload:n}){n.readyState<3&&(this._waiting=!0,this._notify("waiting",void 0,new Event(e)))}_onEnded(e){let{payload:n}=e,i=ei(n.played);this._updateCurrentTime(n.duration,i,e),this._notify("end",void 0,new Event(e.type))}_onTimeUpdate(e){let{payload:n}=e,i=ei(n.played);this._updateCurrentTime(n.current,i,e)}_onDurationChange(e){let{payload:n}=e,i=ei(n.played);this._ctx.$state.ended()&&this._updateCurrentTime(n.duration,i,e),this._notify("duration-change",n.duration,new Event(e.type))}_onVolumeChange({type:e,payload:n}){let i={volume:n.volume,muted:n.muted};this._notify("volume-change",i,new Event(e))}_onSeeked(e){let{payload:n}=e,i=ei(n.played);this._updateCurrentTime(n.current,i,e),this._notify("seeked",n.current,new Event(e.type))}_onSeeking({type:e,payload:n}){this._notify("seeking",n.current,new Event(e))}_onProgress({type:e,payload:n}){let i={buffered:ei(n.buffered),seekable:ei(n.seekable)};this._notify("progress",i,new Event(e))}_onSuspend({type:e}){this._notify("suspend",void 0,new Event(e))}_onRateChange({type:e,payload:n}){this._notify("rate-change",n.rate,new Event(e))}_onError({type:e,payload:n}){let i={message:n.message,code:n.code};this._notify("error",i,new ErrorEvent(e,{error:n}))}};async function mC(t,e){return await e.executeJavaScript(`(async function(){${t}})()`)}var{onDispose:gC}=ys,du,Sf=class{constructor(e,n,i){this._video=e;this._media=n;this.userGesture=i;O(this,du,!1);w(this,"_onChange",(e,n)=>{this._media.delegate._notify("picture-in-picture-change",e,n)});gC(e.on("enterpictureinpicture",r=>this._onChange(!0,new Event(r.type)))),gC(e.on("leavepictureinpicture",r=>this._onChange(!1,new Event(r.type))))}async updateActive(){let e=await this._video.methods.pictureInPictureEnabled();return we(this,du,e),e}get active(){return this.updateActive(),k(this,du)}get supported(){return!!document.pictureInPictureEnabled}async enter(){await this.userGesture(),await this._video.methods.requestPictureInPicture()}async exit(){await this._video.methods.exitPictureInPicture()}};du=new WeakMap;var{createScope:dF,onDispose:Jw,scoped:pF}=ys,ao,Rn=class{constructor(e,n){this._webview=e;this._ctx=n;w(this,"scope",dF());w(this,"$$PROVIDER_TYPE","WEBVIEW");w(this,"_currentSrc",null);w(this,"_port",new Tp);w(this,"pictureInPicture");O(this,ao,null);w(this,"onDomReady",async e=>{let n=this._webview;this.handlePlayReady(),new Tf(this,this._ctx),this._updateTitle(e),await mC(b1,n),await this.loadPlugin(this.currentWebHost)});pF(()=>{this.pictureInPicture=new Sf(this._port,n,()=>this.userGesture(!0))},this.scope)}setup(){Jw(()=>{this._webview.src=""}),hF(),this.type==="webview"&&this._ctx.delegate._notify("provider-setup",this),this.registerTitleChange(),Jw(()=>{this._webview.removeEventListener("dom-ready",this.onDomReady)})}get type(){return"webview"}get webview(){return this._webview}get media(){return this._port}get currentSrc(){return this._currentSrc}get currentWebHost(){return this._currentSrc?.host??"generic"}setPlaybackRate(e){this._port.methods.setPlaybackRate(e)}async userGesture(e=!1){if(!e&&k(this,ao)){await k(this,ao);return}await we(this,ao,this.webview.executeJavaScript("1",!0))}async play(){this.webview.isConnected&&(await this.userGesture(),await this._port.methods.play())}async pause(){this.webview.isConnected&&(await this.userGesture(),await this._port.methods.pause())}setMuted(e){this._port.methods.setMuted(e)}setVolume(e){this._port.methods.setVolume(e)}setCurrentTime(e){this._port.methods.setCurrentTime(e)}get _notify(){return this._ctx.delegate._notify}async _updateTitle(e,n){let i=e=typeof e=="string"?new Event(e):e,r=n??this._webview.getTitle(),s=j1[this.currentWebHost](r),a=this._ctx.$state.title();s!==a&&this._notify("title-change",s,i)}loadPlugin(e){return new Promise((n,i)=>{let r=this._webview,s=this.media.onReady(async()=>{window.clearTimeout(a),await this.media.methods.loadPlugin(U1[e]),n()},{once:!0}),a=setTimeout(()=>{s(),i(new Ui(5e3))},5e3),{port1:o,port2:l}=new MessageChannel;this._port.load(o),r.contentWindow.postMessage(kx,"*",[l])})}handlePlayReady(){let e=new Promise((a,o)=>{let l=()=>{this.webview.removeEventListener("did-stop-loading",c),this.webview.removeEventListener("did-finish-load",c),this.webview.removeEventListener("did-fail-load",u)},c=()=>{a(),l()},u=d=>{o(new Pf(d)),l()};this.webview.addEventListener("did-stop-loading",c),this.webview.addEventListener("did-finish-load",c),this.webview.addEventListener("did-fail-load",u)}),n,i=a=>new Promise((o,l)=>{n=window.setTimeout(()=>l(new Ui(a)),a)}),r=new Promise(a=>{this._port.once("mx-play-ready",()=>{a(),window.clearTimeout(n)})}),s=1e4;e.then(()=>Promise.race([r,i(s)])).then(()=>{this.togglePlayReady(!0)}).catch(a=>{if(a instanceof Ui)fF(s);else if(a instanceof Pf)new Ds.Notice("Webview failed to load website: "+a.message);else throw a}).finally(()=>{this.togglePlayReady(!0)})}registerTitleChange(){let e=this._webview,n=i=>{this._updateTitle(i,i.title)};e.addEventListener("page-title-updated",n),Jw(()=>{e.removeEventListener("page-title-updated",n)})}togglePlayReady(e){typeof e>"u"&&(e=!("playReady"in this._webview.dataset)),e?this._webview.dataset.playReady="":delete this._webview.dataset.playReady}untilPluginReady(){let e=this._webview;return this.togglePlayReady(!1),e.removeEventListener("dom-ready",this.onDomReady),new Promise((n,i)=>{let r=s=>{this.onDomReady(s).then(n).catch(i),e.removeEventListener("dom-ready",r),e.addEventListener("dom-ready",this.onDomReady)};e.addEventListener("dom-ready",r)})}async loadSource({src:e,type:n}){if(!lu(e))throw new Error("Webview provider only supports string src.");let i=_t.create(pC(e)),r=this._webview;if(this._currentSrc={src:i?.source.href??"",type:n,host:i?.type??"generic"},!i){r.src="";return}let s=!r.src||qo(i.source)!==qo(r.src);r.src=i.href,s&&await this.untilPluginReady()}};ao=new WeakMap;var Pf=class extends Error{constructor(e){super(`${e.errorCode}: ${e.errorDescription}`)}};function hF(){let t="mx:webview-login-notified";localStorage.getItem(t)||(new Ds.Notice(createFragment(n=>{n.appendText("You're using a webpage media player."),n.createEl("p",{text:"If you are requested to login, you can open a browser to login from:"},i=>{i.createEl("br"),i.appendText('- the "Login" command'),i.createEl("br"),i.appendText("- the entry in settings tab")}),n.appendText("Click to dismiss this notice.")}),0),localStorage.setItem(t,"1"))}function fF(t){let e="mx:webview-timeout-ignore";if(localStorage.getItem(e))return;let i=(t/1e3).toFixed(1),r=new Ds.Notice(createFragment(s=>{s.createDiv({text:`Webpage not fully loaded within ${i}s. You can still try to play.`}),s.createDiv({},a=>{a.style.display="flex",a.style.justifyContent="flex-end",a.style.gap="1em",a.style.marginTop="1em",new Ds.ButtonComponent(a).setButtonText("OK"),new Ds.ButtonComponent(a).setButtonText("Don't show again").onClick(()=>{console.log("ignore webview timeout notice"),localStorage.setItem(e,"1"),r.hide()})})}),5e3)}var Lf=require("fs/promises"),hu=require("obsidian");function Cf(t,e){let n=new Map;for(let i of t){let r=e(i),s=n.get(r);s?s.push(i):n.set(r,[i])}return n}var Rf=$(eb());var tb={"de-AT":"\xD6sterreichisches Deutsch","de-CH":"Schweizer Hochdeutsch","en-AU":"Australian English","en-CA":"Canadian English","en-GB":"British English","en-US":"American English","es-ES":"espa\xF1ol de Espa\xF1a","es-MX":"espa\xF1ol de M\xE9xico","fr-CA":"fran\xE7ais canadien","fr-CH":"fran\xE7ais suisse","nl-BE":"Vlaams","pt-BR":"portugu\xEAs do Brasil","pt-PT":"portugu\xEAs europeu","ro-MD":"moldoveneasc\u0103","zh-Hans":"\u7B80\u4F53\u4E2D\u6587","zh-Hant":"\u7E41\u9AD4\u4E2D\u6587"},SC=()=>Cf(Object.entries(tb),([t])=>t.split("-")[0]),TC={"zh-Hans":["CN","SG","MY"],"zh-Hant":["TW","HK","MO"]};function PC(t){let e=t.split("-"),n=e[0].toLowerCase();if(e.length===1)return Rf.default.getNativeName(n);let i=e.slice(0,2).join("-");return tb[i]||`${Rf.default.getNativeName(e[0])} (${t})`}function gF(t){return t.toLowerCase()==="hans"||TC["zh-Hans"].includes(t.toUpperCase())?"zh-Hans":t.toLowerCase()==="hant"||TC["zh-Hant"].includes(t.toUpperCase())?"zh-Hant":"zh"}function nb(t){if(!t)return!1;let e=t.split("-")[0].toLowerCase();return Rf.default.validate(e)}function CC(t){if(!nb(t))return null;let e=t.split("-"),n=e[0].toLowerCase();if(e.length===1)return n;let i=e[1];return n==="zh"?gF(i):tb[`${n}-${i.toUpperCase()}`]??`${n}-${e.slice(1).join("-")}`}var $C=["vtt","ass","ssa","srt"];function vF(t){return $C.includes(t.extension)}function MC(t,e,n){console.debug("Search subtitles for media",{basename:t.basename,path:t.path,defaultLangCode:n}),console.debug(`${e.length} siblings`,e);let i=e.filter(vF).flatMap(l=>{let c=yF(l,t.basename);return c?[c]:[]});if(i.length===0)return console.debug("No subtitles found"),i;console.debug(`Found ${i.length} subtitles: `,i.map(l=>l.src.path)),console.debug("Subtitles details: ",i);let r=Cf(i,l=>l.language),s=[...r.keys()],a=n?s.find(l=>{if(l)return l===n})??s.find(l=>{if(!l)return;let c=l.split("-")[0],u=n.split("-")[0];return c===u}):s.filter(l=>!!l)[0],o=[];return r.forEach((l,c)=>{for(let u of $C){let d=l.find(p=>p.type===u);if(d){o.push({...d,default:!!a&&c===a});return}}}),console.debug(`Final tracks: ${o.length}`,o.map(l=>l.src.path)),console.debug("Final tracks details",o),o.length===0||(console.debug(`Final default lang: ${a??o[0].id}`),a||(o[0].default=!0)),o}async function If(t,e){let n=t.filePath;if(!n||!t.inferredType)return[];let i=xi.basename(n),r=i.split(".").slice(0,-1).join("."),s=xi.dirname(n),a=(await(0,Lf.readdir)(s,{encoding:"utf-8",withFileTypes:!0}).catch(l=>{let c=l;return c.code!=="ENOENT"&&new hu.Notice(`Failed to read directory ${s}: ${c.message}`),[]})).filter(l=>l.name!==i&&(l.isFile()||l.isSymbolicLink())).map(l=>{let c=l.name.split(".");return c.length===1?{extension:"",basename:l.name,path:xi.join(s,l.name)}:{extension:c.at(-1),basename:c.slice(0,-1).join("."),path:xi.join(s,l.name)}}),o=MC({basename:r,path:n},a,e);return(await Promise.all(o.map(async({src:l,...c})=>{let u=await(0,Lf.readFile)(l.path,"utf-8").catch(d=>{let p=d;return p.code!=="ENOENT"&&new hu.Notice(`Failed to read subtitle file ${l.path}: ${p.message}`),""});return u?{...c,content:u}:null}))).filter(l=>!!l)}async function RC(t,e,n){if(!t.parent)return[];let i=MC(t,t.parent.children.filter(r=>r instanceof hu.TFile),n);return await Promise.all(i.map(async({src:r,...s})=>({...s,content:await e.cachedRead(r)})))}function yF(t,e){if(!t.basename.startsWith(e))return null;let n=t.basename.substring(e.length),i;if(!n)i=null;else if(i=CC(n.replace(/^\./,"")),!i)return null;let r=i?PC(i):"Unknown";return{kind:"subtitles",language:i??void 0,id:`${t.basename}.${t.extension}.${i??"unknown"}`,src:t,type:t.extension,label:`${r} (${t.extension})`,default:!1}}function Af(){return/[<>:"/\\|?*\u0000-\u001F]/g}function LC(){return/^(con|prn|aux|nul|com\d|lpt\d)$/i}var _F=100,wF=/^\.+(\\|\/)|^\.+$/,bF=/\.+$/;function ib(t,e={}){let n=/[\u0000-\u001F\u0080-\u009F]/g,i=/([<>:"/\\|?*\u0000-\u001F]){2,}/g;if(typeof t!="string")throw new TypeError("Expected a string");let r=e.replacement===void 0?"!":e.replacement;if(Af().test(r)&&n.test(r))throw new Error("Replacement string cannot contain reserved filename characters");r.length>0&&(t=t.replace(i,"$1")),t=t.normalize("NFD"),t=t.replace(wF,r),t=t.replace(Af(),r),t=t.replace(n,r),t=t.replace(bF,""),r.length>0&&(!(t[0]===".")&&t[0]==="."&&(t=r+t),t[t.length-1]==="."&&(t+=r)),t=LC().test(t)?t+r:t;let s=typeof e.maxLength=="number"?e.maxLength:_F;if(t.length>s){let a=t.lastIndexOf(".");if(a===-1)t=t.slice(0,s);else{let o=t.slice(0,a),l=t.slice(a);t=o.slice(0,Math.max(1,s-l.length))+l}}return t}var IC={"application/prs.cww":["cww"],"application/prs.xsf+xml":["xsf"],"application/vnd.1000minds.decision-model+xml":["1km"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["*xfdf"],"application/vnd.age":["age"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.keynote":["key"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.apple.numbers":["numbers"],"application/vnd.apple.pages":["pages"],"application/vnd.apple.pkpass":["pkpass"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.balsamiq.bmml+xml":["bmml"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.citationstyles.style+xml":["csl"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dbf":["dbf"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["*fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-apps.document":["gdoc"],"application/vnd.google-apps.presentation":["gslides"],"application/vnd.google-apps.spreadsheet":["gsheet"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.hydrostatix.sof-data":["sfd-hdstx"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mapbox-vector-tile":["mvt"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-outlook":["msg"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["*stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["*mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.ac+xml":["*ac"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.n-gage.symbian.install":["n-gage"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openblox.game+xml":["obgx"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openstreetmap.data+xml":["osm"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.pwg-xhtml-print+xml":["xhtm"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.rar":["rar"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.software602.filler.form+xml":["fo"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.wadl+xml":["wadl"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.syncml.dmddf+xml":["ddf"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml","uo"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["*dmg"],"application/x-arj":["arj"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bdoc":["*bdoc"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-cocoa":["cco"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["*deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-httpd-php":["php"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["*iso"],"application/x-iwork-keynote-sffkey":["*key"],"application/x-iwork-numbers-sffnumbers":["*numbers"],"application/x-iwork-pages-sffpages":["*pages"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-keepass2":["kdbx"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-makeself":["run"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["*prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdos-program":["*exe"],"application/x-msdownload":["*exe","*dll","com","bat","*msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["*wmf","*wmz","*emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-ns-proxy-autoconfig":["pac"],"application/x-nzb":["nzb"],"application/x-perl":["pl","pm"],"application/x-pilot":["*prc","*pdb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["*rar"],"application/x-redhat-package-manager":["rpm"],"application/x-research-info-systems":["ris"],"application/x-sea":["sea"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["*sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl","tk"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["*obj"],"application/x-ustar":["ustar"],"application/x-virtualbox-hdd":["hdd"],"application/x-virtualbox-ova":["ova"],"application/x-virtualbox-ovf":["ovf"],"application/x-virtualbox-vbox":["vbox"],"application/x-virtualbox-vbox-extpack":["vbox-extpack"],"application/x-virtualbox-vdi":["vdi"],"application/x-virtualbox-vhd":["vhd"],"application/x-virtualbox-vmdk":["vmdk"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt","pem"],"application/x-xfig":["fig"],"application/x-xliff+xml":["*xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/x-aac":["*aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-m4a":["*m4a"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-realaudio":["*ra"],"audio/x-wav":["*wav"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/prs.btif":["btif","btf"],"image/prs.pti":["pti"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.airzip.accelerator.azv":["azv"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["*sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.microsoft.icon":["ico"],"image/vnd.ms-dds":["dds"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.pco.b16":["b16"],"image/vnd.tencent.tap":["tap"],"image/vnd.valve.source.texture":["vtf"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/vnd.zbrush.pcx":["pcx"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["*ico"],"image/x-jng":["jng"],"image/x-mrsid-image":["sid"],"image/x-ms-bmp":["*bmp"],"image/x-pcx":["*pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/vnd.wfa.wsc":["wsc"],"model/vnd.cld":["cld"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.opengex":["ogex"],"model/vnd.parasolid.transmit.binary":["x_b"],"model/vnd.parasolid.transmit.text":["x_t"],"model/vnd.pytha.pyox":["pyo","pyox"],"model/vnd.sap.vds":["vds"],"model/vnd.usda":["usda"],"model/vnd.usdz+zip":["usdz"],"model/vnd.valve.source.compiled-map":["bsp"],"model/vnd.vtu":["vtu"],"text/prs.lines.tag":["dsc"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.familysearch.gedcom":["ged"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-org":["*org"],"text/x-pascal":["p","pas"],"text/x-processing":["pde"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-suse-ymp":["ymp"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]};Object.freeze(IC);var AC=IC;var NC={"application/andrew-inset":["ez"],"application/appinstaller":["appinstaller"],"application/applixware":["aw"],"application/appx":["appx"],"application/appxbundle":["appxbundle"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/automationml-aml+xml":["aml"],"application/automationml-amlx+zip":["amlx"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cpl+xml":["cpl"],"application/cu-seeme":["cu"],"application/cwl":["cwl"],"application/dash+xml":["mpd"],"application/dash-patch+xml":["mpp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdf":["fdf"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["*js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/media-policy-dataset+xml":["mpf"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["*mp4","*mpg4","mp4s","m4p"],"application/msix":["msix"],"application/msixbundle":["msixbundle"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-keys":["asc"],"application/pgp-signature":["sig","*asc"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/sql":["sql"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/watcherinfo+xml":["wif"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xfdf":["xfdf"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/aac":["adts","aac"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avci":["avci"],"image/avcs":["avcs"],"image/avif":["avif"],"image/bmp":["bmp","dib"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/dpx":["dpx"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm","jpgm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/jt":["jt"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/prc":["prc"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/u3d":["u3d"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/javascript":["js","mjs"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["md","markdown"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/wgsl":["wgsl"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","*jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};Object.freeze(NC);var DC=NC;var Ln=function(t,e,n,i){if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?i:n==="a"?i.call(t):i?i.value:e.get(t)},oo,fu,Os,rb=class{constructor(...e){oo.set(this,new Map),fu.set(this,new Map),Os.set(this,new Map);for(let n of e)this.define(n)}define(e,n=!1){for(let[i,r]of Object.entries(e)){i=i.toLowerCase(),r=r.map(o=>o.toLowerCase()),Ln(this,Os,"f").has(i)||Ln(this,Os,"f").set(i,new Set);let s=Ln(this,Os,"f").get(i),a=!0;for(let o of r){let l=o.startsWith("*");if(o=l?o.slice(1):o,s?.add(o),a&&Ln(this,fu,"f").set(i,o),a=!1,l)continue;let c=Ln(this,oo,"f").get(o);if(c&&c!=i&&!n)throw new Error(`"${i} -> ${o}" conflicts with "${c} -> ${o}". Pass \`force=true\` to override this definition.`);Ln(this,oo,"f").set(o,i)}}return this}getType(e){if(typeof e!="string")return null;let n=e.replace(/^.*[/\\]/,"").toLowerCase(),i=n.replace(/^.*\./,"").toLowerCase(),r=n.length{throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances")},Object.freeze(this);for(let e of Ln(this,Os,"f").values())Object.freeze(e);return this}_getTestState(){return{types:Ln(this,oo,"f"),extensions:Ln(this,fu,"f")}}};oo=new WeakMap,fu=new WeakMap,Os=new WeakMap;var sb=rb;var ab=new sb(DC,AC)._freeze();var Vs=require("obsidian");var mu=require("obsidian");async function OC(t,e,n){let i=document.createElement("canvas"),{videoWidth:r,videoHeight:s}=t;Object.assign(i,{width:r,height:s});let a=i.getContext("2d",{alpha:!1});if(!a)throw new Error("Canvas context creation failed");a.drawImage(t,0,0,r,s);let o=await new Promise((c,u)=>{try{i.toBlob(d=>{d?c(d):u(new Error("Canvas to blob failed"))},e,n)}catch(d){u(d)}}),l=await o.arrayBuffer();return{time:t.currentTime,blob:{arrayBuffer:l,type:o.type}}}function gu(t){return to(t)||t instanceof Rn}async function Nf(t,e,n){let i=mu.Platform.isSafari&&e==="image/webp"?"image/jpeg":e;try{if(to(t))return await OC(t.video,i,n);if(t instanceof Rn)return await t.media.methods.screenshot(i,n);throw new Error("Unsupported provider for screenshot")}catch(r){throw r instanceof DOMException&&r.name==="SecurityError"?new mu.Notice("Cannot take screenshot due to CORS restriction, you can try open media as webpage to bypass this"):new mu.Notice("Cannot take screenshot: "+(r instanceof Error?r.message:String(r))),r}}var VC=require("obsidian");function Df({timestamp:t,screenshot:e},{template:n,editor:i,insertBefore:r}){console.debug("insert timestamp",{timestamp:t,screenshot:e,template:n});let s=n.replace("{{TIMESTAMP}}",t);e&&(s=s.replace("{{SCREENSHOT}}",e)),console.debug("content to insert",s);try{console.debug(`inserting timestamp ${r?"before":"after"} cursor`),r?kF(s,i):xF(s,i)}catch(a){new VC.Notice("Failed to insert timestamp, see console for details"),console.error("Failed to insert timestamp",a)}}function xF(t,e){let n=e.getCursor("to");console.debug("insert to cursor [to]",n.ch,n.line),e.replaceRange(t,n,n),e.setCursor(e.offsetToPos(e.posToOffset(n)+t.length))}function kF(t,e){let n=e.getCursor("from");console.debug("insert before cursor [from]",n.ch,n.line),e.replaceRange(t,n,n)}function FC(t){return t.file.basename}function zC({source:t},e){return e.title??t.hostname+decodeURI(t.pathname).replaceAll("/","_")}function UC(t,e){return $i(t)?FC(t):zC(t,e)}function vu(t,e){let{metadataCache:n}=e.plugin.app,i=e.store.getState().player;if(!i)throw new Error("Player not initialized");if($i(t)){let{file:r,type:s}=t;return e.plugin.leafOpener.openNote(t,{title:FC(t),fm:a=>({[s]:`[[${n.fileToLinktext(r,a)}]]`}),sourcePath:r.path})}else return e.plugin.leafOpener.openNote(t,{title:zC(t,i.state),fm:()=>({media:t.jsonState.source})})}function Of(t,e,n){let{fileManager:i}=n.plugin.app,{timestampOffset:r}=n.plugin.settings.getState(),s=n.store.getState().player?.state.duration;t+=r,t<0&&(t=0),s&&t>s&&(t=s);let a=xf(t),o=t>0?`#${Qw({start:t,end:-1})}`:"";if($i(e)){let{file:l}=e;return c=>i.generateMarkdownLink(l,c,o,a).replace(/^!/,"")}else{let l=e.jsonState.source;return()=>`[${a}](${l}${o})`}}async function Vf(t,{file:e,editor:n}){let{fileManager:i,vault:r}=t.plugin.app,s=t.store.getState().player;if(!s){new Vs.Notice("Player not initialized");return}let a=t.getMediaInfo();if(!a){new Vs.Notice("No media is opened");return}if(!s?.provider||!gu(s.provider)){new Vs.Notice("Screenshot is not supported for this media");return}let{screenshotQuality:o,screenshotFormat:l}=t.plugin.settings.getState(),{blob:c,time:u}=await Nf(s.provider,l,o),d=Of(u,a,t),p=ab.getExtension(c.type);if(!p){new Vs.Notice("Unknown mime type: "+c.type);return}let h=UC(a,s.state),y=ib(h,{replacement:"_"})+B1(u),v=u>0?` - ${xf(u)}`:"",_=await r.getAvailablePathForAttachments(y,p,e),m=await r.createBinary(_,c.arrayBuffer);new Vs.Notice("Screenshot saved to "+m.path);let{insertBefore:f,screenshotTemplate:g,screenshotEmbedTemplate:x}=t.plugin.settings.getState();try{Df({timestamp:d(e.path),screenshot:i.generateMarkdownLink(m,e.path,"",x.replaceAll("{{TITLE}}",h).replaceAll("{{DURATION}}",v)).replace(/^!/,"")},{editor:n,template:g,insertBefore:f})}catch(T){new Vs.Notice("Failed to insert screenshot, see console for details"),console.error("Failed to insert screenshot",T)}}var yu=require("obsidian");async function Ff(t,{file:e,editor:n}){let i=t.store.getState().player;if(!i){new yu.Notice("Player not initialized");return}let r=t.getMediaInfo();if(!r){new yu.Notice("No media is opened");return}let s=i.currentTime,a=Of(s,r,t);if(s<=0){new yu.Notice("Playback not started yet");return}let{insertBefore:o,timestampTemplate:l}=t.plugin.settings.getState();try{Df({timestamp:a(e.path)},{editor:n,template:l,insertBefore:o})}catch(c){new yu.Notice("Failed to insert timestamp, see console for details"),console.error("Failed to insert timestamp",c)}}var jC=require("obsidian");function lo(t){let e="mx:media-notetaking-notified";localStorage.getItem(e)||(new jC.Notice(createFragment(i=>{i.appendText(`You are taking ${t} from media player. By default, they will only be saved in the media note. `),i.createEl("p",{text:`To take ${t} or control playback from abritrary note, use command when focused on the note`}),i.createEl("p",{text:"PS: you can assign a hotkey to each command in the settings"}),i.appendText("Click to dismiss this notice.")}),0),localStorage.setItem(e,"1"))}function zf(t){let e=Un(t);if(!e)return"";let{pathname:n}=e;if(!n)return"";let i=n.split("/").pop();return i?decodeURI(i.split(".").slice(0,-1).join(".")):""}function Uf(t){t.addAction("star","Timestamp",()=>{let e=t.getMediaInfo();e&&(lo("timestamp"),vu(e,t).then(n=>{Ff(t,n)}))}),t.getViewType()!==Mi&&t.addAction("camera","Screenshot",()=>{let e=t.getMediaInfo();e&&(lo("screenshot"),vu(e,t).then(n=>Vf(t,n)))})}function jf(t,e,n){let{player:i,source:r,toggleControls:s,controls:a,setTransform:o,transform:l,toggleWebFullscreen:c,disableWebFullscreen:u}=t.store.getState();!i||!r||t.plugin.app.workspace.trigger("mx-media-menu",e,{source:r.url,player:i,toggleControls:s,controls:a,setTransform:o,transform:l,plugin:t.plugin,disableWebFullscreen:u,toggleWebFullscreen:c,reload:()=>t.render()},n,t.leaf)}var ob=new WeakSet;function qC(t){t.subscribe((e,n)=>{e.player!==n.player&&_u(e)}),t.subscribe((e,n)=>{let i=e.player;if(!i)return;let r=e.source,s=n.source;if(r===s)return;let a=r?.url,o=s?.url;a!==o&&(!a&&o!==void 0||a!==void 0&&!a.compare(o))&&ob.delete(i)})}async function _u({player:t,hash:{tempFragment:e}}){if(!t||!e)return;let n=!ob.has(t);ob.add(t);let i=null,r=.25;if(kn(e)||t.currentTimee.end&&(i=e.end),i!==null){let s=i;t.currentTime=s,!t.state.canPlay&&["video/youtube"].includes(t.state.source.type)&&!t.state.autoPlay&&(await EF(t,"seeked"),await t.pause())}kn(e)&&t.state.canPlay&&!n&&await t.play(new Event("hashchange"))}function EF(t,e){return new Promise(n=>{let i=window.setTimeout(()=>{n(),r()},5e3),r=t.listen(e,()=>{n(),window.clearTimeout(i),r()})})}function Fr(){let t=_p((e,n,i)=>({player:null,playerRef:r=>e({player:r}),source:void 0,hash:{autoplay:void 0,controls:void 0,loop:void 0,muted:void 0,tempFragment:null,volume:void 0},async getPlayer(r=1e4){let{player:s}=n();return s||new Promise((a,o)=>{let l=i.subscribe(({player:u})=>{u&&(l(),a(u),window.clearTimeout(c))}),c=window.setTimeout(()=>{l(),o(new Ui(r))},r)})},setSource(r,{hash:s,enableWebview:a,title:o,type:l,textTracks:c}={}){e(u=>({source:{...u.source,type:l??u.source?.type,url:r,enableWebview:a??u.source?.enableWebview},textTracks:c??u.textTracks,hash:{...u.hash,...xp(s||r.hash)},title:(o===!0?zf(r.source.href):o)??u.title})),_u(n())},setHash(r){e(s=>({hash:{...s.hash,...xp(r)}})),_u(n())},async loadFile(r,{vault:s,subpath:a,defaultLang:o}){let l=await RC(r,s,o);e(({source:c,hash:u})=>({source:{...c,url:uC(r,s)},textTracks:l,title:r.name,hash:a?{...u,...xp(a)}:u})),await _u(n())},title:"",transform:null,setTransform:r=>{e(r?s=>{let a={transform:{...s.transform,...r}};return a.transform.flipHorizontal&&a.transform.flipVertical&&a.transform.rotate==="180"&&(a.transform={...a.transform,flipHorizontal:!1,flipVertical:!1,rotate:void 0}),a}:{transform:null})},toggleControls(r){let{player:s}=n();e({controls:r}),s&&s.provider instanceof Rn&&s.provider.media.send("mx-toggle-controls",!r)},toggleWebFullscreen(r){let{player:s}=n();e({disableWebFullscreen:!r}),s&&s.provider instanceof Rn&&s.provider.media.send("mx-toggle-webfs",r)},textTracks:[],updateWebHost:r=>e({webHost:r==="generic"?void 0:r})}));return qC(t),t}var wt=(0,ti.createContext)(null);function Nt(t){let{store:e}=(0,ti.useContext)(wt);return Py(e,t)}function Fs(t){let{plugin:{settings:e}}=(0,ti.useContext)(wt);return Py(e,t)}function qf(){let{store:t}=(0,ti.useContext)(wt);return t}function HC(){return(0,ti.useContext)(wt).reload}function Hf(t){let e=(0,ti.useContext)(wt).plugin.app;return t?t(e):e}function BC(){return(0,ti.useContext)(wt).plugin}function WC(){return(0,ti.useContext)(wt).onScreenshot}var co=()=>(0,ti.useContext)(wt).embed;function wu(t,e){let n=Fl,i=[()=>n(),t.subscribe((r,s)=>{if(r.player===s.player||(n(),!r.player))return;let a=e(r.player);a?Array.isArray(a)?n=()=>a.forEach(o=>o()):n=a:n=Fl})];return()=>i.forEach(r=>r())}var bM=require("obsidian"),xM=$(z());var KC=$(z());function GC(){let t=bi(),e=qf();(0,KC.useEffect)(()=>{if(t)return TF(t,e)},[t,e])}function TF(t,e){let n={currentTime:t.state.currentTime,paused:t.state.paused,loop:t.state.loop},i=!1,r=[t.subscribe(({currentTime:s,paused:a,loop:o})=>{let l=SF(e.getState().hash.tempFragment,t.state.duration);if(!l||kn(l))return;let{start:c,end:u}=l;if(n.paused!==a&&!a)(s>u||su)if(o)t.currentTime=c,a&&t.play();else{if(i){i=!1;return}a||t.pause()}}Object.assign(n,{currentTime:s,paused:a,loop:o})})];return()=>r.forEach(s=>s())}function SF(t,e){if(!t)return null;if(kn(t))return t;let{start:n,end:i}=t;return e&&ea(s))?.classGroupId}var XC=/^\[(.+)\]$/;function CF(t){if(XC.test(t)){let e=XC.exec(t)[1],n=e?.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}}function $F(t){let{theme:e,prefix:n}=t,i={nextPart:new Map,validators:[]};return RF(Object.entries(t.classGroups),n).forEach(([s,a])=>{lb(a,i,s,e)}),i}function lb(t,e,n,i){t.forEach(r=>{if(typeof r=="string"){let s=r===""?e:ZC(e,r);s.classGroupId=n;return}if(typeof r=="function"){if(MF(r)){lb(r(i),e,n,i);return}e.validators.push({validator:r,classGroupId:n});return}Object.entries(r).forEach(([s,a])=>{lb(a,ZC(e,s),n,i)})})}function ZC(t,e){let n=t;return e.split(cb).forEach(i=>{n.nextPart.has(i)||n.nextPart.set(i,{nextPart:new Map,validators:[]}),n=n.nextPart.get(i)}),n}function MF(t){return t.isThemeGetter}function RF(t,e){return e?t.map(([n,i])=>{let r=i.map(s=>typeof s=="string"?e+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([a,o])=>[e+a,o])):s);return[n,r]}):t}function LF(t){if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,i=new Map;function r(s,a){n.set(s,a),e++,e>t&&(e=0,i=n,n=new Map)}return{get(s){let a=n.get(s);if(a!==void 0)return a;if((a=i.get(s))!==void 0)return r(s,a),a},set(s,a){n.has(s)?n.set(s,a):r(s,a)}}}var e$="!";function IF(t){let e=t.separator,n=e.length===1,i=e[0],r=e.length;return function(a){let o=[],l=0,c=0,u;for(let v=0;vc?u-c:void 0;return{modifiers:o,hasImportantModifier:p,baseClassName:h,maybePostfixModifierPosition:y}}}function AF(t){if(t.length<=1)return t;let e=[],n=[];return t.forEach(i=>{i[0]==="["?(e.push(...n.sort(),i),n=[]):n.push(i)}),e.push(...n.sort()),e}function NF(t){return{cache:LF(t.cacheSize),splitModifiers:IF(t),...PF(t)}}var DF=/\s+/;function OF(t,e){let{splitModifiers:n,getClassGroupId:i,getConflictingClassGroupIds:r}=e,s=new Set;return t.trim().split(DF).map(a=>{let{modifiers:o,hasImportantModifier:l,baseClassName:c,maybePostfixModifierPosition:u}=n(a),d=i(u?c.substring(0,u):c),p=!!u;if(!d){if(!u)return{isTailwindClass:!1,originalClassName:a};if(d=i(c),!d)return{isTailwindClass:!1,originalClassName:a};p=!1}let h=AF(o).join(":");return{isTailwindClass:!0,modifierId:l?h+e$:h,classGroupId:d,originalClassName:a,hasPostfixModifier:p}}).reverse().filter(a=>{if(!a.isTailwindClass)return!0;let{modifierId:o,classGroupId:l,hasPostfixModifier:c}=a,u=o+l;return s.has(u)?!1:(s.add(u),r(l,c).forEach(d=>s.add(o+d)),!0)}).reverse().map(a=>a.originalClassName).join(" ")}function VF(){let t=0,e,n,i="";for(;td(u),t());return n=NF(c),i=n.cache.get,r=n.cache.set,s=o,o(l)}function o(l){let c=i(l);if(c)return c;let u=OF(l,n);return r(l,u),u}return function(){return s(VF.apply(null,arguments))}}function Te(t){let e=n=>n[t]||[];return e.isThemeGetter=!0,e}var n$=/^\[(?:([a-z-]+):)?(.+)\]$/i,zF=/^\d+\/\d+$/,UF=new Set(["px","full","screen"]),jF=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,qF=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,HF=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,BF=/^-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,WF=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/;function nr(t){return zs(t)||UF.has(t)||zF.test(t)}function zr(t){return uo(t,"length",e5)}function zs(t){return!!t&&!Number.isNaN(Number(t))}function Bf(t){return uo(t,"number",zs)}function bu(t){return!!t&&Number.isInteger(Number(t))}function KF(t){return t.endsWith("%")&&zs(t.slice(0,-1))}function Q(t){return n$.test(t)}function Ur(t){return jF.test(t)}var GF=new Set(["length","size","percentage"]);function YF(t){return uo(t,GF,i$)}function QF(t){return uo(t,"position",i$)}var XF=new Set(["image","url"]);function ZF(t){return uo(t,XF,n5)}function JF(t){return uo(t,"",t5)}function xu(){return!0}function uo(t,e,n){let i=n$.exec(t);return i?i[1]?typeof e=="string"?i[1]===e:e.has(i[1]):n(i[2]):!1}function e5(t){return qF.test(t)&&!HF.test(t)}function i$(){return!1}function t5(t){return BF.test(t)}function n5(t){return WF.test(t)}function i5(){let t=Te("colors"),e=Te("spacing"),n=Te("blur"),i=Te("brightness"),r=Te("borderColor"),s=Te("borderRadius"),a=Te("borderSpacing"),o=Te("borderWidth"),l=Te("contrast"),c=Te("grayscale"),u=Te("hueRotate"),d=Te("invert"),p=Te("gap"),h=Te("gradientColorStops"),y=Te("gradientColorStopPositions"),v=Te("inset"),_=Te("margin"),m=Te("opacity"),f=Te("padding"),g=Te("saturate"),x=Te("scale"),T=Te("sepia"),L=Te("skew"),R=Te("space"),I=Te("translate"),K=()=>["auto","contain","none"],q=()=>["auto","hidden","clip","visible","scroll"],_e=()=>["auto",Q,e],J=()=>[Q,e],sr=()=>["",nr,zr],$e=()=>["auto",zs,Q],bt=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Pi=()=>["solid","dashed","dotted","double","none"],Uo=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-lighter"],Zr=()=>["start","end","center","between","around","evenly","stretch"],Vn=()=>["","0",Q],Ci=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Qt=()=>[zs,Bf],Jr=()=>[zs,Q];return{cacheSize:500,separator:":",theme:{colors:[xu],spacing:[nr,zr],blur:["none","",Ur,Q],brightness:Qt(),borderColor:[t],borderRadius:["none","","full",Ur,Q],borderSpacing:J(),borderWidth:sr(),contrast:Qt(),grayscale:Vn(),hueRotate:Jr(),invert:Vn(),gap:J(),gradientColorStops:[t],gradientColorStopPositions:[KF,zr],inset:_e(),margin:_e(),opacity:Qt(),padding:J(),saturate:Qt(),scale:Qt(),sepia:Vn(),skew:Jr(),space:J(),translate:J()},classGroups:{aspect:[{aspect:["auto","square","video",Q]}],container:["container"],columns:[{columns:[Ur]}],"break-after":[{"break-after":Ci()}],"break-before":[{"break-before":Ci()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...bt(),Q]}],overflow:[{overflow:q()}],"overflow-x":[{"overflow-x":q()}],"overflow-y":[{"overflow-y":q()}],overscroll:[{overscroll:K()}],"overscroll-x":[{"overscroll-x":K()}],"overscroll-y":[{"overscroll-y":K()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[v]}],"inset-x":[{"inset-x":[v]}],"inset-y":[{"inset-y":[v]}],start:[{start:[v]}],end:[{end:[v]}],top:[{top:[v]}],right:[{right:[v]}],bottom:[{bottom:[v]}],left:[{left:[v]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",bu,Q]}],basis:[{basis:_e()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Q]}],grow:[{grow:Vn()}],shrink:[{shrink:Vn()}],order:[{order:["first","last","none",bu,Q]}],"grid-cols":[{"grid-cols":[xu]}],"col-start-end":[{col:["auto",{span:["full",bu,Q]},Q]}],"col-start":[{"col-start":$e()}],"col-end":[{"col-end":$e()}],"grid-rows":[{"grid-rows":[xu]}],"row-start-end":[{row:["auto",{span:[bu,Q]},Q]}],"row-start":[{"row-start":$e()}],"row-end":[{"row-end":$e()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Q]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Q]}],gap:[{gap:[p]}],"gap-x":[{"gap-x":[p]}],"gap-y":[{"gap-y":[p]}],"justify-content":[{justify:["normal",...Zr()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...Zr(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...Zr(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[f]}],px:[{px:[f]}],py:[{py:[f]}],ps:[{ps:[f]}],pe:[{pe:[f]}],pt:[{pt:[f]}],pr:[{pr:[f]}],pb:[{pb:[f]}],pl:[{pl:[f]}],m:[{m:[_]}],mx:[{mx:[_]}],my:[{my:[_]}],ms:[{ms:[_]}],me:[{me:[_]}],mt:[{mt:[_]}],mr:[{mr:[_]}],mb:[{mb:[_]}],ml:[{ml:[_]}],"space-x":[{"space-x":[R]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[R]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Q,e]}],"min-w":[{"min-w":[Q,e,"min","max","fit"]}],"max-w":[{"max-w":[Q,e,"none","full","min","max","fit","prose",{screen:[Ur]},Ur]}],h:[{h:[Q,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Q,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Q,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Q,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Ur,zr]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Bf]}],"font-family":[{font:[xu]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Q]}],"line-clamp":[{"line-clamp":["none",zs,Bf]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",nr,Q]}],"list-image":[{"list-image":["none",Q]}],"list-style-type":[{list:["none","disc","decimal",Q]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[m]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[m]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Pi(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",nr,zr]}],"underline-offset":[{"underline-offset":["auto",nr,Q]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:J()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Q]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Q]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[m]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...bt(),QF]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",YF]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},ZF]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[y]}],"gradient-via-pos":[{via:[y]}],"gradient-to-pos":[{to:[y]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[o]}],"border-w-x":[{"border-x":[o]}],"border-w-y":[{"border-y":[o]}],"border-w-s":[{"border-s":[o]}],"border-w-e":[{"border-e":[o]}],"border-w-t":[{"border-t":[o]}],"border-w-r":[{"border-r":[o]}],"border-w-b":[{"border-b":[o]}],"border-w-l":[{"border-l":[o]}],"border-opacity":[{"border-opacity":[m]}],"border-style":[{border:[...Pi(),"hidden"]}],"divide-x":[{"divide-x":[o]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[o]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[m]}],"divide-style":[{divide:Pi()}],"border-color":[{border:[r]}],"border-color-x":[{"border-x":[r]}],"border-color-y":[{"border-y":[r]}],"border-color-t":[{"border-t":[r]}],"border-color-r":[{"border-r":[r]}],"border-color-b":[{"border-b":[r]}],"border-color-l":[{"border-l":[r]}],"divide-color":[{divide:[r]}],"outline-style":[{outline:["",...Pi()]}],"outline-offset":[{"outline-offset":[nr,Q]}],"outline-w":[{outline:[nr,zr]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:sr()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[m]}],"ring-offset-w":[{"ring-offset":[nr,zr]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Ur,JF]}],"shadow-color":[{shadow:[xu]}],opacity:[{opacity:[m]}],"mix-blend":[{"mix-blend":Uo()}],"bg-blend":[{"bg-blend":Uo()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[i]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Ur,Q]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[d]}],saturate:[{saturate:[g]}],sepia:[{sepia:[T]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[i]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[m]}],"backdrop-saturate":[{"backdrop-saturate":[g]}],"backdrop-sepia":[{"backdrop-sepia":[T]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[a]}],"border-spacing-x":[{"border-spacing-x":[a]}],"border-spacing-y":[{"border-spacing-y":[a]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Q]}],duration:[{duration:Jr()}],ease:[{ease:["linear","in","out","in-out",Q]}],delay:[{delay:Jr()}],animate:[{animate:["none","spin","ping","pulse","bounce",Q]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[x]}],"scale-x":[{"scale-x":[x]}],"scale-y":[{"scale-y":[x]}],rotate:[{rotate:[bu,Q]}],"translate-x":[{"translate-x":[I]}],"translate-y":[{"translate-y":[I]}],"skew-x":[{"skew-x":[L]}],"skew-y":[{"skew-y":[L]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Q]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Q]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":J()}],"scroll-mx":[{"scroll-mx":J()}],"scroll-my":[{"scroll-my":J()}],"scroll-ms":[{"scroll-ms":J()}],"scroll-me":[{"scroll-me":J()}],"scroll-mt":[{"scroll-mt":J()}],"scroll-mr":[{"scroll-mr":J()}],"scroll-mb":[{"scroll-mb":J()}],"scroll-ml":[{"scroll-ml":J()}],"scroll-p":[{"scroll-p":J()}],"scroll-px":[{"scroll-px":J()}],"scroll-py":[{"scroll-py":J()}],"scroll-ps":[{"scroll-ps":J()}],"scroll-pe":[{"scroll-pe":J()}],"scroll-pt":[{"scroll-pt":J()}],"scroll-pr":[{"scroll-pr":J()}],"scroll-pb":[{"scroll-pb":J()}],"scroll-pl":[{"scroll-pl":J()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Q]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[nr,zr,Bf]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}}var r$=FF(i5);function In(...t){return r$(QC(t))}var s$=$(z());function a$(t){let e=bi();(0,s$.useEffect)(()=>{if(e)return e.listen("loaded-metadata",n=>{let i=n.target;if(!to(i.provider)){t("unknown");return}let{videoHeight:r,videoWidth:s}=i.provider.video;t(r===0||s===0?"audio":"unknown")})},[e])}var Wf=$(z());function Kf(){let{controls:t}=ub(),e=Nt(r=>r.controls);return e===void 0&&t===void 0?!0:e||t}function ub(){let{volume:t,tempFragment:e,...n}=Nt(i=>i.hash);return n}function o$(){let t=bi(),{volume:e}=Nt(s=>s.hash),n=Fs(s=>s.defaultVolume/100),i=e??n,r=(0,Wf.useRef)(i);r.current=i,(0,Wf.useEffect)(()=>t?.subscribe(({canPlay:s})=>{s&&(t.volume=r.current)}),[t])}function Ke(){return Ke=Object.assign?Object.assign.bind():function(t){for(var e=1;et.forEach(n=>r5(n,e))}function Ei(...t){return(0,l$.useCallback)(db(...t),t)}var ni=$(z(),1);function jr(t,e=[]){let n=[];function i(s,a){let o=(0,ni.createContext)(a),l=n.length;n=[...n,a];function c(d){let{scope:p,children:h,...y}=d,v=p?.[t][l]||o,_=(0,ni.useMemo)(()=>y,Object.values(y));return(0,ni.createElement)(v.Provider,{value:_},h)}function u(d,p){let h=p?.[t][l]||o,y=(0,ni.useContext)(h);if(y)return y;if(a!==void 0)return a;throw new Error(`\`${d}\` must be used within \`${s}\``)}return c.displayName=s+"Provider",[c,u]}let r=()=>{let s=n.map(a=>(0,ni.createContext)(a));return function(o){let l=o?.[t]||s;return(0,ni.useMemo)(()=>({[`__scope${t}`]:{...o,[t]:l}}),[o,l])}};return r.scopeName=t,[i,s5(r,...e)]}function s5(...t){let e=t[0];if(t.length===1)return e;let n=()=>{let i=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(s){let a=i.reduce((o,{useScope:l,scopeName:c})=>{let d=l(s)[`__scope${c}`];return{...o,...d}},{});return(0,ni.useMemo)(()=>({[`__scope${e.scopeName}`]:a}),[a])}};return n.scopeName=e.scopeName,n}var ho=$(z(),1),c5=$(Dl(),1);var De=$(z(),1);var po=(0,De.forwardRef)((t,e)=>{let{children:n,...i}=t,r=De.Children.toArray(n),s=r.find(o5);if(s){let a=s.props.children,o=r.map(l=>l===s?De.Children.count(a)>1?De.Children.only(null):(0,De.isValidElement)(a)?a.props.children:null:l);return(0,De.createElement)(pb,Ke({},i,{ref:e}),(0,De.isValidElement)(a)?(0,De.cloneElement)(a,void 0,o):null)}return(0,De.createElement)(pb,Ke({},i,{ref:e}),n)});po.displayName="Slot";var pb=(0,De.forwardRef)((t,e)=>{let{children:n,...i}=t;return(0,De.isValidElement)(n)?(0,De.cloneElement)(n,{...l5(i,n.props),ref:e?db(e,n.ref):n.ref}):De.Children.count(n)>1?De.Children.only(null):null});pb.displayName="SlotClone";var a5=({children:t})=>(0,De.createElement)(De.Fragment,null,t);function o5(t){return(0,De.isValidElement)(t)&&t.type===a5}function l5(t,e){let n={...e};for(let i in e){let r=t[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?n[i]=(...o)=>{s(...o),r(...o)}:r&&(n[i]=r):i==="style"?n[i]={...r,...s}:i==="className"&&(n[i]=[r,s].filter(Boolean).join(" "))}return{...t,...n}}var u5=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],ku=u5.reduce((t,e)=>{let n=(0,ho.forwardRef)((i,r)=>{let{asChild:s,...a}=i,o=s?po:e;return(0,ho.useEffect)(()=>{window[Symbol.for("radix-ui")]=!0},[]),(0,ho.createElement)(o,Ke({},a,{ref:r}))});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});var fo=$(z(),1);function hb(t){let e=(0,fo.useRef)(t);return(0,fo.useEffect)(()=>{e.current=t}),(0,fo.useMemo)(()=>(...n)=>{var i;return(i=e.current)===null||i===void 0?void 0:i.call(e,...n)},[])}var c$=$(z(),1),u$=globalThis?.document?c$.useLayoutEffect:()=>{};var Eu=$(z(),1);var d$=$(z(),1);function p$(t){let[e,n]=(0,d$.useState)(void 0);return u$(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});let i=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;let s=r[0],a,o;if("borderBoxSize"in s){let l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;a=c.inlineSize,o=c.blockSize}else a=t.offsetWidth,o=t.offsetHeight;n({width:a,height:o})});return i.observe(t,{box:"border-box"}),()=>i.unobserve(t)}else n(void 0)},[t]),e}var h$="Popper",[f$,fb]=jr(h$),[mq,gq]=f$(h$);var d5="PopperContent",[vq,yq]=f$(d5);var qr=$(z(),1);function m$({prop:t,defaultProp:e,onChange:n=()=>{}}){let[i,r]=p5({defaultProp:e,onChange:n}),s=t!==void 0,a=s?t:i,o=hb(n),l=(0,qr.useCallback)(c=>{if(s){let d=typeof c=="function"?c(t):c;d!==t&&o(d)}else r(c)},[s,t,r,o]);return[a,l]}function p5({defaultProp:t,onChange:e}){let n=(0,qr.useState)(t),[i]=n,r=(0,qr.useRef)(i),s=hb(e);return(0,qr.useEffect)(()=>{r.current!==i&&(s(i),r.current=i)},[i,r,s]),n}var[Gf,$q]=jr("Tooltip",[fb]),Mq=fb(),h5="TooltipProvider",f5=700;var[m5,Rq]=Gf(h5),g5=t=>{let{__scopeTooltip:e,delayDuration:n=f5,skipDelayDuration:i=300,disableHoverableContent:r=!1,children:s}=t,[a,o]=(0,Dt.useState)(!0),l=(0,Dt.useRef)(!1),c=(0,Dt.useRef)(0);return(0,Dt.useEffect)(()=>{let u=c.current;return()=>window.clearTimeout(u)},[]),(0,Dt.createElement)(m5,{scope:e,isOpenDelayed:a,delayDuration:n,onOpen:(0,Dt.useCallback)(()=>{window.clearTimeout(c.current),o(!1)},[]),onClose:(0,Dt.useCallback)(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o(!0),i)},[i]),isPointerInTransitRef:l,onPointerInTransitChange:(0,Dt.useCallback)(u=>{l.current=u},[]),disableHoverableContent:r},s)},g$="Tooltip",[Lq,Iq]=Gf(g$);var v5="TooltipPortal",[Aq,Nq]=Gf(v5,{forceMount:void 0});var[Dq,Oq]=Gf(g$,{isInside:!1});var Yf=g5;var Zf=$(z());var b$=require("obsidian"),Xf=$(z()),A$=$(ae());function E5(t){let e=(0,Xf.useRef)(null);return[(0,Xf.useCallback)(i=>{e.current&&e.current.empty(),i&&(0,b$.setIcon)(i,t),e.current=i},[t])]}function Fe(t){return function(n){let[i]=E5(t);return(0,A$.jsx)("div",{ref:i,...n})}}var x$=Fe("play"),k$=Fe("pause"),qq=Fe("volume"),E$=Fe("volume-1"),T$=Fe("volume-2"),S$=Fe("volume-x"),P$=Fe("maximize"),C$=Fe("minimize"),T5=Fe("picture-in-picture-2"),S5=Fe("picture-in-picture"),mb=Fe("subtitles"),Hq=Fe("check-circle"),Bq=Fe("circle"),$$=Fe("fast-forward"),M$=Fe("rewind"),R$=Fe("edit"),L$=Fe("image-down"),P5=Fe("pin"),I$=Fe("more-horizontal"),Wq=Fe("plus"),Kq=Fe("trash");var Qe=$(ae()),Tu="group ring-mod-border-focus relative inline-flex h-10 w-10 cursor-pointer items-center justify-center rounded-md outline-none ring-inset hover:bg-white/20 focus-visible:ring-2 aria-disabled:hidden";function Jf(){let t=ye("paused");return(0,Qe.jsx)(lf,{className:Tu,"aria-label":t?"Play":"Pause",children:t?(0,Qe.jsx)(x$,{className:"w-7 h-7 translate-x-px"}):(0,Qe.jsx)(k$,{className:"w-7 h-7"})})}function N$({seconds:t}){return(0,Qe.jsx)(su,{className:Tu,seconds:t,"aria-label":`Fast forward ${t}s`,children:(0,Qe.jsx)($$,{className:"w-7 h-7"})})}function D$({seconds:t}){return(0,Qe.jsx)(su,{className:Tu,seconds:-t,"aria-label":`Rewind ${t}s`,children:(0,Qe.jsx)(M$,{className:"w-7 h-7"})})}function em(){let t=ye("volume"),e=ye("muted");return(0,Qe.jsx)(uf,{className:Tu,"aria-label":e?"Unmute":"Mute",children:e||t==0?(0,Qe.jsx)(S$,{className:"w-7 h-7"}):t<.5?(0,Qe.jsx)(E$,{className:"w-7 h-7"}):(0,Qe.jsx)(T$,{className:"w-7 h-7"})})}function O$(){let t=ye("fullscreen");return(0,Qe.jsx)(cf,{className:Tu,"aria-label":t?"Exit fullscreen":"Enter fullscreen",children:t?(0,Qe.jsx)(C$,{className:"w-7 h-7"}):(0,Qe.jsx)(P$,{className:"w-7 h-7"})})}function tm(){return co()?(0,Qe.jsx)("button",{className:In("mx-lp-edit","group ring-mod-border-focus relative inline-flex h-10 w-10 cursor-pointer items-center justify-center rounded-md outline-none ring-inset hover:bg-white/20 focus-visible:ring-2 aria-disabled:hidden"),onClick:()=>{},[Hr]:!0,"aria-label":"Edit in editor",children:(0,Qe.jsx)(R$,{className:"w-7 h-7"})}):null}function C5(){let t=_1(),[e,n]=(0,Zf.useState)(()=>gu(t)),i=WC(),r=Fs(a=>a.screenshotFormat),s=Fs(a=>a.screenshotQuality);return(0,Zf.useEffect)(()=>{n(gu(t))},[t]),!e||!i||!t?null:async()=>{i(await Nf(t,r,s))}}function V$(){let t=C5();return t?(0,Qe.jsx)("button",{className:"group ring-mod-border-focus relative inline-flex h-10 w-10 cursor-pointer items-center justify-center rounded-md outline-none ring-inset hover:bg-white/20 focus-visible:ring-2 aria-disabled:hidden",onClick:t,"aria-label":"Capture screenshot",children:(0,Qe.jsx)(L$,{className:"w-7 h-7"})}):null}var Hr="data-lp-pass-through";function ut(t,e){let n=Object.keys(e).map(i=>$5(t,i,e[i]));return n.length===1?n[0]:function(){n.forEach(i=>i())}}function $5(t,e,n){let i=t[e],r=t.hasOwnProperty(e),s=n(i);return i&&Object.setPrototypeOf(s,i),Object.setPrototypeOf(a,s),t[e]=a,o;function a(...l){return s===i&&t[e]===a&&o(),s.apply(this,l)}function o(){t[e]===a&&(r?t[e]=i:delete t[e]),s!==i&&(s=i,Object.setPrototypeOf(a,i||Function))}}var z$=require("obsidian"),U$=$(z());var Su=$(ae());function j$(t){let e=(0,U$.useRef)(null);return n=>{e.current?.close(),e.current=null;let i=new z$.Menu;t(i)?(Gs(n.nativeEvent,i),n.nativeEvent.stopImmediatePropagation(),ut(i,{close:r=>function(...s){return e.current===this&&(e.current=null),r.call(this,...s)}}),e.current=i):i.close()}}function q$(){let t=zw(),e=ye("textTracks"),n=j$(i=>(t.forEach(({label:r,select:s,selected:a},o,l)=>{i.addItem(c=>{l.length===2&&r==="Unknown"&&(r="On"),c.setTitle(r).setChecked(a).onClick(s)})}),!0));return e.length===0?null:(0,Su.jsx)("button",{className:"group ring-mod-border-focus relative inline-flex h-10 w-10 cursor-pointer items-center justify-center rounded-md outline-none ring-inset hover:bg-white/20 focus-visible:ring-2 aria-disabled:hidden",[Hr]:!0,onClick:n,"aria-label":"Select Caption",children:(0,Su.jsx)(mb,{className:"w-7 h-7"})})}function nm(){let t=bi(),e=Hf(l=>l.workspace),n=BC(),i=co(),r=HC(),s=Nt(l=>l.source?.url),a=qf(),o=j$(l=>{if(!t||!s)return!1;let{toggleControls:c,controls:u,setTransform:d,transform:p,disableWebFullscreen:h,toggleWebFullscreen:y}=a.getState();return e.trigger("mx-media-menu",l,{player:t,reload:r,source:s,toggleControls:c,controls:u,setTransform:d,transform:p,plugin:n,disableWebFullscreen:h,toggleWebFullscreen:y},i?"player-menu-embed":"player-menu-view"),!0});return!t||!s?null:(0,Su.jsx)("button",{className:"group ring-mod-border-focus relative inline-flex h-10 w-10 cursor-pointer items-center justify-center rounded-md outline-none ring-inset hover:bg-white/20 focus-visible:ring-2 aria-disabled:hidden",[Hr]:!0,onClick:o,"aria-label":"More options",children:(0,Su.jsx)(I$,{className:"w-7 h-7"})})}var am=$(z());var B=$(z(),1);function gb(t,[e,n]){return Math.min(n,Math.max(e,t))}var Pu=$(z(),1),M5=(0,Pu.createContext)(void 0);function B$(t){let e=(0,Pu.useContext)(M5);return t||e||"ltr"}var im=$(z(),1);function W$(t){let e=(0,im.useRef)({value:t,previous:t});return(0,im.useMemo)(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var ii=$(z(),1);function K$(t){let e=t+"CollectionProvider",[n,i]=jr(e),[r,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),a=h=>{let{scope:y,children:v}=h,_=ii.default.useRef(null),m=ii.default.useRef(new Map).current;return ii.default.createElement(r,{scope:y,itemMap:m,collectionRef:_},v)},o=t+"CollectionSlot",l=ii.default.forwardRef((h,y)=>{let{scope:v,children:_}=h,m=s(o,v),f=Ei(y,m.collectionRef);return ii.default.createElement(po,{ref:f},_)}),c=t+"CollectionItemSlot",u="data-radix-collection-item",d=ii.default.forwardRef((h,y)=>{let{scope:v,children:_,...m}=h,f=ii.default.useRef(null),g=Ei(y,f),x=s(c,v);return ii.default.useEffect(()=>(x.itemMap.set(f,{ref:f,...m}),()=>void x.itemMap.delete(f))),ii.default.createElement(po,{[u]:"",ref:g},_)});function p(h){let y=s(t+"CollectionConsumer",h);return ii.default.useCallback(()=>{let _=y.collectionRef.current;if(!_)return[];let m=Array.from(_.querySelectorAll(`[${u}]`));return Array.from(y.itemMap.values()).sort((x,T)=>m.indexOf(x.ref.current)-m.indexOf(T.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:a,Slot:l,ItemSlot:d},p,i]}var Q$=["PageUp","PageDown"],X$=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Z$={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Cu="Slider",[vb,R5,L5]=K$(Cu),[J$,RH]=jr(Cu,[L5]),[I5,rm]=J$(Cu),A5=(0,B.forwardRef)((t,e)=>{let{name:n,min:i=0,max:r=100,step:s=1,orientation:a="horizontal",disabled:o=!1,minStepsBetweenThumbs:l=0,defaultValue:c=[i],value:u,onValueChange:d=()=>{},onValueCommit:p=()=>{},inverted:h=!1,...y}=t,[v,_]=(0,B.useState)(null),m=Ei(e,$e=>_($e)),f=(0,B.useRef)(new Set),g=(0,B.useRef)(0),x=a==="horizontal",T=v?!!v.closest("form"):!0,L=x?N5:D5,[R=[],I]=m$({prop:u,defaultProp:c,onChange:$e=>{var bt;(bt=[...f.current][g.current])===null||bt===void 0||bt.focus(),d($e)}}),K=(0,B.useRef)(R);function q($e){let bt=B5(R,$e);sr($e,bt)}function _e($e){sr($e,g.current)}function J(){let $e=K.current[g.current];R[g.current]!==$e&&p(R)}function sr($e,bt,{commit:Pi}={commit:!1}){let Uo=Y5(s),Zr=Q5(Math.round(($e-i)/s)*s+i,Uo),Vn=gb(Zr,[i,r]);I((Ci=[])=>{let Qt=q5(Ci,Vn,bt);if(G5(Qt,l*s)){g.current=Qt.indexOf(Vn);let Jr=String(Qt)!==String(Ci);return Jr&&Pi&&p(Qt),Jr?Qt:Ci}else return Ci})}return(0,B.createElement)(I5,{scope:t.__scopeSlider,disabled:o,min:i,max:r,valueIndexToChangeRef:g,thumbs:f.current,values:R,orientation:a},(0,B.createElement)(vb.Provider,{scope:t.__scopeSlider},(0,B.createElement)(vb.Slot,{scope:t.__scopeSlider},(0,B.createElement)(L,Ke({"aria-disabled":o,"data-disabled":o?"":void 0},y,{ref:m,onPointerDown:Us(y.onPointerDown,()=>{o||(K.current=R)}),min:i,max:r,inverted:h,onSlideStart:o?void 0:q,onSlideMove:o?void 0:_e,onSlideEnd:o?void 0:J,onHomeKeyDown:()=>!o&&sr(i,0,{commit:!0}),onEndKeyDown:()=>!o&&sr(r,R.length-1,{commit:!0}),onStepKeyDown:({event:$e,direction:bt})=>{if(!o){let Zr=Q$.includes($e.key)||$e.shiftKey&&X$.includes($e.key)?10:1,Vn=g.current,Ci=R[Vn],Qt=s*Zr*bt;sr(Ci+Qt,Vn,{commit:!0})}}})))),T&&R.map(($e,bt)=>(0,B.createElement)(j5,{key:bt,name:n?n+(R.length>1?"[]":""):void 0,value:$e})))}),[eM,tM]=J$(Cu,{startEdge:"left",endEdge:"right",size:"width",direction:1}),N5=(0,B.forwardRef)((t,e)=>{let{min:n,max:i,dir:r,inverted:s,onSlideStart:a,onSlideMove:o,onSlideEnd:l,onStepKeyDown:c,...u}=t,[d,p]=(0,B.useState)(null),h=Ei(e,g=>p(g)),y=(0,B.useRef)(),v=B$(r),_=v==="ltr",m=_&&!s||!_&&s;function f(g){let x=y.current||d.getBoundingClientRect(),T=[0,x.width],R=yb(T,m?[n,i]:[i,n]);return y.current=x,R(g-x.left)}return(0,B.createElement)(eM,{scope:t.__scopeSlider,startEdge:m?"left":"right",endEdge:m?"right":"left",direction:m?1:-1,size:"width"},(0,B.createElement)(nM,Ke({dir:v,"data-orientation":"horizontal"},u,{ref:h,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:g=>{let x=f(g.clientX);a?.(x)},onSlideMove:g=>{let x=f(g.clientX);o?.(x)},onSlideEnd:()=>{y.current=void 0,l?.()},onStepKeyDown:g=>{let T=Z$[m?"from-left":"from-right"].includes(g.key);c?.({event:g,direction:T?-1:1})}})))}),D5=(0,B.forwardRef)((t,e)=>{let{min:n,max:i,inverted:r,onSlideStart:s,onSlideMove:a,onSlideEnd:o,onStepKeyDown:l,...c}=t,u=(0,B.useRef)(null),d=Ei(e,u),p=(0,B.useRef)(),h=!r;function y(v){let _=p.current||u.current.getBoundingClientRect(),m=[0,_.height],g=yb(m,h?[i,n]:[n,i]);return p.current=_,g(v-_.top)}return(0,B.createElement)(eM,{scope:t.__scopeSlider,startEdge:h?"bottom":"top",endEdge:h?"top":"bottom",size:"height",direction:h?1:-1},(0,B.createElement)(nM,Ke({"data-orientation":"vertical"},c,{ref:d,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:v=>{let _=y(v.clientY);s?.(_)},onSlideMove:v=>{let _=y(v.clientY);a?.(_)},onSlideEnd:()=>{p.current=void 0,o?.()},onStepKeyDown:v=>{let m=Z$[h?"from-bottom":"from-top"].includes(v.key);l?.({event:v,direction:m?-1:1})}})))}),nM=(0,B.forwardRef)((t,e)=>{let{__scopeSlider:n,onSlideStart:i,onSlideMove:r,onSlideEnd:s,onHomeKeyDown:a,onEndKeyDown:o,onStepKeyDown:l,...c}=t,u=rm(Cu,n);return(0,B.createElement)(ku.span,Ke({},c,{ref:e,onKeyDown:Us(t.onKeyDown,d=>{d.key==="Home"?(a(d),d.preventDefault()):d.key==="End"?(o(d),d.preventDefault()):Q$.concat(X$).includes(d.key)&&(l(d),d.preventDefault())}),onPointerDown:Us(t.onPointerDown,d=>{let p=d.target;p.setPointerCapture(d.pointerId),d.preventDefault(),u.thumbs.has(p)?p.focus():i(d)}),onPointerMove:Us(t.onPointerMove,d=>{d.target.hasPointerCapture(d.pointerId)&&r(d)}),onPointerUp:Us(t.onPointerUp,d=>{let p=d.target;p.hasPointerCapture(d.pointerId)&&(p.releasePointerCapture(d.pointerId),s(d))})}))}),O5="SliderTrack",V5=(0,B.forwardRef)((t,e)=>{let{__scopeSlider:n,...i}=t,r=rm(O5,n);return(0,B.createElement)(ku.span,Ke({"data-disabled":r.disabled?"":void 0,"data-orientation":r.orientation},i,{ref:e}))}),G$="SliderRange",F5=(0,B.forwardRef)((t,e)=>{let{__scopeSlider:n,...i}=t,r=rm(G$,n),s=tM(G$,n),a=(0,B.useRef)(null),o=Ei(e,a),l=r.values.length,c=r.values.map(p=>iM(p,r.min,r.max)),u=l>1?Math.min(...c):0,d=100-Math.max(...c);return(0,B.createElement)(ku.span,Ke({"data-orientation":r.orientation,"data-disabled":r.disabled?"":void 0},i,{ref:o,style:{...t.style,[s.startEdge]:u+"%",[s.endEdge]:d+"%"}}))}),Y$="SliderThumb",z5=(0,B.forwardRef)((t,e)=>{let n=R5(t.__scopeSlider),[i,r]=(0,B.useState)(null),s=Ei(e,o=>r(o)),a=(0,B.useMemo)(()=>i?n().findIndex(o=>o.ref.current===i):-1,[n,i]);return(0,B.createElement)(U5,Ke({},t,{ref:s,index:a}))}),U5=(0,B.forwardRef)((t,e)=>{let{__scopeSlider:n,index:i,...r}=t,s=rm(Y$,n),a=tM(Y$,n),[o,l]=(0,B.useState)(null),c=Ei(e,_=>l(_)),u=p$(o),d=s.values[i],p=d===void 0?0:iM(d,s.min,s.max),h=H5(i,s.values.length),y=u?.[a.size],v=y?W5(y,p,a.direction):0;return(0,B.useEffect)(()=>{if(o)return s.thumbs.add(o),()=>{s.thumbs.delete(o)}},[o,s.thumbs]),(0,B.createElement)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${p}% + ${v}px)`}},(0,B.createElement)(vb.ItemSlot,{scope:t.__scopeSlider},(0,B.createElement)(ku.span,Ke({role:"slider","aria-label":t["aria-label"]||h,"aria-valuemin":s.min,"aria-valuenow":d,"aria-valuemax":s.max,"aria-orientation":s.orientation,"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,tabIndex:s.disabled?void 0:0},r,{ref:c,style:d===void 0?{display:"none"}:t.style,onFocus:Us(t.onFocus,()=>{s.valueIndexToChangeRef.current=i})}))))}),j5=t=>{let{value:e,...n}=t,i=(0,B.useRef)(null),r=W$(e);return(0,B.useEffect)(()=>{let s=i.current,a=window.HTMLInputElement.prototype,l=Object.getOwnPropertyDescriptor(a,"value").set;if(r!==e&&l){let c=new Event("input",{bubbles:!0});l.call(s,e),s.dispatchEvent(c)}},[r,e]),(0,B.createElement)("input",Ke({style:{display:"none"}},n,{ref:i,defaultValue:e}))};function q5(t=[],e,n){let i=[...t];return i[n]=e,i.sort((r,s)=>r-s)}function iM(t,e,n){let s=100/(n-e)*(t-e);return gb(s,[0,100])}function H5(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function B5(t,e){if(t.length===1)return 0;let n=t.map(r=>Math.abs(r-e)),i=Math.min(...n);return n.indexOf(i)}function W5(t,e,n){let i=t/2,s=yb([0,50],[0,i]);return(i-s(e)*n)*n}function K5(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function G5(t,e){if(e>0){let n=K5(t);return Math.min(...n)>=e}return!0}function yb(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];let i=(e[1]-e[0])/(t[1]-t[0]);return e[0]+i*(n-t[0])}}function Y5(t){return(String(t).split(".")[1]||"").length}function Q5(t,e){let n=Math.pow(10,e);return Math.round(t*n)/n}var _b=A5,rM=V5,sM=F5,aM=z5;var oM=$(z());var mo=$(ae()),sm=oM.forwardRef(({className:t,variant:e="regular",autoHidden:n,children:i,...r},s)=>(0,mo.jsxs)(_b,{ref:s,className:In("group relative flex w-full touch-none select-none items-center",t),...r,children:[(0,mo.jsx)(rM,{className:"relative h-slider-track w-full grow overflow-hidden rounded-sm bg-slider-track",children:(0,mo.jsx)(sM,{className:"absolute h-full bg-ia-accent rounded-sm will-change-[width]"})}),(0,mo.jsx)(aM,{className:In("block rounded-slider-thumb border-width-slider-thumb border-slider-thumb bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mod-border-focus disabled:pointer-events-none disabled:opacity-50 transition-opacity will-change-[left]",e==="regular"?"h-slider-thumb w-slider-thumb":"h-slider-thumb-sm w-slider-thumb-sm",n&&"opacity-0 group-hocus:opacity-100 focus:opacity-100")}),i]}));sm.displayName=_b.displayName;var Br=$(ae());function om(){let t=ye("volume"),e=ye("canSetVolume"),n=vf();return e?(0,Br.jsx)(sm,{className:"group relative inline-flex h-10 w-full max-w-[80px] cursor-pointer touch-none select-none items-center outline-none",value:[t*100],onValueChange:([i])=>{n.changeVolume(i/100)},"aria-label":"Volume",autoHidden:!0}):null}function lm({thumbnails:t}){let e=ye("currentTime"),n=ye("canSeek"),i=ye("duration"),r=ye("seeking"),s=vf(),a=1/i*100,[o,l]=(0,am.useState)(0),{previewRootRef:c,previewRef:u,previewValue:d}=w1({clamp:!0,offset:6,orientation:"horizontal"}),p=d/100*i;return(0,am.useEffect)(()=>{r||l(e/i*100)},[e,i,r]),(0,Br.jsx)(sm,{className:"group relative inline-flex h-9 w-full cursor-pointer touch-none select-none items-center outline-none",value:[o],disabled:!n,step:Number.isFinite(a)?a:1,ref:c,onValueChange:([h])=>{l(h),s.seeking(h/100*i)},onValueCommit:([h])=>{s.seek(h/100*i)},autoHidden:!0,"aria-label":"Current Time",children:(0,Br.jsxs)("div",{className:"flex flex-col items-center absolute opacity-0 data-[visible]:opacity-100 transition-opacity duration-200 will-change-[left] pointer-events-none",ref:u,children:[t?(0,Br.jsx)(df.Root,{src:t,time:p,className:"block mb-2 h-[var(--thumbnail-height)] max-h-[160px] min-h-[80px] w-[var(--thumbnail-width)] min-w-[120px] max-w-[180px] overflow-hidden border border-white bg-black",children:(0,Br.jsx)(df.Img,{})}):null,(0,Br.jsx)("span",{className:"text-[13px]",children:Vr(p)})]})})}var go=$(ae());function cm(){return(0,go.jsxs)("div",{className:"ml-2.5 flex items-center text-sm font-medium",children:[(0,go.jsx)(au,{className:"time",type:"current"}),(0,go.jsx)("div",{className:"mx-1 text-white/80",children:"/"}),(0,go.jsx)(au,{className:"time",type:"duration"})]})}var $u=$(ae());function um(){let t=ye("title").trim(),e=ff().trim();return!t&&!e?null:(0,$u.jsxs)("span",{className:"inline-block flex-1 overflow-hidden text-ellipsis whitespace-nowrap px-2 text-sm font-medium text-white/70",children:[(0,$u.jsx)("span",{className:"mr-1",children:"|"}),(0,$u.jsx)("span",{children:e||t})]})}var fe=$(ae());function cM({thumbnails:t}){return(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)(Z5,{}),(0,fe.jsx)(er.Root,{className:"opacity-100 absolute inset-0 z-10 flex h-full w-full flex-col bg-gradient-to-t from-black/10 to-transparent",children:(0,fe.jsxs)(Yf,{children:[(0,fe.jsx)("div",{className:"flex-1"}),(0,fe.jsx)(er.Group,{className:"flex w-full items-center px-2",children:(0,fe.jsx)(lm,{thumbnails:t})}),(0,fe.jsxs)(er.Group,{className:"-mt-0.5 flex w-full items-center px-2 pb-2",children:[(0,fe.jsx)(D$,{seconds:30}),(0,fe.jsx)(Jf,{}),(0,fe.jsx)(N$,{seconds:30}),(0,fe.jsx)(em,{}),(0,fe.jsx)(om,{}),(0,fe.jsx)(cm,{}),(0,fe.jsx)(um,{}),(0,fe.jsx)("div",{className:"flex-1"}),(0,fe.jsx)(tm,{}),(0,fe.jsx)(nm,{})]})]})})]})}function Z5(){return(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)($n,{className:"absolute inset-0 z-0 block h-full w-full",event:"pointerup",action:"toggle:paused"}),(0,fe.jsx)($n,{className:"absolute inset-0 z-0 block h-full w-full",event:"dblpointerup",action:"toggle:fullscreen"}),(0,fe.jsx)($n,{className:"absolute left-0 top-0 z-10 block h-full w-1/5",event:"dblpointerup",action:"seek:-10"}),(0,fe.jsx)($n,{className:"absolute right-0 top-0 z-10 block h-full w-1/5",event:"dblpointerup",action:"seek:10"})]})}var ue=$(ae());function uM({thumbnails:t}){return(0,ue.jsxs)(ue.Fragment,{children:[(0,ue.jsx)(J5,{}),(0,ue.jsx)(mf,{className:"mx-captions media-preview:opacity-0 media-controls:bottom-[85px] media-captions:opacity-100 absolute inset-0 bottom-2 z-10 select-none break-words opacity-0 transition-[opacity,bottom] duration-300"}),(0,ue.jsx)(er.Root,{className:"media-controls:opacity-100 not-media-can-load:opacity-100 absolute inset-0 z-10 flex h-full w-full flex-col bg-gradient-to-t from-black/10 to-transparent opacity-0 transition-opacity",children:(0,ue.jsxs)(Yf,{children:[(0,ue.jsx)("div",{className:"flex-1"}),(0,ue.jsx)(er.Group,{className:"flex w-full items-center px-2",children:(0,ue.jsx)(lm,{thumbnails:t})}),(0,ue.jsxs)(er.Group,{className:"-mt-0.5 flex w-full items-center px-2 pb-2",children:[(0,ue.jsx)(Jf,{}),(0,ue.jsx)(em,{}),(0,ue.jsx)(om,{}),(0,ue.jsx)(cm,{}),(0,ue.jsx)(um,{}),(0,ue.jsx)("div",{className:"flex-1"}),(0,ue.jsx)(q$,{}),(0,ue.jsx)(V$,{}),(0,ue.jsx)(O$,{}),(0,ue.jsx)(tm,{}),(0,ue.jsx)(nm,{})]})]})})]})}function J5(){return(0,ue.jsxs)(ue.Fragment,{children:[(0,ue.jsx)($n,{className:"absolute inset-0 z-0 block h-full w-full",event:"pointerup",action:"toggle:paused"}),(0,ue.jsx)($n,{className:"absolute inset-0 z-0 block h-full w-full",event:"dblpointerup",action:"toggle:fullscreen"}),(0,ue.jsx)($n,{className:"absolute left-0 top-0 z-10 block h-full w-1/5",event:"dblpointerup",action:"seek:-10"}),(0,ue.jsx)($n,{className:"absolute right-0 top-0 z-10 block h-full w-1/5",event:"dblpointerup",action:"seek:10"})]})}var _M=$(z());var Mu=class{constructor(){w(this,"name","webview");w(this,"target")}canPlay({src:e}){return lu(e)&&hC(e)}mediaType(){return"video"}async load(e){return new Rn(this.target,e)}};var fn=$(z());function dm(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}var dM=$(z());function pM(t,e){var n=(0,dM.useState)(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(i){var r=n.value;r!==i&&(n.value=i,n.callback(i,r))}}}})[0];return n.callback=e,n.facade}var fM=$(z());var hM=new WeakMap;function wb(t,e){var n=pM(e||null,function(i){return t.forEach(function(r){return dm(r,i)})});return fM.useLayoutEffect(function(){var i=hM.get(n);if(i){var r=new Set(i),s=new Set(t),a=n.current;r.forEach(function(o){s.has(o)||dm(o,null)}),s.forEach(function(o){r.has(o)||dm(o,a)})}hM.set(n,t)},[t]),n}function bb(t){return"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"}var mM=$(z()),xb={onLoadCommit:"load-commit",onDidFinishLoad:"did-finish-load",onDidFailLoad:"did-fail-load",onDidFrameFinishLoad:"did-frame-finish-load",onDidStartLoading:"did-start-loading",onDidStopLoading:"did-stop-loading",onDidAttach:"did-attach",onDomReady:"dom-ready",onPageTitleUpdated:"page-title-updated",onPageFaviconUpdated:"page-favicon-updated",onEnterHtmlFullScreen:"enter-html-full-screen",onLeaveHtmlFullScreen:"leave-html-full-screen",onConsoleMessage:"console-message",onFoundInPage:"found-in-page",onWillNavigate:"will-navigate",onDidStartNavigation:"did-start-navigation",onDidRedirectNavigation:"did-redirect-navigation",onDidNavigate:"did-navigate",onDidFrameNavigate:"did-frame-navigate",onDidNavigateInPage:"did-navigate-in-page",onClose:"close",onIpcMessage:"ipc-message",onCrashed:"crashed",onPluginCrashed:"plugin-crashed",onDestroyed:"destroyed",onMediaStartedPlaying:"media-started-playing",onMediaPaused:"media-paused",onDidChangeThemeColor:"did-change-theme-color",onUpdateTargetUrl:"update-target-url",onDevtoolsOpened:"devtools-opened",onDevtoolsClosed:"devtools-closed",onDevtoolsFocused:"devtools-focused",onContextMenu:"context-menu"};function e4(t){return Object.entries(t).reduce((e,[n,i])=>(n in xb?e.event[n]=i:e.rest[n]=i,e),{event:{},rest:{}})}function gM(t,e){let{event:n,rest:i}=e4(t);for(let r of Object.keys(xb)){let s=r,a=xb[s],o=n[s];(0,mM.useEffect)(()=>{if(!e.current||!o)return;let l=e.current;return l.addEventListener(a,o),()=>{l.removeEventListener(a,o)}},[a,o,e])}return i}var yM=$(ae()),vM=(0,fn.forwardRef)(function({devtools:e=!1,muted:n=!1,className:i,useragent:r,...s},a){let o=(0,fn.useRef)(null),[l,c]=(0,fn.useState)(!1),u=gM(s,o);n4(n,o,l);let d=t4(r??navigator.userAgent,o,l);return(0,fn.useEffect)(()=>{if(!o.current)return;let p=o.current;return p.addEventListener("dom-ready",h),p.addEventListener("will-navigate",y),()=>{p.removeEventListener("dom-ready",h),p.removeEventListener("will-navigate",y)};function h(){c(!0)}function y(){c(!1)}},[]),(0,yM.jsx)("webview",{ref:wb([o,a]),className:In("h-full w-full",i),useragent:d,...u})});function t4(t,e,n){let i=(0,fn.useMemo)(()=>{let r=t??navigator.userAgent;return bb(r)},[t]);return(0,fn.useEffect)(()=>{!e.current||!n||i===e.current.useragent||e.current.setUserAgent(i)},[i,n,e]),i}function n4(t,e,n){(0,fn.useEffect)(()=>{!e.current||!n||t===e.current.isAudioMuted()||e.current.setAudioMuted(t)},[t,n,e])}var kb=$(ae());function wM({loaders:t,...e}){let n=Hf(l=>l.appId),i=ye("viewType"),r=Nt(l=>!!l.transform?.flipHorizontal),s=Nt(l=>!!l.transform?.flipVertical),a=Nt(l=>{if(l.transform?.rotate)switch(l.transform.rotate){case"90":return"rotate-90";case"180":return"rotate-180";case"270":return"rotate-[270deg]";default:return}}),o=Kf();return(0,kb.jsx)(qw,{className:In(i==="video"&&r&&"-scale-x-100",i==="video"&&s&&"-scale-y-100",i==="video"&&a),loaders:[Mu,...t??[]],buildMediaEl:(0,_M.useCallback)((l,c)=>l instanceof Mu?(0,kb.jsx)(vM,{"aria-hidden":!0,className:In("data-[play-ready]:blur-none blur-lg transition-opacity",o&&"pointer-events-none"),webpreferences:"autoplayPolicy=user-gesture-required",partition:ai(n),ref:u=>{c.load(u)}}):null,[n,o]),...e})}var ri=$(ae()),kM=$(z());function i4({onViewTypeChange:t}){return a$(t),GC(),o$(),(0,ri.jsx)(ri.Fragment,{})}function r4(){let t=ye("viewType"),e=Kf();return t==="audio"?(0,ri.jsx)(cM,{}):e?(0,ri.jsx)(uM,{}):null}function Wr(){let t=Nt(u=>u.playerRef),e=Nt(({source:u})=>{if(!u)return;let d=u.url.source.href;return u.enableWebview?{src:dC(d)}:{type:u.type,src:d}}),n=Nt(({textTracks:u})=>u),i=Fs(u=>u.loadStrategy),r=co(),[s,a]=(0,xM.useState)("unknown"),o=Nt(u=>u.title),{controls:l,...c}=ub();return e?(0,ri.jsxs)(jw,{className:In("w-full bg-slate-900 text-white font-sans overflow-hidden rounded-md ring-mod-border-focus data-[focus]:ring-2","data-[view-type=video]:aspect-video data-[view-type=audio]:h-20 data-[view-type=audio]:aspect-auto"),load:r?i:"eager",src:e,playsInline:!0,title:o,viewType:s,ref:t,onError:u=>{new bM.Notice(createFragment(d=>{switch(d.appendText(`Failed to load media for ${e.src}: `),d.createEl("br"),u.code){case 1:d.appendText("The media playback was aborted");break;case 2:d.appendText("A network error caused the media playback to fail");break;case 3:d.appendText("The media playback was aborted due to a corruption problem or because the media encoding is not supported");break;case 4:d.appendText("The media is not supported to open as regular video or audio, try open as webpage");break;default:d.appendText(u.message||"Unknown error, check console for more details"),console.error("Failed to load media",e.src,u);break}}))},...c,children:[(0,ri.jsx)(wM,{children:n.map(u=>(0,kM.createElement)(Hw,{...u,key:u.id}))}),(0,ri.jsx)(i4,{onViewTypeChange:a}),(0,ri.jsx)(r4,{})]}):null}function pm(t,e){let n=new WeakMap,i;t.register(wu(t.store,r=>[r.subscribe(({currentTime:s,paused:a,playbackRate:o})=>{s!==0&&r.el&&n.set(t.leaf.parent,{currentTime:s,paused:a,playbackRate:o})}),r.listen("can-play",()=>{if(!i)return;let s=n.get(i);if(!s){i=void 0;return}let{currentTime:a,paused:o,playbackRate:l}=s;if(!o)r.play(new Event("recover-state")).then(()=>{r.currentTime=a,r.playbackRate=l,i&&(n.delete(i),i=void 0)}).catch(c=>console.error("recov err play",c));else try{r.currentTime=a,r.playbackRate=l,i&&(n.delete(i),i=void 0)}catch(c){console.error("recov err paused",c)}})])),t.register(a4(t,(r,s)=>{e(),n.has(s)?i=s:i=void 0})),t.register(()=>{i=void 0})}function hm(t,e){let n=new WeakMap,i;t.register(wu(t.store,r=>[r.subscribe(({currentTime:s,paused:a,playbackRate:o})=>{s!==0&&r.el&&n.set(r.el.win,{currentTime:s,paused:a,playbackRate:o})}),r.listen("can-play",()=>{if(!i)return;let s=n.get(i);if(!s){i=void 0;return}let{currentTime:a,paused:o,playbackRate:l}=s;if(!o)r.play(new Event("recover-state")).then(()=>{r.currentTime=a,r.playbackRate=l,i&&(n.delete(i),i=void 0)}).catch(c=>console.error("recov err play",c));else try{r.currentTime=a,r.playbackRate=l,i&&(n.delete(i),i=void 0)}catch(c){console.error("recov err paused",c)}})])),t.register(s4(t.containerEl,(r,s)=>{e(),n.has(s)?i=s:i=void 0})),t.register(()=>{i=void 0})}function s4(t,e){let n=t.win;return t.onNodeInserted(()=>{let i=t.win;i!==n&&(e(i,n),n=i)})}function a4(t,e){let n=t.containerEl.win,i=t.leaf.parent;return t.containerEl.onNodeInserted(()=>{let r=t.containerEl.win,s=t.leaf.parent;r===n?s!==i&&(e(s,i),i=s):n=r})}var Eb=$(ae()),fm=class extends mm.EditableFileView{constructor(n,i){super(n);this.plugin=i;w(this,"allowNoFile",!1);w(this,"store");w(this,"scope");w(this,"root",null);this.store=Fr(),this.scope=new mm.Scope(this.app.scope),this.contentEl.addClasses(["mx","custom"]),Uf(this)}onload(){hm(this,()=>this.render())}async onLoadFile(n){await this.store.getState().loadFile(n,{vault:this.app.vault,defaultLang:this.plugin.settings.getState().getDefaultLang()})}onPaneMenu(n,i){super.onPaneMenu(n,i),jf(this,n,i)}setEphemeralState(n){if("subpath"in n){let{subpath:i}=n;this.store.getState().setHash(i)}super.setEphemeralState(n)}async onOpen(){await super.onOpen(),this.render()}render(){this.root?.unmount(),this.root=EM.default.createRoot(this.contentEl),this.root.render((0,Eb.jsx)(wt.Provider,{value:{plugin:this.plugin,store:this.store,reload:()=>this.render(),embed:!1},children:(0,Eb.jsx)(Wr,{})}))}async onClose(){return this.root?.unmount(),this.root=null,super.onClose()}},vo=class extends fm{getIcon(){return"file-video"}getMediaInfo(){return this.file?{type:"video",file:this.file,hash:this.getEphemeralState().subpath}:null}getViewType(){return jn.video}canAcceptExtension(e){return kt.video.includes(e)}},yo=class extends fm{getIcon(){return"file-audio"}getViewType(){return jn.audio}getMediaInfo(){return this.file?{type:"audio",file:this.file,hash:this.getEphemeralState().subpath}:null}canAcceptExtension(e){return kt.audio.includes(e)}};var gm=require("obsidian"),TM=$(Ol());var Tb=$(ae()),Kr=class extends gm.ItemView{constructor(n,i){super(n);this.plugin=i;w(this,"store");w(this,"scope");w(this,"root",null);w(this,"navigation",!0);this.store=Fr(),this.scope=new gm.Scope(this.app.scope),this.contentEl.addClasses(["mx","custom"]),Uf(this)}setSource(n){this.store.getState().setSource(n)}getMediaInfo(){return this.store.getState().source?.url??null}get sourceType(){return this.store.getState().player?.state.source.type??""}get playerTitle(){return this.store.getState().player?.state.title??""}onload(){let n=this;super.onload(),this.register(ut(this.leaf,{detach:i=>function(...r){return n.root?.unmount(),n.root=null,i.call(this,...r)}})),hm(this,()=>this.render())}registerRemoteTitleChange(){this.register(wu(this.store,n=>n.subscribe(({title:i})=>{this.updateTitle()})))}onPaneMenu(n,i){super.onPaneMenu(n,i),jf(this,n,i)}getState(){let n=super.getState(),i=this.store.getState().source?.url;return{...n,source:i?i.jsonState.source:n.source}}async setState(n,i){if(await super.setState(n,i),!("source"in n))return;let r=this.plugin.resolveUrl(n.source);if(!r)console.warn("Invalid URL",n.source);else{let s=this.store.getState().source?.url;r.compare(s)||(await this.setSource(r),this.render())}}setEphemeralState(n){if("subpath"in n){let{subpath:i}=n;this.store.getState().setHash(i)}super.setEphemeralState(n)}async onOpen(){await super.onOpen(),this.render()}updateTitle(){let n=this.getDisplayText();this.titleEl.setText(n),this.app.workspace.activeLeaf===this.leaf&&this.app.workspace.requestActiveLeafEvents()&&this.leaf.updateHeader()}render(){this.root&&this.root.unmount(),this.root=TM.default.createRoot(this.contentEl),this.root.render((0,Tb.jsx)(wt.Provider,{value:{plugin:this.plugin,store:this.store,reload:()=>this.render(),embed:!1},children:(0,Tb.jsx)(Wr,{})}))}close(){return this.root?.unmount(),this.root=null,super.close()}async onClose(){return this.root?.unmount(),this.root=null,super.onClose()}};var o4={"video/vimeo":"Vimeo","video/youtube":"YouTube"},_o=class extends Kr{onload(){super.onload(),this.registerRemoteTitleChange(),pm(this,()=>this.render())}getDisplayText(){let e=o4[this.sourceType]??"Embed";return this.playerTitle?`${this.playerTitle} - ${e}`:e}getIcon(){switch(this.sourceType){case"video/youtube":return"youtube";case"video/vimeo":return"vimeo";default:return"video"}}getViewType(){return Mi}};var vm=class extends Kr{},wo=class extends vm{getIcon(){return"file-video"}getViewType(){return pt.video}getDisplayText(){return this.playerTitle||"Video"}async setSource(e){let n=this.plugin.settings.getState().getDefaultLang(),i=await If(e,n).catch(r=>(console.error("Failed to get text tracks",r,e.href,n),[]));this.store.getState().setSource(e,{title:!0,textTracks:i,type:"video/mp4"})}},bo=class extends vm{getIcon(){return"file-audio"}getDisplayText(){return this.playerTitle||"Audio"}getViewType(){return pt.audio}async setSource(e){this.store.getState().setSource(e,{title:!0,type:"audio/mp3"})}};var xo=class extends Kr{onload(){super.onload(),this.registerRemoteTitleChange(),pm(this,()=>this.render())}getViewType(){return Zt}getIcon(){let e=this.getHost();return e==="generic"?"globe":e}getHost(){let{source:e}=this.store.getState();return e?.url?e.url.type:"generic"}getDisplayText(){return this.playerTitle?`${this.playerTitle} - ${Gu[this.getHost()]}`:"Webpage"}setSource(e){this.store.getState().setSource(e,{enableWebview:!0})}};function SM(t,e){if(!(t.view instanceof vo||t.view instanceof yo))return!1;let{file:n}=t.view.getState();return n===e.file.path}function PM(t,e){if(!(t.view instanceof _o||t.view instanceof xo||t.view instanceof wo||t.view instanceof bo))return!1;let{source:n}=t.view.store.getState();return e.compare(n?.url)}function Sb(t,e){let n=t.stat.mtime,i=e.stat.mtime;return!n||!i?0:i-n}var ym="mx-media-active",Ru,Pb,wm,$M,bm,MM,xm,RM,_m=class extends ko.Component{constructor(n){super();this.plugin=n;O(this,Ru);O(this,wm);O(this,bm);O(this,xm);w(this,"app");w(this,"activeMediaLeaf",null);w(this,"onLeafUpdate",(0,ko.debounce)(n=>{n=n??this.workspace.activeLeaf,this.onActiveLeafChange(n)},200));this.app=n.app}onload(){let n=this.app.workspace;n.onLayoutReady(()=>{this.onLeafUpdate()}),this.registerEvent(n.on("active-leaf-change",i=>{this.onLeafUpdate(i)})),this.registerEvent(n.on("layout-change",()=>{this.onLeafUpdate()}))}onunload(){this.applyActiveMediaLeaf(null)}get workspace(){return this.app.workspace}onActiveLeafChange(n){let i=this.detectActiveMediaLeaf(n);this.activeMediaLeaf!==i&&this.applyActiveMediaLeaf(i)}applyActiveMediaLeaf(n){this.activeMediaLeaf?.tabHeaderEl.removeClass(ym),this.activeMediaLeaf?.containerEl.removeClass(ym),n?.tabHeaderEl.addClass(ym),n?.containerEl.addClass(ym),this.activeMediaLeaf=n}detectActiveMediaLeaf(n){let i=()=>{let r=this.findPinnedPlayer();if(r)return r;let s=CM(this.workspace),{activeTabGroup:a}=this.workspace;return(!n||!a?s:s.filter(l=>!a.children.includes(l))).at(0)??null};if(!n)return i();if(Cb(n))return n;if(n.view instanceof ko.MarkdownView&&n.view.file){let{mediaNote:r}=this.plugin,s=r.findMedia(n.view.file);if(s)return this.findPlayerWithSameMedia(s)}return i()}findPlayerWithSameMedia(n){for(let i of this.plugin.urlViewType.getSupported(n)){let r=l4(n,i,this.workspace);if(r.length>0)return r[0]}return null}findPinnedPlayer(){return CM(this.workspace).filter(n=>n.pinned)[0]??null}get settings(){return this.plugin.settings.getState()}getSplitBehavior(n){let{defaultMxLinkClick:{click:i,alt:r}}=this.settings;return i===null?n??!1:n===void 0||n===!1?i:r!==null&&n===i?r:n}async openMedia(n,i,{direction:r,viewType:s,fromUser:a}={}){let{workspace:o}=this.app;if(!i){let c=await M(this,wm,$M).call(this,n,s);if(c)return c}let l=o.getLeaf(a?this.getSplitBehavior(i):i,r);return M(this,Ru,Pb).call(this,l,n,s)}async openNote(n,i,r="split",s="vertical"){let a=this.plugin.mediaNote.findNotes(n),o=M(this,bm,MM).call(this,a);if(o)return o.getMode()!=="source"&&await o.setState({mode:"source"},{history:!1}),o;let l;if(a.length===0){let u=`Media Note - ${i.title}`;l=await M(this,xm,RM).call(this,u,i.fm,i.sourcePath??"")}else l=a.sort(Sb).at(0);let c=this.app.workspace.getLeaf(r,s);return await c.openFile(l,{state:{mode:"source"}}),{file:l,editor:c.view.editor}}};Ru=new WeakSet,Pb=async function(n,i,r){if($i(i))await n.openFile(i.file,{eState:{subpath:i.hash},active:!0});else{let s={source:i.jsonState.source};r??(r=this.plugin.urlViewType.getPreferred(i)),await n.setViewState({type:r,state:s,active:!0},{subpath:i.hash})}return n},wm=new WeakSet,$M=async function(n,i){let r=this.findPinnedPlayer();if(r)return await M(this,Ru,Pb).call(this,r,n,i);let s=this.findPlayerWithSameMedia(n);return s?(c4(n.hash,s),s):null},bm=new WeakSet,MM=function(n){let{workspace:i}=this.app,r=i.getLeavesOfType("markdown").filter(a=>{let o=a.view.file?.path;return!!o&&n.some(l=>l.path===o)});return r.length===0?null:(r.find(a=>a===i.activeLeaf)??r.sort((a,o)=>Sb(a.view.file,o.view.file)).at(0)).view},xm=new WeakSet,RM=async function(n,i,r=""){let{fileManager:s}=this.app,a=s.getNewFileParent(r,n),o=await s.createNewFile(a,n,"md",`--- +`;var K1={bilibili:q1,youtube:W1,vimeo:B1,coursera:void 0,generic:void 0};var G1={generic:t=>t,bilibili:t=>t.replaceAll(/[-_]哔哩哔哩.+$|[-_]bilibili.+$|-(?:番剧|电影|纪录片|国创|电视剧|综艺)-.+/g,""),youtube:t=>t.replace(/ - YouTube$/,""),vimeo:t=>t.replace(/ on Vimeo$/,""),coursera:t=>t.replace(/ \| Coursera$/,"")};var fC=require("url"),oo=require("obsidian");var pu=require("obsidian");function Cf(t){return t===0?"00:00:00":pu.moment.utc(pu.moment.duration({seconds:t}).as("milliseconds")).format("HH:mm:ss")}function X1(t){return t===0?"DT0S":pu.moment.duration(t,"seconds").toISOString()}var Y1=(t,e=2)=>{let n,i;return Number.isInteger(t)?n=t.toString():[n,i]=t.toFixed(e).split("."),n.length===1&&(n="0"+n),i?n+"."+i:n};function $f(t){return t.replace(/t=[^&]+/,"")}function Z1(t,e){let n=tb(e);return`${t}&${n}`}function J1(t,e){let n=Number.isNaN(t)?-1:t,i=Number.isNaN(e)?-1:e;return{start:n,end:i}}function tb(t){let{start:e,end:n}=t,i={get start(){return Q1(e)},get end(){return Q1(n)}};return kn(t)?`t=${i.start}`:e<0&&n>0?Number.isFinite(n)?`t=,${i.end}`:null:e>0&&n>0?`t=${i.start},${i.end}`:null}function Q1(t){if(Number.isNaN(t)||t<0)throw new Error("durationInSecond must be positive");if(t===1/0)return"e";let e=pu.moment.duration(t,"seconds"),n=e.hours(),i=e.minutes(),r=e.seconds()+e.milliseconds()/1e3;if(n>0)return[n,...[i,r].map(s=>Y1(s))].join(":");if(i>0)return[i,r].map(s=>Y1(s)).join(":");if(r>0)return r.toFixed(2);throw new Error("durationInSecond must be positive")}var eC=require("obsidian"),dF=eC.Platform.isWin?require("path/win32"):require("path/posix"),ei=dF;function Ei(t){let e=new URL(t.href),n=$f(e.hash);return e.hash===n?t:e}function tC(t){return t.hostname==="b23.tv"?!1:t.hostname.endsWith(".bilibili.com")&&(t.pathname.startsWith("/video/")||t.pathname.startsWith("/bangumi/play/"))?t.pathname.split("/").filter(Boolean).slice(-1)[0]:null}var nC=t=>tC(t)===null?null:"bilibili",iC=t=>{let e=tC(t);if(e===null)throw new Error("Invalid bilibili url");let n=$r(t.hash),i=pF(t),r=zn(t);r.searchParams.forEach((a,o,l)=>{o==="p"&&a!=="1"||l.delete(o)}),r.searchParams.sort();let s=new URL(r);return!n&&i>0&&(n={start:i,end:-1}),n&&kn(n)&&s.searchParams.set("t",String(n.start)),{source:Ei(s),cleaned:r,id:e||void 0}};function pF(t){let e=t.searchParams.get("t"),n=e?Number(e):NaN;return Number.isNaN(n)?NaN:n}var rC=t=>t.hostname==="www.coursera.org"?"coursera":null,sC=t=>{let e=zn(t);e.search="";let n=new URL(t);return{cleaned:e,source:Ei(n)}};var aC=require("obsidian");var oC=t=>({type:"generic",cleaned:zn(t),source:Ei(t.protocol==="file:"?hF(t):t)});function hF(t){let e=new URL(aC.Platform.resourcePathPrefix+t.href.substring(8));return e.search=Date.now().toString(),e}var lC=t=>t.hostname!=="vimeo.com"||!t.pathname.substring(1).match(/^\d+$/)?null:"vimeo",cC=t=>{let e=t.pathname.substring(1);if(!e.match(/^\d+$/))throw new Error("Invalid vimeo url");let n=zn(t);n.search="";let i=new URL(t);return{cleaned:n,source:Ei(i),id:e}};function dC(t){let e=t.pathname.split("/");if(t.hostname==="youtu.be"&&e.length===2)return e[1];if(t.hostname==="www.youtube.com"||t.hostname==="youtube.com"){if(e.length===2&&e[1]==="watch")return t.searchParams.get("v");let n=["shorts","embed","v"];if(e.length===3&&n.includes(e[1]))return e[2]}return null}var pC=t=>dC(t)?"youtube":null,hC=t=>{let e=$r(t.hash),n=nb(t.searchParams.get("t")),i=nb(t.searchParams.get("start")),r=nb(t.searchParams.get("end")),s=dC(t);if(!s)throw new Error("Invalid youtube url");let a=zn("https://www.youtube.com/watch");a.search=new URLSearchParams({v:s}).toString();let o=new URL(a);if(t.searchParams.has("list")&&o.searchParams.set("list",t.searchParams.get("list")),e||(i>0&&r>0?e=J1(i,r):i>0?e={start:i,end:1/0}:r>0?e={start:0,end:r}:n>0&&(e={start:n,end:-1})),e){let l=uC(e.start),c=uC(e.end);kn(e)||e.start>0&&e.end>0&&l===c?o.searchParams.set("t",l):(e.start>0&&o.searchParams.set("start",l),e.end>0&&o.searchParams.set("end",c))}return{source:Ei(o),cleaned:a,id:s}};function uC(t){return t.toFixed(0)}function nb(t){if(!t)return NaN;let e=Number(t);if(!Number.isNaN(e))return e;let n=/^(?:(?\d+)h)?(?:(?\d+)m)?(?:(?\d+)s)?$/,i=t.match(n);if(!i)return NaN;let{h:r,m:s,s:a}=i.groups,o=r?Number(r):0,l=s?Number(s):0,c=a?Number(a):0;return o*3600+l*60+c}var fF=new Set(["https:","http:","file:"]),Vs,hu=class hu extends URL{constructor(n,i){super(n);O(this,Vs,void 0);_(this,"type");_(this,"mxUrl");if(this.mxUrl=i?new URL(i):null,!fF.has(this.protocol))throw new Error("Unsupported protocol: "+this.protocol);this.type=mF.reduce((r,s)=>r??s(this),null)??"generic",we(this,Vs,gF[this.type](this))}static create(n,i){if(n instanceof hu)return n.clone();try{return new hu(n,i)}catch{return null}}get inferredType(){let n=this.pathname.split(".").pop();return n?Xt(n):null}get isFileUrl(){return this.protocol==="file:"}get filePath(){if(this.isFileUrl)try{return(0,fC.fileURLToPath)(this)}catch(n){return console.error("Failed to convert file url to path",n,this.href),null}return null}getVaultFile(n){if(!(n.adapter instanceof oo.FileSystemAdapter))return null;let i=this.filePath,r=n.adapter.getBasePath();if(!i)return null;let s=ei.relative(r,i);if(/^\.\.[/\\]/.test(s)||ei.isAbsolute(s))return null;let a=(0,oo.normalizePath)(s);return n.getFileByPath(a)}compare(n){return!!n&&this.jsonState.source===n.jsonState.source}get tempFrag(){return $r(this.hash)}setTempFrag(n){let i=this.clone(),r=$f(this.hash);return n?i.hash=Z1(r,n):i.hash=r,i}clone(){return new hu(this,this.mxUrl??void 0)}get readableHref(){return decodeURI(this.href)}get source(){return k(this,Vs).source}get cleaned(){return k(this,Vs).cleaned}get id(){return k(this,Vs).id}get jsonState(){return{source:Bo(this.mxUrl??this.cleaned)}}};Vs=new WeakMap;var _t=hu,mF=[nC,pC,lC,rC],gF={bilibili:iC,youtube:hC,vimeo:cC,coursera:sC,generic:oC};function mC(t,{getUrlMapping:e}){if(!t)return null;if(t.protocol!=="mx:")return _t.create(t);let[,,n]=t.pathname.split("/"),i=e(n);return i?_t.create(t.href.replace(`mx://${n}/`,i.replace(/\/*$/,"/")),t):null}function gC(t,e){if(Xt(t.extension)===null)throw new Error(`Unknown media type ${t.extension}`);let n=e.getResourcePath(t);return new _t("file:///"+n.substring(oo.Platform.resourcePathPrefix.length))}function vC(t){return`webpage::${btoa(t)}`}function yC(t){return atob(t.replace(/^webpage::/,""))}function Mf(t){return typeof t=="string"&&t.startsWith("webpage::")}function _C(t){return t.type==="TimeRanges"}var Rf=class{constructor(e){this.ranges=e}get length(){return this.ranges.length}start(e){return this.ranges[e][0]}end(e){return this.ranges[e][1]}};function ti(t){return _C(t)?new Rf(t.value):t}var{onDispose:ib,peek:vF}=bs,Lf=class{constructor(e,n){this._provider=e;this._ctx=n;_(this,"_disposal",H1());_(this,"_waiting",!1);_(this,"_attachedLoadStart",!1);_(this,"_attachedCanPlay",!1);_(this,"_handlers");_(this,"_handleDevEvent");this._attachInitialListeners(),ib(this._media.on("timeupdate",this._onTimeUpdate.bind(this))),ib(this._onDispose.bind(this))}get _webview(){return this._provider.webview}get _media(){return this._provider.media}get _notify(){return this._ctx.delegate._notify}_onDispose(){this._attachedLoadStart=!1,this._attachedCanPlay=!1,this._disposal.empty()}_attachInitialListeners(){this._attachEventListener("loadstart",this._onLoadStart),this._attachEventListener("abort",this._onAbort),this._attachEventListener("emptied",this._onEmptied),this._attachEventListener("error",this._onError),this._attachEventListener("volumechange",this._onVolumeChange)}_attachLoadStartListeners(){this._attachedLoadStart||(this._disposal.add(this._attachEventListener("loadeddata",this._onLoadedData),this._attachEventListener("loadedmetadata",this._onLoadedMetadata),this._attachEventListener("canplay",this._onCanPlay),this._attachEventListener("canplaythrough",this._onCanPlayThrough),this._attachEventListener("durationchange",this._onDurationChange),this._attachEventListener("play",this._onPlay),this._attachEventListener("progress",this._onProgress),this._attachEventListener("stalled",this._onStalled),this._attachEventListener("suspend",this._onSuspend)),this._attachedLoadStart=!0)}_attachCanPlayListeners(){this._attachedCanPlay||(this._disposal.add(this._attachEventListener("pause",this._onPause),this._attachEventListener("playing",this._onPlaying),this._attachEventListener("ratechange",this._onRateChange),this._attachEventListener("seeked",this._onSeeked),this._attachEventListener("seeking",this._onSeeking),this._attachEventListener("ended",this._onEnded),this._attachEventListener("waiting",this._onWaiting)),this._attachedCanPlay=!0)}_attachEventListener(e,n){let i=n.bind(this),r=this._media.on(e,i);return ib(r)}_onDevEvent(e){}_updateCurrentTime(e,n,i){let r={currentTime:Math.min(e,this._ctx.$state.seekableEnd()),played:n};this._notify("time-update",r,i&&new Event(i.type))}_onLoadStart(e){if(e.payload.networkState===3){this._onAbort(e);return}this._attachLoadStartListeners(),this._notify("load-start",void 0,new Event(e.type))}_onAbort(e){this._notify("abort",void 0,new Event(e.type))}_onEmptied({type:e}){this._notify("emptied",void 0,new Event(e))}_onLoadedData(e){this._notify("loaded-data",void 0,new Event(e.type))}_onLoadedMetadata(e){this._attachCanPlayListeners(),this._notify("loaded-metadata",void 0,new Event(e.type))}_getCanPlayDetail({duration:e,buffered:n,seekable:i}){return{provider:vF(this._ctx.$provider),duration:e,buffered:n,seekable:i}}_onPlay(e){this._ctx.$state.canPlay&&this._notify("play",void 0,new Event(e.type))}_onPause({type:e,payload:n}){n.readyState===1&&!this._waiting||(this._waiting=!1,this._notify("pause",void 0,new Event(e)))}_onCanPlay({type:e,payload:n}){let i=ti(n.buffered),r=ti(n.seekable);this._ctx.delegate._ready(this._getCanPlayDetail({duration:n.duration,buffered:i,seekable:r}),new Event(e))}_onCanPlayThrough({type:e,payload:n}){if(this._ctx.$state.started())return;let i=ti(n.buffered),r=ti(n.seekable);this._notify("can-play-through",this._getCanPlayDetail({duration:n.duration,buffered:i,seekable:r}),new Event(e))}_onPlaying({type:e}){this._waiting=!1,this._notify("playing",void 0,new Event(e))}_onStalled({type:e,payload:n}){this._notify("stalled",void 0,new Event(e)),n.readyState<3&&(this._waiting=!0,this._notify("waiting",void 0,new Event(e)))}_onWaiting({type:e,payload:n}){n.readyState<3&&(this._waiting=!0,this._notify("waiting",void 0,new Event(e)))}_onEnded(e){let{payload:n}=e,i=ti(n.played);this._updateCurrentTime(n.duration,i,e),this._notify("end",void 0,new Event(e.type))}_onTimeUpdate(e){let{payload:n}=e,i=ti(n.played);this._updateCurrentTime(n.current,i,e)}_onDurationChange(e){let{payload:n}=e,i=ti(n.played);this._ctx.$state.ended()&&this._updateCurrentTime(n.duration,i,e),this._notify("duration-change",n.duration,new Event(e.type))}_onVolumeChange({type:e,payload:n}){let i={volume:n.volume,muted:n.muted};this._notify("volume-change",i,new Event(e))}_onSeeked(e){let{payload:n}=e,i=ti(n.played);this._updateCurrentTime(n.current,i,e),this._notify("seeked",n.current,new Event(e.type))}_onSeeking({type:e,payload:n}){this._notify("seeking",n.current,new Event(e))}_onProgress({type:e,payload:n}){let i={buffered:ti(n.buffered),seekable:ti(n.seekable)};this._notify("progress",i,new Event(e))}_onSuspend({type:e}){this._notify("suspend",void 0,new Event(e))}_onRateChange({type:e,payload:n}){this._notify("rate-change",n.rate,new Event(e))}_onError({type:e,payload:n}){let i={message:n.message,code:n.code};this._notify("error",i,new ErrorEvent(e,{error:n}))}};async function wC(t,e){return await e.executeJavaScript(`(async function(){${t}})()`)}function bC(t){switch(t.code){case-202:return"SSL certificate isn't trusted by the browser. If the website is self-hosted, double check the SSL certificate and test it with a browser. ";default:return t.message}}var fu=class extends Error{constructor(n){super(`${n.errorCode}: ${n.errorDescription}`);_(this,"code");_(this,"description");_(this,"url");this.code=n.errorCode,this.url=n.validatedURL,this.description=n.errorDescription}};var{onDispose:xC}=bs,mu,If=class{constructor(e,n,i){this._video=e;this._media=n;this.userGesture=i;O(this,mu,!1);_(this,"_onChange",(e,n)=>{this._media.delegate._notify("picture-in-picture-change",e,n)});xC(e.on("enterpictureinpicture",r=>this._onChange(!0,new Event(r.type)))),xC(e.on("leavepictureinpicture",r=>this._onChange(!1,new Event(r.type))))}async updateActive(){let e=await this._video.methods.pictureInPictureEnabled();return we(this,mu,e),e}get active(){return this.updateActive(),k(this,mu)}get supported(){return!!document.pictureInPictureEnabled}async enter(){await this.userGesture(),await this._video.methods.requestPictureInPicture()}async exit(){await this._video.methods.exitPictureInPicture()}};mu=new WeakMap;var{createScope:yF,onDispose:rb,scoped:_F}=bs,lo,Rn=class{constructor(e,n){this._webview=e;this._ctx=n;_(this,"scope",yF());_(this,"$$PROVIDER_TYPE","WEBVIEW");_(this,"_currentSrc",null);_(this,"_port",new Rp);_(this,"pictureInPicture");O(this,lo,null);_(this,"onDomReady",async e=>{let n=this._webview;new Lf(this,this._ctx),this._updateTitle(e),await wC(P1,n),await this.loadPlugin(this.currentWebHost)});_F(()=>{this.pictureInPicture=new If(this._port,n,()=>this.userGesture(!0))},this.scope)}setup(){rb(()=>{this._webview.src=""}),wF(),this.type==="webview"&&this._ctx.delegate._notify("provider-setup",this),this.registerTitleChange(),rb(()=>{this._webview.removeEventListener("dom-ready",this.onDomReady)})}get type(){return"webview"}get webview(){return this._webview}get media(){return this._port}get currentSrc(){return this._currentSrc}get currentWebHost(){return this._currentSrc?.host??"generic"}setPlaybackRate(e){this._port.methods.setPlaybackRate(e)}async userGesture(e=!1){if(!e&&k(this,lo)){await k(this,lo);return}await we(this,lo,this.webview.executeJavaScript("1",!0))}async play(){this.webview.isConnected&&(await this.userGesture(),await this._port.methods.play())}async pause(){this.webview.isConnected&&(await this.userGesture(),await this._port.methods.pause())}setMuted(e){this._port.methods.setMuted(e)}setVolume(e){this._port.methods.setVolume(e)}setCurrentTime(e){this._port.methods.setCurrentTime(e)}get _notify(){return this._ctx.delegate._notify}async _updateTitle(e,n){let i=e=typeof e=="string"?new Event(e):e,r=n??this._webview.getTitle(),s=G1[this.currentWebHost](r),a=this._ctx.$state.title();s!==a&&this._notify("title-change",s,i)}loadPlugin(e){return new Promise((n,i)=>{let r=this._webview,s=this.media.onReady(async()=>{window.clearTimeout(a),await this.media.methods.loadPlugin(K1[e]),n()},{once:!0}),a=setTimeout(()=>{s(),i(new ji(5e3))},5e3),{port1:o,port2:l}=new MessageChannel;this._port.load(o),r.contentWindow.postMessage(Cx,"*",[l])})}handlePlayReady(){let e=new Promise((a,o)=>{let l=()=>{this.webview.removeEventListener("did-stop-loading",c),this.webview.removeEventListener("did-finish-load",c),this.webview.removeEventListener("did-fail-load",u)},c=()=>{a(),l()},u=d=>{o(new fu(d)),l()};this.webview.addEventListener("did-stop-loading",c),this.webview.addEventListener("did-finish-load",c),this.webview.addEventListener("did-fail-load",u)}),n,i=a=>new Promise((o,l)=>{n=window.setTimeout(()=>l(new ji(a)),a)}),r=new Promise(a=>{this._port.once("mx-play-ready",()=>{a(),window.clearTimeout(n)})}),s=1e4;e.then(()=>Promise.race([r,i(s)])).then(()=>{this.togglePlayReady(!0)}).catch(a=>{if(a instanceof ji)bF(s);else if(a instanceof fu){let o=bC(a);new zr.Notice(createFragment(l=>{l.appendText(`Failed to load webpage: ${o}`),l.createEl("p",{text:"Click to copy "},c=>c.createEl("a",{href:a.url,text:a.url.length>50?`${a.url.substring(0,50)}...`:a.url},u=>{u.addEventListener("click",d=>{d.preventDefault(),navigator.clipboard.writeText(a.url),new zr.Notice("URL copied to clipboard.")})}))}))}else throw a}).finally(()=>{this.togglePlayReady(!0)})}registerTitleChange(){let e=this._webview,n=i=>{this._updateTitle(i,i.title)};e.addEventListener("page-title-updated",n),rb(()=>{e.removeEventListener("page-title-updated",n)})}togglePlayReady(e){typeof e>"u"&&(e=!("playReady"in this._webview.dataset)),e?this._webview.dataset.playReady="":delete this._webview.dataset.playReady}untilPluginReady(){let e=this._webview;return this.togglePlayReady(!1),e.removeEventListener("dom-ready",this.onDomReady),this.handlePlayReady(),new Promise((n,i)=>{let r=s=>{this.onDomReady(s).then(n).catch(i),e.removeEventListener("dom-ready",r),e.addEventListener("dom-ready",this.onDomReady)};e.addEventListener("dom-ready",r)})}async loadSource({src:e,type:n}){if(!du(e))throw new Error("Webview provider only supports string src.");let i=_t.create(yC(e)),r=this._webview;if(this._currentSrc={src:i?.source.href??"",type:n,host:i?.type??"generic"},!i){r.src="";return}let s=!r.src||Bo(i.source)!==Bo(r.src);r.src=i.href,s&&await this.untilPluginReady()}};lo=new WeakMap;function wF(){let t="mx:webview-login-notified";localStorage.getItem(t)||(new zr.Notice(createFragment(n=>{n.appendText("You're using a webpage media player."),n.createEl("p",{text:"If you are requested to login, you can open a browser to login from:"},i=>{i.createEl("br"),i.appendText('- the "Login" command'),i.createEl("br"),i.appendText("- the entry in settings tab")}),n.appendText("Click to dismiss this notice.")}),0),localStorage.setItem(t,"1"))}function bF(t){let e="mx:webview-timeout-ignore";if(localStorage.getItem(e))return;let i=(t/1e3).toFixed(1),r=new zr.Notice(createFragment(s=>{s.createDiv({text:`Webpage not fully loaded within ${i}s. You can still try to play.`}),s.createDiv({},a=>{a.style.display="flex",a.style.justifyContent="flex-end",a.style.gap="1em",a.style.marginTop="1em",new zr.ButtonComponent(a).setButtonText("OK"),new zr.ButtonComponent(a).setButtonText("Don't show again").onClick(()=>{console.log("ignore webview timeout notice"),localStorage.setItem(e,"1"),r.hide()})})}),5e3)}var Vf=require("fs/promises"),vu=require("obsidian");function Af(t,e){let n=new Map;for(let i of t){let r=e(i),s=n.get(r);s?s.push(i):n.set(r,[i])}return n}var Of=$(sb());var ab={"de-AT":"\xD6sterreichisches Deutsch","de-CH":"Schweizer Hochdeutsch","en-AU":"Australian English","en-CA":"Canadian English","en-GB":"British English","en-US":"American English","es-ES":"espa\xF1ol de Espa\xF1a","es-MX":"espa\xF1ol de M\xE9xico","fr-CA":"fran\xE7ais canadien","fr-CH":"fran\xE7ais suisse","nl-BE":"Vlaams","pt-BR":"portugu\xEAs do Brasil","pt-PT":"portugu\xEAs europeu","ro-MD":"moldoveneasc\u0103","zh-Hans":"\u7B80\u4F53\u4E2D\u6587","zh-Hant":"\u7E41\u9AD4\u4E2D\u6587"},LC=()=>Af(Object.entries(ab),([t])=>t.split("-")[0]),RC={"zh-Hans":["CN","SG","MY"],"zh-Hant":["TW","HK","MO"]};function IC(t){let e=t.split("-"),n=e[0].toLowerCase();if(e.length===1)return Of.default.getNativeName(n);let i=e.slice(0,2).join("-");return ab[i]||`${Of.default.getNativeName(e[0])} (${t})`}function kF(t){return t.toLowerCase()==="hans"||RC["zh-Hans"].includes(t.toUpperCase())?"zh-Hans":t.toLowerCase()==="hant"||RC["zh-Hant"].includes(t.toUpperCase())?"zh-Hant":"zh"}function ob(t){if(!t)return!1;let e=t.split("-")[0].toLowerCase();return Of.default.validate(e)}function AC(t){if(!ob(t))return null;let e=t.split("-"),n=e[0].toLowerCase();if(e.length===1)return n;let i=e[1];return n==="zh"?kF(i):ab[`${n}-${i.toUpperCase()}`]??`${n}-${e.slice(1).join("-")}`}var NC=["vtt","ass","ssa","srt"];function EF(t){return NC.includes(t.extension)}function DC(t,e,n){console.debug("Search subtitles for media",{basename:t.basename,path:t.path,defaultLangCode:n}),console.debug(`${e.length} siblings`,e);let i=e.filter(EF).flatMap(l=>{let c=TF(l,t.basename);return c?[c]:[]});if(i.length===0)return console.debug("No subtitles found"),i;console.debug(`Found ${i.length} subtitles: `,i.map(l=>l.src.path)),console.debug("Subtitles details: ",i);let r=Af(i,l=>l.language),s=[...r.keys()],a=n?s.find(l=>{if(l)return l===n})??s.find(l=>{if(!l)return;let c=l.split("-")[0],u=n.split("-")[0];return c===u}):s.filter(l=>!!l)[0],o=[];return r.forEach((l,c)=>{for(let u of NC){let d=l.find(p=>p.type===u);if(d){o.push({...d,default:!!a&&c===a});return}}}),console.debug(`Final tracks: ${o.length}`,o.map(l=>l.src.path)),console.debug("Final tracks details",o),o.length===0||(console.debug(`Final default lang: ${a??o[0].id}`),a||(o[0].default=!0)),o}async function Ff(t,e){let n=t.filePath;if(!n||!t.inferredType)return[];let i=ei.basename(n),r=i.split(".").slice(0,-1).join("."),s=ei.dirname(n),a=(await(0,Vf.readdir)(s,{encoding:"utf-8",withFileTypes:!0}).catch(l=>{let c=l;return c.code!=="ENOENT"&&new vu.Notice(`Failed to read directory ${s}: ${c.message}`),[]})).filter(l=>l.name!==i&&(l.isFile()||l.isSymbolicLink())).map(l=>{let c=l.name.split(".");return c.length===1?{extension:"",basename:l.name,path:ei.join(s,l.name)}:{extension:c.at(-1),basename:c.slice(0,-1).join("."),path:ei.join(s,l.name)}}),o=DC({basename:r,path:n},a,e);return(await Promise.all(o.map(async({src:l,...c})=>{let u=await(0,Vf.readFile)(l.path,"utf-8").catch(d=>{let p=d;return p.code!=="ENOENT"&&new vu.Notice(`Failed to read subtitle file ${l.path}: ${p.message}`),""});return u?{...c,content:u}:null}))).filter(l=>!!l)}async function OC(t,e,n){if(!t.parent)return[];let i=DC(t,t.parent.children.filter(r=>r instanceof vu.TFile),n);return await Promise.all(i.map(async({src:r,...s})=>({...s,content:await e.cachedRead(r)})))}function TF(t,e){if(!t.basename.startsWith(e))return null;let n=t.basename.substring(e.length),i;if(!n)i=null;else if(i=AC(n.replace(/^\./,"")),!i)return null;let r=i?IC(i):"Unknown";return{kind:"subtitles",language:i??void 0,id:`${t.basename}.${t.extension}.${i??"unknown"}`,src:t,type:t.extension,label:`${r} (${t.extension})`,default:!1}}var VC={"application/prs.cww":["cww"],"application/prs.xsf+xml":["xsf"],"application/vnd.1000minds.decision-model+xml":["1km"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["*xfdf"],"application/vnd.age":["age"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.keynote":["key"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.apple.numbers":["numbers"],"application/vnd.apple.pages":["pages"],"application/vnd.apple.pkpass":["pkpass"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.balsamiq.bmml+xml":["bmml"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.citationstyles.style+xml":["csl"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dbf":["dbf"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["*fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-apps.document":["gdoc"],"application/vnd.google-apps.presentation":["gslides"],"application/vnd.google-apps.spreadsheet":["gsheet"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.hydrostatix.sof-data":["sfd-hdstx"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mapbox-vector-tile":["mvt"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-outlook":["msg"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["*stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["*mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.ac+xml":["*ac"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.n-gage.symbian.install":["n-gage"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openblox.game+xml":["obgx"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openstreetmap.data+xml":["osm"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.pwg-xhtml-print+xml":["xhtm"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.rar":["rar"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.software602.filler.form+xml":["fo"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.wadl+xml":["wadl"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.syncml.dmddf+xml":["ddf"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml","uo"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["*dmg"],"application/x-arj":["arj"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bdoc":["*bdoc"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-cocoa":["cco"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["*deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-httpd-php":["php"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["*iso"],"application/x-iwork-keynote-sffkey":["*key"],"application/x-iwork-numbers-sffnumbers":["*numbers"],"application/x-iwork-pages-sffpages":["*pages"],"application/x-java-archive-diff":["jardiff"],"application/x-java-jnlp-file":["jnlp"],"application/x-keepass2":["kdbx"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-makeself":["run"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["*prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdos-program":["*exe"],"application/x-msdownload":["*exe","*dll","com","bat","*msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["*wmf","*wmz","*emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-ns-proxy-autoconfig":["pac"],"application/x-nzb":["nzb"],"application/x-perl":["pl","pm"],"application/x-pilot":["*prc","*pdb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["*rar"],"application/x-redhat-package-manager":["rpm"],"application/x-research-info-systems":["ris"],"application/x-sea":["sea"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["*sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl","tk"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["*obj"],"application/x-ustar":["ustar"],"application/x-virtualbox-hdd":["hdd"],"application/x-virtualbox-ova":["ova"],"application/x-virtualbox-ovf":["ovf"],"application/x-virtualbox-vbox":["vbox"],"application/x-virtualbox-vbox-extpack":["vbox-extpack"],"application/x-virtualbox-vdi":["vdi"],"application/x-virtualbox-vhd":["vhd"],"application/x-virtualbox-vmdk":["vmdk"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt","pem"],"application/x-xfig":["fig"],"application/x-xliff+xml":["*xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/x-aac":["*aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-m4a":["*m4a"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-realaudio":["*ra"],"audio/x-wav":["*wav"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"image/prs.btif":["btif","btf"],"image/prs.pti":["pti"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.airzip.accelerator.azv":["azv"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["*sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.microsoft.icon":["ico"],"image/vnd.ms-dds":["dds"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.pco.b16":["b16"],"image/vnd.tencent.tap":["tap"],"image/vnd.valve.source.texture":["vtf"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/vnd.zbrush.pcx":["pcx"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["*ico"],"image/x-jng":["jng"],"image/x-mrsid-image":["sid"],"image/x-ms-bmp":["*bmp"],"image/x-pcx":["*pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/vnd.wfa.wsc":["wsc"],"model/vnd.cld":["cld"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.opengex":["ogex"],"model/vnd.parasolid.transmit.binary":["x_b"],"model/vnd.parasolid.transmit.text":["x_t"],"model/vnd.pytha.pyox":["pyo","pyox"],"model/vnd.sap.vds":["vds"],"model/vnd.usda":["usda"],"model/vnd.usdz+zip":["usdz"],"model/vnd.valve.source.compiled-map":["bsp"],"model/vnd.vtu":["vtu"],"text/prs.lines.tag":["dsc"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.familysearch.gedcom":["ged"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-org":["*org"],"text/x-pascal":["p","pas"],"text/x-processing":["pde"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-suse-ymp":["ymp"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]};Object.freeze(VC);var FC=VC;var zC={"application/andrew-inset":["ez"],"application/appinstaller":["appinstaller"],"application/applixware":["aw"],"application/appx":["appx"],"application/appxbundle":["appxbundle"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomdeleted+xml":["atomdeleted"],"application/atomsvc+xml":["atomsvc"],"application/atsc-dwd+xml":["dwd"],"application/atsc-held+xml":["held"],"application/atsc-rsat+xml":["rsat"],"application/automationml-aml+xml":["aml"],"application/automationml-amlx+zip":["amlx"],"application/bdoc":["bdoc"],"application/calendar+xml":["xcs"],"application/ccxml+xml":["ccxml"],"application/cdfx+xml":["cdfx"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cpl+xml":["cpl"],"application/cu-seeme":["cu"],"application/cwl":["cwl"],"application/dash+xml":["mpd"],"application/dash-patch+xml":["mpp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/emotionml+xml":["emotionml"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/express":["exp"],"application/fdf":["fdf"],"application/fdt+xml":["fdt"],"application/font-tdpfr":["pfr"],"application/geo+json":["geojson"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/gzip":["gz"],"application/hjson":["hjson"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/its+xml":["its"],"application/java-archive":["jar","war","ear"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["*js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/ld+json":["jsonld"],"application/lgr+xml":["lgr"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/manifest+json":["webmanifest"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/media-policy-dataset+xml":["mpf"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mmt-aei+xml":["maei"],"application/mmt-usd+xml":["musd"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["*mp4","*mpg4","mp4s","m4p"],"application/msix":["msix"],"application/msixbundle":["msixbundle"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/n-quads":["nq"],"application/n-triples":["nt"],"application/node":["cjs"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","exe","dll","deb","dmg","iso","img","msi","msp","msm","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/p2p-overlay+xml":["relo"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-keys":["asc"],"application/pgp-signature":["sig","*asc"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/provenance+xml":["provx"],"application/pskc+xml":["pskcxml"],"application/raml+yaml":["raml"],"application/rdf+xml":["rdf","owl"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/route-apd+xml":["rapd"],"application/route-s-tsid+xml":["sls"],"application/route-usd+xml":["rusd"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/senml+xml":["senmlx"],"application/sensml+xml":["sensmlx"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/sieve":["siv","sieve"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/sql":["sql"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/swid+xml":["swidtag"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/toml":["toml"],"application/trig":["trig"],"application/ttml+xml":["ttml"],"application/ubjson":["ubj"],"application/urc-ressheet+xml":["rsheet"],"application/urc-targetdesc+xml":["td"],"application/voicexml+xml":["vxml"],"application/wasm":["wasm"],"application/watcherinfo+xml":["wif"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/xaml+xml":["xaml"],"application/xcap-att+xml":["xav"],"application/xcap-caps+xml":["xca"],"application/xcap-diff+xml":["xdf"],"application/xcap-el+xml":["xel"],"application/xcap-ns+xml":["xns"],"application/xenc+xml":["xenc"],"application/xfdf":["xfdf"],"application/xhtml+xml":["xhtml","xht"],"application/xliff+xml":["xlf"],"application/xml":["xml","xsl","xsd","rng"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["*xsl","xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/3gpp":["*3gpp"],"audio/aac":["adts","aac"],"audio/adpcm":["adp"],"audio/amr":["amr"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mobile-xmf":["mxmf"],"audio/mp3":["*mp3"],"audio/mp4":["m4a","mp4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx","opus"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/wav":["wav"],"audio/wave":["*wav"],"audio/webm":["weba"],"audio/xm":["xm"],"font/collection":["ttc"],"font/otf":["otf"],"font/ttf":["ttf"],"font/woff":["woff"],"font/woff2":["woff2"],"image/aces":["exr"],"image/apng":["apng"],"image/avci":["avci"],"image/avcs":["avcs"],"image/avif":["avif"],"image/bmp":["bmp","dib"],"image/cgm":["cgm"],"image/dicom-rle":["drle"],"image/dpx":["dpx"],"image/emf":["emf"],"image/fits":["fits"],"image/g3fax":["g3"],"image/gif":["gif"],"image/heic":["heic"],"image/heic-sequence":["heics"],"image/heif":["heif"],"image/heif-sequence":["heifs"],"image/hej2k":["hej2"],"image/hsj2":["hsj2"],"image/ief":["ief"],"image/jls":["jls"],"image/jp2":["jp2","jpg2"],"image/jpeg":["jpeg","jpg","jpe"],"image/jph":["jph"],"image/jphc":["jhc"],"image/jpm":["jpm","jpgm"],"image/jpx":["jpx","jpf"],"image/jxr":["jxr"],"image/jxra":["jxra"],"image/jxrs":["jxrs"],"image/jxs":["jxs"],"image/jxsc":["jxsc"],"image/jxsi":["jxsi"],"image/jxss":["jxss"],"image/ktx":["ktx"],"image/ktx2":["ktx2"],"image/png":["png"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/t38":["t38"],"image/tiff":["tif","tiff"],"image/tiff-fx":["tfx"],"image/webp":["webp"],"image/wmf":["wmf"],"message/disposition-notification":["disposition-notification"],"message/global":["u8msg"],"message/global-delivery-status":["u8dsn"],"message/global-disposition-notification":["u8mdn"],"message/global-headers":["u8hdr"],"message/rfc822":["eml","mime"],"model/3mf":["3mf"],"model/gltf+json":["gltf"],"model/gltf-binary":["glb"],"model/iges":["igs","iges"],"model/jt":["jt"],"model/mesh":["msh","mesh","silo"],"model/mtl":["mtl"],"model/obj":["obj"],"model/prc":["prc"],"model/step+xml":["stpx"],"model/step+zip":["stpz"],"model/step-xml+zip":["stpxz"],"model/stl":["stl"],"model/u3d":["u3d"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["*x3db","x3dbz"],"model/x3d+fastinfoset":["x3db"],"model/x3d+vrml":["*x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"model/x3d-vrml":["x3dv"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee","litcoffee"],"text/css":["css"],"text/csv":["csv"],"text/html":["html","htm","shtml"],"text/jade":["jade"],"text/javascript":["js","mjs"],"text/jsx":["jsx"],"text/less":["less"],"text/markdown":["md","markdown"],"text/mathml":["mml"],"text/mdx":["mdx"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/richtext":["rtx"],"text/rtf":["*rtf"],"text/sgml":["sgml","sgm"],"text/shex":["shex"],"text/slim":["slim","slm"],"text/spdx":["spdx"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vtt":["vtt"],"text/wgsl":["wgsl"],"text/xml":["*xml"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp","3gpp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/iso.segment":["m4s"],"video/jpeg":["jpgv"],"video/jpm":["*jpm","*jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/webm":["webm"]};Object.freeze(zC);var UC=zC;var Ln=function(t,e,n,i){if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?i:n==="a"?i.call(t):i?i.value:e.get(t)},co,yu,Fs,lb=class{constructor(...e){co.set(this,new Map),yu.set(this,new Map),Fs.set(this,new Map);for(let n of e)this.define(n)}define(e,n=!1){for(let[i,r]of Object.entries(e)){i=i.toLowerCase(),r=r.map(o=>o.toLowerCase()),Ln(this,Fs,"f").has(i)||Ln(this,Fs,"f").set(i,new Set);let s=Ln(this,Fs,"f").get(i),a=!0;for(let o of r){let l=o.startsWith("*");if(o=l?o.slice(1):o,s?.add(o),a&&Ln(this,yu,"f").set(i,o),a=!1,l)continue;let c=Ln(this,co,"f").get(o);if(c&&c!=i&&!n)throw new Error(`"${i} -> ${o}" conflicts with "${c} -> ${o}". Pass \`force=true\` to override this definition.`);Ln(this,co,"f").set(o,i)}}return this}getType(e){if(typeof e!="string")return null;let n=e.replace(/^.*[/\\]/,"").toLowerCase(),i=n.replace(/^.*\./,"").toLowerCase(),r=n.length{throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances")},Object.freeze(this);for(let e of Ln(this,Fs,"f").values())Object.freeze(e);return this}_getTestState(){return{types:Ln(this,co,"f"),extensions:Ln(this,yu,"f")}}};co=new WeakMap,yu=new WeakMap,Fs=new WeakMap;var cb=lb;var ub=new cb(UC,FC)._freeze();var ir=require("obsidian");var _u=require("obsidian");async function jC(t,e,n){let i=document.createElement("canvas"),{videoWidth:r,videoHeight:s}=t;Object.assign(i,{width:r,height:s});let a=i.getContext("2d",{alpha:!1});if(!a)throw new Error("Canvas context creation failed");a.drawImage(t,0,0,r,s);let o=await new Promise((c,u)=>{try{i.toBlob(d=>{d?c(d):u(new Error("Canvas to blob failed"))},e,n)}catch(d){u(d)}}),l=await o.arrayBuffer();return{time:t.currentTime,blob:{arrayBuffer:l,type:o.type}}}function zs(t){return io(t)||t instanceof Rn}async function wu(t,e,n){let i=_u.Platform.isSafari&&e==="image/webp"?"image/jpeg":e;try{if(io(t))return await jC(t.video,i,n);if(t instanceof Rn)return await t.media.methods.screenshot(i,n);throw new Error("Unsupported provider for screenshot")}catch(r){throw r instanceof DOMException&&r.name==="SecurityError"?new _u.Notice("Cannot take screenshot due to CORS restriction, you can try open media as webpage to bypass this"):new _u.Notice("Cannot take screenshot: "+(r instanceof Error?r.message:String(r))),r}}var HC=require("obsidian");function zf({timestamp:t,screenshot:e},{template:n,editor:i,insertBefore:r}){console.debug("insert timestamp",{timestamp:t,screenshot:e,template:n});let s=n.replace("{{TIMESTAMP}}",t);e&&(s=s.replace("{{SCREENSHOT}}",e)),console.debug("content to insert",s);try{console.debug(`inserting timestamp ${r?"before":"after"} cursor`),r?PF(s,i):SF(s,i)}catch(a){new HC.Notice("Failed to insert timestamp, see console for details"),console.error("Failed to insert timestamp",a)}}function SF(t,e){let n=e.getCursor("to");console.debug("insert to cursor [to]",n.ch,n.line),e.replaceRange(t,n,n),e.setCursor(e.offsetToPos(e.posToOffset(n)+t.length))}function PF(t,e){let n=e.getCursor("from");console.debug("insert before cursor [from]",n.ch,n.line),e.replaceRange(t,n,n)}function qC(t){return t.file.basename}function BC({source:t},e){return e.title??t.hostname+decodeURI(t.pathname).replaceAll("/","_")}function WC(t,e){return Mi(t)?qC(t):BC(t,e)}function uo(t,e){let{metadataCache:n}=e.plugin.app,i=e.store.getState().player;if(!i)throw new Error("Player not initialized");if(Mi(t)){let{file:r,type:s}=t;return e.plugin.leafOpener.openNote(t,{title:qC(t),fm:a=>({[s]:`[[${n.fileToLinktext(r,a)}]]`}),sourcePath:r.path})}else return e.plugin.leafOpener.openNote(t,{title:BC(t,i.state),fm:()=>({media:t.jsonState.source})})}function Uf(t,e,{app:{fileManager:n},settings:{timestampOffset:i},state:{duration:r}}){t+=i,t<0&&(t=0),r&&t>r&&(t=r);let s=Cf(t),a=t>0?`#${tb({start:t,end:-1})}`:"";if(Mi(e)){let{file:o}=e;return l=>n.generateMarkdownLink(o,l,a,s).replace(/^!/,"")}else{let o=e.jsonState.source;return()=>`[${s}](${o}${a})`}}function jf(t){let e=t.store.getState().player;if(!e)return new ir.Notice("Player not initialized"),!1;let n=t.getMediaInfo();return n?!e?.provider||!zs(e.provider)?(new ir.Notice("Screenshot is not supported for this media"),!1):{media:n,provider:e.provider,state:e.state,app:t.plugin.app,settings:t.plugin.settings.getState()}:(new ir.Notice("No media is opened"),!1)}async function bu(t,{file:e,editor:n}){let i=jf(t);if(!i)return!1;let{provider:r,state:s,media:a,app:{fileManager:o,vault:l},settings:{insertBefore:c,screenshotTemplate:u,screenshotEmbedTemplate:d,screenshotQuality:p,screenshotFormat:h}}=i,{blob:y,time:v}=await wu(r,h,p),w=Uf(v,a,i),m=ub.getExtension(y.type);if(!m)return new ir.Notice("Unknown mime type: "+y.type),!1;let f=WC(a,s),g=Wo(f,{replacement:"_"})+X1(v),x=v>0?` - ${Cf(v)}`:"",T=await o.getAvailablePathForAttachment(`${g}.${m}`,e.path),L=await l.createBinary(T,y.arrayBuffer);new ir.Notice("Screenshot saved to "+L.path);try{return zf({timestamp:w(e.path),screenshot:o.generateMarkdownLink(L,e.path,"",d.replaceAll("{{TITLE}}",f).replaceAll("{{DURATION}}",x)).replace(/^!/,"")},{editor:n,template:u,insertBefore:c}),!0}catch(R){return new ir.Notice("Failed to insert screenshot, see console for details"),console.error("Failed to insert screenshot",R),!1}}async function xu(t){let{provider:e}=t,{blob:{arrayBuffer:n,type:i}}=await wu(e,"image/png",void 0),r;try{r=new ClipboardItem({[i]:new Blob([n],{type:i})})}catch(s){return new ir.Notice("Failed to copy screenshot, see console for details"),console.error("Failed to copy screenshot",s),!1}await navigator.clipboard.write([r]),new ir.Notice("Screenshot copied to clipboard")}var ku=require("obsidian");async function Eu(t,{file:e,editor:n}){let i=t.store.getState().player;if(!i)return new ku.Notice("Player not initialized"),!1;let r=t.getMediaInfo();if(!r)return new ku.Notice("No media is opened"),!1;let s=i.currentTime,a=Uf(s,r,{app:t.plugin.app,settings:t.plugin.settings.getState(),state:i.state});if(s<=0)return new ku.Notice("Playback not started yet"),!1;let{insertBefore:o,timestampTemplate:l}=t.plugin.settings.getState();try{return zf({timestamp:a(e.path)},{editor:n,template:l,insertBefore:o}),!0}catch(c){return new ku.Notice("Failed to insert timestamp, see console for details"),console.error("Failed to insert timestamp",c),!1}}var KC=require("obsidian");function db(t){let e="mx:media-notetaking-notified";localStorage.getItem(e)||(new KC.Notice(createFragment(i=>{i.appendText(`You are taking ${t} from media player. By default, they will only be saved in the media note. `),i.createEl("p",{text:`To take ${t} or control playback from abritrary note, use command when focused on the note`}),i.createEl("p",{text:"PS: you can assign a hotkey to each command in the settings"}),i.appendText("Click to dismiss this notice.")}),0),localStorage.setItem(e,"1"))}function Hf(t){let e=Un(t);if(!e)return"";let{pathname:n}=e;if(!n)return"";let i=n.split("/").pop();return i?decodeURI(i.split(".").slice(0,-1).join(".")):""}function qf(t){t.addAction("star","Take timestamp in media note",()=>{let e=t.getMediaInfo();e&&(db("timestamp"),uo(e,t).then(n=>{Eu(t,n)}))}),t.getViewType()!==Ri&&t.addAction("camera","Take screenshot in media",()=>{let e=t.getMediaInfo();e&&(db("screenshot"),uo(e,t).then(n=>bu(t,n)))})}function Bf(t,e,n){let{player:i,source:r,toggleControls:s,controls:a,setTransform:o,transform:l,toggleWebFullscreen:c,disableWebFullscreen:u}=t.store.getState();!i||!r||t.plugin.app.workspace.trigger("mx-media-menu",e,{source:r.url,player:i,toggleControls:s,controls:a,setTransform:o,transform:l,plugin:t.plugin,disableWebFullscreen:u,toggleWebFullscreen:c,reload:()=>t.render()},n,t.leaf)}var pb=new WeakSet;function GC(t){t.subscribe((e,n)=>{e.player!==n.player&&Tu(e)}),t.subscribe((e,n)=>{let i=e.player;if(!i)return;let r=e.source,s=n.source;if(r===s)return;let a=r?.url,o=s?.url;a!==o&&(!a&&o!==void 0||a!==void 0&&!a.compare(o))&&pb.delete(i)})}async function Tu({player:t,hash:{tempFragment:e}}){if(!t||!e)return;let n=!pb.has(t);pb.add(t);let i=null,r=.25;if(kn(e)||t.currentTimee.end&&(i=e.end),i!==null){let s=i;t.currentTime=s,!t.state.canPlay&&["video/youtube"].includes(t.state.source.type)&&!t.state.autoPlay&&(await CF(t,"seeked"),await t.pause())}kn(e)&&t.state.canPlay&&!n&&await t.play(new Event("hashchange"))}function CF(t,e){return new Promise(n=>{let i=window.setTimeout(()=>{n(),r()},5e3),r=t.listen(e,()=>{n(),window.clearTimeout(i),r()})})}function Ur(){let t=Tp((e,n,i)=>({player:null,playerRef:r=>e({player:r}),source:void 0,hash:{autoplay:void 0,controls:void 0,loop:void 0,muted:void 0,tempFragment:null,volume:void 0},async getPlayer(r=1e4){let{player:s}=n();return s||new Promise((a,o)=>{let l=i.subscribe(({player:u})=>{u&&(l(),a(u),window.clearTimeout(c))}),c=window.setTimeout(()=>{l(),o(new ji(r))},r)})},setSource(r,{hash:s,enableWebview:a,title:o,type:l,textTracks:c}={}){e(u=>({source:{...u.source,type:l??u.source?.type,url:r,enableWebview:a??u.source?.enableWebview},textTracks:c??u.textTracks,hash:{...u.hash,...Cp(s||r.hash)},title:(o===!0?Hf(r.source.href):o)??u.title})),Tu(n())},setHash(r){e(s=>({hash:{...s.hash,...Cp(r)}})),Tu(n())},async loadFile(r,{vault:s,subpath:a,defaultLang:o}){let l=await OC(r,s,o);e(({source:c,hash:u})=>({source:{...c,url:gC(r,s)},textTracks:l,title:r.name,hash:a?{...u,...Cp(a)}:u})),await Tu(n())},title:"",transform:null,setTransform:r=>{e(r?s=>{let a={transform:{...s.transform,...r}};return a.transform.flipHorizontal&&a.transform.flipVertical&&a.transform.rotate==="180"&&(a.transform={...a.transform,flipHorizontal:!1,flipVertical:!1,rotate:void 0}),a}:{transform:null})},toggleControls(r){let{player:s}=n();e({controls:r}),s&&s.provider instanceof Rn&&s.provider.media.send("mx-toggle-controls",!r)},toggleWebFullscreen(r){let{player:s}=n();e({disableWebFullscreen:!r}),s&&s.provider instanceof Rn&&s.provider.media.send("mx-toggle-webfs",r)},textTracks:[],updateWebHost:r=>e({webHost:r==="generic"?void 0:r})}));return GC(t),t}var wt=(0,ni.createContext)(null);function Nt(t){let{store:e}=(0,ni.useContext)(wt);return Ly(e,t)}function Us(t){let{plugin:{settings:e}}=(0,ni.useContext)(wt);return Ly(e,t)}function Wf(){let{store:t}=(0,ni.useContext)(wt);return t}function YC(){return(0,ni.useContext)(wt).reload}function Kf(t){let e=(0,ni.useContext)(wt).plugin.app;return t?t(e):e}function QC(){return(0,ni.useContext)(wt).plugin}function XC(){return(0,ni.useContext)(wt).onScreenshot}var po=()=>(0,ni.useContext)(wt).embed;function Su(t,e){let n=jl,i=[()=>n(),t.subscribe((r,s)=>{if(r.player===s.player||(n(),!r.player))return;let a=e(r.player);a?Array.isArray(a)?n=()=>a.forEach(o=>o()):n=a:n=jl})];return()=>i.forEach(r=>r())}var SM=require("obsidian"),PM=$(z());var ZC=$(z());function JC(){let t=ki(),e=Wf();(0,ZC.useEffect)(()=>{if(t)return $F(t,e)},[t,e])}function $F(t,e){if(localStorage.getItem("MX_DEV_DISABLE_WEBVIEW_TEMP_FRAG")==="1"&&Mf(t.state.source.src)){console.log("DEV: temporal fragment handling in webpage disabled");return}let n={currentTime:t.state.currentTime,paused:t.state.paused,loop:t.state.loop},i=!1,r=[t.subscribe(({currentTime:s,paused:a,loop:o})=>{let l=MF(e.getState().hash.tempFragment,t.state.duration);if(!l||kn(l))return;let{start:c,end:u}=l;if(n.paused!==a&&!a)(s>u||su)if(o)t.currentTime=c,a&&t.play();else{if(i){i=!1;return}a||t.pause()}}Object.assign(n,{currentTime:s,paused:a,loop:o})})];return()=>r.forEach(s=>s())}function MF(t,e){if(!t)return null;if(kn(t))return t;let{start:n,end:i}=t;return e&&ea(s))?.classGroupId}var n$=/^\[(.+)\]$/;function LF(t){if(n$.test(t)){let e=n$.exec(t)[1],n=e?.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}}function IF(t){let{theme:e,prefix:n}=t,i={nextPart:new Map,validators:[]};return NF(Object.entries(t.classGroups),n).forEach(([s,a])=>{hb(a,i,s,e)}),i}function hb(t,e,n,i){t.forEach(r=>{if(typeof r=="string"){let s=r===""?e:i$(e,r);s.classGroupId=n;return}if(typeof r=="function"){if(AF(r)){hb(r(i),e,n,i);return}e.validators.push({validator:r,classGroupId:n});return}Object.entries(r).forEach(([s,a])=>{hb(a,i$(e,s),n,i)})})}function i$(t,e){let n=t;return e.split(fb).forEach(i=>{n.nextPart.has(i)||n.nextPart.set(i,{nextPart:new Map,validators:[]}),n=n.nextPart.get(i)}),n}function AF(t){return t.isThemeGetter}function NF(t,e){return e?t.map(([n,i])=>{let r=i.map(s=>typeof s=="string"?e+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([a,o])=>[e+a,o])):s);return[n,r]}):t}function DF(t){if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,i=new Map;function r(s,a){n.set(s,a),e++,e>t&&(e=0,i=n,n=new Map)}return{get(s){let a=n.get(s);if(a!==void 0)return a;if((a=i.get(s))!==void 0)return r(s,a),a},set(s,a){n.has(s)?n.set(s,a):r(s,a)}}}var s$="!";function OF(t){let e=t.separator,n=e.length===1,i=e[0],r=e.length;return function(a){let o=[],l=0,c=0,u;for(let v=0;vc?u-c:void 0;return{modifiers:o,hasImportantModifier:p,baseClassName:h,maybePostfixModifierPosition:y}}}function VF(t){if(t.length<=1)return t;let e=[],n=[];return t.forEach(i=>{i[0]==="["?(e.push(...n.sort(),i),n=[]):n.push(i)}),e.push(...n.sort()),e}function FF(t){return{cache:DF(t.cacheSize),splitModifiers:OF(t),...RF(t)}}var zF=/\s+/;function UF(t,e){let{splitModifiers:n,getClassGroupId:i,getConflictingClassGroupIds:r}=e,s=new Set;return t.trim().split(zF).map(a=>{let{modifiers:o,hasImportantModifier:l,baseClassName:c,maybePostfixModifierPosition:u}=n(a),d=i(u?c.substring(0,u):c),p=!!u;if(!d){if(!u)return{isTailwindClass:!1,originalClassName:a};if(d=i(c),!d)return{isTailwindClass:!1,originalClassName:a};p=!1}let h=VF(o).join(":");return{isTailwindClass:!0,modifierId:l?h+s$:h,classGroupId:d,originalClassName:a,hasPostfixModifier:p}}).reverse().filter(a=>{if(!a.isTailwindClass)return!0;let{modifierId:o,classGroupId:l,hasPostfixModifier:c}=a,u=o+l;return s.has(u)?!1:(s.add(u),r(l,c).forEach(d=>s.add(o+d)),!0)}).reverse().map(a=>a.originalClassName).join(" ")}function jF(){let t=0,e,n,i="";for(;td(u),t());return n=FF(c),i=n.cache.get,r=n.cache.set,s=o,o(l)}function o(l){let c=i(l);if(c)return c;let u=UF(l,n);return r(l,u),u}return function(){return s(jF.apply(null,arguments))}}function Te(t){let e=n=>n[t]||[];return e.isThemeGetter=!0,e}var o$=/^\[(?:([a-z-]+):)?(.+)\]$/i,qF=/^\d+\/\d+$/,BF=new Set(["px","full","screen"]),WF=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,KF=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,GF=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,YF=/^-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,QF=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/;function rr(t){return js(t)||BF.has(t)||qF.test(t)}function jr(t){return ho(t,"length",r5)}function js(t){return!!t&&!Number.isNaN(Number(t))}function Gf(t){return ho(t,"number",js)}function Pu(t){return!!t&&Number.isInteger(Number(t))}function XF(t){return t.endsWith("%")&&js(t.slice(0,-1))}function Q(t){return o$.test(t)}function Hr(t){return WF.test(t)}var ZF=new Set(["length","size","percentage"]);function JF(t){return ho(t,ZF,l$)}function e5(t){return ho(t,"position",l$)}var t5=new Set(["image","url"]);function n5(t){return ho(t,t5,a5)}function i5(t){return ho(t,"",s5)}function Cu(){return!0}function ho(t,e,n){let i=o$.exec(t);return i?i[1]?typeof e=="string"?i[1]===e:e.has(i[1]):n(i[2]):!1}function r5(t){return KF.test(t)&&!GF.test(t)}function l$(){return!1}function s5(t){return YF.test(t)}function a5(t){return QF.test(t)}function o5(){let t=Te("colors"),e=Te("spacing"),n=Te("blur"),i=Te("brightness"),r=Te("borderColor"),s=Te("borderRadius"),a=Te("borderSpacing"),o=Te("borderWidth"),l=Te("contrast"),c=Te("grayscale"),u=Te("hueRotate"),d=Te("invert"),p=Te("gap"),h=Te("gradientColorStops"),y=Te("gradientColorStopPositions"),v=Te("inset"),w=Te("margin"),m=Te("opacity"),f=Te("padding"),g=Te("saturate"),x=Te("scale"),T=Te("sepia"),L=Te("skew"),R=Te("space"),I=Te("translate"),K=()=>["auto","contain","none"],H=()=>["auto","hidden","clip","visible","scroll"],_e=()=>["auto",Q,e],J=()=>[Q,e],or=()=>["",rr,jr],Ce=()=>["auto",js,Q],bt=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Ci=()=>["solid","dashed","dotted","double","none"],Ho=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","plus-lighter"],ts=()=>["start","end","center","between","around","evenly","stretch"],Vn=()=>["","0",Q],$i=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Qt=()=>[js,Gf],ns=()=>[js,Q];return{cacheSize:500,separator:":",theme:{colors:[Cu],spacing:[rr,jr],blur:["none","",Hr,Q],brightness:Qt(),borderColor:[t],borderRadius:["none","","full",Hr,Q],borderSpacing:J(),borderWidth:or(),contrast:Qt(),grayscale:Vn(),hueRotate:ns(),invert:Vn(),gap:J(),gradientColorStops:[t],gradientColorStopPositions:[XF,jr],inset:_e(),margin:_e(),opacity:Qt(),padding:J(),saturate:Qt(),scale:Qt(),sepia:Vn(),skew:ns(),space:J(),translate:J()},classGroups:{aspect:[{aspect:["auto","square","video",Q]}],container:["container"],columns:[{columns:[Hr]}],"break-after":[{"break-after":$i()}],"break-before":[{"break-before":$i()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...bt(),Q]}],overflow:[{overflow:H()}],"overflow-x":[{"overflow-x":H()}],"overflow-y":[{"overflow-y":H()}],overscroll:[{overscroll:K()}],"overscroll-x":[{"overscroll-x":K()}],"overscroll-y":[{"overscroll-y":K()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[v]}],"inset-x":[{"inset-x":[v]}],"inset-y":[{"inset-y":[v]}],start:[{start:[v]}],end:[{end:[v]}],top:[{top:[v]}],right:[{right:[v]}],bottom:[{bottom:[v]}],left:[{left:[v]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Pu,Q]}],basis:[{basis:_e()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Q]}],grow:[{grow:Vn()}],shrink:[{shrink:Vn()}],order:[{order:["first","last","none",Pu,Q]}],"grid-cols":[{"grid-cols":[Cu]}],"col-start-end":[{col:["auto",{span:["full",Pu,Q]},Q]}],"col-start":[{"col-start":Ce()}],"col-end":[{"col-end":Ce()}],"grid-rows":[{"grid-rows":[Cu]}],"row-start-end":[{row:["auto",{span:[Pu,Q]},Q]}],"row-start":[{"row-start":Ce()}],"row-end":[{"row-end":Ce()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Q]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Q]}],gap:[{gap:[p]}],"gap-x":[{"gap-x":[p]}],"gap-y":[{"gap-y":[p]}],"justify-content":[{justify:["normal",...ts()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ts(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ts(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[f]}],px:[{px:[f]}],py:[{py:[f]}],ps:[{ps:[f]}],pe:[{pe:[f]}],pt:[{pt:[f]}],pr:[{pr:[f]}],pb:[{pb:[f]}],pl:[{pl:[f]}],m:[{m:[w]}],mx:[{mx:[w]}],my:[{my:[w]}],ms:[{ms:[w]}],me:[{me:[w]}],mt:[{mt:[w]}],mr:[{mr:[w]}],mb:[{mb:[w]}],ml:[{ml:[w]}],"space-x":[{"space-x":[R]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[R]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Q,e]}],"min-w":[{"min-w":[Q,e,"min","max","fit"]}],"max-w":[{"max-w":[Q,e,"none","full","min","max","fit","prose",{screen:[Hr]},Hr]}],h:[{h:[Q,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Q,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Q,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Q,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Hr,jr]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Gf]}],"font-family":[{font:[Cu]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",Q]}],"line-clamp":[{"line-clamp":["none",js,Gf]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",rr,Q]}],"list-image":[{"list-image":["none",Q]}],"list-style-type":[{list:["none","disc","decimal",Q]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[m]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[m]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Ci(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",rr,jr]}],"underline-offset":[{"underline-offset":["auto",rr,Q]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:J()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Q]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Q]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[m]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...bt(),e5]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",JF]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},n5]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[y]}],"gradient-via-pos":[{via:[y]}],"gradient-to-pos":[{to:[y]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[o]}],"border-w-x":[{"border-x":[o]}],"border-w-y":[{"border-y":[o]}],"border-w-s":[{"border-s":[o]}],"border-w-e":[{"border-e":[o]}],"border-w-t":[{"border-t":[o]}],"border-w-r":[{"border-r":[o]}],"border-w-b":[{"border-b":[o]}],"border-w-l":[{"border-l":[o]}],"border-opacity":[{"border-opacity":[m]}],"border-style":[{border:[...Ci(),"hidden"]}],"divide-x":[{"divide-x":[o]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[o]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[m]}],"divide-style":[{divide:Ci()}],"border-color":[{border:[r]}],"border-color-x":[{"border-x":[r]}],"border-color-y":[{"border-y":[r]}],"border-color-t":[{"border-t":[r]}],"border-color-r":[{"border-r":[r]}],"border-color-b":[{"border-b":[r]}],"border-color-l":[{"border-l":[r]}],"divide-color":[{divide:[r]}],"outline-style":[{outline:["",...Ci()]}],"outline-offset":[{"outline-offset":[rr,Q]}],"outline-w":[{outline:[rr,jr]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:or()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[m]}],"ring-offset-w":[{"ring-offset":[rr,jr]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Hr,i5]}],"shadow-color":[{shadow:[Cu]}],opacity:[{opacity:[m]}],"mix-blend":[{"mix-blend":Ho()}],"bg-blend":[{"bg-blend":Ho()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[i]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Hr,Q]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[d]}],saturate:[{saturate:[g]}],sepia:[{sepia:[T]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[i]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[m]}],"backdrop-saturate":[{"backdrop-saturate":[g]}],"backdrop-sepia":[{"backdrop-sepia":[T]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[a]}],"border-spacing-x":[{"border-spacing-x":[a]}],"border-spacing-y":[{"border-spacing-y":[a]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",Q]}],duration:[{duration:ns()}],ease:[{ease:["linear","in","out","in-out",Q]}],delay:[{delay:ns()}],animate:[{animate:["none","spin","ping","pulse","bounce",Q]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[x]}],"scale-x":[{"scale-x":[x]}],"scale-y":[{"scale-y":[x]}],rotate:[{rotate:[Pu,Q]}],"translate-x":[{"translate-x":[I]}],"translate-y":[{"translate-y":[I]}],"skew-x":[{"skew-x":[L]}],"skew-y":[{"skew-y":[L]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Q]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Q]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":J()}],"scroll-mx":[{"scroll-mx":J()}],"scroll-my":[{"scroll-my":J()}],"scroll-ms":[{"scroll-ms":J()}],"scroll-me":[{"scroll-me":J()}],"scroll-mt":[{"scroll-mt":J()}],"scroll-mr":[{"scroll-mr":J()}],"scroll-mb":[{"scroll-mb":J()}],"scroll-ml":[{"scroll-ml":J()}],"scroll-p":[{"scroll-p":J()}],"scroll-px":[{"scroll-px":J()}],"scroll-py":[{"scroll-py":J()}],"scroll-ps":[{"scroll-ps":J()}],"scroll-pe":[{"scroll-pe":J()}],"scroll-pt":[{"scroll-pt":J()}],"scroll-pr":[{"scroll-pr":J()}],"scroll-pb":[{"scroll-pb":J()}],"scroll-pl":[{"scroll-pl":J()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Q]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[rr,jr,Gf]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}}var c$=HF(o5);function In(...t){return c$(t$(t))}var u$=$(z());function d$(t){let e=ki();(0,u$.useEffect)(()=>{if(e)return e.listen("loaded-metadata",n=>{let i=n.target;if(!io(i.provider)){t("unknown");return}let{videoHeight:r,videoWidth:s}=i.provider.video;t(r===0||s===0?"audio":"unknown")})},[e])}var Yf=$(z());function Qf(){let{controls:t}=mb(),e=Nt(r=>r.controls);return e===void 0&&t===void 0?!0:e||t}function mb(){let{volume:t,tempFragment:e,...n}=Nt(i=>i.hash);return n}function p$(){let t=ki(),{volume:e}=Nt(s=>s.hash),n=Us(s=>s.defaultVolume/100),i=e??n,r=(0,Yf.useRef)(i);r.current=i,(0,Yf.useEffect)(()=>t?.subscribe(({canPlay:s})=>{s&&(t.volume=r.current)}),[t])}function Ke(){return Ke=Object.assign?Object.assign.bind():function(t){for(var e=1;et.forEach(n=>l5(n,e))}function Ti(...t){return(0,h$.useCallback)(gb(...t),t)}var ii=$(z(),1);function qr(t,e=[]){let n=[];function i(s,a){let o=(0,ii.createContext)(a),l=n.length;n=[...n,a];function c(d){let{scope:p,children:h,...y}=d,v=p?.[t][l]||o,w=(0,ii.useMemo)(()=>y,Object.values(y));return(0,ii.createElement)(v.Provider,{value:w},h)}function u(d,p){let h=p?.[t][l]||o,y=(0,ii.useContext)(h);if(y)return y;if(a!==void 0)return a;throw new Error(`\`${d}\` must be used within \`${s}\``)}return c.displayName=s+"Provider",[c,u]}let r=()=>{let s=n.map(a=>(0,ii.createContext)(a));return function(o){let l=o?.[t]||s;return(0,ii.useMemo)(()=>({[`__scope${t}`]:{...o,[t]:l}}),[o,l])}};return r.scopeName=t,[i,c5(r,...e)]}function c5(...t){let e=t[0];if(t.length===1)return e;let n=()=>{let i=t.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(s){let a=i.reduce((o,{useScope:l,scopeName:c})=>{let d=l(s)[`__scope${c}`];return{...o,...d}},{});return(0,ii.useMemo)(()=>({[`__scope${e.scopeName}`]:a}),[a])}};return n.scopeName=e.scopeName,n}var mo=$(z(),1),h5=$(Fl(),1);var Ne=$(z(),1);var fo=(0,Ne.forwardRef)((t,e)=>{let{children:n,...i}=t,r=Ne.Children.toArray(n),s=r.find(d5);if(s){let a=s.props.children,o=r.map(l=>l===s?Ne.Children.count(a)>1?Ne.Children.only(null):(0,Ne.isValidElement)(a)?a.props.children:null:l);return(0,Ne.createElement)(vb,Ke({},i,{ref:e}),(0,Ne.isValidElement)(a)?(0,Ne.cloneElement)(a,void 0,o):null)}return(0,Ne.createElement)(vb,Ke({},i,{ref:e}),n)});fo.displayName="Slot";var vb=(0,Ne.forwardRef)((t,e)=>{let{children:n,...i}=t;return(0,Ne.isValidElement)(n)?(0,Ne.cloneElement)(n,{...p5(i,n.props),ref:e?gb(e,n.ref):n.ref}):Ne.Children.count(n)>1?Ne.Children.only(null):null});vb.displayName="SlotClone";var u5=({children:t})=>(0,Ne.createElement)(Ne.Fragment,null,t);function d5(t){return(0,Ne.isValidElement)(t)&&t.type===u5}function p5(t,e){let n={...e};for(let i in e){let r=t[i],s=e[i];/^on[A-Z]/.test(i)?r&&s?n[i]=(...o)=>{s(...o),r(...o)}:r&&(n[i]=r):i==="style"?n[i]={...r,...s}:i==="className"&&(n[i]=[r,s].filter(Boolean).join(" "))}return{...t,...n}}var f5=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],$u=f5.reduce((t,e)=>{let n=(0,mo.forwardRef)((i,r)=>{let{asChild:s,...a}=i,o=s?fo:e;return(0,mo.useEffect)(()=>{window[Symbol.for("radix-ui")]=!0},[]),(0,mo.createElement)(o,Ke({},a,{ref:r}))});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});var go=$(z(),1);function yb(t){let e=(0,go.useRef)(t);return(0,go.useEffect)(()=>{e.current=t}),(0,go.useMemo)(()=>(...n)=>{var i;return(i=e.current)===null||i===void 0?void 0:i.call(e,...n)},[])}var f$=$(z(),1),m$=globalThis?.document?f$.useLayoutEffect:()=>{};var Mu=$(z(),1);var g$=$(z(),1);function v$(t){let[e,n]=(0,g$.useState)(void 0);return m$(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});let i=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;let s=r[0],a,o;if("borderBoxSize"in s){let l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;a=c.inlineSize,o=c.blockSize}else a=t.offsetWidth,o=t.offsetHeight;n({width:a,height:o})});return i.observe(t,{box:"border-box"}),()=>i.unobserve(t)}else n(void 0)},[t]),e}var y$="Popper",[_$,_b]=qr(y$),[EH,TH]=_$(y$);var m5="PopperContent",[SH,PH]=_$(m5);var Br=$(z(),1);function w$({prop:t,defaultProp:e,onChange:n=()=>{}}){let[i,r]=g5({defaultProp:e,onChange:n}),s=t!==void 0,a=s?t:i,o=yb(n),l=(0,Br.useCallback)(c=>{if(s){let d=typeof c=="function"?c(t):c;d!==t&&o(d)}else r(c)},[s,t,r,o]);return[a,l]}function g5({defaultProp:t,onChange:e}){let n=(0,Br.useState)(t),[i]=n,r=(0,Br.useRef)(i),s=yb(e);return(0,Br.useEffect)(()=>{r.current!==i&&(s(i),r.current=i)},[i,r,s]),n}var[Xf,VH]=qr("Tooltip",[_b]),FH=_b(),v5="TooltipProvider",y5=700;var[_5,zH]=Xf(v5),w5=t=>{let{__scopeTooltip:e,delayDuration:n=y5,skipDelayDuration:i=300,disableHoverableContent:r=!1,children:s}=t,[a,o]=(0,Dt.useState)(!0),l=(0,Dt.useRef)(!1),c=(0,Dt.useRef)(0);return(0,Dt.useEffect)(()=>{let u=c.current;return()=>window.clearTimeout(u)},[]),(0,Dt.createElement)(_5,{scope:e,isOpenDelayed:a,delayDuration:n,onOpen:(0,Dt.useCallback)(()=>{window.clearTimeout(c.current),o(!1)},[]),onClose:(0,Dt.useCallback)(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o(!0),i)},[i]),isPointerInTransitRef:l,onPointerInTransitChange:(0,Dt.useCallback)(u=>{l.current=u},[]),disableHoverableContent:r},s)},b$="Tooltip",[UH,jH]=Xf(b$);var b5="TooltipPortal",[HH,qH]=Xf(b5,{forceMount:void 0});var[BH,WH]=Xf(b$,{isInside:!1});var Zf=w5;var tm=$(z());var S$=require("obsidian"),em=$(z()),F$=$(ae());function C5(t){let e=(0,em.useRef)(null);return[(0,em.useCallback)(i=>{e.current&&e.current.empty(),i&&(0,S$.setIcon)(i,t),e.current=i},[t])]}function Ve(t){return function(n){let[i]=C5(t);return(0,F$.jsx)("div",{ref:i,...n})}}var P$=Ve("play"),C$=Ve("pause"),ZH=Ve("volume"),$$=Ve("volume-1"),M$=Ve("volume-2"),R$=Ve("volume-x"),L$=Ve("maximize"),I$=Ve("minimize"),$5=Ve("picture-in-picture-2"),M5=Ve("picture-in-picture"),wb=Ve("subtitles"),JH=Ve("check-circle"),eq=Ve("circle"),A$=Ve("fast-forward"),N$=Ve("rewind"),D$=Ve("edit"),O$=Ve("image-down"),R5=Ve("pin"),V$=Ve("more-horizontal"),tq=Ve("plus"),nq=Ve("trash");var Qe=$(ae()),Ru="group ring-mod-border-focus relative inline-flex h-10 w-10 cursor-pointer items-center justify-center rounded-md outline-none ring-inset hover:bg-white/20 focus-visible:ring-2 aria-disabled:hidden";function nm(){let t=ye("paused");return(0,Qe.jsx)(ff,{className:Ru,"aria-label":t?"Play":"Pause",children:t?(0,Qe.jsx)(P$,{className:"w-7 h-7 translate-x-px"}):(0,Qe.jsx)(C$,{className:"w-7 h-7"})})}function z$({seconds:t}){return(0,Qe.jsx)(lu,{className:Ru,seconds:t,"aria-label":`Fast forward ${t}s`,children:(0,Qe.jsx)(A$,{className:"w-7 h-7"})})}function U$({seconds:t}){return(0,Qe.jsx)(lu,{className:Ru,seconds:-t,"aria-label":`Rewind ${t}s`,children:(0,Qe.jsx)(N$,{className:"w-7 h-7"})})}function im(){let t=ye("volume"),e=ye("muted");return(0,Qe.jsx)(gf,{className:Ru,"aria-label":e?"Unmute":"Mute",children:e||t==0?(0,Qe.jsx)(R$,{className:"w-7 h-7"}):t<.5?(0,Qe.jsx)($$,{className:"w-7 h-7"}):(0,Qe.jsx)(M$,{className:"w-7 h-7"})})}function j$(){let t=ye("fullscreen");return(0,Qe.jsx)(mf,{className:Ru,"aria-label":t?"Exit fullscreen":"Enter fullscreen",children:t?(0,Qe.jsx)(I$,{className:"w-7 h-7"}):(0,Qe.jsx)(L$,{className:"w-7 h-7"})})}function rm(){return po()?(0,Qe.jsx)("button",{className:In("mx-lp-edit","group ring-mod-border-focus relative inline-flex h-10 w-10 cursor-pointer items-center justify-center rounded-md outline-none ring-inset hover:bg-white/20 focus-visible:ring-2 aria-disabled:hidden"),onClick:()=>{},[Wr]:!0,"aria-label":"Edit in editor",children:(0,Qe.jsx)(D$,{className:"w-7 h-7"})}):null}function L5(){let t=T1(),[e,n]=(0,tm.useState)(()=>zs(t)),i=XC(),r=Us(a=>a.screenshotFormat),s=Us(a=>a.screenshotQuality);return(0,tm.useEffect)(()=>{n(zs(t))},[t]),!e||!i||!t?null:async()=>{i(await wu(t,r,s))}}function H$(){let t=L5();return t?(0,Qe.jsx)("button",{className:"group ring-mod-border-focus relative inline-flex h-10 w-10 cursor-pointer items-center justify-center rounded-md outline-none ring-inset hover:bg-white/20 focus-visible:ring-2 aria-disabled:hidden",onClick:t,"aria-label":"Capture screenshot",children:(0,Qe.jsx)(O$,{className:"w-7 h-7"})}):null}var Wr="data-lp-pass-through";function ut(t,e){let n=Object.keys(e).map(i=>I5(t,i,e[i]));return n.length===1?n[0]:function(){n.forEach(i=>i())}}function I5(t,e,n){let i=t[e],r=t.hasOwnProperty(e),s=n(i);return i&&Object.setPrototypeOf(s,i),Object.setPrototypeOf(a,s),t[e]=a,o;function a(...l){return s===i&&t[e]===a&&o(),s.apply(this,l)}function o(){t[e]===a&&(r?t[e]=i:delete t[e]),s!==i&&(s=i,Object.setPrototypeOf(a,i||Function))}}var B$=require("obsidian"),W$=$(z());var Lu=$(ae());function K$(t){let e=(0,W$.useRef)(null);return n=>{e.current?.close(),e.current=null;let i=new B$.Menu;t(i)?(Qs(n.nativeEvent,i),n.nativeEvent.stopImmediatePropagation(),ut(i,{close:r=>function(...s){return e.current===this&&(e.current=null),r.call(this,...s)}}),e.current=i):i.close()}}function G$(){let t=Bw(),e=ye("textTracks"),n=K$(i=>(t.forEach(({label:r,select:s,selected:a},o,l)=>{i.addItem(c=>{l.length===2&&r==="Unknown"&&(r="On"),c.setTitle(r).setChecked(a).onClick(s)})}),!0));return e.length===0?null:(0,Lu.jsx)("button",{className:"group ring-mod-border-focus relative inline-flex h-10 w-10 cursor-pointer items-center justify-center rounded-md outline-none ring-inset hover:bg-white/20 focus-visible:ring-2 aria-disabled:hidden",[Wr]:!0,onClick:n,"aria-label":"Select Caption",children:(0,Lu.jsx)(wb,{className:"w-7 h-7"})})}function sm(){let t=ki(),e=Kf(l=>l.workspace),n=QC(),i=po(),r=YC(),s=Nt(l=>l.source?.url),a=Wf(),o=K$(l=>{if(!t||!s)return!1;let{toggleControls:c,controls:u,setTransform:d,transform:p,disableWebFullscreen:h,toggleWebFullscreen:y}=a.getState();return e.trigger("mx-media-menu",l,{player:t,reload:r,source:s,toggleControls:c,controls:u,setTransform:d,transform:p,plugin:n,disableWebFullscreen:h,toggleWebFullscreen:y},i?"player-menu-embed":"player-menu-view"),!0});return!t||!s?null:(0,Lu.jsx)("button",{className:"group ring-mod-border-focus relative inline-flex h-10 w-10 cursor-pointer items-center justify-center rounded-md outline-none ring-inset hover:bg-white/20 focus-visible:ring-2 aria-disabled:hidden",[Wr]:!0,onClick:o,"aria-label":"More options",children:(0,Lu.jsx)(V$,{className:"w-7 h-7"})})}var cm=$(z());var B=$(z(),1);function bb(t,[e,n]){return Math.min(n,Math.max(e,t))}var Iu=$(z(),1),A5=(0,Iu.createContext)(void 0);function Q$(t){let e=(0,Iu.useContext)(A5);return t||e||"ltr"}var am=$(z(),1);function X$(t){let e=(0,am.useRef)({value:t,previous:t});return(0,am.useMemo)(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var ri=$(z(),1);function Z$(t){let e=t+"CollectionProvider",[n,i]=qr(e),[r,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),a=h=>{let{scope:y,children:v}=h,w=ri.default.useRef(null),m=ri.default.useRef(new Map).current;return ri.default.createElement(r,{scope:y,itemMap:m,collectionRef:w},v)},o=t+"CollectionSlot",l=ri.default.forwardRef((h,y)=>{let{scope:v,children:w}=h,m=s(o,v),f=Ti(y,m.collectionRef);return ri.default.createElement(fo,{ref:f},w)}),c=t+"CollectionItemSlot",u="data-radix-collection-item",d=ri.default.forwardRef((h,y)=>{let{scope:v,children:w,...m}=h,f=ri.default.useRef(null),g=Ti(y,f),x=s(c,v);return ri.default.useEffect(()=>(x.itemMap.set(f,{ref:f,...m}),()=>void x.itemMap.delete(f))),ri.default.createElement(fo,{[u]:"",ref:g},w)});function p(h){let y=s(t+"CollectionConsumer",h);return ri.default.useCallback(()=>{let w=y.collectionRef.current;if(!w)return[];let m=Array.from(w.querySelectorAll(`[${u}]`));return Array.from(y.itemMap.values()).sort((x,T)=>m.indexOf(x.ref.current)-m.indexOf(T.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:a,Slot:l,ItemSlot:d},p,i]}var tM=["PageUp","PageDown"],nM=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],iM={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Au="Slider",[xb,N5,D5]=Z$(Au),[rM,zq]=qr(Au,[D5]),[O5,om]=rM(Au),V5=(0,B.forwardRef)((t,e)=>{let{name:n,min:i=0,max:r=100,step:s=1,orientation:a="horizontal",disabled:o=!1,minStepsBetweenThumbs:l=0,defaultValue:c=[i],value:u,onValueChange:d=()=>{},onValueCommit:p=()=>{},inverted:h=!1,...y}=t,[v,w]=(0,B.useState)(null),m=Ti(e,Ce=>w(Ce)),f=(0,B.useRef)(new Set),g=(0,B.useRef)(0),x=a==="horizontal",T=v?!!v.closest("form"):!0,L=x?F5:z5,[R=[],I]=w$({prop:u,defaultProp:c,onChange:Ce=>{var bt;(bt=[...f.current][g.current])===null||bt===void 0||bt.focus(),d(Ce)}}),K=(0,B.useRef)(R);function H(Ce){let bt=Y5(R,Ce);or(Ce,bt)}function _e(Ce){or(Ce,g.current)}function J(){let Ce=K.current[g.current];R[g.current]!==Ce&&p(R)}function or(Ce,bt,{commit:Ci}={commit:!1}){let Ho=J5(s),ts=e4(Math.round((Ce-i)/s)*s+i,Ho),Vn=bb(ts,[i,r]);I(($i=[])=>{let Qt=K5($i,Vn,bt);if(Z5(Qt,l*s)){g.current=Qt.indexOf(Vn);let ns=String(Qt)!==String($i);return ns&&Ci&&p(Qt),ns?Qt:$i}else return $i})}return(0,B.createElement)(O5,{scope:t.__scopeSlider,disabled:o,min:i,max:r,valueIndexToChangeRef:g,thumbs:f.current,values:R,orientation:a},(0,B.createElement)(xb.Provider,{scope:t.__scopeSlider},(0,B.createElement)(xb.Slot,{scope:t.__scopeSlider},(0,B.createElement)(L,Ke({"aria-disabled":o,"data-disabled":o?"":void 0},y,{ref:m,onPointerDown:Hs(y.onPointerDown,()=>{o||(K.current=R)}),min:i,max:r,inverted:h,onSlideStart:o?void 0:H,onSlideMove:o?void 0:_e,onSlideEnd:o?void 0:J,onHomeKeyDown:()=>!o&&or(i,0,{commit:!0}),onEndKeyDown:()=>!o&&or(r,R.length-1,{commit:!0}),onStepKeyDown:({event:Ce,direction:bt})=>{if(!o){let ts=tM.includes(Ce.key)||Ce.shiftKey&&nM.includes(Ce.key)?10:1,Vn=g.current,$i=R[Vn],Qt=s*ts*bt;or($i+Qt,Vn,{commit:!0})}}})))),T&&R.map((Ce,bt)=>(0,B.createElement)(W5,{key:bt,name:n?n+(R.length>1?"[]":""):void 0,value:Ce})))}),[sM,aM]=rM(Au,{startEdge:"left",endEdge:"right",size:"width",direction:1}),F5=(0,B.forwardRef)((t,e)=>{let{min:n,max:i,dir:r,inverted:s,onSlideStart:a,onSlideMove:o,onSlideEnd:l,onStepKeyDown:c,...u}=t,[d,p]=(0,B.useState)(null),h=Ti(e,g=>p(g)),y=(0,B.useRef)(),v=Q$(r),w=v==="ltr",m=w&&!s||!w&&s;function f(g){let x=y.current||d.getBoundingClientRect(),T=[0,x.width],R=kb(T,m?[n,i]:[i,n]);return y.current=x,R(g-x.left)}return(0,B.createElement)(sM,{scope:t.__scopeSlider,startEdge:m?"left":"right",endEdge:m?"right":"left",direction:m?1:-1,size:"width"},(0,B.createElement)(oM,Ke({dir:v,"data-orientation":"horizontal"},u,{ref:h,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:g=>{let x=f(g.clientX);a?.(x)},onSlideMove:g=>{let x=f(g.clientX);o?.(x)},onSlideEnd:()=>{y.current=void 0,l?.()},onStepKeyDown:g=>{let T=iM[m?"from-left":"from-right"].includes(g.key);c?.({event:g,direction:T?-1:1})}})))}),z5=(0,B.forwardRef)((t,e)=>{let{min:n,max:i,inverted:r,onSlideStart:s,onSlideMove:a,onSlideEnd:o,onStepKeyDown:l,...c}=t,u=(0,B.useRef)(null),d=Ti(e,u),p=(0,B.useRef)(),h=!r;function y(v){let w=p.current||u.current.getBoundingClientRect(),m=[0,w.height],g=kb(m,h?[i,n]:[n,i]);return p.current=w,g(v-w.top)}return(0,B.createElement)(sM,{scope:t.__scopeSlider,startEdge:h?"bottom":"top",endEdge:h?"top":"bottom",size:"height",direction:h?1:-1},(0,B.createElement)(oM,Ke({"data-orientation":"vertical"},c,{ref:d,style:{...c.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:v=>{let w=y(v.clientY);s?.(w)},onSlideMove:v=>{let w=y(v.clientY);a?.(w)},onSlideEnd:()=>{p.current=void 0,o?.()},onStepKeyDown:v=>{let m=iM[h?"from-bottom":"from-top"].includes(v.key);l?.({event:v,direction:m?-1:1})}})))}),oM=(0,B.forwardRef)((t,e)=>{let{__scopeSlider:n,onSlideStart:i,onSlideMove:r,onSlideEnd:s,onHomeKeyDown:a,onEndKeyDown:o,onStepKeyDown:l,...c}=t,u=om(Au,n);return(0,B.createElement)($u.span,Ke({},c,{ref:e,onKeyDown:Hs(t.onKeyDown,d=>{d.key==="Home"?(a(d),d.preventDefault()):d.key==="End"?(o(d),d.preventDefault()):tM.concat(nM).includes(d.key)&&(l(d),d.preventDefault())}),onPointerDown:Hs(t.onPointerDown,d=>{let p=d.target;p.setPointerCapture(d.pointerId),d.preventDefault(),u.thumbs.has(p)?p.focus():i(d)}),onPointerMove:Hs(t.onPointerMove,d=>{d.target.hasPointerCapture(d.pointerId)&&r(d)}),onPointerUp:Hs(t.onPointerUp,d=>{let p=d.target;p.hasPointerCapture(d.pointerId)&&(p.releasePointerCapture(d.pointerId),s(d))})}))}),U5="SliderTrack",j5=(0,B.forwardRef)((t,e)=>{let{__scopeSlider:n,...i}=t,r=om(U5,n);return(0,B.createElement)($u.span,Ke({"data-disabled":r.disabled?"":void 0,"data-orientation":r.orientation},i,{ref:e}))}),J$="SliderRange",H5=(0,B.forwardRef)((t,e)=>{let{__scopeSlider:n,...i}=t,r=om(J$,n),s=aM(J$,n),a=(0,B.useRef)(null),o=Ti(e,a),l=r.values.length,c=r.values.map(p=>lM(p,r.min,r.max)),u=l>1?Math.min(...c):0,d=100-Math.max(...c);return(0,B.createElement)($u.span,Ke({"data-orientation":r.orientation,"data-disabled":r.disabled?"":void 0},i,{ref:o,style:{...t.style,[s.startEdge]:u+"%",[s.endEdge]:d+"%"}}))}),eM="SliderThumb",q5=(0,B.forwardRef)((t,e)=>{let n=N5(t.__scopeSlider),[i,r]=(0,B.useState)(null),s=Ti(e,o=>r(o)),a=(0,B.useMemo)(()=>i?n().findIndex(o=>o.ref.current===i):-1,[n,i]);return(0,B.createElement)(B5,Ke({},t,{ref:s,index:a}))}),B5=(0,B.forwardRef)((t,e)=>{let{__scopeSlider:n,index:i,...r}=t,s=om(eM,n),a=aM(eM,n),[o,l]=(0,B.useState)(null),c=Ti(e,w=>l(w)),u=v$(o),d=s.values[i],p=d===void 0?0:lM(d,s.min,s.max),h=G5(i,s.values.length),y=u?.[a.size],v=y?Q5(y,p,a.direction):0;return(0,B.useEffect)(()=>{if(o)return s.thumbs.add(o),()=>{s.thumbs.delete(o)}},[o,s.thumbs]),(0,B.createElement)("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${p}% + ${v}px)`}},(0,B.createElement)(xb.ItemSlot,{scope:t.__scopeSlider},(0,B.createElement)($u.span,Ke({role:"slider","aria-label":t["aria-label"]||h,"aria-valuemin":s.min,"aria-valuenow":d,"aria-valuemax":s.max,"aria-orientation":s.orientation,"data-orientation":s.orientation,"data-disabled":s.disabled?"":void 0,tabIndex:s.disabled?void 0:0},r,{ref:c,style:d===void 0?{display:"none"}:t.style,onFocus:Hs(t.onFocus,()=>{s.valueIndexToChangeRef.current=i})}))))}),W5=t=>{let{value:e,...n}=t,i=(0,B.useRef)(null),r=X$(e);return(0,B.useEffect)(()=>{let s=i.current,a=window.HTMLInputElement.prototype,l=Object.getOwnPropertyDescriptor(a,"value").set;if(r!==e&&l){let c=new Event("input",{bubbles:!0});l.call(s,e),s.dispatchEvent(c)}},[r,e]),(0,B.createElement)("input",Ke({style:{display:"none"}},n,{ref:i,defaultValue:e}))};function K5(t=[],e,n){let i=[...t];return i[n]=e,i.sort((r,s)=>r-s)}function lM(t,e,n){let s=100/(n-e)*(t-e);return bb(s,[0,100])}function G5(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function Y5(t,e){if(t.length===1)return 0;let n=t.map(r=>Math.abs(r-e)),i=Math.min(...n);return n.indexOf(i)}function Q5(t,e,n){let i=t/2,s=kb([0,50],[0,i]);return(i-s(e)*n)*n}function X5(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function Z5(t,e){if(e>0){let n=X5(t);return Math.min(...n)>=e}return!0}function kb(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];let i=(e[1]-e[0])/(t[1]-t[0]);return e[0]+i*(n-t[0])}}function J5(t){return(String(t).split(".")[1]||"").length}function e4(t,e){let n=Math.pow(10,e);return Math.round(t*n)/n}var Eb=V5,cM=j5,uM=H5,dM=q5;var pM=$(z());var vo=$(ae()),lm=pM.forwardRef(({className:t,variant:e="regular",autoHidden:n,children:i,...r},s)=>(0,vo.jsxs)(Eb,{ref:s,className:In("group relative flex w-full touch-none select-none items-center",t),...r,children:[(0,vo.jsx)(cM,{className:"relative h-slider-track w-full grow overflow-hidden rounded-sm bg-slider-track",children:(0,vo.jsx)(uM,{className:"absolute h-full bg-ia-accent rounded-sm will-change-[width]"})}),(0,vo.jsx)(dM,{className:In("block rounded-slider-thumb border-width-slider-thumb border-slider-thumb bg-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mod-border-focus disabled:pointer-events-none disabled:opacity-50 transition-opacity will-change-[left]",e==="regular"?"h-slider-thumb w-slider-thumb":"h-slider-thumb-sm w-slider-thumb-sm",n&&"opacity-0 group-hocus:opacity-100 focus:opacity-100")}),i]}));lm.displayName=Eb.displayName;var Kr=$(ae());function um(){let t=ye("volume"),e=ye("canSetVolume"),n=kf();return e?(0,Kr.jsx)(lm,{className:"group relative inline-flex h-10 w-full max-w-[80px] cursor-pointer touch-none select-none items-center outline-none",value:[t*100],onValueChange:([i])=>{n.changeVolume(i/100)},"aria-label":"Volume",autoHidden:!0}):null}function dm({thumbnails:t}){let e=ye("currentTime"),n=ye("canSeek"),i=ye("duration"),r=ye("seeking"),s=kf(),a=1/i*100,[o,l]=(0,cm.useState)(0),{previewRootRef:c,previewRef:u,previewValue:d}=S1({clamp:!0,offset:6,orientation:"horizontal"}),p=d/100*i;return(0,cm.useEffect)(()=>{r||l(e/i*100)},[e,i,r]),(0,Kr.jsx)(lm,{className:"group relative inline-flex h-9 w-full cursor-pointer touch-none select-none items-center outline-none",value:[o],disabled:!n,step:Number.isFinite(a)?a:1,ref:c,onValueChange:([h])=>{l(h),s.seeking(h/100*i)},onValueCommit:([h])=>{s.seek(h/100*i)},autoHidden:!0,"aria-label":"Current Time",children:(0,Kr.jsxs)("div",{className:"flex flex-col items-center absolute opacity-0 data-[visible]:opacity-100 transition-opacity duration-200 will-change-[left] pointer-events-none",ref:u,children:[t?(0,Kr.jsx)(vf.Root,{src:t,time:p,className:"block mb-2 h-[var(--thumbnail-height)] max-h-[160px] min-h-[80px] w-[var(--thumbnail-width)] min-w-[120px] max-w-[180px] overflow-hidden border border-white bg-black",children:(0,Kr.jsx)(vf.Img,{})}):null,(0,Kr.jsx)("span",{className:"text-[13px]",children:Fr(p)})]})})}var yo=$(ae());function pm(){return(0,yo.jsxs)("div",{className:"ml-2.5 flex items-center text-sm font-medium",children:[(0,yo.jsx)(cu,{className:"time",type:"current"}),(0,yo.jsx)("div",{className:"mx-1 text-white/80",children:"/"}),(0,yo.jsx)(cu,{className:"time",type:"duration"})]})}var Nu=$(ae());function hm(){let t=ye("title").trim(),e=wf().trim();return!t&&!e?null:(0,Nu.jsxs)("span",{className:"inline-block flex-1 overflow-hidden text-ellipsis whitespace-nowrap px-2 text-sm font-medium text-white/70",children:[(0,Nu.jsx)("span",{className:"mr-1",children:"|"}),(0,Nu.jsx)("span",{children:e||t})]})}var fe=$(ae());function fM({thumbnails:t}){return(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)(n4,{}),(0,fe.jsx)(tr.Root,{className:"opacity-100 absolute inset-0 z-10 flex h-full w-full flex-col bg-gradient-to-t from-black/10 to-transparent",children:(0,fe.jsxs)(Zf,{children:[(0,fe.jsx)("div",{className:"flex-1"}),(0,fe.jsx)(tr.Group,{className:"flex w-full items-center px-2",children:(0,fe.jsx)(dm,{thumbnails:t})}),(0,fe.jsxs)(tr.Group,{className:"-mt-0.5 flex w-full items-center px-2 pb-2",children:[(0,fe.jsx)(U$,{seconds:30}),(0,fe.jsx)(nm,{}),(0,fe.jsx)(z$,{seconds:30}),(0,fe.jsx)(im,{}),(0,fe.jsx)(um,{}),(0,fe.jsx)(pm,{}),(0,fe.jsx)(hm,{}),(0,fe.jsx)("div",{className:"flex-1"}),(0,fe.jsx)(rm,{}),(0,fe.jsx)(sm,{})]})]})})]})}function n4(){return(0,fe.jsxs)(fe.Fragment,{children:[(0,fe.jsx)($n,{className:"absolute inset-0 z-0 block h-full w-full",event:"pointerup",action:"toggle:paused"}),(0,fe.jsx)($n,{className:"absolute inset-0 z-0 block h-full w-full",event:"dblpointerup",action:"toggle:fullscreen"}),(0,fe.jsx)($n,{className:"absolute left-0 top-0 z-10 block h-full w-1/5",event:"dblpointerup",action:"seek:-10"}),(0,fe.jsx)($n,{className:"absolute right-0 top-0 z-10 block h-full w-1/5",event:"dblpointerup",action:"seek:10"})]})}var ue=$(ae());function mM({thumbnails:t}){return(0,ue.jsxs)(ue.Fragment,{children:[(0,ue.jsx)(i4,{}),(0,ue.jsx)(bf,{className:"mx-captions media-preview:opacity-0 media-controls:bottom-[85px] media-captions:opacity-100 absolute inset-0 bottom-2 z-10 select-none break-words opacity-0 transition-[opacity,bottom] duration-300"}),(0,ue.jsx)(tr.Root,{className:"media-controls:opacity-100 not-media-can-load:opacity-100 absolute inset-0 z-10 flex h-full w-full flex-col bg-gradient-to-t from-black/10 to-transparent opacity-0 transition-opacity",children:(0,ue.jsxs)(Zf,{children:[(0,ue.jsx)("div",{className:"flex-1"}),(0,ue.jsx)(tr.Group,{className:"flex w-full items-center px-2",children:(0,ue.jsx)(dm,{thumbnails:t})}),(0,ue.jsxs)(tr.Group,{className:"-mt-0.5 flex w-full items-center px-2 pb-2",children:[(0,ue.jsx)(nm,{}),(0,ue.jsx)(im,{}),(0,ue.jsx)(um,{}),(0,ue.jsx)(pm,{}),(0,ue.jsx)(hm,{}),(0,ue.jsx)("div",{className:"flex-1"}),(0,ue.jsx)(G$,{}),(0,ue.jsx)(H$,{}),(0,ue.jsx)(j$,{}),(0,ue.jsx)(rm,{}),(0,ue.jsx)(sm,{})]})]})})]})}function i4(){return(0,ue.jsxs)(ue.Fragment,{children:[(0,ue.jsx)($n,{className:"absolute inset-0 z-0 block h-full w-full",event:"pointerup",action:"toggle:paused"}),(0,ue.jsx)($n,{className:"absolute inset-0 z-0 block h-full w-full",event:"dblpointerup",action:"toggle:fullscreen"}),(0,ue.jsx)($n,{className:"absolute left-0 top-0 z-10 block h-full w-1/5",event:"dblpointerup",action:"seek:-10"}),(0,ue.jsx)($n,{className:"absolute right-0 top-0 z-10 block h-full w-1/5",event:"dblpointerup",action:"seek:10"})]})}var EM=$(z());var Du=class{constructor(){_(this,"name","webview");_(this,"target")}canPlay({src:e}){return du(e)&&Mf(e)}mediaType(){return"video"}async load(e){return new Rn(this.target,e)}};var fn=$(z());function fm(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}var gM=$(z());function vM(t,e){var n=(0,gM.useState)(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(i){var r=n.value;r!==i&&(n.value=i,n.callback(i,r))}}}})[0];return n.callback=e,n.facade}var _M=$(z());var yM=new WeakMap;function Tb(t,e){var n=vM(e||null,function(i){return t.forEach(function(r){return fm(r,i)})});return _M.useLayoutEffect(function(){var i=yM.get(n);if(i){var r=new Set(i),s=new Set(t),a=n.current;r.forEach(function(o){s.has(o)||fm(o,null)}),s.forEach(function(o){r.has(o)||fm(o,a)})}yM.set(n,t)},[t]),n}function Sb(t){return"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"}var wM=$(z()),Pb={onLoadCommit:"load-commit",onDidFinishLoad:"did-finish-load",onDidFailLoad:"did-fail-load",onDidFrameFinishLoad:"did-frame-finish-load",onDidStartLoading:"did-start-loading",onDidStopLoading:"did-stop-loading",onDidAttach:"did-attach",onDomReady:"dom-ready",onPageTitleUpdated:"page-title-updated",onPageFaviconUpdated:"page-favicon-updated",onEnterHtmlFullScreen:"enter-html-full-screen",onLeaveHtmlFullScreen:"leave-html-full-screen",onConsoleMessage:"console-message",onFoundInPage:"found-in-page",onWillNavigate:"will-navigate",onDidStartNavigation:"did-start-navigation",onDidRedirectNavigation:"did-redirect-navigation",onDidNavigate:"did-navigate",onDidFrameNavigate:"did-frame-navigate",onDidNavigateInPage:"did-navigate-in-page",onClose:"close",onIpcMessage:"ipc-message",onCrashed:"crashed",onPluginCrashed:"plugin-crashed",onDestroyed:"destroyed",onMediaStartedPlaying:"media-started-playing",onMediaPaused:"media-paused",onDidChangeThemeColor:"did-change-theme-color",onUpdateTargetUrl:"update-target-url",onDevtoolsOpened:"devtools-opened",onDevtoolsClosed:"devtools-closed",onDevtoolsFocused:"devtools-focused",onContextMenu:"context-menu"};function r4(t){return Object.entries(t).reduce((e,[n,i])=>(n in Pb?e.event[n]=i:e.rest[n]=i,e),{event:{},rest:{}})}function bM(t,e){let{event:n,rest:i}=r4(t);for(let r of Object.keys(Pb)){let s=r,a=Pb[s],o=n[s];(0,wM.useEffect)(()=>{if(!e.current||!o)return;let l=e.current;return l.addEventListener(a,o),()=>{l.removeEventListener(a,o)}},[a,o,e])}return i}var kM=$(ae()),xM=(0,fn.forwardRef)(function({devtools:e=!1,muted:n=!1,className:i,useragent:r,...s},a){let o=(0,fn.useRef)(null),[l,c]=(0,fn.useState)(!1),u=bM(s,o);a4(n,o,l);let d=s4(r??navigator.userAgent,o,l);return(0,fn.useEffect)(()=>{if(!o.current)return;let p=o.current;return p.addEventListener("dom-ready",h),p.addEventListener("will-navigate",y),()=>{p.removeEventListener("dom-ready",h),p.removeEventListener("will-navigate",y)};function h(){c(!0)}function y(){c(!1)}},[]),(0,kM.jsx)("webview",{ref:Tb([o,a]),className:In("h-full w-full",i),useragent:d,...u})});function s4(t,e,n){let i=(0,fn.useMemo)(()=>{let r=t??navigator.userAgent;return Sb(r)},[t]);return(0,fn.useEffect)(()=>{!e.current||!n||i===e.current.useragent||e.current.setUserAgent(i)},[i,n,e]),i}function a4(t,e,n){(0,fn.useEffect)(()=>{!e.current||!n||t===e.current.isAudioMuted()||e.current.setAudioMuted(t)},[t,n,e])}var Cb=$(ae());function TM({loaders:t,...e}){let n=Kf(l=>l.appId),i=ye("viewType"),r=Nt(l=>!!l.transform?.flipHorizontal),s=Nt(l=>!!l.transform?.flipVertical),a=Nt(l=>{if(l.transform?.rotate)switch(l.transform.rotate){case"90":return"rotate-90";case"180":return"rotate-180";case"270":return"rotate-[270deg]";default:return}}),o=Qf();return(0,Cb.jsx)(Gw,{className:In(i==="video"&&r&&"-scale-x-100",i==="video"&&s&&"-scale-y-100",i==="video"&&a),loaders:[Du,...t??[]],buildMediaEl:(0,EM.useCallback)((l,c)=>l instanceof Du?(0,Cb.jsx)(xM,{"aria-hidden":!0,className:In("data-[play-ready]:blur-none blur-lg transition-opacity",o&&"pointer-events-none"),webpreferences:"autoplayPolicy=user-gesture-required",partition:oi(n),ref:u=>{c.load(u)}}):null,[n,o]),...e})}var si=$(ae()),CM=$(z());function o4({onViewTypeChange:t}){return d$(t),JC(),p$(),(0,si.jsx)(si.Fragment,{})}function l4(){let t=ye("viewType"),e=Qf();return t==="audio"?(0,si.jsx)(fM,{}):e?(0,si.jsx)(mM,{}):null}function Gr(){let t=Nt(u=>u.playerRef),e=Nt(({source:u})=>{if(!u)return;let d=u.url.source.href;return u.enableWebview?{src:vC(d)}:{type:u.type,src:d}}),n=Nt(({textTracks:u})=>u),i=Us(u=>u.loadStrategy),r=po(),[s,a]=(0,PM.useState)("unknown"),o=Nt(u=>u.title),{controls:l,...c}=mb();return e?(0,si.jsxs)(Kw,{className:In("w-full bg-slate-900 text-white font-sans overflow-hidden rounded-md ring-mod-border-focus data-[focus]:ring-2","data-[view-type=video]:aspect-video data-[view-type=audio]:h-20 data-[view-type=audio]:aspect-auto"),load:r?i:"eager",src:e,playsInline:!0,title:o,viewType:s,ref:t,onError:u=>{new SM.Notice(createFragment(d=>{switch(d.appendText(`Failed to load media for ${e.src}: `),d.createEl("br"),u.code){case 1:d.appendText("The media playback was aborted");break;case 2:d.appendText("A network error caused the media playback to fail");break;case 3:d.appendText("The media playback was aborted due to a corruption problem or because the media encoding is not supported");break;case 4:d.appendText("The media is not supported to open as regular video or audio, try open as webpage");break;default:d.appendText(u.message||"Unknown error, check console for more details"),console.error("Failed to load media",e.src,u);break}}))},...c,children:[(0,si.jsx)(TM,{children:n.map(u=>(0,CM.createElement)(Yw,{...u,key:u.id}))}),(0,si.jsx)(o4,{onViewTypeChange:a}),(0,si.jsx)(l4,{})]}):null}function mm(t,e){let n=new WeakMap,i;t.register(Su(t.store,r=>[r.subscribe(({currentTime:s,paused:a,playbackRate:o})=>{s!==0&&r.el&&n.set(t.leaf.parent,{currentTime:s,paused:a,playbackRate:o})}),r.listen("can-play",()=>{if(!i)return;let s=n.get(i);if(!s){i=void 0;return}let{currentTime:a,paused:o,playbackRate:l}=s;if(!o)r.play(new Event("recover-state")).then(()=>{r.currentTime=a,r.playbackRate=l,i&&(n.delete(i),i=void 0)}).catch(c=>console.error("recov err play",c));else try{r.currentTime=a,r.playbackRate=l,i&&(n.delete(i),i=void 0)}catch(c){console.error("recov err paused",c)}})])),t.register(u4(t,(r,s)=>{e(),n.has(s)?i=s:i=void 0})),t.register(()=>{i=void 0})}function gm(t,e){let n=new WeakMap,i;t.register(Su(t.store,r=>[r.subscribe(({currentTime:s,paused:a,playbackRate:o})=>{s!==0&&r.el&&n.set(r.el.win,{currentTime:s,paused:a,playbackRate:o})}),r.listen("can-play",()=>{if(!i)return;let s=n.get(i);if(!s){i=void 0;return}let{currentTime:a,paused:o,playbackRate:l}=s;if(!o)r.play(new Event("recover-state")).then(()=>{r.currentTime=a,r.playbackRate=l,i&&(n.delete(i),i=void 0)}).catch(c=>console.error("recov err play",c));else try{r.currentTime=a,r.playbackRate=l,i&&(n.delete(i),i=void 0)}catch(c){console.error("recov err paused",c)}})])),t.register(c4(t.containerEl,(r,s)=>{e(),n.has(s)?i=s:i=void 0})),t.register(()=>{i=void 0})}function c4(t,e){let n=t.win;return t.onNodeInserted(()=>{let i=t.win;i!==n&&(e(i,n),n=i)})}function u4(t,e){let n=t.containerEl.win,i=t.leaf.parent;return t.containerEl.onNodeInserted(()=>{let r=t.containerEl.win,s=t.leaf.parent;r===n?s!==i&&(e(s,i),i=s):n=r})}var $b=$(ae()),vm=class extends ym.EditableFileView{constructor(n,i){super(n);this.plugin=i;_(this,"allowNoFile",!1);_(this,"store");_(this,"scope");_(this,"root",null);this.store=Ur(),this.scope=new ym.Scope(this.app.scope),this.contentEl.addClasses(["mx","custom"]),qf(this)}onload(){gm(this,()=>this.render())}async onLoadFile(n){await this.store.getState().loadFile(n,{vault:this.app.vault,defaultLang:this.plugin.settings.getState().getDefaultLang()})}onPaneMenu(n,i){super.onPaneMenu(n,i),Bf(this,n,i)}setEphemeralState(n){if("subpath"in n){let{subpath:i}=n;this.store.getState().setHash(i)}super.setEphemeralState(n)}async onOpen(){await super.onOpen(),this.render()}render(){this.root?.unmount(),this.root=$M.default.createRoot(this.contentEl),this.root.render((0,$b.jsx)(wt.Provider,{value:{plugin:this.plugin,store:this.store,reload:()=>this.render(),embed:!1},children:(0,$b.jsx)(Gr,{})}))}async onClose(){return this.root?.unmount(),this.root=null,super.onClose()}},_o=class extends vm{getIcon(){return"file-video"}getMediaInfo(){return this.file?{type:"video",file:this.file,hash:this.getEphemeralState().subpath}:null}getViewType(){return jn.video}canAcceptExtension(e){return kt.video.includes(e)}},wo=class extends vm{getIcon(){return"file-audio"}getViewType(){return jn.audio}getMediaInfo(){return this.file?{type:"audio",file:this.file,hash:this.getEphemeralState().subpath}:null}canAcceptExtension(e){return kt.audio.includes(e)}};var _m=require("obsidian"),MM=$(zl());var Mb=$(ae()),Yr=class extends _m.ItemView{constructor(n,i){super(n);this.plugin=i;_(this,"store");_(this,"scope");_(this,"root",null);_(this,"navigation",!0);this.store=Ur(),this.scope=new _m.Scope(this.app.scope),this.contentEl.addClasses(["mx","custom"]),qf(this)}setSource(n){this.store.getState().setSource(n)}getMediaInfo(){return this.store.getState().source?.url??null}get sourceType(){return this.store.getState().player?.state.source.type??""}get playerTitle(){return this.store.getState().player?.state.title??""}onload(){let n=this;super.onload(),this.register(ut(this.leaf,{detach:i=>function(...r){return n.root?.unmount(),n.root=null,i.call(this,...r)}})),gm(this,()=>this.render())}registerRemoteTitleChange(){this.register(Su(this.store,n=>n.subscribe(({title:i})=>{this.updateTitle()})))}onPaneMenu(n,i){super.onPaneMenu(n,i),Bf(this,n,i)}getState(){let n=super.getState(),i=this.store.getState().source?.url;return{...n,source:i?i.jsonState.source:n.source}}async setState(n,i){if(await super.setState(n,i),!("source"in n))return;let r=this.plugin.resolveUrl(n.source);if(!r)console.warn("Invalid URL",n.source);else{let s=this.store.getState().source?.url;r.compare(s)||(await this.setSource(r),this.render())}}setEphemeralState(n){if("subpath"in n){let{subpath:i}=n;this.store.getState().setHash(i)}super.setEphemeralState(n)}async onOpen(){await super.onOpen(),this.render()}updateTitle(){let n=this.getDisplayText();this.titleEl.setText(n),this.app.workspace.activeLeaf===this.leaf&&this.app.workspace.requestActiveLeafEvents()&&this.leaf.updateHeader()}render(){this.root&&this.root.unmount(),this.root=MM.default.createRoot(this.contentEl),this.root.render((0,Mb.jsx)(wt.Provider,{value:{plugin:this.plugin,store:this.store,reload:()=>this.render(),embed:!1},children:(0,Mb.jsx)(Gr,{})}))}close(){return this.root?.unmount(),this.root=null,super.close()}async onClose(){return this.root?.unmount(),this.root=null,super.onClose()}};var d4={"video/vimeo":"Vimeo","video/youtube":"YouTube"},bo=class extends Yr{onload(){super.onload(),this.registerRemoteTitleChange(),mm(this,()=>this.render())}getDisplayText(){let e=d4[this.sourceType]??"Embed";return this.playerTitle?`${this.playerTitle} - ${e}`:e}getIcon(){switch(this.sourceType){case"video/youtube":return"youtube";case"video/vimeo":return"vimeo";default:return"video"}}getViewType(){return Ri}};var wm=class extends Yr{},xo=class extends wm{getIcon(){return"file-video"}getViewType(){return pt.video}getDisplayText(){return this.playerTitle||"Video"}async setSource(e){let n=this.plugin.settings.getState().getDefaultLang(),i=await Ff(e,n).catch(r=>(console.error("Failed to get text tracks",r,e.href,n),[]));this.store.getState().setSource(e,{title:!0,textTracks:i,type:"video/mp4"})}},ko=class extends wm{getIcon(){return"file-audio"}getDisplayText(){return this.playerTitle||"Audio"}getViewType(){return pt.audio}async setSource(e){this.store.getState().setSource(e,{title:!0,type:"audio/mp3"})}};var Eo=class extends Yr{onload(){super.onload(),this.registerRemoteTitleChange(),mm(this,()=>this.render())}getViewType(){return Zt}getIcon(){let e=this.getHost();return e==="generic"?"globe":e}getHost(){let{source:e}=this.store.getState();return e?.url?e.url.type:"generic"}getDisplayText(){return this.playerTitle?`${this.playerTitle} - ${Ju[this.getHost()]}`:"Webpage"}setSource(e){this.store.getState().setSource(e,{enableWebview:!0})}};function RM(t,e){if(!(t.view instanceof _o||t.view instanceof wo))return!1;let{file:n}=t.view.getState();return n===e.file.path}function LM(t,e){if(!(t.view instanceof bo||t.view instanceof Eo||t.view instanceof xo||t.view instanceof ko))return!1;let{source:n}=t.view.store.getState();return e.compare(n?.url)}function Rb(t,e){let n=t.stat.mtime,i=e.stat.mtime;return!n||!i?0:i-n}var bm="mx-media-active",Ou,Lb,km,AM,Em,NM,Tm,DM,xm=class extends To.Component{constructor(n){super();this.plugin=n;O(this,Ou);O(this,km);O(this,Em);O(this,Tm);_(this,"app");_(this,"activeMediaLeaf",null);_(this,"onLeafUpdate",(0,To.debounce)(n=>{n=n??this.workspace.activeLeaf,this.onActiveLeafChange(n)},200));this.app=n.app}onload(){let n=this.app.workspace;n.onLayoutReady(()=>{this.onLeafUpdate()}),this.registerEvent(n.on("active-leaf-change",i=>{this.onLeafUpdate(i)})),this.registerEvent(n.on("layout-change",()=>{this.onLeafUpdate()}))}onunload(){this.applyActiveMediaLeaf(null)}get workspace(){return this.app.workspace}onActiveLeafChange(n){let i=this.detectActiveMediaLeaf(n);this.activeMediaLeaf!==i&&this.applyActiveMediaLeaf(i)}applyActiveMediaLeaf(n){this.activeMediaLeaf?.tabHeaderEl.removeClass(bm),this.activeMediaLeaf?.containerEl.removeClass(bm),n?.tabHeaderEl.addClass(bm),n?.containerEl.addClass(bm),this.activeMediaLeaf=n}detectActiveMediaLeaf(n){let i=()=>{let r=this.findPinnedPlayer();if(r)return r;let s=IM(this.workspace),{activeTabGroup:a}=this.workspace;return(!n||!a?s:s.filter(l=>!a.children.includes(l))).at(0)??null};if(!n)return i();if(Ib(n))return n;if(n.view instanceof To.MarkdownView&&n.view.file){let{mediaNote:r}=this.plugin,s=r.findMedia(n.view.file);if(s)return this.findPlayerWithSameMedia(s)}return i()}findPlayerWithSameMedia(n){for(let i of this.plugin.urlViewType.getSupported(n)){let r=p4(n,i,this.workspace);if(r.length>0)return r[0]}return null}findPinnedPlayer(){return IM(this.workspace).filter(n=>n.pinned)[0]??null}get settings(){return this.plugin.settings.getState()}getSplitBehavior(n){let{defaultMxLinkClick:{click:i,alt:r}}=this.settings;return i===null?n??!1:n===void 0||n===!1?i:r!==null&&n===i?r:n}async openMedia(n,i,{direction:r,viewType:s,fromUser:a}={}){let{workspace:o}=this.app;if(!i){let c=await M(this,km,AM).call(this,n,s);if(c)return c}let l=o.getLeaf(a?this.getSplitBehavior(i):i,r);return M(this,Ou,Lb).call(this,l,n,s)}async openNote(n,i,r="split",s="vertical"){let a=this.plugin.mediaNote.findNotes(n),o=M(this,Em,NM).call(this,a);if(o)return o.getMode()!=="source"&&await o.setState({mode:"source"},{history:!1}),o;let l;if(a.length===0){let d=`Media Note - ${Wo(i.title,{replacement:"_"})}`;l=await M(this,Tm,DM).call(this,d,i.fm,i.sourcePath??"")}else l=a.sort(Rb).at(0);let c=this.app.workspace.getLeaf(r,s);return await c.openFile(l,{state:{mode:"source"}}),{file:l,editor:c.view.editor}}};Ou=new WeakSet,Lb=async function(n,i,r){if(Mi(i))await n.openFile(i.file,{eState:{subpath:i.hash},active:!0});else{let s={source:i.jsonState.source};r??(r=this.plugin.urlViewType.getPreferred(i)),await n.setViewState({type:r,state:s,active:!0},{subpath:i.hash})}return n},km=new WeakSet,AM=async function(n,i){let r=this.findPinnedPlayer();if(r)return await M(this,Ou,Lb).call(this,r,n,i);let s=this.findPlayerWithSameMedia(n);return s?(h4(n.hash,s),s):null},Em=new WeakSet,NM=function(n){let{workspace:i}=this.app,r=i.getLeavesOfType("markdown").filter(a=>{let o=a.view.file?.path;return!!o&&n.some(l=>l.path===o)});return r.length===0?null:(r.find(a=>a===i.activeLeaf)??r.sort((a,o)=>Rb(a.view.file,o.view.file)).at(0)).view},Tm=new WeakSet,DM=async function(n,i,r=""){let{fileManager:s}=this.app,a=s.getNewFileParent(r,n),o=await s.createNewFile(a,n,"md",`--- --- -`);return await s.processFrontMatter(o,l=>{Object.assign(l,i(o.path))}),o};function CM(t){let e=[];return t.iterateAllLeaves(n=>{ag(n.view.getViewType())&&e.push(n)}),e.sort(LM),e}function l4(t,e,n){let i=n.getLeavesOfType(e).filter(r=>$i(t)?SM(r,t):PM(r,t));return i.sort(LM),i}function Cb(t){return!!t&&ag(t.view.getViewType())}function LM(t,e){return e.activeTime-t.activeTime}function c4(t,e){e.setEphemeralState({subpath:t})}function u4(t,e,n){return i=>{let r=n.workspace.activeEditor;if(!r)return t?t(i):void 0;if(e&&r.getMode()!=="preview")return r instanceof IM.MarkdownView&&r.inlineTitleEl.isActiveElement()?void 0:e(i,r.editor,r)}}function Lu({playerCheckCallback:t,noteCheckCallback:e,...n},i){let{app:r}=i,s=i.addCommand({...n,checkCallback:u4(t&&(a=>!t||!Cb(r.workspace.activeLeaf)?!1:a?!0:t(a,r.workspace.activeLeaf.view)),e&&((a,o,l)=>{if(!l.file)return!1;let c=i.mediaNote.findMedia(l.file),u=i.leafOpener.detectActiveMediaLeaf(r.workspace.activeLeaf);return e(a,u?.view,{isMediaNote:c,file:l.file,editor:o})}),r)});return!e||!n.menu||i.registerEvent(i.app.workspace.on("editor-menu",(a,o,l)=>{if(!l.file)return!1;let c=i.mediaNote.findMedia(l.file),u=i.leafOpener.detectActiveMediaLeaf(r.workspace.activeLeaf);if(!e(!0,u?.view,{isMediaNote:c,file:l.file,editor:o}))return;let d=l.file;a.addItem(p=>{n.icon&&p.setIcon(n.icon),n.name&&p.setTitle(n.name),n.section&&p.setSection(n.section),p.onClick(()=>{e(!1,u?.view,{isMediaNote:c,file:d,editor:o})})})})),s}var d4=[{id:"toggle-play",label:"Play/pause",icon:"play",action:t=>{t.paused=!t.paused}},...[5,30].flatMap(t=>[{id:`forward-${t}s`,label:`Forward ${t}s`,icon:"forward",action:e=>{e.currentTime+=t},repeat:!0},{id:`rewind-${t}s`,label:`Rewind ${t}s`,icon:"rewind",action:e=>{e.currentTime-=t},repeat:!0}]),{id:"toggle-mute",label:"Mute/unmute",icon:"volume-x",action:t=>{t.muted=!t.muted}},{id:"toggle-fullscreen",label:"Enter/exit fullscreen",icon:"expand",check:t=>t.state.canFullscreen,action:t=>{t.state.fullscreen?t.exitFullscreen():t.enterFullscreen()}},...p4()];function p4(){let t=null,e=(0,Iu.debounce)(()=>t?.hide(),2e3,!0);function n(r){!t||t.noticeEl.isConnected===!1?t=new Iu.Notice(r,0):t.setMessage(r),e()}function i(r){new Iu.Notice(r,2e3)}return[{id:"reset-speed",label:"Reset playback speed",icon:"reset",check:r=>r.state.playbackRate!==1,action:r=>{r.playbackRate=1,i("Speed reset to 1x")}},{id:"increase-speed",label:"Increase playback speed",icon:"arrow-up",action:r=>{let s=r.playbackRate;if(s>=ar.last()){i("Cannot increase speed further");return}let a=ar.find(o=>o>s);r.playbackRate=a,n(`Speed increased to ${a}x`)}},{id:"decrease-speed",label:"Decrease playback speed",icon:"arrow-down",action:r=>{let s=r.playbackRate;if(s<=ar.first()){i("Cannot decrease speed further");return}let a=ar.slice().reverse().find(o=>o{let s=await Qs.run();s&&(r.playbackRate=s,n(`Speed set to ${s}x`))}}]}function AM(t){d4.forEach(({id:e,label:n,icon:i,action:r,repeat:s,check:a})=>{Lu({id:e,name:n,icon:i,repeatable:s,playerCheckCallback:(o,l)=>{if(!l)return!1;let c=l.store.getState().player;if(!c||a&&!a(c))return!1;if(o)return!0;r(c)},noteCheckCallback(o,l){if(!l)return!1;let c=l.store.getState().player;if(!c||a&&!a(c))return!1;if(o)return!0;r(c)}},t)})}function NM(t){Lu({id:"take-timestamp",name:"Take timestamp",icon:"star",menu:!0,section:"selection-link",...e(async(n,i)=>{i.from==="player"&&lo("timestamp"),await Ff(n,i)})},t),Lu({id:"save-screenshot",name:"Save screenshot",icon:"camera",section:"selection-link",menu:!0,...e(async(n,i)=>{i.from==="player"&&lo("screenshot"),await Vf(n,i)})},t);function e(n){return{playerCheckCallback:(i,r)=>{let s=r.getMediaInfo();if(!s)return!1;if(i)return!0;vu(s,r).then(a=>n(r,{...a,from:"player"}))},noteCheckCallback:(i,r,{isMediaNote:s,...a})=>{let o;if(r){if(i)return!0;t.app.workspace.revealLeaf(r.leaf),o=Promise.resolve(r)}else{if(!s)return!1;if(i)return!0;o=t.leafOpener.openMedia(s,void 0,{fromUser:!0}).then(l=>l.view)}o.then(l=>n(l,{...a,from:"note"}))}}}}function OM(){this.registerEvent(this.app.workspace.on("file-menu",(t,e,n,i)=>{if(!(e instanceof DM.TFile))return;let r=this.mediaNote.findMedia(e);r&&t.addItem(s=>s.setSection("view").setIcon("play").setTitle("Open linked media").onClick(()=>this.leafOpener.openMedia(r,void 0,{fromUser:!0})))})),NM(this),AM(this)}var An=require("obsidian");function Eo(t,e){return!!(t.type!=="generic"||t.inferredType||t.tempFrag||e.mediaNote.findNotes(t).length>0||e.urlViewType.getPreferred(t,!0))}var $b=async function(t,e,n){let i=this.resolveUrl(t);if(!i||!Eo(i,this)){n();return}await this.leafOpener.openMedia(i,e,{fromUser:!0})},VM={"mx-embed":{label:"iframe",icon:"code"},"mx-url-audio":{label:"regular audio",icon:"headphones"},"mx-url-video":{label:"regular video",icon:"film"},"mx-webpage":{label:"webpage",icon:"globe"}};async function h4(t){if(!An.Platform.isDesktopApp)return;let e=window.electron;if(!e)return;await(An.Platform.isMacOS?e.remote.shell:e.shell).showItemInFolder(t)}async function f4(t){if(!An.Platform.isDesktopApp)return;let e=window.electron;if(!e)return;let i=await(An.Platform.isMacOS?e.remote.shell:e.shell).openPath(t);if(i)throw new Error(i)}function FM(t){t.registerEvent(t.app.workspace.on("url-menu",(e,n)=>{let i=t.resolveUrl(n);if(!i)return;if(An.Platform.isDesktopApp&&i.isFileUrl&&i.filePath){let h=i.filePath;e.addItem(y=>y.setIcon("folder").setTitle(An.Platform.isMacOS?"Reveal in Finder":"Show in system explorer").onClick(()=>{h4(h).catch(v=>{new An.Notice(`Failed to open file in file explorer: ${v.message}`),console.error("Failed to open file in file explorer",v)})})).addItem(y=>y.setIcon("arrow-up-right").setTitle("Open in system player").onClick(()=>{f4(h).catch(v=>{new An.Notice(`Failed to open file in system player: ${v.message}`),console.error("Failed to open file in system player",v)})}))}let{protocol:r,hostname:s,pathname:a,host:o,port:l}=i,c=t.urlViewType.getSupported(i),u=t.urlViewType.getPreferred(i),d=Eo(i,t)?c.filter(h=>h!==u):c;if(d.length===0)return;function p(h,y,v=!1){let _=VM[y].label;return h.setTitle(v?_:`Open as ${_}`).setIcon(VM[y].icon)}d.forEach(h=>{e.addItem(y=>p(y,h).setSection("mx-link").onClick(async()=>{await t.leafOpener.openMedia(i,void 0,{viewType:h,fromUser:!0})}))}),e.addItem(h=>{let y=h.setTitle("Always open this url as").setIcon("external-link").setSection("mx-link").setSubmenu();d.forEach(v=>{y.addItem(_=>p(_,v,!0).setSection("mx-link").onClick(async()=>{t.urlViewType.setPreferred({protocol:r,hostname:s,pathname:a,port:l},v),await t.leafOpener.openMedia(i,void 0,{viewType:v,fromUser:!0})}))})}),s&&e.addItem(h=>{let y=h.setTitle(`Always open ${o} as`).setIcon("external-link").setSection("mx-link").setSubmenu();d.forEach(v=>{y.addItem(_=>p(_,v,!0).setSection("mx-link").onClick(async()=>{t.urlViewType.setPreferred({protocol:r,hostname:s,port:l},v),await t.leafOpener.openMedia(i,void 0,{viewType:v,fromUser:!0})}))})})}))}var zM=async function(t,e,n,i){let{metadataCache:r}=this.app,{path:s,subpath:a}=(0,An.parseLinktext)(t),o=r.getFirstLinkpathDest(s,e),l;if(!o||!(l=Xt(o.extension))){i();return}let c={file:o,hash:a,type:l,viewType:jn[l]};await this.leafOpener.openMedia(c,n,{fromUser:!0})};var Gr=require("obsidian");var Em=class extends Gr.Component{constructor(n){super();this.plugin=n;w(this,"app");w(this,"noteToMediaIndex",new Map);w(this,"mediaToNoteIndex",new Map);this.app=n.app}findNotes(n){let i=this.mediaToNoteIndex.get(km(n));return i?[...i]:[]}findMedia(n){return this.noteToMediaIndex.get(n.path)}onResolve(){this.noteToMediaIndex.clear(),this.mediaToNoteIndex.clear();let n={metadataCache:this.app.metadataCache,vault:this.app.vault,plugin:this.plugin};for(let{file:i,mediaInfo:r}of g4(n))this.addMediaNote(r,i);this.registerEvent(this.app.metadataCache.on("changed",i=>{let r=jM(i,n);r&&this.addMediaNote(r,i)})),this.registerEvent(this.app.metadataCache.on("deleted",i=>{this.removeMediaNote(i)})),this.registerEvent(this.app.vault.on("rename",(i,r)=>{if(!this.noteToMediaIndex.has(r))return;let s=this.noteToMediaIndex.get(r);this.noteToMediaIndex.delete(r),this.noteToMediaIndex.set(i.path,s)}))}removeMediaNote(n){let i=this.noteToMediaIndex.get(n.path);if(!i)return;this.noteToMediaIndex.delete(n.path);let r=km(i),s=this.mediaToNoteIndex.get(r);s&&(s.delete(n),s.size===0&&this.mediaToNoteIndex.delete(r))}addMediaNote(n,i){this.noteToMediaIndex.set(i.path,n);let r=this.mediaToNoteIndex.get(km(n));r?r.add(i):this.mediaToNoteIndex.set(km(n),new Set([i]))}onload(){m4(this.app.metadataCache,this).then(()=>{this.onResolve()})}};function m4(t,e){return t.initialized?Promise.resolve():new Promise(n=>{let i=t.on("initialized",()=>{t.offref(i),n()});e?.registerEvent(i)})}function*UM(t){for(let e of t.children)e instanceof Gr.TFolder?yield*UM(e):e instanceof Gr.TFile&&(yield e)}function*g4(t){for(let e of UM(t.vault.getRoot())){if(e.extension!=="md")continue;let n=jM(e,t);n&&(yield{mediaInfo:n,file:e})}}var Mb={generic:"media",video:"video",audio:"audio"};function jM(t,{metadataCache:e,plugin:n}){let i=e.getFileCache(t);if(!i)return null;let r={metadataCache:e,sourcePath:t.path,plugin:n};return Rb(Mb.video,i,r)??Rb(Mb.audio,i,r)??Rb(Mb.generic,i,r)}function Rb(t,e,n){let{frontmatter:i,frontmatterLinks:r}=e;if(!i||!(t in i))return null;let s=r?.find(o=>o.key===t);if(s){let{path:o,subpath:l}=(0,Gr.parseLinktext)(s.link),c=n.metadataCache.getFirstLinkpathDest(o,n.sourcePath);if(!c)return null;let u=Xt(c.extension);return u?{type:u,file:c,hash:l}:null}let a=i[t];return typeof a!="string"?null:n.plugin.resolveUrl(a)}function km(t){return $i(t)?`file:${t.file.path}`:`url:${t.jsonState.source}`}var qM=require("obsidian"),HM=$(Ol());var Lb=$(ae()),Tm=class extends qM.Component{constructor(n,i,r,s){super();this.info=n;this.file=i;this.subpath=r;this.plugin=s;w(this,"store");w(this,"root",null);w(this,"containerEl");this.containerEl=n.containerEl,this.store=Fr();let{containerEl:a}=n;a.addClasses(["mx","mx-media-embed","custom"]);function o(l){if(!(l instanceof Element))return!1;let c=l.closest("button");return c?c.hasAttribute(Hr):!1}this.registerDomEvent(a,"click",l=>{o(l.target)||l.stopImmediatePropagation()})}getMediaInfo(){if(!this.file)return null;let n=Xt(this.file.extension);return n?{type:n,file:this.file,hash:this.subpath}:null}render(){this.root?.unmount(),this.root=HM.default.createRoot(this.info.containerEl),this.root.render((0,Lb.jsx)(wt.Provider,{value:{plugin:this.plugin,store:this.store,reload:()=>this.render(),embed:!0},children:(0,Lb.jsx)(Wr,{})}))}onload(){super.onload(),this.render()}async loadFile(){await this.store.getState().loadFile(this.file,{vault:this.plugin.app.vault,subpath:this.subpath,defaultLang:this.plugin.settings.getState().getDefaultLang()})}onunload(){this.root?.unmount(),this.root=null,super.onunload()}};function BM(t,e){let n=e.muted;t.addItem(i=>i.setSection("mx-player").setIcon(n?"volume-2":"volume-x").setTitle(n?"Unmute":"Mute").onClick(()=>{e.muted=!n}))}function WM(t,e){e.state.canPictureInPicture&&(e.state.pictureInPicture?t.addItem(n=>n.setTitle("Exit Picture in Picture").setIcon("picture-in-picture-2").setSection("mx-player").onClick(()=>e.exitPictureInPicture())):t.addItem(n=>n.setTitle("Picture in Picture").setSection("mx-player").setIcon("picture-in-picture").onClick(()=>e.enterPictureInPicture())))}function KM(t,{setTransform:e,transform:n}){let i=t.setTitle("Transform").setIcon("rotate-3d").setSection("mx-player").setSubmenu();(n?.flipHorizontal||n?.flipVertical||n?.rotate)&&i.addItem(r=>r.setIcon("reset").setTitle("Reset").onClick(()=>e(null))),i.addItem(r=>r.setTitle("Flip horizontally").setIcon("flip-horizontal").setChecked(!!n?.flipHorizontal).onClick(()=>e({flipHorizontal:!n?.flipHorizontal}))).addItem(r=>r.setTitle("Flip vertically").setIcon("flip-vertical").setChecked(!!n?.flipVertical).onClick(()=>e({flipVertical:!n?.flipVertical}))).addSeparator().addItem(r=>r.setChecked(n?.rotate==="180").setIcon("iteration-cw").setTitle("Rotate 180\xB0").onClick(()=>{e({rotate:n?.rotate==="180"?void 0:"180"})}))}function GM(t,{source:e}){e.isFileUrl||t.addItem(n=>n.setTitle("Open in browser").setIcon("globe").setSection("view").onClick(()=>{window.open(e.href)}))}function YM(t,{controls:e=!0,toggleControls:n,player:i,source:r,disableWebFullscreen:s,toggleWebFullscreen:a},o){i.provider instanceof Rn&&o==="more-options"&&(t.addItem(l=>{l.setTitle(e?"Show website native controls":"Hide website controls").setSection("mx-web-player").setIcon("sliders-horizontal").onClick(()=>{n(!e)})}),r.type!=="bilibili"&&r.type!=="youtube"&&t.addItem(l=>{l.setTitle(s?"Enable in-player fullscreen":"Disable in-player fullscreen").setSection("mx-web-player").setIcon(s?"maximize":"minimize").onClick(()=>{a(!!s)})}))}function Ib(){FM(this),this.registerEvent(this.app.workspace.on("mx-media-menu",(t,e,n)=>{if((n==="more-options"||n==="sidebar-context-menu"||n==="tab-header"||n==="player-menu-embed")&&t.addItem(i=>i.setTitle("Refresh").setSection("view").setIcon("reset").onClick(()=>{e.reload()})),n!=="sidebar-context-menu"&&n!=="tab-header"?(t.addItem(i=>Cx(i,e.player)),e.player.state.viewType==="video"&&(t.addItem(i=>KM(i,e)),WM(t,e.player))):BM(t,e.player),n==="player-menu-embed"){let i=e.source;t.addItem(r=>r.setTitle("Open to the right").setIcon("separator-vertical").setSection("view").onClick(()=>{this.leafOpener.openMedia(i,"split")})).addItem(r=>r.setTitle("Open in new tab").setSection("view").setIcon("file-plus").onClick(()=>{this.leafOpener.openMedia(i,"tab")})).addItem(r=>r.setTitle("Open in new window").setSection("view").setIcon("maximize").onClick(()=>{this.leafOpener.openMedia(i,"window")}))}YM(t,e,n),(n==="player-menu-embed"||n==="more-options")&&GM(t,e)}))}var v4=/^(?\d+)?x(?\d+)$|^(?\d+)$/;function QM(t){let e=parseInt(t,10);return Number.isNaN(e)?-1:e}var Au=t=>{let e=t?.match(v4)?.groups;if(!e)return null;let n=QM(e.xOnly??e.x),i=QM(e.y);return[n,i]},Ab=t=>{let e=t.lastIndexOf("|"),n,i=t;return e===-1?(n=Au(t),n&&(i="")):(n=Au(i.substring(e+1)),n&&(i=i.substring(0,e))),[i,n]};var XM=require("obsidian"),ZM=$(Ol());var Nb=$(ae()),To=class extends XM.MarkdownRenderChild{constructor(n,i){super(n);this.containerEl=n;this.plugin=i;w(this,"store");w(this,"root",null);this.store=Fr(),n.addClasses(["mx","custom","mx-media-embed"])}getMediaInfo(){return this.store.getState().source?.url??null}async setSource(n,i={}){let r=this.plugin.urlViewType.getPreferred(n),s=this.plugin.settings.getState().getDefaultLang();this.store.getState().setSource(n,{title:i.title??!0,hash:i.hash,enableWebview:r===Zt,type:r===pt.video?"video/mp4":r===pt.audio?"audio/mp3":void 0,textTracks:r===pt.video?await If(n,s).catch(a=>(console.error("Failed to get text tracks",a,n.href,s),[])):[]})}render(){this.root?.unmount(),this.root=ZM.default.createRoot(this.containerEl),this.root.render((0,Nb.jsx)(wt.Provider,{value:{plugin:this.plugin,store:this.store,reload:()=>this.render(),embed:!0},children:(0,Nb.jsx)(Wr,{})}))}onload(){super.onload(),this.render()}onunload(){this.root?.unmount(),this.root=null,super.onunload()}};var iR=require("@codemirror/state"),So=require("@codemirror/view"),Po=require("obsidian");var Sm=require("@codemirror/language"),Ub=require("@codemirror/view");var JM=t=>!(!t.startsWith("./")&&!t.startsWith("../"))||t.indexOf(":")===-1;var eR=require("@codemirror/view"),tR=require("obsidian");var Db=class extends To{constructor(n,i){super(n,i);this.containerEl=n;this.plugin=i;n.addClasses(["mx-external-media-embed"]);function r(s){if(!(s instanceof Element))return!1;let a=s.closest("button");return a?a.hasAttribute(Hr):!1}this.registerDomEvent(n,"click",s=>{r(s.target)||s.stopImmediatePropagation()})}},js=class extends eR.WidgetType{constructor(n,i,r,s,a){super();this.plugin=n;this.media=i;this.title=r;this.start=s;this.end=a}setPos(n){let i=n.playerInfo;i&&(i.start=this.start,i.end=this.end)}hookClickHandler(n,i){i.on("click","button.mx-lp-edit",r=>{r.defaultPrevented||(this.selectElement(n,i),r.preventDefault())})}selectElement(n,i){let r=i.playerInfo,{start:s}=r??this,{end:a}=r??this;try{if(s<0||a<0){let o=n.posAtDOM(i);n.dispatch({selection:{head:o,anchor:o}}),n.focus()}else tR.Platform.isMobile&&(a=s),n.dispatch({selection:{head:s,anchor:a}}),n.focus()}catch{}}resizeWidget(n,i){window.ResizeObserver&&new window.ResizeObserver(()=>n.requestMeasure()).observe(i,{box:"border-box"})}setInfo(n,i){n.playerInfo={title:this.title,start:this.start,end:this.end,child:i,url:this.media}}updateDOM(n){let i=n.playerInfo;if(!i)return!1;let{title:r}=i;return this.media.compare(i.url)?this.title!==r&&(i.title=this.title,this.applyTitle(n),this.setPos(n)):i.child.setSource(this.media),!0}destroy(n){let i=n.playerInfo;i&&(delete n.playerInfo,i.child.unload())}eq(n){return this.media.compare(n.media)&&this.title===n.title}setDOM(n,i){i.tabIndex=-1,this.applyTitle(i);let r=new Db(i,this.plugin);r.setSource(this.media),r.load(),this.hookClickHandler(n,i),this.setInfo(i,r),this.resizeWidget(n,i)}applyTitle(n){if(!this.title){n.removeAttribute("alt"),n.style.removeProperty("width"),n.style.removeProperty("height");return}let i=this.title.lastIndexOf("|"),r,s=this.title;i===-1?(r=Au(this.title),r&&(s="")):(r=Au(s.substring(i+1)),r&&(s=s.substring(0,i))),s?n.setAttr("alt",s):n.removeAttribute("alt");let a=(o,l)=>{l<0?n.style.removeProperty(o):n.style[o]=`${l}px`};r?(a("width",r[0]),a("height",r[1])):(a("width",-1),a("height",-1))}toDOM(n){let i=createDiv();return i.style.display="none",i.setAttr("src",this.media.source.href),i.addClasses(["external-embed","cm-embed-block","mx-media-embed"]),i.style.removeProperty("display"),this.setDOM(n,i),i}};Object.defineProperty(js.prototype,"estimatedHeight",{get:()=>100,enumerable:!1,configurable:!0});var Ob=class extends js{constructor(){super(...arguments);w(this,"enableWebview",!1)}},Vb=class extends js{constructor(){super(...arguments);w(this,"enableWebview",!1)}},Fb=class extends js{constructor(){super(...arguments);w(this,"enableWebview",!1)}},zb=class extends js{constructor(){super(...arguments);w(this,"enableWebview",!0)}},nR={"mx-url-audio":Vb,"mx-url-video":Ob,"mx-embed":Fb,"mx-webpage":zb};var y4=(t,e,n,i,r)=>{let s=e.doc,a=!1,o="",l="",c=-1;(0,Sm.syntaxTree)(e).iterate({from:i,to:r,enter:({type:d,from:p,to:h})=>{let y=new Set(d.prop(Sm.tokenClassNodeProp)?.split(" "));if(y){if(y.has("image-marker"))a=!0,c=p;else if(y.has("image-alt-text")&&!y.has("formatting"))o=s.sliceString(p,h);else if(a&&y.has("url")&&!y.has("formatting"))l=s.sliceString(p,h);else if(a&&l&&y.has("formatting")){if(JM(l))return;let v=t.resolveUrl(l);if(v&&Eo(v,t)){let _=t.urlViewType.getPreferred(v),m=new nR[_](t,v,o,c,h);u(m,c,h)}a=!1,l="",o="",c=-1}}}});function u(d,p,h){let{from:v,text:_}=s.lineAt(p);_.substring(0,p-v).trim()===""&&_.substring(h-v).trim()===""?n.push(Ub.Decoration.widget({widget:d,block:!0,side:-1}).range(v)):n.push(Ub.Decoration.widget({widget:d,side:-1}).range(p))}},jb=y4;var _4=(t,e)=>Pm(t,e[0])||Pm(t,e[1]),Pm=(t,e)=>t[0]e,w4=(t,e)=>{let n=Pm(t,e[0])?t[0]:e[0],i=Pm(t,e[1])?t[1]:e[1];return[n,i]};function qb(t){return t.sort((e,n)=>e[0]-n[0]).reduce((e,n)=>{let i=e.findIndex(r=>_4(r,n));return i!==-1?e[i]=w4(e[i],n):e.push(n),e},[])}var b4=t=>{let e=n=>{if(n.field(Po.editorLivePreviewField)){let i=[];return jb(t,n,i),So.Decoration.set(i)}else return So.Decoration.none};return iR.StateField.define({create:e,update:(n,i)=>{let r=i.startState.field(Po.editorLivePreviewField),s=i.state.field(Po.editorLivePreviewField);if(r!==s)return e(i.state);if(!s)return So.Decoration.none;if(!i.docChanged)return n;if(i.state.field(Po.editorEditorField).composing)return n.map(i.changes);n=n.map(i.changes);let a=[];i.changes.iterChangedRanges((l,c,u,d)=>{a.push([i.state.doc.lineAt(u).number,i.state.doc.lineAt(d).number])});let o=[];for(let[l,c]of qb(a)){let{from:u}=i.state.doc.line(l),{to:d}=i.state.doc.line(c);n=n.update({filterFrom:u,filterTo:d,filter:()=>!1}),jb(t,i.state,o,u,d)}return n.update({add:o,sort:!0})},provide:n=>So.EditorView.decorations.from(n)})},rR=b4;function Hb(t){t.registerEditorExtension(rR(t)),k4(t)}var x4=["cm-line","cm-content"],sR="mxError";function aR(t){if(!t.parentElement)return!1;let e=t.parentElement;return x4.some(n=>e.classList.contains(n))}function oR(){aR(this)&&(this.dataset[sR]="",this.removeEventListener("load",lR))}function lR(){aR(this)&&(delete this.dataset[sR],this.removeEventListener("error",oR))}function k4(t){t.register(ut(window,{createEl:e=>function(){let n=e.apply(this,arguments);return n instanceof HTMLImageElement&&(n.addEventListener("error",oR,{once:!0}),n.addEventListener("load",lR,{once:!0})),n}}))}var E4=require("obsidian");function cR(t,e){let{app:n}=e;return new Promise(i=>{function r(){let s=n.workspace.getLeavesOfType(t)[0];return s?(i(s.view),!0):!1}n.workspace.onLayoutReady(()=>{if(r())return;let s=()=>{r()&&n.workspace.off("layout-change",s)};n.workspace.on("layout-change",s),e.register(()=>n.workspace.off("layout-change",s))})})}function Cm(t){return t.constructor.prototype}function Bb(t){t.getLeavesOfType("markdown").forEach(async e=>{let n=e.getViewState();await e.setViewState({type:"empty"}),await e.setViewState(n)})}function Kb(t){T4.call(this,t),S4.call(this),Hb(this)}function T4(t){let{app:e}=this;["video","audio"].forEach(r=>{let s=kt[r],a=i(s),o=n(s,t);this.register(()=>{o(),a()})}),Bb(e.workspace),this.register(()=>{Bb(e.workspace)});function n(r,s){return e.embedRegistry.registerExtensions(r,s),()=>{e.embedRegistry.unregisterExtensions(r)}}function i(r){let s=r.map(a=>e.embedRegistry.embedByExtension[a]);return e.embedRegistry.unregisterExtensions(r),()=>{r.forEach((a,o)=>{let l=s[o];l&&e.embedRegistry.registerExtension(a,l)})}}}var Wb=class extends To{constructor(n,i,r){super(i,r);this.info=n;this.containerEl=i;this.plugin=r;i.addClasses(["mx-external-media-embed"])}onload(){this.setSource(this.info)}};function S4(){let t=this;this.registerMarkdownPostProcessor((e,n)=>{for(let r of e.querySelectorAll("img")){let s=P4(r);s&&i(s,r)}for(let r of e.querySelectorAll('iframe[src*="youtube.com/embed/"]')){let s=n.getSectionInfo(r)?.text,a=C4(s)??$4(r);!a||!this.resolveUrl(a.url)||i(a,r)}function i({title:r,url:s},a){let o=t.resolveUrl(s);if(!o||!Eo(o,t))return;let l=createSpan({cls:["media-embed","external-embed","is-loaded"],attr:{src:o.href,alt:r}});a.replaceWith(l),n.addChild(new Wb(o,l,t))}})}function P4(t){let e=t.alt,n=t.src;if(!n)return null;let[i,r]=Ab(e);return{url:n,title:i,size:r}}function C4(t){if(!t)return null;let e=t.match(/!\[(?[^\]]*)\]\((?[^)]+)\)/);if(!e)return null;let{alt:n,src:i}=e.groups;if(!i)return null;let[r,s]=Ab(n);return{url:i,title:r,size:s}}function $4(t){console.warn("cannot get source text of iframe, use src instead");let e=t.src;return e?{url:e,title:zf(e),size:null}:null}var uR=require("obsidian");function $m(t){let e=uR.Keymap.isModEvent(t);return Nu(e)}function Nu(t){return t===!0?"tab":t}function Gb({onExternalLinkClick:t}){let e=this;return cR("markdown",e).then(n=>{if(!n.editMode){console.error("MarkdownView.editMode is not available, cannot patch editor click");return}e.register(ut(Cm(n.editMode),{triggerClickableToken:i=>async function(r,s,...a){let o=()=>i.call(this,r,s,...a);if(t&&r.type==="external-link")try{await t.call(e,r.text,Nu(s),o)}catch(l){console.error("onExternalLinkClick error in editor, fallback to default",l),o()}else o()}})),console.debug("editor click patched")})}var dR=require("obsidian");function Yb(){let t=n=>{let i=n.target;if(!i.instanceOf(HTMLElement)||!i.matches(".metadata-link-inner.external-link"))return;let r=this.resolveUrl(i.textContent);r&&(n.stopImmediatePropagation(),this.leafOpener.openMedia(r,$m(n),{fromUser:!0}))},e=ut(dR.MarkdownView.prototype,{onload:n=>function(){return this.registerDomEvent(this.containerEl,"click",t,{capture:!0}),n.call(this)}});this.register(()=>{e(),this.app.workspace.getLeavesOfType("markdown").forEach(n=>n.view.containerEl.removeEventListener("click",t))})}function Qb({onInternalLinkClick:t}){let e=this;this.register(ut(this.app.workspace,{openLinkText:n=>async function(i,r,s,a,...o){let l=()=>n.call(this,i,r,s,a,...o);try{await t.call(e,i,r,Nu(s),l)}catch(c){console.error("onInternalLinkClick error in openLinktext, fallback to default",c),l()}}}))}function Xb(){this.registerMarkdownPostProcessor(t=>t.querySelectorAll("a").forEach(e=>{let n=e.getAttr("aria-label");if(n)try{let i=decodeURI(n);n!==i&&e.setAttr("aria-label",i)}catch{}}))}var pR=require("obsidian");function Zb(t){let e=this,n=ut(pR.MarkdownPreviewRenderer,{registerDomEvents:i=>function(r,s,...a){return M4(s,t,e),n(),console.debug("preview click patched"),i.call(this,r,s,...a)}});e.register(n)}function M4(t,{onExternalLinkClick:e},n){n.register(ut(Cm(t),{onExternalLinkClick:i=>async function(r,s,a,...o){let l=()=>i.call(this,r,s,a,...o);if(!e)return l();r.preventDefault();try{await e.call(n,a,$m(r),l)}catch(c){console.error("onExternalLinkClick error in preview, fallback to default",c),l()}}}))}function Jb(t,e,n){let{app:i}=this;this.registerView(t,e),this.register(r(n)),this.registerExtensions(n,t);function r(s){let a=s.map(o=>({ext:o,type:i.viewRegistry.typeByExtension[o]}));return i.viewRegistry.unregisterExtensions(s),()=>{R4(a,"type").forEach((o,l)=>{l&&i.viewRegistry.registerExtensions(o.map(c=>c.ext),l)})}}}function R4(t,e){return t.reduce((n,i)=>{let r=i[e],s=n.get(r);return s?s.push(i):n.set(r,[i]),n},new Map)}var hR=require("obsidian");function fR(t){return t?(t=t instanceof URL?t:Un(t),hR.Platform.isWin||!t||t.protocol!=="file:"||!t.pathname.includes("%5C")||(t.pathname=t.pathname.replaceAll(/%5C/g,"/")),t):null}var kR=$(Rm()),nt=require("obsidian");var gR=()=>(...t)=>t;var vR=require("obsidian");var yR={6:"240P \u6781\u901F",16:"360P \u6D41\u7545",32:"480P \u6E05\u6670",64:"720P \u9AD8\u6E05",74:"720P60 \u9AD8\u5E27\u7387",80:"1080P \u9AD8\u6E05",112:"1080P+ \u9AD8\u7801\u7387",116:"1080P60 \u9AD8\u5E27\u7387",120:"4K \u8D85\u6E05",125:"HDR \u771F\u5F69\u8272",126:"\u675C\u6BD4\u89C6\u754C",127:"8K \u8D85\u9AD8\u6E05"};async function ex(t,e){await t.cookies.set({url:"https://www.bilibili.com",domain:".bilibili.com",path:"/",name:"CURRENT_QUALITY",value:e.toString(),expirationDate:Date.now()+1e3*60*60*24*365})}var _R=gR()("defaultVolume","urlMappingData","devices","defaultMxLinkClick","linkHandler","loadStrategy","timestampTemplate","screenshotTemplate","screenshotEmbedTemplate","insertBefore","timestampOffset","biliDefaultQuality","screenshotFormat","screenshotQuality","defaultLanguage"),wR={defaultVolume:80,urlMappingData:[],devices:[],defaultMxLinkClick:{click:"split",alt:"window"},linkHandler:{"mx-embed":[],"mx-url-audio":[],"mx-url-video":[],"mx-webpage":[]},loadStrategy:"eager",timestampTemplate:` +`);return await s.processFrontMatter(o,l=>{Object.assign(l,i(o.path))}),o};function IM(t){let e=[];return t.iterateRootLeaves(n=>{dg(n.view.getViewType())&&e.push(n)}),e.sort(Sm),e}function p4(t,e,n){let i=n.getLeavesOfType(e).filter(r=>Mi(t)?RM(r,t):LM(r,t));return i.sort(Sm),i}function Ib(t){return!!t&&dg(t.view.getViewType())}function Sm(t,e){return e.activeTime-t.activeTime}function h4(t,e){e.setEphemeralState({subpath:t})}function f4(t,e,n){return i=>{let r=n.workspace.activeEditor;if(!r)return t?t(i):void 0;if(e&&r.getMode()!=="preview")return r instanceof OM.MarkdownView&&r.inlineTitleEl.isActiveElement()?void 0:e(i,r.editor,r)}}function Qr({playerCheckCallback:t,noteCheckCallback:e,...n},i){let{app:r}=i,s=i.addCommand({...n,checkCallback:f4(t&&(a=>!t||!Ib(r.workspace.activeLeaf)?!1:a?!0:t(a,r.workspace.activeLeaf.view)),e&&((a,o,l)=>{if(!l.file)return!1;let c=i.mediaNote.findMedia(l.file),u=i.leafOpener.detectActiveMediaLeaf(r.workspace.activeLeaf);return e(a,u?.view,{isMediaNote:c,file:l.file,editor:o})}),r)});return!e||!n.menu||i.registerEvent(i.app.workspace.on("editor-menu",(a,o,l)=>{if(!l.file)return!1;let c=i.mediaNote.findMedia(l.file),u=i.leafOpener.detectActiveMediaLeaf(r.workspace.activeLeaf);if(!e(!0,u?.view,{isMediaNote:c,file:l.file,editor:o}))return;let d=l.file;a.addItem(p=>{n.icon&&p.setIcon(n.icon),n.name&&p.setTitle(n.name),n.section&&p.setSection(n.section),p.onClick(()=>{e(!1,u?.view,{isMediaNote:c,file:d,editor:o})})})})),s}var m4=[{id:"toggle-play",label:"Play/pause",icon:"play",action:t=>{t.paused=!t.paused}},...[5,30].flatMap(t=>[{id:`forward-${t}s`,label:`Forward ${t}s`,icon:"forward",action:e=>{e.currentTime+=t},repeat:!0},{id:`rewind-${t}s`,label:`Rewind ${t}s`,icon:"rewind",action:e=>{e.currentTime-=t},repeat:!0}]),{id:"toggle-mute",label:"Mute/unmute",icon:"volume-x",action:t=>{t.muted=!t.muted}},{id:"toggle-fullscreen",label:"Enter/exit fullscreen",icon:"expand",check:t=>t.state.canFullscreen,action:t=>{t.state.fullscreen?t.exitFullscreen():t.enterFullscreen()}},...g4()];function g4(){let t=null,e=(0,Vu.debounce)(()=>t?.hide(),2e3,!0);function n(r){!t||t.noticeEl.isConnected===!1?t=new Vu.Notice(r,0):t.setMessage(r),e()}function i(r){new Vu.Notice(r,2e3)}return[{id:"reset-speed",label:"Reset playback speed",icon:"reset",check:r=>r.state.playbackRate!==1,action:r=>{r.playbackRate=1,i("Speed reset to 1x")}},{id:"increase-speed",label:"Increase playback speed",icon:"arrow-up",action:r=>{let s=r.playbackRate;if(s>=li.last()){i("Cannot increase speed further");return}let a=li.find(o=>o>s);r.playbackRate=a,n(`Speed increased to ${a}x`)}},{id:"decrease-speed",label:"Decrease playback speed",icon:"arrow-down",action:r=>{let s=r.playbackRate;if(s<=li.first()){i("Cannot decrease speed further");return}let a=li.slice().reverse().find(o=>o{let s=await Zs.run();s&&(r.playbackRate=s,n(`Speed set to ${s}x`))}},{id:"increase-speed-granular",label:"Increase playback speed by 0.1x",icon:"arrow-up",action:r=>{let s=r.playbackRate;if(s>=li.last()){i("Cannot increase speed further");return}let a=Math.round((s+.1)*10)/10;r.playbackRate=a,n(`Speed increased to ${a}x`)}},{id:"decrease-speed-granular",label:"Decrease playback speed by 0.1x",icon:"arrow-down",action:r=>{let s=r.playbackRate;if(s<=li.first()){i("Cannot decrease speed further");return}let a=Math.round((s-.1)*10)/10;r.playbackRate=a,n(`Speed decreased to ${a}x`)}}]}function VM(t){m4.forEach(({id:e,label:n,icon:i,action:r,repeat:s,check:a})=>{Qr({id:e,name:n,icon:i,repeatable:s,playerCheckCallback:(o,l)=>{if(!l)return!1;let c=l.store.getState().player;if(!c||a&&!a(c))return!1;if(o)return!0;r(c)},noteCheckCallback(o,l){if(!l)return!1;let c=l.store.getState().player;if(!c||a&&!a(c))return!1;if(o)return!0;r(c)}},t)})}var Pm=require("obsidian");function FM(t){let e=null;Qr({id:"copy-screenshot",name:"Copy screenshot",icon:"copy",playerCheckCallback(i,r){if(i)return!0;let s=jf(r);s&&xu(s)},noteCheckCallback:n(i=>{let r=jf(i);r&&xu(r)}).noteCheckCallback},t),Qr({id:"take-timestamp",name:"Take timestamp",icon:"star",menu:!0,section:"selection-link",...n(async(i,r)=>{let s=e;e=r.file,await Eu(i,r)&&r.from==="player"&&s!==r.file&&new Pm.Notice(`Timestamp taken in "${r.file.basename}"`)})},t),Qr({id:"save-screenshot",name:"Save screenshot",icon:"camera",section:"selection-link",menu:!0,...n(async(i,r)=>{let s=e;e=r.file,await bu(i,r)&&r.from==="player"&&s!==r.file&&new Pm.Notice(`Taking screenshot in "${r.file.basename}"`)})},t),Qr({id:"take-timestamp-media-note",name:"Take timestamp in media note",icon:"star",menu:!0,section:"selection-link",playerCheckCallback(i,r){let s=r.getMediaInfo();if(!s)return!1;if(i)return!0;uo(s,r).then(a=>Eu(r,a))}},t),Qr({id:"save-screenshot-media-note",name:"Save screenshot in media note",icon:"camera",section:"selection-link",menu:!0,playerCheckCallback(i,r){let s=r.getMediaInfo();if(!s)return!1;if(i)return!0;uo(s,r).then(a=>bu(r,a))}},t);function n(i){return{playerCheckCallback:(r,s)=>{let a=v4(t.app);if(!a){if(r)return!1;new Pm.Notice("No active note can be edited");return}if(r)return!0;i(s,{file:a.view.file,editor:a.view.editor,from:"player"})},noteCheckCallback:(r,s,{isMediaNote:a,...o})=>{let l;if(s){if(r)return!0;t.app.workspace.revealLeaf(s.leaf),l=Promise.resolve(s)}else{if(!a)return!1;if(r)return!0;l=t.leafOpener.openMedia(a,void 0,{fromUser:!0}).then(c=>c.view)}l.then(c=>i(c,{...o,from:"note"}))}}}}function v4(t){return t.workspace.getLeavesOfType("markdown").filter(n=>{let i=n.view;return i.file&&i.getMode()==="source"}).sort(Sm)[0]??null}function UM(){this.registerEvent(this.app.workspace.on("file-menu",(t,e,n,i)=>{if(!(e instanceof zM.TFile))return;let r=this.mediaNote.findMedia(e);r&&t.addItem(s=>s.setSection("view").setIcon("play").setTitle("Open linked media").onClick(()=>this.leafOpener.openMedia(r,void 0,{fromUser:!0})))})),FM(this),VM(this)}var An=require("obsidian");function So(t,e){return!!(t.type!=="generic"||t.inferredType||t.tempFrag||e.mediaNote.findNotes(t).length>0||e.urlViewType.getPreferred(t,!0))}var Ab=async function(t,e,n){let i=this.resolveUrl(t);if(!i||!So(i,this)){n();return}await this.leafOpener.openMedia(i,e,{fromUser:!0})},jM={"mx-embed":{label:"iframe",icon:"code"},"mx-url-audio":{label:"regular audio",icon:"headphones"},"mx-url-video":{label:"regular video",icon:"film"},"mx-webpage":{label:"webpage",icon:"globe"}};async function y4(t){if(!An.Platform.isDesktopApp)return;let e=window.electron;if(!e)return;await(An.Platform.isMacOS?e.remote.shell:e.shell).showItemInFolder(t)}async function _4(t){if(!An.Platform.isDesktopApp)return;let e=window.electron;if(!e)return;let i=await(An.Platform.isMacOS?e.remote.shell:e.shell).openPath(t);if(i)throw new Error(i)}function HM(t){t.registerEvent(t.app.workspace.on("url-menu",(e,n)=>{let i=t.resolveUrl(n);if(!i)return;if(An.Platform.isDesktopApp&&i.isFileUrl&&i.filePath){let h=i.filePath;e.addItem(y=>y.setIcon("folder").setTitle(An.Platform.isMacOS?"Reveal in Finder":"Show in system explorer").onClick(()=>{y4(h).catch(v=>{new An.Notice(`Failed to open file in file explorer: ${v.message}`),console.error("Failed to open file in file explorer",v)})})).addItem(y=>y.setIcon("arrow-up-right").setTitle("Open in system player").onClick(()=>{_4(h).catch(v=>{new An.Notice(`Failed to open file in system player: ${v.message}`),console.error("Failed to open file in system player",v)})}))}let{protocol:r,hostname:s,pathname:a,host:o,port:l}=i,c=t.urlViewType.getSupported(i),u=t.urlViewType.getPreferred(i),d=So(i,t)?c.filter(h=>h!==u):c;if(d.length===0)return;function p(h,y,v=!1){let w=jM[y].label;return h.setTitle(v?w:`Open as ${w}`).setIcon(jM[y].icon)}d.forEach(h=>{e.addItem(y=>p(y,h).setSection("mx-link").onClick(async()=>{await t.leafOpener.openMedia(i,void 0,{viewType:h,fromUser:!0})}))}),e.addItem(h=>{let y=h.setTitle("Always open this url as").setIcon("external-link").setSection("mx-link").setSubmenu();d.forEach(v=>{y.addItem(w=>p(w,v,!0).setSection("mx-link").onClick(async()=>{t.urlViewType.setPreferred({protocol:r,hostname:s,pathname:a,port:l},v),await t.leafOpener.openMedia(i,void 0,{viewType:v,fromUser:!0})}))})}),s&&e.addItem(h=>{let y=h.setTitle(`Always open ${o} as`).setIcon("external-link").setSection("mx-link").setSubmenu();d.forEach(v=>{y.addItem(w=>p(w,v,!0).setSection("mx-link").onClick(async()=>{t.urlViewType.setPreferred({protocol:r,hostname:s,port:l},v),await t.leafOpener.openMedia(i,void 0,{viewType:v,fromUser:!0})}))})})}))}var qM=async function(t,e,n,i){let{metadataCache:r}=this.app,{path:s,subpath:a}=(0,An.parseLinktext)(t),o=r.getFirstLinkpathDest(s,e),l;if(!o||!(l=Xt(o.extension))){i();return}let c={file:o,hash:a,type:l,viewType:jn[l]};await this.leafOpener.openMedia(c,n,{fromUser:!0})};var Xr=require("obsidian");var $m=class extends Xr.Component{constructor(n){super();this.plugin=n;_(this,"app");_(this,"noteToMediaIndex",new Map);_(this,"mediaToNoteIndex",new Map);this.app=n.app}findNotes(n){let i=this.mediaToNoteIndex.get(Cm(n));return i?[...i]:[]}findMedia(n){return this.noteToMediaIndex.get(n.path)}onResolve(){this.noteToMediaIndex.clear(),this.mediaToNoteIndex.clear();let n={metadataCache:this.app.metadataCache,vault:this.app.vault,plugin:this.plugin};for(let{file:i,mediaInfo:r}of b4(n))this.addMediaNote(r,i);this.registerEvent(this.app.metadataCache.on("changed",i=>{let r=WM(i,n);r&&this.addMediaNote(r,i)})),this.registerEvent(this.app.metadataCache.on("deleted",i=>{this.removeMediaNote(i)})),this.registerEvent(this.app.vault.on("rename",(i,r)=>{if(!this.noteToMediaIndex.has(r))return;let s=this.noteToMediaIndex.get(r);this.noteToMediaIndex.delete(r),this.noteToMediaIndex.set(i.path,s)}))}removeMediaNote(n){let i=this.noteToMediaIndex.get(n.path);if(!i)return;this.noteToMediaIndex.delete(n.path);let r=Cm(i),s=this.mediaToNoteIndex.get(r);s&&(s.delete(n),s.size===0&&this.mediaToNoteIndex.delete(r))}addMediaNote(n,i){this.noteToMediaIndex.set(i.path,n);let r=this.mediaToNoteIndex.get(Cm(n));r?r.add(i):this.mediaToNoteIndex.set(Cm(n),new Set([i]))}onload(){w4(this.app.metadataCache,this).then(()=>{this.onResolve()})}};function w4(t,e){return t.initialized?Promise.resolve():new Promise(n=>{let i=t.on("initialized",()=>{t.offref(i),n()});e?.registerEvent(i)})}function*BM(t){for(let e of t.children)e instanceof Xr.TFolder?yield*BM(e):e instanceof Xr.TFile&&(yield e)}function*b4(t){for(let e of BM(t.vault.getRoot())){if(e.extension!=="md")continue;let n=WM(e,t);n&&(yield{mediaInfo:n,file:e})}}var Nb={generic:"media",video:"video",audio:"audio"};function WM(t,{metadataCache:e,plugin:n}){let i=e.getFileCache(t);if(!i)return null;let r={metadataCache:e,sourcePath:t.path,plugin:n};return Db(Nb.video,i,r)??Db(Nb.audio,i,r)??Db(Nb.generic,i,r)}function Db(t,e,n){let{frontmatter:i,frontmatterLinks:r}=e;if(!i||!(t in i))return null;let s=r?.find(o=>o.key===t);if(s){let{path:o,subpath:l}=(0,Xr.parseLinktext)(s.link),c=n.metadataCache.getFirstLinkpathDest(o,n.sourcePath);if(!c)return null;let u=Xt(c.extension);return u?{type:u,file:c,hash:l}:null}let a=i[t];return typeof a!="string"?null:n.plugin.resolveUrl(a)}function Cm(t){return Mi(t)?`file:${t.file.path}`:`url:${t.jsonState.source}`}var KM=require("obsidian"),GM=$(zl());var Ob=$(ae()),Mm=class extends KM.Component{constructor(n,i,r,s){super();this.info=n;this.file=i;this.subpath=r;this.plugin=s;_(this,"store");_(this,"root",null);_(this,"containerEl");this.containerEl=n.containerEl,this.store=Ur();let{containerEl:a}=n;a.addClasses(["mx","mx-media-embed","custom"]);function o(l){if(!(l instanceof Element))return!1;let c=l.closest("button");return c?c.hasAttribute(Wr):!1}this.registerDomEvent(a,"click",l=>{o(l.target)||l.stopImmediatePropagation()})}getMediaInfo(){if(!this.file)return null;let n=Xt(this.file.extension);return n?{type:n,file:this.file,hash:this.subpath}:null}render(){this.root?.unmount(),this.root=GM.default.createRoot(this.info.containerEl),this.root.render((0,Ob.jsx)(wt.Provider,{value:{plugin:this.plugin,store:this.store,reload:()=>this.render(),embed:!0},children:(0,Ob.jsx)(Gr,{})}))}onload(){super.onload(),this.render()}async loadFile(){await this.store.getState().loadFile(this.file,{vault:this.plugin.app.vault,subpath:this.subpath,defaultLang:this.plugin.settings.getState().getDefaultLang()})}onunload(){this.root?.unmount(),this.root=null,super.onunload()}};function YM(t,e){let n=e.muted;t.addItem(i=>i.setSection("mx-player").setIcon(n?"volume-2":"volume-x").setTitle(n?"Unmute":"Mute").onClick(()=>{e.muted=!n}))}function QM(t,e){e.state.canPictureInPicture&&(e.state.pictureInPicture?t.addItem(n=>n.setTitle("Exit Picture in Picture").setIcon("picture-in-picture-2").setSection("mx-player").onClick(()=>e.exitPictureInPicture())):t.addItem(n=>n.setTitle("Picture in Picture").setSection("mx-player").setIcon("picture-in-picture").onClick(()=>e.enterPictureInPicture())))}function XM(t,{setTransform:e,transform:n}){let i=t.setTitle("Transform").setIcon("rotate-3d").setSection("mx-player").setSubmenu();(n?.flipHorizontal||n?.flipVertical||n?.rotate)&&i.addItem(r=>r.setIcon("reset").setTitle("Reset").onClick(()=>e(null))),i.addItem(r=>r.setTitle("Flip horizontally").setIcon("flip-horizontal").setChecked(!!n?.flipHorizontal).onClick(()=>e({flipHorizontal:!n?.flipHorizontal}))).addItem(r=>r.setTitle("Flip vertically").setIcon("flip-vertical").setChecked(!!n?.flipVertical).onClick(()=>e({flipVertical:!n?.flipVertical}))).addSeparator().addItem(r=>r.setChecked(n?.rotate==="180").setIcon("iteration-cw").setTitle("Rotate 180\xB0").onClick(()=>{e({rotate:n?.rotate==="180"?void 0:"180"})}))}function ZM(t,{source:e}){e.isFileUrl||t.addItem(n=>n.setTitle("Open in browser").setIcon("globe").setSection("view").onClick(()=>{window.open(e.href)}))}function JM(t,{controls:e=!0,toggleControls:n,player:i,source:r,disableWebFullscreen:s,toggleWebFullscreen:a},o){i.provider instanceof Rn&&o==="more-options"&&(t.addItem(l=>{l.setTitle(e?"Show website native controls":"Hide website controls").setSection("mx-web-player").setIcon("sliders-horizontal").onClick(()=>{n(!e)})}),r.type!=="bilibili"&&r.type!=="youtube"&&t.addItem(l=>{l.setTitle(s?"Enable in-player fullscreen":"Disable in-player fullscreen").setSection("mx-web-player").setIcon(s?"maximize":"minimize").onClick(()=>{a(!!s)})}))}function Vb(){HM(this),this.registerEvent(this.app.workspace.on("mx-media-menu",(t,e,n)=>{if((n==="more-options"||n==="sidebar-context-menu"||n==="tab-header"||n==="player-menu-embed")&&t.addItem(r=>r.setTitle("Refresh").setSection("view").setIcon("reset").onClick(()=>{e.reload()})),n!=="sidebar-context-menu"&&n!=="tab-header"?(t.addItem(r=>Ix(r,e.player)),e.player.state.viewType==="video"&&(t.addItem(r=>XM(r,e)),QM(t,e.player))):YM(t,e.player),n==="player-menu-embed"){let r=e.source;t.addItem(s=>s.setTitle("Open to the right").setIcon("separator-vertical").setSection("view").onClick(()=>{this.leafOpener.openMedia(r,"split")})).addItem(s=>s.setTitle("Open in new tab").setSection("view").setIcon("file-plus").onClick(()=>{this.leafOpener.openMedia(r,"tab")})).addItem(s=>s.setTitle("Open in new window").setSection("view").setIcon("maximize").onClick(()=>{this.leafOpener.openMedia(r,"window")}))}JM(t,e,n),(n==="player-menu-embed"||n==="more-options")&&ZM(t,e);let i=e.player.provider;(n==="player-menu-embed"||n==="more-options"||n==="sidebar-context-menu")&&zs(i)&&t.addItem(r=>r.setTitle("Copy Screenshot").setSection("view").setIcon("copy").onClick(()=>{xu({app:this.app,media:e.source,provider:i,settings:this.settings.getState(),state:e.player.state})}))}))}var x4=/^(?\d+)?x(?\d+)$|^(?\d+)$/;function eR(t){let e=parseInt(t,10);return Number.isNaN(e)?-1:e}var Fu=t=>{let e=t?.match(x4)?.groups;if(!e)return null;let n=eR(e.xOnly??e.x),i=eR(e.y);return[n,i]},Fb=t=>{let e=t.lastIndexOf("|"),n,i=t;return e===-1?(n=Fu(t),n&&(i="")):(n=Fu(i.substring(e+1)),n&&(i=i.substring(0,e))),[i,n]};var tR=require("obsidian"),nR=$(zl());var zb=$(ae()),Po=class extends tR.MarkdownRenderChild{constructor(n,i){super(n);this.containerEl=n;this.plugin=i;_(this,"store");_(this,"root",null);this.store=Ur(),n.addClasses(["mx","custom","mx-media-embed"])}getMediaInfo(){return this.store.getState().source?.url??null}async setSource(n,i={}){let r=this.plugin.urlViewType.getPreferred(n),s=this.plugin.settings.getState().getDefaultLang();this.store.getState().setSource(n,{title:i.title??!0,hash:i.hash,enableWebview:r===Zt,type:r===pt.video?"video/mp4":r===pt.audio?"audio/mp3":void 0,textTracks:r===pt.video?await Ff(n,s).catch(a=>(console.error("Failed to get text tracks",a,n.href,s),[])):[]})}render(){this.root?.unmount(),this.root=nR.default.createRoot(this.containerEl),this.root.render((0,zb.jsx)(wt.Provider,{value:{plugin:this.plugin,store:this.store,reload:()=>this.render(),embed:!0},children:(0,zb.jsx)(Gr,{})}))}onload(){super.onload(),this.render()}onunload(){this.root?.unmount(),this.root=null,super.onunload()}};var oR=require("@codemirror/state"),Co=require("@codemirror/view"),$o=require("obsidian");var Rm=require("@codemirror/language"),Wb=require("@codemirror/view");var iR=t=>!(!t.startsWith("./")&&!t.startsWith("../"))||t.indexOf(":")===-1;var rR=require("@codemirror/view"),sR=require("obsidian");var Ub=class extends Po{constructor(n,i){super(n,i);this.containerEl=n;this.plugin=i;n.addClasses(["mx-external-media-embed"]);function r(s){if(!(s instanceof Element))return!1;let a=s.closest("button");return a?a.hasAttribute(Wr):!1}this.registerDomEvent(n,"click",s=>{r(s.target)||s.stopImmediatePropagation()})}},qs=class extends rR.WidgetType{constructor(n,i,r,s,a){super();this.plugin=n;this.media=i;this.title=r;this.start=s;this.end=a}setPos(n){let i=n.playerInfo;i&&(i.start=this.start,i.end=this.end)}hookClickHandler(n,i){i.on("click","button.mx-lp-edit",r=>{r.defaultPrevented||(this.selectElement(n,i),r.preventDefault())})}selectElement(n,i){let r=i.playerInfo,{start:s}=r??this,{end:a}=r??this;try{if(s<0||a<0){let o=n.posAtDOM(i);n.dispatch({selection:{head:o,anchor:o}}),n.focus()}else sR.Platform.isMobile&&(a=s),n.dispatch({selection:{head:s,anchor:a}}),n.focus()}catch{}}resizeWidget(n,i){window.ResizeObserver&&new window.ResizeObserver(()=>n.requestMeasure()).observe(i,{box:"border-box"})}setInfo(n,i){n.playerInfo={title:this.title,start:this.start,end:this.end,child:i,url:this.media}}updateDOM(n){let i=n.playerInfo;if(!i)return!1;let{title:r}=i;return this.media.compare(i.url)?this.title!==r&&(i.title=this.title,this.applyTitle(n),this.setPos(n)):i.child.setSource(this.media),!0}destroy(n){let i=n.playerInfo;i&&(delete n.playerInfo,i.child.unload())}eq(n){return this.media.compare(n.media)&&this.title===n.title}setDOM(n,i){i.tabIndex=-1,this.applyTitle(i);let r=new Ub(i,this.plugin);r.setSource(this.media),r.load(),this.hookClickHandler(n,i),this.setInfo(i,r),this.resizeWidget(n,i)}applyTitle(n){if(!this.title){n.removeAttribute("alt"),n.style.removeProperty("width"),n.style.removeProperty("height");return}let i=this.title.lastIndexOf("|"),r,s=this.title;i===-1?(r=Fu(this.title),r&&(s="")):(r=Fu(s.substring(i+1)),r&&(s=s.substring(0,i))),s?n.setAttr("alt",s):n.removeAttribute("alt");let a=(o,l)=>{l<0?n.style.removeProperty(o):n.style[o]=`${l}px`};r?(a("width",r[0]),a("height",r[1])):(a("width",-1),a("height",-1))}toDOM(n){let i=createDiv();return i.style.display="none",i.setAttr("src",this.media.source.href),i.addClasses(["external-embed","cm-embed-block","mx-media-embed"]),i.style.removeProperty("display"),this.setDOM(n,i),i}};Object.defineProperty(qs.prototype,"estimatedHeight",{get:()=>100,enumerable:!1,configurable:!0});var jb=class extends qs{constructor(){super(...arguments);_(this,"enableWebview",!1)}},Hb=class extends qs{constructor(){super(...arguments);_(this,"enableWebview",!1)}},qb=class extends qs{constructor(){super(...arguments);_(this,"enableWebview",!1)}},Bb=class extends qs{constructor(){super(...arguments);_(this,"enableWebview",!0)}},aR={"mx-url-audio":Hb,"mx-url-video":jb,"mx-embed":qb,"mx-webpage":Bb};var k4=(t,e,n,i,r)=>{let s=e.doc,a=!1,o="",l="",c=-1;(0,Rm.syntaxTree)(e).iterate({from:i,to:r,enter:({type:d,from:p,to:h})=>{let y=new Set(d.prop(Rm.tokenClassNodeProp)?.split(" "));if(y){if(y.has("image-marker"))a=!0,c=p;else if(y.has("image-alt-text")&&!y.has("formatting"))o=s.sliceString(p,h);else if(a&&y.has("url")&&!y.has("formatting"))l=s.sliceString(p,h);else if(a&&l&&y.has("formatting")){if(iR(l))return;let v=t.resolveUrl(l);if(v&&So(v,t)){let w=t.urlViewType.getPreferred(v),m=new aR[w](t,v,o,c,h);u(m,c,h)}a=!1,l="",o="",c=-1}}}});function u(d,p,h){let{from:v,text:w}=s.lineAt(p);w.substring(0,p-v).trim()===""&&w.substring(h-v).trim()===""?n.push(Wb.Decoration.widget({widget:d,block:!0,side:-1}).range(v)):n.push(Wb.Decoration.widget({widget:d,side:-1}).range(p))}},Kb=k4;var E4=(t,e)=>Lm(t,e[0])||Lm(t,e[1]),Lm=(t,e)=>t[0]e,T4=(t,e)=>{let n=Lm(t,e[0])?t[0]:e[0],i=Lm(t,e[1])?t[1]:e[1];return[n,i]};function Gb(t){return t.sort((e,n)=>e[0]-n[0]).reduce((e,n)=>{let i=e.findIndex(r=>E4(r,n));return i!==-1?e[i]=T4(e[i],n):e.push(n),e},[])}var S4=t=>{let e=n=>{if(n.field($o.editorLivePreviewField)){let i=[];return Kb(t,n,i),Co.Decoration.set(i)}else return Co.Decoration.none};return oR.StateField.define({create:e,update:(n,i)=>{let r=i.startState.field($o.editorLivePreviewField),s=i.state.field($o.editorLivePreviewField);if(r!==s)return e(i.state);if(!s)return Co.Decoration.none;if(!i.docChanged)return n;if(i.state.field($o.editorEditorField).composing)return n.map(i.changes);n=n.map(i.changes);let a=[];i.changes.iterChangedRanges((l,c,u,d)=>{a.push([i.state.doc.lineAt(u).number,i.state.doc.lineAt(d).number])});let o=[];for(let[l,c]of Gb(a)){let{from:u}=i.state.doc.line(l),{to:d}=i.state.doc.line(c);n=n.update({filterFrom:u,filterTo:d,filter:()=>!1}),Kb(t,i.state,o,u,d)}return n.update({add:o,sort:!0})},provide:n=>Co.EditorView.decorations.from(n)})},lR=S4;function Yb(t){t.registerEditorExtension(lR(t)),C4(t)}var P4=["cm-line","cm-content"],cR="mxError";function uR(t){if(!t.parentElement)return!1;let e=t.parentElement;return P4.some(n=>e.classList.contains(n))}function dR(){uR(this)&&(this.dataset[cR]="",this.removeEventListener("load",pR))}function pR(){uR(this)&&(delete this.dataset[cR],this.removeEventListener("error",dR))}function C4(t){t.register(ut(window,{createEl:e=>function(){let n=e.apply(this,arguments);return n instanceof HTMLImageElement&&(n.addEventListener("error",dR,{once:!0}),n.addEventListener("load",pR,{once:!0})),n}}))}var $4=require("obsidian");function hR(t,e){let{app:n}=e;return new Promise(i=>{function r(){let s=n.workspace.getLeavesOfType(t)[0];return s?(i(s.view),!0):!1}n.workspace.onLayoutReady(()=>{if(r())return;let s=()=>{r()&&n.workspace.off("layout-change",s)};n.workspace.on("layout-change",s),e.register(()=>n.workspace.off("layout-change",s))})})}function Im(t){return t.constructor.prototype}function Qb(t){t.getLeavesOfType("markdown").forEach(async e=>{let n=e.getViewState();await e.setViewState({type:"empty"}),await e.setViewState(n)})}function Zb(t){M4.call(this,t),R4.call(this),Yb(this)}function M4(t){let{app:e}=this;["video","audio"].forEach(r=>{let s=kt[r],a=i(s),o=n(s,t);this.register(()=>{o(),a()})}),Qb(e.workspace),this.register(()=>{Qb(e.workspace)});function n(r,s){return e.embedRegistry.registerExtensions(r,s),()=>{e.embedRegistry.unregisterExtensions(r)}}function i(r){let s=r.map(a=>e.embedRegistry.embedByExtension[a]);return e.embedRegistry.unregisterExtensions(r),()=>{r.forEach((a,o)=>{let l=s[o];l&&e.embedRegistry.registerExtension(a,l)})}}}var Xb=class extends Po{constructor(n,i,r){super(i,r);this.info=n;this.containerEl=i;this.plugin=r;i.addClasses(["mx-external-media-embed"])}onload(){this.setSource(this.info)}};function R4(){let t=this;this.registerMarkdownPostProcessor((e,n)=>{for(let r of e.querySelectorAll("img")){let s=L4(r);s&&i(s,r)}for(let r of e.querySelectorAll('iframe.external-embed[src*="youtube.com/embed/"]')){let s=n.getSectionInfo(r)?.text,a=I4(s)??A4(r);!a||!this.resolveUrl(a.url)||i(a,r)}function i({title:r,url:s},a){let o=t.resolveUrl(s);if(!o||!So(o,t))return;let l=createSpan({cls:["media-embed","external-embed","is-loaded"],attr:{src:o.href,alt:r}});a.replaceWith(l),n.addChild(new Xb(o,l,t))}})}function L4(t){let e=t.alt,n=t.src;if(!n)return null;let[i,r]=Fb(e);return{url:n,title:i,size:r}}function I4(t){if(!t)return null;let e=t.match(/!\[(?[^\]]*)\]\((?[^)]+)\)/);if(!e)return null;let{alt:n,src:i}=e.groups;if(!i)return null;let[r,s]=Fb(n);return{url:i,title:r,size:s}}function A4(t){console.warn("cannot get source text of iframe, use src instead");let e=t.src;return e?{url:e,title:Hf(e),size:null}:null}var fR=require("obsidian");function Am(t){let e=fR.Keymap.isModEvent(t);return zu(e)}function zu(t){return t===!0?"tab":t}function Jb({onExternalLinkClick:t}){let e=this;return hR("markdown",e).then(n=>{if(!n.editMode){console.error("MarkdownView.editMode is not available, cannot patch editor click");return}e.register(ut(Im(n.editMode),{triggerClickableToken:i=>async function(r,s,...a){let o=()=>i.call(this,r,s,...a);if(t&&r.type==="external-link")try{await t.call(e,r.text,zu(s),o)}catch(l){console.error("onExternalLinkClick error in editor, fallback to default",l),o()}else o()}})),console.debug("editor click patched")})}var mR=require("obsidian");function ex(){let t=n=>{let i=n.target;if(!i.instanceOf(HTMLElement)||!i.matches(".metadata-link-inner.external-link"))return;let r=this.resolveUrl(i.textContent);r&&(n.stopImmediatePropagation(),this.leafOpener.openMedia(r,Am(n),{fromUser:!0}))},e=ut(mR.MarkdownView.prototype,{onload:n=>function(){return this.registerDomEvent(this.containerEl,"click",t,{capture:!0}),n.call(this)}});this.register(()=>{e(),this.app.workspace.getLeavesOfType("markdown").forEach(n=>n.view.containerEl.removeEventListener("click",t))})}function tx({onInternalLinkClick:t}){let e=this;this.register(ut(this.app.workspace,{openLinkText:n=>async function(i,r,s,a,...o){let l=()=>n.call(this,i,r,s,a,...o);try{await t.call(e,i,r,zu(s),l)}catch(c){console.error("onInternalLinkClick error in openLinktext, fallback to default",c),l()}}}))}function nx(){this.registerMarkdownPostProcessor(t=>t.querySelectorAll("a").forEach(e=>{let n=e.getAttr("aria-label");if(n)try{let i=decodeURI(n);n!==i&&e.setAttr("aria-label",i)}catch{}}))}var gR=require("obsidian");function ix(t){let e=this,n=ut(gR.MarkdownPreviewRenderer,{registerDomEvents:i=>function(r,s,...a){return N4(s,t,e),n(),console.debug("preview click patched"),i.call(this,r,s,...a)}});e.register(n)}function N4(t,{onExternalLinkClick:e},n){n.register(ut(Im(t),{onExternalLinkClick:i=>async function(r,s,a,...o){let l=()=>i.call(this,r,s,a,...o);if(!e)return l();r.preventDefault();try{await e.call(n,a,Am(r),l)}catch(c){console.error("onExternalLinkClick error in preview, fallback to default",c),l()}}}))}function rx(t,e,n){let{app:i}=this;this.registerView(t,e),this.register(r(n)),this.registerExtensions(n,t);function r(s){let a=s.map(o=>({ext:o,type:i.viewRegistry.typeByExtension[o]}));return i.viewRegistry.unregisterExtensions(s),()=>{D4(a,"type").forEach((o,l)=>{l&&i.viewRegistry.registerExtensions(o.map(c=>c.ext),l)})}}}function D4(t,e){return t.reduce((n,i)=>{let r=i[e],s=n.get(r);return s?s.push(i):n.set(r,[i]),n},new Map)}var vR=require("obsidian");function yR(t){return t?(t=t instanceof URL?t:Un(t),vR.Platform.isWin||!t||t.protocol!=="file:"||!t.pathname.includes("%5C")||(t.pathname=t.pathname.replaceAll(/%5C/g,"/")),t):null}var PR=$(Dm()),nt=require("obsidian");var wR=()=>(...t)=>t;var bR=require("obsidian");var xR={6:"240P \u6781\u901F",16:"360P \u6D41\u7545",32:"480P \u6E05\u6670",64:"720P \u9AD8\u6E05",74:"720P60 \u9AD8\u5E27\u7387",80:"1080P \u9AD8\u6E05",112:"1080P+ \u9AD8\u7801\u7387",116:"1080P60 \u9AD8\u5E27\u7387",120:"4K \u8D85\u6E05",125:"HDR \u771F\u5F69\u8272",126:"\u675C\u6BD4\u89C6\u754C",127:"8K \u8D85\u9AD8\u6E05"};async function sx(t,e){await t.cookies.set({url:"https://www.bilibili.com",domain:".bilibili.com",path:"/",name:"CURRENT_QUALITY",value:e.toString(),expirationDate:Date.now()+1e3*60*60*24*365})}var kR=wR()("defaultVolume","urlMappingData","devices","defaultMxLinkClick","linkHandler","loadStrategy","timestampTemplate","screenshotTemplate","screenshotEmbedTemplate","insertBefore","timestampOffset","biliDefaultQuality","screenshotFormat","screenshotQuality","defaultLanguage"),ER={defaultVolume:80,urlMappingData:[],devices:[],defaultMxLinkClick:{click:"split",alt:"window"},linkHandler:{"mx-embed":[],"mx-url-audio":[],"mx-url-video":[],"mx-webpage":[]},loadStrategy:"eager",timestampTemplate:` - {{TIMESTAMP}} `,screenshotEmbedTemplate:"{{TITLE}}{{DURATION}}|50",screenshotTemplate:` -- !{{SCREENSHOT}} {{TIMESTAMP}} `,insertBefore:!1,timestampOffset:0,biliDefaultQuality:80,screenshotFormat:"image/webp"};function bR(){return nt.Platform.isDesktopApp?require("os").hostname()||(nt.Platform.isMacOS?"Mac":nt.Platform.isWin?"Windows":nt.Platform.isLinux?"Linux":"Desktop"):nt.Platform.isIosApp?nt.Platform.isPhone?"iPhone":nt.Platform.isTablet?"iPad":"iOS Device":nt.Platform.isAndroidApp?nt.Platform.isPhone?"Android Phone":nt.Platform.isTablet?"Android Tablet":"Android Device":"Unknown Device"}function xR(t){return new Map(t.map(e=>[`${e.appId}%${e.protocol}`,e.replace]))}function L4(t){return Array.from(t.entries()).map(([e,n])=>{let[i,r]=e.split("%");return{appId:i,protocol:r,replace:n}}).filter(e=>e.appId&&e.protocol&&e.replace)}function ER(t){let e=(0,nt.debounce)(n=>{let i=ig(n,_R);t.saveData({...i,urlMappingData:n.getUrlMappingData()})},1e3);return _p((n,i)=>({...Ku(wR,["urlMappingData"]),setScreenshotFormat(r){n({screenshotFormat:r}),e(i())},setScreenshotQuality(r){n({screenshotQuality:r??void 0}),e(i())},setDefaultLanguage(r){n({defaultLanguage:r?.format()}),e(i())},getDefaultLang(){let r=i().defaultLanguage,s=nt.moment.locale();return r&&!nb(r)?(new nt.Notice(`Invalid language code detected in preferences: ${r}, reverting to ${s}.`),n({defaultLanguage:void 0}),e(i()),s):r??nt.moment.locale()},getUrlMappingData(){return L4(i().urlMapping)},setBiliDefaultQuality(r){n({biliDefaultQuality:r}),e(i())},setInsertPosition(r){n({insertBefore:r==="before"}),e(i())},setLinkHandler(r,s){n(a=>{let o={...a.linkHandler};for(let l of Object.keys(o)){let c=l;o[c]=o[c].filter(u=>typeof u=="string"?u!==r:typeof r=="string"||!I4(u,r)),c===s&&(o[c]=[...o[c],r])}return{linkHandler:o}}),e(i())},setTimestampOffset(r){n({timestampOffset:r}),e(i())},setDefaultMxLinkBehavior:r=>{let s;r==="split"?s="window":r==="window"?s="tab":r==="tab"?s="split":s=null,n({defaultMxLinkClick:{click:r,alt:s}}),e(i())},setTemplate(r,s){switch(r){case"screenshot":n({screenshotTemplate:s});break;case"screenshotEmbed":n({screenshotEmbedTemplate:s});break;case"timestamp":n({timestampTemplate:s});break;default:(0,kR.assertNever)(r)}e(i())},setMxLinkAltBehavior:r=>{n(({defaultMxLinkClick:s})=>({defaultMxLinkClick:{...s,alt:r}})),e(i())},urlMapping:xR(wR.urlMappingData),setDefaultVolume:r=>{n({defaultVolume:r}),e(i())},getUrlMapping:r=>i().urlMapping.get(`${t.app.appId}%${r}`),setUrlMapping:(r,s)=>{if(r.includes("%"))throw new Error("Protocol cannot contain %");let a=`${t.app.appId}%${r}`;n(o=>({urlMapping:new Map(o.urlMapping).set(a,s),devices:o.getDeviceName()?o.devices:[...o.devices,{appId:t.app.appId,name:bR()}]})),e(i())},removeUrlMapping:r=>{if(r.includes("%"))throw new Error("Protocol cannot contain %");n(s=>{let a=`${t.app.appId}%${r}`,o=new Map(s.urlMapping);return o.delete(a),{urlMapping:o}}),e(i())},getDeviceName(r=t.app.appId){return i().devices.find(s=>s.appId===r)?.name},getDeviceNameWithDefault(r=t.app.appId){let s=i().devices.find(a=>a.appId===r);return s?s.name:r===t.app.appId?bR():"Unknown Device"},setDeviceName(r,s=t.app.appId){n({devices:[...i().devices.filter(a=>a.appId!==s),{appId:s,name:r}]}),e(i())},setLoadStrategy:r=>{n({loadStrategy:r}),e(i())},load:async()=>{let r=await t.loadData();if(!r)return;let{urlMappingData:s,...a}=ig(r,_R);n({...a,urlMapping:xR(s??[])})},save:()=>{e(i())}}))}function I4(t,e){let n=new Set([...Object.keys(t),...Object.keys(e)]);for(let i of n)if(t[i]!==e[i])return!1;return!0}var PR=require("url"),nx=$(eb()),ne=require("obsidian");var Im=class extends ne.PluginSettingTab{constructor(n){super(n.app,n);w(this,"plugin");this.plugin=n}get state(){return this.plugin.settings.getState()}get sub(){return this.plugin.settings.subscribe.bind(this.plugin.settings)}protocol(){new ne.Setting(this.containerEl).setHeading().setName("Protocols").setDesc("Create custom protocols that resolve link per device");let n=this.containerEl.createDiv({cls:"mx-protocol-container"});new ne.Setting(n).setHeading().setName("This device").addText(o=>o.setPlaceholder(this.state.getDeviceNameWithDefault()).setValue(this.state.getDeviceName()??"").onChange(l=>this.state.setDeviceName(l))).addExtraButton(o=>o.setIcon("plus").setTooltip("Add new protocol").onClick(()=>{let l=new ne.Menu().addItem(c=>c.setIcon("link").setTitle("Link mapping").onClick(()=>{let u=r({protocol:"",replace:"https://"});i.insertAdjacentElement("afterbegin",u.settingEl)}));ne.Platform.isDesktopApp&&l.addItem(c=>c.setIcon("folder").setTitle("Folder mapping").onClick(async()=>{let u=(await Yu().showOpenDialog({title:"Pick a folder",message:"Pick a folder to resolve media files from",buttonLabel:"Pick",properties:["openDirectory"]})).filePaths[0];if(!u)return;let d=r({protocol:"",replace:(0,PR.pathToFileURL)(u).href});i.insertAdjacentElement("afterbegin",d.settingEl)})),Gs(o.extraSettingsEl,l)}));let i=n.createDiv({cls:"mx-protocol-list"}),r=o=>new ne.Setting(i).then(l=>{let c=o.protocol,u=new ne.TextComponent(l.controlEl).setPlaceholder("Protocol name").setValue(c).onChange(h=>{if(!h)return;let y=c;c=h,this.state.removeUrlMapping(y);let v=p.getValue();v&&this.state.setUrlMapping(h,v)}),d="Target URL prefix";if(o.devices){d="Configured in ";let h=o.devices.filter(y=>!!y).slice(0,2);h.length>0?(d+=h.join(", "),h.length1&&(d+="s"))}let p=new ne.TextComponent(l.controlEl).setPlaceholder(d).setValue(o.replace).onChange(h=>{u.getValue()&&this.state.setUrlMapping(u.getValue(),h)});u.inputEl.addClass("mx-protocol-input"),p.inputEl.addClass("mx-replace-input"),l.addExtraButton(h=>h.setIcon("trash").setTooltip(`Remove ${u.getValue()||"empty"} protocol`).onClick(()=>{this.state.removeUrlMapping(u.getValue()),l.settingEl.remove()}))}),s=this.state.getUrlMappingData();[...new Set(s.map(o=>o.protocol))].sort().forEach(o=>{r({protocol:o,devices:s.filter(l=>l.protocol===o&&l.appId!==this.plugin.app.appId).map(l=>this.state.devices.find(c=>c.appId===l.appId)?.name??null),replace:this.state.getUrlMapping(o)??""})})}linkOpen(){let{containerEl:n}=this;new ne.Setting(n).setHeading().setName("Link open").setDesc("Configure how links to media are opened");let i={default:"Default obsidian behavior",replace:"In current pane",split:"New pane on the side",tab:"New tab",window:"New window"},r=c=>{switch(c){case"split":return ne.Platform.isMacOS?"click holding \u2318+\u2325":"click holding Ctrl+Alt";case"tab":return ne.Platform.isMacOS?"click holding \u2318 or middle-click":"middle-click or click holding Ctrl";case"window":return ne.Platform.isMacOS?"click holding \u2318+\u2325+\u21E7":"click holding Ctrl+Alt+Shift";default:return""}},s=c=>c===null?"default":c===!1?"replace":c,a=c=>{switch(c){case"replace":return!1;case"split":case"tab":case"window":return c;default:return null}};new ne.Setting(n).setName("Default link click").setDesc("Configure how links to media are opened").addDropdown(c=>c.addOptions(i).setValue(s(this.state.defaultMxLinkClick.click)).onChange(u=>this.state.setDefaultMxLinkBehavior(a(u))).then(()=>this.sub((u,d)=>{u.defaultMxLinkClick.click!==d.defaultMxLinkClick.click&&c.setValue(s(u.defaultMxLinkClick.click))})));let o=new ne.Setting(n).setName("Altnernative behavior").addDropdown(c=>c.addOptions(i).setValue(s(this.state.defaultMxLinkClick.alt)).onChange(u=>this.state.setMxLinkAltBehavior(a(u))).then(()=>this.sub((u,d)=>{u.defaultMxLinkClick.alt!==d.defaultMxLinkClick.alt&&c.setValue(s(u.defaultMxLinkClick.alt))})));function l(c){o.settingEl.style.display=c?"":"none";let u=r(c);o.setDesc("Configure link open behavior"+u?` when ${u}`:"")}l(this.state.defaultMxLinkClick.click),this.sub((c,u)=>{c.defaultMxLinkClick!==u.defaultMxLinkClick&&l(c.defaultMxLinkClick.click)})}playback(){let{containerEl:n}=this;new ne.Setting(n).setHeading().setName("Playback"),new ne.Setting(n).setName("Default volume").setDesc("The default volume for media files").addSlider(a=>a.setLimits(0,100,1).setValue(this.state.defaultVolume).onChange(this.state.setDefaultVolume).then(o=>{this.sub((l,c)=>{l.defaultVolume!==c.defaultVolume&&o.setValue(l.defaultVolume)})})).addText(a=>a.setValue(Lm(this.state.defaultVolume)).onChange(TR(this.state.setDefaultVolume)).then(o=>{tx.call(o,0,100,1),o.inputEl.type="number",o.inputEl.style.textAlign="center",this.sub((l,c)=>{l.defaultVolume!==c.defaultVolume&&o.setValue(Lm(l.defaultVolume))})})).then(a=>a.controlEl.appendText("%")),new ne.Setting(n).setName("Load strategy").setDesc(createFragment(a=>{a.appendText("Configure when media embeds are loaded in the note"),a.createEl("br"),a.appendText("Useful if you want lazy load media embeds in a note when there are many of them")})).addDropdown(a=>a.addOption("eager","On note open").addOption("play","When interacted with").setValue(this.state.loadStrategy).onChange(o=>this.state.setLoadStrategy(o)));let i="_follow_",r=SC(),s=Object.fromEntries(nx.default.getAllCodes().flatMap(a=>r.has(a)?[...r.get(a).values()]:[[a,nx.default.getNativeName(a)]]));new ne.Setting(n).setName("Default locale").setDesc("The default locale for subtitles").addDropdown(a=>a.addOption(i,"Follow obsidian locale").addOptions(s).setValue(this.state.defaultLanguage??i).onChange(o=>this.state.setDefaultLanguage(o===i?null:o)))}timestamp(){let{containerEl:n}=this;new ne.Setting(n).setHeading().setName("Timestamp"),new ne.Setting(n).setName("Timestamp template").setDesc(createFragment(i=>{i.appendText("The template used to insert timestamps."),i.createEl("br"),i.appendText("Supported placeholders: {{TIMESTAMP}}")})).addTextArea(i=>{i.setValue(this.state.timestampTemplate).onChange(r=>this.state.setTemplate("timestamp",r)),i.inputEl.rows=5,i.inputEl.cols=40}),new ne.Setting(n).setName("Timestamp offset").setDesc("Offset in seconds to add to the timestamp").addSlider(i=>i.setLimits(-10,10,.01).setValue(this.state.timestampOffset).onChange(this.state.setTimestampOffset).then(r=>{this.sub((s,a)=>{s.timestampOffset!==a.timestampOffset&&r.setValue(s.timestampOffset)})})).addText(i=>i.setValue(Lm(this.state.timestampOffset)).onChange(SR(this.state.setTimestampOffset)).then(r=>{tx.call(r,-10,10,.01),r.inputEl.type="number",r.inputEl.style.textAlign="center",this.sub((s,a)=>{s.timestampOffset!==a.timestampOffset&&r.setValue(Lm(s.timestampOffset))})})).then(i=>i.controlEl.appendText("s"))}screenshot(){let{containerEl:n}=this;new ne.Setting(n).setHeading().setName("Screenshot"),new ne.Setting(n).setName("Screenshot linktext template").setDesc(createFragment(r=>{r.appendText("The template used to create screenshot linktext."),r.createEl("br"),r.appendText("Supported placeholders: {{DURATION}}, {{TITLE}}"),r.createEl("br"),r.appendText("Remove `|50` suffix to embed image in full size")})).addTextArea(r=>{r.setValue(this.state.screenshotEmbedTemplate).onChange(s=>this.state.setTemplate("screenshotEmbed",s)),r.inputEl.rows=5,r.inputEl.cols=40}),new ne.Setting(n).setName("Screenshot template").setDesc(createFragment(r=>{r.appendText("The template used to insert screenshot."),r.createEl("br"),r.appendText("Supported placeholders: "),r.createEl("ul",{},s=>{s.createEl("li").appendText("{{TIMESTAMP}} - timestamp link"),s.createEl("li",{},a=>{a.appendText("{{SCREENSHOT}} - link to screenshot"),a.createEl("br"),a.appendText("add `!` prefix to insert as image embed")})})})).addTextArea(r=>{r.setValue(this.state.screenshotTemplate).onChange(s=>this.state.setTemplate("screenshot",s)),r.inputEl.rows=5,r.inputEl.cols=40}),new ne.Setting(n).setName("Screenshot format").setDesc(createFragment(r=>{r.appendText("The format to use when taking screenshots"),r.createEl("br"),r.appendText("Note that the webp format falls back to jpeg in iOS or iPadOS")})).addDropdown(r=>r.addOptions({"image/png":"PNG","image/jpeg":"JPEG","image/webp":"WEBP"}).setValue(this.state.screenshotFormat).onChange(s=>this.state.setScreenshotFormat(s)));let i=r=>r.screenshotFormat==="image/webp"?.8:.92;new ne.Setting(n).setName("Screenshot quality").setDesc("Quality of the screenshot").addText(r=>r.setValue(this.state.screenshotQuality?.toString()??"").setPlaceholder(i(this.state).toString()).onChange(SR(this.state.setScreenshotQuality)).then(s=>{tx.call(s,0,1,.01),s.inputEl.type="number",s.inputEl.style.textAlign="center",this.sub((a,o)=>{a.screenshotFormat!==o.screenshotFormat&&s.setPlaceholder(i(this.state).toString()),a.screenshotQuality!==o.screenshotQuality&&s.setValue(a.screenshotQuality?.toString()??"")})})).addButton(r=>r.setTooltip("Reset to default").setIcon("reset").onClick(()=>{this.state.setScreenshotQuality(null)}).setDisabled(this.state.screenshotQuality===null).then(()=>{this.sub((s,a)=>{s.screenshotQuality!==a.screenshotQuality&&r.setDisabled(s.screenshotQuality===null)})})).then(r=>{this.sub((s,a)=>{s.screenshotFormat!==a.screenshotFormat&&(r.settingEl.style.display=s.screenshotFormat==="image/png"?"none":"")})})}noteTaking(){let{containerEl:n}=this;new ne.Setting(n).setHeading().setName("Note taking"),new ne.Setting(n).setDesc("Configure where timestamps and screenshots are inserted").setName("Insert location").addDropdown(i=>i.addOption("before","Latest content on top").addOption("after","Latest content at end").setValue(this.state.insertBefore===!0?"before":"after").onChange(r=>this.state.setInsertPosition(r))),this.timestamp(),this.screenshot()}webpage(){if(!ne.Platform.isDesktopApp)return;let{containerEl:n}=this;new ne.Setting(n).setHeading().setName("Webpage"),new ne.Setting(n).setName("Login").setDesc("If website requires login to access content or request login during playback, you can open a browser page here to login.").addButton(i=>i.setCta().setButtonText("Open broswer").onClick(()=>{new Ys(this.app).open()}))}bilibili(){let{containerEl:n}=this;new ne.Setting(n).setHeading().setName("Bilibili"),new ne.Setting(n).setName("Default quality").setDesc(createFragment(i=>{i.appendText("The default quality for bilibili videos, will fallback to closest quality if not available"),i.createEl("br"),i.appendText("Only new videos will use this quality")})).addDropdown(i=>i.addOptions(yR).setValue(this.state.biliDefaultQuality.toString()).onChange(TR(r=>this.state.setBiliDefaultQuality(r))))}display(){let{containerEl:n}=this;n.empty(),this.webpage(),this.playback(),this.noteTaking(),this.linkOpen(),this.protocol(),this.bilibili()}};function TR(t){return e=>t(parseInt(e,10))}function SR(t){return e=>t(parseFloat(e))}function Lm(t){return t.toString()}function tx(t,e,n){return this.inputEl.min=t.toString(),this.inputEl.max=e.toString(),this.inputEl.step=n.toString(),this}var LR=require("url"),rx=$(Rm()),Se=require("obsidian");var CR=require("obsidian");async function ix(t){if(!CR.Platform.isDesktopApp)throw new Error("Not supported in web");let e=await Yu().showOpenDialog({title:"Pick a media file",message:"Pick a media file to open",buttonLabel:"Pick",properties:["openFile"],filters:[{extensions:kt.video,name:"Video"},{extensions:kt.audio,name:"Audio"}],defaultPath:t});return e.canceled?null:e.filePaths[0]??null}var $R=require("url"),MR=require("obsidian");var Am=class t extends MR.FuzzySuggestModal{constructor(n){super(n.app);this.plugin=n;w(this,"resolve",Fl)}static choose(n){return new Promise(i=>{let r=new t(n);r.open(),r.resolve=i})}getItems(){return this.plugin.settings.getState().getUrlMappingData().filter(n=>n.appId===this.app.appId&&n.replace.startsWith("file://")).map(n=>({action:n.protocol,path:(0,$R.fileURLToPath)(n.replace),url:n.replace}))}getItemText(n){return`mx://${n.action}: ${n.path}`}onChooseItem(n){this.resolve(n)}onClose(){super.onClose(),setTimeout(()=>{this.resolve(null)},0)}};var A4=/^av(?\d+)$/i,N4=/^BV1(?[1-9A-HJ-NP-Za-km-z]{9})$/,D4=/^[\w-]{11}$/,O4=/^(?:(?:[a-zA-Z\d]|[a-zA-Z\d][a-zA-Z\d-]*[a-zA-Z\d])\.)*(?:[A-Za-z\d]|[A-Za-z\d][A-Za-z\d-]*[A-Za-z\d])$/;function sx(t){try{return(0,LR.pathToFileURL)(t)}catch(e){return console.error(`Failed to convert path ${t} to URL: `,e),null}}function RR(t){let e=xi.isAbsolute(t)?sx(t):Un(t);return!e||["http:","https:"].includes(e.protocol)&&!O4.test(e.hostname)?null:e}var Nm=class extends Se.SuggestModal{constructor(n){super(n.app);this.plugin=n;this.inputEl.addEventListener("drop",i=>{if(!i.dataTransfer||i.dataTransfer.files.length===0)return;let r=[...i.dataTransfer.files],s=[...i.dataTransfer.files].filter(l=>Xt(xi.extname(l.name)));if(s.length===0){new Se.Notice(`Cannot open dropped file${r.length>1?"s":""}, not supported media file type`);return}let a=s[0];i.preventDefault();let o=i.target;o.value=a.path,o.dispatchEvent(new Event("input"))}),this.setPlaceholder("Enter file path, URL or media id, or drop a media file here"),this.setInstructions([{command:"\u2191\u2193",purpose:"to navigate"},{command:"\u21B5",purpose:"to open url"},{command:Se.Platform.isMacOS?"\u2318 \u21B5":"ctrl \u21B5",purpose:"to open in new tab"},{command:Se.Platform.isMacOS?"\u2318 \u2325 \u21B5":"ctrl alt \u21B5",purpose:"to open to the right"},{command:"esc",purpose:"to dismiss"}]),this.scope.register(null,"Enter",i=>(this.chooser.useSelectedItem(i),!1))}getSuggestions(n){let i=RR(n),r=[];if(!i){let o;if((o=n.match(A4))&&r.push(new URL(`https://www.bilibili.com/video/av${o.groups.id}`)),(o=n.match(N4))&&r.push(new URL(`https://www.bilibili.com/video/${n}`)),(o=n.match(D4))&&r.push(new URL(`https://www.youtube.com/watch?v=${n}`)),!o){let l=RR(`https://${n}`);l&&r.push(l)}}let s=r.map(o=>_t.create(o.href)).filter(o=>!!o),a=this.plugin.resolveUrl(i?.href);return a?[a,...s]:s}onNoSuggestion(){super.onNoSuggestion(),this.chooser.setSuggestions(["file-picker","file-protocol-picker"])}renderSuggestion(n,i){n instanceof _t?i.setText(decodeURI(n.href)):n==="file-picker"?i.setText("Open local file"):n==="file-protocol-picker"?i.setText("Pick from folders defined in custom protocol"):(0,rx.assertNever)(n)}async onChooseSuggestion(n,i){let r;if(n==="file-protocol-picker"){let a=await Am.choose(this.plugin);if(!a)return;let o=await ix(a.path);if(!o)return;if(!o.startsWith(a.path)){new Se.Notice(`For protocol ${a.action}, the file must be in ${a.path}`);return}let l=sx(o);if(!l)return;let c=this.plugin.resolveUrl(l.href.replace(a.url.replace(/\/*$/,"/"),`mx://${a.action}/`));if(!c){new Se.Notice(`Failed to resolve file protocol url: ${l.href} with ${a.url}`);return}r=c}else if(n==="file-picker"){let a=await ix();if(!a)return;let o=sx(a);if(!o)return;r=new _t(o.href)}else n instanceof _t?r=n:(0,rx.assertNever)(n);if(r.isFileUrl){if(!r.inferredType){new Se.Notice("Unsupported file type: "+r.pathname);return}if(r.hostname){new Se.Notice(`Network path is not supported in obsidian, you need to map it to a local path: ${r.filePath??r.href}`);return}}let s=r.getVaultFile(this.plugin.app.vault);if(s!==!1){if(!s){new Se.Notice("File not found in vault: "+r.href);return}if(!(s instanceof Se.TFile)){new Se.Notice("Not a file: "+r.href);return}let a=Xt(s.extension);if(!a){new Se.Notice("Unsupported file type: "+s.path);return}r={file:s,hash:r.hash,type:a}}else if(r.isFileUrl){let a=Tx();if(!a){new Se.Notice("File path is only supported in desktop app");return}try{if(!(await a.stat(r)).isFile()){new Se.Notice("Not a file: "+r.href);return}}catch(o){let l=o,c=r.filePath??r.href;l.code==="ENOENT"?new Se.Notice("File not found: "+c):l.code==="EACCES"?new Se.Notice("Permission denied: "+c):new Se.Notice(`Failed to access file (${l.code}): `+c);return}}console.debug("media selected",r),Se.Keymap.isModifier(i,"Mod")&&Se.Keymap.isModifier(i,"Alt")?this.plugin.leafOpener.openMedia(r,"split",{direction:"vertical"}):Se.Keymap.isModifier(i,"Mod")?this.plugin.leafOpener.openMedia(r,"tab"):this.plugin.leafOpener.openMedia(r,!1)}};var Du=require("obsidian");var IR="mx-open";function AR(t){window.OBS_ACT&&t.register(ut(window,{OBS_ACT:i=>function(s){if(s.action.startsWith(IR+"/")){e(s);return}return i.apply(this,arguments)}})),t.registerObsidianProtocolHandler("mx-open",async i=>{let r=Un(i.url);if(!r){new Du.Notice("Invalid URL: "+i.url);return}await n(r)});async function e(i){let r=i.action.substring(IR.length+1),s=Un(r),a=new URLSearchParams(i);if(a.delete("action"),!s){new Du.Notice("Invalid URL: "+r+"?"+a.toString());return}s.search=a.toString(),await n(s)}async function n(i){let r=_t.create(i);if(!r){new Du.Notice("Invail URL: "+i.href);return}new Du.Notice(createFragment(s=>{s.appendText(`Opening ${r.type} ${r.inferredType??"content"} from browser: `),s.createEl("br"),s.createEl("a",{text:i.href.length>50?i.href.slice(0,25)+"..."+i.href.slice(-25):i.href,href:i.href})})),await t.leafOpener.openMedia(r,"tab")}}function NR(t){function e(){new Nm(t).open()}t.addCommand({id:"open-media-switcher",name:"Open media",icon:"play",callback:e}),t.addRibbonIcon("play","Open media",e),AR(t)}var lx=(t,e)=>e.some(n=>t instanceof n),DR,OR;function V4(){return DR||(DR=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function F4(){return OR||(OR=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var cx=new WeakMap,ax=new WeakMap,Dm=new WeakMap;function z4(t){let e=new Promise((n,i)=>{let r=()=>{t.removeEventListener("success",s),t.removeEventListener("error",a)},s=()=>{n(qs(t.result)),r()},a=()=>{i(t.error),r()};t.addEventListener("success",s),t.addEventListener("error",a)});return Dm.set(e,t),e}function U4(t){if(cx.has(t))return;let e=new Promise((n,i)=>{let r=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",a),t.removeEventListener("abort",a)},s=()=>{n(),r()},a=()=>{i(t.error||new DOMException("AbortError","AbortError")),r()};t.addEventListener("complete",s),t.addEventListener("error",a),t.addEventListener("abort",a)});cx.set(t,e)}var ux={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return cx.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return qs(t[e])},set(t,e,n){return t[e]=n,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function UR(t){ux=t(ux)}function j4(t){return F4().includes(t)?function(...e){return t.apply(dx(this),e),qs(this.request)}:function(...e){return qs(t.apply(dx(this),e))}}function q4(t){return typeof t=="function"?j4(t):(t instanceof IDBTransaction&&U4(t),lx(t,V4())?new Proxy(t,ux):t)}function qs(t){if(t instanceof IDBRequest)return z4(t);if(ax.has(t))return ax.get(t);let e=q4(t);return e!==t&&(ax.set(t,e),Dm.set(e,t)),e}var dx=t=>Dm.get(t);function jR(t,e,{blocked:n,upgrade:i,blocking:r,terminated:s}={}){let a=indexedDB.open(t,e),o=qs(a);return i&&a.addEventListener("upgradeneeded",l=>{i(qs(a.result),l.oldVersion,l.newVersion,qs(a.transaction),l)}),n&&a.addEventListener("blocked",l=>n(l.oldVersion,l.newVersion,l)),o.then(l=>{s&&l.addEventListener("close",()=>s()),r&&l.addEventListener("versionchange",c=>r(c.oldVersion,c.newVersion,c))}).catch(()=>{}),o}var H4=["get","getKey","getAll","getAllKeys","count"],B4=["put","add","delete","clear"],ox=new Map;function VR(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(ox.get(e))return ox.get(e);let n=e.replace(/FromIndex$/,""),i=e!==n,r=B4.includes(n);if(!(n in(i?IDBIndex:IDBObjectStore).prototype)||!(r||H4.includes(n)))return;let s=async function(a,...o){let l=this.transaction(a,r?"readwrite":"readonly"),c=l.store;return i&&(c=c.index(o.shift())),(await Promise.all([c[n](...o),r&&l.done]))[0]};return ox.set(e,s),s}UR(t=>({...t,get:(e,n,i)=>VR(e,n)||t.get(e,n,i),has:(e,n)=>!!VR(e,n)||t.has(e,n)}));var W4=["continue","continuePrimaryKey","advance"],FR={},px=new WeakMap,qR=new WeakMap,K4={get(t,e){if(!W4.includes(e))return t[e];let n=FR[e];return n||(n=FR[e]=function(...i){px.set(this,qR.get(this)[e](...i))}),n}};async function*G4(...t){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...t)),!e)return;e=e;let n=new Proxy(e,K4);for(qR.set(n,e),Dm.set(n,dx(e));e;)yield n,e=await(px.get(n)||e.continue()),px.delete(n)}function zR(t,e){return e===Symbol.asyncIterator&&lx(t,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&lx(t,[IDBIndex,IDBObjectStore])}UR(t=>({...t,get(e,n,i){return zR(e,n)?G4:t.get(e,n,i)},has(e,n){return zR(e,n)||t.has(e,n)}}));var Vm=require("obsidian");function Y4(t,...e){return t.reduce((n,i,r)=>{let s=e[r],a=s!==void 0?JSON.stringify(s):"";return n+i+a},"")}var Ou="mx:http_proxy",hx={type:"player_v2",host:"api.bilibili.com",pathnames:["/x/player/v2","/x/player/wbi/v2"],filter:["https://api.bilibili.com/x/player/v2*","https://api.bilibili.com/x/player/wbi/v2*"],header:"player_v2",types:["xhr"]};function HR(t,e){return Y4` +- !{{SCREENSHOT}} {{TIMESTAMP}} `,insertBefore:!1,timestampOffset:0,biliDefaultQuality:80,screenshotFormat:"image/webp"};function TR(){return nt.Platform.isDesktopApp?require("os").hostname()||(nt.Platform.isMacOS?"Mac":nt.Platform.isWin?"Windows":nt.Platform.isLinux?"Linux":"Desktop"):nt.Platform.isIosApp?nt.Platform.isPhone?"iPhone":nt.Platform.isTablet?"iPad":"iOS Device":nt.Platform.isAndroidApp?nt.Platform.isPhone?"Android Phone":nt.Platform.isTablet?"Android Tablet":"Android Device":"Unknown Device"}function SR(t){return new Map(t.map(e=>[`${e.appId}%${e.protocol}`,e.replace]))}function O4(t){return Array.from(t.entries()).map(([e,n])=>{let[i,r]=e.split("%");return{appId:i,protocol:r,replace:n}}).filter(e=>e.appId&&e.protocol&&e.replace)}function CR(t){let e=(0,nt.debounce)(n=>{let i=lg(n,kR);t.saveData({...i,urlMappingData:n.getUrlMappingData()})},1e3);return Tp((n,i)=>({...Zu(ER,["urlMappingData"]),setScreenshotFormat(r){n({screenshotFormat:r}),e(i())},setScreenshotQuality(r){n({screenshotQuality:r??void 0}),e(i())},setDefaultLanguage(r){n({defaultLanguage:r?.format()}),e(i())},getDefaultLang(){let r=i().defaultLanguage,s=nt.moment.locale();return r&&!ob(r)?(new nt.Notice(`Invalid language code detected in preferences: ${r}, reverting to ${s}.`),n({defaultLanguage:void 0}),e(i()),s):r??nt.moment.locale()},getUrlMappingData(){return O4(i().urlMapping)},setBiliDefaultQuality(r){n({biliDefaultQuality:r}),e(i())},setInsertPosition(r){n({insertBefore:r==="before"}),e(i())},setLinkHandler(r,s){n(a=>{let o={...a.linkHandler};for(let l of Object.keys(o)){let c=l;o[c]=o[c].filter(u=>typeof u=="string"?u!==r:typeof r=="string"||!V4(u,r)),c===s&&(o[c]=[...o[c],r])}return{linkHandler:o}}),e(i())},setTimestampOffset(r){n({timestampOffset:r}),e(i())},setDefaultMxLinkBehavior:r=>{let s;r==="split"?s="window":r==="window"?s="tab":r==="tab"?s="split":s=null,n({defaultMxLinkClick:{click:r,alt:s}}),e(i())},setTemplate(r,s){switch(r){case"screenshot":n({screenshotTemplate:s});break;case"screenshotEmbed":n({screenshotEmbedTemplate:s});break;case"timestamp":n({timestampTemplate:s});break;default:(0,PR.assertNever)(r)}e(i())},setMxLinkAltBehavior:r=>{n(({defaultMxLinkClick:s})=>({defaultMxLinkClick:{...s,alt:r}})),e(i())},urlMapping:SR(ER.urlMappingData),setDefaultVolume:r=>{n({defaultVolume:r}),e(i())},getUrlMapping:r=>i().urlMapping.get(`${t.app.appId}%${r}`),setUrlMapping:(r,s)=>{if(r.includes("%"))throw new Error("Protocol cannot contain %");let a=`${t.app.appId}%${r}`;n(o=>({urlMapping:new Map(o.urlMapping).set(a,s),devices:o.getDeviceName()?o.devices:[...o.devices,{appId:t.app.appId,name:TR()}]})),e(i())},removeUrlMapping:r=>{if(r.includes("%"))throw new Error("Protocol cannot contain %");n(s=>{let a=`${t.app.appId}%${r}`,o=new Map(s.urlMapping);return o.delete(a),{urlMapping:o}}),e(i())},getDeviceName(r=t.app.appId){return i().devices.find(s=>s.appId===r)?.name},getDeviceNameWithDefault(r=t.app.appId){let s=i().devices.find(a=>a.appId===r);return s?s.name:r===t.app.appId?TR():"Unknown Device"},setDeviceName(r,s=t.app.appId){n({devices:[...i().devices.filter(a=>a.appId!==s),{appId:s,name:r}]}),e(i())},setLoadStrategy:r=>{n({loadStrategy:r}),e(i())},load:async()=>{let r=await t.loadData();if(!r)return;let{urlMappingData:s,...a}=lg(r,kR);n({...a,urlMapping:SR(s??[])})},save:()=>{e(i())}}))}function V4(t,e){let n=new Set([...Object.keys(t),...Object.keys(e)]);for(let i of n)if(t[i]!==e[i])return!1;return!0}var RR=require("url"),ox=$(sb()),ne=require("obsidian");var Vm=class extends ne.PluginSettingTab{constructor(n){super(n.app,n);_(this,"plugin");this.plugin=n}get state(){return this.plugin.settings.getState()}get sub(){return this.plugin.settings.subscribe.bind(this.plugin.settings)}protocol(){new ne.Setting(this.containerEl).setHeading().setName("Protocols").setDesc("Create custom protocols that resolve link per device");let n=this.containerEl.createDiv({cls:"mx-protocol-container"});new ne.Setting(n).setHeading().setName("This device").addText(o=>o.setPlaceholder(this.state.getDeviceNameWithDefault()).setValue(this.state.getDeviceName()??"").onChange(l=>this.state.setDeviceName(l))).addExtraButton(o=>o.setIcon("plus").setTooltip("Add new protocol").onClick(()=>{let l=new ne.Menu().addItem(c=>c.setIcon("link").setTitle("Link mapping").onClick(()=>{let u=r({protocol:"",replace:"https://"});i.insertAdjacentElement("afterbegin",u.settingEl)}));ne.Platform.isDesktopApp&&l.addItem(c=>c.setIcon("folder").setTitle("Folder mapping").onClick(async()=>{let u=(await ed().showOpenDialog({title:"Pick a folder",message:"Pick a folder to resolve media files from",buttonLabel:"Pick",properties:["openDirectory"]})).filePaths[0];if(!u)return;let d=r({protocol:"",replace:(0,RR.pathToFileURL)(u).href});i.insertAdjacentElement("afterbegin",d.settingEl)})),Qs(o.extraSettingsEl,l)}));let i=n.createDiv({cls:"mx-protocol-list"}),r=o=>new ne.Setting(i).then(l=>{let c=o.protocol,u=new ne.TextComponent(l.controlEl).setPlaceholder("Protocol name").setValue(c).onChange(h=>{if(!h)return;let y=c;c=h,this.state.removeUrlMapping(y);let v=p.getValue();v&&this.state.setUrlMapping(h,v)}),d="Target URL prefix";if(o.devices){d="Configured in ";let h=o.devices.filter(y=>!!y).slice(0,2);h.length>0?(d+=h.join(", "),h.length1&&(d+="s"))}let p=new ne.TextComponent(l.controlEl).setPlaceholder(d).setValue(o.replace).onChange(h=>{u.getValue()&&this.state.setUrlMapping(u.getValue(),h)});u.inputEl.addClass("mx-protocol-input"),p.inputEl.addClass("mx-replace-input"),l.addExtraButton(h=>h.setIcon("trash").setTooltip(`Remove ${u.getValue()||"empty"} protocol`).onClick(()=>{this.state.removeUrlMapping(u.getValue()),l.settingEl.remove()}))}),s=this.state.getUrlMappingData();[...new Set(s.map(o=>o.protocol))].sort().forEach(o=>{r({protocol:o,devices:s.filter(l=>l.protocol===o&&l.appId!==this.plugin.app.appId).map(l=>this.state.devices.find(c=>c.appId===l.appId)?.name??null),replace:this.state.getUrlMapping(o)??""})})}linkOpen(){let{containerEl:n}=this;new ne.Setting(n).setHeading().setName("Link open").setDesc("Configure how links to media are opened");let i={default:"Default obsidian behavior",replace:"In current pane",split:"New pane on the side",tab:"New tab",window:"New window"},r=c=>{switch(c){case"split":return ne.Platform.isMacOS?"click holding \u2318+\u2325":"click holding Ctrl+Alt";case"window":return ne.Platform.isMacOS?"click holding \u2318+\u2325+\u21E7":"click holding Ctrl+Alt+Shift";case"tab":default:return ne.Platform.isMacOS?"click holding \u2318 or middle-click":"middle-click or click holding Ctrl"}},s=c=>c===null?"default":c===!1?"replace":c,a=c=>{switch(c){case"replace":return!1;case"split":case"tab":case"window":return c;default:return null}};new ne.Setting(n).setName("Default link click").setDesc("Configure how links to media are opened").addDropdown(c=>c.addOptions(i).setValue(s(this.state.defaultMxLinkClick.click)).onChange(u=>this.state.setDefaultMxLinkBehavior(a(u))).then(()=>this.sub((u,d)=>{u.defaultMxLinkClick.click!==d.defaultMxLinkClick.click&&c.setValue(s(u.defaultMxLinkClick.click))})));let o=new ne.Setting(n).setName("Altnernative behavior").addDropdown(c=>c.addOptions(i).setValue(s(this.state.defaultMxLinkClick.alt)).onChange(u=>this.state.setMxLinkAltBehavior(a(u))).then(()=>this.sub((u,d)=>{u.defaultMxLinkClick.alt!==d.defaultMxLinkClick.alt&&c.setValue(s(u.defaultMxLinkClick.alt))})));function l(c){let u=r(c);o.setDesc("Configure link open behavior"+u?` when ${u}`:"")}l(this.state.defaultMxLinkClick.click),this.sub((c,u)=>{c.defaultMxLinkClick!==u.defaultMxLinkClick&&l(c.defaultMxLinkClick.click)})}playback(){let{containerEl:n}=this;new ne.Setting(n).setHeading().setName("Playback"),new ne.Setting(n).setName("Default volume").setDesc("The default volume for media files").addSlider(a=>a.setLimits(0,100,1).setValue(this.state.defaultVolume).onChange(this.state.setDefaultVolume).then(o=>{this.sub((l,c)=>{l.defaultVolume!==c.defaultVolume&&o.setValue(l.defaultVolume)})})).addText(a=>a.setValue(Om(this.state.defaultVolume)).onChange($R(this.state.setDefaultVolume)).then(o=>{ax.call(o,0,100,1),o.inputEl.type="number",o.inputEl.style.textAlign="center",this.sub((l,c)=>{l.defaultVolume!==c.defaultVolume&&o.setValue(Om(l.defaultVolume))})})).then(a=>a.controlEl.appendText("%")),new ne.Setting(n).setName("Load strategy").setDesc(createFragment(a=>{a.appendText("Configure when media embeds are loaded in the note"),a.createEl("br"),a.appendText("Useful if you want lazy load media embeds in a note when there are many of them")})).addDropdown(a=>a.addOption("eager","On note open").addOption("play","When interacted with").setValue(this.state.loadStrategy).onChange(o=>this.state.setLoadStrategy(o)));let i="_follow_",r=LC(),s=Object.fromEntries(ox.default.getAllCodes().flatMap(a=>r.has(a)?[...r.get(a).values()]:[[a,ox.default.getNativeName(a)]]));new ne.Setting(n).setName("Default locale").setDesc("The default locale for subtitles").addDropdown(a=>a.addOption(i,"Follow obsidian locale").addOptions(s).setValue(this.state.defaultLanguage??i).onChange(o=>this.state.setDefaultLanguage(o===i?null:o)))}timestamp(){let{containerEl:n}=this;new ne.Setting(n).setHeading().setName("Timestamp"),new ne.Setting(n).setName("Timestamp template").setDesc(createFragment(i=>{i.appendText("The template used to insert timestamps."),i.createEl("br"),i.appendText("Supported placeholders: {{TIMESTAMP}}")})).addTextArea(i=>{i.setValue(this.state.timestampTemplate).onChange(r=>this.state.setTemplate("timestamp",r)),i.inputEl.rows=5,i.inputEl.cols=40}),new ne.Setting(n).setName("Timestamp offset").setDesc("Offset in seconds to add to the timestamp").addSlider(i=>i.setLimits(-10,10,.01).setValue(this.state.timestampOffset).onChange(this.state.setTimestampOffset).then(r=>{this.sub((s,a)=>{s.timestampOffset!==a.timestampOffset&&r.setValue(s.timestampOffset)})})).addText(i=>i.setValue(Om(this.state.timestampOffset)).onChange(MR(this.state.setTimestampOffset)).then(r=>{ax.call(r,-10,10,.01),r.inputEl.type="number",r.inputEl.style.textAlign="center",this.sub((s,a)=>{s.timestampOffset!==a.timestampOffset&&r.setValue(Om(s.timestampOffset))})})).then(i=>i.controlEl.appendText("s"))}screenshot(){let{containerEl:n}=this;new ne.Setting(n).setHeading().setName("Screenshot"),new ne.Setting(n).setName("Screenshot linktext template").setDesc(createFragment(r=>{r.appendText("The template used to create screenshot linktext."),r.createEl("br"),r.appendText("Supported placeholders: {{DURATION}}, {{TITLE}}"),r.createEl("br"),r.appendText("Remove `|50` suffix to embed image in full size")})).addTextArea(r=>{r.setValue(this.state.screenshotEmbedTemplate).onChange(s=>this.state.setTemplate("screenshotEmbed",s)),r.inputEl.rows=5,r.inputEl.cols=40}),new ne.Setting(n).setName("Screenshot template").setDesc(createFragment(r=>{r.appendText("The template used to insert screenshot."),r.createEl("br"),r.appendText("Supported placeholders: "),r.createEl("ul",{},s=>{s.createEl("li").appendText("{{TIMESTAMP}} - timestamp link"),s.createEl("li",{},a=>{a.appendText("{{SCREENSHOT}} - link to screenshot"),a.createEl("br"),a.appendText("add `!` prefix to insert as image embed")})})})).addTextArea(r=>{r.setValue(this.state.screenshotTemplate).onChange(s=>this.state.setTemplate("screenshot",s)),r.inputEl.rows=5,r.inputEl.cols=40}),new ne.Setting(n).setName("Screenshot format").setDesc(createFragment(r=>{r.appendText("The format to use when taking screenshots"),r.createEl("br"),r.appendText("Note that the webp format falls back to jpeg in iOS or iPadOS")})).addDropdown(r=>r.addOptions({"image/png":"PNG","image/jpeg":"JPEG","image/webp":"WEBP"}).setValue(this.state.screenshotFormat).onChange(s=>this.state.setScreenshotFormat(s)));let i=r=>r.screenshotFormat==="image/webp"?.8:.92;new ne.Setting(n).setName("Screenshot quality").setDesc("Quality of the screenshot").addText(r=>r.setValue(this.state.screenshotQuality?.toString()??"").setPlaceholder(i(this.state).toString()).onChange(MR(this.state.setScreenshotQuality)).then(s=>{ax.call(s,0,1,.01),s.inputEl.type="number",s.inputEl.style.textAlign="center",this.sub((a,o)=>{a.screenshotFormat!==o.screenshotFormat&&s.setPlaceholder(i(this.state).toString()),a.screenshotQuality!==o.screenshotQuality&&s.setValue(a.screenshotQuality?.toString()??"")})})).addButton(r=>r.setTooltip("Reset to default").setIcon("reset").onClick(()=>{this.state.setScreenshotQuality(null)}).setDisabled(this.state.screenshotQuality===null).then(()=>{this.sub((s,a)=>{s.screenshotQuality!==a.screenshotQuality&&r.setDisabled(s.screenshotQuality===null)})})).then(r=>{this.sub((s,a)=>{s.screenshotFormat!==a.screenshotFormat&&(r.settingEl.style.display=s.screenshotFormat==="image/png"?"none":"")})})}noteTaking(){let{containerEl:n}=this;new ne.Setting(n).setHeading().setName("Note taking"),new ne.Setting(n).setDesc("Configure where timestamps and screenshots are inserted").setName("Insert location").addDropdown(i=>i.addOption("before","Latest content on top").addOption("after","Latest content at end").setValue(this.state.insertBefore===!0?"before":"after").onChange(r=>this.state.setInsertPosition(r))),this.timestamp(),this.screenshot()}webpage(){if(!ne.Platform.isDesktopApp)return;let{containerEl:n}=this;new ne.Setting(n).setHeading().setName("Webpage"),new ne.Setting(n).setName("Login").setDesc("If website requires login to access content or request login during playback, you can open a browser page here to login.").addButton(i=>i.setCta().setButtonText("Open broswer").onClick(()=>{new Xs(this.app).open()}))}bilibili(){let{containerEl:n}=this;new ne.Setting(n).setHeading().setName("Bilibili"),new ne.Setting(n).setName("Default quality").setDesc(createFragment(i=>{i.appendText("The default quality for bilibili videos, will fallback to closest quality if not available"),i.createEl("br"),i.appendText("Only new videos will use this quality")})).addDropdown(i=>i.addOptions(xR).setValue(this.state.biliDefaultQuality.toString()).onChange($R(r=>this.state.setBiliDefaultQuality(r))))}display(){let{containerEl:n}=this;n.empty(),this.webpage(),this.playback(),this.noteTaking(),this.linkOpen(),this.protocol(),this.bilibili()}};function $R(t){return e=>t(parseInt(e,10))}function MR(t){return e=>t(parseFloat(e))}function Om(t){return t.toString()}function ax(t,e,n){return this.inputEl.min=t.toString(),this.inputEl.max=e.toString(),this.inputEl.step=n.toString(),this}var DR=require("url"),cx=$(Dm()),Fe=require("obsidian");var LR=require("obsidian");async function lx(t){if(!LR.Platform.isDesktopApp)throw new Error("Not supported in web");let e=await ed().showOpenDialog({title:"Pick a media file",message:"Pick a media file to open",buttonLabel:"Pick",properties:["openFile"],filters:[{extensions:kt.video,name:"Video"},{extensions:kt.audio,name:"Audio"}],defaultPath:t});return e.canceled?null:e.filePaths[0]??null}var IR=require("url"),AR=require("obsidian");var Fm=class t extends AR.FuzzySuggestModal{constructor(n){super(n.app);this.plugin=n;_(this,"resolve",jl)}static choose(n){return new Promise(i=>{let r=new t(n);r.open(),r.resolve=i})}getItems(){return this.plugin.settings.getState().getUrlMappingData().filter(n=>n.appId===this.app.appId&&n.replace.startsWith("file://")).map(n=>({action:n.protocol,path:(0,IR.fileURLToPath)(n.replace),url:n.replace}))}getItemText(n){return`mx://${n.action}: ${n.path}`}onChooseItem(n){this.resolve(n)}onClose(){super.onClose(),setTimeout(()=>{this.resolve(null)},0)}};var F4=/^av(?\d+)$/i,z4=/^BV1(?[1-9A-HJ-NP-Za-km-z]{9})$/,U4=/^[\w-]{11}$/,j4=/^(?:(?:[a-zA-Z\d]|[a-zA-Z\d][a-zA-Z\d-]*[a-zA-Z\d])\.)*(?:[A-Za-z\d]|[A-Za-z\d][A-Za-z\d-]*[A-Za-z\d])$/;function ux(t){try{return(0,DR.pathToFileURL)(t)}catch(e){return console.error(`Failed to convert path ${t} to URL: `,e),null}}function NR(t){let e=ei.isAbsolute(t)?ux(t):Un(t);return!e||["http:","https:"].includes(e.protocol)&&!j4.test(e.hostname)?null:e}var zm=class extends Fe.SuggestModal{constructor(n){super(n.app);this.plugin=n;this.inputEl.addEventListener("drop",i=>{if(!i.dataTransfer||i.dataTransfer.files.length===0)return;let r=[...i.dataTransfer.files],s=[...i.dataTransfer.files].filter(l=>Xt(ei.extname(l.name)));if(s.length===0){new Fe.Notice(`Cannot open dropped file${r.length>1?"s":""}, not supported media file type`);return}let a=s[0];i.preventDefault();let o=i.target;o.value=a.path,o.dispatchEvent(new Event("input"))}),this.setPlaceholder("Enter file path, URL or media id, or drop a media file here"),this.setInstructions([{command:"\u2191\u2193",purpose:"to navigate"},{command:"\u21B5",purpose:"to open url"},{command:Fe.Platform.isMacOS?"\u2318 \u21B5":"ctrl \u21B5",purpose:"to open in new tab"},{command:Fe.Platform.isMacOS?"\u2318 \u2325 \u21B5":"ctrl alt \u21B5",purpose:"to open to the right"},{command:"esc",purpose:"to dismiss"}]),this.scope.register(null,"Enter",i=>(this.chooser.useSelectedItem(i),!1))}getSuggestions(n){let i=NR(n),r=[];if(!i){let o;if((o=n.match(F4))&&r.push(new URL(`https://www.bilibili.com/video/av${o.groups.id}`)),(o=n.match(z4))&&r.push(new URL(`https://www.bilibili.com/video/${n}`)),(o=n.match(U4))&&r.push(new URL(`https://www.youtube.com/watch?v=${n}`)),!o){let l=NR(`https://${n}`);l&&r.push(l)}}let s=r.map(o=>_t.create(o.href)).filter(o=>!!o),a=this.plugin.resolveUrl(i?.href);return a?[a,...s]:s}onNoSuggestion(){super.onNoSuggestion(),this.chooser.setSuggestions(["file-picker","file-protocol-picker"])}renderSuggestion(n,i){n instanceof _t?i.setText(decodeURI(n.href)):n==="file-picker"?i.setText("Open local file"):n==="file-protocol-picker"?i.setText("Pick from folders defined in custom protocol"):(0,cx.assertNever)(n)}async onChooseSuggestion(n,i){let r;if(n==="file-protocol-picker"){let a=await Fm.choose(this.plugin);if(!a)return;let o=await lx(a.path);if(!o)return;if(!o.startsWith(a.path)){new Fe.Notice(`For protocol ${a.action}, the file must be in ${a.path}`);return}let l=ux(o);if(!l)return;let c=this.plugin.resolveUrl(l.href.replace(a.url.replace(/\/*$/,"/"),`mx://${a.action}/`));if(!c){new Fe.Notice(`Failed to resolve file protocol url: ${l.href} with ${a.url}`);return}r=c}else if(n==="file-picker"){let a=await lx();if(!a)return;let o=ux(a);if(!o)return;r=new _t(o.href)}else n instanceof _t?r=n:(0,cx.assertNever)(n);if(r.isFileUrl){if(!r.inferredType){new Fe.Notice("Unsupported file type: "+r.pathname);return}if(r.hostname){new Fe.Notice(`Network path is not supported in obsidian, you need to map it to a local path: ${r.filePath??r.readableHref}`);return}}let s=r.getVaultFile(this.plugin.app.vault);if(s){let a=Xt(s.extension);if(!a){new Fe.Notice("Unsupported file type: "+s.path);return}r={file:s,hash:r.hash,type:a}}else if(r.isFileUrl){let a=Mx();if(!a){new Fe.Notice("File path is only supported in desktop app");return}try{if(!(await a.stat(r)).isFile()){new Fe.Notice("Not a file: "+r.readableHref);return}}catch(o){let l=o,c=r.filePath??r.href;l.code==="ENOENT"?new Fe.Notice("File not found: "+c):l.code==="EACCES"?new Fe.Notice("Permission denied: "+c):new Fe.Notice(`Failed to access file (${l.code}): `+c);return}}console.debug("media selected",r),Fe.Keymap.isModifier(i,"Mod")&&Fe.Keymap.isModifier(i,"Alt")?this.plugin.leafOpener.openMedia(r,"split",{direction:"vertical"}):Fe.Keymap.isModifier(i,"Mod")?this.plugin.leafOpener.openMedia(r,"tab"):this.plugin.leafOpener.openMedia(r,!1)}};var Uu=require("obsidian");var OR="mx-open";function VR(t){window.OBS_ACT&&t.register(ut(window,{OBS_ACT:i=>function(s){if(s.action.startsWith(OR+"/")){e(s);return}return i.apply(this,arguments)}})),t.registerObsidianProtocolHandler("mx-open",async i=>{let r=Un(i.url);if(!r){new Uu.Notice("Invalid URL: "+i.url);return}await n(r)});async function e(i){let r=i.action.substring(OR.length+1),s=Un(r),a=new URLSearchParams(i);if(a.delete("action"),!s){new Uu.Notice("Invalid URL: "+r+"?"+a.toString());return}s.search=a.toString(),await n(s)}async function n(i){let r=_t.create(i);if(!r){new Uu.Notice("Invail URL: "+i.href);return}new Uu.Notice(createFragment(s=>{s.appendText(`Opening ${r.type} ${r.inferredType??"content"} from browser: `),s.createEl("br"),s.createEl("a",{text:i.href.length>50?i.href.slice(0,25)+"..."+i.href.slice(-25):i.href,href:i.href})})),await t.leafOpener.openMedia(r,"tab")}}function FR(t){function e(){new zm(t).open()}t.addCommand({id:"open-media-switcher",name:"Open media",icon:"play",callback:e}),t.addRibbonIcon("play","Open media",e),VR(t)}var hx=(t,e)=>e.some(n=>t instanceof n),zR,UR;function H4(){return zR||(zR=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function q4(){return UR||(UR=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var fx=new WeakMap,dx=new WeakMap,Um=new WeakMap;function B4(t){let e=new Promise((n,i)=>{let r=()=>{t.removeEventListener("success",s),t.removeEventListener("error",a)},s=()=>{n(Bs(t.result)),r()},a=()=>{i(t.error),r()};t.addEventListener("success",s),t.addEventListener("error",a)});return Um.set(e,t),e}function W4(t){if(fx.has(t))return;let e=new Promise((n,i)=>{let r=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",a),t.removeEventListener("abort",a)},s=()=>{n(),r()},a=()=>{i(t.error||new DOMException("AbortError","AbortError")),r()};t.addEventListener("complete",s),t.addEventListener("error",a),t.addEventListener("abort",a)});fx.set(t,e)}var mx={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return fx.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Bs(t[e])},set(t,e,n){return t[e]=n,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function BR(t){mx=t(mx)}function K4(t){return q4().includes(t)?function(...e){return t.apply(gx(this),e),Bs(this.request)}:function(...e){return Bs(t.apply(gx(this),e))}}function G4(t){return typeof t=="function"?K4(t):(t instanceof IDBTransaction&&W4(t),hx(t,H4())?new Proxy(t,mx):t)}function Bs(t){if(t instanceof IDBRequest)return B4(t);if(dx.has(t))return dx.get(t);let e=G4(t);return e!==t&&(dx.set(t,e),Um.set(e,t)),e}var gx=t=>Um.get(t);function WR(t,e,{blocked:n,upgrade:i,blocking:r,terminated:s}={}){let a=indexedDB.open(t,e),o=Bs(a);return i&&a.addEventListener("upgradeneeded",l=>{i(Bs(a.result),l.oldVersion,l.newVersion,Bs(a.transaction),l)}),n&&a.addEventListener("blocked",l=>n(l.oldVersion,l.newVersion,l)),o.then(l=>{s&&l.addEventListener("close",()=>s()),r&&l.addEventListener("versionchange",c=>r(c.oldVersion,c.newVersion,c))}).catch(()=>{}),o}var Y4=["get","getKey","getAll","getAllKeys","count"],Q4=["put","add","delete","clear"],px=new Map;function jR(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(px.get(e))return px.get(e);let n=e.replace(/FromIndex$/,""),i=e!==n,r=Q4.includes(n);if(!(n in(i?IDBIndex:IDBObjectStore).prototype)||!(r||Y4.includes(n)))return;let s=async function(a,...o){let l=this.transaction(a,r?"readwrite":"readonly"),c=l.store;return i&&(c=c.index(o.shift())),(await Promise.all([c[n](...o),r&&l.done]))[0]};return px.set(e,s),s}BR(t=>({...t,get:(e,n,i)=>jR(e,n)||t.get(e,n,i),has:(e,n)=>!!jR(e,n)||t.has(e,n)}));var X4=["continue","continuePrimaryKey","advance"],HR={},vx=new WeakMap,KR=new WeakMap,Z4={get(t,e){if(!X4.includes(e))return t[e];let n=HR[e];return n||(n=HR[e]=function(...i){vx.set(this,KR.get(this)[e](...i))}),n}};async function*J4(...t){let e=this;if(e instanceof IDBCursor||(e=await e.openCursor(...t)),!e)return;e=e;let n=new Proxy(e,Z4);for(KR.set(n,e),Um.set(n,gx(e));e;)yield n,e=await(vx.get(n)||e.continue()),vx.delete(n)}function qR(t,e){return e===Symbol.asyncIterator&&hx(t,[IDBIndex,IDBObjectStore,IDBCursor])||e==="iterate"&&hx(t,[IDBIndex,IDBObjectStore])}BR(t=>({...t,get(e,n,i){return qR(e,n)?J4:t.get(e,n,i)},has(e,n){return qR(e,n)||t.has(e,n)}}));var Hm=require("obsidian");function e6(t,...e){return t.reduce((n,i,r)=>{let s=e[r],a=s!==void 0?JSON.stringify(s):"";return n+i+a},"")}var ju="mx:http_proxy",yx={type:"player_v2",host:"api.bilibili.com",pathnames:["/x/player/v2","/x/player/wbi/v2"],filter:["https://api.bilibili.com/x/player/v2*","https://api.bilibili.com/x/player/wbi/v2*"],header:"player_v2",types:["xhr"]};function GR(t,e){return e6` const { session, webContents, net } = require("electron"); -const webviewSession = session.fromPartition(${ai(e.appId)}); +const webviewSession = session.fromPartition(${oi(e.appId)}); const webContent = webContents.fromId(${t}); webviewSession.webRequest.onSendHeaders( { - urls: ${hx.filter}, type: ${hx.types} + urls: ${yx.filter}, type: ${yx.types} }, ({url, method, requestHeaders, webContentsId}) => { if (method !== "GET" || webContentsId===undefined) return; - webContent.send(${Ou}, {type:${hx.type} ,url, method, requestHeaders, webContentsId}); + webContent.send(${ju}, {type:${yx.type} ,url, method, requestHeaders, webContentsId}); }) -`.trim()}async function BR(t,e){return Q4(t.pipeThrough(new DecompressionStream("gzip")),e)}function WR(t){return new ReadableStream({start(e){e.enqueue(new Uint8Array(t)),e.close()}})}async function Q4(t,e){let n=t.getReader(),i=[];for(;;){let{done:r,value:s}=await n.read();if(r)break;i.push(s)}return new Blob(i,{type:e})}function X4(t){return`${t.aid}-${t.bvid}-${t.cid}`}var Vu,Fu,Co,Om=class extends Vm.Component{constructor(n){super();this.plugin=n;O(this,Vu,kp());O(this,Fu,new Map);O(this,Co,new Map);w(this,"app");w(this,"db");this.app=n.app,this.db=jR(`mx-cache-${this.app.appId}`,1,{upgrade(i){i.createObjectStore("bili-subtitle")}}),this.app=n.app}async getPlayerApiResp(n,i=1e4){let{aid:r,bvid:s,cid:a}=await n.methods.bili_getManifest(),o=X4({aid:r,bvid:s,cid:a}),l=k(this,Fu).get(o);if(l)return l;let c=k(this,Co).get(`${s}-${a}`)??k(this,Co).get(`${r}-${a}`);c||(c=await new Promise((p,h)=>{let y=k(this,Vu).on("player_v2",_=>{a===_.cid&&(r===_.aid||s===_.bvid)&&(p(_.url),window.clearTimeout(v))}),v=window.setTimeout(()=>{y(),h(new Error("player_v2 timeout: "+o))},i)}));let u=await n.methods.fetch(c,{gzip:!1,credentials:"include"});if(u.type!=="application/json")throw new Error(`Unexpected response type ${u.type} for player_v2 api`);let d=JSON.parse(new TextDecoder().decode(u.ab));if(d.code!==0)throw new Error(`player_v2 api error: (${d.code}) ${d.message}`);return k(this,Fu).set(o,d.data),d.data}async cacheSubtitle(n,i){(await this.db).put("bili-subtitle",i,n.toString())}async getCachedSubtitle(n){let r=await(await this.db).get("bili-subtitle",n.toString());if(!r)return null;let{ab:s,gzip:a}=r,o="application/json",c=await(a?await BR(WR(s),o):new Blob([s],{type:o})).text();return JSON.parse(c)}async hasSubtitle(n){return await(await this.db).count("bili-subtitle",n.toString())>0}async onload(){if(!Vm.Platform.isDesktopApp)throw new Error("Cannot register ipc events, not in desktop app");let n=require("path"),i=require("fs/promises"),{ipcRenderer:r}=require("electron"),s=require("@electron/remote"),a=(o,l)=>{if(l.type!=="player_v2")return;let c=new URL(l.url),u=c.searchParams.get("aid"),d=c.searchParams.get("bvid"),p=c.searchParams.get("cid");if(!u&&!d||!p)return;k(this,Vu).emit("player_v2",{url:l.url,aid:+u,bvid:d,cid:+p});let h=d?`${d}-${p}`:`${u}-${p}`;k(this,Co).set(h,l.url)};r.on(Ou,a);try{let o=s.getCurrentWebContents().id,l=HR(o,this.app),c=n.join(this.app.vault.adapter.getBasePath(),...this.app.vault.configDir.split("/"),`mx-player-hack.${Date.now()}.js`);await i.writeFile(c,l,"utf-8");try{await s.require(c),console.log("mx-player-hack loaded")}finally{await i.rm(c,{force:!0,maxRetries:5})}this.register(()=>{r.off(Ou,a)})}catch(o){throw r.off(Ou,a),o}}};Vu=new WeakMap,Fu=new WeakMap,Co=new WeakMap;var KR=require("obsidian");async function GR(){if(!KR.Platform.isDesktopApp)return;let e=require("@electron/remote").session.fromPartition(ai(this.app.appId));this.settings.subscribe((n,i)=>{n.biliDefaultQuality!==i.biliDefaultQuality&&ex(e,n.biliDefaultQuality)}),await ex(e,this.settings.getState().biliDefaultQuality)}var _L=$(Rm()),Jm=require("obsidian");var qu=class{constructor(t,e,n,i,r,s){w(this,"type",3);w(this,"name","");w(this,"prefix","");w(this,"value","");w(this,"suffix","");w(this,"modifier",3);this.type=t,this.name=e,this.prefix=n,this.value=i,this.suffix=r,this.modifier=s}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},Z4=/[$_\p{ID_Start}]/u,J4=/[$_\u200C\u200D\p{ID_Continue}]/u,mx=".*";function e6(t,e){return(e?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(t)}function JR(t,e=!1){let n=[],i=0;for(;i{if(ac("OTHER_MODIFIER")??c("ASTERISK"),d=g=>{let x=c(g);if(x!==void 0)return x;let{type:T,index:L}=n[a];throw new TypeError(`Unexpected ${T} at ${L}, expected ${g}`)},p=()=>{let g="",x;for(;x=c("CHAR")??c("ESCAPED_CHAR");)g+=x;return g},h=g=>g,y=e.encodePart||h,v="",_=g=>{v+=g},m=()=>{v.length&&(r.push(new qu(3,"","",y(v),"",3)),v="")},f=(g,x,T,L,R)=>{let I=3;switch(R){case"?":I=1;break;case"*":I=0;break;case"+":I=2;break}if(!x&&!T&&I===3){_(g);return}if(m(),!x&&!T){if(!g)return;r.push(new qu(3,"","",y(g),"",I));return}let K;T?T==="*"?K=mx:K=T:K=i;let q=2;K===i?(q=1,K=""):K===mx&&(q=0,K="");let _e;if(x?_e=x:T&&(_e=s++),l.has(_e))throw new TypeError(`Duplicate name '${_e}'.`);l.add(_e),r.push(new qu(q,_e,y(g),K,y(L),I))};for(;a-1)}return a||(i+=`(?=${s}|${r})`),new RegExp(i,YR(n))}var Qr={delimiter:"",prefixes:"",sensitive:!0,strict:!0},n6={delimiter:".",prefixes:"",sensitive:!0,strict:!0},i6={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function r6(t,e){return t.length?t[0]==="/"?!0:!e||t.length<2?!1:(t[0]=="\\"||t[0]=="{")&&t[1]=="/":!1}function nL(t,e){return t.startsWith(e)?t.substring(e.length,t.length):t}function s6(t,e){return t.endsWith(e)?t.substr(0,t.length-e.length):t}function iL(t){return!t||t.length<2?!1:t[0]==="["||(t[0]==="\\"||t[0]==="{")&&t[1]==="["}var rL=["ftp","file","http","https","ws","wss"];function sL(t){if(!t)return!0;for(let e of rL)if(t.test(e))return!0;return!1}function a6(t,e){if(t=nL(t,"#"),e||t==="")return t;let n=new URL("https://example.com");return n.hash=t,n.hash?n.hash.substring(1,n.hash.length):""}function o6(t,e){if(t=nL(t,"?"),e||t==="")return t;let n=new URL("https://example.com");return n.search=t,n.search?n.search.substring(1,n.search.length):""}function l6(t,e){return e||t===""?t:iL(t)?lL(t):oL(t)}function c6(t,e){if(e||t==="")return t;let n=new URL("https://example.com");return n.password=t,n.password}function u6(t,e){if(e||t==="")return t;let n=new URL("https://example.com");return n.username=t,n.username}function d6(t,e,n){if(n||t==="")return t;if(e&&!rL.includes(e))return new URL(`${e}:${t}`).pathname;let i=t[0]=="/";return t=new URL(i?t:"/-"+t,"https://example.com").pathname,i||(t=t.substring(2,t.length)),t}function p6(t,e,n){return aL(e)===t&&(t=""),n||t===""?t:cL(t)}function h6(t,e){return t=s6(t,":"),e||t===""?t:yx(t)}function aL(t){switch(t){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}function yx(t){if(t==="")return t;if(/^[-+.A-Za-z0-9]*$/.test(t))return t.toLowerCase();throw new TypeError(`Invalid protocol '${t}'.`)}function f6(t){if(t==="")return t;let e=new URL("https://example.com");return e.username=t,e.username}function m6(t){if(t==="")return t;let e=new URL("https://example.com");return e.password=t,e.password}function oL(t){if(t==="")return t;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(t))throw new TypeError(`Invalid hostname '${t}'`);let e=new URL("https://example.com");return e.hostname=t,e.hostname}function lL(t){if(t==="")return t;if(/[^0-9a-fA-F[\]:]/g.test(t))throw new TypeError(`Invalid IPv6 hostname '${t}'`);return t.toLowerCase()}function cL(t){if(t===""||/^[0-9]*$/.test(t)&&parseInt(t)<=65535)return t;throw new TypeError(`Invalid port '${t}'.`)}function g6(t){if(t==="")return t;let e=new URL("https://example.com");return e.pathname=t[0]!=="/"?"/-"+t:t,t[0]!=="/"?e.pathname.substring(2,e.pathname.length):e.pathname}function v6(t){return t===""?t:new URL(`data:${t}`).pathname}function y6(t){if(t==="")return t;let e=new URL("https://example.com");return e.search=t,e.search.substring(1,e.search.length)}function _6(t){if(t==="")return t;let e=new URL("https://example.com");return e.hash=t,e.hash.substring(1,e.hash.length)}var Ro,Ot,it,Pe,Bs,Lo,mn,Io,Ao,No,ze,Xe,jm,uL,Hu,gx,Ws,Uu,Do,Fm,Yt,Dn,Bu,vx,qm,dL,Oo,zm,Hm,pL,Bm,hL,Vo,Um,Xr,$o,rr,Hs,Wm,fL,Km,mL,Gm,gL,Ym,vL,On,Ti,Qm,yL,XR,w6=(XR=class{constructor(t){O(this,ze);O(this,jm);O(this,Hu);O(this,Ws);O(this,Do);O(this,Yt);O(this,Bu);O(this,qm);O(this,Oo);O(this,Hm);O(this,Bm);O(this,Vo);O(this,Xr);O(this,rr);O(this,Wm);O(this,Km);O(this,Gm);O(this,Ym);O(this,On);O(this,Qm);O(this,Ro,void 0);O(this,Ot,[]);O(this,it,{});O(this,Pe,0);O(this,Bs,1);O(this,Lo,0);O(this,mn,0);O(this,Io,0);O(this,Ao,0);O(this,No,!1);we(this,Ro,t)}get result(){return k(this,it)}parse(){for(we(this,Ot,JR(k(this,Ro),!0));k(this,Pe)0)if(M(this,Km,mL).call(this))we(this,Io,k(this,Io)-1);else continue;if(M(this,Wm,fL).call(this)){we(this,Io,k(this,Io)+1);continue}switch(k(this,mn)){case 0:M(this,Bu,vx).call(this)&&M(this,Ws,Uu).call(this,1);break;case 1:if(M(this,Bu,vx).call(this)){M(this,Qm,yL).call(this);let t=7,e=1;M(this,qm,dL).call(this)?(t=2,e=3):k(this,No)&&(t=2),M(this,ze,Xe).call(this,t,e)}break;case 2:M(this,Oo,zm).call(this)?M(this,Ws,Uu).call(this,3):(M(this,Vo,Um).call(this)||M(this,Xr,$o).call(this)||M(this,rr,Hs).call(this))&&M(this,Ws,Uu).call(this,5);break;case 3:M(this,Hm,pL).call(this)?M(this,ze,Xe).call(this,4,1):M(this,Oo,zm).call(this)&&M(this,ze,Xe).call(this,5,1);break;case 4:M(this,Oo,zm).call(this)&&M(this,ze,Xe).call(this,5,1);break;case 5:M(this,Gm,gL).call(this)?we(this,Ao,k(this,Ao)+1):M(this,Ym,vL).call(this)&&we(this,Ao,k(this,Ao)-1),M(this,Bm,hL).call(this)&&!k(this,Ao)?M(this,ze,Xe).call(this,6,1):M(this,Vo,Um).call(this)?M(this,ze,Xe).call(this,7,0):M(this,Xr,$o).call(this)?M(this,ze,Xe).call(this,8,1):M(this,rr,Hs).call(this)&&M(this,ze,Xe).call(this,9,1);break;case 6:M(this,Vo,Um).call(this)?M(this,ze,Xe).call(this,7,0):M(this,Xr,$o).call(this)?M(this,ze,Xe).call(this,8,1):M(this,rr,Hs).call(this)&&M(this,ze,Xe).call(this,9,1);break;case 7:M(this,Xr,$o).call(this)?M(this,ze,Xe).call(this,8,1):M(this,rr,Hs).call(this)&&M(this,ze,Xe).call(this,9,1);break;case 8:M(this,rr,Hs).call(this)&&M(this,ze,Xe).call(this,9,1);break;case 9:break;case 10:break}}k(this,it).hostname!==void 0&&k(this,it).port===void 0&&(k(this,it).port="")}},Ro=new WeakMap,Ot=new WeakMap,it=new WeakMap,Pe=new WeakMap,Bs=new WeakMap,Lo=new WeakMap,mn=new WeakMap,Io=new WeakMap,Ao=new WeakMap,No=new WeakMap,ze=new WeakSet,Xe=function(t,e){var n,i,r;switch(k(this,mn)){case 0:break;case 1:k(this,it).protocol=M(this,On,Ti).call(this);break;case 2:break;case 3:k(this,it).username=M(this,On,Ti).call(this);break;case 4:k(this,it).password=M(this,On,Ti).call(this);break;case 5:k(this,it).hostname=M(this,On,Ti).call(this);break;case 6:k(this,it).port=M(this,On,Ti).call(this);break;case 7:k(this,it).pathname=M(this,On,Ti).call(this);break;case 8:k(this,it).search=M(this,On,Ti).call(this);break;case 9:k(this,it).hash=M(this,On,Ti).call(this);break;case 10:break}k(this,mn)!==0&&t!==10&&([1,2,3,4].includes(k(this,mn))&&[6,7,8,9].includes(t)&&((n=k(this,it)).hostname??(n.hostname="")),[1,2,3,4,5,6].includes(k(this,mn))&&[8,9].includes(t)&&((i=k(this,it)).pathname??(i.pathname=k(this,No)?"/":"")),[1,2,3,4,5,6,7].includes(k(this,mn))&&t===9&&((r=k(this,it)).search??(r.search=""))),M(this,jm,uL).call(this,t,e)},jm=new WeakSet,uL=function(t,e){we(this,mn,t),we(this,Lo,k(this,Pe)+e),we(this,Pe,k(this,Pe)+e),we(this,Bs,0)},Hu=new WeakSet,gx=function(){we(this,Pe,k(this,Lo)),we(this,Bs,0)},Ws=new WeakSet,Uu=function(t){M(this,Hu,gx).call(this),we(this,mn,t)},Do=new WeakSet,Fm=function(t){return t<0&&(t=k(this,Ot).length-t),t=0&&(t.pathname=ir(i.pathname.substring(0,r+1),n)+t.pathname)}t.pathname=d6(t.pathname,t.protocol,n)}return typeof e.search=="string"&&(t.search=o6(e.search,n)),typeof e.hash=="string"&&(t.hash=a6(e.hash,n)),t}function ju(t){return t.replace(/([+*?:{}()\\])/g,"\\$1")}function b6(t){return t.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function x6(t,e){e.delimiter??(e.delimiter="/#?"),e.prefixes??(e.prefixes="./"),e.sensitive??(e.sensitive=!1),e.strict??(e.strict=!1),e.end??(e.end=!0),e.start??(e.start=!0),e.endsWith="";let n=".*",i=`[^${b6(e.delimiter)}]+?`,r=/[$_\u200C\u200D\p{ID_Continue}]/u,s="";for(let a=0;a0?t[a-1]:null,d=a0?d.value[0]:"";c=r.test(p)}else c=!d.hasCustomName();if(!c&&!o.prefix.length&&u&&u.type===3){let p=u.value[u.value.length-1];c=e.prefixes.includes(p)}c&&(s+="{"),s+=ju(o.prefix),l&&(s+=`:${o.name}`),o.type===2?s+=`(${o.value})`:o.type===1?l||(s+=`(${i})`):o.type===0&&(!l&&(!u||u.type===3||u.modifier!==3||c||o.prefix!=="")?s+="*":s+=`(${n})`),o.type===1&&l&&o.suffix.length&&r.test(o.suffix[0])&&(s+="\\"),s+=ju(o.suffix),c&&(s+="}"),o.modifier!==3&&(s+=Mo(o.modifier))}return s}var Si,Ks,Fo,rt,si,zo,ZR,Xm=(ZR=class{constructor(t={},e,n){O(this,Si,void 0);O(this,Ks,{});O(this,Fo,{});O(this,rt,{});O(this,si,{});O(this,zo,!1);try{let i;if(typeof e=="string"?i=e:n=e,typeof t=="string"){let o=new w6(t);if(o.parse(),t=o.result,i===void 0&&typeof t.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");t.baseURL=i}else{if(!t||typeof t!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(i)throw new TypeError("parameter 1 is not of type 'string'.")}typeof n>"u"&&(n={ignoreCase:!1});let r={ignoreCase:n.ignoreCase===!0};we(this,Si,zu({pathname:Yr,protocol:Yr,username:Yr,password:Yr,hostname:Yr,port:Yr,search:Yr,hash:Yr},t,!0)),aL(k(this,Si).protocol)===k(this,Si).port&&(k(this,Si).port="");let a;for(a of fx){if(!(a in k(this,Si)))continue;let o={},l=k(this,Si)[a];switch(k(this,Fo)[a]=[],a){case"protocol":Object.assign(o,Qr),o.encodePart=yx;break;case"username":Object.assign(o,Qr),o.encodePart=f6;break;case"password":Object.assign(o,Qr),o.encodePart=m6;break;case"hostname":Object.assign(o,n6),iL(l)?o.encodePart=lL:o.encodePart=oL;break;case"port":Object.assign(o,Qr),o.encodePart=cL;break;case"pathname":sL(k(this,Ks).protocol)?(Object.assign(o,i6,r),o.encodePart=g6):(Object.assign(o,Qr,r),o.encodePart=v6);break;case"search":Object.assign(o,Qr,r),o.encodePart=y6;break;case"hash":Object.assign(o,Qr,r),o.encodePart=_6;break}try{k(this,si)[a]=eL(l,o),k(this,Ks)[a]=tL(k(this,si)[a],k(this,Fo)[a],o),k(this,rt)[a]=x6(k(this,si)[a],o),we(this,zo,k(this,zo)||k(this,si)[a].some(c=>c.type===2))}catch{throw new TypeError(`invalid ${a} pattern '${k(this,Si)[a]}'.`)}}}catch(i){throw new TypeError(`Failed to construct 'URLPattern': ${i.message}`)}}test(t={},e){let n={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof t!="string"&&e)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof t>"u")return!1;try{typeof t=="object"?n=zu(n,t,!1):n=zu(n,QR(t,e),!1)}catch{return!1}let i;for(i of fx)if(!k(this,Ks)[i].exec(n[i]))return!1;return!0}exec(t={},e){let n={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof t!="string"&&e)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof t>"u")return;try{typeof t=="object"?n=zu(n,t,!1):n=zu(n,QR(t,e),!1)}catch{return null}let i={};e?i.inputs=[t,e]:i.inputs=[t];let r;for(r of fx){let s=k(this,Ks)[r].exec(n[r]);if(!s)return null;let a={};for(let[o,l]of k(this,Fo)[r].entries())if(typeof l=="string"||typeof l=="number"){let c=s[o+1];a[l]=c}i[r]={input:n[r]??"",groups:a}}return i}static compareComponent(t,e,n){let i=(o,l)=>{for(let c of["type","modifier","prefix","value","suffix"]){if(o[c]{let c=0;for(;cM(this,Wu,_x).call(this),500,!0);this.register(this.plugin.settings.subscribe((i,r)=>{i.linkHandler!==r.linkHandler&&n()}))}getPreferred(n,i){let r=this.getSupported(n),s=null;for(let a of r)for(let o of this.matcher.get(a)){if(!o.test(n))continue;let l=k6(o);(!s||l>s.specifity)&&(s={type:a,specifity:l})}return s?.type??(i?null:r[0])}setPreferred(n,i){this.plugin.settings.getState().setLinkHandler(n,i)}getSupported(n){if(!(n instanceof _t))return[jn[n.type]];if(n.type==="generic")switch(n.inferredType){case"video":return[pt.video,Zt];case"audio":return[pt.audio,Zt];default:return[Zt,pt.video,pt.audio]}switch(n.type){case"youtube":case"vimeo":return[Zt,Mi];case"bilibili":case"coursera":return[Zt];default:(0,_L.assertNever)(n.type)}}};Wu=new WeakSet,_x=function(){this.matcher=new Map(Object.entries(this.plugin.settings.getState().linkHandler).map(([n,i])=>[n,i.map(r=>new Xm(r))]))};function k6(t){return["protocol","username","password","hostname","port","pathname","search","hash"].reduce((e,n)=>{let i=t[n];return e+(i!=="*"?1:0)},0)}var eg=class extends tg.Plugin{constructor(){super(...arguments);w(this,"settings",ER(this));w(this,"api",{openUrl:async(n,i,r)=>{let s=this.resolveUrl(n);if(!s){new tg.Notice("Protocol not yet supported");return}await this.leafOpener.openMedia(s,i,{direction:r})}});w(this,"urlViewType",this.addChild(new Zm(this)));w(this,"mediaNote",this.addChild(new Em(this)));w(this,"biliReq",this.addChild(new Om(this)));w(this,"leafOpener",this.addChild(new _m(this)));w(this,"handleMediaNote",OM);w(this,"injectMediaEmbed",Kb);w(this,"injectMediaView",Jb);w(this,"registerMediaMenu",Ib);w(this,"fixLinkLabel",Xb);w(this,"patchEditorClick",Gb);w(this,"patchPreviewClick",Zb);w(this,"patchInlineUrl",Yb);w(this,"patchLinktextOpen",Qb);w(this,"modifySession",GR);w(this,"initLogin",Px)}resolveUrl(n){let i=fR(n);return i?cC(Un(i),this.settings.getState()):null}async onload(){this.addSettingTab(new Im(this)),await this.loadSettings(),this.initLogin(),this.loadPatches(),this.registerMediaMenu(),this.handleMediaNote(),await this.modifySession(),NR(this)}async loadSettings(){await this.settings.getState().load()}loadPatches(){this.injectMediaView(jn.audio,n=>new yo(n,this),kt.audio),this.injectMediaView(jn.video,n=>new vo(n,this),kt.video),this.injectMediaEmbed((n,i,r)=>new Tm(n,i,r,this)),this.registerView(Zt,n=>new xo(n,this)),this.registerView(Mi,n=>new _o(n,this)),this.registerView(pt.video,n=>new wo(n,this)),this.registerView(pt.audio,n=>new bo(n,this)),this.patchEditorClick({onExternalLinkClick:$b}),this.patchPreviewClick({onExternalLinkClick:$b}),this.fixLinkLabel(),this.patchInlineUrl(),this.patchLinktextOpen({onInternalLinkClick:zM})}}; +`.trim()}async function YR(t,e){return t6(t.pipeThrough(new DecompressionStream("gzip")),e)}function QR(t){return new ReadableStream({start(e){e.enqueue(new Uint8Array(t)),e.close()}})}async function t6(t,e){let n=t.getReader(),i=[];for(;;){let{done:r,value:s}=await n.read();if(r)break;i.push(s)}return new Blob(i,{type:e})}function n6(t){return`${t.aid}-${t.bvid}-${t.cid}`}var Hu,qu,Mo,jm=class extends Hm.Component{constructor(n){super();this.plugin=n;O(this,Hu,$p());O(this,qu,new Map);O(this,Mo,new Map);_(this,"app");_(this,"db");this.app=n.app,this.db=WR(`mx-cache-${this.app.appId}`,1,{upgrade(i){i.createObjectStore("bili-subtitle")}}),this.app=n.app}async getPlayerApiResp(n,i=1e4){let{aid:r,bvid:s,cid:a}=await n.methods.bili_getManifest(),o=n6({aid:r,bvid:s,cid:a}),l=k(this,qu).get(o);if(l)return l;let c=k(this,Mo).get(`${s}-${a}`)??k(this,Mo).get(`${r}-${a}`);c||(c=await new Promise((p,h)=>{let y=k(this,Hu).on("player_v2",w=>{a===w.cid&&(r===w.aid||s===w.bvid)&&(p(w.url),window.clearTimeout(v))}),v=window.setTimeout(()=>{y(),h(new Error("player_v2 timeout: "+o))},i)}));let u=await n.methods.fetch(c,{gzip:!1,credentials:"include"});if(u.type!=="application/json")throw new Error(`Unexpected response type ${u.type} for player_v2 api`);let d=JSON.parse(new TextDecoder().decode(u.ab));if(d.code!==0)throw new Error(`player_v2 api error: (${d.code}) ${d.message}`);return k(this,qu).set(o,d.data),d.data}async cacheSubtitle(n,i){(await this.db).put("bili-subtitle",i,n.toString())}async getCachedSubtitle(n){let r=await(await this.db).get("bili-subtitle",n.toString());if(!r)return null;let{ab:s,gzip:a}=r,o="application/json",c=await(a?await YR(QR(s),o):new Blob([s],{type:o})).text();return JSON.parse(c)}async hasSubtitle(n){return await(await this.db).count("bili-subtitle",n.toString())>0}async onload(){if(!Hm.Platform.isDesktopApp)throw new Error("Cannot register ipc events, not in desktop app");let n=require("path"),i=require("fs/promises"),{ipcRenderer:r}=require("electron"),s=require("@electron/remote"),a=(o,l)=>{if(l.type!=="player_v2")return;let c=new URL(l.url),u=c.searchParams.get("aid"),d=c.searchParams.get("bvid"),p=c.searchParams.get("cid");if(!u&&!d||!p)return;k(this,Hu).emit("player_v2",{url:l.url,aid:+u,bvid:d,cid:+p});let h=d?`${d}-${p}`:`${u}-${p}`;k(this,Mo).set(h,l.url)};r.on(ju,a);try{let o=s.getCurrentWebContents().id,l=GR(o,this.app),c=n.join(this.app.vault.adapter.getBasePath(),...this.app.vault.configDir.split("/"),`mx-player-hack.${Date.now()}.js`);await i.writeFile(c,l,"utf-8");try{await s.require(c),console.log("mx-player-hack loaded")}finally{await i.rm(c,{force:!0,maxRetries:5})}this.register(()=>{r.off(ju,a)})}catch(o){throw r.off(ju,a),o}}};Hu=new WeakMap,qu=new WeakMap,Mo=new WeakMap;var XR=require("obsidian");async function ZR(){if(!XR.Platform.isDesktopApp)return;let e=require("@electron/remote").session.fromPartition(oi(this.app.appId));this.settings.subscribe((n,i)=>{n.biliDefaultQuality!==i.biliDefaultQuality&&sx(e,n.biliDefaultQuality)}),await sx(e,this.settings.getState().biliDefaultQuality)}var kL=$(Dm()),rg=require("obsidian");var Gu=class{constructor(t,e,n,i,r,s){_(this,"type",3);_(this,"name","");_(this,"prefix","");_(this,"value","");_(this,"suffix","");_(this,"modifier",3);this.type=t,this.name=e,this.prefix=n,this.value=i,this.suffix=r,this.modifier=s}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},i6=/[$_\p{ID_Start}]/u,r6=/[$_\u200C\u200D\p{ID_Continue}]/u,wx=".*";function s6(t,e){return(e?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(t)}function iL(t,e=!1){let n=[],i=0;for(;i{if(ac("OTHER_MODIFIER")??c("ASTERISK"),d=g=>{let x=c(g);if(x!==void 0)return x;let{type:T,index:L}=n[a];throw new TypeError(`Unexpected ${T} at ${L}, expected ${g}`)},p=()=>{let g="",x;for(;x=c("CHAR")??c("ESCAPED_CHAR");)g+=x;return g},h=g=>g,y=e.encodePart||h,v="",w=g=>{v+=g},m=()=>{v.length&&(r.push(new Gu(3,"","",y(v),"",3)),v="")},f=(g,x,T,L,R)=>{let I=3;switch(R){case"?":I=1;break;case"*":I=0;break;case"+":I=2;break}if(!x&&!T&&I===3){w(g);return}if(m(),!x&&!T){if(!g)return;r.push(new Gu(3,"","",y(g),"",I));return}let K;T?T==="*"?K=wx:K=T:K=i;let H=2;K===i?(H=1,K=""):K===wx&&(H=0,K="");let _e;if(x?_e=x:T&&(_e=s++),l.has(_e))throw new TypeError(`Duplicate name '${_e}'.`);l.add(_e),r.push(new Gu(H,_e,y(g),K,y(L),I))};for(;a-1)}return a||(i+=`(?=${s}|${r})`),new RegExp(i,JR(n))}var Jr={delimiter:"",prefixes:"",sensitive:!0,strict:!0},o6={delimiter:".",prefixes:"",sensitive:!0,strict:!0},l6={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function c6(t,e){return t.length?t[0]==="/"?!0:!e||t.length<2?!1:(t[0]=="\\"||t[0]=="{")&&t[1]=="/":!1}function aL(t,e){return t.startsWith(e)?t.substring(e.length,t.length):t}function u6(t,e){return t.endsWith(e)?t.substr(0,t.length-e.length):t}function oL(t){return!t||t.length<2?!1:t[0]==="["||(t[0]==="\\"||t[0]==="{")&&t[1]==="["}var lL=["ftp","file","http","https","ws","wss"];function cL(t){if(!t)return!0;for(let e of lL)if(t.test(e))return!0;return!1}function d6(t,e){if(t=aL(t,"#"),e||t==="")return t;let n=new URL("https://example.com");return n.hash=t,n.hash?n.hash.substring(1,n.hash.length):""}function p6(t,e){if(t=aL(t,"?"),e||t==="")return t;let n=new URL("https://example.com");return n.search=t,n.search?n.search.substring(1,n.search.length):""}function h6(t,e){return e||t===""?t:oL(t)?pL(t):dL(t)}function f6(t,e){if(e||t==="")return t;let n=new URL("https://example.com");return n.password=t,n.password}function m6(t,e){if(e||t==="")return t;let n=new URL("https://example.com");return n.username=t,n.username}function g6(t,e,n){if(n||t==="")return t;if(e&&!lL.includes(e))return new URL(`${e}:${t}`).pathname;let i=t[0]=="/";return t=new URL(i?t:"/-"+t,"https://example.com").pathname,i||(t=t.substring(2,t.length)),t}function v6(t,e,n){return uL(e)===t&&(t=""),n||t===""?t:hL(t)}function y6(t,e){return t=u6(t,":"),e||t===""?t:kx(t)}function uL(t){switch(t){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}function kx(t){if(t==="")return t;if(/^[-+.A-Za-z0-9]*$/.test(t))return t.toLowerCase();throw new TypeError(`Invalid protocol '${t}'.`)}function _6(t){if(t==="")return t;let e=new URL("https://example.com");return e.username=t,e.username}function w6(t){if(t==="")return t;let e=new URL("https://example.com");return e.password=t,e.password}function dL(t){if(t==="")return t;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(t))throw new TypeError(`Invalid hostname '${t}'`);let e=new URL("https://example.com");return e.hostname=t,e.hostname}function pL(t){if(t==="")return t;if(/[^0-9a-fA-F[\]:]/g.test(t))throw new TypeError(`Invalid IPv6 hostname '${t}'`);return t.toLowerCase()}function hL(t){if(t===""||/^[0-9]*$/.test(t)&&parseInt(t)<=65535)return t;throw new TypeError(`Invalid port '${t}'.`)}function b6(t){if(t==="")return t;let e=new URL("https://example.com");return e.pathname=t[0]!=="/"?"/-"+t:t,t[0]!=="/"?e.pathname.substring(2,e.pathname.length):e.pathname}function x6(t){return t===""?t:new URL(`data:${t}`).pathname}function k6(t){if(t==="")return t;let e=new URL("https://example.com");return e.search=t,e.search.substring(1,e.search.length)}function E6(t){if(t==="")return t;let e=new URL("https://example.com");return e.hash=t,e.hash.substring(1,e.hash.length)}var Io,Ot,it,Se,Ks,Ao,mn,No,Do,Oo,ze,Xe,Km,fL,Yu,bx,Gs,Wu,Vo,qm,Yt,Dn,Qu,xx,Gm,mL,Fo,Bm,Ym,gL,Qm,vL,zo,Wm,es,Ro,ar,Ws,Xm,yL,Zm,_L,Jm,wL,eg,bL,On,Si,tg,xL,tL,T6=(tL=class{constructor(t){O(this,ze);O(this,Km);O(this,Yu);O(this,Gs);O(this,Vo);O(this,Yt);O(this,Qu);O(this,Gm);O(this,Fo);O(this,Ym);O(this,Qm);O(this,zo);O(this,es);O(this,ar);O(this,Xm);O(this,Zm);O(this,Jm);O(this,eg);O(this,On);O(this,tg);O(this,Io,void 0);O(this,Ot,[]);O(this,it,{});O(this,Se,0);O(this,Ks,1);O(this,Ao,0);O(this,mn,0);O(this,No,0);O(this,Do,0);O(this,Oo,!1);we(this,Io,t)}get result(){return k(this,it)}parse(){for(we(this,Ot,iL(k(this,Io),!0));k(this,Se)0)if(M(this,Zm,_L).call(this))we(this,No,k(this,No)-1);else continue;if(M(this,Xm,yL).call(this)){we(this,No,k(this,No)+1);continue}switch(k(this,mn)){case 0:M(this,Qu,xx).call(this)&&M(this,Gs,Wu).call(this,1);break;case 1:if(M(this,Qu,xx).call(this)){M(this,tg,xL).call(this);let t=7,e=1;M(this,Gm,mL).call(this)?(t=2,e=3):k(this,Oo)&&(t=2),M(this,ze,Xe).call(this,t,e)}break;case 2:M(this,Fo,Bm).call(this)?M(this,Gs,Wu).call(this,3):(M(this,zo,Wm).call(this)||M(this,es,Ro).call(this)||M(this,ar,Ws).call(this))&&M(this,Gs,Wu).call(this,5);break;case 3:M(this,Ym,gL).call(this)?M(this,ze,Xe).call(this,4,1):M(this,Fo,Bm).call(this)&&M(this,ze,Xe).call(this,5,1);break;case 4:M(this,Fo,Bm).call(this)&&M(this,ze,Xe).call(this,5,1);break;case 5:M(this,Jm,wL).call(this)?we(this,Do,k(this,Do)+1):M(this,eg,bL).call(this)&&we(this,Do,k(this,Do)-1),M(this,Qm,vL).call(this)&&!k(this,Do)?M(this,ze,Xe).call(this,6,1):M(this,zo,Wm).call(this)?M(this,ze,Xe).call(this,7,0):M(this,es,Ro).call(this)?M(this,ze,Xe).call(this,8,1):M(this,ar,Ws).call(this)&&M(this,ze,Xe).call(this,9,1);break;case 6:M(this,zo,Wm).call(this)?M(this,ze,Xe).call(this,7,0):M(this,es,Ro).call(this)?M(this,ze,Xe).call(this,8,1):M(this,ar,Ws).call(this)&&M(this,ze,Xe).call(this,9,1);break;case 7:M(this,es,Ro).call(this)?M(this,ze,Xe).call(this,8,1):M(this,ar,Ws).call(this)&&M(this,ze,Xe).call(this,9,1);break;case 8:M(this,ar,Ws).call(this)&&M(this,ze,Xe).call(this,9,1);break;case 9:break;case 10:break}}k(this,it).hostname!==void 0&&k(this,it).port===void 0&&(k(this,it).port="")}},Io=new WeakMap,Ot=new WeakMap,it=new WeakMap,Se=new WeakMap,Ks=new WeakMap,Ao=new WeakMap,mn=new WeakMap,No=new WeakMap,Do=new WeakMap,Oo=new WeakMap,ze=new WeakSet,Xe=function(t,e){var n,i,r;switch(k(this,mn)){case 0:break;case 1:k(this,it).protocol=M(this,On,Si).call(this);break;case 2:break;case 3:k(this,it).username=M(this,On,Si).call(this);break;case 4:k(this,it).password=M(this,On,Si).call(this);break;case 5:k(this,it).hostname=M(this,On,Si).call(this);break;case 6:k(this,it).port=M(this,On,Si).call(this);break;case 7:k(this,it).pathname=M(this,On,Si).call(this);break;case 8:k(this,it).search=M(this,On,Si).call(this);break;case 9:k(this,it).hash=M(this,On,Si).call(this);break;case 10:break}k(this,mn)!==0&&t!==10&&([1,2,3,4].includes(k(this,mn))&&[6,7,8,9].includes(t)&&((n=k(this,it)).hostname??(n.hostname="")),[1,2,3,4,5,6].includes(k(this,mn))&&[8,9].includes(t)&&((i=k(this,it)).pathname??(i.pathname=k(this,Oo)?"/":"")),[1,2,3,4,5,6,7].includes(k(this,mn))&&t===9&&((r=k(this,it)).search??(r.search=""))),M(this,Km,fL).call(this,t,e)},Km=new WeakSet,fL=function(t,e){we(this,mn,t),we(this,Ao,k(this,Se)+e),we(this,Se,k(this,Se)+e),we(this,Ks,0)},Yu=new WeakSet,bx=function(){we(this,Se,k(this,Ao)),we(this,Ks,0)},Gs=new WeakSet,Wu=function(t){M(this,Yu,bx).call(this),we(this,mn,t)},Vo=new WeakSet,qm=function(t){return t<0&&(t=k(this,Ot).length-t),t=0&&(t.pathname=sr(i.pathname.substring(0,r+1),n)+t.pathname)}t.pathname=g6(t.pathname,t.protocol,n)}return typeof e.search=="string"&&(t.search=p6(e.search,n)),typeof e.hash=="string"&&(t.hash=d6(e.hash,n)),t}function Ku(t){return t.replace(/([+*?:{}()\\])/g,"\\$1")}function S6(t){return t.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function P6(t,e){e.delimiter??(e.delimiter="/#?"),e.prefixes??(e.prefixes="./"),e.sensitive??(e.sensitive=!1),e.strict??(e.strict=!1),e.end??(e.end=!0),e.start??(e.start=!0),e.endsWith="";let n=".*",i=`[^${S6(e.delimiter)}]+?`,r=/[$_\u200C\u200D\p{ID_Continue}]/u,s="";for(let a=0;a0?t[a-1]:null,d=a0?d.value[0]:"";c=r.test(p)}else c=!d.hasCustomName();if(!c&&!o.prefix.length&&u&&u.type===3){let p=u.value[u.value.length-1];c=e.prefixes.includes(p)}c&&(s+="{"),s+=Ku(o.prefix),l&&(s+=`:${o.name}`),o.type===2?s+=`(${o.value})`:o.type===1?l||(s+=`(${i})`):o.type===0&&(!l&&(!u||u.type===3||u.modifier!==3||c||o.prefix!=="")?s+="*":s+=`(${n})`),o.type===1&&l&&o.suffix.length&&r.test(o.suffix[0])&&(s+="\\"),s+=Ku(o.suffix),c&&(s+="}"),o.modifier!==3&&(s+=Lo(o.modifier))}return s}var Pi,Ys,Uo,rt,ai,jo,nL,ng=(nL=class{constructor(t={},e,n){O(this,Pi,void 0);O(this,Ys,{});O(this,Uo,{});O(this,rt,{});O(this,ai,{});O(this,jo,!1);try{let i;if(typeof e=="string"?i=e:n=e,typeof t=="string"){let o=new T6(t);if(o.parse(),t=o.result,i===void 0&&typeof t.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");t.baseURL=i}else{if(!t||typeof t!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(i)throw new TypeError("parameter 1 is not of type 'string'.")}typeof n>"u"&&(n={ignoreCase:!1});let r={ignoreCase:n.ignoreCase===!0};we(this,Pi,Bu({pathname:Zr,protocol:Zr,username:Zr,password:Zr,hostname:Zr,port:Zr,search:Zr,hash:Zr},t,!0)),uL(k(this,Pi).protocol)===k(this,Pi).port&&(k(this,Pi).port="");let a;for(a of _x){if(!(a in k(this,Pi)))continue;let o={},l=k(this,Pi)[a];switch(k(this,Uo)[a]=[],a){case"protocol":Object.assign(o,Jr),o.encodePart=kx;break;case"username":Object.assign(o,Jr),o.encodePart=_6;break;case"password":Object.assign(o,Jr),o.encodePart=w6;break;case"hostname":Object.assign(o,o6),oL(l)?o.encodePart=pL:o.encodePart=dL;break;case"port":Object.assign(o,Jr),o.encodePart=hL;break;case"pathname":cL(k(this,Ys).protocol)?(Object.assign(o,l6,r),o.encodePart=b6):(Object.assign(o,Jr,r),o.encodePart=x6);break;case"search":Object.assign(o,Jr,r),o.encodePart=k6;break;case"hash":Object.assign(o,Jr,r),o.encodePart=E6;break}try{k(this,ai)[a]=rL(l,o),k(this,Ys)[a]=sL(k(this,ai)[a],k(this,Uo)[a],o),k(this,rt)[a]=P6(k(this,ai)[a],o),we(this,jo,k(this,jo)||k(this,ai)[a].some(c=>c.type===2))}catch{throw new TypeError(`invalid ${a} pattern '${k(this,Pi)[a]}'.`)}}}catch(i){throw new TypeError(`Failed to construct 'URLPattern': ${i.message}`)}}test(t={},e){let n={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof t!="string"&&e)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof t>"u")return!1;try{typeof t=="object"?n=Bu(n,t,!1):n=Bu(n,eL(t,e),!1)}catch{return!1}let i;for(i of _x)if(!k(this,Ys)[i].exec(n[i]))return!1;return!0}exec(t={},e){let n={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof t!="string"&&e)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof t>"u")return;try{typeof t=="object"?n=Bu(n,t,!1):n=Bu(n,eL(t,e),!1)}catch{return null}let i={};e?i.inputs=[t,e]:i.inputs=[t];let r;for(r of _x){let s=k(this,Ys)[r].exec(n[r]);if(!s)return null;let a={};for(let[o,l]of k(this,Uo)[r].entries())if(typeof l=="string"||typeof l=="number"){let c=s[o+1];a[l]=c}i[r]={input:n[r]??"",groups:a}}return i}static compareComponent(t,e,n){let i=(o,l)=>{for(let c of["type","modifier","prefix","value","suffix"]){if(o[c]{let c=0;for(;cM(this,Xu,Ex).call(this),500,!0);this.register(this.plugin.settings.subscribe((i,r)=>{i.linkHandler!==r.linkHandler&&n()}))}getPreferred(n,i){let r=this.getSupported(n),s=null;for(let a of r)for(let o of this.matcher.get(a)){if(!o.test(n))continue;let l=C6(o);(!s||l>s.specifity)&&(s={type:a,specifity:l})}return s?.type??(i?null:r[0])}setPreferred(n,i){this.plugin.settings.getState().setLinkHandler(n,i)}getSupported(n){if(!(n instanceof _t))return[jn[n.type]];if(n.type==="generic")switch(n.inferredType){case"video":return[pt.video,Zt];case"audio":return[pt.audio,Zt];default:return[Zt,pt.video,pt.audio]}switch(n.type){case"youtube":case"vimeo":return[Zt,Ri];case"bilibili":case"coursera":return[Zt];default:(0,kL.assertNever)(n.type)}}};Xu=new WeakSet,Ex=function(){this.matcher=new Map(Object.entries(this.plugin.settings.getState().linkHandler).map(([n,i])=>[n,i.map(r=>new ng(r))]))};function C6(t){return["protocol","username","password","hostname","port","pathname","search","hash"].reduce((e,n)=>{let i=t[n];return e+(i!=="*"?1:0)},0)}var sg=class extends ag.Plugin{constructor(){super(...arguments);_(this,"settings",CR(this));_(this,"api",{openUrl:async(n,i,r)=>{let s=this.resolveUrl(n);if(!s){new ag.Notice("Protocol not yet supported");return}await this.leafOpener.openMedia(s,i,{direction:r})}});_(this,"urlViewType",this.addChild(new ig(this)));_(this,"mediaNote",this.addChild(new $m(this)));_(this,"biliReq",this.addChild(new jm(this)));_(this,"leafOpener",this.addChild(new xm(this)));_(this,"handleMediaNote",UM);_(this,"injectMediaEmbed",Zb);_(this,"injectMediaView",rx);_(this,"registerMediaMenu",Vb);_(this,"fixLinkLabel",nx);_(this,"patchEditorClick",Jb);_(this,"patchPreviewClick",ix);_(this,"patchInlineUrl",ex);_(this,"patchLinktextOpen",tx);_(this,"modifySession",ZR);_(this,"initLogin",Lx)}resolveUrl(n){let i=yR(n);return i?mC(Un(i),this.settings.getState()):null}async onload(){this.addSettingTab(new Vm(this)),await this.loadSettings(),this.initLogin(),this.loadPatches(),this.registerMediaMenu(),this.handleMediaNote(),await this.modifySession(),FR(this)}async loadSettings(){await this.settings.getState().load()}loadPatches(){this.injectMediaView(jn.audio,n=>new wo(n,this),kt.audio),this.injectMediaView(jn.video,n=>new _o(n,this),kt.video),this.injectMediaEmbed((n,i,r)=>new Mm(n,i,r,this)),this.registerView(Zt,n=>new Eo(n,this)),this.registerView(Ri,n=>new bo(n,this)),this.registerView(pt.video,n=>new xo(n,this)),this.registerView(pt.audio,n=>new ko(n,this)),this.patchEditorClick({onExternalLinkClick:Ab}),this.patchPreviewClick({onExternalLinkClick:Ab}),this.fixLinkLabel(),this.patchInlineUrl(),this.patchLinktextOpen({onInternalLinkClick:qM})}}; /*! Bundled license information: react/cjs/react.production.min.js: diff --git a/.obsidian/plugins/media-extended/manifest.json b/.obsidian/plugins/media-extended/manifest.json index 398bf5de..2108c117 100644 --- a/.obsidian/plugins/media-extended/manifest.json +++ b/.obsidian/plugins/media-extended/manifest.json @@ -1,8 +1,8 @@ { "id": "media-extended", "name": "Media Extended", - "version": "3.0.2", - "minAppVersion": "1.5.3", + "version": "3.0.4", + "minAppVersion": "1.5.7", "description": "Media(Video/Audio) Playback Enhancement for Obsidian.md", "author": "AidenLx", "authorUrl": "https://github.com/AidenLx/", diff --git a/.obsidian/plugins/obsidian-activity-history/data.json b/.obsidian/plugins/obsidian-activity-history/data.json index 9ebf03a4..1ff1e6e3 100644 --- a/.obsidian/plugins/obsidian-activity-history/data.json +++ b/.obsidian/plugins/obsidian-activity-history/data.json @@ -12,8 +12,8 @@ "checkpointList": [ { "path": "/", - "date": "2024-03-03", - "size": 13839244 + "date": "2024-03-10", + "size": 13983098 } ], "activityHistory": [ @@ -3146,7 +3146,35 @@ }, { "date": "2024-03-03", - "value": 1362 + "value": 1397 + }, + { + "date": "2024-03-04", + "value": 142237 + }, + { + "date": "2024-03-05", + "value": 2331 + }, + { + "date": "2024-03-06", + "value": 1391 + }, + { + "date": "2024-03-07", + "value": 1287 + }, + { + "date": "2024-03-08", + "value": 2797 + }, + { + "date": "2024-03-09", + "value": 1338 + }, + { + "date": "2024-03-10", + "value": 1496 } ] } diff --git a/.obsidian/plugins/obsidian-book-search-plugin/main.js b/.obsidian/plugins/obsidian-book-search-plugin/main.js index a809cbfc..e62c4081 100644 --- a/.obsidian/plugins/obsidian-book-search-plugin/main.js +++ b/.obsidian/plugins/obsidian-book-search-plugin/main.js @@ -3,7 +3,7 @@ THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ -var Mr=Object.create;var ke=Object.defineProperty;var Rr=Object.getOwnPropertyDescriptor;var Lr=Object.getOwnPropertyNames,Ft=Object.getOwnPropertySymbols,Fr=Object.getPrototypeOf,_t=Object.prototype.hasOwnProperty,_r=Object.prototype.propertyIsEnumerable;var $t=(r,e,t)=>e in r?ke(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ye=(r,e)=>{for(var t in e||(e={}))_t.call(e,t)&&$t(r,t,e[t]);if(Ft)for(var t of Ft(e))_r.call(e,t)&&$t(r,t,e[t]);return r};var Vt=r=>ke(r,"__esModule",{value:!0});var $r=(r,e)=>{Vt(r);for(var t in e)ke(r,t,{get:e[t],enumerable:!0})},Vr=(r,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Lr(e))!_t.call(r,o)&&o!=="default"&&ke(r,o,{get:()=>e[o],enumerable:!(t=Rr(e,o))||t.enumerable});return r},q=r=>Vr(Vt(ke(r!=null?Mr(Fr(r)):{},"default",r&&r.__esModule&&"default"in r?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r);var h=(r,e,t)=>new Promise((o,i)=>{var n=l=>{try{a(t.next(l))}catch(u){i(u)}},s=l=>{try{a(t.throw(l))}catch(u){i(u)}},a=l=>l.done?o(l.value):Promise.resolve(l.value).then(n,s);a((t=t.apply(r,e)).next())});$r(exports,{default:()=>Tt});var ne=q(require("obsidian"));var re=q(require("obsidian"));var I;(function(t){t.google="google",t.naver="naver"})(I||(I={}));var Ht=q(require("obsidian"));var rt=class{constructor(e,t){this.localePreference=e;this.apiKey=t}getByQuery(e){return h(this,null,function*(){try{let t={q:e,maxResults:40,printType:"books"},o=this.localePreference;o==="default"?t.langRestrict=window.moment.locale():t.langRestrict=o,this.apiKey!==""&&(t.key=this.apiKey);let i=yield He("https://www.googleapis.com/books/v1/volumes",t);return(i==null?void 0:i.totalItems)?i.items.map(({volumeInfo:n})=>this.createBookItem(n)):[]}catch(t){throw console.warn(t),t}})}getISBN(e){return e==null?void 0:e.reduce((t,o)=>(o.type=="ISBN_10"&&(t.isbn10=o.identifier.trim()),o.type=="ISBN_13"&&(t.isbn13=o.identifier.trim()),t),{})}createBookItem(e){var o,i,n,s;return ye({title:e.title,subtitle:e.subtitle,author:this.formatList(e.authors),authors:e.authors,category:this.formatList(e.categories),publisher:e.publisher,totalPage:e.pageCount,coverUrl:(i=(o=e.imageLinks)==null?void 0:o.thumbnail)!=null?i:"",coverSmallUrl:(s=(n=e.imageLinks)==null?void 0:n.smallThumbnail)!=null?s:"",publishDate:e.publishedDate||"",description:e.description,link:e.canonicalVolumeLink||e.infoLink,previewLink:e.previewLink},this.getISBN(e.industryIdentifiers))}convertGoogleBookImageURLSize(e,t){return e.replace(/(&zoom)=\d/,`$1=${t}`)}formatList(e){var t,o;return(e==null?void 0:e.length)>1?e.map(i=>`${i.trim()}`).join(", "):(o=(t=e==null?void 0:e[0])==null?void 0:t.replace("N/A",""))!=null?o:""}};var ot=class{constructor(e,t){this.clientId=e;this.clientSecret=t}getByQuery(e){return h(this,null,function*(){try{let t={query:e,display:50,sort:"sim"},o={"X-Naver-Client-Id":this.clientId,"X-Naver-Client-Secret":this.clientSecret},i=yield He("https://openapi.naver.com/v1/search/book.json",t,o);return(i==null?void 0:i.total)?i.items.map(this.createBookItem):[]}catch(t){throw console.warn(t),t}})}createBookItem(e){var t,o;return ye({title:e.title,author:e.author,publisher:e.publisher,coverUrl:e.image,publishDate:((t=e.pubdate)==null?void 0:t.slice(0,4))||"",link:e.link,description:e.description,isbn:e.isbn},((o=e.isbn)==null?void 0:o.length)>=13?{isbn13:e.isbn}:{isbn10:e.isbn})}};function Wt(r){if(r.serviceProvider===I.google)return new rt(r.localePreference,r.apiKey);if(r.serviceProvider===I.naver){if(!r.naverClientId||!r.naverClientSecret)throw new Error('\uB124\uC774\uBC84 \uAC1C\uBC1C\uC790\uC13C\uD130\uC5D0\uC11C "Client ID"\uC640 "Client Secret"\uB97C \uBC1C\uAE09\uBC1B\uC544 \uC124\uC815\uD574\uC8FC\uC138\uC694.');return new ot(r.naverClientId,r.naverClientSecret)}}function He(o){return h(this,arguments,function*(r,e={},t){let i=new URL(r);return Object.entries(e).forEach(([s,a])=>{i.searchParams.append(s,a==null?void 0:a.toString())}),(yield(0,Ht.requestUrl)({url:i.href,method:"GET",headers:ye({Accept:"*/*","Content-Type":"application/json; charset=utf-8"},t)})).json})}var it=class extends re.Modal{constructor(e,t,o){super(e.app);this.query=t;this.callback=o;this.isBusy=!1;this.serviceProvider=Wt(e.settings)}setBusy(e){var t,o;this.isBusy=e,(t=this.okBtnRef)==null||t.setDisabled(e),(o=this.okBtnRef)==null||o.setButtonText(e?"Requesting...":"Search")}searchBook(){return h(this,null,function*(){if(!this.query)throw new Error("No query entered.");if(!this.isBusy){try{this.setBusy(!0);let e=yield this.serviceProvider.getByQuery(this.query);if(this.setBusy(!1),!(e==null?void 0:e.length)){new re.Notice(`No results found for "${this.query}"`);return}this.callback(null,e)}catch(e){this.callback(e)}this.close()}})}submitEnterCallback(e){e.key==="Enter"&&!e.isComposing&&this.searchBook()}onOpen(){let{contentEl:e}=this;e.createEl("h2",{text:"Search Book"}),e.createDiv({cls:"book-search-plugin__search-modal--input"},t=>{new re.TextComponent(t).setValue(this.query).setPlaceholder("Search by keyword or ISBN").onChange(o=>this.query=o).inputEl.addEventListener("keydown",this.submitEnterCallback.bind(this))}),new re.Setting(e).addButton(t=>this.okBtnRef=t.setButtonText("Search").setCta().onClick(()=>{this.searchBook()}))}onClose(){this.contentEl.empty()}};var Gt=q(require("obsidian")),nt=class extends Gt.SuggestModal{constructor(e,t,o,i){super(e);this.suggestion=o;this.onChoose=i;this.showCoverImageInSearch=t}getSuggestions(e){return this.suggestion.filter(t=>{var i,n,s;let o=e==null?void 0:e.toLowerCase();return((i=t.title)==null?void 0:i.toLowerCase().includes(o))||((n=t.author)==null?void 0:n.toLowerCase().includes(o))||((s=t.publisher)==null?void 0:s.toLowerCase().includes(o))})}renderSuggestion(e,t){t.addClass("book-suggestion-item");let o=e.coverLargeUrl||e.coverMediumUrl||e.coverSmallUrl||e.coverUrl;this.showCoverImageInSearch&&o&&t.createEl("img",{cls:"book-cover-image",attr:{src:o,alt:`Cover Image for ${e.title}`}});let i=t.createEl("div",{cls:"book-text-info"});i.createEl("div",{text:e.title});let n=e.publisher?`, ${e.publisher}`:"",s=e.publishDate?`(${e.publishDate})`:"",a=e.totalPage?`, p${e.totalPage}`:"",l=`${e.author}${n}${s}${a}`;i.createEl("small",{text:l})}onChooseSuggestion(e){this.onChoose(null,e)}};var Ut=q(require("obsidian")),st=class{constructor(e){this.app=e}jumpToNextCursorLocation(){return h(this,null,function*(){let e=this.app.workspace.getActiveViewOfType(Ut.MarkdownView);if(!e)return;let o=(yield this.app.vault.cachedRead(e.file)).length+1,i=e.editor;i.focus(),i.setCursor(o,0)})}};var _=q(require("obsidian"));var Xt=/^-?[0-9]*$/,at=/{{DATE(\+-?[0-9]+)?}}/,lt=/{{DATE:([^}\n\r+]*)(\+-?[0-9]+)?}}/;function Hr(r){return r.replace(/[\\,#%&{}/*<>$":@.?|]/g,"").replace(/\s+/g," ")}function pt(r,e,t="md"){let o;return e?o=Ie(r,We(e)):o=r.author?`${r.title} - ${r.author}`:r.title,Hr(o)+`.${t}`}function Wr(r){return Object.entries(r).reduce((e,[t,o])=>(e[Gr(t)]=o,e),{})}function qt(r,e,t=be.snakeCase){var n,s;let o=t===be.camelCase?r:Wr(r),i=typeof e=="string"?Ur(e):e;for(let a in i){let l=(s=(n=i[a])==null?void 0:n.toString().trim())!=null?s:"";o[a]&&o[a]!==l?o[a]=`${o[a]}, ${l}`:o[a]=l}return o}function Ie(r,e){return(e==null?void 0:e.trim())?Object.entries(r).reduce((o,[i,n=""])=>o.replace(new RegExp(`{{${i}}}`,"ig"),n),e).replace(/{{\w+}}/gi,"").trim():""}function Gr(r){return r.replace(/[A-Z]/g,e=>`_${e==null?void 0:e.toLowerCase()}`)}function Ur(r){return r?r.split(` +var Mr=Object.create;var ke=Object.defineProperty;var Rr=Object.getOwnPropertyDescriptor;var Lr=Object.getOwnPropertyNames,Ft=Object.getOwnPropertySymbols,Fr=Object.getPrototypeOf,_t=Object.prototype.hasOwnProperty,_r=Object.prototype.propertyIsEnumerable;var $t=(r,e,t)=>e in r?ke(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ye=(r,e)=>{for(var t in e||(e={}))_t.call(e,t)&&$t(r,t,e[t]);if(Ft)for(var t of Ft(e))_r.call(e,t)&&$t(r,t,e[t]);return r};var Vt=r=>ke(r,"__esModule",{value:!0});var $r=(r,e)=>{Vt(r);for(var t in e)ke(r,t,{get:e[t],enumerable:!0})},Vr=(r,e,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Lr(e))!_t.call(r,o)&&o!=="default"&&ke(r,o,{get:()=>e[o],enumerable:!(t=Rr(e,o))||t.enumerable});return r},q=r=>Vr(Vt(ke(r!=null?Mr(Fr(r)):{},"default",r&&r.__esModule&&"default"in r?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r);var h=(r,e,t)=>new Promise((o,i)=>{var n=l=>{try{a(t.next(l))}catch(u){i(u)}},s=l=>{try{a(t.throw(l))}catch(u){i(u)}},a=l=>l.done?o(l.value):Promise.resolve(l.value).then(n,s);a((t=t.apply(r,e)).next())});$r(exports,{default:()=>Tt});var ne=q(require("obsidian"));var re=q(require("obsidian"));var I;(function(t){t.google="google",t.naver="naver"})(I||(I={}));var Ht=q(require("obsidian"));var rt=class{constructor(e,t){this.localePreference=e;this.apiKey=t}getByQuery(e){return h(this,null,function*(){try{let t={q:e,maxResults:40,printType:"books"},o=this.localePreference;o==="default"?t.langRestrict=window.moment.locale():t.langRestrict=o,this.apiKey!==""&&(t.key=this.apiKey);let i=yield He("https://www.googleapis.com/books/v1/volumes",t);return(i==null?void 0:i.totalItems)?i.items.map(({volumeInfo:n})=>this.createBookItem(n)):[]}catch(t){throw console.warn(t),t}})}getISBN(e){return e==null?void 0:e.reduce((t,o)=>(o.type=="ISBN_10"&&(t.isbn10=o.identifier.trim()),o.type=="ISBN_13"&&(t.isbn13=o.identifier.trim()),t),{})}createBookItem(e){var o,i,n,s;return ye({title:e.title,subtitle:e.subtitle,author:this.formatList(e.authors),authors:e.authors,category:this.formatList(e.categories),categories:e.categories,publisher:e.publisher,totalPage:e.pageCount,coverUrl:(i=(o=e.imageLinks)==null?void 0:o.thumbnail)!=null?i:"",coverSmallUrl:(s=(n=e.imageLinks)==null?void 0:n.smallThumbnail)!=null?s:"",publishDate:e.publishedDate||"",description:e.description,link:e.canonicalVolumeLink||e.infoLink,previewLink:e.previewLink},this.getISBN(e.industryIdentifiers))}convertGoogleBookImageURLSize(e,t){return e.replace(/(&zoom)=\d/,`$1=${t}`)}formatList(e){var t,o;return(e==null?void 0:e.length)>1?e.map(i=>`${i.trim()}`).join(", "):(o=(t=e==null?void 0:e[0])==null?void 0:t.replace("N/A",""))!=null?o:""}};var ot=class{constructor(e,t){this.clientId=e;this.clientSecret=t}getByQuery(e){return h(this,null,function*(){try{let t={query:e,display:50,sort:"sim"},o={"X-Naver-Client-Id":this.clientId,"X-Naver-Client-Secret":this.clientSecret},i=yield He("https://openapi.naver.com/v1/search/book.json",t,o);return(i==null?void 0:i.total)?i.items.map(this.createBookItem):[]}catch(t){throw console.warn(t),t}})}createBookItem(e){var t,o;return ye({title:e.title,author:e.author,publisher:e.publisher,coverUrl:e.image,publishDate:((t=e.pubdate)==null?void 0:t.slice(0,4))||"",link:e.link,description:e.description,isbn:e.isbn},((o=e.isbn)==null?void 0:o.length)>=13?{isbn13:e.isbn}:{isbn10:e.isbn})}};function Wt(r){if(r.serviceProvider===I.google)return new rt(r.localePreference,r.apiKey);if(r.serviceProvider===I.naver){if(!r.naverClientId||!r.naverClientSecret)throw new Error('\uB124\uC774\uBC84 \uAC1C\uBC1C\uC790\uC13C\uD130\uC5D0\uC11C "Client ID"\uC640 "Client Secret"\uB97C \uBC1C\uAE09\uBC1B\uC544 \uC124\uC815\uD574\uC8FC\uC138\uC694.');return new ot(r.naverClientId,r.naverClientSecret)}}function He(o){return h(this,arguments,function*(r,e={},t){let i=new URL(r);return Object.entries(e).forEach(([s,a])=>{i.searchParams.append(s,a==null?void 0:a.toString())}),(yield(0,Ht.requestUrl)({url:i.href,method:"GET",headers:ye({Accept:"*/*","Content-Type":"application/json; charset=utf-8"},t)})).json})}var it=class extends re.Modal{constructor(e,t,o){super(e.app);this.query=t;this.callback=o;this.isBusy=!1;this.serviceProvider=Wt(e.settings)}setBusy(e){var t,o;this.isBusy=e,(t=this.okBtnRef)==null||t.setDisabled(e),(o=this.okBtnRef)==null||o.setButtonText(e?"Requesting...":"Search")}searchBook(){return h(this,null,function*(){if(!this.query)throw new Error("No query entered.");if(!this.isBusy){try{this.setBusy(!0);let e=yield this.serviceProvider.getByQuery(this.query);if(this.setBusy(!1),!(e==null?void 0:e.length)){new re.Notice(`No results found for "${this.query}"`);return}this.callback(null,e)}catch(e){this.callback(e)}this.close()}})}submitEnterCallback(e){e.key==="Enter"&&!e.isComposing&&this.searchBook()}onOpen(){let{contentEl:e}=this;e.createEl("h2",{text:"Search Book"}),e.createDiv({cls:"book-search-plugin__search-modal--input"},t=>{new re.TextComponent(t).setValue(this.query).setPlaceholder("Search by keyword or ISBN").onChange(o=>this.query=o).inputEl.addEventListener("keydown",this.submitEnterCallback.bind(this))}),new re.Setting(e).addButton(t=>this.okBtnRef=t.setButtonText("Search").setCta().onClick(()=>{this.searchBook()}))}onClose(){this.contentEl.empty()}};var Gt=q(require("obsidian")),nt=class extends Gt.SuggestModal{constructor(e,t,o,i){super(e);this.suggestion=o;this.onChoose=i;this.showCoverImageInSearch=t}getSuggestions(e){return this.suggestion.filter(t=>{var i,n,s;let o=e==null?void 0:e.toLowerCase();return((i=t.title)==null?void 0:i.toLowerCase().includes(o))||((n=t.author)==null?void 0:n.toLowerCase().includes(o))||((s=t.publisher)==null?void 0:s.toLowerCase().includes(o))})}renderSuggestion(e,t){t.addClass("book-suggestion-item");let o=e.coverLargeUrl||e.coverMediumUrl||e.coverSmallUrl||e.coverUrl;this.showCoverImageInSearch&&o&&t.createEl("img",{cls:"book-cover-image",attr:{src:o,alt:`Cover Image for ${e.title}`}});let i=t.createEl("div",{cls:"book-text-info"});i.createEl("div",{text:e.title});let n=e.publisher?`, ${e.publisher}`:"",s=e.publishDate?`(${e.publishDate})`:"",a=e.totalPage?`, p${e.totalPage}`:"",l=`${e.author}${n}${s}${a}`;i.createEl("small",{text:l})}onChooseSuggestion(e){this.onChoose(null,e)}};var Ut=q(require("obsidian")),st=class{constructor(e){this.app=e}jumpToNextCursorLocation(){return h(this,null,function*(){let e=this.app.workspace.getActiveViewOfType(Ut.MarkdownView);if(!e)return;let o=(yield this.app.vault.cachedRead(e.file)).length+1,i=e.editor;i.focus(),i.setCursor(o,0)})}};var _=q(require("obsidian"));var Xt=/^-?[0-9]*$/,at=/{{DATE(\+-?[0-9]+)?}}/,lt=/{{DATE:([^}\n\r+]*)(\+-?[0-9]+)?}}/;function Hr(r){return r.replace(/[\\,#%&{}/*<>$":@.?|]/g,"").replace(/\s+/g," ")}function pt(r,e,t="md"){let o;return e?o=Ie(r,We(e)):o=r.author?`${r.title} - ${r.author}`:r.title,Hr(o)+`.${t}`}function Wr(r){return Object.entries(r).reduce((e,[t,o])=>(e[Gr(t)]=o,e),{})}function qt(r,e,t=be.snakeCase){var n,s;let o=t===be.camelCase?r:Wr(r),i=typeof e=="string"?Ur(e):e;for(let a in i){let l=(s=(n=i[a])==null?void 0:n.toString().trim())!=null?s:"";o[a]&&o[a]!==l?o[a]=`${o[a]}, ${l}`:o[a]=l}return o}function Ie(r,e){return(e==null?void 0:e.trim())?Object.entries(r).reduce((o,[i,n=""])=>o.replace(new RegExp(`{{${i}}}`,"ig"),n),e).replace(/{{\w+}}/gi,"").trim():""}function Gr(r){return r.replace(/[A-Z]/g,e=>`_${e==null?void 0:e.toLowerCase()}`)}function Ur(r){return r?r.split(` `).map(e=>{var n,s;let t=e.indexOf(":");if(t===-1)return[e.trim(),""];let o=(n=e.slice(0,t))==null?void 0:n.trim(),i=(s=e.slice(t+1))==null?void 0:s.trim();return[o,i]}).reduce((e,[t,o])=>{var i;return t&&(e[t]=(i=o==null?void 0:o.trim())!=null?i:""),e},{}):{}}function Yt(r){return Object.entries(r).map(([e,t])=>{var i;let o=(i=t==null?void 0:t.toString().trim())!=null?i:"";return/\r|\n/.test(o)?"":/:\s/.test(o)?`${e}: "${o.replace(/"/g,""")}" `:`${e}: ${o} `}).join("").trim()}function Kt(r){let e;return(r==null?void 0:r.offset)!==null&&(r==null?void 0:r.offset)!==void 0&&typeof r.offset=="number"&&(e=window.moment.duration(r.offset,"days")),(r==null?void 0:r.format)?window.moment().add(e).format(r==null?void 0:r.format):window.moment().add(e).format("YYYY-MM-DD")}function We(r){let e=r;for(;at.test(e);){let t=at.exec(e),o=0;if(t==null?void 0:t[1]){let i=t[1].replace("+","").trim();Xt.test(i)&&(o=parseInt(i))}e=zt(e,at,Kt({offset:o}))}for(;lt.test(e);){let t=lt.exec(e),o=t==null?void 0:t[1],i=0;if(t==null?void 0:t[2]){let n=t[2].replace("+","").trim();Xt.test(n)&&(i=parseInt(n))}e=zt(e,lt,Kt({format:o,offset:i}))}return e}function zt(r,e,t){return r.replace(e,function(){return t})}var wr=q(require("obsidian"));var j="top",N="bottom",k="right",T="left",Ge="auto",oe=[j,N,k,T],J="start",pe="end",Qt="clippingParents",Ue="viewport",xe="popper",Jt="reference",ct=oe.reduce(function(r,e){return r.concat([e+"-"+J,e+"-"+pe])},[]),Xe=[].concat(oe,[Ge]).reduce(function(r,e){return r.concat([e,e+"-"+J,e+"-"+pe])},[]),Xr="beforeRead",qr="read",Yr="afterRead",Kr="beforeMain",zr="main",Qr="afterMain",Jr="beforeWrite",Zr="write",eo="afterWrite",Zt=[Xr,qr,Yr,Kr,zr,Qr,Jr,Zr,eo];function D(r){return r?(r.nodeName||"").toLowerCase():null}function B(r){if(r==null)return window;if(r.toString()!=="[object Window]"){var e=r.ownerDocument;return e&&e.defaultView||window}return r}function Q(r){var e=B(r).Element;return r instanceof e||r instanceof Element}function A(r){var e=B(r).HTMLElement;return r instanceof e||r instanceof HTMLElement}function Se(r){if(typeof ShadowRoot=="undefined")return!1;var e=B(r).ShadowRoot;return r instanceof e||r instanceof ShadowRoot}function to(r){var e=r.state;Object.keys(e.elements).forEach(function(t){var o=e.styles[t]||{},i=e.attributes[t]||{},n=e.elements[t];!A(n)||!D(n)||(Object.assign(n.style,o),Object.keys(i).forEach(function(s){var a=i[s];a===!1?n.removeAttribute(s):n.setAttribute(s,a===!0?"":a)}))})}function ro(r){var e=r.state,t={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,t.popper),e.styles=t,e.elements.arrow&&Object.assign(e.elements.arrow.style,t.arrow),function(){Object.keys(e.elements).forEach(function(o){var i=e.elements[o],n=e.attributes[o]||{},s=Object.keys(e.styles.hasOwnProperty(o)?e.styles[o]:t[o]),a=s.reduce(function(l,u){return l[u]="",l},{});!A(i)||!D(i)||(Object.assign(i.style,a),Object.keys(n).forEach(function(l){i.removeAttribute(l)}))})}}var er={name:"applyStyles",enabled:!0,phase:"write",fn:to,effect:ro,requires:["computeStyles"]};function M(r){return r.split("-")[0]}var Y=Math.max,ce=Math.min,Z=Math.round;function G(r,e){e===void 0&&(e=!1);var t=r.getBoundingClientRect(),o=1,i=1;if(A(r)&&e){var n=r.offsetHeight,s=r.offsetWidth;s>0&&(o=Z(t.width)/s||1),n>0&&(i=Z(t.height)/n||1)}return{width:t.width/o,height:t.height/i,top:t.top/i,right:t.right/o,bottom:t.bottom/i,left:t.left/o,x:t.left/o,y:t.top/i}}function me(r){var e=G(r),t=r.offsetWidth,o=r.offsetHeight;return Math.abs(e.width-t)<=1&&(t=e.width),Math.abs(e.height-o)<=1&&(o=e.height),{x:r.offsetLeft,y:r.offsetTop,width:t,height:o}}function Ne(r,e){var t=e.getRootNode&&e.getRootNode();if(r.contains(e))return!0;if(t&&Se(t)){var o=e;do{if(o&&r.isSameNode(o))return!0;o=o.parentNode||o.host}while(o)}return!1}function $(r){return B(r).getComputedStyle(r)}function mt(r){return["table","td","th"].indexOf(D(r))>=0}function F(r){return((Q(r)?r.ownerDocument:r.document)||window.document).documentElement}function ee(r){return D(r)==="html"?r:r.assignedSlot||r.parentNode||(Se(r)?r.host:null)||F(r)}function tr(r){return!A(r)||$(r).position==="fixed"?null:r.offsetParent}function oo(r){var e=navigator.userAgent.toLowerCase().indexOf("firefox")!==-1,t=navigator.userAgent.indexOf("Trident")!==-1;if(t&&A(r)){var o=$(r);if(o.position==="fixed")return null}var i=ee(r);for(Se(i)&&(i=i.host);A(i)&&["html","body"].indexOf(D(i))<0;){var n=$(i);if(n.transform!=="none"||n.perspective!=="none"||n.contain==="paint"||["transform","perspective"].indexOf(n.willChange)!==-1||e&&n.willChange==="filter"||e&&n.filter&&n.filter!=="none")return i;i=i.parentNode}return null}function K(r){for(var e=B(r),t=tr(r);t&&mt(t)&&$(t).position==="static";)t=tr(t);return t&&(D(t)==="html"||D(t)==="body"&&$(t).position==="static")?e:t||oo(r)||e}function ue(r){return["top","bottom"].indexOf(r)>=0?"x":"y"}function fe(r,e,t){return Y(r,ce(e,t))}function rr(r,e,t){var o=fe(r,e,t);return o>t?t:o}function Ae(){return{top:0,right:0,bottom:0,left:0}}function De(r){return Object.assign({},Ae(),r)}function Me(r,e){return e.reduce(function(t,o){return t[o]=r,t},{})}var io=function(e,t){return e=typeof e=="function"?e(Object.assign({},t.rects,{placement:t.placement})):e,De(typeof e!="number"?e:Me(e,oe))};function no(r){var e,t=r.state,o=r.name,i=r.options,n=t.elements.arrow,s=t.modifiersData.popperOffsets,a=M(t.placement),l=ue(a),u=[T,k].indexOf(a)>=0,p=u?"height":"width";if(!(!n||!s)){var d=io(i.padding,t),E=me(n),c=l==="y"?j:T,m=l==="y"?N:k,f=t.rects.reference[p]+t.rects.reference[l]-s[l]-t.rects.popper[p],g=s[l]-t.rects.reference[l],y=K(n),P=y?l==="y"?y.clientHeight||0:y.clientWidth||0:0,C=f/2-g/2,v=d[c],b=P-E[p]-d[m],w=P/2-E[p]/2+C,x=fe(v,w,b),O=l;t.modifiersData[o]=(e={},e[O]=x,e.centerOffset=x-w,e)}}function so(r){var e=r.state,t=r.options,o=t.element,i=o===void 0?"[data-popper-arrow]":o;i!=null&&(typeof i=="string"&&(i=e.elements.popper.querySelector(i),!i)||!Ne(e.elements.popper,i)||(e.elements.arrow=i))}var or={name:"arrow",enabled:!0,phase:"main",fn:no,effect:so,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function U(r){return r.split("-")[1]}var ao={top:"auto",right:"auto",bottom:"auto",left:"auto"};function lo(r){var e=r.x,t=r.y,o=window,i=o.devicePixelRatio||1;return{x:Z(e*i)/i||0,y:Z(t*i)/i||0}}function ir(r){var e,t=r.popper,o=r.popperRect,i=r.placement,n=r.variation,s=r.offsets,a=r.position,l=r.gpuAcceleration,u=r.adaptive,p=r.roundOffsets,d=r.isFixed,E=s.x,c=E===void 0?0:E,m=s.y,f=m===void 0?0:m,g=typeof p=="function"?p({x:c,y:f}):{x:c,y:f};c=g.x,f=g.y;var y=s.hasOwnProperty("x"),P=s.hasOwnProperty("y"),C=T,v=j,b=window;if(u){var w=K(t),x="clientHeight",O="clientWidth";if(w===B(t)&&(w=F(t),$(w).position!=="static"&&a==="absolute"&&(x="scrollHeight",O="scrollWidth")),w=w,i===j||(i===T||i===k)&&n===pe){v=N;var R=d&&w===b&&b.visualViewport?b.visualViewport.height:w[x];f-=R-o.height,f*=l?1:-1}if(i===T||(i===j||i===N)&&n===pe){C=k;var L=d&&w===b&&b.visualViewport?b.visualViewport.width:w[O];c-=L-o.width,c*=l?1:-1}}var S=Object.assign({position:a},u&&ao),V=p===!0?lo({x:c,y:f}):{x:c,y:f};if(c=V.x,f=V.y,l){var H;return Object.assign({},S,(H={},H[v]=P?"0":"",H[C]=y?"0":"",H.transform=(b.devicePixelRatio||1)<=1?"translate("+c+"px, "+f+"px)":"translate3d("+c+"px, "+f+"px, 0)",H))}return Object.assign({},S,(e={},e[v]=P?f+"px":"",e[C]=y?c+"px":"",e.transform="",e))}function po(r){var e=r.state,t=r.options,o=t.gpuAcceleration,i=o===void 0?!0:o,n=t.adaptive,s=n===void 0?!0:n,a=t.roundOffsets,l=a===void 0?!0:a;if(!1)var u;var p={placement:M(e.placement),variation:U(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:i,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,ir(Object.assign({},p,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:s,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,ir(Object.assign({},p,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}var nr={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:po,data:{}};var qe={passive:!0};function co(r){var e=r.state,t=r.instance,o=r.options,i=o.scroll,n=i===void 0?!0:i,s=o.resize,a=s===void 0?!0:s,l=B(e.elements.popper),u=[].concat(e.scrollParents.reference,e.scrollParents.popper);return n&&u.forEach(function(p){p.addEventListener("scroll",t.update,qe)}),a&&l.addEventListener("resize",t.update,qe),function(){n&&u.forEach(function(p){p.removeEventListener("scroll",t.update,qe)}),a&&l.removeEventListener("resize",t.update,qe)}}var sr={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:co,data:{}};var mo={left:"right",right:"left",bottom:"top",top:"bottom"};function Ee(r){return r.replace(/left|right|bottom|top/g,function(e){return mo[e]})}var uo={start:"end",end:"start"};function Ye(r){return r.replace(/start|end/g,function(e){return uo[e]})}function de(r){var e=B(r),t=e.pageXOffset,o=e.pageYOffset;return{scrollLeft:t,scrollTop:o}}function ge(r){return G(F(r)).left+de(r).scrollLeft}function ut(r){var e=B(r),t=F(r),o=e.visualViewport,i=t.clientWidth,n=t.clientHeight,s=0,a=0;return o&&(i=o.width,n=o.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(s=o.offsetLeft,a=o.offsetTop)),{width:i,height:n,x:s+ge(r),y:a}}function ft(r){var e,t=F(r),o=de(r),i=(e=r.ownerDocument)==null?void 0:e.body,n=Y(t.scrollWidth,t.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),s=Y(t.scrollHeight,t.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),a=-o.scrollLeft+ge(r),l=-o.scrollTop;return $(i||t).direction==="rtl"&&(a+=Y(t.clientWidth,i?i.clientWidth:0)-n),{width:n,height:s,x:a,y:l}}function he(r){var e=$(r),t=e.overflow,o=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+i+o)}function Ke(r){return["html","body","#document"].indexOf(D(r))>=0?r.ownerDocument.body:A(r)&&he(r)?r:Ke(ee(r))}function ie(r,e){var t;e===void 0&&(e=[]);var o=Ke(r),i=o===((t=r.ownerDocument)==null?void 0:t.body),n=B(o),s=i?[n].concat(n.visualViewport||[],he(o)?o:[]):o,a=e.concat(s);return i?a:a.concat(ie(ee(s)))}function Pe(r){return Object.assign({},r,{left:r.x,top:r.y,right:r.x+r.width,bottom:r.y+r.height})}function fo(r){var e=G(r);return e.top=e.top+r.clientTop,e.left=e.left+r.clientLeft,e.bottom=e.top+r.clientHeight,e.right=e.left+r.clientWidth,e.width=r.clientWidth,e.height=r.clientHeight,e.x=e.left,e.y=e.top,e}function ar(r,e){return e===Ue?Pe(ut(r)):Q(e)?fo(e):Pe(ft(F(r)))}function go(r){var e=ie(ee(r)),t=["absolute","fixed"].indexOf($(r).position)>=0,o=t&&A(r)?K(r):r;return Q(o)?e.filter(function(i){return Q(i)&&Ne(i,o)&&D(i)!=="body"}):[]}function dt(r,e,t){var o=e==="clippingParents"?go(r):[].concat(e),i=[].concat(o,[t]),n=i[0],s=i.reduce(function(a,l){var u=ar(r,l);return a.top=Y(u.top,a.top),a.right=ce(u.right,a.right),a.bottom=ce(u.bottom,a.bottom),a.left=Y(u.left,a.left),a},ar(r,n));return s.width=s.right-s.left,s.height=s.bottom-s.top,s.x=s.left,s.y=s.top,s}function Re(r){var e=r.reference,t=r.element,o=r.placement,i=o?M(o):null,n=o?U(o):null,s=e.x+e.width/2-t.width/2,a=e.y+e.height/2-t.height/2,l;switch(i){case j:l={x:s,y:e.y-t.height};break;case N:l={x:s,y:e.y+e.height};break;case k:l={x:e.x+e.width,y:a};break;case T:l={x:e.x-t.width,y:a};break;default:l={x:e.x,y:e.y}}var u=i?ue(i):null;if(u!=null){var p=u==="y"?"height":"width";switch(n){case J:l[u]=l[u]-(e[p]/2-t[p]/2);break;case pe:l[u]=l[u]+(e[p]/2-t[p]/2);break;default:}}return l}function z(r,e){e===void 0&&(e={});var t=e,o=t.placement,i=o===void 0?r.placement:o,n=t.boundary,s=n===void 0?Qt:n,a=t.rootBoundary,l=a===void 0?Ue:a,u=t.elementContext,p=u===void 0?xe:u,d=t.altBoundary,E=d===void 0?!1:d,c=t.padding,m=c===void 0?0:c,f=De(typeof m!="number"?m:Me(m,oe)),g=p===xe?Jt:xe,y=r.rects.popper,P=r.elements[E?g:p],C=dt(Q(P)?P:P.contextElement||F(r.elements.popper),s,l),v=G(r.elements.reference),b=Re({reference:v,element:y,strategy:"absolute",placement:i}),w=Pe(Object.assign({},y,b)),x=p===xe?w:v,O={top:C.top-x.top+f.top,bottom:x.bottom-C.bottom+f.bottom,left:C.left-x.left+f.left,right:x.right-C.right+f.right},R=r.modifiersData.offset;if(p===xe&&R){var L=R[i];Object.keys(O).forEach(function(S){var V=[k,N].indexOf(S)>=0?1:-1,H=[j,N].indexOf(S)>=0?"y":"x";O[S]+=L[H]*V})}return O}function gt(r,e){e===void 0&&(e={});var t=e,o=t.placement,i=t.boundary,n=t.rootBoundary,s=t.padding,a=t.flipVariations,l=t.allowedAutoPlacements,u=l===void 0?Xe:l,p=U(o),d=p?a?ct:ct.filter(function(m){return U(m)===p}):oe,E=d.filter(function(m){return u.indexOf(m)>=0});E.length===0&&(E=d);var c=E.reduce(function(m,f){return m[f]=z(r,{placement:f,boundary:i,rootBoundary:n,padding:s})[M(f)],m},{});return Object.keys(c).sort(function(m,f){return c[m]-c[f]})}function ho(r){if(M(r)===Ge)return[];var e=Ee(r);return[Ye(r),e,Ye(e)]}function vo(r){var e=r.state,t=r.options,o=r.name;if(!e.modifiersData[o]._skip){for(var i=t.mainAxis,n=i===void 0?!0:i,s=t.altAxis,a=s===void 0?!0:s,l=t.fallbackPlacements,u=t.padding,p=t.boundary,d=t.rootBoundary,E=t.altBoundary,c=t.flipVariations,m=c===void 0?!0:c,f=t.allowedAutoPlacements,g=e.options.placement,y=M(g),P=y===g,C=l||(P||!m?[Ee(g)]:ho(g)),v=[g].concat(C).reduce(function(we,te){return we.concat(M(te)===Ge?gt(e,{placement:te,boundary:p,rootBoundary:d,padding:u,flipVariations:m,allowedAutoPlacements:f}):te)},[]),b=e.rects.reference,w=e.rects.popper,x=new Map,O=!0,R=v[0],L=0;L=0,Oe=je?"width":"height",W=z(e,{placement:S,boundary:p,rootBoundary:d,altBoundary:E,padding:u}),X=je?H?k:T:H?N:j;b[Oe]>w[Oe]&&(X=Ee(X));var Le=Ee(X),se=[];if(n&&se.push(W[V]<=0),a&&se.push(W[X]<=0,W[Le]<=0),se.every(function(we){return we})){R=S,O=!1;break}x.set(S,se)}if(O)for(var Fe=m?3:1,Je=function(te){var Be=v.find(function($e){var ae=x.get($e);if(ae)return ae.slice(0,te).every(function(Ze){return Ze})});if(Be)return R=Be,"break"},Te=Fe;Te>0;Te--){var _e=Je(Te);if(_e==="break")break}e.placement!==R&&(e.modifiersData[o]._skip=!0,e.placement=R,e.reset=!0)}}var lr={name:"flip",enabled:!0,phase:"main",fn:vo,requiresIfExists:["offset"],data:{_skip:!1}};function pr(r,e,t){return t===void 0&&(t={x:0,y:0}),{top:r.top-e.height-t.y,right:r.right-e.width+t.x,bottom:r.bottom-e.height+t.y,left:r.left-e.width-t.x}}function cr(r){return[j,k,N,T].some(function(e){return r[e]>=0})}function wo(r){var e=r.state,t=r.name,o=e.rects.reference,i=e.rects.popper,n=e.modifiersData.preventOverflow,s=z(e,{elementContext:"reference"}),a=z(e,{altBoundary:!0}),l=pr(s,o),u=pr(a,i,n),p=cr(l),d=cr(u);e.modifiersData[t]={referenceClippingOffsets:l,popperEscapeOffsets:u,isReferenceHidden:p,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":p,"data-popper-escaped":d})}var mr={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:wo};function yo(r,e,t){var o=M(r),i=[T,j].indexOf(o)>=0?-1:1,n=typeof t=="function"?t(Object.assign({},e,{placement:r})):t,s=n[0],a=n[1];return s=s||0,a=(a||0)*i,[T,k].indexOf(o)>=0?{x:a,y:s}:{x:s,y:a}}function bo(r){var e=r.state,t=r.options,o=r.name,i=t.offset,n=i===void 0?[0,0]:i,s=Xe.reduce(function(p,d){return p[d]=yo(d,e.rects,n),p},{}),a=s[e.placement],l=a.x,u=a.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=u),e.modifiersData[o]=s}var ur={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:bo};function xo(r){var e=r.state,t=r.name;e.modifiersData[t]=Re({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}var fr={name:"popperOffsets",enabled:!0,phase:"read",fn:xo,data:{}};function ht(r){return r==="x"?"y":"x"}function So(r){var e=r.state,t=r.options,o=r.name,i=t.mainAxis,n=i===void 0?!0:i,s=t.altAxis,a=s===void 0?!1:s,l=t.boundary,u=t.rootBoundary,p=t.altBoundary,d=t.padding,E=t.tether,c=E===void 0?!0:E,m=t.tetherOffset,f=m===void 0?0:m,g=z(e,{boundary:l,rootBoundary:u,padding:d,altBoundary:p}),y=M(e.placement),P=U(e.placement),C=!P,v=ue(y),b=ht(v),w=e.modifiersData.popperOffsets,x=e.rects.reference,O=e.rects.popper,R=typeof f=="function"?f(Object.assign({},e.rects,{placement:e.placement})):f,L=typeof R=="number"?{mainAxis:R,altAxis:R}:Object.assign({mainAxis:0,altAxis:0},R),S=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,V={x:0,y:0};if(!!w){if(n){var H,je=v==="y"?j:T,Oe=v==="y"?N:k,W=v==="y"?"height":"width",X=w[v],Le=X+g[je],se=X-g[Oe],Fe=c?-O[W]/2:0,Je=P===J?x[W]:O[W],Te=P===J?-O[W]:-x[W],_e=e.elements.arrow,we=c&&_e?me(_e):{width:0,height:0},te=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:Ae(),Be=te[je],$e=te[Oe],ae=fe(0,x[W],we[W]),Ze=C?x[W]/2-Fe-ae-Be-L.mainAxis:Je-ae-Be-L.mainAxis,Br=C?-x[W]/2+Fe+ae+$e+L.mainAxis:Te+ae+$e+L.mainAxis,et=e.elements.arrow&&K(e.elements.arrow),kr=et?v==="y"?et.clientTop||0:et.clientLeft||0:0,Bt=(H=S==null?void 0:S[v])!=null?H:0,Ir=X+Ze-Bt-kr,Nr=X+Br-Bt,kt=fe(c?ce(Le,Ir):Le,X,c?Y(se,Nr):se);w[v]=kt,V[v]=kt-X}if(a){var It,Ar=v==="x"?j:T,Dr=v==="x"?N:k,le=w[b],Ve=b==="y"?"height":"width",Nt=le+g[Ar],At=le-g[Dr],tt=[j,T].indexOf(y)!==-1,Dt=(It=S==null?void 0:S[b])!=null?It:0,Mt=tt?Nt:le-x[Ve]-O[Ve]-Dt+L.altAxis,Rt=tt?le+x[Ve]+O[Ve]-Dt-L.altAxis:At,Lt=c&&tt?rr(Mt,le,Rt):fe(c?Mt:Nt,le,c?Rt:At);w[b]=Lt,V[b]=Lt-le}e.modifiersData[o]=V}}var dr={name:"preventOverflow",enabled:!0,phase:"main",fn:So,requiresIfExists:["offset"]};function vt(r){return{scrollLeft:r.scrollLeft,scrollTop:r.scrollTop}}function wt(r){return r===B(r)||!A(r)?de(r):vt(r)}function Eo(r){var e=r.getBoundingClientRect(),t=Z(e.width)/r.offsetWidth||1,o=Z(e.height)/r.offsetHeight||1;return t!==1||o!==1}function yt(r,e,t){t===void 0&&(t=!1);var o=A(e),i=A(e)&&Eo(e),n=F(e),s=G(r,i),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(o||!o&&!t)&&((D(e)!=="body"||he(n))&&(a=wt(e)),A(e)?(l=G(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):n&&(l.x=ge(n))),{x:s.left+a.scrollLeft-l.x,y:s.top+a.scrollTop-l.y,width:s.width,height:s.height}}function Po(r){var e=new Map,t=new Set,o=[];r.forEach(function(n){e.set(n.name,n)});function i(n){t.add(n.name);var s=[].concat(n.requires||[],n.requiresIfExists||[]);s.forEach(function(a){if(!t.has(a)){var l=e.get(a);l&&i(l)}}),o.push(n)}return r.forEach(function(n){t.has(n.name)||i(n)}),o}function bt(r){var e=Po(r);return Zt.reduce(function(t,o){return t.concat(e.filter(function(i){return i.phase===o}))},[])}function xt(r){var e;return function(){return e||(e=new Promise(function(t){Promise.resolve().then(function(){e=void 0,t(r())})})),e}}function St(r){var e=r.reduce(function(t,o){var i=t[o.name];return t[o.name]=i?Object.assign({},i,o,{options:Object.assign({},i.options,o.options),data:Object.assign({},i.data,o.data)}):o,t},{});return Object.keys(e).map(function(t){return e[t]})}var gr={placement:"bottom",modifiers:[],strategy:"absolute"};function hr(){for(var r=arguments.length,e=new Array(r),t=0;t(r%e+e)%e,yr=class{constructor(e,t,o){this.owner=e,this.containerEl=t,t.on("click",".suggestion-item",this.onSuggestionClick.bind(this)),t.on("mousemove",".suggestion-item",this.onSuggestionMouseover.bind(this)),o.register([],"ArrowUp",i=>{if(!i.isComposing)return this.setSelectedItem(this.selectedItem-1,!0),!1}),o.register([],"ArrowDown",i=>{if(!i.isComposing)return this.setSelectedItem(this.selectedItem+1,!0),!1}),o.register([],"Enter",i=>{if(!i.isComposing)return this.useSelectedItem(i),!1})}onSuggestionClick(e,t){e.preventDefault();let o=this.suggestions.indexOf(t);this.setSelectedItem(o,!1),this.useSelectedItem(e)}onSuggestionMouseover(e,t){let o=this.suggestions.indexOf(t);this.setSelectedItem(o,!1)}setSuggestions(e){this.containerEl.empty();let t=[];e.forEach(o=>{let i=this.containerEl.createDiv("suggestion-item");this.owner.renderSuggestion(o,i),t.push(i)}),this.values=e,this.suggestions=t,this.setSelectedItem(0,!1)}useSelectedItem(e){let t=this.values[this.selectedItem];t&&this.owner.selectSuggestion(t,e)}setSelectedItem(e,t){let o=jo(e,this.suggestions.length),i=this.suggestions[this.selectedItem],n=this.suggestions[o];i==null||i.removeClass("is-selected"),n==null||n.addClass("is-selected"),this.selectedItem=o,t&&n.scrollIntoView(!1)}},ve=class{constructor(e,t){this.app=e;this.inputEl=t;this.scope=new wr.Scope,this.suggestEl=createDiv("suggestion-container");let o=this.suggestEl.createDiv("suggestion");this.suggest=new yr(this,o,this.scope),this.scope.register([],"Escape",this.close.bind(this)),this.inputEl.addEventListener("input",this.onInputChanged.bind(this)),this.inputEl.addEventListener("focus",this.onInputChanged.bind(this)),this.inputEl.addEventListener("blur",this.close.bind(this)),this.suggestEl.on("mousedown",".suggestion-container",i=>{i.preventDefault()})}onInputChanged(){let e=this.inputEl.value,t=this.getSuggestions(e);if(!t){this.close();return}t.length>0?(this.suggest.setSuggestions(t),this.open(this.app.dom.appContainerEl,this.inputEl)):this.close()}open(e,t){this.app.keymap.pushScope(this.scope),e.appendChild(this.suggestEl),this.popper=Et(t,this.suggestEl,{placement:"bottom-start",modifiers:[{name:"sameWidth",enabled:!0,fn:({state:o,instance:i})=>{let n=`${o.rects.reference.width}px`;o.styles.popper.width!==n&&(o.styles.popper.width=n,i.update())},phase:"beforeWrite",requires:["computeStyles"]}]})}close(){this.app.keymap.popScope(this.scope),this.suggest.setSuggestions([]),this.popper&&this.popper.destroy(),this.suggestEl.detach()}};var Oo="{{DATE}}",br="{{DATE:}}",To=/{{D?A?T?E?}?}?$/i,Bo=/{{D?A?T?E?:?$|{{DATE:[^\n\r}]*}}$/i,ko="{{author}}",Io=/{{a?u?t?h?o?r?}?}?$/i,No="{{title}}",Ao=/{{t?i?t?l?e?}?}?$/i,Pt=class extends ve{constructor(e,t){super(e,t);this.app=e;this.inputEl=t;this.lastInput=""}getSuggestions(e){let t=this.inputEl.selectionStart,o=15,i=e.substr(t-o,o),n=[];return this.processToken(i,(s,a)=>{this.lastInput=s[0],n.push(a)}),n}selectSuggestion(e){let t=this.inputEl.selectionStart,o=this.lastInput.length,i=this.inputEl.value,n=0,s=(a,l=0)=>`${i.substr(0,t-o+l)}${a}${i.substr(t)}`;this.processToken(e,(a,l)=>{e.contains(l)&&(this.inputEl.value=s(e),n=t-o+e.length,e===br&&(n-=2))}),this.inputEl.trigger("input"),this.close(),this.inputEl.setSelectionRange(n,n)}renderSuggestion(e,t){e&&t.setText(e)}processToken(e,t){let o=Bo.exec(e);o&&t(o,br);let i=To.exec(e);i&&t(i,Oo);let n=Io.exec(e);n&&t(n,ko);let s=Ao.exec(e);s&&t(s,No)}};var xr=q(require("obsidian"));var ze=class extends ve{getSuggestions(e){let t=this.app.vault.getAllLoadedFiles(),o=[],i=e.toLowerCase();return t.forEach(n=>{n instanceof xr.TFolder&&n.path.toLowerCase().contains(i)&&o.push(n)}),o}renderSuggestion(e,t){t.setText(e.path)}selectSuggestion(e){this.inputEl.value=e.path,this.inputEl.trigger("input"),this.close()}};var Sr=q(require("obsidian"));var Ct=class extends ve{getSuggestions(e){let t=this.app.vault.getAllLoadedFiles(),o=[],i=e.toLowerCase();return t.forEach(n=>{n instanceof Sr.TFile&&n.extension==="md"&&n.path.toLowerCase().contains(i)&&o.push(n)}),o}renderSuggestion(e,t){t.setText(e.path)}selectSuggestion(e){this.inputEl.value=e.path,this.inputEl.trigger("input"),this.close()}};var Ce=q(require("obsidian")),jt=class extends Ce.Modal{constructor(e,t){super(e.app);this.callback=t;var o,i;this.plugin=e,this.currentServiceProvider=(i=(o=e.settings)==null?void 0:o.serviceProvider)!=null?i:I.google}get settings(){return this.plugin.settings}saveSetting(){return h(this,null,function*(){return this.plugin.saveSettings()})}saveClientId(e){this.currentServiceProvider===I.naver&&(this.plugin.settings.naverClientId=e)}saveClientSecret(e){this.currentServiceProvider===I.naver&&(this.settings.naverClientSecret=e)}get currentClientId(){return this.currentServiceProvider===I.naver?this.settings.naverClientId:""}get currentClientSecret(){return this.currentServiceProvider===I.naver?this.settings.naverClientSecret:""}onOpen(){let{contentEl:e}=this;e.createEl("h2",{text:"Service Provider Setting"}),new Ce.Setting(e).setName("Client ID").addText(t=>{t.setValue(this.currentClientId).onChange(o=>this.saveClientId(o))}),new Ce.Setting(e).setName("Client Secret").addText(t=>{t.setValue(this.currentClientSecret).onChange(o=>this.saveClientSecret(o))}),new Ce.Setting(e).addButton(t=>t.setButtonText("Save").setCta().onClick(()=>h(this,null,function*(){var o;yield this.plugin.saveSettings(),this.close(),(o=this.callback)==null||o.call(this)})))}onClose(){this.contentEl.empty()}};var Do="https://github.com/anpigon/obsidian-book-search-plugin",be;(function(t){t.snakeCase="Snake Case",t.camelCase="Camel Case"})(be||(be={}));var Er={folder:"",fileNameFormat:"",frontmatter:"",content:"",useDefaultFrontmatter:!0,defaultFrontmatterKeyType:be.camelCase,templateFile:"",serviceProvider:I.google,naverClientId:"",naverClientSecret:"",localePreference:"default",apiKey:"",openPageOnCompletion:!0,showCoverImageInSearch:!1,enableCoverImageSave:!1,coverImagePath:""},Ot=class extends _.PluginSettingTab{constructor(e,t){super(e,t);this.plugin=t}get settings(){return this.plugin.settings}display(){let{containerEl:e}=this;e.empty(),e.classList.add("book-search-plugin__settings"),Pr(e,"General Settings"),new _.Setting(e).setName("New file location").setDesc("New book notes will be placed here.").addSearch(c=>{try{new ze(this.app,c.inputEl)}catch(m){}c.setPlaceholder("Example: folder1/folder2").setValue(this.plugin.settings.folder).onChange(m=>{this.plugin.settings.folder=m,this.plugin.saveSettings()})});let t=document.createDocumentFragment().createEl("code",{text:We(this.plugin.settings.fileNameFormat)||"{{title}} - {{author}}"});new _.Setting(e).setClass("book-search-plugin__settings--new_file_name").setName("New file name").setDesc("Enter the file name format.").addSearch(c=>{try{new Pt(this.app,c.inputEl)}catch(m){}c.setPlaceholder("Example: {{title}} - {{author}}").setValue(this.plugin.settings.fileNameFormat).onChange(m=>{this.plugin.settings.fileNameFormat=m==null?void 0:m.trim(),this.plugin.saveSettings(),t.innerHTML=We(m)||"{{title}} - {{author}}"})}),e.createEl("div",{cls:["setting-item-description","book-search-plugin__settings--new_file_name_hint"]}).append(t);let o=document.createDocumentFragment();o.createDiv({text:"Files will be available as templates."}),o.createEl("a",{text:"Example Template",href:`${Do}#example-template`}),new _.Setting(e).setName("Template file").setDesc(o).addSearch(c=>{try{new Ct(this.app,c.inputEl)}catch(m){}c.setPlaceholder("Example: templates/template-file").setValue(this.plugin.settings.templateFile).onChange(m=>{this.plugin.settings.templateFile=m,this.plugin.saveSettings()})});let i,n,s=()=>{i.addClass("book-search-plugin__hide")},a=()=>{i.removeClass("book-search-plugin__hide")},l=()=>{n!==void 0&&n.settingEl.addClass("book-search-plugin__hide")},u=()=>{n!==void 0&&n.settingEl.removeClass("book-search-plugin__hide")},p=(c=(m=>(m=this.settings)==null?void 0:m.serviceProvider)())=>{c===I.naver?(a(),l()):(s(),u())};new _.Setting(e).setName("Service Provider").setDesc("Choose the service provider you want to use to search your books.").setClass("book-search-plugin__settings--service_provider").addDropdown(c=>{var m,f;c.addOption(I.google,`${I.google} (Global)`),c.addOption(I.naver,`${I.naver} (Korean)`),c.setValue((f=(m=this.plugin.settings)==null?void 0:m.serviceProvider)!=null?f:I.google),c.onChange(g=>h(this,null,function*(){let y=g;p(y),this.settings.serviceProvider=y,yield this.plugin.saveSettings()}))}).addExtraButton(c=>{i=c.extraSettingsEl,p(),c.onClick(()=>{new jt(this.plugin).open()})}),n=new _.Setting(e).setName("Preferred locale").setDesc("Sets the preferred locale to use when searching for books.").addDropdown(c=>{let m=window.moment.locale();c.addOption(m,`${m} (Default Locale)`),window.moment.locales().forEach(g=>{c.addOption(g,g)});let f=this.settings.localePreference;f==="default"?c.setValue(m):c.setValue(f),c.onChange(g=>h(this,null,function*(){let y=g;this.settings.localePreference=y,yield this.plugin.saveSettings()}))}),new _.Setting(e).setName("Open New Book Note").setDesc("Enable or disable the automatic opening of the note on creation.").addToggle(c=>c.setValue(this.plugin.settings.openPageOnCompletion).onChange(m=>h(this,null,function*(){this.plugin.settings.openPageOnCompletion=m,yield this.plugin.saveSettings()}))),new _.Setting(e).setName("Show Cover Images in Search").setDesc("Toggle to show or hide cover images in the search results.").addToggle(c=>c.setValue(this.plugin.settings.showCoverImageInSearch).onChange(m=>h(this,null,function*(){this.plugin.settings.showCoverImageInSearch=m,yield this.plugin.saveSettings()}))),new _.Setting(e).setName("Enable Cover Image Save").setDesc("Toggle to enable or disable saving cover images in notes.").addToggle(c=>c.setValue(this.plugin.settings.enableCoverImageSave).onChange(m=>h(this,null,function*(){this.plugin.settings.enableCoverImageSave=m,yield this.plugin.saveSettings()}))),new _.Setting(e).setName("Cover Image Path").setDesc("Specify the path where cover images should be saved.").addSearch(c=>{try{new ze(this.app,c.inputEl)}catch(m){}c.setPlaceholder("Enter the path (e.g., Images/Covers)").setValue(this.plugin.settings.coverImagePath).onChange(m=>h(this,null,function*(){this.plugin.settings.coverImagePath=m.trim(),yield this.plugin.saveSettings()}))});let d=[];Mo(e,"Google API Settings",d);let E="";d.push(new _.Setting(e).setClass("book-search-plugin__hide").setName("Google Book API Key").setDesc("Add your Books API key. **WARNING** please use this field after you must understand Google Cloud API, such as API key security.").addText(c=>{c.inputEl.type="password",c.setValue(this.plugin.settings.apiKey).onChange(m=>h(this,null,function*(){E=m}))}).addButton(c=>{c.setButtonText("Save Key").onClick(()=>h(this,null,function*(){this.plugin.settings.apiKey=E,yield this.plugin.saveSettings(),new _.Notice("Apikey Saved")}))}))}};function Pr(r,e){let t=document.createDocumentFragment();return t.createEl("h2",{text:e}),new _.Setting(r).setHeading().setName(t)}function Mo(r,e,t){return Pr(r,e).addToggle(o=>{o.onChange(i=>{t.forEach(({settingEl:n})=>{n.toggleClass("book-search-plugin__show",i)})})})}var Qe=q(require("obsidian"));function Cr(r,e){return h(this,null,function*(){let{metadataCache:t,vault:o}=r,i=(0,Qe.normalizePath)(e!=null?e:"");if(e==="/")return Promise.resolve("");try{let n=t.getFirstLinkpathDest(i,"");return n?o.cachedRead(n):""}catch(n){return console.error(`Failed to read the daily note template '${i}'`,n),new Qe.Notice("Failed to read the daily note template"),""}})}function jr(r){return r.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(e,t,o,i,n,s)=>{let a=window.moment(),l=window.moment().clone().set({hour:a.get("hour"),minute:a.get("minute"),second:a.get("second")});return o&&l.add(parseInt(i,10),n),s?l.format(s.substring(1).trim()):l.format("YYYY-MM-DD")})}function Or(r,e){let t=/<%(?:=)(.+)%>/g,o=Ro();return[...e.matchAll(t)].reduce((n,[s,a])=>{try{let l=new o(["const [book] = arguments",`const output = ${a}`,'if(typeof output === "string") return output',"return JSON.stringify(output)"].join(";"))(r);return n.replace(s,l)}catch(l){console.warn(l)}return n},e)}function Ro(){try{return new Function("return (function(){}).constructor")()}catch(r){throw console.warn(r),r instanceof SyntaxError?Error("Bad template syntax"):r}}function Tr(r,e){return h(this,null,function*(){let t=r.plugins.plugins["templater-obsidian"];t&&!(t==null?void 0:t.settings.trigger_on_file_creation)&&(yield t.templater.overwrite_file_commands(e))})}var Tt=class extends ne.Plugin{onload(){return h(this,null,function*(){yield this.loadSettings(),this.addRibbonIcon("book","Create new book note",()=>this.createNewBookNote()).addClass("obsidian-book-search-plugin-ribbon-class"),this.addCommand({id:"open-book-search-modal",name:"Create new book note",callback:()=>this.createNewBookNote()}),this.addCommand({id:"open-book-search-modal-to-insert",name:"Insert the metadata",callback:()=>this.insertMetadata()}),this.addSettingTab(new Ot(this.app,this)),console.log(`Book Search: version ${this.manifest.version} (requires obsidian ${this.manifest.minAppVersion})`)})}showNotice(e){try{new ne.Notice(e==null?void 0:e.toString())}catch(t){}}searchBookMetadata(e){return h(this,null,function*(){let t=yield this.openBookSearchModal(e);return yield this.openBookSuggestModal(t)})}getRenderedContents(e){return h(this,null,function*(){let{templateFile:t,useDefaultFrontmatter:o,defaultFrontmatterKeyType:i,enableCoverImageSave:n,coverImagePath:s,frontmatter:a,content:l}=this.settings,u="";if(n){let p=e.coverLargeUrl||e.coverMediumUrl||e.coverSmallUrl||e.coverUrl;if(p){let d=pt(e,this.settings.fileNameFormat,"jpg");e.localCoverImage=yield this.downloadAndSaveImage(d,s,p)}}if(t){let p=yield Cr(this.app,t),d=Ie(e,jr(p));u+=Or(e,d)}else{let p=Ie(e,a);o&&(p=Yt(qt(e,p,i)));let d=Ie(e,l);u+=p?`--- diff --git a/.obsidian/plugins/obsidian-book-search-plugin/manifest.json b/.obsidian/plugins/obsidian-book-search-plugin/manifest.json index d4e4d5ce..6a01d607 100644 --- a/.obsidian/plugins/obsidian-book-search-plugin/manifest.json +++ b/.obsidian/plugins/obsidian-book-search-plugin/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-book-search-plugin", "name": "Book Search", - "version": "0.6.0", + "version": "0.6.1", "minAppVersion": "0.15.0", "description": "Helps you find books and create notes.", "author": "anpigon", diff --git a/.obsidian/plugins/obsidian-commits/data.json b/.obsidian/plugins/obsidian-commits/data.json index 129dd222..765bf81a 100644 --- a/.obsidian/plugins/obsidian-commits/data.json +++ b/.obsidian/plugins/obsidian-commits/data.json @@ -1520,7 +1520,7 @@ "links": 18 }, "05.02 Networks/Configuring UFW.md": { - "size": 20005, + "size": 22259, "tags": 2, "links": 7 }, @@ -10299,11 +10299,6 @@ "tags": 0, "links": 8 }, - "00.01 Admin/Calendars/Events/2024-03-05 ⚽️ Real Sociedad - PSG.md": { - "size": 186, - "tags": 0, - "links": 2 - }, "00.01 Admin/Calendars/2023-12-19.md": { "size": 1412, "tags": 0, @@ -10374,11 +10369,6 @@ "tags": 1, "links": 2 }, - "00.02 Inbox/Yoga.md": { - "size": 1099, - "tags": 4, - "links": 1 - }, "00.02 Inbox/Gaslight.md": { "size": 878, "tags": 3, @@ -11499,11 +11489,6 @@ "tags": 3, "links": 2 }, - "00.02 Inbox/Invisible Man.md": { - "size": 885, - "tags": 4, - "links": 1 - }, "00.01 Admin/Calendars/2024-02-27.md": { "size": 1412, "tags": 0, @@ -11540,17 +11525,92 @@ "links": 6 }, "00.01 Admin/Calendars/2024-03-03.md": { + "size": 1412, + "tags": 0, + "links": 7 + }, + "00.01 Admin/Calendars/2024-03-04.md": { + "size": 1412, + "tags": 0, + "links": 5 + }, + "00.03 News/How Russian Spies Get Flipped or Expelled, As Told by a Spycatcher.md": { + "size": 16868, + "tags": 5, + "links": 1 + }, + "00.03 News/The (Many) Vintages of the Century.md": { + "size": 15031, + "tags": 3, + "links": 2 + }, + "00.03 News/I always believed my funny, kind father was killed by a murderous teenage gang. Three decades on, I discovered the truth.md": { + "size": 26351, + "tags": 3, + "links": 1 + }, + "00.03 News/The Great Pretenders How two faux-Inuit sisters cashed in on a life of deception.md": { + "size": 41977, + "tags": 4, + "links": 1 + }, + "00.03 News/The Pentagon’s Silicon Valley Problem, by Andrew Cockburn.md": { + "size": 32155, + "tags": 2, + "links": 1 + }, + "00.01 Admin/Calendars/2024-03-05.md": { + "size": 1412, + "tags": 0, + "links": 7 + }, + "00.01 Admin/Calendars/Events/2024-03-05 ⚽️ Real Sociedad - PSG (1-2).md": { + "size": 434, + "tags": 0, + "links": 2 + }, + "00.01 Admin/Calendars/2024-03-06.md": { + "size": 1412, + "tags": 0, + "links": 7 + }, + "03.01 Reading list/Invisible Man.md": { + "size": 885, + "tags": 4, + "links": 2 + }, + "00.01 Admin/Calendars/2024-03-07.md": { + "size": 1412, + "tags": 0, + "links": 7 + }, + "00.01 Admin/Calendars/2024-03-08.md": { + "size": 1705, + "tags": 0, + "links": 7 + }, + "00.01 Admin/Calendars/2024-03-09.md": { "size": 1412, "tags": 0, "links": 6 + }, + "03.01 Reading list/Yoga.md": { + "size": 1099, + "tags": 4, + "links": 2 + }, + "00.01 Admin/Calendars/2024-03-10.md": { + "size": 1255, + "tags": 0, + "links": 4 } }, "commitTypes": { "/": { - "Refactor": 6976, - "Create": 2490, - "Link": 9064, - "Expand": 2123 + "Refactor": 6989, + "Create": 2503, + "Link": 9097, + "Expand": 2127 } }, "dailyCommits": { @@ -11561,40 +11621,44 @@ "3": 12, "4": 46, "5": 16, - "6": 69, - "7": 897, - "8": 1139, - "9": 1068, + "6": 70, + "7": 908, + "8": 1142, + "9": 1097, "10": 751, - "11": 549, - "12": 6740, - "13": 675, + "11": 551, + "12": 6745, + "13": 676, "14": 574, "15": 640, "16": 706, "17": 815, - "18": 1005, - "19": 939, + "18": 1006, + "19": 943, "20": 867, - "21": 777, - "22": 749, - "23": 1351 + "21": 779, + "22": 750, + "23": 1354 } }, "weeklyCommits": { "/": { - "Mon": 2890, - "Tue": 1713, - "Wed": 7884, - "Thu": 1341, - "Fri": 1452, + "Mon": 2919, + "Tue": 1719, + "Wed": 7892, + "Thu": 1344, + "Fri": 1458, "Sat": 0, - "Sun": 5373 + "Sun": 5384 } }, "recentCommits": { "/": { "Expanded": [ + " 2024-03-08 ", + " Configuring UFW ", + " 2024-03-05 ⚽️ Real Sociedad - PSG (1-2) ", + " 2024-03-05 ⚽️ Real Sociedad - PSG ", " 2024-03-01 ⚽️ AS Monaco - PSG ", " 2024-03-01 ⚽️ AS Monaco - PSG ", " 2023-12-15 Eczema ", @@ -11641,13 +11705,22 @@ " 2024-01-20 ⚽️ US Orleans - PSG ", " 2024-01-20 ⚽️ US Orleans - PSG ", " 2024-01-20 ⚽️ US Orleans - PSG ", - " Hoch Ybrig ", - " Hoch Ybrig ", - " Configuring UFW ", - " Bandes Dessinées ", - " Sawerdo " + " Hoch Ybrig " ], "Created": [ + " 2024-03-10 ", + " 2024-03-09 ", + " 2024-03-08 ", + " 2024-03-07 ", + " 2024-03-06 ", + " 2024-03-05 ", + " The Spy War How the C.I.A. Secretly Helps Ukraine Fight Putin ", + " The Pentagon’s Silicon Valley Problem, by Andrew Cockburn ", + " The Great Pretenders How two faux-Inuit sisters cashed in on a life of deception ", + " I always believed my funny, kind father was killed by a murderous teenage gang. Three decades on, I discovered the truth ", + " The (Many) Vintages of the Century ", + " How Russian Spies Get Flipped or Expelled, As Told by a Spycatcher - VSquare.org ", + " 2024-03-04 ", " 2024-03-03 ", " 2024-03-02 ", " 2024-03-01 ⚽️ AS Monaco - PSG ", @@ -11685,22 +11758,20 @@ " 2024-02-14 ", " 2024-02-13 ", " 2024-02-12 ", - " His Best Friend Was a 250-Pound Warthog. One Day, It Decided to Kill Him. ", - " A Teen’s Fatal Plunge Into the London Underworld ", - " How Nikola Jokić Became the World’s Best Basketball Player ", - " Nat Friedman Embraces AI to Translate the Herculaneum Papyri ", - " Paper mills are bribing editors at scholarly journals, Science investigation finds ", - " 2024-02-11 ", - " 2024-02-10 ⚽️ PSG - Lille OSC ", - " 2024-02-10 ", - " 2024-02-09 ", - " 2024-02-08 ", - " 2024-02-07 ", - " 2024-02-06 ", - " 2024-02-05 ", - " Why Tim Cook Is Going All In on the Apple Vision Pro " + " His Best Friend Was a 250-Pound Warthog. One Day, It Decided to Kill Him. " ], "Renamed": [ + " Yoga ", + " Invisible Man ", + " 2024-03-05 ⚽️ Real Sociedad - PSG (1-2) ", + " The Spy War How the C.I.A. Secretly Helps Ukraine Fight Putin ", + " The Spy War How the C.I.A. Secretly Helps Ukraine Fight Putin ", + " The Pentagon’s Silicon Valley Problem, by Andrew Cockburn ", + " The Great Pretenders How two faux-Inuit sisters cashed in on a life of deception ", + " I always believed my funny, kind father was killed by a murderous teenage gang. Three decades on, I discovered the truth ", + " The (Many) Vintages of the Century ", + " How Russian Spies Get Flipped or Expelled, As Told by a Spycatcher ", + " How Russian Spies Get Flipped or Expelled, As Told by a Spycatcher - VSquare.org ", " 2024-03-01 ⚽️ AS Monaco - PSG (0-0) ", " La Louisiane ", " La Louisiane 1 ", @@ -11740,20 +11811,14 @@ " Ripples of hate ", " Hippy, capitalist, guru, grocer the forgotten genius who changed British food ", " Fentanyl, the portrait of a mass murderer ", - " The Taylor Swift deepfakes are a warning ", - " The Juror Who Found Herself Guilty ", - " Highway to Hell (by ACDC - 1979) ", - " Enter the Wu‐Tang (36 Chambers) (by Wu‐Tang Clan - 1993) ", - " Thriller (by Michael Jackson - 1982) ", - " Barfussbar ", - " Old Crow ", - " The Old Crow ", - " Interview with the Vampire - The Vampire Chronicles (1994) ", - " Rain Man (1988) ", - " Inside the house shows that bolster Boston’s lacking nightlife ", - " Hvaldimir, the Whale Who Went AWOL " + " The Taylor Swift deepfakes are a warning " ], "Tagged": [ + " I always believed my funny, kind father was killed by a murderous teenage gang. Three decades on, I discovered the truth ", + " The Great Pretenders How two faux-Inuit sisters cashed in on a life of deception ", + " The Pentagon’s Silicon Valley Problem, by Andrew Cockburn ", + " How Russian Spies Get Flipped or Expelled, As Told by a Spycatcher ", + " The (Many) Vintages of the Century ", " Invisible Man ", " The surreal life of a professional bridesmaid - The Hustle ", " How a Con Man Ended Up in Solitary in Colorado Supermax Federal Prison ", @@ -11799,14 +11864,10 @@ " Barfussbar ", " The Old Crow ", " Inside the house shows that bolster Boston’s lacking nightlife ", - " Hvaldimir, the Whale Who Went AWOL ", - " My cousin was killed by a car bomb in Milwaukee. A mob boss was the top suspect. Now, I’m looking for answers. ", - " Klewenalp ", - " Hoch Ybrig ", - " Hoch Ybrig ", - " Hoch Ybrig " + " Hvaldimir, the Whale Who Went AWOL " ], "Refactored": [ + " 2024-03-10 ", " 2024-03-01 ⚽️ AS Monaco - PSG ", " 2024-02-25 ", " Sesame Seared Tuna Steak ", @@ -11856,10 +11917,10 @@ " 2023-11-02 ", " Real Estate ", " 2023-10-26 ", - " Rape, Race and a Decades-Old Lie That Still Wounds ", - " A crumbling, long-forgotten statue with an unusual erect phallus might be a Michelangelo. Renaissance scholars want hard evidence. " + " Rape, Race and a Decades-Old Lie That Still Wounds " ], "Deleted": [ + " The Spy War How the C.I.A. Secretly Helps Ukraine Fight Putin ", " When the Border Crisis Is in Your Backyard Migrants, Cartels and Cowboys ", " As a Son Risks His Life to Topple the King, His Father Guards the Throne ", " The Untold Origin Story of ESPN ", @@ -11909,10 +11970,37 @@ " ‘Trump’s Kevin’ McCarthy could soon be speaker of the House - Los Angeles Times ", " The Most Lawless County in Texas ", " How Ukrainians Are Protecting Their Centuries-Old Culture From Putin’s Invasion ", - " Do We Have the History of Native Americans Backward ", - " The Too-Muchness of Bono " + " Do We Have the History of Native Americans Backward " ], "Linked": [ + " 2024-03-10 ", + " The (Many) Vintages of the Century ", + " Yoga ", + " 2024-03-09 ", + " 2024-03-09 ", + " 2024-03-09 ", + " 2024-03-08 ", + " 2024-03-07 ", + " 2024-03-08 ", + " 2024-03-07 ", + " 2024-03-07 ", + " 2024-03-06 ", + " 2024-03-06 ", + " Invisible Man ", + " 2024-03-06 ", + " 2024-03-06 ", + " 2024-03-05 ", + " 2024-03-05 ", + " 2024-03-05 ", + " 2024-03-04 ", + " The Spy War How the C.I.A. Secretly Helps Ukraine Fight Putin ", + " The Great Pretenders How two faux-Inuit sisters cashed in on a life of deception ", + " The Pentagon’s Silicon Valley Problem, by Andrew Cockburn ", + " I always believed my funny, kind father was killed by a murderous teenage gang. Three decades on, I discovered the truth ", + " How Russian Spies Get Flipped or Expelled, As Told by a Spycatcher ", + " The (Many) Vintages of the Century ", + " 2024-03-04 ", + " 2024-03-03 ", " 2024-03-02 ", " 2024-03-03 ", " 2024-03-02 ", @@ -11935,35 +12023,7 @@ " Zoo Station ", " Invisible Man ", " 2024-02-26 ", - " 2024-02-26 ", - " As a Son Risks His Life to Topple the King, His Father Guards the Throne ", - " How a Con Man Ended Up in Solitary in Colorado Supermax Federal Prison ", - " Recovering the Lost Aviators of World War II ", - " 2024-02-25 ", - " 2024-02-25 ", - " 2024-02-25 ", - " 2024-02-24 ", - " 2024-02-24 ", - " 2024-02-23 ", - " 2024-02-23 ", - " The art of doing nothing have the Dutch found the answer to burnout culture ", - " Sesame Seared Tuna Steak ", - " Sesame Seared Tuna Steak Recipe ", - " 2024-02-22 ", - " Seven Pillars of Wisdom ", - " 2024-02-22 ", - " 2024-02-21 ", - " 2024-02-22 ", - " 2024-02-22 ", - " 2024-02-21 ", - " 2024-02-20 ", - " 2024-02-20 ", - " 2024-02-19 ", - " 2024-02-19 ", - " The rise and fall of robots.txt ", - " 2024-02-19 ", - " In the Land of the Very Old ", - " The surreal life of a professional bridesmaid - The Hustle " + " 2024-02-26 " ], "Removed Tags from": [ " @Cinematheque ", diff --git a/.obsidian/plugins/obsidian-map-view/main.js b/.obsidian/plugins/obsidian-map-view/main.js index 519d89f9..bd8fe6d6 100644 --- a/.obsidian/plugins/obsidian-map-view/main.js +++ b/.obsidian/plugins/obsidian-map-view/main.js @@ -6,7 +6,7 @@ if you want to view the source visit the plugins github repository 'use strict'; var obsidian = require('obsidian'); -var path = require('path'); +var path$1 = require('path'); var child_process = require('child_process'); var view = require('@codemirror/view'); var state = require('@codemirror/state'); @@ -44,7 +44,7 @@ function _mergeNamespaces(n, m) { return Object.freeze(n); } -var path__namespace = /*#__PURE__*/_interopNamespace(path); +var path__namespace = /*#__PURE__*/_interopNamespace(path$1); /****************************************************************************** Copyright (c) Microsoft Corporation. @@ -71,35 +71,31 @@ function __awaiter(thisArg, _arguments, P, generator) { }); } -const MAP_VIEW_NAME = 'map'; -const MINI_MAP_VIEW_NAME = 'minimap'; -const SEARCH_RESULT_MARKER = { - prefix: 'fas', - icon: 'fa-search', - markerColor: 'blue', -}; -const CURRENT_LOCATION_MARKER = { - prefix: 'fas', - icon: 'fa-location-crosshairs', - markerColor: 'blue', +// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot +var documentAll = typeof document == 'object' && document.all; + +// `IsCallable` abstract operation +// https://tc39.es/ecma262/#sec-iscallable +// eslint-disable-next-line unicorn/no-typeof-undefined -- required for testing +var isCallable = typeof documentAll == 'undefined' && documentAll !== undefined ? function (argument) { + return typeof argument == 'function' || argument === documentAll; +} : function (argument) { + return typeof argument == 'function'; }; -const ROUTING_SOURCE_MARKER = { - prefix: 'fas', - icon: 'fa-flag', - markerColor: 'red', + +var fails = function (exec) { + try { + return !!exec(); + } catch (error) { + return true; + } }; -const MAX_CLUSTER_PREVIEW_ICONS = 4; -const HISTORY_SAVE_ZOOM_DIFF = 2; -const LAT_LIMITS = [-90, 90]; -const LNG_LIMITS = [-180, 180]; -const MAX_QUERY_SUGGESTIONS = 20; -const MAX_EXTERNAL_SEARCH_SUGGESTIONS = 5; -const MAX_MARKER_SUGGESTIONS = 5; -const MAX_ZOOM = 25; -const DEFAULT_MAX_TILE_ZOOM = 19; -const HIGHLIGHT_CLASS_NAME = 'map-view-highlight'; -const DEFAULT_EMBEDDED_HEIGHT = 300; -const MIN_QUICK_EMBED_ZOOM = 8; + +// Detect IE8's incomplete defineProperty implementation +var descriptors = !fails(function () { + // eslint-disable-next-line es/no-object-defineproperty -- required for testing + return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] !== 7; +}); var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; @@ -108,27296 +104,47456 @@ function createCommonjsModule(fn) { return fn(module, module.exports), module.exports; } -/* @preserve - * Leaflet 1.7.1, a JS library for interactive maps. http://leafletjs.com - * (c) 2010-2019 Vladimir Agafonkin, (c) 2010-2011 CloudMade - */ +var check = function (it) { + return it && it.Math === Math && it; +}; -var leafletSrc = createCommonjsModule(function (module, exports) { -(function (global, factory) { - factory(exports) ; -}(commonjsGlobal, (function (exports) { - var version = "1.7.1"; +// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 +var global$1 = + // eslint-disable-next-line es/no-global-this -- safe + check(typeof globalThis == 'object' && globalThis) || + check(typeof window == 'object' && window) || + // eslint-disable-next-line no-restricted-globals -- safe + check(typeof self == 'object' && self) || + check(typeof commonjsGlobal == 'object' && commonjsGlobal) || + check(typeof commonjsGlobal == 'object' && commonjsGlobal) || + // eslint-disable-next-line no-new-func -- fallback + (function () { return this; })() || Function('return this')(); + +var isObject = function (it) { + return typeof it == 'object' ? it !== null : isCallable(it); +}; - /* - * @namespace Util - * - * Various utility functions, used by Leaflet internally. - */ - - // @function extend(dest: Object, src?: Object): Object - // Merges the properties of the `src` object (or multiple objects) into `dest` object and returns the latter. Has an `L.extend` shortcut. - function extend(dest) { - var i, j, len, src; - - for (j = 1, len = arguments.length; j < len; j++) { - src = arguments[j]; - for (i in src) { - dest[i] = src[i]; - } - } - return dest; - } - - // @function create(proto: Object, properties?: Object): Object - // Compatibility polyfill for [Object.create](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/create) - var create = Object.create || (function () { - function F() {} - return function (proto) { - F.prototype = proto; - return new F(); - }; - })(); - - // @function bind(fn: Function, …): Function - // Returns a new function bound to the arguments passed, like [Function.prototype.bind](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). - // Has a `L.bind()` shortcut. - function bind(fn, obj) { - var slice = Array.prototype.slice; - - if (fn.bind) { - return fn.bind.apply(fn, slice.call(arguments, 1)); - } - - var args = slice.call(arguments, 2); - - return function () { - return fn.apply(obj, args.length ? args.concat(slice.call(arguments)) : arguments); - }; - } - - // @property lastId: Number - // Last unique ID used by [`stamp()`](#util-stamp) - var lastId = 0; - - // @function stamp(obj: Object): Number - // Returns the unique ID of an object, assigning it one if it doesn't have it. - function stamp(obj) { - /*eslint-disable */ - obj._leaflet_id = obj._leaflet_id || ++lastId; - return obj._leaflet_id; - /* eslint-enable */ - } - - // @function throttle(fn: Function, time: Number, context: Object): Function - // Returns a function which executes function `fn` with the given scope `context` - // (so that the `this` keyword refers to `context` inside `fn`'s code). The function - // `fn` will be called no more than one time per given amount of `time`. The arguments - // received by the bound function will be any arguments passed when binding the - // function, followed by any arguments passed when invoking the bound function. - // Has an `L.throttle` shortcut. - function throttle(fn, time, context) { - var lock, args, wrapperFn, later; - - later = function () { - // reset lock and call if queued - lock = false; - if (args) { - wrapperFn.apply(context, args); - args = false; - } - }; - - wrapperFn = function () { - if (lock) { - // called too soon, queue to call later - args = arguments; - - } else { - // call and lock until later - fn.apply(context, arguments); - setTimeout(later, time); - lock = true; - } - }; - - return wrapperFn; - } - - // @function wrapNum(num: Number, range: Number[], includeMax?: Boolean): Number - // Returns the number `num` modulo `range` in such a way so it lies within - // `range[0]` and `range[1]`. The returned value will be always smaller than - // `range[1]` unless `includeMax` is set to `true`. - function wrapNum(x, range, includeMax) { - var max = range[1], - min = range[0], - d = max - min; - return x === max && includeMax ? x : ((x - min) % d + d) % d + min; - } - - // @function falseFn(): Function - // Returns a function which always returns `false`. - function falseFn() { return false; } - - // @function formatNum(num: Number, digits?: Number): Number - // Returns the number `num` rounded to `digits` decimals, or to 6 decimals by default. - function formatNum(num, digits) { - var pow = Math.pow(10, (digits === undefined ? 6 : digits)); - return Math.round(num * pow) / pow; - } - - // @function trim(str: String): String - // Compatibility polyfill for [String.prototype.trim](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim) - function trim(str) { - return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, ''); - } - - // @function splitWords(str: String): String[] - // Trims and splits the string on whitespace and returns the array of parts. - function splitWords(str) { - return trim(str).split(/\s+/); - } - - // @function setOptions(obj: Object, options: Object): Object - // Merges the given properties to the `options` of the `obj` object, returning the resulting options. See `Class options`. Has an `L.setOptions` shortcut. - function setOptions(obj, options) { - if (!Object.prototype.hasOwnProperty.call(obj, 'options')) { - obj.options = obj.options ? create(obj.options) : {}; - } - for (var i in options) { - obj.options[i] = options[i]; - } - return obj.options; - } - - // @function getParamString(obj: Object, existingUrl?: String, uppercase?: Boolean): String - // Converts an object into a parameter URL string, e.g. `{a: "foo", b: "bar"}` - // translates to `'?a=foo&b=bar'`. If `existingUrl` is set, the parameters will - // be appended at the end. If `uppercase` is `true`, the parameter names will - // be uppercased (e.g. `'?A=foo&B=bar'`) - function getParamString(obj, existingUrl, uppercase) { - var params = []; - for (var i in obj) { - params.push(encodeURIComponent(uppercase ? i.toUpperCase() : i) + '=' + encodeURIComponent(obj[i])); - } - return ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&'); - } - - var templateRe = /\{ *([\w_-]+) *\}/g; - - // @function template(str: String, data: Object): String - // Simple templating facility, accepts a template string of the form `'Hello {a}, {b}'` - // and a data object like `{a: 'foo', b: 'bar'}`, returns evaluated string - // `('Hello foo, bar')`. You can also specify functions instead of strings for - // data values — they will be evaluated passing `data` as an argument. - function template(str, data) { - return str.replace(templateRe, function (str, key) { - var value = data[key]; - - if (value === undefined) { - throw new Error('No value provided for variable ' + str); - - } else if (typeof value === 'function') { - value = value(data); - } - return value; - }); - } - - // @function isArray(obj): Boolean - // Compatibility polyfill for [Array.isArray](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray) - var isArray = Array.isArray || function (obj) { - return (Object.prototype.toString.call(obj) === '[object Array]'); - }; - - // @function indexOf(array: Array, el: Object): Number - // Compatibility polyfill for [Array.prototype.indexOf](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) - function indexOf(array, el) { - for (var i = 0; i < array.length; i++) { - if (array[i] === el) { return i; } - } - return -1; - } - - // @property emptyImageUrl: String - // Data URI string containing a base64-encoded empty GIF image. - // Used as a hack to free memory from unused images on WebKit-powered - // mobile devices (by setting image `src` to this string). - var emptyImageUrl = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='; - - // inspired by http://paulirish.com/2011/requestanimationframe-for-smart-animating/ - - function getPrefixed(name) { - return window['webkit' + name] || window['moz' + name] || window['ms' + name]; - } - - var lastTime = 0; - - // fallback for IE 7-8 - function timeoutDefer(fn) { - var time = +new Date(), - timeToCall = Math.max(0, 16 - (time - lastTime)); - - lastTime = time + timeToCall; - return window.setTimeout(fn, timeToCall); - } - - var requestFn = window.requestAnimationFrame || getPrefixed('RequestAnimationFrame') || timeoutDefer; - var cancelFn = window.cancelAnimationFrame || getPrefixed('CancelAnimationFrame') || - getPrefixed('CancelRequestAnimationFrame') || function (id) { window.clearTimeout(id); }; - - // @function requestAnimFrame(fn: Function, context?: Object, immediate?: Boolean): Number - // Schedules `fn` to be executed when the browser repaints. `fn` is bound to - // `context` if given. When `immediate` is set, `fn` is called immediately if - // the browser doesn't have native support for - // [`window.requestAnimationFrame`](https://developer.mozilla.org/docs/Web/API/window/requestAnimationFrame), - // otherwise it's delayed. Returns a request ID that can be used to cancel the request. - function requestAnimFrame(fn, context, immediate) { - if (immediate && requestFn === timeoutDefer) { - fn.call(context); - } else { - return requestFn.call(window, bind(fn, context)); - } - } - - // @function cancelAnimFrame(id: Number): undefined - // Cancels a previous `requestAnimFrame`. See also [window.cancelAnimationFrame](https://developer.mozilla.org/docs/Web/API/window/cancelAnimationFrame). - function cancelAnimFrame(id) { - if (id) { - cancelFn.call(window, id); - } +var document$1 = global$1.document; +// typeof document.createElement is 'object' in old IE +var EXISTS$1 = isObject(document$1) && isObject(document$1.createElement); + +var documentCreateElement = function (it) { + return EXISTS$1 ? document$1.createElement(it) : {}; +}; + +// Thanks to IE8 for its funny defineProperty +var ie8DomDefine = !descriptors && !fails(function () { + // eslint-disable-next-line es/no-object-defineproperty -- required for testing + return Object.defineProperty(documentCreateElement('div'), 'a', { + get: function () { return 7; } + }).a !== 7; +}); + +// V8 ~ Chrome 36- +// https://bugs.chromium.org/p/v8/issues/detail?id=3334 +var v8PrototypeDefineBug = descriptors && fails(function () { + // eslint-disable-next-line es/no-object-defineproperty -- required for testing + return Object.defineProperty(function () { /* empty */ }, 'prototype', { + value: 42, + writable: false + }).prototype !== 42; +}); + +var $String$4 = String; +var $TypeError$a = TypeError; + +// `Assert: Type(argument) is Object` +var anObject = function (argument) { + if (isObject(argument)) return argument; + throw new $TypeError$a($String$4(argument) + ' is not an object'); +}; + +var functionBindNative = !fails(function () { + // eslint-disable-next-line es/no-function-prototype-bind -- safe + var test = (function () { /* empty */ }).bind(); + // eslint-disable-next-line no-prototype-builtins -- safe + return typeof test != 'function' || test.hasOwnProperty('prototype'); +}); + +var call$1 = Function.prototype.call; + +var functionCall = functionBindNative ? call$1.bind(call$1) : function () { + return call$1.apply(call$1, arguments); +}; + +var aFunction = function (argument) { + return isCallable(argument) ? argument : undefined; +}; + +var getBuiltIn = function (namespace, method) { + return arguments.length < 2 ? aFunction(global$1[namespace]) : global$1[namespace] && global$1[namespace][method]; +}; + +var FunctionPrototype$1 = Function.prototype; +var call = FunctionPrototype$1.call; +var uncurryThisWithBind = functionBindNative && FunctionPrototype$1.bind.bind(call, call); + +var functionUncurryThis = functionBindNative ? uncurryThisWithBind : function (fn) { + return function () { + return call.apply(fn, arguments); + }; +}; + +var objectIsPrototypeOf = functionUncurryThis({}.isPrototypeOf); + +var engineUserAgent = typeof navigator != 'undefined' && String(navigator.userAgent) || ''; + +var process$1 = global$1.process; +var Deno$1 = global$1.Deno; +var versions = process$1 && process$1.versions || Deno$1 && Deno$1.version; +var v8 = versions && versions.v8; +var match, version; + +if (v8) { + match = v8.split('.'); + // in old Chrome, versions of V8 isn't V8 = Chrome / 10 + // but their correct versions are not interesting for us + version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]); +} + +// BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0` +// so check `userAgent` even if `.v8` exists, but 0 +if (!version && engineUserAgent) { + match = engineUserAgent.match(/Edge\/(\d+)/); + if (!match || match[1] >= 74) { + match = engineUserAgent.match(/Chrome\/(\d+)/); + if (match) version = +match[1]; } +} - var Util = ({ - extend: extend, - create: create, - bind: bind, - lastId: lastId, - stamp: stamp, - throttle: throttle, - wrapNum: wrapNum, - falseFn: falseFn, - formatNum: formatNum, - trim: trim, - splitWords: splitWords, - setOptions: setOptions, - getParamString: getParamString, - template: template, - isArray: isArray, - indexOf: indexOf, - emptyImageUrl: emptyImageUrl, - requestFn: requestFn, - cancelFn: cancelFn, - requestAnimFrame: requestAnimFrame, - cancelAnimFrame: cancelAnimFrame - }); +var engineV8Version = version; - // @class Class - // @aka L.Class - - // @section - // @uninheritable - - // Thanks to John Resig and Dean Edwards for inspiration! - - function Class() {} - - Class.extend = function (props) { - - // @function extend(props: Object): Function - // [Extends the current class](#class-inheritance) given the properties to be included. - // Returns a Javascript function that is a class constructor (to be called with `new`). - var NewClass = function () { - - // call the constructor - if (this.initialize) { - this.initialize.apply(this, arguments); - } - - // call all constructor hooks - this.callInitHooks(); - }; - - var parentProto = NewClass.__super__ = this.prototype; - - var proto = create(parentProto); - proto.constructor = NewClass; - - NewClass.prototype = proto; - - // inherit parent's statics - for (var i in this) { - if (Object.prototype.hasOwnProperty.call(this, i) && i !== 'prototype' && i !== '__super__') { - NewClass[i] = this[i]; - } - } - - // mix static properties into the class - if (props.statics) { - extend(NewClass, props.statics); - delete props.statics; - } - - // mix includes into the prototype - if (props.includes) { - checkDeprecatedMixinEvents(props.includes); - extend.apply(null, [proto].concat(props.includes)); - delete props.includes; - } - - // merge options - if (proto.options) { - props.options = extend(create(proto.options), props.options); - } - - // mix given properties into the prototype - extend(proto, props); - - proto._initHooks = []; - - // add method for calling all hooks - proto.callInitHooks = function () { - - if (this._initHooksCalled) { return; } - - if (parentProto.callInitHooks) { - parentProto.callInitHooks.call(this); - } - - this._initHooksCalled = true; - - for (var i = 0, len = proto._initHooks.length; i < len; i++) { - proto._initHooks[i].call(this); - } - }; - - return NewClass; - }; - - - // @function include(properties: Object): this - // [Includes a mixin](#class-includes) into the current class. - Class.include = function (props) { - extend(this.prototype, props); - return this; - }; - - // @function mergeOptions(options: Object): this - // [Merges `options`](#class-options) into the defaults of the class. - Class.mergeOptions = function (options) { - extend(this.prototype.options, options); - return this; - }; - - // @function addInitHook(fn: Function): this - // Adds a [constructor hook](#class-constructor-hooks) to the class. - Class.addInitHook = function (fn) { // (Function) || (String, args...) - var args = Array.prototype.slice.call(arguments, 1); - - var init = typeof fn === 'function' ? fn : function () { - this[fn].apply(this, args); - }; - - this.prototype._initHooks = this.prototype._initHooks || []; - this.prototype._initHooks.push(init); - return this; - }; - - function checkDeprecatedMixinEvents(includes) { - if (typeof L === 'undefined' || !L || !L.Mixin) { return; } - - includes = isArray(includes) ? includes : [includes]; - - for (var i = 0; i < includes.length; i++) { - if (includes[i] === L.Mixin.Events) { - console.warn('Deprecated include of L.Mixin.Events: ' + - 'this property will be removed in future releases, ' + - 'please inherit from L.Evented instead.', new Error().stack); - } - } +/* eslint-disable es/no-symbol -- required for testing */ + + + + +var $String$3 = global$1.String; + +// eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing +var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails(function () { + var symbol = Symbol('symbol detection'); + // Chrome 38 Symbol has incorrect toString conversion + // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances + // nb: Do not call `String` directly to avoid this being optimized out to `symbol+''` which will, + // of course, fail. + return !$String$3(symbol) || !(Object(symbol) instanceof Symbol) || + // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances + !Symbol.sham && engineV8Version && engineV8Version < 41; +}); + +/* eslint-disable es/no-symbol -- required for testing */ + + +var useSymbolAsUid = symbolConstructorDetection + && !Symbol.sham + && typeof Symbol.iterator == 'symbol'; + +var $Object$4 = Object; + +var isSymbol = useSymbolAsUid ? function (it) { + return typeof it == 'symbol'; +} : function (it) { + var $Symbol = getBuiltIn('Symbol'); + return isCallable($Symbol) && objectIsPrototypeOf($Symbol.prototype, $Object$4(it)); +}; + +var $String$2 = String; + +var tryToString = function (argument) { + try { + return $String$2(argument); + } catch (error) { + return 'Object'; } +}; - /* - * @class Evented - * @aka L.Evented - * @inherits Class - * - * A set of methods shared between event-powered classes (like `Map` and `Marker`). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map to fire `'click'` event). - * - * @example - * - * ```js - * map.on('click', function(e) { - * alert(e.latlng); - * } ); - * ``` - * - * Leaflet deals with event listeners by reference, so if you want to add a listener and then remove it, define it as a function: - * - * ```js - * function onClick(e) { ... } - * - * map.on('click', onClick); - * map.off('click', onClick); - * ``` - */ - - var Events = { - /* @method on(type: String, fn: Function, context?: Object): this - * Adds a listener function (`fn`) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. `'click dblclick'`). - * - * @alternative - * @method on(eventMap: Object): this - * Adds a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}` - */ - on: function (types, fn, context) { - - // types can be a map of types/handlers - if (typeof types === 'object') { - for (var type in types) { - // we don't process space-separated events here for performance; - // it's a hot path since Layer uses the on(obj) syntax - this._on(type, types[type], fn); - } - - } else { - // types can be a string of space-separated words - types = splitWords(types); - - for (var i = 0, len = types.length; i < len; i++) { - this._on(types[i], fn, context); - } - } - - return this; - }, - - /* @method off(type: String, fn?: Function, context?: Object): this - * Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to `on`, you must pass the same context to `off` in order to remove the listener. - * - * @alternative - * @method off(eventMap: Object): this - * Removes a set of type/listener pairs. - * - * @alternative - * @method off: this - * Removes all listeners to all events on the object. This includes implicitly attached events. - */ - off: function (types, fn, context) { - - if (!types) { - // clear all listeners if called without arguments - delete this._events; - - } else if (typeof types === 'object') { - for (var type in types) { - this._off(type, types[type], fn); - } - - } else { - types = splitWords(types); - - for (var i = 0, len = types.length; i < len; i++) { - this._off(types[i], fn, context); - } - } - - return this; - }, - - // attach listener (without syntactic sugar now) - _on: function (type, fn, context) { - this._events = this._events || {}; - - /* get/init listeners for type */ - var typeListeners = this._events[type]; - if (!typeListeners) { - typeListeners = []; - this._events[type] = typeListeners; - } - - if (context === this) { - // Less memory footprint. - context = undefined; - } - var newListener = {fn: fn, ctx: context}, - listeners = typeListeners; - - // check if fn already there - for (var i = 0, len = listeners.length; i < len; i++) { - if (listeners[i].fn === fn && listeners[i].ctx === context) { - return; - } - } - - listeners.push(newListener); - }, - - _off: function (type, fn, context) { - var listeners, - i, - len; - - if (!this._events) { return; } - - listeners = this._events[type]; - - if (!listeners) { - return; - } - - if (!fn) { - // Set all removed listeners to noop so they are not called if remove happens in fire - for (i = 0, len = listeners.length; i < len; i++) { - listeners[i].fn = falseFn; - } - // clear all listeners for a type if function isn't specified - delete this._events[type]; - return; - } - - if (context === this) { - context = undefined; - } - - if (listeners) { - - // find fn and remove it - for (i = 0, len = listeners.length; i < len; i++) { - var l = listeners[i]; - if (l.ctx !== context) { continue; } - if (l.fn === fn) { - - // set the removed listener to noop so that's not called if remove happens in fire - l.fn = falseFn; - - if (this._firingCount) { - /* copy array in case events are being fired */ - this._events[type] = listeners = listeners.slice(); - } - listeners.splice(i, 1); - - return; - } - } - } - }, - - // @method fire(type: String, data?: Object, propagate?: Boolean): this - // Fires an event of the specified type. You can optionally provide an data - // object — the first argument of the listener function will contain its - // properties. The event can optionally be propagated to event parents. - fire: function (type, data, propagate) { - if (!this.listens(type, propagate)) { return this; } - - var event = extend({}, data, { - type: type, - target: this, - sourceTarget: data && data.sourceTarget || this - }); - - if (this._events) { - var listeners = this._events[type]; - - if (listeners) { - this._firingCount = (this._firingCount + 1) || 1; - for (var i = 0, len = listeners.length; i < len; i++) { - var l = listeners[i]; - l.fn.call(l.ctx || this, event); - } - - this._firingCount--; - } - } - - if (propagate) { - // propagate the event to parents (set with addEventParent) - this._propagateEvent(event); - } - - return this; - }, - - // @method listens(type: String): Boolean - // Returns `true` if a particular event type has any listeners attached to it. - listens: function (type, propagate) { - var listeners = this._events && this._events[type]; - if (listeners && listeners.length) { return true; } - - if (propagate) { - // also check parents for listeners if event propagates - for (var id in this._eventParents) { - if (this._eventParents[id].listens(type, propagate)) { return true; } - } - } - return false; - }, - - // @method once(…): this - // Behaves as [`on(…)`](#evented-on), except the listener will only get fired once and then removed. - once: function (types, fn, context) { - - if (typeof types === 'object') { - for (var type in types) { - this.once(type, types[type], fn); - } - return this; - } - - var handler = bind(function () { - this - .off(types, fn, context) - .off(types, handler, context); - }, this); - - // add a listener that's executed once and removed after that - return this - .on(types, fn, context) - .on(types, handler, context); - }, - - // @method addEventParent(obj: Evented): this - // Adds an event parent - an `Evented` that will receive propagated events - addEventParent: function (obj) { - this._eventParents = this._eventParents || {}; - this._eventParents[stamp(obj)] = obj; - return this; - }, - - // @method removeEventParent(obj: Evented): this - // Removes an event parent, so it will stop receiving propagated events - removeEventParent: function (obj) { - if (this._eventParents) { - delete this._eventParents[stamp(obj)]; - } - return this; - }, - - _propagateEvent: function (e) { - for (var id in this._eventParents) { - this._eventParents[id].fire(e.type, extend({ - layer: e.target, - propagatedFrom: e.target - }, e), true); - } - } - }; - - // aliases; we should ditch those eventually - - // @method addEventListener(…): this - // Alias to [`on(…)`](#evented-on) - Events.addEventListener = Events.on; - - // @method removeEventListener(…): this - // Alias to [`off(…)`](#evented-off) - - // @method clearAllEventListeners(…): this - // Alias to [`off()`](#evented-off) - Events.removeEventListener = Events.clearAllEventListeners = Events.off; - - // @method addOneTimeEventListener(…): this - // Alias to [`once(…)`](#evented-once) - Events.addOneTimeEventListener = Events.once; - - // @method fireEvent(…): this - // Alias to [`fire(…)`](#evented-fire) - Events.fireEvent = Events.fire; - - // @method hasEventListeners(…): Boolean - // Alias to [`listens(…)`](#evented-listens) - Events.hasEventListeners = Events.listens; - - var Evented = Class.extend(Events); +var $TypeError$9 = TypeError; - /* - * @class Point - * @aka L.Point - * - * Represents a point with `x` and `y` coordinates in pixels. - * - * @example - * - * ```js - * var point = L.point(200, 300); - * ``` - * - * All Leaflet methods and options that accept `Point` objects also accept them in a simple Array form (unless noted otherwise), so these lines are equivalent: - * - * ```js - * map.panBy([200, 300]); - * map.panBy(L.point(200, 300)); - * ``` - * - * Note that `Point` does not inherit from Leaflet's `Class` object, - * which means new classes can't inherit from it, and new methods - * can't be added to it with the `include` function. - */ - - function Point(x, y, round) { - // @property x: Number; The `x` coordinate of the point - this.x = (round ? Math.round(x) : x); - // @property y: Number; The `y` coordinate of the point - this.y = (round ? Math.round(y) : y); - } - - var trunc = Math.trunc || function (v) { - return v > 0 ? Math.floor(v) : Math.ceil(v); - }; - - Point.prototype = { - - // @method clone(): Point - // Returns a copy of the current point. - clone: function () { - return new Point(this.x, this.y); - }, - - // @method add(otherPoint: Point): Point - // Returns the result of addition of the current and the given points. - add: function (point) { - // non-destructive, returns a new point - return this.clone()._add(toPoint(point)); - }, - - _add: function (point) { - // destructive, used directly for performance in situations where it's safe to modify existing point - this.x += point.x; - this.y += point.y; - return this; - }, - - // @method subtract(otherPoint: Point): Point - // Returns the result of subtraction of the given point from the current. - subtract: function (point) { - return this.clone()._subtract(toPoint(point)); - }, - - _subtract: function (point) { - this.x -= point.x; - this.y -= point.y; - return this; - }, - - // @method divideBy(num: Number): Point - // Returns the result of division of the current point by the given number. - divideBy: function (num) { - return this.clone()._divideBy(num); - }, - - _divideBy: function (num) { - this.x /= num; - this.y /= num; - return this; - }, - - // @method multiplyBy(num: Number): Point - // Returns the result of multiplication of the current point by the given number. - multiplyBy: function (num) { - return this.clone()._multiplyBy(num); - }, - - _multiplyBy: function (num) { - this.x *= num; - this.y *= num; - return this; - }, - - // @method scaleBy(scale: Point): Point - // Multiply each coordinate of the current point by each coordinate of - // `scale`. In linear algebra terms, multiply the point by the - // [scaling matrix](https://en.wikipedia.org/wiki/Scaling_%28geometry%29#Matrix_representation) - // defined by `scale`. - scaleBy: function (point) { - return new Point(this.x * point.x, this.y * point.y); - }, - - // @method unscaleBy(scale: Point): Point - // Inverse of `scaleBy`. Divide each coordinate of the current point by - // each coordinate of `scale`. - unscaleBy: function (point) { - return new Point(this.x / point.x, this.y / point.y); - }, - - // @method round(): Point - // Returns a copy of the current point with rounded coordinates. - round: function () { - return this.clone()._round(); - }, - - _round: function () { - this.x = Math.round(this.x); - this.y = Math.round(this.y); - return this; - }, - - // @method floor(): Point - // Returns a copy of the current point with floored coordinates (rounded down). - floor: function () { - return this.clone()._floor(); - }, - - _floor: function () { - this.x = Math.floor(this.x); - this.y = Math.floor(this.y); - return this; - }, - - // @method ceil(): Point - // Returns a copy of the current point with ceiled coordinates (rounded up). - ceil: function () { - return this.clone()._ceil(); - }, - - _ceil: function () { - this.x = Math.ceil(this.x); - this.y = Math.ceil(this.y); - return this; - }, - - // @method trunc(): Point - // Returns a copy of the current point with truncated coordinates (rounded towards zero). - trunc: function () { - return this.clone()._trunc(); - }, - - _trunc: function () { - this.x = trunc(this.x); - this.y = trunc(this.y); - return this; - }, - - // @method distanceTo(otherPoint: Point): Number - // Returns the cartesian distance between the current and the given points. - distanceTo: function (point) { - point = toPoint(point); - - var x = point.x - this.x, - y = point.y - this.y; - - return Math.sqrt(x * x + y * y); - }, - - // @method equals(otherPoint: Point): Boolean - // Returns `true` if the given point has the same coordinates. - equals: function (point) { - point = toPoint(point); - - return point.x === this.x && - point.y === this.y; - }, - - // @method contains(otherPoint: Point): Boolean - // Returns `true` if both coordinates of the given point are less than the corresponding current point coordinates (in absolute values). - contains: function (point) { - point = toPoint(point); - - return Math.abs(point.x) <= Math.abs(this.x) && - Math.abs(point.y) <= Math.abs(this.y); - }, - - // @method toString(): String - // Returns a string representation of the point for debugging purposes. - toString: function () { - return 'Point(' + - formatNum(this.x) + ', ' + - formatNum(this.y) + ')'; - } - }; - - // @factory L.point(x: Number, y: Number, round?: Boolean) - // Creates a Point object with the given `x` and `y` coordinates. If optional `round` is set to true, rounds the `x` and `y` values. - - // @alternative - // @factory L.point(coords: Number[]) - // Expects an array of the form `[x, y]` instead. - - // @alternative - // @factory L.point(coords: Object) - // Expects a plain object of the form `{x: Number, y: Number}` instead. - function toPoint(x, y, round) { - if (x instanceof Point) { - return x; - } - if (isArray(x)) { - return new Point(x[0], x[1]); - } - if (x === undefined || x === null) { - return x; - } - if (typeof x === 'object' && 'x' in x && 'y' in x) { - return new Point(x.x, x.y); - } - return new Point(x, y, round); +// `Assert: IsCallable(argument) is true` +var aCallable = function (argument) { + if (isCallable(argument)) return argument; + throw new $TypeError$9(tryToString(argument) + ' is not a function'); +}; + +// we can't use just `it == null` since of `document.all` special case +// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot-aec +var isNullOrUndefined = function (it) { + return it === null || it === undefined; +}; + +// `GetMethod` abstract operation +// https://tc39.es/ecma262/#sec-getmethod +var getMethod = function (V, P) { + var func = V[P]; + return isNullOrUndefined(func) ? undefined : aCallable(func); +}; + +var $TypeError$8 = TypeError; + +// `OrdinaryToPrimitive` abstract operation +// https://tc39.es/ecma262/#sec-ordinarytoprimitive +var ordinaryToPrimitive = function (input, pref) { + var fn, val; + if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; + if (isCallable(fn = input.valueOf) && !isObject(val = functionCall(fn, input))) return val; + if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = functionCall(fn, input))) return val; + throw new $TypeError$8("Can't convert object to primitive value"); +}; + +// eslint-disable-next-line es/no-object-defineproperty -- safe +var defineProperty$5 = Object.defineProperty; + +var defineGlobalProperty = function (key, value) { + try { + defineProperty$5(global$1, key, { value: value, configurable: true, writable: true }); + } catch (error) { + global$1[key] = value; + } return value; +}; + +var SHARED = '__core-js_shared__'; +var store$1 = global$1[SHARED] || defineGlobalProperty(SHARED, {}); + +var sharedStore = store$1; + +var shared = createCommonjsModule(function (module) { + + + +(module.exports = function (key, value) { + return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {}); +})('versions', []).push({ + version: '3.35.1', + mode: 'global', + copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)', + license: 'https://github.com/zloirock/core-js/blob/v3.35.1/LICENSE', + source: 'https://github.com/zloirock/core-js' +}); +}); + +var $TypeError$7 = TypeError; + +// `RequireObjectCoercible` abstract operation +// https://tc39.es/ecma262/#sec-requireobjectcoercible +var requireObjectCoercible = function (it) { + if (isNullOrUndefined(it)) throw new $TypeError$7("Can't call method on " + it); + return it; +}; + +var $Object$3 = Object; + +// `ToObject` abstract operation +// https://tc39.es/ecma262/#sec-toobject +var toObject = function (argument) { + return $Object$3(requireObjectCoercible(argument)); +}; + +var hasOwnProperty = functionUncurryThis({}.hasOwnProperty); + +// `HasOwnProperty` abstract operation +// https://tc39.es/ecma262/#sec-hasownproperty +// eslint-disable-next-line es/no-object-hasown -- safe +var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) { + return hasOwnProperty(toObject(it), key); +}; + +var id = 0; +var postfix = Math.random(); +var toString$2 = functionUncurryThis(1.0.toString); + +var uid = function (key) { + return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$2(++id + postfix, 36); +}; + +var Symbol$1 = global$1.Symbol; +var WellKnownSymbolsStore = shared('wks'); +var createWellKnownSymbol = useSymbolAsUid ? Symbol$1['for'] || Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid; + +var wellKnownSymbol = function (name) { + if (!hasOwnProperty_1(WellKnownSymbolsStore, name)) { + WellKnownSymbolsStore[name] = symbolConstructorDetection && hasOwnProperty_1(Symbol$1, name) + ? Symbol$1[name] + : createWellKnownSymbol('Symbol.' + name); + } return WellKnownSymbolsStore[name]; +}; + +var $TypeError$6 = TypeError; +var TO_PRIMITIVE = wellKnownSymbol('toPrimitive'); + +// `ToPrimitive` abstract operation +// https://tc39.es/ecma262/#sec-toprimitive +var toPrimitive = function (input, pref) { + if (!isObject(input) || isSymbol(input)) return input; + var exoticToPrim = getMethod(input, TO_PRIMITIVE); + var result; + if (exoticToPrim) { + if (pref === undefined) pref = 'default'; + result = functionCall(exoticToPrim, input, pref); + if (!isObject(result) || isSymbol(result)) return result; + throw new $TypeError$6("Can't convert object to primitive value"); } + if (pref === undefined) pref = 'number'; + return ordinaryToPrimitive(input, pref); +}; - /* - * @class Bounds - * @aka L.Bounds - * - * Represents a rectangular area in pixel coordinates. - * - * @example - * - * ```js - * var p1 = L.point(10, 10), - * p2 = L.point(40, 60), - * bounds = L.bounds(p1, p2); - * ``` - * - * All Leaflet methods that accept `Bounds` objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this: - * - * ```js - * otherBounds.intersects([[10, 10], [40, 60]]); - * ``` - * - * Note that `Bounds` does not inherit from Leaflet's `Class` object, - * which means new classes can't inherit from it, and new methods - * can't be added to it with the `include` function. - */ - - function Bounds(a, b) { - if (!a) { return; } - - var points = b ? [a, b] : a; - - for (var i = 0, len = points.length; i < len; i++) { - this.extend(points[i]); - } - } - - Bounds.prototype = { - // @method extend(point: Point): this - // Extends the bounds to contain the given point. - extend: function (point) { // (Point) - point = toPoint(point); - - // @property min: Point - // The top left corner of the rectangle. - // @property max: Point - // The bottom right corner of the rectangle. - if (!this.min && !this.max) { - this.min = point.clone(); - this.max = point.clone(); - } else { - this.min.x = Math.min(point.x, this.min.x); - this.max.x = Math.max(point.x, this.max.x); - this.min.y = Math.min(point.y, this.min.y); - this.max.y = Math.max(point.y, this.max.y); - } - return this; - }, - - // @method getCenter(round?: Boolean): Point - // Returns the center point of the bounds. - getCenter: function (round) { - return new Point( - (this.min.x + this.max.x) / 2, - (this.min.y + this.max.y) / 2, round); - }, - - // @method getBottomLeft(): Point - // Returns the bottom-left point of the bounds. - getBottomLeft: function () { - return new Point(this.min.x, this.max.y); - }, - - // @method getTopRight(): Point - // Returns the top-right point of the bounds. - getTopRight: function () { // -> Point - return new Point(this.max.x, this.min.y); - }, - - // @method getTopLeft(): Point - // Returns the top-left point of the bounds (i.e. [`this.min`](#bounds-min)). - getTopLeft: function () { - return this.min; // left, top - }, - - // @method getBottomRight(): Point - // Returns the bottom-right point of the bounds (i.e. [`this.max`](#bounds-max)). - getBottomRight: function () { - return this.max; // right, bottom - }, - - // @method getSize(): Point - // Returns the size of the given bounds - getSize: function () { - return this.max.subtract(this.min); - }, - - // @method contains(otherBounds: Bounds): Boolean - // Returns `true` if the rectangle contains the given one. - // @alternative - // @method contains(point: Point): Boolean - // Returns `true` if the rectangle contains the given point. - contains: function (obj) { - var min, max; - - if (typeof obj[0] === 'number' || obj instanceof Point) { - obj = toPoint(obj); - } else { - obj = toBounds(obj); - } - - if (obj instanceof Bounds) { - min = obj.min; - max = obj.max; - } else { - min = max = obj; - } - - return (min.x >= this.min.x) && - (max.x <= this.max.x) && - (min.y >= this.min.y) && - (max.y <= this.max.y); - }, - - // @method intersects(otherBounds: Bounds): Boolean - // Returns `true` if the rectangle intersects the given bounds. Two bounds - // intersect if they have at least one point in common. - intersects: function (bounds) { // (Bounds) -> Boolean - bounds = toBounds(bounds); - - var min = this.min, - max = this.max, - min2 = bounds.min, - max2 = bounds.max, - xIntersects = (max2.x >= min.x) && (min2.x <= max.x), - yIntersects = (max2.y >= min.y) && (min2.y <= max.y); - - return xIntersects && yIntersects; - }, - - // @method overlaps(otherBounds: Bounds): Boolean - // Returns `true` if the rectangle overlaps the given bounds. Two bounds - // overlap if their intersection is an area. - overlaps: function (bounds) { // (Bounds) -> Boolean - bounds = toBounds(bounds); - - var min = this.min, - max = this.max, - min2 = bounds.min, - max2 = bounds.max, - xOverlaps = (max2.x > min.x) && (min2.x < max.x), - yOverlaps = (max2.y > min.y) && (min2.y < max.y); - - return xOverlaps && yOverlaps; - }, - - isValid: function () { - return !!(this.min && this.max); - } - }; - - - // @factory L.bounds(corner1: Point, corner2: Point) - // Creates a Bounds object from two corners coordinate pairs. - // @alternative - // @factory L.bounds(points: Point[]) - // Creates a Bounds object from the given array of points. - function toBounds(a, b) { - if (!a || a instanceof Bounds) { - return a; - } - return new Bounds(a, b); +// `ToPropertyKey` abstract operation +// https://tc39.es/ecma262/#sec-topropertykey +var toPropertyKey = function (argument) { + var key = toPrimitive(argument, 'string'); + return isSymbol(key) ? key : key + ''; +}; + +var $TypeError$5 = TypeError; +// eslint-disable-next-line es/no-object-defineproperty -- safe +var $defineProperty = Object.defineProperty; +// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe +var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor; +var ENUMERABLE = 'enumerable'; +var CONFIGURABLE$1 = 'configurable'; +var WRITABLE = 'writable'; + +// `Object.defineProperty` method +// https://tc39.es/ecma262/#sec-object.defineproperty +var f$7 = descriptors ? v8PrototypeDefineBug ? function defineProperty(O, P, Attributes) { + anObject(O); + P = toPropertyKey(P); + anObject(Attributes); + if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) { + var current = $getOwnPropertyDescriptor$1(O, P); + if (current && current[WRITABLE]) { + O[P] = Attributes.value; + Attributes = { + configurable: CONFIGURABLE$1 in Attributes ? Attributes[CONFIGURABLE$1] : current[CONFIGURABLE$1], + enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE], + writable: false + }; + } + } return $defineProperty(O, P, Attributes); +} : $defineProperty : function defineProperty(O, P, Attributes) { + anObject(O); + P = toPropertyKey(P); + anObject(Attributes); + if (ie8DomDefine) try { + return $defineProperty(O, P, Attributes); + } catch (error) { /* empty */ } + if ('get' in Attributes || 'set' in Attributes) throw new $TypeError$5('Accessors not supported'); + if ('value' in Attributes) O[P] = Attributes.value; + return O; +}; + +var objectDefineProperty = { + f: f$7 +}; + +var FunctionPrototype = Function.prototype; +// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe +var getDescriptor = descriptors && Object.getOwnPropertyDescriptor; + +var EXISTS = hasOwnProperty_1(FunctionPrototype, 'name'); +// additional protection from minified / mangled / dropped function names +var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something'; +var CONFIGURABLE = EXISTS && (!descriptors || (descriptors && getDescriptor(FunctionPrototype, 'name').configurable)); + +var functionName = { + EXISTS: EXISTS, + PROPER: PROPER, + CONFIGURABLE: CONFIGURABLE +}; + +var functionToString = functionUncurryThis(Function.toString); + +// this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper +if (!isCallable(sharedStore.inspectSource)) { + sharedStore.inspectSource = function (it) { + return functionToString(it); + }; +} + +var inspectSource = sharedStore.inspectSource; + +var WeakMap$2 = global$1.WeakMap; + +var weakMapBasicDetection = isCallable(WeakMap$2) && /native code/.test(String(WeakMap$2)); + +var createPropertyDescriptor = function (bitmap, value) { + return { + enumerable: !(bitmap & 1), + configurable: !(bitmap & 2), + writable: !(bitmap & 4), + value: value + }; +}; + +var createNonEnumerableProperty = descriptors ? function (object, key, value) { + return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value)); +} : function (object, key, value) { + object[key] = value; + return object; +}; + +var keys$1 = shared('keys'); + +var sharedKey = function (key) { + return keys$1[key] || (keys$1[key] = uid(key)); +}; + +var hiddenKeys$1 = {}; + +var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; +var TypeError$2 = global$1.TypeError; +var WeakMap$1 = global$1.WeakMap; +var set, get, has; + +var enforce = function (it) { + return has(it) ? get(it) : set(it, {}); +}; + +var getterFor$1 = function (TYPE) { + return function (it) { + var state; + if (!isObject(it) || (state = get(it)).type !== TYPE) { + throw new TypeError$2('Incompatible receiver, ' + TYPE + ' required'); + } return state; + }; +}; + +if (weakMapBasicDetection || sharedStore.state) { + var store = sharedStore.state || (sharedStore.state = new WeakMap$1()); + /* eslint-disable no-self-assign -- prototype methods protection */ + store.get = store.get; + store.has = store.has; + store.set = store.set; + /* eslint-enable no-self-assign -- prototype methods protection */ + set = function (it, metadata) { + if (store.has(it)) throw new TypeError$2(OBJECT_ALREADY_INITIALIZED); + metadata.facade = it; + store.set(it, metadata); + return metadata; + }; + get = function (it) { + return store.get(it) || {}; + }; + has = function (it) { + return store.has(it); + }; +} else { + var STATE = sharedKey('state'); + hiddenKeys$1[STATE] = true; + set = function (it, metadata) { + if (hasOwnProperty_1(it, STATE)) throw new TypeError$2(OBJECT_ALREADY_INITIALIZED); + metadata.facade = it; + createNonEnumerableProperty(it, STATE, metadata); + return metadata; + }; + get = function (it) { + return hasOwnProperty_1(it, STATE) ? it[STATE] : {}; + }; + has = function (it) { + return hasOwnProperty_1(it, STATE); + }; +} + +var internalState = { + set: set, + get: get, + has: has, + enforce: enforce, + getterFor: getterFor$1 +}; + +var makeBuiltIn_1 = createCommonjsModule(function (module) { + + + + + +var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; + + + +var enforceInternalState = internalState.enforce; +var getInternalState = internalState.get; +var $String = String; +// eslint-disable-next-line es/no-object-defineproperty -- safe +var defineProperty = Object.defineProperty; +var stringSlice = functionUncurryThis(''.slice); +var replace = functionUncurryThis(''.replace); +var join = functionUncurryThis([].join); + +var CONFIGURABLE_LENGTH = descriptors && !fails(function () { + return defineProperty(function () { /* empty */ }, 'length', { value: 8 }).length !== 8; +}); + +var TEMPLATE = String(String).split('String'); + +var makeBuiltIn = module.exports = function (value, name, options) { + if (stringSlice($String(name), 0, 7) === 'Symbol(') { + name = '[' + replace($String(name), /^Symbol\(([^)]*)\).*$/, '$1') + ']'; + } + if (options && options.getter) name = 'get ' + name; + if (options && options.setter) name = 'set ' + name; + if (!hasOwnProperty_1(value, 'name') || (CONFIGURABLE_FUNCTION_NAME && value.name !== name)) { + if (descriptors) defineProperty(value, 'name', { value: name, configurable: true }); + else value.name = name; + } + if (CONFIGURABLE_LENGTH && options && hasOwnProperty_1(options, 'arity') && value.length !== options.arity) { + defineProperty(value, 'length', { value: options.arity }); } + try { + if (options && hasOwnProperty_1(options, 'constructor') && options.constructor) { + if (descriptors) defineProperty(value, 'prototype', { writable: false }); + // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable + } else if (value.prototype) value.prototype = undefined; + } catch (error) { /* empty */ } + var state = enforceInternalState(value); + if (!hasOwnProperty_1(state, 'source')) { + state.source = join(TEMPLATE, typeof name == 'string' ? name : ''); + } return value; +}; - /* - * @class LatLngBounds - * @aka L.LatLngBounds - * - * Represents a rectangular geographical area on a map. - * - * @example - * - * ```js - * var corner1 = L.latLng(40.712, -74.227), - * corner2 = L.latLng(40.774, -74.125), - * bounds = L.latLngBounds(corner1, corner2); - * ``` - * - * All Leaflet methods that accept LatLngBounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this: - * - * ```js - * map.fitBounds([ - * [40.712, -74.227], - * [40.774, -74.125] - * ]); - * ``` - * - * Caution: if the area crosses the antimeridian (often confused with the International Date Line), you must specify corners _outside_ the [-180, 180] degrees longitude range. - * - * Note that `LatLngBounds` does not inherit from Leaflet's `Class` object, - * which means new classes can't inherit from it, and new methods - * can't be added to it with the `include` function. - */ - - function LatLngBounds(corner1, corner2) { // (LatLng, LatLng) or (LatLng[]) - if (!corner1) { return; } - - var latlngs = corner2 ? [corner1, corner2] : corner1; - - for (var i = 0, len = latlngs.length; i < len; i++) { - this.extend(latlngs[i]); - } - } - - LatLngBounds.prototype = { - - // @method extend(latlng: LatLng): this - // Extend the bounds to contain the given point - - // @alternative - // @method extend(otherBounds: LatLngBounds): this - // Extend the bounds to contain the given bounds - extend: function (obj) { - var sw = this._southWest, - ne = this._northEast, - sw2, ne2; - - if (obj instanceof LatLng) { - sw2 = obj; - ne2 = obj; - - } else if (obj instanceof LatLngBounds) { - sw2 = obj._southWest; - ne2 = obj._northEast; - - if (!sw2 || !ne2) { return this; } - - } else { - return obj ? this.extend(toLatLng(obj) || toLatLngBounds(obj)) : this; - } - - if (!sw && !ne) { - this._southWest = new LatLng(sw2.lat, sw2.lng); - this._northEast = new LatLng(ne2.lat, ne2.lng); - } else { - sw.lat = Math.min(sw2.lat, sw.lat); - sw.lng = Math.min(sw2.lng, sw.lng); - ne.lat = Math.max(ne2.lat, ne.lat); - ne.lng = Math.max(ne2.lng, ne.lng); - } - - return this; - }, - - // @method pad(bufferRatio: Number): LatLngBounds - // Returns bounds created by extending or retracting the current bounds by a given ratio in each direction. - // For example, a ratio of 0.5 extends the bounds by 50% in each direction. - // Negative values will retract the bounds. - pad: function (bufferRatio) { - var sw = this._southWest, - ne = this._northEast, - heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio, - widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio; - - return new LatLngBounds( - new LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer), - new LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer)); - }, - - // @method getCenter(): LatLng - // Returns the center point of the bounds. - getCenter: function () { - return new LatLng( - (this._southWest.lat + this._northEast.lat) / 2, - (this._southWest.lng + this._northEast.lng) / 2); - }, - - // @method getSouthWest(): LatLng - // Returns the south-west point of the bounds. - getSouthWest: function () { - return this._southWest; - }, - - // @method getNorthEast(): LatLng - // Returns the north-east point of the bounds. - getNorthEast: function () { - return this._northEast; - }, - - // @method getNorthWest(): LatLng - // Returns the north-west point of the bounds. - getNorthWest: function () { - return new LatLng(this.getNorth(), this.getWest()); - }, - - // @method getSouthEast(): LatLng - // Returns the south-east point of the bounds. - getSouthEast: function () { - return new LatLng(this.getSouth(), this.getEast()); - }, - - // @method getWest(): Number - // Returns the west longitude of the bounds - getWest: function () { - return this._southWest.lng; - }, - - // @method getSouth(): Number - // Returns the south latitude of the bounds - getSouth: function () { - return this._southWest.lat; - }, - - // @method getEast(): Number - // Returns the east longitude of the bounds - getEast: function () { - return this._northEast.lng; - }, - - // @method getNorth(): Number - // Returns the north latitude of the bounds - getNorth: function () { - return this._northEast.lat; - }, - - // @method contains(otherBounds: LatLngBounds): Boolean - // Returns `true` if the rectangle contains the given one. - - // @alternative - // @method contains (latlng: LatLng): Boolean - // Returns `true` if the rectangle contains the given point. - contains: function (obj) { // (LatLngBounds) or (LatLng) -> Boolean - if (typeof obj[0] === 'number' || obj instanceof LatLng || 'lat' in obj) { - obj = toLatLng(obj); - } else { - obj = toLatLngBounds(obj); - } - - var sw = this._southWest, - ne = this._northEast, - sw2, ne2; - - if (obj instanceof LatLngBounds) { - sw2 = obj.getSouthWest(); - ne2 = obj.getNorthEast(); - } else { - sw2 = ne2 = obj; - } - - return (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) && - (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng); - }, - - // @method intersects(otherBounds: LatLngBounds): Boolean - // Returns `true` if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common. - intersects: function (bounds) { - bounds = toLatLngBounds(bounds); - - var sw = this._southWest, - ne = this._northEast, - sw2 = bounds.getSouthWest(), - ne2 = bounds.getNorthEast(), - - latIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat), - lngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng); - - return latIntersects && lngIntersects; - }, - - // @method overlaps(otherBounds: LatLngBounds): Boolean - // Returns `true` if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area. - overlaps: function (bounds) { - bounds = toLatLngBounds(bounds); - - var sw = this._southWest, - ne = this._northEast, - sw2 = bounds.getSouthWest(), - ne2 = bounds.getNorthEast(), - - latOverlaps = (ne2.lat > sw.lat) && (sw2.lat < ne.lat), - lngOverlaps = (ne2.lng > sw.lng) && (sw2.lng < ne.lng); - - return latOverlaps && lngOverlaps; - }, - - // @method toBBoxString(): String - // Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data. - toBBoxString: function () { - return [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(','); - }, - - // @method equals(otherBounds: LatLngBounds, maxMargin?: Number): Boolean - // Returns `true` if the rectangle is equivalent (within a small margin of error) to the given bounds. The margin of error can be overridden by setting `maxMargin` to a small number. - equals: function (bounds, maxMargin) { - if (!bounds) { return false; } - - bounds = toLatLngBounds(bounds); - - return this._southWest.equals(bounds.getSouthWest(), maxMargin) && - this._northEast.equals(bounds.getNorthEast(), maxMargin); - }, - - // @method isValid(): Boolean - // Returns `true` if the bounds are properly initialized. - isValid: function () { - return !!(this._southWest && this._northEast); - } - }; - - // TODO International date line? - - // @factory L.latLngBounds(corner1: LatLng, corner2: LatLng) - // Creates a `LatLngBounds` object by defining two diagonally opposite corners of the rectangle. - - // @alternative - // @factory L.latLngBounds(latlngs: LatLng[]) - // Creates a `LatLngBounds` object defined by the geographical points it contains. Very useful for zooming the map to fit a particular set of locations with [`fitBounds`](#map-fitbounds). - function toLatLngBounds(a, b) { - if (a instanceof LatLngBounds) { - return a; - } - return new LatLngBounds(a, b); +// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative +// eslint-disable-next-line no-extend-native -- required +Function.prototype.toString = makeBuiltIn(function toString() { + return isCallable(this) && getInternalState(this).source || inspectSource(this); +}, 'toString'); +}); + +var defineBuiltIn = function (O, key, value, options) { + if (!options) options = {}; + var simple = options.enumerable; + var name = options.name !== undefined ? options.name : key; + if (isCallable(value)) makeBuiltIn_1(value, name, options); + if (options.global) { + if (simple) O[key] = value; + else defineGlobalProperty(key, value); + } else { + try { + if (!options.unsafe) delete O[key]; + else if (O[key]) simple = true; + } catch (error) { /* empty */ } + if (simple) O[key] = value; + else objectDefineProperty.f(O, key, { + value: value, + enumerable: false, + configurable: !options.nonConfigurable, + writable: !options.nonWritable + }); + } return O; +}; + +var TO_STRING_TAG$2 = wellKnownSymbol('toStringTag'); +var test = {}; + +test[TO_STRING_TAG$2] = 'z'; + +var toStringTagSupport = String(test) === '[object z]'; + +var toString$1 = functionUncurryThis({}.toString); +var stringSlice = functionUncurryThis(''.slice); + +var classofRaw = function (it) { + return stringSlice(toString$1(it), 8, -1); +}; + +var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag'); +var $Object$2 = Object; + +// ES3 wrong here +var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) === 'Arguments'; + +// fallback for IE11 Script Access Denied error +var tryGet = function (it, key) { + try { + return it[key]; + } catch (error) { /* empty */ } +}; + +// getting tag from ES6+ `Object.prototype.toString` +var classof = toStringTagSupport ? classofRaw : function (it) { + var O, tag, result; + return it === undefined ? 'Undefined' : it === null ? 'Null' + // @@toStringTag case + : typeof (tag = tryGet(O = $Object$2(it), TO_STRING_TAG$1)) == 'string' ? tag + // builtinTag case + : CORRECT_ARGUMENTS ? classofRaw(O) + // ES3 arguments fallback + : (result = classofRaw(O)) === 'Object' && isCallable(O.callee) ? 'Arguments' : result; +}; + +var $String$1 = String; + +var toString = function (argument) { + if (classof(argument) === 'Symbol') throw new TypeError('Cannot convert a Symbol value to a string'); + return $String$1(argument); +}; + +var normalizeStringArgument = function (argument, $default) { + return argument === undefined ? arguments.length < 2 ? '' : $default : toString(argument); +}; + +var nativeErrorToString = Error.prototype.toString; + +var INCORRECT_TO_STRING$2 = fails(function () { + if (descriptors) { + // Chrome 32- incorrectly call accessor + // eslint-disable-next-line es/no-object-create, es/no-object-defineproperty -- safe + var object = Object.create(Object.defineProperty({}, 'name', { get: function () { + return this === object; + } })); + if (nativeErrorToString.call(object) !== 'true') return true; } + // FF10- does not properly handle non-strings + return nativeErrorToString.call({ message: 1, name: 2 }) !== '2: 1' + // IE8 does not properly handle defaults + || nativeErrorToString.call({}) !== 'Error'; +}); - /* @class LatLng - * @aka L.LatLng - * - * Represents a geographical point with a certain latitude and longitude. - * - * @example - * - * ``` - * var latlng = L.latLng(50.5, 30.5); - * ``` - * - * All Leaflet methods that accept LatLng objects also accept them in a simple Array form and simple object form (unless noted otherwise), so these lines are equivalent: - * - * ``` - * map.panTo([50, 30]); - * map.panTo({lon: 30, lat: 50}); - * map.panTo({lat: 50, lng: 30}); - * map.panTo(L.latLng(50, 30)); - * ``` - * - * Note that `LatLng` does not inherit from Leaflet's `Class` object, - * which means new classes can't inherit from it, and new methods - * can't be added to it with the `include` function. - */ - - function LatLng(lat, lng, alt) { - if (isNaN(lat) || isNaN(lng)) { - throw new Error('Invalid LatLng object: (' + lat + ', ' + lng + ')'); - } - - // @property lat: Number - // Latitude in degrees - this.lat = +lat; - - // @property lng: Number - // Longitude in degrees - this.lng = +lng; - - // @property alt: Number - // Altitude in meters (optional) - if (alt !== undefined) { - this.alt = +alt; - } - } - - LatLng.prototype = { - // @method equals(otherLatLng: LatLng, maxMargin?: Number): Boolean - // Returns `true` if the given `LatLng` point is at the same position (within a small margin of error). The margin of error can be overridden by setting `maxMargin` to a small number. - equals: function (obj, maxMargin) { - if (!obj) { return false; } - - obj = toLatLng(obj); - - var margin = Math.max( - Math.abs(this.lat - obj.lat), - Math.abs(this.lng - obj.lng)); - - return margin <= (maxMargin === undefined ? 1.0E-9 : maxMargin); - }, - - // @method toString(): String - // Returns a string representation of the point (for debugging purposes). - toString: function (precision) { - return 'LatLng(' + - formatNum(this.lat, precision) + ', ' + - formatNum(this.lng, precision) + ')'; - }, - - // @method distanceTo(otherLatLng: LatLng): Number - // Returns the distance (in meters) to the given `LatLng` calculated using the [Spherical Law of Cosines](https://en.wikipedia.org/wiki/Spherical_law_of_cosines). - distanceTo: function (other) { - return Earth.distance(this, toLatLng(other)); - }, - - // @method wrap(): LatLng - // Returns a new `LatLng` object with the longitude wrapped so it's always between -180 and +180 degrees. - wrap: function () { - return Earth.wrapLatLng(this); - }, - - // @method toBounds(sizeInMeters: Number): LatLngBounds - // Returns a new `LatLngBounds` object in which each boundary is `sizeInMeters/2` meters apart from the `LatLng`. - toBounds: function (sizeInMeters) { - var latAccuracy = 180 * sizeInMeters / 40075017, - lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat); - - return toLatLngBounds( - [this.lat - latAccuracy, this.lng - lngAccuracy], - [this.lat + latAccuracy, this.lng + lngAccuracy]); - }, - - clone: function () { - return new LatLng(this.lat, this.lng, this.alt); - } - }; - - - - // @factory L.latLng(latitude: Number, longitude: Number, altitude?: Number): LatLng - // Creates an object representing a geographical point with the given latitude and longitude (and optionally altitude). - - // @alternative - // @factory L.latLng(coords: Array): LatLng - // Expects an array of the form `[Number, Number]` or `[Number, Number, Number]` instead. - - // @alternative - // @factory L.latLng(coords: Object): LatLng - // Expects an plain object of the form `{lat: Number, lng: Number}` or `{lat: Number, lng: Number, alt: Number}` instead. - - function toLatLng(a, b, c) { - if (a instanceof LatLng) { - return a; - } - if (isArray(a) && typeof a[0] !== 'object') { - if (a.length === 3) { - return new LatLng(a[0], a[1], a[2]); - } - if (a.length === 2) { - return new LatLng(a[0], a[1]); - } - return null; - } - if (a === undefined || a === null) { - return a; - } - if (typeof a === 'object' && 'lat' in a) { - return new LatLng(a.lat, 'lng' in a ? a.lng : a.lon, a.alt); - } - if (b === undefined) { - return null; - } - return new LatLng(a, b, c); - } +var errorToString = INCORRECT_TO_STRING$2 ? function toString() { + var O = anObject(this); + var name = normalizeStringArgument(O.name, 'Error'); + var message = normalizeStringArgument(O.message); + return !name ? message : !message ? name : name + ': ' + message; +} : nativeErrorToString; - /* - * @namespace CRS - * @crs L.CRS.Base - * Object that defines coordinate reference systems for projecting - * geographical points into pixel (screen) coordinates and back (and to - * coordinates in other units for [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services). See - * [spatial reference system](http://en.wikipedia.org/wiki/Coordinate_reference_system). - * - * Leaflet defines the most usual CRSs by default. If you want to use a - * CRS not defined by default, take a look at the - * [Proj4Leaflet](https://github.com/kartena/Proj4Leaflet) plugin. - * - * Note that the CRS instances do not inherit from Leaflet's `Class` object, - * and can't be instantiated. Also, new classes can't inherit from them, - * and methods can't be added to them with the `include` function. - */ - - var CRS = { - // @method latLngToPoint(latlng: LatLng, zoom: Number): Point - // Projects geographical coordinates into pixel coordinates for a given zoom. - latLngToPoint: function (latlng, zoom) { - var projectedPoint = this.projection.project(latlng), - scale = this.scale(zoom); - - return this.transformation._transform(projectedPoint, scale); - }, - - // @method pointToLatLng(point: Point, zoom: Number): LatLng - // The inverse of `latLngToPoint`. Projects pixel coordinates on a given - // zoom into geographical coordinates. - pointToLatLng: function (point, zoom) { - var scale = this.scale(zoom), - untransformedPoint = this.transformation.untransform(point, scale); - - return this.projection.unproject(untransformedPoint); - }, - - // @method project(latlng: LatLng): Point - // Projects geographical coordinates into coordinates in units accepted for - // this CRS (e.g. meters for EPSG:3857, for passing it to WMS services). - project: function (latlng) { - return this.projection.project(latlng); - }, - - // @method unproject(point: Point): LatLng - // Given a projected coordinate returns the corresponding LatLng. - // The inverse of `project`. - unproject: function (point) { - return this.projection.unproject(point); - }, - - // @method scale(zoom: Number): Number - // Returns the scale used when transforming projected coordinates into - // pixel coordinates for a particular zoom. For example, it returns - // `256 * 2^zoom` for Mercator-based CRS. - scale: function (zoom) { - return 256 * Math.pow(2, zoom); - }, - - // @method zoom(scale: Number): Number - // Inverse of `scale()`, returns the zoom level corresponding to a scale - // factor of `scale`. - zoom: function (scale) { - return Math.log(scale / 256) / Math.LN2; - }, - - // @method getProjectedBounds(zoom: Number): Bounds - // Returns the projection's bounds scaled and transformed for the provided `zoom`. - getProjectedBounds: function (zoom) { - if (this.infinite) { return null; } - - var b = this.projection.bounds, - s = this.scale(zoom), - min = this.transformation.transform(b.min, s), - max = this.transformation.transform(b.max, s); - - return new Bounds(min, max); - }, - - // @method distance(latlng1: LatLng, latlng2: LatLng): Number - // Returns the distance between two geographical coordinates. - - // @property code: String - // Standard code name of the CRS passed into WMS services (e.g. `'EPSG:3857'`) - // - // @property wrapLng: Number[] - // An array of two numbers defining whether the longitude (horizontal) coordinate - // axis wraps around a given range and how. Defaults to `[-180, 180]` in most - // geographical CRSs. If `undefined`, the longitude axis does not wrap around. - // - // @property wrapLat: Number[] - // Like `wrapLng`, but for the latitude (vertical) axis. - - // wrapLng: [min, max], - // wrapLat: [min, max], - - // @property infinite: Boolean - // If true, the coordinate space will be unbounded (infinite in both axes) - infinite: false, - - // @method wrapLatLng(latlng: LatLng): LatLng - // Returns a `LatLng` where lat and lng has been wrapped according to the - // CRS's `wrapLat` and `wrapLng` properties, if they are outside the CRS's bounds. - wrapLatLng: function (latlng) { - var lng = this.wrapLng ? wrapNum(latlng.lng, this.wrapLng, true) : latlng.lng, - lat = this.wrapLat ? wrapNum(latlng.lat, this.wrapLat, true) : latlng.lat, - alt = latlng.alt; - - return new LatLng(lat, lng, alt); - }, - - // @method wrapLatLngBounds(bounds: LatLngBounds): LatLngBounds - // Returns a `LatLngBounds` with the same size as the given one, ensuring - // that its center is within the CRS's bounds. - // Only accepts actual `L.LatLngBounds` instances, not arrays. - wrapLatLngBounds: function (bounds) { - var center = bounds.getCenter(), - newCenter = this.wrapLatLng(center), - latShift = center.lat - newCenter.lat, - lngShift = center.lng - newCenter.lng; - - if (latShift === 0 && lngShift === 0) { - return bounds; - } - - var sw = bounds.getSouthWest(), - ne = bounds.getNorthEast(), - newSw = new LatLng(sw.lat - latShift, sw.lng - lngShift), - newNe = new LatLng(ne.lat - latShift, ne.lng - lngShift); - - return new LatLngBounds(newSw, newNe); - } - }; +var ErrorPrototype$1 = Error.prototype; - /* - * @namespace CRS - * @crs L.CRS.Earth - * - * Serves as the base for CRS that are global such that they cover the earth. - * Can only be used as the base for other CRS and cannot be used directly, - * since it does not have a `code`, `projection` or `transformation`. `distance()` returns - * meters. - */ +// `Error.prototype.toString` method fix +// https://tc39.es/ecma262/#sec-error.prototype.tostring +if (ErrorPrototype$1.toString !== errorToString) { + defineBuiltIn(ErrorPrototype$1, 'toString', errorToString); +} - var Earth = extend({}, CRS, { - wrapLng: [-180, 180], +var $Object$1 = Object; +var split = functionUncurryThis(''.split); - // Mean Earth Radius, as recommended for use by - // the International Union of Geodesy and Geophysics, - // see http://rosettacode.org/wiki/Haversine_formula - R: 6371000, +// fallback for non-array-like ES3 and non-enumerable old V8 strings +var indexedObject = fails(function () { + // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 + // eslint-disable-next-line no-prototype-builtins -- safe + return !$Object$1('z').propertyIsEnumerable(0); +}) ? function (it) { + return classofRaw(it) === 'String' ? split(it, '') : $Object$1(it); +} : $Object$1; - // distance between two geographical points using spherical law of cosines approximation - distance: function (latlng1, latlng2) { - var rad = Math.PI / 180, - lat1 = latlng1.lat * rad, - lat2 = latlng2.lat * rad, - sinDLat = Math.sin((latlng2.lat - latlng1.lat) * rad / 2), - sinDLon = Math.sin((latlng2.lng - latlng1.lng) * rad / 2), - a = sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon, - c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); - return this.R * c; - } - }); +// toObject with fallback for non-array-like ES3 strings - /* - * @namespace Projection - * @projection L.Projection.SphericalMercator - * - * Spherical Mercator projection — the most common projection for online maps, - * used by almost all free and commercial tile providers. Assumes that Earth is - * a sphere. Used by the `EPSG:3857` CRS. - */ - - var earthRadius = 6378137; - - var SphericalMercator = { - - R: earthRadius, - MAX_LATITUDE: 85.0511287798, - - project: function (latlng) { - var d = Math.PI / 180, - max = this.MAX_LATITUDE, - lat = Math.max(Math.min(max, latlng.lat), -max), - sin = Math.sin(lat * d); - - return new Point( - this.R * latlng.lng * d, - this.R * Math.log((1 + sin) / (1 - sin)) / 2); - }, - - unproject: function (point) { - var d = 180 / Math.PI; - - return new LatLng( - (2 * Math.atan(Math.exp(point.y / this.R)) - (Math.PI / 2)) * d, - point.x * d / this.R); - }, - - bounds: (function () { - var d = earthRadius * Math.PI; - return new Bounds([-d, -d], [d, d]); - })() + + +var toIndexedObject = function (it) { + return indexedObject(requireObjectCoercible(it)); +}; + +var ceil = Math.ceil; +var floor = Math.floor; + +// `Math.trunc` method +// https://tc39.es/ecma262/#sec-math.trunc +// eslint-disable-next-line es/no-math-trunc -- safe +var mathTrunc = Math.trunc || function trunc(x) { + var n = +x; + return (n > 0 ? floor : ceil)(n); +}; + +// `ToIntegerOrInfinity` abstract operation +// https://tc39.es/ecma262/#sec-tointegerorinfinity +var toIntegerOrInfinity = function (argument) { + var number = +argument; + // eslint-disable-next-line no-self-compare -- NaN check + return number !== number || number === 0 ? 0 : mathTrunc(number); +}; + +var max$1 = Math.max; +var min$2 = Math.min; + +// Helper for a popular repeating case of the spec: +// Let integer be ? ToInteger(index). +// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). +var toAbsoluteIndex = function (index, length) { + var integer = toIntegerOrInfinity(index); + return integer < 0 ? max$1(integer + length, 0) : min$2(integer, length); +}; + +var min$1 = Math.min; + +// `ToLength` abstract operation +// https://tc39.es/ecma262/#sec-tolength +var toLength = function (argument) { + var len = toIntegerOrInfinity(argument); + return len > 0 ? min$1(len, 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 +}; + +// `LengthOfArrayLike` abstract operation +// https://tc39.es/ecma262/#sec-lengthofarraylike +var lengthOfArrayLike = function (obj) { + return toLength(obj.length); +}; + +// `Array.prototype.{ indexOf, includes }` methods implementation +var createMethod = function (IS_INCLUDES) { + return function ($this, el, fromIndex) { + var O = toIndexedObject($this); + var length = lengthOfArrayLike(O); + var index = toAbsoluteIndex(fromIndex, length); + var value; + // Array#includes uses SameValueZero equality algorithm + // eslint-disable-next-line no-self-compare -- NaN check + if (IS_INCLUDES && el !== el) while (length > index) { + value = O[index++]; + // eslint-disable-next-line no-self-compare -- NaN check + if (value !== value) return true; + // Array#indexOf ignores holes, Array#includes - not + } else for (;length > index; index++) { + if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; + } return !IS_INCLUDES && -1; }; +}; - /* - * @class Transformation - * @aka L.Transformation - * - * Represents an affine transformation: a set of coefficients `a`, `b`, `c`, `d` - * for transforming a point of a form `(x, y)` into `(a*x + b, c*y + d)` and doing - * the reverse. Used by Leaflet in its projections code. - * - * @example - * - * ```js - * var transformation = L.transformation(2, 5, -1, 10), - * p = L.point(1, 2), - * p2 = transformation.transform(p), // L.point(7, 8) - * p3 = transformation.untransform(p2); // L.point(1, 2) - * ``` - */ - - - // factory new L.Transformation(a: Number, b: Number, c: Number, d: Number) - // Creates a `Transformation` object with the given coefficients. - function Transformation(a, b, c, d) { - if (isArray(a)) { - // use array properties - this._a = a[0]; - this._b = a[1]; - this._c = a[2]; - this._d = a[3]; - return; - } - this._a = a; - this._b = b; - this._c = c; - this._d = d; - } - - Transformation.prototype = { - // @method transform(point: Point, scale?: Number): Point - // Returns a transformed point, optionally multiplied by the given scale. - // Only accepts actual `L.Point` instances, not arrays. - transform: function (point, scale) { // (Point, Number) -> Point - return this._transform(point.clone(), scale); - }, - - // destructive transform (faster) - _transform: function (point, scale) { - scale = scale || 1; - point.x = scale * (this._a * point.x + this._b); - point.y = scale * (this._c * point.y + this._d); - return point; - }, - - // @method untransform(point: Point, scale?: Number): Point - // Returns the reverse transformation of the given point, optionally divided - // by the given scale. Only accepts actual `L.Point` instances, not arrays. - untransform: function (point, scale) { - scale = scale || 1; - return new Point( - (point.x / scale - this._b) / this._a, - (point.y / scale - this._d) / this._c); - } - }; - - // factory L.transformation(a: Number, b: Number, c: Number, d: Number) - - // @factory L.transformation(a: Number, b: Number, c: Number, d: Number) - // Instantiates a Transformation object with the given coefficients. - - // @alternative - // @factory L.transformation(coefficients: Array): Transformation - // Expects an coefficients array of the form - // `[a: Number, b: Number, c: Number, d: Number]`. - - function toTransformation(a, b, c, d) { - return new Transformation(a, b, c, d); +var arrayIncludes = { + // `Array.prototype.includes` method + // https://tc39.es/ecma262/#sec-array.prototype.includes + includes: createMethod(true), + // `Array.prototype.indexOf` method + // https://tc39.es/ecma262/#sec-array.prototype.indexof + indexOf: createMethod(false) +}; + +var indexOf = arrayIncludes.indexOf; + + +var push$1 = functionUncurryThis([].push); + +var objectKeysInternal = function (object, names) { + var O = toIndexedObject(object); + var i = 0; + var result = []; + var key; + for (key in O) !hasOwnProperty_1(hiddenKeys$1, key) && hasOwnProperty_1(O, key) && push$1(result, key); + // Don't enum bug & hidden keys + while (names.length > i) if (hasOwnProperty_1(O, key = names[i++])) { + ~indexOf(result, key) || push$1(result, key); } + return result; +}; - /* - * @namespace CRS - * @crs L.CRS.EPSG3857 - * - * The most common CRS for online maps, used by almost all free and commercial - * tile providers. Uses Spherical Mercator projection. Set in by default in - * Map's `crs` option. - */ - - var EPSG3857 = extend({}, Earth, { - code: 'EPSG:3857', - projection: SphericalMercator, - - transformation: (function () { - var scale = 0.5 / (Math.PI * SphericalMercator.R); - return toTransformation(scale, 0.5, -scale, 0.5); - }()) - }); - - var EPSG900913 = extend({}, EPSG3857, { - code: 'EPSG:900913' +// IE8- don't enum bug keys +var enumBugKeys = [ + 'constructor', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'toLocaleString', + 'toString', + 'valueOf' +]; + +// `Object.keys` method +// https://tc39.es/ecma262/#sec-object.keys +// eslint-disable-next-line es/no-object-keys -- safe +var objectKeys$1 = Object.keys || function keys(O) { + return objectKeysInternal(O, enumBugKeys); +}; + +// `Object.defineProperties` method +// https://tc39.es/ecma262/#sec-object.defineproperties +// eslint-disable-next-line es/no-object-defineproperties -- safe +var f$6 = descriptors && !v8PrototypeDefineBug ? Object.defineProperties : function defineProperties(O, Properties) { + anObject(O); + var props = toIndexedObject(Properties); + var keys = objectKeys$1(Properties); + var length = keys.length; + var index = 0; + var key; + while (length > index) objectDefineProperty.f(O, key = keys[index++], props[key]); + return O; +}; + +var objectDefineProperties = { + f: f$6 +}; + +var html = getBuiltIn('document', 'documentElement'); + +/* global ActiveXObject -- old IE, WSH */ + + + + + + + + +var GT = '>'; +var LT = '<'; +var PROTOTYPE = 'prototype'; +var SCRIPT = 'script'; +var IE_PROTO$1 = sharedKey('IE_PROTO'); + +var EmptyConstructor = function () { /* empty */ }; + +var scriptTag = function (content) { + return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT; +}; + +// Create object with fake `null` prototype: use ActiveX Object with cleared prototype +var NullProtoObjectViaActiveX = function (activeXDocument) { + activeXDocument.write(scriptTag('')); + activeXDocument.close(); + var temp = activeXDocument.parentWindow.Object; + activeXDocument = null; // avoid memory leak + return temp; +}; + +// Create object with fake `null` prototype: use iframe Object with cleared prototype +var NullProtoObjectViaIFrame = function () { + // Thrash, waste and sodomy: IE GC bug + var iframe = documentCreateElement('iframe'); + var JS = 'java' + SCRIPT + ':'; + var iframeDocument; + iframe.style.display = 'none'; + html.appendChild(iframe); + // https://github.com/zloirock/core-js/issues/475 + iframe.src = String(JS); + iframeDocument = iframe.contentWindow.document; + iframeDocument.open(); + iframeDocument.write(scriptTag('document.F=Object')); + iframeDocument.close(); + return iframeDocument.F; +}; + +// Check for document.domain and active x support +// No need to use active x approach when document.domain is not set +// see https://github.com/es-shims/es5-shim/issues/150 +// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 +// avoid IE GC bug +var activeXDocument; +var NullProtoObject = function () { + try { + activeXDocument = new ActiveXObject('htmlfile'); + } catch (error) { /* ignore */ } + NullProtoObject = typeof document != 'undefined' + ? document.domain && activeXDocument + ? NullProtoObjectViaActiveX(activeXDocument) // old IE + : NullProtoObjectViaIFrame() + : NullProtoObjectViaActiveX(activeXDocument); // WSH + var length = enumBugKeys.length; + while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; + return NullProtoObject(); +}; + +hiddenKeys$1[IE_PROTO$1] = true; + +// `Object.create` method +// https://tc39.es/ecma262/#sec-object.create +// eslint-disable-next-line es/no-object-create -- safe +var objectCreate = Object.create || function create(O, Properties) { + var result; + if (O !== null) { + EmptyConstructor[PROTOTYPE] = anObject(O); + result = new EmptyConstructor(); + EmptyConstructor[PROTOTYPE] = null; + // add "__proto__" for Object.getPrototypeOf polyfill + result[IE_PROTO$1] = O; + } else result = NullProtoObject(); + return Properties === undefined ? result : objectDefineProperties.f(result, Properties); +}; + +var defineProperty$4 = objectDefineProperty.f; + +var UNSCOPABLES = wellKnownSymbol('unscopables'); +var ArrayPrototype$1 = Array.prototype; + +// Array.prototype[@@unscopables] +// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables +if (ArrayPrototype$1[UNSCOPABLES] === undefined) { + defineProperty$4(ArrayPrototype$1, UNSCOPABLES, { + configurable: true, + value: objectCreate(null) }); +} - // @namespace SVG; @section - // There are several static functions which can be called without instantiating L.SVG: +// add a key to Array.prototype[@@unscopables] +var addToUnscopables = function (key) { + ArrayPrototype$1[UNSCOPABLES][key] = true; +}; - // @function create(name: String): SVGElement - // Returns a instance of [SVGElement](https://developer.mozilla.org/docs/Web/API/SVGElement), - // corresponding to the class name passed. For example, using 'line' will return - // an instance of [SVGLineElement](https://developer.mozilla.org/docs/Web/API/SVGLineElement). - function svgCreate(name) { - return document.createElementNS('http://www.w3.org/2000/svg', name); - } +var iterators = {}; - // @function pointsToPath(rings: Point[], closed: Boolean): String - // Generates a SVG path string for multiple rings, with each ring turning - // into "M..L..L.." instructions - function pointsToPath(rings, closed) { - var str = '', - i, j, len, len2, points, p; +var $propertyIsEnumerable = {}.propertyIsEnumerable; +// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe +var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor; - for (i = 0, len = rings.length; i < len; i++) { - points = rings[i]; +// Nashorn ~ JDK8 bug +var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1); - for (j = 0, len2 = points.length; j < len2; j++) { - p = points[j]; - str += (j ? 'L' : 'M') + p.x + ' ' + p.y; - } +// `Object.prototype.propertyIsEnumerable` method implementation +// https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable +var f$5 = NASHORN_BUG ? function propertyIsEnumerable(V) { + var descriptor = getOwnPropertyDescriptor$1(this, V); + return !!descriptor && descriptor.enumerable; +} : $propertyIsEnumerable; - // closes the ring for polygons; "x" is VML syntax - str += closed ? (svg ? 'z' : 'x') : ''; - } +var objectPropertyIsEnumerable = { + f: f$5 +}; - // SVG complains about empty path strings - return str || 'M0 0'; - } +// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe +var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; + +// `Object.getOwnPropertyDescriptor` method +// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor +var f$4 = descriptors ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) { + O = toIndexedObject(O); + P = toPropertyKey(P); + if (ie8DomDefine) try { + return $getOwnPropertyDescriptor(O, P); + } catch (error) { /* empty */ } + if (hasOwnProperty_1(O, P)) return createPropertyDescriptor(!functionCall(objectPropertyIsEnumerable.f, O, P), O[P]); +}; - /* - * @namespace Browser - * @aka L.Browser - * - * A namespace with static properties for browser/feature detection used by Leaflet internally. - * - * @example - * - * ```js - * if (L.Browser.ielt9) { - * alert('Upgrade your browser, dude!'); - * } - * ``` - */ - - var style$1 = document.documentElement.style; - - // @property ie: Boolean; `true` for all Internet Explorer versions (not Edge). - var ie = 'ActiveXObject' in window; - - // @property ielt9: Boolean; `true` for Internet Explorer versions less than 9. - var ielt9 = ie && !document.addEventListener; - - // @property edge: Boolean; `true` for the Edge web browser. - var edge = 'msLaunchUri' in navigator && !('documentMode' in document); - - // @property webkit: Boolean; - // `true` for webkit-based browsers like Chrome and Safari (including mobile versions). - var webkit = userAgentContains('webkit'); - - // @property android: Boolean - // `true` for any browser running on an Android platform. - var android = userAgentContains('android'); - - // @property android23: Boolean; `true` for browsers running on Android 2 or Android 3. - var android23 = userAgentContains('android 2') || userAgentContains('android 3'); - - /* See https://stackoverflow.com/a/17961266 for details on detecting stock Android */ - var webkitVer = parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1], 10); // also matches AppleWebKit - // @property androidStock: Boolean; `true` for the Android stock browser (i.e. not Chrome) - var androidStock = android && userAgentContains('Google') && webkitVer < 537 && !('AudioNode' in window); - - // @property opera: Boolean; `true` for the Opera browser - var opera = !!window.opera; - - // @property chrome: Boolean; `true` for the Chrome browser. - var chrome = !edge && userAgentContains('chrome'); - - // @property gecko: Boolean; `true` for gecko-based browsers like Firefox. - var gecko = userAgentContains('gecko') && !webkit && !opera && !ie; - - // @property safari: Boolean; `true` for the Safari browser. - var safari = !chrome && userAgentContains('safari'); - - var phantom = userAgentContains('phantom'); - - // @property opera12: Boolean - // `true` for the Opera browser supporting CSS transforms (version 12 or later). - var opera12 = 'OTransition' in style$1; - - // @property win: Boolean; `true` when the browser is running in a Windows platform - var win = navigator.platform.indexOf('Win') === 0; - - // @property ie3d: Boolean; `true` for all Internet Explorer versions supporting CSS transforms. - var ie3d = ie && ('transition' in style$1); - - // @property webkit3d: Boolean; `true` for webkit-based browsers supporting CSS transforms. - var webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()) && !android23; - - // @property gecko3d: Boolean; `true` for gecko-based browsers supporting CSS transforms. - var gecko3d = 'MozPerspective' in style$1; - - // @property any3d: Boolean - // `true` for all browsers supporting CSS transforms. - var any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d) && !opera12 && !phantom; - - // @property mobile: Boolean; `true` for all browsers running in a mobile device. - var mobile = typeof orientation !== 'undefined' || userAgentContains('mobile'); - - // @property mobileWebkit: Boolean; `true` for all webkit-based browsers in a mobile device. - var mobileWebkit = mobile && webkit; - - // @property mobileWebkit3d: Boolean - // `true` for all webkit-based browsers in a mobile device supporting CSS transforms. - var mobileWebkit3d = mobile && webkit3d; - - // @property msPointer: Boolean - // `true` for browsers implementing the Microsoft touch events model (notably IE10). - var msPointer = !window.PointerEvent && window.MSPointerEvent; - - // @property pointer: Boolean - // `true` for all browsers supporting [pointer events](https://msdn.microsoft.com/en-us/library/dn433244%28v=vs.85%29.aspx). - var pointer = !!(window.PointerEvent || msPointer); - - // @property touch: Boolean - // `true` for all browsers supporting [touch events](https://developer.mozilla.org/docs/Web/API/Touch_events). - // This does not necessarily mean that the browser is running in a computer with - // a touchscreen, it only means that the browser is capable of understanding - // touch events. - var touch = !window.L_NO_TOUCH && (pointer || 'ontouchstart' in window || - (window.DocumentTouch && document instanceof window.DocumentTouch)); - - // @property mobileOpera: Boolean; `true` for the Opera browser in a mobile device. - var mobileOpera = mobile && opera; - - // @property mobileGecko: Boolean - // `true` for gecko-based browsers running in a mobile device. - var mobileGecko = mobile && gecko; - - // @property retina: Boolean - // `true` for browsers on a high-resolution "retina" screen or on any screen when browser's display zoom is more than 100%. - var retina = (window.devicePixelRatio || (window.screen.deviceXDPI / window.screen.logicalXDPI)) > 1; - - // @property passiveEvents: Boolean - // `true` for browsers that support passive events. - var passiveEvents = (function () { - var supportsPassiveOption = false; - try { - var opts = Object.defineProperty({}, 'passive', { - get: function () { // eslint-disable-line getter-return - supportsPassiveOption = true; - } - }); - window.addEventListener('testPassiveEventSupport', falseFn, opts); - window.removeEventListener('testPassiveEventSupport', falseFn, opts); - } catch (e) { - // Errors can safely be ignored since this is only a browser support test. - } - return supportsPassiveOption; - }()); - - // @property canvas: Boolean - // `true` when the browser supports [``](https://developer.mozilla.org/docs/Web/API/Canvas_API). - var canvas = (function () { - return !!document.createElement('canvas').getContext; - }()); - - // @property svg: Boolean - // `true` when the browser supports [SVG](https://developer.mozilla.org/docs/Web/SVG). - var svg = !!(document.createElementNS && svgCreate('svg').createSVGRect); - - // @property vml: Boolean - // `true` if the browser supports [VML](https://en.wikipedia.org/wiki/Vector_Markup_Language). - var vml = !svg && (function () { - try { - var div = document.createElement('div'); - div.innerHTML = ''; - - var shape = div.firstChild; - shape.style.behavior = 'url(#default#VML)'; - - return shape && (typeof shape.adj === 'object'); - - } catch (e) { - return false; - } - }()); - - - function userAgentContains(str) { - return navigator.userAgent.toLowerCase().indexOf(str) >= 0; - } +var objectGetOwnPropertyDescriptor = { + f: f$4 +}; - var Browser = ({ - ie: ie, - ielt9: ielt9, - edge: edge, - webkit: webkit, - android: android, - android23: android23, - androidStock: androidStock, - opera: opera, - chrome: chrome, - gecko: gecko, - safari: safari, - phantom: phantom, - opera12: opera12, - win: win, - ie3d: ie3d, - webkit3d: webkit3d, - gecko3d: gecko3d, - any3d: any3d, - mobile: mobile, - mobileWebkit: mobileWebkit, - mobileWebkit3d: mobileWebkit3d, - msPointer: msPointer, - pointer: pointer, - touch: touch, - mobileOpera: mobileOpera, - mobileGecko: mobileGecko, - retina: retina, - passiveEvents: passiveEvents, - canvas: canvas, - svg: svg, - vml: vml - }); +var hiddenKeys = enumBugKeys.concat('length', 'prototype'); - /* - * Extends L.DomEvent to provide touch support for Internet Explorer and Windows-based devices. - */ +// `Object.getOwnPropertyNames` method +// https://tc39.es/ecma262/#sec-object.getownpropertynames +// eslint-disable-next-line es/no-object-getownpropertynames -- safe +var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { + return objectKeysInternal(O, hiddenKeys); +}; +var objectGetOwnPropertyNames = { + f: f$3 +}; - var POINTER_DOWN = msPointer ? 'MSPointerDown' : 'pointerdown'; - var POINTER_MOVE = msPointer ? 'MSPointerMove' : 'pointermove'; - var POINTER_UP = msPointer ? 'MSPointerUp' : 'pointerup'; - var POINTER_CANCEL = msPointer ? 'MSPointerCancel' : 'pointercancel'; +// eslint-disable-next-line es/no-object-getownpropertysymbols -- safe +var f$2 = Object.getOwnPropertySymbols; - var _pointers = {}; - var _pointerDocListener = false; +var objectGetOwnPropertySymbols = { + f: f$2 +}; - // Provides a touch events wrapper for (ms)pointer events. - // ref http://www.w3.org/TR/pointerevents/ https://www.w3.org/Bugs/Public/show_bug.cgi?id=22890 +var concat = functionUncurryThis([].concat); - function addPointerListener(obj, type, handler, id) { - if (type === 'touchstart') { - _addPointerStart(obj, handler, id); +// all object keys, includes non-enumerable and symbols +var ownKeys$1 = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) { + var keys = objectGetOwnPropertyNames.f(anObject(it)); + var getOwnPropertySymbols = objectGetOwnPropertySymbols.f; + return getOwnPropertySymbols ? concat(keys, getOwnPropertySymbols(it)) : keys; +}; - } else if (type === 'touchmove') { - _addPointerMove(obj, handler, id); +var copyConstructorProperties = function (target, source, exceptions) { + var keys = ownKeys$1(source); + var defineProperty = objectDefineProperty.f; + var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + if (!hasOwnProperty_1(target, key) && !(exceptions && hasOwnProperty_1(exceptions, key))) { + defineProperty(target, key, getOwnPropertyDescriptor(source, key)); + } + } +}; - } else if (type === 'touchend') { - _addPointerEnd(obj, handler, id); - } +var replacement = /#|\.prototype\./; - return this; - } +var isForced = function (feature, detection) { + var value = data[normalize(feature)]; + return value === POLYFILL ? true + : value === NATIVE ? false + : isCallable(detection) ? fails(detection) + : !!detection; +}; - function removePointerListener(obj, type, id) { - var handler = obj['_leaflet_' + type + id]; +var normalize = isForced.normalize = function (string) { + return String(string).replace(replacement, '.').toLowerCase(); +}; - if (type === 'touchstart') { - obj.removeEventListener(POINTER_DOWN, handler, false); +var data = isForced.data = {}; +var NATIVE = isForced.NATIVE = 'N'; +var POLYFILL = isForced.POLYFILL = 'P'; - } else if (type === 'touchmove') { - obj.removeEventListener(POINTER_MOVE, handler, false); +var isForced_1 = isForced; - } else if (type === 'touchend') { - obj.removeEventListener(POINTER_UP, handler, false); - obj.removeEventListener(POINTER_CANCEL, handler, false); - } +var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; - return this; - } - function _addPointerStart(obj, handler, id) { - var onDown = bind(function (e) { - // IE10 specific: MsTouch needs preventDefault. See #2000 - if (e.MSPOINTER_TYPE_TOUCH && e.pointerType === e.MSPOINTER_TYPE_TOUCH) { - preventDefault(e); - } - _handlePointer(e, handler); - }); - obj['_leaflet_touchstart' + id] = onDown; - obj.addEventListener(POINTER_DOWN, onDown, false); - // need to keep track of what pointers and how many are active to provide e.touches emulation - if (!_pointerDocListener) { - // we listen document as any drags that end by moving the touch off the screen get fired there - document.addEventListener(POINTER_DOWN, _globalPointerDown, true); - document.addEventListener(POINTER_MOVE, _globalPointerMove, true); - document.addEventListener(POINTER_UP, _globalPointerUp, true); - document.addEventListener(POINTER_CANCEL, _globalPointerUp, true); - _pointerDocListener = true; - } +/* + options.target - name of the target object + options.global - target is the global object + options.stat - export as static methods of target + options.proto - export as prototype methods of target + options.real - real prototype method for the `pure` version + options.forced - export even if the native feature is available + options.bind - bind methods to the target, required for the `pure` version + options.wrap - wrap constructors to preventing global pollution, required for the `pure` version + options.unsafe - use the simple assignment of property instead of delete + defineProperty + options.sham - add a flag to not completely full polyfills + options.enumerable - export as enumerable property + options.dontCallGetSet - prevent calling a getter on target + options.name - the .name of the function if it does not match the key +*/ +var _export = function (options, source) { + var TARGET = options.target; + var GLOBAL = options.global; + var STATIC = options.stat; + var FORCED, target, key, targetProperty, sourceProperty, descriptor; + if (GLOBAL) { + target = global$1; + } else if (STATIC) { + target = global$1[TARGET] || defineGlobalProperty(TARGET, {}); + } else { + target = global$1[TARGET] && global$1[TARGET].prototype; } - - function _globalPointerDown(e) { - _pointers[e.pointerId] = e; + if (target) for (key in source) { + sourceProperty = source[key]; + if (options.dontCallGetSet) { + descriptor = getOwnPropertyDescriptor(target, key); + targetProperty = descriptor && descriptor.value; + } else targetProperty = target[key]; + FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); + // contained in target + if (!FORCED && targetProperty !== undefined) { + if (typeof sourceProperty == typeof targetProperty) continue; + copyConstructorProperties(sourceProperty, targetProperty); + } + // add a flag to not completely full polyfills + if (options.sham || (targetProperty && targetProperty.sham)) { + createNonEnumerableProperty(sourceProperty, 'sham', true); + } + defineBuiltIn(target, key, sourceProperty, options); } +}; - function _globalPointerMove(e) { - if (_pointers[e.pointerId]) { - _pointers[e.pointerId] = e; - } +var correctPrototypeGetter = !fails(function () { + function F() { /* empty */ } + F.prototype.constructor = null; + // eslint-disable-next-line es/no-object-getprototypeof -- required for testing + return Object.getPrototypeOf(new F()) !== F.prototype; +}); + +var IE_PROTO = sharedKey('IE_PROTO'); +var $Object = Object; +var ObjectPrototype = $Object.prototype; + +// `Object.getPrototypeOf` method +// https://tc39.es/ecma262/#sec-object.getprototypeof +// eslint-disable-next-line es/no-object-getprototypeof -- safe +var objectGetPrototypeOf = correctPrototypeGetter ? $Object.getPrototypeOf : function (O) { + var object = toObject(O); + if (hasOwnProperty_1(object, IE_PROTO)) return object[IE_PROTO]; + var constructor = object.constructor; + if (isCallable(constructor) && object instanceof constructor) { + return constructor.prototype; + } return object instanceof $Object ? ObjectPrototype : null; +}; + +var ITERATOR$4 = wellKnownSymbol('iterator'); +var BUGGY_SAFARI_ITERATORS$1 = false; + +// `%IteratorPrototype%` object +// https://tc39.es/ecma262/#sec-%iteratorprototype%-object +var IteratorPrototype$2, PrototypeOfArrayIteratorPrototype, arrayIterator; + +/* eslint-disable es/no-array-prototype-keys -- safe */ +if ([].keys) { + arrayIterator = [].keys(); + // Safari 8 has buggy iterators w/o `next` + if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS$1 = true; + else { + PrototypeOfArrayIteratorPrototype = objectGetPrototypeOf(objectGetPrototypeOf(arrayIterator)); + if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype$2 = PrototypeOfArrayIteratorPrototype; } +} - function _globalPointerUp(e) { - delete _pointers[e.pointerId]; +var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype$2) || fails(function () { + var test = {}; + // FF44- legacy iterators case + return IteratorPrototype$2[ITERATOR$4].call(test) !== test; +}); + +if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$2 = {}; + +// `%IteratorPrototype%[@@iterator]()` method +// https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator +if (!isCallable(IteratorPrototype$2[ITERATOR$4])) { + defineBuiltIn(IteratorPrototype$2, ITERATOR$4, function () { + return this; + }); +} + +var iteratorsCore = { + IteratorPrototype: IteratorPrototype$2, + BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS$1 +}; + +var defineProperty$3 = objectDefineProperty.f; + + + +var TO_STRING_TAG = wellKnownSymbol('toStringTag'); + +var setToStringTag = function (target, TAG, STATIC) { + if (target && !STATIC) target = target.prototype; + if (target && !hasOwnProperty_1(target, TO_STRING_TAG)) { + defineProperty$3(target, TO_STRING_TAG, { configurable: true, value: TAG }); } +}; - function _handlePointer(e, handler) { - e.touches = []; - for (var i in _pointers) { - e.touches.push(_pointers[i]); - } - e.changedTouches = [e]; +var IteratorPrototype$1 = iteratorsCore.IteratorPrototype; - handler(e); + + + + +var returnThis$1 = function () { return this; }; + +var iteratorCreateConstructor = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) { + var TO_STRING_TAG = NAME + ' Iterator'; + IteratorConstructor.prototype = objectCreate(IteratorPrototype$1, { next: createPropertyDescriptor(+!ENUMERABLE_NEXT, next) }); + setToStringTag(IteratorConstructor, TO_STRING_TAG, false); + iterators[TO_STRING_TAG] = returnThis$1; + return IteratorConstructor; +}; + +var functionUncurryThisAccessor = function (object, key, method) { + try { + // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe + return functionUncurryThis(aCallable(Object.getOwnPropertyDescriptor(object, key)[method])); + } catch (error) { /* empty */ } +}; + +var isPossiblePrototype = function (argument) { + return isObject(argument) || argument === null; +}; + +var $String = String; +var $TypeError$4 = TypeError; + +var aPossiblePrototype = function (argument) { + if (isPossiblePrototype(argument)) return argument; + throw new $TypeError$4("Can't set " + $String(argument) + ' as a prototype'); +}; + +/* eslint-disable no-proto -- safe */ + + + + +// `Object.setPrototypeOf` method +// https://tc39.es/ecma262/#sec-object.setprototypeof +// Works with __proto__ only. Old v8 can't work with null proto objects. +// eslint-disable-next-line es/no-object-setprototypeof -- safe +var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () { + var CORRECT_SETTER = false; + var test = {}; + var setter; + try { + setter = functionUncurryThisAccessor(Object.prototype, '__proto__', 'set'); + setter(test, []); + CORRECT_SETTER = test instanceof Array; + } catch (error) { /* empty */ } + return function setPrototypeOf(O, proto) { + anObject(O); + aPossiblePrototype(proto); + if (CORRECT_SETTER) setter(O, proto); + else O.__proto__ = proto; + return O; + }; +}() : undefined); + +var PROPER_FUNCTION_NAME = functionName.PROPER; +var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE; +var IteratorPrototype = iteratorsCore.IteratorPrototype; +var BUGGY_SAFARI_ITERATORS = iteratorsCore.BUGGY_SAFARI_ITERATORS; +var ITERATOR$3 = wellKnownSymbol('iterator'); +var KEYS = 'keys'; +var VALUES = 'values'; +var ENTRIES = 'entries'; + +var returnThis = function () { return this; }; + +var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { + iteratorCreateConstructor(IteratorConstructor, NAME, next); + + var getIterationMethod = function (KIND) { + if (KIND === DEFAULT && defaultIterator) return defaultIterator; + if (!BUGGY_SAFARI_ITERATORS && KIND && KIND in IterablePrototype) return IterablePrototype[KIND]; + + switch (KIND) { + case KEYS: return function keys() { return new IteratorConstructor(this, KIND); }; + case VALUES: return function values() { return new IteratorConstructor(this, KIND); }; + case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); }; + } + + return function () { return new IteratorConstructor(this); }; + }; + + var TO_STRING_TAG = NAME + ' Iterator'; + var INCORRECT_VALUES_NAME = false; + var IterablePrototype = Iterable.prototype; + var nativeIterator = IterablePrototype[ITERATOR$3] + || IterablePrototype['@@iterator'] + || DEFAULT && IterablePrototype[DEFAULT]; + var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT); + var anyNativeIterator = NAME === 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; + var CurrentIteratorPrototype, methods, KEY; + + // fix native + if (anyNativeIterator) { + CurrentIteratorPrototype = objectGetPrototypeOf(anyNativeIterator.call(new Iterable())); + if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) { + if (objectGetPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) { + if (objectSetPrototypeOf) { + objectSetPrototypeOf(CurrentIteratorPrototype, IteratorPrototype); + } else if (!isCallable(CurrentIteratorPrototype[ITERATOR$3])) { + defineBuiltIn(CurrentIteratorPrototype, ITERATOR$3, returnThis); + } + } + // Set @@toStringTag to native iterators + setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true); + } } - function _addPointerMove(obj, handler, id) { - var onMove = function (e) { - // don't fire touch moves when mouse isn't down - if ((e.pointerType === (e.MSPOINTER_TYPE_MOUSE || 'mouse')) && e.buttons === 0) { - return; - } + // fix Array.prototype.{ values, @@iterator }.name in V8 / FF + if (PROPER_FUNCTION_NAME && DEFAULT === VALUES && nativeIterator && nativeIterator.name !== VALUES) { + if (CONFIGURABLE_FUNCTION_NAME) { + createNonEnumerableProperty(IterablePrototype, 'name', VALUES); + } else { + INCORRECT_VALUES_NAME = true; + defaultIterator = function values() { return functionCall(nativeIterator, this); }; + } + } - _handlePointer(e, handler); - }; + // export additional methods + if (DEFAULT) { + methods = { + values: getIterationMethod(VALUES), + keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), + entries: getIterationMethod(ENTRIES) + }; + if (FORCED) for (KEY in methods) { + if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { + defineBuiltIn(IterablePrototype, KEY, methods[KEY]); + } + } else _export({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods); + } - obj['_leaflet_touchmove' + id] = onMove; - obj.addEventListener(POINTER_MOVE, onMove, false); + // define iterator + if (IterablePrototype[ITERATOR$3] !== defaultIterator) { + defineBuiltIn(IterablePrototype, ITERATOR$3, defaultIterator, { name: DEFAULT }); } + iterators[NAME] = defaultIterator; - function _addPointerEnd(obj, handler, id) { - var onUp = function (e) { - _handlePointer(e, handler); - }; + return methods; +}; - obj['_leaflet_touchend' + id] = onUp; - obj.addEventListener(POINTER_UP, onUp, false); - obj.addEventListener(POINTER_CANCEL, onUp, false); +// `CreateIterResultObject` abstract operation +// https://tc39.es/ecma262/#sec-createiterresultobject +var createIterResultObject = function (value, done) { + return { value: value, done: done }; +}; + +var defineProperty$2 = objectDefineProperty.f; + + + + + +var ARRAY_ITERATOR = 'Array Iterator'; +var setInternalState$2 = internalState.set; +var getInternalState$1 = internalState.getterFor(ARRAY_ITERATOR); + +// `Array.prototype.entries` method +// https://tc39.es/ecma262/#sec-array.prototype.entries +// `Array.prototype.keys` method +// https://tc39.es/ecma262/#sec-array.prototype.keys +// `Array.prototype.values` method +// https://tc39.es/ecma262/#sec-array.prototype.values +// `Array.prototype[@@iterator]` method +// https://tc39.es/ecma262/#sec-array.prototype-@@iterator +// `CreateArrayIterator` internal method +// https://tc39.es/ecma262/#sec-createarrayiterator +iteratorDefine(Array, 'Array', function (iterated, kind) { + setInternalState$2(this, { + type: ARRAY_ITERATOR, + target: toIndexedObject(iterated), // target + index: 0, // next index + kind: kind // kind + }); +// `%ArrayIteratorPrototype%.next` method +// https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next +}, function () { + var state = getInternalState$1(this); + var target = state.target; + var index = state.index++; + if (!target || index >= target.length) { + state.target = undefined; + return createIterResultObject(undefined, true); + } + switch (state.kind) { + case 'keys': return createIterResultObject(index, false); + case 'values': return createIterResultObject(target[index], false); + } return createIterResultObject([index, target[index]], false); +}, 'values'); + +// argumentsList[@@iterator] is %ArrayProto_values% +// https://tc39.es/ecma262/#sec-createunmappedargumentsobject +// https://tc39.es/ecma262/#sec-createmappedargumentsobject +var values = iterators.Arguments = iterators.Array; + +// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables +addToUnscopables('keys'); +addToUnscopables('values'); +addToUnscopables('entries'); + +// V8 ~ Chrome 45- bug +if (descriptors && values.name !== 'values') try { + defineProperty$2(values, 'name', { value: 'values' }); +} catch (error) { /* empty */ } + +var FAILS_ON_PRIMITIVES$1 = fails(function () { objectKeys$1(1); }); + +// `Object.keys` method +// https://tc39.es/ecma262/#sec-object.keys +_export({ target: 'Object', stat: true, forced: FAILS_ON_PRIMITIVES$1 }, { + keys: function keys(it) { + return objectKeys$1(toObject(it)); } +}); - /* - * Extends the event handling code with double tap support for mobile browsers. - */ - - var _touchstart = msPointer ? 'MSPointerDown' : pointer ? 'pointerdown' : 'touchstart'; - var _touchend = msPointer ? 'MSPointerUp' : pointer ? 'pointerup' : 'touchend'; - var _pre = '_leaflet_'; - - // inspired by Zepto touch code by Thomas Fuchs - function addDoubleTapListener(obj, handler, id) { - var last, touch$$1, - doubleTap = false, - delay = 250; - - function onTouchStart(e) { - - if (pointer) { - if (!e.isPrimary) { return; } - if (e.pointerType === 'mouse') { return; } // mouse fires native dblclick - } else if (e.touches.length > 1) { - return; - } - - var now = Date.now(), - delta = now - (last || now); - - touch$$1 = e.touches ? e.touches[0] : e; - doubleTap = (delta > 0 && delta <= delay); - last = now; - } - - function onTouchEnd(e) { - if (doubleTap && !touch$$1.cancelBubble) { - if (pointer) { - if (e.pointerType === 'mouse') { return; } - // work around .type being readonly with MSPointer* events - var newTouch = {}, - prop, i; - - for (i in touch$$1) { - prop = touch$$1[i]; - newTouch[i] = prop && prop.bind ? prop.bind(touch$$1) : prop; - } - touch$$1 = newTouch; - } - touch$$1.type = 'dblclick'; - touch$$1.button = 0; - handler(touch$$1); - last = null; - } - } - - obj[_pre + _touchstart + id] = onTouchStart; - obj[_pre + _touchend + id] = onTouchEnd; - obj[_pre + 'dblclick' + id] = handler; - - obj.addEventListener(_touchstart, onTouchStart, passiveEvents ? {passive: false} : false); - obj.addEventListener(_touchend, onTouchEnd, passiveEvents ? {passive: false} : false); - - // On some platforms (notably, chrome<55 on win10 + touchscreen + mouse), - // the browser doesn't fire touchend/pointerup events but does fire - // native dblclicks. See #4127. - // Edge 14 also fires native dblclicks, but only for pointerType mouse, see #5180. - obj.addEventListener('dblclick', handler, false); - - return this; - } - - function removeDoubleTapListener(obj, id) { - var touchstart = obj[_pre + _touchstart + id], - touchend = obj[_pre + _touchend + id], - dblclick = obj[_pre + 'dblclick' + id]; - - obj.removeEventListener(_touchstart, touchstart, passiveEvents ? {passive: false} : false); - obj.removeEventListener(_touchend, touchend, passiveEvents ? {passive: false} : false); - obj.removeEventListener('dblclick', dblclick, false); - - return this; +// `Object.prototype.toString` method implementation +// https://tc39.es/ecma262/#sec-object.prototype.tostring +var objectToString = toStringTagSupport ? {}.toString : function toString() { + return '[object ' + classof(this) + ']'; +}; + +// `Object.prototype.toString` method +// https://tc39.es/ecma262/#sec-object.prototype.tostring +if (!toStringTagSupport) { + defineBuiltIn(Object.prototype, 'toString', objectToString, { unsafe: true }); +} + +var arraySlice = functionUncurryThis([].slice); + +/* eslint-disable es/no-object-getownpropertynames -- safe */ + + +var $getOwnPropertyNames = objectGetOwnPropertyNames.f; + + +var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames + ? Object.getOwnPropertyNames(window) : []; + +var getWindowNames = function (it) { + try { + return $getOwnPropertyNames(it); + } catch (error) { + return arraySlice(windowNames); } +}; - /* - * @namespace DomUtil - * - * Utility functions to work with the [DOM](https://developer.mozilla.org/docs/Web/API/Document_Object_Model) - * tree, used by Leaflet internally. - * - * Most functions expecting or returning a `HTMLElement` also work for - * SVG elements. The only difference is that classes refer to CSS classes - * in HTML and SVG classes in SVG. - */ - - - // @property TRANSFORM: String - // Vendor-prefixed transform style name (e.g. `'webkitTransform'` for WebKit). - var TRANSFORM = testProp( - ['transform', 'webkitTransform', 'OTransform', 'MozTransform', 'msTransform']); - - // webkitTransition comes first because some browser versions that drop vendor prefix don't do - // the same for the transitionend event, in particular the Android 4.1 stock browser - - // @property TRANSITION: String - // Vendor-prefixed transition style name. - var TRANSITION = testProp( - ['webkitTransition', 'transition', 'OTransition', 'MozTransition', 'msTransition']); - - // @property TRANSITION_END: String - // Vendor-prefixed transitionend event name. - var TRANSITION_END = - TRANSITION === 'webkitTransition' || TRANSITION === 'OTransition' ? TRANSITION + 'End' : 'transitionend'; - - - // @function get(id: String|HTMLElement): HTMLElement - // Returns an element given its DOM id, or returns the element itself - // if it was passed directly. - function get(id) { - return typeof id === 'string' ? document.getElementById(id) : id; - } - - // @function getStyle(el: HTMLElement, styleAttrib: String): String - // Returns the value for a certain style attribute on an element, - // including computed values or values set through CSS. - function getStyle(el, style) { - var value = el.style[style] || (el.currentStyle && el.currentStyle[style]); - - if ((!value || value === 'auto') && document.defaultView) { - var css = document.defaultView.getComputedStyle(el, null); - value = css ? css[style] : null; - } - return value === 'auto' ? null : value; - } - - // @function create(tagName: String, className?: String, container?: HTMLElement): HTMLElement - // Creates an HTML element with `tagName`, sets its class to `className`, and optionally appends it to `container` element. - function create$1(tagName, className, container) { - var el = document.createElement(tagName); - el.className = className || ''; - - if (container) { - container.appendChild(el); - } - return el; - } - - // @function remove(el: HTMLElement) - // Removes `el` from its parent element - function remove(el) { - var parent = el.parentNode; - if (parent) { - parent.removeChild(el); - } - } - - // @function empty(el: HTMLElement) - // Removes all of `el`'s children elements from `el` - function empty(el) { - while (el.firstChild) { - el.removeChild(el.firstChild); - } - } - - // @function toFront(el: HTMLElement) - // Makes `el` the last child of its parent, so it renders in front of the other children. - function toFront(el) { - var parent = el.parentNode; - if (parent && parent.lastChild !== el) { - parent.appendChild(el); - } - } - - // @function toBack(el: HTMLElement) - // Makes `el` the first child of its parent, so it renders behind the other children. - function toBack(el) { - var parent = el.parentNode; - if (parent && parent.firstChild !== el) { - parent.insertBefore(el, parent.firstChild); - } - } - - // @function hasClass(el: HTMLElement, name: String): Boolean - // Returns `true` if the element's class attribute contains `name`. - function hasClass(el, name) { - if (el.classList !== undefined) { - return el.classList.contains(name); - } - var className = getClass(el); - return className.length > 0 && new RegExp('(^|\\s)' + name + '(\\s|$)').test(className); - } - - // @function addClass(el: HTMLElement, name: String) - // Adds `name` to the element's class attribute. - function addClass(el, name) { - if (el.classList !== undefined) { - var classes = splitWords(name); - for (var i = 0, len = classes.length; i < len; i++) { - el.classList.add(classes[i]); - } - } else if (!hasClass(el, name)) { - var className = getClass(el); - setClass(el, (className ? className + ' ' : '') + name); - } - } - - // @function removeClass(el: HTMLElement, name: String) - // Removes `name` from the element's class attribute. - function removeClass(el, name) { - if (el.classList !== undefined) { - el.classList.remove(name); - } else { - setClass(el, trim((' ' + getClass(el) + ' ').replace(' ' + name + ' ', ' '))); - } - } - - // @function setClass(el: HTMLElement, name: String) - // Sets the element's class. - function setClass(el, name) { - if (el.className.baseVal === undefined) { - el.className = name; - } else { - // in case of SVG element - el.className.baseVal = name; - } - } - - // @function getClass(el: HTMLElement): String - // Returns the element's class. - function getClass(el) { - // Check if the element is an SVGElementInstance and use the correspondingElement instead - // (Required for linked SVG elements in IE11.) - if (el.correspondingElement) { - el = el.correspondingElement; - } - return el.className.baseVal === undefined ? el.className : el.className.baseVal; - } - - // @function setOpacity(el: HTMLElement, opacity: Number) - // Set the opacity of an element (including old IE support). - // `opacity` must be a number from `0` to `1`. - function setOpacity(el, value) { - if ('opacity' in el.style) { - el.style.opacity = value; - } else if ('filter' in el.style) { - _setOpacityIE(el, value); - } - } - - function _setOpacityIE(el, value) { - var filter = false, - filterName = 'DXImageTransform.Microsoft.Alpha'; - - // filters collection throws an error if we try to retrieve a filter that doesn't exist - try { - filter = el.filters.item(filterName); - } catch (e) { - // don't set opacity to 1 if we haven't already set an opacity, - // it isn't needed and breaks transparent pngs. - if (value === 1) { return; } - } - - value = Math.round(value * 100); - - if (filter) { - filter.Enabled = (value !== 100); - filter.Opacity = value; - } else { - el.style.filter += ' progid:' + filterName + '(opacity=' + value + ')'; - } - } - - // @function testProp(props: String[]): String|false - // Goes through the array of style names and returns the first name - // that is a valid style name for an element. If no such name is found, - // it returns false. Useful for vendor-prefixed styles like `transform`. - function testProp(props) { - var style = document.documentElement.style; - - for (var i = 0; i < props.length; i++) { - if (props[i] in style) { - return props[i]; - } - } - return false; - } - - // @function setTransform(el: HTMLElement, offset: Point, scale?: Number) - // Resets the 3D CSS transform of `el` so it is translated by `offset` pixels - // and optionally scaled by `scale`. Does not have an effect if the - // browser doesn't support 3D CSS transforms. - function setTransform(el, offset, scale) { - var pos = offset || new Point(0, 0); - - el.style[TRANSFORM] = - (ie3d ? - 'translate(' + pos.x + 'px,' + pos.y + 'px)' : - 'translate3d(' + pos.x + 'px,' + pos.y + 'px,0)') + - (scale ? ' scale(' + scale + ')' : ''); - } - - // @function setPosition(el: HTMLElement, position: Point) - // Sets the position of `el` to coordinates specified by `position`, - // using CSS translate or top/left positioning depending on the browser - // (used by Leaflet internally to position its layers). - function setPosition(el, point) { - - /*eslint-disable */ - el._leaflet_pos = point; - /* eslint-enable */ - - if (any3d) { - setTransform(el, point); - } else { - el.style.left = point.x + 'px'; - el.style.top = point.y + 'px'; - } - } - - // @function getPosition(el: HTMLElement): Point - // Returns the coordinates of an element previously positioned with setPosition. - function getPosition(el) { - // this method is only used for elements previously positioned using setPosition, - // so it's safe to cache the position for performance - - return el._leaflet_pos || new Point(0, 0); - } - - // @function disableTextSelection() - // Prevents the user from generating `selectstart` DOM events, usually generated - // when the user drags the mouse through a page with text. Used internally - // by Leaflet to override the behaviour of any click-and-drag interaction on - // the map. Affects drag interactions on the whole document. - - // @function enableTextSelection() - // Cancels the effects of a previous [`L.DomUtil.disableTextSelection`](#domutil-disabletextselection). - var disableTextSelection; - var enableTextSelection; - var _userSelect; - if ('onselectstart' in document) { - disableTextSelection = function () { - on(window, 'selectstart', preventDefault); - }; - enableTextSelection = function () { - off(window, 'selectstart', preventDefault); - }; - } else { - var userSelectProperty = testProp( - ['userSelect', 'WebkitUserSelect', 'OUserSelect', 'MozUserSelect', 'msUserSelect']); - - disableTextSelection = function () { - if (userSelectProperty) { - var style = document.documentElement.style; - _userSelect = style[userSelectProperty]; - style[userSelectProperty] = 'none'; - } - }; - enableTextSelection = function () { - if (userSelectProperty) { - document.documentElement.style[userSelectProperty] = _userSelect; - _userSelect = undefined; - } - }; - } - - // @function disableImageDrag() - // As [`L.DomUtil.disableTextSelection`](#domutil-disabletextselection), but - // for `dragstart` DOM events, usually generated when the user drags an image. - function disableImageDrag() { - on(window, 'dragstart', preventDefault); - } - - // @function enableImageDrag() - // Cancels the effects of a previous [`L.DomUtil.disableImageDrag`](#domutil-disabletextselection). - function enableImageDrag() { - off(window, 'dragstart', preventDefault); - } - - var _outlineElement, _outlineStyle; - // @function preventOutline(el: HTMLElement) - // Makes the [outline](https://developer.mozilla.org/docs/Web/CSS/outline) - // of the element `el` invisible. Used internally by Leaflet to prevent - // focusable elements from displaying an outline when the user performs a - // drag interaction on them. - function preventOutline(element) { - while (element.tabIndex === -1) { - element = element.parentNode; - } - if (!element.style) { return; } - restoreOutline(); - _outlineElement = element; - _outlineStyle = element.style.outline; - element.style.outline = 'none'; - on(window, 'keydown', restoreOutline); - } - - // @function restoreOutline() - // Cancels the effects of a previous [`L.DomUtil.preventOutline`](). - function restoreOutline() { - if (!_outlineElement) { return; } - _outlineElement.style.outline = _outlineStyle; - _outlineElement = undefined; - _outlineStyle = undefined; - off(window, 'keydown', restoreOutline); - } - - // @function getSizedParentNode(el: HTMLElement): HTMLElement - // Finds the closest parent node which size (width and height) is not null. - function getSizedParentNode(element) { - do { - element = element.parentNode; - } while ((!element.offsetWidth || !element.offsetHeight) && element !== document.body); - return element; - } - - // @function getScale(el: HTMLElement): Object - // Computes the CSS scale currently applied on the element. - // Returns an object with `x` and `y` members as horizontal and vertical scales respectively, - // and `boundingClientRect` as the result of [`getBoundingClientRect()`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). - function getScale(element) { - var rect = element.getBoundingClientRect(); // Read-only in old browsers. - - return { - x: rect.width / element.offsetWidth || 1, - y: rect.height / element.offsetHeight || 1, - boundingClientRect: rect - }; - } - - var DomUtil = ({ - TRANSFORM: TRANSFORM, - TRANSITION: TRANSITION, - TRANSITION_END: TRANSITION_END, - get: get, - getStyle: getStyle, - create: create$1, - remove: remove, - empty: empty, - toFront: toFront, - toBack: toBack, - hasClass: hasClass, - addClass: addClass, - removeClass: removeClass, - setClass: setClass, - getClass: getClass, - setOpacity: setOpacity, - testProp: testProp, - setTransform: setTransform, - setPosition: setPosition, - getPosition: getPosition, - disableTextSelection: disableTextSelection, - enableTextSelection: enableTextSelection, - disableImageDrag: disableImageDrag, - enableImageDrag: enableImageDrag, - preventOutline: preventOutline, - restoreOutline: restoreOutline, - getSizedParentNode: getSizedParentNode, - getScale: getScale - }); - - /* - * @namespace DomEvent - * Utility functions to work with the [DOM events](https://developer.mozilla.org/docs/Web/API/Event), used by Leaflet internally. - */ - - // Inspired by John Resig, Dean Edwards and YUI addEvent implementations. - - // @function on(el: HTMLElement, types: String, fn: Function, context?: Object): this - // Adds a listener function (`fn`) to a particular DOM event type of the - // element `el`. You can optionally specify the context of the listener - // (object the `this` keyword will point to). You can also pass several - // space-separated types (e.g. `'click dblclick'`). - - // @alternative - // @function on(el: HTMLElement, eventMap: Object, context?: Object): this - // Adds a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}` - function on(obj, types, fn, context) { - - if (typeof types === 'object') { - for (var type in types) { - addOne(obj, type, types[type], fn); - } - } else { - types = splitWords(types); - - for (var i = 0, len = types.length; i < len; i++) { - addOne(obj, types[i], fn, context); - } - } - - return this; - } - - var eventsKey = '_leaflet_events'; - - // @function off(el: HTMLElement, types: String, fn: Function, context?: Object): this - // Removes a previously added listener function. - // Note that if you passed a custom context to on, you must pass the same - // context to `off` in order to remove the listener. - - // @alternative - // @function off(el: HTMLElement, eventMap: Object, context?: Object): this - // Removes a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}` - function off(obj, types, fn, context) { - - if (typeof types === 'object') { - for (var type in types) { - removeOne(obj, type, types[type], fn); - } - } else if (types) { - types = splitWords(types); - - for (var i = 0, len = types.length; i < len; i++) { - removeOne(obj, types[i], fn, context); - } - } else { - for (var j in obj[eventsKey]) { - removeOne(obj, j, obj[eventsKey][j]); - } - delete obj[eventsKey]; - } - - return this; - } - - function browserFiresNativeDblClick() { - // See https://github.com/w3c/pointerevents/issues/171 - if (pointer) { - return !(edge || safari); - } - } - - var mouseSubst = { - mouseenter: 'mouseover', - mouseleave: 'mouseout', - wheel: !('onwheel' in window) && 'mousewheel' - }; - - function addOne(obj, type, fn, context) { - var id = type + stamp(fn) + (context ? '_' + stamp(context) : ''); - - if (obj[eventsKey] && obj[eventsKey][id]) { return this; } - - var handler = function (e) { - return fn.call(context || obj, e || window.event); - }; - - var originalHandler = handler; - - if (pointer && type.indexOf('touch') === 0) { - // Needs DomEvent.Pointer.js - addPointerListener(obj, type, handler, id); - - } else if (touch && (type === 'dblclick') && !browserFiresNativeDblClick()) { - addDoubleTapListener(obj, handler, id); - - } else if ('addEventListener' in obj) { - - if (type === 'touchstart' || type === 'touchmove' || type === 'wheel' || type === 'mousewheel') { - obj.addEventListener(mouseSubst[type] || type, handler, passiveEvents ? {passive: false} : false); - - } else if (type === 'mouseenter' || type === 'mouseleave') { - handler = function (e) { - e = e || window.event; - if (isExternalTarget(obj, e)) { - originalHandler(e); - } - }; - obj.addEventListener(mouseSubst[type], handler, false); - - } else { - obj.addEventListener(type, originalHandler, false); - } - - } else if ('attachEvent' in obj) { - obj.attachEvent('on' + type, handler); - } - - obj[eventsKey] = obj[eventsKey] || {}; - obj[eventsKey][id] = handler; - } - - function removeOne(obj, type, fn, context) { - - var id = type + stamp(fn) + (context ? '_' + stamp(context) : ''), - handler = obj[eventsKey] && obj[eventsKey][id]; - - if (!handler) { return this; } - - if (pointer && type.indexOf('touch') === 0) { - removePointerListener(obj, type, id); - - } else if (touch && (type === 'dblclick') && !browserFiresNativeDblClick()) { - removeDoubleTapListener(obj, id); - - } else if ('removeEventListener' in obj) { - - obj.removeEventListener(mouseSubst[type] || type, handler, false); - - } else if ('detachEvent' in obj) { - obj.detachEvent('on' + type, handler); - } - - obj[eventsKey][id] = null; - } - - // @function stopPropagation(ev: DOMEvent): this - // Stop the given event from propagation to parent elements. Used inside the listener functions: - // ```js - // L.DomEvent.on(div, 'click', function (ev) { - // L.DomEvent.stopPropagation(ev); - // }); - // ``` - function stopPropagation(e) { - - if (e.stopPropagation) { - e.stopPropagation(); - } else if (e.originalEvent) { // In case of Leaflet event. - e.originalEvent._stopped = true; - } else { - e.cancelBubble = true; - } - skipped(e); - - return this; - } - - // @function disableScrollPropagation(el: HTMLElement): this - // Adds `stopPropagation` to the element's `'wheel'` events (plus browser variants). - function disableScrollPropagation(el) { - addOne(el, 'wheel', stopPropagation); - return this; - } - - // @function disableClickPropagation(el: HTMLElement): this - // Adds `stopPropagation` to the element's `'click'`, `'doubleclick'`, - // `'mousedown'` and `'touchstart'` events (plus browser variants). - function disableClickPropagation(el) { - on(el, 'mousedown touchstart dblclick', stopPropagation); - addOne(el, 'click', fakeStop); - return this; - } - - // @function preventDefault(ev: DOMEvent): this - // Prevents the default action of the DOM Event `ev` from happening (such as - // following a link in the href of the a element, or doing a POST request - // with page reload when a `
` is submitted). - // Use it inside listener functions. - function preventDefault(e) { - if (e.preventDefault) { - e.preventDefault(); - } else { - e.returnValue = false; - } - return this; - } - - // @function stop(ev: DOMEvent): this - // Does `stopPropagation` and `preventDefault` at the same time. - function stop(e) { - preventDefault(e); - stopPropagation(e); - return this; - } - - // @function getMousePosition(ev: DOMEvent, container?: HTMLElement): Point - // Gets normalized mouse position from a DOM event relative to the - // `container` (border excluded) or to the whole page if not specified. - function getMousePosition(e, container) { - if (!container) { - return new Point(e.clientX, e.clientY); - } - - var scale = getScale(container), - offset = scale.boundingClientRect; // left and top values are in page scale (like the event clientX/Y) - - return new Point( - // offset.left/top values are in page scale (like clientX/Y), - // whereas clientLeft/Top (border width) values are the original values (before CSS scale applies). - (e.clientX - offset.left) / scale.x - container.clientLeft, - (e.clientY - offset.top) / scale.y - container.clientTop - ); - } - - // Chrome on Win scrolls double the pixels as in other platforms (see #4538), - // and Firefox scrolls device pixels, not CSS pixels - var wheelPxFactor = - (win && chrome) ? 2 * window.devicePixelRatio : - gecko ? window.devicePixelRatio : 1; - - // @function getWheelDelta(ev: DOMEvent): Number - // Gets normalized wheel delta from a wheel DOM event, in vertical - // pixels scrolled (negative if scrolling down). - // Events from pointing devices without precise scrolling are mapped to - // a best guess of 60 pixels. - function getWheelDelta(e) { - return (edge) ? e.wheelDeltaY / 2 : // Don't trust window-geometry-based delta - (e.deltaY && e.deltaMode === 0) ? -e.deltaY / wheelPxFactor : // Pixels - (e.deltaY && e.deltaMode === 1) ? -e.deltaY * 20 : // Lines - (e.deltaY && e.deltaMode === 2) ? -e.deltaY * 60 : // Pages - (e.deltaX || e.deltaZ) ? 0 : // Skip horizontal/depth wheel events - e.wheelDelta ? (e.wheelDeltaY || e.wheelDelta) / 2 : // Legacy IE pixels - (e.detail && Math.abs(e.detail) < 32765) ? -e.detail * 20 : // Legacy Moz lines - e.detail ? e.detail / -32765 * 60 : // Legacy Moz pages - 0; - } - - var skipEvents = {}; - - function fakeStop(e) { - // fakes stopPropagation by setting a special event flag, checked/reset with skipped(e) - skipEvents[e.type] = true; - } - - function skipped(e) { - var events = skipEvents[e.type]; - // reset when checking, as it's only used in map container and propagates outside of the map - skipEvents[e.type] = false; - return events; - } - - // check if element really left/entered the event target (for mouseenter/mouseleave) - function isExternalTarget(el, e) { - - var related = e.relatedTarget; - - if (!related) { return true; } - - try { - while (related && (related !== el)) { - related = related.parentNode; - } - } catch (err) { - return false; - } - return (related !== el); - } - - var DomEvent = ({ - on: on, - off: off, - stopPropagation: stopPropagation, - disableScrollPropagation: disableScrollPropagation, - disableClickPropagation: disableClickPropagation, - preventDefault: preventDefault, - stop: stop, - getMousePosition: getMousePosition, - getWheelDelta: getWheelDelta, - fakeStop: fakeStop, - skipped: skipped, - isExternalTarget: isExternalTarget, - addListener: on, - removeListener: off - }); - - /* - * @class PosAnimation - * @aka L.PosAnimation - * @inherits Evented - * Used internally for panning animations, utilizing CSS3 Transitions for modern browsers and a timer fallback for IE6-9. - * - * @example - * ```js - * var fx = new L.PosAnimation(); - * fx.run(el, [300, 500], 0.5); - * ``` - * - * @constructor L.PosAnimation() - * Creates a `PosAnimation` object. - * - */ - - var PosAnimation = Evented.extend({ - - // @method run(el: HTMLElement, newPos: Point, duration?: Number, easeLinearity?: Number) - // Run an animation of a given element to a new position, optionally setting - // duration in seconds (`0.25` by default) and easing linearity factor (3rd - // argument of the [cubic bezier curve](http://cubic-bezier.com/#0,0,.5,1), - // `0.5` by default). - run: function (el, newPos, duration, easeLinearity) { - this.stop(); - - this._el = el; - this._inProgress = true; - this._duration = duration || 0.25; - this._easeOutPower = 1 / Math.max(easeLinearity || 0.5, 0.2); - - this._startPos = getPosition(el); - this._offset = newPos.subtract(this._startPos); - this._startTime = +new Date(); - - // @event start: Event - // Fired when the animation starts - this.fire('start'); - - this._animate(); - }, - - // @method stop() - // Stops the animation (if currently running). - stop: function () { - if (!this._inProgress) { return; } - - this._step(true); - this._complete(); - }, - - _animate: function () { - // animation loop - this._animId = requestAnimFrame(this._animate, this); - this._step(); - }, - - _step: function (round) { - var elapsed = (+new Date()) - this._startTime, - duration = this._duration * 1000; - - if (elapsed < duration) { - this._runFrame(this._easeOut(elapsed / duration), round); - } else { - this._runFrame(1); - this._complete(); - } - }, - - _runFrame: function (progress, round) { - var pos = this._startPos.add(this._offset.multiplyBy(progress)); - if (round) { - pos._round(); - } - setPosition(this._el, pos); - - // @event step: Event - // Fired continuously during the animation. - this.fire('step'); - }, - - _complete: function () { - cancelAnimFrame(this._animId); - - this._inProgress = false; - // @event end: Event - // Fired when the animation ends. - this.fire('end'); - }, - - _easeOut: function (t) { - return 1 - Math.pow(1 - t, this._easeOutPower); - } - }); - - /* - * @class Map - * @aka L.Map - * @inherits Evented - * - * The central class of the API — it is used to create a map on a page and manipulate it. - * - * @example - * - * ```js - * // initialize the map on the "map" div with a given center and zoom - * var map = L.map('map', { - * center: [51.505, -0.09], - * zoom: 13 - * }); - * ``` - * - */ - - var Map = Evented.extend({ - - options: { - // @section Map State Options - // @option crs: CRS = L.CRS.EPSG3857 - // The [Coordinate Reference System](#crs) to use. Don't change this if you're not - // sure what it means. - crs: EPSG3857, - - // @option center: LatLng = undefined - // Initial geographic center of the map - center: undefined, - - // @option zoom: Number = undefined - // Initial map zoom level - zoom: undefined, - - // @option minZoom: Number = * - // Minimum zoom level of the map. - // If not specified and at least one `GridLayer` or `TileLayer` is in the map, - // the lowest of their `minZoom` options will be used instead. - minZoom: undefined, - - // @option maxZoom: Number = * - // Maximum zoom level of the map. - // If not specified and at least one `GridLayer` or `TileLayer` is in the map, - // the highest of their `maxZoom` options will be used instead. - maxZoom: undefined, - - // @option layers: Layer[] = [] - // Array of layers that will be added to the map initially - layers: [], - - // @option maxBounds: LatLngBounds = null - // When this option is set, the map restricts the view to the given - // geographical bounds, bouncing the user back if the user tries to pan - // outside the view. To set the restriction dynamically, use - // [`setMaxBounds`](#map-setmaxbounds) method. - maxBounds: undefined, - - // @option renderer: Renderer = * - // The default method for drawing vector layers on the map. `L.SVG` - // or `L.Canvas` by default depending on browser support. - renderer: undefined, - - - // @section Animation Options - // @option zoomAnimation: Boolean = true - // Whether the map zoom animation is enabled. By default it's enabled - // in all browsers that support CSS3 Transitions except Android. - zoomAnimation: true, - - // @option zoomAnimationThreshold: Number = 4 - // Won't animate zoom if the zoom difference exceeds this value. - zoomAnimationThreshold: 4, - - // @option fadeAnimation: Boolean = true - // Whether the tile fade animation is enabled. By default it's enabled - // in all browsers that support CSS3 Transitions except Android. - fadeAnimation: true, - - // @option markerZoomAnimation: Boolean = true - // Whether markers animate their zoom with the zoom animation, if disabled - // they will disappear for the length of the animation. By default it's - // enabled in all browsers that support CSS3 Transitions except Android. - markerZoomAnimation: true, - - // @option transform3DLimit: Number = 2^23 - // Defines the maximum size of a CSS translation transform. The default - // value should not be changed unless a web browser positions layers in - // the wrong place after doing a large `panBy`. - transform3DLimit: 8388608, // Precision limit of a 32-bit float - - // @section Interaction Options - // @option zoomSnap: Number = 1 - // Forces the map's zoom level to always be a multiple of this, particularly - // right after a [`fitBounds()`](#map-fitbounds) or a pinch-zoom. - // By default, the zoom level snaps to the nearest integer; lower values - // (e.g. `0.5` or `0.1`) allow for greater granularity. A value of `0` - // means the zoom level will not be snapped after `fitBounds` or a pinch-zoom. - zoomSnap: 1, - - // @option zoomDelta: Number = 1 - // Controls how much the map's zoom level will change after a - // [`zoomIn()`](#map-zoomin), [`zoomOut()`](#map-zoomout), pressing `+` - // or `-` on the keyboard, or using the [zoom controls](#control-zoom). - // Values smaller than `1` (e.g. `0.5`) allow for greater granularity. - zoomDelta: 1, - - // @option trackResize: Boolean = true - // Whether the map automatically handles browser window resize to update itself. - trackResize: true - }, - - initialize: function (id, options) { // (HTMLElement or String, Object) - options = setOptions(this, options); - - // Make sure to assign internal flags at the beginning, - // to avoid inconsistent state in some edge cases. - this._handlers = []; - this._layers = {}; - this._zoomBoundLayers = {}; - this._sizeChanged = true; - - this._initContainer(id); - this._initLayout(); - - // hack for https://github.com/Leaflet/Leaflet/issues/1980 - this._onResize = bind(this._onResize, this); - - this._initEvents(); - - if (options.maxBounds) { - this.setMaxBounds(options.maxBounds); - } - - if (options.zoom !== undefined) { - this._zoom = this._limitZoom(options.zoom); - } - - if (options.center && options.zoom !== undefined) { - this.setView(toLatLng(options.center), options.zoom, {reset: true}); - } - - this.callInitHooks(); - - // don't animate on browsers without hardware-accelerated transitions or old Android/Opera - this._zoomAnimated = TRANSITION && any3d && !mobileOpera && - this.options.zoomAnimation; - - // zoom transitions run with the same duration for all layers, so if one of transitionend events - // happens after starting zoom animation (propagating to the map pane), we know that it ended globally - if (this._zoomAnimated) { - this._createAnimProxy(); - on(this._proxy, TRANSITION_END, this._catchTransitionEnd, this); - } - - this._addLayers(this.options.layers); - }, - - - // @section Methods for modifying map state - - // @method setView(center: LatLng, zoom: Number, options?: Zoom/pan options): this - // Sets the view of the map (geographical center and zoom) with the given - // animation options. - setView: function (center, zoom, options) { - - zoom = zoom === undefined ? this._zoom : this._limitZoom(zoom); - center = this._limitCenter(toLatLng(center), zoom, this.options.maxBounds); - options = options || {}; - - this._stop(); - - if (this._loaded && !options.reset && options !== true) { - - if (options.animate !== undefined) { - options.zoom = extend({animate: options.animate}, options.zoom); - options.pan = extend({animate: options.animate, duration: options.duration}, options.pan); - } - - // try animating pan or zoom - var moved = (this._zoom !== zoom) ? - this._tryAnimatedZoom && this._tryAnimatedZoom(center, zoom, options.zoom) : - this._tryAnimatedPan(center, options.pan); - - if (moved) { - // prevent resize handler call, the view will refresh after animation anyway - clearTimeout(this._sizeTimer); - return this; - } - } - - // animation didn't start, just reset the map view - this._resetView(center, zoom); - - return this; - }, - - // @method setZoom(zoom: Number, options?: Zoom/pan options): this - // Sets the zoom of the map. - setZoom: function (zoom, options) { - if (!this._loaded) { - this._zoom = zoom; - return this; - } - return this.setView(this.getCenter(), zoom, {zoom: options}); - }, - - // @method zoomIn(delta?: Number, options?: Zoom options): this - // Increases the zoom of the map by `delta` ([`zoomDelta`](#map-zoomdelta) by default). - zoomIn: function (delta, options) { - delta = delta || (any3d ? this.options.zoomDelta : 1); - return this.setZoom(this._zoom + delta, options); - }, - - // @method zoomOut(delta?: Number, options?: Zoom options): this - // Decreases the zoom of the map by `delta` ([`zoomDelta`](#map-zoomdelta) by default). - zoomOut: function (delta, options) { - delta = delta || (any3d ? this.options.zoomDelta : 1); - return this.setZoom(this._zoom - delta, options); - }, - - // @method setZoomAround(latlng: LatLng, zoom: Number, options: Zoom options): this - // Zooms the map while keeping a specified geographical point on the map - // stationary (e.g. used internally for scroll zoom and double-click zoom). - // @alternative - // @method setZoomAround(offset: Point, zoom: Number, options: Zoom options): this - // Zooms the map while keeping a specified pixel on the map (relative to the top-left corner) stationary. - setZoomAround: function (latlng, zoom, options) { - var scale = this.getZoomScale(zoom), - viewHalf = this.getSize().divideBy(2), - containerPoint = latlng instanceof Point ? latlng : this.latLngToContainerPoint(latlng), - - centerOffset = containerPoint.subtract(viewHalf).multiplyBy(1 - 1 / scale), - newCenter = this.containerPointToLatLng(viewHalf.add(centerOffset)); - - return this.setView(newCenter, zoom, {zoom: options}); - }, - - _getBoundsCenterZoom: function (bounds, options) { - - options = options || {}; - bounds = bounds.getBounds ? bounds.getBounds() : toLatLngBounds(bounds); - - var paddingTL = toPoint(options.paddingTopLeft || options.padding || [0, 0]), - paddingBR = toPoint(options.paddingBottomRight || options.padding || [0, 0]), - - zoom = this.getBoundsZoom(bounds, false, paddingTL.add(paddingBR)); - - zoom = (typeof options.maxZoom === 'number') ? Math.min(options.maxZoom, zoom) : zoom; - - if (zoom === Infinity) { - return { - center: bounds.getCenter(), - zoom: zoom - }; - } - - var paddingOffset = paddingBR.subtract(paddingTL).divideBy(2), - - swPoint = this.project(bounds.getSouthWest(), zoom), - nePoint = this.project(bounds.getNorthEast(), zoom), - center = this.unproject(swPoint.add(nePoint).divideBy(2).add(paddingOffset), zoom); - - return { - center: center, - zoom: zoom - }; - }, - - // @method fitBounds(bounds: LatLngBounds, options?: fitBounds options): this - // Sets a map view that contains the given geographical bounds with the - // maximum zoom level possible. - fitBounds: function (bounds, options) { - - bounds = toLatLngBounds(bounds); - - if (!bounds.isValid()) { - throw new Error('Bounds are not valid.'); - } - - var target = this._getBoundsCenterZoom(bounds, options); - return this.setView(target.center, target.zoom, options); - }, - - // @method fitWorld(options?: fitBounds options): this - // Sets a map view that mostly contains the whole world with the maximum - // zoom level possible. - fitWorld: function (options) { - return this.fitBounds([[-90, -180], [90, 180]], options); - }, - - // @method panTo(latlng: LatLng, options?: Pan options): this - // Pans the map to a given center. - panTo: function (center, options) { // (LatLng) - return this.setView(center, this._zoom, {pan: options}); - }, - - // @method panBy(offset: Point, options?: Pan options): this - // Pans the map by a given number of pixels (animated). - panBy: function (offset, options) { - offset = toPoint(offset).round(); - options = options || {}; - - if (!offset.x && !offset.y) { - return this.fire('moveend'); - } - // If we pan too far, Chrome gets issues with tiles - // and makes them disappear or appear in the wrong place (slightly offset) #2602 - if (options.animate !== true && !this.getSize().contains(offset)) { - this._resetView(this.unproject(this.project(this.getCenter()).add(offset)), this.getZoom()); - return this; - } - - if (!this._panAnim) { - this._panAnim = new PosAnimation(); - - this._panAnim.on({ - 'step': this._onPanTransitionStep, - 'end': this._onPanTransitionEnd - }, this); - } - - // don't fire movestart if animating inertia - if (!options.noMoveStart) { - this.fire('movestart'); - } - - // animate pan unless animate: false specified - if (options.animate !== false) { - addClass(this._mapPane, 'leaflet-pan-anim'); - - var newPos = this._getMapPanePos().subtract(offset).round(); - this._panAnim.run(this._mapPane, newPos, options.duration || 0.25, options.easeLinearity); - } else { - this._rawPanBy(offset); - this.fire('move').fire('moveend'); - } - - return this; - }, - - // @method flyTo(latlng: LatLng, zoom?: Number, options?: Zoom/pan options): this - // Sets the view of the map (geographical center and zoom) performing a smooth - // pan-zoom animation. - flyTo: function (targetCenter, targetZoom, options) { - - options = options || {}; - if (options.animate === false || !any3d) { - return this.setView(targetCenter, targetZoom, options); - } - - this._stop(); - - var from = this.project(this.getCenter()), - to = this.project(targetCenter), - size = this.getSize(), - startZoom = this._zoom; - - targetCenter = toLatLng(targetCenter); - targetZoom = targetZoom === undefined ? startZoom : targetZoom; - - var w0 = Math.max(size.x, size.y), - w1 = w0 * this.getZoomScale(startZoom, targetZoom), - u1 = (to.distanceTo(from)) || 1, - rho = 1.42, - rho2 = rho * rho; - - function r(i) { - var s1 = i ? -1 : 1, - s2 = i ? w1 : w0, - t1 = w1 * w1 - w0 * w0 + s1 * rho2 * rho2 * u1 * u1, - b1 = 2 * s2 * rho2 * u1, - b = t1 / b1, - sq = Math.sqrt(b * b + 1) - b; - - // workaround for floating point precision bug when sq = 0, log = -Infinite, - // thus triggering an infinite loop in flyTo - var log = sq < 0.000000001 ? -18 : Math.log(sq); - - return log; - } - - function sinh(n) { return (Math.exp(n) - Math.exp(-n)) / 2; } - function cosh(n) { return (Math.exp(n) + Math.exp(-n)) / 2; } - function tanh(n) { return sinh(n) / cosh(n); } - - var r0 = r(0); - - function w(s) { return w0 * (cosh(r0) / cosh(r0 + rho * s)); } - function u(s) { return w0 * (cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2; } - - function easeOut(t) { return 1 - Math.pow(1 - t, 1.5); } - - var start = Date.now(), - S = (r(1) - r0) / rho, - duration = options.duration ? 1000 * options.duration : 1000 * S * 0.8; - - function frame() { - var t = (Date.now() - start) / duration, - s = easeOut(t) * S; - - if (t <= 1) { - this._flyToFrame = requestAnimFrame(frame, this); - - this._move( - this.unproject(from.add(to.subtract(from).multiplyBy(u(s) / u1)), startZoom), - this.getScaleZoom(w0 / w(s), startZoom), - {flyTo: true}); - - } else { - this - ._move(targetCenter, targetZoom) - ._moveEnd(true); - } - } - - this._moveStart(true, options.noMoveStart); - - frame.call(this); - return this; - }, - - // @method flyToBounds(bounds: LatLngBounds, options?: fitBounds options): this - // Sets the view of the map with a smooth animation like [`flyTo`](#map-flyto), - // but takes a bounds parameter like [`fitBounds`](#map-fitbounds). - flyToBounds: function (bounds, options) { - var target = this._getBoundsCenterZoom(bounds, options); - return this.flyTo(target.center, target.zoom, options); - }, - - // @method setMaxBounds(bounds: LatLngBounds): this - // Restricts the map view to the given bounds (see the [maxBounds](#map-maxbounds) option). - setMaxBounds: function (bounds) { - bounds = toLatLngBounds(bounds); - - if (!bounds.isValid()) { - this.options.maxBounds = null; - return this.off('moveend', this._panInsideMaxBounds); - } else if (this.options.maxBounds) { - this.off('moveend', this._panInsideMaxBounds); - } - - this.options.maxBounds = bounds; - - if (this._loaded) { - this._panInsideMaxBounds(); - } - - return this.on('moveend', this._panInsideMaxBounds); - }, - - // @method setMinZoom(zoom: Number): this - // Sets the lower limit for the available zoom levels (see the [minZoom](#map-minzoom) option). - setMinZoom: function (zoom) { - var oldZoom = this.options.minZoom; - this.options.minZoom = zoom; - - if (this._loaded && oldZoom !== zoom) { - this.fire('zoomlevelschange'); - - if (this.getZoom() < this.options.minZoom) { - return this.setZoom(zoom); - } - } - - return this; - }, - - // @method setMaxZoom(zoom: Number): this - // Sets the upper limit for the available zoom levels (see the [maxZoom](#map-maxzoom) option). - setMaxZoom: function (zoom) { - var oldZoom = this.options.maxZoom; - this.options.maxZoom = zoom; - - if (this._loaded && oldZoom !== zoom) { - this.fire('zoomlevelschange'); - - if (this.getZoom() > this.options.maxZoom) { - return this.setZoom(zoom); - } - } - - return this; - }, - - // @method panInsideBounds(bounds: LatLngBounds, options?: Pan options): this - // Pans the map to the closest view that would lie inside the given bounds (if it's not already), controlling the animation using the options specific, if any. - panInsideBounds: function (bounds, options) { - this._enforcingBounds = true; - var center = this.getCenter(), - newCenter = this._limitCenter(center, this._zoom, toLatLngBounds(bounds)); - - if (!center.equals(newCenter)) { - this.panTo(newCenter, options); - } - - this._enforcingBounds = false; - return this; - }, - - // @method panInside(latlng: LatLng, options?: options): this - // Pans the map the minimum amount to make the `latlng` visible. Use - // `padding`, `paddingTopLeft` and `paddingTopRight` options to fit - // the display to more restricted bounds, like [`fitBounds`](#map-fitbounds). - // If `latlng` is already within the (optionally padded) display bounds, - // the map will not be panned. - panInside: function (latlng, options) { - options = options || {}; - - var paddingTL = toPoint(options.paddingTopLeft || options.padding || [0, 0]), - paddingBR = toPoint(options.paddingBottomRight || options.padding || [0, 0]), - center = this.getCenter(), - pixelCenter = this.project(center), - pixelPoint = this.project(latlng), - pixelBounds = this.getPixelBounds(), - halfPixelBounds = pixelBounds.getSize().divideBy(2), - paddedBounds = toBounds([pixelBounds.min.add(paddingTL), pixelBounds.max.subtract(paddingBR)]); - - if (!paddedBounds.contains(pixelPoint)) { - this._enforcingBounds = true; - var diff = pixelCenter.subtract(pixelPoint), - newCenter = toPoint(pixelPoint.x + diff.x, pixelPoint.y + diff.y); - - if (pixelPoint.x < paddedBounds.min.x || pixelPoint.x > paddedBounds.max.x) { - newCenter.x = pixelCenter.x - diff.x; - if (diff.x > 0) { - newCenter.x += halfPixelBounds.x - paddingTL.x; - } else { - newCenter.x -= halfPixelBounds.x - paddingBR.x; - } - } - if (pixelPoint.y < paddedBounds.min.y || pixelPoint.y > paddedBounds.max.y) { - newCenter.y = pixelCenter.y - diff.y; - if (diff.y > 0) { - newCenter.y += halfPixelBounds.y - paddingTL.y; - } else { - newCenter.y -= halfPixelBounds.y - paddingBR.y; - } - } - this.panTo(this.unproject(newCenter), options); - this._enforcingBounds = false; - } - return this; - }, - - // @method invalidateSize(options: Zoom/pan options): this - // Checks if the map container size changed and updates the map if so — - // call it after you've changed the map size dynamically, also animating - // pan by default. If `options.pan` is `false`, panning will not occur. - // If `options.debounceMoveend` is `true`, it will delay `moveend` event so - // that it doesn't happen often even if the method is called many - // times in a row. - - // @alternative - // @method invalidateSize(animate: Boolean): this - // Checks if the map container size changed and updates the map if so — - // call it after you've changed the map size dynamically, also animating - // pan by default. - invalidateSize: function (options) { - if (!this._loaded) { return this; } - - options = extend({ - animate: false, - pan: true - }, options === true ? {animate: true} : options); - - var oldSize = this.getSize(); - this._sizeChanged = true; - this._lastCenter = null; - - var newSize = this.getSize(), - oldCenter = oldSize.divideBy(2).round(), - newCenter = newSize.divideBy(2).round(), - offset = oldCenter.subtract(newCenter); - - if (!offset.x && !offset.y) { return this; } - - if (options.animate && options.pan) { - this.panBy(offset); - - } else { - if (options.pan) { - this._rawPanBy(offset); - } - - this.fire('move'); - - if (options.debounceMoveend) { - clearTimeout(this._sizeTimer); - this._sizeTimer = setTimeout(bind(this.fire, this, 'moveend'), 200); - } else { - this.fire('moveend'); - } - } - - // @section Map state change events - // @event resize: ResizeEvent - // Fired when the map is resized. - return this.fire('resize', { - oldSize: oldSize, - newSize: newSize - }); - }, - - // @section Methods for modifying map state - // @method stop(): this - // Stops the currently running `panTo` or `flyTo` animation, if any. - stop: function () { - this.setZoom(this._limitZoom(this._zoom)); - if (!this.options.zoomSnap) { - this.fire('viewreset'); - } - return this._stop(); - }, - - // @section Geolocation methods - // @method locate(options?: Locate options): this - // Tries to locate the user using the Geolocation API, firing a [`locationfound`](#map-locationfound) - // event with location data on success or a [`locationerror`](#map-locationerror) event on failure, - // and optionally sets the map view to the user's location with respect to - // detection accuracy (or to the world view if geolocation failed). - // Note that, if your page doesn't use HTTPS, this method will fail in - // modern browsers ([Chrome 50 and newer](https://sites.google.com/a/chromium.org/dev/Home/chromium-security/deprecating-powerful-features-on-insecure-origins)) - // See `Locate options` for more details. - locate: function (options) { - - options = this._locateOptions = extend({ - timeout: 10000, - watch: false - // setView: false - // maxZoom: - // maximumAge: 0 - // enableHighAccuracy: false - }, options); - - if (!('geolocation' in navigator)) { - this._handleGeolocationError({ - code: 0, - message: 'Geolocation not supported.' - }); - return this; - } - - var onResponse = bind(this._handleGeolocationResponse, this), - onError = bind(this._handleGeolocationError, this); - - if (options.watch) { - this._locationWatchId = - navigator.geolocation.watchPosition(onResponse, onError, options); - } else { - navigator.geolocation.getCurrentPosition(onResponse, onError, options); - } - return this; - }, - - // @method stopLocate(): this - // Stops watching location previously initiated by `map.locate({watch: true})` - // and aborts resetting the map view if map.locate was called with - // `{setView: true}`. - stopLocate: function () { - if (navigator.geolocation && navigator.geolocation.clearWatch) { - navigator.geolocation.clearWatch(this._locationWatchId); - } - if (this._locateOptions) { - this._locateOptions.setView = false; - } - return this; - }, - - _handleGeolocationError: function (error) { - var c = error.code, - message = error.message || - (c === 1 ? 'permission denied' : - (c === 2 ? 'position unavailable' : 'timeout')); - - if (this._locateOptions.setView && !this._loaded) { - this.fitWorld(); - } - - // @section Location events - // @event locationerror: ErrorEvent - // Fired when geolocation (using the [`locate`](#map-locate) method) failed. - this.fire('locationerror', { - code: c, - message: 'Geolocation error: ' + message + '.' - }); - }, - - _handleGeolocationResponse: function (pos) { - var lat = pos.coords.latitude, - lng = pos.coords.longitude, - latlng = new LatLng(lat, lng), - bounds = latlng.toBounds(pos.coords.accuracy * 2), - options = this._locateOptions; - - if (options.setView) { - var zoom = this.getBoundsZoom(bounds); - this.setView(latlng, options.maxZoom ? Math.min(zoom, options.maxZoom) : zoom); - } - - var data = { - latlng: latlng, - bounds: bounds, - timestamp: pos.timestamp - }; - - for (var i in pos.coords) { - if (typeof pos.coords[i] === 'number') { - data[i] = pos.coords[i]; - } - } - - // @event locationfound: LocationEvent - // Fired when geolocation (using the [`locate`](#map-locate) method) - // went successfully. - this.fire('locationfound', data); - }, - - // TODO Appropriate docs section? - // @section Other Methods - // @method addHandler(name: String, HandlerClass: Function): this - // Adds a new `Handler` to the map, given its name and constructor function. - addHandler: function (name, HandlerClass) { - if (!HandlerClass) { return this; } - - var handler = this[name] = new HandlerClass(this); - - this._handlers.push(handler); - - if (this.options[name]) { - handler.enable(); - } - - return this; - }, - - // @method remove(): this - // Destroys the map and clears all related event listeners. - remove: function () { - - this._initEvents(true); - this.off('moveend', this._panInsideMaxBounds); - - if (this._containerId !== this._container._leaflet_id) { - throw new Error('Map container is being reused by another instance'); - } - - try { - // throws error in IE6-8 - delete this._container._leaflet_id; - delete this._containerId; - } catch (e) { - /*eslint-disable */ - this._container._leaflet_id = undefined; - /* eslint-enable */ - this._containerId = undefined; - } - - if (this._locationWatchId !== undefined) { - this.stopLocate(); - } - - this._stop(); - - remove(this._mapPane); - - if (this._clearControlPos) { - this._clearControlPos(); - } - if (this._resizeRequest) { - cancelAnimFrame(this._resizeRequest); - this._resizeRequest = null; - } - - this._clearHandlers(); - - if (this._loaded) { - // @section Map state change events - // @event unload: Event - // Fired when the map is destroyed with [remove](#map-remove) method. - this.fire('unload'); - } - - var i; - for (i in this._layers) { - this._layers[i].remove(); - } - for (i in this._panes) { - remove(this._panes[i]); - } - - this._layers = []; - this._panes = []; - delete this._mapPane; - delete this._renderer; - - return this; - }, - - // @section Other Methods - // @method createPane(name: String, container?: HTMLElement): HTMLElement - // Creates a new [map pane](#map-pane) with the given name if it doesn't exist already, - // then returns it. The pane is created as a child of `container`, or - // as a child of the main map pane if not set. - createPane: function (name, container) { - var className = 'leaflet-pane' + (name ? ' leaflet-' + name.replace('Pane', '') + '-pane' : ''), - pane = create$1('div', className, container || this._mapPane); - - if (name) { - this._panes[name] = pane; - } - return pane; - }, - - // @section Methods for Getting Map State - - // @method getCenter(): LatLng - // Returns the geographical center of the map view - getCenter: function () { - this._checkIfLoaded(); - - if (this._lastCenter && !this._moved()) { - return this._lastCenter; - } - return this.layerPointToLatLng(this._getCenterLayerPoint()); - }, - - // @method getZoom(): Number - // Returns the current zoom level of the map view - getZoom: function () { - return this._zoom; - }, - - // @method getBounds(): LatLngBounds - // Returns the geographical bounds visible in the current map view - getBounds: function () { - var bounds = this.getPixelBounds(), - sw = this.unproject(bounds.getBottomLeft()), - ne = this.unproject(bounds.getTopRight()); - - return new LatLngBounds(sw, ne); - }, - - // @method getMinZoom(): Number - // Returns the minimum zoom level of the map (if set in the `minZoom` option of the map or of any layers), or `0` by default. - getMinZoom: function () { - return this.options.minZoom === undefined ? this._layersMinZoom || 0 : this.options.minZoom; - }, - - // @method getMaxZoom(): Number - // Returns the maximum zoom level of the map (if set in the `maxZoom` option of the map or of any layers). - getMaxZoom: function () { - return this.options.maxZoom === undefined ? - (this._layersMaxZoom === undefined ? Infinity : this._layersMaxZoom) : - this.options.maxZoom; - }, - - // @method getBoundsZoom(bounds: LatLngBounds, inside?: Boolean, padding?: Point): Number - // Returns the maximum zoom level on which the given bounds fit to the map - // view in its entirety. If `inside` (optional) is set to `true`, the method - // instead returns the minimum zoom level on which the map view fits into - // the given bounds in its entirety. - getBoundsZoom: function (bounds, inside, padding) { // (LatLngBounds[, Boolean, Point]) -> Number - bounds = toLatLngBounds(bounds); - padding = toPoint(padding || [0, 0]); - - var zoom = this.getZoom() || 0, - min = this.getMinZoom(), - max = this.getMaxZoom(), - nw = bounds.getNorthWest(), - se = bounds.getSouthEast(), - size = this.getSize().subtract(padding), - boundsSize = toBounds(this.project(se, zoom), this.project(nw, zoom)).getSize(), - snap = any3d ? this.options.zoomSnap : 1, - scalex = size.x / boundsSize.x, - scaley = size.y / boundsSize.y, - scale = inside ? Math.max(scalex, scaley) : Math.min(scalex, scaley); - - zoom = this.getScaleZoom(scale, zoom); - - if (snap) { - zoom = Math.round(zoom / (snap / 100)) * (snap / 100); // don't jump if within 1% of a snap level - zoom = inside ? Math.ceil(zoom / snap) * snap : Math.floor(zoom / snap) * snap; - } - - return Math.max(min, Math.min(max, zoom)); - }, - - // @method getSize(): Point - // Returns the current size of the map container (in pixels). - getSize: function () { - if (!this._size || this._sizeChanged) { - this._size = new Point( - this._container.clientWidth || 0, - this._container.clientHeight || 0); - - this._sizeChanged = false; - } - return this._size.clone(); - }, - - // @method getPixelBounds(): Bounds - // Returns the bounds of the current map view in projected pixel - // coordinates (sometimes useful in layer and overlay implementations). - getPixelBounds: function (center, zoom) { - var topLeftPoint = this._getTopLeftPoint(center, zoom); - return new Bounds(topLeftPoint, topLeftPoint.add(this.getSize())); - }, - - // TODO: Check semantics - isn't the pixel origin the 0,0 coord relative to - // the map pane? "left point of the map layer" can be confusing, specially - // since there can be negative offsets. - // @method getPixelOrigin(): Point - // Returns the projected pixel coordinates of the top left point of - // the map layer (useful in custom layer and overlay implementations). - getPixelOrigin: function () { - this._checkIfLoaded(); - return this._pixelOrigin; - }, - - // @method getPixelWorldBounds(zoom?: Number): Bounds - // Returns the world's bounds in pixel coordinates for zoom level `zoom`. - // If `zoom` is omitted, the map's current zoom level is used. - getPixelWorldBounds: function (zoom) { - return this.options.crs.getProjectedBounds(zoom === undefined ? this.getZoom() : zoom); - }, - - // @section Other Methods - - // @method getPane(pane: String|HTMLElement): HTMLElement - // Returns a [map pane](#map-pane), given its name or its HTML element (its identity). - getPane: function (pane) { - return typeof pane === 'string' ? this._panes[pane] : pane; - }, - - // @method getPanes(): Object - // Returns a plain object containing the names of all [panes](#map-pane) as keys and - // the panes as values. - getPanes: function () { - return this._panes; - }, - - // @method getContainer: HTMLElement - // Returns the HTML element that contains the map. - getContainer: function () { - return this._container; - }, - - - // @section Conversion Methods - - // @method getZoomScale(toZoom: Number, fromZoom: Number): Number - // Returns the scale factor to be applied to a map transition from zoom level - // `fromZoom` to `toZoom`. Used internally to help with zoom animations. - getZoomScale: function (toZoom, fromZoom) { - // TODO replace with universal implementation after refactoring projections - var crs = this.options.crs; - fromZoom = fromZoom === undefined ? this._zoom : fromZoom; - return crs.scale(toZoom) / crs.scale(fromZoom); - }, - - // @method getScaleZoom(scale: Number, fromZoom: Number): Number - // Returns the zoom level that the map would end up at, if it is at `fromZoom` - // level and everything is scaled by a factor of `scale`. Inverse of - // [`getZoomScale`](#map-getZoomScale). - getScaleZoom: function (scale, fromZoom) { - var crs = this.options.crs; - fromZoom = fromZoom === undefined ? this._zoom : fromZoom; - var zoom = crs.zoom(scale * crs.scale(fromZoom)); - return isNaN(zoom) ? Infinity : zoom; - }, - - // @method project(latlng: LatLng, zoom: Number): Point - // Projects a geographical coordinate `LatLng` according to the projection - // of the map's CRS, then scales it according to `zoom` and the CRS's - // `Transformation`. The result is pixel coordinate relative to - // the CRS origin. - project: function (latlng, zoom) { - zoom = zoom === undefined ? this._zoom : zoom; - return this.options.crs.latLngToPoint(toLatLng(latlng), zoom); - }, - - // @method unproject(point: Point, zoom: Number): LatLng - // Inverse of [`project`](#map-project). - unproject: function (point, zoom) { - zoom = zoom === undefined ? this._zoom : zoom; - return this.options.crs.pointToLatLng(toPoint(point), zoom); - }, - - // @method layerPointToLatLng(point: Point): LatLng - // Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin), - // returns the corresponding geographical coordinate (for the current zoom level). - layerPointToLatLng: function (point) { - var projectedPoint = toPoint(point).add(this.getPixelOrigin()); - return this.unproject(projectedPoint); - }, - - // @method latLngToLayerPoint(latlng: LatLng): Point - // Given a geographical coordinate, returns the corresponding pixel coordinate - // relative to the [origin pixel](#map-getpixelorigin). - latLngToLayerPoint: function (latlng) { - var projectedPoint = this.project(toLatLng(latlng))._round(); - return projectedPoint._subtract(this.getPixelOrigin()); - }, - - // @method wrapLatLng(latlng: LatLng): LatLng - // Returns a `LatLng` where `lat` and `lng` has been wrapped according to the - // map's CRS's `wrapLat` and `wrapLng` properties, if they are outside the - // CRS's bounds. - // By default this means longitude is wrapped around the dateline so its - // value is between -180 and +180 degrees. - wrapLatLng: function (latlng) { - return this.options.crs.wrapLatLng(toLatLng(latlng)); - }, - - // @method wrapLatLngBounds(bounds: LatLngBounds): LatLngBounds - // Returns a `LatLngBounds` with the same size as the given one, ensuring that - // its center is within the CRS's bounds. - // By default this means the center longitude is wrapped around the dateline so its - // value is between -180 and +180 degrees, and the majority of the bounds - // overlaps the CRS's bounds. - wrapLatLngBounds: function (latlng) { - return this.options.crs.wrapLatLngBounds(toLatLngBounds(latlng)); - }, - - // @method distance(latlng1: LatLng, latlng2: LatLng): Number - // Returns the distance between two geographical coordinates according to - // the map's CRS. By default this measures distance in meters. - distance: function (latlng1, latlng2) { - return this.options.crs.distance(toLatLng(latlng1), toLatLng(latlng2)); - }, - - // @method containerPointToLayerPoint(point: Point): Point - // Given a pixel coordinate relative to the map container, returns the corresponding - // pixel coordinate relative to the [origin pixel](#map-getpixelorigin). - containerPointToLayerPoint: function (point) { // (Point) - return toPoint(point).subtract(this._getMapPanePos()); - }, - - // @method layerPointToContainerPoint(point: Point): Point - // Given a pixel coordinate relative to the [origin pixel](#map-getpixelorigin), - // returns the corresponding pixel coordinate relative to the map container. - layerPointToContainerPoint: function (point) { // (Point) - return toPoint(point).add(this._getMapPanePos()); - }, - - // @method containerPointToLatLng(point: Point): LatLng - // Given a pixel coordinate relative to the map container, returns - // the corresponding geographical coordinate (for the current zoom level). - containerPointToLatLng: function (point) { - var layerPoint = this.containerPointToLayerPoint(toPoint(point)); - return this.layerPointToLatLng(layerPoint); - }, - - // @method latLngToContainerPoint(latlng: LatLng): Point - // Given a geographical coordinate, returns the corresponding pixel coordinate - // relative to the map container. - latLngToContainerPoint: function (latlng) { - return this.layerPointToContainerPoint(this.latLngToLayerPoint(toLatLng(latlng))); - }, - - // @method mouseEventToContainerPoint(ev: MouseEvent): Point - // Given a MouseEvent object, returns the pixel coordinate relative to the - // map container where the event took place. - mouseEventToContainerPoint: function (e) { - return getMousePosition(e, this._container); - }, - - // @method mouseEventToLayerPoint(ev: MouseEvent): Point - // Given a MouseEvent object, returns the pixel coordinate relative to - // the [origin pixel](#map-getpixelorigin) where the event took place. - mouseEventToLayerPoint: function (e) { - return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(e)); - }, - - // @method mouseEventToLatLng(ev: MouseEvent): LatLng - // Given a MouseEvent object, returns geographical coordinate where the - // event took place. - mouseEventToLatLng: function (e) { // (MouseEvent) - return this.layerPointToLatLng(this.mouseEventToLayerPoint(e)); - }, - - - // map initialization methods - - _initContainer: function (id) { - var container = this._container = get(id); - - if (!container) { - throw new Error('Map container not found.'); - } else if (container._leaflet_id) { - throw new Error('Map container is already initialized.'); - } - - on(container, 'scroll', this._onScroll, this); - this._containerId = stamp(container); - }, - - _initLayout: function () { - var container = this._container; - - this._fadeAnimated = this.options.fadeAnimation && any3d; - - addClass(container, 'leaflet-container' + - (touch ? ' leaflet-touch' : '') + - (retina ? ' leaflet-retina' : '') + - (ielt9 ? ' leaflet-oldie' : '') + - (safari ? ' leaflet-safari' : '') + - (this._fadeAnimated ? ' leaflet-fade-anim' : '')); - - var position = getStyle(container, 'position'); - - if (position !== 'absolute' && position !== 'relative' && position !== 'fixed') { - container.style.position = 'relative'; - } - - this._initPanes(); - - if (this._initControlPos) { - this._initControlPos(); - } - }, - - _initPanes: function () { - var panes = this._panes = {}; - this._paneRenderers = {}; - - // @section - // - // Panes are DOM elements used to control the ordering of layers on the map. You - // can access panes with [`map.getPane`](#map-getpane) or - // [`map.getPanes`](#map-getpanes) methods. New panes can be created with the - // [`map.createPane`](#map-createpane) method. - // - // Every map has the following default panes that differ only in zIndex. - // - // @pane mapPane: HTMLElement = 'auto' - // Pane that contains all other map panes - - this._mapPane = this.createPane('mapPane', this._container); - setPosition(this._mapPane, new Point(0, 0)); - - // @pane tilePane: HTMLElement = 200 - // Pane for `GridLayer`s and `TileLayer`s - this.createPane('tilePane'); - // @pane overlayPane: HTMLElement = 400 - // Pane for overlay shadows (e.g. `Marker` shadows) - this.createPane('shadowPane'); - // @pane shadowPane: HTMLElement = 500 - // Pane for vectors (`Path`s, like `Polyline`s and `Polygon`s), `ImageOverlay`s and `VideoOverlay`s - this.createPane('overlayPane'); - // @pane markerPane: HTMLElement = 600 - // Pane for `Icon`s of `Marker`s - this.createPane('markerPane'); - // @pane tooltipPane: HTMLElement = 650 - // Pane for `Tooltip`s. - this.createPane('tooltipPane'); - // @pane popupPane: HTMLElement = 700 - // Pane for `Popup`s. - this.createPane('popupPane'); - - if (!this.options.markerZoomAnimation) { - addClass(panes.markerPane, 'leaflet-zoom-hide'); - addClass(panes.shadowPane, 'leaflet-zoom-hide'); - } - }, - - - // private methods that modify map state - - // @section Map state change events - _resetView: function (center, zoom) { - setPosition(this._mapPane, new Point(0, 0)); - - var loading = !this._loaded; - this._loaded = true; - zoom = this._limitZoom(zoom); - - this.fire('viewprereset'); - - var zoomChanged = this._zoom !== zoom; - this - ._moveStart(zoomChanged, false) - ._move(center, zoom) - ._moveEnd(zoomChanged); - - // @event viewreset: Event - // Fired when the map needs to redraw its content (this usually happens - // on map zoom or load). Very useful for creating custom overlays. - this.fire('viewreset'); - - // @event load: Event - // Fired when the map is initialized (when its center and zoom are set - // for the first time). - if (loading) { - this.fire('load'); - } - }, - - _moveStart: function (zoomChanged, noMoveStart) { - // @event zoomstart: Event - // Fired when the map zoom is about to change (e.g. before zoom animation). - // @event movestart: Event - // Fired when the view of the map starts changing (e.g. user starts dragging the map). - if (zoomChanged) { - this.fire('zoomstart'); - } - if (!noMoveStart) { - this.fire('movestart'); - } - return this; - }, - - _move: function (center, zoom, data) { - if (zoom === undefined) { - zoom = this._zoom; - } - var zoomChanged = this._zoom !== zoom; - - this._zoom = zoom; - this._lastCenter = center; - this._pixelOrigin = this._getNewPixelOrigin(center); - - // @event zoom: Event - // Fired repeatedly during any change in zoom level, including zoom - // and fly animations. - if (zoomChanged || (data && data.pinch)) { // Always fire 'zoom' if pinching because #3530 - this.fire('zoom', data); - } - - // @event move: Event - // Fired repeatedly during any movement of the map, including pan and - // fly animations. - return this.fire('move', data); - }, - - _moveEnd: function (zoomChanged) { - // @event zoomend: Event - // Fired when the map has changed, after any animations. - if (zoomChanged) { - this.fire('zoomend'); - } - - // @event moveend: Event - // Fired when the center of the map stops changing (e.g. user stopped - // dragging the map). - return this.fire('moveend'); - }, - - _stop: function () { - cancelAnimFrame(this._flyToFrame); - if (this._panAnim) { - this._panAnim.stop(); - } - return this; - }, - - _rawPanBy: function (offset) { - setPosition(this._mapPane, this._getMapPanePos().subtract(offset)); - }, - - _getZoomSpan: function () { - return this.getMaxZoom() - this.getMinZoom(); - }, - - _panInsideMaxBounds: function () { - if (!this._enforcingBounds) { - this.panInsideBounds(this.options.maxBounds); - } - }, - - _checkIfLoaded: function () { - if (!this._loaded) { - throw new Error('Set map center and zoom first.'); - } - }, - - // DOM event handling - - // @section Interaction events - _initEvents: function (remove$$1) { - this._targets = {}; - this._targets[stamp(this._container)] = this; - - var onOff = remove$$1 ? off : on; - - // @event click: MouseEvent - // Fired when the user clicks (or taps) the map. - // @event dblclick: MouseEvent - // Fired when the user double-clicks (or double-taps) the map. - // @event mousedown: MouseEvent - // Fired when the user pushes the mouse button on the map. - // @event mouseup: MouseEvent - // Fired when the user releases the mouse button on the map. - // @event mouseover: MouseEvent - // Fired when the mouse enters the map. - // @event mouseout: MouseEvent - // Fired when the mouse leaves the map. - // @event mousemove: MouseEvent - // Fired while the mouse moves over the map. - // @event contextmenu: MouseEvent - // Fired when the user pushes the right mouse button on the map, prevents - // default browser context menu from showing if there are listeners on - // this event. Also fired on mobile when the user holds a single touch - // for a second (also called long press). - // @event keypress: KeyboardEvent - // Fired when the user presses a key from the keyboard that produces a character value while the map is focused. - // @event keydown: KeyboardEvent - // Fired when the user presses a key from the keyboard while the map is focused. Unlike the `keypress` event, - // the `keydown` event is fired for keys that produce a character value and for keys - // that do not produce a character value. - // @event keyup: KeyboardEvent - // Fired when the user releases a key from the keyboard while the map is focused. - onOff(this._container, 'click dblclick mousedown mouseup ' + - 'mouseover mouseout mousemove contextmenu keypress keydown keyup', this._handleDOMEvent, this); - - if (this.options.trackResize) { - onOff(window, 'resize', this._onResize, this); - } - - if (any3d && this.options.transform3DLimit) { - (remove$$1 ? this.off : this.on).call(this, 'moveend', this._onMoveEnd); - } - }, - - _onResize: function () { - cancelAnimFrame(this._resizeRequest); - this._resizeRequest = requestAnimFrame( - function () { this.invalidateSize({debounceMoveend: true}); }, this); - }, - - _onScroll: function () { - this._container.scrollTop = 0; - this._container.scrollLeft = 0; - }, - - _onMoveEnd: function () { - var pos = this._getMapPanePos(); - if (Math.max(Math.abs(pos.x), Math.abs(pos.y)) >= this.options.transform3DLimit) { - // https://bugzilla.mozilla.org/show_bug.cgi?id=1203873 but Webkit also have - // a pixel offset on very high values, see: http://jsfiddle.net/dg6r5hhb/ - this._resetView(this.getCenter(), this.getZoom()); - } - }, - - _findEventTargets: function (e, type) { - var targets = [], - target, - isHover = type === 'mouseout' || type === 'mouseover', - src = e.target || e.srcElement, - dragging = false; - - while (src) { - target = this._targets[stamp(src)]; - if (target && (type === 'click' || type === 'preclick') && !e._simulated && this._draggableMoved(target)) { - // Prevent firing click after you just dragged an object. - dragging = true; - break; - } - if (target && target.listens(type, true)) { - if (isHover && !isExternalTarget(src, e)) { break; } - targets.push(target); - if (isHover) { break; } - } - if (src === this._container) { break; } - src = src.parentNode; - } - if (!targets.length && !dragging && !isHover && isExternalTarget(src, e)) { - targets = [this]; - } - return targets; - }, - - _handleDOMEvent: function (e) { - if (!this._loaded || skipped(e)) { return; } - - var type = e.type; - - if (type === 'mousedown' || type === 'keypress' || type === 'keyup' || type === 'keydown') { - // prevents outline when clicking on keyboard-focusable element - preventOutline(e.target || e.srcElement); - } - - this._fireDOMEvent(e, type); - }, - - _mouseEvents: ['click', 'dblclick', 'mouseover', 'mouseout', 'contextmenu'], - - _fireDOMEvent: function (e, type, targets) { - - if (e.type === 'click') { - // Fire a synthetic 'preclick' event which propagates up (mainly for closing popups). - // @event preclick: MouseEvent - // Fired before mouse click on the map (sometimes useful when you - // want something to happen on click before any existing click - // handlers start running). - var synth = extend({}, e); - synth.type = 'preclick'; - this._fireDOMEvent(synth, synth.type, targets); - } - - if (e._stopped) { return; } - - // Find the layer the event is propagating from and its parents. - targets = (targets || []).concat(this._findEventTargets(e, type)); - - if (!targets.length) { return; } - - var target = targets[0]; - if (type === 'contextmenu' && target.listens(type, true)) { - preventDefault(e); - } - - var data = { - originalEvent: e - }; - - if (e.type !== 'keypress' && e.type !== 'keydown' && e.type !== 'keyup') { - var isMarker = target.getLatLng && (!target._radius || target._radius <= 10); - data.containerPoint = isMarker ? - this.latLngToContainerPoint(target.getLatLng()) : this.mouseEventToContainerPoint(e); - data.layerPoint = this.containerPointToLayerPoint(data.containerPoint); - data.latlng = isMarker ? target.getLatLng() : this.layerPointToLatLng(data.layerPoint); - } - - for (var i = 0; i < targets.length; i++) { - targets[i].fire(type, data, true); - if (data.originalEvent._stopped || - (targets[i].options.bubblingMouseEvents === false && indexOf(this._mouseEvents, type) !== -1)) { return; } - } - }, - - _draggableMoved: function (obj) { - obj = obj.dragging && obj.dragging.enabled() ? obj : this; - return (obj.dragging && obj.dragging.moved()) || (this.boxZoom && this.boxZoom.moved()); - }, - - _clearHandlers: function () { - for (var i = 0, len = this._handlers.length; i < len; i++) { - this._handlers[i].disable(); - } - }, - - // @section Other Methods - - // @method whenReady(fn: Function, context?: Object): this - // Runs the given function `fn` when the map gets initialized with - // a view (center and zoom) and at least one layer, or immediately - // if it's already initialized, optionally passing a function context. - whenReady: function (callback, context) { - if (this._loaded) { - callback.call(context || this, {target: this}); - } else { - this.on('load', callback, context); - } - return this; - }, - - - // private methods for getting map state - - _getMapPanePos: function () { - return getPosition(this._mapPane) || new Point(0, 0); - }, - - _moved: function () { - var pos = this._getMapPanePos(); - return pos && !pos.equals([0, 0]); - }, - - _getTopLeftPoint: function (center, zoom) { - var pixelOrigin = center && zoom !== undefined ? - this._getNewPixelOrigin(center, zoom) : - this.getPixelOrigin(); - return pixelOrigin.subtract(this._getMapPanePos()); - }, - - _getNewPixelOrigin: function (center, zoom) { - var viewHalf = this.getSize()._divideBy(2); - return this.project(center, zoom)._subtract(viewHalf)._add(this._getMapPanePos())._round(); - }, - - _latLngToNewLayerPoint: function (latlng, zoom, center) { - var topLeft = this._getNewPixelOrigin(center, zoom); - return this.project(latlng, zoom)._subtract(topLeft); - }, - - _latLngBoundsToNewLayerBounds: function (latLngBounds, zoom, center) { - var topLeft = this._getNewPixelOrigin(center, zoom); - return toBounds([ - this.project(latLngBounds.getSouthWest(), zoom)._subtract(topLeft), - this.project(latLngBounds.getNorthWest(), zoom)._subtract(topLeft), - this.project(latLngBounds.getSouthEast(), zoom)._subtract(topLeft), - this.project(latLngBounds.getNorthEast(), zoom)._subtract(topLeft) - ]); - }, - - // layer point of the current center - _getCenterLayerPoint: function () { - return this.containerPointToLayerPoint(this.getSize()._divideBy(2)); - }, - - // offset of the specified place to the current center in pixels - _getCenterOffset: function (latlng) { - return this.latLngToLayerPoint(latlng).subtract(this._getCenterLayerPoint()); - }, - - // adjust center for view to get inside bounds - _limitCenter: function (center, zoom, bounds) { - - if (!bounds) { return center; } - - var centerPoint = this.project(center, zoom), - viewHalf = this.getSize().divideBy(2), - viewBounds = new Bounds(centerPoint.subtract(viewHalf), centerPoint.add(viewHalf)), - offset = this._getBoundsOffset(viewBounds, bounds, zoom); - - // If offset is less than a pixel, ignore. - // This prevents unstable projections from getting into - // an infinite loop of tiny offsets. - if (offset.round().equals([0, 0])) { - return center; - } - - return this.unproject(centerPoint.add(offset), zoom); - }, - - // adjust offset for view to get inside bounds - _limitOffset: function (offset, bounds) { - if (!bounds) { return offset; } - - var viewBounds = this.getPixelBounds(), - newBounds = new Bounds(viewBounds.min.add(offset), viewBounds.max.add(offset)); - - return offset.add(this._getBoundsOffset(newBounds, bounds)); - }, - - // returns offset needed for pxBounds to get inside maxBounds at a specified zoom - _getBoundsOffset: function (pxBounds, maxBounds, zoom) { - var projectedMaxBounds = toBounds( - this.project(maxBounds.getNorthEast(), zoom), - this.project(maxBounds.getSouthWest(), zoom) - ), - minOffset = projectedMaxBounds.min.subtract(pxBounds.min), - maxOffset = projectedMaxBounds.max.subtract(pxBounds.max), - - dx = this._rebound(minOffset.x, -maxOffset.x), - dy = this._rebound(minOffset.y, -maxOffset.y); - - return new Point(dx, dy); - }, - - _rebound: function (left, right) { - return left + right > 0 ? - Math.round(left - right) / 2 : - Math.max(0, Math.ceil(left)) - Math.max(0, Math.floor(right)); - }, - - _limitZoom: function (zoom) { - var min = this.getMinZoom(), - max = this.getMaxZoom(), - snap = any3d ? this.options.zoomSnap : 1; - if (snap) { - zoom = Math.round(zoom / snap) * snap; - } - return Math.max(min, Math.min(max, zoom)); - }, - - _onPanTransitionStep: function () { - this.fire('move'); - }, - - _onPanTransitionEnd: function () { - removeClass(this._mapPane, 'leaflet-pan-anim'); - this.fire('moveend'); - }, - - _tryAnimatedPan: function (center, options) { - // difference between the new and current centers in pixels - var offset = this._getCenterOffset(center)._trunc(); - - // don't animate too far unless animate: true specified in options - if ((options && options.animate) !== true && !this.getSize().contains(offset)) { return false; } - - this.panBy(offset, options); - - return true; - }, - - _createAnimProxy: function () { - - var proxy = this._proxy = create$1('div', 'leaflet-proxy leaflet-zoom-animated'); - this._panes.mapPane.appendChild(proxy); - - this.on('zoomanim', function (e) { - var prop = TRANSFORM, - transform = this._proxy.style[prop]; - - setTransform(this._proxy, this.project(e.center, e.zoom), this.getZoomScale(e.zoom, 1)); - - // workaround for case when transform is the same and so transitionend event is not fired - if (transform === this._proxy.style[prop] && this._animatingZoom) { - this._onZoomTransitionEnd(); - } - }, this); - - this.on('load moveend', this._animMoveEnd, this); - - this._on('unload', this._destroyAnimProxy, this); - }, - - _destroyAnimProxy: function () { - remove(this._proxy); - this.off('load moveend', this._animMoveEnd, this); - delete this._proxy; - }, - - _animMoveEnd: function () { - var c = this.getCenter(), - z = this.getZoom(); - setTransform(this._proxy, this.project(c, z), this.getZoomScale(z, 1)); - }, - - _catchTransitionEnd: function (e) { - if (this._animatingZoom && e.propertyName.indexOf('transform') >= 0) { - this._onZoomTransitionEnd(); - } - }, - - _nothingToAnimate: function () { - return !this._container.getElementsByClassName('leaflet-zoom-animated').length; - }, - - _tryAnimatedZoom: function (center, zoom, options) { - - if (this._animatingZoom) { return true; } - - options = options || {}; - - // don't animate if disabled, not supported or zoom difference is too large - if (!this._zoomAnimated || options.animate === false || this._nothingToAnimate() || - Math.abs(zoom - this._zoom) > this.options.zoomAnimationThreshold) { return false; } - - // offset is the pixel coords of the zoom origin relative to the current center - var scale = this.getZoomScale(zoom), - offset = this._getCenterOffset(center)._divideBy(1 - 1 / scale); - - // don't animate if the zoom origin isn't within one screen from the current center, unless forced - if (options.animate !== true && !this.getSize().contains(offset)) { return false; } - - requestAnimFrame(function () { - this - ._moveStart(true, false) - ._animateZoom(center, zoom, true); - }, this); - - return true; - }, - - _animateZoom: function (center, zoom, startAnim, noUpdate) { - if (!this._mapPane) { return; } - - if (startAnim) { - this._animatingZoom = true; - - // remember what center/zoom to set after animation - this._animateToCenter = center; - this._animateToZoom = zoom; - - addClass(this._mapPane, 'leaflet-zoom-anim'); - } - - // @section Other Events - // @event zoomanim: ZoomAnimEvent - // Fired at least once per zoom animation. For continuous zoom, like pinch zooming, fired once per frame during zoom. - this.fire('zoomanim', { - center: center, - zoom: zoom, - noUpdate: noUpdate - }); - - // Work around webkit not firing 'transitionend', see https://github.com/Leaflet/Leaflet/issues/3689, 2693 - setTimeout(bind(this._onZoomTransitionEnd, this), 250); - }, - - _onZoomTransitionEnd: function () { - if (!this._animatingZoom) { return; } - - if (this._mapPane) { - removeClass(this._mapPane, 'leaflet-zoom-anim'); - } - - this._animatingZoom = false; - - this._move(this._animateToCenter, this._animateToZoom); - - // This anim frame should prevent an obscure iOS webkit tile loading race condition. - requestAnimFrame(function () { - this._moveEnd(true); - }, this); - } - }); - - // @section - - // @factory L.map(id: String, options?: Map options) - // Instantiates a map object given the DOM ID of a `
` element - // and optionally an object literal with `Map options`. - // - // @alternative - // @factory L.map(el: HTMLElement, options?: Map options) - // Instantiates a map object given an instance of a `
` HTML element - // and optionally an object literal with `Map options`. - function createMap(id, options) { - return new Map(id, options); - } - - /* - * @class Control - * @aka L.Control - * @inherits Class - * - * L.Control is a base class for implementing map controls. Handles positioning. - * All other controls extend from this class. - */ - - var Control = Class.extend({ - // @section - // @aka Control options - options: { - // @option position: String = 'topright' - // The position of the control (one of the map corners). Possible values are `'topleft'`, - // `'topright'`, `'bottomleft'` or `'bottomright'` - position: 'topright' - }, - - initialize: function (options) { - setOptions(this, options); - }, - - /* @section - * Classes extending L.Control will inherit the following methods: - * - * @method getPosition: string - * Returns the position of the control. - */ - getPosition: function () { - return this.options.position; - }, - - // @method setPosition(position: string): this - // Sets the position of the control. - setPosition: function (position) { - var map = this._map; - - if (map) { - map.removeControl(this); - } - - this.options.position = position; - - if (map) { - map.addControl(this); - } - - return this; - }, - - // @method getContainer: HTMLElement - // Returns the HTMLElement that contains the control. - getContainer: function () { - return this._container; - }, - - // @method addTo(map: Map): this - // Adds the control to the given map. - addTo: function (map) { - this.remove(); - this._map = map; - - var container = this._container = this.onAdd(map), - pos = this.getPosition(), - corner = map._controlCorners[pos]; - - addClass(container, 'leaflet-control'); - - if (pos.indexOf('bottom') !== -1) { - corner.insertBefore(container, corner.firstChild); - } else { - corner.appendChild(container); - } - - this._map.on('unload', this.remove, this); - - return this; - }, - - // @method remove: this - // Removes the control from the map it is currently active on. - remove: function () { - if (!this._map) { - return this; - } - - remove(this._container); - - if (this.onRemove) { - this.onRemove(this._map); - } - - this._map.off('unload', this.remove, this); - this._map = null; - - return this; - }, - - _refocusOnMap: function (e) { - // if map exists and event is not a keyboard event - if (this._map && e && e.screenX > 0 && e.screenY > 0) { - this._map.getContainer().focus(); - } - } - }); - - var control = function (options) { - return new Control(options); - }; - - /* @section Extension methods - * @uninheritable - * - * Every control should extend from `L.Control` and (re-)implement the following methods. - * - * @method onAdd(map: Map): HTMLElement - * Should return the container DOM element for the control and add listeners on relevant map events. Called on [`control.addTo(map)`](#control-addTo). - * - * @method onRemove(map: Map) - * Optional method. Should contain all clean up code that removes the listeners previously added in [`onAdd`](#control-onadd). Called on [`control.remove()`](#control-remove). - */ - - /* @namespace Map - * @section Methods for Layers and Controls - */ - Map.include({ - // @method addControl(control: Control): this - // Adds the given control to the map - addControl: function (control) { - control.addTo(this); - return this; - }, - - // @method removeControl(control: Control): this - // Removes the given control from the map - removeControl: function (control) { - control.remove(); - return this; - }, - - _initControlPos: function () { - var corners = this._controlCorners = {}, - l = 'leaflet-', - container = this._controlContainer = - create$1('div', l + 'control-container', this._container); - - function createCorner(vSide, hSide) { - var className = l + vSide + ' ' + l + hSide; - - corners[vSide + hSide] = create$1('div', className, container); - } - - createCorner('top', 'left'); - createCorner('top', 'right'); - createCorner('bottom', 'left'); - createCorner('bottom', 'right'); - }, - - _clearControlPos: function () { - for (var i in this._controlCorners) { - remove(this._controlCorners[i]); - } - remove(this._controlContainer); - delete this._controlCorners; - delete this._controlContainer; - } - }); - - /* - * @class Control.Layers - * @aka L.Control.Layers - * @inherits Control - * - * The layers control gives users the ability to switch between different base layers and switch overlays on/off (check out the [detailed example](http://leafletjs.com/examples/layers-control/)). Extends `Control`. - * - * @example - * - * ```js - * var baseLayers = { - * "Mapbox": mapbox, - * "OpenStreetMap": osm - * }; - * - * var overlays = { - * "Marker": marker, - * "Roads": roadsLayer - * }; - * - * L.control.layers(baseLayers, overlays).addTo(map); - * ``` - * - * The `baseLayers` and `overlays` parameters are object literals with layer names as keys and `Layer` objects as values: - * - * ```js - * { - * "": layer1, - * "": layer2 - * } - * ``` - * - * The layer names can contain HTML, which allows you to add additional styling to the items: - * - * ```js - * {" My Layer": myLayer} - * ``` - */ - - var Layers = Control.extend({ - // @section - // @aka Control.Layers options - options: { - // @option collapsed: Boolean = true - // If `true`, the control will be collapsed into an icon and expanded on mouse hover or touch. - collapsed: true, - position: 'topright', - - // @option autoZIndex: Boolean = true - // If `true`, the control will assign zIndexes in increasing order to all of its layers so that the order is preserved when switching them on/off. - autoZIndex: true, - - // @option hideSingleBase: Boolean = false - // If `true`, the base layers in the control will be hidden when there is only one. - hideSingleBase: false, - - // @option sortLayers: Boolean = false - // Whether to sort the layers. When `false`, layers will keep the order - // in which they were added to the control. - sortLayers: false, - - // @option sortFunction: Function = * - // A [compare function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) - // that will be used for sorting the layers, when `sortLayers` is `true`. - // The function receives both the `L.Layer` instances and their names, as in - // `sortFunction(layerA, layerB, nameA, nameB)`. - // By default, it sorts layers alphabetically by their name. - sortFunction: function (layerA, layerB, nameA, nameB) { - return nameA < nameB ? -1 : (nameB < nameA ? 1 : 0); - } - }, - - initialize: function (baseLayers, overlays, options) { - setOptions(this, options); - - this._layerControlInputs = []; - this._layers = []; - this._lastZIndex = 0; - this._handlingClick = false; - - for (var i in baseLayers) { - this._addLayer(baseLayers[i], i); - } - - for (i in overlays) { - this._addLayer(overlays[i], i, true); - } - }, - - onAdd: function (map) { - this._initLayout(); - this._update(); - - this._map = map; - map.on('zoomend', this._checkDisabledLayers, this); - - for (var i = 0; i < this._layers.length; i++) { - this._layers[i].layer.on('add remove', this._onLayerChange, this); - } - - return this._container; - }, - - addTo: function (map) { - Control.prototype.addTo.call(this, map); - // Trigger expand after Layers Control has been inserted into DOM so that is now has an actual height. - return this._expandIfNotCollapsed(); - }, - - onRemove: function () { - this._map.off('zoomend', this._checkDisabledLayers, this); - - for (var i = 0; i < this._layers.length; i++) { - this._layers[i].layer.off('add remove', this._onLayerChange, this); - } - }, - - // @method addBaseLayer(layer: Layer, name: String): this - // Adds a base layer (radio button entry) with the given name to the control. - addBaseLayer: function (layer, name) { - this._addLayer(layer, name); - return (this._map) ? this._update() : this; - }, - - // @method addOverlay(layer: Layer, name: String): this - // Adds an overlay (checkbox entry) with the given name to the control. - addOverlay: function (layer, name) { - this._addLayer(layer, name, true); - return (this._map) ? this._update() : this; - }, - - // @method removeLayer(layer: Layer): this - // Remove the given layer from the control. - removeLayer: function (layer) { - layer.off('add remove', this._onLayerChange, this); - - var obj = this._getLayer(stamp(layer)); - if (obj) { - this._layers.splice(this._layers.indexOf(obj), 1); - } - return (this._map) ? this._update() : this; - }, - - // @method expand(): this - // Expand the control container if collapsed. - expand: function () { - addClass(this._container, 'leaflet-control-layers-expanded'); - this._section.style.height = null; - var acceptableHeight = this._map.getSize().y - (this._container.offsetTop + 50); - if (acceptableHeight < this._section.clientHeight) { - addClass(this._section, 'leaflet-control-layers-scrollbar'); - this._section.style.height = acceptableHeight + 'px'; - } else { - removeClass(this._section, 'leaflet-control-layers-scrollbar'); - } - this._checkDisabledLayers(); - return this; - }, - - // @method collapse(): this - // Collapse the control container if expanded. - collapse: function () { - removeClass(this._container, 'leaflet-control-layers-expanded'); - return this; - }, - - _initLayout: function () { - var className = 'leaflet-control-layers', - container = this._container = create$1('div', className), - collapsed = this.options.collapsed; - - // makes this work on IE touch devices by stopping it from firing a mouseout event when the touch is released - container.setAttribute('aria-haspopup', true); - - disableClickPropagation(container); - disableScrollPropagation(container); - - var section = this._section = create$1('section', className + '-list'); - - if (collapsed) { - this._map.on('click', this.collapse, this); - - if (!android) { - on(container, { - mouseenter: this.expand, - mouseleave: this.collapse - }, this); - } - } - - var link = this._layersLink = create$1('a', className + '-toggle', container); - link.href = '#'; - link.title = 'Layers'; - - if (touch) { - on(link, 'click', stop); - on(link, 'click', this.expand, this); - } else { - on(link, 'focus', this.expand, this); - } - - if (!collapsed) { - this.expand(); - } - - this._baseLayersList = create$1('div', className + '-base', section); - this._separator = create$1('div', className + '-separator', section); - this._overlaysList = create$1('div', className + '-overlays', section); - - container.appendChild(section); - }, - - _getLayer: function (id) { - for (var i = 0; i < this._layers.length; i++) { - - if (this._layers[i] && stamp(this._layers[i].layer) === id) { - return this._layers[i]; - } - } - }, - - _addLayer: function (layer, name, overlay) { - if (this._map) { - layer.on('add remove', this._onLayerChange, this); - } - - this._layers.push({ - layer: layer, - name: name, - overlay: overlay - }); - - if (this.options.sortLayers) { - this._layers.sort(bind(function (a, b) { - return this.options.sortFunction(a.layer, b.layer, a.name, b.name); - }, this)); - } - - if (this.options.autoZIndex && layer.setZIndex) { - this._lastZIndex++; - layer.setZIndex(this._lastZIndex); - } - - this._expandIfNotCollapsed(); - }, - - _update: function () { - if (!this._container) { return this; } - - empty(this._baseLayersList); - empty(this._overlaysList); - - this._layerControlInputs = []; - var baseLayersPresent, overlaysPresent, i, obj, baseLayersCount = 0; - - for (i = 0; i < this._layers.length; i++) { - obj = this._layers[i]; - this._addItem(obj); - overlaysPresent = overlaysPresent || obj.overlay; - baseLayersPresent = baseLayersPresent || !obj.overlay; - baseLayersCount += !obj.overlay ? 1 : 0; - } - - // Hide base layers section if there's only one layer. - if (this.options.hideSingleBase) { - baseLayersPresent = baseLayersPresent && baseLayersCount > 1; - this._baseLayersList.style.display = baseLayersPresent ? '' : 'none'; - } - - this._separator.style.display = overlaysPresent && baseLayersPresent ? '' : 'none'; - - return this; - }, - - _onLayerChange: function (e) { - if (!this._handlingClick) { - this._update(); - } - - var obj = this._getLayer(stamp(e.target)); - - // @namespace Map - // @section Layer events - // @event baselayerchange: LayersControlEvent - // Fired when the base layer is changed through the [layers control](#control-layers). - // @event overlayadd: LayersControlEvent - // Fired when an overlay is selected through the [layers control](#control-layers). - // @event overlayremove: LayersControlEvent - // Fired when an overlay is deselected through the [layers control](#control-layers). - // @namespace Control.Layers - var type = obj.overlay ? - (e.type === 'add' ? 'overlayadd' : 'overlayremove') : - (e.type === 'add' ? 'baselayerchange' : null); - - if (type) { - this._map.fire(type, obj); - } - }, - - // IE7 bugs out if you create a radio dynamically, so you have to do it this hacky way (see http://bit.ly/PqYLBe) - _createRadioElement: function (name, checked) { - - var radioHtml = ''; - - var radioFragment = document.createElement('div'); - radioFragment.innerHTML = radioHtml; - - return radioFragment.firstChild; - }, - - _addItem: function (obj) { - var label = document.createElement('label'), - checked = this._map.hasLayer(obj.layer), - input; - - if (obj.overlay) { - input = document.createElement('input'); - input.type = 'checkbox'; - input.className = 'leaflet-control-layers-selector'; - input.defaultChecked = checked; - } else { - input = this._createRadioElement('leaflet-base-layers_' + stamp(this), checked); - } - - this._layerControlInputs.push(input); - input.layerId = stamp(obj.layer); - - on(input, 'click', this._onInputClick, this); - - var name = document.createElement('span'); - name.innerHTML = ' ' + obj.name; - - // Helps from preventing layer control flicker when checkboxes are disabled - // https://github.com/Leaflet/Leaflet/issues/2771 - var holder = document.createElement('div'); - - label.appendChild(holder); - holder.appendChild(input); - holder.appendChild(name); - - var container = obj.overlay ? this._overlaysList : this._baseLayersList; - container.appendChild(label); - - this._checkDisabledLayers(); - return label; - }, - - _onInputClick: function () { - var inputs = this._layerControlInputs, - input, layer; - var addedLayers = [], - removedLayers = []; - - this._handlingClick = true; - - for (var i = inputs.length - 1; i >= 0; i--) { - input = inputs[i]; - layer = this._getLayer(input.layerId).layer; - - if (input.checked) { - addedLayers.push(layer); - } else if (!input.checked) { - removedLayers.push(layer); - } - } - - // Bugfix issue 2318: Should remove all old layers before readding new ones - for (i = 0; i < removedLayers.length; i++) { - if (this._map.hasLayer(removedLayers[i])) { - this._map.removeLayer(removedLayers[i]); - } - } - for (i = 0; i < addedLayers.length; i++) { - if (!this._map.hasLayer(addedLayers[i])) { - this._map.addLayer(addedLayers[i]); - } - } - - this._handlingClick = false; - - this._refocusOnMap(); - }, - - _checkDisabledLayers: function () { - var inputs = this._layerControlInputs, - input, - layer, - zoom = this._map.getZoom(); - - for (var i = inputs.length - 1; i >= 0; i--) { - input = inputs[i]; - layer = this._getLayer(input.layerId).layer; - input.disabled = (layer.options.minZoom !== undefined && zoom < layer.options.minZoom) || - (layer.options.maxZoom !== undefined && zoom > layer.options.maxZoom); - - } - }, - - _expandIfNotCollapsed: function () { - if (this._map && !this.options.collapsed) { - this.expand(); - } - return this; - }, - - _expand: function () { - // Backward compatibility, remove me in 1.1. - return this.expand(); - }, - - _collapse: function () { - // Backward compatibility, remove me in 1.1. - return this.collapse(); - } - - }); - - - // @factory L.control.layers(baselayers?: Object, overlays?: Object, options?: Control.Layers options) - // Creates a layers control with the given layers. Base layers will be switched with radio buttons, while overlays will be switched with checkboxes. Note that all base layers should be passed in the base layers object, but only one should be added to the map during map instantiation. - var layers = function (baseLayers, overlays, options) { - return new Layers(baseLayers, overlays, options); - }; - - /* - * @class Control.Zoom - * @aka L.Control.Zoom - * @inherits Control - * - * A basic zoom control with two buttons (zoom in and zoom out). It is put on the map by default unless you set its [`zoomControl` option](#map-zoomcontrol) to `false`. Extends `Control`. - */ - - var Zoom = Control.extend({ - // @section - // @aka Control.Zoom options - options: { - position: 'topleft', - - // @option zoomInText: String = '+' - // The text set on the 'zoom in' button. - zoomInText: '+', - - // @option zoomInTitle: String = 'Zoom in' - // The title set on the 'zoom in' button. - zoomInTitle: 'Zoom in', - - // @option zoomOutText: String = '−' - // The text set on the 'zoom out' button. - zoomOutText: '−', - - // @option zoomOutTitle: String = 'Zoom out' - // The title set on the 'zoom out' button. - zoomOutTitle: 'Zoom out' - }, - - onAdd: function (map) { - var zoomName = 'leaflet-control-zoom', - container = create$1('div', zoomName + ' leaflet-bar'), - options = this.options; - - this._zoomInButton = this._createButton(options.zoomInText, options.zoomInTitle, - zoomName + '-in', container, this._zoomIn); - this._zoomOutButton = this._createButton(options.zoomOutText, options.zoomOutTitle, - zoomName + '-out', container, this._zoomOut); - - this._updateDisabled(); - map.on('zoomend zoomlevelschange', this._updateDisabled, this); - - return container; - }, - - onRemove: function (map) { - map.off('zoomend zoomlevelschange', this._updateDisabled, this); - }, - - disable: function () { - this._disabled = true; - this._updateDisabled(); - return this; - }, - - enable: function () { - this._disabled = false; - this._updateDisabled(); - return this; - }, - - _zoomIn: function (e) { - if (!this._disabled && this._map._zoom < this._map.getMaxZoom()) { - this._map.zoomIn(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1)); - } - }, - - _zoomOut: function (e) { - if (!this._disabled && this._map._zoom > this._map.getMinZoom()) { - this._map.zoomOut(this._map.options.zoomDelta * (e.shiftKey ? 3 : 1)); - } - }, - - _createButton: function (html, title, className, container, fn) { - var link = create$1('a', className, container); - link.innerHTML = html; - link.href = '#'; - link.title = title; - - /* - * Will force screen readers like VoiceOver to read this as "Zoom in - button" - */ - link.setAttribute('role', 'button'); - link.setAttribute('aria-label', title); - - disableClickPropagation(link); - on(link, 'click', stop); - on(link, 'click', fn, this); - on(link, 'click', this._refocusOnMap, this); - - return link; - }, - - _updateDisabled: function () { - var map = this._map, - className = 'leaflet-disabled'; - - removeClass(this._zoomInButton, className); - removeClass(this._zoomOutButton, className); - - if (this._disabled || map._zoom === map.getMinZoom()) { - addClass(this._zoomOutButton, className); - } - if (this._disabled || map._zoom === map.getMaxZoom()) { - addClass(this._zoomInButton, className); - } - } - }); - - // @namespace Map - // @section Control options - // @option zoomControl: Boolean = true - // Whether a [zoom control](#control-zoom) is added to the map by default. - Map.mergeOptions({ - zoomControl: true - }); - - Map.addInitHook(function () { - if (this.options.zoomControl) { - // @section Controls - // @property zoomControl: Control.Zoom - // The default zoom control (only available if the - // [`zoomControl` option](#map-zoomcontrol) was `true` when creating the map). - this.zoomControl = new Zoom(); - this.addControl(this.zoomControl); - } - }); - - // @namespace Control.Zoom - // @factory L.control.zoom(options: Control.Zoom options) - // Creates a zoom control - var zoom = function (options) { - return new Zoom(options); - }; - - /* - * @class Control.Scale - * @aka L.Control.Scale - * @inherits Control - * - * A simple scale control that shows the scale of the current center of screen in metric (m/km) and imperial (mi/ft) systems. Extends `Control`. - * - * @example - * - * ```js - * L.control.scale().addTo(map); - * ``` - */ - - var Scale = Control.extend({ - // @section - // @aka Control.Scale options - options: { - position: 'bottomleft', - - // @option maxWidth: Number = 100 - // Maximum width of the control in pixels. The width is set dynamically to show round values (e.g. 100, 200, 500). - maxWidth: 100, - - // @option metric: Boolean = True - // Whether to show the metric scale line (m/km). - metric: true, - - // @option imperial: Boolean = True - // Whether to show the imperial scale line (mi/ft). - imperial: true - - // @option updateWhenIdle: Boolean = false - // If `true`, the control is updated on [`moveend`](#map-moveend), otherwise it's always up-to-date (updated on [`move`](#map-move)). - }, - - onAdd: function (map) { - var className = 'leaflet-control-scale', - container = create$1('div', className), - options = this.options; - - this._addScales(options, className + '-line', container); - - map.on(options.updateWhenIdle ? 'moveend' : 'move', this._update, this); - map.whenReady(this._update, this); - - return container; - }, - - onRemove: function (map) { - map.off(this.options.updateWhenIdle ? 'moveend' : 'move', this._update, this); - }, - - _addScales: function (options, className, container) { - if (options.metric) { - this._mScale = create$1('div', className, container); - } - if (options.imperial) { - this._iScale = create$1('div', className, container); - } - }, - - _update: function () { - var map = this._map, - y = map.getSize().y / 2; - - var maxMeters = map.distance( - map.containerPointToLatLng([0, y]), - map.containerPointToLatLng([this.options.maxWidth, y])); - - this._updateScales(maxMeters); - }, - - _updateScales: function (maxMeters) { - if (this.options.metric && maxMeters) { - this._updateMetric(maxMeters); - } - if (this.options.imperial && maxMeters) { - this._updateImperial(maxMeters); - } - }, - - _updateMetric: function (maxMeters) { - var meters = this._getRoundNum(maxMeters), - label = meters < 1000 ? meters + ' m' : (meters / 1000) + ' km'; - - this._updateScale(this._mScale, label, meters / maxMeters); - }, - - _updateImperial: function (maxMeters) { - var maxFeet = maxMeters * 3.2808399, - maxMiles, miles, feet; - - if (maxFeet > 5280) { - maxMiles = maxFeet / 5280; - miles = this._getRoundNum(maxMiles); - this._updateScale(this._iScale, miles + ' mi', miles / maxMiles); - - } else { - feet = this._getRoundNum(maxFeet); - this._updateScale(this._iScale, feet + ' ft', feet / maxFeet); - } - }, - - _updateScale: function (scale, text, ratio) { - scale.style.width = Math.round(this.options.maxWidth * ratio) + 'px'; - scale.innerHTML = text; - }, - - _getRoundNum: function (num) { - var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1), - d = num / pow10; - - d = d >= 10 ? 10 : - d >= 5 ? 5 : - d >= 3 ? 3 : - d >= 2 ? 2 : 1; - - return pow10 * d; - } - }); - - - // @factory L.control.scale(options?: Control.Scale options) - // Creates an scale control with the given options. - var scale = function (options) { - return new Scale(options); - }; - - /* - * @class Control.Attribution - * @aka L.Control.Attribution - * @inherits Control - * - * The attribution control allows you to display attribution data in a small text box on a map. It is put on the map by default unless you set its [`attributionControl` option](#map-attributioncontrol) to `false`, and it fetches attribution texts from layers with the [`getAttribution` method](#layer-getattribution) automatically. Extends Control. - */ - - var Attribution = Control.extend({ - // @section - // @aka Control.Attribution options - options: { - position: 'bottomright', - - // @option prefix: String = 'Leaflet' - // The HTML text shown before the attributions. Pass `false` to disable. - prefix: 'Leaflet' - }, - - initialize: function (options) { - setOptions(this, options); - - this._attributions = {}; - }, - - onAdd: function (map) { - map.attributionControl = this; - this._container = create$1('div', 'leaflet-control-attribution'); - disableClickPropagation(this._container); - - // TODO ugly, refactor - for (var i in map._layers) { - if (map._layers[i].getAttribution) { - this.addAttribution(map._layers[i].getAttribution()); - } - } - - this._update(); - - return this._container; - }, - - // @method setPrefix(prefix: String): this - // Sets the text before the attributions. - setPrefix: function (prefix) { - this.options.prefix = prefix; - this._update(); - return this; - }, - - // @method addAttribution(text: String): this - // Adds an attribution text (e.g. `'Vector data © Mapbox'`). - addAttribution: function (text) { - if (!text) { return this; } - - if (!this._attributions[text]) { - this._attributions[text] = 0; - } - this._attributions[text]++; - - this._update(); - - return this; - }, - - // @method removeAttribution(text: String): this - // Removes an attribution text. - removeAttribution: function (text) { - if (!text) { return this; } - - if (this._attributions[text]) { - this._attributions[text]--; - this._update(); - } - - return this; - }, - - _update: function () { - if (!this._map) { return; } - - var attribs = []; - - for (var i in this._attributions) { - if (this._attributions[i]) { - attribs.push(i); - } - } - - var prefixAndAttribs = []; - - if (this.options.prefix) { - prefixAndAttribs.push(this.options.prefix); - } - if (attribs.length) { - prefixAndAttribs.push(attribs.join(', ')); - } - - this._container.innerHTML = prefixAndAttribs.join(' | '); - } - }); - - // @namespace Map - // @section Control options - // @option attributionControl: Boolean = true - // Whether a [attribution control](#control-attribution) is added to the map by default. - Map.mergeOptions({ - attributionControl: true - }); - - Map.addInitHook(function () { - if (this.options.attributionControl) { - new Attribution().addTo(this); - } - }); - - // @namespace Control.Attribution - // @factory L.control.attribution(options: Control.Attribution options) - // Creates an attribution control. - var attribution = function (options) { - return new Attribution(options); - }; - - Control.Layers = Layers; - Control.Zoom = Zoom; - Control.Scale = Scale; - Control.Attribution = Attribution; - - control.layers = layers; - control.zoom = zoom; - control.scale = scale; - control.attribution = attribution; - - /* - L.Handler is a base class for handler classes that are used internally to inject - interaction features like dragging to classes like Map and Marker. - */ - - // @class Handler - // @aka L.Handler - // Abstract class for map interaction handlers - - var Handler = Class.extend({ - initialize: function (map) { - this._map = map; - }, - - // @method enable(): this - // Enables the handler - enable: function () { - if (this._enabled) { return this; } - - this._enabled = true; - this.addHooks(); - return this; - }, - - // @method disable(): this - // Disables the handler - disable: function () { - if (!this._enabled) { return this; } - - this._enabled = false; - this.removeHooks(); - return this; - }, - - // @method enabled(): Boolean - // Returns `true` if the handler is enabled - enabled: function () { - return !!this._enabled; - } - - // @section Extension methods - // Classes inheriting from `Handler` must implement the two following methods: - // @method addHooks() - // Called when the handler is enabled, should add event hooks. - // @method removeHooks() - // Called when the handler is disabled, should remove the event hooks added previously. - }); - - // @section There is static function which can be called without instantiating L.Handler: - // @function addTo(map: Map, name: String): this - // Adds a new Handler to the given map with the given name. - Handler.addTo = function (map, name) { - map.addHandler(name, this); - return this; - }; - - var Mixin = {Events: Events}; - - /* - * @class Draggable - * @aka L.Draggable - * @inherits Evented - * - * A class for making DOM elements draggable (including touch support). - * Used internally for map and marker dragging. Only works for elements - * that were positioned with [`L.DomUtil.setPosition`](#domutil-setposition). - * - * @example - * ```js - * var draggable = new L.Draggable(elementToDrag); - * draggable.enable(); - * ``` - */ - - var START = touch ? 'touchstart mousedown' : 'mousedown'; - var END = { - mousedown: 'mouseup', - touchstart: 'touchend', - pointerdown: 'touchend', - MSPointerDown: 'touchend' - }; - var MOVE = { - mousedown: 'mousemove', - touchstart: 'touchmove', - pointerdown: 'touchmove', - MSPointerDown: 'touchmove' - }; - - - var Draggable = Evented.extend({ - - options: { - // @section - // @aka Draggable options - // @option clickTolerance: Number = 3 - // The max number of pixels a user can shift the mouse pointer during a click - // for it to be considered a valid click (as opposed to a mouse drag). - clickTolerance: 3 - }, - - // @constructor L.Draggable(el: HTMLElement, dragHandle?: HTMLElement, preventOutline?: Boolean, options?: Draggable options) - // Creates a `Draggable` object for moving `el` when you start dragging the `dragHandle` element (equals `el` itself by default). - initialize: function (element, dragStartTarget, preventOutline$$1, options) { - setOptions(this, options); - - this._element = element; - this._dragStartTarget = dragStartTarget || element; - this._preventOutline = preventOutline$$1; - }, - - // @method enable() - // Enables the dragging ability - enable: function () { - if (this._enabled) { return; } - - on(this._dragStartTarget, START, this._onDown, this); - - this._enabled = true; - }, - - // @method disable() - // Disables the dragging ability - disable: function () { - if (!this._enabled) { return; } - - // If we're currently dragging this draggable, - // disabling it counts as first ending the drag. - if (Draggable._dragging === this) { - this.finishDrag(); - } - - off(this._dragStartTarget, START, this._onDown, this); - - this._enabled = false; - this._moved = false; - }, - - _onDown: function (e) { - // Ignore simulated events, since we handle both touch and - // mouse explicitly; otherwise we risk getting duplicates of - // touch events, see #4315. - // Also ignore the event if disabled; this happens in IE11 - // under some circumstances, see #3666. - if (e._simulated || !this._enabled) { return; } - - this._moved = false; - - if (hasClass(this._element, 'leaflet-zoom-anim')) { return; } - - if (Draggable._dragging || e.shiftKey || ((e.which !== 1) && (e.button !== 1) && !e.touches)) { return; } - Draggable._dragging = this; // Prevent dragging multiple objects at once. - - if (this._preventOutline) { - preventOutline(this._element); - } - - disableImageDrag(); - disableTextSelection(); - - if (this._moving) { return; } - - // @event down: Event - // Fired when a drag is about to start. - this.fire('down'); - - var first = e.touches ? e.touches[0] : e, - sizedParent = getSizedParentNode(this._element); - - this._startPoint = new Point(first.clientX, first.clientY); - - // Cache the scale, so that we can continuously compensate for it during drag (_onMove). - this._parentScale = getScale(sizedParent); - - on(document, MOVE[e.type], this._onMove, this); - on(document, END[e.type], this._onUp, this); - }, - - _onMove: function (e) { - // Ignore simulated events, since we handle both touch and - // mouse explicitly; otherwise we risk getting duplicates of - // touch events, see #4315. - // Also ignore the event if disabled; this happens in IE11 - // under some circumstances, see #3666. - if (e._simulated || !this._enabled) { return; } - - if (e.touches && e.touches.length > 1) { - this._moved = true; - return; - } - - var first = (e.touches && e.touches.length === 1 ? e.touches[0] : e), - offset = new Point(first.clientX, first.clientY)._subtract(this._startPoint); - - if (!offset.x && !offset.y) { return; } - if (Math.abs(offset.x) + Math.abs(offset.y) < this.options.clickTolerance) { return; } - - // We assume that the parent container's position, border and scale do not change for the duration of the drag. - // Therefore there is no need to account for the position and border (they are eliminated by the subtraction) - // and we can use the cached value for the scale. - offset.x /= this._parentScale.x; - offset.y /= this._parentScale.y; - - preventDefault(e); - - if (!this._moved) { - // @event dragstart: Event - // Fired when a drag starts - this.fire('dragstart'); - - this._moved = true; - this._startPos = getPosition(this._element).subtract(offset); - - addClass(document.body, 'leaflet-dragging'); - - this._lastTarget = e.target || e.srcElement; - // IE and Edge do not give the element, so fetch it - // if necessary - if (window.SVGElementInstance && this._lastTarget instanceof window.SVGElementInstance) { - this._lastTarget = this._lastTarget.correspondingUseElement; - } - addClass(this._lastTarget, 'leaflet-drag-target'); - } - - this._newPos = this._startPos.add(offset); - this._moving = true; - - cancelAnimFrame(this._animRequest); - this._lastEvent = e; - this._animRequest = requestAnimFrame(this._updatePosition, this, true); - }, - - _updatePosition: function () { - var e = {originalEvent: this._lastEvent}; - - // @event predrag: Event - // Fired continuously during dragging *before* each corresponding - // update of the element's position. - this.fire('predrag', e); - setPosition(this._element, this._newPos); - - // @event drag: Event - // Fired continuously during dragging. - this.fire('drag', e); - }, - - _onUp: function (e) { - // Ignore simulated events, since we handle both touch and - // mouse explicitly; otherwise we risk getting duplicates of - // touch events, see #4315. - // Also ignore the event if disabled; this happens in IE11 - // under some circumstances, see #3666. - if (e._simulated || !this._enabled) { return; } - this.finishDrag(); - }, - - finishDrag: function () { - removeClass(document.body, 'leaflet-dragging'); - - if (this._lastTarget) { - removeClass(this._lastTarget, 'leaflet-drag-target'); - this._lastTarget = null; - } - - for (var i in MOVE) { - off(document, MOVE[i], this._onMove, this); - off(document, END[i], this._onUp, this); - } - - enableImageDrag(); - enableTextSelection(); - - if (this._moved && this._moving) { - // ensure drag is not fired after dragend - cancelAnimFrame(this._animRequest); - - // @event dragend: DragEndEvent - // Fired when the drag ends. - this.fire('dragend', { - distance: this._newPos.distanceTo(this._startPos) - }); - } - - this._moving = false; - Draggable._dragging = false; - } - - }); - - /* - * @namespace LineUtil - * - * Various utility functions for polyline points processing, used by Leaflet internally to make polylines lightning-fast. - */ - - // Simplify polyline with vertex reduction and Douglas-Peucker simplification. - // Improves rendering performance dramatically by lessening the number of points to draw. - - // @function simplify(points: Point[], tolerance: Number): Point[] - // Dramatically reduces the number of points in a polyline while retaining - // its shape and returns a new array of simplified points, using the - // [Douglas-Peucker algorithm](http://en.wikipedia.org/wiki/Douglas-Peucker_algorithm). - // Used for a huge performance boost when processing/displaying Leaflet polylines for - // each zoom level and also reducing visual noise. tolerance affects the amount of - // simplification (lesser value means higher quality but slower and with more points). - // Also released as a separated micro-library [Simplify.js](http://mourner.github.com/simplify-js/). - function simplify(points, tolerance) { - if (!tolerance || !points.length) { - return points.slice(); - } - - var sqTolerance = tolerance * tolerance; - - // stage 1: vertex reduction - points = _reducePoints(points, sqTolerance); - - // stage 2: Douglas-Peucker simplification - points = _simplifyDP(points, sqTolerance); - - return points; - } - - // @function pointToSegmentDistance(p: Point, p1: Point, p2: Point): Number - // Returns the distance between point `p` and segment `p1` to `p2`. - function pointToSegmentDistance(p, p1, p2) { - return Math.sqrt(_sqClosestPointOnSegment(p, p1, p2, true)); - } - - // @function closestPointOnSegment(p: Point, p1: Point, p2: Point): Number - // Returns the closest point from a point `p` on a segment `p1` to `p2`. - function closestPointOnSegment(p, p1, p2) { - return _sqClosestPointOnSegment(p, p1, p2); - } - - // Douglas-Peucker simplification, see http://en.wikipedia.org/wiki/Douglas-Peucker_algorithm - function _simplifyDP(points, sqTolerance) { - - var len = points.length, - ArrayConstructor = typeof Uint8Array !== undefined + '' ? Uint8Array : Array, - markers = new ArrayConstructor(len); - - markers[0] = markers[len - 1] = 1; - - _simplifyDPStep(points, markers, sqTolerance, 0, len - 1); - - var i, - newPoints = []; - - for (i = 0; i < len; i++) { - if (markers[i]) { - newPoints.push(points[i]); - } - } - - return newPoints; - } - - function _simplifyDPStep(points, markers, sqTolerance, first, last) { - - var maxSqDist = 0, - index, i, sqDist; - - for (i = first + 1; i <= last - 1; i++) { - sqDist = _sqClosestPointOnSegment(points[i], points[first], points[last], true); - - if (sqDist > maxSqDist) { - index = i; - maxSqDist = sqDist; - } - } - - if (maxSqDist > sqTolerance) { - markers[index] = 1; - - _simplifyDPStep(points, markers, sqTolerance, first, index); - _simplifyDPStep(points, markers, sqTolerance, index, last); - } - } - - // reduce points that are too close to each other to a single point - function _reducePoints(points, sqTolerance) { - var reducedPoints = [points[0]]; - - for (var i = 1, prev = 0, len = points.length; i < len; i++) { - if (_sqDist(points[i], points[prev]) > sqTolerance) { - reducedPoints.push(points[i]); - prev = i; - } - } - if (prev < len - 1) { - reducedPoints.push(points[len - 1]); - } - return reducedPoints; - } - - var _lastCode; - - // @function clipSegment(a: Point, b: Point, bounds: Bounds, useLastCode?: Boolean, round?: Boolean): Point[]|Boolean - // Clips the segment a to b by rectangular bounds with the - // [Cohen-Sutherland algorithm](https://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm) - // (modifying the segment points directly!). Used by Leaflet to only show polyline - // points that are on the screen or near, increasing performance. - function clipSegment(a, b, bounds, useLastCode, round) { - var codeA = useLastCode ? _lastCode : _getBitCode(a, bounds), - codeB = _getBitCode(b, bounds), - - codeOut, p, newCode; - - // save 2nd code to avoid calculating it on the next segment - _lastCode = codeB; - - while (true) { - // if a,b is inside the clip window (trivial accept) - if (!(codeA | codeB)) { - return [a, b]; - } - - // if a,b is outside the clip window (trivial reject) - if (codeA & codeB) { - return false; - } - - // other cases - codeOut = codeA || codeB; - p = _getEdgeIntersection(a, b, codeOut, bounds, round); - newCode = _getBitCode(p, bounds); - - if (codeOut === codeA) { - a = p; - codeA = newCode; - } else { - b = p; - codeB = newCode; - } - } - } - - function _getEdgeIntersection(a, b, code, bounds, round) { - var dx = b.x - a.x, - dy = b.y - a.y, - min = bounds.min, - max = bounds.max, - x, y; - - if (code & 8) { // top - x = a.x + dx * (max.y - a.y) / dy; - y = max.y; - - } else if (code & 4) { // bottom - x = a.x + dx * (min.y - a.y) / dy; - y = min.y; - - } else if (code & 2) { // right - x = max.x; - y = a.y + dy * (max.x - a.x) / dx; - - } else if (code & 1) { // left - x = min.x; - y = a.y + dy * (min.x - a.x) / dx; - } - - return new Point(x, y, round); - } - - function _getBitCode(p, bounds) { - var code = 0; - - if (p.x < bounds.min.x) { // left - code |= 1; - } else if (p.x > bounds.max.x) { // right - code |= 2; - } - - if (p.y < bounds.min.y) { // bottom - code |= 4; - } else if (p.y > bounds.max.y) { // top - code |= 8; - } - - return code; - } - - // square distance (to avoid unnecessary Math.sqrt calls) - function _sqDist(p1, p2) { - var dx = p2.x - p1.x, - dy = p2.y - p1.y; - return dx * dx + dy * dy; - } - - // return closest point on segment or distance to that point - function _sqClosestPointOnSegment(p, p1, p2, sqDist) { - var x = p1.x, - y = p1.y, - dx = p2.x - x, - dy = p2.y - y, - dot = dx * dx + dy * dy, - t; - - if (dot > 0) { - t = ((p.x - x) * dx + (p.y - y) * dy) / dot; - - if (t > 1) { - x = p2.x; - y = p2.y; - } else if (t > 0) { - x += dx * t; - y += dy * t; - } - } - - dx = p.x - x; - dy = p.y - y; - - return sqDist ? dx * dx + dy * dy : new Point(x, y); - } - - - // @function isFlat(latlngs: LatLng[]): Boolean - // Returns true if `latlngs` is a flat array, false is nested. - function isFlat(latlngs) { - return !isArray(latlngs[0]) || (typeof latlngs[0][0] !== 'object' && typeof latlngs[0][0] !== 'undefined'); - } - - function _flat(latlngs) { - console.warn('Deprecated use of _flat, please use L.LineUtil.isFlat instead.'); - return isFlat(latlngs); - } - - var LineUtil = ({ - simplify: simplify, - pointToSegmentDistance: pointToSegmentDistance, - closestPointOnSegment: closestPointOnSegment, - clipSegment: clipSegment, - _getEdgeIntersection: _getEdgeIntersection, - _getBitCode: _getBitCode, - _sqClosestPointOnSegment: _sqClosestPointOnSegment, - isFlat: isFlat, - _flat: _flat - }); - - /* - * @namespace PolyUtil - * Various utility functions for polygon geometries. - */ - - /* @function clipPolygon(points: Point[], bounds: Bounds, round?: Boolean): Point[] - * Clips the polygon geometry defined by the given `points` by the given bounds (using the [Sutherland-Hodgman algorithm](https://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm)). - * Used by Leaflet to only show polygon points that are on the screen or near, increasing - * performance. Note that polygon points needs different algorithm for clipping - * than polyline, so there's a separate method for it. - */ - function clipPolygon(points, bounds, round) { - var clippedPoints, - edges = [1, 4, 2, 8], - i, j, k, - a, b, - len, edge, p; - - for (i = 0, len = points.length; i < len; i++) { - points[i]._code = _getBitCode(points[i], bounds); - } - - // for each edge (left, bottom, right, top) - for (k = 0; k < 4; k++) { - edge = edges[k]; - clippedPoints = []; - - for (i = 0, len = points.length, j = len - 1; i < len; j = i++) { - a = points[i]; - b = points[j]; - - // if a is inside the clip window - if (!(a._code & edge)) { - // if b is outside the clip window (a->b goes out of screen) - if (b._code & edge) { - p = _getEdgeIntersection(b, a, edge, bounds, round); - p._code = _getBitCode(p, bounds); - clippedPoints.push(p); - } - clippedPoints.push(a); - - // else if b is inside the clip window (a->b enters the screen) - } else if (!(b._code & edge)) { - p = _getEdgeIntersection(b, a, edge, bounds, round); - p._code = _getBitCode(p, bounds); - clippedPoints.push(p); - } - } - points = clippedPoints; - } - - return points; - } - - var PolyUtil = ({ - clipPolygon: clipPolygon - }); - - /* - * @namespace Projection - * @section - * Leaflet comes with a set of already defined Projections out of the box: - * - * @projection L.Projection.LonLat - * - * Equirectangular, or Plate Carree projection — the most simple projection, - * mostly used by GIS enthusiasts. Directly maps `x` as longitude, and `y` as - * latitude. Also suitable for flat worlds, e.g. game maps. Used by the - * `EPSG:4326` and `Simple` CRS. - */ - - var LonLat = { - project: function (latlng) { - return new Point(latlng.lng, latlng.lat); - }, - - unproject: function (point) { - return new LatLng(point.y, point.x); - }, - - bounds: new Bounds([-180, -90], [180, 90]) - }; - - /* - * @namespace Projection - * @projection L.Projection.Mercator - * - * Elliptical Mercator projection — more complex than Spherical Mercator. Assumes that Earth is an ellipsoid. Used by the EPSG:3395 CRS. - */ - - var Mercator = { - R: 6378137, - R_MINOR: 6356752.314245179, - - bounds: new Bounds([-20037508.34279, -15496570.73972], [20037508.34279, 18764656.23138]), - - project: function (latlng) { - var d = Math.PI / 180, - r = this.R, - y = latlng.lat * d, - tmp = this.R_MINOR / r, - e = Math.sqrt(1 - tmp * tmp), - con = e * Math.sin(y); - - var ts = Math.tan(Math.PI / 4 - y / 2) / Math.pow((1 - con) / (1 + con), e / 2); - y = -r * Math.log(Math.max(ts, 1E-10)); - - return new Point(latlng.lng * d * r, y); - }, - - unproject: function (point) { - var d = 180 / Math.PI, - r = this.R, - tmp = this.R_MINOR / r, - e = Math.sqrt(1 - tmp * tmp), - ts = Math.exp(-point.y / r), - phi = Math.PI / 2 - 2 * Math.atan(ts); - - for (var i = 0, dphi = 0.1, con; i < 15 && Math.abs(dphi) > 1e-7; i++) { - con = e * Math.sin(phi); - con = Math.pow((1 - con) / (1 + con), e / 2); - dphi = Math.PI / 2 - 2 * Math.atan(ts * con) - phi; - phi += dphi; - } - - return new LatLng(phi * d, point.x * d / r); - } - }; - - /* - * @class Projection - - * An object with methods for projecting geographical coordinates of the world onto - * a flat surface (and back). See [Map projection](http://en.wikipedia.org/wiki/Map_projection). - - * @property bounds: Bounds - * The bounds (specified in CRS units) where the projection is valid - - * @method project(latlng: LatLng): Point - * Projects geographical coordinates into a 2D point. - * Only accepts actual `L.LatLng` instances, not arrays. - - * @method unproject(point: Point): LatLng - * The inverse of `project`. Projects a 2D point into a geographical location. - * Only accepts actual `L.Point` instances, not arrays. - - * Note that the projection instances do not inherit from Leaflet's `Class` object, - * and can't be instantiated. Also, new classes can't inherit from them, - * and methods can't be added to them with the `include` function. - - */ - - var index = ({ - LonLat: LonLat, - Mercator: Mercator, - SphericalMercator: SphericalMercator - }); - - /* - * @namespace CRS - * @crs L.CRS.EPSG3395 - * - * Rarely used by some commercial tile providers. Uses Elliptical Mercator projection. - */ - var EPSG3395 = extend({}, Earth, { - code: 'EPSG:3395', - projection: Mercator, - - transformation: (function () { - var scale = 0.5 / (Math.PI * Mercator.R); - return toTransformation(scale, 0.5, -scale, 0.5); - }()) - }); - - /* - * @namespace CRS - * @crs L.CRS.EPSG4326 - * - * A common CRS among GIS enthusiasts. Uses simple Equirectangular projection. - * - * Leaflet 1.0.x complies with the [TMS coordinate scheme for EPSG:4326](https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-geodetic), - * which is a breaking change from 0.7.x behaviour. If you are using a `TileLayer` - * with this CRS, ensure that there are two 256x256 pixel tiles covering the - * whole earth at zoom level zero, and that the tile coordinate origin is (-180,+90), - * or (-180,-90) for `TileLayer`s with [the `tms` option](#tilelayer-tms) set. - */ - - var EPSG4326 = extend({}, Earth, { - code: 'EPSG:4326', - projection: LonLat, - transformation: toTransformation(1 / 180, 1, -1 / 180, 0.5) - }); - - /* - * @namespace CRS - * @crs L.CRS.Simple - * - * A simple CRS that maps longitude and latitude into `x` and `y` directly. - * May be used for maps of flat surfaces (e.g. game maps). Note that the `y` - * axis should still be inverted (going from bottom to top). `distance()` returns - * simple euclidean distance. - */ - - var Simple = extend({}, CRS, { - projection: LonLat, - transformation: toTransformation(1, 0, -1, 0), - - scale: function (zoom) { - return Math.pow(2, zoom); - }, - - zoom: function (scale) { - return Math.log(scale) / Math.LN2; - }, - - distance: function (latlng1, latlng2) { - var dx = latlng2.lng - latlng1.lng, - dy = latlng2.lat - latlng1.lat; - - return Math.sqrt(dx * dx + dy * dy); - }, - - infinite: true - }); - - CRS.Earth = Earth; - CRS.EPSG3395 = EPSG3395; - CRS.EPSG3857 = EPSG3857; - CRS.EPSG900913 = EPSG900913; - CRS.EPSG4326 = EPSG4326; - CRS.Simple = Simple; - - /* - * @class Layer - * @inherits Evented - * @aka L.Layer - * @aka ILayer - * - * A set of methods from the Layer base class that all Leaflet layers use. - * Inherits all methods, options and events from `L.Evented`. - * - * @example - * - * ```js - * var layer = L.marker(latlng).addTo(map); - * layer.addTo(map); - * layer.remove(); - * ``` - * - * @event add: Event - * Fired after the layer is added to a map - * - * @event remove: Event - * Fired after the layer is removed from a map - */ - - - var Layer = Evented.extend({ - - // Classes extending `L.Layer` will inherit the following options: - options: { - // @option pane: String = 'overlayPane' - // By default the layer will be added to the map's [overlay pane](#map-overlaypane). Overriding this option will cause the layer to be placed on another pane by default. - pane: 'overlayPane', - - // @option attribution: String = null - // String to be shown in the attribution control, e.g. "© OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers. - attribution: null, - - bubblingMouseEvents: true - }, - - /* @section - * Classes extending `L.Layer` will inherit the following methods: - * - * @method addTo(map: Map|LayerGroup): this - * Adds the layer to the given map or layer group. - */ - addTo: function (map) { - map.addLayer(this); - return this; - }, - - // @method remove: this - // Removes the layer from the map it is currently active on. - remove: function () { - return this.removeFrom(this._map || this._mapToAdd); - }, - - // @method removeFrom(map: Map): this - // Removes the layer from the given map - // - // @alternative - // @method removeFrom(group: LayerGroup): this - // Removes the layer from the given `LayerGroup` - removeFrom: function (obj) { - if (obj) { - obj.removeLayer(this); - } - return this; - }, - - // @method getPane(name? : String): HTMLElement - // Returns the `HTMLElement` representing the named pane on the map. If `name` is omitted, returns the pane for this layer. - getPane: function (name) { - return this._map.getPane(name ? (this.options[name] || name) : this.options.pane); - }, - - addInteractiveTarget: function (targetEl) { - this._map._targets[stamp(targetEl)] = this; - return this; - }, - - removeInteractiveTarget: function (targetEl) { - delete this._map._targets[stamp(targetEl)]; - return this; - }, - - // @method getAttribution: String - // Used by the `attribution control`, returns the [attribution option](#gridlayer-attribution). - getAttribution: function () { - return this.options.attribution; - }, - - _layerAdd: function (e) { - var map = e.target; - - // check in case layer gets added and then removed before the map is ready - if (!map.hasLayer(this)) { return; } - - this._map = map; - this._zoomAnimated = map._zoomAnimated; - - if (this.getEvents) { - var events = this.getEvents(); - map.on(events, this); - this.once('remove', function () { - map.off(events, this); - }, this); - } - - this.onAdd(map); - - if (this.getAttribution && map.attributionControl) { - map.attributionControl.addAttribution(this.getAttribution()); - } - - this.fire('add'); - map.fire('layeradd', {layer: this}); - } - }); - - /* @section Extension methods - * @uninheritable - * - * Every layer should extend from `L.Layer` and (re-)implement the following methods. - * - * @method onAdd(map: Map): this - * Should contain code that creates DOM elements for the layer, adds them to `map panes` where they should belong and puts listeners on relevant map events. Called on [`map.addLayer(layer)`](#map-addlayer). - * - * @method onRemove(map: Map): this - * Should contain all clean up code that removes the layer's elements from the DOM and removes listeners previously added in [`onAdd`](#layer-onadd). Called on [`map.removeLayer(layer)`](#map-removelayer). - * - * @method getEvents(): Object - * This optional method should return an object like `{ viewreset: this._reset }` for [`addEventListener`](#evented-addeventlistener). The event handlers in this object will be automatically added and removed from the map with your layer. - * - * @method getAttribution(): String - * This optional method should return a string containing HTML to be shown on the `Attribution control` whenever the layer is visible. - * - * @method beforeAdd(map: Map): this - * Optional method. Called on [`map.addLayer(layer)`](#map-addlayer), before the layer is added to the map, before events are initialized, without waiting until the map is in a usable state. Use for early initialization only. - */ - - - /* @namespace Map - * @section Layer events - * - * @event layeradd: LayerEvent - * Fired when a new layer is added to the map. - * - * @event layerremove: LayerEvent - * Fired when some layer is removed from the map - * - * @section Methods for Layers and Controls - */ - Map.include({ - // @method addLayer(layer: Layer): this - // Adds the given layer to the map - addLayer: function (layer) { - if (!layer._layerAdd) { - throw new Error('The provided object is not a Layer.'); - } - - var id = stamp(layer); - if (this._layers[id]) { return this; } - this._layers[id] = layer; - - layer._mapToAdd = this; - - if (layer.beforeAdd) { - layer.beforeAdd(this); - } - - this.whenReady(layer._layerAdd, layer); - - return this; - }, - - // @method removeLayer(layer: Layer): this - // Removes the given layer from the map. - removeLayer: function (layer) { - var id = stamp(layer); - - if (!this._layers[id]) { return this; } - - if (this._loaded) { - layer.onRemove(this); - } - - if (layer.getAttribution && this.attributionControl) { - this.attributionControl.removeAttribution(layer.getAttribution()); - } - - delete this._layers[id]; - - if (this._loaded) { - this.fire('layerremove', {layer: layer}); - layer.fire('remove'); - } - - layer._map = layer._mapToAdd = null; - - return this; - }, - - // @method hasLayer(layer: Layer): Boolean - // Returns `true` if the given layer is currently added to the map - hasLayer: function (layer) { - return !!layer && (stamp(layer) in this._layers); - }, - - /* @method eachLayer(fn: Function, context?: Object): this - * Iterates over the layers of the map, optionally specifying context of the iterator function. - * ``` - * map.eachLayer(function(layer){ - * layer.bindPopup('Hello'); - * }); - * ``` - */ - eachLayer: function (method, context) { - for (var i in this._layers) { - method.call(context, this._layers[i]); - } - return this; - }, - - _addLayers: function (layers) { - layers = layers ? (isArray(layers) ? layers : [layers]) : []; - - for (var i = 0, len = layers.length; i < len; i++) { - this.addLayer(layers[i]); - } - }, - - _addZoomLimit: function (layer) { - if (isNaN(layer.options.maxZoom) || !isNaN(layer.options.minZoom)) { - this._zoomBoundLayers[stamp(layer)] = layer; - this._updateZoomLevels(); - } - }, - - _removeZoomLimit: function (layer) { - var id = stamp(layer); - - if (this._zoomBoundLayers[id]) { - delete this._zoomBoundLayers[id]; - this._updateZoomLevels(); - } - }, - - _updateZoomLevels: function () { - var minZoom = Infinity, - maxZoom = -Infinity, - oldZoomSpan = this._getZoomSpan(); - - for (var i in this._zoomBoundLayers) { - var options = this._zoomBoundLayers[i].options; - - minZoom = options.minZoom === undefined ? minZoom : Math.min(minZoom, options.minZoom); - maxZoom = options.maxZoom === undefined ? maxZoom : Math.max(maxZoom, options.maxZoom); - } - - this._layersMaxZoom = maxZoom === -Infinity ? undefined : maxZoom; - this._layersMinZoom = minZoom === Infinity ? undefined : minZoom; - - // @section Map state change events - // @event zoomlevelschange: Event - // Fired when the number of zoomlevels on the map is changed due - // to adding or removing a layer. - if (oldZoomSpan !== this._getZoomSpan()) { - this.fire('zoomlevelschange'); - } - - if (this.options.maxZoom === undefined && this._layersMaxZoom && this.getZoom() > this._layersMaxZoom) { - this.setZoom(this._layersMaxZoom); - } - if (this.options.minZoom === undefined && this._layersMinZoom && this.getZoom() < this._layersMinZoom) { - this.setZoom(this._layersMinZoom); - } - } - }); - - /* - * @class LayerGroup - * @aka L.LayerGroup - * @inherits Layer - * - * Used to group several layers and handle them as one. If you add it to the map, - * any layers added or removed from the group will be added/removed on the map as - * well. Extends `Layer`. - * - * @example - * - * ```js - * L.layerGroup([marker1, marker2]) - * .addLayer(polyline) - * .addTo(map); - * ``` - */ - - var LayerGroup = Layer.extend({ - - initialize: function (layers, options) { - setOptions(this, options); - - this._layers = {}; - - var i, len; - - if (layers) { - for (i = 0, len = layers.length; i < len; i++) { - this.addLayer(layers[i]); - } - } - }, - - // @method addLayer(layer: Layer): this - // Adds the given layer to the group. - addLayer: function (layer) { - var id = this.getLayerId(layer); - - this._layers[id] = layer; - - if (this._map) { - this._map.addLayer(layer); - } - - return this; - }, - - // @method removeLayer(layer: Layer): this - // Removes the given layer from the group. - // @alternative - // @method removeLayer(id: Number): this - // Removes the layer with the given internal ID from the group. - removeLayer: function (layer) { - var id = layer in this._layers ? layer : this.getLayerId(layer); - - if (this._map && this._layers[id]) { - this._map.removeLayer(this._layers[id]); - } - - delete this._layers[id]; - - return this; - }, - - // @method hasLayer(layer: Layer): Boolean - // Returns `true` if the given layer is currently added to the group. - // @alternative - // @method hasLayer(id: Number): Boolean - // Returns `true` if the given internal ID is currently added to the group. - hasLayer: function (layer) { - if (!layer) { return false; } - var layerId = typeof layer === 'number' ? layer : this.getLayerId(layer); - return layerId in this._layers; - }, - - // @method clearLayers(): this - // Removes all the layers from the group. - clearLayers: function () { - return this.eachLayer(this.removeLayer, this); - }, - - // @method invoke(methodName: String, …): this - // Calls `methodName` on every layer contained in this group, passing any - // additional parameters. Has no effect if the layers contained do not - // implement `methodName`. - invoke: function (methodName) { - var args = Array.prototype.slice.call(arguments, 1), - i, layer; - - for (i in this._layers) { - layer = this._layers[i]; - - if (layer[methodName]) { - layer[methodName].apply(layer, args); - } - } - - return this; - }, - - onAdd: function (map) { - this.eachLayer(map.addLayer, map); - }, - - onRemove: function (map) { - this.eachLayer(map.removeLayer, map); - }, - - // @method eachLayer(fn: Function, context?: Object): this - // Iterates over the layers of the group, optionally specifying context of the iterator function. - // ```js - // group.eachLayer(function (layer) { - // layer.bindPopup('Hello'); - // }); - // ``` - eachLayer: function (method, context) { - for (var i in this._layers) { - method.call(context, this._layers[i]); - } - return this; - }, - - // @method getLayer(id: Number): Layer - // Returns the layer with the given internal ID. - getLayer: function (id) { - return this._layers[id]; - }, - - // @method getLayers(): Layer[] - // Returns an array of all the layers added to the group. - getLayers: function () { - var layers = []; - this.eachLayer(layers.push, layers); - return layers; - }, - - // @method setZIndex(zIndex: Number): this - // Calls `setZIndex` on every layer contained in this group, passing the z-index. - setZIndex: function (zIndex) { - return this.invoke('setZIndex', zIndex); - }, - - // @method getLayerId(layer: Layer): Number - // Returns the internal ID for a layer - getLayerId: function (layer) { - return stamp(layer); - } - }); - - - // @factory L.layerGroup(layers?: Layer[], options?: Object) - // Create a layer group, optionally given an initial set of layers and an `options` object. - var layerGroup = function (layers, options) { - return new LayerGroup(layers, options); - }; - - /* - * @class FeatureGroup - * @aka L.FeatureGroup - * @inherits LayerGroup - * - * Extended `LayerGroup` that makes it easier to do the same thing to all its member layers: - * * [`bindPopup`](#layer-bindpopup) binds a popup to all of the layers at once (likewise with [`bindTooltip`](#layer-bindtooltip)) - * * Events are propagated to the `FeatureGroup`, so if the group has an event - * handler, it will handle events from any of the layers. This includes mouse events - * and custom events. - * * Has `layeradd` and `layerremove` events - * - * @example - * - * ```js - * L.featureGroup([marker1, marker2, polyline]) - * .bindPopup('Hello world!') - * .on('click', function() { alert('Clicked on a member of the group!'); }) - * .addTo(map); - * ``` - */ - - var FeatureGroup = LayerGroup.extend({ - - addLayer: function (layer) { - if (this.hasLayer(layer)) { - return this; - } - - layer.addEventParent(this); - - LayerGroup.prototype.addLayer.call(this, layer); - - // @event layeradd: LayerEvent - // Fired when a layer is added to this `FeatureGroup` - return this.fire('layeradd', {layer: layer}); - }, - - removeLayer: function (layer) { - if (!this.hasLayer(layer)) { - return this; - } - if (layer in this._layers) { - layer = this._layers[layer]; - } - - layer.removeEventParent(this); - - LayerGroup.prototype.removeLayer.call(this, layer); - - // @event layerremove: LayerEvent - // Fired when a layer is removed from this `FeatureGroup` - return this.fire('layerremove', {layer: layer}); - }, - - // @method setStyle(style: Path options): this - // Sets the given path options to each layer of the group that has a `setStyle` method. - setStyle: function (style) { - return this.invoke('setStyle', style); - }, - - // @method bringToFront(): this - // Brings the layer group to the top of all other layers - bringToFront: function () { - return this.invoke('bringToFront'); - }, - - // @method bringToBack(): this - // Brings the layer group to the back of all other layers - bringToBack: function () { - return this.invoke('bringToBack'); - }, - - // @method getBounds(): LatLngBounds - // Returns the LatLngBounds of the Feature Group (created from bounds and coordinates of its children). - getBounds: function () { - var bounds = new LatLngBounds(); - - for (var id in this._layers) { - var layer = this._layers[id]; - bounds.extend(layer.getBounds ? layer.getBounds() : layer.getLatLng()); - } - return bounds; - } - }); - - // @factory L.featureGroup(layers?: Layer[], options?: Object) - // Create a feature group, optionally given an initial set of layers and an `options` object. - var featureGroup = function (layers, options) { - return new FeatureGroup(layers, options); - }; - - /* - * @class Icon - * @aka L.Icon - * - * Represents an icon to provide when creating a marker. - * - * @example - * - * ```js - * var myIcon = L.icon({ - * iconUrl: 'my-icon.png', - * iconRetinaUrl: 'my-icon@2x.png', - * iconSize: [38, 95], - * iconAnchor: [22, 94], - * popupAnchor: [-3, -76], - * shadowUrl: 'my-icon-shadow.png', - * shadowRetinaUrl: 'my-icon-shadow@2x.png', - * shadowSize: [68, 95], - * shadowAnchor: [22, 94] - * }); - * - * L.marker([50.505, 30.57], {icon: myIcon}).addTo(map); - * ``` - * - * `L.Icon.Default` extends `L.Icon` and is the blue icon Leaflet uses for markers by default. - * - */ - - var Icon = Class.extend({ - - /* @section - * @aka Icon options - * - * @option iconUrl: String = null - * **(required)** The URL to the icon image (absolute or relative to your script path). - * - * @option iconRetinaUrl: String = null - * The URL to a retina sized version of the icon image (absolute or relative to your - * script path). Used for Retina screen devices. - * - * @option iconSize: Point = null - * Size of the icon image in pixels. - * - * @option iconAnchor: Point = null - * The coordinates of the "tip" of the icon (relative to its top left corner). The icon - * will be aligned so that this point is at the marker's geographical location. Centered - * by default if size is specified, also can be set in CSS with negative margins. - * - * @option popupAnchor: Point = [0, 0] - * The coordinates of the point from which popups will "open", relative to the icon anchor. - * - * @option tooltipAnchor: Point = [0, 0] - * The coordinates of the point from which tooltips will "open", relative to the icon anchor. - * - * @option shadowUrl: String = null - * The URL to the icon shadow image. If not specified, no shadow image will be created. - * - * @option shadowRetinaUrl: String = null - * - * @option shadowSize: Point = null - * Size of the shadow image in pixels. - * - * @option shadowAnchor: Point = null - * The coordinates of the "tip" of the shadow (relative to its top left corner) (the same - * as iconAnchor if not specified). - * - * @option className: String = '' - * A custom class name to assign to both icon and shadow images. Empty by default. - */ - - options: { - popupAnchor: [0, 0], - tooltipAnchor: [0, 0] - }, - - initialize: function (options) { - setOptions(this, options); - }, - - // @method createIcon(oldIcon?: HTMLElement): HTMLElement - // Called internally when the icon has to be shown, returns a `` HTML element - // styled according to the options. - createIcon: function (oldIcon) { - return this._createIcon('icon', oldIcon); - }, - - // @method createShadow(oldIcon?: HTMLElement): HTMLElement - // As `createIcon`, but for the shadow beneath it. - createShadow: function (oldIcon) { - return this._createIcon('shadow', oldIcon); - }, - - _createIcon: function (name, oldIcon) { - var src = this._getIconUrl(name); - - if (!src) { - if (name === 'icon') { - throw new Error('iconUrl not set in Icon options (see the docs).'); - } - return null; - } - - var img = this._createImg(src, oldIcon && oldIcon.tagName === 'IMG' ? oldIcon : null); - this._setIconStyles(img, name); - - return img; - }, - - _setIconStyles: function (img, name) { - var options = this.options; - var sizeOption = options[name + 'Size']; - - if (typeof sizeOption === 'number') { - sizeOption = [sizeOption, sizeOption]; - } - - var size = toPoint(sizeOption), - anchor = toPoint(name === 'shadow' && options.shadowAnchor || options.iconAnchor || - size && size.divideBy(2, true)); - - img.className = 'leaflet-marker-' + name + ' ' + (options.className || ''); - - if (anchor) { - img.style.marginLeft = (-anchor.x) + 'px'; - img.style.marginTop = (-anchor.y) + 'px'; - } - - if (size) { - img.style.width = size.x + 'px'; - img.style.height = size.y + 'px'; - } - }, - - _createImg: function (src, el) { - el = el || document.createElement('img'); - el.src = src; - return el; - }, - - _getIconUrl: function (name) { - return retina && this.options[name + 'RetinaUrl'] || this.options[name + 'Url']; - } - }); - - - // @factory L.icon(options: Icon options) - // Creates an icon instance with the given options. - function icon(options) { - return new Icon(options); - } - - /* - * @miniclass Icon.Default (Icon) - * @aka L.Icon.Default - * @section - * - * A trivial subclass of `Icon`, represents the icon to use in `Marker`s when - * no icon is specified. Points to the blue marker image distributed with Leaflet - * releases. - * - * In order to customize the default icon, just change the properties of `L.Icon.Default.prototype.options` - * (which is a set of `Icon options`). - * - * If you want to _completely_ replace the default icon, override the - * `L.Marker.prototype.options.icon` with your own icon instead. - */ - - var IconDefault = Icon.extend({ - - options: { - iconUrl: 'marker-icon.png', - iconRetinaUrl: 'marker-icon-2x.png', - shadowUrl: 'marker-shadow.png', - iconSize: [25, 41], - iconAnchor: [12, 41], - popupAnchor: [1, -34], - tooltipAnchor: [16, -28], - shadowSize: [41, 41] - }, - - _getIconUrl: function (name) { - if (!IconDefault.imagePath) { // Deprecated, backwards-compatibility only - IconDefault.imagePath = this._detectIconPath(); - } - - // @option imagePath: String - // `Icon.Default` will try to auto-detect the location of the - // blue icon images. If you are placing these images in a non-standard - // way, set this option to point to the right path. - return (this.options.imagePath || IconDefault.imagePath) + Icon.prototype._getIconUrl.call(this, name); - }, - - _detectIconPath: function () { - var el = create$1('div', 'leaflet-default-icon-path', document.body); - var path = getStyle(el, 'background-image') || - getStyle(el, 'backgroundImage'); // IE8 - - document.body.removeChild(el); - - if (path === null || path.indexOf('url') !== 0) { - path = ''; - } else { - path = path.replace(/^url\(["']?/, '').replace(/marker-icon\.png["']?\)$/, ''); - } - - return path; - } - }); - - /* - * L.Handler.MarkerDrag is used internally by L.Marker to make the markers draggable. - */ - - - /* @namespace Marker - * @section Interaction handlers - * - * Interaction handlers are properties of a marker instance that allow you to control interaction behavior in runtime, enabling or disabling certain features such as dragging (see `Handler` methods). Example: - * - * ```js - * marker.dragging.disable(); - * ``` - * - * @property dragging: Handler - * Marker dragging handler (by both mouse and touch). Only valid when the marker is on the map (Otherwise set [`marker.options.draggable`](#marker-draggable)). - */ - - var MarkerDrag = Handler.extend({ - initialize: function (marker) { - this._marker = marker; - }, - - addHooks: function () { - var icon = this._marker._icon; - - if (!this._draggable) { - this._draggable = new Draggable(icon, icon, true); - } - - this._draggable.on({ - dragstart: this._onDragStart, - predrag: this._onPreDrag, - drag: this._onDrag, - dragend: this._onDragEnd - }, this).enable(); - - addClass(icon, 'leaflet-marker-draggable'); - }, - - removeHooks: function () { - this._draggable.off({ - dragstart: this._onDragStart, - predrag: this._onPreDrag, - drag: this._onDrag, - dragend: this._onDragEnd - }, this).disable(); - - if (this._marker._icon) { - removeClass(this._marker._icon, 'leaflet-marker-draggable'); - } - }, - - moved: function () { - return this._draggable && this._draggable._moved; - }, - - _adjustPan: function (e) { - var marker = this._marker, - map = marker._map, - speed = this._marker.options.autoPanSpeed, - padding = this._marker.options.autoPanPadding, - iconPos = getPosition(marker._icon), - bounds = map.getPixelBounds(), - origin = map.getPixelOrigin(); - - var panBounds = toBounds( - bounds.min._subtract(origin).add(padding), - bounds.max._subtract(origin).subtract(padding) - ); - - if (!panBounds.contains(iconPos)) { - // Compute incremental movement - var movement = toPoint( - (Math.max(panBounds.max.x, iconPos.x) - panBounds.max.x) / (bounds.max.x - panBounds.max.x) - - (Math.min(panBounds.min.x, iconPos.x) - panBounds.min.x) / (bounds.min.x - panBounds.min.x), - - (Math.max(panBounds.max.y, iconPos.y) - panBounds.max.y) / (bounds.max.y - panBounds.max.y) - - (Math.min(panBounds.min.y, iconPos.y) - panBounds.min.y) / (bounds.min.y - panBounds.min.y) - ).multiplyBy(speed); - - map.panBy(movement, {animate: false}); - - this._draggable._newPos._add(movement); - this._draggable._startPos._add(movement); - - setPosition(marker._icon, this._draggable._newPos); - this._onDrag(e); - - this._panRequest = requestAnimFrame(this._adjustPan.bind(this, e)); - } - }, - - _onDragStart: function () { - // @section Dragging events - // @event dragstart: Event - // Fired when the user starts dragging the marker. - - // @event movestart: Event - // Fired when the marker starts moving (because of dragging). - - this._oldLatLng = this._marker.getLatLng(); - - // When using ES6 imports it could not be set when `Popup` was not imported as well - this._marker.closePopup && this._marker.closePopup(); - - this._marker - .fire('movestart') - .fire('dragstart'); - }, - - _onPreDrag: function (e) { - if (this._marker.options.autoPan) { - cancelAnimFrame(this._panRequest); - this._panRequest = requestAnimFrame(this._adjustPan.bind(this, e)); - } - }, - - _onDrag: function (e) { - var marker = this._marker, - shadow = marker._shadow, - iconPos = getPosition(marker._icon), - latlng = marker._map.layerPointToLatLng(iconPos); - - // update shadow position - if (shadow) { - setPosition(shadow, iconPos); - } - - marker._latlng = latlng; - e.latlng = latlng; - e.oldLatLng = this._oldLatLng; - - // @event drag: Event - // Fired repeatedly while the user drags the marker. - marker - .fire('move', e) - .fire('drag', e); - }, - - _onDragEnd: function (e) { - // @event dragend: DragEndEvent - // Fired when the user stops dragging the marker. - - cancelAnimFrame(this._panRequest); - - // @event moveend: Event - // Fired when the marker stops moving (because of dragging). - delete this._oldLatLng; - this._marker - .fire('moveend') - .fire('dragend', e); - } - }); - - /* - * @class Marker - * @inherits Interactive layer - * @aka L.Marker - * L.Marker is used to display clickable/draggable icons on the map. Extends `Layer`. - * - * @example - * - * ```js - * L.marker([50.5, 30.5]).addTo(map); - * ``` - */ - - var Marker = Layer.extend({ - - // @section - // @aka Marker options - options: { - // @option icon: Icon = * - // Icon instance to use for rendering the marker. - // See [Icon documentation](#L.Icon) for details on how to customize the marker icon. - // If not specified, a common instance of `L.Icon.Default` is used. - icon: new IconDefault(), - - // Option inherited from "Interactive layer" abstract class - interactive: true, - - // @option keyboard: Boolean = true - // Whether the marker can be tabbed to with a keyboard and clicked by pressing enter. - keyboard: true, - - // @option title: String = '' - // Text for the browser tooltip that appear on marker hover (no tooltip by default). - title: '', - - // @option alt: String = '' - // Text for the `alt` attribute of the icon image (useful for accessibility). - alt: '', - - // @option zIndexOffset: Number = 0 - // By default, marker images zIndex is set automatically based on its latitude. Use this option if you want to put the marker on top of all others (or below), specifying a high value like `1000` (or high negative value, respectively). - zIndexOffset: 0, - - // @option opacity: Number = 1.0 - // The opacity of the marker. - opacity: 1, - - // @option riseOnHover: Boolean = false - // If `true`, the marker will get on top of others when you hover the mouse over it. - riseOnHover: false, - - // @option riseOffset: Number = 250 - // The z-index offset used for the `riseOnHover` feature. - riseOffset: 250, - - // @option pane: String = 'markerPane' - // `Map pane` where the markers icon will be added. - pane: 'markerPane', - - // @option shadowPane: String = 'shadowPane' - // `Map pane` where the markers shadow will be added. - shadowPane: 'shadowPane', - - // @option bubblingMouseEvents: Boolean = false - // When `true`, a mouse event on this marker will trigger the same event on the map - // (unless [`L.DomEvent.stopPropagation`](#domevent-stoppropagation) is used). - bubblingMouseEvents: false, - - // @section Draggable marker options - // @option draggable: Boolean = false - // Whether the marker is draggable with mouse/touch or not. - draggable: false, - - // @option autoPan: Boolean = false - // Whether to pan the map when dragging this marker near its edge or not. - autoPan: false, - - // @option autoPanPadding: Point = Point(50, 50) - // Distance (in pixels to the left/right and to the top/bottom) of the - // map edge to start panning the map. - autoPanPadding: [50, 50], - - // @option autoPanSpeed: Number = 10 - // Number of pixels the map should pan by. - autoPanSpeed: 10 - }, - - /* @section - * - * In addition to [shared layer methods](#Layer) like `addTo()` and `remove()` and [popup methods](#Popup) like bindPopup() you can also use the following methods: - */ - - initialize: function (latlng, options) { - setOptions(this, options); - this._latlng = toLatLng(latlng); - }, - - onAdd: function (map) { - this._zoomAnimated = this._zoomAnimated && map.options.markerZoomAnimation; - - if (this._zoomAnimated) { - map.on('zoomanim', this._animateZoom, this); - } - - this._initIcon(); - this.update(); - }, - - onRemove: function (map) { - if (this.dragging && this.dragging.enabled()) { - this.options.draggable = true; - this.dragging.removeHooks(); - } - delete this.dragging; - - if (this._zoomAnimated) { - map.off('zoomanim', this._animateZoom, this); - } - - this._removeIcon(); - this._removeShadow(); - }, - - getEvents: function () { - return { - zoom: this.update, - viewreset: this.update - }; - }, - - // @method getLatLng: LatLng - // Returns the current geographical position of the marker. - getLatLng: function () { - return this._latlng; - }, - - // @method setLatLng(latlng: LatLng): this - // Changes the marker position to the given point. - setLatLng: function (latlng) { - var oldLatLng = this._latlng; - this._latlng = toLatLng(latlng); - this.update(); - - // @event move: Event - // Fired when the marker is moved via [`setLatLng`](#marker-setlatlng) or by [dragging](#marker-dragging). Old and new coordinates are included in event arguments as `oldLatLng`, `latlng`. - return this.fire('move', {oldLatLng: oldLatLng, latlng: this._latlng}); - }, - - // @method setZIndexOffset(offset: Number): this - // Changes the [zIndex offset](#marker-zindexoffset) of the marker. - setZIndexOffset: function (offset) { - this.options.zIndexOffset = offset; - return this.update(); - }, - - // @method getIcon: Icon - // Returns the current icon used by the marker - getIcon: function () { - return this.options.icon; - }, - - // @method setIcon(icon: Icon): this - // Changes the marker icon. - setIcon: function (icon) { - - this.options.icon = icon; - - if (this._map) { - this._initIcon(); - this.update(); - } - - if (this._popup) { - this.bindPopup(this._popup, this._popup.options); - } - - return this; - }, - - getElement: function () { - return this._icon; - }, - - update: function () { - - if (this._icon && this._map) { - var pos = this._map.latLngToLayerPoint(this._latlng).round(); - this._setPos(pos); - } - - return this; - }, - - _initIcon: function () { - var options = this.options, - classToAdd = 'leaflet-zoom-' + (this._zoomAnimated ? 'animated' : 'hide'); - - var icon = options.icon.createIcon(this._icon), - addIcon = false; - - // if we're not reusing the icon, remove the old one and init new one - if (icon !== this._icon) { - if (this._icon) { - this._removeIcon(); - } - addIcon = true; - - if (options.title) { - icon.title = options.title; - } - - if (icon.tagName === 'IMG') { - icon.alt = options.alt || ''; - } - } - - addClass(icon, classToAdd); - - if (options.keyboard) { - icon.tabIndex = '0'; - } - - this._icon = icon; - - if (options.riseOnHover) { - this.on({ - mouseover: this._bringToFront, - mouseout: this._resetZIndex - }); - } - - var newShadow = options.icon.createShadow(this._shadow), - addShadow = false; - - if (newShadow !== this._shadow) { - this._removeShadow(); - addShadow = true; - } - - if (newShadow) { - addClass(newShadow, classToAdd); - newShadow.alt = ''; - } - this._shadow = newShadow; - - - if (options.opacity < 1) { - this._updateOpacity(); - } - - - if (addIcon) { - this.getPane().appendChild(this._icon); - } - this._initInteraction(); - if (newShadow && addShadow) { - this.getPane(options.shadowPane).appendChild(this._shadow); - } - }, - - _removeIcon: function () { - if (this.options.riseOnHover) { - this.off({ - mouseover: this._bringToFront, - mouseout: this._resetZIndex - }); - } - - remove(this._icon); - this.removeInteractiveTarget(this._icon); - - this._icon = null; - }, - - _removeShadow: function () { - if (this._shadow) { - remove(this._shadow); - } - this._shadow = null; - }, - - _setPos: function (pos) { - - if (this._icon) { - setPosition(this._icon, pos); - } - - if (this._shadow) { - setPosition(this._shadow, pos); - } - - this._zIndex = pos.y + this.options.zIndexOffset; - - this._resetZIndex(); - }, - - _updateZIndex: function (offset) { - if (this._icon) { - this._icon.style.zIndex = this._zIndex + offset; - } - }, - - _animateZoom: function (opt) { - var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round(); - - this._setPos(pos); - }, - - _initInteraction: function () { - - if (!this.options.interactive) { return; } - - addClass(this._icon, 'leaflet-interactive'); - - this.addInteractiveTarget(this._icon); - - if (MarkerDrag) { - var draggable = this.options.draggable; - if (this.dragging) { - draggable = this.dragging.enabled(); - this.dragging.disable(); - } - - this.dragging = new MarkerDrag(this); - - if (draggable) { - this.dragging.enable(); - } - } - }, - - // @method setOpacity(opacity: Number): this - // Changes the opacity of the marker. - setOpacity: function (opacity) { - this.options.opacity = opacity; - if (this._map) { - this._updateOpacity(); - } - - return this; - }, - - _updateOpacity: function () { - var opacity = this.options.opacity; - - if (this._icon) { - setOpacity(this._icon, opacity); - } - - if (this._shadow) { - setOpacity(this._shadow, opacity); - } - }, - - _bringToFront: function () { - this._updateZIndex(this.options.riseOffset); - }, - - _resetZIndex: function () { - this._updateZIndex(0); - }, - - _getPopupAnchor: function () { - return this.options.icon.options.popupAnchor; - }, - - _getTooltipAnchor: function () { - return this.options.icon.options.tooltipAnchor; - } - }); - - - // factory L.marker(latlng: LatLng, options? : Marker options) - - // @factory L.marker(latlng: LatLng, options? : Marker options) - // Instantiates a Marker object given a geographical point and optionally an options object. - function marker(latlng, options) { - return new Marker(latlng, options); - } - - /* - * @class Path - * @aka L.Path - * @inherits Interactive layer - * - * An abstract class that contains options and constants shared between vector - * overlays (Polygon, Polyline, Circle). Do not use it directly. Extends `Layer`. - */ - - var Path = Layer.extend({ - - // @section - // @aka Path options - options: { - // @option stroke: Boolean = true - // Whether to draw stroke along the path. Set it to `false` to disable borders on polygons or circles. - stroke: true, - - // @option color: String = '#3388ff' - // Stroke color - color: '#3388ff', - - // @option weight: Number = 3 - // Stroke width in pixels - weight: 3, - - // @option opacity: Number = 1.0 - // Stroke opacity - opacity: 1, - - // @option lineCap: String= 'round' - // A string that defines [shape to be used at the end](https://developer.mozilla.org/docs/Web/SVG/Attribute/stroke-linecap) of the stroke. - lineCap: 'round', - - // @option lineJoin: String = 'round' - // A string that defines [shape to be used at the corners](https://developer.mozilla.org/docs/Web/SVG/Attribute/stroke-linejoin) of the stroke. - lineJoin: 'round', - - // @option dashArray: String = null - // A string that defines the stroke [dash pattern](https://developer.mozilla.org/docs/Web/SVG/Attribute/stroke-dasharray). Doesn't work on `Canvas`-powered layers in [some old browsers](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/setLineDash#Browser_compatibility). - dashArray: null, - - // @option dashOffset: String = null - // A string that defines the [distance into the dash pattern to start the dash](https://developer.mozilla.org/docs/Web/SVG/Attribute/stroke-dashoffset). Doesn't work on `Canvas`-powered layers in [some old browsers](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/setLineDash#Browser_compatibility). - dashOffset: null, - - // @option fill: Boolean = depends - // Whether to fill the path with color. Set it to `false` to disable filling on polygons or circles. - fill: false, - - // @option fillColor: String = * - // Fill color. Defaults to the value of the [`color`](#path-color) option - fillColor: null, - - // @option fillOpacity: Number = 0.2 - // Fill opacity. - fillOpacity: 0.2, - - // @option fillRule: String = 'evenodd' - // A string that defines [how the inside of a shape](https://developer.mozilla.org/docs/Web/SVG/Attribute/fill-rule) is determined. - fillRule: 'evenodd', - - // className: '', - - // Option inherited from "Interactive layer" abstract class - interactive: true, - - // @option bubblingMouseEvents: Boolean = true - // When `true`, a mouse event on this path will trigger the same event on the map - // (unless [`L.DomEvent.stopPropagation`](#domevent-stoppropagation) is used). - bubblingMouseEvents: true - }, - - beforeAdd: function (map) { - // Renderer is set here because we need to call renderer.getEvents - // before this.getEvents. - this._renderer = map.getRenderer(this); - }, - - onAdd: function () { - this._renderer._initPath(this); - this._reset(); - this._renderer._addPath(this); - }, - - onRemove: function () { - this._renderer._removePath(this); - }, - - // @method redraw(): this - // Redraws the layer. Sometimes useful after you changed the coordinates that the path uses. - redraw: function () { - if (this._map) { - this._renderer._updatePath(this); - } - return this; - }, - - // @method setStyle(style: Path options): this - // Changes the appearance of a Path based on the options in the `Path options` object. - setStyle: function (style) { - setOptions(this, style); - if (this._renderer) { - this._renderer._updateStyle(this); - if (this.options.stroke && style && Object.prototype.hasOwnProperty.call(style, 'weight')) { - this._updateBounds(); - } - } - return this; - }, - - // @method bringToFront(): this - // Brings the layer to the top of all path layers. - bringToFront: function () { - if (this._renderer) { - this._renderer._bringToFront(this); - } - return this; - }, - - // @method bringToBack(): this - // Brings the layer to the bottom of all path layers. - bringToBack: function () { - if (this._renderer) { - this._renderer._bringToBack(this); - } - return this; - }, - - getElement: function () { - return this._path; - }, - - _reset: function () { - // defined in child classes - this._project(); - this._update(); - }, - - _clickTolerance: function () { - // used when doing hit detection for Canvas layers - return (this.options.stroke ? this.options.weight / 2 : 0) + this._renderer.options.tolerance; - } - }); - - /* - * @class CircleMarker - * @aka L.CircleMarker - * @inherits Path - * - * A circle of a fixed size with radius specified in pixels. Extends `Path`. - */ - - var CircleMarker = Path.extend({ - - // @section - // @aka CircleMarker options - options: { - fill: true, - - // @option radius: Number = 10 - // Radius of the circle marker, in pixels - radius: 10 - }, - - initialize: function (latlng, options) { - setOptions(this, options); - this._latlng = toLatLng(latlng); - this._radius = this.options.radius; - }, - - // @method setLatLng(latLng: LatLng): this - // Sets the position of a circle marker to a new location. - setLatLng: function (latlng) { - var oldLatLng = this._latlng; - this._latlng = toLatLng(latlng); - this.redraw(); - - // @event move: Event - // Fired when the marker is moved via [`setLatLng`](#circlemarker-setlatlng). Old and new coordinates are included in event arguments as `oldLatLng`, `latlng`. - return this.fire('move', {oldLatLng: oldLatLng, latlng: this._latlng}); - }, - - // @method getLatLng(): LatLng - // Returns the current geographical position of the circle marker - getLatLng: function () { - return this._latlng; - }, - - // @method setRadius(radius: Number): this - // Sets the radius of a circle marker. Units are in pixels. - setRadius: function (radius) { - this.options.radius = this._radius = radius; - return this.redraw(); - }, - - // @method getRadius(): Number - // Returns the current radius of the circle - getRadius: function () { - return this._radius; - }, - - setStyle : function (options) { - var radius = options && options.radius || this._radius; - Path.prototype.setStyle.call(this, options); - this.setRadius(radius); - return this; - }, - - _project: function () { - this._point = this._map.latLngToLayerPoint(this._latlng); - this._updateBounds(); - }, - - _updateBounds: function () { - var r = this._radius, - r2 = this._radiusY || r, - w = this._clickTolerance(), - p = [r + w, r2 + w]; - this._pxBounds = new Bounds(this._point.subtract(p), this._point.add(p)); - }, - - _update: function () { - if (this._map) { - this._updatePath(); - } - }, - - _updatePath: function () { - this._renderer._updateCircle(this); - }, - - _empty: function () { - return this._radius && !this._renderer._bounds.intersects(this._pxBounds); - }, - - // Needed by the `Canvas` renderer for interactivity - _containsPoint: function (p) { - return p.distanceTo(this._point) <= this._radius + this._clickTolerance(); - } - }); - - - // @factory L.circleMarker(latlng: LatLng, options?: CircleMarker options) - // Instantiates a circle marker object given a geographical point, and an optional options object. - function circleMarker(latlng, options) { - return new CircleMarker(latlng, options); - } - - /* - * @class Circle - * @aka L.Circle - * @inherits CircleMarker - * - * A class for drawing circle overlays on a map. Extends `CircleMarker`. - * - * It's an approximation and starts to diverge from a real circle closer to poles (due to projection distortion). - * - * @example - * - * ```js - * L.circle([50.5, 30.5], {radius: 200}).addTo(map); - * ``` - */ - - var Circle = CircleMarker.extend({ - - initialize: function (latlng, options, legacyOptions) { - if (typeof options === 'number') { - // Backwards compatibility with 0.7.x factory (latlng, radius, options?) - options = extend({}, legacyOptions, {radius: options}); - } - setOptions(this, options); - this._latlng = toLatLng(latlng); - - if (isNaN(this.options.radius)) { throw new Error('Circle radius cannot be NaN'); } - - // @section - // @aka Circle options - // @option radius: Number; Radius of the circle, in meters. - this._mRadius = this.options.radius; - }, - - // @method setRadius(radius: Number): this - // Sets the radius of a circle. Units are in meters. - setRadius: function (radius) { - this._mRadius = radius; - return this.redraw(); - }, - - // @method getRadius(): Number - // Returns the current radius of a circle. Units are in meters. - getRadius: function () { - return this._mRadius; - }, - - // @method getBounds(): LatLngBounds - // Returns the `LatLngBounds` of the path. - getBounds: function () { - var half = [this._radius, this._radiusY || this._radius]; - - return new LatLngBounds( - this._map.layerPointToLatLng(this._point.subtract(half)), - this._map.layerPointToLatLng(this._point.add(half))); - }, - - setStyle: Path.prototype.setStyle, - - _project: function () { - - var lng = this._latlng.lng, - lat = this._latlng.lat, - map = this._map, - crs = map.options.crs; - - if (crs.distance === Earth.distance) { - var d = Math.PI / 180, - latR = (this._mRadius / Earth.R) / d, - top = map.project([lat + latR, lng]), - bottom = map.project([lat - latR, lng]), - p = top.add(bottom).divideBy(2), - lat2 = map.unproject(p).lat, - lngR = Math.acos((Math.cos(latR * d) - Math.sin(lat * d) * Math.sin(lat2 * d)) / - (Math.cos(lat * d) * Math.cos(lat2 * d))) / d; - - if (isNaN(lngR) || lngR === 0) { - lngR = latR / Math.cos(Math.PI / 180 * lat); // Fallback for edge case, #2425 - } - - this._point = p.subtract(map.getPixelOrigin()); - this._radius = isNaN(lngR) ? 0 : p.x - map.project([lat2, lng - lngR]).x; - this._radiusY = p.y - top.y; - - } else { - var latlng2 = crs.unproject(crs.project(this._latlng).subtract([this._mRadius, 0])); - - this._point = map.latLngToLayerPoint(this._latlng); - this._radius = this._point.x - map.latLngToLayerPoint(latlng2).x; - } - - this._updateBounds(); - } - }); - - // @factory L.circle(latlng: LatLng, options?: Circle options) - // Instantiates a circle object given a geographical point, and an options object - // which contains the circle radius. - // @alternative - // @factory L.circle(latlng: LatLng, radius: Number, options?: Circle options) - // Obsolete way of instantiating a circle, for compatibility with 0.7.x code. - // Do not use in new applications or plugins. - function circle(latlng, options, legacyOptions) { - return new Circle(latlng, options, legacyOptions); - } - - /* - * @class Polyline - * @aka L.Polyline - * @inherits Path - * - * A class for drawing polyline overlays on a map. Extends `Path`. - * - * @example - * - * ```js - * // create a red polyline from an array of LatLng points - * var latlngs = [ - * [45.51, -122.68], - * [37.77, -122.43], - * [34.04, -118.2] - * ]; - * - * var polyline = L.polyline(latlngs, {color: 'red'}).addTo(map); - * - * // zoom the map to the polyline - * map.fitBounds(polyline.getBounds()); - * ``` - * - * You can also pass a multi-dimensional array to represent a `MultiPolyline` shape: - * - * ```js - * // create a red polyline from an array of arrays of LatLng points - * var latlngs = [ - * [[45.51, -122.68], - * [37.77, -122.43], - * [34.04, -118.2]], - * [[40.78, -73.91], - * [41.83, -87.62], - * [32.76, -96.72]] - * ]; - * ``` - */ - - - var Polyline = Path.extend({ - - // @section - // @aka Polyline options - options: { - // @option smoothFactor: Number = 1.0 - // How much to simplify the polyline on each zoom level. More means - // better performance and smoother look, and less means more accurate representation. - smoothFactor: 1.0, - - // @option noClip: Boolean = false - // Disable polyline clipping. - noClip: false - }, - - initialize: function (latlngs, options) { - setOptions(this, options); - this._setLatLngs(latlngs); - }, - - // @method getLatLngs(): LatLng[] - // Returns an array of the points in the path, or nested arrays of points in case of multi-polyline. - getLatLngs: function () { - return this._latlngs; - }, - - // @method setLatLngs(latlngs: LatLng[]): this - // Replaces all the points in the polyline with the given array of geographical points. - setLatLngs: function (latlngs) { - this._setLatLngs(latlngs); - return this.redraw(); - }, - - // @method isEmpty(): Boolean - // Returns `true` if the Polyline has no LatLngs. - isEmpty: function () { - return !this._latlngs.length; - }, - - // @method closestLayerPoint(p: Point): Point - // Returns the point closest to `p` on the Polyline. - closestLayerPoint: function (p) { - var minDistance = Infinity, - minPoint = null, - closest = _sqClosestPointOnSegment, - p1, p2; - - for (var j = 0, jLen = this._parts.length; j < jLen; j++) { - var points = this._parts[j]; - - for (var i = 1, len = points.length; i < len; i++) { - p1 = points[i - 1]; - p2 = points[i]; - - var sqDist = closest(p, p1, p2, true); - - if (sqDist < minDistance) { - minDistance = sqDist; - minPoint = closest(p, p1, p2); - } - } - } - if (minPoint) { - minPoint.distance = Math.sqrt(minDistance); - } - return minPoint; - }, - - // @method getCenter(): LatLng - // Returns the center ([centroid](http://en.wikipedia.org/wiki/Centroid)) of the polyline. - getCenter: function () { - // throws error when not yet added to map as this center calculation requires projected coordinates - if (!this._map) { - throw new Error('Must add layer to map before using getCenter()'); - } - - var i, halfDist, segDist, dist, p1, p2, ratio, - points = this._rings[0], - len = points.length; - - if (!len) { return null; } - - // polyline centroid algorithm; only uses the first ring if there are multiple - - for (i = 0, halfDist = 0; i < len - 1; i++) { - halfDist += points[i].distanceTo(points[i + 1]) / 2; - } - - // The line is so small in the current view that all points are on the same pixel. - if (halfDist === 0) { - return this._map.layerPointToLatLng(points[0]); - } - - for (i = 0, dist = 0; i < len - 1; i++) { - p1 = points[i]; - p2 = points[i + 1]; - segDist = p1.distanceTo(p2); - dist += segDist; - - if (dist > halfDist) { - ratio = (dist - halfDist) / segDist; - return this._map.layerPointToLatLng([ - p2.x - ratio * (p2.x - p1.x), - p2.y - ratio * (p2.y - p1.y) - ]); - } - } - }, - - // @method getBounds(): LatLngBounds - // Returns the `LatLngBounds` of the path. - getBounds: function () { - return this._bounds; - }, - - // @method addLatLng(latlng: LatLng, latlngs?: LatLng[]): this - // Adds a given point to the polyline. By default, adds to the first ring of - // the polyline in case of a multi-polyline, but can be overridden by passing - // a specific ring as a LatLng array (that you can earlier access with [`getLatLngs`](#polyline-getlatlngs)). - addLatLng: function (latlng, latlngs) { - latlngs = latlngs || this._defaultShape(); - latlng = toLatLng(latlng); - latlngs.push(latlng); - this._bounds.extend(latlng); - return this.redraw(); - }, - - _setLatLngs: function (latlngs) { - this._bounds = new LatLngBounds(); - this._latlngs = this._convertLatLngs(latlngs); - }, - - _defaultShape: function () { - return isFlat(this._latlngs) ? this._latlngs : this._latlngs[0]; - }, - - // recursively convert latlngs input into actual LatLng instances; calculate bounds along the way - _convertLatLngs: function (latlngs) { - var result = [], - flat = isFlat(latlngs); - - for (var i = 0, len = latlngs.length; i < len; i++) { - if (flat) { - result[i] = toLatLng(latlngs[i]); - this._bounds.extend(result[i]); - } else { - result[i] = this._convertLatLngs(latlngs[i]); - } - } - - return result; - }, - - _project: function () { - var pxBounds = new Bounds(); - this._rings = []; - this._projectLatlngs(this._latlngs, this._rings, pxBounds); - - if (this._bounds.isValid() && pxBounds.isValid()) { - this._rawPxBounds = pxBounds; - this._updateBounds(); - } - }, - - _updateBounds: function () { - var w = this._clickTolerance(), - p = new Point(w, w); - this._pxBounds = new Bounds([ - this._rawPxBounds.min.subtract(p), - this._rawPxBounds.max.add(p) - ]); - }, - - // recursively turns latlngs into a set of rings with projected coordinates - _projectLatlngs: function (latlngs, result, projectedBounds) { - var flat = latlngs[0] instanceof LatLng, - len = latlngs.length, - i, ring; - - if (flat) { - ring = []; - for (i = 0; i < len; i++) { - ring[i] = this._map.latLngToLayerPoint(latlngs[i]); - projectedBounds.extend(ring[i]); - } - result.push(ring); - } else { - for (i = 0; i < len; i++) { - this._projectLatlngs(latlngs[i], result, projectedBounds); - } - } - }, - - // clip polyline by renderer bounds so that we have less to render for performance - _clipPoints: function () { - var bounds = this._renderer._bounds; - - this._parts = []; - if (!this._pxBounds || !this._pxBounds.intersects(bounds)) { - return; - } - - if (this.options.noClip) { - this._parts = this._rings; - return; - } - - var parts = this._parts, - i, j, k, len, len2, segment, points; - - for (i = 0, k = 0, len = this._rings.length; i < len; i++) { - points = this._rings[i]; - - for (j = 0, len2 = points.length; j < len2 - 1; j++) { - segment = clipSegment(points[j], points[j + 1], bounds, j, true); - - if (!segment) { continue; } - - parts[k] = parts[k] || []; - parts[k].push(segment[0]); - - // if segment goes out of screen, or it's the last one, it's the end of the line part - if ((segment[1] !== points[j + 1]) || (j === len2 - 2)) { - parts[k].push(segment[1]); - k++; - } - } - } - }, - - // simplify each clipped part of the polyline for performance - _simplifyPoints: function () { - var parts = this._parts, - tolerance = this.options.smoothFactor; - - for (var i = 0, len = parts.length; i < len; i++) { - parts[i] = simplify(parts[i], tolerance); - } - }, - - _update: function () { - if (!this._map) { return; } - - this._clipPoints(); - this._simplifyPoints(); - this._updatePath(); - }, - - _updatePath: function () { - this._renderer._updatePoly(this); - }, - - // Needed by the `Canvas` renderer for interactivity - _containsPoint: function (p, closed) { - var i, j, k, len, len2, part, - w = this._clickTolerance(); - - if (!this._pxBounds || !this._pxBounds.contains(p)) { return false; } - - // hit detection for polylines - for (i = 0, len = this._parts.length; i < len; i++) { - part = this._parts[i]; - - for (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) { - if (!closed && (j === 0)) { continue; } - - if (pointToSegmentDistance(p, part[k], part[j]) <= w) { - return true; - } - } - } - return false; - } - }); - - // @factory L.polyline(latlngs: LatLng[], options?: Polyline options) - // Instantiates a polyline object given an array of geographical points and - // optionally an options object. You can create a `Polyline` object with - // multiple separate lines (`MultiPolyline`) by passing an array of arrays - // of geographic points. - function polyline(latlngs, options) { - return new Polyline(latlngs, options); - } - - // Retrocompat. Allow plugins to support Leaflet versions before and after 1.1. - Polyline._flat = _flat; - - /* - * @class Polygon - * @aka L.Polygon - * @inherits Polyline - * - * A class for drawing polygon overlays on a map. Extends `Polyline`. - * - * Note that points you pass when creating a polygon shouldn't have an additional last point equal to the first one — it's better to filter out such points. - * - * - * @example - * - * ```js - * // create a red polygon from an array of LatLng points - * var latlngs = [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]]; - * - * var polygon = L.polygon(latlngs, {color: 'red'}).addTo(map); - * - * // zoom the map to the polygon - * map.fitBounds(polygon.getBounds()); - * ``` - * - * You can also pass an array of arrays of latlngs, with the first array representing the outer shape and the other arrays representing holes in the outer shape: - * - * ```js - * var latlngs = [ - * [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]], // outer ring - * [[37.29, -108.58],[40.71, -108.58],[40.71, -102.50],[37.29, -102.50]] // hole - * ]; - * ``` - * - * Additionally, you can pass a multi-dimensional array to represent a MultiPolygon shape. - * - * ```js - * var latlngs = [ - * [ // first polygon - * [[37, -109.05],[41, -109.03],[41, -102.05],[37, -102.04]], // outer ring - * [[37.29, -108.58],[40.71, -108.58],[40.71, -102.50],[37.29, -102.50]] // hole - * ], - * [ // second polygon - * [[41, -111.03],[45, -111.04],[45, -104.05],[41, -104.05]] - * ] - * ]; - * ``` - */ - - var Polygon = Polyline.extend({ - - options: { - fill: true - }, - - isEmpty: function () { - return !this._latlngs.length || !this._latlngs[0].length; - }, - - getCenter: function () { - // throws error when not yet added to map as this center calculation requires projected coordinates - if (!this._map) { - throw new Error('Must add layer to map before using getCenter()'); - } - - var i, j, p1, p2, f, area, x, y, center, - points = this._rings[0], - len = points.length; - - if (!len) { return null; } - - // polygon centroid algorithm; only uses the first ring if there are multiple - - area = x = y = 0; - - for (i = 0, j = len - 1; i < len; j = i++) { - p1 = points[i]; - p2 = points[j]; - - f = p1.y * p2.x - p2.y * p1.x; - x += (p1.x + p2.x) * f; - y += (p1.y + p2.y) * f; - area += f * 3; - } - - if (area === 0) { - // Polygon is so small that all points are on same pixel. - center = points[0]; - } else { - center = [x / area, y / area]; - } - return this._map.layerPointToLatLng(center); - }, - - _convertLatLngs: function (latlngs) { - var result = Polyline.prototype._convertLatLngs.call(this, latlngs), - len = result.length; - - // remove last point if it equals first one - if (len >= 2 && result[0] instanceof LatLng && result[0].equals(result[len - 1])) { - result.pop(); - } - return result; - }, - - _setLatLngs: function (latlngs) { - Polyline.prototype._setLatLngs.call(this, latlngs); - if (isFlat(this._latlngs)) { - this._latlngs = [this._latlngs]; - } - }, - - _defaultShape: function () { - return isFlat(this._latlngs[0]) ? this._latlngs[0] : this._latlngs[0][0]; - }, - - _clipPoints: function () { - // polygons need a different clipping algorithm so we redefine that - - var bounds = this._renderer._bounds, - w = this.options.weight, - p = new Point(w, w); - - // increase clip padding by stroke width to avoid stroke on clip edges - bounds = new Bounds(bounds.min.subtract(p), bounds.max.add(p)); - - this._parts = []; - if (!this._pxBounds || !this._pxBounds.intersects(bounds)) { - return; - } - - if (this.options.noClip) { - this._parts = this._rings; - return; - } - - for (var i = 0, len = this._rings.length, clipped; i < len; i++) { - clipped = clipPolygon(this._rings[i], bounds, true); - if (clipped.length) { - this._parts.push(clipped); - } - } - }, - - _updatePath: function () { - this._renderer._updatePoly(this, true); - }, - - // Needed by the `Canvas` renderer for interactivity - _containsPoint: function (p) { - var inside = false, - part, p1, p2, i, j, k, len, len2; - - if (!this._pxBounds || !this._pxBounds.contains(p)) { return false; } - - // ray casting algorithm for detecting if point is in polygon - for (i = 0, len = this._parts.length; i < len; i++) { - part = this._parts[i]; - - for (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) { - p1 = part[j]; - p2 = part[k]; - - if (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) { - inside = !inside; - } - } - } - - // also check if it's on polygon stroke - return inside || Polyline.prototype._containsPoint.call(this, p, true); - } - - }); - - - // @factory L.polygon(latlngs: LatLng[], options?: Polyline options) - function polygon(latlngs, options) { - return new Polygon(latlngs, options); - } - - /* - * @class GeoJSON - * @aka L.GeoJSON - * @inherits FeatureGroup - * - * Represents a GeoJSON object or an array of GeoJSON objects. Allows you to parse - * GeoJSON data and display it on the map. Extends `FeatureGroup`. - * - * @example - * - * ```js - * L.geoJSON(data, { - * style: function (feature) { - * return {color: feature.properties.color}; - * } - * }).bindPopup(function (layer) { - * return layer.feature.properties.description; - * }).addTo(map); - * ``` - */ - - var GeoJSON = FeatureGroup.extend({ - - /* @section - * @aka GeoJSON options - * - * @option pointToLayer: Function = * - * A `Function` defining how GeoJSON points spawn Leaflet layers. It is internally - * called when data is added, passing the GeoJSON point feature and its `LatLng`. - * The default is to spawn a default `Marker`: - * ```js - * function(geoJsonPoint, latlng) { - * return L.marker(latlng); - * } - * ``` - * - * @option style: Function = * - * A `Function` defining the `Path options` for styling GeoJSON lines and polygons, - * called internally when data is added. - * The default value is to not override any defaults: - * ```js - * function (geoJsonFeature) { - * return {} - * } - * ``` - * - * @option onEachFeature: Function = * - * A `Function` that will be called once for each created `Feature`, after it has - * been created and styled. Useful for attaching events and popups to features. - * The default is to do nothing with the newly created layers: - * ```js - * function (feature, layer) {} - * ``` - * - * @option filter: Function = * - * A `Function` that will be used to decide whether to include a feature or not. - * The default is to include all features: - * ```js - * function (geoJsonFeature) { - * return true; - * } - * ``` - * Note: dynamically changing the `filter` option will have effect only on newly - * added data. It will _not_ re-evaluate already included features. - * - * @option coordsToLatLng: Function = * - * A `Function` that will be used for converting GeoJSON coordinates to `LatLng`s. - * The default is the `coordsToLatLng` static method. - * - * @option markersInheritOptions: Boolean = false - * Whether default Markers for "Point" type Features inherit from group options. - */ - - initialize: function (geojson, options) { - setOptions(this, options); - - this._layers = {}; - - if (geojson) { - this.addData(geojson); - } - }, - - // @method addData( data ): this - // Adds a GeoJSON object to the layer. - addData: function (geojson) { - var features = isArray(geojson) ? geojson : geojson.features, - i, len, feature; - - if (features) { - for (i = 0, len = features.length; i < len; i++) { - // only add this if geometry or geometries are set and not null - feature = features[i]; - if (feature.geometries || feature.geometry || feature.features || feature.coordinates) { - this.addData(feature); - } - } - return this; - } - - var options = this.options; - - if (options.filter && !options.filter(geojson)) { return this; } - - var layer = geometryToLayer(geojson, options); - if (!layer) { - return this; - } - layer.feature = asFeature(geojson); - - layer.defaultOptions = layer.options; - this.resetStyle(layer); - - if (options.onEachFeature) { - options.onEachFeature(geojson, layer); - } - - return this.addLayer(layer); - }, - - // @method resetStyle( layer? ): this - // Resets the given vector layer's style to the original GeoJSON style, useful for resetting style after hover events. - // If `layer` is omitted, the style of all features in the current layer is reset. - resetStyle: function (layer) { - if (layer === undefined) { - return this.eachLayer(this.resetStyle, this); - } - // reset any custom styles - layer.options = extend({}, layer.defaultOptions); - this._setLayerStyle(layer, this.options.style); - return this; - }, - - // @method setStyle( style ): this - // Changes styles of GeoJSON vector layers with the given style function. - setStyle: function (style) { - return this.eachLayer(function (layer) { - this._setLayerStyle(layer, style); - }, this); - }, - - _setLayerStyle: function (layer, style) { - if (layer.setStyle) { - if (typeof style === 'function') { - style = style(layer.feature); - } - layer.setStyle(style); - } - } - }); - - // @section - // There are several static functions which can be called without instantiating L.GeoJSON: - - // @function geometryToLayer(featureData: Object, options?: GeoJSON options): Layer - // Creates a `Layer` from a given GeoJSON feature. Can use a custom - // [`pointToLayer`](#geojson-pointtolayer) and/or [`coordsToLatLng`](#geojson-coordstolatlng) - // functions if provided as options. - function geometryToLayer(geojson, options) { - - var geometry = geojson.type === 'Feature' ? geojson.geometry : geojson, - coords = geometry ? geometry.coordinates : null, - layers = [], - pointToLayer = options && options.pointToLayer, - _coordsToLatLng = options && options.coordsToLatLng || coordsToLatLng, - latlng, latlngs, i, len; - - if (!coords && !geometry) { - return null; - } - - switch (geometry.type) { - case 'Point': - latlng = _coordsToLatLng(coords); - return _pointToLayer(pointToLayer, geojson, latlng, options); - - case 'MultiPoint': - for (i = 0, len = coords.length; i < len; i++) { - latlng = _coordsToLatLng(coords[i]); - layers.push(_pointToLayer(pointToLayer, geojson, latlng, options)); - } - return new FeatureGroup(layers); - - case 'LineString': - case 'MultiLineString': - latlngs = coordsToLatLngs(coords, geometry.type === 'LineString' ? 0 : 1, _coordsToLatLng); - return new Polyline(latlngs, options); - - case 'Polygon': - case 'MultiPolygon': - latlngs = coordsToLatLngs(coords, geometry.type === 'Polygon' ? 1 : 2, _coordsToLatLng); - return new Polygon(latlngs, options); - - case 'GeometryCollection': - for (i = 0, len = geometry.geometries.length; i < len; i++) { - var layer = geometryToLayer({ - geometry: geometry.geometries[i], - type: 'Feature', - properties: geojson.properties - }, options); - - if (layer) { - layers.push(layer); - } - } - return new FeatureGroup(layers); - - default: - throw new Error('Invalid GeoJSON object.'); - } - } - - function _pointToLayer(pointToLayerFn, geojson, latlng, options) { - return pointToLayerFn ? - pointToLayerFn(geojson, latlng) : - new Marker(latlng, options && options.markersInheritOptions && options); - } - - // @function coordsToLatLng(coords: Array): LatLng - // Creates a `LatLng` object from an array of 2 numbers (longitude, latitude) - // or 3 numbers (longitude, latitude, altitude) used in GeoJSON for points. - function coordsToLatLng(coords) { - return new LatLng(coords[1], coords[0], coords[2]); - } - - // @function coordsToLatLngs(coords: Array, levelsDeep?: Number, coordsToLatLng?: Function): Array - // Creates a multidimensional array of `LatLng`s from a GeoJSON coordinates array. - // `levelsDeep` specifies the nesting level (0 is for an array of points, 1 for an array of arrays of points, etc., 0 by default). - // Can use a custom [`coordsToLatLng`](#geojson-coordstolatlng) function. - function coordsToLatLngs(coords, levelsDeep, _coordsToLatLng) { - var latlngs = []; - - for (var i = 0, len = coords.length, latlng; i < len; i++) { - latlng = levelsDeep ? - coordsToLatLngs(coords[i], levelsDeep - 1, _coordsToLatLng) : - (_coordsToLatLng || coordsToLatLng)(coords[i]); - - latlngs.push(latlng); - } - - return latlngs; - } - - // @function latLngToCoords(latlng: LatLng, precision?: Number): Array - // Reverse of [`coordsToLatLng`](#geojson-coordstolatlng) - function latLngToCoords(latlng, precision) { - precision = typeof precision === 'number' ? precision : 6; - return latlng.alt !== undefined ? - [formatNum(latlng.lng, precision), formatNum(latlng.lat, precision), formatNum(latlng.alt, precision)] : - [formatNum(latlng.lng, precision), formatNum(latlng.lat, precision)]; - } - - // @function latLngsToCoords(latlngs: Array, levelsDeep?: Number, closed?: Boolean): Array - // Reverse of [`coordsToLatLngs`](#geojson-coordstolatlngs) - // `closed` determines whether the first point should be appended to the end of the array to close the feature, only used when `levelsDeep` is 0. False by default. - function latLngsToCoords(latlngs, levelsDeep, closed, precision) { - var coords = []; - - for (var i = 0, len = latlngs.length; i < len; i++) { - coords.push(levelsDeep ? - latLngsToCoords(latlngs[i], levelsDeep - 1, closed, precision) : - latLngToCoords(latlngs[i], precision)); - } - - if (!levelsDeep && closed) { - coords.push(coords[0]); - } - - return coords; - } - - function getFeature(layer, newGeometry) { - return layer.feature ? - extend({}, layer.feature, {geometry: newGeometry}) : - asFeature(newGeometry); - } - - // @function asFeature(geojson: Object): Object - // Normalize GeoJSON geometries/features into GeoJSON features. - function asFeature(geojson) { - if (geojson.type === 'Feature' || geojson.type === 'FeatureCollection') { - return geojson; - } - - return { - type: 'Feature', - properties: {}, - geometry: geojson - }; - } - - var PointToGeoJSON = { - toGeoJSON: function (precision) { - return getFeature(this, { - type: 'Point', - coordinates: latLngToCoords(this.getLatLng(), precision) - }); - } - }; - - // @namespace Marker - // @section Other methods - // @method toGeoJSON(precision?: Number): Object - // `precision` is the number of decimal places for coordinates. - // The default value is 6 places. - // Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the marker (as a GeoJSON `Point` Feature). - Marker.include(PointToGeoJSON); - - // @namespace CircleMarker - // @method toGeoJSON(precision?: Number): Object - // `precision` is the number of decimal places for coordinates. - // The default value is 6 places. - // Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the circle marker (as a GeoJSON `Point` Feature). - Circle.include(PointToGeoJSON); - CircleMarker.include(PointToGeoJSON); - - - // @namespace Polyline - // @method toGeoJSON(precision?: Number): Object - // `precision` is the number of decimal places for coordinates. - // The default value is 6 places. - // Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the polyline (as a GeoJSON `LineString` or `MultiLineString` Feature). - Polyline.include({ - toGeoJSON: function (precision) { - var multi = !isFlat(this._latlngs); - - var coords = latLngsToCoords(this._latlngs, multi ? 1 : 0, false, precision); - - return getFeature(this, { - type: (multi ? 'Multi' : '') + 'LineString', - coordinates: coords - }); - } - }); - - // @namespace Polygon - // @method toGeoJSON(precision?: Number): Object - // `precision` is the number of decimal places for coordinates. - // The default value is 6 places. - // Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the polygon (as a GeoJSON `Polygon` or `MultiPolygon` Feature). - Polygon.include({ - toGeoJSON: function (precision) { - var holes = !isFlat(this._latlngs), - multi = holes && !isFlat(this._latlngs[0]); - - var coords = latLngsToCoords(this._latlngs, multi ? 2 : holes ? 1 : 0, true, precision); - - if (!holes) { - coords = [coords]; - } - - return getFeature(this, { - type: (multi ? 'Multi' : '') + 'Polygon', - coordinates: coords - }); - } - }); - - - // @namespace LayerGroup - LayerGroup.include({ - toMultiPoint: function (precision) { - var coords = []; - - this.eachLayer(function (layer) { - coords.push(layer.toGeoJSON(precision).geometry.coordinates); - }); - - return getFeature(this, { - type: 'MultiPoint', - coordinates: coords - }); - }, - - // @method toGeoJSON(precision?: Number): Object - // `precision` is the number of decimal places for coordinates. - // The default value is 6 places. - // Returns a [`GeoJSON`](http://en.wikipedia.org/wiki/GeoJSON) representation of the layer group (as a GeoJSON `FeatureCollection`, `GeometryCollection`, or `MultiPoint`). - toGeoJSON: function (precision) { - - var type = this.feature && this.feature.geometry && this.feature.geometry.type; - - if (type === 'MultiPoint') { - return this.toMultiPoint(precision); - } - - var isGeometryCollection = type === 'GeometryCollection', - jsons = []; - - this.eachLayer(function (layer) { - if (layer.toGeoJSON) { - var json = layer.toGeoJSON(precision); - if (isGeometryCollection) { - jsons.push(json.geometry); - } else { - var feature = asFeature(json); - // Squash nested feature collections - if (feature.type === 'FeatureCollection') { - jsons.push.apply(jsons, feature.features); - } else { - jsons.push(feature); - } - } - } - }); - - if (isGeometryCollection) { - return getFeature(this, { - geometries: jsons, - type: 'GeometryCollection' - }); - } - - return { - type: 'FeatureCollection', - features: jsons - }; - } - }); - - // @namespace GeoJSON - // @factory L.geoJSON(geojson?: Object, options?: GeoJSON options) - // Creates a GeoJSON layer. Optionally accepts an object in - // [GeoJSON format](https://tools.ietf.org/html/rfc7946) to display on the map - // (you can alternatively add it later with `addData` method) and an `options` object. - function geoJSON(geojson, options) { - return new GeoJSON(geojson, options); - } - - // Backward compatibility. - var geoJson = geoJSON; - - /* - * @class ImageOverlay - * @aka L.ImageOverlay - * @inherits Interactive layer - * - * Used to load and display a single image over specific bounds of the map. Extends `Layer`. - * - * @example - * - * ```js - * var imageUrl = 'http://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg', - * imageBounds = [[40.712216, -74.22655], [40.773941, -74.12544]]; - * L.imageOverlay(imageUrl, imageBounds).addTo(map); - * ``` - */ - - var ImageOverlay = Layer.extend({ - - // @section - // @aka ImageOverlay options - options: { - // @option opacity: Number = 1.0 - // The opacity of the image overlay. - opacity: 1, - - // @option alt: String = '' - // Text for the `alt` attribute of the image (useful for accessibility). - alt: '', - - // @option interactive: Boolean = false - // If `true`, the image overlay will emit [mouse events](#interactive-layer) when clicked or hovered. - interactive: false, - - // @option crossOrigin: Boolean|String = false - // Whether the crossOrigin attribute will be added to the image. - // If a String is provided, the image will have its crossOrigin attribute set to the String provided. This is needed if you want to access image pixel data. - // Refer to [CORS Settings](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes) for valid String values. - crossOrigin: false, - - // @option errorOverlayUrl: String = '' - // URL to the overlay image to show in place of the overlay that failed to load. - errorOverlayUrl: '', - - // @option zIndex: Number = 1 - // The explicit [zIndex](https://developer.mozilla.org/docs/Web/CSS/CSS_Positioning/Understanding_z_index) of the overlay layer. - zIndex: 1, - - // @option className: String = '' - // A custom class name to assign to the image. Empty by default. - className: '' - }, - - initialize: function (url, bounds, options) { // (String, LatLngBounds, Object) - this._url = url; - this._bounds = toLatLngBounds(bounds); - - setOptions(this, options); - }, - - onAdd: function () { - if (!this._image) { - this._initImage(); - - if (this.options.opacity < 1) { - this._updateOpacity(); - } - } - - if (this.options.interactive) { - addClass(this._image, 'leaflet-interactive'); - this.addInteractiveTarget(this._image); - } - - this.getPane().appendChild(this._image); - this._reset(); - }, - - onRemove: function () { - remove(this._image); - if (this.options.interactive) { - this.removeInteractiveTarget(this._image); - } - }, - - // @method setOpacity(opacity: Number): this - // Sets the opacity of the overlay. - setOpacity: function (opacity) { - this.options.opacity = opacity; - - if (this._image) { - this._updateOpacity(); - } - return this; - }, - - setStyle: function (styleOpts) { - if (styleOpts.opacity) { - this.setOpacity(styleOpts.opacity); - } - return this; - }, - - // @method bringToFront(): this - // Brings the layer to the top of all overlays. - bringToFront: function () { - if (this._map) { - toFront(this._image); - } - return this; - }, - - // @method bringToBack(): this - // Brings the layer to the bottom of all overlays. - bringToBack: function () { - if (this._map) { - toBack(this._image); - } - return this; - }, - - // @method setUrl(url: String): this - // Changes the URL of the image. - setUrl: function (url) { - this._url = url; - - if (this._image) { - this._image.src = url; - } - return this; - }, - - // @method setBounds(bounds: LatLngBounds): this - // Update the bounds that this ImageOverlay covers - setBounds: function (bounds) { - this._bounds = toLatLngBounds(bounds); - - if (this._map) { - this._reset(); - } - return this; - }, - - getEvents: function () { - var events = { - zoom: this._reset, - viewreset: this._reset - }; - - if (this._zoomAnimated) { - events.zoomanim = this._animateZoom; - } - - return events; - }, - - // @method setZIndex(value: Number): this - // Changes the [zIndex](#imageoverlay-zindex) of the image overlay. - setZIndex: function (value) { - this.options.zIndex = value; - this._updateZIndex(); - return this; - }, - - // @method getBounds(): LatLngBounds - // Get the bounds that this ImageOverlay covers - getBounds: function () { - return this._bounds; - }, - - // @method getElement(): HTMLElement - // Returns the instance of [`HTMLImageElement`](https://developer.mozilla.org/docs/Web/API/HTMLImageElement) - // used by this overlay. - getElement: function () { - return this._image; - }, - - _initImage: function () { - var wasElementSupplied = this._url.tagName === 'IMG'; - var img = this._image = wasElementSupplied ? this._url : create$1('img'); - - addClass(img, 'leaflet-image-layer'); - if (this._zoomAnimated) { addClass(img, 'leaflet-zoom-animated'); } - if (this.options.className) { addClass(img, this.options.className); } - - img.onselectstart = falseFn; - img.onmousemove = falseFn; - - // @event load: Event - // Fired when the ImageOverlay layer has loaded its image - img.onload = bind(this.fire, this, 'load'); - img.onerror = bind(this._overlayOnError, this, 'error'); - - if (this.options.crossOrigin || this.options.crossOrigin === '') { - img.crossOrigin = this.options.crossOrigin === true ? '' : this.options.crossOrigin; - } - - if (this.options.zIndex) { - this._updateZIndex(); - } - - if (wasElementSupplied) { - this._url = img.src; - return; - } - - img.src = this._url; - img.alt = this.options.alt; - }, - - _animateZoom: function (e) { - var scale = this._map.getZoomScale(e.zoom), - offset = this._map._latLngBoundsToNewLayerBounds(this._bounds, e.zoom, e.center).min; - - setTransform(this._image, offset, scale); - }, - - _reset: function () { - var image = this._image, - bounds = new Bounds( - this._map.latLngToLayerPoint(this._bounds.getNorthWest()), - this._map.latLngToLayerPoint(this._bounds.getSouthEast())), - size = bounds.getSize(); - - setPosition(image, bounds.min); - - image.style.width = size.x + 'px'; - image.style.height = size.y + 'px'; - }, - - _updateOpacity: function () { - setOpacity(this._image, this.options.opacity); - }, - - _updateZIndex: function () { - if (this._image && this.options.zIndex !== undefined && this.options.zIndex !== null) { - this._image.style.zIndex = this.options.zIndex; - } - }, - - _overlayOnError: function () { - // @event error: Event - // Fired when the ImageOverlay layer fails to load its image - this.fire('error'); - - var errorUrl = this.options.errorOverlayUrl; - if (errorUrl && this._url !== errorUrl) { - this._url = errorUrl; - this._image.src = errorUrl; - } - } - }); - - // @factory L.imageOverlay(imageUrl: String, bounds: LatLngBounds, options?: ImageOverlay options) - // Instantiates an image overlay object given the URL of the image and the - // geographical bounds it is tied to. - var imageOverlay = function (url, bounds, options) { - return new ImageOverlay(url, bounds, options); - }; - - /* - * @class VideoOverlay - * @aka L.VideoOverlay - * @inherits ImageOverlay - * - * Used to load and display a video player over specific bounds of the map. Extends `ImageOverlay`. - * - * A video overlay uses the [`