@vouchfor/embeds-legacy 4.0.3 → 4.0.4
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-legacy.js
CHANGED
|
@@ -196,7 +196,7 @@ class FetcherController {
|
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
const name = "@vouchfor/embeds-legacy";
|
|
199
|
-
const version = "4.0.
|
|
199
|
+
const version = "4.0.4";
|
|
200
200
|
const license = "MIT";
|
|
201
201
|
const author = "Aaron Williams";
|
|
202
202
|
const main = "dist/es/embeds-legacy.js";
|
|
@@ -239,7 +239,7 @@ const dependencies = {
|
|
|
239
239
|
"@a11y/focus-trap": "^1.0.5",
|
|
240
240
|
"@lit/task": "^1.0.0",
|
|
241
241
|
"@vouchfor/canvas-video-legacy": "^9.0.0",
|
|
242
|
-
"@vouchfor/media-player-legacy": "^5.0.
|
|
242
|
+
"@vouchfor/media-player-legacy": "^5.0.4",
|
|
243
243
|
uuid: "^9.0.1"
|
|
244
244
|
};
|
|
245
245
|
const peerDependencies = {
|
|
@@ -248,11 +248,11 @@ const peerDependencies = {
|
|
|
248
248
|
const devDependencies = {
|
|
249
249
|
"@esm-bundle/chai": "^4.3.4-fix.0",
|
|
250
250
|
"@open-wc/testing": "^4.0.0",
|
|
251
|
-
"@storybook/addon-essentials": "^8.
|
|
252
|
-
"@storybook/addon-links": "^8.
|
|
253
|
-
"@storybook/blocks": "^8.
|
|
254
|
-
"@storybook/web-components": "^8.
|
|
255
|
-
"@storybook/web-components-vite": "^8.
|
|
251
|
+
"@storybook/addon-essentials": "^8.5.8",
|
|
252
|
+
"@storybook/addon-links": "^8.5.8",
|
|
253
|
+
"@storybook/blocks": "^8.5.8",
|
|
254
|
+
"@storybook/web-components": "^8.5.8",
|
|
255
|
+
"@storybook/web-components-vite": "^8.5.8",
|
|
256
256
|
"@svgr/core": "^8.1.0",
|
|
257
257
|
"@types/flat": "^5.0.5",
|
|
258
258
|
"@types/mocha": "^10.0.6",
|
|
@@ -272,7 +272,7 @@ const devDependencies = {
|
|
|
272
272
|
"react-dom": "^18.2.0",
|
|
273
273
|
"rollup-plugin-tla": "^0.0.2",
|
|
274
274
|
sinon: "^17.0.1",
|
|
275
|
-
storybook: "^8.
|
|
275
|
+
storybook: "^8.5.8",
|
|
276
276
|
svgson: "^5.3.1",
|
|
277
277
|
typescript: "^5.4.3",
|
|
278
278
|
vite: "^5.2.2",
|
|
@@ -149,7 +149,7 @@ ${e}`,Bg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Qg=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 Jg(){return new Image}const Bl=Kt(async function(e,t=Jg){return e?new Promise((i,r)=>{t().then(n=>{n.onload=()=>{i(n)},n.onerror=o=>{r(o)},n.src=e})}):null});async function So({element:s,meta:e,imageFactory:t},i,r){var n,o,a;let A={...s};const{node:l}=s;if((l==null?void 0:l.type)==="video"&&((n=l==null?void 0:l.value)!=null&&n.src||(o=l==null?void 0:l.value)!=null&&o.playlist)){const c=await i(l.value,e);let h;try{h=await Bl(l.value.poster,t)}catch{h=null}A={...A,node:{...l,video:c,poster:h,meta:await r(l.value,c.node,e)}}}if((l==null?void 0:l.type)==="image"&&l.value){let c;try{c=await Bl(l.value,t)}catch{c=null}A={...A,node:{...l,image:c}}}return A.node&&((a=s.node)!=null&&a.elements)&&(A.node.elements=await Promise.all(s.node.elements.map(c=>So({element:c,meta:e,imageFactory:t},i,r)))),s.elements&&(A.elements=await Promise.all(s.elements.map(c=>So({element:c,meta:e,imageFactory:t},i,r)))),A}async function Wg(){return document.createElement("canvas")}function zs(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=zs(t==null?void 0:t.elements);if(i)return i}}function qg(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 jg(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 Xg(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 Xr(s){return s.flatMap(e=>Array.isArray(e)?e.flatMap(t=>t):e).reduce((e,t)=>e+t,0)}const zg=Kt(()=>nl.loadYoga());po.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${Xg(s)}"`:jg(s)||Array.isArray(s)?JSON.stringify(s):s);const ls=(s,e,t)=>po.render(s,e,po.getConfig({autoEscape:!1,defaultFilter:"parse",...t}));async function cs({data:s,template:e,burnCaptions:t=!1,debug:i=!1,imageFactory:r,canvasFactory:n=Wg},o,a,A){var l,c,h,u;const d=await zg(),g=e??Vg;if(!((l=g.templates)!=null&&l.length))throw new Error(`No templates found for template instance: ${g.id}`);let f=g.templates.find(({version:q})=>q===wo);if(!f){const q=g.templates.map(({version:Y})=>`"${Y}"`).join(", ");console.warn(`Template renderer expects template version "${wo}" but got ${q}`),f=g.templates[g.templates.length-1]}const p=await Promise.all(f.content.map(async({scenes:q,root:Y})=>{const z={...g.options,...s,intro:g.intro,outro:g.outro};async function S(x,U){return Promise.all(q.map(async({layout:b,duration:R,data:T,derived:V,options:P})=>{var j,se,ce;const Ae={...z,_index:U,_root:x,_derived:await o({data:s,rootData:x,index:U})},ye=T?JSON.parse(await ls(T,Ae)):{},Ee=V?JSON.parse(await ls(V,Ae)):{},Re=P?JSON.parse(await ls(P,Ae)):{},ne=R?parseFloat(await ls(R,Ae)):NaN,ue=(j=f.layouts.find(Be=>Be.name===b))==null?void 0:j.tree;if(!ue)throw new Error(`Layout tree "${b}" not found in template "${f.id}" layouts.`);const Se=JSON.parse(await ls(ue,{...ye,...Ee,...Re})),Ce=await Promise.all(Se.flatMap(Be=>So({element:Be,meta:g.meta,imageFactory:r},a,A))),he=zs(Ce);return{duration:(isNaN(ne)?null:ne)??((se=he==null?void 0:he.meta)==null?void 0:se.duration)??0,captions:(ce=he==null?void 0:he.meta)==null?void 0:ce.captions,elements:Ce}}))}if(Y){const x=JSON.parse(await ls(Y,z));return Array.isArray(x)?Promise.all(x.map(async(U,b)=>S(U,b))):Promise.all([S(x,null)])}return Promise.all([S(s,null)])}));if(p.every(q=>q.every(Y=>Y.every(z=>{const S=zs(z.elements);return!(S!=null&&S.value.src)&&!(S!=null&&S.value.playlist)})))){const q=p.flatMap(Y=>Y.flatMap(z=>z.map(S=>{const x=zs(S.elements);return!(x!=null&&x.value.src)&&!(x!=null&&x.value.playlist)&&(x==null?void 0:x.value.id)}).filter(Boolean))).join(", ");throw new Error(`Video(s) with ID ${q} failed to load, video can not be processed`)}if(p.every(q=>q.every(Y=>Y.every(z=>z.duration<=0))))throw new Error("No scenes have any duration, video can not be processed");const Q=p.reduce((q,Y)=>{const z=Y.reduce((S,x)=>{const U=x.filter(b=>b.duration>0);return U.length>0?[...S,U]:S},[]);return z.length>0?[...q,z]:q},[]),C=((c=g.meta)==null?void 0:c.frameRate)??30,w=((h=g.meta)==null?void 0:h.resolution)??1080,B=((u=g.meta)==null?void 0:u.transitionDuration)??1/3,L=qg(Q,B),_=Xr(L),$=await Promise.all(Q.map((q,Y)=>{const z=Xr(L[Y]),S=Xr(L.slice(0,Y));return Promise.all(q.map((x,U)=>Promise.all(x.map(async({duration:b,captions:R,elements:T},V)=>{var P,j;const se=await n(),ce=await n(),Ae=await n(),ye=await n(),Ee=zs(T),Re=Xr([...L.slice(0,Y),...L[Y].slice(0,U),...L[Y][U].slice(0,V)]);return{draw:async({canvas:ue,currentTime:Se})=>{const Ce=Math.max(0,Se-S),he=Math.max(0,Se-Re);await bo({yoga:d,debug:i,canvas:ue,cropCanvas:se,posterCanvas:ye,letterboxCanvas:ce,elements:T,currentTime:Se,contentTime:Ce,sceneTime:he,totalDuration:_,contentDuration:z,sceneDuration:b}),R&&t&&Gg({canvas:ue,dx:0,dy:0,dw:ue.width,dh:ue.height,vttCaptions:R,sceneTime:he+((Ee==null?void 0:Ee.meta.start)??0)})},duration:b,transitionCanvas:Ae,id:Kg(),start:Re,video:Ee==null?void 0:Ee.video,videoMeta:Ee==null?void 0:Ee.meta,audio:{duration:b,src:(P=Ee==null?void 0:Ee.value)==null?void 0:P.src,start:(j=Ee==null?void 0:Ee.meta)==null?void 0:j.start}}}))))})),F=$.flatMap(q=>q);return{scenes:F.flatMap(q=>q),sections:F,contents:$,frameRate:C,resolution:w,transitionDuration:B,fonts:f.fonts??[],duration:_}}const wo="3",Zg={name:"@vouchfor/embeds-legacy",version:"4.0.3",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds-legacy.js",module:"dist/es/embeds-legacy.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds-legacy.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-legacy 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-legacy":"^9.0.0","@vouchfor/media-player-legacy":"^5.0.3",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-legacy":"^2.0.3","@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 ef(s){const{publicApiUrl:e}=Dr(s),t=Ti();return navigator.sendBeacon(`${e}/api/visitor`,JSON.stringify({visitorId:t})),t}function tf(s){var n,o,a,A,l,c,h,u,d,g,f,p;if(typeof window>"u")return{client:null,tab:null,request:Ti()};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=Ti();return e||(e=ef(s),(u=(h=window.localStorage)==null?void 0:h.setItem)==null||u.call(h,"vouch-uid-visitor",e)),t||(t=Ti(),(g=(d=window.localStorage)==null?void 0:d.setItem)==null||g.call(d,"vouch-uid-client",t)),i||(i=Ti(),(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 sf(s,e){return s&&"vouchId"in s?s.vouchId:(e==null?void 0:e.id)??null}function rf(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:Zg.version,templateVersion:wo,...i}}const Ql=1;class nf{constructor(e){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(t,i)=>{const r=sf(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}=Dr(this.host.env),{client:i,tab:r,request:n,visitor:o}=tf(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":rf(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:t,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+Ql&&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]+Ql&&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 Ro={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof go<"u"&&go,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(S){return S&&DataView.prototype.isPrototypeOf(S)}if(A.arrayBuffer)var c=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(S){return S&&c.indexOf(Object.prototype.toString.call(S))>-1};function u(S){if(typeof S!="string"&&(S=String(S)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(S)||S==="")throw new TypeError('Invalid character in header field name: "'+S+'"');return S.toLowerCase()}function d(S){return typeof S!="string"&&(S=String(S)),S}function g(S){var x={next:function(){var U=S.shift();return{done:U===void 0,value:U}}};return A.iterable&&(x[Symbol.iterator]=function(){return x}),x}function f(S){this.map={},S instanceof f?S.forEach(function(x,U){this.append(U,x)},this):Array.isArray(S)?S.forEach(function(x){this.append(x[0],x[1])},this):S&&Object.getOwnPropertyNames(S).forEach(function(x){this.append(x,S[x])},this)}f.prototype.append=function(S,x){S=u(S),x=d(x);var U=this.map[S];this.map[S]=U?U+", "+x:x},f.prototype.delete=function(S){delete this.map[u(S)]},f.prototype.get=function(S){return S=u(S),this.has(S)?this.map[S]:null},f.prototype.has=function(S){return this.map.hasOwnProperty(u(S))},f.prototype.set=function(S,x){this.map[u(S)]=d(x)},f.prototype.forEach=function(S,x){for(var U in this.map)this.map.hasOwnProperty(U)&&S.call(x,this.map[U],U,this)},f.prototype.keys=function(){var S=[];return this.forEach(function(x,U){S.push(U)}),g(S)},f.prototype.values=function(){var S=[];return this.forEach(function(x){S.push(x)}),g(S)},f.prototype.entries=function(){var S=[];return this.forEach(function(x,U){S.push([U,x])}),g(S)},A.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function p(S){if(S.bodyUsed)return Promise.reject(new TypeError("Already read"));S.bodyUsed=!0}function y(S){return new Promise(function(x,U){S.onload=function(){x(S.result)},S.onerror=function(){U(S.error)}})}function v(S){var x=new FileReader,U=y(x);return x.readAsArrayBuffer(S),U}function Q(S){var x=new FileReader,U=y(x);return x.readAsText(S),U}function C(S){for(var x=new Uint8Array(S),U=new Array(x.length),b=0;b<x.length;b++)U[b]=String.fromCharCode(x[b]);return U.join("")}function w(S){if(S.slice)return S.slice(0);var x=new Uint8Array(S.byteLength);return x.set(new Uint8Array(S)),x.buffer}function B(){return this.bodyUsed=!1,this._initBody=function(S){this.bodyUsed=this.bodyUsed,this._bodyInit=S,S?typeof S=="string"?this._bodyText=S:A.blob&&Blob.prototype.isPrototypeOf(S)?this._bodyBlob=S:A.formData&&FormData.prototype.isPrototypeOf(S)?this._bodyFormData=S:A.searchParams&&URLSearchParams.prototype.isPrototypeOf(S)?this._bodyText=S.toString():A.arrayBuffer&&A.blob&&l(S)?(this._bodyArrayBuffer=w(S.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(S)||h(S))?this._bodyArrayBuffer=w(S):this._bodyText=S=Object.prototype.toString.call(S):this._bodyText="",this.headers.get("content-type")||(typeof S=="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(S)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},A.blob&&(this.blob=function(){var S=p(this);if(S)return S;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 S=p(this);return S||(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(v)}),this.text=function(){var S=p(this);if(S)return S;if(this._bodyBlob)return Q(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(F)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function _(S){var x=S.toUpperCase();return L.indexOf(x)>-1?x:S}function $(S,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 U=x.body;if(S instanceof $){if(S.bodyUsed)throw new TypeError("Already read");this.url=S.url,this.credentials=S.credentials,x.headers||(this.headers=new f(S.headers)),this.method=S.method,this.mode=S.mode,this.signal=S.signal,!U&&S._bodyInit!=null&&(U=S._bodyInit,S.bodyUsed=!0)}else this.url=String(S);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")&&U)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(U),(this.method==="GET"||this.method==="HEAD")&&(x.cache==="no-store"||x.cache==="no-cache")){var b=/([?&])_=[^&]*/;if(b.test(this.url))this.url=this.url.replace(b,"$1_="+new Date().getTime());else{var R=/\?/;this.url+=(R.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}$.prototype.clone=function(){return new $(this,{body:this._bodyInit})};function F(S){var x=new FormData;return S.trim().split("&").forEach(function(U){if(U){var b=U.split("="),R=b.shift().replace(/\+/g," "),T=b.join("=").replace(/\+/g," ");x.append(decodeURIComponent(R),decodeURIComponent(T))}}),x}function H(S){var x=new f,U=S.replace(/\r?\n[\t ]+/g," ");return U.split("\r").map(function(b){return b.indexOf(`
|
|
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 Jg(){return new Image}const Bl=Kt(async function(e,t=Jg){return e?new Promise((i,r)=>{t().then(n=>{n.onload=()=>{i(n)},n.onerror=o=>{r(o)},n.src=e})}):null});async function So({element:s,meta:e,imageFactory:t},i,r){var n,o,a;let A={...s};const{node:l}=s;if((l==null?void 0:l.type)==="video"&&((n=l==null?void 0:l.value)!=null&&n.src||(o=l==null?void 0:l.value)!=null&&o.playlist)){const c=await i(l.value,e);let h;try{h=await Bl(l.value.poster,t)}catch{h=null}A={...A,node:{...l,video:c,poster:h,meta:await r(l.value,c.node,e)}}}if((l==null?void 0:l.type)==="image"&&l.value){let c;try{c=await Bl(l.value,t)}catch{c=null}A={...A,node:{...l,image:c}}}return A.node&&((a=s.node)!=null&&a.elements)&&(A.node.elements=await Promise.all(s.node.elements.map(c=>So({element:c,meta:e,imageFactory:t},i,r)))),s.elements&&(A.elements=await Promise.all(s.elements.map(c=>So({element:c,meta:e,imageFactory:t},i,r)))),A}async function Wg(){return document.createElement("canvas")}function zs(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=zs(t==null?void 0:t.elements);if(i)return i}}function qg(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 jg(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 Xg(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 Xr(s){return s.flatMap(e=>Array.isArray(e)?e.flatMap(t=>t):e).reduce((e,t)=>e+t,0)}const zg=Kt(()=>nl.loadYoga());po.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${Xg(s)}"`:jg(s)||Array.isArray(s)?JSON.stringify(s):s);const ls=(s,e,t)=>po.render(s,e,po.getConfig({autoEscape:!1,defaultFilter:"parse",...t}));async function cs({data:s,template:e,burnCaptions:t=!1,debug:i=!1,imageFactory:r,canvasFactory:n=Wg},o,a,A){var l,c,h,u;const d=await zg(),g=e??Vg;if(!((l=g.templates)!=null&&l.length))throw new Error(`No templates found for template instance: ${g.id}`);let f=g.templates.find(({version:q})=>q===wo);if(!f){const q=g.templates.map(({version:Y})=>`"${Y}"`).join(", ");console.warn(`Template renderer expects template version "${wo}" but got ${q}`),f=g.templates[g.templates.length-1]}const p=await Promise.all(f.content.map(async({scenes:q,root:Y})=>{const z={...g.options,...s,intro:g.intro,outro:g.outro};async function S(x,U){return Promise.all(q.map(async({layout:b,duration:R,data:T,derived:V,options:P})=>{var j,se,ce;const Ae={...z,_index:U,_root:x,_derived:await o({data:s,rootData:x,index:U})},ye=T?JSON.parse(await ls(T,Ae)):{},Ee=V?JSON.parse(await ls(V,Ae)):{},Re=P?JSON.parse(await ls(P,Ae)):{},ne=R?parseFloat(await ls(R,Ae)):NaN,ue=(j=f.layouts.find(Be=>Be.name===b))==null?void 0:j.tree;if(!ue)throw new Error(`Layout tree "${b}" not found in template "${f.id}" layouts.`);const Se=JSON.parse(await ls(ue,{...ye,...Ee,...Re})),Ce=await Promise.all(Se.flatMap(Be=>So({element:Be,meta:g.meta,imageFactory:r},a,A))),he=zs(Ce);return{duration:(isNaN(ne)?null:ne)??((se=he==null?void 0:he.meta)==null?void 0:se.duration)??0,captions:(ce=he==null?void 0:he.meta)==null?void 0:ce.captions,elements:Ce}}))}if(Y){const x=JSON.parse(await ls(Y,z));return Array.isArray(x)?Promise.all(x.map(async(U,b)=>S(U,b))):Promise.all([S(x,null)])}return Promise.all([S(s,null)])}));if(p.every(q=>q.every(Y=>Y.every(z=>{const S=zs(z.elements);return!(S!=null&&S.value.src)&&!(S!=null&&S.value.playlist)})))){const q=p.flatMap(Y=>Y.flatMap(z=>z.map(S=>{const x=zs(S.elements);return!(x!=null&&x.value.src)&&!(x!=null&&x.value.playlist)&&(x==null?void 0:x.value.id)}).filter(Boolean))).join(", ");throw new Error(`Video(s) with ID ${q} failed to load, video can not be processed`)}if(p.every(q=>q.every(Y=>Y.every(z=>z.duration<=0))))throw new Error("No scenes have any duration, video can not be processed");const Q=p.reduce((q,Y)=>{const z=Y.reduce((S,x)=>{const U=x.filter(b=>b.duration>0);return U.length>0?[...S,U]:S},[]);return z.length>0?[...q,z]:q},[]),C=((c=g.meta)==null?void 0:c.frameRate)??30,w=((h=g.meta)==null?void 0:h.resolution)??1080,B=((u=g.meta)==null?void 0:u.transitionDuration)??1/3,L=qg(Q,B),_=Xr(L),$=await Promise.all(Q.map((q,Y)=>{const z=Xr(L[Y]),S=Xr(L.slice(0,Y));return Promise.all(q.map((x,U)=>Promise.all(x.map(async({duration:b,captions:R,elements:T},V)=>{var P,j;const se=await n(),ce=await n(),Ae=await n(),ye=await n(),Ee=zs(T),Re=Xr([...L.slice(0,Y),...L[Y].slice(0,U),...L[Y][U].slice(0,V)]);return{draw:async({canvas:ue,currentTime:Se})=>{const Ce=Math.max(0,Se-S),he=Math.max(0,Se-Re);await bo({yoga:d,debug:i,canvas:ue,cropCanvas:se,posterCanvas:ye,letterboxCanvas:ce,elements:T,currentTime:Se,contentTime:Ce,sceneTime:he,totalDuration:_,contentDuration:z,sceneDuration:b}),R&&t&&Gg({canvas:ue,dx:0,dy:0,dw:ue.width,dh:ue.height,vttCaptions:R,sceneTime:he+((Ee==null?void 0:Ee.meta.start)??0)})},duration:b,transitionCanvas:Ae,id:Kg(),start:Re,video:Ee==null?void 0:Ee.video,videoMeta:Ee==null?void 0:Ee.meta,audio:{duration:b,src:(P=Ee==null?void 0:Ee.value)==null?void 0:P.src,start:(j=Ee==null?void 0:Ee.meta)==null?void 0:j.start}}}))))})),F=$.flatMap(q=>q);return{scenes:F.flatMap(q=>q),sections:F,contents:$,frameRate:C,resolution:w,transitionDuration:B,fonts:f.fonts??[],duration:_}}const wo="3",Zg={name:"@vouchfor/embeds-legacy",version:"4.0.4",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds-legacy.js",module:"dist/es/embeds-legacy.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds-legacy.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-legacy 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-legacy":"^9.0.0","@vouchfor/media-player-legacy":"^5.0.4",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.5.8","@storybook/addon-links":"^8.5.8","@storybook/blocks":"^8.5.8","@storybook/web-components":"^8.5.8","@storybook/web-components-vite":"^8.5.8","@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-legacy":"^2.0.3","@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.5.8",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 ef(s){const{publicApiUrl:e}=Dr(s),t=Ti();return navigator.sendBeacon(`${e}/api/visitor`,JSON.stringify({visitorId:t})),t}function tf(s){var n,o,a,A,l,c,h,u,d,g,f,p;if(typeof window>"u")return{client:null,tab:null,request:Ti()};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=Ti();return e||(e=ef(s),(u=(h=window.localStorage)==null?void 0:h.setItem)==null||u.call(h,"vouch-uid-visitor",e)),t||(t=Ti(),(g=(d=window.localStorage)==null?void 0:d.setItem)==null||g.call(d,"vouch-uid-client",t)),i||(i=Ti(),(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 sf(s,e){return s&&"vouchId"in s?s.vouchId:(e==null?void 0:e.id)??null}function rf(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:Zg.version,templateVersion:wo,...i}}const Ql=1;class nf{constructor(e){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(t,i)=>{const r=sf(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}=Dr(this.host.env),{client:i,tab:r,request:n,visitor:o}=tf(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":rf(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:t,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+Ql&&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]+Ql&&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 Ro={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof go<"u"&&go,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(S){return S&&DataView.prototype.isPrototypeOf(S)}if(A.arrayBuffer)var c=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(S){return S&&c.indexOf(Object.prototype.toString.call(S))>-1};function u(S){if(typeof S!="string"&&(S=String(S)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(S)||S==="")throw new TypeError('Invalid character in header field name: "'+S+'"');return S.toLowerCase()}function d(S){return typeof S!="string"&&(S=String(S)),S}function g(S){var x={next:function(){var U=S.shift();return{done:U===void 0,value:U}}};return A.iterable&&(x[Symbol.iterator]=function(){return x}),x}function f(S){this.map={},S instanceof f?S.forEach(function(x,U){this.append(U,x)},this):Array.isArray(S)?S.forEach(function(x){this.append(x[0],x[1])},this):S&&Object.getOwnPropertyNames(S).forEach(function(x){this.append(x,S[x])},this)}f.prototype.append=function(S,x){S=u(S),x=d(x);var U=this.map[S];this.map[S]=U?U+", "+x:x},f.prototype.delete=function(S){delete this.map[u(S)]},f.prototype.get=function(S){return S=u(S),this.has(S)?this.map[S]:null},f.prototype.has=function(S){return this.map.hasOwnProperty(u(S))},f.prototype.set=function(S,x){this.map[u(S)]=d(x)},f.prototype.forEach=function(S,x){for(var U in this.map)this.map.hasOwnProperty(U)&&S.call(x,this.map[U],U,this)},f.prototype.keys=function(){var S=[];return this.forEach(function(x,U){S.push(U)}),g(S)},f.prototype.values=function(){var S=[];return this.forEach(function(x){S.push(x)}),g(S)},f.prototype.entries=function(){var S=[];return this.forEach(function(x,U){S.push([U,x])}),g(S)},A.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function p(S){if(S.bodyUsed)return Promise.reject(new TypeError("Already read"));S.bodyUsed=!0}function y(S){return new Promise(function(x,U){S.onload=function(){x(S.result)},S.onerror=function(){U(S.error)}})}function v(S){var x=new FileReader,U=y(x);return x.readAsArrayBuffer(S),U}function Q(S){var x=new FileReader,U=y(x);return x.readAsText(S),U}function C(S){for(var x=new Uint8Array(S),U=new Array(x.length),b=0;b<x.length;b++)U[b]=String.fromCharCode(x[b]);return U.join("")}function w(S){if(S.slice)return S.slice(0);var x=new Uint8Array(S.byteLength);return x.set(new Uint8Array(S)),x.buffer}function B(){return this.bodyUsed=!1,this._initBody=function(S){this.bodyUsed=this.bodyUsed,this._bodyInit=S,S?typeof S=="string"?this._bodyText=S:A.blob&&Blob.prototype.isPrototypeOf(S)?this._bodyBlob=S:A.formData&&FormData.prototype.isPrototypeOf(S)?this._bodyFormData=S:A.searchParams&&URLSearchParams.prototype.isPrototypeOf(S)?this._bodyText=S.toString():A.arrayBuffer&&A.blob&&l(S)?(this._bodyArrayBuffer=w(S.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(S)||h(S))?this._bodyArrayBuffer=w(S):this._bodyText=S=Object.prototype.toString.call(S):this._bodyText="",this.headers.get("content-type")||(typeof S=="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(S)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},A.blob&&(this.blob=function(){var S=p(this);if(S)return S;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 S=p(this);return S||(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(v)}),this.text=function(){var S=p(this);if(S)return S;if(this._bodyBlob)return Q(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(F)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function _(S){var x=S.toUpperCase();return L.indexOf(x)>-1?x:S}function $(S,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 U=x.body;if(S instanceof $){if(S.bodyUsed)throw new TypeError("Already read");this.url=S.url,this.credentials=S.credentials,x.headers||(this.headers=new f(S.headers)),this.method=S.method,this.mode=S.mode,this.signal=S.signal,!U&&S._bodyInit!=null&&(U=S._bodyInit,S.bodyUsed=!0)}else this.url=String(S);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")&&U)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(U),(this.method==="GET"||this.method==="HEAD")&&(x.cache==="no-store"||x.cache==="no-cache")){var b=/([?&])_=[^&]*/;if(b.test(this.url))this.url=this.url.replace(b,"$1_="+new Date().getTime());else{var R=/\?/;this.url+=(R.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}$.prototype.clone=function(){return new $(this,{body:this._bodyInit})};function F(S){var x=new FormData;return S.trim().split("&").forEach(function(U){if(U){var b=U.split("="),R=b.shift().replace(/\+/g," "),T=b.join("=").replace(/\+/g," ");x.append(decodeURIComponent(R),decodeURIComponent(T))}}),x}function H(S){var x=new f,U=S.replace(/\r?\n[\t ]+/g," ");return U.split("\r").map(function(b){return b.indexOf(`
|
|
153
153
|
`)===0?b.substr(1,b.length):b}).forEach(function(b){var R=b.split(":"),T=R.shift().trim();if(T){var V=R.join(":").trim();x.append(T,V)}}),x}B.call($.prototype);function q(S,x){if(!(this instanceof q))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(S)}B.call(q.prototype),q.prototype.clone=function(){return new q(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},q.error=function(){var S=new q(null,{status:0,statusText:""});return S.type="error",S};var Y=[301,302,303,307,308];q.redirect=function(S,x){if(Y.indexOf(x)===-1)throw new RangeError("Invalid status code");return new q(null,{status:x,headers:{location:S}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(x,U){this.message=x,this.name=U;var b=Error(x);this.stack=b.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function z(S,x){return new Promise(function(U,b){var R=new $(S,x);if(R.signal&&R.signal.aborted)return b(new o.DOMException("Aborted","AbortError"));var T=new XMLHttpRequest;function V(){T.abort()}T.onload=function(){var j={status:T.status,statusText:T.statusText,headers:H(T.getAllResponseHeaders()||"")};j.url="responseURL"in T?T.responseURL:j.headers.get("X-Request-URL");var se="response"in T?T.response:T.responseText;setTimeout(function(){U(new q(se,j))},0)},T.onerror=function(){setTimeout(function(){b(new TypeError("Network request failed"))},0)},T.ontimeout=function(){setTimeout(function(){b(new TypeError("Network request failed"))},0)},T.onabort=function(){setTimeout(function(){b(new o.DOMException("Aborted","AbortError"))},0)};function P(j){try{return j===""&&a.location.href?a.location.href:j}catch{return j}}T.open(R.method,P(R.url),!0),R.credentials==="include"?T.withCredentials=!0:R.credentials==="omit"&&(T.withCredentials=!1),"responseType"in T&&(A.blob?T.responseType="blob":A.arrayBuffer&&R.headers.get("Content-Type")&&R.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(j){T.setRequestHeader(j,d(x.headers[j]))}):R.headers.forEach(function(j,se){T.setRequestHeader(se,j)}),R.signal&&(R.signal.addEventListener("abort",V),T.onreadystatechange=function(){T.readyState===4&&R.signal.removeEventListener("abort",V)}),T.send(typeof R._bodyInit>"u"?null:R._bodyInit)})}return z.polyfill=!0,a.fetch||(a.fetch=z,a.Headers=f,a.Request=$,a.Response=q),o.Headers=f,o.Request=$,o.Response=q,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})(Ro,Ro.exports);var of=Ro.exports;const bl=Ig(of);async function af(s){var e;try{if((e=await bl(s,{method:"HEAD"}))!=null&&e.ok)return s}catch{return}}async function xo({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=>af(o));e=(await Promise.all(n)).find(Boolean)}return e}async function Af(s){try{return(await bl(s)).text()}catch{return null}}async function lf(s){return s=s.trim(),s.startsWith("http")||s.startsWith("blob:")?Af(s):s}const cf=Kt(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?lf(A):null},{cacheKey:([s,{language:e}])=>JSON.stringify({...s,language:e})}),hf=Kt(async s=>{var e,t,i,r,n,o,a,A,l,c,h;const[u,d,g]=await Promise.all([xo({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]}),xo({sources:[(o=(n=s==null?void 0:s.answer)==null?void 0:n.media)==null?void 0:o.playlist]}),xo({sources:[((A=(a=s==null?void 0:s.answer)==null?void 0:a.media)==null?void 0:A.reducedQuality)??((h=(c=(l=s==null?void 0:s.answer)==null?void 0:l.media)==null?void 0:c.videos)==null?void 0:h.xs)]})]);return{src:u,playlist:d,preview:g}},{cacheKey:([s])=>{var e,t,i,r,n,o,a,A,l,c,h;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)??((h=(c=(l=s==null?void 0:s.answer)==null?void 0:l.media)==null?void 0:c.videos)==null?void 0:h.xs)})}});function Sl(s){var e,t,i,r,n,o,a,A,l,c,h,u;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"?"":((u=(h=(c=(l=s==null?void 0:s.answer)==null?void 0:l.contact)==null?void 0:c.client)==null?void 0:h.name)==null?void 0:u.trim())??"",[f,p]=d.split(" ");return{name:d,firstName:f,lastName:p,companyName:g}}const uf=Kt(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 To({data:s,rootData:e,index:t},i){var r,n,o,a,A,l,c,h,u,d,g,f,p,y,v,Q,C,w,B,L,_,$,F;const[H,q,Y]=await Promise.all([uf(s,e,t),hf(e),cf({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)??((h=(c=e==null?void 0:e.answer)==null?void 0:c.captions)==null?void 0:h.translation),originalLanguage:(d=(u=e==null?void 0:e.answer)==null?void 0:u.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=Sl(e);return{...q,...z,key:H,captions:Y,answerLabel:((y=e==null?void 0:e.answer)==null?void 0:y.label)??(e==null?void 0:e.title),prevAnswerLabel:t?((w=(C=(Q=(v=s==null?void 0:s.questions)==null?void 0:v.items)==null?void 0:Q[t-1])==null?void 0:C.answer)==null?void 0:w.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?((F=($=s==null?void 0:s.questions)==null?void 0:$.items)==null?void 0:F.findIndex(S=>Sl(S).name===z.name))===t:!0}}const zr={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 df({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,h;const u=(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=(h=(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:h.split("-")[0];return u&&zr[u]&&!i.find(g=>g.value===u)&&i.push({value:u,label:zr[u]}),d&&zr[d]&&!i.find(g=>g.value===d)&&i.push({value:d,label:zr[d]}),i},[]))??[]}/**
|
|
154
154
|
* @license
|
|
155
155
|
* Copyright 2018 Google LLC
|
|
@@ -149,7 +149,7 @@ ${e}`,vg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Bg=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 Vg(){return new Image}const vl=Yt(async function(e,t=Vg){return e?new Promise((i,r)=>{t().then(n=>{n.onload=()=>{i(n)},n.onerror=o=>{r(o)},n.src=e})}):null});async function bo({element:s,meta:e,imageFactory:t},i,r){var n,o,a;let A={...s};const{node:l}=s;if((l==null?void 0:l.type)==="video"&&((n=l==null?void 0:l.value)!=null&&n.src||(o=l==null?void 0:l.value)!=null&&o.playlist)){const c=await i(l.value,e);let h;try{h=await vl(l.value.poster,t)}catch{h=null}A={...A,node:{...l,video:c,poster:h,meta:await r(l.value,c.node,e)}}}if((l==null?void 0:l.type)==="image"&&l.value){let c;try{c=await vl(l.value,t)}catch{c=null}A={...A,node:{...l,image:c}}}return A.node&&((a=s.node)!=null&&a.elements)&&(A.node.elements=await Promise.all(s.node.elements.map(c=>bo({element:c,meta:e,imageFactory:t},i,r)))),s.elements&&(A.elements=await Promise.all(s.elements.map(c=>bo({element:c,meta:e,imageFactory:t},i,r)))),A}async function Jg(){return document.createElement("canvas")}function Xs(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=Xs(t==null?void 0:t.elements);if(i)return i}}function Wg(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 qg(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 jg(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 jr(s){return s.flatMap(e=>Array.isArray(e)?e.flatMap(t=>t):e).reduce((e,t)=>e+t,0)}const Xg=Yt(()=>rl.loadYoga());fo.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${jg(s)}"`:qg(s)||Array.isArray(s)?JSON.stringify(s):s);const As=(s,e,t)=>fo.render(s,e,fo.getConfig({autoEscape:!1,defaultFilter:"parse",...t}));async function ls({data:s,template:e,burnCaptions:t=!1,debug:i=!1,imageFactory:r,canvasFactory:n=Jg},o,a,A){var l,c,h,u;const d=await Xg(),g=e??Kg;if(!((l=g.templates)!=null&&l.length))throw new Error(`No templates found for template instance: ${g.id}`);let f=g.templates.find(({version:q})=>q===So);if(!f){const q=g.templates.map(({version:Y})=>`"${Y}"`).join(", ");console.warn(`Template renderer expects template version "${So}" but got ${q}`),f=g.templates[g.templates.length-1]}const p=await Promise.all(f.content.map(async({scenes:q,root:Y})=>{const z={...g.options,...s,intro:g.intro,outro:g.outro};async function S(T,U){return Promise.all(q.map(async({layout:b,duration:R,data:x,derived:V,options:O})=>{var j,se,ce;const Ae={...z,_index:U,_root:T,_derived:await o({data:s,rootData:T,index:U})},ye=x?JSON.parse(await As(x,Ae)):{},Ee=V?JSON.parse(await As(V,Ae)):{},Re=O?JSON.parse(await As(O,Ae)):{},ne=R?parseFloat(await As(R,Ae)):NaN,ue=(j=f.layouts.find(Be=>Be.name===b))==null?void 0:j.tree;if(!ue)throw new Error(`Layout tree "${b}" not found in template "${f.id}" layouts.`);const Se=JSON.parse(await As(ue,{...ye,...Ee,...Re})),Ce=await Promise.all(Se.flatMap(Be=>bo({element:Be,meta:g.meta,imageFactory:r},a,A))),he=Xs(Ce);return{duration:(isNaN(ne)?null:ne)??((se=he==null?void 0:he.meta)==null?void 0:se.duration)??0,captions:(ce=he==null?void 0:he.meta)==null?void 0:ce.captions,elements:Ce}}))}if(Y){const T=JSON.parse(await As(Y,z));return Array.isArray(T)?Promise.all(T.map(async(U,b)=>S(U,b))):Promise.all([S(T,null)])}return Promise.all([S(s,null)])}));if(p.every(q=>q.every(Y=>Y.every(z=>{const S=Xs(z.elements);return!(S!=null&&S.value.src)&&!(S!=null&&S.value.playlist)})))){const q=p.flatMap(Y=>Y.flatMap(z=>z.map(S=>{const T=Xs(S.elements);return!(T!=null&&T.value.src)&&!(T!=null&&T.value.playlist)&&(T==null?void 0:T.value.id)}).filter(Boolean))).join(", ");throw new Error(`Video(s) with ID ${q} failed to load, video can not be processed`)}if(p.every(q=>q.every(Y=>Y.every(z=>z.duration<=0))))throw new Error("No scenes have any duration, video can not be processed");const Q=p.reduce((q,Y)=>{const z=Y.reduce((S,T)=>{const U=T.filter(b=>b.duration>0);return U.length>0?[...S,U]:S},[]);return z.length>0?[...q,z]:q},[]),C=((c=g.meta)==null?void 0:c.frameRate)??30,w=((h=g.meta)==null?void 0:h.resolution)??1080,B=((u=g.meta)==null?void 0:u.transitionDuration)??1/3,L=Wg(Q,B),_=jr(L),$=await Promise.all(Q.map((q,Y)=>{const z=jr(L[Y]),S=jr(L.slice(0,Y));return Promise.all(q.map((T,U)=>Promise.all(T.map(async({duration:b,captions:R,elements:x},V)=>{var O,j;const se=await n(),ce=await n(),Ae=await n(),ye=await n(),Ee=Xs(x),Re=jr([...L.slice(0,Y),...L[Y].slice(0,U),...L[Y][U].slice(0,V)]);return{draw:async({canvas:ue,currentTime:Se})=>{const Ce=Math.max(0,Se-S),he=Math.max(0,Se-Re);await Qo({yoga:d,debug:i,canvas:ue,cropCanvas:se,posterCanvas:ye,letterboxCanvas:ce,elements:x,currentTime:Se,contentTime:Ce,sceneTime:he,totalDuration:_,contentDuration:z,sceneDuration:b}),R&&t&&Ug({canvas:ue,dx:0,dy:0,dw:ue.width,dh:ue.height,vttCaptions:R,sceneTime:he+((Ee==null?void 0:Ee.meta.start)??0)})},duration:b,transitionCanvas:Ae,id:Yg(),start:Re,video:Ee==null?void 0:Ee.video,videoMeta:Ee==null?void 0:Ee.meta,audio:{duration:b,src:(O=Ee==null?void 0:Ee.value)==null?void 0:O.src,start:(j=Ee==null?void 0:Ee.meta)==null?void 0:j.start}}}))))})),F=$.flatMap(q=>q);return{scenes:F.flatMap(q=>q),sections:F,contents:$,frameRate:C,resolution:w,transitionDuration:B,fonts:f.fonts??[],duration:_}}const So="3",zg={name:"@vouchfor/embeds-legacy",version:"4.0.3",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds-legacy.js",module:"dist/es/embeds-legacy.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds-legacy.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-legacy 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-legacy":"^9.0.0","@vouchfor/media-player-legacy":"^5.0.3",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-legacy":"^2.0.3","@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 Zg(s){const{publicApiUrl:e}=xr(s),t=Ti();return navigator.sendBeacon(`${e}/api/visitor`,JSON.stringify({visitorId:t})),t}function ef(s){var n,o,a,A,l,c,h,u,d,g,f,p;if(typeof window>"u")return{client:null,tab:null,request:Ti()};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=Ti();return e||(e=Zg(s),(u=(h=window.localStorage)==null?void 0:h.setItem)==null||u.call(h,"vouch-uid-visitor",e)),t||(t=Ti(),(g=(d=window.localStorage)==null?void 0:d.setItem)==null||g.call(d,"vouch-uid-client",t)),i||(i=Ti(),(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 tf(s,e){return s&&"vouchId"in s?s.vouchId:(e==null?void 0:e.id)??null}function sf(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:zg.version,templateVersion:So,...i}}const Bl=1;class rf{constructor(e){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(t,i)=>{const r=tf(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}=xr(this.host.env),{client:i,tab:r,request:n,visitor:o}=ef(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":sf(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:t,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+Bl&&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]+Bl&&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 wo={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof uo<"u"&&uo,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(S){return S&&DataView.prototype.isPrototypeOf(S)}if(A.arrayBuffer)var c=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(S){return S&&c.indexOf(Object.prototype.toString.call(S))>-1};function u(S){if(typeof S!="string"&&(S=String(S)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(S)||S==="")throw new TypeError('Invalid character in header field name: "'+S+'"');return S.toLowerCase()}function d(S){return typeof S!="string"&&(S=String(S)),S}function g(S){var T={next:function(){var U=S.shift();return{done:U===void 0,value:U}}};return A.iterable&&(T[Symbol.iterator]=function(){return T}),T}function f(S){this.map={},S instanceof f?S.forEach(function(T,U){this.append(U,T)},this):Array.isArray(S)?S.forEach(function(T){this.append(T[0],T[1])},this):S&&Object.getOwnPropertyNames(S).forEach(function(T){this.append(T,S[T])},this)}f.prototype.append=function(S,T){S=u(S),T=d(T);var U=this.map[S];this.map[S]=U?U+", "+T:T},f.prototype.delete=function(S){delete this.map[u(S)]},f.prototype.get=function(S){return S=u(S),this.has(S)?this.map[S]:null},f.prototype.has=function(S){return this.map.hasOwnProperty(u(S))},f.prototype.set=function(S,T){this.map[u(S)]=d(T)},f.prototype.forEach=function(S,T){for(var U in this.map)this.map.hasOwnProperty(U)&&S.call(T,this.map[U],U,this)},f.prototype.keys=function(){var S=[];return this.forEach(function(T,U){S.push(U)}),g(S)},f.prototype.values=function(){var S=[];return this.forEach(function(T){S.push(T)}),g(S)},f.prototype.entries=function(){var S=[];return this.forEach(function(T,U){S.push([U,T])}),g(S)},A.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function p(S){if(S.bodyUsed)return Promise.reject(new TypeError("Already read"));S.bodyUsed=!0}function y(S){return new Promise(function(T,U){S.onload=function(){T(S.result)},S.onerror=function(){U(S.error)}})}function v(S){var T=new FileReader,U=y(T);return T.readAsArrayBuffer(S),U}function Q(S){var T=new FileReader,U=y(T);return T.readAsText(S),U}function C(S){for(var T=new Uint8Array(S),U=new Array(T.length),b=0;b<T.length;b++)U[b]=String.fromCharCode(T[b]);return U.join("")}function w(S){if(S.slice)return S.slice(0);var T=new Uint8Array(S.byteLength);return T.set(new Uint8Array(S)),T.buffer}function B(){return this.bodyUsed=!1,this._initBody=function(S){this.bodyUsed=this.bodyUsed,this._bodyInit=S,S?typeof S=="string"?this._bodyText=S:A.blob&&Blob.prototype.isPrototypeOf(S)?this._bodyBlob=S:A.formData&&FormData.prototype.isPrototypeOf(S)?this._bodyFormData=S:A.searchParams&&URLSearchParams.prototype.isPrototypeOf(S)?this._bodyText=S.toString():A.arrayBuffer&&A.blob&&l(S)?(this._bodyArrayBuffer=w(S.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(S)||h(S))?this._bodyArrayBuffer=w(S):this._bodyText=S=Object.prototype.toString.call(S):this._bodyText="",this.headers.get("content-type")||(typeof S=="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(S)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},A.blob&&(this.blob=function(){var S=p(this);if(S)return S;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 S=p(this);return S||(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(v)}),this.text=function(){var S=p(this);if(S)return S;if(this._bodyBlob)return Q(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(F)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function _(S){var T=S.toUpperCase();return L.indexOf(T)>-1?T:S}function $(S,T){if(!(this instanceof $))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');T=T||{};var U=T.body;if(S instanceof $){if(S.bodyUsed)throw new TypeError("Already read");this.url=S.url,this.credentials=S.credentials,T.headers||(this.headers=new f(S.headers)),this.method=S.method,this.mode=S.mode,this.signal=S.signal,!U&&S._bodyInit!=null&&(U=S._bodyInit,S.bodyUsed=!0)}else this.url=String(S);if(this.credentials=T.credentials||this.credentials||"same-origin",(T.headers||!this.headers)&&(this.headers=new f(T.headers)),this.method=_(T.method||this.method||"GET"),this.mode=T.mode||this.mode||null,this.signal=T.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&U)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(U),(this.method==="GET"||this.method==="HEAD")&&(T.cache==="no-store"||T.cache==="no-cache")){var b=/([?&])_=[^&]*/;if(b.test(this.url))this.url=this.url.replace(b,"$1_="+new Date().getTime());else{var R=/\?/;this.url+=(R.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}$.prototype.clone=function(){return new $(this,{body:this._bodyInit})};function F(S){var T=new FormData;return S.trim().split("&").forEach(function(U){if(U){var b=U.split("="),R=b.shift().replace(/\+/g," "),x=b.join("=").replace(/\+/g," ");T.append(decodeURIComponent(R),decodeURIComponent(x))}}),T}function H(S){var T=new f,U=S.replace(/\r?\n[\t ]+/g," ");return U.split("\r").map(function(b){return b.indexOf(`
|
|
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 Vg(){return new Image}const vl=Yt(async function(e,t=Vg){return e?new Promise((i,r)=>{t().then(n=>{n.onload=()=>{i(n)},n.onerror=o=>{r(o)},n.src=e})}):null});async function bo({element:s,meta:e,imageFactory:t},i,r){var n,o,a;let A={...s};const{node:l}=s;if((l==null?void 0:l.type)==="video"&&((n=l==null?void 0:l.value)!=null&&n.src||(o=l==null?void 0:l.value)!=null&&o.playlist)){const c=await i(l.value,e);let h;try{h=await vl(l.value.poster,t)}catch{h=null}A={...A,node:{...l,video:c,poster:h,meta:await r(l.value,c.node,e)}}}if((l==null?void 0:l.type)==="image"&&l.value){let c;try{c=await vl(l.value,t)}catch{c=null}A={...A,node:{...l,image:c}}}return A.node&&((a=s.node)!=null&&a.elements)&&(A.node.elements=await Promise.all(s.node.elements.map(c=>bo({element:c,meta:e,imageFactory:t},i,r)))),s.elements&&(A.elements=await Promise.all(s.elements.map(c=>bo({element:c,meta:e,imageFactory:t},i,r)))),A}async function Jg(){return document.createElement("canvas")}function Xs(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=Xs(t==null?void 0:t.elements);if(i)return i}}function Wg(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 qg(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 jg(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 jr(s){return s.flatMap(e=>Array.isArray(e)?e.flatMap(t=>t):e).reduce((e,t)=>e+t,0)}const Xg=Yt(()=>rl.loadYoga());fo.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${jg(s)}"`:qg(s)||Array.isArray(s)?JSON.stringify(s):s);const As=(s,e,t)=>fo.render(s,e,fo.getConfig({autoEscape:!1,defaultFilter:"parse",...t}));async function ls({data:s,template:e,burnCaptions:t=!1,debug:i=!1,imageFactory:r,canvasFactory:n=Jg},o,a,A){var l,c,h,u;const d=await Xg(),g=e??Kg;if(!((l=g.templates)!=null&&l.length))throw new Error(`No templates found for template instance: ${g.id}`);let f=g.templates.find(({version:q})=>q===So);if(!f){const q=g.templates.map(({version:Y})=>`"${Y}"`).join(", ");console.warn(`Template renderer expects template version "${So}" but got ${q}`),f=g.templates[g.templates.length-1]}const p=await Promise.all(f.content.map(async({scenes:q,root:Y})=>{const z={...g.options,...s,intro:g.intro,outro:g.outro};async function S(T,U){return Promise.all(q.map(async({layout:b,duration:R,data:x,derived:V,options:O})=>{var j,se,ce;const Ae={...z,_index:U,_root:T,_derived:await o({data:s,rootData:T,index:U})},ye=x?JSON.parse(await As(x,Ae)):{},Ee=V?JSON.parse(await As(V,Ae)):{},Re=O?JSON.parse(await As(O,Ae)):{},ne=R?parseFloat(await As(R,Ae)):NaN,ue=(j=f.layouts.find(Be=>Be.name===b))==null?void 0:j.tree;if(!ue)throw new Error(`Layout tree "${b}" not found in template "${f.id}" layouts.`);const Se=JSON.parse(await As(ue,{...ye,...Ee,...Re})),Ce=await Promise.all(Se.flatMap(Be=>bo({element:Be,meta:g.meta,imageFactory:r},a,A))),he=Xs(Ce);return{duration:(isNaN(ne)?null:ne)??((se=he==null?void 0:he.meta)==null?void 0:se.duration)??0,captions:(ce=he==null?void 0:he.meta)==null?void 0:ce.captions,elements:Ce}}))}if(Y){const T=JSON.parse(await As(Y,z));return Array.isArray(T)?Promise.all(T.map(async(U,b)=>S(U,b))):Promise.all([S(T,null)])}return Promise.all([S(s,null)])}));if(p.every(q=>q.every(Y=>Y.every(z=>{const S=Xs(z.elements);return!(S!=null&&S.value.src)&&!(S!=null&&S.value.playlist)})))){const q=p.flatMap(Y=>Y.flatMap(z=>z.map(S=>{const T=Xs(S.elements);return!(T!=null&&T.value.src)&&!(T!=null&&T.value.playlist)&&(T==null?void 0:T.value.id)}).filter(Boolean))).join(", ");throw new Error(`Video(s) with ID ${q} failed to load, video can not be processed`)}if(p.every(q=>q.every(Y=>Y.every(z=>z.duration<=0))))throw new Error("No scenes have any duration, video can not be processed");const Q=p.reduce((q,Y)=>{const z=Y.reduce((S,T)=>{const U=T.filter(b=>b.duration>0);return U.length>0?[...S,U]:S},[]);return z.length>0?[...q,z]:q},[]),C=((c=g.meta)==null?void 0:c.frameRate)??30,w=((h=g.meta)==null?void 0:h.resolution)??1080,B=((u=g.meta)==null?void 0:u.transitionDuration)??1/3,L=Wg(Q,B),_=jr(L),$=await Promise.all(Q.map((q,Y)=>{const z=jr(L[Y]),S=jr(L.slice(0,Y));return Promise.all(q.map((T,U)=>Promise.all(T.map(async({duration:b,captions:R,elements:x},V)=>{var O,j;const se=await n(),ce=await n(),Ae=await n(),ye=await n(),Ee=Xs(x),Re=jr([...L.slice(0,Y),...L[Y].slice(0,U),...L[Y][U].slice(0,V)]);return{draw:async({canvas:ue,currentTime:Se})=>{const Ce=Math.max(0,Se-S),he=Math.max(0,Se-Re);await Qo({yoga:d,debug:i,canvas:ue,cropCanvas:se,posterCanvas:ye,letterboxCanvas:ce,elements:x,currentTime:Se,contentTime:Ce,sceneTime:he,totalDuration:_,contentDuration:z,sceneDuration:b}),R&&t&&Ug({canvas:ue,dx:0,dy:0,dw:ue.width,dh:ue.height,vttCaptions:R,sceneTime:he+((Ee==null?void 0:Ee.meta.start)??0)})},duration:b,transitionCanvas:Ae,id:Yg(),start:Re,video:Ee==null?void 0:Ee.video,videoMeta:Ee==null?void 0:Ee.meta,audio:{duration:b,src:(O=Ee==null?void 0:Ee.value)==null?void 0:O.src,start:(j=Ee==null?void 0:Ee.meta)==null?void 0:j.start}}}))))})),F=$.flatMap(q=>q);return{scenes:F.flatMap(q=>q),sections:F,contents:$,frameRate:C,resolution:w,transitionDuration:B,fonts:f.fonts??[],duration:_}}const So="3",zg={name:"@vouchfor/embeds-legacy",version:"4.0.4",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds-legacy.js",module:"dist/es/embeds-legacy.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds-legacy.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-legacy 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-legacy":"^9.0.0","@vouchfor/media-player-legacy":"^5.0.4",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.5.8","@storybook/addon-links":"^8.5.8","@storybook/blocks":"^8.5.8","@storybook/web-components":"^8.5.8","@storybook/web-components-vite":"^8.5.8","@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-legacy":"^2.0.3","@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.5.8",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 Zg(s){const{publicApiUrl:e}=xr(s),t=Ti();return navigator.sendBeacon(`${e}/api/visitor`,JSON.stringify({visitorId:t})),t}function ef(s){var n,o,a,A,l,c,h,u,d,g,f,p;if(typeof window>"u")return{client:null,tab:null,request:Ti()};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=Ti();return e||(e=Zg(s),(u=(h=window.localStorage)==null?void 0:h.setItem)==null||u.call(h,"vouch-uid-visitor",e)),t||(t=Ti(),(g=(d=window.localStorage)==null?void 0:d.setItem)==null||g.call(d,"vouch-uid-client",t)),i||(i=Ti(),(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 tf(s,e){return s&&"vouchId"in s?s.vouchId:(e==null?void 0:e.id)??null}function sf(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:zg.version,templateVersion:So,...i}}const Bl=1;class rf{constructor(e){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(t,i)=>{const r=tf(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}=xr(this.host.env),{client:i,tab:r,request:n,visitor:o}=ef(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":sf(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:t,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+Bl&&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]+Bl&&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 wo={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof uo<"u"&&uo,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(S){return S&&DataView.prototype.isPrototypeOf(S)}if(A.arrayBuffer)var c=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(S){return S&&c.indexOf(Object.prototype.toString.call(S))>-1};function u(S){if(typeof S!="string"&&(S=String(S)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(S)||S==="")throw new TypeError('Invalid character in header field name: "'+S+'"');return S.toLowerCase()}function d(S){return typeof S!="string"&&(S=String(S)),S}function g(S){var T={next:function(){var U=S.shift();return{done:U===void 0,value:U}}};return A.iterable&&(T[Symbol.iterator]=function(){return T}),T}function f(S){this.map={},S instanceof f?S.forEach(function(T,U){this.append(U,T)},this):Array.isArray(S)?S.forEach(function(T){this.append(T[0],T[1])},this):S&&Object.getOwnPropertyNames(S).forEach(function(T){this.append(T,S[T])},this)}f.prototype.append=function(S,T){S=u(S),T=d(T);var U=this.map[S];this.map[S]=U?U+", "+T:T},f.prototype.delete=function(S){delete this.map[u(S)]},f.prototype.get=function(S){return S=u(S),this.has(S)?this.map[S]:null},f.prototype.has=function(S){return this.map.hasOwnProperty(u(S))},f.prototype.set=function(S,T){this.map[u(S)]=d(T)},f.prototype.forEach=function(S,T){for(var U in this.map)this.map.hasOwnProperty(U)&&S.call(T,this.map[U],U,this)},f.prototype.keys=function(){var S=[];return this.forEach(function(T,U){S.push(U)}),g(S)},f.prototype.values=function(){var S=[];return this.forEach(function(T){S.push(T)}),g(S)},f.prototype.entries=function(){var S=[];return this.forEach(function(T,U){S.push([U,T])}),g(S)},A.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function p(S){if(S.bodyUsed)return Promise.reject(new TypeError("Already read"));S.bodyUsed=!0}function y(S){return new Promise(function(T,U){S.onload=function(){T(S.result)},S.onerror=function(){U(S.error)}})}function v(S){var T=new FileReader,U=y(T);return T.readAsArrayBuffer(S),U}function Q(S){var T=new FileReader,U=y(T);return T.readAsText(S),U}function C(S){for(var T=new Uint8Array(S),U=new Array(T.length),b=0;b<T.length;b++)U[b]=String.fromCharCode(T[b]);return U.join("")}function w(S){if(S.slice)return S.slice(0);var T=new Uint8Array(S.byteLength);return T.set(new Uint8Array(S)),T.buffer}function B(){return this.bodyUsed=!1,this._initBody=function(S){this.bodyUsed=this.bodyUsed,this._bodyInit=S,S?typeof S=="string"?this._bodyText=S:A.blob&&Blob.prototype.isPrototypeOf(S)?this._bodyBlob=S:A.formData&&FormData.prototype.isPrototypeOf(S)?this._bodyFormData=S:A.searchParams&&URLSearchParams.prototype.isPrototypeOf(S)?this._bodyText=S.toString():A.arrayBuffer&&A.blob&&l(S)?(this._bodyArrayBuffer=w(S.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(S)||h(S))?this._bodyArrayBuffer=w(S):this._bodyText=S=Object.prototype.toString.call(S):this._bodyText="",this.headers.get("content-type")||(typeof S=="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(S)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},A.blob&&(this.blob=function(){var S=p(this);if(S)return S;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 S=p(this);return S||(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(v)}),this.text=function(){var S=p(this);if(S)return S;if(this._bodyBlob)return Q(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(F)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function _(S){var T=S.toUpperCase();return L.indexOf(T)>-1?T:S}function $(S,T){if(!(this instanceof $))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');T=T||{};var U=T.body;if(S instanceof $){if(S.bodyUsed)throw new TypeError("Already read");this.url=S.url,this.credentials=S.credentials,T.headers||(this.headers=new f(S.headers)),this.method=S.method,this.mode=S.mode,this.signal=S.signal,!U&&S._bodyInit!=null&&(U=S._bodyInit,S.bodyUsed=!0)}else this.url=String(S);if(this.credentials=T.credentials||this.credentials||"same-origin",(T.headers||!this.headers)&&(this.headers=new f(T.headers)),this.method=_(T.method||this.method||"GET"),this.mode=T.mode||this.mode||null,this.signal=T.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&U)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(U),(this.method==="GET"||this.method==="HEAD")&&(T.cache==="no-store"||T.cache==="no-cache")){var b=/([?&])_=[^&]*/;if(b.test(this.url))this.url=this.url.replace(b,"$1_="+new Date().getTime());else{var R=/\?/;this.url+=(R.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}$.prototype.clone=function(){return new $(this,{body:this._bodyInit})};function F(S){var T=new FormData;return S.trim().split("&").forEach(function(U){if(U){var b=U.split("="),R=b.shift().replace(/\+/g," "),x=b.join("=").replace(/\+/g," ");T.append(decodeURIComponent(R),decodeURIComponent(x))}}),T}function H(S){var T=new f,U=S.replace(/\r?\n[\t ]+/g," ");return U.split("\r").map(function(b){return b.indexOf(`
|
|
153
153
|
`)===0?b.substr(1,b.length):b}).forEach(function(b){var R=b.split(":"),x=R.shift().trim();if(x){var V=R.join(":").trim();T.append(x,V)}}),T}B.call($.prototype);function q(S,T){if(!(this instanceof q))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');T||(T={}),this.type="default",this.status=T.status===void 0?200:T.status,this.ok=this.status>=200&&this.status<300,this.statusText=T.statusText===void 0?"":""+T.statusText,this.headers=new f(T.headers),this.url=T.url||"",this._initBody(S)}B.call(q.prototype),q.prototype.clone=function(){return new q(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},q.error=function(){var S=new q(null,{status:0,statusText:""});return S.type="error",S};var Y=[301,302,303,307,308];q.redirect=function(S,T){if(Y.indexOf(T)===-1)throw new RangeError("Invalid status code");return new q(null,{status:T,headers:{location:S}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(T,U){this.message=T,this.name=U;var b=Error(T);this.stack=b.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function z(S,T){return new Promise(function(U,b){var R=new $(S,T);if(R.signal&&R.signal.aborted)return b(new o.DOMException("Aborted","AbortError"));var x=new XMLHttpRequest;function V(){x.abort()}x.onload=function(){var j={status:x.status,statusText:x.statusText,headers:H(x.getAllResponseHeaders()||"")};j.url="responseURL"in x?x.responseURL:j.headers.get("X-Request-URL");var se="response"in x?x.response:x.responseText;setTimeout(function(){U(new q(se,j))},0)},x.onerror=function(){setTimeout(function(){b(new TypeError("Network request failed"))},0)},x.ontimeout=function(){setTimeout(function(){b(new TypeError("Network request failed"))},0)},x.onabort=function(){setTimeout(function(){b(new o.DOMException("Aborted","AbortError"))},0)};function O(j){try{return j===""&&a.location.href?a.location.href:j}catch{return j}}x.open(R.method,O(R.url),!0),R.credentials==="include"?x.withCredentials=!0:R.credentials==="omit"&&(x.withCredentials=!1),"responseType"in x&&(A.blob?x.responseType="blob":A.arrayBuffer&&R.headers.get("Content-Type")&&R.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(x.responseType="arraybuffer")),T&&typeof T.headers=="object"&&!(T.headers instanceof f)?Object.getOwnPropertyNames(T.headers).forEach(function(j){x.setRequestHeader(j,d(T.headers[j]))}):R.headers.forEach(function(j,se){x.setRequestHeader(se,j)}),R.signal&&(R.signal.addEventListener("abort",V),x.onreadystatechange=function(){x.readyState===4&&R.signal.removeEventListener("abort",V)}),x.send(typeof R._bodyInit>"u"?null:R._bodyInit)})}return z.polyfill=!0,a.fetch||(a.fetch=z,a.Headers=f,a.Request=$,a.Response=q),o.Headers=f,o.Request=$,o.Response=q,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})(wo,wo.exports);var nf=wo.exports;const Ql=Eg(nf);async function of(s){var e;try{if((e=await Ql(s,{method:"HEAD"}))!=null&&e.ok)return s}catch{return}}async function Ro({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=>of(o));e=(await Promise.all(n)).find(Boolean)}return e}async function af(s){try{return(await Ql(s)).text()}catch{return null}}async function Af(s){return s=s.trim(),s.startsWith("http")||s.startsWith("blob:")?af(s):s}const lf=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?Af(A):null},{cacheKey:([s,{language:e}])=>JSON.stringify({...s,language:e})}),cf=Yt(async s=>{var e,t,i,r,n,o,a,A,l,c,h;const[u,d,g]=await Promise.all([Ro({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]}),Ro({sources:[(o=(n=s==null?void 0:s.answer)==null?void 0:n.media)==null?void 0:o.playlist]}),Ro({sources:[((A=(a=s==null?void 0:s.answer)==null?void 0:a.media)==null?void 0:A.reducedQuality)??((h=(c=(l=s==null?void 0:s.answer)==null?void 0:l.media)==null?void 0:c.videos)==null?void 0:h.xs)]})]);return{src:u,playlist:d,preview:g}},{cacheKey:([s])=>{var e,t,i,r,n,o,a,A,l,c,h;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)??((h=(c=(l=s==null?void 0:s.answer)==null?void 0:l.media)==null?void 0:c.videos)==null?void 0:h.xs)})}});function bl(s){var e,t,i,r,n,o,a,A,l,c,h,u;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"?"":((u=(h=(c=(l=s==null?void 0:s.answer)==null?void 0:l.contact)==null?void 0:c.client)==null?void 0:h.name)==null?void 0:u.trim())??"",[f,p]=d.split(" ");return{name:d,firstName:f,lastName:p,companyName:g}}const hf=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 To({data:s,rootData:e,index:t},i){var r,n,o,a,A,l,c,h,u,d,g,f,p,y,v,Q,C,w,B,L,_,$,F;const[H,q,Y]=await Promise.all([hf(s,e,t),cf(e),lf({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)??((h=(c=e==null?void 0:e.answer)==null?void 0:c.captions)==null?void 0:h.translation),originalLanguage:(d=(u=e==null?void 0:e.answer)==null?void 0:u.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=bl(e);return{...q,...z,key:H,captions:Y,answerLabel:((y=e==null?void 0:e.answer)==null?void 0:y.label)??(e==null?void 0:e.title),prevAnswerLabel:t?((w=(C=(Q=(v=s==null?void 0:s.questions)==null?void 0:v.items)==null?void 0:Q[t-1])==null?void 0:C.answer)==null?void 0:w.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?((F=($=s==null?void 0:s.questions)==null?void 0:$.items)==null?void 0:F.findIndex(S=>bl(S).name===z.name))===t:!0}}const Xr={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 uf({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,h;const u=(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=(h=(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:h.split("-")[0];return u&&Xr[u]&&!i.find(g=>g.value===u)&&i.push({value:u,label:Xr[u]}),d&&Xr[d]&&!i.find(g=>g.value===d)&&i.push({value:d,label:Xr[d]}),i},[]))??[]}/**
|
|
154
154
|
* @license
|
|
155
155
|
* Copyright 2018 Google LLC
|
|
@@ -149,7 +149,7 @@ ${e}`,dg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),gg=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 Mg(){return new Image}const gl=Ut(async function(e,t=Mg){return e?new Promise((i,r)=>{t().then(n=>{n.onload=()=>{i(n)},n.onerror=o=>{r(o)},n.src=e})}):null});async function Io({element:s,meta:e,imageFactory:t},i,r){var n,o,a;let A={...s};const{node:l}=s;if((l==null?void 0:l.type)==="video"&&((n=l==null?void 0:l.value)!=null&&n.src||(o=l==null?void 0:l.value)!=null&&o.playlist)){const c=await i(l.value,e);let h;try{h=await gl(l.value.poster,t)}catch{h=null}A={...A,node:{...l,video:c,poster:h,meta:await r(l.value,c.node,e)}}}if((l==null?void 0:l.type)==="image"&&l.value){let c;try{c=await gl(l.value,t)}catch{c=null}A={...A,node:{...l,image:c}}}return A.node&&((a=s.node)!=null&&a.elements)&&(A.node.elements=await Promise.all(s.node.elements.map(c=>Io({element:c,meta:e,imageFactory:t},i,r)))),s.elements&&(A.elements=await Promise.all(s.elements.map(c=>Io({element:c,meta:e,imageFactory:t},i,r)))),A}async function Pg(){return document.createElement("canvas")}function Ws(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=Ws(t==null?void 0:t.elements);if(i)return i}}function Og(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 Ug(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 Gg(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 Yr(s){return s.flatMap(e=>Array.isArray(e)?e.flatMap(t=>t):e).reduce((e,t)=>e+t,0)}const Hg=Ut(()=>jA.loadYoga());ao.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${Gg(s)}"`:Ug(s)||Array.isArray(s)?JSON.stringify(s):s);const ns=(s,e,t)=>ao.render(s,e,ao.getConfig({autoEscape:!1,defaultFilter:"parse",...t}));async function os({data:s,template:e,burnCaptions:t=!1,debug:i=!1,imageFactory:r,canvasFactory:n=Pg},o,a,A){var l,c,h,u;const d=await Hg(),g=e??Ng;if(!((l=g.templates)!=null&&l.length))throw new Error(`No templates found for template instance: ${g.id}`);let f=g.templates.find(({version:W})=>W===mo);if(!f){const W=g.templates.map(({version:Y})=>`"${Y}"`).join(", ");console.warn(`Template renderer expects template version "${mo}" but got ${W}`),f=g.templates[g.templates.length-1]}const p=await Promise.all(f.content.map(async({scenes:W,root:Y})=>{const X={...g.options,...s,intro:g.intro,outro:g.outro};async function b(x,U){return Promise.all(W.map(async({layout:S,duration:R,data:T,derived:V,options:O})=>{var q,se,ce;const Ae={...X,_index:U,_root:x,_derived:await o({data:s,rootData:x,index:U})},ye=T?JSON.parse(await ns(T,Ae)):{},pe=V?JSON.parse(await ns(V,Ae)):{},Re=O?JSON.parse(await ns(O,Ae)):{},ne=R?parseFloat(await ns(R,Ae)):NaN,ue=(q=f.layouts.find(Be=>Be.name===S))==null?void 0:q.tree;if(!ue)throw new Error(`Layout tree "${S}" not found in template "${f.id}" layouts.`);const be=JSON.parse(await ns(ue,{...ye,...pe,...Re})),me=await Promise.all(be.flatMap(Be=>Io({element:Be,meta:g.meta,imageFactory:r},a,A))),he=Ws(me);return{duration:(isNaN(ne)?null:ne)??((se=he==null?void 0:he.meta)==null?void 0:se.duration)??0,captions:(ce=he==null?void 0:he.meta)==null?void 0:ce.captions,elements:me}}))}if(Y){const x=JSON.parse(await ns(Y,X));return Array.isArray(x)?Promise.all(x.map(async(U,S)=>b(U,S))):Promise.all([b(x,null)])}return Promise.all([b(s,null)])}));if(p.every(W=>W.every(Y=>Y.every(X=>{const b=Ws(X.elements);return!(b!=null&&b.value.src)&&!(b!=null&&b.value.playlist)})))){const W=p.flatMap(Y=>Y.flatMap(X=>X.map(b=>{const x=Ws(b.elements);return!(x!=null&&x.value.src)&&!(x!=null&&x.value.playlist)&&(x==null?void 0:x.value.id)}).filter(Boolean))).join(", ");throw new Error(`Video(s) with ID ${W} failed to load, video can not be processed`)}if(p.every(W=>W.every(Y=>Y.every(X=>X.duration<=0))))throw new Error("No scenes have any duration, video can not be processed");const Q=p.reduce((W,Y)=>{const X=Y.reduce((b,x)=>{const U=x.filter(S=>S.duration>0);return U.length>0?[...b,U]:b},[]);return X.length>0?[...W,X]:W},[]),C=((c=g.meta)==null?void 0:c.frameRate)??30,w=((h=g.meta)==null?void 0:h.resolution)??1080,B=((u=g.meta)==null?void 0:u.transitionDuration)??1/3,L=Og(Q,B),_=Yr(L),$=await Promise.all(Q.map((W,Y)=>{const X=Yr(L[Y]),b=Yr(L.slice(0,Y));return Promise.all(W.map((x,U)=>Promise.all(x.map(async({duration:S,captions:R,elements:T},V)=>{var O,q;const se=await n(),ce=await n(),Ae=await n(),ye=await n(),pe=Ws(T),Re=Yr([...L.slice(0,Y),...L[Y].slice(0,U),...L[Y][U].slice(0,V)]);return{draw:async({canvas:ue,currentTime:be})=>{const me=Math.max(0,be-b),he=Math.max(0,be-Re);await Eo({yoga:d,debug:i,canvas:ue,cropCanvas:se,posterCanvas:ye,letterboxCanvas:ce,elements:T,currentTime:be,contentTime:me,sceneTime:he,totalDuration:_,contentDuration:X,sceneDuration:S}),R&&t&&Dg({canvas:ue,dx:0,dy:0,dw:ue.width,dh:ue.height,vttCaptions:R,sceneTime:he+((pe==null?void 0:pe.meta.start)??0)})},duration:S,transitionCanvas:Ae,id:Fg(),start:Re,video:pe==null?void 0:pe.video,videoMeta:pe==null?void 0:pe.meta,audio:{duration:S,src:(O=pe==null?void 0:pe.value)==null?void 0:O.src,start:(q=pe==null?void 0:pe.meta)==null?void 0:q.start}}}))))})),F=$.flatMap(W=>W);return{scenes:F.flatMap(W=>W),sections:F,contents:$,frameRate:C,resolution:w,transitionDuration:B,fonts:f.fonts??[],duration:_}}const mo="3",$g={name:"@vouchfor/embeds-legacy",version:"4.0.3",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds-legacy.js",module:"dist/es/embeds-legacy.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds-legacy.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-legacy 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-legacy":"^9.0.0","@vouchfor/media-player-legacy":"^5.0.3",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-legacy":"^2.0.3","@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 Yg(s){const{publicApiUrl:e}=Qr(s),t=Pi();return navigator.sendBeacon(`${e}/api/visitor`,JSON.stringify({visitorId:t})),t}function Kg(s){var n,o,a,A,l,c,h,u,d,g,f,p;if(typeof window>"u")return{client:null,tab:null,request:Pi()};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=Pi();return e||(e=Yg(s),(u=(h=window.localStorage)==null?void 0:h.setItem)==null||u.call(h,"vouch-uid-visitor",e)),t||(t=Pi(),(g=(d=window.localStorage)==null?void 0:d.setItem)==null||g.call(d,"vouch-uid-client",t)),i||(i=Pi(),(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 Vg(s,e){return s&&"vouchId"in s?s.vouchId:(e==null?void 0:e.id)??null}function Jg(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:$g.version,templateVersion:mo,...i}}const fl=1;class Wg{constructor(e){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(t,i)=>{const r=Vg(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}=Qr(this.host.env),{client:i,tab:r,request:n,visitor:o}=Kg(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":Jg(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 Co={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof no<"u"&&no,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(b){return b&&DataView.prototype.isPrototypeOf(b)}if(A.arrayBuffer)var c=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(b){return b&&c.indexOf(Object.prototype.toString.call(b))>-1};function u(b){if(typeof b!="string"&&(b=String(b)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(b)||b==="")throw new TypeError('Invalid character in header field name: "'+b+'"');return b.toLowerCase()}function d(b){return typeof b!="string"&&(b=String(b)),b}function g(b){var x={next:function(){var U=b.shift();return{done:U===void 0,value:U}}};return A.iterable&&(x[Symbol.iterator]=function(){return x}),x}function f(b){this.map={},b instanceof f?b.forEach(function(x,U){this.append(U,x)},this):Array.isArray(b)?b.forEach(function(x){this.append(x[0],x[1])},this):b&&Object.getOwnPropertyNames(b).forEach(function(x){this.append(x,b[x])},this)}f.prototype.append=function(b,x){b=u(b),x=d(x);var U=this.map[b];this.map[b]=U?U+", "+x:x},f.prototype.delete=function(b){delete this.map[u(b)]},f.prototype.get=function(b){return b=u(b),this.has(b)?this.map[b]:null},f.prototype.has=function(b){return this.map.hasOwnProperty(u(b))},f.prototype.set=function(b,x){this.map[u(b)]=d(x)},f.prototype.forEach=function(b,x){for(var U in this.map)this.map.hasOwnProperty(U)&&b.call(x,this.map[U],U,this)},f.prototype.keys=function(){var b=[];return this.forEach(function(x,U){b.push(U)}),g(b)},f.prototype.values=function(){var b=[];return this.forEach(function(x){b.push(x)}),g(b)},f.prototype.entries=function(){var b=[];return this.forEach(function(x,U){b.push([U,x])}),g(b)},A.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function p(b){if(b.bodyUsed)return Promise.reject(new TypeError("Already read"));b.bodyUsed=!0}function y(b){return new Promise(function(x,U){b.onload=function(){x(b.result)},b.onerror=function(){U(b.error)}})}function v(b){var x=new FileReader,U=y(x);return x.readAsArrayBuffer(b),U}function Q(b){var x=new FileReader,U=y(x);return x.readAsText(b),U}function C(b){for(var x=new Uint8Array(b),U=new Array(x.length),S=0;S<x.length;S++)U[S]=String.fromCharCode(x[S]);return U.join("")}function w(b){if(b.slice)return b.slice(0);var x=new Uint8Array(b.byteLength);return x.set(new Uint8Array(b)),x.buffer}function B(){return this.bodyUsed=!1,this._initBody=function(b){this.bodyUsed=this.bodyUsed,this._bodyInit=b,b?typeof b=="string"?this._bodyText=b:A.blob&&Blob.prototype.isPrototypeOf(b)?this._bodyBlob=b:A.formData&&FormData.prototype.isPrototypeOf(b)?this._bodyFormData=b:A.searchParams&&URLSearchParams.prototype.isPrototypeOf(b)?this._bodyText=b.toString():A.arrayBuffer&&A.blob&&l(b)?(this._bodyArrayBuffer=w(b.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(b)||h(b))?this._bodyArrayBuffer=w(b):this._bodyText=b=Object.prototype.toString.call(b):this._bodyText="",this.headers.get("content-type")||(typeof b=="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(b)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},A.blob&&(this.blob=function(){var b=p(this);if(b)return b;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 b=p(this);return b||(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(v)}),this.text=function(){var b=p(this);if(b)return b;if(this._bodyBlob)return Q(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(F)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function _(b){var x=b.toUpperCase();return L.indexOf(x)>-1?x:b}function $(b,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 U=x.body;if(b instanceof $){if(b.bodyUsed)throw new TypeError("Already read");this.url=b.url,this.credentials=b.credentials,x.headers||(this.headers=new f(b.headers)),this.method=b.method,this.mode=b.mode,this.signal=b.signal,!U&&b._bodyInit!=null&&(U=b._bodyInit,b.bodyUsed=!0)}else this.url=String(b);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")&&U)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(U),(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 R=/\?/;this.url+=(R.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}$.prototype.clone=function(){return new $(this,{body:this._bodyInit})};function F(b){var x=new FormData;return b.trim().split("&").forEach(function(U){if(U){var S=U.split("="),R=S.shift().replace(/\+/g," "),T=S.join("=").replace(/\+/g," ");x.append(decodeURIComponent(R),decodeURIComponent(T))}}),x}function H(b){var x=new f,U=b.replace(/\r?\n[\t ]+/g," ");return U.split("\r").map(function(S){return S.indexOf(`
|
|
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 Mg(){return new Image}const gl=Ut(async function(e,t=Mg){return e?new Promise((i,r)=>{t().then(n=>{n.onload=()=>{i(n)},n.onerror=o=>{r(o)},n.src=e})}):null});async function Io({element:s,meta:e,imageFactory:t},i,r){var n,o,a;let A={...s};const{node:l}=s;if((l==null?void 0:l.type)==="video"&&((n=l==null?void 0:l.value)!=null&&n.src||(o=l==null?void 0:l.value)!=null&&o.playlist)){const c=await i(l.value,e);let h;try{h=await gl(l.value.poster,t)}catch{h=null}A={...A,node:{...l,video:c,poster:h,meta:await r(l.value,c.node,e)}}}if((l==null?void 0:l.type)==="image"&&l.value){let c;try{c=await gl(l.value,t)}catch{c=null}A={...A,node:{...l,image:c}}}return A.node&&((a=s.node)!=null&&a.elements)&&(A.node.elements=await Promise.all(s.node.elements.map(c=>Io({element:c,meta:e,imageFactory:t},i,r)))),s.elements&&(A.elements=await Promise.all(s.elements.map(c=>Io({element:c,meta:e,imageFactory:t},i,r)))),A}async function Pg(){return document.createElement("canvas")}function Ws(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=Ws(t==null?void 0:t.elements);if(i)return i}}function Og(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 Ug(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 Gg(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 Yr(s){return s.flatMap(e=>Array.isArray(e)?e.flatMap(t=>t):e).reduce((e,t)=>e+t,0)}const Hg=Ut(()=>jA.loadYoga());ao.filters.define("parse",s=>typeof s>"u"?null:typeof s=="string"?`"${Gg(s)}"`:Ug(s)||Array.isArray(s)?JSON.stringify(s):s);const ns=(s,e,t)=>ao.render(s,e,ao.getConfig({autoEscape:!1,defaultFilter:"parse",...t}));async function os({data:s,template:e,burnCaptions:t=!1,debug:i=!1,imageFactory:r,canvasFactory:n=Pg},o,a,A){var l,c,h,u;const d=await Hg(),g=e??Ng;if(!((l=g.templates)!=null&&l.length))throw new Error(`No templates found for template instance: ${g.id}`);let f=g.templates.find(({version:W})=>W===mo);if(!f){const W=g.templates.map(({version:Y})=>`"${Y}"`).join(", ");console.warn(`Template renderer expects template version "${mo}" but got ${W}`),f=g.templates[g.templates.length-1]}const p=await Promise.all(f.content.map(async({scenes:W,root:Y})=>{const X={...g.options,...s,intro:g.intro,outro:g.outro};async function b(x,U){return Promise.all(W.map(async({layout:S,duration:R,data:T,derived:V,options:O})=>{var q,se,ce;const Ae={...X,_index:U,_root:x,_derived:await o({data:s,rootData:x,index:U})},ye=T?JSON.parse(await ns(T,Ae)):{},pe=V?JSON.parse(await ns(V,Ae)):{},Re=O?JSON.parse(await ns(O,Ae)):{},ne=R?parseFloat(await ns(R,Ae)):NaN,ue=(q=f.layouts.find(Be=>Be.name===S))==null?void 0:q.tree;if(!ue)throw new Error(`Layout tree "${S}" not found in template "${f.id}" layouts.`);const be=JSON.parse(await ns(ue,{...ye,...pe,...Re})),me=await Promise.all(be.flatMap(Be=>Io({element:Be,meta:g.meta,imageFactory:r},a,A))),he=Ws(me);return{duration:(isNaN(ne)?null:ne)??((se=he==null?void 0:he.meta)==null?void 0:se.duration)??0,captions:(ce=he==null?void 0:he.meta)==null?void 0:ce.captions,elements:me}}))}if(Y){const x=JSON.parse(await ns(Y,X));return Array.isArray(x)?Promise.all(x.map(async(U,S)=>b(U,S))):Promise.all([b(x,null)])}return Promise.all([b(s,null)])}));if(p.every(W=>W.every(Y=>Y.every(X=>{const b=Ws(X.elements);return!(b!=null&&b.value.src)&&!(b!=null&&b.value.playlist)})))){const W=p.flatMap(Y=>Y.flatMap(X=>X.map(b=>{const x=Ws(b.elements);return!(x!=null&&x.value.src)&&!(x!=null&&x.value.playlist)&&(x==null?void 0:x.value.id)}).filter(Boolean))).join(", ");throw new Error(`Video(s) with ID ${W} failed to load, video can not be processed`)}if(p.every(W=>W.every(Y=>Y.every(X=>X.duration<=0))))throw new Error("No scenes have any duration, video can not be processed");const Q=p.reduce((W,Y)=>{const X=Y.reduce((b,x)=>{const U=x.filter(S=>S.duration>0);return U.length>0?[...b,U]:b},[]);return X.length>0?[...W,X]:W},[]),C=((c=g.meta)==null?void 0:c.frameRate)??30,w=((h=g.meta)==null?void 0:h.resolution)??1080,B=((u=g.meta)==null?void 0:u.transitionDuration)??1/3,L=Og(Q,B),_=Yr(L),$=await Promise.all(Q.map((W,Y)=>{const X=Yr(L[Y]),b=Yr(L.slice(0,Y));return Promise.all(W.map((x,U)=>Promise.all(x.map(async({duration:S,captions:R,elements:T},V)=>{var O,q;const se=await n(),ce=await n(),Ae=await n(),ye=await n(),pe=Ws(T),Re=Yr([...L.slice(0,Y),...L[Y].slice(0,U),...L[Y][U].slice(0,V)]);return{draw:async({canvas:ue,currentTime:be})=>{const me=Math.max(0,be-b),he=Math.max(0,be-Re);await Eo({yoga:d,debug:i,canvas:ue,cropCanvas:se,posterCanvas:ye,letterboxCanvas:ce,elements:T,currentTime:be,contentTime:me,sceneTime:he,totalDuration:_,contentDuration:X,sceneDuration:S}),R&&t&&Dg({canvas:ue,dx:0,dy:0,dw:ue.width,dh:ue.height,vttCaptions:R,sceneTime:he+((pe==null?void 0:pe.meta.start)??0)})},duration:S,transitionCanvas:Ae,id:Fg(),start:Re,video:pe==null?void 0:pe.video,videoMeta:pe==null?void 0:pe.meta,audio:{duration:S,src:(O=pe==null?void 0:pe.value)==null?void 0:O.src,start:(q=pe==null?void 0:pe.meta)==null?void 0:q.start}}}))))})),F=$.flatMap(W=>W);return{scenes:F.flatMap(W=>W),sections:F,contents:$,frameRate:C,resolution:w,transitionDuration:B,fonts:f.fonts??[],duration:_}}const mo="3",$g={name:"@vouchfor/embeds-legacy",version:"4.0.4",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds-legacy.js",module:"dist/es/embeds-legacy.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds-legacy.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-legacy 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-legacy":"^9.0.0","@vouchfor/media-player-legacy":"^5.0.4",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.5.8","@storybook/addon-links":"^8.5.8","@storybook/blocks":"^8.5.8","@storybook/web-components":"^8.5.8","@storybook/web-components-vite":"^8.5.8","@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-legacy":"^2.0.3","@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.5.8",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 Yg(s){const{publicApiUrl:e}=Qr(s),t=Pi();return navigator.sendBeacon(`${e}/api/visitor`,JSON.stringify({visitorId:t})),t}function Kg(s){var n,o,a,A,l,c,h,u,d,g,f,p;if(typeof window>"u")return{client:null,tab:null,request:Pi()};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=Pi();return e||(e=Yg(s),(u=(h=window.localStorage)==null?void 0:h.setItem)==null||u.call(h,"vouch-uid-visitor",e)),t||(t=Pi(),(g=(d=window.localStorage)==null?void 0:d.setItem)==null||g.call(d,"vouch-uid-client",t)),i||(i=Pi(),(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 Vg(s,e){return s&&"vouchId"in s?s.vouchId:(e==null?void 0:e.id)??null}function Jg(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:$g.version,templateVersion:mo,...i}}const fl=1;class Wg{constructor(e){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(t,i)=>{const r=Vg(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}=Qr(this.host.env),{client:i,tab:r,request:n,visitor:o}=Kg(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":Jg(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 Co={exports:{}};(function(s,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof no<"u"&&no,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(b){return b&&DataView.prototype.isPrototypeOf(b)}if(A.arrayBuffer)var c=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(b){return b&&c.indexOf(Object.prototype.toString.call(b))>-1};function u(b){if(typeof b!="string"&&(b=String(b)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(b)||b==="")throw new TypeError('Invalid character in header field name: "'+b+'"');return b.toLowerCase()}function d(b){return typeof b!="string"&&(b=String(b)),b}function g(b){var x={next:function(){var U=b.shift();return{done:U===void 0,value:U}}};return A.iterable&&(x[Symbol.iterator]=function(){return x}),x}function f(b){this.map={},b instanceof f?b.forEach(function(x,U){this.append(U,x)},this):Array.isArray(b)?b.forEach(function(x){this.append(x[0],x[1])},this):b&&Object.getOwnPropertyNames(b).forEach(function(x){this.append(x,b[x])},this)}f.prototype.append=function(b,x){b=u(b),x=d(x);var U=this.map[b];this.map[b]=U?U+", "+x:x},f.prototype.delete=function(b){delete this.map[u(b)]},f.prototype.get=function(b){return b=u(b),this.has(b)?this.map[b]:null},f.prototype.has=function(b){return this.map.hasOwnProperty(u(b))},f.prototype.set=function(b,x){this.map[u(b)]=d(x)},f.prototype.forEach=function(b,x){for(var U in this.map)this.map.hasOwnProperty(U)&&b.call(x,this.map[U],U,this)},f.prototype.keys=function(){var b=[];return this.forEach(function(x,U){b.push(U)}),g(b)},f.prototype.values=function(){var b=[];return this.forEach(function(x){b.push(x)}),g(b)},f.prototype.entries=function(){var b=[];return this.forEach(function(x,U){b.push([U,x])}),g(b)},A.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function p(b){if(b.bodyUsed)return Promise.reject(new TypeError("Already read"));b.bodyUsed=!0}function y(b){return new Promise(function(x,U){b.onload=function(){x(b.result)},b.onerror=function(){U(b.error)}})}function v(b){var x=new FileReader,U=y(x);return x.readAsArrayBuffer(b),U}function Q(b){var x=new FileReader,U=y(x);return x.readAsText(b),U}function C(b){for(var x=new Uint8Array(b),U=new Array(x.length),S=0;S<x.length;S++)U[S]=String.fromCharCode(x[S]);return U.join("")}function w(b){if(b.slice)return b.slice(0);var x=new Uint8Array(b.byteLength);return x.set(new Uint8Array(b)),x.buffer}function B(){return this.bodyUsed=!1,this._initBody=function(b){this.bodyUsed=this.bodyUsed,this._bodyInit=b,b?typeof b=="string"?this._bodyText=b:A.blob&&Blob.prototype.isPrototypeOf(b)?this._bodyBlob=b:A.formData&&FormData.prototype.isPrototypeOf(b)?this._bodyFormData=b:A.searchParams&&URLSearchParams.prototype.isPrototypeOf(b)?this._bodyText=b.toString():A.arrayBuffer&&A.blob&&l(b)?(this._bodyArrayBuffer=w(b.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):A.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(b)||h(b))?this._bodyArrayBuffer=w(b):this._bodyText=b=Object.prototype.toString.call(b):this._bodyText="",this.headers.get("content-type")||(typeof b=="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(b)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},A.blob&&(this.blob=function(){var b=p(this);if(b)return b;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 b=p(this);return b||(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(v)}),this.text=function(){var b=p(this);if(b)return b;if(this._bodyBlob)return Q(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(F)}),this.json=function(){return this.text().then(JSON.parse)},this}var L=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function _(b){var x=b.toUpperCase();return L.indexOf(x)>-1?x:b}function $(b,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 U=x.body;if(b instanceof $){if(b.bodyUsed)throw new TypeError("Already read");this.url=b.url,this.credentials=b.credentials,x.headers||(this.headers=new f(b.headers)),this.method=b.method,this.mode=b.mode,this.signal=b.signal,!U&&b._bodyInit!=null&&(U=b._bodyInit,b.bodyUsed=!0)}else this.url=String(b);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")&&U)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(U),(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 R=/\?/;this.url+=(R.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}$.prototype.clone=function(){return new $(this,{body:this._bodyInit})};function F(b){var x=new FormData;return b.trim().split("&").forEach(function(U){if(U){var S=U.split("="),R=S.shift().replace(/\+/g," "),T=S.join("=").replace(/\+/g," ");x.append(decodeURIComponent(R),decodeURIComponent(T))}}),x}function H(b){var x=new f,U=b.replace(/\r?\n[\t ]+/g," ");return U.split("\r").map(function(S){return S.indexOf(`
|
|
153
153
|
`)===0?S.substr(1,S.length):S}).forEach(function(S){var R=S.split(":"),T=R.shift().trim();if(T){var V=R.join(":").trim();x.append(T,V)}}),x}B.call($.prototype);function W(b,x){if(!(this instanceof W))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(b)}B.call(W.prototype),W.prototype.clone=function(){return new W(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},W.error=function(){var b=new W(null,{status:0,statusText:""});return b.type="error",b};var Y=[301,302,303,307,308];W.redirect=function(b,x){if(Y.indexOf(x)===-1)throw new RangeError("Invalid status code");return new W(null,{status:x,headers:{location:b}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(x,U){this.message=x,this.name=U;var S=Error(x);this.stack=S.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function X(b,x){return new Promise(function(U,S){var R=new $(b,x);if(R.signal&&R.signal.aborted)return S(new o.DOMException("Aborted","AbortError"));var T=new XMLHttpRequest;function V(){T.abort()}T.onload=function(){var q={status:T.status,statusText:T.statusText,headers:H(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(){U(new W(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 O(q){try{return q===""&&a.location.href?a.location.href:q}catch{return q}}T.open(R.method,O(R.url),!0),R.credentials==="include"?T.withCredentials=!0:R.credentials==="omit"&&(T.withCredentials=!1),"responseType"in T&&(A.blob?T.responseType="blob":A.arrayBuffer&&R.headers.get("Content-Type")&&R.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]))}):R.headers.forEach(function(q,se){T.setRequestHeader(se,q)}),R.signal&&(R.signal.addEventListener("abort",V),T.onreadystatechange=function(){T.readyState===4&&R.signal.removeEventListener("abort",V)}),T.send(typeof R._bodyInit>"u"?null:R._bodyInit)})}return X.polyfill=!0,a.fetch||(a.fetch=X,a.Headers=f,a.Request=$,a.Response=W),o.Headers=f,o.Request=$,o.Response=W,o.fetch=X,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})(Co,Co.exports);var qg=Co.exports;const pl=Ag(qg);async function jg(s){var e;try{if((e=await pl(s,{method:"HEAD"}))!=null&&e.ok)return s}catch{return}}async function yo({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=>jg(o));e=(await Promise.all(n)).find(Boolean)}return e}async function Xg(s){try{return(await pl(s)).text()}catch{return null}}async function zg(s){return s=s.trim(),s.startsWith("http")||s.startsWith("blob:")?Xg(s):s}const Zg=Ut(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?zg(A):null},{cacheKey:([s,{language:e}])=>JSON.stringify({...s,language:e})}),ef=Ut(async s=>{var e,t,i,r,n,o,a,A,l,c,h;const[u,d,g]=await Promise.all([yo({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]}),yo({sources:[(o=(n=s==null?void 0:s.answer)==null?void 0:n.media)==null?void 0:o.playlist]}),yo({sources:[((A=(a=s==null?void 0:s.answer)==null?void 0:a.media)==null?void 0:A.reducedQuality)??((h=(c=(l=s==null?void 0:s.answer)==null?void 0:l.media)==null?void 0:c.videos)==null?void 0:h.xs)]})]);return{src:u,playlist:d,preview:g}},{cacheKey:([s])=>{var e,t,i,r,n,o,a,A,l,c,h;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)??((h=(c=(l=s==null?void 0:s.answer)==null?void 0:l.media)==null?void 0:c.videos)==null?void 0:h.xs)})}});function El(s){var e,t,i,r,n,o,a,A,l,c,h,u;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"?"":((u=(h=(c=(l=s==null?void 0:s.answer)==null?void 0:l.contact)==null?void 0:c.client)==null?void 0:h.name)==null?void 0:u.trim())??"",[f,p]=d.split(" ");return{name:d,firstName:f,lastName:p,companyName:g}}const tf=Ut(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 vo({data:s,rootData:e,index:t},i){var r,n,o,a,A,l,c,h,u,d,g,f,p,y,v,Q,C,w,B,L,_,$,F;const[H,W,Y]=await Promise.all([tf(s,e,t),ef(e),Zg({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)??((h=(c=e==null?void 0:e.answer)==null?void 0:c.captions)==null?void 0:h.translation),originalLanguage:(d=(u=e==null?void 0:e.answer)==null?void 0:u.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)]),X=El(e);return{...W,...X,key:H,captions:Y,answerLabel:((y=e==null?void 0:e.answer)==null?void 0:y.label)??(e==null?void 0:e.title),prevAnswerLabel:t?((w=(C=(Q=(v=s==null?void 0:s.questions)==null?void 0:v.items)==null?void 0:Q[t-1])==null?void 0:C.answer)==null?void 0:w.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?((F=($=s==null?void 0:s.questions)==null?void 0:$.items)==null?void 0:F.findIndex(b=>El(b).name===X.name))===t:!0}}const Kr={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 sf({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,h;const u=(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=(h=(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:h.split("-")[0];return u&&Kr[u]&&!i.find(g=>g.value===u)&&i.push({value:u,label:Kr[u]}),d&&Kr[d]&&!i.find(g=>g.value===d)&&i.push({value:d,label:Kr[d]}),i},[]))??[]}/**
|
|
154
154
|
* @license
|
|
155
155
|
* Copyright 2018 Google LLC
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vouchfor/embeds-legacy",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Aaron Williams",
|
|
6
6
|
"main": "dist/es/embeds-legacy.js",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@a11y/focus-trap": "^1.0.5",
|
|
48
48
|
"@lit/task": "^1.0.0",
|
|
49
49
|
"@vouchfor/canvas-video-legacy": "^9.0.0",
|
|
50
|
-
"@vouchfor/media-player-legacy": "^5.0.
|
|
50
|
+
"@vouchfor/media-player-legacy": "^5.0.4",
|
|
51
51
|
"uuid": "^9.0.1"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
@@ -56,11 +56,11 @@
|
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@esm-bundle/chai": "^4.3.4-fix.0",
|
|
58
58
|
"@open-wc/testing": "^4.0.0",
|
|
59
|
-
"@storybook/addon-essentials": "^8.
|
|
60
|
-
"@storybook/addon-links": "^8.
|
|
61
|
-
"@storybook/blocks": "^8.
|
|
62
|
-
"@storybook/web-components": "^8.
|
|
63
|
-
"@storybook/web-components-vite": "^8.
|
|
59
|
+
"@storybook/addon-essentials": "^8.5.8",
|
|
60
|
+
"@storybook/addon-links": "^8.5.8",
|
|
61
|
+
"@storybook/blocks": "^8.5.8",
|
|
62
|
+
"@storybook/web-components": "^8.5.8",
|
|
63
|
+
"@storybook/web-components-vite": "^8.5.8",
|
|
64
64
|
"@svgr/core": "^8.1.0",
|
|
65
65
|
"@types/flat": "^5.0.5",
|
|
66
66
|
"@types/mocha": "^10.0.6",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"react-dom": "^18.2.0",
|
|
81
81
|
"rollup-plugin-tla": "^0.0.2",
|
|
82
82
|
"sinon": "^17.0.1",
|
|
83
|
-
"storybook": "^8.
|
|
83
|
+
"storybook": "^8.5.8",
|
|
84
84
|
"svgson": "^5.3.1",
|
|
85
85
|
"typescript": "^5.4.3",
|
|
86
86
|
"vite": "^5.2.2",
|