!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 i=function(e,t){const i=navigator.userAgent.match(/Android/i),s=navigator.userAgent.match(/Chrome/i),n=e&&i&&s;if(!n)return!1;const r=function(e,t){try{const i=e.split("://"),s=i[0];return`intent://${i[1]}/#Intent;scheme=${s};S.browser_fallback_url=${t||""};end`}catch(e){return!1}}(e,t);return r||!1}(e,t),s=i||t;window.open(s,"_blank")}function t(e,t,i,s){return new(i||(i=Promise))((function(n,r){function a(e){try{c(s.next(e))}catch(e){r(e)}}function o(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,o)}c((s=s.apply(e,t||[])).next())}))}function i(e,t,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(e):s?s.value:t.get(e)}function s(e,t,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!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"===s?n.call(e,i):n?n.value=i:t.set(e,i),i}"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),i=Object.keys(e).every((e=>"string"==typeof e)),s=Object.values(e).every((e=>"string"==typeof e));return t&&i&&s},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 i=e.prototype;return t.every((e=>n(e)&&"function"==typeof i[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 p,g,m,I,_,D=E;!function(e){e.GEO_PROFILE="geoProfile",e.USER_PROFILE="userProfile"}(p||(p={})),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",e.UPS_FIRST_FETCH_DONE="upsFirstFetchDone",e.UPS_SERVICE_CALL="UPSServiceCall",e.DGS_SERVICE_CALL="DGSServiceCall"}(g||(g={})),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?i(this,_,"f").set(e,t):Object.entries(e).forEach((([e,t])=>{i(this,_,"f").set(e,t)}))}get(e){var t;return"string"!=typeof e||0==e.length?i(this,_,"f"):null!==(t=i(this,_,"f").get(e))&&void 0!==t?t:null}get isSDKInitialized(){return Boolean(i(this,_,"f").get(g.SDK_INITIALIZED))}}_=new WeakMap,y.instance=new y;const R=y.getInstance();var S,T,w,O,N,P;class C{constructor(){S.add(this),this.AppInstance=T.getInstance(),w.set(this,{id:""})}static getInstance(){return T.instance}setVersion(e){return i(this,S,"m",O).call(this),i(this,w,"f").version=e,T.instance}setOrientation(e){var t;return i(this,S,"m",O).call(this),void 0===(null===(t=i(this,w,"f"))||void 0===t?void 0:t.ext)&&(i(this,w,"f").ext={}),i(this,w,"f").ext.orientation=e,this}getPayload(){return i(this,S,"m",N).call(this),i(this,w,"f")}setPageCategory(e){return i(this,S,"m",O).call(this),h(e)||!c(e)||(i(this,w,"f").pagecat=e),this}setCustomData(e){return i(this,S,"m",O).call(this),o(e)&&(i(this,w,"f").ext||(i(this,w,"f").ext={}),"object"==typeof i(this,w,"f").ext&&null!==i(this,w,"f").ext?i(this,w,"f").ext=Object.assign(Object.assign({},i(this,w,"f").ext),{customkeys:e}):i(this,w,"f").ext={customkeys:e}),this}setSectionCategory(e){return i(this,S,"m",O).call(this),h(e)||!c(e)||(i(this,w,"f").sectioncat=e),this}setKeywords(e){return i(this,S,"m",O).call(this),c(e)&&e.every((e=>n(e)))?(i(this,w,"f").kwarray=[...e],T.instance):T.instance}}T=C,w=new WeakMap,S=new WeakSet,O=function(){const e=R.get(g.IS_APP);return!!R.get(g.SDK_INITIALIZED)&&(e||console.warn("Since App is not set, App level targeting will be ignored"),e)},N=function(){const e=R.get(g.APP_ID);if(e)return i(this,w,"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,L,b,M,U,V,x,W,K,j,F,G,Y,B,H,q,X,Q,z,Z,$,J,ee,te,ie=P;function se(e){return"object"!=typeof e||Array.isArray(e)?null:Object.keys(e).reduce(((t,i)=>(t[i]=e[i],t)),{})}class ne{constructor(){k.add(this),L.set(this,{}),this.DeviceType=se(D),this.ConnectionType=se(ie)}static getInstance(){return ne.instance}setLocation(e){if(!(e instanceof GeolocationCoordinates))return ne.instance;const{latitude:t,longitude:s,accuracy:n}=e;return i(this,L,"f").geolocationCoordinates={type:1,lat:t,lon:s,accuracy:n},ne.instance}setDeviceType(e){return n(e)?(i(this,L,"f").type=e,ne.instance):ne.instance}setConnectionType(e){return n(e)?(i(this,L,"f").connectionType=e,ne.instance):ne.instance}setSimOperatorOrMccMnc(e){return n(e)?(i(this,L,"f").mccmnc=e,ne.instance):ne.instance}setMake(e){return n(e)?(i(this,L,"f").make=e,ne.instance):ne.instance}setModel(e){return n(e)?(i(this,L,"f").model=e,ne.instance):ne.instance}get(){return i(this,L,"f")}setAdvertisingId(e){return n(e)?(i(this,L,"f").ifa=e,this):ne.instance}setCarrier(e){return n(e)?(i(this,L,"f").carrier=e,this):ne.instance}setMarketingName(e){return n(e)?(i(this,L,"f").maketingName=e,this):ne.instance}setPlatform(e){return n(e)?(i(this,L,"f").platformId=e,this):ne.instance}getPayload(){var e;const{GEO_PROFILE:t}=g,{geolocationCoordinates:s,type:n,connectionType:r,ifa:a,carrier:o,maketingName:c,platformId:d,mccmnc:l,make:h,model:u}=i(this,L,"f"),f=null===(e=R.get(t))||void 0===e?void 0:e.geo,A=s||f||!1,E={ua:i(this,k,"a",b),language:i(this,k,"a",M)};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}}L=new WeakMap,k=new WeakSet,b=function(){return window.navigator.userAgent},M=function(){return navigator.language},ne.instance=new ne;class re{isRequestAllowed(e){try{const t=e.payload,i=null==t?void 0:t.imp;return!(!i||0===Object.keys(i).length)}catch(e){return console.warn(e),!1}}}function ae(...e){console.warn.apply(console,e)}function oe(...e){console.error.apply(console,e)}class ce{constructor(){U.set(this,new Map),V.set(this,[new re])}static get getInstance(){return ce.instance}addVmaxAd(e){if(!u(e))return oe("Registry: must be a valid VmaxAd");let t=new e;i(this,U,"f").set(e,[].concat(t.getAllSignatures())),t=null}removeVmaxAd(e){if(!u(e))return oe("Registry: must be a valid VmaxAd");i(this,U,"f").delete(e)}getVmaxAd(e){let t=Array.from(i(this,U,"f").entries()).find((([t,i])=>i.includes(e)));return t?t[0]:null}getAllSignatures(){let e=Array.from(i(this,U,"f").values()).reduce(((e,t)=>e.concat(t)),[]);return Array.from(new Set(e))}addRequestAdvisor(e){i(this,V,"f").some((t=>t instanceof e.constructor))?ae("Advisor already present"):i(this,V,"f").push(e)}removeRequestAdvisor(e){i(this,V,"f").forEach(((t,s)=>{t instanceof e.constructor&&i(this,V,"f").splice(s,1)}))}getAdvisors(){return i(this,V,"f")}}U=new WeakMap,V=new WeakMap,ce.instance=new ce;class de{constructor(){x.add(this),W.set(this,void 0),K.set(this,void 0),j.set(this,{id:""})}static getInstance(){return de.instance}setPageURL(e){return i(this,x,"m",F).call(this),d(e)?(i(this,j,"f").pageUrl=e,de.instance):de.instance}setReferrerURL(e){return i(this,x,"m",F).call(this),d(e)?(i(this,j,"f").referrerUrl=e,de.instance):de.instance}setSearchFor(e){return i(this,x,"m",F).call(this),n(e)?(i(this,j,"f").searchFor=encodeURIComponent(e),de.instance):de.instance}getPayload(){return i(this,x,"m",Y).call(this),i(this,x,"m",B).call(this),i(this,x,"m",G).call(this),i(this,j,"f")}setPageCategory(e){return i(this,x,"m",F).call(this),h(e)||!c(e)||(i(this,j,"f").pagecat=e),this}setCustomData(e){return i(this,x,"m",F).call(this),o(e)&&(i(this,j,"f").ext={customkeys:e}),this}setSectionCategory(e){return i(this,x,"m",F).call(this),h(e)||!c(e)||(i(this,j,"f").sectioncat=e),this}setKeywords(e){return i(this,x,"m",F).call(this),c(e)&&e.every((e=>n(e)))?(i(this,j,"f").kwarray=[...e],de.instance):de.instance}}W=new WeakMap,K=new WeakMap,j=new WeakMap,x=new WeakSet,F=function(){const e=R.get(g.IS_APP);return!R.get(g.SDK_INITIALIZED)||(e&&console.warn("Since App is set, site level targeting will be ignored"),e)},G=function(){const e=R.get(g.APP_ID);i(this,j,"f").id=e},Y=function(){var e;return!(null===(e=i(this,j,"f"))||void 0===e?void 0:e.pageUrl)&&(i(this,j,"f").pageUrl=window.location.href,!0)},B=function(){var e;if(!!(null===(e=i(this,j,"f"))||void 0===e?void 0:e.referrerUrl))return!1;return!!document.referrer&&(i(this,j,"f").referrerUrl=document.referrer),!0},de.instance=new de,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]"}(H||(H={}));class le{static post(e){return t(this,void 0,void 0,(function*(){const{url:t,payload:i,headers:s={},credentials:n}=e||{};let r={method:"POST",body:JSON.stringify(i)};n&&(r.credentials=n),s&&(r.headers=s);const a=new AbortController;r.signal=a.signal;return[fetch(t,r).then((e=>e.ok?e.json().catch((()=>Promise.reject(oe("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(g.ACCOUNT_KEY),t=R.get(g.DGS_ENDPOINT);R.get(g.DGS_XAUTH);const i=(t||"").replace("ACCOUNT_KEY",e);return q.get(i)}static UserProfileService(e){return t(this,void 0,void 0,(function*(){const t=R.get(g.ACCOUNT_KEY),i=R.get(g.UPS_ENDPOINT),s=R.get(g.UPS_XAUTH),n=(i||"").replace("ACCOUNT_KEY",t),[r]=yield q.post({url:n,headers:{"X-AUTH":s},payload:e});return r}))}static AdQuery(e){const{ACCOUNT_KEY:t,AS_ENDPOINT:i}=g,s=R.get(t)||"",n=R.get(i);return q.post({url:n.replace("ACCOUNT_KEY",s),payload:e,credentials:"include"})}static replaceAllMacros(e,t){const i=Object.keys(H);if(0===i.length)return e;const{ifa:s=""}=window.VmaxAdManager.getDevice().getPayload();return i.forEach((i=>{var n;const r=H[i];let a;a=r===H.randomCcb?Date.now().toString():r===H.deviceIFA?s: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||i.forEach((t=>{const i=H[t],s=new RegExp(this.escapeRegExp(i),"g");e=e.replace(s,"")})),e}static escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}static FireTracker(e,s){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,s),yield i(q,q,"m",X).call(q,t)}))}}function he(e){return t(this,void 0,void 0,(function*(){const{PRIVATE_KEY:t,KEY_ID:i}=g,s=R.get(t);R.get(i);try{const t=function(e){const t=atob(e),i=t.length,s=new Uint8Array(i);for(let e=0;e> decryptedData",a),R.set(s,a),i(t=i(this,z,"f",Z),Q,"m",ee).call(t,a),Promise.resolve(i(this,z,"f",Z))}catch(e){return Promise.reject(new Error("Failed to load source config"))}}return i(this,z,"f",Z)}))}static get instance(){return i(this,z,"f",Z)||null}getConfig(e){var t,s;return"string"==typeof e&&e?null!==(s=null===(t=i(this,$,"f"))||void 0===t?void 0:t[e])&&void 0!==s?s:null:Object.assign({},i(this,$,"f"))}getURL(e){const{ACCOUNT_KEY:t,APP_ID:i,KEY_ID:s}=g,n={ACCOUNT_KEY:R.get(t),SOURCE_ID:R.get(i),KEY_ID:R.get(s)};return(e||"").replace(/ACCOUNT_KEY|SOURCE_ID|KEY_ID/g,(e=>n[e]||e))}}z=ue,$=new WeakMap,J=new WeakMap,Q=new WeakSet,ee=function(e){if("object"!=typeof e||Array.isArray(e)||!e)return;Object.keys(e).forEach((t=>{i(this,J,"f").includes(t)||(i(this,$,"f")[t]=e[t])}))},te=function(){return t(this,void 0,void 0,(function*(){try{const e=this.getURL("https://assets.talia.telkomsel.com/ACCOUNT_KEY/source-config/1.0.0/SOURCE_ID/KEY_ID"),t=yield le.getPlainResponse(e);return Promise.resolve(t)}catch(e){return Promise.reject("Failed to load source data.")}}))},Z={value:void 0};var fe,Ae,Ee,ve;class pe{constructor(){fe.add(this),Ae.set(this,{}),s(this,Ae,{},"f")}static getInstance(){return pe.instance}setId(e){return n(e)?(i(this,Ae,"f").uid=e,pe.instance):pe.instance}setGender(e){return n(e)?(i(this,Ae,"f").gender=e,pe.instance):pe.instance}setAge(e){return n(e)?(i(this,Ae,"f").age=e,pe.instance):pe.instance}setCity(e){return n(e)?(i(this,Ae,"f").city=e,pe.instance):pe.instance}setRegion(e){return n(e)?(i(this,Ae,"f").region=e,pe.instance):pe.instance}setCountry(e){return n(e)?(i(this,Ae,"f").country=e,pe.instance):pe.instance}setZipcode(e){return n(e)&&(e=>/^\d+$/.test(e))(e)?(i(this,Ae,"f").zip=e,pe.instance):pe.instance}setKeywords(e){return c(e)||e.every((e=>n(e)))?(i(this,Ae,"f").keywordsArray=[...e],pe.instance):pe.instance}setCustomData(e){var t;return o(e)&&("undefined"===(null===(t=i(this,Ae,"f"))||void 0===t?void 0:t.ext)&&(i(this,Ae,"f").ext={}),i(this,Ae,"f").ext={customkeys:e}),pe.instance}get(){return i(this,Ae,"f")}getPayload(){var e;const{uid:t,keywordsArray:s,country:n,region:r,city:a,zip:o,ext:c,age:d,gender:l}=i(this,Ae,"f"),{USER_PROFILE:h}=g,u=null===(e=R.get(h))||void 0===e?void 0:e.user;let f={};t&&(f.id=t),s&&(f.kwarray=s);!!(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=i(this,fe,"m",Ee).call(this);return A&&(f.data=A),f=Object.assign(Object.assign({},f),u),f}}Ae=new WeakMap,fe=new WeakSet,Ee=function(){const{age:e,gender:t}=i(this,Ae,"f");if(!!e||!!t){let i=[];t&&i.push({name:"gender",value:t}),e&&i.push({name:"age",value:e});return[{segment:i}]}return!1},pe.instance=new pe,function(e){e.PAUSED="paused",e.RESUMED="resumed",e.STARTED="started",e.COMPLETED="completed",e.NOT_READY="not_ready"}(ve||(ve={}));var ge=ve;const me={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 Ie,_e,De,ye,Re,Se,Te,we,Oe,Ne,Pe,Ce,ke,Le,be,Me,Ue,Ve,xe,We,Ke,je,Fe,Ge,Ye,Be,He,qe,Xe,Qe,ze,Ze,$e,Je,et,tt,it,st,nt,rt,at,ot,ct,dt,lt,ht,ut,ft,At,Et,vt,pt,gt,mt,It,_t,Dt;Object.freeze(me);class yt{constructor(){Ie.set(this,new Map),_e.set(this,new Map)}addEventListener(e,t){var s;if("string"!=typeof e)throw new Error("Invalid Event");if("function"!=typeof t)throw new Error("Invalid Callback");i(this,Ie,"f").has(e)||i(this,Ie,"f").set(e,[]),null===(s=i(this,Ie,"f").get(e))||void 0===s||s.push(t)}addEventListenerOnce(e,t){var s;if("string"!=typeof e)throw new Error("Invalid Event");if("function"!=typeof t)throw new Error("Invalid Callback");i(this,_e,"f").has(e)||i(this,_e,"f").set(e,[]),null===(s=i(this,_e,"f").get(e))||void 0===s||s.push(t)}removeEventListener(e,t){var s,n;if("string"!=typeof e)throw new Error("Invalid Event");if("function"!=typeof t)throw new Error("Invalid Callback");if(!i(this,Ie,"f").has(e)&&!i(this,_e,"f").get(e))return;const r=i(this,Ie,"f").get(e),a=i(this,_e,"f").get(e),o=null!==(s=null==r?void 0:r.indexOf(t))&&void 0!==s?s:-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)),i(this,Ie,"f").set(e,r||[]),i(this,_e,"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");i(this,Ie,"f").has(e)&&i(this,Ie,"f").delete(e),i(this,_e,"f").has(e)&&i(this,_e,"f").delete(e)}dispatchEvent(e,...t){if("string"!=typeof e)throw new Error("Invalid Event");if(!i(this,Ie,"f").has(e)&&!i(this,_e,"f").get(e))return;const s=i(this,Ie,"f").get(e),n=i(this,_e,"f").get(e);null==s||s.forEach((e=>e(...t))),null==n||n.forEach((e=>e(...t))),i(this,_e,"f").set(e,[])}}Ie=new WeakMap,_e=new WeakMap;class Rt{constructor(e,t){if(De.add(this),ye.set(this,null),Re.set(this,0),Se.set(this,0),Te.set(this,!1),we.set(this,(()=>{})),Oe.set(this,0),Ne.set(this,!1),Pe.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");s(this,we,e,"f"),s(this,Oe,t,"f")}pause(){i(this,Ne,"f")||i(this,ye,"f")&&(clearTimeout(i(this,ye,"f")),s(this,Se,i(this,Se,"f")-(Date.now()-i(this,Re,"f")),"f"),s(this,Te,!0,"f"))}startOrResume(){if(!i(this,Pe,"f"))return i(this,De,"m",Ce).call(this);i(this,Ne,"f")||i(this,Te,"f")&&(s(this,Te,!1,"f"),i(this,De,"m",ke).call(this))}clear(){i(this,Ne,"f")||i(this,ye,"f")&&(clearTimeout(i(this,ye,"f")),s(this,ye,null,"f"),s(this,Ne,!0,"f"))}get isFinished(){return i(this,Ne,"f")}}ye=new WeakMap,Re=new WeakMap,Se=new WeakMap,Te=new WeakMap,we=new WeakMap,Oe=new WeakMap,Ne=new WeakMap,Pe=new WeakMap,De=new WeakSet,Ce=function(){i(this,Pe,"f")||i(this,Ne,"f")||(s(this,Pe,!0,"f"),i(this,De,"m",ke).call(this))},ke=function(){i(this,Te,"f")||(s(this,Re,Date.now(),"f"),s(this,Se,i(this,Se,"f")||1e3*i(this,Oe,"f"),"f")),s(this,ye,setTimeout((()=>{s(this,Te,!1,"f"),s(this,Ne,!0,"f"),i(this,we,"f").call(this)}),i(this,Se,"f")),"f")};class St{constructor(){Le.add(this),be.set(this,{})}static getInstance(){return St.instance}getPayload(e){return{modules:{adsignatures:[...i(this,Le,"m",Me).call(this,e)]}}}}function Tt(e){try{for(const t in e){const i=e[t];null!=i&&i||delete e[t],"object"!=typeof i||Array.isArray(i)||Tt(i)}return e}catch(t){return e}}function wt(){return t(this,void 0,void 0,(function*(){const{UID:e,ACCOUNT_KEY:i,GEO_PROFILE:s,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),p),g),{services:{ups:A,dgs:E,as:v}}=R.get(a)||{},{INVALID_SERVICE_ENDPOINT:I,INVALID_API_KEY:_}=me,{domain:D,apikey:y}=A||{},{domain:S}=E||{},{domain:T}=v||{};if(!n(T))return Promise.reject(I.message);if(n(D)&&n(S)&&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 w=R.get(i);if(!w||!f(w))return Promise.reject();const O=yield function(e,i){return t(this,arguments,void 0,(function*(e,t,i="base64"){const s=new TextEncoder,n=s.encode(t),r=s.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"===i){return Array.from(new Uint8Array(t)).map((e=>e.toString(16).padStart(2,"0"))).join("")}if("base64"===i)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}}))}(w,y);return R.set({[o]:D+"/ACCOUNT_KEY/",[c]:S+"/ACCOUNT_KEY/",[l]:O}),Promise.resolve()}))}function Ot(e){return t(this,void 0,void 0,(function*(){try{const{ignoreExpiry:i=!1}=e||{};let s=!0,n=!0;const{GEO_PROFILE:r,USER_PROFILE:a,ACCOUNT_KEY:o,UPS_FIRST_FETCH_DONE:c,UPS_SERVICE_CALL:d,DGS_SERVICE_CALL:h}=Object.assign(Object.assign(Object.assign({},m),p),g),u=R.get(r),f=R.get(a),A=R.get(h),E=R.get(d),v=null!==E,I=null!==A;console.log(u,f);const _=i||l(null==u?void 0:u.expiry),D=R.get(o),y=i||l(null==f?void 0:f.expiry);if(!(_||y))return Promise.resolve();const S=pe.getInstance().get(),T=[];if(I)T.push(A),n=!1;else if(_){const e=le.DeviceGeoService();T.push(e),R.set({[h]:e})}else T.push(Promise.resolve());if(v)T.push(E),s=!1;else if(y){const e=yield function(e,i,s){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=Tt({[r]:null==i?void 0:i[r],[a]:null==i?void 0:i[a],[o]:null==i?void 0:i[o],[c]:null==i?void 0:i[c]}),h=Tt({[n]:null==i?void 0:i[n],[d]:null==i?void 0:i[d],geo:l}),u=Tt({accountkey:e,identifiers:{uid:null==i?void 0:i[t]},demographics:h});return s&&(u.profile=s),u}))}(D,S,f),i=le.UserProfileService(e);T.push(i),R.set({[d]:i})}else T.push(Promise.reject());const w=yield Promise.allSettled(T),[O,N]=w,P=O.value,C=N.value,k="fulfilled"===O.status&&Number.isInteger(null==P?void 0:P.expiry),L="fulfilled"===N.status&&Number.isInteger(null==C?void 0:C.expiry);return n&&(R.set({[h]:null}),k&&R.set({[r]:P})),s&&(R.set({[d]:null}),L&&R.set({[a]:C})),Promise.resolve()}catch(e){return console.warn(e),Promise.reject()}}))}be=new WeakMap,Le=new WeakSet,Me=function(e){return e&&Array.isArray(e)&&0!==e.length?i(this,be,"f").adsignatures=e.reduce(((e,t)=>(!!ce.getInstance.getVmaxAd(t)&&e.push(t),e)),[]):i(this,be,"f").adsignatures=ce.getInstance.getAllSignatures(),i(this,be,"f").adsignatures},St.instance=new St,function(e){e[e.ACTIVE=1]="ACTIVE",e[e.INACTIVE=0]="INACTIVE",e[e.UNAVAILABLE=-1]="UNAVAILABLE"}(Ue||(Ue={}));class Nt{constructor(){Ve.add(this),xe.set(this,[]),We.set(this,{}),this.events=new yt,Ke.set(this,!1),je.set(this,void 0),Fe.set(this,[])}addAdSpace(e){return e instanceof ci?(i(this,xe,"f").push(e),this):this}build(){const e=i(this,Ve,"m",Ye).call(this),t=R.get(g.IS_APP);if(e.length<1)return this;s(this,We,{imp:e,device:ne.getInstance().getPayload(),user:pe.getInstance().getPayload(),ext:St.getInstance().getPayload(i(this,Fe,"f"))},"f");const n=de.getInstance().getPayload(),r=C.getInstance().getPayload();return t?i(this,We,"f").app=r:i(this,We,"f").site=n,this}setSignatures(e){if(!Array.isArray(e)||0===e.length)return;const t=e.filter((e=>"string"==typeof e));s(this,Fe,t,"f")}process(){return i(this,Ke,"f")?Promise.reject("Ad Request already in progress"):i(this,Ve,"m",He).call(this)}abort(){i(this,je,"f")&&i(this,je,"f").abort(),i(this,xe,"f").forEach((e=>{e.onAdError(me.AD_ABORT)}))}handleAdResponse(e){var t,s;const n=(null===(s=null===(t=null==e?void 0:e.seatbid)||void 0===t?void 0:t[0])||void 0===s?void 0:s.bid)||[];i(this,xe,"f").forEach((e=>{var t=n.findIndex((t=>t.impid===e.tagId&&""!==t.adm));const i=n[t];t>=0&&n.splice(t,1),t>=0&&i?e.setCache(i):e.isAdCached||e.handleNoFill()})),i(this,Ve,"m",Ge).call(this,e)}}function Pt(){return new Nt}function Ct(e){if(!(e instanceof Nt))throw new Error("Invalid request object");return e.process()}xe=new WeakMap,We=new WeakMap,Ke=new WeakMap,je=new WeakMap,Fe=new WeakMap,Ve=new WeakSet,Ge=function(e){const t=ce.getInstance.getAdvisors(),s={payload:i(this,We,"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,s)}))},Ye=function(){return i(this,xe,"f").reduce(((e,t)=>{const i=function(e){const{SOURCE_CONFIG_DATA:t}=g,{ACTIVE:i,INACTIVE:s,UNAVAILABLE:n}=Ue,{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===i?i:s:n}(t.tagId),{ACTIVE:s,INACTIVE:n,UNAVAILABLE:r}=Ue,{AD_SPOT_INACTIVE:a,AD_SPOT_UNAVAILABLE:o}=me,c=i===s;return!t.isAdCached&&c&&e.push(t.getRequestPayload()),i===n?(console.warn("Adspot is inactive",t.tagId),t.onAdError(a)):i===r&&(console.warn("Adspot is unavailable",t.tagId),t.onAdError(o)),e}),[])},Be=function(){return t(this,void 0,void 0,(function*(){const[e,t]=yield le.AdQuery(i(this,We,"f"));return s(this,Ke,!0,"f"),s(this,je,t,"f"),e.then((e=>this.handleAdResponse(e))).catch((e=>{i(this,xe,"f").forEach((e=>{e.onAdError(me.AD_SERVER_ERROR)})),Promise.reject(e)})).finally((()=>{s(this,Ke,!1,"f")}))}))},He=function(){return t(this,void 0,void 0,(function*(){return(yield i(this,Ve,"m",qe).call(this))?(yield wt(),Ot(),i(this,Ve,"m",Be).call(this)):(i(this,xe,"f").forEach((e=>{e.isAdCached&&e.onAdError(me.AD_REQUEST_BLOCKED_BY_ADVISOR)})),Promise.reject("Ad Request Blocked by Advisor"))}))},qe=function(){return t(this,void 0,void 0,(function*(){const e=ce.getInstance.getAdvisors(),t={payload:i(this,We,"f")},s=e.map((e=>e.isRequestAllowed(t)));return Promise.all(s).then((e=>e.every((e=>!0===e))))}))};Qe=new WeakMap,ze=new WeakMap,Ze=new WeakMap,$e=new WeakMap,Je=new WeakMap,et=new WeakMap,tt=new WeakMap,it=new WeakMap,st=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,Xe=new WeakSet,Et=function(){var e,t,s,n,r;if(!i(this,et,"f"))return;const a=null===(n=null===(s=null===(t=null===(e=i(this,et,"f"))||void 0===e?void 0:e.ext)||void 0===t?void 0:t.modules)||void 0===s?void 0:s.render)||void 0===n?void 0:n.signature;if(!a)return void this.onAdError(me.VMAX_AD_NOT_REGISTERED);const o=ce.getInstance.getVmaxAd(a);if(!o||!u(o))return void this.onAdError(me.VMAX_AD_NOT_REGISTERED);const c=i(this,at,"f")&&(null===(r=i(this,it,"f"))||void 0===r?void 0:r.destroy());c instanceof Promise?c.then((()=>i(this,Xe,"m",vt).call(this,o))):i(this,Xe,"m",vt).call(this,o)},vt=function(e){var t,n,r;i(this,et,"f")&&(s(this,it,null,"f"),s(this,it,new e,"f"),i(this,At,"f")&&(null===(n=null===(t=i(this,it,"f"))||void 0===t?void 0:t.setMediaTimeOut)||void 0===n||n.call(t,i(this,At,"f"))),null===(r=i(this,it,"f"))||void 0===r||r.prepare({bid:i(this,et,"f"),listeners:i(this,nt,"f"),nativeLayout:i(this,ct,"f")||void 0,videoLayout:i(this,dt,"f")||void 0,skipVideoThumbnail:i(this,lt,"f")||void 0,requestedBitRate:i(this,Je,"f")||void 0,container:i(this,Qe,"f")||void 0}).then((()=>{var e;if(i(this,at,"f"))return i(this,Xe,"m",It).call(this);i(this,Xe,"m",gt).call(this,v.AD_READY),i(this,ft,"f")&&(null===(e=i(this,it,"f"))||void 0===e?void 0:e.setAdClickHandler)&&i(this,it,"f").setAdClickHandler(i(this,ft,"f"))})).catch((e=>{this.onAdError(e||me.PREPARE_VMAX_AD_FAILED)})))},pt=function(){var e,t,i,s,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===(s=null===(i=window.VmaxAdManager.getSite().getPayload())||void 0===i?void 0:i.ext)||void 0===s?void 0:s.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)},gt=function(e,t){var s;const n=i(this,Xe,"m",pt).call(this),r=null===(s=this.getVmaxAd())||void 0===s?void 0:s.getVmaxAdInfo();i(this,tt,"f").dispatchEvent(e,{eventName:e,adSpace:this,adInfo:Object.assign(Object.assign(Object.assign({tagId:this.tagId},r),{keyValueMap:Object.assign({},n)}),t)})},mt=function(e){const{layout:t,layoutTemplate:i}=e,s=i instanceof HTMLElement&&"TEMPLATE"===i.nodeName,n="string"==typeof t&&t.length>0;return s||n},It=function(){var e;null===(e=i(this,it,"f"))||void 0===e||e.render({container:i(this,rt,"f")}).then((e=>{this.setCache(null),s(this,ut,i(this,it,"f"),"f"),i(this,Xe,"m",gt).call(this,i(this,at,"f")?v.AD_REFRESHED:v.AD_RENDERED,e),i(this,Xe,"m",_t).call(this)})).catch((e=>{console.error("Error while rendering ad",e),this.onAdError(me.RENDITION_FAILED)}))},_t=function(e=!1){var t,n;(null===(t=i(this,it,"f"))||void 0===t?void 0:t.shouldProcessRefresh)&&i(this,Ze,"f")>0&&(s(this,ot,new Rt(i(this,Xe,"m",Dt).bind(this),i(this,Ze,"f")),"f"),e&&i(this,ot,"f").startOrResume()),!i(this,at,"f")&&(null===(n=i(this,it,"f"))||void 0===n?void 0:n.shouldProcessRefresh)&&s(this,at,!0,"f")},Dt=function e(){var t,n;if(!i(this,ot,"f"))return void console.warn("adRefreshTimer is empty or null");i(this,ot,"f").clear(),s(this,ot,null,"f");const r=null===(t=i(this,it,"f"))||void 0===t?void 0:t.canRefresh;if(void 0===r||!0===r){(a=this,Ct(Pt().addAdSpace(a).build())).catch((e=>(console.log("Error in singleAdRequest",e),i(this,Xe,"m",_t).call(this,!0))))}else{var a;(null===(n=i(this,it,"f"))||void 0===n?void 0:n.shouldProcessRefresh)&&(s(this,ot,new Rt(i(this,Xe,"m",e).bind(this),i(this,Ze,"f")),"f"),i(this,ot,"f").startOrResume())}};var kt,Lt,bt,Mt,Ut,Vt,xt,Wt,Kt,jt,Ft,Gt,Yt,Bt,Ht,qt,Xt,Qt,zt,Zt,$t,Jt,ei,ti,ii,si,ni,ri,ai,oi,ci=class{constructor(e){Xe.add(this),Qe.set(this,void 0),ze.set(this,!1),Ze.set(this,30),$e.set(this,-1),Je.set(this,void 0),et.set(this,null),tt.set(this,new yt),it.set(this,void 0),st.set(this,ge.NOT_READY),nt.set(this,{AdClicked:this.onAdClicked.bind(this),AdPaused:this.onAdPaused.bind(this),AdResumed:this.onAdResumed.bind(this),AdImpression:e=>i(this,Xe,"m",gt).call(this,v.AD_IMPRESSION,e),AdUserClose:e=>i(this,Xe,"m",gt).call(this,v.AD_USER_CLOSE,e),AdClosed:e=>i(this,Xe,"m",gt).call(this,v.AD_CLOSED,e),AdVolumeChanged:e=>i(this,Xe,"m",gt).call(this,v.AD_VOLUME_CHANGED,e),AdMuted:e=>i(this,Xe,"m",gt).call(this,v.AD_MUTED,e),AdUnmuted:e=>i(this,Xe,"m",gt).call(this,v.AD_UNMUTED,e),AdSkipped:e=>i(this,Xe,"m",gt).call(this,v.AD_SKIPPED,e),AdVideoStart:e=>i(this,Xe,"m",gt).call(this,v.AD_VIDEO_START,e),AdVideoFirstQuartile:e=>i(this,Xe,"m",gt).call(this,v.AD_VIDEO_FIRST_QUARTILE,e),AdVideoMidpoint:e=>i(this,Xe,"m",gt).call(this,v.AD_VIDEO_MIDPOINT,e),AdVideoThirdQuartile:e=>i(this,Xe,"m",gt).call(this,v.AD_VIDEO_THIRD_QUARTILE,e),AdVideoComplete:e=>i(this,Xe,"m",gt).call(this,v.AD_VIDEO_COMPLETE,e),AdSkippableStateChange:e=>i(this,Xe,"m",gt).call(this,v.AD_SKIPPABLE_STATE_CHANGE,e),AdVideoProgress:e=>i(this,Xe,"m",gt).call(this,v.AD_PROGRESS,e),AdMediaExpand:e=>i(this,Xe,"m",gt).call(this,v.AD_MEDIA_EXPAND,e),AdMediaCollapse:e=>i(this,Xe,"m",gt).call(this,v.AD_MEDIA_COLLAPSE,e),AdError:e=>this.onAdError(e)}),rt.set(this,void 0),at.set(this,!1),ot.set(this,null),ct.set(this,void 0),dt.set(this,void 0),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),R.isSDKInitialized;const{tagId:t,container:r}=e||{};n(t),this.tagId=t,s(this,Qe,r,"f")}setInterstitialExperience(e){return a(e)?(s(this,ze,e,"f"),this):this}setRefreshRate(e){return 0===e&&s(this,Ze,0,"f"),!Number.isInteger(e)||e<30||s(this,Ze,e,"f"),this}setOrientation(e){return s(this,$e,e,"f"),this}setNativeLayout(e){i(this,Xe,"m",mt).call(this,e)?s(this,ct,e,"f"):ae("AdSpace: Invalid native layout")}setVideoLayout(e){i(this,Xe,"m",mt).call(this,e)?s(this,dt,e,"f"):ae("AdSpace: Invalid video layout")}setVideoSkipThumbnail(e){const{source:t=""}=e||{};try{s(this,lt,new URL(t),"f")}catch(e){ae("AdSpace: Invalid video skip thumbnail source")}}setVolume(e){var t;"number"!=typeof e||e<0||e>1||(null===(t=i(this,it,"f"))||void 0===t?void 0:t.setVolume)&&i(this,it,"f").setVolume(e)}setFullscreenContainer(e){var t;e instanceof HTMLElement?(null===(t=i(this,it,"f"))||void 0===t?void 0:t.setFullscreenContainer)&&i(this,it,"f").setFullscreenContainer(e):ae("AdSpace: Invalid container")}setRequestedBitRate(e){"number"!=typeof e||e<0||s(this,Je,e,"f")}setAdClickHandler(e){var t;"function"==typeof e&&(s(this,ft,e,"f"),(null===(t=i(this,it,"f"))||void 0===t?void 0:t.setAdClickHandler)&&i(this,it,"f").setAdClickHandler(e))}closeAd(){const e=i(this,ut,"f")||i(this,it,"f");return(null==e?void 0:e.closeAd)?Promise.resolve(e.closeAd()).then((()=>{var e;s(this,ut,null,"f"),null===(e=i(this,ot,"f"))||void 0===e||e.clear(),s(this,ot,null,"f")})):Promise.resolve()}setCache(e){s(this,et,e,"f"),i(this,Xe,"m",Et).call(this)}setSecure(e){return a(e)?(s(this,ht,e,"f"),this):this}get isAdCached(){return!!i(this,et,"f")}setMediaLoadTimeout(e){var t,n;return e<=0||(s(this,At,e,"f"),null===(n=null===(t=i(this,it,"f"))||void 0===t?void 0:t.setMediaTimeOut)||void 0===n||n.call(t,e)),this}getRequestPayload(){const e={tagid:this.tagId,instl:i(this,ze,"f")?1:0,displaymanager:"vmax",displaymanagerver:"A-WEB-4.1.8",ext:{orientation:i(this,$e,"f")},secure:1};return void 0!==i(this,ht,"f")&&(e.secure=i(this,ht,"f")?1:0),e}handleNoFill(){this.onAdError(me.NO_FILL),i(this,it,"f")&&i(this,Xe,"m",_t).call(this,!0)}addEventListener(e,t){if(!Object.values(v).includes(e))throw new Error("AdSpace: Invalid Event");i(this,tt,"f").addEventListener(e,t)}addEventListenerOnce(e,t){if(!Object.values(v).includes(e))throw new Error("AdSpace: Invalid Event");i(this,tt,"f").addEventListenerOnce(e,t)}removeEventListener(e,t){i(this,tt,"f").removeEventListener(e,t)}removeAllEventListeners(e){i(this,tt,"f").removeAllEventListeners(e)}onAdError(e){var t,n;if(null===(n=null===(t=i(this,et,"f"))||void 0===t?void 0:t.ext)||void 0===n?void 0:n.fallback)return s(this,et,i(this,et,"f").ext.fallback,"f"),i(this,Xe,"m",Et).call(this);i(this,tt,"f").dispatchEvent(v.AD_ERROR,{eventName:v.AD_ERROR,errorObject:e,adSpace:this})}onAdPaused(){var e;null===(e=i(this,ot,"f"))||void 0===e||e.pause(),s(this,st,ge.PAUSED,"f"),i(this,Xe,"m",gt).call(this,v.AD_PAUSED)}onAdResumed(){var e;null===(e=i(this,ot,"f"))||void 0===e||e.startOrResume(),i(this,st,"f")===ge.PAUSED&&(i(this,Xe,"m",gt).call(this,v.AD_RESUMED),s(this,st,ge.RESUMED,"f"))}pauseAd(){var e,t;(null===(e=i(this,it,"f"))||void 0===e?void 0:e.pauseAd)&&(null===(t=i(this,it,"f"))||void 0===t||t.pauseAd())}resumeAd(){var e,t;(null===(e=i(this,it,"f"))||void 0===e?void 0:e.resumeAd)&&(null===(t=i(this,it,"f"))||void 0===t||t.resumeAd())}onAdClicked(){i(this,Xe,"m",gt).call(this,v.AD_CLICKED)}showAd(e){const{container:t}=e||{};return i(this,et,"f")?i(this,it,"f")?"function"!=typeof i(this,it,"f").render?(console.warn("Vmax Ad Template does not have render method"),this.onAdError(me.RENDITION_FAILED)):(s(this,rt,t||i(this,Qe,"f"),"f"),i(this,rt,"f")?void i(this,Xe,"m",It).call(this):console.warn("No container to show ad")):this.onAdError(me.VMAX_AD_NOT_REGISTERED):this.onAdError(me.RENDITION_FAILED)}getVmaxAd(){return i(this,it,"f")}};class di extends Nt{constructor(e,t){super(),kt.add(this),Lt.set(this,void 0),bt.set(this,I.REPEAT),Mt.set(this,[]),Ut.set(this,-1),Vt.set(this,-1),xt.set(this,-1),Wt.set(this,!1),Kt.set(this,!1),jt.set(this,void 0),Ft.set(this,!1),Gt.set(this,!1),Yt.set(this,void 0),Bt.set(this,void 0),this.adEventListeners=new Map,Ht.set(this,void 0),qt.set(this,void 0),zt.set(this,(e=>{const t=i(this,Mt,"f").find((t=>t.ad===e));t&&(t.cached=!0,t.canPlay=!0)})),Zt.set(this,(e=>{const t=i(this,Mt,"f").find((t=>t.ad===e));t&&(t.canPlay=!1)})),s(this,jt,e,"f"),s(this,Lt,t,"f"),i(this,jt,"f").onCueOut(i(this,kt,"m",Jt).bind(this)),i(this,jt,"f").onCueIn(i(this,kt,"m",ai).bind(this))}addEventListener(e,t){return this.events.addEventListener(e,t),this}addBumperAdSpace(e){return e instanceof ci?(this.addAdSpace(e),i(this,Mt,"f").push({ad:e,type:"bumper",playing:!1,cached:!1,canPlay:!1}),this):this}addRegularAdSpace(e){return e instanceof ci?(this.addAdSpace(e),i(this,Mt,"f").push({ad:e,type:"regular",playing:!1,cached:!1,canPlay:!1}),this):this}setAdsRecurrence(e){return s(this,bt,e,"f"),this}setAdVolume(e){return"number"!=typeof e||e<0||e>1||s(this,qt,e,"f"),this}getAdVolume(){return i(this,qt,"f")}setMaxBreakDuration(e){return!r(e)||e<0||s(this,Ut,e,"f"),this}setMinimumBreakDuration(e){return!r(e)||e<0||s(this,Vt,e,"f"),this}process(){return i(this,kt,"m",Xt).call(this,i(this,Mt,"f").map((e=>e.ad))),super.process()}restorePlayerState(){i(this,jt,"f").mutePlayer(i(this,Ft,"f"))}pauseAd(){var e,t;if(!i(this,Kt,"f"))return;let s=-1!==i(this,xt,"f")?i(this,xt,"f"):i(this,Ht,"f");const n=null===(e=i(this,Mt,"f")[s])||void 0===e?void 0:e.ad;null==n||n.pauseAd(),null===(t=i(this,Yt,"f"))||void 0===t||t.pause()}resumeAd(){var e,t;if(!i(this,Kt,"f"))return;let s=-1!==i(this,xt,"f")?i(this,xt,"f"):i(this,Ht,"f");const n=null===(e=i(this,Mt,"f")[s])||void 0===e?void 0:e.ad;null==n||n.resumeAd(),null===(t=i(this,Yt,"f"))||void 0===t||t.startOrResume()}destroy(){var e,t;s(this,Ut,-1,"f"),s(this,Vt,-1,"f"),s(this,xt,-1,"f"),s(this,Wt,!1,"f"),s(this,Kt,!1,"f"),null===(e=i(this,Yt,"f"))||void 0===e||e.clear(),null===(t=i(this,Mt,"f"))||void 0===t||t.forEach((e=>{var t,i;e.playing=!1,null===(i=null===(t=null==e?void 0:e.ad)||void 0===t?void 0:t.getVmaxAd())||void 0===i||i.destroy()})),s(this,Mt,[],"f"),this.adEventListeners.clear(),console.debug("Ad Insertion Destroyed"),s(this,Gt,!0,"f")}}function li(e){const{eventName:t,payload:i={}}=e||{},s=new CustomEvent(t,{detail:i});window.dispatchEvent(s)}Lt=new WeakMap,bt=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,Gt=new WeakMap,Yt=new WeakMap,Bt=new WeakMap,Ht=new WeakMap,qt=new WeakMap,zt=new WeakMap,Zt=new WeakMap,kt=new WeakSet,Xt=function(e){0!==e.length&&e.forEach(((e,t)=>{e.addEventListener(Ai.AdEvents.AD_VOLUME_CHANGED,i(this,kt,"m",Qt).bind(this)),e.addEventListenerOnce(Ai.AdEvents.AD_READY,i(this,zt,"f").bind(this,e)),e.addEventListenerOnce(Ai.AdEvents.AD_ERROR,i(this,Zt,"f").bind(this,e))}))},Qt=function(e){const{adInfo:t}=e,{volume:i}=t;s(this,qt,i,"f")},$t=function(){this.build(),this.process()},Jt=function(e,t){var n;if(i(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(i(this,Kt,"f"))return;this.events.dispatchEvent(v.AD_INSERTION_START,{eventName:v.AD_INSERTION_START,duration:r}),console.debug("Ads Insertion started");0!==i(this,Mt,"f").filter((e=>e.cached&&e.canPlay)).length?(i(this,Lt,"f").style.display="block",s(this,Ft,i(this,jt,"f").muteState,"f"),s(this,qt,Number(!i(this,Ft,"f")),"f"),null===(n=i(this,jt,"f"))||void 0===n||n.mutePlayer(!0),s(this,xt,0,"f"),s(this,Wt,!1,"f"),s(this,Kt,!0,"f"),i(this,Ut,"f")>0&&(s(this,Yt,new Rt(i(this,kt,"m",ai).bind(this),i(this,Ut,"f")),"f"),i(this,Yt,"f").startOrResume()),i(this,kt,"m",ii).call(this)):console.warn("No cached Ads to Show")},ei=function(e,t,i){const s=i.bind(this,e);this.adEventListeners.set(e,Object.assign(Object.assign({},this.adEventListeners.get(e)),{[t]:s})),e.addEventListenerOnce(t,s)},ti=function(e,t){const i=this.adEventListeners.get(e);i&&i[t]&&(e.removeEventListener(t,i[t]),delete i[t])},ii=function e(){var t;if(i(this,Kt,"f"))if(i(this,xt,"f")i(this,kt,"m",ei).call(this,e,Ai.AdEvents.AD_CLOSED,i(this,kt,"m",ri).bind(this,n))),0),s(this,Ht,i(this,xt,"f"),"f")}else n.playing=!1,i(this,xt,"f")e.cached&&e.canPlay));!i(this,Wt,"f")&&0===t.length&&i(this,bt,"f")===I.REPEAT&&i(this,Mt,"f")[i(this,xt,"f")].ad.isAdCached?i(this,kt,"m",ei).call(this,e.ad,Ai.AdEvents.AD_RENDERED,i(this,kt,"m",ni).bind(this,e.ad)):!i(this,Wt,"f")&&0===t.length&&i(this,Mt,"f")[i(this,xt,"f")].ad.isAdCached?i(this,kt,"m",ei).call(this,e.ad,Ai.AdEvents.AD_CLOSED,i(this,kt,"m",ai).bind(this)):i(this,Wt,"f")||0!==t.length||!1!==e.playing||i(this,kt,"m",ai).call(this)},ni=function e(t){if(i(this,bt,"f")!==I.REPEAT)return;const n=i(this,Mt,"f").filter((e=>"regular"===e.type&&!e.cached&&e.canPlay));i(this,kt,"m",ei).call(this,t,Ai.AdEvents.AD_RENDERED,i(this,kt,"m",e).bind(this,t));const r=Pt();n.forEach((e=>{r.addAdSpace(e.ad)})),r.build(),Ai.process(r),s(this,xt,-1,"f"),i(this,kt,"m",Xt).call(this,n.map((e=>e.ad)))},ri=function(e){var t;!i(this,Wt,"f")&&e.playing&&(e.playing=!1,i(this,kt,"m",ti).call(this,e.ad,Ai.AdEvents.AD_CLOSED),s(this,xt,(t=i(this,xt,"f"),++t),"f"),i(this,xt,"f"){e.playing=!1}));let r=-1!==i(this,xt,"f")?i(this,xt,"f"):i(this,Ht,"f");if(i(this,xt,"f"){}))}this.events.dispatchEvent(v.AD_INSERTION_END,{eventName:v.AD_INSERTION_END}),i(this,Lt,"f").style.display="none",s(this,Kt,!1,"f"),null===(n=i(this,jt,"f"))||void 0===n||n.mutePlayer(!i(this,qt,"f")),i(this,kt,"m",$t).call(this)},function(e){e.READY="VmaxAdManagerReady",e.FAILED="VmaxAdManagerFailed",e.INITIALIZED="VmaxAdManagerInitialized"}(oi||(oi={}));var hi,ui=oi;!function(e){e[e.UNKNOWN=-1]="UNKNOWN",e[e.PORTRAIT=1]="PORTRAIT",e[e.LANDSCAPE=2]="LANDSCAPE",e[e.ADAPTIVE=3]="ADAPTIVE"}(hi||(hi={}));var fi=hi;window.VmaxAdEvents=class{static handleClick(t){const{deepLinkUrl:i="",linkFallback:s=""}=t;e(i,s)}};var Ai=Object.freeze({Registry:ce.getInstance,getUser:pe.getInstance,getSite:de.getInstance,getApp:C.getInstance,getDevice:ne.getInstance,getSourceConfiguration:()=>ue.instance,initialize:function(e){return t(this,void 0,void 0,(function*(){try{const{ACCOUNT_KEY:t,APP_ID:i,SDK_INITIALIZED:s,IS_APP:r,KEY_ID:o,PRIVATE_KEY:c}=g;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),p=a(A),m=n(h),I=n(u);p&&A&&console.warn("IsApp is set to true, all Site Level targeting will be ignored"),p&&!A&&console.warn("IsApp is set to false, all App Level targeting will be ignored");return E&&v&&p&&m&&I?(R.set({[t]:d,[i]:l,[r]:A,[c]:h,[o]:u}),yield ue.getInstance(),R.set(s,!0),setTimeout((()=>li({eventName:ui.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(me.INVALID_INITIALIZE_OPTION.message))}catch(e){return console.error("Error in initialize",e),setTimeout((()=>li({eventName:ui.FAILED})),0),Promise.reject(e)}}))},createAdSpace:function(e){return new ci(e)},createAdspotRequestBuilder:Pt,createAdsInsertionRequestBuilder:function({pluginInstance:e,adsContainer:t}){return new di(e,t)},process:Ct,AdEvents:v,Orientation:fi,AdsRecurrence:I,get isApp(){return R.get(g.IS_APP)}});return setTimeout((()=>li({eventName:ui.READY})),0),Ai}));