@vouchfor/embeds 0.0.0-experiment.4ea86a2 → 0.0.0-experiment.4eb5f06

Sign up to get free protection for your applications and to get access to all the features.
@@ -74,7 +74,7 @@ var UT=Object.defineProperty;var BT=(Ge,Kr,Rr)=>Kr in Ge?UT(Ge,Kr,{enumerable:!0
74
74
  * @license
75
75
  * Copyright 2017 Google LLC
76
76
  * SPDX-License-Identifier: BSD-3-Clause
77
- */const rg=Symbol();class kd{get taskComplete(){return this.t||(this.status===1?this.t=new Promise((t,e)=>{this.i=t,this.o=e}):this.status===3?this.t=Promise.reject(this.h):this.t=Promise.resolve(this.l)),this.t}constructor(t,e,i){var o;this.u=0,this.status=0,(this.p=t).addController(this);const s=typeof e=="object"?e:{task:e,args:i};this._=s.task,this.v=s.args,this.j=s.argsEqual??sg,this.m=s.onComplete,this.g=s.onError,this.autoRun=s.autoRun??!0,"initialValue"in s&&(this.l=s.initialValue,this.status=2,this.k=(o=this.A)==null?void 0:o.call(this))}hostUpdate(){this.autoRun===!0&&this.O()}hostUpdated(){this.autoRun==="afterUpdate"&&this.O()}A(){if(this.v===void 0)return;const t=this.v();if(!Array.isArray(t))throw Error("The args function must return an array");return t}async O(){const t=this.A(),e=this.k;this.k=t,t===e||t===void 0||e!==void 0&&this.j(e,t)||await this.run(t)}async run(t){var c,d,f,p,g;let e,i;t??(t=this.A()),this.k=t,this.status===1?(c=this.T)==null||c.abort():(this.t=void 0,this.i=void 0,this.o=void 0),this.status=1,this.autoRun==="afterUpdate"?queueMicrotask(()=>this.p.requestUpdate()):this.p.requestUpdate();const s=++this.u;this.T=new AbortController;let o=!1;try{e=await this._(t,{signal:this.T.signal})}catch(v){o=!0,i=v}if(this.u===s){if(e===rg)this.status=0;else{if(o===!1){try{(d=this.m)==null||d.call(this,e)}catch{}this.status=2,(f=this.i)==null||f.call(this,e)}else{try{(p=this.g)==null||p.call(this,i)}catch{}this.status=3,(g=this.o)==null||g.call(this,i)}this.l=e,this.h=i}this.p.requestUpdate()}}abort(t){var e;this.status===1&&((e=this.T)==null||e.abort(t))}get value(){return this.l}get error(){return this.h}render(t){var e,i,s,o;switch(this.status){case 0:return(e=t.initial)==null?void 0:e.call(t);case 1:return(i=t.pending)==null?void 0:i.call(t);case 2:return(s=t.complete)==null?void 0:s.call(t,this.value);case 3:return(o=t.error)==null?void 0:o.call(t,this.error);default:throw Error("Unexpected status: "+this.status)}}}const sg=(n,t)=>n===t||n.length===t.length&&n.every((e,i)=>!El(e,t[i]));let Ya;const ng=new Uint8Array(16);function ag(){if(!Ya&&(Ya=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ya))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ya(ng)}const yi=[];for(let n=0;n<256;++n)yi.push((n+256).toString(16).slice(1));function og(n,t=0){return yi[n[t+0]]+yi[n[t+1]]+yi[n[t+2]]+yi[n[t+3]]+"-"+yi[n[t+4]]+yi[n[t+5]]+"-"+yi[n[t+6]]+yi[n[t+7]]+"-"+yi[n[t+8]]+yi[n[t+9]]+"-"+yi[n[t+10]]+yi[n[t+11]]+yi[n[t+12]]+yi[n[t+13]]+yi[n[t+14]]+yi[n[t+15]]}const Td={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Ks(n,t,e){if(Td.randomUUID&&!t&&!n)return Td.randomUUID();n=n||{};const i=n.random||(n.rng||ag)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let s=0;s<16;++s)t[e+s]=i[s];return t}return og(i)}const wd="https://d2rxhdlm2q91uk.cloudfront.net",lg="https://d1ix11aj5kfygl.cloudfront.net",cg="https://d157jlwnudd93d.cloudfront.net",Sd="https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev",hg="https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging",dg="https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod",ug="http://localhost:6060/v2",fg="https://embed-dev.vouchfor.com/v2",pg="https://embed-staging.vouchfor.com/v2",gg="https://embed.vouchfor.com/v2";function za(n){if(!["local","dev","staging","prod"].includes(n))throw new Error(`Unknown environment: ${n}`);if(n==="local")return{videoUrl:wd,publicApiUrl:Sd,embedApiUrl:ug};if(n==="dev")return{videoUrl:wd,publicApiUrl:Sd,embedApiUrl:fg};if(n==="staging")return{videoUrl:lg,publicApiUrl:hg,embedApiUrl:pg};if(n==="prod")return{videoUrl:cg,publicApiUrl:dg,embedApiUrl:gg}}class mg{constructor(t){this._fetching=!1,this.getVouch=async(e,i,s)=>{var g;const{embedApiUrl:o}=za(e),c=Ks(),d=await fetch(`${o}/vouches/${s}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",c]]}),f=await d.json();this.host.dispatchEvent(new CustomEvent("vouch:loaded",{detail:s}));const p=(g=d==null?void 0:d.headers)==null?void 0:g.get("X-Cache-Check");return p&&p!==c&&fetch(`${o}/vouches/${s}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.getTemplate=async(e,i,s)=>{var g;const{embedApiUrl:o}=za(e),c=Ks(),d=await fetch(`${o}/templates/${s}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",c]]}),f=await d.json(),p=(g=d==null?void 0:d.headers)==null?void 0:g.get("X-Cache-Check");return p&&p!==c&&fetch(`${o}/templates/${s}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.host=t,new kd(this.host,async([e,i,s,o,c])=>{var d,f,p,g;try{if(t.vouch=void 0,t.template=void 0,s){let v;c&&(this.fetching=!0,v=await this.getTemplate(e,i,c)),t.vouch=s,t.template=v??((f=(d=s==null?void 0:s.settings)==null?void 0:d.template)==null?void 0:f.instance)}else if(o){this.fetching=!0;const[v,b]=await Promise.all([this.getVouch(e,i,o),c?this.getTemplate(e,i,c):null]);t.vouch=v,t.template=b??((g=(p=v==null?void 0:v.settings)==null?void 0:p.template)==null?void 0:g.instance)}}finally{this.fetching=!1}},()=>[t.env,t.apiKey,t.data,t.vouchId,t.templateId])}set fetching(t){this._fetching!==t&&(this._fetching=t,this.host.requestUpdate())}get fetching(){return this._fetching}}const vg=1e4;class yg{constructor(t){this._tabId=void 0,this._clientId=void 0,this._visitorId=void 0,this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamedTime={},this._streamLatestTime={},this._streamedPrevTimestamp={},this._createVisitor=e=>{var s,o;const{publicApiUrl:i}=za(this.host.env);return(o=(s=window.localStorage)==null?void 0:s.setItem)==null||o.call(s,"vouch-uid-visitor",e),navigator.sendBeacon(`${i}/api/visitor`,JSON.stringify({visitorId:e})),e},this._getReportingMetadata=()=>{var o,c;const[e,i]=((c=(o=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:o.split)==null?void 0:c.call(o,"/"))??[],s={};return[...new URLSearchParams(location.search).entries()].forEach(([d,f])=>{if(/utm/.test(d)){const p=d.toLowerCase().replace(/[-_][a-z0-9]/g,g=>g.slice(-1).toUpperCase());s[p]=f}}),{source:this.host.trackingSource,time:new Date,region:i,country:e,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,...s}},this._sendTrackingEvent=(e,i)=>{const{publicApiUrl:s}=za(this.host.env),{client:o,tab:c,request:d,visitor:f}=this._getUids();this.host.disableTracking||navigator.sendBeacon(`${s}/api/events`,JSON.stringify({event:e,payload:i,context:{"x-uid-client":o,"x-uid-tab":c,"x-uid-request":d,"x-uid-visitor":f,"x-reporting-metadata":this._getReportingMetadata()}}))},this._handleVouchLoaded=({detail:e})=>{e&&(this._hasLoaded[e]||(this._sendTrackingEvent("VOUCH_LOADED",{vouchId:e}),this._hasLoaded[e]=!0))},this._handlePlay=()=>{const e=this._findVouchId();e&&(this._hasPlayed||(this._sendTrackingEvent("VIDEO_PLAYED",{vouchId:e,streamStart:this.host.currentTime}),this._hasPlayed=!0))},this._handleVideoPlay=({detail:{id:e,key:i,node:s}})=>{const o=this._findVouchId();o&&(this._answersViewed[i]||(this._sendTrackingEvent("VOUCH_RESPONSE_VIEWED",{vouchId:o,answerId:e}),this._answersViewed[i]=!0),this._streamedTime[i]=s.currentTime,this._streamLatestTime[i]=s.currentTime,this._streamedPrevTimestamp[i]=Date.now())},this._handleVideoSeeking=({detail:{id:e,key:i}})=>{const s=this._findVouchId();s&&(this._streamLatestTime[i]&&this._sendTrackingEvent("VIDEO_STREAMED",{vouchId:s,answerId:e,streamStart:this._streamedTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamedTime[i],delete this._streamLatestTime[i],delete this._streamedPrevTimestamp[i])},this._handleVideoTimeUpdate=({detail:{id:e,key:i,node:s}})=>{var d,f;const o=this._findVouchId();if(!o)return;const c=Date.now();s.currentTime&&!s.paused&&!this.host.paused&&e===((f=(d=this.host.scene)==null?void 0:d.video)==null?void 0:f.id)&&c-this._streamedPrevTimestamp[i]>vg&&(this._sendTrackingEvent("VIDEO_STREAMED",{vouchId:o,answerId:e,streamStart:this._streamedTime[i],streamEnd:s.currentTime}),this._streamedTime[i]=s.currentTime,this._streamedPrevTimestamp[i]=c),this._streamLatestTime[i]=s.currentTime},this._handleVideoPause=({detail:{id:e,key:i,node:s}})=>{const o=this._findVouchId();o&&(s.currentTime>this._streamedTime[i]&&this._sendTrackingEvent("VIDEO_STREAMED",{vouchId:o,answerId:e,streamStart:this._streamedTime[i],streamEnd:s.currentTime}),delete this._streamedTime[i],delete this._streamLatestTime[i],delete this._streamedPrevTimestamp[i])},this.host=t,t.addController(this)}_findVouchId(){if(this.host.vouch)return"uuid"in this.host.vouch?this.host.vouch.uuid:this.host.vouch.id}_getUids(){var o,c,d,f,p,g,v,b,E,k,T,R;if(typeof window>"u")return{client:null,tab:null,request:Ks()};const t=this._visitorId||((c=(o=window.localStorage)==null?void 0:o.getItem)==null?void 0:c.call(o,"vouch-uid-visitor"))||this._createVisitor(Ks()),e=this._clientId||((f=(d=window.localStorage)==null?void 0:d.getItem)==null?void 0:f.call(d,"vouch-uid-client"))||Ks(),i=this._tabId||((g=(p=window.sessionStorage)==null?void 0:p.getItem)==null?void 0:g.call(p,"vouch-uid-tab"))||Ks(),s=Ks();return t!==this._visitorId&&(this._visitorId=t,(b=(v=window.localStorage)==null?void 0:v.setItem)==null||b.call(v,"vouch-uid-visitor",t)),e!==this._clientId&&(this._clientId=e,(k=(E=window.localStorage)==null?void 0:E.setItem)==null||k.call(E,"vouch-uid-client",e)),i!==this._tabId&&(this._tabId=i,(R=(T=window.sessionStorage)==null?void 0:T.setItem)==null||R.call(T,"vouch-uid-tab",i)),{client:e,tab:i,request:s,visitor:t}}hostConnected(){requestAnimationFrame(()=>{var t,e,i,s,o;this.host.addEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.addEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.addEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.addEventListener("video:seeking",this._handleVideoSeeking),(s=this.host.mediaPlayer)==null||s.addEventListener("video:pause",this._handleVideoPause),(o=this.host.mediaPlayer)==null||o.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var t,e,i,s,o;this.host.removeEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.removeEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.removeEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.removeEventListener("video:seeking",this._handleVideoSeeking),(s=this.host.mediaPlayer)==null||s.removeEventListener("video:pause",this._handleVideoPause),(o=this.host.mediaPlayer)==null||o.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}const bg=(n,t,e,i)=>{if(e==="length"||e==="prototype"||e==="arguments"||e==="caller")return;const s=Object.getOwnPropertyDescriptor(n,e),o=Object.getOwnPropertyDescriptor(t,e);!Ag(s,o)&&i||Object.defineProperty(n,e,o)},Ag=function(n,t){return n===void 0||n.configurable||n.writable===t.writable&&n.enumerable===t.enumerable&&n.configurable===t.configurable&&(n.writable||n.value===t.value)},Eg=(n,t)=>{const e=Object.getPrototypeOf(t);e!==Object.getPrototypeOf(n)&&Object.setPrototypeOf(n,e)},kg=(n,t)=>`/* Wrapped ${n}*/
77
+ */const rg=Symbol();class kd{get taskComplete(){return this.t||(this.status===1?this.t=new Promise((t,e)=>{this.i=t,this.o=e}):this.status===3?this.t=Promise.reject(this.h):this.t=Promise.resolve(this.l)),this.t}constructor(t,e,i){var o;this.u=0,this.status=0,(this.p=t).addController(this);const s=typeof e=="object"?e:{task:e,args:i};this._=s.task,this.v=s.args,this.j=s.argsEqual??sg,this.m=s.onComplete,this.g=s.onError,this.autoRun=s.autoRun??!0,"initialValue"in s&&(this.l=s.initialValue,this.status=2,this.k=(o=this.A)==null?void 0:o.call(this))}hostUpdate(){this.autoRun===!0&&this.O()}hostUpdated(){this.autoRun==="afterUpdate"&&this.O()}A(){if(this.v===void 0)return;const t=this.v();if(!Array.isArray(t))throw Error("The args function must return an array");return t}async O(){const t=this.A(),e=this.k;this.k=t,t===e||t===void 0||e!==void 0&&this.j(e,t)||await this.run(t)}async run(t){var c,d,f,p,g;let e,i;t??(t=this.A()),this.k=t,this.status===1?(c=this.T)==null||c.abort():(this.t=void 0,this.i=void 0,this.o=void 0),this.status=1,this.autoRun==="afterUpdate"?queueMicrotask(()=>this.p.requestUpdate()):this.p.requestUpdate();const s=++this.u;this.T=new AbortController;let o=!1;try{e=await this._(t,{signal:this.T.signal})}catch(v){o=!0,i=v}if(this.u===s){if(e===rg)this.status=0;else{if(o===!1){try{(d=this.m)==null||d.call(this,e)}catch{}this.status=2,(f=this.i)==null||f.call(this,e)}else{try{(p=this.g)==null||p.call(this,i)}catch{}this.status=3,(g=this.o)==null||g.call(this,i)}this.l=e,this.h=i}this.p.requestUpdate()}}abort(t){var e;this.status===1&&((e=this.T)==null||e.abort(t))}get value(){return this.l}get error(){return this.h}render(t){var e,i,s,o;switch(this.status){case 0:return(e=t.initial)==null?void 0:e.call(t);case 1:return(i=t.pending)==null?void 0:i.call(t);case 2:return(s=t.complete)==null?void 0:s.call(t,this.value);case 3:return(o=t.error)==null?void 0:o.call(t,this.error);default:throw Error("Unexpected status: "+this.status)}}}const sg=(n,t)=>n===t||n.length===t.length&&n.every((e,i)=>!El(e,t[i]));let Ya;const ng=new Uint8Array(16);function ag(){if(!Ya&&(Ya=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ya))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ya(ng)}const yi=[];for(let n=0;n<256;++n)yi.push((n+256).toString(16).slice(1));function og(n,t=0){return yi[n[t+0]]+yi[n[t+1]]+yi[n[t+2]]+yi[n[t+3]]+"-"+yi[n[t+4]]+yi[n[t+5]]+"-"+yi[n[t+6]]+yi[n[t+7]]+"-"+yi[n[t+8]]+yi[n[t+9]]+"-"+yi[n[t+10]]+yi[n[t+11]]+yi[n[t+12]]+yi[n[t+13]]+yi[n[t+14]]+yi[n[t+15]]}const Td={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Ks(n,t,e){if(Td.randomUUID&&!t&&!n)return Td.randomUUID();n=n||{};const i=n.random||(n.rng||ag)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let s=0;s<16;++s)t[e+s]=i[s];return t}return og(i)}const wd="https://d2rxhdlm2q91uk.cloudfront.net",lg="https://d1ix11aj5kfygl.cloudfront.net",cg="https://d157jlwnudd93d.cloudfront.net",Sd="https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev",hg="https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging",dg="https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod",ug="http://localhost:6060/v2",fg="https://embed-dev.vouchfor.com/v2",pg="https://embed-staging.vouchfor.com/v2",gg="https://embed.vouchfor.com/v2";function za(n){if(!["local","dev","staging","prod"].includes(n))throw new Error(`Unknown environment: ${n}`);if(n==="local")return{videoUrl:wd,publicApiUrl:Sd,embedApiUrl:ug};if(n==="dev")return{videoUrl:wd,publicApiUrl:Sd,embedApiUrl:fg};if(n==="staging")return{videoUrl:lg,publicApiUrl:hg,embedApiUrl:pg};if(n==="prod")return{videoUrl:cg,publicApiUrl:dg,embedApiUrl:gg}}class mg{constructor(t){this._fetching=!1,this.getVouch=async(e,i,s)=>{var g;const{embedApiUrl:o}=za(e),c=Ks(),d=await fetch(`${o}/vouches/${s}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",c]]}),f=await d.json();this.host.dispatchEvent(new CustomEvent("vouch:loaded",{detail:s}));const p=(g=d==null?void 0:d.headers)==null?void 0:g.get("X-Cache-Check");return p&&p!==c&&fetch(`${o}/vouches/${s}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.getTemplate=async(e,i,s)=>{var g;const{embedApiUrl:o}=za(e),c=Ks(),d=await fetch(`${o}/templates/${s}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",c]]}),f=await d.json(),p=(g=d==null?void 0:d.headers)==null?void 0:g.get("X-Cache-Check");return p&&p!==c&&fetch(`${o}/templates/${s}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.host=t,new kd(this.host,async([e,i,s,o,c])=>{var d,f,p,g;try{if(t.vouch=void 0,t.template=void 0,s){let v;c&&(this.fetching=!0,v=await this.getTemplate(e,i,c)),t.vouch=s,t.template=v??((f=(d=s==null?void 0:s.settings)==null?void 0:d.template)==null?void 0:f.instance)}else if(o){this.fetching=!0;const[v,b]=await Promise.all([this.getVouch(e,i,o),c?this.getTemplate(e,i,c):null]);t.vouch=v,t.template=b??((g=(p=v==null?void 0:v.settings)==null?void 0:p.template)==null?void 0:g.instance)}}finally{this.fetching=!1}},()=>[t.env,t.apiKey,t.data,t.vouchId,t.templateId])}set fetching(t){this._fetching!==t&&(this._fetching=t,this.host.requestUpdate())}get fetching(){return this._fetching}}const vg=10;class yg{constructor(t){this._tabId=void 0,this._clientId=void 0,this._visitorId=void 0,this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamedTime={},this._streamLatestTime={},this._createVisitor=e=>{var s,o;const{publicApiUrl:i}=za(this.host.env);return(o=(s=window.localStorage)==null?void 0:s.setItem)==null||o.call(s,"vouch-uid-visitor",e),navigator.sendBeacon(`${i}/api/visitor`,JSON.stringify({visitorId:e})),e},this._getReportingMetadata=()=>{var o,c;const[e,i]=((c=(o=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:o.split)==null?void 0:c.call(o,"/"))??[],s={};return[...new URLSearchParams(location.search).entries()].forEach(([d,f])=>{if(/utm/.test(d)){const p=d.toLowerCase().replace(/[-_][a-z0-9]/g,g=>g.slice(-1).toUpperCase());s[p]=f}}),{source:this.host.trackingSource,time:new Date,region:i,country:e,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,...s}},this._sendTrackingEvent=(e,i)=>{const{publicApiUrl:s}=za(this.host.env),{client:o,tab:c,request:d,visitor:f}=this._getUids();this.host.disableTracking||navigator.sendBeacon(`${s}/api/events`,JSON.stringify({event:e,payload:i,context:{"x-uid-client":o,"x-uid-tab":c,"x-uid-request":d,"x-uid-visitor":f,"x-reporting-metadata":this._getReportingMetadata()}}))},this._handleVouchLoaded=({detail:e})=>{e&&(this._hasLoaded[e]||(this._sendTrackingEvent("VOUCH_LOADED",{vouchId:e}),this._hasLoaded[e]=!0))},this._handlePlay=()=>{const e=this._findVouchId();e&&(this._hasPlayed||(this._sendTrackingEvent("VIDEO_PLAYED",{vouchId:e,streamStart:this.host.currentTime}),this._hasPlayed=!0))},this._handleVideoPlay=({detail:{id:e,key:i,node:s}})=>{const o=this._findVouchId();o&&(this._answersViewed[i]||(this._sendTrackingEvent("VOUCH_RESPONSE_VIEWED",{vouchId:o,answerId:e}),this._answersViewed[i]=!0),this._streamedTime[i]=s.currentTime,this._streamLatestTime[i]=s.currentTime)},this._handleVideoTimeUpdate=({detail:{id:e,key:i,node:s}})=>{var c,d;const o=this._findVouchId();o&&(s.currentTime&&!s.paused&&!this.host.paused&&e===((d=(c=this.host.scene)==null?void 0:c.video)==null?void 0:d.id)&&s.currentTime-this._streamedTime[i]>vg&&(this._sendTrackingEvent("VIDEO_STREAMED",{vouchId:o,answerId:e,streamStart:this._streamedTime[i],streamEnd:s.currentTime}),this._streamedTime[i]=s.currentTime),this.host.paused||(this._streamLatestTime[i]=s.currentTime))},this._handleVideoPause=({detail:{id:e,key:i}})=>{const s=this._findVouchId();s&&(this._streamLatestTime[i]>this._streamedTime[i]+.5&&this._sendTrackingEvent("VIDEO_STREAMED",{vouchId:s,answerId:e,streamStart:this._streamedTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamedTime[i],delete this._streamLatestTime[i])},this.host=t,t.addController(this)}_findVouchId(){if(this.host.vouch)return"uuid"in this.host.vouch?this.host.vouch.uuid:this.host.vouch.id}_getUids(){var o,c,d,f,p,g,v,b,E,k,T,R;if(typeof window>"u")return{client:null,tab:null,request:Ks()};const t=this._visitorId||((c=(o=window.localStorage)==null?void 0:o.getItem)==null?void 0:c.call(o,"vouch-uid-visitor"))||this._createVisitor(Ks()),e=this._clientId||((f=(d=window.localStorage)==null?void 0:d.getItem)==null?void 0:f.call(d,"vouch-uid-client"))||Ks(),i=this._tabId||((g=(p=window.sessionStorage)==null?void 0:p.getItem)==null?void 0:g.call(p,"vouch-uid-tab"))||Ks(),s=Ks();return t!==this._visitorId&&(this._visitorId=t,(b=(v=window.localStorage)==null?void 0:v.setItem)==null||b.call(v,"vouch-uid-visitor",t)),e!==this._clientId&&(this._clientId=e,(k=(E=window.localStorage)==null?void 0:E.setItem)==null||k.call(E,"vouch-uid-client",e)),i!==this._tabId&&(this._tabId=i,(R=(T=window.sessionStorage)==null?void 0:T.setItem)==null||R.call(T,"vouch-uid-tab",i)),{client:e,tab:i,request:s,visitor:t}}hostConnected(){requestAnimationFrame(()=>{var t,e,i,s;this.host.addEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.addEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.addEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.addEventListener("video:pause",this._handleVideoPause),(s=this.host.mediaPlayer)==null||s.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var t,e,i,s;this.host.removeEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.removeEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.removeEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.removeEventListener("video:pause",this._handleVideoPause),(s=this.host.mediaPlayer)==null||s.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}const bg=(n,t,e,i)=>{if(e==="length"||e==="prototype"||e==="arguments"||e==="caller")return;const s=Object.getOwnPropertyDescriptor(n,e),o=Object.getOwnPropertyDescriptor(t,e);!Ag(s,o)&&i||Object.defineProperty(n,e,o)},Ag=function(n,t){return n===void 0||n.configurable||n.writable===t.writable&&n.enumerable===t.enumerable&&n.configurable===t.configurable&&(n.writable||n.value===t.value)},Eg=(n,t)=>{const e=Object.getPrototypeOf(t);e!==Object.getPrototypeOf(n)&&Object.setPrototypeOf(n,e)},kg=(n,t)=>`/* Wrapped ${n}*/
78
78
  ${t}`,Tg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Sg=(n,t,e)=>{const i=e===""?"":`with ${e.trim()}() `,s=kg.bind(null,i,t.toString());Object.defineProperty(s,"name",wg),Object.defineProperty(n,"toString",{...Tg,value:s})};function Lg(n,t,{ignoreNonConfigurable:e=!1}={}){const{name:i}=n;for(const s of Reflect.ownKeys(t))bg(n,t,s,e);return Eg(n,t),Sg(n,t,i),n}const Rg=new WeakMap;function ra(n,{cacheKey:t=([i])=>i,cache:e=new Map}={}){const i=new Map,s=function(...o){const c=t(o);if(i.has(c))return i.get(c);const d=(async()=>{try{if(e&&await e.has(c))return await e.get(c);const p=await n.apply(this,o);try{return p}finally{e&&await e.set(c,p)}}finally{i.delete(c)}})();return i.set(c,d),d};return Lg(s,n,{ignoreNonConfigurable:!0}),Rg.set(s,e),s}var Za=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function kl(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Tl={exports:{}};(function(n,t){(function(e,i){i(t)})(Za,function(e){function i($){var N,Z,pt=new Error($);return N=pt,Z=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(N,Z):N.__proto__=Z,pt}function s($,N,Z){var pt=N.slice(0,Z).split(/\n/),kt=pt.length,Ot=pt[kt-1].length+1;throw i($+=" at line "+kt+" col "+Ot+`:
79
79
 
80
80
  `+N.split(/\n/)[kt-1]+`
@@ -1381,7 +1381,7 @@ ${t}`,Tg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
1381
1381
  @captions:click=${()=>{this._captions=!this._captions}}
1382
1382
  @fullscreen:click=${()=>{this.toggleFullscreen()}}
1383
1383
  @input=${k=>{const T=k.composedPath()[0],R=T.getAttribute("key");if(R==="scrubber"){const x=parseFloat(T.value);this._drawController.currentTime=x,this._sceneController.setVideosCurrentTime(x),this.dispatchEvent(new CustomEvent("seeking",{detail:x}))}R==="volume"&&(this.volume=parseFloat(T.value))}}
1384
- @pointerdown=${k=>{k.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!0,this._wasPlaying=!this.paused,this.paused||setTimeout(()=>{this.pause()}))}}
1384
+ @pointerdown=${k=>{k.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!0,this._wasPlaying=!this.paused,this.paused||this.pause())}}
1385
1385
  @pointerup=${k=>{k.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!1,this._wasPlaying&&(this.play(),this._wasPlaying=!1),this.dispatchEvent(new CustomEvent("seeked",{detail:this._drawController.currentTime})))}}
1386
1386
  ></vmp-new-player-overlay>
1387
1387
  </div>