@commversion/libs 0.18.4 → 0.18.5

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.
@@ -1 +1 @@
1
- (function(){function e(t){"@babel/helpers - typeof";return e=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},e(t)}function t(t,n){if(e(t)!=`object`||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var i=r.call(t,n||`default`);if(e(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(t)}function n(n){var r=t(n,`string`);return e(r)==`symbol`?r:r+``}function r(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?i(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var o=class e{constructor(e={}){r(this,`dependencies`,void 0),this.dependencies=e}provide(t){return new e(a(a({},this.dependencies),t(this.dependencies)))}},s=class e{constructor(e,t,n,i,a,o){r(this,`bus`,void 0),r(this,`pageData`,void 0),r(this,`registry`,void 0),r(this,`channelClick`,void 0),r(this,`exitIntent`,void 0),r(this,`form`,void 0),this.bus=e,this.pageData=t,this.registry=n,this.channelClick=i,this.exitIntent=a,this.form=o}static build(t){let{bus:n,pageData:r,registry:i,channelClick:a,exitIntent:o,form:s}=t;return{app:new e(n,r,i,a,o,s)}}init(){this.pageData.init(),this.registry.init(),this.channelClick.init(),this.exitIntent.init(),this.form.init(),this.bus.dispatch(`commversion:attribution-ready`,{})}destroy(){this.registry.destroy(),this.channelClick.destroy(),this.exitIntent.destroy(),this.form.destroy()}},c=class e{constructor(e){r(this,`target`,void 0),this.target=e}on(e,t){let n=e=>{e instanceof CustomEvent&&t(e.detail)};return this.target.addEventListener(e,n),()=>this.target.removeEventListener(e,n)}dispatch(e,t){this.target.dispatchEvent(new CustomEvent(e,{detail:t}))}static build(){return{bus:new e(window)}}},l=class e{constructor(e,t){r(this,`bus`,void 0),r(this,`registry`,void 0),r(this,`unsubscribe`,void 0),this.bus=e,this.registry=t}static build(t){let{bus:n,registry:r}=t;return{channelClick:new e(n,r)}}init(){this.unsubscribe=this.bus.on(`commversion:channel-clicked`,({channel:e})=>{let{sessionVariables:t}=window.LiveChatWidget.get(`customer_data`);this.registry.patchOne(e,{chat_start_url:window.location.href,chat_start_time:new Date().toISOString(),session_variables:t})})}destroy(){var e;(e=this.unsubscribe)==null||e.call(this),this.unsubscribe=void 0}},u=class e{constructor(e,t,n){r(this,`registry`,void 0),r(this,`debounceMs`,void 0),r(this,`margin`,void 0),r(this,`isMouseInside`,!0),r(this,`leaveTimeout`,void 0),r(this,`onMouseEnter`,()=>{this.registry.patchAll({exit_intent:!1})}),r(this,`onMouseLeave`,()=>{this.isBrowsing()&&this.registry.patchAll({exit_intent:!0})}),r(this,`onMouseMove`,e=>{this.checkBounds(e.clientX,e.clientY)?this.isMouseInside?(clearTimeout(this.leaveTimeout),this.leaveTimeout=void 0):(this.isMouseInside=!0,this.registry.patchAll({exit_intent:!1})):this.isMouseInside&&(this.isMouseInside=!1,this.leaveTimeout=setTimeout(()=>{this.leaveTimeout=void 0,this.isBrowsing()&&this.registry.patchAll({exit_intent:!0})},this.debounceMs))}),this.registry=e,this.debounceMs=t,this.margin=n}init(){window.addEventListener(`mouseenter`,this.onMouseEnter),window.addEventListener(`mouseleave`,this.onMouseLeave),window.addEventListener(`mousemove`,this.onMouseMove)}static build(t){let{registry:n,config:r}=t,{exitIntentDebounceMs:i=1500,exitIntentMargin:a=10}=r;return{exitIntent:new e(n,i,a)}}destroy(){window.removeEventListener(`mouseenter`,this.onMouseEnter),window.removeEventListener(`mouseleave`,this.onMouseLeave),window.removeEventListener(`mousemove`,this.onMouseMove)}checkBounds(e,t){let n=window.innerWidth,r=window.innerHeight;return e>=this.margin&&e<=n-this.margin&&t>=this.margin&&t<=r-this.margin}isBrowsing(){try{return window.LiveChatWidget.get(`customer_data`).status===`browsing`}catch(e){return!1}}},d=class e{constructor(e,t,n,i){r(this,`registry`,void 0),r(this,`abandonmentSelector`,void 0),r(this,`abandonmentDelaySeconds`,void 0),r(this,`submissionSelector`,void 0),r(this,`formAbandonmentTimeout`,void 0),r(this,`abandonmentForms`,void 0),r(this,`submissionForms`,void 0),r(this,`inputs`,void 0),r(this,`onChange`,()=>{clearTimeout(this.formAbandonmentTimeout),this.formAbandonmentTimeout=setTimeout(()=>{this.registry.patchAll({form_abandoned:!0})},this.abandonmentDelaySeconds*1e3)}),r(this,`onAbandonmentFormSubmit`,()=>{clearTimeout(this.formAbandonmentTimeout)}),r(this,`onSubmit`,()=>{this.registry.patchAll({form_submission:!0})}),r(this,`onInvalid`,()=>{this.registry.patchAll({input_error:!0})}),this.registry=e,this.abandonmentSelector=t,this.abandonmentDelaySeconds=n,this.submissionSelector=i}static build(t){let{registry:n,config:r}=t,{formAbandonmentSelector:i=`form`,formAbandonmentDelay:a=10,formSubmissionSelector:o=`form`}=r;return{form:new e(n,i,a,o)}}init(){this.abandonmentForms=document.querySelectorAll(this.abandonmentSelector),this.submissionForms=document.querySelectorAll(this.submissionSelector),this.inputs=document.querySelectorAll(`input`);for(let e of this.abandonmentForms)e.addEventListener(`change`,this.onChange),e.addEventListener(`submit`,this.onAbandonmentFormSubmit);for(let e of this.submissionForms)e.addEventListener(`submit`,this.onSubmit);for(let e of this.inputs)e.addEventListener(`invalid`,this.onInvalid)}destroy(){var e,t,n;for(let t of(e=this.abandonmentForms)==null?[]:e)t.removeEventListener(`change`,this.onChange),t.removeEventListener(`submit`,this.onAbandonmentFormSubmit);for(let e of(t=this.submissionForms)==null?[]:t)e.removeEventListener(`submit`,this.onSubmit);for(let e of(n=this.inputs)==null?[]:n)e.removeEventListener(`invalid`,this.onInvalid)}};function f(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function p(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){f(a,r,i,o,s,`next`,e)}function s(e){f(a,r,i,o,s,`throw`,e)}o(void 0)})}}var m=class e{constructor(e){r(this,`url`,void 0),this.url=e}static build(t){let{url:n}=t;return{http:new e(n)}}post(e){var t=this;return p(function*(){let n=yield fetch(t.url,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!n.ok)throw Error(`POST ${t.url} failed with ${n.status}`);return yield n.json()})()}patch(e){var t=this;return p(function*(){yield fetch(t.url,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),keepalive:!0})})()}},h;function g(e,t,n){var r;function i(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:s,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=s.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let a=(r=n==null?void 0:n.Parent)==null?Object:r;class o extends a{}Object.defineProperty(o,"name",{value:e});function s(e){var t;let r=n!=null&&n.Parent?new o:this;i(r,e),(t=r._zod).deferred!=null||(t.deferred=[]);for(let e of r._zod.deferred)e();return r}return Object.defineProperty(s,"init",{value:i}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>{var r;return n!=null&&n.Parent&&t instanceof n.Parent?!0:t==null||(r=t._zod)==null||(r=r.traits)==null?void 0:r.has(e)}}),Object.defineProperty(s,"name",{value:e}),s}var _=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}};(h=globalThis).__zod_globalConfig!=null||(h.__zod_globalConfig={});var v=globalThis.__zod_globalConfig;function y(e){return e&&Object.assign(v,e),v}function b(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function x(e,t){if(e==null)return{};var n,r,i=b(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var ee=[`inst`,`continue`,`input`];function te(e,t){return typeof t==`bigint`?t.toString():t}function ne(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}var S=Symbol(`evaluating`);function C(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==S)return r===void 0&&(r=S,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}var w=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function re(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ie(e,t,n){let r=new e._zod.constr(t==null?e._zod.def:t);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function T(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?a(a({},t),{},{error:()=>t.error}):t}function ae(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}-Number.MAX_VALUE,Number.MAX_VALUE;function E(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++){var n;if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0}return!1}function D(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++){var n;if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0}return!1}function O(e,t){return t.map(t=>{var n;return(n=t).path!=null||(n.path=[]),t.path.unshift(e),t})}function k(e){return typeof e==`string`?e:e==null?void 0:e.message}function A(e,t,n){var r,i,a,o,s,c,l,u,d;let f=e.message?e.message:(r=(i=(a=(o=k((s=e.inst)==null||(s=s._zod.def)==null||(c=s.error)==null?void 0:c.call(s,e)))==null?k(t==null||(l=t.error)==null?void 0:l.call(t,e)):o)==null?k((u=n.customError)==null?void 0:u.call(n,e)):a)==null?k((d=n.localeError)==null?void 0:d.call(n,e)):i)==null?`Invalid input`:r,{inst:p,continue:m,input:h}=e,g=x(e,ee);return g.path!=null||(g.path=[]),g.message=f,t!=null&&t.reportInput&&(g.input=h),g}var j=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,te,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},oe=g(`$ZodError`,j),M=g(`$ZodError`,j,{Parent:Error}),se=(e=>(t,n,r,i)=>{let o=r?a(a({},r),{},{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new _;if(s.issues.length){var c;let t=new((c=i==null?void 0:i.Err)==null?e:c)(s.issues.map(e=>A(e,o,y())));throw w(t,i==null?void 0:i.callee),t}return s.value})(M),ce=(e=>function(){var t=p(function*(t,n,r,i){let o=r?a(a({},r),{},{async:!0}):{async:!0},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise&&(s=yield s),s.issues.length){var c;let t=new((c=i==null?void 0:i.Err)==null?e:c)(s.issues.map(e=>A(e,o,y())));throw w(t,i==null?void 0:i.callee),t}return s.value});return function(e,n,r,i){return t.apply(this,arguments)}}())(M),N=(e=>(t,n,r)=>{let i=r?a(a({},r),{},{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new _;return o.issues.length?{success:!1,error:new(e==null?oe:e)(o.issues.map(e=>A(e,i,y())))}:{success:!0,data:o.value}})(M),P=(e=>function(){var t=p(function*(t,n,r){let i=r?a(a({},r),{},{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=yield o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>A(e,i,y())))}:{success:!0,data:o.value}});return function(e,n,r){return t.apply(this,arguments)}}())(M),le=/^https?$/,F=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;`${F}`;function ue(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function I(e){let t=ue({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${F}T(?:${r})$`)}var L=e=>{var t,n;let r=e?`[\\s\\S]{${(t=e==null?void 0:e.minimum)==null?0:t},${(n=e==null?void 0:e.maximum)==null?``:n}}`:`[\\s\\S]*`;return RegExp(`^${r}$`)},R=g(`$ZodCheck`,(e,t)=>{var n;e._zod!=null||(e._zod={}),e._zod.def=t,(n=e._zod).onattach!=null||(n.onattach=[])}),z=g(`$ZodCheckStringFormat`,(e,t)=>{var n,r;R.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns!=null||(n.patterns=new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check!=null||(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push(a(a({origin:`string`,code:`invalid_format`,format:t.format,input:n.value},t.pattern?{pattern:t.pattern.toString()}:{}),{},{inst:e,continue:!t.abort}))}):(r=e._zod).check!=null||(r.check=()=>{})}),B={major:4,minor:4,patch:3},V=g(`$ZodType`,(e,t)=>{var n,r;e!=null||(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=B;let i=[...(n=e._zod.def.checks)==null?[]:n];e._zod.traits.has(`$ZodCheck`)&&i.unshift(e);for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0){var o;(r=e._zod).deferred!=null||(r.deferred=[]),(o=e._zod.deferred)==null||o.push(()=>{e._zod.run=e._zod.parse})}else{let t=(e,t,n)=>{let r=E(e),i;for(let o of t){if(o._zod.def.when){if(D(e)||!o._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,s=o._zod.check(e);if(s instanceof Promise&&(n==null?void 0:n.async)===!1)throw new _;if(i||s instanceof Promise){var a;i=((a=i)==null?Promise.resolve():a).then(p(function*(){yield s,e.issues.length!==t&&(r||(r=E(e,t)))}))}else{if(e.issues.length===t)continue;r||(r=E(e,t))}}return i?i.then(()=>e):e},n=(n,r,a)=>{if(E(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new _;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,o)=>{if(o.skipChecks)return e._zod.parse(r,o);if(o.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},a(a({},o),{},{skipChecks:!0}));return t instanceof Promise?t.then(e=>n(e,r,o)):n(t,r,o)}let s=e._zod.parse(r,o);if(s instanceof Promise){if(o.async===!1)throw new _;return s.then(e=>t(e,i,o))}return t(s,i,o)}}C(e,`~standard`,()=>({validate:t=>{try{var n;let r=N(e,t);return r.success?{value:r.data}:{issues:(n=r.error)==null?void 0:n.issues}}catch(n){return P(e,t).then(e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}})}},vendor:`zod`,version:1}))}),H=g(`$ZodString`,(e,t)=>{var n,r,i;V.init(e,t),e._zod.pattern=(n=[...(r=e==null||(i=e._zod.bag)==null?void 0:i.patterns)==null?[]:r].pop())==null?L(e._zod.bag):n,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(e){}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),U=g(`$ZodStringFormat`,(e,t)=>{z.init(e,t),H.init(e,t)}),de=g(`$ZodURL`,(e,t)=>{U.init(e,t),e._zod.check=n=>{try{var r;let i=n.value.trim();if(!t.normalize&&((r=t.protocol)==null?void 0:r.source)===le.source&&!/^https?:\/\//i.test(i)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let a=new URL(i);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(a.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(a.protocol.endsWith(`:`)?a.protocol.slice(0,-1):a.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=a.href:n.value=i;return}catch(r){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),fe=g(`$ZodISODateTime`,(e,t)=>{t.pattern!=null||(t.pattern=I(t)),U.init(e,t)}),pe=g(`$ZodNever`,(e,t)=>{V.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function W(e,t,n){e.issues.length&&t.issues.push(...O(n,e.issues)),t.value[n]=e.value}var me=g(`$ZodArray`,(e,t)=>{V.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>W(t,n,e))):W(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function G(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...O(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function he(e){let t=Object.keys(e.shape);for(let r of t){var n;if(!(!((n=e.shape)==null||(n=n[r])==null||(n=n._zod)==null||(n=n.traits)==null)&&n.has(`$ZodType`)))throw Error(`Invalid element at key "${r}": expected a Zod schema`)}let r=ae(e.shape);return a(a({},e),{},{keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)})}function ge(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>G(e,n,i,t,u,d))):G(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var _e=g(`$ZodObject`,(e,t)=>{V.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`);if(!(n!=null&&n.get)){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n=a({},e);return Object.defineProperty(t,"shape",{value:n}),n}})}let r=ne(()=>he(t));C(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]!=null||(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let i=re,o=t.catchall,s;e._zod.parse=(t,n)=>{s!=null||(s=r.value);let a=t.value;if(!i(a))return t.issues.push({expected:`object`,code:`invalid_type`,input:a,inst:e}),t;t.value={};let c=[],l=s.shape;for(let e of s.keys){let r=l[e],i=r._zod.optin===`optional`,o=r._zod.optout===`optional`,s=r._zod.run({value:a[e],issues:[]},n);s instanceof Promise?c.push(s.then(n=>G(n,t,e,a,i,o))):G(s,t,e,a,i,o)}return o?ge(c,a,t,n,r.value,e):c.length?Promise.all(c).then(()=>t):t}});function ve(e,t){return new e(a({type:`string`},T(t)))}function ye(e,t){return new e(a({type:`string`,format:`url`,check:`string_format`,abort:!1},T(t)))}function be(e,t){return new e(a({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null},T(t)))}function xe(e,t){return new e(a({type:`never`},T(t)))}var K=g(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);V.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>se(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>N(e,t,n),e.parseAsync=function(){var t=p(function*(t,n){return ce(e,t,n,{callee:e.parseAsync})});return function(e,n){return t.apply(this,arguments)}}(),e.safeParseAsync=function(){var t=p(function*(t,n){return P(e,t,n)});return function(e,n){return t.apply(this,arguments)}}(),e.check=(...n)=>{var r;return e.clone(a(a({},t),{},{checks:[...(r=t.checks)==null?[]:r,...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},e.with=e.check,e.clone=(t,n)=>ie(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.apply=t=>t(e)}),q=g(`ZodMiniString`,(e,t)=>{H.init(e,t),K.init(e,t)});function J(e){return ve(q,e)}var Y=g(`ZodMiniStringFormat`,(e,t)=>{U.init(e,t),q.init(e,t)}),Se=g(`ZodMiniURL`,(e,t)=>{de.init(e,t),Y.init(e,t)});function X(e){return ye(Se,e)}var Ce=g(`ZodMiniNever`,(e,t)=>{pe.init(e,t),K.init(e,t)});function we(e){return xe(Ce,e)}var Te=g(`ZodMiniArray`,(e,t)=>{me.init(e,t),K.init(e,t)});function Ee(e,t){return new Te(a({type:`array`,element:e},T(t)))}var De=g(`ZodMiniObject`,(e,t)=>{_e.init(e,t),K.init(e,t),C(e,`shape`,()=>t.shape)});function Z(e,t){return new De(a({type:`object`,shape:e,catchall:we()},T(t)))}var Oe=g(`ZodMiniISODateTime`,(e,t)=>{fe.init(e,t),Y.init(e,t)});function ke(e){return be(Oe,e)}var Ae=e=>{let t={};for(let n of e.split(/;\s*/)){if(!n)continue;let e=n.indexOf(`=`);if(e<0)continue;let r=n.slice(0,e).trim();if(!r)continue;let i=n.slice(e+1).trim();try{t[r]=decodeURIComponent(i)}catch(e){t[r]=i}}return t},je=Z({referrer:J(),landing_page:X(),browsing_history:Ee(Z({opened_at:ke(),url:X(),title:J()}))}),Q=`lc_browsing_history_data`,Me=`screen and (max-width: 992px) and (pointer: coarse)`,Ne=class e{constructor(e){r(this,`sessionVariables`,void 0),r(this,`data`,void 0),this.sessionVariables=e}static build(t){let{sessionVariables:n}=t;return{pageData:new e(n)}}init(){this.data=Pe(this.sessionVariables)}get(){if(this.data===void 0)throw Error(`PageDataCollector.get called before init`);return this.data}},Pe=e=>{let t=new URLSearchParams(window.location.search);return a(a(a({session_variables:e,device:window.matchMedia(Me).matches?`mobile`:`desktop`},Fe(t,e)),Ie(t)),Le())},Fe=(e,t)=>{var n,r,i;let a={};if(window.gaGlobal===void 0)return a;let o=Ae(document.cookie),s=Object.entries(o),c=(n=window.analytics)==null?void 0:n.user(),l=window.gaGlobal.vid,u=s.filter(([e])=>e.startsWith(`_ga_`)).map(e=>{var t;return(t=e[1])==null?``:t}),d=e.get(`gclid`)||((r=s.find(([e])=>e.startsWith(`_gcl_aw`)))==null?void 0:r[1])||t.gclid,f=e.get(`dclid`)||o._gcl_dc||t.dclid,p=t.fbc||o._fbc,m=t.fbp||o._fbp,h=e.get(`ttclid`)||o._ttp,g=e.get(`li_fat_id`)||o.li_fat_id,_=(c==null?void 0:c.anonymousId())||window.localStorage.getItem(`ajs_anonymous_id`),v=(c==null?void 0:c.id())||window.localStorage.getItem(`ajs_user_id`),y=(i=s.find(([e])=>e.startsWith(`bid_`)))==null?void 0:i[1];return l&&(a.ga_session=l),u.length>0&&(a.ga_session_id=u),d&&(a.gclid=d),f&&(a.dclid=f),p&&(a.fbc=p),m&&(a.fbp=m),h&&(a.ttclid=h),g&&(a.li_fat_id=g),_&&(a.segment_anonymous_id=_),v&&(a.segment_user_id=v),y&&(a.sitecore_browser_id=y),a},Ie=e=>{let t={},n=e.get(`utm_id`),r=e.get(`utm_source`),i=e.get(`utm_medium`),a=e.get(`utm_campaign`),o=e.get(`utm_term`),s=e.get(`utm_content`);return n&&(t.utm_id=n),r&&(t.utm_source=r),i&&(t.utm_medium=i),a&&(t.utm_campaign=a),o&&(t.utm_term=o),s&&(t.utm_content=s),t},Le=()=>{let e=$(),t=new Date;t.setDate(t.getDate()-30);let n=e.browsing_history.filter(e=>new Date(e.opened_at)>t),r={opened_at:new Date().toISOString(),url:window.location.href,title:document.title},i=n.length===0?{referrer:document.referrer,landing_page:r.url,browsing_history:[r]}:a(a({},e),{},{browsing_history:[...n,r].slice(-50)});return window.localStorage.setItem(Q,JSON.stringify(i)),i},$=()=>{let e=window.localStorage.getItem(Q);if(!e)return{referrer:``,landing_page:``,browsing_history:[]};try{return je.parse(JSON.parse(e))}catch(t){return console.error(`Error parsing ${Q}:`,{content:e},t),{referrer:``,landing_page:``,browsing_history:[]}}},Re=class e{constructor(e,t,n,i){r(this,`bus`,void 0),r(this,`http`,void 0),r(this,`pageData`,void 0),r(this,`clientId`,void 0),r(this,`shortCodes`,{whatsapp:void 0,sms:void 0,facebook:void 0}),r(this,`unsubscribe`,void 0),this.bus=e,this.http=t,this.pageData=n,this.clientId=i}static build(t){let{bus:n,http:r,pageData:i,config:a}=t;return{registry:new e(n,r,i,a.clientId)}}init(){this.unsubscribe=this.bus.on(`commversion:channels-registered`,({channels:e})=>{for(let t of e)this.shortCodes[t]===void 0&&(this.shortCodes[t]=this.startChannel(t),this.shortCodes[t].catch(e=>console.error(e)))})}destroy(){var e;(e=this.unsubscribe)==null||e.call(this),this.unsubscribe=void 0}patchAll(e){for(let t of Object.values(this.shortCodes))t==null||t.then(t=>this.http.patch(a({short_code:t},e)).catch(e=>console.error(e)),()=>{})}patchOne(e,t){var n;(n=this.shortCodes[e])==null||n.then(e=>this.http.patch(a({short_code:e},t)).catch(e=>console.error(e)),()=>{})}startChannel(e){var t=this;return p(function*(){try{let{short_code:n}=yield t.http.post(a(a({},t.pageData.get()),{},{client_id:t.clientId,channel:e,exit_intent:!1}));return t.bus.dispatch(`commversion:shortcode-resolved`,{channel:e,shortCode:n}),n}catch(n){let r=n instanceof Error?n.message:String(n);throw t.bus.dispatch(`commversion:shortcode-failed`,{channel:e,error:r}),n}})()}},ze=`https://api.cht-srvc.net/attribution`,Be=e=>{var t;let n,r=(t=e.attributionUrl)==null?ze:t;return Object.assign(({customerData:t})=>{n=new o({config:e,url:r,sessionVariables:t.sessionVariables}).provide(c.build).provide(m.build).provide(Ne.build).provide(Re.build).provide(l.build).provide(u.build).provide(d.build).provide(s.build).dependencies.app,n.init()},{destroy:()=>{n==null||n.destroy(),n=void 0}})};window.commversion=window.commversion||{};var Ve=Be(window.commversion);window.LiveChatWidget.once(`ready`,Ve)})();
1
+ (function(){function e(t){"@babel/helpers - typeof";return e=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},e(t)}function t(t,n){if(e(t)!=`object`||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var i=r.call(t,n||`default`);if(e(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(n===`string`?String:Number)(t)}function n(n){var r=t(n,`string`);return e(r)==`symbol`?r:r+``}function r(e,t,r){return(t=n(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?i(Object(n),!0).forEach(function(t){r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var o=class e{constructor(e={}){r(this,`dependencies`,void 0),this.dependencies=e}provide(t){return new e(a(a({},this.dependencies),t(this.dependencies)))}},s=class e{constructor(e,t,n,i,a,o,s){r(this,`bus`,void 0),r(this,`pageData`,void 0),r(this,`shortCodeStore`,void 0),r(this,`registry`,void 0),r(this,`channelClick`,void 0),r(this,`exitIntent`,void 0),r(this,`form`,void 0),this.bus=e,this.pageData=t,this.shortCodeStore=n,this.registry=i,this.channelClick=a,this.exitIntent=o,this.form=s}static build(t){let{bus:n,pageData:r,shortCodeStore:i,registry:a,channelClick:o,exitIntent:s,form:c}=t;return{app:new e(n,r,i,a,o,s,c)}}init(){this.pageData.init(),this.pageData.isNewSession()&&this.shortCodeStore.clear(),this.shortCodeStore.init(),this.registry.init(),this.channelClick.init(),this.exitIntent.init(),this.form.init(),this.bus.dispatch(`commversion:attribution-ready`,{})}destroy(){this.registry.destroy(),this.channelClick.destroy(),this.exitIntent.destroy(),this.form.destroy()}},c=class e{constructor(e){r(this,`target`,void 0),this.target=e}on(e,t){let n=e=>{e instanceof CustomEvent&&t(e.detail)};return this.target.addEventListener(e,n),()=>this.target.removeEventListener(e,n)}dispatch(e,t){this.target.dispatchEvent(new CustomEvent(e,{detail:t}))}static build(){return{bus:new e(window)}}},l=class e{constructor(e,t){r(this,`bus`,void 0),r(this,`registry`,void 0),r(this,`unsubscribe`,void 0),this.bus=e,this.registry=t}static build(t){let{bus:n,registry:r}=t;return{channelClick:new e(n,r)}}init(){this.unsubscribe=this.bus.on(`commversion:channel-clicked`,({channel:e})=>{let{sessionVariables:t}=window.LiveChatWidget.get(`customer_data`);this.registry.patchOne(e,{chat_start_url:window.location.href,chat_start_time:new Date().toISOString(),session_variables:t})})}destroy(){var e;(e=this.unsubscribe)==null||e.call(this),this.unsubscribe=void 0}},u=class e{constructor(e,t,n){r(this,`registry`,void 0),r(this,`debounceMs`,void 0),r(this,`margin`,void 0),r(this,`isMouseInside`,!0),r(this,`leaveTimeout`,void 0),r(this,`onMouseEnter`,()=>{this.registry.patchAll({exit_intent:!1})}),r(this,`onMouseLeave`,()=>{this.isBrowsing()&&this.registry.patchAll({exit_intent:!0})}),r(this,`onMouseMove`,e=>{this.checkBounds(e.clientX,e.clientY)?this.isMouseInside?(clearTimeout(this.leaveTimeout),this.leaveTimeout=void 0):(this.isMouseInside=!0,this.registry.patchAll({exit_intent:!1})):this.isMouseInside&&(this.isMouseInside=!1,this.leaveTimeout=setTimeout(()=>{this.leaveTimeout=void 0,this.isBrowsing()&&this.registry.patchAll({exit_intent:!0})},this.debounceMs))}),this.registry=e,this.debounceMs=t,this.margin=n}init(){window.addEventListener(`mouseenter`,this.onMouseEnter),window.addEventListener(`mouseleave`,this.onMouseLeave),window.addEventListener(`mousemove`,this.onMouseMove)}static build(t){let{registry:n,config:r}=t,{exitIntentDebounceMs:i=1500,exitIntentMargin:a=10}=r;return{exitIntent:new e(n,i,a)}}destroy(){window.removeEventListener(`mouseenter`,this.onMouseEnter),window.removeEventListener(`mouseleave`,this.onMouseLeave),window.removeEventListener(`mousemove`,this.onMouseMove)}checkBounds(e,t){let n=window.innerWidth,r=window.innerHeight;return e>=this.margin&&e<=n-this.margin&&t>=this.margin&&t<=r-this.margin}isBrowsing(){try{return window.LiveChatWidget.get(`customer_data`).status===`browsing`}catch(e){return!1}}},d=class e{constructor(e,t,n,i){r(this,`registry`,void 0),r(this,`abandonmentSelector`,void 0),r(this,`abandonmentDelaySeconds`,void 0),r(this,`submissionSelector`,void 0),r(this,`formAbandonmentTimeout`,void 0),r(this,`abandonmentForms`,void 0),r(this,`submissionForms`,void 0),r(this,`inputs`,void 0),r(this,`onChange`,()=>{clearTimeout(this.formAbandonmentTimeout),this.formAbandonmentTimeout=setTimeout(()=>{this.registry.patchAll({form_abandoned:!0})},this.abandonmentDelaySeconds*1e3)}),r(this,`onAbandonmentFormSubmit`,()=>{clearTimeout(this.formAbandonmentTimeout)}),r(this,`onSubmit`,()=>{this.registry.patchAll({form_submission:!0})}),r(this,`onInvalid`,()=>{this.registry.patchAll({input_error:!0})}),this.registry=e,this.abandonmentSelector=t,this.abandonmentDelaySeconds=n,this.submissionSelector=i}static build(t){let{registry:n,config:r}=t,{formAbandonmentSelector:i=`form`,formAbandonmentDelay:a=10,formSubmissionSelector:o=`form`}=r;return{form:new e(n,i,a,o)}}init(){this.abandonmentForms=document.querySelectorAll(this.abandonmentSelector),this.submissionForms=document.querySelectorAll(this.submissionSelector),this.inputs=document.querySelectorAll(`input`);for(let e of this.abandonmentForms)e.addEventListener(`change`,this.onChange),e.addEventListener(`submit`,this.onAbandonmentFormSubmit);for(let e of this.submissionForms)e.addEventListener(`submit`,this.onSubmit);for(let e of this.inputs)e.addEventListener(`invalid`,this.onInvalid)}destroy(){var e,t,n;for(let t of(e=this.abandonmentForms)==null?[]:e)t.removeEventListener(`change`,this.onChange),t.removeEventListener(`submit`,this.onAbandonmentFormSubmit);for(let e of(t=this.submissionForms)==null?[]:t)e.removeEventListener(`submit`,this.onSubmit);for(let e of(n=this.inputs)==null?[]:n)e.removeEventListener(`invalid`,this.onInvalid)}};function f(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function p(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){f(a,r,i,o,s,`next`,e)}function s(e){f(a,r,i,o,s,`throw`,e)}o(void 0)})}}var m=class e{constructor(e){r(this,`url`,void 0),this.url=e}static build(t){let{url:n}=t;return{http:new e(n)}}post(e){var t=this;return p(function*(){let n=yield fetch(t.url,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!n.ok)throw Error(`POST ${t.url} failed with ${n.status}`);return yield n.json()})()}patch(e){var t=this;return p(function*(){yield fetch(t.url,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),keepalive:!0})})()}},h;function g(e,t,n){var r;function i(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:s,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=s.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let a=(r=n==null?void 0:n.Parent)==null?Object:r;class o extends a{}Object.defineProperty(o,"name",{value:e});function s(e){var t;let r=n!=null&&n.Parent?new o:this;i(r,e),(t=r._zod).deferred!=null||(t.deferred=[]);for(let e of r._zod.deferred)e();return r}return Object.defineProperty(s,"init",{value:i}),Object.defineProperty(s,Symbol.hasInstance,{value:t=>{var r;return n!=null&&n.Parent&&t instanceof n.Parent?!0:t==null||(r=t._zod)==null||(r=r.traits)==null?void 0:r.has(e)}}),Object.defineProperty(s,"name",{value:e}),s}var _=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}};(h=globalThis).__zod_globalConfig!=null||(h.__zod_globalConfig={});var v=globalThis.__zod_globalConfig;function y(e){return e&&Object.assign(v,e),v}function ee(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.includes(r))continue;n[r]=e[r]}return n}function b(e,t){if(e==null)return{};var n,r,i=ee(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.includes(n)||{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var te=[`inst`,`continue`,`input`];function x(e,t){return typeof t==`bigint`?t.toString():t}function ne(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}var S=Symbol(`evaluating`);function C(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==S)return r===void 0&&(r=S,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}var w=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function T(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function re(e){if(T(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(T(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function ie(e,t,n){let r=new e._zod.constr(t==null?e._zod.def:t);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function E(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?a(a({},t),{},{error:()=>t.error}):t}function ae(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}-Number.MAX_VALUE,Number.MAX_VALUE;function D(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++){var n;if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0}return!1}function oe(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++){var n;if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0}return!1}function O(e,t){return t.map(t=>{var n;return(n=t).path!=null||(n.path=[]),t.path.unshift(e),t})}function k(e){return typeof e==`string`?e:e==null?void 0:e.message}function A(e,t,n){var r,i,a,o,s,c,l,u,d;let f=e.message?e.message:(r=(i=(a=(o=k((s=e.inst)==null||(s=s._zod.def)==null||(c=s.error)==null?void 0:c.call(s,e)))==null?k(t==null||(l=t.error)==null?void 0:l.call(t,e)):o)==null?k((u=n.customError)==null?void 0:u.call(n,e)):a)==null?k((d=n.localeError)==null?void 0:d.call(n,e)):i)==null?`Invalid input`:r,{inst:p,continue:m,input:h}=e,g=b(e,te);return g.path!=null||(g.path=[]),g.message=f,t!=null&&t.reportInput&&(g.input=h),g}var j=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,x,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},se=g(`$ZodError`,j),M=g(`$ZodError`,j,{Parent:Error}),ce=(e=>(t,n,r,i)=>{let o=r?a(a({},r),{},{async:!1}):{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new _;if(s.issues.length){var c;let t=new((c=i==null?void 0:i.Err)==null?e:c)(s.issues.map(e=>A(e,o,y())));throw w(t,i==null?void 0:i.callee),t}return s.value})(M),le=(e=>function(){var t=p(function*(t,n,r,i){let o=r?a(a({},r),{},{async:!0}):{async:!0},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise&&(s=yield s),s.issues.length){var c;let t=new((c=i==null?void 0:i.Err)==null?e:c)(s.issues.map(e=>A(e,o,y())));throw w(t,i==null?void 0:i.callee),t}return s.value});return function(e,n,r,i){return t.apply(this,arguments)}}())(M),N=(e=>(t,n,r)=>{let i=r?a(a({},r),{},{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new _;return o.issues.length?{success:!1,error:new(e==null?se:e)(o.issues.map(e=>A(e,i,y())))}:{success:!0,data:o.value}})(M),P=(e=>function(){var t=p(function*(t,n,r){let i=r?a(a({},r),{},{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=yield o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>A(e,i,y())))}:{success:!0,data:o.value}});return function(e,n,r){return t.apply(this,arguments)}}())(M),ue=/^https?$/,F=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;`${F}`;function de(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function fe(e){let t=de({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${F}T(?:${r})$`)}var pe=e=>{var t,n;let r=e?`[\\s\\S]{${(t=e==null?void 0:e.minimum)==null?0:t},${(n=e==null?void 0:e.maximum)==null?``:n}}`:`[\\s\\S]*`;return RegExp(`^${r}$`)},me=/^-?\d+(?:\.\d+)?$/,he=g(`$ZodCheck`,(e,t)=>{var n;e._zod!=null||(e._zod={}),e._zod.def=t,(n=e._zod).onattach!=null||(n.onattach=[])}),I=g(`$ZodCheckStringFormat`,(e,t)=>{var n,r;he.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns!=null||(n.patterns=new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check!=null||(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push(a(a({origin:`string`,code:`invalid_format`,format:t.format,input:n.value},t.pattern?{pattern:t.pattern.toString()}:{}),{},{inst:e,continue:!t.abort}))}):(r=e._zod).check!=null||(r.check=()=>{})}),L={major:4,minor:4,patch:3},R=g(`$ZodType`,(e,t)=>{var n,r;e!=null||(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=L;let i=[...(n=e._zod.def.checks)==null?[]:n];e._zod.traits.has(`$ZodCheck`)&&i.unshift(e);for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0){var o;(r=e._zod).deferred!=null||(r.deferred=[]),(o=e._zod.deferred)==null||o.push(()=>{e._zod.run=e._zod.parse})}else{let t=(e,t,n)=>{let r=D(e),i;for(let o of t){if(o._zod.def.when){if(oe(e)||!o._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,s=o._zod.check(e);if(s instanceof Promise&&(n==null?void 0:n.async)===!1)throw new _;if(i||s instanceof Promise){var a;i=((a=i)==null?Promise.resolve():a).then(p(function*(){yield s,e.issues.length!==t&&(r||(r=D(e,t)))}))}else{if(e.issues.length===t)continue;r||(r=D(e,t))}}return i?i.then(()=>e):e},n=(n,r,a)=>{if(D(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new _;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,o)=>{if(o.skipChecks)return e._zod.parse(r,o);if(o.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},a(a({},o),{},{skipChecks:!0}));return t instanceof Promise?t.then(e=>n(e,r,o)):n(t,r,o)}let s=e._zod.parse(r,o);if(s instanceof Promise){if(o.async===!1)throw new _;return s.then(e=>t(e,i,o))}return t(s,i,o)}}C(e,`~standard`,()=>({validate:t=>{try{var n;let r=N(e,t);return r.success?{value:r.data}:{issues:(n=r.error)==null?void 0:n.issues}}catch(n){return P(e,t).then(e=>{var t;return e.success?{value:e.data}:{issues:(t=e.error)==null?void 0:t.issues}})}},vendor:`zod`,version:1}))}),z=g(`$ZodString`,(e,t)=>{var n,r,i;R.init(e,t),e._zod.pattern=(n=[...(r=e==null||(i=e._zod.bag)==null?void 0:i.patterns)==null?[]:r].pop())==null?pe(e._zod.bag):n,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(e){}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),B=g(`$ZodStringFormat`,(e,t)=>{I.init(e,t),z.init(e,t)}),ge=g(`$ZodURL`,(e,t)=>{B.init(e,t),e._zod.check=n=>{try{var r;let i=n.value.trim();if(!t.normalize&&((r=t.protocol)==null?void 0:r.source)===ue.source&&!/^https?:\/\//i.test(i)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let a=new URL(i);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(a.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(a.protocol.endsWith(`:`)?a.protocol.slice(0,-1):a.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=a.href:n.value=i;return}catch(r){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),_e=g(`$ZodISODateTime`,(e,t)=>{t.pattern!=null||(t.pattern=fe(t)),B.init(e,t)}),ve=g(`$ZodNever`,(e,t)=>{R.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function V(e,t,n){e.issues.length&&t.issues.push(...O(n,e.issues)),t.value[n]=e.value}var ye=g(`$ZodArray`,(e,t)=>{R.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>V(t,n,e))):V(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function H(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...O(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function be(e){let t=Object.keys(e.shape);for(let r of t){var n;if(!(!((n=e.shape)==null||(n=n[r])==null||(n=n._zod)==null||(n=n.traits)==null)&&n.has(`$ZodType`)))throw Error(`Invalid element at key "${r}": expected a Zod schema`)}let r=ae(e.shape);return a(a({},e),{},{keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)})}function xe(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>H(e,n,i,t,u,d))):H(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var Se=g(`$ZodObject`,(e,t)=>{R.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`);if(!(n!=null&&n.get)){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n=a({},e);return Object.defineProperty(t,"shape",{value:n}),n}})}let r=ne(()=>be(t));C(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]!=null||(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let i=T,o=t.catchall,s;e._zod.parse=(t,n)=>{s!=null||(s=r.value);let a=t.value;if(!i(a))return t.issues.push({expected:`object`,code:`invalid_type`,input:a,inst:e}),t;t.value={};let c=[],l=s.shape;for(let e of s.keys){let r=l[e],i=r._zod.optin===`optional`,o=r._zod.optout===`optional`,s=r._zod.run({value:a[e],issues:[]},n);s instanceof Promise?c.push(s.then(n=>H(n,t,e,a,i,o))):H(s,t,e,a,i,o)}return o?xe(c,a,t,n,r.value,e):c.length?Promise.all(c).then(()=>t):t}}),Ce=g(`$ZodRecord`,(e,t)=>{R.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!re(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let c=new Set;for(let s of o)if(typeof s==`string`||typeof s==`number`||typeof s==`symbol`){c.add(typeof s==`number`?s.toString():s);let o=t.keyType._zod.run({value:s,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>A(e,r,y())),input:s,path:[s],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[s],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...O(s,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...O(s,u.issues)),n.value[l]=u.value)}let l;for(let e in i)if(!c.has(e)){var s;l=(s=l)==null?[]:s,l.push(e)}l&&l.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:l})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&me.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>A(e,r,y())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...O(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...O(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}});function we(e,t){return new e(a({type:`string`},E(t)))}function Te(e,t){return new e(a({type:`string`,format:`url`,check:`string_format`,abort:!1},E(t)))}function Ee(e,t){return new e(a({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null},E(t)))}function De(e,t){return new e(a({type:`never`},E(t)))}var U=g(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);R.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>ce(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>N(e,t,n),e.parseAsync=function(){var t=p(function*(t,n){return le(e,t,n,{callee:e.parseAsync})});return function(e,n){return t.apply(this,arguments)}}(),e.safeParseAsync=function(){var t=p(function*(t,n){return P(e,t,n)});return function(e,n){return t.apply(this,arguments)}}(),e.check=(...n)=>{var r;return e.clone(a(a({},t),{},{checks:[...(r=t.checks)==null?[]:r,...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},e.with=e.check,e.clone=(t,n)=>ie(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.apply=t=>t(e)}),W=g(`ZodMiniString`,(e,t)=>{z.init(e,t),U.init(e,t)});function G(e){return we(W,e)}var K=g(`ZodMiniStringFormat`,(e,t)=>{B.init(e,t),W.init(e,t)}),Oe=g(`ZodMiniURL`,(e,t)=>{ge.init(e,t),K.init(e,t)});function q(e){return Te(Oe,e)}var ke=g(`ZodMiniNever`,(e,t)=>{ve.init(e,t),U.init(e,t)});function Ae(e){return De(ke,e)}var je=g(`ZodMiniArray`,(e,t)=>{ye.init(e,t),U.init(e,t)});function Me(e,t){return new je(a({type:`array`,element:e},E(t)))}var Ne=g(`ZodMiniObject`,(e,t)=>{Se.init(e,t),U.init(e,t),C(e,`shape`,()=>t.shape)});function J(e,t){return new Ne(a({type:`object`,shape:e,catchall:Ae()},E(t)))}var Y=g(`ZodMiniRecord`,(e,t)=>{Ce.init(e,t),U.init(e,t)});function Pe(e,t,n){return!t||!t._zod?new Y(a({type:`record`,keyType:G(),valueType:e},E(t))):new Y(a({type:`record`,keyType:e,valueType:t},E(n)))}var Fe=g(`ZodMiniISODateTime`,(e,t)=>{_e.init(e,t),K.init(e,t)});function Ie(e){return Ee(Fe,e)}var Le=e=>{let t={};for(let n of e.split(/;\s*/)){if(!n)continue;let e=n.indexOf(`=`);if(e<0)continue;let r=n.slice(0,e).trim();if(!r)continue;let i=n.slice(e+1).trim();try{t[r]=decodeURIComponent(i)}catch(e){t[r]=i}}return t},Re=J({referrer:G(),landing_page:q(),browsing_history:Me(J({opened_at:Ie(),url:q(),title:G()}))}),X=`lc_browsing_history_data`,ze=`screen and (max-width: 992px) and (pointer: coarse)`,Be=class e{constructor(e){r(this,`sessionVariables`,void 0),r(this,`data`,void 0),this.sessionVariables=e}static build(t){let{sessionVariables:n}=t;return{pageData:new e(n)}}init(){this.data=Ve(this.sessionVariables)}get(){if(this.data===void 0)throw Error(`PageDataCollector.get called before init`);return this.data}isNewSession(){if(this.data===void 0)throw Error(`PageDataCollector.isNewSession called before init`);return this.data.wasReset}},Ve=e=>{let t=new URLSearchParams(window.location.search);return a(a(a({session_variables:e,device:window.matchMedia(ze).matches?`mobile`:`desktop`},He(t,e)),Ue(t)),Z())},He=(e,t)=>{var n,r,i;let a={};if(window.gaGlobal===void 0)return a;let o=Le(document.cookie),s=Object.entries(o),c=(n=window.analytics)==null?void 0:n.user(),l=window.gaGlobal.vid,u=s.filter(([e])=>e.startsWith(`_ga_`)).map(e=>{var t;return(t=e[1])==null?``:t}),d=e.get(`gclid`)||((r=s.find(([e])=>e.startsWith(`_gcl_aw`)))==null?void 0:r[1])||t.gclid,f=e.get(`dclid`)||o._gcl_dc||t.dclid,p=t.fbc||o._fbc,m=t.fbp||o._fbp,h=e.get(`ttclid`)||o._ttp,g=e.get(`li_fat_id`)||o.li_fat_id,_=(c==null?void 0:c.anonymousId())||window.localStorage.getItem(`ajs_anonymous_id`),v=(c==null?void 0:c.id())||window.localStorage.getItem(`ajs_user_id`),y=(i=s.find(([e])=>e.startsWith(`bid_`)))==null?void 0:i[1];return l&&(a.ga_session=l),u.length>0&&(a.ga_session_id=u),d&&(a.gclid=d),f&&(a.dclid=f),p&&(a.fbc=p),m&&(a.fbp=m),h&&(a.ttclid=h),g&&(a.li_fat_id=g),_&&(a.segment_anonymous_id=_),v&&(a.segment_user_id=v),y&&(a.sitecore_browser_id=y),a},Ue=e=>{let t={},n=e.get(`utm_id`),r=e.get(`utm_source`),i=e.get(`utm_medium`),a=e.get(`utm_campaign`),o=e.get(`utm_term`),s=e.get(`utm_content`);return n&&(t.utm_id=n),r&&(t.utm_source=r),i&&(t.utm_medium=i),a&&(t.utm_campaign=a),o&&(t.utm_term=o),s&&(t.utm_content=s),t},Z=()=>{let e=We(),t=new Date;t.setDate(t.getDate()-30);let n=e.browsing_history.filter(e=>new Date(e.opened_at)>t),r={opened_at:new Date().toISOString(),url:window.location.href,title:document.title},i=n.length===0,o=i?{referrer:document.referrer,landing_page:r.url,browsing_history:[r]}:a(a({},e),{},{browsing_history:[...n,r].slice(-50)});return window.localStorage.setItem(X,JSON.stringify(o)),a(a({},o),{},{wasReset:i})},We=()=>{let e=window.localStorage.getItem(X);if(!e)return{referrer:``,landing_page:``,browsing_history:[]};try{return Re.parse(JSON.parse(e))}catch(t){return console.error(`Error parsing ${X}:`,{content:e},t),{referrer:``,landing_page:``,browsing_history:[]}}},Ge=[`wasReset`],Ke=class e{constructor(e,t,n,i,a){r(this,`bus`,void 0),r(this,`http`,void 0),r(this,`pageData`,void 0),r(this,`shortCodeStore`,void 0),r(this,`clientId`,void 0),r(this,`shortCodes`,{whatsapp:void 0,sms:void 0,facebook:void 0}),r(this,`unsubscribe`,void 0),this.bus=e,this.http=t,this.pageData=n,this.shortCodeStore=i,this.clientId=a}static build(t){let{bus:n,http:r,pageData:i,shortCodeStore:a,config:o}=t;return{registry:new e(n,r,i,a,o.clientId)}}init(){this.unsubscribe=this.bus.on(`commversion:channels-registered`,({channels:e})=>{for(let t of e){if(this.shortCodes[t]!==void 0)continue;let e=this.shortCodeStore.get(t);if(e!==void 0){this.shortCodes[t]=Promise.resolve(e),this.bus.dispatch(`commversion:shortcode-resolved`,{channel:t,shortCode:e}),this.http.patch(a(a({},Q(this.pageData.get())),{},{short_code:e,exit_intent:!1})).catch(e=>console.error(e));continue}this.shortCodes[t]=this.startChannel(t),this.shortCodes[t].catch(e=>console.error(e))}})}destroy(){var e;(e=this.unsubscribe)==null||e.call(this),this.unsubscribe=void 0}patchAll(e){for(let t of Object.values(this.shortCodes))t==null||t.then(t=>this.http.patch(a({short_code:t},e)).catch(e=>console.error(e)),()=>{})}patchOne(e,t){var n;(n=this.shortCodes[e])==null||n.then(e=>this.http.patch(a({short_code:e},t)).catch(e=>console.error(e)),()=>{})}startChannel(e){var t=this;return p(function*(){try{let{short_code:n}=yield t.http.post(a(a({},Q(t.pageData.get())),{},{client_id:t.clientId,channel:e,exit_intent:!1}));return t.shortCodeStore.set(e,n),t.bus.dispatch(`commversion:shortcode-resolved`,{channel:e,shortCode:n}),n}catch(n){let r=n instanceof Error?n.message:String(n);throw t.bus.dispatch(`commversion:shortcode-failed`,{channel:e,error:r}),n}})()}},Q=e=>{let{wasReset:t}=e;return b(e,Ge)},$=`lc_attribution_short_codes`,qe=Pe(G(),G()),Je=class e{constructor(){r(this,`codes`,{})}static build(){return{shortCodeStore:new e}}init(){this.codes=Ye()}get(e){return this.codes[e]}set(e,t){this.codes=a(a({},this.codes),{},{[e]:t}),window.localStorage.setItem($,JSON.stringify(this.codes))}clear(){this.codes={},window.localStorage.removeItem($)}},Ye=()=>{let e=window.localStorage.getItem($);if(!e)return{};try{return qe.parse(JSON.parse(e))}catch(t){return console.error(`Error parsing ${$}:`,{content:e},t),{}}},Xe=`https://api.cht-srvc.net/attribution`,Ze=e=>{var t;let n,r=(t=e.attributionUrl)==null?Xe:t;return Object.assign(({customerData:t})=>{n=new o({config:e,url:r,sessionVariables:t.sessionVariables}).provide(c.build).provide(m.build).provide(Be.build).provide(Je.build).provide(Ke.build).provide(l.build).provide(u.build).provide(d.build).provide(s.build).dependencies.app,n.init()},{destroy:()=>{n==null||n.destroy(),n=void 0}})};window.commversion=window.commversion||{};var Qe=Ze(window.commversion);window.LiveChatWidget.once(`ready`,Qe)})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commversion/libs",
3
- "version": "0.18.4",
3
+ "version": "0.18.5",
4
4
  "license": "UNLICENSED",
5
5
  "author": "Commversion",
6
6
  "type": "module",