import{r as t,h as i,H as e}from"./p-76ab1744.js";const s={HTML5Video:"html",Vimeo:"vimeo"};Object.values(s);const o=class{constructor(i){t(this,i),this.dataTrackingId="telia-video-player",this.setVideoRef=t=>{this.videoElement=t}}async play(){var t;"function"==typeof(null===(t=this.videoElement)||void 0===t?void 0:t.play)&&this.videoElement.play()}async pause(){var t;"function"==typeof(null===(t=this.videoElement)||void 0===t?void 0:t.pause)&&this.videoElement.pause()}getHTML5VideoSubtitles(){if(Array.isArray(this.subtitles))return this.subtitles;try{return this.subtitles&&JSON.parse(this.subtitles)}catch(t){return void console.error("Telia Video Player: please provide a valid subtitles JSON string")}}getActiveVimeoSourceSettings(){var t;let i=this.src;if(null===(t=this.src)||void 0===t?void 0:t.includes("https://player.vimeo.com/video/")){const t=new URL(this.src),e=new URLSearchParams(t.searchParams);let s=new URLSearchParams;e.get("h")&&s.append("h",e.get("h")),this.applyVimeoParamSettings(s,"title",!1),this.applyVimeoParamSettings(s,"byline",!1),this.applyVimeoParamSettings(s,"portrait",!1),this.applyVimeoParamSettings(s,"background",!this.controls),this.applyVimeoParamSettings(s,"autoplay",this.autoplay),this.applyVimeoParamSettings(s,"loop",this.loop),this.applyVimeoParamSettings(s,"muted",this.muted),i=`${t.origin}${t.pathname}?${s.toString()}`}else i=void 0;return i}applyVimeoParamSettings(t,i,e){t.append(i,e?"1":"0")}render(){var t;const o="telia-video-player";return i(e,{class:o,"data-testid":this.dataTestid},i("telia-vst",{dataTrackingId:this.dataTrackingId}),this.type===s.HTML5Video&&i("video",{autoplay:!!this.autoplay||null,controls:this.controls,muted:this.muted,loop:this.loop,poster:this.poster,ref:this.setVideoRef,preload:this.preload,playsinline:!0,controlsList:"nodownload nofullscreen noremoteplayback noplaybackrate",disablepictureinpicture:!0},i("source",{src:this.src,type:this.srcType}),null===(t=this.getHTML5VideoSubtitles())||void 0===t?void 0:t.map((t=>i("track",{label:t.label,kind:"subtitles",srclang:t.srcLanguage,src:t.src,default:t.default})))),this.type===s.Vimeo&&i("div",{class:o+"__container"},this.getActiveVimeoSourceSettings()?i("iframe",{title:this.iframeTitle,src:this.getActiveVimeoSourceSettings(),frameborder:"0",allow:"autoplay; fullscreen;"}):this.poster&&i("telia-image",{src:this.poster})))}};o.style=":host{display:block;height:inherit;width:inherit}:host video{height:inherit;object-fit:cover;object-position:center;width:inherit}:host .telia-video-player__container{display:block;height:inherit;width:inherit}:host .telia-video-player__container iframe{height:100%;width:100%}";export{o as telia_video_player}