snippet.js 9.9 KB

1
  1. (()=>{var e,t,r={271:e=>{function t(e){const t=document.createElement("a");return t.href=e,t.search.split("?")[1]||""}e.exports={getQueryParamsString:t,parseUrlParams:function(e){const r=t(e);return""===r?{}:r.split("&").reduce((function(e,t){const r=t.split("=");return e[r[0]]=decodeURIComponent(r[1]),e}),{})},loadScript:function(e,t=(()=>{})){const r=document.createElement("script");r.type="text/javascript",r.onerror=function(){t(new Error("Script failed to load"))},r.readyState?r.onreadystatechange=function(){"loaded"!==r.readyState&&"complete"!==r.readyState||(r.onreadystatechange=null,t())}:r.onload=function(){t()},r.src=e,document.getElementsByTagName("head")[0].appendChild(r)}}}},n={};function s(e){var t=n[e];if(void 0!==t)return t.exports;var o=n[e]={id:e,loaded:!1,exports:{}};return r[e](o,o.exports,s),o.loaded=!0,o.exports}s.m=r,s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce(((t,r)=>(s.f[r](e,t),t)),[])),s.u=e=>"sentry-browser.min.js",s.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="asset_composer:",s.l=(r,n,o,i)=>{if(e[r])e[r].push(n);else{var a,c;if(void 0!==o)for(var d=document.getElementsByTagName("script"),u=0;u<d.length;u++){var p=d[u];if(p.getAttribute("src")==r||p.getAttribute("data-webpack")==t+o){a=p;break}}a||(c=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,s.nc&&a.setAttribute("nonce",s.nc),a.setAttribute("data-webpack",t+o),a.src=r),e[r]=[n];var l=(t,n)=>{a.onerror=a.onload=null,clearTimeout(h);var s=e[r];if(delete e[r],a.parentNode&&a.parentNode.removeChild(a),s&&s.forEach((e=>e(n))),t)return t(n)},h=setTimeout(l.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=l.bind(null,a.onerror),a.onload=l.bind(null,a.onload),c&&document.head.appendChild(a)}},s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.p="https://static.zdassets.com/ekr/",(()=>{var e={11:0};s.f.j=(t,r)=>{var n=s.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var o=new Promise(((r,s)=>n=e[t]=[r,s]));r.push(n[2]=o);var i=s.p+s.u(t),a=new Error;s.l(i,(r=>{if(s.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var o=r&&("load"===r.type?"missing":r.type),i=r&&r.target&&r.target.src;a.message="Loading chunk "+t+" failed.\n("+o+": "+i+")",a.name="ChunkLoadError",a.type=o,a.request=i,n[1](a)}}),"chunk-"+t,t)}};var t=(t,r)=>{var n,o,[i,a,c]=r,d=0;if(i.some((t=>0!==e[t]))){for(n in a)s.o(a,n)&&(s.m[n]=a[n]);c&&c(s)}for(t&&t(r);d<i.length;d++)o=i[d],s.o(e,o)&&e[o]&&e[o][0](),e[o]=0},r=globalThis.zEWebpackACJsonp=globalThis.zEWebpackACJsonp||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})(),(()=>{"use strict";class e{constructor(e="",t={},r=!1){this.message=e,this.props=t,this.error=Error(this.message),this.isUserError=r,this.fingerprint=this.message}}const t={},r={},n={};class o{constructor(e,t){this.name=e.name,this.id=e.id,this.features=e.features,this.bootstrap=e.bootstrap,this.win=t,this.doc=t.document}ready(){return new Promise(((e,t)=>{this.createIframeElement().then((r=>{r.addEventListener("load",(()=>{const{contentWindow:n}=r;n&&n.document?e(n.document):t(this.error())})),r.src="about:blank",this.doc.body.appendChild(r)}))}))}injectMetadata(e,t){e&&(e.zendesk={[this.name]:{id:this.id,features:this.features,bootstrap:this.bootstrap}},Object&&Object.freeze&&this.deepFreeze(e.zendesk),e.zEQueue=t)}deepFreeze(e){return Object.freeze(e),void 0===e||Object.getOwnPropertyNames(e).forEach((t=>{null===e[t]||"object"!=typeof e[t]&&"function"!=typeof e[t]||Object.isFrozen(e[t])||this.deepFreeze(e[t])})),e}injectAssets(e,t){if(!e)return;const r=e.getElementsByTagName("head")[0];t.scripts.forEach((t=>{r.appendChild(this.createScriptElement(e,t.src))}))}parentDocumentReady(){return new Promise(((t,r)=>{"loading"!==this.doc.readyState&&this.doc.body?t():this.doc.addEventListener("DOMContentLoaded",(()=>{const{body:n}=this.doc;n?t():r(new e("host page document.body not available"))}))}))}createIframeElement(){return this.parentDocumentReady().then((()=>{const e=this.doc.createElement("iframe");return e.dataset.product=this.name,e.title="No content",e.role="presentation",e.tabIndex=-1,e.allow="microphone *",e.setAttribute("aria-hidden",!0),e.style.cssText="width: 0; height: 0; border: 0; position: absolute; top: -9999px",e}))}createScriptElement(e,t){if(!e)return null;const r=e.createElement("script");return r.type="text/javascript",r.src=t,r}error(){const t={product:this.name,id:this.id,features:this.features};return new e("iframe document not available to load product",t)}}class i{constructor(e,t){this.product=e,this.productIframe=new o(this.product,t)}getProductAssets(e=!1){return e?n[this.product.name].assets:this.product.assets}load(e,t){return this.productIframe.ready().then((r=>{this.productIframe.injectMetadata(r,t),this.productIframe.injectAssets(r,e)})).catch((()=>Promise.reject(this.loadProductError())))}loadProductError(){const{name:t,id:r,features:n}=this.product;return new e("failed to load product",{product:t,id:r,features:n})}}var a=s(271);class c{constructor(e,t){this.zopimKey=e,this.win=t,this.doc=t.document}getProductAssets(){return{zopimSrc:`https://v2.zopim.com/w?${this.zopimKey}`}}load(e){return new Promise(((t,r)=>{try{(0,a.loadScript)(e.zopimSrc),t()}catch(e){r(e)}}))}}const d="__zE_ac_version";class u{constructor(e,t){this.version=this.getVersion(e),this.baseUrl=`https://ekr.zdassets.com/compose/${t}`,this.snippetKey=t}resolveComposeUrl(e=!1){let t=this.baseUrl;return this.version&&(t+=`?${this.getSerializedVersionQueryParam()}`,this.displayWarning()),decodeURI(t)}displayWarning(){console.warn(`You are loading ${this.version.name} version ${this.version.string}`)}getSerializedVersionQueryParam(){return`${d}=${this.version.name}/${this.version.string}`}getVersion(e){let t;try{t=e.localStorage.getItem("ZD-ac-version")}catch{}const r=(0,a.parseUrlParams)(e.location.href)[d]||t;if(r){const e=r.split("/");if(this.validVersion(e[1]))return{name:e[0],string:e[1]}}return null}validVersion(e){return e&&/^\w+$/.test(e)}}class p{constructor(e){this.snippet=e}getProducts(e,n=!1){return new Promise(((s,o)=>{const i=this.snippet.getParentWindow();if(n)i.zEACLoaded=!0,i.$zopim?s(r.products):s(t.products);else{const t=t=>{200===t.status?t.json().then((({products:e})=>{i.zEACLoaded=!0,s(e)})).catch((()=>o(this.error(e)))):o(this.error(e))},r=new u(i,e).resolveComposeUrl();fetch(r).then(t).catch((()=>o(this.error(e))))}}))}loadProducts(e,t=!1){return e.map((e=>{const r=e.getProductAssets(t);return e.load(r,this.snippet.getZEQueue()).catch((e=>Promise.reject(e)))}))}getProductLoaders(e){const t=this.snippet.getParentWindow();return e.map((e=>"zopim_chat"===e.name?new c(e.id,t):new i(e,t)))}error(t){return new e("compose request failed",{key:t})}}class l{constructor(e){this.win=e,this.doc=e.document}getKey(){return new Promise(((t,r)=>r(new e("Key is missing from snippet",{},!0))))}getZEQueue(){return null}getParentWindow(){return this.win}}class h extends l{getKey(){return new Promise(((t,r)=>{const{zendeskHost:n}=this.doc;return n?this._isHostMapped(n)?fetch(`https://${n}/embeddable/zendesk_host`).then((n=>{200===n.status?n.json().then((e=>{t(`web_widget/${e.zendesk_host}`)})).catch((t=>r(new e(t.message)))):r(new e("zendesk_host request failed"))})).catch((t=>r(new e(t.message)))):t(`web_widget/${n}`):r(Error("Zendesk host is not defined"))}))}getZEQueue(){return this.doc.zEQueue}getParentWindow(){return this.win.parent}_isHostMapped(e){return-1===e.indexOf(".zendesk.com")&&-1===e.indexOf(".zendesk-staging.com")}}class m extends l{static isSnippetPresent(e){return e.document.getElementById("ze-snippet")}getKey(){return new Promise(((t,r)=>{const n=this._getScript(this.win.zE);if(n){const e=(0,a.parseUrlParams)(n.src);if(e&&e.key)return t(e.key)}return r(new e("Key is missing from snippet",{},!0))}))}getZEQueue(){return this.win.zE._}_getScript(e){return m.isSnippetPresent(this.win)||(e&&e.s?e.s:void 0)}}class g extends l{getKey(){return new Promise(((e,t)=>e(`zopim_chat/${(0,a.getQueryParamsString)(g.getScriptSrc(this.win))}`)))}static getScriptSrc(e){if(e.$zopim&&e.$zopim.s)return e.$zopim.s.src;const t=document.getElementsByTagName("script"),r=/.*zopim.(com|net|org)\//;let n;for(let e=0,s=t.length;e<s;e++)if(n=t[e].src||"",r.test(n))return n}static isSnippetPresent(e){return!!g.getScriptSrc(e)}}let f=null;const w={autoSessionTracking:!1,enabled:!window.zESettings||void 0===window.zESettings.errorReporting||Boolean(window.zESettings.errorReporting),dsn:"https://872255ec19884ba7a0c81c005eef1913@zendesk-eu.my.sentry.io/41",environment:"production",release:"asset-composer@v71",sampleRate:.001,defaultIntegrations:!1},y=()=>new Promise((e=>{f?e(f):s.e(996).then(s.bind(s,858)).then((t=>{const{BrowserClient:r,makeFetchTransport:n,defaultStackParser:s,Hub:o,Integrations:i}=t,a=new r({...w,integrations:[new i.InboundFilters,new i.FunctionToString,new i.HttpContext],transport:n,stackParser:s});f=new o(a),e(f)}))}));function b(t){return t&&t instanceof e?y().then((e=>{e.withScope((r=>{t.fingerprint&&r.setFingerprint(t.fingerprint),r.setLevel("warning"),e.captureException(t.error)})),window.console&&t.isUserError&&window.console.error(t.message)})):y().then((e=>{e.captureException(t)}))}!function(){try{if("function"!=typeof window.zE){const e=function(){const e=[],t=function(){e.push(arguments)};return t._=e,t.t=Date.now(),t}();window.zE=e,window.zEmbed=e}if(window.zEACLoaded)return;const e=function(e){return m.isSnippetPresent(e)?new m(e):e.document.zendeskHost&&e.document.zEQueue?new h(e):g.isSnippetPresent(e)?new g(e):new m(e)}(window),t=new p(e),r=!1;e.getKey().then((e=>t.getProducts(e,r))).then((e=>{if(e&&e.length)return Promise.all(t.loadProducts(t.getProductLoaders(e),r))})).catch((e=>b(e)))}catch(e){b(e)}}()})()})();