OwlCyberSecurity - MANAGER
Edit File: presto-dynamic-overlays2.js
import{proxyCustomElement,HTMLElement,createEvent,h}from"@stencil/core/internal/client";import{p as parseColor,a as timeToSeconds}from"./util.js";import{d as defineCustomElement$1}from"./presto-dynamic-overlay-ui2.js";const prestoDynamicOverlaysCss=".top-left,.top-right{position:absolute;display:block;padding:20px;max-width:45%;z-index:20;display:flex;flex-direction:column;flex-wrap:wrap}.top-left{top:0;left:0}.top-right{top:0;right:0;align-items:flex-end}presto-dynamic-overlay-ui{overflow:hidden;height:0;opacity:0;transition:height 0ms 400ms, opacity 400ms 0ms}presto-dynamic-overlay-ui.visible{margin-bottom:10px;height:auto;opacity:1;transition:height 0ms 0ms, opacity 500ms 0ms}",PrestoDynamicOverlaysStyle0=prestoDynamicOverlaysCss,PrestoDynamicOverlays=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.reloadComponent=createEvent(this,"reloadComponent",7),this.watermarkRef={left:null,right:null},this.refs={},this.overlays=void 0,this.player=void 0,this.preset=void 0,this.enabled=void 0,this.currentTime=void 0,this.destroy=!1}componentDidLoad(){this.player&&this.player.on("timeupdate",(t=>{this.currentTime=t.detail.plyr.currentTime,this.checkValidity()}))}checkValidity(){var t,e,o,i,r,s,l,a,n,d;this.player.playing&&((null===(t=null==this?void 0:this.overlays)||void 0===t?void 0:t.length)||(null===(o=null===(e=this.preset)||void 0===e?void 0:e.watermark)||void 0===o?void 0:o.enabled))&&((null===(i=this.container)||void 0===i?void 0:i.offsetParent)&&(null===(r=this.topLeft)||void 0===r?void 0:r.offsetParent)&&(null===(s=this.topRight)||void 0===s?void 0:s.offsetParent)||this.reloadComponent.emit(),Object.keys(this.refs||{}).forEach((t=>{const{overlay:e,component:o}=this.refs[t];this.checkComponent(o,e.text,(()=>this.reloadComponent.emit()))})),this.shouldShowWatermark("top-left")&&this.watermarkRef.left&&this.checkComponent(this.watermarkRef.left,null===(a=null===(l=this.preset)||void 0===l?void 0:l.watermark)||void 0===a?void 0:a.text,(()=>this.reloadComponent.emit())),this.shouldShowWatermark("top-right")&&this.watermarkRef.right&&this.checkComponent(this.watermarkRef.right,null===(d=null===(n=this.preset)||void 0===n?void 0:n.watermark)||void 0===d?void 0:d.text,(()=>this.reloadComponent.emit())))}checkComponent(t,e,o){if(!(null==t?void 0:t.offsetParent))return o();if(!t.shadowRoot.querySelector("slot"))return o();if(this.player&&this.player.playing){const i=t.shadowRoot.querySelector("slot").assignedNodes()[0];if(i){if(i.parentElement.innerHTML!=e)return o();const t=getComputedStyle(i.parentElement.shadowRoot.querySelector(".overlay-text"));if(parseInt(t.fontSize,10)<10)return o();const r=parseColor(t.color);if("1"!==(null==r?void 0:r[3]))return o()}}}shouldShowOverlay(t){if(void 0!==this.currentTime)return!(this.currentTime<timeToSeconds(null==t?void 0:t.startTime)||this.currentTime>timeToSeconds(null==t?void 0:t.endTime))}renderOverlay(t){var e,o;return h("presto-dynamic-overlay-ui",{class:{visible:this.shouldShowOverlay(t)},ref:e=>this.refs[t.id]={overlay:t,component:e},key:t.id,position:t.position,href:null===(e=null==t?void 0:t.link)||void 0===e?void 0:e.url,target:(null===(o=null==t?void 0:t.link)||void 0===o?void 0:o.opensInNewTab)?"_blank":"_self",innerHTML:this.shouldShowOverlay(t)?t.text:"",style:{"--presto-dynamic-overlay-color":(null==t?void 0:t.color)||"#fff","--presto-dynamic-overlay-background":(null==t?void 0:t.backgroundColor)||"#333","--presto-dynamic-overlay-opacity":(null==t?void 0:t.opacity)?(t.opacity/100).toString():"1"}})}shouldShowWatermark(t){var e,o,i;if(!(null===(o=null===(e=this.preset)||void 0===e?void 0:e.watermark)||void 0===o?void 0:o.enabled))return!1;const r=null===(i=this.preset)||void 0===i?void 0:i.watermark;return"randomize"===r.position?Math.floor((this.player.currentTime||0)/10)%2==0?"top-left"===t:"top-right"===t:r.position===t||!r.position&&"top-right"===t}render(){var t,e,o,i,r,s,l,a,n,d,p;if(this.enabled&&((null===(t=null==this?void 0:this.overlays)||void 0===t?void 0:t.length)||(null===(o=null===(e=this.preset)||void 0===e?void 0:e.watermark)||void 0===o?void 0:o.enabled)))return h("div",{class:"overlays",ref:t=>this.container=t},h("div",{class:"top-left",ref:t=>this.topLeft=t},!!this.shouldShowWatermark("top-left")&&h("presto-dynamic-overlay-ui",{ref:t=>this.watermarkRef.left=t,style:{"--presto-dynamic-overlay-color":(null===(i=this.preset.watermark)||void 0===i?void 0:i.color)||"#fff","--presto-dynamic-overlay-background":(null===(r=this.preset.watermark)||void 0===r?void 0:r.backgroundColor)||"#333","--presto-dynamic-overlay-opacity":(null===(s=this.preset.watermark)||void 0===s?void 0:s.opacity)?(this.preset.watermark.opacity/100).toString():"1"},class:"visible",position:"top-left",innerHTML:this.preset.watermark.text}),!!(null===(l=null==this?void 0:this.overlays)||void 0===l?void 0:l.length)&&this.overlays.map((t=>"top-left"!==t.position?"":this.renderOverlay(t)))),h("div",{class:"top-right",ref:t=>this.topRight=t},!!this.shouldShowWatermark("top-right")&&h("presto-dynamic-overlay-ui",{ref:t=>this.watermarkRef.right=t,style:{"--presto-dynamic-overlay-color":(null===(a=this.preset.watermark)||void 0===a?void 0:a.color)||"#fff","--presto-dynamic-overlay-background":(null===(n=this.preset.watermark)||void 0===n?void 0:n.backgroundColor)||"#333","--presto-dynamic-overlay-opacity":(null===(d=this.preset.watermark)||void 0===d?void 0:d.opacity)?(this.preset.watermark.opacity/100).toString():"1"},class:"visible",position:"top-right",innerHTML:this.preset.watermark.text}),!!(null===(p=null==this?void 0:this.overlays)||void 0===p?void 0:p.length)&&this.overlays.map((t=>"top-right"!==t.position?"":this.renderOverlay(t)))))}get el(){return this}static get style(){return PrestoDynamicOverlaysStyle0}},[1,"presto-dynamic-overlays",{overlays:[16],player:[8],preset:[16],enabled:[4],currentTime:[32],destroy:[32]}]);function defineCustomElement(){"undefined"!=typeof customElements&&["presto-dynamic-overlays","presto-dynamic-overlay-ui"].forEach((t=>{switch(t){case"presto-dynamic-overlays":customElements.get(t)||customElements.define(t,PrestoDynamicOverlays);break;case"presto-dynamic-overlay-ui":customElements.get(t)||defineCustomElement$1()}}))}export{PrestoDynamicOverlays as P,defineCustomElement as d};