https://www.whiteandwarren.com/cdn/shop/t/360/assets/vendor-media-…?v=111817465237235833351790108762
1/** 2 * Bundled by jsDelivr using Rollup v2.79.1 and Terser v5.19.2. 3 * Original file: /npm/[email protected]/youtube-video-element.js 4 * 5 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files 6 */ 7const e="https://www.youtube.com/embed",t=/(?:youtu\.be\/|youtube\.com\/(?:shorts\/|embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})/;function s(e){return`\n <style>\n :host {\n display: inline-block;\n line-height: 0;\n position: relative;\n min-width: 300px;\n min-height: 150px;\n }\n iframe {\n position: absolute;\n top: 0;\n left: 0;\n }\n </style>\n <iframe${function(e){let t="";for(const s in e){const i=e[s];t+=""===i?` ${s}`:` ${s}="${i}"`}return t}({src:i(e),frameborder:0,width:"100%",height:"100%",allow:"accelerometer; fullscreen; autoplay; encrypted-media; gyroscope; picture-in-picture"})}></iframe>\n `}function i(s){if(!s.src)return;const i=s.src.match(t),a=i&&i[1],n={controls:""===s.controls?null:0,autoplay:s.autoplay,loop:s.loop,mute:s.muted,playsinline:s.playsinline,preload:s.preload??"metadata",enablejsapi:1,showinfo:0,rel:0,iv_load_policy:3,modestbranding:1};return`${e}/${a}?${o=n,String(new URLSearchParams(function(e){let t={};for(let s in e){let i=e[s];!0===i||""===i?t[s]=1:!1===i?t[s]=0:null!=i&&(t[s]=i)}return t}(o)))}`;var o}class a extends(globalThis.HTMLElement??class{}){static getTemplateHTML=s;static shadowRootOptions={mode:"open"};static observedAttributes=["autoplay","controls","crossorigin","loop","muted","playsinline","poster","preload","src"];loadComplete=new r;#e;#t;#s=0;#i=!1;#a;isLoaded=!1;async load(){if(this.#e)return;this.shadowRoot||this.attachShadow({mode:"open"}),this.#t&&(this.loadComplete=new r,this.isLoaded=!1),this.#t=!0,await(this.#e=Promise.resolve()),this.#e=null,this.#s=0,this.dispatchEvent(new Event("emptied"));let e=this.api;if(this.api=null,!this.src)return void e?.destroy();this.dispatchEvent(new Event("loadstart"));let t=this.shadowRoot.querySelector("iframe"),a=function(e){let t={};for(let s of e)t[s.name]=s.value;return t}(this.attributes);t?.src&&t.src===i(a)||(this.shadowRoot.innerHTML=s(a),t=this.shadowRoot.querySelector("iframe"));const l=await async function(e,t,s){if(n[e])return n[e];if(t&&self[t])return await o(0),self[t];return n[e]=new Promise((function(i,a){const n=document.createElement("script");n.src=e;const o=()=>i(self[t]);s&&(self[s]=o),n.onload=()=>!s&&o(),n.onerror=a,document.head.append(n)}))}("https://www.youtube.com/iframe_api","YT","onYouTubeIframeAPIReady");this.api=new l.Player(t,{events:{onReady:()=>{this.#s=1,this.dispatchEvent(new Event("loadedmetadata")),this.dispatchEvent(new Event("durationchange")),this.dispatchEvent(new Event("volumechange")),this.dispatchEvent(new Event("loadcomplete")),this.isLoaded=!0,this.loadComplete.resolve()},onError:e=>console.error(e)}});let h=!1;this.api.addEventListener("onStateChange",(e=>{const t=e.data;if(t!==l.PlayerState.PLAYING&&t!==l.PlayerState.BUFFERING||h||(h=!0,this.dispatchEvent(new Event("play"))),t===l.PlayerState.PLAYING)this.seeking&&(this.#i=!1,this.#a?.resolve(),this.dispatchEvent(new Event("seeked"))),this.#s=3,this.dispatchEvent(new Event("playing"));else if(t===l.PlayerState.PAUSED){const e=Math.abs(this.currentTime-u);!this.seeking&&e>.1&&(this.#i=!0,this.dispatchEvent(new Event("seeking"))),h=!1,this.dispatchEvent(new Event("pause"))}t===l.PlayerState.ENDED&&(h=!1,this.dispatchEvent(new Event("pause")),this.dispatchEvent(new Event("ended")),this.loop&&this.play())})),this.api.addEventListener("onPlaybackRateChange",(()=>{this.dispatchEvent(new Event("ratechange"))})),this.api.addEventListener("onVolumeChange",(()=>{this.dispatchEvent(new Event("volumechange"))})),this.api.addEventListener("onVideoProgress",(()=>{this.dispatchEvent(new Event("timeupdate"))})),await this.loadComplete;let d,u=0;setInterval((()=>{const e=Math.abs(this.currentTime-u),t=this.buffered.end(this.buffered.length-1);this.seeking&&t>.1?(this.#i=!1,this.#a?.resolve(),this.dispatchEvent(new Event("seeked"))):!this.seeking&&e>.1&&(this.#i=!0,this.dispatchEvent(new Event("seeking"))),u=this.currentTime}),50);const p=setInterval((()=>{const e=this.buffered.end(this.buffered.length-1);e>=this.duration&&(clearInterval(p),this.#s=4),d!=e&&(d=e,this.dispatchEvent(new Event("progress")))}),100)}async attributeChangedCallback(e,t,s){if(t!==s)switch(e){case"src":case"auto
7play":case"controls":case"loop":case"playsinline":this.load()}}async play(){return this.#a=null,await this.loadComplete,this.api?.playVideo(),e=this,(t=(t,s)=>{let i;e.addEventListener(t,i=()=>{e.removeEventListener(t,i),s()})},(...e)=>new Promise((s=>{t(...e,((...e)=>{e.length>1?s(e):s(e[0])}))})))("playing");var e,t}async pause(){return await this.loadComplete,this.api?.pauseVideo()}get seeking(){return this.#i}get readyState(){return this.#s}get src(){return this.getAttribute("src")}set src(e){this.src!=e&&this.setAttribute("src",e)}get paused(){return this.isLoaded?[-1,0,2,5].includes(this.api?.getPlayerState?.()):!this.autoplay}get duration(){return this.api?.getDuration?.()??NaN}get autoplay(){return this.hasAttribute("autoplay")}set autoplay(e){this.autoplay!=e&&this.toggleAttribute("autoplay",Boolean(e))}get buffered(){if(!this.isLoaded)return l();const e=this.api?.getVideoLoadedFraction()*this.api?.getDuration();return e>0?l(0,e):l()}get controls(){return this.hasAttribute("controls")}set controls(e){this.controls!=e&&this.toggleAttribute("controls",Boolean(e))}get currentTime(){return this.api?.getCurrentTime?.()??0}set currentTime(e){this.currentTime!=e&&(this.#a=new r,this.loadComplete.then((()=>{this.api?.seekTo(e,!0),this.paused&&this.#a?.then((()=>{this.#a&&this.api?.pauseVideo()}))})))}set defaultMuted(e){this.defaultMuted!=e&&this.toggleAttribute("muted",Boolean(e))}get defaultMuted(){return this.hasAttribute("muted")}get loop(){return this.hasAttribute("loop")}set loop(e){this.loop!=e&&this.toggleAttribute("loop",Boolean(e))}set muted(e){this.muted!=e&&this.loadComplete.then((()=>{e?this.api?.mute():this.api?.unMute()}))}get muted(){return this.isLoaded?this.api?.isMuted?.():this.defaultMuted}get playbackRate(){return this.api?.getPlaybackRate?.()??1}set playbackRate(e){this.playbackRate!=e&&this.loadComplete.then((()=>{this.api?.setPlaybackRate(e)}))}get playsInline(){return this.hasAttribute("playsinline")}set playsInline(e){this.playsInline!=e&&this.toggleAttribute("playsinline",Boolean(e))}get poster(){return this.getAttribute("poster")}set poster(e){this.poster!=e&&this.setAttribute("poster",`${e}`)}set volume(e){this.volume!=e&&this.loadComplete.then((()=>{this.api?.setVolume(100*e)}))}get volume(){return this.isLoaded?this.api?.getVolume()/100:1}}const n={};const o=e=>new Promise((t=>setTimeout(t,e)));class r extends Promise{constructor(e=(()=>{})){let t,s;super(((i,a)=>{e(i,a),t=i,s=a})),this.resolve=t,this.reject=s}}function l(e,t){return Array.isArray(e)?h(e):h(null==e||null==t||0===e&&0===t?[[0,0]]:[[e,t]])}function h(e){return Object.defineProperties(e,{start:{value:t=>e[t][0]},end:{value:t=>e[t][1]}}),e}globalThis.customElements&&!globalThis.customElements.get("youtube-video")&&globalThis.customElements.define("youtube-video",a);export{a as default}; 8//# sourceMappingURL=/sm/b5c0497119e40fe14faed1b262af9b9860e5de654f8f622a5551cbc4cba66691.map
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.