vidply 1.0.28 → 1.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/{vidply.TranscriptManager-QSF2PWUN.js → vidply.TranscriptManager-T677KF4N.js} +4 -5
- package/dist/dev/{vidply.TranscriptManager-QSF2PWUN.js.map → vidply.TranscriptManager-T677KF4N.js.map} +2 -2
- package/dist/dev/{vidply.chunk-SRM7VNHG.js → vidply.chunk-GS2JX5RQ.js} +136 -95
- package/dist/dev/vidply.chunk-GS2JX5RQ.js.map +7 -0
- package/dist/dev/vidply.esm.js +1674 -310
- package/dist/dev/vidply.esm.js.map +4 -4
- package/dist/legacy/vidply.js +1776 -348
- package/dist/legacy/vidply.js.map +4 -4
- package/dist/legacy/vidply.min.js +1 -1
- package/dist/legacy/vidply.min.meta.json +92 -24
- package/dist/prod/vidply.TranscriptManager-WFZSW6NR.min.js +6 -0
- package/dist/prod/vidply.chunk-LGTJRPUL.min.js +6 -0
- package/dist/prod/vidply.esm.min.js +8 -8
- package/dist/vidply.esm.min.meta.json +92 -24
- package/package.json +1 -1
- package/src/controls/ControlBar.js +3 -7
- package/src/controls/TranscriptManager.js +7 -7
- package/src/core/AudioDescriptionManager.js +701 -0
- package/src/core/Player.js +4776 -4921
- package/src/core/SignLanguageManager.js +1134 -0
- package/src/utils/DOMUtils.js +153 -114
- package/src/utils/MenuFactory.js +374 -0
- package/dist/dev/vidply.TranscriptManager-GZKY44ON.js +0 -1744
- package/dist/dev/vidply.TranscriptManager-GZKY44ON.js.map +0 -7
- package/dist/dev/vidply.TranscriptManager-UTJBQC5B.js +0 -1744
- package/dist/dev/vidply.TranscriptManager-UTJBQC5B.js.map +0 -7
- package/dist/dev/vidply.chunk-5663PYKK.js +0 -1631
- package/dist/dev/vidply.chunk-5663PYKK.js.map +0 -7
- package/dist/dev/vidply.chunk-SRM7VNHG.js.map +0 -7
- package/dist/dev/vidply.chunk-UH5MTGKF.js +0 -1630
- package/dist/dev/vidply.chunk-UH5MTGKF.js.map +0 -7
- package/dist/dev/vidply.de-RXAJM5QE.js +0 -181
- package/dist/dev/vidply.de-RXAJM5QE.js.map +0 -7
- package/dist/dev/vidply.de-THBIMP4S.js +0 -180
- package/dist/dev/vidply.de-THBIMP4S.js.map +0 -7
- package/dist/dev/vidply.es-6VWDNNNL.js +0 -180
- package/dist/dev/vidply.es-6VWDNNNL.js.map +0 -7
- package/dist/dev/vidply.es-SADVLJTQ.js +0 -181
- package/dist/dev/vidply.es-SADVLJTQ.js.map +0 -7
- package/dist/dev/vidply.fr-V3VAYBBT.js +0 -181
- package/dist/dev/vidply.fr-V3VAYBBT.js.map +0 -7
- package/dist/dev/vidply.fr-WHTWCHWT.js +0 -180
- package/dist/dev/vidply.fr-WHTWCHWT.js.map +0 -7
- package/dist/dev/vidply.ja-BFQNPOFI.js +0 -180
- package/dist/dev/vidply.ja-BFQNPOFI.js.map +0 -7
- package/dist/dev/vidply.ja-KL2TLZGJ.js +0 -181
- package/dist/dev/vidply.ja-KL2TLZGJ.js.map +0 -7
- package/dist/prod/vidply.TranscriptManager-DZ2WZU3K.min.js +0 -6
- package/dist/prod/vidply.TranscriptManager-E5QHGFIR.min.js +0 -6
- package/dist/prod/vidply.TranscriptManager-UZ6DUFB6.min.js +0 -6
- package/dist/prod/vidply.chunk-5DWTMWEO.min.js +0 -6
- package/dist/prod/vidply.chunk-IBNYTGGM.min.js +0 -6
- package/dist/prod/vidply.chunk-MBUR3U5L.min.js +0 -6
- package/dist/prod/vidply.de-HGJBCLLE.min.js +0 -6
- package/dist/prod/vidply.de-SWFW4HYT.min.js +0 -6
- package/dist/prod/vidply.es-7BJ2DJAY.min.js +0 -6
- package/dist/prod/vidply.es-CZEBXCZN.min.js +0 -6
- package/dist/prod/vidply.fr-DPVR5DFY.min.js +0 -6
- package/dist/prod/vidply.fr-HFOL7MWA.min.js +0 -6
- package/dist/prod/vidply.ja-PEBVWKVH.min.js +0 -6
- package/dist/prod/vidply.ja-QTVU5C25.min.js +0 -6
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"format": "esm"
|
|
7
7
|
},
|
|
8
8
|
"src/utils/DOMUtils.js": {
|
|
9
|
-
"bytes":
|
|
9
|
+
"bytes": 7360,
|
|
10
10
|
"imports": [],
|
|
11
11
|
"format": "esm"
|
|
12
12
|
},
|
|
@@ -98,8 +98,13 @@
|
|
|
98
98
|
"imports": [],
|
|
99
99
|
"format": "esm"
|
|
100
100
|
},
|
|
101
|
+
"src/utils/PerformanceUtils.js": {
|
|
102
|
+
"bytes": 1820,
|
|
103
|
+
"imports": [],
|
|
104
|
+
"format": "esm"
|
|
105
|
+
},
|
|
101
106
|
"src/controls/ControlBar.js": {
|
|
102
|
-
"bytes":
|
|
107
|
+
"bytes": 131933,
|
|
103
108
|
"imports": [
|
|
104
109
|
{
|
|
105
110
|
"path": "src/utils/DOMUtils.js",
|
|
@@ -125,6 +130,11 @@
|
|
|
125
130
|
"path": "src/utils/FocusUtils.js",
|
|
126
131
|
"kind": "import-statement",
|
|
127
132
|
"original": "../utils/FocusUtils.js"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"path": "src/utils/PerformanceUtils.js",
|
|
136
|
+
"kind": "import-statement",
|
|
137
|
+
"original": "../utils/PerformanceUtils.js"
|
|
128
138
|
}
|
|
129
139
|
],
|
|
130
140
|
"format": "esm"
|
|
@@ -134,11 +144,6 @@
|
|
|
134
144
|
"imports": [],
|
|
135
145
|
"format": "esm"
|
|
136
146
|
},
|
|
137
|
-
"src/utils/PerformanceUtils.js": {
|
|
138
|
-
"bytes": 1820,
|
|
139
|
-
"imports": [],
|
|
140
|
-
"format": "esm"
|
|
141
|
-
},
|
|
142
147
|
"src/controls/CaptionManager.js": {
|
|
143
148
|
"bytes": 17842,
|
|
144
149
|
"imports": [
|
|
@@ -228,8 +233,55 @@
|
|
|
228
233
|
],
|
|
229
234
|
"format": "esm"
|
|
230
235
|
},
|
|
236
|
+
"src/core/AudioDescriptionManager.js": {
|
|
237
|
+
"bytes": 26497,
|
|
238
|
+
"imports": [
|
|
239
|
+
{
|
|
240
|
+
"path": "src/controls/CaptionManager.js",
|
|
241
|
+
"kind": "import-statement",
|
|
242
|
+
"original": "../controls/CaptionManager.js"
|
|
243
|
+
}
|
|
244
|
+
],
|
|
245
|
+
"format": "esm"
|
|
246
|
+
},
|
|
247
|
+
"src/core/SignLanguageManager.js": {
|
|
248
|
+
"bytes": 39788,
|
|
249
|
+
"imports": [
|
|
250
|
+
{
|
|
251
|
+
"path": "src/utils/DOMUtils.js",
|
|
252
|
+
"kind": "import-statement",
|
|
253
|
+
"original": "../utils/DOMUtils.js"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"path": "src/icons/Icons.js",
|
|
257
|
+
"kind": "import-statement",
|
|
258
|
+
"original": "../icons/Icons.js"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"path": "src/i18n/i18n.js",
|
|
262
|
+
"kind": "import-statement",
|
|
263
|
+
"original": "../i18n/i18n.js"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"path": "src/utils/DraggableResizable.js",
|
|
267
|
+
"kind": "import-statement",
|
|
268
|
+
"original": "../utils/DraggableResizable.js"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"path": "src/utils/MenuUtils.js",
|
|
272
|
+
"kind": "import-statement",
|
|
273
|
+
"original": "../utils/MenuUtils.js"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"path": "src/utils/FormUtils.js",
|
|
277
|
+
"kind": "import-statement",
|
|
278
|
+
"original": "../utils/FormUtils.js"
|
|
279
|
+
}
|
|
280
|
+
],
|
|
281
|
+
"format": "esm"
|
|
282
|
+
},
|
|
231
283
|
"src/controls/TranscriptManager.js": {
|
|
232
|
-
"bytes":
|
|
284
|
+
"bytes": 80133,
|
|
233
285
|
"imports": [
|
|
234
286
|
{
|
|
235
287
|
"path": "src/utils/DOMUtils.js",
|
|
@@ -306,7 +358,7 @@
|
|
|
306
358
|
"format": "esm"
|
|
307
359
|
},
|
|
308
360
|
"src/core/Player.js": {
|
|
309
|
-
"bytes":
|
|
361
|
+
"bytes": 210757,
|
|
310
362
|
"imports": [
|
|
311
363
|
{
|
|
312
364
|
"path": "src/utils/EventEmitter.js",
|
|
@@ -373,6 +425,16 @@
|
|
|
373
425
|
"kind": "import-statement",
|
|
374
426
|
"original": "../utils/PerformanceUtils.js"
|
|
375
427
|
},
|
|
428
|
+
{
|
|
429
|
+
"path": "src/core/AudioDescriptionManager.js",
|
|
430
|
+
"kind": "import-statement",
|
|
431
|
+
"original": "./AudioDescriptionManager.js"
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
"path": "src/core/SignLanguageManager.js",
|
|
435
|
+
"kind": "import-statement",
|
|
436
|
+
"original": "./SignLanguageManager.js"
|
|
437
|
+
},
|
|
376
438
|
{
|
|
377
439
|
"path": "src/controls/TranscriptManager.js",
|
|
378
440
|
"kind": "dynamic-import",
|
|
@@ -466,7 +528,7 @@
|
|
|
466
528
|
"entryPoint": "src/index.js",
|
|
467
529
|
"inputs": {
|
|
468
530
|
"src/utils/DOMUtils.js": {
|
|
469
|
-
"bytesInOutput":
|
|
531
|
+
"bytesInOutput": 2595
|
|
470
532
|
},
|
|
471
533
|
"src/i18n/languages/en.js": {
|
|
472
534
|
"bytesInOutput": 6175
|
|
@@ -490,7 +552,7 @@
|
|
|
490
552
|
"bytesInOutput": 2480
|
|
491
553
|
},
|
|
492
554
|
"src/utils/TimeUtils.js": {
|
|
493
|
-
"bytesInOutput":
|
|
555
|
+
"bytesInOutput": 896
|
|
494
556
|
},
|
|
495
557
|
"src/icons/Icons.js": {
|
|
496
558
|
"bytesInOutput": 9362
|
|
@@ -502,19 +564,19 @@
|
|
|
502
564
|
"bytesInOutput": 1638
|
|
503
565
|
},
|
|
504
566
|
"src/renderers/HTML5Renderer.js": {
|
|
505
|
-
"bytesInOutput":
|
|
567
|
+
"bytesInOutput": 4915
|
|
506
568
|
},
|
|
507
569
|
"src/utils/DraggableResizable.js": {
|
|
508
570
|
"bytesInOutput": 14166
|
|
509
571
|
},
|
|
510
572
|
"src/utils/MenuUtils.js": {
|
|
511
|
-
"bytesInOutput":
|
|
573
|
+
"bytesInOutput": 2298
|
|
512
574
|
},
|
|
513
575
|
"src/utils/FormUtils.js": {
|
|
514
|
-
"bytesInOutput":
|
|
576
|
+
"bytesInOutput": 798
|
|
515
577
|
},
|
|
516
578
|
"src/controls/TranscriptManager.js": {
|
|
517
|
-
"bytesInOutput":
|
|
579
|
+
"bytesInOutput": 43869
|
|
518
580
|
},
|
|
519
581
|
"src/renderers/YouTubeRenderer.js": {
|
|
520
582
|
"bytesInOutput": 4430
|
|
@@ -529,31 +591,37 @@
|
|
|
529
591
|
"bytesInOutput": 5597
|
|
530
592
|
},
|
|
531
593
|
"src/utils/EventEmitter.js": {
|
|
532
|
-
"bytesInOutput":
|
|
594
|
+
"bytesInOutput": 437
|
|
533
595
|
},
|
|
534
596
|
"src/core/Player.js": {
|
|
535
|
-
"bytesInOutput":
|
|
597
|
+
"bytesInOutput": 76421
|
|
536
598
|
},
|
|
537
599
|
"src/controls/ControlBar.js": {
|
|
538
|
-
"bytesInOutput":
|
|
539
|
-
},
|
|
540
|
-
"src/controls/CaptionManager.js": {
|
|
541
|
-
"bytesInOutput": 7463
|
|
600
|
+
"bytesInOutput": 58403
|
|
542
601
|
},
|
|
543
602
|
"src/utils/PerformanceUtils.js": {
|
|
544
|
-
"bytesInOutput":
|
|
603
|
+
"bytesInOutput": 257
|
|
604
|
+
},
|
|
605
|
+
"src/controls/CaptionManager.js": {
|
|
606
|
+
"bytesInOutput": 7462
|
|
545
607
|
},
|
|
546
608
|
"src/controls/KeyboardManager.js": {
|
|
547
609
|
"bytesInOutput": 4025
|
|
548
610
|
},
|
|
611
|
+
"src/core/AudioDescriptionManager.js": {
|
|
612
|
+
"bytesInOutput": 9690
|
|
613
|
+
},
|
|
614
|
+
"src/core/SignLanguageManager.js": {
|
|
615
|
+
"bytesInOutput": 19804
|
|
616
|
+
},
|
|
549
617
|
"src/features/PlaylistManager.js": {
|
|
550
|
-
"bytesInOutput":
|
|
618
|
+
"bytesInOutput": 21617
|
|
551
619
|
},
|
|
552
620
|
"src/index.js": {
|
|
553
621
|
"bytesInOutput": 1877
|
|
554
622
|
}
|
|
555
623
|
},
|
|
556
|
-
"bytes":
|
|
624
|
+
"bytes": 341389
|
|
557
625
|
}
|
|
558
626
|
}
|
|
559
627
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Universal, Accessible Video Player
|
|
3
|
+
* (c) 2025 Matthias Peltzer
|
|
4
|
+
* Released under GPL-2.0-or-later License
|
|
5
|
+
*/
|
|
6
|
+
import{a as o,b as r,c as M,d as b,f as v,h as C,i as P,j as f,k as w,m as S,n as z}from"./vidply.chunk-LGTJRPUL.min.js";var W=class{constructor(t){this.player=t,this.transcriptWindow=null,this.transcriptEntries=[],this.metadataCues=[],this.currentActiveEntry=null,this.isVisible=!1,this.storage=new C("vidply"),this.draggableResizable=null,this.settingsMenuVisible=!1,this.settingsMenu=null,this.settingsButton=null,this.settingsMenuJustOpened=!1,this.resizeOptionButton=null,this.resizeOptionText=null,this.dragOptionButton=null,this.dragOptionText=null,this.resizeModeIndicator=null,this.resizeModeIndicatorTimeout=null,this.transcriptResizeHandles=[],this.liveRegion=null,this.styleDialog=null,this.styleDialogVisible=!1,this.styleDialogJustOpened=!1,this.languageSelector=null,this.languageLabel=null,this.currentTranscriptLanguage=null,this.availableTranscriptLanguages=[],this.languageSelectorHandler=null;let i=this.storage.getTranscriptPreferences();this.autoscrollEnabled=i?.autoscroll!==void 0?i.autoscroll:!0,this.showTimestamps=i?.showTimestamps!==void 0?i.showTimestamps:!1,this.transcriptStyle={fontSize:i?.fontSize||this.player.options.transcriptFontSize||"100%",fontFamily:i?.fontFamily||this.player.options.transcriptFontFamily||"sans-serif",color:i?.color||this.player.options.transcriptColor||"#ffffff",backgroundColor:i?.backgroundColor||this.player.options.transcriptBackgroundColor||"#1e1e1e",opacity:i?.opacity??this.player.options.transcriptOpacity??.98},this.handlers={timeupdate:()=>this.updateActiveEntry(),audiodescriptionenabled:()=>{this.isVisible&&this.loadTranscriptData()},audiodescriptiondisabled:()=>{this.isVisible&&this.loadTranscriptData()},resize:null,settingsClick:null,settingsKeydown:null,documentClick:null,styleDialogKeydown:null},this.timeouts=new Set,this.init()}init(){this.setupMetadataHandlingOnLoad(),this.player.on("timeupdate",this.handlers.timeupdate),this.player.on("audiodescriptionenabled",this.handlers.audiodescriptionenabled),this.player.on("audiodescriptiondisabled",this.handlers.audiodescriptiondisabled),this.player.on("fullscreenchange",()=>{this.isVisible&&(window.innerWidth<768&&this.setupDragAndDrop(),(!this.draggableResizable||!this.draggableResizable.manuallyPositioned)&&this.setManagedTimeout(()=>this.positionTranscript(),100))})}toggleTranscript(){this.isVisible?this.hideTranscript():this.showTranscript()}showTranscript(){if(this.transcriptWindow){this.transcriptWindow.style.display="flex",this.isVisible=!0,this.player.controlBar&&typeof this.player.controlBar.updateTranscriptButton=="function"&&this.player.controlBar.updateTranscriptButton(),v(this.settingsButton,{delay:150});return}this.createTranscriptWindow(),this.loadTranscriptData(),this.transcriptWindow&&(this.transcriptWindow.style.display="flex",(!this.draggableResizable||!this.draggableResizable.manuallyPositioned)&&this.setManagedTimeout(()=>this.positionTranscript(),0),v(this.settingsButton,{delay:150})),this.isVisible=!0}hideTranscript({focusButton:t=!1}={}){if(this.transcriptWindow&&(this.transcriptWindow.style.display="none",this.isVisible=!1),this.draggableResizable&&this.draggableResizable.pointerResizeMode&&(this.draggableResizable.disablePointerResizeMode(),this.updateResizeOptionState()),this.hideResizeModeIndicator(),this.announceLive(""),this.player.controlBar&&typeof this.player.controlBar.updateTranscriptButton=="function"&&this.player.controlBar.updateTranscriptButton(),t){let i=this.player.controlBar?.controls?.transcript;i&&typeof i.focus=="function"&&i.focus({preventScroll:!0})}}createTranscriptWindow(){this.transcriptWindow=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-window`,attributes:{role:"dialog","aria-label":r.t("transcript.ariaLabel"),tabindex:"-1"}}),this.transcriptHeader=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-header`,attributes:{tabindex:"0"}}),this.headerLeft=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-header-left`});let t=r.t("transcript.settingsMenu");this.settingsButton=o.createElement("button",{className:`${this.player.options.classPrefix}-transcript-settings`,attributes:{type:"button","aria-label":t,"aria-expanded":"false"}}),this.settingsButton.appendChild(b("settings")),o.attachTooltip(this.settingsButton,t,this.player.options.classPrefix),this.handlers.settingsClick=d=>{d.preventDefault(),d.stopPropagation(),this.settingsMenuVisible?this.hideSettingsMenu():this.showSettingsMenu()},this.settingsButton.addEventListener("click",this.handlers.settingsClick),this.handlers.settingsKeydown=d=>{d.key==="d"||d.key==="D"?(d.preventDefault(),d.stopPropagation(),this.toggleKeyboardDragMode()):d.key==="r"||d.key==="R"?(d.preventDefault(),d.stopPropagation(),this.toggleResizeMode()):d.key==="Escape"&&this.settingsMenuVisible&&(d.preventDefault(),d.stopPropagation(),this.hideSettingsMenu())},this.settingsButton.addEventListener("keydown",this.handlers.settingsKeydown);let i=o.createElement("h3",{textContent:`${r.t("transcript.title")}. ${r.t("transcript.dragResizePrompt")}`}),e=`${this.player.options.classPrefix}-transcript-autoscroll-${Date.now()}`,a=o.createElement("label",{className:`${this.player.options.classPrefix}-transcript-autoscroll-label`,attributes:{for:e}});this.autoscrollCheckbox=o.createElement("input",{attributes:{id:e,type:"checkbox"}}),this.autoscrollEnabled&&(this.autoscrollCheckbox.checked=!0);let n=o.createElement("span",{textContent:r.t("transcript.autoscroll"),className:`${this.player.options.classPrefix}-transcript-autoscroll-text`});a.appendChild(this.autoscrollCheckbox),a.appendChild(n),this.autoscrollCheckbox.addEventListener("change",d=>{this.autoscrollEnabled=d.target.checked,this.saveAutoscrollPreference()}),this.transcriptHeader.appendChild(i),this.headerLeft.appendChild(this.settingsButton),this.headerLeft.appendChild(a);let p=`${this.player.options.classPrefix}-transcript-language-select-${Date.now()}`,{label:l,select:s}=S({classPrefix:this.player.options.classPrefix,labelClass:`${this.player.options.classPrefix}-transcript-language-label`,selectClass:`${this.player.options.classPrefix}-transcript-language-select`,labelText:"settings.language",selectId:p,hidden:!1});this.languageLabel=l,this.languageSelector=s;let c=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-language-wrapper`,attributes:{style:"display: none;"}});c.appendChild(this.languageLabel),c.appendChild(this.languageSelector),this.languageSelectorWrapper=c,z(c),this.headerLeft.appendChild(c);let h=r.t("transcript.close"),u=o.createElement("button",{className:`${this.player.options.classPrefix}-transcript-close`,attributes:{type:"button","aria-label":h}});u.appendChild(b("close")),o.attachTooltip(u,h,this.player.options.classPrefix),u.addEventListener("click",()=>this.hideTranscript({focusButton:!0})),this.transcriptHeader.appendChild(this.headerLeft),this.transcriptHeader.appendChild(u),this.transcriptContent=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-content`}),this.transcriptWindow.appendChild(this.transcriptHeader),this.transcriptWindow.appendChild(this.transcriptContent),this.createResizeHandles(),this.liveRegion=o.createElement("div",{className:"vidply-sr-only",attributes:{"aria-live":"polite","aria-atomic":"true"}}),this.transcriptWindow.appendChild(this.liveRegion),this.player.container.appendChild(this.transcriptWindow),this.setupDragAndDrop(),(!this.draggableResizable||!this.draggableResizable.manuallyPositioned)&&this.positionTranscript(),this.handlers.documentClick=d=>{this.settingsMenuJustOpened||this.styleDialogJustOpened||this.settingsButton&&this.settingsButton.contains(d.target)||this.settingsMenu&&this.settingsMenu.contains(d.target)||(this.settingsMenuVisible&&this.hideSettingsMenu(),this.styleDialogVisible&&this.styleDialog&&!this.styleDialog.contains(d.target)&&this.hideStyleDialog())},this.documentClickHandlerAdded=!1;let y;this.handlers.resize=()=>{y&&this.clearManagedTimeout(y),y=this.setManagedTimeout(()=>{(!this.draggableResizable||!this.draggableResizable.manuallyPositioned)&&this.positionTranscript()},100)},window.addEventListener("resize",this.handlers.resize)}createResizeHandles(){if(!this.transcriptWindow)return;let t=["n","s","e","w","ne","nw","se","sw"];this.transcriptResizeHandles=t.map(i=>{let e=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-resize-handle ${this.player.options.classPrefix}-transcript-resize-${i}`,attributes:{"data-direction":i,"data-vidply-managed-resize":"true","aria-hidden":"true"}});return e.style.display="none",this.transcriptWindow.appendChild(e),e})}positionTranscript(){if(!this.transcriptWindow||!this.player.videoWrapper||!this.isVisible||this.draggableResizable&&this.draggableResizable.manuallyPositioned)return;let t=window.innerWidth<768,i=this.player.videoWrapper.getBoundingClientRect(),e=this.player.state.fullscreen;if(t&&!e)this.transcriptWindow.style.position="relative",this.transcriptWindow.style.left="0",this.transcriptWindow.style.right="0",this.transcriptWindow.style.bottom="auto",this.transcriptWindow.style.top="auto",this.transcriptWindow.style.width="100%",this.transcriptWindow.style.maxWidth="100%",this.transcriptWindow.style.maxHeight="400px",this.transcriptWindow.style.height="auto",this.transcriptWindow.style.borderRadius="0",this.transcriptWindow.style.transform="none",this.transcriptWindow.style.border="none",this.transcriptWindow.style.borderTop="1px solid var(--vidply-border-light)",this.transcriptWindow.style.removeProperty("border-right"),this.transcriptWindow.style.removeProperty("border-bottom"),this.transcriptWindow.style.removeProperty("border-left"),this.transcriptWindow.style.removeProperty("border-image"),this.transcriptWindow.style.removeProperty("border-image-source"),this.transcriptWindow.style.removeProperty("border-image-slice"),this.transcriptWindow.style.removeProperty("border-image-width"),this.transcriptWindow.style.removeProperty("border-image-outset"),this.transcriptWindow.style.removeProperty("border-image-repeat"),this.transcriptWindow.style.boxShadow="none",this.transcriptHeader&&(this.transcriptHeader.style.cursor="default"),this.transcriptWindow.parentNode!==this.player.container&&this.player.container.appendChild(this.transcriptWindow);else if(e){this.transcriptWindow.style.position="fixed",this.transcriptWindow.style.left="auto",this.transcriptWindow.style.right="20px",this.transcriptWindow.style.bottom="80px",this.transcriptWindow.style.top="auto",this.transcriptWindow.style.maxHeight="calc(100vh - 180px)",this.transcriptWindow.style.height="auto";let a=260,n=Math.max(a,window.innerWidth-40),p=parseFloat(this.transcriptWindow.style.width)||400,l=Math.max(a,Math.min(p,n));this.transcriptWindow.style.width=`${l}px`,this.transcriptWindow.style.maxWidth="none",this.transcriptWindow.style.borderRadius="8px",this.transcriptWindow.style.border="1px solid var(--vidply-border)",this.transcriptWindow.style.removeProperty("border-top"),this.transcriptWindow.style.removeProperty("border-right"),this.transcriptWindow.style.removeProperty("border-bottom"),this.transcriptWindow.style.removeProperty("border-left"),this.transcriptWindow.style.removeProperty("border-image"),this.transcriptWindow.style.removeProperty("border-image-source"),this.transcriptWindow.style.removeProperty("border-image-slice"),this.transcriptWindow.style.removeProperty("border-image-width"),this.transcriptWindow.style.removeProperty("border-image-outset"),this.transcriptWindow.style.removeProperty("border-image-repeat"),this.transcriptHeader&&(this.transcriptHeader.style.cursor="move"),this.transcriptWindow.parentNode!==this.player.container&&this.player.container.appendChild(this.transcriptWindow)}else{let a=parseFloat(this.transcriptWindow.style.width)||400,n=20,p=260,l=this.player.container.getBoundingClientRect();window.getComputedStyle(this.player.container).position==="static"&&(this.player.container.style.position="relative");let c=i.right-l.left+n,h=window.innerWidth-i.right-n,u=Math.max(p,Math.min(a,h)),y=i.height;this.transcriptWindow.style.position="absolute",this.transcriptWindow.style.left=`${c}px`,this.transcriptWindow.style.right="auto",this.transcriptWindow.style.bottom="auto",this.transcriptWindow.style.top="0",this.transcriptWindow.style.height=`${y}px`,this.transcriptWindow.style.maxHeight="none",this.transcriptWindow.style.width=`${u}px`,this.transcriptWindow.style.maxWidth="none",this.transcriptWindow.style.borderRadius="8px",this.transcriptWindow.style.border="1px solid var(--vidply-border)",this.transcriptWindow.style.removeProperty("border-top"),this.transcriptWindow.style.removeProperty("border-right"),this.transcriptWindow.style.removeProperty("border-bottom"),this.transcriptWindow.style.removeProperty("border-left"),this.transcriptWindow.style.removeProperty("border-image"),this.transcriptWindow.style.removeProperty("border-image-source"),this.transcriptWindow.style.removeProperty("border-image-slice"),this.transcriptWindow.style.removeProperty("border-image-width"),this.transcriptWindow.style.removeProperty("border-image-outset"),this.transcriptWindow.style.removeProperty("border-image-repeat"),this.transcriptHeader&&(this.transcriptHeader.style.cursor="move"),this.transcriptWindow.parentNode!==this.player.container&&this.player.container.appendChild(this.transcriptWindow)}}getAvailableTranscriptLanguages(){let t=this.player.textTracks,i=new Map;return t.forEach(e=>{(e.kind==="captions"||e.kind==="subtitles")&&e.language&&(i.has(e.language)||i.set(e.language,{language:e.language,label:e.label||e.language,track:e}))}),Array.from(i.values())}updateLanguageSelector(){if(this.languageSelector){if(this.availableTranscriptLanguages=this.getAvailableTranscriptLanguages(),this.languageSelector.innerHTML="",this.availableTranscriptLanguages.length<2){this.languageSelectorWrapper&&(this.languageSelectorWrapper.style.display="none");return}if(this.languageSelectorWrapper&&(this.languageSelectorWrapper.style.display="flex"),this.availableTranscriptLanguages.forEach((t,i)=>{let e=o.createElement("option",{textContent:t.label,attributes:{value:t.language,lang:t.language}});this.languageSelector.appendChild(e)}),this.currentTranscriptLanguage)this.languageSelector.value=this.currentTranscriptLanguage;else if(this.availableTranscriptLanguages.length>0){let t=this.player.textTracks.find(i=>(i.kind==="captions"||i.kind==="subtitles")&&i.mode==="showing");this.currentTranscriptLanguage=t?t.language:this.availableTranscriptLanguages[0].language,this.languageSelector.value=this.currentTranscriptLanguage}this.languageSelectorHandler&&this.languageSelector.removeEventListener("change",this.languageSelectorHandler),this.languageSelectorHandler=t=>{this.currentTranscriptLanguage=t.target.value,this.loadTranscriptData(),this.transcriptContent&&this.currentTranscriptLanguage&&this.transcriptContent.setAttribute("lang",this.currentTranscriptLanguage)},this.languageSelector.addEventListener("change",this.languageSelectorHandler)}}loadTranscriptData(){this.transcriptEntries=[],this.transcriptContent.innerHTML="";let t=this.player.textTracks,i=null;this.currentTranscriptLanguage&&(i=t.find(s=>(s.kind==="captions"||s.kind==="subtitles")&&s.language===this.currentTranscriptLanguage)),i||(i=t.find(s=>s.kind==="captions"||s.kind==="subtitles"),i&&(this.currentTranscriptLanguage=i.language));let e=null;this.currentTranscriptLanguage&&(e=t.find(s=>s.kind==="descriptions"&&s.language===this.currentTranscriptLanguage)),e||(e=t.find(s=>s.kind==="descriptions"));let a=t.find(s=>s.kind==="metadata");if(!i&&!e&&!a){this.showNoTranscriptMessage();return}let n=[i,e,a].filter(Boolean);if(n.forEach(s=>{s.mode==="disabled"&&(s.mode="hidden")}),n.some(s=>!s.cues||s.cues.length===0)){let s=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-loading`,textContent:r.t("transcript.loading")});this.transcriptContent.appendChild(s);let c=0,h=()=>{c++,c>=n.length&&this.loadTranscriptData()};n.forEach(u=>{u.addEventListener("load",h,{once:!0})}),this.setManagedTimeout(()=>{this.loadTranscriptData()},500);return}let l=[];i&&i.cues&&Array.from(i.cues).forEach(s=>{l.push({cue:s,type:"caption"})}),e&&e.cues&&Array.from(e.cues).forEach(s=>{l.push({cue:s,type:"description"})}),a&&a.cues&&(this.metadataCues=Array.from(a.cues),this.setupMetadataHandling()),l.sort((s,c)=>s.cue.startTime-c.cue.startTime),l.forEach((s,c)=>{let h=this.createTranscriptEntry(s.cue,c,s.type);this.transcriptEntries.push({element:h,cue:s.cue,type:s.type,startTime:s.cue.startTime,endTime:s.cue.endTime}),this.transcriptContent.appendChild(h)}),this.applyTranscriptStyles(),this.updateTimestampVisibility(),this.transcriptContent&&this.currentTranscriptLanguage&&this.transcriptContent.setAttribute("lang",this.currentTranscriptLanguage),this.updateLanguageSelector()}setupMetadataHandlingOnLoad(){let t=()=>{let e=this.player.textTracks.find(a=>a.kind==="metadata");if(e){if(e.mode==="disabled"&&(e.mode="hidden"),this.metadataCueChangeHandler&&e.removeEventListener("cuechange",this.metadataCueChangeHandler),this.metadataCueChangeHandler=()=>{let a=Array.from(e.activeCues||[]);a.length>0&&this.player.options.debug&&console.log("[VidPly Metadata] Active cues:",a.map(n=>({start:n.startTime,end:n.endTime,text:n.text}))),a.forEach(n=>{this.handleMetadataCue(n)})},e.addEventListener("cuechange",this.metadataCueChangeHandler),this.player.options.debug){let a=e.cues?e.cues.length:0;console.log("[VidPly Metadata] Track enabled,",a,"cues available")}}else this.player.options.debug&&console.warn("[VidPly Metadata] No metadata track found")};t(),this.player.on("loadedmetadata",t)}setupMetadataHandling(){!this.metadataCues||this.metadataCues.length===0||this.player.options.debug&&console.log("[VidPly Metadata]",this.metadataCues.length,"cues stored from transcript load")}handleMetadataCue(t){let i=t.text.trim();this.player.options.debug&&console.log("[VidPly Metadata] Processing cue:",{time:t.startTime,text:i}),this.player.emit("metadata",{time:t.startTime,endTime:t.endTime,text:i,cue:t}),i.includes("PAUSE")&&(this.player.state.paused||(this.player.options.debug&&console.log("[VidPly Metadata] Pausing video at",t.startTime),this.player.pause()),this.player.emit("metadata:pause",{time:t.startTime,text:i}));let e=i.match(/FOCUS:([\w#-]+)/);if(e){let n=e[1],p=document.querySelector(n);p?(this.player.options.debug&&console.log("[VidPly Metadata] Focusing element:",n),this.setManagedTimeout(()=>{p.focus({preventScroll:!0})},10)):this.player.options.debug&&console.warn("[VidPly Metadata] Element not found:",n),this.player.emit("metadata:focus",{time:t.startTime,target:n,element:p,text:i})}let a=i.match(/#[\w-]+/g);a&&(this.player.options.debug&&console.log("[VidPly Metadata] Hashtags found:",a),this.player.emit("metadata:hashtags",{time:t.startTime,hashtags:a,text:i}))}createTranscriptEntry(t,i,e="caption"){let a=this.stripVTTFormatting(t.text),n=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-entry ${this.player.options.classPrefix}-transcript-${e}`,attributes:{tabindex:"0","data-start":String(t.startTime),"data-end":String(t.endTime),"data-type":e}}),p=o.createElement("span",{className:`${this.player.options.classPrefix}-transcript-time`,textContent:M.formatTime(t.startTime),attributes:{"aria-hidden":"true"}}),l=o.createElement("span",{className:`${this.player.options.classPrefix}-transcript-text`,textContent:a});n.appendChild(p),n.appendChild(l);let s=()=>{this.player.seek(t.startTime),this.player.state.paused&&this.player.play()};return n.addEventListener("click",s),n.addEventListener("keydown",c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),s())}),n}stripVTTFormatting(t){return t.replace(/<[^>]+>/g,"").replace(/\n/g," ").trim()}showNoTranscriptMessage(){let t=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-empty`,textContent:r.t("transcript.noTranscript")});this.transcriptContent.appendChild(t)}updateActiveEntry(){if(!this.isVisible||this.transcriptEntries.length===0)return;let t=this.player.state.currentTime,i=this.transcriptEntries.find(e=>t>=e.startTime&&t<e.endTime);i&&i!==this.currentActiveEntry?(this.currentActiveEntry&&this.currentActiveEntry.element.classList.remove(`${this.player.options.classPrefix}-transcript-entry-active`),i.element.classList.add(`${this.player.options.classPrefix}-transcript-entry-active`),this.scrollToEntry(i.element),this.currentActiveEntry=i):!i&&this.currentActiveEntry&&(this.currentActiveEntry.element.classList.remove(`${this.player.options.classPrefix}-transcript-entry-active`),this.currentActiveEntry=null)}scrollToEntry(t){if(!this.transcriptContent||!this.autoscrollEnabled)return;let i=this.transcriptContent.getBoundingClientRect(),e=t.getBoundingClientRect();if(e.top<i.top||e.bottom>i.bottom){let a=t.offsetTop-this.transcriptContent.clientHeight/2+t.clientHeight/2;this.transcriptContent.scrollTo({top:a,behavior:"smooth"})}}saveAutoscrollPreference(){let t=this.storage.getTranscriptPreferences()||{};t.autoscroll=this.autoscrollEnabled,this.storage.saveTranscriptPreferences(t)}setupDragAndDrop(){if(!this.transcriptHeader||!this.transcriptWindow)return;let t=window.innerWidth<768,i=this.player.state.fullscreen;if(t&&!i){this.draggableResizable&&(this.draggableResizable.destroy(),this.draggableResizable=null);return}this.draggableResizable||(this.draggableResizable=new P(this.transcriptWindow,{dragHandle:this.transcriptHeader,resizeHandles:this.transcriptResizeHandles,constrainToViewport:!0,classPrefix:`${this.player.options.classPrefix}-transcript`,keyboardDragKey:"d",keyboardResizeKey:"r",keyboardStep:10,keyboardStepLarge:50,minWidth:300,minHeight:200,maxWidth:()=>Math.max(320,window.innerWidth-40),maxHeight:()=>Math.max(200,window.innerHeight-120),pointerResizeIndicatorText:r.t("transcript.resizeModeHint"),onPointerResizeToggle:e=>{this.transcriptResizeHandles.forEach(a=>{a.style.display=e?"block":"none"}),this.onPointerResizeModeChange(e)},onDragStart:e=>{let a=[`.${this.player.options.classPrefix}-transcript-close`,`.${this.player.options.classPrefix}-transcript-settings`,`.${this.player.options.classPrefix}-transcript-language-select`,`.${this.player.options.classPrefix}-transcript-language-label`,`.${this.player.options.classPrefix}-transcript-settings-menu`,`.${this.player.options.classPrefix}-transcript-style-dialog`];for(let n of a)if(e.target.closest(n))return!1;return!0}}),this.customKeyHandler=e=>{let a=e.key.toLowerCase(),n=e.defaultPrevented;if(!(this.settingsMenuVisible||this.styleDialogVisible)){if(a==="home"){e.preventDefault(),e.stopPropagation(),this.draggableResizable&&(this.draggableResizable.pointerResizeMode&&this.draggableResizable.disablePointerResizeMode(),this.draggableResizable.manuallyPositioned=!1,this.positionTranscript(),this.updateResizeOptionState(),this.announceLive(r.t("transcript.positionReset")));return}if(a==="r"){if(n)return;e.preventDefault(),e.stopPropagation(),this.toggleResizeMode()&&this.transcriptWindow.focus({preventScroll:!0});return}if(a==="escape"){if(this.draggableResizable&&this.draggableResizable.pointerResizeMode){e.preventDefault(),e.stopPropagation(),this.draggableResizable.disablePointerResizeMode();return}if(this.draggableResizable&&this.draggableResizable.keyboardDragMode){e.preventDefault(),e.stopPropagation(),this.draggableResizable.disableKeyboardDragMode(),this.announceLive(r.t("transcript.dragModeDisabled"));return}e.preventDefault(),e.stopPropagation(),this.hideTranscript({focusButton:!0});return}}},this.transcriptWindow.addEventListener("keydown",this.customKeyHandler))}toggleKeyboardDragMode(){if(this.draggableResizable){let t=this.draggableResizable.keyboardDragMode;this.draggableResizable.toggleKeyboardDragMode();let i=this.draggableResizable.keyboardDragMode;!t&&i&&this.enableMoveMode(),this.updateDragOptionState(),this.settingsMenuVisible&&this.hideSettingsMenu(),this.transcriptWindow.focus({preventScroll:!0})}}toggleSettingsMenu(){this.settingsMenuVisible?this.hideSettingsMenu():this.showSettingsMenu()}showSettingsMenu(){if(this.settingsMenuJustOpened=!0,setTimeout(()=>{this.settingsMenuJustOpened=!1},350),this.documentClickHandlerAdded||setTimeout(()=>{document.addEventListener("click",this.handlers.documentClick),this.documentClickHandlerAdded=!0},300),this.settingsMenu){this.settingsMenu.style.display="block",this.settingsMenuVisible=!0,this.settingsButton&&this.settingsButton.setAttribute("aria-expanded","true"),this.attachSettingsMenuKeyboardNavigation(),this.positionSettingsMenuImmediate(),this.updateResizeOptionState(),setTimeout(()=>{let g=this.settingsMenu.querySelectorAll(`.${this.player.options.classPrefix}-transcript-settings-item`);if(g.length>0){g[0].setAttribute("tabindex","0");for(let m=1;m<g.length;m++)g[m].setAttribute("tabindex","-1");g[0].focus({preventScroll:!0})}},50);return}this.settingsMenu=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-settings-menu`,attributes:{role:"menu"}});let t=f({classPrefix:this.player.options.classPrefix,itemClass:`${this.player.options.classPrefix}-transcript-settings-item`,icon:"move",label:"transcript.enableDragMode",hasTextClass:!0,onClick:()=>{this.toggleKeyboardDragMode(),this.hideSettingsMenu()}});t.setAttribute("role","switch"),t.setAttribute("aria-checked","false");let i=t.querySelector(`.${this.player.options.classPrefix}-tooltip`);i&&i.remove();let e=t.querySelector(`.${this.player.options.classPrefix}-button-text`);e&&e.remove(),this.dragOptionButton=t,this.dragOptionText=t.querySelector(`.${this.player.options.classPrefix}-settings-text`),this.updateDragOptionState();let a=f({classPrefix:this.player.options.classPrefix,itemClass:`${this.player.options.classPrefix}-transcript-settings-item`,icon:"settings",label:"transcript.styleTranscript",onClick:g=>{g.preventDefault(),g.stopPropagation(),this.hideSettingsMenu(),setTimeout(()=>{this.showStyleDialog()},50)}}),n=a.querySelector(`.${this.player.options.classPrefix}-tooltip`);n&&n.remove();let p=a.querySelector(`.${this.player.options.classPrefix}-button-text`);p&&p.remove();let l=f({classPrefix:this.player.options.classPrefix,itemClass:`${this.player.options.classPrefix}-transcript-settings-item`,icon:"resize",label:"transcript.enableResizeMode",hasTextClass:!0,onClick:g=>{g.preventDefault(),g.stopPropagation(),this.toggleResizeMode({focus:!1})?(this.hideSettingsMenu({focusButton:!1}),setTimeout(()=>{this.transcriptWindow&&this.transcriptWindow.focus({preventScroll:!0})},20)):this.hideSettingsMenu({focusButton:!0})}});l.setAttribute("role","switch"),l.setAttribute("aria-checked","false");let s=l.querySelector(`.${this.player.options.classPrefix}-tooltip`);s&&s.remove();let c=l.querySelector(`.${this.player.options.classPrefix}-button-text`);c&&c.remove(),this.resizeOptionButton=l,this.resizeOptionText=l.querySelector(`.${this.player.options.classPrefix}-settings-text`),this.updateResizeOptionState();let h=f({classPrefix:this.player.options.classPrefix,itemClass:`${this.player.options.classPrefix}-transcript-settings-item`,icon:"clock",label:"transcript.showTimestamps",hasTextClass:!0,onClick:()=>{this.toggleShowTimestamps()}});h.setAttribute("role","switch"),h.setAttribute("aria-checked",this.showTimestamps?"true":"false");let u=h.querySelector(`.${this.player.options.classPrefix}-tooltip`);u&&u.remove();let y=h.querySelector(`.${this.player.options.classPrefix}-button-text`);y&&y.remove(),this.showTimestampsButton=h,this.showTimestampsText=h.querySelector(`.${this.player.options.classPrefix}-settings-text`),this.updateShowTimestampsState();let d=f({classPrefix:this.player.options.classPrefix,itemClass:`${this.player.options.classPrefix}-transcript-settings-item`,icon:"close",label:"transcript.closeMenu",onClick:()=>{this.hideSettingsMenu()}}),x=d.querySelector(`.${this.player.options.classPrefix}-tooltip`);x&&x.remove();let T=d.querySelector(`.${this.player.options.classPrefix}-button-text`);T&&T.remove(),this.settingsMenu.appendChild(t),this.settingsMenu.appendChild(l),this.settingsMenu.appendChild(a),this.settingsMenu.appendChild(h),this.settingsMenu.appendChild(d),this.settingsMenu.style.visibility="hidden",this.settingsMenu.style.display="block",this.settingsButton&&this.settingsButton.parentNode?this.settingsButton.insertAdjacentElement("afterend",this.settingsMenu):this.headerLeft?this.headerLeft.appendChild(this.settingsMenu):this.transcriptHeader?this.transcriptHeader.appendChild(this.settingsMenu):this.transcriptWindow.appendChild(this.settingsMenu),this.positionSettingsMenuImmediate(),requestAnimationFrame(()=>{this.settingsMenu&&(this.settingsMenu.style.visibility="visible")}),this.settingsMenuKeyHandler=w(this.settingsMenu,this.settingsButton,`.${this.player.options.classPrefix}-transcript-settings-item`,()=>this.hideSettingsMenu({focusButton:!0})),this.settingsMenuVisible=!0,this.settingsMenu.style.display="block",this.settingsButton&&this.settingsButton.setAttribute("aria-expanded","true"),this.updateResizeOptionState(),setTimeout(()=>{let g=this.settingsMenu.querySelectorAll(`.${this.player.options.classPrefix}-transcript-settings-item`);if(g.length>0){g[0].setAttribute("tabindex","0");for(let m=1;m<g.length;m++)g[m].setAttribute("tabindex","-1");g[0].focus({preventScroll:!0})}},50)}positionSettingsMenuImmediate(){if(!this.settingsMenu||!this.settingsButton)return;let t=this.settingsButton.parentElement;if(!t)return;let i=this.settingsButton.getBoundingClientRect(),e=t.getBoundingClientRect(),a=this.settingsMenu.getBoundingClientRect(),n=window.innerHeight,p=i.left-e.left,l=i.bottom-e.top,s=i.top-e.top,c=n-i.bottom,h=i.top,u=l+4;c<a.height+20&&h>c?(u=s-a.height-4,this.settingsMenu.classList.add("vidply-menu-above")):this.settingsMenu.classList.remove("vidply-menu-above"),this.settingsMenu.style.top=`${u}px`,this.settingsMenu.style.left=`${p}px`,this.settingsMenu.style.right="auto",this.settingsMenu.style.bottom="auto"}positionSettingsMenu(){!this.settingsMenu||!this.settingsButton||requestAnimationFrame(()=>{setTimeout(()=>{this.positionSettingsMenuImmediate()},10)})}attachSettingsMenuKeyboardNavigation(){if(!this.settingsMenu)return;this.settingsMenuKeyHandler&&this.settingsMenu.removeEventListener("keydown",this.settingsMenuKeyHandler,!0);let t=w(this.settingsMenu,this.settingsButton,`.${this.player.options.classPrefix}-transcript-settings-item`,()=>this.hideSettingsMenu({focusButton:!0}));this.settingsMenuKeyHandler=t}hideSettingsMenu({focusButton:t=!0}={}){this.settingsMenu&&(this.settingsMenu.style.display="none",this.settingsMenuVisible=!1,this.settingsMenuJustOpened=!1,this.settingsMenuKeyHandler&&(this.settingsMenu.removeEventListener("keydown",this.settingsMenuKeyHandler,!0),this.settingsMenuKeyHandler=null),this.settingsButton&&(this.settingsButton.setAttribute("aria-expanded","false"),t&&this.settingsButton.focus({preventScroll:!0})))}enableMoveMode(){this.hideResizeModeIndicator(),this.transcriptWindow.classList.add(`${this.player.options.classPrefix}-transcript-move-mode`);let t=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-move-tooltip`,textContent:"Drag with mouse or press D for keyboard drag mode"});this.transcriptHeader.appendChild(t),setTimeout(()=>{this.transcriptWindow.classList.remove(`${this.player.options.classPrefix}-transcript-move-mode`),t.parentNode&&t.remove()},2e3)}toggleResizeMode({focus:t=!0}={}){return this.draggableResizable?this.draggableResizable.pointerResizeMode?(this.draggableResizable.disablePointerResizeMode({focus:t}),!1):(this.draggableResizable.enablePointerResizeMode({focus:t}),!0):!1}updateDragOptionState(){if(!this.dragOptionButton)return;let t=!!(this.draggableResizable&&this.draggableResizable.keyboardDragMode),i=t?r.t("transcript.disableDragMode"):r.t("transcript.enableDragMode"),e=t?r.t("transcript.disableDragModeAria"):r.t("transcript.enableDragModeAria");this.dragOptionButton.setAttribute("aria-checked",t?"true":"false"),this.dragOptionButton.setAttribute("aria-label",e),this.dragOptionText&&(this.dragOptionText.textContent=i)}updateResizeOptionState(){if(!this.resizeOptionButton)return;let t=!!(this.draggableResizable&&this.draggableResizable.pointerResizeMode),i=t?r.t("transcript.disableResizeMode"):r.t("transcript.enableResizeMode"),e=t?r.t("transcript.disableResizeModeAria"):r.t("transcript.enableResizeModeAria");this.resizeOptionButton.setAttribute("aria-checked",t?"true":"false"),this.resizeOptionButton.setAttribute("aria-label",e),this.resizeOptionText&&(this.resizeOptionText.textContent=i)}toggleShowTimestamps(){this.showTimestamps=!this.showTimestamps,this.updateShowTimestampsState(),this.updateTimestampVisibility(),this.saveTimestampsPreference()}updateShowTimestampsState(){if(!this.showTimestampsButton)return;let t=this.showTimestamps?r.t("transcript.hideTimestamps"):r.t("transcript.showTimestamps"),i=this.showTimestamps?r.t("transcript.hideTimestampsAria"):r.t("transcript.showTimestampsAria");this.showTimestampsButton.setAttribute("aria-checked",this.showTimestamps?"true":"false"),this.showTimestampsButton.setAttribute("aria-label",i),this.showTimestampsText&&(this.showTimestampsText.textContent=t)}updateTimestampVisibility(){if(!this.transcriptContent)return;this.transcriptContent.querySelectorAll(`.${this.player.options.classPrefix}-transcript-time`).forEach(i=>{i.style.display=this.showTimestamps?"":"none"})}saveTimestampsPreference(){let t=this.storage.getTranscriptPreferences()||{};t.showTimestamps=this.showTimestamps,this.storage.saveTranscriptPreferences(t)}showResizeModeIndicator(){if(!this.transcriptHeader)return;this.hideResizeModeIndicator();let t=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-resize-tooltip`,textContent:r.t("transcript.resizeModeHint")||"Resize handles enabled. Drag edges or corners to adjust. Press Esc or R to exit."});this.transcriptHeader.appendChild(t),this.resizeModeIndicator=t,this.resizeModeIndicatorTimeout=this.setManagedTimeout(()=>{this.hideResizeModeIndicator()},3e3)}hideResizeModeIndicator(){this.resizeModeIndicatorTimeout&&(this.clearManagedTimeout(this.resizeModeIndicatorTimeout),this.resizeModeIndicatorTimeout=null),this.resizeModeIndicator&&this.resizeModeIndicator.parentNode&&this.resizeModeIndicator.remove(),this.resizeModeIndicator=null}onPointerResizeModeChange(t){this.updateResizeOptionState(),t?(this.showResizeModeIndicator(),this.announceLive(r.t("transcript.resizeModeEnabled"))):(this.hideResizeModeIndicator(),this.announceLive(r.t("transcript.resizeModeDisabled")))}showStyleDialog(){if(this.styleDialog){this.styleDialog.style.display="block",this.styleDialogVisible=!0,this.handlers.styleDialogKeydown&&document.addEventListener("keydown",this.handlers.styleDialogKeydown),this.styleDialogJustOpened=!0,setTimeout(()=>{this.styleDialogJustOpened=!1},350),setTimeout(()=>{let s=this.styleDialog.querySelector("select, input");s&&s.focus({preventScroll:!0})},0);return}this.styleDialog=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-dialog`});let t=o.createElement("h4",{textContent:r.t("transcript.styleTitle"),className:`${this.player.options.classPrefix}-transcript-style-title`});this.styleDialog.appendChild(t);let i=this.createStyleSelectControl(r.t("captions.fontSize"),"fontSize",[{label:r.t("fontSizes.small"),value:"90%"},{label:r.t("fontSizes.normal"),value:"100%"},{label:r.t("fontSizes.large"),value:"110%"},{label:r.t("fontSizes.xlarge"),value:"120%"}]);this.styleDialog.appendChild(i);let e=this.createStyleSelectControl(r.t("captions.fontFamily"),"fontFamily",[{label:r.t("fontFamilies.sansSerif"),value:"sans-serif"},{label:r.t("fontFamilies.serif"),value:"serif"},{label:r.t("fontFamilies.monospace"),value:"monospace"}]);this.styleDialog.appendChild(e);let a=this.createStyleColorControl(r.t("captions.color"),"color");this.styleDialog.appendChild(a);let n=this.createStyleColorControl(r.t("captions.backgroundColor"),"backgroundColor");this.styleDialog.appendChild(n);let p=this.createStyleOpacityControl(r.t("captions.opacity"),"opacity");this.styleDialog.appendChild(p);let l=o.createElement("button",{className:`${this.player.options.classPrefix}-transcript-style-close`,textContent:r.t("settings.close"),attributes:{type:"button"}});l.addEventListener("click",()=>this.hideStyleDialog()),this.styleDialog.appendChild(l),this.handlers.styleDialogKeydown=s=>{if(this.styleDialogVisible){if(s.key==="Escape"){s.preventDefault(),s.stopPropagation(),this.hideStyleDialog();return}if(s.key==="Tab"){let c=this.styleDialog.querySelectorAll("select, input, button"),h=c[0],u=c[c.length-1];s.shiftKey&&document.activeElement===h?(s.preventDefault(),u.focus({preventScroll:!0})):!s.shiftKey&&document.activeElement===u&&(s.preventDefault(),h.focus({preventScroll:!0}))}}},document.addEventListener("keydown",this.handlers.styleDialogKeydown),this.headerLeft?this.headerLeft.appendChild(this.styleDialog):this.transcriptHeader.appendChild(this.styleDialog),this.applyTranscriptStyles(),this.styleDialogVisible=!0,this.styleDialog.style.display="block",this.styleDialogJustOpened=!0,setTimeout(()=>{this.styleDialogJustOpened=!1},350),setTimeout(()=>{let s=this.styleDialog.querySelector("select, input");s&&s.focus({preventScroll:!0})},0)}hideStyleDialog(){this.styleDialog&&(this.styleDialog.style.display="none",this.styleDialogVisible=!1,this.handlers.styleDialogKeydown&&document.removeEventListener("keydown",this.handlers.styleDialogKeydown),this.settingsButton&&this.settingsButton.focus({preventScroll:!0}))}createStyleSelectControl(t,i,e){let a=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-group`}),n=`${this.player.options.classPrefix}-transcript-${i}-${Date.now()}`,p=o.createElement("label",{textContent:t,attributes:{for:n}});a.appendChild(p);let l=o.createElement("select",{className:`${this.player.options.classPrefix}-transcript-style-select`,attributes:{id:n}});return e.forEach(s=>{let c=o.createElement("option",{textContent:s.label,attributes:{value:s.value}});this.transcriptStyle[i]===s.value&&(c.selected=!0),l.appendChild(c)}),l.addEventListener("change",s=>{this.transcriptStyle[i]=s.target.value,this.applyTranscriptStyles(),this.savePreferences()}),a.appendChild(l),a}createStyleColorControl(t,i){let e=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-group`}),a=`${this.player.options.classPrefix}-transcript-${i}-${Date.now()}`,n=o.createElement("label",{textContent:t,attributes:{for:a}});e.appendChild(n);let p=o.createElement("input",{attributes:{id:a,type:"color",value:this.transcriptStyle[i]},className:`${this.player.options.classPrefix}-transcript-style-color`});return p.addEventListener("input",l=>{this.transcriptStyle[i]=l.target.value,this.applyTranscriptStyles(),this.savePreferences()}),e.appendChild(p),e}createStyleOpacityControl(t,i){let e=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-group`}),a=`${this.player.options.classPrefix}-transcript-${i}-${Date.now()}`,n=o.createElement("label",{textContent:t,attributes:{for:a}});e.appendChild(n);let p=o.createElement("span",{textContent:Math.round(this.transcriptStyle[i]*100)+"%",className:`${this.player.options.classPrefix}-transcript-style-value`}),l=o.createElement("input",{attributes:{id:a,type:"range",min:"0",max:"1",step:"0.1",value:String(this.transcriptStyle[i])},className:`${this.player.options.classPrefix}-transcript-style-range`});l.addEventListener("input",c=>{let h=parseFloat(c.target.value);this.transcriptStyle[i]=h,p.textContent=Math.round(h*100)+"%",this.applyTranscriptStyles(),this.savePreferences()});let s=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-range-container`});return s.appendChild(l),s.appendChild(p),e.appendChild(n),e.appendChild(s),e}savePreferences(){this.storage.saveTranscriptPreferences(this.transcriptStyle)}applyTranscriptStyles(){if(!this.transcriptWindow)return;this.transcriptWindow.style.backgroundColor=this.transcriptStyle.backgroundColor,this.transcriptWindow.style.opacity=String(this.transcriptStyle.opacity),this.transcriptContent&&(this.transcriptContent.style.fontSize=this.transcriptStyle.fontSize,this.transcriptContent.style.fontFamily=this.transcriptStyle.fontFamily,this.transcriptContent.style.color=this.transcriptStyle.color),this.transcriptWindow.querySelectorAll(`.${this.player.options.classPrefix}-transcript-text`).forEach(e=>{e.style.fontSize=this.transcriptStyle.fontSize,e.style.fontFamily=this.transcriptStyle.fontFamily,e.style.color=this.transcriptStyle.color}),this.transcriptWindow.querySelectorAll(`.${this.player.options.classPrefix}-transcript-time`).forEach(e=>{e.style.fontFamily=this.transcriptStyle.fontFamily})}setManagedTimeout(t,i){let e=setTimeout(()=>{this.timeouts.delete(e),t()},i);return this.timeouts.add(e),e}clearManagedTimeout(t){t&&(clearTimeout(t),this.timeouts.delete(t))}destroy(){this.hideResizeModeIndicator(),this.draggableResizable&&(this.draggableResizable.pointerResizeMode&&(this.draggableResizable.disablePointerResizeMode(),this.updateResizeOptionState()),this.draggableResizable.destroy(),this.draggableResizable=null),this.transcriptWindow&&this.customKeyHandler&&(this.transcriptWindow.removeEventListener("keydown",this.customKeyHandler),this.customKeyHandler=null),this.handlers.timeupdate&&this.player.off("timeupdate",this.handlers.timeupdate),this.handlers.audiodescriptionenabled&&this.player.off("audiodescriptionenabled",this.handlers.audiodescriptionenabled),this.handlers.audiodescriptiondisabled&&this.player.off("audiodescriptiondisabled",this.handlers.audiodescriptiondisabled),this.settingsButton&&(this.handlers.settingsClick&&this.settingsButton.removeEventListener("click",this.handlers.settingsClick),this.handlers.settingsKeydown&&this.settingsButton.removeEventListener("keydown",this.handlers.settingsKeydown)),this.handlers.styleDialogKeydown&&document.removeEventListener("keydown",this.handlers.styleDialogKeydown),this.handlers.documentClick&&document.removeEventListener("click",this.handlers.documentClick),this.handlers.resize&&window.removeEventListener("resize",this.handlers.resize),this.timeouts.forEach(t=>clearTimeout(t)),this.timeouts.clear(),this.handlers=null,this.transcriptWindow&&this.transcriptWindow.parentNode&&this.transcriptWindow.parentNode.removeChild(this.transcriptWindow),this.transcriptWindow=null,this.transcriptHeader=null,this.transcriptContent=null,this.transcriptEntries=[],this.settingsMenu=null,this.styleDialog=null,this.transcriptResizeHandles=[],this.resizeOptionButton=null,this.resizeOptionText=null,this.liveRegion=null}announceLive(t){this.liveRegion&&(this.liveRegion.textContent=t||"")}};export{W as TranscriptManager};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Universal, Accessible Video Player
|
|
3
|
+
* (c) 2025 Matthias Peltzer
|
|
4
|
+
* Released under GPL-2.0-or-later License
|
|
5
|
+
*/
|
|
6
|
+
var m={createElement(i,e={}){let t=document.createElement(i);if(e.className&&(t.className=e.className),e.attributes)for(let[s,o]of Object.entries(e.attributes))t.setAttribute(s,o);if(e.innerHTML&&(t.innerHTML=e.innerHTML),e.textContent&&(t.textContent=e.textContent),e.style&&Object.assign(t.style,e.style),e.children)for(let s of e.children)s&&t.appendChild(s);return t},show(i){i?.style&&(i.style.display="")},hide(i){i?.style&&(i.style.display="none")},fadeIn(i,e=300,t){if(i&&(i.style.opacity="0",i.style.display="",i.style.transition=`opacity ${e}ms ease`,i.offsetHeight,i.style.opacity="1",t)){let s=()=>{i.removeEventListener("transitionend",s),t()};i.addEventListener("transitionend",s,{once:!0}),setTimeout(s,e+50)}},fadeOut(i,e=300,t){if(!i)return;i.style.transition=`opacity ${e}ms ease`,i.style.opacity="0";let s=()=>{i.removeEventListener("transitionend",s),i.style.display="none",t&&t()};i.addEventListener("transitionend",s,{once:!0}),setTimeout(s,e+50)},offset(i){if(!i)return{top:0,left:0,width:0,height:0};let e=i.getBoundingClientRect();return{top:e.top+window.scrollY,left:e.left+window.scrollX,width:e.width,height:e.height}},escapeHTML(i){let e={"&":"&","<":"<",">":">",'"':""","'":"'"};return i.replace(/[&<>"']/g,t=>e[t])},sanitizeHTML(i){let e=i.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/on\w+\s*=/gi,"").replace(/javascript:/gi,""),t=document.createElement("div");return t.innerHTML=e,t.innerHTML},createTooltip(i,e="vidply"){return this.createElement("span",{className:`${e}-tooltip`,textContent:i,attributes:{"aria-hidden":"true"}})},attachTooltip(i,e,t="vidply"){if(!i||!e)return;i.querySelector(`.${t}-tooltip`)?.remove();let s=this.createTooltip(e,t);i.appendChild(s);let o=`${t}-tooltip-visible`,n=()=>s.classList.add(o),r=()=>s.classList.remove(o);i.addEventListener("mouseenter",n),i.addEventListener("mouseleave",r),i.addEventListener("focus",n),i.addEventListener("blur",r)},createButtonText(i,e="vidply"){return this.createElement("span",{className:`${e}-button-text`,textContent:i,attributes:{"aria-hidden":"true"}})},addClass(i,e){i?.classList?.add(e)},removeClass(i,e){i?.classList?.remove(e)},toggleClass(i,e){i?.classList?.toggle(e)},hasClass(i,e){return i?.classList?.contains(e)??!1}};var w={player:{label:"Video Player",play:"Play",pause:"Pause",stop:"Stop",restart:"Restart from beginning",rewind:"Rewind",forward:"Forward",rewindSeconds:"Rewind {seconds} seconds",forwardSeconds:"Forward {seconds} seconds",previous:"Previous track",next:"Next track",playlist:"Toggle playlist",volume:"Volume",mute:"Mute",unmute:"Unmute",fullscreen:"Fullscreen",exitFullscreen:"Exit Fullscreen",captions:"Captions",chapters:"Chapters",quality:"Quality",captionStyling:"Caption styling",transcript:"Toggle transcript",audioDescription:"Audio description",signLanguage:"Sign language video",settings:"Settings",speed:"Playback Speed",pip:"Picture in Picture",currentTime:"Current time",duration:"Duration",progress:"Progress",seekForward:"Seek forward {seconds} seconds",seekBackward:"Seek backward {seconds} seconds",volumeUp:"Volume up",volumeDown:"Volume down",loading:"Loading...",loadingChapters:"Loading chapters...",error:"Error loading media",buffering:"Buffering...",signLanguageVideo:"Sign Language Video",closeSignLanguage:"Close sign language video",signLanguageSettings:"Sign language settings",noChapters:"No chapters available",noCaptions:"No captions available",auto:"Auto",autoQuality:"Auto (no quality selection available)",noQuality:"Quality selection not available",signLanguageDragResize:"Sign Language Video - Press D to drag with keyboard, R to resize",signLanguageDragActive:"Sign Language Video - Drag mode active. Use arrow keys to move, Escape to exit.",signLanguageResizeActive:"Sign Language Video - Resize mode active. Use left/right arrow keys to resize, Escape to exit.",enableSignDragMode:"Enable drag mode. Shortcut: D key",disableSignDragMode:"Disable drag mode. Shortcut: D key",enableSignDragModeAria:"Enable toggle keyboard drag mode with arrow keys. Shortcut: D key",disableSignDragModeAria:"Disable toggle keyboard drag mode with arrow keys. Shortcut: D key",enableSignResizeMode:"Enable resize mode. Shortcut: R key",disableSignResizeMode:"Disable resize mode. Shortcut: R key",enableSignResizeModeAria:"Enable keyboard resize mode with arrow keys. Shortcut: R key",disableSignResizeModeAria:"Disable keyboard resize mode with arrow keys. Shortcut: R key",resizeHandle:"Resize {direction} corner",moreOptions:"More options",noMoreOptions:"No additional options available"},captions:{off:"Off",select:"Select captions",fontSize:"Font Size",fontFamily:"Font Family",color:"Text Color",backgroundColor:"Background Color",opacity:"Opacity"},fontSizes:{small:"Small",normal:"Normal",large:"Large",xlarge:"X-Large"},fontFamilies:{sansSerif:"Sans-serif",serif:"Serif",monospace:"Monospace"},styleLabels:{textColor:"Text Color",background:"Background",font:"Font",fontSize:"Font Size",opacity:"Opacity"},audioDescription:{enable:"Enable audio description",disable:"Disable audio description"},signLanguage:{show:"Show sign language video",hide:"Hide sign language video"},transcript:{title:"Transcript",ariaLabel:"Video Transcript",close:"Close transcript",loading:"Loading transcript...",noTranscript:"No transcript available for this video.",settings:"Transcript settings. Press Enter to open menu, or D to enable drag mode",keyboardDragMode:"Toggle keyboard drag mode with arrow keys. Shortcut: D key",keyboardDragActive:"⌨️ Keyboard Drag Mode Active (Arrow keys to move, Shift+Arrows for large steps, D or ESC to exit)",dragResizePrompt:"Press D to drag or R to resize. Use Home to reset position, Esc to close.",dragModeEnabled:"Keyboard drag mode enabled. Use arrow keys to move, Shift+Arrow for larger steps. Press D or Esc to exit.",dragModeDisabled:"Keyboard drag mode disabled.",enableDragMode:"Enable drag mode. Shortcut: D key",disableDragMode:"Disable drag mode. Shortcut: D key",enableDragModeAria:"Enable toggle keyboard drag mode with arrow keys. Shortcut: D key",disableDragModeAria:"Disable toggle keyboard drag mode with arrow keys. Shortcut: D key",resizeWindow:"Resize Window",disableResizeWindow:"Disable Resize Mode",enableResizeMode:"Enable resize mode. Shortcut: R key",disableResizeMode:"Disable resize mode. Shortcut: R key",enableResizeModeAria:"Enable keyboard resize mode with arrow keys. Shortcut: R key",disableResizeModeAria:"Disable keyboard resize mode with arrow keys. Shortcut: R key",resizeModeHint:"Resize handles enabled. Drag edges or corners to adjust. Press Esc or R to exit.",resizeModeEnabled:"Resize mode enabled. Drag edges or corners to adjust. Press Esc or R to exit.",resizeModeDisabled:"Resize mode disabled.",positionReset:"Transcript position reset.",styleTranscript:"Open transcript style settings",closeMenu:"Close Menu",styleTitle:"Transcript Style",autoscroll:"Autoscroll",settingsMenu:"Transcript dialog settings",showTimestamps:"Show timestamps",hideTimestamps:"Hide timestamps",showTimestampsAria:"Show timestamps in transcript",hideTimestampsAria:"Hide timestamps in transcript"},settings:{title:"Settings",quality:"Quality",speed:"Speed",captions:"Captions",language:"Language",reset:"Reset to defaults",close:"Close"},speeds:{normal:"Normal"},time:{display:"Time display",durationPrefix:"Duration: ",of:"of",hour:"{count} hour",hours:"{count} hours",minute:"{count} minute",minutes:"{count} minutes",second:"{count} second",seconds:"{count} seconds"},playlist:{title:"Playlist",trackOf:"Track {current} of {total}",nowPlaying:"Now playing: Track {current} of {total}. {title}{artist}",by:" by ",untitled:"Untitled",trackUntitled:"Track {number}",currentlyPlaying:"Currently playing",notPlaying:"Not playing",pressEnterPlay:"Press Enter to play",pressEnterRestart:"Press Enter to restart",keyboardInstructions:"Playlist navigation: Use Up and Down arrow keys to move between tracks. Press Page Up or Page Down to skip 5 tracks. Press Home to go to first track, End to go to last track. Press Enter or Space to play the selected track.",endOfPlaylist:"End of playlist. {current} of {total}.",beginningOfPlaylist:"Beginning of playlist. 1 of {total}.",jumpedToLastTrack:"Jumped to last track. {current} of {total}.",jumpedToFirstTrack:"Jumped to first track. 1 of {total}.",firstTrack:"First track. 1 of {total}.",lastTrack:"Last track. {current} of {total}."}};var M={de:()=>import("./vidply.de-FR3XX54P.min.js"),es:()=>import("./vidply.es-3IJCQLJ7.min.js"),fr:()=>import("./vidply.fr-NC4VEAPH.min.js"),ja:()=>import("./vidply.ja-4ZC6ZQLV.min.js")};function y(){return{en:w}}function k(){return M}async function S(i){let e=M[i];if(!e)return null;let t=await e();return t[i]||t.default||null}var V=y();var v=class{constructor(){this.currentLanguage="en",this.translations=y(),this.loadingPromises=new Map,this.builtInLanguageLoaders=k()}setLanguage(e){this.translations[e]?this.currentLanguage=e:(console.warn(`Language "${e}" not found, falling back to English`),this.currentLanguage="en")}getLanguage(){return this.currentLanguage}async ensureLanguage(e){let t=(e||"").toLowerCase();if(!t)return this.currentLanguage;if(this.translations[t])return t;if(this.loadingPromises.has(t))return await this.loadingPromises.get(t),this.translations[t]?t:null;if(!this.builtInLanguageLoaders[t])return null;let s=(async()=>{try{let o=await S(t);o&&(this.translations[t]=o)}catch(o){console.warn(`Language "${t}" failed to load:`,o)}finally{this.loadingPromises.delete(t)}})();return this.loadingPromises.set(t,s),await s,this.translations[t]?t:null}t(e,t={}){let s=e.split("."),o=this.translations[this.currentLanguage];for(let n of s)if(o&&typeof o=="object"&&n in o)o=o[n];else{o=this.translations.en;for(let r of s)if(o&&typeof o=="object"&&r in o)o=o[r];else return e;break}return typeof o=="string"&&Object.entries(t).forEach(([n,r])=>{o=o.replace(new RegExp(`{${n}}`,"g"),r)}),o}addTranslation(e,t){this.translations[e]||(this.translations[e]={}),Object.assign(this.translations[e],t)}async loadLanguageFromUrl(e,t){if(this.loadingPromises.has(t))return this.loadingPromises.get(t);let s=(async()=>{try{let o=await fetch(t);if(!o.ok)throw new Error(`Failed to load language file: ${o.statusText}`);let n=o.headers.get("content-type")||"",r,d=await o.arrayBuffer(),a=new TextDecoder("utf-8").decode(d);if(n.includes("application/json")||t.endsWith(".json"))r=JSON.parse(a);else if(n.includes("text/yaml")||n.includes("application/x-yaml")||t.endsWith(".yaml")||t.endsWith(".yml"))try{r=JSON.parse(a)}catch{if(typeof window<"u"&&window.jsyaml)r=window.jsyaml.load(a);else throw console.warn("YAML parsing requires js-yaml library. Please include it or use JSON format."),new Error("YAML parsing not available. Please use JSON format or include js-yaml library.")}else r=JSON.parse(a);return this.addTranslation(e,r),r}catch(o){throw console.error(`Error loading language file from ${t}:`,o),o}finally{this.loadingPromises.delete(t)}})();return this.loadingPromises.set(t,s),s}async loadLanguagesFromUrls(e){let t=Object.entries(e).map(([s,o])=>this.loadLanguageFromUrl(s,o));await Promise.all(t)}},p=new v;var I={formatTime(i,e=!1){if(!isFinite(i)||i<0)return e?"00:00:00":"00:00";let t=Math.floor(i/3600),s=Math.floor(i%3600/60),o=Math.floor(i%60),n=r=>String(r).padStart(2,"0");return t>0||e?`${n(t)}:${n(s)}:${n(o)}`:`${n(s)}:${n(o)}`},parseTime(i){let e=i.split(":").map(t=>parseInt(t,10));return e.length===3?e[0]*3600+e[1]*60+e[2]:e.length===2?e[0]*60+e[1]:e.length===1?e[0]:0},formatDuration(i){if(!isFinite(i)||i<0)return p.t("time.seconds",{count:0});let e=Math.floor(i/3600),t=Math.floor(i%3600/60),s=Math.floor(i%60),o=[];if(e>0){let n=e===1?"time.hour":"time.hours";o.push(p.t(n,{count:e}))}if(t>0){let n=t===1?"time.minute":"time.minutes";o.push(p.t(n,{count:t}))}if(s>0||o.length===0){let n=s===1?"time.second":"time.seconds";o.push(p.t(n,{count:s}))}return o.join(", ")},formatPercentage(i,e){return e===0?0:Math.round(i/e*100)}};var E={play:'<path d="M8 5v14l11-7z"/>',pause:'<path d="M6 4h4v16H6V4zm8 0h4v16h-4V4z"/>',stop:'<rect x="6" y="6" width="12" height="12"/>',rewind:'<path d="M11 18V6l-8.5 6 8.5 6zm.5-6l8.5 6V6l-8.5 6z"/>',forward:'<path d="M4 18l8.5-6L4 6v12zm9-12v12l8.5-6L13 6z"/>',skipPrevious:'<path d="M6 6h2v12H6V6zm3 6l8.5 6V6L9 12z"/>',skipNext:'<path d="M16 6h2v12h-2V6zM6 6l8.5 6L6 18V6z"/>',restart:'<path d="M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z"/>',volumeHigh:'<path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/>',volumeMedium:'<path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02z"/>',volumeLow:'<path d="M7 9v6h4l5 5V4l-5 5H7z"/>',volumeMuted:'<path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"/>',fullscreen:'<path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/>',fullscreenExit:'<path d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"/>',settings:'<path d="M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94L14.4 2.81c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"/>',captions:'<path d="M19 4H5c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-8 7H9.5v-.5h-2v3h2V13H11v1c0 .55-.45 1-1 1H7c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1v1zm7 0h-1.5v-.5h-2v3h2V13H18v1c0 .55-.45 1-1 1h-3c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1v1z"/>',captionsOff:'<path d="M19 4H5c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-8 7H9.5v-.5h-2v3h2V13H11v1c0 .55-.45 1-1 1H7c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1v1zm7 0h-1.5v-.5h-2v3h2V13H18v1c0 .55-.45 1-1 1h-3c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1v1z"/><path d="M0 0h24v24H0z" fill="none"/>',pip:'<path d="M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 1.98 2 1.98h18c1.1 0 2-.88 2-1.98V5c0-1.1-.9-2-2-2zm0 16.01H3V4.98h18v14.03z"/>',speed:'<path d="M20.38 8.57l-1.23 1.85a8 8 0 0 1-.22 7.58H5.07A8 8 0 0 1 15.58 6.85l1.85-1.23A10 10 0 0 0 3.35 19a2 2 0 0 0 1.72 1h13.85a2 2 0 0 0 1.74-1 10 10 0 0 0-.27-10.44z"/><path d="M10.59 15.41a2 2 0 0 0 2.83 0l5.66-8.49-8.49 5.66a2 2 0 0 0 0 2.83z"/>',close:'<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>',check:'<path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/>',loading:'<path d="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0-4.42-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6 0-1.01.25-1.97.7-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4-4-4-4v3z"/>',error:'<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"/>',playlist:'<path d="M15 6H3v2h12V6zm0 4H3v2h12v-2zM3 16h8v-2H3v2zM17 6v8.18c-.31-.11-.65-.18-1-.18-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3V8h3V6h-5z"/>',hd:'<path d="M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-8 12H9.5v-2h-2v2H6V9h1.5v2.5h2V9H11v6zm7-1c0 .55-.45 1-1 1h-.75v1.5h-1.5V15H14c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1v4zm-3.5-.5h2v-3h-2v3z"/>',transcript:'<path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"/>',chapters:'<path d="M3 5h2v2H3V5zm0 4h2v2H3V9zm0 4h2v2H3v-2zm0 4h2v2H3v-2zM7 5h14v2H7V5zm0 4h14v2H7V9zm0 4h14v2H7v-2zm0 4h14v2H7v-2z"/>',audioDescription:'<rect x="2" y="5" width="20" height="14" rx="2" fill="#ffffff" stroke="#ffffff" stroke-width="2"/><text x="12" y="16" font-family="Arial, sans-serif" font-size="10" font-weight="bold" text-anchor="middle" fill="#1a1a1a">AD</text>',audioDescriptionOn:'<rect x="2" y="5" width="20" height="14" rx="2" fill="none" stroke="currentColor" stroke-width="2"/><text x="12" y="16" font-family="Arial, sans-serif" font-size="10" font-weight="bold" text-anchor="middle" fill="currentColor">AD</text>',signLanguage:'<g transform="scale(1.5)"><path d="M16 11.3c-.1-.9-4.8 1.3-5.4 1.1-2.6-1 5.8-1.3 5.1-2.9s-5.1 1.5-6 1.4C6.5 9.4 16.5 9.1 13.5 8c-1.9-.6-8.8 2.9-6.8.4.7-.6.7-1.9-.7-1.7-9.7 7.2-.7 12.2 8.8 7 0-1.3-3.5.4-4.1.4-2.6 0 5.6-2 5.4-3ZM3.9 7.8c3.2-4.2 3.7 1.2 6 .1s.2-.2.2-.3c.7-2.7 2.5-7.5-1.5-1.3-1.6 0 1.1-4 1-4.6C8.9-1 7.3 4.4 7.2 4.9c-1.6.7-.9-1.4-.7-1.5 3-6-.6-3.1-.9.4-2.5 1.8 0-2.8 0-3.5C2.8-.9 4 9.4 1.1 4.9S.1 4.6 0 5c-.4 2.7 2.6 7.2 3.9 2.8Z"/></g>',signLanguageOn:'<g transform="scale(1.5)"><path d="M16 11.3c-.1-.9-4.8 1.3-5.4 1.1-2.6-1 5.8-1.3 5.1-2.9s-5.1 1.5-6 1.4C6.5 9.4 16.5 9.1 13.5 8c-1.9-.6-8.8 2.9-6.8.4.7-.6.7-1.9-.7-1.7-9.7 7.2-.7 12.2 8.8 7 0-1.3-3.5.4-4.1.4-2.6 0 5.6-2 5.4-3ZM3.9 7.8c3.2-4.2 3.7 1.2 6 .1s.2-.2.2-.3c.7-2.7 2.5-7.5-1.5-1.3-1.6 0 1.1-4 1-4.6C8.9-1 7.3 4.4 7.2 4.9c-1.6.7-.9-1.4-.7-1.5 3-6-.6-3.1-.9.4-2.5 1.8 0-2.8 0-3.5C2.8-.9 4 9.4 1.1 4.9S.1 4.6 0 5c-.4 2.7 2.6 7.2 3.9 2.8Z"/></g>',music:'<path d="M12 3v9.28c-.47-.17-.97-.28-1.5-.28C8.01 12 6 14.01 6 16.5S8.01 21 10.5 21c2.31 0 4.2-1.75 4.45-4H15V6h4V3h-7zm-1.5 16c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"/>',moreVertical:'<path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/>',move:'<path d="M10 9h4V6h3l-5-5-5 5h3v3zm-1 1H6V7l-5 5 5 5v-3h3v-4zm14 2l-5-5v3h-3v4h3v3l5-5zm-9 3h-4v3H7l5 5 5-5h-3v-3z"/>',resize:'<path d="M21.71 11.29l-9-9c-.39-.39-1.02-.39-1.41 0l-9 9c-.39.39-.39 1.02 0 1.41l9 9c.39.39 1.02.39 1.41 0l9-9c.39-.38.39-1.01 0-1.41zM14 14.5V12h-4v2.5L7 11l3-3.5V10h4V7.5l3 3.5-3 3.5z"/>',clock:'<path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/><path d="M12.5 7H11v6l5.25 3.15.75-1.23-4.5-2.67z"/>'},H=i=>`<svg viewBox="0 0 24 24" fill="currentColor">${i}</svg>`,L=Object.fromEntries(Object.entries(E).map(([i,e])=>[i,H(e)]));function P(i){return L[i]||L.play}function D(i,e=""){let t=document.createElement("span");return t.className=`vidply-icon ${e}`.trim(),t.innerHTML=P(i),t.setAttribute("aria-hidden","true"),t}function W(){let i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("class","vidply-play-overlay"),i.setAttribute("viewBox","0 0 80 80"),i.setAttribute("width","80"),i.setAttribute("height","80"),i.setAttribute("aria-hidden","true"),i.setAttribute("role","presentation"),i.style.cursor="pointer";let e=document.createElementNS("http://www.w3.org/2000/svg","defs"),t=`vidply-play-shadow-${Math.random().toString(36).substr(2,9)}`,s=document.createElementNS("http://www.w3.org/2000/svg","filter");s.setAttribute("id",t),s.setAttribute("x","-50%"),s.setAttribute("y","-50%"),s.setAttribute("width","200%"),s.setAttribute("height","200%");let o=document.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur");o.setAttribute("in","SourceAlpha"),o.setAttribute("stdDeviation","3");let n=document.createElementNS("http://www.w3.org/2000/svg","feOffset");n.setAttribute("dx","0"),n.setAttribute("dy","2"),n.setAttribute("result","offsetblur");let r=document.createElementNS("http://www.w3.org/2000/svg","feComponentTransfer"),d=document.createElementNS("http://www.w3.org/2000/svg","feFuncA");d.setAttribute("type","linear"),d.setAttribute("slope","0.3"),r.appendChild(d);let a=document.createElementNS("http://www.w3.org/2000/svg","feMerge"),u=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode"),h=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode");h.setAttribute("in","SourceGraphic"),a.appendChild(u),a.appendChild(h),s.appendChild(o),s.appendChild(n),s.appendChild(r),s.appendChild(a),e.appendChild(s),i.appendChild(e);let l=document.createElementNS("http://www.w3.org/2000/svg","circle");l.setAttribute("cx","40"),l.setAttribute("cy","40"),l.setAttribute("r","40"),l.setAttribute("fill","rgba(255, 255, 255, 0.95)"),l.setAttribute("filter",`url(#${t})`),l.setAttribute("class","vidply-play-overlay-bg"),i.appendChild(l);let c=document.createElementNS("http://www.w3.org/2000/svg","polygon");return c.setAttribute("points","32,28 32,52 54,40"),c.setAttribute("fill","#0a406e"),c.setAttribute("class","vidply-play-overlay-icon"),i.appendChild(c),i}function b(i,{delay:e=0,preventScroll:t=!0}={}){i&&requestAnimationFrame(()=>{setTimeout(()=>{i&&document.contains(i)&&i.focus({preventScroll:t})},e)})}function X(i,e,t={}){if(!i)return;let s=i.querySelector(e);s&&b(s,t)}var x=class{constructor(e="vidply"){this.namespace=e,this.storage=this.isStorageAvailable()?localStorage:null}isStorageAvailable(){try{let e="__storage_test__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch{return!1}}getKey(e){return`${this.namespace}_${e}`}set(e,t){if(!this.storage)return!1;try{let s=this.getKey(e);return this.storage.setItem(s,JSON.stringify(t)),!0}catch(s){return console.warn("Failed to save to localStorage:",s),!1}}get(e,t=null){if(!this.storage)return t;try{let s=this.getKey(e),o=this.storage.getItem(s);return o?JSON.parse(o):t}catch(s){return console.warn("Failed to read from localStorage:",s),t}}remove(e){if(!this.storage)return!1;try{let t=this.getKey(e);return this.storage.removeItem(t),!0}catch(t){return console.warn("Failed to remove from localStorage:",t),!1}}clear(){if(!this.storage)return!1;try{return Object.keys(this.storage).forEach(t=>{t.startsWith(this.namespace)&&this.storage.removeItem(t)}),!0}catch(e){return console.warn("Failed to clear localStorage:",e),!1}}saveTranscriptPreferences(e){return this.set("transcript_preferences",e)}getTranscriptPreferences(){return this.get("transcript_preferences",null)}saveCaptionPreferences(e){return this.set("caption_preferences",e)}getCaptionPreferences(){return this.get("caption_preferences",null)}savePlayerPreferences(e){return this.set("player_preferences",e)}getPlayerPreferences(){return this.get("player_preferences",null)}saveSignLanguagePreferences(e){return this.set("sign_language_preferences",e)}getSignLanguagePreferences(){return this.get("sign_language_preferences",null)}};var R=class{constructor(e,t={}){this.element=e,this.options={dragHandle:null,resizeHandles:[],onDragStart:null,onDrag:null,onDragEnd:null,onResizeStart:null,onResize:null,onResizeEnd:null,constrainToViewport:!0,minWidth:150,minHeight:100,maintainAspectRatio:!1,keyboardDragKey:"d",keyboardResizeKey:"r",keyboardStep:5,keyboardStepLarge:10,maxWidth:null,maxHeight:null,pointerResizeIndicatorText:null,onPointerResizeToggle:null,classPrefix:"draggable",storage:null,storageKey:null,...t},this.isDragging=!1,this.isResizing=!1,this.resizeDirection=null,this.dragOffsetX=0,this.dragOffsetY=0,this.positionOffsetX=0,this.positionOffsetY=0,this.initialMouseX=0,this.initialMouseY=0,this.needsPositionConversion=!1,this.resizeStartX=0,this.resizeStartY=0,this.resizeStartWidth=0,this.resizeStartHeight=0,this.resizeStartLeft=0,this.resizeStartTop=0,this.keyboardDragMode=!1,this.keyboardResizeMode=!1,this.pointerResizeMode=!1,this.manuallyPositioned=!1,this.resizeHandlesManaged=new Map,this.resizeIndicatorElement=null,this.handlers={mousedown:this.onMouseDown.bind(this),mousemove:this.onMouseMove.bind(this),mouseup:this.onMouseUp.bind(this),touchstart:this.onTouchStart.bind(this),touchmove:this.onTouchMove.bind(this),touchend:this.onTouchEnd.bind(this),keydown:this.onKeyDown.bind(this),resizeHandleMousedown:this.onResizeHandleMouseDown.bind(this)},this.init()}hasManagedResizeHandles(){return Array.from(this.resizeHandlesManaged.values()).some(Boolean)}storeOriginalHandleDisplay(e){e.dataset.originalDisplay||(e.dataset.originalDisplay=e.style.display||"")}hideResizeHandle(e){e.style.display="none",e.setAttribute("aria-hidden","true")}showResizeHandle(e){let t=e.dataset.originalDisplay!==void 0?e.dataset.originalDisplay:"";e.style.display=t,e.removeAttribute("aria-hidden")}setManagedHandlesVisible(e){!this.options.resizeHandles||this.options.resizeHandles.length===0||this.options.resizeHandles.forEach(t=>{this.resizeHandlesManaged.get(t)&&(e?this.showResizeHandle(t):this.hideResizeHandle(t))})}init(){let e=this.options.dragHandle||this.element;e.addEventListener("mousedown",this.handlers.mousedown),e.addEventListener("touchstart",this.handlers.touchstart),document.addEventListener("mousemove",this.handlers.mousemove),document.addEventListener("mouseup",this.handlers.mouseup),document.addEventListener("touchmove",this.handlers.touchmove,{passive:!1}),document.addEventListener("touchend",this.handlers.touchend),this.element.addEventListener("keydown",this.handlers.keydown),this.options.resizeHandles&&this.options.resizeHandles.length>0&&this.options.resizeHandles.forEach(t=>{t.addEventListener("mousedown",this.handlers.resizeHandleMousedown),t.addEventListener("touchstart",this.handlers.resizeHandleMousedown);let s=t.dataset.vidplyManagedResize==="true";this.resizeHandlesManaged.set(t,s),s&&(this.storeOriginalHandleDisplay(t),this.hideResizeHandle(t))})}onMouseDown(e){e.target.classList.contains(`${this.options.classPrefix}-resize-handle`)||this.options.onDragStart&&!this.options.onDragStart(e)||(this.startDragging(e.clientX,e.clientY),e.preventDefault())}onTouchStart(e){if(e.target.classList.contains(`${this.options.classPrefix}-resize-handle`)||this.options.onDragStart&&!this.options.onDragStart(e))return;let t=e.touches[0];this.startDragging(t.clientX,t.clientY)}onResizeHandleMouseDown(e){e.preventDefault(),e.stopPropagation();let t=e.target;this.resizeDirection=t.getAttribute("data-direction");let s=e.clientX||e.touches?.[0]?.clientX,o=e.clientY||e.touches?.[0]?.clientY;this.startResizing(s,o)}onMouseMove(e){this.isDragging?(this.drag(e.clientX,e.clientY),e.preventDefault()):this.isResizing&&(this.resize(e.clientX,e.clientY),e.preventDefault())}onTouchMove(e){if(this.isDragging||this.isResizing){let t=e.touches[0];this.isDragging?this.drag(t.clientX,t.clientY):this.resize(t.clientX,t.clientY),e.preventDefault()}}onMouseUp(){this.isDragging?this.stopDragging():this.isResizing&&this.stopResizing()}onTouchEnd(){this.isDragging?this.stopDragging():this.isResizing&&this.stopResizing()}onKeyDown(e){if(e.key.toLowerCase()===this.options.keyboardDragKey.toLowerCase()){e.preventDefault(),this.toggleKeyboardDragMode();return}if(e.key.toLowerCase()===this.options.keyboardResizeKey.toLowerCase()){e.preventDefault(),this.hasManagedResizeHandles()?this.togglePointerResizeMode():this.toggleKeyboardResizeMode();return}if(e.key==="Escape"){if(this.pointerResizeMode){e.preventDefault(),this.disablePointerResizeMode();return}if(this.keyboardDragMode||this.keyboardResizeMode){e.preventDefault(),this.disableKeyboardDragMode(),this.disableKeyboardResizeMode();return}}["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(e.key)&&(this.keyboardDragMode?(e.preventDefault(),e.stopPropagation(),this.keyboardDrag(e.key,e.shiftKey)):this.keyboardResizeMode&&(e.preventDefault(),e.stopPropagation(),this.keyboardResize(e.key,e.shiftKey))),e.key==="Home"&&(this.keyboardDragMode||this.keyboardResizeMode)&&(e.preventDefault(),this.resetPosition())}startDragging(e,t){let s=this.element.getBoundingClientRect(),o=window.getComputedStyle(this.element),n=o.right!=="auto"||o.bottom!=="auto"||o.transform!=="none";if(this.positionOffsetX=0,this.positionOffsetY=0,n){let d,a;if(o.position==="absolute"){let c=(this.element.offsetParent||document.body).getBoundingClientRect();d=s.left-c.left,a=s.top-c.top,this.positionOffsetX=c.left,this.positionOffsetY=c.top}else if(o.position==="fixed"){let l=parseFloat(o.left),c=parseFloat(o.top),f=Number.isFinite(l),g=Number.isFinite(c);d=f?l:s.left,a=g?c:s.top,this.positionOffsetX=s.left-d,this.positionOffsetY=s.top-a}else d=s.left,a=s.top,this.positionOffsetX=s.left-d,this.positionOffsetY=s.top-a;let h=this.element.style.cssText.split(";").filter(l=>{let c=l.trim();if(!c)return!1;let f=c.indexOf(":");if(f===-1)return!1;let g=c.substring(0,f).trim(),z=c.substring(f+1).trim();return!(!z||z===""||g==="right"||g==="bottom"||g==="transform"||g==="left"||g==="top"||g==="inset"||g.startsWith("border-image"))}).join("; ");h&&(h+="; "),h+=`left: ${d}px; top: ${a}px; right: auto; bottom: auto; transform: none`,this.element.style.cssText=h}let r=this.element.getBoundingClientRect();this.dragOffsetX=e-r.left,this.dragOffsetY=t-r.top,this.isDragging=!0,this.element.classList.add(`${this.options.classPrefix}-dragging`),document.body.style.cursor="grabbing",document.body.style.userSelect="none"}drag(e,t){if(!this.isDragging)return;let s=e-this.dragOffsetX-this.positionOffsetX,o=t-this.dragOffsetY-this.positionOffsetY;if(this.options.constrainToViewport){let n=this.element.getBoundingClientRect(),r=document.documentElement.clientWidth,d=document.documentElement.clientHeight,a=100,u=-(n.width-a),h=-(n.height-a),l=r-a,c=d-a;s=Math.max(u,Math.min(s,l)),o=Math.max(h,Math.min(o,c))}this.element.style.left=`${s}px`,this.element.style.top=`${o}px`,this.options.onDrag&&this.options.onDrag({x:s,y:o})}stopDragging(){this.isDragging=!1,this.element.classList.remove(`${this.options.classPrefix}-dragging`),document.body.style.cursor="",document.body.style.userSelect="",this.manuallyPositioned=!0,this.options.onDragEnd&&this.options.onDragEnd()}startResizing(e,t){this.isResizing=!0,this.resizeStartX=e,this.resizeStartY=t;let s=this.element.getBoundingClientRect();this.resizeStartWidth=s.width,this.resizeStartHeight=s.height,this.resizeStartLeft=s.left,this.resizeStartTop=s.top,this.element.classList.add(`${this.options.classPrefix}-resizing`),document.body.style.userSelect="none",this.options.onResizeStart&&this.options.onResizeStart()}resize(e,t){if(!this.isResizing)return;let s=e-this.resizeStartX,o=t-this.resizeStartY,n=this.resizeStartWidth,r=this.resizeStartHeight,d=this.resizeStartLeft,a=this.resizeStartTop;if(this.resizeDirection.includes("e")&&(n=Math.max(this.options.minWidth,this.resizeStartWidth+s)),this.resizeDirection.includes("w")){let h=Math.max(this.options.minWidth,this.resizeStartWidth-s);d=this.resizeStartLeft+(this.resizeStartWidth-h),n=h}let u=typeof this.options.maxWidth=="function"?this.options.maxWidth():this.options.maxWidth;if(Number.isFinite(u)){let h=Math.min(n,u);h!==n&&this.resizeDirection.includes("w")&&(d+=n-h),n=h}if(!this.options.maintainAspectRatio){if(this.resizeDirection.includes("s")&&(r=Math.max(this.options.minHeight,this.resizeStartHeight+o)),this.resizeDirection.includes("n")){let l=Math.max(this.options.minHeight,this.resizeStartHeight-o);a=this.resizeStartTop+(this.resizeStartHeight-l),r=l}let h=typeof this.options.maxHeight=="function"?this.options.maxHeight():this.options.maxHeight;if(Number.isFinite(h)){let l=Math.min(r,h);l!==r&&this.resizeDirection.includes("n")&&(a+=r-l),r=l}}this.element.style.width=`${n}px`,this.options.maintainAspectRatio?this.element.style.height="auto":this.element.style.height=`${r}px`,this.resizeDirection.includes("w")&&(this.element.style.left=`${d}px`),this.resizeDirection.includes("n")&&!this.options.maintainAspectRatio&&(this.element.style.top=`${a}px`),this.options.onResize&&this.options.onResize({width:n,height:r,left:d,top:a})}stopResizing(){this.isResizing=!1,this.resizeDirection=null,this.element.classList.remove(`${this.options.classPrefix}-resizing`),document.body.style.userSelect="",this.manuallyPositioned=!0,this.options.onResizeEnd&&this.options.onResizeEnd()}toggleKeyboardDragMode(){this.keyboardDragMode?this.disableKeyboardDragMode():this.enableKeyboardDragMode()}enableKeyboardDragMode(){this.keyboardDragMode=!0,this.keyboardResizeMode=!1,this.element.classList.add(`${this.options.classPrefix}-keyboard-drag`),this.element.classList.remove(`${this.options.classPrefix}-keyboard-resize`),this.focusElement()}disableKeyboardDragMode(){this.keyboardDragMode=!1,this.element.classList.remove(`${this.options.classPrefix}-keyboard-drag`)}toggleKeyboardResizeMode(){this.keyboardResizeMode?this.disableKeyboardResizeMode():this.enableKeyboardResizeMode()}enableKeyboardResizeMode(){this.keyboardResizeMode=!0,this.keyboardDragMode=!1,this.element.classList.add(`${this.options.classPrefix}-keyboard-resize`),this.element.classList.remove(`${this.options.classPrefix}-keyboard-drag`),this.focusElement()}disableKeyboardResizeMode(){this.keyboardResizeMode=!1,this.element.classList.remove(`${this.options.classPrefix}-keyboard-resize`)}enablePointerResizeMode({focus:e=!0}={}){if(!this.hasManagedResizeHandles()){this.enableKeyboardResizeMode();return}this.pointerResizeMode||(this.pointerResizeMode=!0,this.setManagedHandlesVisible(!0),this.element.classList.add(`${this.options.classPrefix}-resizable`),this.enableKeyboardResizeMode(),e&&this.focusElement(),typeof this.options.onPointerResizeToggle=="function"&&this.options.onPointerResizeToggle(!0))}disablePointerResizeMode({focus:e=!1}={}){this.pointerResizeMode&&(this.pointerResizeMode=!1,this.setManagedHandlesVisible(!1),this.element.classList.remove(`${this.options.classPrefix}-resizable`),this.disableKeyboardResizeMode(),e&&this.focusElement(),typeof this.options.onPointerResizeToggle=="function"&&this.options.onPointerResizeToggle(!1))}togglePointerResizeMode(){return this.pointerResizeMode?this.disablePointerResizeMode():this.enablePointerResizeMode(),this.pointerResizeMode}focusElement(){if(typeof this.element.focus=="function")try{this.element.focus({preventScroll:!0})}catch{this.element.focus()}}keyboardDrag(e,t){let s=t?this.options.keyboardStepLarge:this.options.keyboardStep,o=parseFloat(this.element.style.left)||0,n=parseFloat(this.element.style.top)||0;if(window.getComputedStyle(this.element).transform!=="none"){let u=this.element.getBoundingClientRect();o=u.left,n=u.top,this.element.style.transform="none",this.element.style.left=`${o}px`,this.element.style.top=`${n}px`}let d=o,a=n;switch(e){case"ArrowLeft":d-=s;break;case"ArrowRight":d+=s;break;case"ArrowUp":a-=s;break;case"ArrowDown":a+=s;break}this.element.style.left=`${d}px`,this.element.style.top=`${a}px`,this.options.onDrag&&this.options.onDrag({x:d,y:a})}keyboardResize(e,t){let s=t?this.options.keyboardStepLarge:this.options.keyboardStep,o=this.element.getBoundingClientRect(),n=o.width,r=o.height;switch(e){case"ArrowLeft":n-=s;break;case"ArrowRight":n+=s;break;case"ArrowUp":this.options.maintainAspectRatio?n+=s:r-=s;break;case"ArrowDown":this.options.maintainAspectRatio?n-=s:r+=s;break}n=Math.max(this.options.minWidth,n),r=Math.max(this.options.minHeight,r),this.element.style.width=`${n}px`,this.options.maintainAspectRatio?this.element.style.height="auto":this.element.style.height=`${r}px`,this.options.onResize&&this.options.onResize({width:n,height:r})}resetPosition(){this.element.style.left="50%",this.element.style.top="50%",this.element.style.transform="translate(-50%, -50%)",this.element.style.right="",this.element.style.bottom="",this.manuallyPositioned=!1,this.options.onDrag&&this.options.onDrag({centered:!0})}destroy(){let e=this.options.dragHandle||this.element;this.disablePointerResizeMode(),e.removeEventListener("mousedown",this.handlers.mousedown),e.removeEventListener("touchstart",this.handlers.touchstart),document.removeEventListener("mousemove",this.handlers.mousemove),document.removeEventListener("mouseup",this.handlers.mouseup),document.removeEventListener("touchmove",this.handlers.touchmove),document.removeEventListener("touchend",this.handlers.touchend),this.element.removeEventListener("keydown",this.handlers.keydown),this.options.resizeHandles&&this.options.resizeHandles.length>0&&this.options.resizeHandles.forEach(t=>{t.removeEventListener("mousedown",this.handlers.resizeHandleMousedown),t.removeEventListener("touchstart",this.handlers.resizeHandleMousedown)}),this.element.classList.remove(`${this.options.classPrefix}-dragging`,`${this.options.classPrefix}-resizing`,`${this.options.classPrefix}-keyboard-drag`,`${this.options.classPrefix}-keyboard-resize`)}};function Z({classPrefix:i,itemClass:e,icon:t,label:s,ariaLabel:o,onClick:n,hasTextClass:r=!1}){let d=typeof s=="string"&&(s.startsWith("transcript.")||s.startsWith("player.")||s.startsWith("settings.")),a=o||d&&p.t(s)||s,u=m.createElement("button",{className:e,attributes:{type:"button","aria-label":a,tabindex:"-1"}});t&&u.appendChild(D(t));let l=typeof s=="string"&&(s.startsWith("transcript.")||s.startsWith("player.")||s.startsWith("settings."))&&p.t(s)||s,c=m.createElement("span",{textContent:l,className:r?`${i}-settings-text`:void 0,attributes:{"aria-hidden":"true"}});return u.appendChild(c),n&&u.addEventListener("click",n),u}function G(i,e,t,s){if(!i)return;let o=Array.from(i.querySelectorAll(t));if(o.length===0)return;let n=r=>{let d=o.indexOf(document.activeElement);switch(r.key){case"ArrowDown":r.preventDefault(),r.stopPropagation();let a=(d+1)%o.length;o.forEach((l,c)=>{l.setAttribute("tabindex",c===a?"0":"-1")}),o[a].focus({preventScroll:!1}),o[a].scrollIntoView({behavior:"smooth",block:"nearest"});break;case"ArrowUp":r.preventDefault(),r.stopPropagation();let u=(d-1+o.length)%o.length;o.forEach((l,c)=>{l.setAttribute("tabindex",c===u?"0":"-1")}),o[u].focus({preventScroll:!1}),o[u].scrollIntoView({behavior:"smooth",block:"nearest"});break;case"Home":r.preventDefault(),r.stopPropagation(),o.forEach((l,c)=>{l.setAttribute("tabindex",c===0?"0":"-1")}),o[0].focus({preventScroll:!1}),o[0].scrollIntoView({behavior:"smooth",block:"nearest"});break;case"End":r.preventDefault(),r.stopPropagation();let h=o.length-1;o.forEach((l,c)=>{l.setAttribute("tabindex",c===h?"0":"-1")}),o[h].focus({preventScroll:!1}),o[h].scrollIntoView({behavior:"smooth",block:"nearest"});break;case"Enter":case" ":r.preventDefault(),r.stopPropagation(),document.activeElement&&o.includes(document.activeElement)&&(document.activeElement.click(),s&&setTimeout(()=>{e&&document.contains(e)&&e.focus()},0));break;case"Escape":r.preventDefault(),r.stopPropagation(),s&&s();break}};return i.addEventListener("keydown",n,!0),n}function ee(i,e,t=0){i&&setTimeout(()=>{let s=Array.from(i.querySelectorAll(e));s.length>0&&(s.forEach((o,n)=>{o.setAttribute("tabindex",n===0?"0":"-1")}),b(s[0],{delay:0}),s[0].scrollIntoView({behavior:"smooth",block:"nearest"}))},t)}function oe({classPrefix:i,labelClass:e,selectClass:t,labelText:s,selectId:o,hidden:n=!1,onChange:r=null,options:d=[]}){let u=typeof s=="string"&&(s.startsWith("transcript.")||s.startsWith("player.")||s.startsWith("settings.")||s.startsWith("captions."))&&p.t(s)||s,h=m.createElement("label",{className:e,textContent:u,attributes:{for:o,style:n?"display: none;":void 0}}),l=m.createElement("select",{className:t,attributes:{id:o,style:n?"display: none;":void 0}});return d.forEach(c=>{let f=m.createElement("option",{textContent:c.text,attributes:{value:c.value,selected:c.selected?"selected":void 0}});l.appendChild(f)}),r&&l.addEventListener("change",r),{label:h,select:l}}function ne(i){i&&["mousedown","click"].forEach(e=>{i.addEventListener(e,t=>{t.stopPropagation()})})}export{m as a,p as b,I as c,D as d,W as e,b as f,X as g,x as h,R as i,Z as j,G as k,ee as l,oe as m,ne as n};
|