!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VmaxAdManager=t()}(this,(function(){"use strict";function e(e,t){const s=function(e,t){const s=navigator.userAgent.match(/Android/i),i=navigator.userAgent.match(/Chrome/i),n=e&&s&&i;if(!n)return!1;const r=function(e,t){try{const s=e.split("://"),i=s[0];return`intent://${s[1]}/#Intent;scheme=${i};S.browser_fallback_url=${t||""};end`}catch(e){return!1}}(e,t);return r||!1}(e,t),i=s||t;window.open(i,"_blank")}function t(e,t,s,i){return new(s||(s=Promise))((function(n,r){function a(e){try{c(i.next(e))}catch(e){r(e)}}function o(e){try{c(i.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(a,o)}c((i=i.apply(e,t||[])).next())}))}function s(e,t,s,i){if("a"===s&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?i:"a"===s?i.call(e):i?i.value:t.get(e)}function i(e,t,s,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,s):n?n.value=s:t.set(e,s),s}"function"==typeof SuppressedError&&SuppressedError;const n=e=>"string"==typeof e&&e.length>0,r=e=>"number"==typeof e,a=e=>"boolean"==typeof e,o=e=>{const t="object"==typeof e&&!Array.isArray(e),s=Object.keys(e).every((e=>"string"==typeof e)),i=Object.values(e).every((e=>"string"==typeof e));return t&&s&&i},c=e=>Array.isArray(e),d=e=>{const t=new URL(e);return Boolean(t.host)};function l(e){if(null==e)return!0;const t=Date.now();return Boolean(e)&&Number.isInteger(e)&&e<=t}function h(e){return null===e||!(Object.keys(e)||e).length}function u(e){return function(e,t){if(!e||!e.prototype)throw new Error("Class constructor is not defined");if(!c(t))throw new Error("Methods must be an array");const s=e.prototype;return t.every((e=>n(e)&&"function"==typeof s[e]))}(e,["getAllSignatures","prepare","render"])}function f(e){return r(e)||n(e)}var A;!function(e){e.AD_READY="adReady",e.AD_IMPRESSION="adImpression",e.AD_RENDERED="adRendered",e.AD_REFRESHED="adRefreshed",e.AD_ERROR="adError",e.AD_CLOSED="adClosed",e.AD_CLICKED="adClicked",e.AD_SKIPPED="adSkipped",e.AD_SKIPPABLE_STATE_CHANGE="adSkippableStateChange",e.AD_PAUSED="adPaused",e.AD_RESUMED="adResumed",e.AD_VIDEO_START="adVideoStart",e.AD_VIDEO_FIRST_QUARTILE="adVideoFirstQuartile",e.AD_VIDEO_MIDPOINT="adVideoMidpoint",e.AD_VIDEO_THIRD_QUARTILE="adVideoThirdQuartile",e.AD_VIDEO_COMPLETE="adVideoComplete",e.AD_VOLUME_CHANGED="adVolumeChanged",e.AD_MUTED="adMuted",e.AD_UNMUTED="adUnmuted",e.AD_PROGRESS="adProgress",e.AD_USER_CLOSE="adUserClose",e.AD_INSERTION_START="adInsertionStart",e.AD_INSERTION_END="adInsertionEnd",e.AD_MEDIA_EXPAND="onFullScreen",e.AD_MEDIA_COLLAPSE="onExitFullScreen"}(A||(A={}));var E,v=A;!function(e){e.PERSONAL_COMPUTER="2",e.CONNECTED_TV="3",e.PHONE="4",e.TABLET="5",e.CONNECTED_DEVICE="6",e.SET_TOP_BOX="7"}(E||(E={}));var g,p,m,I,_,D=E;!function(e){e.GEO_PROFILE="geoProfile",e.USER_PROFILE="userProfile"}(g||(g={})),function(e){e.APP_ID="appId",e.ACCOUNT_KEY="accountKey",e.SECRET_KEY="secretKey",e.SDK_INITIALIZED="sdkInitialized",e.GEO_PROFILE="geoProfile",e.USER_PROFILE="userProfile",e.IS_APP="isApp",e.SOURCE_CONFIG_DATA="sourceConfig",e.ABORT="abort",e.PRIVATE_KEY="privateKey",e.KEY_ID="keyId",e.UPS_ENDPOINT="upsEndpoint",e.UPS_XAUTH="upsXAuth",e.DGS_ENDPOINT="dgsEndpoint",e.DGS_XAUTH="dgsXAuth",e.AS_ENDPOINT="adspotEndpoint",e.AS_XAUTH="adspotXAuth"}(p||(p={})),function(e){e.UID="uid",e.GENDER="gender",e.AGE="age",e.COUNTRY="country",e.REGION="region",e.CITY="city",e.ZIPCODE="zip",e.KEYWORDS="keywords"}(m||(m={})),function(e){e.PLAY_ONCE="play_once",e.REPEAT="repeat"}(I||(I={}));class y{constructor(){_.set(this,new Map)}static getInstance(){return y.instance}set(e,t){"object"!=typeof e?s(this,_,"f").set(e,t):Object.entries(e).forEach((([e,t])=>{(n(t)||r(t)||a(t))&&s(this,_,"f").set(e,t)}))}get(e){var t;return"string"!=typeof e||0==e.length?s(this,_,"f"):null!==(t=s(this,_,"f").get(e))&&void 0!==t?t:null}get isSDKInitialized(){return Boolean(s(this,_,"f").get(p.SDK_INITIALIZED))}}_=new WeakMap,y.instance=new y;const R=y.getInstance();var w,T,S,O,N,P;class C{constructor(){w.add(this),this.AppInstance=T.getInstance(),S.set(this,{id:""})}static getInstance(){return T.instance}setVersion(e){return s(this,w,"m",O).call(this),s(this,S,"f").version=e,T.instance}setOrientation(e){var t;return s(this,w,"m",O).call(this),void 0===(null===(t=s(this,S,"f"))||void 0===t?void 0:t.ext)&&(s(this,S,"f").ext={}),s(this,S,"f").ext.orientation=e,this}getPayload(){return s(this,w,"m",N).call(this),s(this,S,"f")}setPageCategory(e){return s(this,w,"m",O).call(this),h(e)||!c(e)||(s(this,S,"f").pagecat=e),this}setCustomData(e){return s(this,w,"m",O).call(this),o(e)&&(s(this,S,"f").ext||(s(this,S,"f").ext={}),"object"==typeof s(this,S,"f").ext&&null!==s(this,S,"f").ext?s(this,S,"f").ext=Object.assign(Object.assign({},s(this,S,"f").ext),{customkeys:e}):s(this,S,"f").ext={customkeys:e}),this}setSectionCategory(e){return s(this,w,"m",O).call(this),h(e)||!c(e)||(s(this,S,"f").sectioncat=e),this}setKeywords(e){return s(this,w,"m",O).call(this),c(e)&&e.every((e=>n(e)))?(s(this,S,"f").kwarray=[...e],T.instance):T.instance}}T=C,S=new WeakMap,w=new WeakSet,O=function(){const e=R.get(p.IS_APP);return!!R.get(p.SDK_INITIALIZED)&&(e||console.warn("Since App is not set, App level targeting will be ignored"),e)},N=function(){const e=R.get(p.APP_ID);if(e)return s(this,S,"f").id=e,T.instance},C.instance=new T,function(e){e.UNKNOWN="0",e.ETHERNET="1",e.WIFI="2",e.UNKNOWN_CELLULAR_NETWORK="3",e.NETWORK_2G="4",e.NETWORK_3G="5",e.NETWORK_4G="6",e.NETWORK_5G="7"}(P||(P={}));var k=P;function b(e){return"object"!=typeof e||Array.isArray(e)?null:Object.keys(e).reduce(((t,s)=>(t[s]=e[s],t)),{})}class L{static getInstance(){return L.instance}set(e,t){window.localStorage.setItem(e,JSON.stringify(t))}get(e){const t=window.localStorage.getItem(e);return t?JSON.parse(t):null}}L.instance=new L;const M=L.getInstance();var U,V,x,W,K,j,F,Y,G,B,H,q,X,Q,z,Z,$,J,ee,te,se,ie,ne,re;class ae{constructor(){U.add(this),V.set(this,{}),this.DeviceType=b(D),this.ConnectionType=b(k)}static getInstance(){return ae.instance}setLocation(e){if(!(e instanceof GeolocationCoordinates))return ae.instance;const{latitude:t,longitude:i,accuracy:n}=e;return s(this,V,"f").geolocationCoordinates={type:1,lat:t,lon:i,accuracy:n},ae.instance}setDeviceType(e){return n(e)?(s(this,V,"f").type=e,ae.instance):ae.instance}setConnectionType(e){return n(e)?(s(this,V,"f").connectionType=e,ae.instance):ae.instance}setSimOperatorOrMccMnc(e){return n(e)?(s(this,V,"f").mccmnc=e,ae.instance):ae.instance}setMake(e){return n(e)?(s(this,V,"f").make=e,ae.instance):ae.instance}setModel(e){return n(e)?(s(this,V,"f").model=e,ae.instance):ae.instance}get(){return s(this,V,"f")}setAdvertisingId(e){return n(e)?(s(this,V,"f").ifa=e,this):ae.instance}setCarrier(e){return n(e)?(s(this,V,"f").carrier=e,this):ae.instance}setMarketingName(e){return n(e)?(s(this,V,"f").maketingName=e,this):ae.instance}setPlatform(e){return n(e)?(s(this,V,"f").platformId=e,this):ae.instance}getPayload(){var e;const{GEO_PROFILE:t}=p,{geolocationCoordinates:i,type:n,connectionType:r,ifa:a,carrier:o,maketingName:c,platformId:d,mccmnc:l,make:h,model:u}=s(this,V,"f"),f=null===(e=M.get(t))||void 0===e?void 0:e.geo,A=i||f||!1,E={ua:s(this,U,"a",x),language:s(this,U,"a",W)};return A&&(E.geo=A),n&&(E.devicetype=n),r&&(E.connectiontype=r),a&&(E.ifa=a),o&&(E.carrier=o),c&&(void 0===(null==E?void 0:E.ext)&&(E.ext={}),E.ext.dvmn=c),d&&(void 0===(null==E?void 0:E.ext)&&(E.ext={}),E.ext.dvpl=d),l&&(E.mccmnc=l),h&&(E.make=h),u&&(E.model=u),E}}V=new WeakMap,U=new WeakSet,x=function(){return window.navigator.userAgent},W=function(){return navigator.language},ae.instance=new ae;class oe{isRequestAllowed(e){try{const t=e.payload,s=null==t?void 0:t.imp;return!(!s||0===Object.keys(s).length)}catch(e){return console.warn(e),!1}}}function ce(...e){console.warn.apply(console,e)}function de(...e){console.error.apply(console,e)}class le{constructor(){K.set(this,new Map),j.set(this,[new oe])}static get getInstance(){return le.instance}addVmaxAd(e){if(!u(e))return de("Registry: must be a valid VmaxAd");let t=new e;s(this,K,"f").set(e,[].concat(t.getAllSignatures())),t=null}removeVmaxAd(e){if(!u(e))return de("Registry: must be a valid VmaxAd");s(this,K,"f").delete(e)}getVmaxAd(e){let t=Array.from(s(this,K,"f").entries()).find((([t,s])=>s.includes(e)));return t?t[0]:null}getAllSignatures(){let e=Array.from(s(this,K,"f").values()).reduce(((e,t)=>e.concat(t)),[]);return Array.from(new Set(e))}addRequestAdvisor(e){s(this,j,"f").some((t=>t instanceof e.constructor))?ce("Advisor already present"):s(this,j,"f").push(e)}removeRequestAdvisor(e){s(this,j,"f").forEach(((t,i)=>{t instanceof e.constructor&&s(this,j,"f").splice(i,1)}))}getAdvisors(){return s(this,j,"f")}}K=new WeakMap,j=new WeakMap,le.instance=new le;class he{constructor(){F.add(this),Y.set(this,void 0),G.set(this,void 0),B.set(this,{id:""})}static getInstance(){return he.instance}setPageURL(e){return s(this,F,"m",H).call(this),d(e)?(s(this,B,"f").pageUrl=e,he.instance):he.instance}setReferrerURL(e){return s(this,F,"m",H).call(this),d(e)?(s(this,B,"f").referrerUrl=e,he.instance):he.instance}setSearchFor(e){return s(this,F,"m",H).call(this),n(e)?(s(this,B,"f").searchFor=encodeURIComponent(e),he.instance):he.instance}getPayload(){return s(this,F,"m",X).call(this),s(this,F,"m",Q).call(this),s(this,F,"m",q).call(this),s(this,B,"f")}setPageCategory(e){return s(this,F,"m",H).call(this),h(e)||!c(e)||(s(this,B,"f").pagecat=e),this}setCustomData(e){return s(this,F,"m",H).call(this),o(e)&&(s(this,B,"f").ext={customkeys:e}),this}setSectionCategory(e){return s(this,F,"m",H).call(this),h(e)||!c(e)||(s(this,B,"f").sectioncat=e),this}setKeywords(e){return s(this,F,"m",H).call(this),c(e)&&e.every((e=>n(e)))?(s(this,B,"f").kwarray=[...e],he.instance):he.instance}}Y=new WeakMap,G=new WeakMap,B=new WeakMap,F=new WeakSet,H=function(){const e=R.get(p.IS_APP);return!R.get(p.SDK_INITIALIZED)||(e&&console.warn("Since App is set, site level targeting will be ignored"),e)},q=function(){const e=R.get(p.APP_ID);s(this,B,"f").id=e},X=function(){var e;return!(null===(e=s(this,B,"f"))||void 0===e?void 0:e.pageUrl)&&(s(this,B,"f").pageUrl=window.location.href,!0)},Q=function(){var e;if(!!(null===(e=s(this,B,"f"))||void 0===e?void 0:e.referrerUrl))return!1;return!!document.referrer&&(s(this,B,"f").referrerUrl=document.referrer),!0},he.instance=new he,function(e){e.errorCode="{errorcode}",e.noFill="",e.noFillError="[nofill.error]",e.demandPartnerSDKVersion="[demand.partner.sdkversion]",e.eventName="[event.name]",e.vastErrorCode="[vast.error]",e.OmidSDKVersion="[omid.partner.sdkversion]",e.eventAttribute1="[event.attribute1]",e.eventAttribute2="[event.attribute2]",e.eventAttribute3="[event.attribute3]",e.randomCcb="[random.ccb]",e.deviceIFA="[device.ifa]"}(z||(z={}));class ue{static post(e){return t(this,void 0,void 0,(function*(){const{url:t,payload:s,headers:i={},credentials:n}=e||{};let r={method:"POST",body:JSON.stringify(s)};n&&(r.credentials=n),i&&(r.headers=i);const a=new AbortController;r.signal=a.signal;return[fetch(t,r).then((e=>e.ok?e.json().catch((()=>Promise.reject(de("Invalid JSON response")))):e.text().then((t=>Promise.reject({message:`Error: ${e.status}`,status:e.status,body:t}))))).catch((e=>(function(...e){console.log.apply(console,e)}("Error in Fetch.post",e),Promise.reject(e)))),a]}))}static get(e){return t(this,arguments,void 0,(function*(e,t={}){return fetch(e,t).then((e=>e.json()))}))}static getPlainResponse(e){return t(this,arguments,void 0,(function*(e,t={}){return fetch(e,t)}))}static DeviceGeoService(){const e=R.get(p.ACCOUNT_KEY),t=R.get(p.DGS_ENDPOINT);R.get(p.DGS_XAUTH);const s=(t||"").replace("ACCOUNT_KEY",e);return Z.get(s)}static UserProfileService(e){return t(this,void 0,void 0,(function*(){const t=R.get(p.ACCOUNT_KEY),s=R.get(p.UPS_ENDPOINT),i=R.get(p.UPS_XAUTH),n=(s||"").replace("ACCOUNT_KEY",t),[r]=yield Z.post({url:n,headers:{"X-AUTH":i},payload:e});return r}))}static AdQuery(e){const{ACCOUNT_KEY:t,AS_ENDPOINT:s}=p,i=R.get(t)||"",n=R.get(s);return Z.post({url:n.replace("ACCOUNT_KEY",i),payload:e,credentials:"include"})}static replaceAllMacros(e,t){const s=Object.keys(z);if(0===s.length)return e;const{ifa:i=""}=window.VmaxAdManager.getDevice().getPayload();return s.forEach((s=>{var n;const r=z[s];let a;a=r===z.randomCcb?Date.now().toString():r===z.deviceIFA?i:t&&(null===(n=t[r])||void 0===n?void 0:n.toString())||"";const o=new RegExp(this.escapeRegExp(r),"g");e=e.replace(o,a)})),t||s.forEach((t=>{const s=z[t],i=new RegExp(this.escapeRegExp(s),"g");e=e.replace(i,"")})),e}static escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}static FireTracker(e,i){return t(this,void 0,void 0,(function*(){if(!n(e)&&!c(e))return Promise.reject("No url to fire tracker");for(let t of e)t=this.replaceAllMacros(t,i),yield s(Z,Z,"m",$).call(Z,t)}))}}function fe(e){return t(this,void 0,void 0,(function*(){const{PRIVATE_KEY:t,KEY_ID:s}=p,i=R.get(t);R.get(s);try{const t=function(e){const t=atob(e),s=t.length,i=new Uint8Array(s);for(let e=0;en[e]||e))}}ee=Ae,se=new WeakMap,ie=new WeakMap,J=new WeakSet,ne=function(e){if("object"!=typeof e||Array.isArray(e)||!e)return;Object.keys(e).forEach((t=>{s(this,ie,"f").includes(t)||(s(this,se,"f")[t]=e[t])}))},re=function(){return t(this,void 0,void 0,(function*(){try{const e=this.getURL("https://assets-telksl.vmax.com/ACCOUNT_KEY/source-config/1.0.0/SOURCE_ID/KEY_ID"),t=yield ue.getPlainResponse(e);return Promise.resolve(t)}catch(e){return Promise.reject("Failed to load source data.")}}))},te={value:void 0};var Ee,ve,ge,pe;class me{constructor(){Ee.add(this),ve.set(this,{}),i(this,ve,{},"f")}static getInstance(){return me.instance}setId(e){return n(e)?(s(this,ve,"f").uid=e,me.instance):me.instance}setGender(e){return n(e)?(s(this,ve,"f").gender=e,me.instance):me.instance}setAge(e){return n(e)?(s(this,ve,"f").age=e,me.instance):me.instance}setCity(e){return n(e)?(s(this,ve,"f").city=e,me.instance):me.instance}setRegion(e){return n(e)?(s(this,ve,"f").region=e,me.instance):me.instance}setCountry(e){return n(e)?(s(this,ve,"f").country=e,me.instance):me.instance}setZipcode(e){return n(e)&&(e=>/^\d+$/.test(e))(e)?(s(this,ve,"f").zip=e,me.instance):me.instance}setKeywords(e){return c(e)||e.every((e=>n(e)))?(s(this,ve,"f").keywordsArray=[...e],me.instance):me.instance}setCustomData(e){var t;return o(e)&&("undefined"===(null===(t=s(this,ve,"f"))||void 0===t?void 0:t.ext)&&(s(this,ve,"f").ext={}),s(this,ve,"f").ext={customkeys:e}),me.instance}get(){return s(this,ve,"f")}getPayload(){var e;const{uid:t,keywordsArray:i,country:n,region:r,city:a,zip:o,ext:c,age:d,gender:l}=s(this,ve,"f"),{USER_PROFILE:h}=p,u=null===(e=M.get(h))||void 0===e?void 0:e.user;let f={};t&&(f.id=t),i&&(f.kwarray=i);!!(n||r||a||o)&&(f.geo={type:3},n&&(f.geo.country=n),r&&(f.geo.region=r),a&&(f.geo.city=a),o&&(f.geo.zip=o)),c&&(f.ext=c);const A=s(this,Ee,"m",ge).call(this);return A&&(f.data=A),f=Object.assign(Object.assign({},f),u),f}}ve=new WeakMap,Ee=new WeakSet,ge=function(){const{age:e,gender:t}=s(this,ve,"f");if(!!e||!!t){let s=[];t&&s.push({name:"gender",value:t}),e&&s.push({name:"age",value:e});return[{segment:s}]}return!1},me.instance=new me,function(e){e.PAUSED="paused",e.RESUMED="resumed",e.STARTED="started",e.COMPLETED="completed",e.NOT_READY="not_ready"}(pe||(pe={}));var Ie=pe;const _e={NO_FILL:{code:1e3,message:"No Fill"},AD_MANAGER_INIT_FAILED:{code:1001,message:"Ad Manager initialization failed"},PREPARE_VMAX_AD_FAILED:{code:1002,message:"Prepare Vmax Ad failed"},AD_REQUEST_BLOCKED_BY_ADVISOR:{code:1003,message:"Ad request blocked by advisor"},INVALID_AD_SPACES:{code:1004,message:"Invalid ad spaces"},AD_SERVER_ERROR:{code:1005,message:"Ad server error"},UNIVERSAL_LINK_FAILED:{code:1006,message:"Universal link failed"},REQUEST_ATTRIBUTE_BUILDER_EMPTY:{code:1007,message:"Request attribute builder is empty"},REQUEST_ATTRIBUTE_VALUE_NOT_SET:{code:1008,message:"Mandatory parameter is not set"},REQUEST_ATTRIBUTES_MISSING:{code:1009,message:"Request attribute is missing"},REQUEST_ATTRIBUTE_VALUE_CASE_MISMATCH:{code:1010,message:"Request attribute value case mismatch"},REQUEST_ATTRIBUTE_KEY_NOT_FOUND:{code:1011,message:"Request attribute key not found"},REQUEST_ATTRIBUTE_VALUE_INVALID:{code:1012,message:"Request attribute value is not valid"},AD_SPACE_COUNT_ZERO:{code:1013,message:"Ad not provided"},AD_REQUEST_BODY_FAILED:{code:1014,message:"Ad request body failed"},RENDITION_FAILED:{code:1015,message:"Ad rendition failed"},AD_RESPONSE_FAILED:{code:1016,message:"Ad response failed"},INVALID_USER_AGENT:{code:1017,message:"Invalid user agent"},NETWORK_ERROR:{code:1018,message:"Network error"},AD_ALREADY_CACHED:{code:1019,message:"Ad is already cached"},VMAX_AD_NOT_REGISTERED:{code:1020,message:"Vmax Ad Signatures not found"},ASSET_HELPER_NOT_IN_MEMORY:{code:1021,message:"Asset helper not in memory"},ASSET_DELEGATE_NOT_IN_MEMORY:{code:1022,message:"Asset delegate not in memory"},VPP_NOT_IN_MEMORY:{code:1023,message:"VPP not in memory"},CONTAINER_IS_MISSING_PARENT_VIEW_CONTROLLER:{code:1024,message:"Container is missing parent view controller"},AD_SPOT_INACTIVE:{code:1025,message:"Adspot is inactive"},AD_SPOT_UNAVAILABLE:{code:1026,message:"Adspot is unavailable"},AD_ABORT:{code:1027,message:"User canceled the ad request."},INVALID_INITIALIZE_OPTION:{code:1028,message:"Invalid initialize options."},INVALID_DGS_ENDPOINT:{code:1029,message:"Invalid dgs url."},INVALID_SERVICE_ENDPOINT:{code:1030,message:"Invalid UPS/DGS/Adspot url."},INVALID_API_KEY:{code:1031,message:"Invalid api key for UPS/DGS/Adspot."}};var De,ye,Re,we,Te,Se,Oe,Ne,Pe,Ce,ke,be,Le,Me,Ue,Ve,xe,We,Ke,je,Fe,Ye,Ge,Be,He,qe,Xe,Qe,ze,Ze,$e,Je,et,tt,st,it,nt,rt,at,ot,ct,dt,lt,ht,ut,ft,At,Et,vt,gt,pt,mt,It,_t,Dt,yt;Object.freeze(_e);class Rt{constructor(){De.set(this,new Map),ye.set(this,new Map)}addEventListener(e,t){var i;if("string"!=typeof e)throw new Error("Invalid Event");if("function"!=typeof t)throw new Error("Invalid Callback");s(this,De,"f").has(e)||s(this,De,"f").set(e,[]),null===(i=s(this,De,"f").get(e))||void 0===i||i.push(t)}addEventListenerOnce(e,t){var i;if("string"!=typeof e)throw new Error("Invalid Event");if("function"!=typeof t)throw new Error("Invalid Callback");s(this,ye,"f").has(e)||s(this,ye,"f").set(e,[]),null===(i=s(this,ye,"f").get(e))||void 0===i||i.push(t)}removeEventListener(e,t){var i,n;if("string"!=typeof e)throw new Error("Invalid Event");if("function"!=typeof t)throw new Error("Invalid Callback");if(!s(this,De,"f").has(e)&&!s(this,ye,"f").get(e))return;const r=s(this,De,"f").get(e),a=s(this,ye,"f").get(e),o=null!==(i=null==r?void 0:r.indexOf(t))&&void 0!==i?i:-1,c=null!==(n=null==a?void 0:a.indexOf(t))&&void 0!==n?n:-1;o>-1&&(null==r||r.splice(o,1)),c>-1&&(null==a||a.splice(c,1)),s(this,De,"f").set(e,r||[]),s(this,ye,"f").set(e,a||[]),-1===o&&-1===c&&console.warn("Eventlistener: Callback not found")}removeAllEventListeners(e){if("string"!=typeof e)throw new Error("Invalid Event");s(this,De,"f").has(e)&&s(this,De,"f").delete(e),s(this,ye,"f").has(e)&&s(this,ye,"f").delete(e)}dispatchEvent(e,...t){if("string"!=typeof e)throw new Error("Invalid Event");if(!s(this,De,"f").has(e)&&!s(this,ye,"f").get(e))return;const i=s(this,De,"f").get(e),n=s(this,ye,"f").get(e);null==i||i.forEach((e=>e(...t))),null==n||n.forEach((e=>e(...t))),s(this,ye,"f").set(e,[])}}De=new WeakMap,ye=new WeakMap;class wt{constructor(e,t){if(Re.add(this),we.set(this,null),Te.set(this,0),Se.set(this,0),Oe.set(this,!1),Ne.set(this,(()=>{})),Pe.set(this,0),Ce.set(this,!1),ke.set(this,!1),!r(t)||t<0)throw new Error("Timer must have a duration");if("function"!=typeof e)throw new Error("Timer must have a callback function");i(this,Ne,e,"f"),i(this,Pe,t,"f")}pause(){s(this,Ce,"f")||s(this,we,"f")&&(clearTimeout(s(this,we,"f")),i(this,Se,s(this,Se,"f")-(Date.now()-s(this,Te,"f")),"f"),i(this,Oe,!0,"f"))}startOrResume(){if(!s(this,ke,"f"))return s(this,Re,"m",be).call(this);s(this,Ce,"f")||s(this,Oe,"f")&&(i(this,Oe,!1,"f"),s(this,Re,"m",Le).call(this))}clear(){s(this,Ce,"f")||s(this,we,"f")&&(clearTimeout(s(this,we,"f")),i(this,we,null,"f"),i(this,Ce,!0,"f"))}get isFinished(){return s(this,Ce,"f")}}we=new WeakMap,Te=new WeakMap,Se=new WeakMap,Oe=new WeakMap,Ne=new WeakMap,Pe=new WeakMap,Ce=new WeakMap,ke=new WeakMap,Re=new WeakSet,be=function(){s(this,ke,"f")||s(this,Ce,"f")||(i(this,ke,!0,"f"),s(this,Re,"m",Le).call(this))},Le=function(){s(this,Oe,"f")||(i(this,Te,Date.now(),"f"),i(this,Se,s(this,Se,"f")||1e3*s(this,Pe,"f"),"f")),i(this,we,setTimeout((()=>{i(this,Oe,!1,"f"),i(this,Ce,!0,"f"),s(this,Ne,"f").call(this)}),s(this,Se,"f")),"f")};class Tt{constructor(){Me.add(this),Ue.set(this,{})}static getInstance(){return Tt.instance}getPayload(e){return{modules:{adsignatures:[...s(this,Me,"m",Ve).call(this,e)]}}}}function St(e){try{for(const t in e){const s=e[t];null!=s&&s||delete e[t],"object"!=typeof s||Array.isArray(s)||St(s)}return e}catch(t){return e}}function Ot(){return t(this,void 0,void 0,(function*(){const{UID:e,ACCOUNT_KEY:s,GEO_PROFILE:i,USER_PROFILE:r,SOURCE_CONFIG_DATA:a,UPS_ENDPOINT:o,DGS_ENDPOINT:c,AS_ENDPOINT:d,UPS_XAUTH:l,DGS_XAUTH:h,AS_XAUTH:u}=Object.assign(Object.assign(Object.assign({},m),g),p),{services:{ups:A,dgs:E,as:v}}=R.get(a)||{},{INVALID_SERVICE_ENDPOINT:I,INVALID_API_KEY:_}=_e,{domain:D,apikey:y}=A||{},{domain:w}=E||{},{domain:T}=v||{};if(!n(T))return Promise.reject(I.message);if(n(D)&&n(w)&&n(T)||console.warn(I.message),R.set({[d]:T+"/ACCOUNT_KEY/adspot/1.0.1/query/"}),!n(y))return void console.warn(_.message);const S=R.get(s);if(!S||!f(S))return Promise.reject();const O=yield function(e,s){return t(this,arguments,void 0,(function*(e,t,s="base64"){const i=new TextEncoder,n=i.encode(t),r=i.encode(e.toString());try{const e=yield window.crypto.subtle.importKey("raw",n,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),t=yield window.crypto.subtle.sign("HMAC",e,r);if("hex"===s){return Array.from(new Uint8Array(t)).map((e=>e.toString(16).padStart(2,"0"))).join("")}if("base64"===s)return btoa(String.fromCharCode(...new Uint8Array(t)));throw new Error('Invalid format specified. Must be "hex" or "base64".')}catch(e){throw console.error("Error generating HMAC-SHA256 key:",e),e}}))}(S,y);return R.set({[o]:D+"/ACCOUNT_KEY/",[c]:w+"/ACCOUNT_KEY/",[l]:O}),Promise.resolve()}))}function Nt(e){return t(this,void 0,void 0,(function*(){var s,i;try{const{ignoreExpiry:n=!1}=e||{},{UID:r,GEO_PROFILE:a,USER_PROFILE:o,ACCOUNT_KEY:c}=Object.assign(Object.assign(Object.assign({},m),g),p),d=M.get(a),h=M.get(o),u=n||l(null==d?void 0:d.expiry),f=R.get(c),A=n||l(null==h?void 0:h.expiry);if(!(u||A))return Promise.resolve();const E=me.getInstance().get(),v=Boolean(null==E?void 0:E[r]),I=[];if(u?I.push(ue.DeviceGeoService()):I.push(Promise.resolve()),A&&v){const e=yield function(e,s,i){return t(this,void 0,void 0,(function*(){const{UID:t,GENDER:n,COUNTRY:r,REGION:a,CITY:o,ZIPCODE:c,AGE:d}=m,l=St({[r]:null==s?void 0:s[r],[a]:null==s?void 0:s[a],[o]:null==s?void 0:s[o],[c]:null==s?void 0:s[c]}),h=St({[n]:null==s?void 0:s[n],[d]:null==s?void 0:s[d],geo:l}),u=St({accountkey:e,identifiers:{uid:null==s?void 0:s[t]},demographics:h});return i&&(u.profile=i),u}))}(f,E,h);I.push(ue.UserProfileService(e))}else I.push(Promise.reject());const _=yield Promise.allSettled(I),[D,y]=_,w="fulfilled"===D.status&&Number.isInteger(null===(s=D.value)||void 0===s?void 0:s.expiry),T="fulfilled"===y.status&&Number.isInteger(null===(i=y.value)||void 0===i?void 0:i.expiry);return w&&M.set(a,D.value),T&&M.set(o,y.value),Promise.resolve()}catch(e){return console.warn(e),Promise.reject()}}))}Ue=new WeakMap,Me=new WeakSet,Ve=function(e){return e&&Array.isArray(e)&&0!==e.length?s(this,Ue,"f").adsignatures=e.reduce(((e,t)=>(!!le.getInstance.getVmaxAd(t)&&e.push(t),e)),[]):s(this,Ue,"f").adsignatures=le.getInstance.getAllSignatures(),s(this,Ue,"f").adsignatures},Tt.instance=new Tt,function(e){e[e.ACTIVE=1]="ACTIVE",e[e.INACTIVE=0]="INACTIVE",e[e.UNAVAILABLE=-1]="UNAVAILABLE"}(xe||(xe={}));class Pt{constructor(){We.add(this),Ke.set(this,[]),je.set(this,{}),this.events=new Rt,Fe.set(this,!1),Ye.set(this,void 0),Ge.set(this,[])}addAdSpace(e){return e instanceof os?(s(this,Ke,"f").push(e),this):this}build(){const e=s(this,We,"m",He).call(this),t=R.get(p.IS_APP);if(e.length<1)return this;i(this,je,{imp:e,device:ae.getInstance().getPayload(),user:me.getInstance().getPayload(),ext:Tt.getInstance().getPayload(s(this,Ge,"f"))},"f");const n=he.getInstance().getPayload(),r=C.getInstance().getPayload();return t?s(this,je,"f").app=r:s(this,je,"f").site=n,this}setSignatures(e){if(!Array.isArray(e)||0===e.length)return;const t=e.filter((e=>"string"==typeof e));i(this,Ge,t,"f")}process(){return s(this,Fe,"f")?Promise.reject("Ad Request already in progress"):s(this,We,"m",Xe).call(this)}abort(){s(this,Ye,"f")&&s(this,Ye,"f").abort(),s(this,Ke,"f").forEach((e=>{e.onAdError(_e.AD_ABORT)}))}handleAdResponse(e){var t,i;console.log("Response",e);const n=(null===(i=null===(t=null==e?void 0:e.seatbid)||void 0===t?void 0:t[0])||void 0===i?void 0:i.bid)||[];s(this,Ke,"f").forEach((e=>{var t=n.findIndex((t=>t.impid===e.tagId&&""!==t.adm));const s=n[t];t>=0&&n.splice(t,1),t>=0&&s?e.setCache(s):e.isAdCached||e.handleNoFill()})),s(this,We,"m",Be).call(this,e)}}function Ct(){return new Pt}function kt(e){if(!(e instanceof Pt))throw new Error("Invalid request object");return e.process()}Ke=new WeakMap,je=new WeakMap,Fe=new WeakMap,Ye=new WeakMap,Ge=new WeakMap,We=new WeakSet,Be=function(e){const t=le.getInstance.getAdvisors(),i={payload:s(this,je,"f"),response:e};t.forEach((e=>{var t;return null===(t=null==e?void 0:e.handleAdResponse)||void 0===t?void 0:t.call(e,i)}))},He=function(){return s(this,Ke,"f").reduce(((e,t)=>{const s=function(e){const{SOURCE_CONFIG_DATA:t}=p,{ACTIVE:s,INACTIVE:i,UNAVAILABLE:n}=xe,{inventory:r}=R.get(t),a=null==r?void 0:r.adspots,o=!!a&&"object"==typeof a&&Object.keys(a).length,c=o&&a[e];return o&&c?a[e].status===s?s:i:n}(t.tagId),{ACTIVE:i,INACTIVE:n,UNAVAILABLE:r}=xe,{AD_SPOT_INACTIVE:a,AD_SPOT_UNAVAILABLE:o}=_e,c=s===i;return!t.isAdCached&&c&&e.push(t.getRequestPayload()),s===n?(console.warn("Adspot is inactive",t.tagId),t.onAdError(a)):s===r&&(console.warn("Adspot is unavailable",t.tagId),t.onAdError(o)),e}),[])},qe=function(){return t(this,void 0,void 0,(function*(){const[e,t]=yield ue.AdQuery(s(this,je,"f"));return i(this,Fe,!0,"f"),i(this,Ye,t,"f"),e.then((e=>this.handleAdResponse(e))).catch((e=>{s(this,Ke,"f").forEach((e=>{e.onAdError(_e.AD_SERVER_ERROR)})),Promise.reject(e)})).finally((()=>{i(this,Fe,!1,"f")}))}))},Xe=function(){return t(this,void 0,void 0,(function*(){return(yield s(this,We,"m",Qe).call(this))?(yield Ot(),Nt(),s(this,We,"m",qe).call(this)):(s(this,Ke,"f").forEach((e=>{e.isAdCached&&e.onAdError(_e.AD_REQUEST_BLOCKED_BY_ADVISOR)})),Promise.reject("Ad Request Blocked by Advisor"))}))},Qe=function(){return t(this,void 0,void 0,(function*(){const e=le.getInstance.getAdvisors(),t={payload:s(this,je,"f")},i=e.map((e=>e.isRequestAllowed(t)));return Promise.all(i).then((e=>e.every((e=>!0===e))))}))};Ze=new WeakMap,$e=new WeakMap,Je=new WeakMap,et=new WeakMap,tt=new WeakMap,st=new WeakMap,it=new WeakMap,nt=new WeakMap,rt=new WeakMap,at=new WeakMap,ot=new WeakMap,ct=new WeakMap,dt=new WeakMap,lt=new WeakMap,ht=new WeakMap,ut=new WeakMap,ft=new WeakMap,At=new WeakMap,Et=new WeakMap,ze=new WeakSet,vt=function(){var e,t,i,n,r;if(!s(this,st,"f"))return;const a=null===(n=null===(i=null===(t=null===(e=s(this,st,"f"))||void 0===e?void 0:e.ext)||void 0===t?void 0:t.modules)||void 0===i?void 0:i.render)||void 0===n?void 0:n.signature;if(!a)return void this.onAdError(_e.VMAX_AD_NOT_REGISTERED);const o=le.getInstance.getVmaxAd(a);if(!o||!u(o))return void this.onAdError(_e.VMAX_AD_NOT_REGISTERED);const c=s(this,ct,"f")&&(null===(r=s(this,nt,"f"))||void 0===r?void 0:r.destroy());c instanceof Promise?c.then((()=>s(this,ze,"m",gt).call(this,o))):s(this,ze,"m",gt).call(this,o)},gt=function(e){var t;s(this,st,"f")&&(i(this,nt,null,"f"),i(this,nt,new e,"f"),null===(t=s(this,nt,"f"))||void 0===t||t.prepare({bid:s(this,st,"f"),listeners:s(this,at,"f"),nativeLayout:s(this,lt,"f")||void 0,videoLayout:s(this,ht,"f")||void 0,skipVideoThumbnail:s(this,ut,"f")||void 0,requestedBitRate:s(this,tt,"f")||void 0,container:s(this,Ze,"f")||void 0}).then((()=>{var e;if(s(this,ct,"f"))return s(this,ze,"m",_t).call(this);s(this,ze,"m",mt).call(this,v.AD_READY),s(this,Et,"f")&&(null===(e=s(this,nt,"f"))||void 0===e?void 0:e.setAdClickHandler)&&s(this,nt,"f").setAdClickHandler(s(this,Et,"f"))})).catch((e=>{this.onAdError(e||_e.PREPARE_VMAX_AD_FAILED)})))},pt=function(){var e,t,s,i,n,r;const a=null===(t=null===(e=window.VmaxAdManager.getUser().getPayload())||void 0===e?void 0:e.ext)||void 0===t?void 0:t.customkeys,o=null===(i=null===(s=window.VmaxAdManager.getSite().getPayload())||void 0===s?void 0:s.ext)||void 0===i?void 0:i.customkeys,c=null===(r=null===(n=window.VmaxAdManager.getApp().getPayload())||void 0===n?void 0:n.ext)||void 0===r?void 0:r.customkeys,d=window.VmaxAdManager.isApp?c:o;return Object.assign(Object.assign({},a),d)},mt=function(e,t){var i;const n=s(this,ze,"m",pt).call(this),r=null===(i=this.getVmaxAd())||void 0===i?void 0:i.getVmaxAdInfo();s(this,it,"f").dispatchEvent(e,{eventName:e,adSpace:this,adInfo:Object.assign(Object.assign(Object.assign({tagId:this.tagId},r),{keyValueMap:Object.assign({},n)}),t)})},It=function(e){const{layout:t,layoutTemplate:s}=e,i=s instanceof HTMLElement&&"TEMPLATE"===s.nodeName,n="string"==typeof t&&t.length>0;return i||n},_t=function(){var e;null===(e=s(this,nt,"f"))||void 0===e||e.render({container:s(this,ot,"f")}).then((e=>{this.setCache(null),i(this,At,s(this,nt,"f"),"f"),s(this,ze,"m",mt).call(this,s(this,ct,"f")?v.AD_REFRESHED:v.AD_RENDERED,e),s(this,ze,"m",Dt).call(this)})).catch((e=>{console.error("Error while rendering ad",e),this.onAdError(_e.RENDITION_FAILED)}))},Dt=function(e=!1){var t,n;(null===(t=s(this,nt,"f"))||void 0===t?void 0:t.shouldProcessRefresh)&&s(this,Je,"f")>0&&(i(this,dt,new wt(s(this,ze,"m",yt).bind(this),s(this,Je,"f")),"f"),e&&s(this,dt,"f").startOrResume()),!s(this,ct,"f")&&(null===(n=s(this,nt,"f"))||void 0===n?void 0:n.shouldProcessRefresh)&&i(this,ct,!0,"f")},yt=function e(){var t,n;if(!s(this,dt,"f"))return void console.warn("adRefreshTimer is empty or null");s(this,dt,"f").clear(),i(this,dt,null,"f");const r=null===(t=s(this,nt,"f"))||void 0===t?void 0:t.canRefresh;if(void 0===r||!0===r){(a=this,kt(Ct().addAdSpace(a).build())).catch((e=>(console.log("Error in singleAdRequest",e),s(this,ze,"m",Dt).call(this,!0))))}else{var a;(null===(n=s(this,nt,"f"))||void 0===n?void 0:n.shouldProcessRefresh)&&(i(this,dt,new wt(s(this,ze,"m",e).bind(this),s(this,Je,"f")),"f"),s(this,dt,"f").startOrResume())}};var bt,Lt,Mt,Ut,Vt,xt,Wt,Kt,jt,Ft,Yt,Gt,Bt,Ht,qt,Xt,Qt,zt,Zt,$t,Jt,es,ts,ss,is,ns,rs,as,os=class{constructor(e){ze.add(this),Ze.set(this,void 0),$e.set(this,!1),Je.set(this,30),et.set(this,-1),tt.set(this,void 0),st.set(this,null),it.set(this,new Rt),nt.set(this,void 0),rt.set(this,Ie.NOT_READY),at.set(this,{AdClicked:this.onAdClicked.bind(this),AdPaused:this.onAdPaused.bind(this),AdResumed:this.onAdResumed.bind(this),AdImpression:e=>s(this,ze,"m",mt).call(this,v.AD_IMPRESSION,e),AdUserClose:e=>s(this,ze,"m",mt).call(this,v.AD_USER_CLOSE,e),AdClosed:e=>s(this,ze,"m",mt).call(this,v.AD_CLOSED,e),AdVolumeChanged:e=>s(this,ze,"m",mt).call(this,v.AD_VOLUME_CHANGED,e),AdMuted:e=>s(this,ze,"m",mt).call(this,v.AD_MUTED,e),AdUnmuted:e=>s(this,ze,"m",mt).call(this,v.AD_UNMUTED,e),AdSkipped:e=>s(this,ze,"m",mt).call(this,v.AD_SKIPPED,e),AdVideoStart:e=>s(this,ze,"m",mt).call(this,v.AD_VIDEO_START,e),AdVideoFirstQuartile:e=>s(this,ze,"m",mt).call(this,v.AD_VIDEO_FIRST_QUARTILE,e),AdVideoMidpoint:e=>s(this,ze,"m",mt).call(this,v.AD_VIDEO_MIDPOINT,e),AdVideoThirdQuartile:e=>s(this,ze,"m",mt).call(this,v.AD_VIDEO_THIRD_QUARTILE,e),AdVideoComplete:e=>s(this,ze,"m",mt).call(this,v.AD_VIDEO_COMPLETE,e),AdSkippableStateChange:e=>s(this,ze,"m",mt).call(this,v.AD_SKIPPABLE_STATE_CHANGE,e),AdVideoProgress:e=>s(this,ze,"m",mt).call(this,v.AD_PROGRESS,e),AdMediaExpand:e=>s(this,ze,"m",mt).call(this,v.AD_MEDIA_EXPAND,e),AdMediaCollapse:e=>s(this,ze,"m",mt).call(this,v.AD_MEDIA_COLLAPSE,e),AdError:e=>this.onAdError(e)}),ot.set(this,void 0),ct.set(this,!1),dt.set(this,null),lt.set(this,void 0),ht.set(this,void 0),ut.set(this,void 0),ft.set(this,void 0),At.set(this,void 0),Et.set(this,void 0),R.isSDKInitialized;const{tagId:t,container:r}=e||{};n(t),this.tagId=t,i(this,Ze,r,"f")}setInterstitialExperience(e){return a(e)?(i(this,$e,e,"f"),this):this}setRefreshRate(e){return 0===e&&i(this,Je,0,"f"),!Number.isInteger(e)||e<30||i(this,Je,e,"f"),this}setOrientation(e){return i(this,et,e,"f"),this}setNativeLayout(e){s(this,ze,"m",It).call(this,e)?i(this,lt,e,"f"):ce("AdSpace: Invalid native layout")}setVideoLayout(e){s(this,ze,"m",It).call(this,e)?i(this,ht,e,"f"):ce("AdSpace: Invalid video layout")}setVideoSkipThumbnail(e){const{source:t=""}=e||{};try{i(this,ut,new URL(t),"f")}catch(e){ce("AdSpace: Invalid video skip thumbnail source")}}setVolume(e){var t;"number"!=typeof e||e<0||e>1||(null===(t=s(this,nt,"f"))||void 0===t?void 0:t.setVolume)&&s(this,nt,"f").setVolume(e)}setFullscreenContainer(e){var t;e instanceof HTMLElement?(null===(t=s(this,nt,"f"))||void 0===t?void 0:t.setFullscreenContainer)&&s(this,nt,"f").setFullscreenContainer(e):ce("AdSpace: Invalid container")}setRequestedBitRate(e){"number"!=typeof e||e<0||i(this,tt,e,"f")}setAdClickHandler(e){var t;"function"==typeof e&&(i(this,Et,e,"f"),(null===(t=s(this,nt,"f"))||void 0===t?void 0:t.setAdClickHandler)&&s(this,nt,"f").setAdClickHandler(e))}closeAd(){const e=s(this,At,"f")||s(this,nt,"f");return(null==e?void 0:e.closeAd)?Promise.resolve(e.closeAd()).then((()=>{var e;i(this,At,null,"f"),null===(e=s(this,dt,"f"))||void 0===e||e.clear(),i(this,dt,null,"f")})):Promise.resolve()}setCache(e){i(this,st,e,"f"),s(this,ze,"m",vt).call(this)}setSecure(e){return a(e)?(i(this,ft,e,"f"),this):this}get isAdCached(){return!!s(this,st,"f")}getRequestPayload(){const e={tagid:this.tagId,instl:s(this,$e,"f")?1:0,displaymanager:"vmax",displaymanagerver:"A-WEB-4.1.4",ext:{orientation:s(this,et,"f")},secure:1};return void 0!==s(this,ft,"f")&&(e.secure=s(this,ft,"f")?1:0),e}handleNoFill(){this.onAdError(_e.NO_FILL),s(this,nt,"f")&&s(this,ze,"m",Dt).call(this,!0)}addEventListener(e,t){if(!Object.values(v).includes(e))throw new Error("AdSpace: Invalid Event");s(this,it,"f").addEventListener(e,t)}addEventListenerOnce(e,t){if(!Object.values(v).includes(e))throw new Error("AdSpace: Invalid Event");s(this,it,"f").addEventListenerOnce(e,t)}removeEventListener(e,t){s(this,it,"f").removeEventListener(e,t)}removeAllEventListeners(e){s(this,it,"f").removeAllEventListeners(e)}onAdError(e){var t,n;if(null===(n=null===(t=s(this,st,"f"))||void 0===t?void 0:t.ext)||void 0===n?void 0:n.fallback)return i(this,st,s(this,st,"f").ext.fallback,"f"),s(this,ze,"m",vt).call(this);s(this,it,"f").dispatchEvent(v.AD_ERROR,{eventName:v.AD_ERROR,errorObject:e,adSpace:this})}onAdPaused(){var e;null===(e=s(this,dt,"f"))||void 0===e||e.pause(),i(this,rt,Ie.PAUSED,"f"),s(this,ze,"m",mt).call(this,v.AD_PAUSED)}onAdResumed(){var e;null===(e=s(this,dt,"f"))||void 0===e||e.startOrResume(),s(this,rt,"f")===Ie.PAUSED&&(s(this,ze,"m",mt).call(this,v.AD_RESUMED),i(this,rt,Ie.RESUMED,"f"))}pauseAd(){var e,t;(null===(e=s(this,nt,"f"))||void 0===e?void 0:e.pauseAd)&&(null===(t=s(this,nt,"f"))||void 0===t||t.pauseAd())}resumeAd(){var e,t;(null===(e=s(this,nt,"f"))||void 0===e?void 0:e.resumeAd)&&(null===(t=s(this,nt,"f"))||void 0===t||t.resumeAd())}onAdClicked(){s(this,ze,"m",mt).call(this,v.AD_CLICKED)}showAd(e){const{container:t}=e||{};return s(this,st,"f")?s(this,nt,"f")?"function"!=typeof s(this,nt,"f").render?(console.warn("Vmax Ad Template does not have render method"),this.onAdError(_e.RENDITION_FAILED)):(i(this,ot,t||s(this,Ze,"f"),"f"),s(this,ot,"f")?void s(this,ze,"m",_t).call(this):console.warn("No container to show ad")):this.onAdError(_e.VMAX_AD_NOT_REGISTERED):this.onAdError(_e.RENDITION_FAILED)}getVmaxAd(){return s(this,nt,"f")}};class cs extends Pt{constructor(e,t){super(),bt.add(this),Lt.set(this,void 0),Mt.set(this,I.REPEAT),Ut.set(this,[]),Vt.set(this,-1),xt.set(this,-1),Wt.set(this,-1),Kt.set(this,!1),jt.set(this,!1),Ft.set(this,void 0),Yt.set(this,!1),Gt.set(this,!1),Bt.set(this,void 0),Ht.set(this,void 0),this.adEventListeners=new Map,qt.set(this,void 0),Qt.set(this,(e=>{const t=s(this,Ut,"f").find((t=>t.ad===e));t&&(t.cached=!0,t.canPlay=!0)})),zt.set(this,(e=>{const t=s(this,Ut,"f").find((t=>t.ad===e));t&&(t.canPlay=!1)})),i(this,Ft,e,"f"),i(this,Lt,t,"f"),s(this,Ft,"f").onCueOut(s(this,bt,"m",$t).bind(this)),s(this,Ft,"f").onCueIn(s(this,bt,"m",rs).bind(this))}addEventListener(e,t){return this.events.addEventListener(e,t),this}addBumperAdSpace(e){return e instanceof os?(this.addAdSpace(e),s(this,Ut,"f").push({ad:e,type:"bumper",playing:!1,cached:!1,canPlay:!1}),this):this}addRegularAdSpace(e){return e instanceof os?(this.addAdSpace(e),s(this,Ut,"f").push({ad:e,type:"regular",playing:!1,cached:!1,canPlay:!1}),this):this}setAdsRecurrence(e){return i(this,Mt,e,"f"),this}setMaxBreakDuration(e){return!r(e)||e<0||i(this,Vt,e,"f"),this}setMinimumBreakDuration(e){return!r(e)||e<0||i(this,xt,e,"f"),this}process(){return s(this,bt,"m",Xt).call(this,s(this,Ut,"f").map((e=>e.ad))),super.process()}restorePlayerState(){s(this,Ft,"f").mutePlayer(s(this,Yt,"f"))}pauseAd(){var e,t;if(!s(this,jt,"f"))return;let i=-1!==s(this,Wt,"f")?s(this,Wt,"f"):s(this,qt,"f");const n=null===(e=s(this,Ut,"f")[i])||void 0===e?void 0:e.ad;null==n||n.pauseAd(),null===(t=s(this,Bt,"f"))||void 0===t||t.pause()}resumeAd(){var e,t;if(!s(this,jt,"f"))return;let i=-1!==s(this,Wt,"f")?s(this,Wt,"f"):s(this,qt,"f");const n=null===(e=s(this,Ut,"f")[i])||void 0===e?void 0:e.ad;null==n||n.resumeAd(),null===(t=s(this,Bt,"f"))||void 0===t||t.startOrResume()}destroy(){var e,t;i(this,Vt,-1,"f"),i(this,xt,-1,"f"),i(this,Wt,-1,"f"),i(this,Kt,!1,"f"),i(this,jt,!1,"f"),null===(e=s(this,Bt,"f"))||void 0===e||e.clear(),null===(t=s(this,Ut,"f"))||void 0===t||t.forEach((e=>{var t,s;e.playing=!1,null===(s=null===(t=null==e?void 0:e.ad)||void 0===t?void 0:t.getVmaxAd())||void 0===s||s.destroy()})),i(this,Ut,[],"f"),this.adEventListeners.clear(),console.debug("Ad Insertion Destroyed"),i(this,Gt,!0,"f")}}function ds(e){const{eventName:t,payload:s={}}=e||{},i=new CustomEvent(t,{detail:s});window.dispatchEvent(i)}Lt=new WeakMap,Mt=new WeakMap,Ut=new WeakMap,Vt=new WeakMap,xt=new WeakMap,Wt=new WeakMap,Kt=new WeakMap,jt=new WeakMap,Ft=new WeakMap,Yt=new WeakMap,Gt=new WeakMap,Bt=new WeakMap,Ht=new WeakMap,qt=new WeakMap,Qt=new WeakMap,zt=new WeakMap,bt=new WeakSet,Xt=function(e){0!==e.length&&e.forEach(((e,t)=>{e.addEventListenerOnce(fs.AdEvents.AD_READY,s(this,Qt,"f").bind(this,e)),e.addEventListenerOnce(fs.AdEvents.AD_ERROR,s(this,zt,"f").bind(this,e))}))},Zt=function(){this.build(),this.process()},$t=function(e,t){var n;if(s(this,Gt,"f"))return void console.warn("Ad Insertion is already destroyed");const{duration:r=-1}=t||{};if(r0)return void console.warn("Ad Duration less than minimum duration, hence skipping ad insertion");if(s(this,jt,"f"))return;this.events.dispatchEvent(v.AD_INSERTION_START,{eventName:v.AD_INSERTION_START,duration:r}),console.debug("Ads Insertion started");0!==s(this,Ut,"f").filter((e=>e.cached&&e.canPlay)).length?(s(this,Lt,"f").style.display="block",i(this,Yt,s(this,Ft,"f").muteState,"f"),null===(n=s(this,Ft,"f"))||void 0===n||n.mutePlayer(!0),i(this,Wt,0,"f"),i(this,Kt,!1,"f"),i(this,jt,!0,"f"),s(this,Vt,"f")>0&&(i(this,Bt,new wt(s(this,bt,"m",rs).bind(this),s(this,Vt,"f")),"f"),s(this,Bt,"f").startOrResume()),s(this,bt,"m",ts).call(this)):console.warn("No cached Ads to Show")},Jt=function(e,t,s){const i=s.bind(this,e);this.adEventListeners.set(e,Object.assign(Object.assign({},this.adEventListeners.get(e)),{[t]:i})),e.addEventListenerOnce(t,i)},es=function(e,t){const s=this.adEventListeners.get(e);s&&s[t]&&(e.removeEventListener(t,s[t]),delete s[t])},ts=function e(){var t;if(s(this,jt,"f"))if(s(this,Wt,"f")s(this,bt,"m",Jt).call(this,e,fs.AdEvents.AD_CLOSED,s(this,bt,"m",ns).bind(this,n))),0),i(this,qt,s(this,Wt,"f"),"f")}else n.playing=!1,s(this,Wt,"f")e.cached&&e.canPlay));!s(this,Kt,"f")&&0===t.length&&s(this,Mt,"f")===I.REPEAT&&s(this,Ut,"f")[s(this,Wt,"f")].ad.isAdCached?s(this,bt,"m",Jt).call(this,e.ad,fs.AdEvents.AD_RENDERED,s(this,bt,"m",is).bind(this,e.ad)):!s(this,Kt,"f")&&0===t.length&&s(this,Ut,"f")[s(this,Wt,"f")].ad.isAdCached?s(this,bt,"m",Jt).call(this,e.ad,fs.AdEvents.AD_CLOSED,s(this,bt,"m",rs).bind(this)):s(this,Kt,"f")||0!==t.length||!1!==e.playing||s(this,bt,"m",rs).call(this)},is=function e(t){if(s(this,Mt,"f")!==I.REPEAT)return;const n=s(this,Ut,"f").filter((e=>"regular"===e.type&&!e.cached&&e.canPlay));s(this,bt,"m",Jt).call(this,t,fs.AdEvents.AD_RENDERED,s(this,bt,"m",e).bind(this,t));const r=Ct();n.forEach((e=>{r.addAdSpace(e.ad)})),r.build(),fs.process(r),i(this,Wt,-1,"f"),s(this,bt,"m",Xt).call(this,n.map((e=>e.ad)))},ns=function(e){var t;!s(this,Kt,"f")&&e.playing&&(e.playing=!1,s(this,bt,"m",es).call(this,e.ad,fs.AdEvents.AD_CLOSED),i(this,Wt,(t=s(this,Wt,"f"),++t),"f"),s(this,Wt,"f"){e.playing=!1}));let r=-1!==s(this,Wt,"f")?s(this,Wt,"f"):s(this,qt,"f");if(s(this,Wt,"f"){}))}this.events.dispatchEvent(v.AD_INSERTION_END,{eventName:v.AD_INSERTION_END}),s(this,Lt,"f").style.display="none",i(this,jt,!1,"f"),null===(n=s(this,Ft,"f"))||void 0===n||n.mutePlayer(s(this,Yt,"f")),s(this,bt,"m",Zt).call(this)},function(e){e.READY="VmaxAdManagerReady",e.FAILED="VmaxAdManagerFailed",e.INITIALIZED="VmaxAdManagerInitialized"}(as||(as={}));var ls,hs=as;!function(e){e[e.UNKNOWN=-1]="UNKNOWN",e[e.PORTRAIT=1]="PORTRAIT",e[e.LANDSCAPE=2]="LANDSCAPE",e[e.ADAPTIVE=3]="ADAPTIVE"}(ls||(ls={}));var us=ls;window.VmaxAdEvents=class{static handleClick(t){const{deepLinkUrl:s="",linkFallback:i=""}=t;e(s,i)}};var fs=Object.freeze({Registry:le.getInstance,getUser:me.getInstance,getSite:he.getInstance,getApp:C.getInstance,getDevice:ae.getInstance,getSourceConfiguration:()=>Ae.instance,initialize:function(e){return t(this,void 0,void 0,(function*(){try{const{ACCOUNT_KEY:t,APP_ID:s,SDK_INITIALIZED:i,IS_APP:r,KEY_ID:o,PRIVATE_KEY:c}=p;if(R.isSDKInitialized)return Promise.reject("SDK already initialized");const{accountKey:d,appId:l,privateKey:h,keyId:u,isApp:A=!1}=e,E=f(d),v=n(l),g=a(A),m=n(h),I=n(u);g&&A&&console.warn("IsApp is set to true, all Site Level targeting will be ignored"),g&&!A&&console.warn("IsApp is set to false, all App Level targeting will be ignored");return E&&v&&g&&m&&I?(R.set({[t]:d,[s]:l,[r]:A,[c]:h,[o]:u}),yield Ae.getInstance(),R.set(i,!0),setTimeout((()=>ds({eventName:hs.INITIALIZED})),0),console.warn('The "adInfo" object in ad/media event arguments will be deprecated in next release. \nPlease use AdSpace?.getVmaxAd().getVmaxAdInfo() method instead.'),Promise.resolve()):Promise.reject(new Error(_e.INVALID_INITIALIZE_OPTION.message))}catch(e){return console.error("Error in initialize",e),setTimeout((()=>ds({eventName:hs.FAILED})),0),Promise.reject(e)}}))},createAdSpace:function(e){return new os(e)},createAdspotRequestBuilder:Ct,createAdsInsertionRequestBuilder:function({pluginInstance:e,adsContainer:t}){return new cs(e,t)},process:kt,AdEvents:v,Orientation:us,AdsRecurrence:I,get isApp(){return R.get(p.IS_APP)}});return setTimeout((()=>ds({eventName:hs.READY})),0),fs}));