@vouchfor/embeds 3.2.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/embeds.js +3 -3
- package/dist/iife/dialog-embed/embed.iife.js +2 -2
- package/dist/iife/dialog-embed/embed.iife.js.map +1 -1
- package/dist/iife/embeds.iife.js +2 -2
- package/dist/iife/embeds.iife.js.map +1 -1
- package/dist/iife/player-embed/embed.iife.js +2 -2
- package/dist/iife/player-embed/embed.iife.js.map +1 -1
- package/package.json +3 -3
package/dist/iife/embeds.iife.js
CHANGED
|
@@ -149,8 +149,8 @@ ${e}`,Gg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Hg=Objec
|
|
|
149
149
|
"playlist": {{ it._derived?.playlist }},
|
|
150
150
|
"preview": {{ it._derived?.preview }},
|
|
151
151
|
"captions": {{ it._derived?.captions }}
|
|
152
|
-
}`}],root:"{{ it.outro?.questions?.items }}"}],system:!0}],meta:{frameRate:30,resolution:1080,transitionDuration:1/3},options:{videoFormat:"letterbox-video"},default:0,system:!0};async function hf(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>Xh);return new s.Image}return new Image}const kl=Yt(async function(e){return e?new Promise((t,i)=>{hf().then(r=>{r.onload=()=>{t(r)},r.onerror=n=>{i(n)},r.src=e})}):null});async function To({element:s,meta:e},t,i){var r,n,o;let a={...s};const{node:A}=s;if((A==null?void 0:A.type)==="video"&&((r=A==null?void 0:A.value)!=null&&r.src||(n=A==null?void 0:A.value)!=null&&n.playlist)){const l=await t(A.value,e);let c;try{c=await kl(A.value.poster)}catch{c=null}a={...a,node:{...A,video:l,poster:c,meta:await i(A.value,l.node,e)}}}if((A==null?void 0:A.type)==="image"&&A.value){let l;try{l=await kl(A.value)}catch{l=null}a={...a,node:{...A,image:l}}}return a.node&&((o=s.node)!=null&&o.elements)&&(a.node.elements=await Promise.all(s.node.elements.map(l=>To({element:l,meta:e},t,i)))),s.elements&&(a.elements=await Promise.all(s.elements.map(l=>To({element:l,meta:e},t,i)))),a}async function Zr(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>Xh),e=new s.Canvas;return e.gpu=!1,e}return document.createElement("canvas")}function tr(s=[]){var e;for(const t of s){if(((e=t==null?void 0:t.node)==null?void 0:e.type)==="video")return t.node;const i=tr(t==null?void 0:t.elements);if(i)return i}}function df(s,e){return s.reduce((t,i,r)=>[...t,i.map((n,o)=>n.map(({duration:a},A)=>r===s.length-1&&o===i.length-1&&A===n.length-1?a:a-e))],[])}function gf(s){if(s===null||typeof s!="object")return!1;if(Object.getPrototypeOf(s)===null)return!0;let e=s;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(s)===e}function ff(s){return s.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\f/g,"\\f").replace(/"/g,'\\"')}function en(s){return s.flatMap(e=>Array.isArray(e)?e.flatMap(t=>t):e).reduce((e,t)=>e+t,0)}const pf=Yt(()=>pl.loadYoga());Co.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${ff(s)}"`:gf(s)||Array.isArray(s)?JSON.stringify(s):s);const us=(s,e,t)=>Co.render(s,e,Co.getConfig({autoEscape:!1,defaultFilter:"parse",...t}));async function hs({data:s,template:e,burnCaptions:t=!1,debug:i=!1},r,n,o){var a,A,l,c;const u=await pf(),h=e??uf;if(!((a=h.templates)!=null&&a.length))throw new Error(`No templates found for template instance: ${h.id}`);let d=h.templates.find(({version:k})=>k===Do);if(!d){const k=h.templates.map(({version:M})=>`"${M}"`).join(", ");console.warn(`Template renderer expects template version "${Do}" but got ${k}`),d=h.templates[h.templates.length-1]}const g=await Promise.all(d.content.map(async({scenes:k,root:M})=>{const j={...h.options,...s,intro:h.intro,outro:h.outro};async function V(z,R){return Promise.all(k.map(async({layout:x,duration:G,data:S,derived:w,options:T})=>{var Y,U,q;const se={...j,_index:R,_root:z,_derived:await r({data:s,rootData:z,index:R})},ce=S?JSON.parse(await us(S,se)):{},ne=w?JSON.parse(await us(w,se)):{},me=T?JSON.parse(await us(T,se)):{},Se=G?parseFloat(await us(G,se)):NaN,Re=(Y=d.layouts.find(ge=>ge.name===x))==null?void 0:Y.tree;if(!Re)throw new Error(`Layout tree "${x}" not found in template "${d.id}" layouts.`);const oe=JSON.parse(await us(Re,{...ce,...ne,...me})),de=await Promise.all(oe.flatMap(ge=>To({element:ge,meta:h.meta},n,o))),Qe=tr(de);return{duration:(isNaN(Se)?null:Se)??((U=Qe==null?void 0:Qe.meta)==null?void 0:U.duration)??0,captions:(q=Qe==null?void 0:Qe.meta)==null?void 0:q.captions,elements:de}}))}if(M){const z=JSON.parse(await us(M,j));return Array.isArray(z)?Promise.all(z.map(async(R,x)=>V(R,x))):Promise.all([V(z,null)])}return Promise.all([V(s,null)])}));if(g.every(k=>k.every(M=>M.every(j=>{const V=tr(j.elements);return!(V!=null&&V.value.src)&&!(V!=null&&V.value.playlist)})))){const k=g.flatMap(M=>M.flatMap(j=>j.map(V=>{const z=tr(V.elements);return!(z!=null&&z.value.src)&&!(z!=null&&z.value.playlist)&&(z==null?void 0:z.value.id)}).filter(Boolean))).join(", ");throw new Error(`Video(s) with ID ${k} failed to load, video can not be processed`)}if(g.every(k=>k.every(M=>M.every(j=>j.duration<=0))))throw new Error("No scenes have any duration, video can not be processed");const v=g.reduce((k,M)=>{const j=M.reduce((V,z)=>{const R=z.filter(x=>x.duration>0);return R.length>0?[...V,R]:V},[]);return j.length>0?[...k,j]:k},[]),y=((A=h.meta)==null?void 0:A.frameRate)??30,b=((l=h.meta)==null?void 0:l.resolution)??1080,C=((c=h.meta)==null?void 0:c.transitionDuration)??1/3,Q=df(v,C),B=en(Q),L=await Promise.all(v.map((k,M)=>{const j=en(Q[M]),V=en(Q.slice(0,M));return Promise.all(k.map((z,R)=>Promise.all(z.map(async({duration:x,captions:G,elements:S},w)=>{var T,Y;const U=await Zr(),q=await Zr(),se=await Zr(),ce=await Zr(),ne=tr(S),me=en([...Q.slice(0,M),...Q[M].slice(0,R),...Q[M][R].slice(0,w)]);return{draw:({canvas:Re,currentTime:oe})=>{const de=Math.max(0,oe-V),Qe=Math.max(0,oe-me);xo({yoga:u,debug:i,canvas:Re,cropCanvas:U,posterCanvas:ce,letterboxCanvas:q,elements:S,currentTime:oe,contentTime:de,sceneTime:Qe,totalDuration:B,contentDuration:j,sceneDuration:x}),G&&t&&of({canvas:Re,dx:0,dy:0,dw:Re.width,dh:Re.height,vttCaptions:G,sceneTime:Qe+((ne==null?void 0:ne.meta.start)??0)})},duration:x,transitionCanvas:se,id:cf(),start:me,video:ne==null?void 0:ne.video,videoMeta:ne==null?void 0:ne.meta,audio:{duration:x,src:(T=ne==null?void 0:ne.value)==null?void 0:T.src,start:(Y=ne==null?void 0:ne.meta)==null?void 0:Y.start}}}))))})),_=L.flatMap(k=>k);return{scenes:_.flatMap(k=>k),sections:_,contents:L,frameRate:y,resolution:b,transitionDuration:C,fonts:d.fonts??[],duration:B}}const Do="3",Ef={name:"@vouchfor/embeds",version:"3.2.0",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds.js",module:"dist/es/embeds.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds.js"},files:["dist","src"],publishConfig:{tag:"latest",access:"public"},engines:{node:">=18.18.0"},scripts:{build:"rm -rf dist && tsc && yarn build:self","build:deps":"yarn --cwd ../media-player build","build:self":"vite build --mode iife && vite build --mode es && node scripts/build.cjs","build:package":"yarn build","build:storybook":"yarn prebuild && storybook build","generate:manifest":"wca src --outFile custom-elements.json",lint:"eslint . --quiet","lint:fix":"eslint . --fix","lint:staged":"lint-staged",prepublishOnly:"yarn build",size:"size-limit",storybook:"yarn prebuild && storybook dev -p 6007",prebuild:"yarn build:deps && yarn generate:manifest",test:"rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner","test:ci":"yarn test --config web-test-runner.ci.config.js","test:watch":"yarn test --watch"},"lint-staged":{"**/*.{ts,tsx,js}":"eslint --fix --quiet","**/*.{md,json,yml}":"prettier --write"},dependencies:{"@a11y/focus-trap":"^1.0.5","@lit/task":"^1.0.0","@vouchfor/canvas-video":"^8.2.2","@vouchfor/media-player":"^4.2.0",uuid:"^9.0.1"},peerDependencies:{lit:"^3.1.2"},devDependencies:{"@esm-bundle/chai":"^4.3.4-fix.0","@open-wc/testing":"^4.0.0","@storybook/addon-essentials":"^8.0.4","@storybook/addon-links":"^8.0.4","@storybook/blocks":"^8.0.4","@storybook/web-components":"^8.0.4","@storybook/web-components-vite":"^8.0.4","@svgr/core":"^8.1.0","@types/flat":"^5.0.5","@types/mocha":"^10.0.6","@vouchfor/eslint-config":"^1.0.1","@vouchfor/prettier-config":"^1.0.1","@vouchfor/video-utils":"^1.4.0","@web/dev-server-esbuild":"^1.0.2","@web/test-runner":"^0.18.1","@web/test-runner-browserstack":"^0.7.1","@web/test-runner-mocha":"^0.9.0","@web/test-runner-playwright":"^0.11.0",glob:"^10.3.10","lint-staged":"^15.2.2",lit:"^3.1.2",lodash:"^4.17.21",react:"^18.2.0","react-dom":"^18.2.0","rollup-plugin-tla":"^0.0.2",sinon:"^17.0.1",storybook:"^8.0.4",svgson:"^5.3.1",typescript:"^5.4.3",vite:"^5.2.2","vite-plugin-commonjs":"^0.10.1","vite-plugin-dts":"^3.7.3","web-component-analyzer":"^2.0.0"}};function If(s){const{publicApiUrl:e}=Lr(s),t=Li();return navigator.sendBeacon(`${e}/api/visitor`,JSON.stringify({visitorId:t})),t}function mf(s){var n,o,a,A,l,c,u,h,d,g,f,p;if(typeof window>"u")return{client:null,tab:null,request:Li()};let e=(o=(n=window.localStorage)==null?void 0:n.getItem)==null?void 0:o.call(n,"vouch-uid-visitor"),t=(A=(a=window.localStorage)==null?void 0:a.getItem)==null?void 0:A.call(a,"vouch-uid-client"),i=(c=(l=window.sessionStorage)==null?void 0:l.getItem)==null?void 0:c.call(l,"vouch-uid-tab");const r=Li();return e||(e=If(s),(h=(u=window.localStorage)==null?void 0:u.setItem)==null||h.call(u,"vouch-uid-visitor",e)),t||(t=Li(),(g=(d=window.localStorage)==null?void 0:d.setItem)==null||g.call(d,"vouch-uid-client",t)),i||(i=Li(),(p=(f=window.sessionStorage)==null?void 0:f.setItem)==null||p.call(f,"vouch-uid-tab",i)),{client:t,tab:i,request:r,visitor:e}}function Cf(s,e){return s&&"vouchId"in s?s.vouchId:(e==null?void 0:e.id)??null}function vf(s="embedded_player"){var r,n;const[e,t]=((n=(r=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:r.split)==null?void 0:n.call(r,"/"))??[],i={};return[...new URLSearchParams(location.search).entries()].forEach(([o,a])=>{if(/utm/.test(o)){const A=o.toLowerCase().replace(/[-_][a-z0-9]/g,l=>l.slice(-1).toUpperCase());i[A]=a}}),{source:s,time:new Date,region:t,country:e,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,embedType:"media-player-embed",embedVersion:Ef.version,templateVersion:Do,...i}}const Fl=1;class yf{constructor(e){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(t,i)=>{const r=Cf(i,this.host.vouch);!r||this.host.disableTracking||this._batchedEvents.push({event:t,payload:{...i,vouchId:r,time:new Date().toISOString()}})},this._sendTrackingEvent=()=>{if(this._batchedEvents.length<=0)return;const{publicApiUrl:t}=Lr(this.host.env),{client:i,tab:r,request:n,visitor:o}=mf(this.host.env);navigator.sendBeacon(`${t}/api/batchevents`,JSON.stringify({payload:{events:this._batchedEvents},context:{"x-uid-client":i,"x-uid-tab":r,"x-uid-request":n,"x-uid-visitor":o,"x-reporting-metadata":vf(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:t,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+Fl&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:t,streamStart:this._streamStartTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamStartTime[i],delete this._streamLatestTime[i]}},this._handleVouchLoaded=({detail:t})=>{t&&(this._hasLoaded[t]||(this._createTrackingEvent("VOUCH_LOADED",{vouchId:t}),this._hasLoaded[t]=!0))},this._handlePlay=()=>{this._hasPlayed||(this._createTrackingEvent("VIDEO_PLAYED",{streamStart:this.host.currentTime}),this._hasPlayed=!0)},this._handleVideoPlay=({detail:{id:t,key:i}})=>{this._answersViewed[i]||(this._createTrackingEvent("VOUCH_RESPONSE_VIEWED",{answerId:t}),this._answersViewed[i]=!0)},this._handleVideoTimeUpdate=({detail:{id:t,key:i,node:r}})=>{var n,o;!this.host.paused&&t===((o=(n=this.host.scene)==null?void 0:n.video)==null?void 0:o.id)&&(this._currentlyPlayingVideo={id:t,key:i,node:r},this._streamLatestTime[i]=r.currentTime,this._streamStartTime[i]||(this._streamStartTime[i]=r.currentTime,this._streamLatestTime[i]=r.currentTime))},this._handleVideoPause=({detail:{id:t,key:i}})=>{this._streamLatestTime[i]>this._streamStartTime[i]+Fl&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:t,streamStart:this._streamStartTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamStartTime[i],delete this._streamLatestTime[i]},this._pageUnloading=()=>{this._streamEnded(),this._sendTrackingEvent()},this._handleVisibilityChange=()=>{document.visibilityState==="hidden"&&this._pageUnloading()},this._handlePageHide=()=>{this._pageUnloading()},this.host=e,e.addController(this)}hostConnected(){requestAnimationFrame(()=>{var e,t,i,r;"onvisibilitychange"in document?document.addEventListener("visibilitychange",this._handleVisibilityChange):window.addEventListener("pagehide",this._handlePageHide),this.host.addEventListener("vouch:loaded",this._handleVouchLoaded),(e=this.host.mediaPlayer)==null||e.addEventListener("play",this._handlePlay),(t=this.host.mediaPlayer)==null||t.addEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.addEventListener("video:pause",this._handleVideoPause),(r=this.host.mediaPlayer)==null||r.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var e,t,i,r;this._pageUnloading(),"onvisibilitychange"in document?document.removeEventListener("visibilitychange",this._handleVisibilityChange):window.removeEventListener("pagehide",this._handlePageHide),this.host.removeEventListener("vouch:loaded",this._handleVouchLoaded),(e=this.host.mediaPlayer)==null||e.removeEventListener("play",this._handlePlay),(t=this.host.mediaPlayer)==null||t.removeEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.removeEventListener("video:pause",this._handleVideoPause),(r=this.host.mediaPlayer)==null||r.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}var Lo={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Pr<"u"&&Pr,i=function(){function n(){this.fetch=!1,this.DOMException=t.DOMException}return n.prototype=t,new n}();(function(n){(function(o){var a=typeof n<"u"&&n||typeof self<"u"&&self||typeof a<"u"&&a,A={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function l(R){return R&&DataView.prototype.isPrototypeOf(R)}if(A.arrayBuffer)var c=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(R){return R&&c.indexOf(Object.prototype.toString.call(R))>-1};function h(R){if(typeof R!="string"&&(R=String(R)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(R)||R==="")throw new TypeError('Invalid character in header field name: "'+R+'"');return R.toLowerCase()}function d(R){return typeof R!="string"&&(R=String(R)),R}function g(R){var x={next:function(){var G=R.shift();return{done:G===void 0,value:G}}};return A.iterable&&(x[Symbol.iterator]=function(){return x}),x}function f(R){this.map={},R instanceof f?R.forEach(function(x,G){this.append(G,x)},this):Array.isArray(R)?R.forEach(function(x){this.append(x[0],x[1])},this):R&&Object.getOwnPropertyNames(R).forEach(function(x){this.append(x,R[x])},this)}f.prototype.append=function(R,x){R=h(R),x=d(x);var G=this.map[R];this.map[R]=G?G+", "+x:x},f.prototype.delete=function(R){delete this.map[h(R)]},f.prototype.get=function(R){return R=h(R),this.has(R)?this.map[R]:null},f.prototype.has=function(R){return this.map.hasOwnProperty(h(R))},f.prototype.set=function(R,x){this.map[h(R)]=d(x)},f.prototype.forEach=function(R,x){for(var G in this.map)this.map.hasOwnProperty(G)&&R.call(x,this.map[G],G,this)},f.prototype.keys=function(){var R=[];return this.forEach(function(x,G){R.push(G)}),g(R)},f.prototype.values=function(){var R=[];return this.forEach(function(x){R.push(x)}),g(R)},f.prototype.entries=function(){var R=[];return this.forEach(function(x,G){R.push([G,x])}),g(R)},A.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function p(R){if(R.bodyUsed)return Promise.reject(new TypeError("Already read"));R.bodyUsed=!0}function v(R){return new Promise(function(x,G){R.onload=function(){x(R.result)},R.onerror=function(){G(R.error)}})}function y(R){var x=new FileReader,G=v(x);return x.readAsArrayBuffer(R),G}function b(R){var x=new FileReader,G=v(x);return x.readAsText(R),G}function C(R){for(var x=new Uint8Array(R),G=new Array(x.length),S=0;S<x.length;S++)G[S]=String.fromCharCode(x[S]);return G.join("")}function Q(R){if(R.slice)return R.slice(0);var x=new Uint8Array(R.byteLength);return x.set(new Uint8Array(R)),x.buffer}function B(){return this.bodyUsed=!1,this._initBody=function(R){this.bodyUsed=this.bodyUsed,this._bodyInit=R,R?typeof R=="string"?this._bodyText=R:A.blob&&Blob.prototype.isPrototypeOf(R)?this._bodyBlob=R:A.formData&&FormData.prototype.isPrototypeOf(R)?this._bodyFormData=R:A.searchParams&&URLSearchParams.prototype.isPrototypeOf(R)?this._bodyText=R.toString():A.arrayBuffer&&A.blob&&l(R)?(this._bodyArrayBuffer=Q(R.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(R)||u(R))?this._bodyArrayBuffer=Q(R):this._bodyText=R=Object.prototype.toString.call(R):this._bodyText="",this.headers.get("content-type")||(typeof R=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):A.searchParams&&URLSearchParams.prototype.isPrototypeOf(R)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},A.blob&&(this.blob=function(){var R=p(this);if(R)return R;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var R=p(this);return R||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(y)}),this.text=function(){var R=p(this);if(R)return R;if(this._bodyBlob)return b(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(C(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},A.formData&&(this.formData=function(){return this.text().then(k)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function _(R){var x=R.toUpperCase();return L.indexOf(x)>-1?x:R}function $(R,x){if(!(this instanceof $))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');x=x||{};var G=x.body;if(R instanceof $){if(R.bodyUsed)throw new TypeError("Already read");this.url=R.url,this.credentials=R.credentials,x.headers||(this.headers=new f(R.headers)),this.method=R.method,this.mode=R.mode,this.signal=R.signal,!G&&R._bodyInit!=null&&(G=R._bodyInit,R.bodyUsed=!0)}else this.url=String(R);if(this.credentials=x.credentials||this.credentials||"same-origin",(x.headers||!this.headers)&&(this.headers=new f(x.headers)),this.method=_(x.method||this.method||"GET"),this.mode=x.mode||this.mode||null,this.signal=x.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&G)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(G),(this.method==="GET"||this.method==="HEAD")&&(x.cache==="no-store"||x.cache==="no-cache")){var S=/([?&])_=[^&]*/;if(S.test(this.url))this.url=this.url.replace(S,"$1_="+new Date().getTime());else{var w=/\?/;this.url+=(w.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}$.prototype.clone=function(){return new $(this,{body:this._bodyInit})};function k(R){var x=new FormData;return R.trim().split("&").forEach(function(G){if(G){var S=G.split("="),w=S.shift().replace(/\+/g," "),T=S.join("=").replace(/\+/g," ");x.append(decodeURIComponent(w),decodeURIComponent(T))}}),x}function M(R){var x=new f,G=R.replace(/\r?\n[\t ]+/g," ");return G.split("\r").map(function(S){return S.indexOf(`
|
|
153
|
-
`)===0?S.substr(1,S.length):S}).forEach(function(S){var w=S.split(":"),T=w.shift().trim();if(T){var Y=w.join(":").trim();x.append(T,Y)}}),x}B.call($.prototype);function j(R,x){if(!(this instanceof j))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');x||(x={}),this.type="default",this.status=x.status===void 0?200:x.status,this.ok=this.status>=200&&this.status<300,this.statusText=x.statusText===void 0?"":""+x.statusText,this.headers=new f(x.headers),this.url=x.url||"",this._initBody(R)}B.call(j.prototype),j.prototype.clone=function(){return new j(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},j.error=function(){var R=new j(null,{status:0,statusText:""});return R.type="error",R};var V=[301,302,303,307,308];j.redirect=function(R,x){if(V.indexOf(x)===-1)throw new RangeError("Invalid status code");return new j(null,{status:x,headers:{location:R}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(x,G){this.message=x,this.name=G;var S=Error(x);this.stack=S.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function z(R,x){return new Promise(function(G,S){var w=new $(R,x);if(w.signal&&w.signal.aborted)return S(new o.DOMException("Aborted","AbortError"));var T=new XMLHttpRequest;function Y(){T.abort()}T.onload=function(){var q={status:T.status,statusText:T.statusText,headers:M(T.getAllResponseHeaders()||"")};q.url="responseURL"in T?T.responseURL:q.headers.get("X-Request-URL");var se="response"in T?T.response:T.responseText;setTimeout(function(){G(new j(se,q))},0)},T.onerror=function(){setTimeout(function(){S(new TypeError("Network request failed"))},0)},T.ontimeout=function(){setTimeout(function(){S(new TypeError("Network request failed"))},0)},T.onabort=function(){setTimeout(function(){S(new o.DOMException("Aborted","AbortError"))},0)};function U(q){try{return q===""&&a.location.href?a.location.href:q}catch{return q}}T.open(w.method,U(w.url),!0),w.credentials==="include"?T.withCredentials=!0:w.credentials==="omit"&&(T.withCredentials=!1),"responseType"in T&&(A.blob?T.responseType="blob":A.arrayBuffer&&w.headers.get("Content-Type")&&w.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(T.responseType="arraybuffer")),x&&typeof x.headers=="object"&&!(x.headers instanceof f)?Object.getOwnPropertyNames(x.headers).forEach(function(q){T.setRequestHeader(q,d(x.headers[q]))}):w.headers.forEach(function(q,se){T.setRequestHeader(se,q)}),w.signal&&(w.signal.addEventListener("abort",Y),T.onreadystatechange=function(){T.readyState===4&&w.signal.removeEventListener("abort",Y)}),T.send(typeof w._bodyInit>"u"?null:w._bodyInit)})}return z.polyfill=!0,a.fetch||(a.fetch=z,a.Headers=f,a.Request=$,a.Response=j),o.Headers=f,o.Request=$,o.Response=j,o.fetch=z,o})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var r=t.fetch?t:i;e=r.fetch,e.default=r.fetch,e.fetch=r.fetch,e.Headers=r.Headers,e.Request=r.Request,e.Response=r.Response,s.exports=e})(Lo,Lo.exports);var Bf=Lo.exports;const Nl=fl(Bf);async function Qf(s){var e;try{if((e=await Nl(s,{method:"HEAD"}))!=null&&e.ok)return s}catch{return}}async function _o({sources:s}){let e=null;const t=s==null?void 0:s.filter(Boolean),i=t==null?void 0:t.find(n=>n.startsWith("blob:")),r=t==null?void 0:t.find(n=>!n.startsWith("http")&&!n.startsWith("blob:"));if(i||r)return i??r;if(t.length>0){const n=t.map(o=>Qf(o));e=(await Promise.all(n)).find(Boolean)}return e}async function bf(s){try{return(await Nl(s)).text()}catch{return null}}async function Sf(s){return s=s.trim(),s.startsWith("http")||s.startsWith("blob:")?bf(s):s}const wf=Yt(async({original:s,translation:e,originalLanguage:t="",translationLanguage:i=""},{language:r})=>{var n,o;const a={[(n=i==null?void 0:i.split("-"))==null?void 0:n[0]]:e,[(o=t==null?void 0:t.split("-"))==null?void 0:o[0]]:s},A=(r&&a[r])??s;return A?Sf(A):null},{cacheKey:([s,{language:e}])=>JSON.stringify({...s,language:e})}),Rf=Yt(async s=>{var e,t,i,r,n,o,a,A,l,c,u;const[h,d,g]=await Promise.all([_o({sources:[(t=(e=s==null?void 0:s.answer)==null?void 0:e.media)==null?void 0:t.video,(r=(i=s==null?void 0:s.answer)==null?void 0:i.media)==null?void 0:r.input]}),_o({sources:[(o=(n=s==null?void 0:s.answer)==null?void 0:n.media)==null?void 0:o.playlist]}),_o({sources:[((A=(a=s==null?void 0:s.answer)==null?void 0:a.media)==null?void 0:A.reducedQuality)??((u=(c=(l=s==null?void 0:s.answer)==null?void 0:l.media)==null?void 0:c.videos)==null?void 0:u.xs)]})]);return{src:h,playlist:d,preview:g}},{cacheKey:([s])=>{var e,t,i,r,n,o,a,A,l,c,u;return JSON.stringify({video:(t=(e=s==null?void 0:s.answer)==null?void 0:e.media)==null?void 0:t.video,input:(r=(i=s==null?void 0:s.answer)==null?void 0:i.media)==null?void 0:r.input,playlist:(o=(n=s==null?void 0:s.answer)==null?void 0:n.media)==null?void 0:o.playlist,preview:((A=(a=s==null?void 0:s.answer)==null?void 0:a.media)==null?void 0:A.reducedQuality)??((u=(c=(l=s==null?void 0:s.answer)==null?void 0:l.media)==null?void 0:c.videos)==null?void 0:u.xs)})}});function Ml(s){var e,t,i,r,n,o,a,A,l,c,u,h;const d=((t=(e=s==null?void 0:s.answer)==null?void 0:e.contact)==null?void 0:t.name)==="Anonymous"?"":((n=(r=(i=s==null?void 0:s.answer)==null?void 0:i.contact)==null?void 0:r.name)==null?void 0:n.trim())??"",g=((A=(a=(o=s==null?void 0:s.answer)==null?void 0:o.contact)==null?void 0:a.client)==null?void 0:A.name)==="Not Supplied"?"":((h=(u=(c=(l=s==null?void 0:s.answer)==null?void 0:l.contact)==null?void 0:c.client)==null?void 0:u.name)==null?void 0:h.trim())??"",[f,p]=d.split(" ");return{name:d,firstName:f,lastName:p,companyName:g}}const xf=Yt(async(s,e,t)=>{var i,r,n;const o=(i=e==null?void 0:e.answer)==null?void 0:i.id;return((n=(r=s==null?void 0:s.questions)==null?void 0:r.items)==null?void 0:n.reduce((A,l)=>{var c;return((c=l==null?void 0:l.answer)==null?void 0:c.id)===o?(A??0)+1:A},0))<=1?o:`${o}-${t}`},{cacheKey:([s,e,t])=>{var i;return JSON.stringify({index:t,rootData:e,allQuestions:(i=s==null?void 0:s.questions)==null?void 0:i.items})}});async function ko({data:s,rootData:e,index:t},i){var r,n,o,a,A,l,c,u,h,d,g,f,p,v,y,b,C,Q,B,L,_,$,k
|
|
152
|
+
}`}],root:"{{ it.outro?.questions?.items }}"}],system:!0}],meta:{frameRate:30,resolution:1080,transitionDuration:1/3},options:{videoFormat:"letterbox-video"},default:0,system:!0};async function hf(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>Xh);return new s.Image}return new Image}const kl=Yt(async function(e){return e?new Promise((t,i)=>{hf().then(r=>{r.onload=()=>{t(r)},r.onerror=n=>{i(n)},r.src=e})}):null});async function To({element:s,meta:e},t,i){var r,n,o;let a={...s};const{node:A}=s;if((A==null?void 0:A.type)==="video"&&((r=A==null?void 0:A.value)!=null&&r.src||(n=A==null?void 0:A.value)!=null&&n.playlist)){const l=await t(A.value,e);let c;try{c=await kl(A.value.poster)}catch{c=null}a={...a,node:{...A,video:l,poster:c,meta:await i(A.value,l.node,e)}}}if((A==null?void 0:A.type)==="image"&&A.value){let l;try{l=await kl(A.value)}catch{l=null}a={...a,node:{...A,image:l}}}return a.node&&((o=s.node)!=null&&o.elements)&&(a.node.elements=await Promise.all(s.node.elements.map(l=>To({element:l,meta:e},t,i)))),s.elements&&(a.elements=await Promise.all(s.elements.map(l=>To({element:l,meta:e},t,i)))),a}async function Zr(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>Xh),e=new s.Canvas;return e.gpu=!1,e}return document.createElement("canvas")}function tr(s=[]){var e;for(const t of s){if(((e=t==null?void 0:t.node)==null?void 0:e.type)==="video")return t.node;const i=tr(t==null?void 0:t.elements);if(i)return i}}function df(s,e){return s.reduce((t,i,r)=>[...t,i.map((n,o)=>n.map(({duration:a},A)=>r===s.length-1&&o===i.length-1&&A===n.length-1?a:a-e))],[])}function gf(s){if(s===null||typeof s!="object")return!1;if(Object.getPrototypeOf(s)===null)return!0;let e=s;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(s)===e}function ff(s){return s.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\f/g,"\\f").replace(/"/g,'\\"')}function en(s){return s.flatMap(e=>Array.isArray(e)?e.flatMap(t=>t):e).reduce((e,t)=>e+t,0)}const pf=Yt(()=>pl.loadYoga());Co.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${ff(s)}"`:gf(s)||Array.isArray(s)?JSON.stringify(s):s);const us=(s,e,t)=>Co.render(s,e,Co.getConfig({autoEscape:!1,defaultFilter:"parse",...t}));async function hs({data:s,template:e,burnCaptions:t=!1,debug:i=!1},r,n,o){var a,A,l,c;const u=await pf(),h=e??uf;if(!((a=h.templates)!=null&&a.length))throw new Error(`No templates found for template instance: ${h.id}`);let d=h.templates.find(({version:k})=>k===Do);if(!d){const k=h.templates.map(({version:M})=>`"${M}"`).join(", ");console.warn(`Template renderer expects template version "${Do}" but got ${k}`),d=h.templates[h.templates.length-1]}const g=await Promise.all(d.content.map(async({scenes:k,root:M})=>{const j={...h.options,...s,intro:h.intro,outro:h.outro};async function V(z,R){return Promise.all(k.map(async({layout:x,duration:G,data:S,derived:w,options:T})=>{var Y,U,q;const se={...j,_index:R,_root:z,_derived:await r({data:s,rootData:z,index:R})},ce=S?JSON.parse(await us(S,se)):{},ne=w?JSON.parse(await us(w,se)):{},me=T?JSON.parse(await us(T,se)):{},Se=G?parseFloat(await us(G,se)):NaN,Re=(Y=d.layouts.find(ge=>ge.name===x))==null?void 0:Y.tree;if(!Re)throw new Error(`Layout tree "${x}" not found in template "${d.id}" layouts.`);const oe=JSON.parse(await us(Re,{...ce,...ne,...me})),de=await Promise.all(oe.flatMap(ge=>To({element:ge,meta:h.meta},n,o))),Qe=tr(de);return{duration:(isNaN(Se)?null:Se)??((U=Qe==null?void 0:Qe.meta)==null?void 0:U.duration)??0,captions:(q=Qe==null?void 0:Qe.meta)==null?void 0:q.captions,elements:de}}))}if(M){const z=JSON.parse(await us(M,j));return Array.isArray(z)?Promise.all(z.map(async(R,x)=>V(R,x))):Promise.all([V(z,null)])}return Promise.all([V(s,null)])}));if(g.every(k=>k.every(M=>M.every(j=>{const V=tr(j.elements);return!(V!=null&&V.value.src)&&!(V!=null&&V.value.playlist)})))){const k=g.flatMap(M=>M.flatMap(j=>j.map(V=>{const z=tr(V.elements);return!(z!=null&&z.value.src)&&!(z!=null&&z.value.playlist)&&(z==null?void 0:z.value.id)}).filter(Boolean))).join(", ");throw new Error(`Video(s) with ID ${k} failed to load, video can not be processed`)}if(g.every(k=>k.every(M=>M.every(j=>j.duration<=0))))throw new Error("No scenes have any duration, video can not be processed");const v=g.reduce((k,M)=>{const j=M.reduce((V,z)=>{const R=z.filter(x=>x.duration>0);return R.length>0?[...V,R]:V},[]);return j.length>0?[...k,j]:k},[]),y=((A=h.meta)==null?void 0:A.frameRate)??30,b=((l=h.meta)==null?void 0:l.resolution)??1080,C=((c=h.meta)==null?void 0:c.transitionDuration)??1/3,Q=df(v,C),B=en(Q),L=await Promise.all(v.map((k,M)=>{const j=en(Q[M]),V=en(Q.slice(0,M));return Promise.all(k.map((z,R)=>Promise.all(z.map(async({duration:x,captions:G,elements:S},w)=>{var T,Y;const U=await Zr(),q=await Zr(),se=await Zr(),ce=await Zr(),ne=tr(S),me=en([...Q.slice(0,M),...Q[M].slice(0,R),...Q[M][R].slice(0,w)]);return{draw:({canvas:Re,currentTime:oe})=>{const de=Math.max(0,oe-V),Qe=Math.max(0,oe-me);xo({yoga:u,debug:i,canvas:Re,cropCanvas:U,posterCanvas:ce,letterboxCanvas:q,elements:S,currentTime:oe,contentTime:de,sceneTime:Qe,totalDuration:B,contentDuration:j,sceneDuration:x}),G&&t&&of({canvas:Re,dx:0,dy:0,dw:Re.width,dh:Re.height,vttCaptions:G,sceneTime:Qe+((ne==null?void 0:ne.meta.start)??0)})},duration:x,transitionCanvas:se,id:cf(),start:me,video:ne==null?void 0:ne.video,videoMeta:ne==null?void 0:ne.meta,audio:{duration:x,src:(T=ne==null?void 0:ne.value)==null?void 0:T.src,start:(Y=ne==null?void 0:ne.meta)==null?void 0:Y.start}}}))))})),_=L.flatMap(k=>k);return{scenes:_.flatMap(k=>k),sections:_,contents:L,frameRate:y,resolution:b,transitionDuration:C,fonts:d.fonts??[],duration:B}}const Do="3",Ef={name:"@vouchfor/embeds",version:"3.2.1",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds.js",module:"dist/es/embeds.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds.js"},files:["dist","src"],publishConfig:{tag:"latest",access:"public"},engines:{node:">=18.18.0"},scripts:{build:"rm -rf dist && tsc && yarn build:self","build:deps":"yarn --cwd ../media-player build","build:self":"vite build --mode iife && vite build --mode es && node scripts/build.cjs","build:package":"yarn build","build:storybook":"yarn prebuild && storybook build","generate:manifest":"wca src --outFile custom-elements.json",lint:"eslint . --quiet","lint:fix":"eslint . --fix","lint:staged":"lint-staged",prepublishOnly:"yarn build",size:"size-limit",storybook:"yarn prebuild && storybook dev -p 6007",prebuild:"yarn build:deps && yarn generate:manifest",test:"rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner","test:ci":"yarn test --config web-test-runner.ci.config.js","test:watch":"yarn test --watch"},"lint-staged":{"**/*.{ts,tsx,js}":"eslint --fix --quiet","**/*.{md,json,yml}":"prettier --write"},dependencies:{"@a11y/focus-trap":"^1.0.5","@lit/task":"^1.0.0","@vouchfor/canvas-video":"^8.2.2","@vouchfor/media-player":"^4.2.1",uuid:"^9.0.1"},peerDependencies:{lit:"^3.1.2"},devDependencies:{"@esm-bundle/chai":"^4.3.4-fix.0","@open-wc/testing":"^4.0.0","@storybook/addon-essentials":"^8.0.4","@storybook/addon-links":"^8.0.4","@storybook/blocks":"^8.0.4","@storybook/web-components":"^8.0.4","@storybook/web-components-vite":"^8.0.4","@svgr/core":"^8.1.0","@types/flat":"^5.0.5","@types/mocha":"^10.0.6","@vouchfor/eslint-config":"^1.0.1","@vouchfor/prettier-config":"^1.0.1","@vouchfor/video-utils":"^1.4.1","@web/dev-server-esbuild":"^1.0.2","@web/test-runner":"^0.18.1","@web/test-runner-browserstack":"^0.7.1","@web/test-runner-mocha":"^0.9.0","@web/test-runner-playwright":"^0.11.0",glob:"^10.3.10","lint-staged":"^15.2.2",lit:"^3.1.2",lodash:"^4.17.21",react:"^18.2.0","react-dom":"^18.2.0","rollup-plugin-tla":"^0.0.2",sinon:"^17.0.1",storybook:"^8.0.4",svgson:"^5.3.1",typescript:"^5.4.3",vite:"^5.2.2","vite-plugin-commonjs":"^0.10.1","vite-plugin-dts":"^3.7.3","web-component-analyzer":"^2.0.0"}};function If(s){const{publicApiUrl:e}=Lr(s),t=Li();return navigator.sendBeacon(`${e}/api/visitor`,JSON.stringify({visitorId:t})),t}function mf(s){var n,o,a,A,l,c,u,h,d,g,f,p;if(typeof window>"u")return{client:null,tab:null,request:Li()};let e=(o=(n=window.localStorage)==null?void 0:n.getItem)==null?void 0:o.call(n,"vouch-uid-visitor"),t=(A=(a=window.localStorage)==null?void 0:a.getItem)==null?void 0:A.call(a,"vouch-uid-client"),i=(c=(l=window.sessionStorage)==null?void 0:l.getItem)==null?void 0:c.call(l,"vouch-uid-tab");const r=Li();return e||(e=If(s),(h=(u=window.localStorage)==null?void 0:u.setItem)==null||h.call(u,"vouch-uid-visitor",e)),t||(t=Li(),(g=(d=window.localStorage)==null?void 0:d.setItem)==null||g.call(d,"vouch-uid-client",t)),i||(i=Li(),(p=(f=window.sessionStorage)==null?void 0:f.setItem)==null||p.call(f,"vouch-uid-tab",i)),{client:t,tab:i,request:r,visitor:e}}function Cf(s,e){return s&&"vouchId"in s?s.vouchId:(e==null?void 0:e.id)??null}function vf(s="embedded_player"){var r,n;const[e,t]=((n=(r=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:r.split)==null?void 0:n.call(r,"/"))??[],i={};return[...new URLSearchParams(location.search).entries()].forEach(([o,a])=>{if(/utm/.test(o)){const A=o.toLowerCase().replace(/[-_][a-z0-9]/g,l=>l.slice(-1).toUpperCase());i[A]=a}}),{source:s,time:new Date,region:t,country:e,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,embedType:"media-player-embed",embedVersion:Ef.version,templateVersion:Do,...i}}const Fl=1;class yf{constructor(e){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(t,i)=>{const r=Cf(i,this.host.vouch);!r||this.host.disableTracking||this._batchedEvents.push({event:t,payload:{...i,vouchId:r,time:new Date().toISOString()}})},this._sendTrackingEvent=()=>{if(this._batchedEvents.length<=0)return;const{publicApiUrl:t}=Lr(this.host.env),{client:i,tab:r,request:n,visitor:o}=mf(this.host.env);navigator.sendBeacon(`${t}/api/batchevents`,JSON.stringify({payload:{events:this._batchedEvents},context:{"x-uid-client":i,"x-uid-tab":r,"x-uid-request":n,"x-uid-visitor":o,"x-reporting-metadata":vf(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:t,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+Fl&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:t,streamStart:this._streamStartTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamStartTime[i],delete this._streamLatestTime[i]}},this._handleVouchLoaded=({detail:t})=>{t&&(this._hasLoaded[t]||(this._createTrackingEvent("VOUCH_LOADED",{vouchId:t}),this._hasLoaded[t]=!0))},this._handlePlay=()=>{this._hasPlayed||(this._createTrackingEvent("VIDEO_PLAYED",{streamStart:this.host.currentTime}),this._hasPlayed=!0)},this._handleVideoPlay=({detail:{id:t,key:i}})=>{this._answersViewed[i]||(this._createTrackingEvent("VOUCH_RESPONSE_VIEWED",{answerId:t}),this._answersViewed[i]=!0)},this._handleVideoTimeUpdate=({detail:{id:t,key:i,node:r}})=>{var n,o;!this.host.paused&&t===((o=(n=this.host.scene)==null?void 0:n.video)==null?void 0:o.id)&&(this._currentlyPlayingVideo={id:t,key:i,node:r},this._streamLatestTime[i]=r.currentTime,this._streamStartTime[i]||(this._streamStartTime[i]=r.currentTime,this._streamLatestTime[i]=r.currentTime))},this._handleVideoPause=({detail:{id:t,key:i}})=>{this._streamLatestTime[i]>this._streamStartTime[i]+Fl&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:t,streamStart:this._streamStartTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamStartTime[i],delete this._streamLatestTime[i]},this._pageUnloading=()=>{this._streamEnded(),this._sendTrackingEvent()},this._handleVisibilityChange=()=>{document.visibilityState==="hidden"&&this._pageUnloading()},this._handlePageHide=()=>{this._pageUnloading()},this.host=e,e.addController(this)}hostConnected(){requestAnimationFrame(()=>{var e,t,i,r;"onvisibilitychange"in document?document.addEventListener("visibilitychange",this._handleVisibilityChange):window.addEventListener("pagehide",this._handlePageHide),this.host.addEventListener("vouch:loaded",this._handleVouchLoaded),(e=this.host.mediaPlayer)==null||e.addEventListener("play",this._handlePlay),(t=this.host.mediaPlayer)==null||t.addEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.addEventListener("video:pause",this._handleVideoPause),(r=this.host.mediaPlayer)==null||r.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var e,t,i,r;this._pageUnloading(),"onvisibilitychange"in document?document.removeEventListener("visibilitychange",this._handleVisibilityChange):window.removeEventListener("pagehide",this._handlePageHide),this.host.removeEventListener("vouch:loaded",this._handleVouchLoaded),(e=this.host.mediaPlayer)==null||e.removeEventListener("play",this._handlePlay),(t=this.host.mediaPlayer)==null||t.removeEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.removeEventListener("video:pause",this._handleVideoPause),(r=this.host.mediaPlayer)==null||r.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}var Lo={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Pr<"u"&&Pr,i=function(){function n(){this.fetch=!1,this.DOMException=t.DOMException}return n.prototype=t,new n}();(function(n){(function(o){var a=typeof n<"u"&&n||typeof self<"u"&&self||typeof a<"u"&&a,A={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function l(R){return R&&DataView.prototype.isPrototypeOf(R)}if(A.arrayBuffer)var c=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(R){return R&&c.indexOf(Object.prototype.toString.call(R))>-1};function h(R){if(typeof R!="string"&&(R=String(R)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(R)||R==="")throw new TypeError('Invalid character in header field name: "'+R+'"');return R.toLowerCase()}function d(R){return typeof R!="string"&&(R=String(R)),R}function g(R){var x={next:function(){var G=R.shift();return{done:G===void 0,value:G}}};return A.iterable&&(x[Symbol.iterator]=function(){return x}),x}function f(R){this.map={},R instanceof f?R.forEach(function(x,G){this.append(G,x)},this):Array.isArray(R)?R.forEach(function(x){this.append(x[0],x[1])},this):R&&Object.getOwnPropertyNames(R).forEach(function(x){this.append(x,R[x])},this)}f.prototype.append=function(R,x){R=h(R),x=d(x);var G=this.map[R];this.map[R]=G?G+", "+x:x},f.prototype.delete=function(R){delete this.map[h(R)]},f.prototype.get=function(R){return R=h(R),this.has(R)?this.map[R]:null},f.prototype.has=function(R){return this.map.hasOwnProperty(h(R))},f.prototype.set=function(R,x){this.map[h(R)]=d(x)},f.prototype.forEach=function(R,x){for(var G in this.map)this.map.hasOwnProperty(G)&&R.call(x,this.map[G],G,this)},f.prototype.keys=function(){var R=[];return this.forEach(function(x,G){R.push(G)}),g(R)},f.prototype.values=function(){var R=[];return this.forEach(function(x){R.push(x)}),g(R)},f.prototype.entries=function(){var R=[];return this.forEach(function(x,G){R.push([G,x])}),g(R)},A.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function p(R){if(R.bodyUsed)return Promise.reject(new TypeError("Already read"));R.bodyUsed=!0}function v(R){return new Promise(function(x,G){R.onload=function(){x(R.result)},R.onerror=function(){G(R.error)}})}function y(R){var x=new FileReader,G=v(x);return x.readAsArrayBuffer(R),G}function b(R){var x=new FileReader,G=v(x);return x.readAsText(R),G}function C(R){for(var x=new Uint8Array(R),G=new Array(x.length),S=0;S<x.length;S++)G[S]=String.fromCharCode(x[S]);return G.join("")}function Q(R){if(R.slice)return R.slice(0);var x=new Uint8Array(R.byteLength);return x.set(new Uint8Array(R)),x.buffer}function B(){return this.bodyUsed=!1,this._initBody=function(R){this.bodyUsed=this.bodyUsed,this._bodyInit=R,R?typeof R=="string"?this._bodyText=R:A.blob&&Blob.prototype.isPrototypeOf(R)?this._bodyBlob=R:A.formData&&FormData.prototype.isPrototypeOf(R)?this._bodyFormData=R:A.searchParams&&URLSearchParams.prototype.isPrototypeOf(R)?this._bodyText=R.toString():A.arrayBuffer&&A.blob&&l(R)?(this._bodyArrayBuffer=Q(R.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(R)||u(R))?this._bodyArrayBuffer=Q(R):this._bodyText=R=Object.prototype.toString.call(R):this._bodyText="",this.headers.get("content-type")||(typeof R=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):A.searchParams&&URLSearchParams.prototype.isPrototypeOf(R)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},A.blob&&(this.blob=function(){var R=p(this);if(R)return R;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var R=p(this);return R||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(y)}),this.text=function(){var R=p(this);if(R)return R;if(this._bodyBlob)return b(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(C(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},A.formData&&(this.formData=function(){return this.text().then(k)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function _(R){var x=R.toUpperCase();return L.indexOf(x)>-1?x:R}function $(R,x){if(!(this instanceof $))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');x=x||{};var G=x.body;if(R instanceof $){if(R.bodyUsed)throw new TypeError("Already read");this.url=R.url,this.credentials=R.credentials,x.headers||(this.headers=new f(R.headers)),this.method=R.method,this.mode=R.mode,this.signal=R.signal,!G&&R._bodyInit!=null&&(G=R._bodyInit,R.bodyUsed=!0)}else this.url=String(R);if(this.credentials=x.credentials||this.credentials||"same-origin",(x.headers||!this.headers)&&(this.headers=new f(x.headers)),this.method=_(x.method||this.method||"GET"),this.mode=x.mode||this.mode||null,this.signal=x.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&G)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(G),(this.method==="GET"||this.method==="HEAD")&&(x.cache==="no-store"||x.cache==="no-cache")){var S=/([?&])_=[^&]*/;if(S.test(this.url))this.url=this.url.replace(S,"$1_="+new Date().getTime());else{var w=/\?/;this.url+=(w.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}$.prototype.clone=function(){return new $(this,{body:this._bodyInit})};function k(R){var x=new FormData;return R.trim().split("&").forEach(function(G){if(G){var S=G.split("="),w=S.shift().replace(/\+/g," "),T=S.join("=").replace(/\+/g," ");x.append(decodeURIComponent(w),decodeURIComponent(T))}}),x}function M(R){var x=new f,G=R.replace(/\r?\n[\t ]+/g," ");return G.split("\r").map(function(S){return S.indexOf(`
|
|
153
|
+
`)===0?S.substr(1,S.length):S}).forEach(function(S){var w=S.split(":"),T=w.shift().trim();if(T){var Y=w.join(":").trim();x.append(T,Y)}}),x}B.call($.prototype);function j(R,x){if(!(this instanceof j))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');x||(x={}),this.type="default",this.status=x.status===void 0?200:x.status,this.ok=this.status>=200&&this.status<300,this.statusText=x.statusText===void 0?"":""+x.statusText,this.headers=new f(x.headers),this.url=x.url||"",this._initBody(R)}B.call(j.prototype),j.prototype.clone=function(){return new j(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},j.error=function(){var R=new j(null,{status:0,statusText:""});return R.type="error",R};var V=[301,302,303,307,308];j.redirect=function(R,x){if(V.indexOf(x)===-1)throw new RangeError("Invalid status code");return new j(null,{status:x,headers:{location:R}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(x,G){this.message=x,this.name=G;var S=Error(x);this.stack=S.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function z(R,x){return new Promise(function(G,S){var w=new $(R,x);if(w.signal&&w.signal.aborted)return S(new o.DOMException("Aborted","AbortError"));var T=new XMLHttpRequest;function Y(){T.abort()}T.onload=function(){var q={status:T.status,statusText:T.statusText,headers:M(T.getAllResponseHeaders()||"")};q.url="responseURL"in T?T.responseURL:q.headers.get("X-Request-URL");var se="response"in T?T.response:T.responseText;setTimeout(function(){G(new j(se,q))},0)},T.onerror=function(){setTimeout(function(){S(new TypeError("Network request failed"))},0)},T.ontimeout=function(){setTimeout(function(){S(new TypeError("Network request failed"))},0)},T.onabort=function(){setTimeout(function(){S(new o.DOMException("Aborted","AbortError"))},0)};function U(q){try{return q===""&&a.location.href?a.location.href:q}catch{return q}}T.open(w.method,U(w.url),!0),w.credentials==="include"?T.withCredentials=!0:w.credentials==="omit"&&(T.withCredentials=!1),"responseType"in T&&(A.blob?T.responseType="blob":A.arrayBuffer&&w.headers.get("Content-Type")&&w.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(T.responseType="arraybuffer")),x&&typeof x.headers=="object"&&!(x.headers instanceof f)?Object.getOwnPropertyNames(x.headers).forEach(function(q){T.setRequestHeader(q,d(x.headers[q]))}):w.headers.forEach(function(q,se){T.setRequestHeader(se,q)}),w.signal&&(w.signal.addEventListener("abort",Y),T.onreadystatechange=function(){T.readyState===4&&w.signal.removeEventListener("abort",Y)}),T.send(typeof w._bodyInit>"u"?null:w._bodyInit)})}return z.polyfill=!0,a.fetch||(a.fetch=z,a.Headers=f,a.Request=$,a.Response=j),o.Headers=f,o.Request=$,o.Response=j,o.fetch=z,o})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var r=t.fetch?t:i;e=r.fetch,e.default=r.fetch,e.fetch=r.fetch,e.Headers=r.Headers,e.Request=r.Request,e.Response=r.Response,s.exports=e})(Lo,Lo.exports);var Bf=Lo.exports;const Nl=fl(Bf);async function Qf(s){var e;try{if((e=await Nl(s,{method:"HEAD"}))!=null&&e.ok)return s}catch{return}}async function _o({sources:s}){let e=null;const t=s==null?void 0:s.filter(Boolean),i=t==null?void 0:t.find(n=>n.startsWith("blob:")),r=t==null?void 0:t.find(n=>!n.startsWith("http")&&!n.startsWith("blob:"));if(i||r)return i??r;if(t.length>0){const n=t.map(o=>Qf(o));e=(await Promise.all(n)).find(Boolean)}return e}async function bf(s){try{return(await Nl(s)).text()}catch{return null}}async function Sf(s){return s=s.trim(),s.startsWith("http")||s.startsWith("blob:")?bf(s):s}const wf=Yt(async({original:s,translation:e,originalLanguage:t="",translationLanguage:i=""},{language:r})=>{var n,o;const a={[(n=i==null?void 0:i.split("-"))==null?void 0:n[0]]:e,[(o=t==null?void 0:t.split("-"))==null?void 0:o[0]]:s},A=(r&&a[r])??s;return A?Sf(A):null},{cacheKey:([s,{language:e}])=>JSON.stringify({...s,language:e})}),Rf=Yt(async s=>{var e,t,i,r,n,o,a,A,l,c,u;const[h,d,g]=await Promise.all([_o({sources:[(t=(e=s==null?void 0:s.answer)==null?void 0:e.media)==null?void 0:t.video,(r=(i=s==null?void 0:s.answer)==null?void 0:i.media)==null?void 0:r.input]}),_o({sources:[(o=(n=s==null?void 0:s.answer)==null?void 0:n.media)==null?void 0:o.playlist]}),_o({sources:[((A=(a=s==null?void 0:s.answer)==null?void 0:a.media)==null?void 0:A.reducedQuality)??((u=(c=(l=s==null?void 0:s.answer)==null?void 0:l.media)==null?void 0:c.videos)==null?void 0:u.xs)]})]);return{src:h,playlist:d,preview:g}},{cacheKey:([s])=>{var e,t,i,r,n,o,a,A,l,c,u;return JSON.stringify({video:(t=(e=s==null?void 0:s.answer)==null?void 0:e.media)==null?void 0:t.video,input:(r=(i=s==null?void 0:s.answer)==null?void 0:i.media)==null?void 0:r.input,playlist:(o=(n=s==null?void 0:s.answer)==null?void 0:n.media)==null?void 0:o.playlist,preview:((A=(a=s==null?void 0:s.answer)==null?void 0:a.media)==null?void 0:A.reducedQuality)??((u=(c=(l=s==null?void 0:s.answer)==null?void 0:l.media)==null?void 0:c.videos)==null?void 0:u.xs)})}});function Ml(s){var e,t,i,r,n,o,a,A,l,c,u,h;const d=((t=(e=s==null?void 0:s.answer)==null?void 0:e.contact)==null?void 0:t.name)==="Anonymous"?"":((n=(r=(i=s==null?void 0:s.answer)==null?void 0:i.contact)==null?void 0:r.name)==null?void 0:n.trim())??"",g=((A=(a=(o=s==null?void 0:s.answer)==null?void 0:o.contact)==null?void 0:a.client)==null?void 0:A.name)==="Not Supplied"?"":((h=(u=(c=(l=s==null?void 0:s.answer)==null?void 0:l.contact)==null?void 0:c.client)==null?void 0:u.name)==null?void 0:h.trim())??"",[f,p]=d.split(" ");return{name:d,firstName:f,lastName:p,companyName:g}}const xf=Yt(async(s,e,t)=>{var i,r,n;const o=(i=e==null?void 0:e.answer)==null?void 0:i.id;return((n=(r=s==null?void 0:s.questions)==null?void 0:r.items)==null?void 0:n.reduce((A,l)=>{var c;return((c=l==null?void 0:l.answer)==null?void 0:c.id)===o?(A??0)+1:A},0))<=1?o:`${o}-${t}`},{cacheKey:([s,e,t])=>{var i;return JSON.stringify({index:t,rootData:e,allQuestions:(i=s==null?void 0:s.questions)==null?void 0:i.items})}});async function ko({data:s,rootData:e,index:t},i){var r,n,o,a,A,l,c,u,h,d,g,f,p,v,y,b,C,Q,B,L,_,$,k;const[M,j,V]=await Promise.all([xf(s,e,t),Rf(e),wf({original:((n=(r=e==null?void 0:e.answer)==null?void 0:r.media)==null?void 0:n.captions)??((a=(o=e==null?void 0:e.answer)==null?void 0:o.captions)==null?void 0:a.current),translation:((l=(A=e==null?void 0:e.answer)==null?void 0:A.media)==null?void 0:l.translation)??((u=(c=e==null?void 0:e.answer)==null?void 0:c.captions)==null?void 0:u.translation),originalLanguage:(d=(h=e==null?void 0:e.answer)==null?void 0:h.transcription)==null?void 0:d.language,translationLanguage:(p=(f=(g=e==null?void 0:e.answer)==null?void 0:g.transcription)==null?void 0:f.translation)==null?void 0:p.language},i)]),z=Ml(e);return{...j,...z,key:M,captions:V,answerLabel:((v=e==null?void 0:e.answer)==null?void 0:v.label)??(e==null?void 0:e.title),prevAnswerLabel:t?((Q=(C=(b=(y=s==null?void 0:s.questions)==null?void 0:y.items)==null?void 0:b[t-1])==null?void 0:C.answer)==null?void 0:Q.label)??((_=(L=(B=s==null?void 0:s.questions)==null?void 0:B.items)==null?void 0:L[t-1])==null?void 0:_.title)??null:null,isFirstInstanceOfName:t?((k=($=s==null?void 0:s.questions)==null?void 0:$.items)==null?void 0:k.findIndex(R=>Ml(R).name===z.name))===t:!0}}const tn={af:"Afrikaans",sq:"Albanian",am:"Amharic",ar:"Arabic",hy:"Armenian",az:"Azerbaijani",eu:"Basque",be:"Belarusian",bn:"Bengali",bs:"Bosnian",bg:"Bulgarian",ca:"Catalan",zh:"Chinese (Simplified)",zh_TW:"Chinese (Traditional)",hr:"Croatian",cs:"Czech",da:"Danish",nl:"Dutch",en:"English",et:"Estonian",fi:"Finnish",fr:"French",fa:"Farsi",tl:"Filipino",ka:"Georgian",de:"German",el:"Greek",gu:"Gujarati",ht:"Haitian Creole",ha:"Hausa",he:"Hebrew",hi:"Hindi",hu:"Hungarian",is:"Icelandic",id:"Indonesian",ga:"Irish",it:"Italian",ja:"Japanese",kn:"Kannada",kk:"Kazakh",ko:"Korean",lv:"Latvian",lt:"Lithuanian",mk:"Macedonian",ms:"Malay",ml:"Malayalam",mt:"Maltese",mr:"Marathi",mn:"Mongolian",no:"Norwegian",ps:"Pashto",pl:"Polish",pt:"Portuguese",pa:"Punjabi",ro:"Romanian",ru:"Russian",sr:"Serbian",si:"Sinhala",sk:"Slovak",sl:"Slovenian",so:"Somali",es:"Spanish",sw:"Swahili",sv:"Swedish",ta:"Tamil",te:"Telugu",th:"Thai",tr:"Turkish",uk:"Ukrainian",ur:"Urdu",uz:"Uzbek",vi:"Vietnamese",cy:"Welsh"};function Tf({data:s}){var e,t;return((t=(e=s==null?void 0:s.questions)==null?void 0:e.items)==null?void 0:t.reduce((i,r)=>{var n,o,a,A,l,c,u;const h=(a=(o=(n=r==null?void 0:r.answer)==null?void 0:n.transcription)==null?void 0:o.language)==null?void 0:a.split("-")[0],d=(u=(c=(l=(A=r==null?void 0:r.answer)==null?void 0:A.transcription)==null?void 0:l.translation)==null?void 0:c.language)==null?void 0:u.split("-")[0];return h&&tn[h]&&!i.find(g=>g.value===h)&&i.push({value:h,label:tn[h]}),d&&tn[d]&&!i.find(g=>g.value===d)&&i.push({value:d,label:tn[d]}),i},[]))??[]}/**
|
|
154
154
|
* @license
|
|
155
155
|
* Copyright 2018 Google LLC
|
|
156
156
|
* SPDX-License-Identifier: BSD-3-Clause
|