{"version":3,"names":["prestoPlaylistCss","PrestoPlaylistStyle0","PrestoPlaylist","rewatch","this","handlePlay","next","handleNext","handleCurrentPlay","value","previousValue","addOverlay","currentPlyr","elements","container","getRootNode","host","style","currentPlaylistItem","config","styles","undefined","provider","muted","_a","embed","unMute","play","overlay","document","createElement","nextItemTitle","getNextItemTitle","isLastItem","nextItemString","listTextSingular","transitionDuration","_b","closest","append","componentWillLoad","items","handleItemClick","item","show","el","height","offsetHeight","width","offsetWidth","getNextItem","handlePause","pause","nextItem","i","length","id","_c","_d","lastIndex","title","render","listTextS","listTextP","listTextPlural","h","src","Object","assign","slot","video_id","_e","_f","class","_g","playerClass","key","_h","_j","onPlayerReady","e","detail","onPlayedMedia","playing","onPausedMedia","onEndedMedia","name","heading","map","onClick","active","onTriggerPause","onTriggerPlay","duration"],"sources":["src/components/core/features/presto-playlist/presto-playlist.scss?tag=presto-playlist&encapsulation=shadow","src/components/core/features/presto-playlist/presto-playlist.tsx"],"sourcesContent":[":host {\n display: block;\n overflow: hidden;\n}\npresto-player {\n opacity: 0;\n visibility: hidden;\n transition: 0.35s opacity, 0.35s visibility;\n\n &.ready {\n opacity: 1;\n visibility: visible;\n }\n}\n","import { Component, h, Prop, State, Watch, Listen, Element } from '@stencil/core';\n\nimport { PlaylistItem } from '../../../../interfaces';\n\n@Component({\n tag: 'presto-playlist',\n styleUrl: 'presto-playlist.scss',\n shadow: true,\n})\nexport class PrestoPlaylist {\n @Element() el: HTMLElement;\n\n /** Overlay component */\n private overlay: any;\n\n /** Array of videos from the Playlist */\n @Prop() items: Array;\n\n /** Title for the Playlist */\n @Prop() heading: string;\n\n /** Count prefix string for the Playlist - Singular */\n @Prop() listTextSingular: string;\n\n /** Count prefix string for the Playlist - Plural */\n @Prop() listTextPlural: string;\n\n /** Transition duration for next video. */\n @Prop() transitionDuration: number = 5;\n\n /** Stores current video that is shown in the preview. */\n @State() currentPlaylistItem: PlaylistItem;\n\n /** Stores current video Plyr object that is shown in the preview. */\n @State() currentPlyr: any;\n\n /** Is a video playing. */\n @State() playing: boolean = false;\n\n /**\n * Listening to the Rewatch Video button click event.\n */\n @Listen('rewatch')\n rewatch() {\n this.handlePlay();\n }\n\n /**\n * Listening to the Next Video button click event.\n */\n @Listen('next')\n next() {\n this.handleNext();\n }\n\n /**\n * Plays the video, adds overlay and Presto Video styles as soon as a new object is assigned.\n * @param value Current value\n * @param previousValue Previous value\n */\n @Watch('currentPlyr')\n handleCurrentPlay(value, previousValue) {\n if (!value) return;\n\n // add the overlay.\n this.addOverlay();\n\n // add styles from the current video config.\n this.currentPlyr.elements.container.getRootNode().host.style = this.currentPlaylistItem.config.styles;\n\n // if we have a previous value, then we need to autoplay the video since we are switching.\n if (previousValue !== undefined) {\n // Restore audio (YouTube starts playing on seek if the video hasn't been played yet)\n if (this.currentPlyr.provider === 'youtube' && !this.currentPlyr.muted && this.currentPlyr?.embed) {\n this.currentPlyr.embed.unMute();\n }\n\n this.currentPlyr.play();\n }\n }\n\n /**\n * Adds overlay to the player which will regulate the Next video button.\n */\n addOverlay() {\n // create overlay\n this.overlay = document.createElement('presto-playlist-overlay');\n // assign properties.\n this.overlay.nextItemTitle = this.getNextItemTitle();\n this.overlay.isLastItem = this.isLastItem();\n this.overlay.nextItemString = this?.listTextSingular || 'Video';\n this.overlay.transitionDuration = this.transitionDuration;\n // append\n this.currentPlyr.elements?.container?.closest('.presto-player__wrapper').append(this.overlay);\n }\n\n /**\n * Lifecycle: Component will load.\n */\n componentWillLoad() {\n // Select the first video as a current video to be shown in the playlist.\n this.currentPlaylistItem = this?.items?.[0] || null;\n }\n\n /**\n * Handles the click on the playlist item.\n * @param item PlaylistItem\n */\n handleItemClick(item: PlaylistItem) {\n if (this.overlay) {\n this.overlay.show = false;\n }\n this.el.style.height = this.el.offsetHeight + 'px';\n this.el.style.width = this.el.offsetWidth + 'px';\n this.currentPlaylistItem = item;\n }\n\n /**\n * Assign the next item in the playlist as a current item.\n */\n handleNext() {\n this.overlay.show = false;\n this.currentPlaylistItem = this.getNextItem() || this.currentPlaylistItem;\n }\n\n /**\n * Play the current video.\n */\n handlePlay() {\n if (this.overlay) {\n this.overlay.show = false;\n }\n this.currentPlyr.play();\n }\n\n /**\n * Pause the current video.\n */\n handlePause() {\n this.overlay.show = false;\n this.currentPlyr.pause();\n }\n\n /**\n * Get the next item in the playlist.\n * @returns PlaylistItem Next item in the playlist.\n */\n getNextItem() {\n if (this.isLastItem()) return this.items[0];\n\n let nextItem: PlaylistItem;\n for (let i = 0; i < this.items?.length; i++) {\n if (this.items[i]?.id === this.currentPlaylistItem?.id && this.items?.length !== i + 1) {\n nextItem = this.items[i + 1];\n break;\n }\n }\n return nextItem;\n }\n\n /**\n * Checks if the current item is the last item in the playlist.\n * @returns boolean True if the current item is the last item in the playlist.\n */\n isLastItem() {\n const lastIndex = this.items?.length - 1;\n return this.items[lastIndex]?.id === this.currentPlaylistItem?.id;\n }\n\n /**\n * Get the title of the next item in the playlist.\n * @returns string Title of the next item in the playlist.\n */\n getNextItemTitle() {\n const nextItem = this.getNextItem();\n if (undefined !== nextItem) {\n return nextItem?.title || nextItem?.config?.title;\n }\n return '';\n }\n\n /**\n * Rendering the component.\n * @returns Web Component\n */\n render() {\n if (!this.items?.length) return '';\n\n const listTextS = this.listTextSingular ? this.listTextSingular : 'Video';\n const listTextP = this.listTextPlural ? this.listTextPlural : 'Videos';\n\n return (\n \n {!!this.currentPlaylistItem.config?.src ? (\n {\n this.currentPlyr = e.detail;\n this.el.style.height = null;\n this.el.style.width = null;\n }}\n onPlayedMedia={() => (this.playing = true)}\n onPausedMedia={() => (this.playing = false)}\n onEndedMedia={() => (this.overlay.show = true)}\n />\n ) : (\n \n )}\n\n
{this.heading || 'Playlist'}
\n\n
\n {this.items.length} {this.items.length > 1 ? listTextP : listTextS}\n
\n\n {this.items.map(item => {\n return (\n this.handleItemClick(item)}\n active={this.currentPlaylistItem?.id === item?.id}\n playing={this.currentPlaylistItem?.id === item?.id && this.playing}\n class={this.currentPlaylistItem?.id === item?.id ? 'active' : ''}\n key={item?.id}\n onTriggerPause={() => this.handlePause()}\n onTriggerPlay={() => this.handlePlay()}\n >\n \n {item?.title || item?.config?.title}\n \n \n {item?.duration}\n \n \n );\n })}\n
\n );\n }\n}\n"],"mappings":"kDAAA,MAAMA,EAAoB,6KAC1B,MAAAC,EAAeD,E,MCQFE,EAAc,M,2JAmBY,E,2EAST,K,CAM5B,OAAAC,GACEC,KAAKC,Y,CAOP,IAAAC,GACEF,KAAKG,Y,CASP,iBAAAC,CAAkBC,EAAOC,G,MACvB,IAAKD,EAAO,OAGZL,KAAKO,aAGLP,KAAKQ,YAAYC,SAASC,UAAUC,cAAcC,KAAKC,MAAQb,KAAKc,oBAAoBC,OAAOC,OAG/F,GAAIV,IAAkBW,UAAW,CAE/B,GAAIjB,KAAKQ,YAAYU,WAAa,YAAclB,KAAKQ,YAAYW,SAASC,EAAApB,KAAKQ,eAAW,MAAAY,SAAA,SAAAA,EAAEC,OAAO,CACjGrB,KAAKQ,YAAYa,MAAMC,Q,CAGzBtB,KAAKQ,YAAYe,M,EAOrB,UAAAhB,G,QAEEP,KAAKwB,QAAUC,SAASC,cAAc,2BAEtC1B,KAAKwB,QAAQG,cAAgB3B,KAAK4B,mBAClC5B,KAAKwB,QAAQK,WAAa7B,KAAK6B,aAC/B7B,KAAKwB,QAAQM,gBAAiB9B,OAAI,MAAJA,YAAI,SAAJA,KAAM+B,mBAAoB,QACxD/B,KAAKwB,QAAQQ,mBAAqBhC,KAAKgC,oBAEvCC,GAAAb,EAAApB,KAAKQ,YAAYC,YAAQ,MAAAW,SAAA,SAAAA,EAAEV,aAAS,MAAAuB,SAAA,SAAAA,EAAEC,QAAQ,2BAA2BC,OAAOnC,KAAKwB,Q,CAMvF,iBAAAY,G,MAEEpC,KAAKc,sBAAsBM,EAAApB,OAAI,MAAJA,YAAI,SAAJA,KAAMqC,SAAK,MAAAjB,SAAA,SAAAA,EAAG,KAAM,I,CAOjD,eAAAkB,CAAgBC,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