1import{b as g,J as $,$ as o,d as m,w as a,e as p,t as d,m as u}from"./chunk-vendor-lit.NvY0u02.js";import{bA as v,bB as f,S as k,C as T}from"./storefrontApp.CsApItsi.min.js";import{S as b}from"./chunk-storefront_base_lit_element.lX23Jvc.js";import{t as i}from"./chunk-translations_directive.DWSzkd6.js";import{T as L}from"./chunk-transcript_service.DEDoHy_.js";import"./chunk-vendor-di.Bh23gdA.js";import"./chunk-vendor-lodash.CWHFt7Z.js";import"./chunk-storefront_settings_constants.DIF02Gz.js";import"./chunk-vendor-rxjs.Dp7kflo.js";import"./chunk-vendor-phoenix.cdKS79L.js";var D=Object.defineProperty,r=(h,t,e,l)=>{for(var n=void 0,c=h.length-1,_;c>=0;c--)(_=h[c])&&(n=_(t,e,n)||n);return n&&D(t,e,n),n};class s extends b{constructor(){super(),this.src="",this.instanceId="",this.settings="{}",this._settings={},this._isPlayed=!1,this._isLoaded=!1,this._isMuted=!1,this._intersectionObserver=null,this._isDescriptionEnabled=!1,this._currentDescriptionText="",this._descriptionTrack=null,this._transcriptContent=null,this._sourceSrc=null,this._modal=g(),this._handleLoadError=()=>{console.error("Video failed to load with the provided source"),this._isLoaded=!1},this._resetState=()=>{this._setPlayedState(!1),this._$video&&(this._$video.pause(),this._$video.currentTime=0)},this._handleVideoReady=()=>{this._findDescriptionTrack(),this._isLoaded=!0,this._$video.removeEventListener("loadedmetadata",this._handleVideoReady)},this._handleCueChange=()=>{if(!this._descriptionTrack||!this._isDescriptionEnabled)return;const t=this._descriptionTrack.activeCues;this._currentDescriptionText=t?.[0]?.text||""},this._toggleDescription=()=>{this._isDescriptionEnabled=!this._isDescriptionEnabled,this._isDescriptionEnabled?this._handleCueChange():this._currentDescriptionText=""},this._transcriptService=new L}static{this.moduleName=v.component}_setupIntersectionObserver(){if(typeof IntersectionObserver>"u"){this._sourceSrc=this.src;return}!this.src||this._intersectionObserver||(this._intersectionObserver=new IntersectionObserver(t=>{t.forEach(e=>{e.isIntersecting&&(this._sourceSrc=this.src,this._disconnectIntersectionObserver())})},{rootMargin:"50px 0px",threshold:0}),this._intersectionObserver.observe(this))}_disconnectIntersectionObserver(){this._intersectionObserver&&(this._intersectionObserver.disconnect(),this._intersectionObserver=null)}play(){this._setPlayedState(!0),this._$video.play()}pause(){this._setPlayedState(!1),this._$video.pause()}_setPlayedState(t){this._isPlayed=t}_attachMediaEventListeners(){this._$video.addEventListener("play",()=>this._setPlayedState(!0)),this._$video.addEventListener("pause",()=>this._setPlayedState(!1)),this._$video.addEventListener("ended",()=>this._setPlayedState(!1)),this._$video.addEventListener("error",this._handleLoadError),this._$video.addEventListener("volumechange",()=>{this._isMuted=this._$video.muted})}async _attemptAutoPlayVideo(){if(this._settings.autoplay){this._$video.autoplay=!0,this._$video.muted=!0;try{this._$video.load(),await this._$video.play(),this._setPlayedState(!0),this._isLoaded=!0}catch{this._setPlayedState(!1)}}}_findDescriptionTrack(){const t=this._$video.textTracks;if(!t)return;const e=Array.from(t).find(n=>n.kind==="descriptions");if(e){this._setupTrack(e);return}const l=()=>{const n=Array.from(t).find(c=>c.kind==="descriptions");n&&(this._setupTrack(n),t.removeEventListener("addtrack",l))};t.addEventListener("addtrack",l),setTimeout(()=>{t.removeEventListener("addtrack",l)},f)}_setupTrack(t){t.mode="hidden",this._descriptionTrack=t,t.addEventListener("cuechange",this._handleCueChange),this.requestUpdate()}async _fetchTranscriptFile(){const t=this._settings.transcriptTrackLink;!t||this._transcriptContent!==null||(this._transcriptContent=await this._transcriptService.fetchTranscript(t))}async connectedCallback(){super.connectedCallback(),this._setupIntersectionObserver(),await this.updateComplete,this._isMuted=!!(this._settings.muted||this._settings.autoplay),this._$video&&(this._$video.muted=this._isMuted,this._attemptAutoPlayVideo(),this._isLoaded=!1,this._$video.addEventListener("loadedmetadata",this._handleVideoReady),this._attachMediaEventListeners()),this._settings.posterSrc!==""&&!this._settings.autoplay&&this._resetState()}disconnectedCallback(){super.disconnectedCallback(),this._disconnectIntersectionObserver()}willUpdate(t){if(t.has("settings"))try{this._settings=$.fromJson(this.settings)||{}}catch(e){console.error("Failed to parse video settings JSON:",this.settings,e),this._settings={}}}_renderAudioDescriptionDisplay(){return o` 2 <div class="video__audio-description-display">
3 <span class="video__audio-description-text"> ${this._currentDescriptionText} </span> 4 </div> 5 `}_renderPlayButton(){return o` <button 6 class="video__play-button" 7 aria-label=${i("Play video")} 8 @click=${this.play} 9 > 10 <h-icon 11 icon-name="icon-play" 12 size="xl" 13 filled 14 ></h-icon> 15 </button>`}_renderAudioDescriptionControl(){const t=this._isDescriptionEnabled?i("Turn off audio description"):i("Turn on audio description");return o` 16 <button 17 class="video__controls video__controls-ad ${this._isDescriptionEnabled?"active":"inactive"}" 18 aria-pressed=${this._isDescriptionEnabled?"true":"false"} 19 aria-label=${t} 20 @click=${this._toggleDescription} 21 > 22 <h-icon icon-name="icon-audio-description"></h-icon> 23 <span class="sr-only">${t}</span> 24 </button> 25 `}_renderPlayPauseControl(){return o` <button 26 class="video__controls video__controls-${this._isPlayed?"pause":"play"}" 27 @click=${this._isPlayed?this.pause:this.play} 28 aria-label=${this._isPlayed?i("Stop Video"):i("Play Video")} 29 > 30 <h-icon 31 icon-name="icon-${this._isPlayed?"pause":"play"}" 32 size="m" 33 filled 34 ></h-icon> 35 </button>`}_renderTranscriptContent(t){return t===null?o`<p class="video__transcript-content">${i("Loading transcript...")}</p>`:t==="ERROR_COULD_NOT_LOAD_TRANSCRIPT"?o`<p class="video__transcript-content"> 36 ${i("An error occurred while displaying the transcript. We apologize for the inconvenience.")} 37 </p>`:o`<pre class="video__transcript-content">${t}</pre>`}_renderTranscriptModal(){const t=this._renderTranscriptContent(this._transcriptContent);return o` 38 <h-modal-opener 39 class="video__transcript-modal-opener" 40 name="video__container__transcript-modal-${this.instanceId}" 41 @click=${this._fetchTranscriptFile} 42 > 43 ${i("This video includes a transcript.")} 44 </h-modal-opener> 45 46 <h-modal 47 id="video__container__transcript-modal-${this.instanceId}" 48 ${m(this._modal)} 49 hidden 50 > 51 <h-modal-header> 52 <h2 class="section-title section-title_s">${i("Transcript")}</h2> 53 <h-modal-close 54 class="btn btn_icon" 55 aria-label="${i("Close window")+"-"+i("Transcript")}" 56 > 57 <h-icon icon-name="icon-x"></h-icon> 58 </h-modal-close> 59 </h-modal-header> 60 61 <h-modal-body> ${t} </h-modal-body> 62 63 <h-modal-footer> 64 <h-modal-close class="modal__btn btn btn_primary"> ${i("Return to the page")} </h-modal-close> 65 </h-modal-footer> 66 </h-modal> 67 `}_renderCaptionTrackLink(){return o`<track 68 ${this._settings.captionTrackLink&&!this._settings.audioDescriptionTrackLink?"default":a} 69 kind="captions" 70 src=${this._settings.captionTrackLink} 71 srclang=${this._settings.captionLang||"en"} 72 />`}_renderAudioDescriptionTrackLink(){return o`<track 73 kind="descriptions" 74 src=${this._settings.audioDescriptionTrackLink} 75 srclang=${this._settings.audioDescriptionLang||"en"} 76 label=${i("Audio description")} 77 ${!this._settings.captionTrackLink&&this._settings.audioDescriptionTrackLink?"default":a} 78 />`}render(){if(!this.src)return o`<p>${i("No video source provided")}.</p>`;const t=this.src.split(".").pop()||"",e=this._isLoaded,l=e&&this._settings.captionTrackLink,n=e&&this._settings.audioDescriptionTrackLink&&this._settings.controls,c=e&&this._settings.audioDescriptionTrackLink&&this._settings.controls,_=e&&this._settings.posterSrc!==""&&!this._isPlayed&&!this._settings.autoplay,y=e&&this._settings.posterSrc===""&&!this._settings.controls;return o` 79 <div class="video"> 80 <figure class="video__container"> 81 <video 82 preload="metadata" 83 width="100%" 84 height="100%" 85 aria-label=${this._settings.videoDescription||"video"} 86 playsinline 87 poster=${this._settings.posterSrc||""} 88 ?autoplay=${this._settings.autoplay&&this._settings.posterSrc!==""} 89 ?muted=${this._isMuted} 90 ?controls=${this._settings.controls&&(this._settings.posterSrc===""||this._isPlayed||this._settings.autoplay)} 91 ?loop=${this._settings.loop} 92 > 93 ${this._sourceSrc?o`<source 94 src="${this._sourceSrc}" 95 type="video/${t}" 96 />`:a} 97 ${l?this._renderCaptionTrackLink():a} 98 ${n?this._renderAudioDescriptionTrackLink():a} 99 <p>${i("Your browser does not support the video tag")}.</p> 100 </video> 101 ${_?this._renderPlayButton():a}
102 <div class="video__custom-controls"> 103 ${c?this._renderAudioDescriptionControl():a} 104 ${y?this._renderPlayPauseControl():a} 105 </div> 106 </figure> 107 ${this._settings.audioDescriptionTrackLink?this._renderAudioDescriptionDisplay():a} 108 ${this._settings.transcriptTrackLink?this._renderTranscriptModal():a} 109 </div> 110 `}}r([p({type:String,attribute:"src"})],s.prototype,"src");r([p({type:String,attribute:"instance-id"})],s.prototype,"instanceId");r([p({type:String,attribute:"settings"})],s.prototype,"settings");r([d()],s.prototype,"_settings");r([d()],s.prototype,"_isPlayed");r([d()],s.prototype,"_isLoaded");r([d()],s.prototype,"_isMuted");r([d()],s.prototype,"_isDescriptionEnabled");r([d()],s.prototype,"_currentDescriptionText");r([d()],s.prototype,"_descriptionTrack");r([d()],s.prototype,"_transcriptContent");r([d()],s.prototype,"_sourceSrc");r([u("video")],s.prototype,"_$video");r([u(".video__live-description")],s.prototype,"_$liveDescriptionRegion");class w extends k{static{this.featureName=v.feature}init(){return{cores:[{type:T,instance:[s]}]}}}export{w as VideoInitializer};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.